"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("vue"),R=require("../vc-util/Dom/css.js"),_=3,D=8;let n;const N={padding:0,margin:0,display:"inline",lineHeight:"inherit"};function v(e,s){e.setAttribute("aria-hidden","true");const r=window.getComputedStyle(s),p=R.styleToString(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 V(e){const s=document.createElement("div");v(s,e),s.appendChild(document.createTextNode("text")),document.body.appendChild(s);const r=s.getBoundingClientRect().height;return document.body.removeChild(s),r}const q=(e,s,r,p,H)=>{n||(n=document.createElement("div"),n.setAttribute("aria-hidden","true"),document.body.appendChild(n));const{rows:T,suffix:C=""}=s,b=V(e),S=Math.round(b*T*100)/100;v(n,e);const h=u.createApp({render(){return u.createVNode("div",{style:N},[u.createVNode("span",{style:N},[r,C]),u.createVNode("span",{style:N},[p])])}});h.mount(n);function a(){return Math.round(n.getBoundingClientRect().height*100)/100-.1<=S}if(a())return h.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!==D&&i!==""),w=Array.prototype.slice.apply(n.childNodes[0].childNodes[1].cloneNode(!0).childNodes);h.unmount();const g=[];n.innerHTML="";const y=document.createElement("span");n.appendChild(y);const x=document.createTextNode(H+C);y.appendChild(x),w.forEach(t=>{n.appendChild(t)});function E(t){y.insertBefore(t,x)}function m(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 f=i.slice(0,c);if(t.textContent=f,a()||!f)return c===i.length?{finished:!1,vNode:i}:{finished:!0,vNode:f}}return a()?m(t,i,l,d,l):m(t,i,o,l,B)}function A(t){if(t.nodeType===_){const o=t.textContent||"",d=document.createTextNode(o);return E(d),m(d,o)}return{finished:!1,vNode:null}}return M.some(t=>{const{finished:i,vNode:o}=A(t);return o&&g.push(o),i}),{content:g,text:n.innerHTML,ellipsis:!0}};exports.default=q;
