"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),q=require("@ant-design/icons-vue"),y=require("@aplus-frontend/antdv"),T=require("lodash-unified");require("../../config-provider/index.js");const W=require("../../config-provider/hooks/use-token.js");require("../../hooks/index.js");const b=require("../../utils/warning.js");require("./ap-tag.vue2.js");const S=require("./style/group.js"),h=require("./utils.js"),z=require("../../config-provider/hooks/use-locale.js"),_=require("../../config-provider/hooks/use-namespace.js"),D=require("../../hooks/useResize.js"),P=require("./ap-tag.vue.js"),G=e.defineComponent({__name:"ap-tag-group",props:{list:{default:()=>[]},space:{default:4},ellipsisColor:{},ellipsis:{default:()=>({isWrapGroup:!0})}},setup(n){const{t:x}=z.useLocale(),o=n,{token:k}=W.useToken(),C=b.useDevWarning("ApTagGroup"),{b:u}=_.useNamespace("tag-group"),w=S.default("tag-group"),i=e.ref(),{observe:E,unobserve:V}=D.useResize(),r=e.computed(()=>({...{iconColor:k.value?.textColor1,symbol:"icon",text:x("ap.common.more")},...o.ellipsis})),m=e.computed(()=>r.value.tooltip&&typeof r.value.tooltip=="object"?T.omit(r.value.tooltip,["trigger","title"]):{}),c=e.computed(()=>e.unref(p)<o.list.length),p=e.ref(0),g=e.computed(()=>o.list.map(t=>t.text).join("、")),N=e.computed(()=>[u(),w.value].filter(Boolean)),f=()=>{let t=0,l=0;if(!i.value)return;const a=i.value.offsetWidth;for(let s of o.list){const d=s.size==="small"?8:12,v=h.getTextWidth(s.size==="large"?14:12,s.text)+d+o.space;if(t+=v,t>a){t-=v;break}l++}if(l<o.list.length){const d=h.getTextWidth(12,r.value.text);o.ellipsis.symbol==="icon"?t+=16:t+=d,t>a&&l--}p.value=l};e.watch(()=>o.list,(t,l)=>{t!==l&&e.nextTick(()=>{f()})},{immediate:!0});const B=()=>{f()};return e.onMounted(()=>{[["ellipsisColor","ellipse.color"]].forEach(([t,l])=>{C.deprecated(!o[t],t,l)}),i.value&&E(i.value,B)}),e.onUnmounted(()=>{i.value&&V(i.value)}),(t,l)=>(e.openBlock(),e.createBlock(e.unref(y.Tooltip),e.mergeProps({trigger:"hover"},m.value),e.createSlots({default:e.withCtx(()=>[e.createElementVNode("div",{ref_key:"container",ref:i,class:e.normalizeClass(N.value),style:e.normalizeStyle({pointerEvents:c.value?"auto":"none"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.list,(a,s)=>(e.openBlock(),e.createBlock(P.default,e.mergeProps({ref_for:!0},a,{key:s,style:{display:s>=p.value?"none":"inline-flex",marginRight:`${n.space}px`}}),null,16,["style"]))),128)),c.value&&r.value.symbol==="icon"?(e.openBlock(),e.createBlock(e.unref(q),{key:0,style:e.normalizeStyle({color:n.ellipsisColor||r.value.iconColor,cursor:"pointer"})},{component:e.withCtx(()=>[...l[0]||(l[0]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",fill:"none",version:"1.1",width:"16",height:"16",viewBox:"0 0 16 16"},[e.createElementVNode("defs",null,[e.createElementVNode("clipPath",{id:"master_svg0_1133_24991"},[e.createElementVNode("rect",{x:"0",y:"0",width:"16",height:"16",rx:"0"})])]),e.createElementVNode("g",{"clip-path":"url(#master_svg0_1133_24991)"},[e.createElementVNode("g",null,[e.createElementVNode("ellipse",{cx:"8",cy:"8",rx:"1",ry:"1",fill:"currentColor","fill-opacity":"1"})]),e.createElementVNode("g",null,[e.createElementVNode("ellipse",{cx:"3.25",cy:"8",rx:"1",ry:"1",fill:"currentColor","fill-opacity":"1"})]),e.createElementVNode("g",null,[e.createElementVNode("ellipse",{cx:"12.75",cy:"8",rx:"1",ry:"1",fill:"currentColor","fill-opacity":"1"})])])],-1)])]),_:1},8,["style"])):c.value&&r.value.symbol==="text"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[n.ellipsis.isWrapGroup?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(e.unref(u)("ellipsis-text")),style:{cursor:"pointer"}},e.toDisplayString(r.value.text),3)):(e.openBlock(),e.createBlock(e.unref(y.Tooltip),e.mergeProps({key:1,trigger:"hover"},m.value),{title:e.withCtx(()=>[e.renderSlot(t.$slots,"tooltip",{tags:n.list},()=>[e.createTextVNode(e.toDisplayString(g.value),1)])]),default:e.withCtx(()=>[e.createElementVNode("span",{class:e.normalizeClass(e.unref(u)("ellipsis-text")),style:{cursor:"pointer"}},e.toDisplayString(r.value.text),3)]),_:3},16))],64)):e.createCommentVNode("",!0)],6)]),_:2},[n.ellipsis.isWrapGroup?{name:"title",fn:e.withCtx(()=>[e.renderSlot(t.$slots,"tooltip",{tags:n.list},()=>[e.createTextVNode(e.toDisplayString(g.value),1)])]),key:"0"}:void 0]),1040))}});exports.default=G;
