(function(){let e=new Uint8Array([13,10,13,10]),t=(e,t,n)=>{for(;;){let r=e.indexOf(t[0],n);if(r===-1||r+t.length>e.length)return-1;if(t.every((t,n)=>e[r+n]===t))return r;n=r+1}},n=async(n,r)=>{let i=await fetch(n,{mode:`cors`});if(!i.ok||!i.body)throw Error(`Failed to fetch MJPEG stream: ${i.status}`);let a=i.headers.get(`content-type`)||``;if(!a.includes(`multipart`))throw Error(`Invalid content-type "${a}"`);let o=a.match(/boundary=([^;]+)/)?.[1];if(!o)throw Error(`Boundary not found in content-type "${a}"`);let s=new TextEncoder().encode(`--${o}`),c=i.body.getReader({mode:`byob`}),l=new Uint8Array;try{for(;;){let n=new Uint8Array(8192),{done:i,value:a}=await c.read(n);if(i)break;let o=new Uint8Array(l.length+a.length);for(o.set(l),o.set(a,l.length),l=o;;){let n=t(l,s);if(n===-1)break;let i=n+s.length,a=t(l,s,i);if(a===-1)break;let o=t(l,e,i);o!==-1&&o<a&&r(l.slice(o+4,a)),l=l.slice(a)}}}finally{c.releaseLock()}},r={silent:-1/0,fatal:0,error:0,warn:1,log:2,info:3,success:3,fail:3,ready:3,start:3,box:3,debug:4,trace:5,verbose:1/0},i={silent:{level:-1},fatal:{level:r.fatal},error:{level:r.error},warn:{level:r.warn},log:{level:r.log},info:{level:r.info},success:{level:r.success},fail:{level:r.fail},ready:{level:r.info},start:{level:r.info},box:{level:r.info},debug:{level:r.debug},trace:{level:r.trace},verbose:{level:r.verbose}};function a(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function o(e,t,n=`.`,r){if(!a(t))return o(e,{},n,r);let i=Object.assign({},t);for(let t in e){if(t===`__proto__`||t===`constructor`)continue;let s=e[t];s!=null&&(r&&r(i,t,s,n)||(Array.isArray(s)&&Array.isArray(i[t])?i[t]=[...s,...i[t]]:a(s)&&a(i[t])?i[t]=o(s,i[t],(n?`${n}.`:``)+t.toString(),r):i[t]=s))}return i}function s(e){return(...t)=>t.reduce((t,n)=>o(t,n,``,e),{})}let c=s();function l(e){return Object.prototype.toString.call(e)===`[object Object]`}function u(e){return!(!l(e)||!e.message&&!e.args||e.stack)}let d=!1,f=[];var p=class e{options;_lastLog;_mockFn;constructor(e={}){let t=e.types||i;this.options=c({...e,defaults:{...e.defaults},level:m(e.level,t),reporters:[...e.reporters||[]]},{types:i,throttle:1e3,throttleMin:5,formatOptions:{date:!0,colors:!1,compact:!0}});for(let e in t){let n={type:e,...this.options.defaults,...t[e]};this[e]=this._wrapLogFn(n),this[e].raw=this._wrapLogFn(n,!0)}this.options.mockFn&&this.mockTypes(),this._lastLog={}}get level(){return this.options.level}set level(e){this.options.level=m(e,this.options.types,this.options.level)}prompt(e,t){if(!this.options.prompt)throw Error(`prompt is not supported!`);return this.options.prompt(e,t)}create(t){let n=new e({...this.options,...t});return this._mockFn&&n.mockTypes(this._mockFn),n}withDefaults(e){return this.create({...this.options,defaults:{...this.options.defaults,...e}})}withTag(e){return this.withDefaults({tag:this.options.defaults.tag?this.options.defaults.tag+`:`+e:e})}addReporter(e){return this.options.reporters.push(e),this}removeReporter(e){if(e){let t=this.options.reporters.indexOf(e);if(t!==-1)return this.options.reporters.splice(t,1)}else this.options.reporters.splice(0);return this}setReporters(e){return this.options.reporters=Array.isArray(e)?e:[e],this}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}wrapConsole(){for(let e in this.options.types)console[`__`+e]||(console[`__`+e]=console[e]),console[e]=this[e].raw}restoreConsole(){for(let e in this.options.types)console[`__`+e]&&(console[e]=console[`__`+e],delete console[`__`+e])}wrapStd(){this._wrapStream(this.options.stdout,`log`),this._wrapStream(this.options.stderr,`log`)}_wrapStream(e,t){e&&(e.__write||=e.write,e.write=e=>{this[t].raw(String(e).trim())})}restoreStd(){this._restoreStream(this.options.stdout),this._restoreStream(this.options.stderr)}_restoreStream(e){e&&e.__write&&(e.write=e.__write,delete e.__write)}pauseLogs(){d=!0}resumeLogs(){d=!1;let e=f.splice(0);for(let t of e)t[0]._logFn(t[1],t[2])}mockTypes(e){let t=e||this.options.mockFn;if(this._mockFn=t,typeof t==`function`)for(let e in this.options.types)this[e]=t(e,this.options.types[e])||this[e],this[e].raw=this[e]}_wrapLogFn(e,t){return(...n)=>{if(d){f.push([this,e,n,t]);return}return this._logFn(e,n,t)}}_logFn(e,t,n){if((e.level||0)>this.level)return!1;let r={date:new Date,args:[],...e,level:m(e.level,this.options.types)};!n&&t.length===1&&u(t[0])?Object.assign(r,t[0]):r.args=[...t],r.message&&(r.args.unshift(r.message),delete r.message),r.additional&&(Array.isArray(r.additional)||(r.additional=r.additional.split(`
`)),r.args.push(`
`+r.additional.join(`
`)),delete r.additional),r.type=typeof r.type==`string`?r.type.toLowerCase():`log`,r.tag=typeof r.tag==`string`?r.tag:``;let i=(e=!1)=>{let t=(this._lastLog.count||0)-this.options.throttleMin;if(this._lastLog.object&&t>0){let e=[...this._lastLog.object.args];t>1&&e.push(`(repeated ${t} times)`),this._log({...this._lastLog.object,args:e}),this._lastLog.count=1}e&&(this._lastLog.object=r,this._log(r))};clearTimeout(this._lastLog.timeout);let a=this._lastLog.time&&r.date?r.date.getTime()-this._lastLog.time.getTime():0;if(this._lastLog.time=r.date,a<this.options.throttle)try{let e=JSON.stringify([r.type,r.tag,r.args]),t=this._lastLog.serialized===e;if(this._lastLog.serialized=e,t&&(this._lastLog.count=(this._lastLog.count||0)+1,this._lastLog.count>this.options.throttleMin)){this._lastLog.timeout=setTimeout(i,this.options.throttle);return}}catch{}i(!0)}_log(e){for(let t of this.options.reporters)t.log(e,{options:this.options})}};function m(e,t={},n=3){return e===void 0?n:typeof e==`number`?e:t[e]&&t[e].level!==void 0?t[e].level:n}p.prototype.add=p.prototype.addReporter,p.prototype.remove=p.prototype.removeReporter,p.prototype.clear=p.prototype.removeReporter,p.prototype.withScope=p.prototype.withTag,p.prototype.mock=p.prototype.mockTypes,p.prototype.pause=p.prototype.pauseLogs,p.prototype.resume=p.prototype.resumeLogs;function h(e={}){return new p(e)}var g=class{options;defaultColor;levelColorMap;typeColorMap;constructor(e){this.options={...e},this.defaultColor=`#7f8c8d`,this.levelColorMap={0:`#c0392b`,1:`#f39c12`,3:`#00BCD4`},this.typeColorMap={success:`#2ecc71`}}_getLogFn(e){return e<1?console.__error||console.error:e===1?console.__warn||console.warn:console.__log||console.log}log(e){let t=this._getLogFn(e.level),n=e.type===`log`?``:e.type,r=e.tag||``,i=`
      background: ${this.typeColorMap[e.type]||this.levelColorMap[e.level]||this.defaultColor};
      border-radius: 0.5em;
      color: white;
      font-weight: bold;
      padding: 2px 0.5em;
    `,a=`%c${[r,n].filter(Boolean).join(`:`)}`;typeof e.args[0]==`string`?t(`${a}%c ${e.args[0]}`,i,``,...e.args.slice(1)):t(a,i,...e.args)}};function _(e={}){return h({reporters:e.reporters||[new g({})],prompt(e,t={}){return t.type===`confirm`?Promise.resolve(confirm(e)):Promise.resolve(prompt(e))},...e})}let v=_(),y=e=>{let t={action:`frame`,data:e};self.postMessage(t,[e.buffer])},b=()=>{self.postMessage({action:`done`})},x=e=>{let t={action:`error`,error:e};self.postMessage(t)};self.onmessage=async e=>{let t=e.data;try{switch(t.action){case`start`:await n(t.url,y),b();break}}catch(e){v.error(`[MjpegStream] error in worker`,e),x(e)}}})();