@anker-in/headless-ui 1.0.20-alpha.1761126577041 → 1.0.20-alpha.1761134202138

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.
Files changed (103) hide show
  1. package/dist/cjs/biz-components/Listing/ProductProvider.d.ts +57 -1
  2. package/dist/cjs/biz-components/Listing/ProductProvider.js +1 -1
  3. package/dist/cjs/biz-components/Listing/ProductProvider.js.map +3 -3
  4. package/dist/cjs/biz-components/Listing/components/PaidShipping/LearnMore.d.ts +2 -0
  5. package/dist/cjs/biz-components/Listing/components/PaidShipping/LearnMore.js +2 -0
  6. package/dist/cjs/biz-components/Listing/components/PaidShipping/LearnMore.js.map +7 -0
  7. package/dist/cjs/biz-components/Listing/components/PaidShipping/ShippingMethod.d.ts +10 -0
  8. package/dist/cjs/biz-components/Listing/components/PaidShipping/ShippingMethod.js +2 -0
  9. package/dist/cjs/biz-components/Listing/components/PaidShipping/ShippingMethod.js.map +7 -0
  10. package/dist/cjs/biz-components/Listing/components/PaidShipping/ShippingPolicyModal.d.ts +25 -0
  11. package/dist/cjs/biz-components/Listing/components/PaidShipping/ShippingPolicyModal.js +2 -0
  12. package/dist/cjs/biz-components/Listing/components/PaidShipping/ShippingPolicyModal.js.map +7 -0
  13. package/dist/cjs/biz-components/Listing/components/PaidShipping/index.d.ts +12 -0
  14. package/dist/cjs/biz-components/Listing/components/PaidShipping/index.js +2 -0
  15. package/dist/cjs/biz-components/Listing/components/PaidShipping/index.js.map +7 -0
  16. package/dist/cjs/biz-components/Listing/components/PaidShipping/type.d.ts +30 -0
  17. package/dist/cjs/biz-components/Listing/components/PaidShipping/type.js +2 -0
  18. package/dist/cjs/biz-components/Listing/components/PaidShipping/type.js.map +7 -0
  19. package/dist/cjs/biz-components/Listing/components/PaidShipping/utils.d.ts +2 -0
  20. package/dist/cjs/biz-components/Listing/components/PaidShipping/utils.js +2 -0
  21. package/dist/cjs/biz-components/Listing/components/PaidShipping/utils.js.map +7 -0
  22. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.d.ts +40 -0
  23. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js +22 -0
  24. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js.map +7 -0
  25. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/index.js +1 -1
  26. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/index.js.map +2 -2
  27. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductFreeGift/index.js +1 -1
  28. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductFreeGift/index.js.map +2 -2
  29. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/index.js +1 -1
  30. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/index.js.map +3 -3
  31. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGallery/index.js +1 -1
  32. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGallery/index.js.map +2 -2
  33. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductSummary/index.js +1 -1
  34. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductSummary/index.js.map +2 -2
  35. package/dist/cjs/biz-components/Listing/hooks/useBenefits.d.ts +50 -0
  36. package/dist/cjs/biz-components/Listing/hooks/useBenefits.js +2 -0
  37. package/dist/cjs/biz-components/Listing/hooks/useBenefits.js.map +7 -0
  38. package/dist/cjs/biz-components/Listing/hooks/useCopy.d.ts +3 -6
  39. package/dist/cjs/biz-components/Listing/hooks/useCopy.js +1 -1
  40. package/dist/cjs/biz-components/Listing/hooks/useCopy.js.map +3 -3
  41. package/dist/cjs/biz-components/Listing/index.js +1 -1
  42. package/dist/cjs/biz-components/Listing/index.js.map +3 -3
  43. package/dist/cjs/biz-components/Listing/utils/helper.d.ts +15 -0
  44. package/dist/cjs/biz-components/Listing/utils/helper.js +1 -1
  45. package/dist/cjs/biz-components/Listing/utils/helper.js.map +3 -3
  46. package/dist/cjs/biz-components/Listing/utils/textFormat.d.ts +73 -0
  47. package/dist/cjs/biz-components/Listing/utils/textFormat.js +2 -0
  48. package/dist/cjs/biz-components/Listing/utils/textFormat.js.map +7 -0
  49. package/dist/cjs/biz-components/index.d.ts +2 -0
  50. package/dist/cjs/biz-components/index.js +1 -1
  51. package/dist/cjs/biz-components/index.js.map +3 -3
  52. package/dist/esm/biz-components/Listing/ProductProvider.d.ts +57 -1
  53. package/dist/esm/biz-components/Listing/ProductProvider.js +1 -1
  54. package/dist/esm/biz-components/Listing/ProductProvider.js.map +3 -3
  55. package/dist/esm/biz-components/Listing/components/PaidShipping/LearnMore.d.ts +2 -0
  56. package/dist/esm/biz-components/Listing/components/PaidShipping/LearnMore.js +2 -0
  57. package/dist/esm/biz-components/Listing/components/PaidShipping/LearnMore.js.map +7 -0
  58. package/dist/esm/biz-components/Listing/components/PaidShipping/ShippingMethod.d.ts +10 -0
  59. package/dist/esm/biz-components/Listing/components/PaidShipping/ShippingMethod.js +2 -0
  60. package/dist/esm/biz-components/Listing/components/PaidShipping/ShippingMethod.js.map +7 -0
  61. package/dist/esm/biz-components/Listing/components/PaidShipping/ShippingPolicyModal.d.ts +25 -0
  62. package/dist/esm/biz-components/Listing/components/PaidShipping/ShippingPolicyModal.js +2 -0
  63. package/dist/esm/biz-components/Listing/components/PaidShipping/ShippingPolicyModal.js.map +7 -0
  64. package/dist/esm/biz-components/Listing/components/PaidShipping/index.d.ts +12 -0
  65. package/dist/esm/biz-components/Listing/components/PaidShipping/index.js +2 -0
  66. package/dist/esm/biz-components/Listing/components/PaidShipping/index.js.map +7 -0
  67. package/dist/esm/biz-components/Listing/components/PaidShipping/type.d.ts +30 -0
  68. package/dist/esm/biz-components/Listing/components/PaidShipping/type.js +2 -0
  69. package/dist/esm/biz-components/Listing/components/PaidShipping/type.js.map +7 -0
  70. package/dist/esm/biz-components/Listing/components/PaidShipping/utils.d.ts +2 -0
  71. package/dist/esm/biz-components/Listing/components/PaidShipping/utils.js +2 -0
  72. package/dist/esm/biz-components/Listing/components/PaidShipping/utils.js.map +7 -0
  73. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.d.ts +40 -0
  74. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js +22 -0
  75. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js.map +7 -0
  76. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/index.js +1 -1
  77. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/index.js.map +2 -2
  78. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductFreeGift/index.js +1 -1
  79. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductFreeGift/index.js.map +2 -2
  80. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/index.js +1 -1
  81. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/index.js.map +3 -3
  82. package/dist/esm/biz-components/Listing/components/ProductCard/ProductGallery/index.js +1 -1
  83. package/dist/esm/biz-components/Listing/components/ProductCard/ProductGallery/index.js.map +2 -2
  84. package/dist/esm/biz-components/Listing/components/ProductCard/ProductSummary/index.js +1 -1
  85. package/dist/esm/biz-components/Listing/components/ProductCard/ProductSummary/index.js.map +2 -2
  86. package/dist/esm/biz-components/Listing/hooks/useBenefits.d.ts +50 -0
  87. package/dist/esm/biz-components/Listing/hooks/useBenefits.js +2 -0
  88. package/dist/esm/biz-components/Listing/hooks/useBenefits.js.map +7 -0
  89. package/dist/esm/biz-components/Listing/hooks/useCopy.d.ts +3 -6
  90. package/dist/esm/biz-components/Listing/hooks/useCopy.js +1 -1
  91. package/dist/esm/biz-components/Listing/hooks/useCopy.js.map +3 -3
  92. package/dist/esm/biz-components/Listing/index.js +1 -1
  93. package/dist/esm/biz-components/Listing/index.js.map +3 -3
  94. package/dist/esm/biz-components/Listing/utils/helper.d.ts +15 -0
  95. package/dist/esm/biz-components/Listing/utils/helper.js +1 -1
  96. package/dist/esm/biz-components/Listing/utils/helper.js.map +3 -3
  97. package/dist/esm/biz-components/Listing/utils/textFormat.d.ts +73 -0
  98. package/dist/esm/biz-components/Listing/utils/textFormat.js +2 -0
  99. package/dist/esm/biz-components/Listing/utils/textFormat.js.map +7 -0
  100. package/dist/esm/biz-components/index.d.ts +2 -0
  101. package/dist/esm/biz-components/index.js +1 -1
  102. package/dist/esm/biz-components/index.js.map +2 -2
  103. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/biz-components/Listing/components/ProductCard/ProductGallery/index.tsx"],
