@anker-in/headless-ui 1.1.17-alpha.1766053535791 → 1.1.17-alpha.1766054863247
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/biz-components/HeaderNavigation/index.js +1 -1
- package/dist/cjs/biz-components/HeaderNavigation/index.js.map +2 -2
- package/dist/cjs/biz-components/NavigationSearch/index.js +1 -1
- package/dist/cjs/biz-components/NavigationSearch/index.js.map +2 -2
- package/dist/cjs/biz-components/SearchPage/index.js +1 -1
- package/dist/cjs/biz-components/SearchPage/index.js.map +2 -2
- package/dist/esm/biz-components/HeaderNavigation/index.js +1 -1
- package/dist/esm/biz-components/HeaderNavigation/index.js.map +2 -2
- package/dist/esm/biz-components/NavigationSearch/index.js +1 -1
- package/dist/esm/biz-components/NavigationSearch/index.js.map +2 -2
- package/dist/esm/biz-components/SearchPage/index.js +1 -1
- package/dist/esm/biz-components/SearchPage/index.js.map +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/NavigationSearch/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable react/no-unknown-property */\nimport { Picture, Text, Button, Container, Link, Heading, Grid, GridItem } from '../../components/index.js'\nimport { Search as SearchIcon, Close as CloseIcon } from '../HeaderNavigation/icons/index.js'\nimport { forwardRef, useCallback, useMemo, useState } from 'react'\nimport type { NavigationSearchProps } from './types.js'\nimport { useAiuiContext } from '../AiuiProvider/index.js'\n\nimport { SearchStatus } from './types.js'\n\nimport { debounce } from 'es-toolkit'\nimport { cn, atobID, highlightSearchWord } from '../../helpers/utils.js'\n\nexport const canSearch = (target: any) => {\n return !(\n target.metafields?.global?.HideSearch ||\n target.metafields?.seo?.hidden ||\n target.metafields?.seo?.setting?.noindex\n )\n}\n\nconst NavigationSearch = forwardRef<HTMLDivElement, NavigationSearchProps>(\n ({ data, onSearch, onClose, searchResult, isSearching, keywords }, ref) => {\n const { locale = 'us', copyWriting } = useAiuiContext()\n\n const [searchValue, setSearchValue] = useState('')\n const [isComposing, setIsComposing] = useState(false)\n\n const debouncedFunction = debounce((value: string) => {\n onSearch(value)\n }, 300)\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter' && !isComposing) {\n window.open(`${locale === 'us' ? '' : locale}${data?.moreLink}?q=${searchValue.toLowerCase()}`, '_self')\n }\n },\n [isComposing, searchValue, locale, data?.moreLink]\n )\n\n const searchKeywords = useMemo(() => {\n if (Array.isArray(keywords) && keywords?.length) {\n return keywords.map((keyword: any) => keyword.search_term)\n }\n if (Array.isArray(data?.popularWords) && data?.popularWords?.length) {\n return data?.popularWords.map((word: any) => word.popularWord)\n }\n return []\n }, [keywords, data?.popularWords])\n\n const getLink = useCallback(\n (item: any) => {\n const type = item.__typename || item.type\n switch (type) {\n case 'Product':\n return `/products${item.path}?q=${searchValue.toLowerCase()}`\n case 'Article':\n return `/blogs/${item.blog.handle}/${item.handle.replace('storefront-', '')}?q=${searchValue.toLowerCase()}`\n default:\n break\n }\n },\n [searchValue]\n )\n\n const searchStatus = useMemo(() => {\n if (!searchValue) {\n // \u6CA1\u6709\u641C\u7D22\u503C\n return SearchStatus.Default\n } else if (searchResult?.totalCount) {\n // \u6709\u641C\u7D22\u7ED3\u679C\n return SearchStatus.Predict\n } else if (!isSearching) {\n // \u6CA1\u6709\u641C\u7D22\u7ED3\u679C\n return SearchStatus.Empty\n }\n }, [searchResult?.totalCount, searchValue, isSearching])\n\n return (\n <Container childClassName=\"!bg-white\" className=\"relative\" ref={ref}>\n <style>\n {`\n .navigation-search-component input:-webkit-autofill,\n .navigation-search-component input:-webkit-autofill:hover,\n .navigation-search-component input:-webkit-autofill:focus {\n -webkit-box-shadow: 0 0 0 1000px transparent inset !important; /* \u80CC\u666F\u900F\u660E */\n -webkit-text-fill-color: #000 !important;\n transition: background-color 9999s ease-in-out 0s !important;\n caret-color: #000;\n }\n `}\n </style>\n <div className=\"navigation-search-component laptop:h-[52px] desktop:h-[60px] desktop:pt-6 flex items-center justify-between border-b border-b-gray-200 py-4 text-black\">\n <input\n value={searchValue}\n onCompositionStart={() => setIsComposing(true)}\n onCompositionEnd={() => setIsComposing(false)}\n onKeyDown={handleKeyDown}\n onChange={e => {\n setSearchValue(e.target.value)\n if (e.target.value) {\n debouncedFunction(e.target.value)\n }\n }}\n type=\"text\"\n className=\"basis-[200px] bg-white text-sm font-bold leading-[1.4] outline-none focus-visible:!outline-none \"\n placeholder={data?.placeholder}\n />\n <div className=\"flex items-center gap-3\">\n <SearchIcon className=\"size-5 cursor-pointer\" onClick={() => onSearch(searchValue)} />\n <div className=\"h-[20px] w-px bg-[#E4E5E6]\" />\n <CloseIcon className=\"size-5 cursor-pointer\" onClick={onClose} />\n </div>\n </div>\n <div className=\"desktop:gap-12 desktop:py-6 flex flex-col gap-6 py-4 text-black\">\n {searchStatus === SearchStatus.Predict ? (\n <>\n <div>\n <div className=\"flex items-center gap-1\">\n <Text html={data?.suggestText} className=\"text-sm font-bold leading-[1.4] text-[#6D6D6F]\" />\n {searchResult?.items?.length > 6 && (\n <Button\n as=\"a\"\n iconClassName=\"size-4\"\n href={`${locale === 'us' ? '' : locale}${data?.moreLink}?q=${searchValue.toLowerCase()}`}\n className=\"!p-0 !text-sm font-bold leading-[1.2]\"\n variant=\"link\"\n >\n {data?.moreText}\n </Button>\n )}\n </div>\n <div className=\"mt-2 flex flex-col\">\n {searchResult?.items\n ?.filter((item: any) => canSearch(item))\n .slice(0, 6)\n ?.map((item: any) => (\n <Link\n className=\"w-full p-4 no-underline hover:bg-[#F5F5F7] hover:text-current\"\n href={getLink(item)}\n key={item.id}\n >\n <Text\n html={highlightSearchWord(item.title, searchValue)}\n className=\"cursor-pointer text-sm font-bold leading-[1.4]\"\n />\n </Link>\n ))}\n </div>\n </div>\n <div>\n <Text html={data?.hotProductsText} className=\"text-sm font-bold leading-[1.4] text-[#6D6D6F]\" />\n <div className=\"tablet:grid-cols-2 laptop:grid-cols-3 desktop:grid-cols-4 tablet:gap-x-3 tablet:gap-y-4 laptop:gap-4 mt-2 grid grid-cols-1 gap-2\">\n <Link asChild={!data?.advertisingLink} href={data?.advertisingLink}>\n <div className=\"relative\">\n <Picture\n source={data?.advertisingBgImg?.url}\n className=\"laptop:h-[120px] h-[114px]\"\n imgClassName=\"object-cover h-full\"\n />\n <div className=\"absolute inset-x-0 bottom-0 p-4\">\n <Heading\n size={2}\n html={data?.advertisingTitle || 'Buy in Guide'}\n className={cn('font-bold text-white', {\n 'text-black': data?.advertisingTheme === 'dark',\n })}\n />\n <Text\n html={data?.advertisingSubtitle || '20.000mAh'}\n className={cn('text-sm font-bold text-white', {\n 'text-black': data?.advertisingTheme === 'dark',\n })}\n />\n </div>\n </div>\n </Link>\n {searchResult?.items\n ?.filter((item: any) => item.type.toLowerCase() === 'product')\n .slice(0, 7)\n ?.map((item: any) => {\n const variant = item?.variants?.[0]\n const productImage = `${variant?.image?.url || item?.images?.[0]?.url}`\n const productName = item?.title || item?.name\n const productDesc = item?.description\n const productBadge = item?.badge || ''\n const listingLink = `/products/${item?.handle}?variant=${atobID(variant?.id as string)}`\n return (\n <SearchProduct\n productImage={productImage}\n productName={productName}\n productDesc={productDesc}\n productBadge={productBadge}\n listingLink={listingLink}\n key={item.id}\n />\n )\n })}\n </div>\n </div>\n </>\n ) : (\n <>\n {searchStatus === SearchStatus.Empty && (\n <Text\n html={data?.noResultText}\n as=\"p\"\n className=\"border-b border-[#E4E5E6] pb-6 text-sm font-bold leading-[1.4] text-[#6D6D6F]\"\n />\n )}\n <div>\n <Text html={data?.popularText} className=\"text-sm font-bold leading-[1.4] text-[#6D6D6F]\" />\n <div className=\"mt-2\">\n <SearchKeyword data={data} keywords={searchKeywords} locale={locale} />\n {Array.isArray(data?.popularPages) && !!data?.popularPages?.length && (\n <Grid className=\"laptop:gap-4 laptop:mt-4 mt-3 gap-3\">\n {data?.popularPages?.map((item: any) => (\n <GridItem\n key={item?.id}\n className=\"tablet:col-span-6 laptop:p-3 desktop:p-4 laptop:col-span-3 col-span-12 p-2 hover:bg-[#F5F5F7]\"\n >\n <a\n href={`${locale === 'us' ? '' : locale}${data?.moreLink}?q=${item?.popularPage.toLowerCase()}`}\n className=\"line-clamp-1 cursor-pointer text-sm font-bold leading-[1.4]\"\n >\n {item?.popularPage}\n </a>\n </GridItem>\n ))}\n </Grid>\n )}\n </div>\n </div>\n <div>\n <Text html={data?.hotProductsText} className=\"text-sm font-bold leading-[1.4] text-[#6D6D6F]\" />\n <div className=\"tablet:grid-cols-2 laptop:grid-cols-3 desktop:grid-cols-4 tablet:gap-x-3 tablet:gap-y-4 laptop:gap-4 mt-2 grid grid-cols-1 gap-2\">\n <Link asChild={!data?.advertisingLink} href={data?.advertisingLink}>\n <div className=\"relative [&_img]:hover:scale-110 [&_img]:hover:transition-all [&_img]:hover:duration-[600]\">\n <Picture\n source={data?.advertisingBgImg?.url}\n className=\"laptop:h-[120px] h-[114px]\"\n imgClassName=\"object-cover h-full\"\n />\n <div className=\"absolute inset-x-0 bottom-0 p-4\">\n <Heading\n size={2}\n html={data?.advertisingTitle || 'Buy in Guide'}\n className=\"font-bold text-white\"\n />\n <Text\n html={data?.advertisingSubtitle || '20.000mAh'}\n className=\"text-sm font-bold text-white\"\n />\n </div>\n </div>\n </Link>\n {data?.hotProducts?.slice(0, 7)?.map((item: any) => {\n const productDesc = item?.custom_description\n const productBadge = item?.badge || ''\n const listingLink = `/products/${item?.handle}?variant=${atobID(item?.shopify_id as string)}`\n return (\n <SearchProduct\n productImage={item?.image}\n productName={item?.name}\n productDesc={productDesc}\n productBadge={productBadge}\n listingLink={listingLink}\n key={item.id}\n />\n )\n })}\n </div>\n </div>\n </>\n )}\n </div>\n </Container>\n )\n }\n)\n\nNavigationSearch.displayName = 'NavigationSearch'\n\nconst SearchProduct = ({\n productImage,\n productName,\n productDesc,\n productBadge,\n className,\n listingLink,\n}: {\n productImage: string\n productName: string\n productDesc: string\n productBadge: string\n className?: string\n listingLink: string\n}) => {\n return (\n <Link href={listingLink} className=\"block no-underline hover:text-current\">\n <div\n className={cn('flex shrink-0 gap-4 bg-[#F5F5F7] px-4 py-3 duration-[600] [&_img]:hover:scale-110', className)}\n >\n <div className=\"shrink-0\">\n <Picture\n source={productImage}\n width={90}\n height={90}\n className=\"size-[96px]\"\n imgClassName=\"object-contain h-full\"\n />\n </div>\n <div className=\"relative\">\n <div className=\" h-[24px] \">\n {productBadge && (\n <Text\n as=\"p\"\n html={productBadge}\n className=\"text-brand-0 mb-1 inline-block h-full rounded-full border-[1.6px] border-[#00BEFA] px-[6px] text-sm font-bold !leading-[24px]\"\n />\n )}\n </div>\n <div>\n <Link href={listingLink} className=\"no-underline hover:text-current\">\n <Text\n className=\"lg-desktop:h-[44px] lg-desktop:text-base line-clamp-2 h-[40px] text-sm font-bold leading-[1.4]\"\n html={productName}\n />\n </Link>\n {productDesc && (\n <Text\n as=\"p\"\n html={productDesc}\n className=\"lg-desktop:text-sm mt-1 line-clamp-1 text-xs font-bold leading-[1.4] text-[#6D6D6F]\"\n />\n )}\n </div>\n </div>\n </div>\n </Link>\n )\n}\n\nconst SearchKeyword = ({ data, keywords, locale }: { data: any; keywords: any[]; locale: string }) => {\n return (\n <div className=\"laptop:gap-4 flex flex-wrap gap-3\">\n {keywords?.map((keyword: any, index) => (\n <a\n href={`${locale === 'us' ? '' : locale}${data?.moreLink}?q=${keyword?.toLowerCase()}`}\n key={index}\n className=\"laptop:p-3 desktop:p-4 cursor-pointer p-2 text-sm font-bold leading-[1.4] hover:bg-[#F5F5F7]\"\n >\n {keyword}\n </a>\n ))}\n </div>\n )\n}\n\nexport default NavigationSearch\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAgFQ,IAAAK,EAAA,6BA/ERC,EAAgF,q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,EACd,YAAaC,EACb,YAAaC,EACb,aAAcC,EACd,YAAaC,GACRT,EAAK,EACZ,CAEJ,CAAC,GACL,GACF,GACF,KAEA,oBACG,UAAAC,IAAiB,eAAa,UAC7B,OAAC,QACC,KAAMtB,GAAM,aACZ,GAAG,IACH,UAAU,gFACZ,KAEF,QAAC,OACC,oBAAC,QAAK,KAAMA,GAAM,YAAa,UAAU,iDAAiD,KAC1F,QAAC,OAAI,UAAU,OACb,oBAACgC,EAAA,CAAc,KAAMhC,EAAM,SAAUiB,EAAgB,OAAQV,EAAQ,EACpE,MAAM,QAAQP,GAAM,YAAY,GAAK,CAAC,CAACA,GAAM,cAAc,WAC1D,OAAC,QAAK,UAAU,sCACb,SAAAA,GAAM,cAAc,IAAKqB,MACxB,OAAC,YAEC,UAAU,gGAEV,mBAAC,KACC,KAAM,GAAGd,IAAW,KAAO,GAAKA,CAAM,GAAGP,GAAM,QAAQ,MAAMqB,GAAM,YAAY,YAAY,CAAC,GAC5F,UAAU,8DAET,SAAAA,GAAM,YACT,GARKA,GAAM,EASb,CACD,EACH,GAEJ,GACF,KACA,QAAC,OACC,oBAAC,QAAK,KAAMrB,GAAM,gBAAiB,UAAU,iDAAiD,KAC9F,QAAC,OAAI,UAAU,mIACb,oBAAC,QAAK,QAAS,CAACA,GAAM,gBAAiB,KAAMA,GAAM,gBACjD,oBAAC,OAAI,UAAU,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable react/no-unknown-property */\nimport { Picture, Text, Button, Container, Link, Heading, Grid, GridItem } from '../../components/index.js'\nimport { Search as SearchIcon, Close as CloseIcon } from '../HeaderNavigation/icons/index.js'\nimport { forwardRef, useCallback, useMemo, useState } from 'react'\nimport type { NavigationSearchProps } from './types.js'\nimport { useAiuiContext } from '../AiuiProvider/index.js'\n\nimport { SearchStatus } from './types.js'\n\nimport { debounce } from 'es-toolkit'\nimport { cn, atobID, highlightSearchWord } from '../../helpers/utils.js'\n\nexport const canSearch = (target: any) => {\n return !(\n target.metafields?.global?.HideSearch ||\n target.metafields?.seo?.hidden ||\n target.metafields?.seo?.setting?.noindex\n )\n}\n\nconst NavigationSearch = forwardRef<HTMLDivElement, NavigationSearchProps>(\n ({ data, onSearch, onClose, searchResult, isSearching, keywords }, ref) => {\n const { locale = 'us', copyWriting } = useAiuiContext()\n\n const [searchValue, setSearchValue] = useState('')\n const [isComposing, setIsComposing] = useState(false)\n\n const debouncedFunction = debounce((value: string) => {\n onSearch(value)\n }, 300)\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter' && !isComposing) {\n window.open(`${locale === 'us' ? '' : locale}${data?.moreLink}?q=${searchValue.toLowerCase()}`, '_self')\n }\n },\n [isComposing, searchValue, locale, data?.moreLink]\n )\n\n const searchKeywords = useMemo(() => {\n if (Array.isArray(keywords) && keywords?.length) {\n return keywords.map((keyword: any) => keyword.search_term)\n }\n if (Array.isArray(data?.popularWords) && data?.popularWords?.length) {\n return data?.popularWords.map((word: any) => word.popularWord)\n }\n return []\n }, [keywords, data?.popularWords])\n\n const getLink = useCallback(\n (item: any) => {\n const type = item.__typename || item.type\n switch (type) {\n case 'Product':\n return `/products${item.path}?q=${searchValue.toLowerCase()}`\n case 'Article':\n return `/blogs/${item.blog.handle}/${item.handle.replace('storefront-', '')}?q=${searchValue.toLowerCase()}`\n default:\n break\n }\n },\n [searchValue]\n )\n\n const searchStatus = useMemo(() => {\n if (!searchValue) {\n // \u6CA1\u6709\u641C\u7D22\u503C\n return SearchStatus.Default\n } else if (searchResult?.totalCount) {\n // \u6709\u641C\u7D22\u7ED3\u679C\n return SearchStatus.Predict\n } else if (!isSearching) {\n // \u6CA1\u6709\u641C\u7D22\u7ED3\u679C\n return SearchStatus.Empty\n }\n }, [searchResult?.totalCount, searchValue, isSearching])\n\n return (\n <Container childClassName=\"!bg-white\" className=\"relative\" ref={ref}>\n <style>\n {`\n .navigation-search-component input:-webkit-autofill,\n .navigation-search-component input:-webkit-autofill:hover,\n .navigation-search-component input:-webkit-autofill:focus {\n -webkit-box-shadow: 0 0 0 1000px transparent inset !important; /* \u80CC\u666F\u900F\u660E */\n -webkit-text-fill-color: #000 !important;\n transition: background-color 9999s ease-in-out 0s !important;\n caret-color: #000;\n }\n `}\n </style>\n <div className=\"navigation-search-component laptop:h-[52px] desktop:h-[60px] desktop:pt-6 flex items-center justify-between border-b border-b-gray-200 py-4 text-black\">\n <input\n value={searchValue}\n onCompositionStart={() => setIsComposing(true)}\n onCompositionEnd={() => setIsComposing(false)}\n onKeyDown={handleKeyDown}\n onChange={e => {\n setSearchValue(e.target.value)\n if (e.target.value) {\n debouncedFunction(e.target.value)\n }\n }}\n type=\"text\"\n className=\"basis-[200px] bg-white text-sm font-bold leading-[1.4] outline-none focus-visible:!outline-none \"\n placeholder={data?.placeholder}\n />\n <div className=\"flex items-center gap-3\">\n <SearchIcon className=\"size-5 cursor-pointer\" onClick={() => onSearch(searchValue)} />\n <div className=\"h-[20px] w-px bg-[#E4E5E6]\" />\n <CloseIcon className=\"size-5 cursor-pointer\" onClick={onClose} />\n </div>\n </div>\n <div className=\"desktop:gap-12 desktop:py-6 flex flex-col gap-6 py-4 text-black\">\n {searchStatus === SearchStatus.Predict ? (\n <>\n <div>\n <div className=\"flex items-center gap-1\">\n <Text html={data?.suggestText} className=\"text-sm font-bold leading-[1.4] text-[#6D6D6F]\" />\n {searchResult?.items?.length > 6 && (\n <Button\n as=\"a\"\n iconClassName=\"size-4\"\n href={`${locale === 'us' ? '' : locale}${data?.moreLink}?q=${searchValue.toLowerCase()}`}\n className=\"!p-0 !text-sm font-bold leading-[1.2]\"\n variant=\"link\"\n >\n {data?.moreText}\n </Button>\n )}\n </div>\n <div className=\"mt-2 flex flex-col\">\n {searchResult?.items\n ?.filter((item: any) => canSearch(item))\n .slice(0, 6)\n ?.map((item: any) => (\n <Link\n className=\"w-full p-4 no-underline hover:bg-[#F5F5F7] hover:text-current\"\n href={getLink(item)}\n key={item.id}\n >\n <Text\n html={highlightSearchWord(item.title, searchValue)}\n className=\"cursor-pointer text-sm font-bold leading-[1.4]\"\n />\n </Link>\n ))}\n </div>\n </div>\n <div>\n <Text html={data?.hotProductsText} className=\"text-sm font-bold leading-[1.4] text-[#6D6D6F]\" />\n <div className=\"tablet:grid-cols-2 laptop:grid-cols-3 desktop:grid-cols-4 tablet:gap-x-3 tablet:gap-y-4 laptop:gap-4 mt-2 grid grid-cols-1 gap-2\">\n <Link asChild={!data?.advertisingLink} href={data?.advertisingLink}>\n <div className=\"relative\">\n <Picture\n source={data?.advertisingBgImg?.url}\n className=\"laptop:h-[120px] h-[114px]\"\n imgClassName=\"object-cover h-full\"\n />\n <div className=\"absolute inset-x-0 bottom-0 p-4\">\n <Heading\n size={2}\n html={data?.advertisingTitle || 'Buy in Guide'}\n className={cn('font-bold text-white', {\n 'text-black': data?.advertisingTheme === 'dark',\n })}\n />\n <Text\n html={data?.advertisingSubtitle || '20.000mAh'}\n className={cn('text-sm font-bold text-white', {\n 'text-black': data?.advertisingTheme === 'dark',\n })}\n />\n </div>\n </div>\n </Link>\n {searchResult?.items\n ?.filter((item: any) => item.type.toLowerCase() === 'product')\n .slice(0, 7)\n ?.map((item: any) => {\n const variant = item?.variants?.[0]\n const productImage = `${variant?.image?.url || item?.images?.[0]?.url}`\n const productName = item?.title || item?.name\n const productDesc = item?.description\n const productBadge = item?.badge || ''\n const listingLink = `/products/${item?.handle}?variant=${atobID(variant?.id as string)}`\n return (\n <SearchProduct\n productImage={productImage}\n productName={productName}\n productDesc={productDesc}\n productBadge={productBadge}\n listingLink={listingLink}\n key={item.id}\n />\n )\n })}\n </div>\n </div>\n </>\n ) : (\n <>\n {searchStatus === SearchStatus.Empty && (\n <Text\n html={data?.noResultText}\n as=\"p\"\n className=\"border-b border-[#E4E5E6] pb-6 text-sm font-bold leading-[1.4] text-[#6D6D6F]\"\n />\n )}\n <div>\n <Text html={data?.popularText} className=\"text-sm font-bold leading-[1.4] text-[#6D6D6F]\" />\n <div className=\"mt-2\">\n <SearchKeyword data={data} keywords={searchKeywords} locale={locale} />\n {Array.isArray(data?.popularPages) && !!data?.popularPages?.length && (\n <Grid className=\"laptop:gap-4 laptop:mt-4 mt-3 gap-3\">\n {data?.popularPages?.map((item: any) => (\n <GridItem\n key={item?.id}\n className=\"tablet:col-span-6 laptop:p-3 desktop:p-4 laptop:col-span-3 col-span-12 p-2 hover:bg-[#F5F5F7]\"\n >\n <a\n href={`${locale === 'us' ? '' : locale}${data?.moreLink}?q=${item?.popularPage.toLowerCase()}`}\n className=\"line-clamp-1 cursor-pointer text-sm font-bold leading-[1.4]\"\n >\n {item?.popularPage}\n </a>\n </GridItem>\n ))}\n </Grid>\n )}\n </div>\n </div>\n <div>\n <Text html={data?.hotProductsText} className=\"text-sm font-bold leading-[1.4] text-[#6D6D6F]\" />\n <div className=\"tablet:grid-cols-2 laptop:grid-cols-3 desktop:grid-cols-4 tablet:gap-x-3 tablet:gap-y-4 laptop:gap-4 mt-2 grid grid-cols-1 gap-2\">\n <Link asChild={!data?.advertisingLink} href={data?.advertisingLink}>\n <div className=\"relative [&_img]:hover:scale-110 [&_img]:hover:transition-all [&_img]:hover:duration-500\">\n <Picture\n source={data?.advertisingBgImg?.url}\n className=\"laptop:h-[120px] h-[114px]\"\n imgClassName=\"object-cover h-full\"\n />\n <div className=\"absolute inset-x-0 bottom-0 p-4\">\n <Heading\n size={2}\n html={data?.advertisingTitle || 'Buy in Guide'}\n className=\"font-bold text-white\"\n />\n <Text\n html={data?.advertisingSubtitle || '20.000mAh'}\n className=\"text-sm font-bold text-white\"\n />\n </div>\n </div>\n </Link>\n {data?.hotProducts?.slice(0, 7)?.map((item: any) => {\n const productDesc = item?.custom_description\n const productBadge = item?.badge || ''\n const listingLink = `/products/${item?.handle}?variant=${atobID(item?.shopify_id as string)}`\n return (\n <SearchProduct\n productImage={item?.image}\n productName={item?.name}\n productDesc={productDesc}\n productBadge={productBadge}\n listingLink={listingLink}\n key={item.id}\n />\n )\n })}\n </div>\n </div>\n </>\n )}\n </div>\n </Container>\n )\n }\n)\n\nNavigationSearch.displayName = 'NavigationSearch'\n\nconst SearchProduct = ({\n productImage,\n productName,\n productDesc,\n productBadge,\n className,\n listingLink,\n}: {\n productImage: string\n productName: string\n productDesc: string\n productBadge: string\n className?: string\n listingLink: string\n}) => {\n return (\n <Link href={listingLink} className=\"block no-underline hover:text-current\">\n <div\n className={cn(\n 'flex shrink-0 gap-4 bg-[#F5F5F7] px-4 py-3 [&_img]:hover:scale-110 [&_img]:hover:duration-500',\n className\n )}\n >\n <div className=\"shrink-0\">\n <Picture\n source={productImage}\n width={90}\n height={90}\n className=\"size-[96px]\"\n imgClassName=\"object-contain h-full\"\n />\n </div>\n <div className=\"relative\">\n <div className=\" h-[24px] \">\n {productBadge && (\n <Text\n as=\"p\"\n html={productBadge}\n className=\"text-brand-0 mb-1 inline-block h-full rounded-full border-[1.6px] border-[#00BEFA] px-[6px] text-sm font-bold !leading-[24px]\"\n />\n )}\n </div>\n <div>\n <Link href={listingLink} className=\"no-underline hover:text-current\">\n <Text\n className=\"lg-desktop:h-[44px] lg-desktop:text-base line-clamp-2 h-[40px] text-sm font-bold leading-[1.4]\"\n html={productName}\n />\n </Link>\n {productDesc && (\n <Text\n as=\"p\"\n html={productDesc}\n className=\"lg-desktop:text-sm mt-1 line-clamp-1 text-xs font-bold leading-[1.4] text-[#6D6D6F]\"\n />\n )}\n </div>\n </div>\n </div>\n </Link>\n )\n}\n\nconst SearchKeyword = ({ data, keywords, locale }: { data: any; keywords: any[]; locale: string }) => {\n return (\n <div className=\"laptop:gap-4 flex flex-wrap gap-3\">\n {keywords?.map((keyword: any, index) => (\n <a\n href={`${locale === 'us' ? '' : locale}${data?.moreLink}?q=${keyword?.toLowerCase()}`}\n key={index}\n className=\"laptop:p-3 desktop:p-4 cursor-pointer p-2 text-sm font-bold leading-[1.4] hover:bg-[#F5F5F7]\"\n >\n {keyword}\n </a>\n ))}\n </div>\n )\n}\n\nexport default NavigationSearch\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CAIP,CACD,EACH,EAIJ,IAAO9C,EAAQW",
|
|
6
6
|
"names": ["NavigationSearch_exports", "__export", "canSearch", "NavigationSearch_default", "__toCommonJS", "import_jsx_runtime", "import_components", "import_icons", "import_react", "import_AiuiProvider", "import_types", "import_es_toolkit", "import_utils", "target", "NavigationSearch", "data", "onSearch", "onClose", "searchResult", "isSearching", "keywords", "ref", "locale", "copyWriting", "searchValue", "setSearchValue", "isComposing", "setIsComposing", "debouncedFunction", "value", "handleKeyDown", "e", "searchKeywords", "keyword", "word", "getLink", "item", "searchStatus", "SearchIcon", "CloseIcon", "variant", "productImage", "productName", "productDesc", "productBadge", "listingLink", "SearchProduct", "SearchKeyword", "className", "index"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var S=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var j=(s,o)=>{for(var l in o)S(s,l,{get:o[l],enumerable:!0})},$=(s,o,l,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let c of O(o))!R.call(s,c)&&c!==l&&S(s,c,{get:()=>o[c],enumerable:!(n=A(o,c))||n.enumerable});return s};var F=s=>$(S({},"__esModule",{value:!0}),s);var H={};j(H,{default:()=>U});module.exports=F(H);var e=require("react/jsx-runtime"),t=require("../../components/index.js"),E=require("../HeaderNavigation/icons/index.js"),i=require("react"),d=require("../../helpers/utils.js"),k=require("../AiuiProvider/index.js"),I=require("../ShelfDisplay/shelfDisplay.js"),u=require("./types.js");const B=({product:s,onSecondaryButton:o,onPrimaryButton:l,searchValue:n,variantData:c})=>{const p=(0,i.useMemo)(()=>c||s?.variants?.[0],[s,c]),{locale:g="us",copyWriting:m}=(0,k.useAiuiContext)(),h=(0,i.useMemo)(()=>`/products/${s?.handle}?variant=${(0,d.atobID)(p?.id)}`,[s?.handle,p?.id]),x=p?.coupons?.[0],{price:r,basePrice:N}=(0,I.formatVariantPrice)({locale:g,amount:x?x.variant_price4wscode:p?.price,baseAmount:x?p?.price:0,currencyCode:s?.price?.currencyCode||"USD"}),y=(0,i.useMemo)(()=>s?.tags?.filter?.(b=>b?.startsWith?.("CLtag"))?.map?.(b=>b?.replace?.("CLtag:",""))?.slice?.(0,2),[s?.tags]);return(0,e.jsx)("div",{className:"ipc_search_product_item lg-desktop:h-[480px] desktop:h-[384px] laptop:h-[360px] relative h-auto",children:s?.type==="advertising"?(0,e.jsxs)(t.Link,{href:s?.advertisingLink,className:"h-full",children:[(0,e.jsx)(t.Picture,{source:s?.advertisingBgImg?.url,className:"size-full",imgClassName:"size-full object-cover"}),(0,e.jsxs)("div",{className:"desktop:p-6 absolute inset-0 z-[2] p-4 [&_img]:hover:scale-110 [&_img]:hover:transition-all [&_img]:hover:duration-[600]",children:[(0,e.jsx)(t.Text,{html:s?.advertisingTitle,className:"desktop:text-[18px] text-sm font-bold text-white"}),(0,e.jsx)(t.Heading,{size:3,html:s?.advertisingSubtitle,className:"laptop:line-clamp-3 mt-2 line-clamp-4 font-bold text-white"})]})]}):(0,e.jsxs)("a",{href:h,className:" tablet:hover:bg-info-white desktop:p-6 desktop:pt-4 tablet:p-4 flex h-full flex-col bg-[#EAEAEC] px-2 py-4 no-underline duration-300",children:[(0,e.jsx)("div",{className:"ipc_search_product_item_image",children:(0,e.jsx)(t.Picture,{className:"lg-desktop:size-[196px] mx-auto size-[138px]",source:`${p?.image?.url||s?.images?.[0]?.url}}`,alt:s.title,imgClassName:"object-cover size-full"})}),(0,e.jsxs)("div",{className:"ipc_search_product_item_content desktop:mt-2 lg-desktop:mt-3 desktop:gap-6 mt-1 flex flex-1 flex-col justify-between gap-4",children:[(0,e.jsxs)("div",{className:"flex-1",children:[(0,e.jsx)("div",{className:"lg-desktop:h-[28px] mb-2 flex h-[24px] gap-2",children:y?.map((b,_)=>(0,e.jsx)(t.Text,{as:"p",html:b,className:"text-brand-0 lg-desktop:px-2 lg-desktop:!leading-[28px] h-full rounded-full border-[1.6px] border-[#00BEFA] px-[6px] text-sm font-bold !leading-[24px]"},_))}),(0,e.jsx)(t.Text,{className:"desktop:text-2xl tablet:line-clamp-2 line-clamp-3 text-xl font-bold !leading-[1.2]",weight:"bold",html:(0,d.highlightSearchWord)(s?.title||"",n||"")}),(0,e.jsx)(t.Text,{as:"p",className:"lg-desktop:text-[18px] tablet:line-clamp-1 mt-1 line-clamp-2 text-sm font-bold",html:(0,d.highlightSearchWord)(s.description,n||"")})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"mb-2 flex items-center",children:p?.availableForSale?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"final-price text-info-primary tablet:text-xl lg-desktop:text-2xl text-[18px] font-bold",children:p?.availableForSale&&r||""}),(0,e.jsx)("div",{className:"origin-price tablet:text-xl lg-desktop:text-2xl text-info-secondary ml-1 text-[18px] font-bold line-through",children:p?.availableForSale&&N||""})]}):(0,e.jsx)("div",{className:"text-info-primary tablet:text-xl lg-desktop:text-2xl text-[18px] font-bold",children:m?.soldOutText||"Sold Out"})}),(0,e.jsxs)("div",{className:(0,d.cn)("ipc_search_product_item_button_group","lg-desktop:gap-3 laptop:flex-row flex flex-col items-center gap-2"),children:[m?.learnMoreText&&(0,e.jsx)(t.Button,{variant:"secondary",className:"laptop:w-auto w-full",size:"lg",disabled:!p?.availableForSale,onClick:()=>o?.(),children:m?.learnMoreText}),m?.shopNowText&&(0,e.jsx)(t.Button,{variant:"primary",className:"laptop:w-auto w-full",size:"lg",disabled:!p?.availableForSale,onClick:()=>l?.(),children:m?.shopNowText})]})]})]})]})})},G=({blog:s,searchValue:o})=>{const{copyWriting:l}=(0,k.useAiuiContext)(),n=(0,i.useMemo)(()=>`blogs/${s?.handle}/${s?.handle.replace("storefront-","")}`,[s]);return(0,e.jsx)("div",{className:"ipc_search_blog_item border-b border-[#E4E5E6] py-6",children:(0,e.jsxs)("div",{className:"ipc_search_blog_item_content laptop:flex-row-reverse laptop:gap-8 desktop:gap-16 flex flex-col gap-4",children:[(0,e.jsx)("div",{className:"laptop:flex-[440] desktop:flex-[540] desktop:h-[280px] h-[240px]",children:(0,e.jsx)(t.Picture,{source:s?.image?.url,className:"size-full",imgClassName:"size-full object-cover",alt:s?.title})}),(0,e.jsxs)("div",{className:"laptop:flex-[424] desktop:flex-[704] lg-desktop:flex-[1056] flex flex-col justify-center",children:[(0,e.jsx)(t.Heading,{size:3,html:(0,d.highlightSearchWord)(s?.title,o)}),(0,e.jsx)(t.Text,{html:(0,d.highlightSearchWord)(s?.content,o),className:"lg-desktop:text-[18px] desktop:text-[16px] mt-1 line-clamp-2 text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"desktop:mt-6 mt-4",children:(0,e.jsx)(t.Button,{as:"a",href:n,variant:"secondary",size:"lg",children:l?.learnMoreText||"Learn More"})})]})]})})},W=({searchValue:s,page:o})=>{const{copyWriting:l,locale:n="us"}=(0,k.useAiuiContext)(),c=(0,i.useMemo)(()=>`${n==="us"?"":`/${n}`}/${o?.handle}`,[o,n]);return(0,e.jsxs)("div",{className:"ipc_search_page_items border-b border-[#E4E5E6] py-6",children:[(0,e.jsx)(t.Heading,{size:3,html:(0,d.highlightSearchWord)(o?.name,s)}),(0,e.jsx)(t.Text,{as:"p",html:(0,d.highlightSearchWord)(o?.bodySummary||"",s),className:"lg-desktop:text-[18px] desktop:text-[16px] mt-1 text-sm font-bold leading-[1.4]"}),(0,e.jsx)(t.Button,{as:"a",href:c,variant:"secondary",size:"lg",className:"desktop:mt-6 mt-4",children:l?.learnMoreText||"Learn More"})]})},P=({url:s,label:o})=>(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4",children:[(0,e.jsx)(t.Picture,{source:s,className:"h-[180px] w-[240px]",imgClassName:"object-cover"}),(0,e.jsx)(t.Text,{html:o,className:"desktop:text-[18px] text-sm font-bold leading-[1.4]"})]}),T=({products:s,title:o,buildProps:l,onSecondaryButton:n,onPrimaryButton:c})=>{const{products:p}=l||{};return(0,e.jsxs)("div",{className:"ipc_search_recommend_product tablet:pt-[80px] laptop:pt-[96px] desktop:pt-[112px] lg-desktop:pt-[128px] pt-[64px]",children:[(0,e.jsx)(t.Heading,{size:4,weight:"bold",html:o}),(0,e.jsx)("div",{className:" tablet:grid-cols-3 desktop:grid-cols-4 desktop:gap-4 mt-6 grid grid-cols-2 gap-x-3 gap-y-4",children:s?.map((g,m)=>{const h=p?.find(r=>r.handle===g.handle),x=h?.variants?.find(r=>r.sku===g.sku);return(0,e.jsx)(B,{product:h,variantData:x,onSecondaryButton:()=>n?.(),onPrimaryButton:()=>c?.()},g.id+m)})})]})},K=({searchResult:s,searchValue:o,data:l,onSecondaryButton:n,onPrimaryButton:c,onChangeSort:p,loading:g,searchResultCount:m,onChangeTab:h,buildProps:x})=>{const[r,N]=(0,i.useState)(l?.tabs?.[0]),y=(0,i.useRef)(!1),[b,_]=(0,i.useState)(!1),[w,z]=(0,i.useState)({[u.SearchPageTabType.PRODUCTS]:l?.tabs?.find(a=>a.tabType===u.SearchPageTabType.PRODUCTS)?.sortKeys?.[0],[u.SearchPageTabType.BLOGS]:l?.tabs?.find(a=>a.tabType===u.SearchPageTabType.BLOGS)?.sortKeys?.[0],[u.SearchPageTabType.PAGES]:l?.tabs?.find(a=>a.tabType===u.SearchPageTabType.PAGES)?.sortKeys?.[0]}),v=(0,i.useMemo)(()=>s?.products||[],[s]),C=(0,i.useMemo)(()=>s?.blogs||[],[s]),L=(0,i.useMemo)(()=>s?.pages||[],[s]),D=(0,i.useMemo)(()=>Object.values(m||{}).reduce((a,f)=>a+f,0),[m]),M=(0,i.useMemo)(()=>{const a={advertisingBgImg:r?.advertisingBgImg,advertisingTitle:r?.advertisingTitle,advertisingSubtitle:r?.advertisingSubtitle,advertisingLink:r?.advertisingLink,type:"advertising"};return!y.current&&v?.length&&(v?.length>=8?(v?.splice(7,0,a),y.current=!0):(v?.push(a),y.current=!0)),v},[r,v]);return(0,e.jsxs)("div",{className:"ipc_search_page desktop:py-[128px] tablet:px-8 laptop:px-16 desktop:px-16 lg-desktop:px-[calc(50%-832px)] px-4 py-16",children:[(0,e.jsx)(t.Heading,{size:4,weight:"bold",html:l?.title?.replace("$totalCount",D?.toString())?.replace("$inputValue",`"${o}"`)}),(0,e.jsx)("div",{className:"mt-6",children:(0,e.jsxs)(t.Tabs,{className:"ipc_search_page_tabs",defaultValue:"products",children:[(0,e.jsxs)("div",{className:"desktop:flex desktop:items-center desktop:flex-row desktop:gap-6 desktop:justify-between",children:[(0,e.jsx)(t.TabsList,{children:l?.tabs?.map(a=>(0,e.jsxs)(t.TabsTrigger,{onClick:()=>{N(a),h?.(a?.tabType)},defaultValue:"products",value:a.tabType,children:[a.label," (",m?.[a.tabType],")"]},a.id))}),(0,e.jsxs)(t.DropdownMenu,{onOpenChange:_,children:[(0,e.jsx)(t.DropdownMenuTrigger,{asChild:!0,children:(0,e.jsxs)("button",{className:"desktop:mt-0 mt-6 flex items-center text-base font-bold leading-[1.2]",children:[r?.sortLabel," ",w?.[r?.tabType]?.label," ",(0,e.jsx)(E.DownArrow,{className:(0,d.cn)("inline-block size-4",{"rotate-180":b})})]})}),(0,e.jsx)(t.DropdownMenuContent,{align:"start",sideOffset:8,className:"rounded-none bg-white !px-0 py-2",children:r?.sortKeys?.map(a=>(0,e.jsx)(t.DropdownMenuItem,{className:(0,d.cn)("laptop:px-4 laptop:text-base px-3 py-4 text-sm font-bold hover:bg-[#EAEAEC] hover:text-current",{"bg-[#EAEAEC]":w?.[r?.tabType]?.value===a.value}),onClick:()=>{y.current=!1,p?.(r?.tabType,a),z(f=>({...f,[r?.tabType]:a}))},children:a.label},a.id))})]})]}),(0,e.jsxs)(t.TabsContent,{value:u.SearchPageTabType.PRODUCTS,className:"ipc_search_page_tabs_products_content mt-6",children:[(0,e.jsx)("div",{className:"tablet:grid-cols-3 desktop:grid-cols-4 desktop:gap-4 grid grid-cols-2 gap-x-3 gap-y-4",children:M?.map((a,f)=>(0,e.jsx)(B,{searchValue:o,product:a,onSecondaryButton:()=>n?.(a),onPrimaryButton:()=>c?.(a)},a.id+f))}),g?(0,e.jsx)("div",{className:"mt-6 flex w-full justify-center",children:(0,e.jsx)(t.LoadingDots,{})}):!v?.length&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(P,{url:l?.noResultImage?.url,label:l?.noResultLabel}),(0,e.jsx)(T,{products:l?.recommendProducts||[],buildProps:x,title:l?.recommendProductsTitle})]})]}),(0,e.jsx)(t.TabsContent,{value:u.SearchPageTabType.BLOGS,className:"ipc_search_page_tabs_blogs_content",children:(0,e.jsxs)("div",{children:[C?.map(a=>(0,e.jsx)(G,{blog:a,searchValue:o},a.id)),g?(0,e.jsx)("div",{className:"mt-6 flex justify-center",children:(0,e.jsx)(t.LoadingDots,{})}):!C?.length&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(P,{url:l?.noResultImage?.url,label:l?.noResultLabel}),(0,e.jsx)(T,{products:l?.recommendProducts||[],buildProps:x,title:l?.recommendProductsTitle})]})]})}),(0,e.jsxs)(t.TabsContent,{value:u.SearchPageTabType.PAGES,className:"ipc_search_page_tabs_pages_content",children:[(0,e.jsx)("div",{children:L?.map((a,f)=>(0,e.jsx)(W,{page:a,searchValue:o},a.global_id+f))}),g?(0,e.jsx)("div",{className:"mt-6 flex justify-center",children:(0,e.jsx)(t.LoadingDots,{})}):!L?.length&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(P,{url:l?.noResultImage?.url,label:l?.noResultLabel}),(0,e.jsx)(T,{products:l?.recommendProducts||[],buildProps:x,title:l?.recommendProductsTitle})]})]})]})})]})};var U=K;
|
|
1
|
+
"use strict";var S=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var j=(s,o)=>{for(var l in o)S(s,l,{get:o[l],enumerable:!0})},$=(s,o,l,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let c of O(o))!R.call(s,c)&&c!==l&&S(s,c,{get:()=>o[c],enumerable:!(n=A(o,c))||n.enumerable});return s};var F=s=>$(S({},"__esModule",{value:!0}),s);var H={};j(H,{default:()=>U});module.exports=F(H);var e=require("react/jsx-runtime"),t=require("../../components/index.js"),E=require("../HeaderNavigation/icons/index.js"),i=require("react"),d=require("../../helpers/utils.js"),k=require("../AiuiProvider/index.js"),I=require("../ShelfDisplay/shelfDisplay.js"),u=require("./types.js");const B=({product:s,onSecondaryButton:o,onPrimaryButton:l,searchValue:n,variantData:c})=>{const p=(0,i.useMemo)(()=>c||s?.variants?.[0],[s,c]),{locale:g="us",copyWriting:m}=(0,k.useAiuiContext)(),h=(0,i.useMemo)(()=>`/products/${s?.handle}?variant=${(0,d.atobID)(p?.id)}`,[s?.handle,p?.id]),x=p?.coupons?.[0],{price:r,basePrice:N}=(0,I.formatVariantPrice)({locale:g,amount:x?x.variant_price4wscode:p?.price,baseAmount:x?p?.price:0,currencyCode:s?.price?.currencyCode||"USD"}),y=(0,i.useMemo)(()=>s?.tags?.filter?.(b=>b?.startsWith?.("CLtag"))?.map?.(b=>b?.replace?.("CLtag:",""))?.slice?.(0,2),[s?.tags]);return(0,e.jsx)("div",{className:"ipc_search_product_item lg-desktop:h-[480px] desktop:h-[384px] laptop:h-[360px] relative h-auto",children:s?.type==="advertising"?(0,e.jsxs)(t.Link,{href:s?.advertisingLink,className:"h-full",children:[(0,e.jsx)(t.Picture,{source:s?.advertisingBgImg?.url,className:"size-full",imgClassName:"size-full object-cover"}),(0,e.jsxs)("div",{className:"desktop:p-6 absolute inset-0 z-[2] p-4 [&_img]:hover:scale-110 [&_img]:hover:transition-all [&_img]:hover:duration-500",children:[(0,e.jsx)(t.Text,{html:s?.advertisingTitle,className:"desktop:text-[18px] text-sm font-bold text-white"}),(0,e.jsx)(t.Heading,{size:3,html:s?.advertisingSubtitle,className:"laptop:line-clamp-3 mt-2 line-clamp-4 font-bold text-white"})]})]}):(0,e.jsxs)("a",{href:h,className:" tablet:hover:bg-info-white desktop:p-6 desktop:pt-4 tablet:p-4 flex h-full flex-col bg-[#EAEAEC] px-2 py-4 no-underline duration-300",children:[(0,e.jsx)("div",{className:"ipc_search_product_item_image",children:(0,e.jsx)(t.Picture,{className:"lg-desktop:size-[196px] mx-auto size-[138px]",source:`${p?.image?.url||s?.images?.[0]?.url}}`,alt:s.title,imgClassName:"object-cover size-full"})}),(0,e.jsxs)("div",{className:"ipc_search_product_item_content desktop:mt-2 lg-desktop:mt-3 desktop:gap-6 mt-1 flex flex-1 flex-col justify-between gap-4",children:[(0,e.jsxs)("div",{className:"flex-1",children:[(0,e.jsx)("div",{className:"lg-desktop:h-[28px] mb-2 flex h-[24px] gap-2",children:y?.map((b,_)=>(0,e.jsx)(t.Text,{as:"p",html:b,className:"text-brand-0 lg-desktop:px-2 lg-desktop:!leading-[28px] h-full rounded-full border-[1.6px] border-[#00BEFA] px-[6px] text-sm font-bold !leading-[24px]"},_))}),(0,e.jsx)(t.Text,{className:"desktop:text-2xl tablet:line-clamp-2 line-clamp-3 text-xl font-bold !leading-[1.2]",weight:"bold",html:(0,d.highlightSearchWord)(s?.title||"",n||"")}),(0,e.jsx)(t.Text,{as:"p",className:"lg-desktop:text-[18px] tablet:line-clamp-1 mt-1 line-clamp-2 text-sm font-bold",html:(0,d.highlightSearchWord)(s.description,n||"")})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"mb-2 flex items-center",children:p?.availableForSale?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"final-price text-info-primary tablet:text-xl lg-desktop:text-2xl text-[18px] font-bold",children:p?.availableForSale&&r||""}),(0,e.jsx)("div",{className:"origin-price tablet:text-xl lg-desktop:text-2xl text-info-secondary ml-1 text-[18px] font-bold line-through",children:p?.availableForSale&&N||""})]}):(0,e.jsx)("div",{className:"text-info-primary tablet:text-xl lg-desktop:text-2xl text-[18px] font-bold",children:m?.soldOutText||"Sold Out"})}),(0,e.jsxs)("div",{className:(0,d.cn)("ipc_search_product_item_button_group","lg-desktop:gap-3 laptop:flex-row flex flex-col items-center gap-2"),children:[m?.learnMoreText&&(0,e.jsx)(t.Button,{variant:"secondary",className:"laptop:w-auto w-full",size:"lg",disabled:!p?.availableForSale,onClick:()=>o?.(),children:m?.learnMoreText}),m?.shopNowText&&(0,e.jsx)(t.Button,{variant:"primary",className:"laptop:w-auto w-full",size:"lg",disabled:!p?.availableForSale,onClick:()=>l?.(),children:m?.shopNowText})]})]})]})]})})},G=({blog:s,searchValue:o})=>{const{copyWriting:l}=(0,k.useAiuiContext)(),n=(0,i.useMemo)(()=>`blogs/${s?.handle}/${s?.handle.replace("storefront-","")}`,[s]);return(0,e.jsx)("div",{className:"ipc_search_blog_item border-b border-[#E4E5E6] py-6",children:(0,e.jsxs)("div",{className:"ipc_search_blog_item_content laptop:flex-row-reverse laptop:gap-8 desktop:gap-16 flex flex-col gap-4",children:[(0,e.jsx)("div",{className:"laptop:flex-[440] desktop:flex-[540] desktop:h-[280px] h-[240px]",children:(0,e.jsx)(t.Picture,{source:s?.image?.url,className:"size-full",imgClassName:"size-full object-cover",alt:s?.title})}),(0,e.jsxs)("div",{className:"laptop:flex-[424] desktop:flex-[704] lg-desktop:flex-[1056] flex flex-col justify-center",children:[(0,e.jsx)(t.Heading,{size:3,html:(0,d.highlightSearchWord)(s?.title,o)}),(0,e.jsx)(t.Text,{html:(0,d.highlightSearchWord)(s?.content,o),className:"lg-desktop:text-[18px] desktop:text-[16px] mt-1 line-clamp-2 text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"desktop:mt-6 mt-4",children:(0,e.jsx)(t.Button,{as:"a",href:n,variant:"secondary",size:"lg",children:l?.learnMoreText||"Learn More"})})]})]})})},W=({searchValue:s,page:o})=>{const{copyWriting:l,locale:n="us"}=(0,k.useAiuiContext)(),c=(0,i.useMemo)(()=>`${n==="us"?"":`/${n}`}/${o?.handle}`,[o,n]);return(0,e.jsxs)("div",{className:"ipc_search_page_items border-b border-[#E4E5E6] py-6",children:[(0,e.jsx)(t.Heading,{size:3,html:(0,d.highlightSearchWord)(o?.name,s)}),(0,e.jsx)(t.Text,{as:"p",html:(0,d.highlightSearchWord)(o?.bodySummary||"",s),className:"lg-desktop:text-[18px] desktop:text-[16px] mt-1 text-sm font-bold leading-[1.4]"}),(0,e.jsx)(t.Button,{as:"a",href:c,variant:"secondary",size:"lg",className:"desktop:mt-6 mt-4",children:l?.learnMoreText||"Learn More"})]})},P=({url:s,label:o})=>(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4",children:[(0,e.jsx)(t.Picture,{source:s,className:"h-[180px] w-[240px]",imgClassName:"object-cover"}),(0,e.jsx)(t.Text,{html:o,className:"desktop:text-[18px] text-sm font-bold leading-[1.4]"})]}),T=({products:s,title:o,buildProps:l,onSecondaryButton:n,onPrimaryButton:c})=>{const{products:p}=l||{};return(0,e.jsxs)("div",{className:"ipc_search_recommend_product tablet:pt-[80px] laptop:pt-[96px] desktop:pt-[112px] lg-desktop:pt-[128px] pt-[64px]",children:[(0,e.jsx)(t.Heading,{size:4,weight:"bold",html:o}),(0,e.jsx)("div",{className:" tablet:grid-cols-3 desktop:grid-cols-4 desktop:gap-4 mt-6 grid grid-cols-2 gap-x-3 gap-y-4",children:s?.map((g,m)=>{const h=p?.find(r=>r.handle===g.handle),x=h?.variants?.find(r=>r.sku===g.sku);return(0,e.jsx)(B,{product:h,variantData:x,onSecondaryButton:()=>n?.(),onPrimaryButton:()=>c?.()},g.id+m)})})]})},K=({searchResult:s,searchValue:o,data:l,onSecondaryButton:n,onPrimaryButton:c,onChangeSort:p,loading:g,searchResultCount:m,onChangeTab:h,buildProps:x})=>{const[r,N]=(0,i.useState)(l?.tabs?.[0]),y=(0,i.useRef)(!1),[b,_]=(0,i.useState)(!1),[w,z]=(0,i.useState)({[u.SearchPageTabType.PRODUCTS]:l?.tabs?.find(a=>a.tabType===u.SearchPageTabType.PRODUCTS)?.sortKeys?.[0],[u.SearchPageTabType.BLOGS]:l?.tabs?.find(a=>a.tabType===u.SearchPageTabType.BLOGS)?.sortKeys?.[0],[u.SearchPageTabType.PAGES]:l?.tabs?.find(a=>a.tabType===u.SearchPageTabType.PAGES)?.sortKeys?.[0]}),v=(0,i.useMemo)(()=>s?.products||[],[s]),C=(0,i.useMemo)(()=>s?.blogs||[],[s]),L=(0,i.useMemo)(()=>s?.pages||[],[s]),D=(0,i.useMemo)(()=>Object.values(m||{}).reduce((a,f)=>a+f,0),[m]),M=(0,i.useMemo)(()=>{const a={advertisingBgImg:r?.advertisingBgImg,advertisingTitle:r?.advertisingTitle,advertisingSubtitle:r?.advertisingSubtitle,advertisingLink:r?.advertisingLink,type:"advertising"};return!y.current&&v?.length&&(v?.length>=8?(v?.splice(7,0,a),y.current=!0):(v?.push(a),y.current=!0)),v},[r,v]);return(0,e.jsxs)("div",{className:"ipc_search_page desktop:py-[128px] tablet:px-8 laptop:px-16 desktop:px-16 lg-desktop:px-[calc(50%-832px)] px-4 py-16",children:[(0,e.jsx)(t.Heading,{size:4,weight:"bold",html:l?.title?.replace("$totalCount",D?.toString())?.replace("$inputValue",`"${o}"`)}),(0,e.jsx)("div",{className:"mt-6",children:(0,e.jsxs)(t.Tabs,{className:"ipc_search_page_tabs",defaultValue:"products",children:[(0,e.jsxs)("div",{className:"desktop:flex desktop:items-center desktop:flex-row desktop:gap-6 desktop:justify-between",children:[(0,e.jsx)(t.TabsList,{children:l?.tabs?.map(a=>(0,e.jsxs)(t.TabsTrigger,{onClick:()=>{N(a),h?.(a?.tabType)},defaultValue:"products",value:a.tabType,children:[a.label," (",m?.[a.tabType],")"]},a.id))}),(0,e.jsxs)(t.DropdownMenu,{onOpenChange:_,children:[(0,e.jsx)(t.DropdownMenuTrigger,{asChild:!0,children:(0,e.jsxs)("button",{className:"desktop:mt-0 mt-6 flex items-center text-base font-bold leading-[1.2]",children:[r?.sortLabel," ",w?.[r?.tabType]?.label," ",(0,e.jsx)(E.DownArrow,{className:(0,d.cn)("inline-block size-4",{"rotate-180":b})})]})}),(0,e.jsx)(t.DropdownMenuContent,{align:"start",sideOffset:8,className:"rounded-none bg-white !px-0 py-2",children:r?.sortKeys?.map(a=>(0,e.jsx)(t.DropdownMenuItem,{className:(0,d.cn)("laptop:px-4 laptop:text-base px-3 py-4 text-sm font-bold hover:bg-[#EAEAEC] hover:text-current",{"bg-[#EAEAEC]":w?.[r?.tabType]?.value===a.value}),onClick:()=>{y.current=!1,p?.(r?.tabType,a),z(f=>({...f,[r?.tabType]:a}))},children:a.label},a.id))})]})]}),(0,e.jsxs)(t.TabsContent,{value:u.SearchPageTabType.PRODUCTS,className:"ipc_search_page_tabs_products_content mt-6",children:[(0,e.jsx)("div",{className:"tablet:grid-cols-3 desktop:grid-cols-4 desktop:gap-4 grid grid-cols-2 gap-x-3 gap-y-4",children:M?.map((a,f)=>(0,e.jsx)(B,{searchValue:o,product:a,onSecondaryButton:()=>n?.(a),onPrimaryButton:()=>c?.(a)},a.id+f))}),g?(0,e.jsx)("div",{className:"mt-6 flex w-full justify-center",children:(0,e.jsx)(t.LoadingDots,{})}):!v?.length&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(P,{url:l?.noResultImage?.url,label:l?.noResultLabel}),(0,e.jsx)(T,{products:l?.recommendProducts||[],buildProps:x,title:l?.recommendProductsTitle})]})]}),(0,e.jsx)(t.TabsContent,{value:u.SearchPageTabType.BLOGS,className:"ipc_search_page_tabs_blogs_content",children:(0,e.jsxs)("div",{children:[C?.map(a=>(0,e.jsx)(G,{blog:a,searchValue:o},a.id)),g?(0,e.jsx)("div",{className:"mt-6 flex justify-center",children:(0,e.jsx)(t.LoadingDots,{})}):!C?.length&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(P,{url:l?.noResultImage?.url,label:l?.noResultLabel}),(0,e.jsx)(T,{products:l?.recommendProducts||[],buildProps:x,title:l?.recommendProductsTitle})]})]})}),(0,e.jsxs)(t.TabsContent,{value:u.SearchPageTabType.PAGES,className:"ipc_search_page_tabs_pages_content",children:[(0,e.jsx)("div",{children:L?.map((a,f)=>(0,e.jsx)(W,{page:a,searchValue:o},a.global_id+f))}),g?(0,e.jsx)("div",{className:"mt-6 flex justify-center",children:(0,e.jsx)(t.LoadingDots,{})}):!L?.length&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(P,{url:l?.noResultImage?.url,label:l?.noResultLabel}),(0,e.jsx)(T,{products:l?.recommendProducts||[],buildProps:x,title:l?.recommendProductsTitle})]})]})]})})]})};var U=K;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/SearchPage/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n Heading,\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n Text,\n Picture,\n Link,\n Button,\n DropdownMenu,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n LoadingDots,\n} from '../../components/index.js'\nimport { DownArrow } from '../HeaderNavigation/icons/index.js'\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport { cn, atobID, highlightSearchWord } from '../../helpers/utils.js'\nimport { useAiuiContext } from '../AiuiProvider/index.js'\nimport { formatVariantPrice } from '../ShelfDisplay/shelfDisplay.js'\nimport type {\n SearchPageProps,\n SortKey,\n SearchProductItemProps,\n SearchBlogItemProps,\n SearchPageItemProps,\n SearchRecommendProductsProps,\n} from './types'\nimport { SearchPageTabType } from './types.js'\n\n/**\n * \u641C\u7D22\u5546\u54C1\n */\nconst SearchProductItem = ({\n product,\n onSecondaryButton,\n onPrimaryButton,\n searchValue,\n variantData,\n}: SearchProductItemProps) => {\n const variant = useMemo(() => variantData || product?.variants?.[0], [product, variantData])\n const { locale = 'us', copyWriting } = useAiuiContext()\n\n const listingLink = useMemo(() => {\n return `/products/${product?.handle}?variant=${atobID(variant?.id as string)}`\n }, [product?.handle, variant?.id])\n\n const coupon = variant?.coupons?.[0]\n\n const { price, basePrice } = formatVariantPrice({\n locale: locale,\n amount: coupon ? coupon.variant_price4wscode : variant?.price,\n baseAmount: coupon ? variant?.price : 0,\n currencyCode: product?.price?.currencyCode || 'USD',\n })\n\n const tags = useMemo(() => {\n return product?.tags\n ?.filter?.((item: any) => item?.startsWith?.('CLtag'))\n ?.map?.((item: any) => item?.replace?.('CLtag:', ''))\n ?.slice?.(0, 2)\n }, [product?.tags])\n\n return (\n <div className=\"ipc_search_product_item lg-desktop:h-[480px] desktop:h-[384px] laptop:h-[360px] relative h-auto\">\n {product?.type === 'advertising' ? (\n <Link href={product?.advertisingLink} className=\"h-full\">\n <Picture\n source={product?.advertisingBgImg?.url}\n className=\"size-full\"\n imgClassName=\"size-full object-cover\"\n />\n <div className=\"desktop:p-6 absolute inset-0 z-[2] p-4 [&_img]:hover:scale-110 [&_img]:hover:transition-all [&_img]:hover:duration-[600]\">\n <Text html={product?.advertisingTitle} className=\"desktop:text-[18px] text-sm font-bold text-white\" />\n <Heading\n size={3}\n html={product?.advertisingSubtitle}\n className=\"laptop:line-clamp-3 mt-2 line-clamp-4 font-bold text-white\"\n />\n </div>\n </Link>\n ) : (\n <a\n href={listingLink}\n className=\" tablet:hover:bg-info-white desktop:p-6 desktop:pt-4 tablet:p-4 flex h-full flex-col bg-[#EAEAEC] px-2 py-4 no-underline duration-300\"\n >\n <div className=\"ipc_search_product_item_image\">\n <Picture\n className=\"lg-desktop:size-[196px] mx-auto size-[138px]\"\n source={`${variant?.image?.url || product?.images?.[0]?.url}}`}\n alt={product.title}\n imgClassName=\"object-cover size-full\"\n />\n </div>\n <div className=\"ipc_search_product_item_content desktop:mt-2 lg-desktop:mt-3 desktop:gap-6 mt-1 flex flex-1 flex-col justify-between gap-4\">\n <div className=\"flex-1\">\n <div className=\"lg-desktop:h-[28px] mb-2 flex h-[24px] gap-2\">\n {tags?.map((tag: string, index: number) => (\n <Text\n key={index}\n as=\"p\"\n html={tag}\n className=\"text-brand-0 lg-desktop:px-2 lg-desktop:!leading-[28px] h-full rounded-full border-[1.6px] border-[#00BEFA] px-[6px] text-sm font-bold !leading-[24px]\"\n />\n ))}\n </div>\n <Text\n className=\"desktop:text-2xl tablet:line-clamp-2 line-clamp-3 text-xl font-bold !leading-[1.2]\"\n weight=\"bold\"\n html={highlightSearchWord(product?.title || '', searchValue || '')}\n />\n <Text\n as=\"p\"\n className=\"lg-desktop:text-[18px] tablet:line-clamp-1 mt-1 line-clamp-2 text-sm font-bold\"\n html={highlightSearchWord(product.description, searchValue || '')}\n />\n </div>\n <div>\n <div className=\"mb-2 flex items-center\">\n {!variant?.availableForSale ? (\n <div className=\"text-info-primary tablet:text-xl lg-desktop:text-2xl text-[18px] font-bold\">\n {copyWriting?.soldOutText || 'Sold Out'}\n </div>\n ) : (\n <>\n <div className=\"final-price text-info-primary tablet:text-xl lg-desktop:text-2xl text-[18px] font-bold\">\n {variant?.availableForSale ? price || '' : ''}\n </div>\n <div className=\"origin-price tablet:text-xl lg-desktop:text-2xl text-info-secondary ml-1 text-[18px] font-bold line-through\">\n {variant?.availableForSale ? basePrice || '' : ''}\n </div>\n </>\n )}\n </div>\n <div\n className={cn(\n 'ipc_search_product_item_button_group',\n 'lg-desktop:gap-3 laptop:flex-row flex flex-col items-center gap-2'\n )}\n >\n {copyWriting?.learnMoreText && (\n <Button\n variant=\"secondary\"\n className=\"laptop:w-auto w-full\"\n size=\"lg\"\n disabled={!variant?.availableForSale}\n onClick={() => onSecondaryButton?.()}\n >\n {copyWriting?.learnMoreText}\n </Button>\n )}\n {copyWriting?.shopNowText && (\n <Button\n variant=\"primary\"\n className=\"laptop:w-auto w-full\"\n size=\"lg\"\n disabled={!variant?.availableForSale}\n onClick={() => onPrimaryButton?.()}\n >\n {copyWriting?.shopNowText}\n </Button>\n )}\n </div>\n </div>\n </div>\n </a>\n )}\n </div>\n )\n}\n\n/**\n * \u641C\u7D22\u6587\u7AE0\n */\nconst SearchBlogItem = ({ blog, searchValue }: SearchBlogItemProps) => {\n const { copyWriting } = useAiuiContext()\n\n const articleLink = useMemo(() => `blogs/${blog?.handle}/${blog?.handle.replace('storefront-', '')}`, [blog])\n\n return (\n <div className=\"ipc_search_blog_item border-b border-[#E4E5E6] py-6\">\n <div className=\"ipc_search_blog_item_content laptop:flex-row-reverse laptop:gap-8 desktop:gap-16 flex flex-col gap-4\">\n <div className=\"laptop:flex-[440] desktop:flex-[540] desktop:h-[280px] h-[240px]\">\n <Picture\n source={blog?.image?.url}\n className=\"size-full\"\n imgClassName=\"size-full object-cover\"\n alt={blog?.title}\n />\n </div>\n <div className=\"laptop:flex-[424] desktop:flex-[704] lg-desktop:flex-[1056] flex flex-col justify-center\">\n <Heading size={3} html={highlightSearchWord(blog?.title, searchValue)} />\n <Text\n html={highlightSearchWord(blog?.content, searchValue)}\n className=\"lg-desktop:text-[18px] desktop:text-[16px] mt-1 line-clamp-2 text-sm font-bold leading-[1.4]\"\n />\n <div className=\"desktop:mt-6 mt-4\">\n <Button as=\"a\" href={articleLink} variant=\"secondary\" size=\"lg\">\n {copyWriting?.learnMoreText || 'Learn More'}\n </Button>\n </div>\n </div>\n </div>\n </div>\n )\n}\n\n/**\n * \u641C\u7D22\u9875\u9762\n */\nconst SearchPageItem = ({ searchValue, page }: SearchPageItemProps) => {\n const { copyWriting, locale = 'us' } = useAiuiContext()\n const pageLink = useMemo(() => `${locale === 'us' ? '' : `/${locale}`}/${page?.handle}`, [page, locale])\n return (\n <div className=\"ipc_search_page_items border-b border-[#E4E5E6] py-6\">\n <Heading size={3} html={highlightSearchWord(page?.name, searchValue)} />\n <Text\n as=\"p\"\n html={highlightSearchWord(page?.bodySummary || '', searchValue)}\n className=\"lg-desktop:text-[18px] desktop:text-[16px] mt-1 text-sm font-bold leading-[1.4]\"\n />\n <Button as=\"a\" href={pageLink} variant=\"secondary\" size=\"lg\" className=\"desktop:mt-6 mt-4\">\n {copyWriting?.learnMoreText || 'Learn More'}\n </Button>\n </div>\n )\n}\n\n/**\n * \u641C\u7D22\u7ED3\u679C\u4E3A\u7A7A\n */\nconst SearchPageNoResult = ({ url, label }: { url: string; label: string }) => {\n return (\n <div className=\"flex flex-col items-center justify-center gap-4\">\n <Picture source={url} className=\"h-[180px] w-[240px]\" imgClassName=\"object-cover\" />\n <Text html={label} className=\"desktop:text-[18px] text-sm font-bold leading-[1.4]\" />\n </div>\n )\n}\n\n/**\n * \u641C\u7D22\u63A8\u8350\u5546\u54C1\n */\nconst SearchRecommendProducts = ({\n products,\n title,\n buildProps,\n onSecondaryButton,\n onPrimaryButton,\n}: SearchRecommendProductsProps) => {\n const { products: buildProducts } = buildProps || {}\n return (\n <div className=\"ipc_search_recommend_product tablet:pt-[80px] laptop:pt-[96px] desktop:pt-[112px] lg-desktop:pt-[128px] pt-[64px]\">\n <Heading size={4} weight=\"bold\" html={title} />\n <div className=\" tablet:grid-cols-3 desktop:grid-cols-4 desktop:gap-4 mt-6 grid grid-cols-2 gap-x-3 gap-y-4\">\n {products?.map((product: any, index: number) => {\n const buildProduct = buildProducts?.find((buildProduct: any) => buildProduct.handle === product.handle)\n const variant = buildProduct?.variants?.find((variant: any) => variant.sku === product.sku)\n return (\n <SearchProductItem\n product={buildProduct}\n variantData={variant}\n key={product.id + index}\n onSecondaryButton={() => onSecondaryButton?.()}\n onPrimaryButton={() => onPrimaryButton?.()}\n />\n )\n })}\n </div>\n </div>\n )\n}\n\n/**\n * \u641C\u7D22\u9875\u9762\n */\nconst SearchPage = ({\n searchResult,\n searchValue,\n data,\n onSecondaryButton,\n onPrimaryButton,\n // loadMore,\n onChangeSort,\n loading,\n searchResultCount,\n onChangeTab,\n buildProps,\n}: SearchPageProps) => {\n const [currentTab, setCurrentTab] = useState<any>(data?.tabs?.[0])\n const isInsertAdvertising = useRef(false)\n const [isOpenSort, setIsOpenSort] = useState(false)\n const [currentSortKey, setCurrentSortKey] = useState<any>({\n [SearchPageTabType.PRODUCTS]: data?.tabs?.find((tab: any) => tab.tabType === SearchPageTabType.PRODUCTS)\n ?.sortKeys?.[0],\n [SearchPageTabType.BLOGS]: data?.tabs?.find((tab: any) => tab.tabType === SearchPageTabType.BLOGS)?.sortKeys?.[0],\n [SearchPageTabType.PAGES]: data?.tabs?.find((tab: any) => tab.tabType === SearchPageTabType.PAGES)?.sortKeys?.[0],\n })\n\n const searchProductsResult = useMemo(() => {\n return searchResult?.products || []\n }, [searchResult])\n\n const searchBlogsResult = useMemo(() => {\n return searchResult?.blogs || []\n }, [searchResult])\n\n const searchPagesResult = useMemo(() => {\n return searchResult?.pages || []\n }, [searchResult])\n\n const totalCount = useMemo(() => {\n return Object.values(searchResultCount || {}).reduce((acc, curr) => acc + curr, 0)\n }, [searchResultCount])\n\n const searchProductsResultWithAdvertising = useMemo(() => {\n const advertisingData = {\n advertisingBgImg: currentTab?.advertisingBgImg,\n advertisingTitle: currentTab?.advertisingTitle,\n advertisingSubtitle: currentTab?.advertisingSubtitle,\n advertisingLink: currentTab?.advertisingLink,\n type: 'advertising',\n }\n if (!isInsertAdvertising.current && !!searchProductsResult?.length) {\n if (searchProductsResult?.length >= 8) {\n searchProductsResult?.splice(7, 0, advertisingData)\n isInsertAdvertising.current = true\n } else {\n searchProductsResult?.push(advertisingData)\n isInsertAdvertising.current = true\n }\n }\n return searchProductsResult\n }, [currentTab, searchProductsResult])\n\n return (\n <div className=\"ipc_search_page desktop:py-[128px] tablet:px-8 laptop:px-16 desktop:px-16 lg-desktop:px-[calc(50%-832px)] px-4 py-16\">\n <Heading\n size={4}\n weight=\"bold\"\n html={data?.title?.replace('$totalCount', totalCount?.toString())?.replace('$inputValue', `\"${searchValue}\"`)}\n />\n <div className=\"mt-6\">\n <Tabs className=\"ipc_search_page_tabs\" defaultValue=\"products\">\n <div className=\"desktop:flex desktop:items-center desktop:flex-row desktop:gap-6 desktop:justify-between\">\n <TabsList>\n {data?.tabs?.map((tab: any) => (\n <TabsTrigger\n onClick={() => {\n setCurrentTab(tab)\n onChangeTab?.(tab?.tabType)\n }}\n key={tab.id}\n defaultValue=\"products\"\n value={tab.tabType}\n >\n {tab.label} ({searchResultCount?.[tab.tabType as keyof typeof searchResultCount]})\n </TabsTrigger>\n ))}\n </TabsList>\n <DropdownMenu onOpenChange={setIsOpenSort}>\n <DropdownMenuTrigger asChild>\n <button className=\"desktop:mt-0 mt-6 flex items-center text-base font-bold leading-[1.2]\">\n {currentTab?.sortLabel} {currentSortKey?.[currentTab?.tabType]?.label}{' '}\n <DownArrow\n className={cn('inline-block size-4', {\n 'rotate-180': isOpenSort,\n })}\n />\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"start\" sideOffset={8} className=\"rounded-none bg-white !px-0 py-2\">\n {currentTab?.sortKeys?.map((sortKey: SortKey) => {\n return (\n <DropdownMenuItem\n className={cn(\n 'laptop:px-4 laptop:text-base px-3 py-4 text-sm font-bold hover:bg-[#EAEAEC] hover:text-current',\n {\n 'bg-[#EAEAEC]': currentSortKey?.[currentTab?.tabType]?.value === sortKey.value,\n }\n )}\n onClick={() => {\n isInsertAdvertising.current = false\n onChangeSort?.(currentTab?.tabType, sortKey)\n setCurrentSortKey((prev: any) => ({\n ...prev,\n [currentTab?.tabType]: sortKey,\n }))\n }}\n key={sortKey.id}\n >\n {sortKey.label}\n </DropdownMenuItem>\n )\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n <TabsContent value={SearchPageTabType.PRODUCTS} className=\"ipc_search_page_tabs_products_content mt-6\">\n <div className=\"tablet:grid-cols-3 desktop:grid-cols-4 desktop:gap-4 grid grid-cols-2 gap-x-3 gap-y-4\">\n {searchProductsResultWithAdvertising?.map((product: any, index: number) => (\n <SearchProductItem\n searchValue={searchValue}\n key={product.id + index}\n product={product}\n onSecondaryButton={() => onSecondaryButton?.(product)}\n onPrimaryButton={() => onPrimaryButton?.(product)}\n />\n ))}\n </div>\n {loading ? (\n <div className=\"mt-6 flex w-full justify-center\">\n <LoadingDots />\n </div>\n ) : (\n !searchProductsResult?.length && (\n <>\n <SearchPageNoResult url={data?.noResultImage?.url} label={data?.noResultLabel} />\n <SearchRecommendProducts\n products={data?.recommendProducts || []}\n buildProps={buildProps}\n title={data?.recommendProductsTitle}\n />\n </>\n )\n )}\n </TabsContent>\n <TabsContent value={SearchPageTabType.BLOGS} className=\"ipc_search_page_tabs_blogs_content\">\n <div>\n {searchBlogsResult?.map((blog: any) => (\n <SearchBlogItem key={blog.id} blog={blog} searchValue={searchValue} />\n ))}\n {loading ? (\n <div className=\"mt-6 flex justify-center\">\n <LoadingDots />\n </div>\n ) : (\n !searchBlogsResult?.length && (\n <>\n <SearchPageNoResult url={data?.noResultImage?.url} label={data?.noResultLabel} />\n <SearchRecommendProducts\n products={data?.recommendProducts || []}\n buildProps={buildProps}\n title={data?.recommendProductsTitle}\n />\n </>\n )\n )}\n </div>\n </TabsContent>\n <TabsContent value={SearchPageTabType.PAGES} className=\"ipc_search_page_tabs_pages_content\">\n <div>\n {searchPagesResult?.map((page: any, index: number) => (\n <SearchPageItem key={page.global_id + index} page={page} searchValue={searchValue} />\n ))}\n </div>\n {loading ? (\n <div className=\"mt-6 flex justify-center\">\n <LoadingDots />\n </div>\n ) : (\n !searchPagesResult?.length && (\n <>\n <SearchPageNoResult url={data?.noResultImage?.url} label={data?.noResultLabel} />\n <SearchRecommendProducts\n products={data?.recommendProducts || []}\n buildProps={buildProps}\n title={data?.recommendProductsTitle}\n />\n </>\n )\n )}\n </TabsContent>\n </Tabs>\n </div>\n </div>\n )\n}\n\nexport default SearchPage\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAqEU,IAAAI,EAAA,6BArEVC,EAgBO,qCACPC,EAA0B,8CAC1BC,EAAqD,iBACrDC,EAAgD,kCAChDC,EAA+B,oCAC/BC,EAAmC,2CASnCC,EAAkC,sBAKlC,MAAMC,EAAoB,CAAC,CACzB,QAAAC,EACA,kBAAAC,EACA,gBAAAC,EACA,YAAAC,EACA,YAAAC,CACF,IAA8B,CAC5B,MAAMC,KAAU,WAAQ,IAAMD,GAAeJ,GAAS,WAAW,CAAC,EAAG,CAACA,EAASI,CAAW,CAAC,EACrF,CAAE,OAAAE,EAAS,KAAM,YAAAC,CAAY,KAAI,kBAAe,EAEhDC,KAAc,WAAQ,IACnB,aAAaR,GAAS,MAAM,eAAY,UAAOK,GAAS,EAAY,CAAC,GAC3E,CAACL,GAAS,OAAQK,GAAS,EAAE,CAAC,EAE3BI,EAASJ,GAAS,UAAU,CAAC,EAE7B,CAAE,MAAAK,EAAO,UAAAC,CAAU,KAAI,sBAAmB,CAC9C,OAAQL,EACR,OAAQG,EAASA,EAAO,qBAAuBJ,GAAS,MACxD,WAAYI,EAASJ,GAAS,MAAQ,EACtC,aAAcL,GAAS,OAAO,cAAgB,KAChD,CAAC,EAEKY,KAAO,WAAQ,IACZZ,GAAS,MACZ,SAAUa,GAAcA,GAAM,aAAa,OAAO,CAAC,GACnD,MAAOA,GAAcA,GAAM,UAAU,SAAU,EAAE,CAAC,GAClD,QAAQ,EAAG,CAAC,EACf,CAACb,GAAS,IAAI,CAAC,EAElB,SACE,OAAC,OAAI,UAAU,kGACZ,SAAAA,GAAS,OAAS,iBACjB,QAAC,QAAK,KAAMA,GAAS,gBAAiB,UAAU,SAC9C,oBAAC,WACC,OAAQA,GAAS,kBAAkB,IACnC,UAAU,YACV,aAAa,yBACf,KACA,QAAC,OAAI,UAAU,
|
|
4
|
+
"sourcesContent": ["import {\n Heading,\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n Text,\n Picture,\n Link,\n Button,\n DropdownMenu,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n LoadingDots,\n} from '../../components/index.js'\nimport { DownArrow } from '../HeaderNavigation/icons/index.js'\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport { cn, atobID, highlightSearchWord } from '../../helpers/utils.js'\nimport { useAiuiContext } from '../AiuiProvider/index.js'\nimport { formatVariantPrice } from '../ShelfDisplay/shelfDisplay.js'\nimport type {\n SearchPageProps,\n SortKey,\n SearchProductItemProps,\n SearchBlogItemProps,\n SearchPageItemProps,\n SearchRecommendProductsProps,\n} from './types'\nimport { SearchPageTabType } from './types.js'\n\n/**\n * \u641C\u7D22\u5546\u54C1\n */\nconst SearchProductItem = ({\n product,\n onSecondaryButton,\n onPrimaryButton,\n searchValue,\n variantData,\n}: SearchProductItemProps) => {\n const variant = useMemo(() => variantData || product?.variants?.[0], [product, variantData])\n const { locale = 'us', copyWriting } = useAiuiContext()\n\n const listingLink = useMemo(() => {\n return `/products/${product?.handle}?variant=${atobID(variant?.id as string)}`\n }, [product?.handle, variant?.id])\n\n const coupon = variant?.coupons?.[0]\n\n const { price, basePrice } = formatVariantPrice({\n locale: locale,\n amount: coupon ? coupon.variant_price4wscode : variant?.price,\n baseAmount: coupon ? variant?.price : 0,\n currencyCode: product?.price?.currencyCode || 'USD',\n })\n\n const tags = useMemo(() => {\n return product?.tags\n ?.filter?.((item: any) => item?.startsWith?.('CLtag'))\n ?.map?.((item: any) => item?.replace?.('CLtag:', ''))\n ?.slice?.(0, 2)\n }, [product?.tags])\n\n return (\n <div className=\"ipc_search_product_item lg-desktop:h-[480px] desktop:h-[384px] laptop:h-[360px] relative h-auto\">\n {product?.type === 'advertising' ? (\n <Link href={product?.advertisingLink} className=\"h-full\">\n <Picture\n source={product?.advertisingBgImg?.url}\n className=\"size-full\"\n imgClassName=\"size-full object-cover\"\n />\n <div className=\"desktop:p-6 absolute inset-0 z-[2] p-4 [&_img]:hover:scale-110 [&_img]:hover:transition-all [&_img]:hover:duration-500\">\n <Text html={product?.advertisingTitle} className=\"desktop:text-[18px] text-sm font-bold text-white\" />\n <Heading\n size={3}\n html={product?.advertisingSubtitle}\n className=\"laptop:line-clamp-3 mt-2 line-clamp-4 font-bold text-white\"\n />\n </div>\n </Link>\n ) : (\n <a\n href={listingLink}\n className=\" tablet:hover:bg-info-white desktop:p-6 desktop:pt-4 tablet:p-4 flex h-full flex-col bg-[#EAEAEC] px-2 py-4 no-underline duration-300\"\n >\n <div className=\"ipc_search_product_item_image\">\n <Picture\n className=\"lg-desktop:size-[196px] mx-auto size-[138px]\"\n source={`${variant?.image?.url || product?.images?.[0]?.url}}`}\n alt={product.title}\n imgClassName=\"object-cover size-full\"\n />\n </div>\n <div className=\"ipc_search_product_item_content desktop:mt-2 lg-desktop:mt-3 desktop:gap-6 mt-1 flex flex-1 flex-col justify-between gap-4\">\n <div className=\"flex-1\">\n <div className=\"lg-desktop:h-[28px] mb-2 flex h-[24px] gap-2\">\n {tags?.map((tag: string, index: number) => (\n <Text\n key={index}\n as=\"p\"\n html={tag}\n className=\"text-brand-0 lg-desktop:px-2 lg-desktop:!leading-[28px] h-full rounded-full border-[1.6px] border-[#00BEFA] px-[6px] text-sm font-bold !leading-[24px]\"\n />\n ))}\n </div>\n <Text\n className=\"desktop:text-2xl tablet:line-clamp-2 line-clamp-3 text-xl font-bold !leading-[1.2]\"\n weight=\"bold\"\n html={highlightSearchWord(product?.title || '', searchValue || '')}\n />\n <Text\n as=\"p\"\n className=\"lg-desktop:text-[18px] tablet:line-clamp-1 mt-1 line-clamp-2 text-sm font-bold\"\n html={highlightSearchWord(product.description, searchValue || '')}\n />\n </div>\n <div>\n <div className=\"mb-2 flex items-center\">\n {!variant?.availableForSale ? (\n <div className=\"text-info-primary tablet:text-xl lg-desktop:text-2xl text-[18px] font-bold\">\n {copyWriting?.soldOutText || 'Sold Out'}\n </div>\n ) : (\n <>\n <div className=\"final-price text-info-primary tablet:text-xl lg-desktop:text-2xl text-[18px] font-bold\">\n {variant?.availableForSale ? price || '' : ''}\n </div>\n <div className=\"origin-price tablet:text-xl lg-desktop:text-2xl text-info-secondary ml-1 text-[18px] font-bold line-through\">\n {variant?.availableForSale ? basePrice || '' : ''}\n </div>\n </>\n )}\n </div>\n <div\n className={cn(\n 'ipc_search_product_item_button_group',\n 'lg-desktop:gap-3 laptop:flex-row flex flex-col items-center gap-2'\n )}\n >\n {copyWriting?.learnMoreText && (\n <Button\n variant=\"secondary\"\n className=\"laptop:w-auto w-full\"\n size=\"lg\"\n disabled={!variant?.availableForSale}\n onClick={() => onSecondaryButton?.()}\n >\n {copyWriting?.learnMoreText}\n </Button>\n )}\n {copyWriting?.shopNowText && (\n <Button\n variant=\"primary\"\n className=\"laptop:w-auto w-full\"\n size=\"lg\"\n disabled={!variant?.availableForSale}\n onClick={() => onPrimaryButton?.()}\n >\n {copyWriting?.shopNowText}\n </Button>\n )}\n </div>\n </div>\n </div>\n </a>\n )}\n </div>\n )\n}\n\n/**\n * \u641C\u7D22\u6587\u7AE0\n */\nconst SearchBlogItem = ({ blog, searchValue }: SearchBlogItemProps) => {\n const { copyWriting } = useAiuiContext()\n\n const articleLink = useMemo(() => `blogs/${blog?.handle}/${blog?.handle.replace('storefront-', '')}`, [blog])\n\n return (\n <div className=\"ipc_search_blog_item border-b border-[#E4E5E6] py-6\">\n <div className=\"ipc_search_blog_item_content laptop:flex-row-reverse laptop:gap-8 desktop:gap-16 flex flex-col gap-4\">\n <div className=\"laptop:flex-[440] desktop:flex-[540] desktop:h-[280px] h-[240px]\">\n <Picture\n source={blog?.image?.url}\n className=\"size-full\"\n imgClassName=\"size-full object-cover\"\n alt={blog?.title}\n />\n </div>\n <div className=\"laptop:flex-[424] desktop:flex-[704] lg-desktop:flex-[1056] flex flex-col justify-center\">\n <Heading size={3} html={highlightSearchWord(blog?.title, searchValue)} />\n <Text\n html={highlightSearchWord(blog?.content, searchValue)}\n className=\"lg-desktop:text-[18px] desktop:text-[16px] mt-1 line-clamp-2 text-sm font-bold leading-[1.4]\"\n />\n <div className=\"desktop:mt-6 mt-4\">\n <Button as=\"a\" href={articleLink} variant=\"secondary\" size=\"lg\">\n {copyWriting?.learnMoreText || 'Learn More'}\n </Button>\n </div>\n </div>\n </div>\n </div>\n )\n}\n\n/**\n * \u641C\u7D22\u9875\u9762\n */\nconst SearchPageItem = ({ searchValue, page }: SearchPageItemProps) => {\n const { copyWriting, locale = 'us' } = useAiuiContext()\n const pageLink = useMemo(() => `${locale === 'us' ? '' : `/${locale}`}/${page?.handle}`, [page, locale])\n return (\n <div className=\"ipc_search_page_items border-b border-[#E4E5E6] py-6\">\n <Heading size={3} html={highlightSearchWord(page?.name, searchValue)} />\n <Text\n as=\"p\"\n html={highlightSearchWord(page?.bodySummary || '', searchValue)}\n className=\"lg-desktop:text-[18px] desktop:text-[16px] mt-1 text-sm font-bold leading-[1.4]\"\n />\n <Button as=\"a\" href={pageLink} variant=\"secondary\" size=\"lg\" className=\"desktop:mt-6 mt-4\">\n {copyWriting?.learnMoreText || 'Learn More'}\n </Button>\n </div>\n )\n}\n\n/**\n * \u641C\u7D22\u7ED3\u679C\u4E3A\u7A7A\n */\nconst SearchPageNoResult = ({ url, label }: { url: string; label: string }) => {\n return (\n <div className=\"flex flex-col items-center justify-center gap-4\">\n <Picture source={url} className=\"h-[180px] w-[240px]\" imgClassName=\"object-cover\" />\n <Text html={label} className=\"desktop:text-[18px] text-sm font-bold leading-[1.4]\" />\n </div>\n )\n}\n\n/**\n * \u641C\u7D22\u63A8\u8350\u5546\u54C1\n */\nconst SearchRecommendProducts = ({\n products,\n title,\n buildProps,\n onSecondaryButton,\n onPrimaryButton,\n}: SearchRecommendProductsProps) => {\n const { products: buildProducts } = buildProps || {}\n return (\n <div className=\"ipc_search_recommend_product tablet:pt-[80px] laptop:pt-[96px] desktop:pt-[112px] lg-desktop:pt-[128px] pt-[64px]\">\n <Heading size={4} weight=\"bold\" html={title} />\n <div className=\" tablet:grid-cols-3 desktop:grid-cols-4 desktop:gap-4 mt-6 grid grid-cols-2 gap-x-3 gap-y-4\">\n {products?.map((product: any, index: number) => {\n const buildProduct = buildProducts?.find((buildProduct: any) => buildProduct.handle === product.handle)\n const variant = buildProduct?.variants?.find((variant: any) => variant.sku === product.sku)\n return (\n <SearchProductItem\n product={buildProduct}\n variantData={variant}\n key={product.id + index}\n onSecondaryButton={() => onSecondaryButton?.()}\n onPrimaryButton={() => onPrimaryButton?.()}\n />\n )\n })}\n </div>\n </div>\n )\n}\n\n/**\n * \u641C\u7D22\u9875\u9762\n */\nconst SearchPage = ({\n searchResult,\n searchValue,\n data,\n onSecondaryButton,\n onPrimaryButton,\n // loadMore,\n onChangeSort,\n loading,\n searchResultCount,\n onChangeTab,\n buildProps,\n}: SearchPageProps) => {\n const [currentTab, setCurrentTab] = useState<any>(data?.tabs?.[0])\n const isInsertAdvertising = useRef(false)\n const [isOpenSort, setIsOpenSort] = useState(false)\n const [currentSortKey, setCurrentSortKey] = useState<any>({\n [SearchPageTabType.PRODUCTS]: data?.tabs?.find((tab: any) => tab.tabType === SearchPageTabType.PRODUCTS)\n ?.sortKeys?.[0],\n [SearchPageTabType.BLOGS]: data?.tabs?.find((tab: any) => tab.tabType === SearchPageTabType.BLOGS)?.sortKeys?.[0],\n [SearchPageTabType.PAGES]: data?.tabs?.find((tab: any) => tab.tabType === SearchPageTabType.PAGES)?.sortKeys?.[0],\n })\n\n const searchProductsResult = useMemo(() => {\n return searchResult?.products || []\n }, [searchResult])\n\n const searchBlogsResult = useMemo(() => {\n return searchResult?.blogs || []\n }, [searchResult])\n\n const searchPagesResult = useMemo(() => {\n return searchResult?.pages || []\n }, [searchResult])\n\n const totalCount = useMemo(() => {\n return Object.values(searchResultCount || {}).reduce((acc, curr) => acc + curr, 0)\n }, [searchResultCount])\n\n const searchProductsResultWithAdvertising = useMemo(() => {\n const advertisingData = {\n advertisingBgImg: currentTab?.advertisingBgImg,\n advertisingTitle: currentTab?.advertisingTitle,\n advertisingSubtitle: currentTab?.advertisingSubtitle,\n advertisingLink: currentTab?.advertisingLink,\n type: 'advertising',\n }\n if (!isInsertAdvertising.current && !!searchProductsResult?.length) {\n if (searchProductsResult?.length >= 8) {\n searchProductsResult?.splice(7, 0, advertisingData)\n isInsertAdvertising.current = true\n } else {\n searchProductsResult?.push(advertisingData)\n isInsertAdvertising.current = true\n }\n }\n return searchProductsResult\n }, [currentTab, searchProductsResult])\n\n return (\n <div className=\"ipc_search_page desktop:py-[128px] tablet:px-8 laptop:px-16 desktop:px-16 lg-desktop:px-[calc(50%-832px)] px-4 py-16\">\n <Heading\n size={4}\n weight=\"bold\"\n html={data?.title?.replace('$totalCount', totalCount?.toString())?.replace('$inputValue', `\"${searchValue}\"`)}\n />\n <div className=\"mt-6\">\n <Tabs className=\"ipc_search_page_tabs\" defaultValue=\"products\">\n <div className=\"desktop:flex desktop:items-center desktop:flex-row desktop:gap-6 desktop:justify-between\">\n <TabsList>\n {data?.tabs?.map((tab: any) => (\n <TabsTrigger\n onClick={() => {\n setCurrentTab(tab)\n onChangeTab?.(tab?.tabType)\n }}\n key={tab.id}\n defaultValue=\"products\"\n value={tab.tabType}\n >\n {tab.label} ({searchResultCount?.[tab.tabType as keyof typeof searchResultCount]})\n </TabsTrigger>\n ))}\n </TabsList>\n <DropdownMenu onOpenChange={setIsOpenSort}>\n <DropdownMenuTrigger asChild>\n <button className=\"desktop:mt-0 mt-6 flex items-center text-base font-bold leading-[1.2]\">\n {currentTab?.sortLabel} {currentSortKey?.[currentTab?.tabType]?.label}{' '}\n <DownArrow\n className={cn('inline-block size-4', {\n 'rotate-180': isOpenSort,\n })}\n />\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"start\" sideOffset={8} className=\"rounded-none bg-white !px-0 py-2\">\n {currentTab?.sortKeys?.map((sortKey: SortKey) => {\n return (\n <DropdownMenuItem\n className={cn(\n 'laptop:px-4 laptop:text-base px-3 py-4 text-sm font-bold hover:bg-[#EAEAEC] hover:text-current',\n {\n 'bg-[#EAEAEC]': currentSortKey?.[currentTab?.tabType]?.value === sortKey.value,\n }\n )}\n onClick={() => {\n isInsertAdvertising.current = false\n onChangeSort?.(currentTab?.tabType, sortKey)\n setCurrentSortKey((prev: any) => ({\n ...prev,\n [currentTab?.tabType]: sortKey,\n }))\n }}\n key={sortKey.id}\n >\n {sortKey.label}\n </DropdownMenuItem>\n )\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n <TabsContent value={SearchPageTabType.PRODUCTS} className=\"ipc_search_page_tabs_products_content mt-6\">\n <div className=\"tablet:grid-cols-3 desktop:grid-cols-4 desktop:gap-4 grid grid-cols-2 gap-x-3 gap-y-4\">\n {searchProductsResultWithAdvertising?.map((product: any, index: number) => (\n <SearchProductItem\n searchValue={searchValue}\n key={product.id + index}\n product={product}\n onSecondaryButton={() => onSecondaryButton?.(product)}\n onPrimaryButton={() => onPrimaryButton?.(product)}\n />\n ))}\n </div>\n {loading ? (\n <div className=\"mt-6 flex w-full justify-center\">\n <LoadingDots />\n </div>\n ) : (\n !searchProductsResult?.length && (\n <>\n <SearchPageNoResult url={data?.noResultImage?.url} label={data?.noResultLabel} />\n <SearchRecommendProducts\n products={data?.recommendProducts || []}\n buildProps={buildProps}\n title={data?.recommendProductsTitle}\n />\n </>\n )\n )}\n </TabsContent>\n <TabsContent value={SearchPageTabType.BLOGS} className=\"ipc_search_page_tabs_blogs_content\">\n <div>\n {searchBlogsResult?.map((blog: any) => (\n <SearchBlogItem key={blog.id} blog={blog} searchValue={searchValue} />\n ))}\n {loading ? (\n <div className=\"mt-6 flex justify-center\">\n <LoadingDots />\n </div>\n ) : (\n !searchBlogsResult?.length && (\n <>\n <SearchPageNoResult url={data?.noResultImage?.url} label={data?.noResultLabel} />\n <SearchRecommendProducts\n products={data?.recommendProducts || []}\n buildProps={buildProps}\n title={data?.recommendProductsTitle}\n />\n </>\n )\n )}\n </div>\n </TabsContent>\n <TabsContent value={SearchPageTabType.PAGES} className=\"ipc_search_page_tabs_pages_content\">\n <div>\n {searchPagesResult?.map((page: any, index: number) => (\n <SearchPageItem key={page.global_id + index} page={page} searchValue={searchValue} />\n ))}\n </div>\n {loading ? (\n <div className=\"mt-6 flex justify-center\">\n <LoadingDots />\n </div>\n ) : (\n !searchPagesResult?.length && (\n <>\n <SearchPageNoResult url={data?.noResultImage?.url} label={data?.noResultLabel} />\n <SearchRecommendProducts\n products={data?.recommendProducts || []}\n buildProps={buildProps}\n title={data?.recommendProductsTitle}\n />\n </>\n )\n )}\n </TabsContent>\n </Tabs>\n </div>\n </div>\n )\n}\n\nexport default SearchPage\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAqEU,IAAAI,EAAA,6BArEVC,EAgBO,qCACPC,EAA0B,8CAC1BC,EAAqD,iBACrDC,EAAgD,kCAChDC,EAA+B,oCAC/BC,EAAmC,2CASnCC,EAAkC,sBAKlC,MAAMC,EAAoB,CAAC,CACzB,QAAAC,EACA,kBAAAC,EACA,gBAAAC,EACA,YAAAC,EACA,YAAAC,CACF,IAA8B,CAC5B,MAAMC,KAAU,WAAQ,IAAMD,GAAeJ,GAAS,WAAW,CAAC,EAAG,CAACA,EAASI,CAAW,CAAC,EACrF,CAAE,OAAAE,EAAS,KAAM,YAAAC,CAAY,KAAI,kBAAe,EAEhDC,KAAc,WAAQ,IACnB,aAAaR,GAAS,MAAM,eAAY,UAAOK,GAAS,EAAY,CAAC,GAC3E,CAACL,GAAS,OAAQK,GAAS,EAAE,CAAC,EAE3BI,EAASJ,GAAS,UAAU,CAAC,EAE7B,CAAE,MAAAK,EAAO,UAAAC,CAAU,KAAI,sBAAmB,CAC9C,OAAQL,EACR,OAAQG,EAASA,EAAO,qBAAuBJ,GAAS,MACxD,WAAYI,EAASJ,GAAS,MAAQ,EACtC,aAAcL,GAAS,OAAO,cAAgB,KAChD,CAAC,EAEKY,KAAO,WAAQ,IACZZ,GAAS,MACZ,SAAUa,GAAcA,GAAM,aAAa,OAAO,CAAC,GACnD,MAAOA,GAAcA,GAAM,UAAU,SAAU,EAAE,CAAC,GAClD,QAAQ,EAAG,CAAC,EACf,CAACb,GAAS,IAAI,CAAC,EAElB,SACE,OAAC,OAAI,UAAU,kGACZ,SAAAA,GAAS,OAAS,iBACjB,QAAC,QAAK,KAAMA,GAAS,gBAAiB,UAAU,SA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ACF,GAGN,GACF,EACF,GACF,CAEJ,EAEA,IAAO5C,EAAQ0C",
|
|
6
6
|
"names": ["SearchPage_exports", "__export", "SearchPage_default", "__toCommonJS", "import_jsx_runtime", "import_components", "import_icons", "import_react", "import_utils", "import_AiuiProvider", "import_shelfDisplay", "import_types", "SearchProductItem", "product", "onSecondaryButton", "onPrimaryButton", "searchValue", "variantData", "variant", "locale", "copyWriting", "listingLink", "coupon", "price", "basePrice", "tags", "item", "tag", "index", "SearchBlogItem", "blog", "articleLink", "SearchPageItem", "page", "pageLink", "SearchPageNoResult", "url", "label", "SearchRecommendProducts", "products", "title", "buildProps", "buildProducts", "buildProduct", "SearchPage", "searchResult", "data", "onChangeSort", "loading", "searchResultCount", "onChangeTab", "currentTab", "setCurrentTab", "isInsertAdvertising", "isOpenSort", "setIsOpenSort", "currentSortKey", "setCurrentSortKey", "tab", "searchProductsResult", "searchBlogsResult", "searchPagesResult", "totalCount", "acc", "curr", "searchProductsResultWithAdvertising", "advertisingData", "sortKey", "prev"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{Fragment as U,jsx as e,jsxs as l}from"react/jsx-runtime";import Le,{forwardRef as ee,useCallback as V,useEffect as B,useImperativeHandle as Pe,useMemo as L,useRef as j,useState as z}from"react";import{Picture as X,Text as g,Button as A,Container as te,Link as O,Heading as me,BrandStrip as Ee}from"../../components/index.js";import{withLayout as ze}from"../../shared/Styles.js";import{cn as k,atobID as He}from"../../helpers/utils.js";import Be,{useNavContext as K}from"./NavProvider.js";import{HeaderNavigationMenu as R,HeaderNavigationBlockType as I,HeaderNavigationActionBlockType as T}from"./types.js";import"react-responsive";import{debounce as Te}from"es-toolkit";import $e from"jump.js";import{useGSAP as ie}from"@gsap/react";import{gsap as se}from"gsap";import{WithSidebar as be,WithSupports as fe,WithMulticol as ve,WithGroupCategory as ge}from"./withCategory.js";import{Menu as Ae,Close as ye,User as Re,RightArrow as je,LeftArrow as Fe,DownArrow as ae,Polygon as _e}from"./icons/index.js";import Oe from"../NavigationSearch/index.js";const ce=ee((t,a)=>{const{data:{header:n}={},buildProps:s,event:u,profile:p,theme:b="light",isTop:c=!1,searchResult:h,onSearch:v,isSearching:r,keywords:D,onPrimaryNavClick:w,onSeriesProductClick:d,onSidebarNavClick:x,headerId:f,cartCount:y,menuData:i}=t,[m,S]=z(!1),[M,P]=z(!1),C=j(null),$=j(null),G=()=>{const N=document?.querySelector("body")?.offsetWidth||0;P(N<=1440)};B(()=>(G(),window.addEventListener("resize",G),()=>{window.removeEventListener("resize",G)}),[]),Pe(a,()=>$.current),B(()=>{$.current&&c&&$e($.current,{duration:0,offset:$.current?.getBoundingClientRect()?.bottom||0})},[c]),B(()=>{u&&(u.search=()=>S(!0))},[u]),ie(()=>{C?.current&&m&&se.fromTo(C.current,{height:0},{height:"auto",duration:.3})},[m]),B(()=>{document.documentElement.style.overflow=m?"hidden":"auto"},[m]);const W=L(()=>n?.bar?.actions?.find(N=>N?.blockType===T.Search)?.searchBar?.[0]||{},[n]);return e(Be,{buildProps:s,profile:p,isMobile:M,event:u,payloadData:n,onSidebarNavClick:x,onSeriesProductClick:d,cartCount:y,children:e("header",{id:f||"header","data-ui-component-id":"HeaderNavigation",className:"relative z-[100] bg-white",ref:$,children:l("div",{className:k("hover:bg-white hover:text-black",b==="light"?"text-black":"text-white",{}),children:[e(de,{data:n,className:"desktop:block hidden !bg-white",theme:b,onPrimaryNavClick:w}),e(pe,{menuData:i,data:n,className:"desktop:hidden block !bg-white",onPrimaryNavClick:w}),m&&l("div",{className:"absolute left-0 top-0 z-[60] flex w-full flex-col bg-black/70",style:{height:`calc(100dvh - ${$?.current?.getBoundingClientRect()?.top}px)`},role:"dialog","aria-modal":"true","aria-label":"Search",children:[e("div",{ref:C,className:k("overflow-y-auto",{}),children:e(Oe,{data:W,keywords:D,isSearching:r,searchResult:h,onSearch:N=>{v?.(N)},onClose:()=>{v?.(),S(!1)}})}),e("div",{className:"flex-1 bg-transparent",onClick:()=>S(!1),role:"button",tabIndex:0,"aria-label":"Close search",onKeyDown:N=>{(N.key==="Enter"||N.key===" "||N.key==="Escape")&&(N.preventDefault(),S(!1))}})]})]})})})}),de=ee((t,a)=>{const{data:n,onNavItemClick:s,className:u,theme:p,onPrimaryNavClick:b}=t,{event:c,profile:h}=K(),[v,r]=z(!1),D=L(()=>ge(n?.categories?.filter(o=>o?.pcShow)),[n]),[w,d]=z(null),[x,f]=z([]),y=j(null),[i,m]=z(!1),S=j(null),M=j(null),P=j(D.map(o=>Array(o?.length||0).fill(null)));B(()=>{D?.length&&f(D?.map((o,E)=>o?.map((H,F)=>({groupIndex:E,index:F,open:!1}))))},[D]);const C=L(()=>{let o=null;for(const E of x){for(const H of E)if(H.open){o=H;break}if(o)break}return o},[x]);B(()=>{document.documentElement.style.overflow=C?.open||i?"hidden":"auto"},[C?.open,i]);const $=(o,E,H)=>{if(m(!1),w?.components?.[0]?.blockType===I.Links)w?.components?.[0]?.url&&window.open(w?.components?.[0]?.url);else{const F=D?.flat()||[],J=F?.findIndex(_=>_?.id===D[E][H]?.id);o.stopPropagation(),s?.(),b?.(F[J],J),d(D[E][H]),f(_=>_.map(Me=>Me.map(Y=>Y.groupIndex===E&&Y.index===H?{...Y,open:!Y.open}:{...Y,open:!1})))}},G=(o,E,H)=>{o.key==="Enter"||o.key===" "?(o.preventDefault(),$(o,E,H)):o.key==="Escape"&&C?.groupIndex===E&&C?.index===H&&(o.preventDefault(),W())},W=()=>{f(o=>o.map(E=>E.map(H=>({...H,open:!1}))))},N=L(()=>{if(w)return w?.components?.[0]?.blockType},[w]),le=be(ue,w),q=ve(Ie,w),Se=fe(We,{categoriesItem:w,currentNavItemRef:P.current?.[C?.groupIndex||0]?.[C?.index||0]}),De=L(()=>{switch(N){case I.Sidebar:return e(le,{});case I.Supports:return e(Se,{});case I.Multicol:return e(q,{});default:return null}},[N,w]),re=L(()=>n?.bar?.actions?.filter(o=>o?.pcShow),[n]),Q=L(()=>re?.find(o=>o?.blockType===T.Profile),[re]),oe=V(()=>{m(o=>!o)},[]);return B(()=>{if(y?.current){const o=y.current;return o.addEventListener("click",oe),()=>{o.removeEventListener("click",oe)}}},[oe]),ie(()=>{C?.open&&se.fromTo(M?.current,{height:0},{height:"auto"})},[C?.open]),l(te,{className:k("relative h-[96px]",u),children:[l("div",{ref:S,onClick:W,className:"flex h-full flex-col justify-end gap-4",children:[l("div",{className:"flex items-center justify-between",children:[e(we,{}),e(ne,{ref:y,actions:re,activeStatus:i})]}),e("nav",{className:"flex justify-between",role:"navigation","aria-label":"Primary navigation",children:D?.map((o,E)=>e("div",{className:"flex gap-3",children:o?.map((H,F)=>{const J=C?.groupIndex===E&&C?.index===F;return e("div",{ref:_=>{P.current[E][F]=_},className:"group cursor-pointer",children:l("div",{className:"relative",children:[l("button",{className:"flex cursor-pointer items-center gap-1 border-0 bg-transparent pb-4",onClick:_=>$(_,E,F),onKeyDown:_=>G(_,E,F),"aria-expanded":J,"aria-haspopup":"true","aria-label":H.text,children:[e(g,{html:H.text,className:"text-sm font-bold leading-[1.4]"}),e(ae,{"aria-hidden":"true",className:k("size-4 opacity-0 transition-opacity duration-500 group-hover:opacity-100",{"rotate-180":J,"opacity-100":v&&J})})]}),e("div",{className:k("absolute bottom-0 left-0 h-[2px] w-0 transition-all duration-500",{"w-[calc(100%-20px)]":J},p==="dark"?"bg-white":"bg-[#080A0F]"),"aria-hidden":"true"})]})},H.id)})},`groupCategory-${E}`))})]}),l("div",{role:"menu","aria-hidden":!(C?.open&&w),className:k("absolute left-0 top-full z-[999] flex w-full flex-col overflow-hidden border-t border-b-[#E4E5E6] bg-black/70 text-black",{hidden:!(C?.open&&w)}),onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{height:`calc(100dvh - ${S?.current?.getBoundingClientRect()?.bottom}px)`},children:[e("div",{ref:M,className:k("relative z-50",{"overflow-hidden":N!==I.Supports}),children:De}),e("div",{className:"flex-1 bg-transparent",onClick:W,role:"button",tabIndex:0,"aria-label":"Close menu",onKeyDown:o=>{(o.key==="Enter"||o.key===" "||o.key==="Escape")&&(o.preventDefault(),W())}})]}),i&&l("div",{className:"absolute left-0 top-full z-[999] flex h-dvh w-full bg-black/70",role:"dialog","aria-modal":"true","aria-label":"User profile menu",children:[e("div",{className:"absolute w-[272px] bg-white p-4",style:{right:`calc(100% - ${y?.current?.getBoundingClientRect()?.right}px)`,top:"-36px"},children:h?.email?l(U,{children:[e(g,{html:h?.nick_name||Q?.welcome,className:"text-sm font-bold"}),e("div",{className:"mt-2 h-px bg-[#D9D9D9]","aria-hidden":"true"}),e("nav",{className:"mt-2",role:"navigation","aria-label":"Profile navigation",children:Q?.profiles?.map(o=>e(Z,{className:"py-2",label:o?.title,href:o?.url},o.id))})]}):l(U,{children:[e(_e,{className:"absolute -top-2 right-[46px] z-30 text-white","aria-hidden":"true"}),e(g,{html:Q?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),e("div",{className:"mt-2 flex flex-col gap-1",children:Q?.benefits?.map(o=>l("div",{className:"flex items-center gap-[6px]",children:[e(X,{source:o.benefitIcon?.url,className:"size-4",alt:o.benefit,width:16,height:16}),e(g,{html:o.benefit,className:"text-sm font-bold leading-[1.4]"})]},o.id))}),l("div",{className:"mt-4 flex items-center gap-2",children:[e(A,{variant:"secondary",size:"lg",onClick:()=>c?.join?.(),children:e(g,{html:Q?.primaryButton||"Join Now",className:"font-bold"})}),e(A,{variant:"primary",size:"lg",onClick:()=>c?.login?.(),children:e(g,{html:Q?.secondaryButton||"Log In",className:"font-bold"})})]})]})}),e("div",{className:"flex-1 bg-transparent",onClick:()=>m(!1),role:"button",tabIndex:0,"aria-label":"Close profile menu",onKeyDown:o=>{(o.key==="Enter"||o.key===" "||o.key==="Escape")&&(o.preventDefault(),m(!1))}})]})]})}),ue=Le.memo(({sidebarCategoriesMetadata:t,seriesMetadata:a})=>{const{buildProps:n,onSidebarNavClick:s}=K(),[u,p]=z([]),[b,c]=z(-1),h=j(null),v=V(()=>{const d=t?.subcategories;if(!d?.length)return;const x=d.findIndex(i=>!!i?.subSubCategories),f=d.findIndex(i=>!i?.subSubCategories),y=d.map((i,m)=>({index:m,open:x===m||f===m}));p(y)},[t]);B(()=>{v()},[v]);const r=L(()=>{const d=t?.subcategories?.[u?.find(f=>f.open)?.index||0],x=a?.find(f=>f?.label?.toLowerCase()===d?.label?.toLowerCase())||{};if(d?.collections){const f=n?.categories?.[d?.collections]||{};return{label:x?.label,isCollection:!0,banner:x?.banner,primary:x?.primary,series:[{products:f?.products}]}}else if(d?.subSubCategories){const f=d?.subSubCategories?.[b],y=a?.find(i=>i?.label?.toLowerCase()===f?.label?.toLowerCase())||{};if(f?.collections){const i=n?.categories?.[f?.collections]||{};return{label:y?.label,isCollection:!0,banner:y?.banner,primary:y?.primary,series:[{products:i?.products}]}}else return y}else return x},[t,u,b,a,n]),D=V((d,x)=>{x?.subSubCategories?.length>0?c(0):c(-1),p(f=>f.map((y,i)=>({...y,open:i===d?!y.open:!1})))},[]),w=(d,x)=>{p(f=>f.map(y=>y.index===d?{...y,open:!0}:{...y,open:!1})),c(x)};return l(te,{childClassName:"lg-desktop:gap-12 flex bg-white gap-8",children:[l("div",{className:"lg-desktop:basis-[356px] flex basis-[284px] flex-col gap-4 py-4",style:{userSelect:"none"},ref:h,children:[e("div",{className:"desktop:h-[416px] flex flex-col overflow-y-auto",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:t?.subcategories?.map((d,x)=>{const f=Array.isArray(d?.subSubCategories)&&d?.subSubCategories?.length>0,y=u?.find(i=>i.index===x)?.open;return l("div",{children:[l("button",{className:k("flex w-full cursor-pointer items-center justify-between border-0 bg-transparent text-left",{"bg-[#F5F5F7]":!f&&y}),onClick:()=>{D(x,d),s?.(d,x)},"aria-expanded":f?y:void 0,"aria-haspopup":f?"true":void 0,children:[e(g,{html:d.label,className:"p-4 text-sm font-bold leading-[1.4]"}),f&&e(ae,{"aria-hidden":"true",className:k("size-4",{"rotate-180":y})})]}),y&&e("div",{className:"flex flex-col",role:"menu",children:d.subSubCategories?.map((i,m)=>e("button",{onClick:()=>{w(x,m),s?.(i,m)},className:k("w-full cursor-pointer border-0 bg-transparent px-6 py-4 text-left hover:bg-[#F5F5F7]",{"bg-[#F5F5F7]":b===m}),role:"menuitem","aria-label":i.label,children:e(g,{html:i.label,className:"text-sm font-bold leading-[1.4] text-[#6D6D6F]"})},`subSubItem-${x}-${m}`))})]},`subcategoryItem-${x}`)})}),t&&e("div",{className:"flex",children:l("div",{className:"flex flex-col gap-4",children:[t?.primary&&e(A,{as:"a",href:`${t?.primary?.url}?ref=${t?.primary?.label}_shopall`,variant:"primary",size:"lg",className:"lg-desktop:text-base text-sm",children:t?.primary?.label}),t?.secondary&&e(A,{as:"a",href:t?.secondary?.url,variant:"link",size:"lg",className:"lg-desktop:text-base justify-start !p-0 text-sm",children:t?.secondary?.label})]})})]}),l("div",{className:"flex-1 py-4",children:[Reflect.ownKeys(r).length>0&&l("div",{className:"mb-4 flex items-center justify-between",children:[l("div",{className:"flex items-center gap-2",children:[e(g,{html:r?.label,className:"lg-desktop:text-2xl text-xl font-bold leading-[1.4]"}),r?.primary&&!r?.primary?.hide&&e(A,{as:"a",href:`${r?.primary?.url}?ref=${r?.label}_viewmore`,variant:"link",size:"lg",className:"lg-desktop:text-base justify-start !p-0 text-sm font-bold leading-[1.2] no-underline",children:r?.primary?.label})]}),e(O,{href:r?.guide?.url,className:"lg-desktop:text-base text-sm leading-[1.2] text-[#6D6D6F]",children:r?.guide?.label})]}),e("div",{className:"flex h-[426px] flex-col gap-4 overflow-y-auto",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:r?.series?.map((d,x)=>l("div",{children:[d.label&&e(g,{html:d.label,className:"mb-2 text-sm font-bold leading-[1.4] text-[#6D6D6F]"}),l("div",{className:"grid grid-cols-3 gap-4",children:[!!r?.banner&&e(O,{asChild:!r?.banner?.href,href:r?.banner?.href,children:l("div",{className:"relative [&_img]:hover:scale-110 [&_img]:hover:transition-all [&_img]:hover:duration-[600]",children:[e(X,{source:r?.banner?.imageUrl,className:"laptop:h-[120px] h-[114px]",imgClassName:"object-cover h-full"}),l("div",{className:"absolute inset-x-0 bottom-0 p-4",children:[e(me,{size:2,html:r?.banner?.title||"Buy in Guide",className:"font-bold text-white"}),e(g,{html:r?.banner?.desc||"20.000mAh",className:"text-sm font-bold text-white"})]})]})}),d.products?.map((f,y)=>e(he,{seriesLabel:r?.label,product:f,isCollection:r?.isCollection},`seriesProductItem-${y}`))]})]},`seriesItem-${x}`))})]})]})}),Ie=({multicolMetadata:t})=>{const a=j(null);return e("div",{ref:a,children:e(te,{childClassName:"bg-white",className:"h-full",children:e("div",{className:"flex gap-4 py-4",children:t?.map((n,s)=>e("div",{className:"w-1/4",children:e(xe,{item:n})},`multicolItem-${n?.label}-${s}`))})})})},We=({supportsMetadata:t,currentNavItemRef:a})=>{const n=j(null),[s,u]=z(null),[p,b]=z(0);B(()=>{if(n?.current){const h=n?.current?.getBoundingClientRect();b(h.height)}},[n]);const c=Te(()=>{if(a){const h=a.getBoundingClientRect();u(h)}},500);return B(()=>(c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}),[c]),B(()=>{if(a){const h=a.getBoundingClientRect();u(h)}},[a]),e("div",{className:"absolute top-0 h-full overflow-hidden bg-white transition-all duration-500",style:{right:`calc(100% - ${s?.right}px)`,height:p},children:e("div",{ref:n,className:"p-4",children:t?.map(h=>e("div",{className:"py-2",children:e(O,{href:h.url,className:"text-sm font-bold leading-[1.4] no-underline",children:h.label})},h.id))})})},he=({product:t,isCollection:a,position:n,seriesLabel:s})=>{const{buildProps:u,onSeriesProductClick:p}=K();let b=a?t:u?.products?.find(r=>r.handle===t.handle);const c=b?.variants?.find(r=>r.sku===t.sku)||b?.variants?.[0],h=L(()=>`/products/${b?.handle}?variant=${He(c?.id)}`,[b?.handle,c?.id]),v=L(()=>b?.tags?.filter?.(r=>r?.startsWith?.("CLtag"))?.map?.(r=>r?.replace?.("CLtag:",""))?.slice?.(0,2),[b?.tags]);return c?.availableForSale?e(O,{href:h,onClick:r=>{r.preventDefault(),window.open(h,"_self"),p?.(b,n||0,s)},className:"no-underline hover:text-current",children:l("div",{className:"flex shrink-0 items-center gap-4 bg-[#F5F5F7] px-4 py-3 duration-[600] [&_img]:hover:scale-110",children:[e("div",{className:"shrink-0",children:e(X,{source:`${c?.image?.url||t?.images?.[0]?.url}}`,width:90,height:90,className:"size-[96px]",imgClassName:"object-contain h-full"})}),l("div",{className:"relative",children:[e("div",{className:"flex gap-1",children:Array.isArray(v)&&v?.map((r,D)=>e(g,{as:"p",html:r,className:"text-brand-0 mb-1 inline-block h-[24px] whitespace-nowrap rounded-full border-[1.6px] border-[#00BEFA] px-[6px] text-sm font-bold !leading-[22px]"},D))}),e(g,{className:"lg-desktop:h-[44px] lg-desktop:text-base line-clamp-2 h-[40px] text-sm font-bold leading-[1.4]",html:b?.title||t?.name}),t?.desc&&e(g,{as:"p",html:t?.desc,className:"lg-desktop:text-sm mt-1 line-clamp-1 text-xs font-bold leading-[1.4] text-[#6D6D6F]"})]})]})}):null},xe=({item:t,allPicture:a})=>l(U,{children:[t?.columns&&l(U,{children:[e(g,{html:t.label,as:"div",className:"my-2 text-sm font-bold leading-[1.4] text-[#6D6D6F]"}),e("div",{className:"mt-2 flex flex-col",children:t.columns?.map(n=>l("div",{className:"flex items-center gap-1 py-2",children:[e(O,{href:`${n.url}?ref=navMenu`,asChild:!n.url,className:"text-sm font-bold leading-[1.4] no-underline",children:n.label}),n?.badge&&e(g,{as:"p",html:n?.badge||"badge",className:"text-brand-0 h-[24px] rounded-full border-[1.6px] border-[var(--brand-color-0)] px-[6px] text-sm font-bold !leading-[22px]"})]},n.label))})]}),t?.imageUrl&&e("div",{className:k("laptop:h-[280px] desktop:h-[224px] lg-desktop:h-[280px] tablet:max-w-[346px] laptop:max-w-[440px] desktop:w-full relative h-[240px] max-w-[358px] overflow-hidden",{"tablet:max-w-none laptop:max-w-none":a}),children:l(O,{href:`${t.url}?ref=navMenu`,asChild:!t.url,children:[e(X,{source:t.imageUrl,width:404,height:280,className:"size-full",imgClassName:"object-cover h-full hover:scale-105 transition-all duration-300"}),l("div",{className:"absolute bottom-4 left-4 z-10 flex flex-col justify-end no-underline",children:[e(g,{html:t.title,className:k("lg-desktop:text-2xl text-xl font-bold leading-[1.2] text-white",{"text-black":t?.theme==="dark"})}),t.subtitle&&e(g,{html:t.subtitle,className:k("text-sm font-bold leading-[1.4] text-white",{"text-black":t?.theme==="dark"})}),t?.primary?.label&&e(A,{as:"a",href:t?.primary?.url,variant:"link",size:"lg",className:k("mr-auto !p-0 text-sm font-bold leading-[1.4] text-white",{"text-black":t?.theme==="dark"}),children:t?.primary?.label||"more"})]})]})})]}),pe=ee(({data:t,menuData:a,className:n,onPrimaryNavClick:s},u)=>{const p=L(()=>ge(t?.categories?.filter(N=>N?.mobileShow)),[t]),{currentMenu:b,setCurrentMenu:c,subSubCategory:h}=K(),[v,r]=z(!1),[D,w]=z(0),[d,x]=z(null),f=j(null);B(()=>{if(f?.current&&v){const N=f?.current?.getBoundingClientRect();w(window?.innerHeight-(N?.bottom||0))}},[v]),ie(()=>{se.fromTo(f.current,{height:0},{height:D,duration:.3})},[D]),B(()=>{document.documentElement.style.overflow=v?"hidden":"auto"},[v]);const y=L(()=>d?.components?.[0]?.blockType,[d]),i=fe(Ge,{categoriesItem:d}),m=be(Ue,d),S=ve(Je,d),M=L(()=>{switch(y){case I.Sidebar:return e(m,{});case I.Supports:return e(i,{});case I.Multicol:return e(S,{});default:return null}},[y,d,i]),P=V(()=>{r(!1),w(0),c&&c(R.Primary)},[r,w,c]),C=L(()=>t?.bar?.actions?.filter(N=>N?.mobileShow&&N?.blockType!==T.Profile),[t]),$=L(()=>t?.bar?.actions?.find(N=>N?.mobileShow&&N?.blockType===T.Profile)||{},[t]),G=L(()=>{switch(b){case R.Primary:return e(qe,{actions:C,menuOpen:v,onMenuOpenClose:()=>{r(!1),w(0)},onMenuOpenClick:()=>r(!0)});case R.Secondary:return e(Ce,{title:d?.text,onMenuOpenClose:P,onMenuBackClick:()=>c?.(R.Primary)});case R.Third:return e(Ce,{title:h?.label,onMenuOpenClose:P,onMenuBackClick:()=>c?.(R.Secondary)});default:return null}},[v,b,c,d,C,h,P]),W=V((N,le)=>{const q=Array.isArray(p)?Array.isArray(p[N])?p[N][le]:{}:{};x(q),q?.components?.[0]?.blockType===I.Links?q?.components?.[0]?.url&&window.open(q?.components?.[0]?.url):c?.(R.Secondary)},[p,c]);return l(te,{className:k("relative h-[52px]",n),children:[G,v&&l("nav",{ref:f,className:"absolute left-0 top-full z-[999] w-full overflow-y-auto border-t border-[#E4E5E6] bg-white text-black",style:{height:D},role:"navigation","aria-label":"Mobile navigation menu",children:[b===R.Primary?e("div",{className:"pt-4",children:e(Ee,{data:a})}):null,b===R.Primary?e(Ke,{categories:p,onPrimaryMenuClick:W,onPrimaryNavClick:s,profileAction:$}):M]})]})}),Ke=({categories:t,onPrimaryMenuClick:a,profileAction:n,onPrimaryNavClick:s})=>l("div",{className:"flex h-full flex-col justify-between",children:[e("div",{className:"tablet:px-8 laptop:px-16 p-4",children:t?.map((u,p)=>l("div",{className:"",children:[e("div",{className:k("my-2 h-px w-full bg-[#E5E5E7]")}),u?.map((b,c)=>e(Z,{label:b.text,onClick:()=>{const v=(t?.flat()||[])?.findIndex(r=>r?.id===t[p][c]?.id);a(p,c),s?.(b,v)},icon:b.components?.[0]?.icon},b.id))]},`groupCategory-${p}`))}),e(Ve,{profileAction:n})]}),Ue=({sidebarCategoriesMetadata:t,seriesMetadata:a})=>{const{currentMenu:n,setCurrentMenu:s,subSubCategory:u,setSubSubCategory:p,setCurrentSeriesMetadata:b,currentSeriesMetadata:c,buildProps:h,onSidebarNavClick:v}=K(),[r,D]=z([]),[w,d]=z([]);B(()=>{t?.subcategories?.length&&D(t?.subcategories?.map((i,m)=>({index:m,open:!1})))},[t]),B(()=>{u?.subSubCategories?.length&&d(u?.subSubCategories?.map((i,m)=>({index:m,open:m===0})))},[u]);const x=V((i,m)=>{s&&s(R.Third),p?.(i);const S=a?.find(M=>m!==void 0?i?.subSubCategories?.[m]?.label?.toLowerCase()===M.label?.toLowerCase():i?.label?.toLowerCase()===M.label?.toLowerCase())||{};if(i?.collections){const M=h?.categories?.[i?.collections]||{};b?.({label:S?.label,isCollection:!0,banner:S?.banner,primary:S?.primary,series:[{products:M?.products}]})}else b?.(S)},[a,s,p,b,h?.categories]),f=L(()=>a?.find(i=>!!i?.guide)?.guide,[a]);return L(()=>{switch(n){case R.Secondary:return l("div",{className:"tablet:px-8 laptop:px-16 tablet:justify-start tablet:gap-16 flex h-full flex-col justify-between p-4",children:[e("div",{children:t?.subcategories?.map((i,m)=>e("div",{children:e(Z,{label:i?.label,active:r.find(S=>S.index===m)?.open,onClick:()=>{x(i),v?.(i,m)}})},`${i.label}-${m}`))}),l("div",{className:"tablet:items-start flex flex-col items-center gap-4",children:[t?.primary&&e(A,{as:"a",href:`${t?.primary?.url}?ref=${t?.primary?.label}_shopall`,variant:"primary",size:"lg",className:"tablet:w-auto w-full text-base",children:t?.primary?.label}),t?.secondary&&e(A,{as:"a",href:t?.secondary?.url,variant:"link",size:"lg",className:"tablet:w-auto tablet:px-0 w-full py-0 text-base",children:t?.secondary?.label})]})]});case R.Third:return l("div",{className:"tablet:px-8 laptop:px-16 p-4",children:[u?.subSubCategories?u?.subSubCategories?.map((i,m)=>{const S=a?.find(P=>P.label.toLowerCase()===i?.label?.toLowerCase())||{};let M={};if(i?.collections){const P=h?.categories?.[i?.collections]||{};M={label:S?.label,isCollection:!0,banner:S?.banner,primary:S?.primary,series:[{products:P?.products}]}}else M=S;return l("div",{children:[Reflect.ownKeys(i).length>0&&e(Ne,{matchSeriesMetadata:M,onSubSubCategoryItemClick:()=>{v?.(i,m),d(P=>P.map((C,$)=>({...C,open:$===m?!C.open:C.open})))},expanded:!!w?.find(P=>P.index===m)?.open}),w?.find(P=>P.index===m)?.open&&l(U,{children:[e(ke,{matchSeriesMetadata:M}),M?.primary&&e("div",{className:"my-4 text-center",children:e(A,{as:"a",href:M?.primary?.url,className:"text-base leading-[1.2] no-underline",variant:"secondary",size:"base",children:M?.primary?.label})})]})]},`${i.label}-${m}`)}):l(U,{children:[Reflect.ownKeys(c).length>0&&e(Ne,{matchSeriesMetadata:c}),e(ke,{matchSeriesMetadata:c}),c?.primary&&e("div",{className:"my-4 text-center ",children:e(A,{as:"a",href:`${c?.primary?.url}?ref=${c?.label}_viewmore`,variant:"secondary",size:"base",className:"text-base leading-[1.2] no-underline",children:c?.primary?.label})})]}),f&&e(O,{href:f?.url,children:e("div",{className:"mt-4",children:e(g,{html:f?.label,className:"text-sm font-bold leading-[1.2] text-[#6D6D6F]"})})})]});default:return null}},[n,t,a,r,w,u,c,h?.categories,f,x,v])},Ne=({matchSeriesMetadata:t,onSubSubCategoryItemClick:a,expanded:n})=>{const s=l(U,{children:[t?.label&&e(g,{html:t?.label,className:"text-sm font-bold leading-[1.4]"}),a&&e(ae,{"aria-hidden":"true",className:k("size-5",{"rotate-180":n})})]});return a?e("button",{className:"tablet:pt-0 flex w-full cursor-pointer items-center justify-between border-0 bg-transparent py-4 text-left",onClick:a,"aria-expanded":n,children:s}):e("div",{className:"tablet:pt-0 flex items-center justify-between py-4",children:s})},ke=({matchSeriesMetadata:t})=>e("div",{className:"laptop:gap-3 flex flex-col gap-2",children:!!t?.series?.length&&t?.series?.map((a,n)=>l("div",{children:[a.label&&e(g,{html:a.label,className:"mb-2 text-sm font-bold leading-[1.4] text-[#3D3D3F]"}),l("div",{className:"laptop:grid-cols-3 laptop:gap-4 tablet:grid tablet:grid-cols-2 tablet:gap-3 flex flex-col gap-2",children:[!!t?.banner&&e(O,{asChild:!t?.banner?.href,href:t?.banner?.href,children:l("div",{className:"relative [&_img]:hover:scale-110 [&_img]:hover:transition-all [&_img]:hover:duration-[600]",children:[e(X,{source:t?.banner?.imageUrl,className:"laptop:h-[120px] h-[114px]",imgClassName:"object-cover h-full"}),l("div",{className:"absolute inset-x-0 bottom-0 p-4",children:[e(me,{size:2,html:t?.banner?.title||"Buy in Guide",className:k("font-bold text-white",{"text-black":t?.banner?.theme==="dark"})}),e(g,{html:t?.banner?.desc||"20.000mAh",className:k("text-sm font-bold text-white",{"text-black":t?.banner?.theme==="dark"})})]})]})}),a.products?.map((s,u)=>e(he,{position:u,product:s,seriesLabel:t?.label,isCollection:t?.isCollection},`seriesProductItem-${n}-${u}`))]})]},`seriesItem-${n}`))}),Ge=({supportsMetadata:t})=>e("div",{className:"tablet:px-8 laptop:px-16 p-4",children:t?.map(a=>e(Z,{href:a.url,label:a.label,onClick:()=>{}},a.id))}),Je=({multicolMetadata:t})=>{const a=L(()=>!t?.some(n=>!!n.columns),[t]);return e("div",{className:k("tablet:py-4 tablet:px-8 laptop:px-16 tablet:gap-6 flex flex-col gap-4 p-4",{"tablet:grid tablet:grid-cols-2 tablet:gap-3 laptop:gap-4":a}),children:t?.map((n,s)=>e("div",{children:e(xe,{item:n,allPicture:a})},`multicolItem-${n?.label}-${s}`))})},Ve=({profileAction:t})=>{const[a,n]=z(!1),{profile:s,event:u}=K();return l("div",{className:k("tablet:px-8 laptop:px-16 bg-[#F5F5F7] px-4 py-6",{"p-4":a}),children:[l("button",{className:"flex w-full cursor-pointer items-center justify-between border-0 bg-transparent",onClick:()=>n(!a),"aria-expanded":a,"aria-label":s?.nick_name||t?.welcome,children:[l("div",{className:"flex items-center gap-[14px]",children:[e("div",{className:"flex size-[40px] shrink-0 items-center justify-center rounded-full bg-white",children:e(Re,{"aria-hidden":"true"})}),e(g,{html:s?.nick_name||t?.welcome,className:"text-base font-bold leading-[1.4]"})]}),!s?.email&&e(ae,{"aria-hidden":"true",className:k("laptop:size-4 size-5",{"rotate-180":a})})]}),s?.email&&e("nav",{className:"mt-4",role:"navigation","aria-label":"Profile menu",children:t?.profiles?.map(p=>e(Z,{label:p?.title,href:p?.url},p.id))}),a&&!s?.email&&l("div",{className:"mt-4",children:[e(g,{html:t?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),e("div",{className:"mt-2 flex flex-col gap-1",children:t?.benefits?.map(p=>l("div",{className:"flex items-center gap-[6px]",children:[e(X,{source:p.benefitIcon?.url,className:"size-4",alt:p.benefit,width:16,height:16}),e(g,{html:p.benefit,className:"text-sm font-bold leading-[1.4]"})]},p.id))})]}),!s?.email&&l("div",{className:"mt-4 flex items-center gap-3",children:[e(A,{className:"tablet:flex-none flex-1",variant:"secondary",size:"base",onClick:()=>u?.join?.(),children:e(g,{html:t?.primaryButton||"Join Now",className:"text-sm font-bold leading-[1.4]"})}),e(A,{className:"tablet:flex-none flex-1",variant:"primary",size:"base",onClick:()=>u?.login?.(),children:e(g,{html:t?.secondaryButton||"Log In",className:"text-sm font-bold leading-[1.4]"})})]})]})},qe=({menuOpen:t,onMenuOpenClose:a,onMenuOpenClick:n,actions:s})=>l("div",{className:"flex h-full items-center justify-between gap-4",children:[e(we,{}),l("div",{className:"desktop:gap-6 flex items-center gap-4",children:[e(ne,{actions:s}),t?e("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>a(),"aria-label":"Close menu","aria-expanded":"true",children:e(ye,{className:"size-5","aria-hidden":"true"})}):e("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>n(),"aria-label":"Open menu","aria-expanded":"false","aria-haspopup":"true",children:e(Ae,{className:"size-5","aria-hidden":"true"})})]})]}),we=()=>{const{payloadData:t,isMobile:a}=K();return e("a",{href:"/",className:"hover:text-brand-0 [&>svg]:w-full","aria-label":"Home",dangerouslySetInnerHTML:{__html:a?t?.bar?.mobileLogo:t?.bar?.desktopLogo}})},ne=ee(({actions:t,activeStatus:a=!1},n)=>{const{event:s,cartCount:u}=K(),[p,b]=z(null),c=v=>{switch(v){case T.Search:return"Search";case T.Cart:return`Shopping cart${u>0?` (${u} items)`:""}`;case T.Profile:return"User profile";case T.Livestream:return"Livestream";default:return"Action"}},h=V((v,r)=>{switch(b(r),v?.blockType){case T.Search:s?.search?.();break;case T.Cart:s?.cart?.();break;case T.Profile:s?.profile?.();break;case T.Livestream:s?.livestream?.();break;default:return()=>{}}},[s]);return e("div",{className:"desktop:gap-6 flex items-center gap-4",children:Array.isArray(t)&&t?.map((v,r)=>l("button",{className:"relative cursor-pointer border-0 bg-transparent p-0",ref:v.blockType===T.Profile?n:null,onClick:()=>h(v,r),"aria-label":c(v.blockType),"aria-pressed":a&&p===r,children:[e(g,{html:v.icon,className:k("size-5",{"text-brand-0":a&&p===r}),"aria-hidden":"true"}),v.blockType===T.Cart&&u>0&&e("div",{className:"bg-brand-0 absolute right-[-12px] top-[calc(100%-16px)] z-[1] flex min-h-5 min-w-5 items-center justify-center rounded-full px-[2px]","aria-hidden":"true",children:e(g,{html:u?.toString(),className:"text-sm font-bold leading-[1.2] text-white"})})]},v.id))})}),Ce=({title:t,onMenuOpenClose:a,onMenuBackClick:n})=>l("div",{className:"flex h-full items-center gap-3",children:[e("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>n(),"aria-label":"Back to previous menu",children:e(Fe,{className:"size-5","aria-hidden":"true"})}),e(g,{html:t,className:"flex-1 text-center text-base font-bold leading-[1.4]"}),e("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>a(),"aria-label":"Close menu",children:e(ye,{className:"size-5","aria-hidden":"true"})})]}),Z=({label:t,href:a,onClick:n,active:s,icon:u,className:p})=>{const b=l(U,{children:[l("div",{className:"flex items-center gap-4",children:[e(g,{html:t,className:k("text-sm font-bold leading-[1.4]",{underline:u})}),u&&e(g,{html:u,"aria-hidden":"true"})]}),e(je,{className:k("laptop:size-4 size-5",{"rotate-90":s}),"aria-hidden":"true"})]});return a?e(O,{href:a,className:k("flex cursor-pointer items-center justify-between py-4 no-underline",p),children:b}):e("button",{className:k("flex w-full cursor-pointer items-center justify-between border-0 bg-transparent py-4 text-left",p),onClick:n,"aria-expanded":s,children:b})};pe.displayName="MobileNavigation",ne.displayName="Actions",ce.displayName="HeaderNavigation",de.displayName="DesktopNavigation",ue.displayName="SidebarDropdown",pe.displayName="MobileNavigation",ne.displayName="Actions",ce.displayName="HeaderNavigation",de.displayName="DesktopNavigation",ue.displayName="SidebarDropdown";var pt=ze(ce);export{pt as default};
|
|
1
|
+
"use client";import{Fragment as U,jsx as e,jsxs as l}from"react/jsx-runtime";import Le,{forwardRef as ee,useCallback as V,useEffect as B,useImperativeHandle as Pe,useMemo as L,useRef as j,useState as z}from"react";import{Picture as X,Text as g,Button as A,Container as te,Link as O,Heading as me,BrandStrip as Ee}from"../../components/index.js";import{withLayout as ze}from"../../shared/Styles.js";import{cn as k,atobID as He}from"../../helpers/utils.js";import Be,{useNavContext as K}from"./NavProvider.js";import{HeaderNavigationMenu as R,HeaderNavigationBlockType as I,HeaderNavigationActionBlockType as T}from"./types.js";import"react-responsive";import{debounce as Te}from"es-toolkit";import $e from"jump.js";import{useGSAP as ie}from"@gsap/react";import{gsap as se}from"gsap";import{WithSidebar as be,WithSupports as fe,WithMulticol as ve,WithGroupCategory as ge}from"./withCategory.js";import{Menu as Ae,Close as ye,User as Re,RightArrow as je,LeftArrow as Fe,DownArrow as ae,Polygon as _e}from"./icons/index.js";import Oe from"../NavigationSearch/index.js";const ce=ee((t,a)=>{const{data:{header:n}={},buildProps:s,event:u,profile:p,theme:b="light",isTop:c=!1,searchResult:h,onSearch:v,isSearching:r,keywords:D,onPrimaryNavClick:w,onSeriesProductClick:d,onSidebarNavClick:x,headerId:f,cartCount:y,menuData:i}=t,[m,S]=z(!1),[M,P]=z(!1),C=j(null),$=j(null),G=()=>{const N=document?.querySelector("body")?.offsetWidth||0;P(N<=1440)};B(()=>(G(),window.addEventListener("resize",G),()=>{window.removeEventListener("resize",G)}),[]),Pe(a,()=>$.current),B(()=>{$.current&&c&&$e($.current,{duration:0,offset:$.current?.getBoundingClientRect()?.bottom||0})},[c]),B(()=>{u&&(u.search=()=>S(!0))},[u]),ie(()=>{C?.current&&m&&se.fromTo(C.current,{height:0},{height:"auto",duration:.3})},[m]),B(()=>{document.documentElement.style.overflow=m?"hidden":"auto"},[m]);const W=L(()=>n?.bar?.actions?.find(N=>N?.blockType===T.Search)?.searchBar?.[0]||{},[n]);return e(Be,{buildProps:s,profile:p,isMobile:M,event:u,payloadData:n,onSidebarNavClick:x,onSeriesProductClick:d,cartCount:y,children:e("header",{id:f||"header","data-ui-component-id":"HeaderNavigation",className:"relative z-[100] bg-white",ref:$,children:l("div",{className:k("hover:bg-white hover:text-black",b==="light"?"text-black":"text-white",{}),children:[e(de,{data:n,className:"desktop:block hidden !bg-white",theme:b,onPrimaryNavClick:w}),e(pe,{menuData:i,data:n,className:"desktop:hidden block !bg-white",onPrimaryNavClick:w}),m&&l("div",{className:"absolute left-0 top-0 z-[60] flex w-full flex-col bg-black/70",style:{height:`calc(100dvh - ${$?.current?.getBoundingClientRect()?.top}px)`},role:"dialog","aria-modal":"true","aria-label":"Search",children:[e("div",{ref:C,className:k("overflow-y-auto",{}),children:e(Oe,{data:W,keywords:D,isSearching:r,searchResult:h,onSearch:N=>{v?.(N)},onClose:()=>{v?.(),S(!1)}})}),e("div",{className:"flex-1 bg-transparent",onClick:()=>S(!1),role:"button",tabIndex:0,"aria-label":"Close search",onKeyDown:N=>{(N.key==="Enter"||N.key===" "||N.key==="Escape")&&(N.preventDefault(),S(!1))}})]})]})})})}),de=ee((t,a)=>{const{data:n,onNavItemClick:s,className:u,theme:p,onPrimaryNavClick:b}=t,{event:c,profile:h}=K(),[v,r]=z(!1),D=L(()=>ge(n?.categories?.filter(o=>o?.pcShow)),[n]),[w,d]=z(null),[x,f]=z([]),y=j(null),[i,m]=z(!1),S=j(null),M=j(null),P=j(D.map(o=>Array(o?.length||0).fill(null)));B(()=>{D?.length&&f(D?.map((o,E)=>o?.map((H,F)=>({groupIndex:E,index:F,open:!1}))))},[D]);const C=L(()=>{let o=null;for(const E of x){for(const H of E)if(H.open){o=H;break}if(o)break}return o},[x]);B(()=>{document.documentElement.style.overflow=C?.open||i?"hidden":"auto"},[C?.open,i]);const $=(o,E,H)=>{if(m(!1),w?.components?.[0]?.blockType===I.Links)w?.components?.[0]?.url&&window.open(w?.components?.[0]?.url);else{const F=D?.flat()||[],J=F?.findIndex(_=>_?.id===D[E][H]?.id);o.stopPropagation(),s?.(),b?.(F[J],J),d(D[E][H]),f(_=>_.map(Me=>Me.map(Y=>Y.groupIndex===E&&Y.index===H?{...Y,open:!Y.open}:{...Y,open:!1})))}},G=(o,E,H)=>{o.key==="Enter"||o.key===" "?(o.preventDefault(),$(o,E,H)):o.key==="Escape"&&C?.groupIndex===E&&C?.index===H&&(o.preventDefault(),W())},W=()=>{f(o=>o.map(E=>E.map(H=>({...H,open:!1}))))},N=L(()=>{if(w)return w?.components?.[0]?.blockType},[w]),le=be(ue,w),q=ve(Ie,w),Se=fe(We,{categoriesItem:w,currentNavItemRef:P.current?.[C?.groupIndex||0]?.[C?.index||0]}),De=L(()=>{switch(N){case I.Sidebar:return e(le,{});case I.Supports:return e(Se,{});case I.Multicol:return e(q,{});default:return null}},[N,w]),re=L(()=>n?.bar?.actions?.filter(o=>o?.pcShow),[n]),Q=L(()=>re?.find(o=>o?.blockType===T.Profile),[re]),oe=V(()=>{m(o=>!o)},[]);return B(()=>{if(y?.current){const o=y.current;return o.addEventListener("click",oe),()=>{o.removeEventListener("click",oe)}}},[oe]),ie(()=>{C?.open&&se.fromTo(M?.current,{height:0},{height:"auto"})},[C?.open]),l(te,{className:k("relative h-[96px]",u),children:[l("div",{ref:S,onClick:W,className:"flex h-full flex-col justify-end gap-4",children:[l("div",{className:"flex items-center justify-between",children:[e(we,{}),e(ne,{ref:y,actions:re,activeStatus:i})]}),e("nav",{className:"flex justify-between",role:"navigation","aria-label":"Primary navigation",children:D?.map((o,E)=>e("div",{className:"flex gap-3",children:o?.map((H,F)=>{const J=C?.groupIndex===E&&C?.index===F;return e("div",{ref:_=>{P.current[E][F]=_},className:"group cursor-pointer",children:l("div",{className:"relative",children:[l("button",{className:"flex cursor-pointer items-center gap-1 border-0 bg-transparent pb-4",onClick:_=>$(_,E,F),onKeyDown:_=>G(_,E,F),"aria-expanded":J,"aria-haspopup":"true","aria-label":H.text,children:[e(g,{html:H.text,className:"text-sm font-bold leading-[1.4]"}),e(ae,{"aria-hidden":"true",className:k("size-4 opacity-0 transition-opacity duration-500 group-hover:opacity-100",{"rotate-180":J,"opacity-100":v&&J})})]}),e("div",{className:k("absolute bottom-0 left-0 h-[2px] w-0 transition-all duration-500",{"w-[calc(100%-20px)]":J},p==="dark"?"bg-white":"bg-[#080A0F]"),"aria-hidden":"true"})]})},H.id)})},`groupCategory-${E}`))})]}),l("div",{role:"menu","aria-hidden":!(C?.open&&w),className:k("absolute left-0 top-full z-[999] flex w-full flex-col overflow-hidden border-t border-b-[#E4E5E6] bg-black/70 text-black",{hidden:!(C?.open&&w)}),onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{height:`calc(100dvh - ${S?.current?.getBoundingClientRect()?.bottom}px)`},children:[e("div",{ref:M,className:k("relative z-50",{"overflow-hidden":N!==I.Supports}),children:De}),e("div",{className:"flex-1 bg-transparent",onClick:W,role:"button",tabIndex:0,"aria-label":"Close menu",onKeyDown:o=>{(o.key==="Enter"||o.key===" "||o.key==="Escape")&&(o.preventDefault(),W())}})]}),i&&l("div",{className:"absolute left-0 top-full z-[999] flex h-dvh w-full bg-black/70",role:"dialog","aria-modal":"true","aria-label":"User profile menu",children:[e("div",{className:"absolute w-[272px] bg-white p-4",style:{right:`calc(100% - ${y?.current?.getBoundingClientRect()?.right}px)`,top:"-36px"},children:h?.email?l(U,{children:[e(g,{html:h?.nick_name||Q?.welcome,className:"text-sm font-bold"}),e("div",{className:"mt-2 h-px bg-[#D9D9D9]","aria-hidden":"true"}),e("nav",{className:"mt-2",role:"navigation","aria-label":"Profile navigation",children:Q?.profiles?.map(o=>e(Z,{className:"py-2",label:o?.title,href:o?.url},o.id))})]}):l(U,{children:[e(_e,{className:"absolute -top-2 right-[46px] z-30 text-white","aria-hidden":"true"}),e(g,{html:Q?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),e("div",{className:"mt-2 flex flex-col gap-1",children:Q?.benefits?.map(o=>l("div",{className:"flex items-center gap-[6px]",children:[e(X,{source:o.benefitIcon?.url,className:"size-4",alt:o.benefit,width:16,height:16}),e(g,{html:o.benefit,className:"text-sm font-bold leading-[1.4]"})]},o.id))}),l("div",{className:"mt-4 flex items-center gap-2",children:[e(A,{variant:"secondary",size:"lg",onClick:()=>c?.join?.(),children:e(g,{html:Q?.primaryButton||"Join Now",className:"font-bold"})}),e(A,{variant:"primary",size:"lg",onClick:()=>c?.login?.(),children:e(g,{html:Q?.secondaryButton||"Log In",className:"font-bold"})})]})]})}),e("div",{className:"flex-1 bg-transparent",onClick:()=>m(!1),role:"button",tabIndex:0,"aria-label":"Close profile menu",onKeyDown:o=>{(o.key==="Enter"||o.key===" "||o.key==="Escape")&&(o.preventDefault(),m(!1))}})]})]})}),ue=Le.memo(({sidebarCategoriesMetadata:t,seriesMetadata:a})=>{const{buildProps:n,onSidebarNavClick:s}=K(),[u,p]=z([]),[b,c]=z(-1),h=j(null),v=V(()=>{const d=t?.subcategories;if(!d?.length)return;const x=d.findIndex(i=>!!i?.subSubCategories),f=d.findIndex(i=>!i?.subSubCategories),y=d.map((i,m)=>({index:m,open:x===m||f===m}));p(y)},[t]);B(()=>{v()},[v]);const r=L(()=>{const d=t?.subcategories?.[u?.find(f=>f.open)?.index||0],x=a?.find(f=>f?.label?.toLowerCase()===d?.label?.toLowerCase())||{};if(d?.collections){const f=n?.categories?.[d?.collections]||{};return{label:x?.label,isCollection:!0,banner:x?.banner,primary:x?.primary,series:[{products:f?.products}]}}else if(d?.subSubCategories){const f=d?.subSubCategories?.[b],y=a?.find(i=>i?.label?.toLowerCase()===f?.label?.toLowerCase())||{};if(f?.collections){const i=n?.categories?.[f?.collections]||{};return{label:y?.label,isCollection:!0,banner:y?.banner,primary:y?.primary,series:[{products:i?.products}]}}else return y}else return x},[t,u,b,a,n]),D=V((d,x)=>{x?.subSubCategories?.length>0?c(0):c(-1),p(f=>f.map((y,i)=>({...y,open:i===d?!y.open:!1})))},[]),w=(d,x)=>{p(f=>f.map(y=>y.index===d?{...y,open:!0}:{...y,open:!1})),c(x)};return l(te,{childClassName:"lg-desktop:gap-12 flex bg-white gap-8",children:[l("div",{className:"lg-desktop:basis-[356px] flex basis-[284px] flex-col gap-4 py-4",style:{userSelect:"none"},ref:h,children:[e("div",{className:"desktop:h-[416px] flex flex-col overflow-y-auto",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:t?.subcategories?.map((d,x)=>{const f=Array.isArray(d?.subSubCategories)&&d?.subSubCategories?.length>0,y=u?.find(i=>i.index===x)?.open;return l("div",{children:[l("button",{className:k("flex w-full cursor-pointer items-center justify-between border-0 bg-transparent text-left",{"bg-[#F5F5F7]":!f&&y}),onClick:()=>{D(x,d),s?.(d,x)},"aria-expanded":f?y:void 0,"aria-haspopup":f?"true":void 0,children:[e(g,{html:d.label,className:"p-4 text-sm font-bold leading-[1.4]"}),f&&e(ae,{"aria-hidden":"true",className:k("size-4",{"rotate-180":y})})]}),y&&e("div",{className:"flex flex-col",role:"menu",children:d.subSubCategories?.map((i,m)=>e("button",{onClick:()=>{w(x,m),s?.(i,m)},className:k("w-full cursor-pointer border-0 bg-transparent px-6 py-4 text-left hover:bg-[#F5F5F7]",{"bg-[#F5F5F7]":b===m}),role:"menuitem","aria-label":i.label,children:e(g,{html:i.label,className:"text-sm font-bold leading-[1.4] text-[#6D6D6F]"})},`subSubItem-${x}-${m}`))})]},`subcategoryItem-${x}`)})}),t&&e("div",{className:"flex",children:l("div",{className:"flex flex-col gap-4",children:[t?.primary&&e(A,{as:"a",href:`${t?.primary?.url}?ref=${t?.primary?.label}_shopall`,variant:"primary",size:"lg",className:"lg-desktop:text-base text-sm",children:t?.primary?.label}),t?.secondary&&e(A,{as:"a",href:t?.secondary?.url,variant:"link",size:"lg",className:"lg-desktop:text-base justify-start !p-0 text-sm",children:t?.secondary?.label})]})})]}),l("div",{className:"flex-1 py-4",children:[Reflect.ownKeys(r).length>0&&l("div",{className:"mb-4 flex items-center justify-between",children:[l("div",{className:"flex items-center gap-2",children:[e(g,{html:r?.label,className:"lg-desktop:text-2xl text-xl font-bold leading-[1.4]"}),r?.primary&&!r?.primary?.hide&&e(A,{as:"a",href:`${r?.primary?.url}?ref=${r?.label}_viewmore`,variant:"link",size:"lg",className:"lg-desktop:text-base justify-start !p-0 text-sm font-bold leading-[1.2] no-underline",children:r?.primary?.label})]}),e(O,{href:r?.guide?.url,className:"lg-desktop:text-base text-sm leading-[1.2] text-[#6D6D6F]",children:r?.guide?.label})]}),e("div",{className:"flex h-[426px] flex-col gap-4 overflow-y-auto",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:r?.series?.map((d,x)=>l("div",{children:[d.label&&e(g,{html:d.label,className:"mb-2 text-sm font-bold leading-[1.4] text-[#6D6D6F]"}),l("div",{className:"grid grid-cols-3 gap-4",children:[!!r?.banner&&e(O,{asChild:!r?.banner?.href,href:r?.banner?.href,children:l("div",{className:"relative [&_img]:hover:scale-110 [&_img]:hover:transition-all [&_img]:hover:duration-500",children:[e(X,{source:r?.banner?.imageUrl,className:"laptop:h-[120px] h-[114px]",imgClassName:"object-cover h-full"}),l("div",{className:"absolute inset-x-0 bottom-0 p-4",children:[e(me,{size:2,html:r?.banner?.title||"Buy in Guide",className:"font-bold text-white"}),e(g,{html:r?.banner?.desc||"20.000mAh",className:"text-sm font-bold text-white"})]})]})}),d.products?.map((f,y)=>e(he,{seriesLabel:r?.label,product:f,isCollection:r?.isCollection},`seriesProductItem-${y}`))]})]},`seriesItem-${x}`))})]})]})}),Ie=({multicolMetadata:t})=>{const a=j(null);return e("div",{ref:a,children:e(te,{childClassName:"bg-white",className:"h-full",children:e("div",{className:"flex gap-4 py-4",children:t?.map((n,s)=>e("div",{className:"w-1/4",children:e(xe,{item:n})},`multicolItem-${n?.label}-${s}`))})})})},We=({supportsMetadata:t,currentNavItemRef:a})=>{const n=j(null),[s,u]=z(null),[p,b]=z(0);B(()=>{if(n?.current){const h=n?.current?.getBoundingClientRect();b(h.height)}},[n]);const c=Te(()=>{if(a){const h=a.getBoundingClientRect();u(h)}},500);return B(()=>(c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}),[c]),B(()=>{if(a){const h=a.getBoundingClientRect();u(h)}},[a]),e("div",{className:"absolute top-0 h-full overflow-hidden bg-white transition-all duration-500",style:{right:`calc(100% - ${s?.right}px)`,height:p},children:e("div",{ref:n,className:"p-4",children:t?.map(h=>e("div",{className:"py-2",children:e(O,{href:h.url,className:"text-sm font-bold leading-[1.4] no-underline",children:h.label})},h.id))})})},he=({product:t,isCollection:a,position:n,seriesLabel:s})=>{const{buildProps:u,onSeriesProductClick:p}=K();let b=a?t:u?.products?.find(r=>r.handle===t.handle);const c=b?.variants?.find(r=>r.sku===t.sku)||b?.variants?.[0],h=L(()=>`/products/${b?.handle}?variant=${He(c?.id)}`,[b?.handle,c?.id]),v=L(()=>b?.tags?.filter?.(r=>r?.startsWith?.("CLtag"))?.map?.(r=>r?.replace?.("CLtag:",""))?.slice?.(0,2),[b?.tags]);return c?.availableForSale?e(O,{href:h,onClick:r=>{r.preventDefault(),window.open(h,"_self"),p?.(b,n||0,s)},className:"no-underline hover:text-current",children:l("div",{className:"flex shrink-0 items-center gap-4 bg-[#F5F5F7] px-4 py-3 [&_img]:hover:scale-110 [&_img]:hover:duration-500",children:[e("div",{className:"shrink-0",children:e(X,{source:`${c?.image?.url||t?.images?.[0]?.url}}`,width:90,height:90,className:"size-[96px]",imgClassName:"object-contain h-full"})}),l("div",{className:"relative",children:[e("div",{className:"flex gap-1",children:Array.isArray(v)&&v?.map((r,D)=>e(g,{as:"p",html:r,className:"text-brand-0 mb-1 inline-block h-[24px] whitespace-nowrap rounded-full border-[1.6px] border-[#00BEFA] px-[6px] text-sm font-bold !leading-[22px]"},D))}),e(g,{className:"lg-desktop:h-[44px] lg-desktop:text-base line-clamp-2 h-[40px] text-sm font-bold leading-[1.4]",html:b?.title||t?.name}),t?.desc&&e(g,{as:"p",html:t?.desc,className:"lg-desktop:text-sm mt-1 line-clamp-1 text-xs font-bold leading-[1.4] text-[#6D6D6F]"})]})]})}):null},xe=({item:t,allPicture:a})=>l(U,{children:[t?.columns&&l(U,{children:[e(g,{html:t.label,as:"div",className:"my-2 text-sm font-bold leading-[1.4] text-[#6D6D6F]"}),e("div",{className:"mt-2 flex flex-col",children:t.columns?.map(n=>l("div",{className:"flex items-center gap-1 py-2",children:[e(O,{href:`${n.url}?ref=navMenu`,asChild:!n.url,className:"text-sm font-bold leading-[1.4] no-underline",children:n.label}),n?.badge&&e(g,{as:"p",html:n?.badge||"badge",className:"text-brand-0 h-[24px] rounded-full border-[1.6px] border-[var(--brand-color-0)] px-[6px] text-sm font-bold !leading-[22px]"})]},n.label))})]}),t?.imageUrl&&e("div",{className:k("laptop:h-[280px] desktop:h-[224px] lg-desktop:h-[280px] tablet:max-w-[346px] laptop:max-w-[440px] desktop:w-full relative h-[240px] max-w-[358px] overflow-hidden",{"tablet:max-w-none laptop:max-w-none":a}),children:l(O,{href:`${t.url}?ref=navMenu`,asChild:!t.url,children:[e(X,{source:t.imageUrl,width:404,height:280,className:"size-full",imgClassName:"object-cover h-full hover:scale-105 transition-all duration-300"}),l("div",{className:"absolute bottom-4 left-4 z-10 flex flex-col justify-end no-underline",children:[e(g,{html:t.title,className:k("lg-desktop:text-2xl text-xl font-bold leading-[1.2] text-white",{"text-black":t?.theme==="dark"})}),t.subtitle&&e(g,{html:t.subtitle,className:k("text-sm font-bold leading-[1.4] text-white",{"text-black":t?.theme==="dark"})}),t?.primary?.label&&e(A,{as:"a",href:t?.primary?.url,variant:"link",size:"lg",className:k("mr-auto !p-0 text-sm font-bold leading-[1.4] text-white",{"text-black":t?.theme==="dark"}),children:t?.primary?.label||"more"})]})]})})]}),pe=ee(({data:t,menuData:a,className:n,onPrimaryNavClick:s},u)=>{const p=L(()=>ge(t?.categories?.filter(N=>N?.mobileShow)),[t]),{currentMenu:b,setCurrentMenu:c,subSubCategory:h}=K(),[v,r]=z(!1),[D,w]=z(0),[d,x]=z(null),f=j(null);B(()=>{if(f?.current&&v){const N=f?.current?.getBoundingClientRect();w(window?.innerHeight-(N?.bottom||0))}},[v]),ie(()=>{se.fromTo(f.current,{height:0},{height:D,duration:.3})},[D]),B(()=>{document.documentElement.style.overflow=v?"hidden":"auto"},[v]);const y=L(()=>d?.components?.[0]?.blockType,[d]),i=fe(Ge,{categoriesItem:d}),m=be(Ue,d),S=ve(Je,d),M=L(()=>{switch(y){case I.Sidebar:return e(m,{});case I.Supports:return e(i,{});case I.Multicol:return e(S,{});default:return null}},[y,d,i]),P=V(()=>{r(!1),w(0),c&&c(R.Primary)},[r,w,c]),C=L(()=>t?.bar?.actions?.filter(N=>N?.mobileShow&&N?.blockType!==T.Profile),[t]),$=L(()=>t?.bar?.actions?.find(N=>N?.mobileShow&&N?.blockType===T.Profile)||{},[t]),G=L(()=>{switch(b){case R.Primary:return e(qe,{actions:C,menuOpen:v,onMenuOpenClose:()=>{r(!1),w(0)},onMenuOpenClick:()=>r(!0)});case R.Secondary:return e(Ce,{title:d?.text,onMenuOpenClose:P,onMenuBackClick:()=>c?.(R.Primary)});case R.Third:return e(Ce,{title:h?.label,onMenuOpenClose:P,onMenuBackClick:()=>c?.(R.Secondary)});default:return null}},[v,b,c,d,C,h,P]),W=V((N,le)=>{const q=Array.isArray(p)?Array.isArray(p[N])?p[N][le]:{}:{};x(q),q?.components?.[0]?.blockType===I.Links?q?.components?.[0]?.url&&window.open(q?.components?.[0]?.url):c?.(R.Secondary)},[p,c]);return l(te,{className:k("relative h-[52px]",n),children:[G,v&&l("nav",{ref:f,className:"absolute left-0 top-full z-[999] w-full overflow-y-auto border-t border-[#E4E5E6] bg-white text-black",style:{height:D},role:"navigation","aria-label":"Mobile navigation menu",children:[b===R.Primary?e("div",{className:"pt-4",children:e(Ee,{data:a})}):null,b===R.Primary?e(Ke,{categories:p,onPrimaryMenuClick:W,onPrimaryNavClick:s,profileAction:$}):M]})]})}),Ke=({categories:t,onPrimaryMenuClick:a,profileAction:n,onPrimaryNavClick:s})=>l("div",{className:"flex h-full flex-col justify-between",children:[e("div",{className:"tablet:px-8 laptop:px-16 p-4",children:t?.map((u,p)=>l("div",{className:"",children:[e("div",{className:k("my-2 h-px w-full bg-[#E5E5E7]")}),u?.map((b,c)=>e(Z,{label:b.text,onClick:()=>{const v=(t?.flat()||[])?.findIndex(r=>r?.id===t[p][c]?.id);a(p,c),s?.(b,v)},icon:b.components?.[0]?.icon},b.id))]},`groupCategory-${p}`))}),e(Ve,{profileAction:n})]}),Ue=({sidebarCategoriesMetadata:t,seriesMetadata:a})=>{const{currentMenu:n,setCurrentMenu:s,subSubCategory:u,setSubSubCategory:p,setCurrentSeriesMetadata:b,currentSeriesMetadata:c,buildProps:h,onSidebarNavClick:v}=K(),[r,D]=z([]),[w,d]=z([]);B(()=>{t?.subcategories?.length&&D(t?.subcategories?.map((i,m)=>({index:m,open:!1})))},[t]),B(()=>{u?.subSubCategories?.length&&d(u?.subSubCategories?.map((i,m)=>({index:m,open:m===0})))},[u]);const x=V((i,m)=>{s&&s(R.Third),p?.(i);const S=a?.find(M=>m!==void 0?i?.subSubCategories?.[m]?.label?.toLowerCase()===M.label?.toLowerCase():i?.label?.toLowerCase()===M.label?.toLowerCase())||{};if(i?.collections){const M=h?.categories?.[i?.collections]||{};b?.({label:S?.label,isCollection:!0,banner:S?.banner,primary:S?.primary,series:[{products:M?.products}]})}else b?.(S)},[a,s,p,b,h?.categories]),f=L(()=>a?.find(i=>!!i?.guide)?.guide,[a]);return L(()=>{switch(n){case R.Secondary:return l("div",{className:"tablet:px-8 laptop:px-16 tablet:justify-start tablet:gap-16 flex h-full flex-col justify-between p-4",children:[e("div",{children:t?.subcategories?.map((i,m)=>e("div",{children:e(Z,{label:i?.label,active:r.find(S=>S.index===m)?.open,onClick:()=>{x(i),v?.(i,m)}})},`${i.label}-${m}`))}),l("div",{className:"tablet:items-start flex flex-col items-center gap-4",children:[t?.primary&&e(A,{as:"a",href:`${t?.primary?.url}?ref=${t?.primary?.label}_shopall`,variant:"primary",size:"lg",className:"tablet:w-auto w-full text-base",children:t?.primary?.label}),t?.secondary&&e(A,{as:"a",href:t?.secondary?.url,variant:"link",size:"lg",className:"tablet:w-auto tablet:px-0 w-full py-0 text-base",children:t?.secondary?.label})]})]});case R.Third:return l("div",{className:"tablet:px-8 laptop:px-16 p-4",children:[u?.subSubCategories?u?.subSubCategories?.map((i,m)=>{const S=a?.find(P=>P.label.toLowerCase()===i?.label?.toLowerCase())||{};let M={};if(i?.collections){const P=h?.categories?.[i?.collections]||{};M={label:S?.label,isCollection:!0,banner:S?.banner,primary:S?.primary,series:[{products:P?.products}]}}else M=S;return l("div",{children:[Reflect.ownKeys(i).length>0&&e(Ne,{matchSeriesMetadata:M,onSubSubCategoryItemClick:()=>{v?.(i,m),d(P=>P.map((C,$)=>({...C,open:$===m?!C.open:C.open})))},expanded:!!w?.find(P=>P.index===m)?.open}),w?.find(P=>P.index===m)?.open&&l(U,{children:[e(ke,{matchSeriesMetadata:M}),M?.primary&&e("div",{className:"my-4 text-center",children:e(A,{as:"a",href:M?.primary?.url,className:"text-base leading-[1.2] no-underline",variant:"secondary",size:"base",children:M?.primary?.label})})]})]},`${i.label}-${m}`)}):l(U,{children:[Reflect.ownKeys(c).length>0&&e(Ne,{matchSeriesMetadata:c}),e(ke,{matchSeriesMetadata:c}),c?.primary&&e("div",{className:"my-4 text-center ",children:e(A,{as:"a",href:`${c?.primary?.url}?ref=${c?.label}_viewmore`,variant:"secondary",size:"base",className:"text-base leading-[1.2] no-underline",children:c?.primary?.label})})]}),f&&e(O,{href:f?.url,children:e("div",{className:"mt-4",children:e(g,{html:f?.label,className:"text-sm font-bold leading-[1.2] text-[#6D6D6F]"})})})]});default:return null}},[n,t,a,r,w,u,c,h?.categories,f,x,v])},Ne=({matchSeriesMetadata:t,onSubSubCategoryItemClick:a,expanded:n})=>{const s=l(U,{children:[t?.label&&e(g,{html:t?.label,className:"text-sm font-bold leading-[1.4]"}),a&&e(ae,{"aria-hidden":"true",className:k("size-5",{"rotate-180":n})})]});return a?e("button",{className:"tablet:pt-0 flex w-full cursor-pointer items-center justify-between border-0 bg-transparent py-4 text-left",onClick:a,"aria-expanded":n,children:s}):e("div",{className:"tablet:pt-0 flex items-center justify-between py-4",children:s})},ke=({matchSeriesMetadata:t})=>e("div",{className:"laptop:gap-3 flex flex-col gap-2",children:!!t?.series?.length&&t?.series?.map((a,n)=>l("div",{children:[a.label&&e(g,{html:a.label,className:"mb-2 text-sm font-bold leading-[1.4] text-[#3D3D3F]"}),l("div",{className:"laptop:grid-cols-3 laptop:gap-4 tablet:grid tablet:grid-cols-2 tablet:gap-3 flex flex-col gap-2",children:[!!t?.banner&&e(O,{asChild:!t?.banner?.href,href:t?.banner?.href,children:l("div",{className:"relative [&_img]:hover:scale-110 [&_img]:hover:transition-all [&_img]:hover:duration-500",children:[e(X,{source:t?.banner?.imageUrl,className:"laptop:h-[120px] h-[114px]",imgClassName:"object-cover h-full"}),l("div",{className:"absolute inset-x-0 bottom-0 p-4",children:[e(me,{size:2,html:t?.banner?.title||"Buy in Guide",className:k("font-bold text-white",{"text-black":t?.banner?.theme==="dark"})}),e(g,{html:t?.banner?.desc||"20.000mAh",className:k("text-sm font-bold text-white",{"text-black":t?.banner?.theme==="dark"})})]})]})}),a.products?.map((s,u)=>e(he,{position:u,product:s,seriesLabel:t?.label,isCollection:t?.isCollection},`seriesProductItem-${n}-${u}`))]})]},`seriesItem-${n}`))}),Ge=({supportsMetadata:t})=>e("div",{className:"tablet:px-8 laptop:px-16 p-4",children:t?.map(a=>e(Z,{href:a.url,label:a.label,onClick:()=>{}},a.id))}),Je=({multicolMetadata:t})=>{const a=L(()=>!t?.some(n=>!!n.columns),[t]);return e("div",{className:k("tablet:py-4 tablet:px-8 laptop:px-16 tablet:gap-6 flex flex-col gap-4 p-4",{"tablet:grid tablet:grid-cols-2 tablet:gap-3 laptop:gap-4":a}),children:t?.map((n,s)=>e("div",{children:e(xe,{item:n,allPicture:a})},`multicolItem-${n?.label}-${s}`))})},Ve=({profileAction:t})=>{const[a,n]=z(!1),{profile:s,event:u}=K();return l("div",{className:k("tablet:px-8 laptop:px-16 bg-[#F5F5F7] px-4 py-6",{"p-4":a}),children:[l("button",{className:"flex w-full cursor-pointer items-center justify-between border-0 bg-transparent",onClick:()=>n(!a),"aria-expanded":a,"aria-label":s?.nick_name||t?.welcome,children:[l("div",{className:"flex items-center gap-[14px]",children:[e("div",{className:"flex size-[40px] shrink-0 items-center justify-center rounded-full bg-white",children:e(Re,{"aria-hidden":"true"})}),e(g,{html:s?.nick_name||t?.welcome,className:"text-base font-bold leading-[1.4]"})]}),!s?.email&&e(ae,{"aria-hidden":"true",className:k("laptop:size-4 size-5",{"rotate-180":a})})]}),s?.email&&e("nav",{className:"mt-4",role:"navigation","aria-label":"Profile menu",children:t?.profiles?.map(p=>e(Z,{label:p?.title,href:p?.url},p.id))}),a&&!s?.email&&l("div",{className:"mt-4",children:[e(g,{html:t?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),e("div",{className:"mt-2 flex flex-col gap-1",children:t?.benefits?.map(p=>l("div",{className:"flex items-center gap-[6px]",children:[e(X,{source:p.benefitIcon?.url,className:"size-4",alt:p.benefit,width:16,height:16}),e(g,{html:p.benefit,className:"text-sm font-bold leading-[1.4]"})]},p.id))})]}),!s?.email&&l("div",{className:"mt-4 flex items-center gap-3",children:[e(A,{className:"tablet:flex-none flex-1",variant:"secondary",size:"base",onClick:()=>u?.join?.(),children:e(g,{html:t?.primaryButton||"Join Now",className:"text-sm font-bold leading-[1.4]"})}),e(A,{className:"tablet:flex-none flex-1",variant:"primary",size:"base",onClick:()=>u?.login?.(),children:e(g,{html:t?.secondaryButton||"Log In",className:"text-sm font-bold leading-[1.4]"})})]})]})},qe=({menuOpen:t,onMenuOpenClose:a,onMenuOpenClick:n,actions:s})=>l("div",{className:"flex h-full items-center justify-between gap-4",children:[e(we,{}),l("div",{className:"desktop:gap-6 flex items-center gap-4",children:[e(ne,{actions:s}),t?e("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>a(),"aria-label":"Close menu","aria-expanded":"true",children:e(ye,{className:"size-5","aria-hidden":"true"})}):e("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>n(),"aria-label":"Open menu","aria-expanded":"false","aria-haspopup":"true",children:e(Ae,{className:"size-5","aria-hidden":"true"})})]})]}),we=()=>{const{payloadData:t,isMobile:a}=K();return e("a",{href:"/",className:"hover:text-brand-0 [&>svg]:w-full","aria-label":"Home",dangerouslySetInnerHTML:{__html:a?t?.bar?.mobileLogo:t?.bar?.desktopLogo}})},ne=ee(({actions:t,activeStatus:a=!1},n)=>{const{event:s,cartCount:u}=K(),[p,b]=z(null),c=v=>{switch(v){case T.Search:return"Search";case T.Cart:return`Shopping cart${u>0?` (${u} items)`:""}`;case T.Profile:return"User profile";case T.Livestream:return"Livestream";default:return"Action"}},h=V((v,r)=>{switch(b(r),v?.blockType){case T.Search:s?.search?.();break;case T.Cart:s?.cart?.();break;case T.Profile:s?.profile?.();break;case T.Livestream:s?.livestream?.();break;default:return()=>{}}},[s]);return e("div",{className:"desktop:gap-6 flex items-center gap-4",children:Array.isArray(t)&&t?.map((v,r)=>l("button",{className:"relative cursor-pointer border-0 bg-transparent p-0",ref:v.blockType===T.Profile?n:null,onClick:()=>h(v,r),"aria-label":c(v.blockType),"aria-pressed":a&&p===r,children:[e(g,{html:v.icon,className:k("size-5",{"text-brand-0":a&&p===r}),"aria-hidden":"true"}),v.blockType===T.Cart&&u>0&&e("div",{className:"bg-brand-0 absolute right-[-12px] top-[calc(100%-16px)] z-[1] flex min-h-5 min-w-5 items-center justify-center rounded-full px-[2px]","aria-hidden":"true",children:e(g,{html:u?.toString(),className:"text-sm font-bold leading-[1.2] text-white"})})]},v.id))})}),Ce=({title:t,onMenuOpenClose:a,onMenuBackClick:n})=>l("div",{className:"flex h-full items-center gap-3",children:[e("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>n(),"aria-label":"Back to previous menu",children:e(Fe,{className:"size-5","aria-hidden":"true"})}),e(g,{html:t,className:"flex-1 text-center text-base font-bold leading-[1.4]"}),e("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>a(),"aria-label":"Close menu",children:e(ye,{className:"size-5","aria-hidden":"true"})})]}),Z=({label:t,href:a,onClick:n,active:s,icon:u,className:p})=>{const b=l(U,{children:[l("div",{className:"flex items-center gap-4",children:[e(g,{html:t,className:k("text-sm font-bold leading-[1.4]",{underline:u})}),u&&e(g,{html:u,"aria-hidden":"true"})]}),e(je,{className:k("laptop:size-4 size-5",{"rotate-90":s}),"aria-hidden":"true"})]});return a?e(O,{href:a,className:k("flex cursor-pointer items-center justify-between py-4 no-underline",p),children:b}):e("button",{className:k("flex w-full cursor-pointer items-center justify-between border-0 bg-transparent py-4 text-left",p),onClick:n,"aria-expanded":s,children:b})};pe.displayName="MobileNavigation",ne.displayName="Actions",ce.displayName="HeaderNavigation",de.displayName="DesktopNavigation",ue.displayName="SidebarDropdown",pe.displayName="MobileNavigation",ne.displayName="Actions",ce.displayName="HeaderNavigation",de.displayName="DesktopNavigation",ue.displayName="SidebarDropdown";var pt=ze(ce);export{pt as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|