import{r as e,j as t}from"./vendor-react-Dp9pL_Wn.js";const n="undefined"!=typeof Intl&&"Segmenter"in Intl?new Intl.Segmenter(void 0,{granularity:"grapheme"}):null;const r=e.memo(({text:r})=>{const[u,a]=e.useState(r),[s,o]=e.useState(0),[c,m]=e.useState(!1),l=e.useRef(null),i=e.useRef(r),f=e.useMemo(()=>function(e){return n?Array.from(n.segment(e),e=>e.segment):Array.from(e)}(u),[u]);return e.useEffect(()=>{i.current=r,r!==u&&m(!0)},[r]),e.useEffect(()=>{const e=f.length,t=c?11:16,n=s;let r=null;const u=s=>{r??=s;const f=Math.floor((s-r)/t),g=c?Math.max(0,n-f):Math.min(e,f);o(g),(c?g>0:g<e)?l.current=requestAnimationFrame(u):c&&(a(i.current),m(!1))};return l.current=requestAnimationFrame(u),()=>{null!==l.current&&cancelAnimationFrame(l.current)}},[u,f.length,c]),t.jsx("span",{"aria-hidden":!0,children:f.slice(0,s).join("")})});export{r as TypewriterText};
