import{ah as e,aw as t,an as s,v as o,o as i,d as n,w as d,e as r,L as a,H as h,I as l,K as c,J as u,f as y,t as f,x as p,bp as k,i as C,a3 as b,$ as g,M as x,G as m,Q as N,R as w,X as I,h as K,a0 as S,N as _}from"./index-C0ioWTxp.js";import{_ as E}from"./u-badge.DbUhok-P.js";import{r as v}from"./uni-app.es.BJUZsD-t.js";import{_ as B}from"./_plugin-vue_export-helper.BCo6x5W8.js";import{r as L}from"./resources.DipqUmnN.js";import{l as T,g as A,T as D}from"./ly-checkbox.BhUXEP5M.js";let O=k;const{windowWidth:$}=e();const F=B({name:"u-tabs-swiper",emits:["update:modelValue","input","change"],props:{isScroll:{type:Boolean,default:!0},list:{type:Array,default:()=>[]},current:{type:[Number,String],default:0},height:{type:[Number,String],default:80},fontSize:{type:[Number,String],default:30},swiperWidth:{type:[String,Number],default:750},activeColor:{type:String,default:"#2979ff"},inactiveColor:{type:String,default:"#303133"},barWidth:{type:[Number,String],default:40},barHeight:{type:[Number,String],default:6},gutter:{type:[Number,String],default:40},zIndex:{type:[Number,String],default:1},bgColor:{type:String,default:"#ffffff"},autoCenterMode:{type:String,default:"window"},name:{type:String,default:"name"},count:{type:String,default:"count"},offset:{type:Array,default:()=>[5,20]},bold:{type:Boolean,default:!0},activeItemStyle:{type:Object,default:()=>({})},showBar:{type:Boolean,default:!0},barStyle:{type:Object,default:()=>({})}},data(){return{scrollLeft:0,tabQueryInfo:[],windowWidth:0,animationFinishCurrent:this.current,componentsWidth:0,line3AddDx:0,line3Dx:0,preId:"UEl_",sW:0,tabsInfo:[],colorGradientArr:[],colorStep:100}},computed:{getCurrent(){const e=Number(this.current);return e>this.getTabs.length-1?this.getTabs.length-1:e<0?0:e},getTabs(){return this.list},scrollBarLeft(){return Number(this.line3Dx)+Number(this.line3AddDx)},barWidthPx(){return t(this.barWidth)},tabItemStyle(){return e=>{let t={height:this.height+"rpx",lineHeight:this.height+"rpx",padding:`0 ${this.gutter/2}rpx`,color:this.tabsInfo.length>0?this.tabsInfo[e]?this.tabsInfo[e].color:this.activeColor:this.inactiveColor,fontSize:this.fontSize+"rpx",zIndex:this.zIndex+2,fontWeight:e==this.getCurrent&&this.bold?"bold":"normal"};return e==this.getCurrent&&(t=Object.assign(t,this.activeItemStyle)),t}},tabBarStyle(){let e={width:this.barWidthPx+"px",height:this.barHeight+"rpx",borderRadius:"100px",backgroundColor:this.activeColor,left:this.scrollBarLeft+"px"};return Object.assign(e,this.barStyle)}},watch:{current(e,t){this.change(e),this.setFinishCurrent(e)},list(){this.$nextTick((()=>{this.init()}))}},mounted(){this.init()},methods:{async init(){this.countPx(),await this.getTabsInfo(),this.countLine3Dx(),this.getQuery((()=>{this.setScrollViewToCenter()})),this.colorGradientArr=O.colorGradient(this.inactiveColor,this.activeColor,this.colorStep)},getTabsInfo(){return new Promise(((e,t)=>{let o=s().in(this);for(let s=0;s{const s=[];for(let e=0;e{t?(this.componentsWidth=t.width,e&&"function"==typeof e&&e(t)):this.getQuery(e)})).exec()}catch(t){this.componentsWidth=$}},setScrollViewToCenter(){let e;if(e=this.tabsInfo[this.animationFinishCurrent],e){let t,s=e.left+e.width/2;t="window"===this.autoCenterMode?$:this.componentsWidth,this.scrollLeft=s-t/2}},setDx(e){let t=e>0?this.animationFinishCurrent+1:this.animationFinishCurrent-1;t=t<=0?0:t,t=t>=this.list.length?this.list.length-1:t,this.tabsInfo[t];let s=this.tabsInfo[this.animationFinishCurrent],o=s.left+s.width/2,i=this.tabsInfo[t],n=i.left+i.width/2,d=Math.abs(n-o);this.line3AddDx=e/this.sW*d,this.setTabColor(this.animationFinishCurrent,t,e)},setTabColor(e,t,s){let o=Math.abs(Math.ceil(s/this.sW*100)),i=this.colorGradientArr.length;o=o>=i?i-1:o<=0?0:o,this.tabsInfo[t].color=this.colorGradientArr[o],this.tabsInfo[e].color=this.colorGradientArr[i-1-o]},setFinishCurrent(e){this.tabsInfo.map(((t,s)=>(t.color=e==s?this.activeColor:this.inactiveColor,t))),this.line3AddDx=0,this.animationFinishCurrent=e,this.countLine3Dx()}}},[["render",function(e,t,s,k,g,x){const m=v(o("u-badge"),E),N=C,w=b;return i(),n(N,{class:"u-tabs",style:a({zIndex:s.zIndex,background:s.bgColor})},{default:d((()=>[r(w,{"scroll-x":"",class:"u-scroll-view","scroll-left":g.scrollLeft,"scroll-with-animation":"",style:a({zIndex:s.zIndex+1})},{default:d((()=>[r(N,{class:h(["u-tabs-scroll-box",{"u-tabs-scroll-flex":!s.isScroll}])},{default:d((()=>[(i(!0),l(c,null,u(x.getTabs,((e,t)=>(i(),n(N,{class:h(["u-tabs-item",[g.preId+t]]),style:a([x.tabItemStyle(t)]),key:t,onClick:e=>x.emit(t)},{default:d((()=>[r(m,{count:e[s.count]||e.count||0,offset:s.offset,size:"mini"},null,8,["count","offset"]),y(" "+f(e[s.name]||e.name),1)])),_:2},1032,["style","class","onClick"])))),128)),s.showBar?(i(),n(N,{key:0,class:"u-scroll-bar",style:a([x.tabBarStyle])},null,8,["style"])):p("",!0)])),_:1},8,["class"])])),_:1},8,["scroll-left","style"])])),_:1},8,["style"])}],["__scopeId","data-v-9cfc860e"]]);const P=B({name:"LyTree",componentName:"LyTree",components:{LyTreeNode:B({name:"LyTreeNode",componentName:"LyTreeNode",components:{lyCheckbox:T},props:{nodeId:[Number,String],renderAfterExpand:{type:Boolean,default:!0},checkOnlyLeaf:{type:Boolean,default:!1},showCheckbox:{type:Boolean,default:!1},showRadio:{type:Boolean,default:!1},indent:Number,iconClass:String},data:()=>({node:{indeterminate:!1,checked:!1,expanded:!1},expanded:!1,childNodeRendered:!1,oldChecked:null,oldIndeterminate:null,highlightCurrent:!1}),inject:["tree"],computed:{checkboxVisible(){return this.checkOnlyLeaf?this.showCheckbox&&this.node.isLeaf:this.showCheckbox},radioVisible(){return this.checkOnlyLeaf?this.showRadio&&this.node.isLeaf:this.showRadio}},watch:{"node.indeterminate"(e){this.handleSelectChange(this.node.checked,e)},"node.checked"(e){this.handleSelectChange(e,this.node.indeterminate)},"node.expanded"(e){this.$nextTick((()=>this.expanded=e)),e&&(this.childNodeRendered=!0)}},methods:{getNodeKey(e){let t=this.tree.store.root.getChildNodes([e])[0];return A(this.tree.nodeKey,t.data)},handleSelectChange(e,t){if(this.oldChecked!==e&&this.oldIndeterminate!==t){if(this.checkOnlyLeaf&&!this.node.isLeaf)return;if(this.checkboxVisible){const s=this.tree.store._getAllNodes();this.tree.$emit("check-change",{checked:e,indeterminate:t,node:this.node,data:this.node.data,checkedall:s.every((e=>e.checked))})}else this.tree.$emit("radio-change",{checked:e,node:this.node,data:this.node.data,checkedall:!1})}!this.expanded&&this.tree.expandOnCheckNode&&e&&this.handleExpandIconClick(),this.oldChecked=e,this.indeterminate=t},handleClick(){this.tree.store.setCurrentNode(this.node),this.tree.$emit("current-change",{node:this.node,data:this.tree.store.currentNode?this.tree.store.currentNode.data:null,currentNode:this.tree.store.currentNode}),this.tree.currentNode=this.node,this.tree.expandOnClickNode&&this.handleExpandIconClick(),this.tree.checkOnClickNode&&!this.node.disabled&&(this.checkboxVisible||this.radioVisible)&&this.handleCheckChange(!this.node.checked),this.tree.$emit("node-click",this.node)},handleExpandIconClick(){this.node.isLeaf||(this.expanded?(this.tree.$emit("node-collapse",this.node),this.node.collapse()):(this.node.expand(),this.tree.$emit("node-expand",this.node),this.tree.accordion&&g(`${this.tree.elId}-tree-node-expand`,this.node)))},handleCheckChange(e){this.node.disabled||(this.checkboxVisible?this.node.setChecked(e,!(this.tree.checkStrictly||this.checkOnlyLeaf)):this.node.setRadioChecked(e),this.$nextTick((()=>{this.tree.$emit("check",{node:this.node,data:this.node.data,checkedNodes:this.tree.store.getCheckedNodes(),checkedKeys:this.tree.store.getCheckedKeys(),halfCheckedNodes:this.tree.store.getHalfCheckedNodes(),halfCheckedKeys:this.tree.store.getHalfCheckedKeys()})})),g("updateKey"))},handleImageError(){this.node.icon=this.tree.defaultNodeIcon}},created(){if(!this.tree)throw new Error("Can not find node's tree.");this.node=this.tree.store.nodesMap[this.nodeId],this.highlightCurrent=this.tree.highlightCurrent,this.node.expanded&&(this.expanded=!0,this.childNodeRendered=!0);const e=(this.tree.props||{}).children||"children";this.$watch(`node.data.${e}`,(()=>{this.node.updateChildren()})),this.tree.accordion&&x(`${this.tree.elId}-tree-node-expand`,(e=>{this.node.id!==e.id&&this.node.level===e.level&&this.node.collapse()}))},beforeDestroy(){this.$parent=null}},[["render",function(e,t,s,o,k,b){const g=K,x=m("ly-checkbox"),_=S,E=C,v=m("ly-tree-node",!0);return N((i(),n(E,{ref:"node",name:"LyTreeNode",class:h(["ly-tree-node",{"is-expanded":k.expanded,"is-hidden":!k.node.visible,"is-checked":!k.node.disabled&&k.node.checked}]),role:"treeitem",onClick:I(b.handleClick,["stop"])},{default:d((()=>[r(E,{class:h(["ly-tree-node__content",{"is-current":k.node.isCurrent&&k.highlightCurrent}]),style:a({"padding-left":(k.node.level-1)*s.indent+"px"})},{default:d((()=>[r(g,{onClick:I(b.handleExpandIconClick,["stop"]),class:h([{"is-leaf":k.node.isLeaf,expanded:!k.node.isLeaf&&k.node.expanded},"ly-tree-node__expand-icon",s.iconClass?s.iconClass:"ly-iconfont ly-icon-caret-right"])},null,8,["onClick","class"]),b.checkboxVisible||b.radioVisible?(i(),n(x,{key:0,type:b.checkboxVisible?"checkbox":"radio",checked:k.node.checked,indeterminate:k.node.indeterminate,disabled:!!k.node.disabled,onCheck:t[0]||(t[0]=e=>b.handleCheckChange(!k.node.checked))},null,8,["type","checked","indeterminate","disabled"])):p("",!0),k.node.loading?(i(),n(g,{key:1,class:"ly-tree-node__loading-icon ly-iconfont ly-icon-loading"})):p("",!0),k.node.icon&&k.node.icon.length>0?(i(),l(c,{key:2},[-1!==k.node.icon.indexOf("/")?(i(),n(_,{key:0,class:"ly-tree-node__icon",mode:"widthFix",src:k.node.icon,onError:b.handleImageError},null,8,["src","onError"])):(i(),n(g,{key:1,class:h(["ly-tree-node__icon",k.node.icon])},null,8,["class"]))],64)):p("",!0),r(g,{class:"ly-tree-node__label u-line-1"},{default:d((()=>[y(f(k.node.label),1)])),_:1})])),_:1},8,["class","style"]),!s.renderAfterExpand||k.childNodeRendered?N((i(),n(E,{key:0,class:"ly-tree-node__children",role:"group"},{default:d((()=>[(i(!0),l(c,null,u(k.node.childNodesId,(e=>(i(),n(v,{nodeId:e,"render-after-expand":s.renderAfterExpand,"show-checkbox":s.showCheckbox,"show-radio":s.showRadio,"check-only-leaf":s.checkOnlyLeaf,key:b.getNodeKey(e),indent:s.indent,"icon-class":s.iconClass},null,8,["nodeId","render-after-expand","show-checkbox","show-radio","check-only-leaf","indent","icon-class"])))),128))])),_:1},512)),[[w,k.expanded]]):p("",!0)])),_:1},8,["class","onClick"])),[[w,k.node.visible]])}],["__scopeId","data-v-c7a4cbf7"]])},data:()=>({updateKey:(new Date).getTime(),elId:`ly_${Math.ceil(1e6*Math.random()).toString(36)}`,visible:!0,store:{ready:!1},currentNode:null,childNodesId:[],mathKey:1,icon:L.message.nodata}),provide(){return{tree:this}},props:{treeData:Array,ready:{type:Boolean,default:!0},emptyText:{type:String,default:"暂无数据"},renderAfterExpand:{type:Boolean,default:!0},nodeKey:String,checkStrictly:Boolean,defaultExpandAll:{type:Boolean,default:!0},toggleExpendAll:Boolean,expandOnClickNode:{type:Boolean,default:!0},expandOnCheckNode:{type:Boolean,default:!0},checkOnClickNode:Boolean,checkDescendants:{type:Boolean,default:!1},autoExpandParent:{type:Boolean,default:!0},defaultCheckedKeys:Array,defaultExpandedKeys:Array,expandCurrentNodeParent:Boolean,currentNodeKey:[String,Number],checkOnlyLeaf:{type:Boolean,default:!1},showCheckbox:{type:Boolean,default:!1},showRadio:{type:Boolean,default:!1},props:{type:[Object,Function],default:()=>({children:"children",label:"label",disabled:"disabled"})},lazy:{type:Boolean,default:!1},highlightCurrent:Boolean,load:Function,filterNodeMethod:Function,childVisibleForFilterNode:{type:Boolean,default:!1},accordion:Boolean,indent:{type:Number,default:18},iconClass:String,showNodeIcon:{type:Boolean,default:!1},defaultNodeIcon:{type:String,default:""},isInjectParentInNode:{type:Boolean,default:!1}},computed:{isEmpty(){if(this.store.root){const e=this.store.root.getChildNodes(this.childNodesId);return!e||0===e.length||e.every((({visible:e})=>!e))}return!0},showLoading(){return this.mathKey,!(this.store.getReady()&&this.ready)}},watch:{toggleExpendAll(e){this.store.toggleExpendAll(e)},defaultCheckedKeys(e){this.store.setDefaultCheckedKey(e)},defaultExpandedKeys(e){this.store.defaultExpandedKeys=e,this.store.setDefaultExpandedKeys(e)},checkStrictly(e){this.store.checkStrictly=e||this.checkOnlyLeaf},"store.root.childNodesId"(e){this.childNodesId=e},"store.root.visible"(e){this.visible=e},childNodesId(){this.$nextTick((()=>{this.$emit("ly-tree-render-completed")}))},treeData:{handler(e){this.updateKey=(new Date).getTime(),this.store.setData(e)},deep:!0}},methods:{filter(e,t){if(!this.filterNodeMethod)throw new Error("[Tree] filterNodeMethod is required when filter");this.store.filter(e,t),this.handleUpdateKey()},handleUpdateKey(){this.updateKey=(new Date).getTime()},getNodeKey(e){let t=this.store.root.getChildNodes([e])[0];return A(this.nodeKey,t.data)},getNodePath(e){return this.store.getNodePath(e)},getCheckedNodes(e,t){return this.store.getCheckedNodes(e,t)},getCheckedKeys(e,t){return this.store.getCheckedKeys(e,t)},getCurrentNode(){const e=this.store.getCurrentNode();return e?e.data:null},getCurrentKey(){const e=this.getCurrentNode();return e?e[this.nodeKey]:null},setCheckAll(e=!0){if(this.showRadio)throw new Error('You set the "show-radio" property, so you cannot select all nodes');this.showCheckbox||console.warn('You have not set the property "show-checkbox". Please check your settings'),this.store.setCheckAll(e)},setCheckedNodes(e,t){this.store.setCheckedNodes(e,t)},setCheckedKeys(e,t){if(!this.nodeKey)throw new Error("[Tree] nodeKey is required in setCheckedKeys");this.store.setCheckedKeys(e,t),this.handleUpdateKey()},setChecked(e,t,s){this.store.setChecked(e,t,s)},getHalfCheckedNodes(){return this.store.getHalfCheckedNodes()},getHalfCheckedKeys(){return this.store.getHalfCheckedKeys()},setCurrentNode(e){if(!this.nodeKey)throw new Error("[Tree] nodeKey is required in setCurrentNode");this.store.setUserCurrentNode(e)},setCurrentKey(e){if(!this.nodeKey)throw new Error("[Tree] nodeKey is required in setCurrentKey");this.store.setCurrentNodeKey(e)},getNode(e){return this.store.getNode(e)},remove(e){this.store.remove(e)},append(e,t){this.store.append(e,t)},insertBefore(e,t){this.store.insertBefore(e,t)},insertAfter(e,t){this.store.insertAfter(e,t)},updateKeyChildren(e,t){if(!this.nodeKey)throw new Error("[Tree] nodeKey is required in updateKeyChild");this.store.updateChildren(e,t)}},created(){this.isTree=!0;let e=this.props;if("function"==typeof this.props&&(e=this.props()),"object"!=typeof e)throw new Error("props must be of object type.");this.store=new D({key:this.nodeKey,data:this.treeData,lazy:this.lazy,props:e,load:this.load,showCheckbox:this.showCheckbox,showRadio:this.showRadio,currentNodeKey:this.currentNodeKey,checkStrictly:this.checkStrictly||this.checkOnlyLeaf,checkDescendants:this.checkDescendants,expandOnCheckNode:this.expandOnCheckNode,defaultCheckedKeys:this.defaultCheckedKeys,defaultExpandedKeys:this.defaultExpandedKeys,expandCurrentNodeParent:this.expandCurrentNodeParent,autoExpandParent:this.autoExpandParent,defaultExpandAll:this.defaultExpandAll,filterNodeMethod:this.filterNodeMethod,childVisibleForFilterNode:this.childVisibleForFilterNode,showNodeIcon:this.showNodeIcon,isInjectParentInNode:this.isInjectParentInNode}),this.childNodesId=this.store.root.childNodesId,x("updateKey",(()=>{this.handleUpdateKey(),this.mathKey++}))},beforeDestroy(){this.accordion&&_(`${this.elId}-tree-node-expand`),_("updateKey")}},[["render",function(e,t,s,o,a,f){const k=C,b=S,g=K,x=m("ly-tree-node");return i(),n(k,null,{default:d((()=>[f.showLoading?(i(),n(k,{key:0,class:"ly-loader ly-flex-center"},{default:d((()=>[r(k,{class:"ly-loader-inner"},{default:d((()=>[y("加载中...")])),_:1})])),_:1})):(i(),l(c,{key:1},[f.isEmpty||!a.visible?(i(),n(k,{key:0,class:"notData-box u-flex-col"},{default:d((()=>[r(k,{class:"u-flex-col notData-inner"},{default:d((()=>[r(b,{src:a.icon,mode:"",class:"iconImg"},null,8,["src"])])),_:1}),r(g,{class:"notData-inner-text"},{default:d((()=>[y("暂无数据")])),_:1})])),_:1})):p("",!0),(i(),n(k,{key:a.updateKey,class:h(["ly-tree",{"is-empty":f.isEmpty||!a.visible}]),role:"tree",name:"LyTreeExpand"},{default:d((()=>[(i(!0),l(c,null,u(a.childNodesId,(e=>(i(),n(x,{nodeId:e,"render-after-expand":s.renderAfterExpand,"show-checkbox":s.showCheckbox,"show-radio":s.showRadio,"check-only-leaf":s.checkOnlyLeaf,key:f.getNodeKey(e),indent:s.indent,"icon-class":s.iconClass,updateKey:"hanldeUpdateKey"},null,8,["nodeId","render-after-expand","show-checkbox","show-radio","check-only-leaf","indent","icon-class"])))),128))])),_:1},8,["class"]))],64))])),_:1})}],["__scopeId","data-v-e9e2de34"]]);export{P as _,F as a};