var u=Object.defineProperty;var l=(r,t,e)=>t in r?u(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var a=(r,t,e)=>(l(r,typeof t!="symbol"?t+"":t,e),e);import{m as g,C as p,e as S,R as d,f}from"./index-FcXwFJdn.js";var T=Object.defineProperty,_=Object.getOwnPropertyDescriptor,c=(r,t,e,m)=>{for(var s=m>1?void 0:m?_(t,e):t,i=r.length-1,o;i>=0;i--)(o=r[i])&&(s=(m?o(t,e,s):o(s))||s);return m&&s&&T(t,e,s),s};let n=class extends g(p){constructor(){super(...arguments);a(this,"cameraImage");a(this,"cameraImageSource","");a(this,"cameraImageSourceUrl",null);a(this,"requestStartTime",performance.now());a(this,"startTime",performance.now());a(this,"time",0);a(this,"requestTime",0);a(this,"timeSmoothing",.6);a(this,"requestTimeSmoothing",.1)}handleImageLoad(){const e=!document.hasFocus()&&this.camera.targetFpsIdle||this.camera.targetFps||10,m=performance.now(),s=m-this.startTime;this.time=this.time*this.timeSmoothing+s*(1-this.timeSmoothing),this.startTime=m;const i=1e3/e,o=performance.now()-this.requestStartTime;this.requestTime=this.requestTime*this.requestTimeSmoothing+o*(1-this.requestTimeSmoothing);const h=Math.max(0,i-this.requestTime);this.$nextTick(()=>{setTimeout(this.handleRefresh,h)})}handleRefresh(){if(document.hidden)this.stopPlayback();else{const e=Math.round(1e3/this.time).toString().padStart(2,"0");this.$emit("frames-per-second",e),this.$nextTick(()=>this.updateCameraImageSource())}}updateCameraImageSource(){const e=this.cameraImageSourceUrl;e&&(e.searchParams.set("cacheBust",Date.now().toString()),this.requestStartTime=performance.now(),this.cameraImageSource=e.toString())}startPlayback(){this.cameraImageSourceUrl=this.buildAbsoluteUrl(this.camera.urlSnapshot||""),this.updateCameraImageSource();const e=this.buildAbsoluteUrl(this.camera.urlStream||"");e.searchParams.set("cacheBust",Date.now().toString()),this.$emit("raw-camera-url",e.toString())}stopPlayback(){this.cameraImageSourceUrl=null,this.cameraImageSource="",this.cameraImage.src=""}};c([d("streamingElement")],n.prototype,"cameraImage",2);n=c([S({})],n);var I=function(){var t=this,e=t._self._c;return t._self._setupProxy,e("img",{ref:"streamingElement",style:t.cameraStyle,attrs:{src:t.cameraImageSource,crossorigin:t.crossorigin},on:{load:t.handleImageLoad}})},v=[],q=f(n,I,v,!1,null,null,null,null);const b=q.exports;export{b as default};
