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OAA4B,EAA5BA,EAA8BpD,KAAI3G,GAAKA,EAAEoG,OAEnE,GAAI6D,GAAqBA,EAAkBzI,OAAS,EAChD,IAAK,IAAI0I,EAAI,EAAGA,EAAID,EAAkBzI,OAAQ0I,IAC1C,GAAKD,EAAkBC,GAGvB,IAAK,IAAIC,EAAI,EAAGA,GAAwB,QAAvBC,EAAGH,EAAkBC,UAAE,IAAAE,OAAA,EAApBA,EAAsB5I,QAAQ2I,IAAK,KAAAC,EAAAC,EACnD,MAAM/D,EAAQlH,EAA4BC,EACtC4K,EAAkBC,GAAGC,GACrBzC,EAAenI,cAAgBsK,GAEL,QAA1BQ,EAAC3C,EAAe4C,kBAAU,IAAAD,GAAzBA,EAA2BnH,SAASoD,IACrCwD,EAAiBrC,KAAK0C,GAYtC,OAL4BL,EAAiBS,QAAO,CAACC,EAAKC,EAAMP,EAAGQ,KAC/D,MAAMC,EAAQD,EAAI1H,QAAQhD,GAAMA,IAAMyK,IAAMjJ,OAC5C,OAAOmJ,EAAQH,EAAIG,MAAQ,CAAEA,MAAAA,EAAO1D,MAAOwD,GAASD,IACrD,CAAEG,MAAO,EAAG1D,MAAO,IAAKA,Q,cCqBxB,IAAKzC,E,iBAAZ,SAAYA,GACRA,EAAA,wBADJ,CAAYA,IAAAA,EAAe,M","sources":["webpack://Msdyn365.Commerce.Online/./src/shared-utils/attributes/attributes.ts?f392","webpack://Msdyn365.Commerce.Online/./src/shared-utils/attributes/attributes-map.ts?19ca","webpack://Msdyn365.Commerce.Online/./src/shared-utils/attributes/attribute-sorters.ts?85e1","webpack://Msdyn365.Commerce.Online/./src/shared-utils/attributes/get-most-used-attribute-name-index.ts?6ba6","webpack://Msdyn365.Commerce.Online/./src/shared-utils/types.ts?f79b"],"sourcesContent":["import { AttributeValue, CategoryPath, Customer } from \"@msdyn365-commerce/retail-proxy\";\r\nimport { ICoreContext } from '@msdyn365-commerce/core';\r\nimport nbNO from './locale/nb-NO.json';\r\nimport enUS from './locale/en-US.json';\r\nimport { LifeCycleStatus, SimpleProductExt } from \"../types\";\r\nimport { ProductSearchResultExt } from \"../../modules/vinhuset-search-result-container/components\";\r\n\r\nexport function getAttribute(attributes: AttributeValue[] | undefined, attributeName: string): AttributeValue {\r\n if (!attributes) {\r\n throw new Error(`No attributes found.`);\r\n }\r\n\r\n const attribute = attributes?.find(x => x.Name === attributeName);\r\n\r\n if (!attribute) {\r\n throw new Error(`Attribute ${attributeName} not found.`);\r\n }\r\n\r\n return attribute;\r\n}\r\n\r\nexport function getAttributeNumber(attributes: AttributeValue[] | undefined, attributeName: string): number {\r\n if (!attributes) {\r\n throw new Error(`No attributes found.`);\r\n }\r\n\r\n const attribute = attributes?.find(x => x.Name === attributeName);\r\n let result: number | undefined;\r\n\r\n if (!attribute) {\r\n throw new Error(`Attribute ${attributeName} not found.`);\r\n }\r\n\r\n switch (attribute.DataTypeValue) {\r\n case 1: // Currency\r\n result = attribute.CurrencyValue;\r\n break;\r\n case 3: // Decimal\r\n result = attribute.FloatValue;\r\n break;\r\n case 4: // Integer\r\n result = attribute.IntegerValue;\r\n break;\r\n case 0: // None\r\n case 2: // DateTime\r\n case 5: // Text\r\n case 6: // TrueFalse\r\n throw new Error(`Attribute ${attributeName} is not a number.`);\r\n }\r\n\r\n return result || 0;\r\n}\r\n\r\nexport function getAttributeNumberOrDefault(attributes: AttributeValue[] | undefined, attributeName: string, defaultValue: number): number {\r\n if (!attributes) {\r\n return defaultValue;\r\n }\r\n\r\n const attribute = attributes?.find(x => x.Name === attributeName);\r\n let result: number | undefined;\r\n\r\n if (!attribute) {\r\n return defaultValue;\r\n }\r\n\r\n switch (attribute.DataTypeValue) {\r\n case 1: // Currency\r\n result = attribute.CurrencyValue;\r\n break;\r\n case 3: // Decimal\r\n result = attribute.FloatValue;\r\n break;\r\n case 4: // Integer\r\n result = attribute.IntegerValue;\r\n break;\r\n case 0: // None\r\n case 2: // DateTime\r\n case 5: // Text\r\n case 6: // TrueFalse\r\n result = defaultValue;\r\n break;\r\n }\r\n\r\n return result || 0;\r\n}\r\n\r\nexport function getAttributeString(attributes: AttributeValue[] | undefined, attributeOrName: AttributeValue | string, suffix?: string): string {\r\n if (!attributes) {\r\n throw new Error(`No attributes found.`);\r\n }\r\n\r\n let attribute, result;\r\n\r\n if (typeof attributeOrName === 'string') {\r\n attribute = attributes?.find(x => x.Name === attributeOrName);\r\n } else {\r\n attribute = attributeOrName;\r\n }\r\n\r\n switch (attribute?.DataTypeValue) {\r\n case 0: // None\r\n result = `-`;\r\n break;\r\n case 1: // Currency\r\n result = attribute.CurrencyValue?.toString();\r\n break;\r\n case 2: // DateTime\r\n result = attribute.DateTimeOffsetValue ? new Date(attribute.DateTimeOffsetValue).toUTCString() : undefined;\r\n break;\r\n case 3: // Decimal\r\n result = attribute.FloatValue?.toString();\r\n break;\r\n case 4: // Integer\r\n result = attribute.IntegerValue?.toString();\r\n break;\r\n case 5: // Text\r\n result = attribute.TextValue?.toString();\r\n break;\r\n case 6: // TrueFalse\r\n result = attribute.BooleanValue?.toString();\r\n break;\r\n }\r\n\r\n if (!result) {\r\n throw new Error(`Attribute ${attributeOrName} not found`);\r\n }\r\n\r\n if (result !== '-' && suffix) {\r\n result += suffix;\r\n }\r\n\r\n return result;\r\n}\r\n\r\nexport function getAttributeStringOrDefault(attributes: AttributeValue[] | undefined, attributeName: string, defaultValue: T, suffix?: string): T | string {\r\n if (!attributes) {\r\n return defaultValue;\r\n }\r\n\r\n const attribute = attributes?.find(x => x.Name === attributeName);\r\n let result;\r\n\r\n if (!attribute) {\r\n return defaultValue;\r\n }\r\n\r\n switch (attribute?.DataTypeValue) {\r\n case 0: // None\r\n result = `-`;\r\n break;\r\n case 1: // Currency\r\n result = attribute.CurrencyValue?.toString();\r\n break;\r\n case 2: // DateTime\r\n result = attribute.DateTimeOffsetValue ? new Date(attribute.DateTimeOffsetValue).toUTCString() : undefined;\r\n break;\r\n case 3: // Decimal\r\n result = attribute.FloatValue?.toString();\r\n break;\r\n case 4: // Integer\r\n result = attribute.IntegerValue?.toString();\r\n break;\r\n case 5: // Text\r\n result = attribute.TextValue?.toString();\r\n break;\r\n case 6: // TrueFalse\r\n result = attribute.BooleanValue?.toString();\r\n break;\r\n default:\r\n result = '';\r\n break;\r\n }\r\n\r\n if (result && result !== '-' && suffix) {\r\n result += suffix;\r\n }\r\n\r\n return result || '';\r\n}\r\n\r\nexport function getAttributesLocale(lang: string): typeof nbNO {\r\n switch (lang) {\r\n case 'nb-NO':\r\n return nbNO;\r\n case 'en-US':\r\n return {...nbNO, ...enUS};\r\n default:\r\n return nbNO;\r\n }\r\n}\r\n\r\nexport function hasAttribute(attributes: AttributeValue[] | undefined, attributeName: string): boolean {\r\n if (!attributes) {\r\n return false;\r\n }\r\n\r\n return attributes?.some(x => x.Name === attributeName);\r\n}\r\n\r\nexport function hasAccessToBuy(context: ICoreContext, customer: Customer | undefined, productAttributes: AttributeValue[] | undefined) {\r\n if (!productAttributes || productAttributes.length === 0) {\r\n // No product attributes available, default to true\r\n return true;\r\n }\r\n\r\n // @ts-expect-error\r\n const locale = getAttributesLocale(context.request.locale);\r\n const licensesToCheck: string[] = [];\r\n let hasAccess = true;\r\n\r\n for (const license of licensesToCheck) {\r\n const productAttribute = Number(productAttributes?.find(x => x.Name === license)?.TextValue);\r\n const customerAttribute = Number(customer?.Attributes?.find(x => x.Name === license)?.AttributeValue?.StringValue);\r\n\r\n // Product doesn't have the attribute. Default to has access\r\n if (isNaN(productAttribute) || productAttribute === 0) {\r\n continue;\r\n }\r\n\r\n // Product has the attribute and it's more than 0, but customer doesn't have it at all. No access\r\n if (isNaN(customerAttribute)) {\r\n hasAccess = false;\r\n break;\r\n }\r\n\r\n // Product has the attribute, but customer has a lower value. No access\r\n if (customerAttribute < productAttribute) {\r\n hasAccess = false;\r\n break;\r\n }\r\n }\r\n\r\n const attributeRecordId = Number(context.request.app.config?.customerSpecificRefinerRecordId);\r\n\r\n if (!isNaN(attributeRecordId) && attributeRecordId > 0) {\r\n const customerNumber = customer?.AccountNumber;\r\n const productAttribute = productAttributes?.find(x => x.RecordId === attributeRecordId)?.TextValue\r\n ?.split('|')\r\n .filter(Boolean);\r\n\r\n // Produt is customer specific\r\n if (productAttribute && productAttribute.length > 0 && !productAttribute.includes('0')) {\r\n if (!customerNumber || !productAttribute.includes(customerNumber)) {\r\n hasAccess = false;\r\n }\r\n }\r\n }\r\n\r\n return hasAccess;\r\n}\r\n\r\nexport function applyAttributesToSimpleProduct(locale: string, product: SimpleProductExt, attributes: AttributeValue[] | undefined, categoryPaths: CategoryPath[] | undefined): void {\r\n if (attributes && attributes.length > 0) {\r\n const attrLocale = getAttributesLocale(locale);\r\n const alcoholPercentage = getAttributeStringOrDefault(attributes, attrLocale.prefixedAttributes.alcoholPercent, '-', '%');\r\n const volumeCl = getAttributeStringOrDefault(attributes, attrLocale.prefixedAttributes.volumeCl, undefined, ' cl')\r\n || getAttributeStringOrDefault(attributes, attrLocale.alternative.prefixed.volumeCl, undefined, ' cl');\r\n const producer = getAttributeStringOrDefault(attributes, attrLocale.prefixedAttributes.producer, undefined)\r\n || getAttributeStringOrDefault(attributes, attrLocale.alternative.prefixed.producer, undefined);\r\n const country = getAttributeStringOrDefault(attributes, attrLocale.prefixedAttributes.country, undefined)\r\n || getAttributeStringOrDefault(attributes, attrLocale.alternative.prefixed.country, undefined);\r\n const district = getAttributeStringOrDefault(attributes, attrLocale.prefixedAttributes.district, undefined)\r\n || getAttributeStringOrDefault(attributes, attrLocale.alternative.prefixed.district, undefined);\r\n const vintage = getAttributeStringOrDefault(attributes, attrLocale.prefixedAttributes.vintage, undefined);\r\n const soldOutUntilDate = attributes.find(x => x.Name === attrLocale.prefixedAttributes.soldOutUntilDate)?.DateTimeOffsetValue;\r\n const soldOutUnknownDate = attributes.find(x => x.Name === attrLocale.prefixedAttributes.lifeCycle)?.TextValue\r\n ?.split('-')[0]\r\n ?.trim() === LifeCycleStatus.SoldOutUnknownDate;\r\n\r\n product.AlcoholPercentage = alcoholPercentage;\r\n product.VolumeCl = volumeCl;\r\n product.Producer = producer;\r\n product.Country = country;\r\n product.District = district;\r\n product.CountryAndDistrict = [country, district].filter(Boolean).join(', ') || undefined;\r\n product.Vintage = vintage;\r\n product.SoldOutUntilDate = soldOutUntilDate ? new Date(soldOutUntilDate) : undefined;\r\n product.SoldOutUnknownDate = soldOutUnknownDate;\r\n }\r\n\r\n product.CategoryPaths = categoryPaths;\r\n product.Category = product.CategoryPaths?.[0]?.Segments?.[1]?.CategoryName;\r\n}\r\n\r\nexport function applyAttributesToProductSearchResult(locale: string, product: ProductSearchResultExt, attributes: AttributeValue[] | undefined, categoryPaths: CategoryPath[] | undefined): void {\r\n if (attributes && attributes.length > 0) {\r\n const attrLocale = getAttributesLocale(locale);\r\n const alcoholPercentage = getAttributeStringOrDefault(attributes, attrLocale.prefixedAttributes.alcoholPercent, '-', '%');\r\n const volumeCl = getAttributeStringOrDefault(attributes, attrLocale.prefixedAttributes.volumeCl, undefined, ' cl')\r\n || getAttributeStringOrDefault(attributes, attrLocale.alternative.prefixed.volumeCl, undefined, ' cl');\r\n const producer = getAttributeStringOrDefault(attributes, attrLocale.prefixedAttributes.producer, undefined)\r\n || getAttributeStringOrDefault(attributes, attrLocale.alternative.prefixed.producer, undefined);\r\n const country = getAttributeStringOrDefault(attributes, attrLocale.prefixedAttributes.country, undefined)\r\n || getAttributeStringOrDefault(attributes, attrLocale.alternative.prefixed.country, undefined);\r\n const district = getAttributeStringOrDefault(attributes, attrLocale.prefixedAttributes.district, undefined)\r\n || getAttributeStringOrDefault(attributes, attrLocale.alternative.prefixed.district, undefined);\r\n const vintage = getAttributeStringOrDefault(attributes, attrLocale.prefixedAttributes.vintage, undefined);\r\n const soldOutUntilDate = attributes.find(x => x.Name === attrLocale.prefixedAttributes.soldOutUntilDate)?.DateTimeOffsetValue;\r\n const soldOutUnknownDate = attributes.find(x => x.Name === attrLocale.prefixedAttributes.lifeCycle)?.TextValue\r\n ?.split('-')[0]\r\n ?.trim() === LifeCycleStatus.SoldOutUnknownDate;\r\n\r\n product.AlcoholPercentage = alcoholPercentage;\r\n product.VolumeCl = volumeCl;\r\n product.Producer = producer;\r\n product.Country = country;\r\n product.District = district;\r\n product.CountryAndDistrict = [country, district].filter(Boolean).join(', ') || undefined;\r\n product.Vintage = vintage;\r\n product.SoldOutUntilDate = soldOutUntilDate ? new Date(soldOutUntilDate) : undefined;\r\n product.SoldOutUnknownDate = soldOutUnknownDate;\r\n }\r\n\r\n product.CategoryPaths = categoryPaths;\r\n product.Category = product.CategoryPaths?.[0]?.Segments?.[1]?.CategoryName;\r\n}\r\n","import { ICoreContext, getUrlSync } from '@msdyn365-commerce/core';\r\nimport { getAttributeStringOrDefault, getAttributesLocale } from './attributes';\r\nimport { getMostUsedAttributeNameIndex, sortAttributes, sortAttributesByGroupOrder } from '.';\r\nimport { AttributeValue } from '@msdyn365-commerce/retail-proxy';\r\n\r\nexport interface IAttributeGroupMapAttribute {\r\n name: string | string[];\r\n label?: string;\r\n hideIfEmpty?: boolean;\r\n transform?: (value: string) => string;\r\n transformName?: (key: string) => string;\r\n}\r\n\r\nexport interface IAttributeGroupMap {\r\n type: AttributeGroupType;\r\n group: string;\r\n /** Sets the mode for how to handle the 'attributes':\r\n * - 'include': Only include the attributes defined in 'attributes'.\r\n * - 'transform': Include all attributes and apply transformations defined in 'attributes' on matching attributes.\r\n */\r\n attributesMode: 'include' | 'transform';\r\n attributes?: (string | IAttributeGroupMapAttribute)[];\r\n transform?: (value: string) => string;\r\n defaultValue?: string;\r\n nullValues?: string[];\r\n /** Sets global 'hideIfEmpty' for all attributes in this group. Only used if 'attributes' is not defined or list of strings. */\r\n hideIfEmpty?: boolean;\r\n /** The attribute to use as source. If set this will look for the attributes inside this attribute. */\r\n attributeSource?: string;\r\n attributeSourceSet?: { source: string, value: string }[];\r\n exclude?: string[];\r\n}\r\n\r\nexport type AttributeGroupType = 'default';\r\nexport type ModelVersion = '1.0' | '2.0' | '3.0';\r\n\r\nexport interface IParsedAttributeMap {\r\n type: AttributeGroupType;\r\n name: string;\r\n attributes: IParsedAttribute[];\r\n modelVersion?: ModelVersion;\r\n}\r\n\r\nexport interface IParsedAttribute {\r\n name: string;\r\n value: string;\r\n}\r\n\r\nexport const replaceCommaWithDot = (value: string): string => {\r\n // Shouldn't need to replace anything if both are present\r\n if (value.includes(',') && value.includes('.')) {\r\n return value.replace(' ', '');\r\n }\r\n // Only replace the last occurance of a comma with a dot\r\n const lastCommaIndex = value.lastIndexOf(',');\r\n if (lastCommaIndex !== -1) {\r\n return `${value.substring(0, lastCommaIndex)}.${value.substring(lastCommaIndex + 1)}`.replace(' ', '');\r\n }\r\n // If no comma is present, return the value as is\r\n return value.replace(' ', '');\r\n // return value.replace(',', '.').replace(' ', '');\r\n};\r\nexport const padValue = (value: string): string => {\r\n return Number(value.replace(',', '')).toFixed(2).toString();\r\n};\r\nexport const addCelsiusSign = (value: string): string => {\r\n return value ? `${value}°` : value;\r\n};\r\nexport const addDashPrefix = (key: string): string => {\r\n return ` - ${key}`;\r\n};\r\n\r\nfunction findAttribute(attributeName: string): (attribute: string | IAttributeGroupMapAttribute) => boolean {\r\n return (attribute: string | IAttributeGroupMapAttribute) => {\r\n if (typeof attribute === 'string') {\r\n return attribute === attributeName;\r\n } else {\r\n return attribute.name === attributeName;\r\n }\r\n };\r\n}\r\n\r\nexport function parseAttributesMap(context: ICoreContext, attributes: AttributeValue[] | undefined, attributesMap?: IAttributeGroupMap[]): IParsedAttributeMap[] {\r\n if (!attributesMap) {\r\n attributesMap = getAttributesMap(context);\r\n }\r\n\r\n const attributesLocale = getAttributesLocale(context.request.locale);\r\n const groups: {\r\n [key: string]: AttributeValue[];\r\n } = {};\r\n\r\n attributes!.sort(sortAttributesByGroupOrder).map((product: AttributeValue, index) => {\r\n const attrFind = product.ExtensionProperties?.find((e) => {\r\n return e.Key === 'ATTRGROUPNAME';\r\n });\r\n if(attrFind && attrFind.Value && attrFind.Value.StringValue){\r\n const key = attrFind.Value.StringValue.trim();\r\n if (groups[key]) {\r\n groups[key].push(product);\r\n } else {\r\n groups[key] = [];\r\n groups[key].push(product);\r\n }\r\n }\r\n });\r\n\r\n const parsed: IParsedAttributeMap[] = attributesMap.map((attributeGroup) => {\r\n const mostCommonNameIndex = getMostUsedAttributeNameIndex(attributes, attributeGroup, attributesLocale.notFound);\r\n\r\n if (!attributeGroup.attributes && !groups[attributeGroup.group]) {\r\n return {\r\n type: attributeGroup.type,\r\n name: attributeGroup.group,\r\n attributes: []\r\n };\r\n }\r\n\r\n let modelVersion: ModelVersion = '1.0';\r\n let attributesToUse: AttributeValue[] | undefined;\r\n const attributeSource = attributeGroup.attributeSource\r\n ? attributes!.find((attribute: AttributeValue) => attribute.Name === attributeGroup.attributeSource)\r\n : undefined;\r\n const shouldUseAttributeSet = attributeGroup.attributeSourceSet?.some((source) => {\r\n return attributes?.find((attribute: AttributeValue) => attribute.Name === source.source)?.TextValue;\r\n });\r\n\r\n if (shouldUseAttributeSet) {\r\n modelVersion = '3.0';\r\n attributesToUse = [];\r\n\r\n attributeGroup.attributeSourceSet!.forEach((source) => {\r\n const attribute = attributes?.find((attribute: AttributeValue) => attribute.Name === source.source);\r\n\r\n if (!attribute || !attribute.TextValue) {\r\n return;\r\n }\r\n\r\n attributesToUse!.push(...attribute.TextValue.split('|').map((attribute) => {\r\n return {\r\n Name: attribute,\r\n DataTypeValue: 5,\r\n TextValue: source.value,\r\n ExtensionProperties: [\r\n {\r\n Key: 'ATTRORDER',\r\n Value: {\r\n DecimalValue: (attributeGroup.attributes?.findIndex((attr) => {\r\n if (typeof attr === 'string') {\r\n return attr === attribute;\r\n } else {\r\n return attr.name === attribute;\r\n }\r\n }) ?? -1) + 1\r\n }\r\n }\r\n ]\r\n } as AttributeValue;\r\n }));\r\n });\r\n } else if (attributeGroup.attributeSource && attributeSource?.TextValue) {\r\n modelVersion = '2.0';\r\n attributesToUse = attributeSource?.TextValue?.split('|').map((attribute) => {\r\n return {\r\n Name: attribute.split(':')[0],\r\n DataTypeValue: 5,\r\n TextValue: attribute.split(':')[1]\r\n } as AttributeValue;\r\n });\r\n } else {\r\n if (attributeGroup.attributesMode === 'include' && attributeGroup.attributes) {\r\n // Only get the attributes defined in the 'attributes' list\r\n const includes = attributeGroup.attributes.map(attr => {\r\n if (typeof attr === 'string') {\r\n return attr;\r\n } else {\r\n if (typeof attr.name === 'string') {\r\n return attr.name;\r\n } else {\r\n return attr.name[mostCommonNameIndex];\r\n }\r\n }\r\n });\r\n attributesToUse = attributes?.filter((attribute: AttributeValue) => includes.includes(attribute.Name || ''));\r\n } else {\r\n // Get all attributes in this group and 'attributes' is a list of transformations to apply to matching attributes\r\n attributesToUse = groups[attributeGroup.group];\r\n }\r\n }\r\n\r\n const attrsNew = attributesToUse?.sort(sortAttributes).map((attribute) => {\r\n if (!attribute.Name) {\r\n throw new Error(`Attribute name is missing.`);\r\n }\r\n\r\n if (attributeGroup.exclude && attributeGroup.exclude.includes(attribute.Name)) {\r\n return undefined;\r\n }\r\n\r\n let name = attribute.Name;\r\n let value = getAttributeStringOrDefault(attributesToUse,\r\n attribute.Name,\r\n attributeGroup.defaultValue);\r\n\r\n const findAttributeFromAttributes = attributeGroup.attributes?.find(findAttribute(attribute.Name));\r\n\r\n if (typeof findAttributeFromAttributes === 'object') {\r\n if (findAttributeFromAttributes.transformName) {\r\n name = findAttributeFromAttributes.transformName(attribute.Name);\r\n }\r\n\r\n if (value && findAttributeFromAttributes.transform) {\r\n value = findAttributeFromAttributes.transform(value);\r\n }\r\n\r\n if (value && attributeGroup.transform) {\r\n value = attributeGroup.transform(value);\r\n }\r\n\r\n if (findAttributeFromAttributes.hideIfEmpty && !value) {\r\n return undefined;\r\n }\r\n\r\n if (findAttributeFromAttributes.hideIfEmpty !== false && attributeGroup.hideIfEmpty && !value) {\r\n return undefined;\r\n }\r\n } else {\r\n if (value && attributeGroup.transform) {\r\n value = attributeGroup.transform(value);\r\n }\r\n\r\n if (attributeGroup.hideIfEmpty && !value) {\r\n return undefined;\r\n }\r\n }\r\n\r\n return {\r\n name,\r\n value: value || attributesLocale.notFound\r\n };\r\n });\r\n\r\n return {\r\n type: attributeGroup.type,\r\n name: attributeGroup.group,\r\n attributes: (attrsNew || []).filter(x => x).map((attribute) => {\r\n const { name, value } = attribute || {};\r\n\r\n return {\r\n name: name as string,\r\n value: value as string\r\n };\r\n }),\r\n modelVersion\r\n };\r\n });\r\n\r\n return parsed;\r\n}\r\n\r\nexport function getAttributesMap(context: ICoreContext): IAttributeGroupMap[] {\r\n const attributesLocale = getAttributesLocale(context.request.locale);\r\n\r\n return [\r\n {\r\n type: 'default',\r\n group: attributesLocale.groups.aboutProduct,\r\n hideIfEmpty: true,\r\n attributesMode: 'transform',\r\n attributes: [\r\n {\r\n name: attributesLocale.country,\r\n transform: (value) => {\r\n const searchURLBase = getUrlSync('search', context.actionContext);\r\n const separator = searchURLBase!.includes('?') ? '&' : '?';\r\n\r\n return value.split('|').map((v) => {\r\n const searchURL = `${searchURLBase}${separator}q=${encodeURIComponent(v)}`;\r\n return `${v}`;\r\n }).join(', ');\r\n }\r\n },\r\n {\r\n name: attributesLocale.alcoholPercent,\r\n transform: (value) => `${value}%`\r\n },\r\n {\r\n name: attributesLocale.volumeCl,\r\n transform: (value) => `${value} cl`\r\n }\r\n ]\r\n }\r\n ];\r\n}\r\n","import { AttributeValue } from \"@msdyn365-commerce/retail-proxy\";\r\n\r\nexport const sortAttributes = (a: AttributeValue, b: AttributeValue): number => {\r\n const a_order = a.ExtensionProperties?.find(prop => prop.Key === 'ATTRORDER')?.Value?.DecimalValue;\r\n const b_order = b.ExtensionProperties?.find(prop => prop.Key === 'ATTRORDER')?.Value?.DecimalValue;\r\n\r\n if (a_order === undefined) {\r\n return 1;\r\n }\r\n if (b_order === undefined) {\r\n return -1;\r\n }\r\n\r\n if (a_order < b_order) {\r\n return -1;\r\n }\r\n if (a_order > b_order) {\r\n return 1;\r\n }\r\n return 0;\r\n};\r\n\r\nexport const sortAttributesByGroupOrder = (a: AttributeValue, b: AttributeValue): number => {\r\n const a_order = a.ExtensionProperties?.find(prop => prop.Key === 'ATTRGROUPORDER')?.Value?.DecimalValue;\r\n const b_order = b.ExtensionProperties?.find(prop => prop.Key === 'ATTRGROUPORDER')?.Value?.DecimalValue;\r\n\r\n if (a_order === undefined) {\r\n return 1;\r\n }\r\n if (b_order === undefined) {\r\n return -1;\r\n }\r\n\r\n if (a_order < b_order) {\r\n return -1;\r\n }\r\n if (a_order > b_order) {\r\n return 1;\r\n }\r\n return 0;\r\n};\r\n","import { AttributeValue } from \"@msdyn365-commerce/retail-proxy\";\r\nimport { IAttributeGroupMap, IAttributeGroupMapAttribute } from \"./attributes-map\";\r\nimport { getAttributeStringOrDefault } from \"./\";\r\n\r\n/**\r\n * Returns the index of the most used attribute name in the given array of product specifications named from attribute map.\r\n */\r\nexport function getMostUsedAttributeNameIndex(attributes: AttributeValue[] | undefined, attributeGroup: IAttributeGroupMap, notFoundDefaultValue: string) {\r\n const usedNameIndicies: number[] = [];\r\n const attributeGroupsWithNameArray = attributeGroup.attributes?.filter(x => typeof x !== 'string' && x.name instanceof Array) as IAttributeGroupMapAttribute[];\r\n const arrayOfNameArrays = attributeGroupsWithNameArray?.map(x => x.name) as (string[])[];\r\n\r\n if (arrayOfNameArrays && arrayOfNameArrays.length > 0) {\r\n for (let i = 0; i < arrayOfNameArrays.length; i++) {\r\n if (!arrayOfNameArrays[i]) {\r\n continue;\r\n }\r\n for (let y = 0; y < arrayOfNameArrays[i]?.length; y++) {\r\n const value = getAttributeStringOrDefault(attributes,\r\n arrayOfNameArrays[i][y],\r\n attributeGroup.defaultValue || notFoundDefaultValue);\r\n\r\n if (!attributeGroup.nullValues?.includes(value)) {\r\n usedNameIndicies.push(y);\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Get the number that appears the most in 'usedNameIndicies' array\r\n const mostCommonNameIndex = usedNameIndicies.reduce((acc, curr, i, arr) => {\r\n const count = arr.filter((x) => x === curr).length;\r\n return count > acc.count ? { count, index: curr } : acc;\r\n }, { count: 0, index: 0 }).index;\r\n\r\n return mostCommonNameIndex;\r\n}\r\n","import { IModuleStateManager } from '@msdyn365-commerce-modules/checkout-utilities';\r\nimport { IProductRefinerHierarchy } from '@msdyn365-commerce/commerce-entities';\r\nimport { CategoryPath, ProductPrice, SimpleProduct } from \"@msdyn365-commerce/retail-proxy\";\r\nimport { IOrderSummaryLines } from '@msdyn365-commerce-modules/order-summary-utilities';\r\n\r\nexport interface IModuleStatePropsExt {\r\n moduleState: IModuleStateManagerExt;\r\n}\r\n\r\nexport interface IModuleStateManagerExt extends IModuleStateManager {\r\n init(options?: Partial): void;\r\n wide?: boolean;\r\n}\r\n\r\nexport interface IProductError {\r\n RecordId: number;\r\n Error: string;\r\n Type: 'warning' | 'error';\r\n}\r\n\r\nexport interface SimpleProductExt extends SimpleProduct {\r\n OutOfAssortment?: boolean;\r\n AlcoholPercentage?: string;\r\n Badge?: string;\r\n Brand?: string;\r\n VolumeCl?: string;\r\n CategoryPaths?: CategoryPath[];\r\n Manufacturer?: string;\r\n ProductPrice?: ProductPrice;\r\n\r\n Producer?: string;\r\n Country?: string;\r\n District?: string;\r\n CountryAndDistrict?: string;\r\n Category?: string;\r\n Vintage?: string;\r\n\r\n SoldOutUntilDate?: Date;\r\n SoldOutUnknownDate?: boolean;\r\n}\r\n\r\nexport interface ProductPriceExt extends ProductPrice {\r\n OverrideDiscountPercentage?: number;\r\n}\r\n\r\nexport interface IProductRefinerHierarchyExt extends IProductRefinerHierarchy {\r\n DisableSortValues?: boolean;\r\n RangeToPredefinedRanges?: boolean;\r\n}\r\n\r\nexport interface IOrderSummaryLinesExt extends IOrderSummaryLines {\r\n charges?: React.ReactNode[];\r\n}\r\n\r\nexport enum LifeCycleStatus {\r\n SoldOutUnknownDate = '20'\r\n}\r\n"],"names":["getAttributeStringOrDefault","attributes","attributeName","defaultValue","suffix","_attribute$CurrencyVa2","_attribute$FloatValue2","_attribute$IntegerVal2","_attribute$TextValue2","_attribute$BooleanVal2","attribute","find","x","Name","result","DataTypeValue","CurrencyValue","toString","DateTimeOffsetValue","Date","toUTCString","undefined","FloatValue","IntegerValue","TextValue","BooleanValue","getAttributesLocale","lang","nbNO","_objectSpread","enUS","hasAccessToBuy","context","customer","productAttributes","_context$request$app$","length","request","locale","licensesToCheck","hasAccess","license","_productAttributes$fi","_customer$Attributes","productAttribute","Number","customerAttribute","Attributes","AttributeValue","StringValue","isNaN","attributeRecordId","app","config","customerSpecificRefinerRecordId","_productAttributes$fi2","customerNumber","AccountNumber","RecordId","split","filter","Boolean","includes","applyAttributesToSimpleProduct","product","categoryPaths","_product$CategoryPath","_attributes$find","_attributes$find2","attrLocale","alcoholPercentage","prefixedAttributes","alcoholPercent","volumeCl","alternative","prefixed","producer","country","district","vintage","soldOutUntilDate","soldOutUnknownDate","lifeCycle","trim","LifeCycleStatus","SoldOutUnknownDate","AlcoholPercentage","VolumeCl","Producer","Country","District","CountryAndDistrict","join","Vintage","SoldOutUntilDate","CategoryPaths","Category","Segments","CategoryName","applyAttributesToProductSearchResult","_product$CategoryPath2","_attributes$find3","_attributes$find4","parseAttributesMap","attributesMap","attributesLocale","type","group","groups","aboutProduct","hideIfEmpty","attributesMode","name","transform","value","searchURLBase","getUrlSync","actionContext","separator","map","v","encodeURIComponent","getAttributesMap","sort","sortAttributesByGroupOrder","index","_product$ExtensionPro","attrFind","ExtensionProperties","e","Key","Value","key","push","attributeGroup","_attributeGroup$attri","_attributesToUse","mostCommonNameIndex","getMostUsedAttributeNameIndex","notFound","attributesToUse","modelVersion","attributeSource","attributeSourceSet","some","source","forEach","_attributeGroup$attri2","_attributeGroup$attri3","DecimalValue","findIndex","attr","_attributeSource$Text","attrsNew","sortAttributes","_attributeGroup$attri4","Error","exclude","findAttributeFromAttributes","transformName","a","b","_a$ExtensionPropertie","_b$ExtensionPropertie","a_order","prop","b_order","_a$ExtensionPropertie2","_b$ExtensionPropertie2","notFoundDefaultValue","usedNameIndicies","attributeGroupsWithNameArray","Array","arrayOfNameArrays","i","y","_arrayOfNameArrays$i","_attributeGroup$nullV","nullValues","reduce","acc","curr","arr","count"],"sourceRoot":""}