'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@gem-sdk/core"),l=require("next/link"),s=require("react"),r=require("react-transition-group"),a=require("../../icons/ChevronLeft.js"),n=require("../../icons/Dismiss.js");const p={transitionDuration:"300ms",opacity:0},i={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}},o=({id:g,menu:c,arrow:u,menuBg:d,menuTextColor:f,closeMenu:x,depth:m=0,maxDepth:y=2,typo:h,typography:j,enableHoverEffect:b})=>{let[v,w]=s.useState(!1),N=s.useRef(null),k=t.composeTypographyStyle(h,j),C=c?.[g];if(!C||m>y)return null;let q=!!C?.childrens?.length&&m!==y,S=q&&!!u,D=e=>{e.preventDefault(),e.stopPropagation(),w(e=>!e)},G=t.getGlobalColorStateStyle("c",f),P=b?G:t.filterHoverVariables(G);return e.jsxs("li",{className:t.cls("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":m>0}),style:{...P,...t.getGlobalColorResponsiveStyle("bgc",d)},children:[e.jsxs("div",{className:"gp-flex gp-w-full gp-items-center gp-justify-between","aria-hidden":!0,onClick:!C?.link&&S?D:void 0,children:[C?.link?e.jsx(l,{href:C.link,title:C.title,className:"gp-w-full",children:C.title}):e.jsx("span",{style:{...k},children:C?.title}),S&&e.jsx("span",{role:"button",tabIndex:0,"aria-expanded":v,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&D(e)},onClick:D,dangerouslySetInnerHTML:{__html:u},className:t.cls("gp-ml-auto gp-transition-all gp-duration-200 [&>svg]:gp-w-5",{"gp-rotate-0":m>0&&!v,"gp-rotate-180":m>0&&v,"-gp-rotate-90":0===m}),style:{...k}})]}),q&&e.jsx(r.Transition,{in:v,timeout:300,nodeRef:N,unmountOnExit:!0,children:l=>e.jsxs("div",{ref:N,className:t.cls("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===m}),style:{...t.getGlobalColorResponsiveStyle("bgc",d),...p,...i[l]},children:[0===m&&e.jsxs("div",{className:"gp-relative gp-flex gp-h-10 gp-w-full gp-items-center gp-justify-between gp-border-b",children:[e.jsx("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),w(!1)},className:"gp-relative gp-z-1 gp-flex gp-aspect-square gp-h-full gp-items-center gp-justify-center",children:e.jsx(a.default,{className:"gp-w-5"})}),e.jsx("div",{"aria-hidden":!0,onClick:e=>{e.preventDefault(),e.stopPropagation(),w(!1)},className:"gp-absolute gp-inset-0 gp-flex gp-items-center gp-justify-center",children:e.jsx("span",{className:"gp-font-semibold",children:C.title})}),e.jsx("button",{onClick:x,"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:{...t.getGlobalColorStateStyle("c",f)},children:e.jsx(n.default,{className:"gp-w-5"})})]}),e.jsx("ul",{className:t.cls("gp-flex gp-flex-col"),children:C?.childrens?.map(t=>e.jsx(o,{id:t,menu:c,depth:m+1,maxDepth:y,arrow:u,menuBg:d,menuTextColor:f},t))})]})})]})};exports.default=o;
