import{_ as __rest,a as __assign}from"./tslib.es6-bjGg6Bxl.js";import React__default,{createContext,useState,useEffect}from"react";var NavigationContext=createContext(void 0),Navigation=function(a){var b=a.activeItem,c=void 0===b?"":b,d=a.ariaLabel,e=void 0===d?"":d,f=a.children,g=void 0===f?null:f,h=a.className,i=void 0===h?"":h,j=a.disabled,k=void 0!==j&&j,l=a.onActiveItemChange,m=__rest(a,["activeItem","ariaLabel","children","className","disabled","onActiveItemChange"]),n=useState(""),o=n[0],p=n[1],q=useState(new Map),r=q[0],s=q[1],t=function(a){var b=["value","children","label"],c=Array.from(r.keys());if(c.includes(a))return a;for(var d,e=void 0,f=function(c){var d=r.get(c);b.forEach(function(b){d&&d[b]===a&&(e=d.id)})},g=0,h=c;g<h.length;g++)d=h[g],f(d);return e};useEffect(function(){if(c){var a=t(c);p(a)}},[c]),useEffect(function(){if(c){var a=t(c);p(a)}},[r]);return React__default.createElement(NavigationContext.Provider,{value:{activeItem:o,addItem:function(a,b,c,d){s(function(e){return new Map(e).set(a,{id:a,value:d,label:c,children:b,displayName:b||c||d})})},handleActiveItemChange:function(a){p(a),l&&l(a)},navigationDisabled:k}},React__default.createElement("ul",__assign({"aria-disabled":!!k,"aria-label":e&&e.length?e:"",className:"juno-navigation \n          ".concat(k?"juno-navigation-disabled":""," \n          ").concat(i),role:"navigation"},m),g))};export{Navigation as N,NavigationContext as a};