let M,P,Y=typeof Symbol=="function"?Symbol():"_split",K,oe=()=>K||ue.register(window.gsap),Z=typeof Intl<"u"&&"Segmenter"in Intl?new Intl.Segmenter:0,H=e=>e?typeof e=="string"?H(document.querySelectorAll(e)):"length"in e?Array.from(e).reduce((t,i)=>(typeof i=="string"?t.push(...H(i)):t.push(i),t),[]):[e]:[],$=e=>H(e).filter(t=>t&&t.nodeType===1),Q=[],J=function(){},ae={add:e=>e()},de=/\s+/g,ee=new RegExp("\\p{RI}\\p{RI}|\\p{Emoji}(\\p{EMod}|\\u{FE0F}\\u{20E3}?|[\\u{E0020}-\\u{E007E}]+\\u{E007F})?(\\u{200D}\\p{Emoji}(\\p{EMod}|\\u{FE0F}\\u{20E3}?|[\\u{E0020}-\\u{E007E}]+\\u{E007F})?)*|.","gu"),G={left:0,top:0,width:0,height:0},he=(e,t)=>{for(;++t<e.length&&e[t]===G;);return e[t]||G},te=({element:e,html:t,ariaL:i,ariaH:s})=>{e.innerHTML=t,i?e.setAttribute("aria-label",i):e.removeAttribute("aria-label"),s?e.setAttribute("aria-hidden",s):e.removeAttribute("aria-hidden")},ie=(e,t)=>{if(t){let i=new Set(e.join("").match(t)||Q),s=e.length,a,c,r,o;if(i.size)for(;--s>-1;){c=e[s];for(r of i)if(r.startsWith(c)&&r.length>c.length){for(a=0,o=c;r.startsWith(o+=e[s+ ++a])&&o.length<r.length;);if(a&&o.length===r.length){e[s]=r,e.splice(s+1,a);break}}}}return e},se=e=>window.getComputedStyle(e).display==="inline"&&(e.style.display="inline-block"),F=(e,t,i)=>t.insertBefore(typeof e=="string"?document.createTextNode(e):e,i),U=(e,t,i)=>{let s=t[e+"sClass"]||"",{tag:a="div",aria:c="auto",propIndex:r=!1}=t,o=e==="line"?"block":"inline-block",h=s.indexOf("++")>-1,T=S=>{let g=document.createElement(a),_=i.length+1;return s&&(g.className=s+(h?" "+s+_:"")),r&&g.style.setProperty("--"+e,_+""),c!=="none"&&g.setAttribute("aria-hidden","true"),a!=="span"&&(g.style.position="relative",g.style.display=o),g.textContent=S,i.push(g),g};return h&&(s=s.replace("++","")),T.collection=i,T},pe=(e,t,i,s)=>{let a=U("line",i,s),c=window.getComputedStyle(e).textAlign||"left";return(r,o)=>{let h=a("");for(h.style.textAlign=c,e.insertBefore(h,t[r]);r<o;r++)h.appendChild(t[r]);h.normalize()}},re=(e,t,i,s,a,c,r,o,h,T)=>{var S;let g=Array.from(e.childNodes),_=0,{wordDelimiter:A,reduceWhiteSpace:B=!0,prepareText:q}=t,V=e.getBoundingClientRect(),k=V,z=!B&&window.getComputedStyle(e).whiteSpace.substring(0,3)==="pre",y=0,b=i.collection,l,f,R,n,m,v,O,d,p,W,C,E,N,j,w,u,L,x;for(typeof A=="object"?(R=A.delimiter||A,f=A.replaceWith||""):f=A===""?"":A||" ",l=f!==" ";_<g.length;_++)if(n=g[_],n.nodeType===3){for(w=n.textContent||"",B?w=w.replace(de," "):z&&(w=w.replace(/\n/g,f+`
`)),q&&(w=q(w,e)),n.textContent=w,m=f||R?w.split(R||f):w.match(o)||Q,L=m[m.length-1],d=l?L.slice(-1)===" ":!L,L||m.pop(),k=V,O=l?m[0].charAt(0)===" ":!m[0],O&&F(" ",e,n),m[0]||m.shift(),ie(m,h),c&&T||(n.textContent=""),p=1;p<=m.length;p++)if(u=m[p-1],!B&&z&&u.charAt(0)===`
`&&((S=n.previousSibling)==null||S.remove(),F(document.createElement("br"),e,n),u=u.slice(1)),!B&&u==="")F(f,e,n);else if(u===" ")e.insertBefore(document.createTextNode(" "),n);else{if(l&&u.charAt(0)===" "&&F(" ",e,n),y&&p===1&&!O&&b.indexOf(y.parentNode)>-1?(v=b[b.length-1],v.appendChild(document.createTextNode(s?"":u))):(v=i(s?"":u),F(v,e,n),y&&p===1&&!O&&v.insertBefore(y,v.firstChild)),s)for(C=Z?ie([...Z.segment(u)].map(I=>I.segment),h):u.match(o)||Q,x=0;x<C.length;x++)v.appendChild(C[x]===" "?document.createTextNode(" "):s(C[x]));if(c&&T){if(w=n.textContent=w.substring(u.length+1,w.length),W=v.getBoundingClientRect(),W.top>k.top&&W.left<=k.left){for(E=e.cloneNode(),N=e.childNodes[0];N&&N!==v;)j=N,N=N.nextSibling,E.appendChild(j);e.parentNode.insertBefore(E,e),a&&se(E)}k=W}(p<m.length||d)&&F(p>=m.length?" ":l&&u.slice(-1)===" "?" "+f:f,e,n)}e.removeChild(n),y=0}else n.nodeType===1&&(r&&r.indexOf(n)>-1?(b.indexOf(n.previousSibling)>-1&&b[b.length-1].appendChild(n),y=n):(re(n,t,i,s,a,c,r,o,h,!0),y=0),a&&se(n))};const ne=class le{constructor(t,i){this.isSplit=!1,oe(),this.elements=$(t),this.chars=[],this.words=[],this.lines=[],this.masks=[],this.vars=i,this.elements.forEach(r=>{var o;i.overwrite!==!1&&((o=r[Y])==null||o._data.orig.filter(({element:h})=>h===r).forEach(te)),r[Y]=this}),this._split=()=>this.isSplit&&this.split(this.vars);let s=[],a,c=()=>{let r=s.length,o;for(;r--;){o=s[r];let h=o.element.offsetWidth;if(h!==o.width){o.width=h,this._split();return}}};this._data={orig:s,obs:typeof ResizeObserver<"u"&&new ResizeObserver(()=>{clearTimeout(a),a=setTimeout(c,200)})},J(this),this.split(i)}split(t){return(this._ctx||ae).add(()=>{this.isSplit&&this.revert(),this.vars=t=t||this.vars||{};let{type:i="chars,words,lines",aria:s="auto",deepSlice:a=!0,smartWrap:c,onSplit:r,autoSplit:o=!1,specialChars:h,mask:T}=this.vars,S=i.indexOf("lines")>-1,g=i.indexOf("chars")>-1,_=i.indexOf("words")>-1,A=g&&!_&&!S,B=h&&("push"in h?new RegExp("(?:"+h.join("|")+")","gu"):h),q=B?new RegExp(B.source+"|"+ee.source,"gu"):ee,V=!!t.ignore&&$(t.ignore),{orig:k,animTime:z,obs:y}=this._data,b;(g||_||S)&&(this.elements.forEach((l,f)=>{k[f]={element:l,html:l.innerHTML,ariaL:l.getAttribute("aria-label"),ariaH:l.getAttribute("aria-hidden")},s==="auto"?l.setAttribute("aria-label",(l.textContent||"").trim()):s==="hidden"&&l.setAttribute("aria-hidden","true");let R=[],n=[],m=[],v=g?U("char",t,R):null,O=U("word",t,n),d,p,W,C;if(re(l,t,O,v,A,a&&(S||A),V,q,B,!1),S){let E=H(l.childNodes),N=pe(l,E,t,m),j,w=[],u=0,L=E.map(D=>D.nodeType===1?D.getBoundingClientRect():G),x=G,I;for(d=0;d<E.length;d++)j=E[d],j.nodeType===1&&(j.nodeName==="BR"?((!d||E[d-1].nodeName!=="BR")&&(w.push(j),N(u,d+1)),u=d+1,x=he(L,d)):(I=L[d],d&&I.top>x.top&&I.left<x.left+x.width-1&&(N(u,d),u=d),x=I));u<d&&N(u,d),w.forEach(D=>{var X;return(X=D.parentNode)==null?void 0:X.removeChild(D)})}if(!_){for(d=0;d<n.length;d++)if(p=n[d],g||!p.nextSibling||p.nextSibling.nodeType!==3)if(c&&!S){for(W=document.createElement("span"),W.style.whiteSpace="nowrap";p.firstChild;)W.appendChild(p.firstChild);p.replaceWith(W)}else p.replaceWith(...p.childNodes);else C=p.nextSibling,C&&C.nodeType===3&&(C.textContent=(p.textContent||"")+(C.textContent||""),p.remove());n.length=0,l.normalize()}this.lines.push(...m),this.words.push(...n),this.chars.push(...R)}),T&&this[T]&&this.masks.push(...this[T].map(l=>{let f=l.cloneNode();return l.replaceWith(f),f.appendChild(l),l.className&&(f.className=l.className.trim().split(" ").map(R=>R+"-mask").join(" ")),f.style.overflow="clip",f}))),this.isSplit=!0,P&&S&&o&&P.addEventListener("loadingdone",this._split),(b=r&&r(this))&&b.totalTime&&(this._data.anim=z?b.totalTime(z):b),S&&o&&this.elements.forEach((l,f)=>{k[f].width=l.offsetWidth,y&&y.observe(l)})}),this}kill(){let{obs:t}=this._data;t&&t.disconnect(),P?.removeEventListener("loadingdone",this._split)}revert(){var t,i;if(this.isSplit){let{orig:s,anim:a}=this._data;this.kill(),s.forEach(te),this.chars.length=this.words.length=this.lines.length=s.length=this.masks.length=0,this.isSplit=!1,a&&(this._data.animTime=a.totalTime(),a.revert()),(i=(t=this.vars).onRevert)==null||i.call(t,this)}return this}static create(t,i){return new le(t,i)}static register(t){M=M||t||window.gsap,M&&(H=M.utils.toArray,J=M.core.context||J),!K&&window.innerWidth>0&&(P=document.fonts,K=!0)}};ne.version="3.15.0";let ue=ne;export{ue as SplitText,ue as default};
