text: !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FPS={})}(this,(function(t){"use strict";var e=function(){return(e=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)},i={meter:!0,side:"bottom-right",FPS:60,tolerance:1,meterWidth:100,meterHeight:25,meterLineHeight:4,styles:{background:"rgba(0, 0, 0, 0.5)",color:"white"},stylesFPS:{padding:"0.1em 0.5em"},text:" FPS",colorGreen:"#00ff00",colorOrange:"#ffa500",colorRed:"#ff0000",zIndex:1e3},s=function(){function t(t){void 0===t&&(t={}),this.lastTime=0,this.frameNumber=0,this.lastFPS=0,this.options=e(e({},i),t),this.div=document.createElement("div"),this.findParent(this.options.side||"bottom-right").appendChild(this.div),this.style(this.div,this.options.styles),this.createDivFPS(),this.options.meter&&this.createDivMeter()}return Object.defineProperty(t.prototype,"fps",{get:function(){return this.options.FPS},set:function(t){this.options.FPS=t},enumerable:!1,configurable:!0}),t.prototype.remove=function(){this.div.remove()},Object.defineProperty(t.prototype,"meter",{get:function(){return this.options.meter},set:function(t){t?this.createDivMeter():this.meterCanvas&&(this.meterCanvas.style.display="none")},enumerable:!1,configurable:!0}),t.prototype.style=function(t,e){for(var i in e)t.style[i]=e[i]},t.prototype.createDivFPS=function(){var t=document.createElement("div");this.style(t,this.options.stylesFPS),this.div.appendChild(t),this.fpsSpan=document.createElement("span"),t.appendChild(this.fpsSpan);var e=document.createElement("span");t.appendChild(e),e.innerText=this.options.text},t.prototype.createDivMeter=function(){this.meterCanvas?this.meterCanvas.style.display="block":(this.meterCanvas=document.createElement("canvas"),this.div.appendChild(this.meterCanvas),this.meterCanvas.width=this.options.meterWidth,this.meterCanvas.height=this.options.meterHeight,this.meterCanvas.style.width=this.options.meterWidth+"px",this.meterCanvas.style.height=this.options.meterHeight+"px",this.style(this.meterCanvas,this.options.stylesMeter),this.meterContext=this.meterCanvas.getContext("2d"))},t.prototype.frame=function(){this.frameNumber++;var t=performance.now()-this.lastTime;t>500&&(0!==this.lastTime&&(this.lastFPS=Math.floor(this.frameNumber/(t/1e3)),(this.lastFPS>this.options.FPS||this.lastFPS>=this.options.FPS-this.options.tolerance&&this.lastFPS<=this.options.FPS+this.options.tolerance)&&(this.lastFPS=this.options.FPS)),this.lastTime=performance.now(),this.frameNumber=0),this.fpsSpan.innerText=0===this.lastFPS?"--":this.lastFPS+"",this.options.meter&&0!==this.lastFPS&&this.meterUpdate(this.lastFPS/this.options.FPS)},t.prototype.mix=function(t,e,i){var s=function(t){return{r:parseInt(t.substr(1,2),16),g:parseInt(t.substr(3,2),16),b:parseInt(t.substr(5,2),16)}},n=function(t){return 1===(t=Math.floor(t)).toString().length?"0"+t.toString(16):t.toString(16)},o=s(t),r=s(e);return"#"+n(o.r*i+r.r*(1-i))+n(o.g*i+r.g*(1-i))+n(o.b*i+r.b*(1-i))},t.prototype.meterUpdate=function(t){var e=this.meterContext.getImageData(0,0,this.meterCanvas.width,this.meterCanvas.height);this.meterContext.putImageData(e,-1,0),this.meterContext.clearRect(this.meterCanvas.width-1,0,1,this.meterCanvas.height),this.meterContext.fillStyle=t<=.5?this.mix(this.options.colorRed,this.options.colorOrange,1-2*t):this.mix(this.options.colorGreen,this.options.colorOrange,2*(t-.5));var i=(this.meterCanvas.height-this.options.meterLineHeight)*(1-t);this.meterContext.fillRect(this.meterCanvas.width-1,i,1,this.options.meterLineHeight)},t.prototype.findParent=function(t){var e=[],i="yy-counter-";-1!==t.indexOf("left")?(i+="left-",e.left=0):(i+="right-",e.right=0),-1!==t.indexOf("top")?(i+="top",e.top=0):(i+="bottom",e.bottom=0);var s=document.getElementById(i);if(s)return s;var n=document.createElement("div");for(var o in n.id=i,n.style.overflow="hidden",n.style.position="fixed",n.style.zIndex=this.options.zIndex.toString(),n.style.pointerEvents="none",n.style.userSelect="none",e)n.style[o]=e[o];return document.body.appendChild(n),n},t}();t.FPS=s,t.defaultFPSOptions=i,Object.defineProperty(t,"__esModule",{value:!0})}));
  //# sourceMappingURL=fps.min.js.map
  