@anker-in/headless-ui 1.0.20-alpha.1761270530082 → 1.0.20-alpha.1761276598634
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 +1 -1
- package/dist/cjs/biz-components/NavigationSearch/index.js +2 -2
- package/dist/cjs/biz-components/NavigationSearch/index.js.map +2 -2
- package/dist/esm/biz-components/HeaderNavigation/index.js +1 -1
- package/dist/esm/biz-components/HeaderNavigation/index.js.map +1 -1
- package/dist/esm/biz-components/NavigationSearch/index.js +2 -2
- package/dist/esm/biz-components/NavigationSearch/index.js.map +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var x=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var G=(t,o)=>{for(var r in o)x(t,r,{get:o[r],enumerable:!0})},j=(t,o,r,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let l of W(o))!_.call(t,l)&&l!==r&&x(t,l,{get:()=>o[l],enumerable:!(i=B(o,l))||i.enumerable});return t};var q=t=>j(x({},"__esModule",{value:!0}),t);var M={};G(M,{canSearch:()=>L,default:()=>H});module.exports=q(M);var e=require("react/jsx-runtime"),s=require("../../components/index.js"),h=require("../HeaderNavigation/icons/index.js"),p=require("react"),
|
|
1
|
+
"use strict";var x=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var G=(t,o)=>{for(var r in o)x(t,r,{get:o[r],enumerable:!0})},j=(t,o,r,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let l of W(o))!_.call(t,l)&&l!==r&&x(t,l,{get:()=>o[l],enumerable:!(i=B(o,l))||i.enumerable});return t};var q=t=>j(x({},"__esModule",{value:!0}),t);var M={};G(M,{canSearch:()=>L,default:()=>H});module.exports=q(M);var e=require("react/jsx-runtime"),s=require("../../components/index.js"),h=require("../HeaderNavigation/icons/index.js"),p=require("react"),w=require("../AiuiProvider/index.js"),m=require("./types.js"),C=require("es-toolkit"),c=require("../../helpers/utils.js");const L=t=>!(t.metafields?.global?.HideSearch||t.metafields?.seo?.hidden||t.metafields?.seo?.setting?.noindex),z=(0,p.forwardRef)(({data:t,onSearch:o,onClose:r,searchResult:i,isSearching:l,keywords:d},D)=>{const{locale:g="us",copyWriting:V}=(0,w.useAiuiContext)(),[n,F]=(0,p.useState)(""),[f,N]=(0,p.useState)(!1),$=(0,C.debounce)(a=>{o(a)},300),P=(0,p.useCallback)(a=>{a.key==="Enter"&&!f&&o(n)},[f,n,o]),S=(0,p.useMemo)(()=>Array.isArray(d)&&d?.length?d.map(a=>a.search_term):Array.isArray(t?.popularWords)&&t?.popularWords?.length?t?.popularWords.map(a=>a.popularWord):[],[d,t?.popularWords]),E=(0,p.useCallback)(a=>{switch(a.type){case"Product":return`/products${a.path}?q=${n.toLowerCase()}`;case"Article":return`/blogs/${a.blog.handle}/${a.handle.replace("storefront-","")}?q=${n.toLowerCase()}`;default:break}},[n]),k=(0,p.useMemo)(()=>{if(n){if(i?.totalCount)return m.SearchStatus.Predict;if(!l)return m.SearchStatus.Empty}else return m.SearchStatus.Default},[i?.totalCount,n]);return(0,e.jsxs)(s.Container,{childClassName:"!bg-white",className:"relative",ref:D,children:[(0,e.jsx)("style",{jsx:!0,global:!0,children:`
|
|
2
2
|
.navigation-search-component input:-webkit-autofill,
|
|
3
3
|
.navigation-search-component input:-webkit-autofill:hover,
|
|
4
4
|
.navigation-search-component input:-webkit-autofill:focus {
|
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
transition: background-color 9999s ease-in-out 0s !important;
|
|
8
8
|
caret-color: #000;
|
|
9
9
|
}
|
|
10
|
-
`}),(0,e.jsxs)("div",{className:"navigation-search-component laptop:h-[52px] text-black desktop:h-[60px] flex items-center pt-4 desktop:pt-6 pb-4 justify-between border-b border-b-gray-200",children:[(0,e.jsx)("input",{value:n,onCompositionStart:()=>N(!0),onCompositionEnd:()=>N(!1),onKeyDown:P,onChange:a=>{F(a.target.value),a.target.value&&$(a.target.value)},type:"text",className:"text-sm basis-[200px] focus-visible:!outline-none outline-none leading-[1.4] font-bold",placeholder:t?.placeholder}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(h.Search,{className:"size-5 cursor-pointer",onClick:()=>o(n)}),(0,e.jsx)("div",{className:"w-[1px] h-[20px] bg-[#E4E5E6]"}),(0,e.jsx)(h.Close,{className:"size-5 cursor-pointer",onClick:r})]})]}),(0,e.jsx)("div",{className:"flex flex-col gap-6 desktop:gap-12 text-black desktop:py-6 py-4",children:k===m.SearchStatus.Predict?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(s.Text,{html:t?.suggestText,className:"text-sm text-[#6D6D6F] leading-[1.4] font-bold"}),i?.items?.length>6&&(0,e.jsx)(s.Button,{as:"a",href:`${g==="us"?"":g}${t?.moreLink}?q=${n.toLowerCase()}`,className:"!text-sm leading-[1.2] font-bold !p-0",variant:"link",children:t?.moreText})]}),(0,e.jsx)("div",{className:"flex flex-col mt-2",children:i?.items?.filter(a=>L(a)).slice(0,6)?.map(a=>(0,e.jsx)(s.Link,{className:"hover:bg-[#F5F5F7] hover:text-current no-underline w-full p-4",href:E(a),children:(0,e.jsx)(s.Text,{html:(0,c.highlightSearchWord)(a.title,n),className:"text-sm cursor-pointer leading-[1.4] font-bold"})},a.id))})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)(s.Text,{html:t?.hotProductsText,className:"text-sm text-[#6D6D6F] leading-[1.4] font-bold"}),(0,e.jsxs)("div",{className:"grid grid-cols-1 tablet:grid-cols-2 laptop:grid-cols-3 desktop:grid-cols-4 gap-2 mt-2 tablet:gap-x-3 tablet:gap-y-4 laptop:gap-4",children:[(0,e.jsx)(s.Link,{asChild:!t?.advertisingLink,href:t?.advertisingLink,children:(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)(s.Picture,{source:t?.advertisingBgImg?.url,className:"h-[114px] laptop:h-[120px]",imgClassName:"object-cover h-full"}),(0,e.jsxs)("div",{className:"absolute bottom-0 left-0 right-0 p-4",children:[(0,e.jsx)(s.Heading,{size:2,html:t?.advertisingTitle||"Buy in Guide",className:(0,c.cn)("font-bold text-white",{"text-black":t?.advertisingTheme==="dark"})}),(0,e.jsx)(s.Text,{html:t?.advertisingSubtitle||"20.000mAh",className:(0,c.cn)("text-sm text-white font-bold",{"text-black":t?.advertisingTheme==="dark"})})]})]})}),i?.items?.filter(a=>a.type.toLowerCase()==="product").slice(0,7)?.map(a=>{const u=a?.variants?.[0],v=`${u?.image?.url||a?.images?.[0]?.url}`,b=a?.title||a?.name,I=a?.description,T=a?.badge||"",A=`/products/${a?.handle}?variant=${(0,c.atobID)(u?.id)}`;return(0,e.jsx)(y,{productImage:v,productName:b,productDesc:I,productBadge:T,listingLink:A},a.id)})]})]})]}):(0,e.jsxs)(e.Fragment,{children:[k===m.SearchStatus.Empty&&(0,e.jsx)(s.Text,{html:t?.noResultText,as:"p",className:"text-sm pb-6 border-[#E4E5E6] border-b text-[#6D6D6F] leading-[1.4] font-bold"}),(0,e.jsxs)("div",{children:[(0,e.jsx)(s.Text,{html:t?.popularText,className:"text-sm text-[#6D6D6F] leading-[1.4] font-bold"}),(0,e.jsxs)("div",{className:"mt-2",children:[(0,e.jsx)(K,{data:t,keywords:S,locale:g}),Array.isArray(t?.popularPages)&&!!t?.popularPages?.length&&(0,e.jsx)(s.Grid,{className:"gap-3 laptop:gap-4 mt-3 laptop:mt-4",children:t?.popularPages?.map(a=>(0,e.jsx)(s.GridItem,{className:"col-span-12 tablet:col-span-6 p-2 hover:bg-[#F5F5F7] laptop:p-3 desktop:p-4 laptop:col-span-3",children:(0,e.jsx)("a",{href:`${g==="us"?"":g}${t?.moreLink}?q=${a?.popularPage.toLowerCase()}`,className:"text-sm cursor-pointer line-clamp-1 leading-[1.4] font-bold",children:a?.popularPage})},a?.id))})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)(s.Text,{html:t?.hotProductsText,className:"text-sm text-[#6D6D6F] leading-[1.4] font-bold"}),(0,e.jsxs)("div",{className:"grid grid-cols-1 tablet:grid-cols-2 laptop:grid-cols-3 desktop:grid-cols-4 gap-2 mt-2 tablet:gap-x-3 tablet:gap-y-4 laptop:gap-4",children:[(0,e.jsx)(s.Link,{asChild:!t?.advertisingLink,href:t?.advertisingLink,children:(0,e.jsxs)("div",{className:"relative [&_img]:hover:scale-105 [&_img]:hover:transition-all [&_img]:hover:duration-300",children:[(0,e.jsx)(s.Picture,{source:t?.advertisingBgImg?.url,className:"h-[114px] laptop:h-[120px]",imgClassName:"object-cover h-full"}),(0,e.jsxs)("div",{className:"absolute bottom-0 left-0 right-0 p-4",children:[(0,e.jsx)(s.Heading,{size:2,html:t?.advertisingTitle||"Buy in Guide",className:"font-bold text-white"}),(0,e.jsx)(s.Text,{html:t?.advertisingSubtitle||"20.000mAh",className:"text-sm text-white font-bold"})]})]})}),t?.hotProducts?.slice(0,7)?.map(a=>{const u=a?.custom_description,v=a?.badge||"",b=`/products/${a?.handle}?variant=${(0,c.atobID)(a?.shopify_id)}`;return(0,e.jsx)(y,{productImage:a?.image,productName:a?.name,productDesc:u,productBadge:v,listingLink:b},a.id)})]})]})]})})]})}),y=({productImage:t,productName:o,productDesc:r,productBadge:i,className:l,listingLink:d})=>(0,e.jsxs)("div",{className:(0,c.cn)("flex shrink-0 gap-4 bg-[#F5F5F7] px-4 py-3 [&_img]:hover:scale-105",l),children:[(0,e.jsx)("div",{className:"shrink-0",children:(0,e.jsx)(s.Picture,{source:t,width:90,height:90,className:"size-[96px]",imgClassName:"object-contain h-full"})}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("div",{className:" h-[24px] ",children:i&&(0,e.jsx)(s.Text,{as:"p",html:i,className:"text-brand-0 mb-1 inline-block rounded-full border-[1.6px] border-[#00BEFA] px-[6px] text-sm font-bold h-full !leading-[24px]"})}),(0,e.jsxs)("div",{children:[(0,e.jsx)(s.Link,{href:d,className:"no-underline hover:text-current",children:(0,e.jsx)(s.Text,{className:"lg-desktop:h-[44px] lg-desktop:text-base line-clamp-2 h-[40px] text-sm font-bold leading-[1.4]",html:o})}),r&&(0,e.jsx)(s.Text,{as:"p",html:r,className:"lg-desktop:text-sm line-clamp-1 mt-1 text-xs font-bold leading-[1.4] text-[#6D6D6F]"})]})]})]}),K=({data:t,keywords:o,locale:r})=>(0,e.jsx)("div",{className:"flex flex-wrap gap-3 laptop:gap-4",children:o?.map((i,l)=>(0,e.jsx)("a",{href:`${r==="us"?"":r}${t?.moreLink}?q=${i?.toLowerCase()}`,className:"text-sm cursor-pointer hover:bg-[#F5F5F7] p-2 laptop:p-3 desktop:p-4 leading-[1.4] font-bold",children:i},l))});var H=z;
|
|
10
|
+
`}),(0,e.jsxs)("div",{className:"navigation-search-component laptop:h-[52px] text-black desktop:h-[60px] flex items-center pt-4 desktop:pt-6 pb-4 justify-between border-b border-b-gray-200",children:[(0,e.jsx)("input",{value:n,onCompositionStart:()=>N(!0),onCompositionEnd:()=>N(!1),onKeyDown:P,onChange:a=>{F(a.target.value),a.target.value&&$(a.target.value)},type:"text",className:"text-sm bg-white basis-[200px] focus-visible:!outline-none outline-none leading-[1.4] font-bold",placeholder:t?.placeholder}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(h.Search,{className:"size-5 cursor-pointer",onClick:()=>o(n)}),(0,e.jsx)("div",{className:"w-[1px] h-[20px] bg-[#E4E5E6]"}),(0,e.jsx)(h.Close,{className:"size-5 cursor-pointer",onClick:r})]})]}),(0,e.jsx)("div",{className:"flex flex-col gap-6 desktop:gap-12 text-black desktop:py-6 py-4",children:k===m.SearchStatus.Predict?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(s.Text,{html:t?.suggestText,className:"text-sm text-[#6D6D6F] leading-[1.4] font-bold"}),i?.items?.length>6&&(0,e.jsx)(s.Button,{as:"a",href:`${g==="us"?"":g}${t?.moreLink}?q=${n.toLowerCase()}`,className:"!text-sm leading-[1.2] font-bold !p-0",variant:"link",children:t?.moreText})]}),(0,e.jsx)("div",{className:"flex flex-col mt-2",children:i?.items?.filter(a=>L(a)).slice(0,6)?.map(a=>(0,e.jsx)(s.Link,{className:"hover:bg-[#F5F5F7] hover:text-current no-underline w-full p-4",href:E(a),children:(0,e.jsx)(s.Text,{html:(0,c.highlightSearchWord)(a.title,n),className:"text-sm cursor-pointer leading-[1.4] font-bold"})},a.id))})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)(s.Text,{html:t?.hotProductsText,className:"text-sm text-[#6D6D6F] leading-[1.4] font-bold"}),(0,e.jsxs)("div",{className:"grid grid-cols-1 tablet:grid-cols-2 laptop:grid-cols-3 desktop:grid-cols-4 gap-2 mt-2 tablet:gap-x-3 tablet:gap-y-4 laptop:gap-4",children:[(0,e.jsx)(s.Link,{asChild:!t?.advertisingLink,href:t?.advertisingLink,children:(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)(s.Picture,{source:t?.advertisingBgImg?.url,className:"h-[114px] laptop:h-[120px]",imgClassName:"object-cover h-full"}),(0,e.jsxs)("div",{className:"absolute bottom-0 left-0 right-0 p-4",children:[(0,e.jsx)(s.Heading,{size:2,html:t?.advertisingTitle||"Buy in Guide",className:(0,c.cn)("font-bold text-white",{"text-black":t?.advertisingTheme==="dark"})}),(0,e.jsx)(s.Text,{html:t?.advertisingSubtitle||"20.000mAh",className:(0,c.cn)("text-sm text-white font-bold",{"text-black":t?.advertisingTheme==="dark"})})]})]})}),i?.items?.filter(a=>a.type.toLowerCase()==="product").slice(0,7)?.map(a=>{const u=a?.variants?.[0],v=`${u?.image?.url||a?.images?.[0]?.url}`,b=a?.title||a?.name,I=a?.description,T=a?.badge||"",A=`/products/${a?.handle}?variant=${(0,c.atobID)(u?.id)}`;return(0,e.jsx)(y,{productImage:v,productName:b,productDesc:I,productBadge:T,listingLink:A},a.id)})]})]})]}):(0,e.jsxs)(e.Fragment,{children:[k===m.SearchStatus.Empty&&(0,e.jsx)(s.Text,{html:t?.noResultText,as:"p",className:"text-sm pb-6 border-[#E4E5E6] border-b text-[#6D6D6F] leading-[1.4] font-bold"}),(0,e.jsxs)("div",{children:[(0,e.jsx)(s.Text,{html:t?.popularText,className:"text-sm text-[#6D6D6F] leading-[1.4] font-bold"}),(0,e.jsxs)("div",{className:"mt-2",children:[(0,e.jsx)(K,{data:t,keywords:S,locale:g}),Array.isArray(t?.popularPages)&&!!t?.popularPages?.length&&(0,e.jsx)(s.Grid,{className:"gap-3 laptop:gap-4 mt-3 laptop:mt-4",children:t?.popularPages?.map(a=>(0,e.jsx)(s.GridItem,{className:"col-span-12 tablet:col-span-6 p-2 hover:bg-[#F5F5F7] laptop:p-3 desktop:p-4 laptop:col-span-3",children:(0,e.jsx)("a",{href:`${g==="us"?"":g}${t?.moreLink}?q=${a?.popularPage.toLowerCase()}`,className:"text-sm cursor-pointer line-clamp-1 leading-[1.4] font-bold",children:a?.popularPage})},a?.id))})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)(s.Text,{html:t?.hotProductsText,className:"text-sm text-[#6D6D6F] leading-[1.4] font-bold"}),(0,e.jsxs)("div",{className:"grid grid-cols-1 tablet:grid-cols-2 laptop:grid-cols-3 desktop:grid-cols-4 gap-2 mt-2 tablet:gap-x-3 tablet:gap-y-4 laptop:gap-4",children:[(0,e.jsx)(s.Link,{asChild:!t?.advertisingLink,href:t?.advertisingLink,children:(0,e.jsxs)("div",{className:"relative [&_img]:hover:scale-105 [&_img]:hover:transition-all [&_img]:hover:duration-300",children:[(0,e.jsx)(s.Picture,{source:t?.advertisingBgImg?.url,className:"h-[114px] laptop:h-[120px]",imgClassName:"object-cover h-full"}),(0,e.jsxs)("div",{className:"absolute bottom-0 left-0 right-0 p-4",children:[(0,e.jsx)(s.Heading,{size:2,html:t?.advertisingTitle||"Buy in Guide",className:"font-bold text-white"}),(0,e.jsx)(s.Text,{html:t?.advertisingSubtitle||"20.000mAh",className:"text-sm text-white font-bold"})]})]})}),t?.hotProducts?.slice(0,7)?.map(a=>{const u=a?.custom_description,v=a?.badge||"",b=`/products/${a?.handle}?variant=${(0,c.atobID)(a?.shopify_id)}`;return(0,e.jsx)(y,{productImage:a?.image,productName:a?.name,productDesc:u,productBadge:v,listingLink:b},a.id)})]})]})]})})]})}),y=({productImage:t,productName:o,productDesc:r,productBadge:i,className:l,listingLink:d})=>(0,e.jsxs)("div",{className:(0,c.cn)("flex shrink-0 gap-4 bg-[#F5F5F7] px-4 py-3 [&_img]:hover:scale-105",l),children:[(0,e.jsx)("div",{className:"shrink-0",children:(0,e.jsx)(s.Picture,{source:t,width:90,height:90,className:"size-[96px]",imgClassName:"object-contain h-full"})}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("div",{className:" h-[24px] ",children:i&&(0,e.jsx)(s.Text,{as:"p",html:i,className:"text-brand-0 mb-1 inline-block rounded-full border-[1.6px] border-[#00BEFA] px-[6px] text-sm font-bold h-full !leading-[24px]"})}),(0,e.jsxs)("div",{children:[(0,e.jsx)(s.Link,{href:d,className:"no-underline hover:text-current",children:(0,e.jsx)(s.Text,{className:"lg-desktop:h-[44px] lg-desktop:text-base line-clamp-2 h-[40px] text-sm font-bold leading-[1.4]",html:o})}),r&&(0,e.jsx)(s.Text,{as:"p",html:r,className:"lg-desktop:text-sm line-clamp-1 mt-1 text-xs font-bold leading-[1.4] text-[#6D6D6F]"})]})]})]}),K=({data:t,keywords:o,locale:r})=>(0,e.jsx)("div",{className:"flex flex-wrap gap-3 laptop:gap-4",children:o?.map((i,l)=>(0,e.jsx)("a",{href:`${r==="us"?"":r}${t?.moreLink}?q=${i?.toLowerCase()}`,className:"text-sm cursor-pointer hover:bg-[#F5F5F7] p-2 laptop:p-3 desktop:p-4 leading-[1.4] font-bold",children:i},l))});var H=z;
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/NavigationSearch/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { 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 onSearch(searchValue)\n }\n },\n [isComposing, searchValue, onSearch]\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 switch (item.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])\n\n return (\n <Container childClassName=\"!bg-white\" className=\"relative\" ref={ref}>\n <style jsx global>\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] text-black desktop:h-[60px] flex items-center pt-4 desktop:pt-6 pb-4 justify-between border-b border-b-gray-200\">\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=\"text-sm basis-[200px] focus-visible:!outline-none outline-none leading-[1.4] font-bold\"\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=\"w-[1px] h-[20px] bg-[#E4E5E6]\" />\n <CloseIcon className=\"size-5 cursor-pointer\" onClick={onClose} />\n </div>\n </div>\n\n <div className=\"flex flex-col gap-6 desktop:gap-12 text-black desktop:py-6 py-4\">\n {searchStatus === SearchStatus.Predict ? (\n <>\n <div>\n <div className=\"flex items-center gap-2\">\n <Text html={data?.suggestText} className=\"text-sm text-[#6D6D6F] leading-[1.4] font-bold\" />\n {searchResult?.items?.length > 6 && (\n <Button\n as=\"a\"\n href={`${locale === 'us' ? '' : locale}${data?.moreLink}?q=${searchValue.toLowerCase()}`}\n className=\"!text-sm leading-[1.2] font-bold !p-0\"\n variant=\"link\"\n >\n {data?.moreText}\n </Button>\n )}\n </div>\n <div className=\"flex flex-col mt-2\">\n {searchResult?.items\n ?.filter((item: any) => canSearch(item))\n .slice(0, 6)\n ?.map((item: any) => (\n <Link\n className=\"hover:bg-[#F5F5F7] hover:text-current no-underline w-full p-4\"\n href={getLink(item)}\n key={item.id}\n >\n <Text\n html={highlightSearchWord(item.title, searchValue)}\n className=\"text-sm cursor-pointer leading-[1.4] font-bold\"\n />\n </Link>\n ))}\n </div>\n </div>\n <div>\n <Text html={data?.hotProductsText} className=\"text-sm text-[#6D6D6F] leading-[1.4] font-bold\" />\n <div className=\"grid grid-cols-1 tablet:grid-cols-2 laptop:grid-cols-3 desktop:grid-cols-4 gap-2 mt-2 tablet:gap-x-3 tablet:gap-y-4 laptop:gap-4\">\n <Link asChild={!data?.advertisingLink} href={data?.advertisingLink}>\n <div className=\"relative\">\n <Picture\n source={data?.advertisingBgImg?.url}\n className=\"h-[114px] laptop:h-[120px]\"\n imgClassName=\"object-cover h-full\"\n />\n <div className=\"absolute bottom-0 left-0 right-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 text-white font-bold', {\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=\"text-sm pb-6 border-[#E4E5E6] border-b text-[#6D6D6F] leading-[1.4] font-bold\"\n />\n )}\n <div>\n <Text html={data?.popularText} className=\"text-sm text-[#6D6D6F] leading-[1.4] font-bold\" />\n <div className=\"mt-2\">\n <SearchKeyword data={data} keywords={searchKeywords} locale={locale} />\n {Array.isArray(data?.popularPages) && !!data?.popularPages?.length && (\n <Grid className=\"gap-3 laptop:gap-4 mt-3 laptop:mt-4\">\n {data?.popularPages?.map((item: any) => (\n <GridItem\n key={item?.id}\n className=\"col-span-12 tablet:col-span-6 p-2 hover:bg-[#F5F5F7] laptop:p-3 desktop:p-4 laptop:col-span-3\"\n >\n <a\n href={`${locale === 'us' ? '' : locale}${data?.moreLink}?q=${item?.popularPage.toLowerCase()}`}\n className=\"text-sm cursor-pointer line-clamp-1 leading-[1.4] font-bold\"\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 text-[#6D6D6F] leading-[1.4] font-bold\" />\n <div className=\"grid grid-cols-1 tablet:grid-cols-2 laptop:grid-cols-3 desktop:grid-cols-4 gap-2 mt-2 tablet:gap-x-3 tablet:gap-y-4 laptop:gap-4\">\n <Link asChild={!data?.advertisingLink} href={data?.advertisingLink}>\n <div className=\"relative [&_img]:hover:scale-105 [&_img]:hover:transition-all [&_img]:hover:duration-300\">\n <Picture\n source={data?.advertisingBgImg?.url}\n className=\"h-[114px] laptop:h-[120px]\"\n imgClassName=\"object-cover h-full\"\n />\n <div className=\"absolute bottom-0 left-0 right-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 text-white font-bold\"\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\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 <div className={cn('flex shrink-0 gap-4 bg-[#F5F5F7] px-4 py-3 [&_img]:hover:scale-105', className)}>\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 rounded-full border-[1.6px] border-[#00BEFA] px-[6px] text-sm font-bold h-full !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 line-clamp-1 mt-1 text-xs font-bold leading-[1.4] text-[#6D6D6F]\"\n />\n )}\n </div>\n </div>\n </div>\n )\n}\n\nconst SearchKeyword = ({ data, keywords, locale }: { data: any; keywords: any[]; locale: string }) => {\n return (\n <div className=\"flex flex-wrap gap-3 laptop:gap-4\">\n {keywords?.map((keyword: any, index) => (\n <a\n href={`${locale === 'us' ? '' : locale}${data?.moreLink}?q=${keyword?.toLowerCase()}`}\n key={index}\n className=\"text-sm cursor-pointer hover:bg-[#F5F5F7] p-2 laptop:p-3 desktop:p-4 leading-[1.4] font-bold\"\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,GA8EQ,IAAAK,EAAA,6BA9ERC,EAAgF,qCAChFC,EAAyD,8CACzDC,EAA2D,iBAE3DC,EAA+B,oCAE/BC,EAA6B,sBAE7BC,EAAyB,sBACzBC,EAAgD,kCAEzC,MAAMV,EAAaW,GACjB,EACLA,EAAO,YAAY,QAAQ,YAC3BA,EAAO,YAAY,KAAK,QACxBA,EAAO,YAAY,KAAK,SAAS,SAI/BC,KAAmB,cACvB,CAAC,CAAE,KAAAC,EAAM,SAAAC,EAAU,QAAAC,EAAS,aAAAC,EAAc,YAAAC,EAAa,SAAAC,CAAS,EAAGC,IAAQ,CACzE,KAAM,CAAE,OAAAC,EAAS,KAAM,YAAAC,CAAY,KAAI,kBAAe,EAEhD,CAACC,EAAaC,CAAc,KAAI,YAAS,EAAE,EAC3C,CAACC,EAAaC,CAAc,KAAI,YAAS,EAAK,EAE9CC,KAAoB,YAAUC,GAAkB,CACpDb,EAASa,CAAK,CAChB,EAAG,GAAG,EAEAC,KAAgB,eACnBC,GAA6C,CACxCA,EAAE,MAAQ,SAAW,CAACL,GACxBV,EAASQ,CAAW,CAExB,EACA,CAACE,EAAaF,EAAaR,CAAQ,CACrC,EAEMgB,KAAiB,WAAQ,IACzB,MAAM,QAAQZ,CAAQ,GAAKA,GAAU,OAChCA,EAAS,IAAKa,GAAiBA,EAAQ,WAAW,EAEvD,MAAM,QAAQlB,GAAM,YAAY,GAAKA,GAAM,cAAc,OACpDA,GAAM,aAAa,IAAKmB,GAAcA,EAAK,WAAW,EAExD,CAAC,EACP,CAACd,EAAUL,GAAM,YAAY,CAAC,EAE3BoB,KAAU,eACbC,GAAc,CACb,OAAQA,EAAK,KAAM,CACjB,IAAK,UACH,MAAO,YAAYA,EAAK,IAAI,MAAMZ,EAAY,YAAY,CAAC,GAC7D,IAAK,UACH,MAAO,UAAUY,EAAK,KAAK,MAAM,IAAIA,EAAK,OAAO,QAAQ,cAAe,EAAE,CAAC,MAAMZ,EAAY,YAAY,CAAC,GAC5G,QACE,KACJ,CACF,EACA,CAACA,CAAW,CACd,EAEMa,KAAe,WAAQ,IAAM,CACjC,GAAKb,EAGE,IAAIN,GAAc,WAEvB,OAAO,eAAa,QACf,GAAI,CAACC,EAEV,OAAO,eAAa,UANpB,QAAO,eAAa,OAQxB,EAAG,CAACD,GAAc,WAAYM,CAAW,CAAC,EAE1C,SACE,QAAC,aAAU,eAAe,YAAY,UAAU,WAAW,IAAKH,EAC9D,oBAAC,SAAM,IAAG,GAAC,OAAM,GACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAUH,KACA,QAAC,OAAI,UAAU,8JACb,oBAAC,SACC,MAAOG,EACP,mBAAoB,IAAMG,EAAe,EAAI,EAC7C,iBAAkB,IAAMA,EAAe,EAAK,EAC5C,UAAWG,EACX,SAAUC,GAAK,CACbN,EAAeM,EAAE,OAAO,KAAK,EACzBA,EAAE,OAAO,OACXH,EAAkBG,EAAE,OAAO,KAAK,CAEpC,EACA,KAAK,OACL,UAAU,
|
|
4
|
+
"sourcesContent": ["import { 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 onSearch(searchValue)\n }\n },\n [isComposing, searchValue, onSearch]\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 switch (item.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])\n\n return (\n <Container childClassName=\"!bg-white\" className=\"relative\" ref={ref}>\n <style jsx global>\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] text-black desktop:h-[60px] flex items-center pt-4 desktop:pt-6 pb-4 justify-between border-b border-b-gray-200\">\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=\"text-sm bg-white basis-[200px] focus-visible:!outline-none outline-none leading-[1.4] font-bold\"\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=\"w-[1px] h-[20px] bg-[#E4E5E6]\" />\n <CloseIcon className=\"size-5 cursor-pointer\" onClick={onClose} />\n </div>\n </div>\n\n <div className=\"flex flex-col gap-6 desktop:gap-12 text-black desktop:py-6 py-4\">\n {searchStatus === SearchStatus.Predict ? (\n <>\n <div>\n <div className=\"flex items-center gap-2\">\n <Text html={data?.suggestText} className=\"text-sm text-[#6D6D6F] leading-[1.4] font-bold\" />\n {searchResult?.items?.length > 6 && (\n <Button\n as=\"a\"\n href={`${locale === 'us' ? '' : locale}${data?.moreLink}?q=${searchValue.toLowerCase()}`}\n className=\"!text-sm leading-[1.2] font-bold !p-0\"\n variant=\"link\"\n >\n {data?.moreText}\n </Button>\n )}\n </div>\n <div className=\"flex flex-col mt-2\">\n {searchResult?.items\n ?.filter((item: any) => canSearch(item))\n .slice(0, 6)\n ?.map((item: any) => (\n <Link\n className=\"hover:bg-[#F5F5F7] hover:text-current no-underline w-full p-4\"\n href={getLink(item)}\n key={item.id}\n >\n <Text\n html={highlightSearchWord(item.title, searchValue)}\n className=\"text-sm cursor-pointer leading-[1.4] font-bold\"\n />\n </Link>\n ))}\n </div>\n </div>\n <div>\n <Text html={data?.hotProductsText} className=\"text-sm text-[#6D6D6F] leading-[1.4] font-bold\" />\n <div className=\"grid grid-cols-1 tablet:grid-cols-2 laptop:grid-cols-3 desktop:grid-cols-4 gap-2 mt-2 tablet:gap-x-3 tablet:gap-y-4 laptop:gap-4\">\n <Link asChild={!data?.advertisingLink} href={data?.advertisingLink}>\n <div className=\"relative\">\n <Picture\n source={data?.advertisingBgImg?.url}\n className=\"h-[114px] laptop:h-[120px]\"\n imgClassName=\"object-cover h-full\"\n />\n <div className=\"absolute bottom-0 left-0 right-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 text-white font-bold', {\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=\"text-sm pb-6 border-[#E4E5E6] border-b text-[#6D6D6F] leading-[1.4] font-bold\"\n />\n )}\n <div>\n <Text html={data?.popularText} className=\"text-sm text-[#6D6D6F] leading-[1.4] font-bold\" />\n <div className=\"mt-2\">\n <SearchKeyword data={data} keywords={searchKeywords} locale={locale} />\n {Array.isArray(data?.popularPages) && !!data?.popularPages?.length && (\n <Grid className=\"gap-3 laptop:gap-4 mt-3 laptop:mt-4\">\n {data?.popularPages?.map((item: any) => (\n <GridItem\n key={item?.id}\n className=\"col-span-12 tablet:col-span-6 p-2 hover:bg-[#F5F5F7] laptop:p-3 desktop:p-4 laptop:col-span-3\"\n >\n <a\n href={`${locale === 'us' ? '' : locale}${data?.moreLink}?q=${item?.popularPage.toLowerCase()}`}\n className=\"text-sm cursor-pointer line-clamp-1 leading-[1.4] font-bold\"\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 text-[#6D6D6F] leading-[1.4] font-bold\" />\n <div className=\"grid grid-cols-1 tablet:grid-cols-2 laptop:grid-cols-3 desktop:grid-cols-4 gap-2 mt-2 tablet:gap-x-3 tablet:gap-y-4 laptop:gap-4\">\n <Link asChild={!data?.advertisingLink} href={data?.advertisingLink}>\n <div className=\"relative [&_img]:hover:scale-105 [&_img]:hover:transition-all [&_img]:hover:duration-300\">\n <Picture\n source={data?.advertisingBgImg?.url}\n className=\"h-[114px] laptop:h-[120px]\"\n imgClassName=\"object-cover h-full\"\n />\n <div className=\"absolute bottom-0 left-0 right-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 text-white font-bold\"\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\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 <div className={cn('flex shrink-0 gap-4 bg-[#F5F5F7] px-4 py-3 [&_img]:hover:scale-105', className)}>\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 rounded-full border-[1.6px] border-[#00BEFA] px-[6px] text-sm font-bold h-full !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 line-clamp-1 mt-1 text-xs font-bold leading-[1.4] text-[#6D6D6F]\"\n />\n )}\n </div>\n </div>\n </div>\n )\n}\n\nconst SearchKeyword = ({ data, keywords, locale }: { data: any; keywords: any[]; locale: string }) => {\n return (\n <div className=\"flex flex-wrap gap-3 laptop:gap-4\">\n {keywords?.map((keyword: any, index) => (\n <a\n href={`${locale === 'us' ? '' : locale}${data?.moreLink}?q=${keyword?.toLowerCase()}`}\n key={index}\n className=\"text-sm cursor-pointer hover:bg-[#F5F5F7] p-2 laptop:p-3 desktop:p-4 leading-[1.4] font-bold\"\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,GA8EQ,IAAAK,EAAA,6BA9ERC,EAAgF,qCAChFC,EAAyD,8CACzDC,EAA2D,iBAE3DC,EAA+B,oCAE/BC,EAA6B,sBAE7BC,EAAyB,sBACzBC,EAAgD,kCAEzC,MAAMV,EAAaW,GACjB,EACLA,EAAO,YAAY,QAAQ,YAC3BA,EAAO,YAAY,KAAK,QACxBA,EAAO,YAAY,KAAK,SAAS,SAI/BC,KAAmB,cACvB,CAAC,CAAE,KAAAC,EAAM,SAAAC,EAAU,QAAAC,EAAS,aAAAC,EAAc,YAAAC,EAAa,SAAAC,CAAS,EAAGC,IAAQ,CACzE,KAAM,CAAE,OAAAC,EAAS,KAAM,YAAAC,CAAY,KAAI,kBAAe,EAEhD,CAACC,EAAaC,CAAc,KAAI,YAAS,EAAE,EAC3C,CAACC,EAAaC,CAAc,KAAI,YAAS,EAAK,EAE9CC,KAAoB,YAAUC,GAAkB,CACpDb,EAASa,CAAK,CAChB,EAAG,GAAG,EAEAC,KAAgB,eACnBC,GAA6C,CACxCA,EAAE,MAAQ,SAAW,CAACL,GACxBV,EAASQ,CAAW,CAExB,EACA,CAACE,EAAaF,EAAaR,CAAQ,CACrC,EAEMgB,KAAiB,WAAQ,IACzB,MAAM,QAAQZ,CAAQ,GAAKA,GAAU,OAChCA,EAAS,IAAKa,GAAiBA,EAAQ,WAAW,EAEvD,MAAM,QAAQlB,GAAM,YAAY,GAAKA,GAAM,cAAc,OACpDA,GAAM,aAAa,IAAKmB,GAAcA,EAAK,WAAW,EAExD,CAAC,EACP,CAACd,EAAUL,GAAM,YAAY,CAAC,EAE3BoB,KAAU,eACbC,GAAc,CACb,OAAQA,EAAK,KAAM,CACjB,IAAK,UACH,MAAO,YAAYA,EAAK,IAAI,MAAMZ,EAAY,YAAY,CAAC,GAC7D,IAAK,UACH,MAAO,UAAUY,EAAK,KAAK,MAAM,IAAIA,EAAK,OAAO,QAAQ,cAAe,EAAE,CAAC,MAAMZ,EAAY,YAAY,CAAC,GAC5G,QACE,KACJ,CACF,EACA,CAACA,CAAW,CACd,EAEMa,KAAe,WAAQ,IAAM,CACjC,GAAKb,EAGE,IAAIN,GAAc,WAEvB,OAAO,eAAa,QACf,GAAI,CAACC,EAEV,OAAO,eAAa,UANpB,QAAO,eAAa,OAQxB,EAAG,CAACD,GAAc,WAAYM,CAAW,CAAC,EAE1C,SACE,QAAC,aAAU,eAAe,YAAY,UAAU,WAAW,IAAKH,EAC9D,oBAAC,SAAM,IAAG,GAAC,OAAM,GACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAUH,KACA,QAAC,OAAI,UAAU,8JACb,oBAAC,SACC,MAAOG,EACP,mBAAoB,IAAMG,EAAe,EAAI,EAC7C,iBAAkB,IAAMA,EAAe,EAAK,EAC5C,UAAWG,EACX,SAAUC,GAAK,CACbN,EAAeM,EAAE,OAAO,KAAK,EACzBA,EAAE,OAAO,OACXH,EAAkBG,EAAE,OAAO,KAAK,CAEpC,EACA,KAAK,OACL,UAAU,kGACV,YAAahB,GAAM,YACrB,KACA,QAAC,OAAI,UAAU,0BACb,oBAAC,EAAAuB,OAAA,CAAW,UAAU,wBAAwB,QAAS,IAAMtB,EAASQ,CAAW,EAAG,KACpF,OAAC,OAAI,UAAU,gCAAgC,KAC/C,OAAC,EAAAe,MAAA,CAAU,UAAU,wBAAwB,QAAStB,EAAS,GACjE,GACF,KAEA,OAAC,OAAI,UAAU,kEACZ,SAAAoB,IAAiB,eAAa,WAC7B,oBACE,qBAAC,OACC,qBAAC,OAAI,UAAU,0BACb,oBAAC,QAAK,KAAMtB,GAAM,YAAa,UAAU,iDAAiD,EACzFG,GAAc,OAAO,OAAS,MAC7B,OAAC,UACC,GAAG,IACH,KAAM,GAAGI,IAAW,KAAO,GAAKA,CAAM,GAAGP,GAAM,QAAQ,MAAMS,EAAY,YAAY,CAAC,GACtF,UAAU,wCACV,QAAQ,OAEP,SAAAT,GAAM,SACT,GAEJ,KACA,OAAC,OAAI,UAAU,qBACZ,SAAAG,GAAc,OACX,OAAQkB,GAAclC,EAAUkC,CAAI,CAAC,EACtC,MAAM,EAAG,CAAC,GACT,IAAKA,MACL,OAAC,QACC,UAAU,gEACV,KAAMD,EAAQC,CAAI,EAGlB,mBAAC,QACC,QAAM,uBAAoBA,EAAK,MAAOZ,CAAW,EACjD,UAAU,iDACZ,GALKY,EAAK,EAMZ,CACD,EACL,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,WACb,oBAAC,WACC,OAAQA,GAAM,kBAAkB,IAChC,UAAU,6BACV,aAAa,sBACf,KACA,QAAC,OAAI,UAAU,uCACb,oBAAC,WACC,KAAM,EACN,KAAMA,GAAM,kBAAoB,eAChC,aAAW,MAAG,uBAAwB,CACpC,aAAcA,GAAM,mBAAqB,MAC3C,CAAC,EACH,KACA,OAAC,QACC,KAAMA,GAAM,qBAAuB,YACnC,aAAW,MAAG,+BAAgC,CAC5C,aAAcA,GAAM,mBAAqB,MAC3C,CAAC,EACH,GACF,GACF,EACF,EACCG,GAAc,OACX,OAAQkB,GAAcA,EAAK,KAAK,YAAY,IAAM,SAAS,EAC5D,MAAM,EAAG,CAAC,GACT,IAAKA,GAAc,CACnB,MAAMI,EAAUJ,GAAM,WAAW,CAAC,EAC5BK,EAAe,GAAGD,GAAS,OAAO,KAAOJ,GAAM,SAAS,CAAC,GAAG,GAAG,GAC/DM,EAAcN,GAAM,OAASA,GAAM,KACnCO,EAAcP,GAAM,YACpBQ,EAAeR,GAAM,OAAS,GAC9BS,EAAc,aAAaT,GAAM,MAAM,eAAY,UAAOI,GAAS,EAAY,CAAC,GACtF,SACE,OAACM,EAAA,CACC,aAAcL,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,2FACb,oBAAC,WACC,OAAQA,GAAM,kBAAkB,IAChC,UAAU,6BACV,aAAa,sBACf,KACA,QAAC,OAAI,UAAU,uCACb,oBAAC,WACC,KAAM,EACN,KAAMA,GAAM,kBAAoB,eAChC,UAAU,uBACZ,KACA,OAAC,QACC,KAAMA,GAAM,qBAAuB,YACnC,UAAU,+BACZ,GACF,GACF,EACF,EACCA,GAAM,aAAa,MAAM,EAAG,CAAC,GAAG,IAAKqB,GAAc,CAClD,MAAMO,EAAcP,GAAM,mBACpBQ,EAAeR,GAAM,OAAS,GAC9BS,EAAc,aAAaT,GAAM,MAAM,eAAY,UAAOA,GAAM,UAAoB,CAAC,GAC3F,SACE,OAACU,EAAA,CACC,aAAcV,GAAM,MACpB,YAAaA,GAAM,KACnB,YAAaO,EACb,aAAcC,EACd,YAAaC,GACRT,EAAK,EACZ,CAEJ,CAAC,GACH,GACF,GACF,EAEJ,GACF,CAEJ,CACF,EAEMU,EAAgB,CAAC,CACrB,aAAAL,EACA,YAAAC,EACA,YAAAC,EACA,aAAAC,EACA,UAAAI,EACA,YAAAH,CACF,OASI,QAAC,OAAI,aAAW,MAAG,qEAAsEG,CAAS,EAChG,oBAAC,OAAI,UAAU,WACb,mBAAC,WACC,OAAQP,EACR,MAAO,GACP,OAAQ,GACR,UAAU,cACV,aAAa,wBACf,EACF,KACA,QAAC,OAAI,UAAU,WACb,oBAAC,OAAI,UAAU,aACZ,SAAAG,MACC,OAAC,QACC,GAAG,IACH,KAAMA,EACN,UAAU,gIACZ,EAEJ,KACA,QAAC,OACC,oBAAC,QAAK,KAAMC,EAAa,UAAU,kCACjC,mBAAC,QACC,UAAU,iGACV,KAAMH,EACR,EACF,EACCC,MACC,OAAC,QACC,GAAG,IACH,KAAMA,EACN,UAAU,sFACZ,GAEJ,GACF,GACF,EAIEI,EAAgB,CAAC,CAAE,KAAAhC,EAAM,SAAAK,EAAU,OAAAE,CAAO,OAE5C,OAAC,OAAI,UAAU,oCACZ,SAAAF,GAAU,IAAI,CAACa,EAAcgB,OAC5B,OAAC,KACC,KAAM,GAAG3B,IAAW,KAAO,GAAKA,CAAM,GAAGP,GAAM,QAAQ,MAAMkB,GAAS,YAAY,CAAC,GAEnF,UAAU,+FAET,SAAAA,GAHIgB,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 client";import{Fragment as J,jsx as e,jsxs as n}from"react/jsx-runtime";import xe,{forwardRef as X,useCallback as _,useEffect as E,useImperativeHandle as Ne,useMemo as M,useRef as R,useState as D}from"react";import{Picture as K,Text as f,Button as B,Container as Y,Link as F,Heading as oe}from"../../components/index.js";import{withLayout as ke}from"../../shared/Styles.js";import{cn as x,atobID as we}from"../../helpers/utils.js";import Ce,{useNavContext as O}from"./NavProvider.js";import{HeaderNavigationMenu as T,HeaderNavigationBlockType as j,HeaderNavigationActionBlockType as I}from"./types.js";import"react-responsive";import{debounce as Se}from"es-toolkit";import Me from"jump.js";import{useGSAP as ne}from"@gsap/react";import{gsap as le}from"gsap";import{WithSidebar as se,WithSupports as re,WithMulticol as ie,WithGroupCategory as ce}from"./withCategory.js";import{Menu as De,Close as de,User as Le,RightArrow as Pe,LeftArrow as ze,DownArrow as Z,Polygon as Ee}from"./icons/index.js";import He from"../NavigationSearch/index.js";const Be=X((t,a)=>{const{data:{headerNavigation:l}={},buildProps:o,event:s,profile:c,theme:y="light",isTop:r=!1,searchResult:v,onSearch:N,isSearching:L,keywords:h}=t,u=R(null),[d,m]=D(!1),[p,i]=D(!1),[g,S]=D(!1),[C,P]=D(!1),k=R(null),A=()=>{const w=document?.querySelector("body")?.offsetWidth||0;P(w<=1440)};E(()=>(A(),window.addEventListener("resize",A),()=>{window.removeEventListener("resize",A)}),[]),Ne(a,()=>k.current),E(()=>{k.current&&r&&Me(k.current,{duration:0,offset:k.current?.getBoundingClientRect()?.bottom||0})},[r]),E(()=>{s&&(s.search=()=>m(!0))},[s]),ne(()=>{u?.current&&d&&le.fromTo(u.current,{height:0},{height:"auto",duration:.3})},[d]),E(()=>{document.documentElement.style.overflow=d?"hidden":"auto"},[d]);const W=M(()=>l?.headerBar?.actions?.find(w=>w?.blockType===I.Search)?.searchBar?.[0]||{},[l]);return e(Ce,{buildProps:o,profile:c,isMobile:C,event:s,payloadData:l,children:e("header",{"data-ui-component-id":"HeaderNavigation",className:"relative z-[100]",ref:k,children:n("div",{className:x("hover:text-black hover:bg-white",y==="light"?"text-black":"text-white",{}),onClick:()=>S(!0),children:[e(Te,{data:l,className:"hidden desktop:block",theme:y,onNavItemClick:()=>S(!0)}),e(Fe,{data:l,className:"block desktop:hidden"}),d&&n("div",{className:"absolute z-[60] top-0 left-0 w-full bg-black/70 flex flex-col",style:{height:`calc(100dvh - ${k?.current?.getBoundingClientRect()?.top}px)`},children:[e("div",{ref:u,className:x("overflow-y-auto",{}),children:e(He,{data:W,keywords:h,isSearching:L,searchResult:v,onSearch:w=>{N?.(w)},onClose:()=>{N?.(),m(!1)}})}),e("div",{className:"flex-1 bg-transparent",onClick:()=>m(!1)})]})]})})})}),Te=X((t,a)=>{const{data:l,onNavItemClick:o,className:s,theme:c}=t,{event:y,profile:r}=O(),[v,N]=D(!1),L=M(()=>ce(l?.categories?.filter(b=>b?.pcShow)),[l]),[h,u]=D(null),[d,m]=D([]),p=R(null),[i,g]=D(!1),S=R(null),C=R(null),P=R(L.map(b=>Array(b?.length||0).fill(null)));E(()=>{L?.length&&m(L?.map((b,z)=>b?.map((H,$)=>({groupIndex:z,index:$,open:!1}))))},[L]);const k=M(()=>{let b=null;for(const z of d){for(const H of z)if(H.open){b=H;break}if(b)break}return b},[d]);E(()=>{document.documentElement.style.overflow=k?.open||i?"hidden":"auto"},[k?.open,i]);const A=(b,z,H)=>{g(!1),h?.components?.[0]?.blockType===j.Links?h?.components?.[0]?.url&&window.open(h?.components?.[0]?.url):(b.stopPropagation(),o?.(),u(L[z][H]),m($=>$.map(V=>V.map(q=>q.groupIndex===z&&q.index===H?{...q,open:!q.open}:{...q,open:!1}))))},W=()=>{m(b=>b.map(z=>z.map(H=>({...H,open:!1}))))},w=M(()=>{if(h)return h?.components?.[0]?.blockType},[h]),ee=se(Re,h),U=ie(Ae,h),he=re($e,{categoriesItem:h,currentNavItemRef:P.current?.[k?.groupIndex||0]?.[k?.index||0]}),ye=M(()=>{switch(w){case j.Sidebar:return e(ee,{});case j.Supports:return e(he,{});case j.Multicol:return e(U,{});default:return null}},[w,h]),te=M(()=>l?.headerBar?.actions?.filter(b=>b?.pcShow),[l]),G=M(()=>te?.find(b=>b?.blockType===I.Profile),[te]),ae=_(()=>{g(b=>!b)},[]);return E(()=>{if(p?.current){const b=p.current;return b.addEventListener("click",ae),()=>{b.removeEventListener("click",ae)}}},[ae]),ne(()=>{k?.open&&le.fromTo(C?.current,{height:0},{height:"auto"})},[k?.open]),n(Y,{className:x("relative h-[96px]",s),children:[n("div",{ref:S,onClick:W,className:"flex h-full flex-col justify-end gap-4",children:[n("div",{className:"flex items-center justify-between",children:[e(fe,{}),e(ve,{ref:p,actions:te,activeStatus:i})]}),e("div",{className:"flex justify-between",children:L?.map((b,z)=>e("div",{className:"flex gap-3",children:b?.map((H,$)=>e("div",{ref:V=>{P.current[z][$]=V},className:"group cursor-pointer",children:n("div",{className:"relative",children:[n("div",{className:"flex items-center gap-1 pb-4",onClick:V=>A(V,z,$),children:[e(f,{html:H.text,className:"text-sm font-bold leading-[1.4]"}),e(Z,{className:x("opacity-0 size-4 group-hover:opacity-100 transition-opacity duration-500",{"rotate-180":k?.groupIndex===z&&k?.index===$,"opacity-100":v&&k?.groupIndex===z&&k?.index===$})})]}),e("div",{className:x("absolute bottom-0 left-0 h-[2px] w-0 transition-all duration-500",{"w-[calc(100%-20px)]":k?.groupIndex===z&&k?.index===$},c==="dark"?"bg-white":"bg-[#1D1D1F]")})]})},H.id))},`groupCategory-${z}`))})]}),n("div",{className:x("border-t border-b-[#E4E5E6] text-black absolute left-0 top-full z-[999] flex w-full flex-col bg-black/70 overflow-hidden",{hidden:!(k?.open&&h)}),onMouseEnter:()=>N(!0),onMouseLeave:()=>N(!1),style:{height:`calc(100dvh - ${S?.current?.getBoundingClientRect()?.bottom}px)`},children:[e("div",{ref:C,className:x("relative z-50",{"overflow-hidden":w!==j.Supports}),children:ye}),e("div",{className:"flex-1 bg-transparent",onClick:W})]}),i&&n("div",{className:"absolute left-0 z-[999] flex w-full bg-black/70 h-[100dvh] top-full",children:[e("div",{className:"absolute w-[272px] bg-white p-4",style:{right:`calc(100% - ${p?.current?.getBoundingClientRect()?.right}px)`,top:"-36px"},children:r?.email?n(J,{children:[e(f,{html:r?.nick_name||G?.welcome,className:"text-sm font-bold"}),e("div",{className:"h-[1px] mt-2 bg-[#D9D9D9]"}),e("div",{className:"mt-2",children:G?.profiles?.map(b=>e(Q,{className:"py-2",label:b?.title,href:b?.url},b.id))})]}):n(J,{children:[e(Ee,{className:"absolute -top-2 text-white right-[46px] z-30"}),e(f,{html:G?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),e("div",{className:"mt-2 flex flex-col gap-1",children:G?.benefits?.map(b=>n("div",{className:"flex items-center gap-[6px]",children:[e(K,{source:b.benefitIcon?.url,className:"size-4",alt:b.benefit,width:16,height:16}),e(f,{html:b.benefit,className:"text-sm font-bold leading-[1.4]"})]},b.id))}),n("div",{className:"mt-4 flex items-center gap-2",children:[e(B,{variant:"secondary",size:"lg",onClick:()=>y?.join?.(),children:e(f,{html:G?.primaryButton||"Join Now",className:"font-bold"})}),e(B,{variant:"primary",size:"lg",onClick:()=>y?.login?.(),children:e(f,{html:G?.secondaryButton||"Log In",className:"font-bold"})})]})]})}),e("div",{className:"flex-1 bg-transparent",onClick:()=>g(!1)})]})]})}),Re=xe.memo(({sidebarCategoriesMetadata:t,seriesMetadata:a})=>{const{buildProps:l}=O(),[o,s]=D([]),[c,y]=D(-1),r=R(null),v=_(()=>{const u=t?.subcategories;if(!u?.length)return;const d=u.findIndex(i=>!!i?.subSubCategories),m=u.findIndex(i=>!i?.subSubCategories),p=u.map((i,g)=>({index:g,open:d===g||m===g}));s(p)},[t]);E(()=>{v()},[v]);const N=M(()=>{const u=t?.subcategories?.[o?.find(m=>m.open)?.index||0],d=a?.find(m=>m?.label?.toLowerCase()===u?.label?.toLowerCase())||{};if(u?.collections){const m=l?.categories?.[u?.collections]||{};return{label:d?.label,isCollection:!0,banner:d?.banner,primary:d?.primary,series:[{products:m?.products}]}}else if(u?.subSubCategories){const m=u?.subSubCategories?.[c],p=a?.find(i=>i?.label?.toLowerCase()===m?.label?.toLowerCase())||{};if(m?.collections){const i=l?.categories?.[m?.collections]||{};return{label:p?.label,isCollection:!0,banner:p?.banner,primary:p?.primary,series:[{products:i?.products}]}}else return p}else return d},[t,o,c,a]),L=_((u,d)=>{if(d?.subSubCategories?.length>0?y(0):y(-1),d?.subSubCategories?.length>0)s(m=>m.map(p=>p.index===u?{...p,open:!0}:{...p,open:!1}));else{const p=t?.subcategories?.findIndex(i=>!!i?.subSubCategories);s(i=>i.map(g=>({...g,open:g.index===u||g.index===p})))}},[t,v]),h=(u,d)=>{s(m=>m.map(p=>p.index===u?{...p,open:!0}:{...p,open:!1})),y(d)};return n(Y,{childClassName:"lg-desktop:gap-12 flex bg-white gap-8",children:[n("div",{className:"lg-desktop:basis-[356px] flex basis-[284px] flex-col gap-4 py-4",style:{userSelect:"none"},ref:r,children:[e("div",{className:"desktop:h-[416px] flex flex-col overflow-y-auto",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:t?.subcategories?.map((u,d)=>{const m=Array.isArray(u?.subSubCategories)&&u?.subSubCategories?.length>0;return n("div",{children:[n("div",{className:x("flex cursor-pointer items-center justify-between",{"bg-[#F5F5F7]":!m&&o?.find(p=>p.index===d)?.open}),onClick:()=>{L(d,u)},children:[e(f,{html:u.label,className:"p-4 text-sm font-bold leading-[1.4]"}),m&&e(Z,{className:x("size-4",{"rotate-180":o?.find(p=>p.index===d)?.open})})]}),o?.find(p=>p.index===d)?.open&&e("div",{className:"flex flex-col",children:u.subSubCategories?.map((p,i)=>e(f,{html:p.label,onClick:()=>h(d,i),className:x("cursor-pointer hover:bg-[#F5F5F7] px-6 py-4 text-sm font-bold leading-[1.4] text-[#6D6D6F]",{"bg-[#F5F5F7]":c===i})},`subSubItem-${d}-${i}`))})]},`subcategoryItem-${d}`)})}),t&&e("div",{className:"flex",children:n("div",{className:"flex flex-col gap-4",children:[t?.primary&&e(B,{as:"a",href:t?.primary?.url,variant:"primary",size:"lg",className:"text-sm lg-desktop:text-base",children:t?.primary?.label}),t?.secondary&&e(B,{as:"a",href:t?.secondary?.url,variant:"link",size:"lg",className:"justify-start !p-0 text-sm lg-desktop:text-base",children:t?.secondary?.label})]})})]}),n("div",{className:"flex-1 py-4",children:[Reflect.ownKeys(N).length>0&&n("div",{className:"mb-4 flex items-center justify-between",children:[e("div",{className:"flex items-center gap-2",children:e(f,{html:N?.label,className:"text-xl lg-desktop:text-2xl font-bold leading-[1.4]"})}),e(F,{href:N?.guide?.url,className:"text-sm lg-desktop:text-base leading-[1.2] text-[#6D6D6F]",children:N?.guide?.label})]}),e("div",{className:"flex flex-col gap-4 overflow-y-auto h-[426px]",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:N?.series?.map((u,d)=>n("div",{children:[u.label&&e(f,{html:u.label,className:"text-sm mb-2 font-bold leading-[1.4] text-[#6D6D6F]"}),n("div",{className:"grid grid-cols-3 gap-4",children:[!!N?.banner&&e(F,{asChild:!N?.banner?.href,href:N?.banner?.href,children:n("div",{className:"relative [&_img]:hover:scale-105 [&_img]:hover:transition-all [&_img]:hover:duration-300",children:[e(K,{source:N?.banner?.imageUrl,className:"h-[114px] laptop:h-[120px]",imgClassName:"object-cover h-full"}),n("div",{className:"absolute bottom-0 left-0 right-0 p-4",children:[e(oe,{size:2,html:N?.banner?.title||"Buy in Guide",className:"font-bold text-white"}),e(f,{html:N?.banner?.desc||"20.000mAh",className:"text-sm text-white font-bold"})]})]})}),u.products?.map((m,p)=>e(ue,{product:m,isCollection:N?.isCollection},`seriesProductItem-${p}`))]})]},`seriesItem-${d}`))})]})]})}),Ae=({multicolMetadata:t})=>{const a=R(null);return e("div",{ref:a,children:e(Y,{childClassName:"bg-white",className:"h-full",children:e("div",{className:"flex gap-4 py-4",children:t?.map((l,o)=>e("div",{className:"w-1/4",children:e(me,{item:l})},`multicolItem-${l?.label}-${o}`))})})})},$e=({supportsMetadata:t,currentNavItemRef:a})=>{const l=R(null),[o,s]=D(null),[c,y]=D(0);E(()=>{if(l?.current){const v=l?.current?.getBoundingClientRect();y(v.height)}},[l]);const r=Se(()=>{if(a){const v=a.getBoundingClientRect();s(v)}},500);return E(()=>(r(),window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}),[r]),E(()=>{if(a){const v=a.getBoundingClientRect();s(v)}},[a]),e("div",{className:"absolute top-0 h-full bg-white transition-all duration-500 overflow-hidden",style:{right:`calc(100% - ${o?.right}px)`,height:c},children:e("div",{ref:l,className:"p-4",children:t?.map(v=>e("div",{className:"py-2",children:e(F,{href:v.url,className:"text-sm font-bold leading-[1.4] no-underline",children:v.label})},v.id))})})},ue=({product:t,isCollection:a})=>{const{buildProps:l}=O();let o=a?t:l?.products?.find(r=>r.handle===t.handle);const s=o?.variants?.find(r=>r.sku===t.sku)||o?.variants?.[0],c=M(()=>`/products/${o?.handle}?variant=${we(s?.id)}`,[o?.handle,s?.id]),y=M(()=>o?.tags?.filter?.(r=>r?.startsWith?.("CLtag"))?.map?.(r=>r?.replace?.("CLtag:",""))?.slice?.(0,2),[o?.tags]);return s?.availableForSale?n("div",{className:"flex shrink-0 items-center gap-4 bg-[#F5F5F7] px-4 py-3 [&_img]:hover:scale-105",children:[e("div",{className:"shrink-0",children:e(K,{source:`${s?.image?.url||t?.images?.[0]?.url}}`,width:90,height:90,className:"size-[96px]",imgClassName:"object-contain h-full"})}),n("div",{className:"relative",children:[e("div",{className:"flex gap-1",children:Array.isArray(y)&&y?.map(r=>e(f,{as:"p",html:r,className:"text-brand-0 whitespace-nowrap mb-1 inline-block h-[24px] rounded-full border-[1.6px] border-[#00BEFA] px-[6px] text-sm font-bold !leading-[22px]"}))}),e(F,{href:c,className:"no-underline hover:text-current",children:e(f,{className:"lg-desktop:h-[44px] lg-desktop:text-base line-clamp-2 h-[40px] text-sm font-bold leading-[1.4]",html:o?.title||t?.name})}),t?.desc&&e(f,{as:"p",html:t?.desc,className:"lg-desktop:text-sm line-clamp-1 mt-1 text-xs font-bold leading-[1.4] text-[#6D6D6F]"})]})]}):null},me=({item:t,allPicture:a})=>n(J,{children:[t?.columns&&n(J,{children:[e(f,{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(l=>n("div",{className:"py-2 flex items-center gap-1",children:[e(F,{href:l.url,className:"text-sm font-bold leading-[1.4] no-underline",children:l.label}),l?.badge&&e(f,{as:"p",html:l?.badge||"badge",className:"text-sm font-bold !leading-[24px] text-brand-0 h-[24px] rounded-full border-[1.6px] border-[var(--brand-color-0)] px-[6px]"})]},l.label))})]}),t?.imageUrl&&n("div",{className:x("laptop:h-[280px] desktop:h-[224px] lg-desktop:h-[280px] h-[240px] max-w-[358px] tablet:max-w-[346px] laptop:max-w-[440px] desktop:w-full relative overflow-hidden",{"tablet:max-w-none laptop:max-w-none":a}),children:[e(K,{source:t.imageUrl,width:404,height:280,className:"size-full",imgClassName:"object-cover h-full hover:scale-105 transition-all duration-300"}),n(F,{href:t.url,className:"absolute bottom-4 left-4 z-10 flex flex-col justify-end no-underline",children:[e(f,{html:t.title,className:x("lg-desktop:text-2xl text-xl font-bold leading-[1.2] text-white",{"text-black":t?.theme==="dark"})}),t.subtitle&&e(f,{html:t.subtitle,className:x("text-sm font-bold leading-[1.4] text-white",{"text-black":t?.theme==="dark"})}),t?.primary?.label&&e(B,{as:"a",href:t?.primary?.url,variant:"link",size:"lg",className:x("text-sm font-bold mr-auto !p-0 leading-[1.4] text-white",{"text-black":t?.theme==="dark"}),children:t?.primary?.label||"more"})]})]})]}),Fe=X(({data:t,className:a},l)=>{const o=M(()=>ce(t?.categories?.filter(w=>w?.mobileShow)),[t]),{currentMenu:s,setCurrentMenu:c,subSubCategory:y}=O(),[r,v]=D(!1),[N,L]=D(0),[h,u]=D(null),d=R(null);E(()=>{if(d?.current&&r){const w=d?.current?.getBoundingClientRect();L(window?.innerHeight-(w?.bottom||0))}},[r]),ne(()=>{le.fromTo(d.current,{height:0},{height:N,duration:.3})},[N]),E(()=>{document.documentElement.style.overflow=r?"hidden":"auto"},[r]);const m=M(()=>h?.components?.[0]?.blockType,[h]),p=re(Oe,{categoriesItem:h}),i=se(Ie,h),g=ie(_e,h),S=M(()=>{switch(m){case j.Sidebar:return e(i,{});case j.Supports:return e(p,{});case j.Multicol:return e(g,{});default:return null}},[m,h,p]),C=_(()=>{v(!1),L(0),c&&c(T.Primary)},[v,L,c]),P=M(()=>t?.headerBar?.actions?.filter(w=>w?.mobileShow&&w?.blockType!==I.Profile),[t]),k=M(()=>t?.headerBar?.actions?.find(w=>w?.mobileShow&&w?.blockType===I.Profile)||{},[t]),A=M(()=>{switch(s){case T.Primary:return e(Ue,{actions:P,menuOpen:r,onMenuOpenClose:()=>{v(!1),L(0)},onMenuOpenClick:()=>v(!0)});case T.Secondary:return e(ge,{title:h?.text,onMenuOpenClose:C,onMenuBackClick:()=>c?.(T.Primary)});case T.Third:return e(ge,{title:y?.label,onMenuOpenClose:C,onMenuBackClick:()=>c?.(T.Secondary)});default:return null}},[r,s,c,h,P,y,C]),W=_((w,ee)=>{const U=Array.isArray(o)?Array.isArray(o[w])?o[w][ee]:{}:{};u(U),U?.components?.[0]?.blockType===j.Links?U?.components?.[0]?.url&&window.open(U?.components?.[0]?.url):c?.(T.Secondary)},[o,c]);return n(Y,{className:x("relative h-[52px]",a),children:[A,r&&e("div",{ref:d,className:"absolute left-0 top-full text-black border-t border-[#E5E5E7] z-[999] w-full overflow-y-auto bg-white",style:{height:N},children:s===T.Primary?e(je,{categories:o,onPrimaryMenuClick:W,profileAction:k}):S})]})}),je=({categories:t,onPrimaryMenuClick:a,profileAction:l})=>n("div",{className:"flex h-full flex-col justify-between",children:[e("div",{className:"tablet:px-8 laptop:px-16 p-4",children:t?.map((o,s)=>n("div",{className:"",children:[o?.map((c,y)=>e(Q,{label:c.text,onClick:()=>a(s,y),icon:c.components?.[0]?.icon},c.id)),e("div",{className:x("my-2 h-px w-full bg-[#E5E5E7]",{hidden:s===t.length-1})})]},`groupCategory-${s}`))}),e(We,{profileAction:l})]}),Ie=({sidebarCategoriesMetadata:t,seriesMetadata:a})=>{const{currentMenu:l,setCurrentMenu:o,subSubCategory:s,setSubSubCategory:c,setCurrentSeriesMetadata:y,currentSeriesMetadata:r,buildProps:v}=O(),[N,L]=D([]),[h,u]=D([]);E(()=>{t?.subcategories?.length&&L(t?.subcategories?.map((i,g)=>({index:g,open:!1})))},[t]),E(()=>{s?.subSubCategories?.length&&u(s?.subSubCategories?.map((i,g)=>({index:g,open:g===0})))},[s]);const d=_((i,g)=>{o&&o(T.Third),c?.(i);const S=a?.find(C=>g!==void 0?i?.subSubCategories?.[g]?.label?.toLowerCase()===C.label?.toLowerCase():i?.label?.toLowerCase()===C.label?.toLowerCase())||{};if(i?.collections){const C=v?.categories?.[i?.collections]||{};y?.({label:S?.label,isCollection:!0,banner:S?.banner,primary:S?.primary,series:[{products:C?.products}]})}else y?.(S)},[a,t,o,c,y]),m=M(()=>a?.find(i=>!!i?.guide)?.guide,[a,t]);return M(()=>{switch(l){case T.Secondary:return n("div",{className:"tablet:px-8 laptop:px-16 flex h-full flex-col justify-between tablet:justify-start tablet:gap-16 p-4",children:[e("div",{children:t?.subcategories?.map((i,g)=>e("div",{children:e(Q,{label:i?.label,active:N.find(S=>S.index===g)?.open,onClick:()=>{d(i)}})},`${i.label}-${g}`))}),n("div",{className:"tablet:items-start flex flex-col items-center gap-4",children:[t?.primary&&e(B,{as:"a",href:t?.primary?.url,variant:"primary",size:"lg",className:"tablet:w-auto w-full text-base",children:t?.primary?.label}),t?.secondary&&e(B,{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 T.Third:return n("div",{className:"tablet:px-8 laptop:px-16 p-4",children:[s?.subSubCategories?s?.subSubCategories?.map((i,g)=>{const S=a?.find(P=>P.label.toLowerCase()===i?.label?.toLowerCase())||{};let C={};if(i?.collections){const P=v?.categories?.[i?.collections]||{};C={label:S?.label,isCollection:!0,banner:S?.banner,primary:S?.primary,series:[{products:P?.products}]}}else C=S;return n("div",{children:[Reflect.ownKeys(i).length>0&&e(pe,{matchSeriesMetadata:C,onSubSubCategoryItemClick:()=>u(P=>P.map((k,A)=>({...k,open:A===g}))),expanded:!!h?.find(P=>P.index===g)?.open}),h?.find(P=>P.index===g)?.open&&n(J,{children:[e(be,{matchSeriesMetadata:C}),C?.primary&&e("div",{className:"text-center my-4",children:e(B,{as:"a",href:C?.primary?.url,className:"text-base no-underline leading-[1.2]",variant:"secondary",size:"base",children:C?.primary?.label})})]})]},`${i.label}-${g}`)}):n(J,{children:[Reflect.ownKeys(r).length>0&&e(pe,{matchSeriesMetadata:r}),e(be,{matchSeriesMetadata:r}),r?.primary&&e("div",{className:"text-center my-4 ",children:e(B,{as:"a",href:r?.primary?.url,variant:"secondary",size:"base",className:"text-base no-underline leading-[1.2]",children:r?.primary?.label})})]}),m&&e(F,{href:m?.url,children:e("div",{className:"mt-4",children:e(f,{html:m?.label,className:"text-sm font-bold leading-[1.2] text-[#6D6D6F]"})})})]});default:return null}},[l,t,o,a,N,h,c,s,y,r])},pe=({matchSeriesMetadata:t,onSubSubCategoryItemClick:a,expanded:l})=>n("div",{className:"tablet:pt-0 py-4 flex items-center justify-between",onClick:a,children:[t?.label&&e(f,{html:t?.label,className:"text-sm font-bold leading-[1.4]"}),a&&e(Z,{className:x("size-5",{"rotate-180":l})})]}),be=({matchSeriesMetadata:t})=>e("div",{className:"flex flex-col gap-2 laptop:gap-3",children:!!t?.series?.length&&t?.series?.map((a,l)=>n("div",{children:[a.label&&e(f,{html:a.label,className:"text-sm mb-2 font-bold leading-[1.4] text-[#3D3D3F]"}),n("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(F,{asChild:!t?.banner?.href,href:t?.banner?.href,children:n("div",{className:"relative [&_img]:hover:scale-105 [&_img]:hover:transition-all [&_img]:hover:duration-300",children:[e(K,{source:t?.banner?.imageUrl,className:"h-[114px] laptop:h-[120px]",imgClassName:"object-cover h-full"}),n("div",{className:"absolute bottom-0 left-0 right-0 p-4",children:[e(oe,{size:2,html:t?.banner?.title||"Buy in Guide",className:x("font-bold text-white",{"text-black":t?.banner?.theme==="dark"})}),e(f,{html:t?.banner?.desc||"20.000mAh",className:x("text-sm text-white font-bold",{"text-black":t?.banner?.theme==="dark"})})]})]})}),a.products?.map((o,s)=>e(ue,{product:o,isCollection:t?.isCollection},`seriesProductItem-${l}-${s}`))]})]},`seriesItem-${l}`))}),Oe=({supportsMetadata:t})=>e("div",{className:"tablet:px-8 laptop:px-16 p-4",children:t?.map(a=>e(Q,{href:a.url,label:a.label,onClick:()=>{}},a.id))}),_e=({multicolMetadata:t})=>{const a=M(()=>!t?.some(l=>!!l.columns),[t]);return e("div",{className:x("tablet:py-4 tablet:px-8 laptop:px-16 flex flex-col gap-4 tablet:gap-6 p-4",{"tablet:grid tablet:grid-cols-2 tablet:gap-3 laptop:gap-4":a}),children:t?.map((l,o)=>e("div",{children:e(me,{item:l,allPicture:a})},`multicolItem-${l?.label}-${o}`))})},We=({profileAction:t})=>{const[a,l]=D(!1),{profile:o,event:s}=O();return n("div",{className:x("tablet:px-8 laptop:px-16 bg-[#F5F5F7] px-4 py-6",{"p-4":a}),children:[n("div",{className:"flex items-center justify-between",onClick:()=>l(!a),children:[n("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(Le,{})}),e(f,{html:o?.nick_name||t?.welcome,className:"text-base font-bold leading-[1.4]"})]}),!o?.email&&e(Z,{className:x("size-5 laptop:size-4",{"rotate-180":a})})]}),o?.email&&e("div",{className:"mt-4",children:t?.profiles?.map(c=>e(Q,{label:c?.title,href:c?.url},c.id))}),a&&!o?.email&&n("div",{className:"mt-4",children:[e(f,{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(c=>n("div",{className:"flex items-center gap-[6px]",children:[e(K,{source:c.benefitIcon?.url,className:"size-4",alt:c.benefit,width:16,height:16}),e(f,{html:c.benefit,className:"text-sm font-bold leading-[1.4]"})]},c.id))})]}),!o?.email&&n("div",{className:"mt-4 flex items-center gap-3",children:[e(B,{className:"tablet:flex-none flex-1",variant:"secondary",size:"base",onClick:()=>s?.join?.(),children:e(f,{html:t?.primaryButton||"Join Now",className:"text-sm font-bold leading-[1.4]"})}),e(B,{className:"tablet:flex-none flex-1",variant:"primary",size:"base",onClick:()=>s?.login?.(),children:e(f,{html:t?.secondaryButton||"Log In",className:"text-sm font-bold leading-[1.4]"})})]})]})},Ue=({menuOpen:t,onMenuOpenClose:a,onMenuOpenClick:l,actions:o})=>n("div",{className:"flex h-full items-center justify-between gap-4",children:[e(fe,{}),n("div",{className:"desktop:gap-6 flex items-center gap-4",children:[e(ve,{actions:o}),t?e(de,{className:"size-5",onClick:()=>a()}):e(De,{className:"size-5",onClick:()=>l()})]})]}),fe=()=>{const{payloadData:t,isMobile:a}=O();return e("div",{className:"[&>svg]:w-full hover:text-brand-0 cursor-pointer",onClick:()=>{window.location.href="/"},dangerouslySetInnerHTML:{__html:a?t?.headerBar?.mobileLogo:t?.headerBar?.desktopLogo}})},ve=X(({actions:t,activeStatus:a=!1},l)=>{const{event:o}=O(),[s,c]=D(null),y=_((r,v)=>{switch(c(v),r?.blockType){case I.Search:o?.search?.();break;case I.Cart:o?.cart?.();break;case I.Profile:o?.profile?.();break;case I.Livestream:o?.livestream?.();break;default:return()=>{}}},[o]);return e("div",{className:"desktop:gap-6 flex items-center gap-4",children:Array.isArray(t)&&t?.map((r,v)=>e("div",{ref:r.blockType===I.Profile?l:null,onClick:()=>y(r,v),children:e(f,{html:r.icon,className:x("cursor-pointer size-5",{"text-brand-0":a&&s===v})})},r.id))})}),ge=({title:t,onMenuOpenClose:a,onMenuBackClick:l})=>n("div",{className:"flex h-full items-center gap-3",children:[e(ze,{className:"size-5",onClick:()=>l()}),e(f,{html:t,className:"flex-1 text-center text-base font-bold leading-[1.4]"}),e(de,{className:"size-5",onClick:()=>a()})]}),Q=({label:t,href:a,onClick:l,active:o,icon:s,className:c})=>e("div",{className:x("flex cursor-pointer items-center justify-between py-4",c),onClick:l,children:n(F,{href:a,asChild:!a,className:"flex w-full items-center justify-between no-underline",children:[n("div",{className:"flex items-center gap-4",children:[e(f,{html:t,className:x("text-sm font-bold leading-[1.4]",{underline:s})}),s&&e(f,{html:s})]}),e(Pe,{className:x("size-5 laptop:size-4",{"rotate-90":o})})]})});var it=ke(Be);export{it as default};
|
|
1
|
+
"use client";import{Fragment as J,jsx as e,jsxs as n}from"react/jsx-runtime";import xe,{forwardRef as X,useCallback as _,useEffect as E,useImperativeHandle as Ne,useMemo as M,useRef as R,useState as D}from"react";import{Picture as K,Text as f,Button as B,Container as Y,Link as F,Heading as oe}from"../../components/index.js";import{withLayout as ke}from"../../shared/Styles.js";import{cn as x,atobID as we}from"../../helpers/utils.js";import Ce,{useNavContext as O}from"./NavProvider.js";import{HeaderNavigationMenu as T,HeaderNavigationBlockType as j,HeaderNavigationActionBlockType as I}from"./types.js";import"react-responsive";import{debounce as Se}from"es-toolkit";import Me from"jump.js";import{useGSAP as ne}from"@gsap/react";import{gsap as le}from"gsap";import{WithSidebar as se,WithSupports as re,WithMulticol as ie,WithGroupCategory as ce}from"./withCategory.js";import{Menu as De,Close as de,User as Le,RightArrow as Pe,LeftArrow as ze,DownArrow as Z,Polygon as Ee}from"./icons/index.js";import He from"../NavigationSearch/index.js";const Be=X((t,a)=>{const{data:{headerNavigation:l}={},buildProps:o,event:s,profile:c,theme:y="light",isTop:r=!1,searchResult:v,onSearch:N,isSearching:L,keywords:h}=t,u=R(null),[d,m]=D(!1),[p,i]=D(!1),[g,S]=D(!1),[C,P]=D(!1),k=R(null),A=()=>{const w=document?.querySelector("body")?.offsetWidth||0;P(w<=1440)};E(()=>(A(),window.addEventListener("resize",A),()=>{window.removeEventListener("resize",A)}),[]),Ne(a,()=>k.current),E(()=>{k.current&&r&&Me(k.current,{duration:0,offset:k.current?.getBoundingClientRect()?.bottom||0})},[r]),E(()=>{s&&(s.search=()=>m(!0))},[s]),ne(()=>{u?.current&&d&&le.fromTo(u.current,{height:0},{height:"auto",duration:.3})},[d]),E(()=>{document.documentElement.style.overflow=d?"hidden":"auto"},[d]);const W=M(()=>l?.headerBar?.actions?.find(w=>w?.blockType===I.Search)?.searchBar?.[0]||{},[l]);return e(Ce,{buildProps:o,profile:c,isMobile:C,event:s,payloadData:l,children:e("header",{"data-ui-component-id":"HeaderNavigation",className:"relative z-[100]",ref:k,children:n("div",{className:x("hover:text-black hover:bg-white",y==="light"?"text-black":"text-white",{}),onClick:()=>S(!0),children:[e(Te,{data:l,className:"hidden desktop:block",theme:y,onNavItemClick:()=>S(!0)}),e(Fe,{data:l,className:"block desktop:hidden"}),d&&n("div",{className:"absolute z-[60] top-0 left-0 w-full bg-black/70 flex flex-col",style:{height:`calc(100dvh - ${k?.current?.getBoundingClientRect()?.top}px)`},children:[e("div",{ref:u,className:x("overflow-y-auto",{}),children:e(He,{data:W,keywords:h,isSearching:L,searchResult:v,onSearch:w=>{N?.(w)},onClose:()=>{N?.(),m(!1)}})}),e("div",{className:"flex-1 bg-transparent",onClick:()=>m(!1)})]})]})})})}),Te=X((t,a)=>{const{data:l,onNavItemClick:o,className:s,theme:c}=t,{event:y,profile:r}=O(),[v,N]=D(!1),L=M(()=>ce(l?.categories?.filter(b=>b?.pcShow)),[l]),[h,u]=D(null),[d,m]=D([]),p=R(null),[i,g]=D(!1),S=R(null),C=R(null),P=R(L.map(b=>Array(b?.length||0).fill(null)));E(()=>{L?.length&&m(L?.map((b,z)=>b?.map((H,$)=>({groupIndex:z,index:$,open:!1}))))},[L]);const k=M(()=>{let b=null;for(const z of d){for(const H of z)if(H.open){b=H;break}if(b)break}return b},[d]);E(()=>{document.documentElement.style.overflow=k?.open||i?"hidden":"auto"},[k?.open,i]);const A=(b,z,H)=>{g(!1),h?.components?.[0]?.blockType===j.Links?h?.components?.[0]?.url&&window.open(h?.components?.[0]?.url):(b.stopPropagation(),o?.(),u(L[z][H]),m($=>$.map(V=>V.map(q=>q.groupIndex===z&&q.index===H?{...q,open:!q.open}:{...q,open:!1}))))},W=()=>{m(b=>b.map(z=>z.map(H=>({...H,open:!1}))))},w=M(()=>{if(h)return h?.components?.[0]?.blockType},[h]),ee=se(Re,h),U=ie(Ae,h),he=re($e,{categoriesItem:h,currentNavItemRef:P.current?.[k?.groupIndex||0]?.[k?.index||0]}),ye=M(()=>{switch(w){case j.Sidebar:return e(ee,{});case j.Supports:return e(he,{});case j.Multicol:return e(U,{});default:return null}},[w,h]),te=M(()=>l?.headerBar?.actions?.filter(b=>b?.pcShow),[l]),G=M(()=>te?.find(b=>b?.blockType===I.Profile),[te]),ae=_(()=>{g(b=>!b)},[]);return E(()=>{if(p?.current){const b=p.current;return b.addEventListener("click",ae),()=>{b.removeEventListener("click",ae)}}},[ae]),ne(()=>{k?.open&&le.fromTo(C?.current,{height:0},{height:"auto"})},[k?.open]),n(Y,{className:x("relative h-[96px]",s),children:[n("div",{ref:S,onClick:W,className:"flex h-full flex-col justify-end gap-4",children:[n("div",{className:"flex items-center justify-between",children:[e(fe,{}),e(ve,{ref:p,actions:te,activeStatus:i})]}),e("div",{className:"flex justify-between",children:L?.map((b,z)=>e("div",{className:"flex gap-3",children:b?.map((H,$)=>e("div",{ref:V=>{P.current[z][$]=V},className:"group cursor-pointer",children:n("div",{className:"relative",children:[n("div",{className:"flex items-center gap-1 pb-4",onClick:V=>A(V,z,$),children:[e(f,{html:H.text,className:"text-sm font-bold leading-[1.4]"}),e(Z,{className:x("opacity-0 size-4 group-hover:opacity-100 transition-opacity duration-500",{"rotate-180":k?.groupIndex===z&&k?.index===$,"opacity-100":v&&k?.groupIndex===z&&k?.index===$})})]}),e("div",{className:x("absolute bottom-0 left-0 h-[2px] w-0 transition-all duration-500",{"w-[calc(100%-20px)]":k?.groupIndex===z&&k?.index===$},c==="dark"?"bg-white":"bg-[#1D1D1F]")})]})},H.id))},`groupCategory-${z}`))})]}),n("div",{className:x("border-t border-b-[#E4E5E6] text-black absolute left-0 top-full z-[999] flex w-full flex-col bg-black/70 overflow-hidden",{hidden:!(k?.open&&h)}),onMouseEnter:()=>N(!0),onMouseLeave:()=>N(!1),style:{height:`calc(100dvh - ${S?.current?.getBoundingClientRect()?.bottom}px)`},children:[e("div",{ref:C,className:x("relative z-50",{"overflow-hidden":w!==j.Supports}),children:ye}),e("div",{className:"flex-1 bg-transparent",onClick:W})]}),i&&n("div",{className:"absolute left-0 z-[999] flex w-full bg-black/70 h-[100dvh] top-full",children:[e("div",{className:"absolute w-[272px] bg-white p-4",style:{right:`calc(100% - ${p?.current?.getBoundingClientRect()?.right}px)`,top:"-36px"},children:r?.email?n(J,{children:[e(f,{html:r?.nick_name||G?.welcome,className:"text-sm font-bold"}),e("div",{className:"h-[1px] mt-2 bg-[#D9D9D9]"}),e("div",{className:"mt-2",children:G?.profiles?.map(b=>e(Q,{className:"py-2",label:b?.title,href:b?.url},b.id))})]}):n(J,{children:[e(Ee,{className:"absolute -top-2 text-white right-[46px] z-30"}),e(f,{html:G?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),e("div",{className:"mt-2 flex flex-col gap-1",children:G?.benefits?.map(b=>n("div",{className:"flex items-center gap-[6px]",children:[e(K,{source:b.benefitIcon?.url,className:"size-4",alt:b.benefit,width:16,height:16}),e(f,{html:b.benefit,className:"text-sm font-bold leading-[1.4]"})]},b.id))}),n("div",{className:"mt-4 flex items-center gap-2",children:[e(B,{variant:"secondary",size:"lg",onClick:()=>y?.join?.(),children:e(f,{html:G?.primaryButton||"Join Now",className:"font-bold"})}),e(B,{variant:"primary",size:"lg",onClick:()=>y?.login?.(),children:e(f,{html:G?.secondaryButton||"Log In",className:"font-bold"})})]})]})}),e("div",{className:"flex-1 bg-transparent",onClick:()=>g(!1)})]})]})}),Re=xe.memo(({sidebarCategoriesMetadata:t,seriesMetadata:a})=>{const{buildProps:l}=O(),[o,s]=D([]),[c,y]=D(-1),r=R(null),v=_(()=>{const u=t?.subcategories;if(!u?.length)return;const d=u.findIndex(i=>!!i?.subSubCategories),m=u.findIndex(i=>!i?.subSubCategories),p=u.map((i,g)=>({index:g,open:d===g||m===g}));s(p)},[t]);E(()=>{v()},[v]);const N=M(()=>{const u=t?.subcategories?.[o?.find(m=>m.open)?.index||0],d=a?.find(m=>m?.label?.toLowerCase()===u?.label?.toLowerCase())||{};if(u?.collections){const m=l?.categories?.[u?.collections]||{};return{label:d?.label,isCollection:!0,banner:d?.banner,primary:d?.primary,series:[{products:m?.products}]}}else if(u?.subSubCategories){const m=u?.subSubCategories?.[c],p=a?.find(i=>i?.label?.toLowerCase()===m?.label?.toLowerCase())||{};if(m?.collections){const i=l?.categories?.[m?.collections]||{};return{label:p?.label,isCollection:!0,banner:p?.banner,primary:p?.primary,series:[{products:i?.products}]}}else return p}else return d},[t,o,c,a]),L=_((u,d)=>{if(d?.subSubCategories?.length>0?y(0):y(-1),d?.subSubCategories?.length>0)s(m=>m.map(p=>p.index===u?{...p,open:!0}:{...p,open:!1}));else{const p=t?.subcategories?.findIndex(i=>!!i?.subSubCategories);s(i=>i.map(g=>({...g,open:g.index===u||g.index===p})))}},[t,v]),h=(u,d)=>{s(m=>m.map(p=>p.index===u?{...p,open:!0}:{...p,open:!1})),y(d)};return n(Y,{childClassName:"lg-desktop:gap-12 flex bg-white gap-8",children:[n("div",{className:"lg-desktop:basis-[356px] flex basis-[284px] flex-col gap-4 py-4",style:{userSelect:"none"},ref:r,children:[e("div",{className:"desktop:h-[416px] flex flex-col overflow-y-auto",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:t?.subcategories?.map((u,d)=>{const m=Array.isArray(u?.subSubCategories)&&u?.subSubCategories?.length>0;return n("div",{children:[n("div",{className:x("flex cursor-pointer items-center justify-between",{"bg-[#F5F5F7]":!m&&o?.find(p=>p.index===d)?.open}),onClick:()=>{L(d,u)},children:[e(f,{html:u.label,className:"p-4 text-sm font-bold leading-[1.4]"}),m&&e(Z,{className:x("size-4",{"rotate-180":o?.find(p=>p.index===d)?.open})})]}),o?.find(p=>p.index===d)?.open&&e("div",{className:"flex flex-col",children:u.subSubCategories?.map((p,i)=>e(f,{html:p.label,onClick:()=>h(d,i),className:x("cursor-pointer hover:bg-[#F5F5F7] px-6 py-4 text-sm font-bold leading-[1.4] text-[#6D6D6F]",{"bg-[#F5F5F7]":c===i})},`subSubItem-${d}-${i}`))})]},`subcategoryItem-${d}`)})}),t&&e("div",{className:"flex",children:n("div",{className:"flex flex-col gap-4",children:[t?.primary&&e(B,{as:"a",href:t?.primary?.url,variant:"primary",size:"lg",className:"text-sm lg-desktop:text-base",children:t?.primary?.label}),t?.secondary&&e(B,{as:"a",href:t?.secondary?.url,variant:"link",size:"lg",className:"justify-start !p-0 text-sm lg-desktop:text-base",children:t?.secondary?.label})]})})]}),n("div",{className:"flex-1 py-4",children:[Reflect.ownKeys(N).length>0&&n("div",{className:"mb-4 flex items-center justify-between",children:[e("div",{className:"flex items-center gap-2",children:e(f,{html:N?.label,className:"text-xl lg-desktop:text-2xl font-bold leading-[1.4]"})}),e(F,{href:N?.guide?.url,className:"text-sm lg-desktop:text-base leading-[1.2] text-[#6D6D6F]",children:N?.guide?.label})]}),e("div",{className:"flex flex-col gap-4 overflow-y-auto h-[426px]",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:N?.series?.map((u,d)=>n("div",{children:[u.label&&e(f,{html:u.label,className:"text-sm mb-2 font-bold leading-[1.4] text-[#6D6D6F]"}),n("div",{className:"grid grid-cols-3 gap-4",children:[!!N?.banner&&e(F,{asChild:!N?.banner?.href,href:N?.banner?.href,children:n("div",{className:"relative [&_img]:hover:scale-105 [&_img]:hover:transition-all [&_img]:hover:duration-300",children:[e(K,{source:N?.banner?.imageUrl,className:"h-[114px] laptop:h-[120px]",imgClassName:"object-cover h-full"}),n("div",{className:"absolute bottom-0 left-0 right-0 p-4",children:[e(oe,{size:2,html:N?.banner?.title||"Buy in Guide",className:"font-bold text-white"}),e(f,{html:N?.banner?.desc||"20.000mAh",className:"text-sm text-white font-bold"})]})]})}),u.products?.map((m,p)=>e(ue,{product:m,isCollection:N?.isCollection},`seriesProductItem-${p}`))]})]},`seriesItem-${d}`))})]})]})}),Ae=({multicolMetadata:t})=>{const a=R(null);return e("div",{ref:a,children:e(Y,{childClassName:"bg-white",className:"h-full",children:e("div",{className:"flex gap-4 py-4",children:t?.map((l,o)=>e("div",{className:"w-1/4",children:e(me,{item:l})},`multicolItem-${l?.label}-${o}`))})})})},$e=({supportsMetadata:t,currentNavItemRef:a})=>{const l=R(null),[o,s]=D(null),[c,y]=D(0);E(()=>{if(l?.current){const v=l?.current?.getBoundingClientRect();y(v.height)}},[l]);const r=Se(()=>{if(a){const v=a.getBoundingClientRect();s(v)}},500);return E(()=>(r(),window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}),[r]),E(()=>{if(a){const v=a.getBoundingClientRect();s(v)}},[a]),e("div",{className:"absolute top-0 h-full bg-white transition-all duration-500 overflow-hidden",style:{right:`calc(100% - ${o?.right}px)`,height:c},children:e("div",{ref:l,className:"p-4",children:t?.map(v=>e("div",{className:"py-2",children:e(F,{href:v.url,className:"text-sm font-bold leading-[1.4] no-underline",children:v.label})},v.id))})})},ue=({product:t,isCollection:a})=>{const{buildProps:l}=O();let o=a?t:l?.products?.find(r=>r.handle===t.handle);const s=o?.variants?.find(r=>r.sku===t.sku)||o?.variants?.[0],c=M(()=>`/products/${o?.handle}?variant=${we(s?.id)}`,[o?.handle,s?.id]),y=M(()=>o?.tags?.filter?.(r=>r?.startsWith?.("CLtag"))?.map?.(r=>r?.replace?.("CLtag:",""))?.slice?.(0,2),[o?.tags]);return s?.availableForSale?n("div",{className:"flex shrink-0 items-center gap-4 bg-[#F5F5F7] px-4 py-3 [&_img]:hover:scale-105",children:[e("div",{className:"shrink-0",children:e(K,{source:`${s?.image?.url||t?.images?.[0]?.url}}`,width:90,height:90,className:"size-[96px]",imgClassName:"object-contain h-full"})}),n("div",{className:"relative",children:[e("div",{className:"flex gap-1",children:Array.isArray(y)&&y?.map(r=>e(f,{as:"p",html:r,className:"text-brand-0 whitespace-nowrap mb-1 inline-block h-[24px] rounded-full border-[1.6px] border-[#00BEFA] px-[6px] text-sm font-bold !leading-[22px]"}))}),e(F,{href:c,className:"no-underline hover:text-current",children:e(f,{className:"lg-desktop:h-[44px] lg-desktop:text-base line-clamp-2 h-[40px] text-sm font-bold leading-[1.4]",html:o?.title||t?.name})}),t?.desc&&e(f,{as:"p",html:t?.desc,className:"lg-desktop:text-sm line-clamp-1 mt-1 text-xs font-bold leading-[1.4] text-[#6D6D6F]"})]})]}):null},me=({item:t,allPicture:a})=>n(J,{children:[t?.columns&&n(J,{children:[e(f,{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(l=>n("div",{className:"py-2 flex items-center gap-1",children:[e(F,{href:l.url,className:"text-sm font-bold leading-[1.4] no-underline",children:l.label}),l?.badge&&e(f,{as:"p",html:l?.badge||"badge",className:"text-sm font-bold !leading-[24px] text-brand-0 h-[24px] rounded-full border-[1.6px] border-[var(--brand-color-0)] px-[6px]"})]},l.label))})]}),t?.imageUrl&&n("div",{className:x("laptop:h-[280px] desktop:h-[224px] lg-desktop:h-[280px] h-[240px] max-w-[358px] tablet:max-w-[346px] laptop:max-w-[440px] desktop:w-full relative overflow-hidden",{"tablet:max-w-none laptop:max-w-none":a}),children:[e(K,{source:t.imageUrl,width:404,height:280,className:"size-full",imgClassName:"object-cover h-full hover:scale-105 transition-all duration-300"}),n(F,{href:t.url,className:"absolute bottom-4 left-4 z-10 flex flex-col justify-end no-underline",children:[e(f,{html:t.title,className:x("lg-desktop:text-2xl text-xl font-bold leading-[1.2] text-white",{"text-black":t?.theme==="dark"})}),t.subtitle&&e(f,{html:t.subtitle,className:x("text-sm font-bold leading-[1.4] text-white",{"text-black":t?.theme==="dark"})}),t?.primary?.label&&e(B,{as:"a",href:t?.primary?.url,variant:"link",size:"lg",className:x("text-sm font-bold mr-auto !p-0 leading-[1.4] text-white",{"text-black":t?.theme==="dark"}),children:t?.primary?.label||"more"})]})]})]}),Fe=X(({data:t,className:a},l)=>{const o=M(()=>ce(t?.categories?.filter(w=>w?.mobileShow)),[t]),{currentMenu:s,setCurrentMenu:c,subSubCategory:y}=O(),[r,v]=D(!1),[N,L]=D(0),[h,u]=D(null),d=R(null);E(()=>{if(d?.current&&r){const w=d?.current?.getBoundingClientRect();L(window?.innerHeight-(w?.bottom||0))}},[r]),ne(()=>{le.fromTo(d.current,{height:0},{height:N,duration:.3})},[N]),E(()=>{document.documentElement.style.overflow=r?"hidden":"auto"},[r]);const m=M(()=>h?.components?.[0]?.blockType,[h]),p=re(Oe,{categoriesItem:h}),i=se(Ie,h),g=ie(_e,h),S=M(()=>{switch(m){case j.Sidebar:return e(i,{});case j.Supports:return e(p,{});case j.Multicol:return e(g,{});default:return null}},[m,h,p]),C=_(()=>{v(!1),L(0),c&&c(T.Primary)},[v,L,c]),P=M(()=>t?.headerBar?.actions?.filter(w=>w?.mobileShow&&w?.blockType!==I.Profile),[t]),k=M(()=>t?.headerBar?.actions?.find(w=>w?.mobileShow&&w?.blockType===I.Profile)||{},[t]),A=M(()=>{switch(s){case T.Primary:return e(Ue,{actions:P,menuOpen:r,onMenuOpenClose:()=>{v(!1),L(0)},onMenuOpenClick:()=>v(!0)});case T.Secondary:return e(ge,{title:h?.text,onMenuOpenClose:C,onMenuBackClick:()=>c?.(T.Primary)});case T.Third:return e(ge,{title:y?.label,onMenuOpenClose:C,onMenuBackClick:()=>c?.(T.Secondary)});default:return null}},[r,s,c,h,P,y,C]),W=_((w,ee)=>{const U=Array.isArray(o)?Array.isArray(o[w])?o[w][ee]:{}:{};u(U),U?.components?.[0]?.blockType===j.Links?U?.components?.[0]?.url&&window.open(U?.components?.[0]?.url):c?.(T.Secondary)},[o,c]);return n(Y,{className:x("relative h-[52px]",a),children:[A,r&&e("div",{ref:d,className:"absolute left-0 top-full text-black border-t border-[#E4E5E6] z-[999] w-full overflow-y-auto bg-white",style:{height:N},children:s===T.Primary?e(je,{categories:o,onPrimaryMenuClick:W,profileAction:k}):S})]})}),je=({categories:t,onPrimaryMenuClick:a,profileAction:l})=>n("div",{className:"flex h-full flex-col justify-between",children:[e("div",{className:"tablet:px-8 laptop:px-16 p-4",children:t?.map((o,s)=>n("div",{className:"",children:[o?.map((c,y)=>e(Q,{label:c.text,onClick:()=>a(s,y),icon:c.components?.[0]?.icon},c.id)),e("div",{className:x("my-2 h-px w-full bg-[#E5E5E7]",{hidden:s===t.length-1})})]},`groupCategory-${s}`))}),e(We,{profileAction:l})]}),Ie=({sidebarCategoriesMetadata:t,seriesMetadata:a})=>{const{currentMenu:l,setCurrentMenu:o,subSubCategory:s,setSubSubCategory:c,setCurrentSeriesMetadata:y,currentSeriesMetadata:r,buildProps:v}=O(),[N,L]=D([]),[h,u]=D([]);E(()=>{t?.subcategories?.length&&L(t?.subcategories?.map((i,g)=>({index:g,open:!1})))},[t]),E(()=>{s?.subSubCategories?.length&&u(s?.subSubCategories?.map((i,g)=>({index:g,open:g===0})))},[s]);const d=_((i,g)=>{o&&o(T.Third),c?.(i);const S=a?.find(C=>g!==void 0?i?.subSubCategories?.[g]?.label?.toLowerCase()===C.label?.toLowerCase():i?.label?.toLowerCase()===C.label?.toLowerCase())||{};if(i?.collections){const C=v?.categories?.[i?.collections]||{};y?.({label:S?.label,isCollection:!0,banner:S?.banner,primary:S?.primary,series:[{products:C?.products}]})}else y?.(S)},[a,t,o,c,y]),m=M(()=>a?.find(i=>!!i?.guide)?.guide,[a,t]);return M(()=>{switch(l){case T.Secondary:return n("div",{className:"tablet:px-8 laptop:px-16 flex h-full flex-col justify-between tablet:justify-start tablet:gap-16 p-4",children:[e("div",{children:t?.subcategories?.map((i,g)=>e("div",{children:e(Q,{label:i?.label,active:N.find(S=>S.index===g)?.open,onClick:()=>{d(i)}})},`${i.label}-${g}`))}),n("div",{className:"tablet:items-start flex flex-col items-center gap-4",children:[t?.primary&&e(B,{as:"a",href:t?.primary?.url,variant:"primary",size:"lg",className:"tablet:w-auto w-full text-base",children:t?.primary?.label}),t?.secondary&&e(B,{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 T.Third:return n("div",{className:"tablet:px-8 laptop:px-16 p-4",children:[s?.subSubCategories?s?.subSubCategories?.map((i,g)=>{const S=a?.find(P=>P.label.toLowerCase()===i?.label?.toLowerCase())||{};let C={};if(i?.collections){const P=v?.categories?.[i?.collections]||{};C={label:S?.label,isCollection:!0,banner:S?.banner,primary:S?.primary,series:[{products:P?.products}]}}else C=S;return n("div",{children:[Reflect.ownKeys(i).length>0&&e(pe,{matchSeriesMetadata:C,onSubSubCategoryItemClick:()=>u(P=>P.map((k,A)=>({...k,open:A===g}))),expanded:!!h?.find(P=>P.index===g)?.open}),h?.find(P=>P.index===g)?.open&&n(J,{children:[e(be,{matchSeriesMetadata:C}),C?.primary&&e("div",{className:"text-center my-4",children:e(B,{as:"a",href:C?.primary?.url,className:"text-base no-underline leading-[1.2]",variant:"secondary",size:"base",children:C?.primary?.label})})]})]},`${i.label}-${g}`)}):n(J,{children:[Reflect.ownKeys(r).length>0&&e(pe,{matchSeriesMetadata:r}),e(be,{matchSeriesMetadata:r}),r?.primary&&e("div",{className:"text-center my-4 ",children:e(B,{as:"a",href:r?.primary?.url,variant:"secondary",size:"base",className:"text-base no-underline leading-[1.2]",children:r?.primary?.label})})]}),m&&e(F,{href:m?.url,children:e("div",{className:"mt-4",children:e(f,{html:m?.label,className:"text-sm font-bold leading-[1.2] text-[#6D6D6F]"})})})]});default:return null}},[l,t,o,a,N,h,c,s,y,r])},pe=({matchSeriesMetadata:t,onSubSubCategoryItemClick:a,expanded:l})=>n("div",{className:"tablet:pt-0 py-4 flex items-center justify-between",onClick:a,children:[t?.label&&e(f,{html:t?.label,className:"text-sm font-bold leading-[1.4]"}),a&&e(Z,{className:x("size-5",{"rotate-180":l})})]}),be=({matchSeriesMetadata:t})=>e("div",{className:"flex flex-col gap-2 laptop:gap-3",children:!!t?.series?.length&&t?.series?.map((a,l)=>n("div",{children:[a.label&&e(f,{html:a.label,className:"text-sm mb-2 font-bold leading-[1.4] text-[#3D3D3F]"}),n("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(F,{asChild:!t?.banner?.href,href:t?.banner?.href,children:n("div",{className:"relative [&_img]:hover:scale-105 [&_img]:hover:transition-all [&_img]:hover:duration-300",children:[e(K,{source:t?.banner?.imageUrl,className:"h-[114px] laptop:h-[120px]",imgClassName:"object-cover h-full"}),n("div",{className:"absolute bottom-0 left-0 right-0 p-4",children:[e(oe,{size:2,html:t?.banner?.title||"Buy in Guide",className:x("font-bold text-white",{"text-black":t?.banner?.theme==="dark"})}),e(f,{html:t?.banner?.desc||"20.000mAh",className:x("text-sm text-white font-bold",{"text-black":t?.banner?.theme==="dark"})})]})]})}),a.products?.map((o,s)=>e(ue,{product:o,isCollection:t?.isCollection},`seriesProductItem-${l}-${s}`))]})]},`seriesItem-${l}`))}),Oe=({supportsMetadata:t})=>e("div",{className:"tablet:px-8 laptop:px-16 p-4",children:t?.map(a=>e(Q,{href:a.url,label:a.label,onClick:()=>{}},a.id))}),_e=({multicolMetadata:t})=>{const a=M(()=>!t?.some(l=>!!l.columns),[t]);return e("div",{className:x("tablet:py-4 tablet:px-8 laptop:px-16 flex flex-col gap-4 tablet:gap-6 p-4",{"tablet:grid tablet:grid-cols-2 tablet:gap-3 laptop:gap-4":a}),children:t?.map((l,o)=>e("div",{children:e(me,{item:l,allPicture:a})},`multicolItem-${l?.label}-${o}`))})},We=({profileAction:t})=>{const[a,l]=D(!1),{profile:o,event:s}=O();return n("div",{className:x("tablet:px-8 laptop:px-16 bg-[#F5F5F7] px-4 py-6",{"p-4":a}),children:[n("div",{className:"flex items-center justify-between",onClick:()=>l(!a),children:[n("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(Le,{})}),e(f,{html:o?.nick_name||t?.welcome,className:"text-base font-bold leading-[1.4]"})]}),!o?.email&&e(Z,{className:x("size-5 laptop:size-4",{"rotate-180":a})})]}),o?.email&&e("div",{className:"mt-4",children:t?.profiles?.map(c=>e(Q,{label:c?.title,href:c?.url},c.id))}),a&&!o?.email&&n("div",{className:"mt-4",children:[e(f,{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(c=>n("div",{className:"flex items-center gap-[6px]",children:[e(K,{source:c.benefitIcon?.url,className:"size-4",alt:c.benefit,width:16,height:16}),e(f,{html:c.benefit,className:"text-sm font-bold leading-[1.4]"})]},c.id))})]}),!o?.email&&n("div",{className:"mt-4 flex items-center gap-3",children:[e(B,{className:"tablet:flex-none flex-1",variant:"secondary",size:"base",onClick:()=>s?.join?.(),children:e(f,{html:t?.primaryButton||"Join Now",className:"text-sm font-bold leading-[1.4]"})}),e(B,{className:"tablet:flex-none flex-1",variant:"primary",size:"base",onClick:()=>s?.login?.(),children:e(f,{html:t?.secondaryButton||"Log In",className:"text-sm font-bold leading-[1.4]"})})]})]})},Ue=({menuOpen:t,onMenuOpenClose:a,onMenuOpenClick:l,actions:o})=>n("div",{className:"flex h-full items-center justify-between gap-4",children:[e(fe,{}),n("div",{className:"desktop:gap-6 flex items-center gap-4",children:[e(ve,{actions:o}),t?e(de,{className:"size-5",onClick:()=>a()}):e(De,{className:"size-5",onClick:()=>l()})]})]}),fe=()=>{const{payloadData:t,isMobile:a}=O();return e("div",{className:"[&>svg]:w-full hover:text-brand-0 cursor-pointer",onClick:()=>{window.location.href="/"},dangerouslySetInnerHTML:{__html:a?t?.headerBar?.mobileLogo:t?.headerBar?.desktopLogo}})},ve=X(({actions:t,activeStatus:a=!1},l)=>{const{event:o}=O(),[s,c]=D(null),y=_((r,v)=>{switch(c(v),r?.blockType){case I.Search:o?.search?.();break;case I.Cart:o?.cart?.();break;case I.Profile:o?.profile?.();break;case I.Livestream:o?.livestream?.();break;default:return()=>{}}},[o]);return e("div",{className:"desktop:gap-6 flex items-center gap-4",children:Array.isArray(t)&&t?.map((r,v)=>e("div",{ref:r.blockType===I.Profile?l:null,onClick:()=>y(r,v),children:e(f,{html:r.icon,className:x("cursor-pointer size-5",{"text-brand-0":a&&s===v})})},r.id))})}),ge=({title:t,onMenuOpenClose:a,onMenuBackClick:l})=>n("div",{className:"flex h-full items-center gap-3",children:[e(ze,{className:"size-5",onClick:()=>l()}),e(f,{html:t,className:"flex-1 text-center text-base font-bold leading-[1.4]"}),e(de,{className:"size-5",onClick:()=>a()})]}),Q=({label:t,href:a,onClick:l,active:o,icon:s,className:c})=>e("div",{className:x("flex cursor-pointer items-center justify-between py-4",c),onClick:l,children:n(F,{href:a,asChild:!a,className:"flex w-full items-center justify-between no-underline",children:[n("div",{className:"flex items-center gap-4",children:[e(f,{html:t,className:x("text-sm font-bold leading-[1.4]",{underline:s})}),s&&e(f,{html:s})]}),e(Pe,{className:x("size-5 laptop:size-4",{"rotate-90":o})})]})});var it=ke(Be);export{it as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|