import{s as R,cn as Q,y as _,f as u,K as N,bd as P,a3 as q,ao as w,aH as G,aI as J,a5 as g,cm as A,a6 as S,cl as L,d9 as U,z as k,P as W,Q as x,D as X}from"./index-BPRWoLf4.js";var Y=function(f){R(n,f);function n(t){var a=f.call(this,t)||this,e=t.activeKey||0;return a.state={activeKey:e},a}return n.prototype.handleSelect=function(t){var a=this.props,e=a.onSelect,s=a.tabs;if(typeof t=="number"&&t<s.length&&this.setState({activeKey:t}),typeof e=="string"){var o=Q(e,"key","props");o&&o(t,this.props)}else typeof e=="function"&&e(t,this.props)},n.prototype.renderToolbarItem=function(t){var a=this.props.render,e=[];return Array.isArray(t)&&t.forEach(function(s,o){return e.push(a("toolbar/".concat(o),_({type:"button",level:"link",size:"sm"},s),{key:o}))}),e},n.prototype.renderToolbar=function(){var t=this.props,a=t.toolbar,e=t.classnames,s=t.classPrefix,o=t.tabs,c=this.state.activeKey,d=null,v=null,y=a?u.createElement("div",{className:e("".concat(s,"toolbar"))},this.renderToolbarItem(a)):null;return typeof c<"u"&&(d=o[c].toolbar,v=d?u.createElement("div",{className:e("".concat(s,"tab-toolbar"))},this.renderToolbarItem(d)):null),y||v?u.createElement("div",{className:e("".concat(s,"Portlet-toolbar"))},y,v):null},n.prototype.renderDesc=function(){var t=this.props,a=t.description;t.render;var e=t.classnames,s=t.classPrefix,o=t.data,c=N(a,o);return c?u.createElement("span",{className:e("".concat(s,"Portlet-header-desc"))},c):null},n.prototype.renderTabs=function(){var t,a=this,e=this.props,s=e.classnames,o=e.classPrefix,c=e.tabsClassName,d=e.contentClassName,v=e.linksClassName,y=e.tabRender,h=e.render,p=e.data,B=e.mode,D=e.tabsMode,O=e.unmountOnExit,V=e.source,C=e.mountOnEnter,H=e.scrollable,M=e.translate,j=e.addBtnText,z=e.divider,I=D||B,K=P(V,p),m=this.props.tabs;if(!m)return null;m=Array.isArray(m)?m:[m];var b=[],F=s("".concat(o,"Portlet-tab"),c,(t={},t["unactive-select"]=m.length<=1,t["no-divider"]=!z,t));return Array.isArray(K)?K.forEach(function(r,i){var E=q(p,w(r)?_({index:i},r):{item:r,index:i});b.push.apply(b,G([],J(m.map(function(l,T){return g(l,E)?u.createElement(A,_({},l,{title:N(l.title,E),disabled:S(l,E),key:"".concat(i*1e3+T),eventKey:i*1e3+T,mountOnEnter:C,unmountOnExit:typeof l.reload=="boolean"?l.reload:typeof l.unmountOnExit=="boolean"?l.unmountOnExit:O}),h("item/".concat(i,"/").concat(T),l!=null&&l.type?l:l.tab||l.body,{data:E})):null})),!1))}):b=m.map(function(r,i){return g(r,p)?u.createElement(A,_({},r,{title:N(r.title,p),disabled:S(r,p),key:i,eventKey:i,mountOnEnter:C,unmountOnExit:typeof r.reload=="boolean"?r.reload:typeof r.unmountOnExit=="boolean"?r.unmountOnExit:O}),a.renderTab?a.renderTab(r,a.props,i):y?y(r,a.props,i):h("tab/".concat(i),r!=null&&r.type?r:r.tab||r.body)):null}),u.createElement(L,{addBtnText:M(j||"add"),classPrefix:o,classnames:s,mode:I,className:F,contentClassName:d,linksClassName:v,activeKey:this.state.activeKey,onSelect:this.handleSelect,toolbar:this.renderToolbar(),additionBtns:this.renderDesc(),scrollable:H},b)},n.prototype.render=function(){var t,a=this.props,e=a.className,s=a.data,o=a.classnames,c=a.classPrefix,d=a.style,v=a.hideHeader,y=o("".concat(c,"Portlet"),e,(t={},t["no-header"]=v,t)),h=typeof d=="string"?P(d,s)||{}:U(d,function(p){return P(p,s)||p});return u.createElement("div",{className:y,style:h},this.renderTabs())},n.defaultProps={className:"",mode:"line",divider:!0},k([W,x("design:type",Function),x("design:paramtypes",[Number]),x("design:returntype",void 0)],n.prototype,"handleSelect",null),n}(u.Component),$=function(f){R(n,f);function n(){return f!==null&&f.apply(this,arguments)||this}return n=k([X({type:"portlet"})],n),n}(Y);export{Y as Portlet,$ as PortletRenderer};
