@anker-in/headless-ui 1.0.20-alpha.1761550525400 → 1.0.20-alpha.1761573388494
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";"use client";var me=Object.create;var U=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ve=Object.prototype.hasOwnProperty;var ge=(t,n)=>{for(var o in n)U(t,o,{get:n[o],enumerable:!0})},X=(t,n,o,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of be(n))!ve.call(t,r)&&r!==o&&U(t,r,{get:()=>n[r],enumerable:!(c=pe(n,r))||c.enumerable});return t};var G=(t,n,o)=>(o=t!=null?me(fe(t)):{},X(n||!t||!t.__esModule?U(o,"default",{value:t,enumerable:!0}):o,t)),ye=t=>X(U({},"__esModule",{value:!0}),t);var He={};ge(He,{default:()=>Ee});module.exports=ye(He);var e=require("react/jsx-runtime"),a=G(require("react")),l=require("../../components/index.js"),oe=require("../../shared/Styles.js"),N=require("../../helpers/utils.js"),B=G(require("./NavProvider.js")),y=require("./types.js"),Re=require("react-responsive"),se=require("es-toolkit"),re=G(require("jump.js")),K=require("@gsap/react"),J=require("gsap"),H=require("./withCategory.js"),P=require("./icons/index.js"),ie=G(require("../NavigationSearch/index.js"));const he=(0,a.forwardRef)((t,n)=>{const{data:{headerNavigation:o}={},buildProps:c,event:r,profile:b,theme:d="light",isTop:m=!1,searchResult:p,onSearch:v,isSearching:k,keywords:w,onPrimaryNavClick:s,onSeriesProductClick:x}=t,f=(0,a.useRef)(null),[u,i]=(0,a.useState)(!1),[h,D]=(0,a.useState)(!1),[L,C]=(0,a.useState)(!1),[A,S]=(0,a.useState)(!1),T=(0,a.useRef)(null),j=()=>{const $=document?.querySelector("body")?.offsetWidth||0;S($<=1440)};(0,a.useEffect)(()=>(j(),window.addEventListener("resize",j),()=>{window.removeEventListener("resize",j)}),[]),(0,a.useImperativeHandle)(n,()=>T.current),(0,a.useEffect)(()=>{T.current&&m&&(0,re.default)(T.current,{duration:0,offset:T.current?.getBoundingClientRect()?.bottom||0})},[m]),(0,a.useEffect)(()=>{r&&(r.search=()=>i(!0))},[r]),(0,K.useGSAP)(()=>{f?.current&&u&&J.gsap.fromTo(f.current,{height:0},{height:"auto",duration:.3})},[u]),(0,a.useEffect)(()=>{document.documentElement.style.overflow=u?"hidden":"auto"},[u]);const M=(0,a.useMemo)(()=>o?.headerBar?.actions?.find($=>$?.blockType===y.HeaderNavigationActionBlockType.Search)?.searchBar?.[0]||{},[o]);return(0,e.jsx)(B.default,{buildProps:c,profile:b,isMobile:A,event:r,payloadData:o,onSeriesProductClick:x,children:(0,e.jsx)("header",{"data-ui-component-id":"HeaderNavigation",className:"relative z-[100]",ref:T,children:(0,e.jsxs)("div",{className:(0,N.cn)("hover:text-black hover:bg-white",d==="light"?"text-black":"text-white",{}),onClick:()=>C(!0),children:[(0,e.jsx)(xe,{data:o,className:"hidden desktop:block",theme:d,onNavItemClick:()=>C(!0),onPrimaryNavClick:s}),(0,e.jsx)(Ce,{data:o,className:"block desktop:hidden",onPrimaryNavClick:s}),u&&(0,e.jsxs)("div",{className:"absolute z-[60] top-0 left-0 w-full bg-black/70 flex flex-col",style:{height:`calc(100dvh - ${T?.current?.getBoundingClientRect()?.top}px)`},children:[(0,e.jsx)("div",{ref:f,className:(0,N.cn)("overflow-y-auto",{}),children:(0,e.jsx)(ie.default,{data:M,keywords:w,isSearching:k,searchResult:p,onSearch:$=>{v?.($)},onClose:()=>{v?.(),i(!1)}})}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:()=>i(!1)})]})]})})})}),xe=(0,a.forwardRef)((t,n)=>{const{data:o,onNavItemClick:c,className:r,theme:b,onPrimaryNavClick:d}=t,{event:m,profile:p}=(0,B.useNavContext)(),[v,k]=(0,a.useState)(!1),w=(0,a.useMemo)(()=>(0,H.WithGroupCategory)(o?.categories?.filter(g=>g?.pcShow)),[o]),[s,x]=(0,a.useState)(null),[f,u]=(0,a.useState)([]),i=(0,a.useRef)(null),[h,D]=(0,a.useState)(!1),L=(0,a.useRef)(null),C=(0,a.useRef)(null),A=(0,a.useRef)(w.map(g=>Array(g?.length||0).fill(null)));(0,a.useEffect)(()=>{w?.length&&u(w?.map((g,z)=>g?.map((E,R)=>({groupIndex:z,index:R,open:!1}))))},[w]);const S=(0,a.useMemo)(()=>{let g=null;for(const z of f){for(const E of z)if(E.open){g=E;break}if(g)break}return g},[f]);(0,a.useEffect)(()=>{document.documentElement.style.overflow=S?.open||h?"hidden":"auto"},[S?.open,h]);const T=(g,z,E)=>{if(D(!1),s?.components?.[0]?.blockType===y.HeaderNavigationBlockType.Links)s?.components?.[0]?.url&&window.open(s?.components?.[0]?.url);else{const R=w?.flat()||[],_=R?.findIndex(Q=>Q?.id===w[z][E]?.id);g.stopPropagation(),c?.(),d?.(R[_],_),x(w[z][E]),u(Q=>Q.map(ue=>ue.map(I=>I.groupIndex===z&&I.index===E?{...I,open:!I.open}:{...I,open:!1})))}},j=()=>{u(g=>g.map(z=>z.map(E=>({...E,open:!1}))))},M=(0,a.useMemo)(()=>{if(s)return s?.components?.[0]?.blockType},[s]),$=(0,H.WithSidebar)(Ne,s),F=(0,H.WithMulticol)(ke,s),ce=(0,H.WithSupports)(we,{categoriesItem:s,currentNavItemRef:A.current?.[S?.groupIndex||0]?.[S?.index||0]}),de=(0,a.useMemo)(()=>{switch(M){case y.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)($,{});case y.HeaderNavigationBlockType.Supports:return(0,e.jsx)(ce,{});case y.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(F,{});default:return null}},[M,s]),V=(0,a.useMemo)(()=>o?.headerBar?.actions?.filter(g=>g?.pcShow),[o]),O=(0,a.useMemo)(()=>V?.find(g=>g?.blockType===y.HeaderNavigationActionBlockType.Profile),[V]),q=(0,a.useCallback)(()=>{D(g=>!g)},[]);return(0,a.useEffect)(()=>{if(i?.current){const g=i.current;return g.addEventListener("click",q),()=>{g.removeEventListener("click",q)}}},[q]),(0,K.useGSAP)(()=>{S?.open&&J.gsap.fromTo(C?.current,{height:0},{height:"auto"})},[S?.open]),(0,e.jsxs)(l.Container,{className:(0,N.cn)("relative h-[96px]",r),children:[(0,e.jsxs)("div",{ref:L,onClick:j,className:"flex h-full flex-col justify-end gap-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)(ae,{}),(0,e.jsx)(ne,{ref:i,actions:V,activeStatus:h})]}),(0,e.jsx)("div",{className:"flex justify-between",children:w?.map((g,z)=>(0,e.jsx)("div",{className:"flex gap-3",children:g?.map((E,R)=>(0,e.jsx)("div",{ref:_=>{A.current[z][R]=_},className:"group cursor-pointer",children:(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 pb-4",onClick:_=>T(_,z,R),children:[(0,e.jsx)(l.Text,{html:E.text,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)(P.DownArrow,{className:(0,N.cn)("opacity-0 size-4 group-hover:opacity-100 transition-opacity duration-500",{"rotate-180":S?.groupIndex===z&&S?.index===R,"opacity-100":v&&S?.groupIndex===z&&S?.index===R})})]}),(0,e.jsx)("div",{className:(0,N.cn)("absolute bottom-0 left-0 h-[2px] w-0 transition-all duration-500",{"w-[calc(100%-20px)]":S?.groupIndex===z&&S?.index===R},b==="dark"?"bg-white":"bg-[#1D1D1F]")})]})},E.id))},`groupCategory-${z}`))})]}),(0,e.jsxs)("div",{className:(0,N.cn)("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:!(S?.open&&s)}),onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),style:{height:`calc(100dvh - ${L?.current?.getBoundingClientRect()?.bottom}px)`},children:[(0,e.jsx)("div",{ref:C,className:(0,N.cn)("relative z-50",{"overflow-hidden":M!==y.HeaderNavigationBlockType.Supports}),children:de}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:j})]}),h&&(0,e.jsxs)("div",{className:"absolute left-0 z-[999] flex w-full bg-black/70 h-[100dvh] top-full",children:[(0,e.jsx)("div",{className:"absolute w-[272px] bg-white p-4",style:{right:`calc(100% - ${i?.current?.getBoundingClientRect()?.right}px)`,top:"-36px"},children:p?.email?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l.Text,{html:p?.nick_name||O?.welcome,className:"text-sm font-bold"}),(0,e.jsx)("div",{className:"h-[1px] mt-2 bg-[#D9D9D9]"}),(0,e.jsx)("div",{className:"mt-2",children:O?.profiles?.map(g=>(0,e.jsx)(W,{className:"py-2",label:g?.title,href:g?.url},g.id))})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(P.Polygon,{className:"absolute -top-2 text-white right-[46px] z-30"}),(0,e.jsx)(l.Text,{html:O?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col gap-1",children:O?.benefits?.map(g=>(0,e.jsxs)("div",{className:"flex items-center gap-[6px]",children:[(0,e.jsx)(l.Picture,{source:g.benefitIcon?.url,className:"size-4",alt:g.benefit,width:16,height:16}),(0,e.jsx)(l.Text,{html:g.benefit,className:"text-sm font-bold leading-[1.4]"})]},g.id))}),(0,e.jsxs)("div",{className:"mt-4 flex items-center gap-2",children:[(0,e.jsx)(l.Button,{variant:"secondary",size:"lg",onClick:()=>m?.join?.(),children:(0,e.jsx)(l.Text,{html:O?.primaryButton||"Join Now",className:"font-bold"})}),(0,e.jsx)(l.Button,{variant:"primary",size:"lg",onClick:()=>m?.login?.(),children:(0,e.jsx)(l.Text,{html:O?.secondaryButton||"Log In",className:"font-bold"})})]})]})}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:()=>D(!1)})]})]})}),Ne=a.default.memo(({sidebarCategoriesMetadata:t,seriesMetadata:n})=>{const{buildProps:o}=(0,B.useNavContext)(),[c,r]=(0,a.useState)([]),[b,d]=(0,a.useState)(-1),m=(0,a.useRef)(null),p=(0,a.useCallback)(()=>{const s=t?.subcategories;if(!s?.length)return;const x=s.findIndex(i=>!!i?.subSubCategories),f=s.findIndex(i=>!i?.subSubCategories),u=s.map((i,h)=>({index:h,open:x===h||f===h}));r(u)},[t]);(0,a.useEffect)(()=>{p()},[p]);const v=(0,a.useMemo)(()=>{const s=t?.subcategories?.[c?.find(f=>f.open)?.index||0],x=n?.find(f=>f?.label?.toLowerCase()===s?.label?.toLowerCase())||{};if(s?.collections){const f=o?.categories?.[s?.collections]||{};return{label:x?.label,isCollection:!0,banner:x?.banner,primary:x?.primary,series:[{products:f?.products}]}}else if(s?.subSubCategories){const f=s?.subSubCategories?.[b],u=n?.find(i=>i?.label?.toLowerCase()===f?.label?.toLowerCase())||{};if(f?.collections){const i=o?.categories?.[f?.collections]||{};return{label:u?.label,isCollection:!0,banner:u?.banner,primary:u?.primary,series:[{products:i?.products}]}}else return u}else return x},[t,c,b,n]),k=(0,a.useCallback)((s,x)=>{if(x?.subSubCategories?.length>0?d(0):d(-1),x?.subSubCategories?.length>0)r(f=>f.map(u=>u.index===s?{...u,open:!0}:{...u,open:!1}));else{const u=t?.subcategories?.findIndex(i=>!!i?.subSubCategories);r(i=>i.map(h=>({...h,open:h.index===s||h.index===u})))}},[t,p]),w=(s,x)=>{r(f=>f.map(u=>u.index===s?{...u,open:!0}:{...u,open:!1})),d(x)};return(0,e.jsxs)(l.Container,{childClassName:"lg-desktop:gap-12 flex bg-white gap-8",children:[(0,e.jsxs)("div",{className:"lg-desktop:basis-[356px] flex basis-[284px] flex-col gap-4 py-4",style:{userSelect:"none"},ref:m,children:[(0,e.jsx)("div",{className:"desktop:h-[416px] flex flex-col overflow-y-auto",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:t?.subcategories?.map((s,x)=>{const f=Array.isArray(s?.subSubCategories)&&s?.subSubCategories?.length>0;return(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:(0,N.cn)("flex cursor-pointer items-center justify-between",{"bg-[#F5F5F7]":!f&&c?.find(u=>u.index===x)?.open}),onClick:()=>{k(x,s)},children:[(0,e.jsx)(l.Text,{html:s.label,className:"p-4 text-sm font-bold leading-[1.4]"}),f&&(0,e.jsx)(P.DownArrow,{className:(0,N.cn)("size-4",{"rotate-180":c?.find(u=>u.index===x)?.open})})]}),c?.find(u=>u.index===x)?.open&&(0,e.jsx)("div",{className:"flex flex-col",children:s.subSubCategories?.map((u,i)=>(0,e.jsx)(l.Text,{html:u.label,onClick:()=>w(x,i),className:(0,N.cn)("cursor-pointer hover:bg-[#F5F5F7] px-6 py-4 text-sm font-bold leading-[1.4] text-[#6D6D6F]",{"bg-[#F5F5F7]":b===i})},`subSubItem-${x}-${i}`))})]},`subcategoryItem-${x}`)})}),t&&(0,e.jsx)("div",{className:"flex",children:(0,e.jsxs)("div",{className:"flex flex-col gap-4",children:[t?.primary&&(0,e.jsx)(l.Button,{as:"a",href:t?.primary?.url,variant:"primary",size:"lg",className:"text-sm lg-desktop:text-base",children:t?.primary?.label}),t?.secondary&&(0,e.jsx)(l.Button,{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})]})})]}),(0,e.jsxs)("div",{className:"flex-1 py-4",children:[Reflect.ownKeys(v).length>0&&(0,e.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(l.Text,{html:v?.label,className:"text-xl lg-desktop:text-2xl font-bold leading-[1.4]"}),v?.primary&&!v?.primary?.hide&&(0,e.jsx)(l.Button,{as:"a",href:v?.primary?.url,variant:"link",size:"lg",className:"justify-start !p-0 text-sm lg-desktop:text-base font-bold leading-[1.2] no-underline",children:v?.primary?.label})]}),(0,e.jsx)(l.Link,{href:v?.guide?.url,className:"text-sm lg-desktop:text-base leading-[1.2] text-[#6D6D6F]",children:v?.guide?.label})]}),(0,e.jsx)("div",{className:"flex flex-col gap-4 overflow-y-auto h-[426px]",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:v?.series?.map((s,x)=>(0,e.jsxs)("div",{children:[s.label&&(0,e.jsx)(l.Text,{html:s.label,className:"text-sm mb-2 font-bold leading-[1.4] text-[#6D6D6F]"}),(0,e.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[!!v?.banner&&(0,e.jsx)(l.Link,{asChild:!v?.banner?.href,href:v?.banner?.href,children:(0,e.jsxs)("div",{className:"relative [&_img]:hover:scale-105 [&_img]:hover:transition-all [&_img]:hover:duration-300",children:[(0,e.jsx)(l.Picture,{source:v?.banner?.imageUrl,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)(l.Heading,{size:2,html:v?.banner?.title||"Buy in Guide",className:"font-bold text-white"}),(0,e.jsx)(l.Text,{html:v?.banner?.desc||"20.000mAh",className:"text-sm text-white font-bold"})]})]})}),s.products?.map((f,u)=>(0,e.jsx)(Y,{seriesLabel:s?.label,product:f,isCollection:v?.isCollection},`seriesProductItem-${u}`))]})]},`seriesItem-${x}`))})]})]})}),ke=({multicolMetadata:t})=>{const n=(0,a.useRef)(null);return(0,e.jsx)("div",{ref:n,children:(0,e.jsx)(l.Container,{childClassName:"bg-white",className:"h-full",children:(0,e.jsx)("div",{className:"flex gap-4 py-4",children:t?.map((o,c)=>(0,e.jsx)("div",{className:"w-1/4",children:(0,e.jsx)(Z,{item:o})},`multicolItem-${o?.label}-${c}`))})})})},we=({supportsMetadata:t,currentNavItemRef:n})=>{const o=(0,a.useRef)(null),[c,r]=(0,a.useState)(null),[b,d]=(0,a.useState)(0);(0,a.useEffect)(()=>{if(o?.current){const p=o?.current?.getBoundingClientRect();d(p.height)}},[o]);const m=(0,se.debounce)(()=>{if(n){const p=n.getBoundingClientRect();r(p)}},500);return(0,a.useEffect)(()=>(m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}),[m]),(0,a.useEffect)(()=>{if(n){const p=n.getBoundingClientRect();r(p)}},[n]),(0,e.jsx)("div",{className:"absolute top-0 h-full bg-white transition-all duration-500 overflow-hidden",style:{right:`calc(100% - ${c?.right}px)`,height:b},children:(0,e.jsx)("div",{ref:o,className:"p-4",children:t?.map(p=>(0,e.jsx)("div",{className:"py-2",children:(0,e.jsx)(l.Link,{href:p.url,className:"text-sm font-bold leading-[1.4] no-underline",children:p.label})},p.id))})})},Y=({product:t,isCollection:n,position:o,seriesLabel:c})=>{const{buildProps:r,onSeriesProductClick:b}=(0,B.useNavContext)();let d=n?t:r?.products?.find(k=>k.handle===t.handle);const m=d?.variants?.find(k=>k.sku===t.sku)||d?.variants?.[0],p=(0,a.useMemo)(()=>`/products/${d?.handle}?variant=${(0,N.atobID)(m?.id)}`,[d?.handle,m?.id]),v=(0,a.useMemo)(()=>d?.tags?.filter?.(k=>k?.startsWith?.("CLtag"))?.map?.(k=>k?.replace?.("CLtag:",""))?.slice?.(0,2),[d?.tags]);return m?.availableForSale?(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-4 bg-[#F5F5F7] px-4 py-3 [&_img]:hover:scale-105",children:[(0,e.jsx)("div",{className:"shrink-0",children:(0,e.jsx)(l.Picture,{source:`${m?.image?.url||t?.images?.[0]?.url}}`,width:90,height:90,className:"size-[96px]",imgClassName:"object-contain h-full"})}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("div",{className:"flex gap-1",children:Array.isArray(v)&&v?.map(k=>(0,e.jsx)(l.Text,{as:"p",html:k,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]"}))}),(0,e.jsx)(l.Link,{href:p,onClick:k=>{k.preventDefault(),window.open(p),b?.(d,o||0,c)},className:"no-underline hover:text-current",children:(0,e.jsx)(l.Text,{className:"lg-desktop:h-[44px] lg-desktop:text-base line-clamp-2 h-[40px] text-sm font-bold leading-[1.4]",html:d?.title||t?.name})}),t?.desc&&(0,e.jsx)(l.Text,{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},Z=({item:t,allPicture:n})=>(0,e.jsxs)(e.Fragment,{children:[t?.columns&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l.Text,{html:t.label,as:"div",className:"my-2 text-sm font-bold leading-[1.4] text-[#6D6D6F]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col",children:t.columns?.map(o=>(0,e.jsxs)("div",{className:"py-2 flex items-center gap-1",children:[(0,e.jsx)(l.Link,{href:o.url,asChild:!o.url,className:"text-sm font-bold leading-[1.4] no-underline",children:o.label}),o?.badge&&(0,e.jsx)(l.Text,{as:"p",html:o?.badge||"badge",className:"text-sm font-bold !leading-[22px] text-brand-0 h-[24px] rounded-full border-[1.6px] border-[var(--brand-color-0)] px-[6px]"})]},o.label))})]}),t?.imageUrl&&(0,e.jsx)("div",{className:(0,N.cn)("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":n}),children:(0,e.jsxs)(l.Link,{href:t.url,asChild:!t.url,children:[(0,e.jsx)(l.Picture,{source:t.imageUrl,width:404,height:280,className:"size-full",imgClassName:"object-cover h-full hover:scale-105 transition-all duration-300"}),(0,e.jsxs)("div",{className:"absolute bottom-4 left-4 z-10 flex flex-col justify-end no-underline",children:[(0,e.jsx)(l.Text,{html:t.title,className:(0,N.cn)("lg-desktop:text-2xl text-xl font-bold leading-[1.2] text-white",{"text-black":t?.theme==="dark"})}),t.subtitle&&(0,e.jsx)(l.Text,{html:t.subtitle,className:(0,N.cn)("text-sm font-bold leading-[1.4] text-white",{"text-black":t?.theme==="dark"})}),t?.primary?.label&&(0,e.jsx)(l.Button,{as:"a",href:t?.primary?.url,variant:"link",size:"lg",className:(0,N.cn)("text-sm font-bold mr-auto !p-0 leading-[1.4] text-white",{"text-black":t?.theme==="dark"}),children:t?.primary?.label||"more"})]})]})})]}),Ce=(0,a.forwardRef)(({data:t,className:n,onPrimaryNavClick:o},c)=>{const r=(0,a.useMemo)(()=>(0,H.WithGroupCategory)(t?.categories?.filter(M=>M?.mobileShow)),[t]),{currentMenu:b,setCurrentMenu:d,subSubCategory:m}=(0,B.useNavContext)(),[p,v]=(0,a.useState)(!1),[k,w]=(0,a.useState)(0),[s,x]=(0,a.useState)(null),f=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(f?.current&&p){const M=f?.current?.getBoundingClientRect();w(window?.innerHeight-(M?.bottom||0))}},[p]),(0,K.useGSAP)(()=>{J.gsap.fromTo(f.current,{height:0},{height:k,duration:.3})},[k]),(0,a.useEffect)(()=>{document.documentElement.style.overflow=p?"hidden":"auto"},[p]);const u=(0,a.useMemo)(()=>s?.components?.[0]?.blockType,[s]),i=(0,H.WithSupports)(Le,{categoriesItem:s}),h=(0,H.WithSidebar)(De,s),D=(0,H.WithMulticol)(Me,s),L=(0,a.useMemo)(()=>{switch(u){case y.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)(h,{});case y.HeaderNavigationBlockType.Supports:return(0,e.jsx)(i,{});case y.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(D,{});default:return null}},[u,s,i]),C=(0,a.useCallback)(()=>{v(!1),w(0),d&&d(y.HeaderNavigationMenu.Primary)},[v,w,d]),A=(0,a.useMemo)(()=>t?.headerBar?.actions?.filter(M=>M?.mobileShow&&M?.blockType!==y.HeaderNavigationActionBlockType.Profile),[t]),S=(0,a.useMemo)(()=>t?.headerBar?.actions?.find(M=>M?.mobileShow&&M?.blockType===y.HeaderNavigationActionBlockType.Profile)||{},[t]),T=(0,a.useMemo)(()=>{switch(b){case y.HeaderNavigationMenu.Primary:return(0,e.jsx)(ze,{actions:A,menuOpen:p,onMenuOpenClose:()=>{v(!1),w(0)},onMenuOpenClick:()=>v(!0)});case y.HeaderNavigationMenu.Secondary:return(0,e.jsx)(le,{title:s?.text,onMenuOpenClose:C,onMenuBackClick:()=>d?.(y.HeaderNavigationMenu.Primary)});case y.HeaderNavigationMenu.Third:return(0,e.jsx)(le,{title:m?.label,onMenuOpenClose:C,onMenuBackClick:()=>d?.(y.HeaderNavigationMenu.Secondary)});default:return null}},[p,b,d,s,A,m,C]),j=(0,a.useCallback)((M,$)=>{const F=Array.isArray(r)?Array.isArray(r[M])?r[M][$]:{}:{};x(F),F?.components?.[0]?.blockType===y.HeaderNavigationBlockType.Links?F?.components?.[0]?.url&&window.open(F?.components?.[0]?.url):d?.(y.HeaderNavigationMenu.Secondary)},[r,d]);return(0,e.jsxs)(l.Container,{className:(0,N.cn)("relative h-[52px]",n),children:[T,p&&(0,e.jsx)("div",{ref:f,className:"absolute left-0 top-full text-black border-t border-[#E4E5E6] z-[999] w-full overflow-y-auto bg-white",style:{height:k},children:b===y.HeaderNavigationMenu.Primary?(0,e.jsx)(Se,{categories:r,onPrimaryMenuClick:j,onPrimaryNavClick:o,profileAction:S}):L})]})}),Se=({categories:t,onPrimaryMenuClick:n,profileAction:o,onPrimaryNavClick:c})=>(0,e.jsxs)("div",{className:"flex h-full flex-col justify-between",children:[(0,e.jsx)("div",{className:"tablet:px-8 laptop:px-16 p-4",children:t?.map((r,b)=>(0,e.jsxs)("div",{className:"",children:[r?.map((d,m)=>(0,e.jsx)(W,{label:d.text,onClick:()=>{const v=(t?.flat()||[])?.findIndex(k=>k?.id===t[b][m]?.id);n(b,m),c?.(d,v)},icon:d.components?.[0]?.icon},d.id)),(0,e.jsx)("div",{className:(0,N.cn)("my-2 h-px w-full bg-[#E5E5E7]",{hidden:b===t.length-1})})]},`groupCategory-${b}`))}),(0,e.jsx)(Pe,{profileAction:o})]}),De=({sidebarCategoriesMetadata:t,seriesMetadata:n})=>{const{currentMenu:o,setCurrentMenu:c,subSubCategory:r,setSubSubCategory:b,setCurrentSeriesMetadata:d,currentSeriesMetadata:m,buildProps:p}=(0,B.useNavContext)(),[v,k]=(0,a.useState)([]),[w,s]=(0,a.useState)([]);(0,a.useEffect)(()=>{t?.subcategories?.length&&k(t?.subcategories?.map((i,h)=>({index:h,open:!1})))},[t]),(0,a.useEffect)(()=>{r?.subSubCategories?.length&&s(r?.subSubCategories?.map((i,h)=>({index:h,open:h===0})))},[r]);const x=(0,a.useCallback)((i,h)=>{c&&c(y.HeaderNavigationMenu.Third),b?.(i);const D=n?.find(L=>h!==void 0?i?.subSubCategories?.[h]?.label?.toLowerCase()===L.label?.toLowerCase():i?.label?.toLowerCase()===L.label?.toLowerCase())||{};if(i?.collections){const L=p?.categories?.[i?.collections]||{};d?.({label:D?.label,isCollection:!0,banner:D?.banner,primary:D?.primary,series:[{products:L?.products}]})}else d?.(D)},[n,t,c,b,d]),f=(0,a.useMemo)(()=>n?.find(i=>!!i?.guide)?.guide,[n,t]);return(0,a.useMemo)(()=>{switch(o){case y.HeaderNavigationMenu.Secondary:return(0,e.jsxs)("div",{className:"tablet:px-8 laptop:px-16 flex h-full flex-col justify-between tablet:justify-start tablet:gap-16 p-4",children:[(0,e.jsx)("div",{children:t?.subcategories?.map((i,h)=>(0,e.jsx)("div",{children:(0,e.jsx)(W,{label:i?.label,active:v.find(D=>D.index===h)?.open,onClick:()=>{x(i)}})},`${i.label}-${h}`))}),(0,e.jsxs)("div",{className:"tablet:items-start flex flex-col items-center gap-4",children:[t?.primary&&(0,e.jsx)(l.Button,{as:"a",href:t?.primary?.url,variant:"primary",size:"lg",className:"tablet:w-auto w-full text-base",children:t?.primary?.label}),t?.secondary&&(0,e.jsx)(l.Button,{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 y.HeaderNavigationMenu.Third:return(0,e.jsxs)("div",{className:"tablet:px-8 laptop:px-16 p-4",children:[r?.subSubCategories?r?.subSubCategories?.map((i,h)=>{const D=n?.find(C=>C.label.toLowerCase()===i?.label?.toLowerCase())||{};let L={};if(i?.collections){const C=p?.categories?.[i?.collections]||{};L={label:D?.label,isCollection:!0,banner:D?.banner,primary:D?.primary,series:[{products:C?.products}]}}else L=D;return(0,e.jsxs)("div",{children:[Reflect.ownKeys(i).length>0&&(0,e.jsx)(ee,{matchSeriesMetadata:L,onSubSubCategoryItemClick:()=>s(C=>C.map((A,S)=>({...A,open:S===h}))),expanded:!!w?.find(C=>C.index===h)?.open}),w?.find(C=>C.index===h)?.open&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(te,{matchSeriesMetadata:L}),L?.primary&&(0,e.jsx)("div",{className:"text-center my-4",children:(0,e.jsx)(l.Button,{as:"a",href:L?.primary?.url,className:"text-base no-underline leading-[1.2]",variant:"secondary",size:"base",children:L?.primary?.label})})]})]},`${i.label}-${h}`)}):(0,e.jsxs)(e.Fragment,{children:[Reflect.ownKeys(m).length>0&&(0,e.jsx)(ee,{matchSeriesMetadata:m}),(0,e.jsx)(te,{matchSeriesMetadata:m}),m?.primary&&(0,e.jsx)("div",{className:"text-center my-4 ",children:(0,e.jsx)(l.Button,{as:"a",href:m?.primary?.url,variant:"secondary",size:"base",className:"text-base no-underline leading-[1.2]",children:m?.primary?.label})})]}),f&&(0,e.jsx)(l.Link,{href:f?.url,children:(0,e.jsx)("div",{className:"mt-4",children:(0,e.jsx)(l.Text,{html:f?.label,className:"text-sm font-bold leading-[1.2] text-[#6D6D6F]"})})})]});default:return null}},[o,t,c,n,v,w,b,r,d,m])},ee=({matchSeriesMetadata:t,onSubSubCategoryItemClick:n,expanded:o})=>(0,e.jsxs)("div",{className:"tablet:pt-0 py-4 flex items-center justify-between",onClick:n,children:[t?.label&&(0,e.jsx)(l.Text,{html:t?.label,className:"text-sm font-bold leading-[1.4]"}),n&&(0,e.jsx)(P.DownArrow,{className:(0,N.cn)("size-5",{"rotate-180":o})})]}),te=({matchSeriesMetadata:t})=>(0,e.jsx)("div",{className:"flex flex-col gap-2 laptop:gap-3",children:!!t?.series?.length&&t?.series?.map((n,o)=>(0,e.jsxs)("div",{children:[n.label&&(0,e.jsx)(l.Text,{html:n.label,className:"text-sm mb-2 font-bold leading-[1.4] text-[#3D3D3F]"}),(0,e.jsxs)("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&&(0,e.jsx)(l.Link,{asChild:!t?.banner?.href,href:t?.banner?.href,children:(0,e.jsxs)("div",{className:"relative [&_img]:hover:scale-105 [&_img]:hover:transition-all [&_img]:hover:duration-300",children:[(0,e.jsx)(l.Picture,{source:t?.banner?.imageUrl,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)(l.Heading,{size:2,html:t?.banner?.title||"Buy in Guide",className:(0,N.cn)("font-bold text-white",{"text-black":t?.banner?.theme==="dark"})}),(0,e.jsx)(l.Text,{html:t?.banner?.desc||"20.000mAh",className:(0,N.cn)("text-sm text-white font-bold",{"text-black":t?.banner?.theme==="dark"})})]})]})}),n.products?.map((c,r)=>(0,e.jsx)(Y,{position:r,product:c,seriesLabel:t?.label,isCollection:t?.isCollection},`seriesProductItem-${o}-${r}`))]})]},`seriesItem-${o}`))}),Le=({supportsMetadata:t})=>(0,e.jsx)("div",{className:"tablet:px-8 laptop:px-16 p-4",children:t?.map(n=>(0,e.jsx)(W,{href:n.url,label:n.label,onClick:()=>{}},n.id))}),Me=({multicolMetadata:t})=>{const n=(0,a.useMemo)(()=>!t?.some(o=>!!o.columns),[t]);return(0,e.jsx)("div",{className:(0,N.cn)("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":n}),children:t?.map((o,c)=>(0,e.jsx)("div",{children:(0,e.jsx)(Z,{item:o,allPicture:n})},`multicolItem-${o?.label}-${c}`))})},Pe=({profileAction:t})=>{const[n,o]=(0,a.useState)(!1),{profile:c,event:r}=(0,B.useNavContext)();return(0,e.jsxs)("div",{className:(0,N.cn)("tablet:px-8 laptop:px-16 bg-[#F5F5F7] px-4 py-6",{"p-4":n}),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",onClick:()=>o(!n),children:[(0,e.jsxs)("div",{className:"flex items-center gap-[14px]",children:[(0,e.jsx)("div",{className:"flex size-[40px] shrink-0 items-center justify-center rounded-full bg-white",children:(0,e.jsx)(P.User,{})}),(0,e.jsx)(l.Text,{html:c?.nick_name||t?.welcome,className:"text-base font-bold leading-[1.4]"})]}),!c?.email&&(0,e.jsx)(P.DownArrow,{className:(0,N.cn)("size-5 laptop:size-4",{"rotate-180":n})})]}),c?.email&&(0,e.jsx)("div",{className:"mt-4",children:t?.profiles?.map(b=>(0,e.jsx)(W,{label:b?.title,href:b?.url},b.id))}),n&&!c?.email&&(0,e.jsxs)("div",{className:"mt-4",children:[(0,e.jsx)(l.Text,{html:t?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col gap-1",children:t?.benefits?.map(b=>(0,e.jsxs)("div",{className:"flex items-center gap-[6px]",children:[(0,e.jsx)(l.Picture,{source:b.benefitIcon?.url,className:"size-4",alt:b.benefit,width:16,height:16}),(0,e.jsx)(l.Text,{html:b.benefit,className:"text-sm font-bold leading-[1.4]"})]},b.id))})]}),!c?.email&&(0,e.jsxs)("div",{className:"mt-4 flex items-center gap-3",children:[(0,e.jsx)(l.Button,{className:"tablet:flex-none flex-1",variant:"secondary",size:"base",onClick:()=>r?.join?.(),children:(0,e.jsx)(l.Text,{html:t?.primaryButton||"Join Now",className:"text-sm font-bold leading-[1.4]"})}),(0,e.jsx)(l.Button,{className:"tablet:flex-none flex-1",variant:"primary",size:"base",onClick:()=>r?.login?.(),children:(0,e.jsx)(l.Text,{html:t?.secondaryButton||"Log In",className:"text-sm font-bold leading-[1.4]"})})]})]})},ze=({menuOpen:t,onMenuOpenClose:n,onMenuOpenClick:o,actions:c})=>(0,e.jsxs)("div",{className:"flex h-full items-center justify-between gap-4",children:[(0,e.jsx)(ae,{}),(0,e.jsxs)("div",{className:"desktop:gap-6 flex items-center gap-4",children:[(0,e.jsx)(ne,{actions:c}),t?(0,e.jsx)(P.Close,{className:"size-5",onClick:()=>n()}):(0,e.jsx)(P.Menu,{className:"size-5",onClick:()=>o()})]})]}),ae=()=>{const{payloadData:t,isMobile:n}=(0,B.useNavContext)();return(0,e.jsx)("div",{className:"[&>svg]:w-full hover:text-brand-0 cursor-pointer",onClick:()=>{window.location.href="/"},dangerouslySetInnerHTML:{__html:n?t?.headerBar?.mobileLogo:t?.headerBar?.desktopLogo}})},ne=(0,a.forwardRef)(({actions:t,activeStatus:n=!1},o)=>{const{event:c}=(0,B.useNavContext)(),[r,b]=(0,a.useState)(null),d=(0,a.useCallback)((m,p)=>{switch(b(p),m?.blockType){case y.HeaderNavigationActionBlockType.Search:c?.search?.();break;case y.HeaderNavigationActionBlockType.Cart:c?.cart?.();break;case y.HeaderNavigationActionBlockType.Profile:c?.profile?.();break;case y.HeaderNavigationActionBlockType.Livestream:c?.livestream?.();break;default:return()=>{}}},[c]);return(0,e.jsx)("div",{className:"desktop:gap-6 flex items-center gap-4",children:Array.isArray(t)&&t?.map((m,p)=>(0,e.jsx)("div",{ref:m.blockType===y.HeaderNavigationActionBlockType.Profile?o:null,onClick:()=>d(m,p),children:(0,e.jsx)(l.Text,{html:m.icon,className:(0,N.cn)("cursor-pointer size-5",{"text-brand-0":n&&r===p})})},m.id))})}),le=({title:t,onMenuOpenClose:n,onMenuBackClick:o})=>(0,e.jsxs)("div",{className:"flex h-full items-center gap-3",children:[(0,e.jsx)(P.LeftArrow,{className:"size-5",onClick:()=>o()}),(0,e.jsx)(l.Text,{html:t,className:"flex-1 text-center text-base font-bold leading-[1.4]"}),(0,e.jsx)(P.Close,{className:"size-5",onClick:()=>n()})]}),W=({label:t,href:n,onClick:o,active:c,icon:r,className:b})=>(0,e.jsx)("div",{className:(0,N.cn)("flex cursor-pointer items-center justify-between py-4",b),onClick:o,children:(0,e.jsxs)(l.Link,{href:n,asChild:!n,className:"flex w-full items-center justify-between no-underline",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)(l.Text,{html:t,className:(0,N.cn)("text-sm font-bold leading-[1.4]",{underline:r})}),r&&(0,e.jsx)(l.Text,{html:r})]}),(0,e.jsx)(P.RightArrow,{className:(0,N.cn)("size-5 laptop:size-4",{"rotate-90":c})})]})});var Ee=(0,oe.withLayout)(he);
|
|
1
|
+
"use strict";"use client";var me=Object.create;var U=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ve=Object.prototype.hasOwnProperty;var ge=(t,n)=>{for(var o in n)U(t,o,{get:n[o],enumerable:!0})},X=(t,n,o,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of be(n))!ve.call(t,r)&&r!==o&&U(t,r,{get:()=>n[r],enumerable:!(c=pe(n,r))||c.enumerable});return t};var G=(t,n,o)=>(o=t!=null?me(fe(t)):{},X(n||!t||!t.__esModule?U(o,"default",{value:t,enumerable:!0}):o,t)),ye=t=>X(U({},"__esModule",{value:!0}),t);var He={};ge(He,{default:()=>Ee});module.exports=ye(He);var e=require("react/jsx-runtime"),a=G(require("react")),l=require("../../components/index.js"),oe=require("../../shared/Styles.js"),N=require("../../helpers/utils.js"),B=G(require("./NavProvider.js")),y=require("./types.js"),Re=require("react-responsive"),se=require("es-toolkit"),re=G(require("jump.js")),K=require("@gsap/react"),J=require("gsap"),H=require("./withCategory.js"),P=require("./icons/index.js"),ie=G(require("../NavigationSearch/index.js"));const he=(0,a.forwardRef)((t,n)=>{const{data:{headerNavigation:o}={},buildProps:c,event:r,profile:b,theme:d="light",isTop:m=!1,searchResult:p,onSearch:v,isSearching:k,keywords:w,onPrimaryNavClick:s,onSeriesProductClick:x}=t,f=(0,a.useRef)(null),[u,i]=(0,a.useState)(!1),[h,D]=(0,a.useState)(!1),[L,C]=(0,a.useState)(!1),[A,S]=(0,a.useState)(!1),T=(0,a.useRef)(null),j=()=>{const $=document?.querySelector("body")?.offsetWidth||0;S($<=1440)};(0,a.useEffect)(()=>(j(),window.addEventListener("resize",j),()=>{window.removeEventListener("resize",j)}),[]),(0,a.useImperativeHandle)(n,()=>T.current),(0,a.useEffect)(()=>{T.current&&m&&(0,re.default)(T.current,{duration:0,offset:T.current?.getBoundingClientRect()?.bottom||0})},[m]),(0,a.useEffect)(()=>{r&&(r.search=()=>i(!0))},[r]),(0,K.useGSAP)(()=>{f?.current&&u&&J.gsap.fromTo(f.current,{height:0},{height:"auto",duration:.3})},[u]),(0,a.useEffect)(()=>{document.documentElement.style.overflow=u?"hidden":"auto"},[u]);const M=(0,a.useMemo)(()=>o?.headerBar?.actions?.find($=>$?.blockType===y.HeaderNavigationActionBlockType.Search)?.searchBar?.[0]||{},[o]);return(0,e.jsx)(B.default,{buildProps:c,profile:b,isMobile:A,event:r,payloadData:o,onSeriesProductClick:x,children:(0,e.jsx)("header",{"data-ui-component-id":"HeaderNavigation",className:"relative z-[100]",ref:T,children:(0,e.jsxs)("div",{className:(0,N.cn)("hover:text-black hover:bg-white",d==="light"?"text-black":"text-white",{}),onClick:()=>C(!0),children:[(0,e.jsx)(xe,{data:o,className:"hidden desktop:block",theme:d,onNavItemClick:()=>C(!0),onPrimaryNavClick:s}),(0,e.jsx)(Ce,{data:o,className:"block desktop:hidden",onPrimaryNavClick:s}),u&&(0,e.jsxs)("div",{className:"absolute z-[60] top-0 left-0 w-full bg-black/70 flex flex-col",style:{height:`calc(100dvh - ${T?.current?.getBoundingClientRect()?.top}px)`},children:[(0,e.jsx)("div",{ref:f,className:(0,N.cn)("overflow-y-auto",{}),children:(0,e.jsx)(ie.default,{data:M,keywords:w,isSearching:k,searchResult:p,onSearch:$=>{v?.($)},onClose:()=>{v?.(),i(!1)}})}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:()=>i(!1)})]})]})})})}),xe=(0,a.forwardRef)((t,n)=>{const{data:o,onNavItemClick:c,className:r,theme:b,onPrimaryNavClick:d}=t,{event:m,profile:p}=(0,B.useNavContext)(),[v,k]=(0,a.useState)(!1),w=(0,a.useMemo)(()=>(0,H.WithGroupCategory)(o?.categories?.filter(g=>g?.pcShow)),[o]),[s,x]=(0,a.useState)(null),[f,u]=(0,a.useState)([]),i=(0,a.useRef)(null),[h,D]=(0,a.useState)(!1),L=(0,a.useRef)(null),C=(0,a.useRef)(null),A=(0,a.useRef)(w.map(g=>Array(g?.length||0).fill(null)));(0,a.useEffect)(()=>{w?.length&&u(w?.map((g,z)=>g?.map((E,R)=>({groupIndex:z,index:R,open:!1}))))},[w]);const S=(0,a.useMemo)(()=>{let g=null;for(const z of f){for(const E of z)if(E.open){g=E;break}if(g)break}return g},[f]);(0,a.useEffect)(()=>{document.documentElement.style.overflow=S?.open||h?"hidden":"auto"},[S?.open,h]);const T=(g,z,E)=>{if(D(!1),s?.components?.[0]?.blockType===y.HeaderNavigationBlockType.Links)s?.components?.[0]?.url&&window.open(s?.components?.[0]?.url);else{const R=w?.flat()||[],I=R?.findIndex(Q=>Q?.id===w[z][E]?.id);g.stopPropagation(),c?.(),d?.(R[I],I),x(w[z][E]),u(Q=>Q.map(ue=>ue.map(_=>_.groupIndex===z&&_.index===E?{..._,open:!_.open}:{..._,open:!1})))}},j=()=>{u(g=>g.map(z=>z.map(E=>({...E,open:!1}))))},M=(0,a.useMemo)(()=>{if(s)return s?.components?.[0]?.blockType},[s]),$=(0,H.WithSidebar)(Ne,s),F=(0,H.WithMulticol)(ke,s),ce=(0,H.WithSupports)(we,{categoriesItem:s,currentNavItemRef:A.current?.[S?.groupIndex||0]?.[S?.index||0]}),de=(0,a.useMemo)(()=>{switch(M){case y.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)($,{});case y.HeaderNavigationBlockType.Supports:return(0,e.jsx)(ce,{});case y.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(F,{});default:return null}},[M,s]),V=(0,a.useMemo)(()=>o?.headerBar?.actions?.filter(g=>g?.pcShow),[o]),O=(0,a.useMemo)(()=>V?.find(g=>g?.blockType===y.HeaderNavigationActionBlockType.Profile),[V]),q=(0,a.useCallback)(()=>{D(g=>!g)},[]);return(0,a.useEffect)(()=>{if(i?.current){const g=i.current;return g.addEventListener("click",q),()=>{g.removeEventListener("click",q)}}},[q]),(0,K.useGSAP)(()=>{S?.open&&J.gsap.fromTo(C?.current,{height:0},{height:"auto"})},[S?.open]),(0,e.jsxs)(l.Container,{className:(0,N.cn)("relative h-[96px]",r),children:[(0,e.jsxs)("div",{ref:L,onClick:j,className:"flex h-full flex-col justify-end gap-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)(ae,{}),(0,e.jsx)(ne,{ref:i,actions:V,activeStatus:h})]}),(0,e.jsx)("div",{className:"flex justify-between",children:w?.map((g,z)=>(0,e.jsx)("div",{className:"flex gap-3",children:g?.map((E,R)=>(0,e.jsx)("div",{ref:I=>{A.current[z][R]=I},className:"group cursor-pointer",children:(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 pb-4",onClick:I=>T(I,z,R),children:[(0,e.jsx)(l.Text,{html:E.text,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)(P.DownArrow,{className:(0,N.cn)("opacity-0 size-4 group-hover:opacity-100 transition-opacity duration-500",{"rotate-180":S?.groupIndex===z&&S?.index===R,"opacity-100":v&&S?.groupIndex===z&&S?.index===R})})]}),(0,e.jsx)("div",{className:(0,N.cn)("absolute bottom-0 left-0 h-[2px] w-0 transition-all duration-500",{"w-[calc(100%-20px)]":S?.groupIndex===z&&S?.index===R},b==="dark"?"bg-white":"bg-[#1D1D1F]")})]})},E.id))},`groupCategory-${z}`))})]}),(0,e.jsxs)("div",{className:(0,N.cn)("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:!(S?.open&&s)}),onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),style:{height:`calc(100dvh - ${L?.current?.getBoundingClientRect()?.bottom}px)`},children:[(0,e.jsx)("div",{ref:C,className:(0,N.cn)("relative z-50",{"overflow-hidden":M!==y.HeaderNavigationBlockType.Supports}),children:de}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:j})]}),h&&(0,e.jsxs)("div",{className:"absolute left-0 z-[999] flex w-full bg-black/70 h-[100dvh] top-full",children:[(0,e.jsx)("div",{className:"absolute w-[272px] bg-white p-4",style:{right:`calc(100% - ${i?.current?.getBoundingClientRect()?.right}px)`,top:"-36px"},children:p?.email?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l.Text,{html:p?.nick_name||O?.welcome,className:"text-sm font-bold"}),(0,e.jsx)("div",{className:"h-[1px] mt-2 bg-[#D9D9D9]"}),(0,e.jsx)("div",{className:"mt-2",children:O?.profiles?.map(g=>(0,e.jsx)(W,{className:"py-2",label:g?.title,href:g?.url},g.id))})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(P.Polygon,{className:"absolute -top-2 text-white right-[46px] z-30"}),(0,e.jsx)(l.Text,{html:O?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col gap-1",children:O?.benefits?.map(g=>(0,e.jsxs)("div",{className:"flex items-center gap-[6px]",children:[(0,e.jsx)(l.Picture,{source:g.benefitIcon?.url,className:"size-4",alt:g.benefit,width:16,height:16}),(0,e.jsx)(l.Text,{html:g.benefit,className:"text-sm font-bold leading-[1.4]"})]},g.id))}),(0,e.jsxs)("div",{className:"mt-4 flex items-center gap-2",children:[(0,e.jsx)(l.Button,{variant:"secondary",size:"lg",onClick:()=>m?.join?.(),children:(0,e.jsx)(l.Text,{html:O?.primaryButton||"Join Now",className:"font-bold"})}),(0,e.jsx)(l.Button,{variant:"primary",size:"lg",onClick:()=>m?.login?.(),children:(0,e.jsx)(l.Text,{html:O?.secondaryButton||"Log In",className:"font-bold"})})]})]})}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:()=>D(!1)})]})]})}),Ne=a.default.memo(({sidebarCategoriesMetadata:t,seriesMetadata:n})=>{const{buildProps:o}=(0,B.useNavContext)(),[c,r]=(0,a.useState)([]),[b,d]=(0,a.useState)(-1),m=(0,a.useRef)(null),p=(0,a.useCallback)(()=>{const s=t?.subcategories;if(!s?.length)return;const x=s.findIndex(i=>!!i?.subSubCategories),f=s.findIndex(i=>!i?.subSubCategories),u=s.map((i,h)=>({index:h,open:x===h||f===h}));r(u)},[t]);(0,a.useEffect)(()=>{p()},[p]);const v=(0,a.useMemo)(()=>{const s=t?.subcategories?.[c?.find(f=>f.open)?.index||0],x=n?.find(f=>f?.label?.toLowerCase()===s?.label?.toLowerCase())||{};if(s?.collections){const f=o?.categories?.[s?.collections]||{};return{label:x?.label,isCollection:!0,banner:x?.banner,primary:x?.primary,series:[{products:f?.products}]}}else if(s?.subSubCategories){const f=s?.subSubCategories?.[b],u=n?.find(i=>i?.label?.toLowerCase()===f?.label?.toLowerCase())||{};if(f?.collections){const i=o?.categories?.[f?.collections]||{};return{label:u?.label,isCollection:!0,banner:u?.banner,primary:u?.primary,series:[{products:i?.products}]}}else return u}else return x},[t,c,b,n]),k=(0,a.useCallback)((s,x)=>{if(x?.subSubCategories?.length>0?d(0):d(-1),x?.subSubCategories?.length>0)r(f=>f.map(u=>u.index===s?{...u,open:!0}:{...u,open:!1}));else{const u=t?.subcategories?.findIndex(i=>!!i?.subSubCategories);r(i=>i.map(h=>({...h,open:h.index===s||h.index===u})))}},[t,p]),w=(s,x)=>{r(f=>f.map(u=>u.index===s?{...u,open:!0}:{...u,open:!1})),d(x)};return(0,e.jsxs)(l.Container,{childClassName:"lg-desktop:gap-12 flex bg-white gap-8",children:[(0,e.jsxs)("div",{className:"lg-desktop:basis-[356px] flex basis-[284px] flex-col gap-4 py-4",style:{userSelect:"none"},ref:m,children:[(0,e.jsx)("div",{className:"desktop:h-[416px] flex flex-col overflow-y-auto",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:t?.subcategories?.map((s,x)=>{const f=Array.isArray(s?.subSubCategories)&&s?.subSubCategories?.length>0;return(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:(0,N.cn)("flex cursor-pointer items-center justify-between",{"bg-[#F5F5F7]":!f&&c?.find(u=>u.index===x)?.open}),onClick:()=>{k(x,s)},children:[(0,e.jsx)(l.Text,{html:s.label,className:"p-4 text-sm font-bold leading-[1.4]"}),f&&(0,e.jsx)(P.DownArrow,{className:(0,N.cn)("size-4",{"rotate-180":c?.find(u=>u.index===x)?.open})})]}),c?.find(u=>u.index===x)?.open&&(0,e.jsx)("div",{className:"flex flex-col",children:s.subSubCategories?.map((u,i)=>(0,e.jsx)(l.Text,{html:u.label,onClick:()=>w(x,i),className:(0,N.cn)("cursor-pointer hover:bg-[#F5F5F7] px-6 py-4 text-sm font-bold leading-[1.4] text-[#6D6D6F]",{"bg-[#F5F5F7]":b===i})},`subSubItem-${x}-${i}`))})]},`subcategoryItem-${x}`)})}),t&&(0,e.jsx)("div",{className:"flex",children:(0,e.jsxs)("div",{className:"flex flex-col gap-4",children:[t?.primary&&(0,e.jsx)(l.Button,{as:"a",href:t?.primary?.url,variant:"primary",size:"lg",className:"text-sm lg-desktop:text-base",children:t?.primary?.label}),t?.secondary&&(0,e.jsx)(l.Button,{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})]})})]}),(0,e.jsxs)("div",{className:"flex-1 py-4",children:[Reflect.ownKeys(v).length>0&&(0,e.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(l.Text,{html:v?.label,className:"text-xl lg-desktop:text-2xl font-bold leading-[1.4]"}),v?.primary&&!v?.primary?.hide&&(0,e.jsx)(l.Button,{as:"a",href:v?.primary?.url,variant:"link",size:"lg",className:"justify-start !p-0 text-sm lg-desktop:text-base font-bold leading-[1.2] no-underline",children:v?.primary?.label})]}),(0,e.jsx)(l.Link,{href:v?.guide?.url,className:"text-sm lg-desktop:text-base leading-[1.2] text-[#6D6D6F]",children:v?.guide?.label})]}),(0,e.jsx)("div",{className:"flex flex-col gap-4 overflow-y-auto h-[426px]",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:v?.series?.map((s,x)=>(0,e.jsxs)("div",{children:[s.label&&(0,e.jsx)(l.Text,{html:s.label,className:"text-sm mb-2 font-bold leading-[1.4] text-[#6D6D6F]"}),(0,e.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[!!v?.banner&&(0,e.jsx)(l.Link,{asChild:!v?.banner?.href,href:v?.banner?.href,children:(0,e.jsxs)("div",{className:"relative [&_img]:hover:scale-105 [&_img]:hover:transition-all [&_img]:hover:duration-300",children:[(0,e.jsx)(l.Picture,{source:v?.banner?.imageUrl,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)(l.Heading,{size:2,html:v?.banner?.title||"Buy in Guide",className:"font-bold text-white"}),(0,e.jsx)(l.Text,{html:v?.banner?.desc||"20.000mAh",className:"text-sm text-white font-bold"})]})]})}),s.products?.map((f,u)=>(0,e.jsx)(Y,{seriesLabel:v?.label,product:f,isCollection:v?.isCollection},`seriesProductItem-${u}`))]})]},`seriesItem-${x}`))})]})]})}),ke=({multicolMetadata:t})=>{const n=(0,a.useRef)(null);return(0,e.jsx)("div",{ref:n,children:(0,e.jsx)(l.Container,{childClassName:"bg-white",className:"h-full",children:(0,e.jsx)("div",{className:"flex gap-4 py-4",children:t?.map((o,c)=>(0,e.jsx)("div",{className:"w-1/4",children:(0,e.jsx)(Z,{item:o})},`multicolItem-${o?.label}-${c}`))})})})},we=({supportsMetadata:t,currentNavItemRef:n})=>{const o=(0,a.useRef)(null),[c,r]=(0,a.useState)(null),[b,d]=(0,a.useState)(0);(0,a.useEffect)(()=>{if(o?.current){const p=o?.current?.getBoundingClientRect();d(p.height)}},[o]);const m=(0,se.debounce)(()=>{if(n){const p=n.getBoundingClientRect();r(p)}},500);return(0,a.useEffect)(()=>(m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}),[m]),(0,a.useEffect)(()=>{if(n){const p=n.getBoundingClientRect();r(p)}},[n]),(0,e.jsx)("div",{className:"absolute top-0 h-full bg-white transition-all duration-500 overflow-hidden",style:{right:`calc(100% - ${c?.right}px)`,height:b},children:(0,e.jsx)("div",{ref:o,className:"p-4",children:t?.map(p=>(0,e.jsx)("div",{className:"py-2",children:(0,e.jsx)(l.Link,{href:p.url,className:"text-sm font-bold leading-[1.4] no-underline",children:p.label})},p.id))})})},Y=({product:t,isCollection:n,position:o,seriesLabel:c})=>{const{buildProps:r,onSeriesProductClick:b}=(0,B.useNavContext)();let d=n?t:r?.products?.find(k=>k.handle===t.handle);const m=d?.variants?.find(k=>k.sku===t.sku)||d?.variants?.[0],p=(0,a.useMemo)(()=>`/products/${d?.handle}?variant=${(0,N.atobID)(m?.id)}`,[d?.handle,m?.id]),v=(0,a.useMemo)(()=>d?.tags?.filter?.(k=>k?.startsWith?.("CLtag"))?.map?.(k=>k?.replace?.("CLtag:",""))?.slice?.(0,2),[d?.tags]);return m?.availableForSale?(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-4 bg-[#F5F5F7] px-4 py-3 [&_img]:hover:scale-105",children:[(0,e.jsx)("div",{className:"shrink-0",children:(0,e.jsx)(l.Picture,{source:`${m?.image?.url||t?.images?.[0]?.url}}`,width:90,height:90,className:"size-[96px]",imgClassName:"object-contain h-full"})}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("div",{className:"flex gap-1",children:Array.isArray(v)&&v?.map(k=>(0,e.jsx)(l.Text,{as:"p",html:k,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]"}))}),(0,e.jsx)(l.Link,{href:p,onClick:k=>{k.preventDefault(),window.open(p),b?.(d,o||0,c)},className:"no-underline hover:text-current",children:(0,e.jsx)(l.Text,{className:"lg-desktop:h-[44px] lg-desktop:text-base line-clamp-2 h-[40px] text-sm font-bold leading-[1.4]",html:d?.title||t?.name})}),t?.desc&&(0,e.jsx)(l.Text,{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},Z=({item:t,allPicture:n})=>(0,e.jsxs)(e.Fragment,{children:[t?.columns&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l.Text,{html:t.label,as:"div",className:"my-2 text-sm font-bold leading-[1.4] text-[#6D6D6F]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col",children:t.columns?.map(o=>(0,e.jsxs)("div",{className:"py-2 flex items-center gap-1",children:[(0,e.jsx)(l.Link,{href:o.url,asChild:!o.url,className:"text-sm font-bold leading-[1.4] no-underline",children:o.label}),o?.badge&&(0,e.jsx)(l.Text,{as:"p",html:o?.badge||"badge",className:"text-sm font-bold !leading-[22px] text-brand-0 h-[24px] rounded-full border-[1.6px] border-[var(--brand-color-0)] px-[6px]"})]},o.label))})]}),t?.imageUrl&&(0,e.jsx)("div",{className:(0,N.cn)("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":n}),children:(0,e.jsxs)(l.Link,{href:t.url,asChild:!t.url,children:[(0,e.jsx)(l.Picture,{source:t.imageUrl,width:404,height:280,className:"size-full",imgClassName:"object-cover h-full hover:scale-105 transition-all duration-300"}),(0,e.jsxs)("div",{className:"absolute bottom-4 left-4 z-10 flex flex-col justify-end no-underline",children:[(0,e.jsx)(l.Text,{html:t.title,className:(0,N.cn)("lg-desktop:text-2xl text-xl font-bold leading-[1.2] text-white",{"text-black":t?.theme==="dark"})}),t.subtitle&&(0,e.jsx)(l.Text,{html:t.subtitle,className:(0,N.cn)("text-sm font-bold leading-[1.4] text-white",{"text-black":t?.theme==="dark"})}),t?.primary?.label&&(0,e.jsx)(l.Button,{as:"a",href:t?.primary?.url,variant:"link",size:"lg",className:(0,N.cn)("text-sm font-bold mr-auto !p-0 leading-[1.4] text-white",{"text-black":t?.theme==="dark"}),children:t?.primary?.label||"more"})]})]})})]}),Ce=(0,a.forwardRef)(({data:t,className:n,onPrimaryNavClick:o},c)=>{const r=(0,a.useMemo)(()=>(0,H.WithGroupCategory)(t?.categories?.filter(M=>M?.mobileShow)),[t]),{currentMenu:b,setCurrentMenu:d,subSubCategory:m}=(0,B.useNavContext)(),[p,v]=(0,a.useState)(!1),[k,w]=(0,a.useState)(0),[s,x]=(0,a.useState)(null),f=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(f?.current&&p){const M=f?.current?.getBoundingClientRect();w(window?.innerHeight-(M?.bottom||0))}},[p]),(0,K.useGSAP)(()=>{J.gsap.fromTo(f.current,{height:0},{height:k,duration:.3})},[k]),(0,a.useEffect)(()=>{document.documentElement.style.overflow=p?"hidden":"auto"},[p]);const u=(0,a.useMemo)(()=>s?.components?.[0]?.blockType,[s]),i=(0,H.WithSupports)(Le,{categoriesItem:s}),h=(0,H.WithSidebar)(De,s),D=(0,H.WithMulticol)(Me,s),L=(0,a.useMemo)(()=>{switch(u){case y.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)(h,{});case y.HeaderNavigationBlockType.Supports:return(0,e.jsx)(i,{});case y.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(D,{});default:return null}},[u,s,i]),C=(0,a.useCallback)(()=>{v(!1),w(0),d&&d(y.HeaderNavigationMenu.Primary)},[v,w,d]),A=(0,a.useMemo)(()=>t?.headerBar?.actions?.filter(M=>M?.mobileShow&&M?.blockType!==y.HeaderNavigationActionBlockType.Profile),[t]),S=(0,a.useMemo)(()=>t?.headerBar?.actions?.find(M=>M?.mobileShow&&M?.blockType===y.HeaderNavigationActionBlockType.Profile)||{},[t]),T=(0,a.useMemo)(()=>{switch(b){case y.HeaderNavigationMenu.Primary:return(0,e.jsx)(ze,{actions:A,menuOpen:p,onMenuOpenClose:()=>{v(!1),w(0)},onMenuOpenClick:()=>v(!0)});case y.HeaderNavigationMenu.Secondary:return(0,e.jsx)(le,{title:s?.text,onMenuOpenClose:C,onMenuBackClick:()=>d?.(y.HeaderNavigationMenu.Primary)});case y.HeaderNavigationMenu.Third:return(0,e.jsx)(le,{title:m?.label,onMenuOpenClose:C,onMenuBackClick:()=>d?.(y.HeaderNavigationMenu.Secondary)});default:return null}},[p,b,d,s,A,m,C]),j=(0,a.useCallback)((M,$)=>{const F=Array.isArray(r)?Array.isArray(r[M])?r[M][$]:{}:{};x(F),F?.components?.[0]?.blockType===y.HeaderNavigationBlockType.Links?F?.components?.[0]?.url&&window.open(F?.components?.[0]?.url):d?.(y.HeaderNavigationMenu.Secondary)},[r,d]);return(0,e.jsxs)(l.Container,{className:(0,N.cn)("relative h-[52px]",n),children:[T,p&&(0,e.jsx)("div",{ref:f,className:"absolute left-0 top-full text-black border-t border-[#E4E5E6] z-[999] w-full overflow-y-auto bg-white",style:{height:k},children:b===y.HeaderNavigationMenu.Primary?(0,e.jsx)(Se,{categories:r,onPrimaryMenuClick:j,onPrimaryNavClick:o,profileAction:S}):L})]})}),Se=({categories:t,onPrimaryMenuClick:n,profileAction:o,onPrimaryNavClick:c})=>(0,e.jsxs)("div",{className:"flex h-full flex-col justify-between",children:[(0,e.jsx)("div",{className:"tablet:px-8 laptop:px-16 p-4",children:t?.map((r,b)=>(0,e.jsxs)("div",{className:"",children:[r?.map((d,m)=>(0,e.jsx)(W,{label:d.text,onClick:()=>{const v=(t?.flat()||[])?.findIndex(k=>k?.id===t[b][m]?.id);n(b,m),c?.(d,v)},icon:d.components?.[0]?.icon},d.id)),(0,e.jsx)("div",{className:(0,N.cn)("my-2 h-px w-full bg-[#E5E5E7]",{hidden:b===t.length-1})})]},`groupCategory-${b}`))}),(0,e.jsx)(Pe,{profileAction:o})]}),De=({sidebarCategoriesMetadata:t,seriesMetadata:n})=>{const{currentMenu:o,setCurrentMenu:c,subSubCategory:r,setSubSubCategory:b,setCurrentSeriesMetadata:d,currentSeriesMetadata:m,buildProps:p}=(0,B.useNavContext)(),[v,k]=(0,a.useState)([]),[w,s]=(0,a.useState)([]);(0,a.useEffect)(()=>{t?.subcategories?.length&&k(t?.subcategories?.map((i,h)=>({index:h,open:!1})))},[t]),(0,a.useEffect)(()=>{r?.subSubCategories?.length&&s(r?.subSubCategories?.map((i,h)=>({index:h,open:h===0})))},[r]);const x=(0,a.useCallback)((i,h)=>{c&&c(y.HeaderNavigationMenu.Third),b?.(i);const D=n?.find(L=>h!==void 0?i?.subSubCategories?.[h]?.label?.toLowerCase()===L.label?.toLowerCase():i?.label?.toLowerCase()===L.label?.toLowerCase())||{};if(i?.collections){const L=p?.categories?.[i?.collections]||{};d?.({label:D?.label,isCollection:!0,banner:D?.banner,primary:D?.primary,series:[{products:L?.products}]})}else d?.(D)},[n,t,c,b,d]),f=(0,a.useMemo)(()=>n?.find(i=>!!i?.guide)?.guide,[n,t]);return(0,a.useMemo)(()=>{switch(o){case y.HeaderNavigationMenu.Secondary:return(0,e.jsxs)("div",{className:"tablet:px-8 laptop:px-16 flex h-full flex-col justify-between tablet:justify-start tablet:gap-16 p-4",children:[(0,e.jsx)("div",{children:t?.subcategories?.map((i,h)=>(0,e.jsx)("div",{children:(0,e.jsx)(W,{label:i?.label,active:v.find(D=>D.index===h)?.open,onClick:()=>{x(i)}})},`${i.label}-${h}`))}),(0,e.jsxs)("div",{className:"tablet:items-start flex flex-col items-center gap-4",children:[t?.primary&&(0,e.jsx)(l.Button,{as:"a",href:t?.primary?.url,variant:"primary",size:"lg",className:"tablet:w-auto w-full text-base",children:t?.primary?.label}),t?.secondary&&(0,e.jsx)(l.Button,{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 y.HeaderNavigationMenu.Third:return(0,e.jsxs)("div",{className:"tablet:px-8 laptop:px-16 p-4",children:[r?.subSubCategories?r?.subSubCategories?.map((i,h)=>{const D=n?.find(C=>C.label.toLowerCase()===i?.label?.toLowerCase())||{};let L={};if(i?.collections){const C=p?.categories?.[i?.collections]||{};L={label:D?.label,isCollection:!0,banner:D?.banner,primary:D?.primary,series:[{products:C?.products}]}}else L=D;return(0,e.jsxs)("div",{children:[Reflect.ownKeys(i).length>0&&(0,e.jsx)(ee,{matchSeriesMetadata:L,onSubSubCategoryItemClick:()=>s(C=>C.map((A,S)=>({...A,open:S===h}))),expanded:!!w?.find(C=>C.index===h)?.open}),w?.find(C=>C.index===h)?.open&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(te,{matchSeriesMetadata:L}),L?.primary&&(0,e.jsx)("div",{className:"text-center my-4",children:(0,e.jsx)(l.Button,{as:"a",href:L?.primary?.url,className:"text-base no-underline leading-[1.2]",variant:"secondary",size:"base",children:L?.primary?.label})})]})]},`${i.label}-${h}`)}):(0,e.jsxs)(e.Fragment,{children:[Reflect.ownKeys(m).length>0&&(0,e.jsx)(ee,{matchSeriesMetadata:m}),(0,e.jsx)(te,{matchSeriesMetadata:m}),m?.primary&&(0,e.jsx)("div",{className:"text-center my-4 ",children:(0,e.jsx)(l.Button,{as:"a",href:m?.primary?.url,variant:"secondary",size:"base",className:"text-base no-underline leading-[1.2]",children:m?.primary?.label})})]}),f&&(0,e.jsx)(l.Link,{href:f?.url,children:(0,e.jsx)("div",{className:"mt-4",children:(0,e.jsx)(l.Text,{html:f?.label,className:"text-sm font-bold leading-[1.2] text-[#6D6D6F]"})})})]});default:return null}},[o,t,c,n,v,w,b,r,d,m])},ee=({matchSeriesMetadata:t,onSubSubCategoryItemClick:n,expanded:o})=>(0,e.jsxs)("div",{className:"tablet:pt-0 py-4 flex items-center justify-between",onClick:n,children:[t?.label&&(0,e.jsx)(l.Text,{html:t?.label,className:"text-sm font-bold leading-[1.4]"}),n&&(0,e.jsx)(P.DownArrow,{className:(0,N.cn)("size-5",{"rotate-180":o})})]}),te=({matchSeriesMetadata:t})=>(0,e.jsx)("div",{className:"flex flex-col gap-2 laptop:gap-3",children:!!t?.series?.length&&t?.series?.map((n,o)=>(0,e.jsxs)("div",{children:[n.label&&(0,e.jsx)(l.Text,{html:n.label,className:"text-sm mb-2 font-bold leading-[1.4] text-[#3D3D3F]"}),(0,e.jsxs)("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&&(0,e.jsx)(l.Link,{asChild:!t?.banner?.href,href:t?.banner?.href,children:(0,e.jsxs)("div",{className:"relative [&_img]:hover:scale-105 [&_img]:hover:transition-all [&_img]:hover:duration-300",children:[(0,e.jsx)(l.Picture,{source:t?.banner?.imageUrl,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)(l.Heading,{size:2,html:t?.banner?.title||"Buy in Guide",className:(0,N.cn)("font-bold text-white",{"text-black":t?.banner?.theme==="dark"})}),(0,e.jsx)(l.Text,{html:t?.banner?.desc||"20.000mAh",className:(0,N.cn)("text-sm text-white font-bold",{"text-black":t?.banner?.theme==="dark"})})]})]})}),n.products?.map((c,r)=>(0,e.jsx)(Y,{position:r,product:c,seriesLabel:t?.label,isCollection:t?.isCollection},`seriesProductItem-${o}-${r}`))]})]},`seriesItem-${o}`))}),Le=({supportsMetadata:t})=>(0,e.jsx)("div",{className:"tablet:px-8 laptop:px-16 p-4",children:t?.map(n=>(0,e.jsx)(W,{href:n.url,label:n.label,onClick:()=>{}},n.id))}),Me=({multicolMetadata:t})=>{const n=(0,a.useMemo)(()=>!t?.some(o=>!!o.columns),[t]);return(0,e.jsx)("div",{className:(0,N.cn)("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":n}),children:t?.map((o,c)=>(0,e.jsx)("div",{children:(0,e.jsx)(Z,{item:o,allPicture:n})},`multicolItem-${o?.label}-${c}`))})},Pe=({profileAction:t})=>{const[n,o]=(0,a.useState)(!1),{profile:c,event:r}=(0,B.useNavContext)();return(0,e.jsxs)("div",{className:(0,N.cn)("tablet:px-8 laptop:px-16 bg-[#F5F5F7] px-4 py-6",{"p-4":n}),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",onClick:()=>o(!n),children:[(0,e.jsxs)("div",{className:"flex items-center gap-[14px]",children:[(0,e.jsx)("div",{className:"flex size-[40px] shrink-0 items-center justify-center rounded-full bg-white",children:(0,e.jsx)(P.User,{})}),(0,e.jsx)(l.Text,{html:c?.nick_name||t?.welcome,className:"text-base font-bold leading-[1.4]"})]}),!c?.email&&(0,e.jsx)(P.DownArrow,{className:(0,N.cn)("size-5 laptop:size-4",{"rotate-180":n})})]}),c?.email&&(0,e.jsx)("div",{className:"mt-4",children:t?.profiles?.map(b=>(0,e.jsx)(W,{label:b?.title,href:b?.url},b.id))}),n&&!c?.email&&(0,e.jsxs)("div",{className:"mt-4",children:[(0,e.jsx)(l.Text,{html:t?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col gap-1",children:t?.benefits?.map(b=>(0,e.jsxs)("div",{className:"flex items-center gap-[6px]",children:[(0,e.jsx)(l.Picture,{source:b.benefitIcon?.url,className:"size-4",alt:b.benefit,width:16,height:16}),(0,e.jsx)(l.Text,{html:b.benefit,className:"text-sm font-bold leading-[1.4]"})]},b.id))})]}),!c?.email&&(0,e.jsxs)("div",{className:"mt-4 flex items-center gap-3",children:[(0,e.jsx)(l.Button,{className:"tablet:flex-none flex-1",variant:"secondary",size:"base",onClick:()=>r?.join?.(),children:(0,e.jsx)(l.Text,{html:t?.primaryButton||"Join Now",className:"text-sm font-bold leading-[1.4]"})}),(0,e.jsx)(l.Button,{className:"tablet:flex-none flex-1",variant:"primary",size:"base",onClick:()=>r?.login?.(),children:(0,e.jsx)(l.Text,{html:t?.secondaryButton||"Log In",className:"text-sm font-bold leading-[1.4]"})})]})]})},ze=({menuOpen:t,onMenuOpenClose:n,onMenuOpenClick:o,actions:c})=>(0,e.jsxs)("div",{className:"flex h-full items-center justify-between gap-4",children:[(0,e.jsx)(ae,{}),(0,e.jsxs)("div",{className:"desktop:gap-6 flex items-center gap-4",children:[(0,e.jsx)(ne,{actions:c}),t?(0,e.jsx)(P.Close,{className:"size-5",onClick:()=>n()}):(0,e.jsx)(P.Menu,{className:"size-5",onClick:()=>o()})]})]}),ae=()=>{const{payloadData:t,isMobile:n}=(0,B.useNavContext)();return(0,e.jsx)("div",{className:"[&>svg]:w-full hover:text-brand-0 cursor-pointer",onClick:()=>{window.location.href="/"},dangerouslySetInnerHTML:{__html:n?t?.headerBar?.mobileLogo:t?.headerBar?.desktopLogo}})},ne=(0,a.forwardRef)(({actions:t,activeStatus:n=!1},o)=>{const{event:c}=(0,B.useNavContext)(),[r,b]=(0,a.useState)(null),d=(0,a.useCallback)((m,p)=>{switch(b(p),m?.blockType){case y.HeaderNavigationActionBlockType.Search:c?.search?.();break;case y.HeaderNavigationActionBlockType.Cart:c?.cart?.();break;case y.HeaderNavigationActionBlockType.Profile:c?.profile?.();break;case y.HeaderNavigationActionBlockType.Livestream:c?.livestream?.();break;default:return()=>{}}},[c]);return(0,e.jsx)("div",{className:"desktop:gap-6 flex items-center gap-4",children:Array.isArray(t)&&t?.map((m,p)=>(0,e.jsx)("div",{ref:m.blockType===y.HeaderNavigationActionBlockType.Profile?o:null,onClick:()=>d(m,p),children:(0,e.jsx)(l.Text,{html:m.icon,className:(0,N.cn)("cursor-pointer size-5",{"text-brand-0":n&&r===p})})},m.id))})}),le=({title:t,onMenuOpenClose:n,onMenuBackClick:o})=>(0,e.jsxs)("div",{className:"flex h-full items-center gap-3",children:[(0,e.jsx)(P.LeftArrow,{className:"size-5",onClick:()=>o()}),(0,e.jsx)(l.Text,{html:t,className:"flex-1 text-center text-base font-bold leading-[1.4]"}),(0,e.jsx)(P.Close,{className:"size-5",onClick:()=>n()})]}),W=({label:t,href:n,onClick:o,active:c,icon:r,className:b})=>(0,e.jsx)("div",{className:(0,N.cn)("flex cursor-pointer items-center justify-between py-4",b),onClick:o,children:(0,e.jsxs)(l.Link,{href:n,asChild:!n,className:"flex w-full items-center justify-between no-underline",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)(l.Text,{html:t,className:(0,N.cn)("text-sm font-bold leading-[1.4]",{underline:r})}),r&&(0,e.jsx)(l.Text,{html:r})]}),(0,e.jsx)(P.RightArrow,{className:(0,N.cn)("size-5 laptop:size-4",{"rotate-90":c})})]})});var Ee=(0,oe.withLayout)(he);
|
|
2
2
|
//# sourceMappingURL=index.js.map
|