var u=Object.defineProperty;var l=(a,e,t)=>e in a?u(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var r=(a,e,t)=>l(a,typeof e!="symbol"?e+"":e,t);import{m as p,f as g,R as d,C as f,j as S}from"./index-DGn1DPCK.js";import{C as _}from"./camera-DJLV_IoI.js";var T=Object.defineProperty,v=Object.getOwnPropertyDescriptor,c=(a,e,t,i)=>{for(var s=i>1?void 0:i?v(e,t):e,m=a.length-1,o;m>=0;m--)(o=a[m])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&T(e,t,s),s};let n=class extends p(_){constructor(){super(...arguments);r(this,"cameraImage");r(this,"cameraImageSource","");r(this,"cameraImageSourceUrl",null);r(this,"requestStartTime",0);r(this,"startTime",0);r(this,"time",0);r(this,"requestTime",0);r(this,"timeSmoothing",.6);r(this,"requestTimeSmoothing",.1)}get autoRaiseFrameEvent(){return!1}handleImageLoad(){this.updateStatus("connected"),this.$emit("frame",this.streamingElement);const t=!document.hasFocus()&&this.camera.target_fps_idle||this.camera.target_fps||10,i=performance.now(),s=i-this.startTime;this.time=this.time*this.timeSmoothing+s*(1-this.timeSmoothing),this.startTime=i;const m=1e3/t,o=performance.now()-this.requestStartTime;this.requestTime=this.requestTime*this.requestTimeSmoothing+o*(1-this.requestTimeSmoothing);const h=Math.max(0,m-this.requestTime);this.$nextTick(()=>{setTimeout(this.handleRefresh,h)})}handleRefresh(){document.hidden?this.stopPlayback():(this.time!==0&&this.updateFramesPerSecond(Math.round(1e3/this.time)),this.$nextTick(()=>this.updateCameraImageSource()))}updateCameraImageSource(){const t=this.cameraImageSourceUrl;t&&(t.searchParams.set("cacheBust",Date.now().toString()),this.requestStartTime=performance.now(),this.cameraImageSource=t.toString())}startPlayback(){try{this.updateStatus("connecting"),this.cameraImageSourceUrl=this.buildAbsoluteUrl(this.camera.snapshot_url||""),this.time=0,this.startTime=performance.now(),this.updateCameraImageSource();const t=this.buildAbsoluteUrl(this.camera.stream_url||"");t.searchParams.set("cacheBust",Date.now().toString()),this.updateRawCameraUrl(t.toString())}catch(t){g.error(`[MjpegstreamerAdaptiveCamera] failed to start playback "${this.camera.name}"`,t)}}stopPlayback(){this.updateStatus("disconnected"),this.cameraImageSourceUrl=null,this.cameraImageSource="",this.cameraImage.src=""}};c([d("streamingElement")],n.prototype,"cameraImage",2);n=c([f({})],n);var I=function(){var e=this,t=e._self._c;return e._self._setupProxy,t("img",{directives:[{name:"show",rawName:"v-show",value:e.status==="connected",expression:"status === 'connected'"}],ref:"streamingElement",style:e.cameraStyle,attrs:{src:e.cameraImageSource,crossorigin:e.crossorigin},on:{load:e.handleImageLoad,error:function(i){return e.updateStatus("error")}}})},C=[],w=S(n,I,C,!1,null,null);const y=w.exports;export{y as default};
