import{cd as o,dp as n}from"./index-6Jqoo2rk.js";import{C as h}from"./emailSetup-CFcJlzt-.js";class p{constructor(i,t){this.inputField=i,this.size=t,this.max=45,this.needFrame=0,this.container=document.createElement("div"),this.container.classList.add("media-sticker-wrapper");const e=i.input;e.addEventListener("blur",()=>{this.playAnimation(0)}),i instanceof h?(e.addEventListener("focus",()=>{this.playAnimation(1)}),e.addEventListener("input",a=>{o(()=>{const s=(1+i.value.length)/i.options.length;this.playAnimation(s*this.max)})})):e.addEventListener("input",a=>{this.playAnimation(i.value.length)})}playAnimation(i){if(!this.animation)return;i=Math.min(i,30);let t;i?(t=Math.round(Math.min(this.max,i)*(165/this.max)+11.33),this.idleAnimation&&(this.idleAnimation.stop(!0),this.idleAnimation.canvas[0].style.display="none"),this.animation.canvas[0].style.display=""):t=0;const e=this.needFrame>t?-1:1;this.animation.setDirection(e),this.needFrame!==0&&t===0&&this.animation.setSpeed(7),this.needFrame=t,this.animation.play()}load(){return this.loadPromise?this.loadPromise:this.loadPromise=Promise.all([n.loadAnimationAsAsset({container:this.container,loop:!0,autoplay:!0,width:this.size,height:this.size},"TwoFactorSetupMonkeyIdle").then(i=>(this.idleAnimation=i,this.inputField.value.length||i.play(),n.waitForFirstFrame(i))),n.loadAnimationAsAsset({container:this.container,loop:!1,autoplay:!1,width:this.size,height:this.size},"TwoFactorSetupMonkeyTracking").then(i=>(this.animation=i,this.inputField.value.length||(this.animation.canvas[0].style.display="none"),this.animation.addEventListener("enterFrame",t=>{(this.animation.direction===1&&t>=this.needFrame||this.animation.direction===-1&&t<=this.needFrame)&&(this.animation.setSpeed(1),this.animation.pause()),t===0&&this.needFrame===0&&this.idleAnimation&&(this.idleAnimation.canvas[0].style.display="",this.idleAnimation.play(),this.animation.canvas[0].style.display="none")}),n.waitForFirstFrame(i)))])}remove(){this.animation&&this.animation.remove(),this.idleAnimation&&this.idleAnimation.remove()}}export{p as T};
//# sourceMappingURL=tracking-CIK7NCFD.js.map
