PageSourceSearch

https://tumichael.com/en/assets/js/vendor-typewriter.js

js tumichael.com collected 2026-10-04 07:02:58 UTC 3,462 bytes, 4 lines download raw bytes

1import{a as l}from"./vendor-idle.js";import{b as a}from"./vendor-device.js";class h extends HTMLElement{timer=null;observer=null;isVisible=!0;wordIndex=0;charIndex=0;isDeleting=!1;words=[];unbindResume=null;textEl=null;connectedCallback(){if(this.hasAttribute("data-typewriter-ready")){this.textEl=this.querySelector(".tana-typewriter-text"),this.resume();return}if(this.setAttribute("data-typewriter-ready","true"),a()||(this.parseWords(),this.words.length<=1))return;this.classList.add("tana-typewriter","text-ghost");const t=this.words.reduce((s,i)=>s.length>=i.length?s:i,""),r=this.words[0]||"";this.style.display="inline-grid",this.style.gridTemplateColumns="max-content",this.style.gridTemplateRows="1fr",this.style.verticalAlign="baseline",this.style.textAlign="left",this.innerHTML=`
2      <span class="tana-typewriter-sizer" aria-hidden="true" style="grid-column: 1 / 2; grid-row: 1 / 2; visibility: hidden; opacity: 0; pointer-events: none; user-select: none; white-space: nowrap; line-height: inherit;">${t}&nbsp;
2</span>
3      <span class="tana-typewriter-text" style="grid-column: 1 / 2; grid-row: 1 / 2; white-space: nowrap; line-height: inherit;">${r}</span>
4    `,this.textEl=this.querySelector(".tana-typewriter-text"),this.charIndex=r.length,this.isDeleting=!0,typeof IntersectionObserver<"u"&&(this.observer=new IntersectionObserver(s=>{const i=s[0];i&&(i.isIntersecting?(this.isVisible=!0,this.timer||this.resume()):(this.isVisible=!1,this.pause()))},{threshold:.1}),this.observer.observe(this)),this.unbindResume=l(()=>{this.isVisible&&this.resume()},()=>{this.pause()},300);const e=parseInt(this.getAttribute("initial-delay")||"2200",10);this.timer=window.setTimeout(()=>this.loop(),e)}disconnectedCallback(){this.pause(),this.unbindResume?.(),this.unbindResume=null,this.observer&&(this.observer.disconnect(),this.observer=null)}pause(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}resume(){this.timer===null&&this.words.length>1&&(this.timer=window.setTimeout(()=>this.loop(),300))}parseWords(){const t=(this.getAttribute("words")||"").trim();if(!t){const e=this.textContent?.replace(/^[\[\s"']+|[\]\s"']+$/g,"").trim();e&&(this.words=[e]);return}if(t.startsWith("[")&&t.endsWith("]"))try{const e=t.replace(/'/g,'"'),s=JSON.parse(e);if(Array.isArray(s)&&s.length>0){this.words=s.map(i=>String(i).replace(/^[\[\s"']+|[\]\s"']+$/g,"").trim()).filter(Boolean);return}}catch{}const r=t.includes("|")?"|":",";this.words=t.split(r).map(e=>e.replace(/^[\[\s"']+|[\]\s"']+$/g,"").trim()).filter(Boolean)}loop(){if(!this.isConnected||!this.words.length||!this.isVisible){this.timer=null;return}const t=this.words[this.wordIndex];if(!t){this.timer=null;return}const r=parseInt(this.getAttribute("speed")||"80",10),e=parseInt(this.getAttribute("delete-speed")||"40",10),s=parseInt(this.getAttribute("delay")||"2200",10),i=this.textEl||this;this.isDeleting?(i.textContent=t.substring(0,this.charIndex-1),this.charIndex--):(i.textContent=t.substring(0,this.charIndex+1),this.charIndex++);let n=this.isDeleting?e:r+(Math.random()*24-12);!this.isDeleting&&this.charIndex===t.length?(n=s,this.isDeleting=!0):this.isDeleting&&this.charIndex===0&&(this.isDeleting=!1,this.wordIndex=(this.wordIndex+1)%this.words.length,n=300),this.timer=window.setTimeout(()=>this.loop(),Math.max(20,Math.round(n)))}}typeof customElements<"u"&&!customElements.get("tana-typewriter")&&customElements.define("tana-typewriter",h);export{h as TanaTypewriter};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.