"use strict";var d=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var W=(e,t)=>{for(var n in t)d(e,n,{get:t[n],enumerable:!0})},R=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of P(t))!H.call(e,a)&&a!==n&&d(e,a,{get:()=>t[a],enumerable:!(r=L(t,a))||r.enumerable});return e};var N=e=>R(d({},"__esModule",{value:!0}),e);var J={};W(J,{default:()=>X,glyphCycle:()=>g});module.exports=N(J);var k=[{name:"typewriter",containerClass:"persona-stream-typewriter",wrap:"char",useCaret:!0},{name:"pop-bubble",bubbleClass:"persona-stream-pop",wrap:"none"},{name:"letter-rise",containerClass:"persona-stream-letter-rise",wrap:"char"},{name:"word-fade",containerClass:"persona-stream-word-fade",wrap:"word"}],f=new Map;for(let e of k)f.set(e.name,e);var A=e=>{f.set(e.name,e)};var D=`
[data-persona-root] .persona-stream-glyph-cycle .persona-stream-char {
  animation: persona-stream-glyph-cycle-fade
    calc(var(--persona-stream-step, 120ms) * 1.5) ease-out both;
}
[data-persona-root] .persona-stream-glyph-cycle .persona-stream-char[data-glyph-cycle-final] {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@keyframes persona-stream-glyph-cycle-fade {
  from { opacity: 0.35; }
  to   { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  [data-persona-root] .persona-stream-glyph-cycle .persona-stream-char {
    animation: none !important;
    opacity: 1 !important;
  }
}
`.trim(),l="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#$%&@",_=10,I=120,u=120,F=.4,B=50,O=e=>{var r;if(!e)return u;let n=((r=e.style.getPropertyValue("--persona-stream-step"))==null?void 0:r.trim()).match(/([\d.]+)\s*ms/);return n?parseFloat(n[1]):u},x=e=>{let t=e.closest(".persona-stream-glyph-cycle"),n=O(t);return I*n/u},p=e=>{let t=l[Math.floor(Math.random()*l.length)];return e&&t===e&&(t=l[(l.indexOf(t)+1)%l.length]),t},G=e=>{let t=e.closest(".persona-stream-glyph-cycle");if(!t)return;let n=t.querySelectorAll(".persona-stream-char[data-glyph-cycle-final]"),r=!1;for(let a of Array.from(n)){if(a===e){r=!0;continue}r&&Math.random()<F&&(a.textContent=p())}},S=new WeakMap,T=25,C=.5,U=6,M=.25,w=new WeakMap,E=new WeakMap,$=(e,t)=>{var a;if(!e)return T*C;let n=w.get(e);w.set(e,t);let r=(a=E.get(e))!=null?a:T;if(n!==void 0){let s=t-n;s>1&&(r=r*(1-M)+s*M,E.set(e,r))}return Math.max(U,r*C)},i=new Map,j=e=>{var n;let t=e.closest("[data-message-id]");return(n=t==null?void 0:t.dataset.messageId)!=null?n:null},K=e=>{var t;e&&i.set(e,((t=i.get(e))!=null?t:0)+1)},V=e=>{var n;if(!e)return;let t=(n=i.get(e))!=null?n:0;t<=1?i.delete(e):i.set(e,t-1)},v=e=>{var h;if(e.dataset.glyphCycleScheduled==="true")return;let t=(h=e.textContent)!=null?h:"";if(!t||/\s/.test(t))return;e.dataset.glyphCycleScheduled="true",e.dataset.glyphCycleFinal=t,e.setAttribute("data-preserve-runtime","stream-glyph-cycle"),e.textContent=p();let n=j(e);n&&(e.dataset.glyphCycleMessageId=n),K(n);let r=e.closest(".persona-stream-glyph-cycle"),a=Date.now(),s=$(r,a),c=x(e),m=_*c,o=a+m;if(r){let y=S.get(r);y!==void 0&&(o=Math.max(o,y)),S.set(r,o+s)}Y(e,t,o)},Y=(e,t,n)=>{var c;if(e.dataset.glyphCycleStarted==="true")return;e.dataset.glyphCycleStarted="true";let r=x(e),a=(c=e.textContent)!=null?c:void 0,s=()=>{var o;if(!e.isConnected)return;if(Date.now()>=n){e.textContent=t,e.removeAttribute("data-preserve-runtime"),delete e.dataset.glyphCycleStarted,delete e.dataset.glyphCycleFinal,V((o=e.dataset.glyphCycleMessageId)!=null?o:null),delete e.dataset.glyphCycleMessageId;return}let m=p(a);e.textContent=m,a=m,G(e),setTimeout(s,r)};setTimeout(s,r)},b=e=>{var n;let t=(n=e.querySelectorAll)==null?void 0:n.call(e,".persona-stream-glyph-cycle .persona-stream-char:not([data-glyph-cycle-scheduled])");if(t)for(let r of Array.from(t))v(r)},q=e=>e.nodeType===1,g={name:"glyph-cycle",containerClass:"persona-stream-glyph-cycle",wrap:"char",skipTags:["a","script","style"],styles:D,bufferContent(e){if(e.length<B)return"";let t=0,n=-1,r=0;for(;r<e.length;){if(e[r]==="*"&&e[r+1]==="*"){t+=1,r+=2;continue}/\s/.test(e[r])&&t%2===0&&(n=r),r+=1}return n<0?"":e.slice(0,n)},isAnimating(e){var t;return((t=i.get(e.id))!=null?t:0)>0},onAttach(e){b(e);let t=new MutationObserver(n=>{for(let r of n)for(let a of Array.from(r.addedNodes))q(a)&&(a.classList.contains("persona-stream-char")&&a.closest(".persona-stream-glyph-cycle")?v(a):b(a))});return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}};A(g);var X=g;0&&(module.exports={glyphCycle});