4
- "sourcesContent": ["import { useAiuiContext } from '../../../../AiuiProvider/index.js'\nimport { Text, Picture, Button, Badge } from '../../../../../components'\nimport {\n useCallback,\n useMemo,\n useState,\n forwardRef,\n useRef,\n type RefObject,\n useEffect,\n type Dispatch,\n type SetStateAction,\n} from 'react'\nimport { Swiper, SwiperSlide, type SwiperRef } from 'swiper/react'\nimport { Navigation, Mousewheel, Thumbs, Pagination } from 'swiper/modules'\nimport { cn } from '../../../../../helpers/index.js'\nimport { GalleryTabType } from './types.js'\nimport { Content, List, Root, Trigger } from '@radix-ui/react-tabs'\nimport { useProductContext } from '../../../ProductProvider.js'\nimport { useVariantMedia } from '../../../hooks/use-variant-media.js'\nimport { SpecsModal } from './components/SpecsModal.js'\nimport CompareModal from './components/CompareModal.js'\nimport { formatPrice } from '../../../utils/index.js'\n\nimport type { Swiper as SwiperType } from 'swiper'\nimport type { ImageMedia, VideoMedia } from '../../../hooks/use-variant-media.js'\nimport type { ProductGalleryProps, ProductGalleryTabItemProps, GalleryTabItemProps } from './types.js'\n\nconst SwiperLeftButtonIcon = (props: React.SVGProps<SVGSVGElement>) => {\n return (\n <svg width=\"48\" height=\"48\" viewBox=\"0 0 48 48\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" {...props}>\n <rect x=\"48\" y=\"48\" width=\"48\" height=\"48\" rx=\"24\" transform=\"rotate(-180 48 48)\" fill=\"white\" />\n <path\n d=\"M25.1035 16.8545C25.5372 16.3818 26.246 16.3818 26.6797 16.8545C27.1067 17.3201 27.1067 18.0706 26.6797 18.5361L21.668 24L26.6797 29.4639C27.1067 29.9294 27.1067 30.6799 26.6797 31.1455C26.246 31.6182 25.5372 31.6182 25.1035 31.1455L19.3203 24.8408C18.8933 24.3752 18.8933 23.6248 19.3203 23.1592L25.1035 16.8545Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n\nconst SwiperRightButtonIcon = (props: React.SVGProps<SVGSVGElement>) => {\n return (\n <svg width=\"48\" height=\"48\" viewBox=\"0 0 48 48\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" {...props}>\n <rect width=\"48\" height=\"48\" rx=\"24\" transform=\"matrix(1 -8.74228e-08 -8.74228e-08 -1 0 48)\" fill=\"white\" />\n <path\n d=\"M22.8965 16.8545C22.4628 16.3818 21.754 16.3818 21.3203 16.8545C20.8933 17.3201 20.8933 18.0706 21.3203 18.5361L26.332 24L21.3203 29.4639C20.8933 29.9294 20.8933 30.6799 21.3203 31.1455C21.754 31.6182 22.4628 31.6182 22.8965 31.1455L28.6797 24.8408C29.1067 24.3752 29.1067 23.6248 28.6797 23.1592L22.8965 16.8545Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n\nconst ProductGallery = () => {\n const { copyWriting } = useAiuiContext()\n const { product, variant, isMobile } = useProductContext()\n const defaultMediaData = useVariantMedia({ product, variant })\n const [swiper, setSwiper] = useState<SwiperType | null>(null)\n\n const customMediaList = variant?.metafields?.component?.custom_media_list\n let productList: ImageMedia[], sceneList: ImageMedia[], keyFeaturesList: ImageMedia[], videoList: VideoMedia[]\n\n if (customMediaList && customMediaList?.available) {\n productList = customMediaList?.product || []\n sceneList = customMediaList?.scenarios || []\n keyFeaturesList = customMediaList?.keyFeatures || []\n videoList = customMediaList?.video || []\n } else {\n productList = defaultMediaData?.productList\n sceneList = defaultMediaData?.sceneList\n keyFeaturesList = defaultMediaData?.keyFeaturesList\n videoList = defaultMediaData?.videoList\n }\n\n const allMedia = useMemo(() => [...productList, ...sceneList, ...videoList], [productList, sceneList, videoList])\n\n const galleryMap: Record<string, ImageMedia[] | VideoMedia[]> = {\n productList: productList,\n sceneList: sceneList,\n keyFeaturesList: keyFeaturesList,\n videoList: videoList,\n }\n\n const galleryTabs = useMemo(() => {\n const productTab =\n product?.payload?.components?.find((item: any) => item.componentKey === 'ProductGallery')?.data || []\n\n return productTab\n ?.map((item: any) => ({\n ...item,\n galleries: galleryMap[item?.galleries] || [],\n }))\n .filter((item: any) => item.galleries.length > 0)\n }, [product?.payload, galleryMap])\n\n // \u4E3A\u6BCF\u4E2A galleryTab \u521B\u5EFA\u5BF9\u5E94\u7684 ref\n const gallerySwiperRefs = useRef<{ [key: string]: SwiperRef | null }>({})\n\n const [activeGalleryTab, setActiveGalleryTab] = useState<GalleryTabItemProps>(galleryTabs?.[0])\n\n // \u4E3A\u6BCF\u4E2A tab \u6E32\u67D3\u5BF9\u5E94\u7684\u7EC4\u4EF6\n const renderGalleryForTab = (tab: any, index: number) => {\n switch (tab?.galleryTabType) {\n case GalleryTabType.GALLERY_IMAGE:\n return (\n <ProductGalleryTabImage\n {...tab}\n onCurrentTabLoopEnd={() => {\n setActiveGalleryTab(galleryTabs?.[index])\n }}\n onCurrentTabLoopStart={() => {\n setActiveGalleryTab(galleryTabs?.[index])\n }}\n index={index}\n />\n )\n case GalleryTabType.GALLERY_VIDEO:\n return <ProductGalleryTabVideo {...tab} />\n // case GalleryTabType.GALLERY_3D_VIEW:\n // return <ProductGalleryTab3DView {...item} />\n default:\n return null\n }\n }\n\n return (\n <div id=\"ipc-product-gallery\">\n <Root className=\"relative\" defaultValue={galleryTabs?.[0]?.tabValue}>\n {/* <Swiper\n className=\"h-[420px] laptop:h-[700px] bg-[#EAEAEC] rounded-2xl\"\n onSwiper={setSwiper}\n loop={true}\n // onProgress={swiper => {\n // setStart(swiper.isBeginning)\n // setEnd(swiper.isEnd)\n // }}\n modules={[Mousewheel]}\n mousewheel={{\n forceToAxis: true,\n }}\n >\n {galleryTabs.map((item, index) => {\n return (\n <Content forceMount key={item.tabValue} value={item.tabValue}>\n <SwiperSlide key={index}>{renderGalleryForTab(activeGalleryTab)}</SwiperSlide>\n </Content>\n )\n })}\n </Swiper>\n <div\n className={cn(\n 'absolute top-1/2 left-6 z-10 -translate-y-1/2 cursor-pointer',\n `ipc-product-gallery-custom-swiper-button-prev`\n )}\n >\n <SwiperLeftButtonIcon\n className=\"size-12\"\n onClick={() => {\n if (activeGalleryTab?.tabValue) {\n const currentRef = gallerySwiperRefs.current[activeGalleryTab.tabValue]\n currentRef?.swiper?.slidePrev()\n }\n }}\n />\n </div>\n <div\n className={cn(\n 'absolute top-1/2 right-6 z-10 -translate-y-1/2 cursor-pointer',\n `ipc-product-gallery-custom-swiper-button-next`\n )}\n >\n <SwiperRightButtonIcon\n className=\"size-12\"\n onClick={() => {\n if (activeGalleryTab?.tabValue) {\n const currentRef = gallerySwiperRefs.current[activeGalleryTab.tabValue]\n currentRef?.swiper?.slideNext()\n }\n }}\n />\n </div> */}\n <div className=\"h-[420px] tablet:h-[620px] desktop:rounded-2xl desktop:h-[560px] lg-desktop:h-[700px] bg-[#EAEAEC] desktop:relative \">\n {galleryTabs.map((item: any, index: number) => {\n return (\n <Content key={item.tabValue} className=\"h-full\" value={item.tabValue}>\n {renderGalleryForTab(item, index)}\n </Content>\n )\n })}\n </div>\n <ProductGalleryTab\n galleryTabs={galleryTabs}\n activeGalleryTab={activeGalleryTab}\n setActiveGalleryTab={setActiveGalleryTab}\n />\n </Root>\n </div>\n )\n}\n\nconst ProductGalleryTab = ({\n galleryTabs,\n activeGalleryTab,\n setActiveGalleryTab,\n}: {\n galleryTabs: GalleryTabItemProps[]\n activeGalleryTab: GalleryTabItemProps\n setActiveGalleryTab: Dispatch<SetStateAction<GalleryTabItemProps>>\n}) => {\n const { product } = useProductContext()\n return (\n <div className=\"absolute z-[2] bottom-4 left-4 right-4 laptop:left-16 laptop:right-16 flex justify-between items-center tablet:mt-3 desktop:static\">\n <List\n className=\"rounded-full bg-[#EAEAEC] p-1 laptop:p-0 desktop:p-1 overflow-x-auto\"\n style={{\n scrollbarWidth: 'none',\n msOverflowStyle: 'none',\n }}\n >\n <div className=\"whitespace-nowrap\">\n {galleryTabs?.map(item => {\n return (\n <Trigger\n className={cn(\n 'lg-desktop:px-7 lg-desktop:pb-[14px] rounded-full font-bold lg-desktop:pt-[15px] lg-desktop:text-[16px] px-5 pb-[10px] pt-[11px] text-[14px] leading-tight',\n item.tabValue === activeGalleryTab?.tabValue && 'bg-white'\n )}\n onClick={() => setActiveGalleryTab(item)}\n key={item.tabValue}\n value={item.tabValue}\n >\n {item.tabLabel}\n </Trigger>\n )\n })}\n </div>\n </List>\n <div className=\"laptop:gap-2 hidden laptop:flex\">\n {product.metafields?.global?.specifications && (\n <>\n <SpecsModal /> | <CompareModal />\n </>\n )}\n </div>\n </div>\n )\n}\n\nconst ProductGalleryTabImage = forwardRef<SwiperRef, ProductGalleryTabItemProps>((props, ref) => {\n const { locale = 'us', copyWriting } = useAiuiContext()\n const { variant, totalSavings } = useProductContext()\n const paginationRef = useRef<HTMLDivElement>(null)\n const [thumbsSwiper, setThumbsSwiper] = useState<SwiperType | null>(null)\n const [isStart, setStart] = useState(true)\n const [isEnd, setEnd] = useState(false)\n const [swiper, setSwiper] = useState<SwiperType | null>(null)\n\n return (\n <div className=\"h-full\">\n <Swiper\n ref={ref}\n className=\"h-full\"\n navigation={{\n nextEl: `.ipc-product-gallery-${props?.id}-custom-swiper-button-next`,\n prevEl: `.ipc-product-gallery-${props?.id}-custom-swiper-button-prev`,\n }}\n onSwiper={setSwiper}\n onProgress={swiper => {\n setStart(swiper.isBeginning)\n setEnd(swiper.isEnd)\n }}\n pagination={{\n clickable: true,\n el: paginationRef.current,\n }}\n onSlideChange={swiper => {\n if (swiper) {\n if (swiper.isEnd) {\n props?.onCurrentTabLoopEnd?.()\n } else if (swiper.isBeginning) {\n props?.onCurrentTabLoopStart?.()\n }\n }\n }}\n thumbs={{ swiper: thumbsSwiper }}\n modules={[Mousewheel, Thumbs, Navigation, Pagination]}\n mousewheel={{\n forceToAxis: true,\n }}\n breakpoints={{\n 0: {\n slidesPerView: 1,\n freeMode: false,\n },\n }}\n >\n {props?.galleries?.map((item, jIndex) => {\n return (\n <SwiperSlide className=\"h-full\" key={props?.id + 'SwiperSlideItem' + jIndex}>\n <Picture\n source={item?.image?.url}\n alt={item?.image?.altText}\n className=\"h-full\"\n imgClassName=\"object-contain h-full \"\n />\n </SwiperSlide>\n )\n })}\n </Swiper>\n {variant.availableForSale && !!totalSavings && !props.index && (\n <Badge\n size=\"lg\"\n className=\"absolute bg-brand text-white top-3 laptop:left-16 laptop:top-5 left-4 z-[2] desktop:left-6 desktop:top-6\"\n >\n {`${formatPrice({\n amount: totalSavings,\n currencyCode: variant?.price?.currencyCode,\n locale: locale,\n })} ${copyWriting?.off}`}\n </Badge>\n )}\n <div\n className={cn(\n 'hidden tablet:block tablet:absolute tablet:top-1/2 tablet:left-6 z-10 -translate-y-1/2 cursor-pointer',\n `ipc-product-gallery-${props?.id}-custom-swiper-button-prev`\n )}\n >\n <SwiperLeftButtonIcon className=\"tablet:size-10 lg-desktop:size-12\" />\n </div>\n <div\n className={cn(\n 'hidden tablet:block tablet:absolute tablet:top-1/2 tablet:right-6 z-10 -translate-y-1/2 cursor-pointer',\n `ipc-product-gallery-${props?.id}-custom-swiper-button-next`\n )}\n >\n <SwiperRightButtonIcon className=\"tablet:size-10 lg-desktop:size-12\" />\n </div>\n {/* {props?.galleries?.map((item, jIndex) => {\n return (\n <Picture\n key={props?.id + 'SwiperSlideItem' + jIndex}\n source={item?.image?.url}\n alt={item?.image?.altText}\n className=\"h-full\"\n imgClassName=\"object-cover h-full\"\n />\n )\n })} */}\n <div className=\"absolute bottom-[94px] tablet:bottom-[70px] left-4 right-4 z-10 items-center tablet:flex justify-between laptop:left-16 laptop:right-16 desktop:bottom-[20px] desktop:right-[6] desktop:left-[6]\">\n <div className=\"hidden tablet:block\">\n <Swiper\n className=\"flex items-center justify-between\"\n onSwiper={setThumbsSwiper}\n spaceBetween={12}\n slidesPerView={6}\n freeMode={true}\n watchSlidesProgress={true}\n modules={[Navigation, Thumbs]}\n >\n {props?.galleries?.map((item, jIndex) => (\n <SwiperSlide\n key={props?.id + 'SwiperSlideThumbItem' + jIndex}\n className=\"!w-auto [&.swiper-slide-thumb-active]:border [&.swiper-slide-thumb-active]:border-brand\"\n >\n <Picture\n source={item.image?.url}\n alt={item.image?.altText}\n className=\"size-10 lg-desktop:size-12 rounded\"\n imgClassName=\"object-contain h-full\"\n />\n </SwiperSlide>\n ))}\n </Swiper>\n </div>\n {!props?.index && (\n <div className=\"flex items-center gap-2\">\n <Picture\n source={props?.comment?.avatar?.url}\n className=\"size-10 rounded-full shrink-0\"\n imgClassName=\"object-cover \"\n />\n <Text\n html={props?.comment?.content}\n className=\"text-sm lg-desktop:text-base max-w-[528px] font-bold text-[#6D6D6F] line-clamp-2\"\n />\n </div>\n )}\n </div>\n <div ref={paginationRef} className=\"tablet:hidden text-center absolute !bottom-[70px] left-4 right-4 z-10\" />\n </div>\n )\n})\n\nconst ProductGalleryTabVideo = (props: ProductGalleryTabItemProps) => {\n return (\n <div className=\"h-full\">\n <Swiper\n className=\"h-full\"\n navigation={{\n nextEl: `.ipc-product-gallery-${props?.id}-custom-swiper-button-next`,\n prevEl: `.ipc-product-gallery-${props?.id}-custom-swiper-button-prev`,\n }}\n modules={[Mousewheel, Thumbs, Navigation, Pagination]}\n mousewheel={{\n forceToAxis: true,\n }}\n breakpoints={{\n 0: {\n slidesPerView: 1,\n freeMode: false,\n },\n }}\n >\n {props?.galleries?.map((item, jIndex) => {\n return (\n <SwiperSlide className=\"h-full\" key={props?.id + 'SwiperSlideItem' + jIndex}>\n <video controls className=\"size-full\">\n <track kind=\"captions\" />\n <source src={item?.sources?.[0]?.url} type=\"video/mp4\" />\n <source src={item?.sources?.[0]?.url} type=\"video/webm\" />\n <source src={item?.sources?.[0]?.url} type=\"video/ogg\" />\n </video>\n </SwiperSlide>\n )\n })}\n </Swiper>\n <div\n className={cn(\n 'hidden tablet:block tablet:absolute tablet:top-1/2 tablet:left-6 z-10 -translate-y-1/2 cursor-pointer',\n `ipc-product-gallery-${props?.id}-custom-swiper-button-prev`\n )}\n >\n <SwiperLeftButtonIcon className=\"tablet:size-10 lg-desktop:size-12\" />\n </div>\n <div\n className={cn(\n 'hidden tablet:block tablet:absolute tablet:top-1/2 tablet:right-6 z-10 -translate-y-1/2 cursor-pointer',\n `ipc-product-gallery-${props?.id}-custom-swiper-button-next`\n )}\n >\n <SwiperRightButtonIcon className=\"tablet:size-10 lg-desktop:size-12\" />\n </div>\n </div>\n )\n}\n\nconst ProductGalleryTab3DView = (props: ProductGalleryTabItemProps) => {\n return <div>3D View</div>\n}\n\nexport default ProductGallery\n"],
5
- "mappings": "AA8BI,OAgNM,YAAAA,GA/MJ,OAAAC,EADF,QAAAC,MAAA,oBA9BJ,OAAS,kBAAAC,MAAsB,oCAC/B,OAAS,QAAAC,EAAM,WAAAC,EAAiB,SAAAC,MAAa,4BAC7C,OAEE,WAAAC,EACA,YAAAC,EACA,cAAAC,EACA,UAAAC,MAKK,QACP,OAAS,UAAAC,EAAQ,eAAAC,MAAmC,eACpD,OAAS,cAAAC,EAAY,cAAAC,EAAY,UAAAC,EAAQ,cAAAC,MAAkB,iBAC3D,OAAS,MAAAC,MAAU,kCACnB,OAAS,kBAAAC,MAAsB,aAC/B,OAAS,WAAAC,EAAS,QAAAC,EAAM,QAAAC,EAAM,WAAAC,MAAe,uBAC7C,OAAS,qBAAAC,MAAyB,8BAClC,OAAS,mBAAAC,MAAuB,sCAChC,OAAS,cAAAC,MAAkB,6BAC3B,OAAOC,MAAkB,+BACzB,OAAS,eAA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AO,GAAK,kBAAoBsC,CAOrE,CAEH,EACH,EACAlE,EAAC,OACC,UAAWgB,EACT,wGACA,uBAAuBY,GAAO,EAAE,4BAClC,EAEA,SAAA5B,EAAC2B,EAAA,CAAqB,UAAU,oCAAoC,EACtE,EACA3B,EAAC,OACC,UAAWgB,EACT,yGACA,uBAAuBY,GAAO,EAAE,4BAClC,EAEA,SAAA5B,EAAC6B,EAAA,CAAsB,UAAU,oCAAoC,EACvE,GACF,EAIEsC,GAA2BvC,GACxB5B,EAAC,OAAI,mBAAO,EAGrB,IAAOoE,GAAQtC",
4
+ "sourcesContent": ["import { useAiuiContext } from '../../../../AiuiProvider/index.js'\nimport { Text, Picture, Button, Badge } from '../../../../../components'\nimport {\n useCallback,\n useMemo,\n useState,\n forwardRef,\n useRef,\n type RefObject,\n useEffect,\n type Dispatch,\n type SetStateAction,\n} from 'react'\nimport { Swiper, SwiperSlide, type SwiperRef } from 'swiper/react'\nimport { Navigation, Mousewheel, Thumbs, Pagination } from 'swiper/modules'\nimport { cn } from '../../../../../helpers/index.js'\nimport { GalleryTabType } from './types.js'\nimport { Content, List, Root, Trigger } from '@radix-ui/react-tabs'\nimport { useProductContext } from '../../../ProductProvider.js'\nimport { useVariantMedia } from '../../../hooks/use-variant-media.js'\nimport { SpecsModal } from './components/SpecsModal.js'\nimport CompareModal from './components/CompareModal.js'\nimport { formatPrice } from '../../../utils/index.js'\n\nimport type { Swiper as SwiperType } from 'swiper'\nimport type { ImageMedia, VideoMedia } from '../../../hooks/use-variant-media.js'\nimport type { ProductGalleryProps, ProductGalleryTabItemProps, GalleryTabItemProps } from './types.js'\n\nconst SwiperLeftButtonIcon = (props: React.SVGProps<SVGSVGElement>) => {\n return (\n <svg width=\"48\" height=\"48\" viewBox=\"0 0 48 48\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" {...props}>\n <rect x=\"48\" y=\"48\" width=\"48\" height=\"48\" rx=\"24\" transform=\"rotate(-180 48 48)\" fill=\"white\" />\n <path\n d=\"M25.1035 16.8545C25.5372 16.3818 26.246 16.3818 26.6797 16.8545C27.1067 17.3201 27.1067 18.0706 26.6797 18.5361L21.668 24L26.6797 29.4639C27.1067 29.9294 27.1067 30.6799 26.6797 31.1455C26.246 31.6182 25.5372 31.6182 25.1035 31.1455L19.3203 24.8408C18.8933 24.3752 18.8933 23.6248 19.3203 23.1592L25.1035 16.8545Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n\nconst SwiperRightButtonIcon = (props: React.SVGProps<SVGSVGElement>) => {\n return (\n <svg width=\"48\" height=\"48\" viewBox=\"0 0 48 48\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" {...props}>\n <rect width=\"48\" height=\"48\" rx=\"24\" transform=\"matrix(1 -8.74228e-08 -8.74228e-08 -1 0 48)\" fill=\"white\" />\n <path\n d=\"M22.8965 16.8545C22.4628 16.3818 21.754 16.3818 21.3203 16.8545C20.8933 17.3201 20.8933 18.0706 21.3203 18.5361L26.332 24L21.3203 29.4639C20.8933 29.9294 20.8933 30.6799 21.3203 31.1455C21.754 31.6182 22.4628 31.6182 22.8965 31.1455L28.6797 24.8408C29.1067 24.3752 29.1067 23.6248 28.6797 23.1592L22.8965 16.8545Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n\nconst ProductGallery = () => {\n const { copyWriting } = useAiuiContext()\n const { product, variant, isMobile } = useProductContext()\n const defaultMediaData = useVariantMedia({ product, variant })\n const [swiper, setSwiper] = useState<SwiperType | null>(null)\n\n const customMediaList = variant?.metafields?.component?.custom_media_list\n let productList: ImageMedia[], sceneList: ImageMedia[], keyFeaturesList: ImageMedia[], videoList: VideoMedia[]\n\n if (customMediaList && customMediaList?.available) {\n productList = customMediaList?.product || []\n sceneList = customMediaList?.scenarios || []\n keyFeaturesList = customMediaList?.keyFeatures || []\n videoList = customMediaList?.video || []\n } else {\n productList = defaultMediaData?.productList\n sceneList = defaultMediaData?.sceneList\n keyFeaturesList = defaultMediaData?.keyFeaturesList\n videoList = defaultMediaData?.videoList\n }\n\n const allMedia = useMemo(() => [...productList, ...sceneList, ...videoList], [productList, sceneList, videoList])\n\n const galleryMap: Record<string, ImageMedia[] | VideoMedia[]> = {\n productList: productList,\n sceneList: sceneList,\n keyFeaturesList: keyFeaturesList,\n videoList: videoList,\n }\n\n const galleryTabs = useMemo(() => {\n const productTab =\n product?.payload?.components?.find((item: any) => item.componentKey === 'ProductGallery')?.data || []\n\n return productTab\n ?.map((item: any) => ({\n ...item,\n galleries: galleryMap[item?.galleries] || [],\n }))\n .filter((item: any) => item.galleries.length > 0)\n }, [product?.payload, galleryMap])\n\n // \u4E3A\u6BCF\u4E2A galleryTab \u521B\u5EFA\u5BF9\u5E94\u7684 ref\n const gallerySwiperRefs = useRef<{ [key: string]: SwiperRef | null }>({})\n\n const [activeGalleryTab, setActiveGalleryTab] = useState<GalleryTabItemProps>(galleryTabs?.[0])\n\n // \u4E3A\u6BCF\u4E2A tab \u6E32\u67D3\u5BF9\u5E94\u7684\u7EC4\u4EF6\n const renderGalleryForTab = (tab: any, index: number) => {\n switch (tab?.galleryTabType) {\n case GalleryTabType.GALLERY_IMAGE:\n return (\n <ProductGalleryTabImage\n {...tab}\n onCurrentTabLoopEnd={() => {\n setActiveGalleryTab(galleryTabs?.[index])\n }}\n onCurrentTabLoopStart={() => {\n setActiveGalleryTab(galleryTabs?.[index])\n }}\n index={index}\n />\n )\n case GalleryTabType.GALLERY_VIDEO:\n return <ProductGalleryTabVideo {...tab} />\n // case GalleryTabType.GALLERY_3D_VIEW:\n // return <ProductGalleryTab3DView {...item} />\n default:\n return null\n }\n }\n\n return (\n <div id=\"ipc-product-gallery\">\n <Root className=\"relative\" defaultValue={galleryTabs?.[0]?.tabValue}>\n {/* <Swiper\n className=\"h-[420px] laptop:h-[700px] bg-[#EAEAEC] rounded-2xl\"\n onSwiper={setSwiper}\n loop={true}\n // onProgress={swiper => {\n // setStart(swiper.isBeginning)\n // setEnd(swiper.isEnd)\n // }}\n modules={[Mousewheel]}\n mousewheel={{\n forceToAxis: true,\n }}\n >\n {galleryTabs.map((item, index) => {\n return (\n <Content forceMount key={item.tabValue} value={item.tabValue}>\n <SwiperSlide key={index}>{renderGalleryForTab(activeGalleryTab)}</SwiperSlide>\n </Content>\n )\n })}\n </Swiper>\n <div\n className={cn(\n 'absolute top-1/2 left-6 z-10 -translate-y-1/2 cursor-pointer',\n `ipc-product-gallery-custom-swiper-button-prev`\n )}\n >\n <SwiperLeftButtonIcon\n className=\"size-12\"\n onClick={() => {\n if (activeGalleryTab?.tabValue) {\n const currentRef = gallerySwiperRefs.current[activeGalleryTab.tabValue]\n currentRef?.swiper?.slidePrev()\n }\n }}\n />\n </div>\n <div\n className={cn(\n 'absolute top-1/2 right-6 z-10 -translate-y-1/2 cursor-pointer',\n `ipc-product-gallery-custom-swiper-button-next`\n )}\n >\n <SwiperRightButtonIcon\n className=\"size-12\"\n onClick={() => {\n if (activeGalleryTab?.tabValue) {\n const currentRef = gallerySwiperRefs.current[activeGalleryTab.tabValue]\n currentRef?.swiper?.slideNext()\n }\n }}\n />\n </div> */}\n <div className=\"h-[420px] tablet:h-[620px] desktop:rounded-2xl desktop:h-[560px] lg-desktop:h-[700px] bg-[#EAEAEC] desktop:relative \">\n {galleryTabs.map((item: any, index: number) => {\n return (\n <Content key={item.tabValue} className=\"h-full\" value={item.tabValue}>\n {renderGalleryForTab(item, index)}\n </Content>\n )\n })}\n </div>\n <ProductGalleryTab\n galleryTabs={galleryTabs}\n activeGalleryTab={activeGalleryTab}\n setActiveGalleryTab={setActiveGalleryTab}\n />\n </Root>\n </div>\n )\n}\n\nconst ProductGalleryTab = ({\n galleryTabs,\n activeGalleryTab,\n setActiveGalleryTab,\n}: {\n galleryTabs: GalleryTabItemProps[]\n activeGalleryTab: GalleryTabItemProps\n setActiveGalleryTab: Dispatch<SetStateAction<GalleryTabItemProps>>\n}) => {\n const { product } = useProductContext()\n return (\n <div className=\"absolute z-[2] bottom-4 left-4 right-4 laptop:left-16 laptop:right-16 flex justify-between items-center tablet:mt-3 desktop:static\">\n <List\n className=\"rounded-full bg-[#EAEAEC] p-1 laptop:p-0 desktop:p-1 overflow-x-auto\"\n style={{\n scrollbarWidth: 'none',\n msOverflowStyle: 'none',\n }}\n >\n <div className=\"whitespace-nowrap\">\n {galleryTabs?.map(item => {\n return (\n <Trigger\n className={cn(\n 'lg-desktop:px-7 lg-desktop:pb-[14px] rounded-full font-bold lg-desktop:pt-[15px] lg-desktop:text-[16px] px-5 pb-[10px] pt-[11px] text-[14px] leading-tight',\n item.tabValue === activeGalleryTab?.tabValue && 'bg-white'\n )}\n onClick={() => setActiveGalleryTab(item)}\n key={item.tabValue}\n value={item.tabValue}\n >\n {item.tabLabel}\n </Trigger>\n )\n })}\n </div>\n </List>\n <div className=\"laptop:gap-2 hidden laptop:flex\">\n {product.metafields?.global?.specifications && (\n <>\n <SpecsModal /> | <CompareModal />\n </>\n )}\n </div>\n </div>\n )\n}\n\nconst ProductGalleryTabImage = forwardRef<SwiperRef, ProductGalleryTabItemProps>((props, ref) => {\n const { locale = 'us', copyWriting } = useAiuiContext()\n const { variant, totalSavings } = useProductContext()\n const paginationRef = useRef<HTMLDivElement>(null)\n const [thumbsSwiper, setThumbsSwiper] = useState<SwiperType | null>(null)\n const [isStart, setStart] = useState(true)\n const [isEnd, setEnd] = useState(false)\n const [swiper, setSwiper] = useState<SwiperType | null>(null)\n\n return (\n <div className=\"h-full\">\n <Swiper\n ref={ref}\n className=\"h-full\"\n navigation={{\n nextEl: `.ipc-product-gallery-${props?.id}-custom-swiper-button-next`,\n prevEl: `.ipc-product-gallery-${props?.id}-custom-swiper-button-prev`,\n }}\n onSwiper={setSwiper}\n onProgress={swiper => {\n setStart(swiper.isBeginning)\n setEnd(swiper.isEnd)\n }}\n pagination={{\n clickable: true,\n el: paginationRef.current,\n }}\n onSlideChange={swiper => {\n if (swiper) {\n if (swiper.isEnd) {\n props?.onCurrentTabLoopEnd?.()\n } else if (swiper.isBeginning) {\n props?.onCurrentTabLoopStart?.()\n }\n }\n }}\n thumbs={{ swiper: thumbsSwiper }}\n modules={[Mousewheel, Thumbs, Navigation, Pagination]}\n mousewheel={{\n forceToAxis: true,\n }}\n breakpoints={{\n 0: {\n slidesPerView: 1,\n freeMode: false,\n },\n }}\n >\n {props?.galleries?.map((item, jIndex) => {\n return (\n <SwiperSlide className=\"h-full\" key={props?.id + 'SwiperSlideItem' + jIndex}>\n <Picture\n source={item?.image?.url}\n alt={item?.image?.altText}\n className=\"h-full\"\n imgClassName=\"object-contain h-full \"\n />\n </SwiperSlide>\n )\n })}\n </Swiper>\n {variant.availableForSale && !!totalSavings && !props.index && (\n <Badge\n size=\"lg\"\n className=\"absolute bg-brand text-white top-3 laptop:left-16 laptop:top-5 left-4 z-[2] desktop:left-6 desktop:top-6\"\n >\n {`${formatPrice({\n amount: totalSavings,\n currencyCode: variant?.price?.currencyCode,\n locale: locale,\n })} ${copyWriting?.off}`}\n </Badge>\n )}\n <div\n className={cn(\n 'hidden tablet:block tablet:absolute tablet:top-1/2 laptop:left-16 tablet:left-6 desktop:left-6 z-10 -translate-y-1/2 cursor-pointer',\n `ipc-product-gallery-${props?.id}-custom-swiper-button-prev`\n )}\n >\n <SwiperLeftButtonIcon className=\"tablet:size-10 lg-desktop:size-12\" />\n </div>\n <div\n className={cn(\n 'hidden tablet:block tablet:absolute tablet:top-1/2 laptop:right-16 tablet:right-6 z-10 desktop:right-6 -translate-y-1/2 cursor-pointer',\n `ipc-product-gallery-${props?.id}-custom-swiper-button-next`\n )}\n >\n <SwiperRightButtonIcon className=\"tablet:size-10 lg-desktop:size-12\" />\n </div>\n {/* {props?.galleries?.map((item, jIndex) => {\n return (\n <Picture\n key={props?.id + 'SwiperSlideItem' + jIndex}\n source={item?.image?.url}\n alt={item?.image?.altText}\n className=\"h-full\"\n imgClassName=\"object-cover h-full\"\n />\n )\n })} */}\n <div className=\"absolute bottom-[94px] tablet:bottom-[70px] left-4 right-4 z-10 items-center tablet:flex justify-between laptop:left-16 laptop:right-16 desktop:bottom-[20px] desktop:right-6 desktop:left-6\">\n <div className=\"hidden tablet:block\">\n <Swiper\n className=\"flex items-center justify-between\"\n onSwiper={setThumbsSwiper}\n spaceBetween={12}\n slidesPerView={6}\n freeMode={true}\n watchSlidesProgress={true}\n modules={[Navigation, Thumbs]}\n >\n {props?.galleries?.map((item, jIndex) => (\n <SwiperSlide\n key={props?.id + 'SwiperSlideThumbItem' + jIndex}\n className=\"!w-auto [&.swiper-slide-thumb-active]:border [&.swiper-slide-thumb-active]:border-brand\"\n >\n <Picture\n source={item.image?.url}\n alt={item.image?.altText}\n className=\"size-10 lg-desktop:size-12 rounded\"\n imgClassName=\"object-contain h-full\"\n />\n </SwiperSlide>\n ))}\n </Swiper>\n </div>\n {!props?.index && (\n <div className=\"flex items-center gap-2\">\n <Picture\n source={props?.comment?.avatar?.url}\n className=\"size-10 rounded-full shrink-0\"\n imgClassName=\"object-cover \"\n />\n <Text\n html={props?.comment?.content}\n className=\"text-sm lg-desktop:text-base max-w-[528px] font-bold text-[#6D6D6F] line-clamp-2\"\n />\n </div>\n )}\n </div>\n <div ref={paginationRef} className=\"tablet:hidden text-center absolute !bottom-[70px] left-4 right-4 z-10\" />\n </div>\n )\n})\n\nconst ProductGalleryTabVideo = (props: ProductGalleryTabItemProps) => {\n return (\n <div className=\"h-full\">\n <Swiper\n className=\"h-full\"\n navigation={{\n nextEl: `.ipc-product-gallery-${props?.id}-custom-swiper-button-next`,\n prevEl: `.ipc-product-gallery-${props?.id}-custom-swiper-button-prev`,\n }}\n modules={[Mousewheel, Thumbs, Navigation, Pagination]}\n mousewheel={{\n forceToAxis: true,\n }}\n breakpoints={{\n 0: {\n slidesPerView: 1,\n freeMode: false,\n },\n }}\n >\n {props?.galleries?.map((item, jIndex) => {\n return (\n <SwiperSlide className=\"h-full\" key={props?.id + 'SwiperSlideItem' + jIndex}>\n <video controls className=\"size-full\">\n <track kind=\"captions\" />\n <source src={item?.sources?.[0]?.url} type=\"video/mp4\" />\n <source src={item?.sources?.[0]?.url} type=\"video/webm\" />\n <source src={item?.sources?.[0]?.url} type=\"video/ogg\" />\n </video>\n </SwiperSlide>\n )\n })}\n </Swiper>\n <div\n className={cn(\n 'hidden tablet:block tablet:absolute tablet:top-1/2 tablet:left-6 z-10 -translate-y-1/2 cursor-pointer',\n `ipc-product-gallery-${props?.id}-custom-swiper-button-prev`\n )}\n >\n <SwiperLeftButtonIcon className=\"tablet:size-10 lg-desktop:size-12\" />\n </div>\n <div\n className={cn(\n 'hidden tablet:block tablet:absolute tablet:top-1/2 tablet:right-6 z-10 -translate-y-1/2 cursor-pointer',\n `ipc-product-gallery-${props?.id}-custom-swiper-button-next`\n )}\n >\n <SwiperRightButtonIcon className=\"tablet:size-10 lg-desktop:size-12\" />\n </div>\n </div>\n )\n}\n\nconst ProductGalleryTab3DView = (props: ProductGalleryTabItemProps) => {\n return <div>3D View</div>\n}\n\nexport default ProductGallery\n"],
5
+ "mappings": "AA8BI,OAgNM,YAAAA,GA/MJ,OAAAC,EADF,QAAAC,MAAA,oBA9BJ,OAAS,kBAAAC,MAAsB,oCAC/B,OAAS,QAAAC,EAAM,WAAAC,EAAiB,SAAAC,MAAa,4BAC7C,OAEE,WAAAC,EACA,YAAAC,EACA,cAAAC,EACA,UAAAC,MAKK,QACP,OAAS,UAAAC,EAAQ,eAAAC,MAAmC,eACpD,OAAS,cAAAC,EAAY,cAAAC,EAAY,UAAAC,EAAQ,cAAAC,MAAkB,iBAC3D,OAAS,MAAAC,MAAU,kCACnB,OAAS,kBAAAC,MAAsB,aAC/B,OAAS,WAAAC,EAAS,QAAAC,EAAM,QAAAC,EAAM,WAAAC,MAAe,uBAC7C,OAAS,qBAAAC,MAAyB,8BAClC,OAAS,mBAAAC,MAAuB,sCAChC,OAAS,cAAAC,MAAkB,6BAC3B,OAAOC,MAAkB,+BACzB,OAAS,eAAAC,MAAmB,0BAM5B,MAAMC,EAAwBC,GAE1B3B,EAAC,OAAI,MAAM,KA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EACT,wGACA,uBAAuBY,GAAO,EAAE,4BAClC,EAEA,SAAA5B,EAAC2B,EAAA,CAAqB,UAAU,oCAAoC,EACtE,EACA3B,EAAC,OACC,UAAWgB,EACT,yGACA,uBAAuBY,GAAO,EAAE,4BAClC,EAEA,SAAA5B,EAAC6B,EAAA,CAAsB,UAAU,oCAAoC,EACvE,GACF,EAIEsC,GAA2BvC,GACxB5B,EAAC,OAAI,mBAAO,EAGrB,IAAOoE,GAAQtC",
6
6
  "names": ["Fragment", "jsx", "jsxs", "useAiuiContext", "Text", "Picture", "Badge", "useMemo", "useState", "forwardRef", "useRef", "Swiper", "SwiperSlide", "Navigation", "Mousewheel", "Thumbs", "Pagination", "cn", "GalleryTabType", "Content", "List", "Root", "Trigger", "useProductContext", "useVariantMedia", "SpecsModal", "CompareModal", "formatPrice", "SwiperLeftButtonIcon", "props", "SwiperRightButtonIcon", "ProductGallery", "copyWriting", "product", "variant", "isMobile", "defaultMediaData", "swiper", "setSwiper", "customMediaList", "productList", "sceneList", "keyFeaturesList", "videoList", "allMedia", "galleryMap", "galleryTabs", "item", "gallerySwiperRefs", "activeGalleryTab", "setActiveGalleryTab", "renderGalleryForTab", "tab", "index", "ProductGalleryTabImage", "ProductGalleryTabVideo", "ProductGalleryTab", "ref", "locale", "totalSavings", "paginationRef", "thumbsSwiper", "setThumbsSwiper", "isStart", "setStart", "isEnd", "setEnd", "jIndex", "ProductGalleryTab3DView", "ProductGallery_default"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Text as s,Button as g,Grid as I,GridItem as G,Picture as N,Heading as L}from"../../../../../components";import{useProductContext as y}from"../../../ProductProvider";import{useEffect as R,useMemo as A,useState as O}from"react";import{formatPrice as f}from"../../../utils";import{useAiuiContext as C}from"../../../../AiuiProvider";import{cn as F}from"../../../../../helpers";import V from"decimal.js";const S=({})=>{const{locale:d="us",copyWriting:a}=C(),{product:l,variant:o,finalPrice:p,comparePrice:m,coupon:n,selectedOptions:c,onAddToCart:k,onBuyNow:h,savingDetail:b,joinedRecommendBuyProducts:i,setJoinedRecommendBuyProducts:u}=y();if(!o.availableForSale)return null;const{bundleVariant:B,giftVariant:w}=$()||{},[r,v]=O();R(()=>{v({bundle:i.bundle?void 0:B,gift:i.gift?void 0:w})},[B,w,i]);const D=A(()=>new V(m).minus(b.freeGift).toNumber(),[m,b]);return e("div",{className:"ipc-product-summary bg-[#F5F5F7] mt-16",children:t(I,{className:"px-4 py-6 tablet:p-8",children:[t(G,{className:"col-span-12 desktop:col-start-1 desktop:col-span-5",children:[e(L,{className:"font-bold text-[24px] lg-desktop:text-[48px] laptop:text-[32px] desktop:text-[40px] leading-[1] mb-4 [&>span]:text-[#D1D1D1]",html:`${l.title} is ready <br/><span>Just the way you want it.</span>`}),e("div",{className:"aspect-[644/320]",children:e(N,{source:o.image?.url||l?.images?.[0]?.url,className:"h-full w-full",imgClassName:"object-contain h-full"})})]}),t(G,{className:"col-span-12 mt-8 desktop:col-start-7 laptop:mt-0 desktop:col-span-6 flex flex-col gap-6 justify-between",children:[t("div",{children:[t("div",{className:"flex flex-col gap-4",children:[t("div",{className:"flex items-center justify-between",children:[t("div",{className:"shrink-0 flex items-center gap-4",children:[e(N,{source:o.image?.url||l?.images?.[0]?.url,className:"size-16 object-cover"}),t("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:[e(s,{className:"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]",html:l.title}),e(s,{className:"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]",html:`x1 | ${c.color||c.colour||c.couleur}`})]})]}),t("div",{className:"flex items-center gap-1",children:[e(s,{className:"text-base desktop:text-2xl font-bold",html:f({amount:p,currencyCode:o.price.currencyCode,locale:d})}),n&&e(s,{className:"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]",html:f({amount:D,currencyCode:o.price.currencyCode,locale:d})})]})]}),i?.gift&&e(z,{giftOperation:x=>{u?.({...i,gift:void 0}),v?.({...r,gift:x})},giftStatus:!!i?.gift,gift:i?.gift}),i?.bundle&&e(j,{bundleOperation:x=>{u?.({...i,bundle:void 0}),v?.({...r,bundle:x})},bundleStatus:!!i?.bundle,bundleListItem:i?.bundle})]}),(r?.bundle||r?.gift)&&t("div",{className:"mt-6",children:[e(s,{className:"text-sm desktop:text-[18px] font-bold",html:"Recommend Buy"}),t("div",{className:"flex flex-col gap-6 mt-6",children:[r?.gift&&e(z,{giftOperation:x=>{u?.({...i,gift:x}),v?.({...r,gift:void 0})},giftStatus:!r?.gift,gift:r?.gift}),r?.bundle&&e(j,{bundleOperation:x=>{u?.({...i,bundle:x}),v?.({...r,bundle:void 0})},bundleStatus:!r?.bundle,bundleListItem:r?.bundle})]})]})]}),t("div",{className:"text-right",children:[e(s,{className:"laptop:text-xl desktop:text-2xl font-bold text-right",html:`${a?.totalPrice} ${f({amount:p,currencyCode:o.price.currencyCode,locale:d})}`}),n&&e(s,{className:"text-base desktop:text-2xl ml-1 font-bold line-through text-[#6D6D6F]",html:f({amount:D,currencyCode:o.price.currencyCode,locale:d})}),t("div",{className:"flex gap-3 mt-2",children:[e(g,{size:"lg",variant:"secondary",className:"w-1/2",onClick:()=>k?.(),children:a?.addToCart}),e(g,{size:"lg",variant:"primary",className:"w-1/2",onClick:()=>h?.(),children:a?.shopNow})]})]})]})]})})},$=()=>{const{bundle:d,variant:a,checkedBundle:l,freeGift:o,checkedGift:p}=y();let m,n;const{bundleList:c}=d||{},{giftList:k=[]}=o||{},h=c?.filter(u=>u.variants.slice(1,u.variants.length).every(P=>P.variant.availableForSale))||[],[b]=h;m=l||b;const[i]=k?.filter(u=>u.availableForSale);return n=p||i,{bundleVariant:m,giftVariant:n}},j=({bundleOperation:d,bundleStatus:a,bundleListItem:l})=>{const{locale:o="us"}=C(),{variant:p,setCheckedBundle:m}=y(),n=l?.variants.filter(c=>c.variant.sku!==p.sku);return t("div",{className:"flex items-center justify-between",children:[n?.map(c=>t("div",{className:"flex items-center gap-4",children:[e(N,{source:c?.variant?.image?.url,className:"size-16 object-cover"}),e("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:e(s,{className:"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]",html:c.variant.product.title})})]},c.variant.id)),t("div",{className:"flex flex-col items-end gap-1 justify-center",children:[a&&e(s,{className:"text-base desktop:text-2xl font-bold",html:f({amount:n[0]?.price,locale:o,currencyCode:n[0]?.variant?.price?.currencyCode})}),e(g,{size:a?"icon":"lg",variant:a?"link":"primary",onClick:()=>{m?.(a?void 0:l),d(l)},className:F("shrink-0 size-auto",{underline:a}),children:a?"Remove":"Add +"})]})]})},z=({giftOperation:d,giftStatus:a,gift:l})=>{const{locale:o="us"}=C(),{freeGift:p,setCheckedGift:m}=y(),{freeLabel:n}=p||{};return t("div",{className:"flex items-center justify-between",children:[t("div",{className:"flex items-center gap-4",children:[e(N,{source:l?.image?.url,className:"size-16 object-cover"}),t("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:[e(s,{className:"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]",html:l?.product?.title}),e(s,{className:"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]",html:`x1 | ${n}`})]})]}),t("div",{className:"flex flex-col items-end gap-2 justify-center",children:[a&&t("div",{className:"flex items-center gap-1",children:[e(s,{className:"text-base desktop:text-2xl font-bold",html:n}),e(s,{className:"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]",html:f({amount:l.price.amount,locale:o,currencyCode:l.price.currencyCode})})]}),e(g,{size:a?"icon":"lg",variant:a?"link":"primary",onClick:()=>{m?.(a?void 0:l),d(l)},className:F("shrink-0 size-auto",{underline:a}),children:a?"Remove":"Add +"})]})]})};var Q=S;export{Q as default};
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Text as s,Button as g,Grid as I,GridItem as G,Picture as N,Heading as L}from"../../../../../components";import{useProductContext as y}from"../../../ProductProvider";import{useEffect as R,useMemo as A,useState as O}from"react";import{formatPrice as f}from"../../../utils";import{useAiuiContext as C}from"../../../../AiuiProvider";import{cn as F}from"../../../../../helpers";import V from"decimal.js";const S=({})=>{const{locale:d="us",copyWriting:a}=C(),{product:l,variant:i,finalPrice:p,comparePrice:m,coupon:n,selectedOptions:c,onAddToCart:k,onBuyNow:h,savingDetail:b,joinedRecommendBuyProducts:o,setJoinedRecommendBuyProducts:u}=y();if(!i.availableForSale)return null;const{bundleVariant:B,giftVariant:w}=$()||{},[r,v]=O();R(()=>{v({bundle:o.bundle?void 0:B,gift:o.gift?void 0:w})},[B,w,o]);const D=A(()=>new V(m).minus(b.freeGift).toNumber(),[m,b]);return e("div",{className:"ipc-product-summary bg-[#F5F5F7] mt-16",children:t(I,{className:"px-4 py-6 tablet:p-8",children:[t(G,{className:"col-span-12 desktop:col-start-1 desktop:col-span-5",children:[e(L,{className:"font-bold text-[24px] lg-desktop:text-[48px] laptop:text-[32px] desktop:text-[40px] leading-[1] mb-4 [&>span]:text-[#D1D1D1]",html:`${l.title} is ready <br/><span>Just the way you want it.</span>`}),e("div",{className:"aspect-[644/320]",children:e(N,{source:i.image?.url||l?.images?.[0]?.url,className:"h-full w-full",imgClassName:"object-contain h-full"})})]}),t(G,{className:"col-span-12 mt-8 desktop:col-start-7 laptop:mt-0 desktop:col-span-6 flex flex-col gap-6 justify-between",children:[t("div",{children:[t("div",{className:"flex flex-col gap-4",children:[t("div",{className:"flex items-center justify-between",children:[t("div",{className:"shrink-0 flex items-center gap-4",children:[e(N,{source:i.image?.url||l?.images?.[0]?.url,className:"size-16 object-cover"}),t("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:[e(s,{className:"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]",html:l.title}),e(s,{className:"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]",html:`x1 | ${c.color||c.colour||c.couleur}`})]})]}),t("div",{className:"flex items-center gap-1",children:[e(s,{className:"text-base desktop:text-2xl font-bold",html:f({amount:p,currencyCode:i.price.currencyCode,locale:d})}),n&&e(s,{className:"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]",html:f({amount:D,currencyCode:i.price.currencyCode,locale:d})})]})]}),o?.gift&&e(z,{giftOperation:x=>{u?.({...o,gift:void 0}),v?.({...r,gift:x})},giftStatus:!!o?.gift,gift:o?.gift}),o?.bundle&&e(j,{bundleOperation:x=>{u?.({...o,bundle:void 0}),v?.({...r,bundle:x})},bundleStatus:!!o?.bundle,bundleListItem:o?.bundle})]}),(r?.bundle||r?.gift)&&t("div",{className:"mt-6",children:[e(s,{className:"text-sm desktop:text-[18px] font-bold",html:"Recommend Buy"}),t("div",{className:"flex flex-col gap-6 mt-6",children:[r?.gift&&e(z,{giftOperation:x=>{u?.({gift:x}),v?.({...r,gift:void 0})},giftStatus:!r?.gift,gift:r?.gift}),r?.bundle&&e(j,{bundleOperation:x=>{u?.({bundle:x}),v?.({...r,bundle:void 0})},bundleStatus:!r?.bundle,bundleListItem:r?.bundle})]})]})]}),t("div",{className:"text-right",children:[e(s,{className:"laptop:text-xl desktop:text-2xl font-bold text-right",html:`${a?.totalPrice} ${f({amount:p,currencyCode:i.price.currencyCode,locale:d})}`}),n&&e(s,{className:"text-base desktop:text-2xl ml-1 font-bold line-through text-[#6D6D6F]",html:f({amount:D,currencyCode:i.price.currencyCode,locale:d})}),t("div",{className:"flex gap-3 mt-2",children:[e(g,{size:"lg",variant:"secondary",className:"w-1/2",onClick:()=>k?.(),children:a?.addToCart}),e(g,{size:"lg",variant:"primary",className:"w-1/2",onClick:()=>h?.(),children:a?.shopNow})]})]})]})]})})},$=()=>{const{bundle:d,variant:a,checkedBundle:l,freeGift:i,checkedGift:p}=y();let m,n;const{bundleList:c}=d||{},{giftList:k=[]}=i||{},h=c?.filter(u=>u.variants.slice(1,u.variants.length).every(P=>P.variant.availableForSale))||[],[b]=h;m=l||b;const[o]=k?.filter(u=>u.availableForSale);return n=p||o,{bundleVariant:m,giftVariant:n}},j=({bundleOperation:d,bundleStatus:a,bundleListItem:l})=>{const{locale:i="us"}=C(),{variant:p,setCheckedBundle:m}=y(),n=l?.variants.filter(c=>c.variant.sku!==p.sku);return t("div",{className:"flex items-center justify-between",children:[n?.map(c=>t("div",{className:"flex items-center gap-4",children:[e(N,{source:c?.variant?.image?.url,className:"size-16 object-cover"}),e("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:e(s,{className:"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]",html:c.variant.product.title})})]},c.variant.id)),t("div",{className:"flex flex-col items-end gap-1 justify-center",children:[a&&e(s,{className:"text-base desktop:text-2xl font-bold",html:f({amount:n[0]?.price,locale:i,currencyCode:n[0]?.variant?.price?.currencyCode})}),e(g,{size:a?"icon":"lg",variant:a?"link":"primary",onClick:()=>{m?.(a?void 0:l),d(l)},className:F("shrink-0 size-auto",{underline:a}),children:a?"Remove":"Add +"})]})]})},z=({giftOperation:d,giftStatus:a,gift:l})=>{const{locale:i="us"}=C(),{freeGift:p,setCheckedGift:m}=y(),{freeLabel:n}=p||{};return t("div",{className:"flex items-center justify-between",children:[t("div",{className:"flex items-center gap-4",children:[e(N,{source:l?.image?.url,className:"size-16 object-cover"}),t("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:[e(s,{className:"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]",html:l?.product?.title}),e(s,{className:"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]",html:`x1 | ${n}`})]})]}),t("div",{className:"flex flex-col items-end gap-2 justify-center",children:[a&&t("div",{className:"flex items-center gap-1",children:[e(s,{className:"text-base desktop:text-2xl font-bold",html:n}),e(s,{className:"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]",html:f({amount:l.price.amount,locale:i,currencyCode:l.price.currencyCode})})]}),e(g,{size:a?"icon":"lg",variant:a?"link":"primary",onClick:()=>{m?.(a?void 0:l),d(l)},className:F("shrink-0 size-auto",{underline:a}),children:a?"Remove":"Add +"})]})]})};var Q=S;export{Q as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/biz-components/Listing/components/ProductCard/ProductSummary/index.tsx"],
4
- "sourcesContent": ["import { Text, Button, Container, Grid, GridItem, Picture, Heading } from '../../../../../components'\nimport type { ProductSummaryProps } from './types'\nimport { useProductContext } from '../../../ProductProvider'\nimport { useEffect, useMemo, useState } from 'react'\nimport { formatPrice } from '../../../utils'\nimport { useAiuiContext } from '../../../../AiuiProvider'\nimport type { BundleListItem, ProductVariant } from '../../../types/product'\nimport { cn } from '../../../../../helpers'\nimport Decimal from 'decimal.js'\n\nconst ProductSummary = ({}: ProductSummaryProps) => {\n const { locale = 'us', copyWriting } = useAiuiContext()\n const {\n product,\n variant,\n finalPrice,\n comparePrice,\n coupon,\n selectedOptions,\n onAddToCart,\n onBuyNow,\n savingDetail,\n joinedRecommendBuyProducts,\n setJoinedRecommendBuyProducts,\n } = useProductContext()\n\n const isAvailable = variant.availableForSale\n if (!isAvailable) return null\n\n const { bundleVariant, giftVariant } = useRecommendBuyProducts() || {}\n const [initialRecommendBuyProducts, setInitialRecommendBuyProducts] = useState<{\n bundle?: BundleListItem\n gift?: ProductVariant\n }>()\n\n useEffect(() => {\n setInitialRecommendBuyProducts({\n bundle: joinedRecommendBuyProducts.bundle ? undefined : bundleVariant,\n gift: joinedRecommendBuyProducts.gift ? undefined : giftVariant,\n })\n }, [bundleVariant, giftVariant, joinedRecommendBuyProducts])\n\n const comparePriceRemovedFreeGift = useMemo(\n () => new Decimal(comparePrice).minus(savingDetail.freeGift).toNumber(),\n [comparePrice, savingDetail]\n )\n\n return (\n <div className=\"ipc-product-summary bg-[#F5F5F7] mt-16\">\n <Grid className=\"px-4 py-6 tablet:p-8\">\n <GridItem className=\"col-span-12 desktop:col-start-1 desktop:col-span-5\">\n <Heading\n className=\"font-bold text-[24px] lg-desktop:text-[48px] laptop:text-[32px] desktop:text-[40px] leading-[1] mb-4 [&>span]:text-[#D1D1D1]\"\n html={`${product.title} is ready <br/><span>Just the way you want it.</span>`}\n />\n <div className=\"aspect-[644/320]\">\n <Picture\n source={variant.image?.url || product?.images?.[0]?.url}\n className=\"h-full w-full\"\n imgClassName=\"object-contain h-full\"\n />\n </div>\n </GridItem>\n <GridItem className=\"col-span-12 mt-8 desktop:col-start-7 laptop:mt-0 desktop:col-span-6 flex flex-col gap-6 justify-between\">\n <div>\n <div className=\"flex flex-col gap-4\">\n <div className=\"flex items-center justify-between\">\n <div className=\"shrink-0 flex items-center gap-4\">\n <Picture source={variant.image?.url || product?.images?.[0]?.url} className=\"size-16 object-cover\" />\n <div className=\"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none\">\n <Text\n className=\"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]\"\n html={product.title}\n />\n <Text\n className=\"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]\"\n html={`x1 | ${selectedOptions.color || selectedOptions.colour || selectedOptions.couleur}`}\n />\n </div>\n </div>\n <div className=\"flex items-center gap-1\">\n <Text\n className=\"text-base desktop:text-2xl font-bold\"\n html={formatPrice({ amount: finalPrice, currencyCode: variant.price.currencyCode, locale })}\n />\n {coupon && (\n <Text\n className=\"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]\"\n html={formatPrice({\n amount: comparePriceRemovedFreeGift,\n currencyCode: variant.price.currencyCode,\n locale,\n })}\n />\n )}\n </div>\n </div>\n {joinedRecommendBuyProducts?.gift && (\n <ProductGiftSummary\n giftOperation={gift => {\n setJoinedRecommendBuyProducts?.({ ...joinedRecommendBuyProducts, gift: undefined })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, gift })\n }}\n giftStatus={!!joinedRecommendBuyProducts?.gift}\n gift={joinedRecommendBuyProducts?.gift}\n />\n )}\n {joinedRecommendBuyProducts?.bundle && (\n <ProductBundleSummary\n bundleOperation={bundle => {\n setJoinedRecommendBuyProducts?.({ ...joinedRecommendBuyProducts, bundle: undefined })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, bundle })\n }}\n bundleStatus={!!joinedRecommendBuyProducts?.bundle}\n bundleListItem={joinedRecommendBuyProducts?.bundle}\n />\n )}\n </div>\n {(initialRecommendBuyProducts?.bundle || initialRecommendBuyProducts?.gift) && (\n <div className=\"mt-6\">\n <Text className=\"text-sm desktop:text-[18px] font-bold\" html={'Recommend Buy'} />\n <div className=\"flex flex-col gap-6 mt-6\">\n {initialRecommendBuyProducts?.gift && (\n <ProductGiftSummary\n giftOperation={gift => {\n setJoinedRecommendBuyProducts?.({ ...joinedRecommendBuyProducts, gift })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, gift: undefined })\n }}\n giftStatus={!initialRecommendBuyProducts?.gift}\n gift={initialRecommendBuyProducts?.gift}\n />\n )}\n {initialRecommendBuyProducts?.bundle && (\n <ProductBundleSummary\n bundleOperation={bundle => {\n setJoinedRecommendBuyProducts?.({ ...joinedRecommendBuyProducts, bundle })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, bundle: undefined })\n }}\n bundleStatus={!initialRecommendBuyProducts?.bundle}\n bundleListItem={initialRecommendBuyProducts?.bundle}\n />\n )}\n </div>\n </div>\n )}\n </div>\n <div className=\"text-right\">\n <Text\n className=\"laptop:text-xl desktop:text-2xl font-bold text-right\"\n html={`${copyWriting?.totalPrice} ${formatPrice({ amount: finalPrice, currencyCode: variant.price.currencyCode, locale })}`}\n />\n\n {coupon && (\n <Text\n className=\"text-base desktop:text-2xl ml-1 font-bold line-through text-[#6D6D6F]\"\n html={formatPrice({\n amount: comparePriceRemovedFreeGift,\n currencyCode: variant.price.currencyCode,\n locale,\n })}\n />\n )}\n <div className=\"flex gap-3 mt-2\">\n <Button size=\"lg\" variant=\"secondary\" className=\"w-1/2\" onClick={() => onAddToCart?.()}>\n {copyWriting?.addToCart}\n </Button>\n <Button size=\"lg\" variant=\"primary\" className=\"w-1/2\" onClick={() => onBuyNow?.()}>\n {copyWriting?.shopNow}\n </Button>\n </div>\n </div>\n </GridItem>\n </Grid>\n </div>\n )\n}\n\nconst useRecommendBuyProducts = () => {\n const { bundle, variant, checkedBundle, freeGift, checkedGift } = useProductContext()\n let bundleVariant = undefined\n let giftVariant = undefined\n const { bundleList } = bundle || {}\n\n const { giftList = [] } = freeGift || {}\n\n const availableBundleList =\n bundleList?.filter(bundle =>\n bundle.variants.slice(1, bundle.variants.length).every(v => v.variant.availableForSale)\n ) || []\n\n const [firstAvailableBundle] = availableBundleList\n bundleVariant = checkedBundle || firstAvailableBundle\n\n const [firstAvailableGift] = giftList?.filter(gift => gift.availableForSale)\n giftVariant = checkedGift || firstAvailableGift\n\n return { bundleVariant, giftVariant }\n}\n\nconst ProductBundleSummary = ({\n bundleOperation,\n bundleStatus,\n bundleListItem,\n}: {\n bundleOperation: (bundle: BundleListItem) => void\n bundleStatus: boolean\n bundleListItem: BundleListItem\n}) => {\n const { locale = 'us' } = useAiuiContext()\n const { variant, setCheckedBundle } = useProductContext()\n const bundleVariants = bundleListItem?.variants.filter(v => v.variant.sku !== variant.sku)\n\n return (\n <div className=\"flex items-center justify-between\">\n {bundleVariants?.map(bundleVariant => {\n return (\n <div className=\"flex items-center gap-4\" key={bundleVariant.variant.id}>\n <Picture source={bundleVariant?.variant?.image?.url} className=\"size-16 object-cover\" />\n <div className=\"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none\">\n <Text\n className=\"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]\"\n html={bundleVariant.variant.product.title}\n />\n </div>\n </div>\n )\n })}\n <div className=\"flex flex-col items-end gap-1 justify-center\">\n {bundleStatus && (\n <Text\n className=\"text-base desktop:text-2xl font-bold\"\n html={formatPrice({\n amount: bundleVariants[0]?.price,\n locale,\n currencyCode: bundleVariants[0]?.variant?.price?.currencyCode,\n })}\n />\n )}\n <Button\n size={bundleStatus ? 'icon' : 'lg'}\n variant={bundleStatus ? 'link' : 'primary'}\n onClick={() => {\n setCheckedBundle?.(bundleStatus ? undefined : bundleListItem)\n bundleOperation(bundleListItem)\n }}\n className={cn('shrink-0 size-auto', {\n underline: bundleStatus,\n })}\n >\n {bundleStatus ? 'Remove' : 'Add +'}\n </Button>\n </div>\n </div>\n )\n}\n\nconst ProductGiftSummary = ({\n giftOperation,\n giftStatus,\n gift,\n}: {\n giftOperation: (gift: ProductVariant) => void\n giftStatus: boolean\n gift: ProductVariant\n}) => {\n const { locale = 'us' } = useAiuiContext()\n const { freeGift, setCheckedGift } = useProductContext()\n const { freeLabel } = freeGift || {}\n\n return (\n <div className=\"flex items-center justify-between\">\n <div className=\"flex items-center gap-4\">\n <Picture source={gift?.image?.url} className=\"size-16 object-cover\" />\n <div className=\"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none\">\n <Text\n className=\"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]\"\n html={gift?.product?.title}\n />\n <Text\n className=\"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]\"\n html={`x1 | ${freeLabel}`}\n />\n </div>\n </div>\n <div className=\"flex flex-col items-end gap-2 justify-center\">\n {giftStatus && (\n <div className=\"flex items-center gap-1\">\n <Text className=\"text-base desktop:text-2xl font-bold\" html={freeLabel} />\n <Text\n className=\"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]\"\n html={formatPrice({\n amount: gift.price.amount,\n locale,\n currencyCode: gift.price.currencyCode,\n })}\n />\n </div>\n )}\n <Button\n size={giftStatus ? 'icon' : 'lg'}\n variant={giftStatus ? 'link' : 'primary'}\n onClick={() => {\n setCheckedGift?.(giftStatus ? undefined : gift)\n giftOperation(gift)\n }}\n className={cn('shrink-0 size-auto', {\n underline: giftStatus,\n })}\n >\n {giftStatus ? 'Remove' : 'Add +'}\n </Button>\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OAAQyB,EAAK,MAAM,OACnB,OAAApB,EACA,aAAcoB,EAAK,MAAM,YAC3B,CAAC,EACH,GACF,EAEFrC,EAACG,EAAA,CACC,KAAMoD,EAAa,OAAS,KAC5B,QAASA,EAAa,OAAS,UAC/B,QAAS,IAAM,CACbC,IAAiBD,EAAa,OAAYlB,CAAI,EAC9CiB,EAAcjB,CAAI,CACpB,EACA,UAAWvB,EAAG,qBAAsB,CAClC,UAAWyC,CACb,CAAC,EAEA,SAAAA,EAAa,SAAW,QAC3B,GACF,GACF,CAEJ,EAEA,IAAOG,EAAQ1C",
4
+ "sourcesContent": ["import { Text, Button, Container, Grid, GridItem, Picture, Heading } from '../../../../../components'\nimport type { ProductSummaryProps } from './types'\nimport { useProductContext } from '../../../ProductProvider'\nimport { useEffect, useMemo, useState } from 'react'\nimport { formatPrice } from '../../../utils'\nimport { useAiuiContext } from '../../../../AiuiProvider'\nimport type { BundleListItem, ProductVariant } from '../../../types/product'\nimport { cn } from '../../../../../helpers'\nimport Decimal from 'decimal.js'\n\nconst ProductSummary = ({}: ProductSummaryProps) => {\n const { locale = 'us', copyWriting } = useAiuiContext()\n const {\n product,\n variant,\n finalPrice,\n comparePrice,\n coupon,\n selectedOptions,\n onAddToCart,\n onBuyNow,\n savingDetail,\n joinedRecommendBuyProducts,\n setJoinedRecommendBuyProducts,\n } = useProductContext()\n\n const isAvailable = variant.availableForSale\n if (!isAvailable) return null\n\n const { bundleVariant, giftVariant } = useRecommendBuyProducts() || {}\n const [initialRecommendBuyProducts, setInitialRecommendBuyProducts] = useState<{\n bundle?: BundleListItem\n gift?: ProductVariant\n }>()\n\n useEffect(() => {\n setInitialRecommendBuyProducts({\n bundle: joinedRecommendBuyProducts.bundle ? undefined : bundleVariant,\n gift: joinedRecommendBuyProducts.gift ? undefined : giftVariant,\n })\n }, [bundleVariant, giftVariant, joinedRecommendBuyProducts])\n\n const comparePriceRemovedFreeGift = useMemo(\n () => new Decimal(comparePrice).minus(savingDetail.freeGift).toNumber(),\n [comparePrice, savingDetail]\n )\n\n return (\n <div className=\"ipc-product-summary bg-[#F5F5F7] mt-16\">\n <Grid className=\"px-4 py-6 tablet:p-8\">\n <GridItem className=\"col-span-12 desktop:col-start-1 desktop:col-span-5\">\n <Heading\n className=\"font-bold text-[24px] lg-desktop:text-[48px] laptop:text-[32px] desktop:text-[40px] leading-[1] mb-4 [&>span]:text-[#D1D1D1]\"\n html={`${product.title} is ready <br/><span>Just the way you want it.</span>`}\n />\n <div className=\"aspect-[644/320]\">\n <Picture\n source={variant.image?.url || product?.images?.[0]?.url}\n className=\"h-full w-full\"\n imgClassName=\"object-contain h-full\"\n />\n </div>\n </GridItem>\n <GridItem className=\"col-span-12 mt-8 desktop:col-start-7 laptop:mt-0 desktop:col-span-6 flex flex-col gap-6 justify-between\">\n <div>\n <div className=\"flex flex-col gap-4\">\n <div className=\"flex items-center justify-between\">\n <div className=\"shrink-0 flex items-center gap-4\">\n <Picture source={variant.image?.url || product?.images?.[0]?.url} className=\"size-16 object-cover\" />\n <div className=\"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none\">\n <Text\n className=\"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]\"\n html={product.title}\n />\n <Text\n className=\"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]\"\n html={`x1 | ${selectedOptions.color || selectedOptions.colour || selectedOptions.couleur}`}\n />\n </div>\n </div>\n <div className=\"flex items-center gap-1\">\n <Text\n className=\"text-base desktop:text-2xl font-bold\"\n html={formatPrice({ amount: finalPrice, currencyCode: variant.price.currencyCode, locale })}\n />\n {coupon && (\n <Text\n className=\"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]\"\n html={formatPrice({\n amount: comparePriceRemovedFreeGift,\n currencyCode: variant.price.currencyCode,\n locale,\n })}\n />\n )}\n </div>\n </div>\n {joinedRecommendBuyProducts?.gift && (\n <ProductGiftSummary\n giftOperation={gift => {\n setJoinedRecommendBuyProducts?.({ ...joinedRecommendBuyProducts, gift: undefined })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, gift })\n }}\n giftStatus={!!joinedRecommendBuyProducts?.gift}\n gift={joinedRecommendBuyProducts?.gift}\n />\n )}\n {joinedRecommendBuyProducts?.bundle && (\n <ProductBundleSummary\n bundleOperation={bundle => {\n setJoinedRecommendBuyProducts?.({ ...joinedRecommendBuyProducts, bundle: undefined })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, bundle })\n }}\n bundleStatus={!!joinedRecommendBuyProducts?.bundle}\n bundleListItem={joinedRecommendBuyProducts?.bundle}\n />\n )}\n </div>\n {(initialRecommendBuyProducts?.bundle || initialRecommendBuyProducts?.gift) && (\n <div className=\"mt-6\">\n <Text className=\"text-sm desktop:text-[18px] font-bold\" html={'Recommend Buy'} />\n <div className=\"flex flex-col gap-6 mt-6\">\n {initialRecommendBuyProducts?.gift && (\n <ProductGiftSummary\n giftOperation={gift => {\n setJoinedRecommendBuyProducts?.({ gift })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, gift: undefined })\n }}\n giftStatus={!initialRecommendBuyProducts?.gift}\n gift={initialRecommendBuyProducts?.gift}\n />\n )}\n {initialRecommendBuyProducts?.bundle && (\n <ProductBundleSummary\n bundleOperation={bundle => {\n setJoinedRecommendBuyProducts?.({ bundle })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, bundle: undefined })\n }}\n bundleStatus={!initialRecommendBuyProducts?.bundle}\n bundleListItem={initialRecommendBuyProducts?.bundle}\n />\n )}\n </div>\n </div>\n )}\n </div>\n <div className=\"text-right\">\n <Text\n className=\"laptop:text-xl desktop:text-2xl font-bold text-right\"\n html={`${copyWriting?.totalPrice} ${formatPrice({ amount: finalPrice, currencyCode: variant.price.currencyCode, locale })}`}\n />\n\n {coupon && (\n <Text\n className=\"text-base desktop:text-2xl ml-1 font-bold line-through text-[#6D6D6F]\"\n html={formatPrice({\n amount: comparePriceRemovedFreeGift,\n currencyCode: variant.price.currencyCode,\n locale,\n })}\n />\n )}\n <div className=\"flex gap-3 mt-2\">\n <Button size=\"lg\" variant=\"secondary\" className=\"w-1/2\" onClick={() => onAddToCart?.()}>\n {copyWriting?.addToCart}\n </Button>\n <Button size=\"lg\" variant=\"primary\" className=\"w-1/2\" onClick={() => onBuyNow?.()}>\n {copyWriting?.shopNow}\n </Button>\n </div>\n </div>\n </GridItem>\n </Grid>\n </div>\n )\n}\n\nconst useRecommendBuyProducts = () => {\n const { bundle, variant, checkedBundle, freeGift, checkedGift } = useProductContext()\n let bundleVariant = undefined\n let giftVariant = undefined\n const { bundleList } = bundle || {}\n\n const { giftList = [] } = freeGift || {}\n\n const availableBundleList =\n bundleList?.filter(bundle =>\n bundle.variants.slice(1, bundle.variants.length).every(v => v.variant.availableForSale)\n ) || []\n\n const [firstAvailableBundle] = availableBundleList\n bundleVariant = checkedBundle || firstAvailableBundle\n\n const [firstAvailableGift] = giftList?.filter(gift => gift.availableForSale)\n giftVariant = checkedGift || firstAvailableGift\n\n return { bundleVariant, giftVariant }\n}\n\nconst ProductBundleSummary = ({\n bundleOperation,\n bundleStatus,\n bundleListItem,\n}: {\n bundleOperation: (bundle: BundleListItem) => void\n bundleStatus: boolean\n bundleListItem: BundleListItem\n}) => {\n const { locale = 'us' } = useAiuiContext()\n const { variant, setCheckedBundle } = useProductContext()\n const bundleVariants = bundleListItem?.variants.filter(v => v.variant.sku !== variant.sku)\n\n return (\n <div className=\"flex items-center justify-between\">\n {bundleVariants?.map(bundleVariant => {\n return (\n <div className=\"flex items-center gap-4\" key={bundleVariant.variant.id}>\n <Picture source={bundleVariant?.variant?.image?.url} className=\"size-16 object-cover\" />\n <div className=\"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none\">\n <Text\n className=\"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]\"\n html={bundleVariant.variant.product.title}\n />\n </div>\n </div>\n )\n })}\n <div className=\"flex flex-col items-end gap-1 justify-center\">\n {bundleStatus && (\n <Text\n className=\"text-base desktop:text-2xl font-bold\"\n html={formatPrice({\n amount: bundleVariants[0]?.price,\n locale,\n currencyCode: bundleVariants[0]?.variant?.price?.currencyCode,\n })}\n />\n )}\n <Button\n size={bundleStatus ? 'icon' : 'lg'}\n variant={bundleStatus ? 'link' : 'primary'}\n onClick={() => {\n setCheckedBundle?.(bundleStatus ? undefined : bundleListItem)\n bundleOperation(bundleListItem)\n }}\n className={cn('shrink-0 size-auto', {\n underline: bundleStatus,\n })}\n >\n {bundleStatus ? 'Remove' : 'Add +'}\n </Button>\n </div>\n </div>\n )\n}\n\nconst ProductGiftSummary = ({\n giftOperation,\n giftStatus,\n gift,\n}: {\n giftOperation: (gift: ProductVariant) => void\n giftStatus: boolean\n gift: ProductVariant\n}) => {\n const { locale = 'us' } = useAiuiContext()\n const { freeGift, setCheckedGift } = useProductContext()\n const { freeLabel } = freeGift || {}\n\n return (\n <div className=\"flex items-center justify-between\">\n <div className=\"flex items-center gap-4\">\n <Picture source={gift?.image?.url} className=\"size-16 object-cover\" />\n <div className=\"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none\">\n <Text\n className=\"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]\"\n html={gift?.product?.title}\n />\n <Text\n className=\"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]\"\n html={`x1 | ${freeLabel}`}\n />\n </div>\n </div>\n <div className=\"flex flex-col items-end gap-2 justify-center\">\n {giftStatus && (\n <div className=\"flex items-center gap-1\">\n <Text className=\"text-base desktop:text-2xl font-bold\" html={freeLabel} />\n <Text\n className=\"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]\"\n html={formatPrice({\n amount: gift.price.amount,\n locale,\n currencyCode: gift.price.currencyCode,\n })}\n />\n </div>\n )}\n <Button\n size={giftStatus ? 'icon' : 'lg'}\n variant={giftStatus ? 'link' : 'primary'}\n onClick={() => {\n setCheckedGift?.(giftStatus ? undefined : gift)\n giftOperation(gift)\n }}\n className={cn('shrink-0 size-auto', {\n underline: giftStatus,\n })}\n >\n {giftStatus ? 'Remove' : 'Add +'}\n </Button>\n </div>\n </div>\n )\n}\n\nexport default ProductSummary\n"],
5
+ "mappings": "AAkDQ,OACE,OAAAA,EADF,QAAAC,MAAA,oBAlDR,OAAS,QAAAC,EAAM,UAAAC,EAAmB,QAAAC,EAAM,YAAAC,EAAU,WAAAC,EAAS,WAAAC,MAAe,4BAE1E,OAAS,qBAAAC,MAAyB,2BAClC,OAAS,aAAAC,EAAW,WAAAC,EAAS,YAAAC,MAAgB,QAC7C,OAAS,eAAAC,MAAmB,iBAC5B,OAAS,kBAAAC,MAAsB,2BAE/B,OAAS,MAAAC,MAAU,yBACnB,OAAOC,MAAa,aAEpB,MAAMC,EAAiB,CAAC,CAAC,IAA2B,CAClD,KAAM,CAAE,OAAAC,EAAS,KAAM,YAAAC,CAAY,EAAIL,EAAe,EAChD,CACJ,QAAAM,EACA,QAAAC,EACA,WAAAC,EACA,aAAAC,EACA,OAAAC,EACA,gBAAAC,EACA,YAAAC,EACA,SAAAC,EACA,aAAAC,EACA,2BAAAC,EACA,8BAAAC,CACF,EAAIrB,EAAkB,EAGtB,GAAI,CADgBY,EAAQ,iBACV,OAAO,KAEzB,KAAM,CAAE,cAAAU,EAAe,YAAAC,CAAY,EAAIC,EAAwB,GAAK,CAAC,EAC/D,CAACC,EAA6BC,CAA8B,EAAIvB,EAGnE,EAEHF,EAAU,IAAM,CACdyB,EAA+B,CAC7B,OAAQN,EAA2B,OAAS,OAAYE,EACxD,KAAMF,EAA2B,KAAO,OAAYG,CACtD,CAAC,CACH,EAAG,CAACD,EAAeC,EAAaH,CAA0B,CAAC,EAE3D,MAAMO,EAA8BzB,EAClC,IAAM,IAAIK,EAAQO,CAAY,EAAE,MAAMK,EAAa,QAAQ,EAAE,SAAS,EACtE,CAACL,EAAcK,CAAY,CAC7B,EAEA,OACE3B,EAAC,OAAI,UAAU,yCACb,SAAAC,EAACG,EAAA,CAAK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W,EACxEzD,EAACE,EAAA,CACC,UAAU,mEACV,KAAMU,EAAY,CAChB,OAAQyB,EAAK,MAAM,OACnB,OAAApB,EACA,aAAcoB,EAAK,MAAM,YAC3B,CAAC,EACH,GACF,EAEFrC,EAACG,EAAA,CACC,KAAMoD,EAAa,OAAS,KAC5B,QAASA,EAAa,OAAS,UAC/B,QAAS,IAAM,CACbC,IAAiBD,EAAa,OAAYlB,CAAI,EAC9CiB,EAAcjB,CAAI,CACpB,EACA,UAAWvB,EAAG,qBAAsB,CAClC,UAAWyC,CACb,CAAC,EAEA,SAAAA,EAAa,SAAW,QAC3B,GACF,GACF,CAEJ,EAEA,IAAOG,EAAQ1C",
6
6
  "names": ["jsx", "jsxs", "Text", "Button", "Grid", "GridItem", "Picture", "Heading", "useProductContext", "useEffect", "useMemo", "useState", "formatPrice", "useAiuiContext", "cn", "Decimal", "ProductSummary", "locale", "copyWriting", "product", "variant", "finalPrice", "comparePrice", "coupon", "selectedOptions", "onAddToCart", "onBuyNow", "savingDetail", "joinedRecommendBuyProducts", "setJoinedRecommendBuyProducts", "bundleVariant", "giftVariant", "useRecommendBuyProducts", "initialRecommendBuyProducts", "setInitialRecommendBuyProducts", "comparePriceRemovedFreeGift", "ProductGiftSummary", "gift", "ProductBundleSummary", "bundle", "checkedBundle", "freeGift", "checkedGift", "bundleList", "giftList", "availableBundleList", "v", "firstAvailableBundle", "firstAvailableGift", "bundleOperation", "bundleStatus", "bundleListItem", "setCheckedBundle", "bundleVariants", "giftOperation", "giftStatus", "setCheckedGift", "freeLabel", "ProductSummary_default"]
7
7
  }
@@ -0,0 +1,50 @@
1
+ import type { ProductVariant, FreeGift, Bundle } from '../types/product';
2
+ interface BenefitsParams {
3
+ variant: ProductVariant;
4
+ }
5
+ interface BenefitItemConfig<T extends Record<string, any> = Record<string, any>> {
6
+ enable: boolean;
7
+ config?: T;
8
+ }
9
+ interface BenefitsResult {
10
+ /**
11
+ * 通用优惠券
12
+ */
13
+ commonCoupon?: BenefitItemConfig;
14
+ /**
15
+ * 买赠
16
+ */
17
+ freeGift: BenefitItemConfig<FreeGift>;
18
+ /**
19
+ * 捆绑折扣
20
+ */
21
+ bundle: BenefitItemConfig<Bundle>;
22
+ /**
23
+ * 会员价
24
+ */
25
+ memberDiscount: BenefitItemConfig;
26
+ /**
27
+ * 积分抵现
28
+ */
29
+ creditsRedemption: BenefitItemConfig;
30
+ /**
31
+ * 高标物流
32
+ */
33
+ paidShipping: BenefitItemConfig;
34
+ /**
35
+ * 满赠
36
+ */
37
+ fullGift: BenefitItemConfig;
38
+ /**
39
+ * 满减折扣
40
+ */
41
+ levelDiscount: BenefitItemConfig;
42
+ }
43
+ /**
44
+ * 商品权益
45
+ * 获取当前sku 所有的权益
46
+ * 包括 通用优惠券,会员价,满减,捆绑折扣,买赠 ,满赠 ,积分抵现
47
+ * @returns
48
+ */
49
+ export declare const useBenefits: ({ variant, }: BenefitsParams) => BenefitsResult;
50
+ export {};
@@ -0,0 +1,2 @@
1
+ import{useProductContext as p}from"../ProductProvider";import{checkItemAvailableForProduct as g}from"../utils/helper";import{useAiuiContext as b}from"../../AiuiProvider/index.js";const I=({variant:t})=>{const{coupon:s,product:u,bundle:o,freeGift:i,memberFunctionResult:l,creditsRedemptionAmount:f}=p(),{trackingData:n}=b(),c=Math.max(l?.withCouponMemberTotalSave??0,l?.withoutCouponMaxMemberTotalSave??0),r=!!(n?.paidShipping&&t.requiresShipping&&!t?.metafields?.global?.presell&&!t?.metafields?.global?.HideShipping),a=n?.freeGift,m=a?.excludeProducts?.map(e=>typeof e=="object"&&"sku"in e?e.sku:e)??[],d=n?.levelDiscount&&g({product:u,variant:t,item:n?.levelDiscount});return{commonCoupon:{enable:!!s,config:s??{}},freeGift:{enable:!!i&&!!i?.giftList?.length,config:i},bundle:{enable:!!o&&!!o?.bundleList?.length&&Math.max(...o?.bundleList?.map(e=>e.savings??0))>0,config:o},memberDiscount:{enable:c>0,config:{amount:c,description:l?.labels?.find(e=>e.key==="benefit_tab_string")?.value}},creditsRedemption:{enable:!!f&&f>0,config:{amount:f,label:n?.creditsRedemptionLabel}},paidShipping:{enable:r,config:{}},fullGift:{enable:!!(a&&!m.includes(t.sku)),config:a??{}},levelDiscount:{enable:!!d,config:n?.levelDiscount??{}}}};export{I as useBenefits};
2
+ //# sourceMappingURL=useBenefits.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/biz-components/Listing/hooks/useBenefits.ts"],
4
+ "sourcesContent": ["import { useProductContext } from '../ProductProvider'\nimport type { ProductVariant, FreeGift, Bundle } from '../types/product'\nimport { checkItemAvailableForProduct } from '../utils/helper'\n\n\nimport { useAiuiContext } from '../../AiuiProvider/index.js'\n\ninterface BenefitsParams {\n variant: ProductVariant\n}\n\ninterface BenefitItemConfig<T extends Record<string, any> = Record<string, any>> {\n enable: boolean\n config?: T // \u539F\u59CB\u914D\u7F6E\n}\n\ninterface BenefitsResult {\n /**\n * \u901A\u7528\u4F18\u60E0\u5238\n */\n commonCoupon?: BenefitItemConfig\n /**\n * \u4E70\u8D60\n */\n freeGift: BenefitItemConfig<FreeGift>\n /**\n * \u6346\u7ED1\u6298\u6263\n */\n bundle: BenefitItemConfig<Bundle>\n /**\n * \u4F1A\u5458\u4EF7\n */\n memberDiscount: BenefitItemConfig\n /**\n * \u79EF\u5206\u62B5\u73B0\n */\n creditsRedemption: BenefitItemConfig\n /**\n * \u9AD8\u6807\u7269\u6D41\n */\n paidShipping: BenefitItemConfig\n\n /**\n * \u6EE1\u8D60\n */\n fullGift: BenefitItemConfig\n\n /**\n * \u6EE1\u51CF\u6298\u6263\n */\n levelDiscount: BenefitItemConfig\n}\n\n/**\n * \u5546\u54C1\u6743\u76CA\n * \u83B7\u53D6\u5F53\u524Dsku \u6240\u6709\u7684\u6743\u76CA\n * \u5305\u62EC \u901A\u7528\u4F18\u60E0\u5238\uFF0C\u4F1A\u5458\u4EF7\uFF0C\u6EE1\u51CF\uFF0C\u6346\u7ED1\u6298\u6263\uFF0C\u4E70\u8D60 \uFF0C\u6EE1\u8D60 \uFF0C\u79EF\u5206\u62B5\u73B0\n * @returns\n */\nexport const useBenefits = ({\n variant,\n}: BenefitsParams): BenefitsResult => {\n const { coupon, product, bundle, freeGift, memberFunctionResult, creditsRedemptionAmount } = useProductContext()\n\n const { trackingData } = useAiuiContext()\n\n const total = Math.max(\n memberFunctionResult?.withCouponMemberTotalSave ?? 0,\n memberFunctionResult?.withoutCouponMaxMemberTotalSave ?? 0\n )\n\n // \u9AD8\u6807\u7269\u6D41\n const showPaidShipping = Boolean(\n trackingData?.paidShipping &&\n variant.requiresShipping &&\n !variant?.metafields?.global?.presell &&\n !variant?.metafields?.global?.HideShipping\n )\n\n // \u811A\u672C\u6EE1\u8D60\n const fullGift = trackingData?.freeGift\n const excludeProducts =\n fullGift?.excludeProducts?.map((item: any) => (typeof item === 'object' && 'sku' in item ? item.sku : item)) ?? []\n\n const showLevelDiscount =\n trackingData?.levelDiscount &&\n checkItemAvailableForProduct({ product, variant, item: trackingData?.levelDiscount })\n\n return {\n commonCoupon: {\n enable: Boolean(coupon),\n config: coupon ?? {},\n },\n freeGift: {\n enable: Boolean(freeGift) && !!freeGift?.giftList?.length,\n config: freeGift,\n },\n bundle: {\n enable:\n Boolean(bundle) &&\n !!bundle?.bundleList?.length &&\n Math.max(...bundle?.bundleList?.map(item => item.savings ?? 0)) > 0, // \u6709\u4F18\u60E0\u624D\u5C55\u793A\n config: bundle,\n },\n memberDiscount: {\n enable: total > 0,\n config: {\n amount: total,\n description: memberFunctionResult?.labels?.find((item: any) => item.key === 'benefit_tab_string')?.value,\n },\n },\n creditsRedemption: {\n enable: Boolean(creditsRedemptionAmount) && creditsRedemptionAmount! > 0,\n config: { amount: creditsRedemptionAmount, label: trackingData?.creditsRedemptionLabel },\n },\n paidShipping: {\n enable: showPaidShipping,\n config: {},\n },\n fullGift: {\n enable: Boolean(fullGift && !excludeProducts.includes(variant.sku)),\n config: fullGift ?? {},\n },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ACF,EACA,kBAAmB,CACjB,OAAQ,EAAQN,GAA4BA,EAA2B,EACvE,OAAQ,CAAE,OAAQA,EAAyB,MAAOC,GAAc,sBAAuB,CACzF,EACA,aAAc,CACZ,OAAQE,EACR,OAAQ,CAAC,CACX,EACA,SAAU,CACR,OAAQ,GAAQC,GAAY,CAACC,EAAgB,SAASX,EAAQ,GAAG,GACjE,OAAQU,GAAY,CAAC,CACvB,EACA,cAAe,CACb,OAAQ,EAAQG,EAChB,OAAQN,GAAc,eAAiB,CAAC,CAC1C,CACF,CACF",
6
+ "names": ["useProductContext", "checkItemAvailableForProduct", "useAiuiContext", "useBenefits", "variant", "coupon", "product", "bundle", "freeGift", "memberFunctionResult", "creditsRedemptionAmount", "trackingData", "total", "showPaidShipping", "fullGift", "excludeProducts", "item", "showLevelDiscount"]
7
+ }
@@ -1,8 +1,5 @@
1
- type UseCopyReturn = {
2
- isCopied: boolean;
3
- copyError: Error | null;
4
- copyToClipboard: (text: string) => Promise<void>;
5
- reset: () => void;
1
+ declare const useCopy: () => {
2
+ copy: (val: string) => void;
3
+ copied: boolean;
6
4
  };
7
- declare const useCopy: () => UseCopyReturn;
8
5
  export default useCopy;
@@ -1,2 +1,2 @@
1
- import{useState as t,useCallback as i}from"react";const p=()=>{const[s,r]=t(!1),[l,o]=t(null),n=i(async a=>{try{await navigator.clipboard.writeText(a),r(!0),o(null)}catch(e){r(!1),o(e instanceof Error?e:new Error("Copy failed"))}finally{setTimeout(()=>{r(!1)},2e3)}},[]);return{isCopied:s,copyError:l,copyToClipboard:n,reset:()=>{r(!1),o(null)}}};var y=p;export{y as default};
1
+ import u from"copy-to-clipboard";import{useCallback as s,useEffect as n,useRef as i,useState as a}from"react";const f=()=>{const e=i(),[t,r]=a(!1),o=s(c=>{u(c),e.current&&clearTimeout(e.current),r(!0),e.current=setTimeout(()=>{r(!1)},2e3)},[]);return n(()=>()=>{e.current&&clearTimeout(e.current)},[]),{copy:o,copied:t}};var m=f;export{m as default};
2
2
  //# sourceMappingURL=useCopy.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/biz-components/Listing/hooks/useCopy.ts"],
4
- "sourcesContent": ["import { useState, useCallback } from 'react'\n\ntype UseCopyReturn = {\n isCopied: boolean\n copyError: Error | null\n copyToClipboard: (text: string) => Promise<void>\n reset: () => void\n}\n\nconst useCopy = (): UseCopyReturn => {\n const [isCopied, setIsCopied] = useState<boolean>(false)\n const [copyError, setCopyError] = useState<Error | null>(null)\n\n // \u5B9A\u4E49\u590D\u5236\u5230\u526A\u8D34\u677F\u7684\u51FD\u6570\n const copyToClipboard = useCallback(async (text: string) => {\n try {\n await navigator.clipboard.writeText(text)\n setIsCopied(true)\n setCopyError(null) // \u6E05\u9664\u9519\u8BEF\u72B6\u6001\n } catch (error: any) {\n setIsCopied(false)\n setCopyError(error instanceof Error ? error : new Error('Copy failed'))\n } finally {\n setTimeout(() => {\n setIsCopied(false)\n }, 2000)\n }\n }, [])\n\n // \u91CD\u7F6E\u590D\u5236\u72B6\u6001\n const reset = () => {\n setIsCopied(false)\n setCopyError(null)\n }\n\n return { isCopied, copyError, copyToClipboard, reset }\n}\n\nexport default useCopy\n"],
5
- "mappings": "AAAA,OAAS,YAAAA,EAAU,eAAAC,MAAmB,QAStC,MAAMC,EAAU,IAAqB,CACnC,KAAM,CAACC,EAAUC,CAAW,EAAIJ,EAAkB,EAAK,EACjD,CAACK,EAAWC,CAAY,EAAIN,EAAuB,IAAI,EAGvDO,EAAkBN,EAAY,MAAOO,GAAiB,CAC1D,GAAI,CACF,MAAM,UAAU,UAAU,UAAUA,CAAI,EACxCJ,EAAY,EAAI,EAChBE,EAAa,IAAI,CACnB,OAASG,EAAY,CACnBL,EAAY,EAAK,EACjBE,EAAaG,aAAiB,MAAQA,EAAQ,IAAI,MAAM,aAAa,CAAC,CACxE,QAAE,CACA,WAAW,IAAM,CACfL,EAAY,EAAK,CACnB,EAAG,GAAI,CACT,CACF,EAAG,CAAC,CAAC,EAQL,MAAO,CAAE,SAAAD,EAAU,UAAAE,EAAW,gBAAAE,EAAiB,MALjC,IAAM,CAClBH,EAAY,EAAK,EACjBE,EAAa,IAAI,CACnB,CAEqD,CACvD,EAEA,IAAOI,EAAQR",
6
- "names": ["useState", "useCallback", "useCopy", "isCopied", "setIsCopied", "copyError", "setCopyError", "copyToClipboard", "text", "error", "useCopy_default"]
4
+ "sourcesContent": ["import clipboard from 'copy-to-clipboard'\nimport { useCallback, useEffect, useRef, useState } from 'react'\n\nconst useCopy = () => {\n const copyTimer = useRef<any>()\n const [copied, setCopied] = useState(false)\n\n const copy = useCallback((val: string) => {\n clipboard(val)\n\n if (copyTimer.current) {\n clearTimeout(copyTimer.current)\n }\n\n setCopied(true)\n copyTimer.current = setTimeout(() => {\n setCopied(false)\n }, 2000)\n }, [])\n\n useEffect(() => {\n return () => {\n if (copyTimer.current) {\n clearTimeout(copyTimer.current)\n }\n }\n }, [])\n\n return {\n copy,\n copied,\n }\n}\n\nexport default useCopy\n"],
5
+ "mappings": "AAAA,OAAOA,MAAe,oBACtB,OAAS,eAAAC,EAAa,aAAAC,EAAW,UAAAC,EAAQ,YAAAC,MAAgB,QAEzD,MAAMC,EAAU,IAAM,CACpB,MAAMC,EAAYH,EAAY,EACxB,CAACI,EAAQC,CAAS,EAAIJ,EAAS,EAAK,EAEpCK,EAAOR,EAAaS,GAAgB,CACxCV,EAAUU,CAAG,EAETJ,EAAU,SACZ,aAAaA,EAAU,OAAO,EAGhCE,EAAU,EAAI,EACdF,EAAU,QAAU,WAAW,IAAM,CACnCE,EAAU,EAAK,CACjB,EAAG,GAAI,CACT,EAAG,CAAC,CAAC,EAEL,OAAAN,EAAU,IACD,IAAM,CACPI,EAAU,SACZ,aAAaA,EAAU,OAAO,CAElC,EACC,CAAC,CAAC,EAEE,CACL,KAAAG,EACA,OAAAF,CACF,CACF,EAEA,IAAOI,EAAQN",
6
+ "names": ["clipboard", "useCallback", "useEffect", "useRef", "useState", "useCopy", "copyTimer", "copied", "setCopied", "copy", "val", "useCopy_default"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as A}from"react/jsx-runtime";import{useAiuiContext as I}from"../AiuiProvider/index.js";import{PurchaseBar as b,ProductActions as w}from"./components/index.js";import D from"./ProductProvider.js";import{ProductCard as R}from"./components/index.js";import{useMediaQuery as o}from"react-responsive";const i=({product:r,renderRating:c,variant:d,selectedOptions:n,setSelectedOptions:s,isLogin:G,finalPrice:a,coupon:p,comparePrice:l,totalSavings:m,savingDetail:u,freeGift:y,bundle:f,checkedBundle:v,checkedGift:P,setCheckedBundle:C,setCheckedGift:k,compareData:S,selectedVariants:g,onAddToCart:h,onBuyNow:N})=>{const{locale:L}=I(),t=o({query:"(max-width: 768px)"}),x=o({query:"(min-width: 1440px)"});return e(D,{product:r,isMobile:t,isDesktop:x,freeGift:y,renderRating:c,finalPrice:a,comparePrice:l,totalSavings:m,savingDetail:u,variant:d,selectedOptions:n,setSelectedOptions:s,bundle:f,coupon:p,checkedBundle:v,checkedGift:P,setCheckedBundle:C,setCheckedGift:k,compareData:S,selectedVariants:g,onAddToCart:h,onBuyNow:N,children:A("div",{id:"ipc-listing",children:[e(b,{onSpyNavItemClick:B=>{console.log(B)}}),t&&e("div",{className:"fixed bottom-0 left-0 w-full z-[60]",children:e(w,{})}),e(R,{})]})})};i.displayName="Listing";var F=i;export{F as default};
1
+ import{jsx as e,jsxs as j}from"react/jsx-runtime";import{useAiuiContext as G}from"../AiuiProvider/index.js";import{PurchaseBar as L,ProductActions as O}from"./components/index.js";import T from"./ProductProvider.js";import{ProductCard as q}from"./components/index.js";import{useMediaQuery as t}from"react-responsive";const i=({product:r,renderRating:n,variant:d,selectedOptions:c,setSelectedOptions:a,isLogin:z,finalPrice:s,coupon:p,comparePrice:l,totalSavings:m,savingDetail:u,freeGift:y,bundle:f,checkedBundle:P,checkedGift:v,setCheckedBundle:C,setCheckedGift:S,compareData:g,selectedVariants:h,onAddToCart:k,onBuyNow:N,openModal:x,setSavingDetail:B,openSignInPopup:I,openAuthCodePopup:A,renderAffirm:D,renderKlarna:b,renderPaypal:w})=>{const{locale:F}=G(),o=t({query:"(max-width: 768px)"}),M=t({query:"(min-width: 1440px)"});return e(T,{product:r,isMobile:o,isDesktop:M,freeGift:y,renderRating:n,finalPrice:s,comparePrice:l,totalSavings:m,savingDetail:u,variant:d,selectedOptions:c,setSelectedOptions:a,bundle:f,coupon:p,checkedBundle:P,checkedGift:v,setCheckedBundle:C,setCheckedGift:S,compareData:g,selectedVariants:h,onAddToCart:k,onBuyNow:N,openModal:x,setSavingDetail:B,openSignInPopup:I,openAuthCodePopup:A,renderAffirm:D,renderKlarna:b,renderPaypal:w,children:j("div",{id:"ipc-listing",children:[e(L,{onSpyNavItemClick:R=>{console.log(R)}}),o&&e("div",{className:"fixed bottom-0 left-0 w-full z-[60]",children:e(O,{})}),e(q,{})]})})};i.displayName="Listing";var U=i;export{U as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/biz-components/Listing/index.tsx"],
4
- "sourcesContent": ["import { useAiuiContext } from '../AiuiProvider/index.js'\nimport { PurchaseBar, ProductActions } from './components/index.js'\nimport type { ScrollSpyNavItem } from './components/PurchaseBar/types.js'\nimport ProductProvider, { type ProductContextType } from './ProductProvider.js'\nimport { ProductCard } from './components/index.js'\n\nimport { useMediaQuery } from 'react-responsive'\n\nconst Listing: React.FC<Omit<ProductContextType, 'joinedRecommendBuyProducts' | 'setJoinedRecommendBuyProducts'>> = ({\n product,\n renderRating,\n variant,\n selectedOptions,\n setSelectedOptions,\n isLogin,\n finalPrice,\n coupon,\n comparePrice,\n totalSavings,\n savingDetail,\n freeGift,\n bundle,\n checkedBundle,\n checkedGift,\n setCheckedBundle,\n setCheckedGift,\n compareData,\n selectedVariants,\n onAddToCart,\n onBuyNow,\n}) => {\n const { locale } = useAiuiContext()\n\n const isMobile = useMediaQuery({ query: '(max-width: 768px)' })\n const isDesktop = useMediaQuery({ query: '(min-width: 1440px)' })\n\n const onSpyNavItemClick = (tab: ScrollSpyNavItem) => {\n console.log(tab)\n }\n\n return (\n <ProductProvider\n product={product}\n isMobile={isMobile}\n isDesktop={isDesktop}\n freeGift={freeGift}\n renderRating={renderRating}\n finalPrice={finalPrice}\n comparePrice={comparePrice}\n totalSavings={totalSavings}\n savingDetail={savingDetail}\n variant={variant}\n selectedOptions={selectedOptions}\n setSelectedOptions={setSelectedOptions}\n bundle={bundle}\n coupon={coupon}\n checkedBundle={checkedBundle}\n checkedGift={checkedGift}\n setCheckedBundle={setCheckedBundle}\n setCheckedGift={setCheckedGift}\n compareData={compareData}\n selectedVariants={selectedVariants}\n onAddToCart={onAddToCart}\n onBuyNow={onBuyNow}\n >\n <div id=\"ipc-listing\">\n <PurchaseBar onSpyNavItemClick={onSpyNavItemClick} />\n {isMobile && (\n <div className=\"fixed bottom-0 left-0 w-full z-[60]\">\n <ProductActions />\n </div>\n )}\n <ProductCard />\n </div>\n </ProductProvider>\n )\n}\n\nListing.displayName = 'Listing'\n\nexport default Listing\n"],
5
- "mappings": "AAiEM,OACE,OAAAA,EADF,QAAAC,MAAA,oBAjEN,OAAS,kBAAAC,MAAsB,2BAC/B,OAAS,eAAAC,EAAa,kBAAAC,MAAsB,wBAE5C,OAAOC,MAAkD,uBACzD,OAAS,eAAAC,MAAmB,wBAE5B,OAAS,iBAAAC,MAAqB,mBAE9B,MAAMC,EAA8G,CAAC,CACnH,QAAAC,EACA,aAAAC,EACA,QAAAC,EACA,gBAAAC,EACA,mBAAAC,EACA,QAAAC,EACA,WAAAC,EACA,OAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,SAAAC,EACA,OAAAC,EACA,cAAAC,EACA,YAAAC,EACA,iBAAAC,EACA,eAAAC,EACA,YAAAC,EACA,iBAAAC,EACA,YAAAC,EACA,SAAAC,CACF,IAAM,CACJ,KAAM,CAAE,OAAAC,CAAO,EAAI5B,EAAe,EAE5B6B,EAAWxB,EAAc,CAAE,MAAO,oBAAqB,CAAC,EACxDyB,EAAYzB,EAAc,CAAE,MAAO,qBAAsB,CAAC,EAMhE,OACEP,EAACK,EAAA,CACC,QAASI,EACT,SAAUsB,EACV,UAAWC,EACX,SAAUZ,EACV,aAAcV,EACd,WAAYK,EACZ,aAAcE,EACd,aAAcC,EACd,aAAcC,EACd,QAASR,EACT,gBAAiBC,EACjB,mBAAoBC,EACpB,OAAQQ,EACR,OAAQL,EACR,cAAeM,EACf,YAAaC,EACb,iBAAkBC,EAClB,eAAgBC,EAChB,YAAaC,EACb,iBAAkBC,EAClB,YAAaC,EACb,SAAUC,EAEV,SAAA5B,EAAC,OAAI,GAAG,cACN,UAAAD,EAACG,EAAA,CAAY,kBA9BQ8B,GAA0B,CACnD,QAAQ,IAAIA,CAAG,CACjB,EA4ByD,EAClDF,GACC/B,EAAC,OAAI,UAAU,sCACb,SAAAA,EAACI,EAAA,EAAe,EAClB,EAEFJ,EAACM,EAAA,EAAY,GACf,EACF,CAEJ,EAEAE,EAAQ,YAAc,UAEtB,IAAO0B,EAAQ1B",
6
- "names": ["jsx", "jsxs", "useAiuiContext", "PurchaseBar", "ProductActions", "ProductProvider", "ProductCard", "useMediaQuery", "Listing", "product", "renderRating", "variant", "selectedOptions", "setSelectedOptions", "isLogin", "finalPrice", "coupon", "comparePrice", "totalSavings", "savingDetail", "freeGift", "bundle", "checkedBundle", "checkedGift", "setCheckedBundle", "setCheckedGift", "compareData", "selectedVariants", "onAddToCart", "onBuyNow", "locale", "isMobile", "isDesktop", "tab", "Listing_default"]
4
+ "sourcesContent": ["import { useAiuiContext } from '../AiuiProvider/index.js'\nimport { PurchaseBar, ProductActions } from './components/index.js'\nimport type { ScrollSpyNavItem } from './components/PurchaseBar/types.js'\nimport ProductProvider, { type ProductContextType } from './ProductProvider.js'\nimport { ProductCard } from './components/index.js'\n\nimport { useMediaQuery } from 'react-responsive'\n\nconst Listing: React.FC<Omit<ProductContextType, 'joinedRecommendBuyProducts' | 'setJoinedRecommendBuyProducts'>> = ({\n product,\n renderRating,\n variant,\n selectedOptions,\n setSelectedOptions,\n isLogin,\n finalPrice,\n coupon,\n comparePrice,\n totalSavings,\n savingDetail,\n freeGift,\n bundle,\n checkedBundle,\n checkedGift,\n setCheckedBundle,\n setCheckedGift,\n compareData,\n selectedVariants,\n onAddToCart,\n onBuyNow,\n openModal,\n setSavingDetail,\n openSignInPopup,\n openAuthCodePopup,\n renderAffirm,\n renderKlarna,\n renderPaypal,\n}) => {\n const { locale } = useAiuiContext()\n\n const isMobile = useMediaQuery({ query: '(max-width: 768px)' })\n const isDesktop = useMediaQuery({ query: '(min-width: 1440px)' })\n\n const onSpyNavItemClick = (tab: ScrollSpyNavItem) => {\n console.log(tab)\n }\n\n return (\n <ProductProvider\n product={product}\n isMobile={isMobile}\n isDesktop={isDesktop}\n freeGift={freeGift}\n renderRating={renderRating}\n finalPrice={finalPrice}\n comparePrice={comparePrice}\n totalSavings={totalSavings}\n savingDetail={savingDetail}\n variant={variant}\n selectedOptions={selectedOptions}\n setSelectedOptions={setSelectedOptions}\n bundle={bundle}\n coupon={coupon}\n checkedBundle={checkedBundle}\n checkedGift={checkedGift}\n setCheckedBundle={setCheckedBundle}\n setCheckedGift={setCheckedGift}\n compareData={compareData}\n selectedVariants={selectedVariants}\n onAddToCart={onAddToCart}\n onBuyNow={onBuyNow}\n openModal={openModal}\n setSavingDetail={setSavingDetail}\n openSignInPopup={openSignInPopup}\n openAuthCodePopup={openAuthCodePopup}\n renderAffirm={renderAffirm}\n renderKlarna={renderKlarna}\n renderPaypal={renderPaypal}\n >\n <div id=\"ipc-listing\">\n <PurchaseBar onSpyNavItemClick={onSpyNavItemClick} />\n {isMobile && (\n <div className=\"fixed bottom-0 left-0 w-full z-[60]\">\n <ProductActions />\n </div>\n )}\n <ProductCard />\n </div>\n </ProductProvider>\n )\n}\n\nListing.displayName = 'Listing'\n\nexport default Listing\n"],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IAAIA,CAAG,CACjB,EAmCyD,EAClDF,GACCtC,EAAC,OAAI,UAAU,sCACb,SAAAA,EAACI,EAAA,EAAe,EAClB,EAEFJ,EAACM,EAAA,EAAY,GACf,EACF,CAEJ,EAEAE,EAAQ,YAAc,UAEtB,IAAOiC,EAAQjC",
6
+ "names": ["jsx", "jsxs", "useAiuiContext", "PurchaseBar", "ProductActions", "ProductProvider", "ProductCard", "useMediaQuery", "Listing", "product", "renderRating", "variant", "selectedOptions", "setSelectedOptions", "isLogin", "finalPrice", "coupon", "comparePrice", "totalSavings", "savingDetail", "freeGift", "bundle", "checkedBundle", "checkedGift", "setCheckedBundle", "setCheckedGift", "compareData", "selectedVariants", "onAddToCart", "onBuyNow", "openModal", "setSavingDetail", "openSignInPopup", "openAuthCodePopup", "renderAffirm", "renderKlarna", "renderPaypal", "locale", "isMobile", "isDesktop", "tab", "Listing_default"]
7
7
  }
@@ -1,4 +1,10 @@
1
1
  import type { Product, ProductMedia, ProductVariant } from '../types/product';
2
+ export type SchemaVariant = {
3
+ variant: {
4
+ handle: string;
5
+ sku: string;
6
+ };
7
+ };
2
8
  export declare function isObjEmpty(obj?: Record<string, any>): boolean;
3
9
  export declare function atobID(id: string): string | undefined;
4
10
  export declare function btoaID(id: string, type?: 'ProductVariant' | 'Product'): string;
@@ -19,3 +25,12 @@ export declare function getVariantMediaList({ product, variant }: {
19
25
  variant: ProductVariant;
20
26
  product: Product;
21
27
  }): ProductMedia[];
28
+ export declare const checkItemAvailableForProduct: ({ product, item, variant, }: {
29
+ product: Product;
30
+ variant: ProductVariant;
31
+ item?: {
32
+ includeTags?: string[];
33
+ includeProducts?: SchemaVariant[];
34
+ excludeProducts?: SchemaVariant[];
35
+ };
36
+ }) => string | boolean | SchemaVariant | undefined;
@@ -1,2 +1,2 @@
1
- import{CouponChannel as o}from"../const";function d(t){return t?Object.keys(t).length===0:!0}function p(t){return t&&typeof t=="string"&&t.includes("/")?t.split("/").pop()?.split("?")?.shift():t}function f(t,e="ProductVariant"){return`gid://shopify/${e}/${t}`}const l=t=>t==="eu-de"?"de":t==="eu-en"?"eu":t==="au"?"au":t,m=({variant:t})=>t?.coupons?.find(e=>e.discount_type!==o.WSCH),u={\u00DC:"U",\u00C4:"A",\u00D6:"O",\u00FC:"u",\u00E4:"a",\u00F6:"o",\u00DF:"ss",\u00E8:"e"};function c(t){return t.replace(/[\u00dc|\u00c4|\u00d6][a-z]/g,e=>{const r=u[e.slice(0,1)];return r.charAt(0)+r.charAt(1).toLowerCase()+e.slice(1)}).replace(new RegExp("["+Object.keys(u).join("|")+"]","g"),e=>u[e])}function g(t){return c(t).replace(/ /g,"-").replace(/[^a-zA-Z0-9-]/g,"").toLowerCase()}function i({mediaList:t,variant:e}){const r=e?.image?.url;return r?t.map(n=>n.image?.url).findIndex(n=>n==r):null}function x({product:t,variant:e}){const r=i({mediaList:t.media,variant:e});if(r!==null){const n=t.variants.filter(a=>e.id!==a.id).map(a=>i({mediaList:t.media,variant:a})).find(a=>a!==null&&a>r)||-1;return t.media.slice(r,n===-1?t.media.length:n)}else return t.media}export{p as atobID,f as btoaID,m as getNormalCoupon,l as getThemeLocale,i as getVariantImageIndex,x as getVariantMediaList,g as handle,d as isObjEmpty,c as replaceUmlaut};
1
+ import{CouponChannel as o}from"../const";function d(e){return e?Object.keys(e).length===0:!0}function l(e){return e&&typeof e=="string"&&e.includes("/")?e.split("/").pop()?.split("?")?.shift():e}function f(e,t="ProductVariant"){return`gid://shopify/${t}/${e}`}const g=e=>e==="eu-de"?"de":e==="eu-en"?"eu":e==="au"?"au":e,p=({variant:e})=>e?.coupons?.find(t=>t.discount_type!==o.WSCH),u={\u00DC:"U",\u00C4:"A",\u00D6:"O",\u00FC:"u",\u00E4:"a",\u00F6:"o",\u00DF:"ss",\u00E8:"e"};function s(e){return e.replace(/[\u00dc|\u00c4|\u00d6][a-z]/g,t=>{const n=u[t.slice(0,1)];return n.charAt(0)+n.charAt(1).toLowerCase()+t.slice(1)}).replace(new RegExp("["+Object.keys(u).join("|")+"]","g"),t=>u[t])}function m(e){return s(e).replace(/ /g,"-").replace(/[^a-zA-Z0-9-]/g,"").toLowerCase()}function i({mediaList:e,variant:t}){const n=t?.image?.url;return n?e.map(r=>r.image?.url).findIndex(r=>r==n):null}function h({product:e,variant:t}){const n=i({mediaList:e.media,variant:t});if(n!==null){const r=e.variants.filter(a=>t.id!==a.id).map(a=>i({mediaList:e.media,variant:a})).find(a=>a!==null&&a>n)||-1;return e.media.slice(n,r===-1?e.media.length:r)}else return e.media}const P=({product:e,item:t,variant:n})=>t?Number(t?.includeTags?.length)>0?e.tags?.find(r=>t?.includeTags?.includes(r)):Number(t?.includeProducts?.length)>0?t.includeProducts?.find(r=>r?.variant?.handle===e.handle&&r?.variant?.sku===n.sku):Number(t?.excludeProducts?.length)>0?!t.excludeProducts?.find(r=>r?.variant?.handle===e.handle&&r?.variant?.sku===n.sku):!0:!1;export{l as atobID,f as btoaID,P as checkItemAvailableForProduct,p as getNormalCoupon,g as getThemeLocale,i as getVariantImageIndex,h as getVariantMediaList,m as handle,d as isObjEmpty,s as replaceUmlaut};
2
2
  //# sourceMappingURL=helper.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/biz-components/Listing/utils/helper.ts"],
4
- "sourcesContent": ["// \u6539\u7EC4\u4EF6\u5BA2\u6237\u7AEF\u6267\u884C\n// import { SchemaVariant } from '@projectTypes/template'\nimport type { Product, ProductMedia, ProductVariant } from '../types/product'\nimport { CouponChannel } from '../const'\n// import Cookies from 'js-cookie'\n// import { Attribute, HasMetafieldsIdentifier } from 'lib/shopify/gql'\n// import { HasMetafieldQueryRoot } from 'lib/shopify/types/fetcher'\n// import { useEffect, useState } from 'react'\n\n// import { PartialRecord } from './type-helper'\n\n// \u5224\u65AD\u5BF9\u8C61\u662F\u5426\u4E3A\u7A7A\nexport function isObjEmpty(obj?: Record<string, any>) {\n if (!obj) return true\n else {\n return Object.keys(obj).length === 0\n }\n}\n\nexport function atobID(id: string) {\n if (id && typeof id === 'string' && id.includes('/')) {\n return id.split('/').pop()?.split('?')?.shift()\n } else {\n return id\n }\n}\n\nexport function btoaID(id: string, type: 'ProductVariant' | 'Product' = 'ProductVariant') {\n return `gid://shopify/${type}/${id}`\n}\n\n// \u76AE\u80A4\u7AD9\u4E09\u7EA7\u57DF\u540D\nexport const getThemeLocale = (locale: string) => {\n if (locale === 'eu-de') return 'de'\n if (locale === 'eu-en') return 'eu'\n if (locale === 'au') return 'au'\n return locale\n}\n\n/**\n * \u751F\u6210 metafieldIdentifiers \u67E5\u8BE2\u53C2\u6570\n */\n// export function constructMetafieldIdentifiersQueryParams<T extends HasMetafieldQueryRoot>(\n// metafieldIdentifiers: PartialRecord<T, HasMetafieldsIdentifier[]> = {},\n// ): PartialRecord<`${T}MetafieldIdentifiers`, HasMetafieldsIdentifier[]> {\n// const identifiers = Object.entries(metafieldIdentifiers).reduce(\n// (queryInput, [key, value]) => {\n// const metafieldIdentifiers = value as HasMetafieldsIdentifier[]\n// queryInput[`${key}MetafieldIdentifiers`] = metafieldIdentifiers\n// .filter((item) => !item.namespace.startsWith(metafieldNamespacePrefix))\n// .map((item) => ({\n// namespace: `${metafieldNamespacePrefix}combo`,\n// key: item.namespace,\n// }))\n// .concat(metafieldIdentifiers)\n// return queryInput\n// },\n// {} as PartialRecord<`${T}MetafieldIdentifiers`, HasMetafieldsIdentifier[]>,\n// )\n// return identifiers\n// }\n\n// export function cleanShopKey(shop: Shop) {\n// const { privacyPolicy, refundPolicy, shippingPolicy, termsOfService, subscriptionPolicy, ...otherShop } = shop\n// return otherShop\n// }\n\n// export const delHtmlTag = (str?: string) => {\n// return str ? String(str).replace(/<[^>]+>/g, '') : ''\n// }\n\nexport const getNormalCoupon = ({ variant }: { variant?: ProductVariant }) => {\n return variant?.coupons?.find(coupon => coupon.discount_type !== CouponChannel.WSCH)\n}\n\n// export const setCartSecretCookie = ({ cart }) => {\n// const key = cart.id.split('?key=')[1]\n// const id = cart.id.split('?key=')[0].split('gid://shopify/Cart/')[1]\n// Cookies.set(id, key, {\n// Domain: window.location.hostname.split('.').reverse().slice(0, 2).reverse().join('.'),\n// })\n// }\n\n// export const languageCode = (locale: string) =>\n// ({\n// us: 'US',\n// uk: 'GB',\n// ca: 'CA',\n// fr: 'FR',\n// au: 'AU',\n// my: 'MY',\n// vn: 'VN',\n// it: 'IT',\n// de: 'DE',\n// cl: 'CL',\n// })[locale] || 'US'\n\n// shopify \u7684\u7279\u6B8A\u6587\u4EF6\u8F6C\u6362\u89C4\u5219\nconst umlautMap = {\n '\\u00dc': 'U',\n '\\u00c4': 'A',\n '\\u00d6': 'O',\n '\\u00fc': 'u',\n '\\u00e4': 'a',\n '\\u00f6': 'o',\n '\\u00df': 'ss',\n '\\u00E8': 'e',\n}\n\n// \u66FF\u6362\u5B57\u7B26\u4E32\u4E2D\u7684\u7279\u6B8A\u5B57\u7B26\nexport function replaceUmlaut(str: string) {\n return str\n .replace(/[\\u00dc|\\u00c4|\\u00d6][a-z]/g, a => {\n const big = umlautMap[a.slice(0, 1) as keyof typeof umlautMap]\n return big.charAt(0) + big.charAt(1).toLowerCase() + a.slice(1)\n })\n .replace(new RegExp('[' + Object.keys(umlautMap).join('|') + ']', 'g'), a => umlautMap[a as keyof typeof umlautMap])\n}\n\n// \u5C06\u5B57\u7B26\u4E32\u8F6C\u6362\u4E3A slug\nexport function handle(str: string) {\n return replaceUmlaut(str)\n .replace(/ /g, '-')\n .replace(/[^a-zA-Z0-9-]/g, '')\n .toLowerCase()\n}\n\n// get variant image index\nexport function getVariantImageIndex({\n mediaList,\n variant,\n}: {\n variant: ProductVariant\n mediaList: ProductMedia[]\n}): null | number {\n const src = variant?.image?.url\n return src ? mediaList.map(media => media.image?.url).findIndex(imageSrc => imageSrc == src) : null\n}\n\n// get images belong to variant\nexport function getVariantMediaList({ product, variant }: { variant: ProductVariant; product: Product }) {\n const currentVariantImageIndex = getVariantImageIndex({ mediaList: product.media, variant })\n\n if (currentVariantImageIndex !== null) {\n const nextVariantImageIndex =\n product.variants\n .filter(v => variant.id !== v.id)\n .map(v => getVariantImageIndex({ mediaList: product.media, variant: v }))\n .find(index => index !== null && index > currentVariantImageIndex) || -1\n\n // current variant images, if no next variant found, return images from current index to the end\n return product.media.slice(\n currentVariantImageIndex,\n nextVariantImageIndex === -1 ? product.media.length : nextVariantImageIndex\n )\n } else {\n // if no variant image found, return all images\n return product.media\n }\n}\n\n// // \u901A\u8FC7\u9009\u62E9 option \u83B7\u53D6 variant\n// export function getVariantFromSelectedOptions({\n// product,\n// selectedOptions,\n// }: {\n// product: Product\n// selectedOptions: Record<string, string>\n// }) {\n// return product.variants.find((variant) => {\n// return Object.entries(selectedOptions).every(([key, value]) =>\n// variant.options.find((option) => {\n// if (option.__typename === 'MultipleChoiceOption' && option.name === key) {\n// return option.values.find((v) => v.label === value)\n// }\n// }),\n// )\n// })\n// }\n\n// export const getURLParameter = (name, url = window.location.href) => {\n// name = name.replace(/[\\[\\]]/g, '\\\\$&') // \u5C06\u65B9\u62EC\u53F7\u8F6C\u4E49\uFF0C\u4EE5\u4FBF\u5728\u6B63\u5219\u8868\u8FBE\u5F0F\u4E2D\u4F7F\u7528\n// var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)') // \u521B\u5EFA\u5339\u914D\u53C2\u6570\u7684\u6B63\u5219\u8868\u8FBE\u5F0F\n// var results = regex.exec(url) // \u5728URL\u4E2D\u67E5\u627E\u5339\u914D\u7684\u53C2\u6570\n// if (!results) return null // \u5982\u679C\u6CA1\u6709\u627E\u5230\u5339\u914D\u7684\u53C2\u6570\uFF0C\u5219\u8FD4\u56DEnull\n// if (!results[2]) return '' // \u5982\u679C\u53C2\u6570\u7684\u503C\u4E3A\u7A7A\uFF0C\u5219\u8FD4\u56DE\u7A7A\u5B57\u7B26\u4E32\n// return decodeURIComponent(results[2]) // \u8FD4\u56DE\u89E3\u7801\u540E\u7684\u53C2\u6570\u503C\n// }\n\n// export const checkItemAvailableForProduct = ({\n// product,\n// item,\n// variant,\n// }: {\n// product: Product\n// variant: ProductVariant\n// item?: {\n// includeTags?: string[]\n// includeProducts?: SchemaVariant[]\n// excludeProducts?: SchemaVariant[]\n// }\n// }) => {\n// if (item) {\n// if (Number(item?.includeTags?.length) > 0) {\n// return product.tags?.find((tag) => item?.includeTags?.includes(tag))\n// } else if (Number(item?.includeProducts?.length) > 0) {\n// return item.includeProducts?.find((p) => p?.variant?.handle === product.handle && p?.variant?.sku === variant.sku)\n// } else if (Number(item?.excludeProducts?.length) > 0) {\n// return !item.excludeProducts?.find(\n// (p) => p?.variant?.handle === product.handle && p?.variant?.sku === variant.sku,\n// )\n// } else {\n// return true\n// }\n// } else {\n// return false\n// }\n// }\n// export const getReferralAttributes = () => {\n// const inviteCode = Cookies.get('invite_code')\n// const playModeId = Cookies.get('playModeId')\n// const popup = Cookies.get('_popup')\n// if (inviteCode && playModeId) {\n// return popup\n// ? [\n// { key: '_invite_code', value: inviteCode ? inviteCode : '' },\n// { key: '_play_mode_id', value: playModeId ? playModeId : '' },\n// { key: '_popup', value: popup },\n// ]\n// : [\n// { key: '_invite_code', value: inviteCode ? inviteCode : '' },\n// { key: '_play_mode_id', value: playModeId ? playModeId : '' },\n// ]\n// }\n// return []\n// }\n\n// export function useH2Toc(htmlContent: string) {\n// const [toc, setToc] = useState<{ updatedHtmlContent: string; dataList: { url: string; text: string }[] }>({\n// updatedHtmlContent: htmlContent,\n// dataList: [],\n// })\n\n// useEffect(() => {\n// if (typeof window === 'undefined' || typeof document === 'undefined') return\n// const div = document.createElement('div')\n// div.innerHTML = htmlContent\n// const h2s = div.querySelectorAll('h2')\n// const dataList: { url: string; text: string }[] = []\n// h2s.forEach((h2, idx) => {\n// const text = (h2.textContent || '').trim()\n// if (!text) return\n// const id = encodeURIComponent(text).replace(/'/g, '&#39;')\n// h2.setAttribute('id', id)\n// dataList.push({ url: id, text })\n// })\n// setToc({ updatedHtmlContent: div.innerHTML, dataList })\n// }, [htmlContent])\n\n// return toc\n// }\n\n// export const isAttributesEqual = (oldAttributes: Attribute[], newAttributes: Attribute[]) => {\n// // \u6BD4\u5BF9\u4E24\u4E2A\u6570\u636E\u662F\u5426\u5B8C\u5168\u76F8\u540C\n// // \u68C0\u67E5\u6570\u7EC4\u957F\u5EA6\u662F\u5426\u76F8\u540C\n// if (oldAttributes?.length !== newAttributes?.length) {\n// return false\n// }\n\n// // \u5C06\u6570\u7EC4\u8F6C\u6362\u4E3A Map \u4EE5\u4FBF\u5FEB\u901F\u67E5\u627E\n// const oldMap = new Map(oldAttributes.map((attr) => [attr.key, attr.value]))\n// const newMap = new Map(newAttributes.map((attr) => [attr.key, attr.value]))\n\n// // \u68C0\u67E5\u6240\u6709 key \u662F\u5426\u90FD\u5B58\u5728\u4E14\u503C\u76F8\u540C\n// for (const [key, value] of newMap) {\n// if (!oldMap.has(key) || oldMap.get(key) !== value) {\n// return false\n// }\n// }\n\n// return true\n// }\n\n// // \u68C0\u67E5\u8F93\u5165\u6846\u4E2D\u7684\u7279\u6B8A\u7B26\u53F7\n// export function validateSpecialCharacters(input: string): { isValid: boolean; invalidChars: string[] } {\n// // \u5B9A\u4E49\u4E0D\u5141\u8BB8\u7684\u7279\u6B8A\u7B26\u53F7\n// const invalidSpecialChars = /[!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>\\/?`~]/g\n\n// const matches = input.match(invalidSpecialChars)\n// const invalidChars = matches ? [...new Set(matches)] : []\n\n// return {\n// isValid: invalidChars.length === 0,\n// invalidChars,\n// }\n// }\n\n// // \u83B7\u53D6\u7279\u6B8A\u7B26\u53F7\u7684\u9519\u8BEF\u63D0\u793A\u4FE1\u606F\n// export function getSpecialCharErrorMessage(invalidChars: string[]): string {\n// if (invalidChars.length === 0) return ''\n\n// const uniqueChars = [...new Set(invalidChars)]\n// if (uniqueChars.length === 1) {\n// return `\u4E0D\u5141\u8BB8\u4F7F\u7528\u7279\u6B8A\u7B26\u53F7: ${uniqueChars[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Q,KAAM,GAAG,EACjB,QAAQ,iBAAkB,EAAE,EAC5B,YAAY,CACjB,CAGO,SAASI,EAAqB,CACnC,UAAAC,EACA,QAAAT,CACF,EAGkB,CAChB,MAAMU,EAAMV,GAAS,OAAO,IAC5B,OAAOU,EAAMD,EAAU,IAAIE,GAASA,EAAM,OAAO,GAAG,EAAE,UAAUC,GAAYA,GAAYF,CAAG,EAAI,IACjG,CAGO,SAASG,EAAoB,CAAE,QAAAC,EAAS,QAAAd,CAAQ,EAAkD,CACvG,MAAMe,EAA2BP,EAAqB,CAAE,UAAWM,EAAQ,MAAO,QAAAd,CAAQ,CAAC,EAE3F,GAAIe,IAA6B,KAAM,CACrC,MAAMC,EACJF,EAAQ,SACL,OAAOG,GAAKjB,EAAQ,KAAOiB,EAAE,EAAE,EAC/B,IAAIA,GAAKT,EAAqB,CAAE,UAAWM,EAAQ,MAAO,QAASG,CAAE,CAAC,CAAC,EACvE,KAAKC,GAASA,IAAU,MAAQA,EAAQH,CAAwB,GAAK,GAG1E,OAAOD,EAAQ,MAAM,MACnBC,EACAC,IAA0B,GAAKF,EAAQ,MAAM,OAASE,CACxD,CACF,KAEE,QAAOF,EAAQ,KAEnB",
6
- "names": ["CouponChannel", "isObjEmpty", "obj", "atobID", "id", "btoaID", "type", "getThemeLocale", "locale", "getNormalCoupon", "variant", "coupon", "umlautMap", "replaceUmlaut", "str", "a", "big", "handle", "getVariantImageIndex", "mediaList", "src", "media", "imageSrc", "getVariantMediaList", "product", "currentVariantImageIndex", "nextVariantImageIndex", "v", "index"]
4
+ "sourcesContent": ["// \u6539\u7EC4\u4EF6\u5BA2\u6237\u7AEF\u6267\u884C\n// import { SchemaVariant } from '@projectTypes/template'\nimport type { Product, ProductMedia, ProductVariant } from '../types/product'\nimport { CouponChannel } from '../const'\n// import Cookies from 'js-cookie'\n// import { Attribute, HasMetafieldsIdentifier } from 'lib/shopify/gql'\n// import { HasMetafieldQueryRoot } from 'lib/shopify/types/fetcher'\n// import { useEffect, useState } from 'react'\n\n// import { PartialRecord } from './type-helper'\n\nexport type SchemaVariant = {\n variant: {\n handle: string\n sku: string\n }\n}\n\n// \u5224\u65AD\u5BF9\u8C61\u662F\u5426\u4E3A\u7A7A\nexport function isObjEmpty(obj?: Record<string, any>) {\n if (!obj) return true\n else {\n return Object.keys(obj).length === 0\n }\n}\n\nexport function atobID(id: string) {\n if (id && typeof id === 'string' && id.includes('/')) {\n return id.split('/').pop()?.split('?')?.shift()\n } else {\n return id\n }\n}\n\nexport function btoaID(id: string, type: 'ProductVariant' | 'Product' = 'ProductVariant') {\n return `gid://shopify/${type}/${id}`\n}\n\n// \u76AE\u80A4\u7AD9\u4E09\u7EA7\u57DF\u540D\nexport const getThemeLocale = (locale: string) => {\n if (locale === 'eu-de') return 'de'\n if (locale === 'eu-en') return 'eu'\n if (locale === 'au') return 'au'\n return locale\n}\n\n/**\n * \u751F\u6210 metafieldIdentifiers \u67E5\u8BE2\u53C2\u6570\n */\n// export function constructMetafieldIdentifiersQueryParams<T extends HasMetafieldQueryRoot>(\n// metafieldIdentifiers: PartialRecord<T, HasMetafieldsIdentifier[]> = {},\n// ): PartialRecord<`${T}MetafieldIdentifiers`, HasMetafieldsIdentifier[]> {\n// const identifiers = Object.entries(metafieldIdentifiers).reduce(\n// (queryInput, [key, value]) => {\n// const metafieldIdentifiers = value as HasMetafieldsIdentifier[]\n// queryInput[`${key}MetafieldIdentifiers`] = metafieldIdentifiers\n// .filter((item) => !item.namespace.startsWith(metafieldNamespacePrefix))\n// .map((item) => ({\n// namespace: `${metafieldNamespacePrefix}combo`,\n// key: item.namespace,\n// }))\n// .concat(metafieldIdentifiers)\n// return queryInput\n// },\n// {} as PartialRecord<`${T}MetafieldIdentifiers`, HasMetafieldsIdentifier[]>,\n// )\n// return identifiers\n// }\n\n// export function cleanShopKey(shop: Shop) {\n// const { privacyPolicy, refundPolicy, shippingPolicy, termsOfService, subscriptionPolicy, ...otherShop } = shop\n// return otherShop\n// }\n\n// export const delHtmlTag = (str?: string) => {\n// return str ? String(str).replace(/<[^>]+>/g, '') : ''\n// }\n\nexport const getNormalCoupon = ({ variant }: { variant?: ProductVariant }) => {\n return variant?.coupons?.find(coupon => coupon.discount_type !== CouponChannel.WSCH)\n}\n\n// export const setCartSecretCookie = ({ cart }) => {\n// const key = cart.id.split('?key=')[1]\n// const id = cart.id.split('?key=')[0].split('gid://shopify/Cart/')[1]\n// Cookies.set(id, key, {\n// Domain: window.location.hostname.split('.').reverse().slice(0, 2).reverse().join('.'),\n// })\n// }\n\n// export const languageCode = (locale: string) =>\n// ({\n// us: 'US',\n// uk: 'GB',\n// ca: 'CA',\n// fr: 'FR',\n// au: 'AU',\n// my: 'MY',\n// vn: 'VN',\n// it: 'IT',\n// de: 'DE',\n// cl: 'CL',\n// })[locale] || 'US'\n\n// shopify \u7684\u7279\u6B8A\u6587\u4EF6\u8F6C\u6362\u89C4\u5219\nconst umlautMap = {\n '\\u00dc': 'U',\n '\\u00c4': 'A',\n '\\u00d6': 'O',\n '\\u00fc': 'u',\n '\\u00e4': 'a',\n '\\u00f6': 'o',\n '\\u00df': 'ss',\n '\\u00E8': 'e',\n}\n\n// \u66FF\u6362\u5B57\u7B26\u4E32\u4E2D\u7684\u7279\u6B8A\u5B57\u7B26\nexport function replaceUmlaut(str: string) {\n return str\n .replace(/[\\u00dc|\\u00c4|\\u00d6][a-z]/g, a => {\n const big = umlautMap[a.slice(0, 1) as keyof typeof umlautMap]\n return big.charAt(0) + big.charAt(1).toLowerCase() + a.slice(1)\n })\n .replace(new RegExp('[' + Object.keys(umlautMap).join('|') + ']', 'g'), a => umlautMap[a as keyof typeof umlautMap])\n}\n\n// \u5C06\u5B57\u7B26\u4E32\u8F6C\u6362\u4E3A slug\nexport function handle(str: string) {\n return replaceUmlaut(str)\n .replace(/ /g, '-')\n .replace(/[^a-zA-Z0-9-]/g, '')\n .toLowerCase()\n}\n\n// get variant image index\nexport function getVariantImageIndex({\n mediaList,\n variant,\n}: {\n variant: ProductVariant\n mediaList: ProductMedia[]\n}): null | number {\n const src = variant?.image?.url\n return src ? mediaList.map(media => media.image?.url).findIndex(imageSrc => imageSrc == src) : null\n}\n\n// get images belong to variant\nexport function getVariantMediaList({ product, variant }: { variant: ProductVariant; product: Product }) {\n const currentVariantImageIndex = getVariantImageIndex({ mediaList: product.media, variant })\n\n if (currentVariantImageIndex !== null) {\n const nextVariantImageIndex =\n product.variants\n .filter(v => variant.id !== v.id)\n .map(v => getVariantImageIndex({ mediaList: product.media, variant: v }))\n .find(index => index !== null && index > currentVariantImageIndex) || -1\n\n // current variant images, if no next variant found, return images from current index to the end\n return product.media.slice(\n currentVariantImageIndex,\n nextVariantImageIndex === -1 ? product.media.length : nextVariantImageIndex\n )\n } else {\n // if no variant image found, return all images\n return product.media\n }\n}\n\n// // \u901A\u8FC7\u9009\u62E9 option \u83B7\u53D6 variant\n// export function getVariantFromSelectedOptions({\n// product,\n// selectedOptions,\n// }: {\n// product: Product\n// selectedOptions: Record<string, string>\n// }) {\n// return product.variants.find((variant) => {\n// return Object.entries(selectedOptions).every(([key, value]) =>\n// variant.options.find((option) => {\n// if (option.__typename === 'MultipleChoiceOption' && option.name === key) {\n// return option.values.find((v) => v.label === value)\n// }\n// }),\n// )\n// })\n// }\n\n// export const getURLParameter = (name, url = window.location.href) => {\n// name = name.replace(/[\\[\\]]/g, '\\\\$&') // \u5C06\u65B9\u62EC\u53F7\u8F6C\u4E49\uFF0C\u4EE5\u4FBF\u5728\u6B63\u5219\u8868\u8FBE\u5F0F\u4E2D\u4F7F\u7528\n// var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)') // \u521B\u5EFA\u5339\u914D\u53C2\u6570\u7684\u6B63\u5219\u8868\u8FBE\u5F0F\n// var results = regex.exec(url) // \u5728URL\u4E2D\u67E5\u627E\u5339\u914D\u7684\u53C2\u6570\n// if (!results) return null // \u5982\u679C\u6CA1\u6709\u627E\u5230\u5339\u914D\u7684\u53C2\u6570\uFF0C\u5219\u8FD4\u56DEnull\n// if (!results[2]) return '' // \u5982\u679C\u53C2\u6570\u7684\u503C\u4E3A\u7A7A\uFF0C\u5219\u8FD4\u56DE\u7A7A\u5B57\u7B26\u4E32\n// return decodeURIComponent(results[2]) // \u8FD4\u56DE\u89E3\u7801\u540E\u7684\u53C2\u6570\u503C\n// }\n\nexport const checkItemAvailableForProduct = ({\n product,\n item,\n variant,\n}: {\n product: Product\n variant: ProductVariant\n item?: {\n includeTags?: string[]\n includeProducts?: SchemaVariant[]\n excludeProducts?: SchemaVariant[]\n }\n}) => {\n if (item) {\n if (Number(item?.includeTags?.length) > 0) {\n return product.tags?.find((tag) => item?.includeTags?.includes(tag))\n } else if (Number(item?.includeProducts?.length) > 0) {\n return item.includeProducts?.find((p) => p?.variant?.handle === product.handle && p?.variant?.sku === variant.sku)\n } else if (Number(item?.excludeProducts?.length) > 0) {\n return !item.excludeProducts?.find(\n (p) => p?.variant?.handle === product.handle && p?.variant?.sku === variant.sku,\n )\n } else {\n return true\n }\n } else {\n return false\n }\n}\n// export const getReferralAttributes = () => {\n// const inviteCode = Cookies.get('invite_code')\n// const playModeId = Cookies.get('playModeId')\n// const popup = Cookies.get('_popup')\n// if (inviteCode && playModeId) {\n// return popup\n// ? [\n// { key: '_invite_code', value: inviteCode ? inviteCode : '' },\n// { key: '_play_mode_id', value: playModeId ? playModeId : '' },\n// { key: '_popup', value: popup },\n// ]\n// : [\n// { key: '_invite_code', value: inviteCode ? inviteCode : '' },\n// { key: '_play_mode_id', value: playModeId ? playModeId : '' },\n// ]\n// }\n// return []\n// }\n\n// export function useH2Toc(htmlContent: string) {\n// const [toc, setToc] = useState<{ updatedHtmlContent: string; dataList: { url: string; text: string }[] }>({\n// updatedHtmlContent: htmlContent,\n// dataList: [],\n// })\n\n// useEffect(() => {\n// if (typeof window === 'undefined' || typeof document === 'undefined') return\n// const div = document.createElement('div')\n// div.innerHTML = htmlContent\n// const h2s = div.querySelectorAll('h2')\n// const dataList: { url: string; text: string }[] = []\n// h2s.forEach((h2, idx) => {\n// const text = (h2.textContent || '').trim()\n// if (!text) return\n// const id = encodeURIComponent(text).replace(/'/g, '&#39;')\n// h2.setAttribute('id', id)\n// dataList.push({ url: id, text })\n// })\n// setToc({ updatedHtmlContent: div.innerHTML, dataList })\n// }, [htmlContent])\n\n// return toc\n// }\n\n// export const isAttributesEqual = (oldAttributes: Attribute[], newAttributes: Attribute[]) => {\n// // \u6BD4\u5BF9\u4E24\u4E2A\u6570\u636E\u662F\u5426\u5B8C\u5168\u76F8\u540C\n// // \u68C0\u67E5\u6570\u7EC4\u957F\u5EA6\u662F\u5426\u76F8\u540C\n// if (oldAttributes?.length !== newAttributes?.length) {\n// return false\n// }\n\n// // \u5C06\u6570\u7EC4\u8F6C\u6362\u4E3A Map \u4EE5\u4FBF\u5FEB\u901F\u67E5\u627E\n// const oldMap = new Map(oldAttributes.map((attr) => [attr.key, attr.value]))\n// const newMap = new Map(newAttributes.map((attr) => [attr.key, attr.value]))\n\n// // \u68C0\u67E5\u6240\u6709 key \u662F\u5426\u90FD\u5B58\u5728\u4E14\u503C\u76F8\u540C\n// for (const [key, value] of newMap) {\n// if (!oldMap.has(key) || oldMap.get(key) !== value) {\n// return false\n// }\n// }\n\n// return true\n// }\n\n// // \u68C0\u67E5\u8F93\u5165\u6846\u4E2D\u7684\u7279\u6B8A\u7B26\u53F7\n// export function validateSpecialCharacters(input: string): { isValid: boolean; invalidChars: string[] } {\n// // \u5B9A\u4E49\u4E0D\u5141\u8BB8\u7684\u7279\u6B8A\u7B26\u53F7\n// const invalidSpecialChars = /[!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>\\/?`~]/g\n\n// const matches = input.match(invalidSpecialChars)\n// const invalidChars = matches ? [...new Set(matches)] : []\n\n// return {\n// isValid: invalidChars.length === 0,\n// invalidChars,\n// }\n// }\n\n// // \u83B7\u53D6\u7279\u6B8A\u7B26\u53F7\u7684\u9519\u8BEF\u63D0\u793A\u4FE1\u606F\n// export function getSpecialCharErrorMessage(invalidChars: string[]): string {\n// if (invalidChars.length === 0) return ''\n\n// const uniqueChars = [...new Set(invalidChars)]\n// if (uniqueChars.length === 1) {\n// return `\u4E0D\u5141\u8BB8\u4F7F\u7528\u7279\u6B8A\u7B26\u53F7: ${uniqueChars[0]}`\n// } else {\n// return `\u4E0D\u5141\u8BB8\u4F7F\u7528\u4EE5\u4E0B\u7279\u6B8A\u7B26\u53F7: ${uniqueChars.join(', ')}`\n// }\n// }"],
5
+ "mappings": "AAGA,OAAS,iBAAAA,MAAqB,WAgBvB,SAASC,EAAWC,EAA2B,CACpD,OAAKA,EAEI,OAAO,KAAKA,CAAG,EAAE,SAAW,EAFpB,EAInB,CAEO,SAASC,EAAOC,EAAY,CACjC,OAAIA,GAAM,OAAOA,GAAO,UAAYA,EAAG,SAAS,GAAG,EAC1CA,EAAG,MAAM,GAAG,EAAE,IAAI,GAAG,MAAM,GAAG,GAAG,MAAM,EAEvCA,CAEX,CAEO,SAASC,EAAOD,EAAYE,EAAqC,iBAAkB,CACxF,MAAO,iBAAiBA,CAAI,IAAIF,CAAE,EACpC,CAGO,MAAMG,EAAkBC,GACzBA,IAAW,QAAgB,KAC3BA,IAAW,QAAgB,KAC3BA,IAAW,KAAa,KACrBA,EAmCIC,EAAkB,CAAC,CAAE,QAAAC,CAAQ,IACjCA,GAAS,SAAS,KAAKC,GAAUA,EAAO,gBAAkBX,EAAc,IAAI,EA0B/EY,EAAY,CAChB,OAAU,IACV,OAAU,IACV,OAAU,IACV,OAAU,IACV,OAAU,IACV,OAAU,IACV,OAAU,KACV,OAAU,GACZ,EAGO,SAASC,EAAcC,EAAa,CACzC,OAAOA,EACJ,QAAQ,+BAAgCC,GAAK,CAC5C,MAAMC,EAAMJ,EAAUG,EAAE,MAAM,EAAG,CAAC,CAA2B,EAC7D,OAAOC,EAAI,OAAO,CAAC,EAAIA,EAAI,OAAO,CAAC,EAAE,YAAY,EAAID,EAAE,MAAM,CAAC,CAChE,CAAC,EACA,QAAQ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AQ,GAAG,EACxG,OAAOoB,GAAM,iBAAiB,MAAM,EAAI,EAC1C,CAACA,EAAK,iBAAiB,KAC3BE,GAAMA,GAAG,SAAS,SAAWR,EAAQ,QAAUQ,GAAG,SAAS,MAAQtB,EAAQ,GAC9E,EAEO,GAGF",
6
+ "names": ["CouponChannel", "isObjEmpty", "obj", "atobID", "id", "btoaID", "type", "getThemeLocale", "locale", "getNormalCoupon", "variant", "coupon", "umlautMap", "replaceUmlaut", "str", "a", "big", "handle", "getVariantImageIndex", "mediaList", "src", "media", "imageSrc", "getVariantMediaList", "product", "currentVariantImageIndex", "nextVariantImageIndex", "v", "index", "checkItemAvailableForProduct", "item", "tag", "p"]
7
7
  }