tanya-chatbot 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tanya-chatbot.cjs.js +10 -10
- package/dist/tanya-chatbot.cjs.js.map +1 -1
- package/dist/tanya-chatbot.es.js +719 -720
- package/dist/tanya-chatbot.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tanya-chatbot.cjs.js","sources":["../src/components/lib/utils.ts","../src/components/ui/popover.tsx","../src/config/api.ts","../src/components/utils/fetchTokenBmGrant.ts","../src/components/utils/fetchExistingRegisterCustomerToken.ts","../src/sfcc-apis/session/index.ts","../src/components/utils/index.ts","../src/components/utils/helper.js","../node_modules/@iconify/react/dist/iconify.js","../src/store/reducers/productReducer.ts","../src/components/carousel/ProductCarousel.tsx","../src/components/carousel/ProductDisplay.tsx","../src/components/api/api.ts","../src/config/constant.ts","../src/components/utils/localStorage.ts","../src/components/product/ProductDisplayCard.tsx","../src/components/tanya-widget/tanya-shopping-assistent.tsx"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport const notifySFCC = (basketId?: string) => {\n const event = new CustomEvent(\"reactCartUpdated\", {\n detail: {\n cartUpdated: true,\n basketId,\n\n // any other data SFCC needs\n },\n });\n window.dispatchEvent(event);\n};\n","\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\r\n\r\nimport { cn } from \"../lib/utils\";\r\n\r\nfunction Popover({\r\n ...props\r\n}: React.ComponentProps<typeof PopoverPrimitive.Root>) {\r\n return <PopoverPrimitive.Root data-slot=\"popover\" {...props} />;\r\n}\r\n\r\nfunction PopoverTrigger({\r\n ...props\r\n}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {\r\n return <PopoverPrimitive.Trigger data-slot=\"popover-trigger\" {...props} />;\r\n}\r\n\r\nfunction PopoverContent({\r\n className,\r\n align = \"center\",\r\n sideOffset = 4,\r\n ...props\r\n}: React.ComponentProps<typeof PopoverPrimitive.Content>) {\r\n return (\r\n <PopoverPrimitive.Portal>\r\n <PopoverPrimitive.Content\r\n data-slot=\"popover-content\"\r\n align={align}\r\n sideOffset={sideOffset}\r\n className={cn(\r\n \"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden\",\r\n className\r\n )}\r\n {...props}\r\n />\r\n </PopoverPrimitive.Portal>\r\n );\r\n}\r\n\r\nfunction PopoverAnchor({\r\n ...props\r\n}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {\r\n return <PopoverPrimitive.Anchor data-slot=\"popover-anchor\" {...props} />;\r\n}\r\n\r\nexport { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };\r\n","function stringToUint8Array(str: string): Uint8Array {\n return new TextEncoder().encode(str);\n}\n\n// Helper function to convert ArrayBuffer to hex string\nfunction arrayBufferToHex(buffer: ArrayBuffer): string {\n const byteArray = new Uint8Array(buffer);\n const hexCodes = [...byteArray].map((value) => {\n const hexCode = value.toString(16);\n const paddedHexCode = hexCode.padStart(2, \"0\");\n return paddedHexCode;\n });\n return hexCodes.join(\"\");\n}\n\n// SHA256 hash using Web Crypto API\nasync function sha256(data: string): Promise<ArrayBuffer> {\n const encoder = new TextEncoder();\n return await crypto.subtle.digest(\"SHA-256\", encoder.encode(data));\n}\n\n// HMAC-SHA256 using Web Crypto API\nasync function hmacSha256(\n key: ArrayBuffer | Uint8Array,\n data: string\n): Promise<ArrayBuffer> {\n const cryptoKey = await crypto.subtle.importKey(\n \"raw\",\n key,\n { name: \"HMAC\", hash: \"SHA-256\" },\n false,\n [\"sign\"]\n );\n\n const encoder = new TextEncoder();\n return await crypto.subtle.sign(\"HMAC\", cryptoKey, encoder.encode(data));\n}\n\n// Get signing key\nasync function getSignatureKey(\n key: string,\n dateStamp: string,\n regionName: string,\n serviceName: string\n): Promise<ArrayBuffer> {\n const kDate = await hmacSha256(stringToUint8Array(\"AWS4\" + key), dateStamp);\n const kRegion = await hmacSha256(kDate, regionName);\n const kService = await hmacSha256(kRegion, serviceName);\n const kSigning = await hmacSha256(kService, \"aws4_request\");\n return kSigning;\n}\n\nexport async function createSignedHeaders(\n url: string,\n method: string,\n payload: string,\n accessKeyId: string,\n secretAccessKey: string,\n region: string,\n service: string\n): Promise<Record<string, string>> {\n const urlObj = new URL(url);\n const host = urlObj.hostname;\n const pathname = urlObj.pathname;\n const search = urlObj.search;\n\n const now = new Date();\n const amzDate = now.toISOString().replace(/[:\\-]|\\.\\d{3}/g, \"\");\n const dateStamp = amzDate.substring(0, 8);\n const payloadHash = arrayBufferToHex(await sha256(payload));\n const contentLength = new TextEncoder().encode(payload).length.toString();\n\n const canonicalHeaders =\n `content-length:${contentLength}\\n` +\n `content-type:application/json\\n` +\n `host:${host}\\n` +\n `x-amz-content-sha256:${payloadHash}\\n` +\n `x-amz-date:${amzDate}\\n`;\n\n const signedHeaders =\n \"content-length;content-type;host;x-amz-content-sha256;x-amz-date\";\n\n const canonicalRequest = [\n method,\n pathname,\n search.slice(1),\n canonicalHeaders,\n signedHeaders,\n payloadHash,\n ].join(\"\\n\");\n\n const algorithm = \"AWS4-HMAC-SHA256\";\n const credentialScope = `${dateStamp}/${region}/${service}/aws4_request`;\n const stringToSign = [\n algorithm,\n amzDate,\n credentialScope,\n arrayBufferToHex(await sha256(canonicalRequest)),\n ].join(\"\\n\");\n\n const signingKey = await getSignatureKey(\n secretAccessKey,\n dateStamp,\n region,\n service\n );\n\n const signature = arrayBufferToHex(\n await hmacSha256(signingKey, stringToSign)\n );\n\n const authorizationHeader = `${algorithm} Credential=${accessKeyId}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`;\n\n return {\n \"Content-Type\": \"application/json\",\n \"Content-Length\": contentLength,\n \"X-Amz-Content-Sha256\": payloadHash,\n \"X-Amz-Date\": amzDate,\n Authorization: authorizationHeader,\n };\n}\n\nexport const apiConfig = () => {\n const aiConversationUrl = `https://mdv3qwfi2j.execute-api.us-east-1.amazonaws.com/dev/api/bedrock/invoke/stream`;\n const xAPIKey = \"BJBtjpPkqGatuoa3qJqdR8aHXSsHkgvGaootbubi\";\n // const serverUrl = \"https://tanya-sfcc-server.vercel.app/\";\n const serverUrl = import.meta.env.VITE_SERVER_BASE_URL;\n const basePath = import.meta.env.VITE_SCAPI_ENVIRONMENT ? \"sc-api\" : \"api\";\n\n return { aiConversationUrl, xAPIKey, serverUrl, basePath };\n};\n","import axios from \"axios\";\r\nimport { getHost, getSiteId } from \".\";\r\n\r\n// email:password:client need to be pass in encrypt form in the auth of fetchTokenBmGrant\r\n\r\n// email:password:client is different from user to user\r\nexport const fetchTokenBmGrant = async () => {\r\n const URL = `${import.meta.env.VITE_SERVER_BASE_URL}`;\r\n try {\r\n const response = await axios.post(\r\n `${URL}api/auth/token-bm-grant?baseUrl=${getHost()}&siteId=${getSiteId()}`\r\n );\r\n if (response.status === 200 && response.data.access_token) {\r\n return response.data.access_token;\r\n } else {\r\n console.error(\"Failed to fetch token:\", response.data);\r\n return null;\r\n }\r\n } catch (error) {\r\n if (axios.isAxiosError(error)) {\r\n console.error(\"Error fetching token:\", error.response || error.message);\r\n } else {\r\n console.error(\"Unexpected error:\", error);\r\n }\r\n return null;\r\n }\r\n};\r\n","import axios from \"axios\";\r\nimport { clientId, getHost, getSiteId, organisationId, shortCode } from \".\";\r\n\r\ninterface Customer {\r\n access_token: string;\r\n customerId: string;\r\n}\r\n\r\n// function getCookie(name: string): string | null {\r\n// const value = `; ${document.cookie}`;\r\n// console.log(\"parts\", value,value.includes(\"dwsid\"));\r\n// const parts = value.split(`; ${name}=`);\r\n// if (parts.length === 2) return parts.pop()?.split(\";\").shift() || null;\r\n// return null;\r\n// }\r\n\r\nexport const fetchExistingRegisterCustomerToken = async ({\r\n access_token,\r\n customerId,\r\n}: Customer) => {\r\n const URL = `${import.meta.env.VITE_SERVER_BASE_URL}`;\r\n try {\r\n const response = await axios.post(\r\n `${URL}api/auth/token-existing-register-customer/${customerId}?baseUrl=${getHost()}&siteId=${getSiteId()}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}`,\r\n {},\r\n {\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n Authorization: `Bearer ${access_token}`,\r\n },\r\n }\r\n );\r\n\r\n if (response.status === 200 && response.data) {\r\n // console.log(\"customer token res fe\", response.data)\r\n return response.data;\r\n }\r\n return null;\r\n } catch (error) {\r\n if (axios.isAxiosError(error)) {\r\n console.error(\"Error creating basket:\", error.response || error.message);\r\n } else {\r\n console.error(\"Unexpected error:\", error);\r\n }\r\n return null;\r\n }\r\n};\r\n\r\nexport const fetchExistingGuestCustomerToken = async (\r\n access_token: string,\r\n) => {\r\n const URL = `${import.meta.env.VITE_SERVER_BASE_URL}`;\r\n try {\r\n const dwsid = JSON.parse(sessionStorage.getItem(\"customerData\")|| \"{}\").dwsid // fetch cookie\r\n\r\n const response = await axios.post(\r\n `${URL}api/auth/token-existing-guest-customer?dwsid=${dwsid}&baseUrl=${getHost()}&siteId=${getSiteId()}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}`,\r\n {},\r\n {\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n Authorization: `Bearer ${access_token}`,\r\n },\r\n }\r\n );\r\n\r\n if (response.status === 200 && response.data) {\r\n return response.data;\r\n }\r\n return null;\r\n } catch (error) {\r\n if (axios.isAxiosError(error)) {\r\n console.error(\"Error creating basket:\", error.response || error.message);\r\n } else {\r\n console.error(\"Unexpected error:\", error);\r\n }\r\n return null;\r\n }\r\n};\r\n","import axios from \"axios\";\nimport { apiConfig } from \"../../config/api\";\nimport { clientId, getSiteId, organisationId, shortCode } from \"../../components/utils\";\n\nexport async function authData() {\n if (!import.meta.env.VITE_SCAPI_ENVIRONMENT) {\n return \"\";\n }\n const expires_in = localStorage.getItem(\"expires_in\");\n const access_token = localStorage.getItem(\"access_token\");\n const isGuest = JSON.parse(\n sessionStorage.getItem(\"customerData\") || \"{}\"\n ).isGuest;\n if (\n expires_in &&\n access_token &&\n new Date().getTime() < parseInt(expires_in) &&\n isGuest === JSON.parse(localStorage.getItem(\"isGuest\") || \"false\")\n ) {\n console.log(\"access token found in local storage\");\n return { access_token, expires_in };\n }\n const { serverUrl } = apiConfig();\n const dwsid = JSON.parse(\n sessionStorage.getItem(\"customerData\") || \"{}\"\n ).dwsid;\n\n const customerMail = JSON.parse(\n sessionStorage.getItem(\"customerData\") || \"{}\"\n ).usrRef;\n\n try {\n const endpoint = isGuest ? \"unregister-auth\" : \"register-auth\";\n const res = await axios.get(\n `${serverUrl}sc-api/${endpoint}?dwsid=${dwsid}&email=${customerMail}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}&siteId=${getSiteId()}`\n );\n localStorage.setItem(\"access_token\", res.data.access_token);\n localStorage.setItem(\n \"expires_in\",\n String(new Date().getTime() + res.data.expires_in * 1000)\n );\n localStorage.setItem(\"isGuest\", isGuest.toString());\n console.log(res.data);\n return res.data;\n } catch (err) {\n console.log(err);\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport axios from \"axios\";\nimport { apiConfig } from \"../../config/api\";\nimport { fetchTokenBmGrant } from \"./fetchTokenBmGrant\";\nimport { fetchExistingGuestCustomerToken } from \"./fetchExistingRegisterCustomerToken\";\nimport { authData } from \"../../sfcc-apis/session\";\n\nexport const getHost = () => {\n const host = sessionStorage.getItem(\"Host\");\n return host;\n};\n\nexport const getSiteId = () => {\n const siteId = sessionStorage.getItem(\"SiteId\");\n return siteId;\n};\n\nexport const clientId = () => {\n const clientId = sessionStorage.getItem(\"pubCfg\");\n return clientId;\n};\n\nexport const shortCode = () => {\n const shortCode = sessionStorage.getItem(\"envRef\");\n return shortCode;\n};\n\nexport const organisationId = () => {\n const orgRef = sessionStorage.getItem(\"orgRef\");\n return orgRef;\n};\n\nexport const getSearchResults = async (query: string, token: string) => {\n const { serverUrl, basePath } = apiConfig();\n\n try {\n const host = getHost();\n const response = await axios.get(\n `${serverUrl}${basePath}/search-sfcc?baseUrl=${host}&query=${query}&siteId=${getSiteId()}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}`,\n {\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${token}`,\n },\n }\n );\n\n return response.data.hits;\n } catch (error) {\n console.error(\"Error fetching search results:\", error);\n throw error;\n }\n};\n\nexport const getProductById = async (id: number | string) => {\n if (!id) throw new Error(\"Product ID is required\");\n const { serverUrl, basePath } = apiConfig();\n const host = getHost();\n console.log(\"calling access\");\n const { access_token } = await authData();\n console.log(access_token);\n const response = await axios.get(\n `${serverUrl}${basePath}/product-sfcc/${id}?baseUrl=${host}&siteId=${getSiteId()}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}`,\n {\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${access_token}`,\n },\n }\n );\n\n return response.data;\n};\n\nexport const getInterestApi = async (customerId: any) => {\n if (!customerId) throw new Error(\"customerId is required\");\n const access_token = await fetchTokenBmGrant();\n\n const { customer_token } = await fetchExistingGuestCustomerToken(\n access_token\n );\n const { serverUrl, basePath } = apiConfig();\n const data = await authData();\n const token = data.access_token;\n\n const response = await axios.get(\n `${serverUrl}${basePath}/get-interest?baseUrl=${getHost()}&customerId=${customerId}&siteId=${getSiteId()}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}`,\n {\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: import.meta.env.VITE_SCAPI_ENVIRONMENT\n ? `Bearer ${token}`\n : `${customer_token}`,\n },\n }\n );\n\n return response.data;\n};\n","import CryptoJS from \"crypto-js\";\nconst SECRET_KEY = \"admin_one\";\nexport const displayData = (data) => {\n if (typeof data === \"string\") {\n return String(data);\n }\n return String(data[\"en-US\"] || data);\n};\nexport const imageUrlArray = (data) => {\n if (data?.image) {\n return [data.image];\n }\n else if (\"variants\" in data) {\n return data.variants[0].images;\n }\n return data.masterVariant.images.map((image) => image.url);\n};\nexport const currencyFormatter = (data, currencyCode) => {\n return data.toLocaleString(\"en-US\", {\n style: \"currency\",\n currency: currencyCode || \"USD\",\n });\n};\nexport const priceFormatter = (data) => {\n if (\"variants\" in data) {\n return {\n centAmount: data.variants[0]?.prices.EUR.max,\n currencyCode: \"DOL\",\n };\n }\n return {\n centAmount: data.masterVariant?.prices[0].value.centAmount,\n currencyCode: data.masterVariant?.prices[0].value.currencyCode,\n };\n};\nexport const encryptData = (data) => {\n return CryptoJS.AES.encrypt(JSON.stringify(data), SECRET_KEY).toString();\n};\nexport const decryptData = (cipherText) => {\n const bytes = CryptoJS.AES.decrypt(cipherText, SECRET_KEY);\n return JSON.parse(bytes.toString(CryptoJS.enc.Utf8));\n};\nexport const initialCapital = (text) => {\n return text.charAt(0).toUpperCase() + text.slice(1);\n};\nexport const laterDate = (day) => {\n const fiveDaysLater = new Date();\n fiveDaysLater.setDate(fiveDaysLater.getDate() + day);\n const formattedDate = fiveDaysLater.toLocaleDateString(\"en-US\", {\n day: \"numeric\",\n month: \"long\",\n });\n return formattedDate;\n};\nexport const stringReducer = (text, length) => {\n return text.length < length ? text : text.slice(0, length) + \"...\";\n};\nexport const formatStringToHtml = (str) => {\n return str\n .split(\"\\\\n\")\n .map((line, index) => {\n const numberedPoint = line.match(/^(\\d+)\\.\\s(.+)/);\n if (numberedPoint) {\n return `<p key=${index} class=\"mb-2\"><strong>${numberedPoint[1]}.</strong> ${numberedPoint[2]}</p>`;\n }\n return line.trim() ? `<p key=${index} class=\"mb-2\">${line}</p>` : \"<br/>\";\n })\n .join(\"\");\n};\n","'use client';\n\nimport { createElement, forwardRef, useState, useEffect } from 'react';\n\n/**\n* Resolve icon set icons\n*\n* Returns parent icon for each icon\n*/\nfunction getIconsTree(data, names) {\n\tconst icons = data.icons;\n\tconst aliases = data.aliases || Object.create(null);\n\tconst resolved = Object.create(null);\n\tfunction resolve(name) {\n\t\tif (icons[name]) return resolved[name] = [];\n\t\tif (!(name in resolved)) {\n\t\t\tresolved[name] = null;\n\t\t\tconst parent = aliases[name] && aliases[name].parent;\n\t\t\tconst value = parent && resolve(parent);\n\t\t\tif (value) resolved[name] = [parent].concat(value);\n\t\t}\n\t\treturn resolved[name];\n\t}\n\t(Object.keys(icons).concat(Object.keys(aliases))).forEach(resolve);\n\treturn resolved;\n}\n\n/**\n* Default values for dimensions\n*/\nconst defaultIconDimensions = Object.freeze({\n\tleft: 0,\n\ttop: 0,\n\twidth: 16,\n\theight: 16\n});\n/**\n* Default values for transformations\n*/\nconst defaultIconTransformations = Object.freeze({\n\trotate: 0,\n\tvFlip: false,\n\thFlip: false\n});\n/**\n* Default values for all optional IconifyIcon properties\n*/\nconst defaultIconProps = Object.freeze({\n\t...defaultIconDimensions,\n\t...defaultIconTransformations\n});\n/**\n* Default values for all properties used in ExtendedIconifyIcon\n*/\nconst defaultExtendedIconProps = Object.freeze({\n\t...defaultIconProps,\n\tbody: \"\",\n\thidden: false\n});\n\n/**\n* Merge transformations\n*/\nfunction mergeIconTransformations(obj1, obj2) {\n\tconst result = {};\n\tif (!obj1.hFlip !== !obj2.hFlip) result.hFlip = true;\n\tif (!obj1.vFlip !== !obj2.vFlip) result.vFlip = true;\n\tconst rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;\n\tif (rotate) result.rotate = rotate;\n\treturn result;\n}\n\n/**\n* Merge icon and alias\n*\n* Can also be used to merge default values and icon\n*/\nfunction mergeIconData(parent, child) {\n\tconst result = mergeIconTransformations(parent, child);\n\tfor (const key in defaultExtendedIconProps) if (key in defaultIconTransformations) {\n\t\tif (key in parent && !(key in result)) result[key] = defaultIconTransformations[key];\n\t} else if (key in child) result[key] = child[key];\n\telse if (key in parent) result[key] = parent[key];\n\treturn result;\n}\n\n/**\n* Get icon data, using prepared aliases tree\n*/\nfunction internalGetIconData(data, name, tree) {\n\tconst icons = data.icons;\n\tconst aliases = data.aliases || Object.create(null);\n\tlet currentProps = {};\n\tfunction parse(name$1) {\n\t\tcurrentProps = mergeIconData(icons[name$1] || aliases[name$1], currentProps);\n\t}\n\tparse(name);\n\ttree.forEach(parse);\n\treturn mergeIconData(data, currentProps);\n}\n\n/**\n* Extract icons from an icon set\n*\n* Returns list of icons that were found in icon set\n*/\nfunction parseIconSet(data, callback) {\n\tconst names = [];\n\tif (typeof data !== \"object\" || typeof data.icons !== \"object\") return names;\n\tif (data.not_found instanceof Array) data.not_found.forEach((name) => {\n\t\tcallback(name, null);\n\t\tnames.push(name);\n\t});\n\tconst tree = getIconsTree(data);\n\tfor (const name in tree) {\n\t\tconst item = tree[name];\n\t\tif (item) {\n\t\t\tcallback(name, internalGetIconData(data, name, item));\n\t\t\tnames.push(name);\n\t\t}\n\t}\n\treturn names;\n}\n\n/**\n* Optional properties\n*/\nconst optionalPropertyDefaults = {\n\tprovider: \"\",\n\taliases: {},\n\tnot_found: {},\n\t...defaultIconDimensions\n};\n/**\n* Check props\n*/\nfunction checkOptionalProps(item, defaults) {\n\tfor (const prop in defaults) if (prop in item && typeof item[prop] !== typeof defaults[prop]) return false;\n\treturn true;\n}\n/**\n* Validate icon set, return it as IconifyJSON on success, null on failure\n*\n* Unlike validateIconSet(), this function is very basic.\n* It does not throw exceptions, it does not check metadata, it does not fix stuff.\n*/\nfunction quicklyValidateIconSet(obj) {\n\tif (typeof obj !== \"object\" || obj === null) return null;\n\tconst data = obj;\n\tif (typeof data.prefix !== \"string\" || !obj.icons || typeof obj.icons !== \"object\") return null;\n\tif (!checkOptionalProps(obj, optionalPropertyDefaults)) return null;\n\tconst icons = data.icons;\n\tfor (const name in icons) {\n\t\tconst icon = icons[name];\n\t\tif (!name || typeof icon.body !== \"string\" || !checkOptionalProps(icon, defaultExtendedIconProps)) return null;\n\t}\n\tconst aliases = data.aliases || Object.create(null);\n\tfor (const name in aliases) {\n\t\tconst icon = aliases[name];\n\t\tconst parent = icon.parent;\n\t\tif (!name || typeof parent !== \"string\" || !icons[parent] && !aliases[parent] || !checkOptionalProps(icon, defaultExtendedIconProps)) return null;\n\t}\n\treturn data;\n}\n\n/**\n* Storage by provider and prefix\n*/\nconst dataStorage = Object.create(null);\n/**\n* Create new storage\n*/\nfunction newStorage(provider, prefix) {\n\treturn {\n\t\tprovider,\n\t\tprefix,\n\t\ticons: Object.create(null),\n\t\tmissing: /* @__PURE__ */ new Set()\n\t};\n}\n/**\n* Get storage for provider and prefix\n*/\nfunction getStorage(provider, prefix) {\n\tconst providerStorage = dataStorage[provider] || (dataStorage[provider] = Object.create(null));\n\treturn providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));\n}\n/**\n* Add icon set to storage\n*\n* Returns array of added icons\n*/\nfunction addIconSet(storage, data) {\n\tif (!quicklyValidateIconSet(data)) return [];\n\treturn parseIconSet(data, (name, icon) => {\n\t\tif (icon) storage.icons[name] = icon;\n\t\telse storage.missing.add(name);\n\t});\n}\n/**\n* Add icon to storage\n*/\nfunction addIconToStorage(storage, name, icon) {\n\ttry {\n\t\tif (typeof icon.body === \"string\") {\n\t\t\tstorage.icons[name] = { ...icon };\n\t\t\treturn true;\n\t\t}\n\t} catch (err) {}\n\treturn false;\n}\n/**\n* List available icons\n*/\nfunction listIcons(provider, prefix) {\n\tlet allIcons = [];\n\tconst providers = typeof provider === \"string\" ? [provider] : Object.keys(dataStorage);\n\tproviders.forEach((provider$1) => {\n\t\tconst prefixes = typeof provider$1 === \"string\" && typeof prefix === \"string\" ? [prefix] : Object.keys(dataStorage[provider$1] || {});\n\t\tprefixes.forEach((prefix$1) => {\n\t\t\tconst storage = getStorage(provider$1, prefix$1);\n\t\t\tallIcons = allIcons.concat(Object.keys(storage.icons).map((name) => (provider$1 !== \"\" ? \"@\" + provider$1 + \":\" : \"\") + prefix$1 + \":\" + name));\n\t\t});\n\t});\n\treturn allIcons;\n}\n\n/**\n* Expression to test part of icon name.\n*\n* Used when loading icons from Iconify API due to project naming convension.\n* Ignored when using custom icon sets - convension does not apply.\n*/\nconst matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;\n/**\n* Convert string icon name to IconifyIconName object.\n*/\nconst stringToIcon = (value, validate, allowSimpleName, provider = \"\") => {\n\tconst colonSeparated = value.split(\":\");\n\tif (value.slice(0, 1) === \"@\") {\n\t\tif (colonSeparated.length < 2 || colonSeparated.length > 3) return null;\n\t\tprovider = colonSeparated.shift().slice(1);\n\t}\n\tif (colonSeparated.length > 3 || !colonSeparated.length) return null;\n\tif (colonSeparated.length > 1) {\n\t\tconst name$1 = colonSeparated.pop();\n\t\tconst prefix = colonSeparated.pop();\n\t\tconst result = {\n\t\t\tprovider: colonSeparated.length > 0 ? colonSeparated[0] : provider,\n\t\t\tprefix,\n\t\t\tname: name$1\n\t\t};\n\t\treturn validate && !validateIconName(result) ? null : result;\n\t}\n\tconst name = colonSeparated[0];\n\tconst dashSeparated = name.split(\"-\");\n\tif (dashSeparated.length > 1) {\n\t\tconst result = {\n\t\t\tprovider,\n\t\t\tprefix: dashSeparated.shift(),\n\t\t\tname: dashSeparated.join(\"-\")\n\t\t};\n\t\treturn validate && !validateIconName(result) ? null : result;\n\t}\n\tif (allowSimpleName && provider === \"\") {\n\t\tconst result = {\n\t\t\tprovider,\n\t\t\tprefix: \"\",\n\t\t\tname\n\t\t};\n\t\treturn validate && !validateIconName(result, allowSimpleName) ? null : result;\n\t}\n\treturn null;\n};\n/**\n* Check if icon is valid.\n*\n* This function is not part of stringToIcon because validation is not needed for most code.\n*/\nconst validateIconName = (icon, allowSimpleName) => {\n\tif (!icon) return false;\n\treturn !!((allowSimpleName && icon.prefix === \"\" || !!icon.prefix) && !!icon.name);\n};\n\n/**\n* Allow storing icons without provider or prefix, making it possible to store icons like \"home\"\n*/\nlet simpleNames = false;\nfunction allowSimpleNames(allow) {\n\tif (typeof allow === \"boolean\") simpleNames = allow;\n\treturn simpleNames;\n}\n/**\n* Get icon data\n*\n* Returns:\n* - IconifyIcon on success, object directly from storage so don't modify it\n* - null if icon is marked as missing (returned in `not_found` property from API, so don't bother sending API requests)\n* - undefined if icon is missing in storage\n*/\nfunction getIconData(name) {\n\tconst icon = typeof name === \"string\" ? stringToIcon(name, true, simpleNames) : name;\n\tif (icon) {\n\t\tconst storage = getStorage(icon.provider, icon.prefix);\n\t\tconst iconName = icon.name;\n\t\treturn storage.icons[iconName] || (storage.missing.has(iconName) ? null : void 0);\n\t}\n}\n/**\n* Add one icon\n*/\nfunction addIcon(name, data) {\n\tconst icon = stringToIcon(name, true, simpleNames);\n\tif (!icon) return false;\n\tconst storage = getStorage(icon.provider, icon.prefix);\n\tif (data) return addIconToStorage(storage, icon.name, data);\n\telse {\n\t\tstorage.missing.add(icon.name);\n\t\treturn true;\n\t}\n}\n/**\n* Add icon set\n*/\nfunction addCollection(data, provider) {\n\tif (typeof data !== \"object\") return false;\n\tif (typeof provider !== \"string\") provider = data.provider || \"\";\n\tif (simpleNames && !provider && !data.prefix) {\n\t\tlet added = false;\n\t\tif (quicklyValidateIconSet(data)) {\n\t\t\tdata.prefix = \"\";\n\t\t\tparseIconSet(data, (name, icon) => {\n\t\t\t\tif (addIcon(name, icon)) added = true;\n\t\t\t});\n\t\t}\n\t\treturn added;\n\t}\n\tconst prefix = data.prefix;\n\tif (!validateIconName({\n\t\tprefix,\n\t\tname: \"a\"\n\t})) return false;\n\tconst storage = getStorage(provider, prefix);\n\treturn !!addIconSet(storage, data);\n}\n/**\n* Check if icon data is available\n*/\nfunction iconLoaded(name) {\n\treturn !!getIconData(name);\n}\n/**\n* Get full icon\n*/\nfunction getIcon(name) {\n\tconst result = getIconData(name);\n\treturn result ? {\n\t\t...defaultIconProps,\n\t\t...result\n\t} : result;\n}\n\n/**\n* Default icon customisations values\n*/\nconst defaultIconSizeCustomisations = Object.freeze({\n\twidth: null,\n\theight: null\n});\nconst defaultIconCustomisations = Object.freeze({\n\t...defaultIconSizeCustomisations,\n\t...defaultIconTransformations\n});\n\n/**\n* Regular expressions for calculating dimensions\n*/\nconst unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;\nconst unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;\nfunction calculateSize(size, ratio, precision) {\n\tif (ratio === 1) return size;\n\tprecision = precision || 100;\n\tif (typeof size === \"number\") return Math.ceil(size * ratio * precision) / precision;\n\tif (typeof size !== \"string\") return size;\n\tconst oldParts = size.split(unitsSplit);\n\tif (oldParts === null || !oldParts.length) return size;\n\tconst newParts = [];\n\tlet code = oldParts.shift();\n\tlet isNumber = unitsTest.test(code);\n\twhile (true) {\n\t\tif (isNumber) {\n\t\t\tconst num = parseFloat(code);\n\t\t\tif (isNaN(num)) newParts.push(code);\n\t\t\telse newParts.push(Math.ceil(num * ratio * precision) / precision);\n\t\t} else newParts.push(code);\n\t\tcode = oldParts.shift();\n\t\tif (code === void 0) return newParts.join(\"\");\n\t\tisNumber = !isNumber;\n\t}\n}\n\nfunction splitSVGDefs(content, tag = \"defs\") {\n\tlet defs = \"\";\n\tconst index = content.indexOf(\"<\" + tag);\n\twhile (index >= 0) {\n\t\tconst start = content.indexOf(\">\", index);\n\t\tconst end = content.indexOf(\"</\" + tag);\n\t\tif (start === -1 || end === -1) break;\n\t\tconst endEnd = content.indexOf(\">\", end);\n\t\tif (endEnd === -1) break;\n\t\tdefs += content.slice(start + 1, end).trim();\n\t\tcontent = content.slice(0, index).trim() + content.slice(endEnd + 1);\n\t}\n\treturn {\n\t\tdefs,\n\t\tcontent\n\t};\n}\n/**\n* Merge defs and content\n*/\nfunction mergeDefsAndContent(defs, content) {\n\treturn defs ? \"<defs>\" + defs + \"</defs>\" + content : content;\n}\n/**\n* Wrap SVG content, without wrapping definitions\n*/\nfunction wrapSVGContent(body, start, end) {\n\tconst split = splitSVGDefs(body);\n\treturn mergeDefsAndContent(split.defs, start + split.content + end);\n}\n\n/**\n* Check if value should be unset. Allows multiple keywords\n*/\nconst isUnsetKeyword = (value) => value === \"unset\" || value === \"undefined\" || value === \"none\";\n/**\n* Get SVG attributes and content from icon + customisations\n*\n* Does not generate style to make it compatible with frameworks that use objects for style, such as React.\n* Instead, it generates 'inline' value. If true, rendering engine should add verticalAlign: -0.125em to icon.\n*\n* Customisations should be normalised by platform specific parser.\n* Result should be converted to <svg> by platform specific parser.\n* Use replaceIDs to generate unique IDs for body.\n*/\nfunction iconToSVG(icon, customisations) {\n\tconst fullIcon = {\n\t\t...defaultIconProps,\n\t\t...icon\n\t};\n\tconst fullCustomisations = {\n\t\t...defaultIconCustomisations,\n\t\t...customisations\n\t};\n\tconst box = {\n\t\tleft: fullIcon.left,\n\t\ttop: fullIcon.top,\n\t\twidth: fullIcon.width,\n\t\theight: fullIcon.height\n\t};\n\tlet body = fullIcon.body;\n\t[fullIcon, fullCustomisations].forEach((props) => {\n\t\tconst transformations = [];\n\t\tconst hFlip = props.hFlip;\n\t\tconst vFlip = props.vFlip;\n\t\tlet rotation = props.rotate;\n\t\tif (hFlip) if (vFlip) rotation += 2;\n\t\telse {\n\t\t\ttransformations.push(\"translate(\" + (box.width + box.left).toString() + \" \" + (0 - box.top).toString() + \")\");\n\t\t\ttransformations.push(\"scale(-1 1)\");\n\t\t\tbox.top = box.left = 0;\n\t\t}\n\t\telse if (vFlip) {\n\t\t\ttransformations.push(\"translate(\" + (0 - box.left).toString() + \" \" + (box.height + box.top).toString() + \")\");\n\t\t\ttransformations.push(\"scale(1 -1)\");\n\t\t\tbox.top = box.left = 0;\n\t\t}\n\t\tlet tempValue;\n\t\tif (rotation < 0) rotation -= Math.floor(rotation / 4) * 4;\n\t\trotation = rotation % 4;\n\t\tswitch (rotation) {\n\t\t\tcase 1:\n\t\t\t\ttempValue = box.height / 2 + box.top;\n\t\t\t\ttransformations.unshift(\"rotate(90 \" + tempValue.toString() + \" \" + tempValue.toString() + \")\");\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\ttransformations.unshift(\"rotate(180 \" + (box.width / 2 + box.left).toString() + \" \" + (box.height / 2 + box.top).toString() + \")\");\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\ttempValue = box.width / 2 + box.left;\n\t\t\t\ttransformations.unshift(\"rotate(-90 \" + tempValue.toString() + \" \" + tempValue.toString() + \")\");\n\t\t\t\tbreak;\n\t\t}\n\t\tif (rotation % 2 === 1) {\n\t\t\tif (box.left !== box.top) {\n\t\t\t\ttempValue = box.left;\n\t\t\t\tbox.left = box.top;\n\t\t\t\tbox.top = tempValue;\n\t\t\t}\n\t\t\tif (box.width !== box.height) {\n\t\t\t\ttempValue = box.width;\n\t\t\t\tbox.width = box.height;\n\t\t\t\tbox.height = tempValue;\n\t\t\t}\n\t\t}\n\t\tif (transformations.length) body = wrapSVGContent(body, \"<g transform=\\\"\" + transformations.join(\" \") + \"\\\">\", \"</g>\");\n\t});\n\tconst customisationsWidth = fullCustomisations.width;\n\tconst customisationsHeight = fullCustomisations.height;\n\tconst boxWidth = box.width;\n\tconst boxHeight = box.height;\n\tlet width;\n\tlet height;\n\tif (customisationsWidth === null) {\n\t\theight = customisationsHeight === null ? \"1em\" : customisationsHeight === \"auto\" ? boxHeight : customisationsHeight;\n\t\twidth = calculateSize(height, boxWidth / boxHeight);\n\t} else {\n\t\twidth = customisationsWidth === \"auto\" ? boxWidth : customisationsWidth;\n\t\theight = customisationsHeight === null ? calculateSize(width, boxHeight / boxWidth) : customisationsHeight === \"auto\" ? boxHeight : customisationsHeight;\n\t}\n\tconst attributes = {};\n\tconst setAttr = (prop, value) => {\n\t\tif (!isUnsetKeyword(value)) attributes[prop] = value.toString();\n\t};\n\tsetAttr(\"width\", width);\n\tsetAttr(\"height\", height);\n\tconst viewBox = [\n\t\tbox.left,\n\t\tbox.top,\n\t\tboxWidth,\n\t\tboxHeight\n\t];\n\tattributes.viewBox = viewBox.join(\" \");\n\treturn {\n\t\tattributes,\n\t\tviewBox,\n\t\tbody\n\t};\n}\n\n/**\n* IDs usage:\n*\n* id=\"{id}\"\n* xlink:href=\"#{id}\"\n* url(#{id})\n*\n* From SVG animations:\n*\n* begin=\"0;{id}.end\"\n* begin=\"{id}.end\"\n* begin=\"{id}.click\"\n*/\n/**\n* Regular expression for finding ids\n*/\nconst regex = /\\sid=\"(\\S+)\"/g;\n/**\n* New random-ish prefix for ids\n*\n* Do not use dash, it cannot be used in SVG 2 animations\n*/\nconst randomPrefix = \"IconifyId\" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16);\n/**\n* Counter for ids, increasing with every replacement\n*/\nlet counter = 0;\n/**\n* Replace IDs in SVG output with unique IDs\n*/\nfunction replaceIDs(body, prefix = randomPrefix) {\n\tconst ids = [];\n\tlet match;\n\twhile (match = regex.exec(body)) ids.push(match[1]);\n\tif (!ids.length) return body;\n\tconst suffix = \"suffix\" + (Math.random() * 16777216 | Date.now()).toString(16);\n\tids.forEach((id) => {\n\t\tconst newID = typeof prefix === \"function\" ? prefix(id) : prefix + (counter++).toString();\n\t\tconst escapedID = id.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t\tbody = body.replace(new RegExp(\"([#;\\\"])(\" + escapedID + \")([\\\")]|\\\\.[a-z])\", \"g\"), \"$1\" + newID + suffix + \"$3\");\n\t});\n\tbody = body.replace(new RegExp(suffix, \"g\"), \"\");\n\treturn body;\n}\n\n/**\n* Local storate types and entries\n*/\nconst storage = Object.create(null);\n/**\n* Set API module\n*/\nfunction setAPIModule(provider, item) {\n\tstorage[provider] = item;\n}\n/**\n* Get API module\n*/\nfunction getAPIModule(provider) {\n\treturn storage[provider] || storage[\"\"];\n}\n\n/**\n* Create full API configuration from partial data\n*/\nfunction createAPIConfig(source) {\n\tlet resources;\n\tif (typeof source.resources === \"string\") resources = [source.resources];\n\telse {\n\t\tresources = source.resources;\n\t\tif (!(resources instanceof Array) || !resources.length) return null;\n\t}\n\tconst result = {\n\t\tresources,\n\t\tpath: source.path || \"/\",\n\t\tmaxURL: source.maxURL || 500,\n\t\trotate: source.rotate || 750,\n\t\ttimeout: source.timeout || 5e3,\n\t\trandom: source.random === true,\n\t\tindex: source.index || 0,\n\t\tdataAfterTimeout: source.dataAfterTimeout !== false\n\t};\n\treturn result;\n}\n/**\n* Local storage\n*/\nconst configStorage = Object.create(null);\n/**\n* Redundancy for API servers.\n*\n* API should have very high uptime because of implemented redundancy at server level, but\n* sometimes bad things happen. On internet 100% uptime is not possible.\n*\n* There could be routing problems. Server might go down for whatever reason, but it takes\n* few minutes to detect that downtime, so during those few minutes API might not be accessible.\n*\n* This script has some redundancy to mitigate possible network issues.\n*\n* If one host cannot be reached in 'rotate' (750 by default) ms, script will try to retrieve\n* data from different host. Hosts have different configurations, pointing to different\n* API servers hosted at different providers.\n*/\nconst fallBackAPISources = [\"https://api.simplesvg.com\", \"https://api.unisvg.com\"];\nconst fallBackAPI = [];\nwhile (fallBackAPISources.length > 0) if (fallBackAPISources.length === 1) fallBackAPI.push(fallBackAPISources.shift());\nelse if (Math.random() > .5) fallBackAPI.push(fallBackAPISources.shift());\nelse fallBackAPI.push(fallBackAPISources.pop());\nconfigStorage[\"\"] = createAPIConfig({ resources: [\"https://api.iconify.design\"].concat(fallBackAPI) });\n/**\n* Add custom config for provider\n*/\nfunction addAPIProvider(provider, customConfig) {\n\tconst config = createAPIConfig(customConfig);\n\tif (config === null) return false;\n\tconfigStorage[provider] = config;\n\treturn true;\n}\n/**\n* Get API configuration\n*/\nfunction getAPIConfig(provider) {\n\treturn configStorage[provider];\n}\n/**\n* List API providers\n*/\nfunction listAPIProviders() {\n\treturn Object.keys(configStorage);\n}\n\nconst detectFetch = () => {\n\tlet callback;\n\ttry {\n\t\tcallback = fetch;\n\t\tif (typeof callback === \"function\") return callback;\n\t} catch (err) {}\n};\n/**\n* Fetch function\n*/\nlet fetchModule = detectFetch();\n/**\n* Set custom fetch() function\n*/\nfunction setFetch(fetch$1) {\n\tfetchModule = fetch$1;\n}\n/**\n* Get fetch() function. Used by Icon Finder Core\n*/\nfunction getFetch() {\n\treturn fetchModule;\n}\n/**\n* Calculate maximum icons list length for prefix\n*/\nfunction calculateMaxLength(provider, prefix) {\n\tconst config = getAPIConfig(provider);\n\tif (!config) return 0;\n\tlet result;\n\tif (!config.maxURL) result = 0;\n\telse {\n\t\tlet maxHostLength = 0;\n\t\tconfig.resources.forEach((item) => {\n\t\t\tconst host = item;\n\t\t\tmaxHostLength = Math.max(maxHostLength, host.length);\n\t\t});\n\t\tconst url = prefix + \".json?icons=\";\n\t\tresult = config.maxURL - maxHostLength - config.path.length - url.length;\n\t}\n\treturn result;\n}\n/**\n* Should query be aborted, based on last HTTP status\n*/\nfunction shouldAbort(status) {\n\treturn status === 404;\n}\n/**\n* Prepare params\n*/\nconst prepare = (provider, prefix, icons) => {\n\tconst results = [];\n\tconst maxLength = calculateMaxLength(provider, prefix);\n\tconst type = \"icons\";\n\tlet item = {\n\t\ttype,\n\t\tprovider,\n\t\tprefix,\n\t\ticons: []\n\t};\n\tlet length = 0;\n\ticons.forEach((name, index) => {\n\t\tlength += name.length + 1;\n\t\tif (length >= maxLength && index > 0) {\n\t\t\tresults.push(item);\n\t\t\titem = {\n\t\t\t\ttype,\n\t\t\t\tprovider,\n\t\t\t\tprefix,\n\t\t\t\ticons: []\n\t\t\t};\n\t\t\tlength = name.length;\n\t\t}\n\t\titem.icons.push(name);\n\t});\n\tresults.push(item);\n\treturn results;\n};\n/**\n* Get path\n*/\nfunction getPath(provider) {\n\tif (typeof provider === \"string\") {\n\t\tconst config = getAPIConfig(provider);\n\t\tif (config) return config.path;\n\t}\n\treturn \"/\";\n}\n/**\n* Load icons\n*/\nconst send = (host, params, callback) => {\n\tif (!fetchModule) {\n\t\tcallback(\"abort\", 424);\n\t\treturn;\n\t}\n\tlet path = getPath(params.provider);\n\tswitch (params.type) {\n\t\tcase \"icons\": {\n\t\t\tconst prefix = params.prefix;\n\t\t\tconst icons = params.icons;\n\t\t\tconst iconsList = icons.join(\",\");\n\t\t\tconst urlParams = new URLSearchParams({ icons: iconsList });\n\t\t\tpath += prefix + \".json?\" + urlParams.toString();\n\t\t\tbreak;\n\t\t}\n\t\tcase \"custom\": {\n\t\t\tconst uri = params.uri;\n\t\t\tpath += uri.slice(0, 1) === \"/\" ? uri.slice(1) : uri;\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tcallback(\"abort\", 400);\n\t\t\treturn;\n\t}\n\tlet defaultError = 503;\n\tfetchModule(host + path).then((response) => {\n\t\tconst status = response.status;\n\t\tif (status !== 200) {\n\t\t\tsetTimeout(() => {\n\t\t\t\tcallback(shouldAbort(status) ? \"abort\" : \"next\", status);\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tdefaultError = 501;\n\t\treturn response.json();\n\t}).then((data) => {\n\t\tif (typeof data !== \"object\" || data === null) {\n\t\t\tsetTimeout(() => {\n\t\t\t\tif (data === 404) callback(\"abort\", data);\n\t\t\t\telse callback(\"next\", defaultError);\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tsetTimeout(() => {\n\t\t\tcallback(\"success\", data);\n\t\t});\n\t}).catch(() => {\n\t\tcallback(\"next\", defaultError);\n\t});\n};\n/**\n* Export module\n*/\nconst fetchAPIModule = {\n\tprepare,\n\tsend\n};\n\n/**\n* Remove callback\n*/\nfunction removeCallback(storages, id) {\n\tstorages.forEach((storage) => {\n\t\tconst items = storage.loaderCallbacks;\n\t\tif (items) storage.loaderCallbacks = items.filter((row) => row.id !== id);\n\t});\n}\n/**\n* Update all callbacks for provider and prefix\n*/\nfunction updateCallbacks(storage) {\n\tif (!storage.pendingCallbacksFlag) {\n\t\tstorage.pendingCallbacksFlag = true;\n\t\tsetTimeout(() => {\n\t\t\tstorage.pendingCallbacksFlag = false;\n\t\t\tconst items = storage.loaderCallbacks ? storage.loaderCallbacks.slice(0) : [];\n\t\t\tif (!items.length) return;\n\t\t\tlet hasPending = false;\n\t\t\tconst provider = storage.provider;\n\t\t\tconst prefix = storage.prefix;\n\t\t\titems.forEach((item) => {\n\t\t\t\tconst icons = item.icons;\n\t\t\t\tconst oldLength = icons.pending.length;\n\t\t\t\ticons.pending = icons.pending.filter((icon) => {\n\t\t\t\t\tif (icon.prefix !== prefix) return true;\n\t\t\t\t\tconst name = icon.name;\n\t\t\t\t\tif (storage.icons[name]) icons.loaded.push({\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\tprefix,\n\t\t\t\t\t\tname\n\t\t\t\t\t});\n\t\t\t\t\telse if (storage.missing.has(name)) icons.missing.push({\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\tprefix,\n\t\t\t\t\t\tname\n\t\t\t\t\t});\n\t\t\t\t\telse {\n\t\t\t\t\t\thasPending = true;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t});\n\t\t\t\tif (icons.pending.length !== oldLength) {\n\t\t\t\t\tif (!hasPending) removeCallback([storage], item.id);\n\t\t\t\t\titem.callback(icons.loaded.slice(0), icons.missing.slice(0), icons.pending.slice(0), item.abort);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n}\n/**\n* Unique id counter for callbacks\n*/\nlet idCounter = 0;\n/**\n* Add callback\n*/\nfunction storeCallback(callback, icons, pendingSources) {\n\tconst id = idCounter++;\n\tconst abort = removeCallback.bind(null, pendingSources, id);\n\tif (!icons.pending.length) return abort;\n\tconst item = {\n\t\tid,\n\t\ticons,\n\t\tcallback,\n\t\tabort\n\t};\n\tpendingSources.forEach((storage) => {\n\t\t(storage.loaderCallbacks || (storage.loaderCallbacks = [])).push(item);\n\t});\n\treturn abort;\n}\n\n/**\n* Check if icons have been loaded\n*/\nfunction sortIcons(icons) {\n\tconst result = {\n\t\tloaded: [],\n\t\tmissing: [],\n\t\tpending: []\n\t};\n\tconst storage = Object.create(null);\n\ticons.sort((a, b) => {\n\t\tif (a.provider !== b.provider) return a.provider.localeCompare(b.provider);\n\t\tif (a.prefix !== b.prefix) return a.prefix.localeCompare(b.prefix);\n\t\treturn a.name.localeCompare(b.name);\n\t});\n\tlet lastIcon = {\n\t\tprovider: \"\",\n\t\tprefix: \"\",\n\t\tname: \"\"\n\t};\n\ticons.forEach((icon) => {\n\t\tif (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) return;\n\t\tlastIcon = icon;\n\t\tconst provider = icon.provider;\n\t\tconst prefix = icon.prefix;\n\t\tconst name = icon.name;\n\t\tconst providerStorage = storage[provider] || (storage[provider] = Object.create(null));\n\t\tconst localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));\n\t\tlet list;\n\t\tif (name in localStorage.icons) list = result.loaded;\n\t\telse if (prefix === \"\" || localStorage.missing.has(name)) list = result.missing;\n\t\telse list = result.pending;\n\t\tconst item = {\n\t\t\tprovider,\n\t\t\tprefix,\n\t\t\tname\n\t\t};\n\t\tlist.push(item);\n\t});\n\treturn result;\n}\n\n/**\n* Convert icons list from string/icon mix to icons and validate them\n*/\nfunction listToIcons(list, validate = true, simpleNames = false) {\n\tconst result = [];\n\tlist.forEach((item) => {\n\t\tconst icon = typeof item === \"string\" ? stringToIcon(item, validate, simpleNames) : item;\n\t\tif (icon) result.push(icon);\n\t});\n\treturn result;\n}\n\n/**\n* Default RedundancyConfig for API calls\n*/\nconst defaultConfig = {\n\tresources: [],\n\tindex: 0,\n\ttimeout: 2e3,\n\trotate: 750,\n\trandom: false,\n\tdataAfterTimeout: false\n};\n\n/**\n* Send query\n*/\nfunction sendQuery(config, payload, query, done) {\n\tconst resourcesCount = config.resources.length;\n\tconst startIndex = config.random ? Math.floor(Math.random() * resourcesCount) : config.index;\n\tlet resources;\n\tif (config.random) {\n\t\tlet list = config.resources.slice(0);\n\t\tresources = [];\n\t\twhile (list.length > 1) {\n\t\t\tconst nextIndex = Math.floor(Math.random() * list.length);\n\t\t\tresources.push(list[nextIndex]);\n\t\t\tlist = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));\n\t\t}\n\t\tresources = resources.concat(list);\n\t} else resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));\n\tconst startTime = Date.now();\n\tlet status = \"pending\";\n\tlet queriesSent = 0;\n\tlet lastError;\n\tlet timer = null;\n\tlet queue = [];\n\tlet doneCallbacks = [];\n\tif (typeof done === \"function\") doneCallbacks.push(done);\n\t/**\n\t* Reset timer\n\t*/\n\tfunction resetTimer() {\n\t\tif (timer) {\n\t\t\tclearTimeout(timer);\n\t\t\ttimer = null;\n\t\t}\n\t}\n\t/**\n\t* Abort everything\n\t*/\n\tfunction abort() {\n\t\tif (status === \"pending\") status = \"aborted\";\n\t\tresetTimer();\n\t\tqueue.forEach((item) => {\n\t\t\tif (item.status === \"pending\") item.status = \"aborted\";\n\t\t});\n\t\tqueue = [];\n\t}\n\t/**\n\t* Add / replace callback to call when execution is complete.\n\t* This can be used to abort pending query implementations when query is complete or aborted.\n\t*/\n\tfunction subscribe(callback, overwrite) {\n\t\tif (overwrite) doneCallbacks = [];\n\t\tif (typeof callback === \"function\") doneCallbacks.push(callback);\n\t}\n\t/**\n\t* Get query status\n\t*/\n\tfunction getQueryStatus() {\n\t\treturn {\n\t\t\tstartTime,\n\t\t\tpayload,\n\t\t\tstatus,\n\t\t\tqueriesSent,\n\t\t\tqueriesPending: queue.length,\n\t\t\tsubscribe,\n\t\t\tabort\n\t\t};\n\t}\n\t/**\n\t* Fail query\n\t*/\n\tfunction failQuery() {\n\t\tstatus = \"failed\";\n\t\tdoneCallbacks.forEach((callback) => {\n\t\t\tcallback(void 0, lastError);\n\t\t});\n\t}\n\t/**\n\t* Clear queue\n\t*/\n\tfunction clearQueue() {\n\t\tqueue.forEach((item) => {\n\t\t\tif (item.status === \"pending\") item.status = \"aborted\";\n\t\t});\n\t\tqueue = [];\n\t}\n\t/**\n\t* Got response from module\n\t*/\n\tfunction moduleResponse(item, response, data) {\n\t\tconst isError = response !== \"success\";\n\t\tqueue = queue.filter((queued) => queued !== item);\n\t\tswitch (status) {\n\t\t\tcase \"pending\": break;\n\t\t\tcase \"failed\":\n\t\t\t\tif (isError || !config.dataAfterTimeout) return;\n\t\t\t\tbreak;\n\t\t\tdefault: return;\n\t\t}\n\t\tif (response === \"abort\") {\n\t\t\tlastError = data;\n\t\t\tfailQuery();\n\t\t\treturn;\n\t\t}\n\t\tif (isError) {\n\t\t\tlastError = data;\n\t\t\tif (!queue.length) if (!resources.length) failQuery();\n\t\t\telse execNext();\n\t\t\treturn;\n\t\t}\n\t\tresetTimer();\n\t\tclearQueue();\n\t\tif (!config.random) {\n\t\t\tconst index = config.resources.indexOf(item.resource);\n\t\t\tif (index !== -1 && index !== config.index) config.index = index;\n\t\t}\n\t\tstatus = \"completed\";\n\t\tdoneCallbacks.forEach((callback) => {\n\t\t\tcallback(data);\n\t\t});\n\t}\n\t/**\n\t* Execute next query\n\t*/\n\tfunction execNext() {\n\t\tif (status !== \"pending\") return;\n\t\tresetTimer();\n\t\tconst resource = resources.shift();\n\t\tif (resource === void 0) {\n\t\t\tif (queue.length) {\n\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\tresetTimer();\n\t\t\t\t\tif (status === \"pending\") {\n\t\t\t\t\t\tclearQueue();\n\t\t\t\t\t\tfailQuery();\n\t\t\t\t\t}\n\t\t\t\t}, config.timeout);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfailQuery();\n\t\t\treturn;\n\t\t}\n\t\tconst item = {\n\t\t\tstatus: \"pending\",\n\t\t\tresource,\n\t\t\tcallback: (status$1, data) => {\n\t\t\t\tmoduleResponse(item, status$1, data);\n\t\t\t}\n\t\t};\n\t\tqueue.push(item);\n\t\tqueriesSent++;\n\t\ttimer = setTimeout(execNext, config.rotate);\n\t\tquery(resource, payload, item.callback);\n\t}\n\tsetTimeout(execNext);\n\treturn getQueryStatus;\n}\n\n/**\n* Redundancy instance\n*/\nfunction initRedundancy(cfg) {\n\tconst config = {\n\t\t...defaultConfig,\n\t\t...cfg\n\t};\n\tlet queries = [];\n\t/**\n\t* Remove aborted and completed queries\n\t*/\n\tfunction cleanup() {\n\t\tqueries = queries.filter((item) => item().status === \"pending\");\n\t}\n\t/**\n\t* Send query\n\t*/\n\tfunction query(payload, queryCallback, doneCallback) {\n\t\tconst query$1 = sendQuery(config, payload, queryCallback, (data, error) => {\n\t\t\tcleanup();\n\t\t\tif (doneCallback) doneCallback(data, error);\n\t\t});\n\t\tqueries.push(query$1);\n\t\treturn query$1;\n\t}\n\t/**\n\t* Find instance\n\t*/\n\tfunction find(callback) {\n\t\treturn queries.find((value) => {\n\t\t\treturn callback(value);\n\t\t}) || null;\n\t}\n\tconst instance = {\n\t\tquery,\n\t\tfind,\n\t\tsetIndex: (index) => {\n\t\t\tconfig.index = index;\n\t\t},\n\t\tgetIndex: () => config.index,\n\t\tcleanup\n\t};\n\treturn instance;\n}\n\nfunction emptyCallback$1() {}\nconst redundancyCache = Object.create(null);\n/**\n* Get Redundancy instance for provider\n*/\nfunction getRedundancyCache(provider) {\n\tif (!redundancyCache[provider]) {\n\t\tconst config = getAPIConfig(provider);\n\t\tif (!config) return;\n\t\tconst redundancy = initRedundancy(config);\n\t\tconst cachedReundancy = {\n\t\t\tconfig,\n\t\t\tredundancy\n\t\t};\n\t\tredundancyCache[provider] = cachedReundancy;\n\t}\n\treturn redundancyCache[provider];\n}\n/**\n* Send API query\n*/\nfunction sendAPIQuery(target, query, callback) {\n\tlet redundancy;\n\tlet send;\n\tif (typeof target === \"string\") {\n\t\tconst api = getAPIModule(target);\n\t\tif (!api) {\n\t\t\tcallback(void 0, 424);\n\t\t\treturn emptyCallback$1;\n\t\t}\n\t\tsend = api.send;\n\t\tconst cached = getRedundancyCache(target);\n\t\tif (cached) redundancy = cached.redundancy;\n\t} else {\n\t\tconst config = createAPIConfig(target);\n\t\tif (config) {\n\t\t\tredundancy = initRedundancy(config);\n\t\t\tconst moduleKey = target.resources ? target.resources[0] : \"\";\n\t\t\tconst api = getAPIModule(moduleKey);\n\t\t\tif (api) send = api.send;\n\t\t}\n\t}\n\tif (!redundancy || !send) {\n\t\tcallback(void 0, 424);\n\t\treturn emptyCallback$1;\n\t}\n\treturn redundancy.query(query, send, callback)().abort;\n}\n\nfunction emptyCallback() {}\n/**\n* Function called when new icons have been loaded\n*/\nfunction loadedNewIcons(storage) {\n\tif (!storage.iconsLoaderFlag) {\n\t\tstorage.iconsLoaderFlag = true;\n\t\tsetTimeout(() => {\n\t\t\tstorage.iconsLoaderFlag = false;\n\t\t\tupdateCallbacks(storage);\n\t\t});\n\t}\n}\n/**\n* Check icon names for API\n*/\nfunction checkIconNamesForAPI(icons) {\n\tconst valid = [];\n\tconst invalid = [];\n\ticons.forEach((name) => {\n\t\t(name.match(matchIconName) ? valid : invalid).push(name);\n\t});\n\treturn {\n\t\tvalid,\n\t\tinvalid\n\t};\n}\n/**\n* Parse loader response\n*/\nfunction parseLoaderResponse(storage, icons, data) {\n\tfunction checkMissing() {\n\t\tconst pending = storage.pendingIcons;\n\t\ticons.forEach((name) => {\n\t\t\tif (pending) pending.delete(name);\n\t\t\tif (!storage.icons[name]) storage.missing.add(name);\n\t\t});\n\t}\n\tif (data && typeof data === \"object\") try {\n\t\tconst parsed = addIconSet(storage, data);\n\t\tif (!parsed.length) {\n\t\t\tcheckMissing();\n\t\t\treturn;\n\t\t}\n\t} catch (err) {\n\t\tconsole.error(err);\n\t}\n\tcheckMissing();\n\tloadedNewIcons(storage);\n}\n/**\n* Handle response that can be async\n*/\nfunction parsePossiblyAsyncResponse(response, callback) {\n\tif (response instanceof Promise) response.then((data) => {\n\t\tcallback(data);\n\t}).catch(() => {\n\t\tcallback(null);\n\t});\n\telse callback(response);\n}\n/**\n* Load icons\n*/\nfunction loadNewIcons(storage, icons) {\n\tif (!storage.iconsToLoad) storage.iconsToLoad = icons;\n\telse storage.iconsToLoad = storage.iconsToLoad.concat(icons).sort();\n\tif (!storage.iconsQueueFlag) {\n\t\tstorage.iconsQueueFlag = true;\n\t\tsetTimeout(() => {\n\t\t\tstorage.iconsQueueFlag = false;\n\t\t\tconst { provider, prefix } = storage;\n\t\t\tconst icons$1 = storage.iconsToLoad;\n\t\t\tdelete storage.iconsToLoad;\n\t\t\tif (!icons$1 || !icons$1.length) return;\n\t\t\tconst customIconLoader = storage.loadIcon;\n\t\t\tif (storage.loadIcons && (icons$1.length > 1 || !customIconLoader)) {\n\t\t\t\tparsePossiblyAsyncResponse(storage.loadIcons(icons$1, prefix, provider), (data) => {\n\t\t\t\t\tparseLoaderResponse(storage, icons$1, data);\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (customIconLoader) {\n\t\t\t\ticons$1.forEach((name) => {\n\t\t\t\t\tconst response = customIconLoader(name, prefix, provider);\n\t\t\t\t\tparsePossiblyAsyncResponse(response, (data) => {\n\t\t\t\t\t\tconst iconSet = data ? {\n\t\t\t\t\t\t\tprefix,\n\t\t\t\t\t\t\ticons: { [name]: data }\n\t\t\t\t\t\t} : null;\n\t\t\t\t\t\tparseLoaderResponse(storage, [name], iconSet);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { valid, invalid } = checkIconNamesForAPI(icons$1);\n\t\t\tif (invalid.length) parseLoaderResponse(storage, invalid, null);\n\t\t\tif (!valid.length) return;\n\t\t\tconst api = prefix.match(matchIconName) ? getAPIModule(provider) : null;\n\t\t\tif (!api) {\n\t\t\t\tparseLoaderResponse(storage, valid, null);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst params = api.prepare(provider, prefix, valid);\n\t\t\tparams.forEach((item) => {\n\t\t\t\tsendAPIQuery(provider, item, (data) => {\n\t\t\t\t\tparseLoaderResponse(storage, item.icons, data);\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t}\n}\n/**\n* Load icons\n*/\nconst loadIcons = (icons, callback) => {\n\tconst cleanedIcons = listToIcons(icons, true, allowSimpleNames());\n\tconst sortedIcons = sortIcons(cleanedIcons);\n\tif (!sortedIcons.pending.length) {\n\t\tlet callCallback = true;\n\t\tif (callback) setTimeout(() => {\n\t\t\tif (callCallback) callback(sortedIcons.loaded, sortedIcons.missing, sortedIcons.pending, emptyCallback);\n\t\t});\n\t\treturn () => {\n\t\t\tcallCallback = false;\n\t\t};\n\t}\n\tconst newIcons = Object.create(null);\n\tconst sources = [];\n\tlet lastProvider, lastPrefix;\n\tsortedIcons.pending.forEach((icon) => {\n\t\tconst { provider, prefix } = icon;\n\t\tif (prefix === lastPrefix && provider === lastProvider) return;\n\t\tlastProvider = provider;\n\t\tlastPrefix = prefix;\n\t\tsources.push(getStorage(provider, prefix));\n\t\tconst providerNewIcons = newIcons[provider] || (newIcons[provider] = Object.create(null));\n\t\tif (!providerNewIcons[prefix]) providerNewIcons[prefix] = [];\n\t});\n\tsortedIcons.pending.forEach((icon) => {\n\t\tconst { provider, prefix, name } = icon;\n\t\tconst storage = getStorage(provider, prefix);\n\t\tconst pendingQueue = storage.pendingIcons || (storage.pendingIcons = /* @__PURE__ */ new Set());\n\t\tif (!pendingQueue.has(name)) {\n\t\t\tpendingQueue.add(name);\n\t\t\tnewIcons[provider][prefix].push(name);\n\t\t}\n\t});\n\tsources.forEach((storage) => {\n\t\tconst list = newIcons[storage.provider][storage.prefix];\n\t\tif (list.length) loadNewIcons(storage, list);\n\t});\n\treturn callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;\n};\n/**\n* Load one icon using Promise\n*/\nconst loadIcon = (icon) => {\n\treturn new Promise((fulfill, reject) => {\n\t\tconst iconObj = typeof icon === \"string\" ? stringToIcon(icon, true) : icon;\n\t\tif (!iconObj) {\n\t\t\treject(icon);\n\t\t\treturn;\n\t\t}\n\t\tloadIcons([iconObj || icon], (loaded) => {\n\t\t\tif (loaded.length && iconObj) {\n\t\t\t\tconst data = getIconData(iconObj);\n\t\t\t\tif (data) {\n\t\t\t\t\tfulfill({\n\t\t\t\t\t\t...defaultIconProps,\n\t\t\t\t\t\t...data\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\treject(icon);\n\t\t});\n\t});\n};\n\n/**\n* Set custom loader for multiple icons\n*/\nfunction setCustomIconsLoader(loader, prefix, provider) {\n\tgetStorage(provider || \"\", prefix).loadIcons = loader;\n}\n/**\n* Set custom loader for one icon\n*/\nfunction setCustomIconLoader(loader, prefix, provider) {\n\tgetStorage(provider || \"\", prefix).loadIcon = loader;\n}\n\n/**\n* Convert IconifyIconCustomisations to FullIconCustomisations, checking value types\n*/\nfunction mergeCustomisations(defaults, item) {\n\tconst result = { ...defaults };\n\tfor (const key in item) {\n\t\tconst value = item[key];\n\t\tconst valueType = typeof value;\n\t\tif (key in defaultIconSizeCustomisations) {\n\t\t\tif (value === null || value && (valueType === \"string\" || valueType === \"number\")) result[key] = value;\n\t\t} else if (valueType === typeof result[key]) result[key] = key === \"rotate\" ? value % 4 : value;\n\t}\n\treturn result;\n}\n\nconst separator = /[\\s,]+/;\n/**\n* Apply \"flip\" string to icon customisations\n*/\nfunction flipFromString(custom, flip) {\n\tflip.split(separator).forEach((str) => {\n\t\tconst value = str.trim();\n\t\tswitch (value) {\n\t\t\tcase \"horizontal\":\n\t\t\t\tcustom.hFlip = true;\n\t\t\t\tbreak;\n\t\t\tcase \"vertical\":\n\t\t\t\tcustom.vFlip = true;\n\t\t\t\tbreak;\n\t\t}\n\t});\n}\n\n/**\n* Get rotation value\n*/\nfunction rotateFromString(value, defaultValue = 0) {\n\tconst units = value.replace(/^-?[0-9.]*/, \"\");\n\tfunction cleanup(value$1) {\n\t\twhile (value$1 < 0) value$1 += 4;\n\t\treturn value$1 % 4;\n\t}\n\tif (units === \"\") {\n\t\tconst num = parseInt(value);\n\t\treturn isNaN(num) ? 0 : cleanup(num);\n\t} else if (units !== value) {\n\t\tlet split = 0;\n\t\tswitch (units) {\n\t\t\tcase \"%\":\n\t\t\t\tsplit = 25;\n\t\t\t\tbreak;\n\t\t\tcase \"deg\": split = 90;\n\t\t}\n\t\tif (split) {\n\t\t\tlet num = parseFloat(value.slice(0, value.length - units.length));\n\t\t\tif (isNaN(num)) return 0;\n\t\t\tnum = num / split;\n\t\t\treturn num % 1 === 0 ? cleanup(num) : 0;\n\t\t}\n\t}\n\treturn defaultValue;\n}\n\n/**\n* Generate <svg>\n*/\nfunction iconToHTML(body, attributes) {\n\tlet renderAttribsHTML = body.indexOf(\"xlink:\") === -1 ? \"\" : \" xmlns:xlink=\\\"http://www.w3.org/1999/xlink\\\"\";\n\tfor (const attr in attributes) renderAttribsHTML += \" \" + attr + \"=\\\"\" + attributes[attr] + \"\\\"\";\n\treturn \"<svg xmlns=\\\"http://www.w3.org/2000/svg\\\"\" + renderAttribsHTML + \">\" + body + \"</svg>\";\n}\n\n/**\n* Encode SVG for use in url()\n*\n* Short alternative to encodeURIComponent() that encodes only stuff used in SVG, generating\n* smaller code.\n*/\nfunction encodeSVGforURL(svg) {\n\treturn svg.replace(/\"/g, \"'\").replace(/%/g, \"%25\").replace(/#/g, \"%23\").replace(/</g, \"%3C\").replace(/>/g, \"%3E\").replace(/\\s+/g, \" \");\n}\n/**\n* Generate data: URL from SVG\n*/\nfunction svgToData(svg) {\n\treturn \"data:image/svg+xml,\" + encodeSVGforURL(svg);\n}\n/**\n* Generate url() from SVG\n*/\nfunction svgToURL(svg) {\n\treturn \"url(\\\"\" + svgToData(svg) + \"\\\")\";\n}\n\nlet policy;\n/**\n* Attempt to create policy\n*/\nfunction createPolicy() {\n\ttry {\n\t\tpolicy = window.trustedTypes.createPolicy(\"iconify\", { createHTML: (s) => s });\n\t} catch (err) {\n\t\tpolicy = null;\n\t}\n}\n/**\n* Clean up value for innerHTML assignment\n*\n* This code doesn't actually clean up anything.\n* It is intended be used with Iconify icon data, which has already been validated\n*/\nfunction cleanUpInnerHTML(html) {\n\tif (policy === void 0) createPolicy();\n\treturn policy ? policy.createHTML(html) : html;\n}\n\nconst defaultExtendedIconCustomisations = {\n ...defaultIconCustomisations,\n inline: false,\n};\n\n/**\n * Default SVG attributes\n */\nconst svgDefaults = {\n 'xmlns': 'http://www.w3.org/2000/svg',\n 'xmlnsXlink': 'http://www.w3.org/1999/xlink',\n 'aria-hidden': true,\n 'role': 'img',\n};\n/**\n * Style modes\n */\nconst commonProps = {\n display: 'inline-block',\n};\nconst monotoneProps = {\n backgroundColor: 'currentColor',\n};\nconst coloredProps = {\n backgroundColor: 'transparent',\n};\n// Dynamically add common props to variables above\nconst propsToAdd = {\n Image: 'var(--svg)',\n Repeat: 'no-repeat',\n Size: '100% 100%',\n};\nconst propsToAddTo = {\n WebkitMask: monotoneProps,\n mask: monotoneProps,\n background: coloredProps,\n};\nfor (const prefix in propsToAddTo) {\n const list = propsToAddTo[prefix];\n for (const prop in propsToAdd) {\n list[prefix + prop] = propsToAdd[prop];\n }\n}\n/**\n * Default values for customisations for inline icon\n */\nconst inlineDefaults = {\n ...defaultExtendedIconCustomisations,\n inline: true,\n};\n/**\n * Fix size: add 'px' to numbers\n */\nfunction fixSize(value) {\n return value + (value.match(/^[-0-9.]+$/) ? 'px' : '');\n}\n/**\n * Render icon\n */\nconst render = (\n// Icon must be validated before calling this function\nicon, \n// Partial properties\nprops, \n// Icon name\nname) => {\n // Get default properties\n const defaultProps = props.inline\n ? inlineDefaults\n : defaultExtendedIconCustomisations;\n // Get all customisations\n const customisations = mergeCustomisations(defaultProps, props);\n // Check mode\n const mode = props.mode || 'svg';\n // Create style\n const style = {};\n const customStyle = props.style || {};\n // Create SVG component properties\n const componentProps = {\n ...(mode === 'svg' ? svgDefaults : {}),\n };\n if (name) {\n const iconName = stringToIcon(name, false, true);\n if (iconName) {\n const classNames = ['iconify'];\n const props = [\n 'provider',\n 'prefix',\n ];\n for (const prop of props) {\n if (iconName[prop]) {\n classNames.push('iconify--' + iconName[prop]);\n }\n }\n componentProps.className = classNames.join(' ');\n }\n }\n // Get element properties\n for (let key in props) {\n const value = props[key];\n if (value === void 0) {\n continue;\n }\n switch (key) {\n // Properties to ignore\n case 'icon':\n case 'style':\n case 'children':\n case 'onLoad':\n case 'mode':\n case 'ssr':\n case 'fallback':\n break;\n // Forward ref\n case '_ref':\n componentProps.ref = value;\n break;\n // Merge class names\n case 'className':\n componentProps[key] =\n (componentProps[key] ? componentProps[key] + ' ' : '') +\n value;\n break;\n // Boolean attributes\n case 'inline':\n case 'hFlip':\n case 'vFlip':\n customisations[key] =\n value === true || value === 'true' || value === 1;\n break;\n // Flip as string: 'horizontal,vertical'\n case 'flip':\n if (typeof value === 'string') {\n flipFromString(customisations, value);\n }\n break;\n // Color: copy to style\n case 'color':\n style.color = value;\n break;\n // Rotation as string\n case 'rotate':\n if (typeof value === 'string') {\n customisations[key] = rotateFromString(value);\n }\n else if (typeof value === 'number') {\n customisations[key] = value;\n }\n break;\n // Remove aria-hidden\n case 'ariaHidden':\n case 'aria-hidden':\n if (value !== true && value !== 'true') {\n delete componentProps['aria-hidden'];\n }\n break;\n // Copy missing property if it does not exist in customisations\n default:\n if (defaultProps[key] === void 0) {\n componentProps[key] = value;\n }\n }\n }\n // Generate icon\n const item = iconToSVG(icon, customisations);\n const renderAttribs = item.attributes;\n // Inline display\n if (customisations.inline) {\n style.verticalAlign = '-0.125em';\n }\n if (mode === 'svg') {\n // Add style\n componentProps.style = {\n ...style,\n ...customStyle,\n };\n // Add icon stuff\n Object.assign(componentProps, renderAttribs);\n // Counter for ids based on \"id\" property to render icons consistently on server and client\n let localCounter = 0;\n let id = props.id;\n if (typeof id === 'string') {\n // Convert '-' to '_' to avoid errors in animations\n id = id.replace(/-/g, '_');\n }\n // Add icon stuff\n componentProps.dangerouslySetInnerHTML = {\n __html: cleanUpInnerHTML(replaceIDs(item.body, id ? () => id + 'ID' + localCounter++ : 'iconifyReact')),\n };\n return createElement('svg', componentProps);\n }\n // Render <span> with style\n const { body, width, height } = icon;\n const useMask = mode === 'mask' ||\n (mode === 'bg' ? false : body.indexOf('currentColor') !== -1);\n // Generate SVG\n const html = iconToHTML(body, {\n ...renderAttribs,\n width: width + '',\n height: height + '',\n });\n // Generate style\n componentProps.style = {\n ...style,\n '--svg': svgToURL(html),\n 'width': fixSize(renderAttribs.width),\n 'height': fixSize(renderAttribs.height),\n ...commonProps,\n ...(useMask ? monotoneProps : coloredProps),\n ...customStyle,\n };\n return createElement('span', componentProps);\n};\n\n/**\n * Initialise stuff\n */\n// Enable short names\nallowSimpleNames(true);\n// Set API module\nsetAPIModule('', fetchAPIModule);\n/**\n * Browser stuff\n */\nif (typeof document !== 'undefined' && typeof window !== 'undefined') {\n const _window = window;\n // Load icons from global \"IconifyPreload\"\n if (_window.IconifyPreload !== void 0) {\n const preload = _window.IconifyPreload;\n const err = 'Invalid IconifyPreload syntax.';\n if (typeof preload === 'object' && preload !== null) {\n (preload instanceof Array ? preload : [preload]).forEach((item) => {\n try {\n if (\n // Check if item is an object and not null/array\n typeof item !== 'object' ||\n item === null ||\n item instanceof Array ||\n // Check for 'icons' and 'prefix'\n typeof item.icons !== 'object' ||\n typeof item.prefix !== 'string' ||\n // Add icon set\n !addCollection(item)) {\n console.error(err);\n }\n }\n catch (e) {\n console.error(err);\n }\n });\n }\n }\n // Set API from global \"IconifyProviders\"\n if (_window.IconifyProviders !== void 0) {\n const providers = _window.IconifyProviders;\n if (typeof providers === 'object' && providers !== null) {\n for (let key in providers) {\n const err = 'IconifyProviders[' + key + '] is invalid.';\n try {\n const value = providers[key];\n if (typeof value !== 'object' ||\n !value ||\n value.resources === void 0) {\n continue;\n }\n if (!addAPIProvider(key, value)) {\n console.error(err);\n }\n }\n catch (e) {\n console.error(err);\n }\n }\n }\n }\n}\nfunction IconComponent(props) {\n const [mounted, setMounted] = useState(!!props.ssr);\n const [abort, setAbort] = useState({});\n // Get initial state\n function getInitialState(mounted) {\n if (mounted) {\n const name = props.icon;\n if (typeof name === 'object') {\n // Icon as object\n return {\n name: '',\n data: name,\n };\n }\n const data = getIconData(name);\n if (data) {\n return {\n name,\n data,\n };\n }\n }\n return {\n name: '',\n };\n }\n const [state, setState] = useState(getInitialState(!!props.ssr));\n // Cancel loading\n function cleanup() {\n const callback = abort.callback;\n if (callback) {\n callback();\n setAbort({});\n }\n }\n // Change state if it is different\n function changeState(newState) {\n if (JSON.stringify(state) !== JSON.stringify(newState)) {\n cleanup();\n setState(newState);\n return true;\n }\n }\n // Update state\n function updateState() {\n var _a;\n const name = props.icon;\n if (typeof name === 'object') {\n // Icon as object\n changeState({\n name: '',\n data: name,\n });\n return;\n }\n // New icon or got icon data\n const data = getIconData(name);\n if (changeState({\n name,\n data,\n })) {\n if (data === undefined) {\n // Load icon, update state when done\n const callback = loadIcons([name], updateState);\n setAbort({\n callback,\n });\n }\n else if (data) {\n // Icon data is available: trigger onLoad callback if present\n (_a = props.onLoad) === null || _a === void 0 ? void 0 : _a.call(props, name);\n }\n }\n }\n // Mounted state, cleanup for loader\n useEffect(() => {\n setMounted(true);\n return cleanup;\n }, []);\n // Icon changed or component mounted\n useEffect(() => {\n if (mounted) {\n updateState();\n }\n }, [props.icon, mounted]);\n // Render icon\n const { name, data } = state;\n if (!data) {\n return props.children\n ? props.children\n : props.fallback\n ? props.fallback\n : createElement('span', {});\n }\n return render({\n ...defaultIconProps,\n ...data,\n }, props, name);\n}\n/**\n * Block icon\n *\n * @param props - Component properties\n */\nconst Icon = forwardRef((props, ref) => IconComponent({\n ...props,\n _ref: ref,\n}));\n/**\n * Inline icon (has negative verticalAlign that makes it behave like icon font)\n *\n * @param props - Component properties\n */\nconst InlineIcon = forwardRef((props, ref) => IconComponent({\n inline: true,\n ...props,\n _ref: ref,\n}));\n/**\n * Internal API\n */\nconst _api = {\n getAPIConfig,\n setAPIModule,\n sendAPIQuery,\n setFetch,\n getFetch,\n listAPIProviders,\n};\n\nexport { Icon, InlineIcon, _api, addAPIProvider, addCollection, addIcon, iconToSVG as buildIcon, calculateSize, getIcon, iconLoaded, listIcons, loadIcon, loadIcons, replaceIDs, setCustomIconLoader, setCustomIconsLoader };\n","import { createSlice, type PayloadAction } from \"@reduxjs/toolkit\";\nimport type { SearchProduct } from \"../../components/graphQL/queries/types\";\n\ninterface ProductState {\n product: SearchProduct | null;\n}\n\nconst initialState: ProductState = {\n product: null,\n};\n\nexport const productSlice = createSlice({\n name: \"product\",\n initialState,\n reducers: {\n setProduct: (state, action: PayloadAction<SearchProduct | null>) => {\n state.product = action.payload;\n },\n },\n});\n\nexport const { setProduct } = productSlice.actions;\n\nexport default productSlice.reducer;\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useDispatch } from \"react-redux\";\nimport type { SearchProduct } from \"../graphQL/queries/types\";\nimport {\n stringReducer,\n priceFormatter,\n currencyFormatter,\n displayData,\n imageUrlArray,\n} from \"../utils/helper\";\nimport { Icon } from \"@iconify/react/dist/iconify.js\";\nimport { useEffect, useState } from \"react\";\nimport { setProduct } from \"../../store/reducers/productReducer\";\nimport { getProductById } from \"../utils\";\n\nfunction useResponsiveProductsPerPage() {\n const getProductsPerPage = () => {\n if (window.innerWidth < 425) return 1; // Below Mobile-L\n if (window.innerWidth < 768) return 2; // Mobile-L to md\n return 4; // md and above\n };\n\n const [productsPerPage, setProductsPerPage] = useState(getProductsPerPage);\n\n useEffect(() => {\n const handleResize = () => setProductsPerPage(getProductsPerPage());\n window.addEventListener(\"resize\", handleResize);\n return () => window.removeEventListener(\"resize\", handleResize);\n }, []);\n\n return productsPerPage;\n}\n\nconst ProductCarousel = ({\n product,\n}: // storeDetails,\n{\n product: SearchProduct[];\n storeDetails: any;\n}) => {\n const dispatch = useDispatch();\n // const selectedProduct = useSelector((state: any) => state.product.product);\n const productsPerPage = useResponsiveProductsPerPage();\n const [startIndex, setStartIndex] = useState(0);\n\n const nextProducts = () => {\n setStartIndex((prevIndex) =>\n prevIndex + productsPerPage >= product.length\n ? 0\n : prevIndex + productsPerPage\n );\n };\n\n const prevProducts = () => {\n setStartIndex((prevIndex) =>\n prevIndex - productsPerPage < 0\n ? product.length - (product.length % productsPerPage || productsPerPage)\n : prevIndex - productsPerPage\n );\n };\n\n const getProduct = async (id: number | string) => {\n const product = await getProductById(id);\n dispatch(setProduct(product));\n };\n\n return (\n <div className=\"mt-2 overflow-x-hidden\">\n <div className=\"flex items-center justify-center gap-4 relative\">\n {product?.length > productsPerPage && (\n <button\n onClick={prevProducts}\n className=\"absolute z-50 left-0 text-[#000000] bg-[#ffffff] rounded-full p-2 flex items-center h-fit\"\n // style={{ color: storeDetails.tanyaThemeColor }}\n >\n <Icon icon=\"mdi:chevron-left\" width=\"25\" />\n </button>\n )}\n\n <div className=\"flex gap-5 justify-center flex-1 overflow-hidden\">\n {product\n .slice(startIndex, startIndex + productsPerPage)\n .map((prod) => (\n <div\n key={prod.productId}\n className=\"flex-shrink-0 flex flex-col w-[150px] h-[200px] p-2 items-center justify-between cursor-pointer bg-[#FFFFFF] rounded-[10px] shadow-[0px_2px_2px_0px_#9292BC40]\"\n onClick={() => {\n getProduct(prod.product_id ?? prod.productId);\n }}\n >\n {/* Image */}\n <div className=\"w-full p-2 flex items-center justify-center bg-white\">\n <img\n src={\n imageUrlArray(prod)[0]?.link ||\n imageUrlArray(prod)[0] || // fallback if it's a string\n \"https://via.placeholder.com/120\"\n }\n alt={prod?.productName ? prod.productName : \"Product\"}\n className=\"w-28 h-28 rounded-[10px] transition-transform duration-300 hover:scale-125 object-cover\"\n />\n </div>\n\n {/* Price & Name */}\n <div\n className=\"text-white w-full p-2 text-[12px] text-center h-[60px]\"\n // style={{ background: storeDetails.tanyaThemeColor }}\n >\n <div className=\"relative inline-block group\">\n <div className=\"w-full line-clamp-1 overflow-hidden text-ellipsis text-[#000000] font-medium font-nunitoSans\">\n {prod?.productName\n ? prod.productName\n : prod?.product_name\n ? prod.product_name\n : stringReducer(\n displayData(prod?.name?.[\"en-US\"]),\n 60\n ) || \"Product\"}\n </div>\n\n {/* Tooltip */}\n <div\n className=\"absolute left-0 top-full mt-1 w-max max-w-[200px] p-2 bg-white shadow-lg text-black text-xs rounded opacity-0 transition-opacity duration-300 group-hover:opacity-100 z-50 pointer-events-auto\"\n style={{\n position: \"absolute\",\n top: \"-100%\",\n left: \"0\",\n marginBottom: \"5px\",\n zIndex: 50,\n }}\n >\n {prod?.productName\n ? prod.productName\n : prod?.product_name\n ? prod.product_name\n : stringReducer(\n displayData(prod?.name?.[\"en-US\"]),\n 60\n ) || \"Product\"}\n </div>\n </div>\n <div className=\" flex text-center items-center gap-2 text-[14px] text-[#14121F] font-bold font-nunitoSans text-base mb-1\">\n <p>\n {currencyFormatter(\n prod?.price\n ? Number(prod?.price)\n : priceFormatter(prod).centAmount || 0,\n priceFormatter(prod)?.currencyCode\n )}\n </p>\n <p className=\"text-[#14121F] font-normal line-through text-sm font-nunitoSans truncate\">\n ${Number(prod?.price).toFixed(2) ?? 0 + 5}\n </p>\n </div>\n </div>\n </div>\n ))}\n </div>\n\n {product?.length > productsPerPage && (\n <button\n onClick={nextProducts}\n className=\"absolute z-50 right-0 text-[#000000] bg-[#ffffff] rounded-full p-2 flex items-center h-fit\"\n // style={{ color: storeDetails.tanyaThemeColor }}\n >\n <Icon icon=\"mdi:chevron-right\" width=\"25\" />\n </button>\n )}\n </div>\n </div>\n );\n};\n\nexport default ProductCarousel;\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport ProductCarousel from \"./ProductCarousel\";\nimport { initialCapital } from \"../utils/helper\";\n\nconst ProductDisplay = ({ chat, storeDetails }: any) => {\n return (\n <div className=\"bg-[#FFFFFF] px-7 py-4 rounded-r-xl rounded-bl-2xl w-full\">\n {chat.map((products: any, i: number) => (\n <div\n key={i}\n className=\"mb-4 p-3 rounded-xl\"\n style={{ \n background: \"linear-gradient(109.52deg, #F0EEF5 36.91%, #F4F3EE 100.34%\",\n // backgroundColor: storeDetails.tanyaThemeColorLight \n }} // slightly darker grey // light grey section bg\n >\n <div\n className=\"font-nunitoSans font-bold text-sm text-[#494949] p-2 w-fit rounded-[20px]\"\n // style={{\n // color: storeDetails?.tanyaThemeContrastColor,\n // border: `1px solid ${storeDetails.tanyaThemeColor}`,\n // backgroundColor: storeDetails.tanyaThemeColor,\n // }}\n >\n {initialCapital(products.keyword) || \"No keyword\"}\n </div>\n\n <ProductCarousel\n product={products.items}\n storeDetails={storeDetails}\n />\n </div>\n ))}\n </div>\n );\n};\n\nexport default ProductDisplay;\n","import { apiConfig } from \"../../config/api\";\nimport { clientId, getHost, getSiteId, organisationId, shortCode } from \"../utils\";\nimport { getAccessToken } from \"../utils/getAccessToken\";\nimport axios from \"axios\";\n\nexport const fetchStoreConfig = async (storeCode: string) => {\n try {\n const token = await getAccessToken();\n const { serverUrl } = apiConfig();\n const response = await axios.get(\n `${serverUrl}api/logo?storeCode=${storeCode}`,\n {\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${token}`,\n },\n }\n );\n return response.data;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n return error;\n // console.error(\"Error fetching logo details:\", error);\n }\n};\n\ninterface Product {\n product_id: string;\n quantity: number;\n}\n\nexport const createBasket = async (customer_token: string, data?: any) => {\n const { serverUrl, basePath } = apiConfig();\n const URL = `${serverUrl}`;\n console.log(\"customer_token \\n\", customer_token);\n try {\n const response = await axios.post(\n `${URL}${basePath}/basket/create?baseUrl=${getHost()}&siteId=${getSiteId()}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}`,\n data,\n {\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: customer_token,\n },\n }\n );\n\n return response.data;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n console.error(\"Error creating basket:\", error.response || error.message);\n } else {\n console.error(\"Unexpected error:\", error);\n }\n return null;\n }\n};\n\nexport const addProductToBasket = async (\n basketId: string,\n products: Product[],\n customer_token: string\n) => {\n const { serverUrl, basePath } = apiConfig();\n const URL = `${serverUrl}`;\n try {\n const response = await axios.post(\n `${URL}${basePath}/basket/add-product/${basketId}?baseUrl=${getHost()}&siteId=${getSiteId()}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}`,\n products,\n {\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: customer_token,\n },\n }\n );\n\n if (response.status === 200 && response.data) {\n return response.data;\n }\n return null;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n console.error(\n \"Error adding products to basket:\",\n error.response || error.message\n );\n } else {\n console.error(\"Unexpected error:\", error);\n }\n return null;\n }\n};\n\nexport const fetchBasket = async ({\n basketId,\n customer_token,\n}: {\n basketId: string;\n customer_token: string;\n}) => {\n const { serverUrl, basePath } = apiConfig();\n const URL = `${serverUrl}`;\n try {\n const response = await axios.get(\n `${URL}${basePath}/basket/${basketId}?baseUrl=${getHost()}&siteId=${getSiteId()}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}`,\n {\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: customer_token,\n },\n }\n );\n return { status: response.status, data: response.data };\n } catch (error) {\n if (axios.isAxiosError(error)) {\n return { status: error.response?.status, data: null };\n } else {\n return { status: null, data: null };\n }\n }\n};\n","export const BASKET_ID_KEY = \"sfcc_basket_id\";\r\nexport const TOKEN_KEY = \"sfcc_customer_token\";\r\nexport const TOKEN_EXPIRY_KEY = \"sfcc_token_expiry\";\r\n\r\nexport const EXPIRY_TIME = 5 * 60 * 1000; // 5 minutes in milliseconds\r\nexport const BUFFER_TIME = 10 * 1000; // 10 seconds buffer before expiry\r\nexport const VERSION = \"1.0.0\";","import {\r\n BASKET_ID_KEY,\r\n EXPIRY_TIME,\r\n TOKEN_EXPIRY_KEY,\r\n TOKEN_KEY,\r\n} from \"../../config/constant\";\r\n\r\nexport const getStoredBasketId = (): string | null => {\r\n try {\r\n return localStorage.getItem(BASKET_ID_KEY);\r\n } catch (error) {\r\n console.error(\"Error reading basket ID from storage:\", error);\r\n return null;\r\n }\r\n};\r\n\r\nexport const setStoredBasketId = (basketId: string | null): void => {\r\n try {\r\n if (basketId) {\r\n localStorage.setItem(BASKET_ID_KEY, basketId);\r\n } else {\r\n localStorage.removeItem(BASKET_ID_KEY);\r\n }\r\n } catch (error) {\r\n console.error(\"Error saving basket ID to storage:\", error);\r\n }\r\n};\r\n\r\nexport const clearBasketStorage = (): void => {\r\n try {\r\n localStorage.removeItem(BASKET_ID_KEY);\r\n } catch (error) {\r\n console.error(\"Error clearing basket storage:\", error);\r\n }\r\n};\r\n\r\nexport const getStoredToken = (): string | null => {\r\n try {\r\n return localStorage.getItem(TOKEN_KEY);\r\n } catch (error) {\r\n console.error(\"Error reading token:\", error);\r\n return null;\r\n }\r\n};\r\n\r\nexport const setStoredToken = (token: string | null): void => {\r\n try {\r\n if (token) {\r\n localStorage.setItem(TOKEN_KEY, token);\r\n const expiryTime = Date.now() + EXPIRY_TIME;\r\n localStorage.setItem(TOKEN_EXPIRY_KEY, expiryTime.toString());\r\n } else {\r\n localStorage.removeItem(TOKEN_KEY);\r\n }\r\n } catch (error) {\r\n console.error(\"Error storing token:\", error);\r\n }\r\n};\r\n","/* eslint-disable @typescript-eslint/no-explicit-any */\r\nimport { useEffect, useState } from \"react\"; // Add useMemo here when uncomment the color, size, width code\r\n// import { useEffect, useMemo, useState } from \"react\";\r\nimport { useSelector, useDispatch } from \"react-redux\";\r\nimport { Icon } from \"@iconify/react\";\r\nimport { setProduct } from \"../../store/reducers/productReducer\";\r\nimport { addProductToBasket, createBasket, fetchBasket } from \"../api/api\";\r\n// import { fetchTokenSFCC } from \"../utils/fetchTokenSFCC\";\r\nimport {\r\n getStoredBasketId,\r\n // getStoredToken,\r\n setStoredBasketId,\r\n setStoredToken,\r\n} from \"../utils/localStorage\";\r\nimport { toast } from \"react-toastify\";\r\nimport { TOKEN_EXPIRY_KEY } from \"../../config/constant\";\r\nimport { fetchTokenBmGrant } from \"../utils/fetchTokenBmGrant\";\r\nimport {\r\n // fetchExistingRegisterCustomerToken,\r\n fetchExistingGuestCustomerToken,\r\n} from \"../utils/fetchExistingRegisterCustomerToken\";\r\nimport { notifySFCC } from \"../lib/utils\";\r\nimport { authData } from \"../../sfcc-apis/session\";\r\n\r\nconst ANIMATION_DURATION = 300; // ms\r\n\r\nconst ProductDisplayCard = () => {\r\n const dispatch = useDispatch();\r\n const product = useSelector((state: any) => state.product.product);\r\n const storeDetails = useSelector((s: any) => s.store.store);\r\n const [show, setShow] = useState(!!product);\r\n\r\n useEffect(() => {\r\n setShow(!!product);\r\n }, [product]);\r\n\r\n if (!product) return null;\r\n\r\n // const { sizeAttr, colorAttr, widthAttr } = attributes;\r\n\r\n const addToCart = async () => {\r\n console.log(product, \"the prod\");\r\n try {\r\n // Check if product and variants exist\r\n\r\n if (\r\n !product?.variants?.[0]?.product_id &&\r\n !(product.type.item || product.type.bundle) &&\r\n !product?.variants?.[0]?.productId\r\n ) {\r\n toast.error(\"Variants not available\", {\r\n position: \"bottom-right\",\r\n autoClose: 1000,\r\n });\r\n console.error(\"No product variant found\");\r\n return;\r\n }\r\n\r\n const productData = [\r\n {\r\n product_id:\r\n product.variants?.[0].product_id ||\r\n product.variants?.[0].productId ||\r\n product?.id,\r\n quantity: 1,\r\n },\r\n ];\r\n console.log(productData, \"the product data\");\r\n // for getting customer id\r\n const customerData = JSON.parse(\r\n sessionStorage.getItem(\"customerData\") || \"{}\"\r\n );\r\n const basketIdFromCustomer = customerData?.basketId;\r\n const customer_token = false;\r\n const tokenExpiry = localStorage.getItem(TOKEN_EXPIRY_KEY);\r\n const currentTime = Date.now();\r\n\r\n // If no token, get a new one\r\n if (\r\n !customer_token ||\r\n !tokenExpiry ||\r\n currentTime >= parseInt(tokenExpiry)\r\n ) {\r\n let customer_token = \"\";\r\n if (import.meta.env.VITE_SCAPI_ENVIRONMENT) {\r\n const authDetails = await authData();\r\n console.log(\"token from auth data\");\r\n customer_token = \"Bearer \" + authDetails.access_token;\r\n } else {\r\n console.log(\"token from bm grant\");\r\n const access_token = await fetchTokenBmGrant();\r\n const customerTokenData = await fetchExistingGuestCustomerToken(\r\n access_token\r\n );\r\n customer_token = customerTokenData.customer_token;\r\n }\r\n if (!customer_token) {\r\n console.error(\"Failed to get customer_token\");\r\n return;\r\n }\r\n const newExpiryTime = currentTime + 5 * 60 * 1000;\r\n setStoredToken(customer_token);\r\n localStorage.setItem(TOKEN_EXPIRY_KEY, newExpiryTime.toString());\r\n\r\n // 1. Try basketId from customerData\r\n if (basketIdFromCustomer) {\r\n const fetchBasketResponse = await fetchBasket({\r\n basketId: basketIdFromCustomer,\r\n customer_token,\r\n });\r\n console.log(basketIdFromCustomer, \"basket id from customer\");\r\n if (fetchBasketResponse.status === 200 && fetchBasketResponse) {\r\n // Use this basketId to add product\r\n\r\n const response = await addProductToBasket(\r\n basketIdFromCustomer,\r\n productData,\r\n customer_token\r\n );\r\n if (\r\n response?.product_items?.length > 0 ||\r\n response?.productItems?.length > 0\r\n ) {\r\n // const addedProduct = response.product_items.at(-1);\r\n toast.success(`Added to cart`, {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n hideProgressBar: false,\r\n closeOnClick: true,\r\n pauseOnHover: true,\r\n draggable: true,\r\n });\r\n notifySFCC(basketIdFromCustomer);\r\n // window.location.reload();\r\n }\r\n return; // Skip basket creation\r\n }\r\n }\r\n\r\n // 2. If not valid, create new basket and store its ID in localStorage\r\n const data = {\r\n productItems: [\r\n {\r\n productId:\r\n product.variants?.[0].product_id ||\r\n product.variants?.[0].productId ||\r\n product?.id,\r\n quantity: 1,\r\n },\r\n ],\r\n };\r\n console.log(\"before create basket\");\r\n const basketResponse = await createBasket(customer_token, data);\r\n console.log(\r\n basketResponse,\r\n basketResponse?.basket_id,\r\n basketResponse?.basketId,\r\n \"the basket response\"\r\n );\r\n if (!basketResponse?.basket_id && !basketResponse?.basketId) {\r\n console.error(\"Failed to create basket\");\r\n return;\r\n }\r\n console.log(\r\n \"setting stored id\",\r\n basketResponse?.basket_id || basketResponse?.basketId\r\n );\r\n // else if (basketResponse?.basketId) {\r\n // toast.success(`Added to cart`, {\r\n // position: \"bottom-right\",\r\n // autoClose: 3000,\r\n // hideProgressBar: false,\r\n // closeOnClick: true,\r\n // pauseOnHover: true,\r\n // draggable: true,\r\n // });\r\n // }\r\n setStoredBasketId(\r\n basketResponse?.basket_id || basketResponse?.basketId\r\n );\r\n // Add product to new basket\r\n // if (!import.meta.env.VITE_SCAPI_ENVIRONMENT) {\r\n console.log(\"adding product to basket\");\r\n const response = await addProductToBasket(\r\n basketResponse?.basket_id || basketResponse?.basketId,\r\n productData,\r\n customer_token\r\n );\r\n console.log(\"object added to basket\");\r\n if (\r\n response?.product_items?.length > 0 ||\r\n response?.productItems?.length > 0\r\n ) {\r\n toast.success(`Added to cart`, {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n hideProgressBar: false,\r\n closeOnClick: true,\r\n pauseOnHover: true,\r\n draggable: true,\r\n });\r\n }\r\n notifySFCC(basketResponse.basket_id || basketResponse?.basketId);\r\n // }\r\n } else {\r\n // Use existing customer_token and basket ID\r\n const basketId = getStoredBasketId();\r\n if (!basketId) {\r\n console.error(\"No basket ID found\");\r\n return;\r\n }\r\n\r\n const response = await addProductToBasket(\r\n basketId,\r\n productData,\r\n customer_token\r\n );\r\n if (response?.product_items?.length > 0) {\r\n toast.success(`Added to cart`, {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n hideProgressBar: false,\r\n closeOnClick: true,\r\n pauseOnHover: true,\r\n draggable: true,\r\n });\r\n notifySFCC(basketId);\r\n }\r\n }\r\n } catch (error: any) {\r\n console.error(\"Error adding to cart:\", error);\r\n toast.error(\"Failed to add product to cart\", {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n });\r\n\r\n if (\r\n error?.response?.status === 404 || // Basket not found\r\n error?.response?.status === 401 // Unauthorized/expired\r\n ) {\r\n // Clear only basket ID for 404\r\n if (error?.response?.status === 404) {\r\n setStoredBasketId(null);\r\n }\r\n // Clear both for 401\r\n if (error?.response?.status === 401) {\r\n setStoredBasketId(null);\r\n setStoredToken(null);\r\n }\r\n } else {\r\n console.error(\"Failed to add product to basket:\", error.message);\r\n toast.error(\"Failed to add product to cart\", {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n });\r\n }\r\n } finally {\r\n notifySFCC();\r\n }\r\n };\r\n\r\n // Function to generate and redirect to the product detail page\r\n const viewMore = () => {\r\n if (!product) return;\r\n\r\n window.location.href = product.c_pdpUrl; //redirect to sfcc product details url\r\n };\r\n console.log(product, \"the prod\");\r\n return (\r\n <>\r\n <div\r\n className=\"fixed inset-0 z-40 bg-black/30\"\r\n onClick={() => {\r\n setShow(false);\r\n setTimeout(() => dispatch(setProduct(null)), ANIMATION_DURATION);\r\n }}\r\n />\r\n <div\r\n className={`\r\n flex flex-col gap-2 items-center h-[90vh] absolute right-0 bottom-0 z-50 w-full md:w-1/2 md:h-[100vh] lg:w-1/2 lg:h-[100vh] shadow-xl p-2 border-l-2 bg-white border-gray-200 overflow-y-scroll\r\n transition-all duration-300\r\n ${\r\n show\r\n ? \"translate-y-0 md:translate-y-0 md:translate-x-0 opacity-100\"\r\n : \"translate-y-full md:translate-y-0 md:translate-x-full opacity-0 pointer-events-none\"\r\n }\r\n `}\r\n style={{ willChange: \"transform, opacity\" }}\r\n // Prevent click inside card from closing\r\n onClick={(e) => e.stopPropagation()}\r\n >\r\n {/* name and close button */}\r\n <div className=\"mt-3 flex flex-row justify-between w-full \">\r\n <div>\r\n <p className=\"text-[#000000] font-bold font-nunitoSans\">\r\n {product.name}\r\n </p>\r\n </div>\r\n <div>\r\n <Icon\r\n icon=\"mdi:close\"\r\n className=\"text-[#555555] w-6 h-6 cursor-pointer\"\r\n onClick={() => {\r\n setShow(false);\r\n setTimeout(\r\n () => dispatch(setProduct(null)),\r\n ANIMATION_DURATION\r\n );\r\n }}\r\n />\r\n </div>\r\n </div>\r\n {/* image and variants */}\r\n <div className=\"flex flex-row gap-2 items-center flex-wrap\">\r\n <div className=\"flex flex-row items-center justify-center w-[120px] h-[120px] my-5\">\r\n <img\r\n src={\r\n import.meta.env.VITE_SCAPI_ENVIRONMENT\r\n ? product.imageGroups?.[0]?.images?.[0]?.link\r\n : product.image_groups?.[0]?.images?.[0]?.link ||\r\n \"https://via.placeholder.com/120\"\r\n }\r\n alt={product.name}\r\n className=\"rounded-[10px]\"\r\n />\r\n </div>\r\n <div className=\"flex flex-col items-center gap-2\">\r\n {(import.meta.env.VITE_SCAPI_ENVIRONMENT\r\n ? product.imageGroups\r\n : product.image_groups\r\n )\r\n .slice(1, 2)\r\n .map((group: any) =>\r\n group.images.slice(1, 2).map((image: any) => (\r\n <img\r\n key={image.link}\r\n src={image.link}\r\n alt={product.name}\r\n className=\"rounded-[10px] w-[60px] h-[60px]\"\r\n />\r\n ))\r\n )}\r\n </div>\r\n </div>\r\n {/* price and discount */}\r\n <div className=\"flex flex-row items-center justify-between w-full\">\r\n <div className=\"flex flex-row items-center gap-2\">\r\n <p className=\"text-[#14121F] font-bold font-nunitoSans\">\r\n {\" \"}\r\n ${product.price.toFixed(2)}\r\n </p>{\" \"}\r\n <p className=\"text-[#14121F] font-normal line-through text-sm font-nunitoSans\">\r\n {\" \"}\r\n ${(product.price + 5).toFixed(2)}\r\n </p>\r\n </div>\r\n <div>\r\n <p className=\"text-[#EC5050] font-bold font-nunitoSans\">\r\n {product.discount}\r\n </p>\r\n </div>\r\n </div>\r\n {/* horizontal line */}\r\n <div className=\"mt-2 w-full border-t-2 border-gray-200\"></div>\r\n <div className=\"w-full text-left\">\r\n <div className=\"text-[#323135] font-bold font-nunitoSans mt-3 text-[14px]\">\r\n Product Details\r\n </div>\r\n <div\r\n className=\"text-[#68656E] font-normal font-nunitoSans text-xs pl-2 mt-3\"\r\n dangerouslySetInnerHTML={{ __html: product.short_description || product.longDescription }}\r\n ></div>\r\n </div>\r\n {/* rating and reviews */}\r\n <div className=\"mt-4 flex flex-col gap-2 w-full p-2\">\r\n <div className=\"flex flex-row items-center gap-2\">\r\n <div className=\"flex items-center gap-2 text-left font-nunitoSans\">\r\n <div className=\"text-[#323135] font-bold\">\r\n {product?.rating?.rate || 0} /{\" \"}\r\n <span className=\"text-[#68656E]\">5</span>\r\n </div>\r\n <div className=\"text-[#323135] font-semibold text-sm\">\r\n Overall Rating\r\n </div>\r\n <div className=\"text-[#68656E] font-semibold text-sm\">\r\n {product?.rating?.count || 0} ratings\r\n </div>\r\n </div>\r\n </div>\r\n <div className=\"mt-2 flex flex-row items-center gap-2\">\r\n {Array.from({ length: 5 }).map((_, index) => (\r\n <Icon\r\n key={index}\r\n icon=\"mdi:star\"\r\n width=\"20\"\r\n height=\"20\"\r\n className={`text-yellow-500 \r\n ${\r\n product?.rating?.rate > index\r\n ? \"text-yellow-500\"\r\n : \"text-gray-300\"\r\n }\r\n `}\r\n />\r\n ))}\r\n </div>\r\n </div>\r\n\r\n <div\r\n className=\"flex flex-col items-center justify-between font-nunitoSans font-semibold w-5/6 text-black gap-2\"\r\n style={{ marginTop: \"150px\" }}\r\n >\r\n <button\r\n className=\"rounded-[5px] shadow-sm text-[#FBFBFC] bg-[#6851C6] p-2 w-full text-center cursor-pointer\"\r\n style={{ backgroundColor: storeDetails.tanyaThemeColor }}\r\n onClick={addToCart}\r\n >\r\n Add to Cart\r\n </button>\r\n <button\r\n className=\"rounded-[5px] shadow-sm text-[#FBFBFC] bg-[#6851C6] p-2 w-full text-center cursor-pointer mb-16\"\r\n style={{ backgroundColor: storeDetails.tanyaThemeColor }}\r\n onClick={viewMore}\r\n >\r\n View more\r\n </button>\r\n </div>\r\n </div>\r\n </>\r\n );\r\n};\r\n\r\nexport default ProductDisplayCard;\r\n","/* eslint-disable @typescript-eslint/no-explicit-any */\r\nimport { useState, useRef, useEffect } from \"react\";\r\nimport { Popover, PopoverTrigger } from \"../ui/popover\";\r\n// import tanyaChatBotIcon from \"@/assets/tanya-chatbot/chat-with-tanya.png\";\r\n// import { getAccessToken } from \"../utils/getAccessToken\";\r\nimport { getInterestApi, getProductById, getSearchResults } from \"../utils\";\r\nimport type { SearchProduct } from \"../graphQL/queries/types\";\r\nimport {\r\n // decryptData,\r\n // currencyFormatter,\r\n formatStringToHtml,\r\n // priceFormatter,\r\n} from \"../utils/helper\";\r\nimport { useSearchParams } from \"react-router-dom\";\r\nimport ProductDisplay from \"../carousel/ProductDisplay\";\r\nimport { useSelector } from \"react-redux\";\r\nimport ProductDisplayCard from \"../product/ProductDisplayCard\";\r\nimport { toast } from \"react-toastify\";\r\nimport { notifySFCC } from \"../lib/utils\";\r\nimport { addProductToBasket, createBasket, fetchBasket } from \"../api/api\";\r\nimport { fetchTokenBmGrant } from \"../utils/fetchTokenBmGrant\";\r\nimport { fetchExistingGuestCustomerToken } from \"../utils/fetchExistingRegisterCustomerToken\";\r\nimport { TOKEN_EXPIRY_KEY, VERSION } from \"../../config/constant\";\r\nimport {\r\n getStoredBasketId,\r\n setStoredBasketId,\r\n setStoredToken,\r\n} from \"../utils/localStorage\";\r\nimport { authData } from \"../../sfcc-apis/session\";\r\n\r\ntype ProductSnapshot = {\r\n id: string;\r\n name: string;\r\n image: string | null;\r\n price: number | null;\r\n points: number;\r\n quantity: number;\r\n};\r\n\r\nconst TanyaShoppingAssistantStream = () => {\r\n // Shopping options\r\n const shoppingOptions = [\r\n \"Myself\",\r\n \"My Child\",\r\n \"My Grandchild\",\r\n \"Niece/Nephew\",\r\n \"My Friends\",\r\n \"Others\",\r\n ];\r\n\r\n const payloadMapping: Record<string, string> = {\r\n Myself: \"himself/herself\",\r\n \"My Child\": \"his/her child\",\r\n \"My Grandchild\": \"his/her grandchild\",\r\n \"Niece/Nephew\": \"his/her niece/nephew\",\r\n \"My Friends\": \"his/her friends\",\r\n Others: \"others\",\r\n };\r\n const productName = useRef<string | null>(null);\r\n const productId = useRef<number | null>(null);\r\n const productImage = useRef<string | null>(null);\r\n const productPrice = useRef<number | null>(null);\r\n const [authDetails, setAuthDetails] = useState<any>(null);\r\n\r\n const [searchParams] = useSearchParams();\r\n const [isOpen, setIsOpen] = useState(\r\n searchParams.get(\"shoppingassist\") === \"true\"\r\n );\r\n const [isAnimating, setIsAnimating] = useState(false);\r\n const [isVisible, setIsVisible] = useState(false);\r\n const [adding, setAdding] = useState<boolean>(false);\r\n const [isLoading, setIsLoading] = useState(false);\r\n const [productLoading, setProductLoading] = useState(false);\r\n const [inputText, setInputText] = useState(\"\");\r\n const [whom, setWhom] = useState(\"\");\r\n const mapSnapshotToProduct = (snap: ProductSnapshot): any => ({\r\n id: snap.id,\r\n title: snap.name,\r\n image: snap.image ?? \"\",\r\n price: snap.price ?? 0,\r\n });\r\n // const dispatch = useDispatch();\r\n\r\n const [chatHistory, setChatHistory] = useState<\r\n {\r\n query: string;\r\n response: string;\r\n potentialQuestions: string;\r\n products?: { keyword: string; items: SearchProduct[] }[];\r\n keywords: string;\r\n noResults?: boolean;\r\n secondaryResponse?: string;\r\n secondaryLoading?: boolean;\r\n productSnapshot?: ProductSnapshot; // NEW\r\n }[]\r\n >([]);\r\n const scrollRef = useRef<HTMLDivElement>(null);\r\n // const storeCode =\r\n // searchParams.get(\"storeCode\") || localStorage.getItem(\"storeCode\");\r\n const storeDetails = useSelector((s: any) => s.store.store);\r\n const product = useSelector((s: any) => s.product.product);\r\n\r\n const openPanel = () => {\r\n setIsVisible(true);\r\n setTimeout(() => setIsAnimating(true), 10); // trigger opening animation\r\n };\r\n\r\n const closePanel = () => {\r\n setIsAnimating(false);\r\n setTimeout(() => setIsVisible(false), 300); // // wait for exit animation\r\n };\r\n\r\n useEffect(() => {\r\n if (isOpen) openPanel();\r\n else closePanel();\r\n }, [isOpen]);\r\n\r\n const handleWhomSelection = (selected: string) => {\r\n setWhom(payloadMapping[selected]);\r\n };\r\n\r\n useEffect(() => {\r\n if (scrollRef.current) {\r\n scrollRef.current.scrollTop += 150; // Scrolls down by 50px\r\n }\r\n }, [chatHistory]);\r\n\r\n let cachedToken: any = null;\r\n let tokenExpiry: any = null;\r\n\r\n const getJWTToken = async () => {\r\n if (cachedToken && tokenExpiry && Date.now() < tokenExpiry) {\r\n return cachedToken;\r\n }\r\n\r\n try {\r\n const tokenUrl =\r\n \"https://us-east-1lsr29ln3u.auth.us-east-1.amazoncognito.com/oauth2/token\";\r\n\r\n const tokenPayload = new URLSearchParams({\r\n grant_type: \"client_credentials\",\r\n client_id: \"4i8rd70sgt961tc4dhskgf08c\",\r\n client_secret: \"bnsfq1220loh2cn2cm2ttn8fdhdpt0u8m1fgj8vfk2rn61aurjg\",\r\n scope: \"default-m2m-resource-server-8xzfzo/read\",\r\n });\r\n\r\n const tokenResponse = await fetch(tokenUrl, {\r\n method: \"POST\",\r\n headers: {\r\n \"Content-Type\": \"application/x-www-form-urlencoded\",\r\n },\r\n body: tokenPayload,\r\n });\r\n\r\n if (!tokenResponse.ok) {\r\n throw new Error(\r\n `Token request failed! status: ${tokenResponse.status}`\r\n );\r\n }\r\n\r\n const tokenData = await tokenResponse.json();\r\n\r\n // Cache the token\r\n cachedToken = tokenData.access_token;\r\n const expiresIn = tokenData.expires_in || 3600; // Default to 1 hour\r\n tokenExpiry = Date.now() + (expiresIn - 60) * 1000; // Refresh 1 minute before expiry\r\n\r\n return cachedToken;\r\n } catch (error) {\r\n console.error(\"Error obtaining JWT token:\", error);\r\n // Clear cache on error\r\n cachedToken = null;\r\n tokenExpiry = null;\r\n return null;\r\n }\r\n };\r\n\r\n const getAuthDetails = async () => {\r\n const data = await authData(); // <- calls your async function\r\n if (data == null) return;\r\n setAuthDetails(data); // <- saves the result in state\r\n };\r\n\r\n useEffect(() => {\r\n if (import.meta.env.VITE_SCAPI_ENVIRONMENT) {\r\n getAuthDetails();\r\n console.log(\"scapi environment v1\");\r\n } else {\r\n console.log(\"ocapi environment\");\r\n }\r\n }, []);\r\n\r\n const getInterests = async () => {\r\n const customer_id = JSON.parse(\r\n sessionStorage.getItem(\"customerData\") || \"{}\"\r\n ).customerId;\r\n const res = await getInterestApi(customer_id || \"\");\r\n return res.c_interests;\r\n };\r\n\r\n const runSecondaryFlow = async (productTitle: string, points: number) => {\r\n console.log(\"in secondary flow\", VERSION);\r\n const interests = await getInterests();\r\n console.log(interests, \"interests of customer\", VERSION);\r\n if (!interests) return;\r\n try {\r\n // surprise animation\r\n setChatHistory((prev) =>\r\n prev.map((msg, idx) =>\r\n idx === prev.length - 1 ? { ...msg, secondaryLoading: true } : msg\r\n )\r\n );\r\n\r\n const accessToken = await getJWTToken();\r\n if (!accessToken) throw new Error(\"Failed to fetch token\");\r\n\r\n const user = localStorage.getItem(\"customerNumber\");\r\n const isLoggedIn = localStorage.getItem(\"isLoggedIn\");\r\n const queryParams = new URLSearchParams({\r\n registered: String(isLoggedIn || false),\r\n userId: String(user || new Date().getTime()),\r\n });\r\n const invokeUrl = `https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${queryParams.toString()}`;\r\n\r\n const payload = JSON.stringify({\r\n flowId: \"Q166PR519W\",\r\n flowAliasId: \"HKFUVLWVH2\",\r\n input: {\r\n loyaltyPoints: \"\",\r\n productName: productTitle,\r\n productPoints: String(points || 0),\r\n interests: interests,\r\n },\r\n });\r\n\r\n const response = await fetch(invokeUrl, {\r\n signal: AbortSignal.timeout(30000),\r\n method: \"POST\",\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n Authorization: `Bearer ${accessToken}`,\r\n },\r\n body: payload,\r\n });\r\n\r\n if (!response.body) throw new Error(\"Readable stream not supported\");\r\n\r\n const reader = response.body.getReader();\r\n const decoder = new TextDecoder();\r\n let buffer = \"\";\r\n\r\n while (true) {\r\n const { done, value } = await reader.read();\r\n if (done) break;\r\n buffer += decoder.decode(value, { stream: true });\r\n const lines = buffer.split(\"\\n\");\r\n buffer = lines.pop() || \"\";\r\n\r\n for (const line of lines) {\r\n if (line.startsWith(\"data:\")) {\r\n const jsonData = line.slice(5).trim();\r\n try {\r\n const parsedData = JSON.parse(jsonData);\r\n\r\n if (parsedData.index === 0) {\r\n // attach response & stop animation\r\n setChatHistory((prev) =>\r\n prev.map((msg, idx) =>\r\n idx === prev.length - 1\r\n ? {\r\n ...msg,\r\n secondaryResponse: parsedData.data,\r\n secondaryLoading: false,\r\n }\r\n : msg\r\n )\r\n );\r\n }\r\n // ignore 1/2/3\r\n } catch (e) {\r\n // stop animation on parse error too\r\n setChatHistory((prev) =>\r\n prev.map((msg, idx) =>\r\n idx === prev.length - 1\r\n ? { ...msg, secondaryLoading: false }\r\n : msg\r\n )\r\n );\r\n console.error(\"Secondary flow JSON parse error:\", e);\r\n }\r\n }\r\n }\r\n }\r\n } catch (e) {\r\n console.error(\"Secondary flow error:\", e);\r\n }\r\n };\r\n\r\n const handleSendMessage = async (question?: string) => {\r\n const newQuery = question || inputText.trim();\r\n if (!newQuery) return;\r\n\r\n setIsLoading(true);\r\n setInputText(\"\");\r\n\r\n productName.current = null;\r\n productId.current = null;\r\n productImage.current = null;\r\n productPrice.current = null;\r\n\r\n setChatHistory((prev) => [\r\n ...prev,\r\n {\r\n query: newQuery,\r\n response: \"Thinking for what suits you best...\",\r\n potentialQuestions: \"\",\r\n products: [],\r\n keywords: \"Thinking for best products...\",\r\n },\r\n ]);\r\n\r\n try {\r\n const sanitizedWhom = whom;\r\n const user = localStorage.getItem(\"customerNumber\");\r\n const isLoggedIn = localStorage.getItem(\"isLoggedIn\");\r\n\r\n // Get JWT access token\r\n const accessToken = await getJWTToken();\r\n if (!accessToken) {\r\n throw new Error(\"Failed to obtain access token\");\r\n }\r\n\r\n // Build the invoke flow URL\r\n const queryParams = new URLSearchParams({\r\n registered: String(isLoggedIn || false),\r\n userId: String(user || new Date().getTime()),\r\n });\r\n\r\n const invokeUrl = `https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${queryParams.toString()}`;\r\n\r\n const payload = JSON.stringify({\r\n flowId: \"MMHQKYI1NE\",\r\n flowAliasId: \"SZF9ZK1ATE\",\r\n input: {\r\n userPrompt: newQuery,\r\n whom: sanitizedWhom,\r\n },\r\n });\r\n\r\n const response = await fetch(invokeUrl, {\r\n signal: AbortSignal.timeout(30000),\r\n method: \"POST\",\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n Authorization: `Bearer ${accessToken}`,\r\n },\r\n body: payload,\r\n });\r\n\r\n if (!response.ok) {\r\n throw new Error(`HTTP error! status: ${response.status}`);\r\n }\r\n\r\n if (!response.body) throw new Error(\"Readable stream not supported\");\r\n\r\n const reader = response.body.getReader();\r\n const decoder = new TextDecoder();\r\n let buffer = \"\";\r\n let keywords = \"\";\r\n\r\n while (true) {\r\n setProductLoading(true);\r\n const { done, value } = await reader.read();\r\n if (done) break;\r\n\r\n buffer += decoder.decode(value, { stream: true });\r\n const lines = buffer.split(\"\\n\");\r\n buffer = lines.pop() || \"\";\r\n\r\n for (const line of lines) {\r\n if (line.startsWith(\"data:\")) {\r\n const jsonData = line.slice(5).trim();\r\n try {\r\n const parsedData = JSON.parse(jsonData);\r\n if (parsedData.index == 1) keywords = parsedData.data;\r\n\r\n setChatHistory((prev) =>\r\n prev.map((msg, idx) =>\r\n idx === prev.length - 1\r\n ? {\r\n ...msg,\r\n [parsedData.index == 0\r\n ? \"response\"\r\n : parsedData.index == 1\r\n ? \"keywords\"\r\n : parsedData.index == 2\r\n ? \"potentialQuestions\"\r\n : \"end\"]: parsedData.data,\r\n }\r\n : msg\r\n )\r\n );\r\n } catch (error) {\r\n console.error(\"Error parsing JSON:\", error);\r\n }\r\n }\r\n }\r\n }\r\n getKeywords(sanitizeKeywords(keywords));\r\n } catch (error) {\r\n console.error(\"Error sending message to Tanya:\", error);\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n const sanitizeKeywords = (response: string) => {\r\n const keywordMatch = response.match(\r\n /top five relevant product or category names are: (.*)/i\r\n );\r\n const keywordsString = keywordMatch ? keywordMatch[1] : response;\r\n const keywordsArray = keywordsString.split(\", \");\r\n const sanitizedKeywords = keywordsArray.map((keyword) => {\r\n return keyword.replace(/\\s*(Toys|Bags|Miniature|etc\\.*)\\s*/gi, \"\").trim();\r\n });\r\n const uniqueKeywords = [...new Set(sanitizedKeywords)].filter(Boolean);\r\n return uniqueKeywords.join(\",\");\r\n };\r\n\r\n const getKeywords = async (keywords: string[] | string) => {\r\n console.log(authDetails?.access_token, \"access_token\");\r\n if (typeof keywords === \"string\") {\r\n console.log(keywords, \"keywords\");\r\n const splitedKeywords = keywords.split(\",\");\r\n for (const keyword of splitedKeywords) {\r\n const results = await getSearchResults(\r\n keyword,\r\n authDetails?.access_token\r\n );\r\n setProductLoading(false);\r\n if (results?.length > 0) {\r\n setChatHistory((prev) =>\r\n prev.map((msg, idx) =>\r\n idx === prev.length - 1\r\n ? {\r\n ...msg,\r\n products: [\r\n ...(msg.products || []),\r\n { keyword: keyword, items: results, loading: false },\r\n ],\r\n }\r\n : msg\r\n )\r\n );\r\n if (!productName.current || productId.current == null) {\r\n const first = results[0] as any;\r\n productName.current = String(first?.product_name ?? \"\");\r\n productImage.current = first.image.link;\r\n productId.current = first.product_id;\r\n\r\n // price\r\n const priceVal =\r\n typeof first?.price === \"number\" ? first.price : undefined;\r\n\r\n productPrice.current =\r\n typeof priceVal === \"number\" && Number.isFinite(priceVal)\r\n ? priceVal\r\n : null;\r\n }\r\n }\r\n }\r\n } else {\r\n for (const keyword of keywords) {\r\n const results = await getSearchResults(\r\n keyword,\r\n authDetails?.access_token\r\n );\r\n setProductLoading(false);\r\n if (results?.length > 0) {\r\n setChatHistory((prev) =>\r\n prev.map((msg, idx) =>\r\n idx === prev.length - 1\r\n ? {\r\n ...msg,\r\n products: [\r\n ...(msg.products || []),\r\n { keyword: keyword, items: results, loading: false },\r\n ],\r\n }\r\n : msg\r\n )\r\n );\r\n }\r\n }\r\n }\r\n if (productName.current) {\r\n setChatHistory((prev: any) =>\r\n prev.map((msg: any, idx: number) =>\r\n idx === prev.length - 1\r\n ? {\r\n ...msg,\r\n productSnapshot: {\r\n id: productId.current,\r\n name: productName.current,\r\n image: productImage.current,\r\n price: productPrice.current ?? null,\r\n points: 0,\r\n quantity: 1,\r\n },\r\n }\r\n : msg\r\n )\r\n );\r\n const customerData = JSON.parse(\r\n sessionStorage.getItem(\"customerData\") || \"{}\"\r\n );\r\n if (customerData?.isGuest == false) {\r\n console.log(\"running secondary flow\", VERSION);\r\n runSecondaryFlow(productName.current, 0);\r\n } else {\r\n console.log(\"not running secondary flow\", VERSION);\r\n }\r\n }\r\n setProductLoading(false);\r\n };\r\n\r\n const handleAddToCart = async (productToBeAdded: any, quantity: number) => {\r\n setAdding(true);\r\n try {\r\n const product = await getProductById(productToBeAdded.id);\r\n if (\r\n !(\r\n product?.variants?.[0]?.product_id ||\r\n product?.variants?.[0]?.productId\r\n ) &&\r\n !(product.type.item || product.type.bundle)\r\n ) {\r\n setAdding(false);\r\n toast.error(\"Variants not found\", {\r\n position: \"bottom-right\",\r\n autoClose: 1000,\r\n });\r\n console.error(\"No product variant found\");\r\n return;\r\n }\r\n\r\n const productData = [\r\n {\r\n product_id:\r\n product.variants?.[0].product_id ||\r\n product.variants?.[0].productId ||\r\n product?.id,\r\n quantity: quantity,\r\n },\r\n ];\r\n console.log(productData, \"product data\", \"app version\", VERSION);\r\n // for getting customer id\r\n const customerData = JSON.parse(\r\n sessionStorage.getItem(\"customerData\") || \"{}\"\r\n );\r\n const basketIdFromCustomer = customerData?.basketId;\r\n const customer_token = false;\r\n const tokenExpiry = localStorage.getItem(TOKEN_EXPIRY_KEY);\r\n const currentTime = Date.now();\r\n\r\n // If no token, get a new one\r\n if (\r\n !customer_token ||\r\n !tokenExpiry ||\r\n currentTime >= parseInt(tokenExpiry)\r\n ) {\r\n const access_token = await fetchTokenBmGrant();\r\n\r\n let { customer_token } = await fetchExistingGuestCustomerToken(\r\n access_token\r\n );\r\n if (import.meta.env.VITE_SCAPI_ENVIRONMENT) {\r\n customer_token = \"Bearer \" + authDetails.access_token;\r\n }\r\n if (!customer_token) {\r\n console.error(\"Failed to get customer_token\");\r\n return;\r\n }\r\n const newExpiryTime = currentTime + 5 * 60 * 1000;\r\n setStoredToken(customer_token);\r\n localStorage.setItem(TOKEN_EXPIRY_KEY, newExpiryTime.toString());\r\n\r\n // 1. Try basketId from customerData\r\n if (basketIdFromCustomer) {\r\n const fetchBasketResponse = await fetchBasket({\r\n basketId: basketIdFromCustomer,\r\n customer_token,\r\n });\r\n if (fetchBasketResponse.status === 200 && fetchBasketResponse) {\r\n // Use this basketId to add product\r\n\r\n const response = await addProductToBasket(\r\n basketIdFromCustomer,\r\n productData,\r\n customer_token\r\n );\r\n if (response?.product_items?.length > 0) {\r\n // const addedProduct = response.product_items.at(-1);\r\n toast.success(`Added to cart`, {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n hideProgressBar: false,\r\n closeOnClick: true,\r\n pauseOnHover: true,\r\n draggable: true,\r\n });\r\n notifySFCC(basketIdFromCustomer);\r\n setAdding(false);\r\n // window.location.reload();\r\n }\r\n return; // Skip basket creation\r\n }\r\n }\r\n\r\n // 2. If not valid, create new basket and store its ID in localStorage\r\n const data = {\r\n productItems: [\r\n {\r\n productId:\r\n product.variants?.[0].product_id ||\r\n product.variants?.[0].productId ||\r\n product?.id,\r\n quantity: 1,\r\n },\r\n ],\r\n };\r\n const basketResponse = await createBasket(customer_token, data);\r\n console.log(\r\n basketResponse,\r\n basketResponse?.basket_id,\r\n basketResponse?.basketId,\r\n \"the basket response\"\r\n );\r\n if (!(basketResponse?.basket_id || !basketResponse?.basketId)) {\r\n setAdding(false);\r\n console.error(\"Failed to create basket\");\r\n return;\r\n }\r\n // else if (basketResponse?.basketId) {\r\n // toast.success(`Added to cart`, {\r\n // position: \"bottom-right\",\r\n // autoClose: 3000,\r\n // hideProgressBar: false,\r\n // closeOnClick: true,\r\n // pauseOnHover: true,\r\n // draggable: true,\r\n // });\r\n // }\r\n\r\n // Store new basket ID\r\n setStoredBasketId(\r\n basketResponse?.basket_id || basketResponse?.basketId\r\n );\r\n // Add product to new basket\r\n // if (!import.meta.env.VITE_SCAPI_ENVIRONMENT) {\r\n const response = await addProductToBasket(\r\n basketResponse?.basket_id || basketResponse?.basketId,\r\n productData,\r\n customer_token\r\n );\r\n if (\r\n response?.product_items?.length > 0 ||\r\n response?.productItems?.length > 0\r\n ) {\r\n toast.success(`Added to cart`, {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n hideProgressBar: false,\r\n closeOnClick: true,\r\n pauseOnHover: true,\r\n draggable: true,\r\n });\r\n }\r\n notifySFCC(basketResponse.basket_id || basketResponse?.basketId);\r\n // }\r\n } else {\r\n // Use existing customer_token and basket ID\r\n const basketId = getStoredBasketId();\r\n if (!basketId) {\r\n console.error(\"No basket ID found\");\r\n setAdding(false);\r\n return;\r\n }\r\n\r\n const response = await addProductToBasket(\r\n basketId,\r\n productData,\r\n customer_token\r\n );\r\n if (response?.product_items?.length > 0) {\r\n toast.success(`Added to cart`, {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n hideProgressBar: false,\r\n closeOnClick: true,\r\n pauseOnHover: true,\r\n draggable: true,\r\n });\r\n setAdding(false);\r\n notifySFCC(basketId);\r\n }\r\n }\r\n } catch (error: any) {\r\n setAdding(false);\r\n console.error(\"Error adding to cart:\", error);\r\n toast.error(\"Failed to add product to cart\", {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n });\r\n\r\n if (\r\n error?.response?.status === 404 || // Basket not found\r\n error?.response?.status === 401 // Unauthorized/expired\r\n ) {\r\n // Clear only basket ID for 404\r\n if (error?.response?.status === 404) {\r\n setStoredBasketId(null);\r\n }\r\n // Clear both for 401\r\n if (error?.response?.status === 401) {\r\n setStoredBasketId(null);\r\n setStoredToken(null);\r\n }\r\n } else {\r\n console.error(\"Failed to add product to basket:\", error.message);\r\n toast.error(\"Failed to add product to cart\", {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n });\r\n }\r\n } finally {\r\n notifySFCC();\r\n }\r\n setAdding(false);\r\n };\r\n\r\n // Update the main container div's className\r\n return (\r\n <div className=\"relative flex justify-center\">\r\n <Popover open={isOpen} onOpenChange={setIsOpen}>\r\n <PopoverTrigger\r\n onClick={() => setIsOpen(true)}\r\n style={\r\n {\r\n // background: storeDetails.tanyaThemeColor,\r\n }\r\n }\r\n className=\"flex items-center rounded-lg cursor-pointer hover:opacity-90 transition-opacity\"\r\n >\r\n <div className=\"flex flex-col p-[5px]\">\r\n <svg\r\n width=\"40\"\r\n height=\"40\"\r\n viewBox=\"0 0 40 40\"\r\n fill=\"none\"\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n >\r\n <g clipPath=\"url(#clip0_958_585)\">\r\n <path\r\n d=\"M30.0002 5C31.7683 5 33.464 5.70238 34.7142 6.95262C35.9644 8.20286 36.6668 9.89856 36.6668 11.6667V25C36.6668 26.7681 35.9644 28.4638 34.7142 29.714C33.464 30.9643 31.7683 31.6667 30.0002 31.6667H25.6902L21.1785 36.1783C20.8915 36.4653 20.5097 36.6377 20.1046 36.6631C19.6996 36.6886 19.2992 36.5654 18.9785 36.3167L18.8218 36.1783L14.3085 31.6667H10.0002C8.28976 31.6667 6.64478 31.0093 5.40548 29.8305C4.16617 28.6516 3.42735 27.0416 3.34183 25.3333L3.3335 25V11.6667C3.3335 9.89856 4.03588 8.20286 5.28612 6.95262C6.53636 5.70238 8.23205 5 10.0002 5H30.0002Z\"\r\n fill=\"url(#paint0_linear_958_585)\"\r\n />\r\n <path\r\n d=\"M28.3335 15.6511V11.6667C28.3335 11.6667 22.2774 12.6042 20.1148 15.4167C17.9521 18.2292 18.6644 26.6667 18.6644 26.6667H22.5321C22.5321 26.6667 22.0614 18.9323 23.4989 17.2917C24.9364 15.6511 28.3335 15.6511 28.3335 15.6511Z\"\r\n fill=\"white\"\r\n />\r\n <path\r\n d=\"M13.3335 11.6667H19.6184V15.4167H13.3335V11.6667Z\"\r\n fill=\"white\"\r\n />\r\n </g>\r\n <defs>\r\n <linearGradient\r\n id=\"paint0_linear_958_585\"\r\n x1=\"20.0002\"\r\n y1=\"5\"\r\n x2=\"35.0002\"\r\n y2=\"30\"\r\n gradientUnits=\"userSpaceOnUse\"\r\n >\r\n <stop stopColor=\"#452697\" />\r\n <stop offset=\"1\" stopColor=\"#7C5BFF\" />\r\n </linearGradient>\r\n <clipPath id=\"clip0_958_585\">\r\n <rect width=\"40\" height=\"40\" fill=\"white\" />\r\n </clipPath>\r\n </defs>\r\n </svg>\r\n </div>\r\n </PopoverTrigger>\r\n\r\n {/* Absolute Positioned PopoverContent and Custom Sidebar Panel */}\r\n {isVisible && (\r\n <>\r\n {/* Overlay For closing tanya popup by clicking on side or background */}\r\n <div\r\n className=\"fixed inset-0 z-40 bg-black/30\"\r\n onClick={() => setIsOpen(false)}\r\n />\r\n <div\r\n className={`\r\n fixed z-50 h-screen w-[100vw] sm:w-[80vw] md:w-[770px] border-0 bg-white lg:rounded-l-xl overflow-hidden flex flex-col shadow-[0px_4px_10px_0px_#5F499840]\r\n top-0 right-0\r\n transition-transform duration-300 ease-in-out\r\n lg:transform\r\n ${isAnimating ? \"lg:translate-x-0\" : \"lg:translate-x-full\"}\r\n // For mobile: animate from bottom\r\n ${isAnimating ? \"translate-y-0\" : \"translate-y-full\"}\r\n lg:translate-y-0\r\n `}\r\n style={{\r\n background:\r\n \"linear-gradient(170.1deg, #FFFFFF 60.03%, #E3DEEF 99.59%)\",\r\n }}\r\n >\r\n {/* Header */}\r\n <div\r\n className={`flex justify-between p-3 bg-[#FFFFFF] border border-b-1 border-[#E5E5E5] `} //lg:rounded-tl-xl lg:rounded-bl-xl\r\n >\r\n <div\r\n style={{\r\n display: \"flex\",\r\n color: storeDetails.tanyaThemeContrastColor,\r\n alignItems: \"center\",\r\n gap: \"0.5rem\",\r\n }}\r\n >\r\n <div className=\"flex flex-col gap-1\">\r\n <div\r\n className=\"flex gap-2 w-28 h-12 text-center items-center p-2 border rounded-l-[20px] rounded-tr-[20px]\"\r\n style={{\r\n background:\r\n \"linear-gradient(265.62deg, #6851C6 5.24%, #8668FF 98.49%)\",\r\n }}\r\n >\r\n <svg\r\n width=\"20\"\r\n height=\"20\"\r\n viewBox=\"0 0 15 16\"\r\n fill=\"none\"\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n >\r\n <path\r\n d=\"M15 4.48438V0.5C15 0.5 8.94395 1.4375 6.78127 4.25C4.61859 7.0625 5.33095 15.5 5.33095 15.5H9.19857C9.19857 15.5 8.72793 7.76562 10.1654 6.125C11.6029 4.48438 15 4.48438 15 4.48438Z\"\r\n fill=\"white\"\r\n />\r\n <path d=\"M0 0.5H6.28488V4.25H0V0.5Z\" fill=\"white\" />\r\n </svg>\r\n\r\n <p className=\"text-[#FFFFFF] font-nunitoSans font-semibold\">\r\n TANYA\r\n </p>\r\n </div>\r\n <p\r\n className=\"text-[#5B5B5B] font-nunitoSans font-semibold\"\r\n style={{ fontStyle: \"italic\" }}\r\n >\r\n {\" \"}\r\n Your AI shopping assistant !{\" \"}\r\n </p>\r\n </div>\r\n </div>\r\n <div\r\n style={{\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n gap: \"1.25rem\",\r\n margin: \"0.75rem\",\r\n }}\r\n >\r\n {/* close icon */}\r\n <button onClick={() => setIsOpen(false)}>\r\n <svg\r\n width=\"24\"\r\n height=\"25\"\r\n viewBox=\"0 0 24 25\"\r\n fill=\"none\"\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n >\r\n <g clipPath=\"url(#clip0_501_6036)\">\r\n <path\r\n d=\"M18 6.5L6 18.5\"\r\n stroke=\"#555555\"\r\n strokeWidth=\"1.5\"\r\n strokeLinecap=\"round\"\r\n strokeLinejoin=\"round\"\r\n />\r\n <path\r\n d=\"M6 6.5L18 18.5\"\r\n stroke=\"#555555\"\r\n strokeWidth=\"1.5\"\r\n strokeLinecap=\"round\"\r\n strokeLinejoin=\"round\"\r\n />\r\n </g>\r\n <defs>\r\n <clipPath id=\"clip0_501_6036\">\r\n <rect\r\n width=\"24\"\r\n height=\"24\"\r\n fill=\"white\"\r\n transform=\"translate(0 0.5)\"\r\n />\r\n </clipPath>\r\n </defs>\r\n </svg>\r\n </button>\r\n </div>\r\n </div>\r\n\r\n {/* Chat Container */}\r\n <div className={`flex h-full md:flex-row lg:flex-row`}>\r\n <div\r\n className={`flex flex-col h-full ${\r\n product ? \"lg:w-2/3 w-full\" : \"w-full\"\r\n }`}\r\n >\r\n {/* Chat Body - Scrollable */}\r\n <div\r\n ref={scrollRef}\r\n className=\"overflow-y-auto pr-5 pb-2 space-y-4 hide-scrollbar flex-grow mb-24\"\r\n >\r\n {/* Shopping Options */}\r\n {storeDetails?.whomRequired && (\r\n <div\r\n className=\"mx-3 p-3 rounded-2xl bg-[#FFFFFF]\"\r\n // style={{\r\n // color: storeDetails?.tanyaThemeContrastColor,\r\n // backgroundColor: storeDetails.tanyaThemeColor, //need to comment\r\n // width: \"fit-content\",\r\n // }}\r\n >\r\n <div className=\"flex gap-2 bg-[#FFFFFF]\">\r\n {/* <Icon\r\n icon=\"mdi:shopping\"\r\n color=\"white\"\r\n width=\"22\"\r\n height=\"22\"\r\n /> */}\r\n <p className=\"font-bold font-nunitoSans text-[#494949]\">\r\n Is this for you or someone else?\r\n </p>\r\n </div>\r\n\r\n <div className=\"flex flex-wrap gap-2 mt-2\">\r\n {shoppingOptions.map((option) => (\r\n <button\r\n key={option}\r\n onClick={() => handleWhomSelection(option)}\r\n className=\"px-2 py-2 font-semibold text-xs text-[#18181B] bg-[#F3F3F3] rounded-2xl\"\r\n style={{\r\n backgroundColor:\r\n whom === payloadMapping[option]\r\n ? \"#FFFFFF\"\r\n : \"#F3F3F3\",\r\n borderColor:\r\n whom === payloadMapping[option]\r\n ? \"#BBB3DD\"\r\n : \"\",\r\n }}\r\n >\r\n {option}\r\n </button>\r\n ))}\r\n </div>\r\n </div>\r\n )}\r\n {/* Chat History */}\r\n {chatHistory.map((chat, index) => (\r\n <div key={index}>\r\n <div className=\"flex justify-end\">\r\n <p className=\"text-sm font-nunitoSans font-bold text-[#000000] bg-[#E2DBFF] border border-[#C9C2DE] rounded-l-xl p-2 m-3 mb-4 rounded-br-xl max-w-[75%]\">\r\n {chat.query}\r\n </p>\r\n </div>\r\n {chat.response && chat.response.includes(\"Thinking\") ? (\r\n <div>\r\n <div\r\n className=\"font-nunitoSans animate-pulse font-bold text-sm text-[#494949] bg-[#FFFFFF] px-7 py-1 rounded-r-xl rounded-bl-2xl w-full\"\r\n dangerouslySetInnerHTML={{\r\n __html: formatStringToHtml(chat.response),\r\n }}\r\n />\r\n </div>\r\n ) : (\r\n <div>\r\n <div\r\n className=\"font-nunitoSans font-bold text-sm text-[#494949] bg-[#FFFFFF] px-7 py-1 rounded-r-xl rounded-bl-2xl w-full\"\r\n dangerouslySetInnerHTML={{\r\n __html: formatStringToHtml(chat.response),\r\n }}\r\n />\r\n </div>\r\n )}\r\n {productLoading &&\r\n !chat.response.includes(\"Thinking\") &&\r\n chat.products?.length == 0 && (\r\n <div>\r\n <p className=\"text-sm animate-pulse font-nunitoSans font-bold text-[#000000] bg-[#E2DBFF] border border-[#C9C2DE] rounded-l-xl p-2 m-3 mb-4 rounded-br-xl max-w-[75%]\">\r\n Finding best products for you\r\n </p>\r\n </div>\r\n )}\r\n {chat?.products && chat?.products?.length > 0 && (\r\n <ProductDisplay\r\n chat={chat.products}\r\n storeDetails={storeDetails}\r\n />\r\n )}\r\n\r\n {/* Potential Questions */}\r\n {chat.potentialQuestions.length > 0 && (\r\n <div className=\"my-2 px-4 text-sm text-gray-700\">\r\n <p\r\n className=\"font-nunitoSans font-bold text-sm text-[#494949]\"\r\n style={{ color: storeDetails.themeDarkColor }}\r\n >\r\n Why not explore these inquiries...\r\n </p>\r\n {chat.potentialQuestions\r\n .split(\",\")\r\n .map((question, idx) => (\r\n <button\r\n key={idx}\r\n className={`cursor-pointer font-nunitoSans font-semibold text-[#232323] border bg-[#804C9E0D] border-${storeDetails.themeDarkColor} m-1 rounded-xl px-2 py-1`}\r\n onClick={() => handleSendMessage(question)}\r\n style={{\r\n backgroundColor:\r\n storeDetails.tanyaThemeColorLight,\r\n }}\r\n >\r\n {question}\r\n </button>\r\n ))}\r\n </div>\r\n )}\r\n\r\n {chat.secondaryLoading && (\r\n <div className=\"mt-3 mb-4 px-4\">\r\n <div\r\n className=\"tanya-surprise-wrapper bg-indigo-300 text-sm px-7 py-4 rounded-r-xl rounded-bl-2xl w-full relative overflow-hidden\"\r\n style={{\r\n margin: \"0.75rem\",\r\n }}\r\n >\r\n <div className=\"flex gap-1\">\r\n <div className=\"tanya-sparkle tanya-sparkle-1\">\r\n ✨\r\n </div>\r\n <div className=\"tanya-sparkle tanya-sparkle-2\">\r\n ✨\r\n </div>\r\n <div className=\"tanya-sparkle tanya-sparkle-3\">\r\n ✨\r\n </div>\r\n </div>\r\n <div className=\"tanya-shimmer\" />\r\n <p\r\n className=\"font-semibold tanya-pulse\"\r\n style={{ color: storeDetails.themeDarkColor }}\r\n >\r\n I’ve found a special surprise crafted just for\r\n you… hang on a sec!\r\n </p>\r\n <p\r\n className=\"tanya-dots mt-1\"\r\n style={{ color: storeDetails.themeDarkColor }}\r\n >\r\n • • •\r\n </p>\r\n </div>\r\n </div>\r\n )}\r\n\r\n {/* Secondary Response (from secondary flow) */}\r\n {chat.secondaryResponse && (\r\n <>\r\n <div className=\"mt-3 mb-8 px-4 bg-indigo-300 rounded-tr-[5px]\">\r\n {/* Chat Response */}\r\n <div\r\n className=\"text-sm text-[#232323] bg-[#FFFFFF] px-7 py-4 rounded-br-xl rounded-bl-2xl w-full\"\r\n style={{\r\n backgroundColor:\r\n storeDetails.tanyaThemeColorLight,\r\n }}\r\n dangerouslySetInnerHTML={{\r\n __html: formatStringToHtml(\r\n chat.secondaryResponse\r\n ),\r\n }}\r\n />\r\n {chat.productSnapshot && (\r\n // chat.productSnapshot.points > 0 &&\r\n <div className=\"mt-4 w-full\">\r\n <div\r\n className=\"flex gap-4 items-stretch rounded-2xl p-4\"\r\n style={{\r\n backgroundColor:\r\n storeDetails.tanyaThemeColorLight,\r\n }}\r\n >\r\n <div\r\n className=\"flex-shrink-0 rounded-xl overflow-hidden border\"\r\n style={{\r\n width: 112,\r\n height: 112,\r\n borderColor: \"#eee\",\r\n }}\r\n >\r\n {chat.productSnapshot.image ? (\r\n <img\r\n src={chat.productSnapshot.image}\r\n alt={chat.productSnapshot.name}\r\n className=\"w-full h-full object-cover\"\r\n />\r\n ) : (\r\n <div className=\"w-full h-full flex items-center justify-center text-xs text-gray-500\">\r\n No Image\r\n </div>\r\n )}\r\n </div>\r\n\r\n <div className=\"flex flex-col flex-1 justify-between\">\r\n <div>\r\n <p className=\"font-semibold text-[15px] leading-snug\">\r\n {chat.productSnapshot.name}\r\n </p>\r\n <p className=\"mt-1 text-[14px] font-medium\">\r\n {chat.productSnapshot.price != null\r\n ? new Intl.NumberFormat(undefined, {\r\n style: \"currency\",\r\n currency:\r\n storeDetails?.currency ||\r\n \"USD\",\r\n }).format(\r\n chat.productSnapshot.price\r\n )\r\n : \"\"}\r\n </p>\r\n\r\n {chat.productSnapshot.points > 0 && (\r\n <p className=\"mt-1 text-xs opacity-80\">\r\n You will earn{\" \"}\r\n <strong>\r\n {chat.productSnapshot.points}{\" \"}\r\n points\r\n </strong>\r\n </p>\r\n )}\r\n </div>\r\n\r\n <div className=\"mt-3 flex items-center gap-3\">\r\n <div className=\"flex items-center border rounded-full overflow-hidden\">\r\n <button\r\n className=\"px-3 py-1 text-sm\"\r\n onClick={() =>\r\n setChatHistory((prev) =>\r\n prev.map((m, i) =>\r\n i === index &&\r\n m.productSnapshot\r\n ? {\r\n ...m,\r\n productSnapshot: {\r\n ...m.productSnapshot,\r\n quantity: Math.max(\r\n 1,\r\n m.productSnapshot\r\n .quantity - 1\r\n ),\r\n },\r\n }\r\n : m\r\n )\r\n )\r\n }\r\n style={{\r\n background: \"transparent\",\r\n color:\r\n storeDetails.themeDarkColor,\r\n }}\r\n >\r\n −\r\n </button>\r\n <div className=\"px-3 py-1 text-sm select-none\">\r\n {chat.productSnapshot.quantity}\r\n </div>\r\n <button\r\n className=\"px-3 py-1 text-sm\"\r\n onClick={() =>\r\n setChatHistory((prev) =>\r\n prev.map((m, i) =>\r\n i === index &&\r\n m.productSnapshot\r\n ? {\r\n ...m,\r\n productSnapshot: {\r\n ...m.productSnapshot,\r\n quantity:\r\n m.productSnapshot\r\n .quantity + 1,\r\n },\r\n }\r\n : m\r\n )\r\n )\r\n }\r\n style={{\r\n background: \"transparent\",\r\n color:\r\n storeDetails.themeDarkColor,\r\n }}\r\n >\r\n +\r\n </button>\r\n </div>\r\n <button\r\n onClick={() => {\r\n handleAddToCart(\r\n mapSnapshotToProduct(\r\n chat.productSnapshot!\r\n ),\r\n chat.productSnapshot!.quantity\r\n );\r\n }}\r\n disabled={adding}\r\n className=\"px-4 py-2 rounded-full font-medium\"\r\n style={{\r\n background:\r\n storeDetails.tanyaThemeColor,\r\n color:\r\n storeDetails?.tanyaThemeContrastColor ||\r\n \"#fff\",\r\n opacity: adding ? 0.8 : 1,\r\n }}\r\n >\r\n {adding ? \"Adding...\" : \"Add to cart\"}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n )}\r\n </div>\r\n </>\r\n )}\r\n <div className=\"mb-20\"></div>\r\n </div>\r\n ))}\r\n </div>\r\n\r\n {/* Sticky Bottom Input Bar */}\r\n <div className=\"flex flex-col gap-2 sticky bottom-0 left-0 right-0 bg-[#E3DEEF] z-50 px-4 py-2\">\r\n {/* Gradient Border Wrapper */}\r\n <div\r\n className=\"p-[1px] rounded-xl\"\r\n style={{\r\n background:\r\n \"linear-gradient(180deg, #B09FFF 0%, #8D79F6 100%)\",\r\n }}\r\n >\r\n {/* Input + Mic + Submit */}\r\n <div className=\"flex items-center bg-[#FFFFFF] flex-1 rounded-xl px-2 py-1\">\r\n <input\r\n className=\"flex-1 bg-[#FFFFFF] text-[#232323] outline-none border-none px-2 py-2 text-sm\"\r\n placeholder=\"How can I help you...\"\r\n value={inputText}\r\n autoFocus\r\n onChange={(e) => setInputText(e.target.value)}\r\n onKeyDown={(e) => {\r\n if (e.key === \"Enter\" && !isLoading)\r\n handleSendMessage();\r\n }}\r\n />\r\n {/* Mic Icon */}\r\n {/* <button\r\n type=\"button\"\r\n className=\"p-2 text-[#959595] hover:text-[#6952C7]\"\r\n >\r\n <svg\r\n width=\"20\"\r\n height=\"20\"\r\n viewBox=\"0 0 20 20\"\r\n fill=\"none\"\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n >\r\n <g clipPath=\"url(#clip0_501_6086)\">\r\n <path\r\n d=\"M7.5 4.16663C7.5 3.50358 7.76339 2.8677 8.23223 2.39886C8.70107 1.93002 9.33696 1.66663 10 1.66663C10.663 1.66663 11.2989 1.93002 11.7678 2.39886C12.2366 2.8677 12.5 3.50358 12.5 4.16663V8.33329C12.5 8.99633 12.2366 9.63222 11.7678 10.1011C11.2989 10.5699 10.663 10.8333 10 10.8333C9.33696 10.8333 8.70107 10.5699 8.23223 10.1011C7.76339 9.63222 7.5 8.99633 7.5 8.33329V4.16663Z\"\r\n stroke=\"#959595\"\r\n strokeLinecap=\"round\"\r\n strokeLinejoin=\"round\"\r\n />\r\n <path\r\n d=\"M4.1665 8.33337C4.1665 9.88047 4.78109 11.3642 5.87505 12.4582C6.96901 13.5521 8.45274 14.1667 9.99984 14.1667C11.5469 14.1667 13.0307 13.5521 14.1246 12.4582C15.2186 11.3642 15.8332 9.88047 15.8332 8.33337\"\r\n stroke=\"#959595\"\r\n strokeLinecap=\"round\"\r\n strokeLinejoin=\"round\"\r\n />\r\n <path\r\n d=\"M6.6665 17.5H13.3332\"\r\n stroke=\"#959595\"\r\n strokeLinecap=\"round\"\r\n strokeLinejoin=\"round\"\r\n />\r\n <path\r\n d=\"M10 14.1666V17.5\"\r\n stroke=\"#959595\"\r\n strokeLinecap=\"round\"\r\n strokeLinejoin=\"round\"\r\n />\r\n </g>\r\n <defs>\r\n <clipPath id=\"clip0_501_6086\">\r\n <rect width=\"20\" height=\"20\" fill=\"white\" />\r\n </clipPath>\r\n </defs>\r\n </svg>\r\n </button> */}\r\n {/* Submit Button */}\r\n <button\r\n type=\"submit\"\r\n disabled={isLoading}\r\n className=\"p-3\"\r\n onClick={() => handleSendMessage()}\r\n >\r\n {isLoading ? (\r\n <div\r\n className=\"p-3 animate-spin rounded-full h-3 w-3 border-b-2\"\r\n style={{\r\n borderBottom: \"2px solid\",\r\n color: storeDetails.tanyaThemeColor,\r\n }}\r\n />\r\n ) : (\r\n <svg\r\n width=\"20\"\r\n height=\"20\"\r\n viewBox=\"0 0 20 20\"\r\n fill=\"none\"\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n >\r\n <path\r\n d=\"M16.6357 13.6701L18.3521 8.5208C19.8516 4.02242 20.6013 1.77322 19.414 0.585948C18.2268 -0.601312 15.9776 0.148418 11.4792 1.64788L6.32987 3.36432C2.69923 4.57453 0.883923 5.17964 0.368062 6.06698C-0.122688 6.91112 -0.122688 7.95369 0.368062 8.7978C0.883923 9.6852 2.69923 10.2903 6.32987 11.5005C6.77981 11.6505 7.28601 11.5434 7.62294 11.2096L13.1286 5.75495C13.4383 5.44808 13.9382 5.45041 14.245 5.76015C14.5519 6.06989 14.5496 6.56975 14.2398 6.87662L8.8231 12.2432C8.4518 12.6111 8.3342 13.1742 8.4995 13.6701C9.7097 17.3007 10.3148 19.1161 11.2022 19.6319C12.0463 20.1227 13.0889 20.1227 13.933 19.6319C14.8204 19.1161 15.4255 17.3008 16.6357 13.6701Z\"\r\n fill=\"#6952C7\"\r\n />\r\n </svg>\r\n )}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <ProductDisplayCard />\r\n </div>\r\n {/* </PopoverContent> */}\r\n </div>\r\n </>\r\n )}\r\n </Popover>\r\n </div>\r\n );\r\n};\r\n\r\nexport default TanyaShoppingAssistantStream;\r\n\r\n// ${import.meta.env.VITE_SERVER_BASE_URL}api/web-bff/assistantStream\r\n"],"names":["notifySFCC","basketId","event","Popover","props","PopoverPrimitive","PopoverTrigger","apiConfig","fetchTokenBmGrant","URL","response","axios","getHost","getSiteId","error","fetchExistingGuestCustomerToken","access_token","dwsid","clientId","shortCode","organisationId","authData","expires_in","isGuest","serverUrl","customerMail","endpoint","res","err","getSearchResults","query","token","basePath","host","getProductById","id","getInterestApi","customerId","customer_token","displayData","data","imageUrlArray","image","currencyFormatter","currencyCode","priceFormatter","_a","_b","_c","initialCapital","text","stringReducer","length","formatStringToHtml","str","line","index","numberedPoint","getIconsTree","names","icons","aliases","resolved","resolve","name","parent","value","defaultIconDimensions","defaultIconTransformations","defaultIconProps","defaultExtendedIconProps","mergeIconTransformations","obj1","obj2","result","rotate","mergeIconData","child","key","internalGetIconData","tree","currentProps","parse","name$1","parseIconSet","callback","item","optionalPropertyDefaults","checkOptionalProps","defaults","prop","quicklyValidateIconSet","obj","icon","dataStorage","newStorage","provider","prefix","getStorage","providerStorage","addIconSet","storage","addIconToStorage","matchIconName","stringToIcon","validate","allowSimpleName","colonSeparated","validateIconName","dashSeparated","simpleNames","allowSimpleNames","allow","getIconData","iconName","addIcon","addCollection","added","defaultIconSizeCustomisations","defaultIconCustomisations","unitsSplit","unitsTest","calculateSize","size","ratio","precision","oldParts","newParts","code","isNumber","num","splitSVGDefs","content","tag","defs","start","end","endEnd","mergeDefsAndContent","wrapSVGContent","body","split","isUnsetKeyword","iconToSVG","customisations","fullIcon","fullCustomisations","box","transformations","hFlip","vFlip","rotation","tempValue","customisationsWidth","customisationsHeight","boxWidth","boxHeight","width","height","attributes","setAttr","viewBox","regex","randomPrefix","counter","replaceIDs","ids","match","suffix","newID","escapedID","setAPIModule","getAPIModule","createAPIConfig","source","resources","configStorage","fallBackAPISources","fallBackAPI","addAPIProvider","customConfig","config","getAPIConfig","detectFetch","fetchModule","calculateMaxLength","maxHostLength","url","shouldAbort","status","prepare","results","maxLength","type","getPath","send","params","path","iconsList","urlParams","uri","defaultError","fetchAPIModule","removeCallback","storages","items","row","updateCallbacks","hasPending","oldLength","idCounter","storeCallback","pendingSources","abort","sortIcons","a","b","lastIcon","localStorage","list","listToIcons","defaultConfig","sendQuery","payload","done","resourcesCount","startIndex","nextIndex","startTime","queriesSent","lastError","timer","queue","doneCallbacks","resetTimer","subscribe","overwrite","getQueryStatus","failQuery","clearQueue","moduleResponse","isError","queued","execNext","resource","status$1","initRedundancy","cfg","queries","cleanup","queryCallback","doneCallback","query$1","find","emptyCallback$1","redundancyCache","getRedundancyCache","redundancy","cachedReundancy","sendAPIQuery","target","api","cached","moduleKey","emptyCallback","loadedNewIcons","checkIconNamesForAPI","valid","invalid","parseLoaderResponse","checkMissing","pending","parsePossiblyAsyncResponse","loadNewIcons","icons$1","customIconLoader","iconSet","loadIcons","cleanedIcons","sortedIcons","callCallback","newIcons","sources","lastProvider","lastPrefix","providerNewIcons","pendingQueue","mergeCustomisations","valueType","separator","flipFromString","custom","flip","rotateFromString","defaultValue","units","value$1","iconToHTML","renderAttribsHTML","attr","encodeSVGforURL","svg","svgToData","svgToURL","policy","createPolicy","s","cleanUpInnerHTML","html","defaultExtendedIconCustomisations","svgDefaults","commonProps","monotoneProps","coloredProps","propsToAdd","propsToAddTo","inlineDefaults","fixSize","render","defaultProps","mode","style","customStyle","componentProps","classNames","renderAttribs","localCounter","createElement","useMask","_window","preload","providers","IconComponent","mounted","setMounted","useState","setAbort","getInitialState","state","setState","changeState","newState","updateState","useEffect","Icon","forwardRef","ref","initialState","productSlice","createSlice","action","setProduct","useResponsiveProductsPerPage","getProductsPerPage","productsPerPage","setProductsPerPage","handleResize","ProductCarousel","product","dispatch","useDispatch","setStartIndex","nextProducts","prevIndex","prevProducts","getProduct","jsxs","jsx","prod","_d","ProductDisplay","chat","storeDetails","products","i","createBasket","addProductToBasket","fetchBasket","BASKET_ID_KEY","TOKEN_KEY","TOKEN_EXPIRY_KEY","EXPIRY_TIME","VERSION","setStoredBasketId","setStoredToken","expiryTime","ANIMATION_DURATION","ProductDisplayCard","useSelector","show","setShow","addToCart","toast","productData","_e","_f","customerData","basketIdFromCustomer","tokenExpiry","currentTime","authDetails","newExpiryTime","fetchBasketResponse","_i","_j","basketResponse","_k","_l","_m","_n","_o","_p","viewMore","Fragment","e","group","_","TanyaShoppingAssistantStream","shoppingOptions","payloadMapping","productName","useRef","productId","productImage","productPrice","setAuthDetails","searchParams","useSearchParams","isOpen","setIsOpen","isAnimating","setIsAnimating","isVisible","setIsVisible","adding","setAdding","isLoading","setIsLoading","productLoading","setProductLoading","inputText","setInputText","whom","setWhom","mapSnapshotToProduct","snap","chatHistory","setChatHistory","scrollRef","openPanel","closePanel","handleWhomSelection","selected","cachedToken","getJWTToken","tokenUrl","tokenPayload","tokenResponse","tokenData","expiresIn","getAuthDetails","getInterests","customer_id","runSecondaryFlow","productTitle","points","interests","prev","msg","idx","accessToken","user","isLoggedIn","invokeUrl","reader","decoder","buffer","lines","jsonData","parsedData","handleSendMessage","question","newQuery","sanitizedWhom","keywords","getKeywords","sanitizeKeywords","keywordMatch","sanitizedKeywords","keyword","splitedKeywords","first","priceVal","handleAddToCart","productToBeAdded","quantity","option","m"],"mappings":"2rBAOaA,GAAcC,GAAsB,CAC/C,MAAMC,EAAQ,IAAI,YAAY,mBAAoB,CAChD,OAAQ,CACN,YAAa,GACb,SAAAD,CAAA,CAGF,CACD,EACD,OAAO,cAAcC,CAAK,CAC5B,ECVA,SAASC,GAAQ,CACf,GAAGC,CACL,EAAuD,CACrD,aAAQC,GAAiB,KAAjB,CAAsB,YAAU,UAAW,GAAGD,EAAO,CAC/D,CAEA,SAASE,GAAe,CACtB,GAAGF,CACL,EAA0D,CACxD,aAAQC,GAAiB,QAAjB,CAAyB,YAAU,kBAAmB,GAAGD,EAAO,CAC1E,CCyGO,MAAMG,GAAY,KAOhB,CAAE,kBANiB,uFAME,QALZ,2CAKqB,UAHnB,wCAG8B,SAFU,QAEV,GC3HrCC,GAAoB,SAAY,CAC3C,MAAMC,EAAM,wCACZ,GAAI,CACF,MAAMC,EAAW,MAAMC,EAAM,KAC3B,GAAGF,CAAG,mCAAmCG,IAAS,WAAWC,GAAW,EAAA,EAE1E,OAAIH,EAAS,SAAW,KAAOA,EAAS,KAAK,aACpCA,EAA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EAGFL,EAAAA,IAAC,MAAA,CACC,MAAM,KACN,OAAO,KACP,QAAQ,YACR,KAAK,OACL,MAAM,6BAEN,SAAAA,EAAAA,IAAC,OAAA,CACC,EAAE,qpBACF,KAAK,SAAA,CAAA,CACP,CAAA,CACF,CAAA,CAEJ,EACF,CAAA,CAAA,EAEJ,CAAA,CAAA,CAAA,QAGDoB,GAAA,CAAA,CAAmB,CAAA,EACtB,CAAA,CAAA,CAAA,CAEF,EACF,CAAA,CAAA,CAEJ,CAAA,CACF,CAEJ","x_google_ignoreList":[8]}
|
|
1
|
+
{"version":3,"file":"tanya-chatbot.cjs.js","sources":["../src/components/lib/utils.ts","../src/components/ui/popover.tsx","../src/config/api.ts","../src/components/utils/fetchTokenBmGrant.ts","../src/components/utils/fetchExistingRegisterCustomerToken.ts","../src/sfcc-apis/session/index.ts","../src/components/utils/index.ts","../src/components/utils/helper.js","../node_modules/@iconify/react/dist/iconify.js","../src/store/reducers/productReducer.ts","../src/components/carousel/ProductCarousel.tsx","../src/components/carousel/ProductDisplay.tsx","../src/components/api/api.ts","../src/config/constant.ts","../src/components/utils/localStorage.ts","../src/components/product/ProductDisplayCard.tsx","../src/components/tanya-widget/tanya-shopping-assistent.tsx"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport const notifySFCC = (basketId?: string) => {\n const event = new CustomEvent(\"reactCartUpdated\", {\n detail: {\n cartUpdated: true,\n basketId,\n\n // any other data SFCC needs\n },\n });\n window.dispatchEvent(event);\n};\n","\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\r\n\r\nimport { cn } from \"../lib/utils\";\r\n\r\nfunction Popover({\r\n ...props\r\n}: React.ComponentProps<typeof PopoverPrimitive.Root>) {\r\n return <PopoverPrimitive.Root data-slot=\"popover\" {...props} />;\r\n}\r\n\r\nfunction PopoverTrigger({\r\n ...props\r\n}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {\r\n return <PopoverPrimitive.Trigger data-slot=\"popover-trigger\" {...props} />;\r\n}\r\n\r\nfunction PopoverContent({\r\n className,\r\n align = \"center\",\r\n sideOffset = 4,\r\n ...props\r\n}: React.ComponentProps<typeof PopoverPrimitive.Content>) {\r\n return (\r\n <PopoverPrimitive.Portal>\r\n <PopoverPrimitive.Content\r\n data-slot=\"popover-content\"\r\n align={align}\r\n sideOffset={sideOffset}\r\n className={cn(\r\n \"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden\",\r\n className\r\n )}\r\n {...props}\r\n />\r\n </PopoverPrimitive.Portal>\r\n );\r\n}\r\n\r\nfunction PopoverAnchor({\r\n ...props\r\n}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {\r\n return <PopoverPrimitive.Anchor data-slot=\"popover-anchor\" {...props} />;\r\n}\r\n\r\nexport { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };\r\n","function stringToUint8Array(str: string): Uint8Array {\n return new TextEncoder().encode(str);\n}\n\n// Helper function to convert ArrayBuffer to hex string\nfunction arrayBufferToHex(buffer: ArrayBuffer): string {\n const byteArray = new Uint8Array(buffer);\n const hexCodes = [...byteArray].map((value) => {\n const hexCode = value.toString(16);\n const paddedHexCode = hexCode.padStart(2, \"0\");\n return paddedHexCode;\n });\n return hexCodes.join(\"\");\n}\n\n// SHA256 hash using Web Crypto API\nasync function sha256(data: string): Promise<ArrayBuffer> {\n const encoder = new TextEncoder();\n return await crypto.subtle.digest(\"SHA-256\", encoder.encode(data));\n}\n\n// HMAC-SHA256 using Web Crypto API\nasync function hmacSha256(\n key: ArrayBuffer | Uint8Array,\n data: string\n): Promise<ArrayBuffer> {\n const cryptoKey = await crypto.subtle.importKey(\n \"raw\",\n key,\n { name: \"HMAC\", hash: \"SHA-256\" },\n false,\n [\"sign\"]\n );\n\n const encoder = new TextEncoder();\n return await crypto.subtle.sign(\"HMAC\", cryptoKey, encoder.encode(data));\n}\n\n// Get signing key\nasync function getSignatureKey(\n key: string,\n dateStamp: string,\n regionName: string,\n serviceName: string\n): Promise<ArrayBuffer> {\n const kDate = await hmacSha256(stringToUint8Array(\"AWS4\" + key), dateStamp);\n const kRegion = await hmacSha256(kDate, regionName);\n const kService = await hmacSha256(kRegion, serviceName);\n const kSigning = await hmacSha256(kService, \"aws4_request\");\n return kSigning;\n}\n\nexport async function createSignedHeaders(\n url: string,\n method: string,\n payload: string,\n accessKeyId: string,\n secretAccessKey: string,\n region: string,\n service: string\n): Promise<Record<string, string>> {\n const urlObj = new URL(url);\n const host = urlObj.hostname;\n const pathname = urlObj.pathname;\n const search = urlObj.search;\n\n const now = new Date();\n const amzDate = now.toISOString().replace(/[:\\-]|\\.\\d{3}/g, \"\");\n const dateStamp = amzDate.substring(0, 8);\n const payloadHash = arrayBufferToHex(await sha256(payload));\n const contentLength = new TextEncoder().encode(payload).length.toString();\n\n const canonicalHeaders =\n `content-length:${contentLength}\\n` +\n `content-type:application/json\\n` +\n `host:${host}\\n` +\n `x-amz-content-sha256:${payloadHash}\\n` +\n `x-amz-date:${amzDate}\\n`;\n\n const signedHeaders =\n \"content-length;content-type;host;x-amz-content-sha256;x-amz-date\";\n\n const canonicalRequest = [\n method,\n pathname,\n search.slice(1),\n canonicalHeaders,\n signedHeaders,\n payloadHash,\n ].join(\"\\n\");\n\n const algorithm = \"AWS4-HMAC-SHA256\";\n const credentialScope = `${dateStamp}/${region}/${service}/aws4_request`;\n const stringToSign = [\n algorithm,\n amzDate,\n credentialScope,\n arrayBufferToHex(await sha256(canonicalRequest)),\n ].join(\"\\n\");\n\n const signingKey = await getSignatureKey(\n secretAccessKey,\n dateStamp,\n region,\n service\n );\n\n const signature = arrayBufferToHex(\n await hmacSha256(signingKey, stringToSign)\n );\n\n const authorizationHeader = `${algorithm} Credential=${accessKeyId}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`;\n\n return {\n \"Content-Type\": \"application/json\",\n \"Content-Length\": contentLength,\n \"X-Amz-Content-Sha256\": payloadHash,\n \"X-Amz-Date\": amzDate,\n Authorization: authorizationHeader,\n };\n}\n\nexport const apiConfig = () => {\n const aiConversationUrl = `https://mdv3qwfi2j.execute-api.us-east-1.amazonaws.com/dev/api/bedrock/invoke/stream`;\n const xAPIKey = \"BJBtjpPkqGatuoa3qJqdR8aHXSsHkgvGaootbubi\";\n // const serverUrl = \"https://tanya-sfcc-server.vercel.app/\";\n const serverUrl = import.meta.env.VITE_SERVER_BASE_URL;\n const basePath = import.meta.env.VITE_SCAPI_ENVIRONMENT ? \"sc-api\" : \"api\";\n\n return { aiConversationUrl, xAPIKey, serverUrl, basePath };\n};\n","import axios from \"axios\";\r\nimport { getHost, getSiteId } from \".\";\r\n\r\n// email:password:client need to be pass in encrypt form in the auth of fetchTokenBmGrant\r\n\r\n// email:password:client is different from user to user\r\nexport const fetchTokenBmGrant = async () => {\r\n const URL = `${import.meta.env.VITE_SERVER_BASE_URL}`;\r\n try {\r\n const response = await axios.post(\r\n `${URL}api/auth/token-bm-grant?baseUrl=${getHost()}&siteId=${getSiteId()}`\r\n );\r\n if (response.status === 200 && response.data.access_token) {\r\n return response.data.access_token;\r\n } else {\r\n console.error(\"Failed to fetch token:\", response.data);\r\n return null;\r\n }\r\n } catch (error) {\r\n if (axios.isAxiosError(error)) {\r\n console.error(\"Error fetching token:\", error.response || error.message);\r\n } else {\r\n console.error(\"Unexpected error:\", error);\r\n }\r\n return null;\r\n }\r\n};\r\n","import axios from \"axios\";\r\nimport { clientId, getHost, getSiteId, organisationId, shortCode } from \".\";\r\n\r\ninterface Customer {\r\n access_token: string;\r\n customerId: string;\r\n}\r\n\r\n// function getCookie(name: string): string | null {\r\n// const value = `; ${document.cookie}`;\r\n// console.log(\"parts\", value,value.includes(\"dwsid\"));\r\n// const parts = value.split(`; ${name}=`);\r\n// if (parts.length === 2) return parts.pop()?.split(\";\").shift() || null;\r\n// return null;\r\n// }\r\n\r\nexport const fetchExistingRegisterCustomerToken = async ({\r\n access_token,\r\n customerId,\r\n}: Customer) => {\r\n const URL = `${import.meta.env.VITE_SERVER_BASE_URL}`;\r\n try {\r\n const response = await axios.post(\r\n `${URL}api/auth/token-existing-register-customer/${customerId}?baseUrl=${getHost()}&siteId=${getSiteId()}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}`,\r\n {},\r\n {\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n Authorization: `Bearer ${access_token}`,\r\n },\r\n }\r\n );\r\n\r\n if (response.status === 200 && response.data) {\r\n // console.log(\"customer token res fe\", response.data)\r\n return response.data;\r\n }\r\n return null;\r\n } catch (error) {\r\n if (axios.isAxiosError(error)) {\r\n console.error(\"Error creating basket:\", error.response || error.message);\r\n } else {\r\n console.error(\"Unexpected error:\", error);\r\n }\r\n return null;\r\n }\r\n};\r\n\r\nexport const fetchExistingGuestCustomerToken = async (\r\n access_token: string,\r\n) => {\r\n const URL = `${import.meta.env.VITE_SERVER_BASE_URL}`;\r\n try {\r\n const dwsid = JSON.parse(sessionStorage.getItem(\"customerData\")|| \"{}\").dwsid // fetch cookie\r\n\r\n const response = await axios.post(\r\n `${URL}api/auth/token-existing-guest-customer?dwsid=${dwsid}&baseUrl=${getHost()}&siteId=${getSiteId()}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}`,\r\n {},\r\n {\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n Authorization: `Bearer ${access_token}`,\r\n },\r\n }\r\n );\r\n\r\n if (response.status === 200 && response.data) {\r\n return response.data;\r\n }\r\n return null;\r\n } catch (error) {\r\n if (axios.isAxiosError(error)) {\r\n console.error(\"Error creating basket:\", error.response || error.message);\r\n } else {\r\n console.error(\"Unexpected error:\", error);\r\n }\r\n return null;\r\n }\r\n};\r\n","import axios from \"axios\";\nimport { apiConfig } from \"../../config/api\";\nimport { clientId, getSiteId, organisationId, shortCode } from \"../../components/utils\";\n\nexport async function authData() {\n if (!import.meta.env.VITE_SCAPI_ENVIRONMENT) {\n return \"\";\n }\n const expires_in = localStorage.getItem(\"expires_in\");\n const access_token = localStorage.getItem(\"access_token\");\n const isGuest = JSON.parse(\n sessionStorage.getItem(\"customerData\") || \"{}\"\n ).isGuest;\n if (\n expires_in &&\n access_token &&\n new Date().getTime() < parseInt(expires_in) &&\n isGuest === JSON.parse(localStorage.getItem(\"isGuest\") || \"false\")\n ) {\n console.log(\"access token found in local storage\");\n return { access_token, expires_in };\n }\n const { serverUrl } = apiConfig();\n const dwsid = JSON.parse(\n sessionStorage.getItem(\"customerData\") || \"{}\"\n ).dwsid;\n\n const customerMail = JSON.parse(\n sessionStorage.getItem(\"customerData\") || \"{}\"\n ).usrRef;\n\n try {\n const endpoint = isGuest ? \"unregister-auth\" : \"register-auth\";\n const res = await axios.get(\n `${serverUrl}sc-api/${endpoint}?dwsid=${dwsid}&email=${customerMail}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}&siteId=${getSiteId()}`\n );\n localStorage.setItem(\"access_token\", res.data.access_token);\n localStorage.setItem(\n \"expires_in\",\n String(new Date().getTime() + res.data.expires_in * 1000)\n );\n localStorage.setItem(\"isGuest\", isGuest.toString());\n console.log(res.data);\n return res.data;\n } catch (err) {\n console.log(err);\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport axios from \"axios\";\nimport { apiConfig } from \"../../config/api\";\nimport { fetchTokenBmGrant } from \"./fetchTokenBmGrant\";\nimport { fetchExistingGuestCustomerToken } from \"./fetchExistingRegisterCustomerToken\";\nimport { authData } from \"../../sfcc-apis/session\";\n\nexport const getHost = () => {\n const host = sessionStorage.getItem(\"Host\");\n return host;\n};\n\nexport const getSiteId = () => {\n const siteId = sessionStorage.getItem(\"SiteId\");\n return siteId;\n};\n\nexport const clientId = () => {\n const clientId = sessionStorage.getItem(\"pubCfg\");\n return clientId;\n};\n\nexport const shortCode = () => {\n const shortCode = sessionStorage.getItem(\"envRef\");\n return shortCode;\n};\n\nexport const organisationId = () => {\n const orgRef = sessionStorage.getItem(\"orgRef\");\n return orgRef;\n};\n\nexport const getSearchResults = async (query: string, token: string) => {\n const { serverUrl, basePath } = apiConfig();\n\n try {\n const host = getHost();\n const response = await axios.get(\n `${serverUrl}${basePath}/search-sfcc?baseUrl=${host}&query=${query}&siteId=${getSiteId()}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}`,\n {\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${token}`,\n },\n }\n );\n\n return response.data.hits;\n } catch (error) {\n console.error(\"Error fetching search results:\", error);\n throw error;\n }\n};\n\nexport const getProductById = async (id: number | string) => {\n if (!id) throw new Error(\"Product ID is required\");\n const { serverUrl, basePath } = apiConfig();\n const host = getHost();\n console.log(\"calling access\");\n const { access_token } = await authData();\n console.log(access_token);\n const response = await axios.get(\n `${serverUrl}${basePath}/product-sfcc/${id}?baseUrl=${host}&siteId=${getSiteId()}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}`,\n {\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${access_token}`,\n },\n }\n );\n\n return response.data;\n};\n\nexport const getInterestApi = async (customerId: any) => {\n if (!customerId) throw new Error(\"customerId is required\");\n const access_token = await fetchTokenBmGrant();\n\n const { customer_token } = await fetchExistingGuestCustomerToken(\n access_token\n );\n const { serverUrl, basePath } = apiConfig();\n const data = await authData();\n const token = data.access_token;\n\n const response = await axios.get(\n `${serverUrl}${basePath}/get-interest?baseUrl=${getHost()}&customerId=${customerId}&siteId=${getSiteId()}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}`,\n {\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: import.meta.env.VITE_SCAPI_ENVIRONMENT\n ? `Bearer ${token}`\n : `${customer_token}`,\n },\n }\n );\n\n return response.data;\n};\n","import CryptoJS from \"crypto-js\";\nconst SECRET_KEY = \"admin_one\";\nexport const displayData = (data) => {\n if (typeof data === \"string\") {\n return String(data);\n }\n return String(data[\"en-US\"] || data);\n};\nexport const imageUrlArray = (data) => {\n if (data?.image) {\n return [data.image];\n }\n else if (\"variants\" in data) {\n return data.variants[0].images;\n }\n return data.masterVariant.images.map((image) => image.url);\n};\nexport const currencyFormatter = (data, currencyCode) => {\n return data.toLocaleString(\"en-US\", {\n style: \"currency\",\n currency: currencyCode || \"USD\",\n });\n};\nexport const priceFormatter = (data) => {\n if (\"variants\" in data) {\n return {\n centAmount: data.variants[0]?.prices.EUR.max,\n currencyCode: \"DOL\",\n };\n }\n return {\n centAmount: data.masterVariant?.prices[0].value.centAmount,\n currencyCode: data.masterVariant?.prices[0].value.currencyCode,\n };\n};\nexport const encryptData = (data) => {\n return CryptoJS.AES.encrypt(JSON.stringify(data), SECRET_KEY).toString();\n};\nexport const decryptData = (cipherText) => {\n const bytes = CryptoJS.AES.decrypt(cipherText, SECRET_KEY);\n return JSON.parse(bytes.toString(CryptoJS.enc.Utf8));\n};\nexport const initialCapital = (text) => {\n return text.charAt(0).toUpperCase() + text.slice(1);\n};\nexport const laterDate = (day) => {\n const fiveDaysLater = new Date();\n fiveDaysLater.setDate(fiveDaysLater.getDate() + day);\n const formattedDate = fiveDaysLater.toLocaleDateString(\"en-US\", {\n day: \"numeric\",\n month: \"long\",\n });\n return formattedDate;\n};\nexport const stringReducer = (text, length) => {\n return text.length < length ? text : text.slice(0, length) + \"...\";\n};\nexport const formatStringToHtml = (str) => {\n return str\n .split(\"\\\\n\")\n .map((line, index) => {\n const numberedPoint = line.match(/^(\\d+)\\.\\s(.+)/);\n if (numberedPoint) {\n return `<p key=${index} class=\"mb-2\"><strong>${numberedPoint[1]}.</strong> ${numberedPoint[2]}</p>`;\n }\n return line.trim() ? `<p key=${index} class=\"mb-2\">${line}</p>` : \"<br/>\";\n })\n .join(\"\");\n};\n","'use client';\n\nimport { createElement, forwardRef, useState, useEffect } from 'react';\n\n/**\n* Resolve icon set icons\n*\n* Returns parent icon for each icon\n*/\nfunction getIconsTree(data, names) {\n\tconst icons = data.icons;\n\tconst aliases = data.aliases || Object.create(null);\n\tconst resolved = Object.create(null);\n\tfunction resolve(name) {\n\t\tif (icons[name]) return resolved[name] = [];\n\t\tif (!(name in resolved)) {\n\t\t\tresolved[name] = null;\n\t\t\tconst parent = aliases[name] && aliases[name].parent;\n\t\t\tconst value = parent && resolve(parent);\n\t\t\tif (value) resolved[name] = [parent].concat(value);\n\t\t}\n\t\treturn resolved[name];\n\t}\n\t(Object.keys(icons).concat(Object.keys(aliases))).forEach(resolve);\n\treturn resolved;\n}\n\n/**\n* Default values for dimensions\n*/\nconst defaultIconDimensions = Object.freeze({\n\tleft: 0,\n\ttop: 0,\n\twidth: 16,\n\theight: 16\n});\n/**\n* Default values for transformations\n*/\nconst defaultIconTransformations = Object.freeze({\n\trotate: 0,\n\tvFlip: false,\n\thFlip: false\n});\n/**\n* Default values for all optional IconifyIcon properties\n*/\nconst defaultIconProps = Object.freeze({\n\t...defaultIconDimensions,\n\t...defaultIconTransformations\n});\n/**\n* Default values for all properties used in ExtendedIconifyIcon\n*/\nconst defaultExtendedIconProps = Object.freeze({\n\t...defaultIconProps,\n\tbody: \"\",\n\thidden: false\n});\n\n/**\n* Merge transformations\n*/\nfunction mergeIconTransformations(obj1, obj2) {\n\tconst result = {};\n\tif (!obj1.hFlip !== !obj2.hFlip) result.hFlip = true;\n\tif (!obj1.vFlip !== !obj2.vFlip) result.vFlip = true;\n\tconst rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;\n\tif (rotate) result.rotate = rotate;\n\treturn result;\n}\n\n/**\n* Merge icon and alias\n*\n* Can also be used to merge default values and icon\n*/\nfunction mergeIconData(parent, child) {\n\tconst result = mergeIconTransformations(parent, child);\n\tfor (const key in defaultExtendedIconProps) if (key in defaultIconTransformations) {\n\t\tif (key in parent && !(key in result)) result[key] = defaultIconTransformations[key];\n\t} else if (key in child) result[key] = child[key];\n\telse if (key in parent) result[key] = parent[key];\n\treturn result;\n}\n\n/**\n* Get icon data, using prepared aliases tree\n*/\nfunction internalGetIconData(data, name, tree) {\n\tconst icons = data.icons;\n\tconst aliases = data.aliases || Object.create(null);\n\tlet currentProps = {};\n\tfunction parse(name$1) {\n\t\tcurrentProps = mergeIconData(icons[name$1] || aliases[name$1], currentProps);\n\t}\n\tparse(name);\n\ttree.forEach(parse);\n\treturn mergeIconData(data, currentProps);\n}\n\n/**\n* Extract icons from an icon set\n*\n* Returns list of icons that were found in icon set\n*/\nfunction parseIconSet(data, callback) {\n\tconst names = [];\n\tif (typeof data !== \"object\" || typeof data.icons !== \"object\") return names;\n\tif (data.not_found instanceof Array) data.not_found.forEach((name) => {\n\t\tcallback(name, null);\n\t\tnames.push(name);\n\t});\n\tconst tree = getIconsTree(data);\n\tfor (const name in tree) {\n\t\tconst item = tree[name];\n\t\tif (item) {\n\t\t\tcallback(name, internalGetIconData(data, name, item));\n\t\t\tnames.push(name);\n\t\t}\n\t}\n\treturn names;\n}\n\n/**\n* Optional properties\n*/\nconst optionalPropertyDefaults = {\n\tprovider: \"\",\n\taliases: {},\n\tnot_found: {},\n\t...defaultIconDimensions\n};\n/**\n* Check props\n*/\nfunction checkOptionalProps(item, defaults) {\n\tfor (const prop in defaults) if (prop in item && typeof item[prop] !== typeof defaults[prop]) return false;\n\treturn true;\n}\n/**\n* Validate icon set, return it as IconifyJSON on success, null on failure\n*\n* Unlike validateIconSet(), this function is very basic.\n* It does not throw exceptions, it does not check metadata, it does not fix stuff.\n*/\nfunction quicklyValidateIconSet(obj) {\n\tif (typeof obj !== \"object\" || obj === null) return null;\n\tconst data = obj;\n\tif (typeof data.prefix !== \"string\" || !obj.icons || typeof obj.icons !== \"object\") return null;\n\tif (!checkOptionalProps(obj, optionalPropertyDefaults)) return null;\n\tconst icons = data.icons;\n\tfor (const name in icons) {\n\t\tconst icon = icons[name];\n\t\tif (!name || typeof icon.body !== \"string\" || !checkOptionalProps(icon, defaultExtendedIconProps)) return null;\n\t}\n\tconst aliases = data.aliases || Object.create(null);\n\tfor (const name in aliases) {\n\t\tconst icon = aliases[name];\n\t\tconst parent = icon.parent;\n\t\tif (!name || typeof parent !== \"string\" || !icons[parent] && !aliases[parent] || !checkOptionalProps(icon, defaultExtendedIconProps)) return null;\n\t}\n\treturn data;\n}\n\n/**\n* Storage by provider and prefix\n*/\nconst dataStorage = Object.create(null);\n/**\n* Create new storage\n*/\nfunction newStorage(provider, prefix) {\n\treturn {\n\t\tprovider,\n\t\tprefix,\n\t\ticons: Object.create(null),\n\t\tmissing: /* @__PURE__ */ new Set()\n\t};\n}\n/**\n* Get storage for provider and prefix\n*/\nfunction getStorage(provider, prefix) {\n\tconst providerStorage = dataStorage[provider] || (dataStorage[provider] = Object.create(null));\n\treturn providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));\n}\n/**\n* Add icon set to storage\n*\n* Returns array of added icons\n*/\nfunction addIconSet(storage, data) {\n\tif (!quicklyValidateIconSet(data)) return [];\n\treturn parseIconSet(data, (name, icon) => {\n\t\tif (icon) storage.icons[name] = icon;\n\t\telse storage.missing.add(name);\n\t});\n}\n/**\n* Add icon to storage\n*/\nfunction addIconToStorage(storage, name, icon) {\n\ttry {\n\t\tif (typeof icon.body === \"string\") {\n\t\t\tstorage.icons[name] = { ...icon };\n\t\t\treturn true;\n\t\t}\n\t} catch (err) {}\n\treturn false;\n}\n/**\n* List available icons\n*/\nfunction listIcons(provider, prefix) {\n\tlet allIcons = [];\n\tconst providers = typeof provider === \"string\" ? [provider] : Object.keys(dataStorage);\n\tproviders.forEach((provider$1) => {\n\t\tconst prefixes = typeof provider$1 === \"string\" && typeof prefix === \"string\" ? [prefix] : Object.keys(dataStorage[provider$1] || {});\n\t\tprefixes.forEach((prefix$1) => {\n\t\t\tconst storage = getStorage(provider$1, prefix$1);\n\t\t\tallIcons = allIcons.concat(Object.keys(storage.icons).map((name) => (provider$1 !== \"\" ? \"@\" + provider$1 + \":\" : \"\") + prefix$1 + \":\" + name));\n\t\t});\n\t});\n\treturn allIcons;\n}\n\n/**\n* Expression to test part of icon name.\n*\n* Used when loading icons from Iconify API due to project naming convension.\n* Ignored when using custom icon sets - convension does not apply.\n*/\nconst matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;\n/**\n* Convert string icon name to IconifyIconName object.\n*/\nconst stringToIcon = (value, validate, allowSimpleName, provider = \"\") => {\n\tconst colonSeparated = value.split(\":\");\n\tif (value.slice(0, 1) === \"@\") {\n\t\tif (colonSeparated.length < 2 || colonSeparated.length > 3) return null;\n\t\tprovider = colonSeparated.shift().slice(1);\n\t}\n\tif (colonSeparated.length > 3 || !colonSeparated.length) return null;\n\tif (colonSeparated.length > 1) {\n\t\tconst name$1 = colonSeparated.pop();\n\t\tconst prefix = colonSeparated.pop();\n\t\tconst result = {\n\t\t\tprovider: colonSeparated.length > 0 ? colonSeparated[0] : provider,\n\t\t\tprefix,\n\t\t\tname: name$1\n\t\t};\n\t\treturn validate && !validateIconName(result) ? null : result;\n\t}\n\tconst name = colonSeparated[0];\n\tconst dashSeparated = name.split(\"-\");\n\tif (dashSeparated.length > 1) {\n\t\tconst result = {\n\t\t\tprovider,\n\t\t\tprefix: dashSeparated.shift(),\n\t\t\tname: dashSeparated.join(\"-\")\n\t\t};\n\t\treturn validate && !validateIconName(result) ? null : result;\n\t}\n\tif (allowSimpleName && provider === \"\") {\n\t\tconst result = {\n\t\t\tprovider,\n\t\t\tprefix: \"\",\n\t\t\tname\n\t\t};\n\t\treturn validate && !validateIconName(result, allowSimpleName) ? null : result;\n\t}\n\treturn null;\n};\n/**\n* Check if icon is valid.\n*\n* This function is not part of stringToIcon because validation is not needed for most code.\n*/\nconst validateIconName = (icon, allowSimpleName) => {\n\tif (!icon) return false;\n\treturn !!((allowSimpleName && icon.prefix === \"\" || !!icon.prefix) && !!icon.name);\n};\n\n/**\n* Allow storing icons without provider or prefix, making it possible to store icons like \"home\"\n*/\nlet simpleNames = false;\nfunction allowSimpleNames(allow) {\n\tif (typeof allow === \"boolean\") simpleNames = allow;\n\treturn simpleNames;\n}\n/**\n* Get icon data\n*\n* Returns:\n* - IconifyIcon on success, object directly from storage so don't modify it\n* - null if icon is marked as missing (returned in `not_found` property from API, so don't bother sending API requests)\n* - undefined if icon is missing in storage\n*/\nfunction getIconData(name) {\n\tconst icon = typeof name === \"string\" ? stringToIcon(name, true, simpleNames) : name;\n\tif (icon) {\n\t\tconst storage = getStorage(icon.provider, icon.prefix);\n\t\tconst iconName = icon.name;\n\t\treturn storage.icons[iconName] || (storage.missing.has(iconName) ? null : void 0);\n\t}\n}\n/**\n* Add one icon\n*/\nfunction addIcon(name, data) {\n\tconst icon = stringToIcon(name, true, simpleNames);\n\tif (!icon) return false;\n\tconst storage = getStorage(icon.provider, icon.prefix);\n\tif (data) return addIconToStorage(storage, icon.name, data);\n\telse {\n\t\tstorage.missing.add(icon.name);\n\t\treturn true;\n\t}\n}\n/**\n* Add icon set\n*/\nfunction addCollection(data, provider) {\n\tif (typeof data !== \"object\") return false;\n\tif (typeof provider !== \"string\") provider = data.provider || \"\";\n\tif (simpleNames && !provider && !data.prefix) {\n\t\tlet added = false;\n\t\tif (quicklyValidateIconSet(data)) {\n\t\t\tdata.prefix = \"\";\n\t\t\tparseIconSet(data, (name, icon) => {\n\t\t\t\tif (addIcon(name, icon)) added = true;\n\t\t\t});\n\t\t}\n\t\treturn added;\n\t}\n\tconst prefix = data.prefix;\n\tif (!validateIconName({\n\t\tprefix,\n\t\tname: \"a\"\n\t})) return false;\n\tconst storage = getStorage(provider, prefix);\n\treturn !!addIconSet(storage, data);\n}\n/**\n* Check if icon data is available\n*/\nfunction iconLoaded(name) {\n\treturn !!getIconData(name);\n}\n/**\n* Get full icon\n*/\nfunction getIcon(name) {\n\tconst result = getIconData(name);\n\treturn result ? {\n\t\t...defaultIconProps,\n\t\t...result\n\t} : result;\n}\n\n/**\n* Default icon customisations values\n*/\nconst defaultIconSizeCustomisations = Object.freeze({\n\twidth: null,\n\theight: null\n});\nconst defaultIconCustomisations = Object.freeze({\n\t...defaultIconSizeCustomisations,\n\t...defaultIconTransformations\n});\n\n/**\n* Regular expressions for calculating dimensions\n*/\nconst unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;\nconst unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;\nfunction calculateSize(size, ratio, precision) {\n\tif (ratio === 1) return size;\n\tprecision = precision || 100;\n\tif (typeof size === \"number\") return Math.ceil(size * ratio * precision) / precision;\n\tif (typeof size !== \"string\") return size;\n\tconst oldParts = size.split(unitsSplit);\n\tif (oldParts === null || !oldParts.length) return size;\n\tconst newParts = [];\n\tlet code = oldParts.shift();\n\tlet isNumber = unitsTest.test(code);\n\twhile (true) {\n\t\tif (isNumber) {\n\t\t\tconst num = parseFloat(code);\n\t\t\tif (isNaN(num)) newParts.push(code);\n\t\t\telse newParts.push(Math.ceil(num * ratio * precision) / precision);\n\t\t} else newParts.push(code);\n\t\tcode = oldParts.shift();\n\t\tif (code === void 0) return newParts.join(\"\");\n\t\tisNumber = !isNumber;\n\t}\n}\n\nfunction splitSVGDefs(content, tag = \"defs\") {\n\tlet defs = \"\";\n\tconst index = content.indexOf(\"<\" + tag);\n\twhile (index >= 0) {\n\t\tconst start = content.indexOf(\">\", index);\n\t\tconst end = content.indexOf(\"</\" + tag);\n\t\tif (start === -1 || end === -1) break;\n\t\tconst endEnd = content.indexOf(\">\", end);\n\t\tif (endEnd === -1) break;\n\t\tdefs += content.slice(start + 1, end).trim();\n\t\tcontent = content.slice(0, index).trim() + content.slice(endEnd + 1);\n\t}\n\treturn {\n\t\tdefs,\n\t\tcontent\n\t};\n}\n/**\n* Merge defs and content\n*/\nfunction mergeDefsAndContent(defs, content) {\n\treturn defs ? \"<defs>\" + defs + \"</defs>\" + content : content;\n}\n/**\n* Wrap SVG content, without wrapping definitions\n*/\nfunction wrapSVGContent(body, start, end) {\n\tconst split = splitSVGDefs(body);\n\treturn mergeDefsAndContent(split.defs, start + split.content + end);\n}\n\n/**\n* Check if value should be unset. Allows multiple keywords\n*/\nconst isUnsetKeyword = (value) => value === \"unset\" || value === \"undefined\" || value === \"none\";\n/**\n* Get SVG attributes and content from icon + customisations\n*\n* Does not generate style to make it compatible with frameworks that use objects for style, such as React.\n* Instead, it generates 'inline' value. If true, rendering engine should add verticalAlign: -0.125em to icon.\n*\n* Customisations should be normalised by platform specific parser.\n* Result should be converted to <svg> by platform specific parser.\n* Use replaceIDs to generate unique IDs for body.\n*/\nfunction iconToSVG(icon, customisations) {\n\tconst fullIcon = {\n\t\t...defaultIconProps,\n\t\t...icon\n\t};\n\tconst fullCustomisations = {\n\t\t...defaultIconCustomisations,\n\t\t...customisations\n\t};\n\tconst box = {\n\t\tleft: fullIcon.left,\n\t\ttop: fullIcon.top,\n\t\twidth: fullIcon.width,\n\t\theight: fullIcon.height\n\t};\n\tlet body = fullIcon.body;\n\t[fullIcon, fullCustomisations].forEach((props) => {\n\t\tconst transformations = [];\n\t\tconst hFlip = props.hFlip;\n\t\tconst vFlip = props.vFlip;\n\t\tlet rotation = props.rotate;\n\t\tif (hFlip) if (vFlip) rotation += 2;\n\t\telse {\n\t\t\ttransformations.push(\"translate(\" + (box.width + box.left).toString() + \" \" + (0 - box.top).toString() + \")\");\n\t\t\ttransformations.push(\"scale(-1 1)\");\n\t\t\tbox.top = box.left = 0;\n\t\t}\n\t\telse if (vFlip) {\n\t\t\ttransformations.push(\"translate(\" + (0 - box.left).toString() + \" \" + (box.height + box.top).toString() + \")\");\n\t\t\ttransformations.push(\"scale(1 -1)\");\n\t\t\tbox.top = box.left = 0;\n\t\t}\n\t\tlet tempValue;\n\t\tif (rotation < 0) rotation -= Math.floor(rotation / 4) * 4;\n\t\trotation = rotation % 4;\n\t\tswitch (rotation) {\n\t\t\tcase 1:\n\t\t\t\ttempValue = box.height / 2 + box.top;\n\t\t\t\ttransformations.unshift(\"rotate(90 \" + tempValue.toString() + \" \" + tempValue.toString() + \")\");\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\ttransformations.unshift(\"rotate(180 \" + (box.width / 2 + box.left).toString() + \" \" + (box.height / 2 + box.top).toString() + \")\");\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\ttempValue = box.width / 2 + box.left;\n\t\t\t\ttransformations.unshift(\"rotate(-90 \" + tempValue.toString() + \" \" + tempValue.toString() + \")\");\n\t\t\t\tbreak;\n\t\t}\n\t\tif (rotation % 2 === 1) {\n\t\t\tif (box.left !== box.top) {\n\t\t\t\ttempValue = box.left;\n\t\t\t\tbox.left = box.top;\n\t\t\t\tbox.top = tempValue;\n\t\t\t}\n\t\t\tif (box.width !== box.height) {\n\t\t\t\ttempValue = box.width;\n\t\t\t\tbox.width = box.height;\n\t\t\t\tbox.height = tempValue;\n\t\t\t}\n\t\t}\n\t\tif (transformations.length) body = wrapSVGContent(body, \"<g transform=\\\"\" + transformations.join(\" \") + \"\\\">\", \"</g>\");\n\t});\n\tconst customisationsWidth = fullCustomisations.width;\n\tconst customisationsHeight = fullCustomisations.height;\n\tconst boxWidth = box.width;\n\tconst boxHeight = box.height;\n\tlet width;\n\tlet height;\n\tif (customisationsWidth === null) {\n\t\theight = customisationsHeight === null ? \"1em\" : customisationsHeight === \"auto\" ? boxHeight : customisationsHeight;\n\t\twidth = calculateSize(height, boxWidth / boxHeight);\n\t} else {\n\t\twidth = customisationsWidth === \"auto\" ? boxWidth : customisationsWidth;\n\t\theight = customisationsHeight === null ? calculateSize(width, boxHeight / boxWidth) : customisationsHeight === \"auto\" ? boxHeight : customisationsHeight;\n\t}\n\tconst attributes = {};\n\tconst setAttr = (prop, value) => {\n\t\tif (!isUnsetKeyword(value)) attributes[prop] = value.toString();\n\t};\n\tsetAttr(\"width\", width);\n\tsetAttr(\"height\", height);\n\tconst viewBox = [\n\t\tbox.left,\n\t\tbox.top,\n\t\tboxWidth,\n\t\tboxHeight\n\t];\n\tattributes.viewBox = viewBox.join(\" \");\n\treturn {\n\t\tattributes,\n\t\tviewBox,\n\t\tbody\n\t};\n}\n\n/**\n* IDs usage:\n*\n* id=\"{id}\"\n* xlink:href=\"#{id}\"\n* url(#{id})\n*\n* From SVG animations:\n*\n* begin=\"0;{id}.end\"\n* begin=\"{id}.end\"\n* begin=\"{id}.click\"\n*/\n/**\n* Regular expression for finding ids\n*/\nconst regex = /\\sid=\"(\\S+)\"/g;\n/**\n* New random-ish prefix for ids\n*\n* Do not use dash, it cannot be used in SVG 2 animations\n*/\nconst randomPrefix = \"IconifyId\" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16);\n/**\n* Counter for ids, increasing with every replacement\n*/\nlet counter = 0;\n/**\n* Replace IDs in SVG output with unique IDs\n*/\nfunction replaceIDs(body, prefix = randomPrefix) {\n\tconst ids = [];\n\tlet match;\n\twhile (match = regex.exec(body)) ids.push(match[1]);\n\tif (!ids.length) return body;\n\tconst suffix = \"suffix\" + (Math.random() * 16777216 | Date.now()).toString(16);\n\tids.forEach((id) => {\n\t\tconst newID = typeof prefix === \"function\" ? prefix(id) : prefix + (counter++).toString();\n\t\tconst escapedID = id.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t\tbody = body.replace(new RegExp(\"([#;\\\"])(\" + escapedID + \")([\\\")]|\\\\.[a-z])\", \"g\"), \"$1\" + newID + suffix + \"$3\");\n\t});\n\tbody = body.replace(new RegExp(suffix, \"g\"), \"\");\n\treturn body;\n}\n\n/**\n* Local storate types and entries\n*/\nconst storage = Object.create(null);\n/**\n* Set API module\n*/\nfunction setAPIModule(provider, item) {\n\tstorage[provider] = item;\n}\n/**\n* Get API module\n*/\nfunction getAPIModule(provider) {\n\treturn storage[provider] || storage[\"\"];\n}\n\n/**\n* Create full API configuration from partial data\n*/\nfunction createAPIConfig(source) {\n\tlet resources;\n\tif (typeof source.resources === \"string\") resources = [source.resources];\n\telse {\n\t\tresources = source.resources;\n\t\tif (!(resources instanceof Array) || !resources.length) return null;\n\t}\n\tconst result = {\n\t\tresources,\n\t\tpath: source.path || \"/\",\n\t\tmaxURL: source.maxURL || 500,\n\t\trotate: source.rotate || 750,\n\t\ttimeout: source.timeout || 5e3,\n\t\trandom: source.random === true,\n\t\tindex: source.index || 0,\n\t\tdataAfterTimeout: source.dataAfterTimeout !== false\n\t};\n\treturn result;\n}\n/**\n* Local storage\n*/\nconst configStorage = Object.create(null);\n/**\n* Redundancy for API servers.\n*\n* API should have very high uptime because of implemented redundancy at server level, but\n* sometimes bad things happen. On internet 100% uptime is not possible.\n*\n* There could be routing problems. Server might go down for whatever reason, but it takes\n* few minutes to detect that downtime, so during those few minutes API might not be accessible.\n*\n* This script has some redundancy to mitigate possible network issues.\n*\n* If one host cannot be reached in 'rotate' (750 by default) ms, script will try to retrieve\n* data from different host. Hosts have different configurations, pointing to different\n* API servers hosted at different providers.\n*/\nconst fallBackAPISources = [\"https://api.simplesvg.com\", \"https://api.unisvg.com\"];\nconst fallBackAPI = [];\nwhile (fallBackAPISources.length > 0) if (fallBackAPISources.length === 1) fallBackAPI.push(fallBackAPISources.shift());\nelse if (Math.random() > .5) fallBackAPI.push(fallBackAPISources.shift());\nelse fallBackAPI.push(fallBackAPISources.pop());\nconfigStorage[\"\"] = createAPIConfig({ resources: [\"https://api.iconify.design\"].concat(fallBackAPI) });\n/**\n* Add custom config for provider\n*/\nfunction addAPIProvider(provider, customConfig) {\n\tconst config = createAPIConfig(customConfig);\n\tif (config === null) return false;\n\tconfigStorage[provider] = config;\n\treturn true;\n}\n/**\n* Get API configuration\n*/\nfunction getAPIConfig(provider) {\n\treturn configStorage[provider];\n}\n/**\n* List API providers\n*/\nfunction listAPIProviders() {\n\treturn Object.keys(configStorage);\n}\n\nconst detectFetch = () => {\n\tlet callback;\n\ttry {\n\t\tcallback = fetch;\n\t\tif (typeof callback === \"function\") return callback;\n\t} catch (err) {}\n};\n/**\n* Fetch function\n*/\nlet fetchModule = detectFetch();\n/**\n* Set custom fetch() function\n*/\nfunction setFetch(fetch$1) {\n\tfetchModule = fetch$1;\n}\n/**\n* Get fetch() function. Used by Icon Finder Core\n*/\nfunction getFetch() {\n\treturn fetchModule;\n}\n/**\n* Calculate maximum icons list length for prefix\n*/\nfunction calculateMaxLength(provider, prefix) {\n\tconst config = getAPIConfig(provider);\n\tif (!config) return 0;\n\tlet result;\n\tif (!config.maxURL) result = 0;\n\telse {\n\t\tlet maxHostLength = 0;\n\t\tconfig.resources.forEach((item) => {\n\t\t\tconst host = item;\n\t\t\tmaxHostLength = Math.max(maxHostLength, host.length);\n\t\t});\n\t\tconst url = prefix + \".json?icons=\";\n\t\tresult = config.maxURL - maxHostLength - config.path.length - url.length;\n\t}\n\treturn result;\n}\n/**\n* Should query be aborted, based on last HTTP status\n*/\nfunction shouldAbort(status) {\n\treturn status === 404;\n}\n/**\n* Prepare params\n*/\nconst prepare = (provider, prefix, icons) => {\n\tconst results = [];\n\tconst maxLength = calculateMaxLength(provider, prefix);\n\tconst type = \"icons\";\n\tlet item = {\n\t\ttype,\n\t\tprovider,\n\t\tprefix,\n\t\ticons: []\n\t};\n\tlet length = 0;\n\ticons.forEach((name, index) => {\n\t\tlength += name.length + 1;\n\t\tif (length >= maxLength && index > 0) {\n\t\t\tresults.push(item);\n\t\t\titem = {\n\t\t\t\ttype,\n\t\t\t\tprovider,\n\t\t\t\tprefix,\n\t\t\t\ticons: []\n\t\t\t};\n\t\t\tlength = name.length;\n\t\t}\n\t\titem.icons.push(name);\n\t});\n\tresults.push(item);\n\treturn results;\n};\n/**\n* Get path\n*/\nfunction getPath(provider) {\n\tif (typeof provider === \"string\") {\n\t\tconst config = getAPIConfig(provider);\n\t\tif (config) return config.path;\n\t}\n\treturn \"/\";\n}\n/**\n* Load icons\n*/\nconst send = (host, params, callback) => {\n\tif (!fetchModule) {\n\t\tcallback(\"abort\", 424);\n\t\treturn;\n\t}\n\tlet path = getPath(params.provider);\n\tswitch (params.type) {\n\t\tcase \"icons\": {\n\t\t\tconst prefix = params.prefix;\n\t\t\tconst icons = params.icons;\n\t\t\tconst iconsList = icons.join(\",\");\n\t\t\tconst urlParams = new URLSearchParams({ icons: iconsList });\n\t\t\tpath += prefix + \".json?\" + urlParams.toString();\n\t\t\tbreak;\n\t\t}\n\t\tcase \"custom\": {\n\t\t\tconst uri = params.uri;\n\t\t\tpath += uri.slice(0, 1) === \"/\" ? uri.slice(1) : uri;\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tcallback(\"abort\", 400);\n\t\t\treturn;\n\t}\n\tlet defaultError = 503;\n\tfetchModule(host + path).then((response) => {\n\t\tconst status = response.status;\n\t\tif (status !== 200) {\n\t\t\tsetTimeout(() => {\n\t\t\t\tcallback(shouldAbort(status) ? \"abort\" : \"next\", status);\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tdefaultError = 501;\n\t\treturn response.json();\n\t}).then((data) => {\n\t\tif (typeof data !== \"object\" || data === null) {\n\t\t\tsetTimeout(() => {\n\t\t\t\tif (data === 404) callback(\"abort\", data);\n\t\t\t\telse callback(\"next\", defaultError);\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tsetTimeout(() => {\n\t\t\tcallback(\"success\", data);\n\t\t});\n\t}).catch(() => {\n\t\tcallback(\"next\", defaultError);\n\t});\n};\n/**\n* Export module\n*/\nconst fetchAPIModule = {\n\tprepare,\n\tsend\n};\n\n/**\n* Remove callback\n*/\nfunction removeCallback(storages, id) {\n\tstorages.forEach((storage) => {\n\t\tconst items = storage.loaderCallbacks;\n\t\tif (items) storage.loaderCallbacks = items.filter((row) => row.id !== id);\n\t});\n}\n/**\n* Update all callbacks for provider and prefix\n*/\nfunction updateCallbacks(storage) {\n\tif (!storage.pendingCallbacksFlag) {\n\t\tstorage.pendingCallbacksFlag = true;\n\t\tsetTimeout(() => {\n\t\t\tstorage.pendingCallbacksFlag = false;\n\t\t\tconst items = storage.loaderCallbacks ? storage.loaderCallbacks.slice(0) : [];\n\t\t\tif (!items.length) return;\n\t\t\tlet hasPending = false;\n\t\t\tconst provider = storage.provider;\n\t\t\tconst prefix = storage.prefix;\n\t\t\titems.forEach((item) => {\n\t\t\t\tconst icons = item.icons;\n\t\t\t\tconst oldLength = icons.pending.length;\n\t\t\t\ticons.pending = icons.pending.filter((icon) => {\n\t\t\t\t\tif (icon.prefix !== prefix) return true;\n\t\t\t\t\tconst name = icon.name;\n\t\t\t\t\tif (storage.icons[name]) icons.loaded.push({\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\tprefix,\n\t\t\t\t\t\tname\n\t\t\t\t\t});\n\t\t\t\t\telse if (storage.missing.has(name)) icons.missing.push({\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\tprefix,\n\t\t\t\t\t\tname\n\t\t\t\t\t});\n\t\t\t\t\telse {\n\t\t\t\t\t\thasPending = true;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t});\n\t\t\t\tif (icons.pending.length !== oldLength) {\n\t\t\t\t\tif (!hasPending) removeCallback([storage], item.id);\n\t\t\t\t\titem.callback(icons.loaded.slice(0), icons.missing.slice(0), icons.pending.slice(0), item.abort);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n}\n/**\n* Unique id counter for callbacks\n*/\nlet idCounter = 0;\n/**\n* Add callback\n*/\nfunction storeCallback(callback, icons, pendingSources) {\n\tconst id = idCounter++;\n\tconst abort = removeCallback.bind(null, pendingSources, id);\n\tif (!icons.pending.length) return abort;\n\tconst item = {\n\t\tid,\n\t\ticons,\n\t\tcallback,\n\t\tabort\n\t};\n\tpendingSources.forEach((storage) => {\n\t\t(storage.loaderCallbacks || (storage.loaderCallbacks = [])).push(item);\n\t});\n\treturn abort;\n}\n\n/**\n* Check if icons have been loaded\n*/\nfunction sortIcons(icons) {\n\tconst result = {\n\t\tloaded: [],\n\t\tmissing: [],\n\t\tpending: []\n\t};\n\tconst storage = Object.create(null);\n\ticons.sort((a, b) => {\n\t\tif (a.provider !== b.provider) return a.provider.localeCompare(b.provider);\n\t\tif (a.prefix !== b.prefix) return a.prefix.localeCompare(b.prefix);\n\t\treturn a.name.localeCompare(b.name);\n\t});\n\tlet lastIcon = {\n\t\tprovider: \"\",\n\t\tprefix: \"\",\n\t\tname: \"\"\n\t};\n\ticons.forEach((icon) => {\n\t\tif (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) return;\n\t\tlastIcon = icon;\n\t\tconst provider = icon.provider;\n\t\tconst prefix = icon.prefix;\n\t\tconst name = icon.name;\n\t\tconst providerStorage = storage[provider] || (storage[provider] = Object.create(null));\n\t\tconst localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));\n\t\tlet list;\n\t\tif (name in localStorage.icons) list = result.loaded;\n\t\telse if (prefix === \"\" || localStorage.missing.has(name)) list = result.missing;\n\t\telse list = result.pending;\n\t\tconst item = {\n\t\t\tprovider,\n\t\t\tprefix,\n\t\t\tname\n\t\t};\n\t\tlist.push(item);\n\t});\n\treturn result;\n}\n\n/**\n* Convert icons list from string/icon mix to icons and validate them\n*/\nfunction listToIcons(list, validate = true, simpleNames = false) {\n\tconst result = [];\n\tlist.forEach((item) => {\n\t\tconst icon = typeof item === \"string\" ? stringToIcon(item, validate, simpleNames) : item;\n\t\tif (icon) result.push(icon);\n\t});\n\treturn result;\n}\n\n/**\n* Default RedundancyConfig for API calls\n*/\nconst defaultConfig = {\n\tresources: [],\n\tindex: 0,\n\ttimeout: 2e3,\n\trotate: 750,\n\trandom: false,\n\tdataAfterTimeout: false\n};\n\n/**\n* Send query\n*/\nfunction sendQuery(config, payload, query, done) {\n\tconst resourcesCount = config.resources.length;\n\tconst startIndex = config.random ? Math.floor(Math.random() * resourcesCount) : config.index;\n\tlet resources;\n\tif (config.random) {\n\t\tlet list = config.resources.slice(0);\n\t\tresources = [];\n\t\twhile (list.length > 1) {\n\t\t\tconst nextIndex = Math.floor(Math.random() * list.length);\n\t\t\tresources.push(list[nextIndex]);\n\t\t\tlist = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));\n\t\t}\n\t\tresources = resources.concat(list);\n\t} else resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));\n\tconst startTime = Date.now();\n\tlet status = \"pending\";\n\tlet queriesSent = 0;\n\tlet lastError;\n\tlet timer = null;\n\tlet queue = [];\n\tlet doneCallbacks = [];\n\tif (typeof done === \"function\") doneCallbacks.push(done);\n\t/**\n\t* Reset timer\n\t*/\n\tfunction resetTimer() {\n\t\tif (timer) {\n\t\t\tclearTimeout(timer);\n\t\t\ttimer = null;\n\t\t}\n\t}\n\t/**\n\t* Abort everything\n\t*/\n\tfunction abort() {\n\t\tif (status === \"pending\") status = \"aborted\";\n\t\tresetTimer();\n\t\tqueue.forEach((item) => {\n\t\t\tif (item.status === \"pending\") item.status = \"aborted\";\n\t\t});\n\t\tqueue = [];\n\t}\n\t/**\n\t* Add / replace callback to call when execution is complete.\n\t* This can be used to abort pending query implementations when query is complete or aborted.\n\t*/\n\tfunction subscribe(callback, overwrite) {\n\t\tif (overwrite) doneCallbacks = [];\n\t\tif (typeof callback === \"function\") doneCallbacks.push(callback);\n\t}\n\t/**\n\t* Get query status\n\t*/\n\tfunction getQueryStatus() {\n\t\treturn {\n\t\t\tstartTime,\n\t\t\tpayload,\n\t\t\tstatus,\n\t\t\tqueriesSent,\n\t\t\tqueriesPending: queue.length,\n\t\t\tsubscribe,\n\t\t\tabort\n\t\t};\n\t}\n\t/**\n\t* Fail query\n\t*/\n\tfunction failQuery() {\n\t\tstatus = \"failed\";\n\t\tdoneCallbacks.forEach((callback) => {\n\t\t\tcallback(void 0, lastError);\n\t\t});\n\t}\n\t/**\n\t* Clear queue\n\t*/\n\tfunction clearQueue() {\n\t\tqueue.forEach((item) => {\n\t\t\tif (item.status === \"pending\") item.status = \"aborted\";\n\t\t});\n\t\tqueue = [];\n\t}\n\t/**\n\t* Got response from module\n\t*/\n\tfunction moduleResponse(item, response, data) {\n\t\tconst isError = response !== \"success\";\n\t\tqueue = queue.filter((queued) => queued !== item);\n\t\tswitch (status) {\n\t\t\tcase \"pending\": break;\n\t\t\tcase \"failed\":\n\t\t\t\tif (isError || !config.dataAfterTimeout) return;\n\t\t\t\tbreak;\n\t\t\tdefault: return;\n\t\t}\n\t\tif (response === \"abort\") {\n\t\t\tlastError = data;\n\t\t\tfailQuery();\n\t\t\treturn;\n\t\t}\n\t\tif (isError) {\n\t\t\tlastError = data;\n\t\t\tif (!queue.length) if (!resources.length) failQuery();\n\t\t\telse execNext();\n\t\t\treturn;\n\t\t}\n\t\tresetTimer();\n\t\tclearQueue();\n\t\tif (!config.random) {\n\t\t\tconst index = config.resources.indexOf(item.resource);\n\t\t\tif (index !== -1 && index !== config.index) config.index = index;\n\t\t}\n\t\tstatus = \"completed\";\n\t\tdoneCallbacks.forEach((callback) => {\n\t\t\tcallback(data);\n\t\t});\n\t}\n\t/**\n\t* Execute next query\n\t*/\n\tfunction execNext() {\n\t\tif (status !== \"pending\") return;\n\t\tresetTimer();\n\t\tconst resource = resources.shift();\n\t\tif (resource === void 0) {\n\t\t\tif (queue.length) {\n\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\tresetTimer();\n\t\t\t\t\tif (status === \"pending\") {\n\t\t\t\t\t\tclearQueue();\n\t\t\t\t\t\tfailQuery();\n\t\t\t\t\t}\n\t\t\t\t}, config.timeout);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfailQuery();\n\t\t\treturn;\n\t\t}\n\t\tconst item = {\n\t\t\tstatus: \"pending\",\n\t\t\tresource,\n\t\t\tcallback: (status$1, data) => {\n\t\t\t\tmoduleResponse(item, status$1, data);\n\t\t\t}\n\t\t};\n\t\tqueue.push(item);\n\t\tqueriesSent++;\n\t\ttimer = setTimeout(execNext, config.rotate);\n\t\tquery(resource, payload, item.callback);\n\t}\n\tsetTimeout(execNext);\n\treturn getQueryStatus;\n}\n\n/**\n* Redundancy instance\n*/\nfunction initRedundancy(cfg) {\n\tconst config = {\n\t\t...defaultConfig,\n\t\t...cfg\n\t};\n\tlet queries = [];\n\t/**\n\t* Remove aborted and completed queries\n\t*/\n\tfunction cleanup() {\n\t\tqueries = queries.filter((item) => item().status === \"pending\");\n\t}\n\t/**\n\t* Send query\n\t*/\n\tfunction query(payload, queryCallback, doneCallback) {\n\t\tconst query$1 = sendQuery(config, payload, queryCallback, (data, error) => {\n\t\t\tcleanup();\n\t\t\tif (doneCallback) doneCallback(data, error);\n\t\t});\n\t\tqueries.push(query$1);\n\t\treturn query$1;\n\t}\n\t/**\n\t* Find instance\n\t*/\n\tfunction find(callback) {\n\t\treturn queries.find((value) => {\n\t\t\treturn callback(value);\n\t\t}) || null;\n\t}\n\tconst instance = {\n\t\tquery,\n\t\tfind,\n\t\tsetIndex: (index) => {\n\t\t\tconfig.index = index;\n\t\t},\n\t\tgetIndex: () => config.index,\n\t\tcleanup\n\t};\n\treturn instance;\n}\n\nfunction emptyCallback$1() {}\nconst redundancyCache = Object.create(null);\n/**\n* Get Redundancy instance for provider\n*/\nfunction getRedundancyCache(provider) {\n\tif (!redundancyCache[provider]) {\n\t\tconst config = getAPIConfig(provider);\n\t\tif (!config) return;\n\t\tconst redundancy = initRedundancy(config);\n\t\tconst cachedReundancy = {\n\t\t\tconfig,\n\t\t\tredundancy\n\t\t};\n\t\tredundancyCache[provider] = cachedReundancy;\n\t}\n\treturn redundancyCache[provider];\n}\n/**\n* Send API query\n*/\nfunction sendAPIQuery(target, query, callback) {\n\tlet redundancy;\n\tlet send;\n\tif (typeof target === \"string\") {\n\t\tconst api = getAPIModule(target);\n\t\tif (!api) {\n\t\t\tcallback(void 0, 424);\n\t\t\treturn emptyCallback$1;\n\t\t}\n\t\tsend = api.send;\n\t\tconst cached = getRedundancyCache(target);\n\t\tif (cached) redundancy = cached.redundancy;\n\t} else {\n\t\tconst config = createAPIConfig(target);\n\t\tif (config) {\n\t\t\tredundancy = initRedundancy(config);\n\t\t\tconst moduleKey = target.resources ? target.resources[0] : \"\";\n\t\t\tconst api = getAPIModule(moduleKey);\n\t\t\tif (api) send = api.send;\n\t\t}\n\t}\n\tif (!redundancy || !send) {\n\t\tcallback(void 0, 424);\n\t\treturn emptyCallback$1;\n\t}\n\treturn redundancy.query(query, send, callback)().abort;\n}\n\nfunction emptyCallback() {}\n/**\n* Function called when new icons have been loaded\n*/\nfunction loadedNewIcons(storage) {\n\tif (!storage.iconsLoaderFlag) {\n\t\tstorage.iconsLoaderFlag = true;\n\t\tsetTimeout(() => {\n\t\t\tstorage.iconsLoaderFlag = false;\n\t\t\tupdateCallbacks(storage);\n\t\t});\n\t}\n}\n/**\n* Check icon names for API\n*/\nfunction checkIconNamesForAPI(icons) {\n\tconst valid = [];\n\tconst invalid = [];\n\ticons.forEach((name) => {\n\t\t(name.match(matchIconName) ? valid : invalid).push(name);\n\t});\n\treturn {\n\t\tvalid,\n\t\tinvalid\n\t};\n}\n/**\n* Parse loader response\n*/\nfunction parseLoaderResponse(storage, icons, data) {\n\tfunction checkMissing() {\n\t\tconst pending = storage.pendingIcons;\n\t\ticons.forEach((name) => {\n\t\t\tif (pending) pending.delete(name);\n\t\t\tif (!storage.icons[name]) storage.missing.add(name);\n\t\t});\n\t}\n\tif (data && typeof data === \"object\") try {\n\t\tconst parsed = addIconSet(storage, data);\n\t\tif (!parsed.length) {\n\t\t\tcheckMissing();\n\t\t\treturn;\n\t\t}\n\t} catch (err) {\n\t\tconsole.error(err);\n\t}\n\tcheckMissing();\n\tloadedNewIcons(storage);\n}\n/**\n* Handle response that can be async\n*/\nfunction parsePossiblyAsyncResponse(response, callback) {\n\tif (response instanceof Promise) response.then((data) => {\n\t\tcallback(data);\n\t}).catch(() => {\n\t\tcallback(null);\n\t});\n\telse callback(response);\n}\n/**\n* Load icons\n*/\nfunction loadNewIcons(storage, icons) {\n\tif (!storage.iconsToLoad) storage.iconsToLoad = icons;\n\telse storage.iconsToLoad = storage.iconsToLoad.concat(icons).sort();\n\tif (!storage.iconsQueueFlag) {\n\t\tstorage.iconsQueueFlag = true;\n\t\tsetTimeout(() => {\n\t\t\tstorage.iconsQueueFlag = false;\n\t\t\tconst { provider, prefix } = storage;\n\t\t\tconst icons$1 = storage.iconsToLoad;\n\t\t\tdelete storage.iconsToLoad;\n\t\t\tif (!icons$1 || !icons$1.length) return;\n\t\t\tconst customIconLoader = storage.loadIcon;\n\t\t\tif (storage.loadIcons && (icons$1.length > 1 || !customIconLoader)) {\n\t\t\t\tparsePossiblyAsyncResponse(storage.loadIcons(icons$1, prefix, provider), (data) => {\n\t\t\t\t\tparseLoaderResponse(storage, icons$1, data);\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (customIconLoader) {\n\t\t\t\ticons$1.forEach((name) => {\n\t\t\t\t\tconst response = customIconLoader(name, prefix, provider);\n\t\t\t\t\tparsePossiblyAsyncResponse(response, (data) => {\n\t\t\t\t\t\tconst iconSet = data ? {\n\t\t\t\t\t\t\tprefix,\n\t\t\t\t\t\t\ticons: { [name]: data }\n\t\t\t\t\t\t} : null;\n\t\t\t\t\t\tparseLoaderResponse(storage, [name], iconSet);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { valid, invalid } = checkIconNamesForAPI(icons$1);\n\t\t\tif (invalid.length) parseLoaderResponse(storage, invalid, null);\n\t\t\tif (!valid.length) return;\n\t\t\tconst api = prefix.match(matchIconName) ? getAPIModule(provider) : null;\n\t\t\tif (!api) {\n\t\t\t\tparseLoaderResponse(storage, valid, null);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst params = api.prepare(provider, prefix, valid);\n\t\t\tparams.forEach((item) => {\n\t\t\t\tsendAPIQuery(provider, item, (data) => {\n\t\t\t\t\tparseLoaderResponse(storage, item.icons, data);\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t}\n}\n/**\n* Load icons\n*/\nconst loadIcons = (icons, callback) => {\n\tconst cleanedIcons = listToIcons(icons, true, allowSimpleNames());\n\tconst sortedIcons = sortIcons(cleanedIcons);\n\tif (!sortedIcons.pending.length) {\n\t\tlet callCallback = true;\n\t\tif (callback) setTimeout(() => {\n\t\t\tif (callCallback) callback(sortedIcons.loaded, sortedIcons.missing, sortedIcons.pending, emptyCallback);\n\t\t});\n\t\treturn () => {\n\t\t\tcallCallback = false;\n\t\t};\n\t}\n\tconst newIcons = Object.create(null);\n\tconst sources = [];\n\tlet lastProvider, lastPrefix;\n\tsortedIcons.pending.forEach((icon) => {\n\t\tconst { provider, prefix } = icon;\n\t\tif (prefix === lastPrefix && provider === lastProvider) return;\n\t\tlastProvider = provider;\n\t\tlastPrefix = prefix;\n\t\tsources.push(getStorage(provider, prefix));\n\t\tconst providerNewIcons = newIcons[provider] || (newIcons[provider] = Object.create(null));\n\t\tif (!providerNewIcons[prefix]) providerNewIcons[prefix] = [];\n\t});\n\tsortedIcons.pending.forEach((icon) => {\n\t\tconst { provider, prefix, name } = icon;\n\t\tconst storage = getStorage(provider, prefix);\n\t\tconst pendingQueue = storage.pendingIcons || (storage.pendingIcons = /* @__PURE__ */ new Set());\n\t\tif (!pendingQueue.has(name)) {\n\t\t\tpendingQueue.add(name);\n\t\t\tnewIcons[provider][prefix].push(name);\n\t\t}\n\t});\n\tsources.forEach((storage) => {\n\t\tconst list = newIcons[storage.provider][storage.prefix];\n\t\tif (list.length) loadNewIcons(storage, list);\n\t});\n\treturn callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;\n};\n/**\n* Load one icon using Promise\n*/\nconst loadIcon = (icon) => {\n\treturn new Promise((fulfill, reject) => {\n\t\tconst iconObj = typeof icon === \"string\" ? stringToIcon(icon, true) : icon;\n\t\tif (!iconObj) {\n\t\t\treject(icon);\n\t\t\treturn;\n\t\t}\n\t\tloadIcons([iconObj || icon], (loaded) => {\n\t\t\tif (loaded.length && iconObj) {\n\t\t\t\tconst data = getIconData(iconObj);\n\t\t\t\tif (data) {\n\t\t\t\t\tfulfill({\n\t\t\t\t\t\t...defaultIconProps,\n\t\t\t\t\t\t...data\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\treject(icon);\n\t\t});\n\t});\n};\n\n/**\n* Set custom loader for multiple icons\n*/\nfunction setCustomIconsLoader(loader, prefix, provider) {\n\tgetStorage(provider || \"\", prefix).loadIcons = loader;\n}\n/**\n* Set custom loader for one icon\n*/\nfunction setCustomIconLoader(loader, prefix, provider) {\n\tgetStorage(provider || \"\", prefix).loadIcon = loader;\n}\n\n/**\n* Convert IconifyIconCustomisations to FullIconCustomisations, checking value types\n*/\nfunction mergeCustomisations(defaults, item) {\n\tconst result = { ...defaults };\n\tfor (const key in item) {\n\t\tconst value = item[key];\n\t\tconst valueType = typeof value;\n\t\tif (key in defaultIconSizeCustomisations) {\n\t\t\tif (value === null || value && (valueType === \"string\" || valueType === \"number\")) result[key] = value;\n\t\t} else if (valueType === typeof result[key]) result[key] = key === \"rotate\" ? value % 4 : value;\n\t}\n\treturn result;\n}\n\nconst separator = /[\\s,]+/;\n/**\n* Apply \"flip\" string to icon customisations\n*/\nfunction flipFromString(custom, flip) {\n\tflip.split(separator).forEach((str) => {\n\t\tconst value = str.trim();\n\t\tswitch (value) {\n\t\t\tcase \"horizontal\":\n\t\t\t\tcustom.hFlip = true;\n\t\t\t\tbreak;\n\t\t\tcase \"vertical\":\n\t\t\t\tcustom.vFlip = true;\n\t\t\t\tbreak;\n\t\t}\n\t});\n}\n\n/**\n* Get rotation value\n*/\nfunction rotateFromString(value, defaultValue = 0) {\n\tconst units = value.replace(/^-?[0-9.]*/, \"\");\n\tfunction cleanup(value$1) {\n\t\twhile (value$1 < 0) value$1 += 4;\n\t\treturn value$1 % 4;\n\t}\n\tif (units === \"\") {\n\t\tconst num = parseInt(value);\n\t\treturn isNaN(num) ? 0 : cleanup(num);\n\t} else if (units !== value) {\n\t\tlet split = 0;\n\t\tswitch (units) {\n\t\t\tcase \"%\":\n\t\t\t\tsplit = 25;\n\t\t\t\tbreak;\n\t\t\tcase \"deg\": split = 90;\n\t\t}\n\t\tif (split) {\n\t\t\tlet num = parseFloat(value.slice(0, value.length - units.length));\n\t\t\tif (isNaN(num)) return 0;\n\t\t\tnum = num / split;\n\t\t\treturn num % 1 === 0 ? cleanup(num) : 0;\n\t\t}\n\t}\n\treturn defaultValue;\n}\n\n/**\n* Generate <svg>\n*/\nfunction iconToHTML(body, attributes) {\n\tlet renderAttribsHTML = body.indexOf(\"xlink:\") === -1 ? \"\" : \" xmlns:xlink=\\\"http://www.w3.org/1999/xlink\\\"\";\n\tfor (const attr in attributes) renderAttribsHTML += \" \" + attr + \"=\\\"\" + attributes[attr] + \"\\\"\";\n\treturn \"<svg xmlns=\\\"http://www.w3.org/2000/svg\\\"\" + renderAttribsHTML + \">\" + body + \"</svg>\";\n}\n\n/**\n* Encode SVG for use in url()\n*\n* Short alternative to encodeURIComponent() that encodes only stuff used in SVG, generating\n* smaller code.\n*/\nfunction encodeSVGforURL(svg) {\n\treturn svg.replace(/\"/g, \"'\").replace(/%/g, \"%25\").replace(/#/g, \"%23\").replace(/</g, \"%3C\").replace(/>/g, \"%3E\").replace(/\\s+/g, \" \");\n}\n/**\n* Generate data: URL from SVG\n*/\nfunction svgToData(svg) {\n\treturn \"data:image/svg+xml,\" + encodeSVGforURL(svg);\n}\n/**\n* Generate url() from SVG\n*/\nfunction svgToURL(svg) {\n\treturn \"url(\\\"\" + svgToData(svg) + \"\\\")\";\n}\n\nlet policy;\n/**\n* Attempt to create policy\n*/\nfunction createPolicy() {\n\ttry {\n\t\tpolicy = window.trustedTypes.createPolicy(\"iconify\", { createHTML: (s) => s });\n\t} catch (err) {\n\t\tpolicy = null;\n\t}\n}\n/**\n* Clean up value for innerHTML assignment\n*\n* This code doesn't actually clean up anything.\n* It is intended be used with Iconify icon data, which has already been validated\n*/\nfunction cleanUpInnerHTML(html) {\n\tif (policy === void 0) createPolicy();\n\treturn policy ? policy.createHTML(html) : html;\n}\n\nconst defaultExtendedIconCustomisations = {\n ...defaultIconCustomisations,\n inline: false,\n};\n\n/**\n * Default SVG attributes\n */\nconst svgDefaults = {\n 'xmlns': 'http://www.w3.org/2000/svg',\n 'xmlnsXlink': 'http://www.w3.org/1999/xlink',\n 'aria-hidden': true,\n 'role': 'img',\n};\n/**\n * Style modes\n */\nconst commonProps = {\n display: 'inline-block',\n};\nconst monotoneProps = {\n backgroundColor: 'currentColor',\n};\nconst coloredProps = {\n backgroundColor: 'transparent',\n};\n// Dynamically add common props to variables above\nconst propsToAdd = {\n Image: 'var(--svg)',\n Repeat: 'no-repeat',\n Size: '100% 100%',\n};\nconst propsToAddTo = {\n WebkitMask: monotoneProps,\n mask: monotoneProps,\n background: coloredProps,\n};\nfor (const prefix in propsToAddTo) {\n const list = propsToAddTo[prefix];\n for (const prop in propsToAdd) {\n list[prefix + prop] = propsToAdd[prop];\n }\n}\n/**\n * Default values for customisations for inline icon\n */\nconst inlineDefaults = {\n ...defaultExtendedIconCustomisations,\n inline: true,\n};\n/**\n * Fix size: add 'px' to numbers\n */\nfunction fixSize(value) {\n return value + (value.match(/^[-0-9.]+$/) ? 'px' : '');\n}\n/**\n * Render icon\n */\nconst render = (\n// Icon must be validated before calling this function\nicon, \n// Partial properties\nprops, \n// Icon name\nname) => {\n // Get default properties\n const defaultProps = props.inline\n ? inlineDefaults\n : defaultExtendedIconCustomisations;\n // Get all customisations\n const customisations = mergeCustomisations(defaultProps, props);\n // Check mode\n const mode = props.mode || 'svg';\n // Create style\n const style = {};\n const customStyle = props.style || {};\n // Create SVG component properties\n const componentProps = {\n ...(mode === 'svg' ? svgDefaults : {}),\n };\n if (name) {\n const iconName = stringToIcon(name, false, true);\n if (iconName) {\n const classNames = ['iconify'];\n const props = [\n 'provider',\n 'prefix',\n ];\n for (const prop of props) {\n if (iconName[prop]) {\n classNames.push('iconify--' + iconName[prop]);\n }\n }\n componentProps.className = classNames.join(' ');\n }\n }\n // Get element properties\n for (let key in props) {\n const value = props[key];\n if (value === void 0) {\n continue;\n }\n switch (key) {\n // Properties to ignore\n case 'icon':\n case 'style':\n case 'children':\n case 'onLoad':\n case 'mode':\n case 'ssr':\n case 'fallback':\n break;\n // Forward ref\n case '_ref':\n componentProps.ref = value;\n break;\n // Merge class names\n case 'className':\n componentProps[key] =\n (componentProps[key] ? componentProps[key] + ' ' : '') +\n value;\n break;\n // Boolean attributes\n case 'inline':\n case 'hFlip':\n case 'vFlip':\n customisations[key] =\n value === true || value === 'true' || value === 1;\n break;\n // Flip as string: 'horizontal,vertical'\n case 'flip':\n if (typeof value === 'string') {\n flipFromString(customisations, value);\n }\n break;\n // Color: copy to style\n case 'color':\n style.color = value;\n break;\n // Rotation as string\n case 'rotate':\n if (typeof value === 'string') {\n customisations[key] = rotateFromString(value);\n }\n else if (typeof value === 'number') {\n customisations[key] = value;\n }\n break;\n // Remove aria-hidden\n case 'ariaHidden':\n case 'aria-hidden':\n if (value !== true && value !== 'true') {\n delete componentProps['aria-hidden'];\n }\n break;\n // Copy missing property if it does not exist in customisations\n default:\n if (defaultProps[key] === void 0) {\n componentProps[key] = value;\n }\n }\n }\n // Generate icon\n const item = iconToSVG(icon, customisations);\n const renderAttribs = item.attributes;\n // Inline display\n if (customisations.inline) {\n style.verticalAlign = '-0.125em';\n }\n if (mode === 'svg') {\n // Add style\n componentProps.style = {\n ...style,\n ...customStyle,\n };\n // Add icon stuff\n Object.assign(componentProps, renderAttribs);\n // Counter for ids based on \"id\" property to render icons consistently on server and client\n let localCounter = 0;\n let id = props.id;\n if (typeof id === 'string') {\n // Convert '-' to '_' to avoid errors in animations\n id = id.replace(/-/g, '_');\n }\n // Add icon stuff\n componentProps.dangerouslySetInnerHTML = {\n __html: cleanUpInnerHTML(replaceIDs(item.body, id ? () => id + 'ID' + localCounter++ : 'iconifyReact')),\n };\n return createElement('svg', componentProps);\n }\n // Render <span> with style\n const { body, width, height } = icon;\n const useMask = mode === 'mask' ||\n (mode === 'bg' ? false : body.indexOf('currentColor') !== -1);\n // Generate SVG\n const html = iconToHTML(body, {\n ...renderAttribs,\n width: width + '',\n height: height + '',\n });\n // Generate style\n componentProps.style = {\n ...style,\n '--svg': svgToURL(html),\n 'width': fixSize(renderAttribs.width),\n 'height': fixSize(renderAttribs.height),\n ...commonProps,\n ...(useMask ? monotoneProps : coloredProps),\n ...customStyle,\n };\n return createElement('span', componentProps);\n};\n\n/**\n * Initialise stuff\n */\n// Enable short names\nallowSimpleNames(true);\n// Set API module\nsetAPIModule('', fetchAPIModule);\n/**\n * Browser stuff\n */\nif (typeof document !== 'undefined' && typeof window !== 'undefined') {\n const _window = window;\n // Load icons from global \"IconifyPreload\"\n if (_window.IconifyPreload !== void 0) {\n const preload = _window.IconifyPreload;\n const err = 'Invalid IconifyPreload syntax.';\n if (typeof preload === 'object' && preload !== null) {\n (preload instanceof Array ? preload : [preload]).forEach((item) => {\n try {\n if (\n // Check if item is an object and not null/array\n typeof item !== 'object' ||\n item === null ||\n item instanceof Array ||\n // Check for 'icons' and 'prefix'\n typeof item.icons !== 'object' ||\n typeof item.prefix !== 'string' ||\n // Add icon set\n !addCollection(item)) {\n console.error(err);\n }\n }\n catch (e) {\n console.error(err);\n }\n });\n }\n }\n // Set API from global \"IconifyProviders\"\n if (_window.IconifyProviders !== void 0) {\n const providers = _window.IconifyProviders;\n if (typeof providers === 'object' && providers !== null) {\n for (let key in providers) {\n const err = 'IconifyProviders[' + key + '] is invalid.';\n try {\n const value = providers[key];\n if (typeof value !== 'object' ||\n !value ||\n value.resources === void 0) {\n continue;\n }\n if (!addAPIProvider(key, value)) {\n console.error(err);\n }\n }\n catch (e) {\n console.error(err);\n }\n }\n }\n }\n}\nfunction IconComponent(props) {\n const [mounted, setMounted] = useState(!!props.ssr);\n const [abort, setAbort] = useState({});\n // Get initial state\n function getInitialState(mounted) {\n if (mounted) {\n const name = props.icon;\n if (typeof name === 'object') {\n // Icon as object\n return {\n name: '',\n data: name,\n };\n }\n const data = getIconData(name);\n if (data) {\n return {\n name,\n data,\n };\n }\n }\n return {\n name: '',\n };\n }\n const [state, setState] = useState(getInitialState(!!props.ssr));\n // Cancel loading\n function cleanup() {\n const callback = abort.callback;\n if (callback) {\n callback();\n setAbort({});\n }\n }\n // Change state if it is different\n function changeState(newState) {\n if (JSON.stringify(state) !== JSON.stringify(newState)) {\n cleanup();\n setState(newState);\n return true;\n }\n }\n // Update state\n function updateState() {\n var _a;\n const name = props.icon;\n if (typeof name === 'object') {\n // Icon as object\n changeState({\n name: '',\n data: name,\n });\n return;\n }\n // New icon or got icon data\n const data = getIconData(name);\n if (changeState({\n name,\n data,\n })) {\n if (data === undefined) {\n // Load icon, update state when done\n const callback = loadIcons([name], updateState);\n setAbort({\n callback,\n });\n }\n else if (data) {\n // Icon data is available: trigger onLoad callback if present\n (_a = props.onLoad) === null || _a === void 0 ? void 0 : _a.call(props, name);\n }\n }\n }\n // Mounted state, cleanup for loader\n useEffect(() => {\n setMounted(true);\n return cleanup;\n }, []);\n // Icon changed or component mounted\n useEffect(() => {\n if (mounted) {\n updateState();\n }\n }, [props.icon, mounted]);\n // Render icon\n const { name, data } = state;\n if (!data) {\n return props.children\n ? props.children\n : props.fallback\n ? props.fallback\n : createElement('span', {});\n }\n return render({\n ...defaultIconProps,\n ...data,\n }, props, name);\n}\n/**\n * Block icon\n *\n * @param props - Component properties\n */\nconst Icon = forwardRef((props, ref) => IconComponent({\n ...props,\n _ref: ref,\n}));\n/**\n * Inline icon (has negative verticalAlign that makes it behave like icon font)\n *\n * @param props - Component properties\n */\nconst InlineIcon = forwardRef((props, ref) => IconComponent({\n inline: true,\n ...props,\n _ref: ref,\n}));\n/**\n * Internal API\n */\nconst _api = {\n getAPIConfig,\n setAPIModule,\n sendAPIQuery,\n setFetch,\n getFetch,\n listAPIProviders,\n};\n\nexport { Icon, InlineIcon, _api, addAPIProvider, addCollection, addIcon, iconToSVG as buildIcon, calculateSize, getIcon, iconLoaded, listIcons, loadIcon, loadIcons, replaceIDs, setCustomIconLoader, setCustomIconsLoader };\n","import { createSlice, type PayloadAction } from \"@reduxjs/toolkit\";\nimport type { SearchProduct } from \"../../components/graphQL/queries/types\";\n\ninterface ProductState {\n product: SearchProduct | null;\n}\n\nconst initialState: ProductState = {\n product: null,\n};\n\nexport const productSlice = createSlice({\n name: \"product\",\n initialState,\n reducers: {\n setProduct: (state, action: PayloadAction<SearchProduct | null>) => {\n state.product = action.payload;\n },\n },\n});\n\nexport const { setProduct } = productSlice.actions;\n\nexport default productSlice.reducer;\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useDispatch } from \"react-redux\";\nimport type { SearchProduct } from \"../graphQL/queries/types\";\nimport {\n stringReducer,\n priceFormatter,\n currencyFormatter,\n displayData,\n imageUrlArray,\n} from \"../utils/helper\";\nimport { Icon } from \"@iconify/react/dist/iconify.js\";\nimport { useEffect, useState } from \"react\";\nimport { setProduct } from \"../../store/reducers/productReducer\";\nimport { getProductById } from \"../utils\";\n\nfunction useResponsiveProductsPerPage() {\n const getProductsPerPage = () => {\n if (window.innerWidth < 425) return 1; // Below Mobile-L\n if (window.innerWidth < 768) return 2; // Mobile-L to md\n return 4; // md and above\n };\n\n const [productsPerPage, setProductsPerPage] = useState(getProductsPerPage);\n\n useEffect(() => {\n const handleResize = () => setProductsPerPage(getProductsPerPage());\n window.addEventListener(\"resize\", handleResize);\n return () => window.removeEventListener(\"resize\", handleResize);\n }, []);\n\n return productsPerPage;\n}\n\nconst ProductCarousel = ({\n product,\n}: // storeDetails,\n{\n product: SearchProduct[];\n storeDetails: any;\n}) => {\n const dispatch = useDispatch();\n // const selectedProduct = useSelector((state: any) => state.product.product);\n const productsPerPage = useResponsiveProductsPerPage();\n const [startIndex, setStartIndex] = useState(0);\n\n const nextProducts = () => {\n setStartIndex((prevIndex) =>\n prevIndex + productsPerPage >= product.length\n ? 0\n : prevIndex + productsPerPage\n );\n };\n\n const prevProducts = () => {\n setStartIndex((prevIndex) =>\n prevIndex - productsPerPage < 0\n ? product.length - (product.length % productsPerPage || productsPerPage)\n : prevIndex - productsPerPage\n );\n };\n\n const getProduct = async (id: number | string) => {\n const product = await getProductById(id);\n dispatch(setProduct(product));\n };\n\n return (\n <div className=\"mt-2 overflow-x-hidden\">\n <div className=\"flex items-center justify-center gap-4 relative\">\n {product?.length > productsPerPage && (\n <button\n onClick={prevProducts}\n className=\"absolute z-50 left-0 text-[#000000] bg-[#ffffff] rounded-full p-2 flex items-center h-fit\"\n // style={{ color: storeDetails.tanyaThemeColor }}\n >\n <Icon icon=\"mdi:chevron-left\" width=\"25\" />\n </button>\n )}\n\n <div className=\"flex gap-5 justify-center flex-1 overflow-hidden\">\n {product\n .slice(startIndex, startIndex + productsPerPage)\n .map((prod) => (\n <div\n key={prod.productId}\n className=\"flex-shrink-0 flex flex-col w-[150px] h-[200px] p-2 items-center justify-between cursor-pointer bg-[#FFFFFF] rounded-[10px] shadow-[0px_2px_2px_0px_#9292BC40]\"\n onClick={() => {\n getProduct(prod.product_id ?? prod.productId);\n }}\n >\n {/* Image */}\n <div className=\"w-full p-2 flex items-center justify-center bg-white\">\n <img\n src={\n imageUrlArray(prod)[0]?.link ||\n imageUrlArray(prod)[0] || // fallback if it's a string\n \"https://via.placeholder.com/120\"\n }\n alt={prod?.productName ? prod.productName : \"Product\"}\n className=\"w-28 h-28 rounded-[10px] transition-transform duration-300 hover:scale-125 object-cover\"\n />\n </div>\n\n {/* Price & Name */}\n <div\n className=\"text-white w-full p-2 text-[12px] text-center h-[60px]\"\n // style={{ background: storeDetails.tanyaThemeColor }}\n >\n <div className=\"relative inline-block group\">\n <div className=\"w-full line-clamp-1 overflow-hidden text-ellipsis text-[#000000] font-medium font-nunitoSans\">\n {prod?.productName\n ? prod.productName\n : prod?.product_name\n ? prod.product_name\n : stringReducer(\n displayData(prod?.name?.[\"en-US\"]),\n 60\n ) || \"Product\"}\n </div>\n\n {/* Tooltip */}\n <div\n className=\"absolute left-0 top-full mt-1 w-max max-w-[200px] p-2 bg-white shadow-lg text-black text-xs rounded opacity-0 transition-opacity duration-300 group-hover:opacity-100 z-50 pointer-events-auto\"\n style={{\n position: \"absolute\",\n top: \"-100%\",\n left: \"0\",\n marginBottom: \"5px\",\n zIndex: 50,\n }}\n >\n {prod?.productName\n ? prod.productName\n : prod?.product_name\n ? prod.product_name\n : stringReducer(\n displayData(prod?.name?.[\"en-US\"]),\n 60\n ) || \"Product\"}\n </div>\n </div>\n <div className=\" flex text-center items-center gap-2 text-[14px] text-[#14121F] font-bold font-nunitoSans text-base mb-1\">\n <p>\n {currencyFormatter(\n prod?.price\n ? Number(prod?.price)\n : priceFormatter(prod).centAmount || 0,\n priceFormatter(prod)?.currencyCode\n )}\n </p>\n <p className=\"text-[#14121F] font-normal line-through text-sm font-nunitoSans truncate\">\n ${Number(prod?.price).toFixed(2) ?? 0 + 5}\n </p>\n </div>\n </div>\n </div>\n ))}\n </div>\n\n {product?.length > productsPerPage && (\n <button\n onClick={nextProducts}\n className=\"absolute z-50 right-0 text-[#000000] bg-[#ffffff] rounded-full p-2 flex items-center h-fit\"\n // style={{ color: storeDetails.tanyaThemeColor }}\n >\n <Icon icon=\"mdi:chevron-right\" width=\"25\" />\n </button>\n )}\n </div>\n </div>\n );\n};\n\nexport default ProductCarousel;\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport ProductCarousel from \"./ProductCarousel\";\nimport { initialCapital } from \"../utils/helper\";\n\nconst ProductDisplay = ({ chat, storeDetails }: any) => {\n return (\n <div className=\"bg-[#FFFFFF] px-7 py-4 rounded-r-xl rounded-bl-2xl w-full\">\n {chat.map((products: any, i: number) => (\n <div\n key={i}\n className=\"mb-4 p-3 rounded-xl\"\n style={{ \n background: \"linear-gradient(109.52deg, #F0EEF5 36.91%, #F4F3EE 100.34%\",\n // backgroundColor: storeDetails.tanyaThemeColorLight \n }} // slightly darker grey // light grey section bg\n >\n <div\n className=\"font-nunitoSans font-bold text-sm text-[#494949] p-2 w-fit rounded-[20px]\"\n // style={{\n // color: storeDetails?.tanyaThemeContrastColor,\n // border: `1px solid ${storeDetails.tanyaThemeColor}`,\n // backgroundColor: storeDetails.tanyaThemeColor,\n // }}\n >\n {initialCapital(products.keyword) || \"No keyword\"}\n </div>\n\n <ProductCarousel\n product={products.items}\n storeDetails={storeDetails}\n />\n </div>\n ))}\n </div>\n );\n};\n\nexport default ProductDisplay;\n","import { apiConfig } from \"../../config/api\";\nimport { clientId, getHost, getSiteId, organisationId, shortCode } from \"../utils\";\nimport { getAccessToken } from \"../utils/getAccessToken\";\nimport axios from \"axios\";\n\nexport const fetchStoreConfig = async (storeCode: string) => {\n try {\n const token = await getAccessToken();\n const { serverUrl } = apiConfig();\n const response = await axios.get(\n `${serverUrl}api/logo?storeCode=${storeCode}`,\n {\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${token}`,\n },\n }\n );\n return response.data;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n return error;\n // console.error(\"Error fetching logo details:\", error);\n }\n};\n\ninterface Product {\n product_id: string;\n quantity: number;\n}\n\nexport const createBasket = async (customer_token: string, data?: any) => {\n const { serverUrl, basePath } = apiConfig();\n const URL = `${serverUrl}`;\n console.log(\"customer_token \\n\", customer_token);\n try {\n const response = await axios.post(\n `${URL}${basePath}/basket/create?baseUrl=${getHost()}&siteId=${getSiteId()}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}`,\n data,\n {\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: customer_token,\n },\n }\n );\n\n return response.data;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n console.error(\"Error creating basket:\", error.response || error.message);\n } else {\n console.error(\"Unexpected error:\", error);\n }\n return null;\n }\n};\n\nexport const addProductToBasket = async (\n basketId: string,\n products: Product[],\n customer_token: string\n) => {\n const { serverUrl, basePath } = apiConfig();\n const URL = `${serverUrl}`;\n try {\n const response = await axios.post(\n `${URL}${basePath}/basket/add-product/${basketId}?baseUrl=${getHost()}&siteId=${getSiteId()}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}`,\n products,\n {\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: customer_token,\n },\n }\n );\n\n if (response.status === 200 && response.data) {\n return response.data;\n }\n return null;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n console.error(\n \"Error adding products to basket:\",\n error.response || error.message\n );\n } else {\n console.error(\"Unexpected error:\", error);\n }\n return null;\n }\n};\n\nexport const fetchBasket = async ({\n basketId,\n customer_token,\n}: {\n basketId: string;\n customer_token: string;\n}) => {\n const { serverUrl, basePath } = apiConfig();\n const URL = `${serverUrl}`;\n try {\n const response = await axios.get(\n `${URL}${basePath}/basket/${basketId}?baseUrl=${getHost()}&siteId=${getSiteId()}&pubCfg=${clientId()}&envRef=${shortCode()}&orgRef=${organisationId()}`,\n {\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: customer_token,\n },\n }\n );\n return { status: response.status, data: response.data };\n } catch (error) {\n if (axios.isAxiosError(error)) {\n return { status: error.response?.status, data: null };\n } else {\n return { status: null, data: null };\n }\n }\n};\n","export const BASKET_ID_KEY = \"sfcc_basket_id\";\r\nexport const TOKEN_KEY = \"sfcc_customer_token\";\r\nexport const TOKEN_EXPIRY_KEY = \"sfcc_token_expiry\";\r\n\r\nexport const EXPIRY_TIME = 5 * 60 * 1000; // 5 minutes in milliseconds\r\nexport const BUFFER_TIME = 10 * 1000; // 10 seconds buffer before expiry\r\nexport const VERSION = \"1.0.0\";","import {\r\n BASKET_ID_KEY,\r\n EXPIRY_TIME,\r\n TOKEN_EXPIRY_KEY,\r\n TOKEN_KEY,\r\n} from \"../../config/constant\";\r\n\r\nexport const getStoredBasketId = (): string | null => {\r\n try {\r\n return localStorage.getItem(BASKET_ID_KEY);\r\n } catch (error) {\r\n console.error(\"Error reading basket ID from storage:\", error);\r\n return null;\r\n }\r\n};\r\n\r\nexport const setStoredBasketId = (basketId: string | null): void => {\r\n try {\r\n if (basketId) {\r\n localStorage.setItem(BASKET_ID_KEY, basketId);\r\n } else {\r\n localStorage.removeItem(BASKET_ID_KEY);\r\n }\r\n } catch (error) {\r\n console.error(\"Error saving basket ID to storage:\", error);\r\n }\r\n};\r\n\r\nexport const clearBasketStorage = (): void => {\r\n try {\r\n localStorage.removeItem(BASKET_ID_KEY);\r\n } catch (error) {\r\n console.error(\"Error clearing basket storage:\", error);\r\n }\r\n};\r\n\r\nexport const getStoredToken = (): string | null => {\r\n try {\r\n return localStorage.getItem(TOKEN_KEY);\r\n } catch (error) {\r\n console.error(\"Error reading token:\", error);\r\n return null;\r\n }\r\n};\r\n\r\nexport const setStoredToken = (token: string | null): void => {\r\n try {\r\n if (token) {\r\n localStorage.setItem(TOKEN_KEY, token);\r\n const expiryTime = Date.now() + EXPIRY_TIME;\r\n localStorage.setItem(TOKEN_EXPIRY_KEY, expiryTime.toString());\r\n } else {\r\n localStorage.removeItem(TOKEN_KEY);\r\n }\r\n } catch (error) {\r\n console.error(\"Error storing token:\", error);\r\n }\r\n};\r\n","/* eslint-disable @typescript-eslint/no-explicit-any */\r\nimport { useEffect, useState } from \"react\"; // Add useMemo here when uncomment the color, size, width code\r\n// import { useEffect, useMemo, useState } from \"react\";\r\nimport { useSelector, useDispatch } from \"react-redux\";\r\nimport { Icon } from \"@iconify/react\";\r\nimport { setProduct } from \"../../store/reducers/productReducer\";\r\nimport { addProductToBasket, createBasket, fetchBasket } from \"../api/api\";\r\n// import { fetchTokenSFCC } from \"../utils/fetchTokenSFCC\";\r\nimport {\r\n getStoredBasketId,\r\n // getStoredToken,\r\n setStoredBasketId,\r\n setStoredToken,\r\n} from \"../utils/localStorage\";\r\nimport { toast } from \"react-toastify\";\r\nimport { TOKEN_EXPIRY_KEY } from \"../../config/constant\";\r\nimport { fetchTokenBmGrant } from \"../utils/fetchTokenBmGrant\";\r\nimport {\r\n // fetchExistingRegisterCustomerToken,\r\n fetchExistingGuestCustomerToken,\r\n} from \"../utils/fetchExistingRegisterCustomerToken\";\r\nimport { notifySFCC } from \"../lib/utils\";\r\nimport { authData } from \"../../sfcc-apis/session\";\r\n\r\nconst ANIMATION_DURATION = 300; // ms\r\n\r\nconst ProductDisplayCard = () => {\r\n const dispatch = useDispatch();\r\n const product = useSelector((state: any) => state.product.product);\r\n const storeDetails = useSelector((s: any) => s.store.store);\r\n const [show, setShow] = useState(!!product);\r\n\r\n useEffect(() => {\r\n setShow(!!product);\r\n }, [product]);\r\n\r\n if (!product) return null;\r\n\r\n // const { sizeAttr, colorAttr, widthAttr } = attributes;\r\n\r\n const addToCart = async () => {\r\n console.log(product, \"the prod\");\r\n try {\r\n // Check if product and variants exist\r\n\r\n if (\r\n !product?.variants?.[0]?.product_id &&\r\n !(product.type.item || product.type.bundle) &&\r\n !product?.variants?.[0]?.productId\r\n ) {\r\n toast.error(\"Variants not available\", {\r\n position: \"bottom-right\",\r\n autoClose: 1000,\r\n });\r\n console.error(\"No product variant found\");\r\n return;\r\n }\r\n\r\n const productData = [\r\n {\r\n product_id:\r\n product.variants?.[0].product_id ||\r\n product.variants?.[0].productId ||\r\n product?.id,\r\n quantity: 1,\r\n },\r\n ];\r\n console.log(productData, \"the product data\");\r\n // for getting customer id\r\n const customerData = JSON.parse(\r\n sessionStorage.getItem(\"customerData\") || \"{}\"\r\n );\r\n const basketIdFromCustomer = customerData?.basketId;\r\n const customer_token = false;\r\n const tokenExpiry = localStorage.getItem(TOKEN_EXPIRY_KEY);\r\n const currentTime = Date.now();\r\n\r\n // If no token, get a new one\r\n if (\r\n !customer_token ||\r\n !tokenExpiry ||\r\n currentTime >= parseInt(tokenExpiry)\r\n ) {\r\n let customer_token = \"\";\r\n if (import.meta.env.VITE_SCAPI_ENVIRONMENT) {\r\n const authDetails = await authData();\r\n console.log(\"token from auth data\");\r\n customer_token = \"Bearer \" + authDetails.access_token;\r\n } else {\r\n console.log(\"token from bm grant\");\r\n const access_token = await fetchTokenBmGrant();\r\n const customerTokenData = await fetchExistingGuestCustomerToken(\r\n access_token\r\n );\r\n customer_token = customerTokenData.customer_token;\r\n }\r\n if (!customer_token) {\r\n console.error(\"Failed to get customer_token\");\r\n return;\r\n }\r\n const newExpiryTime = currentTime + 5 * 60 * 1000;\r\n setStoredToken(customer_token);\r\n localStorage.setItem(TOKEN_EXPIRY_KEY, newExpiryTime.toString());\r\n\r\n // 1. Try basketId from customerData\r\n if (basketIdFromCustomer) {\r\n const fetchBasketResponse = await fetchBasket({\r\n basketId: basketIdFromCustomer,\r\n customer_token,\r\n });\r\n console.log(basketIdFromCustomer, \"basket id from customer\");\r\n if (fetchBasketResponse.status === 200 && fetchBasketResponse) {\r\n // Use this basketId to add product\r\n\r\n const response = await addProductToBasket(\r\n basketIdFromCustomer,\r\n productData,\r\n customer_token\r\n );\r\n if (\r\n response?.product_items?.length > 0 ||\r\n response?.productItems?.length > 0\r\n ) {\r\n // const addedProduct = response.product_items.at(-1);\r\n toast.success(`Added to cart`, {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n hideProgressBar: false,\r\n closeOnClick: true,\r\n pauseOnHover: true,\r\n draggable: true,\r\n });\r\n notifySFCC(basketIdFromCustomer);\r\n // window.location.reload();\r\n }\r\n return; // Skip basket creation\r\n }\r\n }\r\n\r\n // 2. If not valid, create new basket and store its ID in localStorage\r\n const data = {\r\n productItems: [\r\n {\r\n productId:\r\n product.variants?.[0].product_id ||\r\n product.variants?.[0].productId ||\r\n product?.id,\r\n quantity: 1,\r\n },\r\n ],\r\n };\r\n console.log(\"before create basket\");\r\n const basketResponse = await createBasket(customer_token, data);\r\n console.log(\r\n basketResponse,\r\n basketResponse?.basket_id,\r\n basketResponse?.basketId,\r\n \"the basket response\"\r\n );\r\n if (!basketResponse?.basket_id && !basketResponse?.basketId) {\r\n console.error(\"Failed to create basket\");\r\n return;\r\n }\r\n console.log(\r\n \"setting stored id\",\r\n basketResponse?.basket_id || basketResponse?.basketId\r\n );\r\n // else if (basketResponse?.basketId) {\r\n // toast.success(`Added to cart`, {\r\n // position: \"bottom-right\",\r\n // autoClose: 3000,\r\n // hideProgressBar: false,\r\n // closeOnClick: true,\r\n // pauseOnHover: true,\r\n // draggable: true,\r\n // });\r\n // }\r\n setStoredBasketId(\r\n basketResponse?.basket_id || basketResponse?.basketId\r\n );\r\n // Add product to new basket\r\n // if (!import.meta.env.VITE_SCAPI_ENVIRONMENT) {\r\n console.log(\"adding product to basket\");\r\n const response = await addProductToBasket(\r\n basketResponse?.basket_id || basketResponse?.basketId,\r\n productData,\r\n customer_token\r\n );\r\n console.log(\"object added to basket\");\r\n if (\r\n response?.product_items?.length > 0 ||\r\n response?.productItems?.length > 0\r\n ) {\r\n toast.success(`Added to cart`, {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n hideProgressBar: false,\r\n closeOnClick: true,\r\n pauseOnHover: true,\r\n draggable: true,\r\n });\r\n }\r\n notifySFCC(basketResponse.basket_id || basketResponse?.basketId);\r\n // }\r\n } else {\r\n // Use existing customer_token and basket ID\r\n const basketId = getStoredBasketId();\r\n if (!basketId) {\r\n console.error(\"No basket ID found\");\r\n return;\r\n }\r\n\r\n const response = await addProductToBasket(\r\n basketId,\r\n productData,\r\n customer_token\r\n );\r\n if (response?.product_items?.length > 0) {\r\n toast.success(`Added to cart`, {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n hideProgressBar: false,\r\n closeOnClick: true,\r\n pauseOnHover: true,\r\n draggable: true,\r\n });\r\n notifySFCC(basketId);\r\n }\r\n }\r\n } catch (error: any) {\r\n console.error(\"Error adding to cart:\", error);\r\n toast.error(\"Failed to add product to cart\", {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n });\r\n\r\n if (\r\n error?.response?.status === 404 || // Basket not found\r\n error?.response?.status === 401 // Unauthorized/expired\r\n ) {\r\n // Clear only basket ID for 404\r\n if (error?.response?.status === 404) {\r\n setStoredBasketId(null);\r\n }\r\n // Clear both for 401\r\n if (error?.response?.status === 401) {\r\n setStoredBasketId(null);\r\n setStoredToken(null);\r\n }\r\n } else {\r\n console.error(\"Failed to add product to basket:\", error.message);\r\n toast.error(\"Failed to add product to cart\", {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n });\r\n }\r\n } finally {\r\n notifySFCC();\r\n }\r\n };\r\n\r\n // Function to generate and redirect to the product detail page\r\n const viewMore = () => {\r\n if (!product) return;\r\n\r\n window.location.href = product.c_pdpUrl; //redirect to sfcc product details url\r\n };\r\n console.log(product, \"the prod\");\r\n return (\r\n <>\r\n <div\r\n className=\"fixed inset-0 z-40 bg-black/30\"\r\n onClick={() => {\r\n setShow(false);\r\n setTimeout(() => dispatch(setProduct(null)), ANIMATION_DURATION);\r\n }}\r\n />\r\n <div\r\n className={`\r\n flex flex-col gap-2 items-center h-[90vh] absolute right-0 bottom-0 z-50 w-full md:w-1/2 md:h-[100vh] lg:w-1/2 lg:h-[100vh] shadow-xl p-2 border-l-2 bg-white border-gray-200 overflow-y-scroll\r\n transition-all duration-300\r\n ${\r\n show\r\n ? \"translate-y-0 md:translate-y-0 md:translate-x-0 opacity-100\"\r\n : \"translate-y-full md:translate-y-0 md:translate-x-full opacity-0 pointer-events-none\"\r\n }\r\n `}\r\n style={{ willChange: \"transform, opacity\" }}\r\n // Prevent click inside card from closing\r\n onClick={(e) => e.stopPropagation()}\r\n >\r\n {/* name and close button */}\r\n <div className=\"mt-3 flex flex-row justify-between w-full \">\r\n <div>\r\n <p className=\"text-[#000000] font-bold font-nunitoSans\">\r\n {product.name}\r\n </p>\r\n </div>\r\n <div>\r\n <Icon\r\n icon=\"mdi:close\"\r\n className=\"text-[#555555] w-6 h-6 cursor-pointer\"\r\n onClick={() => {\r\n setShow(false);\r\n setTimeout(\r\n () => dispatch(setProduct(null)),\r\n ANIMATION_DURATION\r\n );\r\n }}\r\n />\r\n </div>\r\n </div>\r\n {/* image and variants */}\r\n <div className=\"flex flex-row gap-2 items-center flex-wrap\">\r\n <div className=\"flex flex-row items-center justify-center w-[120px] h-[120px] my-5\">\r\n <img\r\n src={\r\n import.meta.env.VITE_SCAPI_ENVIRONMENT\r\n ? product.imageGroups?.[0]?.images?.[0]?.link\r\n : product.image_groups?.[0]?.images?.[0]?.link ||\r\n \"https://via.placeholder.com/120\"\r\n }\r\n alt={product.name}\r\n className=\"rounded-[10px]\"\r\n />\r\n </div>\r\n <div className=\"flex flex-col items-center gap-2\">\r\n {(import.meta.env.VITE_SCAPI_ENVIRONMENT\r\n ? product.imageGroups\r\n : product.image_groups\r\n )\r\n .slice(1, 2)\r\n .map((group: any) =>\r\n group.images.slice(1, 2).map((image: any) => (\r\n <img\r\n key={image.link}\r\n src={image.link}\r\n alt={product.name}\r\n className=\"rounded-[10px] w-[60px] h-[60px]\"\r\n />\r\n ))\r\n )}\r\n </div>\r\n </div>\r\n {/* price and discount */}\r\n <div className=\"flex flex-row items-center justify-between w-full\">\r\n <div className=\"flex flex-row items-center gap-2\">\r\n <p className=\"text-[#14121F] font-bold font-nunitoSans\">\r\n {\" \"}\r\n ${product.price.toFixed(2)}\r\n </p>{\" \"}\r\n <p className=\"text-[#14121F] font-normal line-through text-sm font-nunitoSans\">\r\n {\" \"}\r\n ${(product.price + 5).toFixed(2)}\r\n </p>\r\n </div>\r\n <div>\r\n <p className=\"text-[#EC5050] font-bold font-nunitoSans\">\r\n {product.discount}\r\n </p>\r\n </div>\r\n </div>\r\n {/* horizontal line */}\r\n <div className=\"mt-2 w-full border-t-2 border-gray-200\"></div>\r\n <div className=\"w-full text-left\">\r\n <div className=\"text-[#323135] font-bold font-nunitoSans mt-3 text-[14px]\">\r\n Product Details\r\n </div>\r\n <div\r\n className=\"text-[#68656E] font-normal font-nunitoSans text-xs pl-2 mt-3\"\r\n dangerouslySetInnerHTML={{ __html: product.short_description || product.longDescription }}\r\n ></div>\r\n </div>\r\n {/* rating and reviews */}\r\n <div className=\"mt-4 flex flex-col gap-2 w-full p-2\">\r\n <div className=\"flex flex-row items-center gap-2\">\r\n <div className=\"flex items-center gap-2 text-left font-nunitoSans\">\r\n <div className=\"text-[#323135] font-bold\">\r\n {product?.rating?.rate || 0} /{\" \"}\r\n <span className=\"text-[#68656E]\">5</span>\r\n </div>\r\n <div className=\"text-[#323135] font-semibold text-sm\">\r\n Overall Rating\r\n </div>\r\n <div className=\"text-[#68656E] font-semibold text-sm\">\r\n {product?.rating?.count || 0} ratings\r\n </div>\r\n </div>\r\n </div>\r\n <div className=\"mt-2 flex flex-row items-center gap-2\">\r\n {Array.from({ length: 5 }).map((_, index) => (\r\n <Icon\r\n key={index}\r\n icon=\"mdi:star\"\r\n width=\"20\"\r\n height=\"20\"\r\n className={`text-yellow-500 \r\n ${\r\n product?.rating?.rate > index\r\n ? \"text-yellow-500\"\r\n : \"text-gray-300\"\r\n }\r\n `}\r\n />\r\n ))}\r\n </div>\r\n </div>\r\n\r\n <div\r\n className=\"flex flex-col items-center justify-between font-nunitoSans font-semibold w-5/6 text-black gap-2\"\r\n style={{ marginTop: \"150px\" }}\r\n >\r\n <button\r\n className=\"rounded-[5px] shadow-sm text-[#FBFBFC] bg-[#6851C6] p-2 w-full text-center cursor-pointer\"\r\n style={{ backgroundColor: storeDetails.tanyaThemeColor }}\r\n onClick={addToCart}\r\n >\r\n Add to Cart\r\n </button>\r\n <button\r\n className=\"rounded-[5px] shadow-sm text-[#FBFBFC] bg-[#6851C6] p-2 w-full text-center cursor-pointer mb-16\"\r\n style={{ backgroundColor: storeDetails.tanyaThemeColor }}\r\n onClick={viewMore}\r\n >\r\n View more\r\n </button>\r\n </div>\r\n </div>\r\n </>\r\n );\r\n};\r\n\r\nexport default ProductDisplayCard;\r\n","/* eslint-disable @typescript-eslint/no-explicit-any */\r\nimport { useState, useRef, useEffect } from \"react\";\r\nimport { Popover, PopoverTrigger } from \"../ui/popover\";\r\n// import tanyaChatBotIcon from \"@/assets/tanya-chatbot/chat-with-tanya.png\";\r\n// import { getAccessToken } from \"../utils/getAccessToken\";\r\nimport { getInterestApi, getProductById, getSearchResults } from \"../utils\";\r\nimport type { SearchProduct } from \"../graphQL/queries/types\";\r\nimport {\r\n // decryptData,\r\n // currencyFormatter,\r\n formatStringToHtml,\r\n // priceFormatter,\r\n} from \"../utils/helper\";\r\nimport ProductDisplay from \"../carousel/ProductDisplay\";\r\nimport { useSelector } from \"react-redux\";\r\nimport ProductDisplayCard from \"../product/ProductDisplayCard\";\r\nimport { toast } from \"react-toastify\";\r\nimport { notifySFCC } from \"../lib/utils\";\r\nimport { addProductToBasket, createBasket, fetchBasket } from \"../api/api\";\r\nimport { fetchTokenBmGrant } from \"../utils/fetchTokenBmGrant\";\r\nimport { fetchExistingGuestCustomerToken } from \"../utils/fetchExistingRegisterCustomerToken\";\r\nimport { TOKEN_EXPIRY_KEY, VERSION } from \"../../config/constant\";\r\nimport {\r\n getStoredBasketId,\r\n setStoredBasketId,\r\n setStoredToken,\r\n} from \"../utils/localStorage\";\r\nimport { authData } from \"../../sfcc-apis/session\";\r\n\r\ntype ProductSnapshot = {\r\n id: string;\r\n name: string;\r\n image: string | null;\r\n price: number | null;\r\n points: number;\r\n quantity: number;\r\n};\r\n\r\nconst TanyaShoppingAssistantStream = () => {\r\n // Shopping options\r\n const shoppingOptions = [\r\n \"Myself\",\r\n \"My Child\",\r\n \"My Grandchild\",\r\n \"Niece/Nephew\",\r\n \"My Friends\",\r\n \"Others\",\r\n ];\r\n\r\n const payloadMapping: Record<string, string> = {\r\n Myself: \"himself/herself\",\r\n \"My Child\": \"his/her child\",\r\n \"My Grandchild\": \"his/her grandchild\",\r\n \"Niece/Nephew\": \"his/her niece/nephew\",\r\n \"My Friends\": \"his/her friends\",\r\n Others: \"others\",\r\n };\r\n const productName = useRef<string | null>(null);\r\n const productId = useRef<number | null>(null);\r\n const productImage = useRef<string | null>(null);\r\n const productPrice = useRef<number | null>(null);\r\n const [authDetails, setAuthDetails] = useState<any>(null);\r\n\r\n const [isOpen, setIsOpen] = useState(\r\nfalse\r\n );\r\n const [isAnimating, setIsAnimating] = useState(false);\r\n const [isVisible, setIsVisible] = useState(false);\r\n const [adding, setAdding] = useState<boolean>(false);\r\n const [isLoading, setIsLoading] = useState(false);\r\n const [productLoading, setProductLoading] = useState(false);\r\n const [inputText, setInputText] = useState(\"\");\r\n const [whom, setWhom] = useState(\"\");\r\n const mapSnapshotToProduct = (snap: ProductSnapshot): any => ({\r\n id: snap.id,\r\n title: snap.name,\r\n image: snap.image ?? \"\",\r\n price: snap.price ?? 0,\r\n });\r\n // const dispatch = useDispatch();\r\n\r\n const [chatHistory, setChatHistory] = useState<\r\n {\r\n query: string;\r\n response: string;\r\n potentialQuestions: string;\r\n products?: { keyword: string; items: SearchProduct[] }[];\r\n keywords: string;\r\n noResults?: boolean;\r\n secondaryResponse?: string;\r\n secondaryLoading?: boolean;\r\n productSnapshot?: ProductSnapshot; // NEW\r\n }[]\r\n >([]);\r\n const scrollRef = useRef<HTMLDivElement>(null);\r\n // const storeCode =\r\n // searchParams.get(\"storeCode\") || localStorage.getItem(\"storeCode\");\r\n const storeDetails = useSelector((s: any) => s.store.store);\r\n const product = useSelector((s: any) => s.product.product);\r\n\r\n const openPanel = () => {\r\n setIsVisible(true);\r\n setTimeout(() => setIsAnimating(true), 10); // trigger opening animation\r\n };\r\n\r\n const closePanel = () => {\r\n setIsAnimating(false);\r\n setTimeout(() => setIsVisible(false), 300); // // wait for exit animation\r\n };\r\n\r\n useEffect(() => {\r\n if (isOpen) openPanel();\r\n else closePanel();\r\n }, [isOpen]);\r\n\r\n const handleWhomSelection = (selected: string) => {\r\n setWhom(payloadMapping[selected]);\r\n };\r\n\r\n useEffect(() => {\r\n if (scrollRef.current) {\r\n scrollRef.current.scrollTop += 150; // Scrolls down by 50px\r\n }\r\n }, [chatHistory]);\r\n\r\n let cachedToken: any = null;\r\n let tokenExpiry: any = null;\r\n\r\n const getJWTToken = async () => {\r\n if (cachedToken && tokenExpiry && Date.now() < tokenExpiry) {\r\n return cachedToken;\r\n }\r\n\r\n try {\r\n const tokenUrl =\r\n \"https://us-east-1lsr29ln3u.auth.us-east-1.amazoncognito.com/oauth2/token\";\r\n\r\n const tokenPayload = new URLSearchParams({\r\n grant_type: \"client_credentials\",\r\n client_id: \"4i8rd70sgt961tc4dhskgf08c\",\r\n client_secret: \"bnsfq1220loh2cn2cm2ttn8fdhdpt0u8m1fgj8vfk2rn61aurjg\",\r\n scope: \"default-m2m-resource-server-8xzfzo/read\",\r\n });\r\n\r\n const tokenResponse = await fetch(tokenUrl, {\r\n method: \"POST\",\r\n headers: {\r\n \"Content-Type\": \"application/x-www-form-urlencoded\",\r\n },\r\n body: tokenPayload,\r\n });\r\n\r\n if (!tokenResponse.ok) {\r\n throw new Error(\r\n `Token request failed! status: ${tokenResponse.status}`\r\n );\r\n }\r\n\r\n const tokenData = await tokenResponse.json();\r\n\r\n // Cache the token\r\n cachedToken = tokenData.access_token;\r\n const expiresIn = tokenData.expires_in || 3600; // Default to 1 hour\r\n tokenExpiry = Date.now() + (expiresIn - 60) * 1000; // Refresh 1 minute before expiry\r\n\r\n return cachedToken;\r\n } catch (error) {\r\n console.error(\"Error obtaining JWT token:\", error);\r\n // Clear cache on error\r\n cachedToken = null;\r\n tokenExpiry = null;\r\n return null;\r\n }\r\n };\r\n\r\n const getAuthDetails = async () => {\r\n const data = await authData(); // <- calls your async function\r\n if (data == null) return;\r\n setAuthDetails(data); // <- saves the result in state\r\n };\r\n\r\n useEffect(() => {\r\n if (import.meta.env.VITE_SCAPI_ENVIRONMENT) {\r\n getAuthDetails();\r\n console.log(\"scapi environment v1\");\r\n } else {\r\n console.log(\"ocapi environment\");\r\n }\r\n }, []);\r\n\r\n const getInterests = async () => {\r\n const customer_id = JSON.parse(\r\n sessionStorage.getItem(\"customerData\") || \"{}\"\r\n ).customerId;\r\n const res = await getInterestApi(customer_id || \"\");\r\n return res.c_interests;\r\n };\r\n\r\n const runSecondaryFlow = async (productTitle: string, points: number) => {\r\n console.log(\"in secondary flow\", VERSION);\r\n const interests = await getInterests();\r\n console.log(interests, \"interests of customer\", VERSION);\r\n if (!interests) return;\r\n try {\r\n // surprise animation\r\n setChatHistory((prev) =>\r\n prev.map((msg, idx) =>\r\n idx === prev.length - 1 ? { ...msg, secondaryLoading: true } : msg\r\n )\r\n );\r\n\r\n const accessToken = await getJWTToken();\r\n if (!accessToken) throw new Error(\"Failed to fetch token\");\r\n\r\n const user = localStorage.getItem(\"customerNumber\");\r\n const isLoggedIn = localStorage.getItem(\"isLoggedIn\");\r\n const queryParams = new URLSearchParams({\r\n registered: String(isLoggedIn || false),\r\n userId: String(user || new Date().getTime()),\r\n });\r\n const invokeUrl = `https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${queryParams.toString()}`;\r\n\r\n const payload = JSON.stringify({\r\n flowId: \"Q166PR519W\",\r\n flowAliasId: \"HKFUVLWVH2\",\r\n input: {\r\n loyaltyPoints: \"\",\r\n productName: productTitle,\r\n productPoints: String(points || 0),\r\n interests: interests,\r\n },\r\n });\r\n\r\n const response = await fetch(invokeUrl, {\r\n signal: AbortSignal.timeout(30000),\r\n method: \"POST\",\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n Authorization: `Bearer ${accessToken}`,\r\n },\r\n body: payload,\r\n });\r\n\r\n if (!response.body) throw new Error(\"Readable stream not supported\");\r\n\r\n const reader = response.body.getReader();\r\n const decoder = new TextDecoder();\r\n let buffer = \"\";\r\n\r\n while (true) {\r\n const { done, value } = await reader.read();\r\n if (done) break;\r\n buffer += decoder.decode(value, { stream: true });\r\n const lines = buffer.split(\"\\n\");\r\n buffer = lines.pop() || \"\";\r\n\r\n for (const line of lines) {\r\n if (line.startsWith(\"data:\")) {\r\n const jsonData = line.slice(5).trim();\r\n try {\r\n const parsedData = JSON.parse(jsonData);\r\n\r\n if (parsedData.index === 0) {\r\n // attach response & stop animation\r\n setChatHistory((prev) =>\r\n prev.map((msg, idx) =>\r\n idx === prev.length - 1\r\n ? {\r\n ...msg,\r\n secondaryResponse: parsedData.data,\r\n secondaryLoading: false,\r\n }\r\n : msg\r\n )\r\n );\r\n }\r\n // ignore 1/2/3\r\n } catch (e) {\r\n // stop animation on parse error too\r\n setChatHistory((prev) =>\r\n prev.map((msg, idx) =>\r\n idx === prev.length - 1\r\n ? { ...msg, secondaryLoading: false }\r\n : msg\r\n )\r\n );\r\n console.error(\"Secondary flow JSON parse error:\", e);\r\n }\r\n }\r\n }\r\n }\r\n } catch (e) {\r\n console.error(\"Secondary flow error:\", e);\r\n }\r\n };\r\n\r\n const handleSendMessage = async (question?: string) => {\r\n const newQuery = question || inputText.trim();\r\n if (!newQuery) return;\r\n\r\n setIsLoading(true);\r\n setInputText(\"\");\r\n\r\n productName.current = null;\r\n productId.current = null;\r\n productImage.current = null;\r\n productPrice.current = null;\r\n\r\n setChatHistory((prev) => [\r\n ...prev,\r\n {\r\n query: newQuery,\r\n response: \"Thinking for what suits you best...\",\r\n potentialQuestions: \"\",\r\n products: [],\r\n keywords: \"Thinking for best products...\",\r\n },\r\n ]);\r\n\r\n try {\r\n const sanitizedWhom = whom;\r\n const user = localStorage.getItem(\"customerNumber\");\r\n const isLoggedIn = localStorage.getItem(\"isLoggedIn\");\r\n\r\n // Get JWT access token\r\n const accessToken = await getJWTToken();\r\n if (!accessToken) {\r\n throw new Error(\"Failed to obtain access token\");\r\n }\r\n\r\n // Build the invoke flow URL\r\n const queryParams = new URLSearchParams({\r\n registered: String(isLoggedIn || false),\r\n userId: String(user || new Date().getTime()),\r\n });\r\n\r\n const invokeUrl = `https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${queryParams.toString()}`;\r\n\r\n const payload = JSON.stringify({\r\n flowId: \"MMHQKYI1NE\",\r\n flowAliasId: \"SZF9ZK1ATE\",\r\n input: {\r\n userPrompt: newQuery,\r\n whom: sanitizedWhom,\r\n },\r\n });\r\n\r\n const response = await fetch(invokeUrl, {\r\n signal: AbortSignal.timeout(30000),\r\n method: \"POST\",\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n Authorization: `Bearer ${accessToken}`,\r\n },\r\n body: payload,\r\n });\r\n\r\n if (!response.ok) {\r\n throw new Error(`HTTP error! status: ${response.status}`);\r\n }\r\n\r\n if (!response.body) throw new Error(\"Readable stream not supported\");\r\n\r\n const reader = response.body.getReader();\r\n const decoder = new TextDecoder();\r\n let buffer = \"\";\r\n let keywords = \"\";\r\n\r\n while (true) {\r\n setProductLoading(true);\r\n const { done, value } = await reader.read();\r\n if (done) break;\r\n\r\n buffer += decoder.decode(value, { stream: true });\r\n const lines = buffer.split(\"\\n\");\r\n buffer = lines.pop() || \"\";\r\n\r\n for (const line of lines) {\r\n if (line.startsWith(\"data:\")) {\r\n const jsonData = line.slice(5).trim();\r\n try {\r\n const parsedData = JSON.parse(jsonData);\r\n if (parsedData.index == 1) keywords = parsedData.data;\r\n\r\n setChatHistory((prev) =>\r\n prev.map((msg, idx) =>\r\n idx === prev.length - 1\r\n ? {\r\n ...msg,\r\n [parsedData.index == 0\r\n ? \"response\"\r\n : parsedData.index == 1\r\n ? \"keywords\"\r\n : parsedData.index == 2\r\n ? \"potentialQuestions\"\r\n : \"end\"]: parsedData.data,\r\n }\r\n : msg\r\n )\r\n );\r\n } catch (error) {\r\n console.error(\"Error parsing JSON:\", error);\r\n }\r\n }\r\n }\r\n }\r\n getKeywords(sanitizeKeywords(keywords));\r\n } catch (error) {\r\n console.error(\"Error sending message to Tanya:\", error);\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n const sanitizeKeywords = (response: string) => {\r\n const keywordMatch = response.match(\r\n /top five relevant product or category names are: (.*)/i\r\n );\r\n const keywordsString = keywordMatch ? keywordMatch[1] : response;\r\n const keywordsArray = keywordsString.split(\", \");\r\n const sanitizedKeywords = keywordsArray.map((keyword) => {\r\n return keyword.replace(/\\s*(Toys|Bags|Miniature|etc\\.*)\\s*/gi, \"\").trim();\r\n });\r\n const uniqueKeywords = [...new Set(sanitizedKeywords)].filter(Boolean);\r\n return uniqueKeywords.join(\",\");\r\n };\r\n\r\n const getKeywords = async (keywords: string[] | string) => {\r\n console.log(authDetails?.access_token, \"access_token\");\r\n if (typeof keywords === \"string\") {\r\n console.log(keywords, \"keywords\");\r\n const splitedKeywords = keywords.split(\",\");\r\n for (const keyword of splitedKeywords) {\r\n const results = await getSearchResults(\r\n keyword,\r\n authDetails?.access_token\r\n );\r\n setProductLoading(false);\r\n if (results?.length > 0) {\r\n setChatHistory((prev) =>\r\n prev.map((msg, idx) =>\r\n idx === prev.length - 1\r\n ? {\r\n ...msg,\r\n products: [\r\n ...(msg.products || []),\r\n { keyword: keyword, items: results, loading: false },\r\n ],\r\n }\r\n : msg\r\n )\r\n );\r\n if (!productName.current || productId.current == null) {\r\n const first = results[0] as any;\r\n productName.current = String(first?.product_name ?? \"\");\r\n productImage.current = first.image.link;\r\n productId.current = first.product_id;\r\n\r\n // price\r\n const priceVal =\r\n typeof first?.price === \"number\" ? first.price : undefined;\r\n\r\n productPrice.current =\r\n typeof priceVal === \"number\" && Number.isFinite(priceVal)\r\n ? priceVal\r\n : null;\r\n }\r\n }\r\n }\r\n } else {\r\n for (const keyword of keywords) {\r\n const results = await getSearchResults(\r\n keyword,\r\n authDetails?.access_token\r\n );\r\n setProductLoading(false);\r\n if (results?.length > 0) {\r\n setChatHistory((prev) =>\r\n prev.map((msg, idx) =>\r\n idx === prev.length - 1\r\n ? {\r\n ...msg,\r\n products: [\r\n ...(msg.products || []),\r\n { keyword: keyword, items: results, loading: false },\r\n ],\r\n }\r\n : msg\r\n )\r\n );\r\n }\r\n }\r\n }\r\n if (productName.current) {\r\n setChatHistory((prev: any) =>\r\n prev.map((msg: any, idx: number) =>\r\n idx === prev.length - 1\r\n ? {\r\n ...msg,\r\n productSnapshot: {\r\n id: productId.current,\r\n name: productName.current,\r\n image: productImage.current,\r\n price: productPrice.current ?? null,\r\n points: 0,\r\n quantity: 1,\r\n },\r\n }\r\n : msg\r\n )\r\n );\r\n const customerData = JSON.parse(\r\n sessionStorage.getItem(\"customerData\") || \"{}\"\r\n );\r\n if (customerData?.isGuest == false) {\r\n console.log(\"running secondary flow\", VERSION);\r\n runSecondaryFlow(productName.current, 0);\r\n } else {\r\n console.log(\"not running secondary flow\", VERSION);\r\n }\r\n }\r\n setProductLoading(false);\r\n };\r\n\r\n const handleAddToCart = async (productToBeAdded: any, quantity: number) => {\r\n setAdding(true);\r\n try {\r\n const product = await getProductById(productToBeAdded.id);\r\n if (\r\n !(\r\n product?.variants?.[0]?.product_id ||\r\n product?.variants?.[0]?.productId\r\n ) &&\r\n !(product.type.item || product.type.bundle)\r\n ) {\r\n setAdding(false);\r\n toast.error(\"Variants not found\", {\r\n position: \"bottom-right\",\r\n autoClose: 1000,\r\n });\r\n console.error(\"No product variant found\");\r\n return;\r\n }\r\n\r\n const productData = [\r\n {\r\n product_id:\r\n product.variants?.[0].product_id ||\r\n product.variants?.[0].productId ||\r\n product?.id,\r\n quantity: quantity,\r\n },\r\n ];\r\n console.log(productData, \"product data\", \"app version\", VERSION);\r\n // for getting customer id\r\n const customerData = JSON.parse(\r\n sessionStorage.getItem(\"customerData\") || \"{}\"\r\n );\r\n const basketIdFromCustomer = customerData?.basketId;\r\n const customer_token = false;\r\n const tokenExpiry = localStorage.getItem(TOKEN_EXPIRY_KEY);\r\n const currentTime = Date.now();\r\n\r\n // If no token, get a new one\r\n if (\r\n !customer_token ||\r\n !tokenExpiry ||\r\n currentTime >= parseInt(tokenExpiry)\r\n ) {\r\n const access_token = await fetchTokenBmGrant();\r\n\r\n let { customer_token } = await fetchExistingGuestCustomerToken(\r\n access_token\r\n );\r\n if (import.meta.env.VITE_SCAPI_ENVIRONMENT) {\r\n customer_token = \"Bearer \" + authDetails.access_token;\r\n }\r\n if (!customer_token) {\r\n console.error(\"Failed to get customer_token\");\r\n return;\r\n }\r\n const newExpiryTime = currentTime + 5 * 60 * 1000;\r\n setStoredToken(customer_token);\r\n localStorage.setItem(TOKEN_EXPIRY_KEY, newExpiryTime.toString());\r\n\r\n // 1. Try basketId from customerData\r\n if (basketIdFromCustomer) {\r\n const fetchBasketResponse = await fetchBasket({\r\n basketId: basketIdFromCustomer,\r\n customer_token,\r\n });\r\n if (fetchBasketResponse.status === 200 && fetchBasketResponse) {\r\n // Use this basketId to add product\r\n\r\n const response = await addProductToBasket(\r\n basketIdFromCustomer,\r\n productData,\r\n customer_token\r\n );\r\n if (response?.product_items?.length > 0) {\r\n // const addedProduct = response.product_items.at(-1);\r\n toast.success(`Added to cart`, {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n hideProgressBar: false,\r\n closeOnClick: true,\r\n pauseOnHover: true,\r\n draggable: true,\r\n });\r\n notifySFCC(basketIdFromCustomer);\r\n setAdding(false);\r\n // window.location.reload();\r\n }\r\n return; // Skip basket creation\r\n }\r\n }\r\n\r\n // 2. If not valid, create new basket and store its ID in localStorage\r\n const data = {\r\n productItems: [\r\n {\r\n productId:\r\n product.variants?.[0].product_id ||\r\n product.variants?.[0].productId ||\r\n product?.id,\r\n quantity: 1,\r\n },\r\n ],\r\n };\r\n const basketResponse = await createBasket(customer_token, data);\r\n console.log(\r\n basketResponse,\r\n basketResponse?.basket_id,\r\n basketResponse?.basketId,\r\n \"the basket response\"\r\n );\r\n if (!(basketResponse?.basket_id || !basketResponse?.basketId)) {\r\n setAdding(false);\r\n console.error(\"Failed to create basket\");\r\n return;\r\n }\r\n // else if (basketResponse?.basketId) {\r\n // toast.success(`Added to cart`, {\r\n // position: \"bottom-right\",\r\n // autoClose: 3000,\r\n // hideProgressBar: false,\r\n // closeOnClick: true,\r\n // pauseOnHover: true,\r\n // draggable: true,\r\n // });\r\n // }\r\n\r\n // Store new basket ID\r\n setStoredBasketId(\r\n basketResponse?.basket_id || basketResponse?.basketId\r\n );\r\n // Add product to new basket\r\n // if (!import.meta.env.VITE_SCAPI_ENVIRONMENT) {\r\n const response = await addProductToBasket(\r\n basketResponse?.basket_id || basketResponse?.basketId,\r\n productData,\r\n customer_token\r\n );\r\n if (\r\n response?.product_items?.length > 0 ||\r\n response?.productItems?.length > 0\r\n ) {\r\n toast.success(`Added to cart`, {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n hideProgressBar: false,\r\n closeOnClick: true,\r\n pauseOnHover: true,\r\n draggable: true,\r\n });\r\n }\r\n notifySFCC(basketResponse.basket_id || basketResponse?.basketId);\r\n // }\r\n } else {\r\n // Use existing customer_token and basket ID\r\n const basketId = getStoredBasketId();\r\n if (!basketId) {\r\n console.error(\"No basket ID found\");\r\n setAdding(false);\r\n return;\r\n }\r\n\r\n const response = await addProductToBasket(\r\n basketId,\r\n productData,\r\n customer_token\r\n );\r\n if (response?.product_items?.length > 0) {\r\n toast.success(`Added to cart`, {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n hideProgressBar: false,\r\n closeOnClick: true,\r\n pauseOnHover: true,\r\n draggable: true,\r\n });\r\n setAdding(false);\r\n notifySFCC(basketId);\r\n }\r\n }\r\n } catch (error: any) {\r\n setAdding(false);\r\n console.error(\"Error adding to cart:\", error);\r\n toast.error(\"Failed to add product to cart\", {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n });\r\n\r\n if (\r\n error?.response?.status === 404 || // Basket not found\r\n error?.response?.status === 401 // Unauthorized/expired\r\n ) {\r\n // Clear only basket ID for 404\r\n if (error?.response?.status === 404) {\r\n setStoredBasketId(null);\r\n }\r\n // Clear both for 401\r\n if (error?.response?.status === 401) {\r\n setStoredBasketId(null);\r\n setStoredToken(null);\r\n }\r\n } else {\r\n console.error(\"Failed to add product to basket:\", error.message);\r\n toast.error(\"Failed to add product to cart\", {\r\n position: \"bottom-right\",\r\n autoClose: 3000,\r\n });\r\n }\r\n } finally {\r\n notifySFCC();\r\n }\r\n setAdding(false);\r\n };\r\n\r\n // Update the main container div's className\r\n return (\r\n <div className=\"relative flex justify-center\">\r\n <Popover open={isOpen} onOpenChange={setIsOpen}>\r\n <PopoverTrigger\r\n onClick={() => setIsOpen(true)}\r\n style={\r\n {\r\n // background: storeDetails.tanyaThemeColor,\r\n }\r\n }\r\n className=\"flex items-center rounded-lg cursor-pointer hover:opacity-90 transition-opacity\"\r\n >\r\n <div className=\"flex flex-col p-[5px]\">\r\n <svg\r\n width=\"40\"\r\n height=\"40\"\r\n viewBox=\"0 0 40 40\"\r\n fill=\"none\"\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n >\r\n <g clipPath=\"url(#clip0_958_585)\">\r\n <path\r\n d=\"M30.0002 5C31.7683 5 33.464 5.70238 34.7142 6.95262C35.9644 8.20286 36.6668 9.89856 36.6668 11.6667V25C36.6668 26.7681 35.9644 28.4638 34.7142 29.714C33.464 30.9643 31.7683 31.6667 30.0002 31.6667H25.6902L21.1785 36.1783C20.8915 36.4653 20.5097 36.6377 20.1046 36.6631C19.6996 36.6886 19.2992 36.5654 18.9785 36.3167L18.8218 36.1783L14.3085 31.6667H10.0002C8.28976 31.6667 6.64478 31.0093 5.40548 29.8305C4.16617 28.6516 3.42735 27.0416 3.34183 25.3333L3.3335 25V11.6667C3.3335 9.89856 4.03588 8.20286 5.28612 6.95262C6.53636 5.70238 8.23205 5 10.0002 5H30.0002Z\"\r\n fill=\"url(#paint0_linear_958_585)\"\r\n />\r\n <path\r\n d=\"M28.3335 15.6511V11.6667C28.3335 11.6667 22.2774 12.6042 20.1148 15.4167C17.9521 18.2292 18.6644 26.6667 18.6644 26.6667H22.5321C22.5321 26.6667 22.0614 18.9323 23.4989 17.2917C24.9364 15.6511 28.3335 15.6511 28.3335 15.6511Z\"\r\n fill=\"white\"\r\n />\r\n <path\r\n d=\"M13.3335 11.6667H19.6184V15.4167H13.3335V11.6667Z\"\r\n fill=\"white\"\r\n />\r\n </g>\r\n <defs>\r\n <linearGradient\r\n id=\"paint0_linear_958_585\"\r\n x1=\"20.0002\"\r\n y1=\"5\"\r\n x2=\"35.0002\"\r\n y2=\"30\"\r\n gradientUnits=\"userSpaceOnUse\"\r\n >\r\n <stop stopColor=\"#452697\" />\r\n <stop offset=\"1\" stopColor=\"#7C5BFF\" />\r\n </linearGradient>\r\n <clipPath id=\"clip0_958_585\">\r\n <rect width=\"40\" height=\"40\" fill=\"white\" />\r\n </clipPath>\r\n </defs>\r\n </svg>\r\n </div>\r\n </PopoverTrigger>\r\n\r\n {/* Absolute Positioned PopoverContent and Custom Sidebar Panel */}\r\n {isVisible && (\r\n <>\r\n {/* Overlay For closing tanya popup by clicking on side or background */}\r\n <div\r\n className=\"fixed inset-0 z-40 bg-black/30\"\r\n onClick={() => setIsOpen(false)}\r\n />\r\n <div\r\n className={`\r\n fixed z-50 h-screen w-[100vw] sm:w-[80vw] md:w-[770px] border-0 bg-white lg:rounded-l-xl overflow-hidden flex flex-col shadow-[0px_4px_10px_0px_#5F499840]\r\n top-0 right-0\r\n transition-transform duration-300 ease-in-out\r\n lg:transform\r\n ${isAnimating ? \"lg:translate-x-0\" : \"lg:translate-x-full\"}\r\n // For mobile: animate from bottom\r\n ${isAnimating ? \"translate-y-0\" : \"translate-y-full\"}\r\n lg:translate-y-0\r\n `}\r\n style={{\r\n background:\r\n \"linear-gradient(170.1deg, #FFFFFF 60.03%, #E3DEEF 99.59%)\",\r\n }}\r\n >\r\n {/* Header */}\r\n <div\r\n className={`flex justify-between p-3 bg-[#FFFFFF] border border-b-1 border-[#E5E5E5] `} //lg:rounded-tl-xl lg:rounded-bl-xl\r\n >\r\n <div\r\n style={{\r\n display: \"flex\",\r\n color: storeDetails.tanyaThemeContrastColor,\r\n alignItems: \"center\",\r\n gap: \"0.5rem\",\r\n }}\r\n >\r\n <div className=\"flex flex-col gap-1\">\r\n <div\r\n className=\"flex gap-2 w-28 h-12 text-center items-center p-2 border rounded-l-[20px] rounded-tr-[20px]\"\r\n style={{\r\n background:\r\n \"linear-gradient(265.62deg, #6851C6 5.24%, #8668FF 98.49%)\",\r\n }}\r\n >\r\n <svg\r\n width=\"20\"\r\n height=\"20\"\r\n viewBox=\"0 0 15 16\"\r\n fill=\"none\"\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n >\r\n <path\r\n d=\"M15 4.48438V0.5C15 0.5 8.94395 1.4375 6.78127 4.25C4.61859 7.0625 5.33095 15.5 5.33095 15.5H9.19857C9.19857 15.5 8.72793 7.76562 10.1654 6.125C11.6029 4.48438 15 4.48438 15 4.48438Z\"\r\n fill=\"white\"\r\n />\r\n <path d=\"M0 0.5H6.28488V4.25H0V0.5Z\" fill=\"white\" />\r\n </svg>\r\n\r\n <p className=\"text-[#FFFFFF] font-nunitoSans font-semibold\">\r\n TANYA\r\n </p>\r\n </div>\r\n <p\r\n className=\"text-[#5B5B5B] font-nunitoSans font-semibold\"\r\n style={{ fontStyle: \"italic\" }}\r\n >\r\n {\" \"}\r\n Your AI shopping assistant !{\" \"}\r\n </p>\r\n </div>\r\n </div>\r\n <div\r\n style={{\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n gap: \"1.25rem\",\r\n margin: \"0.75rem\",\r\n }}\r\n >\r\n {/* close icon */}\r\n <button onClick={() => setIsOpen(false)}>\r\n <svg\r\n width=\"24\"\r\n height=\"25\"\r\n viewBox=\"0 0 24 25\"\r\n fill=\"none\"\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n >\r\n <g clipPath=\"url(#clip0_501_6036)\">\r\n <path\r\n d=\"M18 6.5L6 18.5\"\r\n stroke=\"#555555\"\r\n strokeWidth=\"1.5\"\r\n strokeLinecap=\"round\"\r\n strokeLinejoin=\"round\"\r\n />\r\n <path\r\n d=\"M6 6.5L18 18.5\"\r\n stroke=\"#555555\"\r\n strokeWidth=\"1.5\"\r\n strokeLinecap=\"round\"\r\n strokeLinejoin=\"round\"\r\n />\r\n </g>\r\n <defs>\r\n <clipPath id=\"clip0_501_6036\">\r\n <rect\r\n width=\"24\"\r\n height=\"24\"\r\n fill=\"white\"\r\n transform=\"translate(0 0.5)\"\r\n />\r\n </clipPath>\r\n </defs>\r\n </svg>\r\n </button>\r\n </div>\r\n </div>\r\n\r\n {/* Chat Container */}\r\n <div className={`flex h-full md:flex-row lg:flex-row`}>\r\n <div\r\n className={`flex flex-col h-full ${\r\n product ? \"lg:w-2/3 w-full\" : \"w-full\"\r\n }`}\r\n >\r\n {/* Chat Body - Scrollable */}\r\n <div\r\n ref={scrollRef}\r\n className=\"overflow-y-auto pr-5 pb-2 space-y-4 hide-scrollbar flex-grow mb-24\"\r\n >\r\n {/* Shopping Options */}\r\n {storeDetails?.whomRequired && (\r\n <div\r\n className=\"mx-3 p-3 rounded-2xl bg-[#FFFFFF]\"\r\n // style={{\r\n // color: storeDetails?.tanyaThemeContrastColor,\r\n // backgroundColor: storeDetails.tanyaThemeColor, //need to comment\r\n // width: \"fit-content\",\r\n // }}\r\n >\r\n <div className=\"flex gap-2 bg-[#FFFFFF]\">\r\n {/* <Icon\r\n icon=\"mdi:shopping\"\r\n color=\"white\"\r\n width=\"22\"\r\n height=\"22\"\r\n /> */}\r\n <p className=\"font-bold font-nunitoSans text-[#494949]\">\r\n Is this for you or someone else?\r\n </p>\r\n </div>\r\n\r\n <div className=\"flex flex-wrap gap-2 mt-2\">\r\n {shoppingOptions.map((option) => (\r\n <button\r\n key={option}\r\n onClick={() => handleWhomSelection(option)}\r\n className=\"px-2 py-2 font-semibold text-xs text-[#18181B] bg-[#F3F3F3] rounded-2xl\"\r\n style={{\r\n backgroundColor:\r\n whom === payloadMapping[option]\r\n ? \"#FFFFFF\"\r\n : \"#F3F3F3\",\r\n borderColor:\r\n whom === payloadMapping[option]\r\n ? \"#BBB3DD\"\r\n : \"\",\r\n }}\r\n >\r\n {option}\r\n </button>\r\n ))}\r\n </div>\r\n </div>\r\n )}\r\n {/* Chat History */}\r\n {chatHistory.map((chat, index) => (\r\n <div key={index}>\r\n <div className=\"flex justify-end\">\r\n <p className=\"text-sm font-nunitoSans font-bold text-[#000000] bg-[#E2DBFF] border border-[#C9C2DE] rounded-l-xl p-2 m-3 mb-4 rounded-br-xl max-w-[75%]\">\r\n {chat.query}\r\n </p>\r\n </div>\r\n {chat.response && chat.response.includes(\"Thinking\") ? (\r\n <div>\r\n <div\r\n className=\"font-nunitoSans animate-pulse font-bold text-sm text-[#494949] bg-[#FFFFFF] px-7 py-1 rounded-r-xl rounded-bl-2xl w-full\"\r\n dangerouslySetInnerHTML={{\r\n __html: formatStringToHtml(chat.response),\r\n }}\r\n />\r\n </div>\r\n ) : (\r\n <div>\r\n <div\r\n className=\"font-nunitoSans font-bold text-sm text-[#494949] bg-[#FFFFFF] px-7 py-1 rounded-r-xl rounded-bl-2xl w-full\"\r\n dangerouslySetInnerHTML={{\r\n __html: formatStringToHtml(chat.response),\r\n }}\r\n />\r\n </div>\r\n )}\r\n {productLoading &&\r\n !chat.response.includes(\"Thinking\") &&\r\n chat.products?.length == 0 && (\r\n <div>\r\n <p className=\"text-sm animate-pulse font-nunitoSans font-bold text-[#000000] bg-[#E2DBFF] border border-[#C9C2DE] rounded-l-xl p-2 m-3 mb-4 rounded-br-xl max-w-[75%]\">\r\n Finding best products for you\r\n </p>\r\n </div>\r\n )}\r\n {chat?.products && chat?.products?.length > 0 && (\r\n <ProductDisplay\r\n chat={chat.products}\r\n storeDetails={storeDetails}\r\n />\r\n )}\r\n\r\n {/* Potential Questions */}\r\n {chat.potentialQuestions.length > 0 && (\r\n <div className=\"my-2 px-4 text-sm text-gray-700\">\r\n <p\r\n className=\"font-nunitoSans font-bold text-sm text-[#494949]\"\r\n style={{ color: storeDetails.themeDarkColor }}\r\n >\r\n Why not explore these inquiries...\r\n </p>\r\n {chat.potentialQuestions\r\n .split(\",\")\r\n .map((question, idx) => (\r\n <button\r\n key={idx}\r\n className={`cursor-pointer font-nunitoSans font-semibold text-[#232323] border bg-[#804C9E0D] border-${storeDetails.themeDarkColor} m-1 rounded-xl px-2 py-1`}\r\n onClick={() => handleSendMessage(question)}\r\n style={{\r\n backgroundColor:\r\n storeDetails.tanyaThemeColorLight,\r\n }}\r\n >\r\n {question}\r\n </button>\r\n ))}\r\n </div>\r\n )}\r\n\r\n {chat.secondaryLoading && (\r\n <div className=\"mt-3 mb-4 px-4\">\r\n <div\r\n className=\"tanya-surprise-wrapper bg-indigo-300 text-sm px-7 py-4 rounded-r-xl rounded-bl-2xl w-full relative overflow-hidden\"\r\n style={{\r\n margin: \"0.75rem\",\r\n }}\r\n >\r\n <div className=\"flex gap-1\">\r\n <div className=\"tanya-sparkle tanya-sparkle-1\">\r\n ✨\r\n </div>\r\n <div className=\"tanya-sparkle tanya-sparkle-2\">\r\n ✨\r\n </div>\r\n <div className=\"tanya-sparkle tanya-sparkle-3\">\r\n ✨\r\n </div>\r\n </div>\r\n <div className=\"tanya-shimmer\" />\r\n <p\r\n className=\"font-semibold tanya-pulse\"\r\n style={{ color: storeDetails.themeDarkColor }}\r\n >\r\n I’ve found a special surprise crafted just for\r\n you… hang on a sec!\r\n </p>\r\n <p\r\n className=\"tanya-dots mt-1\"\r\n style={{ color: storeDetails.themeDarkColor }}\r\n >\r\n • • •\r\n </p>\r\n </div>\r\n </div>\r\n )}\r\n\r\n {/* Secondary Response (from secondary flow) */}\r\n {chat.secondaryResponse && (\r\n <>\r\n <div className=\"mt-3 mb-8 px-4 bg-indigo-300 rounded-tr-[5px]\">\r\n {/* Chat Response */}\r\n <div\r\n className=\"text-sm text-[#232323] bg-[#FFFFFF] px-7 py-4 rounded-br-xl rounded-bl-2xl w-full\"\r\n style={{\r\n backgroundColor:\r\n storeDetails.tanyaThemeColorLight,\r\n }}\r\n dangerouslySetInnerHTML={{\r\n __html: formatStringToHtml(\r\n chat.secondaryResponse\r\n ),\r\n }}\r\n />\r\n {chat.productSnapshot && (\r\n // chat.productSnapshot.points > 0 &&\r\n <div className=\"mt-4 w-full\">\r\n <div\r\n className=\"flex gap-4 items-stretch rounded-2xl p-4\"\r\n style={{\r\n backgroundColor:\r\n storeDetails.tanyaThemeColorLight,\r\n }}\r\n >\r\n <div\r\n className=\"flex-shrink-0 rounded-xl overflow-hidden border\"\r\n style={{\r\n width: 112,\r\n height: 112,\r\n borderColor: \"#eee\",\r\n }}\r\n >\r\n {chat.productSnapshot.image ? (\r\n <img\r\n src={chat.productSnapshot.image}\r\n alt={chat.productSnapshot.name}\r\n className=\"w-full h-full object-cover\"\r\n />\r\n ) : (\r\n <div className=\"w-full h-full flex items-center justify-center text-xs text-gray-500\">\r\n No Image\r\n </div>\r\n )}\r\n </div>\r\n\r\n <div className=\"flex flex-col flex-1 justify-between\">\r\n <div>\r\n <p className=\"font-semibold text-[15px] leading-snug\">\r\n {chat.productSnapshot.name}\r\n </p>\r\n <p className=\"mt-1 text-[14px] font-medium\">\r\n {chat.productSnapshot.price != null\r\n ? new Intl.NumberFormat(undefined, {\r\n style: \"currency\",\r\n currency:\r\n storeDetails?.currency ||\r\n \"USD\",\r\n }).format(\r\n chat.productSnapshot.price\r\n )\r\n : \"\"}\r\n </p>\r\n\r\n {chat.productSnapshot.points > 0 && (\r\n <p className=\"mt-1 text-xs opacity-80\">\r\n You will earn{\" \"}\r\n <strong>\r\n {chat.productSnapshot.points}{\" \"}\r\n points\r\n </strong>\r\n </p>\r\n )}\r\n </div>\r\n\r\n <div className=\"mt-3 flex items-center gap-3\">\r\n <div className=\"flex items-center border rounded-full overflow-hidden\">\r\n <button\r\n className=\"px-3 py-1 text-sm\"\r\n onClick={() =>\r\n setChatHistory((prev) =>\r\n prev.map((m, i) =>\r\n i === index &&\r\n m.productSnapshot\r\n ? {\r\n ...m,\r\n productSnapshot: {\r\n ...m.productSnapshot,\r\n quantity: Math.max(\r\n 1,\r\n m.productSnapshot\r\n .quantity - 1\r\n ),\r\n },\r\n }\r\n : m\r\n )\r\n )\r\n }\r\n style={{\r\n background: \"transparent\",\r\n color:\r\n storeDetails.themeDarkColor,\r\n }}\r\n >\r\n −\r\n </button>\r\n <div className=\"px-3 py-1 text-sm select-none\">\r\n {chat.productSnapshot.quantity}\r\n </div>\r\n <button\r\n className=\"px-3 py-1 text-sm\"\r\n onClick={() =>\r\n setChatHistory((prev) =>\r\n prev.map((m, i) =>\r\n i === index &&\r\n m.productSnapshot\r\n ? {\r\n ...m,\r\n productSnapshot: {\r\n ...m.productSnapshot,\r\n quantity:\r\n m.productSnapshot\r\n .quantity + 1,\r\n },\r\n }\r\n : m\r\n )\r\n )\r\n }\r\n style={{\r\n background: \"transparent\",\r\n color:\r\n storeDetails.themeDarkColor,\r\n }}\r\n >\r\n +\r\n </button>\r\n </div>\r\n <button\r\n onClick={() => {\r\n handleAddToCart(\r\n mapSnapshotToProduct(\r\n chat.productSnapshot!\r\n ),\r\n chat.productSnapshot!.quantity\r\n );\r\n }}\r\n disabled={adding}\r\n className=\"px-4 py-2 rounded-full font-medium\"\r\n style={{\r\n background:\r\n storeDetails.tanyaThemeColor,\r\n color:\r\n storeDetails?.tanyaThemeContrastColor ||\r\n \"#fff\",\r\n opacity: adding ? 0.8 : 1,\r\n }}\r\n >\r\n {adding ? \"Adding...\" : \"Add to cart\"}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n )}\r\n </div>\r\n </>\r\n )}\r\n <div className=\"mb-20\"></div>\r\n </div>\r\n ))}\r\n </div>\r\n\r\n {/* Sticky Bottom Input Bar */}\r\n <div className=\"flex flex-col gap-2 sticky bottom-0 left-0 right-0 bg-[#E3DEEF] z-50 px-4 py-2\">\r\n {/* Gradient Border Wrapper */}\r\n <div\r\n className=\"p-[1px] rounded-xl\"\r\n style={{\r\n background:\r\n \"linear-gradient(180deg, #B09FFF 0%, #8D79F6 100%)\",\r\n }}\r\n >\r\n {/* Input + Mic + Submit */}\r\n <div className=\"flex items-center bg-[#FFFFFF] flex-1 rounded-xl px-2 py-1\">\r\n <input\r\n className=\"flex-1 bg-[#FFFFFF] text-[#232323] outline-none border-none px-2 py-2 text-sm\"\r\n placeholder=\"How can I help you...\"\r\n value={inputText}\r\n autoFocus\r\n onChange={(e) => setInputText(e.target.value)}\r\n onKeyDown={(e) => {\r\n if (e.key === \"Enter\" && !isLoading)\r\n handleSendMessage();\r\n }}\r\n />\r\n {/* Mic Icon */}\r\n {/* <button\r\n type=\"button\"\r\n className=\"p-2 text-[#959595] hover:text-[#6952C7]\"\r\n >\r\n <svg\r\n width=\"20\"\r\n height=\"20\"\r\n viewBox=\"0 0 20 20\"\r\n fill=\"none\"\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n >\r\n <g clipPath=\"url(#clip0_501_6086)\">\r\n <path\r\n d=\"M7.5 4.16663C7.5 3.50358 7.76339 2.8677 8.23223 2.39886C8.70107 1.93002 9.33696 1.66663 10 1.66663C10.663 1.66663 11.2989 1.93002 11.7678 2.39886C12.2366 2.8677 12.5 3.50358 12.5 4.16663V8.33329C12.5 8.99633 12.2366 9.63222 11.7678 10.1011C11.2989 10.5699 10.663 10.8333 10 10.8333C9.33696 10.8333 8.70107 10.5699 8.23223 10.1011C7.76339 9.63222 7.5 8.99633 7.5 8.33329V4.16663Z\"\r\n stroke=\"#959595\"\r\n strokeLinecap=\"round\"\r\n strokeLinejoin=\"round\"\r\n />\r\n <path\r\n d=\"M4.1665 8.33337C4.1665 9.88047 4.78109 11.3642 5.87505 12.4582C6.96901 13.5521 8.45274 14.1667 9.99984 14.1667C11.5469 14.1667 13.0307 13.5521 14.1246 12.4582C15.2186 11.3642 15.8332 9.88047 15.8332 8.33337\"\r\n stroke=\"#959595\"\r\n strokeLinecap=\"round\"\r\n strokeLinejoin=\"round\"\r\n />\r\n <path\r\n d=\"M6.6665 17.5H13.3332\"\r\n stroke=\"#959595\"\r\n strokeLinecap=\"round\"\r\n strokeLinejoin=\"round\"\r\n />\r\n <path\r\n d=\"M10 14.1666V17.5\"\r\n stroke=\"#959595\"\r\n strokeLinecap=\"round\"\r\n strokeLinejoin=\"round\"\r\n />\r\n </g>\r\n <defs>\r\n <clipPath id=\"clip0_501_6086\">\r\n <rect width=\"20\" height=\"20\" fill=\"white\" />\r\n </clipPath>\r\n </defs>\r\n </svg>\r\n </button> */}\r\n {/* Submit Button */}\r\n <button\r\n type=\"submit\"\r\n disabled={isLoading}\r\n className=\"p-3\"\r\n onClick={() => handleSendMessage()}\r\n >\r\n {isLoading ? (\r\n <div\r\n className=\"p-3 animate-spin rounded-full h-3 w-3 border-b-2\"\r\n style={{\r\n borderBottom: \"2px solid\",\r\n color: storeDetails.tanyaThemeColor,\r\n }}\r\n />\r\n ) : (\r\n <svg\r\n width=\"20\"\r\n height=\"20\"\r\n viewBox=\"0 0 20 20\"\r\n fill=\"none\"\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n >\r\n <path\r\n d=\"M16.6357 13.6701L18.3521 8.5208C19.8516 4.02242 20.6013 1.77322 19.414 0.585948C18.2268 -0.601312 15.9776 0.148418 11.4792 1.64788L6.32987 3.36432C2.69923 4.57453 0.883923 5.17964 0.368062 6.06698C-0.122688 6.91112 -0.122688 7.95369 0.368062 8.7978C0.883923 9.6852 2.69923 10.2903 6.32987 11.5005C6.77981 11.6505 7.28601 11.5434 7.62294 11.2096L13.1286 5.75495C13.4383 5.44808 13.9382 5.45041 14.245 5.76015C14.5519 6.06989 14.5496 6.56975 14.2398 6.87662L8.8231 12.2432C8.4518 12.6111 8.3342 13.1742 8.4995 13.6701C9.7097 17.3007 10.3148 19.1161 11.2022 19.6319C12.0463 20.1227 13.0889 20.1227 13.933 19.6319C14.8204 19.1161 15.4255 17.3008 16.6357 13.6701Z\"\r\n fill=\"#6952C7\"\r\n />\r\n </svg>\r\n )}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <ProductDisplayCard />\r\n </div>\r\n {/* </PopoverContent> */}\r\n </div>\r\n </>\r\n )}\r\n </Popover>\r\n </div>\r\n );\r\n};\r\n\r\nexport default TanyaShoppingAssistantStream;\r\n\r\n// ${import.meta.env.VITE_SERVER_BASE_URL}api/web-bff/assistantStream\r\n"],"names":["notifySFCC","basketId","event","Popover","props","PopoverPrimitive","PopoverTrigger","apiConfig","fetchTokenBmGrant","URL","response","axios","getHost","getSiteId","error","fetchExistingGuestCustomerToken","access_token","dwsid","clientId","shortCode","organisationId","authData","expires_in","isGuest","serverUrl","customerMail","endpoint","res","err","getSearchResults","query","token","basePath","host","getProductById","id","getInterestApi","customerId","customer_token","displayData","data","imageUrlArray","image","currencyFormatter","currencyCode","priceFormatter","_a","_b","_c","initialCapital","text","stringReducer","length","formatStringToHtml","str","line","index","numberedPoint","getIconsTree","names","icons","aliases","resolved","resolve","name","parent","value","defaultIconDimensions","defaultIconTransformations","defaultIconProps","defaultExtendedIconProps","mergeIconTransformations","obj1","obj2","result","rotate","mergeIconData","child","key","internalGetIconData","tree","currentProps","parse","name$1","parseIconSet","callback","item","optionalPropertyDefaults","checkOptionalProps","defaults","prop","quicklyValidateIconSet","obj","icon","dataStorage","newStorage","provider","prefix","getStorage","providerStorage","addIconSet","storage","addIconToStorage","matchIconName","stringToIcon","validate","allowSimpleName","colonSeparated","validateIconName","dashSeparated","simpleNames","allowSimpleNames","allow","getIconData","iconName","addIcon","addCollection","added","defaultIconSizeCustomisations","defaultIconCustomisations","unitsSplit","unitsTest","calculateSize","size","ratio","precision","oldParts","newParts","code","isNumber","num","splitSVGDefs","content","tag","defs","start","end","endEnd","mergeDefsAndContent","wrapSVGContent","body","split","isUnsetKeyword","iconToSVG","customisations","fullIcon","fullCustomisations","box","transformations","hFlip","vFlip","rotation","tempValue","customisationsWidth","customisationsHeight","boxWidth","boxHeight","width","height","attributes","setAttr","viewBox","regex","randomPrefix","counter","replaceIDs","ids","match","suffix","newID","escapedID","setAPIModule","getAPIModule","createAPIConfig","source","resources","configStorage","fallBackAPISources","fallBackAPI","addAPIProvider","customConfig","config","getAPIConfig","detectFetch","fetchModule","calculateMaxLength","maxHostLength","url","shouldAbort","status","prepare","results","maxLength","type","getPath","send","params","path","iconsList","urlParams","uri","defaultError","fetchAPIModule","removeCallback","storages","items","row","updateCallbacks","hasPending","oldLength","idCounter","storeCallback","pendingSources","abort","sortIcons","a","b","lastIcon","localStorage","list","listToIcons","defaultConfig","sendQuery","payload","done","resourcesCount","startIndex","nextIndex","startTime","queriesSent","lastError","timer","queue","doneCallbacks","resetTimer","subscribe","overwrite","getQueryStatus","failQuery","clearQueue","moduleResponse","isError","queued","execNext","resource","status$1","initRedundancy","cfg","queries","cleanup","queryCallback","doneCallback","query$1","find","emptyCallback$1","redundancyCache","getRedundancyCache","redundancy","cachedReundancy","sendAPIQuery","target","api","cached","moduleKey","emptyCallback","loadedNewIcons","checkIconNamesForAPI","valid","invalid","parseLoaderResponse","checkMissing","pending","parsePossiblyAsyncResponse","loadNewIcons","icons$1","customIconLoader","iconSet","loadIcons","cleanedIcons","sortedIcons","callCallback","newIcons","sources","lastProvider","lastPrefix","providerNewIcons","pendingQueue","mergeCustomisations","valueType","separator","flipFromString","custom","flip","rotateFromString","defaultValue","units","value$1","iconToHTML","renderAttribsHTML","attr","encodeSVGforURL","svg","svgToData","svgToURL","policy","createPolicy","s","cleanUpInnerHTML","html","defaultExtendedIconCustomisations","svgDefaults","commonProps","monotoneProps","coloredProps","propsToAdd","propsToAddTo","inlineDefaults","fixSize","render","defaultProps","mode","style","customStyle","componentProps","classNames","renderAttribs","localCounter","createElement","useMask","_window","preload","providers","IconComponent","mounted","setMounted","useState","setAbort","getInitialState","state","setState","changeState","newState","updateState","useEffect","Icon","forwardRef","ref","initialState","productSlice","createSlice","action","setProduct","useResponsiveProductsPerPage","getProductsPerPage","productsPerPage","setProductsPerPage","handleResize","ProductCarousel","product","dispatch","useDispatch","setStartIndex","nextProducts","prevIndex","prevProducts","getProduct","jsxs","jsx","prod","_d","ProductDisplay","chat","storeDetails","products","i","createBasket","addProductToBasket","fetchBasket","BASKET_ID_KEY","TOKEN_KEY","TOKEN_EXPIRY_KEY","EXPIRY_TIME","VERSION","setStoredBasketId","setStoredToken","expiryTime","ANIMATION_DURATION","ProductDisplayCard","useSelector","show","setShow","addToCart","toast","productData","_e","_f","customerData","basketIdFromCustomer","tokenExpiry","currentTime","authDetails","newExpiryTime","fetchBasketResponse","_i","_j","basketResponse","_k","_l","_m","_n","_o","_p","viewMore","Fragment","e","group","_","TanyaShoppingAssistantStream","shoppingOptions","payloadMapping","productName","useRef","productId","productImage","productPrice","setAuthDetails","isOpen","setIsOpen","isAnimating","setIsAnimating","isVisible","setIsVisible","adding","setAdding","isLoading","setIsLoading","productLoading","setProductLoading","inputText","setInputText","whom","setWhom","mapSnapshotToProduct","snap","chatHistory","setChatHistory","scrollRef","openPanel","closePanel","handleWhomSelection","selected","cachedToken","getJWTToken","tokenUrl","tokenPayload","tokenResponse","tokenData","expiresIn","getAuthDetails","getInterests","customer_id","runSecondaryFlow","productTitle","points","interests","prev","msg","idx","accessToken","user","isLoggedIn","invokeUrl","reader","decoder","buffer","lines","jsonData","parsedData","handleSendMessage","question","newQuery","sanitizedWhom","keywords","getKeywords","sanitizeKeywords","keywordMatch","sanitizedKeywords","keyword","splitedKeywords","first","priceVal","handleAddToCart","productToBeAdded","quantity","option","m"],"mappings":"4pBAOaA,GAAcC,GAAsB,CAC/C,MAAMC,EAAQ,IAAI,YAAY,mBAAoB,CAChD,OAAQ,CACN,YAAa,GACb,SAAAD,CAAA,CAGF,CACD,EACD,OAAO,cAAcC,CAAK,CAC5B,ECVA,SAASC,GAAQ,CACf,GAAGC,CACL,EAAuD,CACrD,aAAQC,GAAiB,KAAjB,CAAsB,YAAU,UAAW,GAAGD,EAAO,CAC/D,CAEA,SAASE,GAAe,CACtB,GAAGF,CACL,EAA0D,CACxD,aAAQC,GAAiB,QAAjB,CAAyB,YAAU,kBAAmB,GAAGD,EAAO,CAC1E,CCyGO,MAAMG,GAAY,KAOhB,CAAE,kBANiB,uFAME,QALZ,2CAKqB,UAHnB,wCAG8B,SAFU,QAEV,GC3HrCC,GAAoB,SAAY,CAC3C,MAAMC,EAAM,wCACZ,GAAI,CACF,MAAMC,EAAW,MAAMC,EAAM,KAC3B,GAAGF,CAAG,mCAAmCG,IAAS,WAAWC,GAAW,EAAA,EAE1E,OAAIH,EAAS,SAAW,KAAOA,EAAS,KAAK,aACpCA,EAAS,KAAK,cAErB,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