@anker-in/headless-ui 1.1.17-alpha.1765943848792 → 1.1.17-alpha.1765944830940
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/biz-components/HeaderNavigation/index.js +1 -1
- package/dist/cjs/biz-components/HeaderNavigation/index.js.map +2 -2
- package/dist/cjs/components/brand-strip.d.ts +0 -2
- package/dist/cjs/components/brand-strip.js +1 -1
- package/dist/cjs/components/brand-strip.js.map +3 -3
- package/dist/esm/biz-components/HeaderNavigation/index.js +1 -1
- package/dist/esm/biz-components/HeaderNavigation/index.js.map +2 -2
- package/dist/esm/components/brand-strip.d.ts +0 -2
- package/dist/esm/components/brand-strip.js +1 -1
- package/dist/esm/components/brand-strip.js.map +3 -3
- package/package.json +1 -1
- package/style.css +0 -4
|
@@ -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,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)),he=t=>Y(U({},"__esModule",{value:!0}),t);var ze={};ge(ze,{default:()=>Be});module.exports=he(ze);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"),B=require("./icons/index.js"),ie=G(require("../NavigationSearch/index.js"));const ye=(0,a.forwardRef)((t,n)=>{const{data:{headerNavigation:r}={},menuData:c,buildProps:u,event:d,profile:g,theme:b="light",isTop:x=!1,searchResult:h,onSearch:o,isSearching:M,keywords:C,onPrimaryNavClick:p,onSeriesProductClick:N,onSidebarNavClick:f,headerId:y,cartCount:s}=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)(()=>r?.headerBar?.actions?.find(w=>w?.blockType===v.HeaderNavigationActionBlockType.Search)?.searchBar?.[0]||{},[r]);return(0,e.jsx)($.default,{buildProps:u,profile:g,isMobile:L,event:d,payloadData:r,onSidebarNavClick:f,onSeriesProductClick:N,cartCount:s,children:(0,e.jsx)("header",{id:y||"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:r,className:"desktop:block hidden !bg-white",theme:b,onPrimaryNavClick:p}),(0,e.jsx)(Ce,{data:r,menuData:c,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:h,onSearch:w=>{o?.(w)},onClose:()=>{o?.(),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:d,onPrimaryNavClick:g}=t,{event:b,profile:x}=(0,$.useNavContext)(),[h,o]=(0,a.useState)(!1),M=(0,a.useMemo)(()=>(0,T.WithGroupCategory)(r?.categories?.filter(i=>i?.pcShow)),[r]),[C,p]=(0,a.useState)(null),[N,f]=(0,a.useState)([]),y=(0,a.useRef)(null),[s,m]=(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((z,R)=>({groupIndex:E,index:R,open:!1}))))},[M]);const S=(0,a.useMemo)(()=>{let i=null;for(const E of N){for(const z of E)if(z.open){i=z;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,z)=>{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][z]?.id);i.stopPropagation(),c?.(),g?.(R[_],_),p(M[E][z]),f(A=>A.map(ue=>ue.map(W=>W.groupIndex===E&&W.index===z?{...W,open:!W.open}:{...W,open:!1})))}},F=(i,E,z)=>{i.key==="Enter"||i.key===" "?(i.preventDefault(),H(i,E,z)):i.key==="Escape"&&S?.groupIndex===E&&S?.index===z&&(i.preventDefault(),j())},j=()=>{f(i=>i.map(E=>E.map(z=>({...z,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]}),de=(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?.headerBar?.actions?.filter(i=>i?.pcShow),[r]),I=(0,a.useMemo)(()=>Q?.find(i=>i?.blockType===v.HeaderNavigationActionBlockType.Profile),[Q]),X=(0,a.useCallback)(()=>{m(i=>!i)},[]);return(0,a.useEffect)(()=>{if(y?.current){const i=y.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:y,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((z,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":z.text,children:[(0,e.jsx)(l.Text,{html:z.text,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)(B.DownArrow,{"aria-hidden":"true",className:(0,k.cn)("size-4 opacity-0 transition-opacity duration-500 group-hover:opacity-100",{"rotate-180":_,"opacity-100":h&&_})})]}),(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"})]})},z.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!==v.HeaderNavigationBlockType.Supports}),children:de}),(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% - ${y?.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)(B.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:()=>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:i=>{(i.key==="Enter"||i.key===" "||i.key==="Escape")&&(i.preventDefault(),m(!1))}})]})]})}),Ne=a.default.memo(({sidebarCategoriesMetadata:t,seriesMetadata:n})=>{const{buildProps:r,onSidebarNavClick:c}=(0,$.useNavContext)(),[u,d]=(0,a.useState)([]),[g,b]=(0,a.useState)(-1),x=(0,a.useRef)(null),h=(0,a.useCallback)(()=>{const p=t?.subcategories;if(!p?.length)return;const N=p.findIndex(s=>!!s?.subSubCategories),f=p.findIndex(s=>!s?.subSubCategories),y=p.map((s,m)=>({index:m,open:N===m||f===m}));d(y)},[t]);(0,a.useEffect)(()=>{h()},[h]);const o=(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],y=n?.find(s=>s?.label?.toLowerCase()===f?.label?.toLowerCase())||{};if(f?.collections){const s=r?.categories?.[f?.collections]||{};return{label:y?.label,isCollection:!0,banner:y?.banner,primary:y?.primary,series:[{products:s?.products}]}}else return y}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(y=>y.index===p?{...y,open:!0}:{...y,open:!1}));else{const y=t?.subcategories?.findIndex(s=>!!s?.subSubCategories);d(s=>s.map(m=>({...m,open:m.index===p||m.index===y})))}},[t]),C=(p,N)=>{d(f=>f.map(y=>y.index===p?{...y,open:!0}:{...y,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,y=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&&y}),onClick:()=>{M(N,p),c?.(p,N)},"aria-expanded":f?y: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)(B.DownArrow,{"aria-hidden":"true",className:(0,k.cn)("size-4",{"rotate-180":y})})]}),y&&(0,e.jsx)("div",{className:"flex flex-col",role:"menu",children:p.subSubCategories?.map((s,m)=>(0,e.jsx)("button",{onClick:()=>{C(N,m),c?.(s,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":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}-${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(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((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:[!!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"})]})]})}),p.products?.map((f,y)=>(0,e.jsx)(Z,{seriesLabel:o?.label,product:f,isCollection:o?.isCollection},`seriesProductItem-${y}`))]})]},`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),[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% - ${c?.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:c})=>{const{buildProps:u,onSeriesProductClick:d}=(0,$.useNavContext)();let g=n?t:u?.products?.find(o=>o.handle===t.handle);const b=g?.variants?.find(o=>o.sku===t.sku)||g?.variants?.[0],x=(0,a.useMemo)(()=>`/products/${g?.handle}?variant=${(0,k.atobID)(b?.id)}`,[g?.handle,b?.id]),h=(0,a.useMemo)(()=>g?.tags?.filter?.(o=>o?.startsWith?.("CLtag"))?.map?.(o=>o?.replace?.("CLtag:",""))?.slice?.(0,2),[g?.tags]);return b?.availableForSale?(0,e.jsx)(l.Link,{href:x,onClick:o=>{o.preventDefault(),window.open(x,"_self"),d?.(g,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:`${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(h)&&h?.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: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:c},u)=>{const d=(0,a.useMemo)(()=>(0,T.WithGroupCategory)(t?.categories?.filter(w=>w?.mobileShow)),[t]),{currentMenu:g,setCurrentMenu:b,subSubCategory:x}=(0,$.useNavContext)(),[h,o]=(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&&h){const w=f?.current?.getBoundingClientRect();C(window?.innerHeight-(w?.bottom||0))}},[h]),(0,J.useGSAP)(()=>{V.gsap.fromTo(f.current,{height:0},{height:M,duration:.3})},[M]),(0,a.useEffect)(()=>{document.documentElement.style.overflow=h?"hidden":"auto"},[h]);const y=(0,a.useMemo)(()=>p?.components?.[0]?.blockType,[p]),s=(0,T.WithSupports)(Le,{categoriesItem:p}),m=(0,T.WithSidebar)(De,p),D=(0,T.WithMulticol)(Me,p),L=(0,a.useMemo)(()=>{switch(y){case v.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)(m,{});case v.HeaderNavigationBlockType.Supports:return(0,e.jsx)(s,{});case v.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(D,{});default:return null}},[y,p,s]),P=(0,a.useCallback)(()=>{o(!1),C(0),b&&b(v.HeaderNavigationMenu.Primary)},[o,C,b]),S=(0,a.useMemo)(()=>t?.headerBar?.actions?.filter(w=>w?.mobileShow&&w?.blockType!==v.HeaderNavigationActionBlockType.Profile),[t]),H=(0,a.useMemo)(()=>t?.headerBar?.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:h,onMenuOpenClose:()=>{o(!1),C(0)},onMenuOpenClick:()=>o(!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}},[h,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,h&&(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:[(0,e.jsx)(l.BrandStrip,{data:n,isContainer:!1}),g===v.HeaderNavigationMenu.Primary?(0,e.jsx)(Se,{categories:d,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,d)=>(0,e.jsxs)("div",{className:"",children:[u?.map((g,b)=>(0,e.jsx)(K,{label:g.text,onClick:()=>{const h=(t?.flat()||[])?.findIndex(o=>o?.id===t[d][b]?.id);n(d,b),c?.(g,h)},icon:g.components?.[0]?.icon},g.id)),(0,e.jsx)("div",{className:(0,k.cn)("my-2 h-px w-full bg-[#E5E5E7]",{hidden:d===t.length-1})})]},`groupCategory-${d}`))}),(0,e.jsx)(Pe,{profileAction:r})]}),De=({sidebarCategoriesMetadata:t,seriesMetadata:n})=>{const{currentMenu:r,setCurrentMenu:c,subSubCategory:u,setSubSubCategory:d,setCurrentSeriesMetadata:g,currentSeriesMetadata:b,buildProps:x,onSidebarNavClick:h}=(0,$.useNavContext)(),[o,M]=(0,a.useState)([]),[C,p]=(0,a.useState)([]);(0,a.useEffect)(()=>{t?.subcategories?.length&&M(t?.subcategories?.map((s,m)=>({index:m,open:!1})))},[t]),(0,a.useEffect)(()=>{u?.subSubCategories?.length&&p(u?.subSubCategories?.map((s,m)=>({index:m,open:m===0})))},[u]);const N=(0,a.useCallback)((s,m)=>{c&&c(v.HeaderNavigationMenu.Third),d?.(s);const D=n?.find(L=>m!==void 0?s?.subSubCategories?.[m]?.label?.toLowerCase()===L.label?.toLowerCase():s?.label?.toLowerCase()===L.label?.toLowerCase())||{};if(s?.collections){const L=x?.categories?.[s?.collections]||{};g?.({label:D?.label,isCollection:!0,banner:D?.banner,primary:D?.primary,series:[{products:L?.products}]})}else g?.(D)},[n,c,d,g,x?.categories]),f=(0,a.useMemo)(()=>n?.find(s=>!!s?.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((s,m)=>(0,e.jsx)("div",{children:(0,e.jsx)(K,{label:s?.label,active:o.find(D=>D.index===m)?.open,onClick:()=>{N(s),h?.(s,m)}})},`${s.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((s,m)=>{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:()=>{h?.(s,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})})]})]},`${s.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,o,C,u,b,x?.categories,f,N,h])},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)(B.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)(B.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)(B.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(d=>(0,e.jsx)(K,{label:d?.title,href:d?.url},d.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(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))})]}),!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)(B.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)(B.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?.headerBar?.mobileLogo:t?.headerBar?.desktopLogo}})},le=(0,a.forwardRef)(({actions:t,activeStatus:n=!1},r)=>{const{event:c,cartCount:u}=(0,$.useNavContext)(),[d,g]=(0,a.useState)(null),b=h=>{switch(h){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)((h,o)=>{switch(g(o),h?.blockType){case v.HeaderNavigationActionBlockType.Search:c?.search?.();break;case v.HeaderNavigationActionBlockType.Cart:c?.cart?.();break;case v.HeaderNavigationActionBlockType.Profile:c?.profile?.();break;case v.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((h,o)=>(0,e.jsxs)("button",{className:"relative cursor-pointer border-0 bg-transparent p-0",ref:h.blockType===v.HeaderNavigationActionBlockType.Profile?r:null,onClick:()=>x(h,o),"aria-label":b(h.blockType),"aria-pressed":n&&d===o,children:[(0,e.jsx)(l.Text,{html:h.icon,className:(0,k.cn)("size-5",{"text-brand-0":n&&d===o}),"aria-hidden":"true"}),h.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"})})]},h.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)(B.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)(B.Close,{className:"size-5","aria-hidden":"true"})})]}),K=({label:t,href:n,onClick:r,active:c,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)(B.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",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":c,children:g})};var Be=ye;
|
|
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)),he=t=>Y(U({},"__esModule",{value:!0}),t);var ze={};ge(ze,{default:()=>Be});module.exports=he(ze);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"),B=require("./icons/index.js"),ie=G(require("../NavigationSearch/index.js"));const ye=(0,a.forwardRef)((t,n)=>{const{data:{headerNavigation:r}={},menuData:c,buildProps:u,event:d,profile:g,theme:b="light",isTop:x=!1,searchResult:h,onSearch:o,isSearching:M,keywords:C,onPrimaryNavClick:p,onSeriesProductClick:N,onSidebarNavClick:f,headerId:y,cartCount:s}=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)(()=>r?.headerBar?.actions?.find(w=>w?.blockType===v.HeaderNavigationActionBlockType.Search)?.searchBar?.[0]||{},[r]);return(0,e.jsx)($.default,{buildProps:u,profile:g,isMobile:L,event:d,payloadData:r,onSidebarNavClick:f,onSeriesProductClick:N,cartCount:s,children:(0,e.jsx)("header",{id:y||"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:r,className:"desktop:block hidden !bg-white",theme:b,onPrimaryNavClick:p}),(0,e.jsx)(Ce,{data:r,menuData:c,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:h,onSearch:w=>{o?.(w)},onClose:()=>{o?.(),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:d,onPrimaryNavClick:g}=t,{event:b,profile:x}=(0,$.useNavContext)(),[h,o]=(0,a.useState)(!1),M=(0,a.useMemo)(()=>(0,T.WithGroupCategory)(r?.categories?.filter(i=>i?.pcShow)),[r]),[C,p]=(0,a.useState)(null),[N,f]=(0,a.useState)([]),y=(0,a.useRef)(null),[s,m]=(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((z,R)=>({groupIndex:E,index:R,open:!1}))))},[M]);const S=(0,a.useMemo)(()=>{let i=null;for(const E of N){for(const z of E)if(z.open){i=z;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,z)=>{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][z]?.id);i.stopPropagation(),c?.(),g?.(R[_],_),p(M[E][z]),f(A=>A.map(ue=>ue.map(W=>W.groupIndex===E&&W.index===z?{...W,open:!W.open}:{...W,open:!1})))}},F=(i,E,z)=>{i.key==="Enter"||i.key===" "?(i.preventDefault(),H(i,E,z)):i.key==="Escape"&&S?.groupIndex===E&&S?.index===z&&(i.preventDefault(),j())},j=()=>{f(i=>i.map(E=>E.map(z=>({...z,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]}),de=(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?.headerBar?.actions?.filter(i=>i?.pcShow),[r]),I=(0,a.useMemo)(()=>Q?.find(i=>i?.blockType===v.HeaderNavigationActionBlockType.Profile),[Q]),X=(0,a.useCallback)(()=>{m(i=>!i)},[]);return(0,a.useEffect)(()=>{if(y?.current){const i=y.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:y,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((z,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":z.text,children:[(0,e.jsx)(l.Text,{html:z.text,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)(B.DownArrow,{"aria-hidden":"true",className:(0,k.cn)("size-4 opacity-0 transition-opacity duration-500 group-hover:opacity-100",{"rotate-180":_,"opacity-100":h&&_})})]}),(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"})]})},z.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!==v.HeaderNavigationBlockType.Supports}),children:de}),(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% - ${y?.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)(B.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:()=>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:i=>{(i.key==="Enter"||i.key===" "||i.key==="Escape")&&(i.preventDefault(),m(!1))}})]})]})}),Ne=a.default.memo(({sidebarCategoriesMetadata:t,seriesMetadata:n})=>{const{buildProps:r,onSidebarNavClick:c}=(0,$.useNavContext)(),[u,d]=(0,a.useState)([]),[g,b]=(0,a.useState)(-1),x=(0,a.useRef)(null),h=(0,a.useCallback)(()=>{const p=t?.subcategories;if(!p?.length)return;const N=p.findIndex(s=>!!s?.subSubCategories),f=p.findIndex(s=>!s?.subSubCategories),y=p.map((s,m)=>({index:m,open:N===m||f===m}));d(y)},[t]);(0,a.useEffect)(()=>{h()},[h]);const o=(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],y=n?.find(s=>s?.label?.toLowerCase()===f?.label?.toLowerCase())||{};if(f?.collections){const s=r?.categories?.[f?.collections]||{};return{label:y?.label,isCollection:!0,banner:y?.banner,primary:y?.primary,series:[{products:s?.products}]}}else return y}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(y=>y.index===p?{...y,open:!0}:{...y,open:!1}));else{const y=t?.subcategories?.findIndex(s=>!!s?.subSubCategories);d(s=>s.map(m=>({...m,open:m.index===p||m.index===y})))}},[t]),C=(p,N)=>{d(f=>f.map(y=>y.index===p?{...y,open:!0}:{...y,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,y=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&&y}),onClick:()=>{M(N,p),c?.(p,N)},"aria-expanded":f?y: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)(B.DownArrow,{"aria-hidden":"true",className:(0,k.cn)("size-4",{"rotate-180":y})})]}),y&&(0,e.jsx)("div",{className:"flex flex-col",role:"menu",children:p.subSubCategories?.map((s,m)=>(0,e.jsx)("button",{onClick:()=>{C(N,m),c?.(s,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":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}-${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(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((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:[!!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"})]})]})}),p.products?.map((f,y)=>(0,e.jsx)(Z,{seriesLabel:o?.label,product:f,isCollection:o?.isCollection},`seriesProductItem-${y}`))]})]},`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),[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% - ${c?.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:c})=>{const{buildProps:u,onSeriesProductClick:d}=(0,$.useNavContext)();let g=n?t:u?.products?.find(o=>o.handle===t.handle);const b=g?.variants?.find(o=>o.sku===t.sku)||g?.variants?.[0],x=(0,a.useMemo)(()=>`/products/${g?.handle}?variant=${(0,k.atobID)(b?.id)}`,[g?.handle,b?.id]),h=(0,a.useMemo)(()=>g?.tags?.filter?.(o=>o?.startsWith?.("CLtag"))?.map?.(o=>o?.replace?.("CLtag:",""))?.slice?.(0,2),[g?.tags]);return b?.availableForSale?(0,e.jsx)(l.Link,{href:x,onClick:o=>{o.preventDefault(),window.open(x,"_self"),d?.(g,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:`${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(h)&&h?.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: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:c},u)=>{const d=(0,a.useMemo)(()=>(0,T.WithGroupCategory)(t?.categories?.filter(w=>w?.mobileShow)),[t]),{currentMenu:g,setCurrentMenu:b,subSubCategory:x}=(0,$.useNavContext)(),[h,o]=(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&&h){const w=f?.current?.getBoundingClientRect();C(window?.innerHeight-(w?.bottom||0))}},[h]),(0,J.useGSAP)(()=>{V.gsap.fromTo(f.current,{height:0},{height:M,duration:.3})},[M]),(0,a.useEffect)(()=>{document.documentElement.style.overflow=h?"hidden":"auto"},[h]);const y=(0,a.useMemo)(()=>p?.components?.[0]?.blockType,[p]),s=(0,T.WithSupports)(Le,{categoriesItem:p}),m=(0,T.WithSidebar)(De,p),D=(0,T.WithMulticol)(Me,p),L=(0,a.useMemo)(()=>{switch(y){case v.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)(m,{});case v.HeaderNavigationBlockType.Supports:return(0,e.jsx)(s,{});case v.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(D,{});default:return null}},[y,p,s]),P=(0,a.useCallback)(()=>{o(!1),C(0),b&&b(v.HeaderNavigationMenu.Primary)},[o,C,b]),S=(0,a.useMemo)(()=>t?.headerBar?.actions?.filter(w=>w?.mobileShow&&w?.blockType!==v.HeaderNavigationActionBlockType.Profile),[t]),H=(0,a.useMemo)(()=>t?.headerBar?.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:h,onMenuOpenClose:()=>{o(!1),C(0)},onMenuOpenClick:()=>o(!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}},[h,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,h&&(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:[(0,e.jsx)("div",{className:"py-4",children:(0,e.jsx)(l.BrandStrip,{data:n})}),g===v.HeaderNavigationMenu.Primary?(0,e.jsx)(Se,{categories:d,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,d)=>(0,e.jsxs)("div",{className:"",children:[u?.map((g,b)=>(0,e.jsx)(K,{label:g.text,onClick:()=>{const h=(t?.flat()||[])?.findIndex(o=>o?.id===t[d][b]?.id);n(d,b),c?.(g,h)},icon:g.components?.[0]?.icon},g.id)),(0,e.jsx)("div",{className:(0,k.cn)("my-2 h-px w-full bg-[#E5E5E7]",{hidden:d===t.length-1})})]},`groupCategory-${d}`))}),(0,e.jsx)(Pe,{profileAction:r})]}),De=({sidebarCategoriesMetadata:t,seriesMetadata:n})=>{const{currentMenu:r,setCurrentMenu:c,subSubCategory:u,setSubSubCategory:d,setCurrentSeriesMetadata:g,currentSeriesMetadata:b,buildProps:x,onSidebarNavClick:h}=(0,$.useNavContext)(),[o,M]=(0,a.useState)([]),[C,p]=(0,a.useState)([]);(0,a.useEffect)(()=>{t?.subcategories?.length&&M(t?.subcategories?.map((s,m)=>({index:m,open:!1})))},[t]),(0,a.useEffect)(()=>{u?.subSubCategories?.length&&p(u?.subSubCategories?.map((s,m)=>({index:m,open:m===0})))},[u]);const N=(0,a.useCallback)((s,m)=>{c&&c(v.HeaderNavigationMenu.Third),d?.(s);const D=n?.find(L=>m!==void 0?s?.subSubCategories?.[m]?.label?.toLowerCase()===L.label?.toLowerCase():s?.label?.toLowerCase()===L.label?.toLowerCase())||{};if(s?.collections){const L=x?.categories?.[s?.collections]||{};g?.({label:D?.label,isCollection:!0,banner:D?.banner,primary:D?.primary,series:[{products:L?.products}]})}else g?.(D)},[n,c,d,g,x?.categories]),f=(0,a.useMemo)(()=>n?.find(s=>!!s?.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((s,m)=>(0,e.jsx)("div",{children:(0,e.jsx)(K,{label:s?.label,active:o.find(D=>D.index===m)?.open,onClick:()=>{N(s),h?.(s,m)}})},`${s.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((s,m)=>{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:()=>{h?.(s,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})})]})]},`${s.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,o,C,u,b,x?.categories,f,N,h])},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)(B.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)(B.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)(B.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(d=>(0,e.jsx)(K,{label:d?.title,href:d?.url},d.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(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))})]}),!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)(B.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)(B.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?.headerBar?.mobileLogo:t?.headerBar?.desktopLogo}})},le=(0,a.forwardRef)(({actions:t,activeStatus:n=!1},r)=>{const{event:c,cartCount:u}=(0,$.useNavContext)(),[d,g]=(0,a.useState)(null),b=h=>{switch(h){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)((h,o)=>{switch(g(o),h?.blockType){case v.HeaderNavigationActionBlockType.Search:c?.search?.();break;case v.HeaderNavigationActionBlockType.Cart:c?.cart?.();break;case v.HeaderNavigationActionBlockType.Profile:c?.profile?.();break;case v.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((h,o)=>(0,e.jsxs)("button",{className:"relative cursor-pointer border-0 bg-transparent p-0",ref:h.blockType===v.HeaderNavigationActionBlockType.Profile?r:null,onClick:()=>x(h,o),"aria-label":b(h.blockType),"aria-pressed":n&&d===o,children:[(0,e.jsx)(l.Text,{html:h.icon,className:(0,k.cn)("size-5",{"text-brand-0":n&&d===o}),"aria-hidden":"true"}),h.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"})})]},h.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)(B.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)(B.Close,{className:"size-5","aria-hidden":"true"})})]}),K=({label:t,href:n,onClick:r,active:c,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)(B.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",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":c,children:g})};var Be=ye;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|