import{s as m,a5 as N,f as p,dX as _,y as S,K as A,aH as g,aI as C,dY as R,z as u,P as y,Q as d,D as b}from"./index-BPRWoLf4.js";var P=function(c){m(a,c);function a(e){var r=c.call(this,e)||this,t=e.links,s=0;if(typeof e.active<"u")s=e.active;else{var i=r.getActiveSection(t,e.active,null);s=i&&i.href?i.href:t[0]&&t[0].href||0}return r.state={active:s},r}return a.prototype.getActiveSection=function(e,r,t){var s=this;return t||(e.forEach(function(i){i.href===r?t=i:i.children&&s.getActiveSection(i.children,r,t)}),t)},a.prototype.handleSelect=function(e){this.setState({active:e})},a.prototype.locateTo=function(e){var r=this.props.links;Array.isArray(r)&&r[e]&&this.setState({active:r[e].href||e})},a.prototype.renderSections=function(e,r){var t=this,s=this.props;s.classnames,s.classPrefix;var i=s.sectionRender,f=s.render,h=s.data;e=Array.isArray(e)?e:[e];var l=[];return e.forEach(function(n,v){if(N(n,h)){var o=(r?r+"-":"")+v;l.push(p.createElement(_,S({},n,{title:A(n.title,h),key:o,name:n.href||o}),t.renderSection?t.renderSection(n,t.props,o):i?i(n,t.props,o):f("section/".concat(o),n.body||""))),n.children&&l.push.apply(l,g([],C(t.renderSections(n.children,o)),!1))}}),l.filter(function(n){return!!n})},a.prototype.render=function(){var e=this.props,r=e.classnames,t=e.classPrefix,s=e.className,i=e.style,f=e.linkClassName,h=e.sectionClassName,l=e.direction;e.sectionRender,e.render,e.data;var n=this.props.links;if(!n)return null;var v=this.renderSections(n);return p.createElement(R,{classPrefix:t,classnames:r,className:s,style:i,linkClassName:f,sectionClassName:h,onSelect:this.handleSelect,active:this.state.active,direction:l},v)},a.defaultProps={className:"",linkClassName:"",sectionClassName:""},u([y,d("design:type",Function),d("design:paramtypes",[Object]),d("design:returntype",void 0)],a.prototype,"handleSelect",null),u([y,d("design:type",Function),d("design:paramtypes",[Number]),d("design:returntype",void 0)],a.prototype,"locateTo",null),a}(p.Component),E=function(c){m(a,c);function a(){return c!==null&&c.apply(this,arguments)||this}return a=u([b({type:"anchor-nav"})],a),a}(P);export{E as AnchorNavRenderer,P as default};
