'use client';
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{composeTypographyStyle as l,getGlobalColorStateStyle as r,filterHoverVariables as p,cls as n,getGlobalColorResponsiveStyle as a}from"@gem-sdk/core";import i from"next/link";import{useState as s,useRef as o}from"react";import{Transition as g}from"react-transition-group";import c from"../../icons/ChevronLeft.js";import m from"../../icons/Dismiss.js";let u={transitionDuration:"300ms",opacity:0},f={entering:{opacity:1,transform:"translateX(0)"},entered:{opacity:1,transform:"translateX(0)"},exiting:{opacity:0,transform:"translateX(50px)"},exited:{opacity:0,transform:"translateX(50px)"},unmounted:{opacity:0}},d=({id:h,menu:x,arrow:y,menuBg:b,menuTextColor:v,closeMenu:w,depth:N=0,maxDepth:k=2,typo:j,typography:C,enableHoverEffect:D})=>{let[X,z]=s(!1),I=o(null),M=l(j,C),P=x?.[h];if(!P||N>k)return null;let q=!!P?.childrens?.length&&N!==k,E=q&&!!y,L=e=>{e.preventDefault(),e.stopPropagation(),z(e=>!e)},T=r("c",v),_=D?T:p(T);return e("li",{className:n("gp-group gp-flex gp-cursor-pointer gp-gap-2 gp-whitespace-nowrap gp-px-4 gp-py-2",{"gp-flex-col gp-border-b last:gp-border-b-transparent":N>0}),style:{..._,...a("bgc",b)},children:[e("div",{className:"gp-flex gp-w-full gp-items-center gp-justify-between","aria-hidden":!0,onClick:!P?.link&&E?L:void 0,children:[P?.link?t(i,{href:P.link,title:P.title,className:"gp-w-full",children:P.title}):t("span",{style:{...M},children:P?.title}),E&&t("span",{role:"button",tabIndex:0,"aria-expanded":X,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&L(e)},onClick:L,dangerouslySetInnerHTML:{__html:y},className:n("gp-ml-auto gp-transition-all gp-duration-200 [&>svg]:gp-w-5",{"gp-rotate-0":N>0&&!X,"gp-rotate-180":N>0&&X,"-gp-rotate-90":0===N}),style:{...M}})]}),q&&t(g,{in:X,timeout:300,nodeRef:I,unmountOnExit:!0,children:l=>e("div",{ref:I,className:n("gp-z-10 gp-flex gp-cursor-default gp-flex-col gp-transition-all",{"gp-absolute gp-left-0 gp-top-0 gp-h-full gp-w-full":0===N}),style:{...a("bgc",b),...u,...f[l]},children:[0===N&&e("div",{className:"gp-relative gp-flex gp-h-10 gp-w-full gp-items-center gp-justify-between gp-border-b",children:[t("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),z(!1)},className:"gp-relative gp-z-1 gp-flex gp-aspect-square gp-h-full gp-items-center gp-justify-center",children:t(c,{className:"gp-w-5"})}),t("div",{"aria-hidden":!0,onClick:e=>{e.preventDefault(),e.stopPropagation(),z(!1)},className:"gp-absolute gp-inset-0 gp-flex gp-items-center gp-justify-center",children:t("span",{className:"gp-font-semibold",children:P.title})}),t("button",{onClick:w,"aria-label":"Close menu",className:"gp-relative gp-z-1 gp-flex gp-aspect-square gp-h-full gp-items-center gp-justify-center",style:{...r("c",v)},children:t(m,{className:"gp-w-5"})})]}),t("ul",{className:n("gp-flex gp-flex-col"),children:P?.childrens?.map(e=>t(d,{id:e,menu:x,depth:N+1,maxDepth:k,arrow:y,menuBg:b,menuTextColor:v},e))})]})})]})};export{d as default};
