842.js 8.9 KB

12
  1. (globalThis.webpackChunksakurairo_scripts=globalThis.webpackChunksakurairo_scripts||[]).push([[842],{8842:(t,s,e)=>{function i(){return i=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var e=arguments[s];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},i.apply(this,arguments)}e.r(s),e.d(s,{default:()=>a});const n={strings:["These are the default values...","You know what you should do?","Use your own!","Have a great day!"],stringsElement:null,typeSpeed:0,startDelay:0,backSpeed:0,smartBackspace:!0,shuffle:!1,backDelay:700,fadeOut:!1,fadeOutClass:"typed-fade-out",fadeOutDelay:500,loop:!1,loopCount:1/0,showCursor:!0,cursorChar:"|",autoInsertCss:!0,attr:null,bindInputFocusEvents:!1,contentType:"html",onBegin:t=>{},onComplete:t=>{},preStringTyped:(t,s)=>{},onStringTyped:(t,s)=>{},onLastStringBackspaced:t=>{},onTypingPaused:(t,s)=>{},onTypingResumed:(t,s)=>{},onReset:t=>{},onStop:(t,s)=>{},onStart:(t,s)=>{},onDestroy:t=>{}};let r=new class{load(t,s,e){if(t.el="string"==typeof e?document.querySelector(e):e,t.options=i({},n,s),t.isInput="input"===t.el.tagName.toLowerCase(),t.attr=t.options.attr,t.bindInputFocusEvents=t.options.bindInputFocusEvents,t.showCursor=!t.isInput&&t.options.showCursor,t.cursorChar=t.options.cursorChar,t.cursorBlinking=!0,t.elContent=t.attr?t.el.getAttribute(t.attr):t.el.textContent,t.contentType=t.options.contentType,t.typeSpeed=t.options.typeSpeed,t.startDelay=t.options.startDelay,t.backSpeed=t.options.backSpeed,t.smartBackspace=t.options.smartBackspace,t.backDelay=t.options.backDelay,t.fadeOut=t.options.fadeOut,t.fadeOutClass=t.options.fadeOutClass,t.fadeOutDelay=t.options.fadeOutDelay,t.isPaused=!1,t.strings=t.options.strings.map((t=>t.trim())),t.stringsElement="string"==typeof t.options.stringsElement?document.querySelector(t.options.stringsElement):t.options.stringsElement,t.stringsElement){t.strings=[],t.stringsElement.style.cssText="clip: rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px;";const s=Array.prototype.slice.apply(t.stringsElement.children),e=s.length;if(e)for(let i=0;i<e;i+=1)t.strings.push(s[i].innerHTML.trim())}t.strPos=0,t.arrayPos=0,t.stopNum=0,t.loop=t.options.loop,t.loopCount=t.options.loopCount,t.curLoop=0,t.shuffle=t.options.shuffle,t.sequence=[],t.pause={status:!1,typewrite:!0,curString:"",curStrPos:0},t.typingComplete=!1;for(let s in t.strings)t.sequence[s]=s;t.currentElContent=this.getCurrentElContent(t),t.autoInsertCss=t.options.autoInsertCss,this.appendAnimationCss(t)}getCurrentElContent(t){let s="";return s=t.attr?t.el.getAttribute(t.attr):t.isInput?t.el.value:"html"===t.contentType?t.el.innerHTML:t.el.textContent,s}appendAnimationCss(t){const s="data-typed-js-css";if(!t.autoInsertCss)return;if(!t.showCursor&&!t.fadeOut)return;if(document.querySelector(`[${s}]`))return;let e=document.createElement("style");e.type="text/css",e.setAttribute(s,!0);let i="";t.showCursor&&(i+="\n .typed-cursor{\n opacity: 1;\n }\n .typed-cursor.typed-cursor--blink{\n animation: typedjsBlink 0.7s infinite;\n -webkit-animation: typedjsBlink 0.7s infinite;\n animation: typedjsBlink 0.7s infinite;\n }\n @keyframes typedjsBlink{\n 50% { opacity: 0.0; }\n }\n @-webkit-keyframes typedjsBlink{\n 0% { opacity: 1; }\n 50% { opacity: 0.0; }\n 100% { opacity: 1; }\n }\n "),t.fadeOut&&(i+="\n .typed-fade-out{\n opacity: 0;\n transition: opacity .25s;\n }\n .typed-cursor.typed-cursor--blink.typed-fade-out{\n -webkit-animation: 0;\n animation: 0;\n }\n "),0!==e.length&&(e.innerHTML=i,document.body.appendChild(e))}},o=new class{typeHtmlChars(t,s,e){if("html"!==e.contentType)return s;const i=t.substr(s).charAt(0);if("<"===i||"&"===i){let e="";for(e="<"===i?">":";";t.substr(s+1).charAt(0)!==e&&!(1+ ++s>t.length););s++}return s}backSpaceHtmlChars(t,s,e){if("html"!==e.contentType)return s;const i=t.substr(s).charAt(0);if(">"===i||";"===i){let e="";for(e=">"===i?"<":"&";t.substr(s-1).charAt(0)!==e&&!(--s<0););s--}return s}};class a{constructor(t,s){r.load(this,s,t),this.begin()}toggle(){this.pause.status?this.start():this.stop()}stop(){this.typingComplete||this.pause.status||(this.toggleBlinking(!0),this.pause.status=!0,this.options.onStop(this.arrayPos,this))}start(){this.typingComplete||this.pause.status&&(this.pause.status=!1,this.pause.typewrite?this.typewrite(this.pause.curString,this.pause.curStrPos):this.backspace(this.pause.curString,this.pause.curStrPos),this.options.onStart(this.arrayPos,this))}destroy(){this.reset(!1),this.options.onDestroy(this)}reset(t=!0){clearInterval(this.timeout),this.replaceText(""),this.cursor&&this.cursor.parentNode&&(this.cursor.parentNode.removeChild(this.cursor),this.cursor=null),this.strPos=0,this.arrayPos=0,this.curLoop=0,t&&(this.insertCursor(),this.options.onReset(this),this.begin())}begin(){this.options.onBegin(this),this.typingComplete=!1,this.shuffleStringsIfNeeded(this),this.insertCursor(),this.bindInputFocusEvents&&this.bindFocusEvents(),this.timeout=setTimeout((()=>{this.currentElContent&&0!==this.currentElContent.length?this.backspace(this.currentElContent,this.currentElContent.length):this.typewrite(this.strings[this.sequence[this.arrayPos]],this.strPos)}),this.startDelay)}typewrite(t,s){this.fadeOut&&this.el.classList.contains(this.fadeOutClass)&&(this.el.classList.remove(this.fadeOutClass),this.cursor&&this.cursor.classList.remove(this.fadeOutClass));const e=this.humanizer(this.typeSpeed);let i=1;!0!==this.pause.status?this.timeout=setTimeout((()=>{s=o.typeHtmlChars(t,s,this);let e=0,n=t.substr(s);if("^"===n.charAt(0)&&/^\^\d+/.test(n)){let i=1;n=/\d+/.exec(n)[0],i+=n.length,e=parseInt(n),this.temporaryPause=!0,this.options.onTypingPaused(this.arrayPos,this),t=t.substring(0,s)+t.substring(s+i),this.toggleBlinking(!0)}if("`"===n.charAt(0)){for(;"`"!==t.substr(s+i).charAt(0)&&(i++,!(s+i>t.length)););const e=t.substring(0,s),n=t.substring(e.length+1,s+i),r=t.substring(s+i+1);t=e+n+r,i--}this.timeout=setTimeout((()=>{this.toggleBlinking(!1),s>=t.length?this.doneTyping(t,s):this.keepTyping(t,s,i),this.temporaryPause&&(this.temporaryPause=!1,this.options.onTypingResumed(this.arrayPos,this))}),e)}),e):this.setPauseStatus(t,s,!0)}keepTyping(t,s,e){0===s&&(this.toggleBlinking(!1),this.options.preStringTyped(this.arrayPos,this));const i=t.substr(0,s+=e);this.replaceText(i),this.typewrite(t,s)}doneTyping(t,s){this.options.onStringTyped(this.arrayPos,this),this.toggleBlinking(!0),this.arrayPos===this.strings.length-1&&(this.complete(),!1===this.loop||this.curLoop===this.loopCount)||(this.timeout=setTimeout((()=>{this.backspace(t,s)}),this.backDelay))}backspace(t,s){if(!0===this.pause.status)return void this.setPauseStatus(t,s,!1);if(this.fadeOut)return this.initFadeOut();this.toggleBlinking(!1);const e=this.humanizer(this.backSpeed);this.timeout=setTimeout((()=>{s=o.backSpaceHtmlChars(t,s,this);const e=t.substr(0,s);if(this.replaceText(e),this.smartBackspace){let t=this.strings[this.arrayPos+1];this.stopNum=t&&e===t.substr(0,s)?s:0}s>this.stopNum?(s--,this.backspace(t,s)):s<=this.stopNum&&(this.arrayPos++,this.arrayPos===this.strings.length?(this.arrayPos=0,this.options.onLastStringBackspaced(),this.shuffleStringsIfNeeded(),this.begin()):this.typewrite(this.strings[this.sequence[this.arrayPos]],s))}),e)}complete(){this.options.onComplete(this),this.loop?this.curLoop++:this.typingComplete=!0}setPauseStatus(t,s,e){this.pause.typewrite=e,this.pause.curString=t,this.pause.curStrPos=s}toggleBlinking(t){this.cursor&&(this.pause.status||this.cursorBlinking!==t&&(this.cursorBlinking=t,t?this.cursor.classList.add("typed-cursor--blink"):this.cursor.classList.remove("typed-cursor--blink")))}humanizer(t){return Math.round(Math.random()*t/2)+t}shuffleStringsIfNeeded(){this.shuffle&&(this.sequence=this.sequence.sort((()=>Math.random()-.5)))}initFadeOut(){return this.el.className+=` ${this.fadeOutClass}`,this.cursor&&(this.cursor.className+=` ${this.fadeOutClass}`),setTimeout((()=>{this.arrayPos++,this.replaceText(""),this.strings.length>this.arrayPos?this.typewrite(this.strings[this.sequence[this.arrayPos]],0):(this.typewrite(this.strings[0],0),this.arrayPos=0)}),this.fadeOutDelay)}replaceText(t){this.attr?this.el.setAttribute(this.attr,t):this.isInput?this.el.value=t:"html"===this.contentType?this.el.innerHTML=t:this.el.textContent=t}bindFocusEvents(){this.isInput&&(this.el.addEventListener("focus",(t=>{this.stop()})),this.el.addEventListener("blur",(t=>{this.el.value&&0!==this.el.value.length||this.start()})))}insertCursor(){this.showCursor&&(this.cursor||(this.cursor=document.createElement("span"),this.cursor.className="typed-cursor",this.cursor.setAttribute("aria-hidden",!0),this.cursor.innerHTML=this.cursorChar,this.el.parentNode&&this.el.parentNode.insertBefore(this.cursor,this.el.nextSibling)))}}}}]);
  2. //# sourceMappingURL=842.js.map