Comparing version 8.0.0-rc.2 to 8.0.0-rc.3
// TypeIt by Alex MacArthur - https://typeitjs.com | ||
const e=[null,null,{}];var t=(e,t)=>Object.assign({},e,t),n=e=>Array.from(e),r=e=>{let t=document.implementation.createHTMLDocument();return t.body.innerHTML=e,t.body};const o=(e,t=null,r=!1)=>{let i=n(e.childNodes).flatMap(e=>{return 3===(t=e).nodeType||"BR"===t.tagName?e:o(e);var t});return t&&(i=i.filter(e=>!t.contains(e))),r?i.reverse():i},i=(e,t=null)=>({node:t,content:e});function s(e){let t=r(e);return o(t).flatMap(e=>e.nodeValue?n(e.nodeValue).map(t=>i(t,e)):i(e))}function u(e,t=!0){return t?s(e):n(e).map(e=>i(e))}var l=e=>document.createElement(e),c=e=>document.createTextNode(e),a=(e,t="")=>{let n=l("style");n.id=t,n.appendChild(c(e)),document.head.appendChild(n)},f=e=>Array.isArray(e);const h=e=>Number.isInteger(e),d=(e,t=document,n=!1)=>t["querySelector"+(n?"All":"")](e),m={started:!1,completed:!1,frozen:!1,destroyed:!1},v={breakLines:!0,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,html:!0,lifeLike:!0,loop:!1,loopDelay:750,nextStringDelay:750,speed:100,startDelay:250,startDelete:!1,strings:[],waitUntilVisible:!1,beforeString:()=>{},afterString:()=>{},beforeStep:()=>{},afterStep:()=>{},afterComplete:()=>{}},p=(e,t,n="START")=>{let r=new RegExp("END","i").test(n),i=d(".ti-cursor",t),s=e?d(e,t):t,u=o(s,i,!0),l=u[0],c=u[u.length-1],a=r&&!e?0:o(t,i,!0).findIndex(e=>e.isSameNode(r?l:c));return r&&a--,a+1};var y=e=>(f(e)||(e=[e/2,e/2]),e),g=(e,t)=>Math.abs(Math.random()*(e+t-(e-t))+(e-t));let P=e=>e/2;var b=e=>"value"in e;const S=e=>"function"==typeof e?e():e;var N=e=>"BODY"===e.tagName;const T=(e,t)=>{let r=n(d("*",t,!0));return[t].concat(r.reverse()).find(t=>t.cloneNode().isEqualNode(e.cloneNode()))},M=(e,t,n,r)=>{let i=t.content instanceof HTMLElement,s=t.node,u=null==s?void 0:s.parentNode,l=i?t.content:c(t.content);if(b(e))return void(e.value=""+e.value+t.content);if(!i&&u&&!N(u)){let r=T(u,e);if(r&&((e,t)=>{let n=e.nextSibling;return!n||n.isEqualNode(t)})(r,n))e=r;else{l=u.cloneNode(),l.appendChild(c(t.content));let n=u.parentNode,r=n.cloneNode();if(!N(n)){let t=T(r,e);for(;!t&&!N(n);){let o=r;o.innerHTML=l.outerHTML,l=o,n=n.parentNode,r=n.cloneNode(),t=T(r,e)}e=t||e}}}let a=o(e,n,!0)[r-1],f=a?a.parentNode:e;f.insertBefore(l,f.contains(n)?n:null)};var L=e=>e&&e.remove();const j={"font-family":"","font-weight":"","font-size":"","font-style":"","line-height":"",color:"","margin-left":"-.125em","margin-right":".125em"};function w(e,t,n){if(!e.s){if(n instanceof D){if(!n.s)return void(n.o=w.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(w.bind(null,e,t),w.bind(null,e,2));e.s=t,e.v=n;const r=e.o;r&&r(e)}}const D=function(){function e(){}return e.prototype.then=function(t,n){const r=new e,o=this.s;if(o){const e=1&o?t:n;if(e){try{w(r,1,e(this.v))}catch(e){w(r,2,e)}return r}return this}return this.o=function(e){try{const o=e.v;1&e.s?w(r,1,t?t(o):o):n?w(r,1,n(o)):w(r,2,o)}catch(e){w(r,2,e)}},r},e}();function E(e){return e instanceof D&&1&e.s}function x(e,t,n){var r,o,i=-1;return function s(u){try{for(;++i<e.length&&(!n||!n());)if((u=t(i))&&u.then){if(!E(u))return void u.then(s,o||(o=w.bind(null,r=new D,2)));u=u.v}r?w(r,1,u):r=u}catch(e){w(r||(r=new D),2,e)}}(),r}function k(e,t,n){for(var r;;){var o=e();if(E(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=n();if(i&&i.then){if(!E(i)){r=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!E(s)){r=2;break}}}var u=new D,l=w.bind(null,u,2);return(0===r?o.then(a):1===r?i.then(c):s.then(f)).then(void 0,l),u;function c(r){i=r;do{if(t&&(s=t())&&s.then&&!E(s))return void s.then(f).then(void 0,l);if(!(o=e())||E(o)&&!o.v)return void w(u,1,i);if(o.then)return void o.then(a).then(void 0,l);E(i=n())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,l)}function a(e){e?(i=n())&&i.then?i.then(c).then(void 0,l):c(i):w(u,1,i)}function f(){(o=e())?o.then?o.then(a).then(void 0,l):a(o):w(u,1,i)}}function C(c,N={}){const T=this,w=function(e,t){try{return Promise.resolve(function(e,t,n){try{return Promise.resolve(new Promise(r=>{n.push(setTimeout(function(){try{return Promise.resolve(e()).then(function(){r()})}catch(e){return Promise.reject(e)}},t))}))}catch(e){return Promise.reject(e)}}(e,t,J))}catch(e){return Promise.reject(e)}},D=()=>b(F),E=e=>function(e){let{speed:t,deleteSpeed:n,lifeLike:r}=e;return n=null!==n?n:t/3,r?[g(t,P(t)),g(n,P(n))]:[t,n]}(Z)[e],C=(e,t=0)=>e?E(t):0,H=(e,t)=>(_.add(e),((e={})=>{let t=e.delay;t&&_.add([[O,t]])})(t),this),z=()=>(e=>b(e)?n(e.value):o(e,d(".ti-cursor",e),!0))(F),R=(e={})=>[[U,e],[U,Z]],A=e=>{let t=Z.nextStringDelay;_.add([[O,t[0]],...e,[O,t[1]]])},B=e=>{ee&&(te.classList.toggle("disabled",e),te.classList.toggle("with-delay",!e))},I=function(){try{let e;X.started=!0;let t,n=_.getItems();const r=function(r,o){try{var i=function(){function r(e){return X.completed=!0,Promise.resolve(Z.afterComplete(...t)).then(function(){if(!Z.loop)throw"";let e=Z.loopDelay;w(function(){try{return Promise.resolve(function(e){try{function t(t){return _.reset(),_.set(0,[O,e,{}]),Promise.resolve(Y({num:null})).then(function(){})}return Promise.resolve(K?Promise.resolve(V({value:K})).then(t):t())}catch(e){return Promise.reject(e)}}(e[0])).then(function(){I()})}catch(e){return Promise.reject(e)}},e[1])})}const o=x(n,function(e){if(X.frozen||X.destroyed)throw"";let r=n[e],o=r[2];return t=[r,T],o.freezeCursor&&B(!0),Promise.resolve(Z.beforeStep(...t)).then(function(){return Promise.resolve(r[0].call(T,r[1],o)).then(function(){return Promise.resolve(Z.afterStep(...t)).then(function(){_.setMeta(e,{executed:!0}),B(!1)})})})},function(){return e});return o&&o.then?o.then(r):r()}()}catch(e){return}return i&&i.then?i.then(void 0,function(){}):i}();return Promise.resolve(r&&r.then?r.then(function(t){return e?t:T}):e?r:T)}catch(e){return Promise.reject(e)}},O=(e=0)=>w(()=>{},e),V=function({value:e,to:t="START",instant:n=!1}){try{let r=(({el:e,move:t,cursorPos:n,to:r})=>h(t)?-1*t:p(t,e,r)-n)({el:F,move:e,cursorPos:K,to:t}),o=()=>{K+=r<0?-1:1,((e,t,n,r)=>{let o=t[Math.min(r,t.length)-1];(e=(null==o?void 0:o.parentNode)||e).insertBefore(n,o||null)})(F,z(),te,K)};return Promise.resolve(w(function(){try{let e=0;const t=k(function(){return e<Math.abs(r)},function(){return e++},function(){return n?void o():Promise.resolve(w(o,E(0))).then(function(e){})});return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},C(n))).then(function(){})}catch(e){return Promise.reject(e)}},q=({chars:e,instant:t,silent:n})=>w(function(){try{function r(r){function i(){return n?void 0:Promise.resolve(Z.afterString(e)).then(function(e){})}const s=x(e,function(n){return t?void o(e[n]):Promise.resolve(w(()=>{o(e[n])},E(0))).then(function(e){})});return s&&s.then?s.then(i):i()}const o=e=>M(F,e,te,K);return Promise.resolve(n?r():Promise.resolve(Z.beforeString(e)).then(r))}catch(e){return Promise.reject(e)}},C(t)),U=function(e){try{return Z=t(Z,e),Promise.resolve()}catch(e){return Promise.reject(e)}},Q=function(){try{return D()?(F.value="",Promise.resolve()):(z().forEach(e=>{L(e)}),Promise.resolve())}catch(e){return Promise.reject(e)}},Y=function({num:e=null,instant:t=!1,to:n="START"}){try{const r=e=>h(e)?e:p(e,F,n);return Promise.resolve(w(function(){try{let n=r(e);const o=()=>{let e=z();var t;e.length&&(D()?F.value=F.value.slice(0,-1):(L(e[K]),t=te,d("*",F,!0).forEach(e=>{if(!e.innerHTML&&"BR"!==e.tagName&&!e.isSameNode(t)){let t=e;for(;1===t.parentElement.childNodes.length;)t=t.parentElement;L(t)}})))};let i=0;const s=k(function(){return i<n},function(){return i++},function(){return t?void o():Promise.resolve(w(o,E(1))).then(function(e){})});return Promise.resolve(s&&s.then?s.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},C(t,1))).then(function(){const t=function(){if(null===e&&z().length-1>0)return Promise.resolve(Y({num:null})).then(function(){})}();if(t&&t.then)return t.then(function(){})})}catch(e){return Promise.reject(e)}};this.break=function(e){const t=i(l("BR"));return H([[q,{chars:[t],silent:!0}]],e)},this.delete=function(e=null,t={}){e=S(e);let n=R(t),r=e,{instant:o,to:i}=t;return H([n[0],[Y,{num:r,instant:o,to:i},W],n[1]],t)},this.empty=function(e={}){return H([[Q]],e)},this.exec=function(e,t){let n=R(t);return H([n[0],[e,null],n[1]],t)},this.move=function(e,t={}){e=S(e);let n=R(t),{instant:r,to:o}=t;return H([n[0],[V,{value:null===e?"":e,to:o,instant:r},W],n[1]],t)},this.options=function(e){return e=S(e),H([[U,e]],e)},this.pause=function(e,t={}){return H([[O,S(e)]],t)},this.type=function(e,t={}){e=S(e);let n=R(t),r=u(e,Z.html),{instant:o}=t;return H([n[0],[q,{chars:r,instant:o},W],n[1]],t)},this.is=function(e){return X[e]},this.destroy=function(e=!0){J.forEach(e=>clearTimeout(e)),J=[],S(e)&&L(te),X.destroyed=!0},this.freeze=function(){X.frozen=!0},this.unfreeze=function(){X.frozen=!1,I()},this.reset=function(){!this.is("destroyed")&&this.destroy(),_.reset(),K=0;for(let e in X)X[e]=!1;return F[D()?"value":"innerHTML"]="",this},this.go=function(){return X.started?this:(function(){try{!D()&&F.appendChild(te),ee?(((e,t,n)=>{let r="[data-typeit-id='"+e+"'] .ti-cursor",o=getComputedStyle(n),i=Object.entries(j).reduce((e,[t,n])=>e+" "+t+": var(--ti-"+t+", "+(n||o[t])+");","");a("@keyframes blink-"+e+" { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } "+r+" { display: inline; letter-spacing: -1em; "+i+" animation: blink-"+e+" "+t.cursorSpeed/1e3+"s infinite; } "+r+".with-delay { animation-delay: 500ms; } "+r+".disabled { animation: none; }",e)})($,Z,F),Promise.resolve()):Promise.resolve()}catch(e){return Promise.reject(e)}}(),Z.waitUntilVisible?(((e,t)=>{new IntersectionObserver((n,r)=>{n.forEach(n=>{n.isIntersecting&&(t(),r.unobserve(e))})},{threshold:1}).observe(e)})(F,I.bind(this)),this):(I(),this))},this.getQueue=function(){return _},this.getOptions=function(){return Z},this.getElement=function(){return F};let F="string"==typeof(G=c)?d(G):G;var G;let J=[],K=0,W={freezeCursor:!0},X=t({},m),Z=t(v,N);Z=t(Z,{html:!D()&&Z.html,nextStringDelay:y(Z.nextStringDelay),loopDelay:y(Z.loopDelay)});let $=Math.random().toString().substring(2,9),_=function(n){const r=function(t){return o=o.concat(t.map(t=>e.map((e,n)=>t[n]?t[n]:e))),this};let o=[];return r(n),{add:r,set:function(e,t){o[e]=t},reset:function(){o=o.map(e=>(e[2].executed=!1,e))},getItems:function(){return o.filter(e=>!e[2].executed)},setMeta:function(e,n){o[e][2]=t(o[e][2],n)}}}([[O,Z.startDelay]]);F.dataset.typeitId=$,a("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}");let ee=Z.cursor&&!D(),te=(()=>{if(D())return;let e=l("span");return e.className="ti-cursor",ee?(e.innerHTML=r(Z.cursorChar).innerHTML,e):(e.style.visibility="hidden",e)})();var ne;Z.strings=(e=>{let t=F.innerHTML;return t?(F.innerHTML="",Z.startDelete?(s(t).forEach(e=>{M(F,e,te,K)}),A([[Y,{num:null}]]),e):t.trim().split(/<br(?:\s*?)(?:\/)?>/).concat(e)):e})(f(ne=Z.strings)?ne:[ne]),Z.strings.length&&(()=>{let e=Z.strings.filter(e=>!!e);e.forEach((t,n)=>{let r=u(t,Z.html);if(_.add([[q,{chars:r},W]]),n+1===e.length)return;const o=Z.breakLines?[[q,{chars:[i(l("BR"))]},W]]:[[Y,{num:r.length},W]];A(o)})})()}export{C as default}; | ||
const e=[null,null,{}];var t=(e,t)=>Object.assign({},e,t),n=e=>Array.from(e),r=e=>{let t=document.implementation.createHTMLDocument();return t.body.innerHTML=e,t.body};const o=(e,t=null,r=!1)=>{let i=n(e.childNodes).flatMap(e=>{return 3===(t=e).nodeType||"BR"===t.tagName?e:o(e);var t});return t&&(i=i.filter(e=>!t.contains(e))),r?i.reverse():i},i=(e,t=null)=>({node:t,content:e});function s(e){let t=r(e);return o(t).flatMap(e=>e.nodeValue?n(e.nodeValue).map(t=>i(t,e)):i(e))}function u(e,t=!0){return t?s(e):n(e).map(e=>i(e))}var l=e=>document.createElement(e),c=e=>document.createTextNode(e),a=(e,t="")=>{let n=l("style");n.id=t,n.appendChild(c(e)),document.head.appendChild(n)},f=e=>Array.isArray(e);const h=e=>Number.isInteger(e),d=(e,t=document,n=!1)=>t["querySelector"+(n?"All":"")](e),m={started:!1,completed:!1,frozen:!1,destroyed:!1},v={breakLines:!0,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,html:!0,lifeLike:!0,loop:!1,loopDelay:750,nextStringDelay:750,speed:100,startDelay:250,startDelete:!1,strings:[],waitUntilVisible:!1,beforeString:()=>{},afterString:()=>{},beforeStep:()=>{},afterStep:()=>{},afterComplete:()=>{}};var p=({el:e,move:t,cursorPos:n,to:r})=>h(t)?-1*t:((e,t,n="START")=>{let r=new RegExp("END","i").test(n),i=d(".ti-cursor",t),s=e?d(e,t):t,u=o(s,i,!0),l=u[0],c=u[u.length-1],a=r&&!e?0:o(t,i,!0).findIndex(e=>e.isSameNode(r?l:c));return r&&a--,a+1})(t,e,r)-n,y=e=>(f(e)||(e=[e/2,e/2]),e),g=(e,t)=>Math.abs(Math.random()*(e+t-(e-t))+(e-t));let P=e=>e/2;var b=e=>"value"in e;const S=e=>"function"==typeof e?e():e;var N=e=>"BODY"===e.tagName;const T=(e,t)=>{let r=n(d("*",t,!0));return[t].concat(r.reverse()).find(t=>t.cloneNode().isEqualNode(e.cloneNode()))},M=(e,t,n,r)=>{let i=t.content instanceof HTMLElement,s=t.node,u=null==s?void 0:s.parentNode,l=i?t.content:c(t.content);if(b(e))return void(e.value=""+e.value+t.content);if(!i&&u&&!N(u)){let r=T(u,e);if(r&&((e,t)=>{let n=e.nextSibling;return!n||n.isEqualNode(t)})(r,n))e=r;else{l=u.cloneNode(),l.appendChild(c(t.content));let n=u.parentNode,r=n.cloneNode();if(!N(n)){let t=T(r,e);for(;!t&&!N(n);){let o=r;o.innerHTML=l.outerHTML,l=o,n=n.parentNode,r=n.cloneNode(),t=T(r,e)}e=t||e}}}let a=o(e,n,!0)[r-1],f=a?a.parentNode:e;f.insertBefore(l,f.contains(n)?n:null)};var L=e=>e&&e.remove();const j={"font-family":"","font-weight":"","font-size":"","font-style":"","line-height":"",color:"","margin-left":"-.125em","margin-right":".125em"};function w(e,t,n){if(!e.s){if(n instanceof D){if(!n.s)return void(n.o=w.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(w.bind(null,e,t),w.bind(null,e,2));e.s=t,e.v=n;const r=e.o;r&&r(e)}}const D=function(){function e(){}return e.prototype.then=function(t,n){const r=new e,o=this.s;if(o){const e=1&o?t:n;if(e){try{w(r,1,e(this.v))}catch(e){w(r,2,e)}return r}return this}return this.o=function(e){try{const o=e.v;1&e.s?w(r,1,t?t(o):o):n?w(r,1,n(o)):w(r,2,o)}catch(e){w(r,2,e)}},r},e}();function E(e){return e instanceof D&&1&e.s}function x(e,t,n){var r,o,i=-1;return function s(u){try{for(;++i<e.length&&(!n||!n());)if((u=t(i))&&u.then){if(!E(u))return void u.then(s,o||(o=w.bind(null,r=new D,2)));u=u.v}r?w(r,1,u):r=u}catch(e){w(r||(r=new D),2,e)}}(),r}function k(e,t,n){for(var r;;){var o=e();if(E(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=n();if(i&&i.then){if(!E(i)){r=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!E(s)){r=2;break}}}var u=new D,l=w.bind(null,u,2);return(0===r?o.then(a):1===r?i.then(c):s.then(f)).then(void 0,l),u;function c(r){i=r;do{if(t&&(s=t())&&s.then&&!E(s))return void s.then(f).then(void 0,l);if(!(o=e())||E(o)&&!o.v)return void w(u,1,i);if(o.then)return void o.then(a).then(void 0,l);E(i=n())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,l)}function a(e){e?(i=n())&&i.then?i.then(c).then(void 0,l):c(i):w(u,1,i)}function f(){(o=e())?o.then?o.then(a).then(void 0,l):a(o):w(u,1,i)}}function C(c,N={}){const T=this,w=this,D=function(e,t){try{function n(){return Promise.resolve(function(e,t,n){try{return Promise.resolve(new Promise(r=>{n.push(setTimeout(function(){try{return Promise.resolve(e()).then(function(){r()})}catch(e){return Promise.reject(e)}},t))}))}catch(e){return Promise.reject(e)}}(e,t,K))}const r=function(){if(Z.frozen)return Promise.resolve(new Promise(e=>{T.unfreeze=()=>{Z.frozen=!1,e()}})).then(function(){})}();return Promise.resolve(r&&r.then?r.then(n):n())}catch(e){return Promise.reject(e)}},E=()=>b(G),C=e=>function(e){let{speed:t,deleteSpeed:n,lifeLike:r}=e;return n=null!==n?n:t/3,r?[g(t,P(t)),g(n,P(n))]:[t,n]}($)[e],H=(e,t=0)=>e?C(t):0,z=(e,t)=>(ee.add(e),((e={})=>{let t=e.delay;t&&ee.add([[V,t]])})(t),this),R=()=>(e=>b(e)?n(e.value):o(e,d(".ti-cursor",e),!0))(G),A=(e={})=>[[Q,e],[Q,$]],B=e=>{let t=$.nextStringDelay;ee.add([[V,t[0]],...e,[V,t[1]]])},I=e=>{te&&(ne.classList.toggle("disabled",e),ne.classList.toggle("with-delay",!e))},O=function(){try{let e;Z.started=!0;let t,n=ee.getItems();const r=function(e,r){try{var o=function(){function e(){return Z.completed=!0,Promise.resolve($.afterComplete(...t)).then(function(){if(!$.loop)throw"";let e=$.loopDelay;D(function(){try{return Promise.resolve(function(e){try{function t(t){return ee.reset(),ee.set(0,[V,e,{}]),Promise.resolve(F({num:null})).then(function(){})}return Promise.resolve(W?Promise.resolve(q({value:W})).then(t):t())}catch(e){return Promise.reject(e)}}(e[0])).then(function(){O()})}catch(e){return Promise.reject(e)}},e[1])})}const r=x(n,function(e){let r=n[e],o=r[2];return t=[r,w],o.freezeCursor&&I(!0),Promise.resolve($.beforeStep(...t)).then(function(){return Promise.resolve(r[0].call(w,r[1],o)).then(function(){return Promise.resolve($.afterStep(...t)).then(function(){ee.setMeta(e,{executed:!0}),I(!1)})})})});return r&&r.then?r.then(e):e()}()}catch(e){return}return o&&o.then?o.then(void 0,function(){}):o}();return Promise.resolve(r&&r.then?r.then(function(t){return e?t:w}):e?r:w)}catch(e){return Promise.reject(e)}},V=(e=0)=>D(()=>{},e),q=function({value:e,to:t="START",instant:n=!1}){try{let r=p({el:G,move:e,cursorPos:W,to:t}),o=()=>{W+=r<0?-1:1,((e,t,n,r)=>{let o=t[Math.min(r,t.length)-1];(e=(null==o?void 0:o.parentNode)||e).insertBefore(n,o||null)})(G,R(),ne,W)};return Promise.resolve(D(function(){try{let e=0;const t=k(function(){return e<Math.abs(r)},function(){return e++},function(){return n?void o():Promise.resolve(D(o,C(0))).then(function(e){})});return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},H(n))).then(function(){})}catch(e){return Promise.reject(e)}},U=({chars:e,instant:t,silent:n})=>D(function(){try{function r(r){function i(){return n?void 0:Promise.resolve($.afterString(e)).then(function(e){})}const s=x(e,function(n){return t?void o(e[n]):Promise.resolve(D(()=>{o(e[n])},C(0))).then(function(e){})});return s&&s.then?s.then(i):i()}const o=e=>M(G,e,ne,W);return Promise.resolve(n?r():Promise.resolve($.beforeString(e)).then(r))}catch(e){return Promise.reject(e)}},H(t)),Q=function(e){try{return $=t($,e),Promise.resolve()}catch(e){return Promise.reject(e)}},Y=function(){try{return E()?(G.value="",Promise.resolve()):(R().forEach(e=>{L(e)}),Promise.resolve())}catch(e){return Promise.reject(e)}},F=function({num:e=null,instant:t=!1,to:n="START"}){try{return Promise.resolve(D(function(){try{let r=h(e)?e:p({el:G,move:e,cursorPos:W,to:n});const o=()=>{let e=R();var t;e.length&&(E()?G.value=G.value.slice(0,-1):(L(e[W]),t=ne,d("*",G,!0).forEach(e=>{if(!e.innerHTML&&"BR"!==e.tagName&&!e.isSameNode(t)){let t=e;for(;1===t.parentElement.childNodes.length;)t=t.parentElement;L(t)}})))};let i=0;const s=k(function(){return i<r},function(){return i++},function(){return t?void o():Promise.resolve(D(o,C(1))).then(function(e){})});return Promise.resolve(s&&s.then?s.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},H(t,1))).then(function(){const t=function(){if(null===e&&R().length-1>0)return Promise.resolve(F({num:null})).then(function(){})}();if(t&&t.then)return t.then(function(){})})}catch(e){return Promise.reject(e)}};this.break=function(e){const t=i(l("BR"));return z([[U,{chars:[t],silent:!0}]],e)},this.delete=function(e=null,t={}){e=S(e);let n=A(t),r=e,{instant:o,to:i}=t;return z([n[0],[F,{num:r,instant:o,to:i},X],n[1]],t)},this.empty=function(e={}){return z([[Y]],e)},this.exec=function(e,t){let n=A(t);return z([n[0],[e,null],n[1]],t)},this.move=function(e,t={}){e=S(e);let n=A(t),{instant:r,to:o}=t;return z([n[0],[q,{value:null===e?"":e,to:o,instant:r},X],n[1]],t)},this.options=function(e){return e=S(e),z([[Q,e]],e)},this.pause=function(e,t={}){return z([[V,S(e)]],t)},this.type=function(e,t={}){e=S(e);let n=A(t),r=u(e,$.html),{instant:o}=t;return z([n[0],[U,{chars:r,instant:o},X],n[1]],t)},this.is=function(e){return Z[e]},this.destroy=function(e=!0){K.forEach(e=>clearTimeout(e)),K=[],S(e)&&L(ne),Z.destroyed=!0},this.freeze=function(){Z.frozen=!0},this.unfreeze=function(){},this.reset=function(){!this.is("destroyed")&&this.destroy(),ee.reset(),W=0;for(let e in Z)Z[e]=!1;return G[E()?"value":"innerHTML"]="",this},this.go=function(){return Z.started?this:(function(){try{!E()&&G.appendChild(ne),te?(((e,t,n)=>{let r="[data-typeit-id='"+e+"'] .ti-cursor",o=getComputedStyle(n),i=Object.entries(j).reduce((e,[t,n])=>e+" "+t+": var(--ti-"+t+", "+(n||o[t])+");","");a("@keyframes blink-"+e+" { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } "+r+" { display: inline; letter-spacing: -1em; "+i+" animation: blink-"+e+" "+t.cursorSpeed/1e3+"s infinite; } "+r+".with-delay { animation-delay: 500ms; } "+r+".disabled { animation: none; }",e)})(_,$,G),Promise.resolve()):Promise.resolve()}catch(e){return Promise.reject(e)}}(),$.waitUntilVisible?(((e,t)=>{new IntersectionObserver((n,r)=>{n.forEach(n=>{n.isIntersecting&&(t(),r.unobserve(e))})},{threshold:1}).observe(e)})(G,O.bind(this)),this):(O(),this))},this.getQueue=function(){return ee},this.getOptions=function(){return $},this.getElement=function(){return G};let G="string"==typeof(J=c)?d(J):J;var J;let K=[],W=0,X={freezeCursor:!0},Z=t({},m),$=t(v,N);$=t($,{html:!E()&&$.html,nextStringDelay:y($.nextStringDelay),loopDelay:y($.loopDelay)});let _=Math.random().toString().substring(2,9),ee=function(n){const r=function(t){return o=o.concat(t.map(t=>e.map((e,n)=>t[n]?t[n]:e))),this};let o=[];return r(n),{add:r,set:function(e,t){o[e]=t},reset:function(){o=o.map(e=>(e[2].executed=!1,e))},getItems:function(){return o.filter(e=>!e[2].executed)},setMeta:function(e,n){o[e][2]=t(o[e][2],n)}}}([[V,$.startDelay]]);G.dataset.typeitId=_,a("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}");let te=$.cursor&&!E(),ne=(()=>{if(E())return;let e=l("span");return e.className="ti-cursor",te?(e.innerHTML=r($.cursorChar).innerHTML,e):(e.style.visibility="hidden",e)})();var re;$.strings=(e=>{let t=G.innerHTML;return t?(G.innerHTML="",$.startDelete?(s(t).forEach(e=>{M(G,e,ne,W)}),B([[F,{num:null}]]),e):t.trim().split(/<br(?:\s*?)(?:\/)?>/).concat(e)):e})(f(re=$.strings)?re:[re]),$.strings.length&&(()=>{let e=$.strings.filter(e=>!!e);e.forEach((t,n)=>{let r=u(t,$.html);if(ee.add([[U,{chars:r},X]]),n+1===e.length)return;const o=$.breakLines?[[U,{chars:[i(l("BR"))]},X]]:[[F,{num:r.length},X]];B(o)})})()}export{C as default}; |
// TypeIt by Alex MacArthur - https://typeitjs.com | ||
const e=[null,null,{}];var t=(e,t)=>Object.assign({},e,t),n=e=>Array.from(e),r=e=>{let t=document.implementation.createHTMLDocument();return t.body.innerHTML=e,t.body};const o=(e,t=null,r=!1)=>{let i=n(e.childNodes).flatMap(e=>{return 3===(t=e).nodeType||"BR"===t.tagName?e:o(e);var t});return t&&(i=i.filter(e=>!t.contains(e))),r?i.reverse():i},i=(e,t=null)=>({node:t,content:e});function s(e){let t=r(e);return o(t).flatMap(e=>e.nodeValue?n(e.nodeValue).map(t=>i(t,e)):i(e))}function u(e,t=!0){return t?s(e):n(e).map(e=>i(e))}var l=e=>document.createElement(e),c=e=>document.createTextNode(e),a=(e,t="")=>{let n=l("style");n.id=t,n.appendChild(c(e)),document.head.appendChild(n)},f=e=>Array.isArray(e);const h=e=>Number.isInteger(e),d=(e,t=document,n=!1)=>t["querySelector"+(n?"All":"")](e),m={started:!1,completed:!1,frozen:!1,destroyed:!1},v={breakLines:!0,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,html:!0,lifeLike:!0,loop:!1,loopDelay:750,nextStringDelay:750,speed:100,startDelay:250,startDelete:!1,strings:[],waitUntilVisible:!1,beforeString:()=>{},afterString:()=>{},beforeStep:()=>{},afterStep:()=>{},afterComplete:()=>{}},p=(e,t,n="START")=>{let r=new RegExp("END","i").test(n),i=d(".ti-cursor",t),s=e?d(e,t):t,u=o(s,i,!0),l=u[0],c=u[u.length-1],a=r&&!e?0:o(t,i,!0).findIndex(e=>e.isSameNode(r?l:c));return r&&a--,a+1};var y=e=>(f(e)||(e=[e/2,e/2]),e),g=(e,t)=>Math.abs(Math.random()*(e+t-(e-t))+(e-t));let P=e=>e/2;var b=e=>"value"in e;const S=e=>"function"==typeof e?e():e;var N=e=>"BODY"===e.tagName;const T=(e,t)=>{let r=n(d("*",t,!0));return[t].concat(r.reverse()).find(t=>t.cloneNode().isEqualNode(e.cloneNode()))},M=(e,t,n,r)=>{let i=t.content instanceof HTMLElement,s=t.node,u=null==s?void 0:s.parentNode,l=i?t.content:c(t.content);if(b(e))return void(e.value=""+e.value+t.content);if(!i&&u&&!N(u)){let r=T(u,e);if(r&&((e,t)=>{let n=e.nextSibling;return!n||n.isEqualNode(t)})(r,n))e=r;else{l=u.cloneNode(),l.appendChild(c(t.content));let n=u.parentNode,r=n.cloneNode();if(!N(n)){let t=T(r,e);for(;!t&&!N(n);){let o=r;o.innerHTML=l.outerHTML,l=o,n=n.parentNode,r=n.cloneNode(),t=T(r,e)}e=t||e}}}let a=o(e,n,!0)[r-1],f=a?a.parentNode:e;f.insertBefore(l,f.contains(n)?n:null)};var L=e=>e&&e.remove();const j={"font-family":"","font-weight":"","font-size":"","font-style":"","line-height":"",color:"","margin-left":"-.125em","margin-right":".125em"};function w(e,t,n){if(!e.s){if(n instanceof D){if(!n.s)return void(n.o=w.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(w.bind(null,e,t),w.bind(null,e,2));e.s=t,e.v=n;const r=e.o;r&&r(e)}}const D=function(){function e(){}return e.prototype.then=function(t,n){const r=new e,o=this.s;if(o){const e=1&o?t:n;if(e){try{w(r,1,e(this.v))}catch(e){w(r,2,e)}return r}return this}return this.o=function(e){try{const o=e.v;1&e.s?w(r,1,t?t(o):o):n?w(r,1,n(o)):w(r,2,o)}catch(e){w(r,2,e)}},r},e}();function E(e){return e instanceof D&&1&e.s}function x(e,t,n){var r,o,i=-1;return function s(u){try{for(;++i<e.length&&(!n||!n());)if((u=t(i))&&u.then){if(!E(u))return void u.then(s,o||(o=w.bind(null,r=new D,2)));u=u.v}r?w(r,1,u):r=u}catch(e){w(r||(r=new D),2,e)}}(),r}function k(e,t,n){for(var r;;){var o=e();if(E(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=n();if(i&&i.then){if(!E(i)){r=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!E(s)){r=2;break}}}var u=new D,l=w.bind(null,u,2);return(0===r?o.then(a):1===r?i.then(c):s.then(f)).then(void 0,l),u;function c(r){i=r;do{if(t&&(s=t())&&s.then&&!E(s))return void s.then(f).then(void 0,l);if(!(o=e())||E(o)&&!o.v)return void w(u,1,i);if(o.then)return void o.then(a).then(void 0,l);E(i=n())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,l)}function a(e){e?(i=n())&&i.then?i.then(c).then(void 0,l):c(i):w(u,1,i)}function f(){(o=e())?o.then?o.then(a).then(void 0,l):a(o):w(u,1,i)}}module.exports=function(c,N={}){const T=this,w=function(e,t){try{return Promise.resolve(function(e,t,n){try{return Promise.resolve(new Promise(r=>{n.push(setTimeout(function(){try{return Promise.resolve(e()).then(function(){r()})}catch(e){return Promise.reject(e)}},t))}))}catch(e){return Promise.reject(e)}}(e,t,J))}catch(e){return Promise.reject(e)}},D=()=>b(F),E=e=>function(e){let{speed:t,deleteSpeed:n,lifeLike:r}=e;return n=null!==n?n:t/3,r?[g(t,P(t)),g(n,P(n))]:[t,n]}(Z)[e],C=(e,t=0)=>e?E(t):0,H=(e,t)=>(_.add(e),((e={})=>{let t=e.delay;t&&_.add([[O,t]])})(t),this),z=()=>(e=>b(e)?n(e.value):o(e,d(".ti-cursor",e),!0))(F),R=(e={})=>[[U,e],[U,Z]],A=e=>{let t=Z.nextStringDelay;_.add([[O,t[0]],...e,[O,t[1]]])},B=e=>{ee&&(te.classList.toggle("disabled",e),te.classList.toggle("with-delay",!e))},I=function(){try{let e;X.started=!0;let t,n=_.getItems();const r=function(r,o){try{var i=function(){function r(e){return X.completed=!0,Promise.resolve(Z.afterComplete(...t)).then(function(){if(!Z.loop)throw"";let e=Z.loopDelay;w(function(){try{return Promise.resolve(function(e){try{function t(t){return _.reset(),_.set(0,[O,e,{}]),Promise.resolve(Y({num:null})).then(function(){})}return Promise.resolve(K?Promise.resolve(V({value:K})).then(t):t())}catch(e){return Promise.reject(e)}}(e[0])).then(function(){I()})}catch(e){return Promise.reject(e)}},e[1])})}const o=x(n,function(e){if(X.frozen||X.destroyed)throw"";let r=n[e],o=r[2];return t=[r,T],o.freezeCursor&&B(!0),Promise.resolve(Z.beforeStep(...t)).then(function(){return Promise.resolve(r[0].call(T,r[1],o)).then(function(){return Promise.resolve(Z.afterStep(...t)).then(function(){_.setMeta(e,{executed:!0}),B(!1)})})})},function(){return e});return o&&o.then?o.then(r):r()}()}catch(e){return}return i&&i.then?i.then(void 0,function(){}):i}();return Promise.resolve(r&&r.then?r.then(function(t){return e?t:T}):e?r:T)}catch(e){return Promise.reject(e)}},O=(e=0)=>w(()=>{},e),V=function({value:e,to:t="START",instant:n=!1}){try{let r=(({el:e,move:t,cursorPos:n,to:r})=>h(t)?-1*t:p(t,e,r)-n)({el:F,move:e,cursorPos:K,to:t}),o=()=>{K+=r<0?-1:1,((e,t,n,r)=>{let o=t[Math.min(r,t.length)-1];(e=(null==o?void 0:o.parentNode)||e).insertBefore(n,o||null)})(F,z(),te,K)};return Promise.resolve(w(function(){try{let e=0;const t=k(function(){return e<Math.abs(r)},function(){return e++},function(){return n?void o():Promise.resolve(w(o,E(0))).then(function(e){})});return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},C(n))).then(function(){})}catch(e){return Promise.reject(e)}},q=({chars:e,instant:t,silent:n})=>w(function(){try{function r(r){function i(){return n?void 0:Promise.resolve(Z.afterString(e)).then(function(e){})}const s=x(e,function(n){return t?void o(e[n]):Promise.resolve(w(()=>{o(e[n])},E(0))).then(function(e){})});return s&&s.then?s.then(i):i()}const o=e=>M(F,e,te,K);return Promise.resolve(n?r():Promise.resolve(Z.beforeString(e)).then(r))}catch(e){return Promise.reject(e)}},C(t)),U=function(e){try{return Z=t(Z,e),Promise.resolve()}catch(e){return Promise.reject(e)}},Q=function(){try{return D()?(F.value="",Promise.resolve()):(z().forEach(e=>{L(e)}),Promise.resolve())}catch(e){return Promise.reject(e)}},Y=function({num:e=null,instant:t=!1,to:n="START"}){try{const r=e=>h(e)?e:p(e,F,n);return Promise.resolve(w(function(){try{let n=r(e);const o=()=>{let e=z();var t;e.length&&(D()?F.value=F.value.slice(0,-1):(L(e[K]),t=te,d("*",F,!0).forEach(e=>{if(!e.innerHTML&&"BR"!==e.tagName&&!e.isSameNode(t)){let t=e;for(;1===t.parentElement.childNodes.length;)t=t.parentElement;L(t)}})))};let i=0;const s=k(function(){return i<n},function(){return i++},function(){return t?void o():Promise.resolve(w(o,E(1))).then(function(e){})});return Promise.resolve(s&&s.then?s.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},C(t,1))).then(function(){const t=function(){if(null===e&&z().length-1>0)return Promise.resolve(Y({num:null})).then(function(){})}();if(t&&t.then)return t.then(function(){})})}catch(e){return Promise.reject(e)}};this.break=function(e){const t=i(l("BR"));return H([[q,{chars:[t],silent:!0}]],e)},this.delete=function(e=null,t={}){e=S(e);let n=R(t),r=e,{instant:o,to:i}=t;return H([n[0],[Y,{num:r,instant:o,to:i},W],n[1]],t)},this.empty=function(e={}){return H([[Q]],e)},this.exec=function(e,t){let n=R(t);return H([n[0],[e,null],n[1]],t)},this.move=function(e,t={}){e=S(e);let n=R(t),{instant:r,to:o}=t;return H([n[0],[V,{value:null===e?"":e,to:o,instant:r},W],n[1]],t)},this.options=function(e){return e=S(e),H([[U,e]],e)},this.pause=function(e,t={}){return H([[O,S(e)]],t)},this.type=function(e,t={}){e=S(e);let n=R(t),r=u(e,Z.html),{instant:o}=t;return H([n[0],[q,{chars:r,instant:o},W],n[1]],t)},this.is=function(e){return X[e]},this.destroy=function(e=!0){J.forEach(e=>clearTimeout(e)),J=[],S(e)&&L(te),X.destroyed=!0},this.freeze=function(){X.frozen=!0},this.unfreeze=function(){X.frozen=!1,I()},this.reset=function(){!this.is("destroyed")&&this.destroy(),_.reset(),K=0;for(let e in X)X[e]=!1;return F[D()?"value":"innerHTML"]="",this},this.go=function(){return X.started?this:(function(){try{!D()&&F.appendChild(te),ee?(((e,t,n)=>{let r="[data-typeit-id='"+e+"'] .ti-cursor",o=getComputedStyle(n),i=Object.entries(j).reduce((e,[t,n])=>e+" "+t+": var(--ti-"+t+", "+(n||o[t])+");","");a("@keyframes blink-"+e+" { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } "+r+" { display: inline; letter-spacing: -1em; "+i+" animation: blink-"+e+" "+t.cursorSpeed/1e3+"s infinite; } "+r+".with-delay { animation-delay: 500ms; } "+r+".disabled { animation: none; }",e)})($,Z,F),Promise.resolve()):Promise.resolve()}catch(e){return Promise.reject(e)}}(),Z.waitUntilVisible?(((e,t)=>{new IntersectionObserver((n,r)=>{n.forEach(n=>{n.isIntersecting&&(t(),r.unobserve(e))})},{threshold:1}).observe(e)})(F,I.bind(this)),this):(I(),this))},this.getQueue=function(){return _},this.getOptions=function(){return Z},this.getElement=function(){return F};let F="string"==typeof(G=c)?d(G):G;var G;let J=[],K=0,W={freezeCursor:!0},X=t({},m),Z=t(v,N);Z=t(Z,{html:!D()&&Z.html,nextStringDelay:y(Z.nextStringDelay),loopDelay:y(Z.loopDelay)});let $=Math.random().toString().substring(2,9),_=function(n){const r=function(t){return o=o.concat(t.map(t=>e.map((e,n)=>t[n]?t[n]:e))),this};let o=[];return r(n),{add:r,set:function(e,t){o[e]=t},reset:function(){o=o.map(e=>(e[2].executed=!1,e))},getItems:function(){return o.filter(e=>!e[2].executed)},setMeta:function(e,n){o[e][2]=t(o[e][2],n)}}}([[O,Z.startDelay]]);F.dataset.typeitId=$,a("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}");let ee=Z.cursor&&!D(),te=(()=>{if(D())return;let e=l("span");return e.className="ti-cursor",ee?(e.innerHTML=r(Z.cursorChar).innerHTML,e):(e.style.visibility="hidden",e)})();var ne;Z.strings=(e=>{let t=F.innerHTML;return t?(F.innerHTML="",Z.startDelete?(s(t).forEach(e=>{M(F,e,te,K)}),A([[Y,{num:null}]]),e):t.trim().split(/<br(?:\s*?)(?:\/)?>/).concat(e)):e})(f(ne=Z.strings)?ne:[ne]),Z.strings.length&&(()=>{let e=Z.strings.filter(e=>!!e);e.forEach((t,n)=>{let r=u(t,Z.html);if(_.add([[q,{chars:r},W]]),n+1===e.length)return;const o=Z.breakLines?[[q,{chars:[i(l("BR"))]},W]]:[[Y,{num:r.length},W]];A(o)})})()}; | ||
const e=[null,null,{}];var t=(e,t)=>Object.assign({},e,t),n=e=>Array.from(e),r=e=>{let t=document.implementation.createHTMLDocument();return t.body.innerHTML=e,t.body};const o=(e,t=null,r=!1)=>{let i=n(e.childNodes).flatMap(e=>{return 3===(t=e).nodeType||"BR"===t.tagName?e:o(e);var t});return t&&(i=i.filter(e=>!t.contains(e))),r?i.reverse():i},i=(e,t=null)=>({node:t,content:e});function s(e){let t=r(e);return o(t).flatMap(e=>e.nodeValue?n(e.nodeValue).map(t=>i(t,e)):i(e))}function u(e,t=!0){return t?s(e):n(e).map(e=>i(e))}var l=e=>document.createElement(e),c=e=>document.createTextNode(e),a=(e,t="")=>{let n=l("style");n.id=t,n.appendChild(c(e)),document.head.appendChild(n)},f=e=>Array.isArray(e);const h=e=>Number.isInteger(e),d=(e,t=document,n=!1)=>t["querySelector"+(n?"All":"")](e),m={started:!1,completed:!1,frozen:!1,destroyed:!1},v={breakLines:!0,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,html:!0,lifeLike:!0,loop:!1,loopDelay:750,nextStringDelay:750,speed:100,startDelay:250,startDelete:!1,strings:[],waitUntilVisible:!1,beforeString:()=>{},afterString:()=>{},beforeStep:()=>{},afterStep:()=>{},afterComplete:()=>{}};var p=({el:e,move:t,cursorPos:n,to:r})=>h(t)?-1*t:((e,t,n="START")=>{let r=new RegExp("END","i").test(n),i=d(".ti-cursor",t),s=e?d(e,t):t,u=o(s,i,!0),l=u[0],c=u[u.length-1],a=r&&!e?0:o(t,i,!0).findIndex(e=>e.isSameNode(r?l:c));return r&&a--,a+1})(t,e,r)-n,y=e=>(f(e)||(e=[e/2,e/2]),e),g=(e,t)=>Math.abs(Math.random()*(e+t-(e-t))+(e-t));let P=e=>e/2;var b=e=>"value"in e;const S=e=>"function"==typeof e?e():e;var N=e=>"BODY"===e.tagName;const T=(e,t)=>{let r=n(d("*",t,!0));return[t].concat(r.reverse()).find(t=>t.cloneNode().isEqualNode(e.cloneNode()))},M=(e,t,n,r)=>{let i=t.content instanceof HTMLElement,s=t.node,u=null==s?void 0:s.parentNode,l=i?t.content:c(t.content);if(b(e))return void(e.value=""+e.value+t.content);if(!i&&u&&!N(u)){let r=T(u,e);if(r&&((e,t)=>{let n=e.nextSibling;return!n||n.isEqualNode(t)})(r,n))e=r;else{l=u.cloneNode(),l.appendChild(c(t.content));let n=u.parentNode,r=n.cloneNode();if(!N(n)){let t=T(r,e);for(;!t&&!N(n);){let o=r;o.innerHTML=l.outerHTML,l=o,n=n.parentNode,r=n.cloneNode(),t=T(r,e)}e=t||e}}}let a=o(e,n,!0)[r-1],f=a?a.parentNode:e;f.insertBefore(l,f.contains(n)?n:null)};var L=e=>e&&e.remove();const j={"font-family":"","font-weight":"","font-size":"","font-style":"","line-height":"",color:"","margin-left":"-.125em","margin-right":".125em"};function w(e,t,n){if(!e.s){if(n instanceof D){if(!n.s)return void(n.o=w.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(w.bind(null,e,t),w.bind(null,e,2));e.s=t,e.v=n;const r=e.o;r&&r(e)}}const D=function(){function e(){}return e.prototype.then=function(t,n){const r=new e,o=this.s;if(o){const e=1&o?t:n;if(e){try{w(r,1,e(this.v))}catch(e){w(r,2,e)}return r}return this}return this.o=function(e){try{const o=e.v;1&e.s?w(r,1,t?t(o):o):n?w(r,1,n(o)):w(r,2,o)}catch(e){w(r,2,e)}},r},e}();function E(e){return e instanceof D&&1&e.s}function x(e,t,n){var r,o,i=-1;return function s(u){try{for(;++i<e.length&&(!n||!n());)if((u=t(i))&&u.then){if(!E(u))return void u.then(s,o||(o=w.bind(null,r=new D,2)));u=u.v}r?w(r,1,u):r=u}catch(e){w(r||(r=new D),2,e)}}(),r}function k(e,t,n){for(var r;;){var o=e();if(E(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=n();if(i&&i.then){if(!E(i)){r=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!E(s)){r=2;break}}}var u=new D,l=w.bind(null,u,2);return(0===r?o.then(a):1===r?i.then(c):s.then(f)).then(void 0,l),u;function c(r){i=r;do{if(t&&(s=t())&&s.then&&!E(s))return void s.then(f).then(void 0,l);if(!(o=e())||E(o)&&!o.v)return void w(u,1,i);if(o.then)return void o.then(a).then(void 0,l);E(i=n())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,l)}function a(e){e?(i=n())&&i.then?i.then(c).then(void 0,l):c(i):w(u,1,i)}function f(){(o=e())?o.then?o.then(a).then(void 0,l):a(o):w(u,1,i)}}module.exports=function(c,N={}){const T=this,w=this,D=function(e,t){try{function n(){return Promise.resolve(function(e,t,n){try{return Promise.resolve(new Promise(r=>{n.push(setTimeout(function(){try{return Promise.resolve(e()).then(function(){r()})}catch(e){return Promise.reject(e)}},t))}))}catch(e){return Promise.reject(e)}}(e,t,K))}const r=function(){if(Z.frozen)return Promise.resolve(new Promise(e=>{T.unfreeze=()=>{Z.frozen=!1,e()}})).then(function(){})}();return Promise.resolve(r&&r.then?r.then(n):n())}catch(e){return Promise.reject(e)}},E=()=>b(G),C=e=>function(e){let{speed:t,deleteSpeed:n,lifeLike:r}=e;return n=null!==n?n:t/3,r?[g(t,P(t)),g(n,P(n))]:[t,n]}($)[e],H=(e,t=0)=>e?C(t):0,z=(e,t)=>(ee.add(e),((e={})=>{let t=e.delay;t&&ee.add([[V,t]])})(t),this),R=()=>(e=>b(e)?n(e.value):o(e,d(".ti-cursor",e),!0))(G),A=(e={})=>[[Q,e],[Q,$]],B=e=>{let t=$.nextStringDelay;ee.add([[V,t[0]],...e,[V,t[1]]])},I=e=>{te&&(ne.classList.toggle("disabled",e),ne.classList.toggle("with-delay",!e))},O=function(){try{let e;Z.started=!0;let t,n=ee.getItems();const r=function(e,r){try{var o=function(){function e(){return Z.completed=!0,Promise.resolve($.afterComplete(...t)).then(function(){if(!$.loop)throw"";let e=$.loopDelay;D(function(){try{return Promise.resolve(function(e){try{function t(t){return ee.reset(),ee.set(0,[V,e,{}]),Promise.resolve(F({num:null})).then(function(){})}return Promise.resolve(W?Promise.resolve(q({value:W})).then(t):t())}catch(e){return Promise.reject(e)}}(e[0])).then(function(){O()})}catch(e){return Promise.reject(e)}},e[1])})}const r=x(n,function(e){let r=n[e],o=r[2];return t=[r,w],o.freezeCursor&&I(!0),Promise.resolve($.beforeStep(...t)).then(function(){return Promise.resolve(r[0].call(w,r[1],o)).then(function(){return Promise.resolve($.afterStep(...t)).then(function(){ee.setMeta(e,{executed:!0}),I(!1)})})})});return r&&r.then?r.then(e):e()}()}catch(e){return}return o&&o.then?o.then(void 0,function(){}):o}();return Promise.resolve(r&&r.then?r.then(function(t){return e?t:w}):e?r:w)}catch(e){return Promise.reject(e)}},V=(e=0)=>D(()=>{},e),q=function({value:e,to:t="START",instant:n=!1}){try{let r=p({el:G,move:e,cursorPos:W,to:t}),o=()=>{W+=r<0?-1:1,((e,t,n,r)=>{let o=t[Math.min(r,t.length)-1];(e=(null==o?void 0:o.parentNode)||e).insertBefore(n,o||null)})(G,R(),ne,W)};return Promise.resolve(D(function(){try{let e=0;const t=k(function(){return e<Math.abs(r)},function(){return e++},function(){return n?void o():Promise.resolve(D(o,C(0))).then(function(e){})});return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},H(n))).then(function(){})}catch(e){return Promise.reject(e)}},U=({chars:e,instant:t,silent:n})=>D(function(){try{function r(r){function i(){return n?void 0:Promise.resolve($.afterString(e)).then(function(e){})}const s=x(e,function(n){return t?void o(e[n]):Promise.resolve(D(()=>{o(e[n])},C(0))).then(function(e){})});return s&&s.then?s.then(i):i()}const o=e=>M(G,e,ne,W);return Promise.resolve(n?r():Promise.resolve($.beforeString(e)).then(r))}catch(e){return Promise.reject(e)}},H(t)),Q=function(e){try{return $=t($,e),Promise.resolve()}catch(e){return Promise.reject(e)}},Y=function(){try{return E()?(G.value="",Promise.resolve()):(R().forEach(e=>{L(e)}),Promise.resolve())}catch(e){return Promise.reject(e)}},F=function({num:e=null,instant:t=!1,to:n="START"}){try{return Promise.resolve(D(function(){try{let r=h(e)?e:p({el:G,move:e,cursorPos:W,to:n});const o=()=>{let e=R();var t;e.length&&(E()?G.value=G.value.slice(0,-1):(L(e[W]),t=ne,d("*",G,!0).forEach(e=>{if(!e.innerHTML&&"BR"!==e.tagName&&!e.isSameNode(t)){let t=e;for(;1===t.parentElement.childNodes.length;)t=t.parentElement;L(t)}})))};let i=0;const s=k(function(){return i<r},function(){return i++},function(){return t?void o():Promise.resolve(D(o,C(1))).then(function(e){})});return Promise.resolve(s&&s.then?s.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},H(t,1))).then(function(){const t=function(){if(null===e&&R().length-1>0)return Promise.resolve(F({num:null})).then(function(){})}();if(t&&t.then)return t.then(function(){})})}catch(e){return Promise.reject(e)}};this.break=function(e){const t=i(l("BR"));return z([[U,{chars:[t],silent:!0}]],e)},this.delete=function(e=null,t={}){e=S(e);let n=A(t),r=e,{instant:o,to:i}=t;return z([n[0],[F,{num:r,instant:o,to:i},X],n[1]],t)},this.empty=function(e={}){return z([[Y]],e)},this.exec=function(e,t){let n=A(t);return z([n[0],[e,null],n[1]],t)},this.move=function(e,t={}){e=S(e);let n=A(t),{instant:r,to:o}=t;return z([n[0],[q,{value:null===e?"":e,to:o,instant:r},X],n[1]],t)},this.options=function(e){return e=S(e),z([[Q,e]],e)},this.pause=function(e,t={}){return z([[V,S(e)]],t)},this.type=function(e,t={}){e=S(e);let n=A(t),r=u(e,$.html),{instant:o}=t;return z([n[0],[U,{chars:r,instant:o},X],n[1]],t)},this.is=function(e){return Z[e]},this.destroy=function(e=!0){K.forEach(e=>clearTimeout(e)),K=[],S(e)&&L(ne),Z.destroyed=!0},this.freeze=function(){Z.frozen=!0},this.unfreeze=function(){},this.reset=function(){!this.is("destroyed")&&this.destroy(),ee.reset(),W=0;for(let e in Z)Z[e]=!1;return G[E()?"value":"innerHTML"]="",this},this.go=function(){return Z.started?this:(function(){try{!E()&&G.appendChild(ne),te?(((e,t,n)=>{let r="[data-typeit-id='"+e+"'] .ti-cursor",o=getComputedStyle(n),i=Object.entries(j).reduce((e,[t,n])=>e+" "+t+": var(--ti-"+t+", "+(n||o[t])+");","");a("@keyframes blink-"+e+" { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } "+r+" { display: inline; letter-spacing: -1em; "+i+" animation: blink-"+e+" "+t.cursorSpeed/1e3+"s infinite; } "+r+".with-delay { animation-delay: 500ms; } "+r+".disabled { animation: none; }",e)})(_,$,G),Promise.resolve()):Promise.resolve()}catch(e){return Promise.reject(e)}}(),$.waitUntilVisible?(((e,t)=>{new IntersectionObserver((n,r)=>{n.forEach(n=>{n.isIntersecting&&(t(),r.unobserve(e))})},{threshold:1}).observe(e)})(G,O.bind(this)),this):(O(),this))},this.getQueue=function(){return ee},this.getOptions=function(){return $},this.getElement=function(){return G};let G="string"==typeof(J=c)?d(J):J;var J;let K=[],W=0,X={freezeCursor:!0},Z=t({},m),$=t(v,N);$=t($,{html:!E()&&$.html,nextStringDelay:y($.nextStringDelay),loopDelay:y($.loopDelay)});let _=Math.random().toString().substring(2,9),ee=function(n){const r=function(t){return o=o.concat(t.map(t=>e.map((e,n)=>t[n]?t[n]:e))),this};let o=[];return r(n),{add:r,set:function(e,t){o[e]=t},reset:function(){o=o.map(e=>(e[2].executed=!1,e))},getItems:function(){return o.filter(e=>!e[2].executed)},setMeta:function(e,n){o[e][2]=t(o[e][2],n)}}}([[V,$.startDelay]]);G.dataset.typeitId=_,a("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}");let te=$.cursor&&!E(),ne=(()=>{if(E())return;let e=l("span");return e.className="ti-cursor",te?(e.innerHTML=r($.cursorChar).innerHTML,e):(e.style.visibility="hidden",e)})();var re;$.strings=(e=>{let t=G.innerHTML;return t?(G.innerHTML="",$.startDelete?(s(t).forEach(e=>{M(G,e,ne,W)}),B([[F,{num:null}]]),e):t.trim().split(/<br(?:\s*?)(?:\/)?>/).concat(e)):e})(f(re=$.strings)?re:[re]),$.strings.length&&(()=>{let e=$.strings.filter(e=>!!e);e.forEach((t,n)=>{let r=u(t,$.html);if(ee.add([[U,{chars:r},X]]),n+1===e.length)return;const o=$.breakLines?[[U,{chars:[i(l("BR"))]},X]]:[[F,{num:r.length},X]];B(o)})})()}; |
// TypeIt by Alex MacArthur - https://typeitjs.com | ||
const e=[null,null,{}];var t=(e,t)=>Object.assign({},e,t),n=e=>Array.from(e),r=e=>{let t=document.implementation.createHTMLDocument();return t.body.innerHTML=e,t.body};const i=(e,t=null,r=!1)=>{let a=n(e.childNodes).flatMap(e=>{return 3===(t=e).nodeType||"BR"===t.tagName?e:i(e);var t});return t&&(a=a.filter(e=>!t.contains(e))),r?a.reverse():a},a=(e,t=null)=>({node:t,content:e});function l(e){let t=r(e);return i(t).flatMap(e=>e.nodeValue?n(e.nodeValue).map(t=>a(t,e)):a(e))}function o(e,t=!0){return t?l(e):n(e).map(e=>a(e))}var s=e=>document.createElement(e),u=e=>document.createTextNode(e),c=(e,t="")=>{let n=s("style");n.id=t,n.appendChild(u(e)),document.head.appendChild(n)},d=e=>Array.isArray(e);const f=e=>Number.isInteger(e),h=(e,t=document,n=!1)=>t["querySelector"+(n?"All":"")](e),m={started:!1,completed:!1,frozen:!1,destroyed:!1},p={breakLines:!0,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,html:!0,lifeLike:!0,loop:!1,loopDelay:750,nextStringDelay:750,speed:100,startDelay:250,startDelete:!1,strings:[],waitUntilVisible:!1,beforeString:()=>{},afterString:()=>{},beforeStep:()=>{},afterStep:()=>{},afterComplete:()=>{}},y=(e,t,n="START")=>{let r=new RegExp("END","i").test(n),a=h(".ti-cursor",t),l=e?h(e,t):t,o=i(l,a,!0),s=o[0],u=o[o.length-1],c=r&&!e?0:i(t,a,!0).findIndex(e=>e.isSameNode(r?s:u));return r&&c--,c+1};var g=e=>(d(e)||(e=[e/2,e/2]),e),v=(e,t)=>Math.abs(Math.random()*(e+t-(e-t))+(e-t));let b=e=>e/2;var w=e=>"value"in e;const S=e=>"function"==typeof e?e():e;var N=e=>"BODY"===e.tagName;const T=(e,t)=>{let r=n(h("*",t,!0));return[t].concat(r.reverse()).find(t=>t.cloneNode().isEqualNode(e.cloneNode()))},M=(e,t,n,r)=>{let a=t.content instanceof HTMLElement,l=t.node,o=null==l?void 0:l.parentNode,s=a?t.content:u(t.content);if(w(e))return void(e.value=`${e.value}${t.content}`);if(!a&&o&&!N(o)){let r=T(o,e);if(r&&((e,t)=>{let n=e.nextSibling;return!n||n.isEqualNode(t)})(r,n))e=r;else{s=o.cloneNode(),s.appendChild(u(t.content));let n=o.parentNode,r=n.cloneNode();if(!N(n)){let t=T(r,e);for(;!t&&!N(n);){let i=r;i.innerHTML=s.outerHTML,s=i,n=n.parentNode,r=n.cloneNode(),t=T(r,e)}e=t||e}}}let c=i(e,n,!0)[r-1],d=c?c.parentNode:e;d.insertBefore(s,d.contains(n)?n:null)};var L=e=>e&&e.remove();const D={"font-family":"","font-weight":"","font-size":"","font-style":"","line-height":"",color:"","margin-left":"-.125em","margin-right":".125em"};function E(u,N={}){const T=async(e,t)=>await(async(e,t,n)=>new Promise(r=>{n.push(setTimeout(async()=>{await e(),r()},t))}))(e,t,Q),E=()=>w(j),$=e=>function(e){let{speed:t,deleteSpeed:n,lifeLike:r}=e;return n=null!==n?n:t/3,r?[v(t,b(t)),v(n,b(n))]:[t,n]}(J)[e],x=(e,t=0)=>e?$(t):0,C=(e,t)=>(W.add(e),((e={})=>{let t=e.delay;t&&W.add([[B,t]])})(t),this),H=()=>(e=>w(e)?n(e.value):i(e,h(".ti-cursor",e),!0))(j),k=(e={})=>[[V,e],[V,J]],z=e=>{let t=J.nextStringDelay;W.add([[B,t[0]],...e,[B,t[1]]])},R=e=>{X&&(Z.classList.toggle("disabled",e),Z.classList.toggle("with-delay",!e))},A=async()=>{G.started=!0;let e,t=W.getItems();try{for(let n=0;n<t.length;n++){if(G.frozen||G.destroyed)throw"";let r=t[n],i=r[2];e=[r,this],i.freezeCursor&&R(!0),await J.beforeStep(...e),await r[0].call(this,r[1],i),await J.afterStep(...e),W.setMeta(n,{executed:!0}),R(!1)}if(G.completed=!0,await J.afterComplete(...e),!J.loop)throw"";let n=J.loopDelay;T(async()=>{await(async e=>{Y&&await I({value:Y}),W.reset(),W.set(0,[B,e,{}]),await P({num:null})})(n[0]),A()},n[1])}catch(e){}return this},B=(e=0)=>T(()=>{},e),I=async({value:e,to:t="START",instant:n=!1})=>{let r=(({el:e,move:t,cursorPos:n,to:r})=>f(t)?-1*t:y(t,e,r)-n)({el:j,move:e,cursorPos:Y,to:t}),i=()=>{Y+=r<0?-1:1,((e,t,n,r)=>{let i=t[Math.min(r,t.length)-1];(e=(null==i?void 0:i.parentNode)||e).insertBefore(n,i||null)})(j,H(),Z,Y)};await T(async()=>{for(let e=0;e<Math.abs(r);e++)n?i():await T(i,$(0))},x(n))},O=({chars:e,instant:t,silent:n})=>T(async()=>{const r=e=>M(j,e,Z,Y);n||await J.beforeString(e);for(let n=0;n<e.length;n++)t?r(e[n]):await T(()=>{r(e[n])},$(0));n||await J.afterString(e)},x(t)),V=async e=>{J=t(J,e)},q=async()=>{E()?j.value="":H().forEach(e=>{L(e)})},P=async({num:e=null,instant:t=!1,to:n="START"})=>{await T(async()=>{let r=f(i=e)?i:y(i,j,n);var i;const a=()=>{let e=H();var t;e.length&&(E()?j.value=j.value.slice(0,-1):(L(e[Y]),t=Z,h("*",j,!0).forEach(e=>{if(!e.innerHTML&&"BR"!==e.tagName&&!e.isSameNode(t)){let t=e;for(;1===t.parentElement.childNodes.length;)t=t.parentElement;L(t)}})))};for(let e=0;e<r;e++)t?a():await T(a,$(1))},x(t,1)),null===e&&H().length-1>0&&await P({num:null})};this.break=function(e){const t=a(s("BR"));return C([[O,{chars:[t],silent:!0}]],e)},this.delete=function(e=null,t={}){e=S(e);let n=k(t),r=e,{instant:i,to:a}=t;return C([n[0],[P,{num:r,instant:i,to:a},F],n[1]],t)},this.empty=function(e={}){return C([[q]],e)},this.exec=function(e,t){let n=k(t);return C([n[0],[e,null],n[1]],t)},this.move=function(e,t={}){e=S(e);let n=k(t),{instant:r,to:i}=t;return C([n[0],[I,{value:null===e?"":e,to:i,instant:r},F],n[1]],t)},this.options=function(e){return e=S(e),C([[V,e]],e)},this.pause=function(e,t={}){return C([[B,S(e)]],t)},this.type=function(e,t={}){e=S(e);let n=k(t),r=o(e,J.html),{instant:i}=t;return C([n[0],[O,{chars:r,instant:i},F],n[1]],t)},this.is=function(e){return G[e]},this.destroy=function(e=!0){Q.forEach(e=>clearTimeout(e)),Q=[],S(e)&&L(Z),G.destroyed=!0},this.freeze=function(){G.frozen=!0},this.unfreeze=function(){G.frozen=!1,A()},this.reset=function(){!this.is("destroyed")&&this.destroy(),W.reset(),Y=0;for(let e in G)G[e]=!1;return j[E()?"value":"innerHTML"]="",this},this.go=function(){return G.started?this:((async()=>{!E()&&j.appendChild(Z),X&&((e,t,n)=>{let r=`[data-typeit-id='${e}'] .ti-cursor`,i=getComputedStyle(n),a=Object.entries(D).reduce((e,[t,n])=>`${e} ${t}: var(--ti-${t}, ${n||i[t]});`,"");c(`@keyframes blink-${e} { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ${r} { display: inline; letter-spacing: -1em; ${a} animation: blink-${e} ${t.cursorSpeed/1e3}s infinite; } ${r}.with-delay { animation-delay: 500ms; } ${r}.disabled { animation: none; }`,e)})(K,J,j)})(),J.waitUntilVisible?(((e,t)=>{new IntersectionObserver((n,r)=>{n.forEach(n=>{n.isIntersecting&&(t(),r.unobserve(e))})},{threshold:1}).observe(e)})(j,A.bind(this)),this):(A(),this))},this.getQueue=function(){return W},this.getOptions=function(){return J},this.getElement=function(){return j};let j="string"==typeof(U=u)?h(U):U;var U;let Q=[],Y=0,F={freezeCursor:!0},G=t({},m),J=t(p,N);J=t(J,{html:!E()&&J.html,nextStringDelay:g(J.nextStringDelay),loopDelay:g(J.loopDelay)});let K=Math.random().toString().substring(2,9),W=function(n){const r=function(t){return i=i.concat(t.map(t=>e.map((e,n)=>t[n]?t[n]:e))),this};let i=[];return r(n),{add:r,set:function(e,t){i[e]=t},reset:function(){i=i.map(e=>(e[2].executed=!1,e))},getItems:function(){return i.filter(e=>!e[2].executed)},setMeta:function(e,n){i[e][2]=t(i[e][2],n)}}}([[B,J.startDelay]]);j.dataset.typeitId=K,c("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}");let X=J.cursor&&!E(),Z=(()=>{if(E())return;let e=s("span");return e.className="ti-cursor",X?(e.innerHTML=r(J.cursorChar).innerHTML,e):(e.style.visibility="hidden",e)})();var _;J.strings=(e=>{let t=j.innerHTML;return t?(j.innerHTML="",J.startDelete?(l(t).forEach(e=>{M(j,e,Z,Y)}),z([[P,{num:null}]]),e):t.trim().split(/<br(?:\s*?)(?:\/)?>/).concat(e)):e})(d(_=J.strings)?_:[_]),J.strings.length&&(()=>{let e=J.strings.filter(e=>!!e);e.forEach((t,n)=>{let r=o(t,J.html);if(W.add([[O,{chars:r},F]]),n+1===e.length)return;const i=J.breakLines?[[O,{chars:[a(s("BR"))]},F]]:[[P,{num:r.length},F]];z(i)})})()}export{E as default}; | ||
const e=[null,null,{}];var t=(e,t)=>Object.assign({},e,t),n=e=>Array.from(e),r=e=>{let t=document.implementation.createHTMLDocument();return t.body.innerHTML=e,t.body};const i=(e,t=null,r=!1)=>{let a=n(e.childNodes).flatMap(e=>{return 3===(t=e).nodeType||"BR"===t.tagName?e:i(e);var t});return t&&(a=a.filter(e=>!t.contains(e))),r?a.reverse():a},a=(e,t=null)=>({node:t,content:e});function l(e){let t=r(e);return i(t).flatMap(e=>e.nodeValue?n(e.nodeValue).map(t=>a(t,e)):a(e))}function o(e,t=!0){return t?l(e):n(e).map(e=>a(e))}var s=e=>document.createElement(e),u=e=>document.createTextNode(e),c=(e,t="")=>{let n=s("style");n.id=t,n.appendChild(u(e)),document.head.appendChild(n)},d=e=>Array.isArray(e);const f=e=>Number.isInteger(e),h=(e,t=document,n=!1)=>t["querySelector"+(n?"All":"")](e),m={started:!1,completed:!1,frozen:!1,destroyed:!1},p={breakLines:!0,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,html:!0,lifeLike:!0,loop:!1,loopDelay:750,nextStringDelay:750,speed:100,startDelay:250,startDelete:!1,strings:[],waitUntilVisible:!1,beforeString:()=>{},afterString:()=>{},beforeStep:()=>{},afterStep:()=>{},afterComplete:()=>{}};var y=({el:e,move:t,cursorPos:n,to:r})=>f(t)?-1*t:((e,t,n="START")=>{let r=new RegExp("END","i").test(n),a=h(".ti-cursor",t),l=e?h(e,t):t,o=i(l,a,!0),s=o[0],u=o[o.length-1],c=r&&!e?0:i(t,a,!0).findIndex(e=>e.isSameNode(r?s:u));return r&&c--,c+1})(t,e,r)-n,g=e=>(d(e)||(e=[e/2,e/2]),e),v=(e,t)=>Math.abs(Math.random()*(e+t-(e-t))+(e-t));let b=e=>e/2;var w=e=>"value"in e;const S=e=>"function"==typeof e?e():e;var N=e=>"BODY"===e.tagName;const T=(e,t)=>{let r=n(h("*",t,!0));return[t].concat(r.reverse()).find(t=>t.cloneNode().isEqualNode(e.cloneNode()))},M=(e,t,n,r)=>{let a=t.content instanceof HTMLElement,l=t.node,o=null==l?void 0:l.parentNode,s=a?t.content:u(t.content);if(w(e))return void(e.value=`${e.value}${t.content}`);if(!a&&o&&!N(o)){let r=T(o,e);if(r&&((e,t)=>{let n=e.nextSibling;return!n||n.isEqualNode(t)})(r,n))e=r;else{s=o.cloneNode(),s.appendChild(u(t.content));let n=o.parentNode,r=n.cloneNode();if(!N(n)){let t=T(r,e);for(;!t&&!N(n);){let i=r;i.innerHTML=s.outerHTML,s=i,n=n.parentNode,r=n.cloneNode(),t=T(r,e)}e=t||e}}}let c=i(e,n,!0)[r-1],d=c?c.parentNode:e;d.insertBefore(s,d.contains(n)?n:null)};var L=e=>e&&e.remove();const D={"font-family":"","font-weight":"","font-size":"","font-style":"","line-height":"",color:"","margin-left":"-.125em","margin-right":".125em"};function E(u,N={}){const T=async(e,t)=>(G.frozen&&await new Promise(e=>{this.unfreeze=()=>{G.frozen=!1,e()}}),await(async(e,t,n)=>new Promise(r=>{n.push(setTimeout(async()=>{await e(),r()},t))}))(e,t,Q)),E=()=>w(j),$=e=>function(e){let{speed:t,deleteSpeed:n,lifeLike:r}=e;return n=null!==n?n:t/3,r?[v(t,b(t)),v(n,b(n))]:[t,n]}(J)[e],x=(e,t=0)=>e?$(t):0,C=(e,t)=>(W.add(e),((e={})=>{let t=e.delay;t&&W.add([[B,t]])})(t),this),H=()=>(e=>w(e)?n(e.value):i(e,h(".ti-cursor",e),!0))(j),z=(e={})=>[[P,e],[P,J]],k=e=>{let t=J.nextStringDelay;W.add([[B,t[0]],...e,[B,t[1]]])},R=e=>{X&&(Z.classList.toggle("disabled",e),Z.classList.toggle("with-delay",!e))},A=async()=>{G.started=!0;let e,t=W.getItems();try{for(let n=0;n<t.length;n++){let r=t[n],i=r[2];e=[r,this],i.freezeCursor&&R(!0),await J.beforeStep(...e),await r[0].call(this,r[1],i),await J.afterStep(...e),W.setMeta(n,{executed:!0}),R(!1)}if(G.completed=!0,await J.afterComplete(...e),!J.loop)throw"";let n=J.loopDelay;T(async()=>{await(async e=>{Y&&await I({value:Y}),W.reset(),W.set(0,[B,e,{}]),await q({num:null})})(n[0]),A()},n[1])}catch(e){}return this},B=(e=0)=>T(()=>{},e),I=async({value:e,to:t="START",instant:n=!1})=>{let r=y({el:j,move:e,cursorPos:Y,to:t}),i=()=>{Y+=r<0?-1:1,((e,t,n,r)=>{let i=t[Math.min(r,t.length)-1];(e=(null==i?void 0:i.parentNode)||e).insertBefore(n,i||null)})(j,H(),Z,Y)};await T(async()=>{for(let e=0;e<Math.abs(r);e++)n?i():await T(i,$(0))},x(n))},O=({chars:e,instant:t,silent:n})=>T(async()=>{const r=e=>M(j,e,Z,Y);n||await J.beforeString(e);for(let n=0;n<e.length;n++)t?r(e[n]):await T(()=>{r(e[n])},$(0));n||await J.afterString(e)},x(t)),P=async e=>{J=t(J,e)},V=async()=>{E()?j.value="":H().forEach(e=>{L(e)})},q=async({num:e=null,instant:t=!1,to:n="START"})=>{await T(async()=>{let r=f(e)?e:y({el:j,move:e,cursorPos:Y,to:n});const i=()=>{let e=H();var t;e.length&&(E()?j.value=j.value.slice(0,-1):(L(e[Y]),t=Z,h("*",j,!0).forEach(e=>{if(!e.innerHTML&&"BR"!==e.tagName&&!e.isSameNode(t)){let t=e;for(;1===t.parentElement.childNodes.length;)t=t.parentElement;L(t)}})))};for(let e=0;e<r;e++)t?i():await T(i,$(1))},x(t,1)),null===e&&H().length-1>0&&await q({num:null})};this.break=function(e){const t=a(s("BR"));return C([[O,{chars:[t],silent:!0}]],e)},this.delete=function(e=null,t={}){e=S(e);let n=z(t),r=e,{instant:i,to:a}=t;return C([n[0],[q,{num:r,instant:i,to:a},F],n[1]],t)},this.empty=function(e={}){return C([[V]],e)},this.exec=function(e,t){let n=z(t);return C([n[0],[e,null],n[1]],t)},this.move=function(e,t={}){e=S(e);let n=z(t),{instant:r,to:i}=t;return C([n[0],[I,{value:null===e?"":e,to:i,instant:r},F],n[1]],t)},this.options=function(e){return e=S(e),C([[P,e]],e)},this.pause=function(e,t={}){return C([[B,S(e)]],t)},this.type=function(e,t={}){e=S(e);let n=z(t),r=o(e,J.html),{instant:i}=t;return C([n[0],[O,{chars:r,instant:i},F],n[1]],t)},this.is=function(e){return G[e]},this.destroy=function(e=!0){Q.forEach(e=>clearTimeout(e)),Q=[],S(e)&&L(Z),G.destroyed=!0},this.freeze=function(){G.frozen=!0},this.unfreeze=function(){},this.reset=function(){!this.is("destroyed")&&this.destroy(),W.reset(),Y=0;for(let e in G)G[e]=!1;return j[E()?"value":"innerHTML"]="",this},this.go=function(){return G.started?this:((async()=>{!E()&&j.appendChild(Z),X&&((e,t,n)=>{let r=`[data-typeit-id='${e}'] .ti-cursor`,i=getComputedStyle(n),a=Object.entries(D).reduce((e,[t,n])=>`${e} ${t}: var(--ti-${t}, ${n||i[t]});`,"");c(`@keyframes blink-${e} { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ${r} { display: inline; letter-spacing: -1em; ${a} animation: blink-${e} ${t.cursorSpeed/1e3}s infinite; } ${r}.with-delay { animation-delay: 500ms; } ${r}.disabled { animation: none; }`,e)})(K,J,j)})(),J.waitUntilVisible?(((e,t)=>{new IntersectionObserver((n,r)=>{n.forEach(n=>{n.isIntersecting&&(t(),r.unobserve(e))})},{threshold:1}).observe(e)})(j,A.bind(this)),this):(A(),this))},this.getQueue=function(){return W},this.getOptions=function(){return J},this.getElement=function(){return j};let j="string"==typeof(U=u)?h(U):U;var U;let Q=[],Y=0,F={freezeCursor:!0},G=t({},m),J=t(p,N);J=t(J,{html:!E()&&J.html,nextStringDelay:g(J.nextStringDelay),loopDelay:g(J.loopDelay)});let K=Math.random().toString().substring(2,9),W=function(n){const r=function(t){return i=i.concat(t.map(t=>e.map((e,n)=>t[n]?t[n]:e))),this};let i=[];return r(n),{add:r,set:function(e,t){i[e]=t},reset:function(){i=i.map(e=>(e[2].executed=!1,e))},getItems:function(){return i.filter(e=>!e[2].executed)},setMeta:function(e,n){i[e][2]=t(i[e][2],n)}}}([[B,J.startDelay]]);j.dataset.typeitId=K,c("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}");let X=J.cursor&&!E(),Z=(()=>{if(E())return;let e=s("span");return e.className="ti-cursor",X?(e.innerHTML=r(J.cursorChar).innerHTML,e):(e.style.visibility="hidden",e)})();var _;J.strings=(e=>{let t=j.innerHTML;return t?(j.innerHTML="",J.startDelete?(l(t).forEach(e=>{M(j,e,Z,Y)}),k([[q,{num:null}]]),e):t.trim().split(/<br(?:\s*?)(?:\/)?>/).concat(e)):e})(d(_=J.strings)?_:[_]),J.strings.length&&(()=>{let e=J.strings.filter(e=>!!e);e.forEach((t,n)=>{let r=o(t,J.html);if(W.add([[O,{chars:r},F]]),n+1===e.length)return;const i=J.breakLines?[[O,{chars:[a(s("BR"))]},F]]:[[q,{num:r.length},F]];k(i)})})()}export{E as default}; |
// TypeIt by Alex MacArthur - https://typeitjs.com | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).TypeIt=t()}(this,function(){const e=[null,null,{}];var t=(e,t)=>Object.assign({},e,t),n=e=>Array.from(e),r=e=>{let t=document.implementation.createHTMLDocument();return t.body.innerHTML=e,t.body};const o=(e,t=null,r=!1)=>{let i=n(e.childNodes).flatMap(e=>{return 3===(t=e).nodeType||"BR"===t.tagName?e:o(e);var t});return t&&(i=i.filter(e=>!t.contains(e))),r?i.reverse():i},i=(e,t=null)=>({node:t,content:e});function s(e){let t=r(e);return o(t).flatMap(e=>e.nodeValue?n(e.nodeValue).map(t=>i(t,e)):i(e))}function u(e,t=!0){return t?s(e):n(e).map(e=>i(e))}var l=e=>document.createElement(e),c=e=>document.createTextNode(e),a=(e,t="")=>{let n=l("style");n.id=t,n.appendChild(c(e)),document.head.appendChild(n)},f=e=>Array.isArray(e);const h=e=>Number.isInteger(e),d=(e,t=document,n=!1)=>t["querySelector"+(n?"All":"")](e),m="ti-cursor",v="START",p={started:!1,completed:!1,frozen:!1,destroyed:!1},y={breakLines:!0,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,html:!0,lifeLike:!0,loop:!1,loopDelay:750,nextStringDelay:750,speed:100,startDelay:250,startDelete:!1,strings:[],waitUntilVisible:!1,beforeString:()=>{},afterString:()=>{},beforeStep:()=>{},afterStep:()=>{},afterComplete:()=>{}},g=(e,t,n=v)=>{let r=new RegExp("END","i").test(n),i=d(".ti-cursor",t),s=e?d(e,t):t,u=o(s,i,!0),l=u[0],c=u[u.length-1],a=r&&!e?0:o(t,i,!0).findIndex(e=>e.isSameNode(r?l:c));return r&&a--,a+1};var P=e=>(f(e)||(e=[e/2,e/2]),e),b=(e,t)=>Math.abs(Math.random()*(e+t-(e-t))+(e-t));let N=e=>e/2;var S=e=>"value"in e;const M=e=>"function"==typeof e?e():e;var T=e=>"BODY"===e.tagName;const j=(e,t)=>{let r=n(d("*",t,!0));return[t].concat(r.reverse()).find(t=>t.cloneNode().isEqualNode(e.cloneNode()))},L=(e,t,n,r)=>{let i=t.content instanceof HTMLElement,s=t.node,u=null==s?void 0:s.parentNode,l=i?t.content:c(t.content);if(S(e))return void(e.value=""+e.value+t.content);if(!i&&u&&!T(u)){let r=j(u,e);if(r&&((e,t)=>{let n=e.nextSibling;return!n||n.isEqualNode(t)})(r,n))e=r;else{l=u.cloneNode(),l.appendChild(c(t.content));let n=u.parentNode,r=n.cloneNode();if(!T(n)){let t=j(r,e);for(;!t&&!T(n);){let o=r;o.innerHTML=l.outerHTML,l=o,n=n.parentNode,r=n.cloneNode(),t=j(r,e)}e=t||e}}}let a=o(e,n,!0)[r-1],f=a?a.parentNode:e;f.insertBefore(l,f.contains(n)?n:null)};var w=e=>e&&e.remove();const D={"font-family":"","font-weight":"","font-size":"","font-style":"","line-height":"",color:"","margin-left":"-.125em","margin-right":".125em"};function E(e,t,n){if(!e.s){if(n instanceof x){if(!n.s)return void(n.o=E.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(E.bind(null,e,t),E.bind(null,e,2));e.s=t,e.v=n;const r=e.o;r&&r(e)}}const x=function(){function e(){}return e.prototype.then=function(t,n){const r=new e,o=this.s;if(o){const e=1&o?t:n;if(e){try{E(r,1,e(this.v))}catch(e){E(r,2,e)}return r}return this}return this.o=function(e){try{const o=e.v;1&e.s?E(r,1,t?t(o):o):n?E(r,1,n(o)):E(r,2,o)}catch(e){E(r,2,e)}},r},e}();function k(e){return e instanceof x&&1&e.s}function C(e,t,n){var r,o,i=-1;return function s(u){try{for(;++i<e.length&&(!n||!n());)if((u=t(i))&&u.then){if(!k(u))return void u.then(s,o||(o=E.bind(null,r=new x,2)));u=u.v}r?E(r,1,u):r=u}catch(e){E(r||(r=new x),2,e)}}(),r}function H(e,t,n){for(var r;;){var o=e();if(k(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=n();if(i&&i.then){if(!k(i)){r=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!k(s)){r=2;break}}}var u=new x,l=E.bind(null,u,2);return(0===r?o.then(a):1===r?i.then(c):s.then(f)).then(void 0,l),u;function c(r){i=r;do{if(t&&(s=t())&&s.then&&!k(s))return void s.then(f).then(void 0,l);if(!(o=e())||k(o)&&!o.v)return void E(u,1,i);if(o.then)return void o.then(a).then(void 0,l);k(i=n())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,l)}function a(e){e?(i=n())&&i.then?i.then(c).then(void 0,l):c(i):E(u,1,i)}function f(){(o=e())?o.then?o.then(a).then(void 0,l):a(o):E(u,1,i)}}return function(c,T={}){const j=this,E=function(e,t){try{return Promise.resolve(function(e,t,n){try{return Promise.resolve(new Promise(r=>{n.push(setTimeout(function(){try{return Promise.resolve(e()).then(function(){r()})}catch(e){return Promise.reject(e)}},t))}))}catch(e){return Promise.reject(e)}}(e,t,W))}catch(e){return Promise.reject(e)}},x=()=>S(J),k=e=>function(e){let{speed:t,deleteSpeed:n,lifeLike:r}=e;return n=null!==n?n:t/3,r?[b(t,N(t)),b(n,N(n))]:[t,n]}(_)[e],z=(e,t=0)=>e?k(t):0,I=(e,t)=>(te.add(e),((e={})=>{let t=e.delay;t&&te.add([[q,t]])})(t),this),B=()=>(e=>S(e)?n(e.value):o(e,d(".ti-cursor",e),!0))(J),R=(e={})=>[[Y,e],[Y,_]],A=e=>{let t=_.nextStringDelay;te.add([[q,t[0]],...e,[q,t[1]]])},O=e=>{ne&&(re.classList.toggle("disabled",e),re.classList.toggle("with-delay",!e))},V=function(){try{let e;$.started=!0;let t,n=te.getItems();const r=function(r,o){try{var i=function(){function r(e){return $.completed=!0,Promise.resolve(_.afterComplete(...t)).then(function(){if(!_.loop)throw"";let e=_.loopDelay;E(function(){try{return Promise.resolve(function(e){try{function t(t){return te.reset(),te.set(0,[q,e,{}]),Promise.resolve(G({num:null})).then(function(){})}return Promise.resolve(X?Promise.resolve(U({value:X})).then(t):t())}catch(e){return Promise.reject(e)}}(e[0])).then(function(){V()})}catch(e){return Promise.reject(e)}},e[1])})}const o=C(n,function(e){if($.frozen||$.destroyed)throw"";let r=n[e],o=r[2];return t=[r,j],o.freezeCursor&&O(!0),Promise.resolve(_.beforeStep(...t)).then(function(){return Promise.resolve(r[0].call(j,r[1],o)).then(function(){return Promise.resolve(_.afterStep(...t)).then(function(){te.setMeta(e,{executed:!0}),O(!1)})})})},function(){return e});return o&&o.then?o.then(r):r()}()}catch(e){return}return i&&i.then?i.then(void 0,function(){}):i}();return Promise.resolve(r&&r.then?r.then(function(t){return e?t:j}):e?r:j)}catch(e){return Promise.reject(e)}},q=(e=0)=>E(()=>{},e),U=function({value:e,to:t=v,instant:n=!1}){try{let r=(({el:e,move:t,cursorPos:n,to:r})=>h(t)?-1*t:g(t,e,r)-n)({el:J,move:e,cursorPos:X,to:t}),o=()=>{X+=r<0?-1:1,((e,t,n,r)=>{let o=t[Math.min(r,t.length)-1];(e=(null==o?void 0:o.parentNode)||e).insertBefore(n,o||null)})(J,B(),re,X)};return Promise.resolve(E(function(){try{let e=0;const t=H(function(){return e<Math.abs(r)},function(){return e++},function(){return n?void o():Promise.resolve(E(o,k(0))).then(function(e){})});return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},z(n))).then(function(){})}catch(e){return Promise.reject(e)}},Q=({chars:e,instant:t,silent:n})=>E(function(){try{function r(r){function i(){return n?void 0:Promise.resolve(_.afterString(e)).then(function(e){})}const s=C(e,function(n){return t?void o(e[n]):Promise.resolve(E(()=>{o(e[n])},k(0))).then(function(e){})});return s&&s.then?s.then(i):i()}const o=e=>L(J,e,re,X);return Promise.resolve(n?r():Promise.resolve(_.beforeString(e)).then(r))}catch(e){return Promise.reject(e)}},z(t)),Y=function(e){try{return _=t(_,e),Promise.resolve()}catch(e){return Promise.reject(e)}},F=function(){try{return x()?(J.value="",Promise.resolve()):(B().forEach(e=>{w(e)}),Promise.resolve())}catch(e){return Promise.reject(e)}},G=function({num:e=null,instant:t=!1,to:n=v}){try{const r=e=>h(e)?e:g(e,J,n);return Promise.resolve(E(function(){try{let n=r(e);const o=()=>{let e=B();var t;e.length&&(x()?J.value=J.value.slice(0,-1):(w(e[X]),t=re,d("*",J,!0).forEach(e=>{if(!e.innerHTML&&"BR"!==e.tagName&&!e.isSameNode(t)){let t=e;for(;1===t.parentElement.childNodes.length;)t=t.parentElement;w(t)}})))};let i=0;const s=H(function(){return i<n},function(){return i++},function(){return t?void o():Promise.resolve(E(o,k(1))).then(function(e){})});return Promise.resolve(s&&s.then?s.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},z(t,1))).then(function(){const t=function(){if(null===e&&B().length-1>0)return Promise.resolve(G({num:null})).then(function(){})}();if(t&&t.then)return t.then(function(){})})}catch(e){return Promise.reject(e)}};this.break=function(e){const t=i(l("BR"));return I([[Q,{chars:[t],silent:!0}]],e)},this.delete=function(e=null,t={}){e=M(e);let n=R(t),r=e,{instant:o,to:i}=t;return I([n[0],[G,{num:r,instant:o,to:i},Z],n[1]],t)},this.empty=function(e={}){return I([[F]],e)},this.exec=function(e,t){let n=R(t);return I([n[0],[e,null],n[1]],t)},this.move=function(e,t={}){e=M(e);let n=R(t),{instant:r,to:o}=t;return I([n[0],[U,{value:null===e?"":e,to:o,instant:r},Z],n[1]],t)},this.options=function(e){return e=M(e),I([[Y,e]],e)},this.pause=function(e,t={}){return I([[q,M(e)]],t)},this.type=function(e,t={}){e=M(e);let n=R(t),r=u(e,_.html),{instant:o}=t;return I([n[0],[Q,{chars:r,instant:o},Z],n[1]],t)},this.is=function(e){return $[e]},this.destroy=function(e=!0){W.forEach(e=>clearTimeout(e)),W=[],M(e)&&w(re),$.destroyed=!0},this.freeze=function(){$.frozen=!0},this.unfreeze=function(){$.frozen=!1,V()},this.reset=function(){!this.is("destroyed")&&this.destroy(),te.reset(),X=0;for(let e in $)$[e]=!1;return J[x()?"value":"innerHTML"]="",this},this.go=function(){return $.started?this:(function(){try{!x()&&J.appendChild(re),ne?(((e,t,n)=>{let r="[data-typeit-id='"+e+"'] ."+m,o=getComputedStyle(n),i=Object.entries(D).reduce((e,[t,n])=>e+" "+t+": var(--ti-"+t+", "+(n||o[t])+");","");a("@keyframes blink-"+e+" { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } "+r+" { display: inline; letter-spacing: -1em; "+i+" animation: blink-"+e+" "+t.cursorSpeed/1e3+"s infinite; } "+r+".with-delay { animation-delay: 500ms; } "+r+".disabled { animation: none; }",e)})(ee,_,J),Promise.resolve()):Promise.resolve()}catch(e){return Promise.reject(e)}}(),_.waitUntilVisible?(((e,t)=>{new IntersectionObserver((n,r)=>{n.forEach(n=>{n.isIntersecting&&(t(),r.unobserve(e))})},{threshold:1}).observe(e)})(J,V.bind(this)),this):(V(),this))},this.getQueue=function(){return te},this.getOptions=function(){return _},this.getElement=function(){return J};let J="string"==typeof(K=c)?d(K):K;var K;let W=[],X=0,Z={freezeCursor:!0},$=t({},p),_=t(y,T);_=t(_,{html:!x()&&_.html,nextStringDelay:P(_.nextStringDelay),loopDelay:P(_.loopDelay)});let ee=Math.random().toString().substring(2,9),te=function(n){const r=function(t){return o=o.concat(t.map(t=>e.map((e,n)=>t[n]?t[n]:e))),this};let o=[];return r(n),{add:r,set:function(e,t){o[e]=t},reset:function(){o=o.map(e=>(e[2].executed=!1,e))},getItems:function(){return o.filter(e=>!e[2].executed)},setMeta:function(e,n){o[e][2]=t(o[e][2],n)}}}([[q,_.startDelay]]);J.dataset.typeitId=ee,a("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}");let ne=_.cursor&&!x(),re=(()=>{if(x())return;let e=l("span");return e.className=m,ne?(e.innerHTML=r(_.cursorChar).innerHTML,e):(e.style.visibility="hidden",e)})();var oe;_.strings=(e=>{let t=J.innerHTML;return t?(J.innerHTML="",_.startDelete?(s(t).forEach(e=>{L(J,e,re,X)}),A([[G,{num:null}]]),e):t.trim().split(/<br(?:\s*?)(?:\/)?>/).concat(e)):e})(f(oe=_.strings)?oe:[oe]),_.strings.length&&(()=>{let e=_.strings.filter(e=>!!e);e.forEach((t,n)=>{let r=u(t,_.html);if(te.add([[Q,{chars:r},Z]]),n+1===e.length)return;const o=_.breakLines?[[Q,{chars:[i(l("BR"))]},Z]]:[[G,{num:r.length},Z]];A(o)})})()}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).TypeIt=t()}(this,function(){const e=[null,null,{}];var t=(e,t)=>Object.assign({},e,t),n=e=>Array.from(e),r=e=>{let t=document.implementation.createHTMLDocument();return t.body.innerHTML=e,t.body};const o=(e,t=null,r=!1)=>{let i=n(e.childNodes).flatMap(e=>{return 3===(t=e).nodeType||"BR"===t.tagName?e:o(e);var t});return t&&(i=i.filter(e=>!t.contains(e))),r?i.reverse():i},i=(e,t=null)=>({node:t,content:e});function s(e){let t=r(e);return o(t).flatMap(e=>e.nodeValue?n(e.nodeValue).map(t=>i(t,e)):i(e))}function u(e,t=!0){return t?s(e):n(e).map(e=>i(e))}var l=e=>document.createElement(e),c=e=>document.createTextNode(e),a=(e,t="")=>{let n=l("style");n.id=t,n.appendChild(c(e)),document.head.appendChild(n)},f=e=>Array.isArray(e);const h=e=>Number.isInteger(e),d=(e,t=document,n=!1)=>t["querySelector"+(n?"All":"")](e),m="ti-cursor",v="START",p={started:!1,completed:!1,frozen:!1,destroyed:!1},y={breakLines:!0,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,html:!0,lifeLike:!0,loop:!1,loopDelay:750,nextStringDelay:750,speed:100,startDelay:250,startDelete:!1,strings:[],waitUntilVisible:!1,beforeString:()=>{},afterString:()=>{},beforeStep:()=>{},afterStep:()=>{},afterComplete:()=>{}};var g=({el:e,move:t,cursorPos:n,to:r})=>h(t)?-1*t:((e,t,n=v)=>{let r=new RegExp("END","i").test(n),i=d(".ti-cursor",t),s=e?d(e,t):t,u=o(s,i,!0),l=u[0],c=u[u.length-1],a=r&&!e?0:o(t,i,!0).findIndex(e=>e.isSameNode(r?l:c));return r&&a--,a+1})(t,e,r)-n,P=e=>(f(e)||(e=[e/2,e/2]),e),b=(e,t)=>Math.abs(Math.random()*(e+t-(e-t))+(e-t));let N=e=>e/2;var S=e=>"value"in e;const M=e=>"function"==typeof e?e():e;var T=e=>"BODY"===e.tagName;const j=(e,t)=>{let r=n(d("*",t,!0));return[t].concat(r.reverse()).find(t=>t.cloneNode().isEqualNode(e.cloneNode()))},L=(e,t,n,r)=>{let i=t.content instanceof HTMLElement,s=t.node,u=null==s?void 0:s.parentNode,l=i?t.content:c(t.content);if(S(e))return void(e.value=""+e.value+t.content);if(!i&&u&&!T(u)){let r=j(u,e);if(r&&((e,t)=>{let n=e.nextSibling;return!n||n.isEqualNode(t)})(r,n))e=r;else{l=u.cloneNode(),l.appendChild(c(t.content));let n=u.parentNode,r=n.cloneNode();if(!T(n)){let t=j(r,e);for(;!t&&!T(n);){let o=r;o.innerHTML=l.outerHTML,l=o,n=n.parentNode,r=n.cloneNode(),t=j(r,e)}e=t||e}}}let a=o(e,n,!0)[r-1],f=a?a.parentNode:e;f.insertBefore(l,f.contains(n)?n:null)};var w=e=>e&&e.remove();const D={"font-family":"","font-weight":"","font-size":"","font-style":"","line-height":"",color:"","margin-left":"-.125em","margin-right":".125em"};function E(e,t,n){if(!e.s){if(n instanceof x){if(!n.s)return void(n.o=E.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(E.bind(null,e,t),E.bind(null,e,2));e.s=t,e.v=n;const r=e.o;r&&r(e)}}const x=function(){function e(){}return e.prototype.then=function(t,n){const r=new e,o=this.s;if(o){const e=1&o?t:n;if(e){try{E(r,1,e(this.v))}catch(e){E(r,2,e)}return r}return this}return this.o=function(e){try{const o=e.v;1&e.s?E(r,1,t?t(o):o):n?E(r,1,n(o)):E(r,2,o)}catch(e){E(r,2,e)}},r},e}();function k(e){return e instanceof x&&1&e.s}function C(e,t,n){var r,o,i=-1;return function s(u){try{for(;++i<e.length&&(!n||!n());)if((u=t(i))&&u.then){if(!k(u))return void u.then(s,o||(o=E.bind(null,r=new x,2)));u=u.v}r?E(r,1,u):r=u}catch(e){E(r||(r=new x),2,e)}}(),r}function H(e,t,n){for(var r;;){var o=e();if(k(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=n();if(i&&i.then){if(!k(i)){r=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!k(s)){r=2;break}}}var u=new x,l=E.bind(null,u,2);return(0===r?o.then(a):1===r?i.then(c):s.then(f)).then(void 0,l),u;function c(r){i=r;do{if(t&&(s=t())&&s.then&&!k(s))return void s.then(f).then(void 0,l);if(!(o=e())||k(o)&&!o.v)return void E(u,1,i);if(o.then)return void o.then(a).then(void 0,l);k(i=n())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,l)}function a(e){e?(i=n())&&i.then?i.then(c).then(void 0,l):c(i):E(u,1,i)}function f(){(o=e())?o.then?o.then(a).then(void 0,l):a(o):E(u,1,i)}}return function(c,T={}){const j=this,E=this,x=function(e,t){try{function n(){return Promise.resolve(function(e,t,n){try{return Promise.resolve(new Promise(r=>{n.push(setTimeout(function(){try{return Promise.resolve(e()).then(function(){r()})}catch(e){return Promise.reject(e)}},t))}))}catch(e){return Promise.reject(e)}}(e,t,X))}const r=function(){if(_.frozen)return Promise.resolve(new Promise(e=>{j.unfreeze=()=>{_.frozen=!1,e()}})).then(function(){})}();return Promise.resolve(r&&r.then?r.then(n):n())}catch(e){return Promise.reject(e)}},k=()=>S(K),z=e=>function(e){let{speed:t,deleteSpeed:n,lifeLike:r}=e;return n=null!==n?n:t/3,r?[b(t,N(t)),b(n,N(n))]:[t,n]}(ee)[e],I=(e,t=0)=>e?z(t):0,B=(e,t)=>(ne.add(e),((e={})=>{let t=e.delay;t&&ne.add([[U,t]])})(t),this),R=()=>(e=>S(e)?n(e.value):o(e,d(".ti-cursor",e),!0))(K),A=(e={})=>[[F,e],[F,ee]],O=e=>{let t=ee.nextStringDelay;ne.add([[U,t[0]],...e,[U,t[1]]])},V=e=>{re&&(oe.classList.toggle("disabled",e),oe.classList.toggle("with-delay",!e))},q=function(){try{let e;_.started=!0;let t,n=ne.getItems();const r=function(e,r){try{var o=function(){function e(){return _.completed=!0,Promise.resolve(ee.afterComplete(...t)).then(function(){if(!ee.loop)throw"";let e=ee.loopDelay;x(function(){try{return Promise.resolve(function(e){try{function t(t){return ne.reset(),ne.set(0,[U,e,{}]),Promise.resolve(J({num:null})).then(function(){})}return Promise.resolve(Z?Promise.resolve(Q({value:Z})).then(t):t())}catch(e){return Promise.reject(e)}}(e[0])).then(function(){q()})}catch(e){return Promise.reject(e)}},e[1])})}const r=C(n,function(e){let r=n[e],o=r[2];return t=[r,E],o.freezeCursor&&V(!0),Promise.resolve(ee.beforeStep(...t)).then(function(){return Promise.resolve(r[0].call(E,r[1],o)).then(function(){return Promise.resolve(ee.afterStep(...t)).then(function(){ne.setMeta(e,{executed:!0}),V(!1)})})})});return r&&r.then?r.then(e):e()}()}catch(e){return}return o&&o.then?o.then(void 0,function(){}):o}();return Promise.resolve(r&&r.then?r.then(function(t){return e?t:E}):e?r:E)}catch(e){return Promise.reject(e)}},U=(e=0)=>x(()=>{},e),Q=function({value:e,to:t=v,instant:n=!1}){try{let r=g({el:K,move:e,cursorPos:Z,to:t}),o=()=>{Z+=r<0?-1:1,((e,t,n,r)=>{let o=t[Math.min(r,t.length)-1];(e=(null==o?void 0:o.parentNode)||e).insertBefore(n,o||null)})(K,R(),oe,Z)};return Promise.resolve(x(function(){try{let e=0;const t=H(function(){return e<Math.abs(r)},function(){return e++},function(){return n?void o():Promise.resolve(x(o,z(0))).then(function(e){})});return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},I(n))).then(function(){})}catch(e){return Promise.reject(e)}},Y=({chars:e,instant:t,silent:n})=>x(function(){try{function r(r){function i(){return n?void 0:Promise.resolve(ee.afterString(e)).then(function(e){})}const s=C(e,function(n){return t?void o(e[n]):Promise.resolve(x(()=>{o(e[n])},z(0))).then(function(e){})});return s&&s.then?s.then(i):i()}const o=e=>L(K,e,oe,Z);return Promise.resolve(n?r():Promise.resolve(ee.beforeString(e)).then(r))}catch(e){return Promise.reject(e)}},I(t)),F=function(e){try{return ee=t(ee,e),Promise.resolve()}catch(e){return Promise.reject(e)}},G=function(){try{return k()?(K.value="",Promise.resolve()):(R().forEach(e=>{w(e)}),Promise.resolve())}catch(e){return Promise.reject(e)}},J=function({num:e=null,instant:t=!1,to:n=v}){try{return Promise.resolve(x(function(){try{let r=h(e)?e:g({el:K,move:e,cursorPos:Z,to:n});const o=()=>{let e=R();var t;e.length&&(k()?K.value=K.value.slice(0,-1):(w(e[Z]),t=oe,d("*",K,!0).forEach(e=>{if(!e.innerHTML&&"BR"!==e.tagName&&!e.isSameNode(t)){let t=e;for(;1===t.parentElement.childNodes.length;)t=t.parentElement;w(t)}})))};let i=0;const s=H(function(){return i<r},function(){return i++},function(){return t?void o():Promise.resolve(x(o,z(1))).then(function(e){})});return Promise.resolve(s&&s.then?s.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},I(t,1))).then(function(){const t=function(){if(null===e&&R().length-1>0)return Promise.resolve(J({num:null})).then(function(){})}();if(t&&t.then)return t.then(function(){})})}catch(e){return Promise.reject(e)}};this.break=function(e){const t=i(l("BR"));return B([[Y,{chars:[t],silent:!0}]],e)},this.delete=function(e=null,t={}){e=M(e);let n=A(t),r=e,{instant:o,to:i}=t;return B([n[0],[J,{num:r,instant:o,to:i},$],n[1]],t)},this.empty=function(e={}){return B([[G]],e)},this.exec=function(e,t){let n=A(t);return B([n[0],[e,null],n[1]],t)},this.move=function(e,t={}){e=M(e);let n=A(t),{instant:r,to:o}=t;return B([n[0],[Q,{value:null===e?"":e,to:o,instant:r},$],n[1]],t)},this.options=function(e){return e=M(e),B([[F,e]],e)},this.pause=function(e,t={}){return B([[U,M(e)]],t)},this.type=function(e,t={}){e=M(e);let n=A(t),r=u(e,ee.html),{instant:o}=t;return B([n[0],[Y,{chars:r,instant:o},$],n[1]],t)},this.is=function(e){return _[e]},this.destroy=function(e=!0){X.forEach(e=>clearTimeout(e)),X=[],M(e)&&w(oe),_.destroyed=!0},this.freeze=function(){_.frozen=!0},this.unfreeze=function(){},this.reset=function(){!this.is("destroyed")&&this.destroy(),ne.reset(),Z=0;for(let e in _)_[e]=!1;return K[k()?"value":"innerHTML"]="",this},this.go=function(){return _.started?this:(function(){try{!k()&&K.appendChild(oe),re?(((e,t,n)=>{let r="[data-typeit-id='"+e+"'] ."+m,o=getComputedStyle(n),i=Object.entries(D).reduce((e,[t,n])=>e+" "+t+": var(--ti-"+t+", "+(n||o[t])+");","");a("@keyframes blink-"+e+" { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } "+r+" { display: inline; letter-spacing: -1em; "+i+" animation: blink-"+e+" "+t.cursorSpeed/1e3+"s infinite; } "+r+".with-delay { animation-delay: 500ms; } "+r+".disabled { animation: none; }",e)})(te,ee,K),Promise.resolve()):Promise.resolve()}catch(e){return Promise.reject(e)}}(),ee.waitUntilVisible?(((e,t)=>{new IntersectionObserver((n,r)=>{n.forEach(n=>{n.isIntersecting&&(t(),r.unobserve(e))})},{threshold:1}).observe(e)})(K,q.bind(this)),this):(q(),this))},this.getQueue=function(){return ne},this.getOptions=function(){return ee},this.getElement=function(){return K};let K="string"==typeof(W=c)?d(W):W;var W;let X=[],Z=0,$={freezeCursor:!0},_=t({},p),ee=t(y,T);ee=t(ee,{html:!k()&&ee.html,nextStringDelay:P(ee.nextStringDelay),loopDelay:P(ee.loopDelay)});let te=Math.random().toString().substring(2,9),ne=function(n){const r=function(t){return o=o.concat(t.map(t=>e.map((e,n)=>t[n]?t[n]:e))),this};let o=[];return r(n),{add:r,set:function(e,t){o[e]=t},reset:function(){o=o.map(e=>(e[2].executed=!1,e))},getItems:function(){return o.filter(e=>!e[2].executed)},setMeta:function(e,n){o[e][2]=t(o[e][2],n)}}}([[U,ee.startDelay]]);K.dataset.typeitId=te,a("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}");let re=ee.cursor&&!k(),oe=(()=>{if(k())return;let e=l("span");return e.className=m,re?(e.innerHTML=r(ee.cursorChar).innerHTML,e):(e.style.visibility="hidden",e)})();var ie;ee.strings=(e=>{let t=K.innerHTML;return t?(K.innerHTML="",ee.startDelete?(s(t).forEach(e=>{L(K,e,oe,Z)}),O([[J,{num:null}]]),e):t.trim().split(/<br(?:\s*?)(?:\/)?>/).concat(e)):e})(f(ie=ee.strings)?ie:[ie]),ee.strings.length&&(()=>{let e=ee.strings.filter(e=>!!e);e.forEach((t,n)=>{let r=u(t,ee.html);if(ne.add([[Y,{chars:r},$]]),n+1===e.length)return;const o=ee.breakLines?[[Y,{chars:[i(l("BR"))]},$]]:[[J,{num:r.length},$]];O(o)})})()}}); |
{ | ||
"name": "typeit", | ||
"version": "8.0.0-rc.2", | ||
"version": "8.0.0-rc.3", | ||
"description": "The most versatile animated typing utility on the planet.", | ||
@@ -5,0 +5,0 @@ "author": "Alex MacArthur <alex@macarthur.me> (https://macarthur.me)", |
@@ -11,6 +11,6 @@ import { CURSOR_CLASS, DATA_ATTRIBUTE } from "../contants"; | ||
"line-height": "", | ||
"color": "", | ||
color: "", | ||
"margin-left": "-.125em", | ||
"margin-right": ".125em" | ||
} as const; | ||
"margin-right": ".125em", | ||
} as const; | ||
@@ -28,3 +28,5 @@ export const setCursorStyles = ( | ||
(accumulator, [item, value]) => { | ||
return `${accumulator} ${item}: var(--ti-${item}, ${value || computedStyles[item]});`; | ||
return `${accumulator} ${item}: var(--ti-${item}, ${ | ||
value || computedStyles[item] | ||
});`; | ||
}, | ||
@@ -36,3 +38,4 @@ "" | ||
appendStyleBlock( | ||
`@keyframes blink-${id} { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ${cursorSelector} { display: inline; letter-spacing: -1em; ${customProperties} animation: blink-${id} ${options.cursorSpeed / 1000 | ||
`@keyframes blink-${id} { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ${cursorSelector} { display: inline; letter-spacing: -1em; ${customProperties} animation: blink-${id} ${ | ||
options.cursorSpeed / 1000 | ||
}s infinite; } ${cursorSelector}.with-delay { animation-delay: 500ms; } ${cursorSelector}.disabled { animation: none; }`, | ||
@@ -39,0 +42,0 @@ id |
@@ -51,2 +51,11 @@ import Queue from "./Queue"; | ||
const _wait = async (callback: Function, delay: number) => { | ||
if (_statuses.frozen) { | ||
await new Promise<void>((resolve) => { | ||
this.unfreeze = () => { | ||
_statuses.frozen = false; | ||
resolve(); | ||
}; | ||
}); | ||
} | ||
return await wait(callback, delay, _timeouts); | ||
@@ -227,6 +236,2 @@ }; | ||
for (let i = 0; i < queueItems.length; i++) { | ||
if (_statuses.frozen || _statuses.destroyed) { | ||
throw ""; | ||
} | ||
let queueAction = queueItems[i]; | ||
@@ -370,12 +375,11 @@ let queueActionMeta = queueAction[2]; | ||
}): Promise<void> => { | ||
const _calculateDeleteSteps = (arg: any) => { | ||
if (isNumber(arg)) { | ||
return arg; | ||
} | ||
return calculateStepsToSelector(arg as string, _element, to); | ||
}; | ||
await _wait(async () => { | ||
let rounds = _calculateDeleteSteps(num); | ||
let rounds = isNumber(num) | ||
? num | ||
: calculateCursorSteps({ | ||
el: _element, | ||
move: num, | ||
cursorPos: _cursorPosition, | ||
to, | ||
}); | ||
@@ -523,9 +527,6 @@ const deleteIt = () => { | ||
this.freeze = function () { | ||
_statuses["frozen"] = true; | ||
_statuses.frozen = true; | ||
}; | ||
this.unfreeze = function () { | ||
_statuses["frozen"] = false; | ||
_fire(); | ||
}; | ||
this.unfreeze = function () {}; | ||
@@ -532,0 +533,0 @@ this.reset = function () { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
127098
1540