import{t as me,aM as z,x,aK as W,aQ as ge,z as y,am as se,av as Ce,a_ as ue,a5 as M,G as ne,H as ie,dl as Ke,L as ce,l as b,ad as H,a4 as he,aw as ve,cr as pe,a6 as Q,ae as re,cq as Ne,D as T,Q as N,T as c,U as Ae,E as Se,dm as Ee,ah as ye,cs as _e}from"./index-CEmnTf-r.js";var we=function(D){me(l,D);function l(e){var t=D.call(this,e)||this;t.newTabDefaultId=3;var a=e.location||window.location,n=e.tabs,i=e.source,o=e.data,r=0;if(typeof e.activeKey<"u")r=e.activeKey;else if(a&&Array.isArray(n)){var h=a.hash.substring(1),u=z(n,function(A){return A.hash===h});u?r=u.hash:e.defaultKey!==void 0?r=typeof e.defaultKey=="string"?x(e.defaultKey,e.data):e.defaultKey:e.defaultActiveKey&&(r=typeof e.defaultActiveKey=="string"?x(e.defaultActiveKey,e.data):e.defaultActiveKey),r=r||n[0]&&n[0].hash||0}var p=W(t.initTabArray(n,i,o),2),v=p[0],g=p[1];return t.state={prevKey:void 0,activeKey:t.activeKey=r,localTabs:v,isFromSource:g},t}return l.prototype.initTabArray=function(e,t,a){if(!e)return[[],!1];var n=x(t,a,"| raw");if(!Array.isArray(n))return[e,!1];e=Array.isArray(e)?e:[e];var i=[];return n.forEach(function(o){i.push.apply(i,ge([],W(e.map(function(r){return y(y({},r),{data:o})})),!1))}),[i,!0]},l.prototype.componentDidMount=function(){var e,t;this.autoJumpToNeighbour(this.activeKey);var a=this.props,n=a.name,i=a.value,o=a.onChange,r=a.source;a.tabs;var h=a.data,u=this.state.localTabs;if(!(!n||typeof o!="function"||r))if(i=i??se(h,n),i&&Array.isArray(u)){var p=this.resolveKeyByValue(i);p!==void 0&&this.handleSelect(p)}else{var v=this.resolveTabByKey(this.activeKey);v&&i!==((e=v.value)!==null&&e!==void 0?e:v.title)&&o((t=v.value)!==null&&t!==void 0?t:v.title,n)}},l.prototype.componentDidUpdate=function(e,t){var a,n,i,o=this.props,r=this.state.localTabs,h=x(e.defaultActiveKey,e.data),u=x(o.defaultActiveKey,o.data),p=Ce({tabs:o.tabs,source:x(o.source,o.data,"| raw")},{tabs:e.tabs,source:x(e.source,e.data,"| raw")},!1);if(p){var v=W(this.initTabArray(o.tabs,o.source,o.data),2),g=v[0],A=v[1];this.setState({localTabs:g,isFromSource:A}),r=g}if(o.location&&e.location&&o.location.hash!==e.location.hash){var _=o.location.hash.substring(1);if(!_)return;var m=z(r,function(F){return F.hash===_});m&&m.hash&&m.hash!==this.state.activeKey&&this.setState({activeKey:this.activeKey=m.hash,prevKey:this.state.activeKey})}else if(Array.isArray(r)&&Array.isArray(t.localTabs)&&JSON.stringify(r.map(function(F){return F.hash}))!==JSON.stringify(t.localTabs.map(function(F){return F.hash}))){var S=this.state.activeKey,U=o.location,m=null;if(U&&Array.isArray(r)){var k=U.hash.substring(1);m=z(r,function(E){return E.hash===k})}m?S=m.hash:(!r||!r.some(function(E,Y){return E.hash?E.hash===S:Y===S}))&&(S=r&&r[0]&&r[0].hash||0),this.setState({prevKey:void 0,activeKey:this.activeKey=S})}else if(h!==u){if(u==null)return;var w=null,m=z(r,function(E){return E.hash===u});m?w=m.hash:typeof u=="number"&&r[u]&&(w=u),w!==null&&this.setState({prevKey:h,activeKey:this.activeKey=w})}this.autoJumpToNeighbour(this.activeKey);var O=this.props,V=O.name,C=O.value,J=O.onChange,q=O.source,P=O.data;if(!(!V||typeof J!="function"||q)){var R;C=C??se(P,V);var X=(a=e.value)!==null&&a!==void 0?a:se(e.data,e.name);if(C!==X&&(R=this.resolveKeyByValue(C))!==void 0&&R!==this.activeKey)this.handleSelect(R);else if(this.activeKey!==t.activeKey){var m=this.resolveTabByKey(this.activeKey);m&&C!==((n=m.value)!==null&&n!==void 0?n:m.title)&&J((i=m.value)!==null&&i!==void 0?i:m.title,V)}}},l.prototype.resolveTabByKey=function(e){var t=this.state.localTabs;if(Array.isArray(t))return z(t,function(a,n){return a.hash?a.hash===e:n===e})},l.prototype.resolveKeyByValue=function(e){var t=this.state.localTabs;if(Array.isArray(t)){var a=z(t,function(n){var i;return((i=n.value)!==null&&i!==void 0?i:n.title)===e});return a&&a.hash?a.hash:t.indexOf(a)}},l.prototype.autoJumpToNeighbour=function(e){var t=this.props;t.tabs;var a=t.data,n=this.state.localTabs;if(Array.isArray(n)){var i=ue(n,function(p,v){return p.hash?p.hash===e:v===e});if(n[i]&&!M(n[i],this.props.data))for(var o=n.length,r=i,h=i;r-->=0||h++=0&&M(n[r],a)?u=n[r].hash||r:h0?((K=f[d-1])===null||K===void 0?void 0:K.hash)||d-1:0,nextKey:d0?((K=f[d-1])===null||K===void 0?void 0:K.hash)||d-1:0,nextKey:d a"},focused:{important:!0,suf:".is-active",inner:"> a"},hover:{important:!0,inner:"> a"},disabled:{important:!0,suf:".is-disabled",inner:"> a"}}},{key:"toolbarControlClassName",weights:{default:{important:!0}}},{key:"contentControlClassName",weights:{default:{important:!0}}}]},env:fe})))},l.prototype.render=function(){return this.renderTabs()},l.defaultProps={className:"",mode:"",mountOnEnter:!0,unmountOnExit:!1},T([N,c("design:type",Function),c("design:paramtypes",[Array,String,Object]),c("design:returntype",Array)],l.prototype,"initTabArray",null),T([N,c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",void 0)],l.prototype,"autoJumpToNeighbour",null),T([N,c("design:type",Function),c("design:paramtypes",[]),c("design:returntype",void 0)],l.prototype,"handleAdd",null),T([N,c("design:type",Function),c("design:paramtypes",[Object,Boolean]),c("design:returntype",Promise)],l.prototype,"handleClose",null),T([N,c("design:type",Function),c("design:paramtypes",[Number,String]),c("design:returntype",void 0)],l.prototype,"handleEdit",null),T([N,c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",Promise)],l.prototype,"handleDragChange",null),T([N,c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",Promise)],l.prototype,"handleSelect",null),T([N,c("design:type",Function),c("design:paramtypes",[Number]),c("design:returntype",void 0)],l.prototype,"switchTo",null),T([N,c("design:type",Function),c("design:paramtypes",[]),c("design:returntype",Number)],l.prototype,"currentIndex",null),l}(b.Component),Fe=function(D){me(l,D);function l(e,t){var a=D.call(this,e)||this,n=t;return n.registerComponent(a),a}return l.prototype.componentWillUnmount=function(){var e;(e=D.prototype.componentWillUnmount)===null||e===void 0||e.call(this);var t=this.context;t.unRegisterComponent(this)},l.contextType=Ae,l=T([Se({type:"tabs",onGlobalVarChanged:function(e,t,a){if(Ee(t.source)){var n=W(e.initTabArray(e.props.tabs,e.props.source,a),2),i=n[0],o=n[1];return e.setState({localTabs:i,isFromSource:o}),!1}}}),c("design:paramtypes",[Object,Object])],l),l}(we);export{Fe as TabsRenderer,we as default};