@anker-in/headless-ui 1.1.17-alpha.1765973540226 → 1.1.17-alpha.1765975457739

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