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AAPD,KADb,SAATA,EACgD,YAAc,MAAe,qBAATA,GAAgCC,EAAuB,GAAX,YAAiBF,EAAS,SAAW,MAAME,IAE9K,OACEjJ,IAAAA,cAAA,OAAAuJ,OAAAC,OAAA,GACML,EAAI,CACRF,UAAWK,EACXJ,MAAKlE,EAAAA,EAAA,GACAkE,GAAK,IAERL,MAAO,GAA0B,QAA1BF,EAAGN,EAAiBQ,UAAM,IAAAF,EAAAA,EAAI,KAErCG,OAAQ,GAA2B,QAA3BF,EAAGP,EAAiBS,UAAO,IAAAF,EAAAA,EAAI,KACvCa,aAAc","sources":["webpack://mattressfirm/./src/Utilities/constants.ts?8bdf","webpack://mattressfirm/./src/Utilities/get-bv-attributes.ts?f55a","webpack://mattressfirm/./src/Utilities/get-inventory-quantity.tsx?d0aa","webpack://mattressfirm/./src/Utilities/get-rating.tsx?7b67","webpack://mattressfirm/./src/Utilities/mfrm-buybox-utils.ts?ef8b","webpack://mattressfirm/./src/actions/get-sm-inventory-status.action.ts?cb72","webpack://mattressfirm/./src/actions/product-compare-buybox-state-sharing.ts?5126","webpack://mattressfirm/./src/data-actions/utilities/utils.ts?7452","webpack://mattressfirm/./src/themes/mattressfirm/custom-components/CustomSkeleton/index.tsx?ef9d"],"sourcesContent":["export const variantQueryStringName = 'variantid';","import { AttributeValue } from '@msdyn365-commerce/retail-proxy';\r\n\r\nexport const getBVAttributeValues = (attributeValues: AttributeValue[] | undefined, key: string): number => {\r\n const value = +(attributeValues?.find(attr => attr.Name?.trim() === key)?.TextValue || 0);\r\n return Math.round(value * 10) / 10;\r\n};\r\n\r\nexport const getBVAttributeValuesUnbxd = (attributeValues: any | undefined, key: string): number => {\r\n const value = +(attributeValues[key] ?? 0);\r\n return Math.round(value * 10) / 10;\r\n};\r\n","import { IAny, ICoreContext, IGeneric } from '@msdyn365-commerce/core';\r\nimport { IMFICLDeliveryScheduleParameters } from '../actions/CoreProductDataServiceEntities.g';\r\nimport getATPInventoryStatusAction, { GetATPInventoryStatusInput } from '../actions/get-sm-inventory-status.action';\r\n\r\nconst _getInventoryQuantity = async (\r\n request: IMFICLDeliveryScheduleParameters,\r\n context: ICoreContext>,\r\n isCached?: boolean\r\n) => {\r\n if (request) {\r\n const getATPInventoryStatusInput = new GetATPInventoryStatusInput(request, isCached);\r\n try {\r\n const result = await getATPInventoryStatusAction(getATPInventoryStatusInput, context.actionContext);\r\n if (result) {\r\n return result;\r\n }\r\n } catch (error) {\r\n console.log('Error', error);\r\n }\r\n }\r\n return null;\r\n};\r\n\r\nexport default _getInventoryQuantity;\r\n","import { RatingComponent } from '@msdyn365-commerce/components';\r\nimport {\r\n ICoreContext\r\n} from '@msdyn365-commerce/core';\r\nimport {\r\n format\r\n} from '@msdyn365-commerce-modules/utilities';\r\nimport React from 'react';\r\nexport function renderRating(\r\n context: ICoreContext,\r\n typeName: string,\r\n id: string,\r\n avgRating?: number,\r\n totalRatings?: number,\r\n ariaLabel?: string\r\n): JSX.Element | null {\r\n if (avgRating && avgRating !== 0) {\r\n const numRatings = (totalRatings && totalRatings.toString()) || '0';\r\n const ratingAriaLabel = getRatingAriaLabel(avgRating, ariaLabel);\r\n\r\n return (\r\n \r\n );\r\n } else {\r\n return null;\r\n }\r\n}\r\nfunction getRatingAriaLabel(rating?: number, ratingAriaLabel?: string): string {\r\n if (rating && ratingAriaLabel) {\r\n const roundedRating = rating.toFixed(2);\r\n return format(ratingAriaLabel || '', roundedRating, '5');\r\n }\r\n return '';\r\n}","import { IActionContext, ICoreContext } from '@msdyn365-commerce/core';\r\nimport { getActivePricesAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\r\nimport dayjs from 'dayjs';\r\nimport Cookies from 'universal-cookie';\r\nimport { IMFIATPInventoryStatusEntity, IMFIATPInventoryStatusResponse, IMFICartLine, IMFICLDeliveryScheduleParameters } from '../actions/CoreProductDataServiceEntities.g';\r\nimport { IBuyboxGetDimensionPricingActionData } from '../data-actions/buybox-get-dimension-pricing-action';\r\nimport { IBuyboxGetDimensionVariantAvailabilityActionData } from '../data-actions/buybox-get-dimension-variants-availability-action';\r\nimport { IBuyboxViewPropsExtended, IMFIATPInventoryStatusResponseExtended } from '../modules/mfrm-buybox/types';\r\nimport { IMfrmBuyboxProps } from '../modules/mfrm-buybox/mfrm-buybox.props.autogenerated';\r\nimport { IMfrmBuyBoxData } from '../modules/mfrm-buybox/mfrm-buybox.view';\r\nimport _getDeliveryByMessage from './get-delivery-by-message';\r\nimport _getEyebrowMessage from './get-eyebrow-message';\r\nimport _getInventoryQuantity from './get-inventory-quantity';\r\n// tslint:disable-next-line: max-line-length no-any\r\nexport const _coreProductATPCall = async (\r\n props: IBuyboxViewPropsExtended & IMfrmBuyboxProps,\r\n setCoreProductATPData: React.Dispatch,\r\n recordId: number,\r\n itemId: string | undefined,\r\n setATPCallMessage: React.Dispatch,\r\n setIsAtpCallReturned: React.Dispatch,\r\n isCached?: boolean\r\n) => {\r\n const { context } = props;\r\n const cookies = new Cookies();\r\n const zipcode = cookies.get('zip_code');\r\n if (zipcode === \"\" || zipcode === undefined) {\r\n return;\r\n }\r\n const itemLinesArray = [];\r\n if (props.data.product.result) {\r\n const itemLines: IMFICartLine = {\r\n ItemId: itemId,\r\n Quantity: 1,\r\n VariantRecordId: recordId?.toString()\r\n };\r\n\r\n itemLinesArray.push(itemLines);\r\n const currentDate = Date.now();\r\n const requestBody: IMFICLDeliveryScheduleParameters = {\r\n InventoryType: 'Delivery',\r\n Weeks: props.context.app.config.weeksPDPforATPCall,\r\n StoreId: '',\r\n Page: 'pdp',\r\n RequestedDate: dayjs(currentDate).format('MM/DD/YYYY'),\r\n ZipCode: zipcode,\r\n ItemLines: itemLinesArray\r\n };\r\n await _getDeliveryByMessage(requestBody, context, isCached)\r\n .then(result => {\r\n setIsAtpCallReturned(true);\r\n if (result !== undefined && result?.ATPInventoryData && result?.ATPInventoryData.length > 0) {\r\n setCoreProductATPData(result?.ATPInventoryData);\r\n } else {\r\n // VSI Customization - START\r\n setCoreProductATPData([]);\r\n // VSI Customization - End\r\n }\r\n setATPCallMessage(result?.Message);\r\n })\r\n .catch(e => {\r\n console.log('Error', e);\r\n });\r\n }\r\n};\r\n\r\nexport const _coreProductATPCallForInventoryStatus = async (\r\n props: IBuyboxViewPropsExtended & IMfrmBuyboxProps,\r\n recordId: number,\r\n itemId: string | undefined,\r\n allVariants: IBuyboxGetDimensionVariantAvailabilityActionData[],\r\n index: number\r\n) => {\r\n const { context } = props;\r\n // this commented code will removed when general data appeared\r\n const cookies = new Cookies();\r\n const zipcode = cookies.get('zip_code');\r\n if (zipcode === \"\" || zipcode === undefined) {\r\n return;\r\n }\r\n const itemLinesArray = [];\r\n if (props.data.product.result) {\r\n const itemLines: IMFICartLine = {\r\n ItemId: itemId,\r\n Quantity: 1,\r\n VariantRecordId: recordId?.toString()\r\n };\r\n itemLinesArray.push(itemLines);\r\n const currentDate = Date.now();\r\n const requestBody: IMFICLDeliveryScheduleParameters = {\r\n InventoryType: 'Delivery',\r\n Weeks: props.context.app.config.weeksPDPforATPCall,\r\n StoreId: '',\r\n Page: 'pdp',\r\n RequestedDate: dayjs(currentDate).format('MM/DD/YYYY'),\r\n ZipCode: zipcode, // '77047',\r\n ItemLines: itemLinesArray\r\n };\r\n const getInventoryQuantity = _getInventoryQuantity(requestBody, context);\r\n getInventoryQuantity.then((result) => {\r\n if (result !== undefined && result?.ATPInventoryStatusData && result?.ATPInventoryStatusData.length > 0) {\r\n const coreProductAtpData = result?.ATPInventoryStatusData;\r\n coreProductAtpData?.length && coreProductAtpData.map((item: IMFIATPInventoryStatusEntity) => {\r\n // TODO: remove console logs after testing\r\n if (item.Available === 'YES' && item.Quantity !== undefined && parseInt(item.Quantity, 10) > 0) {\r\n allVariants[index].isAvailable = true;\r\n return true;\r\n }\r\n allVariants[index].isAvailable = false;\r\n return false;\r\n });\r\n }\r\n }).catch((e) => {\r\n console.log('Error', e);\r\n });\r\n }\r\n};\r\n\r\nexport const _getActivePrices = async (\r\n pricingData: IBuyboxGetDimensionPricingActionData[],\r\n ctx: IActionContext\r\n): Promise => {\r\n const date = new Date();\r\n const productIds: number[] = [];\r\n for (let i = 0;i < pricingData.length;i++) {\r\n productIds.push(pricingData[i].productId);\r\n }\r\n await getActivePricesAsync(\r\n { callerContext: ctx },\r\n { ChannelId: ctx.requestContext.apiSettings.channelId, CatalogId: ctx.requestContext.apiSettings.catalogId },\r\n productIds,\r\n date,\r\n null,\r\n [],\r\n true\r\n ).then(dimPricesResult => {\r\n dimPricesResult?.map((item, index) => {\r\n pricingData[index].discountAmount = item.DiscountAmount;\r\n });\r\n });\r\n return pricingData;\r\n};\r\n\r\nexport const _smallParcelProductATPCallForInventoryStatus = async (\r\n props: IBuyboxViewPropsExtended & IMfrmBuyboxProps,\r\n recordId: number,\r\n itemId: string | undefined,\r\n // tslint:disable-next-line: no-any\r\n SetoutOfStockSmallParcelState: React.Dispatch,\r\n isCached?: boolean\r\n) => {\r\n const { context } = props;\r\n // this commented code will removed when general data appeared\r\n const cookies = new Cookies();\r\n const zipcode = cookies.get('zip_code');\r\n if (zipcode === \"\" || zipcode === undefined) {\r\n return;\r\n }\r\n const itemLinesArray = [];\r\n if (props.data.product.result) {\r\n const itemLines: IMFICartLine = {\r\n ItemId: itemId,\r\n Quantity: 1,\r\n VariantRecordId: recordId.toString()\r\n };\r\n itemLinesArray.push(itemLines);\r\n const currentDate = Date.now();\r\n const requestBody: IMFICLDeliveryScheduleParameters = {\r\n InventoryType: 'Delivery',\r\n Weeks: props.context.app.config.weeksPDPforATPCall,\r\n StoreId: '',\r\n Page: 'pdp',\r\n RequestedDate: dayjs(currentDate).format('MM/DD/YYYY'),\r\n ZipCode: zipcode, // '77047',\r\n ItemLines: itemLinesArray\r\n };\r\n await _getInventoryQuantity(requestBody, context, isCached)\r\n .then(result => {\r\n if (result !== undefined && result?.ATPInventoryStatusData && result?.ATPInventoryStatusData.length > 0) {\r\n const coreProductAtpData = result?.ATPInventoryStatusData;\r\n coreProductAtpData &&\r\n coreProductAtpData.length &&\r\n coreProductAtpData.map((item: IMFIATPInventoryStatusEntity) => {\r\n // TODO: remove console logs after testing\r\n if (item.Available === 'YES' && item.Quantity !== undefined && parseInt(item.Quantity, 10) > 0) {\r\n // allVariants[index].isAvailable = true;\r\n SetoutOfStockSmallParcelState(false);\r\n return true;\r\n } else {\r\n SetoutOfStockSmallParcelState(true);\r\n }\r\n // allVariants[index].isAvailable = false;\r\n return false;\r\n });\r\n }\r\n })\r\n .catch(e => {\r\n console.log('Error', e);\r\n });\r\n }\r\n};\r\n\r\nexport const _coreProductATPCallForInventoryStatusForAllVariants = async (\r\n props: IMfrmBuyboxProps,\r\n recordIds: number[],\r\n itemId: string | undefined,\r\n allVariants: IBuyboxGetDimensionVariantAvailabilityActionData[]\r\n): Promise => {\r\n const { context } = props;\r\n // this commented code will removed when general data appeared\r\n const cookies = new Cookies();\r\n const zipcode: any = cookies.get('zip_code');\r\n if (zipcode === '' || zipcode === undefined) {\r\n return null;\r\n }\r\n const itemLinesArray = [];\r\n if (props.data.product.result) {\r\n for (let ridIter = 0;ridIter < recordIds.length;ridIter++) {\r\n const itemLines: IMFICartLine = {\r\n ItemId: itemId,\r\n Quantity: 1,\r\n VariantRecordId: recordIds[ridIter].toString()\r\n };\r\n itemLinesArray.push(itemLines);\r\n }\r\n\r\n const currentDate = Date.now();\r\n const requestBody: IMFICLDeliveryScheduleParameters = {\r\n InventoryType: 'Delivery',\r\n Weeks: props.context.app.config.weeksPDPforATPCall,\r\n StoreId: '',\r\n Page: 'pdp',\r\n RequestedDate: dayjs(currentDate).format('MM/DD/YYYY'),\r\n ZipCode: zipcode, // '77047',\r\n ItemLines: itemLinesArray\r\n };\r\n\r\n const result: IMFIATPInventoryStatusResponse | null = await _getInventoryQuantity(requestBody, context, true);\r\n if (result !== undefined && result?.ATPInventoryStatusData && result?.ATPInventoryStatusData.length > 0) {\r\n const coreProductAtpData = result?.ATPInventoryStatusData;\r\n coreProductAtpData && coreProductAtpData.length && coreProductAtpData.map((item: IMFIATPInventoryStatusEntity) => {\r\n\r\n for (let iter = 0;iter < allVariants.length;iter++) {\r\n // TODO: remove console logs after testing\r\n if (item.Available === 'YES' && item.Quantity !== undefined && parseInt(item.Quantity, 10) > 0 && allVariants[iter].variantID.toString() === item.VariantRecordId) {\r\n allVariants[iter].isAvailable = true;\r\n break;\r\n }\r\n else if (item.Available === 'NO' && allVariants[iter].variantID.toString() === item.VariantRecordId) {\r\n allVariants[iter].isAvailable = false;\r\n break;\r\n }\r\n }\r\n });\r\n }\r\n const finalResult: IMFIATPInventoryStatusResponseExtended = {\r\n ...result,\r\n zipCode: requestBody?.ZipCode\r\n };\r\n return finalResult;\r\n }\r\n return null;\r\n};\r\n\r\nexport const _smallParcelProductATPBooleanStatus = async (\r\n recordId: number,\r\n itemId: string | undefined,\r\n weeksPDPforATPCall: number | undefined,\r\n context: ICoreContext<{ [x: string]: any; }>\r\n // tslint:disable-next-line: no-any\r\n): Promise => {\r\n // this commented code will removed when general data appeared\r\n const cookies = new Cookies();\r\n const zipcode = cookies.get('zip_code');\r\n if (zipcode === \"\" || zipcode === undefined) {\r\n return false;\r\n }\r\n const itemLinesArray = [];\r\n const itemLines: IMFICartLine = {\r\n ItemId: itemId,\r\n Quantity: 1,\r\n VariantRecordId: recordId.toString()\r\n };\r\n itemLinesArray.push(itemLines);\r\n const currentDate = Date.now();\r\n const requestBody: IMFICLDeliveryScheduleParameters = {\r\n InventoryType: 'Delivery',\r\n Weeks: weeksPDPforATPCall ?? 6,\r\n StoreId: '',\r\n Page: 'pdp',\r\n RequestedDate: dayjs(currentDate).format('MM/DD/YYYY'),\r\n ZipCode: zipcode, // '77047',\r\n ItemLines: itemLinesArray\r\n };\r\n return _getInventoryQuantity(requestBody, context, true)\r\n .then(result => {\r\n if (result !== undefined && result?.ATPInventoryStatusData && result?.ATPInventoryStatusData.length > 0) {\r\n const coreProductAtpData = result?.ATPInventoryStatusData[0];\r\n if (coreProductAtpData.Available === 'YES' && coreProductAtpData.Quantity !== undefined && parseInt(coreProductAtpData.Quantity, 10) > 0) {\r\n return false;\r\n } else {\r\n return true;\r\n }\r\n } else {\r\n return false;\r\n }\r\n })\r\n .catch(e => {\r\n console.log('Error', e);\r\n return false;\r\n });\r\n};","/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License. See License.txt in the project root for license information.\r\n *--------------------------------------------------------------------------------------------*/\r\n\r\nimport * as Msdyn365 from '@msdyn365-commerce/core';\r\nimport { mFIATPInventoryStatusAsync } from './CoreProductDataActionExtension.g';\r\nimport { IMFIATPInventoryStatusResponse, IMFICLDeliveryScheduleParameters } from './CoreProductDataServiceEntities.g';\r\n\r\n/**\r\n * Small parcel getInventory status Input Action\r\n */\r\n\r\nexport class GetATPInventoryStatusInput implements Msdyn365.IActionInput {\r\n // Construct the input needed to run the action\r\n public input: IMFICLDeliveryScheduleParameters;\r\n public isCached?: boolean;\r\n constructor(input: IMFICLDeliveryScheduleParameters, isCached: boolean = true) {\r\n this.input = input;\r\n this.isCached = isCached;\r\n }\r\n\r\n // Determine if the results of this get action should cache the results and if so provide\r\n // a cache object type and an appropriate cache key\r\n public getCacheKey = () => {\r\n const key = Array.prototype.map.call(this.input.ItemLines, (item) => { return item.VariantRecordId; }).sort().join(\",\");\r\n return `Get-Inventory-Status${this.input.ZipCode}-${this.input.ItemLines![0].ItemId}-${key}-${\r\n this.input?.Weeks\r\n }-${this.input?.RequestedDate}`;\r\n };\r\n // public getCacheKey = () => 'do';\r\n public getCacheObjectType = () => 'GetATPInventoryStatusResult';\r\n public dataCacheType = (): Msdyn365.CacheType => (this.isCached ? 'request' : 'none');\r\n}\r\n\r\n// Create a data model here or import one to capture the response of the action\r\n\r\n/**\r\n * Use this function to create the input required to make the action call\r\n */\r\n// const createInput = (args: Msdyn365.ICreateActionContext): Msdyn365.IActionInput => {\r\n// return new GetDeliveryMessageInput();\r\n// };\r\n\r\n/**\r\n * Use this function to call your action and process the results as needed\r\n */\r\nasync function getATPInventoryStatusAction(\r\n request: GetATPInventoryStatusInput,\r\n ctx: Msdyn365.IActionContext\r\n): Promise {\r\n if (request.input) {\r\n try {\r\n const result = await mFIATPInventoryStatusAsync({ callerContext: ctx }, request.input);\r\n if (result) {\r\n return result;\r\n }\r\n } catch (error) {\r\n console.log('Error', error);\r\n }\r\n }\r\n return null;\r\n}\r\n\r\nexport default Msdyn365.createObservableDataAction({\r\n action: >getATPInventoryStatusAction,\r\n // Give your data action a unique id\r\n id: 'GetATPInventoryStatus'\r\n // input: createInput\r\n // Uncomment the below line if this is a meant to be a batched data action\r\n // isBatched: true\r\n});\r\n","/*!\r\n * Copyright (c) Microsoft Corporation.\r\n * All rights reserved. See LICENSE in the project root for license information.\r\n */\r\n\r\nimport * as Msdyn365 from '@msdyn365-commerce/core';\r\nimport { observable } from 'mobx';\r\n/**\r\n * SelectYourFoundation Input Action\r\n */\r\nexport class ProductCompareBuyboxStateSharing implements Msdyn365.IActionInput {\r\n @observable public zipCode?: string | undefined;\r\n // Construct the input needed to run the action\r\n constructor(zipCode: string | undefined) {\r\n this.zipCode = zipCode;\r\n }\r\n\r\n // Determine if the results of this get action should cache the results and if so provide\r\n // a cache object type and an appropriate cache key\r\n public getCacheKey = () => `ProductCompareBuyboxStateSharing`;\r\n public getCacheObjectType = () => 'ProductCompareBuyboxStateSharing';\r\n public dataCacheType = (): Msdyn365.CacheType => 'request';\r\n}\r\n\r\n// Create a data model here or import one to capture the response of the action\r\nexport interface ISelectYourFoundationData {\r\n zipCode: string | undefined;\r\n}\r\n\r\n/**\r\n * Use this function to create the input required to make the action call\r\n */\r\nconst createInput = (args: Msdyn365.ICreateActionContext): Msdyn365.IActionInput => {\r\n return new ProductCompareBuyboxStateSharing(args?.config?.zipCode);\r\n};\r\n\r\n/**\r\n * Use this function to call your action and process the results as needed\r\n */\r\nasync function action(input: ProductCompareBuyboxStateSharing, ctx: Msdyn365.IActionContext): Promise {\r\n // const apiSettings = Msdyn365.msdyn365Commerce.apiSettings;\r\n\r\n // Uncomment the below line to get the value from a service\r\n // const response = await Msdyn365.sendRequest('/get/example/id/1', 'get');\r\n return { zipCode: input.zipCode };\r\n}\r\n\r\nexport default Msdyn365.createObservableDataAction({\r\n action: >action,\r\n // Give your data action a unique id\r\n id: 'ProductCompareBuyboxStateSharing',\r\n input: createInput\r\n // Uncomment the below line if this is a meant to be a batched data action\r\n // isBatched: true\r\n});\r\n","/*--------------------------------------------------------------\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * See License.txt in the project root for license information.\r\n *--------------------------------------------------------------*/\r\n\r\nimport { IAny, ICommerceApiSettings, ICoreContext, ICreateActionContext, IGeneric, IRequestContext } from '@msdyn365-commerce/core';\r\nimport {\r\n AsyncResult, CartLine, CommerceListLine, ProductDimension,\r\n ProductDimensionType, ProductSearchResult, SimpleProduct\r\n} from '@msdyn365-commerce/retail-proxy';\r\n\r\nimport { ProductDetailsCriteria, InventoryLevels, ArrayExtensions } from '@msdyn365-commerce-modules/retail-actions';\r\nimport { variantQueryStringName } from '../../Utilities/constants';\r\n// import { parseSearchData } from '@msdyn365-commerce-modules/retail-actions/src/utilities/input-data-parser';\r\n\r\nexport const wrapInResolvedAsyncResult = (input: T | null | undefined): AsyncResult => {\r\n return >{\r\n status: 'SUCCESS',\r\n result: input,\r\n metadata: {}\r\n };\r\n};\r\n\r\nexport const wrapInRejectedAsyncResult = (input: T | null | undefined): AsyncResult => {\r\n return >{\r\n status: 'FAILED',\r\n result: input,\r\n metadata: {}\r\n };\r\n};\r\n\r\n\r\n/**\r\n * Utility function to extract the active productId in the following priority:\r\n * First query param (productId), then UrlToken (itemId), then module config.\r\n * @param inputData - The Action Input data.\r\n * @returns Productid or undefined.\r\n */\r\nexport const getSelectedProductIdFromActionInput = (inputData: ICreateActionContext>): string | undefined => {\r\n const context = inputData.requestContext;\r\n const variantId = context.app.config.queryBasedVariantSelection ? getQueryParamsFromQueryByName(context.url.requestUrl, variantQueryStringName) : undefined;\r\n\r\n if (variantId) {\r\n return variantId;\r\n } else if (context.query?.productId) {\r\n return context.query.productId;\r\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Exsiting code.\r\n } else if (context.urlTokens && inputData.requestContext.urlTokens.itemId && inputData.requestContext.urlTokens.pageType === 'Product') {\r\n return context.urlTokens.itemId;\r\n } else if (inputData && inputData.config && inputData.config.productId) {\r\n return inputData.config.productId;\r\n }\r\n return undefined;\r\n};\r\n\r\nexport const getQueryParamsFromQueryByName = (inputUrl: URL, queryParamName: string) => {\r\n const urlWithIgnoredCase = new URL(inputUrl.toString().toLocaleLowerCase());\r\n const urlParameters = urlWithIgnoredCase.searchParams;\r\n const value = urlParameters.get(queryParamName.trim().toLocaleLowerCase());\r\n if (!value || Number.isNaN(Number(value))) {\r\n return undefined;\r\n }\r\n return value;\r\n};\r\n/**\r\n * Generates a Image URL based on data return from retail server.\r\n * @param imageUrl The image url returned by Retail Server.\r\n * @param ctx The request context.\r\n * @param apiSettings\r\n */\r\nexport const generateImageUrl = (imageUrl: string | undefined, apiSettings: ICommerceApiSettings): string | undefined => {\r\n if (imageUrl) {\r\n // Images hosted in CMS include schema\r\n if (imageUrl.startsWith('http')) {\r\n return imageUrl;\r\n }\r\n\r\n // Images hosted in Retail Server must be encoded and joined with the base image url\r\n return apiSettings.baseImageUrl + encodeURIComponent(imageUrl);\r\n }\r\n\r\n // D365Commerce.telemetry.warning(`Unable to generate a proper Image URL for Product: ${product.RecordId}`);\r\n return undefined;\r\n\r\n};\r\n\r\n/**\r\n * Represents app configuration for dimensions.\r\n */\r\nexport interface IDimensionsConfig {\r\n dimensionsAsSwatchType?: DimensionTypes[];\r\n dimensionsInProductCard?: DimensionTypes[];\r\n inventoryLevel?: InventoryLevels;\r\n dimensionToPreSelectInProductCard?: DimensionTypes;\r\n}\r\n\r\n/**\r\n * Represents app configuration for dimensions.\r\n */\r\nexport interface IDimensionsApp {\r\n config: IDimensionsConfig;\r\n}\r\n\r\n/**\r\n * Represents product dimension types.\r\n */\r\nexport enum DimensionTypes {\r\n none = 'none',\r\n color = 'color',\r\n configuration = 'configuration',\r\n size = 'size',\r\n style = 'style'\r\n}\r\n\r\n/**\r\n * Defines display configuration types.\r\n */\r\nexport enum DimensionSwatchDisplayTypes {\r\n default = 'default',\r\n productCard = 'productCard'\r\n}\r\n\r\n/**\r\n * Checks if rendering the particular dimensions is allowed.\r\n * @param dimensionType - Dimension to be displayed.\r\n * @param context - Core application context.\r\n * @param displayType - The swatch location, the component from which it comes from.\r\n * @returns Updates the state with new product page url.\r\n */\r\nexport const checkIfShouldDisplayAsSwatch = (\r\n dimensionType: DimensionTypes,\r\n context: ICoreContext,\r\n displayType: DimensionSwatchDisplayTypes = DimensionSwatchDisplayTypes.default): boolean => {\r\n\r\n // Additional checks for the product card since it has a separate config setting.\r\n if (displayType === DimensionSwatchDisplayTypes.productCard) {\r\n const dimensionsToDisplayOnProductCard = context.app.config.dimensionsInProductCard;\r\n if (!ArrayExtensions.hasElements(dimensionsToDisplayOnProductCard) ||\r\n dimensionsToDisplayOnProductCard.includes(DimensionTypes.none) ||\r\n !dimensionsToDisplayOnProductCard.includes(dimensionType)) {\r\n return false;\r\n }\r\n }\r\n\r\n const dimensionsToDisplayAsSwatch = context.app.config.dimensionsAsSwatchType;\r\n return ArrayExtensions.hasElements(dimensionsToDisplayAsSwatch) &&\r\n !dimensionsToDisplayAsSwatch.includes(DimensionTypes.none) &&\r\n dimensionsToDisplayAsSwatch.includes(dimensionType);\r\n};\r\n\r\n/**\r\n * Generates an image URL for a swatch.\r\n * @param imageUrl - The image url returned by Retail Server.\r\n * @param apiSettings - The request context.\r\n * @returns Full image url.\r\n */\r\nexport const generateSwatchImageUrl = (imageUrl: string, apiSettings: ICommerceApiSettings): string => {\r\n if (imageUrl.startsWith('http')) {\r\n return imageUrl;\r\n }\r\n\r\n return apiSettings.baseImageUrl + encodeURIComponent(imageUrl);\r\n};\r\n\r\n/**\r\n * Generates a Image URL for a product based on data return from retail server.\r\n * @param product The Product returned by Retail Server.\r\n * @param ctx The request context.\r\n * @param apiSettings\r\n */\r\nexport const generateProductImageUrl = (\r\n product: SimpleProduct | ProductSearchResult,\r\n apiSettings: ICommerceApiSettings\r\n): string | undefined => {\r\n return generateImageUrl(product.PrimaryImageUrl, apiSettings);\r\n};\r\n\r\n/**\r\n * Creates a CartLine object from the passed data.\r\n * @param product The product.\r\n * @param quantity The quantity.\r\n * @param catalogId The catalog.\r\n */\r\nexport const buildCartLine = (product: SimpleProduct, quantity?: number, catalogId?: number): CartLine => {\r\n return {\r\n CatalogId: catalogId || 0,\r\n Description: product.Description,\r\n\r\n // TODO: Investigate this value and what it represents\r\n EntryMethodTypeValue: 3,\r\n ItemId: product.ItemId,\r\n ProductId: product.RecordId,\r\n Quantity: quantity || 1,\r\n TrackingId: '',\r\n UnitOfMeasureSymbol: product.DefaultUnitOfMeasure\r\n };\r\n};\r\n\r\n/**\r\n * Creates a CommerceListLine (also know as WishlistLine) object from the passed data.\r\n * @param productId The RecordId of the Product to be added.\r\n * @param customerId The account number of the customer.\r\n * @param wishlistId The Id of the commerce list.\r\n */\r\nexport const buildWishlistLine = (productId: number, customerId: string, wishlistId: number): CommerceListLine => {\r\n return {\r\n CommerceListId: wishlistId,\r\n ProductId: productId,\r\n CustomerId: customerId\r\n };\r\n};\r\n\r\n/**\r\n * Utility function to prepare the product details criteria before getting full product:\r\n * @param inputData The Action Input data\r\n */\r\nexport const getProductDetailsCriteriaFromActionInput = (inputData: ICreateActionContext>): ProductDetailsCriteria => {\r\n if (inputData && inputData.config) {\r\n return {\r\n getPrice: !inputData.config.hidePrice,\r\n getRating: !inputData.config.hideRating\r\n };\r\n }\r\n return {\r\n getPrice: true,\r\n getRating: true\r\n };\r\n};\r\n\r\n/**\r\n * Transforms search text into the expected 'search terms' format, expected by refiner APIs.\r\n * @param searchText Free-form text used for searching for products or categories of products.\r\n */\r\nexport const ensureSearchTextIsFormedProperly = (searchText: string): string => {\r\n const prefix = searchText.startsWith('\\'') ? '' : '\\'';\r\n const suffix = searchText.endsWith('\\'') ? '' : '\\'';\r\n return `${prefix}${searchText}${suffix}`;\r\n};\r\n\r\nexport const ensureSafeSearchText = (searchText: string): string => {\r\n return searchText?.replace(/[^\\d\\sA-Za-z]+/g, '');\r\n};\r\n\r\nexport const buildCacheKey = (base: string, apiSettings: ICommerceApiSettings, locale?: string): string => {\r\n return `${base}-chanId:${apiSettings.channelId}-catId:${apiSettings.catalogId}${locale ? `-${locale}` : ''}`;\r\n};\r\n\r\nexport const buildCacheKeyWithUrlTokens = (base: string, requestContext: IRequestContext): string => {\r\n const urlTokens = requestContext.urlTokens;\r\n const defaultCacheKey = buildCacheKey(base, requestContext.apiSettings, requestContext.locale);\r\n return urlTokens ? `${defaultCacheKey}-${urlTokens.itemId}-${urlTokens.recordId}-${urlTokens.pageType}` : defaultCacheKey;\r\n};\r\n\r\n/**\r\n * Generates a key from set of arguments as inputs.\r\n *\r\n * @param args Argument list of pivots to generate key from.\r\n * @param handler Handler function for null/undefined values.\r\n */\r\n\r\ntype TKeyTypes = string | number | boolean | null | undefined;\r\ninterface IGenerateKeyOptions {\r\n separator?: string;\r\n handler?(input: null | undefined): string;\r\n}\r\nexport const generateKey = (args: TKeyTypes[], options?: IGenerateKeyOptions): string => {\r\n const { handler, separator }: IGenerateKeyOptions = { ...{ separator: '-', handler: undefined }, ...(options || {}) };\r\n return args\r\n .map(arg => {\r\n if (arg === null || arg === undefined) {\r\n if (handler) {\r\n return handler(arg);\r\n }\r\n }\r\n return arg;\r\n })\r\n .join(separator);\r\n};\r\n\r\n/**\r\n * Gets the fall back image url for a variant image.\r\n * @param itemId Item id of a product.\r\n * @param apiSettings Api setting from request context.\r\n */\r\nexport const getFallbackImageUrl = (itemId: string | undefined, apiSettings: ICommerceApiSettings): string | undefined => {\r\n if (!itemId) {\r\n return '';\r\n }\r\n\r\n const parsedItemId = itemId.trim().split(' ')[0];\r\n\r\n const productUrl = `Products/${parsedItemId}_000_001.png`;\r\n return generateImageUrl(productUrl, apiSettings);\r\n};\r\n\r\n/**\r\n * Converts retail proxy product dimension type to display dimension type.\r\n * @param productDimensionType - Product dimension type from retail proxy.\r\n * @returns Local dimension type.\r\n */\r\nexport const convertProductDimensionTypeToDimensionTypes = (productDimensionType: ProductDimensionType): DimensionTypes => {\r\n switch (productDimensionType) {\r\n case ProductDimensionType.Color:\r\n return DimensionTypes.color;\r\n case ProductDimensionType.Configuration:\r\n return DimensionTypes.configuration;\r\n case ProductDimensionType.Size:\r\n return DimensionTypes.size;\r\n case ProductDimensionType.Style:\r\n return DimensionTypes.style;\r\n default:\r\n return DimensionTypes.none;\r\n }\r\n};\r\n\r\n/**\r\n * Converts display dimension type to retail proxy product dimension type.\r\n * @param dimensionType - Local dimension type.\r\n * @returns Product dimension type from retail proxy.\r\n */\r\nexport const convertDimensionTypeToProductDimensionType = (dimensionType: DimensionTypes): ProductDimensionType => {\r\n switch (dimensionType) {\r\n case DimensionTypes.color:\r\n return ProductDimensionType.Color;\r\n case DimensionTypes.configuration:\r\n return ProductDimensionType.Configuration;\r\n case DimensionTypes.size:\r\n return ProductDimensionType.Size;\r\n case DimensionTypes.style:\r\n return ProductDimensionType.Style;\r\n default:\r\n return ProductDimensionType.None;\r\n }\r\n};\r\n\r\n/**\r\n * Sets dimensions to url.\r\n * @param inputUrl - Url to update.\r\n * @param productDimensions - Dimensions to set.\r\n */\r\nexport const setDimensionValuesToQuery = (inputUrl: URL, productDimensions: ProductDimension[]): void => {\r\n for (const dimension of productDimensions) {\r\n inputUrl.searchParams.set(\r\n convertProductDimensionTypeToDimensionTypes(dimension.DimensionTypeValue), dimension.DimensionValue?.Value ?? '');\r\n }\r\n\r\n window.history?.replaceState(window.history.state, '', inputUrl.toString()?.replace(inputUrl.host, window.location.host));\r\n};\r\n\r\n/**\r\n * Retrieves dimension value stored in url.\r\n * @param urlParameters - Url parameters.\r\n * @param productDimensionType - The dimension type to retrieve.\r\n * @returns Product dimension item.\r\n */\r\nconst parseDimensionFromUrl = (urlParameters: URLSearchParams, productDimensionType: ProductDimensionType): ProductDimension | undefined => {\r\n const localDimensionType = convertProductDimensionTypeToDimensionTypes(productDimensionType);\r\n const value = urlParameters.get(localDimensionType);\r\n if (!value) {\r\n return undefined;\r\n }\r\n return {\r\n DimensionTypeValue: productDimensionType,\r\n DimensionValue: {\r\n RecordId: 0,\r\n Value: value\r\n }\r\n };\r\n};\r\n\r\n/**\r\n * Retrieves all dimensions from URL.\r\n * @param urlParameters - Url parameters.\r\n * @returns Product dimensions stored in url.\r\n */\r\nconst parseDimensionsFromUrl = (urlParameters: URLSearchParams): ProductDimension[] => {\r\n const dimensionsToParse: ProductDimensionType[] = [\r\n ProductDimensionType.Color,\r\n ProductDimensionType.Configuration,\r\n ProductDimensionType.Size,\r\n ProductDimensionType.Style\r\n ];\r\n const parsedDimensions = dimensionsToParse.map(dimension => parseDimensionFromUrl(urlParameters, dimension));\r\n return ArrayExtensions.validValues(parsedDimensions);\r\n};\r\n\r\n/**\r\n * Utility function to extract the dimension values from input url querystring.\r\n * @param inputUrl - The request url.\r\n * @returns The selected dimension values.\r\n */\r\nexport const getDimensionValuesFromQuery = (inputUrl: URL): ProductDimension[] => {\r\n const urlWithIgnoredCase = new URL(inputUrl.toString().toLocaleLowerCase());\r\n const urlParameters = urlWithIgnoredCase.searchParams;\r\n const dimensions: ProductDimension[] = parseDimensionsFromUrl(urlParameters);\r\n return dimensions;\r\n};\r\n","import React, { FunctionComponent } from 'react';\r\n\r\n\r\ninterface Props {\r\n /** Sets the skeleton-pulse style */\r\n type?: 'text' | 'image' | 'button' | 'button-secondary';\r\n /** Sets the width of the skeleton. Default unit is px. */\r\n width?: number | string;\r\n /** Sets the height of the skeleton. Default unit is px. */\r\n height?: number | string;\r\n /** Makes the skeleton look like a circle */\r\n circle?: boolean;\r\n /** Override classNames on wrapper */\r\n className?: string;\r\n /** Override styles on wrapper */\r\n style?: object;\r\n [rest: string]: unknown; // ...rest property\r\n}\r\n\r\nconst getValidCSSInput = (input: string | number) => {\r\n switch (typeof input) {\r\n case 'undefined':\r\n case 'boolean':\r\n return null;\r\n case 'number':\r\n return `${input}px`;\r\n default:\r\n const parsedInput = parseFloat(input);\r\n const unit = input.match(/%|em/);\r\n return isNaN(parsedInput) ? '' : unit ? `${parsedInput}${unit}` : `${parsedInput}px`;\r\n }\r\n};\r\n\r\nconst CustomSkeleton: FunctionComponent = ({\r\n width,\r\n height,\r\n circle,\r\n type = 'text',\r\n className = '',\r\n style = {},\r\n ...rest\r\n}) => {\r\n const isTextType = type === 'text';\r\n const classNames = `pulse ${!className ? type : ``} ${isTextType ? 'transform' : ''} ${type === 'button-secondary' && !className ? 'button' : ''} ${circle ? 'circle' : ''} ${className}`;\r\n\r\n return (\r\n \r\n );\r\n};\r\n\r\nexport default CustomSkeleton;\r\n"],"names":["variantQueryStringName","getBVAttributeValues","attributeValues","key","_attributeValues$find","value","find","attr","_attr$Name","Name","trim","TextValue","Math","round","getBVAttributeValuesUnbxd","_attributeValues$key","async","request","context","isCached","getATPInventoryStatusInput","GetATPInventoryStatusInput","result","getATPInventoryStatusAction","actionContext","error","console","log","renderRating","typeName","id","avgRating","totalRatings","ariaLabel","numRatings","toString","ratingAriaLabel","rating","roundedRating","toFixed","format","getRatingAriaLabel","React","RatingComponent","ratingCount","readOnly","data","_coreProductATPCall","props","setCoreProductATPData","recordId","itemId","setATPCallMessage","setIsAtpCallReturned","zipcode","Cookies","get","undefined","itemLinesArray","product","itemLines","ItemId","Quantity","VariantRecordId","push","currentDate","Date","now","requestBody","InventoryType","Weeks","app","config","weeksPDPforATPCall","StoreId","Page","RequestedDate","dayjs","ZipCode","ItemLines","_getDeliveryByMessage","then","ATPInventoryData","length","Message","catch","e","_getActivePrices","pricingData","ctx","date","productIds","i","productId","getActivePricesAsync","callerContext","ChannelId","requestContext","apiSettings","channelId","CatalogId","catalogId","dimPricesResult","map","item","index","discountAmount","DiscountAmount","_smallParcelProductATPCallForInventoryStatus","SetoutOfStockSmallParcelState","_getInventoryQuantity","ATPInventoryStatusData","coreProductAtpData","Available","parseInt","_coreProductATPCallForInventoryStatusForAllVariants","recordIds","allVariants","ridIter","iter","variantID","isAvailable","_objectSpread","zipCode","_smallParcelProductATPBooleanStatus","constructor","input","arguments","getCacheKey","_this$input","_this$input2","Array","prototype","call","this","sort","join","getCacheObjectType","dataCacheType","Msdyn365","action","mFIATPInventoryStatusAsync","ProductCompareBuyboxStateSharing","__decorate","observable","args","_args$config","getSelectedProductIdFromActionInput","inputData","_context$query","variantId","queryBasedVariantSelection","getQueryParamsFromQueryByName","url","requestUrl","query","urlTokens","pageType","inputUrl","queryParamName","URL","toLocaleLowerCase","searchParams","Number","isNaN","generateImageUrl","imageUrl","startsWith","baseImageUrl","encodeURIComponent","DimensionTypes","DimensionSwatchDisplayTypes","getFallbackImageUrl","parsedItemId","split","getValidCSSInput","parsedInput","parseFloat","unit","match","_ref","_getValidCSSInput","_getValidCSSInput2","width","height","circle","type","className","style","rest","_objectWithoutProperties","_excluded","classNames","Object","assign","borderRadius"],"sourceRoot":""}