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B,OATID,IACIA,EAAUE,kBACVrK,EAAQ,GAAGmK,EAAUE,kBAAkBrK,KAEvCmK,EAAUG,kBACVtK,EAAQ,GAAGA,IAAQmK,EAAUG,oBAI9BtK,GAIf","sources":["webpack://bestseller.commerce.online/external var \"React\"?0d3b","webpack://bestseller.commerce.online/external var \"ReactDOM\"?853b","webpack://bestseller.commerce.online/./src/modules/ext-product-page-summary/ext-product-page-summary.action.ts?ee9e","webpack://bestseller.commerce.online/./lib/ext-product-page-summary/module-registration.js?fde0","webpack://bestseller.commerce.online/./src/modules/ext-product-page-summary/ext-product-page-summary.tsx?ed14"],"sourcesContent":["module.exports = React;","module.exports = ReactDOM;","/*!\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\n/* eslint-disable no-duplicate-imports */\r\nimport {\r\n CacheType,\r\n createObservableDataAction,\r\n getCatalogId,\r\n IAction,\r\n IActionContext,\r\n IActionInput,\r\n ICommerceApiSettings,\r\n ICreateActionContext,\r\n IRequestContext\r\n} from '@msdyn365-commerce/core';\r\nimport { ProductPrice, ProjectionDomain, SimpleProduct } from '@msdyn365-commerce/retail-proxy';\r\nimport {\r\n getActivePricesAsync,\r\n getAttributeValuesAsync,\r\n getByIdsAsync\r\n} from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\r\nimport {\r\n ArrayExtensions,\r\n generateCacheKey,\r\n generateImageUrl,\r\n getProductUrlSync,\r\n getSelectedProductIdFromActionInput,\r\n QueryResultSettingsProxy,\r\n removeDomainQspFromUrl\r\n} from '@msdyn365-commerce-modules/retail-actions';\r\n\r\nimport { IPageSummaryData } from '@msdyn365-commerce-modules/page-summary';\r\nimport { IExtProductPageSummaryConfig } from './ext-product-page-summary.props.autogenerated';\r\n//import { getLocalizedStringsAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/StoreOperationsDataActions.g';\r\n\r\n/**\r\n * Product Page Summary Input.\r\n */\r\nexport class ProductPageSummaryInput implements IActionInput {\r\n public apiSettings: ICommerceApiSettings;\r\n\r\n public config: IExtProductPageSummaryConfig;\r\n\r\n public productId: number;\r\n\r\n public catalogId?: number;\r\n\r\n public constructor(\r\n config: IExtProductPageSummaryConfig,\r\n apiSettings: ICommerceApiSettings,\r\n productId: number,\r\n requestContext?: IRequestContext\r\n ) {\r\n this.config = config || {};\r\n this.apiSettings = apiSettings;\r\n this.productId = productId;\r\n\r\n if (requestContext) {\r\n this.catalogId = getCatalogId(requestContext);\r\n }\r\n }\r\n\r\n public getCacheObjectType = (): string => 'ProductPageSummary';\r\n\r\n public getCacheKey = (): string =>\r\n generateCacheKey(\r\n this.apiSettings,\r\n { key: 'Key', value: 'ProductPageSummary' },\r\n { key: 'Title', value: this.config.title },\r\n { key: 'ProductId', value: this.productId },\r\n { key: 'CatalogId', value: this.catalogId }\r\n );\r\n\r\n public dataCacheType = (): CacheType => 'application';\r\n}\r\n\r\nexport interface IProductPageSummary extends IPageSummaryData {\r\n price?: number;\r\n productId?: number;\r\n masterProductId?: number;\r\n productBrand?: string;\r\n category?: string;\r\n}\r\n\r\nconst createInput = (args: ICreateActionContext) => {\r\n const productId = getSelectedProductIdFromActionInput(args);\r\n\r\n if (productId) {\r\n return new ProductPageSummaryInput(\r\n args.config,\r\n args.requestContext.apiSettings,\r\n +productId,\r\n args.requestContext\r\n );\r\n }\r\n throw new Error('Unable to create ProductPageSummaryAction input, no productId found on module config or query');\r\n};\r\n\r\ninterface Attributes {\r\n brand?: string;\r\n category?: string;\r\n}\r\n\r\n// Checks product attributes for the presence of brand attribute to extract the brand name for product metadata\r\nconst getProductAttributes = async (\r\n context: IActionContext,\r\n recordId: number,\r\n channelId: number,\r\n catalogId: number\r\n): Promise => {\r\n const productAttributes = await getAttributeValuesAsync(\r\n {\r\n callerContext: context,\r\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context)\r\n },\r\n recordId,\r\n channelId,\r\n catalogId\r\n );\r\n const attributes: Attributes = {};\r\n for (const productAttribute of productAttributes) {\r\n if (productAttribute.Name === 'Brand') {\r\n attributes.brand = productAttribute.TextValue;\r\n } else if (productAttribute.Name === 'Category') {\r\n attributes.category = productAttribute.TextValue;\r\n }\r\n }\r\n\r\n return attributes;\r\n};\r\n\r\nconst action = async (input: ProductPageSummaryInput, context: IActionContext): Promise => {\r\n const { config, productId, apiSettings } = input;\r\n let simpleProductsData: SimpleProduct[] | undefined;\r\n try {\r\n simpleProductsData = ArrayExtensions.validValues(\r\n await getByIdsAsync(\r\n {\r\n callerContext: context,\r\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context)\r\n },\r\n apiSettings.channelId,\r\n [productId],\r\n null,\r\n input.catalogId ?? 0\r\n )\r\n );\r\n } catch {\r\n // Do nothing, if there's an error we fall back to values defined from config\r\n }\r\n if (ArrayExtensions.hasElements(simpleProductsData)) {\r\n const simpleProductData = simpleProductsData[0];\r\n let productUrl: string | undefined;\r\n try {\r\n productUrl = getProductUrlSync(simpleProductData, context);\r\n const canonicalDomain = context.requestContext.canonicalDomain;\r\n if (productUrl && canonicalDomain) {\r\n productUrl = `https://${canonicalDomain}/${context.requestContext.locale}${productUrl}`.toLocaleLowerCase();\r\n productUrl = removeDomainQspFromUrl(productUrl, context.requestContext);\r\n } else {\r\n productUrl = undefined;\r\n }\r\n } catch {\r\n productUrl = undefined;\r\n }\r\n\r\n let productBrand: string | undefined;\r\n let category: string | undefined;\r\n try {\r\n const attributes = await getProductAttributes(context, productId, apiSettings.channelId, input.catalogId ?? 0);\r\n productBrand = attributes.brand;\r\n //Gets the first category, which is the Bestseller category\r\n category = attributes.category?.split(';')[0];\r\n } catch (e) {\r\n productBrand = undefined;\r\n category = undefined;\r\n }\r\n\r\n let productPrice: number | undefined;\r\n try {\r\n const projectDomain: ProjectionDomain = {\r\n ChannelId: +context.requestContext.apiSettings.channelId,\r\n CatalogId: input.catalogId ?? 0\r\n };\r\n\r\n productPrice = await getActivePricesAsync(\r\n { callerContext: context, queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context) },\r\n projectDomain,\r\n [productId],\r\n new Date(),\r\n context.requestContext.user.customerAccountNumber,\r\n undefined,\r\n true\r\n ).then((productPrices: ProductPrice[]) => {\r\n if (!ArrayExtensions.hasElements(productPrices)) {\r\n throw new Error('[ExtProductPageSummaryAction]Invalid response received from getActivePricesAsync');\r\n }\r\n return productPrices[0].CustomerContextualPrice;\r\n });\r\n } catch {\r\n productPrice = undefined;\r\n }\r\n\r\n return {\r\n title: simpleProductData.Name,\r\n description: simpleProductData.Description,\r\n sharingImageUrl: generateImageUrl(simpleProductData.PrimaryImageUrl, apiSettings),\r\n canonicalUrl: productUrl,\r\n faviconUrl: config && config.faviconUrl,\r\n productId: parseInt(simpleProductData.ItemId ?? '', 10),\r\n price: productPrice ?? simpleProductData.AdjustedPrice,\r\n productBrand,\r\n category\r\n };\r\n\r\n // If the action fails fallback to values defined from config\r\n } else if (config) {\r\n return {\r\n title: config.title,\r\n description: config.description,\r\n sharingImageUrl: config.sharingImage && config.sharingImage.src,\r\n faviconUrl: config && config.faviconUrl\r\n };\r\n }\r\n return {};\r\n};\r\n\r\nexport default createObservableDataAction({\r\n id: '@msdyn365-commerce-modules/page-summary/product-page-summary',\r\n action: >action,\r\n input: createInput\r\n});\r\n","const binding = { modules: {}, dataActions: {} };\n\n const registerActionId = (actionPath) => {\n if (binding.dataActions[actionPath] &&\n binding.dataActions[actionPath].default &&\n binding.dataActions[actionPath].default.prototype &&\n binding.dataActions[actionPath].default.prototype.id) {\n binding.dataActions[binding.dataActions[actionPath].default.prototype.id] = binding.dataActions[actionPath];\n } else {\n Object.keys(binding.dataActions[actionPath] || {}).forEach(exportName => {\n if (binding.dataActions[actionPath][exportName] &&\n binding.dataActions[actionPath][exportName].prototype &&\n binding.dataActions[actionPath][exportName].prototype.Action) {\n binding.dataActions[binding.dataActions[actionPath][exportName].prototype.id] = binding.dataActions[actionPath][exportName];\n }\n })\n }\n };\n\n const registerSanitizedActionPath = (sanitizedActionPath, dataAction) => {\n if (process.env.NODE_ENV === 'development') {\n if (!dataAction.default) {\n throw new Error('Data action path does not have a default export');\n }\n if (!(dataAction.default.prototype.id && binding.dataActions[dataAction.default.prototype.id]) || !binding.dataActions[sanitizedActionPath]) {\n binding.dataActions[sanitizedActionPath] = dataAction;\n }\n } else {\n binding.dataActions[sanitizedActionPath] = dataAction;\n if (!binding.dataActions[sanitizedActionPath].default) {\n throw new Error('Data action path ' + sanitizedActionPath + ' does not have a default export');\n }\n binding.dataActions[sanitizedActionPath].default.prototype.RegistrationId = sanitizedActionPath;\n if (binding.dataActions[sanitizedActionPath].default.prototype.id) {\n binding.dataActions[binding.dataActions[sanitizedActionPath].default.prototype.id] = sanitizedActionPath;\n }\n }\n };\n \n\n (binding.modules['ext-product-page-summary'] = {\n c: () => require('partner/modules/ext-product-page-summary/ext-product-page-summary.tsx'),\n $type: 'htmlHeadTagsModule',\n da: [{name:'productPageSummary', path:'modules/ext-product-page-summary/ext-product-page-summary.action', runOn: 0}],\n \n iNM: false,\n ns: '__local__',\n n: 'ext-product-page-summary',\n p: '__local__',\n \n pdp: '',\n \n \n md: 'src/modules/ext-product-page-summary'\n });\n \n\n {\n const sanitizedActionPath = 'modules/ext-product-page-summary/ext-product-page-summary.action';\n let dataAction = require('partner/modules/ext-product-page-summary/ext-product-page-summary.action');\n registerSanitizedActionPath(sanitizedActionPath, dataAction);\n }\n \n\n \n window.__bindings__ = window.__bindings__ || {};\n window.__bindings__.modules = {\n ...window.__bindings__.modules || {},\n ...binding.modules\n };\n \n window.__bindings__.dataActions = {\n ...window.__bindings__.dataActions || {},\n ...binding.dataActions\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\n/* eslint-disable no-duplicate-imports */\r\nimport { HtmlHeadInclude, IAny, IGeneric } from '@msdyn365-commerce/core';\r\nimport * as React from 'react';\r\n\r\nimport { IExtProductPageSummaryData } from './ext-product-page-summary.data';\r\nimport { IExtProductPageSummaryProps } from './ext-product-page-summary.props.autogenerated';\r\n\r\ninterface ICategoryBinding {\r\n bindings: ICategoryBindingItem[];\r\n default: string;\r\n}\r\n\r\ninterface ICategoryBindingItem {\r\n google_id: string;\r\n categories: string[];\r\n}\r\n/**\r\n *\r\n * ProductPageSummary component.\r\n * @extends {React.PureComponent}\r\n */\r\nclass ProductPageSummary extends React.PureComponent> {\r\n public render(): JSX.Element {\r\n if (this.props.data.productPageSummary.result === undefined) {\r\n throw new Error('PageSummaryData input to page-summary is undefined. Unable to generate page-summary');\r\n }\r\n let {\r\n data: {\r\n productPageSummary: {\r\n result: { title, description, keywords, sharingImageUrl, faviconUrl }\r\n }\r\n }\r\n } = this.props;\r\n\r\n const {\r\n config,\r\n context,\r\n data: {\r\n productPageSummary: {\r\n result: { canonicalUrl, productId, productBrand, price, category }\r\n }\r\n }\r\n } = this.props;\r\n\r\n // Product SEO metadata specific information - non-overridable\r\n const productName = title;\r\n const productDescription = description;\r\n const productImageUrl = sharingImageUrl;\r\n\r\n // Override values coming from data action if config values are provided\r\n title = config.title || title;\r\n description = config.description || description;\r\n keywords = config.keywords || keywords;\r\n sharingImageUrl = (config.sharingImage && config.sharingImage.src) || sharingImageUrl;\r\n faviconUrl = config.faviconUrl || faviconUrl;\r\n\r\n // Construct page title with suffix and prefix if provided from app settings\r\n const pageTitle = this._constructPageTitle(title, context && context.request && context.request.app);\r\n return (\r\n <>\r\n \r\n {pageTitle && {pageTitle}}\r\n {description && }\r\n {keywords && }\r\n {canonicalUrl && }\r\n {faviconUrl && }\r\n \r\n {this._renderProductMetadata(\r\n productName,\r\n productDescription,\r\n productImageUrl,\r\n canonicalUrl,\r\n productId,\r\n price,\r\n context.request.channel?.Currency,\r\n productBrand,\r\n category\r\n )}\r\n {!config.disableOgTags && this._renderOgTags(pageTitle, description, sharingImageUrl)}\r\n {!config.disableTwitterTags && this._renderTwitterTags(pageTitle, description, sharingImageUrl)}\r\n \r\n );\r\n }\r\n\r\n /**\r\n * Renders the facebook and other social media specific metadata tags.\r\n *\r\n * @param title Page title.\r\n * @param description Product description.\r\n * @param sharingImageUrl Primary product image url.\r\n */\r\n private _renderOgTags(title: string | undefined, description: string | undefined, sharingImageUrl: string | undefined): JSX.Element {\r\n return (\r\n \r\n {title && }\r\n {description && }\r\n {sharingImageUrl && }\r\n \r\n \r\n );\r\n }\r\n\r\n /**\r\n * Constructs and renders the JSON-LD tag used to output product specific metadata used by search engine crawlers.\r\n *\r\n * @param productName Product name.\r\n * @param description Product description.\r\n * @param sharingImageUrl Primary product image url.\r\n * @param canonicalUrl Product canonical url.\r\n * @param productId Master product id.\r\n * @param masterProductId Master product id.\r\n * @param price Proudct price.\r\n * @param currencyCode Current channel currency code.\r\n * @param productBrand Product brand.\r\n * @param category Category.\r\n */\r\n private _renderProductMetadata(\r\n productName: string | undefined,\r\n description: string | undefined,\r\n sharingImageUrl: string | undefined,\r\n canonicalUrl: string | undefined,\r\n productId: number | undefined,\r\n price: number | undefined,\r\n currencyCode: string | undefined,\r\n productBrand: string | undefined,\r\n category?: string | undefined\r\n ): JSX.Element {\r\n var color = '';\r\n //Put the color in the query onto urls\r\n for (const key in this.props.context.request.query) {\r\n if (key === 'color') {\r\n /* eslint-disable-next-line security/detect-object-injection*/\r\n color = this.props.context.request.query[key];\r\n const strings = sharingImageUrl?.split('fileName=/');\r\n sharingImageUrl = strings ? strings[0] : '';\r\n /* eslint-disable-next-line security/detect-object-injection*/\r\n sharingImageUrl = `${sharingImageUrl}filename=/${productId}_${this.props.context.request.query[key]}_000_001.jpg`;\r\n /* eslint-disable-next-line security/detect-object-injection*/\r\n canonicalUrl = `${canonicalUrl}?color=${encodeURIComponent(this.props.context.request.query[key])}`;\r\n }\r\n }\r\n // Construct the JSON-LD data that contains the product metadata information used by search engine crawlers\r\n const productMetaData = JSON.stringify({\r\n '@context': 'http://schema.org',\r\n '@type': 'Product',\r\n name: productName,\r\n description,\r\n image: sharingImageUrl,\r\n productID: `${productId}${color}`,\r\n google_product_category: this._getCategoryId(category),\r\n brand: {\r\n '@type': 'Brand',\r\n name: productBrand\r\n },\r\n offers: {\r\n '@type': 'Offer',\r\n url: canonicalUrl,\r\n priceCurrency: currencyCode,\r\n price,\r\n itemCondition: 'https://schema.org/NewCondition',\r\n availability: 'https://schema.org/InStock'\r\n },\r\n additionalProperty: [\r\n {\r\n '@type': 'PropertyValue',\r\n propertyId: 'item_group_id',\r\n value: productId\r\n }\r\n ]\r\n });\r\n return (\r\n \r\n {/* eslint-disable-next-line react/no-danger -- Implementation is a copy.*/}\r\n