{"version":3,"file":"ProductTileSearchResults.YtpxU-QN.min.js","sources":["../frontend/src/stories/client/ProductTileSearch/ProductTileSearchResults.tsx"],"sourcesContent":["import React, {useEffect, useState} from \"react\";\nimport helpers from \"../../../../js/helpers\";\nimport useMobileBreakpoint from \"@mindarc/arctheme-components/frontend/src/hooks/useMobileBreakpoint\";\n\nexport const ProductTileSearchResults = ({\n product,\n swatches = [],\n siblings,\n show_add = false,\n show_price_inline = false,\n settings,\n enableWishlist,\n type = ''\n }) => {\n const isMobile = useMobileBreakpoint(\"1024px\");\n const currencyCode = window.Alpine?.store('currency').getCurrencyCode();\n const currencySymbol = window.Alpine?.store('currency').getCurrencySymbol();\n\n // Helper function to get price by currency code\n const getPriceByCurrency = (priceRanges, currency, type) => {\n const priceEntry = priceRanges?.find((item) => item.price.currency_code === currency);\n return priceEntry[`${type}`]?.amount || 0; // Convert to proper price format\n };\n\n // Default prices from compare_at_price and price\n let minPrice = product?.price > 0 ? product?.price / 100 : 0;\n let maxPrice = product?.compare_at_price > 0 ? product?.compare_at_price / 100 : 0;\n\n // If presentment_price_ranges exist, extract prices for the current currency\n if (product?.variants[0]?.presentment_prices) {\n const presentmentMinPrice = getPriceByCurrency(product?.variants[0]?.presentment_prices, currencyCode, \"price\");\n const presentmentMaxPrice = getPriceByCurrency(product?.variants[0]?.presentment_prices, currencyCode, \"compare_at_price\");\n\n // Use presentment prices only if they are available\n minPrice = presentmentMinPrice ?? minPrice;\n maxPrice = presentmentMaxPrice ?? maxPrice;\n }\n\n // Ensure that compare_at_price is treated as a \"strike-through price\" if higher\n const isOnSale = minPrice > 0 && minPrice < maxPrice;\n\n return (\n <>\n \n
\n
\n \n
\n
\n
\n \n {product.title}\n
\n
\n
\n {isOnSale ? (\n <>\n Special Price\n
\n {currencyCode} {currencySymbol}{minPrice.toFixed(0)}\n
\n \n ) : (\n <>\n Regular Price\n
\n {currencyCode} {currencySymbol}{minPrice.toFixed(0)}\n
\n \n )}\n
\n
\n
\n {swatches.map((swatch) => (\n \n ))}\n
\n
\n {show_add && (\n {\n }}\n >\n Add to Cart\n \n )}\n {enableWishlist && (\n {\n }}\n >\n Add to Wishlist\n \n )}\n
\n
\n
\n \n
\n \n );\n};\n"],"names":["ProductTileSearchResults","product","swatches","siblings","show_add","show_price_inline","settings","enableWishlist","type","useMobileBreakpoint","currencyCode","_a","currencySymbol","_b","getPriceByCurrency","priceRanges","currency","item","minPrice","maxPrice","_c","presentmentMinPrice","_d","presentmentMaxPrice","_e","isOnSale","jsx","Fragment","jsxs","swatch"],"mappings":"0QAIO,MAAMA,EAA2B,CAAC,CACT,QAAAC,EACA,SAAAC,EAAW,CAAC,EACZ,SAAAC,EACA,SAAAC,EAAW,GACX,kBAAAC,EAAoB,GACpB,SAAAC,EACA,eAAAC,EACA,KAAAC,EAAO,EACX,IAAM,eACbC,EAAoB,QAAQ,EAC7C,MAAMC,GAAgBC,EAAA,OAAO,SAAP,YAAAA,EAAe,MAAM,YAAY,kBACjDC,GAAkBC,EAAA,OAAO,SAAP,YAAAA,EAAe,MAAM,YAAY,oBAGnDC,EAAqB,CAACC,EAAaC,EAAUR,IAAS,OAExD,QAAOG,GADYI,GAAA,YAAAA,EAAa,KAAME,GAASA,EAAK,MAAM,gBAAkBD,IAC1D,GAAGR,CAAI,EAAE,IAApB,YAAAG,EAAuB,SAAU,CAAA,EAI5C,IAAIO,GAAWjB,GAAA,YAAAA,EAAS,OAAQ,GAAIA,GAAA,YAAAA,EAAS,OAAQ,IAAM,EACvDkB,GAAWlB,GAAA,YAAAA,EAAS,kBAAmB,GAAIA,GAAA,YAAAA,EAAS,kBAAmB,IAAM,EAGjF,IAAImB,EAAAnB,GAAA,YAAAA,EAAS,SAAS,KAAlB,MAAAmB,EAAsB,mBAAoB,CACpC,MAAAC,EAAsBP,GAAmBQ,EAAArB,GAAA,YAAAA,EAAS,SAAS,KAAlB,YAAAqB,EAAsB,mBAAoBZ,EAAc,OAAO,EACxGa,EAAsBT,GAAmBU,EAAAvB,GAA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