@anker-in/headless-ui 1.0.20-alpha.1761120380827 → 1.0.20-alpha.1761124393999

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