import{createApp as R,createVNode as f}from"vue";import{styleToString as D}from"../vc-util/Dom/css.mjs";const W=3,_=8;let n;const C={padding:0,margin:0,display:"inline",lineHeight:"inherit"};function H(e,s){e.setAttribute("aria-hidden","true");const r=window.getComputedStyle(s),p=D(r);e.setAttribute("style",p),e.style.position="fixed",e.style.left="0",e.style.height="auto",e.style.minHeight="auto",e.style.maxHeight="auto",e.style.paddingTop="0",e.style.paddingBottom="0",e.style.borderTopWidth="0",e.style.borderBottomWidth="0",e.style.top="-999999px",e.style.zIndex="-1000",e.style.textOverflow="clip",e.style.whiteSpace="normal",e.style.webkitLineClamp="none"}function k(e){const s=document.createElement("div");H(s,e),s.appendChild(document.createTextNode("text")),document.body.appendChild(s);const r=s.getBoundingClientRect().height;return document.body.removeChild(s),r}const V=(e,s,r,p,T)=>{n||(n=document.createElement("div"),n.setAttribute("aria-hidden","true"),document.body.appendChild(n));const{rows:v,suffix:N=""}=s,b=k(e),S=Math.round(b*v*100)/100;H(n,e);const u=R({render(){return f("div",{style:C},[f("span",{style:C},[r,N]),f("span",{style:C},[p])])}});u.mount(n);function h(){return Math.round(n.getBoundingClientRect().height*100)/100-.1<=S}if(h())return u.unmount(),{content:r,text:n.innerHTML,ellipsis:!1};const M=Array.prototype.slice.apply(n.childNodes[0].childNodes[0].cloneNode(!0).childNodes).filter(({nodeType:t,data:i})=>t!==_&&i!==""),w=Array.prototype.slice.apply(n.childNodes[0].childNodes[1].cloneNode(!0).childNodes);u.unmount();const x=[];n.innerHTML="";const a=document.createElement("span");n.appendChild(a);const g=document.createTextNode(T+N);a.appendChild(g),w.forEach(t=>{n.appendChild(t)});function E(t){a.insertBefore(t,g)}function y(t,i,o=0,d=i.length,B=0){const l=Math.floor((o+d)/2),O=i.slice(0,l);if(t.textContent=O,o>=d-1)for(let c=d;c>=o;c-=1){const m=i.slice(0,c);if(t.textContent=m,h()||!m)return c===i.length?{finished:!1,vNode:i}:{finished:!0,vNode:m}}return h()?y(t,i,l,d,l):y(t,i,o,l,B)}function A(t){if(t.nodeType===W){const o=t.textContent||"",d=document.createTextNode(o);return E(d),y(d,o)}return{finished:!1,vNode:null}}return M.some(t=>{const{finished:i,vNode:o}=A(t);return o&&x.push(o),i}),{content:x,text:n.innerHTML,ellipsis:!0}};export{V as default};
