@apocaliss92/scrypted-reolink-native 0.1.30 → 0.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.nodejs.js +1 -1
- package/dist/plugin.zip +0 -0
- package/package.json +1 -1
- package/src/baichuan-base.ts +0 -4
- package/src/camera-battery.ts +4 -59
- package/src/camera.ts +0 -15
- package/src/common.ts +187 -57
- package/src/debug-options.ts +0 -8
- package/src/main.ts +15 -30
- package/src/multiFocal.ts +53 -20
- package/src/nvr.ts +26 -8
- package/src/stream-utils.ts +144 -5
package/dist/main.nodejs.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see main.nodejs.js.LICENSE.txt */
|
|
2
|
-
(()=>{var e={9038:(e,t,s)=>{"use strict";const n=s(1167),r=s(5497),i=s(8542),A=s(8055),o=s(3315),a=s(9246),c=s(4667),l=s(8712),h=s(8297),g=s(4465),d=s(2858),{InvalidArgumentError:u}=g,I=s(9713),E=s(1986),p=s(615),{MockCallHistory:C,MockCallHistoryLog:B}=s(4969),Q=s(7467),f=s(5846),m=s(1313),y=s(3123),S=s(6294),{getGlobalDispatcher:w,setGlobalDispatcher:D}=s(9879),b=s(6917),v=s(8064);Object.assign(r.prototype,I),e.exports.g6=o,s(5132),s(2936),s(532),s(3562),s(6677),s(5752),s(4951),s(9903);function N(e){return(t,s,n)=>{if("function"==typeof s&&(n=s,s=null),!t||"string"!=typeof t&&"object"!=typeof t&&!(t instanceof URL))throw new u("invalid url");if(null!=s&&"object"!=typeof s)throw new u("invalid opts");if(s&&null!=s.path){if("string"!=typeof s.path)throw new u("invalid opts.path");let e=s.path;s.path.startsWith("/")||(e=`/${e}`),t=new URL(d.parseOrigin(t).origin+e)}else s||(s="object"==typeof t?t:{}),t=d.parseURL(t);const{agent:r,dispatcher:i=w()}=s;if(r)throw new u("unsupported opts.agent. Did you mean opts.client?");return e.call(i,{...s,origin:t.origin,path:t.search?`${t.pathname}${t.search}`:t.pathname,method:s.method||(s.body?"PUT":"GET")},n)}}s(2636),d.parseHeaders,d.headerNameToString;const R=s(7388).fetch;e.exports.hd=function(e,t=void 0){return R(e,t).catch((e=>{throw e&&"object"==typeof e&&Error.captureStackTrace(e),e}))},e.exports.Headers=s(6558).Headers,e.exports.Response=s(4821).Response,e.exports.Request=s(4609).Request,e.exports.FormData=s(3944).FormData;const{setGlobalOrigin:k,getGlobalOrigin:T}=s(2837);const{CacheStorage:F}=s(6939),{kConstruct:M}=s(257);new F(M);const{deleteCookie:U,getCookies:L,getSetCookies:P,setCookie:H,parseCookie:x}=s(9391);const{parseMIMEType:Y,serializeAMimeType:V}=s(9934);const{CloseEvent:O,ErrorEvent:G,MessageEvent:J}=s(878),{WebSocket:W,ping:_}=s(2984);e.exports.kb=W,e.exports.rd=O,e.exports.NN=G,e.exports.aM=J,s(27).WebSocketStream,s(7053).WebSocketError,N(I.request),N(I.stream),N(I.pipeline),N(I.connect),N(I.upgrade);const{EventSource:$}=s(7928);e.exports.GD=$},3904:(e,t,s)=>{"use strict";const{addAbortListener:n}=s(2858),{RequestAbortedError:r}=s(4465),i=Symbol("kListener"),A=Symbol("kSignal");function o(e){e.abort?e.abort(e[A]?.reason):e.reason=e[A]?.reason??new r,a(e)}function a(e){e[A]&&("removeEventListener"in e[A]?e[A].removeEventListener("abort",e[i]):e[A].removeListener("abort",e[i]),e[A]=null,e[i]=null)}e.exports={addSignal:function(e,t){e.reason=null,e[A]=null,e[i]=null,t&&(t.aborted?o(e):(e[A]=t,e[i]=()=>{o(e)},n(e[A],e[i])))},removeSignal:a}},3102:(e,t,s)=>{"use strict";const n=s(4589),{AsyncResource:r}=s(6698),{InvalidArgumentError:i,SocketError:A}=s(4465),o=s(2858),{addSignal:a,removeSignal:c}=s(3904);class l extends r{constructor(e,t){if(!e||"object"!=typeof e)throw new i("invalid opts");if("function"!=typeof t)throw new i("invalid callback");const{signal:s,opaque:n,responseHeaders:r}=e;if(s&&"function"!=typeof s.on&&"function"!=typeof s.addEventListener)throw new i("signal must be an EventEmitter or EventTarget");super("UNDICI_CONNECT"),this.opaque=n||null,this.responseHeaders=r||null,this.callback=t,this.abort=null,a(this,s)}onConnect(e,t){this.reason?e(this.reason):(n(this.callback),this.abort=e,this.context=t)}onHeaders(){throw new A("bad connect",null)}onUpgrade(e,t,s){const{callback:n,opaque:r,context:i}=this;c(this),this.callback=null;let A=t;null!=A&&(A="raw"===this.responseHeaders?o.parseRawHeaders(t):o.parseHeaders(t)),this.runInAsyncScope(n,null,null,{statusCode:e,headers:A,socket:s,opaque:r,context:i})}onError(e){const{callback:t,opaque:s}=this;c(this),t&&(this.callback=null,queueMicrotask((()=>{this.runInAsyncScope(t,null,e,{opaque:s})})))}}e.exports=function e(t,s){if(void 0===s)return new Promise(((s,n)=>{e.call(this,t,((e,t)=>e?n(e):s(t)))}));try{const e=new l(t,s),n={...t,method:"CONNECT"};this.dispatch(n,e)}catch(e){if("function"!=typeof s)throw e;const n=t?.opaque;queueMicrotask((()=>s(e,{opaque:n})))}}},8660:(e,t,s)=>{"use strict";const{Readable:n,Duplex:r,PassThrough:i}=s(7075),A=s(4589),{AsyncResource:o}=s(6698),{InvalidArgumentError:a,InvalidReturnValueError:c,RequestAbortedError:l}=s(4465),h=s(2858),{addSignal:g,removeSignal:d}=s(3904);function u(){}const I=Symbol("resume");class E extends n{constructor(){super({autoDestroy:!0}),this[I]=null}_read(){const{[I]:e}=this;e&&(this[I]=null,e())}_destroy(e,t){this._read(),t(e)}}class p extends n{constructor(e){super({autoDestroy:!0}),this[I]=e}_read(){this[I]()}_destroy(e,t){e||this._readableState.endEmitted||(e=new l),t(e)}}class C extends o{constructor(e,t){if(!e||"object"!=typeof e)throw new a("invalid opts");if("function"!=typeof t)throw new a("invalid handler");const{signal:s,method:n,opaque:i,onInfo:A,responseHeaders:o}=e;if(s&&"function"!=typeof s.on&&"function"!=typeof s.addEventListener)throw new a("signal must be an EventEmitter or EventTarget");if("CONNECT"===n)throw new a("invalid method");if(A&&"function"!=typeof A)throw new a("invalid onInfo callback");super("UNDICI_PIPELINE"),this.opaque=i||null,this.responseHeaders=o||null,this.handler=t,this.abort=null,this.context=null,this.onInfo=A||null,this.req=(new E).on("error",u),this.ret=new r({readableObjectMode:e.objectMode,autoDestroy:!0,read:()=>{const{body:e}=this;e?.resume&&e.resume()},write:(e,t,s)=>{const{req:n}=this;n.push(e,t)||n._readableState.destroyed?s():n[I]=s},destroy:(e,t)=>{const{body:s,req:n,res:r,ret:i,abort:A}=this;e||i._readableState.endEmitted||(e=new l),A&&e&&A(),h.destroy(s,e),h.destroy(n,e),h.destroy(r,e),d(this),t(e)}}).on("prefinish",(()=>{const{req:e}=this;e.push(null)})),this.res=null,g(this,s)}onConnect(e,t){const{res:s}=this;this.reason?e(this.reason):(A(!s,"pipeline cannot be retried"),this.abort=e,this.context=t)}onHeaders(e,t,s){const{opaque:n,handler:r,context:i}=this;if(e<200){if(this.onInfo){const s="raw"===this.responseHeaders?h.parseRawHeaders(t):h.parseHeaders(t);this.onInfo({statusCode:e,headers:s})}return}let A;this.res=new p(s);try{this.handler=null;const s="raw"===this.responseHeaders?h.parseRawHeaders(t):h.parseHeaders(t);A=this.runInAsyncScope(r,null,{statusCode:e,headers:s,opaque:n,body:this.res,context:i})}catch(e){throw this.res.on("error",u),e}if(!A||"function"!=typeof A.on)throw new c("expected Readable");A.on("data",(e=>{const{ret:t,body:s}=this;!t.push(e)&&s.pause&&s.pause()})).on("error",(e=>{const{ret:t}=this;h.destroy(t,e)})).on("end",(()=>{const{ret:e}=this;e.push(null)})).on("close",(()=>{const{ret:e}=this;e._readableState.ended||h.destroy(e,new l)})),this.body=A}onData(e){const{res:t}=this;return t.push(e)}onComplete(e){const{res:t}=this;t.push(null)}onError(e){const{ret:t}=this;this.handler=null,h.destroy(t,e)}}e.exports=function(e,t){try{const s=new C(e,t);return this.dispatch({...e,body:s.req},s),s.ret}catch(e){return(new i).destroy(e)}}},7745:(e,t,s)=>{"use strict";const n=s(4589),{AsyncResource:r}=s(6698),{Readable:i}=s(777),{InvalidArgumentError:A,RequestAbortedError:o}=s(4465),a=s(2858);function c(){}class l extends r{constructor(e,t){if(!e||"object"!=typeof e)throw new A("invalid opts");const{signal:s,method:n,opaque:r,body:i,onInfo:l,responseHeaders:h,highWaterMark:g}=e;try{if("function"!=typeof t)throw new A("invalid callback");if(g&&("number"!=typeof g||g<0))throw new A("invalid highWaterMark");if(s&&"function"!=typeof s.on&&"function"!=typeof s.addEventListener)throw new A("signal must be an EventEmitter or EventTarget");if("CONNECT"===n)throw new A("invalid method");if(l&&"function"!=typeof l)throw new A("invalid onInfo callback");super("UNDICI_REQUEST")}catch(e){throw a.isStream(i)&&a.destroy(i.on("error",c),e),e}this.method=n,this.responseHeaders=h||null,this.opaque=r||null,this.callback=t,this.res=null,this.abort=null,this.body=i,this.trailers={},this.context=null,this.onInfo=l||null,this.highWaterMark=g,this.reason=null,this.removeAbortListener=null,s?.aborted?this.reason=s.reason??new o:s&&(this.removeAbortListener=a.addAbortListener(s,(()=>{this.reason=s.reason??new o,this.res?a.destroy(this.res.on("error",c),this.reason):this.abort&&this.abort(this.reason)})))}onConnect(e,t){this.reason?e(this.reason):(n(this.callback),this.abort=e,this.context=t)}onHeaders(e,t,s,n){const{callback:r,opaque:A,abort:o,context:l,responseHeaders:h,highWaterMark:g}=this,d="raw"===h?a.parseRawHeaders(t):a.parseHeaders(t);if(e<200)return void(this.onInfo&&this.onInfo({statusCode:e,headers:d}));const u="raw"===h?a.parseHeaders(t):d,I=u["content-type"],E=u["content-length"],p=new i({resume:s,abort:o,contentType:I,contentLength:"HEAD"!==this.method&&E?Number(E):null,highWaterMark:g});if(this.removeAbortListener&&(p.on("close",this.removeAbortListener),this.removeAbortListener=null),this.callback=null,this.res=p,null!==r)try{this.runInAsyncScope(r,null,null,{statusCode:e,headers:d,trailers:this.trailers,opaque:A,body:p,context:l})}catch(e){this.res=null,a.destroy(p.on("error",c),e),queueMicrotask((()=>{throw e}))}}onData(e){return this.res.push(e)}onComplete(e){a.parseHeaders(e,this.trailers),this.res.push(null)}onError(e){const{res:t,callback:s,body:n,opaque:r}=this;s&&(this.callback=null,queueMicrotask((()=>{this.runInAsyncScope(s,null,e,{opaque:r})}))),t&&(this.res=null,queueMicrotask((()=>{a.destroy(t.on("error",c),e)}))),n&&(this.body=null,a.isStream(n)&&(n.on("error",c),a.destroy(n,e))),this.removeAbortListener&&(this.removeAbortListener(),this.removeAbortListener=null)}}e.exports=function e(t,s){if(void 0===s)return new Promise(((s,n)=>{e.call(this,t,((e,t)=>e?n(e):s(t)))}));try{const e=new l(t,s);this.dispatch(t,e)}catch(e){if("function"!=typeof s)throw e;const n=t?.opaque;queueMicrotask((()=>s(e,{opaque:n})))}},e.exports.RequestHandler=l},322:(e,t,s)=>{"use strict";const n=s(4589),{finished:r}=s(7075),{AsyncResource:i}=s(6698),{InvalidArgumentError:A,InvalidReturnValueError:o}=s(4465),a=s(2858),{addSignal:c,removeSignal:l}=s(3904);function h(){}class g extends i{constructor(e,t,s){if(!e||"object"!=typeof e)throw new A("invalid opts");const{signal:n,method:r,opaque:i,body:o,onInfo:l,responseHeaders:g}=e;try{if("function"!=typeof s)throw new A("invalid callback");if("function"!=typeof t)throw new A("invalid factory");if(n&&"function"!=typeof n.on&&"function"!=typeof n.addEventListener)throw new A("signal must be an EventEmitter or EventTarget");if("CONNECT"===r)throw new A("invalid method");if(l&&"function"!=typeof l)throw new A("invalid onInfo callback");super("UNDICI_STREAM")}catch(e){throw a.isStream(o)&&a.destroy(o.on("error",h),e),e}this.responseHeaders=g||null,this.opaque=i||null,this.factory=t,this.callback=s,this.res=null,this.abort=null,this.context=null,this.trailers=null,this.body=o,this.onInfo=l||null,a.isStream(o)&&o.on("error",(e=>{this.onError(e)})),c(this,n)}onConnect(e,t){this.reason?e(this.reason):(n(this.callback),this.abort=e,this.context=t)}onHeaders(e,t,s,n){const{factory:i,opaque:A,context:c,responseHeaders:l}=this,h="raw"===l?a.parseRawHeaders(t):a.parseHeaders(t);if(e<200)return void(this.onInfo&&this.onInfo({statusCode:e,headers:h}));if(this.factory=null,null===i)return;const g=this.runInAsyncScope(i,null,{statusCode:e,headers:h,opaque:A,context:c});if(!g||"function"!=typeof g.write||"function"!=typeof g.end||"function"!=typeof g.on)throw new o("expected Writable");r(g,{readable:!1},(e=>{const{callback:t,res:s,opaque:n,trailers:r,abort:i}=this;this.res=null,!e&&s?.readable||a.destroy(s,e),this.callback=null,this.runInAsyncScope(t,null,e||null,{opaque:n,trailers:r}),e&&i()})),g.on("drain",s),this.res=g;return!0!==(void 0!==g.writableNeedDrain?g.writableNeedDrain:g._writableState?.needDrain)}onData(e){const{res:t}=this;return!t||t.write(e)}onComplete(e){const{res:t}=this;l(this),t&&(this.trailers=a.parseHeaders(e),t.end())}onError(e){const{res:t,callback:s,opaque:n,body:r}=this;l(this),this.factory=null,t?(this.res=null,a.destroy(t,e)):s&&(this.callback=null,queueMicrotask((()=>{this.runInAsyncScope(s,null,e,{opaque:n})}))),r&&(this.body=null,a.destroy(r,e))}}e.exports=function e(t,s,n){if(void 0===n)return new Promise(((n,r)=>{e.call(this,t,s,((e,t)=>e?r(e):n(t)))}));try{const e=new g(t,s,n);this.dispatch(t,e)}catch(e){if("function"!=typeof n)throw e;const s=t?.opaque;queueMicrotask((()=>n(e,{opaque:s})))}}},3936:(e,t,s)=>{"use strict";const{InvalidArgumentError:n,SocketError:r}=s(4465),{AsyncResource:i}=s(6698),A=s(4589),o=s(2858),{addSignal:a,removeSignal:c}=s(3904);class l extends i{constructor(e,t){if(!e||"object"!=typeof e)throw new n("invalid opts");if("function"!=typeof t)throw new n("invalid callback");const{signal:s,opaque:r,responseHeaders:i}=e;if(s&&"function"!=typeof s.on&&"function"!=typeof s.addEventListener)throw new n("signal must be an EventEmitter or EventTarget");super("UNDICI_UPGRADE"),this.responseHeaders=i||null,this.opaque=r||null,this.callback=t,this.abort=null,this.context=null,a(this,s)}onConnect(e,t){this.reason?e(this.reason):(A(this.callback),this.abort=e,this.context=null)}onHeaders(){throw new r("bad upgrade",null)}onUpgrade(e,t,s){A(101===e);const{callback:n,opaque:r,context:i}=this;c(this),this.callback=null;const a="raw"===this.responseHeaders?o.parseRawHeaders(t):o.parseHeaders(t);this.runInAsyncScope(n,null,null,{headers:a,socket:s,opaque:r,context:i})}onError(e){const{callback:t,opaque:s}=this;c(this),t&&(this.callback=null,queueMicrotask((()=>{this.runInAsyncScope(t,null,e,{opaque:s})})))}}e.exports=function e(t,s){if(void 0===s)return new Promise(((s,n)=>{e.call(this,t,((e,t)=>e?n(e):s(t)))}));try{const e=new l(t,s),n={...t,method:t.method||"GET",upgrade:t.protocol||"Websocket"};this.dispatch(n,e)}catch(e){if("function"!=typeof s)throw e;const n=t?.opaque;queueMicrotask((()=>s(e,{opaque:n})))}}},9713:(e,t,s)=>{"use strict";e.exports.request=s(7745),e.exports.stream=s(322),e.exports.pipeline=s(8660),e.exports.upgrade=s(3936),e.exports.connect=s(3102)},777:(e,t,s)=>{"use strict";const n=s(4589),{Readable:r}=s(7075),{RequestAbortedError:i,NotSupportedError:A,InvalidArgumentError:o,AbortError:a}=s(4465),c=s(2858),{ReadableStreamFrom:l}=s(2858),h=Symbol("kConsume"),g=Symbol("kReading"),d=Symbol("kBody"),u=Symbol("kAbort"),I=Symbol("kContentType"),E=Symbol("kContentLength"),p=Symbol("kUsed"),C=Symbol("kBytesRead"),B=()=>{};function Q(e){return c.isDisturbed(e)||function(e){return!0===e[d]?.locked||null!==e[h]}(e)}function f(e,t){return n(!e[h]),new Promise(((s,n)=>{if(Q(e)){const t=e._readableState;t.destroyed&&!1===t.closeEmitted?e.on("error",n).on("close",(()=>{n(new TypeError("unusable"))})):n(t.errored??new TypeError("unusable"))}else queueMicrotask((()=>{e[h]={type:t,stream:e,resolve:s,reject:n,length:0,body:[]},e.on("error",(function(e){D(this[h],e)})).on("close",(function(){null!==this[h].body&&D(this[h],new i)})),function(e){if(null===e.body)return;const{_readableState:t}=e.stream;if(t.bufferIndex){const s=t.bufferIndex,n=t.buffer.length;for(let r=s;r<n;r++)w(e,t.buffer[r])}else for(const s of t.buffer)w(e,s);t.endEmitted?S(this[h],this._readableState.encoding):e.stream.on("end",(function(){S(this[h],this._readableState.encoding)}));e.stream.resume();for(;null!=e.stream.read(););}(e[h])}))}))}function m(e,t,s){if(0===e.length||0===t)return"";const n=1===e.length?e[0]:Buffer.concat(e,t),r=n.length,i=r>2&&239===n[0]&&187===n[1]&&191===n[2]?3:0;return s&&"utf8"!==s&&"utf-8"!==s?n.subarray(i,r).toString(s):n.utf8Slice(i,r)}function y(e,t){if(0===e.length||0===t)return new Uint8Array(0);if(1===e.length)return new Uint8Array(e[0]);const s=new Uint8Array(Buffer.allocUnsafeSlow(t).buffer);let n=0;for(let t=0;t<e.length;++t){const r=e[t];s.set(r,n),n+=r.length}return s}function S(e,t){const{type:s,body:n,resolve:r,stream:i,length:A}=e;try{"text"===s?r(m(n,A,t)):"json"===s?r(JSON.parse(m(n,A,t))):"arrayBuffer"===s?r(y(n,A).buffer):"blob"===s?r(new Blob(n,{type:i[I]})):"bytes"===s&&r(y(n,A)),D(e)}catch(e){i.destroy(e)}}function w(e,t){e.length+=t.length,e.body.push(t)}function D(e,t){null!==e.body&&(t?e.reject(t):e.resolve(),e.type=null,e.stream=null,e.resolve=null,e.reject=null,e.length=0,e.body=null)}e.exports={Readable:class extends r{constructor({resume:e,abort:t,contentType:s="",contentLength:n,highWaterMark:r=65536}){super({autoDestroy:!0,read:e,highWaterMark:r}),this._readableState.dataEmitted=!1,this[u]=t,this[h]=null,this[C]=0,this[d]=null,this[p]=!1,this[I]=s,this[E]=Number.isFinite(n)?n:null,this[g]=!1}_destroy(e,t){e||this._readableState.endEmitted||(e=new i),e&&this[u](),this[p]?t(e):setImmediate(t,e)}on(e,t){return"data"!==e&&"readable"!==e||(this[g]=!0,this[p]=!0),super.on(e,t)}addListener(e,t){return this.on(e,t)}off(e,t){const s=super.off(e,t);return"data"!==e&&"readable"!==e||(this[g]=this.listenerCount("data")>0||this.listenerCount("readable")>0),s}removeListener(e,t){return this.off(e,t)}push(e){return e&&(this[C]+=e.length,this[h])?(w(this[h],e),!this[g]||super.push(e)):super.push(e)}text(){return f(this,"text")}json(){return f(this,"json")}blob(){return f(this,"blob")}bytes(){return f(this,"bytes")}arrayBuffer(){return f(this,"arrayBuffer")}async formData(){throw new A}get bodyUsed(){return c.isDisturbed(this)}get body(){return this[d]||(this[d]=l(this),this[h]&&(this[d].getReader(),n(this[d].locked))),this[d]}dump(e){const t=e?.signal;if(null!=t&&("object"!=typeof t||!("aborted"in t)))return Promise.reject(new o("signal must be an AbortSignal"));const s=e?.limit&&Number.isFinite(e.limit)?e.limit:131072;return t?.aborted?Promise.reject(t.reason??new a):this._readableState.closeEmitted?Promise.resolve(null):new Promise(((e,n)=>{if((this[E]&&this[E]>s||this[C]>s)&&this.destroy(new a),t){const s=()=>{this.destroy(t.reason??new a)};t.addEventListener("abort",s),this.on("close",(function(){t.removeEventListener("abort",s),t.aborted?n(t.reason??new a):e(null)}))}else this.on("close",e);this.on("error",B).on("data",(()=>{this[C]>s&&this.destroy()})).resume()}))}setEncoding(e){return Buffer.isEncoding(e)&&(this._readableState.encoding=e),this}},chunksDecode:m}},9903:(e,t,s)=>{"use strict";const{Writable:n}=s(7075),{EventEmitter:r}=s(8474),{assertCacheKey:i,assertCacheValue:A}=s(9453);function o(e,t,s){return t.find((t=>t.deleteAt>s&&t.method===e.method&&(null==t.vary||Object.keys(t.vary).every((s=>null===t.vary[s]?void 0===e.headers[s]:t.vary[s]===e.headers[s])))))}e.exports=class extends r{#e=1024;#t=104857600;#s=5242880;#n=0;#r=0;#i=new Map;#A=!1;constructor(e){if(super(),e){if("object"!=typeof e)throw new TypeError("MemoryCacheStore options must be an object");if(void 0!==e.maxCount){if("number"!=typeof e.maxCount||!Number.isInteger(e.maxCount)||e.maxCount<0)throw new TypeError("MemoryCacheStore options.maxCount must be a non-negative integer");this.#e=e.maxCount}if(void 0!==e.maxSize){if("number"!=typeof e.maxSize||!Number.isInteger(e.maxSize)||e.maxSize<0)throw new TypeError("MemoryCacheStore options.maxSize must be a non-negative integer");this.#t=e.maxSize}if(void 0!==e.maxEntrySize){if("number"!=typeof e.maxEntrySize||!Number.isInteger(e.maxEntrySize)||e.maxEntrySize<0)throw new TypeError("MemoryCacheStore options.maxEntrySize must be a non-negative integer");this.#s=e.maxEntrySize}}}get size(){return this.#n}isFull(){return this.#n>=this.#t||this.#r>=this.#e}get(e){i(e);const t=`${e.origin}:${e.path}`,s=Date.now(),n=this.#i.get(t),r=n?o(e,n,s):null;return null==r?void 0:{statusMessage:r.statusMessage,statusCode:r.statusCode,headers:r.headers,body:r.body,vary:r.vary?r.vary:void 0,etag:r.etag,cacheControlDirectives:r.cacheControlDirectives,cachedAt:r.cachedAt,staleAt:r.staleAt,deleteAt:r.deleteAt}}createWriteStream(e,t){i(e),A(t);const s=`${e.origin}:${e.path}`,r=this,a={...e,...t,body:[],size:0};return new n({write(e,t,s){"string"==typeof e&&(e=Buffer.from(e,t)),a.size+=e.byteLength,a.size>=r.#s?this.destroy():a.body.push(e),s(null)},final(t){let n=r.#i.get(s);n||(n=[],r.#i.set(s,n));const i=o(e,n,Date.now());if(i){const e=n.indexOf(i);n.splice(e,1,a),r.#n-=i.size}else n.push(a),r.#r+=1;if(r.#n+=a.size,r.#n>r.#t||r.#r>r.#e){r.#A||(r.emit("maxSizeExceeded",{size:r.#n,maxSize:r.#t,count:r.#r,maxCount:r.#e}),r.#A=!0);for(const[e,t]of r.#i){for(const e of t.splice(0,t.length/2))r.#n-=e.size,r.#r-=1;0===t.length&&r.#i.delete(e)}r.#n<r.#t&&r.#r<r.#e&&(r.#A=!1)}t(null)}})}delete(e){if("object"!=typeof e)throw new TypeError("expected key to be object, got "+typeof e);const t=`${e.origin}:${e.path}`;for(const e of this.#i.get(t)??[])this.#n-=e.size,this.#r-=1;this.#i.delete(t)}}},2636:(e,t,s)=>{"use strict";const{Writable:n}=s(7075),{assertCacheKey:r,assertCacheValue:i}=s(9453);let A;const o=2e9;function a(e,t){return null==e&&null==t||!(null==e&&null!=t||null!=e&&null==t)&&(Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every(((e,s)=>e===t[s])):e===t)}e.exports=class{#s=o;#e=1/0;#o;#a;#c;#l;#h;#g;#d;#u;constructor(e){if(e){if("object"!=typeof e)throw new TypeError("SqliteCacheStore options must be an object");if(void 0!==e.maxEntrySize){if("number"!=typeof e.maxEntrySize||!Number.isInteger(e.maxEntrySize)||e.maxEntrySize<0)throw new TypeError("SqliteCacheStore options.maxEntrySize must be a non-negative integer");if(e.maxEntrySize>o)throw new TypeError("SqliteCacheStore options.maxEntrySize must be less than 2gb");this.#s=e.maxEntrySize}if(void 0!==e.maxCount){if("number"!=typeof e.maxCount||!Number.isInteger(e.maxCount)||e.maxCount<0)throw new TypeError("SqliteCacheStore options.maxCount must be a non-negative integer");this.#e=e.maxCount}}A||(A=s(99).DatabaseSync),this.#o=new A(e?.location??":memory:"),this.#o.exec("\n PRAGMA journal_mode = WAL;\n PRAGMA synchronous = NORMAL;\n PRAGMA temp_store = memory;\n PRAGMA optimize;\n\n CREATE TABLE IF NOT EXISTS cacheInterceptorV3 (\n -- Data specific to us\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n url TEXT NOT NULL,\n method TEXT NOT NULL,\n\n -- Data returned to the interceptor\n body BUF NULL,\n deleteAt INTEGER NOT NULL,\n statusCode INTEGER NOT NULL,\n statusMessage TEXT NOT NULL,\n headers TEXT NULL,\n cacheControlDirectives TEXT NULL,\n etag TEXT NULL,\n vary TEXT NULL,\n cachedAt INTEGER NOT NULL,\n staleAt INTEGER NOT NULL\n );\n\n CREATE INDEX IF NOT EXISTS idx_cacheInterceptorV3_getValuesQuery ON cacheInterceptorV3(url, method, deleteAt);\n CREATE INDEX IF NOT EXISTS idx_cacheInterceptorV3_deleteByUrlQuery ON cacheInterceptorV3(deleteAt);\n "),this.#a=this.#o.prepare("\n SELECT\n id,\n body,\n deleteAt,\n statusCode,\n statusMessage,\n headers,\n etag,\n cacheControlDirectives,\n vary,\n cachedAt,\n staleAt\n FROM cacheInterceptorV3\n WHERE\n url = ?\n AND method = ?\n ORDER BY\n deleteAt ASC\n "),this.#c=this.#o.prepare("\n UPDATE cacheInterceptorV3 SET\n body = ?,\n deleteAt = ?,\n statusCode = ?,\n statusMessage = ?,\n headers = ?,\n etag = ?,\n cacheControlDirectives = ?,\n cachedAt = ?,\n staleAt = ?\n WHERE\n id = ?\n "),this.#l=this.#o.prepare("\n INSERT INTO cacheInterceptorV3 (\n url,\n method,\n body,\n deleteAt,\n statusCode,\n statusMessage,\n headers,\n etag,\n cacheControlDirectives,\n vary,\n cachedAt,\n staleAt\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n "),this.#g=this.#o.prepare("DELETE FROM cacheInterceptorV3 WHERE url = ?"),this.#d=this.#o.prepare("SELECT COUNT(*) AS total FROM cacheInterceptorV3"),this.#h=this.#o.prepare("DELETE FROM cacheInterceptorV3 WHERE deleteAt <= ?"),this.#u=this.#e===1/0?null:this.#o.prepare("\n DELETE FROM cacheInterceptorV3\n WHERE id IN (\n SELECT\n id\n FROM cacheInterceptorV3\n ORDER BY cachedAt DESC\n LIMIT ?\n )\n ")}close(){this.#o.close()}get(e){r(e);const t=this.#I(e);return t?{body:t.body?Buffer.from(t.body.buffer,t.body.byteOffset,t.body.byteLength):void 0,statusCode:t.statusCode,statusMessage:t.statusMessage,headers:t.headers?JSON.parse(t.headers):void 0,etag:t.etag?t.etag:void 0,vary:t.vary?JSON.parse(t.vary):void 0,cacheControlDirectives:t.cacheControlDirectives?JSON.parse(t.cacheControlDirectives):void 0,cachedAt:t.cachedAt,staleAt:t.staleAt,deleteAt:t.deleteAt}:void 0}set(e,t){r(e);const s=this.#E(e),n=Array.isArray(t.body)?Buffer.concat(t.body):t.body,i=n?.byteLength;if(i&&i>this.#s)return;const A=this.#I(e,!0);A?this.#c.run(n,t.deleteAt,t.statusCode,t.statusMessage,t.headers?JSON.stringify(t.headers):null,t.etag?t.etag:null,t.cacheControlDirectives?JSON.stringify(t.cacheControlDirectives):null,t.cachedAt,t.staleAt,A.id):(this.#p(),this.#l.run(s,e.method,n,t.deleteAt,t.statusCode,t.statusMessage,t.headers?JSON.stringify(t.headers):null,t.etag?t.etag:null,t.cacheControlDirectives?JSON.stringify(t.cacheControlDirectives):null,t.vary?JSON.stringify(t.vary):null,t.cachedAt,t.staleAt))}createWriteStream(e,t){r(e),i(t);let s=0;const A=[],o=this;return new n({decodeStrings:!0,write(e,t,n){s+=e.byteLength,s<o.#s?A.push(e):this.destroy(),n()},final(s){o.set(e,{...t,body:A}),s()}})}delete(e){if("object"!=typeof e)throw new TypeError("expected key to be object, got "+typeof e);this.#g.run(this.#E(e))}#p(){if(Number.isFinite(this.#e)&&this.size<=this.#e)return 0;{const e=this.#h.run(Date.now()).changes;if(e)return e}{const e=this.#u?.run(Math.max(Math.floor(.1*this.#e),1)).changes;if(e)return e}return 0}get size(){const{total:e}=this.#d.get();return e}#E(e){return`${e.origin}/${e.path}`}#I(e,t=!1){const s=this.#E(e),{headers:n,method:r}=e,i=this.#a.all(s,r);if(0===i.length)return;const A=Date.now();for(const e of i){if(A>=e.deleteAt&&!t)return;let s=!0;if(e.vary){const t=JSON.parse(e.vary);for(const e in t)if(!a(n[e],t[e])){s=!1;break}}if(s)return e}}}},1986:(e,t,s)=>{"use strict";const n=s(7030),r=s(4589),i=s(2858),{InvalidArgumentError:A}=s(4465);let o;const a=class{constructor(e){this._maxCachedSessions=e,this._sessionCache=new Map,this._sessionRegistry=new FinalizationRegistry((e=>{if(this._sessionCache.size<this._maxCachedSessions)return;const t=this._sessionCache.get(e);void 0!==t&&void 0===t.deref()&&this._sessionCache.delete(e)}))}get(e){const t=this._sessionCache.get(e);return t?t.deref():null}set(e,t){0!==this._maxCachedSessions&&(this._sessionCache.set(e,new WeakRef(t)),this._sessionRegistry.register(t,e))}};e.exports=function({allowH2:e,maxCachedSessions:t,socketPath:c,timeout:l,session:h,...g}){if(null!=t&&(!Number.isInteger(t)||t<0))throw new A("maxCachedSessions must be a positive integer or zero");const d={path:c,...g},u=new a(null==t?100:t);return l=null==l?1e4:l,e=null!=e&&e,function({hostname:t,host:A,protocol:a,port:c,servername:g,localAddress:I,httpSocket:E},p){let C;if("https:"===a){o||(o=s(1692));const n=(g=g||d.servername||i.getServerName(A)||null)||t;r(n);const a=h||u.get(n)||null;c=c||443,C=o.connect({highWaterMark:16384,...d,servername:g,session:a,localAddress:I,ALPNProtocols:e?["http/1.1","h2"]:["http/1.1"],socket:E,port:c,host:t}),C.on("session",(function(e){u.set(n,e)}))}else r(!E,"httpSocket can only be sent on TLS update"),c=c||80,C=n.connect({highWaterMark:65536,...d,localAddress:I,port:c,host:t});if(null==d.keepAlive||d.keepAlive){const e=void 0===d.keepAliveInitialDelay?6e4:d.keepAliveInitialDelay;C.setKeepAlive(!0,e)}const B=i.setupConnectTimeout(new WeakRef(C),{timeout:l,hostname:t,port:c});return C.setNoDelay(!0).once("https:"===a?"secureConnect":"connect",(function(){if(queueMicrotask(B),p){const e=p;p=null,e(null,this)}})).on("error",(function(e){if(queueMicrotask(B),p){const t=p;p=null,t(e)}})),C}}},9605:e=>{"use strict";const t=["Accept","Accept-Encoding","Accept-Language","Accept-Ranges","Access-Control-Allow-Credentials","Access-Control-Allow-Headers","Access-Control-Allow-Methods","Access-Control-Allow-Origin","Access-Control-Expose-Headers","Access-Control-Max-Age","Access-Control-Request-Headers","Access-Control-Request-Method","Age","Allow","Alt-Svc","Alt-Used","Authorization","Cache-Control","Clear-Site-Data","Connection","Content-Disposition","Content-Encoding","Content-Language","Content-Length","Content-Location","Content-Range","Content-Security-Policy","Content-Security-Policy-Report-Only","Content-Type","Cookie","Cross-Origin-Embedder-Policy","Cross-Origin-Opener-Policy","Cross-Origin-Resource-Policy","Date","Device-Memory","Downlink","ECT","ETag","Expect","Expect-CT","Expires","Forwarded","From","Host","If-Match","If-Modified-Since","If-None-Match","If-Range","If-Unmodified-Since","Keep-Alive","Last-Modified","Link","Location","Max-Forwards","Origin","Permissions-Policy","Pragma","Proxy-Authenticate","Proxy-Authorization","RTT","Range","Referer","Referrer-Policy","Refresh","Retry-After","Sec-WebSocket-Accept","Sec-WebSocket-Extensions","Sec-WebSocket-Key","Sec-WebSocket-Protocol","Sec-WebSocket-Version","Server","Server-Timing","Service-Worker-Allowed","Service-Worker-Navigation-Preload","Set-Cookie","SourceMap","Strict-Transport-Security","Supports-Loading-Mode","TE","Timing-Allow-Origin","Trailer","Transfer-Encoding","Upgrade","Upgrade-Insecure-Requests","User-Agent","Vary","Via","WWW-Authenticate","X-Content-Type-Options","X-DNS-Prefetch-Control","X-Frame-Options","X-Permitted-Cross-Domain-Policies","X-Powered-By","X-Requested-With","X-XSS-Protection"],s={};Object.setPrototypeOf(s,null);const n={};Object.setPrototypeOf(n,null);for(let e=0;e<t.length;++e){const n=t[e],r=n.toLowerCase();s[n]=s[r]=r}e.exports={wellknownHeaderNames:t,headerNameLowerCasedRecord:s,getHeaderNameAsBuffer:function(e){let t=n[e];return void 0===t&&(t=Buffer.from(e)),t}}},772:(e,t,s)=>{"use strict";const n=s(3053),r=s(7975),i=r.debuglog("undici"),A=r.debuglog("fetch"),o=r.debuglog("websocket"),a={beforeConnect:n.channel("undici:client:beforeConnect"),connected:n.channel("undici:client:connected"),connectError:n.channel("undici:client:connectError"),sendHeaders:n.channel("undici:client:sendHeaders"),create:n.channel("undici:request:create"),bodySent:n.channel("undici:request:bodySent"),bodyChunkSent:n.channel("undici:request:bodyChunkSent"),bodyChunkReceived:n.channel("undici:request:bodyChunkReceived"),headers:n.channel("undici:request:headers"),trailers:n.channel("undici:request:trailers"),error:n.channel("undici:request:error"),open:n.channel("undici:websocket:open"),close:n.channel("undici:websocket:close"),socketError:n.channel("undici:websocket:socket_error"),ping:n.channel("undici:websocket:ping"),pong:n.channel("undici:websocket:pong")};let c=!1;function l(e=i){c||(c=!0,n.subscribe("undici:client:beforeConnect",(t=>{const{connectParams:{version:s,protocol:n,port:r,host:i}}=t;e("connecting to %s%s using %s%s",i,r?`:${r}`:"",n,s)})),n.subscribe("undici:client:connected",(t=>{const{connectParams:{version:s,protocol:n,port:r,host:i}}=t;e("connected to %s%s using %s%s",i,r?`:${r}`:"",n,s)})),n.subscribe("undici:client:connectError",(t=>{const{connectParams:{version:s,protocol:n,port:r,host:i},error:A}=t;e("connection to %s%s using %s%s errored - %s",i,r?`:${r}`:"",n,s,A.message)})),n.subscribe("undici:client:sendHeaders",(t=>{const{request:{method:s,path:n,origin:r}}=t;e("sending request to %s %s%s",s,r,n)})))}let h=!1;let g=!1;(i.enabled||A.enabled)&&(l(A.enabled?A:i),function(e=i){h||(h=!0,n.subscribe("undici:request:headers",(t=>{const{request:{method:s,path:n,origin:r},response:{statusCode:i}}=t;e("received response to %s %s%s - HTTP %d",s,r,n,i)})),n.subscribe("undici:request:trailers",(t=>{const{request:{method:s,path:n,origin:r}}=t;e("trailers received from %s %s%s",s,r,n)})),n.subscribe("undici:request:error",(t=>{const{request:{method:s,path:n,origin:r},error:i}=t;e("request to %s %s%s errored - %s",s,r,n,i.message)})))}(A.enabled?A:i)),o.enabled&&(l(i.enabled?i:o),function(e=o){g||(g=!0,n.subscribe("undici:websocket:open",(t=>{const{address:{address:s,port:n}}=t;e("connection opened %s%s",s,n?`:${n}`:"")})),n.subscribe("undici:websocket:close",(t=>{const{websocket:s,code:n,reason:r}=t;e("closed connection to %s - %s %s",s.url,n,r)})),n.subscribe("undici:websocket:socket_error",(t=>{e("connection errored - %s",t.message)})),n.subscribe("undici:websocket:ping",(t=>{e("ping received")})),n.subscribe("undici:websocket:pong",(t=>{e("pong received")})))}(o)),e.exports={channels:a}},4465:e=>{"use strict";const t=Symbol.for("undici.error.UND_ERR");class s extends Error{constructor(e,t){super(e,t),this.name="UndiciError",this.code="UND_ERR"}static[Symbol.hasInstance](e){return e&&!0===e[t]}get[t](){return!0}}const n=Symbol.for("undici.error.UND_ERR_CONNECT_TIMEOUT");class r extends s{constructor(e){super(e),this.name="ConnectTimeoutError",this.message=e||"Connect Timeout Error",this.code="UND_ERR_CONNECT_TIMEOUT"}static[Symbol.hasInstance](e){return e&&!0===e[n]}get[n](){return!0}}const i=Symbol.for("undici.error.UND_ERR_HEADERS_TIMEOUT");class A extends s{constructor(e){super(e),this.name="HeadersTimeoutError",this.message=e||"Headers Timeout Error",this.code="UND_ERR_HEADERS_TIMEOUT"}static[Symbol.hasInstance](e){return e&&!0===e[i]}get[i](){return!0}}const o=Symbol.for("undici.error.UND_ERR_HEADERS_OVERFLOW");class a extends s{constructor(e){super(e),this.name="HeadersOverflowError",this.message=e||"Headers Overflow Error",this.code="UND_ERR_HEADERS_OVERFLOW"}static[Symbol.hasInstance](e){return e&&!0===e[o]}get[o](){return!0}}const c=Symbol.for("undici.error.UND_ERR_BODY_TIMEOUT");class l extends s{constructor(e){super(e),this.name="BodyTimeoutError",this.message=e||"Body Timeout Error",this.code="UND_ERR_BODY_TIMEOUT"}static[Symbol.hasInstance](e){return e&&!0===e[c]}get[c](){return!0}}const h=Symbol.for("undici.error.UND_ERR_INVALID_ARG");class g extends s{constructor(e){super(e),this.name="InvalidArgumentError",this.message=e||"Invalid Argument Error",this.code="UND_ERR_INVALID_ARG"}static[Symbol.hasInstance](e){return e&&!0===e[h]}get[h](){return!0}}const d=Symbol.for("undici.error.UND_ERR_INVALID_RETURN_VALUE");class u extends s{constructor(e){super(e),this.name="InvalidReturnValueError",this.message=e||"Invalid Return Value Error",this.code="UND_ERR_INVALID_RETURN_VALUE"}static[Symbol.hasInstance](e){return e&&!0===e[d]}get[d](){return!0}}const I=Symbol.for("undici.error.UND_ERR_ABORT");class E extends s{constructor(e){super(e),this.name="AbortError",this.message=e||"The operation was aborted",this.code="UND_ERR_ABORT"}static[Symbol.hasInstance](e){return e&&!0===e[I]}get[I](){return!0}}const p=Symbol.for("undici.error.UND_ERR_ABORTED");class C extends E{constructor(e){super(e),this.name="AbortError",this.message=e||"Request aborted",this.code="UND_ERR_ABORTED"}static[Symbol.hasInstance](e){return e&&!0===e[p]}get[p](){return!0}}const B=Symbol.for("undici.error.UND_ERR_INFO");class Q extends s{constructor(e){super(e),this.name="InformationalError",this.message=e||"Request information",this.code="UND_ERR_INFO"}static[Symbol.hasInstance](e){return e&&!0===e[B]}get[B](){return!0}}const f=Symbol.for("undici.error.UND_ERR_REQ_CONTENT_LENGTH_MISMATCH");class m extends s{constructor(e){super(e),this.name="RequestContentLengthMismatchError",this.message=e||"Request body length does not match content-length header",this.code="UND_ERR_REQ_CONTENT_LENGTH_MISMATCH"}static[Symbol.hasInstance](e){return e&&!0===e[f]}get[f](){return!0}}const y=Symbol.for("undici.error.UND_ERR_RES_CONTENT_LENGTH_MISMATCH");class S extends s{constructor(e){super(e),this.name="ResponseContentLengthMismatchError",this.message=e||"Response body length does not match content-length header",this.code="UND_ERR_RES_CONTENT_LENGTH_MISMATCH"}static[Symbol.hasInstance](e){return e&&!0===e[y]}get[y](){return!0}}const w=Symbol.for("undici.error.UND_ERR_DESTROYED");class D extends s{constructor(e){super(e),this.name="ClientDestroyedError",this.message=e||"The client is destroyed",this.code="UND_ERR_DESTROYED"}static[Symbol.hasInstance](e){return e&&!0===e[w]}get[w](){return!0}}const b=Symbol.for("undici.error.UND_ERR_CLOSED");class v extends s{constructor(e){super(e),this.name="ClientClosedError",this.message=e||"The client is closed",this.code="UND_ERR_CLOSED"}static[Symbol.hasInstance](e){return e&&!0===e[b]}get[b](){return!0}}const N=Symbol.for("undici.error.UND_ERR_SOCKET");class R extends s{constructor(e,t){super(e),this.name="SocketError",this.message=e||"Socket error",this.code="UND_ERR_SOCKET",this.socket=t}static[Symbol.hasInstance](e){return e&&!0===e[N]}get[N](){return!0}}const k=Symbol.for("undici.error.UND_ERR_NOT_SUPPORTED");class T extends s{constructor(e){super(e),this.name="NotSupportedError",this.message=e||"Not supported error",this.code="UND_ERR_NOT_SUPPORTED"}static[Symbol.hasInstance](e){return e&&!0===e[k]}get[k](){return!0}}const F=Symbol.for("undici.error.UND_ERR_BPL_MISSING_UPSTREAM");class M extends s{constructor(e){super(e),this.name="MissingUpstreamError",this.message=e||"No upstream has been added to the BalancedPool",this.code="UND_ERR_BPL_MISSING_UPSTREAM"}static[Symbol.hasInstance](e){return e&&!0===e[F]}get[F](){return!0}}const U=Symbol.for("undici.error.UND_ERR_HTTP_PARSER");class L extends Error{constructor(e,t,s){super(e),this.name="HTTPParserError",this.code=t?`HPE_${t}`:void 0,this.data=s?s.toString():void 0}static[Symbol.hasInstance](e){return e&&!0===e[U]}get[U](){return!0}}const P=Symbol.for("undici.error.UND_ERR_RES_EXCEEDED_MAX_SIZE");class H extends s{constructor(e){super(e),this.name="ResponseExceededMaxSizeError",this.message=e||"Response content exceeded max size",this.code="UND_ERR_RES_EXCEEDED_MAX_SIZE"}static[Symbol.hasInstance](e){return e&&!0===e[P]}get[P](){return!0}}const x=Symbol.for("undici.error.UND_ERR_REQ_RETRY");class Y extends s{constructor(e,t,{headers:s,data:n}){super(e),this.name="RequestRetryError",this.message=e||"Request retry error",this.code="UND_ERR_REQ_RETRY",this.statusCode=t,this.data=n,this.headers=s}static[Symbol.hasInstance](e){return e&&!0===e[x]}get[x](){return!0}}const V=Symbol.for("undici.error.UND_ERR_RESPONSE");class O extends s{constructor(e,t,{headers:s,body:n}){super(e),this.name="ResponseError",this.message=e||"Response error",this.code="UND_ERR_RESPONSE",this.statusCode=t,this.body=n,this.headers=s}static[Symbol.hasInstance](e){return e&&!0===e[V]}get[V](){return!0}}const G=Symbol.for("undici.error.UND_ERR_PRX_TLS");class J extends s{constructor(e,t,s={}){super(t,{cause:e,...s}),this.name="SecureProxyConnectionError",this.message=t||"Secure Proxy Connection failed",this.code="UND_ERR_PRX_TLS",this.cause=e}static[Symbol.hasInstance](e){return e&&!0===e[G]}get[G](){return!0}}const W=Symbol.for("undici.error.UND_ERR_MAX_ORIGINS_REACHED");class _ extends s{constructor(e){super(e),this.name="MaxOriginsReachedError",this.message=e||"Maximum allowed origins reached",this.code="UND_ERR_MAX_ORIGINS_REACHED"}static[Symbol.hasInstance](e){return e&&!0===e[W]}get[W](){return!0}}e.exports={AbortError:E,HTTPParserError:L,UndiciError:s,HeadersTimeoutError:A,HeadersOverflowError:a,BodyTimeoutError:l,RequestContentLengthMismatchError:m,ConnectTimeoutError:r,InvalidArgumentError:g,InvalidReturnValueError:u,RequestAbortedError:C,ClientDestroyedError:D,ClientClosedError:v,InformationalError:Q,SocketError:R,NotSupportedError:T,ResponseContentLengthMismatchError:S,BalancedPoolMissingUpstreamError:M,ResponseExceededMaxSizeError:H,RequestRetryError:Y,ResponseError:O,SecureProxyConnectionError:J,MaxOriginsReachedError:_}},5837:(e,t,s)=>{"use strict";const{InvalidArgumentError:n,NotSupportedError:r}=s(4465),i=s(4589),{isValidHTTPToken:A,isValidHeaderValue:o,isStream:a,destroy:c,isBuffer:l,isFormDataLike:h,isIterable:g,isBlobLike:d,serializePathWithQuery:u,assertRequestHandler:I,getServerName:E,normalizedMethodRecords:p,getProtocolFromUrlString:C}=s(2858),{channels:B}=s(772),{headerNameLowerCasedRecord:Q}=s(9605),f=/[^\u0021-\u00ff]/,m=Symbol("handler");function y(e,t,s){if(s&&"object"==typeof s&&!Array.isArray(s))throw new n(`invalid ${t} header`);if(void 0===s)return;let i=Q[t];if(void 0===i&&(i=t.toLowerCase(),void 0===Q[i]&&!A(i)))throw new n("invalid header key");if(Array.isArray(s)){const e=[];for(let r=0;r<s.length;r++)if("string"==typeof s[r]){if(!o(s[r]))throw new n(`invalid ${t} header`);e.push(s[r])}else if(null===s[r])e.push("");else{if("object"==typeof s[r])throw new n(`invalid ${t} header`);e.push(`${s[r]}`)}s=e}else if("string"==typeof s){if(!o(s))throw new n(`invalid ${t} header`)}else s=null===s?"":`${s}`;if(null===e.host&&"host"===i){if("string"!=typeof s)throw new n("invalid host header");e.host=s}else if(null===e.contentLength&&"content-length"===i){if(e.contentLength=parseInt(s,10),!Number.isFinite(e.contentLength))throw new n("invalid content-length header")}else if(null===e.contentType&&"content-type"===i)e.contentType=s,e.headers.push(t,s);else{if("transfer-encoding"===i||"keep-alive"===i||"upgrade"===i)throw new n(`invalid ${i} header`);if("connection"===i){const t="string"==typeof s?s.toLowerCase():null;if("close"!==t&&"keep-alive"!==t)throw new n("invalid connection header");"close"===t&&(e.reset=!0)}else{if("expect"===i)throw new r("expect header not supported");e.headers.push(t,s)}}}e.exports=class{constructor(e,{path:t,method:s,body:r,headers:i,query:o,idempotent:Q,blocking:S,upgrade:w,headersTimeout:D,bodyTimeout:b,reset:v,expectContinue:N,servername:R,throwOnError:k,maxRedirections:T},F){if("string"!=typeof t)throw new n("path must be a string");if("/"!==t[0]&&!t.startsWith("http://")&&!t.startsWith("https://")&&"CONNECT"!==s)throw new n("path must be an absolute URL or start with a slash");if(f.test(t))throw new n("invalid request path");if("string"!=typeof s)throw new n("method must be a string");if(void 0===p[s]&&!A(s))throw new n("invalid request method");if(w&&"string"!=typeof w)throw new n("upgrade must be a string");if(null!=D&&(!Number.isFinite(D)||D<0))throw new n("invalid headersTimeout");if(null!=b&&(!Number.isFinite(b)||b<0))throw new n("invalid bodyTimeout");if(null!=v&&"boolean"!=typeof v)throw new n("invalid reset");if(null!=N&&"boolean"!=typeof N)throw new n("invalid expectContinue");if(null!=k)throw new n("invalid throwOnError");if(null!=T&&0!==T)throw new n("maxRedirections is not supported, use the redirect interceptor");if(this.headersTimeout=D,this.bodyTimeout=b,this.method=s,this.abort=null,null==r)this.body=null;else if(a(r)){this.body=r;const e=this.body._readableState;e&&e.autoDestroy||(this.endHandler=function(){c(this)},this.body.on("end",this.endHandler)),this.errorHandler=e=>{this.abort?this.abort(e):this.error=e},this.body.on("error",this.errorHandler)}else if(l(r))this.body=r.byteLength?r:null;else if(ArrayBuffer.isView(r))this.body=r.buffer.byteLength?Buffer.from(r.buffer,r.byteOffset,r.byteLength):null;else if(r instanceof ArrayBuffer)this.body=r.byteLength?Buffer.from(r):null;else if("string"==typeof r)this.body=r.length?Buffer.from(r):null;else{if(!(h(r)||g(r)||d(r)))throw new n("body must be a string, a Buffer, a Readable stream, an iterable, or an async iterable");this.body=r}if(this.completed=!1,this.aborted=!1,this.upgrade=w||null,this.path=o?u(t,o):t,this.origin=e,this.protocol=C(e),this.idempotent=null==Q?"HEAD"===s||"GET"===s:Q,this.blocking=S??"HEAD"!==this.method,this.reset=null==v?null:v,this.host=null,this.contentLength=null,this.contentType=null,this.headers=[],this.expectContinue=null!=N&&N,Array.isArray(i)){if(i.length%2!=0)throw new n("headers array must be even");for(let e=0;e<i.length;e+=2)y(this,i[e],i[e+1])}else if(i&&"object"==typeof i)if(i[Symbol.iterator])for(const e of i){if(!Array.isArray(e)||2!==e.length)throw new n("headers must be in key-value pair format");y(this,e[0],e[1])}else{const e=Object.keys(i);for(let t=0;t<e.length;++t)y(this,e[t],i[e[t]])}else if(null!=i)throw new n("headers must be an object or an array");I(F,s,w),this.servername=R||E(this.host)||null,this[m]=F,B.create.hasSubscribers&&B.create.publish({request:this})}onBodySent(e){if(B.bodyChunkSent.hasSubscribers&&B.bodyChunkSent.publish({request:this,chunk:e}),this[m].onBodySent)try{return this[m].onBodySent(e)}catch(e){this.abort(e)}}onRequestSent(){if(B.bodySent.hasSubscribers&&B.bodySent.publish({request:this}),this[m].onRequestSent)try{return this[m].onRequestSent()}catch(e){this.abort(e)}}onConnect(e){if(i(!this.aborted),i(!this.completed),!this.error)return this.abort=e,this[m].onConnect(e);e(this.error)}onResponseStarted(){return this[m].onResponseStarted?.()}onHeaders(e,t,s,n){i(!this.aborted),i(!this.completed),B.headers.hasSubscribers&&B.headers.publish({request:this,response:{statusCode:e,headers:t,statusText:n}});try{return this[m].onHeaders(e,t,s,n)}catch(e){this.abort(e)}}onData(e){i(!this.aborted),i(!this.completed),B.bodyChunkReceived.hasSubscribers&&B.bodyChunkReceived.publish({request:this,chunk:e});try{return this[m].onData(e)}catch(e){return this.abort(e),!1}}onUpgrade(e,t,s){return i(!this.aborted),i(!this.completed),this[m].onUpgrade(e,t,s)}onComplete(e){this.onFinally(),i(!this.aborted),i(!this.completed),this.completed=!0,B.trailers.hasSubscribers&&B.trailers.publish({request:this,trailers:e});try{return this[m].onComplete(e)}catch(e){this.onError(e)}}onError(e){if(this.onFinally(),B.error.hasSubscribers&&B.error.publish({request:this,error:e}),!this.aborted)return this.aborted=!0,this[m].onError(e)}onFinally(){this.errorHandler&&(this.body.off("error",this.errorHandler),this.errorHandler=null),this.endHandler&&(this.body.off("end",this.endHandler),this.endHandler=null)}addHeader(e,t){return y(this,e,t),this}}},257:e=>{"use strict";e.exports={kClose:Symbol("close"),kDestroy:Symbol("destroy"),kDispatch:Symbol("dispatch"),kUrl:Symbol("url"),kWriting:Symbol("writing"),kResuming:Symbol("resuming"),kQueue:Symbol("queue"),kConnect:Symbol("connect"),kConnecting:Symbol("connecting"),kKeepAliveDefaultTimeout:Symbol("default keep alive timeout"),kKeepAliveMaxTimeout:Symbol("max keep alive timeout"),kKeepAliveTimeoutThreshold:Symbol("keep alive timeout threshold"),kKeepAliveTimeoutValue:Symbol("keep alive timeout"),kKeepAlive:Symbol("keep alive"),kHeadersTimeout:Symbol("headers timeout"),kBodyTimeout:Symbol("body timeout"),kServerName:Symbol("server name"),kLocalAddress:Symbol("local address"),kHost:Symbol("host"),kNoRef:Symbol("no ref"),kBodyUsed:Symbol("used"),kBody:Symbol("abstracted request body"),kRunning:Symbol("running"),kBlocking:Symbol("blocking"),kPending:Symbol("pending"),kSize:Symbol("size"),kBusy:Symbol("busy"),kQueued:Symbol("queued"),kFree:Symbol("free"),kConnected:Symbol("connected"),kClosed:Symbol("closed"),kNeedDrain:Symbol("need drain"),kReset:Symbol("reset"),kDestroyed:Symbol.for("nodejs.stream.destroyed"),kResume:Symbol("resume"),kOnError:Symbol("on error"),kMaxHeadersSize:Symbol("max headers size"),kRunningIdx:Symbol("running index"),kPendingIdx:Symbol("pending index"),kError:Symbol("error"),kClients:Symbol("clients"),kClient:Symbol("client"),kParser:Symbol("parser"),kOnDestroyed:Symbol("destroy callbacks"),kPipelining:Symbol("pipelining"),kSocket:Symbol("socket"),kHostHeader:Symbol("host header"),kConnector:Symbol("connector"),kStrictContentLength:Symbol("strict content length"),kMaxRedirections:Symbol("maxRedirections"),kMaxRequests:Symbol("maxRequestsPerClient"),kProxy:Symbol("proxy agent options"),kCounter:Symbol("socket request counter"),kMaxResponseSize:Symbol("max response size"),kHTTP2Session:Symbol("http2Session"),kHTTP2SessionState:Symbol("http2Session state"),kRetryHandlerDefaultRetry:Symbol("retry agent default retry"),kConstruct:Symbol("constructable"),kListeners:Symbol("listeners"),kHTTPContext:Symbol("http context"),kMaxConcurrentStreams:Symbol("max concurrent streams"),kNoProxyAgent:Symbol("no proxy agent"),kHttpProxyAgent:Symbol("http proxy agent"),kHttpsProxyAgent:Symbol("https proxy agent")}},1310:(e,t,s)=>{"use strict";const{wellknownHeaderNames:n,headerNameLowerCasedRecord:r}=s(9605);class i{value=null;left=null;middle=null;right=null;code;constructor(e,t,s){if(void 0===s||s>=e.length)throw new TypeError("Unreachable");if((this.code=e.charCodeAt(s))>127)throw new TypeError("key must be ascii string");e.length!==++s?this.middle=new i(e,t,s):this.value=t}add(e,t){const s=e.length;if(0===s)throw new TypeError("Unreachable");let n=0,r=this;for(;;){const A=e.charCodeAt(n);if(A>127)throw new TypeError("key must be ascii string");if(r.code===A){if(s===++n){r.value=t;break}if(null===r.middle){r.middle=new i(e,t,n);break}r=r.middle}else if(r.code<A){if(null===r.left){r.left=new i(e,t,n);break}r=r.left}else{if(null===r.right){r.right=new i(e,t,n);break}r=r.right}}}search(e){const t=e.length;let s=0,n=this;for(;null!==n&&s<t;){let r=e[s];for(r<=90&&r>=65&&(r|=32);null!==n;){if(r===n.code){if(t===++s)return n;n=n.middle;break}n=n.code<r?n.left:n.right}}return null}}class A{node=null;insert(e,t){null===this.node?this.node=new i(e,t,0):this.node.add(e,t)}lookup(e){return this.node?.search(e)?.value??null}}const o=new A;for(let e=0;e<n.length;++e){const t=r[n[e]];o.insert(t,t)}e.exports={TernarySearchTree:A,tree:o}},2858:(e,t,s)=>{"use strict";const n=s(4589),{kDestroyed:r,kBodyUsed:i,kListeners:A,kBody:o}=s(257),{IncomingMessage:a}=s(7067),c=s(7075),l=s(7030),{stringify:h}=s(1792),{EventEmitter:g}=s(8474),d=s(3801),{InvalidArgumentError:u,ConnectTimeoutError:I}=s(4465),{headerNameLowerCasedRecord:E}=s(9605),{tree:p}=s(1310),[C,B]=process.versions.node.split(".",2).map((e=>Number(e)));class Q{constructor(e){this[o]=e,this[i]=!1}async*[Symbol.asyncIterator](){n(!this[i],"disturbed"),this[i]=!0,yield*this[o]}}function f(){}function m(e){return e&&"object"==typeof e&&"function"==typeof e.pipe&&"function"==typeof e.on}function y(e){if(null===e)return!1;if(e instanceof Blob)return!0;if("object"!=typeof e)return!1;{const t=e[Symbol.toStringTag];return("Blob"===t||"File"===t)&&("stream"in e&&"function"==typeof e.stream||"arrayBuffer"in e&&"function"==typeof e.arrayBuffer)}}function S(e){return e.includes("?")||e.includes("#")}function w(e){const t=parseInt(e,10);return t===Number(e)&&t>=0&&t<=65535}function D(e){return null!=e&&"h"===e[0]&&"t"===e[1]&&"t"===e[2]&&"p"===e[3]&&(":"===e[4]||"s"===e[4]&&":"===e[5])}function b(e){if("string"==typeof e){if(!D((e=new URL(e)).origin||e.protocol))throw new u("Invalid URL protocol: the URL must start with `http:` or `https:`.");return e}if(!e||"object"!=typeof e)throw new u("Invalid URL: The URL argument must be a non-null object.");if(!(e instanceof URL)){if(null!=e.port&&""!==e.port&&!1===w(e.port))throw new u("Invalid URL: port must be a valid integer or a string representation of an integer.");if(null!=e.path&&"string"!=typeof e.path)throw new u("Invalid URL path: the path must be a string or null/undefined.");if(null!=e.pathname&&"string"!=typeof e.pathname)throw new u("Invalid URL pathname: the pathname must be a string or null/undefined.");if(null!=e.hostname&&"string"!=typeof e.hostname)throw new u("Invalid URL hostname: the hostname must be a string or null/undefined.");if(null!=e.origin&&"string"!=typeof e.origin)throw new u("Invalid URL origin: the origin must be a string or null/undefined.");if(!D(e.origin||e.protocol))throw new u("Invalid URL protocol: the URL must start with `http:` or `https:`.");const t=null!=e.port?e.port:"https:"===e.protocol?443:80;let s=null!=e.origin?e.origin:`${e.protocol||""}//${e.hostname||""}:${t}`,n=null!=e.path?e.path:`${e.pathname||""}${e.search||""}`;return"/"===s[s.length-1]&&(s=s.slice(0,s.length-1)),n&&"/"!==n[0]&&(n=`/${n}`),new URL(`${s}${n}`)}if(!D(e.origin||e.protocol))throw new u("Invalid URL protocol: the URL must start with `http:` or `https:`.");return e}function v(e){return!(null==e||"function"!=typeof e[Symbol.iterator]&&"function"!=typeof e[Symbol.asyncIterator])}function N(e){if(null==e)return 0;if(m(e)){const t=e._readableState;return t&&!1===t.objectMode&&!0===t.ended&&Number.isFinite(t.length)?t.length:null}return y(e)?null!=e.size?e.size:null:M(e)?e.byteLength:null}function R(e){return e&&!!(e.destroyed||e[r]||c.isDestroyed?.(e))}function k(e,t){null!=e&&m(e)&&!R(e)&&("function"==typeof e.destroy?(Object.getPrototypeOf(e).constructor===a&&(e.socket=null),e.destroy(t)):t&&queueMicrotask((()=>{e.emit("error",t)})),!0!==e.destroyed&&(e[r]=!0))}const T=/timeout=(\d+)/;function F(e){return"string"==typeof e?E[e]??e.toLowerCase():p.lookup(e)??e.toString("latin1").toLowerCase()}function M(e){return e instanceof Uint8Array||Buffer.isBuffer(e)}function U(e){switch(e){case 34:case 40:case 41:case 44:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 123:case 125:return!1;default:return e>=33&&e<=126}}const L=/[^\t\x20-\x7e\x80-\xff]/;const P=/^bytes (\d+)-(\d+)\/(\d+)?$/;const H="win32"===process.platform?(e,t)=>{if(!t.timeout)return f;let s=null,n=null;const r=d.setFastTimeout((()=>{s=setImmediate((()=>{n=setImmediate((()=>x(e.deref(),t)))}))}),t.timeout);return()=>{d.clearFastTimeout(r),clearImmediate(s),clearImmediate(n)}}:(e,t)=>{if(!t.timeout)return f;let s=null;const n=d.setFastTimeout((()=>{s=setImmediate((()=>{x(e.deref(),t)}))}),t.timeout);return()=>{d.clearFastTimeout(n),clearImmediate(s)}};function x(e,t){if(null==e)return;let s="Connect Timeout Error";Array.isArray(e.autoSelectFamilyAttemptedAddresses)?s+=` (attempted addresses: ${e.autoSelectFamilyAttemptedAddresses.join(", ")},`:s+=` (attempted address: ${t.hostname}:${t.port},`,s+=` timeout: ${t.timeout}ms)`,k(e,new I(s))}const Y=Object.create(null);Y.enumerable=!0;const V={delete:"DELETE",DELETE:"DELETE",get:"GET",GET:"GET",head:"HEAD",HEAD:"HEAD",options:"OPTIONS",OPTIONS:"OPTIONS",post:"POST",POST:"POST",put:"PUT",PUT:"PUT"},O={...V,patch:"patch",PATCH:"PATCH"};Object.setPrototypeOf(V,null),Object.setPrototypeOf(O,null),e.exports={kEnumerableProperty:Y,isDisturbed:function(e){return!(!e||!c.isDisturbed(e)&&!e[i])},isBlobLike:y,parseOrigin:function(e){if("/"!==(e=b(e)).pathname||e.search||e.hash)throw new u("invalid url");return e},parseURL:b,getServerName:function(e){if(!e)return null;n("string"==typeof e);const t=function(e){if("["===e[0]){const t=e.indexOf("]");return n(-1!==t),e.substring(1,t)}const t=e.indexOf(":");return-1===t?e:e.substring(0,t)}(e);return l.isIP(t)?"":t},isStream:m,isIterable:v,isAsyncIterable:function(e){return!(null==e||"function"!=typeof e[Symbol.asyncIterator])},isDestroyed:R,headerNameToString:F,bufferToLowerCasedHeaderName:function(e){return p.lookup(e)??e.toString("latin1").toLowerCase()},addListener:function(e,t,s){return(e[A]??=[]).push([t,s]),e.on(t,s),e},removeAllListeners:function(e){if(null!=e[A]){for(const[t,s]of e[A])e.removeListener(t,s);e[A]=null}return e},errorRequest:function(e,t,s){try{t.onError(s),n(t.aborted)}catch(s){e.emit("error",s)}},parseRawHeaders:function(e){const t=e.length,s=new Array(t);let n,r,i=!1,A=-1,o=0;for(let a=0;a<t;a+=2)n=e[a],r=e[a+1],"string"!=typeof n&&(n=n.toString()),"string"!=typeof r&&(r=r.toString("utf8")),o=n.length,14!==o||"-"!==n[7]||"content-length"!==n&&"content-length"!==n.toLowerCase()?19!==o||"-"!==n[7]||"content-disposition"!==n&&"content-disposition"!==n.toLowerCase()||(A=a+1):i=!0,s[a]=n,s[a+1]=r;return i&&-1!==A&&(s[A]=Buffer.from(s[A]).toString("latin1")),s},encodeRawHeaders:function(e){if(!Array.isArray(e))throw new TypeError("expected headers to be an array");return e.map((e=>Buffer.from(e)))},parseHeaders:function(e,t){void 0===t&&(t={});for(let s=0;s<e.length;s+=2){const n=F(e[s]);let r=t[n];if(r)"string"==typeof r&&(r=[r],t[n]=r),r.push(e[s+1].toString("utf8"));else{const r=e[s+1];t[n]="string"==typeof r?r:Array.isArray(r)?r.map((e=>e.toString("utf8"))):r.toString("utf8")}}return"content-length"in t&&"content-disposition"in t&&(t["content-disposition"]=Buffer.from(t["content-disposition"]).toString("latin1")),t},parseKeepAliveTimeout:function(e){const t=e.match(T);return t?1e3*parseInt(t[1],10):null},destroy:k,bodyLength:N,deepClone:function(e){return JSON.parse(JSON.stringify(e))},ReadableStreamFrom:function(e){let t;return new ReadableStream({start(){t=e[Symbol.asyncIterator]()},pull(e){return t.next().then((({done:t,value:s})=>{if(t)queueMicrotask((()=>{e.close(),e.byobRequest?.respond(0)}));else{const t=Buffer.isBuffer(s)?s:Buffer.from(s);if(!t.byteLength)return this.pull(e);e.enqueue(new Uint8Array(t))}}))},cancel:()=>t.return(),type:"bytes"})},isBuffer:M,assertRequestHandler:function(e,t,s){if(!e||"object"!=typeof e)throw new u("handler must be an object");if("function"!=typeof e.onRequestStart){if("function"!=typeof e.onConnect)throw new u("invalid onConnect method");if("function"!=typeof e.onError)throw new u("invalid onError method");if("function"!=typeof e.onBodySent&&void 0!==e.onBodySent)throw new u("invalid onBodySent method");if(s||"CONNECT"===t){if("function"!=typeof e.onUpgrade)throw new u("invalid onUpgrade method")}else{if("function"!=typeof e.onHeaders)throw new u("invalid onHeaders method");if("function"!=typeof e.onData)throw new u("invalid onData method");if("function"!=typeof e.onComplete)throw new u("invalid onComplete method")}}},getSocketInfo:function(e){return{localAddress:e.localAddress,localPort:e.localPort,remoteAddress:e.remoteAddress,remotePort:e.remotePort,remoteFamily:e.remoteFamily,timeout:e.timeout,bytesWritten:e.bytesWritten,bytesRead:e.bytesRead}},isFormDataLike:function(e){return e&&"object"==typeof e&&"function"==typeof e.append&&"function"==typeof e.delete&&"function"==typeof e.get&&"function"==typeof e.getAll&&"function"==typeof e.has&&"function"==typeof e.set&&"FormData"===e[Symbol.toStringTag]},pathHasQueryOrFragment:S,serializePathWithQuery:function(e,t){if(S(e))throw new Error('Query params cannot be passed when url already contains "?" or "#".');const s=h(t);return s&&(e+="?"+s),e},addAbortListener:function(e,t){return"addEventListener"in e?(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)):(e.once("abort",t),()=>e.removeListener("abort",t))},isValidHTTPToken:function(e){if(0===e.length)return!1;for(let t=0;t<e.length;++t)if(!U(e.charCodeAt(t)))return!1;return!0},isValidHeaderValue:function(e){return!L.test(e)},isTokenCharCode:U,parseRangeHeader:function(e){if(null==e||""===e)return{start:0,end:null,size:null};const t=e?e.match(P):null;return t?{start:parseInt(t[1]),end:t[2]?parseInt(t[2]):null,size:t[3]?parseInt(t[3]):null}:null},normalizedMethodRecordsBase:V,normalizedMethodRecords:O,isValidPort:w,isHttpOrHttpsPrefixed:D,nodeMajor:C,nodeMinor:B,safeHTTPMethods:Object.freeze(["GET","HEAD","OPTIONS","TRACE"]),wrapRequestBody:function(e){return m(e)?(0===N(e)&&e.on("data",(function(){n(!1)})),"boolean"!=typeof e.readableDidRead&&(e[i]=!1,g.prototype.on.call(e,"data",(function(){this[i]=!0}))),e):e&&"function"==typeof e.pipeTo||e&&"string"!=typeof e&&!ArrayBuffer.isView(e)&&v(e)?new Q(e):e},setupConnectTimeout:H,getProtocolFromUrlString:function(e){if("h"===e[0]&&"t"===e[1]&&"t"===e[2]&&"p"===e[3])switch(e[4]){case":":return"http:";case"s":if(":"===e[5])return"https:"}return e.slice(0,e.indexOf(":")+1)}}},3315:(e,t,s)=>{"use strict";const{InvalidArgumentError:n,MaxOriginsReachedError:r}=s(4465),{kClients:i,kRunning:A,kClose:o,kDestroy:a,kDispatch:c,kUrl:l}=s(257),h=s(7779),g=s(8542),d=s(1167),u=s(2858),I=Symbol("onConnect"),E=Symbol("onDisconnect"),p=Symbol("onConnectionError"),C=Symbol("onDrain"),B=Symbol("factory"),Q=Symbol("options"),f=Symbol("origins");function m(e,t){return t&&1===t.connections?new d(e,t):new g(e,t)}e.exports=class extends h{constructor({factory:e=m,maxOrigins:t=1/0,connect:s,...r}={}){if("function"!=typeof e)throw new n("factory must be a function.");if(null!=s&&"function"!=typeof s&&"object"!=typeof s)throw new n("connect must be a function or an object");if("number"!=typeof t||Number.isNaN(t)||t<=0)throw new n("maxOrigins must be a number greater than 0");super(),s&&"function"!=typeof s&&(s={...s}),this[Q]={...u.deepClone(r),maxOrigins:t,connect:s},this[B]=e,this[i]=new Map,this[f]=new Set,this[C]=(e,t)=>{this.emit("drain",e,[this,...t])},this[I]=(e,t)=>{this.emit("connect",e,[this,...t])},this[E]=(e,t,s)=>{this.emit("disconnect",e,[this,...t],s)},this[p]=(e,t,s)=>{this.emit("connectionError",e,[this,...t],s)}}get[A](){let e=0;for(const{dispatcher:t}of this[i].values())e+=t[A];return e}[c](e,t){let s;if(!e.origin||!("string"==typeof e.origin||e.origin instanceof URL))throw new n("opts.origin must be a non-empty string or URL.");if(s=String(e.origin),this[f].size>=this[Q].maxOrigins&&!this[f].has(s))throw new r;const A=this[i].get(s);let o=A&&A.dispatcher;if(!o){const t=e=>{const t=this[i].get(s);t&&(e&&(t.count-=1),t.count<=0&&(this[i].delete(s),t.dispatcher.close()),this[f].delete(s))};o=this[B](e.origin,this[Q]).on("drain",this[C]).on("connect",((e,t)=>{const n=this[i].get(s);n&&(n.count+=1),this[I](e,t)})).on("disconnect",((e,s,n)=>{t(!0),this[E](e,s,n)})).on("connectionError",((e,s,n)=>{t(!1),this[p](e,s,n)})),this[i].set(s,{count:0,dispatcher:o}),this[f].add(s)}return o.dispatch(e,t)}[o](){const e=[];for(const{dispatcher:t}of this[i].values())e.push(t.close());return this[i].clear(),Promise.all(e)}[a](e){const t=[];for(const{dispatcher:s}of this[i].values())t.push(s.destroy(e));return this[i].clear(),Promise.all(t)}get stats(){const e={};for(const{dispatcher:t}of this[i].values())t.stats&&(e[t[l].origin]=t.stats);return e}}},8055:(e,t,s)=>{"use strict";const{BalancedPoolMissingUpstreamError:n,InvalidArgumentError:r}=s(4465),{PoolBase:i,kClients:A,kNeedDrain:o,kAddClient:a,kRemoveClient:c,kGetDispatcher:l}=s(1694),h=s(8542),{kUrl:g}=s(257),{parseOrigin:d}=s(2858),u=Symbol("factory"),I=Symbol("options"),E=Symbol("kGreatestCommonDivisor"),p=Symbol("kCurrentWeight"),C=Symbol("kIndex"),B=Symbol("kWeight"),Q=Symbol("kMaxWeightPerServer"),f=Symbol("kErrorPenalty");function m(e,t){if(0===e)return t;for(;0!==t;){const s=t;t=e%t,e=s}return e}function y(e,t){return new h(e,t)}e.exports=class extends i{constructor(e=[],{factory:t=y,...s}={}){if("function"!=typeof t)throw new r("factory must be a function.");super(),this[I]=s,this[C]=-1,this[p]=0,this[Q]=this[I].maxWeightPerServer||100,this[f]=this[I].errorPenalty||15,Array.isArray(e)||(e=[e]),this[u]=t;for(const t of e)this.addUpstream(t);this._updateBalancedPoolStats()}addUpstream(e){const t=d(e).origin;if(this[A].find((e=>e[g].origin===t&&!0!==e.closed&&!0!==e.destroyed)))return this;const s=this[u](t,Object.assign({},this[I]));this[a](s),s.on("connect",(()=>{s[B]=Math.min(this[Q],s[B]+this[f])})),s.on("connectionError",(()=>{s[B]=Math.max(1,s[B]-this[f]),this._updateBalancedPoolStats()})),s.on("disconnect",((...e)=>{const t=e[2];t&&"UND_ERR_SOCKET"===t.code&&(s[B]=Math.max(1,s[B]-this[f]),this._updateBalancedPoolStats())}));for(const e of this[A])e[B]=this[Q];return this._updateBalancedPoolStats(),this}_updateBalancedPoolStats(){let e=0;for(let t=0;t<this[A].length;t++)e=m(this[A][t][B],e);this[E]=e}removeUpstream(e){const t=d(e).origin,s=this[A].find((e=>e[g].origin===t&&!0!==e.closed&&!0!==e.destroyed));return s&&this[c](s),this}get upstreams(){return this[A].filter((e=>!0!==e.closed&&!0!==e.destroyed)).map((e=>e[g].origin))}[l](){if(0===this[A].length)throw new n;if(!this[A].find((e=>!e[o]&&!0!==e.closed&&!0!==e.destroyed)))return;if(this[A].map((e=>e[o])).reduce(((e,t)=>e&&t),!0))return;let e=0,t=this[A].findIndex((e=>!e[o]));for(;e++<this[A].length;){this[C]=(this[C]+1)%this[A].length;const e=this[A][this[C]];if(e[B]>this[A][t][B]&&!e[o]&&(t=this[C]),0===this[C]&&(this[p]=this[p]-this[E],this[p]<=0&&(this[p]=this[Q])),e[B]>=this[p]&&!e[o])return e}return this[p]=this[A][t][B],this[C]=t,this[A][t]}}},9355:(e,t,s)=>{"use strict";const n=s(4589),r=s(2858),{channels:i}=s(772),A=s(3801),{RequestContentLengthMismatchError:o,ResponseContentLengthMismatchError:a,RequestAbortedError:c,HeadersTimeoutError:l,HeadersOverflowError:h,SocketError:g,InformationalError:d,BodyTimeoutError:u,HTTPParserError:I,ResponseExceededMaxSizeError:E}=s(4465),{kUrl:p,kReset:C,kClient:B,kParser:Q,kBlocking:f,kRunning:m,kPending:y,kSize:S,kWriting:w,kQueue:D,kNoRef:b,kKeepAliveDefaultTimeout:v,kHostHeader:N,kPendingIdx:R,kRunningIdx:k,kError:T,kPipelining:F,kSocket:M,kKeepAliveTimeoutValue:U,kMaxHeadersSize:L,kKeepAliveMaxTimeout:P,kKeepAliveTimeoutThreshold:H,kHeadersTimeout:x,kBodyTimeout:Y,kStrictContentLength:V,kMaxRequests:O,kCounter:G,kMaxResponseSize:J,kOnError:W,kResume:_,kHTTPContext:$,kClosed:q}=s(257),z=s(4178),X=Buffer.alloc(0),j=Buffer[Symbol.species],Z=r.removeAllListeners;let K;let ee=null,te=null,se=null,ne=0,re=null;class ie{constructor(e,t,{exports:s}){this.llhttp=s,this.ptr=this.llhttp.llhttp_alloc(z.TYPE.RESPONSE),this.client=e,this.socket=t,this.timeout=null,this.timeoutValue=null,this.timeoutType=null,this.statusCode=0,this.statusText="",this.upgrade=!1,this.headers=[],this.headersSize=0,this.headersMaxSize=e[L],this.shouldKeepAlive=!1,this.paused=!1,this.resume=this.resume.bind(this),this.bytesRead=0,this.keepAlive="",this.contentLength="",this.connection="",this.maxResponseSize=e[J]}setTimeout(e,t){e!==this.timeoutValue||1&t^1&this.timeoutType?(this.timeout&&(A.clearTimeout(this.timeout),this.timeout=null),e&&(1&t?this.timeout=A.setFastTimeout(Ae,e,new WeakRef(this)):(this.timeout=setTimeout(Ae,e,new WeakRef(this)),this.timeout?.unref())),this.timeoutValue=e):this.timeout&&this.timeout.refresh&&this.timeout.refresh(),this.timeoutType=t}resume(){!this.socket.destroyed&&this.paused&&(n(null!=this.ptr),n(null===te),this.llhttp.llhttp_resume(this.ptr),n(5===this.timeoutType),this.timeout&&this.timeout.refresh&&this.timeout.refresh(),this.paused=!1,this.execute(this.socket.read()||X),this.readMore())}readMore(){for(;!this.paused&&this.ptr;){const e=this.socket.read();if(null===e)break;this.execute(e)}}execute(e){n(null===te),n(null!=this.ptr),n(!this.paused);const{socket:t,llhttp:s}=this;e.length>ne&&(re&&s.free(re),ne=4096*Math.ceil(e.length/4096),re=s.malloc(ne)),new Uint8Array(s.memory.buffer,re,ne).set(e);try{let n;try{se=e,te=this,n=s.llhttp_execute(this.ptr,re,e.length)}finally{te=null,se=null}if(n!==z.ERROR.OK){const r=e.subarray(s.llhttp_get_error_pos(this.ptr)-re);if(n===z.ERROR.PAUSED_UPGRADE)this.onUpgrade(r);else{if(n!==z.ERROR.PAUSED){const e=s.llhttp_get_error_reason(this.ptr);let t="";if(e){const n=new Uint8Array(s.memory.buffer,e).indexOf(0);t="Response does not match the HTTP/1.1 protocol ("+Buffer.from(s.memory.buffer,e,n).toString()+")"}throw new I(t,z.ERROR[n],r)}this.paused=!0,t.unshift(r)}}}catch(e){r.destroy(t,e)}}destroy(){n(null===te),n(null!=this.ptr),this.llhttp.llhttp_free(this.ptr),this.ptr=null,this.timeout&&A.clearTimeout(this.timeout),this.timeout=null,this.timeoutValue=null,this.timeoutType=null,this.paused=!1}onStatus(e){return this.statusText=e.toString(),0}onMessageBegin(){const{socket:e,client:t}=this;if(e.destroyed)return-1;const s=t[D][t[k]];return s?(s.onResponseStarted(),0):-1}onHeaderField(e){const t=this.headers.length;return 1&t?this.headers[t-1]=Buffer.concat([this.headers[t-1],e]):this.headers.push(e),this.trackHeader(e.length),0}onHeaderValue(e){let t=this.headers.length;1&~t?this.headers[t-1]=Buffer.concat([this.headers[t-1],e]):(this.headers.push(e),t+=1);const s=this.headers[t-2];if(10===s.length){const t=r.bufferToLowerCasedHeaderName(s);"keep-alive"===t?this.keepAlive+=e.toString():"connection"===t&&(this.connection+=e.toString())}else 14===s.length&&"content-length"===r.bufferToLowerCasedHeaderName(s)&&(this.contentLength+=e.toString());return this.trackHeader(e.length),0}trackHeader(e){this.headersSize+=e,this.headersSize>=this.headersMaxSize&&r.destroy(this.socket,new h)}onUpgrade(e){const{upgrade:t,client:s,socket:i,headers:A,statusCode:o}=this;n(t),n(s[M]===i),n(!i.destroyed),n(!this.paused),n(!(1&A.length));const a=s[D][s[k]];n(a),n(a.upgrade||"CONNECT"===a.method),this.statusCode=0,this.statusText="",this.shouldKeepAlive=!1,this.headers=[],this.headersSize=0,i.unshift(e),i[Q].destroy(),i[Q]=null,i[B]=null,i[T]=null,Z(i),s[M]=null,s[$]=null,s[D][s[k]++]=null,s.emit("disconnect",s[p],[s],new d("upgrade"));try{a.onUpgrade(o,A,i)}catch(e){r.destroy(i,e)}s[_]()}onHeadersComplete(e,t,s){const{client:i,socket:A,headers:o,statusText:a}=this;if(A.destroyed)return-1;const c=i[D][i[k]];if(!c)return-1;if(n(!this.upgrade),n(this.statusCode<200),100===e)return r.destroy(A,new g("bad response",r.getSocketInfo(A))),-1;if(t&&!c.upgrade)return r.destroy(A,new g("bad upgrade",r.getSocketInfo(A))),-1;if(n(3===this.timeoutType),this.statusCode=e,this.shouldKeepAlive=s||"HEAD"===c.method&&!A[C]&&"keep-alive"===this.connection.toLowerCase(),this.statusCode>=200){const e=null!=c.bodyTimeout?c.bodyTimeout:i[Y];this.setTimeout(e,5)}else this.timeout&&this.timeout.refresh&&this.timeout.refresh();if("CONNECT"===c.method)return n(1===i[m]),this.upgrade=!0,2;if(t)return n(1===i[m]),this.upgrade=!0,2;if(n(!(1&this.headers.length)),this.headers=[],this.headersSize=0,this.shouldKeepAlive&&i[F]){const e=this.keepAlive?r.parseKeepAliveTimeout(this.keepAlive):null;if(null!=e){const t=Math.min(e-i[H],i[P]);t<=0?A[C]=!0:i[U]=t}else i[U]=i[v]}else A[C]=!0;const l=!1===c.onHeaders(e,o,this.resume,a);return c.aborted?-1:"HEAD"===c.method||e<200?1:(A[f]&&(A[f]=!1,i[_]()),l?z.ERROR.PAUSED:0)}onBody(e){const{client:t,socket:s,statusCode:i,maxResponseSize:A}=this;if(s.destroyed)return-1;const o=t[D][t[k]];return n(o),n(5===this.timeoutType),this.timeout&&this.timeout.refresh&&this.timeout.refresh(),n(i>=200),A>-1&&this.bytesRead+e.length>A?(r.destroy(s,new E),-1):(this.bytesRead+=e.length,!1===o.onData(e)?z.ERROR.PAUSED:0)}onMessageComplete(){const{client:e,socket:t,statusCode:s,upgrade:i,headers:A,contentLength:o,bytesRead:c,shouldKeepAlive:l}=this;if(t.destroyed&&(!s||l))return-1;if(i)return 0;n(s>=100),n(!(1&this.headers.length));const h=e[D][e[k]];return n(h),this.statusCode=0,this.statusText="",this.bytesRead=0,this.contentLength="",this.keepAlive="",this.connection="",this.headers=[],this.headersSize=0,s<200?0:"HEAD"!==h.method&&o&&c!==parseInt(o,10)?(r.destroy(t,new a),-1):(h.onComplete(A),e[D][e[k]++]=null,t[w]?(n(0===e[m]),r.destroy(t,new d("reset")),z.ERROR.PAUSED):l?t[C]&&0===e[m]?(r.destroy(t,new d("reset")),z.ERROR.PAUSED):(null==e[F]||1===e[F]?setImmediate(e[_]):e[_](),0):(r.destroy(t,new d("reset")),z.ERROR.PAUSED))}}function Ae(e){const{socket:t,timeoutType:s,client:i,paused:A}=e.deref();3===s?(!t[w]||t.writableNeedDrain||i[m]>1)&&(n(!A,"cannot be paused while waiting for headers"),r.destroy(t,new l)):5===s?A||r.destroy(t,new u):8===s&&(n(0===i[m]&&i[U]),r.destroy(t,new d("socket idle timeout")))}function oe(e){n("ERR_TLS_CERT_ALTNAME_INVALID"!==e.code);const t=this[Q];"ECONNRESET"!==e.code||!t.statusCode||t.shouldKeepAlive?(this[T]=e,this[B][W](e)):t.onMessageComplete()}function ae(){this[Q]?.readMore()}function ce(){const e=this[Q];!e.statusCode||e.shouldKeepAlive?r.destroy(this,new g("other side closed",r.getSocketInfo(this))):e.onMessageComplete()}function le(){const e=this[Q];e&&(this[T]||!e.statusCode||e.shouldKeepAlive||e.onMessageComplete(),this[Q].destroy(),this[Q]=null);const t=this[T]||new g("closed",r.getSocketInfo(this)),s=this[B];if(s[M]=null,s[$]=null,s.destroyed){n(0===s[y]);const e=s[D].splice(s[k]);for(let n=0;n<e.length;n++){const i=e[n];r.errorRequest(s,i,t)}}else if(s[m]>0&&"UND_ERR_INFO"!==t.code){const e=s[D][s[k]];s[D][s[k]++]=null,r.errorRequest(s,e,t)}s[R]=s[k],n(0===s[m]),s.emit("disconnect",s[p],[s],t),s[_]()}function he(){this[q]=!0}function ge(e,t,s,i,A,o,a,c){try{t?r.isBuffer(t)&&(n(o===t.byteLength,"buffer body must have content length"),A.cork(),A.write(`${a}content-length: ${o}\r\n\r\n`,"latin1"),A.write(t),A.uncork(),i.onBodySent(t),c||!1===i.reset||(A[C]=!0)):0===o?A.write(`${a}content-length: 0\r\n\r\n`,"latin1"):(n(null===o,"no body must not have content length"),A.write(`${a}\r\n`,"latin1")),i.onRequestSent(),s[_]()}catch(t){e(t)}}async function de(e,t,s,r,i,A,o,a){n(0!==A||0===s[m],"iterator body cannot be pipelined");let c=null;function l(){if(c){const e=c;c=null,e()}}i.on("close",l).on("drain",l);const h=new ue({abort:e,socket:i,request:r,contentLength:A,client:s,expectsPayload:a,header:o});try{for await(const e of t){if(i[T])throw i[T];h.write(e)||await new Promise(((e,t)=>{n(null===c),i[T]?t(i[T]):c=e}))}h.end()}catch(e){h.destroy(e)}finally{i.off("close",l).off("drain",l)}}class ue{constructor({abort:e,socket:t,request:s,contentLength:n,client:r,expectsPayload:i,header:A}){this.socket=t,this.request=s,this.contentLength=n,this.client=r,this.bytesWritten=0,this.expectsPayload=i,this.header=A,this.abort=e,t[w]=!0}write(e){const{socket:t,request:s,contentLength:n,client:r,bytesWritten:i,expectsPayload:A,header:a}=this;if(t[T])throw t[T];if(t.destroyed)return!1;const c=Buffer.byteLength(e);if(!c)return!0;if(null!==n&&i+c>n){if(r[V])throw new o;process.emitWarning(new o)}t.cork(),0===i&&(A||!1===s.reset||(t[C]=!0),null===n?t.write(`${a}transfer-encoding: chunked\r\n`,"latin1"):t.write(`${a}content-length: ${n}\r\n\r\n`,"latin1")),null===n&&t.write(`\r\n${c.toString(16)}\r\n`,"latin1"),this.bytesWritten+=c;const l=t.write(e);return t.uncork(),s.onBodySent(e),l||t[Q].timeout&&3===t[Q].timeoutType&&t[Q].timeout.refresh&&t[Q].timeout.refresh(),l}end(){const{socket:e,contentLength:t,client:s,bytesWritten:n,expectsPayload:r,header:i,request:A}=this;if(A.onRequestSent(),e[w]=!1,e[T])throw e[T];if(!e.destroyed){if(0===n?r?e.write(`${i}content-length: 0\r\n\r\n`,"latin1"):e.write(`${i}\r\n`,"latin1"):null===t&&e.write("\r\n0\r\n\r\n","latin1"),null!==t&&n!==t){if(s[V])throw new o;process.emitWarning(new o)}e[Q].timeout&&3===e[Q].timeoutType&&e[Q].timeout.refresh&&e[Q].timeout.refresh(),s[_]()}}destroy(e){const{socket:t,client:s,abort:r}=this;t[w]=!1,e&&(n(s[m]<=1,"pipeline should only contain this request"),r(e))}}e.exports=function(e,t){if(e[M]=t,ee||(ee=function(){const e=process.env.JEST_WORKER_ID?s(4744):void 0;let t,r="ppc64"!==process.arch;if("1"===process.env.UNDICI_NO_WASM_SIMD?r=!0:"0"===process.env.UNDICI_NO_WASM_SIMD&&(r=!1),r)try{t=new WebAssembly.Module(s(7136))}catch{}return t||(t=new WebAssembly.Module(e||s(4744))),new WebAssembly.Instance(t,{env:{wasm_on_url:(e,t,s)=>0,wasm_on_status:(e,t,s)=>{n(te.ptr===e);const r=t-re+se.byteOffset;return te.onStatus(new j(se.buffer,r,s))},wasm_on_message_begin:e=>(n(te.ptr===e),te.onMessageBegin()),wasm_on_header_field:(e,t,s)=>{n(te.ptr===e);const r=t-re+se.byteOffset;return te.onHeaderField(new j(se.buffer,r,s))},wasm_on_header_value:(e,t,s)=>{n(te.ptr===e);const r=t-re+se.byteOffset;return te.onHeaderValue(new j(se.buffer,r,s))},wasm_on_headers_complete:(e,t,s,r)=>(n(te.ptr===e),te.onHeadersComplete(t,1===s,1===r)),wasm_on_body:(e,t,s)=>{n(te.ptr===e);const r=t-re+se.byteOffset;return te.onBody(new j(se.buffer,r,s))},wasm_on_message_complete:e=>(n(te.ptr===e),te.onMessageComplete())}})}()),t.errored)throw t.errored;if(t.destroyed)throw new g("destroyed");return t[b]=!1,t[w]=!1,t[C]=!1,t[f]=!1,t[Q]=new ie(e,t,ee),r.addListener(t,"error",oe),r.addListener(t,"readable",ae),r.addListener(t,"end",ce),r.addListener(t,"close",le),t[q]=!1,t.on("close",he),{version:"h1",defaultPipelining:1,write:t=>function(e,t){const{method:A,path:a,host:l,upgrade:h,blocking:g,reset:u}=t;let{body:I,headers:E,contentLength:p}=t;const B="PUT"===A||"POST"===A||"PATCH"===A||"QUERY"===A||"PROPFIND"===A||"PROPPATCH"===A;if(r.isFormDataLike(I)){K||(K=s(2530).extractBody);const[e,n]=K(I);null==t.contentType&&E.push("content-type",n),I=e.stream,p=e.length}else r.isBlobLike(I)&&null==t.contentType&&I.type&&E.push("content-type",I.type);I&&"function"==typeof I.read&&I.read(0);const Q=r.bodyLength(I);p=Q??p,null===p&&(p=t.contentLength);0!==p||B||(p=null);if(function(e){return"GET"!==e&&"HEAD"!==e&&"OPTIONS"!==e&&"TRACE"!==e&&"CONNECT"!==e}(A)&&p>0&&null!==t.contentLength&&t.contentLength!==p){if(e[V])return r.errorRequest(e,t,new o),!1;process.emitWarning(new o)}const y=e[M],S=s=>{t.aborted||t.completed||(r.errorRequest(e,t,s||new c),r.destroy(I),r.destroy(y,new d("aborted")))};try{t.onConnect(S)}catch(s){r.errorRequest(e,t,s)}if(t.aborted)return!1;"HEAD"===A&&(y[C]=!0);(h||"CONNECT"===A)&&(y[C]=!0);null!=u&&(y[C]=u);e[O]&&y[G]++>=e[O]&&(y[C]=!0);g&&(y[f]=!0);let D=`${A} ${a} HTTP/1.1\r\n`;D+="string"==typeof l?`host: ${l}\r\n`:e[N];h?D+=`connection: upgrade\r\nupgrade: ${h}\r\n`:e[F]&&!y[C]?D+="connection: keep-alive\r\n":D+="connection: close\r\n";if(Array.isArray(E))for(let e=0;e<E.length;e+=2){const t=E[e+0],s=E[e+1];if(Array.isArray(s))for(let e=0;e<s.length;e++)D+=`${t}: ${s[e]}\r\n`;else D+=`${t}: ${s}\r\n`}i.sendHeaders.hasSubscribers&&i.sendHeaders.publish({request:t,headers:D,socket:y});I&&0!==Q?r.isBuffer(I)?ge(S,I,e,t,y,p,D,B):r.isBlobLike(I)?"function"==typeof I.stream?de(S,I.stream(),e,t,y,p,D,B):async function(e,t,s,r,i,A,a,c){n(A===t.size,"blob body must have content length");try{if(null!=A&&A!==t.size)throw new o;const e=Buffer.from(await t.arrayBuffer());i.cork(),i.write(`${a}content-length: ${A}\r\n\r\n`,"latin1"),i.write(e),i.uncork(),r.onBodySent(e),r.onRequestSent(),c||!1===r.reset||(i[C]=!0),s[_]()}catch(t){e(t)}}(S,I,e,t,y,p,D,B):r.isStream(I)?function(e,t,s,i,A,o,a,l){n(0!==o||0===s[m],"stream body cannot be pipelined");let h=!1;const g=new ue({abort:e,socket:A,request:i,contentLength:o,client:s,expectsPayload:l,header:a}),d=function(e){if(!h)try{!g.write(e)&&this.pause&&this.pause()}catch(e){r.destroy(this,e)}},u=function(){h||t.resume&&t.resume()},I=function(){if(queueMicrotask((()=>{t.removeListener("error",E)})),!h){const e=new c;queueMicrotask((()=>E(e)))}},E=function(e){if(!h){if(h=!0,n(A.destroyed||A[w]&&s[m]<=1),A.off("drain",u).off("error",E),t.removeListener("data",d).removeListener("end",E).removeListener("close",I),!e)try{g.end()}catch(t){e=t}g.destroy(e),!e||"UND_ERR_INFO"===e.code&&"reset"===e.message?r.destroy(t):r.destroy(t,e)}};t.on("data",d).on("end",E).on("error",E).on("close",I),t.resume&&t.resume();A.on("drain",u).on("error",E),t.errorEmitted??t.errored?setImmediate(E,t.errored):(t.endEmitted??t.readableEnded)&&setImmediate(E,null);(t.closeEmitted??t.closed)&&setImmediate(I)}(S,I,e,t,y,p,D,B):r.isIterable(I)?de(S,I,e,t,y,p,D,B):n(!1):ge(S,null,e,t,y,p,D,B);return!0}(e,t),resume(){!function(e){const t=e[M];if(t&&!t.destroyed)if(0===e[S]?!t[b]&&t.unref&&(t.unref(),t[b]=!0):t[b]&&t.ref&&(t.ref(),t[b]=!1),0===e[S])8!==t[Q].timeoutType&&t[Q].setTimeout(e[U],8);else if(e[m]>0&&t[Q].statusCode<200&&3!==t[Q].timeoutType){const s=e[D][e[k]],n=null!=s.headersTimeout?s.headersTimeout:e[x];t[Q].setTimeout(n,3)}}(e)},destroy(e,s){t[q]?queueMicrotask(s):(t.on("close",s),t.destroy(e))},get destroyed(){return t.destroyed},busy(s){if(t[w]||t[C]||t[f])return!0;if(s){if(e[m]>0&&!s.idempotent)return!0;if(e[m]>0&&(s.upgrade||"CONNECT"===s.method))return!0;if(e[m]>0&&0!==r.bodyLength(s.body)&&(r.isStream(s.body)||r.isAsyncIterable(s.body)||r.isFormDataLike(s.body)))return!0}return!1}}}},8142:(e,t,s)=>{"use strict";const n=s(4589),{pipeline:r}=s(7075),i=s(2858),{RequestContentLengthMismatchError:A,RequestAbortedError:o,SocketError:a,InformationalError:c}=s(4465),{kUrl:l,kReset:h,kClient:g,kRunning:d,kPending:u,kQueue:I,kPendingIdx:E,kRunningIdx:p,kError:C,kSocket:B,kStrictContentLength:Q,kOnError:f,kMaxConcurrentStreams:m,kHTTP2Session:y,kResume:S,kSize:w,kHTTPContext:D,kClosed:b,kBodyTimeout:v}=s(257),{channels:N}=s(772),R=Symbol("open streams");let k,T;try{T=s(2467)}catch{T={constants:{}}}const{constants:{HTTP2_HEADER_AUTHORITY:F,HTTP2_HEADER_METHOD:M,HTTP2_HEADER_PATH:U,HTTP2_HEADER_SCHEME:L,HTTP2_HEADER_CONTENT_LENGTH:P,HTTP2_HEADER_EXPECT:H,HTTP2_HEADER_STATUS:x}}=T;function Y(e){n("ERR_TLS_CERT_ALTNAME_INVALID"!==e.code),this[B][C]=e,this[g][f](e)}function V(e,t,s){if(0===s){const s=new c(`HTTP/2: "frameError" received - type ${e}, code ${t}`);this[B][C]=s,this[g][f](s)}}function O(){const e=new a("other side closed",i.getSocketInfo(this[B]));this.destroy(e),i.destroy(this[B],e)}function G(e){const t=this[C]||new a(`HTTP/2: "GOAWAY" frame received with code ${e}`,i.getSocketInfo(this[B])),s=this[g];if(s[B]=null,s[D]=null,this.close(),this[y]=null,i.destroy(this[B],t),s[p]<s[I].length){const e=s[I][s[p]];s[I][s[p]++]=null,i.errorRequest(s,e,t),s[E]=s[p]}n(0===s[d]),s.emit("disconnect",s[l],[s],t),s.emit("connectionError",s[l],[s],t),s[S]()}function J(){const{[g]:e}=this,{[B]:t}=e,s=this[B][C]||this[C]||new a("closed",i.getSocketInfo(t));if(e[B]=null,e[D]=null,e.destroyed){n(0===e[u]);const t=e[I].splice(e[p]);for(let n=0;n<t.length;n++){const r=t[n];i.errorRequest(e,r,s)}}}function W(){const e=this[C]||new a("closed",i.getSocketInfo(this)),t=this[y][g];t[B]=null,t[D]=null,null!==this[y]&&this[y].destroy(e),t[E]=t[p],n(0===t[d]),t.emit("disconnect",t[l],[t],e),t[S]()}function _(e){n("ERR_TLS_CERT_ALTNAME_INVALID"!==e.code),this[C]=e,this[g][f](e)}function $(){i.destroy(this,new a("other side closed",i.getSocketInfo(this)))}function q(){this[b]=!0}function z(e,t,s,r,A,o,a,c){try{null!=s&&i.isBuffer(s)&&(n(a===s.byteLength,"buffer body must have content length"),t.cork(),t.write(s),t.uncork(),t.end(),A.onBodySent(s)),c||(o[h]=!0),A.onRequestSent(),r[S]()}catch(t){e(t)}}async function X(e,t,s,r,i,A,o,a){n(0!==o||0===r[d],"iterator body cannot be pipelined");let c=null;function l(){if(c){const e=c;c=null,e()}}t.on("close",l).on("drain",l);try{for await(const e of s){if(A[C])throw A[C];const s=t.write(e);i.onBodySent(e),s||await new Promise(((e,t)=>{n(null===c),A[C]?t(A[C]):c=e}))}t.end(),i.onRequestSent(),a||(A[h]=!0),r[S]()}catch(t){e(t)}finally{t.off("close",l).off("drain",l)}}e.exports=function(e,t){e[B]=t;const a=T.connect(e[l],{createConnection:()=>t,peerMaxConcurrentStreams:e[m],settings:{enablePush:!1}});return a[R]=0,a[g]=e,a[B]=t,a[y]=null,i.addListener(a,"error",Y),i.addListener(a,"frameError",V),i.addListener(a,"end",O),i.addListener(a,"goaway",G),i.addListener(a,"close",J),a.unref(),e[y]=a,t[y]=a,i.addListener(t,"error",_),i.addListener(t,"end",$),i.addListener(t,"close",W),t[b]=!1,t.on("close",q),{version:"h2",defaultPipelining:1/0,write:t=>function(e,t){const a=t.bodyTimeout??e[v],g=e[y],{method:u,path:C,host:m,upgrade:w,expectContinue:D,signal:b,protocol:T,headers:Y}=t;let{body:V}=t;if(w)return i.errorRequest(e,t,new Error("Upgrade not supported for H2")),!1;const O={};for(let e=0;e<Y.length;e+=2){const t=Y[e+0],s=Y[e+1];if("cookie"!==t)if(Array.isArray(s))for(let e=0;e<s.length;e++)O[t]?O[t]+=`, ${s[e]}`:O[t]=s[e];else O[t]?O[t]+=`, ${s}`:O[t]=s;else null!=O[t]?O[t]=Array.isArray(O[t])?(O[t].push(s),O[t]):[O[t],s]:O[t]=s}let G=null;const{hostname:J,port:W}=e[l];O[F]=m||`${J}${W?`:${W}`:""}`,O[M]=u;const _=s=>{t.aborted||t.completed||(s=s||new o,i.errorRequest(e,t,s),null!=G&&(G.removeAllListeners("data"),G.close(),e[f](s),e[S]()),i.destroy(V,s))};try{t.onConnect(_)}catch(s){i.errorRequest(e,t,s)}if(t.aborted)return!1;if("CONNECT"===u)return g.ref(),G=g.request(O,{endStream:!1,signal:b}),G.pending?G.once("ready",(()=>{t.onUpgrade(null,null,G),++g[R],e[I][e[p]++]=null})):(t.onUpgrade(null,null,G),++g[R],e[I][e[p]++]=null),G.once("close",(()=>{g[R]-=1,0===g[R]&&g.unref()})),G.setTimeout(a),!0;O[U]=C,O[L]="http:"===T?"http":"https";const $="PUT"===u||"POST"===u||"PATCH"===u;V&&"function"==typeof V.read&&V.read(0);let q=i.bodyLength(V);if(i.isFormDataLike(V)){k??=s(2530).extractBody;const[e,t]=k(V);O["content-type"]=t,V=e.stream,q=e.length}null==q&&(q=t.contentLength);0!==q&&$||(q=null);if(function(e){return"GET"!==e&&"HEAD"!==e&&"OPTIONS"!==e&&"TRACE"!==e&&"CONNECT"!==e}(u)&&q>0&&null!=t.contentLength&&t.contentLength!==q){if(e[Q])return i.errorRequest(e,t,new A),!1;process.emitWarning(new A)}null!=q&&(n(V,"no body must not have content length"),O[P]=`${q}`);if(g.ref(),N.sendHeaders.hasSubscribers){let e="";for(const t in O)e+=`${t}: ${O[t]}\r\n`;N.sendHeaders.publish({request:t,headers:e,socket:g[B]})}const j="GET"===u||"HEAD"===u||null===V;D?(O[H]="100-continue",G=g.request(O,{endStream:j,signal:b}),G.once("continue",Z)):(G=g.request(O,{endStream:j,signal:b}),Z());return++g[R],G.setTimeout(a),G.once("response",(e=>{const{[x]:s,...n}=e;t.onResponseStarted(),t.aborted?G.removeAllListeners("data"):!1===t.onHeaders(Number(s),function(e){const t=[];for(const[s,n]of Object.entries(e))if(Array.isArray(n))for(const e of n)t.push(Buffer.from(s),Buffer.from(e));else t.push(Buffer.from(s),Buffer.from(n));return t}(n),G.resume.bind(G),"")&&G.pause()})),G.on("data",(e=>{!1===t.onData(e)&&G.pause()})),G.once("end",(s=>{G.removeAllListeners("data"),null==G.state?.state||G.state.state<6?(t.aborted||t.completed||t.onComplete({}),e[I][e[p]++]=null,e[S]()):(--g[R],0===g[R]&&g.unref(),_(s??new c("HTTP/2: stream half-closed (remote)")),e[I][e[p]++]=null,e[E]=e[p],e[S]())})),G.once("close",(()=>{G.removeAllListeners("data"),g[R]-=1,0===g[R]&&g.unref()})),G.once("error",(function(e){G.removeAllListeners("data"),_(e)})),G.once("frameError",((e,t)=>{G.removeAllListeners("data"),_(new c(`HTTP/2: "frameError" received - type ${e}, code ${t}`))})),G.on("aborted",(()=>{G.removeAllListeners("data")})),G.on("timeout",(()=>{const e=new c(`HTTP/2: "stream timeout after ${a}"`);G.removeAllListeners("data"),g[R]-=1,0===g[R]&&g.unref(),_(e)})),G.once("trailers",(e=>{t.aborted||t.completed||t.onComplete(e)})),!0;function Z(){V&&0!==q?i.isBuffer(V)?z(_,G,V,e,t,e[B],q,$):i.isBlobLike(V)?"function"==typeof V.stream?X(_,G,V.stream(),e,t,e[B],q,$):async function(e,t,s,r,i,o,a,c){n(a===s.size,"blob body must have content length");try{if(null!=a&&a!==s.size)throw new A;const e=Buffer.from(await s.arrayBuffer());t.cork(),t.write(e),t.uncork(),t.end(),i.onBodySent(e),i.onRequestSent(),c||(o[h]=!0),r[S]()}catch(t){e(t)}}(_,G,V,e,t,e[B],q,$):i.isStream(V)?function(e,t,s,A,o,a,c,l){n(0!==l||0===a[d],"stream body cannot be pipelined");const g=r(o,A,(n=>{n?(i.destroy(g,n),e(n)):(i.removeAllListeners(g),c.onRequestSent(),s||(t[h]=!0),a[S]())}));function u(e){c.onBodySent(e)}i.addListener(g,"data",u)}(_,e[B],$,G,V,e,t,q):i.isIterable(V)?X(_,G,V,e,t,e[B],q,$):n(!1):z(_,G,null,e,t,e[B],q,$)}}(e,t),resume(){!function(e){const t=e[B];!1===t?.destroyed&&(0===e[w]||0===e[m]?(t.unref(),e[y].unref()):(t.ref(),e[y].ref()))}(e)},destroy(e,s){t[b]?queueMicrotask(s):t.destroy(e).on("close",s)},get destroyed(){return t.destroyed},busy:()=>!1}}},1167:(e,t,s)=>{"use strict";const n=s(4589),r=s(7030),i=s(7067),A=s(2858),{ClientStats:o}=s(4304),{channels:a}=s(772),c=s(5837),l=s(7779),{InvalidArgumentError:h,InformationalError:g,ClientDestroyedError:d}=s(4465),u=s(1986),{kUrl:I,kServerName:E,kClient:p,kBusy:C,kConnect:B,kResuming:Q,kRunning:f,kPending:m,kSize:y,kQueue:S,kConnected:w,kConnecting:D,kNeedDrain:b,kKeepAliveDefaultTimeout:v,kHostHeader:N,kPendingIdx:R,kRunningIdx:k,kError:T,kPipelining:F,kKeepAliveTimeoutValue:M,kMaxHeadersSize:U,kKeepAliveMaxTimeout:L,kKeepAliveTimeoutThreshold:P,kHeadersTimeout:H,kBodyTimeout:x,kStrictContentLength:Y,kConnector:V,kMaxRequests:O,kCounter:G,kClose:J,kDestroy:W,kDispatch:_,kLocalAddress:$,kMaxResponseSize:q,kOnError:z,kHTTPContext:X,kMaxConcurrentStreams:j,kResume:Z}=s(257),K=s(9355),ee=s(8142),te=Symbol("kClosedResolve"),se=i&&i.maxHeaderSize&&Number.isInteger(i.maxHeaderSize)&&i.maxHeaderSize>0?()=>i.maxHeaderSize:()=>{throw new h("http module not available or http.maxHeaderSize invalid")},ne=()=>{};function re(e){return e[F]??e[X]?.defaultPipelining??1}function ie(e,t){if(0===e[f]&&"UND_ERR_INFO"!==t.code&&"UND_ERR_SOCKET"!==t.code){n(e[R]===e[k]);const s=e[S].splice(e[k]);for(let n=0;n<s.length;n++){const r=s[n];A.errorRequest(e,r,t)}n(0===e[y])}}function Ae(e){n(!e[D]),n(!e[X]);let{host:t,hostname:s,protocol:i,port:o}=e[I];if("["===s[0]){const e=s.indexOf("]");n(-1!==e);const t=s.substring(1,e);n(r.isIPv6(t)),s=t}e[D]=!0,a.beforeConnect.hasSubscribers&&a.beforeConnect.publish({connectParams:{host:t,hostname:s,protocol:i,port:o,version:e[X]?.version,servername:e[E],localAddress:e[$]},connector:e[V]}),e[V]({host:t,hostname:s,protocol:i,port:o,servername:e[E],localAddress:e[$]},((r,c)=>{if(r)return oe(e,r,{host:t,hostname:s,protocol:i,port:o}),void e[Z]();if(e.destroyed)return A.destroy(c.on("error",ne),new d),void e[Z]();n(c);try{e[X]="h2"===c.alpnProtocol?ee(e,c):K(e,c)}catch(r){return c.destroy().on("error",ne),oe(e,r,{host:t,hostname:s,protocol:i,port:o}),void e[Z]()}e[D]=!1,c[G]=0,c[O]=e[O],c[p]=e,c[T]=null,a.connected.hasSubscribers&&a.connected.publish({connectParams:{host:t,hostname:s,protocol:i,port:o,version:e[X]?.version,servername:e[E],localAddress:e[$]},connector:e[V],socket:c}),e.emit("connect",e[I],[e]),e[Z]()}))}function oe(e,t,{host:s,hostname:r,protocol:i,port:o}){if(!e.destroyed){if(e[D]=!1,a.connectError.hasSubscribers&&a.connectError.publish({connectParams:{host:s,hostname:r,protocol:i,port:o,version:e[X]?.version,servername:e[E],localAddress:e[$]},connector:e[V],error:t}),"ERR_TLS_CERT_ALTNAME_INVALID"===t.code)for(n(0===e[f]);e[m]>0&&e[S][e[R]].servername===e[E];){const s=e[S][e[R]++];A.errorRequest(e,s,t)}else ie(e,t);e.emit("connectionError",e[I],[e],t)}}function ae(e){e[b]=0,e.emit("drain",e[I],[e])}function ce(e,t){2!==e[Q]&&(e[Q]=2,function(e,t){for(;;){if(e.destroyed)return void n(0===e[m]);if(e[te]&&!e[y])return e[te](),void(e[te]=null);if(e[X]&&e[X].resume(),e[C])e[b]=2;else if(2===e[b]){t?(e[b]=1,queueMicrotask((()=>ae(e)))):ae(e);continue}if(0===e[m])return;if(e[f]>=(re(e)||1))return;const s=e[S][e[R]];if("https:"===e[I].protocol&&e[E]!==s.servername){if(e[f]>0)return;e[E]=s.servername,e[X]?.destroy(new g("servername changed"),(()=>{e[X]=null,ce(e)}))}if(e[D])return;if(!e[X])return void Ae(e);if(e[X].destroyed)return;if(e[X].busy(s))return;!s.aborted&&e[X].write(s)?e[R]++:e[S].splice(e[R],1)}}(e,t),e[Q]=0,e[k]>256&&(e[S].splice(0,e[k]),e[R]-=e[k],e[k]=0))}e.exports=class extends l{constructor(e,{maxHeaderSize:t,headersTimeout:s,socketTimeout:n,requestTimeout:i,connectTimeout:o,bodyTimeout:a,idleTimeout:c,keepAlive:l,keepAliveTimeout:g,maxKeepAliveTimeout:d,keepAliveMaxTimeout:p,keepAliveTimeoutThreshold:C,socketPath:B,pipelining:f,tls:m,strictContentLength:y,maxCachedSessions:w,connect:D,maxRequestsPerClient:T,localAddress:G,maxResponseSize:J,autoSelectFamily:W,autoSelectFamilyAttemptTimeout:_,maxConcurrentStreams:K,allowH2:ee}={}){if(void 0!==l)throw new h("unsupported keepAlive, use pipelining=0 instead");if(void 0!==n)throw new h("unsupported socketTimeout, use headersTimeout & bodyTimeout instead");if(void 0!==i)throw new h("unsupported requestTimeout, use headersTimeout & bodyTimeout instead");if(void 0!==c)throw new h("unsupported idleTimeout, use keepAliveTimeout instead");if(void 0!==d)throw new h("unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead");if(null!=t){if(!Number.isInteger(t)||t<1)throw new h("invalid maxHeaderSize")}else t=se();if(null!=B&&"string"!=typeof B)throw new h("invalid socketPath");if(null!=o&&(!Number.isFinite(o)||o<0))throw new h("invalid connectTimeout");if(null!=g&&(!Number.isFinite(g)||g<=0))throw new h("invalid keepAliveTimeout");if(null!=p&&(!Number.isFinite(p)||p<=0))throw new h("invalid keepAliveMaxTimeout");if(null!=C&&!Number.isFinite(C))throw new h("invalid keepAliveTimeoutThreshold");if(null!=s&&(!Number.isInteger(s)||s<0))throw new h("headersTimeout must be a positive integer or zero");if(null!=a&&(!Number.isInteger(a)||a<0))throw new h("bodyTimeout must be a positive integer or zero");if(null!=D&&"function"!=typeof D&&"object"!=typeof D)throw new h("connect must be a function or an object");if(null!=T&&(!Number.isInteger(T)||T<0))throw new h("maxRequestsPerClient must be a positive number");if(null!=G&&("string"!=typeof G||0===r.isIP(G)))throw new h("localAddress must be valid string IP address");if(null!=J&&(!Number.isInteger(J)||J<-1))throw new h("maxResponseSize must be a positive number");if(null!=_&&(!Number.isInteger(_)||_<-1))throw new h("autoSelectFamilyAttemptTimeout must be a positive number");if(null!=ee&&"boolean"!=typeof ee)throw new h("allowH2 must be a valid boolean value");if(null!=K&&("number"!=typeof K||K<1))throw new h("maxConcurrentStreams must be a positive integer, greater than 0");super(),"function"!=typeof D&&(D=u({...m,maxCachedSessions:w,allowH2:ee,socketPath:B,timeout:o,..."boolean"==typeof W?{autoSelectFamily:W,autoSelectFamilyAttemptTimeout:_}:void 0,...D})),this[I]=A.parseOrigin(e),this[V]=D,this[F]=null!=f?f:1,this[U]=t,this[v]=null==g?4e3:g,this[L]=null==p?6e5:p,this[P]=null==C?2e3:C,this[M]=this[v],this[E]=null,this[$]=null!=G?G:null,this[Q]=0,this[b]=0,this[N]=`host: ${this[I].hostname}${this[I].port?`:${this[I].port}`:""}\r\n`,this[x]=null!=a?a:3e5,this[H]=null!=s?s:3e5,this[Y]=null==y||y,this[O]=T,this[te]=null,this[q]=J>-1?J:-1,this[j]=null!=K?K:100,this[X]=null,this[S]=[],this[k]=0,this[R]=0,this[Z]=e=>ce(this,e),this[z]=e=>ie(this,e)}get pipelining(){return this[F]}set pipelining(e){this[F]=e,this[Z](!0)}get stats(){return new o(this)}get[m](){return this[S].length-this[R]}get[f](){return this[R]-this[k]}get[y](){return this[S].length-this[k]}get[w](){return!!this[X]&&!this[D]&&!this[X].destroyed}get[C](){return Boolean(this[X]?.busy(null)||this[y]>=(re(this)||1)||this[m]>0)}[B](e){Ae(this),this.once("connect",e)}[_](e,t){const s=new c(this[I].origin,e,t);return this[S].push(s),this[Q]||(null==A.bodyLength(s.body)&&A.isIterable(s.body)?(this[Q]=1,queueMicrotask((()=>ce(this)))):this[Z](!0)),this[Q]&&2!==this[b]&&this[C]&&(this[b]=2),this[b]<2}[J](){return new Promise((e=>{this[y]?this[te]=e:e(null)}))}[W](e){return new Promise((t=>{const s=this[S].splice(this[R]);for(let t=0;t<s.length;t++){const n=s[t];A.errorRequest(this,n,e)}const n=()=>{this[te]&&(this[te](),this[te]=null),t(null)};this[X]?(this[X].destroy(e,n),this[X]=null):queueMicrotask(n),this[Z]()}))}}},7779:(e,t,s)=>{"use strict";const n=s(5497),r=s(4555),{ClientDestroyedError:i,ClientClosedError:A,InvalidArgumentError:o}=s(4465),{kDestroy:a,kClose:c,kClosed:l,kDestroyed:h,kDispatch:g}=s(257),d=Symbol("onDestroyed"),u=Symbol("onClosed");e.exports=class extends n{[h]=!1;[d]=null;[l]=!1;[u]=[];get destroyed(){return this[h]}get closed(){return this[l]}close(e){if(void 0===e)return new Promise(((e,t)=>{this.close(((s,n)=>s?t(s):e(n)))}));if("function"!=typeof e)throw new o("invalid callback");if(this[h])return void queueMicrotask((()=>e(new i,null)));if(this[l])return void(this[u]?this[u].push(e):queueMicrotask((()=>e(null,null))));this[l]=!0,this[u].push(e);const t=()=>{const e=this[u];this[u]=null;for(let t=0;t<e.length;t++)e[t](null,null)};this[c]().then((()=>this.destroy())).then((()=>{queueMicrotask(t)}))}destroy(e,t){if("function"==typeof e&&(t=e,e=null),void 0===t)return new Promise(((t,s)=>{this.destroy(e,((e,n)=>e?s(e):t(n)))}));if("function"!=typeof t)throw new o("invalid callback");if(this[h])return void(this[d]?this[d].push(t):queueMicrotask((()=>t(null,null))));e||(e=new i),this[h]=!0,this[d]=this[d]||[],this[d].push(t);const s=()=>{const e=this[d];this[d]=null;for(let t=0;t<e.length;t++)e[t](null,null)};this[a](e).then((()=>{queueMicrotask(s)}))}dispatch(e,t){if(!t||"object"!=typeof t)throw new o("handler must be an object");t=r.unwrap(t);try{if(!e||"object"!=typeof e)throw new o("opts must be an object.");if(this[h]||this[d])throw new i;if(this[l])throw new A;return this[g](e,t)}catch(e){if("function"!=typeof t.onError)throw e;return t.onError(e),!1}}}},5497:(e,t,s)=>{"use strict";const n=s(8474),r=s(832),i=e=>(t,s)=>e(t,r.wrap(s));e.exports=class extends n{dispatch(){throw new Error("not implemented")}close(){throw new Error("not implemented")}destroy(){throw new Error("not implemented")}compose(...e){const t=Array.isArray(e[0])?e[0]:e;let s=this.dispatch.bind(this);for(const e of t)if(null!=e){if("function"!=typeof e)throw new TypeError("invalid interceptor, expected function received "+typeof e);if(s=e(s),s=i(s),null==s||"function"!=typeof s||2!==s.length)throw new TypeError("invalid interceptor")}return new Proxy(this,{get:(e,t)=>"dispatch"===t?s:e[t]})}}},4667:(e,t,s)=>{"use strict";const n=s(7779),{kClose:r,kDestroy:i,kClosed:A,kDestroyed:o,kDispatch:a,kNoProxyAgent:c,kHttpProxyAgent:l,kHttpsProxyAgent:h}=s(257),g=s(9246),d=s(3315),u={"http:":80,"https:":443};e.exports=class extends n{#C=null;#B=null;#Q=null;constructor(e={}){super(),this.#Q=e;const{httpProxy:t,httpsProxy:s,noProxy:n,...r}=e;this[c]=new d(r);const i=t??process.env.http_proxy??process.env.HTTP_PROXY;this[l]=i?new g({...r,uri:i}):this[c];const A=s??process.env.https_proxy??process.env.HTTPS_PROXY;this[h]=A?new g({...r,uri:A}):this[l],this.#f()}[a](e,t){const s=new URL(e.origin);return this.#m(s).dispatch(e,t)}[r](){return Promise.all([this[c].close(),!this[l][A]&&this[l].close(),!this[h][A]&&this[h].close()])}[i](e){return Promise.all([this[c].destroy(e),!this[l][o]&&this[l].destroy(e),!this[h][o]&&this[h].destroy(e)])}#m(e){let{protocol:t,host:s,port:n}=e;return s=s.replace(/:\d*$/,"").toLowerCase(),n=Number.parseInt(n,10)||u[t]||0,this.#y(s,n)?"https:"===t?this[h]:this[l]:this[c]}#y(e,t){if(this.#S&&this.#f(),0===this.#B.length)return!0;if("*"===this.#C)return!1;for(let s=0;s<this.#B.length;s++){const n=this.#B[s];if(!n.port||n.port===t)if(/^[.*]/.test(n.hostname)){if(e.endsWith(n.hostname.replace(/^\*/,"")))return!1}else if(e===n.hostname)return!1}return!0}#f(){const e=this.#Q.noProxy??this.#w,t=e.split(/[,\s]/),s=[];for(let e=0;e<t.length;e++){const n=t[e];if(!n)continue;const r=n.match(/^(.+):(\d+)$/);s.push({hostname:(r?r[1]:n).toLowerCase(),port:r?Number.parseInt(r[2],10):0})}this.#C=e,this.#B=s}get#S(){return void 0===this.#Q.noProxy&&this.#C!==this.#w}get#w(){return process.env.no_proxy??process.env.NO_PROXY??""}}},1726:e=>{"use strict";const t=2047;class s{bottom=0;top=0;list=new Array(2048).fill(void 0);next=null;isEmpty(){return this.top===this.bottom}isFull(){return(this.top+1&t)===this.bottom}push(e){this.list[this.top]=e,this.top=this.top+1&t}shift(){const e=this.list[this.bottom];return void 0===e?null:(this.list[this.bottom]=void 0,this.bottom=this.bottom+1&t,e)}}e.exports=class{constructor(){this.head=this.tail=new s}isEmpty(){return this.head.isEmpty()}push(e){this.head.isFull()&&(this.head=this.head.next=new s),this.head.push(e)}shift(){const e=this.tail,t=e.shift();return e.isEmpty()&&null!==e.next&&(this.tail=e.next,e.next=null),t}}},8297:(e,t,s)=>{"use strict";const{connect:n}=s(7030),{kClose:r,kDestroy:i}=s(257),{InvalidArgumentError:A}=s(4465),o=s(2858),a=s(1167),c=s(7779);e.exports=class extends c{#D=null;constructor(e,t){if("string"==typeof e&&(e=new URL(e)),"http:"!==e.protocol)throw new A("h2c-client: Only h2c protocol is supported");const{connect:s,maxConcurrentStreams:n,pipelining:r,...i}=t??{};let o=100,c=100;if(null!=n&&Number.isInteger(n)&&n>0&&(o=n),null!=r&&Number.isInteger(r)&&r>0&&(c=r),c>o)throw new A("h2c-client: pipelining cannot be greater than maxConcurrentStreams");super(),this.#D=new a(e,{...i,connect:this.#b(s),maxConcurrentStreams:o,pipelining:c,allowH2:!0})}#b(e){return(t,s)=>{const r=e?.connectOpts??1e4,{hostname:i,port:A,pathname:a}=t,c=n({...t,host:i,port:A,pathname:a});if(null==t.keepAlive||t.keepAlive){const e=null==t.keepAliveInitialDelay?6e4:t.keepAliveInitialDelay;c.setKeepAlive(!0,e)}c.alpnProtocol="h2";const l=o.setupConnectTimeout(new WeakRef(c),{timeout:r,hostname:i,port:A});return c.setNoDelay(!0).once("connect",(function(){if(queueMicrotask(l),s){const e=s;s=null,e(null,this)}})).on("error",(function(e){if(queueMicrotask(l),s){const t=s;s=null,t(e)}})),c}}dispatch(e,t){return this.#D.dispatch(e,t)}[r](){return this.#D.close()}[i](){return this.#D.destroy()}}},1694:(e,t,s)=>{"use strict";const{PoolStats:n}=s(4304),r=s(7779),i=s(1726),{kConnected:A,kSize:o,kRunning:a,kPending:c,kQueued:l,kBusy:h,kFree:g,kUrl:d,kClose:u,kDestroy:I,kDispatch:E}=s(257),p=Symbol("clients"),C=Symbol("needDrain"),B=Symbol("queue"),Q=Symbol("closed resolve"),f=Symbol("onDrain"),m=Symbol("onConnect"),y=Symbol("onDisconnect"),S=Symbol("onConnectionError"),w=Symbol("get dispatcher"),D=Symbol("add client"),b=Symbol("remove client");e.exports={PoolBase:class extends r{[B]=new i;[l]=0;[p]=[];[C]=!1;[f](e,t,s){const n=this[B];let r=!1;for(;!r;){const t=n.shift();if(!t)break;this[l]--,r=!e.dispatch(t.opts,t.handler)}if(e[C]=r,!r&&this[C]&&(this[C]=!1,this.emit("drain",t,[this,...s])),this[Q]&&n.isEmpty()){const e=new Array(this[p].length);for(let t=0;t<this[p].length;t++)e[t]=this[p][t].close();Promise.all(e).then(this[Q])}}[m]=(e,t)=>{this.emit("connect",e,[this,...t])};[y]=(e,t,s)=>{this.emit("disconnect",e,[this,...t],s)};[S]=(e,t,s)=>{this.emit("connectionError",e,[this,...t],s)};get[h](){return this[C]}get[A](){let e=0;for(const{[A]:t}of this[p])e+=t;return e}get[g](){let e=0;for(const{[A]:t,[C]:s}of this[p])e+=t&&!s;return e}get[c](){let e=this[l];for(const{[c]:t}of this[p])e+=t;return e}get[a](){let e=0;for(const{[a]:t}of this[p])e+=t;return e}get[o](){let e=this[l];for(const{[o]:t}of this[p])e+=t;return e}get stats(){return new n(this)}[u](){if(this[B].isEmpty()){const e=new Array(this[p].length);for(let t=0;t<this[p].length;t++)e[t]=this[p][t].close();return Promise.all(e)}return new Promise((e=>{this[Q]=e}))}[I](e){for(;;){const t=this[B].shift();if(!t)break;t.handler.onError(e)}const t=new Array(this[p].length);for(let s=0;s<this[p].length;s++)t[s]=this[p][s].destroy(e);return Promise.all(t)}[E](e,t){const s=this[w]();return s?s.dispatch(e,t)||(s[C]=!0,this[C]=!this[w]()):(this[C]=!0,this[B].push({opts:e,handler:t}),this[l]++),!this[C]}[D](e){return e.on("drain",this[f].bind(this,e)).on("connect",this[m]).on("disconnect",this[y]).on("connectionError",this[S]),this[p].push(e),this[C]&&queueMicrotask((()=>{this[C]&&this[f](e,e[d],[e,this])})),this}[b](e){e.close((()=>{const t=this[p].indexOf(e);-1!==t&&this[p].splice(t,1)})),this[C]=this[p].some((e=>!e[C]&&!0!==e.closed&&!0!==e.destroyed))}},kClients:p,kNeedDrain:C,kAddClient:D,kRemoveClient:b,kGetDispatcher:w}},8542:(e,t,s)=>{"use strict";const{PoolBase:n,kClients:r,kNeedDrain:i,kAddClient:A,kGetDispatcher:o,kRemoveClient:a}=s(1694),c=s(1167),{InvalidArgumentError:l}=s(4465),h=s(2858),{kUrl:g}=s(257),d=s(1986),u=Symbol("options"),I=Symbol("connections"),E=Symbol("factory");function p(e,t){return new c(e,t)}e.exports=class extends n{constructor(e,{connections:t,factory:s=p,connect:n,connectTimeout:i,tls:A,maxCachedSessions:o,socketPath:a,autoSelectFamily:c,autoSelectFamilyAttemptTimeout:C,allowH2:B,clientTtl:Q,...f}={}){if(null!=t&&(!Number.isFinite(t)||t<0))throw new l("invalid connections");if("function"!=typeof s)throw new l("factory must be a function.");if(null!=n&&"function"!=typeof n&&"object"!=typeof n)throw new l("connect must be a function or an object");"function"!=typeof n&&(n=d({...A,maxCachedSessions:o,allowH2:B,socketPath:a,timeout:i,..."boolean"==typeof c?{autoSelectFamily:c,autoSelectFamilyAttemptTimeout:C}:void 0,...n})),super(),this[I]=t||null,this[g]=h.parseOrigin(e),this[u]={...h.deepClone(f),connect:n,allowH2:B,clientTtl:Q},this[u].interceptors=f.interceptors?{...f.interceptors}:void 0,this[E]=s,this.on("connect",((e,t)=>{if(null!=Q&&Q>0)for(const e of t)Object.assign(e,{ttl:Date.now()})})),this.on("connectionError",((e,t,s)=>{for(const e of t){const t=this[r].indexOf(e);-1!==t&&this[r].splice(t,1)}}))}[o](){const e=this[u].clientTtl;for(const t of this[r])if(null!=e&&e>0&&t.ttl&&Date.now()-t.ttl>e)this[a](t);else if(!t[i])return t;if(!this[I]||this[r].length<this[I]){const e=this[E](this[g],this[u]);return this[A](e),e}}}},9246:(e,t,s)=>{"use strict";const{kProxy:n,kClose:r,kDestroy:i,kDispatch:A}=s(257),o=s(3315),a=s(8542),c=s(7779),{InvalidArgumentError:l,RequestAbortedError:h,SecureProxyConnectionError:g}=s(4465),d=s(1986),u=s(1167),I=Symbol("proxy agent"),E=Symbol("proxy client"),p=Symbol("proxy headers"),C=Symbol("request tls settings"),B=Symbol("proxy tls settings"),Q=Symbol("connect endpoint function"),f=Symbol("tunnel proxy");function m(e,t){return new a(e,t)}const y=()=>{};function S(e,t){return 1===t.connections?new u(e,t):new a(e,t)}class w extends c{#D;constructor(e,{headers:t={},connect:s,factory:n}){if(!e)throw new l("Proxy URL is mandatory");super(),this[p]=t,this.#D=n?n(e,{connect:s}):new u(e,{connect:s})}[A](e,t){const s=t.onHeaders;t.onHeaders=function(e,n,r){407!==e?s&&s.call(this,e,n,r):"function"==typeof t.onError&&t.onError(new l("Proxy Authentication Required (407)"))};const{origin:n,path:r="/",headers:i={}}=e;if(e.path=n+r,!("host"in i)&&!("Host"in i)){const{host:e}=new URL(n);i.host=e}return e.headers={...this[p],...i},this.#D[A](e,t)}[r](){return this.#D.close()}[i](e){return this.#D.destroy(e)}}e.exports=class extends c{constructor(e){if(!e||"object"==typeof e&&!(e instanceof URL)&&!e.uri)throw new l("Proxy uri is mandatory");const{clientFactory:t=m}=e;if("function"!=typeof t)throw new l("Proxy opts.clientFactory must be a function.");const{proxyTunnel:s=!0}=e;super();const r=this.#v(e),{href:i,origin:A,port:a,protocol:c,username:u,password:D,hostname:b}=r;if(this[n]={uri:i,protocol:c},this[C]=e.requestTls,this[B]=e.proxyTls,this[p]=e.headers||{},this[f]=s,e.auth&&e.token)throw new l("opts.auth cannot be used in combination with opts.token");e.auth?this[p]["proxy-authorization"]=`Basic ${e.auth}`:e.token?this[p]["proxy-authorization"]=e.token:u&&D&&(this[p]["proxy-authorization"]=`Basic ${Buffer.from(`${decodeURIComponent(u)}:${decodeURIComponent(D)}`).toString("base64")}`);const v=d({...e.proxyTls});this[Q]=d({...e.requestTls});const N=e.factory||S;this[E]=t(r,{connect:v}),this[I]=new o({...e,factory:(e,t)=>{const{protocol:s}=new URL(e);return this[f]||"http:"!==s||"http:"!==this[n].protocol?N(e,t):new w(this[n].uri,{headers:this[p],connect:v,factory:N})},connect:async(e,t)=>{let s=e.host;e.port||(s+=`:${function(e){return"https:"===e?443:80}(e.protocol)}`);try{const{socket:n,statusCode:r}=await this[E].connect({origin:A,port:a,path:s,signal:e.signal,headers:{...this[p],host:e.host,...null==e.connections||e.connections>0?{"proxy-connection":"keep-alive"}:{}},servername:this[B]?.servername||b});if(200!==r&&(n.on("error",y).destroy(),t(new h(`Proxy response (${r}) !== 200 when HTTP Tunneling`))),"https:"!==e.protocol)return void t(null,n);let i;i=this[C]?this[C].servername:e.servername,this[Q]({...e,servername:i,httpSocket:n},t)}catch(e){"ERR_TLS_CERT_ALTNAME_INVALID"===e.code?t(new g(e)):t(e)}}})}dispatch(e,t){const s=function(e){if(Array.isArray(e)){const t={};for(let s=0;s<e.length;s+=2)t[e[s]]=e[s+1];return t}return e}(e.headers);if(function(e){const t=e&&Object.keys(e).find((e=>"proxy-authorization"===e.toLowerCase()));if(t)throw new l("Proxy-Authorization should be sent in ProxyAgent constructor")}(s),s&&!("host"in s)&&!("Host"in s)){const{host:t}=new URL(e.origin);s.host=t}return this[I].dispatch({...e,headers:s},t)}#v(e){return"string"==typeof e?new URL(e):e instanceof URL?e:new URL(e.uri)}[r](){return Promise.all([this[I].close(),this[E].close()])}[i](){return Promise.all([this[I].destroy(),this[E].destroy()])}}},8712:(e,t,s)=>{"use strict";const n=s(5497),r=s(6294);e.exports=class extends n{#N=null;#R=null;constructor(e,t={}){super(t),this.#N=e,this.#R=t}dispatch(e,t){const s=new r({...e,retryOptions:this.#R},{dispatch:this.#N.dispatch.bind(this.#N),handler:t});return this.#N.dispatch(e,s)}close(){return this.#N.close()}destroy(){return this.#N.destroy()}}},9879:(e,t,s)=>{"use strict";const n=Symbol.for("undici.globalDispatcher.1"),{InvalidArgumentError:r}=s(4465),i=s(3315);function A(e){if(!e||"function"!=typeof e.dispatch)throw new r("Argument agent must implement Agent");Object.defineProperty(globalThis,n,{value:e,writable:!0,enumerable:!1,configurable:!1})}function o(){return globalThis[n]}void 0===o()&&A(new i);e.exports={setGlobalDispatcher:A,getGlobalDispatcher:o,installedExports:["fetch","Headers","Response","Request","FormData","WebSocket","CloseEvent","ErrorEvent","MessageEvent","EventSource"]}},8358:(e,t,s)=>{"use strict";const n=s(2858),{parseCacheControlHeader:r,parseVaryHeader:i,isEtagUsable:A}=s(9453),{parseHttpDate:o}=s(8851);function a(){}const c=[200,203,204,206,300,301,308,404,405,410,414,501],l=[206,304];e.exports=class{#k;#T;#F;#M;#U;#L;constructor({store:e,type:t,cacheByDefault:s},n,r){this.#M=e,this.#T=t,this.#F=s,this.#k=n,this.#U=r}onRequestStart(e,t){this.#L?.destroy(),this.#L=void 0,this.#U.onRequestStart?.(e,t)}onRequestUpgrade(e,t,s,n){this.#U.onRequestUpgrade?.(e,t,s,n)}onResponseStart(e,t,s,h){const g=()=>this.#U.onResponseStart?.(e,t,s,h);if(!n.safeHTTPMethods.includes(this.#k.method)&&t>=200&&t<=399){try{this.#M.delete(this.#k)?.catch?.(a)}catch{}return g()}const d=s["cache-control"],u=s["last-modified"]&&c.includes(t);if(!(d||s.expires||u||this.#F))return g();const I=d?r(d):{};if(!function(e,t,s,n){if(t<200||l.includes(t))return!1;if(!(c.includes(t)||s.expires||n.public||void 0!==n["max-age"]||n.private&&"private"===e||void 0!==n["s-maxage"]&&"shared"===e))return!1;if(n["no-store"])return!1;if("shared"===e&&!0===n.private)return!1;if(s.vary?.includes("*"))return!1;if(s.authorization){if(!n.public||"string"!=typeof s.authorization)return!1;if(Array.isArray(n["no-cache"])&&n["no-cache"].includes("authorization"))return!1;if(Array.isArray(n.private)&&n.private.includes("authorization"))return!1}return!0}(this.#T,t,s,I))return g();const E=Date.now(),p=s.age?function(e){const t=parseInt(Array.isArray(e)?e[0]:e);return isNaN(t)?void 0:1e3*t}(s.age):void 0;if(p&&p>=2147483647e3)return g();const C="string"==typeof s.date?o(s.date):void 0,B=function(e,t,s,n,r,i){if("shared"===e){const e=i["s-maxage"];if(void 0!==e)return e>0?1e3*e:void 0}const A=i["max-age"];if(void 0!==A)return A>0?1e3*A:void 0;if("string"==typeof n.expires){const e=o(n.expires);if(e){if(t>=e.getTime())return;if(r){if(r>=e)return;if(void 0!==s&&s>e-r)return}return e.getTime()-t}}if("string"==typeof n["last-modified"]){const e=new Date(n["last-modified"]);if((a=e)instanceof Date&&Number.isFinite(a.valueOf())){if(e.getTime()>=t)return;return.1*(t-e.getTime())}}var a;if(i.immutable)return 31536e3;return}(this.#T,E,p,s,C,I)??this.#F;if(void 0===B||p&&p>B)return g();const Q=C?C.getTime():E,f=B+Q;if(E>=f)return g();let m;if(this.#k.headers&&s.vary&&(m=i(s.vary,this.#k.headers),!m))return g();const y=function(e,t,s){let n=-1/0,r=-1/0,i=-1/0;t["stale-while-revalidate"]&&(n=s+1e3*t["stale-while-revalidate"]);t["stale-if-error"]&&(r=s+1e3*t["stale-if-error"]);n===-1/0&&r===-1/0&&(i=e+31536e6);return Math.max(s,n,r,i)}(Q,I,f),S=function(e,t){const s=["connection","proxy-authenticate","proxy-authentication-info","proxy-authorization","proxy-connection","te","transfer-encoding","upgrade","age"];e.connection&&(Array.isArray(e.connection)?s.push(...e.connection.map((e=>e.trim()))):s.push(...e.connection.split(",").map((e=>e.trim()))));Array.isArray(t["no-cache"])&&s.push(...t["no-cache"]);Array.isArray(t.private)&&s.push(...t.private);let n;for(const t of s)e[t]&&(n??={...e},delete n[t]);return n??e}(s,I),w={statusCode:t,statusMessage:h,headers:S,vary:m,cacheControlDirectives:I,cachedAt:p?E-p:E,staleAt:f,deleteAt:y};if("string"==typeof s.etag&&A(s.etag)&&(w.etag=s.etag),this.#L=this.#M.createWriteStream(this.#k,w),!this.#L)return g();const D=this;return this.#L.on("drain",(()=>e.resume())).on("error",(function(){D.#L=void 0,D.#M.delete(D.#k)})).on("close",(function(){D.#L===this&&(D.#L=void 0),e.resume()})),g()}onResponseData(e,t){!1===this.#L?.write(t)&&e.pause(),this.#U.onResponseData?.(e,t)}onResponseEnd(e,t){this.#L?.end(),this.#U.onResponseEnd?.(e,t)}onResponseError(e,t){this.#L?.destroy(t),this.#L=void 0,this.#U.onResponseError?.(e,t)}}},6607:(e,t,s)=>{"use strict";const n=s(4589);e.exports=class{#P=!1;#H;#U;#x;#Y;constructor(e,t,s){if("function"!=typeof e)throw new TypeError("callback must be a function");this.#H=e,this.#U=t,this.#Y=s}onRequestStart(e,t){this.#P=!1,this.#x=t}onRequestUpgrade(e,t,s,n){this.#U.onRequestUpgrade?.(e,t,s,n)}onResponseStart(e,t,s,r){if(n(null!=this.#H),this.#P=304===t||this.#Y&&t>=500&&t<=504,this.#H(this.#P,this.#x),this.#H=null,this.#P)return!0;this.#U.onRequestStart?.(e,this.#x),this.#U.onResponseStart?.(e,t,s,r)}onResponseData(e,t){if(!this.#P)return this.#U.onResponseData?.(e,t)}onResponseEnd(e,t){this.#P||this.#U.onResponseEnd?.(e,t)}onResponseError(e,t){if(!this.#P){if(this.#H&&(this.#H(!1),this.#H=null),"function"!=typeof this.#U.onResponseError)throw t;this.#U.onResponseError(e,t)}}}},6917:(e,t,s)=>{"use strict";const n=s(4589),r=s(832);e.exports=class{#U;#V=!1;#O=!1;#G=!1;constructor(e){if("object"!=typeof e||null===e)throw new TypeError("handler must be an object");this.#U=r.wrap(e)}onRequestStart(...e){this.#U.onRequestStart?.(...e)}onRequestUpgrade(...e){return n(!this.#V),n(!this.#O),this.#U.onRequestUpgrade?.(...e)}onResponseStart(...e){return n(!this.#V),n(!this.#O),n(!this.#G),this.#G=!0,this.#U.onResponseStart?.(...e)}onResponseData(...e){return n(!this.#V),n(!this.#O),this.#U.onResponseData?.(...e)}onResponseEnd(...e){return n(!this.#V),n(!this.#O),this.#V=!0,this.#U.onResponseEnd?.(...e)}onResponseError(...e){return this.#O=!0,this.#U.onResponseError?.(...e)}onBodySent(){}}},8064:(e,t,s)=>{"use strict";const n=s(2858),{kBodyUsed:r}=s(257),i=s(4589),{InvalidArgumentError:A}=s(4465),o=s(8474),a=[300,301,302,303,307,308],c=Symbol("body"),l=()=>{};class h{constructor(e){this[c]=e,this[r]=!1}async*[Symbol.asyncIterator](){i(!this[r],"disturbed"),this[r]=!0,yield*this[c]}}class g{static buildDispatch(e,t){if(null!=t&&(!Number.isInteger(t)||t<0))throw new A("maxRedirections must be a positive number");const s=e.dispatch.bind(e);return(e,n)=>s(e,new g(s,t,e,n))}constructor(e,t,s,a){if(null!=t&&(!Number.isInteger(t)||t<0))throw new A("maxRedirections must be a positive number");this.dispatch=e,this.location=null;const{maxRedirections:c,...l}=s;this.opts=l,this.maxRedirections=t,this.handler=a,this.history=[],n.isStream(this.opts.body)?(0===n.bodyLength(this.opts.body)&&this.opts.body.on("data",(function(){i(!1)})),"boolean"!=typeof this.opts.body.readableDidRead&&(this.opts.body[r]=!1,o.prototype.on.call(this.opts.body,"data",(function(){this[r]=!0})))):(this.opts.body&&"function"==typeof this.opts.body.pipeTo||this.opts.body&&"string"!=typeof this.opts.body&&!ArrayBuffer.isView(this.opts.body)&&n.isIterable(this.opts.body)&&!n.isFormDataLike(this.opts.body))&&(this.opts.body=new h(this.opts.body))}onRequestStart(e,t){this.handler.onRequestStart?.(e,{...t,history:this.history})}onRequestUpgrade(e,t,s,n){this.handler.onRequestUpgrade?.(e,t,s,n)}onResponseStart(e,t,s,r){if(this.opts.throwOnMaxRedirect&&this.history.length>=this.maxRedirections)throw new Error("max redirects");if(301!==t&&302!==t||"POST"!==this.opts.method||(this.opts.method="GET",n.isStream(this.opts.body)&&n.destroy(this.opts.body.on("error",l)),this.opts.body=null),303===t&&"HEAD"!==this.opts.method&&(this.opts.method="GET",n.isStream(this.opts.body)&&n.destroy(this.opts.body.on("error",l)),this.opts.body=null),this.location=this.history.length>=this.maxRedirections||n.isDisturbed(this.opts.body)||-1===a.indexOf(t)?null:s.location,this.opts.origin&&this.history.push(new URL(this.opts.path,this.opts.origin)),!this.location)return void this.handler.onResponseStart?.(e,t,s,r);const{origin:o,pathname:c,search:h}=n.parseURL(new URL(this.location,this.opts.origin&&new URL(this.opts.path,this.opts.origin))),g=h?`${c}${h}`:c,u=`${o}${g}`;for(const e of this.history)if(e.toString()===u)throw new A(`Redirect loop detected. Cannot redirect to ${o}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);this.opts.headers=function(e,t,s){const n=[];if(Array.isArray(e))for(let r=0;r<e.length;r+=2)d(e[r],t,s)||n.push(e[r],e[r+1]);else if(e&&"object"==typeof e){const r="function"==typeof e[Symbol.iterator]?e:Object.entries(e);for(const[e,i]of r)d(e,t,s)||n.push(e,i)}else i(null==e,"headers must be an object or an array");return n}(this.opts.headers,303===t,this.opts.origin!==o),this.opts.path=g,this.opts.origin=o,this.opts.query=null}onResponseData(e,t){this.location||this.handler.onResponseData?.(e,t)}onResponseEnd(e,t){this.location?this.dispatch(this.opts,this):this.handler.onResponseEnd(e,t)}onResponseError(e,t){this.handler.onResponseError?.(e,t)}}function d(e,t,s){if(4===e.length)return"host"===n.headerNameToString(e);if(t&&n.headerNameToString(e).startsWith("content-"))return!0;if(s&&(13===e.length||6===e.length||19===e.length)){const t=n.headerNameToString(e);return"authorization"===t||"cookie"===t||"proxy-authorization"===t}return!1}e.exports=g},6294:(e,t,s)=>{"use strict";const n=s(4589),{kRetryHandlerDefaultRetry:r}=s(257),{RequestRetryError:i}=s(4465),A=s(832),{isDisturbed:o,parseRangeHeader:a,wrapRequestBody:c}=s(2858);class l{constructor(e,{dispatch:t,handler:s}){const{retryOptions:n,...i}=e,{retry:o,maxRetries:a,maxTimeout:h,minTimeout:g,timeoutFactor:d,methods:u,errorCodes:I,retryAfter:E,statusCodes:p,throwOnError:C}=n??{};this.error=null,this.dispatch=t,this.handler=A.wrap(s),this.opts={...i,body:c(e.body)},this.retryOpts={throwOnError:C??!0,retry:o??l[r],retryAfter:E??!0,maxTimeout:h??3e4,minTimeout:g??500,timeoutFactor:d??2,maxRetries:a??5,methods:u??["GET","HEAD","OPTIONS","PUT","DELETE","TRACE"],statusCodes:p??[500,502,503,504,429],errorCodes:I??["ECONNRESET","ECONNREFUSED","ENOTFOUND","ENETDOWN","ENETUNREACH","EHOSTDOWN","EHOSTUNREACH","EPIPE","UND_ERR_SOCKET"]},this.retryCount=0,this.retryCountCheckpoint=0,this.headersSent=!1,this.start=0,this.end=null,this.etag=null}onResponseStartWithRetry(e,t,s,n,r){if(this.retryOpts.throwOnError)!1===this.retryOpts.statusCodes.includes(t)?(this.headersSent=!0,this.handler.onResponseStart?.(e,t,s,n)):this.error=r;else{if(o(this.opts.body))return this.headersSent=!0,void this.handler.onResponseStart?.(e,t,s,n);e.pause(),this.retryOpts.retry(r,{state:{counter:this.retryCount},opts:{retryOptions:this.retryOpts,...this.opts}},function(i){if(i)return this.headersSent=!0,this.headersSent=!0,this.handler.onResponseStart?.(e,t,s,n),void e.resume();this.error=r,e.resume()}.bind(this))}}onRequestStart(e,t){this.headersSent||this.handler.onRequestStart?.(e,t)}onRequestUpgrade(e,t,s,n){this.handler.onRequestUpgrade?.(e,t,s,n)}static[r](e,{state:t,opts:s},n){const{statusCode:r,code:i,headers:A}=e,{method:o,retryOptions:a}=s,{maxRetries:c,minTimeout:l,maxTimeout:h,timeoutFactor:g,statusCodes:d,errorCodes:u,methods:I}=a,{counter:E}=t;if(i&&"UND_ERR_REQ_RETRY"!==i&&!u.includes(i))return void n(e);if(Array.isArray(I)&&!I.includes(o))return void n(e);if(null!=r&&Array.isArray(d)&&!d.includes(r))return void n(e);if(E>c)return void n(e);let p=A?.["retry-after"];p&&(p=Number(p),p=Number.isNaN(p)?function(e){const t=new Date(e).getTime();return isNaN(t)?0:t-Date.now()}(A["retry-after"]):1e3*p);const C=p>0?Math.min(p,h):Math.min(l*g**(E-1),h);setTimeout((()=>n(null)),C)}onResponseStart(e,t,s,r){if(this.error=null,this.retryCount+=1,t>=300){const n=new i("Request failed",t,{headers:s,data:{count:this.retryCount}});this.onResponseStartWithRetry(e,t,s,r,n)}else{if(this.headersSent){if(206!==t&&(this.start>0||200!==t))throw new i("server does not support the range header and the payload was partially consumed",t,{headers:s,data:{count:this.retryCount}});const e=a(s["content-range"]);if(!e)throw new i("Content-Range mismatch",t,{headers:s,data:{count:this.retryCount}});if(null!=this.etag&&this.etag!==s.etag)throw new i("ETag mismatch",t,{headers:s,data:{count:this.retryCount}});const{start:r,size:A,end:o=(A?A-1:null)}=e;return n(this.start===r,"content-range mismatch"),void n(null==this.end||this.end===o,"content-range mismatch")}if(null!=this.end)throw new i("Request failed",t,{headers:s,data:{count:this.retryCount}});if(206===t){const i=a(s["content-range"]);if(null==i)return this.headersSent=!0,void this.handler.onResponseStart?.(e,t,s,r);const{start:A,size:o,end:c=(o?o-1:null)}=i;n(null!=A&&Number.isFinite(A),"content-range mismatch"),n(null!=c&&Number.isFinite(c),"invalid content-length"),this.start=A,this.end=c}if(null==this.end){const e=s["content-length"];this.end=null!=e?Number(e)-1:null}n(Number.isFinite(this.start)),n(null==this.end||Number.isFinite(this.end),"invalid content-length"),this.resume=!0,this.etag=null!=s.etag?s.etag:null,null!=this.etag&&"W"===this.etag[0]&&"/"===this.etag[1]&&(this.etag=null),this.headersSent=!0,this.handler.onResponseStart?.(e,t,s,r)}}onResponseData(e,t){this.error||(this.start+=t.length,this.handler.onResponseData?.(e,t))}onResponseEnd(e,t){if(this.error&&this.retryOpts.throwOnError)throw this.error;if(!this.error)return this.retryCount=0,this.handler.onResponseEnd?.(e,t);this.retry(e)}retry(e){if(0!==this.start){const e={range:`bytes=${this.start}-${this.end??""}`};null!=this.etag&&(e["if-match"]=this.etag),this.opts={...this.opts,headers:{...this.opts.headers,...e}}}try{this.retryCountCheckpoint=this.retryCount,this.dispatch(this.opts,this)}catch(t){this.handler.onResponseError?.(e,t)}}onResponseError(e,t){e?.aborted||o(this.opts.body)?this.handler.onResponseError?.(e,t):(this.retryCount-this.retryCountCheckpoint>0?this.retryCount=this.retryCountCheckpoint+(this.retryCount-this.retryCountCheckpoint):this.retryCount+=1,this.retryOpts.retry(t,{state:{counter:this.retryCount},opts:{retryOptions:this.retryOpts,...this.opts}},function(t){t?this.handler?.onResponseError?.(e,t):this.retry(e)}.bind(this)))}}e.exports=l},4555:(e,t,s)=>{"use strict";const{parseHeaders:n}=s(2858),{InvalidArgumentError:r}=s(4465),i=Symbol("resume");class A{#J=!1;#W=null;#_=!1;#$;[i]=null;constructor(e){this.#$=e}pause(){this.#J=!0}resume(){this.#J&&(this.#J=!1,this[i]?.())}abort(e){this.#_||(this.#_=!0,this.#W=e,this.#$(e))}get aborted(){return this.#_}get reason(){return this.#W}get paused(){return this.#J}}e.exports=class e{#U;#q;constructor(e){this.#U=e}static unwrap(t){return t.onRequestStart?new e(t):t}onConnect(e,t){this.#q=new A(e),this.#U.onRequestStart?.(this.#q,t)}onUpgrade(e,t,s){this.#U.onRequestUpgrade?.(this.#q,e,n(t),s)}onHeaders(e,t,s,r){return this.#q[i]=s,this.#U.onResponseStart?.(this.#q,e,n(t),r),!this.#q.paused}onData(e){return this.#U.onResponseData?.(this.#q,e),!this.#q.paused}onComplete(e){this.#U.onResponseEnd?.(this.#q,n(e))}onError(e){if(!this.#U.onResponseError)throw new r("invalid onError method");this.#U.onResponseError?.(this.#q,e)}}},832:(e,t,s)=>{"use strict";const{InvalidArgumentError:n}=s(4465);e.exports=class e{#U;constructor(e){this.#U=e}static wrap(t){return t.onRequestStart?t:new e(t)}onConnect(e,t){return this.#U.onConnect?.(e,t)}onHeaders(e,t,s,n){return this.#U.onHeaders?.(e,t,s,n)}onUpgrade(e,t,s){return this.#U.onUpgrade?.(e,t,s)}onData(e){return this.#U.onData?.(e)}onComplete(e){return this.#U.onComplete?.(e)}onError(e){if(!this.#U.onError)throw e;return this.#U.onError?.(e)}onRequestStart(e,t){this.#U.onConnect?.((t=>e.abort(t)),t)}onRequestUpgrade(e,t,s,n){const r=[];for(const[e,t]of Object.entries(s))r.push(Buffer.from(e),Array.isArray(t)?t.map((e=>Buffer.from(e))):Buffer.from(t));this.#U.onUpgrade?.(t,r,n)}onResponseStart(e,t,s,n){const r=[];for(const[e,t]of Object.entries(s))r.push(Buffer.from(e),Array.isArray(t)?t.map((e=>Buffer.from(e))):Buffer.from(t));!1===this.#U.onHeaders?.(t,r,(()=>e.resume()),n)&&e.pause()}onResponseData(e,t){!1===this.#U.onData?.(t)&&e.pause()}onResponseEnd(e,t){const s=[];for(const[e,n]of Object.entries(t))s.push(Buffer.from(e),Array.isArray(n)?n.map((e=>Buffer.from(e))):Buffer.from(n));this.#U.onComplete?.(s)}onResponseError(e,t){if(!this.#U.onError)throw new n("invalid onError method");this.#U.onError?.(t)}}},5752:(e,t,s)=>{"use strict";const n=s(4589),{Readable:r}=s(7075),i=s(2858),A=s(8358),o=s(9903),a=s(6607),{assertCacheStore:c,assertCacheMethods:l,makeCacheKey:h,normalizeHeaders:g,parseCacheControlHeader:d}=s(9453),{AbortError:u}=s(4465);function I(e,t,s,A,o,a){const c=i.isStream(s.body)?s.body:r.from(s.body??[]);n(!c.destroyed,"stream should not be destroyed"),n(!c.readableDidRead,"stream should not be readableDidRead");const l={resume(){c.resume()},pause(){c.pause()},get paused(){return c.isPaused()},get aborted(){return c.destroyed},get reason(){return c.errored},abort(e){c.destroy(e??new u)}};if(c.on("error",(function(t){if(!this.readableEnded){if("function"!=typeof e.onResponseError)throw t;e.onResponseError(l,t)}})).on("close",(function(){this.errored||e.onResponseEnd?.(l,{})})),e.onRequestStart?.(l,o),c.destroyed)return;const h={...s.headers,age:String(A)};a&&(h.warning='110 - "response is stale"'),e.onResponseStart?.(l,s.statusCode,h,s.statusMessage),"HEAD"===t.method?c.destroy():c.on("data",(function(t){e.onResponseData?.(l,t)}))}function E(e,t,s,n,r,o,c){if(!c)return function(e,t,s,n,r,i){if(i?.["only-if-cached"]){let e=!1;try{if("function"==typeof n.onConnect&&(n.onConnect((()=>{e=!0})),e))return;if("function"==typeof n.onHeaders&&(n.onHeaders(504,[],(()=>{}),"Gateway Timeout"),e))return;"function"==typeof n.onComplete&&n.onComplete([])}catch(e){"function"==typeof n.onError&&n.onError(e)}return!0}return e(r,new A(t,s,n))}(e,t,s,n,r,o);const l=Date.now();if(l>c.deleteAt)return e(r,new A(t,s,n));const h=Math.round((l-c.cachedAt)/1e3);if(o?.["max-age"]&&h>=o["max-age"])return e(r,n);if(function(e,t){if(t?.["no-cache"])return!0;if(e.cacheControlDirectives?.["no-cache"]&&!Array.isArray(e.cacheControlDirectives["no-cache"]))return!0;const s=Date.now();if(s>e.staleAt)return!t?.["max-stale"]||s>e.staleAt+1e3*t["max-stale"];if(t?.["min-fresh"])return e.staleAt-s<=1e3*t["min-fresh"];return!1}(c,o)){if(i.isStream(r.body)&&0!==i.bodyLength(r.body))return e(r,new A(t,s,n));if(function(e){const t=e.cacheControlDirectives?.["stale-while-revalidate"];return!!t&&Date.now()<=e.staleAt+1e3*t}(c))return I(n,r,c,h,null,!0),queueMicrotask((()=>{let n={...r.headers,"if-modified-since":new Date(c.cachedAt).toUTCString()};c.etag&&(n["if-none-match"]=c.etag),c.vary&&(n={...n,...c.vary}),e({...r,headers:n},new A(t,s,{onRequestStart(){},onRequestUpgrade(){},onResponseStart(){},onResponseData(){},onResponseEnd(){},onResponseError(){}}))})),!0;let g=!1;const d=c.cacheControlDirectives["stale-if-error"]??o?.["stale-if-error"];d&&(g=l<c.staleAt+1e3*d);let u={...r.headers,"if-modified-since":new Date(c.cachedAt).toUTCString()};return c.etag&&(u["if-none-match"]=c.etag),c.vary&&(u={...u,...c.vary}),e({...r,headers:u},new a(((e,t)=>{e?I(n,r,c,h,t,!0):i.isStream(c.body)&&c.body.on("error",(()=>{})).destroy()}),new A(t,s,n),g))}i.isStream(r.body)&&r.body.on("error",(()=>{})).destroy(),I(n,r,c,h,null,!1)}e.exports=(e={})=>{const{store:t=new o,methods:s=["GET"],cacheByDefault:n,type:r="shared"}=e;if("object"!=typeof e||null===e)throw new TypeError("expected type of opts to be an Object, got "+(null===e?"null":typeof e));if(c(t,"opts.store"),l(s,"opts.methods"),"undefined"!=typeof n&&"number"!=typeof n)throw new TypeError("expected opts.cacheByDefault to be number or undefined, got "+typeof n);if("undefined"!=typeof r&&"shared"!==r&&"private"!==r)throw new TypeError("expected opts.type to be shared, private, or undefined, got "+typeof r);const A={store:t,methods:s,cacheByDefault:n,type:r},a=i.safeHTTPMethods.filter((e=>!1===s.includes(e)));return e=>(s,n)=>{if(!s.origin||a.includes(s.method))return e(s,n);s={...s,headers:g(s)};const r=s.headers?.["cache-control"]?d(s.headers["cache-control"]):void 0;if(r?.["no-store"])return e(s,n);const i=h(s),o=t.get(i);return o&&"function"==typeof o.then?o.then((t=>{E(e,A,i,n,s,r,t)})):E(e,A,i,n,s,r,o),!0}}},4951:(e,t,s)=>{"use strict";const{createInflate:n,createGunzip:r,createBrotliDecompress:i,createZstdDecompress:A}=s(8522),{pipeline:o}=s(7075),a=s(6917),c={gzip:r,"x-gzip":r,br:i,deflate:n,compress:n,"x-compress":n,...A?{zstd:A}:{}},l=[204,304];let h=!1;class g extends a{#z=[];#X;#j;#Z;constructor(e,{skipStatusCodes:t=l,skipErrorResponses:s=!0}={}){super(e),this.#j=t,this.#Z=s}#K(e,t){return!e||t<200||(!!this.#j.includes(t)||!!(this.#Z&&t>=400))}#ee(e){const t=e.split(","),s=[];for(let e=t.length-1;e>=0;e--){const n=t[e].trim();if(n){if(!c[n])return s.length=0,s;s.push(c[n]())}}return s}#te(e,t){e.on("readable",(()=>{let s;for(;null!==(s=e.read());){if(!1===super.onResponseData(t,s))break}})),e.on("error",(e=>{super.onResponseError(t,e)}))}#se(e){const t=this.#z[0];this.#te(t,e),t.on("end",(()=>{super.onResponseEnd(e,{})}))}#ne(e){const t=this.#z[this.#z.length-1];this.#te(t,e),this.#X=o(this.#z,(t=>{t?super.onResponseError(e,t):super.onResponseEnd(e,{})}))}#re(){this.#z.length=0,this.#X=null}onResponseStart(e,t,s,n){const r=s["content-encoding"];if(this.#K(r,t))return super.onResponseStart(e,t,s,n);const i=this.#ee(r.toLowerCase());if(0===i.length)return this.#re(),super.onResponseStart(e,t,s,n);this.#z=i;const{"content-encoding":A,"content-length":o,...a}=s;1===this.#z.length?this.#se(e):this.#ne(e),super.onResponseStart(e,t,a,n)}onResponseData(e,t){this.#z.length>0?this.#z[0].write(t):super.onResponseData(e,t)}onResponseEnd(e,t){if(this.#z.length>0)return this.#z[0].end(),void this.#re();super.onResponseEnd(e,t)}onResponseError(e,t){if(this.#z.length>0){for(const e of this.#z)e.destroy(t);this.#re()}super.onResponseError(e,t)}}e.exports=function(e={}){return h||(process.emitWarning("DecompressInterceptor is experimental and subject to change","ExperimentalWarning"),h=!0),t=>(s,n)=>{const r=new g(n,e);return t(s,r)}}},6677:(e,t,s)=>{"use strict";const{isIP:n}=s(7030),{lookup:r}=s(610),i=s(6917),{InvalidArgumentError:A,InformationalError:o}=s(4465),a=Math.pow(2,31)-1;class c{#ie=0;#Ae=0;#oe=new Map;dualStack=!0;affinity=null;lookup=null;pick=null;constructor(e){this.#ie=e.maxTTL,this.#Ae=e.maxItems,this.dualStack=e.dualStack,this.affinity=e.affinity,this.lookup=e.lookup??this.#ae,this.pick=e.pick??this.#ce}get full(){return this.#oe.size===this.#Ae}runLookup(e,t,s){const n=this.#oe.get(e.hostname);if(null==n&&this.full)return void s(null,e);const r={affinity:this.affinity,dualStack:this.dualStack,lookup:this.lookup,pick:this.pick,...t.dns,maxTTL:this.#ie,maxItems:this.#Ae};if(null==n)this.lookup(e,r,((t,n)=>{if(t||null==n||0===n.length)return void s(t??new o("No DNS entries found"));this.setRecords(e,n);const i=this.#oe.get(e.hostname),A=this.pick(e,i,r.affinity);let a;a="number"==typeof A.port?`:${A.port}`:""!==e.port?`:${e.port}`:"",s(null,new URL(`${e.protocol}//${6===A.family?`[${A.address}]`:A.address}${a}`))}));else{const i=this.pick(e,n,r.affinity);if(null==i)return this.#oe.delete(e.hostname),void this.runLookup(e,t,s);let A;A="number"==typeof i.port?`:${i.port}`:""!==e.port?`:${e.port}`:"",s(null,new URL(`${e.protocol}//${6===i.family?`[${i.address}]`:i.address}${A}`))}}#ae(e,t,s){r(e.hostname,{all:!0,family:!1===this.dualStack?this.affinity:0,order:"ipv4first"},((e,t)=>{if(e)return s(e);const n=new Map;for(const e of t)n.set(`${e.address}:${e.family}`,e);s(null,n.values())}))}#ce(e,t,s){let n=null;const{records:r,offset:i}=t;let A;if(this.dualStack?(null==s&&(null==i||i===a?(t.offset=0,s=4):(t.offset++,s=1&~t.offset?4:6)),A=null!=r[s]&&r[s].ips.length>0?r[s]:r[4===s?6:4]):A=r[s],null==A||0===A.ips.length)return n;null==A.offset||A.offset===a?A.offset=0:A.offset++;const o=A.offset%A.ips.length;return n=A.ips[o]??null,null==n?n:Date.now()-n.timestamp>n.ttl?(A.ips.splice(o,1),this.pick(e,t,s)):n}pickFamily(e,t){const s=this.#oe.get(e.hostname)?.records;if(!s)return null;const n=s[t];if(!n)return null;null==n.offset||n.offset===a?n.offset=0:n.offset++;const r=n.offset%n.ips.length,i=n.ips[r]??null;return null==i||Date.now()-i.timestamp>i.ttl&&n.ips.splice(r,1),i}setRecords(e,t){const s=Date.now(),n={records:{4:null,6:null}};for(const e of t){e.timestamp=s,"number"==typeof e.ttl?e.ttl=Math.min(e.ttl,this.#ie):e.ttl=this.#ie;const t=n.records[e.family]??{ips:[]};t.ips.push(e),n.records[e.family]=t}this.#oe.set(e.hostname,n)}deleteRecords(e){this.#oe.delete(e.hostname)}getHandler(e,t){return new l(this,e,t)}}class l extends i{#le=null;#Q=null;#he=null;#ge=null;#q=null;#de=null;#ue=!0;constructor(e,{origin:t,handler:s,dispatch:n,newOrigin:r},i){super(s),this.#ge=t,this.#de=r,this.#Q={...i},this.#le=e,this.#he=n}onResponseError(e,t){switch(t.code){case"ETIMEDOUT":case"ECONNREFUSED":if(this.#le.dualStack){if(!this.#ue)return void super.onResponseError(e,t);this.#ue=!1;const s="["===this.#de.hostname[0]?4:6,n=this.#le.pickFamily(this.#ge,s);if(null==n)return void super.onResponseError(e,t);let r;r="number"==typeof n.port?`:${n.port}`:""!==this.#ge.port?`:${this.#ge.port}`:"";const i={...this.#Q,origin:`${this.#ge.protocol}//${6===n.family?`[${n.address}]`:n.address}${r}`};return void this.#he(i,this)}super.onResponseError(e,t);break;case"ENOTFOUND":this.#le.deleteRecords(this.#ge),super.onResponseError(e,t);break;default:super.onResponseError(e,t)}}}e.exports=e=>{if(null!=e?.maxTTL&&("number"!=typeof e?.maxTTL||e?.maxTTL<0))throw new A("Invalid maxTTL. Must be a positive number");if(null!=e?.maxItems&&("number"!=typeof e?.maxItems||e?.maxItems<1))throw new A("Invalid maxItems. Must be a positive number and greater than zero");if(null!=e?.affinity&&4!==e?.affinity&&6!==e?.affinity)throw new A("Invalid affinity. Must be either 4 or 6");if(null!=e?.dualStack&&"boolean"!=typeof e?.dualStack)throw new A("Invalid dualStack. Must be a boolean");if(null!=e?.lookup&&"function"!=typeof e?.lookup)throw new A("Invalid lookup. Must be a function");if(null!=e?.pick&&"function"!=typeof e?.pick)throw new A("Invalid pick. Must be a function");const t=e?.dualStack??!0;let s;s=t?e?.affinity??null:e?.affinity??4;const r=new c({maxTTL:e?.maxTTL??1e4,lookup:e?.lookup??null,pick:e?.pick??null,dualStack:t,affinity:s,maxItems:e?.maxItems??1/0});return e=>function(t,s){const i=t.origin.constructor===URL?t.origin:new URL(t.origin);return 0!==n(i.hostname)?e(t,s):(r.runLookup(i,t,((n,A)=>{if(n)return s.onResponseError(null,n);const o={...t,servername:i.hostname,origin:A.origin,headers:{host:i.host,...t.headers}};e(o,r.getHandler({origin:i,dispatch:e,handler:s,newOrigin:A},t))})),!0)}}},3562:(e,t,s)=>{"use strict";const{InvalidArgumentError:n,RequestAbortedError:r}=s(4465),i=s(6917);class A extends i{#t=1048576;#Ie=!1;#n=0;#q=null;aborted=!1;reason=!1;constructor({maxSize:e,signal:t},s){if(null!=e&&(!Number.isFinite(e)||e<1))throw new n("maxSize must be a number greater than 0");super(s),this.#t=e??this.#t}#$(e){this.aborted=!0,this.reason=e}onRequestStart(e,t){return e.abort=this.#$.bind(this),this.#q=e,super.onRequestStart(e,t)}onResponseStart(e,t,s,n){const i=s["content-length"];if(null!=i&&i>this.#t)throw new r(`Response size (${i}) larger than maxSize (${this.#t})`);return!0===this.aborted||super.onResponseStart(e,t,s,n)}onResponseError(e,t){this.#Ie||(t=this.#q?.reason??t,super.onResponseError(e,t))}onResponseData(e,t){return this.#n=this.#n+t.length,this.#n>=this.#t&&(this.#Ie=!0,!0===this.aborted?super.onResponseError(e,this.reason):super.onResponseEnd(e,{})),!0}onResponseEnd(e,t){this.#Ie||(!0!==this.#q.aborted?super.onResponseEnd(e,t):super.onResponseError(e,this.reason))}}e.exports=function({maxSize:e}={maxSize:1048576}){return t=>function(s,n){const{dumpMaxSize:r=e}=s,i=new A({maxSize:r,signal:s.signal},n);return t(s,i)}}},5132:(e,t,s)=>{"use strict";const n=s(8064);e.exports=function({maxRedirections:e}={}){return t=>function(s,r){const{maxRedirections:i=e,...A}=s;if(null==i||0===i)return t(s,r);const o={...A},a=new n(t,i,o,r);return t(o,a)}}},2936:(e,t,s)=>{"use strict";const n=s(6917),{ResponseError:r}=s(4465);class i extends n{#Ee;#pe;#Ce;#Be;#Qe;constructor(e,{handler:t}){super(t)}#fe(e){return 0===(this.#pe??"").indexOf(e)}onRequestStart(e,t){return this.#Ee=0,this.#pe=null,this.#Ce=null,this.#Be=null,this.#Qe="",super.onRequestStart(e,t)}onResponseStart(e,t,s,n){if(this.#Ee=t,this.#Be=s,this.#pe=s["content-type"],this.#Ee<400)return super.onResponseStart(e,t,s,n);(this.#fe("application/json")||this.#fe("text/plain"))&&(this.#Ce=new TextDecoder("utf-8"))}onResponseData(e,t){if(this.#Ee<400)return super.onResponseData(e,t);this.#Qe+=this.#Ce?.decode(t,{stream:!0})??""}onResponseEnd(e,t){if(this.#Ee>=400){if(this.#Qe+=this.#Ce?.decode(void 0,{stream:!1})??"",this.#fe("application/json"))try{this.#Qe=JSON.parse(this.#Qe)}catch{}let t;const s=Error.stackTraceLimit;Error.stackTraceLimit=0;try{t=new r("Response Error",this.#Ee,{body:this.#Qe,headers:this.#Be})}finally{Error.stackTraceLimit=s}super.onResponseError(e,t)}else super.onResponseEnd(e,t)}onResponseError(e,t){super.onResponseError(e,t)}}e.exports=()=>e=>function(t,s){return e(t,new i(t,{handler:s}))}},532:(e,t,s)=>{"use strict";const n=s(6294);e.exports=e=>t=>function(s,r){return t(s,new n({...s,retryOptions:{...e,...s.retryOptions}},{handler:r,dispatch:t}))}},4178:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SPECIAL_HEADERS=t.MINOR=t.MAJOR=t.HTAB_SP_VCHAR_OBS_TEXT=t.QUOTED_STRING=t.CONNECTION_TOKEN_CHARS=t.HEADER_CHARS=t.TOKEN=t.HEX=t.URL_CHAR=t.USERINFO_CHARS=t.MARK=t.ALPHANUM=t.NUM=t.HEX_MAP=t.NUM_MAP=t.ALPHA=t.STATUSES_HTTP=t.H_METHOD_MAP=t.METHOD_MAP=t.METHODS_RTSP=t.METHODS_ICE=t.METHODS_HTTP=t.HEADER_STATE=t.FINISH=t.STATUSES=t.METHODS=t.LENIENT_FLAGS=t.FLAGS=t.TYPE=t.ERROR=void 0;const n=s(3530);t.ERROR={OK:0,INTERNAL:1,STRICT:2,CR_EXPECTED:25,LF_EXPECTED:3,UNEXPECTED_CONTENT_LENGTH:4,UNEXPECTED_SPACE:30,CLOSED_CONNECTION:5,INVALID_METHOD:6,INVALID_URL:7,INVALID_CONSTANT:8,INVALID_VERSION:9,INVALID_HEADER_TOKEN:10,INVALID_CONTENT_LENGTH:11,INVALID_CHUNK_SIZE:12,INVALID_STATUS:13,INVALID_EOF_STATE:14,INVALID_TRANSFER_ENCODING:15,CB_MESSAGE_BEGIN:16,CB_HEADERS_COMPLETE:17,CB_MESSAGE_COMPLETE:18,CB_CHUNK_HEADER:19,CB_CHUNK_COMPLETE:20,PAUSED:21,PAUSED_UPGRADE:22,PAUSED_H2_UPGRADE:23,USER:24,CB_URL_COMPLETE:26,CB_STATUS_COMPLETE:27,CB_METHOD_COMPLETE:32,CB_VERSION_COMPLETE:33,CB_HEADER_FIELD_COMPLETE:28,CB_HEADER_VALUE_COMPLETE:29,CB_CHUNK_EXTENSION_NAME_COMPLETE:34,CB_CHUNK_EXTENSION_VALUE_COMPLETE:35,CB_RESET:31,CB_PROTOCOL_COMPLETE:38},t.TYPE={BOTH:0,REQUEST:1,RESPONSE:2},t.FLAGS={CONNECTION_KEEP_ALIVE:1,CONNECTION_CLOSE:2,CONNECTION_UPGRADE:4,CHUNKED:8,UPGRADE:16,CONTENT_LENGTH:32,SKIPBODY:64,TRAILING:128,TRANSFER_ENCODING:512},t.LENIENT_FLAGS={HEADERS:1,CHUNKED_LENGTH:2,KEEP_ALIVE:4,TRANSFER_ENCODING:8,VERSION:16,DATA_AFTER_CLOSE:32,OPTIONAL_LF_AFTER_CR:64,OPTIONAL_CRLF_AFTER_CHUNK:128,OPTIONAL_CR_BEFORE_LF:256,SPACES_AFTER_CHUNK_SIZE:512},t.METHODS={DELETE:0,GET:1,HEAD:2,POST:3,PUT:4,CONNECT:5,OPTIONS:6,TRACE:7,COPY:8,LOCK:9,MKCOL:10,MOVE:11,PROPFIND:12,PROPPATCH:13,SEARCH:14,UNLOCK:15,BIND:16,REBIND:17,UNBIND:18,ACL:19,REPORT:20,MKACTIVITY:21,CHECKOUT:22,MERGE:23,"M-SEARCH":24,NOTIFY:25,SUBSCRIBE:26,UNSUBSCRIBE:27,PATCH:28,PURGE:29,MKCALENDAR:30,LINK:31,UNLINK:32,SOURCE:33,PRI:34,DESCRIBE:35,ANNOUNCE:36,SETUP:37,PLAY:38,PAUSE:39,TEARDOWN:40,GET_PARAMETER:41,SET_PARAMETER:42,REDIRECT:43,RECORD:44,FLUSH:45,QUERY:46},t.STATUSES={CONTINUE:100,SWITCHING_PROTOCOLS:101,PROCESSING:102,EARLY_HINTS:103,RESPONSE_IS_STALE:110,REVALIDATION_FAILED:111,DISCONNECTED_OPERATION:112,HEURISTIC_EXPIRATION:113,MISCELLANEOUS_WARNING:199,OK:200,CREATED:201,ACCEPTED:202,NON_AUTHORITATIVE_INFORMATION:203,NO_CONTENT:204,RESET_CONTENT:205,PARTIAL_CONTENT:206,MULTI_STATUS:207,ALREADY_REPORTED:208,TRANSFORMATION_APPLIED:214,IM_USED:226,MISCELLANEOUS_PERSISTENT_WARNING:299,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,FOUND:302,SEE_OTHER:303,NOT_MODIFIED:304,USE_PROXY:305,SWITCH_PROXY:306,TEMPORARY_REDIRECT:307,PERMANENT_REDIRECT:308,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,IM_A_TEAPOT:418,PAGE_EXPIRED:419,ENHANCE_YOUR_CALM:420,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,TOO_EARLY:425,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,REQUEST_HEADER_FIELDS_TOO_LARGE_UNOFFICIAL:430,REQUEST_HEADER_FIELDS_TOO_LARGE:431,LOGIN_TIMEOUT:440,NO_RESPONSE:444,RETRY_WITH:449,BLOCKED_BY_PARENTAL_CONTROL:450,UNAVAILABLE_FOR_LEGAL_REASONS:451,CLIENT_CLOSED_LOAD_BALANCED_REQUEST:460,INVALID_X_FORWARDED_FOR:463,REQUEST_HEADER_TOO_LARGE:494,SSL_CERTIFICATE_ERROR:495,SSL_CERTIFICATE_REQUIRED:496,HTTP_REQUEST_SENT_TO_HTTPS_PORT:497,INVALID_TOKEN:498,CLIENT_CLOSED_REQUEST:499,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,VARIANT_ALSO_NEGOTIATES:506,INSUFFICIENT_STORAGE:507,LOOP_DETECTED:508,BANDWIDTH_LIMIT_EXCEEDED:509,NOT_EXTENDED:510,NETWORK_AUTHENTICATION_REQUIRED:511,WEB_SERVER_UNKNOWN_ERROR:520,WEB_SERVER_IS_DOWN:521,CONNECTION_TIMEOUT:522,ORIGIN_IS_UNREACHABLE:523,TIMEOUT_OCCURED:524,SSL_HANDSHAKE_FAILED:525,INVALID_SSL_CERTIFICATE:526,RAILGUN_ERROR:527,SITE_IS_OVERLOADED:529,SITE_IS_FROZEN:530,IDENTITY_PROVIDER_AUTHENTICATION_ERROR:561,NETWORK_READ_TIMEOUT:598,NETWORK_CONNECT_TIMEOUT:599},t.FINISH={SAFE:0,SAFE_WITH_CB:1,UNSAFE:2},t.HEADER_STATE={GENERAL:0,CONNECTION:1,CONTENT_LENGTH:2,TRANSFER_ENCODING:3,UPGRADE:4,CONNECTION_KEEP_ALIVE:5,CONNECTION_CLOSE:6,CONNECTION_UPGRADE:7,TRANSFER_ENCODING_CHUNKED:8},t.METHODS_HTTP=[t.METHODS.DELETE,t.METHODS.GET,t.METHODS.HEAD,t.METHODS.POST,t.METHODS.PUT,t.METHODS.CONNECT,t.METHODS.OPTIONS,t.METHODS.TRACE,t.METHODS.COPY,t.METHODS.LOCK,t.METHODS.MKCOL,t.METHODS.MOVE,t.METHODS.PROPFIND,t.METHODS.PROPPATCH,t.METHODS.SEARCH,t.METHODS.UNLOCK,t.METHODS.BIND,t.METHODS.REBIND,t.METHODS.UNBIND,t.METHODS.ACL,t.METHODS.REPORT,t.METHODS.MKACTIVITY,t.METHODS.CHECKOUT,t.METHODS.MERGE,t.METHODS["M-SEARCH"],t.METHODS.NOTIFY,t.METHODS.SUBSCRIBE,t.METHODS.UNSUBSCRIBE,t.METHODS.PATCH,t.METHODS.PURGE,t.METHODS.MKCALENDAR,t.METHODS.LINK,t.METHODS.UNLINK,t.METHODS.PRI,t.METHODS.SOURCE,t.METHODS.QUERY],t.METHODS_ICE=[t.METHODS.SOURCE],t.METHODS_RTSP=[t.METHODS.OPTIONS,t.METHODS.DESCRIBE,t.METHODS.ANNOUNCE,t.METHODS.SETUP,t.METHODS.PLAY,t.METHODS.PAUSE,t.METHODS.TEARDOWN,t.METHODS.GET_PARAMETER,t.METHODS.SET_PARAMETER,t.METHODS.REDIRECT,t.METHODS.RECORD,t.METHODS.FLUSH,t.METHODS.GET,t.METHODS.POST],t.METHOD_MAP=(0,n.enumToMap)(t.METHODS),t.H_METHOD_MAP=Object.fromEntries(Object.entries(t.METHODS).filter((([e])=>e.startsWith("H")))),t.STATUSES_HTTP=[t.STATUSES.CONTINUE,t.STATUSES.SWITCHING_PROTOCOLS,t.STATUSES.PROCESSING,t.STATUSES.EARLY_HINTS,t.STATUSES.RESPONSE_IS_STALE,t.STATUSES.REVALIDATION_FAILED,t.STATUSES.DISCONNECTED_OPERATION,t.STATUSES.HEURISTIC_EXPIRATION,t.STATUSES.MISCELLANEOUS_WARNING,t.STATUSES.OK,t.STATUSES.CREATED,t.STATUSES.ACCEPTED,t.STATUSES.NON_AUTHORITATIVE_INFORMATION,t.STATUSES.NO_CONTENT,t.STATUSES.RESET_CONTENT,t.STATUSES.PARTIAL_CONTENT,t.STATUSES.MULTI_STATUS,t.STATUSES.ALREADY_REPORTED,t.STATUSES.TRANSFORMATION_APPLIED,t.STATUSES.IM_USED,t.STATUSES.MISCELLANEOUS_PERSISTENT_WARNING,t.STATUSES.MULTIPLE_CHOICES,t.STATUSES.MOVED_PERMANENTLY,t.STATUSES.FOUND,t.STATUSES.SEE_OTHER,t.STATUSES.NOT_MODIFIED,t.STATUSES.USE_PROXY,t.STATUSES.SWITCH_PROXY,t.STATUSES.TEMPORARY_REDIRECT,t.STATUSES.PERMANENT_REDIRECT,t.STATUSES.BAD_REQUEST,t.STATUSES.UNAUTHORIZED,t.STATUSES.PAYMENT_REQUIRED,t.STATUSES.FORBIDDEN,t.STATUSES.NOT_FOUND,t.STATUSES.METHOD_NOT_ALLOWED,t.STATUSES.NOT_ACCEPTABLE,t.STATUSES.PROXY_AUTHENTICATION_REQUIRED,t.STATUSES.REQUEST_TIMEOUT,t.STATUSES.CONFLICT,t.STATUSES.GONE,t.STATUSES.LENGTH_REQUIRED,t.STATUSES.PRECONDITION_FAILED,t.STATUSES.PAYLOAD_TOO_LARGE,t.STATUSES.URI_TOO_LONG,t.STATUSES.UNSUPPORTED_MEDIA_TYPE,t.STATUSES.RANGE_NOT_SATISFIABLE,t.STATUSES.EXPECTATION_FAILED,t.STATUSES.IM_A_TEAPOT,t.STATUSES.PAGE_EXPIRED,t.STATUSES.ENHANCE_YOUR_CALM,t.STATUSES.MISDIRECTED_REQUEST,t.STATUSES.UNPROCESSABLE_ENTITY,t.STATUSES.LOCKED,t.STATUSES.FAILED_DEPENDENCY,t.STATUSES.TOO_EARLY,t.STATUSES.UPGRADE_REQUIRED,t.STATUSES.PRECONDITION_REQUIRED,t.STATUSES.TOO_MANY_REQUESTS,t.STATUSES.REQUEST_HEADER_FIELDS_TOO_LARGE_UNOFFICIAL,t.STATUSES.REQUEST_HEADER_FIELDS_TOO_LARGE,t.STATUSES.LOGIN_TIMEOUT,t.STATUSES.NO_RESPONSE,t.STATUSES.RETRY_WITH,t.STATUSES.BLOCKED_BY_PARENTAL_CONTROL,t.STATUSES.UNAVAILABLE_FOR_LEGAL_REASONS,t.STATUSES.CLIENT_CLOSED_LOAD_BALANCED_REQUEST,t.STATUSES.INVALID_X_FORWARDED_FOR,t.STATUSES.REQUEST_HEADER_TOO_LARGE,t.STATUSES.SSL_CERTIFICATE_ERROR,t.STATUSES.SSL_CERTIFICATE_REQUIRED,t.STATUSES.HTTP_REQUEST_SENT_TO_HTTPS_PORT,t.STATUSES.INVALID_TOKEN,t.STATUSES.CLIENT_CLOSED_REQUEST,t.STATUSES.INTERNAL_SERVER_ERROR,t.STATUSES.NOT_IMPLEMENTED,t.STATUSES.BAD_GATEWAY,t.STATUSES.SERVICE_UNAVAILABLE,t.STATUSES.GATEWAY_TIMEOUT,t.STATUSES.HTTP_VERSION_NOT_SUPPORTED,t.STATUSES.VARIANT_ALSO_NEGOTIATES,t.STATUSES.INSUFFICIENT_STORAGE,t.STATUSES.LOOP_DETECTED,t.STATUSES.BANDWIDTH_LIMIT_EXCEEDED,t.STATUSES.NOT_EXTENDED,t.STATUSES.NETWORK_AUTHENTICATION_REQUIRED,t.STATUSES.WEB_SERVER_UNKNOWN_ERROR,t.STATUSES.WEB_SERVER_IS_DOWN,t.STATUSES.CONNECTION_TIMEOUT,t.STATUSES.ORIGIN_IS_UNREACHABLE,t.STATUSES.TIMEOUT_OCCURED,t.STATUSES.SSL_HANDSHAKE_FAILED,t.STATUSES.INVALID_SSL_CERTIFICATE,t.STATUSES.RAILGUN_ERROR,t.STATUSES.SITE_IS_OVERLOADED,t.STATUSES.SITE_IS_FROZEN,t.STATUSES.IDENTITY_PROVIDER_AUTHENTICATION_ERROR,t.STATUSES.NETWORK_READ_TIMEOUT,t.STATUSES.NETWORK_CONNECT_TIMEOUT],t.ALPHA=[];for(let e="A".charCodeAt(0);e<="Z".charCodeAt(0);e++)t.ALPHA.push(String.fromCharCode(e)),t.ALPHA.push(String.fromCharCode(e+32));t.NUM_MAP={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9},t.HEX_MAP={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},t.NUM=["0","1","2","3","4","5","6","7","8","9"],t.ALPHANUM=t.ALPHA.concat(t.NUM),t.MARK=["-","_",".","!","~","*","'","(",")"],t.USERINFO_CHARS=t.ALPHANUM.concat(t.MARK).concat(["%",";",":","&","=","+","$",","]),t.URL_CHAR=["!",'"',"$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","@","[","\\","]","^","_","`","{","|","}","~"].concat(t.ALPHANUM),t.HEX=t.NUM.concat(["a","b","c","d","e","f","A","B","C","D","E","F"]),t.TOKEN=["!","#","$","%","&","'","*","+","-",".","^","_","`","|","~"].concat(t.ALPHANUM),t.HEADER_CHARS=["\t"];for(let e=32;e<=255;e++)127!==e&&t.HEADER_CHARS.push(e);t.CONNECTION_TOKEN_CHARS=t.HEADER_CHARS.filter((e=>44!==e)),t.QUOTED_STRING=["\t"," "];for(let e=33;e<=255;e++)34!==e&&92!==e&&t.QUOTED_STRING.push(e);t.HTAB_SP_VCHAR_OBS_TEXT=["\t"," "];for(let e=33;e<=126;e++)t.HTAB_SP_VCHAR_OBS_TEXT.push(e);for(let e=128;e<=255;e++)t.HTAB_SP_VCHAR_OBS_TEXT.push(e);t.MAJOR=t.NUM_MAP,t.MINOR=t.MAJOR,t.SPECIAL_HEADERS={connection:t.HEADER_STATE.CONNECTION,"content-length":t.HEADER_STATE.CONTENT_LENGTH,"proxy-connection":t.HEADER_STATE.CONNECTION,"transfer-encoding":t.HEADER_STATE.TRANSFER_ENCODING,upgrade:t.HEADER_STATE.UPGRADE},t.default={ERROR:t.ERROR,TYPE:t.TYPE,FLAGS:t.FLAGS,LENIENT_FLAGS:t.LENIENT_FLAGS,METHODS:t.METHODS,STATUSES:t.STATUSES,FINISH:t.FINISH,HEADER_STATE:t.HEADER_STATE,ALPHA:t.ALPHA,NUM_MAP:t.NUM_MAP,HEX_MAP:t.HEX_MAP,NUM:t.NUM,ALPHANUM:t.ALPHANUM,MARK:t.MARK,USERINFO_CHARS:t.USERINFO_CHARS,URL_CHAR:t.URL_CHAR,HEX:t.HEX,TOKEN:t.TOKEN,HEADER_CHARS:t.HEADER_CHARS,CONNECTION_TOKEN_CHARS:t.CONNECTION_TOKEN_CHARS,QUOTED_STRING:t.QUOTED_STRING,HTAB_SP_VCHAR_OBS_TEXT:t.HTAB_SP_VCHAR_OBS_TEXT,MAJOR:t.MAJOR,MINOR:t.MINOR,SPECIAL_HEADERS:t.SPECIAL_HEADERS,METHODS_HTTP:t.METHODS_HTTP,METHODS_ICE:t.METHODS_ICE,METHODS_RTSP:t.METHODS_RTSP,METHOD_MAP:t.METHOD_MAP,H_METHOD_MAP:t.H_METHOD_MAP,STATUSES_HTTP:t.STATUSES_HTTP}},4744:(e,t,s)=>{"use strict";e=s.nmd(e);const{Buffer:n}=s(4573);let r;Object.defineProperty(e,"exports",{get:()=>r||(r=n.from("AGFzbQEAAAABJwdgAX8Bf2ADf39/AX9gAn9/AGABfwBgBH9/f38Bf2AAAGADf39/AALLAQgDZW52GHdhc21fb25faGVhZGVyc19jb21wbGV0ZQAEA2VudhV3YXNtX29uX21lc3NhZ2VfYmVnaW4AAANlbnYLd2FzbV9vbl91cmwAAQNlbnYOd2FzbV9vbl9zdGF0dXMAAQNlbnYUd2FzbV9vbl9oZWFkZXJfZmllbGQAAQNlbnYUd2FzbV9vbl9oZWFkZXJfdmFsdWUAAQNlbnYMd2FzbV9vbl9ib2R5AAEDZW52GHdhc21fb25fbWVzc2FnZV9jb21wbGV0ZQAAAzU0BQYAAAMAAAAAAAADAQMAAwMDAAACAAAAAAICAgICAgICAgIBAQEBAQEBAQEBAwAAAwAAAAQFAXABExMFAwEAAgYIAX8BQcDZBAsHxQcoBm1lbW9yeQIAC19pbml0aWFsaXplAAgZX19pbmRpcmVjdF9mdW5jdGlvbl90YWJsZQEAC2xsaHR0cF9pbml0AAkYbGxodHRwX3Nob3VsZF9rZWVwX2FsaXZlADcMbGxodHRwX2FsbG9jAAsGbWFsbG9jADkLbGxodHRwX2ZyZWUADARmcmVlAAwPbGxodHRwX2dldF90eXBlAA0VbGxodHRwX2dldF9odHRwX21ham9yAA4VbGxodHRwX2dldF9odHRwX21pbm9yAA8RbGxodHRwX2dldF9tZXRob2QAEBZsbGh0dHBfZ2V0X3N0YXR1c19jb2RlABESbGxodHRwX2dldF91cGdyYWRlABIMbGxodHRwX3Jlc2V0ABMObGxodHRwX2V4ZWN1dGUAFBRsbGh0dHBfc2V0dGluZ3NfaW5pdAAVDWxsaHR0c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DQAgAEEQaiEDIAAoAhAiAg0ACyAHQQA2AgAMAgsgBSAAQX5xNgIEIAEgBGogBDYCACABIARBAXI2AgQMAwtBACEACyAGRQ0AAkAgBSgCHCICQQJ0QfTXAGoiAygCACAFRgRAIAMgADYCACAADQFByNUAQcjVACgCAEF+IAJ3cTYCAAwCCyAGQRBBFCAGKAIQIAVGG2ogADYCACAARQ0BCyAAIAY2AhggBSgCECICBEAgACACNgIQIAIgADYCGAsgBUEUaigCACICRQ0AIABBFGogAjYCACACIAA2AhgLIAEgBGogBDYCACABIARBAXI2AgQgAUHY1QAoAgBHDQBBzNUAIAQ2AgAMAQsgBEH/AU0EQCAEQXhxQezVAGohAAJ/QcTVACgCACICQQEgBEEDdnQiA3FFBEBBxNUAIAIgA3I2AgAgAAwBCyAAKAIICyICIAE2AgwgACABNgIIIAEgADYCDCABIAI2AggMAQtBHyECIARB////B00EQCAEQSYgBEEIdmciAGt2QQFxIABBAXRrQT5qIQILIAEgAjYCHCABQgA3AhAgAkECdEH01wBqIQACQEHI1QAoAgAiA0EBIAJ0IgdxRQRAIAAgATYCAEHI1QAgAyAHcjYCACABIAA2AhggASABNgIIIAEgATYCDAwBCyAEQRkgAkEBdmtBACACQR9HG3QhAiAAKAIAIQACQANAIAAiAygCBEF4cSAERg0BIAJBHXYhACACQQF0IQIgAyAAQQRxakEQaiIHKAIAIgANAAsgByABNgIAIAEgAzYCGCABIAE2AgwgASABNgIIDAELIAMoAggiACABNgIMIAMgATYCCCABQQA2AhggASADNgIMIAEgADYCCAtB5NUAQeTVACgCAEEBayIAQX8gABs2AgALCwcAIAAtACgLBwAgAC0AKgsHACAALQArCwcAIAAtACkLBwAgAC8BNAsHACAALQAwC0ABBH8gACgCGCEBIAAvAS4hAiAALQAoIQMgACgCOCEEIAAQOCAAIAQ2AjggACADOgAoIAAgAjsBLiAAIAE2AhgL5YUCAgd/A34gASACaiEEAkAgACIDKAIMIgANACADKAIEBEAgAyABNgIECyMAQRBrIgkkAAJAAkACQ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QAJAAkACQAJAAkACQAJAAkACQCADAn8CQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAn8CQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAn8CQAJAAkACQAJAAkACQAJ/AkACQAJAAn8CQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAIAMCfwJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACfwJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAgAg7jAQABAgMEBQYHCAkKCwwNDg8QERITFBUWFxgZGhscHR4fICEjJCUnKCmeA5sDmgORA4oDgwOAA/0C+wL4AvIC8QLvAu0C6ALnAuYC5QLkAtwC2wLaAtkC2ALXAtYC1QLPAs4CzALLAsoCyQLIAscCxgLEAsMCvgK8AroCuQK4ArcCtgK1ArQCswKyArECsAKuAq0CqQKoAqcCpgK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5syZs+bMGVYNASADIAtCCn4iCjcDICAKIACtQv8BgyILQn+FVg0BIAMgCiALfDcDICAEIAFBAWoiAUcNAAtBwAAhAgzuAgsgAygCBCEAIANBADYCBCADIAAgAUEBaiIBEDEiAA0XDOICC0HAACECDOwCCyABIARGBEBByQAhAgzsAgsCQANAAkAgAS0AAEEJaw4YAAKiAqICqQKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogIAogILIAQgAUEBaiIBRw0AC0HJACECDOwCCyABQQFqIQEgA0Evai0AAEEBcQ2lAiADQQA2AhwgAyABNgIUIANBlxA2AhAgA0EKNgIMQQAhAgzrAgsgASAERwRAA0AgAS0AAEEgRw0VIAQgAUEBaiIBRw0AC0H4ACECDOsCC0H4ACECDOoCCyADQQI6ACgMOAtBACECIANBADYCHCADQb8LNgIQIANBAjYCDCADIAFBAWo2AhQM6AILQQAhAgzOAgtBDSECDM0CC0ETIQIMzAILQRUhAgzLAgtBFiECDMoCC0EYIQIMyQILQRkhAgzIAgtBGiECDMcCC0EbIQIMxgILQRwhAgzFAgtBHSECDMQCC0EeIQIMwwILQR8hAgzCAgtBICECDMECC0EiIQIMwAILQSMhAgy/AgtBJSECDL4CC0HlACECDL0CCyADQT02AhwgAyABNgIUIAMgADYCDEEAIQIM1QILIANBGzYCHCADIAE2AhQgA0GkHDYCECADQRU2AgxBACECDNQCCyADQSA2AhwgAyABNgIUIANBmBo2AhAgA0EVNgIMQQAhAgzTAgsgA0ETNgIcIAMgATYCFCADQZgaNgIQIANBFTYCDEEAIQIM0gILIANBCzYCHCADIAE2AhQgA0GYGjYCECADQRU2AgxBACECDNECCyADQRA2AhwgAyABNgIUIANBmBo2AhAgA0EVNgIMQQAhAgzQAgsgA0EgNgIcIAMgATYCFCADQaQcNgIQIANBFTYCDEEAIQIMzwILIANBCzYCHCADIAE2AhQgA0GkHDYCECADQRU2AgxBACECDM4CCyADQQw2AhwgAyABNgIUIANBpBw2AhAgA0EVNgIMQQAhAgzNAgtBACECIANBADYCHCADIAE2AhQgA0HdDjYCECADQRI2AgwMzAILAkADQAJAIAEtAABBCmsOBAACAgACCyAEIAFBAWoiAUcNAAtB/QEhAgzMAgsCQAJAIAMtADZBAUcNAEEAIQACQCADKAI4IgJFDQAgAigCYCICRQ0AIAMgAhEAACEACyAARQ0AIABBFUcNASADQfwBNgIcIAMgATYCFCADQdwZNgIQIANBFTYCDEEAIQIMzQILQdwBIQIMswILIANBADYCHCADIAE2AhQgA0H5CzYCECADQR82AgxBACECDMsCCwJAAkAgAy0AKEEBaw4CBAEAC0HbASECDLICC0HUASECDLECCyADQQI6ADFBACEAAkAgAygCOCICRQ0AIAIoAgAiAkUNACADIAIRAAAhAAsgAEUEQEHdASECDLECCyAAQRVHBEAgA0EANgIcIAMgATYCFCADQbQMNgIQIANBEDYCDEEAIQIMygILIANB+wE2AhwgAyABNgIUIANBgRo2AhAgA0EVNgIMQQAhAgzJAgsgASAERgRAQfoBIQIMyQILIAEtAABByABGDQEgA0EBOgAoC0HAASECDK4CC0HaASECDK0CCyABIARHBEAgA0EMNgIIIAMgATYCBEHZASECDK0CC0H5ASECDMUCCyABIARGBEBB+AEhAgzFAgsgAS0AAEHIAEcNBCABQQFqIQFB2AEhAgyrAgsgASAERgRAQfcBIQIMxAILAkACQCABLQAAQcUAaw4QAAUFBQUFBQUFBQUFBQUFAQULIAFBAWohAUHWASECDKsCCyABQQFqIQFB1wEhAgyqAgtB9gEhAiABIARGDcICIAMoAgAiACAEIAFraiEFIAEgAGtBAmohBgJAA0AgAS0AACAAQbrVAGotAABHDQMgAEECRg0BIABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADMMCCyADKAIEIQAgA0IANwMAIAMgACAGQQFqIgEQLiIARQRAQeMBIQIMqgILIANB9QE2AhwgAyABNgIUIAMgADYCDEEAIQIMwgILQfQBIQIgASAERg3BAiADKAIAIgAgBCABa2ohBSABIABrQQFqIQYCQANAIAEtAAAgAEG41QBqLQAARw0CIABBAUYNASAAQQFqIQAgBC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AIAIoAjQiAkUNACADIAIRAAAhAAsCQCAABEAgAEEVRg0BIANBADYCHCADIAE2AhQgA0HqDTYCECADQSY2AgxBACECDLQCC0HOASECDJoCCyADQesBNgIcIAMgATYCFCADQYAbNgIQIANBFTYCDEEAIQIMsgILIAEgBEYEQEHrASECDLICCyABLQAAQS9GBEAgAUEBaiEBDAELIANBADYCHCADIAE2AhQgA0GyODYCECADQQg2AgxBACECDLECC0HNASECDJcCCyABIARHBEAgA0EONgIIIAMgATYCBEHMASECDJcCC0HqASECDK8CCyABIARGBEBB6QEhAgyvAgsgAS0AAEEwayIAQf8BcUEKSQRAIAMgADoAKiABQQFqIQFBywEhAgyWAgsgAygCBCEAIANBADYCBCADIAAgARAvIgBFDZcCIANB6AE2AhwgAyABNgIUIAMgADYCDEEAIQIMrgILIAEgBEYEQEHnASECDK4CCwJAIAEtAABBLkYEQCABQQFqIQEMAQsgAygCBCEAIANBADYCBCADIAAgARAvIgBFDZgCIANB5gE2AhwgAyABNgIUIAMgADYCDEEAIQIMrgILQcoBIQIMlAILIAEgBEYEQEHlASECDK0CC0EAIQBBASEFQQEhB0EAIQICQAJAAkACQAJAAn8CQAJAAkACQAJAAkACQCABLQAAQTBrDgoKCQABAgMEBQYICwtBAgwGC0EDDAULQQQMBAtBBQwDC0EGDAILQQcMAQtBCAshAkEAIQVBACEHDAILQQkhAkEBIQBBACEFQQAhBwwBC0EAIQVBASECCyADIAI6ACsgAUEBaiEBAkACQCADLQAuQRBxDQACQAJAAkAgAy0AKg4DAQACBAsgB0UNAwwCCyAADQEMAgsgBUUNAQsgAygCBCEAIANBADYCBCADIAAgARAvIgBFDQIgA0HiATYCHCADIAE2AhQgAyAANgIMQQAhAgyvAgsgAygCBCEAIANBADYCBCADIAAgARAvIgBFDZoCIANB4wE2AhwgAyABNgIUIAMgADYCDEEAIQIMrgILIAMoAgQhACADQQA2AgQgAyAAIAEQLyIARQ2YAiADQeQBNgIcIAMgATYCFCADIAA2AgwMrQILQckBIQIMkw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qDAULIAFBAWohAUHDASECDI8CCyABQQFqIQEgA0Evai0AAEEBcQ0IIANBADYCHCADIAE2AhQgA0GNCzYCECADQQ02AgxBACECDKcCCyADQQA2AhwgAyABNgIUIANBjQs2AhAgA0ENNgIMQQAhAgymAgsgASAERwRAIANBDzYCCCADIAE2AgRBASECDI0CC0HcASECDKUCCwJAAkADQAJAIAEtAABBCmsOBAIAAAMACyAEIAFBAWoiAUcNAAtB2wEhAgymAgsgAygCBCEAIANBADYCBCADIAAgARAtIgBFBEAgAUEBaiEBDAQLIANB2gE2AhwgAyAANgIMIAMgAUEBajYCFEEAIQIMpQILIAMoAgQhACADQQA2AgQgAyAAIAEQLSIADQEgAUEBagshAUHBASECDIoCCyADQdkBNgIcIAMgADYCDCADIAFBAWo2AhRBACECDKICC0HCASECDIgCCyADQS9qLQAAQQFxDQEgA0EANgIcIAMgATYCFCADQeQcNgIQIANBGTYCDEEAIQIMoAILIAEgBEYEQEHZASECDKACCwJAAkACQCABLQAAQQprDgQBAgIAAgsgAUEBaiEBDAILIAFBAWohAQwBCyADLQAuQcAAcUUNAQtBACEAAkAgAygCOCICRQ0AIAIoAjwiAkUNACADIAIRAAAhAAsgAEUNoAEgAEEVRgRAIANB2QA2AhwgAyABNgIUIANBtxo2AhAgA0EVNgIMQQAhAgyfAgsgA0EANgIcIAMgATYCFCADQYANNgIQIANBGzYCDEEAIQIMngILIANBADYCHCADIAE2AhQgA0HcKDYCECADQQI2AgxBACECDJ0CCyABIARHBEAgA0EMNgIIIAMgATYCBEG/ASECDIQCC0HYASECDJwCCyABIARGBEBB1wEhAgycAgsCQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAIAEtAABBwQBrDhUAAQIDWgQFBlpaWgcICQoLDA0ODxBaCyABQQFqIQFB+wAhAgySAgsgAUEBaiEBQfwAIQIMkQILIAFBAWohAUGBASECDJACCyABQQFqIQFBhQEhAgyPAgsgAUEBaiEBQYYBIQIMjgILIAFBAWohAUGJASECDI0CCy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ACAAQaHVAGotAABHDScgAEECRg0BIABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADPsBCyADQQA2AgAgBkEBaiEBQQwMJwtBtQEhAiABIARGDfkBIAMoAgAiACAEIAFraiEFIAEgAGtBAWohBgJAA0AgAS0AACAAQerUAGotAABHDSYgAEEBRg0BIABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADPoBCyADQQA2AgAgBkEBaiEBQQMMJgtBtAEhAiABIARGDfgBIAMoAgAiACAEIAFraiEFIAEgAGtBAWohBgJAA0AgAS0AACAAQejUAGotAABHDSUgAEEBRg0BIABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADPkBCyADQQA2AgAgBkEBaiEBQSYMJQsgASAERgRAQbMBIQIM+AELAkACQCABLQAAQdQAaw4CAAEnCyABQQFqIQFBmQEhAgzfAQsgAUEBaiEBQZoBIQIM3gELQbIBIQIgASAERg32ASADKAIAIgAgBCABa2ohBSABIABrQQFqIQYCQANAIAEtAAAgAEHm1ABqLQAARw0jIABBAUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAz3AQsgA0EANgIAIAZBAWohAUEnDCMLQbEBIQIgASAERg31ASADKAIAIgAgBCABa2ohBSABIABrQQFqIQYCQANAIAEtAAAgAEHk1ABqLQAARw0iIABBAUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAz2AQsgA0EANgIAIAZBAWohAUEcDCILQbABIQIgASAERg30ASADKAIAIgAgBCABa2ohBSABIABrQQVqIQYCQANAIAEtAAAgAEHe1ABqLQAARw0hIABBBUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAz1AQsgA0EANgIAIAZBAWohAUEGDCELQa8BIQIgASAERg3zASADKAIAIgAgBCABa2ohBSABIABrQQRqIQYCQANAIAEtAAAgAEHZ1ABqLQAARw0gIABBBEYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAz0AQsgA0EANgIAIAZBAWohAUEZDCALIAEgBEYEQEGu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w0ACyADIAU2AgAM4gELIANBADYCACAGQQFqIQFBLQwOCyABIARGBEBBnQEhAgzhAQsgAS0AAEHFAEcNDiABQQFqIQFBhAEhAgzHAQsgASAERgRAQZwBIQIM4AELAkACQCABLQAAQcwAaw4IAA8PDw8PDwEPCyABQQFqIQFBggEhAgzHAQsgAUEBaiEBQYMBIQIMxgELQZsBIQIgASAERg3eASADKAIAIgAgBCABa2ohBSABIABrQQRqIQYCQANAIAEtAAAgAEGz1ABqLQAARw0LIABBBEYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAzfAQsgA0EANgIAIAZBAWohAUEjDAsLQZoBIQIgASAERg3dASADKAIAIgAgBCABa2ohBSABIABrQQJqIQYCQANAIAEtAAAgAEGw1ABqLQAARw0KIABBAkYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAzeAQsgA0EANgIAIAZBAWohAUEADAoLIAEgBEYEQEGZASECDN0BCwJAAkAgAS0AAEHIAGsOCAAMDAwMDAwBDAsgAUEBaiEBQf0AIQIMxAELIAFBAWohAUGAASECDMMBCyABIARGBEBBmAEhAgzcAQsCQAJAIAEtAABBzgBrDgMACwELCyABQQFqIQFB/gAhAgzDAQsgAUEBaiEBQf8AIQIMwgELIAEgBEYEQEGXASECDNsBCyABLQAAQdkARw0IIAFBAWohAUEIDAcLQZYBIQIgASAERg3ZASADKAIAIgAgBCABa2ohBSABIABrQQNqIQYCQANAIAEtAAAgAEGs1ABqLQAARw0GIABBA0YNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAzaAQsgA0EANgIAIAZBAWohAUEFDAYLQZUBIQIgASAERg3YASADKAIAIgAgBCABa2ohBSABIABrQQVqIQYCQANAIAEtAAAgAEGm1ABqLQAARw0FIABBBUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAzZAQsgA0EANgIAIAZBAWohAUEWDAULQZQBIQIgASAERg3XASADKAIAIgAgBCABa2ohBSABIABrQQJqIQYCQANAIAEtAAAgAEGh1QBqLQAARw0EIABBAkYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAzYAQsgA0EANgIAIAZBAWohAUEQDAQLIAEgBEYEQEGTASECDNcBCwJAAkAgAS0AAEHDAGsODAAGBgYGBgYGBgYGAQYLIAFBAWohAUH5ACECDL4BCyABQQFqIQFB+gAhAgy9AQtBkgEhAiABIARGDdUBIAMoAgAiACAEIAFraiEFIAEgAGtBBWohBgJAA0AgAS0AACAAQaDUAGotAABHDQIgAEEFRg0BIABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADNYBCyADQQA2AgAgBkEBaiEBQSQMAgsgA0EANgIADAILIAEgBEYEQEGRASECDNQBCyABLQAAQcwARw0BIAFBAWohAUETCzoAKSADKAIEIQAgA0EANgIEIAMgACABEC4iAA0CDAELQQAhAiADQQA2AhwgAyABNgIUIANB/h82AhAgA0EGNgIMDNEBC0H4ACECDLcBCyADQZABNgIcIAMgATYCFCADIAA2AgxBACECDM8BC0EAIQACQCADKAI4IgJFDQAgAigCQCICRQ0AIAMgAhEAACEACyAARQ0AIABBFUYNASADQQA2AhwgAyABNgIUIANBgg82AhAgA0EgNgIMQQAhAgzOAQtB9wAhAgy0AQsgA0GPATYCHCADIAE2AhQgA0HsGzYCECADQRU2AgxBACECDMwBCyABIARGBEBBjwEhAgzMAQsCQCABLQAAQSBGBEAgAUEBaiEBDAELIANBADYCHCADIAE2AhQgA0GbHzYCECADQQY2AgxBACECDMwBC0ECIQIMsgELA0AgAS0AAEEgRw0CIAQgAUEBaiIBRw0AC0GOASECDMoBCyABIARGBEBBjQEhAgzKAQsCQCABLQAAQQlrDgRKAABKAAtB9QAhAgywAQsgAy0AKUEFRgRAQfYAIQIMsAELQfQAIQIMrwELIAEgBEYEQEGMASECDMgBCyADQRA2AgggAyABNgIEDAoLIAEgBEYEQEGLASECDMcBCwJAIAEtAABBCWsOBEcAAEcAC0HzACECDK0BCyABIARHBEAgA0EQNgIIIAMgATYCBEHxACECDK0BC0GK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BgJAA0AgAS0AACAAQbXVAGotAABHDQggAEECRg0BIABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADJwBCyADKAIEIQAgA0IANwMAIAMgACAGQQFqIgEQKyIABEAgA0H0ADYCHCADIAE2AhQgAyAANgIMQQAhAgycAQtB4gAhAgyCAQtBACEAAkAgAygCOCICRQ0AIAIoAjQiAkUNACADIAIRAAAhAAsCQCAABEAgAEEVRg0BIANBADYCHCADIAE2AhQgA0HqDTYCECADQSY2AgxBACECDJwBC0HhACECDIIBCyADQfMANgIcIAMgATYCFCADQYAbNgIQIANBFTYCDEEAIQIMmgELIAMtACkiAEEja0ELSQ0JAkAgAEEGSw0AQQEgAHRBygBxRQ0ADAoLQQAhAiADQQA2AhwgAyABNgIUIANB7Qk2AhAgA0EINgIMDJkBC0HyACECIAEgBEYNmAEgAygCACIAIAQgAWtqIQUgASAAa0EBaiEGAkADQCABLQAAIABBs9UAai0AAEcNBSAAQQFGDQEgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAU2AgAMmQELIAMoAgQhACADQgA3AwAgAyAAIAZBAWoiARArIgAEQCADQfEANgIcIAMgATYCFCADIAA2AgxBACECDJkBC0HfACECDH8LQQAhAAJAIAMoAjgiAkUNACACKAI0IgJFDQAgAyACEQAAIQALAkAgAARAIABBFUYNASADQQA2AhwgAyABNgIUIANB6g02AhAgA0EmNgIMQQAhAgyZAQtB3gAhAgx/CyADQfAANgIcIAMgATYCFCADQYAbNgIQIANBFTYCDEEAIQIMlwELIAMtAClBIUYNBiADQQA2AhwgAyABNgIUIANBkQo2AhAgA0EINgIMQQAhAgyWAQtB7wAhAiABIARGDZUBIAMoAgAiACAEIAFraiEFIAEgAGtBAmohBgJAA0AgAS0AACAAQbDVAGotAABHDQIgAEECRg0BIABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADJYBCyADKAIEIQAgA0IANwMAIAMgACAGQQFqIgEQKyIARQ0CIANB7QA2AhwgAyABNgIUIAMgADYCDEEAIQIMlQELIANBADYCAAsgAygCBCEAIANBADYCBCADIAAgARArIgBFDYABIANB7gA2AhwgAyABNgIUIAMgADYCDEEAIQIMkwELQdwAIQIMeQtBACEAAkAgAygCOCICRQ0AIAIoAjQiAkUNACADIAIRAAAhAAsCQCAABEAgAEEVRg0BIANBADYCHCADIAE2AhQgA0HqDTYCECADQSY2AgxBACECDJMBC0HbACECDHkLIANB7AA2AhwgAyABNgIUIANBgBs2AhAgA0EVNgIMQQAhAgyRAQsgAy0AKSIAQSNJDQAgAEEuRg0AIANBADYCHCADIAE2AhQgA0HJCTYCECADQQg2AgxBACECDJABC0HaACECDHYLIAEgBEYEQEHrACECDI8BCwJAIAEtAABBL0YEQCABQQFqIQEMAQsgA0EANgIcIAMgATYCFCADQbI4NgIQIANBCDYCDEEAIQIMjwELQdkAIQIMdQsgASAERwRAIANBDjYCCCADIAE2AgRB2AAhAgx1C0HqACECDI0BCyABIARGBEBB6QAhAgyNAQsgAS0AAEEwayIAQf8BcUEKSQRAIAMgADoAKiABQQFqIQFB1wAhAgx0CyADKAIEIQAgA0EANgIEIAMgACABEC8iAEUNeiADQegANgIcIAMgATYCFCADIAA2AgxBACECDIwBCyABIARGBEBB5wAhAgyMAQsCQCABLQAAQS5GBEAgAUEBaiEBDAELIAMoAgQhACADQQA2AgQgAyAAIAEQLyIARQ17IANB5gA2AhwgAyABNgIUIAMgADYCDEEAIQIMjAELQdYAIQIMcgsgASAERgRAQeUAIQIMiwELQQAhAEEBIQVBASEHQQAhAgJAAkACQAJAAkACfwJAAkACQAJAAkACQAJAIAEtAABBMGsOCgoJAAECAwQFBggLC0ECDAYLQQMMBQtBBAwEC0EFDAMLQQYMAgtBBwwBC0EICyECQQAhBUEAIQcMAgtBCSECQQEhAEEAIQVBACEHDAELQQAhBUEBIQILIAMgAjoAKyABQQFqIQECQAJAIAMtAC5BEHENAAJAAkACQCADLQAqDgMBAAIECyAHRQ0DDAILIAANAQwCCyAFRQ0BCyADKAIEIQAgA0EANgIEIAMgACABEC8iAEUNAiADQeIANgIcIAMgATYCFCADIAA2AgxBACECDI0BCyADKAIEIQAgA0EANgIEIAMgACABEC8iAEUNfSADQeMANgIcIAMgATYCFCADIAA2AgxBACECDIwBCyADKAIEIQAgA0EANgIEIAMgACABEC8iAEUNeyADQeQANgIcIAMgATYCFCADIAA2AgwMiwELQdQAIQIMcQsgAy0AKUEiRg2GAUHTACECDHALQQAhAAJAIAMoAjgiAkUNACACKAJEIgJFDQAgAyACEQAAIQALIABFBEBB1QAhAgxwCyAAQRVHBEAgA0EANgIcIAMgATYCFCADQaQNNgIQIANBITYCDEEAIQIMiQELIANB4QA2AhwgAyABNgIUIANB0Bo2AhAgA0EVNgIMQQAhAgyIAQsgASAERgRAQeAAIQIMiAELAkACQAJAAkACQCABLQAAQQprDgQBBAQABAsgAUEBaiEBDAELIAFBAWohASADQS9qLQAAQQFxRQ0BC0HSACECDHALIANBADYCHCADIAE2AhQgA0G2ETYCECADQQk2AgxBACECDIgBCyADQQA2AhwgAyABNgIUIANBthE2AhAgA0EJNgIMQQAhAgyHAQsgASAERgRAQd8AIQIMhwELIAEtAABBCkYEQCABQQFqIQEMCQsgAy0ALkHAAHENCCADQQA2AhwgAyABNgIUIANBthE2AhAgA0ECNgIMQQAhAgyGAQsgASAERgRAQd0AIQIMhgELIAEtAAAiAkENRgRAIAFBAWohAUHQACECDG0LIAEhACACQQlrDgQFAQEFAQsgBCABIgBGBEBB3AAhAgyFAQsgAC0AAEEKRw0AIABBAWoMAgtBACECIANBADYCHCADIAA2AhQgA0HKLTYCECADQQc2AgwMgwELIAEgBEYEQEHbACECDIMBCwJAIAEtAABBCWsOBAMAAAMACyABQQFqCyEBQc4AIQIMaAsgASAERgRAQdoAIQIMgQELIAEtAABBCWsOBAABAQABC0EAIQIgA0EANgIcIANBmhI2AhAgA0EHNgIMIAMgAUEBajYCFAx/CyADQYASOwEqQQAhAAJAIAMoAjgiAkUNACACKAI4IgJFDQAgAyACEQAAIQALIABFDQAgAEEVRw0BIAN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0EANgIAIAAhAQwFC0E6IQIgBCABIgBGDVcgBCABayADKAIAIgFqIQYgACABa0EIaiEHAkADQCABQbTBAGotAAAgAC0AACIFQSByIAUgBUHBAGtB/wFxQRpJG0H/AXFHDQEgAUEIRgRAQQUhAQw+CyABQQFqIQEgBCAAQQFqIgBHDQALIAMgBjYCAAxYCyADQQA2AgAgACEBDAQLQTkhAiAEIAEiAEYNViAEIAFrIAMoAgAiAWohBiAAIAFrQQNqIQcCQANAIAFBsMEAai0AACAALQAAIgVBIHIgBSAFQcEAa0H/AXFBGkkbQf8BcUcNASABQQNGBEBBBiEBDD0LIAFBAWohASAEIABBAWoiAEcNAAsgAyAGNgIADFcLIANBADYCACAAIQEMAwsCQANAIAEtAAAiAEEgRwRAIABBCmsOBAcEBAcCCyAEIAFBAWoiAUcNAAtBOCECDFYLIABBLEcNASABQQFqIQBBASEBAkACQAJAAkACQCADLQAsQQVrDgQDAQIEAAsgACEBDAQLQQIhAQwBC0EEIQELIANBAToALCADIAMvATIgAXI7ATIgACEBDAELIAMgAy8BMkEIcjsBMiAAIQELQT4hAgw7CyADQQA6ACwLQTkhAgw5CyABIARGBEBBNiECDFILAkACQAJAAkACQCABLQAAQQprDgQAAgIBAgsgAygCBCEAIANBADYCBCADIAAgARAxIgBFDQIgA0EzNgIcIAMgATYCFCADIAA2AgxBACECDFULIAMoAgQhACADQQA2AgQgAyAAIAEQMSIARQRAIAFBAWohAQwGCyADQTI2AhwgAyAANgIMIAMgAUEBajYCFEEAIQIMVAsgAy0ALkEBcQRAQd8BIQIMOwsgAygCBCEAIANBADYCBCADIAAgARAxIgANAQxJC0E0IQIMOQsgA0E1NgIcIAMgATYCFCADIAA2AgxBACECDFELQTUhAgw3CyADQS9qLQAAQQFxDQAgA0EANgIcIAMgATYCFCADQesWNgIQIANBGTYCDEEAIQIMTwtBMyECDDULIAEgBEYEQEEyIQIMTgsCQCABLQAAQQpGBEAgAUEBaiEBDAELIANBADYCHCADIAE2AhQgA0GSFzYCECAD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DAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMAAAAAAAADAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwBBoNQAC50BTk9VTkNFRUNLT1VUTkVDVEVURUNSSUJFTFVTSEVURUFEU0VBUkNIUkdFQ1RJVklUWUxFTkRBUlZFT1RJRllQVElPTlNDSFNFQVlTVEFUQ0hHRVVFUllPUkRJUkVDVE9SVFJDSFBBUkFNRVRFUlVSQ0VCU0NSSUJFQVJET1dOQUNFSU5ETktDS1VCU0NSSUJFVFRQQ0VUU1BBRFRQLw==","base64"))})},7136:(e,t,s)=>{"use strict";e=s.nmd(e);const{Buffer:n}=s(4573);let r;Object.defineProperty(e,"exports",{get:()=>r||(r=n.from("AGFzbQEAAAABJwdgAX8Bf2ADf39/AX9gAn9/AGABfwBgBH9/f38Bf2AAAGADf39/AALLAQgDZW52GHdhc21fb25faGVhZGVyc19jb21wbGV0ZQAEA2VudhV3YXNtX29uX21lc3NhZ2VfYmVnaW4AAANlbnYLd2FzbV9vbl91cmwAAQNlbnYOd2FzbV9vbl9zdGF0dXMAAQNlbnYUd2FzbV9vbl9oZWFkZXJfZmllbGQAAQNlbnYUd2FzbV9vbl9oZWFkZXJfdmFsdWUAAQNlbnYMd2FzbV9vbl9ib2R5AAEDZW52GHdhc21fb25fbWVzc2FnZV9jb21wbGV0ZQAAAzU0BQYAAAMAAAAAAAADAQMAAwMDAAACAAAAAAICAgICAgICAgIBAQEBAQEBAQEBAwAAAwAAAAQFAXABExMFAwEAAgYIAX8BQcDZBAsHxQcoBm1lbW9yeQIAC19pbml0aWFsaXplAAgZX19pbmRpcmVjdF9mdW5jdGlvbl90YWJsZQEAC2xsaHR0cF9pbml0AAkYbGxodHRwX3Nob3VsZF9rZWVwX2FsaXZlADcMbGxodHRwX2FsbG9jAAsGbWFsbG9jADkLbGxodHRwX2ZyZWUADARmcmVlAAwPbGxodHRwX2dldF90eXBlAA0VbGxodHRwX2dldF9odHRwX21ham9yAA4VbGxodHRwX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EBBxNUAQcTVACgCAEF+IAN3cTYCAAwFCyACIAA2AgggACACNgIMDAQLIAUoAhghBiAFIAUoAgwiAEcEQEHU1QAoAgAaIAAgBSgCCCICNgIIIAIgADYCDAwDCyAFQRRqIgMoAgAiAkUEQCAFKAIQIgJFDQIgBUEQaiEDCwNAIAMhByACIgBBFGoiAygCACICDQAgAEEQaiEDIAAoAhAiAg0ACyAHQQA2AgAMAgsgBSAAQX5xNgIEIAEgBGogBDYCACABIARBAXI2AgQMAwtBACEACyAGRQ0AAkAgBSgCHCICQQJ0QfTXAGoiAygCACAFRgRAIAMgADYCACAADQFByNUAQcjVACgCAEF+IAJ3cTYCAAwCCyAGQRBBFCAGKAIQIAVGG2ogADYCACAARQ0BCyAAIAY2AhggBSgCECICBEAgACACNgIQIAIgADYCGAsgBUEUaigCACICRQ0AIABBFGogAjYCACACIAA2AhgLIAEgBGogBDYCACABIARBAXI2AgQgAUHY1QAoAgBHDQBBzNUAIAQ2AgAMAQsgBEH/AU0EQCAEQXhxQezVAGohAAJ/QcTVACgCACICQQEgBEEDdnQiA3FFBEBBxNUAIAIgA3I2AgAgAAwBCyAAKAIICyICIAE2AgwgACABNgIIIAEgADYCDCABIAI2AggMAQtBHyECIARB////B00EQCAEQSYgBEEIdmciAGt2QQFxIABBAXRrQT5qIQILIAEgAjYCHCABQgA3AhAgAkECdEH01wBqIQACQEHI1QAoAgAiA0EBIAJ0IgdxRQRAIAAgATYCAEHI1QAgAyAHcjYCACABIAA2AhggASABNgIIIAEgATYCDAwBCyAEQRkgAkEBdmtBACACQR9HG3QhAiAAKAIAIQACQANAIAAiAygCBEF4cSAERg0BIAJBHXYhACACQQF0IQIgAyAAQQRxakEQaiIHKAIAIgANAAsgByABNgIAIAEgAzYCGCABIAE2AgwgASABNgIIDAELIAMoAggiACABNgIMIAMgATYCCCABQQA2AhggASADNgIMIAEgADYCCAtB5NUAQeTVACgCAEEBayIAQX8gABs2AgALCwcAIAAtACgLBwAgAC0AKgsHACAALQArCwcAIAAtACkLBwAgAC8BNAsHACAALQAwC0ABBH8gACgCGCEBIAAvAS4hAiAALQAoIQMgACgCOCEEIAAQOCAAIAQ2AjggACADOgAoIAAgAjsBLiAAIAE2AhgLhocCAwd/A34BeyABIAJqIQQCQCAAIgMoAgwiAA0AIAMoAgQEQCADIAE2AgQLIwBBEGsiCSQAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACfwJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQCADKAIcIgJBAmsO/AEB+QECAwQFBgcICQoLDA0ODxAREvgBE/cBFBX2ARYX9QEYGRobHB0eHyD9AfsBIfQBIiMkJSYnKCkqK/MBLC0uLzAxMvIB8QEzNPAB7wE1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk/6AVBRUlPuAe0BVOwBVesBVldYWVrqAVtcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AAYEBggGDAYQBhQGGAYcBiAGJ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AAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAIAMCfwJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACfwJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACfwJAAkACQAJAAkACQAJAAn8CQAJAAkACfwJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAgAwJ/AkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJ/AkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQCACDuMBAAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gIS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AAQTtHDQAgAUEBaiEBDAwLQQAhAiADQQA2AhwgAyABNgIUIANBkhg2AhAgA0ECNgIMDPwCCyAAQRVGDShBACECIANBADYCHCADIAE2AhQgA0HWDDYCECADQSM2AgwM+wILIANBFDYCHCADIAE2AhQgAyAANgIMDPoCCyADKAIEIQBBACECIANBADYCBCADIAAgARA0IgBFBEAgAUEBaiEBDPUCCyADQRU2AhwgAyAANgIMIAMgAUEBajYCFAz5AgsgAygCBCEAQQAhAiADQQA2AgQgAyAAIAEQNCIARQRAIAFBAWohAQzzAgsgA0EXNgIcIAMgADYCDCADIAFBAWo2AhQM+AILIABBFUYNI0EAIQIgA0EANgIcIAMgATYCFCADQdYMNgIQIANBIzYCDAz3AgsgAygCBCEAQQAhAiADQQA2AgQgAyAAIAEQNCIARQRAIAFBAWohAQwdCyADQRk2AhwgAyAANgIMIAMgAUEBajYCFAz2AgsgAygCBCEAQQAhAiADQQA2AgQgAyAAIAEQNCIARQRAIAFBAWohAQzvAgsgA0EaNgIcIAMgADYCDCADIAFBAWo2AhQM9QILIABBFUYNH0EAIQIgA0EANgIcIAMgATYCFCADQdAPNgIQIANBIjYCDAz0AgsgAygCBCEAIANBADYCBCADIAAgARAzIgBFBEAgAUEBaiEBDBsLIANBHDYCHCADIAA2AgwgAyABQQFqNgIUQQAhAgzzAgsgAygCBCEAIANBADYCBCADIAAgARAzIgBFBEAgAUEBaiEBDOsCCyADQR02AhwgAyAANgIMIAMgAUEBajYCFEEAIQIM8gILIABBO0cNASABQQFqIQELQSYhAgzXAgtBACECIANBADYCHCADIAE2AhQgA0GfFTYCECADQQw2AgwM7wILIAEgBEcEQANAIAEtAABBIEcNhAIgBCABQQFqIgFHDQALQSwhAgzvAgtBLCECDO4CCyABIARGBEBBNCECDO4CCwJAAkADQAJAIAEtAABBCmsOBAIAAAMACyAEIAFBAWoiAUcNAAtBNCECDO8CCyADKAIEIQAgA0EANgIEIAMgACABEDEiAEUNnwIgA0EyNgIcIAMgATYCFCADIAA2AgxBACECDO4CCyADKAIEIQAgA0EANgIEIAMgACABEDEiAEUEQCABQQFqIQEMnwILIANBMjYCHCADIAA2AgwgAyABQQFqNgIUQQAhAgztAgsgASAERwRAAkADQCABLQAAQTBrIgBB/wFxQQpPBEBBOiECDNcCCyADKQMgIgtCmbPmzJmz5swZVg0BIAMgC0IKfiIKNwMgIAogAK1C/wGDIgtCf4VWDQEgAyAKIAt8NwMgIAQgAUEBaiIBRw0AC0HAACECDO4CCyADKAIEIQAgA0EANgIEIAMgACABQQFqIgEQMSIADRcM4gILQcAAIQIM7AILIAEgBEYEQEHJACECDOwCCwJAA0ACQCABLQAAQQlrDhgAAqICogKpAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAgCiAgsgBCABQQFqIgFHDQALQckAIQIM7AILIAFBAWohASADQS9qLQAAQQFxDaUCIANBADYCHCADIAE2AhQgA0GXEDYCECADQQo2AgxBACECDOsCCyABIARHBEADQCABLQAAQSBHDRUgBCABQQFqIgFHDQALQfgAIQIM6wILQfgAIQIM6gILIANBAjoAKAw4C0EAIQIgA0EANgIcIANBvws2AhAgA0ECNgIMIAMgAUEBajYCFAzoAgtBACECDM4CC0ENIQIMzQILQRMhAgzMAgtBFSECDMsCC0EWIQIMygILQRghAgzJAgtBGSECDMgCC0EaIQIMxwILQRshAgzGAgtBHCECDMUCC0EdIQIMxAILQR4hAgzDAgtBHyECDMICC0EgIQIMwQILQSIhAgzAAgtBIyECDL8CC0ElIQIMvgILQeUAIQIMvQILIANBPTYCHCADIAE2AhQgAyAANgIMQQAhAgzVAgsgA0EbNgIcIAMgATYCFCADQaQcNgIQIANBFTYCDEEAIQIM1AILIANBIDYCHCADIAE2AhQgA0GYGjYCECADQRU2AgxBACECDNMCCyADQRM2AhwgAyABNgIUIANBmBo2AhAgA0EVNgIMQQAhAgzSAgsgA0ELNgIcIAMgATYCFCADQZgaNgIQIANBFTYCDEEAIQIM0QILIANBEDYCHCADIAE2AhQgA0GYGjYCECADQRU2AgxBAC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gA3AwAgAyAAIAZBAWoiARAuIgBFBEBB4wEhAgyqAgsgA0H1ATYCHCADIAE2AhQgAyAANgIMQQAhAgzCAgtB9AEhAiABIARGDcECIAMoAgAiACAEIAFraiEFIAEgAGtBAWohBgJAA0AgAS0AACAAQbjVAGotAABHDQIgAEEBRg0BIABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADMICCyADQYEEOwEoIAMoAgQhACADQgA3AwAgAyAAIAZBAWoiARAuIgANAwwCCyADQQA2AgALQQAhAiADQQA2AhwgAyABNgIUIANB5R82AhAgA0EINgIMDL8CC0HVASECDKUCCyADQfMBNgIcIAMgATYCFCADIAA2AgxBACECDL0CC0EAIQACQCADKAI4IgJFDQAgAigCQCICRQ0AIAMgAhEAACEACyAARQ1uIABBFUcEQCADQQA2AhwgAyABNgIUIANBgg82AhAgA0EgNgIMQQAhAgy9AgsgA0GPATYCHCADIAE2AhQgA0HsGzYCECADQRU2AgxBACECDLwCCyABIARHBEAgA0ENNgIIIAMgATYCBEHTASECDKMCC0HyASECDLsCCyABIARGBEBB8QEhAgy7AgsCQAJAAkAgAS0AAEHIAGsOCwABCAgICAgICAgCCAsgAUEBaiEBQdABIQIMowILIAFBAWohAUHRASECDKICCyABQQFqIQFB0gEhAgyhAgtB8AEhAiABIARGDbkCIAMoAgAiACAEIAFraiEGIAEgAGtBAmohBQNAIAEtAAAgAEG11QBqLQAARw0EIABBAkYNAyAAQQFqIQAgBCABQQFqIgFHDQALIAMgBjYCAAy5AgtB7wEhAiABIARGDbgCIAMoAgAiACAEIAFraiEGIAEgAGtBAWohBQNAIAEtAAAgAEGz1QBqLQAARw0DIABBAUYNAiAAQQFqIQAgBCABQQFqIgFHDQALIAMgBjYCAAy4AgtB7gEhAiABIARGDbcCIAMoAgAiACAEIAFraiEGIAEgAGtBAmohBQNAIAEtAAAgAEGw1QBqLQAARw0CIABBAkYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBjYCAAy3AgsgAygCBCEAIANCADcDACADIAAgBUEBaiIBECsiAEUNAiADQewBNgIcIAMgATYCFCADIAA2AgxBACECDLYCCyADQQA2AgALIAMoAgQhACADQQA2AgQgAyAAIAEQKyIARQ2cAiADQe0BNgIcIAMgATYCFCADIAA2AgxBACECDLQCC0HPASECDJoCC0EAIQACQCADKAI4IgJFDQAgAigCNCICRQ0AIAMgAhEAACEACwJAIAAEQCAAQRVGDQEgA0EANgIcIAMgATYCFCADQeoNNgIQIANBJjYCDEEAIQIMtAILQc4BIQIMmgILIANB6wE2AhwgAyABNgIUIANBgBs2AhAgA0EVNgIMQQAhAgyyAgsgASAERgRAQesBIQIMsgILIAEtAABBL0YEQCABQQFqIQEMAQsgA0EANgIcIAMgATYCFCADQbI4NgIQIANBCDYCDEEAIQIMsQILQc0BIQIMlwILIAEgBEcEQCADQQ42AgggAyABNgIEQcwBIQIMlwILQeoBIQIMrwILIAEgBEYEQEHpASECDK8CCyABLQAAQTBrIgBB/wFxQQpJBEAgAyAAOgAqIAFBAWohAUHLASECDJYCCyADKAIEIQAgA0EANgIEIAMgACABEC8iAEUNlwIgA0HoATYCHCADIAE2AhQgAyAANgIMQQAhAgyuAgsgASAERgRAQecBIQIMrgILAkAgAS0AAEEuRgRAIAFBAWohAQwBCyADKAIEIQAgA0EANgIEIAMgACABEC8iAEUNmAIgA0HmATYCHCADIAE2AhQgAyAANgIMQQAhAgyuAgtBygEhAgyUAgsgASAERgRAQeUBIQIMrQILQQAhAEEBIQVBASEHQQAhAgJAAkACQAJAAkACfwJAAkACQAJAAkACQAJAIAEtAABBMGsOCgoJAAECAwQFBggLC0ECDAYLQQMMBQtBBAwEC0EFDAMLQQYMAgtBBwwBC0EICyECQQAhBUEAIQcMAgtBCSECQQEhAEEAIQVBACEHDAELQQAhBUEBIQILIAMgAjoAKyABQQFqIQECQAJAIAMtAC5BEHENAAJAAkACQCADLQAqDgMBAAIECyAHRQ0DDAILIAANAQwCCyAFRQ0BCyADKAIEIQAgA0EANgIEIAMgACABEC8iAEUNAiADQeIBNgIcIAMgATYCFCADIAA2AgxBACECDK8CCyADKAIEIQAgA0EANgIEIAMgACABEC8iAEUNmgIgA0HjATYCHCADIAE2AhQgAyAANgIMQQAhAgyuAgsgAygCBCEAIANBADYCBCADIAAgARAvIgBFDZgCIANB5AE2AhwgAyABNgIUIAMgADYCDAytAgtByQEhAgyTAgtBACEAAkAgAygCOCICRQ0AIAIoAkQiAkUNACADIAIRAAAhAAsCQCAABEAgAEEVRg0BIANBADYCHCADIAE2AhQgA0GkDTYCECADQSE2AgxBACECDK0CC0HIASECDJMCCyADQeEBNgIcIAMgATYCFCADQdAaNgIQIANBFTYCDEEAIQIMqwILIAEgBEYEQEHhASECDKsCCwJAIAEtAABBIEYEQCADQQA7ATQgAUEBaiEBDAELIANBADYCHCADIAE2AhQgA0GZETYCECADQQk2AgxBACECDKsCC0HHASECDJECCyABIARGBEBB4AEhAgyqAgsCQCABLQAAQTBrQf8BcSICQQpJBEAgAUEBaiEBAkAgAy8BNCIAQZkzSw0AIAMgAEEKbCIAOwE0IABB/v8DcSACQf//A3NLDQAgAyAAIAJqOwE0DAILQQAhAiADQQA2AhwgAyABNgIUIANBlR42AhAgA0ENNgIMDKsCCyADQQA2AhwgAyABNgIUIANBlR42AhAgA0ENNgIMQQAhAgyqAgtBxgEhAgyQAgsgASAERgRAQd8BIQIMqQILAkAgAS0AAEEwa0H/AXEiAkEKSQRAIAFBAWohAQJAIAMvATQiAEGZM0sNACADIABBCmwiADsBNCAAQf7/A3EgAkH//wNzSw0AIAMgACACajsBNAwCC0EAIQIgA0EANgIcIAMgATYCFCADQZUeNgIQIANBDTYCDAyqAgsgA0EANgIcIAMgATYCFCADQZUeNgIQIANBDTYCDEEAIQIMqQILQcUBIQIMjwILIAEgBEYEQEHeASECDKgCCwJAIAEtAABBMGtB/wFxIgJBCkkEQCABQQFqIQECQCADLwE0IgBBmTNLDQAgAyAAQQpsIgA7ATQgAEH+/wNxIAJB//8Dc0sNACADIAAgAmo7ATQMAgtBACECIANBADYCHCADIAE2AhQgA0GVHjYCECADQQ02AgwMqQILIANBADYCHCADIAE2AhQgA0GVHjYCECADQQ02AgxBACECDKgCC0HEASECDI4CCyABIARGBEBB3QEhAgynAgsCQAJAAkACQCABLQAAQQprDhcCAwMAAwMDAwMDAwMDAwMDAwMDAwMDAQMLIAFBAWoMBQsgAUEBaiEBQcMBIQIMjwILIAFBAWohASADQS9qLQAAQQFxDQggA0EANgIcIAMgATYCFCADQY0LNgIQIANBDTYCDEEAIQIMpwILIANBADYCHCADIAE2AhQgA0GNCzYCECADQQ02AgxBACECDKYCCyABIARHBEAgA0EPNgIIIAMgATYCBEEBIQIMjQILQdwBIQIMpQILAkACQANAAkAgAS0AAEEKaw4EAgAAAwALIAQgAUEBaiIBRw0AC0HbASECDKYCCyADKAIEIQAgA0EANgIEIAMgACABEC0iAEUEQCABQQFqIQEMBAsgA0HaATYCHCADIAA2AgwgAyABQQFqNgIUQQAhAgylAgsgAygCBCEAIANBADYCBCADIAAgARAtIgANASABQQFqCyEBQcEBIQIMigILIANB2QE2AhwgAyAANgIMIAMgAUEBajYCFEEAIQIMogILQcIBIQIMiAILIANBL2otAABBAXENASADQQA2AhwgAyABNgIUIANB5Bw2AhAgA0EZNgIMQQAhAgygAgsgASAERgRAQdkBIQIMoAILAkACQAJAIAEtAABBCmsOBAECAgACCyABQQFqIQEMAgsgAUEBaiEBDAELIAMtAC5BwABxRQ0BC0EAIQACQCADKAI4IgJFDQAgAigCPCICRQ0AIAMgAhEAACEACyAARQ2gASAAQRVGBEAgA0HZADYCHCADIAE2AhQgA0G3GjYCECADQRU2AgxBACECDJ8CCyADQQA2AhwgAyABNgIUIANBgA02AhAgA0EbNgIMQQAhAgyeAgsgA0EANgIcIAMgATYCFCADQdwoNgIQIANBAjYCDEEAIQIMnQILIAEgBEcEQCADQQw2AgggAyABNgIEQb8BIQIMhAILQdgBIQIMnAILIAEgBEYEQEHXASECDJwCCwJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQ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T09PT09PT09PT09PT09PT09AT0LIAFBAWohAUGtASECDPUBCyABQQFqIQFBsAEhAgz0AQsgASAERgRAQcgBIQIMjQILAkACQCABLQAAQdUAaw4LADw8PDw8PDw8PAE8CyABQQFqIQFBrgEhAgz0AQsgAUEBaiEBQa8BIQIM8wELQccBIQIgASAERg2LAiADKAIAIgAgBCABa2ohBSABIABrQQhqIQYCQANAIAEtAAAgAEGE1QBqLQAARw04IABBCEYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAyMAgsgA0EANgIAIAZBAWohAUEqDDgLIAEgBEYEQEHGASECDIsCCyABLQAAQdAARw04IAFBAWohAUElDDcLQcUBIQIgASAERg2JAiADKAIAIgAgBCABa2ohBSABIABrQQJqIQYCQANAIAEtAAAgAEGB1QBqLQAARw02IABBAkYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAyKAgsgA0EANgIAIAZBAWohAUEODDYLIAEgBEYEQEHEASECDIkCCyABLQAAQcUARw02IAFBAWohAUGrASECDO8BCyABIARGBEBBwwEhAgyIAgsCQAJAAkACQCABLQAAQcIAaw4PAAECOTk5OTk5OTk5OTkDOQsgAUEBaiEBQacBIQIM8QELIAFBAWohAUGoASECDPABCyABQQFqIQFBqQEhAgzvAQsgAUEBaiEBQaoBIQIM7gELQcIBIQIgASAERg2GAiADKAIAIgAgBCABa2ohBSABIABrQQJqIQYCQANAIAEtAAAgAEH+1ABqLQAARw0zIABBAkYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAyHAgsgA0EANgIAIAZBAWohAUEUDDMLQcEBIQIgASAERg2FAiADKAIAIgAgBCABa2ohBSABIABrQQRqIQYCQANAIAEtAAAgAEH51ABqLQAARw0yIABBBEYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAyGAgsgA0EANgIAIAZBAWohAUErDDILQcABIQIgASAERg2EAiADKAIAIgAgBCABa2ohBSABIABrQQJqIQYCQANAIAEtAAAgAEH21ABqLQAARw0xIABBA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BkEBaiEBQQYMIQtBrwEhAiABIARGDfMBIAMoAgAiACAEIAFraiEFIAEgAGtBBGohBgJAA0AgAS0AACAAQdnUAGotAABHDSAgAEEERg0BIABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADPQBCyADQQA2AgAgBkEBaiEBQRkMIAsgASAERgRAQa4BIQIM8wELAkACQAJAAkAgAS0AAEEtaw4jACQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkASQkJCQkAiQkJAMkCyABQQFqIQFBjgEhAgzcAQsgAUEBaiEBQY8BIQIM2wELIAFBAWohAUGUASECDNoBCyABQQFqIQFBlQEhAgzZAQtBrQEhAiABIARGDfEBIAMoAgAiACAEIAFraiEFIAEgAGtBAWohBgJAA0AgAS0AACAAQdfUAGotAABHDR4gAEEBRg0BIABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADPIBCyADQQA2AgAgBkEBaiEBQQsMHgsgASAERgRAQawBIQIM8QELAkACQCABLQAAQcEAaw4DACABIAsgAUEBaiEBQZABIQIM2AELIAFBAWohAUGTASECDNcBCyABIARGBEBBqwEhAgzwAQsCQAJAIAEtAABBwQBrDg8AHx8fHx8fHx8fHx8fHwEfCyABQQFqIQFBkQEhAgzXAQsgAUEBaiEBQZIBIQIM1gELIAEgBEYEQEGqASECDO8BCyABLQAAQcwARw0cIAFBAWohAUEKDBsLQakBIQIgASAERg3tASADKAIAIgAgBCABa2ohBSABIABrQQVqIQYCQANAIAEtAAAgAEHR1ABqLQAARw0aIABBBUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAzuAQsgA0EANgIAIAZBAWohAUEeDBoLQagBIQIgASAERg3sASADKAIAIgAgBCABa2ohBSABIABrQQZqIQYCQANAIAEtAAAgAEHK1ABqLQAARw0ZIABBBkYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAztAQsgA0EANgIAIAZBAWohAUEVDBkLQacBIQIgASAERg3rASADKAIAIgAgBCABa2ohBSABIABrQQJqIQYCQANAIAEtAAAgAEHH1ABqLQAARw0YIABBAkYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAzsAQsgA0EANgIAIAZBAWohAUEXDBgLQaYBIQIgASAERg3qASADKAIAIgAgBCABa2ohBSABIABrQQVqIQYCQANAIAEtAAAgAEHB1ABqLQAARw0XIABBBUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAzrAQsgA0EANgIAIAZBAWohAUEYDBcLIAEgBEYEQEGlASECDOoBCwJAAkAgAS0AAEHJAGsOBwAZGRkZGQEZCyABQQFqIQFBiwEhAgzRAQsgAUEBaiEBQYwBIQIM0AELQaQBIQIgASAERg3oASADKAIAIgAgBCABa2ohBSABIABrQQFqIQYCQANAIAEtAAAgAEGm1QBqLQAARw0VIABBAUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAzpAQsgA0EANgIAIAZBAWohAUEJDBULQaMBIQIgASAERg3nASADKAIAIgAgBCABa2ohBSABIABrQQFqIQYCQANAIAEtAAAgAEGk1QBqLQAARw0UIABBAUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAzoAQsgA0EANgIAIAZBAWohAUEfDBQLQaIBIQIgASAERg3mASADKAIAIgAgBCABa2ohBSABIABrQQJqIQYCQANAIAEtAAAgAEG+1ABqLQAARw0TIABBAkYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAznAQsgA0EANgIAIAZBAWohAUECDBMLQaEBIQIgASAERg3lASADKAIAIgAgBCABa2ohBSABIABrQQFqIQYDQCABLQAAIABBvNQAai0AAEcNESAAQQFGDQIgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAU2AgAM5QELIAEgBEYEQEGgASECDOUBC0EBIAEtAABB3wBHDREaIAFBAWohAUGHASECDMsBCyADQQA2AgAgBkEBaiEBQYgBIQIMygELQZ8BIQIgASAERg3iASADKAIAIgAgBCABa2ohBSABIABrQQhqIQYCQANAIAEtAAAgAEGE1QBqLQAARw0PIABBCEYNASAAQQ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BBWohBgJAA0AgAS0AACAAQabUAGotAABHDQUgAEEFRg0BIABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADNkBCyADQQA2AgAgBkEBaiEBQRYMBQtBlAEhAiABIARGDdcBIAMoAgAiACAEIAFraiEFIAEgAGtBAmohBgJAA0AgAS0AACAAQaHVAGotAABHDQQgAEECRg0BIABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADNgBCyADQQA2AgAgBkEBaiEBQRAMBAsgASAERgRAQZMBIQIM1wELAkACQCABLQAAQcMAaw4MAAYGBgYGBgYGBgYBBgsgAUEBaiEBQfkAIQIMvgELIAFBAWohAUH6ACECDL0BC0GSASECIAEgBEYN1QEgAygCACIAIAQgAWtqIQUgASAAa0EFaiEGAkADQCABLQAAIABBoNQAai0AAEcNAiAAQQVGDQEgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAU2AgAM1gELIANBADYCACAGQQFqIQFBJAwCCyADQQA2AgAMAgsgASAERgRAQZEBIQIM1AELIAEtAABBzABHDQEgAUEBaiEBQRMLOgApIAMoAgQhACADQQA2AgQgAyAAIAEQLiIADQIMAQtBACECIANBADYCHCADIAE2AhQgA0H+HzYCECADQQY2AgwM0QELQfgAIQIMtwELIANBkAE2AhwgAyABNgIUIAMgADYCDEEAIQIMzwELQQAhAAJAIAMoAjgiAkUNACACKAJAIgJFDQAgAyACEQAAIQALIABFDQAgAEEVRg0BIANBADYCHCADIAE2AhQgA0GCDzYCECADQSA2AgxBACECDM4BC0H3ACECDLQBCyADQY8BNgIcIAMgATYCFCADQewbNgIQIANBFTYCDEEAIQIMzAELIAEgBEYEQEGPASECDMwBCwJAIAEtAABBIEYEQCABQQFqIQEMAQsgA0EANgIcIAMgATYCFCADQZsfNgIQIANBBjYCDEEAIQIMzAELQQIhAgyyAQsDQCABLQAAQSBHDQIgBCABQQFqIgFHDQALQY4BIQIMygELIAEgBEYEQEGNASECDMoBCwJAIAEtAABBCWsOBEoAAEoAC0H1ACECDLABCyADLQApQQVGBEBB9gAhAgywAQtB9AAhAgyvAQsgASAERgRAQYwBIQIMyAELIANBEDYCCCADIAE2AgQMCgsgASAERgRAQYsBIQIMxwELAkAgAS0AAEEJaw4ERwAARwALQfMAIQIMrQELIAEgBEcEQCADQRA2AgggAyABNgIEQfEAIQIMrQELQYoBIQIMxQELAkAgASAERwRAA0AgAS0AAEGg0ABqLQAAIgBBA0cEQAJAIABBAWsOAkkABAtB8AAhAgyvAQsgBCABQQFqIgFHDQALQYgBIQIMxgELQYgBIQIMxQELIANBADYCHCADIAE2AhQgA0HbIDYCECADQQc2AgxBACECDMQBCyABIARGBEBBiQEhAgzEAQsCQAJAAkAgAS0AAEGg0gBqLQAAQQFrDgNGAgABC0HyACECDKwBCyADQQA2AhwgAyABNgIUIANBtBI2AhAgA0EHNgIMQQAhAgzEAQtB6gAhAgyqAQsgASAERwRAIAFBAWohAUHvACECDKoBC0GHASECDMIBCyAEIAEiAEYEQEGGASECDMIBCyAALQAAIgFBL0YEQCAAQQFqIQFB7gAhAgypAQsgAUEJayICQRdLDQEgACEBQQEgAnRBm4CABHENQQwBCyAEIAEiAEYEQEGFASECDMEBCyAALQAAQS9HDQAgAEEBaiEBDAMLQQAhAiADQQA2AhwgAyAANgIUIANB2yA2AhAgA0EHNgIMDL8BCwJAAkACQAJAAkADQCABLQAAQaDOAGotAAAiAEEFRwRAAkACQCAAQQFrDghHBQYHCAAEAQgLQesAIQIMrQELIAFBAWohAUHtACECDKwBCyAEIAFBAWoiAUcNAAtBhAEhAgzDAQsgAUEBagwUCyADKAIEIQAgA0EANgIEIAMgACABECwiAEUNHiADQdsANgIcIAMgATYCFCADIAA2AgxBACECDMEBCyADKAIEIQAgA0EANgIEIAMgACABECwiAEUNHiADQd0ANgIcIAMgATYCFCADIAA2AgxBACECDMABCyADKAIEIQAgA0EANgIEIAMgACABECwiAEUNHiADQfoANgIcIAMgATYCFCADIAA2AgxBACECDL8BCyADQQA2AhwgAyABNgIUIANB+Q82AhAgA0EHNgIMQQAhAgy+AQsgASAERgRAQYMBIQIMvgELAkAgAS0AAEGgzgBqLQAAQQFrDgg+BAUGAAgCAwcLIAFBAWohAQtBAyECDKMBCyABQQFqDA0LQQAhAiADQQA2AhwgA0HREjYCECADQQc2AgwgAyABQQFqNgIUDLoBCyADKAIEIQAgA0EANgIEIAMgACABECwiAEUNFiADQdsANgIcIAMgATYCFCADIAA2AgxBACECDLkBCyADKAIEIQAgA0EANgIEIAMgACABECwiAEUNFiADQd0ANgIcIAMgATYCFCADIAA2AgxBACECDLgBCyADKAIEIQAgA0EANgIEIAMgACABECwiAEUNFiADQfoANgIcIAMgATYCFCADIAA2AgxBACECDLcBCyADQQA2AhwgAyABNgIUIANB+Q82AhAgA0EHNgIMQQAhAgy2AQtB7AAhAgycAQsgASAERgRAQYIBIQIMtQELIAFBAWoMAgsgASAERgRAQYEBIQIMtAELIAFBAWoMAQsgASAERg0BIAFBAWoLIQFBBCECDJgBC0GAASECDLABCwNAIAEtAABBoMwAai0AACIAQQJHBEAgAEEBRwRAQekAIQIMmQELDDELIAQgAUEBaiIBRw0AC0H/ACECDK8BCyABIARGBEBB/gAhAgyvAQsCQCABLQAAQQlrDjcvAwYvBAYGBgYGBgYGBgYGBgYGBgYGBgUGBgIGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYABgsgAUEBagshAUEFIQIMlAELIAFBAWoMBgsgAygCBCEAIANBADYCBCADIAAgARAsIgBFDQggA0HbADYCHCADIAE2AhQgAyAANgIMQQAhAgyrAQsgAygCBCEAIANBADYCBCADIAAgARAsIgBFDQggA0HdADYCHCADIAE2AhQgAyAANgIMQQAhAgyqAQsgAygCBCEAIANBADYCBCADIAAgARAsIgBFDQggA0H6ADYCHCADIAE2AhQgAyAANgIMQQAhAgypAQsgA0EANgIcIAMgATYCFCADQY0UNgIQIANBBzYCDEEAIQIMqAELAkACQAJAAkADQCABLQAAQaDKAGotAAAiAEEFRwRAAkAgAEEBaw4GLgMEBQYABgtB6AAhAgyUAQsgBCABQQFqIgFHDQALQf0AIQIMqwELIAMoAgQhACADQQA2AgQgAyAAIAEQLCIARQ0HIANB2wA2AhwgAyABNgIUIAMgADYCDEEAIQIMqgELIAMoAgQhACADQQA2AgQgAyAAIAEQLCIARQ0HIANB3QA2AhwgAyABNgIUIAMgADYCDEEAIQIMqQELIAMoAgQhACADQQA2AgQgAyAAIAEQLCIARQ0HIANB+gA2AhwgAyABNgIUIAMgADYCDEEAIQIMqAELIANBADYCHCADIAE2AhQgA0HkCDYCECADQQc2AgxBACECDKcBCyABIARGDQEgAUEBagshAUEGIQIMjAELQfwAIQIMpAELAkACQAJAAkADQCABLQAAQaDIAGotAAAiAEEFRwRAIABBAWsOBCkCAwQFCyAEIAFBAWoiAUcNAAtB+wAhAgynAQsgAygCBCEAIANBADYCBCADIAAgARAsIgBFDQMgA0HbADYCHCADIAE2AhQgAyAANgIMQQAhAgymAQsgAygCBCEAIANBADYCBCADIAAgARAsIgBFDQMgA0HdADYCHCADIAE2AhQgAyAANgIMQQAhAgylAQsgAygCBCEAIANBADYCBCADIAAgARAsIgBFDQMgA0H6ADYCHCADIAE2AhQgAyAANgIMQQAhAgykAQsgA0EANgIcIAMgATYCFCADQbwKNgIQIANBBzYCDEEAIQIMowELQc8AIQIMiQELQdEAIQIMiAELQecAIQIMhwELIAEgBEYEQEH6ACECDKABCwJAIAEtAABBCWsOBCAAACAACyABQQFqIQFB5gAhAgyGAQsgASAERgRAQfkAIQIMnwELAkAgAS0AAEEJaw4EHwAAHwALQQAhAAJAIAMoAjgiAkUNACACKAI4IgJFDQAgAyACEQAAIQALIABFBEBB4gEhAgyGAQsgAEEVRwRAIANBADYCHCADIAE2AhQgA0HJDTYCECADQRo2AgxBACECDJ8BCyADQfgANgIcIAMgATYCFCADQeoaNgIQIANBFTYCDEEAIQIMngELIAEgBEcEQCADQQ02AgggAyABNgIEQeQAIQIMhQELQfcAIQIMnQELIAEgBEYEQEH2ACECDJ0BCwJAAkACQCABLQAAQcgAaw4LAAELCwsLCwsLCwILCyABQQFqIQFB3QAhAgyFAQsgAUEBaiEBQeAAIQIMhAELIAFBAWohAUHjACECDIMBC0H1ACECIAEgBEYNmwEgAygCACIAIAQgAWtqIQUgASAAa0ECaiEGAkADQCABLQAAIABBtdUAai0AAEcNCCAAQQJGDQEgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAU2AgAMnAELIAMoAgQhACADQgA3AwAgAyAAIAZBAWoiARArIgAEQCADQfQANgIcIAMgATYCFCADIAA2AgxBACECDJwBC0HiACECDIIBC0EAIQACQCADKAI4IgJFDQAgAigCNCICRQ0AIAMgAhEAACEACwJAIAAEQCAAQRVGDQEgA0EANgIcIAMgATYCFCADQeoNNgIQIANBJjYCDEEAIQIMnAELQeEAIQIMggELIANB8wA2AhwgAyABNgIUIANBgBs2AhAgA0EVNgIMQQAhAgyaAQsgAy0AKSIAQSNrQQtJDQkCQCAAQQZLDQBBASAAdEHKAHFFDQAMCgtBACECIANBADYCHCADIAE2AhQgA0HtCTYCECADQQg2AgwMmQELQfIAIQIgASAERg2YASADKAIAIgAgBCABa2ohBSABIABrQQFqIQYCQANAIAEtAAAgAEGz1QBqLQAARw0FIABBAUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAyZAQsgAygCBCEAIANCADcDACADIAAgBkEBaiIBECsiAARAIANB8QA2AhwgAyABNgIUIAMgADYCDEEAIQIMmQELQd8AIQIMfwtBACEAAkAgAygCOCICRQ0AIAIoAjQiAkUNACADIAIRAAAhAAsCQCAABEAgAEEVRg0BIANBADYCHCADIAE2AhQgA0HqDTYCECADQSY2AgxBACECDJkBC0HeACECDH8LIANB8AA2AhwgAyABNgIUIANBgBs2AhAgA0EVNgIMQQAhAgyXAQsgAy0AKUEhRg0GIANBADYCHCADIAE2AhQgA0GRCjYCECADQQg2AgxBACECDJYBC0HvACECIAEgBEYNlQEgAygCACIAIAQgAWtqIQUgASAAa0ECaiEGAkADQCABLQAAIABBsNUAai0AAEcNAiAAQQJGDQEgA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ADQRI2AgggAyABIAEQMSIADQELQS4hAgwnCyADQS02AhwgAyABNgIUIAMgADYCDEEAIQIMPwtBACEAAkAgAygCOCICRQ0AIAIoAkwiAkUNACADIAIRAAAhAAsgAEUNACAAQRVHDQEgA0HYADYCHCADIAE2AhQgA0GzGzYCECADQRU2AgxBACECDD4LQcwAIQIMJAsgA0EANgIcIAMgATYCFCADQbMONgIQIANBHTYCDEEAIQIMPAsgASAERgRAQc4AIQIMPAsgAS0AACIAQSBGDQIgAEE6Rg0BCyADQQA6ACxBCSECDCELIAMoAgQhACADQQA2AgQgAyAAIAEQMCIADQEMAgsgAy0ALkEBcQRAQd4BIQIMIAsgAygCBCEAIANBADYCBCADIAAgARAwIgBFDQIgA0EqNgIcIAMgADYCDCADIAFBAWo2AhRBACECDDgLIANBywA2AhwgAyAANgIMIAMgAUEBajYCFEEAIQIMNwsgAUEBaiEBQcAAIQIMHQsgAUEBaiEBDCwLIAEgBEYEQEErIQIMNQsCQCABLQAAQQpGBEAgAUEBaiEBDAELIAMtAC5BwABxRQ0GCyADLQAyQYABcQRAQQAhAAJAIAMoAjgiAkUNACACKAJcIgJFDQAgAyACEQAAIQALIABFDRIgAEEVRgRAIANBBTYCHCADIAE2AhQgA0GbGzYCECADQRU2AgxBACECDDYLIANBADYCHCADIAE2AhQgA0GQDjYCECADQRQ2AgxBACECDDULIANBMmohAiADEDVBACEAAkAgAygCOCIGRQ0AIAYoAigiBkUNACADIAYRAAAhAAsgAA4WAgEABAQEBAQEBAQEBAQEBAQEBAQEAwQLIANBAToAMAsgAiACLwEAQcAAcjsBAAtBKyECDBgLIANBKTYCHCADIAE2AhQgA0GsGTYCECADQRU2AgxBACECDDALIANBADYCHCADIAE2AhQgA0HlCzYCECADQRE2AgxBACECDC8LIANBADYCHCADIAE2AhQgA0GlCzYCECADQQI2AgxBACECDC4LQQEhByADLwEyIgVBCHFFBEAgAykDIEIAUiEHCwJAIAMtADAEQEEBIQAgAy0AKUEFRg0BIAVBwABxRSAHc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AELIAFBAWohAQwBCyABQQFqIQEgAy0ALkEgcQ0AQQAhAiADQQA2AhwgAyABNgIUIANBoSE2AhAgA0EFNgIMDAILQQEhAiABIARHDQALCyAJQRBqJAAgAkUEQCADKAIMIQAMAQsgAyACNgIcQQAhACADKAIEIgFFDQAgAyABIAQgAygCCBEBACIBRQ0AIAMgBDYCFCADIAE2AgwgASEACyAAC74CAQJ/IABBADoAACAAQeQAaiIBQQFrQQA6AAAgAEEAOgACIABBADoAASABQQNrQQA6AAAgAUECa0EAOgAAIABBADoAAyABQQRrQQA6AABBACAAa0EDcSIBIABqIgBBADYCAEHkACABa0F8cSICIABqIgFBBGtBADYCAAJAIAJBCUkNACAAQQA2AgggAEEANgIEIAFBCGtBADYCACABQQxrQQA2AgAgAkEZSQ0AIABBADYCGCAAQQA2AhQgAEEANgIQIABBADYCDCABQRBrQQA2AgAgAUEUa0EANgIAIAFBGGtBADYCACABQRxrQQA2AgAgAiAAQQRxQRhyIgJrIgFBIEkNACAAIAJqIQADQCAAQgA3AxggAEIANwMQIABCADcDCCAAQgA3AwAgAEEgaiEAIAFBIGsiAUEfSw0ACwsLVgEBfwJAIAAoAgwNAAJAAkACQAJAIAAtADEOAwEAAwILIAAoAjgiAUUNACABKAIwIgFFDQAgACABEQAAIgENAwtBAA8LAAsgAEHKGTYCEEEOIQELIAELGgAgACgCDEUEQCAAQd4fNgIQIABBFTYCDAsLFAAgACgCDEEVRgRAIABBADYCDAsLFAAgACgCDEEWRgRAIABBADYCDAsLBwAgACgCDAsHACAAKAIQCwkAIAAgATYCEAsHACAAKAIUCysAAkAgAEEnTw0AQv//////CSAArYhCAYNQDQAgAEECdEHQOGooAgAPCwALFwAgAEEvTwRAAAsgAEECdEHsOWooAgALvwkBAX9B9C0hAQJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAC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wAC14CAgACAgICAgICAgICAgICAgICAgICAgICAgICAgIAAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAEGpzgALBQECAAEDAEHAzgALXwQFAAAFBQUFBQUFBQUFBQYFBQUFBQUFBQUFBQUABQAHCAUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQAFAAUABQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUAAAAFAEGp0AALBQEBAAEBAEHA0AALAQEAQdrQAAtBAgAAAAAAAAMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAAAAAAAAAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMAQanSAAsFAQEAAQEAQcDSAAsBAQBBytIACwYCAAAAAAIAQeHSAAs6AwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMAAAAAAAADAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwBBoNQAC50BTk9VTkNFRUNLT1VUTkVDVEVURUNSSUJFTFVTSEVURUFEU0VBUkNIUkdFQ1RJVklUWUxFTkRBUlZFT1RJRllQVElPTlNDSFNFQVlTVEFUQ0hHRVVFUllPUkRJUkVDVE9SVFJDSFBBUkFNRVRFUlVSQ0VCU0NSSUJFQVJET1dOQUNFSU5ETktDS1VCU0NSSUJFVFRQQ0VUU1BBRFRQLw==","base64"))})},3530:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.enumToMap=function(e,t=[],s=[]){const n=0===(t?.length??0),r=0===(s?.length??0);return Object.fromEntries(Object.entries(e).filter((([,e])=>"number"==typeof e&&(n||t.includes(e))&&(r||!s.includes(e)))))}},7467:(e,t,s)=>{"use strict";const{kClients:n}=s(257),r=s(3315),{kAgent:i,kMockAgentSet:A,kMockAgentGet:o,kDispatches:a,kIsMockActive:c,kNetConnect:l,kGetNetConnect:h,kOptions:g,kFactory:d,kMockAgentRegisterCallHistory:u,kMockAgentIsCallHistoryEnabled:I,kMockAgentAddCallHistoryLog:E,kMockAgentMockCallHistoryInstance:p,kMockAgentAcceptsNonStandardSearchParameters:C,kMockCallHistoryAddLog:B,kIgnoreTrailingSlash:Q}=s(3435),f=s(615),m=s(5846),{matchValue:y,normalizeSearchParams:S,buildAndValidateMockOptions:w}=s(991),{InvalidArgumentError:D,UndiciError:b}=s(4465),v=s(5497),N=s(164),{MockCallHistory:R}=s(4969);e.exports=class extends v{constructor(e={}){super(e);const t=w(e);if(this[l]=!0,this[c]=!0,this[I]=t.enableCallHistory??!1,this[C]=t.acceptNonStandardSearchParameters??!1,this[Q]=t.ignoreTrailingSlash??!1,e?.agent&&"function"!=typeof e.agent.dispatch)throw new D("Argument opts.agent must implement Agent");const s=e?.agent?e.agent:new r(e);this[i]=s,this[n]=s[n],this[g]=t,this[I]&&this[u]()}get(e){const t=this[Q]?e.replace(/\/$/,""):e;let s=this[o](t);return s||(s=this[d](t),this[A](t,s)),s}dispatch(e,t){this.get(e.origin),this[E](e);const s=this[C],n={...e};if(s&&n.path){const[e,t]=n.path.split("?"),r=S(t,s);n.path=`${e}?${r}`}return this[i].dispatch(n,t)}async close(){this.clearCallHistory(),await this[i].close(),this[n].clear()}deactivate(){this[c]=!1}activate(){this[c]=!0}enableNetConnect(e){if("string"==typeof e||"function"==typeof e||e instanceof RegExp)Array.isArray(this[l])?this[l].push(e):this[l]=[e];else{if("undefined"!=typeof e)throw new D("Unsupported matcher. Must be one of String|Function|RegExp.");this[l]=!0}}disableNetConnect(){this[l]=!1}enableCallHistory(){return this[I]=!0,this}disableCallHistory(){return this[I]=!1,this}getCallHistory(){return this[p]}clearCallHistory(){void 0!==this[p]&&this[p].clear()}get isMockActive(){return this[c]}[u](){void 0===this[p]&&(this[p]=new R)}[E](e){this[I]&&(this[u](),this[p][B](e))}[A](e,t){this[n].set(e,{count:0,dispatcher:t})}[d](e){const t=Object.assign({agent:this},this[g]);return this[g]&&1===this[g].connections?new f(e,t):new m(e,t)}[o](e){const t=this[n].get(e);if(t?.dispatcher)return t.dispatcher;if("string"!=typeof e){const t=this[d]("http://localhost:9999");return this[A](e,t),t}for(const[t,s]of Array.from(this[n]))if(s&&"string"!=typeof t&&y(t,e)){const t=this[d](e);return this[A](e,t),t[a]=s.dispatcher[a],t}}[h](){return this[l]}pendingInterceptors(){const e=this[n];return Array.from(e.entries()).flatMap((([e,t])=>t.dispatcher[a].map((t=>({...t,origin:e}))))).filter((({pending:e})=>e))}assertNoPendingInterceptors({pendingInterceptorsFormatter:e=new N}={}){const t=this.pendingInterceptors();if(0!==t.length)throw new b(1===t.length?`1 interceptor is pending:\n\n${e.format(t)}`.trim():`${t.length} interceptors are pending:\n\n${e.format(t)}`.trim())}}},4969:(e,t,s)=>{"use strict";const{kMockCallHistoryAddLog:n}=s(3435),{InvalidArgumentError:r}=s(4465);function i(e,t,s,n){switch(t.operator){case"OR":return n.push(...s(e)),n;case"AND":return s.call({logs:n},e);default:throw new r("options.operator must to be a case insensitive string equal to 'OR' or 'AND'")}}function A(e={}){const t={};if("operator"in e){if("string"!=typeof e.operator||"OR"!==e.operator.toUpperCase()&&"AND"!==e.operator.toUpperCase())throw new r("options.operator must to be a case insensitive string equal to 'OR' or 'AND'");return{...t,operator:e.operator.toUpperCase()}}return t}function o(e){return t=>{if("string"==typeof t||null==t)return this.logs.filter((s=>s[e]===t));if(t instanceof RegExp)return this.logs.filter((s=>t.test(s[e])));throw new r(`${e} parameter should be one of string, regexp, undefined or null`)}}class a{constructor(e={}){this.body=e.body,this.headers=e.headers,this.method=e.method;const t=function(e){try{const t=new URL(e.path,e.origin);return 0!==t.search.length||(t.search=new URLSearchParams(e.query).toString()),t}catch(e){throw new r("An error occurred when computing MockCallHistoryLog.url",{cause:e})}}(e);this.fullUrl=t.toString(),this.origin=t.origin,this.path=t.pathname,this.searchParams=Object.fromEntries(t.searchParams),this.protocol=t.protocol,this.host=t.host,this.port=t.port,this.hash=t.hash}toMap(){return new Map([["protocol",this.protocol],["host",this.host],["port",this.port],["origin",this.origin],["path",this.path],["hash",this.hash],["searchParams",this.searchParams],["fullUrl",this.fullUrl],["method",this.method],["body",this.body],["headers",this.headers]])}toString(){const e="->",t="|";let s="";return this.toMap().forEach(((n,r)=>{"string"!=typeof n&&null!=n||(s=`${s}${r}${e}${n}${t}`),("object"==typeof n&&null!==n||Array.isArray(n))&&(s=`${s}${r}${e}${JSON.stringify(n)}${t}`)})),s.slice(0,-1)}}class c{logs=[];calls(){return this.logs}firstCall(){return this.logs.at(0)}lastCall(){return this.logs.at(-1)}nthCall(e){if("number"!=typeof e)throw new r("nthCall must be called with a number");if(!Number.isInteger(e))throw new r("nthCall must be called with an integer");if(1!==Math.sign(e))throw new r("nthCall must be called with a positive value. use firstCall or lastCall instead");return this.logs.at(e-1)}filterCalls(e,t){if(0===this.logs.length)return this.logs;if("function"==typeof e)return this.logs.filter(e);if(e instanceof RegExp)return this.logs.filter((t=>e.test(t.toString())));if("object"==typeof e&&null!==e){if(0===Object.keys(e).length)return this.logs;const s={operator:"OR",...A(t)};let n=[];"protocol"in e&&(n=i(e.protocol,s,this.filterCallsByProtocol,n)),"host"in e&&(n=i(e.host,s,this.filterCallsByHost,n)),"port"in e&&(n=i(e.port,s,this.filterCallsByPort,n)),"origin"in e&&(n=i(e.origin,s,this.filterCallsByOrigin,n)),"path"in e&&(n=i(e.path,s,this.filterCallsByPath,n)),"hash"in e&&(n=i(e.hash,s,this.filterCallsByHash,n)),"fullUrl"in e&&(n=i(e.fullUrl,s,this.filterCallsByFullUrl,n)),"method"in e&&(n=i(e.method,s,this.filterCallsByMethod,n));return[...new Set(n)]}throw new r("criteria parameter should be one of function, regexp, or object")}filterCallsByProtocol=o.call(this,"protocol");filterCallsByHost=o.call(this,"host");filterCallsByPort=o.call(this,"port");filterCallsByOrigin=o.call(this,"origin");filterCallsByPath=o.call(this,"path");filterCallsByHash=o.call(this,"hash");filterCallsByFullUrl=o.call(this,"fullUrl");filterCallsByMethod=o.call(this,"method");clear(){this.logs=[]}[n](e){const t=new a(e);return this.logs.push(t),t}*[Symbol.iterator](){for(const e of this.calls())yield e}}e.exports.MockCallHistory=c,e.exports.MockCallHistoryLog=a},615:(e,t,s)=>{"use strict";const{promisify:n}=s(7975),r=s(1167),{buildMockDispatch:i}=s(991),{kDispatches:A,kMockAgent:o,kClose:a,kOriginalClose:c,kOrigin:l,kOriginalDispatch:h,kConnected:g,kIgnoreTrailingSlash:d}=s(3435),{MockInterceptor:u}=s(193),I=s(257),{InvalidArgumentError:E}=s(4465);class p extends r{constructor(e,t){if(!t||!t.agent||"function"!=typeof t.agent.dispatch)throw new E("Argument opts.agent must implement Agent");super(e,t),this[o]=t.agent,this[l]=e,this[d]=t.ignoreTrailingSlash??!1,this[A]=[],this[g]=1,this[h]=this.dispatch,this[c]=this.close.bind(this),this.dispatch=i.call(this),this.close=this[a]}get[I.kConnected](){return this[g]}intercept(e){return new u(e&&{ignoreTrailingSlash:this[d],...e},this[A])}cleanMocks(){this[A]=[]}async[a](){await n(this[c])(),this[g]=0,this[o][I.kClients].delete(this[l])}}e.exports=p},3123:(e,t,s)=>{"use strict";const{UndiciError:n}=s(4465),r=Symbol.for("undici.error.UND_MOCK_ERR_MOCK_NOT_MATCHED");class i extends n{constructor(e){super(e),this.name="MockNotMatchedError",this.message=e||"The request does not match any registered mock dispatches",this.code="UND_MOCK_ERR_MOCK_NOT_MATCHED"}static[Symbol.hasInstance](e){return e&&!0===e[r]}get[r](){return!0}}e.exports={MockNotMatchedError:i}},193:(e,t,s)=>{"use strict";const{getResponseData:n,buildKey:r,addMockDispatch:i}=s(991),{kDispatches:A,kDispatchKey:o,kDefaultHeaders:a,kDefaultTrailers:c,kContentLength:l,kMockDispatch:h,kIgnoreTrailingSlash:g}=s(3435),{InvalidArgumentError:d}=s(4465),{serializePathWithQuery:u}=s(2858);class I{constructor(e){this[h]=e}delay(e){if("number"!=typeof e||!Number.isInteger(e)||e<=0)throw new d("waitInMs must be a valid integer > 0");return this[h].delay=e,this}persist(){return this[h].persist=!0,this}times(e){if("number"!=typeof e||!Number.isInteger(e)||e<=0)throw new d("repeatTimes must be a valid integer > 0");return this[h].times=e,this}}e.exports.MockInterceptor=class{constructor(e,t){if("object"!=typeof e)throw new d("opts must be an object");if("undefined"==typeof e.path)throw new d("opts.path must be defined");if("undefined"==typeof e.method&&(e.method="GET"),"string"==typeof e.path)if(e.query)e.path=u(e.path,e.query);else{const t=new URL(e.path,"data://");e.path=t.pathname+t.search}"string"==typeof e.method&&(e.method=e.method.toUpperCase()),this[o]=r(e),this[A]=t,this[g]=e.ignoreTrailingSlash??!1,this[a]={},this[c]={},this[l]=!1}createMockScopeDispatchData({statusCode:e,data:t,responseOptions:s}){const r=n(t),i=this[l]?{"content-length":r.length}:{};return{statusCode:e,data:t,headers:{...this[a],...i,...s.headers},trailers:{...this[c],...s.trailers}}}validateReplyParameters(e){if("undefined"==typeof e.statusCode)throw new d("statusCode must be defined");if("object"!=typeof e.responseOptions||null===e.responseOptions)throw new d("responseOptions must be an object")}reply(e){if("function"==typeof e){const t=t=>{const s=e(t);if("object"!=typeof s||null===s)throw new d("reply options callback must return an object");const n={data:"",responseOptions:{},...s};return this.validateReplyParameters(n),{...this.createMockScopeDispatchData(n)}},s=i(this[A],this[o],t,{ignoreTrailingSlash:this[g]});return new I(s)}const t={statusCode:e,data:void 0===arguments[1]?"":arguments[1],responseOptions:void 0===arguments[2]?{}:arguments[2]};this.validateReplyParameters(t);const s=this.createMockScopeDispatchData(t),n=i(this[A],this[o],s,{ignoreTrailingSlash:this[g]});return new I(n)}replyWithError(e){if("undefined"==typeof e)throw new d("error must be defined");const t=i(this[A],this[o],{error:e},{ignoreTrailingSlash:this[g]});return new I(t)}defaultReplyHeaders(e){if("undefined"==typeof e)throw new d("headers must be defined");return this[a]=e,this}defaultReplyTrailers(e){if("undefined"==typeof e)throw new d("trailers must be defined");return this[c]=e,this}replyContentLength(){return this[l]=!0,this}},e.exports.MockScope=I},5846:(e,t,s)=>{"use strict";const{promisify:n}=s(7975),r=s(8542),{buildMockDispatch:i}=s(991),{kDispatches:A,kMockAgent:o,kClose:a,kOriginalClose:c,kOrigin:l,kOriginalDispatch:h,kConnected:g,kIgnoreTrailingSlash:d}=s(3435),{MockInterceptor:u}=s(193),I=s(257),{InvalidArgumentError:E}=s(4465);class p extends r{constructor(e,t){if(!t||!t.agent||"function"!=typeof t.agent.dispatch)throw new E("Argument opts.agent must implement Agent");super(e,t),this[o]=t.agent,this[l]=e,this[d]=t.ignoreTrailingSlash??!1,this[A]=[],this[g]=1,this[h]=this.dispatch,this[c]=this.close.bind(this),this.dispatch=i.call(this),this.close=this[a]}get[I.kConnected](){return this[g]}intercept(e){return new u(e&&{ignoreTrailingSlash:this[d],...e},this[A])}cleanMocks(){this[A]=[]}async[a](){await n(this[c])(),this[g]=0,this[o][I.kClients].delete(this[l])}}e.exports=p},3435:e=>{"use strict";e.exports={kAgent:Symbol("agent"),kOptions:Symbol("options"),kFactory:Symbol("factory"),kDispatches:Symbol("dispatches"),kDispatchKey:Symbol("dispatch key"),kDefaultHeaders:Symbol("default headers"),kDefaultTrailers:Symbol("default trailers"),kContentLength:Symbol("content length"),kMockAgent:Symbol("mock agent"),kMockAgentSet:Symbol("mock agent set"),kMockAgentGet:Symbol("mock agent get"),kMockDispatch:Symbol("mock dispatch"),kClose:Symbol("close"),kOriginalClose:Symbol("original agent close"),kOriginalDispatch:Symbol("original dispatch"),kOrigin:Symbol("origin"),kIsMockActive:Symbol("is mock active"),kNetConnect:Symbol("net connect"),kGetNetConnect:Symbol("get net connect"),kConnected:Symbol("connected"),kIgnoreTrailingSlash:Symbol("ignore trailing slash"),kMockAgentMockCallHistoryInstance:Symbol("mock agent mock call history name"),kMockAgentRegisterCallHistory:Symbol("mock agent register mock call history"),kMockAgentAddCallHistoryLog:Symbol("mock agent add call history log"),kMockAgentIsCallHistoryEnabled:Symbol("mock agent is call history enabled"),kMockAgentAcceptsNonStandardSearchParameters:Symbol("mock agent accepts non standard search parameters"),kMockCallHistoryAddLog:Symbol("mock call history add log")}},991:(e,t,s)=>{"use strict";const{MockNotMatchedError:n}=s(3123),{kDispatches:r,kMockAgent:i,kOriginalDispatch:A,kOrigin:o,kGetNetConnect:a}=s(3435),{serializePathWithQuery:c}=s(2858),{STATUS_CODES:l}=s(7067),{types:{isPromise:h}}=s(7975),{InvalidArgumentError:g}=s(4465);function d(e,t){return"string"==typeof e?e===t:e instanceof RegExp?e.test(t):"function"==typeof e&&!0===e(t)}function u(e){return Object.fromEntries(Object.entries(e).map((([e,t])=>[e.toLocaleLowerCase(),t])))}function I(e,t){if(!Array.isArray(e))return"function"==typeof e.get?e.get(t):u(e)[t.toLocaleLowerCase()];for(let s=0;s<e.length;s+=2)if(e[s].toLocaleLowerCase()===t.toLocaleLowerCase())return e[s+1]}function E(e){const t=e.slice(),s=[];for(let e=0;e<t.length;e+=2)s.push([t[e],t[e+1]]);return Object.fromEntries(s)}function p(e,t){if("function"==typeof e.headers)return Array.isArray(t)&&(t=E(t)),e.headers(t?u(t):{});if("undefined"==typeof e.headers)return!0;if("object"!=typeof t||"object"!=typeof e.headers)return!1;for(const[s,n]of Object.entries(e.headers)){if(!d(n,I(t,s)))return!1}return!0}function C(e){if("string"!=typeof e)return e;const t=e.split("?",3);if(2!==t.length)return e;const s=new URLSearchParams(t.pop());return s.sort(),[...t,s.toString()].join("?")}function B(e){return Buffer.isBuffer(e)||e instanceof Uint8Array||e instanceof ArrayBuffer?e:"object"==typeof e?JSON.stringify(e):e?e.toString():""}function Q(e,t){const s=t.query?c(t.path,t.query):t.path,r="string"==typeof s?C(s):s,i=m(r);let A=e.filter((({consumed:e})=>!e)).filter((({path:e,ignoreTrailingSlash:t})=>t?d(m(C(e)),i):d(C(e),r)));if(0===A.length)throw new n(`Mock dispatch not matched for path '${r}'`);if(A=A.filter((({method:e})=>d(e,t.method))),0===A.length)throw new n(`Mock dispatch not matched for method '${t.method}' on path '${r}'`);if(A=A.filter((({body:e})=>"undefined"==typeof e||d(e,t.body))),0===A.length)throw new n(`Mock dispatch not matched for body '${t.body}' on path '${r}'`);if(A=A.filter((e=>p(e,t.headers))),0===A.length){const e="object"==typeof t.headers?JSON.stringify(t.headers):t.headers;throw new n(`Mock dispatch not matched for headers '${e}' on path '${r}'`)}return A[0]}function f(e,t){const s=e.findIndex((e=>!!e.consumed&&function(e,{path:t,method:s,body:n,headers:r}){const i=d(e.path,t),A=d(e.method,s),o="undefined"==typeof e.body||d(e.body,n),a=p(e,r);return i&&A&&o&&a}(e,t)));-1!==s&&e.splice(s,1)}function m(e){for(;e.endsWith("/");)e=e.slice(0,-1);return 0===e.length&&(e="/"),e}function y(e){const{path:t,method:s,body:n,headers:r,query:i}=e;return{path:t,method:s,body:n,headers:r,query:i}}function S(e){const t=Object.keys(e),s=[];for(let n=0;n<t.length;++n){const r=t[n],i=e[r],A=Buffer.from(`${r}`);if(Array.isArray(i))for(let e=0;e<i.length;++e)s.push(A,Buffer.from(`${i[e]}`));else s.push(A,Buffer.from(`${i}`))}return s}function w(e){return l[e]||"unknown"}function D(e,t){const s=y(e),n=Q(this[r],s);n.timesInvoked++,n.data.callback&&(n.data={...n.data,...n.data.callback(e)});const{data:{statusCode:i,data:A,headers:o,trailers:a,error:c},delay:l,persist:g}=n,{timesInvoked:d,times:u}=n;if(n.consumed=!g&&d>=u,n.pending=d<u,null!==c)return f(this[r],s),t.onError(c),!0;function I(n,r=A){const c=Array.isArray(e.headers)?E(e.headers):e.headers,l="function"==typeof r?r({...e,headers:c}):r;if(h(l))return void l.then((e=>I(n,e)));const g=B(l),d=S(o),u=S(a);t.onConnect?.((e=>t.onError(e)),null),t.onHeaders?.(i,d,p,w(i)),t.onData?.(Buffer.from(g)),t.onComplete?.(u),f(n,s)}function p(){}return"number"==typeof l&&l>0?setTimeout((()=>{I(this[r])}),l):I(this[r]),!0}function b(e,t){const s=new URL(t);return!0===e||!(!Array.isArray(e)||!e.some((e=>d(e,s.host))))}e.exports={getResponseData:B,getMockDispatch:Q,addMockDispatch:function(e,t,s,n){const r={...{timesInvoked:0,times:1,persist:!1,consumed:!1,...n},...t,pending:!0,data:{error:null,..."function"==typeof s?{callback:s}:{...s}}};return e.push(r),r},deleteMockDispatch:f,buildKey:y,generateKeyValues:S,matchValue:d,getResponse:async function(e){const t=[];for await(const s of e)t.push(s);return Buffer.concat(t).toString("utf8")},getStatusText:w,mockDispatch:D,buildMockDispatch:function(){const e=this[i],t=this[o],s=this[A];return function(r,i){if(e.isMockActive)try{D.call(this,r,i)}catch(A){if("UND_MOCK_ERR_MOCK_NOT_MATCHED"!==A.code)throw A;{const o=e[a]();if(!1===o)throw new n(`${A.message}: subsequent request to origin ${t} was not allowed (net.connect disabled)`);if(!b(o,t))throw new n(`${A.message}: subsequent request to origin ${t} was not allowed (net.connect is not enabled for this origin)`);s.call(this,r,i)}}else s.call(this,r,i)}},checkNetConnect:b,buildAndValidateMockOptions:function(e){const{agent:t,...s}=e;if("enableCallHistory"in s&&"boolean"!=typeof s.enableCallHistory)throw new g("options.enableCallHistory must to be a boolean");if("acceptNonStandardSearchParameters"in s&&"boolean"!=typeof s.acceptNonStandardSearchParameters)throw new g("options.acceptNonStandardSearchParameters must to be a boolean");if("ignoreTrailingSlash"in s&&"boolean"!=typeof s.ignoreTrailingSlash)throw new g("options.ignoreTrailingSlash must to be a boolean");return s},getHeaderByName:I,buildHeadersFromArray:E,normalizeSearchParams:function(e){if("string"!=typeof e)return e;const t=new URLSearchParams(e),s=new URLSearchParams;for(let[e,n]of t.entries()){e=e.replace("[]","");if(/^(['"]).*\1$/.test(n))s.append(e,n);else if(n.includes(",")){const t=n.split(",");for(const n of t)s.append(e,n)}else s.append(e,n)}return s}}},164:(e,t,s)=>{"use strict";const{Transform:n}=s(7075),{Console:r}=s(7540),i=process.versions.icu?"✅":"Y ",A=process.versions.icu?"❌":"N ";e.exports=class{constructor({disableColors:e}={}){this.transform=new n({transform(e,t,s){s(null,e)}}),this.logger=new r({stdout:this.transform,inspectOptions:{colors:!e&&!process.env.CI}})}format(e){const t=e.map((({method:e,path:t,data:{statusCode:s},persist:n,times:r,timesInvoked:o,origin:a})=>({Method:e,Origin:a,Path:t,"Status code":s,Persistent:n?i:A,Invocations:o,Remaining:n?1/0:r-o})));return this.logger.table(t),this.transform.read().toString()}}},1313:(e,t,s)=>{"use strict";const n=s(3315),r=s(7467),{SnapshotRecorder:i}=s(6632),A=s(832),{InvalidArgumentError:o,UndiciError:a}=s(4465),{validateSnapshotMode:c}=s(5505),l=Symbol("kSnapshotRecorder"),h=Symbol("kSnapshotMode"),g=Symbol("kSnapshotPath"),d=Symbol("kSnapshotLoaded"),u=Symbol("kRealAgent");let I=!1;e.exports=class extends r{constructor(e={}){I||(process.emitWarning("SnapshotAgent is experimental and subject to change","ExperimentalWarning"),I=!0);const{mode:t="record",snapshotPath:s=null,...r}=e;if(super(r),c(t),("playback"===t||"update"===t)&&!s)throw new o(`snapshotPath is required when mode is '${t}'`);this[h]=t,this[g]=s,this[l]=new i({snapshotPath:this[g],mode:this[h],maxSnapshots:e.maxSnapshots,autoFlush:e.autoFlush,flushInterval:e.flushInterval,matchHeaders:e.matchHeaders,ignoreHeaders:e.ignoreHeaders,excludeHeaders:e.excludeHeaders,matchBody:e.matchBody,matchQuery:e.matchQuery,caseSensitive:e.caseSensitive,shouldRecord:e.shouldRecord,shouldPlayback:e.shouldPlayback,excludeUrls:e.excludeUrls}),this[d]=!1,"record"!==this[h]&&"update"!==this[h]||(this[u]=new n(e)),"playback"!==this[h]&&"update"!==this[h]||!this[g]||this.loadSnapshots().catch((()=>{}))}dispatch(e,t){t=A.wrap(t);const s=this[h];if("playback"===s||"update"===s){if(!this[d])return this.#me(e,t);const n=this[l].findSnapshot(e);if(n)return this.#ye(n,t);if("update"===s)return this.#Se(e,t);{const s=new a(`No snapshot found for ${e.method||"GET"} ${e.path}`);if(t.onError)return void t.onError(s);throw s}}if("record"===s)return this.#Se(e,t)}async#me(e,t){return await this.loadSnapshots(),this.dispatch(e,t)}#Se(e,t){const s={statusCode:null,headers:{},trailers:{},body:[]},n=this,r={onRequestStart(e,s){return t.onRequestStart(e,{...s,history:this.history})},onRequestUpgrade:(e,s,n,r)=>t.onRequestUpgrade(e,s,n,r),onResponseStart:(e,n,r,i)=>(s.statusCode=n,s.headers=r,t.onResponseStart(e,n,r,i)),onResponseData:(e,n)=>(s.body.push(n),t.onResponseData(e,n)),onResponseEnd(r,i){s.trailers=i;const A=Buffer.concat(s.body);n[l].record(e,{statusCode:s.statusCode,headers:s.headers,body:A,trailers:s.trailers}).then((()=>{t.onResponseEnd(r,i)})).catch((e=>{t.onResponseError(r,e)}))}};return this[u].dispatch(e,r)}#ye(e,t){try{const{response:s}=e,n={pause(){},resume(){},abort(e){this.aborted=!0,this.reason=e},aborted:!1,paused:!1};t.onRequestStart(n),t.onResponseStart(n,s.statusCode,s.headers);const r=Buffer.from(s.body,"base64");t.onResponseData(n,r),t.onResponseEnd(n,s.trailers)}catch(e){t.onError?.(e)}}async loadSnapshots(e){await this[l].loadSnapshots(e||this[g]),this[d]=!0,"playback"===this[h]&&this.#we()}async saveSnapshots(e){return this[l].saveSnapshots(e||this[g])}#we(){for(const e of this[l].getSnapshots()){const{request:t,responses:s,response:n}=e,r=new URL(t.url),i=this.get(r.origin),A=s?s[0]:n;A&&i.intercept({path:r.pathname+r.search,method:t.method,headers:t.headers,body:t.body}).reply(A.statusCode,A.body,{headers:A.headers,trailers:A.trailers}).persist()}}getRecorder(){return this[l]}getMode(){return this[h]}clearSnapshots(){this[l].clear()}resetCallCounts(){this[l].resetCallCounts()}deleteSnapshot(e){return this[l].deleteSnapshot(e)}getSnapshotInfo(e){return this[l].getSnapshotInfo(e)}replaceSnapshots(e){this[l].replaceSnapshots(e)}async close(){await this[l].close(),await(this[u]?.close()),await super.close()}}},6632:(e,t,s)=>{"use strict";const{writeFile:n,readFile:r,mkdir:i}=s(1455),{dirname:A,resolve:o}=s(6760),{setTimeout:a,clearTimeout:c}=s(7997),{InvalidArgumentError:l,UndiciError:h}=s(4465),{hashId:g,isUrlExcludedFactory:d,normalizeHeaders:u,createHeaderFilters:I}=s(5505);function E(e,t,s={}){const n=new URL(e.path,e.origin),r=e._normalizedHeaders||u(e.headers);return e._normalizedHeaders||(e._normalizedHeaders=r),{method:e.method||"GET",url:!1!==s.matchQuery?n.toString():`${n.origin}${n.pathname}`,headers:p(r,t,s),body:!1!==s.matchBody&&e.body?String(e.body):""}}function p(e,t,s={}){if(!e||"object"!=typeof e)return{};const{caseSensitive:n=!1}=s,r={},{ignore:i,exclude:A,match:o}=t;for(const[t,s]of Object.entries(e)){const e=n?t:t.toLowerCase();A.has(e)||(i.has(e)||(0===o.size||o.has(e))&&(r[e]=s))}return r}function C(e,t,s={}){if(!e||"object"!=typeof e)return{};const{caseSensitive:n=!1}=s,r={},{exclude:i}=t;for(const[t,s]of Object.entries(e)){const e=n?t:t.toLowerCase();i.has(e)||(r[e]=s)}return r}function B(e){const t=[e.method,e.url];if(e.headers&&"object"==typeof e.headers){const s=Object.keys(e.headers).sort();for(const n of s){const s=Array.isArray(e.headers[n])?e.headers[n]:[e.headers[n]];t.push(n);for(const e of s.sort())t.push(String(e))}}t.push(e.body);const s=t.join("|");return g(s)}e.exports={SnapshotRecorder:class{#De;#be;#ve=new Map;#Ne;#Re=1/0;#ke=!1;#Te;constructor(e={}){this.#Ne=e.snapshotPath,this.#Re=e.maxSnapshots||1/0,this.#ke=e.autoFlush||!1,this.flushInterval=e.flushInterval||3e4,this._flushTimer=null,this.matchOptions={matchHeaders:e.matchHeaders||[],ignoreHeaders:e.ignoreHeaders||[],excludeHeaders:e.excludeHeaders||[],matchBody:!1!==e.matchBody,matchQuery:!1!==e.matchQuery,caseSensitive:e.caseSensitive||!1},this.#Te=I(this.matchOptions),this.shouldRecord=e.shouldRecord||(()=>!0),this.shouldPlayback=e.shouldPlayback||(()=>!0),this.#be=d(e.excludeUrls),this.#ke&&this.#Ne&&this.#Fe()}async record(e,t){if(!this.shouldRecord(e))return;const s=new URL(e.path,e.origin).toString();if(this.#be(s))return;const n=E(e,this.#Te,this.matchOptions),r=B(n),i=u(t.headers),A={statusCode:t.statusCode,headers:C(i,this.#Te,this.matchOptions),body:Buffer.isBuffer(t.body)?t.body.toString("base64"):Buffer.from(String(t.body||"")).toString("base64"),trailers:t.trailers};if(this.#ve.size>=this.#Re&&!this.#ve.has(r)){const e=this.#ve.keys().next().value;this.#ve.delete(e)}const o=this.#ve.get(r);o&&o.responses?(o.responses.push(A),o.timestamp=(new Date).toISOString()):this.#ve.set(r,{request:n,responses:[A],callCount:0,timestamp:(new Date).toISOString()}),this.#ke&&this.#Ne&&this.#Me()}findSnapshot(e){if(!this.shouldPlayback(e))return;const t=new URL(e.path,e.origin).toString();if(this.#be(t))return;const s=B(E(e,this.#Te,this.matchOptions)),n=this.#ve.get(s);if(!n)return;const r=n.callCount||0,i=Math.min(r,n.responses.length-1);return n.callCount=r+1,{...n,response:n.responses[i]}}async loadSnapshots(e){const t=e||this.#Ne;if(!t)throw new l("Snapshot path is required");try{const e=await r(o(t),"utf8"),s=JSON.parse(e);if(Array.isArray(s)){this.#ve.clear();for(const{hash:e,snapshot:t}of s)this.#ve.set(e,t)}else this.#ve=new Map(Object.entries(s))}catch(e){if("ENOENT"!==e.code)throw new h(`Failed to load snapshots from ${t}`,{cause:e});this.#ve.clear()}}async saveSnapshots(e){const t=e||this.#Ne;if(!t)throw new l("Snapshot path is required");const s=o(t);await i(A(s),{recursive:!0});const r=Array.from(this.#ve.entries()).map((([e,t])=>({hash:e,snapshot:t})));await n(s,JSON.stringify(r,null,2),{flush:!0})}clear(){this.#ve.clear()}getSnapshots(){return Array.from(this.#ve.values())}size(){return this.#ve.size}resetCallCounts(){for(const e of this.#ve.values())e.callCount=0}deleteSnapshot(e){const t=B(E(e,this.#Te,this.matchOptions));return this.#ve.delete(t)}getSnapshotInfo(e){const t=B(E(e,this.#Te,this.matchOptions)),s=this.#ve.get(t);return s?{hash:t,request:s.request,responseCount:s.responses?s.responses.length:s.response?1:0,callCount:s.callCount||0,timestamp:s.timestamp}:null}replaceSnapshots(e){if(this.#ve.clear(),Array.isArray(e))for(const{hash:t,snapshot:s}of e)this.#ve.set(t,s);else e&&"object"==typeof e&&(this.#ve=new Map(Object.entries(e)))}#Fe(){return this.#Me()}#Ue(){this.#De&&(c(this.#De),this.saveSnapshots().catch((()=>{})),this.#De=null)}#Me(){this.#De=a((()=>{this.saveSnapshots().catch((()=>{})),this.#ke?this.#De?.refresh():this.#De=null}),1e3)}destroy(){this.#Ue(),this.#De&&(c(this.#De),this.#De=null)}async close(){this.#Ne&&0!==this.#ve.size&&await this.saveSnapshots(),this.destroy()}},formatRequestKey:E,createRequestHash:B,filterHeadersForMatching:p,filterHeadersForStorage:C,createHeaderFilters:I}},5505:(e,t,s)=>{"use strict";const{InvalidArgumentError:n}=s(4465);let r;try{r=s(7598)}catch{}const i=r?.hash?e=>r.hash("sha256",e,"base64url"):e=>Buffer.from(e).toString("base64url");function A(e){return Array.isArray(e)&&!(1&e.length)}const o=["record","playback","update"];e.exports={createHeaderFilters:function(e={}){const{ignoreHeaders:t=[],excludeHeaders:s=[],matchHeaders:n=[],caseSensitive:r=!1}=e;return{ignore:new Set(t.map((e=>r?e:e.toLowerCase()))),exclude:new Set(s.map((e=>r?e:e.toLowerCase()))),match:new Set(n.map((e=>r?e:e.toLowerCase())))}},hashId:i,isUndiciHeaders:A,normalizeHeaders:function(e){const t={};if(!e)return t;if(A(e)){for(let s=0;s<e.length;s+=2){const n=e[s],r=e[s+1];if(n&&void 0!==r){const e=Buffer.isBuffer(n)?n.toString():n,s=Buffer.isBuffer(r)?r.toString():r;t[e.toLowerCase()]=s}}return t}if(e&&"object"==typeof e)for(const[s,n]of Object.entries(e))s&&"string"==typeof s&&(t[s.toLowerCase()]=Array.isArray(n)?n.join(", "):String(n));return t},isUrlExcludedFactory:function(e=[]){return 0===e.length?()=>!1:function(t){let s;for(const n of e)if("string"==typeof n){if(s||(s=t.toLowerCase()),s.includes(n.toLowerCase()))return!0}else if(n instanceof RegExp&&n.test(t))return!0;return!1}},validateSnapshotMode:function(e){if(!o.includes(e))throw new n(`Invalid snapshot mode: ${e}. Must be one of: ${o.join(", ")}`)}}},9453:(e,t,s)=>{"use strict";const{safeHTTPMethods:n,pathHasQueryOrFragment:r}=s(2858),{serializePathWithQuery:i}=s(2858);e.exports={makeCacheKey:function(e){if(!e.origin)throw new Error("opts.origin is undefined");let t=e.path||"/";return e.query&&!r(e.path)&&(t=i(t,e.query)),{origin:e.origin.toString(),method:e.method,path:t,headers:e.headers}},normalizeHeaders:function(e){let t;if(null==e.headers)t={};else if("function"==typeof e.headers[Symbol.iterator]){t={};for(const s of e.headers){if(!Array.isArray(s))throw new Error("opts.headers is not a valid header map");const[e,n]=s;if("string"!=typeof e||"string"!=typeof n)throw new Error("opts.headers is not a valid header map");t[e.toLowerCase()]=n}}else{if("object"!=typeof e.headers)throw new Error("opts.headers is not an object");t={};for(const s of Object.keys(e.headers))t[s.toLowerCase()]=e.headers[s]}return t},assertCacheKey:function(e){if("object"!=typeof e)throw new TypeError("expected key to be object, got "+typeof e);for(const t of["origin","method","path"])if("string"!=typeof e[t])throw new TypeError(`expected key.${t} to be string, got ${typeof e[t]}`);if(void 0!==e.headers&&"object"!=typeof e.headers)throw new TypeError("expected headers to be object, got "+typeof e)},assertCacheValue:function(e){if("object"!=typeof e)throw new TypeError("expected value to be object, got "+typeof e);for(const t of["statusCode","cachedAt","staleAt","deleteAt"])if("number"!=typeof e[t])throw new TypeError(`expected value.${t} to be number, got ${typeof e[t]}`);if("string"!=typeof e.statusMessage)throw new TypeError("expected value.statusMessage to be string, got "+typeof e.statusMessage);if(null!=e.headers&&"object"!=typeof e.headers)throw new TypeError("expected value.rawHeaders to be object, got "+typeof e.headers);if(void 0!==e.vary&&"object"!=typeof e.vary)throw new TypeError("expected value.vary to be object, got "+typeof e.vary);if(void 0!==e.etag&&"string"!=typeof e.etag)throw new TypeError("expected value.etag to be string, got "+typeof e.etag)},parseCacheControlHeader:function(e){const t={};let s;if(Array.isArray(e)){s=[];for(const t of e)s.push(...t.split(","))}else s=e.split(",");for(let e=0;e<s.length;e++){const n=s[e].toLowerCase(),r=n.indexOf("=");let i,A;switch(-1!==r?(i=n.substring(0,r).trimStart(),A=n.substring(r+1)):i=n.trim(),i){case"min-fresh":case"max-stale":case"max-age":case"s-maxage":case"stale-while-revalidate":case"stale-if-error":{if(void 0===A||" "===A[0])continue;A.length>=2&&'"'===A[0]&&'"'===A[A.length-1]&&(A=A.substring(1,A.length-1));const e=parseInt(A,10);if(e!=e)continue;if("max-age"===i&&i in t&&t[i]>=e)continue;t[i]=e;break}case"private":case"no-cache":if(A){if('"'===A[0]){const n=[A.substring(1)];let r='"'===A[A.length-1];if(!r)for(let t=e+1;t<s.length;t++){const e=s[t],i=e.length;if(n.push(e.trim()),0!==i&&'"'===e[i-1]){r=!0;break}}if(r){let e=n[n.length-1];'"'===e[e.length-1]&&(e=e.substring(0,e.length-1),n[n.length-1]=e),t[i]=i in t?t[i].concat(n):n}}else t[i]=i in t?t[i].concat(A):[A];break}case"public":case"no-store":case"must-revalidate":case"proxy-revalidate":case"immutable":case"no-transform":case"must-understand":case"only-if-cached":if(A)continue;t[i]=!0;break;default:continue}}return t},parseVaryHeader:function(e,t){if("string"==typeof e&&e.includes("*"))return t;const s={},n="string"==typeof e?e.split(","):e;for(const e of n){const n=e.trim().toLowerCase();s[n]=t[n]??null}return s},isEtagUsable:function(e){return!(e.length<=2)&&('"'===e[0]&&'"'===e[e.length-1]?!('"'===e[1]||e.startsWith('"W/')):!(!e.startsWith('W/"')||'"'!==e[e.length-1])&&4!==e.length)},assertCacheMethods:function(e,t="CacheMethods"){if(!Array.isArray(e))throw new TypeError(`expected type of ${t} needs to be an array, got ${null===e?"null":typeof e}`);if(0===e.length)throw new TypeError(`${t} needs to have at least one method`);for(const s of e)if(!n.includes(s))throw new TypeError(`element of ${t}-array needs to be one of following values: ${n.join(", ")}, got ${s}`)},assertCacheStore:function(e,t="CacheStore"){if("object"!=typeof e||null===e)throw new TypeError(`expected type of ${t} to be a CacheStore, got ${null===e?"null":typeof e}`);for(const s of["get","createWriteStream","delete"])if("function"!=typeof e[s])throw new TypeError(`${t} needs to have a \`${s}()\` function`)}}},8851:e=>{"use strict";e.exports={parseHttpDate:function(e){switch(e[3]){case",":return function(e){if(29!==e.length||" "!==e[4]||" "!==e[7]||" "!==e[11]||" "!==e[16]||":"!==e[19]||":"!==e[22]||" "!==e[25]||"G"!==e[26]||"M"!==e[27]||"T"!==e[28])return;let t=-1;if("S"===e[0]&&"u"===e[1]&&"n"===e[2])t=0;else if("M"===e[0]&&"o"===e[1]&&"n"===e[2])t=1;else if("T"===e[0]&&"u"===e[1]&&"e"===e[2])t=2;else if("W"===e[0]&&"e"===e[1]&&"d"===e[2])t=3;else if("T"===e[0]&&"h"===e[1]&&"u"===e[2])t=4;else if("F"===e[0]&&"r"===e[1]&&"i"===e[2])t=5;else{if("S"!==e[0]||"a"!==e[1]||"t"!==e[2])return;t=6}let s=0;if("0"===e[5]){const t=e.charCodeAt(6);if(t<49||t>57)return;s=t-48}else{const t=e.charCodeAt(5);if(t<49||t>51)return;const n=e.charCodeAt(6);if(n<48||n>57)return;s=10*(t-48)+(n-48)}let n=-1;if("J"===e[8]&&"a"===e[9]&&"n"===e[10])n=0;else if("F"===e[8]&&"e"===e[9]&&"b"===e[10])n=1;else if("M"===e[8]&&"a"===e[9])if("r"===e[10])n=2;else{if("y"!==e[10])return;n=4}else if("J"===e[8])if("a"===e[9]&&"n"===e[10])n=0;else{if("u"!==e[9])return;if("n"===e[10])n=5;else{if("l"!==e[10])return;n=6}}else if("A"===e[8])if("p"===e[9]&&"r"===e[10])n=3;else{if("u"!==e[9]||"g"!==e[10])return;n=7}else if("S"===e[8]&&"e"===e[9]&&"p"===e[10])n=8;else if("O"===e[8]&&"c"===e[9]&&"t"===e[10])n=9;else if("N"===e[8]&&"o"===e[9]&&"v"===e[10])n=10;else{if("D"!==e[8]||"e"!==e[9]||"c"!==e[10])return;n=11}const r=e.charCodeAt(12);if(r<48||r>57)return;const i=e.charCodeAt(13);if(i<48||i>57)return;const A=e.charCodeAt(14);if(A<48||A>57)return;const o=e.charCodeAt(15);if(o<48||o>57)return;const a=1e3*(r-48)+100*(i-48)+10*(A-48)+(o-48);let c=0;if("0"===e[17]){const t=e.charCodeAt(18);if(t<48||t>57)return;c=t-48}else{const t=e.charCodeAt(17);if(t<48||t>50)return;const s=e.charCodeAt(18);if(s<48||s>57)return;if(50===t&&s>51)return;c=10*(t-48)+(s-48)}let l=0;if("0"===e[20]){const t=e.charCodeAt(21);if(t<48||t>57)return;l=t-48}else{const t=e.charCodeAt(20);if(t<48||t>53)return;const s=e.charCodeAt(21);if(s<48||s>57)return;l=10*(t-48)+(s-48)}let h=0;if("0"===e[23]){const t=e.charCodeAt(24);if(t<48||t>57)return;h=t-48}else{const t=e.charCodeAt(23);if(t<48||t>53)return;const s=e.charCodeAt(24);if(s<48||s>57)return;h=10*(t-48)+(s-48)}const g=new Date(Date.UTC(a,n,s,c,l,h));return g.getUTCDay()===t?g:void 0}(e);case" ":return function(e){if(24!==e.length||" "!==e[7]||" "!==e[10]||" "!==e[19])return;let t=-1;if("S"===e[0]&&"u"===e[1]&&"n"===e[2])t=0;else if("M"===e[0]&&"o"===e[1]&&"n"===e[2])t=1;else if("T"===e[0]&&"u"===e[1]&&"e"===e[2])t=2;else if("W"===e[0]&&"e"===e[1]&&"d"===e[2])t=3;else if("T"===e[0]&&"h"===e[1]&&"u"===e[2])t=4;else if("F"===e[0]&&"r"===e[1]&&"i"===e[2])t=5;else{if("S"!==e[0]||"a"!==e[1]||"t"!==e[2])return;t=6}let s=-1;if("J"===e[4]&&"a"===e[5]&&"n"===e[6])s=0;else if("F"===e[4]&&"e"===e[5]&&"b"===e[6])s=1;else if("M"===e[4]&&"a"===e[5])if("r"===e[6])s=2;else{if("y"!==e[6])return;s=4}else if("J"===e[4])if("a"===e[5]&&"n"===e[6])s=0;else{if("u"!==e[5])return;if("n"===e[6])s=5;else{if("l"!==e[6])return;s=6}}else if("A"===e[4])if("p"===e[5]&&"r"===e[6])s=3;else{if("u"!==e[5]||"g"!==e[6])return;s=7}else if("S"===e[4]&&"e"===e[5]&&"p"===e[6])s=8;else if("O"===e[4]&&"c"===e[5]&&"t"===e[6])s=9;else if("N"===e[4]&&"o"===e[5]&&"v"===e[6])s=10;else{if("D"!==e[4]||"e"!==e[5]||"c"!==e[6])return;s=11}let n=0;if(" "===e[8]){const t=e.charCodeAt(9);if(t<49||t>57)return;n=t-48}else{const t=e.charCodeAt(8);if(t<49||t>51)return;const s=e.charCodeAt(9);if(s<48||s>57)return;n=10*(t-48)+(s-48)}let r=0;if("0"===e[11]){const t=e.charCodeAt(12);if(t<48||t>57)return;r=t-48}else{const t=e.charCodeAt(11);if(t<48||t>50)return;const s=e.charCodeAt(12);if(s<48||s>57)return;if(50===t&&s>51)return;r=10*(t-48)+(s-48)}let i=0;if("0"===e[14]){const t=e.charCodeAt(15);if(t<48||t>57)return;i=t-48}else{const t=e.charCodeAt(14);if(t<48||t>53)return;const s=e.charCodeAt(15);if(s<48||s>57)return;i=10*(t-48)+(s-48)}let A=0;if("0"===e[17]){const t=e.charCodeAt(18);if(t<48||t>57)return;A=t-48}else{const t=e.charCodeAt(17);if(t<48||t>53)return;const s=e.charCodeAt(18);if(s<48||s>57)return;A=10*(t-48)+(s-48)}const o=e.charCodeAt(20);if(o<48||o>57)return;const a=e.charCodeAt(21);if(a<48||a>57)return;const c=e.charCodeAt(22);if(c<48||c>57)return;const l=e.charCodeAt(23);if(l<48||l>57)return;const h=1e3*(o-48)+100*(a-48)+10*(c-48)+(l-48),g=new Date(Date.UTC(h,s,n,r,i,A));return g.getUTCDay()===t?g:void 0}(e);default:return function(e){let t=-1,s=-1;if("S"===e[0])"u"===e[1]&&"n"===e[2]&&"d"===e[3]&&"a"===e[4]&&"y"===e[5]?(s=0,t=6):"a"===e[1]&&"t"===e[2]&&"u"===e[3]&&"r"===e[4]&&"d"===e[5]&&"a"===e[6]&&"y"===e[7]&&(s=6,t=8);else if("M"===e[0]&&"o"===e[1]&&"n"===e[2]&&"d"===e[3]&&"a"===e[4]&&"y"===e[5])s=1,t=6;else if("T"===e[0])"u"===e[1]&&"e"===e[2]&&"s"===e[3]&&"d"===e[4]&&"a"===e[5]&&"y"===e[6]?(s=2,t=7):"h"===e[1]&&"u"===e[2]&&"r"===e[3]&&"s"===e[4]&&"d"===e[5]&&"a"===e[6]&&"y"===e[7]&&(s=4,t=8);else if("W"===e[0]&&"e"===e[1]&&"d"===e[2]&&"n"===e[3]&&"e"===e[4]&&"s"===e[5]&&"d"===e[6]&&"a"===e[7]&&"y"===e[8])s=3,t=9;else{if("F"!==e[0]||"r"!==e[1]||"i"!==e[2]||"d"!==e[3]||"a"!==e[4]||"y"!==e[5])return;s=5,t=6}if(","!==e[t]||e.length-t-1!=23||" "!==e[t+1]||"-"!==e[t+4]||"-"!==e[t+8]||" "!==e[t+11]||":"!==e[t+14]||":"!==e[t+17]||" "!==e[t+20]||"G"!==e[t+21]||"M"!==e[t+22]||"T"!==e[t+23])return;let n=0;if("0"===e[t+2]){const s=e.charCodeAt(t+3);if(s<49||s>57)return;n=s-48}else{const s=e.charCodeAt(t+2);if(s<49||s>51)return;const r=e.charCodeAt(t+3);if(r<48||r>57)return;n=10*(s-48)+(r-48)}let r=-1;if("J"===e[t+5]&&"a"===e[t+6]&&"n"===e[t+7])r=0;else if("F"===e[t+5]&&"e"===e[t+6]&&"b"===e[t+7])r=1;else if("M"===e[t+5]&&"a"===e[t+6]&&"r"===e[t+7])r=2;else if("A"===e[t+5]&&"p"===e[t+6]&&"r"===e[t+7])r=3;else if("M"===e[t+5]&&"a"===e[t+6]&&"y"===e[t+7])r=4;else if("J"===e[t+5]&&"u"===e[t+6]&&"n"===e[t+7])r=5;else if("J"===e[t+5]&&"u"===e[t+6]&&"l"===e[t+7])r=6;else if("A"===e[t+5]&&"u"===e[t+6]&&"g"===e[t+7])r=7;else if("S"===e[t+5]&&"e"===e[t+6]&&"p"===e[t+7])r=8;else if("O"===e[t+5]&&"c"===e[t+6]&&"t"===e[t+7])r=9;else if("N"===e[t+5]&&"o"===e[t+6]&&"v"===e[t+7])r=10;else{if("D"!==e[t+5]||"e"!==e[t+6]||"c"!==e[t+7])return;r=11}const i=e.charCodeAt(t+9);if(i<48||i>57)return;const A=e.charCodeAt(t+10);if(A<48||A>57)return;let o=10*(i-48)+(A-48);o+=o<70?2e3:1900;let a=0;if("0"===e[t+12]){const s=e.charCodeAt(t+13);if(s<48||s>57)return;a=s-48}else{const s=e.charCodeAt(t+12);if(s<48||s>50)return;const n=e.charCodeAt(t+13);if(n<48||n>57)return;if(50===s&&n>51)return;a=10*(s-48)+(n-48)}let c=0;if("0"===e[t+15]){const s=e.charCodeAt(t+16);if(s<48||s>57)return;c=s-48}else{const s=e.charCodeAt(t+15);if(s<48||s>53)return;const n=e.charCodeAt(t+16);if(n<48||n>57)return;c=10*(s-48)+(n-48)}let l=0;if("0"===e[t+18]){const s=e.charCodeAt(t+19);if(s<48||s>57)return;l=s-48}else{const s=e.charCodeAt(t+18);if(s<48||s>53)return;const n=e.charCodeAt(t+19);if(n<48||n>57)return;l=10*(s-48)+(n-48)}const h=new Date(Date.UTC(o,r,n,a,c,l));return h.getUTCDay()===s?h:void 0}(e)}}}},9250:e=>{"use strict";e.exports={createDeferredPromise:function(){let e,t;return{promise:new Promise(((s,n)=>{e=s,t=n})),resolve:e,reject:t}}}},4304:(e,t,s)=>{"use strict";const{kConnected:n,kPending:r,kRunning:i,kSize:A,kFree:o,kQueued:a}=s(257);e.exports={ClientStats:class{constructor(e){this.connected=e[n],this.pending=e[r],this.running=e[i],this.size=e[A]}},PoolStats:class{constructor(e){this.connected=e[n],this.free=e[o],this.pending=e[r],this.queued=e[a],this.running=e[i],this.size=e[A]}}}},3801:e=>{"use strict";let t=0;const s=1e3;let n;const r=Symbol("kFastTimer"),i=[];function A(){t+=499;let e=0,s=i.length;for(;e<s;){const n=i[e];0===n._state?(n._idleStart=t-499,n._state=1):1===n._state&&t>=n._idleStart+n._idleTimeout&&(n._state=-1,n._idleStart=-1,n._onTimeout(n._timerArg)),-1===n._state?(n._state=-2,0!=--s&&(i[e]=i[s])):++e}i.length=s,0!==i.length&&o()}function o(){n?.refresh?n.refresh():(clearTimeout(n),n=setTimeout(A,499),n?.unref())}class a{[r]=!0;_state=-2;_idleTimeout=-1;_idleStart=-1;_onTimeout;_timerArg;constructor(e,t,s){this._onTimeout=e,this._idleTimeout=t,this._timerArg=s,this.refresh()}refresh(){-2===this._state&&i.push(this),n&&1!==i.length||o(),this._state=0}clear(){this._state=-1,this._idleStart=-1}}e.exports={setTimeout:(e,t,n)=>t<=s?setTimeout(e,t,n):new a(e,t,n),clearTimeout(e){e[r]?e.clear():clearTimeout(e)},setFastTimeout:(e,t,s)=>new a(e,t,s),clearFastTimeout(e){e.clear()},now:()=>t,tick(e=0){t+=e-s+1,A(),A()},reset(){t=0,i.length=0,clearTimeout(n),n=null},kFastTimer:r}},4420:(e,t,s)=>{"use strict";const n=s(4589),{kConstruct:r}=s(257),{urlEquals:i,getFieldValues:A}=s(3932),{kEnumerableProperty:o,isDisturbed:a}=s(2858),{webidl:c}=s(6097),{cloneResponse:l,fromInnerResponse:h,getResponseState:g}=s(4821),{Request:d,fromInnerRequest:u,getRequestState:I}=s(4609),{fetching:E}=s(7388),{urlIsHttpHttpsScheme:p,readAllBytes:C}=s(6686),{createDeferredPromise:B}=s(9250);class Q{#Le;constructor(){arguments[0]!==r&&c.illegalConstructor(),c.util.markAsUncloneable(this),this.#Le=arguments[1]}async match(e,t={}){c.brandCheck(this,Q);const s="Cache.match";c.argumentLengthCheck(arguments,1,s),e=c.converters.RequestInfo(e),t=c.converters.CacheQueryOptions(t,s,"options");const n=this.#Pe(e,t,1);if(0!==n.length)return n[0]}async matchAll(e=void 0,t={}){c.brandCheck(this,Q);return void 0!==e&&(e=c.converters.RequestInfo(e)),t=c.converters.CacheQueryOptions(t,"Cache.matchAll","options"),this.#Pe(e,t)}async add(e){c.brandCheck(this,Q);c.argumentLengthCheck(arguments,1,"Cache.add");const t=[e=c.converters.RequestInfo(e)],s=this.addAll(t);return await s}async addAll(e){c.brandCheck(this,Q);const t="Cache.addAll";c.argumentLengthCheck(arguments,1,t);const s=[],n=[];for(let s of e){if(void 0===s)throw c.errors.conversionFailed({prefix:t,argument:"Argument 1",types:["undefined is not allowed"]});if(s=c.converters.RequestInfo(s),"string"==typeof s)continue;const e=I(s);if(!p(e.url)||"GET"!==e.method)throw c.errors.exception({header:t,message:"Expected http/s scheme when method is not GET."})}const r=[];for(const i of e){const e=I(new d(i));if(!p(e.url))throw c.errors.exception({header:t,message:"Expected http/s scheme."});e.initiator="fetch",e.destination="subresource",n.push(e);const o=B();r.push(E({request:e,processResponse(e){if("error"===e.type||206===e.status||e.status<200||e.status>299)o.reject(c.errors.exception({header:"Cache.addAll",message:"Received an invalid status code or the request failed."}));else if(e.headersList.contains("vary")){const t=A(e.headersList.get("vary"));for(const e of t)if("*"===e){o.reject(c.errors.exception({header:"Cache.addAll",message:"invalid vary field value"}));for(const e of r)e.abort();return}}},processResponseEndOfBody(e){e.aborted?o.reject(new DOMException("aborted","AbortError")):o.resolve(e)}})),s.push(o.promise)}const i=Promise.all(s),o=await i,a=[];let l=0;for(const e of o){const t={type:"put",request:n[l],response:e};a.push(t),l++}const h=B();let g=null;try{this.#He(a)}catch(e){g=e}return queueMicrotask((()=>{null===g?h.resolve(void 0):h.reject(g)})),h.promise}async put(e,t){c.brandCheck(this,Q);const s="Cache.put";c.argumentLengthCheck(arguments,2,s),e=c.converters.RequestInfo(e),t=c.converters.Response(t,s,"response");let n=null;if(n=c.is.Request(e)?I(e):I(new d(e)),!p(n.url)||"GET"!==n.method)throw c.errors.exception({header:s,message:"Expected an http/s scheme when method is not GET"});const r=g(t);if(206===r.status)throw c.errors.exception({header:s,message:"Got 206 status"});if(r.headersList.contains("vary")){const e=A(r.headersList.get("vary"));for(const t of e)if("*"===t)throw c.errors.exception({header:s,message:"Got * vary field value"})}if(r.body&&(a(r.body.stream)||r.body.stream.locked))throw c.errors.exception({header:s,message:"Response body is locked or disturbed"});const i=l(r),o=B();if(null!=r.body){const e=r.body.stream.getReader();C(e,o.resolve,o.reject)}else o.resolve(void 0);const h=[],u={type:"put",request:n,response:i};h.push(u);const E=await o.promise;null!=i.body&&(i.body.source=E);const f=B();let m=null;try{this.#He(h)}catch(e){m=e}return queueMicrotask((()=>{null===m?f.resolve():f.reject(m)})),f.promise}async delete(e,t={}){c.brandCheck(this,Q);const s="Cache.delete";c.argumentLengthCheck(arguments,1,s),e=c.converters.RequestInfo(e),t=c.converters.CacheQueryOptions(t,s,"options");let r=null;if(c.is.Request(e)){if(r=I(e),"GET"!==r.method&&!t.ignoreMethod)return!1}else n("string"==typeof e),r=I(new d(e));const i=[],A={type:"delete",request:r,options:t};i.push(A);const o=B();let a,l=null;try{a=this.#He(i)}catch(e){l=e}return queueMicrotask((()=>{null===l?o.resolve(!!a?.length):o.reject(l)})),o.promise}async keys(e=void 0,t={}){c.brandCheck(this,Q);void 0!==e&&(e=c.converters.RequestInfo(e)),t=c.converters.CacheQueryOptions(t,"Cache.keys","options");let s=null;if(void 0!==e)if(c.is.Request(e)){if(s=I(e),"GET"!==s.method&&!t.ignoreMethod)return[]}else"string"==typeof e&&(s=I(new d(e)));const n=B(),r=[];if(void 0===e)for(const e of this.#Le)r.push(e[0]);else{const e=this.#xe(s,t);for(const t of e)r.push(t[0])}return queueMicrotask((()=>{const e=[];for(const t of r){const s=u(t,void 0,(new AbortController).signal,"immutable");e.push(s)}n.resolve(Object.freeze(e))})),n.promise}#He(e){const t=this.#Le,s=[...t],r=[],i=[];try{for(const s of e){if("delete"!==s.type&&"put"!==s.type)throw c.errors.exception({header:"Cache.#batchCacheOperations",message:'operation type does not match "delete" or "put"'});if("delete"===s.type&&null!=s.response)throw c.errors.exception({header:"Cache.#batchCacheOperations",message:"delete operation should not have an associated response"});if(this.#xe(s.request,s.options,r).length)throw new DOMException("???","InvalidStateError");let e;if("delete"===s.type){if(e=this.#xe(s.request,s.options),0===e.length)return[];for(const s of e){const e=t.indexOf(s);n(-1!==e),t.splice(e,1)}}else if("put"===s.type){if(null==s.response)throw c.errors.exception({header:"Cache.#batchCacheOperations",message:"put operation should have an associated response"});const i=s.request;if(!p(i.url))throw c.errors.exception({header:"Cache.#batchCacheOperations",message:"expected http or https scheme"});if("GET"!==i.method)throw c.errors.exception({header:"Cache.#batchCacheOperations",message:"not get method"});if(null!=s.options)throw c.errors.exception({header:"Cache.#batchCacheOperations",message:"options must not be defined"});e=this.#xe(s.request);for(const s of e){const e=t.indexOf(s);n(-1!==e),t.splice(e,1)}t.push([s.request,s.response]),r.push([s.request,s.response])}i.push([s.request,s.response])}return i}catch(e){throw this.#Le.length=0,this.#Le=s,e}}#xe(e,t,s){const n=[],r=s??this.#Le;for(const s of r){const[r,i]=s;this.#Ye(e,r,i,t)&&n.push(s)}return n}#Ye(e,t,s=null,n){const r=new URL(e.url),o=new URL(t.url);if(n?.ignoreSearch&&(o.search="",r.search=""),!i(r,o,!0))return!1;if(null==s||n?.ignoreVary||!s.headersList.contains("vary"))return!0;const a=A(s.headersList.get("vary"));for(const s of a){if("*"===s)return!1;if(t.headersList.get(s)!==e.headersList.get(s))return!1}return!0}#Pe(e,t,s=1/0){let n=null;if(void 0!==e)if(c.is.Request(e)){if(n=I(e),"GET"!==n.method&&!t.ignoreMethod)return[]}else"string"==typeof e&&(n=I(new d(e)));const r=[];if(void 0===e)for(const e of this.#Le)r.push(e[1]);else{const e=this.#xe(n,t);for(const t of e)r.push(t[1])}const i=[];for(const e of r){const t=h(e,"immutable");if(i.push(t.clone()),i.length>=s)break}return Object.freeze(i)}}Object.defineProperties(Q.prototype,{[Symbol.toStringTag]:{value:"Cache",configurable:!0},match:o,matchAll:o,add:o,addAll:o,put:o,delete:o,keys:o});const f=[{key:"ignoreSearch",converter:c.converters.boolean,defaultValue:()=>!1},{key:"ignoreMethod",converter:c.converters.boolean,defaultValue:()=>!1},{key:"ignoreVary",converter:c.converters.boolean,defaultValue:()=>!1}];c.converters.CacheQueryOptions=c.dictionaryConverter(f),c.converters.MultiCacheQueryOptions=c.dictionaryConverter([...f,{key:"cacheName",converter:c.converters.DOMString}]),c.converters.Response=c.interfaceConverter(c.is.Response,"Response"),c.converters["sequence<RequestInfo>"]=c.sequenceConverter(c.converters.RequestInfo),e.exports={Cache:Q}},6939:(e,t,s)=>{"use strict";const{Cache:n}=s(4420),{webidl:r}=s(6097),{kEnumerableProperty:i}=s(2858),{kConstruct:A}=s(257);class o{#Ve=new Map;constructor(){arguments[0]!==A&&r.illegalConstructor(),r.util.markAsUncloneable(this)}async match(e,t={}){if(r.brandCheck(this,o),r.argumentLengthCheck(arguments,1,"CacheStorage.match"),e=r.converters.RequestInfo(e),null!=(t=r.converters.MultiCacheQueryOptions(t)).cacheName){if(this.#Ve.has(t.cacheName)){const s=this.#Ve.get(t.cacheName),r=new n(A,s);return await r.match(e,t)}}else for(const s of this.#Ve.values()){const r=new n(A,s),i=await r.match(e,t);if(void 0!==i)return i}}async has(e){r.brandCheck(this,o);const t="CacheStorage.has";return r.argumentLengthCheck(arguments,1,t),e=r.converters.DOMString(e,t,"cacheName"),this.#Ve.has(e)}async open(e){r.brandCheck(this,o);const t="CacheStorage.open";if(r.argumentLengthCheck(arguments,1,t),e=r.converters.DOMString(e,t,"cacheName"),this.#Ve.has(e)){const t=this.#Ve.get(e);return new n(A,t)}const s=[];return this.#Ve.set(e,s),new n(A,s)}async delete(e){r.brandCheck(this,o);const t="CacheStorage.delete";return r.argumentLengthCheck(arguments,1,t),e=r.converters.DOMString(e,t,"cacheName"),this.#Ve.delete(e)}async keys(){r.brandCheck(this,o);return[...this.#Ve.keys()]}}Object.defineProperties(o.prototype,{[Symbol.toStringTag]:{value:"CacheStorage",configurable:!0},match:i,has:i,open:i,delete:i,keys:i}),e.exports={CacheStorage:o}},3932:(e,t,s)=>{"use strict";const n=s(4589),{URLSerializer:r}=s(9934),{isValidHeaderName:i}=s(6686);e.exports={urlEquals:function(e,t,s=!1){return r(e,s)===r(t,s)},getFieldValues:function(e){n(null!==e);const t=[];for(let s of e.split(","))s=s.trim(),i(s)&&t.push(s);return t}}},3042:e=>{"use strict";e.exports={maxAttributeValueSize:1024,maxNameValuePairSize:4096}},9391:(e,t,s)=>{"use strict";const{parseSetCookie:n}=s(6712),{stringify:r}=s(9871),{webidl:i}=s(6097),{Headers:A}=s(6558),o=i.brandCheckMultiple([A,globalThis.Headers].filter(Boolean));function a(e,t){i.argumentLengthCheck(arguments,2,"setCookie"),o(e),t=i.converters.Cookie(t);const s=r(t);s&&e.append("set-cookie",s,!0)}i.converters.DeleteCookieAttributes=i.dictionaryConverter([{converter:i.nullableConverter(i.converters.DOMString),key:"path",defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:"domain",defaultValue:()=>null}]),i.converters.Cookie=i.dictionaryConverter([{converter:i.converters.DOMString,key:"name"},{converter:i.converters.DOMString,key:"value"},{converter:i.nullableConverter((e=>"number"==typeof e?i.converters["unsigned long long"](e):new Date(e))),key:"expires",defaultValue:()=>null},{converter:i.nullableConverter(i.converters["long long"]),key:"maxAge",defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:"domain",defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:"path",defaultValue:()=>null},{converter:i.nullableConverter(i.converters.boolean),key:"secure",defaultValue:()=>null},{converter:i.nullableConverter(i.converters.boolean),key:"httpOnly",defaultValue:()=>null},{converter:i.converters.USVString,key:"sameSite",allowedValues:["Strict","Lax","None"]},{converter:i.sequenceConverter(i.converters.DOMString),key:"unparsed",defaultValue:()=>[]}]),e.exports={getCookies:function(e){i.argumentLengthCheck(arguments,1,"getCookies"),o(e);const t=e.get("cookie"),s={};if(!t)return s;for(const e of t.split(";")){const[t,...n]=e.split("=");s[t.trim()]=n.join("=")}return s},deleteCookie:function(e,t,s){o(e);const n="deleteCookie";i.argumentLengthCheck(arguments,2,n),t=i.converters.DOMString(t,n,"name"),s=i.converters.DeleteCookieAttributes(s),a(e,{name:t,value:"",expires:new Date(0),...s})},getSetCookies:function(e){i.argumentLengthCheck(arguments,1,"getSetCookies"),o(e);const t=e.getSetCookie();return t?t.map((e=>n(e))):[]},setCookie:a,parseCookie:function(e){return e=i.converters.DOMString(e),n(e)}}},6712:(e,t,s)=>{"use strict";const{maxNameValuePairSize:n,maxAttributeValueSize:r}=s(3042),{isCTLExcludingHtab:i}=s(9871),{collectASequenceOfCodePointsFast:A}=s(9934),o=s(4589),{unescape:a}=s(1792);function c(e,t={}){if(0===e.length)return t;o(";"===e[0]);let s="";(e=e.slice(1)).includes(";")?(s=A(";",e,{position:0}),e=e.slice(s.length)):(s=e,e="");let n="",i="";if(s.includes("=")){const e={position:0};n=A("=",s,e),i=s.slice(e.position+1)}else n=s;if(n=n.trim(),i=i.trim(),i.length>r)return c(e,t);const a=n.toLowerCase();if("expires"===a){const e=new Date(i);t.expires=e}else if("max-age"===a){const s=i.charCodeAt(0);if((s<48||s>57)&&"-"!==i[0])return c(e,t);if(!/^\d+$/.test(i))return c(e,t);const n=Number(i);t.maxAge=n}else if("domain"===a){let e=i;"."===e[0]&&(e=e.slice(1)),e=e.toLowerCase(),t.domain=e}else if("path"===a){let e="";e=0===i.length||"/"!==i[0]?"/":i,t.path=e}else if("secure"===a)t.secure=!0;else if("httponly"===a)t.httpOnly=!0;else if("samesite"===a){let e="Default";const s=i.toLowerCase();s.includes("none")&&(e="None"),s.includes("strict")&&(e="Strict"),s.includes("lax")&&(e="Lax"),t.sameSite=e}else t.unparsed??=[],t.unparsed.push(`${n}=${i}`);return c(e,t)}e.exports={parseSetCookie:function(e){if(i(e))return null;let t="",s="",r="",o="";if(e.includes(";")){const n={position:0};t=A(";",e,n),s=e.slice(n.position)}else t=e;if(t.includes("=")){const e={position:0};r=A("=",t,e),o=t.slice(e.position+1)}else o=t;return r=r.trim(),o=o.trim(),r.length+o.length>n?null:{name:r,value:a(o),...c(s)}},parseUnparsedAttributes:c}},9871:e=>{"use strict";function t(e){for(let t=0;t<e.length;++t){const s=e.charCodeAt(t);if(s<33||s>126||34===s||40===s||41===s||60===s||62===s||64===s||44===s||59===s||58===s||92===s||47===s||91===s||93===s||63===s||61===s||123===s||125===s)throw new Error("Invalid cookie name")}}function s(e){let t=e.length,s=0;if('"'===e[0]){if(1===t||'"'!==e[t-1])throw new Error("Invalid cookie value");--t,++s}for(;s<t;){const t=e.charCodeAt(s++);if(t<33||t>126||34===t||44===t||59===t||92===t)throw new Error("Invalid cookie value")}}function n(e){for(let t=0;t<e.length;++t){const s=e.charCodeAt(t);if(s<32||127===s||59===s)throw new Error("Invalid cookie path")}}const r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],i=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],A=Array(61).fill(0).map(((e,t)=>t.toString().padStart(2,"0")));function o(e){return"number"==typeof e&&(e=new Date(e)),`${r[e.getUTCDay()]}, ${A[e.getUTCDate()]} ${i[e.getUTCMonth()]} ${e.getUTCFullYear()} ${A[e.getUTCHours()]}:${A[e.getUTCMinutes()]}:${A[e.getUTCSeconds()]} GMT`}e.exports={isCTLExcludingHtab:function(e){for(let t=0;t<e.length;++t){const s=e.charCodeAt(t);if(s>=0&&s<=8||s>=10&&s<=31||127===s)return!0}return!1},validateCookieName:t,validateCookiePath:n,validateCookieValue:s,toIMFDate:o,stringify:function(e){if(0===e.name.length)return null;t(e.name),s(e.value);const r=[`${e.name}=${e.value}`];e.name.startsWith("__Secure-")&&(e.secure=!0),e.name.startsWith("__Host-")&&(e.secure=!0,e.domain=null,e.path="/"),e.secure&&r.push("Secure"),e.httpOnly&&r.push("HttpOnly"),"number"==typeof e.maxAge&&(!function(e){if(e<0)throw new Error("Invalid cookie max-age")}(e.maxAge),r.push(`Max-Age=${e.maxAge}`)),e.domain&&(!function(e){if(e.startsWith("-")||e.endsWith(".")||e.endsWith("-"))throw new Error("Invalid cookie domain")}(e.domain),r.push(`Domain=${e.domain}`)),e.path&&(n(e.path),r.push(`Path=${e.path}`)),e.expires&&"Invalid Date"!==e.expires.toString()&&r.push(`Expires=${o(e.expires)}`),e.sameSite&&r.push(`SameSite=${e.sameSite}`);for(const t of e.unparsed){if(!t.includes("="))throw new Error("Invalid unparsed");const[e,...s]=t.split("=");r.push(`${e.trim()}=${s.join("=")}`)}return r.join("; ")}}},8813:(e,t,s)=>{"use strict";const{Transform:n}=s(7075),{isASCIINumber:r,isValidLastEventId:i}=s(4689),A=[239,187,191];e.exports={EventSourceStream:class extends n{state;checkBOM=!0;crlfCheck=!1;eventEndCheck=!1;buffer=null;pos=0;event={data:void 0,event:void 0,id:void 0,retry:void 0};constructor(e={}){e.readableObjectMode=!0,super(e),this.state=e.eventSourceSettings||{},e.push&&(this.push=e.push)}_transform(e,t,s){if(0!==e.length){if(this.buffer?this.buffer=Buffer.concat([this.buffer,e]):this.buffer=e,this.checkBOM)switch(this.buffer.length){case 1:return this.buffer[0]===A[0]||(this.checkBOM=!1),void s();case 2:if(this.buffer[0]===A[0]&&this.buffer[1]===A[1])return void s();this.checkBOM=!1;break;case 3:if(this.buffer[0]===A[0]&&this.buffer[1]===A[1]&&this.buffer[2]===A[2])return this.buffer=Buffer.alloc(0),this.checkBOM=!1,void s();this.checkBOM=!1;break;default:this.buffer[0]===A[0]&&this.buffer[1]===A[1]&&this.buffer[2]===A[2]&&(this.buffer=this.buffer.subarray(3)),this.checkBOM=!1}for(;this.pos<this.buffer.length;)if(this.eventEndCheck){if(this.crlfCheck){if(10===this.buffer[this.pos]){this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,this.crlfCheck=!1;continue}this.crlfCheck=!1}if(10===this.buffer[this.pos]||13===this.buffer[this.pos]){13===this.buffer[this.pos]&&(this.crlfCheck=!0),this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,(void 0!==this.event.data||this.event.event||void 0!==this.event.id||this.event.retry)&&this.processEvent(this.event),this.clearEvent();continue}this.eventEndCheck=!1}else 10!==this.buffer[this.pos]&&13!==this.buffer[this.pos]?this.pos++:(13===this.buffer[this.pos]&&(this.crlfCheck=!0),this.parseLine(this.buffer.subarray(0,this.pos),this.event),this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,this.eventEndCheck=!0);s()}else s()}parseLine(e,t){if(0===e.length)return;const s=e.indexOf(58);if(0===s)return;let n="",A="";if(-1!==s){n=e.subarray(0,s).toString("utf8");let t=s+1;32===e[t]&&++t,A=e.subarray(t).toString("utf8")}else n=e.toString("utf8"),A="";switch(n){case"data":void 0===t[n]?t[n]=A:t[n]+=`\n${A}`;break;case"retry":r(A)&&(t[n]=A);break;case"id":i(A)&&(t[n]=A);break;case"event":A.length>0&&(t[n]=A)}}processEvent(e){e.retry&&r(e.retry)&&(this.state.reconnectionTime=parseInt(e.retry,10)),void 0!==e.id&&i(e.id)&&(this.state.lastEventId=e.id),void 0!==e.data&&this.push({type:e.event||"message",options:{data:e.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}}}},7928:(e,t,s)=>{"use strict";const{pipeline:n}=s(7075),{fetching:r}=s(7388),{makeRequest:i}=s(4609),{webidl:A}=s(6097),{EventSourceStream:o}=s(8813),{parseMIMEType:a}=s(9934),{createFastMessageEvent:c}=s(878),{isNetworkError:l}=s(4821),{kEnumerableProperty:h}=s(2858),{environmentSettingsObject:g}=s(6686);let d=!1;class u extends EventTarget{#Oe={open:null,error:null,message:null};#Ge;#Je=!1;#We=0;#_e=null;#q=null;#$e;#le;constructor(e,t={}){super(),A.util.markAsUncloneable(this);const s="EventSource constructor";A.argumentLengthCheck(arguments,1,s),d||(d=!0,process.emitWarning("EventSource is experimental, expect them to change at any time.",{code:"UNDICI-ES"})),e=A.converters.USVString(e),t=A.converters.EventSourceInitDict(t,s,"eventSourceInitDict"),this.#$e=t.node.dispatcher||t.dispatcher,this.#le={lastEventId:"",reconnectionTime:t.node.reconnectionTime};const n=g;let r;try{r=new URL(e,n.settingsObject.baseUrl),this.#le.origin=r.origin}catch(e){throw new DOMException(e,"SyntaxError")}this.#Ge=r.href;let o="anonymous";!0===t.withCredentials&&(o="use-credentials",this.#Je=!0);const a={redirect:"follow",keepalive:!0,mode:"cors",credentials:"anonymous"===o?"same-origin":"omit",referrer:"no-referrer"};a.client=g.settingsObject,a.headersList=[["accept",{name:"accept",value:"text/event-stream"}]],a.cache="no-store",a.initiator="other",a.urlList=[new URL(this.#Ge)],this.#_e=i(a),this.#qe()}get readyState(){return this.#We}get url(){return this.#Ge}get withCredentials(){return this.#Je}#qe(){if(2===this.#We)return;this.#We=0;const e={request:this.#_e,dispatcher:this.#$e};e.processResponseEndOfBody=e=>{if(!l(e))return this.#ze()},e.processResponse=e=>{if(l(e))return e.aborted?(this.close(),void this.dispatchEvent(new Event("error"))):void this.#ze();const t=e.headersList.get("content-type",!0),s=null!==t?a(t):"failure",r="failure"!==s&&"text/event-stream"===s.essence;if(200!==e.status||!1===r)return this.close(),void this.dispatchEvent(new Event("error"));this.#We=1,this.dispatchEvent(new Event("open")),this.#le.origin=e.urlList[e.urlList.length-1].origin;const i=new o({eventSourceSettings:this.#le,push:e=>{this.dispatchEvent(c(e.type,e.options))}});n(e.body.stream,i,(e=>{!1===e?.aborted&&(this.close(),this.dispatchEvent(new Event("error")))}))},this.#q=r(e)}#ze(){2!==this.#We&&(this.#We=0,this.dispatchEvent(new Event("error")),setTimeout((()=>{0===this.#We&&(this.#le.lastEventId.length&&this.#_e.headersList.set("last-event-id",this.#le.lastEventId,!0),this.#qe())}),this.#le.reconnectionTime)?.unref())}close(){A.brandCheck(this,u),2!==this.#We&&(this.#We=2,this.#q.abort(),this.#_e=null)}get onopen(){return this.#Oe.open}set onopen(e){this.#Oe.open&&this.removeEventListener("open",this.#Oe.open);const t=A.converters.EventHandlerNonNull(e);null!==t?(this.addEventListener("open",t),this.#Oe.open=e):this.#Oe.open=null}get onmessage(){return this.#Oe.message}set onmessage(e){this.#Oe.message&&this.removeEventListener("message",this.#Oe.message);const t=A.converters.EventHandlerNonNull(e);null!==t?(this.addEventListener("message",t),this.#Oe.message=e):this.#Oe.message=null}get onerror(){return this.#Oe.error}set onerror(e){this.#Oe.error&&this.removeEventListener("error",this.#Oe.error);const t=A.converters.EventHandlerNonNull(e);null!==t?(this.addEventListener("error",t),this.#Oe.error=e):this.#Oe.error=null}}const I={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:0,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:1,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:2,writable:!1}};Object.defineProperties(u,I),Object.defineProperties(u.prototype,I),Object.defineProperties(u.prototype,{close:h,onerror:h,onmessage:h,onopen:h,readyState:h,url:h,withCredentials:h}),A.converters.EventSourceInitDict=A.dictionaryConverter([{key:"withCredentials",converter:A.converters.boolean,defaultValue:()=>!1},{key:"dispatcher",converter:A.converters.any},{key:"node",converter:A.dictionaryConverter([{key:"reconnectionTime",converter:A.converters["unsigned long"],defaultValue:()=>3e3},{key:"dispatcher",converter:A.converters.any}]),defaultValue:()=>({})}]),e.exports={EventSource:u,defaultReconnectionTime:3e3}},4689:e=>{"use strict";e.exports={isValidLastEventId:function(e){return-1===e.indexOf("\0")},isASCIINumber:function(e){if(0===e.length)return!1;for(let t=0;t<e.length;t++)if(e.charCodeAt(t)<48||e.charCodeAt(t)>57)return!1;return!0}}},2530:(e,t,s)=>{"use strict";const n=s(2858),{ReadableStreamFrom:r,readableStreamClose:i,fullyReadBody:A,extractMimeType:o,utf8DecodeBytes:a}=s(6686),{FormData:c,setFormDataState:l}=s(3944),{webidl:h}=s(6097),g=s(4589),{isErrored:d,isDisturbed:u}=s(7075),{isArrayBuffer:I}=s(3429),{serializeAMimeType:E}=s(9934),{multipartFormDataParser:p}=s(4614),{createDeferredPromise:C}=s(9250);let B;try{const e=s(7598);B=t=>e.randomInt(0,t)}catch{B=e=>Math.floor(Math.random()*e)}const Q=new TextEncoder;function f(){}const m=new FinalizationRegistry((e=>{const t=e.deref();!t||t.locked||u(t)||d(t)||t.cancel("Response object has been garbage collected").catch(f)}));function y(e,t=!1){let s=null;s=h.is.ReadableStream(e)?e:h.is.Blob(e)?e.stream():new ReadableStream({pull(e){const t="string"==typeof o?Q.encode(o):o;t.byteLength&&e.enqueue(t),queueMicrotask((()=>i(e)))},start(){},type:"bytes"}),g(h.is.ReadableStream(s));let A=null,o=null,a=null,c=null;if("string"==typeof e)o=e,c="text/plain;charset=UTF-8";else if(h.is.URLSearchParams(e))o=e.toString(),c="application/x-www-form-urlencoded;charset=UTF-8";else if(h.is.BufferSource(e))o=I(e)?new Uint8Array(e.slice()):new Uint8Array(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));else if(h.is.FormData(e)){const t=`----formdata-undici-0${`${B(1e11)}`.padStart(11,"0")}`,s=`--${t}\r\nContent-Disposition: form-data`,n=e=>e.replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22"),r=e=>e.replace(/\r?\n|\r/g,"\r\n"),i=[],l=new Uint8Array([13,10]);a=0;let h=!1;for(const[t,A]of e)if("string"==typeof A){const e=Q.encode(s+`; name="${n(r(t))}"`+`\r\n\r\n${r(A)}\r\n`);i.push(e),a+=e.byteLength}else{const e=Q.encode(`${s}; name="${n(r(t))}"`+(A.name?`; filename="${n(A.name)}"`:"")+"\r\n"+`Content-Type: ${A.type||"application/octet-stream"}\r\n\r\n`);i.push(e,A,l),"number"==typeof A.size?a+=e.byteLength+A.size+l.byteLength:h=!0}const g=Q.encode(`--${t}--\r\n`);i.push(g),a+=g.byteLength,h&&(a=null),o=e,A=async function*(){for(const e of i)e.stream?yield*e.stream():yield e},c=`multipart/form-data; boundary=${t}`}else if(h.is.Blob(e))o=e,a=e.size,e.type&&(c=e.type);else if("function"==typeof e[Symbol.asyncIterator]){if(t)throw new TypeError("keepalive");if(n.isDisturbed(e)||e.locked)throw new TypeError("Response body object should not be disturbed or locked");s=h.is.ReadableStream(e)?e:r(e)}if(("string"==typeof o||n.isBuffer(o))&&(a=Buffer.byteLength(o)),null!=A){let t;s=new ReadableStream({async start(){t=A(e)[Symbol.asyncIterator]()},async pull(e){const{value:n,done:r}=await t.next();if(r)queueMicrotask((()=>{e.close(),e.byobRequest?.respond(0)}));else if(!d(s)){const t=new Uint8Array(n);t.byteLength&&e.enqueue(t)}return e.desiredSize>0},async cancel(e){await t.return()},type:"bytes"})}return[{stream:s,source:o,length:a},c]}function S(e,t,s,n){try{h.brandCheck(e,s)}catch(e){return Promise.reject(e)}const r=n(e);if(w(r))return Promise.reject(new TypeError("Body is unusable: Body has already been read"));if(r.aborted)return Promise.reject(new DOMException("The operation was aborted.","AbortError"));const i=C(),o=i.reject,a=e=>{try{i.resolve(t(e))}catch(e){o(e)}};return null==r.body?(a(Buffer.allocUnsafe(0)),i.promise):(A(r.body,a,o),i.promise)}function w(e){const t=e.body;return null!=t&&(t.stream.locked||n.isDisturbed(t.stream))}function D(e){return JSON.parse(a(e))}function b(e){const t=e.headersList,s=o(t);return"failure"===s?null:s}e.exports={extractBody:y,safelyExtractBody:function(e,t=!1){return h.is.ReadableStream(e)&&(g(!n.isDisturbed(e),"The body has already been consumed."),g(!e.locked,"The stream is locked.")),y(e,t)},cloneBody:function(e){const{0:t,1:s}=e.stream.tee();return e.stream=t,{stream:s,length:e.length,source:e.source}},mixinBody:function(e,t){Object.assign(e.prototype,function(e,t){return{blob(){return S(this,(e=>{let s=b(t(this));return null===s?s="":s&&(s=E(s)),new Blob([e],{type:s})}),e,t)},arrayBuffer(){return S(this,(e=>new Uint8Array(e).buffer),e,t)},text(){return S(this,a,e,t)},json(){return S(this,D,e,t)},formData(){return S(this,(e=>{const s=b(t(this));if(null!==s)switch(s.essence){case"multipart/form-data":{const t=p(e,s),n=new c;return l(n,t),n}case"application/x-www-form-urlencoded":{const t=new URLSearchParams(e.toString()),s=new c;for(const[e,n]of t)s.append(e,n);return s}}throw new TypeError('Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".')}),e,t)},bytes(){return S(this,(e=>new Uint8Array(e)),e,t)}}}(e,t))},streamRegistry:m,bodyUnusable:w}},9441:e=>{"use strict";const t=["GET","HEAD","POST"],s=new Set(t),n=[301,302,303,307,308],r=new Set(n),i=["1","7","9","11","13","15","17","19","20","21","22","23","25","37","42","43","53","69","77","79","87","95","101","102","103","104","109","110","111","113","115","117","119","123","135","137","139","143","161","179","389","427","465","512","513","514","515","526","530","531","532","540","548","554","556","563","587","601","636","989","990","993","995","1719","1720","1723","2049","3659","4045","4190","5060","5061","6000","6566","6665","6666","6667","6668","6669","6679","6697","10080"],A=new Set(i),o=["no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"],a=["",...o],c=new Set(o),l=["GET","HEAD","OPTIONS","TRACE"],h=new Set(l),g=["CONNECT","TRACE","TRACK"],d=new Set(g),u=["audio","audioworklet","font","image","manifest","paintworklet","script","style","track","video","xslt",""],I=new Set(u);e.exports={subresource:u,forbiddenMethods:g,requestBodyHeader:["content-encoding","content-language","content-location","content-type","content-length"],referrerPolicy:a,requestRedirect:["follow","manual","error"],requestMode:["navigate","same-origin","no-cors","cors"],requestCredentials:["omit","same-origin","include"],requestCache:["default","no-store","reload","no-cache","force-cache","only-if-cached"],redirectStatus:n,corsSafeListedMethods:t,nullBodyStatus:[101,204,205,304],safeMethods:l,badPorts:i,requestDuplex:["half"],subresourceSet:I,badPortsSet:A,redirectStatusSet:r,corsSafeListedMethodsSet:s,safeMethodsSet:h,forbiddenMethodsSet:d,referrerPolicyTokens:c}},9934:(e,t,s)=>{"use strict";const n=s(4589),r=new TextEncoder,i=/^[!#$%&'*+\-.^_|~A-Za-z0-9]+$/,A=/[\u000A\u000D\u0009\u0020]/,o=/[\u0009\u000A\u000C\u000D\u0020]/g,a=/^[\u0009\u0020-\u007E\u0080-\u00FF]+$/;function c(e,t=!1){if(!t)return e.href;const s=e.href,n=e.hash.length,r=0===n?s:s.substring(0,s.length-n);return!n&&s.endsWith("#")?r.slice(0,-1):r}function l(e,t,s){let n="";for(;s.position<t.length&&e(t[s.position]);)n+=t[s.position],s.position++;return n}function h(e,t,s){const n=t.indexOf(e,s.position),r=s.position;return-1===n?(s.position=t.length,t.slice(r)):(s.position=n,t.slice(r,s.position))}function g(e){return function(e){const t=e.length,s=new Uint8Array(t);let n=0;for(let r=0;r<t;++r){const t=e[r];37!==t?s[n++]=t:37!==t||d(e[r+1])&&d(e[r+2])?(s[n++]=u(e[r+1])<<4|u(e[r+2]),r+=2):s[n++]=37}return t===n?s:s.subarray(0,n)}(r.encode(e))}function d(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function u(e){return e>=48&&e<=57?e-48:(223&e)-55}function I(e){const t={position:0},s=h("/",e=C(e,!0,!0),t);if(0===s.length||!i.test(s))return"failure";if(t.position>=e.length)return"failure";t.position++;let n=h(";",e,t);if(n=C(n,!1,!0),0===n.length||!i.test(n))return"failure";const r=s.toLowerCase(),o=n.toLowerCase(),c={type:r,subtype:o,parameters:new Map,essence:`${r}/${o}`};for(;t.position<e.length;){t.position++,l((e=>A.test(e)),e,t);let s=l((e=>";"!==e&&"="!==e),e,t);if(s=s.toLowerCase(),t.position<e.length){if(";"===e[t.position])continue;t.position++}if(t.position>=e.length)break;let n=null;if('"'===e[t.position])n=E(e,t,!0),h(";",e,t);else if(n=h(";",e,t),n=C(n,!1,!0),0===n.length)continue;0===s.length||!i.test(s)||0!==n.length&&!a.test(n)||c.parameters.has(s)||c.parameters.set(s,n)}return c}function E(e,t,s=!1){const r=t.position;let i="";for(n('"'===e[t.position]),t.position++;i+=l((e=>'"'!==e&&"\\"!==e),e,t),!(t.position>=e.length);){const s=e[t.position];if(t.position++,"\\"!==s){n('"'===s);break}if(t.position>=e.length){i+="\\";break}i+=e[t.position],t.position++}return s?i:e.slice(r,t.position)}function p(e){return 13===e||10===e||9===e||32===e}function C(e,t=!0,s=!0){return Q(e,t,s,p)}function B(e){return 13===e||10===e||9===e||12===e||32===e}function Q(e,t,s,n){let r=0,i=e.length-1;if(t)for(;r<e.length&&n(e.charCodeAt(r));)r++;if(s)for(;i>0&&n(e.charCodeAt(i));)i--;return 0===r&&i===e.length-1?e:e.slice(r,i+1)}function f(e){const t=e.length;if(65535>t)return String.fromCharCode.apply(null,e);let s="",n=0,r=65535;for(;n<t;)n+r>t&&(r=t-n),s+=String.fromCharCode.apply(null,e.subarray(n,n+=r));return s}e.exports={dataURLProcessor:function(e){n("data:"===e.protocol);let t=c(e,!0);t=t.slice(5);const s={position:0};let r=h(",",t,s);const i=r.length;if(r=function(e,t=!0,s=!0){return Q(e,t,s,B)}(r,!0,!0),s.position>=t.length)return"failure";s.position++;let A=g(t.slice(i+1));if(/;(\u0020){0,}base64$/i.test(r)){if(A=function(e){let t=(e=e.replace(o,"")).length;t%4==0&&61===e.charCodeAt(t-1)&&(--t,61===e.charCodeAt(t-1)&&--t);if(t%4==1)return"failure";if(/[^+/0-9A-Za-z]/.test(e.length===t?e:e.substring(0,t)))return"failure";const s=Buffer.from(e,"base64");return new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}(f(A)),"failure"===A)return"failure";r=r.slice(0,-6),r=r.replace(/(\u0020)+$/,""),r=r.slice(0,-1)}r.startsWith(";")&&(r="text/plain"+r);let a=I(r);return"failure"===a&&(a=I("text/plain;charset=US-ASCII")),{mimeType:a,body:A}},URLSerializer:c,collectASequenceOfCodePoints:l,collectASequenceOfCodePointsFast:h,stringPercentDecode:g,parseMIMEType:I,collectAnHTTPQuotedString:E,serializeAMimeType:function(e){n("failure"!==e);const{parameters:t,essence:s}=e;let r=s;for(let[e,s]of t.entries())r+=";",r+=e,r+="=",i.test(s)||(s=s.replace(/(\\|")/g,"\\$1"),s='"'+s,s+='"'),r+=s;return r},removeChars:Q,removeHTTPWhitespace:C,minimizeSupportedMimeType:function(e){switch(e.essence){case"application/ecmascript":case"application/javascript":case"application/x-ecmascript":case"application/x-javascript":case"text/ecmascript":case"text/javascript":case"text/javascript1.0":case"text/javascript1.1":case"text/javascript1.2":case"text/javascript1.3":case"text/javascript1.4":case"text/javascript1.5":case"text/jscript":case"text/livescript":case"text/x-ecmascript":case"text/x-javascript":return"text/javascript";case"application/json":case"text/json":return"application/json";case"image/svg+xml":return"image/svg+xml";case"text/xml":case"application/xml":return"application/xml"}return e.subtype.endsWith("+json")?"application/json":e.subtype.endsWith("+xml")?"application/xml":""},HTTP_TOKEN_CODEPOINTS:i,isomorphicDecode:f}},4614:(e,t,s)=>{"use strict";const{bufferToLowerCasedHeaderName:n}=s(2858),{utf8DecodeBytes:r}=s(6686),{HTTP_TOKEN_CODEPOINTS:i,isomorphicDecode:A}=s(9934),{makeEntry:o}=s(3944),{webidl:a}=s(6097),c=s(4589),l=Buffer.from('form-data; name="'),h=Buffer.from("filename"),g=Buffer.from("--"),d=Buffer.from("--\r\n");function u(e){for(let t=0;t<e.length;++t)if(-128&e.charCodeAt(t))return!1;return!0}function I(e,t){let s=null,r=null,o=null,a=null;for(;;){if(13===e[t.position]&&10===e[t.position+1]){if(null===s)throw Q("header name is null");return{name:s,filename:r,contentType:o,encoding:a}}let c=p((e=>10!==e&&13!==e&&58!==e),e,t);if(c=C(c,!0,!0,(e=>9===e||32===e)),!i.test(c.toString()))throw Q("header name does not match the field-name token production");if(58!==e[t.position])throw Q("expected :");switch(t.position++,p((e=>32===e||9===e),e,t),n(c)){case"content-disposition":if(s=r=null,!B(e,l,t))throw Q('expected form-data; name=" for content-disposition header');if(t.position+=17,s=E(e,t),59===e[t.position]&&32===e[t.position+1]){const s={position:t.position+2};if(B(e,h,s))if(42===e[s.position+8]){s.position+=10,p((e=>32===e||9===e),e,s);const n=p((e=>32!==e&&13!==e&&10!==e),e,s);if(117!==n[0]&&85!==n[0]||116!==n[1]&&84!==n[1]||102!==n[2]&&70!==n[2]||45!==n[3]||56!==n[4])throw Q("unknown encoding, expected utf-8''");r=decodeURIComponent((new TextDecoder).decode(n.subarray(7))),t.position=s.position}else t.position+=11,p((e=>32===e||9===e),e,t),t.position++,r=E(e,t)}break;case"content-type":{let s=p((e=>10!==e&&13!==e),e,t);s=C(s,!1,!0,(e=>9===e||32===e)),o=A(s);break}case"content-transfer-encoding":{let s=p((e=>10!==e&&13!==e),e,t);s=C(s,!1,!0,(e=>9===e||32===e)),a=A(s);break}default:p((e=>10!==e&&13!==e),e,t)}if(13!==e[t.position]&&10!==e[t.position+1])throw Q("expected CRLF");t.position+=2}}function E(e,t){c(34===e[t.position-1]);let s=p((e=>10!==e&&13!==e&&34!==e),e,t);if(34!==e[t.position])throw Q('expected "');return t.position++,s=(new TextDecoder).decode(s).replace(/%0A/gi,"\n").replace(/%0D/gi,"\r").replace(/%22/g,'"'),s}function p(e,t,s){let n=s.position;for(;n<t.length&&e(t[n]);)++n;return t.subarray(s.position,s.position=n)}function C(e,t,s,n){let r=0,i=e.length-1;if(t)for(;r<e.length&&n(e[r]);)r++;if(s)for(;i>0&&n(e[i]);)i--;return 0===r&&i===e.length-1?e:e.subarray(r,i+1)}function B(e,t,s){if(e.length<t.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[s.position+n])return!1;return!0}function Q(e){return new TypeError("Failed to parse body as FormData.",{cause:new TypeError(e)})}e.exports={multipartFormDataParser:function(e,t){c("failure"!==t&&"multipart/form-data"===t.essence);const s=t.parameters.get("boundary");if(void 0===s)throw Q("missing boundary in content-type header");const n=Buffer.from(`--${s}`,"utf8"),i=[],A={position:0};for(;13===e[A.position]&&10===e[A.position+1];)A.position+=2;let l=e.length;for(;10===e[l-1]&&13===e[l-2];)l-=2;for(l!==e.length&&(e=e.subarray(0,l));;){if(!e.subarray(A.position,A.position+n.length).equals(n))throw Q("expected a value starting with -- and the boundary");if(A.position+=n.length,A.position===e.length-2&&B(e,g,A)||A.position===e.length-4&&B(e,d,A))return i;if(13!==e[A.position]||10!==e[A.position+1])throw Q("expected CRLF");A.position+=2;const t=I(e,A);let s,l,{name:h,filename:E,contentType:p,encoding:C}=t;A.position+=2;{const t=e.indexOf(n.subarray(2),A.position);if(-1===t)throw Q("expected boundary after body");s=e.subarray(A.position,t-4),A.position+=s.length,"base64"===C&&(s=Buffer.from(s.toString(),"base64"))}if(13!==e[A.position]||10!==e[A.position+1])throw Q("expected CRLF");A.position+=2,null!==E?(p??="text/plain",u(p)||(p=""),l=new File([s],E,{type:p})):l=r(Buffer.from(s)),c(a.is.USVString(h)),c("string"==typeof l&&a.is.USVString(l)||a.is.File(l)),i.push(o(h,l,E))}},validateBoundary:function(e){const t=e.length;if(t<27||t>70)return!1;for(let s=0;s<t;++s){const t=e.charCodeAt(s);if(!(t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||39===t||45===t||95===t))return!1}return!0}}},3944:(e,t,s)=>{"use strict";const{iteratorMixin:n}=s(6686),{kEnumerableProperty:r}=s(2858),{webidl:i}=s(6097),A=s(7975);class o{#le=[];constructor(e=void 0){if(i.util.markAsUncloneable(this),void 0!==e)throw i.errors.conversionFailed({prefix:"FormData constructor",argument:"Argument 1",types:["undefined"]})}append(e,t,s=void 0){i.brandCheck(this,o);const n="FormData.append";i.argumentLengthCheck(arguments,2,n),e=i.converters.USVString(e),3===arguments.length||i.is.Blob(t)?(t=i.converters.Blob(t,n,"value"),void 0!==s&&(s=i.converters.USVString(s))):t=i.converters.USVString(t);const r=l(e,t,s);this.#le.push(r)}delete(e){i.brandCheck(this,o);i.argumentLengthCheck(arguments,1,"FormData.delete"),e=i.converters.USVString(e),this.#le=this.#le.filter((t=>t.name!==e))}get(e){i.brandCheck(this,o);i.argumentLengthCheck(arguments,1,"FormData.get"),e=i.converters.USVString(e);const t=this.#le.findIndex((t=>t.name===e));return-1===t?null:this.#le[t].value}getAll(e){i.brandCheck(this,o);return i.argumentLengthCheck(arguments,1,"FormData.getAll"),e=i.converters.USVString(e),this.#le.filter((t=>t.name===e)).map((e=>e.value))}has(e){i.brandCheck(this,o);return i.argumentLengthCheck(arguments,1,"FormData.has"),e=i.converters.USVString(e),-1!==this.#le.findIndex((t=>t.name===e))}set(e,t,s=void 0){i.brandCheck(this,o);const n="FormData.set";i.argumentLengthCheck(arguments,2,n),e=i.converters.USVString(e),3===arguments.length||i.is.Blob(t)?(t=i.converters.Blob(t,n,"value"),void 0!==s&&(s=i.converters.USVString(s))):t=i.converters.USVString(t);const r=l(e,t,s),A=this.#le.findIndex((t=>t.name===e));-1!==A?this.#le=[...this.#le.slice(0,A),r,...this.#le.slice(A+1).filter((t=>t.name!==e))]:this.#le.push(r)}[A.inspect.custom](e,t){const s=this.#le.reduce(((e,t)=>(e[t.name]?Array.isArray(e[t.name])?e[t.name].push(t.value):e[t.name]=[e[t.name],t.value]:e[t.name]=t.value,e)),{__proto__:null});t.depth??=e,t.colors??=!0;const n=A.formatWithOptions(t,s);return`FormData ${n.slice(n.indexOf("]")+2)}`}static getFormDataState(e){return e.#le}static setFormDataState(e,t){e.#le=t}}const{getFormDataState:a,setFormDataState:c}=o;function l(e,t,s){if("string"==typeof t);else if(i.is.File(t)||(t=new File([t],"blob",{type:t.type})),void 0!==s){const e={type:t.type,lastModified:t.lastModified};t=new File([t],s,e)}return{name:e,value:t}}Reflect.deleteProperty(o,"getFormDataState"),Reflect.deleteProperty(o,"setFormDataState"),n("FormData",o,a,"name","value"),Object.defineProperties(o.prototype,{append:r,delete:r,get:r,getAll:r,has:r,set:r,[Symbol.toStringTag]:{value:"FormData",configurable:!0}}),i.is.FormData=i.util.MakeTypeAssertion(o),e.exports={FormData:o,makeEntry:l,setFormDataState:c}},2837:e=>{"use strict";const t=Symbol.for("undici.globalOrigin.1");e.exports={getGlobalOrigin:function(){return globalThis[t]},setGlobalOrigin:function(e){if(void 0===e)return void Object.defineProperty(globalThis,t,{value:void 0,writable:!0,enumerable:!1,configurable:!1});const s=new URL(e);if("http:"!==s.protocol&&"https:"!==s.protocol)throw new TypeError(`Only http & https urls are allowed, received ${s.protocol}`);Object.defineProperty(globalThis,t,{value:s,writable:!0,enumerable:!1,configurable:!1})}}},6558:(e,t,s)=>{"use strict";const{kConstruct:n}=s(257),{kEnumerableProperty:r}=s(2858),{iteratorMixin:i,isValidHeaderName:A,isValidHeaderValue:o}=s(6686),{webidl:a}=s(6097),c=s(4589),l=s(7975);function h(e){return 10===e||13===e||9===e||32===e}function g(e){let t=0,s=e.length;for(;s>t&&h(e.charCodeAt(s-1));)--s;for(;s>t&&h(e.charCodeAt(t));)++t;return 0===t&&s===e.length?e:e.substring(t,s)}function d(e,t){if(Array.isArray(t))for(let s=0;s<t.length;++s){const n=t[s];if(2!==n.length)throw a.errors.exception({header:"Headers constructor",message:`expected name/value pair to be length 2, found ${n.length}.`});u(e,n[0],n[1])}else{if("object"!=typeof t||null===t)throw a.errors.conversionFailed({prefix:"Headers constructor",argument:"Argument 1",types:["sequence<sequence<ByteString>>","record<ByteString, ByteString>"]});{const s=Object.keys(t);for(let n=0;n<s.length;++n)u(e,s[n],t[s[n]])}}}function u(e,t,s){if(s=g(s),!A(t))throw a.errors.invalidArgument({prefix:"Headers.append",value:t,type:"header name"});if(!o(s))throw a.errors.invalidArgument({prefix:"Headers.append",value:s,type:"header value"});if("immutable"===C(e))throw new TypeError("immutable");return Q(e).append(t,s,!1)}function I(e,t){return e[0]<t[0]?-1:1}class E{cookies=null;sortedMap;headersMap;constructor(e){e instanceof E?(this.headersMap=new Map(e.headersMap),this.sortedMap=e.sortedMap,this.cookies=null===e.cookies?null:[...e.cookies]):(this.headersMap=new Map(e),this.sortedMap=null)}contains(e,t){return this.headersMap.has(t?e:e.toLowerCase())}clear(){this.headersMap.clear(),this.sortedMap=null,this.cookies=null}append(e,t,s){this.sortedMap=null;const n=s?e:e.toLowerCase(),r=this.headersMap.get(n);if(r){const e="cookie"===n?"; ":", ";this.headersMap.set(n,{name:r.name,value:`${r.value}${e}${t}`})}else this.headersMap.set(n,{name:e,value:t});"set-cookie"===n&&(this.cookies??=[]).push(t)}set(e,t,s){this.sortedMap=null;const n=s?e:e.toLowerCase();"set-cookie"===n&&(this.cookies=[t]),this.headersMap.set(n,{name:e,value:t})}delete(e,t){this.sortedMap=null,t||(e=e.toLowerCase()),"set-cookie"===e&&(this.cookies=null),this.headersMap.delete(e)}get(e,t){return this.headersMap.get(t?e:e.toLowerCase())?.value??null}*[Symbol.iterator](){for(const{0:e,1:{value:t}}of this.headersMap)yield[e,t]}get entries(){const e={};if(0!==this.headersMap.size)for(const{name:t,value:s}of this.headersMap.values())e[t]=s;return e}rawValues(){return this.headersMap.values()}get entriesList(){const e=[];if(0!==this.headersMap.size)for(const{0:t,1:{name:s,value:n}}of this.headersMap)if("set-cookie"===t)for(const t of this.cookies)e.push([s,t]);else e.push([s,n]);return e}toSortedArray(){const e=this.headersMap.size,t=new Array(e);if(e<=32){if(0===e)return t;const s=this.headersMap[Symbol.iterator](),n=s.next().value;t[0]=[n[0],n[1].value],c(null!==n[1].value);for(let n,r,i=1,A=0,o=0,a=0,l=0;i<e;++i){for(r=s.next().value,n=t[i]=[r[0],r[1].value],c(null!==n[1]),a=0,o=i;a<o;)l=a+(o-a>>1),t[l][0]<=n[0]?a=l+1:o=l;if(i!==l){for(A=i;A>a;)t[A]=t[--A];t[a]=n}}if(!s.next().done)throw new TypeError("Unreachable");return t}{let e=0;for(const{0:s,1:{value:n}}of this.headersMap)t[e++]=[s,n],c(null!==n);return t.sort(I)}}}class p{#Xe;#je;constructor(e=void 0){a.util.markAsUncloneable(this),e!==n&&(this.#je=new E,this.#Xe="none",void 0!==e&&d(this,e=a.converters.HeadersInit(e,"Headers constructor","init")))}append(e,t){a.brandCheck(this,p),a.argumentLengthCheck(arguments,2,"Headers.append");const s="Headers.append";return u(this,e=a.converters.ByteString(e,s,"name"),t=a.converters.ByteString(t,s,"value"))}delete(e){a.brandCheck(this,p),a.argumentLengthCheck(arguments,1,"Headers.delete");if(e=a.converters.ByteString(e,"Headers.delete","name"),!A(e))throw a.errors.invalidArgument({prefix:"Headers.delete",value:e,type:"header name"});if("immutable"===this.#Xe)throw new TypeError("immutable");this.#je.contains(e,!1)&&this.#je.delete(e,!1)}get(e){a.brandCheck(this,p),a.argumentLengthCheck(arguments,1,"Headers.get");const t="Headers.get";if(e=a.converters.ByteString(e,t,"name"),!A(e))throw a.errors.invalidArgument({prefix:t,value:e,type:"header name"});return this.#je.get(e,!1)}has(e){a.brandCheck(this,p),a.argumentLengthCheck(arguments,1,"Headers.has");const t="Headers.has";if(e=a.converters.ByteString(e,t,"name"),!A(e))throw a.errors.invalidArgument({prefix:t,value:e,type:"header name"});return this.#je.contains(e,!1)}set(e,t){a.brandCheck(this,p),a.argumentLengthCheck(arguments,2,"Headers.set");const s="Headers.set";if(e=a.converters.ByteString(e,s,"name"),t=g(t=a.converters.ByteString(t,s,"value")),!A(e))throw a.errors.invalidArgument({prefix:s,value:e,type:"header name"});if(!o(t))throw a.errors.invalidArgument({prefix:s,value:t,type:"header value"});if("immutable"===this.#Xe)throw new TypeError("immutable");this.#je.set(e,t,!1)}getSetCookie(){a.brandCheck(this,p);const e=this.#je.cookies;return e?[...e]:[]}[l.inspect.custom](e,t){return t.depth??=e,`Headers ${l.formatWithOptions(t,this.#je.entries)}`}static getHeadersGuard(e){return e.#Xe}static setHeadersGuard(e,t){e.#Xe=t}static getHeadersList(e){return e.#je}static setHeadersList(e,t){e.#je=t}}const{getHeadersGuard:C,setHeadersGuard:B,getHeadersList:Q,setHeadersList:f}=p;Reflect.deleteProperty(p,"getHeadersGuard"),Reflect.deleteProperty(p,"setHeadersGuard"),Reflect.deleteProperty(p,"getHeadersList"),Reflect.deleteProperty(p,"setHeadersList"),i("Headers",p,(function(e){const t=Q(e);if(!t)return[];if(t.sortedMap)return t.sortedMap;const s=[],n=t.toSortedArray(),r=t.cookies;if(null===r||1===r.length)return t.sortedMap=n;for(let e=0;e<n.length;++e){const{0:t,1:i}=n[e];if("set-cookie"===t)for(let e=0;e<r.length;++e)s.push([t,r[e]]);else s.push([t,i])}return t.sortedMap=s}),0,1),Object.defineProperties(p.prototype,{append:r,delete:r,get:r,has:r,set:r,getSetCookie:r,[Symbol.toStringTag]:{value:"Headers",configurable:!0},[l.inspect.custom]:{enumerable:!1}}),a.converters.HeadersInit=function(e,t,s){if(a.util.Type(e)===a.util.Types.OBJECT){const n=Reflect.get(e,Symbol.iterator);if(!l.types.isProxy(e)&&n===p.prototype.entries)try{return Q(e).entriesList}catch{}return"function"==typeof n?a.converters["sequence<sequence<ByteString>>"](e,t,s,n.bind(e)):a.converters["record<ByteString, ByteString>"](e,t,s)}throw a.errors.conversionFailed({prefix:"Headers constructor",argument:"Argument 1",types:["sequence<sequence<ByteString>>","record<ByteString, ByteString>"]})},e.exports={fill:d,compareHeaderName:I,Headers:p,HeadersList:E,getHeadersGuard:C,setHeadersGuard:B,setHeadersList:f,getHeadersList:Q}},7388:(e,t,s)=>{"use strict";const{makeNetworkError:n,makeAppropriateNetworkError:r,filterResponse:i,makeResponse:A,fromInnerResponse:o,getResponseState:a}=s(4821),{HeadersList:c}=s(6558),{Request:l,cloneRequest:h,getRequestDispatcher:g,getRequestState:d}=s(4609),u=s(8522),{makePolicyContainer:I,clonePolicyContainer:E,requestBadPort:p,TAOCheck:C,appendRequestOriginHeader:B,responseLocationURL:Q,requestCurrentURL:f,setRequestReferrerPolicyOnRedirect:m,tryUpgradeRequestToAPotentiallyTrustworthyURL:y,createOpaqueTimingInfo:S,appendFetchMetadata:w,corsCheck:D,crossOriginResourcePolicyCheck:b,determineRequestsReferrer:v,coarsenedSharedCurrentTime:N,sameOrigin:R,isCancelled:k,isAborted:T,isErrorLike:F,fullyReadBody:M,readableStreamClose:U,isomorphicEncode:L,urlIsLocal:P,urlIsHttpHttpsScheme:H,urlHasHttpsScheme:x,clampAndCoarsenConnectionTimingInfo:Y,simpleRangeHeaderValue:V,buildContentRange:O,createInflate:G,extractMimeType:J}=s(6686),W=s(4589),{safelyExtractBody:_,extractBody:$}=s(2530),{redirectStatusSet:q,nullBodyStatus:z,safeMethodsSet:X,requestBodyHeader:j,subresourceSet:Z}=s(9441),K=s(8474),{Readable:ee,pipeline:te,finished:se,isErrored:ne,isReadable:re}=s(7075),{addAbortListener:ie,bufferToLowerCasedHeaderName:Ae}=s(2858),{dataURLProcessor:oe,serializeAMimeType:ae,minimizeSupportedMimeType:ce}=s(9934),{getGlobalDispatcher:le}=s(9879),{webidl:he}=s(6097),{STATUS_CODES:ge}=s(7067),{bytesMatch:de}=s(7420),{createDeferredPromise:ue}=s(9250),Ie="function"==typeof u.createZstdDecompress,Ee=["GET","HEAD"],pe="undefined"!=typeof __UNDICI_IS_NODE__||"undefined"!=typeof esbuildDetection?"node":"undici";let Ce;class Be extends K{constructor(e){super(),this.dispatcher=e,this.connection=null,this.dump=!1,this.state="ongoing"}terminate(e){"ongoing"===this.state&&(this.state="terminated",this.connection?.destroy(e),this.emit("terminated",e))}abort(e){"ongoing"===this.state&&(this.state="aborted",e||(e=new DOMException("The operation was aborted.","AbortError")),this.serializedAbortReason=e,this.connection?.destroy(e),this.emit("terminated",e))}}function Qe(e){fe(e,"fetch")}function fe(e,t="other"){if("error"===e.type&&e.aborted)return;if(!e.urlList?.length)return;const s=e.urlList[0];let n=e.timingInfo,r=e.cacheState;H(s)&&null!==n&&(e.timingAllowPassed||(n=S({startTime:n.startTime}),r=""),n.endTime=N(),e.timingInfo=n,me(n,s.href,t,globalThis,r,"",e.status))}const me=performance.markResourceTiming;function ye(e,t,s,n){if(e&&e.reject(n),null!=t.body?.stream&&re(t.body.stream)&&t.body.stream.cancel(n).catch((e=>{if("ERR_INVALID_STATE"!==e.code)throw e})),null==s)return;const r=a(s);null!=r.body?.stream&&re(r.body.stream)&&r.body.stream.cancel(n).catch((e=>{if("ERR_INVALID_STATE"!==e.code)throw e}))}function Se({request:e,processRequestBodyChunkLength:t,processRequestEndOfBody:s,processResponse:n,processResponseEndOfBody:r,processResponseConsumeBody:i,useParallelQueue:A=!1,dispatcher:o=le()}){W(o);let a=null,c=!1;null!=e.client&&(a=e.client.globalObject,c=e.client.crossOriginIsolatedCapability);const l=N(c),h=S({startTime:l}),g={controller:new Be(o),request:e,timingInfo:h,processRequestBodyChunkLength:t,processRequestEndOfBody:s,processResponse:n,processResponseConsumeBody:i,processResponseEndOfBody:r,taskDestination:a,crossOriginIsolatedCapability:c};if(W(!e.body||e.body.stream),"client"===e.window&&(e.window="Window"===e.client?.globalObject?.constructor?.name?e.client:"no-window"),"client"===e.origin&&(e.origin=e.client.origin),"client"===e.policyContainer&&(null!=e.client?e.policyContainer=E(e.client.policyContainer):e.policyContainer=I()),!e.headersList.contains("accept",!0)){const t="*/*";e.headersList.append("accept",t,!0)}return e.headersList.contains("accept-language",!0)||e.headersList.append("accept-language","*",!0),e.priority,Z.has(e.destination),we(g,!1),g.controller}async function we(e,t){try{const s=e.request;let r=null;if(s.localURLsOnly&&!P(f(s))&&(r=n("local URLs only")),y(s),"blocked"===p(s)&&(r=n("bad port")),""===s.referrerPolicy&&(s.referrerPolicy=s.policyContainer.referrerPolicy),"no-referrer"!==s.referrer&&(s.referrer=v(s)),null===r){const t=f(s);R(t,s.url)&&"basic"===s.responseTainting||"data:"===t.protocol||"navigate"===s.mode||"websocket"===s.mode?(s.responseTainting="basic",r=await De(e)):"same-origin"===s.mode?r=n('request mode cannot be "same-origin"'):"no-cors"===s.mode?"follow"!==s.redirect?r=n('redirect mode cannot be "follow" for "no-cors" request'):(s.responseTainting="opaque",r=await De(e)):H(f(s))?(s.responseTainting="cors",r=await Ne(e)):r=n("URL scheme must be a HTTP(S) scheme")}if(t)return r;0===r.status||r.internalResponse||(s.responseTainting,"basic"===s.responseTainting?r=i(r,"basic"):"cors"===s.responseTainting?r=i(r,"cors"):"opaque"===s.responseTainting?r=i(r,"opaque"):W(!1));let A=0===r.status?r:r.internalResponse;if(0===A.urlList.length&&A.urlList.push(...s.urlList),s.timingAllowFailed||(r.timingAllowPassed=!0),"opaque"===r.type&&206===A.status&&A.rangeRequested&&!s.headers.contains("range",!0)&&(r=A=n()),0===r.status||"HEAD"!==s.method&&"CONNECT"!==s.method&&!z.includes(A.status)||(A.body=null,e.controller.dump=!0),s.integrity){const t=t=>ve(e,n(t));if("opaque"===s.responseTainting||null==r.body)return void t(r.error);const i=n=>{de(n,s.integrity)?(r.body=_(n)[0],ve(e,r)):t("integrity mismatch")};M(r.body,i,t)}else ve(e,r)}catch(t){e.controller.terminate(t)}}function De(e){if(k(e)&&0===e.request.redirectCount)return Promise.resolve(r(e));const{request:t}=e,{protocol:i}=f(t);switch(i){case"about:":return Promise.resolve(n("about scheme is not supported"));case"blob:":{Ce||(Ce=s(4573).resolveObjectURL);const e=f(t);if(0!==e.search.length)return Promise.resolve(n("NetworkError when attempting to fetch resource."));const r=Ce(e.toString());if("GET"!==t.method||!he.is.Blob(r))return Promise.resolve(n("invalid method"));const i=A(),o=r.size,a=L(`${o}`),c=r.type;if(t.headersList.contains("range",!0)){i.rangeRequested=!0;const e=t.headersList.get("range",!0),s=V(e,!0);if("failure"===s)return Promise.resolve(n("failed to fetch the data URL"));let{rangeStartValue:A,rangeEndValue:a}=s;if(null===A)A=o-a,a=A+a-1;else{if(A>=o)return Promise.resolve(n("Range start is greater than the blob's size."));(null===a||a>=o)&&(a=o-1)}const l=r.slice(A,a,c),h=$(l);i.body=h[0];const g=L(`${l.size}`),d=O(A,a,o);i.status=206,i.statusText="Partial Content",i.headersList.set("content-length",g,!0),i.headersList.set("content-type",c,!0),i.headersList.set("content-range",d,!0)}else{const e=$(r);i.statusText="OK",i.body=e[0],i.headersList.set("content-length",a,!0),i.headersList.set("content-type",c,!0)}return Promise.resolve(i)}case"data:":{const e=f(t),s=oe(e);if("failure"===s)return Promise.resolve(n("failed to fetch the data URL"));const r=ae(s.mimeType);return Promise.resolve(A({statusText:"OK",headersList:[["content-type",{name:"Content-Type",value:r}]],body:_(s.body)[0]}))}case"file:":return Promise.resolve(n("not implemented... yet..."));case"http:":case"https:":return Ne(e).catch((e=>n(e)));default:return Promise.resolve(n("unknown scheme"))}}function be(e,t){e.request.done=!0,null!=e.processResponseDone&&queueMicrotask((()=>e.processResponseDone(t)))}function ve(e,t){let s=e.timingInfo;const n=()=>{const n=Date.now();"document"===e.request.destination&&(e.controller.fullTimingInfo=s),e.controller.reportTimingSteps=()=>{if(!H(e.request.url))return;s.endTime=n;let r=t.cacheState;const i=t.bodyInfo;t.timingAllowPassed||(s=S(s),r="");let A=0;if("navigator"!==e.request.mode||!t.hasCrossOriginRedirects){A=t.status;const e=J(t.headersList);"failure"!==e&&(i.contentType=ce(e))}null!=e.request.initiatorType&&me(s,e.request.url.href,e.request.initiatorType,globalThis,r,i,A)};queueMicrotask((()=>(e.request.done=!0,null!=e.processResponseEndOfBody&&queueMicrotask((()=>e.processResponseEndOfBody(t))),void(null!=e.request.initiatorType&&e.controller.reportTimingSteps()))))};null!=e.processResponse&&queueMicrotask((()=>{e.processResponse(t),e.processResponse=null}));const r="error"===t.type?t:t.internalResponse??t;null==r.body?n():se(r.body.stream,(()=>{n()}))}async function Ne(e){const t=e.request;let s=null,r=null;const i=e.timingInfo;if(t.serviceWorkers,null===s){if("follow"===t.redirect&&(t.serviceWorkers="none"),r=s=await Re(e),"cors"===t.responseTainting&&"failure"===D(t,s))return n("cors failure");"failure"===C(t,s)&&(t.timingAllowFailed=!0)}return"opaque"!==t.responseTainting&&"opaque"!==s.type||"blocked"!==b(t.origin,t.client,t.destination,r)?(q.has(r.status)&&("manual"!==t.redirect&&e.controller.connection.destroy(void 0,!1),"error"===t.redirect?s=n("unexpected redirect"):"manual"===t.redirect?s=r:"follow"===t.redirect?s=await function(e,t){const s=e.request,r=t.internalResponse?t.internalResponse:t;let i;try{if(i=Q(r,f(s).hash),null==i)return t}catch(e){return Promise.resolve(n(e))}if(!H(i))return Promise.resolve(n("URL scheme must be a HTTP(S) scheme"));if(20===s.redirectCount)return Promise.resolve(n("redirect count exceeded"));if(s.redirectCount+=1,"cors"===s.mode&&(i.username||i.password)&&!R(s,i))return Promise.resolve(n('cross origin not allowed for request mode "cors"'));if("cors"===s.responseTainting&&(i.username||i.password))return Promise.resolve(n('URL cannot contain credentials for request mode "cors"'));if(303!==r.status&&null!=s.body&&null==s.body.source)return Promise.resolve(n());if([301,302].includes(r.status)&&"POST"===s.method||303===r.status&&!Ee.includes(s.method)){s.method="GET",s.body=null;for(const e of j)s.headersList.delete(e)}R(f(s),i)||(s.headersList.delete("authorization",!0),s.headersList.delete("proxy-authorization",!0),s.headersList.delete("cookie",!0),s.headersList.delete("host",!0));null!=s.body&&(W(null!=s.body.source),s.body=_(s.body.source)[0]);const A=e.timingInfo;A.redirectEndTime=A.postRedirectStartTime=N(e.crossOriginIsolatedCapability),0===A.redirectStartTime&&(A.redirectStartTime=A.startTime);return s.urlList.push(i),m(s,r),we(e,!0)}(e,s):W(!1)),s.timingInfo=i,s):n("blocked")}async function Re(e,t=!1,s=!1){const i=e.request;let o=null,a=null,l=null;"no-window"===i.window&&"error"===i.redirect?(o=e,a=i):(a=h(i),o={...e},o.request=a);const g="include"===i.credentials||"same-origin"===i.credentials&&"basic"===i.responseTainting,d=a.body?a.body.length:null;let I=null;if(null==a.body&&["POST","PUT"].includes(a.method)&&(I="0"),null!=d&&(I=L(`${d}`)),null!=I&&a.headersList.append("content-length",I,!0),null!=d&&a.keepalive,he.is.URL(a.referrer)&&a.headersList.append("referer",L(a.referrer.href),!0),B(a),w(a),a.headersList.contains("user-agent",!0)||a.headersList.append("user-agent",pe,!0),"default"===a.cache&&(a.headersList.contains("if-modified-since",!0)||a.headersList.contains("if-none-match",!0)||a.headersList.contains("if-unmodified-since",!0)||a.headersList.contains("if-match",!0)||a.headersList.contains("if-range",!0))&&(a.cache="no-store"),"no-cache"!==a.cache||a.preventNoCacheCacheControlHeaderModification||a.headersList.contains("cache-control",!0)||a.headersList.append("cache-control","max-age=0",!0),"no-store"!==a.cache&&"reload"!==a.cache||(a.headersList.contains("pragma",!0)||a.headersList.append("pragma","no-cache",!0),a.headersList.contains("cache-control",!0)||a.headersList.append("cache-control","no-cache",!0)),a.headersList.contains("range",!0)&&a.headersList.append("accept-encoding","identity",!0),a.headersList.contains("accept-encoding",!0)||(x(f(a))?a.headersList.append("accept-encoding","br, gzip, deflate",!0):a.headersList.append("accept-encoding","gzip, deflate",!0)),a.headersList.delete("host",!0),a.cache="no-store","no-store"!==a.cache&&a.cache,null==l){if("only-if-cached"===a.cache)return n("only if cached");const e=await async function(e){W(!e.controller.connection||e.controller.connection.destroyed),e.controller.connection={abort:null,destroyed:!1,destroy(e,t=!0){this.destroyed||(this.destroyed=!0,t&&this.abort?.(e??new DOMException("The operation was aborted.","AbortError")))}};const t=e.request;let s=null;const i=e.timingInfo,o=null;null==o&&(t.cache="no-store");t.mode;let a=null;if(null==t.body&&e.processRequestEndOfBody)queueMicrotask((()=>e.processRequestEndOfBody()));else if(null!=t.body){const s=async function*(t){k(e)||(yield t,e.processRequestBodyChunkLength?.(t.byteLength))},n=()=>{k(e)||e.processRequestEndOfBody&&e.processRequestEndOfBody()},r=t=>{k(e)||("AbortError"===t.name?e.controller.abort():e.controller.terminate(t))};a=async function*(){try{for await(const e of t.body.stream)yield*s(e);n()}catch(e){r(e)}}()}try{const{body:t,status:n,statusText:r,headersList:i,socket:o}=await I({body:a});if(o)s=A({status:n,statusText:r,headersList:i,socket:o});else{const o=t[Symbol.asyncIterator]();e.controller.next=()=>o.next(),s=A({status:n,statusText:r,headersList:i})}}catch(t){return"AbortError"===t.name?(e.controller.connection.destroy(),r(e,t)):n(t)}const l=()=>e.controller.resume(),h=t=>{k(e)||e.controller.abort(t)},g=new ReadableStream({start(t){e.controller.controller=t},pull:l,cancel:h,type:"bytes"});s.body={stream:g,source:null,length:null},e.controller.resume||e.controller.on("terminated",d);function d(t){T(e)?(s.aborted=!0,re(g)&&e.controller.controller.error(e.controller.serializedAbortReason)):re(g)&&e.controller.controller.error(new TypeError("terminated",{cause:F(t)?t:void 0})),e.controller.connection.destroy()}return e.controller.resume=async()=>{for(;;){let t,n;try{const{done:s,value:n}=await e.controller.next();if(T(e))break;t=s?void 0:n}catch(s){e.controller.ended&&!i.encodedBodySize?t=void 0:(t=s,n=!0)}if(void 0===t)return U(e.controller.controller),void be(e,s);if(i.decodedBodySize+=t?.byteLength??0,n)return void e.controller.terminate(t);const r=new Uint8Array(t);if(r.byteLength&&e.controller.controller.enqueue(r),ne(g))return void e.controller.terminate();if(e.controller.controller.desiredSize<=0)return}},s;function I({body:s}){const n=f(t),r=e.controller.dispatcher;return new Promise(((A,o)=>r.dispatch({path:n.pathname+n.search,origin:n.origin,method:t.method,body:r.isMockActive?t.body&&(t.body.source||t.body.stream):s,headers:t.headersList.entries,maxRedirections:0,upgrade:"websocket"===t.mode?"websocket":void 0},{body:null,abort:null,onConnect(t){const{connection:s}=e.controller;i.finalConnectionTimingInfo=Y(void 0,i.postRedirectStartTime,e.crossOriginIsolatedCapability),s.destroyed?t(new DOMException("The operation was aborted.","AbortError")):(e.controller.on("terminated",t),this.abort=s.abort=t),i.finalNetworkRequestStartTime=N(e.crossOriginIsolatedCapability)},onResponseStarted(){i.finalNetworkResponseStartTime=N(e.crossOriginIsolatedCapability)},onHeaders(e,s,n,r){if(e<200)return!1;const i=new c;for(let e=0;e<s.length;e+=2)i.append(Ae(s[e]),s[e+1].toString("latin1"),!0);const o=i.get("location",!0);this.body=new ee({read:n});const a=o&&"follow"===t.redirect&&q.has(e),l=[];if("HEAD"!==t.method&&"CONNECT"!==t.method&&!z.includes(e)&&!a){const e=i.get("content-encoding",!0),t=e?e.toLowerCase().split(","):[];for(let e=t.length-1;e>=0;--e){const s=t[e].trim();if("x-gzip"===s||"gzip"===s)l.push(u.createGunzip({flush:u.constants.Z_SYNC_FLUSH,finishFlush:u.constants.Z_SYNC_FLUSH}));else if("deflate"===s)l.push(G({flush:u.constants.Z_SYNC_FLUSH,finishFlush:u.constants.Z_SYNC_FLUSH}));else if("br"===s)l.push(u.createBrotliDecompress({flush:u.constants.BROTLI_OPERATION_FLUSH,finishFlush:u.constants.BROTLI_OPERATION_FLUSH}));else{if("zstd"!==s||!Ie){l.length=0;break}l.push(u.createZstdDecompress({flush:u.constants.ZSTD_e_continue,finishFlush:u.constants.ZSTD_e_end}))}}}const h=this.onError.bind(this);return A({status:e,statusText:r,headersList:i,body:l.length?te(this.body,...l,(e=>{e&&this.onError(e)})).on("error",h):this.body.on("error",h)}),!0},onData(t){if(e.controller.dump)return;const s=t;return i.encodedBodySize+=s.byteLength,this.body.push(s)},onComplete(){this.abort&&e.controller.off("terminated",this.abort),e.controller.ended=!0,this.body.push(null)},onError(t){this.abort&&e.controller.off("terminated",this.abort),this.body?.destroy(t),e.controller.terminate(t),o(t)},onUpgrade(e,t,s){if(101!==e)return;const n=new c;for(let e=0;e<t.length;e+=2)n.append(Ae(t[e]),t[e+1].toString("latin1"),!0);return A({status:e,statusText:ge[e],headersList:n,socket:s}),!0}})))}}(o,g,s);!X.has(a.method)&&e.status>=200&&e.status,null==l&&(l=e)}if(l.urlList=[...a.urlList],a.headersList.contains("range",!0)&&(l.rangeRequested=!0),l.requestIncludesCredentials=g,407===l.status)return"no-window"===i.window?n():k(e)?r(e):n("proxy authentication required");if(421===l.status&&!s&&(null==i.body||null!=i.body.source)){if(k(e))return r(e);e.controller.connection.destroy(),l=await Re(e,t,!0)}return l}e.exports={fetch:function(e,t=void 0){he.argumentLengthCheck(arguments,1,"globalThis.fetch");let s,n=ue();try{s=new l(e,t)}catch(e){return n.reject(e),n.promise}const r=d(s);if(s.signal.aborted)return ye(n,r,null,s.signal.reason),n.promise;const i=r.client.globalObject;"ServiceWorkerGlobalScope"===i?.constructor?.name&&(r.serviceWorkers="none");let A=null,a=!1,c=null;return ie(s.signal,(()=>{a=!0,W(null!=c),c.abort(s.signal.reason);const e=A?.deref();ye(n,r,e,s.signal.reason)})),c=Se({request:r,processResponseEndOfBody:Qe,processResponse:e=>{a||(e.aborted?ye(n,r,A,c.serializedAbortReason):"error"!==e.type?(A=new WeakRef(o(e,"immutable")),n.resolve(A.deref()),n=null):n.reject(new TypeError("fetch failed",{cause:e.error})))},dispatcher:g(s)}),n.promise},Fetch:Be,fetching:Se,finalizeAndReportTiming:fe}},4609:(e,t,s)=>{"use strict";const{extractBody:n,mixinBody:r,cloneBody:i,bodyUnusable:A}=s(2530),{Headers:o,fill:a,HeadersList:c,setHeadersGuard:l,getHeadersGuard:h,setHeadersList:g,getHeadersList:d}=s(6558),u=s(2858),I=s(7975),{isValidHTTPToken:E,sameOrigin:p,environmentSettingsObject:C}=s(6686),{forbiddenMethodsSet:B,corsSafeListedMethodsSet:Q,referrerPolicy:f,requestRedirect:m,requestMode:y,requestCredentials:S,requestCache:w,requestDuplex:D}=s(9441),{kEnumerableProperty:b,normalizedMethodRecordsBase:v,normalizedMethodRecords:N}=u,{webidl:R}=s(6097),{URLSerializer:k}=s(9934),{kConstruct:T}=s(257),F=s(4589),{getMaxListeners:M,setMaxListeners:U,defaultMaxListeners:L}=s(8474),P=Symbol("abortController"),H=new FinalizationRegistry((({signal:e,abort:t})=>{e.removeEventListener("abort",t)})),x=new WeakMap;let Y;try{Y=M((new AbortController).signal)>0}catch{Y=!1}function V(e){return function t(){const s=e.deref();if(void 0!==s){H.unregister(t),this.removeEventListener("abort",t),s.abort(this.reason);const e=x.get(s.signal);if(void 0!==e){if(0!==e.size){for(const t of e){const e=t.deref();void 0!==e&&e.abort(this.reason)}e.clear()}x.delete(s.signal)}}}}let O=!1;class G{#Ze;#$e;#Be;#le;constructor(e,t=void 0){if(R.util.markAsUncloneable(this),e===T)return;R.argumentLengthCheck(arguments,1,"Request constructor"),e=R.converters.RequestInfo(e),t=R.converters.RequestInit(t);let s=null,r=null;const i=C.settingsObject.baseUrl;let h=null;if("string"==typeof e){let n;this.#$e=t.dispatcher;try{n=new URL(e,i)}catch(t){throw new TypeError("Failed to parse URL from "+e,{cause:t})}if(n.username||n.password)throw new TypeError("Request cannot be constructed from a URL that includes credentials: "+e);s=X({urlList:[n]}),r="cors"}else F(R.is.Request(e)),s=e.#le,h=e.#Ze,this.#$e=t.dispatcher||e.#$e;const I=C.settingsObject.origin;let f="client";if("EnvironmentSettingsObject"===s.window?.constructor?.name&&p(s.window,I)&&(f=s.window),null!=t.window)throw new TypeError(`'window' option '${f}' must be null`);"window"in t&&(f="no-window"),s=X({method:s.method,headersList:s.headersList,unsafeRequest:s.unsafeRequest,client:C.settingsObject,window:f,priority:s.priority,origin:s.origin,referrer:s.referrer,referrerPolicy:s.referrerPolicy,mode:s.mode,credentials:s.credentials,cache:s.cache,redirect:s.redirect,integrity:s.integrity,keepalive:s.keepalive,reloadNavigation:s.reloadNavigation,historyNavigation:s.historyNavigation,urlList:[...s.urlList]});const m=0!==Object.keys(t).length;if(m&&("navigate"===s.mode&&(s.mode="same-origin"),s.reloadNavigation=!1,s.historyNavigation=!1,s.origin="client",s.referrer="client",s.referrerPolicy="",s.url=s.urlList[s.urlList.length-1],s.urlList=[s.url]),void 0!==t.referrer){const e=t.referrer;if(""===e)s.referrer="no-referrer";else{let t;try{t=new URL(e,i)}catch(t){throw new TypeError(`Referrer "${e}" is not a valid URL.`,{cause:t})}"about:"===t.protocol&&"client"===t.hostname||I&&!p(t,C.settingsObject.baseUrl)?s.referrer="client":s.referrer=t}}let y;if(void 0!==t.referrerPolicy&&(s.referrerPolicy=t.referrerPolicy),y=void 0!==t.mode?t.mode:r,"navigate"===y)throw R.errors.exception({header:"Request constructor",message:"invalid request mode navigate."});if(null!=y&&(s.mode=y),void 0!==t.credentials&&(s.credentials=t.credentials),void 0!==t.cache&&(s.cache=t.cache),"only-if-cached"===s.cache&&"same-origin"!==s.mode)throw new TypeError("'only-if-cached' can be set only with 'same-origin' mode");if(void 0!==t.redirect&&(s.redirect=t.redirect),null!=t.integrity&&(s.integrity=String(t.integrity)),void 0!==t.keepalive&&(s.keepalive=Boolean(t.keepalive)),void 0!==t.method){let e=t.method;const n=N[e];if(void 0!==n)s.method=n;else{if(!E(e))throw new TypeError(`'${e}' is not a valid HTTP method.`);const t=e.toUpperCase();if(B.has(t))throw new TypeError(`'${e}' HTTP method is unsupported.`);e=v[t]??e,s.method=e}O||"patch"!==s.method||(process.emitWarning("Using `patch` is highly likely to result in a `405 Method Not Allowed`. `PATCH` is much more likely to succeed.",{code:"UNDICI-FETCH-patch"}),O=!0)}void 0!==t.signal&&(h=t.signal),this.#le=s;const S=new AbortController;if(this.#Ze=S.signal,null!=h)if(h.aborted)S.abort(h.reason);else{this[P]=S;const e=V(new WeakRef(S));Y&&M(h)===L&&U(1500,h),u.addAbortListener(h,e),H.register(S,{signal:h,abort:e},e)}if(this.#Be=new o(T),g(this.#Be,s.headersList),l(this.#Be,"request"),"no-cors"===y){if(!Q.has(s.method))throw new TypeError(`'${s.method} is unsupported in no-cors mode.`);l(this.#Be,"request-no-cors")}if(m){const e=d(this.#Be),s=void 0!==t.headers?t.headers:new c(e);if(e.clear(),s instanceof c){for(const{name:t,value:n}of s.rawValues())e.append(t,n,!1);e.cookies=s.cookies}else a(this.#Be,s)}const w=R.is.Request(e)?e.#le.body:null;if(!(null==t.body&&null==w||"GET"!==s.method&&"HEAD"!==s.method))throw new TypeError("Request with GET/HEAD method cannot have body.");let D=null;if(null!=t.body){const[e,r]=n(t.body,s.keepalive);D=e,r&&!d(this.#Be).contains("content-type",!0)&&this.#Be.append("content-type",r,!0)}const b=D??w;if(null!=b&&null==b.source){if(null!=D&&null==t.duplex)throw new TypeError("RequestInit: duplex option is required when sending a body.");if("same-origin"!==s.mode&&"cors"!==s.mode)throw new TypeError('If request is made from ReadableStream, mode should be "same-origin" or "cors"');s.useCORSPreflightFlag=!0}let k=b;if(null==D&&null!=w){if(A(e.#le))throw new TypeError("Cannot construct a Request with a Request object that has already been used.");const t=new TransformStream;w.stream.pipeThrough(t),k={source:w.source,length:w.length,stream:t.readable}}this.#le.body=k}get method(){return R.brandCheck(this,G),this.#le.method}get url(){return R.brandCheck(this,G),k(this.#le.url)}get headers(){return R.brandCheck(this,G),this.#Be}get destination(){return R.brandCheck(this,G),this.#le.destination}get referrer(){return R.brandCheck(this,G),"no-referrer"===this.#le.referrer?"":"client"===this.#le.referrer?"about:client":this.#le.referrer.toString()}get referrerPolicy(){return R.brandCheck(this,G),this.#le.referrerPolicy}get mode(){return R.brandCheck(this,G),this.#le.mode}get credentials(){return R.brandCheck(this,G),this.#le.credentials}get cache(){return R.brandCheck(this,G),this.#le.cache}get redirect(){return R.brandCheck(this,G),this.#le.redirect}get integrity(){return R.brandCheck(this,G),this.#le.integrity}get keepalive(){return R.brandCheck(this,G),this.#le.keepalive}get isReloadNavigation(){return R.brandCheck(this,G),this.#le.reloadNavigation}get isHistoryNavigation(){return R.brandCheck(this,G),this.#le.historyNavigation}get signal(){return R.brandCheck(this,G),this.#Ze}get body(){return R.brandCheck(this,G),this.#le.body?this.#le.body.stream:null}get bodyUsed(){return R.brandCheck(this,G),!!this.#le.body&&u.isDisturbed(this.#le.body.stream)}get duplex(){return R.brandCheck(this,G),"half"}clone(){if(R.brandCheck(this,G),A(this.#le))throw new TypeError("unusable");const e=j(this.#le),t=new AbortController;if(this.signal.aborted)t.abort(this.signal.reason);else{let e=x.get(this.signal);void 0===e&&(e=new Set,x.set(this.signal,e));const s=new WeakRef(t);e.add(s),u.addAbortListener(t.signal,V(s))}return Z(e,this.#$e,t.signal,h(this.#Be))}[I.inspect.custom](e,t){null===t.depth&&(t.depth=2),t.colors??=!0;const s={method:this.method,url:this.url,headers:this.headers,destination:this.destination,referrer:this.referrer,referrerPolicy:this.referrerPolicy,mode:this.mode,credentials:this.credentials,cache:this.cache,redirect:this.redirect,integrity:this.integrity,keepalive:this.keepalive,isReloadNavigation:this.isReloadNavigation,isHistoryNavigation:this.isHistoryNavigation,signal:this.signal};return`Request ${I.formatWithOptions(t,s)}`}static setRequestSignal(e,t){return e.#Ze=t,e}static getRequestDispatcher(e){return e.#$e}static setRequestDispatcher(e,t){e.#$e=t}static setRequestHeaders(e,t){e.#Be=t}static getRequestState(e){return e.#le}static setRequestState(e,t){e.#le=t}}const{setRequestSignal:J,getRequestDispatcher:W,setRequestDispatcher:_,setRequestHeaders:$,getRequestState:q,setRequestState:z}=G;function X(e){return{method:e.method??"GET",localURLsOnly:e.localURLsOnly??!1,unsafeRequest:e.unsafeRequest??!1,body:e.body??null,client:e.client??null,reservedClient:e.reservedClient??null,replacesClientId:e.replacesClientId??"",window:e.window??"client",keepalive:e.keepalive??!1,serviceWorkers:e.serviceWorkers??"all",initiator:e.initiator??"",destination:e.destination??"",priority:e.priority??null,origin:e.origin??"client",policyContainer:e.policyContainer??"client",referrer:e.referrer??"client",referrerPolicy:e.referrerPolicy??"",mode:e.mode??"no-cors",useCORSPreflightFlag:e.useCORSPreflightFlag??!1,credentials:e.credentials??"same-origin",useCredentials:e.useCredentials??!1,cache:e.cache??"default",redirect:e.redirect??"follow",integrity:e.integrity??"",cryptoGraphicsNonceMetadata:e.cryptoGraphicsNonceMetadata??"",parserMetadata:e.parserMetadata??"",reloadNavigation:e.reloadNavigation??!1,historyNavigation:e.historyNavigation??!1,userActivation:e.userActivation??!1,taintedOrigin:e.taintedOrigin??!1,redirectCount:e.redirectCount??0,responseTainting:e.responseTainting??"basic",preventNoCacheCacheControlHeaderModification:e.preventNoCacheCacheControlHeaderModification??!1,done:e.done??!1,timingAllowFailed:e.timingAllowFailed??!1,urlList:e.urlList,url:e.urlList[0],headersList:e.headersList?new c(e.headersList):new c}}function j(e){const t=X({...e,body:null});return null!=e.body&&(t.body=i(e.body)),t}function Z(e,t,s,n){const r=new G(T);z(r,e),_(r,t),J(r,s);const i=new o(T);return $(r,i),g(i,e.headersList),l(i,n),r}Reflect.deleteProperty(G,"setRequestSignal"),Reflect.deleteProperty(G,"getRequestDispatcher"),Reflect.deleteProperty(G,"setRequestDispatcher"),Reflect.deleteProperty(G,"setRequestHeaders"),Reflect.deleteProperty(G,"getRequestState"),Reflect.deleteProperty(G,"setRequestState"),r(G,q),Object.defineProperties(G.prototype,{method:b,url:b,headers:b,redirect:b,clone:b,signal:b,duplex:b,destination:b,body:b,bodyUsed:b,isHistoryNavigation:b,isReloadNavigation:b,keepalive:b,integrity:b,cache:b,credentials:b,attribute:b,referrerPolicy:b,referrer:b,mode:b,[Symbol.toStringTag]:{value:"Request",configurable:!0}}),R.is.Request=R.util.MakeTypeAssertion(G),R.converters.RequestInfo=function(e){return"string"==typeof e?R.converters.USVString(e):R.is.Request(e)?e:R.converters.USVString(e)},R.converters.RequestInit=R.dictionaryConverter([{key:"method",converter:R.converters.ByteString},{key:"headers",converter:R.converters.HeadersInit},{key:"body",converter:R.nullableConverter(R.converters.BodyInit)},{key:"referrer",converter:R.converters.USVString},{key:"referrerPolicy",converter:R.converters.DOMString,allowedValues:f},{key:"mode",converter:R.converters.DOMString,allowedValues:y},{key:"credentials",converter:R.converters.DOMString,allowedValues:S},{key:"cache",converter:R.converters.DOMString,allowedValues:w},{key:"redirect",converter:R.converters.DOMString,allowedValues:m},{key:"integrity",converter:R.converters.DOMString},{key:"keepalive",converter:R.converters.boolean},{key:"signal",converter:R.nullableConverter((e=>R.converters.AbortSignal(e,"RequestInit","signal")))},{key:"window",converter:R.converters.any},{key:"duplex",converter:R.converters.DOMString,allowedValues:D},{key:"dispatcher",converter:R.converters.any}]),e.exports={Request:G,makeRequest:X,fromInnerRequest:Z,cloneRequest:j,getRequestDispatcher:W,getRequestState:q}},4821:(e,t,s)=>{"use strict";const{Headers:n,HeadersList:r,fill:i,getHeadersGuard:A,setHeadersGuard:o,setHeadersList:a}=s(6558),{extractBody:c,cloneBody:l,mixinBody:h,streamRegistry:g,bodyUnusable:d}=s(2530),u=s(2858),I=s(7975),{kEnumerableProperty:E}=u,{isValidReasonPhrase:p,isCancelled:C,isAborted:B,serializeJavascriptValueToJSONString:Q,isErrorLike:f,isomorphicEncode:m,environmentSettingsObject:y}=s(6686),{redirectStatusSet:S,nullBodyStatus:w}=s(9441),{webidl:D}=s(6097),{URLSerializer:b}=s(9934),{kConstruct:v}=s(257),N=s(4589),R=new TextEncoder("utf-8");class k{#Be;#le;static error(){return O(H(),"immutable")}static json(e,t=void 0){D.argumentLengthCheck(arguments,1,"Response.json"),null!==t&&(t=D.converters.ResponseInit(t));const s=R.encode(Q(e)),n=c(s),r=O(P({}),"response");return V(r,t,{body:n[0],type:"application/json"}),r}static redirect(e,t=302){let s;D.argumentLengthCheck(arguments,1,"Response.redirect"),e=D.converters.USVString(e),t=D.converters["unsigned short"](t);try{s=new URL(e,y.settingsObject.baseUrl)}catch(t){throw new TypeError(`Failed to parse URL from ${e}`,{cause:t})}if(!S.has(t))throw new RangeError(`Invalid status code ${t}`);const n=O(P({}),"immutable");n.#le.status=t;const r=m(b(s));return n.#le.headersList.append("location",r,!0),n}constructor(e=null,t=void 0){if(D.util.markAsUncloneable(this),e===v)return;null!==e&&(e=D.converters.BodyInit(e,"Response","body")),t=D.converters.ResponseInit(t),this.#le=P({}),this.#Be=new n(v),o(this.#Be,"response"),a(this.#Be,this.#le.headersList);let s=null;if(null!=e){const[t,n]=c(e);s={body:t,type:n}}V(this,t,s)}get type(){return D.brandCheck(this,k),this.#le.type}get url(){D.brandCheck(this,k);const e=this.#le.urlList,t=e[e.length-1]??null;return null===t?"":b(t,!0)}get redirected(){return D.brandCheck(this,k),this.#le.urlList.length>1}get status(){return D.brandCheck(this,k),this.#le.status}get ok(){return D.brandCheck(this,k),this.#le.status>=200&&this.#le.status<=299}get statusText(){return D.brandCheck(this,k),this.#le.statusText}get headers(){return D.brandCheck(this,k),this.#Be}get body(){return D.brandCheck(this,k),this.#le.body?this.#le.body.stream:null}get bodyUsed(){return D.brandCheck(this,k),!!this.#le.body&&u.isDisturbed(this.#le.body.stream)}clone(){if(D.brandCheck(this,k),d(this.#le))throw D.errors.exception({header:"Response.clone",message:"Body has already been consumed."});const e=L(this.#le);return this.#le.body?.stream&&g.register(this,new WeakRef(this.#le.body.stream)),O(e,A(this.#Be))}[I.inspect.custom](e,t){null===t.depth&&(t.depth=2),t.colors??=!0;const s={status:this.status,statusText:this.statusText,headers:this.headers,body:this.body,bodyUsed:this.bodyUsed,ok:this.ok,redirected:this.redirected,type:this.type,url:this.url};return`Response ${I.formatWithOptions(t,s)}`}static getResponseHeaders(e){return e.#Be}static setResponseHeaders(e,t){e.#Be=t}static getResponseState(e){return e.#le}static setResponseState(e,t){e.#le=t}}const{getResponseHeaders:T,setResponseHeaders:F,getResponseState:M,setResponseState:U}=k;function L(e){if(e.internalResponse)return Y(L(e.internalResponse),e.type);const t=P({...e,body:null});return null!=e.body&&(t.body=l(e.body)),t}function P(e){return{aborted:!1,rangeRequested:!1,timingAllowPassed:!1,requestIncludesCredentials:!1,type:"default",status:200,timingInfo:null,cacheState:"",statusText:"",...e,headersList:e?.headersList?new r(e?.headersList):new r,urlList:e?.urlList?[...e.urlList]:[]}}function H(e){return P({type:"error",status:0,error:f(e)?e:new Error(e?String(e):e),aborted:e&&"AbortError"===e.name})}function x(e,t){return t={internalResponse:e,...t},new Proxy(e,{get:(e,s)=>s in t?t[s]:e[s],set:(e,s,n)=>(N(!(s in t)),e[s]=n,!0)})}function Y(e,t){return"basic"===t?x(e,{type:"basic",headersList:e.headersList}):"cors"===t?x(e,{type:"cors",headersList:e.headersList}):"opaque"===t?x(e,{type:"opaque",urlList:Object.freeze([]),status:0,statusText:"",body:null}):"opaqueredirect"===t?x(e,{type:"opaqueredirect",status:0,statusText:"",headersList:[],body:null}):void N(!1)}function V(e,t,s){if(null!==t.status&&(t.status<200||t.status>599))throw new RangeError('init["status"] must be in the range of 200 to 599, inclusive.');if("statusText"in t&&null!=t.statusText&&!p(String(t.statusText)))throw new TypeError("Invalid statusText");if("status"in t&&null!=t.status&&(M(e).status=t.status),"statusText"in t&&null!=t.statusText&&(M(e).statusText=t.statusText),"headers"in t&&null!=t.headers&&i(T(e),t.headers),s){if(w.includes(e.status))throw D.errors.exception({header:"Response constructor",message:`Invalid response status code ${e.status}`});M(e).body=s.body,null==s.type||M(e).headersList.contains("content-type",!0)||M(e).headersList.append("content-type",s.type,!0)}}function O(e,t){const s=new k(v);U(s,e);const r=new n(v);return F(s,r),a(r,e.headersList),o(r,t),e.body?.stream&&g.register(s,new WeakRef(e.body.stream)),s}Reflect.deleteProperty(k,"getResponseHeaders"),Reflect.deleteProperty(k,"setResponseHeaders"),Reflect.deleteProperty(k,"getResponseState"),Reflect.deleteProperty(k,"setResponseState"),h(k,M),Object.defineProperties(k.prototype,{type:E,url:E,status:E,ok:E,redirected:E,statusText:E,headers:E,clone:E,body:E,bodyUsed:E,[Symbol.toStringTag]:{value:"Response",configurable:!0}}),Object.defineProperties(k,{json:E,redirect:E,error:E}),D.converters.XMLHttpRequestBodyInit=function(e,t,s){return"string"==typeof e?D.converters.USVString(e,t,s):D.is.Blob(e)||D.is.BufferSource(e)||D.is.FormData(e)||D.is.URLSearchParams(e)?e:D.converters.DOMString(e,t,s)},D.converters.BodyInit=function(e,t,s){return D.is.ReadableStream(e)||e?.[Symbol.asyncIterator]?e:D.converters.XMLHttpRequestBodyInit(e,t,s)},D.converters.ResponseInit=D.dictionaryConverter([{key:"status",converter:D.converters["unsigned short"],defaultValue:()=>200},{key:"statusText",converter:D.converters.ByteString,defaultValue:()=>""},{key:"headers",converter:D.converters.HeadersInit}]),D.is.Response=D.util.MakeTypeAssertion(k),e.exports={isNetworkError:function(e){return"error"===e.type&&0===e.status},makeNetworkError:H,makeResponse:P,makeAppropriateNetworkError:function(e,t=null){return N(C(e)),B(e)?H(Object.assign(new DOMException("The operation was aborted.","AbortError"),{cause:t})):H(Object.assign(new DOMException("Request was cancelled."),{cause:t}))},filterResponse:Y,Response:k,cloneResponse:L,fromInnerResponse:O,getResponseState:M}},6686:(e,t,s)=>{"use strict";const{Transform:n}=s(7075),r=s(8522),{redirectStatusSet:i,referrerPolicyTokens:A,badPortsSet:o}=s(9441),{getGlobalOrigin:a}=s(2837),{collectASequenceOfCodePoints:c,collectAnHTTPQuotedString:l,removeChars:h,parseMIMEType:g}=s(9934),{performance:d}=s(643),{ReadableStreamFrom:u,isValidHTTPToken:I,normalizedMethodRecordsBase:E}=s(2858),p=s(4589),{isUint8Array:C}=s(3429),{webidl:B}=s(6097);function Q(e){const t=e.urlList,s=t.length;return 0===s?null:t[s-1].toString()}function f(e){for(let t=0;t<e.length;++t){const s=e.charCodeAt(t);if(s>126||s<32)return!1}return!0}function m(e){return e.urlList[e.urlList.length-1]}const y=I;function S(e){return!1===("\t"===e[0]||" "===e[0]||"\t"===e[e.length-1]||" "===e[e.length-1]||e.includes("\n")||e.includes("\r")||e.includes("\0"))}function w(e,t){return e}function D(){return{referrerPolicy:"strict-origin-when-cross-origin"}}function b(e,t=!1){return p(B.is.URL(e)),H(e=new URL(e))?"no-referrer":(e.username="",e.password="",e.hash="",!0===t&&(e.pathname="",e.search=""),e)}const v=RegExp.prototype.test.bind(/^127\.(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){2}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)$/),N=RegExp.prototype.test.bind(/^(?:(?:0{1,4}:){7}|(?:0{1,4}:){1,6}:|::)0{0,3}1$/);function R(e){return e.includes(":")?("["===e[0]&&"]"===e[e.length-1]&&(e=e.slice(1,-1)),N(e)):v(e)}function k(e){return!!B.is.URL(e)&&("about:blank"===e.href||"about:srcdoc"===e.href||("data:"===e.protocol||("blob:"===e.protocol||!(null==(t=e.origin)||"null"===t||"https:"!==(t=new URL(t)).protocol&&"wss:"!==t.protocol&&!R(t.hostname)&&"localhost"!==t.hostname&&"localhost."!==t.hostname&&!t.hostname.endsWith(".localhost")&&!t.hostname.endsWith(".localhost.")&&"file:"!==t.protocol))));var t}function T(e,t){return e.origin===t.origin&&"null"===e.origin||e.protocol===t.protocol&&e.hostname===t.hostname&&e.port===t.port}const F=Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()));function M(e,t,s=0,n=1){class r{#Ke;#et;#tt;constructor(e,t){this.#Ke=e,this.#et=t,this.#tt=0}next(){if("object"!=typeof this||null===this||!(#Ke in this))throw new TypeError(`'next' called on an object that does not implement interface ${e} Iterator.`);const r=this.#tt,i=t(this.#Ke);if(r>=i.length)return{value:void 0,done:!0};const{[s]:A,[n]:o}=i[r];let a;switch(this.#tt=r+1,this.#et){case"key":a=A;break;case"value":a=o;break;case"key+value":a=[A,o]}return{value:a,done:!1}}}return delete r.prototype.constructor,Object.setPrototypeOf(r.prototype,F),Object.defineProperties(r.prototype,{[Symbol.toStringTag]:{writable:!1,enumerable:!1,configurable:!0,value:`${e} Iterator`},next:{writable:!0,enumerable:!0,configurable:!0}}),function(e,t){return new r(e,t)}}const U=/[^\x00-\xFF]/;function L(e){return p(!U.test(e)),e}async function P(e,t,s){try{const n=[];let r=0;for(;;){const{done:i,value:A}=await e.read();if(i)return void t(Buffer.concat(n,r));if(!C(A))return void s(new TypeError("Received non-Uint8Array chunk"));n.push(A),r+=A.length}}catch(e){s(e)}}function H(e){p("protocol"in e);const t=e.protocol;return"about:"===t||"blob:"===t||"data:"===t}function x(e){return"string"==typeof e&&":"===e[5]&&"h"===e[0]&&"t"===e[1]&&"t"===e[2]&&"p"===e[3]&&"s"===e[4]||"https:"===e.protocol}function Y(e){p("protocol"in e);const t=e.protocol;return"http:"===t||"https:"===t}class V extends n{#st;constructor(e){super(),this.#st=e}_transform(e,t,s){if(!this._inflateStream){if(0===e.length)return void s();this._inflateStream=8==(15&e[0])?r.createInflate(this.#st):r.createInflateRaw(this.#st),this._inflateStream.on("data",this.push.bind(this)),this._inflateStream.on("end",(()=>this.push(null))),this._inflateStream.on("error",(e=>this.destroy(e)))}this._inflateStream.write(e,t,s)}_final(e){this._inflateStream&&(this._inflateStream.end(),this._inflateStream=null),e()}}function O(e,t){const s=t.get(e,!0);return null===s?null:function(e){const t=e,s={position:0},n=[];let r="";for(;s.position<t.length;){if(r+=c((e=>'"'!==e&&","!==e),t,s),s.position<t.length)if(34===t.charCodeAt(s.position)){if(r+=l(t,s),s.position<t.length)continue}else p(44===t.charCodeAt(s.position)),s.position++;r=h(r,!0,!0,(e=>9===e||32===e)),n.push(r),r=""}return n}(s)}const G=new TextDecoder;class J{get baseUrl(){return a()}get origin(){return this.baseUrl?.origin}policyContainer={referrerPolicy:"strict-origin-when-cross-origin"}}const W=new class{settingsObject=new J};e.exports={isAborted:function(e){return"aborted"===e.controller.state},isCancelled:function(e){return"aborted"===e.controller.state||"terminated"===e.controller.state},isValidEncodedURL:f,ReadableStreamFrom:u,tryUpgradeRequestToAPotentiallyTrustworthyURL:function(e){},clampAndCoarsenConnectionTimingInfo:function(e,t,s){return!e?.startTime||e.startTime<t?{domainLookupStartTime:t,domainLookupEndTime:t,connectionStartTime:t,connectionEndTime:t,secureConnectionStartTime:t,ALPNNegotiatedProtocol:e?.ALPNNegotiatedProtocol}:{domainLookupStartTime:w(e.domainLookupStartTime),domainLookupEndTime:w(e.domainLookupEndTime),connectionStartTime:w(e.connectionStartTime),connectionEndTime:w(e.connectionEndTime),secureConnectionStartTime:w(e.secureConnectionStartTime),ALPNNegotiatedProtocol:e.ALPNNegotiatedProtocol}},coarsenedSharedCurrentTime:function(e){return w(d.now())},determineRequestsReferrer:function(e){const t=e.referrerPolicy;p(t);let s=null;if("client"===e.referrer){const e=a();if(!e||"null"===e.origin)return"no-referrer";s=new URL(e)}else B.is.URL(e.referrer)&&(s=e.referrer);let n=b(s);const r=b(s,!0);switch(n.toString().length>4096&&(n=r),t){case"no-referrer":return"no-referrer";case"origin":return null!=r?r:b(s,!0);case"unsafe-url":return n;case"strict-origin":{const t=m(e);return k(n)&&!k(t)?"no-referrer":r}case"strict-origin-when-cross-origin":{const t=m(e);return T(n,t)?n:k(n)&&!k(t)?"no-referrer":r}case"same-origin":return T(e,n)?n:"no-referrer";case"origin-when-cross-origin":return T(e,n)?n:r;case"no-referrer-when-downgrade":{const t=m(e);return k(n)&&!k(t)?"no-referrer":n}}},makePolicyContainer:D,clonePolicyContainer:function(e){return{referrerPolicy:e.referrerPolicy}},appendFetchMetadata:function(e){let t=null;t=e.mode,e.headersList.set("sec-fetch-mode",t,!0)},appendRequestOriginHeader:function(e){let t=e.origin;if("client"!==t&&void 0!==t)if("cors"===e.responseTainting||"websocket"===e.mode)e.headersList.append("origin",t,!0);else if("GET"!==e.method&&"HEAD"!==e.method){switch(e.referrerPolicy){case"no-referrer":t=null;break;case"no-referrer-when-downgrade":case"strict-origin":case"strict-origin-when-cross-origin":e.origin&&x(e.origin)&&!x(m(e))&&(t=null);break;case"same-origin":T(e,m(e))||(t=null)}e.headersList.append("origin",t,!0)}},TAOCheck:function(){return"success"},corsCheck:function(){return"success"},crossOriginResourcePolicyCheck:function(){return"allowed"},createOpaqueTimingInfo:function(e){return{startTime:e.startTime??0,redirectStartTime:0,redirectEndTime:0,postRedirectStartTime:e.startTime??0,finalServiceWorkerStartTime:0,finalNetworkResponseStartTime:0,finalNetworkRequestStartTime:0,endTime:0,encodedBodySize:0,decodedBodySize:0,finalConnectionTimingInfo:null}},setRequestReferrerPolicyOnRedirect:function(e,t){const s=function(e){const t=(e.headersList.get("referrer-policy",!0)??"").split(",");let s="";if(t.length)for(let e=t.length;0!==e;e--){const n=t[e-1].trim();if(A.has(n)){s=n;break}}return s}(t);""!==s&&(e.referrerPolicy=s)},isValidHTTPToken:I,requestBadPort:function(e){const t=m(e);return Y(t)&&o.has(t.port)?"blocked":"allowed"},requestCurrentURL:m,responseURL:Q,responseLocationURL:function(e,t){if(!i.has(e.status))return null;let s=e.headersList.get("location",!0);var n;return null!==s&&S(s)&&(f(s)||(n=s,s=Buffer.from(n,"binary").toString("utf8")),s=new URL(s,Q(e))),s&&!s.hash&&(s.hash=t),s},isURLPotentiallyTrustworthy:k,isValidReasonPhrase:function(e){for(let t=0;t<e.length;++t){const s=e.charCodeAt(t);if(!(9===s||s>=32&&s<=126||s>=128&&s<=255))return!1}return!0},sameOrigin:T,normalizeMethod:function(e){return E[e.toLowerCase()]??e},serializeJavascriptValueToJSONString:function(e){const t=JSON.stringify(e);if(void 0===t)throw new TypeError("Value is not JSON serializable");return p("string"==typeof t),t},iteratorMixin:function(e,t,s,n=0,r=1){const i=M(e,s,n,r),A={keys:{writable:!0,enumerable:!0,configurable:!0,value:function(){return B.brandCheck(this,t),i(this,"key")}},values:{writable:!0,enumerable:!0,configurable:!0,value:function(){return B.brandCheck(this,t),i(this,"value")}},entries:{writable:!0,enumerable:!0,configurable:!0,value:function(){return B.brandCheck(this,t),i(this,"key+value")}},forEach:{writable:!0,enumerable:!0,configurable:!0,value:function(s,n=globalThis){if(B.brandCheck(this,t),B.argumentLengthCheck(arguments,1,`${e}.forEach`),"function"!=typeof s)throw new TypeError(`Failed to execute 'forEach' on '${e}': parameter 1 is not of type 'Function'.`);for(const{0:e,1:t}of i(this,"key+value"))s.call(n,t,e,this)}}};return Object.defineProperties(t.prototype,{...A,[Symbol.iterator]:{writable:!0,enumerable:!1,configurable:!0,value:A.entries.value}})},createIterator:M,isValidHeaderName:y,isValidHeaderValue:S,isErrorLike:function(e){return e instanceof Error||"Error"===e?.constructor?.name||"DOMException"===e?.constructor?.name},fullyReadBody:function(e,t,s){const n=t,r=s;try{P(e.stream.getReader(),n,r)}catch(e){r(e)}},readableStreamClose:function(e){try{e.close(),e.byobRequest?.respond(0)}catch(e){if(!e.message.includes("Controller is already closed")&&!e.message.includes("ReadableStream is already closed"))throw e}},isomorphicEncode:L,urlIsLocal:H,urlHasHttpsScheme:x,urlIsHttpHttpsScheme:Y,readAllBytes:P,simpleRangeHeaderValue:function(e,t){const s=e;if(!s.startsWith("bytes"))return"failure";const n={position:5};if(t&&c((e=>"\t"===e||" "===e),s,n),61!==s.charCodeAt(n.position))return"failure";n.position++,t&&c((e=>"\t"===e||" "===e),s,n);const r=c((e=>{const t=e.charCodeAt(0);return t>=48&&t<=57}),s,n),i=r.length?Number(r):null;if(t&&c((e=>"\t"===e||" "===e),s,n),45!==s.charCodeAt(n.position))return"failure";n.position++,t&&c((e=>"\t"===e||" "===e),s,n);const A=c((e=>{const t=e.charCodeAt(0);return t>=48&&t<=57}),s,n),o=A.length?Number(A):null;return n.position<s.length||null===o&&null===i||i>o?"failure":{rangeStartValue:i,rangeEndValue:o}},buildContentRange:function(e,t,s){let n="bytes ";return n+=L(`${e}`),n+="-",n+=L(`${t}`),n+="/",n+=L(`${s}`),n},createInflate:function(e){return new V(e)},extractMimeType:function(e){let t=null,s=null,n=null;const r=O("content-type",e);if(null===r)return"failure";for(const e of r){const r=g(e);"failure"!==r&&"*/*"!==r.essence&&(n=r,n.essence!==s?(t=null,n.parameters.has("charset")&&(t=n.parameters.get("charset")),s=n.essence):n.parameters.has("charset")||null===t||n.parameters.set("charset",t))}return null==n?"failure":n},getDecodeSplit:O,utf8DecodeBytes:function(e){return 0===e.length?"":(239===e[0]&&187===e[1]&&191===e[2]&&(e=e.subarray(3)),G.decode(e))},environmentSettingsObject:W,isOriginIPPotentiallyTrustworthy:R}},7420:(e,t,s)=>{"use strict";const n=s(4589),r=new Map([["sha256",0],["sha384",1],["sha512",2]]);let i;try{i=s(7598);const e=i.getHashes();0===e.length&&r.clear();for(const t of r.keys())!1===e.includes(t)&&r.delete(t)}catch{r.clear()}const A=Map.prototype.get.bind(r),o=Map.prototype.has.bind(r),a=void 0===i||0===r.size?()=>!0:(e,t)=>{const s=l(t);if(0===s.length)return!0;const n=c(s);for(const t of n){const s=t.alg,n=t.val;if(g(h(s,e),n))return!0}return!1};function c(e){const t=[];let s=null;for(const r of e){if(n(o(r.alg),"Invalid SRI hash algorithm token"),0===t.length){t.push(r),s=r;continue}const e=s.alg,i=A(e),a=r.alg,c=A(a);c<i||(c>i?(s=r,t[0]=r,t.length=1):t.push(r))}return t}function l(e){const t=[];for(const s of e.split(" ")){const e=s.split("?",1)[0];let n="";const r=[e.slice(0,6),e.slice(7)],i=r[0];if(!o(i))continue;r[1]&&(n=r[1]);const A={alg:i,val:n};t.push(A)}return t}const h=(e,t)=>i.hash(e,t,"base64");function g(e,t){let s=e.length;0!==s&&"="===e[s-1]&&(s-=1),0!==s&&"="===e[s-1]&&(s-=1);let n=t.length;if(0!==n&&"="===t[n-1]&&(n-=1),0!==n&&"="===t[n-1]&&(n-=1),s!==n)return!1;for(let n=0;n<s;++n)if(!(e[n]===t[n]||"+"===e[n]&&"-"===t[n]||"/"===e[n]&&"_"===t[n]))return!1;return!0}e.exports={applyAlgorithmToBytes:h,bytesMatch:a,caseSensitiveMatch:g,isValidSRIHashAlgorithm:o,getStrongestMetadata:c,parseMetadata:l}},6097:(e,t,s)=>{"use strict";const{types:n,inspect:r}=s(7975),{markAsUncloneable:i}=s(5919),A=Function.call.bind(Function.prototype[Symbol.hasInstance]),o={converters:{},util:{},errors:{},is:{}};o.errors.exception=function(e){return new TypeError(`${e.header}: ${e.message}`)},o.errors.conversionFailed=function(e){const t=1===e.types.length?"":" one of",s=`${e.argument} could not be converted to${t}: ${e.types.join(", ")}.`;return o.errors.exception({header:e.prefix,message:s})},o.errors.invalidArgument=function(e){return o.errors.exception({header:e.prefix,message:`"${e.value}" is an invalid ${e.type}.`})},o.brandCheck=function(e,t){if(!A(t,e)){const e=new TypeError("Illegal invocation");throw e.code="ERR_INVALID_THIS",e}},o.brandCheckMultiple=function(e){const t=e.map((e=>o.util.MakeTypeAssertion(e)));return e=>{if(t.every((t=>!t(e)))){const e=new TypeError("Illegal invocation");throw e.code="ERR_INVALID_THIS",e}}},o.argumentLengthCheck=function({length:e},t,s){if(e<t)throw o.errors.exception({message:`${t} argument${1!==t?"s":""} required, but${e?" only":""} ${e} found.`,header:s})},o.illegalConstructor=function(){throw o.errors.exception({header:"TypeError",message:"Illegal constructor"})},o.util.MakeTypeAssertion=function(e){return t=>A(e,t)},o.util.Type=function(e){switch(typeof e){case"undefined":return 1;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"bigint":return 6;case"function":case"object":return null===e?7:8}},o.util.Types={UNDEFINED:1,BOOLEAN:2,STRING:3,SYMBOL:4,NUMBER:5,BIGINT:6,NULL:7,OBJECT:8},o.util.TypeValueToString=function(e){switch(o.util.Type(e)){case 1:return"Undefined";case 2:return"Boolean";case 3:return"String";case 4:return"Symbol";case 5:return"Number";case 6:return"BigInt";case 7:return"Null";case 8:return"Object"}},o.util.markAsUncloneable=i||(()=>{}),o.util.ConvertToInt=function(e,t,s,n){let r,i;64===t?(r=Math.pow(2,53)-1,i="unsigned"===s?0:Math.pow(-2,53)+1):"unsigned"===s?(i=0,r=Math.pow(2,t)-1):(i=Math.pow(-2,t)-1,r=Math.pow(2,t-1)-1);let A=Number(e);if(0===A&&(A=0),o.util.HasFlag(n,o.attributes.EnforceRange)){if(Number.isNaN(A)||A===Number.POSITIVE_INFINITY||A===Number.NEGATIVE_INFINITY)throw o.errors.exception({header:"Integer conversion",message:`Could not convert ${o.util.Stringify(e)} to an integer.`});if(A=o.util.IntegerPart(A),A<i||A>r)throw o.errors.exception({header:"Integer conversion",message:`Value must be between ${i}-${r}, got ${A}.`});return A}return!Number.isNaN(A)&&o.util.HasFlag(n,o.attributes.Clamp)?(A=Math.min(Math.max(A,i),r),A=Math.floor(A)%2==0?Math.floor(A):Math.ceil(A),A):Number.isNaN(A)||0===A&&Object.is(0,A)||A===Number.POSITIVE_INFINITY||A===Number.NEGATIVE_INFINITY?0:(A=o.util.IntegerPart(A),A%=Math.pow(2,t),"signed"===s&&A>=Math.pow(2,t)-1?A-Math.pow(2,t):A)},o.util.IntegerPart=function(e){const t=Math.floor(Math.abs(e));return e<0?-1*t:t},o.util.Stringify=function(e){switch(o.util.Type(e)){case 4:return`Symbol(${e.description})`;case 8:return r(e);case 3:return`"${e}"`;case 6:return`${e}n`;default:return`${e}`}},o.util.IsResizableArrayBuffer=function(e){if(n.isArrayBuffer(e))return e.resizable;if(n.isSharedArrayBuffer(e))return e.growable;throw o.errors.exception({header:"IsResizableArrayBuffer",message:`"${o.util.Stringify(e)}" is not an array buffer.`})},o.util.HasFlag=function(e,t){return"number"==typeof e&&(e&t)===t},o.sequenceConverter=function(e){return(t,s,n,r)=>{if(8!==o.util.Type(t))throw o.errors.exception({header:s,message:`${n} (${o.util.Stringify(t)}) is not iterable.`});const i="function"==typeof r?r():t?.[Symbol.iterator]?.(),A=[];let a=0;if(void 0===i||"function"!=typeof i.next)throw o.errors.exception({header:s,message:`${n} is not iterable.`});for(;;){const{done:t,value:r}=i.next();if(t)break;A.push(e(r,s,`${n}[${a++}]`))}return A}},o.recordConverter=function(e,t){return(s,r,i)=>{if(8!==o.util.Type(s))throw o.errors.exception({header:r,message:`${i} ("${o.util.TypeValueToString(s)}") is not an Object.`});const A={};if(!n.isProxy(s)){const n=[...Object.getOwnPropertyNames(s),...Object.getOwnPropertySymbols(s)];for(const a of n){const n=o.util.Stringify(a),c=e(a,r,`Key ${n} in ${i}`),l=t(s[a],r,`${i}[${n}]`);A[c]=l}return A}const a=Reflect.ownKeys(s);for(const n of a){const o=Reflect.getOwnPropertyDescriptor(s,n);if(o?.enumerable){const o=e(n,r,i),a=t(s[n],r,i);A[o]=a}}return A}},o.interfaceConverter=function(e,t){return(s,n,r)=>{if(!e(s))throw o.errors.exception({header:n,message:`Expected ${r} ("${o.util.Stringify(s)}") to be an instance of ${t}.`});return s}},o.dictionaryConverter=function(e){return(t,s,n)=>{const r={};if(null!=t&&8!==o.util.Type(t))throw o.errors.exception({header:s,message:`Expected ${t} to be one of: Null, Undefined, Object.`});for(const i of e){const{key:e,defaultValue:A,required:a,converter:c}=i;if(!0===a&&(null==t||!Object.hasOwn(t,e)))throw o.errors.exception({header:s,message:`Missing required key "${e}".`});let l=t?.[e];const h=void 0!==A;if(h&&void 0===l&&(l=A()),a||h||void 0!==l){if(l=c(l,s,`${n}.${e}`),i.allowedValues&&!i.allowedValues.includes(l))throw o.errors.exception({header:s,message:`${l} is not an accepted type. Expected one of ${i.allowedValues.join(", ")}.`});r[e]=l}}return r}},o.nullableConverter=function(e){return(t,s,n)=>null===t?t:e(t,s,n)},o.is.USVString=function(e){return"string"==typeof e&&e.isWellFormed()},o.is.ReadableStream=o.util.MakeTypeAssertion(ReadableStream),o.is.Blob=o.util.MakeTypeAssertion(Blob),o.is.URLSearchParams=o.util.MakeTypeAssertion(URLSearchParams),o.is.File=o.util.MakeTypeAssertion(File),o.is.URL=o.util.MakeTypeAssertion(URL),o.is.AbortSignal=o.util.MakeTypeAssertion(AbortSignal),o.is.MessagePort=o.util.MakeTypeAssertion(MessagePort),o.is.BufferSource=function(e){return n.isArrayBuffer(e)||ArrayBuffer.isView(e)&&n.isArrayBuffer(e.buffer)},o.converters.DOMString=function(e,t,s,n){if(null===e&&o.util.HasFlag(n,o.attributes.LegacyNullToEmptyString))return"";if("symbol"==typeof e)throw o.errors.exception({header:t,message:`${s} is a symbol, which cannot be converted to a DOMString.`});return String(e)},o.converters.ByteString=function(e,t,s){if("symbol"==typeof e)throw o.errors.exception({header:t,message:`${s} is a symbol, which cannot be converted to a ByteString.`});const n=String(e);for(let e=0;e<n.length;e++)if(n.charCodeAt(e)>255)throw new TypeError(`Cannot convert argument to a ByteString because the character at index ${e} has a value of ${n.charCodeAt(e)} which is greater than 255.`);return n},o.converters.USVString=function(e){return"string"==typeof e?e.toWellFormed():`${e}`.toWellFormed()},o.converters.boolean=function(e){return Boolean(e)},o.converters.any=function(e){return e},o.converters["long long"]=function(e,t,s){return o.util.ConvertToInt(e,64,"signed",0,t,s)},o.converters["unsigned long long"]=function(e,t,s){return o.util.ConvertToInt(e,64,"unsigned",0,t,s)},o.converters["unsigned long"]=function(e,t,s){return o.util.ConvertToInt(e,32,"unsigned",0,t,s)},o.converters["unsigned short"]=function(e,t,s,n){return o.util.ConvertToInt(e,16,"unsigned",n,t,s)},o.converters.ArrayBuffer=function(e,t,s,r){if(8!==o.util.Type(e)||!n.isArrayBuffer(e))throw o.errors.conversionFailed({prefix:t,argument:`${s} ("${o.util.Stringify(e)}")`,types:["ArrayBuffer"]});if(!o.util.HasFlag(r,o.attributes.AllowResizable)&&o.util.IsResizableArrayBuffer(e))throw o.errors.exception({header:t,message:`${s} cannot be a resizable ArrayBuffer.`});return e},o.converters.SharedArrayBuffer=function(e,t,s,r){if(8!==o.util.Type(e)||!n.isSharedArrayBuffer(e))throw o.errors.conversionFailed({prefix:t,argument:`${s} ("${o.util.Stringify(e)}")`,types:["SharedArrayBuffer"]});if(!o.util.HasFlag(r,o.attributes.AllowResizable)&&o.util.IsResizableArrayBuffer(e))throw o.errors.exception({header:t,message:`${s} cannot be a resizable SharedArrayBuffer.`});return e},o.converters.TypedArray=function(e,t,s,r,i){if(8!==o.util.Type(e)||!n.isTypedArray(e)||e.constructor.name!==t.name)throw o.errors.conversionFailed({prefix:s,argument:`${r} ("${o.util.Stringify(e)}")`,types:[t.name]});if(!o.util.HasFlag(i,o.attributes.AllowShared)&&n.isSharedArrayBuffer(e.buffer))throw o.errors.exception({header:s,message:`${r} cannot be a view on a shared array buffer.`});if(!o.util.HasFlag(i,o.attributes.AllowResizable)&&o.util.IsResizableArrayBuffer(e.buffer))throw o.errors.exception({header:s,message:`${r} cannot be a view on a resizable array buffer.`});return e},o.converters.DataView=function(e,t,s,r){if(8!==o.util.Type(e)||!n.isDataView(e))throw o.errors.conversionFailed({prefix:t,argument:`${s} ("${o.util.Stringify(e)}")`,types:["DataView"]});if(!o.util.HasFlag(r,o.attributes.AllowShared)&&n.isSharedArrayBuffer(e.buffer))throw o.errors.exception({header:t,message:`${s} cannot be a view on a shared array buffer.`});if(!o.util.HasFlag(r,o.attributes.AllowResizable)&&o.util.IsResizableArrayBuffer(e.buffer))throw o.errors.exception({header:t,message:`${s} cannot be a view on a resizable array buffer.`});return e},o.converters.ArrayBufferView=function(e,t,s,r){if(8!==o.util.Type(e)||!n.isArrayBufferView(e))throw o.errors.conversionFailed({prefix:t,argument:`${s} ("${o.util.Stringify(e)}")`,types:["ArrayBufferView"]});if(!o.util.HasFlag(r,o.attributes.AllowShared)&&n.isSharedArrayBuffer(e.buffer))throw o.errors.exception({header:t,message:`${s} cannot be a view on a shared array buffer.`});if(!o.util.HasFlag(r,o.attributes.AllowResizable)&&o.util.IsResizableArrayBuffer(e.buffer))throw o.errors.exception({header:t,message:`${s} cannot be a view on a resizable array buffer.`});return e},o.converters.BufferSource=function(e,t,s,r){if(n.isArrayBuffer(e))return o.converters.ArrayBuffer(e,t,s,r);if(n.isArrayBufferView(e))return r&=~o.attributes.AllowShared,o.converters.ArrayBufferView(e,t,s,r);if(n.isSharedArrayBuffer(e))throw o.errors.exception({header:t,message:`${s} cannot be a SharedArrayBuffer.`});throw o.errors.conversionFailed({prefix:t,argument:`${s} ("${o.util.Stringify(e)}")`,types:["ArrayBuffer","ArrayBufferView"]})},o.converters.AllowSharedBufferSource=function(e,t,s,r){if(n.isArrayBuffer(e))return o.converters.ArrayBuffer(e,t,s,r);if(n.isSharedArrayBuffer(e))return o.converters.SharedArrayBuffer(e,t,s,r);if(n.isArrayBufferView(e))return r|=o.attributes.AllowShared,o.converters.ArrayBufferView(e,t,s,r);throw o.errors.conversionFailed({prefix:t,argument:`${s} ("${o.util.Stringify(e)}")`,types:["ArrayBuffer","SharedArrayBuffer","ArrayBufferView"]})},o.converters["sequence<ByteString>"]=o.sequenceConverter(o.converters.ByteString),o.converters["sequence<sequence<ByteString>>"]=o.sequenceConverter(o.converters["sequence<ByteString>"]),o.converters["record<ByteString, ByteString>"]=o.recordConverter(o.converters.ByteString,o.converters.ByteString),o.converters.Blob=o.interfaceConverter(o.is.Blob,"Blob"),o.converters.AbortSignal=o.interfaceConverter(o.is.AbortSignal,"AbortSignal"),o.converters.EventHandlerNonNull=function(e){return 8!==o.util.Type(e)?null:"function"==typeof e?e:()=>{}},o.attributes={Clamp:1,EnforceRange:2,AllowShared:4,AllowResizable:8,LegacyNullToEmptyString:16},e.exports={webidl:o}},8251:(e,t,s)=>{"use strict";const{uid:n,states:r,sentCloseFrameState:i,emptyBuffer:A,opcodes:o}=s(6490),{parseExtensions:a,isClosed:c,isClosing:l,isEstablished:h,validateCloseCodeAndReason:g}=s(8983),{makeRequest:d}=s(4609),{fetching:u}=s(7388),{Headers:I,getHeadersList:E}=s(6558),{getDecodeSplit:p}=s(6686),{WebsocketFrameSend:C}=s(6834),B=s(4589);let Q;try{Q=s(7598)}catch{}function f(e,t,s,n=!1){if(t??=null,s??="",n&&g(t,s),c(e.readyState)||l(e.readyState));else if(h(e.readyState))if(e.closeState.has(i.SENT)||e.closeState.has(i.RECEIVED))e.readyState=r.CLOSING;else{const n=new C;0!==s.length&&null===t&&(t=1e3),B(null===t||Number.isInteger(t)),null===t&&0===s.length?n.frameData=A:null!==t&&null===s?(n.frameData=Buffer.allocUnsafe(2),n.frameData.writeUInt16BE(t,0)):null!==t&&null!==s?(n.frameData=Buffer.allocUnsafe(2+Buffer.byteLength(s)),n.frameData.writeUInt16BE(t,0),n.frameData.write(s,2,"utf-8")):n.frameData=A,e.socket.write(n.createFrame(o.CLOSE)),e.closeState.add(i.SENT),e.readyState=r.CLOSING}else m(e),e.readyState=r.CLOSING}function m(e,t,s,n){h(e.readyState)&&f(e,t,s,!1),e.controller.abort(),e.socket?!1===e.socket.destroyed&&e.socket.destroy():e.onSocketClose()}e.exports={establishWebSocketConnection:function(e,t,s,i,A){const o=e;o.protocol="ws:"===e.protocol?"http:":"https:";const c=d({urlList:[o],client:s,serviceWorkers:"none",referrer:"no-referrer",mode:"websocket",credentials:"include",cache:"no-store",redirect:"error"});if(A.headers){const e=E(new I(A.headers));c.headersList=e}const l=Q.randomBytes(16).toString("base64");c.headersList.append("sec-websocket-key",l,!0),c.headersList.append("sec-websocket-version","13",!0);for(const e of t)c.headersList.append("sec-websocket-protocol",e,!0);return c.headersList.append("sec-websocket-extensions","permessage-deflate; client_max_window_bits",!0),u({request:c,useParallelQueue:!0,dispatcher:A.dispatcher,processResponse(e){if("error"===e.type&&(i.readyState=r.CLOSED),"error"===e.type||101!==e.status)return void m(i,1002,"Received network error or non-101 status code.",e.error);if(0!==t.length&&!e.headersList.get("Sec-WebSocket-Protocol"))return void m(i,1002,"Server did not respond with sent protocols.");if("websocket"!==e.headersList.get("Upgrade")?.toLowerCase())return void m(i,1002,'Server did not set Upgrade header to "websocket".');if("upgrade"!==e.headersList.get("Connection")?.toLowerCase())return void m(i,1002,'Server did not set Connection header to "upgrade".');if(e.headersList.get("Sec-WebSocket-Accept")!==Q.createHash("sha1").update(l+n).digest("base64"))return void m(i,1002,"Incorrect hash received in Sec-WebSocket-Accept header.");const s=e.headersList.get("Sec-WebSocket-Extensions");let A;if(null!==s&&(A=a(s),!A.has("permessage-deflate")))return void m(i,1002,"Sec-WebSocket-Extensions header does not match.");const o=e.headersList.get("Sec-WebSocket-Protocol");if(null!==o){if(!p("sec-websocket-protocol",c.headersList).includes(o))return void m(i,1002,"Protocol was not set in the opening handshake.")}e.socket.on("data",i.onSocketData),e.socket.on("close",i.onSocketClose),e.socket.on("error",i.onSocketError),i.wasEverConnected=!0,i.onConnectionEstablished(e,A)}})},failWebsocketConnection:m,closeWebSocketConnection:f}},6490:e=>{"use strict";const t=Buffer.allocUnsafe(0);e.exports={uid:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",sentCloseFrameState:{SENT:1,RECEIVED:2},staticPropertyDescriptors:{enumerable:!0,writable:!1,configurable:!1},states:{CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3},opcodes:{CONTINUATION:0,TEXT:1,BINARY:2,CLOSE:8,PING:9,PONG:10},maxUnsigned16Bit:65535,parserStates:{INFO:0,PAYLOADLENGTH_16:2,PAYLOADLENGTH_64:3,READ_DATA:4},emptyBuffer:t,sendHints:{text:1,typedArray:2,arrayBuffer:3,blob:4}}},878:(e,t,s)=>{"use strict";const{webidl:n}=s(6097),{kEnumerableProperty:r}=s(2858),{kConstruct:i}=s(257);class A extends Event{#nt;constructor(e,t={}){if(e===i)return super(arguments[1],arguments[2]),void n.util.markAsUncloneable(this);const s="MessageEvent constructor";n.argumentLengthCheck(arguments,1,s),super(e=n.converters.DOMString(e,s,"type"),t=n.converters.MessageEventInit(t,s,"eventInitDict")),this.#nt=t,n.util.markAsUncloneable(this)}get data(){return n.brandCheck(this,A),this.#nt.data}get origin(){return n.brandCheck(this,A),this.#nt.origin}get lastEventId(){return n.brandCheck(this,A),this.#nt.lastEventId}get source(){return n.brandCheck(this,A),this.#nt.source}get ports(){return n.brandCheck(this,A),Object.isFrozen(this.#nt.ports)||Object.freeze(this.#nt.ports),this.#nt.ports}initMessageEvent(e,t=!1,s=!1,r=null,i="",o="",a=null,c=[]){return n.brandCheck(this,A),n.argumentLengthCheck(arguments,1,"MessageEvent.initMessageEvent"),new A(e,{bubbles:t,cancelable:s,data:r,origin:i,lastEventId:o,source:a,ports:c})}static createFastMessageEvent(e,t){const s=new A(i,e,t);return s.#nt=t,s.#nt.data??=null,s.#nt.origin??="",s.#nt.lastEventId??="",s.#nt.source??=null,s.#nt.ports??=[],s}}const{createFastMessageEvent:o}=A;delete A.createFastMessageEvent;class a extends Event{#nt;constructor(e,t={}){const s="CloseEvent constructor";n.argumentLengthCheck(arguments,1,s),super(e=n.converters.DOMString(e,s,"type"),t=n.converters.CloseEventInit(t)),this.#nt=t,n.util.markAsUncloneable(this)}get wasClean(){return n.brandCheck(this,a),this.#nt.wasClean}get code(){return n.brandCheck(this,a),this.#nt.code}get reason(){return n.brandCheck(this,a),this.#nt.reason}}class c extends Event{#nt;constructor(e,t){const s="ErrorEvent constructor";n.argumentLengthCheck(arguments,1,s),super(e,t),n.util.markAsUncloneable(this),e=n.converters.DOMString(e,s,"type"),t=n.converters.ErrorEventInit(t??{}),this.#nt=t}get message(){return n.brandCheck(this,c),this.#nt.message}get filename(){return n.brandCheck(this,c),this.#nt.filename}get lineno(){return n.brandCheck(this,c),this.#nt.lineno}get colno(){return n.brandCheck(this,c),this.#nt.colno}get error(){return n.brandCheck(this,c),this.#nt.error}}Object.defineProperties(A.prototype,{[Symbol.toStringTag]:{value:"MessageEvent",configurable:!0},data:r,origin:r,lastEventId:r,source:r,ports:r,initMessageEvent:r}),Object.defineProperties(a.prototype,{[Symbol.toStringTag]:{value:"CloseEvent",configurable:!0},reason:r,code:r,wasClean:r}),Object.defineProperties(c.prototype,{[Symbol.toStringTag]:{value:"ErrorEvent",configurable:!0},message:r,filename:r,lineno:r,colno:r,error:r}),n.converters.MessagePort=n.interfaceConverter(n.is.MessagePort,"MessagePort"),n.converters["sequence<MessagePort>"]=n.sequenceConverter(n.converters.MessagePort);const l=[{key:"bubbles",converter:n.converters.boolean,defaultValue:()=>!1},{key:"cancelable",converter:n.converters.boolean,defaultValue:()=>!1},{key:"composed",converter:n.converters.boolean,defaultValue:()=>!1}];n.converters.MessageEventInit=n.dictionaryConverter([...l,{key:"data",converter:n.converters.any,defaultValue:()=>null},{key:"origin",converter:n.converters.USVString,defaultValue:()=>""},{key:"lastEventId",converter:n.converters.DOMString,defaultValue:()=>""},{key:"source",converter:n.nullableConverter(n.converters.MessagePort),defaultValue:()=>null},{key:"ports",converter:n.converters["sequence<MessagePort>"],defaultValue:()=>[]}]),n.converters.CloseEventInit=n.dictionaryConverter([...l,{key:"wasClean",converter:n.converters.boolean,defaultValue:()=>!1},{key:"code",converter:n.converters["unsigned short"],defaultValue:()=>0},{key:"reason",converter:n.converters.USVString,defaultValue:()=>""}]),n.converters.ErrorEventInit=n.dictionaryConverter([...l,{key:"message",converter:n.converters.DOMString,defaultValue:()=>""},{key:"filename",converter:n.converters.USVString,defaultValue:()=>""},{key:"lineno",converter:n.converters["unsigned long"],defaultValue:()=>0},{key:"colno",converter:n.converters["unsigned long"],defaultValue:()=>0},{key:"error",converter:n.converters.any}]),e.exports={MessageEvent:A,CloseEvent:a,ErrorEvent:c,createFastMessageEvent:o}},6834:(e,t,s)=>{"use strict";const{maxUnsigned16Bit:n,opcodes:r}=s(6490),i=8192;let A,o=null,a=i;try{A=s(7598)}catch{A={randomFillSync:function(e,t,s){for(let t=0;t<e.length;++t)e[t]=255*Math.random()|0;return e}}}function c(){return a===i&&(a=0,A.randomFillSync(o??=Buffer.allocUnsafeSlow(i),0,i)),[o[a++],o[a++],o[a++],o[a++]]}e.exports={WebsocketFrameSend:class{constructor(e){this.frameData=e}createFrame(e){const t=this.frameData,s=c(),r=t?.byteLength??0;let i=r,A=6;r>n?(A+=8,i=127):r>125&&(A+=2,i=126);const o=Buffer.allocUnsafe(r+A);o[0]=o[1]=0,o[0]|=128,o[0]=(240&o[0])+e,o[A-4]=s[0],o[A-3]=s[1],o[A-2]=s[2],o[A-1]=s[3],o[1]=i,126===i?o.writeUInt16BE(r,2):127===i&&(o[2]=o[3]=0,o.writeUIntBE(r,4,6)),o[1]|=128;for(let e=0;e<r;++e)o[A+e]=t[e]^s[3&e];return o}static createFastTextFrame(e){const t=c(),s=e.length;for(let n=0;n<s;++n)e[n]^=t[3&n];let i=s,A=6;s>n?(A+=8,i=127):s>125&&(A+=2,i=126);const o=Buffer.allocUnsafeSlow(A);return o[0]=128|r.TEXT,o[1]=128|i,o[A-4]=t[0],o[A-3]=t[1],o[A-2]=t[2],o[A-1]=t[3],126===i?o.writeUInt16BE(s,2):127===i&&(o[2]=o[3]=0,o.writeUIntBE(s,4,6)),[o,e]}},generateMask:c}},8975:(e,t,s)=>{"use strict";const{createInflateRaw:n,Z_DEFAULT_WINDOWBITS:r}=s(8522),{isValidClientWindowBits:i}=s(8983),A=Buffer.from([0,0,255,255]),o=Symbol("kBuffer"),a=Symbol("kLength");e.exports={PerMessageDeflate:class{#rt;#R={};constructor(e){this.#R.serverNoContextTakeover=e.has("server_no_context_takeover"),this.#R.serverMaxWindowBits=e.get("server_max_window_bits")}decompress(e,t,s){if(!this.#rt){let e=r;if(this.#R.serverMaxWindowBits){if(!i(this.#R.serverMaxWindowBits))return void s(new Error("Invalid server_max_window_bits"));e=Number.parseInt(this.#R.serverMaxWindowBits)}this.#rt=n({windowBits:e}),this.#rt[o]=[],this.#rt[a]=0,this.#rt.on("data",(e=>{this.#rt[o].push(e),this.#rt[a]+=e.length})),this.#rt.on("error",(e=>{this.#rt=null,s(e)}))}this.#rt.write(e),t&&this.#rt.write(A),this.#rt.flush((()=>{const e=Buffer.concat(this.#rt[o],this.#rt[a]);this.#rt[o].length=0,this.#rt[a]=0,s(null,e)}))}}}},834:(e,t,s)=>{"use strict";const{Writable:n}=s(7075),r=s(4589),{parserStates:i,opcodes:A,states:o,emptyBuffer:a,sentCloseFrameState:c}=s(6490),{isValidStatusCode:l,isValidOpcode:h,websocketMessageReceived:g,utf8Decode:d,isControlFrame:u,isTextBinaryFrame:I,isContinuationFrame:E}=s(8983),{failWebsocketConnection:p}=s(8251),{WebsocketFrameSend:C}=s(6834),{PerMessageDeflate:B}=s(8975);e.exports={ByteParser:class extends n{#it=[];#At=0;#ot=0;#at=!1;#le=i.INFO;#ct={};#lt=[];#ht;#U;constructor(e,t){super(),this.#U=e,this.#ht=null==t?new Map:t,this.#ht.has("permessage-deflate")&&this.#ht.set("permessage-deflate",new B(t))}_write(e,t,s){this.#it.push(e),this.#ot+=e.length,this.#at=!0,this.run(s)}run(e){for(;this.#at;)if(this.#le===i.INFO){if(this.#ot<2)return e();const t=this.consume(2),s=!!(128&t[0]),n=15&t[0],r=!(128&~t[1]),o=!s&&n!==A.CONTINUATION,a=127&t[1],c=64&t[0],l=32&t[0],g=16&t[0];if(!h(n))return p(this.#U,1002,"Invalid opcode received"),e();if(r)return p(this.#U,1002,"Frame cannot be masked"),e();if(0!==c&&!this.#ht.has("permessage-deflate"))return void p(this.#U,1002,"Expected RSV1 to be clear.");if(0!==l||0!==g)return void p(this.#U,1002,"RSV1, RSV2, RSV3 must be clear");if(o&&!I(n))return void p(this.#U,1002,"Invalid frame type was fragmented.");if(I(n)&&this.#lt.length>0)return void p(this.#U,1002,"Expected continuation frame");if(this.#ct.fragmented&&o)return void p(this.#U,1002,"Fragmented frame exceeded 125 bytes.");if((a>125||o)&&u(n))return void p(this.#U,1002,"Control frame either too large or fragmented");if(E(n)&&0===this.#lt.length&&!this.#ct.compressed)return void p(this.#U,1002,"Unexpected continuation frame");a<=125?(this.#ct.payloadLength=a,this.#le=i.READ_DATA):126===a?this.#le=i.PAYLOADLENGTH_16:127===a&&(this.#le=i.PAYLOADLENGTH_64),I(n)&&(this.#ct.binaryType=n,this.#ct.compressed=0!==c),this.#ct.opcode=n,this.#ct.masked=r,this.#ct.fin=s,this.#ct.fragmented=o}else if(this.#le===i.PAYLOADLENGTH_16){if(this.#ot<2)return e();const t=this.consume(2);this.#ct.payloadLength=t.readUInt16BE(0),this.#le=i.READ_DATA}else if(this.#le===i.PAYLOADLENGTH_64){if(this.#ot<8)return e();const t=this.consume(8),s=t.readUInt32BE(0);if(s>2**31-1)return void p(this.#U,1009,"Received payload length > 2^31 bytes.");const n=t.readUInt32BE(4);this.#ct.payloadLength=(s<<8)+n,this.#le=i.READ_DATA}else if(this.#le===i.READ_DATA){if(this.#ot<this.#ct.payloadLength)return e();const t=this.consume(this.#ct.payloadLength);if(u(this.#ct.opcode))this.#at=this.parseControlFrame(t),this.#le=i.INFO;else{if(this.#ct.compressed){this.#ht.get("permessage-deflate").decompress(t,this.#ct.fin,((t,s)=>{if(t)p(this.#U,1007,t.message);else{if(this.writeFragments(s),!this.#ct.fin)return this.#le=i.INFO,this.#at=!0,void this.run(e);g(this.#U,this.#ct.binaryType,this.consumeFragments()),this.#at=!0,this.#le=i.INFO,this.run(e)}})),this.#at=!1;break}this.writeFragments(t),!this.#ct.fragmented&&this.#ct.fin&&g(this.#U,this.#ct.binaryType,this.consumeFragments()),this.#le=i.INFO}}}consume(e){if(e>this.#ot)throw new Error("Called consume() before buffers satiated.");if(0===e)return a;this.#ot-=e;const t=this.#it[0];if(t.length>e)return this.#it[0]=t.subarray(e,t.length),t.subarray(0,e);if(t.length===e)return this.#it.shift();{let t=0;const s=Buffer.allocUnsafeSlow(e);for(;t!==e;){const n=this.#it[0],r=n.length;if(r+t===e){s.set(this.#it.shift(),t);break}if(r+t>e){s.set(n.subarray(0,e-t),t),this.#it[0]=n.subarray(e-t);break}s.set(this.#it.shift(),t),t+=r}return s}}writeFragments(e){this.#At+=e.length,this.#lt.push(e)}consumeFragments(){const e=this.#lt;if(1===e.length)return this.#At=0,e.shift();let t=0;const s=Buffer.allocUnsafeSlow(this.#At);for(let n=0;n<e.length;++n){const r=e[n];s.set(r,t),t+=r.length}return this.#lt=[],this.#At=0,s}parseCloseBody(e){let t;if(r(1!==e.length),e.length>=2&&(t=e.readUInt16BE(0)),void 0!==t&&!l(t))return{code:1002,reason:"Invalid status code",error:!0};let s=e.subarray(2);239===s[0]&&187===s[1]&&191===s[2]&&(s=s.subarray(3));try{s=d(s)}catch{return{code:1007,reason:"Invalid UTF-8",error:!0}}return{code:t,reason:s,error:!1}}parseControlFrame(e){const{opcode:t,payloadLength:s}=this.#ct;if(t===A.CLOSE){if(1===s)return p(this.#U,1002,"Received close frame with a 1-byte body."),!1;if(this.#ct.closeInfo=this.parseCloseBody(e),this.#ct.closeInfo.error){const{code:e,reason:t}=this.#ct.closeInfo;return p(this.#U,e,t),!1}if(!this.#U.closeState.has(c.SENT)&&!this.#U.closeState.has(c.RECEIVED)){let e=a;this.#ct.closeInfo.code&&(e=Buffer.allocUnsafe(2),e.writeUInt16BE(this.#ct.closeInfo.code,0));const t=new C(e);this.#U.socket.write(t.createFrame(A.CLOSE)),this.#U.closeState.add(c.SENT)}return this.#U.readyState=o.CLOSING,this.#U.closeState.add(c.RECEIVED),!1}if(t===A.PING){if(!this.#U.closeState.has(c.RECEIVED)){const t=new C(e);this.#U.socket.write(t.createFrame(A.PONG)),this.#U.onPing(e)}}else t===A.PONG&&this.#U.onPong(e);return!0}get closingInfo(){return this.#ct.closeInfo}}}},2534:(e,t,s)=>{"use strict";const{WebsocketFrameSend:n}=s(6834),{opcodes:r,sendHints:i}=s(6490),A=s(1726);function o(e,t){return new n(function(e,t){switch(t){case i.text:case i.typedArray:return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);case i.arrayBuffer:case i.blob:return new Uint8Array(e)}}(e,t)).createFrame(t===i.text?r.TEXT:r.BINARY)}e.exports={SendQueue:class{#gt=new A;#dt=!1;#ut;constructor(e){this.#ut=e}add(e,t,s){if(s!==i.blob){if(this.#dt){const n={promise:null,callback:t,frame:o(e,s)};this.#gt.push(n)}else if(s===i.text){const{0:s,1:r}=n.createFastTextFrame(e);this.#ut.cork(),this.#ut.write(s),this.#ut.write(r,t),this.#ut.uncork()}else this.#ut.write(o(e,s),t);return}const r={promise:e.arrayBuffer().then((e=>{r.promise=null,r.frame=o(e,s)})),callback:t,frame:null};this.#gt.push(r),this.#dt||this.#It()}async#It(){this.#dt=!0;const e=this.#gt;for(;!e.isEmpty();){const t=e.shift();null!==t.promise&&await t.promise,this.#ut.write(t.frame,t.callback),t.callback=t.frame=null}this.#dt=!1}}}},7053:(e,t,s)=>{"use strict";const{webidl:n}=s(6097),{validateCloseCodeAndReason:r}=s(8983),{kConstruct:i}=s(257),{kEnumerableProperty:A}=s(2858);class o extends(function(){class e extends DOMException{get reason(){return""}}return void 0!==(new e).reason?DOMException:new Proxy(DOMException,{construct(e,t,s){const n=Reflect.construct(e,t,e);return Object.setPrototypeOf(n,s.prototype),n}})}()){#Et;#W;constructor(e="",t=void 0){if(super(e=n.converters.DOMString(e,"WebSocketError","message"),"WebSocketError"),t===i)return;null!==t&&(t=n.converters.WebSocketCloseInfo(t));let s=t.closeCode??null;const A=t.reason??"";r(s,A),0!==A.length&&null===s&&(s=1e3),this.#Et=s,this.#W=A}get closeCode(){return this.#Et}get reason(){return this.#W}static createUnvalidatedWebSocketError(e,t,s){const n=new o(e,i);return n.#Et=t,n.#W=s,n}}const{createUnvalidatedWebSocketError:a}=o;delete o.createUnvalidatedWebSocketError,Object.defineProperties(o.prototype,{closeCode:A,reason:A,[Symbol.toStringTag]:{value:"WebSocketError",writable:!1,enumerable:!1,configurable:!0}}),n.is.WebSocketError=n.util.MakeTypeAssertion(o),e.exports={WebSocketError:o,createUnvalidatedWebSocketError:a}},27:(e,t,s)=>{"use strict";const{createDeferredPromise:n}=s(9250),{environmentSettingsObject:r}=s(6686),{states:i,opcodes:A,sentCloseFrameState:o}=s(6490),{webidl:a}=s(6097),{getURLRecord:c,isValidSubprotocol:l,isEstablished:h,utf8Decode:g}=s(8983),{establishWebSocketConnection:d,failWebsocketConnection:u,closeWebSocketConnection:I}=s(8251),{channels:E}=s(772),{WebsocketFrameSend:p}=s(6834),{ByteParser:C}=s(834),{WebSocketError:B,createUnvalidatedWebSocketError:Q}=s(7053),{utf8DecodeBytes:f}=s(6686),{kEnumerableProperty:m}=s(2858);let y=!1;class S{#Ge;#pt;#Ct;#Bt;#Qt;#ft;#mt=!1;#U={onConnectionEstablished:(e,t)=>this.#yt(e,t),onMessage:(e,t)=>this.#St(e,t),onParserError:e=>u(this.#U,null,e.message),onParserDrain:()=>this.#U.socket.resume(),onSocketData:e=>{this.#wt.write(e)||this.#U.socket.pause()},onSocketError:e=>{this.#U.readyState=i.CLOSING,E.socketError.hasSubscribers&&E.socketError.publish(e),this.#U.socket.destroy()},onSocketClose:()=>this.#Dt(),onPing:()=>{},onPong:()=>{},readyState:i.CONNECTING,socket:null,closeState:new Set,controller:null,wasEverConnected:!1};#wt;constructor(e,t=void 0){y||(process.emitWarning("WebSocketStream is experimental! Expect it to change at any time.",{code:"UNDICI-WSS"}),y=!0),a.argumentLengthCheck(arguments,1,"WebSocket"),e=a.converters.USVString(e),null!==t&&(t=a.converters.WebSocketStreamOptions(t));const s=r.settingsObject.baseUrl,A=c(e,s),o=t.protocols;if(o.length!==new Set(o.map((e=>e.toLowerCase()))).size)throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");if(o.length>0&&!o.every((e=>l(e))))throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");if(this.#Ge=A.toString(),this.#pt=n(),this.#Ct=n(),null!=t.signal){const e=t.signal;if(e.aborted)return this.#pt.reject(e.reason),void this.#Ct.reject(e.reason);e.addEventListener("abort",(()=>{h(this.#U.readyState)||(u(this.#U),this.#U.readyState=i.CLOSING,this.#pt.reject(e.reason),this.#Ct.reject(e.reason),this.#mt=!0)}),{once:!0})}const g=r.settingsObject;this.#U.controller=d(A,o,g,this.#U,t)}get url(){return this.#Ge.toString()}get opened(){return this.#pt.promise}get closed(){return this.#Ct.promise}close(e=void 0){null!==e&&(e=a.converters.WebSocketCloseInfo(e));const t=e.closeCode??null,s=e.reason;I(this.#U,t,s,!0)}#bt(e){e=a.converters.WebSocketStreamWrite(e);const t=n();let s=null,r=null;if(a.is.BufferSource(e))s=new Uint8Array(ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e.slice()),r=A.BINARY;else{let n;try{n=a.converters.DOMString(e)}catch(e){return t.reject(e),t.promise}s=(new TextEncoder).encode(n),r=A.TEXT}if(!this.#U.closeState.has(o.SENT)&&!this.#U.closeState.has(o.RECEIVED)){const e=new p(s);this.#U.socket.write(e.createFrame(r),(()=>{t.resolve(void 0)}))}return t.promise}#yt(e,t){this.#U.socket=e.socket;const s=new C(this.#U,t);s.on("drain",(()=>this.#U.onParserDrain())),s.on("error",(e=>this.#U.onParserError(e))),this.#wt=s,this.#U.readyState=i.OPEN;const n=t??"",r=e.headersList.get("sec-websocket-protocol")??"",A=new ReadableStream({start:e=>{this.#Qt=e},pull(t){let s;for(;t.desiredSize>0&&null!==(s=e.socket.read());)t.enqueue(s)},cancel:e=>this.#vt(e)}),o=new WritableStream({write:e=>this.#bt(e),close:()=>I(this.#U,null,null),abort:e=>this.#Nt(e)});this.#Bt=A,this.#ft=o,this.#pt.resolve({extensions:n,protocol:r,readable:A,writable:o})}#St(e,t){if(this.#U.readyState!==i.OPEN)return;let s;if(e===A.TEXT)try{s=g(t)}catch{return void u(this.#U,"Received invalid UTF-8 in text frame.")}else e===A.BINARY&&(s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength));this.#Qt.enqueue(s)}#Dt(){const e=this.#U.closeState.has(o.SENT)&&this.#U.closeState.has(o.RECEIVED);if(this.#U.readyState=i.CLOSED,this.#mt)return;this.#U.wasEverConnected||this.#pt.reject(new B("Socket never opened"));const t=this.#wt.closingInfo;let s=t?.code??1005;this.#U.closeState.has(o.SENT)||this.#U.closeState.has(o.RECEIVED)||(s=1006);const n=null==t?.reason?"":f(Buffer.from(t.reason));if(e)this.#Qt.close(),this.#ft.locked||this.#ft.abort(new DOMException("A closed WebSocketStream cannot be written to","InvalidStateError")),this.#Ct.resolve({closeCode:s,reason:n});else{const e=Q("unclean close",s,n);this.#Qt.error(e),this.#ft.abort(e),this.#Ct.reject(e)}}#Nt(e){let t=null,s="";a.is.WebSocketError(e)&&(t=e.closeCode,s=e.reason),I(this.#U,t,s)}#vt(e){this.#Nt(e)}}Object.defineProperties(S.prototype,{url:m,opened:m,closed:m,close:m,[Symbol.toStringTag]:{value:"WebSocketStream",writable:!1,enumerable:!1,configurable:!0}}),a.converters.WebSocketStreamOptions=a.dictionaryConverter([{key:"protocols",converter:a.sequenceConverter(a.converters.USVString),defaultValue:()=>[]},{key:"signal",converter:a.nullableConverter(a.converters.AbortSignal),defaultValue:()=>null}]),a.converters.WebSocketCloseInfo=a.dictionaryConverter([{key:"closeCode",converter:e=>a.converters["unsigned short"](e,a.attributes.EnforceRange)},{key:"reason",converter:a.converters.USVString,defaultValue:()=>""}]),a.converters.WebSocketStreamWrite=function(e){return"string"==typeof e?a.converters.USVString(e):a.converters.BufferSource(e)},e.exports={WebSocketStream:S}},8983:(e,t,s)=>{"use strict";const{states:n,opcodes:r}=s(6490),{isUtf8:i}=s(4573),{collectASequenceOfCodePointsFast:A,removeHTTPWhitespace:o}=s(9934);function a(e){return e===r.CLOSE||e===r.PING||e===r.PONG}function c(e){return e===r.CONTINUATION}function l(e){return e===r.TEXT||e===r.BINARY}const h=(()=>{if("string"==typeof process.versions.icu){const e=new TextDecoder("utf-8",{fatal:!0});return e.decode.bind(e)}return function(e){if(i(e))return e.toString("utf-8");throw new TypeError("Invalid utf-8 received.")}})();e.exports={isConnecting:function(e){return e===n.CONNECTING},isEstablished:function(e){return e===n.OPEN},isClosing:function(e){return e===n.CLOSING},isClosed:function(e){return e===n.CLOSED},fireEvent:function(e,t,s=(e,t)=>new Event(e,t),n={}){const r=s(e,n);t.dispatchEvent(r)},isValidSubprotocol:function(e){if(0===e.length)return!1;for(let t=0;t<e.length;++t){const s=e.charCodeAt(t);if(s<33||s>126||34===s||40===s||41===s||44===s||47===s||58===s||59===s||60===s||61===s||62===s||63===s||64===s||91===s||92===s||93===s||123===s||125===s)return!1}return!0},isValidStatusCode:function(e){return e>=1e3&&e<1015?1004!==e&&1005!==e&&1006!==e:e>=3e3&&e<=4999},websocketMessageReceived:function(e,t,s){e.onMessage(t,s)},utf8Decode:h,isControlFrame:a,isContinuationFrame:c,isTextBinaryFrame:l,isValidOpcode:function(e){return l(e)||c(e)||a(e)},parseExtensions:function(e){const t={position:0},s=new Map;for(;t.position<e.length;){const n=A(";",e,t),[r,i=""]=n.split("=",2);s.set(o(r,!0,!1),o(i,!1,!0)),t.position++}return s},isValidClientWindowBits:function(e){for(let t=0;t<e.length;t++){const s=e.charCodeAt(t);if(s<48||s>57)return!1}return!0},toArrayBuffer:function(e){return e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer},getURLRecord:function(e,t){let s;try{s=new URL(e,t)}catch(e){throw new DOMException(e,"SyntaxError")}if("http:"===s.protocol?s.protocol="ws:":"https:"===s.protocol&&(s.protocol="wss:"),"ws:"!==s.protocol&&"wss:"!==s.protocol)throw new DOMException("expected a ws: or wss: url","SyntaxError");if(s.hash.length||s.href.endsWith("#"))throw new DOMException("hash","SyntaxError");return s},validateCloseCodeAndReason:function(e,t){if(null!==e&&1e3!==e&&(e<3e3||e>4999))throw new DOMException("invalid code","InvalidAccessError");if(null!==t){const e=Buffer.byteLength(t);if(e>123)throw new DOMException(`Reason must be less than 123 bytes; received ${e}`,"SyntaxError")}}}},2984:(e,t,s)=>{"use strict";const{isArrayBuffer:n}=s(3429),{webidl:r}=s(6097),{URLSerializer:i}=s(9934),{environmentSettingsObject:A}=s(6686),{staticPropertyDescriptors:o,states:a,sentCloseFrameState:c,sendHints:l,opcodes:h}=s(6490),{isConnecting:g,isEstablished:d,isClosing:u,isClosed:I,isValidSubprotocol:E,fireEvent:p,utf8Decode:C,toArrayBuffer:B,getURLRecord:Q}=s(8983),{establishWebSocketConnection:f,closeWebSocketConnection:m,failWebsocketConnection:y}=s(8251),{ByteParser:S}=s(834),{kEnumerableProperty:w}=s(2858),{getGlobalDispatcher:D}=s(9879),{ErrorEvent:b,CloseEvent:v,createFastMessageEvent:N}=s(878),{SendQueue:R}=s(2534),{WebsocketFrameSend:k}=s(6834),{channels:T}=s(772);class F extends EventTarget{#Oe={open:null,error:null,close:null,message:null};#Rt=0;#kt="";#ht="";#Tt;#U={onConnectionEstablished:(e,t)=>this.#yt(e,t),onMessage:(e,t)=>this.#St(e,t),onParserError:e=>y(this.#U,null,e.message),onParserDrain:()=>this.#Ft(),onSocketData:e=>{this.#wt.write(e)||this.#U.socket.pause()},onSocketError:e=>{this.#U.readyState=a.CLOSING,T.socketError.hasSubscribers&&T.socketError.publish(e),this.#U.socket.destroy()},onSocketClose:()=>this.#Dt(),onPing:e=>{T.ping.hasSubscribers&&T.ping.publish({payload:e,websocket:this})},onPong:e=>{T.pong.hasSubscribers&&T.pong.publish({payload:e,websocket:this})},readyState:a.CONNECTING,socket:null,closeState:new Set,controller:null,wasEverConnected:!1};#Ge;#Mt;#wt;constructor(e,t=[]){super(),r.util.markAsUncloneable(this);const s="WebSocket constructor";r.argumentLengthCheck(arguments,1,s);const n=r.converters["DOMString or sequence<DOMString> or WebSocketInit"](t,s,"options");e=r.converters.USVString(e),t=n.protocols;const i=A.settingsObject.baseUrl,o=Q(e,i);if("string"==typeof t&&(t=[t]),t.length!==new Set(t.map((e=>e.toLowerCase()))).size)throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");if(t.length>0&&!t.every((e=>E(e))))throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");this.#Ge=new URL(o.href);const a=A.settingsObject;this.#U.controller=f(o,t,a,this.#U,n),this.#U.readyState=F.CONNECTING,this.#Mt="blob"}close(e=void 0,t=void 0){r.brandCheck(this,F);void 0!==e&&(e=r.converters["unsigned short"](e,"WebSocket.close","code",r.attributes.Clamp)),void 0!==t&&(t=r.converters.USVString(t)),e??=null,t??="",m(this.#U,e,t,!0)}send(e){r.brandCheck(this,F);const t="WebSocket.send";if(r.argumentLengthCheck(arguments,1,t),e=r.converters.WebSocketSendData(e,t,"data"),g(this.#U.readyState))throw new DOMException("Sent before connected.","InvalidStateError");if(d(this.#U.readyState)&&!u(this.#U.readyState))if("string"==typeof e){const t=Buffer.from(e);this.#Rt+=t.byteLength,this.#Tt.add(t,(()=>{this.#Rt-=t.byteLength}),l.text)}else n(e)?(this.#Rt+=e.byteLength,this.#Tt.add(e,(()=>{this.#Rt-=e.byteLength}),l.arrayBuffer)):ArrayBuffer.isView(e)?(this.#Rt+=e.byteLength,this.#Tt.add(e,(()=>{this.#Rt-=e.byteLength}),l.typedArray)):r.is.Blob(e)&&(this.#Rt+=e.size,this.#Tt.add(e,(()=>{this.#Rt-=e.size}),l.blob))}get readyState(){return r.brandCheck(this,F),this.#U.readyState}get bufferedAmount(){return r.brandCheck(this,F),this.#Rt}get url(){return r.brandCheck(this,F),i(this.#Ge)}get extensions(){return r.brandCheck(this,F),this.#ht}get protocol(){return r.brandCheck(this,F),this.#kt}get onopen(){return r.brandCheck(this,F),this.#Oe.open}set onopen(e){r.brandCheck(this,F),this.#Oe.open&&this.removeEventListener("open",this.#Oe.open);const t=r.converters.EventHandlerNonNull(e);null!==t?(this.addEventListener("open",t),this.#Oe.open=e):this.#Oe.open=null}get onerror(){return r.brandCheck(this,F),this.#Oe.error}set onerror(e){r.brandCheck(this,F),this.#Oe.error&&this.removeEventListener("error",this.#Oe.error);const t=r.converters.EventHandlerNonNull(e);null!==t?(this.addEventListener("error",t),this.#Oe.error=e):this.#Oe.error=null}get onclose(){return r.brandCheck(this,F),this.#Oe.close}set onclose(e){r.brandCheck(this,F),this.#Oe.close&&this.removeEventListener("close",this.#Oe.close);const t=r.converters.EventHandlerNonNull(e);null!==t?(this.addEventListener("close",t),this.#Oe.close=e):this.#Oe.close=null}get onmessage(){return r.brandCheck(this,F),this.#Oe.message}set onmessage(e){r.brandCheck(this,F),this.#Oe.message&&this.removeEventListener("message",this.#Oe.message);const t=r.converters.EventHandlerNonNull(e);null!==t?(this.addEventListener("message",t),this.#Oe.message=e):this.#Oe.message=null}get binaryType(){return r.brandCheck(this,F),this.#Mt}set binaryType(e){r.brandCheck(this,F),this.#Mt="blob"!==e&&"arraybuffer"!==e?"blob":e}#yt(e,t){this.#U.socket=e.socket;const s=new S(this.#U,t);s.on("drain",(()=>this.#U.onParserDrain())),s.on("error",(e=>this.#U.onParserError(e))),this.#wt=s,this.#Tt=new R(e.socket),this.#U.readyState=a.OPEN;const n=e.headersList.get("sec-websocket-extensions");null!==n&&(this.#ht=n);const r=e.headersList.get("sec-websocket-protocol");if(null!==r&&(this.#kt=r),p("open",this),T.open.hasSubscribers){const t=e.headersList.entries;T.open.publish({address:e.socket.address(),protocol:this.#kt,extensions:this.#ht,websocket:this,handshakeResponse:{status:e.status,statusText:e.statusText,headers:t}})}}#St(e,t){if(this.#U.readyState!==a.OPEN)return;let s;if(e===h.TEXT)try{s=C(t)}catch{return void y(this.#U,1007,"Received invalid UTF-8 in text frame.")}else e===h.BINARY&&(s="blob"===this.#Mt?new Blob([t]):B(t));p("message",this,N,{origin:this.#Ge.origin,data:s})}#Ft(){this.#U.socket.resume()}#Dt(){const e=this.#U.closeState.has(c.SENT)&&this.#U.closeState.has(c.RECEIVED);let t=1005,s="";const n=this.#wt?.closingInfo;n&&!n.error&&(t=n.code??1005,s=n.reason),this.#U.readyState=a.CLOSED,this.#U.closeState.has(c.RECEIVED)||(t=1006,p("error",this,((e,t)=>new b(e,t)),{error:new TypeError(s)})),p("close",this,((e,t)=>new v(e,t)),{wasClean:e,code:t,reason:s}),T.close.hasSubscribers&&T.close.publish({websocket:this,code:t,reason:s})}static ping(e,t){if(Buffer.isBuffer(t)){if(t.length>125)throw new TypeError("A PING frame cannot have a body larger than 125 bytes.")}else if(void 0!==t)throw new TypeError("Expected buffer payload");const s=e.#U.readyState;if(d(s)&&!u(s)&&!I(s)){const s=new k(t);e.#U.socket.write(s.createFrame(h.PING))}}}const{ping:M}=F;Reflect.deleteProperty(F,"ping"),F.CONNECTING=F.prototype.CONNECTING=a.CONNECTING,F.OPEN=F.prototype.OPEN=a.OPEN,F.CLOSING=F.prototype.CLOSING=a.CLOSING,F.CLOSED=F.prototype.CLOSED=a.CLOSED,Object.defineProperties(F.prototype,{CONNECTING:o,OPEN:o,CLOSING:o,CLOSED:o,url:w,readyState:w,bufferedAmount:w,onopen:w,onerror:w,onclose:w,close:w,onmessage:w,binaryType:w,send:w,extensions:w,protocol:w,[Symbol.toStringTag]:{value:"WebSocket",writable:!1,enumerable:!1,configurable:!0}}),Object.defineProperties(F,{CONNECTING:o,OPEN:o,CLOSING:o,CLOSED:o}),r.converters["sequence<DOMString>"]=r.sequenceConverter(r.converters.DOMString),r.converters["DOMString or sequence<DOMString>"]=function(e,t,s){return r.util.Type(e)===r.util.Types.OBJECT&&Symbol.iterator in e?r.converters["sequence<DOMString>"](e):r.converters.DOMString(e,t,s)},r.converters.WebSocketInit=r.dictionaryConverter([{key:"protocols",converter:r.converters["DOMString or sequence<DOMString>"],defaultValue:()=>[]},{key:"dispatcher",converter:r.converters.any,defaultValue:()=>D()},{key:"headers",converter:r.nullableConverter(r.converters.HeadersInit)}]),r.converters["DOMString or sequence<DOMString> or WebSocketInit"]=function(e){return r.util.Type(e)!==r.util.Types.OBJECT||Symbol.iterator in e?{protocols:r.converters["DOMString or sequence<DOMString>"](e)}:r.converters.WebSocketInit(e)},r.converters.WebSocketSendData=function(e){if(r.util.Type(e)===r.util.Types.OBJECT){if(r.is.Blob(e))return e;if(r.is.BufferSource(e))return e}return r.converters.USVString(e)},e.exports={WebSocket:F,ping:M}},6822:(e,t,s)=>{var n=s(9896),r=s(2203).Transform,i=s(2203).PassThrough,A=s(3106),o=s(9023),a=s(4434).EventEmitter,c=s(4434).errorMonitor,l=s(5537);function h(){this.outputStream=new i,this.entries=[],this.outputStreamCursor=0,this.ended=!1,this.allDone=!1,this.forceZip64Eocd=!1,this.errored=!1,this.on(c,(function(){this.errored=!0}))}t.u=h,o.inherits(h,a),h.prototype.addFile=function(e,t,s){var r=this;if(t=Q(t,!1),null==s&&(s={}),!E(r)){var i=new m(t,!1,s);r.entries.push(i),n.stat(e,(function(t,A){return t?r.emit("error",t):A.isFile()?(i.uncompressedSize=A.size,null==s.mtime&&i.setLastModDate(A.mtime),null==s.mode&&i.setFileAttributesMode(A.mode),i.setFileDataPumpFunction((function(){var t=n.createReadStream(e);i.state=m.FILE_DATA_IN_PROGRESS,t.on("error",(function(e){r.emit("error",e)})),u(r,i,t)})),void I(r)):r.emit("error",new Error("not a file: "+e))}))}},h.prototype.addReadStream=function(e,t,s){this.addReadStreamLazy(t,s,(function(t){t(null,e)}))},h.prototype.addReadStreamLazy=function(e,t,s){var n=this;if("function"==typeof t&&(s=t,t=null),null==t&&(t={}),e=Q(e,!1),!E(n)){var r=new m(e,!1,t);n.entries.push(r),r.setFileDataPumpFunction((function(){r.state=m.FILE_DATA_IN_PROGRESS,s((function(e,t){if(e)return n.emit("error",e);u(n,r,t)}))})),I(n)}},h.prototype.addBuffer=function(e,t,s){var n=this;if(t=Q(t,!1),e.length>1073741823)throw new Error("buffer too large: "+e.length+" > 1073741823");if(null==s&&(s={}),null!=s.size)throw new Error("options.size not allowed");if(!E(n)){var r=new m(t,!1,s);r.uncompressedSize=e.length,r.crc32=l.unsigned(e),r.crcAndFileSizeKnown=!0,n.entries.push(r),0===r.compressionLevel?i(e):A.deflateRaw(e,{level:r.compressionLevel},(function(e,t){i(t)}))}function i(e){r.compressedSize=e.length,r.setFileDataPumpFunction((function(){d(n,e),d(n,r.getDataDescriptor()),r.state=m.FILE_DATA_DONE,setImmediate((function(){I(n)}))})),I(n)}},h.prototype.addEmptyDirectory=function(e,t){var s=this;if(e=Q(e,!0),null==t&&(t={}),null!=t.size)throw new Error("options.size not allowed");if(null!=t.compress)throw new Error("options.compress not allowed");if(null!=t.compressionLevel)throw new Error("options.compressionLevel not allowed");if(!E(s)){var n=new m(e,!0,t);s.entries.push(n),n.setFileDataPumpFunction((function(){d(s,n.getDataDescriptor()),n.state=m.FILE_DATA_DONE,I(s)})),I(s)}};var g=Y([80,75,5,6]);function d(e,t){e.outputStream.write(t),e.outputStreamCursor+=t.length}function u(e,t,s){var n=new L,r=new U,o=0!==t.compressionLevel?new A.DeflateRaw({level:t.compressionLevel}):new i,a=new U;s.pipe(n).pipe(r).pipe(o).pipe(a).pipe(e.outputStream,{end:!1}),a.on("end",(function(){if(t.crc32=n.crc32,null==t.uncompressedSize)t.uncompressedSize=r.byteCount;else if(t.uncompressedSize!==r.byteCount)return e.emit("error",new Error("file data stream has unexpected number of bytes"));t.compressedSize=a.byteCount,e.outputStreamCursor+=t.compressedSize,d(e,t.getDataDescriptor()),t.state=m.FILE_DATA_DONE,I(e)}))}function I(e){if(!e.allDone&&!e.errored){if(e.ended&&null!=e.calculatedTotalSizeCallback){var t=function(e){for(var t=0,s=0,n=0;n<e.entries.length;n++){var r=e.entries[n];if(0!==r.compressionLevel)return-1;if(r.state>=m.READY_TO_PUMP_FILE_DATA){if(null==r.uncompressedSize)return-1}else if(null==r.uncompressedSize)return null;r.relativeOffsetOfLocalHeader=t;var i=r.useZip64Format();t+=y+r.utf8FileName.length,t+=r.uncompressedSize,r.crcAndFileSizeKnown||(t+=i?b:D),s+=v+r.utf8FileName.length+r.fileComment.length,r.forceDosTimestamp||(s+=N),i&&(s+=R)}var A=0;(e.forceZip64Eocd||e.entries.length>=65535||s>=65535||t>=4294967295)&&(A+=p+C);return A+=B+e.comment.length,t+s+A}(e);null!=t&&(e.calculatedTotalSizeCallback(t),e.calculatedTotalSizeCallback=null)}var s=function(){for(var t=0;t<e.entries.length;t++){var s=e.entries[t];if(s.state<m.FILE_DATA_DONE)return s}return null}();if(null!=s){if(s.state<m.READY_TO_PUMP_FILE_DATA)return;if(s.state===m.FILE_DATA_IN_PROGRESS)return;s.relativeOffsetOfLocalHeader=e.outputStreamCursor;var n=s.getLocalFileHeader();d(e,n),s.doFileDataPump()}else e.ended&&(e.offsetOfStartOfCentralDirectory=e.outputStreamCursor,e.entries.forEach((function(t){var s=t.getCentralDirectoryRecord();d(e,s)})),d(e,function(e,t){var s=!1,n=e.entries.length;(e.forceZip64Eocd||e.entries.length>=65535)&&(n=65535,s=!0);var r=e.outputStreamCursor-e.offsetOfStartOfCentralDirectory,i=r;(e.forceZip64Eocd||r>=4294967295)&&(i=4294967295,s=!0);var A=e.offsetOfStartOfCentralDirectory;(e.forceZip64Eocd||e.offsetOfStartOfCentralDirectory>=4294967295)&&(A=4294967295,s=!0);if(t)return s?p+C+B:B;var o=x(B+e.comment.length);if(o.writeUInt32LE(101010256,0),o.writeUInt16LE(0,4),o.writeUInt16LE(0,6),o.writeUInt16LE(n,8),o.writeUInt16LE(n,10),o.writeUInt32LE(i,12),o.writeUInt32LE(A,16),o.writeUInt16LE(e.comment.length,20),e.comment.copy(o,22),!s)return o;var a=x(p);a.writeUInt32LE(101075792,0),M(a,p-12,4),a.writeUInt16LE(w,12),a.writeUInt16LE(S,14),a.writeUInt32LE(0,16),a.writeUInt32LE(0,20),M(a,e.entries.length,24),M(a,e.entries.length,32),M(a,r,40),M(a,e.offsetOfStartOfCentralDirectory,48);var c=x(C);return c.writeUInt32LE(117853008,0),c.writeUInt32LE(0,4),M(c,e.outputStreamCursor,8),c.writeUInt32LE(1,16),Buffer.concat([a,c,o])}(e)),e.outputStream.end(),e.allDone=!0)}}function E(e){if(e.ended)throw new Error("cannot add entries after calling end()");return!!e.errored}h.prototype.end=function(e,t){if("function"==typeof e&&(t=e,e=null),null==e&&(e={}),!this.ended&&(this.ended=!0,!this.errored)){if(this.calculatedTotalSizeCallback=t,this.forceZip64Eocd=!!e.forceZip64Format,e.comment){if("string"==typeof e.comment?this.comment=function(e){if(/^[\x20-\x7e]*$/.test(e))return Y(e,"utf-8");if(null==H){H={};for(var t=0;t<P.length;t++)H[P[t]]=t}var s=x(e.length);for(t=0;t<e.length;t++){var n=H[e[t]];if(null==n)throw new Error("character not encodable in CP437: "+JSON.stringify(e[t]));s[t]=n}return s}(e.comment):this.comment=e.comment,this.comment.length>65535)throw new Error("comment is too large");if(V(this.comment,g))throw new Error("comment contains end of central directory record signature")}else this.comment=f;I(this)}};var p=56,C=20,B=22;function Q(e,t){if(""===e)throw new Error("empty metadataPath");if(e=e.replace(/\\/g,"/"),/^[a-zA-Z]:/.test(e)||/^\//.test(e))throw new Error("absolute path: "+e);if(-1!==e.split("/").indexOf(".."))throw new Error("invalid relative path: "+e);var s=/\/$/.test(e);if(t)s||(e+="/");else if(s)throw new Error("file path cannot end with '/': "+e);return e}var f=x(0);function m(e,t,s){if(this.utf8FileName=Y(e),this.utf8FileName.length>65535)throw new Error("utf8 file name too long. "+utf8FileName.length+" > 65535");if(this.isDirectory=t,this.state=m.WAITING_FOR_METADATA,this.setLastModDate(null!=s.mtime?s.mtime:new Date),this.forceDosTimestamp=!!s.forceDosTimestamp,null!=s.mode?this.setFileAttributesMode(s.mode):this.setFileAttributesMode(t?16893:33204),t?(this.crcAndFileSizeKnown=!0,this.crc32=0,this.uncompressedSize=0,this.compressedSize=0):(this.crcAndFileSizeKnown=!1,this.crc32=null,this.uncompressedSize=null,this.compressedSize=null,null!=s.size&&(this.uncompressedSize=s.size)),this.compressionLevel=t?0:function(e){if(null!=e.compress&&null!=e.compressionLevel&&!!e.compress!=!!e.compressionLevel)throw new Error("conflicting settings for compress and compressionLevel");return null!=e.compressionLevel?e.compressionLevel:!1===e.compress?0:6}(s),this.forceZip64Format=!!s.forceZip64Format,s.fileComment){if("string"==typeof s.fileComment?this.fileComment=Y(s.fileComment,"utf-8"):this.fileComment=s.fileComment,this.fileComment.length>65535)throw new Error("fileComment is too large")}else this.fileComment=f}m.WAITING_FOR_METADATA=0,m.READY_TO_PUMP_FILE_DATA=1,m.FILE_DATA_IN_PROGRESS=2,m.FILE_DATA_DONE=3,m.prototype.setLastModDate=function(e){this.mtime=e;var t=F(e);this.lastModFileTime=t.time,this.lastModFileDate=t.date},m.prototype.setFileAttributesMode=function(e){if((65535&e)!==e)throw new Error("invalid mode. expected: 0 <= "+e+" <= 65535");this.externalFileAttributes=e<<16>>>0},m.prototype.setFileDataPumpFunction=function(e){this.doFileDataPump=e,this.state=m.READY_TO_PUMP_FILE_DATA},m.prototype.useZip64Format=function(){return this.forceZip64Format||null!=this.uncompressedSize&&this.uncompressedSize>4294967294||null!=this.compressedSize&&this.compressedSize>4294967294||null!=this.relativeOffsetOfLocalHeader&&this.relativeOffsetOfLocalHeader>4294967294};var y=30,S=45,w=831;m.prototype.getLocalFileHeader=function(){var e=0,t=0,s=0;this.crcAndFileSizeKnown&&(e=this.crc32,t=this.compressedSize,s=this.uncompressedSize);var n=x(y),r=2048;return this.crcAndFileSizeKnown||(r|=8),n.writeUInt32LE(67324752,0),n.writeUInt16LE(20,4),n.writeUInt16LE(r,6),n.writeUInt16LE(this.getCompressionMethod(),8),n.writeUInt16LE(this.lastModFileTime,10),n.writeUInt16LE(this.lastModFileDate,12),n.writeUInt32LE(e,14),n.writeUInt32LE(t,18),n.writeUInt32LE(s,22),n.writeUInt16LE(this.utf8FileName.length,26),n.writeUInt16LE(0,28),Buffer.concat([n,this.utf8FileName])};var D=16,b=24;m.prototype.getDataDescriptor=function(){return this.crcAndFileSizeKnown?f:this.useZip64Format()?((e=x(b)).writeUInt32LE(134695760,0),e.writeUInt32LE(this.crc32,4),M(e,this.compressedSize,8),M(e,this.uncompressedSize,16),e):((e=x(D)).writeUInt32LE(134695760,0),e.writeUInt32LE(this.crc32,4),e.writeUInt32LE(this.compressedSize,8),e.writeUInt32LE(this.uncompressedSize,12),e);var e};var v=46,N=9,R=28;m.prototype.getCentralDirectoryRecord=function(){var e=x(v),t=2048;this.crcAndFileSizeKnown||(t|=8);var s=f;if(!this.forceDosTimestamp){(s=x(N)).writeUInt16LE(21589,0),s.writeUInt16LE(N-4,2);s.writeUInt8(3,4);var n=Math.floor(this.mtime.getTime()/1e3);n<-2147483648&&(n=-2147483648),n>2147483647&&(n=2147483647),s.writeUInt32LE(n,5)}var r=this.compressedSize,i=this.uncompressedSize,A=this.relativeOffsetOfLocalHeader,o=20,a=f;return this.useZip64Format()&&(r=4294967295,i=4294967295,A=4294967295,o=S,(a=x(R)).writeUInt16LE(1,0),a.writeUInt16LE(R-4,2),M(a,this.uncompressedSize,4),M(a,this.compressedSize,12),M(a,this.relativeOffsetOfLocalHeader,20)),e.writeUInt32LE(33639248,0),e.writeUInt16LE(w,4),e.writeUInt16LE(o,6),e.writeUInt16LE(t,8),e.writeUInt16LE(this.getCompressionMethod(),10),e.writeUInt16LE(this.lastModFileTime,12),e.writeUInt16LE(this.lastModFileDate,14),e.writeUInt32LE(this.crc32,16),e.writeUInt32LE(r,20),e.writeUInt32LE(i,24),e.writeUInt16LE(this.utf8FileName.length,28),e.writeUInt16LE(s.length+a.length,30),e.writeUInt16LE(this.fileComment.length,32),e.writeUInt16LE(0,34),e.writeUInt16LE(0,36),e.writeUInt32LE(this.externalFileAttributes,38),e.writeUInt32LE(A,42),Buffer.concat([e,this.utf8FileName,s,a,this.fileComment])},m.prototype.getCompressionMethod=function(){return 0===this.compressionLevel?0:8};var k=new Date(1980,0,1),T=new Date(2107,11,31,23,59,58);function F(e){e<k?e=k:e>T&&(e=T);var t=0;t|=31&e.getDate(),t|=(e.getMonth()+1&15)<<5,t|=(e.getFullYear()-1980&127)<<9;var s=0;return s|=Math.floor(e.getSeconds()/2),s|=(63&e.getMinutes())<<5,{date:t,time:s|=(31&e.getHours())<<11}}function M(e,t,s){var n=Math.floor(t/4294967296),r=t%4294967296;e.writeUInt32LE(r,s),e.writeUInt32LE(n,s+4)}function U(e){r.call(this,e),this.byteCount=0}function L(e){r.call(this,e),this.crc32=0}o.inherits(U,r),U.prototype._transform=function(e,t,s){this.byteCount+=e.length,s(null,e)},o.inherits(L,r),L.prototype._transform=function(e,t,s){this.crc32=l.unsigned(e,this.crc32),s(null,e)};var P="\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ";if(256!==P.length)throw new Error("assertion failure");var H=null;function x(e){x=function(e){return Buffer.allocUnsafe(e)};try{return x(e)}catch(t){return x=function(e){return new Buffer(e)},x(e)}}function Y(e,t){Y=function(e,t){return Buffer.from(e,t)};try{return Y(e,t)}catch(s){return Y=function(e,t){return new Buffer(e,t)},Y(e,t)}}function V(e,t){V=function(e,t){return e.includes(t)};try{return V(e,t)}catch(s){return V=function(e,t){for(var s=0;s<=e.length-t.length;s++)for(var n=0;;n++){if(n===t.length)return!0;if(e[s+n]!==t[n])break}return!1},V(e,t)}}},7562:function(e,t,s){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,s,n){void 0===n&&(n=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,n,r)}:function(e,t,s,n){void 0===n&&(n=s),e[n]=t[s]}),r=this&&this.__exportStar||function(e,t){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(t,s)||n(t,e,s)};Object.defineProperty(t,"__esModule",{value:!0}),t.sdk=t.MixinDeviceBase=t.ScryptedDeviceBase=void 0,r(s(4192),t);const i=s(4192);s(3339);class A extends i.DeviceBase{constructor(e){super(),this.nativeId=e}get storage(){return this._storage||(this._storage=t.sdk.deviceManager.getDeviceStorage(this.nativeId)),this._storage}get log(){return this._log||(this._log=t.sdk.deviceManager.getDeviceLogger(this.nativeId)),this._log}get console(){return this._console||(this._console=t.sdk.deviceManager.getDeviceConsole(this.nativeId)),this._console}async createMediaObject(e,s){return t.sdk.mediaManager.createMediaObject(e,s,{sourceId:this.id})}getMediaObjectConsole(e){return"string"!=typeof e.sourceId?this.console:t.sdk.deviceManager.getMixinConsole(e.sourceId,this.nativeId)}_lazyLoadDeviceState(){this._deviceState||(this.nativeId?this._deviceState=t.sdk.deviceManager.getDeviceState(this.nativeId):this._deviceState=t.sdk.deviceManager.getDeviceState())}onDeviceEvent(e,s){return t.sdk.deviceManager.onDeviceEvent(this.nativeId,e,s)}}t.ScryptedDeviceBase=A;class o extends i.DeviceBase{constructor(e){super(),this._listeners=new Set,this.mixinDevice=e.mixinDevice,this.mixinDeviceInterfaces=e.mixinDeviceInterfaces,this.mixinStorageSuffix=e.mixinStorageSuffix,this._deviceState=e.mixinDeviceState,this.nativeId=t.sdk.systemManager.getDeviceById(this.id).nativeId,this.mixinProviderNativeId=e.mixinProviderNativeId,this._deviceState.__rpcproxy_traps_all_properties&&"string"==typeof this._deviceState.id&&(this._deviceState=t.sdk.deviceManager.createDeviceState(this._deviceState.id,this._deviceState.setState))}get storage(){if(!this._storage){const e=this.mixinStorageSuffix,s=this.id+(e?":"+e:"");this._storage=t.sdk.deviceManager.getMixinStorage(s,this.mixinProviderNativeId)}return this._storage}get console(){return this._console||(t.sdk.deviceManager.getMixinConsole?this._console=t.sdk.deviceManager.getMixinConsole(this.id,this.mixinProviderNativeId):this._console=t.sdk.deviceManager.getDeviceConsole(this.mixinProviderNativeId)),this._console}async createMediaObject(e,s){return t.sdk.mediaManager.createMediaObject(e,s,{sourceId:this.id})}getMediaObjectConsole(e){return"string"!=typeof e.sourceId?this.console:t.sdk.deviceManager.getMixinConsole(e.sourceId,this.mixinProviderNativeId)}onDeviceEvent(e,s){return t.sdk.deviceManager.onMixinEvent(this.id,this,e,s)}_lazyLoadDeviceState(){}manageListener(e){this._listeners.add(e)}release(){for(const e of this._listeners)e.removeListener()}}t.MixinDeviceBase=o,function(){function e(e){return function(){return this._lazyLoadDeviceState(),this._deviceState?.[e]}}function t(e){return function(t){this._lazyLoadDeviceState(),this._deviceState?this._deviceState[e]=t:console.warn("device state is unavailable. the device must be discovered with deviceManager.onDeviceDiscovered or deviceManager.onDevicesChanged before the state can be set.")}}for(const s of Object.values(i.ScryptedInterfaceProperty))s!==i.ScryptedInterfaceProperty.nativeId&&(Object.defineProperty(A.prototype,s,{set:t(s),get:e(s)}),Object.defineProperty(o.prototype,s,{set:t(s),get:e(s)}))}(),t.sdk={};try{let e=!1;try{process.env.SCRYPTED_SDK_ES_MODULE||process.env.SCRYPTED_SDK_MODULE;const n=process.env.SCRYPTED_SDK_CJS_MODULE||process.env.SCRYPTED_SDK_MODULE;if(n)if("undefined"!=typeof require){const s=require(process.env.SCRYPTED_SDK_MODULE);Object.assign(t.sdk,s.getScryptedStatic()),e=!0}else{const r=s(3891)(n);Object.assign(t.sdk,r.getScryptedStatic()),e=!0}}catch(e){throw console.warn("failed to load sdk module",e),e}if(!e){let e;try{e=pluginRuntimeAPI}catch(e){}Object.assign(t.sdk,{log:deviceManager.getDeviceLogger(void 0),deviceManager,endpointManager,mediaManager,systemManager,pluginHostAPI,...e})}try{t.sdk.systemManager.setScryptedInterfaceDescriptors?.(i.TYPES_VERSION,i.ScryptedInterfaceDescriptors)?.catch((()=>{}))}catch(e){}}catch(e){console.error("sdk initialization error, import @scrypted/types or use @scrypted/client instead",e)}t.default=t.sdk},6117:function(e,t,s){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,s,n){void 0===n&&(n=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,n,r)}:function(e,t,s,n){void 0===n&&(n=s),e[n]=t[s]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.prototype.hasOwnProperty.call(e,s)&&n(t,e,s);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.StorageSettings=void 0;const A=i(s(7562)),{systemManager:o}=A.default;t.StorageSettings=class{constructor(e,t){this.device=e,this.settings=t,this.values={},this.hasValue={};for(const e of Object.keys(t)){const s=t[e],n=()=>this.getItem(e);let r;r="clippath"!==s.type?n:()=>{try{return JSON.parse(n())}catch(e){}},Object.defineProperty(this.values,e,{get:r,set:t=>this.putSetting(e,t),enumerable:!0}),Object.defineProperty(this.hasValue,e,{get:()=>null!=this.device.storage.getItem(e),enumerable:!0})}}get keys(){const e={};for(const t of Object.keys(this.settings))e[t]=t;return e}async getSettings(){const e=await(this.options?.onGet?.()),t=[];for(const[s,n]of Object.entries(this.settings)){let r=Object.assign({},n);e?.[s]&&(r=Object.assign(r,e[s])),r.onGet&&(r=Object.assign(r,await r.onGet())),r.hide||await(this.options?.hide?.[s]?.())||(r.key=s,r.value=this.getItemInternal(s,r,!0),"function"==typeof r.deviceFilter&&(r.deviceFilter=r.deviceFilter.toString()),t.push(r),delete r.onPut,delete r.onGet,delete r.mapPut,delete r.mapGet)}return t}async putSetting(e,t){const s=this.settings[e];let n;return s&&(n=this.getItemInternal(e,s)),this.putSettingInternal(s,n,e,t)}putSettingInternal(e,t,s,n){e?.noStore||(e?.mapPut&&(n=e.mapPut(t,n)),null==n?this.device.storage.removeItem(s):"object"==typeof n?this.device.storage.setItem(s,JSON.stringify(n)):this.device.storage.setItem(s,n?.toString())),e?.onPut?.(t,n),e?.hide||this.device.onDeviceEvent(A.ScryptedInterface.Settings,void 0)}getItemInternal(e,t,s){if(!t)return this.device.storage.getItem(e);const n=function(e,t,s,n){if(null==e)return s();const r=t.multiple?"array":t.type;if("boolean"===r)return"true"===e||"false"!==e&&(s()||!1);if("number"===r){const t=parseFloat(e);return isNaN(t)?s()||0:t}if("integer"===r){const t=parseInt(e);return isNaN(t)?s()||0:t}if("array"===r){if(!e)return s()||[];try{return JSON.parse(e)}catch(e){return s()||[]}}if("device"===r)return n?e:o.getDeviceById(e)||o.getDeviceById(s());if(e&&t.json)try{return JSON.parse(e)}catch(e){return s()}return e||s()}(this.device.storage.getItem(e),t,(()=>null!=t.persistedDefaultValue?(this.putSettingInternal(t,void 0,e,t.persistedDefaultValue),t.persistedDefaultValue):t.defaultValue),s);return t.mapGet?t.mapGet(n):n}getItem(e){return this.getItemInternal(e,this.settings[e])}}},3891:e=>{function t(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=3891,e.exports=t},4192:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ScryptedMimeTypes=t.ScryptedInterface=t.MediaPlayerState=t.SecuritySystemObstruction=t.SecuritySystemMode=t.AirQuality=t.AirPurifierMode=t.AirPurifierStatus=t.ChargeState=t.LockState=t.PanTiltZoomMovement=t.ThermostatMode=t.TemperatureUnit=t.FanMode=t.HumidityMode=t.ScryptedDeviceType=t.ScryptedInterfaceDescriptors=t.ScryptedInterfaceMethod=t.ScryptedInterfaceProperty=t.DeviceBase=t.TYPES_VERSION=void 0,t.TYPES_VERSION="0.3.108";var s,n,r,i,A,o,a,c,l,h,g,d,u,I,E,p,C,B;t.DeviceBase=class{},function(e){e.id="id",e.info="info",e.interfaces="interfaces",e.mixins="mixins",e.name="name",e.nativeId="nativeId",e.pluginId="pluginId",e.providedInterfaces="providedInterfaces",e.providedName="providedName",e.providedRoom="providedRoom",e.providedType="providedType",e.providerId="providerId",e.room="room",e.type="type",e.scryptedRuntimeArguments="scryptedRuntimeArguments",e.on="on",e.brightness="brightness",e.colorTemperature="colorTemperature",e.rgb="rgb",e.hsv="hsv",e.buttons="buttons",e.sensors="sensors",e.running="running",e.paused="paused",e.docked="docked",e.temperatureSetting="temperatureSetting",e.temperature="temperature",e.temperatureUnit="temperatureUnit",e.humidity="humidity",e.audioVolumes="audioVolumes",e.recordingActive="recordingActive",e.ptzCapabilities="ptzCapabilities",e.lockState="lockState",e.entryOpen="entryOpen",e.batteryLevel="batteryLevel",e.chargeState="chargeState",e.online="online",e.fromMimeType="fromMimeType",e.toMimeType="toMimeType",e.converters="converters",e.binaryState="binaryState",e.tampered="tampered",e.sleeping="sleeping",e.powerDetected="powerDetected",e.audioDetected="audioDetected",e.motionDetected="motionDetected",e.ambientLight="ambientLight",e.occupied="occupied",e.flooded="flooded",e.ultraviolet="ultraviolet",e.luminance="luminance",e.position="position",e.securitySystemState="securitySystemState",e.pm10Density="pm10Density",e.pm25Density="pm25Density",e.vocDensity="vocDensity",e.noxDensity="noxDensity",e.co2ppm="co2ppm",e.airQuality="airQuality",e.airPurifierState="airPurifierState",e.filterChangeIndication="filterChangeIndication",e.filterLifeLevel="filterLifeLevel",e.humiditySetting="humiditySetting",e.fan="fan",e.applicationInfo="applicationInfo",e.systemDevice="systemDevice"}(s||(t.ScryptedInterfaceProperty=s={})),function(e){e.listen="listen",e.probe="probe",e.setMixins="setMixins",e.setName="setName",e.setRoom="setRoom",e.setType="setType",e.getPluginJson="getPluginJson",e.turnOff="turnOff",e.turnOn="turnOn",e.setBrightness="setBrightness",e.getTemperatureMaxK="getTemperatureMaxK",e.getTemperatureMinK="getTemperatureMinK",e.setColorTemperature="setColorTemperature",e.setRgb="setRgb",e.setHsv="setHsv",e.pressButton="pressButton",e.sendNotification="sendNotification",e.start="start",e.stop="stop",e.pause="pause",e.resume="resume",e.dock="dock",e.setTemperature="setTemperature",e.setTemperatureUnit="setTemperatureUnit",e.getPictureOptions="getPictureOptions",e.takePicture="takePicture",e.getAudioStream="getAudioStream",e.setAudioVolumes="setAudioVolumes",e.startDisplay="startDisplay",e.stopDisplay="stopDisplay",e.getVideoStream="getVideoStream",e.getVideoStreamOptions="getVideoStreamOptions",e.getPrivacyMasks="getPrivacyMasks",e.setPrivacyMasks="setPrivacyMasks",e.getVideoTextOverlays="getVideoTextOverlays",e.setVideoTextOverlay="setVideoTextOverlay",e.getRecordingStream="getRecordingStream",e.getRecordingStreamCurrentTime="getRecordingStreamCurrentTime",e.getRecordingStreamOptions="getRecordingStreamOptions",e.getRecordingStreamThumbnail="getRecordingStreamThumbnail",e.deleteRecordingStream="deleteRecordingStream",e.setRecordingActive="setRecordingActive",e.ptzCommand="ptzCommand",e.getRecordedEvents="getRecordedEvents",e.getVideoClip="getVideoClip",e.getVideoClips="getVideoClips",e.getVideoClipThumbnail="getVideoClipThumbnail",e.removeVideoClips="removeVideoClips",e.setVideoStreamOptions="setVideoStreamOptions",e.startIntercom="startIntercom",e.stopIntercom="stopIntercom",e.lock="lock",e.unlock="unlock",e.addPassword="addPassword",e.getPasswords="getPasswords",e.removePassword="removePassword",e.activate="activate",e.deactivate="deactivate",e.isReversible="isReversible",e.closeEntry="closeEntry",e.openEntry="openEntry",e.getDevice="getDevice",e.releaseDevice="releaseDevice",e.adoptDevice="adoptDevice",e.discoverDevices="discoverDevices",e.createDevice="createDevice",e.getCreateDeviceSettings="getCreateDeviceSettings",e.reboot="reboot",e.getRefreshFrequency="getRefreshFrequency",e.refresh="refresh",e.getMediaStatus="getMediaStatus",e.load="load",e.seek="seek",e.skipNext="skipNext",e.skipPrevious="skipPrevious",e.convert="convert",e.convertMedia="convertMedia",e.getSettings="getSettings",e.putSetting="putSetting",e.armSecuritySystem="armSecuritySystem",e.disarmSecuritySystem="disarmSecuritySystem",e.setAirPurifierState="setAirPurifierState",e.getReadmeMarkdown="getReadmeMarkdown",e.getOauthUrl="getOauthUrl",e.onOauthCallback="onOauthCallback",e.canMixin="canMixin",e.getMixin="getMixin",e.releaseMixin="releaseMixin",e.onRequest="onRequest",e.onConnection="onConnection",e.onPush="onPush",e.run="run",e.eval="eval",e.loadScripts="loadScripts",e.saveScript="saveScript",e.forkInterface="forkInterface",e.trackObjects="trackObjects",e.getDetectionInput="getDetectionInput",e.getObjectTypes="getObjectTypes",e.detectObjects="detectObjects",e.generateObjectDetections="generateObjectDetections",e.getDetectionModel="getDetectionModel",e.setHumidity="setHumidity",e.setFan="setFan",e.startRTCSignalingSession="startRTCSignalingSession",e.createRTCSignalingSession="createRTCSignalingSession",e.getScryptedUserAccessControl="getScryptedUserAccessControl",e.generateVideoFrames="generateVideoFrames",e.connectStream="connectStream",e.getTTYSettings="getTTYSettings"}(n||(t.ScryptedInterfaceMethod=n={})),t.ScryptedInterfaceDescriptors={ScryptedDevice:{name:"ScryptedDevice",methods:["listen","probe","setMixins","setName","setRoom","setType"],properties:["id","info","interfaces","mixins","name","nativeId","pluginId","providedInterfaces","providedName","providedRoom","providedType","providerId","room","type"]},ScryptedPlugin:{name:"ScryptedPlugin",methods:["getPluginJson"],properties:[]},ScryptedPluginRuntime:{name:"ScryptedPluginRuntime",methods:[],properties:["scryptedRuntimeArguments"]},OnOff:{name:"OnOff",methods:["turnOff","turnOn"],properties:["on"]},Brightness:{name:"Brightness",methods:["setBrightness"],properties:["brightness"]},ColorSettingTemperature:{name:"ColorSettingTemperature",methods:["getTemperatureMaxK","getTemperatureMinK","setColorTemperature"],properties:["colorTemperature"]},ColorSettingRgb:{name:"ColorSettingRgb",methods:["setRgb"],properties:["rgb"]},ColorSettingHsv:{name:"ColorSettingHsv",methods:["setHsv"],properties:["hsv"]},Buttons:{name:"Buttons",methods:[],properties:["buttons"]},PressButtons:{name:"PressButtons",methods:["pressButton"],properties:[]},Sensors:{name:"Sensors",methods:[],properties:["sensors"]},Notifier:{name:"Notifier",methods:["sendNotification"],properties:[]},StartStop:{name:"StartStop",methods:["start","stop"],properties:["running"]},Pause:{name:"Pause",methods:["pause","resume"],properties:["paused"]},Dock:{name:"Dock",methods:["dock"],properties:["docked"]},TemperatureSetting:{name:"TemperatureSetting",methods:["setTemperature"],properties:["temperatureSetting"]},Thermometer:{name:"Thermometer",methods:["setTemperatureUnit"],properties:["temperature","temperatureUnit"]},HumiditySensor:{name:"HumiditySensor",methods:[],properties:["humidity"]},Camera:{name:"Camera",methods:["getPictureOptions","takePicture"],properties:[]},Microphone:{name:"Microphone",methods:["getAudioStream"],properties:[]},AudioVolumeControl:{name:"AudioVolumeControl",methods:["setAudioVolumes"],properties:["audioVolumes"]},Display:{name:"Display",methods:["startDisplay","stopDisplay"],properties:[]},VideoCamera:{name:"VideoCamera",methods:["getVideoStream","getVideoStreamOptions"],properties:[]},VideoCameraMask:{name:"VideoCameraMask",methods:["getPrivacyMasks","setPrivacyMasks"],properties:[]},VideoTextOverlays:{name:"VideoTextOverlays",methods:["getVideoTextOverlays","setVideoTextOverlay"],properties:[]},VideoRecorder:{name:"VideoRecorder",methods:["getRecordingStream","getRecordingStreamCurrentTime","getRecordingStreamOptions","getRecordingStreamThumbnail"],properties:["recordingActive"]},VideoRecorderManagement:{name:"VideoRecorderManagement",methods:["deleteRecordingStream","setRecordingActive"],properties:[]},PanTiltZoom:{name:"PanTiltZoom",methods:["ptzCommand"],properties:["ptzCapabilities"]},EventRecorder:{name:"EventRecorder",methods:["getRecordedEvents"],properties:[]},VideoClips:{name:"VideoClips",methods:["getVideoClip","getVideoClips","getVideoClipThumbnail","removeVideoClips"],properties:[]},VideoCameraConfiguration:{name:"VideoCameraConfiguration",methods:["setVideoStreamOptions"],properties:[]},Intercom:{name:"Intercom",methods:["startIntercom","stopIntercom"],properties:[]},Lock:{name:"Lock",methods:["lock","unlock"],properties:["lockState"]},PasswordStore:{name:"PasswordStore",methods:["addPassword","getPasswords","removePassword"],properties:[]},Scene:{name:"Scene",methods:["activate","deactivate","isReversible"],properties:[]},Entry:{name:"Entry",methods:["closeEntry","openEntry"],properties:[]},EntrySensor:{name:"EntrySensor",methods:[],properties:["entryOpen"]},DeviceProvider:{name:"DeviceProvider",methods:["getDevice","releaseDevice"],properties:[]},DeviceDiscovery:{name:"DeviceDiscovery",methods:["adoptDevice","discoverDevices"],properties:[]},DeviceCreator:{name:"DeviceCreator",methods:["createDevice","getCreateDeviceSettings"],properties:[]},Battery:{name:"Battery",methods:[],properties:["batteryLevel"]},Charger:{name:"Charger",methods:[],properties:["chargeState"]},Reboot:{name:"Reboot",methods:["reboot"],properties:[]},Refresh:{name:"Refresh",methods:["getRefreshFrequency","refresh"],properties:[]},MediaPlayer:{name:"MediaPlayer",methods:["getMediaStatus","load","seek","skipNext","skipPrevious"],properties:[]},Online:{name:"Online",methods:[],properties:["online"]},BufferConverter:{name:"BufferConverter",methods:["convert"],properties:["fromMimeType","toMimeType"]},MediaConverter:{name:"MediaConverter",methods:["convertMedia"],properties:["converters"]},Settings:{name:"Settings",methods:["getSettings","putSetting"],properties:[]},BinarySensor:{name:"BinarySensor",methods:[],properties:["binaryState"]},TamperSensor:{name:"TamperSensor",methods:[],properties:["tampered"]},Sleep:{name:"Sleep",methods:[],properties:["sleeping"]},PowerSensor:{name:"PowerSensor",methods:[],properties:["powerDetected"]},AudioSensor:{name:"AudioSensor",methods:[],properties:["audioDetected"]},MotionSensor:{name:"MotionSensor",methods:[],properties:["motionDetected"]},AmbientLightSensor:{name:"AmbientLightSensor",methods:[],properties:["ambientLight"]},OccupancySensor:{name:"OccupancySensor",methods:[],properties:["occupied"]},FloodSensor:{name:"FloodSensor",methods:[],properties:["flooded"]},UltravioletSensor:{name:"UltravioletSensor",methods:[],properties:["ultraviolet"]},LuminanceSensor:{name:"LuminanceSensor",methods:[],properties:["luminance"]},PositionSensor:{name:"PositionSensor",methods:[],properties:["position"]},SecuritySystem:{name:"SecuritySystem",methods:["armSecuritySystem","disarmSecuritySystem"],properties:["securitySystemState"]},PM10Sensor:{name:"PM10Sensor",methods:[],properties:["pm10Density"]},PM25Sensor:{name:"PM25Sensor",methods:[],properties:["pm25Density"]},VOCSensor:{name:"VOCSensor",methods:[],properties:["vocDensity"]},NOXSensor:{name:"NOXSensor",methods:[],properties:["noxDensity"]},CO2Sensor:{name:"CO2Sensor",methods:[],properties:["co2ppm"]},AirQualitySensor:{name:"AirQualitySensor",methods:[],properties:["airQuality"]},AirPurifier:{name:"AirPurifier",methods:["setAirPurifierState"],properties:["airPurifierState"]},FilterMaintenance:{name:"FilterMaintenance",methods:[],properties:["filterChangeIndication","filterLifeLevel"]},Readme:{name:"Readme",methods:["getReadmeMarkdown"],properties:[]},OauthClient:{name:"OauthClient",methods:["getOauthUrl","onOauthCallback"],properties:[]},MixinProvider:{name:"MixinProvider",methods:["canMixin","getMixin","releaseMixin"],properties:[]},HttpRequestHandler:{name:"HttpRequestHandler",methods:["onRequest"],properties:[]},EngineIOHandler:{name:"EngineIOHandler",methods:["onConnection"],properties:[]},PushHandler:{name:"PushHandler",methods:["onPush"],properties:[]},Program:{name:"Program",methods:["run"],properties:[]},Scriptable:{name:"Scriptable",methods:["eval","loadScripts","saveScript"],properties:[]},ClusterForkInterface:{name:"ClusterForkInterface",methods:["forkInterface"],properties:[]},ObjectTracker:{name:"ObjectTracker",methods:["trackObjects"],properties:[]},ObjectDetector:{name:"ObjectDetector",methods:["getDetectionInput","getObjectTypes"],properties:[]},ObjectDetection:{name:"ObjectDetection",methods:["detectObjects","generateObjectDetections","getDetectionModel"],properties:[]},ObjectDetectionPreview:{name:"ObjectDetectionPreview",methods:[],properties:[]},ObjectDetectionGenerator:{name:"ObjectDetectionGenerator",methods:[],properties:[]},HumiditySetting:{name:"HumiditySetting",methods:["setHumidity"],properties:["humiditySetting"]},Fan:{name:"Fan",methods:["setFan"],properties:["fan"]},RTCSignalingChannel:{name:"RTCSignalingChannel",methods:["startRTCSignalingSession"],properties:[]},RTCSignalingClient:{name:"RTCSignalingClient",methods:["createRTCSignalingSession"],properties:[]},LauncherApplication:{name:"LauncherApplication",methods:[],properties:["applicationInfo"]},ScryptedUser:{name:"ScryptedUser",methods:["getScryptedUserAccessControl"],properties:[]},VideoFrameGenerator:{name:"VideoFrameGenerator",methods:["generateVideoFrames"],properties:[]},StreamService:{name:"StreamService",methods:["connectStream"],properties:[]},TTY:{name:"TTY",methods:[],properties:[]},TTYSettings:{name:"TTYSettings",methods:["getTTYSettings"],properties:[]},ScryptedSystemDevice:{name:"ScryptedSystemDevice",methods:[],properties:["systemDevice"]},ScryptedDeviceCreator:{name:"ScryptedDeviceCreator",methods:[],properties:[]},ScryptedSettings:{name:"ScryptedSettings",methods:[],properties:[]}},function(e){e.Builtin="Builtin",e.Camera="Camera",e.Fan="Fan",e.Light="Light",e.Switch="Switch",e.Outlet="Outlet",e.Sensor="Sensor",e.Scene="Scene",e.Program="Program",e.Automation="Automation",e.Vacuum="Vacuum",e.Notifier="Notifier",e.Thermostat="Thermostat",e.Lock="Lock",e.PasswordControl="PasswordControl",e.Display="Display",e.SmartDisplay="SmartDisplay",e.Speaker="Speaker",e.SmartSpeaker="SmartSpeaker",e.Event="Event",e.Entry="Entry",e.Garage="Garage",e.DeviceProvider="DeviceProvider",e.DataSource="DataSource",e.API="API",e.Doorbell="Doorbell",e.Irrigation="Irrigation",e.Valve="Valve",e.Person="Person",e.SecuritySystem="SecuritySystem",e.WindowCovering="WindowCovering",e.Siren="Siren",e.AirPurifier="AirPurifier",e.Unknown="Unknown"}(r||(t.ScryptedDeviceType=r={})),function(e){e.Humidify="Humidify",e.Dehumidify="Dehumidify",e.Auto="Auto",e.Off="Off"}(i||(t.HumidityMode=i={})),function(e){e.Auto="Auto",e.Manual="Manual"}(A||(t.FanMode=A={})),function(e){e.C="C",e.F="F"}(o||(t.TemperatureUnit=o={})),function(e){e.Off="Off",e.Cool="Cool",e.Heat="Heat",e.HeatCool="HeatCool",e.Auto="Auto",e.FanOnly="FanOnly",e.Purifier="Purifier",e.Eco="Eco",e.Dry="Dry",e.On="On"}(a||(t.ThermostatMode=a={})),function(e){e.Absolute="Absolute",e.Relative="Relative",e.Continuous="Continuous",e.Preset="Preset",e.Home="Home"}(c||(t.PanTiltZoomMovement=c={})),function(e){e.Locked="Locked",e.Unlocked="Unlocked",e.Jammed="Jammed"}(l||(t.LockState=l={})),function(e){e.Trickle="trickle",e.Charging="charging",e.NotCharging="not-charging"}(h||(t.ChargeState=h={})),function(e){e.Inactive="Inactive",e.Idle="Idle",e.Active="Active",e.ActiveNightMode="ActiveNightMode"}(g||(t.AirPurifierStatus=g={})),function(e){e.Manual="Manual",e.Automatic="Automatic"}(d||(t.AirPurifierMode=d={})),function(e){e.Unknown="Unknown",e.Excellent="Excellent",e.Good="Good",e.Fair="Fair",e.Inferior="Inferior",e.Poor="Poor"}(u||(t.AirQuality=u={})),function(e){e.Disarmed="Disarmed",e.HomeArmed="HomeArmed",e.AwayArmed="AwayArmed",e.NightArmed="NightArmed"}(I||(t.SecuritySystemMode=I={})),function(e){e.Sensor="Sensor",e.Occupied="Occupied",e.Time="Time",e.Error="Error"}(E||(t.SecuritySystemObstruction=E={})),function(e){e.Idle="Idle",e.Playing="Playing",e.Paused="Paused",e.Buffering="Buffering"}(p||(t.MediaPlayerState=p={})),function(e){e.ScryptedDevice="ScryptedDevice",e.ScryptedPlugin="ScryptedPlugin",e.ScryptedPluginRuntime="ScryptedPluginRuntime",e.OnOff="OnOff",e.Brightness="Brightness",e.ColorSettingTemperature="ColorSettingTemperature",e.ColorSettingRgb="ColorSettingRgb",e.ColorSettingHsv="ColorSettingHsv",e.Buttons="Buttons",e.PressButtons="PressButtons",e.Sensors="Sensors",e.Notifier="Notifier",e.StartStop="StartStop",e.Pause="Pause",e.Dock="Dock",e.TemperatureSetting="TemperatureSetting",e.Thermometer="Thermometer",e.HumiditySensor="HumiditySensor",e.Camera="Camera",e.Microphone="Microphone",e.AudioVolumeControl="AudioVolumeControl",e.Display="Display",e.VideoCamera="VideoCamera",e.VideoCameraMask="VideoCameraMask",e.VideoTextOverlays="VideoTextOverlays",e.VideoRecorder="VideoRecorder",e.VideoRecorderManagement="VideoRecorderManagement",e.PanTiltZoom="PanTiltZoom",e.EventRecorder="EventRecorder",e.VideoClips="VideoClips",e.VideoCameraConfiguration="VideoCameraConfiguration",e.Intercom="Intercom",e.Lock="Lock",e.PasswordStore="PasswordStore",e.Scene="Scene",e.Entry="Entry",e.EntrySensor="EntrySensor",e.DeviceProvider="DeviceProvider",e.DeviceDiscovery="DeviceDiscovery",e.DeviceCreator="DeviceCreator",e.Battery="Battery",e.Charger="Charger",e.Reboot="Reboot",e.Refresh="Refresh",e.MediaPlayer="MediaPlayer",e.Online="Online",e.BufferConverter="BufferConverter",e.MediaConverter="MediaConverter",e.Settings="Settings",e.BinarySensor="BinarySensor",e.TamperSensor="TamperSensor",e.Sleep="Sleep",e.PowerSensor="PowerSensor",e.AudioSensor="AudioSensor",e.MotionSensor="MotionSensor",e.AmbientLightSensor="AmbientLightSensor",e.OccupancySensor="OccupancySensor",e.FloodSensor="FloodSensor",e.UltravioletSensor="UltravioletSensor",e.LuminanceSensor="LuminanceSensor",e.PositionSensor="PositionSensor",e.SecuritySystem="SecuritySystem",e.PM10Sensor="PM10Sensor",e.PM25Sensor="PM25Sensor",e.VOCSensor="VOCSensor",e.NOXSensor="NOXSensor",e.CO2Sensor="CO2Sensor",e.AirQualitySensor="AirQualitySensor",e.AirPurifier="AirPurifier",e.FilterMaintenance="FilterMaintenance",e.Readme="Readme",e.OauthClient="OauthClient",e.MixinProvider="MixinProvider",e.HttpRequestHandler="HttpRequestHandler",e.EngineIOHandler="EngineIOHandler",e.PushHandler="PushHandler",e.Program="Program",e.Scriptable="Scriptable",e.ClusterForkInterface="ClusterForkInterface",e.ObjectTracker="ObjectTracker",e.ObjectDetector="ObjectDetector",e.ObjectDetection="ObjectDetection",e.ObjectDetectionPreview="ObjectDetectionPreview",e.ObjectDetectionGenerator="ObjectDetectionGenerator",e.HumiditySetting="HumiditySetting",e.Fan="Fan",e.RTCSignalingChannel="RTCSignalingChannel",e.RTCSignalingClient="RTCSignalingClient",e.LauncherApplication="LauncherApplication",e.ScryptedUser="ScryptedUser",e.VideoFrameGenerator="VideoFrameGenerator",e.StreamService="StreamService",e.TTY="TTY",e.TTYSettings="TTYSettings",e.ScryptedSystemDevice="ScryptedSystemDevice",e.ScryptedDeviceCreator="ScryptedDeviceCreator",e.ScryptedSettings="ScryptedSettings"}(C||(t.ScryptedInterface=C={})),function(e){e.Url="text/x-uri",e.InsecureLocalUrl="text/x-insecure-local-uri",e.LocalUrl="text/x-local-uri",e.ServerId="text/x-server-id",e.PushEndpoint="text/x-push-endpoint",e.SchemePrefix="x-scrypted/x-scrypted-scheme-",e.MediaStreamUrl="text/x-media-url",e.MediaObject="x-scrypted/x-scrypted-media-object",e.RequestMediaObject="x-scrypted/x-scrypted-request-media-object",e.RequestMediaStream="x-scrypted/x-scrypted-request-stream",e.MediaStreamFeedback="x-scrypted/x-media-stream-feedback",e.FFmpegInput="x-scrypted/x-ffmpeg-input",e.FFmpegTranscodeStream="x-scrypted/x-ffmpeg-transcode-stream",e.RTCSignalingChannel="x-scrypted/x-scrypted-rtc-signaling-channel",e.RTCSignalingSession="x-scrypted/x-scrypted-rtc-signaling-session",e.RTCConnectionManagement="x-scrypted/x-scrypted-rtc-connection-management",e.Image="x-scrypted/x-scrypted-image"}(B||(t.ScryptedMimeTypes=B={}))},7077:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseBaichuanClass=t.BaichuanLogger=void 0;const n=s(7562),r=s(5098);class i{constructor(e,t,s){this.baseLogger=e,this.deviceName=t,this.isDebugEnabledCallback=s}formatMessage(e,...t){const s=(new Date).toLocaleString();return`${`[${this.deviceName}] [${s}] [${e}]`} ${t.map((e=>"object"==typeof e?JSON.stringify(e):String(e))).join(" ")}`}log(...e){this.baseLogger.log(this.formatMessage("LOG",...e))}error(...e){this.baseLogger.error(this.formatMessage("ERROR",...e))}warn(...e){this.baseLogger.warn(this.formatMessage("WARN",...e))}debug(...e){this.isDebugEnabledCallback()&&this.baseLogger.debug(this.formatMessage("DEBUG",...e))}isDebugEnabled(){return this.isDebugEnabledCallback()}assert(e,...t){this.baseLogger.assert(e,...t)}clear(){this.baseLogger.clear()}count(e){this.baseLogger.count(e)}countReset(e){this.baseLogger.countReset(e)}dir(e,t){this.baseLogger.dir(e,t)}dirxml(...e){this.baseLogger.dirxml(...e)}group(...e){this.baseLogger.group(...e)}groupCollapsed(...e){this.baseLogger.groupCollapsed(...e)}groupEnd(){this.baseLogger.groupEnd()}info(...e){this.baseLogger.info(this.formatMessage("INFO",...e))}table(e,t){this.baseLogger.table(e,t)}time(e){this.baseLogger.time(e)}timeEnd(e){this.baseLogger.timeEnd(e)}timeLog(e,...t){this.baseLogger.timeLog(e,...t)}trace(...e){this.baseLogger.trace(...e)}get memory(){return this.baseLogger.memory}get Console(){return this.baseLogger.Console}profile(e){"function"==typeof this.baseLogger.profile&&this.baseLogger.profile(e)}profileEnd(e){"function"==typeof this.baseLogger.profileEnd&&this.baseLogger.profileEnd(e)}timeStamp(e){"function"==typeof this.baseLogger.timeStamp&&this.baseLogger.timeStamp(e)}context(...e){"function"==typeof this.baseLogger.context&&this.baseLogger.context(...e)}}t.BaichuanLogger=i;class A extends n.ScryptedDeviceBase{constructor(){super(...arguments),this.lastDisconnectTime=0,this.reconnectBackoffMs=2e3,this.eventSubscriptionActive=!1}getBaichuanLogger(){return new i(this.console,this.getDeviceName(),(()=>this.isDebugEnabled()))}async onBeforeCleanup(){}async ensureBaichuanClient(){if(this.baichuanApi&&this.baichuanApi.client.isSocketConnected()&&this.baichuanApi.client.loggedIn)return this.baichuanApi;if(this.ensureClientPromise)return await this.ensureClientPromise;if(this.lastDisconnectTime>0){const e=Date.now()-this.lastDisconnectTime;if(e<this.reconnectBackoffMs){const t=this.reconnectBackoffMs-e;this.getBaichuanLogger().log(`Waiting ${t}ms before reconnection (backoff)`),await new Promise((e=>setTimeout(e,t)))}}this.ensureClientPromise=(async()=>{const e=this.getConnectionConfig();this.baichuanApi&&await this.cleanupBaichuanApi();const t=this.getBaichuanLogger(),s=await(0,r.createBaichuanApi)({inputs:{host:e.host,username:e.username,password:e.password,uid:e.uid,logger:t,debugOptions:e.debugOptions},transport:e.transport});if(await s.login(),!s.client.isSocketConnected())throw new Error("Socket not connected after login");return this.attachBaichuanListeners(s),this.baichuanApi=s,this.connectionTime=Date.now(),s})();try{return await this.ensureClientPromise}finally{this.ensureClientPromise=void 0}}attachBaichuanListeners(e){const t=this.getBaichuanLogger(),s=this.getConnectionCallbacks();this.errorListener=e=>{const n=e?.message||e?.toString?.()||String(e);if("string"==typeof n&&(n.includes("Baichuan socket closed")||n.includes("Baichuan UDP stream closed")||n.includes("Not running")))t.debug(`error (recoverable): ${n}`);else if(t.error(`error: ${n}`),s.onError)try{s.onError(e)}catch{}},this.closeListener=async()=>{try{const s=e.client.isSocketConnected(),n=e.client.loggedIn;t.log(`Connection state before close: connected=${s}, loggedIn=${n}`);const r=e.client;(r?.lastRx||r?.lastTx)&&t.debug(`Last message info: lastRx=${JSON.stringify(r.lastRx)}, lastTx=${JSON.stringify(r.lastTx)}`)}catch(e){t.debug(`Could not get connection state: ${e}`)}const n=Date.now(),r=n-this.lastDisconnectTime;if(this.lastDisconnectTime=n,t.log(`Socket closed, resetting client state for reconnection (last disconnect ${r}ms ago)`),await this.cleanupBaichuanApi(),s.onClose)try{await s.onClose()}catch{}},e.client.on("error",this.errorListener),e.client.on("close",this.closeListener)}async cleanupBaichuanApi(){if(!this.baichuanApi)return;const e=this.baichuanApi;if(await this.unsubscribeFromEvents(),await this.onBeforeCleanup(),this.closeListener){try{e.client.off("close",this.closeListener)}catch{}this.closeListener=void 0}if(this.errorListener){try{e.client.off("error",this.errorListener)}catch{}this.errorListener=void 0}try{e.client.isSocketConnected()&&await e.close()}catch{}this.baichuanApi=void 0,this.ensureClientPromise=void 0}async subscribeToEvents(){const e=this.getBaichuanLogger(),t=this.getConnectionCallbacks();if(!t.onSimpleEvent)return;if(this.eventSubscriptionActive&&this.baichuanApi){if(this.baichuanApi.client.isSocketConnected()&&this.baichuanApi.client.loggedIn)return void e.debug("Event subscription already active");this.eventSubscriptionActive=!1}await this.unsubscribeFromEvents();const s=await this.ensureBaichuanClient();if(s.client.isSocketConnected()&&s.client.loggedIn)if(!t.getEventSubscriptionEnabled||t.getEventSubscriptionEnabled())try{await s.onSimpleEvent(t.onSimpleEvent),this.eventSubscriptionActive=!0,e.log("Subscribed to Baichuan events")}catch(t){e.warn("Failed to subscribe to events",t),this.eventSubscriptionActive=!1}else e.debug("Event subscription disabled");else e.warn("Cannot subscribe to events: connection not ready")}async unsubscribeFromEvents(){const e=this.getBaichuanLogger(),t=this.getConnectionCallbacks();if(this.eventSubscriptionActive&&this.baichuanApi&&t.onSimpleEvent)try{this.baichuanApi.offSimpleEvent(t.onSimpleEvent),e.debug("Unsubscribed from Baichuan events")}catch(t){e.warn("Error unsubscribing from events",t)}this.eventSubscriptionActive=!1}}t.BaseBaichuanClass=A},6125:function(e,t,s){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ReolinkNativeBatteryCamera=void 0;const r=n(s(7562)),i=s(8799),A=s(9560);class o extends i.CommonCameraMixin{isBatteryInfoLoggingEnabled(){return(this.storageSettings.values.debugLogs||[]).includes(A.DebugLogOption.BatteryInfo)}constructor(e,t,s,n){super(e,t,{type:"battery",nvrDevice:s,multiFocalDevice:n}),this.plugin=t,this.motionDetected=!1,this.periodicStarted=!1,this.forceNewSnapshot=!1,this.batteryUpdateInProgress=!1}async takePicture(e){const t=this.getBaichuanLogger();if(!this.forceNewSnapshot&&this.lastPicture)return t.debug(`Returning cached snapshot, taken at ${new Date(this.lastPicture.atMs).toLocaleString()}`),this.lastPicture.mo;if(this.takePictureInFlight)return await this.takePictureInFlight;t.log(`Taking new snapshot from camera (forceNewSnapshot: ${this.forceNewSnapshot})`),this.forceNewSnapshot=!1,this.takePictureInFlight=(async()=>{const e=this.storageSettings.values.rtspChannel,s=await this.withBaichuanClient((async t=>await t.getSnapshot(e))),n=await r.default.mediaManager.createMediaObject(s,"image/jpeg");return this.lastPicture={mo:n,atMs:Date.now()},t.log(`Snapshot taken at ${new Date(this.lastPicture.atMs).toLocaleString()}`),n})();try{return await this.takePictureInFlight}finally{this.takePictureInFlight=void 0}}async getPictureOptions(){return[]}async init(){this.startPeriodicTasks(),await this.alignAuxDevicesState(),await this.updateBatteryInfo()}async release(){return this.stopPeriodicTasks(),this.resetBaichuanClient()}stopPeriodicTasks(){this.sleepCheckTimer&&(clearInterval(this.sleepCheckTimer),this.sleepCheckTimer=void 0),this.batteryUpdateTimer&&(clearInterval(this.batteryUpdateTimer),this.batteryUpdateTimer=void 0),this.periodicStarted=!1}startPeriodicTasks(){if(this.periodicStarted)return;const e=this.getBaichuanLogger();this.periodicStarted=!0,e.log("Starting periodic tasks for battery camera"),this.nvrDevice||this.multiFocalDevice||(this.sleepCheckTimer=setInterval((async()=>{try{const t=this.baichuanApi,s=this.storageSettings.values.rtspChannel;if(!t)return void(this.sleeping||(e.log("Camera is sleeping: no active Baichuan client"),this.sleeping=!0));const n=t.getSleepStatus({channel:s});await this.updateSleepingState(n)}catch(t){e.warn("Error checking sleeping state:",t)}}),5e3));const{batteryUpdateIntervalMinutes:t=10}=this.storageSettings.values,s=6e4*t;this.batteryUpdateTimer=setInterval((()=>{this.updateBatteryAndSnapshot().catch((()=>{}))}),s),e.log(`Periodic tasks started: sleep check every 5s, battery update every ${t} minutes`)}async updateSleepingState(e){try{if(this.isBatteryInfoLoggingEnabled()&&this.getBaichuanLogger().debug("getSleepStatus result:",JSON.stringify(e)),"sleeping"===e.state)this.sleeping||(this.getBaichuanLogger().log(`Camera is sleeping: ${e.reason}`),this.sleeping=!0);else if("awake"===e.state){const t=this.sleeping;t&&(this.getBaichuanLogger().log(`Camera woke up: ${e.reason}`),this.sleeping=!1),t&&(this.alignAuxDevicesState().catch((()=>{})),this.forceNewSnapshot&&this.takePicture().catch((()=>{})))}else this.getBaichuanLogger().debug(`Sleep status unknown: ${e.reason}`)}catch(e){this.getBaichuanLogger().debug("Error in checkSleepingState:",e)}}async checkRecordingAction(e){const t=this.plugin.nvrDeviceId;if(t&&this.mixins.includes(t)){const t=this.getBaichuanLogger(),s=await this.thisDevice.getSettings(),n=!s.find((e=>"recording:privacyMode"===e.key))?.value,{lowThresholdBatteryRecording:r,highThresholdBatteryRecording:i}=this.storageSettings.values;n&&e<r?(t.log(`Recording is enabled, but battery level is below low threshold (${e}% < ${r}%), disabling recording`),await this.thisDevice.putSetting("recording:privacyMode",!0)):!n&&e>i&&(t.log(`Recording is disabled, but battery level is above high threshold (${e}% > ${i}%), enabling recording`),await this.thisDevice.putSetting("recording:privacyMode",!1))}}async updateBatteryInfo(){const e=await this.ensureClient(),t=this.storageSettings.values.rtspChannel,s=await e.getBatteryInfo(t);if(this.isBatteryInfoLoggingEnabled()&&this.getBaichuanLogger().debug("getBatteryInfo result:",JSON.stringify(s)),void 0!==s.batteryPercent){const e=this.lastBatteryLevel;this.batteryLevel=s.batteryPercent,this.lastBatteryLevel=s.batteryPercent;let t=!0;if(void 0!==e&&e!==s.batteryPercent)if(void 0!==s.chargeStatus){const t="0"===s.chargeStatus||"2"===s.chargeStatus;this.getBaichuanLogger().log(`Battery level changed: ${e}% → ${s.batteryPercent}% (charging: ${t})`)}else this.getBaichuanLogger().log(`Battery level changed: ${e}% → ${s.batteryPercent}%`);else if(void 0===e)if(void 0!==s.chargeStatus){const e="0"===s.chargeStatus||"2"===s.chargeStatus;this.getBaichuanLogger().log(`Battery level set: ${s.batteryPercent}% (charging: ${e})`)}else this.getBaichuanLogger().log(`Battery level set: ${s.batteryPercent}%`);else t=!1;t&&await this.checkRecordingAction(s.batteryPercent)}}async updateBatteryAndSnapshot(){if(this.batteryUpdateInProgress)this.getBaichuanLogger().debug("Battery update already in progress, skipping");else{this.batteryUpdateInProgress=!0;try{const e=this.storageSettings.values.rtspChannel,t=this.storageSettings.values.batteryUpdateIntervalMinutes??10;this.getBaichuanLogger().log(`Force battery update interval started (every ${t} minutes)`);const s=await this.ensureClient();if(!s)return void this.getBaichuanLogger().warn("Failed to ensure client connection for battery update");let n=s.getSleepStatus({channel:e});if("sleeping"===n.state){this.getBaichuanLogger().log("Camera is sleeping, waking up for periodic update...");try{await s.wakeUp(e,{waitAfterWakeMs:2e3}),this.getBaichuanLogger().log("Wake command sent, waiting for camera to wake up...")}catch(e){return void this.getBaichuanLogger().warn("Failed to wake up camera:",e)}const t=3e4,r=Date.now();let i=!1;for(;Date.now()-r<t;)if(await new Promise((e=>setTimeout(e,1e3))),n=s.getSleepStatus({channel:e}),"awake"===n.state){i=!0,this.getBaichuanLogger().log("Camera is now awake"),this.sleeping=!1;break}if(!i)return void this.getBaichuanLogger().warn("Camera did not wake up within timeout, skipping update")}else"awake"===n.state&&(this.sleeping=!1);try{await this.updateBatteryInfo()}catch(e){this.getBaichuanLogger().warn("Failed to get battery info during periodic update:",e)}try{await this.alignAuxDevicesState()}catch(e){this.getBaichuanLogger().warn("Failed to align auxiliary devices state:",e)}try{this.forceNewSnapshot=!0,await this.takePicture(),this.getBaichuanLogger().log("Snapshot updated during periodic update")}catch(e){this.getBaichuanLogger().warn("Failed to update snapshot during periodic update:",e)}}catch(e){this.getBaichuanLogger().warn("Failed to update battery and snapshot",e)}finally{this.batteryUpdateInProgress=!1}}}async resetBaichuanClient(e){try{if(this.unsubscribedToEvents?.(),this.streamManager){const t=e?.message||e?.toString?.()||"connection reset";await this.streamManager.closeAllStreams(t)}await(this.baichuanApi?.close())}catch(e){this.getBaichuanLogger().warn("Error closing Baichuan client during reset",e)}finally{this.baichuanApi=void 0,this.connectionTime=void 0,this.ensureClientPromise=void 0,this.sleepCheckTimer&&(clearInterval(this.sleepCheckTimer),this.sleepCheckTimer=void 0),this.batteryUpdateTimer&&(clearInterval(this.batteryUpdateTimer),this.batteryUpdateTimer=void 0)}if(e){const t=e?.message||e?.toString?.()||e;this.getBaichuanLogger().warn(`Baichuan client reset requested: ${t}`)}}async withBaichuanClient(e){return e(await this.ensureClient())}async createStreamClient(){return await this.ensureClient()}}t.ReolinkNativeBatteryCamera=o},4417:function(e,t,s){"use strict";var n,r=this&&this.__createBinding||(Object.create?function(e,t,s,n){void 0===n&&(n=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,n,r)}:function(e,t,s,n){void 0===n&&(n=s),e[n]=t[s]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),A=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[t.length]=s);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s=n(e),A=0;A<s.length;A++)"default"!==s[A]&&r(t,e,s[A]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.ReolinkNativeCamera=t.b64ToMo=t.moToB64=void 0;const o=A(s(7562)),a=s(8799),c=s(5098);t.moToB64=async e=>{const t=await o.default.mediaManager.convertMediaObjectToBuffer(e,"image/jpeg");return t?.toString("base64")};t.b64ToMo=async e=>{const t=Buffer.from(e,"base64");return await o.default.mediaManager.createMediaObject(t,"image/jpeg")};class l extends a.CommonCameraMixin{constructor(e,t,s,n){super(e,t,{type:"regular",nvrDevice:s,multiFocalDevice:n}),this.plugin=t,this.initComplete=!1,this.periodicStarted=!1}async resetBaichuanClient(e){try{this.unsubscribedToEvents?.(),await(this.baichuanApi?.close())}catch(e){this.getBaichuanLogger().warn("Error closing Baichuan client during reset",e)}finally{this.baichuanApi=void 0,this.connectionTime=void 0,this.ensureClientPromise=void 0,this.passiveRefreshTimer&&(clearTimeout(this.passiveRefreshTimer),this.passiveRefreshTimer=void 0)}if(e){const t=e?.message||e?.toString?.()||e;this.getBaichuanLogger().warn(`Baichuan client reset requested: ${t}`)}}async init(){this.startPeriodicTasks(),await this.alignAuxDevicesState()}async createStreamClient(){const{ipAddress:e,username:t,password:s}=this.storageSettings.values,n=this.getBaichuanLogger(),r=this.getBaichuanDebugOptions(),i=await(0,c.createBaichuanApi)({inputs:{host:e,username:t,password:s,logger:n,debugOptions:r},transport:"tcp"});return await i.login(),i}async release(){return this.statusPollTimer&&clearInterval(this.statusPollTimer),this.passiveRefreshTimer&&(clearTimeout(this.passiveRefreshTimer),this.passiveRefreshTimer=void 0),this.resetBaichuanClient()}startPeriodicTasks(){this.periodicStarted||(this.periodicStarted=!0,this.getBaichuanLogger().log("Starting periodic tasks for regular camera"),this.statusPollTimer=setInterval((()=>{this.periodic10sTick().catch((()=>{}))}),1e4),this.getBaichuanLogger().log("Periodic tasks started: status poll every 10s"))}async periodic10sTick(){await this.ensureClient(),await this.alignAuxDevicesState()}async getDetectionInput(e,t){return null}async processEvents(e){const t=this.getBaichuanLogger();if(this.isEventDispatchEnabled()&&(this.storageSettings.values.dispatchEvents.includes("eventLogs")&&t.debug(`Events received: ${JSON.stringify(e)}`),this.shouldDispatchMotion()&&e.motion!==this.motionDetected&&(e.motion?(this.motionDetected=!0,this.motionTimeout&&clearTimeout(this.motionTimeout),this.motionTimeout=setTimeout((()=>this.motionDetected=!1),1e3*this.storageSettings.values.motionTimeout)):(this.motionDetected=!1,this.motionTimeout&&clearTimeout(this.motionTimeout))),this.shouldDispatchObjects()&&e.objects?.length)){const t={timestamp:Date.now(),detections:[]};for(const s of e.objects)t.detections.push({className:s,score:1});o.default.deviceManager.onDeviceEvent(this.nativeId,o.ScryptedInterface.ObjectDetector,t)}}async withBaichuanClient(e){return e(await this.ensureClient())}async takePicture(e){try{return this.withBaichuanRetry((async()=>{const e=await this.ensureClient(),t=await e.getSnapshot(this.storageSettings.values.rtspChannel);return await this.createMediaObject(t,"image/jpeg")}))}catch(e){throw this.getBaichuanLogger().error("Error taking snapshot",e),e}}async getPictureOptions(){return[]}async getOtherSettings(){return await this.getSettings()}showRtspUrlOverride(){return!1}async startIntercom(e){await this.intercom.start(e)}stopIntercom(){return this.intercom.stop()}}t.ReolinkNativeCamera=l},8799:function(e,t,s){"use strict";var n,r=this&&this.__createBinding||(Object.create?function(e,t,s,n){void 0===n&&(n=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,n,r)}:function(e,t,s,n){void 0===n&&(n=s),e[n]=t[s]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),A=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[t.length]=s);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s=n(e),A=0;A<s.length;A++)"default"!==s[A]&&r(t,e,s[A]);return i(t,e),t}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CommonCameraMixin=void 0;const a=A(s(7562)),c=s(6117),l=o(s(6928)),h=s(7077),g=s(5098),d=s(9560),u=s(5741),I=s(840),E=s(5050),p=s(6185);class C extends a.ScryptedDeviceBase{constructor(e,t){super(t),this.camera=e}async turnOff(){this.camera.getBaichuanLogger().log(`Siren toggle: turnOff (device=${this.nativeId})`),this.on=!1;try{await this.camera.setSirenEnabled(!1),this.camera.getBaichuanLogger().log(`Siren toggle: turnOff ok (device=${this.nativeId})`)}catch(e){throw this.camera.getBaichuanLogger().warn(`Siren toggle: turnOff failed (device=${this.nativeId})`,e),e}}async turnOn(){this.camera.getBaichuanLogger().log(`Siren toggle: turnOn (device=${this.nativeId})`),this.on=!0;try{await this.camera.setSirenEnabled(!0),this.camera.getBaichuanLogger().log(`Siren toggle: turnOn ok (device=${this.nativeId})`)}catch(e){throw this.camera.getBaichuanLogger().warn(`Siren toggle: turnOn failed (device=${this.nativeId})`,e),e}}}class B extends a.ScryptedDeviceBase{constructor(e,t){super(t),this.camera=e}async setBrightness(e){this.camera.getBaichuanLogger().log(`Floodlight toggle: setBrightness (device=${this.nativeId} brightness=${e})`),this.brightness=e;try{await this.camera.setFloodlightState(void 0,e),this.camera.getBaichuanLogger().log(`Floodlight toggle: setBrightness ok (device=${this.nativeId} brightness=${e})`)}catch(t){throw this.camera.getBaichuanLogger().warn(`Floodlight toggle: setBrightness failed (device=${this.nativeId} brightness=${e})`,t),t}}async turnOff(){this.camera.getBaichuanLogger().log(`Floodlight toggle: turnOff (device=${this.nativeId})`),this.on=!1;try{await this.camera.setFloodlightState(!1),this.camera.getBaichuanLogger().log(`Floodlight toggle: turnOff ok (device=${this.nativeId})`)}catch(e){throw this.camera.getBaichuanLogger().warn(`Floodlight toggle: turnOff failed (device=${this.nativeId})`,e),e}}async turnOn(){this.camera.getBaichuanLogger().log(`Floodlight toggle: turnOn (device=${this.nativeId})`),this.on=!0;try{await this.camera.setFloodlightState(!0),this.camera.getBaichuanLogger().log(`Floodlight toggle: turnOn ok (device=${this.nativeId})`)}catch(e){throw this.camera.getBaichuanLogger().warn(`Floodlight toggle: turnOn failed (device=${this.nativeId})`,e),e}}}class Q extends a.ScryptedDeviceBase{constructor(e,t){super(t),this.camera=e,this.storageSettings=new c.StorageSettings(this,{sensitive:{title:"PIR Sensitivity",description:"Detection sensitivity/threshold (higher = more sensitive)",type:"number",defaultValue:50,range:[0,100]},reduceAlarm:{title:"Reduce False Alarms",description:"Enable reduction of false alarm rate",type:"boolean",defaultValue:!1},interval:{title:"PIR Detection Interval",description:"Detection interval in seconds",type:"number",defaultValue:5,range:[1,60]}})}async getSettings(){return this.storageSettings.getSettings()}async putSetting(e,t){await this.storageSettings.putSetting(e,t);const s=this.camera.storageSettings.values.rtspChannel,n=this.on?1:0,r=this.storageSettings.values.sensitive,i=this.storageSettings.values.reduceAlarm?1:0,A=this.storageSettings.values.interval;await this.camera.withBaichuanRetry((async()=>{const e=await this.camera.ensureClient();await e.setPirInfo(s,{enable:n,sensitive:r,reduceAlarm:i,interval:A})}))}async turnOff(){this.on=!1,await this.updatePirSettings()}async turnOn(){this.on=!0,await this.updatePirSettings()}async updatePirSettings(){const e=this.camera.storageSettings.values.rtspChannel,t=this.on?1:0,s=this.storageSettings.values.sensitive,n=this.storageSettings.values.reduceAlarm?1:0,r=this.storageSettings.values.interval;await this.camera.withBaichuanRetry((async()=>{const i=await this.camera.ensureClient();await i.setPirInfo(e,{enable:t,sensitive:s,reduceAlarm:n,interval:r})}))}}class f extends h.BaseBaichuanClass{constructor(e,t,s){super(e),this.plugin=t,this.options=s,this.storageSettings=new c.StorageSettings(this,{ipAddress:{title:"IP Address",type:"string",onPut:async()=>{await this.credentialsChanged()}},debugEvents:{title:"Debug Events",type:"boolean",immediate:!0,hide:!0},username:{type:"string",title:"Username",onPut:async()=>{await this.credentialsChanged()}},password:{type:"password",title:"Password",onPut:async()=>{await this.credentialsChanged()}},rtspChannel:{type:"number",hide:!0,defaultValue:0},capabilities:{json:!0,hide:!0},multifocalInfo:{json:!0,hide:!0},uid:{title:"UID",description:"Reolink UID (required for battery cameras / BCUDP).",type:"string",hide:!0,onPut:async()=>{await this.credentialsChanged()}},mixinsSetup:{type:"boolean",hide:!0},dispatchEvents:{subgroup:"Advanced",title:"Dispatch Events",description:"Select which events to emit. Empty disables event subscription entirely.",multiple:!0,combobox:!0,immediate:!0,defaultValue:["motion","objects"],choices:["motion","objects"],onPut:async()=>{await this.subscribeToEvents()}},debugLogs:{subgroup:"Advanced",title:"Debug Logs",description:"Enable specific debug logs. Baichuan client logs require reconnect; event logs are immediate.",multiple:!0,combobox:!0,immediate:!0,defaultValue:[],choices:(0,d.getDebugLogChoices)(),onPut:async(e,t)=>{const s=this.getBaichuanLogger(),n=(0,d.getApiRelevantDebugLogs)(e||[]),r=(0,d.getApiRelevantDebugLogs)(t||[]),i=new Set(n),A=new Set(r);(i.size!==A.size||Array.from(i).some((e=>!A.has(e))))&&this.resetBaichuanClient&&(this.debugLogsResetTimeout&&(clearTimeout(this.debugLogsResetTimeout),this.debugLogsResetTimeout=void 0),this.debugLogsResetTimeout=setTimeout((async()=>{this.debugLogsResetTimeout=void 0;try{await this.resetBaichuanClient("debugLogs changed"),this.baichuanApi=void 0,this.ensureClientPromise=void 0,await this.ensureClient()}catch(e){s.warn("Failed to reset client after debug logs change",e)}}),2e3))}},motionTimeout:{subgroup:"Advanced",title:"Motion Timeout",defaultValue:20,type:"number"},cachedOsd:{multiple:!0,hide:!0,json:!0,defaultValue:[]},intercomBlocksPerPayload:{subgroup:"Advanced",title:"Intercom Blocks Per Payload",description:"Lower reduces latency (more packets). Typical: 1-4. Requires restarting talk session to take effect.",type:"number",defaultValue:1},presets:{subgroup:"PTZ",title:"Presets to enable",description:'PTZ Presets in the format "id=name". Where id is the PTZ Preset identifier and name is a friendly name.',multiple:!0,defaultValue:[],combobox:!0,hide:!0,onPut:async(e,t)=>{const s={...this.ptzCapabilities||{},presets:{}};for(const e of t){const[t,n]=e.split("=");s.presets[t]=n}this.ptzCapabilities=s},mapGet:()=>{const e=this.ptzCapabilities?.presets||{};return Object.entries(e).map((([e,t])=>e+"="+t))}},ptzMoveDurationMs:{title:"PTZ Move Duration (ms)",description:"How long a PTZ command moves before sending stop. Higher = more movement per click.",type:"number",defaultValue:300,subgroup:"PTZ",hide:!0},ptzZoomStep:{subgroup:"PTZ",title:"PTZ Zoom Step",description:"How much to change zoom per zoom command (in zoom factor units, where 1.0 is normal).",type:"number",defaultValue:.1,hide:!0},ptzCreatePreset:{subgroup:"PTZ",title:"Create Preset",description:"Enter a name and press Save to create a new PTZ preset at the current position.",type:"string",placeholder:"e.g. Door",defaultValue:"",hide:!0,onPut:async(e,t)=>{const s=String(t??"").trim();if(!s)return void(""!==String(t??"")&&(this.storageSettings.values.ptzCreatePreset=""));const n=this.getBaichuanLogger();n.log(`PTZ presets: create preset requested (name=${s})`);const r=await this.withBaichuanRetry((async()=>{if(await this.ensureClient(),!this.ptzPresets)throw new Error("PTZ presets not available");return await this.ptzPresets.createPtzPreset(s)})),i=`${r.id}=${r.name}`;this.storageSettings.values.ptzSelectedPreset=i,this.storageSettings.values.ptzCreatePreset="",n.log(`PTZ presets: created preset id=${r.id} name=${r.name}`)}},ptzSelectedPreset:{subgroup:"PTZ",title:"Selected Preset",description:'Select the preset to update or delete. Format: "id=name".',type:"string",combobox:!1,immediate:!0,hide:!0},ptzUpdateSelectedPreset:{subgroup:"PTZ",title:"Update Selected Preset Position",description:"Overwrite the selected preset with the current PTZ position.",type:"button",immediate:!0,hide:!0,onPut:async()=>{const e=this.getSelectedPresetId();if(void 0===e)throw new Error("No preset selected");const t=this.getBaichuanLogger();t.log(`PTZ presets: update position requested (presetId=${e})`),await this.withBaichuanRetry((async()=>(await this.ensureClient(),await this.ptzPresets.updatePtzPresetToCurrentPosition(e)))),t.log(`PTZ presets: update position ok (presetId=${e})`)}},ptzDeleteSelectedPreset:{subgroup:"PTZ",title:"Delete Selected Preset",description:"Delete the selected preset (firmware dependent).",type:"button",immediate:!0,hide:!0,onPut:async()=>{const e=this.getSelectedPresetId();if(void 0===e)throw new Error("No preset selected");const t=this.getBaichuanLogger();t.log(`PTZ presets: delete requested (presetId=${e})`),await this.withBaichuanRetry((async()=>(await this.ensureClient(),await this.ptzPresets.deletePtzPreset(e)))),this.storageSettings.values.ptzSelectedPreset="",t.log(`PTZ presets: delete ok (presetId=${e})`)}},batteryUpdateIntervalMinutes:{title:"Battery Update Interval (minutes)",subgroup:"Advanced",description:"How often to wake up the camera and update battery status and snapshot (default: 60 minutes).",type:"number",defaultValue:60,hide:!0},lowThresholdBatteryRecording:{title:"Low Threshold Battery Recording (%)",subgroup:"Recording",description:"Battery level threshold below which recording is disabled (default: 15%).",type:"number",defaultValue:15,hide:!0},highThresholdBatteryRecording:{title:"High Threshold Battery Recording (%)",subgroup:"Recording",description:"Battery level threshold above which recording is enabled (default: 35%).",type:"number",defaultValue:35,hide:!0},diagnosticsOutputPath:{title:"Diagnostics Output Path",subgroup:"Diagnostics",description:"Directory where diagnostics files will be saved (default: plugin volume).",type:"string",defaultValue:l.default.join(process.env.SCRYPTED_PLUGIN_VOLUME,"diagnostics",this.name)},diagnosticsRun:{subgroup:"Diagnostics",title:"Run Diagnostics",description:"Run all diagnostics and save results to the output path.",type:"button",immediate:!0,onPut:async()=>{await this.runDiagnostics()}}}),this.ptzPresets=new I.ReolinkPtzPresets(this),this.refreshingState=!1,this.classes=[],this.presets=[],this.fetchingStreams=!1,this.lastNetPortCacheAttempt=0,this.netPortCacheBackoffMs=5e3,this.onSimpleEvent=e=>{const t=this.getBaichuanLogger();try{const t=this.getBaichuanLogger();if(t.debug(`Baichuan event: ${JSON.stringify(e)}`),!this.isEventDispatchEnabled())return void t.debug("Event dispatch is disabled, ignoring event");const s=this.storageSettings.values.rtspChannel;if(void 0!==e?.channel&&e.channel!==s)return void t.error(`Event channel ${e.channel} does not match camera channel ${s}, ignoring`);const n=[];let r=!1;switch(e?.type){case"motion":r=!0;break;case"doorbell":this.handleDoorbellEvent(),r=!0;break;case"people":case"vehicle":case"animal":case"face":case"package":case"other":this.shouldDispatchObjects()&&n.push(e.type),r=!0;break;default:return void t.error(`Unknown event type: ${e?.type}`)}this.processEvents({motion:r,objects:n}).catch((e=>{t.warn("Error processing events",e)}))}catch(e){t.warn("Error in onSimpleEvent handler",e)}},this.nvrDevice=s.nvrDevice,this.multiFocalDevice=s.multiFocalDevice,this.thisDevice=a.default.systemManager.getDeviceById(this.id);const n="battery"===s.type||"multi-focal-battery"===s.type;this.protocol=n?"udp":"tcp",setTimeout((async()=>{await this.parentInit()}),2e3)}getConnectionConfig(){const{ipAddress:e,username:t,password:s,uid:n}=this.storageSettings.values,r=this.getBaichuanDebugOptions(),i="udp"===this.protocol?(0,g.normalizeUid)(n):void 0;if("udp"===this.protocol&&!i)throw new Error("UID is required for battery cameras (BCUDP)");return{host:e,username:t,password:s,uid:i,transport:this.protocol,logger:this.console,debugOptions:r}}getConnectionCallbacks(){return{onError:void 0,onClose:async()=>{"battery"===this.options.type||setTimeout((async()=>{try{await this.subscribeToEvents()}catch(e){this.getBaichuanLogger().warn("Failed to resubscribe to events after reconnection",e)}}),1e3)},onSimpleEvent:this.onSimpleEvent,getEventSubscriptionEnabled:()=>this.isEventDispatchEnabled?.()??!1}}isDebugEnabled(){return this.isEventLogsEnabled()}getDeviceName(){return this.name||"Camera"}async withBaichuanRetry(e){if("udp"===this.protocol)return await e();try{return await e()}catch(t){if(!this.isRecoverableBaichuanError(t))throw t;await this.resetBaichuanClient(t);try{return await e()}catch(e){throw e}}}async runDiagnostics(){const e=this.getBaichuanLogger(),t=this.storageSettings.values.diagnosticsOutputPath||process.env.SCRYPTED_PLUGIN_VOLUME||"";if(!t)throw new Error("Diagnostics output path is required");const s=this.storageSettings.values.rtspChannel||0,n={kinds:["native"],profiles:["main","ext","sub"]};e.log(`Starting diagnostics with parameters: outDir=${t}, channel=${s}, durationSeconds=15, selection=${JSON.stringify(n)}`);try{const r=await this.ensureClient(),i=await r.runAllDiagnosticsConsecutively({outDir:t,channel:s,durationSeconds:15,selection:n});e.log(`Diagnostics completed successfully. Output directory: ${i.runDir}`),e.log(`Diagnostics file: ${i.diagnosticsPath}`),e.log(`Streams directory: ${i.streamsDir}`)}catch(t){throw e.error("Failed to run diagnostics",t),t}}async onBeforeCleanup(){if(this.onSimpleEvent&&this.baichuanApi)try{this.baichuanApi.offSimpleEvent(this.onSimpleEvent)}catch{}}createStreamClient(){throw new Error("Method not implemented.")}getAbilities(){return this.multiFocalDevice?this.multiFocalDevice.getInterfaces(this.storageSettings.values.rtspChannel).capabilities:this.storageSettings.values.capabilities}getBaichuanDebugOptions(){const e=this.storageSettings.values.debugLogs||[];return(0,d.convertDebugLogsToApiOptions)(e)}isRecoverableBaichuanError(e){const t=e?.message||e?.toString?.()||"";return"string"==typeof t&&(t.includes("Baichuan socket closed")||t.includes("Baichuan UDP stream closed")||t.includes("Baichuan TCP socket is not connected")||t.includes("socket hang up")||t.includes("ECONNRESET")||t.includes("EPIPE"))}updatePtzCaps(){const{hasPan:e,hasTilt:t,hasZoom:s}=this.getAbilities();this.ptzCapabilities={...this.ptzCapabilities,pan:e,tilt:t,zoom:s}}unsubscribedToEvents(){this.unsubscribeFromEvents().catch((()=>{})),this.motionDetected&&(this.motionDetected=!1)}async subscribeToEvents(){if(this.nvrDevice||this.multiFocalDevice)return;const e=this.getBaichuanLogger(),t=Array.from(this.getDispatchEventsSelection?.()??new Set).sort(),s=t.length>0;e.debug(`subscribeToEvents called: enabled=${s}, selection=[${t.join(", ")}], protocol=${this.protocol}`),this.unsubscribedToEvents();if(t.includes("motion")||(this.motionTimeout&&clearTimeout(this.motionTimeout),this.motionDetected=!1),!s)return e.log("Event subscription disabled, unsubscribing"),this.doorbellBinaryTimeout&&(clearTimeout(this.doorbellBinaryTimeout),this.doorbellBinaryTimeout=void 0),void(this.binaryState=!1);const n=await this.ensureClient();try{await n.onSimpleEvent(this.onSimpleEvent),e.log(`Subscribed to events (${t.join(", ")}) on ${this.protocol} connection`)}catch(t){return void e.warn("Failed to attach Baichuan event handler",t)}}async getVideoTextOverlays(){const e=await this.ensureClient(),t=this.storageSettings.values.rtspChannel;let s=this.storageSettings.values.cachedOsd;return s?.length||(s=await e.getOsd(t),this.storageSettings.values.cachedOsd=s),{osdChannel:{text:s?.osdChannel?.enable?s.osdChannel.name:void 0},osdTime:{text:!!s?.osdTime?.enable,readonly:!0}}}async setVideoTextOverlay(e,t){const s=await this.ensureClient(),n=this.storageSettings.values.rtspChannel,r=await s.getOsd(n);if("osdChannel"===e){const e="string"==typeof t?.text?t.text.trim():"",s=!!e||!0===t?.text;r.osdChannel.enable=s?1:0,s&&(r.osdChannel.name=e||r.osdChannel.name||this.name||"Camera")}else{if("osdTime"!==e)throw new Error("unknown overlay: "+e);r.osdTime.enable=t?.text?1:0}await s.setOsd(n,r)}async ptzCommand(e){const t=this.getBaichuanLogger(),s=await this.ensureClient();if(!s)return;const n=this.storageSettings.values.rtspChannel,r=e.preset;if(null!=r){const e=Number(r);return Number.isFinite(e)?void(this.ptzPresets?await this.ptzPresets.moveToPreset(e):t.warn("PTZ presets not available")):void t.warn(`Invalid PTZ preset id: ${r}`)}let i="start",A="Left";if(void 0!==e.pan)0===e.pan?(i="stop",A="Left"):(A=e.pan>0?"Right":"Left",i="start");else if(void 0!==e.tilt)0===e.tilt?(i="stop",A="Up"):(A=e.tilt>0?"Up":"Down",i="start");else if(void 0!==e.zoom){const r=Number(e.zoom);if(!Number.isFinite(r)||0===r)return;const i=Number(this.storageSettings.values.ptzZoomStep);if(!Number.isFinite(i)||i<=0)return void t.warn("Invalid PTZ zoom step, using default 0.1");const A=await s.getZoomFocus(n);if(!A?.zoom)return void t.warn("Zoom command requested but camera did not report zoom support.");const o=(A.zoom.curPos??1e3)/1e3,a=(A.zoom.minPos??1e3)/1e3,c=(A.zoom.maxPos??1e3)/1e3,l=i,h=r>0?1:-1,g=Math.min(c,Math.max(a,o+h*l));return void await s.zoomToFactor(n,g)}const o={action:i,command:A,speed:"number"==typeof e.speed?e.speed:32,autoStopMs:Number(this.storageSettings.values.ptzMoveDurationMs)||500};await s.ptz(n,o)}async getObjectTypes(){return{classes:this.classes}}async getDetectionInput(e,t){return null}getDispatchEventsSelection(){return new Set(this.storageSettings.values.dispatchEvents)}isEventDispatchEnabled(){return this.getDispatchEventsSelection().size>0}shouldDispatchMotion(){return this.getDispatchEventsSelection().has("motion")}shouldDispatchObjects(){return this.getDispatchEventsSelection().has("objects")}async processEvents(e){if(!(this.isEventDispatchEnabled?.()??!0))return;const t=this.getDispatchEventsSelection?.()??new Set(["motion","objects"]),s=t.has("motion"),n=t.has("objects");if(s&&void 0!==e.motion){const t=e.motion;if(t!==this.motionDetected)if(this.motionDetected=t,t){this.motionTimeout&&clearTimeout(this.motionTimeout);const e=1e3*(this.storageSettings.values.motionTimeout||30);this.motionTimeout=setTimeout((()=>{this.motionDetected=!1}),e)}else this.motionTimeout&&clearTimeout(this.motionTimeout)}if(n&&e.objects?.length){const t={timestamp:Date.now(),detections:[]};for(const s of e.objects)t.detections.push({className:s,score:1});this.nativeId&&a.default.deviceManager.onDeviceEvent(this.nativeId,a.ScryptedInterface.ObjectDetector,t)}}isEventLogsEnabled(){return(this.storageSettings.values.debugLogs||[]).includes(d.DebugLogDisplayNames[d.DebugLogOption.EventLogs])}handleDoorbellEvent(){this.doorbellBinaryTimeout||(this.binaryState=!0,this.doorbellBinaryTimeout=setTimeout((()=>{this.binaryState=!1,this.doorbellBinaryTimeout=void 0}),5e3))}clearDoorbellBinary(){this.doorbellBinaryTimeout&&(clearTimeout(this.doorbellBinaryTimeout),this.doorbellBinaryTimeout=void 0),this.binaryState=!1}async reportDevices(){const e=this.getAbilities(),{hasSiren:t,hasFloodlight:s,hasPir:n}=e;if(t){const e=`${this.nativeId}${p.sirenSuffix}`,t={providerNativeId:this.nativeId,name:`${this.name} Siren`,nativeId:e,info:{...this.info||{}},interfaces:[a.ScryptedInterface.OnOff,a.ScryptedInterface.Settings],type:a.ScryptedDeviceType.Siren};a.default.deviceManager.onDeviceDiscovered(t)}if(s){const e=`${this.nativeId}${p.floodlightSuffix}`,t={providerNativeId:this.nativeId,name:`${this.name} Floodlight`,nativeId:e,info:{...this.info||{}},interfaces:[a.ScryptedInterface.OnOff,a.ScryptedInterface.Settings],type:a.ScryptedDeviceType.Light};a.default.deviceManager.onDeviceDiscovered(t)}if(n){const e=`${this.nativeId}${p.pirSuffix}`,t={providerNativeId:this.nativeId,name:`${this.name} PIR`,nativeId:e,info:{...this.info||{}},interfaces:[a.ScryptedInterface.OnOff,a.ScryptedInterface.Settings],type:a.ScryptedDeviceType.Switch};a.default.deviceManager.onDeviceDiscovered(t)}}async getSettings(){return await this.storageSettings.getSettings()}async putSetting(e,t){await this.storageSettings.putSetting(e,t)}async startIntercom(e){if(!this.intercom)throw new Error("Intercom not initialized");await this.intercom.start(e)}async stopIntercom(){if(this.intercom)return await this.intercom.stop();throw new Error("Intercom not initialized")}async updateDeviceInfo(){const e=this.getBaichuanLogger();if(this.multiFocalDevice)return void(this.info=this.multiFocalDevice.info);const{ipAddress:t,rtspChannel:s}=this.storageSettings.values;try{const n=await this.ensureClient(),r=await n.getInfo(this.nvrDevice||this.multiFocalDevice?s:void 0);await(0,p.updateDeviceInfo)({device:this,ipAddress:t,deviceData:r,logger:e})}catch(t){e.warn("Failed to fetch device info",t)}}async getDevice(e){return e.endsWith(p.sirenSuffix)?(this.siren||=new C(this,e),this.siren):e.endsWith(p.floodlightSuffix)?(this.floodlight||=new B(this,e),this.floodlight):e.endsWith(p.pirSuffix)?(this.pirSensor||=new Q(this,e),this.pirSensor):void 0}async releaseDevice(e,t){t.endsWith(p.sirenSuffix)?this.siren=void 0:t.endsWith(p.floodlightSuffix)?this.floodlight=void 0:t.endsWith(p.pirSuffix)&&(this.pirSensor=void 0)}async setSirenEnabled(e){const t=this.storageSettings.values.rtspChannel;await this.withBaichuanRetry((async()=>{const s=await this.ensureClient();return await s.setSiren(t,e)}))}async setFloodlightState(e,t){const s=this.storageSettings.values.rtspChannel;await this.withBaichuanRetry((async()=>{const n=await this.ensureClient();return await n.setWhiteLedState(s,e,t)}))}async setPirEnabled(e){const t=this.storageSettings.values.rtspChannel;let s,n,r;this.pirSensor&&(s=this.pirSensor.storageSettings.values.sensitive,n=this.pirSensor.storageSettings.values.reduceAlarm?1:0,r=this.pirSensor.storageSettings.values.interval),await this.withBaichuanRetry((async()=>{const i=await this.ensureClient();return await i.setPirInfo(t,{enable:e?1:0,...void 0!==s?{sensitive:s}:{},...void 0!==n?{reduceAlarm:n}:{},...void 0!==r?{interval:r}:{}})}))}async alignAuxDevicesState(){const e=this.getBaichuanLogger(),t=this.baichuanApi;if(!t)return;const s=this.storageSettings.values.rtspChannel,{hasSiren:n,hasFloodlight:r,hasPir:i}=this.getAbilities();try{if(n&&this.siren)try{const e=await t.getSiren(s);this.siren.on=e.enabled}catch(t){e.debug("Failed to align siren state",t)}if(r&&this.floodlight)try{const e=await t.getWhiteLedState(s);this.floodlight.on=!!e.enabled,void 0!==e.brightness&&(this.floodlight.brightness=e.brightness)}catch(t){e.debug("Failed to align floodlight state",t)}if(i&&this.pirSensor)try{const e=await t.getPirInfo(s);this.pirSensor.on=e.enabled,e.state&&(void 0!==e.state.sensitive&&(this.pirSensor.storageSettings.values.sensitive=e.state.sensitive),void 0!==e.state.reduceAlarm&&(this.pirSensor.storageSettings.values.reduceAlarm=!!e.state.reduceAlarm),void 0!==e.state.interval&&(this.pirSensor.storageSettings.values.interval=e.state.interval))}catch(t){e.debug("Failed to align PIR state",t)}}catch(t){e.debug("Failed to align auxiliary devices state",t)}}addRtspCredentials(e){const t=this.getBaichuanLogger(),{username:s,password:n}=this.storageSettings.values;if(!s)return e;try{const t=new URL(e);if("rtmp:"===t.protocol){const e=t.searchParams;e.set("user",s),e.set("password",n||"")}else t.username=s,t.password=n||"";return t.toString()}catch(s){return t.warn("Failed to parse URL for credentials",s),e}}async getVideoStreamOptions(){const e=this.getBaichuanLogger();if(this.cachedVideoStreamOptions?.length)return this.cachedVideoStreamOptions;if(this.fetchingStreams)return[];this.fetchingStreams=!0;let t=[];const s=await this.ensureClient(),{rtspChannel:n}=this.storageSettings.values;try{const{nativeStreams:e,rtmpStreams:r,rtspStreams:i}=await s.buildVideoStreamOptions(n);let A=[];A=this.nvrDevice&&"HOMEHUB"===this.nvrDevice.info.model?[...e,...i,...r]:[...i,...r,...e];for(const e of A){const{id:s,metadata:n,url:r,name:i,container:A}=e,o=String(n.videoEncType||"").includes("264")?"h264":String(n.videoEncType||"").includes("265")?"h265":String(n.videoEncType||"").toLowerCase();t.push({id:s,name:i,url:r,container:A,video:{codec:o,width:n.width,height:n.height}})}}catch(t){this.isRecoverableBaichuanError?.(t)||e.warn("Failed to build RTSP/RTMP stream options, falling back to Native",t)}if(t.length)return e.log("Fetched video stream options",t.map((e=>e.name)).join(", ")),e.debug(JSON.stringify(t)),this.cachedVideoStreamOptions=t,t;this.fetchingStreams=!1}async getVideoStream(e){if(!e)throw new Error("video streams not set up or no longer exists.");const t=await this.getVideoStreamOptions(),s=(0,E.selectStreamOption)(t,e);if(s.url&&("rtsp"===s.container||"rtmp"===s.container)){const e=this.addRtspCredentials(s.url),t={container:s.container,url:e,mediaStreamOptions:s};return await this.createMediaObject(t,a.ScryptedMimeTypes.MediaStreamUrl)}if(!this.streamManager)throw new Error("StreamManager not initialized");const n=(0,E.parseStreamProfileFromId)(s.id)||"main",r=this.storageSettings.values.rtspChannel,i=`${r}_${n}`,A=(0,E.expectedVideoTypeFromUrlMediaStreamOptions)(s);return await this.withBaichuanRetry((async()=>await(0,E.createRfc4571MediaObjectFromStreamManager)({streamManager:this.streamManager,channel:r,profile:n,streamKey:i,expectedVideoType:A,selected:s,sourceId:this.id})))}async ensureClient(){return this.nvrDevice?await this.nvrDevice.ensureBaichuanClient():this.multiFocalDevice?await this.multiFocalDevice.ensureBaichuanClient():await this.ensureBaichuanClient()}async credentialsChanged(){this.cachedVideoStreamOptions=void 0}getSelectedPresetId(){const e=this.storageSettings.values.ptzSelectedPreset;if(!e)return;const t=e.includes("=")?e.split("=")[0]:e,s=Number(t);return Number.isFinite(s)?s:void 0}async refreshDeviceState(){if(this.refreshingState)return;this.refreshingState=!0;const e=this.getBaichuanLogger(),t=this.storageSettings.values.rtspChannel;try{const{capabilities:s,abilities:n,support:r,presets:i,objects:A}=await this.withBaichuanRetry((async()=>{const e=await this.ensureClient();return await e.getDeviceCapabilities(t)}));this.classes=A,this.presets=i,this.ptzPresets.setCachedPtzPresets(i);try{const{interfaces:t,type:n}=(0,p.getDeviceInterfaces)({capabilities:s,logger:this.console}),r={nativeId:this.nativeId,providerNativeId:this.nvrDevice?.nativeId??this.multiFocalDevice?.nativeId??this.plugin?.nativeId,name:this.name,interfaces:t,type:n,info:this.info};await a.default.deviceManager.onDeviceDiscovered(r),e.log("Device interfaces updated"),e.debug(`${JSON.stringify(r)}`)}catch(t){e.error("Failed to update device interfaces",t)}e.log(`Refreshed device capabilities: ${JSON.stringify(s)}`),e.debug(`Refreshed device capabilities: ${JSON.stringify({abilities:n,support:r,presets:i,objects:A})}`)}catch(t){e.error("Failed to refresh abilities",t)}this.refreshingState=!1}async parentInit(){const e=this.getBaichuanLogger();try{await this.ensureClient(),await this.updateDeviceInfo()}catch(t){e.warn("Failed to update device info during init",t)}if(!this.multiFocalDevice)try{await this.refreshDeviceState(),await this.reportDevices()}catch(t){e.warn("Failed to connect/refresh during init",t)}const{username:t,password:s}=this.storageSettings.values,n="regular"===this.options.type||"battery"===this.options.type,r="battery"===this.options.type,i="multi-focal-battery"===this.options.type,A=r||i;if(this.storageSettings.settings.uid.hide=!A,this.storageSettings.settings.batteryUpdateIntervalMinutes.hide=!A,this.storageSettings.settings.lowThresholdBatteryRecording.hide=!A,this.storageSettings.settings.highThresholdBatteryRecording.hide=!A,r&&!this.storageSettings.values.mixinsSetup)try{const t=a.default.systemManager.getDeviceById(this.id);t&&(e.log("Disabling prebuffer and snapshots from prebuffer"),await t.putSetting("prebuffer:enabledStreams","[]"),await t.putSetting("snapshot:snapshotsFromPrebuffer","Disabled"),this.storageSettings.values.mixinsSetup=!0)}catch(t){e.warn("Failed to setup mixins during init",t)}try{await this.subscribeToEvents()}catch(t){e.warn("Failed to subscribe to Baichuan events",t)}if(n){this.streamManager=new E.StreamManager({createStreamClient:()=>this.createStreamClient(),getLogger:()=>e,credentials:{username:t,password:s},sharedConnection:A});const{hasIntercom:n,hasPtz:r}=this.getAbilities();if(n&&(this.intercom=new u.ReolinkBaichuanIntercom(this)),r){const e=(this.presets||[]).map((e=>e.id+"="+e.name));this.storageSettings.settings.presets.choices=e,this.storageSettings.settings.ptzSelectedPreset.choices=e,this.storageSettings.settings.presets.hide=!1,this.storageSettings.settings.ptzMoveDurationMs.hide=!1,this.storageSettings.settings.ptzZoomStep.hide=!1,this.storageSettings.settings.ptzCreatePreset.hide=!1,this.storageSettings.settings.ptzSelectedPreset.hide=!1,this.storageSettings.settings.ptzUpdateSelectedPreset.hide=!1,this.storageSettings.settings.ptzDeleteSelectedPreset.hide=!1,this.updatePtzCaps()}}(this.nvrDevice||this.multiFocalDevice)&&(this.storageSettings.settings.username.hide=!0,this.storageSettings.settings.password.hide=!0,this.storageSettings.settings.ipAddress.hide=!0,this.storageSettings.settings.uid.hide=!0,this.storageSettings.settings.username.defaultValue=this.nvrDevice.storageSettings.values.username,this.storageSettings.settings.password.defaultValue=this.nvrDevice.storageSettings.values.password,this.storageSettings.settings.ipAddress.defaultValue=this.nvrDevice.storageSettings.values.ipAddress),await this.init(),this.initComplete=!0}}t.CommonCameraMixin=f},5098:(e,t,s)=>{"use strict";function n(e){const t=e?.trim();return t||void 0}Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeUid=n,t.createBaichuanApi=async function(e){const{inputs:t,transport:r}=e,{logger:i}=t,{ReolinkBaichuanApi:A}=await Promise.resolve().then(s.bind(s,4157)),o={host:t.host,username:t.username,password:t.password,logger:i,debugOptions:t.debugOptions??{}},a=e=>{try{e.client.on("error",(e=>{if(!i)return;const s=e?.message||e?.toString?.()||String(e);"string"==typeof s&&(s.includes("Baichuan socket closed")||s.includes("Baichuan UDP stream closed")||s.includes("Not running"))||i.error(`[BaichuanClient] error (${r}) ${t.host}: ${s}`)})),e.client.on("close",(()=>{}))}catch{}};if("tcp"===r){const e=new A({...o,transport:"tcp"});return a(e),e}const c=n(t.uid);if(!c)throw new Error("UID is required for battery cameras (BCUDP)");const l=new A({...o,transport:"udp",uid:c,idleDisconnect:!0});return a(l),l}},9560:(e,t)=>{"use strict";var s;function n(e){return{[s.General]:"general",[s.DebugRtsp]:"debugRtsp",[s.TraceStream]:"traceStream",[s.TraceTalk]:"traceTalk",[s.TraceEvents]:"traceEvents",[s.DebugH264]:"debugH264",[s.DebugParamSets]:"debugParamSets",[s.EventLogs]:null,[s.BatteryInfo]:null}[e]}Object.defineProperty(t,"__esModule",{value:!0}),t.DebugLogDisplayNames=t.DebugLogOption=void 0,t.mapDebugLogToApiOption=n,t.convertDebugLogsToApiOptions=function(e){const s={},r=new Set(e);for(const[e,i]of Object.entries(t.DebugLogDisplayNames))if(r.has(i)){const t=n(e);t&&(s[t]=!0)}return Object.keys(s).length>0?s:void 0},t.getApiRelevantDebugLogs=function(e){return e.filter((e=>null!==n(e)))},t.getDebugLogChoices=function(){return Object.values(s).map((e=>`${t.DebugLogDisplayNames[e]}`))},function(e){e.General="general",e.DebugRtsp="debugRtsp",e.TraceStream="traceStream",e.TraceTalk="traceTalk",e.TraceEvents="traceEvents",e.DebugH264="debugH264",e.DebugParamSets="debugParamSets",e.EventLogs="eventLogs",e.BatteryInfo="batteryInfo"}(s||(t.DebugLogOption=s={})),t.DebugLogDisplayNames={[s.General]:"General",[s.DebugRtsp]:"RTSP",[s.TraceStream]:"Trace stream",[s.TraceTalk]:"Trace talk",[s.TraceEvents]:"Trace events XML",[s.DebugH264]:"H264",[s.DebugParamSets]:"Video param sets",[s.EventLogs]:"Object detection events",[s.BatteryInfo]:"Battery info update"}},5741:function(e,t,s){"use strict";var n,r=this&&this.__createBinding||(Object.create?function(e,t,s,n){void 0===n&&(n=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,n,r)}:function(e,t,s,n){void 0===n&&(n=s),e[n]=t[s]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),A=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[t.length]=s);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s=n(e),A=0;A<s.length;A++)"default"!==s[A]&&r(t,e,s[A]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.ReolinkBaichuanIntercom=void 0;const o=A(s(7562)),a=s(1421);t.ReolinkBaichuanIntercom=class{constructor(e){this.camera=e,this.loggedCodecInfo=!1,this.maxBacklogMs=40,this.sendChain=Promise.resolve(),this.pcmBuffer=Buffer.alloc(0)}get blocksPerPayload(){return Math.max(1,Math.min(8,this.camera.storageSettings.values.intercomBlocksPerPayload??1))}async start(e){const t=this.camera.getBaichuanLogger(),s=await o.default.mediaManager.convertMediaObjectToJSON(e,o.ScryptedMimeTypes.FFmpegInput);await this.stop();const n=this.camera.storageSettings.values.rtspChannel;if(!this.loggedCodecInfo){this.loggedCodecInfo=!0;try{const e=await this.camera.ensureClient(),s=await e.getTalkAbility(n),r=s.audioConfigList?.map((e=>({audioType:e.audioType,sampleRate:e.sampleRate,samplePrecision:e.samplePrecision,lengthPerEncoder:e.lengthPerEncoder,soundTrack:e.soundTrack})));t.log("Intercom TalkAbility",{channel:n,duplexList:s.duplexList,audioStreamModeList:s.audioStreamModeList,audioConfigList:r})}catch(e){t.warn("Intercom: unable to fetch TalkAbility",e)}}const r=await this.camera.withBaichuanRetry((async()=>{const e=await this.camera.ensureClient();if("battery"===this.camera.options?.type)try{"sleeping"===e.getSleepStatus({channel:n}).state&&(t.log("Camera is sleeping, waking up for intercom..."),await e.wakeUp(n,{waitAfterWakeMs:2e3}),await new Promise((e=>setTimeout(e,1e3))))}catch(e){t.debug("Failed to check/wake camera for intercom, proceeding anyway",e)}return await e.createTalkSession(n,{blocksPerPayload:this.blocksPerPayload})}));this.session=r,this.pcmBuffer=Buffer.alloc(0),this.sendChain=Promise.resolve();const{audioConfig:i,blockSize:A,fullBlockSize:c}=r.info,l=i.sampleRate,h=2*A+1,g=2*h;if(this.maxBacklogBytes=Math.max(g,Math.floor(this.maxBacklogMs/1e3*l*1*2)),!Number.isFinite(l)||l<=0)throw await this.stop(),new Error(`Invalid talk sampleRate: ${l}`);if(!Number.isFinite(A)||A<=0||!Number.isFinite(c)||c!==A+4)throw await this.stop(),new Error(`Invalid talk block sizes: blockSize=${A} fullBlockSize=${c}`);t.log("Starting intercom (baichuan/native-api flow)",{channel:n,audioType:i.audioType,sampleRate:i.sampleRate,samplePrecision:i.samplePrecision,lengthPerEncoder:i.lengthPerEncoder,soundTrack:i.soundTrack,blockSize:A,fullBlockSize:c,samplesPerBlock:h,bytesNeeded:g,maxBacklogMs:this.maxBacklogMs,maxBacklogBytes:this.maxBacklogBytes,blocksPerPayload:this.blocksPerPayload});const d=this.buildFfmpegPcmArgs(s,{sampleRate:l,channels:1});t.log("Intercom ffmpeg decode args",d);const u=(0,a.spawn)("ffmpeg",d,{stdio:["ignore","pipe","pipe"]});if(this.session!==r){try{u.kill("SIGKILL")}catch{}return}this.ffmpeg=u,u.stdout.on("data",(e=>{this.session===r&&e?.length&&this.enqueuePcm(r,e,g,A)}));let I=0;u.stderr.on("data",(e=>{I++<12&&t.warn("Intercom ffmpeg",e.toString().trim())})),u.on("exit",((e,s)=>{t.warn(`Intercom ffmpeg exited code=${e} signal=${s}`),this.stop().catch((()=>{}))})),t.log("Intercom started (ffmpeg decode -> PCM -> IMA ADPCM)")}stop(){return this.stopping||(this.stopping=(async()=>{const e=this.camera.getBaichuanLogger(),t=this.ffmpeg;this.ffmpeg=void 0;const s=this.session;this.session=void 0,this.pcmBuffer=Buffer.alloc(0);const n=async e=>new Promise((t=>setTimeout(t,e)));if(t&&null==t.exitCode){try{t.kill("SIGKILL")}catch{}try{await Promise.race([new Promise((e=>t.once("exit",(()=>e())))),n(1e3)])}catch{}}try{await Promise.race([this.sendChain,n(250)])}catch{}if(this.sendChain=Promise.resolve(),s)try{await Promise.race([s.stop(),n(2e3)])}catch(t){e.warn("Intercom session stop error",t)}})().finally((()=>{this.stopping=void 0}))),this.stopping}clamp16(e){return e>32767?32767:e<-32768?-32768:0|e}enqueuePcm(e,t,s,n){const r=this.camera.getBaichuanLogger();this.sendChain=this.sendChain.then((async()=>{if(this.session!==e)return;this.pcmBuffer=this.pcmBuffer.length?Buffer.concat([this.pcmBuffer,t]):t;const r=this.maxBacklogBytes??s;if(this.pcmBuffer.length>r){const e=r-r%2;this.pcmBuffer=this.pcmBuffer.subarray(this.pcmBuffer.length-e)}for(;this.pcmBuffer.length>=s;){const t=this.pcmBuffer.subarray(0,s);this.pcmBuffer=this.pcmBuffer.subarray(s);const r=new Int16Array(t.buffer,t.byteOffset,t.length/2),i=this.encodeImaAdpcm(r,n);await e.sendAudio(i)}})).catch((e=>{r.warn("Intercom PCM->ADPCM pipeline error",e)}))}buildFfmpegPcmArgs(e,t){const s=e.inputArguments??[],n=[];let r;for(let e=0;e<s.length;e++){const t=s[e];if("-i"===t){const t=s[e+1];if("string"==typeof t){r||(r=t),e++;continue}}n.push(t)}const i=r??e.url;if(!i)throw new Error("FFmpegInput missing url/input");return[...n,"-i",i,"-map","0:a:0?","-fflags","nobuffer","-flags","low_delay","-flush_packets","1","-vn","-sn","-dn","-acodec","pcm_s16le","-ar",t.sampleRate.toString(),"-ac",t.channels.toString(),"-f","s16le","pipe:1"]}encodeImaAdpcm(e,t){const s=2*t+1,n=Math.ceil(e.length/s),r=[],i=Int8Array.from([-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8]),A=Int16Array.from([7,8,9,10,11,12,13,14,16,17,19,21,23,25,28,31,34,37,41,45,50,55,60,66,73,80,88,97,107,118,130,143,157,173,190,209,230,253,279,307,337,371,408,449,494,544,598,658,724,796,876,963,1060,1166,1282,1411,1552,1707,1878,2066,2272,2499,2749,3024,3327,3660,4026,4428,4871,5358,5894,6484,7132,7845,8630,9493,10442,11487,12635,13899,15289,16818,18500,20350,22385,24623,27086,29794,32767]);let o=0;for(let s=0;s<n;s++){const s=Buffer.alloc(4+t);let n=e[o]??0,a=0;s.writeInt16LE(n,0),s.writeUInt8(a,2),s.writeUInt8(0,3),o++;const c=new Uint8Array(2*t);for(let t=0;t<c.length;t++){const s=e[o]??n;o++;let r=s-n,l=0;r<0&&(l=8,r=-r);let h=A[a]??7,g=0,d=h>>3;r>=h&&(g|=4,r-=h,d+=h),h>>=1,r>=h&&(g|=2,r-=h,d+=h),h>>=1,r>=h&&(g|=1,d+=h),l?n-=d:n+=d,n=this.clamp16(n),a+=i[g]??0,a<0&&(a=0),a>88&&(a=88),c[t]=15&(g|l)}for(let e=0;e<t;e++){const t=c[2*e]??0,n=c[2*e+1]??0;s[4+e]=15&t|(15&n)<<4}r.push(s)}return Buffer.concat(r)}}},7927:function(e,t,s){"use strict";var n,r=this&&this.__createBinding||(Object.create?function(e,t,s,n){void 0===n&&(n=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,n,r)}:function(e,t,s,n){void 0===n&&(n=s),e[n]=t[s]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),A=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[t.length]=s);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s=n(e),A=0;A<s.length;A++)"default"!==s[A]&&r(t,e,s[A]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0});const o=A(s(7562)),a=s(4417),c=s(6125),l=s(5098),h=s(5582),g=s(6185),d=s(2256);class u extends o.ScryptedDeviceBase{constructor(e){super(e),this.devices=new Map;const t=o.default.systemManager.getDeviceByName("Scrypted NVR");this.nvrDeviceId=t?.id}getScryptedDeviceCreator(){return"Reolink Native camera"}async getDevice(e){if(this.devices.has(e))return this.devices.get(e);const t=this.createCamera(e);return this.devices.set(e,t),t}async createDevice(e,t){const n=e.ip?.toString(),r=e.username?.toString(),i=e.password?.toString(),A=e.uid?.toString();if(!n||!r||!i)throw new Error("IP address, username, and password are required");this.console.log(`[AutoDetect] Starting device type detection for ${n}...`);const{autoDetectDeviceType:a}=await Promise.resolve().then(s.bind(s,4157)),c=await a({host:n,username:r,password:i,uid:A,logger:this.console});if(this.console.log(`[AutoDetect] Detected device type ${c.type} on transport ${c.transport}: ${JSON.stringify(c.deviceInfo)}`),"multifocal"===c.type){const s=c.deviceInfo||{},A=s.name||"Reolink Multi-Focal",a=s.serialNumber||s.itemNo||`multifocal-${Date.now()}`,l="udp"===c.transport;t=`${a}${l?g.batteryMultifocalSuffix:g.multifocalSuffix}`,e.newCamera||=A;const h=[o.ScryptedInterface.Settings,o.ScryptedInterface.DeviceProvider,o.ScryptedInterface.Reboot];l&&h.push(o.ScryptedInterface.Battery,o.ScryptedInterface.Sleep),await o.default.deviceManager.onDeviceDiscovered({nativeId:t,name:A,interfaces:h,type:o.ScryptedDeviceType.DeviceProvider,providerNativeId:this.nativeId});const u=await this.getDevice(t);if(!(u instanceof d.ReolinkNativeMultiFocalDevice))throw new Error("Expected multi-focal device but got different type");return u.storageSettings.values.ipAddress=n,u.storageSettings.values.username=r,u.storageSettings.values.password=i,u.storageSettings.values.uid=c.uid||"",t}if("nvr"===c.type){const s=c.deviceInfo||{},A=s?.name||"Reolink NVR";t=`${s?.serialNumber||s?.itemNo||`nvr-${Date.now()}`}${g.nvrSuffix}`,e.newCamera||=A,await o.default.deviceManager.onDeviceDiscovered({nativeId:t,name:A,interfaces:[o.ScryptedInterface.Settings,o.ScryptedInterface.DeviceDiscovery,o.ScryptedInterface.DeviceProvider,o.ScryptedInterface.Reboot],type:o.ScryptedDeviceType.DeviceProvider,providerNativeId:this.nativeId});const a=await this.getDevice(t);if(!(a instanceof h.ReolinkNativeNvrDevice))throw new Error("Expected NVR device but got different type");return a.storageSettings.values.ipAddress=n,a.storageSettings.values.username=r,a.storageSettings.values.password=i,t}const u=c.deviceInfo||{},I=u?.name||"Reolink Camera",E=u?.serialNumber||u?.itemNo||`unknown-${Date.now()}`;t="battery-cam"===c.type?`${E}${g.batteryCameraSuffix}`:`${E}${g.cameraSuffix}`,e.newCamera||=I;const p=await(0,l.createBaichuanApi)({inputs:{host:n,username:r,password:i,uid:c.uid,logger:this.console},transport:c.transport});try{await p.login();const e=0,{capabilities:s,objects:A,presets:a}=await p.getDeviceCapabilities(e),{interfaces:l,type:h}=(0,g.getDeviceInterfaces)({capabilities:s,logger:this.console});await o.default.deviceManager.onDeviceDiscovered({nativeId:t,name:I,interfaces:l,type:h,providerNativeId:this.nativeId});const d=await this.getDevice(t);return d.info=u,d.classes=A,d.presets=a,d.storageSettings.values.username=r,d.storageSettings.values.password=i,d.storageSettings.values.rtspChannel=e,d.storageSettings.values.ipAddress=n,d.storageSettings.values.capabilities=s,d.storageSettings.values.uid=c.uid,t}catch(e){throw this.console.error("Error adding Reolink device",e),e}finally{await p.close()}}async releaseDevice(e,t){if(this.devices.has(t)){const e=this.devices.get(t);e&&"release"in e&&"function"==typeof e.release&&await e.release(),this.devices.delete(t)}}async getCreateDeviceSettings(){return[{key:"ip",title:"IP Address",placeholder:"192.168.2.222",value:"192.168."},{key:"username",title:"Username",value:"admin"},{key:"password",title:"Password",type:"password"},{key:"uid",title:"UID",description:"Reolink UID (optional, required for battery cameras if TCP connection fails)"}]}createCamera(e){return e.endsWith(g.batteryCameraSuffix)?new c.ReolinkNativeBatteryCamera(e,this):e.endsWith(g.nvrSuffix)?new h.ReolinkNativeNvrDevice(e,this):e.endsWith(g.batteryMultifocalSuffix)?new d.ReolinkNativeMultiFocalDevice(e,this,"multi-focal-battery"):e.endsWith(g.multifocalSuffix)?new d.ReolinkNativeMultiFocalDevice(e,this,"multi-focal"):new a.ReolinkNativeCamera(e,this)}}t.default=u},2256:function(e,t,s){"use strict";var n,r=this&&this.__createBinding||(Object.create?function(e,t,s,n){void 0===n&&(n=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,n,r)}:function(e,t,s,n){void 0===n&&(n=s),e[n]=t[s]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),A=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[t.length]=s);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s=n(e),A=0;A<s.length;A++)"default"!==s[A]&&r(t,e,s[A]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.ReolinkNativeMultiFocalDevice=void 0;const o=A(s(7562)),a=s(4417),c=s(6125),l=s(8799),h=s(6185);class g extends l.CommonCameraMixin{constructor(e,t,s){super(e,t,{type:s}),this.cameraNativeMap=new Map,this.channelToNativeIdMap=new Map,this.plugin=t,this.scheduleInit()}getAbilities(){const{capabilities:e}=this.storageSettings.values;return{...e,hasPan:!1,hasTilt:!1,hasZoom:!1,hasPresets:!1,hasIntercom:!1}}async reboot(){const e=await this.ensureBaichuanClient();await e.reboot()}takePicture(e){throw new Error("Method not implemented.")}getPictureOptions(){throw new Error("Method not implemented.")}getConnectionCallbacks(){return{onError:void 0,onClose:async()=>{await this.reinit(),this.isBattery||setTimeout((async()=>{try{await this.subscribeToEvents()}catch(e){this.getBaichuanLogger().warn("Failed to resubscribe to events after reconnection",e)}}),1e3)},onSimpleEvent:e=>this.forwardNativeEvent(e),getEventSubscriptionEnabled:()=>!0}}async onBeforeCleanup(){await this.unsubscribeFromAllEvents()}isDebugEnabled(){return this.storageSettings.values.debugEvents||!1}getDeviceName(){return this.name||"Multi-Focal Device"}async reinit(){this.initReinitTimeout&&(clearTimeout(this.initReinitTimeout),this.initReinitTimeout=void 0),this.scheduleInit(!0)}scheduleInit(e=!1){this.initReinitTimeout&&clearTimeout(this.initReinitTimeout),this.initReinitTimeout=setTimeout((async()=>{const t=this.getBaichuanLogger();e&&(t.log("Reinitializing multi-focal device..."),await this.cleanupBaichuanApi()),await this.init(),this.initReinitTimeout=void 0}),e?500:2e3)}async init(){const e=this.getBaichuanLogger();try{this.storageSettings.settings.uid.hide=!this.isBattery,await this.ensureBaichuanClient(),await this.updateDeviceInfo(),await this.reportDevices(),await this.subscribeToEvents()}catch(t){e.error("Failed to initialize multi-focal device",t),t instanceof Error?(e.error(`Error message: ${t.message}`),e.error(`Error stack: ${t.stack}`)):e.error(`Error details: ${JSON.stringify(t)}`)}}async updateDeviceInfo(){const e=this.getBaichuanLogger();try{const t=await this.ensureBaichuanClient(),s=await t.getInfo();await(0,h.updateDeviceInfo)({device:this,deviceData:s,ipAddress:this.storageSettings.values.ipAddress,logger:e})}catch(t){e.warn("Failed to fetch device info",t)}}getInterfaces(e){const t=this.getBaichuanLogger(),{capabilities:s,multifocalInfo:n}=this.storageSettings.values,r=n.channels.find((t=>t.channel===e)),i={...s,hasPan:r.hasPan,hasTilt:r.hasTilt,hasZoom:r.hasZoom,hasPresets:r.hasPresets,hasIntercom:r.hasIntercom},{interfaces:A}=(0,h.getDeviceInterfaces)({capabilities:i,logger:t});return{interfaces:A,capabilities:i}}async reportDevices(){const e=await this.ensureBaichuanClient(),t=this.getBaichuanLogger(),{username:s,password:n,ipAddress:r,uid:i}=this.storageSettings.values,{capabilities:A,support:a,abilities:c,features:l,objects:g,presets:d}=await e.getDeviceCapabilities(),u=await e.getDualLensChannelInfo();t.log(`Sync entities from remote for ${u.channels.length} channels`),this.storageSettings.values.multifocalInfo=u,this.storageSettings.values.capabilities=A,t.log(`Multichannel info: ${JSON.stringify({multifocalInfo:u,capabilities:A,support:a,abilities:c,features:l,objects:g,presets:d})}`);for(const e of u?.channels??[]){const{channel:A,lensType:a}=e,c=`${this.name} - ${a}`,l=`${this.nativeId}-channel${A}${this.isBattery?h.batteryCameraSuffix:h.cameraSuffix}`;this.channelToNativeIdMap.set(A,l);const{interfaces:u,capabilities:I}=this.getInterfaces(A),E={providerNativeId:this.nativeId,name:c,nativeId:l,info:{...this.info,metadata:{channel:A,lensType:a}},interfaces:u,type:o.ScryptedDeviceType.Camera};await o.default.deviceManager.onDeviceDiscovered(E),t.log(`Discovering lens device ${l}: ${JSON.stringify({interfaces:u,deviceCapabilities:I})}`);const p=await this.getDevice(l);p?(p.storageSettings.values.rtspChannel=A,p.classes=g,p.presets=d,p.storageSettings.values.username=s,p.storageSettings.values.password=n,p.storageSettings.values.ipAddress=r,p.storageSettings.values.capabilities=I,this.isBattery&&(p.storageSettings.values.uid=i)):t.error(`Failed to get device ${l}`)}await super.reportDevices()}async getDevice(e){if(e.endsWith(h.cameraSuffix)||e.endsWith(h.batteryCameraSuffix)){let t=this.cameraNativeMap.get(e);return t||(t=e.endsWith(h.batteryCameraSuffix)?new c.ReolinkNativeBatteryCamera(e,this.plugin,void 0,this):new a.ReolinkNativeCamera(e,this.plugin,void 0,this)),t}return super.getDevice(e)}async getSettings(){return await this.storageSettings.getSettings()}async putSetting(e,t){return this.storageSettings.putSetting(e,t)}async releaseDevice(e,t){this.cameraNativeMap.delete(t),super.releaseDevice(e,t)}forwardNativeEvent(e){const t=this.getBaichuanLogger(),s=e?.channel;if(void 0===s)return void t.debug("Event missing channel, ignoring");const n=this.channelToNativeIdMap.get(s);if(!n)return void t.debug(`No camera found for channel ${s}, ignoring event`);const r=this.cameraNativeMap.get(n);r?r.onSimpleEvent(e):t.debug(`Camera ${n} not yet initialized, ignoring event`)}async unsubscribeFromAllEvents(){await super.unsubscribeFromEvents()}async runDiagnostics(){const e=this.getBaichuanLogger();e.log("Starting Multifocal diagnostics...");try{const{ipAddress:t,username:s,password:n}=this.storageSettings.values;if(!t||!s||!n)throw new Error("Missing device credentials");const r=await this.ensureBaichuanClient(),i=await r.collectMultifocalDiagnostics(e);e.log("NVR diagnostics completed successfully."),e.log(JSON.stringify(i))}catch(t){throw e.error("Failed to run NVR diagnostics",t),t}}}t.ReolinkNativeMultiFocalDevice=g},5582:function(e,t,s){"use strict";var n,r=this&&this.__createBinding||(Object.create?function(e,t,s,n){void 0===n&&(n=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,n,r)}:function(e,t,s,n){void 0===n&&(n=s),e[n]=t[s]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),A=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[t.length]=s);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s=n(e),A=0;A<s.length;A++)"default"!==s[A]&&r(t,e,s[A]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.ReolinkNativeNvrDevice=void 0;const o=A(s(7562)),a=s(6117),c=s(7077),l=s(4417),h=s(6125),g=s(5098),d=s(6185);class u extends c.BaseBaichuanClass{constructor(e,t){super(e),this.storageSettings=new a.StorageSettings(this,{debugEvents:{title:"Debug Events",type:"boolean",immediate:!0},eventSource:{title:"Event Source",description:"Select the source for camera events: Native (Baichuan) or CGI (HTTP polling)",type:"string",choices:["Native","CGI"],defaultValue:"Native",immediate:!0,onPut:async()=>{await this.reinitEventSubscriptions()}},ipAddress:{title:"IP address",type:"string",onPut:async()=>await this.reinit()},username:{title:"Username",placeholder:"admin",defaultValue:"admin",type:"string",onPut:async()=>await this.reinit()},password:{title:"Password",type:"password",onPut:async()=>await this.reinit()},diagnosticsRun:{subgroup:"Diagnostics",title:"Run NVR Diagnostics",description:"Collect NVR diagnostics and display results in logs.",type:"button",immediate:!0,onPut:async()=>{await this.runNvrDiagnostics()}}}),this.discoveredDevices=new Map,this.cameraNativeMap=new Map,this.channelToNativeIdMap=new Map,this.processing=!1,this.plugin=t,this.scheduleInit()}async reboot(){const e=await this.ensureClient();await e.Reboot()}getConnectionConfig(){const{ipAddress:e,username:t,password:s}=this.storageSettings.values;if(!e||!t||!s)throw new Error("Missing NVR credentials");return{host:e,username:t,password:s,transport:"tcp",logger:this.console}}getConnectionCallbacks(){return{onError:void 0,onClose:async()=>{await this.reinit()},onSimpleEvent:e=>this.forwardNativeEvent(e),getEventSubscriptionEnabled:()=>"Native"===(this.storageSettings.values.eventSource||"Native")}}isDebugEnabled(){return this.storageSettings.values.debugEvents||!1}getDeviceName(){return this.name||"NVR"}async onBeforeCleanup(){await this.unsubscribeFromAllEvents()}async reinit(){this.initReinitTimeout&&(clearTimeout(this.initReinitTimeout),this.initReinitTimeout=void 0),this.scheduleInit(!0)}scheduleInit(e=!1){this.initReinitTimeout&&clearTimeout(this.initReinitTimeout),this.initReinitTimeout=setTimeout((async()=>{if(e){if(this.nvrApi)try{await this.nvrApi.logout()}catch{}this.nvrApi=void 0,await super.cleanupBaichuanApi()}await this.init(),this.initReinitTimeout=void 0}),e?500:2e3)}async ensureClient(){if(this.nvrApi)return this.nvrApi;const{ipAddress:e,username:t,password:n}=this.storageSettings.values;if(!e||!t||!n)throw new Error("Missing NVR credentials");const{ReolinkCgiApi:r}=await Promise.resolve().then(s.bind(s,4157));return this.nvrApi=new r({host:e,username:t,password:n}),await this.nvrApi.login(),this.nvrApi}forwardNativeEvent(e){const t=this.getBaichuanLogger();if("Native"===(this.storageSettings.values.eventSource||"Native"))try{t.debug(`Baichuan event: ${JSON.stringify(e)}`);const s=e?.channel;if(void 0===s)return void t.error("Event has no channel, ignoring");const n=this.channelToNativeIdMap.get(s),r=n?this.cameraNativeMap.get(n):void 0;if(!r)return void t.debug(`No camera found for channel ${s}, ignoring event`);const i=[];let A=!1;switch(e?.type){case"motion":A=!0;break;case"doorbell":try{"function"==typeof r.handleDoorbellEvent&&r.handleDoorbellEvent()}catch(e){t.warn(`Error handling doorbell event for camera channel ${s}`,e)}A=!0;break;case"people":case"vehicle":case"animal":case"face":case"package":case"other":i.push(e.type),A=!0;break;default:return void t.error(`Unknown event type: ${e?.type}`)}r.processEvents({motion:A,objects:i}).catch((e=>{t.warn(`Error processing events for camera channel ${s}`,e)}))}catch(e){t.warn("Error in NVR Native event forwarder",e)}}async ensureBaichuanClient(){return await super.ensureBaichuanClient()}async subscribeToAllEvents(){"Native"!==(this.storageSettings.values.eventSource||"Native")?await this.unsubscribeFromAllEvents():await super.subscribeToEvents()}async runNvrDiagnostics(){const e=this.getBaichuanLogger();e.log("Starting NVR diagnostics...");try{const t=await this.ensureClient(),s=await t.collectNvrDiagnostics({logger:this.console});e.log("NVR diagnostics completed successfully."),t.printNvrDiagnostics(s,this.console)}catch(t){throw e.error("Failed to run NVR diagnostics",t),t}}async unsubscribeFromAllEvents(){await super.unsubscribeFromEvents()}async reinitEventSubscriptions(){const e=this.getBaichuanLogger(),{eventSource:t}=this.storageSettings.values;"Native"!==t?await this.unsubscribeFromAllEvents():this.subscribeToAllEvents().catch((t=>{e.warn("Failed to subscribe to Native events",t)})),e.log(`Event source set to: ${t}`)}forwardCgiEvents(e){this.getBaichuanLogger().debug(`CGI Events call result: ${JSON.stringify(e)}`);for(const[t,s]of this.channelToNativeIdMap.entries()){const n=s?this.cameraNativeMap.get(s):void 0,r=e[t];r&&n&&n.processEvents(r)}}async init(){const e=this.getBaichuanLogger(),t=await this.ensureClient();await this.ensureBaichuanClient(),await this.updateDeviceInfo(),await this.reinitEventSubscriptions(),setInterval((async()=>{if(!this.processing&&t){this.processing=!0;try{const s=Date.now();if((!this.lastErrorsCheck||s-this.lastErrorsCheck>6e4)&&(this.lastErrorsCheck=s),!this.lastNvrInfoCheck||s-this.lastNvrInfoCheck>3e5){e.log("Starting NVR info data fetch"),this.lastNvrInfoCheck=s;const{nvrData:n}=await t.getNvrInfo(),{devicesData:r,channelsResponse:i,response:A}=await t.getDevicesInfo();e.log("NVR info data fetched"),e.debug(`${JSON.stringify({nvrData:n,devicesData:r,channelsResponse:i,response:A})}`),await this.discoverDevices(!0)}const{eventSource:n}=this.storageSettings.values;if("CGI"===n){const e=await t.getAllChannelsEvents();this.forwardCgiEvents(e.parsed)}const{batteryInfoData:r,response:i}=await t.getAllChannelsBatteryInfo();e.debug(`Battery info call result: ${JSON.stringify({batteryInfoData:r,response:i})}`),this.cameraNativeMap.forEach((e=>{if(e){const t=e.storageSettings.values.rtspChannel,s=r[t];s&&e.updateSleepingState({reason:"NVR",state:s.sleeping?"sleeping":"awake",idleMs:0,lastRxAtMs:0}).catch((()=>{}))}}))}catch(t){e.error("Error on events flow",t)}finally{this.processing=!1}}}),1e3)}async updateDeviceInfo(){const e=this.getBaichuanLogger(),{ipAddress:t}=this.storageSettings.values;try{const s=await this.ensureClient(),n=await s.getInfo();await(0,d.updateDeviceInfo)({device:this,ipAddress:t,deviceData:n,logger:e})}catch(t){e.warn("Failed to fetch device info",t)}}async getSettings(){return await this.storageSettings.getSettings()}async putSetting(e,t){return this.storageSettings.putSetting(e,t)}async releaseDevice(e,t){this.cameraNativeMap.delete(t)}async getDevice(e){let t=this.cameraNativeMap.get(e);return t||(t=e.endsWith("-battery-cam")?new h.ReolinkNativeBatteryCamera(e,this.plugin,this):new l.ReolinkNativeCamera(e,this.plugin,this),this.cameraNativeMap.set(e,t)),t}buildNativeId(e,t,s){const n=s?"-battery-cam":"-cam";return t?`${this.nativeId}-ch${e}-${t}${n}`:`${this.nativeId}-ch${e}${n}`}getCameraInterfaces(){return[o.ScryptedInterface.VideoCameraConfiguration,o.ScryptedInterface.Camera,o.ScryptedInterface.MotionSensor,o.ScryptedInterface.VideoTextOverlays,o.ScryptedInterface.VideoCamera,o.ScryptedInterface.Settings,o.ScryptedInterface.ObjectDetector]}async syncEntitiesFromRemote(){const e=this.getBaichuanLogger(),t=await this.ensureClient(),s=await this.ensureBaichuanClient();if(s?.client&&!s.client.isSocketConnected()){e.debug("Waiting for Baichuan connection to be established...");let t=0;for(;!s.client.isSocketConnected()&&t<50;)await new Promise((e=>setTimeout(e,100))),t++;s.client.isSocketConnected()?e.debug("Baichuan connection established"):e.warn("Baichuan connection not established after waiting, proceeding anyway")}const{devicesData:n,channels:r}=await t.getDevicesInfo();if(r.length){e.log(`Sync entities from remote for ${r.length} channels`);for(const t of r)try{const{channelStatus:s,channelInfo:r,abilities:i}=n[t],A=s?.name,a=s?.uid,c=!!i?.battery?.ver,l=this.buildNativeId(t,a,c),h=[o.ScryptedInterface.VideoCamera];c&&h.push(o.ScryptedInterface.Battery);const g=i.supportDoorbellLight?o.ScryptedDeviceType.Doorbell:o.ScryptedDeviceType.Camera,d={nativeId:l,name:A,providerNativeId:this.nativeId,interfaces:h,type:g,info:{manufacturer:"Reolink",model:r?.typeInfo,serialNumber:a}};if(this.channelToNativeIdMap.set(t,l),o.default.deviceManager.getNativeIds().includes(l))continue;if(this.discoveredDevices.has(l))continue;this.discoveredDevices.set(l,{device:d,description:`${A} (Channel ${t})`,rtspChannel:t,deviceData:n[t]}),e.debug(`Discovered channel ${t}: ${A}`)}catch(s){e.debug(`Error processing channel ${t}: ${s?.message||String(s)}`)}e.debug(`Channel discovery completed. ${JSON.stringify({devicesData:n,channels:r})}`)}else e.debug(`No channels found, ${JSON.stringify({devicesData:n,channels:r})}`)}async discoverDevices(e){return e&&await this.syncEntitiesFromRemote(),[...this.discoveredDevices.values()].map((e=>({...e.device,description:e.description})))}async adoptDevice(e){const t=this.discoveredDevices.get(e.nativeId);if(!t)throw new Error("device not found");await this.onDeviceEvent(o.ScryptedInterface.DeviceDiscovery,await this.discoverDevices());const n=t.device.interfaces.includes(o.ScryptedInterface.Battery),{channelStatus:r}=t.deviceData,{ReolinkBaichuanApi:i}=await Promise.resolve().then(s.bind(s,4157)),A=r?.uid,a=n&&A?(0,g.normalizeUid)(A):void 0,c=new i({host:this.storageSettings.values.ipAddress,username:this.storageSettings.values.username,password:this.storageSettings.values.password,transport:"tcp",channel:t.rtspChannel,...a?{uid:a}:{}});await c.login();const{capabilities:l,objects:h,presets:u}=await c.getDeviceCapabilities(t.rtspChannel),{interfaces:I,type:E}=(0,d.getDeviceInterfaces)({capabilities:l,logger:this.console}),p={...t.device,interfaces:I,type:E};await o.default.deviceManager.onDeviceDiscovered(p);const C=await this.getDevice(e.nativeId),B=this.getBaichuanLogger();B.log("Adopted device",C?.name),B.log(JSON.stringify(t));const{username:Q,password:f,ipAddress:m}=this.storageSettings.values;return C.storageSettings.values.rtspChannel=t.rtspChannel,C.classes=h,C.presets=u,C.storageSettings.values.username=Q,C.storageSettings.values.password=f,C.storageSettings.values.rtspChannel=t.rtspChannel,C.storageSettings.values.ipAddress=m,C.storageSettings.values.capabilities=l,C.storageSettings.values.uid=t.deviceData.channelStatus.uid,this.discoveredDevices.delete(e.nativeId),C?.id}}t.ReolinkNativeNvrDevice=u},840:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReolinkPtzPresets=void 0;t.ReolinkPtzPresets=class{constructor(e){this.camera=e}get storageSettings(){return this.camera.storageSettings}getPtzCapabilitiesStore(){return this.camera.ptzCapabilities}setPtzCapabilitiesStore(e){this.camera.ptzCapabilities=e}parsePresetIdFromSettingValue(e){const t=String(e??"").trim();if(!t)return;const s=t.includes("=")?t.split("=")[0]:t,n=Number(s);return Number.isFinite(n)?n:void 0}syncEnabledPresetsSettingAndCaps(e){const t=this.storageSettings.values.presets??[];if(!t.length)return;const s=new Map(e.map((e=>[e.id,e.name]))),n={};for(const e of t){const t=this.parsePresetIdFromSettingValue(e);if(void 0===t)continue;const r=(e.includes("=")?e.substring(e.indexOf("=")+1).trim():"")||s.get(t);r&&(n[String(t)]=r)}this.setPtzCapabilitiesStore({...this.getPtzCapabilitiesStore()??{},presets:n})}setCachedPtzPresets(e){const t=Array.isArray(e)?e:[];this.camera.presets=t;const s={};for(const e of t)s[String(e.id)]=e.name;this.setPtzCapabilitiesStore({...this.getPtzCapabilitiesStore()??{},presets:s})}getCachedPtzPresets(){const e=this.camera.presets;return Array.isArray(e)?e:[]}nextFreePresetId(e){const t=new Set(e.map((e=>e.id)));for(let e=1;e<=255;e++)if(!t.has(e))return e;throw new Error("No free PTZ preset id available (1..255)")}async refreshPtzPresets(){const e=await this.camera.ensureClient(),t=this.camera.storageSettings.values.rtspChannel,s=await e.getPtzPresets(t);return this.setCachedPtzPresets(s),this.syncEnabledPresetsSettingAndCaps(s),s}async moveToPreset(e){const t=await this.camera.ensureClient(),s=this.camera.storageSettings.values.rtspChannel;await t.moveToPtzPreset(s,e)}async createPtzPreset(e,t){const s=await this.camera.ensureClient(),n=this.camera.storageSettings.values.rtspChannel,r=String(e??"").trim();if(!r)throw new Error("Preset name is required");const i=await s.getPtzPresets(n),A=new Set(i.map((e=>e.id))),o=t??this.nextFreePresetId(i);if(void 0===t&&A.has(o))throw new Error(`PTZ preset id already in use: ${o}`);await s.setPtzPreset(n,o,r);const a=await s.getPtzPresets(n),c=a.some((e=>e.id===o));if(this.setCachedPtzPresets(a),!c)throw this.syncEnabledPresetsSettingAndCaps(a),new Error("PTZ preset save did not persist (camera returned an empty/unchanged preset list). Try again.");const l=this.storageSettings.values.presets??[];if(l.length){l.some((e=>this.parsePresetIdFromSettingValue(e)===o))||(l.push(`${o}=${r}`),this.storageSettings.values.presets=l)}return this.syncEnabledPresetsSettingAndCaps(a),{id:o,name:r}}async updatePtzPresetToCurrentPosition(e){const t=await this.camera.ensureClient(),s=this.camera.storageSettings.values.rtspChannel,n=this.getCachedPtzPresets().find((t=>t.id===e)),r=n?.name??`Preset ${e}`;await t.setPtzPreset(s,e,r),await this.refreshPtzPresets()}async deletePtzPreset(e){const t=await this.camera.ensureClient(),s=this.camera.storageSettings.values.rtspChannel;await t.deletePtzPreset(s,e);const n=this.storageSettings.values.presets;if(Array.isArray(n)&&n.length){const t=n.filter((e=>"string"==typeof e)).filter((t=>this.parsePresetIdFromSettingValue(t)!==e));this.storageSettings.values.presets=t}await this.refreshPtzPresets()}async renamePtzPreset(e,t){const s=await this.camera.ensureClient(),n=this.camera.storageSettings.values.rtspChannel,r=String(t??"").trim();if(!r)throw new Error("Preset name is required");await s.moveToPtzPreset(n,e),await s.setPtzPreset(n,e,r),await this.refreshPtzPresets()}}},5050:function(e,t,s){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StreamManager=void 0,t.parseStreamProfileFromId=function(e){if(!e)return;if(e.startsWith("native_")){return e.replace("native_","")}if(e.endsWith(".bcs")){return e.replace(".bcs","")}if(e.startsWith("h264Preview_")){if(e.endsWith("_main"))return"main";if(e.endsWith("_sub"))return"sub"}return},t.selectStreamOption=function(e,t){if(!t)throw new Error("video streams not set up or no longer exists.");const s=e?.find((e=>e.id===t.id))||e?.[0];if(!s)throw new Error("No stream options available");return s},t.expectedVideoTypeFromUrlMediaStreamOptions=function(e){const t=e?.video?.codec;return"string"!=typeof t?void 0:t.includes("265")?"H265":t.includes("264")?"H264":void 0},t.createRfc4571MediaObjectFromStreamManager=async function(e){const{streamManager:t,channel:s,profile:n,streamKey:i,expectedVideoType:A,selected:o,sourceId:a,onDetectedCodec:c}=e,{host:l,port:h,sdp:g,audio:d,username:u,password:I}=await t.getRfcStream(s,n,i,A);try{const e=/a=rtpmap:\d+\s+(H26[45])\//.exec(g)?.[1];if(e){const t="H265"===e?"h265":"h264";c?.(t)}}catch{}const{url:E,...p}=o;p.container="rtp",d&&(p.audio||={},p.audio.codec=d.codec,p.audio.sampleRate=d.sampleRate,p.audio.channels=d.channels);const C=encodeURIComponent(u||""),B=encodeURIComponent(I||""),Q={url:`tcp://${C}:${B}@${l}:${h}`,sdp:g,mediaStreamOptions:p};return await r.default.mediaManager.createMediaObject(Buffer.from(JSON.stringify(Q)),"x-scrypted/x-rfc4571",{sourceId:a})};const r=n(s(7562));t.StreamManager=class{constructor(e){this.opts=e,this.nativeRfcServers=new Map,this.nativeRfcServerCreatePromises=new Map}getLogger(){return this.opts.getLogger()}async ensureNativeRfcServer(e,t,n,r){const i=this.nativeRfcServerCreatePromises.get(e);if(i)return await i;const A=(async()=>{const i=this.nativeRfcServers.get(e);if(i?.server?.listening){if(!r||i.videoType===r)return{host:i.host,port:i.port,sdp:i.sdp,audio:i.audio,username:i.username||this.opts.credentials.username,password:i.password||this.opts.credentials.password};this.getLogger().warn(`Native RFC cache codec mismatch for ${e}: cached=${i.videoType} expected=${r}; recreating server.`)}if(i){try{await i.close("recreate")}catch{}this.nativeRfcServers.delete(e)}const A=await this.opts.createStreamClient(),{createScryptedRfc4571TcpServer:o}=await Promise.resolve().then(s.bind(s,4157)),{username:a,password:c}=this.opts.credentials,l=!this.opts.sharedConnection,h=await o({api:A,channel:t,profile:n,logger:this.getLogger(),expectedVideoType:r,closeApiOnTeardown:l,username:a,password:c});return this.nativeRfcServers.set(e,h),h.server.once("close",(()=>{const t=this.nativeRfcServers.get(e);t?.server===h.server&&this.nativeRfcServers.delete(e)})),{host:h.host,port:h.port,sdp:h.sdp,audio:h.audio,username:h.username||this.opts.credentials.username,password:h.password||this.opts.credentials.password}})();this.nativeRfcServerCreatePromises.set(e,A);try{return await A}finally{this.nativeRfcServerCreatePromises.delete(e)}}async getRfcStream(e,t,s,n){return await this.ensureNativeRfcServer(s,e,t,n)}async closeAllStreams(e){const t=Array.from(this.nativeRfcServers.values());this.nativeRfcServers.clear(),await Promise.allSettled(t.map((async t=>{try{await t.close(e||"connection reset")}catch(e){this.getLogger().debug("Error closing stream server",e)}})))}}},6185:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateDeviceInfo=t.getDeviceInterfaces=t.pirSuffix=t.floodlightSuffix=t.sirenSuffix=t.cameraSuffix=t.batteryMultifocalSuffix=t.multifocalSuffix=t.batteryCameraSuffix=t.nvrSuffix=t.OperationChannelType=void 0;const n=s(7562);var r;!function(e){e.PAN="pan",e.TILT="tilt",e.ZOOM="zoom",e.INTERCOM="intercom",e.GOTO="goto",e.PRESET="preset",e.PATROL="patrol",e.TRACK="track"}(r||(t.OperationChannelType=r={})),t.nvrSuffix="-nvr",t.batteryCameraSuffix="-battery-cam",t.multifocalSuffix="-multifocal",t.batteryMultifocalSuffix="-battery-multifocal",t.cameraSuffix="-cam",t.sirenSuffix="-siren",t.floodlightSuffix="-floodlight",t.pirSuffix="-pir";t.getDeviceInterfaces=e=>{const{capabilities:t,logger:s}=e,r=[n.ScryptedInterface.VideoCamera,n.ScryptedInterface.Settings,n.ScryptedInterface.Reboot,n.ScryptedInterface.VideoCameraConfiguration,n.ScryptedInterface.Camera,n.ScryptedInterface.AudioSensor,n.ScryptedInterface.MotionSensor,n.ScryptedInterface.VideoTextOverlays];try{const{hasPtz:e,hasSiren:s,hasFloodlight:i,hasPir:A,hasBattery:o,hasIntercom:a,isDoorbell:c}=t;e&&r.push(n.ScryptedInterface.PanTiltZoom),r.push(n.ScryptedInterface.ObjectDetector),(s||i||A)&&r.push(n.ScryptedInterface.DeviceProvider),o&&r.push(n.ScryptedInterface.Battery,n.ScryptedInterface.Sleep),a&&r.push(n.ScryptedInterface.Intercom),c&&r.push(n.ScryptedInterface.BinarySensor)}catch(e){s.error("Error getting device interfaces",e)}return{interfaces:r,type:t.isDoorbell?n.ScryptedDeviceType.Doorbell:n.ScryptedDeviceType.Camera}};t.updateDeviceInfo=async e=>{const{device:t,ipAddress:s,deviceData:n,logger:r}=e;try{const e=t.info||{};e.ip=s,e.serialNumber=n?.serialNumber||n?.itemNo,e.firmware=n?.firmwareVersion,e.version=n?.hardwareVersion,e.model=n?.type,e.manufacturer="Reolink",e.managementUrl=`http://${s}`,t.info=e}catch(e){const n=t.info||{};throw n.ip=s,n.manufacturer="Reolink native",n.managementUrl=`http://${s}`,t.info=n,e}finally{r.log("Device info updated"),r.debug(`${JSON.stringify({newInfo:t.info,deviceData:n})}`)}}},5317:e=>{"use strict";e.exports=require("child_process")},4434:e=>{"use strict";e.exports=require("events")},9896:e=>{"use strict";e.exports=require("fs")},3339:e=>{"use strict";e.exports=require("module")},4589:e=>{"use strict";e.exports=require("node:assert")},6698:e=>{"use strict";e.exports=require("node:async_hooks")},4573:e=>{"use strict";e.exports=require("node:buffer")},1421:e=>{"use strict";e.exports=require("node:child_process")},7540:e=>{"use strict";e.exports=require("node:console")},7598:e=>{"use strict";e.exports=require("node:crypto")},3053:e=>{"use strict";e.exports=require("node:diagnostics_channel")},610:e=>{"use strict";e.exports=require("node:dns")},8474:e=>{"use strict";e.exports=require("node:events")},1455:e=>{"use strict";e.exports=require("node:fs/promises")},7067:e=>{"use strict";e.exports=require("node:http")},2467:e=>{"use strict";e.exports=require("node:http2")},7030:e=>{"use strict";e.exports=require("node:net")},6760:e=>{"use strict";e.exports=require("node:path")},643:e=>{"use strict";e.exports=require("node:perf_hooks")},1792:e=>{"use strict";e.exports=require("node:querystring")},99:e=>{"use strict";e.exports=require("node:sqlite")},7075:e=>{"use strict";e.exports=require("node:stream")},7997:e=>{"use strict";e.exports=require("node:timers")},1692:e=>{"use strict";e.exports=require("node:tls")},7975:e=>{"use strict";e.exports=require("node:util")},3429:e=>{"use strict";e.exports=require("node:util/types")},5919:e=>{"use strict";e.exports=require("node:worker_threads")},8522:e=>{"use strict";e.exports=require("node:zlib")},6928:e=>{"use strict";e.exports=require("path")},2203:e=>{"use strict";e.exports=require("stream")},9023:e=>{"use strict";e.exports=require("util")},3106:e=>{"use strict";e.exports=require("zlib")},5537:e=>{"use strict";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const s=new Int32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);function n(e){if(Buffer.isBuffer(e))return e;if("number"==typeof e)return Buffer.alloc(e);if("string"==typeof e)return Buffer.from(e);throw new Error("input must be buffer, number, or string, received "+typeof e)}function r(e,t){e=n(e),Buffer.isBuffer(t)&&(t=t.readUInt32BE(0));let r=~t;for(var i=0;i<e.length;i++)r=s[255&(r^e[i])]^r>>>8;return~r}function i(){return function(e){const t=n(4);return t.writeInt32BE(e,0),t}(r.apply(null,arguments))}i.signed=function(){return r.apply(null,arguments)},i.unsigned=function(){return r.apply(null,arguments)>>>0};const A=t(i);e.exports=A},6546:(e,t,s)=>{"use strict";s.d(t,{collectMultifocalDiagnostics:()=>n.RA,testChannelStreams:()=>n.bH});var n=s(5940)},5940:(e,t,s)=>{"use strict";s.d(t,{$8:()=>a,$v:()=>we,AG:()=>Pe,Bz:()=>it,Ck:()=>ce,F3:()=>Ne,Fi:()=>Be,Gz:()=>K,H9:()=>Re,I4:()=>Z,KC:()=>se,Kv:()=>y,Mg:()=>d,N_:()=>Y,O1:()=>Qe,Oh:()=>Ce,RA:()=>at,Rp:()=>O,S1:()=>g,S8:()=>U,T$:()=>Se,TB:()=>Ie,Uh:()=>re,VY:()=>ne,XN:()=>ye,XW:()=>pe,Xf:()=>he,YF:()=>He,YO:()=>V,aQ:()=>h,as:()=>Le,ax:()=>oe,bH:()=>ot,cY:()=>l,dB:()=>ue,d_:()=>Ae,f9:()=>Ee,fP:()=>Fe,fg:()=>Ye,fk:()=>Ve,g7:()=>te,gB:()=>be,gW:()=>At,gZ:()=>ee,iI:()=>fe,kV:()=>rt,ki:()=>o,l$:()=>de,lp:()=>je,m8:()=>xe,nf:()=>F,pH:()=>Me,pT:()=>ve,qD:()=>me,rB:()=>m,rJ:()=>ke,rO:()=>ge,tj:()=>X,ts:()=>le,uQ:()=>P,uy:()=>Oe,vF:()=>De,zt:()=>Te,zu:()=>Ue,zw:()=>ae});var n=s(9896),r=s(6928),i=s(5317),A=s(4434),o=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)((function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}));function a(e){const t=!0===e?.general,s=!0===e?.debugRtsp,n=!0===e?.traceStream,i=!0===e?.traceTalk,A=!0===e?.traceEvents,o=!0===e?.debugH264,a=!0===e?.debugParamSets,c=!0===e?.dump?.enabled;return{general:t,debugRtsp:s,traceStream:n,traceTalk:i,traceEvents:A,debugH264:o,debugParamSets:a,dumpEnabled:c,dumpDir:e?.dump?.dir&&e.dump.dir.trim()||r.join(process.cwd(),"test","frames-debug"),dumpBcMedia:e?.dump?.bcmedia??c,dumpNals:e?.dump?.nals??c}}function c(e){e.dumpEnabled&&n.mkdirSync(e.dumpDir,{recursive:!0})}function l(e,t,s,n){e.general&&t.debug(`[${s}] ${n}`)}function h(e,t,s,n){e.traceStream&&t.debug(`[${s}] ${n}`)}function g(e,t,s,n){e.traceTalk&&t.debug(`[${s}] ${n}`)}function d(e,t,s,n){e.traceEvents&&t.debug(`[${s}] ${n}`)}function u(e){if(e.length<4)return null;const t=e.readUInt32LE(0);return 825241649===t?function(e){if(e.length<32)return null;const t=e.readUInt32LE(4);if(32!==t)return null;const s={type:"InfoV1",videoWidth:e.readUInt32LE(8),videoHeight:e.readUInt32LE(12),fps:e.readUInt8(17),startYear:e.readUInt8(18),startMonth:e.readUInt8(19),startDay:e.readUInt8(20),startHour:e.readUInt8(21),startMin:e.readUInt8(22),startSeconds:e.readUInt8(23),endYear:e.readUInt8(24),endMonth:e.readUInt8(25),endDay:e.readUInt8(26),endHour:e.readUInt8(27),endMin:e.readUInt8(28),endSeconds:e.readUInt8(29)};return{media:s,consumed:32}}(e):842018865===t?function(e){if(e.length<32)return null;const t=e.readUInt32LE(4);if(32!==t)return null;const s={type:"InfoV2",videoWidth:e.readUInt32LE(8),videoHeight:e.readUInt32LE(12),fps:e.readUInt8(17),startYear:e.readUInt8(18),startMonth:e.readUInt8(19),startDay:e.readUInt8(20),startHour:e.readUInt8(21),startMin:e.readUInt8(22),startSeconds:e.readUInt8(23),endYear:e.readUInt8(24),endMonth:e.readUInt8(25),endDay:e.readUInt8(26),endHour:e.readUInt8(27),endMin:e.readUInt8(28),endSeconds:e.readUInt8(29)};return{media:s,consumed:32}}(e):t>=1667510320&&t<=1667510329?function(e){if(e.length<20)return null;const t=e.toString("utf8",4,8);if("H264"!==t&&"H265"!==t)return null;const s=t,n=e.readUInt32LE(8),r=e.readUInt32LE(12),i=e.readUInt32LE(16);let A=20;const o=e.readUInt32LE(A);let a;if(A+=4,e.length<A+r)return null;const c=e.subarray(A,A+r);r>=4&&(a=c.readUInt32LE(0));if(A+=r,e.length<A+n)return null;const l=e.subarray(A,A+n);A+=n;const h=n%8==0?0:8-n%8;if(e.length<A+h)return null;A+=h;return{media:{type:"Iframe",videoType:s,microseconds:i,...void 0!==a?{time:a}:{},additionalHeader:c,additionalHeaderSize:r,unknown:o,data:l},consumed:A}}(e):t>=1667510576&&t<=1667510585?function(e){if(e.length<20)return null;const t=e.toString("utf8",4,8);if("H264"!==t&&"H265"!==t)return null;const s=t,n=e.readUInt32LE(8),r=e.readUInt32LE(12),i=e.readUInt32LE(16);let A=20;const o=e.readUInt32LE(A);if(A+=4,e.length<A+r)return null;const a=e.subarray(A,A+r);if(A+=r,e.length<A+n)return null;const c=e.subarray(A,A+n);A+=n;const l=n%8==0?0:8-n%8;if(e.length<A+l)return null;A+=l;return{media:{type:"Pframe",videoType:s,microseconds:i,additionalHeader:a,additionalHeaderSize:r,unknown:o,data:c},consumed:A}}(e):1651979568===t?function(e){if(e.length<12)return null;const t=e.readUInt16LE(4),s=e.readUInt16LE(6);if(t!==s)return null;const n=8,r=n+t+(t%8==0?0:8-t%8);if(e.length<r)return null;const i=e.subarray(n,n+t);return{media:{type:"Aac",data:i},consumed:r}}(e):1651978544===t?function(e){if(e.length<12)return null;const t=e.readUInt16LE(4),s=e.readUInt16LE(6);if(t!==s)return null;const n=e.readUInt16LE(8);if(256!==n)return null;e.readUInt16LE(10);const r=4;if(t<r)return null;const i=t-r,A=12,o=A+i+(t%8==0?0:8-t%8);if(e.length<o)return null;const a=e.subarray(A,A+i);return{media:{type:"Adpcm",data:a},consumed:o}}(e):null}var I=class{buffer=Buffer.alloc(0);strict;amountSkipped=0;logger;constructor(e=!1,t){this.strict=e,this.logger=t}decode(e){this.buffer=0===this.buffer.length?e:Buffer.concat([this.buffer,e]);const t=[];for(;this.buffer.length>=4;){const e=u(this.buffer);if(!e){const e=this.buffer.readUInt32LE(0);if(825241649===e||842018865===e||e>=1667510320&&e<=1667510329||e>=1667510576&&e<=1667510585||1651979568===e||1651978544===e)break;if(this.strict)throw new Error(`[BcMediaCodec] Invalid data in stream (no valid magic at buffer start, len=${this.buffer.length})`);0===this.amountSkipped&&this.logger?.warn("[BcMediaCodec] Error in stream, attempting to recover..."),this.amountSkipped+=this.buffer.length,this.buffer=Buffer.alloc(0);break}this.amountSkipped>0&&(this.strict,this.logger?.warn(`[BcMediaCodec] Recovered stream after skipping ${this.amountSkipped} bytes`),this.amountSkipped=0),t.push(e.media),this.buffer=this.buffer.subarray(e.consumed)}return t}getRemainingBuffer(){return this.buffer}clear(){this.buffer=Buffer.alloc(0),this.amountSkipped=0}},E=Buffer.from([0,0,0,1]),p=Buffer.from([0,0,1]);function C(e){return!(e.length<4)&&(!!e.subarray(0,4).equals(E)||!!e.subarray(0,3).equals(p))}function B(e,t){const s=[];let n=0,r=0;for(;n<e.length;){if(n+4>e.length)return null;const i=t(e,n);if(n+=4,i<=0)return null;if(i>e.length-n)return null;s.push(E),s.push(e.subarray(n,n+i)),n+=i,r++}return 0===r?null:Buffer.concat(s)}function Q(e,t){const s=[];let n=0,r=0;for(;n<e.length;){if(n+2>e.length)return null;const i=t(e,n);if(n+=2,i<=0)return null;if(i>e.length-n)return null;s.push(E),s.push(e.subarray(n,n+i)),n+=i,r++}return 0===r?null:Buffer.concat(s)}function f(e,t){const s=[];let n=0,r=0;const i=(e,s)=>{if(s+3>e.length)return 0;const n=e[s],r=e[s+1],i=e[s+2];return"be"===t?(n<<16|r<<8|i)>>>0:(i<<16|r<<8|n)>>>0};for(;n<e.length;){if(n+3>e.length)return null;const t=i(e,n);if(n+=3,t<=0)return null;if(t>e.length-n)return null;s.push(E),s.push(e.subarray(n,n+t)),n+=t,r++}return 0===r?null:Buffer.concat(s)}function m(e){if(C(e))return e;const t=Buffer.from([0,0,0,1]),s=Buffer.from([0,0,1]),n=Math.min(64,e.length),r=e.subarray(0,n).indexOf(t);if(r>0)return e.subarray(r);const i=e.subarray(0,n).indexOf(s);if(i>0)return e.subarray(i);const A=B(e,((e,t)=>e.readUInt32BE(t)));if(A)return A;const o=B(e,((e,t)=>e.readUInt32LE(t)));if(o)return o;const a=f(e,"be");if(a)return a;const c=f(e,"le");if(c)return c;const l=Q(e,((e,t)=>e.readUInt16BE(t)));if(l)return l;const h=Q(e,((e,t)=>e.readUInt16LE(t)));if(h)return h;const g=function(e){if(e.length<1)return null;const t=31&e[0],s=[],n=e=>{0!==e.length&&s.push(E,e)};if(24===t){let t=1;for(;t+2<=e.length;){const s=e.readUInt16BE(t);if(t+=2,s<=0||t+s>e.length)return null;n(e.subarray(t,t+s)),t+=s}return s.length?Buffer.concat(s):null}if(25===t){let t=3;if(t>e.length)return null;for(;t+2<=e.length;){const s=e.readUInt16BE(t);if(t+=2,s<=0||t+s>e.length)return null;n(e.subarray(t,t+s)),t+=s}return s.length?Buffer.concat(s):null}if(26===t){let t=3;if(t>e.length)return null;for(;t+2<=e.length;){const s=e.readUInt16BE(t);if(t+=2,t+1+2>e.length)return null;if(t+=1,t+=2,s<=0||t+s>e.length)return null;n(e.subarray(t,t+s)),t+=s}return s.length?Buffer.concat(s):null}if(27===t){let t=3;if(t>e.length)return null;for(;t+2<=e.length;){const s=e.readUInt16BE(t);if(t+=2,t+1+3>e.length)return null;if(t+=1,t+=3,s<=0||t+s>e.length)return null;n(e.subarray(t,t+s)),t+=s}return s.length?Buffer.concat(s):null}return null}(e);return g||(function(e){if(e.length<1)return!1;const t=e[0];if(void 0===t)return!1;if(128&t)return!1;const s=31&t;return s>=1&&s<=23}(e)?Buffer.concat([E,e]):e)}function y(e){const t=[];for(let s=0;s<e.length-3;s++)0===e[s]&&0===e[s+1]&&(1===e[s+2]?(t.push({idx:s,len:3}),s+=2):0===e[s+2]&&1===e[s+3]&&(t.push({idx:s,len:4}),s+=3));if(0===t.length)return[];const s=[];for(let n=0;n<t.length;n++){const r=t[n],i=r.idx+r.len,A=t[n+1]?t[n+1].idx:e.length;A>i&&s.push(e.subarray(i,A))}return s}function S(e){if(!C(e))return!1;const t=y(e);if(0===t.length)return!1;for(const e of t){if(e.length<1)return!1;const t=e[0];if(void 0===t)return!1;if(128&t)return!1;const s=31&t;if(0===s||s>=24)return!1}return!0}function w(e){const t=y(e);let s=!1,n=!1,r=!1;for(const e of t){const t=31&(e[0]??0);7===t&&(s=!0),8===t&&(n=!0),5===t&&(r=!0)}return r&&s&&n}var D=class e{fuNalHeader=null;fuParts=[];static parseRtpPayload(e){if(!e||e.length<12)return null;if(2!==(e[0]>>6&3))return null;const t=!!(32&e[0]),s=!!(16&e[0]);let n=12+4*(15&e[0]);if(n>e.length)return null;if(s){if(n+4>e.length)return null;if(n+=4+4*e.readUInt16BE(n+2),n>e.length)return null}let r=e.length;if(t){const t=e[e.length-1];if(t<=0||t>e.length)return null;if(r=e.length-t,r<n)return null}return r<=n?null:e.subarray(n,r)}reset(){this.fuNalHeader=null,this.fuParts=[]}push(t){if(0===t.length)return[];const s=e.parseRtpPayload(t);if(s&&(t=s),C(t))return[t];const n=t[0];if(128&n)return[];const r=31&n;if(r>=1&&r<=23)return[Buffer.concat([E,t])];if(24===r){if(t.length<3)return[];let e=1;const s=[];for(;e+2<=t.length;){const n=t.readUInt16BE(e);if(e+=2,n<=0||e+n>t.length)return[];const r=t.subarray(e,e+n);if(e+=n,r.length<1)return[];if(128&r[0])return[];const i=31&r[0];if(0===i||i>=24)return[];s.push(Buffer.concat([E,r]))}return s}if(28===r||29===r){if(t.length<2)return[];const e=t[0],s=t[1],n=!!(128&s),i=!!(64&s),A=224&e|31&s;let o=2;if(29===r){if(t.length<o+2)return[];o+=2}const a=t.subarray(o);if(n)this.fuNalHeader=A,this.fuParts=[a];else{if(null==this.fuNalHeader)return[];this.fuParts.push(a)}if(i&&null!=this.fuNalHeader){const e=Buffer.concat([Buffer.from([this.fuNalHeader]),...this.fuParts]);return this.reset(),[Buffer.concat([E,e])]}return[]}return[]}};var b=Buffer.from([0,0,0,1]),v=Buffer.from([0,0,1]);function N(e){return!(e.length<4)&&(!!e.subarray(0,4).equals(b)||!!e.subarray(0,3).equals(v))}function R(e,t){const s=[];let n=0,r=0;for(;n<e.length;){if(n+4>e.length)return null;const i=t(e,n);if(n+=4,i<=0)return null;if(i>e.length-n)return null;s.push(b),s.push(e.subarray(n,n+i)),n+=i,r++}return 0===r?null:Buffer.concat(s)}function k(e,t){const s=[];let n=0,r=0;for(;n<e.length;){if(n+2>e.length)return null;const i=t(e,n);if(n+=2,i<=0)return null;if(i>e.length-n)return null;s.push(b),s.push(e.subarray(n,n+i)),n+=i,r++}return 0===r?null:Buffer.concat(s)}function T(e,t){const s=[];let n=0,r=0;const i=(e,s)=>{if(s+3>e.length)return 0;const n=e[s],r=e[s+1],i=e[s+2];return"be"===t?(n<<16|r<<8|i)>>>0:(i<<16|r<<8|n)>>>0};for(;n<e.length;){if(n+3>e.length)return null;const t=i(e,n);if(n+=3,t<=0)return null;if(t>e.length-n)return null;s.push(b),s.push(e.subarray(n,n+t)),n+=t,r++}return 0===r?null:Buffer.concat(s)}function F(e){if(N(e))return e;const t=Buffer.from([0,0,0,1]),s=Buffer.from([0,0,1]),n=Math.min(64,e.length),r=e.subarray(0,n).indexOf(t);if(r>0)return e.subarray(r);const i=e.subarray(0,n).indexOf(s);if(i>0)return e.subarray(i);const A=R(e,((e,t)=>e.readUInt32BE(t)));if(A)return A;const o=R(e,((e,t)=>e.readUInt32LE(t)));if(o)return o;const a=T(e,"be");if(a)return a;const c=T(e,"le");if(c)return c;const l=k(e,((e,t)=>e.readUInt16BE(t)));if(l)return l;const h=k(e,((e,t)=>e.readUInt16LE(t)));return h||(function(e){if(e.length<2)return!1;const t=e[0],s=e[1];return void 0!==t&&void 0!==s&&(!(128&t)&&(t>>1&63)<=40)}(e)?Buffer.concat([b,e]):e)}var M=class e{fuParts=null;reset(){this.fuParts=null}static parseRtpPayload(e){if(!e||e.length<12)return null;if(2!==(e[0]>>6&3))return null;const t=!!(32&e[0]),s=!!(16&e[0]);let n=12+4*(15&e[0]);if(n>e.length)return null;if(s){if(n+4>e.length)return null;if(n+=4+4*e.readUInt16BE(n+2),n>e.length)return null}let r=e.length;if(t){const t=e[e.length-1];if(t<=0||t>e.length)return null;if(r=e.length-t,r<n)return null}return r<=n?null:e.subarray(n,r)}push(t){if(!t||t.length<2)return[];const s=e.parseRtpPayload(t);s&&(t=s);const n=t[0],r=t[1];if(128&n)return[];const i=n>>1&63;if(48===i){let e=2;const s=[];for(;e+2<=t.length;){const n=t.readUInt16BE(e);if(e+=2,n<=0||e+n>t.length)return[];const r=t.subarray(e,e+n);e+=n,r.length&&s.push(b,r)}return s.length?[Buffer.concat(s)]:[]}if(49===i){if(t.length<3)return[];const e=t[2],s=!!(128&e),i=!!(64&e),A=129&n|(63&(63&e))<<1,o=r,a=t.subarray(3);if(s)this.fuParts=[b,Buffer.from([A,o]),a];else{if(!this.fuParts)return[];this.fuParts.push(a)}if(i){if(!this.fuParts)return[];const e=Buffer.concat(this.fuParts);return this.fuParts=null,[e]}return[]}return[Buffer.concat([b,t])]}};function U(e){const t=[];for(let s=0;s<e.length-3;s++)0===e[s]&&0===e[s+1]&&(1===e[s+2]?(t.push({idx:s,len:3}),s+=2):0===e[s+2]&&1===e[s+3]&&(t.push({idx:s,len:4}),s+=3));if(0===t.length)return[];const s=[];for(let n=0;n<t.length;n++){const r=t[n],i=r.idx+r.len,A=t[n+1]?t[n+1].idx:e.length;A>i&&s.push(e.subarray(i,A))}return s}function L(e){if(e.length<1)return null;const t=e[0];return void 0===t||128&t?null:t>>1&63}function P(e){return e>=16&&e<=23}function H(e){if(!N(e))return!1;const t=U(e);if(0===t.length)return!1;for(const e of t){if(e.length<2)return!1;const t=e[0];if(void 0===t)return!1;if(128&t)return!1;const s=L(e);if(null===s)return!1;if(s>40)return!1}return!0}function x(e){const t=U(e);let s=!1,n=!1,r=!1,i=!1;for(const e of t){const t=L(e);null!==t&&(32===t&&(s=!0),33===t&&(n=!0),34===t&&(r=!0),P(t)&&(i=!0))}return i&&s&&n&&r}function Y(e){const t=U(e);for(const e of t){if(32===L(e))return e}return null}function V(e){const t=U(e);for(const e of t){if(33===L(e))return e}return null}function O(e){const t=U(e);for(const e of t){if(34===L(e))return e}return null}var G=Buffer.from([0,0,0,1]),J=class{running=!1;queue=[];maxQueueSize;constructor(e){this.maxQueueSize=e}enqueue(e){this.queue.length>=this.maxQueueSize||(this.queue.push(e),this.pump())}pump(){this.running||(this.running=!0,this.run())}async run(){try{for(;this.queue.length>0;){const e=this.queue.shift();if(e)try{await e()}catch{}}}finally{this.running=!1}}};function W(e){const t=[];for(let s=0;s<e.length;s++)s>=2&&3===e[s]&&0===e[s-1]&&0===e[s-2]||t.push(e[s]);return Buffer.from(t)}var _=class{b;bitPos=0;constructor(e){this.b=e}readBits(e){if(e<=0)return 0;let t=0;for(let s=0;s<e;s++){const e=this.bitPos>>3;if(e>=this.b.length)return null;const s=7-(7&this.bitPos);t=t<<1|this.b[e]>>s&1,this.bitPos++}return t>>>0}readUE(){let e=0;for(;;){const t=this.readBits(1);if(null==t)return null;if(0!==t)break;if(e++,e>31)return null}const t=e?this.readBits(e):0;return null==t?null:(1<<e)-1+t>>>0}};function $(e){if(7!=(31&(e[0]??0)))return null;const t=W(e.subarray(1)),s=new _(t);return null==s.readBits(8)||null==s.readBits(8)||null==s.readBits(8)?null:s.readUE()}function q(e){if(8!=(31&(e[0]??0)))return null;const t=W(e.subarray(1)),s=new _(t),n=s.readUE(),r=s.readUE();return null==n||null==r?null:{ppsId:n,spsId:r}}function z(e){const t=31&(e[0]??0);if(1!==t&&5!==t)return null;const s=W(e.subarray(1)),n=new _(s);return null==n.readUE()||null==n.readUE()?null:n.readUE()}var X=class e extends A.EventEmitter{client;api;channel;profile;logger;active=!1;videoFrameHandler;expectedStreamType;activeMsgNum;bcMediaCodec;debugH264LogsLeft;debugSavedSamples;warnedNonAnnexBOnce=!1;depacketizer=new D;depacketizerH265=new M;dumpChunkIdx=0;dumpNalLines=0;dumpIo=new J(200);spsById=new Map;ppsById=new Map;lastSps=null;lastPps=null;lastPrependedPpsId=null;lastVps=null;lastSpsH265=null;lastPpsH265=null;lastPrependedParamSetsH265=!1;lastMediaAtMs=0;watchdogTimer;restarting=!1;restartWindowStartMs=0;restartCountInWindow=0;idleRestartMs;static scoreBcMediaLike(e){if(e.length<4)return{score:-1,first:-1};const t=Math.min(65536,e.length-4);let s=0,n=-1;for(let r=0;r<=t;r++){const t=e.readUInt32LE(r);if((825241649===t||842018865===t||t>=1667510320&&t<=1667510329||t>=1667510576&&t<=1667510585||1651979568===t||1651978544===t)&&(s++,n<0&&(n=r),s>32&&0===n))break}return{score:1e3*s-(n<0?5e4:n),first:n}}chooseDecryptedOrRawCandidate(t){const{raw:s,enc:n,channelId:r,allowResync:i}=t,A=e.scoreBcMediaLike(s),o="aes"===this.client.enc.kind||"full_aes"===this.client.enc.kind||"bc"===this.client.enc.kind?this.client.tryDecryptBinary(s,r,n):s,a=e.scoreBcMediaLike(o).score>A.score?o:s;if(!i)return a;const c=e.scoreBcMediaLike(a);return c.first>0?a.subarray(c.first):a}constructor(e){super(),this.client=e.client,this.api=e.api,this.channel=e.channel,this.profile=e.profile,this.logger=e.logger,this.expectedStreamType="sub"===this.profile?1:0,this.bcMediaCodec=new I(!1,this.logger);const t=this.client.getDebugConfig();this.debugH264LogsLeft=t.debugH264?200:0,this.debugSavedSamples=!1,this.dumpChunkIdx=0,this.spsById=new Map,this.ppsById=new Map,this.lastSps=null,this.lastPps=null,this.lastPrependedPpsId=null,this.lastVps=null,this.lastSpsH265=null,this.lastPpsH265=null,this.lastPrependedParamSetsH265=!1;const s=this.client.getTransport?.();this.idleRestartMs="udp"===s?6e3:15e3}noteMediaActivity(){this.lastMediaAtMs=Date.now()}startWatchdog(){this.api&&(this.watchdogTimer||(this.restartWindowStartMs=Date.now(),this.restartCountInWindow=0,this.watchdogTimer=setInterval((()=>{this.watchdogTick()}),1e3)))}stopWatchdog(){this.watchdogTimer&&clearInterval(this.watchdogTimer),this.watchdogTimer=void 0}async watchdogTick(){if(!this.active)return;if(!this.api)return;if(this.restarting)return;if(this.lastMediaAtMs<=0)return;const e=Date.now(),t=e-this.lastMediaAtMs;t<this.idleRestartMs||(e-this.restartWindowStartMs>6e4&&(this.restartWindowStartMs=e,this.restartCountInWindow=0),this.restartCountInWindow++,this.restartNativeStream({reason:`idle ${t}ms`}))}async restartNativeStream(e){if(this.api&&this.active&&!this.restarting){this.restarting=!0;try{const t=this.client.getTransport?.()??"unknown",s=this.activeMsgNum??"unknown";this.logger?.warn(`[BaichuanVideoStream] Watchdog restarting native stream (channel=${this.channel} profile=${this.profile} streamType=${this.expectedStreamType} msgNum=${s} transport=${t} reason=${e.reason})`),this.depacketizer.reset(),this.depacketizerH265.reset(),this.bcMediaCodec.clear(),this.activeMsgNum=void 0,this.lastPrependedPpsId=null,this.lastPrependedParamSetsH265=!1;try{await this.api.stopVideoStream(this.channel,this.profile)}catch{}await this.api.startVideoStream(this.channel,this.profile);try{const e=this.api.getActiveVideoMsgNum;this.activeMsgNum="function"==typeof e?e(this.channel,this.profile):void 0}catch{this.activeMsgNum=void 0}this.lastMediaAtMs=Date.now()}catch(e){const t=e instanceof Error?e:new Error(String(e));this.emit("error",t)}finally{this.restarting=!1}}}async start(){if(this.active)throw new Error("Video stream already active");if(this.depacketizer.reset(),this.depacketizerH265.reset(),this.api)try{await this.api.startVideoStream(this.channel,this.profile);try{const e=this.api.getActiveVideoMsgNum;this.activeMsgNum="function"==typeof e?e(this.channel,this.profile):void 0}catch{this.activeMsgNum=void 0}}catch(e){const t=e instanceof Error?e:new Error(String(e));if("udp"===this.client.getTransport?.())throw t;this.emit("error",t)}let e=0,t=0;this.videoFrameHandler=s=>{if(3!==s.header.cmdId)return;if(s.header.streamType!==this.expectedStreamType)return;if(void 0!==this.activeMsgNum&&s.header.msgNum!==this.activeMsgNum)return;e++;const i=this.client.getDebugConfig(),A=i.debugRtsp;1===e&&A&&this.logger?.log(`[BaichuanVideoStream] First cmd_id=3 frame received (bodyLen: ${s.body.length}, channelId: ${s.header.channelId})`),(e%10==0||e<=5)&&A&&this.logger?.log(`[BaichuanVideoStream] Received ${e} Baichuan frames (cmd_id=3)`);const o=this.client.enc,a=s.payload.length>0?s.payload:s.body;let l=a;if(0===s.payload.length){let e=0;const t=a.indexOf(Buffer.from("</Extension>")),s=a.indexOf(Buffer.from("</body>"));-1!==t?e=t+Buffer.from("</Extension>").length:-1!==s&&(e=s+Buffer.from("</body>").length),l=a.subarray(e)}const h=this.chooseDecryptedOrRawCandidate({raw:l,enc:o,channelId:s.header.channelId,allowResync:0===s.payload.length});if(1===e&&A&&this.logger?.log(`[BaichuanVideoStream] Data after XML: ${h.length} bytes, first 32 bytes: ${h.subarray(0,Math.min(32,h.length)).toString("hex")}`),i.dumpEnabled&&c(i),i.dumpBcMedia&&this.dumpChunkIdx<200){const e=i.dumpDir,t=String(this.dumpChunkIdx).padStart(4,"0"),s=r.join(e,`bcmedia_chunk_${t}.bin`),A=r.join(e,"bcmedia_info.json"),o=Buffer.from(h),a=0===this.dumpChunkIdx,c=a?JSON.stringify({note:"Chunks fed into the BcMedia decoder (after XML stripping/alignment).",profile:this.profile,channel:this.channel,encKind:this.client.enc.kind},null,2):"";this.dumpIo.enqueue((async()=>{await n.promises.writeFile(s,o),a&&await n.promises.writeFile(A,c)})),this.dumpChunkIdx++}const g=this.bcMediaCodec.decode(h);t+=g.length;const d=new Map;for(const e of g)d.set(e.type,(d.get(e.type)||0)+1);if(e<=10||e%20==0){const s=this.bcMediaCodec.getRemainingBuffer(),n=Array.from(d.entries()).map((([e,t])=>`${e}:${t}`)).join(", ");A&&this.logger?.log(`[BaichuanVideoStream] Frame #${e}: dataToParse=${h.length} bytes, parsed ${g.length} BcMedia packets (${n||"none"}), total: ${t}, remaining buffer: ${s.length} bytes`)}let u=0,I=0;for(const t of g){const s=(e,t,s)=>{if("H264"===s){const t=y(e);for(const e of t){const t=31&(e[0]??0);if(7===t){const t=$(e);if(null!=t){if(!l(e))continue;this.spsById.set(t,e),i.debugParamSets&&this.logger?.warn(`[BaichuanVideoStream] Cached H.264 SPS id=${t} len=${e.length}`)}l(e)&&(this.lastSps=e)}if(8===t){const t=q(e);if(t){const s=this.spsById.get(t.spsId);if(s&&!l(s))continue;this.ppsById.set(t.ppsId,{nal:e,spsId:t.spsId}),i.debugParamSets&&this.logger?.warn(`[BaichuanVideoStream] Cached H.264 PPS id=${t.ppsId} (spsId=${t.spsId}) len=${e.length}`)}this.lastPps=e}}}else if("H265"===s){const t=Y(e);t&&(this.lastVps=t,i.debugParamSets&&this.logger?.warn(`[BaichuanVideoStream] Cached H.265 VPS len=${t.length}`));const s=V(e);s&&(this.lastSpsH265=s,i.debugParamSets&&this.logger?.warn(`[BaichuanVideoStream] Cached H.265 SPS len=${s.length}`));const n=O(e);n&&(this.lastPpsH265=n,i.debugParamSets&&this.logger?.warn(`[BaichuanVideoStream] Cached H.265 PPS len=${n.length}`))}},o=(e,t)=>{if("H264"===t){const t=y(e);if(0===t.length)return e;const s=t.map((e=>31&(e[0]??0)));if(s.includes(7)&&s.includes(8))return e;if(!s.some((e=>1===e||5===e||19===e||20===e)))return e;let n=null;for(const e of t){const t=31&(e[0]??0);if(1===t||5===t){n=z(e);break}}if(i.debugParamSets&&this.logger?.warn(`[BaichuanVideoStream] Slice references ppsId=${n??"?"} lastPrepended=${this.lastPrependedPpsId??"?"}`),null==n||n>255)return null!=this.lastPrependedPpsId?e:this.lastSps&&this.lastPps?(this.lastPrependedPpsId=-1,Buffer.concat([G,this.lastSps,G,this.lastPps,e])):e;if(this.lastPrependedPpsId===n)return e;const r=this.ppsById.get(n);if(r){const t=this.spsById.get(r.spsId);if(t)return this.lastPrependedPpsId=n,Buffer.concat([G,t,G,r.nal,e])}return Buffer.alloc(0)}if("H265"===t){const t=U(e);if(0===t.length)return e;const s=t.map((e=>L(e))).filter((e=>null!==e));if(s.includes(32)&&s.includes(33)&&s.includes(34))return e;return s.some((e=>e>=0&&e<=9||e>=16&&e<=23))?this.lastPrependedParamSetsH265?e:this.lastVps&&this.lastSpsH265&&this.lastPpsH265?(this.lastPrependedParamSetsH265=!0,i.debugParamSets&&this.logger?.warn("[BaichuanVideoStream] Prepending H.265 VPS/SPS/PPS to frame"),Buffer.concat([G,this.lastVps,G,this.lastSpsH265,G,this.lastPpsH265,e])):e:e}return e},a=(e,t,s)=>{if(i.dumpNals)try{i.dumpEnabled&&c(i);const A=i.dumpDir,o=y(e),a=o.map((e=>31&(e[0]??0)));let l=null;const h=[],g=[];for(const e of o){const t=31&(e[0]??0);if(1!==t&&5!==t||null!=l||(l=z(e)),7===t){const t=$(e);null!=t&&h.push(t)}if(8===t){const t=q(e);t&&g.push(t.ppsId)}}if(this.dumpNalLines>=2e4)return;const d=JSON.stringify({label:t,microseconds:s,len:e.length,nalTypes:a,slicePpsId:l,auSpsIds:h,auPpsIds:g,cachedSps:this.spsById.size,cachedPps:this.ppsById.size,lastPrependedPpsId:this.lastPrependedPpsId})+"\n";this.dumpNalLines++;const u=r.join(A,"nal_dump.ndjson");this.dumpIo.enqueue((async()=>{await n.promises.appendFile(u,d)}))}catch{}},l=e=>{if(e.length<4)return!1;if(7!=(31&(e[0]??0)))return!1;const t=e[1]??0,s=e[3]??0;return!!new Set([66,77,88,100,110,122,244]).has(t)&&!(0===s||s>255)};if("Iframe"===t.type){const c="H265"===t.videoType?F(t.data):m(t.data),l=!0;s(c,"Iframe",t.videoType);const h=o(c,t.videoType);if(0===h.length)continue;if(a(h,"Iframe",t.microseconds),"H264"===t.videoType){if(!S(h)||!w(h)){i.debugH264&&this.logger?.warn(`[BaichuanVideoStream] Dropping invalid H.264 Iframe (Annex-B) len=${h.length}`);continue}}else if("H265"===t.videoType){if(!H(h)){i.debugH264&&this.logger?.warn(`[BaichuanVideoStream] Dropping invalid H.265 Iframe (Annex-B) len=${h.length}`);continue}x(h)||i.debugH264&&this.logger?.warn(`[BaichuanVideoStream] H.265 Iframe missing VPS/SPS/PPS or IRAP, but continuing len=${h.length}`)}if(i.debugH264&&!this.debugSavedSamples)try{const e=i.dumpDir;n.mkdirSync(e,{recursive:!0}),"Iframe"===t.type&&C(c)&&n.writeFileSync(r.join(e,"iframe_annexb.bin"),c)}catch{}if(!this.warnedNonAnnexBOnce&&!C(c)){this.warnedNonAnnexBOnce=!0;const e=t.data,s=e.subarray(0,Math.min(24,e.length)).toString("hex"),n=c.subarray(0,Math.min(24,c.length)).toString("hex");this.logger?.warn(`[BaichuanVideoStream] WARNING: non-AnnexB frame after conversion (${t.type} ${t.videoType}) len=${e.length} head=${s} convertedLen=${c.length} convertedHead=${n}`)}if(this.emit("videoFrame",h),this.emit("videoAccessUnit",{data:h,isKeyframe:l,videoType:t.videoType,microseconds:t.microseconds,..."Iframe"===t.type&&"time"in t&&void 0!==t.time?{time:t.time}:{}}),u++,e<=5||u<=5){const e=C(c)?"yes":"no";A&&this.logger?.log(`[BaichuanVideoStream] Emitted ${t.type} (${t.videoType}) ${t.data.length} bytes -> ${c.length} bytes (Annex-B, startCode:${e})`)}}else if("Pframe"===t.type){const e=t.data,n=C(e)?e:"H265"===t.videoType?F(e):m(e),r=C(n)?[n]:"H265"===t.videoType?this.depacketizerH265.push(e):this.depacketizer.push(e);if(0===r.length)continue;for(const e of r){s(e,"Pframe",t.videoType);const n=o(e,t.videoType);if(0===n.length)continue;const r=n;a(r,"Pframe",t.microseconds);if("H265"===t.videoType?H(r):S(r))this.emit("videoFrame",r),this.emit("videoAccessUnit",{data:r,isKeyframe:!1,videoType:t.videoType,microseconds:t.microseconds}),u++;else if(i.debugH264&&this.debugH264LogsLeft>0){this.debugH264LogsLeft--;const e=r.subarray(0,Math.min(24,r.length)).toString("hex");this.logger?.warn(`[BaichuanVideoStream] Dropping invalid Pframe (${t.videoType}): len=${r.length} head=${e}`)}}}"Aac"!==t.type&&"Adpcm"!==t.type||(I++,this.emit("audioFrame",t.data)),"InfoV1"===t.type||t.type}if((e<=10||e%20==0&&(u>0||I>0))&&A&&this.logger?.log(`[BaichuanVideoStream] Frame #${e}: emitted ${u} video frames, ${I} audio frames`),(u>0||I>0)&&this.noteMediaActivity(),u>0&&(e<=10||e%50==0)){}},this.client.on("push",this.videoFrameHandler),this.active=!0,this.lastMediaAtMs=Date.now(),this.startWatchdog()}async stop(){if(this.active){if(this.stopWatchdog(),this.depacketizer.reset(),this.depacketizerH265.reset(),this.videoFrameHandler&&this.client.removeListener("push",this.videoFrameHandler),this.videoFrameHandler=void 0,this.bcMediaCodec.clear(),this.activeMsgNum=void 0,this.api)try{await this.api.stopVideoStream(this.channel,this.profile)}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}this.active=!1,this.emit("close")}}isActive(){return this.active}};function j(e){const t=e.port??554,s=function(e,t){let s;return s="main"===t?"main":"sub"===t?"sub":"ext",`/h264Preview_${String(e+1).padStart(2,"0")}_${s}`}(e.channel,e.stream);return`rtsp://${encodeURIComponent(e.username)}:${encodeURIComponent(e.password)}@${e.host}:${t}${s}`}var Z=9e3,K=Buffer.from([240,222,188,10]),ee=Buffer.from([160,203,237,15]),te=Uint8Array.from([31,45,60,75,90,105,120,255]),se=Buffer.from("0123456789abcdef","utf8"),ne=25876,re=25620,ie=0,Ae=25730;function oe(e){return e===re||e===ie||e===Ae}var ae=3,ce=4,le=13,he=14,ge=15,de=16,ue=272,Ie=273,Ee=274,pe=10,Ce=11,Be=201,Qe=202,fe=18,me=19,ye=190,Se=433,we=294,De=295,be=252,ve=253,Ne=234,Re=212,ke=213,Te=47,Fe=343,Me=547,Ue=263,Le=289,Pe=288,He=290,xe=291,Ye=151,Ve=199,Oe=93;function Ge(e){if(e instanceof Error)return e.stack||e.message;try{return JSON.stringify(e)}catch{return String(e)}}async function Je(e){try{return{ok:!0,value:await e()}}catch(e){return{ok:!1,error:Ge(e)}}}function We(e){n.mkdirSync(e,{recursive:!0})}function _e(e,t){We(r.dirname(e)),n.writeFileSync(e,JSON.stringify(t,null,2))}function $e(e,t){We(r.dirname(e)),n.appendFileSync(e,JSON.stringify(t)+"\n")}function qe(e){return new Promise((t=>setTimeout(t,e)))}function ze(){return(new Date).toISOString().replace(/[:.]/g,"-")}function Xe(e,t){if("H264"===e){return y(t).map((e=>31&(e[0]??0)))}return U(t).map((e=>L(e))).filter((e=>"number"==typeof e))}async function je(e){const t=e.outDir;We(t);const[s,n]=await Promise.all([e.native?Je((()=>async function(e){const{api:t}=e,s=e.channel??0,n={kind:"native",channel:s,transport:t.client.getTransport?.(),encKind:t.client.enc?.kind,collectedAt:(new Date).toISOString()},[r,i,A,o,a,c,l]=await Promise.all([Je((()=>t.getInfo(s))),Je((()=>t.getPorts())),Je((()=>t.getStreamMetadata(s))),Je((()=>t.getAbilityInfo())),Je((()=>t.getDeviceCapabilities(s,{probe:!1}))),Je((()=>t.getTalkAbility(s))),Je((()=>t.getTwoWayAudioConfig(s)))]);if(n.info=r,n.ports=i,n.streamMetadata=A,n.abilityInfo=o,n.deviceCapabilities=a,n.talkAbility=c,n.twoWayAudio=l,c?.ok&&c.value){const e=c.value,t={duplex:Array.isArray(e.duplexList)?e.duplexList[0]:void 0,audioStreamMode:Array.isArray(e.audioStreamModeList)?e.audioStreamModeList[0]:void 0,audioConfig:Array.isArray(e.audioConfigList)?e.audioConfigList[0]:void 0};n.intercomRecommended=t}return n}(e.native))):Promise.resolve(void 0),e.cgi?Je((()=>async function(e){const{cgi:t}=e,s=e.channel??0,n={kind:"cgi",channel:s,collectedAt:(new Date).toISOString()},[r,i,A,o,a,c,l]=await Promise.all([Je((()=>t.getInfo(s))),Je((()=>t.GetNetPort())),Je((()=>t.GetAbility())),Je((()=>t.GetEnc(s))),Je((()=>t.GetChannelstatus())),Je((()=>t.GetChnTypeInfo(s))),Je((()=>t.GetAiState(s)))]);return n.info=r,n.netPort=i,n.ability=A,n.enc=o,n.channelStatus=a,n.channelTypeInfo=c,n.aiState=l,n.devicesInfo=await Je((()=>t.getDevicesInfo())),n}(e.cgi))):Promise.resolve(void 0)]),i={createdAt:(new Date).toISOString(),native:s,cgi:n,...e.extra?{extra:e.extra}:{}},A=r.join(t,"diagnostics.json");return _e(A,i),{outDir:t,diagnosticsPath:A}}function Ze(e){return e.replace(/([a-z]+:\/\/)([^:@\/\s]+):([^@\/\s]+)@/gi,((e,t,s,n)=>`${t}***:***@`))}function Ke(e,t){return new Promise((s=>{We(r.dirname(t));const A=n.createWriteStream(t,{flags:"a"}),o=(0,i.spawn)("ffmpeg",e,{stdio:["ignore","ignore","pipe"]});o.on("error",(e=>{A.write(`ffmpeg spawn error: ${e instanceof Error?e.message:String(e)}\n`),A.end(),s({ok:!1,error:e instanceof Error?e.message:String(e)})}));let a="";o.stderr.on("data",(e=>{const t=e.toString();a+=t,A.write(Ze(t))})),o.on("close",(e=>{if(A.end(),0===e)return void s({ok:!0});const t=`ffmpeg exited with code ${e}\n${a.slice(-4e3)}`;s({ok:!1,error:Ze(t)})}))}))}async function et(e){const t=e.durationSeconds??2,s=["-hide_banner","-loglevel","error",..."rtsp"===e.kind?["-rtsp_transport","tcp"]:[],"-i",e.url,"-t",String(t),"-f","null","-"];return new Promise((e=>{const n=(0,i.spawn)("ffmpeg",s,{stdio:["ignore","ignore","pipe"]});let r="",A=!1;n.stderr.on("data",(e=>{const t=e.toString();r+=t,(t.includes("Stream #0")||t.includes("Video:")||t.includes("Audio:")||t.includes("Duration:"))&&(A=!0)})),n.on("close",(s=>{if(0===s||A)e({ok:!0,value:{duration:t}});else{const t=`ffmpeg exited with code ${s}\n${r.slice(-1e3)}`;e({ok:!1,error:Ze(t)})}})),n.on("error",(t=>{const s=t instanceof Error?t.message:String(t);e({ok:!1,error:Ze(s)})}))}))}async function tt(e){const t=["-hide_banner","-loglevel","warning","-stats",..."rtsp"===e.kind?["-rtsp_transport","tcp"]:[],"-i",e.url,"-t",String(e.durationSeconds),"-c","copy","-y",e.outputMp4];return await Ke(t,e.logPath)}async function st(e){const t=`fps=1/${Math.max(.25,e.snapshotIntervalSeconds)}`,s=["-hide_banner","-loglevel","warning","-stats",..."rtsp"===e.kind?["-rtsp_transport","tcp"]:[],"-i",e.url,"-t",String(e.durationSeconds),"-vf",t,"-q:v","2","-y",e.snapshotsPattern];return await Ke(s,e.logPath)}async function nt(e){const t=["-hide_banner","-loglevel","warning","-stats","-f","H265"===e.videoType?"hevc":"h264","-i",e.snapshotAnnexBPath,"-frames:v","1","-q:v","2","-y",e.outputJpegPath];await Ke(t,e.logPath)}async function rt(e){const t=e.channel??0,s=Math.max(250,Math.round(1e3*e.durationSeconds)),i=e.snapshotIntervalSeconds??2,A=e.logger,o=(e,t,s)=>{const n=A?.[e]??A?.log;n&&(void 0!==s?n.call(A,t,s):n.call(A,t))},a=function(e){const t=[];for(const s of e??[])"main"!==s&&"sub"!==s&&"ext"!==s||t.includes(s)||t.push(s);return t}(e.selection.profiles),c=a.length?a:["main","sub","ext"],l=e.outDir;We(l),o("log","[Diagnostics] stream sampling start",{outDir:l,channel:t,durationSeconds:e.durationSeconds,snapshotIntervalSeconds:i,selection:e.selection});const h=r.join(l,"events.ndjson");$e(h,{t:Date.now(),type:"sampling_start",channel:t,durationSeconds:e.durationSeconds,snapshotIntervalSeconds:i,selection:e.selection});for(const A of c)for(const a of e.selection.kinds){const c=`${a}_${A}`,g=r.join(l,c);if(We(g),$e(h,{t:Date.now(),type:"stream_begin",kind:a,profile:A,channel:t}),o("log","[Diagnostics] stream begin",{kind:a,profile:A,channel:t}),"native"!==a)if("rtsp"!==a)if("rtmp"!==a);else{const s=e.rtmp?.urlsByProfile?.[A];if(!s){$e(h,{t:Date.now(),type:"stream_skip",kind:a,profile:A,reason:"rtmp url missing"}),o("warn","[Diagnostics] stream skip (rtmp url missing)",{kind:a,profile:A,channel:t});continue}const n=r.join(g,`clip_${ze()}.mp4`),c=r.join(g,"ffmpeg_record.log"),l=r.join(g,"snapshots");We(l);const d=r.join(l,"snap_%05d.jpg");$e(h,{t:Date.now(),type:"rtmp_url",kind:a,profile:A,url:s});const[u,I]=await Promise.all([tt({kind:"rtmp",url:s,outputMp4:n,durationSeconds:e.durationSeconds,logPath:c}),st({kind:"rtmp",url:s,snapshotsPattern:d,durationSeconds:e.durationSeconds,snapshotIntervalSeconds:i,logPath:r.join(g,"ffmpeg_snapshots.log")})]);$e(h,{t:Date.now(),type:"rtmp_done",kind:a,profile:A,mp4Path:n,record:u,snapshots:I}),o("log","[Diagnostics] stream done",{kind:a,profile:A,channel:t,mp4Path:n,record:u,snapshots:I})}else{if(!e.rtsp){$e(h,{t:Date.now(),type:"stream_skip",kind:a,profile:A,reason:"rtsp config missing"}),o("warn","[Diagnostics] stream skip (rtsp config missing)",{kind:a,profile:A,channel:t});continue}const s=j({host:e.rtsp.host,username:e.rtsp.username,password:e.rtsp.password,channel:t,stream:A,...null!=e.rtsp.port?{port:e.rtsp.port}:{}}),n=r.join(g,`clip_${ze()}.mp4`),c=r.join(g,"ffmpeg_record.log"),l=r.join(g,"snapshots");We(l);const d=r.join(l,"snap_%05d.jpg");$e(h,{t:Date.now(),type:"rtsp_url",kind:a,profile:A,url:s});const[u,I]=await Promise.all([tt({kind:"rtsp",url:s,outputMp4:n,durationSeconds:e.durationSeconds,logPath:c}),st({kind:"rtsp",url:s,snapshotsPattern:d,durationSeconds:e.durationSeconds,snapshotIntervalSeconds:i,logPath:r.join(g,"ffmpeg_snapshots.log")})]);$e(h,{t:Date.now(),type:"rtsp_done",kind:a,profile:A,mp4Path:n,record:u,snapshots:I}),o("log","[Diagnostics] stream done",{kind:a,profile:A,channel:t,mp4Path:n,record:u,snapshots:I})}else{const c=e.native?.api;if(!c){$e(h,{t:Date.now(),type:"stream_skip",kind:a,profile:A,reason:"native api missing"}),o("warn","[Diagnostics] stream skip (native api missing)",{kind:a,profile:A,channel:t});continue}const l=r.join(g,"raw_frames"),d=r.join(g,"snapshots");We(l),We(d);const u=e.limits?.maxNativeRawFrames??400,I=e.limits?.maxNativeRawBytes??52428800;let E=0,p=0;const C="sub"===A?1:0,B=e=>{if(!e?.header)return;if(3!==e.header.cmdId)return;if(e.header.streamType!==C)return;if(E>=u)return;const t=Buffer.isBuffer(e.payload)&&e.payload.length?e.payload:e.body;if(!Buffer.isBuffer(t)||0===t.length)return;if(p+t.length>I)return;E++,p+=t.length;const s=String(E).padStart(6,"0"),i=r.join(l,`frame_${s}.bin`);try{n.writeFileSync(i,t)}catch{}$e(h,{t:Date.now(),type:"native_raw_frame",kind:a,profile:A,idx:E,bytes:t.length,header:e.header,bodyLen:e.body?.length??0,payloadLen:e.payload?.length??0})};c.client.on("frame",B);const Q=new X({client:c.client,api:c,channel:t,profile:A}),f=r.join(g,`clip_${ze()}`),m=f+".annexb",y=f+".audio.bin",S=f+".json",w=n.createWriteStream(m,{flags:"w"}),D=n.createWriteStream(y,{flags:"w"});let b,v=null,N=0,R=0,k=0,T=null;const F=e=>{if(!e||!Buffer.isBuffer(e.data))return;b||(b=e.videoType),N++;try{w.write(e.data)}catch{}e.isKeyframe&&null==v&&(v=Date.now());const t=Xe(e.videoType,e.data);$e(h,{t:Date.now(),type:"native_access_unit",kind:a,profile:A,isKeyframe:!!e.isKeyframe,videoType:e.videoType,microseconds:e.microseconds,bytes:e.data.length,nalTypes:t});const s=Date.now();if(e.isKeyframe&&s-k>=1e3*i){k=s;const t=ze(),i=r.join(d,`snap_${t}.${"H265"===e.videoType?"h265":"h264"}`);try{n.writeFileSync(i,e.data),$e(h,{t:Date.now(),type:"native_snapshot_saved",kind:a,profile:A,path:i});const s=r.join(d,`snap_${t}.jpg`);nt({videoType:e.videoType,snapshotAnnexBPath:i,outputJpegPath:s,logPath:r.join(g,"ffmpeg_snapshot.log")})}catch{}}},M=e=>{if(Buffer.isBuffer(e)&&0!==e.length){R++;try{D.write(e)}catch{}$e(h,{t:Date.now(),type:"native_audio",kind:a,profile:A,bytes:e.length})}};Q.on("videoAccessUnit",F),Q.on("audioFrame",M),Q.on("error",(e=>{$e(h,{t:Date.now(),type:"native_error",kind:a,profile:A,error:Ge(e)})}));try{for(await Q.start(),$e(h,{t:Date.now(),type:"native_started",kind:a,profile:A}),T=Date.now();Date.now()-T<s;)await qe(200)}finally{try{await Q.stop()}catch{}c.client.removeListener("frame",B);try{w.end()}catch{}try{D.end()}catch{}const s={kind:a,profile:A,channel:t,durationSeconds:e.durationSeconds,videoAccessUnits:N,audioFrames:R,videoType:b,firstKeyframeLatencyMs:null==v||null==T?null:Math.max(0,v-T),rawFrames:E,rawBytes:p};_e(S,s),$e(h,{t:Date.now(),type:"native_done",...s}),o("log","[Diagnostics] stream done",s)}}}$e(h,{t:Date.now(),type:"sampling_done"})}async function it(e){const{cgi:t,logger:s}=e,n=(e,t)=>{s?.log?void 0!==t?s.log(e,t):s.log(e):(console.log(e),void 0!==t&&console.log(JSON.stringify(t,null,2)))},r={kind:"nvr_diagnostics",collectedAt:(new Date).toISOString()};n("=".repeat(80)),n("NVR/HUB DIAGNOSTICS - Starting comprehensive data collection"),n("=".repeat(80)),n("\n[1/7] Collecting NVR/HUB device information...");const i=await Je((()=>t.getNvrInfo()));r.nvrInfo=i,i.ok?n("✓ NVR/HUB info collected",{model:i.value.devInfo?.type,name:i.value.devInfo?.name,firmware:i.value.devInfo?.firmVer,hardware:i.value.devInfo?.hardVer,serial:i.value.devInfo?.serial}):n("✗ Failed to collect NVR/HUB info",i.error),n("\n[2/7] Discovering channels...");const A=await Je((()=>t.getChannels({useChannelNumFallback:!0})));r.channels=A;let o=[];A.ok?(o=A.value.channels,n(`✓ Found ${o.length} channel(s): ${o.join(", ")}`),r.channelList=o):(n("✗ Failed to discover channels",A.error),r.channelList=[]),n("\n[3/7] Collecting devices information for all channels...");const a=await Je((()=>t.getDevicesInfo({useChannelNumFallback:!0})));if(r.devicesInfo=a,a.ok){n(`✓ Devices info collected for ${Object.keys(a.value.devicesData).length} channel(s)`);for(const[e,t]of Object.entries(a.value.devicesData)){const s=t;n(` Channel ${Number(e)}:`,{model:s.channelInfo?.typeInfo||s.channelStatus?.typeInfo,name:s.channelStatus?.name,online:1===s.channelStatus?.online,sleeping:1===s.channelStatus?.sleep,uid:s.channelStatus?.uid,firmware:s.channelInfo?.firmVer,boardInfo:s.channelInfo?.boardInfo})}}else n("✗ Failed to collect devices info",a.error);n("\n[4/7] Collecting events and detection states for all channels...");const c=await Je((()=>t.getAllChannelsEvents({useChannelNumFallback:!0})));if(r.eventsInfo=c,c.ok){n(`✓ Events info collected for ${Object.keys(c.value.parsed).length} channel(s)`);for(const[e,t]of Object.entries(c.value.parsed)){const s=t;n(` Channel ${Number(e)}:`,{motion:s.motion,detectedObjects:s.objects})}}else n("✗ Failed to collect events info",c.error);n("\n[5/7] Collecting battery information for all channels...");const l=await Je((()=>t.getAllChannelsBatteryInfo({useChannelNumFallback:!0})));if(r.batteryInfo=l,l.ok){n(`✓ Battery info collected for ${Object.keys(l.value.batteryInfoData).length} channel(s)`);for(const[e,t]of Object.entries(l.value.batteryInfoData)){const s=t;n(` Channel ${Number(e)}:`,{batteryLevel:s.batteryLevel,sleeping:s.sleeping})}}else n("✗ Failed to collect battery info",l.error);n("\n[6/7] Building device capabilities map...");const h=new Map;if(a.ok&&l.ok){for(const e of o){const t=a.value.devicesData[e],s=l.value.batteryInfoData[e],n=t?.abilities;h.set(e,{hasBattery:void 0!==s?.batteryLevel&&s.batteryLevel>0,hasPirEvents:!!n?.pirAlarm,hasFloodlight:!!n?.ledCtrl,hasPtz:!!n?.ptz,sleeping:s?.sleeping??!1})}n(`✓ Built capabilities map for ${h.size} channel(s)`)}n("\n[7/7] Collecting status information (OSD, Floodlight, PIR, PTZ) for all channels...");const g=await Je((()=>t.getStatusInfo(h)));if(r.statusInfo=g,g.ok){n(`✓ Status info collected for ${Object.keys(g.value.deviceStatusData).length} channel(s)`);for(const[e,t]of Object.entries(g.value.deviceStatusData)){const s=t;n(` Channel ${Number(e)}:`,{osd:s.osd?"configured":"not available",floodlightEnabled:s.floodlightEnabled,pirEnabled:s.pirEnabled,ptzPresets:s.ptzPresets?.length??0})}}else n("✗ Failed to collect status info",g.error);n("\n[8/8] Collecting additional per-channel details...");const d={};for(const e of o){const s={},r=await Je((()=>t.GetOsd(e)));r.ok&&(s.osd=r.value);const i=await Je((()=>t.getLocalLink(e)));i.ok&&(s.localLink=i.value);const A=await Je((()=>t.getPirState(e)));A.ok&&(s.pirState=A.value);const o=await Je((()=>t.getSiren(e)));o.ok&&(s.siren=o.value);const a=await Je((()=>t.GetPtzPreset(e)));a.ok&&(s.ptzPresets=a.value);const c=await Je((()=>t.GetWhiteLed(e)));c.ok&&(s.whiteLed=c.value);const l=await Je((()=>t.GetEnc(e)));l.ok&&(s.encoding=l.value);const h=await Je((()=>t.GetAiState(e)));h.ok&&(s.aiState=h.value);const g=await Je((()=>t.GetMdState(e)));g.ok&&(s.motionDetection=g.value);const u=await Je((()=>t.GetBatteryInfo(e)));u.ok&&(s.battery=u.value);const I=await Je((()=>t.GetChnTypeInfo(e)));I.ok&&(s.channelType=I.value);const E=await Je((()=>t.GetWifiSignal(e)));E.ok&&(s.wifiSignal=E.value),d[e]=s,n(` Channel ${e}: collected ${Object.keys(s).length} detail(s)`)}return r.perChannelDetails=d,n(`✓ Additional details collected for ${Object.keys(d).length} channel(s)`),n("\n"+"=".repeat(80)),n("NVR/HUB DIAGNOSTICS - Summary"),n("=".repeat(80)),n(`Total Channels: ${o.length}`),n("NVR Info: "+(i.ok?"✓":"✗")),n("Devices Info: "+(a.ok?"✓":"✗")),n("Events Info: "+(c.ok?"✓":"✗")),n("Battery Info: "+(l.ok?"✓":"✗")),n("Status Info: "+(g.ok?"✓":"✗")),n(`Per-Channel Details: ✓ (${Object.keys(d).length} channels)`),n("=".repeat(80)),r}function At(e,t){const s=(e,s)=>{t?.log?void 0!==s?t.log(e,s):t.log(e):(console.log(e),void 0!==s&&console.log(JSON.stringify(s,null,2)))};s("\n"+"=".repeat(80)),s("NVR/HUB DIAGNOSTICS REPORT"),s("=".repeat(80));const n=e.nvrInfo;if(n?.ok){s("\n📡 NVR/HUB DEVICE:");const e=n.value.devInfo;e&&(s(` Model: ${e.type||"N/A"}`),s(` Name: ${e.name||"N/A"}`),s(` Firmware: ${e.firmVer||"N/A"}`),s(` Hardware: ${e.hardVer||"N/A"}`),s(` Serial: ${e.serial||"N/A"}`),s(` Item No: ${e.exactType||e.model||"N/A"}`))}const r=e.channelList||[];s(`\n📺 CHANNELS (${r.length}):`);const i=e.devicesInfo;if(i?.ok)for(const t of r){const n=i.value.devicesData?.[t];if(!n)continue;s(`\n ┌─ Channel ${t} ────────────────────────────────────────────────────`);const r=n.channelStatus;r&&(s(" │ Status:"),s(" │ Online: "+(1===r.online?"✓":"✗")),s(" │ Sleeping: "+(1===r.sleep?"Yes":"No")),s(` │ UID: ${r.uid||"N/A"}`),s(` │ Name: ${r.name||"N/A"}`));const A=n.channelInfo;A&&(s(" │ Device Info:"),s(` │ Model: ${A.typeInfo||"N/A"}`),s(` │ Firmware: ${A.firmVer||"N/A"}`),s(` │ Board Info: ${A.boardInfo||"N/A"}`));const o=n.enc;if(o){const e=o.Enc;s(" │ Encoding:"),e&&(s(` │ Main Stream: ${e.mainStream?.vType||"N/A"} ${e.mainStream?.vSize||""}`),s(` │ Sub Stream: ${e.subStream?.vType||"N/A"} ${e.subStream?.vSize||""}`))}const a=n.ai;if(a){s(" │ AI Detection:");const e=Object.keys(a).filter((e=>"channel"!==e));if(e.length>0)for(const t of e){const e=a[t];1===e?.support&&s(` │ ${t}: ${1===e.alarm_state?"Enabled":"Disabled"}`)}else s(" │ No AI detection available")}const c=n.abilities;c&&(s(" │ Capabilities:"),s(" │ Battery: "+(c.battery?"Yes":"No")),s(" │ PTZ: "+(c.ptz?"Yes":"No")),s(" │ Floodlight: "+(c.ledCtrl?"Yes":"No")),s(" │ PIR: "+(c.pirAlarm?"Yes":"No")));const l=e.eventsInfo;if(l?.ok){const e=l.value.parsed?.[t];e&&(s(" │ Events:"),s(" │ Motion: "+(e.motion?"Yes":"No")),s(` │ Detected Objects: ${e.objects?.join(", ")||"None"}`))}const h=e.batteryInfo;if(h?.ok){const e=h.value.batteryInfoData?.[t];e&&(s(" │ Battery:"),s(` │ Level: ${e.batteryLevel}%`),s(" │ Sleeping: "+(e.sleeping?"Yes":"No")))}const g=e.statusInfo;if(g?.ok){const e=g.value.deviceStatusData?.[t];e&&(s(" │ Status:"),e.osd&&s(" │ OSD: Configured"),void 0!==e.floodlightEnabled&&s(" │ Floodlight: "+(e.floodlightEnabled?"On":"Off")),void 0!==e.pirEnabled&&s(" │ PIR: "+(e.pirEnabled?"Enabled":"Disabled")),e.ptzPresets&&s(` │ PTZ Presets: ${e.ptzPresets.length}`))}const d=e.perChannelDetails;if(d?.[t]){const e=d[t];if(s(" │ Additional Details:"),e.localLink){const t=e.localLink;s(` │ Connection: ${t.activeLink||"N/A"}`),s(" │ WiFi Signal: "+(void 0!==t.wifiSignal?`${t.wifiSignal}/4`:"N/A"))}if(e.siren){s(" │ Siren: "+(e.siren.enabled?"Enabled":"Disabled"))}}s(" └────────────────────────────────────────────────────────────────────")}s("\n"+"=".repeat(80))}async function ot(e){const{api:t,channel:s,logger:n}=e,r=(e,t)=>{n?.log?void 0!==t?n.log(e,t):n.log(e):(console.log(e),void 0!==t&&console.log(JSON.stringify(t,null,2)))},i={kind:"channel_stream_test",channel:s,collectedAt:(new Date).toISOString(),streams:{}};r("=".repeat(80)),r(`STREAM TEST - Channel ${s}`),r("=".repeat(80)),r(`\n[1/3] Getting available stream options for channel ${s}...`);const A=await Je((()=>t.getEncXml(s)));if(A.ok){const e=A.value,n={mainStream:/<mainStream\b/.test(e),subStream:/<subStream\b/.test(e),extStream:/<extStream\b/.test(e),thirdStream:/<thirdStream\b/.test(e),externStream:/<externStream\b/.test(e),extraStream:/<extraStream\b/.test(e)};r(` Raw GetEnc XML stream tags present: ${JSON.stringify(n)}`);r(` GetEnc XML preview:\n${e.length>2e3?e.substring(0,2e3)+`\n... (truncated, total length: ${e.length})`:e}`);const o=await Je((()=>t.getStreamMetadata(s)));if(o.ok){const t=o.value.streams.map((e=>e.profile));r(` Parsed streams from metadata: ${t.join(", ")} (${t.length} total)`),i.rawEncXml=e,i.encXmlTagsPresent=n,i.parsedStreamProfiles=t}}const o=await Je((()=>t.buildVideoStreamOptions(s)));if(!o.ok)return r(`✗ Failed to get stream options: ${o.error}`),i.error=o.error,i;const{nativeStreams:a,rtspStreams:c,rtmpStreams:l}=o.value;r(`✓ Found ${a.length} native, ${c.length} RTSP, ${l.length} RTMP stream(s)`);const h=a.map((e=>e.profile)).join(", "),g=c.map((e=>e.profile)).join(", "),d=l.map((e=>e.profile)).join(", ");r(` Native profiles: [${h||"none"}]`),r(` RTSP profiles: [${g||"none"}]`),r(` RTMP profiles: [${d||"none"}]`);const u={};r("\n[2/3] Testing RTSP streams with ffmpeg...");for(const e of c){const t=`rtsp_${e.profile}`;r(` Testing RTSP ${e.profile}...`);const s={available:!1,profile:e.profile,container:e.container,url:e.url,urlWithAuth:e.urlWithAuth,metadata:e.metadata},n=e.urlWithAuth,i=await et({url:n,kind:"rtsp",durationSeconds:2});i.ok?(s.available=!0,s.ffmpegSuccess=!0,e.metadata?(s.codec=e.metadata.videoEncType,s.width=e.metadata.width,s.height=e.metadata.height,s.fps=e.metadata.frameRate,s.bitRate=e.metadata.bitRate,s.audio=1===e.metadata.audio,r(` ✓ Available: ${e.metadata.width}x${e.metadata.height} @ ${e.metadata.frameRate}fps, ${e.metadata.videoEncType}`)):r(" ✓ Available (ffmpeg test passed)")):(s.available=!1,s.error=i.error,r(` ✗ Not available: ${i.error}`)),u[t]=s}r("\n[3/4] Testing RTMP streams with ffmpeg...");for(const e of l){const t=`rtmp_${e.profile}`;r(` Testing RTMP ${e.profile}...`);const s={available:!1,profile:e.profile,container:e.container,url:e.url,urlWithAuth:e.urlWithAuth,metadata:e.metadata},n=e.urlWithAuth,i=await et({url:n,kind:"rtmp",durationSeconds:2});i.ok?(s.available=!0,s.ffmpegSuccess=!0,e.metadata?(s.codec=e.metadata.videoEncType,s.width=e.metadata.width,s.height=e.metadata.height,s.fps=e.metadata.frameRate,s.bitRate=e.metadata.bitRate,s.audio=1===e.metadata.audio,r(` ✓ Available: ${e.metadata.width}x${e.metadata.height} @ ${e.metadata.frameRate}fps, ${e.metadata.videoEncType}`)):r(" ✓ Available (ffmpeg test passed)")):(s.available=!1,s.error=i.error,r(` ✗ Not available: ${i.error}`)),u[t]=s}r("\n[4/4] Testing native Baichuan streams...");for(const e of a){const n=`native_${e.profile}`;r(` Testing native ${e.profile}...`);const i={available:!1,profile:e.profile,container:e.container,metadata:e.metadata};try{await t.startVideoStream(s,e.profile);const n=new Promise((e=>{let s=!1;const n=setTimeout((()=>{t.client.off("push",r),e(s)}),5e3),r=i=>{i?.header?.cmdId===ae&&(s=!0,clearTimeout(n),t.client.off("push",r),e(!0))};t.client.on("push",r)}));await n?(i.available=!0,i.frameReceived=!0,e.metadata?(i.codec=e.metadata.videoEncType,i.width=e.metadata.width,i.height=e.metadata.height,i.fps=e.metadata.frameRate,i.bitRate=e.metadata.bitRate,i.audio=1===e.metadata.audio,r(` ✓ Available: ${e.metadata.width}x${e.metadata.height} @ ${e.metadata.frameRate}fps, ${e.metadata.videoEncType}`)):r(" ✓ Available (frame received)")):(i.available=!1,i.error="Timeout waiting for video frame",r(" ✗ Not available: timeout waiting for video frame")),await t.stopVideoStream(s,e.profile)}catch(e){i.available=!1,i.error=Ge(e),r(` ✗ Not available: ${i.error}`)}u[n]=i}i.streams=u,r("\n"+"=".repeat(80)),r("STREAM TEST SUMMARY"),r("=".repeat(80));r(`Available streams: ${Object.values(u).filter((e=>!0===e.available)).length}/${Object.keys(u).length}`);for(const[e,t]of Object.entries(u)){const s=t;r(` ${e}: ${s.available?"✓":"✗"} ${s.codec||"N/A"} ${s.width||""}x${s.height||""}`)}return r("=".repeat(80)),i}async function at(e){const{api:t,logger:s}=e,n=(e,t)=>{s?.log?void 0!==t?s.log(e,t):s.log(e):(console.log(e),void 0!==t&&console.log(JSON.stringify(t,null,2)))},r={kind:"multifocal_diagnostics",collectedAt:(new Date).toISOString()};n("=".repeat(80)),n("MULTI-FOCAL DEVICE DIAGNOSTICS - Starting comprehensive analysis"),n("=".repeat(80)),n("\n[1/4] Checking device capabilities...");const i=await Je((()=>t.getDeviceCapabilities()));if(!i.ok)return n(`✗ Failed to get device capabilities: ${i.error}`),r.error=i.error,r;const A=i.value.support,o=A?.channelNum??1;n(`✓ Device channelNum: ${o}`),2!==o&&3!==o&&(n(`⚠ Warning: channelNum is ${o}, expected 2 or 3 for multi-focal device`),r.warning=`channelNum is ${o}, expected 2 or 3`),r.channelNum=o,r.deviceInfo=await Je((()=>t.getInfo())),n("\n[2/4] Getting device information...");const a=await Je((()=>t.getInfo()));a.ok&&(n(`✓ Device: ${a.value.type||"N/A"}`),r.deviceInfo=a.value),n(`\n[3/4] Testing all ${o} channel(s)...`);const c={};for(let e=0;e<o;e++){n(`\n--- Channel ${e} ---`);const r=await ot({api:t,channel:e,logger:s});c[e]=r}r.channels=c,n("\n"+"=".repeat(80)),n("MULTI-FOCAL DIAGNOSTICS SUMMARY"),n("=".repeat(80)),n(`Total Channels: ${o}`);for(let e=0;e<o;e++){const t=c[e];if(t?.streams){const s=t.streams;n(` Channel ${e}: ${Object.values(s).filter((e=>!0===e.available)).length}/${Object.keys(s).length} streams available`)}}return n("=".repeat(80)),r}},4157:(e,t,s)=>{"use strict";s.d(t,{ReolinkBaichuanApi:()=>xe,ReolinkCgiApi:()=>se,autoDetectDeviceType:()=>it,createScryptedRfc4571TcpServer:()=>je});var n=s(5940);const r=require("crypto");var i=s(4434);const A=require("net"),o=require("dgram"),a=require("timers");var c=s(9038),l=s(5317);const h=require("fs/promises");var g=s(6928),d=s(9896),u=s(6822);require("os");const I=require("http");function E(e){return function(e){return(0,r.createHash)("md5").update(e,"utf8").digest("hex").toUpperCase()}(e).slice(0,31)}function p(e,t){const s=E(`${e}-${t}`).slice(0,16);return Buffer.from(s,"utf8")}function C(e,t){const s=255&t,r=Buffer.allocUnsafe(e.length);for(let t=0;t<e.length;t++){const i=n.g7[(s+t)%n.g7.length];r[t]=e[t]^i^s}return r}function B(e,t){return C(e,t)}function Q(e,t){if(0===e.length)return Buffer.alloc(0);const s=(0,r.createCipheriv)("aes-128-cfb",t,n.KC);return s.setAutoPadding(!1),Buffer.concat([s.update(e),s.final()])}function f(e,t){if(0===e.length)return Buffer.alloc(0);const s=(0,r.createDecipheriv)("aes-128-cfb",t,n.KC);return s.setAutoPadding(!1),Buffer.concat([s.update(e),s.final()])}function m(e){const t=(0,n.ax)(e.messageClass),s=t?24:20,r=Buffer.alloc(s),i=e.magic??n.Gz;if(4!==i.length)throw new Error("magic must be 4 bytes");return i.copy(r,0),r.writeUInt32LE(e.cmdId>>>0,4),r.writeUInt32LE(e.bodyLen>>>0,8),r.writeUInt8(255&e.channelId,12),r.writeUInt8(255&e.streamType,13),r.writeUInt16LE(65535&e.msgNum,14),r.writeUInt16LE(65535&e.responseCode,16),r.writeUInt16LE(65535&e.messageClass,18),t&&r.writeUInt32LE((e.payloadOffset??0)>>>0,20),r}function y(e){if(e.length<20)throw new Error("not enough data for Baichuan header");const t=e.subarray(0,4);if(!t.equals(n.Gz)&&!t.equals(n.gZ))throw new Error(`invalid Baichuan magic: ${t.toString("hex")}`);const s=e.readUInt32LE(4),r=e.readUInt32LE(8),i=e.readUInt8(12),A=e.readUInt8(13),o=e.readUInt16LE(14),a=e.readUInt16LE(16),c=e.readUInt16LE(18),l=(0,n.ax)(c)?24:20;if(e.length<l)throw new Error("not enough data for Baichuan header (needs 24 bytes)");const h=e.readUInt32LE(12),g={magic:Buffer.from(t),cmdId:s,bodyLen:r,channelId:i,streamType:A,msgNum:o,responseCode:a,messageClass:c};return 24===l&&(g.payloadOffset=e.readUInt32LE(20)),{header:g,headerLen:l,messageKey:h}}var S=class{buffer=Buffer.alloc(0);push(e){if(0===e.length)return[];const t=e;this.buffer=0===this.buffer.length?t:Buffer.concat([this.buffer,t]);const s=[];for(;!(this.buffer.length<4);){if(!this.buffer.subarray(0,4).equals(n.Gz)&&!this.buffer.subarray(0,4).equals(n.gZ)){const e=this.buffer.indexOf(n.Gz),t=this.buffer.indexOf(n.gZ),s=-1===e?t:-1===t?e:Math.min(e,t);if(-1===s){this.buffer=this.buffer.subarray(Math.max(0,this.buffer.length-3));break}if(this.buffer=this.buffer.subarray(s),this.buffer.length<20)break}if(this.buffer.length<20)break;let e;try{e=y(this.buffer)}catch{break}const{header:t,headerLen:r,messageKey:i}=e,A=r+t.bodyLen;if(this.buffer.length<A)break;const o=this.buffer.subarray(0,A),a=o.subarray(r);let c=0;if(24===r){const e=t.payloadOffset??0;c=e>0?Math.min(e,t.bodyLen):0}const l=a.subarray(0,c),h=a.subarray(c);s.push({header:t,body:a,extension:l,payload:h,messageKey:i,raw:o}),this.buffer=this.buffer.subarray(A)}return s}};function w(e){if(null==e||"string"!=typeof e){throw new Error(`xmlEscape: expected string but got ${typeof e}: ${e}`)}return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function D(e){return null==e?'<?xml version="1.0" encoding="UTF-8" ?><Extension version="1.1"></Extension>':`<?xml version="1.0" encoding="UTF-8" ?>\n<Extension version="1.1">\n<channelId>${e}</channelId>\n</Extension>`}function b(e){return null==e?'<?xml version="1.0" encoding="UTF-8" ?><Extension version="1.1"><binaryData>1</binaryData></Extension>':`<?xml version="1.0" encoding="UTF-8" ?>\n<Extension version="1.1">\n<binaryData>1</binaryData>\n<channelId>${e}</channelId>\n</Extension>`}function v(e,t){const s=new RegExp(`<${t}>([^<]*)</${t}>`).exec(e);return s?.[1]}function N(e,t,s,n){let r="";const i=n?.name;"setPos"===s&&void 0!==i&&(r=`<name>${w(i)}</name>`);let A="";return void 0!==n?.enable&&(A=`<enable>${n.enable}</enable>`),`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<PtzPreset version="1.1">\n<channelId>${e}</channelId>\n<presetList>\n<preset>\n<id>${t}</id>\n<command>${s}</command>\n${r}\n${A}\n</preset>\n</presetList>\n</PtzPreset>\n</body>`}function R(e,t){return`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<audioPlayInfo version="1.1">\n${void 0!==e?`<channelId>${e}</channelId>`:""}\n<playMode>2</playMode>\n<playDuration>10</playDuration>\n<playTimes>1</playTimes>\n<onOff>${t}</onOff>\n</audioPlayInfo>\n</body>`}function k(e,t){return`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<audioPlayInfo version="1.1">\n${void 0!==e?`<channelId>${e}</channelId>`:""}\n<playMode>0</playMode>\n<playDuration>10</playDuration>\n<playTimes>${t}</playTimes>\n<onOff>1</onOff>\n</audioPlayInfo>\n</body>`}function T(e,t,s=180){return`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<FloodlightManual version="1.1">\n<channelId>${e}</channelId>\n<status>${t}</status>\n<duration>${s}</duration>\n</FloodlightManual>\n</body>`}var F,M=713543482,U=713543456,L=713543440,P=2015,H=2018;function x(e){const t=function(){if(F)return F;const e=new Uint32Array(256);for(let t=0;t<256;t++){let s=t;for(let e=0;e<8;e++)s=1&s?3988292384^s>>>1:s>>>1;e[t]=s>>>0}return F=e,e}();let s=0;for(let n=0;n<e.length;n++){s=(t[255&(s^e[n])]^s>>>8)>>>0}return s>>>0}var Y=Uint32Array.from([523058251,1517059981,941043275,2188469082,2252282411,2781280216,2205278644,401789861]);function V(e,t){const s=Buffer.allocUnsafe(t.length),n=function*(e){let t=0;for(;;){const s=Y[t%Y.length]+(e>>>0)>>>0;yield 255&s,yield s>>>8&255,yield s>>>16&255,yield s>>>24&255,t++}}(e>>>0);for(let e=0;e<t.length;e++)s[e]=t[e]^n.next().value;return s}function O(e,t){return e.readInt32LE(t)}function G(e,t){const s=V(e,Buffer.from(t,"utf8")),n=x(s),r=Buffer.alloc(20);return r.writeUInt32LE(M,0),r.writeUInt32LE(s.length>>>0,4),r.writeUInt32LE(1,8),r.writeUInt32LE(e>>>0,12),r.writeUInt32LE(n>>>0,16),Buffer.concat([r,s])}function J(e){const t=Buffer.alloc(20);return t.writeUInt32LE(L,0),t.writeInt32LE(0|e.connectionId,4),t.writeUInt32LE(0,8),t.writeUInt32LE(e.packetId>>>0,12),t.writeUInt32LE(e.payload.length>>>0,16),Buffer.concat([t,e.payload])}function W(e){if(e.length<4)throw new Error("BCUDP packet too short");const t=e.readUInt32LE(0);if(t===M){if(e.length<20)throw new Error("BCUDP discovery header too short");const t=e.readUInt32LE(4),s=e.readUInt32LE(8);if(1!==s)throw new Error(`BCUDP discovery unknownA expected 1, got ${s}`);const n=e.readUInt32LE(12),r=e.readUInt32LE(16),i=e.subarray(20);if(i.length<t)throw new Error("BCUDP discovery payload truncated");const A=i.subarray(0,t);if(r>>>0!=x(A)>>>0)throw new Error("BCUDP discovery CRC mismatch");const o=function(e,t){return V(e,t)}(n,A);return{kind:"discovery",tid:n,xml:o.toString("utf8")}}if(t===U){if(e.length<28)throw new Error("BCUDP ack header too short");const t=O(e,4),s=e.readUInt32LE(8);if(0!==s)throw new Error(`BCUDP ack unknownA expected 0, got ${s}`);const n=e.readUInt32LE(12),r=e.readUInt32LE(16),i=e.readUInt32LE(20),A=e.readUInt32LE(24),o=e.subarray(28);if(o.length<A)throw new Error("BCUDP ack payload truncated");return{kind:"ack",connectionId:t,groupId:n,packetId:r,maybeLatency:i,payload:o.subarray(0,A)}}if(t===L){if(e.length<20)throw new Error("BCUDP data header too short");const t=O(e,4),s=e.readUInt32LE(8);if(0!==s)throw new Error(`BCUDP data unknownA expected 0, got ${s}`);const n=e.readUInt32LE(12),r=e.readUInt32LE(16),i=e.subarray(20);if(i.length<r)throw new Error("BCUDP data payload truncated");return{kind:"data",connectionId:t,packetId:n,payload:i.subarray(0,r)}}throw new Error(`Unknown BCUDP magic 0x${t.toString(16)}`)}function _(e){return`<P2P>${e}</P2P>`}function $(e){const t=e.conn??"local";return _(`<C2D_A><sid>${e.sid}</sid><conn>${w(t)}</conn><cid>${e.cid}</cid><did>${e.did}</did><mtu>${e.mtu}</mtu></C2D_A>`)}function q(e){const t=/<D2C_CFM>([\s\S]*?)<\/D2C_CFM>/.exec(e);if(!t)return;const s=t[1]??"",n=/<sid>(-?\d+)<\/sid>/.exec(s)?.[1];if(null==n)return;const r=/<conn>([^<]+)<\/conn>/.exec(s)?.[1],i=/<rsp>(-?\d+)<\/rsp>/.exec(s)?.[1],A=/<cid>(-?\d+)<\/cid>/.exec(s)?.[1],o=/<did>(-?\d+)<\/did>/.exec(s)?.[1];return{sid:Number(n),...null!=r?{conn:r}:{},...null!=i?{rsp:Number(i)}:{},...null!=A?{cid:Number(A)}:{},...null!=o?{did:Number(o)}:{}}}function z(e){const t=/<D2C_T>([\s\S]*?)<\/D2C_T>/.exec(e);if(!t)return;const s=t[1]??"",n=/<sid>(-?\d+)<\/sid>/.exec(s)?.[1],r=/<cid>(-?\d+)<\/cid>/.exec(s)?.[1],i=/<did>(-?\d+)<\/did>/.exec(s)?.[1];if(null==n||null==r||null==i)return;const A=/<conn>([^<]+)<\/conn>/.exec(s)?.[1];return{sid:Number(n),cid:Number(r),did:Number(i),...null!=A?{conn:A}:{}}}function X(e){const t=/<D2C_DISC>([\s\S]*?)<\/D2C_DISC>/.exec(e);if(!t)return;const s=t[1]??"",n=/<cid>(-?\d+)<\/cid>/.exec(s)?.[1],r=/<did>(-?\d+)<\/did>/.exec(s)?.[1];return null!=n&&null!=r?{cid:Number(n),did:Number(r)}:void 0}var j=class{currentValues=[];lastReceiveTime=null;displayValue=0;lastDisplayTime=null;getValue(){return this.displayValue}feed(){const e=performance.now();if(null!==this.lastReceiveTime){const t=1e3*(e-this.lastReceiveTime);this.currentValues.push(t)}if(this.lastReceiveTime=e,null!==this.lastDisplayTime){if(e-this.lastDisplayTime>1e3){this.lastDisplayTime=e;const t=this.currentValues.length;if(t>0){const e=this.currentValues.reduce(((e,t)=>e+t),0);this.displayValue=Math.floor(e/t)}else this.displayValue=0;this.currentValues=[]}}else this.lastDisplayTime=e,this.displayValue=0}},Z=class extends i.EventEmitter{opts;sock;remote;mtu;clientId;cameraId;sid;sendPacketId=0;packetsWant=0;received=new Map;sent=new Map;ackTimer;resendTimer;hbTimer;discoveryTid;acceptSent=!1;lastAcceptAtMs;ackScheduled=!1;ackLatency=new j;lastAckPacket=Buffer.alloc(0);ackSentCount=0;pendingData=[];pendingDataOffset=0;drainScheduled=!1;getKeepAliveTid(){return null!=this.discoveryTid?this.discoveryTid:(0|Math.floor(255*Math.random()))>>>0}constructor(e){super(),this.opts=e,this.mtu=1350}isConnected(){return!!this.sock&&!!this.remote&&null!=this.cameraId}async connect(){if(this.sock)return;const e=o.createSocket("udp4");this.sock=e;try{e.setRecvBufferSize(4194304),e.setSendBufferSize(4194304)}catch(e){}e.on("message",((e,t)=>{try{const s=W(e);this.handlePacket(s,t.address,t.port)}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}})),e.on("error",(e=>this.emit("error",e))),e.on("close",(()=>this.emit("close"))),await new Promise((t=>e.bind(0,"0.0.0.0",(()=>t())))),"direct"===this.opts.mode?(this.remote={host:this.opts.host,port:this.opts.port},this.clientId=this.opts.clientId,this.cameraId=this.opts.cameraId):await this.discoveryUid(e),this.startTimers()}async discoveryUid(e){if("uid"!==this.opts.mode)throw new Error("Internal: discoveryUid called for non-uid mode");const t=[P,H],s="255.255.255.255";e.setBroadcast(!0);const n=e.address(),r="string"==typeof n?0:n.port,i=0|Math.floor(2147483647*Math.random())||82e3,A=function(e){const t=e.os??"MAC";return _(`<C2D_C><uid>${w(e.uid)}</uid><cli><port>${e.clientPort}</port></cli><cid>${e.cid}</cid><mtu>${e.mtu}</mtu><debug>false</debug><p>${w(t)}</p></C2D_C>`)}({uid:this.opts.uid,clientPort:r,cid:i,mtu:this.mtu}),o=await new Promise(((n,r)=>{const i=setTimeout((()=>{o&&clearInterval(o),e.off("message",Q),r(new Error("BCUDP discovery timeout after 30000ms (camera may be sleeping or unreachable)"))}),3e4);let o,c,l,h,g,d=0,u=!1,I=!1,E=!1;const p=t=>{h&&(g||(g=setTimeout((()=>{const s=h,r=c,A=l;s&&(e.off("message",Q),clearTimeout(i),o&&clearInterval(o),this.emit("debug","discovery_finalize",{reason:t,...null!=r?{sid:r}:{},...s}),n({...s,...null!=r?{sid:r}:{},...null!=A?{tid:A}:{}}))}),250)))},C=(t,s)=>{if(!u&&h&&null!=c)try{const n=(0|Math.floor(2147483647*Math.random()))>>>0,r=G(n,function(e){const t=e.conn??"local";return _("<C2D_T>"+(null!=e.sid?`<sid>${e.sid}</sid>`:"")+`<conn>${w(t)}</conn><cid>${e.cid}</cid><mtu>${e.mtu}</mtu></C2D_T>`)}({...null!=c?{sid:c}:{},cid:h.cid,mtu:this.mtu,conn:"local"}));e.send(r,s,t),u=!0,this.emit("debug","discovery_t_send",{sid:c,cid:h.cid,did:h.did,rhost:t,rport:s})}catch(e){this.emit("debug","discovery_t_send_error",e)}},B=(t,s,n,r)=>{if(!E)try{const i=G(t,$({sid:r.sid,conn:r.conn??"local",cid:r.cid,did:r.did,mtu:this.mtu}));e.send(i,n,s),E=!0,this.emit("debug","discovery_a_send",{sid:r.sid,cid:r.cid,did:r.did,rhost:s,rport:n})}catch(e){this.emit("debug","discovery_a_send_error",e)}},Q=(e,t)=>{try{const s=W(e);if("discovery"!==s.kind)return;this.emit("debug","discovery_rx",{tid:s.tid,rhost:t.address,rport:t.port,xmlPreview:s.xml.slice(0,120)});const n=q(s.xml);n&&(c=n.sid,h||null==n.cid||null==n.did||(h={cid:n.cid,did:n.did,rhost:t.address,rport:t.port}),h&&(C(t.address,t.port),p("cfm")));const r=z(s.xml);if(r)return I=!0,c=r.sid,h||(h={cid:r.cid,did:r.did,rhost:t.address,rport:t.port}),this.emit("debug","discovery_t_rx",{sid:r.sid,cid:r.cid,did:r.did,rhost:t.address,rport:t.port}),B(s.tid,t.address,t.port,r),void p("t_a");const i=function(e){const t=/<D2C_C_R>([\s\S]*?)<\/D2C_C_R>/.exec(e);if(!t)return;const s=t[1]??"",n=/<rsp>(-?\d+)<\/rsp>/.exec(s)?.[1],r=/<cid>(-?\d+)<\/cid>/.exec(s)?.[1],i=/<did>(-?\d+)<\/did>/.exec(s)?.[1];if(null==n||null==r||null==i)return;const A=/<sid>(-?\d+)<\/sid>/.exec(s)?.[1],o=/<timer>([\s\S]*?)<\/timer>/.exec(s)?.[1],a=o?/<def>(-?\d+)<\/def>/.exec(o)?.[1]:void 0,c=o?/<hb>(-?\d+)<\/hb>/.exec(o)?.[1]:void 0,l=o?/<hbt>(-?\d+)<\/hbt>/.exec(o)?.[1]:void 0,h=null!=a||null!=c||null!=l?{...null!=a?{def:Number(a)}:{},...null!=c?{hb:Number(c)}:{},...null!=l?{hbt:Number(l)}:{}}:void 0;return{rsp:Number(n),cid:Number(r),did:Number(i),...null!=A?{sid:Number(A)}:{},...h?{timer:h}:{}}}(s.xml);if(!i)return;if(0!==i.rsp)return;return this.emit("debug","discovery_success",{retryCount:d,rhost:t.address,rport:t.port,sid:i.sid??c,timer:i.timer}),l=s.tid,h={cid:i.cid,did:i.did,rhost:t.address,rport:t.port},null!=i.sid&&(c=i.sid),C(t.address,t.port),void(I||E?p("cr_t"):null!=c?(g&&clearTimeout(g),g=setTimeout((()=>{p("cr_timeout")}),1500)):p("cr_no_sid"))}catch{}};e.on("message",Q);const f=()=>{const n=G((0|Math.floor(255*Math.random()))>>>0,A);for(const r of t)try{e.send(n,r,s),d++,this.emit("debug","discovery_send",{retryCount:d,host:s,port:r})}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}};f(),o=(0,a.setInterval)((()=>{f()}),500)}));this.clientId=o.cid,this.cameraId=o.did,this.sid=o.sid,this.discoveryTid=o.tid,this.remote={host:o.rhost,port:o.rport}}startTimers(){if(!this.sock||!this.remote||null==this.clientId||null==this.cameraId)throw new Error("BCUDP not ready");this.updateAckPacket(),this.sendHeartbeat(),this.ackTimer=(0,a.setInterval)((()=>{try{this.sendAckFast()}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}}),10),this.resendTimer=(0,a.setInterval)((()=>{try{this.resendOutstanding()}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}}),500),this.hbTimer=(0,a.setInterval)((()=>{try{this.sendHeartbeat()}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}}),1e3)}sendHeartbeat(){if(!this.sock||!this.remote||null==this.clientId||null==this.cameraId)return;const e=this.getKeepAliveTid();let t;var s;t=_(`<C2D_HB><cid>${(s={cid:this.clientId,did:this.cameraId}).cid}</cid><did>${s.did}</did></C2D_HB>`);const n=G(e,t);this.emit("debug","udp_hb_send",{tid:e,xml:t,host:this.remote.host,port:this.remote.port}),this.sock.send(n,this.remote.port,this.remote.host)}buildAckPayload(){if(0===this.packetsWant)return{packetId:4294967295,payload:Buffer.alloc(0)};let e=this.packetsWant;for(;this.received.has(e);)e++;let t=e-1;for(const e of this.received.keys())e>t&&(t=e);const s=e+200-1;if(t>s&&(t=s),t<e)return{packetId:e-1>>>0,payload:Buffer.alloc(0)};const n=t-e+1,r=Buffer.allocUnsafe(n);for(let t=0;t<n;t++)r[t]=this.received.has(e+t)?1:0;return{packetId:e-1>>>0,payload:r}}updateAckPacket(){if(null==this.cameraId)return;const{packetId:e,payload:t}=this.buildAckPayload();this.lastAckPacket=function(e){const t=e.payload??Buffer.alloc(0),s=Buffer.alloc(28);return s.writeUInt32LE(U,0),s.writeInt32LE(0|e.connectionId,4),s.writeUInt32LE(0,8),s.writeUInt32LE(e.groupId>>>0,12),s.writeUInt32LE(e.packetId>>>0,16),s.writeUInt32LE((e.maybeLatency??0)>>>0,20),s.writeUInt32LE(t.length>>>0,24),Buffer.concat([s,t])}({connectionId:this.cameraId,groupId:4294967295===e&&0===t.length?4294967295:0,packetId:e,maybeLatency:this.ackLatency.getValue(),payload:t})}sendAckFast(){this.sock&&this.remote&&0!==this.lastAckPacket.length&&(this.sock.send(this.lastAckPacket,this.remote.port,this.remote.host),this.ackSentCount++,this.ackSentCount%100==0&&this.emit("debug","ack_sent_100",{latency:this.ackLatency.getValue()}))}scheduleAck(e="data"){if("manual"===e){if(this.ackScheduled)return;this.ackScheduled=!0,setImmediate((()=>{this.ackScheduled=!1;try{this.sendAckFast()}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}})),this.emit("debug","ack_scheduled",{reason:e})}}resendOutstanding(){if(this.sock&&this.remote)for(const[,e]of this.sent)this.sock.send(e.buf,this.remote.port,this.remote.host)}handleAckFromCamera(e,t){if(4294967295!==e){for(const t of this.sent.keys())t<=e&&this.sent.delete(t);for(let s=0;s<t.length;s++){if((t[s]??0)>0){const t=e+1+s>>>0;this.sent.delete(t)}}}this.ackLatency.feed()}scheduleDrain(){this.drainScheduled||(this.drainScheduled=!0,setImmediate((()=>{this.drainScheduled=!1;try{for(;this.pendingDataOffset<this.pendingData.length;this.pendingDataOffset++)this.emit("data",this.pendingData[this.pendingDataOffset])}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}finally{this.pendingDataOffset>=this.pendingData.length&&(this.pendingData=[],this.pendingDataOffset=0)}})))}flushReceived(){for(;this.received.has(this.packetsWant);){const e=this.received.get(this.packetsWant);this.received.delete(this.packetsWant),this.packetsWant++,this.pendingData.push(e)}this.pendingData.length>this.pendingDataOffset&&this.scheduleDrain()}handlePacket(e,t,s){const n=e=>{this.remote&&this.remote.host===t&&this.remote.port===s||(this.remote={host:t,port:s},this.emit("debug","remote_update",{reason:e,host:t,port:s}))};if(this.remote||n("first_packet"),"ack"!==e.kind)if("data"!==e.kind){if("discovery"===e.kind){this.emit("debug","discovery_rx_connected",{tid:e.tid,xml:e.xml});const r=function(e){const t=/<D2C_HB>([\s\S]*?)<\/D2C_HB>/.exec(e);if(!t)return;const s=t[1]??"",n=/<cid>(-?\d+)<\/cid>/.exec(s)?.[1],r=/<did>(-?\d+)<\/did>/.exec(s)?.[1];return null!=n&&null!=r?{cid:Number(n),did:Number(r)}:void 0}(e.xml);if(r&&null!=this.clientId&&null!=this.cameraId&&r.cid===this.clientId&&r.did===this.cameraId){this.emit("debug","discovery_hb_rx_connected",{...r,rhost:t,rport:s});try{n("d2c_hb"),this.sendHeartbeat()}catch(e){this.emit("debug","discovery_hb_reply_error",e)}return}const i=z(e.xml);if(i&&null!=this.clientId&&null!=this.cameraId&&i.cid===this.clientId&&i.did===this.cameraId){try{n("d2c_t"),this.sid=i.sid,this.emit("debug","discovery_t_rx_connected",{sid:i.sid,cid:i.cid,did:i.did,rhost:t,rport:s});const r=Date.now(),A=750;if(null==this.lastAcceptAtMs||r-this.lastAcceptAtMs>=A){const n=$({sid:i.sid,conn:i.conn??"local",cid:i.cid,did:i.did,mtu:this.mtu}),A=G(e.tid,n);this.sock?.send(A,s,t),this.acceptSent=!0,this.lastAcceptAtMs=r,this.emit("debug","discovery_a_send_connected",{sid:i.sid,cid:i.cid,did:i.did,rhost:t,rport:s})}else this.emit("debug","discovery_a_skip_throttle",{sinceMs:r-this.lastAcceptAtMs,throttleMs:A,sid:i.sid,cid:i.cid,did:i.did,rhost:t,rport:s})}catch(e){this.emit("debug","discovery_a_send_connected_error",e)}return}const A=q(e.xml);if(A&&null!=this.clientId&&null!=this.cameraId&&A.cid===this.clientId&&A.did===this.cameraId)return this.sid=A.sid,void this.emit("debug","discovery_cfm_rx_connected",A);const o=X(e.xml);if(o&&null!=this.clientId&&null!=this.cameraId&&o.cid===this.clientId&&o.did===this.cameraId)return this.emit("debug","discovery_disc_rx_connected",{...o,rhost:t,rport:s}),this.emit("error",new Error("BCUDP disconnected by camera (D2C_DISC)")),void this.close()}}else null!=this.clientId&&e.connectionId===this.clientId&&(n("data"),e.packetId>=this.packetsWant&&(this.received.set(e.packetId,e.payload),this.flushReceived(),this.updateAckPacket(),this.packetsWant%100==0&&this.emit("debug","udp_progress",{packetsWant:this.packetsWant})));else null!=this.clientId&&e.connectionId===this.clientId&&(n("ack"),this.handleAckFromCamera(e.packetId,e.payload))}write(e){if(!this.sock||!this.remote||null==this.cameraId)throw new Error("BCUDP stream is not connected");const t=this.mtu-20;for(let s=0;s<e.length;s+=t){const n=e.subarray(s,Math.min(e.length,s+t)),r=this.sendPacketId>>>0;this.sendPacketId=this.sendPacketId+1>>>0;const i=J({connectionId:this.cameraId,packetId:r,payload:Buffer.from(n)});this.sent.set(r,{packetId:r,buf:i,ts:Date.now()}),this.sock.send(i,this.remote.port,this.remote.host)}}async close(){this.ackTimer&&clearInterval(this.ackTimer),this.resendTimer&&clearInterval(this.resendTimer),this.hbTimer&&clearInterval(this.hbTimer),this.ackTimer=void 0,this.resendTimer=void 0,this.hbTimer=void 0;const e=this.sock;this.sock=void 0,e&&await new Promise((t=>e.close((()=>t()))))}};function K(e){return e===n.XW||e===n.Oh||e===n.Fi||e===n.O1}var ee=class e extends i.EventEmitter{static streamingRegistry=new Map;opts;debugCfg;logger;tcpSocket;udpSocket;transport="tcp";parser=new S;pending=new Map;socketClosed=!1;pendingCloseInfo;lastDisconnectInfo;msgNum=0;loggedIn=!1;subscribed=!1;keepAliveTimer;keepAlivePingInFlight=!1;idleDisconnectTimer;lastUserActivityAtMs;permitSeq=1;permits=new Map;lastRxAtMs;lastTxAtMs;lastRxInfo;lastTxInfo;rxHistory=[];txHistory=[];enc={kind:"none"};nonce;videoSubscriptions=new Map;contributesToGlobalStreamingRegistry=!1;streamTraceStats=new Map;rxCmdTraceStats=new Map;constructor(e){super(),this.opts=e,this.logger=e.logger??console,this.debugCfg=(0,n.$8)(e.debugOptions)}logFixed(e,t){const s=`[BaichuanClient] ${e}`,n=this.logger;"function"!=typeof n.info?"function"!=typeof n.log?"function"==typeof n.warn&&n.warn(s,t):n.log(s,t):n.info(s,t)}getIdleDisconnectTimeoutMs(){const e=this.opts.idleDisconnectTimeoutMs;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:3e4}isIdleDisconnectEnabled(){return!0===this.opts.idleDisconnect}clearIdleDisconnectTimer(){this.idleDisconnectTimer&&(clearTimeout(this.idleDisconnectTimer),this.idleDisconnectTimer=void 0)}touchUserActivity(e){this.lastUserActivityAtMs=Date.now(),this.logDebug("user_activity",{reason:e,atMs:this.lastUserActivityAtMs})}isIdleDisconnectEligibleNow(){return!!this.isIdleDisconnectEnabled()&&(!!this.isSocketConnected()&&(!(this.pending.size>0)&&(!this.hasActiveVideoSubscriptionsInternal()&&!(this.permits.size>0))))}kickIdleDisconnectTimer(){if(!this.isIdleDisconnectEnabled())return;if(this.clearIdleDisconnectTimer(),!this.isIdleDisconnectEligibleNow())return;if(null==this.lastUserActivityAtMs)return;const e=this.getIdleDisconnectTimeoutMs(),t=Date.now()-this.lastUserActivityAtMs,s=Math.max(0,e-t);this.idleDisconnectTimer=setTimeout((()=>{try{if(!this.isIdleDisconnectEligibleNow())return;if(null==this.lastUserActivityAtMs)return;const t=Date.now()-this.lastUserActivityAtMs;if(t<e)return void this.kickIdleDisconnectTimer();this.logDebug("idle_disconnect",{elapsedMs:t,timeoutMs:e,transport:this.transport}),this.logFixed("idle_disconnect",{elapsedMs:t,timeoutMs:e,transport:this.transport,host:this.opts.host}),this.close({reason:"idle_disconnect"})}catch(e){this.logDebug("idle_disconnect_error",e)}}),s),this.idleDisconnectTimer.unref?.()}getLastDisconnectInfo(){return this.lastDisconnectInfo}acquirePermit(e=this.getIdleDisconnectTimeoutMs(),t){const s=Math.max(0,Math.floor(e)),n=this.permitSeq++,r=Date.now()+s;let i;return s>0&&(i=setTimeout((()=>this.releasePermit(n,"timeout")),s),i.unref?.()),this.permits.set(n,{timer:i,untilMs:r,reason:t}),this.logDebug("permit_acquired",{id:n,holdMs:s,untilMs:r,reason:t,permits:this.permits.size}),this.clearIdleDisconnectTimer(),()=>this.releasePermit(n,"manual")}releasePermit(e,t){const s=this.permits.get(e);s&&(s.timer&&clearTimeout(s.timer),this.permits.delete(e),this.logDebug("permit_released",{id:e,how:t,permits:this.permits.size}),this.kickIdleDisconnectTimer())}getDeviceRegistryKey(){const e=(this.opts.uid??"").trim().toUpperCase();return`${(this.opts.host??"").trim()}|${e}|${this.opts.channel??0}`}recomputeGlobalStreamingContribution(){const t=this.hasActiveVideoSubscriptionsInternal();if(t===this.contributesToGlobalStreamingRegistry)return;const s=this.getDeviceRegistryKey(),n=e.streamingRegistry.get(s)??{activeStreamClients:0},r=Math.max(0,n.activeStreamClients+(t?1:-1));0===r?e.streamingRegistry.delete(s):e.streamingRegistry.set(s,{activeStreamClients:r}),this.contributesToGlobalStreamingRegistry=t}isDeviceStreamingActive(){if(this.hasActiveVideoSubscriptionsInternal())return!0;const t=this.getDeviceRegistryKey(),s=e.streamingRegistry.get(t);return(s?.activeStreamClients??0)>0}logDebug(e,t){this.debugCfg.general&&(this.logger.debug(`[BaichuanClient] ${e}`,t),this.emit("debug",e,t))}getTransport(){return this.transport}getConfiguredChannel(){return this.opts.channel??0}refreshKeepAlive(){this.stopKeepAlive(),this.isSocketConnected()&&this.startKeepAlive()}getLastRxAtMs(){return this.lastRxAtMs}getLastRxInfo(){return this.lastRxInfo}getRxHistory(){return this.rxHistory}getLastTxAtMs(){return this.lastTxAtMs}getLastTxInfo(){return this.lastTxInfo}getTxHistory(){return this.txHistory}recordTx(e){const t=Date.now();this.lastTxAtMs=t,this.lastTxInfo={atMs:t,...e},this.txHistory.push(this.lastTxInfo),this.txHistory.length>32&&this.txHistory.shift()}isProbablySleeping(e=15e3){return"udp"===this.transport&&(this.isIdleDisconnectEnabled()?!this.isSocketConnected():!this.isSocketConnected()||!this.isDeviceStreamingActive()&&(null!=this.lastRxAtMs&&Date.now()-this.lastRxAtMs>=e))}getDebugConfig(){return this.debugCfg}isSocketConnected(){return"tcp"===this.transport?void 0!==this.tcpSocket&&!this.tcpSocket.destroyed:"udp"===this.transport&&(void 0!==this.udpSocket&&(this.udpSocket.isConnected?.()??!0))}get username(){return this.opts.username}startKeepAlive(){if(this.keepAliveTimer)return;let e=3e4;if("udp"===this.transport){if(!this.shouldSendUdpKeepAlive())return;e=2500}e<=0||(this.keepAliveTimer=setInterval((()=>{if("udp"!==this.transport)this.keepAlivePingInFlight||(this.keepAlivePingInFlight=!0,(async()=>{try{await this.sendPing()}catch(e){this.logDebug("keepalive_ping_error",e)}finally{this.keepAlivePingInFlight=!1}})());else try{this.sendUdpKeepAlive()}catch(e){this.logDebug("udp_keepalive_ping_error",e)}}),e),this.keepAliveTimer.unref?.())}hasActiveVideoSubscriptionsInternal(){for(const e of this.videoSubscriptions.values())if(e.size>0)return!0;return!1}hasActiveVideoSubscriptions(){return this.hasActiveVideoSubscriptionsInternal()}shouldSendUdpKeepAlive(){return"udp"===this.transport&&(!!this.udpSocket&&(!!this.loggedIn&&!!this.hasActiveVideoSubscriptionsInternal()))}sendUdpKeepAlive(){if("udp"!==this.transport)return;if(!this.udpSocket)return;if(!this.loggedIn)return;const e=this.nextMsgNum(),t=m({cmdId:n.F3,bodyLen:0,channelId:0,streamType:0,msgNum:e,responseCode:0,messageClass:n.Uh,payloadOffset:0});this.logDebug("udp_keepalive_ping_tx",{msgNum:e,channelId:0,streamType:0}),this.recordTx({cmdId:n.F3,responseCode:0,msgNum:e,channelId:0,streamType:0}),this.writeWire(t)}stopKeepAlive(){this.keepAliveTimer&&(clearInterval(this.keepAliveTimer),this.keepAliveTimer=void 0),this.keepAlivePingInFlight=!1}async sendPing(){if((this.tcpSocket||this.udpSocket)&&this.loggedIn)try{await this.sendFrame({cmdId:n.uy,channel:this.opts.channel??0,channelIdOverride:0,messageClass:n.Uh,streamType:0,extensionXml:"",internal:!0})}catch(e){this.logDebug("keepalive_ping_failed",e)}}async connect(){const e=this.opts.transport??"tcp";if("tcp"!==e)if("udp"!==e)try{await Promise.race([this.connectTcp(),new Promise(((e,t)=>setTimeout((()=>t(new Error("TCP connection timeout (falling back to UDP)"))),4e3)))])}catch(e){if(this.logDebug("auto:tcp_failed",e),!this.opts.uid)throw new Error("TCP connection failed and UDP fallback requires `options.uid` (BCUDP discovery UID).");await this.connectUdp()}else await this.connectUdp();else await this.connectTcp()}async connectTcp(){if(this.tcpSocket&&!this.tcpSocket.destroyed)return void(this.transport="tcp");const e=this.opts.port??n.I4,t=A.createConnection({host:this.opts.host,port:e});this.tcpSocket=t,this.transport="tcp",this.socketClosed=!1;try{t.setKeepAlive(!0,3e4)}catch(e){this.logDebug("tcp_setKeepAlive_failed",e)}t.on("data",(e=>{const t=this.parser.push(e);for(const e of t)this.handleFrame(e)})),t.on("close",(()=>{this.stopKeepAlive(),this.socketClosed=!0;const e=this.pendingCloseInfo;this.pendingCloseInfo=void 0,this.lastDisconnectInfo={atMs:Date.now(),transport:"tcp",voluntary:null!=e,reason:e?.reason??"socket_closed"};const t=["transport=tcp",`host=${this.opts.host}`],s=this.opts.port??n.I4;null!=s&&t.push(`port=${s}`),null!=this.lastRxInfo?.cmdId&&t.push(`lastRxCmdId=${this.lastRxInfo.cmdId}`),null!=this.lastTxInfo?.cmdId&&t.push(`lastTxCmdId=${this.lastTxInfo.cmdId}`),this.logFixed("disconnected",t.join(" ")),this.emit("close");const r=Array.from(this.pending.entries());this.pending.clear();for(const[,e]of r)setImmediate((()=>{try{e.reject(new Error("Baichuan socket closed"))}catch(e){}}))})),t.on("error",(e=>this.emit("error",e))),await new Promise(((e,s)=>{t.once("connect",(()=>e())),t.once("error",(e=>s(e)))})),this.logFixed("connected",`transport=tcp host=${this.opts.host} port=${e}`),this.startKeepAlive(),this.kickIdleDisconnectTimer()}async connectUdp(){if(this.udpSocket){if(this.udpSocket.isConnected?.())return void(this.transport="udp");try{await this.udpSocket.close()}catch{}this.udpSocket=void 0}if(!this.opts.uid)throw new Error("Baichuan UDP requested but `options.uid` is not set (required for BCUDP discovery).");const e=new Z({mode:"uid",uid:this.opts.uid});this.udpSocket=e,this.transport="udp",this.socketClosed=!1,e.on("data",(e=>{const t=this.parser.push(e);for(const e of t)this.handleFrame(e)})),e.on("close",(()=>{this.stopKeepAlive(),this.socketClosed=!0;const t=this.pendingCloseInfo;this.pendingCloseInfo=void 0,this.lastDisconnectInfo={atMs:Date.now(),transport:"udp",voluntary:null!=t,reason:t?.reason??"socket_closed"};const s=["transport=udp",`host=${this.opts.host}`];this.opts.uid&&s.push(`uid=${this.opts.uid}`),null!=this.lastRxInfo?.cmdId&&s.push(`lastRxCmdId=${this.lastRxInfo.cmdId}`),null!=this.lastTxInfo?.cmdId&&s.push(`lastTxCmdId=${this.lastTxInfo.cmdId}`),this.logFixed("disconnected",s.join(" ")),this.loggedIn=!1,this.subscribed=!1,this.contributesToGlobalStreamingRegistry&&(this.videoSubscriptions.clear(),this.recomputeGlobalStreamingContribution()),this.udpSocket===e&&(this.udpSocket=void 0),this.emit("close");const n=Array.from(this.pending.entries());this.pending.clear();for(const[,e]of n)setImmediate((()=>{try{e.reject(new Error("Baichuan UDP stream closed"))}catch(e){}}))})),e.on("error",(e=>{e?.message?.includes("D2C_DISC")&&(this.stopKeepAlive(),this.loggedIn=!1,this.subscribed=!1,this.contributesToGlobalStreamingRegistry&&(this.videoSubscriptions.clear(),this.recomputeGlobalStreamingContribution())),this.emit("error",e)})),e.on("debug",((e,t)=>{this.logDebug(`udp_${e}`,t)})),await e.connect(),this.logFixed("connected",`transport=udp host=${this.opts.host} uid=${this.opts.uid}`),this.startKeepAlive(),this.kickIdleDisconnectTimer()}async close(e){Boolean(this.tcpSocket&&!this.tcpSocket.destroyed||this.udpSocket)&&(this.pendingCloseInfo={atMs:Date.now(),reason:(e?.reason??"manual_close").trim()||"manual_close"}),this.stopKeepAlive(),this.clearIdleDisconnectTimer();for(const e of Array.from(this.permits.keys()))this.releasePermit(e,"close");this.contributesToGlobalStreamingRegistry&&(this.videoSubscriptions.clear(),this.recomputeGlobalStreamingContribution());const t=this.tcpSocket;this.tcpSocket=void 0,t&&await new Promise((e=>{t.once("close",(()=>e())),t.destroy()}));const s=this.udpSocket;this.udpSocket=void 0,s&&await s.close()}handleFrame(e){const t=Date.now();if(this.lastRxAtMs=t,this.lastRxInfo={atMs:t,cmdId:e.header.cmdId,responseCode:e.header.responseCode,msgNum:e.header.msgNum,channelId:e.header.channelId,streamType:e.header.streamType},this.rxHistory.push(this.lastRxInfo),this.rxHistory.length>32&&this.rxHistory.shift(),this.debugCfg.general)if(3===e.header.cmdId){const s=this.rxCmdTraceStats.get(3)??{lastLogMs:t,frames:0};s.frames++,t-s.lastLogMs>=1e3&&((0,n.cY)(this.debugCfg,this.logger,"BaichuanRx",`rx cmdId=3 frames=${s.frames} lastMsgNum=${e.header.msgNum} lastResponseCode=${e.header.responseCode} lastChannelId=${e.header.channelId} lastStreamType=${e.header.streamType} lastBodyLen=${e.body.length} lastPayloadLen=${e.payload.length}`),s.lastLogMs=t,s.frames=0),this.rxCmdTraceStats.set(3,s)}else(0,n.cY)(this.debugCfg,this.logger,"BaichuanRx",`rx cmdId=${e.header.cmdId} msgNum=${e.header.msgNum} responseCode=${e.header.responseCode} channelId=${e.header.channelId} streamType=${e.header.streamType} bodyLen=${e.body.length} payloadLen=${e.payload.length} payloadOffset=${e.header.payloadOffset??0}`);if("udp"===this.transport&&e.header.cmdId===n.F3){try{const t=m({cmdId:e.header.cmdId,bodyLen:0,channelId:e.header.channelId,streamType:e.header.streamType,msgNum:e.header.msgNum,responseCode:200,messageClass:e.header.messageClass,payloadOffset:0});this.logDebug("udp_keepalive_rx",{msgNum:e.header.msgNum,channelId:e.header.channelId,streamType:e.header.streamType,responseCode:e.header.responseCode}),this.recordTx({cmdId:e.header.cmdId,responseCode:200,msgNum:e.header.msgNum,channelId:e.header.channelId,streamType:e.header.streamType}),this.writeWire(t),this.logDebug("udp_keepalive_tx",{msgNum:e.header.msgNum,channelId:e.header.channelId,streamType:e.header.streamType})}catch(e){this.logDebug("udp_keepalive_error",e)}return}this.debugCfg.traceTalk&&K(e.header.cmdId)&&(0,n.S1)(this.debugCfg,this.logger,"BaichuanTalk",`rx cmdId=${e.header.cmdId} msgNum=${e.header.msgNum} responseCode=${e.header.responseCode} channelId=${e.header.channelId} bodyLen=${e.body.length} payloadLen=${e.payload.length} payloadOffset=${e.header.payloadOffset??0}`),this.emit("frame",e);const s=`${e.header.cmdId}:${e.header.msgNum}`,r=this.pending.get(s);if(r)return this.pending.delete(s),void r.resolve(e);const i=this.videoSubscriptions.get(e.header.cmdId);if(i&&i.size>0){if(i.has(e.header.msgNum)){if(this.debugCfg.traceStream&&3===e.header.cmdId){const t=Date.now(),s=e.header.msgNum,r=this.streamTraceStats.get(s)??{lastLogMs:t,frames:0};r.frames++,t-r.lastLogMs>=500&&((0,n.aQ)(this.debugCfg,this.logger,"BaichuanTrace",`rx stream frames cmdId=3 msgNum=${e.header.msgNum} frames=${r.frames} lastChannelId=${e.header.channelId} lastBodyLen=${e.body.length} lastPayloadLen=${e.payload.length} lastPayloadOffset=${e.header.payloadOffset??0}`),r.lastLogMs=t,r.frames=0),this.streamTraceStats.set(s,r)}this.emit("push",e)}}else if(this.emit("push",e),33===e.header.cmdId)try{const t=this.parseEvents(e);for(const s of t)(0,n.Mg)(this.debugCfg,this.logger,"BaichuanEvent",`dispatch cmdId=33 msgNum=${e.header.msgNum} channelId=${e.header.channelId} type=${s.type} eventChannel=${s.channel}`+("ai"===s.type?` aiType=${s.ai?.type??"unknown"} detected=${s.ai?.detected??""}`:"")+("motion"===s.type?` source=${s.motion?.source??""}`:"")),this.emit("event",s)}catch(e){this.logDebug("event_parse_error",e)}}subscribeVideoStream(e,t){this.videoSubscriptions.has(e)||this.videoSubscriptions.set(e,new Set),this.videoSubscriptions.get(e).add(t),3!==e||this.streamTraceStats.has(t)||this.streamTraceStats.set(t,{lastLogMs:Date.now(),frames:0}),"udp"===this.transport&&this.refreshKeepAlive(),this.recomputeGlobalStreamingContribution(),this.kickIdleDisconnectTimer()}unsubscribeVideoStream(e,t){const s=this.videoSubscriptions.get(e);s&&(void 0!==t?(s.delete(t),0===s.size&&this.videoSubscriptions.delete(e),3===e&&this.streamTraceStats.delete(t)):(this.videoSubscriptions.delete(e),3===e&&this.streamTraceStats.clear()),"udp"===this.transport&&this.refreshKeepAlive(),this.recomputeGlobalStreamingContribution(),this.kickIdleDisconnectTimer())}parseEvents(e){const t=e.body;if(0===t.length)return[];const s=this.tryDecryptXml(t,e.header.channelId,this.enc);if(!s||!s.startsWith("<?xml"))return[];if(this.debugCfg.traceEvents){const t=s.length>500?`${s.slice(0,500)}...`:s;(0,n.Mg)(this.debugCfg,this.logger,"BaichuanEventRaw",`rx cmdId=${e.header.cmdId} msgNum=${e.header.msgNum} responseCode=${e.header.responseCode} channelId=${e.header.channelId} xml=${JSON.stringify(t)}`)}const r=e.header.channelId,i=250===r?0:Math.max(0,r-1),A=Date.now();if(s.includes("<AlarmEventList")){const e=[],t=s.matchAll(/<AlarmEvent\b[^>]*>([\s\S]*?)<\/AlarmEvent>/g);for(const s of t){const t=s[1]??"",r=v(t,"channelId"),o=void 0!==r?Number(r):i,a=(v(t,"status")??"").trim(),c=a.toUpperCase(),l=(v(t,"AItype")??v(t,"aiType")??v(t,"aitype")??"").trim();this.debugCfg.traceEvents&&(0,n.Mg)(this.debugCfg,this.logger,"BaichuanEventRaw",`AlarmEvent channel=${o} status=${JSON.stringify(a)} aiType=${JSON.stringify(l)}`);const h=a.toLowerCase(),g=h.length>0&&"none"!==h,d=l.trim().length>0&&"none"!==l.trim().toLowerCase();if(g||d){const t=c.includes("MD")?"md":c.includes("PIR")||c.includes("OTHER")?"pir":"unknown";e.push({channel:o,type:"motion",motion:{channel:o,state:!0,timestamp:A,source:t},timestamp:A})}const u=l?l.split(",").map((e=>e.trim())).find((e=>e.length>0&&"none"!==e.toLowerCase())):void 0;if(u){const t=u.toLowerCase(),s={people:"people",person:"people",human:"people",vehicle:"vehicle",car:"vehicle",dog_cat:"dog_cat",dog:"dog_cat",cat:"dog_cat",pet:"dog_cat",face:"face",package:"package"};e.push({channel:o,type:"ai",ai:{channel:o,type:s[t]??"other",detected:!0,timestamp:A},timestamp:A})}else c.includes("AI")&&e.push({channel:o,type:"ai",ai:{channel:o,type:"other",detected:!0,timestamp:A},timestamp:A});c.includes("VIS")&&e.push({channel:o,type:"visitor",timestamp:A}),c.includes("DN")&&e.push({channel:o,type:"daynight",timestamp:A})}return e}const o=s.match(/<Event\b[^>]*>([\s\S]*?)<\/Event>/);if(!o)return[];const a=o[1]??"",c=(v(a,"status")??"").trim(),l=c.toUpperCase(),h=(v(a,"AItype")??v(a,"aiType")??v(a,"aitype")??"").trim(),g=[],d=c.toLowerCase(),u=d.length>0&&"none"!==d,I=h.trim().length>0&&"none"!==h.trim().toLowerCase();if(u||I){const e=l.includes("MD")?"md":l.includes("PIR")||l.includes("OTHER")?"pir":"unknown";g.push({channel:i,type:"motion",motion:{channel:i,state:!0,timestamp:A,source:e},timestamp:A})}const E=h?h.split(",").map((e=>e.trim())).find((e=>e.length>0&&"none"!==e.toLowerCase())):void 0;if(E){const e=E.toLowerCase(),t={people:"people",person:"people",human:"people",vehicle:"vehicle",car:"vehicle",dog_cat:"dog_cat",dog:"dog_cat",cat:"dog_cat",pet:"dog_cat",face:"face",package:"package"};g.push({channel:i,type:"ai",ai:{channel:i,type:t[e]??"other",detected:!0,timestamp:A},timestamp:A})}else l.includes("AI")&&g.push({channel:i,type:"ai",ai:{channel:i,type:"other",detected:!0,timestamp:A},timestamp:A});return l.includes("VIS")&&g.push({channel:i,type:"visitor",timestamp:A}),l.includes("DN")&&g.push({channel:i,type:"daynight",timestamp:A}),g}nextMsgNum(){return this.msgNum=this.msgNum+1&65535,this.msgNum}peekNextMsgNum(){return this.msgNum+1&65535}requireSocket(){if("tcp"!==this.transport)throw new Error("Internal: requireSocket called while not using TCP");if(!this.tcpSocket||this.tcpSocket.destroyed)throw new Error("Baichuan TCP socket is not connected");return this.tcpSocket}writeWire(e){if(this.lastTxAtMs=Date.now(),"tcp"!==this.transport){if(!this.udpSocket)throw new Error("Baichuan UDP stream is not connected");this.udpSocket.write(e)}else this.requireSocket().write(e)}encodeBodyXml(e,t,s,n){const r=Buffer.from(e,"utf8"),i=Buffer.from(t,"utf8");return"none"===n.kind?Buffer.concat([r,i]):"bc"===n.kind?Buffer.concat([C(r,s),C(i,s)]):"aes"===n.kind||"full_aes"===n.kind?Buffer.concat([Q(r,n.key),Q(i,n.key)]):Buffer.concat([r,i])}encodeBodyBinary(e,t,s,n){const r=Buffer.from(e,"utf8");return"none"===n.kind?Buffer.concat([r,t]):"bc"===n.kind?Buffer.concat([C(r,s),t]):"aes"===n.kind||"full_aes"===n.kind?Buffer.concat([Q(r,n.key),t]):Buffer.concat([r,t])}async sendBinaryPayloadNoReply(e){const t=!0===e.internal;t||this.touchUserActivity(`sendBinaryPayloadNoReply cmdId=${e.cmdId}`),await this.connect(),t||this.kickIdleDisconnectTimer();const s=e.channel??this.opts.channel??0,r=e.channelIdOverride??(null==e.channel?250:s+1),i=this.nextMsgNum(),A=e.cmdId,o=e.extensionXml??b(s),a=Buffer.byteLength(o,"utf8"),c=a+e.payload.length,l=e.messageClass??n.Uh,h=m({cmdId:A,bodyLen:c,channelId:r,streamType:e.streamType??0,msgNum:i,responseCode:0,messageClass:l,payloadOffset:a}),g=e.encryption??this.enc,d=this.encodeBodyBinary(o,e.payload,r,g),u=Buffer.concat([h,d]);this.logDebug("tx",{cmdId:A,msgNum:i,channelId:r,messageClass:l,bodyLen:c,binaryPayload:!0}),this.debugCfg.traceTalk&&K(A)&&(0,n.S1)(this.debugCfg,this.logger,"BaichuanTalk",`tx cmdId=${A} msgNum=${i} channelId=${r} streamType=${e.streamType??0} class=0x${l.toString(16)} bodyLen=${c} payloadOffset=${a} binaryPayloadLen=${e.payload.length}`),this.recordTx({cmdId:A,responseCode:0,msgNum:i,channelId:r,streamType:e.streamType??0}),this.writeWire(u),t||this.kickIdleDisconnectTimer()}tryDecryptXml(e,t,s){const n=e=>e.toString("utf8"),r=s=>{let r;try{r="none"===s.kind?e:"bc"===s.kind?B(e,t):f(e,s.key)}catch{return}const i=n(r);return i.startsWith("<?xml")?i:void 0};return r(s)??("bc"!==s.kind?r({kind:"bc"}):void 0)??r({kind:"none"})??n(e)}async sendXml(e){const t=!0===e.internal;t||this.touchUserActivity(`sendXml cmdId=${e.cmdId}`),await this.connect(),t||this.kickIdleDisconnectTimer();const s=e.channel??this.opts.channel??0,r=e.channelIdOverride??(null==e.channel?250:s+1),i=this.nextMsgNum(),A=e.cmdId,o=e.extensionXml??(null!=e.channel?D(s):""),a=e.payloadXml??"",c=e.messageClass??n.Uh,l=Buffer.byteLength(o,"utf8"),h=l+Buffer.byteLength(a,"utf8"),g=m({cmdId:A,bodyLen:h,channelId:r,streamType:e.streamType??0,msgNum:i,responseCode:0,messageClass:c,payloadOffset:l}),d=`${A}:${i}`,u=e.encryption??this.enc,I=this.encodeBodyXml(o,a,r,u),E=Buffer.concat([g,I]),p=e.timeoutMs??1e4;let C;const B=new Promise(((e,t)=>{C=t;const s=setTimeout((()=>{this.pending.delete(d),t(new Error(`Baichuan timeout cmdId=${A} msgNum=${i}`))}),p);this.pending.set(d,{resolve:t=>{clearTimeout(s),e(t)},reject:e=>{clearTimeout(s),t(e)}})}));B.catch((()=>{})),this.logDebug("tx",{cmdId:A,msgNum:i,channelId:r,messageClass:c,bodyLen:h}),!this.debugCfg.traceStream||3!==A&&4!==A||(0,n.aQ)(this.debugCfg,this.logger,"BaichuanTrace",`tx cmdId=${A} msgNum=${i} channelId=${r} streamType=${e.streamType??0} class=0x${c.toString(16)} bodyLen=${h} payloadOffset=${l}`),this.debugCfg.traceTalk&&K(A)&&(0,n.S1)(this.debugCfg,this.logger,"BaichuanTalk",`tx cmdId=${A} msgNum=${i} channelId=${r} streamType=${e.streamType??0} class=0x${c.toString(16)} bodyLen=${h} payloadOffset=${l}`),this.recordTx({cmdId:A,responseCode:0,msgNum:i,channelId:r,streamType:e.streamType??0}),this.writeWire(E);const Q=await B;if(this.logDebug("rx",{cmdId:Q.header.cmdId,responseCode:Q.header.responseCode,msgNum:Q.header.msgNum}),!this.debugCfg.traceStream||3!==A&&4!==A||(0,n.aQ)(this.debugCfg,this.logger,"BaichuanTrace",`rx cmdId=${Q.header.cmdId} msgNum=${Q.header.msgNum} responseCode=${Q.header.responseCode} channelId=${Q.header.channelId} bodyLen=${Q.body.length} payloadLen=${Q.payload.length} payloadOffset=${Q.header.payloadOffset??0}`),this.debugCfg.traceTalk&&K(A)&&(0,n.S1)(this.debugCfg,this.logger,"BaichuanTalk",`rx cmdId=${Q.header.cmdId} msgNum=${Q.header.msgNum} responseCode=${Q.header.responseCode} channelId=${Q.header.channelId} bodyLen=${Q.body.length} payloadLen=${Q.payload.length} payloadOffset=${Q.header.payloadOffset??0}`),400===Q.header.responseCode){if(0===Q.body.length)throw new Error("Baichuan authentication failed (responseCode 400, empty body) - check username/password")}const f=Q.body;if(0===f.length)return t||this.kickIdleDisconnectTimer(),"";const y=this.tryDecryptXml(f,Q.header.channelId,u);return t||this.kickIdleDisconnectTimer(),y}async sendFrame(e){const t=!0===e.internal;t||this.touchUserActivity(`sendFrame cmdId=${e.cmdId}`),await this.connect(),t||this.kickIdleDisconnectTimer();const s=e.channel??this.opts.channel??0,r=e.channelIdOverride??(null==e.channel?250:s+1),i=e.msgNumOverride??this.nextMsgNum(),A=e.cmdId,o=e.extensionXml??(null!=e.channel?D(s):""),a=e.payloadXml??"",c=e.messageClass??n.Uh,l=Buffer.byteLength(o,"utf8"),h=l+Buffer.byteLength(a,"utf8"),g=m({cmdId:A,bodyLen:h,channelId:r,streamType:e.streamType??0,msgNum:i,responseCode:0,messageClass:c,payloadOffset:l}),d=`${A}:${i}`,u=e.encryption??this.enc,I=this.encodeBodyXml(o,a,r,u),E=Buffer.concat([g,I]),p=e.timeoutMs??1e4;let C;const B=new Promise(((e,t)=>{C=t;const s=setTimeout((()=>{this.pending.delete(d),t(new Error(`Baichuan timeout cmdId=${A} msgNum=${i}`))}),p);this.pending.set(d,{resolve:t=>{clearTimeout(s),e(t)},reject:e=>{clearTimeout(s),t(e)}})}));B.catch((()=>{})),this.logDebug("tx",{cmdId:A,msgNum:i,channelId:r,messageClass:c,bodyLen:h}),!this.debugCfg.traceStream||3!==A&&4!==A||(0,n.aQ)(this.debugCfg,this.logger,"BaichuanTrace",`tx cmdId=${A} msgNum=${i} channelId=${r} streamType=${e.streamType??0} class=0x${c.toString(16)} bodyLen=${h} payloadOffset=${l}`),this.debugCfg.traceTalk&&K(A)&&(0,n.S1)(this.debugCfg,this.logger,"BaichuanTalk",`tx cmdId=${A} msgNum=${i} channelId=${r} streamType=${e.streamType??0} class=0x${c.toString(16)} bodyLen=${h} payloadOffset=${l}`),this.recordTx({cmdId:A,responseCode:0,msgNum:i,channelId:r,streamType:e.streamType??0}),this.writeWire(E);const Q=await B;return this.logDebug("rx",{cmdId:Q.header.cmdId,responseCode:Q.header.responseCode,msgNum:Q.header.msgNum}),!this.debugCfg.traceStream||3!==A&&4!==A||(0,n.aQ)(this.debugCfg,this.logger,"BaichuanTrace",`rx cmdId=${Q.header.cmdId} msgNum=${Q.header.msgNum} responseCode=${Q.header.responseCode} channelId=${Q.header.channelId} bodyLen=${Q.body.length} payloadLen=${Q.payload.length} payloadOffset=${Q.header.payloadOffset??0}`),this.debugCfg.traceTalk&&K(A)&&(0,n.S1)(this.debugCfg,this.logger,"BaichuanTalk",`rx cmdId=${Q.header.cmdId} msgNum=${Q.header.msgNum} responseCode=${Q.header.responseCode} channelId=${Q.header.channelId} bodyLen=${Q.body.length} payloadLen=${Q.payload.length} payloadOffset=${Q.header.payloadOffset??0}`),t||this.kickIdleDisconnectTimer(),Q}async sendBinary(e){const t=!0===e.internal;if(t||this.touchUserActivity(`sendBinary cmdId=${e.cmdId}`),109===e.cmdId){const s=await this.sendBinarySnapshot109(e);return t||this.kickIdleDisconnectTimer(),s}if((e.messageClass??n.Uh)===n.d_){const s=await this.sendBinaryFileDownload6482(e);return t||this.kickIdleDisconnectTimer(),s}await this.connect(),t||this.kickIdleDisconnectTimer();const s=e.channel??this.opts.channel??0,r=e.channelIdOverride??(null==e.channel?250:s+1),i=this.nextMsgNum(),A=e.cmdId,o=e.extensionXml??(null!=e.channel?b(s):b(void 0)),a=e.payloadXml??"",c=e.messageClass??n.Uh,l=Buffer.byteLength(o,"utf8"),h=l+Buffer.byteLength(a,"utf8"),g=m({cmdId:A,bodyLen:h,channelId:r,streamType:0,msgNum:i,responseCode:0,messageClass:c,payloadOffset:l}),d=`${A}:${i}`,u=e.encryption??this.enc,I=this.encodeBodyXml(o,a,r,u),E=Buffer.concat([g,I]),p=e.timeoutMs??1e4;let C;const B=new Promise(((e,t)=>{C=t;const s=setTimeout((()=>{this.pending.delete(d),t(new Error(`Baichuan timeout cmdId=${A} msgNum=${i}`))}),p);this.pending.set(d,{resolve:t=>{clearTimeout(s),e(t)},reject:e=>{clearTimeout(s),t(e)}})}));B.catch((()=>{})),this.logDebug("tx",{cmdId:A,msgNum:i,channelId:r,messageClass:c,bodyLen:h,binary:!0}),this.recordTx({cmdId:A,responseCode:0,msgNum:i,channelId:r,streamType:0}),this.writeWire(E);const Q=await B;if(this.logDebug("rx",{cmdId:Q.header.cmdId,responseCode:Q.header.responseCode,msgNum:Q.header.msgNum,binary:!0}),400===Q.header.responseCode){if(0===Q.body.length)throw new Error("Baichuan binary request failed (responseCode 400, empty body)")}const f=Q.payload;if(0===f.length)return Buffer.alloc(0);const y=this.tryDecryptBinary(f,Q.header.channelId,u);return t||this.kickIdleDisconnectTimer(),y}async sendBinaryFileDownload6482(e){await this.connect();const t=e.channel??this.opts.channel??0,s=e.channelIdOverride??(null==e.channel?250:t+1),r=this.nextMsgNum(),i=e.cmdId,A=e.extensionXml??b(t),o=e.payloadXml??"",a=e.messageClass??n.d_,c=Buffer.byteLength(A,"utf8"),l=c+Buffer.byteLength(o,"utf8"),h=m({cmdId:i,bodyLen:l,channelId:s,streamType:e.streamType??0,msgNum:r,responseCode:0,messageClass:a,payloadOffset:c}),g=e.encryption??this.enc,d=this.encodeBodyXml(A,o,s,g),u=Buffer.concat([h,d]),I=e.timeoutMs??6e4,E=[];let p=0,C=0;return await new Promise(((t,n)=>{let A,o=!1;const c=()=>{this.off("frame",d),A&&clearTimeout(A)},h=e=>{o||(o=!0,c(),n(e instanceof Error?e:new Error(String(e))))},d=e=>{var s;if(e.header.cmdId===i)if(e.header.msgNum===r&&e.header.responseCode>=400)h(new Error(`Baichuan file download request rejected (cmdId=${i} msgNum=${r} responseCode=${e.header.responseCode})`));else try{let n=!1;if(e.extension.length>0)try{this.tryDecryptXml(e.extension,e.header.channelId,g).includes("<binaryData>1</binaryData>")&&(n=!0)}catch{}const A=this.tryDecryptBinary(e.payload,e.header.channelId,g);if(0===A.length)return;if(!n&&(e=>{let t=0;for(;t<e.length&&(0===e[t]||9===e[t]||10===e[t]||13===e[t]||32===e[t]);)t++;return!(t>=e.length)&&60===e[t]})(A))return;E.push(A),p+=A.length;const a=Date.now();this.debugCfg.general&&a-C>=2e3&&(C=a,this.logDebug("file_download_progress",{cmdId:i,msgNum:r,bytes:p})),201===e.header.responseCode&&(s=Buffer.concat(E),o||(o=!0,c(),t(s)))}catch(e){h(e)}};A=setTimeout((()=>{h(new Error(`Baichuan timeout waiting file download chunks cmdId=${i} msgNum=${r}`))}),I),this.on("frame",d);try{this.logDebug("tx",{cmdId:i,msgNum:r,channelId:s,messageClass:a,bodyLen:l,binary:!0,fileDownload:!0}),this.recordTx({cmdId:i,responseCode:0,msgNum:r,channelId:s,streamType:e.streamType??0}),this.writeWire(u)}catch(e){h(e)}}))}async sendBinarySnapshot109(e){await this.connect();const t=e.channel??this.opts.channel??0,s=e.channelIdOverride??(null==e.channel?250:t+1),r=this.nextMsgNum(),i=e.cmdId,A=e.extensionXml??(null!=e.channel?D(t):""),o=e.payloadXml??"",a=e.messageClass??n.Uh,c=Buffer.byteLength(A,"utf8"),l=c+Buffer.byteLength(o,"utf8"),h=m({cmdId:i,bodyLen:l,channelId:s,streamType:e.streamType??0,msgNum:r,responseCode:0,messageClass:a,payloadOffset:c}),g=e.encryption??this.enc,d=this.encodeBodyXml(A,o,s,g),u=Buffer.concat([h,d]),I=e.timeoutMs??15e3,E=[];let p=!1;return await new Promise(((t,n)=>{let A,o=!1;const c=()=>{this.off("frame",C),A&&clearTimeout(A)},h=e=>{o||(o=!0,c(),t(e))},d=e=>{o||(o=!0,c(),n(e instanceof Error?e:new Error(String(e))))},C=e=>{if(e.header.cmdId===i)if(e.header.msgNum===r&&e.header.responseCode>=400)d(new Error(`Baichuan snapshot request rejected (cmdId=${i} msgNum=${r} responseCode=${e.header.responseCode})`));else try{let t=!1;if(e.extension.length>0){this.tryDecryptXml(e.extension,e.header.channelId,g).includes("<binaryData>1</binaryData>")&&(t=!0)}const s=this.tryDecryptBinary(e.payload,e.header.channelId,g);if(0===s.length)return;const n=s.subarray(0,Math.min(16,s.length)).toString("utf8"),r=n.startsWith("<?xml")||n.trimStart().startsWith("<");if(!t&&r)return;let i=s;if(!p){const n=(e=>{for(let t=0;t+1<e.length;t++)if(255===e[t]&&216===e[t+1])return t;return-1})(s);if(-1===n){if(!t)return;i=s,E.push(i);const n=Buffer.concat(E);return void(201===e.header.responseCode&&h(n))}p=!0,i=s.subarray(n)}E.push(i);const A=Buffer.concat(E);if((e=>{for(let t=0;t+1<e.length;t++)if(255===e[t]&&217===e[t+1])return!0;return!1})(A)||201===e.header.responseCode){const e=A.indexOf(Buffer.from([255,217]));if(-1!==e)return void h(A.subarray(0,e+2));h(A)}}catch(e){d(e)}};A=setTimeout((()=>{d(new Error(`Baichuan timeout waiting snapshot push cmdId=${i} msgNum=${r}`))}),I),this.on("frame",C);try{this.logDebug("tx",{cmdId:i,msgNum:r,channelId:s,messageClass:a,bodyLen:l,binary:!0,snapshot:!0}),this.recordTx({cmdId:i,responseCode:0,msgNum:r,channelId:s,streamType:e.streamType??0}),this.writeWire(u)}catch(e){d(e)}}))}tryDecryptBinary(e,t,s){if(0===e.length)return e;const n=s=>{try{return"none"===s.kind?e:"bc"===s.kind?B(e,t):"aes"===s.kind||"full_aes"===s.kind?f(e,s.key):null}catch{return null}};return n(s)??("bc"===s.kind||"none"===this.enc.kind||"aes"!==this.enc.kind&&"full_aes"!==this.enc.kind?null:n(this.enc))??("bc"!==s.kind?n({kind:"bc"}):null)??n({kind:"none"})??e}async login(e="full_aes"){if(this.loggedIn)return;let t,s=e;const r=e=>new Promise((t=>setTimeout(t,e)));for(let e=1;e<=3;e++)try{const e="none"===s?56320:"bc"===s?56321:56338;await this.connect();const t=this.nextMsgNum(),r=1,A=m({cmdId:r,bodyLen:0,channelId:250,streamType:0,msgNum:t,responseCode:e,messageClass:n.VY}),o=`${r}:${t}`,a=new Promise(((e,t)=>{const s=setTimeout((()=>{this.pending.delete(o),t(new Error("Baichuan timeout waiting for nonce"))}),1e4);this.pending.set(o,{resolve:t=>{clearTimeout(s),e(t)},reject:e=>{clearTimeout(s),t(e)}})}));a.catch((()=>{})),this.writeWire(A);const c=await a,l=c.header.responseCode;if(l>>>8!=221)throw new Error(`Baichuan login: expected encryption info (0xDDxx), got 0x${l.toString(16)}`);const h=255&l,g=v(this.tryDecryptXml(c.body,c.header.channelId,0===h?{kind:"none"}:{kind:"bc"}),"nonce");if(!g)throw new Error("Baichuan login: nonce not found in XML");if(this.nonce=g,0===h)this.enc={kind:"none"};else if(1===h)this.enc={kind:"bc"};else if(2===h)this.enc={kind:"aes",key:p(g,this.opts.password)};else{if(18!==h)throw new Error(`Baichuan login: unknown encType=0x${h.toString(16)}`);this.enc={kind:"full_aes",key:p(g,this.opts.password)}}const d=E(`${this.opts.username}${g}`),u=E(`${this.opts.password}${g}`),I=(i=u,`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<LoginUser version="1.1">\n<userName>${w(d)}</userName>\n<password>${w(i)}</password>\n<userVer>1</userVer>\n</LoginUser>\n<LoginNet version="1.1">\n<type>LAN</type>\n<udpPort>0</udpPort>\n</LoginNet>\n</body>`);this.logDebug("login_hash",{username:this.opts.username,nonce:g,userHash:d,passHashLength:u.length,loginXmlLength:I.length,loginXmlPreview:I.substring(0,200)});const C=await this.sendFrame({cmdId:1,payloadXml:I,extensionXml:"",messageClass:n.Uh,encryption:{kind:"bc"},timeoutMs:1e4}),B=this.tryDecryptXml(C.body,C.header.channelId,{kind:"bc"});if(this.logDebug("login_reply",{replyLength:B.length,replyPreview:B.substring(0,200),startsWithXml:B.startsWith("<?xml")}),0===B.length)throw new Error("Baichuan login failed: empty reply (camera may be sleeping/waking, session may be stale, or username/password may be invalid)");if(!B.startsWith("<?xml")){const e=B.length>0?B.substring(0,100):"(empty)";throw new Error(`Baichuan login: unexpected non-XML reply (length: ${B.length}, preview: ${e})`)}return void(this.loggedIn=!0)}catch(n){t=n,this.loggedIn=!1;const i=String(n&&"object"==typeof n&&"message"in n?n.message:n);(i.includes("timeout waiting for nonce")||i.includes("expected encryption info")||i.includes("Baichuan socket closed")||i.includes("ECONNRESET")||i.includes("EPIPE"))&&("full_aes"===s||"aes"===s?s="bc":"bc"===s&&(s="none"));try{await this.close()}catch{}if(e<3){await r(1500);continue}throw n}var i;throw t instanceof Error?t:new Error(String(t))}},te=class e{static sessionPool=new Map;host;username;password;port;useHttps;insecureTLS;timeoutMs;token;tokenExpiresAt;httpsAgent;constructor(e){this.host=e.host,this.username=e.username,this.password=e.password,this.port=e.port,this.useHttps=e.useHttps,this.insecureTLS=e.insecureTLS??!0,this.timeoutMs=e.timeoutMs??3e4,this.insecureTLS&&(this.httpsAgent=new c.g6({connect:{rejectUnauthorized:!1}}))}getUsername(){return this.username}getToken(){return this.token}clearToken(){this.token=void 0,this.tokenExpiresAt=void 0}sessionKey(){const e=this.useHttps?"https":"http",t=this.port??(this.useHttps?443:80);return`${e}://${this.host}:${t}|${this.username}`}getSharedSession(){const t=this.sessionKey(),s=e.sessionPool.get(t);if(s)return s;const n={};return e.sessionPool.set(t,n),n}baseUrl(){const e=this.useHttps?"https":"http",t=this.port??(this.useHttps?443:80);return`${e}://${this.host}:${t}`}apiUrl(e){const t=new URLSearchParams;for(const[s,n]of Object.entries(e))null!=n&&t.set(s,String(n));return`${this.baseUrl()}/cgi-bin/api.cgi?${t.toString()}`}isTokenValid(){return!(!this.token||!this.tokenExpiresAt)&&Date.now()+1e4<this.tokenExpiresAt}isSharedTokenValid(e){return!(!e.token||!e.tokenExpiresAt)&&Date.now()+1e4<e.tokenExpiresAt}async performLogin(){const e=[{cmd:"Login",action:0,param:{User:{userName:this.username,password:this.password}}}],t=await this.sendJson(e,{cmd:"Login"},{includeToken:!1}),s=t[0];if(!s||0!==s.code||!s.value?.Token?.name)throw new Error(`Login failed: ${JSON.stringify(t)}`);const n=Number(s.value.Token.leaseTime),r=s.value.Token.name,i=Date.now()+(Number.isFinite(n)?1e3*n:0);this.token=r,this.tokenExpiresAt=i;const A=this.getSharedSession();A.token=r,A.tokenExpiresAt=i}async login(){if(this.isTokenValid())return;const e=this.getSharedSession();return this.isSharedTokenValid(e)?(this.token=e.token,void(this.tokenExpiresAt=e.tokenExpiresAt)):e.loginInFlight?(await e.loginInFlight,void(this.isSharedTokenValid(e)&&(this.token=e.token,this.tokenExpiresAt=e.tokenExpiresAt))):(e.loginInFlight=(async()=>{try{await this.performLogin()}finally{delete e.loginInFlight}})(),void await e.loginInFlight)}async logout(){if(this.token)try{await this.call("Logout",{action:0,param:{}})}finally{this.clearToken();const e=this.getSharedSession();delete e.token,delete e.tokenExpiresAt}}async call(e,t){await this.login();const s=[{cmd:e,action:t?.action??0,...t&&"param"in t&&void 0!==t.param?{param:t.param}:{}}];return await this.sendJson(s,{cmd:e,token:this.token},{includeToken:!0})}async callMany(e){return await this.login(),await this.sendJson(e,{token:this.token},{includeToken:!0})}async sendJson(e,t,s){const n=this.apiUrl(t),r=new AbortController,i=setTimeout((()=>r.abort()),this.timeoutMs);try{const t={method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json"},signal:r.signal};this.useHttps&&this.httpsAgent&&(t.dispatcher=this.httpsAgent);const s=await fetch(n,t),i=await s.text();if(!s.ok)throw new Error(`HTTP ${s.status}: ${i}`);return JSON.parse(i)}finally{clearTimeout(i)}}async snap(e,t){if(await this.login(),!this.token)throw new Error("Missing token after login");const s=t?.rs??Date.now().toString(),n=this.apiUrl({cmd:"Snap",channel:e,rs:s,token:this.token}),r=new AbortController,i=setTimeout((()=>r.abort()),t?.timeoutMs??this.timeoutMs);try{const e={method:"GET",signal:r.signal};this.useHttps&&this.httpsAgent&&(e.dispatcher=this.httpsAgent);const t=await fetch(n,e);if(!t.ok){const e=await t.text().catch((()=>""));throw new Error(`HTTP ${t.status}: ${e}`)}const s=await t.arrayBuffer();return Buffer.from(s)}finally{clearTimeout(i)}}async downloadVod(e,t,s){if(await this.login(),!this.token)throw new Error("Missing token after login");const n=this.useHttps?"https":"http",r=this.port??(this.useHttps?443:80),i=e.replaceAll(" ","%20"),A=t?encodeURIComponent(t):void 0,o=s?encodeURIComponent(s):void 0,a=encodeURIComponent(this.token),c=`${n}://${this.host}:${r}/cgi-bin/api.cgi?cmd=Download&source=${i}${A?`&output=${A}`:""}${o?`&start=${o}`:""}&token=${a}`,l=new AbortController,h=setTimeout((()=>l.abort()),this.timeoutMs);try{const e={method:"POST",body:"[{}]",headers:{"Content-Type":"application/json"},signal:l.signal};this.useHttps&&this.httpsAgent&&(e.dispatcher=this.httpsAgent);const t=await fetch(c,e);if(!t.ok){const e=await t.text().catch((()=>""));throw new Error(`HTTP ${t.status}: ${e}`)}const s=await t.arrayBuffer();return Buffer.from(s)}finally{clearTimeout(h)}}},se=class{client;constructor(e){this.client=new te(e)}async login(){await this.client.login()}async logout(){await this.client.logout()}async call(e,t,s=0){return void 0===t?await this.client.call(e,{action:s}):await this.client.call(e,{action:s,param:t})}async callMany(e){return await this.client.callMany(e)}async GetDevInfo(e){const t=null==e?{}:{channel:e};return await this.call("GetDevInfo",t)}async getInfo(e,t){const s=await this.GetDevInfo(e),n=s?.[0]?.value?.DevInfo,r={},i=n?.type??n?.model??n?.exactType,A=n?.exactType??n?.model??n?.detail;"string"==typeof i&&(r.type=i),"string"==typeof n?.hardVer&&(r.hardwareVersion=n.hardVer),"string"==typeof n?.firmVer&&(r.firmwareVersion=n.firmVer),"string"==typeof A&&(r.itemNo=A),"string"==typeof n?.serial&&(r.serialNumber=n.serial),"string"==typeof n?.name&&(r.name=n.name);const o=t?.tags?.length?t.tags:["type","hardwareVersion","firmwareVersion","itemNo","serialNumber","name"],a={};for(const e of o){const t=r[e];"string"==typeof t&&(a[e]=t)}return a}async GetChnTypeInfo(e){const t=null==e?{}:{channel:e};return await this.call("GetChnTypeInfo",t)}async GetChannelstatus(){return await this.call("GetChannelstatus",void 0,0)}async GetLocalLink(e){const t=null==e?{}:{channel:e};return await this.call("GetLocalLink",t)}async GetWifiSignal(e){const t=null==e?{}:{channel:e};return await this.call("GetWifiSignal",t)}async GetOsd(e){const t=null==e?{}:{channel:e};return await this.call("GetOsd",t,1)}async SetOsd(e){return await this.call("SetOsd",e,0)}async GetEnc(e){const t=null==e?{}:{channel:e};return await this.call("GetEnc",t,1)}async GetAiState(e){const t=null==e?{}:{channel:e};return await this.call("GetAiState",t,0)}async GetMdState(e){const t=null==e?{}:{channel:e};return await this.call("GetMdState",t,0)}async GetEvents(e){const t=null==e?{}:{channel:e};return await this.call("GetEvents",t,0)}async GetBatteryInfo(e){const t=null==e?{}:{channel:e};return await this.call("GetBatteryInfo",t,0)}async GetWhiteLed(e){const t=null==e?{}:{channel:e};return await this.call("GetWhiteLed",t,0)}async SetWhiteLed(e){return await this.call("SetWhiteLed",e,0)}async GetPirInfo(e){const t=null==e?{}:{channel:e};return await this.call("GetPirInfo",t,0)}async SetPirInfo(e){return await this.call("SetPirInfo",e,0)}async GetPtzPreset(e){const t=null==e?{}:{channel:e};return await this.call("GetPtzPreset",t,1)}async GetAudioAlarmV20(e){const t=null==e?{}:{channel:e};return await this.call("GetAudioAlarmV20",t,0)}async AudioAlarmPlay(e){return await this.call("AudioAlarmPlay",e,0)}async GetNetPort(){return await this.call("GetNetPort",{})}async SetNetPort(e){return await this.call("SetNetPort",{NetPort:e})}async Reboot(e){const t=null==e?{}:{channel:e};return await this.call("Reboot",t)}async GetAbility(){const e=this.client.getUsername();return await this.call("GetAbility",{User:{userName:e}})}async getChannels(e){const t=await this.GetChannelstatus(),s=t?.[0]?.value?.status;let n=(s??[]).filter((e=>!!e?.uid)).map((e=>Number(e?.channel))).filter((e=>Number.isFinite(e)));if(0===n.length&&e?.useChannelNumFallback)try{const e=await this.GetDevInfo(),t=e?.[0]?.value?.DevInfo,s=t?.channelNum;null!=s&&s>0&&(n=Array.from({length:s},((e,t)=>t)))}catch(e){}return{channels:n,channelsResponse:t}}async getNvrInfo(){const e=[{cmd:"GetAbility",action:0,param:{User:{userName:this.client.getUsername()}}},{cmd:"GetDevInfo",action:0,param:{}}],t=await this.callMany(e),s=t.find((e=>"GetAbility"===e?.cmd))?.value,n=t.find((e=>"GetDevInfo"===e?.cmd))?.value,r=n?.DevInfo;return{abilities:s,nvrData:n,devInfo:r,response:t}}async getDevicesInfo(e){const{channels:t,channelsResponse:s}=await this.getChannels(e),n=this.client.getUsername(),r=[];r.push({cmd:"GetAbility",action:0,param:{User:{userName:n}}});for(const e of t)r.push({cmd:"GetChnTypeInfo",action:0,param:{channel:e}},{cmd:"GetAiState",action:0,param:{channel:e}},{cmd:"GetEnc",action:1,param:{channel:e}});const i=await this.callMany(r),A=i[0]?.value,o=A?.Ability?.abilityChn,a={};for(let e=0;e<t.length;e++){const n=t[e],r=1+3*e,A=i[r],c=i[r+1],l=i[r+2],h=s?.[0]?.value?.status?.find((e=>e?.channel===n)),g={entries:[A,c,l]};h&&(g.channelStatus=h);const d=o?.[n];d&&(g.abilities=d),A?.error||(g.channelInfo=A?.value),c?.error||(g.ai=c?.value),l?.error||(g.enc=l?.value),a[n]=g}return{devicesData:a,response:i,channels:t,channelsResponse:s,requestBody:r}}async getAllChannelsEvents(e){const{channels:t,channelsResponse:s}=await this.getChannels(e),n=[],r={};for(const e of t)r[e]={},n.push({cmd:"GetEvents",action:0,param:{channel:e}}),r[e].events=n.length-1,n.push({cmd:"GetMdState",action:0,param:{channel:e}}),r[e].motion=n.length-1,n.push({cmd:"GetAiState",action:0,param:{channel:e}}),r[e].ai=n.length-1;const i=await this.callMany(n),A=e=>{const t=[];for(const s of Object.keys(e??{})){if("channel"===s)continue;const n=e?.[s]?.alarm_state;n&&t.push(s)}return t},o={};for(const e of t){const{events:t,motion:s,ai:n}=r[e]??{},a=null!=t?i[t]:void 0,c=null!=s?i[s]:void 0,l=null!=n?i[n]:void 0,h=new Set;for(const e of A(l?.value))h.add(e);for(const e of A(a?.value?.ai??a?.value))h.add(e);const g=Array.from(h),d=g.filter((e=>"other"!==e)),u=!!c?.value?.state||g.length>0;o[e]={motion:u,objects:d,entries:[a,c,l]}}return{parsed:o,response:i,channels:t,channelsResponse:s,requestBody:n}}async getAllChannelsBatteryInfo(e){const{channels:t,channelsResponse:s}=await this.getChannels(e),n=[{cmd:"GetChannelstatus"}],r={};for(const e of t)n.push({cmd:"GetBatteryInfo",action:0,param:{channel:e}}),r[e]=n.length-1;const i=await this.callMany(n),A=i[0],o={};for(const e of t){const t=i[r[e]]?.value?.Battery??void 0,s=A?.value?.status?.find((t=>t?.channel===e));o[e]={entries:[t,s],batteryLevel:Number(t?.batteryPercent??0),sleeping:1===s?.sleep}}return{batteryInfoData:o,response:i,channels:t,channelsResponse:s,requestBody:n}}async getStatusInfo(e){const t=[],s={};for(const[n,r]of e.entries())s[n]={},r.sleeping||(t.push({cmd:"GetOsd",action:1,param:{channel:n}}),s[n].osd=t.length-1,r.hasFloodlight&&(t.push({cmd:"GetWhiteLed",action:0,param:{channel:n}}),s[n].floodlight=t.length-1),r.hasPirEvents&&(t.push({cmd:"GetPirInfo",action:0,param:{channel:n}}),s[n].pir=t.length-1),r.hasPtz&&(t.push({cmd:"GetPtzPreset",action:1,param:{channel:n}}),s[n].presets=t.length-1));const n=await this.callMany(t),r={};for(const[t,i]of e.entries()){const{osd:e,floodlight:A,pir:o,presets:a}=s[t]??{};if(r[t]={entries:[]},null!=e){const s=n[e];r[t].osd=s,r[t].entries.push(s)}if(i.hasFloodlight&&null!=A){const e=n[A];r[t].floodlightEnabled=1===e?.value?.WhiteLed?.state,r[t].entries.push(e)}if(i.hasPirEvents&&null!=o){const e=n[o];r[t].pirEnabled=1===e?.value?.pirInfo?.enable,r[t].entries.push(e)}if(i.hasPtz&&null!=a){const e=n[a],s=e?.value?.PtzPreset;r[t].ptzPresets=Array.isArray(s)?s.filter((e=>1===e?.enable)):[],r[t].entries.push(e)}}return{deviceStatusData:r,response:n}}async getOsd(e){const t=await this.GetOsd(e);return t?.[0]}async setOsd(e,t){const s=t?.value?.Osd??t?.Osd,n={Osd:{channel:e,osdChannel:s?.osdChannel??t?.osdChannel,osdTime:s?.osdTime??t?.osdTime}};await this.call("SetOsd",n,0)}async getEncoderConfiguration(e){const t=await this.GetEnc(e);return t?.[0]?.value?.Enc}async jpegSnapshot(e,t=1e4){return await this.client.snap(e,{timeoutMs:t})}async getSiren(e){const t=await this.GetAudioAlarmV20(e);return{enabled:1===t?.[0]?.value?.Audio?.enable}}async setSiren(e,t,s){const n=s?{channel:e,alarm_mode:"times",times:s}:{channel:e,alarm_mode:"manul",manual_switch:t?1:0},r=await this.AudioAlarmPlay(n);return{value:r?.[0]?.value??r?.value,data:r}}async setWhiteLedState(e,t,s){const n={channel:e};void 0!==t&&(n.state=t?1:0),void 0!==s&&(n.bright=s),await this.SetWhiteLed({WhiteLed:n})}async getPirState(e){const t=await this.GetPirInfo(e),s=t?.[0]?.value?.pirInfo;return{enabled:1===s?.enable,state:s}}async setPirState(e,t){const s=await this.getPirState(e),n=t?1:0,r=s?.state?.enable;if(r===n)return;const i={...s?.state&&"object"==typeof s.state?s.state:{},channel:e,enable:n};await this.SetPirInfo({pirInfo:i})}async getLocalLink(e){const t=[{cmd:"GetLocalLink",action:0,param:{}},{cmd:"GetWifiSignal",action:0,param:{channel:e}}],s=await this.callMany(t),n=s.find((e=>"GetLocalLink"===e?.cmd))?.value?.LocalLink?.activeLink,r=s.find((e=>"GetWifiSignal"===e?.cmd))?.value?.wifiSignal;let i=!1;return void 0!==r&&(i=r>=0&&r<=4),!i&&n&&(i="LAN"!==n),{activeLink:n,wifiSignal:r,isWifi:i}}async collectNvrDiagnostics(e){return await(0,n.Bz)({cgi:this,logger:e.logger})}printNvrDiagnostics(e,t){(0,n.gW)(e,t)}};async function*ne(e,t,s){const r=new n.tj({client:e.client,api:e,channel:t,profile:s,logger:e.logger});let i=null,A=null,o=null,a=!1,c=!1;const l=e=>{c=!0},h=()=>{c=!0};try{await r.start(),r.on("error",l),r.on("close",h);const e=new Promise((e=>{const t=s=>{s.isKeyframe&&!i&&(i={sps:null,pps:null},r.removeListener("videoAccessUnit",t),e(i))};r.on("videoAccessUnit",t),setTimeout((()=>{i||(i={sps:null,pps:null},r.removeListener("videoAccessUnit",t),e(i))}),5e3)}));await Promise.race([e,new Promise((e=>setTimeout(e,5e3)))]);const t=[],s=200;let n=null;for(r.on("videoAccessUnit",(e=>{c||(t.push({audio:!1,data:e.data,codec:null,sampleRate:null,microseconds:e.microseconds,videoType:e.videoType}),t.length>s&&t.splice(0,t.length-s),n&&(n(),n=null))})),r.on("audioFrame",(e=>{c||(A||(A="aac",o=8e3),t.push({audio:!0,data:e,codec:A,sampleRate:o,microseconds:null}),t.length>s&&t.splice(0,t.length-s),n&&(n(),n=null))})),a=!0;!c;)if(t.length>0){const e=t.shift();yield e}else await new Promise((e=>{n=e,setTimeout((()=>{n===e&&(n=null,e())}),1e3)}))}finally{c=!0;try{await r.stop()}catch{}r.removeListener("error",l),r.removeListener("close",h)}}var re=class{key;transport;videoType;keepAliveTimer;constructor(e,t){this.transport=e,this.videoType=t,this.key=function(e,t){return`${e}-${"H264"===t?"h264":"h265"}`}(e,t)}async startKeepAlive(e){this.stopKeepAlive(),e.client.getTransport()}stopKeepAlive(){this.keepAliveTimer&&(clearInterval(this.keepAliveTimer),this.keepAliveTimer=void 0)}},ie=Buffer.from([0,0,0,1]);function Ae(...e){const t=e.filter((e=>!!e&&e.length>0));if(0===t.length)return null;const s=[];for(const e of t)s.push(ie,e);return Buffer.concat(s)}var oe=class extends re{ffmpegFormat="h264";sdpCodec="H264";sps=null;pps=null;constructor(e){super(e,"H264")}extractParameterSets(e){const t=(0,n.Kv)(e);for(const e of t){if(e.length<1)continue;const t=31&(e[0]??0);if(7!==t||this.sps||(this.sps=e),8!==t||this.pps||(this.pps=e),this.sps&&this.pps)break}}getFmtp(){let e="packetization-mode=1";if(this.sps&&this.sps.length>=4){e+=`;profile-level-id=${Buffer.from([this.sps[1],this.sps[2],this.sps[3]]).toString("hex")}`}return this.sps&&this.pps?(e+=`;sprop-parameter-sets=${this.sps.toString("base64")},${this.pps.toString("base64")}`,{fmtp:e,hasParamSets:!0}):{fmtp:e,hasParamSets:!1}}getParameterSetsAnnexB(){return Ae(this.sps,this.pps)}},ae=class extends re{ffmpegFormat="hevc";sdpCodec="H265";vps=null;sps=null;pps=null;constructor(e){super(e,"H265")}extractParameterSets(e){const t=(0,n.N_)(e),s=(0,n.YO)(e),r=(0,n.Rp)(e);t&&!this.vps&&(this.vps=t),s&&!this.sps&&(this.sps=s),r&&!this.pps&&(this.pps=r)}getFmtp(){let e="";return this.vps&&this.sps&&this.pps?(e=`sprop-vps=${this.vps.toString("base64")};sprop-sps=${this.sps.toString("base64")};sprop-pps=${this.pps.toString("base64")}`,{fmtp:e,hasParamSets:!0}):{fmtp:e,hasParamSets:!1}}getParameterSetsAnnexB(){return Ae(this.vps,this.sps,this.pps)}};function ce(e,t){return"H264"===t?new oe(e):new ae(e)}var le=class{maxItems;queue=[];waiting;closed=!1;constructor(e){this.maxItems=Math.max(1,0|e)}push(e){if(!this.closed){if(this.waiting){const{resolve:t}=this.waiting;return this.waiting=void 0,void t({value:e,done:!1})}this.queue.push(e),this.queue.length>this.maxItems&&this.queue.splice(0,this.queue.length-this.maxItems)}}close(){if(!this.closed&&(this.closed=!0,this.waiting)){const{resolve:e}=this.waiting;this.waiting=void 0,e({value:void 0,done:!0})}}async next(){if(this.closed)return{value:void 0,done:!0};const e=this.queue.shift();return void 0!==e?{value:e,done:!1}:await new Promise((e=>{this.waiting={resolve:e}}))}},he=class{opts;queues=new Map;source=null;running=!1;pumpPromise=null;constructor(e){this.opts=e}start(){this.running||(this.running=!0,this.source=this.opts.createSource(),this.pumpPromise=(async()=>{try{for await(const e of this.source){try{this.opts.onFrame?.(e)}catch{}for(const t of this.queues.values())t.push(e)}}catch(e){this.opts.onError?.(e)}finally{for(const e of this.queues.values())e.close();this.queues.clear()}})())}subscribe(e){const t=new le(this.opts.maxQueueItems);this.queues.set(e,t);const s=this;return async function*(){try{for(;;){const e=await t.next();if(e.done)return;yield e.value}}finally{t.close(),s.queues.delete(e)}}()}async stop(){if(!this.running)return;this.running=!1;const e=this.source;this.source=null;for(const e of this.queues.values())e.close();this.queues.clear();try{await(e?.return(void 0))}catch{}try{await this.pumpPromise}catch{}this.pumpPromise=null}};var ge=class e extends i.EventEmitter{api;channel;profile;listenHost;listenPort;path;logger;tcpRtpFraming;active=!1;flow;connectedClients=new Set;nativeStreamActive=!1;clientConnectionServer;streamMetadata=null;clientResources=new Map;isRtspDebugEnabled(){return this.api.client.getDebugConfig().debugRtsp||function(e,t){if(null==e)return t;const s=e.trim().toLowerCase();return"1"===s||"true"===s||"yes"===s||"on"===s||"0"!==s&&"false"!==s&&"no"!==s&&"off"!==s&&t}(process.env.BAICHUAN_DEBUG_RTSP,!1)}rtspDebugLog(e){this.isRtspDebugEnabled()&&this.logger.debug(`[BaichuanRtspServer] ${e}`)}firstFramePromise=null;firstFrameResolve=null;firstFrameReceived=!1;firstAudioPromise=null;firstAudioResolve=null;firstAudioDetected=!1;hasAudio=!1;audioInfo=null;audioPrimingFrame=null;tempStreamGenerator=null;nativeFanout=null;noClientAutoStopTimer;static isAdtsAacFrame(e){return e.length>=2&&255===e[0]&&!(240&~e[1])}static parseAdtsSamplingInfo(t){if(t.length<7)return null;if(!e.isAdtsAacFrame(t))return null;const s=t[2]>>2&15,n=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][s]??null;if(!n)return null;const r=(1&t[2])<<2|t[3]>>6&3,i=0===r?1:r,A=(t[2]>>6&3)+1<<11|s<<7|r<<3;return{sampleRate:n,channels:i,configHex:Buffer.from([A>>8&255,255&A]).toString("hex")}}static parseInterleavedChannels(e){const t=e.match(/interleaved\s*=\s*(\d+)\s*-\s*(\d+)/i);if(!t)return null;const s=Number.parseInt(t[1],10),n=Number.parseInt(t[2],10);return Number.isFinite(s)&&Number.isFinite(n)?{rtp:s,rtcp:n}:null}static splitAnnexBNals(e){const t=[],s=e.length,n=t=>{if(t+3<=s&&0===e[t]&&0===e[t+1]){if(1===e[t+2])return 3;if(t+4<=s&&0===e[t+2]&&1===e[t+3])return 4}return 0};let r=0;for(;r<s;){if(n(r))break;r++}for(;r<s;){const i=n(r);if(!i){r++;continue}const A=r+i;let o=A;for(;o<s;){if(n(o))break;o++}if(A<o){const s=e.subarray(A,o);s.length>0&&t.push(s)}r=o}return t}static stripAdtsHeader(t){if(!e.isAdtsAacFrame(t))return null;if(t.length<7)return null;const s=!(1&~t[1])?7:9;return t.length<=s?null:t.subarray(s)}constructor(e){super(),this.api=e.api,this.channel=e.channel,this.profile=e.profile,this.listenHost=e.listenHost??"127.0.0.1",this.listenPort=e.listenPort??8554,this.path=e.path??`/stream/${this.profile}`,this.logger=e.logger??console,this.tcpRtpFraming=e.tcpRtpFraming??"rfc4571";const t=this.api.client.getTransport();this.flow=ce(t,"H264")}clearNoClientAutoStopTimer(){this.noClientAutoStopTimer&&(clearTimeout(this.noClientAutoStopTimer),this.noClientAutoStopTimer=void 0)}setFlowVideoType(e,t){if(this.flow.videoType===e)return;const s=this.api.client.getTransport();this.flow.stopKeepAlive(),this.flow=ce(s,e),this.rtspDebugLog(`Using RTSP flow ${this.flow.key} (${t})`)}async start(){if(this.active)throw new Error("RTSP server is already active");try{const e=(await this.api.getStreamMetadata(this.channel)).streams.find((e=>e.profile===this.profile));if(e){this.streamMetadata={frameRate:e.frameRate||25,width:e.width,height:e.height};const t=String(e.videoEncType??"").trim().toLowerCase(),s=t.includes("265")||t.includes("hevc")?"H265":"H264";this.setFlowVideoType(s,"metadata")}}catch(e){this.logger.warn(`[BaichuanRtspServer] Could not get stream metadata: ${e}`),this.streamMetadata={frameRate:25,width:1920,height:1080},this.setFlowVideoType("H264","metadata unavailable")}this.clientConnectionServer=A.createServer((e=>{this.handleRtspConnection(e)})),await new Promise(((e,t)=>{this.clientConnectionServer.listen(this.listenPort,this.listenHost,(()=>{const t=this.clientConnectionServer.address();t&&"object"==typeof t&&"port"in t&&(this.listenPort=t.port),e()})),this.clientConnectionServer.on("error",(e=>{t(e)}))})),this.active=!0,this.logger.info(`[BaichuanRtspServer] RTSP server started on ${this.listenHost}:${this.listenPort}, path: ${this.path}`)}handleRtspConnection(t){const s=`${t.remoteAddress}:${t.remotePort}`;this.logger.info(`[BaichuanRtspServer] RTSP client connected: ${s}`);let n,r="",i=Buffer.alloc(0),A=!1,o=null,a=null;const c=()=>{this.removeClient(s);const e=this.clientResources.get(s);if(e){if(e.ffmpeg)try{e.ffmpeg.stdin?.end(),e.ffmpeg.kill("SIGTERM"),setTimeout((()=>{try{e.ffmpeg?.kill("SIGKILL")}catch{}}),1e3)}catch{}if(e.udpSocket)try{e.udpSocket.close()}catch{}if(e.udpSocketAudio)try{e.udpSocketAudio.close()}catch{}if(e.rtspSocket&&!e.rtspSocket.destroyed)try{e.rtspSocket.destroy()}catch{}this.clientResources.delete(s)}if(n){try{n.stdin?.end(),n.kill("SIGTERM"),setTimeout((()=>{try{n?.kill("SIGKILL")}catch{}}),1e3)}catch{}n=void 0}if(o){try{o.close()}catch{}o=null}if(a){try{a.close()}catch{}a=null}};t.on("close",c),t.on("error",(e=>{e&&"object"==typeof e&&"code"in e&&"EPIPE"!==e.code&&this.logger.error("[BaichuanRtspServer] RTSP client error:",e),c()})),t.on("data",(async l=>{for(i=Buffer.concat([i,l]);i.includes("\r\n\r\n");){const l=i.indexOf("\r\n\r\n"),h=i.subarray(0,l).toString();if(i=i.subarray(l+4),!h.trim())continue;const g=h.split("\r\n"),d=g[0]?.split(" ");if(!d||d.length<3)continue;const u=d[0],I=d[1],E=d[2],p=h.match(/CSeq:\s*(\d+)/i),C=p?parseInt(p[1]??"0",10):0,B=(e,s,n={},r)=>{let i=`${E} ${e} ${s}\r\n`;i+=`CSeq: ${C}\r\n`;for(const[e,t]of Object.entries(n))i+=`${e}: ${t}\r\n`;r&&(i+=`Content-Length: ${Buffer.byteLength(r,"utf8")}\r\n`),i+="\r\n",r&&(i+=r),t.write(i)};if(this.rtspDebugLog(`RTSP ${u} ${I}`),"OPTIONS"===u)B(200,"OK",{Public:"DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, OPTIONS"});else if("DESCRIBE"===u){if(!this.firstFrameReceived&&0===this.connectedClients.size){try{this.nativeStreamActive||await this.startNativeStream()}catch(e){this.logger.warn(`[BaichuanRtspServer] Failed to start native stream for SDP priming: ${e}`)}const{hasParamSets:e}=this.flow.getFmtp();if(!e){const e="udp"===this.api.client.getTransport()?4e3:1500;try{await Promise.race([this.firstFramePromise||Promise.resolve(),new Promise((t=>setTimeout(t,e)))])}catch{}}}{const{fmtp:e,hasParamSets:t}=this.flow.getFmtp(),n=e.length>160?`${e.slice(0,160)}...`:e;this.logger.info(`[BaichuanRtspServer] DESCRIBE SDP for ${s} path=${this.path} codec=${this.flow.sdpCodec} hasParamSets=${t} fmtp=${n}`),t||this.rtspDebugLog(`DESCRIBE responding without parameter sets yet (client=${s}, path=${this.path}, flow=${this.flow.key})`)}const e=this.generateSdp();B(200,"OK",{"Content-Type":"application/sdp","Content-Base":`rtsp://${this.listenHost}:${this.listenPort}${this.path}/`},e)}else if("SETUP"===u){const i=I?.includes("track0"),c=I?.includes("track1");if(!i&&!c){B(404,"Not Found",{Session:r||`session_${Date.now()}_${Math.random().toString(36).substring(7)}`});continue}if(c&&!this.hasAudio){B(404,"Not Found",{Session:r||`session_${Date.now()}_${Math.random().toString(36).substring(7)}`});continue}this.connectedClients.add(s),this.emit("client",s),this.clearNoClientAutoStopTimer(),1!==this.connectedClients.size||this.nativeStreamActive||await this.startNativeStream();const l=h.match(/Transport:\s*([^\r\n]+)/i),g=(l?.[1]??"").trim();A=!g||(g.includes("TCP")||g.includes("tcp")),r||(r=`session_${Date.now()}_${Math.random().toString(36).substring(7)}`);const d=this.clientResources.get(s);if(d?d.rtspSocket=t:this.clientResources.set(s,{ffmpeg:void 0,udpSocket:null,udpSocketAudio:null,rtspSocket:t,pipelineStarted:!1,seenFirstVideoKeyframe:!1,setupTrack0:!1,setupTrack1:!1,isPlaying:!1}),A){const t=this.clientResources.get(s),n=e.parseInterleavedChannels(g);if(t)if(c){const e=n??{rtp:2,rtcp:3};t.track1RtpChannel=e.rtp,t.track1RtcpChannel=e.rtcp}else{const e=n??{rtp:0,rtcp:1};t.track0RtpChannel=e.rtp,t.track0RtcpChannel=e.rtcp}}{const e=this.clientResources.get(s);e&&!e.pipelineStarted&&(e.pipelineStarted=!0,await this.startClientFfmpeg(s,t,A,((e,t,r)=>{n=e,o=t,a=r;const i=this.clientResources.get(s);i&&(i.ffmpeg=e,i.udpSocket=t,i.udpSocketAudio=r)})))}{const e=this.clientResources.get(s);e&&(c?e.setupTrack1=!0:e.setupTrack0=!0,this.rtspDebugLog(`SETUP done for ${s}: track0=${!!e.setupTrack0} track1=${!!e.setupTrack1} playing=${!!e.isPlaying}`))}if(A){const e=this.clientResources.get(s),t=c?{rtp:2,rtcp:3}:{rtp:0,rtcp:1};B(200,"OK",{Transport:`RTP/AVP/TCP;unicast;interleaved=${`${c?e?.track1RtpChannel??t.rtp:e?.track0RtpChannel??t.rtp}-${c?e?.track1RtcpChannel??t.rtcp:e?.track0RtcpChannel??t.rtcp}`}`,Session:r})}else B(200,"OK",{Transport:"RTP/AVP/UDP;unicast;client_port=5004-5005;server_port=5004-5005",Session:r})}else if("PLAY"===u){{const e=this.clientResources.get(s);e&&(e.isPlaying=!0,this.rtspDebugLog(`PLAY for ${s}: track0=${!!e.setupTrack0} track1=${!!e.setupTrack1} playing=${!!e.isPlaying}`))}B(200,"OK",{Session:r,Range:"npt=0.000-"})}else"TEARDOWN"===u?(c(),B(200,"OK",{Session:r}),t.end()):B(501,"Not Implemented")}}))}generateSdp(){const e=this.flow.sdpCodec;let t="v=0\r\n";t+=`o=- ${Date.now()} ${Date.now()} IN IP4 ${this.listenHost}\r\n`,t+="s=Baichuan Stream\r\n",t+=`c=IN IP4 ${this.listenHost}\r\n`,t+="t=0 0\r\n",t+="m=video 0 RTP/AVP 96\r\n",t+=`a=rtpmap:96 ${e}/90000\r\n`,this.streamMetadata?.frameRate&&(t+=`a=framerate:${this.streamMetadata.frameRate}\r\n`),this.streamMetadata?.width&&this.streamMetadata?.height&&(t+=`a=framesize:96 ${this.streamMetadata.width}-${this.streamMetadata.height}\r\n`),t+="a=control:track0\r\n";const{fmtp:s,hasParamSets:n}=this.flow.getFmtp();if(n||this.logger.warn(`[BaichuanRtspServer] SDP missing parameter sets for flow ${this.flow.key}`),s&&(t+=`a=fmtp:96 ${s}\r\n`),this.hasAudio){t+="m=audio 0 RTP/AVP 97\r\n";const e=this.audioInfo,s=e?.sampleRate??8e3,n=e?.channels??1,r=e?.configHex??"";t+=`a=rtpmap:97 mpeg4-generic/${s}/${n}\r\n`,r&&(t+=`a=fmtp:97 streamtype=5; profile-level-id=15; mode=AAC-hbr; config=${r}; SizeLength=13; IndexLength=3; IndexDeltaLength=3;\r\n`),t+="a=control:track1\r\n"}return t+="a=setup:passive\r\n",t+="a=connection:new\r\n",t}async startClientFfmpeg(t,s,r,i){let A=this.streamMetadata;if(!A||!A.frameRate)try{const e=(await this.api.getStreamMetadata(this.channel)).streams.find((e=>e.profile===this.profile));e&&(A={frameRate:e.frameRate||25,width:e.width,height:e.height},this.rtspDebugLog(`Fetched metadata for profile ${this.profile}: ${A.frameRate} fps`))}catch(e){this.logger.warn(`[BaichuanRtspServer] Could not fetch stream metadata: ${e}`),A={frameRate:25,width:1920,height:1080}}const a=this.flow.ffmpegFormat;let c=0,h=0,g=null,d=null;const u=r,I=(e,t)=>{if("rfc4571"===(r?"rtsp-interleaved":this.tcpRtpFraming)){const e=Buffer.alloc(2);return e.writeUInt16BE(65535&t.length,0),Buffer.concat([e,t])}const s=Buffer.alloc(4);return s[0]=36,s[1]=255&e,s[2]=t.length>>8&255,s[3]=255&t.length,Buffer.concat([s,t])};if(r&&!u){c=5e4+Math.floor(1e4*Math.random()),g=o.createSocket("udp4"),await new Promise(((e,t)=>{g.once("listening",(()=>e())),g.once("error",t),g.bind(c,"127.0.0.1")}));const e=(e,n)=>{if(!s||s.destroyed||!s.writable)return!1;if(n.length<12)return!1;if(2!==(n[0]>>6&3))return!1;const r=this.clientResources.get(t);if(!r?.isPlaying)return!1;const i=r?.track0RtpChannel??0,A=r?.track1RtpChannel??2;if(e===i&&!r?.setupTrack0)return!1;if(e===A&&!r?.setupTrack1)return!1;try{return s.write(I(e,n))}catch(e){if(e&&"object"==typeof e&&"code"in e&&"EPIPE"===e.code)return!1}return!1};if(g){const s=this.clientResources.get(t),n=s?.track0RtpChannel??0;let r=0,i=!1,A=!1;g.on("message",(s=>{i||(i=!0,this.rtspDebugLog(`First video RTP packet received from ffmpeg for client ${t} (len=${s.length})`));e(n,s)&&!A&&(A=!0,this.rtspDebugLog(`First video RTP packet forwarded via TCP interleaved for client ${t}`)),r++,r%1e3==0&&this.rtspDebugLog(`Forwarded ${r} RTP packets to client ${t} via TCP interleaved`)}))}if(this.hasAudio){h=c+2+2*Math.floor(1e3*Math.random()),d=o.createSocket("udp4"),await new Promise(((e,t)=>{d.once("listening",(()=>e())),d.once("error",t),d.bind(h,"127.0.0.1")}));let s=0,n=!1,r=!1;d.on("message",(i=>{const A=this.clientResources.get(t),o=A?.track1RtpChannel??2;s++,n||(n=!0,this.rtspDebugLog(`First audio RTP packet received from ffmpeg for client ${t} (len=${i.length})`));e(o,i)&&!r&&(r=!0,this.rtspDebugLog(`First audio RTP packet forwarded via TCP interleaved for client ${t}`)),s%1e3==0&&this.rtspDebugLog(`Forwarded ${s} audio RTP packets to client ${t} via TCP interleaved`)}))}}const E=this.clientResources.get(t),p=this.isRtspDebugEnabled(),C=e=>this.rtspDebugLog(e),B=(e,t)=>{if(!s||s.destroyed||!s.writable)return!1;try{return s.write(I(e,t))}catch(e){if(e&&"object"==typeof e&&"code"in e&&"EPIPE"===e.code)return!1}return!1},Q=(e,t,s,n,r)=>{const i=Buffer.alloc(12);return i[0]=128,i[1]=(t?128:0)|127&e,i.writeUInt16BE(65535&s,2),i.writeUInt32BE(n>>>0,4),i.writeUInt32BE(r>>>0,8),i},f=(e,t,s)=>{const n=e?97:96;if(E?.isPlaying&&(!e||E?.setupTrack1)&&(e||E?.setupTrack0))if(e){void 0===E.rtpAudioSeq&&(E.rtpAudioSeq=Math.floor(65536*Math.random())),void 0===E.rtpAudioTimestamp&&(E.rtpAudioTimestamp=0),void 0===E.rtpAudioSsrc&&(E.rtpAudioSsrc=4294967295*Math.random()>>>0);const e=Q(n,s,E.rtpAudioSeq,E.rtpAudioTimestamp,E.rtpAudioSsrc);E.rtpAudioSeq=E.rtpAudioSeq+1&65535,B(E?.track1RtpChannel??2,Buffer.concat([e,t]))}else{void 0===E.rtpVideoSeq&&(E.rtpVideoSeq=Math.floor(65536*Math.random())),void 0===E.rtpVideoTimestamp&&(E.rtpVideoTimestamp=0),void 0===E.rtpVideoSsrc&&(E.rtpVideoSsrc=4294967295*Math.random()>>>0);const e=Q(n,s,E.rtpVideoSeq,E.rtpVideoTimestamp,E.rtpVideoSsrc);E.rtpVideoSeq=E.rtpVideoSeq+1&65535,B(E?.track0RtpChannel??0,Buffer.concat([e,t]))}},m=1200,y=t=>{const s=e.splitAnnexBNals(t);for(const e of s){if(e.length<1)continue;if(5===(31&(e[0]??0)))return!0}return!1},S=(e,t)=>{if(e.length<=m)return void f(!1,e,t);const s=e[0],n=31&s,r=224&s|28,i=e.subarray(1);let A=0;for(;A<i.length;){const e=i.length-A,s=Math.min(e,1198),o=0===A,a=A+s>=i.length,c=(o?128:0)|(a?64:0)|n,l=i.subarray(A,A+s),h=Buffer.concat([Buffer.from([r,c]),l]);f(!1,h,t&&a),A+=s}},w=(e,t)=>{if(e.length<=m)return void f(!1,e,t);if(e.length<3)return;const s=e[0],n=s>>1&63,r=129&s|98,i=e[1],A=e.subarray(2);let o=0;for(;o<A.length;){const e=A.length-o,s=Math.min(e,1197),a=0===o,c=o+s>=A.length,l=(a?128:0)|(c?64:0)|63&n,h=A.subarray(o,o+s),g=Buffer.concat([Buffer.from([r,i,l]),h]);f(!1,g,t&&c),o+=s}},D=A?.frameRate&&A.frameRate>0?A.frameRate:25,b=Math.max(1,Math.round(9e4/D)),v=e=>{if(!E)return;if(null==e)return;if(!Number.isFinite(e))return;if(void 0===E.rtpVideoTimestamp&&(E.rtpVideoTimestamp=0),void 0===E.rtpVideoBaseTimestamp&&(E.rtpVideoBaseTimestamp=E.rtpVideoTimestamp),void 0===E.rtpVideoBaseMicroseconds)return E.rtpVideoBaseMicroseconds=e>>>0,void(E.rtpVideoLastTimestamp=E.rtpVideoTimestamp);const t=(e>>>0)-(E.rtpVideoBaseMicroseconds>>>0)>>>0;let s=((E.rtpVideoBaseTimestamp??0)>>>0)+Math.round(9e4*t/1e6)>>>0;const n=E.rtpVideoLastTimestamp;void 0!==n&&s<=n>>>0&&(s=1+(n>>>0)>>>0),E.rtpVideoTimestamp=s,E.rtpVideoLastTimestamp=s},N=(t,s,n=!0)=>{const r=e.splitAnnexBNals(s);if(0!==r.length){for(let e=0;e<r.length;e++){const s=r[e],n=e===r.length-1;"H265"===t?w(s,n):S(s,n)}n&&void 0!==E?.rtpVideoTimestamp&&void 0===E?.rtpVideoBaseMicroseconds&&(E.rtpVideoTimestamp=E.rtpVideoTimestamp+b>>>0)}},R=t=>{const s=e.stripAdtsHeader(t);if(!s)return;const n=Buffer.from([0,16]),r=8191&s.length,i=Buffer.alloc(2);i[0]=r>>5&255,i[1]=(31&r)<<3;const A=Buffer.concat([n,i,s]);f(!0,A,!0),void 0!==E?.rtpAudioTimestamp&&(E.rtpAudioTimestamp=E.rtpAudioTimestamp+1024>>>0)},k=e=>{const t=(0,n.S8)(e);for(const e of t){if(e.length<2)continue;const t=e[0];if(void 0===t)continue;if(128&t)continue;const s=t>>1&63;if((0,n.uQ)(s))return!0}return!1};let T,F;if(u&&i(void 0,null,null),!u){const e=["-hide_banner","-loglevel","error","-fflags","+genpts+igndts"],s=A?.frameRate||25;if(s>0&&(e.push("-r",s.toString()),this.rtspDebugLog(`Using frame rate ${s} fps for client ${t}`)),e.push("-f",a,"-i","pipe:0"),this.hasAudio&&e.push("-f","aac","-i","pipe:3"),r){if(e.push("-map","0:v:0","-c:v","copy","-vsync","cfr","-avoid_negative_ts","make_zero","-f","rtp","-payload_type","96",`rtp://127.0.0.1:${c}?pkt_size=1300`),this.hasAudio&&d&&h){const t=this.audioInfo,s=t?.sampleRate??8e3,n=t?.channels??1;e.push("-map","1:a:0","-c:a","aac","-profile:a","aac_low","-ar",String(s),"-ac",String(n),"-flags:a","+global_header","-f","rtp","-payload_type","97",`rtp://127.0.0.1:${h}?pkt_size=1300`)}}else e.push("-map","0:v:0","-c:v","copy","-vsync","cfr","-avoid_negative_ts","make_zero","-f","rtp","-payload_type","96","rtp://127.0.0.1:5004?pkt_size=1300");const n=["pipe","ignore","pipe"];this.hasAudio&&n.push("pipe"),this.rtspDebugLog(`Spawning ffmpeg for client ${t}: ffmpeg ${e.join(" ")}`),T=(0,l.spawn)("ffmpeg",e,{stdio:n});try{const e=this.flow.getParameterSetsAnnexB();e&&e.length>0&&T?.stdin&&(T.stdin.write(e),this.rtspDebugLog(`Wrote video parameter sets to ffmpeg stdin for client ${t} (len=${e.length})`))}catch(e){this.logger.warn(`[BaichuanRtspServer] Failed to write video parameter sets to ffmpeg for client ${t}: ${e}`)}if(T.on("error",(e=>{this.logger.error(`[BaichuanRtspServer] Failed to spawn ffmpeg for client ${t}:`,e)})),T.on("close",((e,s)=>{this.rtspDebugLog(`ffmpeg exited for client ${t} (code=${e}, signal=${s})`)})),i(T,g,d),T.stdin?.on("error",(e=>{const s=e?.code;"EPIPE"!==s&&"ERR_STREAM_WRITE_AFTER_END"!==s?this.logger.error(`[BaichuanRtspServer] FFmpeg stdin error for client ${t}:`,e):this.rtspDebugLog(`FFmpeg stdin error (${s}) for client ${t}`)})),F=this.hasAudio?T.stdio?.[3]:void 0,F?.on?.("error",(e=>{const s=e?.code;"EPIPE"!==s&&"ERR_STREAM_WRITE_AFTER_END"!==s?this.logger.error(`[BaichuanRtspServer] FFmpeg audio pipe error for client ${t}:`,e):this.rtspDebugLog(`FFmpeg audio pipe error (${s}) for client ${t}`)})),F&&this.audioPrimingFrame)try{F.write(this.audioPrimingFrame)}catch{}}this.rtspDebugLog(`Creating native stream iterator for client ${t}`);const M=this.nativeFanout?this.nativeFanout.subscribe(t):ne(this.api,this.channel,this.profile);this.tempStreamGenerator=null;let U=0,L=Date.now();const P=A&&A.frameRate>0?1e3/A.frameRate:40;(async()=>{try{this.rtspDebugLog(`Starting to feed frames to client ${t} (target FPS: ${A?.frameRate||25}, interval: ${P}ms)`);let s=0,r=!1,i=!1,o=!1,a=!1,c=!1;for await(const A of M){if(!this.connectedClients.has(t)){this.rtspDebugLog(`Client ${t} disconnected, stopping frame feed`);break}const l=T?.stdin;if(!u&&(!l||l.destroyed||l.writableEnded||l.writableFinished)){this.rtspDebugLog(`FFmpeg stdin closed for client ${t}`);break}if(0===A.data.length)continue;if(!A.audio&&!o&&(o=!0,p)){const e=A.data.subarray(0,16).toString("hex");C(`First video frame received from generator for client ${t} (len=${A.data.length}, videoType=${String(A.videoType??this.flow.videoType)}, head=${e})`)}if(A.audio){if(s++,1===s&&this.rtspDebugLog(`Audio frames detected (codec: ${A.codec||"unknown"}, sampleRate: ${A.sampleRate||"unknown"})`),s%100==0&&this.rtspDebugLog(`Received ${s} audio frames (not sent to RTSP yet)`),u){if(!E?.seenFirstVideoKeyframe)continue;if(this.hasAudio&&e.isAdtsAacFrame(A.data)){if(p&&!i){i=!0;const e=A.data.subarray(0,16).toString("hex");C(`First audio ADTS frame packetized to RTP for client ${t} (len=${A.data.length}, head=${e})`)}R(A.data)}continue}if(this.hasAudio&&F&&!F.writableEnded&&!F.writableFinished){const s=F;if(!s)continue;if(e.isAdtsAacFrame(A.data))try{if(!i){i=!0;const e=A.data.subarray(0,16).toString("hex");this.rtspDebugLog(`First audio frame written to ffmpeg pipe for client ${t} (len=${A.data.length}, head=${e})`)}s.write(A.data)||await new Promise((e=>s.once("drain",(()=>e()))))}catch{}}continue}if("H264"===A.videoType||"H265"===A.videoType){const e="H264"===A.videoType?(0,n.rB)(A.data):(0,n.nf)(A.data);0===U&&this.setFlowVideoType(A.videoType,"first video frame");if(this.flow.getFmtp().hasParamSets)this.firstFrameReceived||this.markFirstFrameReceived();else{this.flow.extractParameterSets(e);this.flow.getFmtp().hasParamSets&&this.markFirstFrameReceived()}}U++,U%100==0&&this.rtspDebugLog(`Sent ${U} frames to client ${t} (frame size: ${A.data.length} bytes)`);const h=Date.now(),g=P-(h-L);if(g>0&&await new Promise((e=>setTimeout(e,Math.min(g,2*P)))),L=Date.now(),u){const e=A.videoType??this.flow.videoType,s="H264"===e?(0,n.rB)(A.data):(0,n.nf)(A.data);if(!E?.seenFirstVideoKeyframe)if("H265"===e){const{hasParamSets:n}=this.flow.getFmtp();if(!n){p&&!a&&(a=!0,C(`H265 gating: waiting for VPS/SPS/PPS before sending RTP to client ${t}`));continue}if(!E?.rtpSentVideoConfig){const t=this.flow.getParameterSetsAnnexB();t&&t.length>0&&(N(e,t,!1),E.rtpSentVideoConfig=!0)}E.h265WaitStartMs||(E.h265WaitStartMs=Date.now());const r=k(s),i=Date.now()-E.h265WaitStartMs;if(!r&&i<2e3){p&&!c&&(c=!0,C(`H265 gating: waiting for IRAP (or timeout) for client ${t}`));continue}E.seenFirstVideoKeyframe=!0}else{const{hasParamSets:n}=this.flow.getFmtp();if(!n){p&&!a&&(a=!0,C(`H264 gating: waiting for SPS/PPS before sending RTP to client ${t}`));continue}if(!E?.rtpSentVideoConfig){const t=this.flow.getParameterSetsAnnexB();t&&t.length>0&&(N(e,t,!1),E.rtpSentVideoConfig=!0)}if(!y(s))continue;E.seenFirstVideoKeyframe=!0}const i=A.microseconds;if(v(i),!E?.rtpSentVideoConfig){const t=this.flow.getParameterSetsAnnexB();t&&t.length>0&&(N(e,t,!1),E.rtpSentVideoConfig=!0)}if(!r&&(r=!0,p)){const e=A.data.subarray(0,16).toString("hex");C(`First video access unit packetized to RTP for client ${t} (len=${A.data.length}, head=${e})`)}N(e,s,!0)}else try{if(l&&!l.destroyed&&!l.writableEnded&&!l.writableFinished){if(!r){r=!0;const e=A.data.subarray(0,16).toString("hex");this.rtspDebugLog(`First video frame written to ffmpeg stdin for client ${t} (len=${A.data.length}, head=${e})`)}l.write("H264"===A.videoType?(0,n.rB)(A.data):A.data)||await new Promise((e=>{l?l.once("drain",(()=>e())):e()}))}}catch(e){const s=e?.code;if("EPIPE"===s||"ERR_STREAM_WRITE_AFTER_END"===s){this.rtspDebugLog(`EPIPE writing to ffmpeg for client ${t}`);break}this.logger.error(`[BaichuanRtspServer] Error writing frame to ffmpeg for client ${t}:`,e)}}this.rtspDebugLog(`Finished feeding frames to client ${t} (total: ${U} frames)`)}catch(e){this.logger.error(`[BaichuanRtspServer] Error in feedFrames for client ${t}:`,e)}})().catch((e=>{this.logger.error(`[BaichuanRtspServer] Error feeding frames to client ${t}:`,e)})),T?.stderr?.on("data",(e=>{const s=e.toString();(s.includes("error")||s.includes("Error"))&&this.logger.error(`[BaichuanRtspServer] FFmpeg error for client ${t}: ${s}`)}))}async startNativeStream(){this.nativeStreamActive||(this.nativeStreamActive=!0,this.firstFrameReceived=!1,this.firstAudioDetected=!1,this.hasAudio=!1,this.audioInfo=null,this.audioPrimingFrame=null,this.firstFramePromise=new Promise((e=>{this.firstFrameResolve=e})),this.firstAudioPromise=new Promise((e=>{this.firstAudioResolve=e})),this.rtspDebugLog(`Starting native stream for profile ${this.profile} (waiting for camera to start transmitting...)`),await this.flow.startKeepAlive(this.api),this.nativeFanout=new he({maxQueueItems:200,createSource:()=>ne(this.api,this.channel,this.profile),onFrame:t=>{if(t.audio){if(!this.hasAudio&&"tcp"===this.api.client.getTransport()&&e.isAdtsAacFrame(t.data)){const s=e.parseAdtsSamplingInfo(t.data);s&&(this.hasAudio=!0,this.audioInfo={codec:"aac-adts",sampleRate:s.sampleRate,channels:s.channels,configHex:s.configHex},this.audioPrimingFrame=Buffer.from(t.data),this.markFirstAudioDetected(),this.rtspDebugLog(`Audio detected (AAC/ADTS ${s.sampleRate}Hz ch=${s.channels}); advertising RTSP track1 as mpeg4-generic`))}return}if(0===t.data.length)return;"H264"!==t.videoType&&"H265"!==t.videoType||this.setFlowVideoType(t.videoType,"native stream"),this.flow.extractParameterSets(t.data);const{hasParamSets:s}=this.flow.getFmtp();s&&this.markFirstFrameReceived()},onError:e=>{this.logger.warn(`[BaichuanRtspServer] Shared native stream error: ${e}`)}}),this.nativeFanout.start(),this.clearNoClientAutoStopTimer(),this.noClientAutoStopTimer=setTimeout((()=>{0===this.connectedClients.size&&(this.rtspDebugLog("Auto-stopping primed native stream (no clients connected)"),this.stopNativeStream())}),15e3),this.noClientAutoStopTimer?.unref?.())}markFirstFrameReceived(){!this.firstFrameReceived&&this.firstFrameResolve&&(this.firstFrameReceived=!0,this.rtspDebugLog(`First frame received from camera for profile ${this.profile}`),this.firstFrameResolve(),this.firstFrameResolve=null)}markFirstAudioDetected(){!this.firstAudioDetected&&this.firstAudioResolve&&(this.firstAudioDetected=!0,this.firstAudioResolve(),this.firstAudioResolve=null)}async stopNativeStream(){if(this.nativeStreamActive){if(this.rtspDebugLog("Stopping native stream"),this.flow.stopKeepAlive(),this.clearNoClientAutoStopTimer(),this.nativeStreamActive=!1,this.firstFrameReceived=!1,this.firstFramePromise=null,this.firstFrameResolve&&(this.firstFrameResolve=null),this.firstAudioDetected=!1,this.firstAudioPromise=null,this.firstAudioResolve&&(this.firstAudioResolve=null),this.nativeFanout){const e=this.nativeFanout;this.nativeFanout=null,await e.stop()}if(this.tempStreamGenerator){try{await this.tempStreamGenerator.return(void 0)}catch{}this.tempStreamGenerator=null}}}removeClient(e){this.connectedClients.has(e)&&(this.connectedClients.delete(e),this.emit("clientDisconnected",e),this.logger.info(`[BaichuanRtspServer] RTSP client disconnected: ${e}`),0===this.connectedClients.size&&this.stopNativeStream())}async waitUntilReady(e=3e4){return new Promise(((t,s)=>{if(!this.clientConnectionServer)return void s(new Error("RTSP server not started"));const n=setTimeout((()=>{s(new Error(`Timeout waiting for RTSP server to be ready (${e}ms). Camera may be sleeping or not responding.`))}),e),r=()=>{const e=new A.Socket;e.setTimeout(1e3),e.on("connect",(()=>{e.destroy(),this.nativeStreamActive&&this.firstFramePromise?(this.rtspDebugLog("Port is listening, waiting for camera to start transmitting frames..."),this.firstFramePromise.then((()=>{clearTimeout(n),t()})).catch((e=>{clearTimeout(n),s(e)}))):(clearTimeout(n),t())})),e.on("timeout",(()=>{e.destroy(),setTimeout(r,500)})),e.on("error",(()=>{e.destroy(),setTimeout(r,500)})),e.connect(this.listenPort,this.listenHost)};r()}))}async stop(){if(!this.active)return;this.logger.info(`[BaichuanRtspServer] Stopping RTSP server on ${this.listenHost}:${this.listenPort}...`),await this.stopNativeStream();const e=Array.from(this.connectedClients);for(const t of e){const e=this.clientResources.get(t);if(e){if(e.ffmpeg)try{e.ffmpeg.stdin?.end(),e.ffmpeg.kill("SIGTERM"),setTimeout((()=>{try{e.ffmpeg?.kill("SIGKILL")}catch{}}),1e3)}catch{}if(e.udpSocket)try{e.udpSocket.close()}catch{}if(e.rtspSocket&&!e.rtspSocket.destroyed)try{e.rtspSocket.destroy()}catch{}}}this.clientResources.clear(),this.clientConnectionServer&&(await new Promise((e=>{this.clientConnectionServer?.close((()=>{e()}))})),this.clientConnectionServer=void 0),this.active=!1,this.connectedClients.clear(),this.emit("close"),this.logger.info("[BaichuanRtspServer] RTSP server stopped")}getRtspUrl(){return`rtsp://${this.listenHost}:${this.listenPort}${this.path}`}isActive(){return this.active}getClientCount(){return this.connectedClients.size}};async function de(e,t){const s=await d.promises.readdir(t,{withFileTypes:!0}),n=[];for(const r of s){const s=g.join(t,r.name),i=g.relative(e,s).replace(/\\/g,"/");r.isDirectory()?(n.push({absPath:s,relPath:i,isDir:!0}),n.push(...await de(e,s))):r.isFile()&&n.push({absPath:s,relPath:i,isDir:!1})}return n}async function ue(e){const{sourceDir:t,zipPath:s}=e;await d.promises.mkdir(g.dirname(s),{recursive:!0});const n=new u.u,r=await de(t,t),i=r.filter((e=>e.isDir)),A=r.filter((e=>!e.isDir));for(const e of i){const t=e.relPath.endsWith("/")?e.relPath:e.relPath+"/";n.addEmptyDirectory(t)}for(const e of A)n.addFile(e.absPath,e.relPath);const o=d.createWriteStream(s);await new Promise(((e,t)=>{o.on("error",t),n.outputStream.on("error",t),o.on("close",e),n.outputStream.pipe(o),n.end()}))}var Ie={resolution_index:[0,7],tv_system:[7,1],framerate:[8,7],audio_index:[15,2],ai_pd:[17,1],ai_fd:[18,1],ai_vd:[19,1],ai_ad:[20,1],encoder_type_index:[21,2],is_schedule_record:[23,1],is_motion_record:[24,1],is_rf_record:[25,1],is_doorbell_record:[26,1],ai_other:[27,1]},Ee={resolution_index:[0,7],tv_system:[7,1],framerate:[8,7],audio_index:[15,2],ai_pd:[17,1],ai_fd:[18,1],ai_vd:[19,1],ai_ad:[20,1],encoder_type_index:[21,2],is_schedule_record:[23,1],is_motion_record:[24,1],is_rf_record:[25,1],is_doorbell_record:[26,1],is_ai_other_record:[27,1],picture_layout_index:[28,7],package_delivered:[35,1],package_takenaway:[36,1]},pe={cam:{2:Ie,3:Ie,4:Ie,7:Ie,9:Ie,10:Ie},hub:{0:Ee,1:{...Ee,package_event:[37,1]},2:{resolution_index:[0,7],tv_system:[7,1],framerate:[8,7],audio_index:[15,2],ai_pd:[17,1],ai_fd:[18,1],ai_vd:[19,1],ai_ad:[20,1],ai_other:[21,2],encoder_type_index:[23,1],is_schedule_record:[24,1],is_motion_record:[25,1],is_rf_record:[26,1],is_doorbell_record:[27,1],picture_layout_index:[28,7],package_delivered:[35,1],package_takenaway:[36,1],package_event:[37,1],upload_flag:[38,1]}}};function Ce(e,t,s){const n=pe[e],r=n[t]??n[Math.max(...Object.keys(n).map((e=>Number(e))))];if(!r)return;const i=function(e,t){if(!e)return;if(!/^[0-9a-fA-F]+$/.test(e))return;const s=4*e.length,n=BigInt(`0x${e}`).toString(2).padStart(s,"0").split("").reverse().join(""),r=BigInt(`0b${n}`),i={};for(const[e,[s,n]]of Object.entries(t)){const t=BigInt(s),A=((r&(1n<<BigInt(n))-1n<<t)>>t).toString(2).padStart(n,"0").split("").reverse().join("");i[e]=Number.parseInt(A,2)}return i}(s,r);if(!i)return;return{raw:i,flags:{aiPerson:1===i.ai_pd,aiVehicle:1===i.ai_vd,aiAnimal:1===i.ai_ad,aiFace:1===i.ai_fd,aiOther:1===i.is_ai_other_record||1===i.ai_other||(i.ai_other??0)>0,schedule:1===i.is_schedule_record,motion:1===i.is_motion_record,rf:1===i.is_rf_record,doorbell:1===i.is_doorbell_record,package:1===i.package_event||1===i.package_delivered||1===i.package_takenaway}}}function Be(e,t){if(!/^\d{8}$/.test(e))return;if(!/^\d{6}$/.test(t))return;const s=Number.parseInt(e.slice(0,4),10),n=Number.parseInt(e.slice(4,6),10),r=Number.parseInt(e.slice(6,8),10),i=Number.parseInt(t.slice(0,2),10),A=Number.parseInt(t.slice(2,4),10),o=Number.parseInt(t.slice(4,6),10);return[s,n,r,i,A,o].every(Number.isFinite)?new Date(s,n-1,r,i,A,o):void 0}function Qe(e){const t=e.lastIndexOf(".");if(t<=0||t===e.length-1)return;const s=e.slice(t+1),n=e.slice(0,t).split("/").filter(Boolean).at(-1);if(!n)return;const r=n.split("_"),i=r[0]??"";if(!i.startsWith("Rec")||6!==i.length)return;const A=i[3],o="M"===A?"main":"S"===A?"sub":"unknown",a=Number.parseInt(i.slice(4,6),16);if(!Number.isFinite(a))return;let c,l,h,g="cam",d="",u="",I="",E="";if(6===r.length)d=r[1]??"",u=r[2]??"",I=r[3]??"",E=r[4]??"";else if(7===r.length)d=r[1]??"",u=r[2]??"",I=r[3]??"",c=r[4],E=r[5]??"";else{if(9!==r.length)return;g="hub",d=r[1]??"",u=r[2]??"",I=r[3]??"",c=r[4],l=r[5],h=r[6],E=r[7]??""}d=d.toLowerCase().replace("dst","");const p=Be(d,u);if(!p)return;const C="000000"===I?p:Be(d,I);if(!C)return;const B=Math.max(0,C.getTime()-p.getTime()),Q={baseName:n,ext:s,streamHint:o,version:a,devType:g,start:p,end:C,durationMs:B},f=Ce(g,a,E);return f&&(Q.flags=f.flags,Q.rawFlags=f.raw),null!=c&&(Q.animalTypeRaw=c),null!=l&&(Q.widthRaw=l),null!=h&&(Q.heightRaw=h),Q}function fe(e){if(null==e)return;const t=Number(e);return Number.isFinite(t)?t:void 0}function me(e){if("number"==typeof e)return e>0;if("string"==typeof e){const t=Number(e);return Number.isFinite(t)?t>0:e.length>0&&"0"!==e}return Boolean(e)}function ye(e,t){if(!e||"object"!=typeof e)return;const s=e,n=s[t],r=s.Host,i={...r&&"object"==typeof r?r:{},...n&&"object"==typeof n?n:{}};return Object.keys(i).length?i:void 0}function Se(e,t){if(!e)return!1;for(const[s,n]of Object.entries(e))if(t.test(s)&&me(n))return!0;return!1}function we(e){if(!e)return;const t=e.match(/<Support[^>]*>([\s\S]*?)<\/Support>/i);if(!t)return;const s=t[1]??"",n=s.match(/<ptzMode>([^<]*)<\/ptzMode>/i)?.[1],r=[];for(const e of s.matchAll(/<item[^>]*>([\s\S]*?)<\/item>/gi)){const t=e[1]??"",s={chnID:fe(t.match(/<chnID>([^<]*)<\/chnID>/i)?.[1])??0};for(const e of t.matchAll(/<([A-Za-z0-9_]+)>([^<]*)<\/\1>/g)){const t=e[1],n=e[2];if(!t)continue;if("chnID"===t)continue;const r=fe(n);s[t]=r??n}r.push(s)}const i={items:r};void 0!==n&&(i.ptzMode=n);const A=(e,t)=>{const n=(e=>{const t=s.match(new RegExp(`<${e}>([^<]*)<\\/${e}>`,"i"));return fe(t?.[1])})(t);void 0!==n&&(i[e]=n)};A("IOInputPortNum","IOInputPortNum"),A("IOOutputPortNum","IOOutputPortNum"),A("diskNum","diskNum"),A("channelNum","channelNum"),A("audioNum","audioNum"),A("ptzCfg","ptzCfg"),A("B485","B485"),A("autoUpdate","autoUpdate"),A("pushAlarm","pushAlarm"),A("ftp","ftp"),A("ftpTest","ftpTest"),A("email","email"),A("wifi","wifi"),A("record","record"),A("wifiTest","wifiTest"),A("rtsp","rtsp"),A("onvif","onvif"),A("audioTalk","audioTalk");const o=(e=>{const t=s.match(new RegExp(`<${e}>([^<]*)<\\/${e}>`,"i"));return t?.[1]})("subVersion");return void 0!==o&&(i.subVersion=o),i}function De(e){const{channel:t}=e,s=ye(e.abilities,t),n=function(e,t){if(!e?.items?.length)return;const s=e=>{const t=e;let s=0;null==t.name&&(s+=2);const n=["ptzType","ptzControl","ptzPreset","ledCtrl","lightType","battery","audioVersion","motion","encCtrl","newIspCfg","remoteAbility"];for(const e of n)void 0!==t[e]&&(s+=3);return s+=Math.min(10,Math.max(0,Object.keys(t).length-1)),s};return(t=>{const n=e.items.filter((e=>e.chnID===t));if(n.length)return n.slice().sort(((e,t)=>s(t)-s(e)))[0]})(t)}(e.support,t),r=e.support?.ptzMode,i="string"==typeof r?r.toLowerCase():void 0,A=n?n.ptzType:void 0,o=n?n.ptzControl:void 0,a=me(A)||me(o)||me(n?.ptzPreset),c=("none"===i||"0"===i)&&!a,l=!!n&&me(n.battery),h=!!n&&me(n.ptzPreset),g=n?n.doorbellVersion:void 0,d=Number.isFinite(Number(g))?Number(g)>0:me(g),u=n?n.lightType:void 0,I="number"==typeof u?u:"string"==typeof u?Number(u):void 0,E=a||!!i&&("none"!==i&&"0"!==i),p=!!i&&(i.includes("pt")||"pt"===i||"ptz"===i),C=!!i&&i.includes("z"),B=Se(s,/battery/i),Q=Se(s,/white\s*led|whiteLed|flood\s*light|floodlight/i),f=Se(s,/audio\s*alarm|audioAlarm|siren|pushAlarn|audioPlay/i),m=me(e.support?.audioTalk)||!!n&&me(n.ipcAudioTalk),y=Se(s,/ptz/i),S=Se(s,/zoom|zoomFocus|StartZoomFocus/i),w=Se(s,/preset/i),D=Se(s,/(^|_)pir/i)||Se(s,/rfAlarm/i)||Se(s,/mdWithPir/i),b=!!n&&(me(n.rfCfg)||me(n.newRfCfg)||me(n.rfVersion)||me(n.battery)),v=!c&&(p||y),N=!c&&(p||y),R=!c&&(C||S),k=!c&&(h||w),T={channel:t,hasPan:v,hasTilt:N,hasZoom:R,hasPresets:k,hasPtz:!c&&(E||v||N||R||k),hasBattery:l||B,hasIntercom:m,hasSiren:f,hasFloodlight:Number.isFinite(I)?I>0:Q,hasPir:D||b,isDoorbell:d};return void 0!==i&&(T.ptzMode=i),T}function be(e){if(null!=e){if("boolean"==typeof e)return e;if("number"==typeof e)return 1===e;if("string"==typeof e){const t=e.trim().toLowerCase();if("1"===t||"true"===t||"yes"===t||"on"===t)return!0;if("0"===t||"false"===t||"no"===t||"off"===t)return!1}}}function ve(e){const t=function(e){if(!e||0===e.length)return[];const t=e[0]?.value;if(!t)return[];let s=t?.status??t?.Channelstatus??t?.ChannelStatus??t?.channelStatus??t?.channelstatus;if(!Array.isArray(s))if(Array.isArray(t))s=t;else if(s=t?.channels??t?.Channels??t?.channel??t?.Channel,!Array.isArray(s)){const e=Object.keys(t).filter((e=>/^channel\d+$/i.test(e)||/^ch\d+$/i.test(e)));e.length>0&&(s=e.map((e=>{const s=t[e];return"object"==typeof s&&null!==s?s:{channel:parseInt(e.replace(/\D/g,""),10)}})))}return Array.isArray(s)?s:[]}(e);if(!t.length)return[];const s=[];for(const e of t){if("object"!=typeof e||null===e)continue;const t=e?.channel??e?.id??e?.channelId??e?.Channel??e?.ID??e?.ChannelId;if("number"!=typeof t||!Number.isFinite(t))continue;const n="string"==typeof e?.name?e.name:void 0,r="string"==typeof e?.uid?e.uid:void 0,i="string"==typeof e?.typeInfo?e.typeInfo:void 0,A=be(e?.online),o=be(e?.sleep);s.push({channel:t,...void 0!==A?{online:A}:{},...void 0!==o?{sleep:o}:{},...n?{name:n}:{},...r?{uid:r}:{},...i?{typeInfo:i}:{}})}return s.sort(((e,t)=>e.channel-t.channel)),s}function Ne(e){return new Promise((t=>setTimeout(t,e)))}function Re(e,t){const s=new RegExp(`<${t}\\b[^>]*>([\\s\\S]*?)<\\/${t}>`,"g"),n=[];let r;for(;r=s.exec(e);)n.push(r[1]??"");return n}function ke(e){const t=Number.parseInt(v(e,"year")??"",10),s=Number.parseInt(v(e,"month")??"",10),n=Number.parseInt(v(e,"day")??"",10),r=Number.parseInt(v(e,"hour")??"",10),i=Number.parseInt(v(e,"minute")??"",10),A=Number.parseInt(v(e,"second")??"",10);if([t,s,n,r,i,A].every(Number.isFinite))return new Date(t,s-1,n,r,i,A)}function Te(e,t){return`<${e}><year>${t.getFullYear()}</year><month>${t.getMonth()+1}</month><day>${t.getDate()}</day><hour>${t.getHours()}</hour><minute>${t.getMinutes()}</minute><second>${t.getSeconds()}</second></${e}>`}function Fe(e){const t=[],s=Re(e,"FileInfo");for(const e of s){const s=v(e,"Id")??v(e,"ID")??v(e,"id"),n=v(e,"name")??v(e,"fileName"),r=(s??n)?.trim();if(!r)continue;const i={fileName:r};null!=n&&n.trim()&&(i.name=n.trim()),null!=s&&s.trim()&&(i.id=s.trim());const A=v(e,"type")??v(e,"recordType")??v(e,"alarmType");null!=A&&(i.recordType=A);const o=v(e,"size")??v(e,"fileSize"),a=o?Number.parseInt(o,10):void 0;null!=a&&Number.isFinite(a)&&(i.sizeBytes=a);const c=Re(e,"startTime")[0],l=Re(e,"endTime")[0],h=c?ke(c):void 0,g=l?ke(l):void 0;h&&(i.startTime=h),g&&(i.endTime=g);const d=Qe(i.name??i.fileName);d&&(i.parsedFileName=d,i.startTime||(i.startTime=d.start),i.endTime||(i.endTime=d.end)),t.push(i)}const n=Re(e,"File");for(const e of n){const s=v(e,"fileName")??v(e,"name");if(!s)continue;const n=v(e,"size")??v(e,"fileSize"),r=n?Number.parseInt(n,10):void 0,i=v(e,"type")??v(e,"recordType")??v(e,"alarmType"),A=Re(e,"startTime")[0],o=Re(e,"endTime")[0],a={fileName:s};null!=r&&Number.isFinite(r)&&(a.sizeBytes=r),null!=i&&(a.recordType=i);const c=A?ke(A):void 0,l=o?ke(o):void 0;c&&(a.startTime=c),l&&(a.endTime=l);const h=Qe(a.fileName);h&&(a.parsedFileName=h,a.startTime||(a.startTime=h.start),a.endTime||(a.endTime=h.end)),t.push(a)}if(0===t.length){const s=/<fileName>([\s\S]*?)<\/fileName>/g;let n;for(;n=s.exec(e);){const e=(n[1]??"").trim();if(!e)continue;const s={fileName:e},r=Qe(e);r&&(s.parsedFileName=r,s.startTime=r.start,s.endTime=r.end),t.push(s)}}if(0===t.length){const s=Re(e,"alarmVideo");for(const e of s){const s=v(e,"fileName")??v(e,"name");if(!s)continue;const n={fileName:s},r=v(e,"alarmType");null!=r&&(n.recordType=r);const i=Re(e,"startTime")[0],A=Re(e,"endTime")[0],o=i?ke(i):void 0,a=A?ke(A):void 0;o&&(n.startTime=o),a&&(n.endTime=a);const c=Qe(n.fileName);c&&(n.parsedFileName=c,n.startTime||(n.startTime=c.start),n.endTime||(n.endTime=c.end)),t.push(n)}}const r=new Set;return t.filter((e=>!r.has(e.fileName)&&(r.add(e.fileName),!0)))}function Me(e){const t=v(e,"audioType"),s=Number.parseInt(v(e,"sampleRate")??"",10),n=Number.parseInt(v(e,"samplePrecision")??"",10),r=Number.parseInt(v(e,"lengthPerEncoder")??"",10),i=v(e,"soundTrack"),A=v(e,"priority");if(!(t&&Number.isFinite(s)&&Number.isFinite(n)&&Number.isFinite(r)&&i))return null;const o={audioType:t,sampleRate:s,samplePrecision:n,lengthPerEncoder:r,soundTrack:i};if(void 0!==A){const e=Number.parseInt(A,10);Number.isFinite(e)&&(o.priority=e)}return o}var Ue=new Set(["Reolink Duo PoE","Reolink Duo WiFi"]),Le=new Set(["Reolink TrackMix PoE","Reolink TrackMix WiFi","RLC-81MA"]),Pe=new Set([...Ue,...Le]);function He(e,t){const s=4+e.length,n=s%8==0?0:8-s%8,r=12+e.length+n,i=Buffer.alloc(r);return i.writeUInt32LE(1651978544,0),i.writeUInt16LE(s,4),i.writeUInt16LE(s,6),i.writeUInt16LE(256,8),i.writeUInt16LE(t,10),e.copy(i,12),i}var xe=class{client;logger;httpClient;host;username;password;rebootAfterDisconnectionsPerMinute;disconnectStormVoluntaryAtMs=[];disconnectStormRebootInFlight;disconnectStormLastRebootAtMs;simpleEventListeners=new Set;simpleEventSubscribed=!1;simpleEventSubscribeInFlight;simpleEventUnsubscribeInFlight;simpleEventResubscribeTimer;simpleEventResubscribeInFlight;simpleEventResubscribeIntervalMs=3e5;statePollingInterval;lastMotionState;lastAiState;aiStatePollingDisabled=!1;aiStatePollingDisabledLogged=!1;rtspServers=new Set;activeVideoMsgNums=new Map;lastSleepProbe;constructor(e){this.logger=e.logger??console,this.client=new ee(e),this.host=e.host,this.username=e.username,this.password=e.password,this.httpClient=new te({host:e.host,username:e.username,password:e.password,timeoutMs:6e5}),this.client.on("event",(e=>{const t=function(e){const t=e.timestamp??Date.now();if("motion"===e.type)return{type:"motion",channel:e.channel,timestamp:t};if("visitor"===e.type)return{type:"doorbell",channel:e.channel,timestamp:t};if("daynight"===e.type)return{type:"daynight",channel:e.channel,timestamp:t};if("ai"===e.type){const s=e.ai,n=s?.type;return{type:n?{people:"people",vehicle:"vehicle",dog_cat:"animal",face:"face",package:"package",other:"other"}[n]:"other",channel:e.channel,timestamp:t}}return null}(e);if(t)for(const e of this.simpleEventListeners)try{e(t)}catch(e){(this.logger.warn??this.logger.error).call(this.logger,"[ReolinkBaichuanApi] onSimpleEvent handler error",e)}}));const t=e.rebootAfterDisconnectionsPerMinute;"number"==typeof t&&Number.isFinite(t)&&t>0&&(this.rebootAfterDisconnectionsPerMinute=Math.floor(t),this.client.on("close",(()=>{try{this.maybeRebootOnDisconnectStorm()}catch{}})))}async runAllDiagnosticsConsecutively(e){const t=e.channel??0,s=e.outDir,r=(new Date).toISOString().replace(/[:.]/g,"-"),i=(0,g.join)(s,r);(this.logger.log??console.log).call(this.logger,"[Diagnostics] starting run",{outDir:s,runDir:i,channel:t,durationSeconds:e.durationSeconds,selection:e.selection});const A=!0===e.cgi||"object"==typeof e.cgi&&null!=e.cgi,o=A?new se({host:("object"==typeof e.cgi?e.cgi.host:void 0)??this.host,username:("object"==typeof e.cgi?e.cgi.username:void 0)??this.username,password:("object"==typeof e.cgi?e.cgi.password:void 0)??this.password,..."object"==typeof e.cgi&&null!=e.cgi.port?{port:e.cgi.port}:{},..."object"==typeof e.cgi&&null!=e.cgi.useHttps?{useHttps:e.cgi.useHttps}:{},..."object"==typeof e.cgi&&null!=e.cgi.insecureTLS?{insecureTLS:e.cgi.insecureTLS}:{},..."object"==typeof e.cgi&&null!=e.cgi.timeoutMs?{timeoutMs:e.cgi.timeoutMs}:{}}):void 0,a=await(0,n.lp)({outDir:i,native:{api:this,channel:t},...o?{cgi:{cgi:o,channel:t}}:{},...e.extra?{extra:e.extra}:{}});(this.logger.log??console.log).call(this.logger,"[Diagnostics] diagnostics bundle collected",{diagnosticsPath:a.diagnosticsPath,runDir:a.outDir,cgiEnabled:A});const c=(0,g.join)(i,"streams"),l=!0===e.rtsp||"object"==typeof e.rtsp&&null!=e.rtsp?{host:("object"==typeof e.rtsp?e.rtsp.host:void 0)??this.host,username:("object"==typeof e.rtsp?e.rtsp.username:void 0)??this.username,password:("object"==typeof e.rtsp?e.rtsp.password:void 0)??this.password,..."object"==typeof e.rtsp&&null!=e.rtsp.port?{port:e.rtsp.port}:{}}:void 0;await(0,n.kV)({outDir:c,durationSeconds:e.durationSeconds,...null!=e.snapshotIntervalSeconds?{snapshotIntervalSeconds:e.snapshotIntervalSeconds}:{},channel:t,selection:e.selection,...l?{rtsp:l}:{},...e.rtmp?{rtmp:e.rtmp}:{},native:{api:this},...e.limits?{limits:e.limits}:{},logger:this.logger}),(this.logger.log??console.log).call(this.logger,"[Diagnostics] stream sampling completed",{streamsDir:c});const h=(0,g.join)(s,`${r}.zip`);return(this.logger.log??console.log).call(this.logger,"[Diagnostics] creating zip bundle",{zipPath:h}),await ue({sourceDir:i,zipPath:h}),(this.logger.log??console.log).call(this.logger,"[Diagnostics] zip bundle created",{zipPath:h}),{runDir:a.outDir,zipPath:h,diagnosticsPath:a.diagnosticsPath,streamsDir:c}}async maybeRebootOnDisconnectStorm(){const e=this.rebootAfterDisconnectionsPerMinute;if(null==e)return;const t=this.client.getLastDisconnectInfo?.();if(!t?.voluntary)return;const s=Date.now(),n=s-6e4;for(;this.disconnectStormVoluntaryAtMs.length&&this.disconnectStormVoluntaryAtMs[0]<n;)this.disconnectStormVoluntaryAtMs.shift();if(this.disconnectStormVoluntaryAtMs.push(s),this.disconnectStormVoluntaryAtMs.length<e)return;if(this.disconnectStormRebootInFlight)return;const r=6e5;null!=this.disconnectStormLastRebootAtMs&&s-this.disconnectStormLastRebootAtMs<r||(this.disconnectStormLastRebootAtMs=s,(this.logger.warn??this.logger.error).call(this.logger,"[ReolinkBaichuanApi] disconnect storm detected; rebooting device",{transport:t.transport,reason:t.reason,voluntaryDisconnectsInWindow:this.disconnectStormVoluntaryAtMs.length,windowMs:6e4,threshold:e,cooldownMs:r,method:"auto"}),this.disconnectStormRebootInFlight=this.rebootFromDisconnectStorm("auto").catch((e=>{(this.logger.warn??this.logger.error).call(this.logger,"[ReolinkBaichuanApi] disconnect-storm reboot failed",e)})).finally((()=>{this.disconnectStormRebootInFlight=void 0})))}async rebootFromDisconnectStorm(e){let t;if("auto"===e||"baichuan"===e)try{return void await this.reboot()}catch(s){if(t=s,"baichuan"===e)throw s}if("auto"===e||"cgi"===e){const e=new se({host:this.host,username:this.username,password:this.password,timeoutMs:6e4});try{return await e.login(),void await e.Reboot()}catch(e){throw t=e,e}finally{try{await e.logout()}catch{}}}throw t instanceof Error?t:new Error(String(t??"disconnect-storm reboot failed"))}async onSimpleEvent(e){this.simpleEventListeners.add(e),await this.ensureSimpleEventSubscribed(),this.startSimpleEventResubscribeTimer()}async offSimpleEvent(e){if(e?this.simpleEventListeners.delete(e):this.simpleEventListeners.clear(),0===this.simpleEventListeners.size)this.stopSimpleEventResubscribeTimer(),await this.ensureSimpleEventUnsubscribed();else{"udp"===this.client.getTransport?.()||this.startStatePolling()}}startSimpleEventResubscribeTimer(){this.simpleEventResubscribeTimer||0!==this.simpleEventListeners.size&&(this.simpleEventResubscribeTimer=setInterval((()=>{this.renewSimpleEventSubscription()}),this.simpleEventResubscribeIntervalMs))}stopSimpleEventResubscribeTimer(){this.simpleEventResubscribeTimer&&(clearInterval(this.simpleEventResubscribeTimer),this.simpleEventResubscribeTimer=void 0)}async renewSimpleEventSubscription(){if(0!==this.simpleEventListeners.size)return this.simpleEventResubscribeInFlight||(this.simpleEventResubscribeInFlight=(async()=>{try{await this.subscribeEvents(),this.simpleEventSubscribed=!0,(this.logger.debug??this.logger.log).call(this.logger,"[ReolinkBaichuanApi] renewed simple event subscription",{intervalMs:this.simpleEventResubscribeIntervalMs})}catch(e){(this.logger.debug??this.logger.log).call(this.logger,"[ReolinkBaichuanApi] failed to renew event subscription",e)}})().finally((()=>{this.simpleEventResubscribeInFlight=void 0}))),await this.simpleEventResubscribeInFlight}async ensureSimpleEventSubscribed(){if(0!==this.simpleEventListeners.size&&!this.simpleEventSubscribed)return this.simpleEventSubscribeInFlight||(this.simpleEventSubscribeInFlight=(async()=>{this.client.subscribed||await this.subscribeEvents(),this.simpleEventSubscribed=!0;if(!("udp"===this.client.getTransport?.())){const e=this.client.getConfiguredChannel?.()??0;await this.checkAndDispatchCurrentState(e),this.startStatePolling()}})().finally((()=>{this.simpleEventSubscribeInFlight=void 0}))),await this.simpleEventSubscribeInFlight}async ensureSimpleEventUnsubscribed(){if(this.simpleEventSubscribed||this.client.subscribed){if(this.simpleEventUnsubscribeInFlight)return await this.simpleEventUnsubscribeInFlight;if(this.simpleEventSubscribeInFlight)try{await this.simpleEventSubscribeInFlight}catch{}return this.simpleEventUnsubscribeInFlight=(async()=>{await this.unsubscribeEvents(),this.simpleEventSubscribed=!1,this.stopSimpleEventResubscribeTimer(),this.stopStatePolling()})().finally((()=>{this.simpleEventUnsubscribeInFlight=void 0})),await this.simpleEventUnsubscribeInFlight}}normalizeChannel(e){return null==e?0:e}async login(e){await this.client.login(e)}async close(){this.stopStatePolling(),await this.cleanup(),await this.client.close()}async cleanup(){const e=Array.from(this.rtspServers);this.rtspServers.clear(),await Promise.allSettled(e.map((async e=>{try{await e.stop()}catch(e){this.logger.error("[ReolinkBaichuanApi] Error stopping RTSP server during cleanup:",e)}}))),e.length>0&&this.logger.info(`[ReolinkBaichuanApi] Cleaned up ${e.length} RTSP server(s)`)}async sendXml(e,t=3){this.client.loggedIn||await this.client.login();try{const s=await this.client.sendFrame(e);if(400===s.header.responseCode){if(t>0){if(0===s.body.length)try{this.client.loggedIn=!1,await this.client.login()}catch{}const n=1500;return await new Promise((e=>setTimeout(e,n))),await this.sendXml(e,t-1)}if(0===s.body.length)throw new Error("Baichuan request failed (responseCode 400, empty body). Possible causes: camera sleeping/waking (battery), expired session, or invalid username/password.")}if(0===s.body.length)return"";return this.client.tryDecryptXml(s.body,s.header.channelId,this.client.enc)}catch(e){throw e}}async getTalkAbility(e){return function(e){const t=Re(e,"TalkAbility")[0];if(!t)throw new Error("TalkAbility XML not found in response");return{duplexList:Re(t,"duplexList").map((e=>v(e,"duplex"))).filter((e=>!!e)),audioStreamModeList:Re(t,"audioStreamModeList").map((e=>v(e,"audioStreamMode"))).filter((e=>!!e)),audioConfigList:Re(t,"audioConfig").map(Me).filter((e=>!!e))}}(await this.sendXml({cmdId:n.XW,...void 0!==e?{channel:e}:{}}))}async createTalkSession(e=0,t){this.client.loggedIn||await this.client.login();const s="udp"===this.client.getTransport?.()?e:void 0,r=await this.getTalkAbility(e),i=r.audioConfigList.find((e=>"adpcm"===e.audioType.toLowerCase()))??r.audioConfigList[0];if(!i)throw new Error(`Talk not supported on channel ${e} (no audioConfig in TalkAbility)`);const A=r.duplexList[0]??"FDX",o=r.audioStreamModeList[0]??"followVideoStream",a={channel:e,duplex:A,audioStreamMode:o,audioConfig:i},c=Math.floor(i.lengthPerEncoder/2),l=c+4;if(c<=0||l<=4)throw new Error(`Invalid talk audio config: lengthPerEncoder=${i.lengthPerEncoder}`);const h=function(e){const t=e.audioConfig;return`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<TalkConfig version="1.1">\n<channelId>${e.channel}</channelId>\n<duplex>${w(e.duplex)}</duplex>\n<audioStreamMode>${w(e.audioStreamMode)}</audioStreamMode>\n<audioConfig>\n<audioType>${w(t.audioType)}</audioType>\n<sampleRate>${t.sampleRate}</sampleRate>\n<samplePrecision>${t.samplePrecision}</samplePrecision>\n<lengthPerEncoder>${t.lengthPerEncoder}</lengthPerEncoder>\n<soundTrack>${w(t.soundTrack)}</soundTrack>\n</audioConfig>\n</TalkConfig>\n</body>`}(a);await(async()=>{const t=await this.client.sendFrame({cmdId:n.Fi,channel:e,...null!=s?{channelIdOverride:s}:{},payloadXml:h,messageClass:n.Uh});if(422!==t.header.responseCode){if(200!==t.header.responseCode)throw new Error(`TalkConfig rejected (responseCode ${t.header.responseCode})`)}else{await this.client.sendFrame({cmdId:n.Oh,channel:e,...null!=s?{channelIdOverride:s}:{},payloadXml:"",messageClass:n.Uh});const t=await this.client.sendFrame({cmdId:n.Fi,channel:e,...null!=s?{channelIdOverride:s}:{},payloadXml:h,messageClass:n.Uh});if(200!==t.header.responseCode)throw new Error(`TalkConfig rejected after reset (responseCode ${t.header.responseCode})`)}})();const g={channel:e,audioConfig:i,blockSize:c,fullBlockSize:l};let d=Buffer.alloc(0),u=!1,I=!1,E=Date.now();const p=Math.max(1,Math.min(8,Math.floor(t?.blocksPerPayload??1))),C=async t=>{if(0===t.length)return;if(t.length>p)throw new Error(`Internal error: too many blocks in payload (${t.length})`);const r=[];let A=0;for(const e of t)r.push(He(e,c)),A+=Math.max(0,2*(e.length-4)+1);await this.client.sendBinaryPayloadNoReply({cmdId:n.O1,channel:e,...null!=s?{channelIdOverride:s}:{},extensionXml:b(e),payload:Buffer.concat(r),messageClass:n.Uh});const o=A/i.sampleRate*1e3,a=Date.now();a>E?E=a+o:E+=o;const l=E-Date.now();l>0&&await Ne(l)},B=async()=>{if(!I){I=!0;try{for(;;){if(!(d.length>=l)){if(u){if(d.length>0){const e=Buffer.alloc(l,255);d.copy(e,0),d=Buffer.alloc(0),await C([e])}break}break}{const e=[];for(;e.length<p&&d.length>=l;)e.push(d.subarray(0,l)),d=d.subarray(l);await C(e)}}}finally{I=!1}}};return{info:g,sendAudio:async e=>{if(u)throw new Error("Talk session is closed");0!==e.length&&(d=0===d.length?e:Buffer.concat([d,e]),await B())},stop:async()=>{if(u)return;u=!0,await B();const t=E-Date.now();t>0?await Ne(t+100):await Ne(100);const r=await this.client.sendFrame({cmdId:n.Oh,channel:e,...null!=s?{channelIdOverride:s}:{},payloadXml:"",messageClass:n.Uh});if(200!==r.header.responseCode)throw new Error(`TalkReset rejected (responseCode ${r.header.responseCode})`)}}}async sendBinary(e){return await this.client.login(),await this.client.sendBinary(e)}async getNetPort(){const e={},t=(await this.sendXml({cmdId:37})).matchAll(/<([A-Za-z]+)Port[^>]*>([\s\S]*?)<\/\1Port>/g);for(const s of t){const t=(s[1]??"").toLowerCase(),n=s[2]??"",r={};for(const e of n.matchAll(/<([A-Za-z]+)>(-?\d+)<\/\1>/g)){const t=(e[1]??"").toLowerCase(),s=Number(e[2]);Number.isFinite(s)&&(r[t]=s)}Object.keys(r).length&&(e[t]=r)}return e}async getPorts(){return this.getNetPort()}async setPortEnabled(e){const t=`${e.port[0].toUpperCase()}${e.port.slice(1)}Port`,s=`<?xml version="1.0" encoding="UTF-8" ?><body><${t} version="1.1"><enable>${e.enable?1:0}</enable></${t}></body>`;await this.sendXml({cmdId:36,payloadXml:s})}async getInfo(e,t){const s={cmdId:null==e?80:318};void 0!==e&&(s.channel=e),null!=t?.timeoutMs&&(s.timeoutMs=t.timeoutMs);return function(e,t){const s={};for(const n of t){const t=v(e,n);void 0!==t&&(s[n]=t)}return s}(await this.sendXml(s),t?.tags?.length?t.tags:["type","hardwareVersion","firmwareVersion","itemNo","serialNumber","name"])}async getChannelIdentity(e,t){const s=await this.getInfo(e,{...null!=t?.timeoutMs?{timeoutMs:t.timeoutMs}:{},tags:["type","name"]});return{channel:e,model:(s.type??"").trim(),name:(s.name??"").trim()}}async getNvrChannelsInfo(e){const t=e?.source??"cgi",s=e?.timeoutMs??3500,n=e?.maxChannels??16,r=e?.cgiTimeoutMs??3e4;if("cgi"===t){const e=new se({host:this.host,username:this.username,password:this.password,timeoutMs:r});try{await e.login();const t=Number.isFinite(n)&&n>0?n:16,s=[{cmd:"GetChannelstatus",action:0},...Array.from({length:t},((e,t)=>({cmd:"GetChnTypeInfo",action:0,param:{channel:t}})))],r=await e.callMany(s),i=ve(r.length?[r[0]]:[]),A=new Map;for(const e of i)A.set(e.channel,e);const o=i.map((e=>e.channel)),a=o.length?[...new Set(o)].sort(((e,t)=>e-t)):Array.from({length:t},((e,t)=>t)),c=[];for(const e of a){const s=A.get(e);let n,i,o;if(e>=0&&e<t){const t=r[1+e],s=t?.value;s&&"object"==typeof s&&("string"==typeof s.typeInfo&&s.typeInfo.trim()&&(n=s.typeInfo.trim()),"string"==typeof s.firmVer&&s.firmVer.trim()&&(i=s.firmVer.trim()),"string"==typeof s.boardInfo&&s.boardInfo.trim()&&(o=s.boardInfo.trim()))}const a=s?.name?.trim(),l=(n??s?.typeInfo)?.trim(),h=s?.uid?.trim();c.push({channel:e,...l?{model:l}:{},...a?{name:a}:{},...h?{uid:h}:{},...void 0!==s?.online?{online:s.online}:{},...void 0!==s?.sleep?{sleep:s.sleep}:{},...i?{firmwareVersion:i}:{},...o?{boardInfo:o}:{},source:"cgi"})}return c}finally{}}let i=[];try{const e=await this.getAbilityInfo();i=Object.keys(e??{}).filter((e=>"Host"!==e)).map((e=>Number(e))).filter((e=>Number.isFinite(e))).sort(((e,t)=>e-t))}catch{}if(0===i.length){const e=Number.isFinite(n)&&n>0?n:16;i=Array.from({length:e},((e,t)=>t))}const A=[];for(const e of i)try{const t=await this.getInfo(e,{timeoutMs:s,tags:["type","name","firmwareVersion"]}),n=(t.type??"").trim(),r=(t.name??"").trim(),i=(t.firmwareVersion??"").trim();if(!!!(n||r||i))continue;A.push({channel:e,...n?{model:n}:{},...r?{name:r}:{},...i?{firmwareVersion:i}:{},source:"baichuan"})}catch{}return A.sort(((e,t)=>e.channel-t.channel))}async getEncXml(e,t){const s=this.normalizeChannel(e);return await this.sendXml({cmdId:56,channel:s,...null!=t?.timeoutMs?{timeoutMs:t.timeoutMs}:{}})}async getStreamMetadata(e){const t=this.normalizeChannel(e),s=await this.getEncXml(t),n=[];let r=!0;const i=this.client.getDebugConfig?.(),A=!0===i?.debugParamSets,o=e=>e.width>0&&e.height>0&&(e.frameRate>0||e.bitRate>0),a=(e,s)=>{if(!A)return;if(!s)return void(this.logger.warn??this.logger.log).call(this.logger,`[ReolinkBaichuanApi] getStreamMetadata(debugParamSets): channel=${t} tag=<${e}> missing`);const n=s,r=v(n,"width")??v(n,"Width"),i=v(n,"height")??v(n,"Height"),a=v(n,"frame")??v(n,"Frame"),c=v(n,"bitRate")??v(n,"BitRate"),l=v(n,"videoEncType")??v(n,"VideoEncType"),h=v(n,"audio")??v(n,"Audio"),g=v(n,"enable")??v(n,"Enable"),d=Number(r??"0"),u=Number(i??"0"),I=Number(a??"0"),E=Number(c??"0"),p=Number(h??"0"),C=void 0===g||"1"===g||"true"===g,B=C&&o({width:d,height:u,frameRate:I,bitRate:E}),Q=1400,f=n.length<=Q?n:n.slice(0,Q)+`\n...truncated (+${n.length-Q} chars)`;(this.logger.warn??this.logger.log).call(this.logger,`[ReolinkBaichuanApi] getStreamMetadata(debugParamSets): channel=${t} tag=<${e}> enabled=${C} plausible=${B} width=${d} height=${u} frame=${I} bitRate=${E} audio=${p} videoEncType=${l??"?"} rawFields=${JSON.stringify({widthText:r,heightText:i,frameText:a,bitRateText:c,videoEncTypeText:l,audioText:h,enableText:g})} blockXml=${JSON.stringify(f)}`)};if(A){const e=1600,n=s.length<=e?s:s.slice(0,e)+`\n...truncated (+${s.length-e} chars)`,r={mainStream:/<mainStream\b/.test(s),subStream:/<subStream\b/.test(s),extStream:/<extStream\b/.test(s),thirdStream:/<thirdStream\b/.test(s),externStream:/<externStream\b/.test(s),extraStream:/<extraStream\b/.test(s)};(this.logger.warn??this.logger.log).call(this.logger,`[ReolinkBaichuanApi] getStreamMetadata(debugParamSets): channel=${t} xmlLen=${s.length} tagsPresent=${JSON.stringify(r)} xmlHead=${JSON.stringify(n)}`)}const c={0:"H.264",1:"H.265",2:"MJPEG",3:"MPEG4"},l=s.match(/<mainStream[^>]*>([\s\S]*?)<\/mainStream>/);if(l){const e=l[1]??"";a("mainStream",e);const t=Number(v(e,"width")??"0"),s=Number(v(e,"height")??"0"),i=Number(v(e,"videoEncType")??"0"),A=Number(v(e,"frame")??"0"),h=Number(v(e,"bitRate")??"0"),g=Number(v(e,"audio")??"0"),d=v(e,"enable");(void 0===d||"1"===d||"true"===d)&&o({width:t,height:s,frameRate:A,bitRate:h})&&(n.push({profile:"main",audio:g,width:t,height:s,videoEncType:c[i]??`Unknown(${i})`,videoEncTypeInt:i,frameRate:A,bitRate:h,audioCodec:"aac"}),r=r&&1===g)}const h=s.match(/<subStream[^>]*>([\s\S]*?)<\/subStream>/);if(h){const e=h[1]??"";a("subStream",e);const t=Number(v(e,"width")??"0"),s=Number(v(e,"height")??"0"),i=Number(v(e,"videoEncType")??"0"),A=Number(v(e,"frame")??"0"),l=Number(v(e,"bitRate")??"0"),g=Number(v(e,"audio")??"0"),d=v(e,"enable");(void 0===d||"1"===d||"true"===d)&&o({width:t,height:s,frameRate:A,bitRate:l})&&(n.push({profile:"sub",audio:g,width:t,height:s,videoEncType:c[i]??`Unknown(${i})`,videoEncTypeInt:i,frameRate:A,bitRate:l,audioCodec:"aac"}),r=r&&1===g)}const g=["extStream","thirdStream","externStream","extraStream"];for(const e of g){const t=s.match(new RegExp(`<${e}[^>]*>([\\s\\S]*?)<\\/${e}>`));if(!t)continue;const i=t[1]??"";a(e,i);const A=Number(v(i,"width")??"0"),l=Number(v(i,"height")??"0"),h=Number(v(i,"videoEncType")??"0"),g=Number(v(i,"frame")??"0"),d=Number(v(i,"bitRate")??"0"),u=Number(v(i,"audio")??"0"),I=v(i,"enable");(void 0===I||"1"===I||"true"===I)&&o({width:A,height:l,frameRate:g,bitRate:d})&&(n.push({profile:"ext",audio:u,width:A,height:l,videoEncType:c[h]??`Unknown(${h})`,videoEncTypeInt:h,frameRate:g,bitRate:d,audioCodec:"aac"}),r=r&&1===u);break}return{channel:t,streams:n,audioEnabled:r}}async setEncXml(e,t){const s="number"==typeof e?this.normalizeChannel(e):0,n="number"==typeof e?t:e;await this.sendXml({cmdId:57,channel:s,payloadXml:n})}async setStreamVideoCodec(e,t,s){const n="number"==typeof e?this.normalizeChannel(e):this.normalizeChannel(s),r="number"==typeof e?t:e,i="H.265"===("number"==typeof e?s:t)?1:0,A="main"===r?["mainStream"]:"sub"===r?["subStream"]:["extStream","thirdStream","externStream","extraStream"],o=await this.getEncXml(n);let a=null;for(const e of A){const t=new RegExp(`(<${e}[^>]*>[\\s\\S]*?<videoEncType>)(\\d+)(</videoEncType>)`);if(!t.test(o))continue;const s=o.replace(t,`$1${i}$3`);if(s!==o){a=s;break}}if(!a)throw new Error(`Could not find <videoEncType> for profile=${r} (tags=${A.join(",")}) in GetEnc XML (channel=${n}).`);await this.setEncXml(n,a)}async setNetPort(e){null!=e.onvifEnable&&await this.setPortEnabled({port:"onvif",enable:1===e.onvifEnable}),null!=e.rtmpEnable&&await this.setPortEnabled({port:"rtmp",enable:1===e.rtmpEnable}),null!=e.rtspEnable&&await this.setPortEnabled({port:"rtsp",enable:1===e.rtspEnable})}async reboot(e){const t={cmdId:23};void 0!==e&&(t.channel=e),await this.sendXml(t)}async ping(){await this.sendXml({cmdId:93})}async getGeneralXml(e){const t={cmdId:104};return void 0!==e&&(t.channel=e),await this.sendXml(t)}async setGeneralXml(e,t){const s="number"==typeof e||void 0===e?e:void 0,n="string"==typeof e?e:t;await this.sendXml({cmdId:105,...void 0===s?{}:{channel:s},payloadXml:n})}static buildChannelExtensionXml(e){return`<?xml version="1.0" encoding="UTF-8" ?><Extension version="1.1"><channelId>${w(String(e))}</channelId></Extension>`}async getMotionState(e){const t=v(await this.sendXml({cmdId:46,...void 0!==e?{channel:e}:{}}),"enable");return"1"===t||"true"===t}async getOsd(e){const t=this.normalizeChannel(e),s=await this.sendXml({cmdId:26,channel:t});return{channel:t,osdChannel:{enable:Number(v(s,"enable")??"0"),name:v(s,"name")??"",pos:v(s,"pos")??""},osdTime:{enable:Number(v(s,"timeEnable")??"0"),pos:v(s,"timePos")??""},watermark:Number(v(s,"watermark")??"0")}}async setOsd(e,t){const s="number"==typeof e?this.normalizeChannel(e):this.normalizeChannel(t),n="number"==typeof e?t:e,r=`<?xml version="1.0" encoding="UTF-8" ?><body><Osd version="1.1"><channel>${s}</channel><osdChannel><enable>${n.osdChannel.enable}</enable><name>${w(n.osdChannel.name)}</name><pos>${w(n.osdChannel.pos)}</pos></osdChannel><osdTime><enable>${n.osdTime.enable}</enable><pos>${w(n.osdTime.pos)}</pos></osdTime><watermark>${n.watermark}</watermark></Osd></body>`;await this.sendXml({cmdId:25,channel:s,payloadXml:r})}async getAiState(e){const t=this.normalizeChannel(e),s=["people","vehicle","dog_cat","face","package"];let n;const r=async(e,s)=>{const n=`<?xml version="1.0" encoding="UTF-8" ?><body><AiDetectCfg version="1.1"><chn>${t}</chn><type>${w(e)}</type></AiDetectCfg></body>`;return await this.sendXml({cmdId:342,channel:t,payloadXml:n,...null!=s?{channelIdOverride:s}:{}},0)};for(const e of s)try{const s=await r(e,t);if(s)return{channel:t,alarm_state:Number(v(s,"alarm_state")??"0"),support:Number(v(s,"support")??"0")}}catch(e){n=e}for(const e of s)try{const s=await r(e,void 0);if(s)return{channel:t,alarm_state:Number(v(s,"alarm_state")??"0"),support:Number(v(s,"support")??"0")}}catch(e){n=e}throw n instanceof Error?n:new Error(String(n??"getAiState failed"))}async getSnapshot(e=0){const t=`<body><Snap version="1.1"><channelId>${e}</channelId><logicChannel>${e}</logicChannel><time>0</time><fullFrame>0</fullFrame><streamType>main</streamType></Snap></body>`;return await this.client.login(),await this.client.sendBinary({cmdId:109,channel:e,payloadXml:t,extensionXml:D(e),timeoutMs:15e3})}async listRecordings(e){await this.client.login();const t=this.normalizeChannel(e.channel),s=e.uid,r=e.streamType??"mainStream",i=e.recordType??"manual, sched, io, md, people, face, vehicle, dog_cat, visitor, other, package",A=e.maxIterations??50,o=e.fallbackToAlarmVideo??!0,a=`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<FileInfoList version="1.1">\n<FileInfo>\n<uid>${w(s)}</uid>\n<searchAITrack>1</searchAITrack>\n<channelId>${t}</channelId>\n<logicChnBitmap>255</logicChnBitmap>\n<streamType>${w(r)}</streamType>\n<recordType>${w(i)}</recordType>\n${Te("startTime",e.start)}\n${Te("endTime",e.end)}\n</FileInfo>\n</FileInfoList>\n</body>`,c=v(await this.sendXml({cmdId:n.Xf,channel:t,payloadXml:a}),"handle");if(!c)throw new Error("FileInfoList open did not return <handle>");const l=Number.parseInt(c,10);if(!Number.isFinite(l))throw new Error(`FileInfoList open returned invalid handle: ${c}`);const h=`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<FileInfoList version="1.1">\n<FileInfo>\n<channelId>${t}</channelId>\n<uid>${w(s)}</uid>\n<searchAITrack>1</searchAITrack>\n<handle>${l}</handle>\n</FileInfo>\n</FileInfoList>\n</body>`,g=[];try{let e=!1;for(let s=0;s<A&&!e;s++){const s=await this.sendXml({cmdId:n.rO,channel:t,payloadXml:h});g.push(...Fe(s));const r=v(s,"bFinished")??v(s,"finished");e=null==r||"1"===r.trim()}}finally{try{await this.sendXml({cmdId:n.l$,channel:t,payloadXml:h})}catch{}}const d=new Set,u=g.filter((e=>!d.has(e.fileName)&&(d.add(e.fileName),!0)));if(u.length>0||!o)return u;const I=s.split("_")[0]??s,E="subStream"===r?1:0,p=e=>`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<findAlarmVideo version="1.1">\n<channelId>${t}</channelId>\n<fileHandle>${w(e)}</fileHandle>\n</findAlarmVideo>\n</body>`,C=[];let B=e.start;for(let s=0;s<A;s++){const s=await this.sendXml({cmdId:n.dB,channel:t,payloadXml:(Q=B,f=e.end,`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<findAlarmVideo version="1.1">\n<channelId>${t}</channelId>\n<uid>${w(I)}</uid>\n<logicChnBitmap>255</logicChnBitmap>\n<streamType>${E}</streamType>\n<notSearchVideo>0</notSearchVideo>\n${Te("startTime",Q)}\n${Te("endTime",f)}\n<alarmType>md, pir, io, people, face, vehicle, dog_cat, visitor, other, package, cry, crossline, intrusion, loitering, legacy, loss</alarmType>\n</findAlarmVideo>\n</body>`)}),r=v(s,"fileHandle")?.trim();if(!r)break;const i=p(r);try{const e=await this.sendXml({cmdId:n.TB,channel:t,payloadXml:i}),s=Fe(e);C.push(...s);const r=v(e,"bFinished")?.trim();if("1"===r)break;const A=[...s].reverse().find((e=>null!=e.startTime));if(!A?.startTime)break;B=A.startTime}finally{try{await this.sendXml({cmdId:n.f9,channel:t,payloadXml:i})}catch{}}}var Q,f;const m=new Set;return C.filter((e=>!m.has(e.fileName)&&(m.add(e.fileName),!0)))}async listRecordingFileNames(e){return(await this.listRecordings(e)).map((e=>e.fileName))}async getVodRtmpUrl(e){await this.client.login();const t=this.normalizeChannel(e.channel),s=e.streamType??"mainStream",n=e.ensureEnabled??!0;let r=e.rtmpPort;try{const e=(await this.getNetPort()).rtmp,t="number"==typeof e?.enable?e.enable:void 0,s="number"==typeof e?.port?e.port:void 0;null==r&&null!=s&&Number.isFinite(s)&&s>0&&(r=s),n&&0===t&&await this.setPortEnabled({port:"rtmp",enable:!0})}catch{}null==r&&(r=1935);const i="subStream"===s?1:0;let A=e.fileName.trim();const o=A.indexOf("Mp4Record/");o>=0&&(A=A.slice(o)),A=A.replace(/^\/+/,"");const a=A.replace(/\//g,"%20").replace(/ /g,"%20"),c=encodeURIComponent(this.username),l=encodeURIComponent(this.password);return`rtmp://${this.host}:${r}/vod/${a}?channel=${t}&stream=${i}&user=${c}&password=${l}`}async predownloadRecordingMp4(e){await this.client.login();const t=this.normalizeChannel(e.channel),s=e.streamType??"mainStream",n=e.ensureAwake??!1,r=e.ffmpegPath??"ffmpeg",i=e.overwrite??!0;await(0,h.mkdir)((0,g.dirname)(e.outputPath),{recursive:!0});const A=async()=>{n&&await this.wakeUp(t,{waitAfterWakeMs:1500,attempts:3});const A=await this.getVodRtmpUrl({channel:t,fileName:e.fileName,streamType:s,ensureEnabled:!0});await new Promise(((t,s)=>{const n=(0,l.spawn)(r,["-hide_banner","-loglevel","error",...i?["-y"]:[],"-rtmp_live","live","-i",A,"-c","copy","-movflags","frag_keyframe+empty_moov","-f","mp4",e.outputPath]);let o="";n.stderr.on("data",(e=>{o+=String(e)})),n.on("close",(e=>{if(0===e)return t();s(new Error(`ffmpeg exited with code ${e}\n${o}`))})),n.on("error",s)}))};try{await A()}catch(e){if(n)try{await this.wakeUp(t,{waitAfterWakeMs:3e3,attempts:3,reconnect:!0})}catch{}await A()}}async generateMp4Screenshot(e){const t=e.ffmpegPath??"ffmpeg",s=Number.isFinite(e.atSeconds)&&e.atSeconds>=0?e.atSeconds:0;await(0,h.mkdir)((0,g.dirname)(e.outputPath),{recursive:!0}),await new Promise(((n,r)=>{const i=(0,l.spawn)(t,["-hide_banner","-loglevel","error","-y","-ss",String(s),"-i",e.inputPath,"-frames:v","1","-q:v","2",e.outputPath]);let A="";i.stderr.on("data",(e=>{A+=String(e)})),i.on("close",(e=>{if(0===e)return n();r(new Error(`ffmpeg screenshot exited with code ${e}\n${A}`))})),i.on("error",r)}))}async downloadRecording(e){await this.client.login();const t=this.normalizeChannel(e.channel),s=e.uid,r=e.fileName,i=r.includes("/")?r.split("/").filter(Boolean).at(-1)??r:r,A=`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<FileInfoList version="1.1">\n<FileInfo>\n<channelId>${t}</channelId>\n<uid>${w(s)}</uid>\n<fileName>${w(r)}</fileName>\n<name>${w(i)}</name>\n<Id>${w(r)}</Id>\n</FileInfo>\n</FileInfoList>\n</body>`,o=e.fallbackToHttp??!1;try{return await this.client.sendBinary({cmdId:n.ts,channel:t,messageClass:n.d_,extensionXml:b(t),payloadXml:A,timeoutMs:e.timeoutMs??12e4})}catch(e){if(!o)throw e;const t=r.replaceAll("/","_").replaceAll("\\","_");try{const e=/Rec(\w{3})(?:_|_DST)(\d{8})_(\d{6})_.*/.exec(r),s=e?`${e[2]}${e[3]}`:void 0,n=[],i=e=>{const t=e?.trim();t&&(n.includes(t)||n.push(t))};let A;i(r),i(r.replace(/^\/mnt\/[a-zA-Z0-9]+\//,"")),i(r.replace(/^\//,""));for(const e of n)try{return await this.httpClient.downloadVod(e,t,s)}catch(e){A=e;if((e instanceof Error?e.message:String(e)).startsWith("HTTP 404"))continue;throw e}throw A instanceof Error?A:new Error(String(A))}catch(t){const s=e instanceof Error?e.message:String(e),n=t instanceof Error?t.message:String(t);throw new Error(`downloadRecording failed (baichuan then http). baichuanErr=${s}; httpErr=${n}`)}}}async subscribeEvents(){await this.client.login();const e=this.client.getConfiguredChannel?.()??0,t=[{label:`channelId=${e} bodyLen=0`,params:{cmdId:31,channelIdOverride:e,messageClass:n.Uh}},{label:"push channelId=251 bodyLen=0",params:{cmdId:31,channelIdOverride:251,messageClass:n.Uh}},{label:"host channelId=250 bodyLen=0",params:{cmdId:31,channelIdOverride:250,messageClass:n.Uh}},{label:"legacy Extension channelId=251",params:{cmdId:31,channelIdOverride:250,messageClass:n.Uh,extensionXml:'<?xml version="1.0" encoding="UTF-8" ?><Extension version="1.1"><channelId>251</channelId></Extension>'}}];let s;for(const e of t){const t=await this.client.sendFrame({...e.params,timeoutMs:1e4});if(s=t.header.responseCode,200===t.header.responseCode)return this.client.subscribed=!0,void this.client.refreshKeepAlive?.();(this.logger.debug??this.logger.log).call(this.logger,`[ReolinkBaichuanApi] subscribeEvents rejected (${e.label}) responseCode=${t.header.responseCode}`)}throw this.client.subscribed=!1,this.client.refreshKeepAlive?.(),new Error(`subscribeEvents failed: camera rejected cmdId=31 (last responseCode=${s??"unknown"})`)}async subscribeToAllEvents(e){await this.client.login();const t=e?.preferCgi??!0,s=e?.maxChannels??16,r=e?.timeoutMs??1e4;let i=[];try{const e=await this.getNvrChannelsInfo({source:t?"cgi":"baichuan",maxChannels:s}),n=e.filter((e=>Boolean((e.uid??"").trim())||Boolean((e.name??"").trim())||!0===e.online||!0===e.sleep)).map((e=>e.channel)).filter((e=>Number.isInteger(e)&&e>=0));i=(n.length?n:e.map((e=>e.channel))).filter((e=>Number.isInteger(e)&&e>=0)).slice(0,s)}catch{}if(!i.length){i=[this.client.getConfiguredChannel?.()??0]}i=[...new Set(i)].sort(((e,t)=>e-t));let A,o=0;for(const e of i){const t=await this.client.sendFrame({cmdId:31,channelIdOverride:e,messageClass:n.Uh,timeoutMs:r});A=t.header.responseCode,200===t.header.responseCode?o++:(this.logger.debug??this.logger.log).call(this.logger,`[ReolinkBaichuanApi] subscribeToAllEvents rejected (channel=${e}) responseCode=${t.header.responseCode}`)}if(o>0)return this.client.subscribed=!0,void this.client.refreshKeepAlive?.();try{return void await this.subscribeEvents()}catch{}throw this.client.subscribed=!1,this.client.refreshKeepAlive?.(),new Error(`subscribeToAllEvents failed: camera rejected cmdId=31 for all channels (last responseCode=${A??"unknown"})`)}async unsubscribeEvents(){this.client.subscribed=!1,this.client.refreshKeepAlive?.()}async checkAndDispatchCurrentState(e=0){try{const t=await this.getMotionState(e);if(t!==this.lastMotionState&&(this.lastMotionState=t,t)){const t={type:"motion",channel:e,timestamp:Date.now()};this.dispatchSimpleEvent(t)}if(!this.aiStatePollingDisabled)try{const t=await this.getAiState(e);if(t&&void 0!==t.alarm_state){if((!this.lastAiState||this.lastAiState.alarm_state!==t.alarm_state||this.lastAiState.support!==t.support)&&(this.lastAiState=t,1===t.alarm_state)){const t={type:"other",channel:e,timestamp:Date.now()};this.dispatchSimpleEvent(t)}}}catch(e){this.aiStatePollingDisabled=!0;const t=String(e&&"object"==typeof e&&"message"in e?e.message:e);t.includes("not supported")||t.includes("unsupported")||(this.logger.debug??this.logger.log)?.call(this.logger,"[ReolinkBaichuanApi] getAiState failed; disabling AI polling",e),this.aiStatePollingDisabledLogged||(this.aiStatePollingDisabledLogged=!0,this.logger.debug?.("[ReolinkBaichuanApi] AI polling disabled after getAiState failure",e))}}catch(e){(this.logger.warn??this.logger.error)?.call(this.logger,"[ReolinkBaichuanApi] Error checking current state",e)}}dispatchSimpleEvent(e){for(const t of this.simpleEventListeners)try{t(e)}catch(e){(this.logger.warn??this.logger.error)?.call(this.logger,"[ReolinkBaichuanApi] onSimpleEvent handler error",e)}}startStatePolling(){if(0===this.simpleEventListeners.size)return;"udp"===this.client.getTransport?.()||this.statePollingInterval||(this.statePollingInterval=setInterval((async()=>{try{if(0===this.simpleEventListeners.size)return void this.stopStatePolling();const e=this.client.getConfiguredChannel?.()??0;await this.checkAndDispatchCurrentState(e)}catch(e){this.logger.debug?.("[ReolinkBaichuanApi] state polling tick failed",e)}}),5e3))}stopStatePolling(){this.statePollingInterval&&(clearInterval(this.statePollingInterval),this.statePollingInterval=void 0)}async getEvents(e){const t=await this.sendXml({cmdId:33,...void 0!==e?{channel:e}:{}}),s=this.normalizeChannel(e),n=Date.now(),r={channel:s};if(t.includes("<AlarmEventList")){const e=t.matchAll(/<AlarmEvent\b[^>]*>([\s\S]*?)<\/AlarmEvent>/g);for(const t of e){const e=t[1]??"",i=v(e,"channelId");if((void 0!==i?Number(i):s)!==s)continue;const A=(v(e,"status")??"").trim().toUpperCase(),o=(v(e,"AItype")??v(e,"aiType")??v(e,"aitype")??"").trim();A.includes("MD")&&(r.motion={state:1,timestamp:n,source:"md"}),A.includes("PIR")&&(r.motion={state:1,timestamp:n,source:"pir"});const a=o?o.split(",").map((e=>e.trim())).find((e=>e.length>0&&"none"!==e.toLowerCase())):void 0;(a||A.includes("AI"))&&(r.ai={channel:s,alarm_state:1,type:a}),A.includes("VIS")&&(r.visitor={detected:!0,timestamp:n})}return r}const i=(v(t,"status")??"").trim().toUpperCase(),A=(v(t,"AItype")??v(t,"aiType")??v(t,"aitype")??"").trim();return i.includes("MD")&&(r.motion={state:1,timestamp:n,source:"md"}),i.includes("PIR")&&(r.motion={state:1,timestamp:n,source:"pir"}),(A||i.includes("AI"))&&(r.ai={channel:s,alarm_state:1,type:A||void 0}),i.includes("VIS")&&(r.visitor={detected:!0,timestamp:n}),r}async getTwoWayAudioConfig(e){const t=v(await this.sendXml({cmdId:10,...void 0!==e?{channel:e}:{}}),"audioStreamMode"),s={channel:e??0,enabled:"mixAudioStream"===t||"followVideoStream"===t};return t&&(s.mode=t),s}async startTwoWayAudio(e){await this.sendXml({cmdId:10,...void 0!==e?{channel:e}:{}})}async sendAudioData(e,t){const s={cmdId:10,payloadXml:""};void 0!==t&&(s.channel=t),await this.client.sendBinary(s)}async stopTwoWayAudio(e){}async startVideoStream(e,t="sub"){const s=this.normalizeChannel(e),r=s,i={main:{handle:0,streamType:0,streamName:"mainStream"},sub:{handle:256,streamType:1,streamName:"subStream"},ext:{handle:1024,streamType:0,streamName:"externStream"}}[t];if(!i)throw new Error(`Invalid stream profile: ${t}`);if(!i.streamName)throw new Error(`Stream name not found for profile: ${t}, config: ${JSON.stringify(i)}`);const A=i.streamName;if("string"!=typeof A)throw new Error(`streamName is not a string: ${typeof A}, value: ${A}, config: ${JSON.stringify(i)}`);const o=function(e,t,s){if(!t||"string"!=typeof t)throw new Error(`buildPreviewXml: streamType is required (string) but got: ${typeof t} = ${t}`);return`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<Preview version="1.0">\n${void 0!==s?`<channelId>${s}</channelId>\n`:""}<handle>${e}</handle>\n<streamType>${w(t)}</streamType>\n</Preview>\n</body>`}(i.handle,A,r),a="udp"===this.client.getTransport?.()?3:1;let c;for(let e=1;e<=a;e++){const A=this.client.peekNextMsgNum();this.client.subscribeVideoStream(n.zw,A);try{const e={cmdId:n.zw,channel:s,channelIdOverride:r,extensionXml:D(r),payloadXml:o,messageClass:n.Uh,streamType:i.streamType},A=await this.client.sendFrame(e);if(200!==A.header.responseCode)throw new Error(`Video stream request rejected (response_code ${A.header.responseCode}). Expected response_code 200, camera returned ${A.header.responseCode}`);return void this.activeVideoMsgNums.set(`${s}:${t}`,A.header.msgNum)}catch(t){c=t;try{this.client.unsubscribeVideoStream(n.zw,A)}catch{}if(e<a){await new Promise((e=>setTimeout(e,250)));continue}}}throw c instanceof Error?c:new Error(String(c))}getActiveVideoMsgNum(e,t="sub"){const s=this.normalizeChannel(e);return this.activeVideoMsgNums.get(`${s}:${t}`)}async stopVideoStream(e,t="sub"){const s=this.normalizeChannel(e),r=s,i={main:{handle:0,streamType:0},sub:{handle:256,streamType:1},ext:{handle:1024,streamType:0}}[t],A=function(e,t){return`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<Preview version="1.0">\n${void 0!==t?`<channelId>${t}</channelId>\n`:""}<handle>${e}</handle>\n</Preview>\n</body>`}(i.handle,r),o=`${s}:${t}`,a=this.activeVideoMsgNums.get(o);this.activeVideoMsgNums.delete(o);try{await this.client.sendFrame({cmdId:n.Ck,channel:s,channelIdOverride:r,extensionXml:D(r),payloadXml:A,messageClass:n.Uh,streamType:i.streamType,...void 0!==a?{msgNumOverride:a}:{},timeoutMs:2e3})}catch{}finally{try{void 0!==a&&this.client.unsubscribeVideoStream(n.zw,a)}catch{}}}async getPtzPresets(e){const t=this.normalizeChannel(e),s=t,r=await this.sendXml({cmdId:n.XN,channel:t,channelIdOverride:s,extensionXml:D(s),messageClass:n.Uh,streamType:0});return this.parsePtzPresetList(r).filter((e=>void 0===e.enable||"1"===e.enable)).filter((e=>void 0===e.name||""!==String(e.name).trim())).map((e=>({id:e.id,name:e.name??`Preset ${e.id}`})))}parsePtzPresetList(e){const t=[],s=e.matchAll(/<preset\b[^>]*>([\s\S]*?)<\/preset>/gi);for(const e of s){const s=e[1]??"",n=/<id>([^<]*)<\/id>/i.exec(s)?.[1];if(!n)continue;const r=Number(n);if(!Number.isFinite(r))continue;const i=/<name>([^<]*)<\/name>/i.exec(s),A=/<enable>([^<]*)<\/enable>/i.exec(s),o={id:r},a=i?.[1],c=A?.[1];void 0!==a&&(o.name=a),void 0!==c&&(o.enable=c),t.push(o)}return t}async getPtzPresetsRaw(e){const t=this.normalizeChannel(e),s=t,r=await this.sendXml({cmdId:n.XN,channel:t,channelIdOverride:s,extensionXml:D(s),messageClass:n.Uh,streamType:0});return this.parsePtzPresetList(r)}async ptz(e,t){const s="number"==typeof e?this.normalizeChannel(e):0,r="number"==typeof e?t:e,i=s;let A,o;if("stop"===r.action)A="stop";else{const e={Left:"left",Right:"right",Up:"up",Down:"down"}[r.command];if(!e)throw new Error(`Unsupported PTZ command for MSG_ID_PTZ_CONTROL: ${r.command}`);A=e}if("stop"===A)o=0;else{const e=r.speed;o=void 0===e?32:e>0&&e<=1?Math.max(1,64*e):e}const a=function(e,t,s){return`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<PtzControl version="1.1">\n<channelId>${e}</channelId>\n<command>${w(t)}</command>\n<speed>${s}</speed>\n</PtzControl>\n</body>`}(i,A,o),c=D(i),l=await this.client.sendFrame({cmdId:n.iI,channel:s,channelIdOverride:i,extensionXml:c,payloadXml:a,messageClass:n.Uh,streamType:0});if(200!==l.header.responseCode){let e="";if(l.body.length>0)try{const t=this.client.tryDecryptXml;if(t){const s=t.call(this.client,l.body,l.header.channelId,this.client.enc);s&&(e=` - Error details: ${s.substring(0,200)}`)}}catch{}throw new Error(`PTZ control rejected (response_code ${l.header.responseCode})${e}`)}if("start"===r.action&&"stop"!==A){const e=r.autoStopMs??500;e>0&&setTimeout((()=>{this.ptz(s,{action:"stop",command:r.command}).catch((()=>{}))}),e)}}async moveToPtzPreset(e,t){const s=void 0===t?this.normalizeChannel(void 0):this.normalizeChannel(e),r=s,i=function(e,t,s,n){return N(e,t,s,void 0===n?void 0:{name:n})}(r,void 0===t?e:t,"toPos"),A=D(r),o=await this.client.sendFrame({cmdId:n.qD,channel:s,channelIdOverride:r,extensionXml:A,payloadXml:i,messageClass:n.Uh,streamType:0});if(200!==o.header.responseCode)throw new Error(`PTZ preset move rejected (response_code ${o.header.responseCode})`)}async setPtzPreset(e,t,s){const r="string"==typeof t?this.normalizeChannel(s):this.normalizeChannel(e),i=r,A=N(i,"string"==typeof t?e:t,"setPos",{name:"string"==typeof t?t:s,enable:1}),o=D(i),a=await this.client.sendFrame({cmdId:n.qD,channel:r,channelIdOverride:i,extensionXml:o,payloadXml:A,messageClass:n.Uh,streamType:0});if(200!==a.header.responseCode)throw new Error(`PTZ preset save rejected (response_code ${a.header.responseCode})`)}async deletePtzPreset(e,t){const s=void 0===t?this.normalizeChannel(void 0):this.normalizeChannel(e),r=void 0===t?e:t,i=s,A=D(i);let o;try{const e=await this.getPtzPresetsRaw(s);o=e.find((e=>e.id===r))?.name}catch{}const a=[{label:"command=delPos",payloadXml:N(i,r,"delPos")},{label:"enable=0 (no name)",payloadXml:N(i,r,"setPos",{enable:0})},{label:"name='' (no enable)",payloadXml:N(i,r,"setPos",{name:""})},{label:"enable=0 name=''",payloadXml:N(i,r,"setPos",{name:"",enable:0})},...o?[{label:"enable=0 name=current",payloadXml:N(i,r,"setPos",{name:o,enable:0})}]:[],{label:"enable=0 name='Preset N'",payloadXml:N(i,r,"setPos",{name:`Preset ${r}`,enable:0})}];let c,l=!1;for(const e of a)try{const t=await this.client.sendFrame({cmdId:n.qD,channel:s,channelIdOverride:i,extensionXml:A,payloadXml:e.payloadXml,messageClass:n.Uh,streamType:0});if(200!==t.header.responseCode)throw new Error(`PTZ preset delete rejected (response_code ${t.header.responseCode})`);l=!0;try{const e=(await this.getPtzPresetsRaw(s)).find((e=>e.id===r));if(!e)return;const t=void 0!==e.name&&""===String(e.name).trim(),n=void 0!==e.enable&&"0"===String(e.enable).trim();if(t||n)return}catch(e){c=e}}catch(e){c=e}if(!l)throw c instanceof Error?c:new Error("PTZ preset delete failed");this.logger.warn("PTZ presets (baichuan): deletePtzPreset did not take effect (firmware ignored request)",{channel:s,channelId:i,presetId:r})}async getPtzPosition(e){const t=this.normalizeChannel(e),s=await this.sendXml({cmdId:n.T$,channel:t}),r=v(s,"pPos"),i=v(s,"tPos"),A={};return void 0!==r&&(A.pan=Number(r)),void 0!==i&&(A.tilt=Number(i)),A}async getZoomFocus(e){const t=this.normalizeChannel(e),s=t,r=await this.sendXml({cmdId:n.$v,channel:t,channelIdOverride:s,extensionXml:D(s),messageClass:n.Uh,streamType:0}),i=e=>{const t=new RegExp(`<${e}>([\\s\\S]*?)</${e}>`).exec(r),s=t?.[1];if(!s)return;const n=v(s,"maxPos"),i=v(s,"minPos"),A=v(s,"curPos");return void 0!==n&&void 0!==i&&void 0!==A?{maxPos:Number(n),minPos:Number(i),curPos:Number(A)}:void 0},A={},o=i("zoom"),a=i("focus");return o&&(A.zoom=o),a&&(A.focus=a),A}async zoomToFactor(e,t){const s=void 0===t?0:this.normalizeChannel(e),r=void 0===t?e:t,i=s,A=(await this.getZoomFocus(s)).zoom;if(!A)throw new Error("Camera did not return <zoom> info (zoom may be unsupported)");const o=Math.round(1e3*r),a=function(e,t){return`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<StartZoomFocus version="1.1">\n<channelId>${e}</channelId>\n<command>zoomPos</command>\n<movePos>${Math.trunc(t)}</movePos>\n</StartZoomFocus>\n</body>`}(i,Math.min(A.maxPos,Math.max(A.minPos,o))),c=D(i),l=await this.client.sendFrame({cmdId:n.vF,channel:s,channelIdOverride:i,extensionXml:c,payloadXml:a,messageClass:n.Uh,streamType:0});if(200!==l.header.responseCode)throw new Error(`Zoom rejected (response_code ${l.header.responseCode})`)}parseBatteryInfoXml(e,t){const s=e=>{if(void 0===e)return;const t=Number(e);return Number.isFinite(t)?t:void 0},n=Re(e,"BatteryInfo"),r=n.find((e=>v(e,"channelId")===String(t)))??n[0]??e,i={},A=s(v(r,"batteryPercent"));void 0!==A&&(i.batteryPercent=A);const o=v(r,"chargeStatus");void 0!==o&&(i.chargeStatus=o);const a=v(r,"adapterStatus");void 0!==a&&(i.adapterStatus=a);const c=s(v(r,"voltage"));void 0!==c&&(i.voltage=c);const l=s(v(r,"current"));void 0!==l&&(i.current=l);const h=s(v(r,"temperature"));void 0!==h&&(i.temperature=h);const g=s(v(r,"lowPower"));void 0!==g&&(i.lowPower=g);const d=s(v(r,"batteryVersion"));return void 0!==d&&(i.batteryVersion=d),i}getSleepStatus(e){const t=e?.windowMs??e?.idleMs??1e4,s=new Set(e?.nonWakingCmdIds??e?.ignoreCmdIds??[n.F3,n.gB,n.pT,n.m8]),r=this.client.getTransport?.();if("udp"!==r)return{state:"unknown",reason:"sleep inference supported only for UDP/battery"};if(this.activeVideoMsgNums.size>0||this.rtspServers.size>0||this.client.isDeviceStreamingActive?.())return{state:"awake",reason:"active streaming"};const i=this.client.isSocketConnected?.()??!1,A=Date.now(),o=A-t,a=(this.client.getRxHistory?.()??[]).filter((e=>e.atMs>=o)),c=(this.client.getTxHistory?.()??[]).filter((e=>e.atMs>=o));if(0===a.length&&0===c.length)return{state:"sleeping",reason:`no rx/tx activity in last ${t}ms${i?"":" (socket disconnected)"}`,idleMs:t};const l=a.find((e=>!s.has(e.cmdId)));if(l)return{state:"awake",reason:`waking rx cmdId=${l.cmdId} responseCode=${l.responseCode} seen ${A-l.atMs}ms ago`,lastRxAtMs:l.atMs,idleMs:A-l.atMs};const h=c.find((e=>!s.has(e.cmdId)));return h?{state:"awake",reason:`waking tx cmdId=${h.cmdId} seen ${A-h.atMs}ms ago`,idleMs:A-h.atMs}:{state:"sleeping",reason:`only non-waking cmdIds observed in last ${t}ms (non-waking: ${Array.from(s).join(",")})`,idleMs:t}}async probeSleepStatus(e){const t=this.client.getTransport?.();if("udp"!==t)return{state:"unknown",reason:"sleep probe supported only for UDP/battery"};if(this.activeVideoMsgNums.size>0||this.rtspServers.size>0||this.client.isDeviceStreamingActive?.())return{state:"awake",reason:"active streaming"};const s=Date.now(),r=e?.minIntervalMs??5e3;if(this.lastSleepProbe&&s-this.lastSleepProbe.atMs<r)return{...this.lastSleepProbe.status,reason:`${this.lastSleepProbe.status.reason} (cached)`};if(!this.client.isSocketConnected()){const e={state:"unknown",reason:"udp socket not connected"};return this.lastSleepProbe={atMs:s,status:e},e}if(!this.client.loggedIn){const e={state:"unknown",reason:"not logged in"};return this.lastSleepProbe={atMs:s,status:e},e}const i=this.normalizeChannel(e?.channel),A=e?.timeoutMs??700,o=Math.max(1,e?.attempts??1),a=e?.cmdId??n.pT;for(let e=0;e<o;e++)try{const e=await this.client.sendFrame({cmdId:a,channel:i,timeoutMs:A}),t={state:200===e.header.responseCode?"awake":"unknown",reason:`probe cmdId=${a} responseCode=${e.header.responseCode}`};return this.lastSleepProbe={atMs:Date.now(),status:t},t}catch(t){const s=t instanceof Error?t.message:String(t);if(s.includes("Baichuan timeout")||s.toLowerCase().includes("timeout")){const e={state:"sleeping",reason:`probe timeout cmdId=${a} timeoutMs=${A}`};return this.lastSleepProbe={atMs:Date.now(),status:e},e}if(e===o-1){const e={state:"unknown",reason:`probe error cmdId=${a}: ${s}`};return this.lastSleepProbe={atMs:Date.now(),status:e},e}}const c={state:"unknown",reason:"probe exhausted"};return this.lastSleepProbe={atMs:Date.now(),status:c},c}async getBatteryStatus(e){const t=this.normalizeChannel(e);if("sleeping"===this.getSleepStatus({channel:t}).state)return{channel:t,sleeping:!0};try{const e=await Promise.race([this.sendXml({cmdId:n.pT,channel:t}),new Promise(((e,t)=>setTimeout((()=>t(new Error("Timeout"))),5e3)))]),s={channel:t,sleeping:!1};return Object.assign(s,this.parseBatteryInfoXml(e,t)),s}catch(e){const s={channel:t};return"sleeping"===this.getSleepStatus({channel:t}).state&&(s.sleeping=!0),e instanceof Error&&"Timeout"===e.message&&null==s.sleeping&&(s.sleeping=!0),s}}async getBatteryInfo(e){const t=this.normalizeChannel(e),s=this.client.getTransport?.();if(!("udp"!==s||this.client.isSocketConnected?.()&&this.client.loggedIn))return{channel:t,sleeping:!0};const r=await this.client.sendXml({cmdId:n.pT,channel:t}),i={channel:t};return Object.assign(i,this.parseBatteryInfoXml(r,t)),i}async wakeUp(e,t){const s=this.normalizeChannel(e),n="number"==typeof t?{waitAfterWakeMs:t}:t??{},r=n.timeoutMs??2e4,i=n.attempts??3,A=n.waitAfterWakeMs??1500,o=n.backoffMs??1500,a="udp"===this.client.getTransport?.(),c=n.reconnect??a;let l;for(let e=1;e<=i;e++)try{return await this.getEncXml(s,{timeoutMs:r}),void(A>0&&await new Promise((e=>setTimeout(e,A))))}catch(t){l=t;const s=t instanceof Error?t.message:String(t),n=s.includes("Baichuan timeout"),r=s.toLowerCase().includes("socket closed")||s.toLowerCase().includes("stream closed");if(e<i){if(c&&(n||r))try{this.client.loggedIn=!1,await this.client.close()}catch{}o>0&&await new Promise((e=>setTimeout(e,o)));continue}}throw l instanceof Error?l:new Error(String(l))}async isSleeping(e){const t=this.normalizeChannel(e);try{return await Promise.race([this.getBatteryInfo(t),new Promise(((e,t)=>setTimeout((()=>t(new Error("Timeout"))),5e3)))]),!1}catch(e){return!0}}async getPirInfo(e){const t=this.normalizeChannel(e),s=await this.sendXml({cmdId:n.H9,channel:t}),r=e=>{if(void 0===e)return;const t=e.trim().toLowerCase();if("true"===t)return 1;if("false"===t)return 0;const s=Number(t);return Number.isFinite(s)?s:void 0},i=v(s,"enable"),A=v(s,"sensiValue"),o=v(s,"reduceFalseAlarm"),a=v(s,"interval"),c=v(s,"intervalSecMax"),l={channel:t};if(void 0!==i){const e=r(i);void 0!==e&&(l.enable=e)}if(void 0!==A&&(l.sensitive=Number(A)),void 0!==o){const e=r(o);void 0!==e&&(l.reduceAlarm=e)}if(void 0!==a){const e=r(a);void 0!==e&&(l.interval=e)}if(void 0!==c){const e=r(c);void 0!==e&&(l.intervalMax=e)}return{enabled:(e=>{if(void 0===e)return!1;const t=e.trim().toLowerCase();return"1"===t||"true"===t})(i),state:l}}async setPirInfo(e,t){const s="number"==typeof e?e:t,r="number"==typeof e?t:e,i=this.normalizeChannel(s);let A=await this.sendXml({cmdId:n.H9,channel:i});if(void 0!==r.enable&&(A=A.replace(/<enable>[^<]*<\/enable>/,`<enable>${r.enable}</enable>`)),void 0!==r.sensitive){const e=(o=r.sensitive,Math.trunc(101-o));A=A.replace(/<sensiValue>[^<]*<\/sensiValue>/,`<sensiValue>${e}</sensiValue>`)}var o;if(void 0!==r.reduceAlarm){const e=(e=>{if(null==e)return;if("boolean"==typeof e)return e?1:0;const t=Number(e);return Number.isFinite(t)?t:void 0})(r.reduceAlarm);void 0!==e&&(A=A.replace(/<reduceFalseAlarm>[^<]*<\/reduceFalseAlarm>/,`<reduceFalseAlarm>${e}</reduceFalseAlarm>`))}void 0!==r.interval&&(A=A.replace(/<interval>[^<]*<\/interval>/,`<interval>${r.interval}</interval>`)),await this.sendXml({cmdId:n.rJ,channel:i,payloadXml:A})}async setMotionDetection(e,t,s){const r="number"==typeof e?e:s,i="number"==typeof e?t:e,A="number"==typeof e?s:t,o=this.normalizeChannel(r);let a=await this.sendXml({cmdId:46,channel:o});void 0!==i&&(a=a.replace(/<enable>[^<]*<\/enable>/,`<enable>${i?"1":"0"}</enable>`)),void 0!==A&&(a=a.replace(/<sensitivityDefault>[^<]*<\/sensitivityDefault>/,`<sensitivityDefault>${A}</sensitivityDefault>`)),await this.sendXml({cmdId:n.zt,channel:o,payloadXml:a})}async setAiDetection(e,t,s,r){const i="number"==typeof e?e:r,A="number"==typeof e?t:e,o="number"==typeof e?s:t,a="number"==typeof e?r:s,c=this.normalizeChannel(i),l=`<?xml version="1.0" encoding="UTF-8" ?>\n <body>\n <AiDetectCfg version="1.1">\n <chn>${c}</chn>\n <type>${w(A)}</type>\n </AiDetectCfg>\n </body>`;let h=await this.sendXml({cmdId:342,channel:c,payloadXml:l});void 0!==o&&(h=h.replace(/<sensitivity>[^<]*<\/sensitivity>/,`<sensitivity>${o}</sensitivity>`)),void 0!==a&&(h=h.replace(/<stayTime>[^<]*<\/stayTime>/,`<stayTime>${a}</stayTime>`)),await this.sendXml({cmdId:n.fP,channel:c,payloadXml:h})}async getSiren(e){try{const t=await this.sendXml({cmdId:n.pH,...void 0!==e?{channel:e}:{}});return{enabled:"1"===v(t,"status")}}catch{return{enabled:!1}}}async setSiren(e,t,s){const r="boolean"==typeof e?s??0:e,i="boolean"==typeof e?e:t,A="boolean"==typeof e?t:s,o=void 0!==r?r+1:void 0;let a;if(void 0!==A)a=k(o,A);else{a=R(o,i?1:0)}try{await this.sendXml({cmdId:n.zu,...void 0!==r?{channel:r}:{},payloadXml:a})}catch(e){if(!0!==i||void 0!==A)throw e;a=k(o,2),await this.sendXml({cmdId:n.zu,...void 0!==r?{channel:r}:{},payloadXml:a})}}async getWhiteLedState(e){const t=this.normalizeChannel(e),s=await this.sendXml({cmdId:n.as,channel:t}),r=v(s,"enable"),i=v(s,"state"),A=v(s,"status"),o=v(s,"brightness_cur"),a={enabled:"1"===r||"1"===i||"1"===A};return void 0!==o&&(a.brightness=Number(o)),a}async setWhiteLedState(e,t,s){const r="number"==typeof e?e:s??0,i="number"==typeof e?t:e,A="number"==typeof e?s:t,o=this.normalizeChannel(r);if(void 0!==i)try{const e=T(o,i?1:0,i?180:0);await this.sendXml({cmdId:n.AG,channel:o,payloadXml:e})}catch(e){let t=await this.sendXml({cmdId:n.as,channel:o});/<enable>[^<]*<\/enable>/i.test(t)&&(t=t.replace(/<enable>[^<]*<\/enable>/i,`<enable>${i?1:0}</enable>`)),/<state>[^<]*<\/state>/i.test(t)&&(t=t.replace(/<state>[^<]*<\/state>/i,`<state>${i?1:0}</state>`)),/<status>[^<]*<\/status>/i.test(t)&&(t=t.replace(/<status>[^<]*<\/status>/i,`<status>${i?1:0}</status>`)),await this.sendXml({cmdId:n.YF,channel:o,payloadXml:t})}if(void 0!==A){let e=await this.sendXml({cmdId:n.as,channel:o});/<brightness_cur>[^<]*<\/brightness_cur>/i.test(e)&&(e=e.replace(/<brightness_cur>[^<]*<\/brightness_cur>/i,`<brightness_cur>${A}</brightness_cur>`)),/<enable>[^<]*<\/enable>/i.test(e)&&(e=e.replace(/<enable>[^<]*<\/enable>/i,"<enable>1</enable>")),await this.sendXml({cmdId:n.YF,channel:o,payloadXml:e})}}async getAbilityInfo(){const e=this.client.username,t=`<?xml version="1.0" encoding="UTF-8" ?>\n<Extension version="1.1">\n<userName>${w(e)}</userName>\n<token>system, streaming, PTZ, IO, security, replay, disk, network, alarm, record, video, image</token>\n</Extension>`;const s=await this.sendXml({cmdId:n.fg,extensionXml:t}),r={},i=["system","streaming","PTZ","IO","security","replay","disk","network","alarm","record","video","image"];for(const e of i){const t=new RegExp(`<${e}[^>]*>([\\s\\S]*?)<\\/${e}>`,"i"),n=s.match(t);if(n){const e=(n[1]??"").matchAll(/<subModule[^>]*>([\s\S]*?)<\/subModule>/g);for(const t of e){const e=t[1]??"",s=v(e,"channelId")||v(e,"chnID"),n=v(e,"abilityValue");if(n){const e=s?Number(s):"Host";r[e]||(r[e]={});const t=n.split(",").map((e=>e.trim())).filter(Boolean);for(const s of t)r[e][s]=1}}}}const A=s.match(/<AbilityInfo[^>]*>([\s\S]*?)<\/AbilityInfo>/);if(A){const e=(A[1]??"").matchAll(/<([A-Za-z]+)[^>]*>([^<]*)<\/\1>/g);r.Host||(r.Host={});for(const t of e){const e=t[1],s=t[2];if(e&&void 0!==s&&!["image","video","subModule"].includes(e)&&"channelId"!==e&&"abilityValue"!==e){const t=Number(s);r.Host[e]=Number.isNaN(t)?s:t}}}return r.Host&&0===Object.keys(r.Host).length&&delete r.Host,r}async getAbilityVersion(e,t){const s=(await this.getAbilityInfo())[null!=t?t:"Host"];if(!s)return 0;const n=s[e];if("number"==typeof n)return n;if("string"==typeof n){const e=Number(n);return Number.isNaN(e)?0:e}return 0}async getSupportInfo(){return we(await this.sendXml({cmdId:n.fk}))}async getDeviceCapabilities(e,t){const s=null!=e,r=this.normalizeChannel(e),i=t?.probe??!0,A=t?.probeSiren??!0,o=t?.probeFloodlight??!0,[a,c]=await Promise.allSettled([this.getAbilityInfo(),this.getSupportInfo()]),l="fulfilled"===a.status?a.value:void 0,h="fulfilled"===c.status?c.value:void 0,g=l?s?{..."object"==typeof l.Host?{Host:l.Host}:{},..."object"==typeof l[r]?{[r]:l[r]}:{}}:l:void 0,d=h?s?{...h,items:(h.items??[]).filter((e=>e.chnID===r))}:h:void 0,u={channel:r};g&&(u.abilities=g),d&&(u.support=d);const I=De(u),E=ye(g,r),p=e=>{if("number"==typeof e)return e>0;if("string"==typeof e){const t=Number(e);return Number.isFinite(t)?t>0:e.length>0&&"0"!==e}return Boolean(e)},C=d?{rtsp:p(d.rtsp),onvif:p(d.onvif),wifi:p(d.wifi),record:p(d.record),ftp:p(d.ftp),email:p(d.email),pushAlarm:p(d.pushAlarm),audioTalk:p(d.audioTalk)}:void 0;if(i&&A&&!I.hasSiren){const e=async()=>{try{return await this.sendXml({cmdId:n.pH,channel:r,timeoutMs:1e3}),!0}catch{return!1}},t=async()=>{try{const e=R(r+1,0);return await this.sendXml({cmdId:n.zu,channel:r,payloadXml:e,timeoutMs:1e3}),!0}catch{return!1}};(await e()||await t())&&(I.hasSiren=!0)}if(i&&o&&!I.hasFloodlight){const e=(d?.items??[]).filter((e=>e.chnID===r||e.chnID===r+1)),t=e=>{const t=e?.lightType;if("number"==typeof t)return t;if("string"==typeof t){const e=Number(t);return Number.isFinite(e)?e:void 0}},s=e.map((e=>t(e))).filter((e=>Number.isFinite(e)));if(s.some((e=>0===e)));else if(s.some((e=>e>0)))I.hasFloodlight=!0;else try{const e=await this.sendXml({cmdId:n.as,channel:r,timeoutMs:1e3});/(<FloodlightTask\b|<FloodlightManual\b|<FloodlightStatusList\b|<WhiteLed\b)/i.test(e)&&(I.hasFloodlight=!0)}catch{}}let B,Q;try{const e=(v(await this.sendXml({cmdId:299,channel:r,timeoutMs:1500}),"detectType")??"").trim();if(e){const t=e.split(",").map((e=>e.trim())).filter(Boolean);t.length>0&&(B=t)}}catch{}if(I.hasPresets){const e=(await Promise.allSettled([this.getPtzPresets(r)]))[0];"fulfilled"===e?.status&&(Q=e.value,I.hasPresets=Q.length>0)}const f={channel:r,channelId1Based:r+1,transport:this.client.getTransport(),encryptionKind:this.client.enc.kind,loggedIn:this.client.loggedIn,subscribed:this.client.subscribed,abilitiesAvailable:Boolean(g),supportAvailable:Boolean(d)};E&&(f.abilityMergedKeyCount=Object.keys(E).length),d?.items&&(f.supportItemCount=d.items.length);const m={capabilities:I,debug:f};return g&&(m.abilities=g),d&&(m.support=d),Q&&(m.presets=Q),B&&(m.objects=B),C&&(m.features=C),m}async getDualLensChannelInfo(){let e,t,s;try{const t=await this.getInfo(0,{tags:["type"]});e=t.type?.trim()}catch{}try{const e=await this.getDeviceCapabilities(0);t=e.support?.channelNum,s=e.support}catch{}let n=e?e.trim():void 0;if(!n&&s)for(const e of s.items??[])if(e.typeInfo){n=String(e.typeInfo).trim();break}n?.toLowerCase().trim();const r=(e,t)=>{if(!t||0===t.length)return!1;const s=t.toLowerCase().trim();for(const t of e){const e=t.toLowerCase().trim();if(s===e)return!0;if(s.includes(e)||e.includes(s))return!0;if(s.includes("trackmix")&&e.includes("trackmix"))return!0;if(s.includes("duo")&&e.includes("duo"))return!0}return!1},i=!!n&&r(Ue,n),A=!!n&&r(Le,n),o="string"==typeof t?Number.parseInt(t,10):t,a=(2===o||3===o)&&Number.isFinite(o);if(!(i||A||a))return{isDualLens:!1,model:n,streamChannelCount:t,logicalChannelCount:t,channels:[],capabilityChannels:{pan:[],tilt:[],zoom:[],motion:[],intercom:[],presets:[]}};let c=i?"dual_motion":A?"single_motion":void 0;if(!c&&a){const e=n?.toLowerCase()??"";e.includes("trackmix")?c="single_motion":e.includes("duo")?c="dual_motion":2===o&&(c="single_motion")}const l=[],h=[];if("single_motion"===c)l.push(0,1),h.push(0);else if("dual_motion"===c)2===o?(l.push(0,1),h.push(0,1)):(l.push(0),h.push(0));else if(o&&Number.isFinite(o)&&o>=2)for(let e=0;e<o;e++)l.push(e),h.push(e);else l.push(0,1),h.push(0);const g=[];for(const e of l)try{const t=await this.getDeviceCapabilities(e),s=t.capabilities,n=t.support,r=t.features;let i=!1;i="single_motion"===c?0===e:"dual_motion"===c?h.includes(e):0===e;const A={rtsp:!1,rtmp:!1,native:!0};if(r?.rtsp||n?.rtsp)A.rtsp=!0;else try{n&&"number"==typeof n.rtsp&&n.rtsp>0&&(A.rtsp=!0)}catch{}let o;n&&"number"==typeof n.rtmp&&n.rtmp>0&&(A.rtmp=!0),0===e?o="wide":1===e&&(o="telephoto");let a=s.hasZoom??!1;"single_motion"===c&&1===e&&"telephoto"===o&&(a=!0),g.push({channel:e,hasPan:s.hasPan??!1,hasTilt:s.hasTilt??!1,hasZoom:a,hasMotion:i,hasIntercom:s.hasIntercom??!1,hasPresets:s.hasPresets??!1,lensType:o,availableStreams:A})}catch(t){(this.logger.warn??this.logger.log).call(this.logger,`[ReolinkBaichuanApi] getDualLensChannelInfo: error in channel ${e}: ${t}`)}const d={pan:g.filter((e=>e.hasPan)).map((e=>e.channel)),tilt:g.filter((e=>e.hasTilt)).map((e=>e.channel)),zoom:g.filter((e=>e.hasZoom)).map((e=>e.channel)),motion:g.filter((e=>e.hasMotion)).map((e=>e.channel)),intercom:g.filter((e=>e.hasIntercom)).map((e=>e.channel)),presets:g.filter((e=>e.hasPresets)).map((e=>e.channel))};return{isDualLens:!0,dualLensType:c,model:n,streamChannelCount:l.length,logicalChannelCount:h.length,channels:g,capabilityChannels:d}}async createRtspStream(e,t,s){const n="number"==typeof e?this.normalizeChannel(e):0,r="number"==typeof e?t:e,i="number"==typeof e?s:t;let A;try{const e=await this.getStreamMetadata(n);if(Array.isArray(e)){const t=e.find((e=>e.profile===r));t?.videoEncType&&(A=t.videoEncType)}else if(e&&"object"==typeof e&&"streams"in e){const t=e.streams;if(Array.isArray(t)){const e=t.find((e=>e?.profile===r));e?.videoEncType&&(A=e.videoEncType)}}}catch(e){this.logger.warn(`[ReolinkBaichuanApi] Could not fetch stream metadata, will auto-detect codec: ${e instanceof Error?e.message:e}`)}const o={api:this,channel:n,profile:r,...void 0!==i?.listenHost?{listenHost:i.listenHost}:{},...void 0!==i?.listenPort?{listenPort:i.listenPort}:{},...void 0!==i?.path?{path:i.path}:{},logger:this.logger},a=new ge(o);return await a.start(),this.rtspServers.add(a),a.once("close",(()=>{this.rtspServers.delete(a)})),a}async buildVideoStreamOptions(e,t){const s=t?.includeAuth,n=this.normalizeChannel(e),r=[],i=[],A=[],o=await this.getNetPort(),a=1===o.rtsp?.enable,c=1===o.rtmp?.enable,l=o.rtsp?.port??554,h=o.rtmp?.port??1935,g=await this.getStreamMetadata(n),d=g?.streams||[];for(const e of d){const t=e.profile;if(a&&"ext"!==t){const i=String(n+1).padStart(2,"0"),A="main"===t?"main":"sub",o=`/h264Preview_${i}_${A}`,a=`h264Preview_${i}_${A}`,c=encodeURIComponent(this.username),h=encodeURIComponent(this.password),g=`rtsp://${this.host}:${l}${o}`,d=`rtsp://${c}:${h}@${this.host}:${l}${o}`;r.push({name:`RTSP ${a}`,id:a,container:"rtsp",channel:n,profile:t,url:s?d:g,urlWithAuth:d,path:o,port:l,metadata:e})}if(c){const r="main"===t?"main":"sub"===t?"sub":"ext",A="sub"===t?1:0,o=`${r}.bcs`,a=`/bcs/channel${n}_${r}.bcs`,c=new URL(`rtmp://${this.host}:${h}${a}`),l=c.searchParams;l.set("channel",n.toString()),l.set("stream",A.toString());const g=new URL(`rtmp://${this.host}:${h}${a}`),d=g.searchParams;d.set("channel",n.toString()),d.set("stream",A.toString()),d.set("user",this.username),d.set("password",this.password),i.push({name:`RTMP ${o}`,id:o,container:"rtmp",channel:n,profile:t,url:s?g.toString():c.toString(),urlWithAuth:g.toString(),path:a,port:h,streamType:A,metadata:e})}const o=`baichuan://${this.host}/channel/${n}/profile/${t}`;A.push({name:`Native ${t}`,id:`native_${t}`,container:"rtp",channel:n,profile:t,url:o,urlWithAuth:o,metadata:e})}return{nativeStreams:A,rtmpStreams:i,rtspStreams:r}}async testChannelStreams(e,t){const{testChannelStreams:n}=await Promise.resolve().then(s.bind(s,6546));return await n({api:this,channel:this.normalizeChannel(e),...void 0!==t?{logger:t}:{}})}async collectMultifocalDiagnostics(e){const{collectMultifocalDiagnostics:t}=await Promise.resolve().then(s.bind(s,6546));return await t({api:this,logger:e})}};function Ye(e,t,s){const n=[];let r=0;const i=(e,n)=>{if(4===t)return"be"===s?e.readUInt32BE(n):e.readUInt32LE(n);if(2===t)return"be"===s?e.readUInt16BE(n):e.readUInt16LE(n);if(3===t){const t=e[n],r=e[n+1],i=e[n+2];return"be"===s?(t<<16|r<<8|i)>>>0:(i<<16|r<<8|t)>>>0}return e.readUInt8(n)};for(;r+t<=e.length;){const s=i(e,r);if(r+=t,!s)return[];if(r+s>e.length)return[];const A=e.subarray(r,r+s);r+=s,A.length&&n.push(A)}return r!==e.length?[]:n}function Ve(e,t){if(!t.length)return Number.POSITIVE_INFINITY;let s=0;for(const n of t)if(n.length){if(128&n[0])s+=10;else if("H264"===e){const e=31&n[0];(e<1||e>23)&&s++}else if("H265"===e){if(n.length<2){s++;continue}const e=n[0]>>1&63;e>=0&&e<=29||e>=32&&e<=40||e>=48&&e<=50||s++}}else s++;return s}function Oe(e,t){if(!e?.length)return[];const s=[],n=function(e,t=64){if(!e?.length)return-1;const s=Math.min(e.length,Math.max(0,t));for(let t=0;t+3<s;t++)if(0===e[t]&&0===e[t+1]){if(1===e[t+2])return t;if(0===e[t+2]&&1===e[t+3])return t}return-1}(e,64);if(n>=0){const t=function(e){const t=[],s=e.length,n=t=>{if(t+3<=s&&0===e[t]&&0===e[t+1]){if(1===e[t+2])return 3;if(t+4<=s&&0===e[t+2]&&1===e[t+3])return 4}return 0};let r=0;for(;r<s&&!n(r);)r++;for(;r<s;){const i=n(r);if(!i){r++;continue}const A=r+i;let o=A;for(;o<s&&!n(o);)o++;if(A<o){const s=e.subarray(A,o);s.length>0&&t.push(s)}r=o}return t}(0===n?e:e.subarray(n));t.length&&s.push(t)}s.push(Ye(e,4,"be")),s.push(Ye(e,4,"le")),s.push(Ye(e,3,"be")),s.push(Ye(e,3,"le")),s.push(Ye(e,2,"be")),s.push(Ye(e,2,"le")),s.push(Ye(e,1,"be"));const r=function(e){if(e.length>=4&&0===e[0]&&0===e[1]){if(1===e[2])return e.subarray(3);if(0===e[2]&&1===e[3])return e.subarray(4)}return e}(e);r.length&&s.push([r]);let i=[],A=Number.POSITIVE_INFINITY;for(const e of s){if(!e.length)continue;const s=Ve(t,e);if(s<A&&(A=s,i=e,0===A))break}return i}function Ge(e){const t=Oe(e,"H264");let s,n,r;for(const e of t){if(e.length<1)continue;const t=31&e[0];if(7===t){if(s=e,e.length>=4){r=Buffer.from([e[1],e[2],e[3]]).toString("hex")}}else 8===t&&(n=e)}const i={};return s&&(i.sps=s),n&&(i.pps=n),r&&(i.profileLevelId=r),i}function Je(e){const t=Oe(e,"H265");let s,n,r;for(const e of t){if(e.length<2)continue;const t=e[0]>>1&63;32===t?s=e:33===t?n=e:34===t&&(r=e)}const i={};return s&&(i.vps=s),n&&(i.sps=n),r&&(i.pps=r),i}var We=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];function _e(e){if(e.length<7)return null;if(255!==e[0]||240&~e[1])return null;const t=!(1&~e[1]),s=((192&e[2])>>6)+1,n=(60&e[2])>>2,r=We[n]??0,i=(1&e[2])<<2|(192&e[3])>>6;if(!r||!i)return null;const A=t?7:9;if(e.length<A)return null;return{headerLength:A,sampleRate:r,channels:i,configHex:((31&s)<<11|(15&n)<<7|(15&i)<<3).toString(16).padStart(4,"0")}}var $e=class{constructor(e){this.payloadType=e,this.seq=r.randomBytes(2).readUInt16BE(0)}seq=0;timestamp=0;ssrc=r.randomBytes(4).readUInt32BE(0);setTimestamp(e){this.timestamp=e>>>0}getTimestamp(){return this.timestamp>>>0}advanceTimestamp(e){this.timestamp=this.timestamp+(e>>>0)>>>0}writePacket(e,t){const s=Buffer.alloc(12);return s[0]=128,s[1]=(t?128:0)|127&this.payloadType,s.writeUInt16BE(65535&this.seq,2),s.writeUInt32BE(this.timestamp>>>0,4),s.writeUInt32BE(this.ssrc>>>0,8),this.seq=this.seq+1&65535,Buffer.concat([s,e])}};function qe(e,t,s,n,r){const i=s.maxRtpPayload,A=[];if(e.length<=i)return A.push(t.writePacket(e,n&&r)),A;const o=e[0],a=31&o,c=128&o|96&o|28,l=e.subarray(1);let h=0;for(;h<l.length;){const e=l.length-h,s=Math.min(e,i-2),o=0===h,g=h+s>=l.length,d=(o?128:0)|(g?64:0)|31&a,u=Buffer.concat([Buffer.from([c,d]),l.subarray(h,h+s)]);A.push(t.writePacket(u,n&&r&&g)),h+=s}return A}function ze(e,t,s,n,r){const i=s.maxRtpPayload,A=[];if(e.length<=i)return A.push(t.writePacket(e,n&&r)),A;if(e.length<3)return A;const o=e[0],a=o>>1&63,c=129&o|98,l=e[1],h=e.subarray(2);let g=0;for(;g<h.length;){const e=h.length-g,s=Math.min(e,i-3),o=0===g,d=g+s>=h.length,u=(o?128:0)|(d?64:0)|63&a,I=Buffer.concat([Buffer.from([c,l,u]),h.subarray(g,g+s)]);A.push(t.writePacket(I,n&&r&&d)),g+=s}return A}var Xe=class e{constructor(e,t,s,n=25,r=1200){this.logger=e,this.videoPayloadType=t,this.maxRtpPayload=r,this.videoRtp=new $e(t),void 0!==s&&(this.audioRtp=new $e(s)),this.fallbackVideoIncrement=Math.max(1,Math.round(this.videoClockRate/Math.max(1,n))),this.fallbackVideoDeltaUs=Math.max(1,Math.round(1e6*this.fallbackVideoIncrement/this.videoClockRate))}clients=new Set;closed=!1;videoRtp;audioRtp;videoLastUsRaw;videoUsWrapOffset=0;videoLastAbsUs;videoAvgDeltaUs;videoClockRate=9e4;fallbackVideoIncrement;fallbackVideoDeltaUs;maxTrustedDeltaUs=5e5;emaAlpha=.1;videoTimingLogState={lastUntrustedDeltaLogMs:0,lastWrapLogMs:0,lastResetLogMs:0,untrustedDeltaCount:0,wrapCount:0,resetCount:0};cachedH264ParamSetsAnnexB;cachedH265ParamSetsAnnexB;addClient(e){if(this.closed)return void e.destroy();const t={socket:e,needsKeyframe:!0,sentVideoConfig:!1};this.clients.add(t);const s=()=>{this.clients.delete(t);try{e.destroy()}catch{}};e.on("error",s),e.on("close",s)}static ANNEXB_START_CODE=Buffer.from([0,0,0,1]);static joinAnnexBNals(...t){const s=t.filter((e=>!!e&&e.length>0));if(!s.length)return;const n=[];for(const t of s)n.push(e.ANNEXB_START_CODE,t);return Buffer.concat(n)}updateVideoParamSetsFromAccessUnit(t,s){if(!s?.length)return;if("H264"===t){const{sps:t,pps:n}=Ge(s);return void(t&&n&&(this.cachedH264ParamSetsAnnexB=e.joinAnnexBNals(t,n)))}const{vps:n,sps:r,pps:i}=Je(s);n&&r&&i&&(this.cachedH265ParamSetsAnnexB=e.joinAnnexBNals(n,r,i))}sendCachedVideoConfigToClient(e,t){if(this.closed)return;if(t.sentVideoConfig)return;const s="H265"===e?this.cachedH265ParamSetsAnnexB:this.cachedH264ParamSetsAnnexB;if(!s?.length)return;const n=Oe(s,e);if(!n.length)return;const r={maxRtpPayload:this.maxRtpPayload};for(let s=0;s<n.length;s++){const i=n[s],A=s===n.length-1,o="H265"===e?ze(i,this.videoRtp,r,!1,A):qe(i,this.videoRtp,r,!1,A);for(const e of o)this.writeRtpPacketToClient(t,e)}t.sentVideoConfig=!0}close(){if(!this.closed){this.closed=!0;for(const e of Array.from(this.clients))try{e.socket.destroy()}catch{}this.clients.clear()}}writeRtpPacketToClient(e,t){if(e.socket.destroyed||!e.socket.writable)return;const s=Buffer.alloc(2);s.writeUInt16BE(65535&t.length,0);const n=Buffer.concat([s,t]);try{e.socket.write(n)}catch{try{e.socket.destroy()}catch{}}}writeRtpPacketToClients(e,t){for(const s of this.clients)t(s)&&this.writeRtpPacketToClient(s,e)}resetVideoTimestampMapping(){this.videoLastUsRaw=void 0,this.videoUsWrapOffset=0,this.videoLastAbsUs=void 0,this.videoAvgDeltaUs=void 0}logVideoTiming(e,t){const s=Date.now(),n=5e3,r=this.videoTimingLogState;if("untrusted-delta"===e){if(r.untrustedDeltaCount++,s-r.lastUntrustedDeltaLogMs<n)return;return r.lastUntrustedDeltaLogMs=s,void this.logger.warn(`[rfc4571] video timing: ${t} (untrustedDeltaCount=${r.untrustedDeltaCount})`)}if("wrap"===e){if(r.wrapCount++,s-r.lastWrapLogMs<n)return;return r.lastWrapLogMs=s,void this.logger.warn(`[rfc4571] video timing: ${t} (wrapCount=${r.wrapCount})`)}r.resetCount++,s-r.lastResetLogMs<n||(r.lastResetLogMs=s,this.logger.warn(`[rfc4571] video timing: ${t} (resetCount=${r.resetCount})`))}advanceVideoTimestampFallback(){this.videoRtp.advanceTimestamp(this.fallbackVideoIncrement)}setVideoTimestampFromMicroseconds(e){if(null==e)return void this.advanceVideoTimestampFallback();if(!Number.isFinite(e))return void this.advanceVideoTimestampFallback();const t=e>>>0;if(void 0!==this.videoLastUsRaw){const e=this.videoLastUsRaw;if(t<e){e>4026531840&&t<268435455?(this.videoUsWrapOffset+=4294967296,this.logVideoTiming("wrap",`detected u32 wrap (lastUsRaw=${e} curUsRaw=${t} wrapOffset=${this.videoUsWrapOffset})`)):(this.logVideoTiming("reset",`detected backwards jump; resetting mapping (lastUsRaw=${e} curUsRaw=${t})`),this.resetVideoTimestampMapping())}}this.videoLastUsRaw=t;const s=this.videoUsWrapOffset+t;if(void 0===this.videoLastAbsUs)return this.videoLastAbsUs=s,void(void 0===this.videoAvgDeltaUs&&(this.videoAvgDeltaUs=this.fallbackVideoDeltaUs));const n=s-this.videoLastAbsUs;this.videoLastAbsUs=s;let r;if(Number.isFinite(n)&&n>0&&n<=this.maxTrustedDeltaUs){const e=this.videoAvgDeltaUs??n;this.videoAvgDeltaUs=e+(n-e)*this.emaAlpha,r=n}else this.logVideoTiming("untrusted-delta",`discarded deltaUs=${n} (absUs=${s} lastAbsUs=${this.videoLastAbsUs} avgDeltaUs=${this.videoAvgDeltaUs??"n/a"}); using fallback`),r=this.videoAvgDeltaUs??this.fallbackVideoDeltaUs;const i=Math.max(1,Math.round(r*this.videoClockRate/1e6));this.videoRtp.advanceTimestamp(i)}sendVideoAccessUnit(e,t,s,n){if(this.closed)return;this.updateVideoParamSetsFromAccessUnit(e,t);const r=Oe(t,e);if(!r.length)return;let i=!1;if("H264"===e)for(const e of r){if(5===(31&e[0])){i=!0;break}}else for(const e of r){if(e.length<2)continue;const t=e[0]>>1&63;if(t>=16&&t<=23){i=!0;break}}const A=s||i,o=e=>!!A||!e.needsKeyframe;let a=!1;for(const e of this.clients)if(o(e)){a=!0;break}if(!a){for(const t of this.clients)t.needsKeyframe&&this.sendCachedVideoConfigToClient(e,t);return}this.setVideoTimestampFromMicroseconds(n);for(const t of this.clients)t.needsKeyframe&&this.sendCachedVideoConfigToClient(e,t);const c={maxRtpPayload:this.maxRtpPayload};for(let t=0;t<r.length;t++){const s=r[t],n=t===r.length-1,i="H265"===e?ze(s,this.videoRtp,c,!0,n):qe(s,this.videoRtp,c,!0,n);for(const e of i)this.writeRtpPacketToClients(e,o)}if(A)for(const e of this.clients)e.needsKeyframe=!1}sendAudioAdtsFrame(e){if(this.closed)return{};if(!this.audioRtp)return{};const{packets:t,config:s}=function(e,t){const s=_e(e);if(!s)return{packets:[]};const n=e.subarray(s.headerLength);if(!n.length)return{packets:[]};const r=Buffer.from([0,16]),i=8191&n.length,A=Buffer.alloc(2);A[0]=i>>5&255,A[1]=(31&i)<<3;const o=Buffer.concat([r,A,n]);return{packets:[t.writePacket(o,!0)],config:{sampleRate:s.sampleRate,channels:s.channels,configHex:s.configHex}}}(e,this.audioRtp);for(const e of t)this.writeRtpPacketToClients(e,(e=>!e.needsKeyframe));return t.length&&this.audioRtp.advanceTimestamp(1024),s?{parsed:s}:{}}sendAudioRtpPacket(e){if(this.closed)return;if(!e||e.length<12)return;2===(e[0]>>6&3)&&this.writeRtpPacketToClients(e,(e=>!e.needsKeyframe))}static parseRtpPayload(e){if(!e||e.length<12)return;if(2!==(e[0]>>6&3))return;const t=!!(32&e[0]),s=!!(16&e[0]);let n=12+4*(15&e[0]);if(n>e.length)return;if(s){if(n+4>e.length)return;if(n+=4+4*e.readUInt16BE(n+2),n>e.length)return}let r=e.length;if(t){const t=e[e.length-1];if(t<=0||t>e.length)return;if(r=e.length-t,r<n)return}return r<=n?void 0:e.subarray(n,r)}static isH264KeyframeLikeRtpPacket(t){const s=e.parseRtpPayload(t);if(!s||s.length<1)return!1;const n=31&s[0];if(n>=1&&n<=23)return 5===n||7===n||8===n;if(24===n){let e=1;for(;e+2<=s.length;){const t=s.readUInt16BE(e);if(e+=2,!t||e+t>s.length)break;const n=31&s[e];if(5===n||7===n||8===n)return!0;e+=t}return!1}if(28===n&&s.length>=2){const e=s[1],t=31&e;return!!!!(128&e)&&(5===t||7===t||8===t)}return!1}static isH265KeyframeLikeRtpPacket(t){const s=e.parseRtpPayload(t);if(!s||s.length<2)return!1;const n=s[0]>>1&63,r=e=>e>=16&&e<=21||(32===e||33===e||34===e);if(49===n&&s.length>=3){const e=s[2];return!!!!(128&e)&&r(63&e)}return r(n)}sendVideoRtpPacket(t,s){if(this.closed)return;if(!s||s.length<12)return;if(2!==(s[0]>>6&3))return;const n="H265"===t?e.isH265KeyframeLikeRtpPacket(s):e.isH264KeyframeLikeRtpPacket(s);if(this.writeRtpPacketToClients(s,(e=>!!n||!e.needsKeyframe)),n)for(const e of this.clients)e.needsKeyframe=!1}};async function je(e){const{api:t,channel:s,profile:r,logger:i,expectedVideoType:o,host:a="127.0.0.1",videoPayloadType:c=96,audioPayloadType:l=97,keyframeTimeoutMs:h=5e3,uptimeRestartMs:g=1e4,idleTeardownMs:d=2500,closeApiOnTeardown:u=!0,username:I,password:E,requireAuth:p=!1}=e,C=`[native-rfc4571 ch=${s} profile=${r}]`,B=e=>i.warn(`${C} ${e}`);B(`starting (host=${a} videoPT=${c} audioPT=${l} expectedVideoType=${o??"n/a"} keyframeTimeoutMs=${h} uptimeRestartMs=${g} idleTeardownMs=${d})`);const Q=new n.tj({client:t.client,api:t,channel:s,profile:r,logger:i});await Q.start(),B("baichuan stream started; waiting for keyframe to extract parameter sets");const f=await(async()=>await new Promise(((e,t)=>{const n=setTimeout((()=>{o(),t(new Error(`Timeout waiting for keyframe on native stream channel=${s} profile=${r}`))}),h),i=e=>{o(),t(e instanceof Error?e:new Error(String(e)))},A=t=>{if(!t?.isKeyframe)return;const s=t.videoType,n=t.data;if("H264"===s){const{sps:t,pps:r,profileLevelId:i}=Ge(n);if(!t||!r)return;return o(),void e({videoType:s,accessUnit:n,...i?{profileLevelId:i}:{},h264:{sps:t,pps:r}})}const{vps:r,sps:i,pps:A}=Je(n);r&&i&&A&&(o(),e({videoType:s,accessUnit:n,h265:{vps:r,sps:i,pps:A}}))},o=()=>{clearTimeout(n),Q.removeListener("error",i),Q.removeListener("videoAccessUnit",A)};Q.on("error",i),Q.on("videoAccessUnit",A)})))();o&&f.videoType!==o&&B(`expectedVideoType mismatch (expected=${o} actual=${f.videoType})`),B(`video detected: codec=${f.videoType} (primed via keyframe)`);let m,y=25;try{const e=await t.getStreamMetadata(s),n=(Array.isArray(e)?e:Array.isArray(e?.streams)?e.streams:[]).find((e=>e?.profile===r)),i=Number(n?.frameRate);Number.isFinite(i)&&i>0&&(y=i)}catch{}B(`video framerate hint: ${y} fps`);m=await(async()=>await new Promise((e=>{let t=!1,s=3;const n=setTimeout((()=>{A(),t&&i.warn("Native audio frames seen but not ADTS AAC; cannot advertise audio track."),e(void 0)}),5e3),r=n=>{t=!0;const r=_e(n);if(r)A(),e({sampleRate:r.sampleRate,channels:r.channels,configHex:r.configHex});else if(s-- >0){const e=n.subarray(0,Math.min(16,n.length)).toString("hex");i.warn(`Native audioFrame not ADTS: len=${n.length} head=${e}`)}},A=()=>{clearTimeout(n),Q.removeListener("audioFrame",r)};Q.on("audioFrame",r)})))(),B(m?`audio detected: codec=aac sampleRate=${m.sampleRate} channels=${m.channels}`:"audio not detected/advertised (no ADTS AAC config within timeout)");const S={videoType:f.videoType,payloadType:c,..."H264"===f.videoType?{h264:{sps:f.h264.sps,pps:f.h264.pps,...f.profileLevelId?{profileLevelId:f.profileLevelId}:{}}}:{h265:{vps:f.h265.vps,sps:f.h265.sps,pps:f.h265.pps}}},w=m?{codec:"aac",payloadType:l,sampleRate:m.sampleRate,channels:m.channels,configHex:m.configHex}:void 0,D=function(e,t){let s="v=0\r\n";if(s+="o=- 0 0 IN IP4 0.0.0.0\r\n",s+="s=No Name\r\n",s+="t=0 0\r\n",s+=`m=video 0 RTP/AVP ${e.payloadType}\r\n`,s+="c=IN IP4 0.0.0.0\r\n",s+=`a=rtpmap:${e.payloadType} ${e.videoType}/90000\r\n`,"H264"===e.videoType&&e.h264){const t=e.h264.sps.toString("base64"),n=e.h264.pps.toString("base64"),r=e.h264.profileLevelId?`profile-level-id=${e.h264.profileLevelId};`:"";s+=`a=fmtp:${e.payloadType} packetization-mode=1;${r}sprop-parameter-sets=${t},${n}\r\n`}if("H265"===e.videoType&&e.h265){const t=e.h265.vps.toString("base64"),n=e.h265.sps.toString("base64"),r=e.h265.pps.toString("base64");s+=`a=fmtp:${e.payloadType} sprop-vps=${t};sprop-sps=${n};sprop-pps=${r}\r\n`}return"aac"===t?.codec&&(s+=`m=audio 0 RTP/AVP ${t.payloadType}\r\n`,s+="c=IN IP4 0.0.0.0\r\n",s+="b=AS:128\r\n",s+=`a=rtpmap:${t.payloadType} MPEG4-GENERIC/${t.sampleRate}/${t.channels}\r\n`,s+=`a=fmtp:${t.payloadType} profile-level-id=1; mode=AAC-hbr; sizelength=13; indexlength=3; indexdeltalength=3; config=${t.configHex}\r\n`),"opus"===t?.codec&&(s+=`m=audio 0 RTP/AVP ${t.payloadType}\r\n`,s+="c=IN IP4 0.0.0.0\r\n",s+="b=AS:128\r\n",s+=`a=rtpmap:${t.payloadType} opus/${t.sampleRate}/${t.channels}\r\n`),s}(S,w),b=()=>new Xe(i,c,w?l:void 0,y);let v=b();B(`SDP ready (video=${f.videoType}/90000 pt=${c}${w?`, audio=aac/${w.sampleRate}/${w.channels} pt=${l}`:", audio=none"})`);let N=0;const R=new Set;let k,T=!1,F=!1,M=Date.now();const U=()=>{M=Date.now()},L=()=>{k&&(clearTimeout(k),k=void 0)};let P;const H=e=>{d&&(k||(k=setTimeout((()=>{k=void 0,0===N&&e(new Error("No RFC4571 clients (idle)")).catch((()=>{}))}),d)))},x=A.createServer(),Y=async e=>{if(T)return;if(F)return;F=!0,U(),L();const t=e?.message||e?.toString?.()||e,s=x.address(),n=s&&"string"!=typeof s?`${s.address}:${s.port}`:"unbound";B(t?`uptime watchdog: restarting (addr=${n} clients=${N} reason=${t})`:`uptime watchdog: restarting (addr=${n} clients=${N})`);for(const e of Array.from(R))try{e.destroy()}catch{}R.clear();try{v.close()}catch{}v=b();try{await Q.stop()}catch{}try{await Q.start()}catch(e){return F=!1,void V(e).catch((()=>{}))}F=!1,U(),B("uptime watchdog: restart complete"),0===N&&H(V)},V=async e=>{if(T)return;T=!0,P&&(clearInterval(P),P=void 0),L();const s=e?.message||e?.toString?.()||e,n=x.address(),r=n&&"string"!=typeof n?`${n.address}:${n.port}`:"unbound";B(s?`teardown requested (addr=${r} clients=${N} reason=${s})`:`teardown requested (addr=${r} clients=${N})`),v.close();try{await Q.stop()}catch{}if(u)try{await t.close()}catch{}try{x.close()}catch{}B("teardown complete")};x.on("connection",(e=>{U();const t=`${e.remoteAddress??"unknown"}:${e.remotePort??"unknown"}`;B(`client connecting (remote=${t} requireAuth=${p})`);const s=()=>{N++,L(),R.add(e),e.on("data",(()=>U()));try{const t=e.write.bind(e);e.write=(...e)=>(U(),t(...e))}catch{}v.addClient(e),B(`client connected (remote=${t} clients=${N})`)};if(p){let n=!1,r=Buffer.alloc(0);const i=setTimeout((()=>{n||(B(`client authentication timeout (remote=${t})`),e.destroy())}),5e3),A=o=>{if(U(),!n){r=Buffer.concat([r,o]);const a=r.toString("utf8").match(/^([^:]+):([^\n]+)\n/);if(a){const[,o,c]=a;if(o!==I||c!==E)return B(`client authentication failed (remote=${t})`),void e.destroy();{n=!0,clearTimeout(i),s();const t=a[0].length,o=r.subarray(t);e.removeListener("data",A),e.on("data",(()=>U())),o.length>0&&e.emit("data",o)}}else if(r.length>1024)return B(`client authentication buffer overflow (remote=${t})`),void e.destroy()}};e.on("data",A)}else s();let n=!0;const r=()=>{n&&(n=!1,N=Math.max(0,N-1),R.delete(e),B(`client disconnected (remote=${t} clients=${N})`),0===N&&H(V))};e.once("close",r),e.once("error",r)})),Q.on("videoAccessUnit",(e=>{U();try{v.sendVideoAccessUnit(e.videoType,e.data,e.isKeyframe,e.microseconds)}catch(e){V(e).catch((()=>{}))}})),w&&Q.on("audioFrame",(e=>{U();try{v.sendAudioAdtsFrame(e)}catch(e){V(e).catch((()=>{}))}})),Q.on("error",(e=>{F||V(e).catch((()=>{}))})),Q.on("close",(e=>{F||V(e).catch((()=>{}))})),await new Promise(((e,t)=>{x.once("error",t),x.listen(0,a,(()=>e()))}));const O=x.address();if(!O||"string"==typeof O)throw new Error("Failed to bind RFC TCP server");const G=O.port;if(!G)throw new Error("Failed to bind RFC TCP server");B(`listening (addr=${a}:${G})`);const J=w?{codec:"aac",sampleRate:w.sampleRate,channels:w.channels}:void 0;return H(V),(()=>{if(!g||g<=0)return;if(P)return;const e=Math.max(250,Math.min(1e3,Math.floor(g/2)));P=setInterval((()=>{if(T||F)return;const e=Date.now()-M;e<g||Y(new Error(`No stream activity for ${e}ms (threshold=${g}ms)`)).catch((()=>{}))}),e)})(),{host:a,port:G,sdp:D,videoType:f.videoType,...J?{audio:J}:{},username:I,password:E,server:x,videoStream:Q,close:V}}var Ze=Buffer.from([0,0,0,1]),Ke=Buffer.from([0,0,1]);function et(e){const t=[];for(let s=0;s<e.length-3;s++)0===e[s]&&0===e[s+1]&&(1===e[s+2]?(t.push({idx:s,len:3}),s+=2):0===e[s+2]&&1===e[s+3]&&(t.push({idx:s,len:4}),s+=3));if(0===t.length)return[];const s=[];for(let n=0;n<t.length;n++){const r=t[n],i=r.idx+r.len,A=t[n+1],o=A?A.idx:e.length;o>i&&s.push(e.subarray(i,o))}return s}function tt(e){if(e.length<1)return null;const t=e[0];return void 0===t?null:31&t}i.EventEmitter;function st(e){const t=e?.trim();return t||void 0}function nt(e,t){const s={host:e.host,username:e.username,password:e.password,...void 0!==e.logger?{logger:e.logger}:{},debugOptions:e.debugOptions??{}};if("tcp"===t){const n=new xe({...s,transport:"tcp"});return rt(n,t,e),n}const n=st(e.uid);if(!n)throw new Error("UID is required for battery cameras (BCUDP)");const r=new xe({...s,transport:"udp",uid:n,idleDisconnect:!0});return rt(r,t,e),r}function rt(e,t,s){try{e.client.on("error",(e=>{if(!s.logger)return;const n=e?.message||e?.toString?.()||String(e);"string"==typeof n&&(n.includes("Baichuan socket closed")||n.includes("Baichuan UDP stream closed")||n.includes("Not running"))||s.logger?.log?.(`[BaichuanClient] error (${t}) ${s.host}: ${n}`)})),e.client.on("close",(()=>{}))}catch{}}async function it(e){const{host:t,uid:s,logger:r}=e;r?.log?.(`[AutoDetect] Pinging ${t}...`);const i=await async function(e,t=3e3){return new Promise((s=>{const{exec:r}=(0,n.ki)("child_process");r("win32"===process.platform?`ping -n 1 -w ${t} ${e}`:`ping -c 1 -W ${Math.floor(t/1e3)} ${e}`,(e=>{s(!e)}))}))}(t);let A;r?.log?.(i?`[AutoDetect] Host ${t} is reachable`:`[AutoDetect] Host ${t} is not reachable via ping, but continuing with connection attempt...`);try{r?.log?.(`[AutoDetect] Trying TCP connection to ${t}...`),A=nt(e,"tcp"),await A.login();const n=await A.getInfo(),i=await A.getDeviceCapabilities(),o=i?.support?.channelNum??1,a=n.type?.trim();r?.log?.(`[AutoDetect] TCP connection successful. channelNum=${o}, model=${a??"unknown"}`);const c=a?a.trim():void 0;return!!c&&Pe.has(c)?(r?.log?.(`[AutoDetect] Detected multi-focal device (model: ${c}, channelNum=${o})`),await A.close(),{type:"multifocal",transport:"tcp",uid:s||"",deviceInfo:n,channelNum:o}):o>1?(r?.log?.(`[AutoDetect] Detected NVR (${o} channels)`),await A.close(),{type:"nvr",transport:"tcp",uid:s||"",deviceInfo:n,channelNum:o}):(r?.log?.("[AutoDetect] Detected regular camera (single channel)"),await A.close(),{type:"camera",transport:"tcp",uid:s||"",deviceInfo:n,channelNum:1})}catch(n){if(A)try{await A.close()}catch{}if(!function(e){const t=e?.message||e?.toString?.()||"";return"string"==typeof t&&(t.includes("ECONNREFUSED")||t.includes("ETIMEDOUT")||t.includes("EHOSTUNREACH")||t.includes("ENETUNREACH")||t.includes("socket hang up")||t.includes("TCP connection timeout")||t.includes("Baichuan socket closed"))}(n))throw n;r?.log?.("[AutoDetect] TCP failed, trying UDP (battery camera)...");const i=st(s);if(!i)throw new Error(`TCP connection failed and device likely requires UDP/BCUDP. UID is required for battery cameras (ip=${t}).`);try{const t=nt({...e,uid:i},"udp");await t.login();const s=await t.getInfo(),n=await t.getDeviceCapabilities(),A=n?.support?.channelNum??1,o=s.type?.trim(),a=o?o.trim():void 0;return!!a&&Pe.has(a)?(r?.log?.(`[AutoDetect] UDP connection successful. Detected multi-focal device (model: ${a}, channelNum=${A}).`),await t.close(),{type:"multifocal",transport:"udp",uid:i,deviceInfo:s,channelNum:A}):(r?.log?.("[AutoDetect] UDP connection successful. Detected battery camera."),await t.close(),{type:"battery-cam",transport:"udp",uid:i,deviceInfo:s,channelNum:1})}catch(e){throw r?.log?.(`[AutoDetect] Both TCP and UDP failed. TCP error: ${n}, UDP error: ${e}`),new Error(`Failed to connect via both TCP and UDP. TCP: ${n?.message||n}, UDP: ${e?.message||e}`)}}}}},t={};function s(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={id:n,loaded:!1,exports:{}};return e[n].call(i.exports,i,i.exports,s),i.loaded=!0,i.exports}s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var n=s(7927),r=exports="undefined"==typeof exports?{}:exports;for(var i in n)r[i]=n[i];n.__esModule&&Object.defineProperty(r,"__esModule",{value:!0})})();
|
|
2
|
+
(()=>{var e={9038:(e,t,s)=>{"use strict";const r=s(1167),n=s(5497),i=s(8542),A=s(8055),o=s(3315),a=s(9246),c=s(4667),l=s(8712),h=s(8297),g=s(4465),d=s(2858),{InvalidArgumentError:u}=g,E=s(9713),I=s(1986),p=s(615),{MockCallHistory:C,MockCallHistoryLog:B}=s(4969),f=s(7467),Q=s(5846),m=s(1313),y=s(3123),w=s(6294),{getGlobalDispatcher:S,setGlobalDispatcher:D}=s(9879),b=s(6917),v=s(8064);Object.assign(n.prototype,E),e.exports.g6=o,s(5132),s(2936),s(532),s(3562),s(6677),s(5752),s(4951),s(9903);function R(e){return(t,s,r)=>{if("function"==typeof s&&(r=s,s=null),!t||"string"!=typeof t&&"object"!=typeof t&&!(t instanceof URL))throw new u("invalid url");if(null!=s&&"object"!=typeof s)throw new u("invalid opts");if(s&&null!=s.path){if("string"!=typeof s.path)throw new u("invalid opts.path");let e=s.path;s.path.startsWith("/")||(e=`/${e}`),t=new URL(d.parseOrigin(t).origin+e)}else s||(s="object"==typeof t?t:{}),t=d.parseURL(t);const{agent:n,dispatcher:i=S()}=s;if(n)throw new u("unsupported opts.agent. Did you mean opts.client?");return e.call(i,{...s,origin:t.origin,path:t.search?`${t.pathname}${t.search}`:t.pathname,method:s.method||(s.body?"PUT":"GET")},r)}}s(2636),d.parseHeaders,d.headerNameToString;const N=s(7388).fetch;e.exports.hd=function(e,t=void 0){return N(e,t).catch((e=>{throw e&&"object"==typeof e&&Error.captureStackTrace(e),e}))},e.exports.Headers=s(6558).Headers,e.exports.Response=s(4821).Response,e.exports.Request=s(4609).Request,e.exports.FormData=s(3944).FormData;const{setGlobalOrigin:k,getGlobalOrigin:T}=s(2837);const{CacheStorage:F}=s(6939),{kConstruct:M}=s(257);new F(M);const{deleteCookie:U,getCookies:L,getSetCookies:P,setCookie:x,parseCookie:H}=s(9391);const{parseMIMEType:Y,serializeAMimeType:V}=s(9934);const{CloseEvent:O,ErrorEvent:G,MessageEvent:J}=s(878),{WebSocket:W,ping:_}=s(2984);e.exports.kb=W,e.exports.rd=O,e.exports.NN=G,e.exports.aM=J,s(27).WebSocketStream,s(7053).WebSocketError,R(E.request),R(E.stream),R(E.pipeline),R(E.connect),R(E.upgrade);const{EventSource:$}=s(7928);e.exports.GD=$},3904:(e,t,s)=>{"use strict";const{addAbortListener:r}=s(2858),{RequestAbortedError:n}=s(4465),i=Symbol("kListener"),A=Symbol("kSignal");function o(e){e.abort?e.abort(e[A]?.reason):e.reason=e[A]?.reason??new n,a(e)}function a(e){e[A]&&("removeEventListener"in e[A]?e[A].removeEventListener("abort",e[i]):e[A].removeListener("abort",e[i]),e[A]=null,e[i]=null)}e.exports={addSignal:function(e,t){e.reason=null,e[A]=null,e[i]=null,t&&(t.aborted?o(e):(e[A]=t,e[i]=()=>{o(e)},r(e[A],e[i])))},removeSignal:a}},3102:(e,t,s)=>{"use strict";const r=s(4589),{AsyncResource:n}=s(6698),{InvalidArgumentError:i,SocketError:A}=s(4465),o=s(2858),{addSignal:a,removeSignal:c}=s(3904);class l extends n{constructor(e,t){if(!e||"object"!=typeof e)throw new i("invalid opts");if("function"!=typeof t)throw new i("invalid callback");const{signal:s,opaque:r,responseHeaders:n}=e;if(s&&"function"!=typeof s.on&&"function"!=typeof s.addEventListener)throw new i("signal must be an EventEmitter or EventTarget");super("UNDICI_CONNECT"),this.opaque=r||null,this.responseHeaders=n||null,this.callback=t,this.abort=null,a(this,s)}onConnect(e,t){this.reason?e(this.reason):(r(this.callback),this.abort=e,this.context=t)}onHeaders(){throw new A("bad connect",null)}onUpgrade(e,t,s){const{callback:r,opaque:n,context:i}=this;c(this),this.callback=null;let A=t;null!=A&&(A="raw"===this.responseHeaders?o.parseRawHeaders(t):o.parseHeaders(t)),this.runInAsyncScope(r,null,null,{statusCode:e,headers:A,socket:s,opaque:n,context:i})}onError(e){const{callback:t,opaque:s}=this;c(this),t&&(this.callback=null,queueMicrotask((()=>{this.runInAsyncScope(t,null,e,{opaque:s})})))}}e.exports=function e(t,s){if(void 0===s)return new Promise(((s,r)=>{e.call(this,t,((e,t)=>e?r(e):s(t)))}));try{const e=new l(t,s),r={...t,method:"CONNECT"};this.dispatch(r,e)}catch(e){if("function"!=typeof s)throw e;const r=t?.opaque;queueMicrotask((()=>s(e,{opaque:r})))}}},8660:(e,t,s)=>{"use strict";const{Readable:r,Duplex:n,PassThrough:i}=s(7075),A=s(4589),{AsyncResource:o}=s(6698),{InvalidArgumentError:a,InvalidReturnValueError:c,RequestAbortedError:l}=s(4465),h=s(2858),{addSignal:g,removeSignal:d}=s(3904);function u(){}const E=Symbol("resume");class I extends r{constructor(){super({autoDestroy:!0}),this[E]=null}_read(){const{[E]:e}=this;e&&(this[E]=null,e())}_destroy(e,t){this._read(),t(e)}}class p extends r{constructor(e){super({autoDestroy:!0}),this[E]=e}_read(){this[E]()}_destroy(e,t){e||this._readableState.endEmitted||(e=new l),t(e)}}class C extends o{constructor(e,t){if(!e||"object"!=typeof e)throw new a("invalid opts");if("function"!=typeof t)throw new a("invalid handler");const{signal:s,method:r,opaque:i,onInfo:A,responseHeaders:o}=e;if(s&&"function"!=typeof s.on&&"function"!=typeof s.addEventListener)throw new a("signal must be an EventEmitter or EventTarget");if("CONNECT"===r)throw new a("invalid method");if(A&&"function"!=typeof A)throw new a("invalid onInfo callback");super("UNDICI_PIPELINE"),this.opaque=i||null,this.responseHeaders=o||null,this.handler=t,this.abort=null,this.context=null,this.onInfo=A||null,this.req=(new I).on("error",u),this.ret=new n({readableObjectMode:e.objectMode,autoDestroy:!0,read:()=>{const{body:e}=this;e?.resume&&e.resume()},write:(e,t,s)=>{const{req:r}=this;r.push(e,t)||r._readableState.destroyed?s():r[E]=s},destroy:(e,t)=>{const{body:s,req:r,res:n,ret:i,abort:A}=this;e||i._readableState.endEmitted||(e=new l),A&&e&&A(),h.destroy(s,e),h.destroy(r,e),h.destroy(n,e),d(this),t(e)}}).on("prefinish",(()=>{const{req:e}=this;e.push(null)})),this.res=null,g(this,s)}onConnect(e,t){const{res:s}=this;this.reason?e(this.reason):(A(!s,"pipeline cannot be retried"),this.abort=e,this.context=t)}onHeaders(e,t,s){const{opaque:r,handler:n,context:i}=this;if(e<200){if(this.onInfo){const s="raw"===this.responseHeaders?h.parseRawHeaders(t):h.parseHeaders(t);this.onInfo({statusCode:e,headers:s})}return}let A;this.res=new p(s);try{this.handler=null;const s="raw"===this.responseHeaders?h.parseRawHeaders(t):h.parseHeaders(t);A=this.runInAsyncScope(n,null,{statusCode:e,headers:s,opaque:r,body:this.res,context:i})}catch(e){throw this.res.on("error",u),e}if(!A||"function"!=typeof A.on)throw new c("expected Readable");A.on("data",(e=>{const{ret:t,body:s}=this;!t.push(e)&&s.pause&&s.pause()})).on("error",(e=>{const{ret:t}=this;h.destroy(t,e)})).on("end",(()=>{const{ret:e}=this;e.push(null)})).on("close",(()=>{const{ret:e}=this;e._readableState.ended||h.destroy(e,new l)})),this.body=A}onData(e){const{res:t}=this;return t.push(e)}onComplete(e){const{res:t}=this;t.push(null)}onError(e){const{ret:t}=this;this.handler=null,h.destroy(t,e)}}e.exports=function(e,t){try{const s=new C(e,t);return this.dispatch({...e,body:s.req},s),s.ret}catch(e){return(new i).destroy(e)}}},7745:(e,t,s)=>{"use strict";const r=s(4589),{AsyncResource:n}=s(6698),{Readable:i}=s(777),{InvalidArgumentError:A,RequestAbortedError:o}=s(4465),a=s(2858);function c(){}class l extends n{constructor(e,t){if(!e||"object"!=typeof e)throw new A("invalid opts");const{signal:s,method:r,opaque:n,body:i,onInfo:l,responseHeaders:h,highWaterMark:g}=e;try{if("function"!=typeof t)throw new A("invalid callback");if(g&&("number"!=typeof g||g<0))throw new A("invalid highWaterMark");if(s&&"function"!=typeof s.on&&"function"!=typeof s.addEventListener)throw new A("signal must be an EventEmitter or EventTarget");if("CONNECT"===r)throw new A("invalid method");if(l&&"function"!=typeof l)throw new A("invalid onInfo callback");super("UNDICI_REQUEST")}catch(e){throw a.isStream(i)&&a.destroy(i.on("error",c),e),e}this.method=r,this.responseHeaders=h||null,this.opaque=n||null,this.callback=t,this.res=null,this.abort=null,this.body=i,this.trailers={},this.context=null,this.onInfo=l||null,this.highWaterMark=g,this.reason=null,this.removeAbortListener=null,s?.aborted?this.reason=s.reason??new o:s&&(this.removeAbortListener=a.addAbortListener(s,(()=>{this.reason=s.reason??new o,this.res?a.destroy(this.res.on("error",c),this.reason):this.abort&&this.abort(this.reason)})))}onConnect(e,t){this.reason?e(this.reason):(r(this.callback),this.abort=e,this.context=t)}onHeaders(e,t,s,r){const{callback:n,opaque:A,abort:o,context:l,responseHeaders:h,highWaterMark:g}=this,d="raw"===h?a.parseRawHeaders(t):a.parseHeaders(t);if(e<200)return void(this.onInfo&&this.onInfo({statusCode:e,headers:d}));const u="raw"===h?a.parseHeaders(t):d,E=u["content-type"],I=u["content-length"],p=new i({resume:s,abort:o,contentType:E,contentLength:"HEAD"!==this.method&&I?Number(I):null,highWaterMark:g});if(this.removeAbortListener&&(p.on("close",this.removeAbortListener),this.removeAbortListener=null),this.callback=null,this.res=p,null!==n)try{this.runInAsyncScope(n,null,null,{statusCode:e,headers:d,trailers:this.trailers,opaque:A,body:p,context:l})}catch(e){this.res=null,a.destroy(p.on("error",c),e),queueMicrotask((()=>{throw e}))}}onData(e){return this.res.push(e)}onComplete(e){a.parseHeaders(e,this.trailers),this.res.push(null)}onError(e){const{res:t,callback:s,body:r,opaque:n}=this;s&&(this.callback=null,queueMicrotask((()=>{this.runInAsyncScope(s,null,e,{opaque:n})}))),t&&(this.res=null,queueMicrotask((()=>{a.destroy(t.on("error",c),e)}))),r&&(this.body=null,a.isStream(r)&&(r.on("error",c),a.destroy(r,e))),this.removeAbortListener&&(this.removeAbortListener(),this.removeAbortListener=null)}}e.exports=function e(t,s){if(void 0===s)return new Promise(((s,r)=>{e.call(this,t,((e,t)=>e?r(e):s(t)))}));try{const e=new l(t,s);this.dispatch(t,e)}catch(e){if("function"!=typeof s)throw e;const r=t?.opaque;queueMicrotask((()=>s(e,{opaque:r})))}},e.exports.RequestHandler=l},322:(e,t,s)=>{"use strict";const r=s(4589),{finished:n}=s(7075),{AsyncResource:i}=s(6698),{InvalidArgumentError:A,InvalidReturnValueError:o}=s(4465),a=s(2858),{addSignal:c,removeSignal:l}=s(3904);function h(){}class g extends i{constructor(e,t,s){if(!e||"object"!=typeof e)throw new A("invalid opts");const{signal:r,method:n,opaque:i,body:o,onInfo:l,responseHeaders:g}=e;try{if("function"!=typeof s)throw new A("invalid callback");if("function"!=typeof t)throw new A("invalid factory");if(r&&"function"!=typeof r.on&&"function"!=typeof r.addEventListener)throw new A("signal must be an EventEmitter or EventTarget");if("CONNECT"===n)throw new A("invalid method");if(l&&"function"!=typeof l)throw new A("invalid onInfo callback");super("UNDICI_STREAM")}catch(e){throw a.isStream(o)&&a.destroy(o.on("error",h),e),e}this.responseHeaders=g||null,this.opaque=i||null,this.factory=t,this.callback=s,this.res=null,this.abort=null,this.context=null,this.trailers=null,this.body=o,this.onInfo=l||null,a.isStream(o)&&o.on("error",(e=>{this.onError(e)})),c(this,r)}onConnect(e,t){this.reason?e(this.reason):(r(this.callback),this.abort=e,this.context=t)}onHeaders(e,t,s,r){const{factory:i,opaque:A,context:c,responseHeaders:l}=this,h="raw"===l?a.parseRawHeaders(t):a.parseHeaders(t);if(e<200)return void(this.onInfo&&this.onInfo({statusCode:e,headers:h}));if(this.factory=null,null===i)return;const g=this.runInAsyncScope(i,null,{statusCode:e,headers:h,opaque:A,context:c});if(!g||"function"!=typeof g.write||"function"!=typeof g.end||"function"!=typeof g.on)throw new o("expected Writable");n(g,{readable:!1},(e=>{const{callback:t,res:s,opaque:r,trailers:n,abort:i}=this;this.res=null,!e&&s?.readable||a.destroy(s,e),this.callback=null,this.runInAsyncScope(t,null,e||null,{opaque:r,trailers:n}),e&&i()})),g.on("drain",s),this.res=g;return!0!==(void 0!==g.writableNeedDrain?g.writableNeedDrain:g._writableState?.needDrain)}onData(e){const{res:t}=this;return!t||t.write(e)}onComplete(e){const{res:t}=this;l(this),t&&(this.trailers=a.parseHeaders(e),t.end())}onError(e){const{res:t,callback:s,opaque:r,body:n}=this;l(this),this.factory=null,t?(this.res=null,a.destroy(t,e)):s&&(this.callback=null,queueMicrotask((()=>{this.runInAsyncScope(s,null,e,{opaque:r})}))),n&&(this.body=null,a.destroy(n,e))}}e.exports=function e(t,s,r){if(void 0===r)return new Promise(((r,n)=>{e.call(this,t,s,((e,t)=>e?n(e):r(t)))}));try{const e=new g(t,s,r);this.dispatch(t,e)}catch(e){if("function"!=typeof r)throw e;const s=t?.opaque;queueMicrotask((()=>r(e,{opaque:s})))}}},3936:(e,t,s)=>{"use strict";const{InvalidArgumentError:r,SocketError:n}=s(4465),{AsyncResource:i}=s(6698),A=s(4589),o=s(2858),{addSignal:a,removeSignal:c}=s(3904);class l extends i{constructor(e,t){if(!e||"object"!=typeof e)throw new r("invalid opts");if("function"!=typeof t)throw new r("invalid callback");const{signal:s,opaque:n,responseHeaders:i}=e;if(s&&"function"!=typeof s.on&&"function"!=typeof s.addEventListener)throw new r("signal must be an EventEmitter or EventTarget");super("UNDICI_UPGRADE"),this.responseHeaders=i||null,this.opaque=n||null,this.callback=t,this.abort=null,this.context=null,a(this,s)}onConnect(e,t){this.reason?e(this.reason):(A(this.callback),this.abort=e,this.context=null)}onHeaders(){throw new n("bad upgrade",null)}onUpgrade(e,t,s){A(101===e);const{callback:r,opaque:n,context:i}=this;c(this),this.callback=null;const a="raw"===this.responseHeaders?o.parseRawHeaders(t):o.parseHeaders(t);this.runInAsyncScope(r,null,null,{headers:a,socket:s,opaque:n,context:i})}onError(e){const{callback:t,opaque:s}=this;c(this),t&&(this.callback=null,queueMicrotask((()=>{this.runInAsyncScope(t,null,e,{opaque:s})})))}}e.exports=function e(t,s){if(void 0===s)return new Promise(((s,r)=>{e.call(this,t,((e,t)=>e?r(e):s(t)))}));try{const e=new l(t,s),r={...t,method:t.method||"GET",upgrade:t.protocol||"Websocket"};this.dispatch(r,e)}catch(e){if("function"!=typeof s)throw e;const r=t?.opaque;queueMicrotask((()=>s(e,{opaque:r})))}}},9713:(e,t,s)=>{"use strict";e.exports.request=s(7745),e.exports.stream=s(322),e.exports.pipeline=s(8660),e.exports.upgrade=s(3936),e.exports.connect=s(3102)},777:(e,t,s)=>{"use strict";const r=s(4589),{Readable:n}=s(7075),{RequestAbortedError:i,NotSupportedError:A,InvalidArgumentError:o,AbortError:a}=s(4465),c=s(2858),{ReadableStreamFrom:l}=s(2858),h=Symbol("kConsume"),g=Symbol("kReading"),d=Symbol("kBody"),u=Symbol("kAbort"),E=Symbol("kContentType"),I=Symbol("kContentLength"),p=Symbol("kUsed"),C=Symbol("kBytesRead"),B=()=>{};function f(e){return c.isDisturbed(e)||function(e){return!0===e[d]?.locked||null!==e[h]}(e)}function Q(e,t){return r(!e[h]),new Promise(((s,r)=>{if(f(e)){const t=e._readableState;t.destroyed&&!1===t.closeEmitted?e.on("error",r).on("close",(()=>{r(new TypeError("unusable"))})):r(t.errored??new TypeError("unusable"))}else queueMicrotask((()=>{e[h]={type:t,stream:e,resolve:s,reject:r,length:0,body:[]},e.on("error",(function(e){D(this[h],e)})).on("close",(function(){null!==this[h].body&&D(this[h],new i)})),function(e){if(null===e.body)return;const{_readableState:t}=e.stream;if(t.bufferIndex){const s=t.bufferIndex,r=t.buffer.length;for(let n=s;n<r;n++)S(e,t.buffer[n])}else for(const s of t.buffer)S(e,s);t.endEmitted?w(this[h],this._readableState.encoding):e.stream.on("end",(function(){w(this[h],this._readableState.encoding)}));e.stream.resume();for(;null!=e.stream.read(););}(e[h])}))}))}function m(e,t,s){if(0===e.length||0===t)return"";const r=1===e.length?e[0]:Buffer.concat(e,t),n=r.length,i=n>2&&239===r[0]&&187===r[1]&&191===r[2]?3:0;return s&&"utf8"!==s&&"utf-8"!==s?r.subarray(i,n).toString(s):r.utf8Slice(i,n)}function y(e,t){if(0===e.length||0===t)return new Uint8Array(0);if(1===e.length)return new Uint8Array(e[0]);const s=new Uint8Array(Buffer.allocUnsafeSlow(t).buffer);let r=0;for(let t=0;t<e.length;++t){const n=e[t];s.set(n,r),r+=n.length}return s}function w(e,t){const{type:s,body:r,resolve:n,stream:i,length:A}=e;try{"text"===s?n(m(r,A,t)):"json"===s?n(JSON.parse(m(r,A,t))):"arrayBuffer"===s?n(y(r,A).buffer):"blob"===s?n(new Blob(r,{type:i[E]})):"bytes"===s&&n(y(r,A)),D(e)}catch(e){i.destroy(e)}}function S(e,t){e.length+=t.length,e.body.push(t)}function D(e,t){null!==e.body&&(t?e.reject(t):e.resolve(),e.type=null,e.stream=null,e.resolve=null,e.reject=null,e.length=0,e.body=null)}e.exports={Readable:class extends n{constructor({resume:e,abort:t,contentType:s="",contentLength:r,highWaterMark:n=65536}){super({autoDestroy:!0,read:e,highWaterMark:n}),this._readableState.dataEmitted=!1,this[u]=t,this[h]=null,this[C]=0,this[d]=null,this[p]=!1,this[E]=s,this[I]=Number.isFinite(r)?r:null,this[g]=!1}_destroy(e,t){e||this._readableState.endEmitted||(e=new i),e&&this[u](),this[p]?t(e):setImmediate(t,e)}on(e,t){return"data"!==e&&"readable"!==e||(this[g]=!0,this[p]=!0),super.on(e,t)}addListener(e,t){return this.on(e,t)}off(e,t){const s=super.off(e,t);return"data"!==e&&"readable"!==e||(this[g]=this.listenerCount("data")>0||this.listenerCount("readable")>0),s}removeListener(e,t){return this.off(e,t)}push(e){return e&&(this[C]+=e.length,this[h])?(S(this[h],e),!this[g]||super.push(e)):super.push(e)}text(){return Q(this,"text")}json(){return Q(this,"json")}blob(){return Q(this,"blob")}bytes(){return Q(this,"bytes")}arrayBuffer(){return Q(this,"arrayBuffer")}async formData(){throw new A}get bodyUsed(){return c.isDisturbed(this)}get body(){return this[d]||(this[d]=l(this),this[h]&&(this[d].getReader(),r(this[d].locked))),this[d]}dump(e){const t=e?.signal;if(null!=t&&("object"!=typeof t||!("aborted"in t)))return Promise.reject(new o("signal must be an AbortSignal"));const s=e?.limit&&Number.isFinite(e.limit)?e.limit:131072;return t?.aborted?Promise.reject(t.reason??new a):this._readableState.closeEmitted?Promise.resolve(null):new Promise(((e,r)=>{if((this[I]&&this[I]>s||this[C]>s)&&this.destroy(new a),t){const s=()=>{this.destroy(t.reason??new a)};t.addEventListener("abort",s),this.on("close",(function(){t.removeEventListener("abort",s),t.aborted?r(t.reason??new a):e(null)}))}else this.on("close",e);this.on("error",B).on("data",(()=>{this[C]>s&&this.destroy()})).resume()}))}setEncoding(e){return Buffer.isEncoding(e)&&(this._readableState.encoding=e),this}},chunksDecode:m}},9903:(e,t,s)=>{"use strict";const{Writable:r}=s(7075),{EventEmitter:n}=s(8474),{assertCacheKey:i,assertCacheValue:A}=s(9453);function o(e,t,s){return t.find((t=>t.deleteAt>s&&t.method===e.method&&(null==t.vary||Object.keys(t.vary).every((s=>null===t.vary[s]?void 0===e.headers[s]:t.vary[s]===e.headers[s])))))}e.exports=class extends n{#e=1024;#t=104857600;#s=5242880;#r=0;#n=0;#i=new Map;#A=!1;constructor(e){if(super(),e){if("object"!=typeof e)throw new TypeError("MemoryCacheStore options must be an object");if(void 0!==e.maxCount){if("number"!=typeof e.maxCount||!Number.isInteger(e.maxCount)||e.maxCount<0)throw new TypeError("MemoryCacheStore options.maxCount must be a non-negative integer");this.#e=e.maxCount}if(void 0!==e.maxSize){if("number"!=typeof e.maxSize||!Number.isInteger(e.maxSize)||e.maxSize<0)throw new TypeError("MemoryCacheStore options.maxSize must be a non-negative integer");this.#t=e.maxSize}if(void 0!==e.maxEntrySize){if("number"!=typeof e.maxEntrySize||!Number.isInteger(e.maxEntrySize)||e.maxEntrySize<0)throw new TypeError("MemoryCacheStore options.maxEntrySize must be a non-negative integer");this.#s=e.maxEntrySize}}}get size(){return this.#r}isFull(){return this.#r>=this.#t||this.#n>=this.#e}get(e){i(e);const t=`${e.origin}:${e.path}`,s=Date.now(),r=this.#i.get(t),n=r?o(e,r,s):null;return null==n?void 0:{statusMessage:n.statusMessage,statusCode:n.statusCode,headers:n.headers,body:n.body,vary:n.vary?n.vary:void 0,etag:n.etag,cacheControlDirectives:n.cacheControlDirectives,cachedAt:n.cachedAt,staleAt:n.staleAt,deleteAt:n.deleteAt}}createWriteStream(e,t){i(e),A(t);const s=`${e.origin}:${e.path}`,n=this,a={...e,...t,body:[],size:0};return new r({write(e,t,s){"string"==typeof e&&(e=Buffer.from(e,t)),a.size+=e.byteLength,a.size>=n.#s?this.destroy():a.body.push(e),s(null)},final(t){let r=n.#i.get(s);r||(r=[],n.#i.set(s,r));const i=o(e,r,Date.now());if(i){const e=r.indexOf(i);r.splice(e,1,a),n.#r-=i.size}else r.push(a),n.#n+=1;if(n.#r+=a.size,n.#r>n.#t||n.#n>n.#e){n.#A||(n.emit("maxSizeExceeded",{size:n.#r,maxSize:n.#t,count:n.#n,maxCount:n.#e}),n.#A=!0);for(const[e,t]of n.#i){for(const e of t.splice(0,t.length/2))n.#r-=e.size,n.#n-=1;0===t.length&&n.#i.delete(e)}n.#r<n.#t&&n.#n<n.#e&&(n.#A=!1)}t(null)}})}delete(e){if("object"!=typeof e)throw new TypeError("expected key to be object, got "+typeof e);const t=`${e.origin}:${e.path}`;for(const e of this.#i.get(t)??[])this.#r-=e.size,this.#n-=1;this.#i.delete(t)}}},2636:(e,t,s)=>{"use strict";const{Writable:r}=s(7075),{assertCacheKey:n,assertCacheValue:i}=s(9453);let A;const o=2e9;function a(e,t){return null==e&&null==t||!(null==e&&null!=t||null!=e&&null==t)&&(Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every(((e,s)=>e===t[s])):e===t)}e.exports=class{#s=o;#e=1/0;#o;#a;#c;#l;#h;#g;#d;#u;constructor(e){if(e){if("object"!=typeof e)throw new TypeError("SqliteCacheStore options must be an object");if(void 0!==e.maxEntrySize){if("number"!=typeof e.maxEntrySize||!Number.isInteger(e.maxEntrySize)||e.maxEntrySize<0)throw new TypeError("SqliteCacheStore options.maxEntrySize must be a non-negative integer");if(e.maxEntrySize>o)throw new TypeError("SqliteCacheStore options.maxEntrySize must be less than 2gb");this.#s=e.maxEntrySize}if(void 0!==e.maxCount){if("number"!=typeof e.maxCount||!Number.isInteger(e.maxCount)||e.maxCount<0)throw new TypeError("SqliteCacheStore options.maxCount must be a non-negative integer");this.#e=e.maxCount}}A||(A=s(99).DatabaseSync),this.#o=new A(e?.location??":memory:"),this.#o.exec("\n PRAGMA journal_mode = WAL;\n PRAGMA synchronous = NORMAL;\n PRAGMA temp_store = memory;\n PRAGMA optimize;\n\n CREATE TABLE IF NOT EXISTS cacheInterceptorV3 (\n -- Data specific to us\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n url TEXT NOT NULL,\n method TEXT NOT NULL,\n\n -- Data returned to the interceptor\n body BUF NULL,\n deleteAt INTEGER NOT NULL,\n statusCode INTEGER NOT NULL,\n statusMessage TEXT NOT NULL,\n headers TEXT NULL,\n cacheControlDirectives TEXT NULL,\n etag TEXT NULL,\n vary TEXT NULL,\n cachedAt INTEGER NOT NULL,\n staleAt INTEGER NOT NULL\n );\n\n CREATE INDEX IF NOT EXISTS idx_cacheInterceptorV3_getValuesQuery ON cacheInterceptorV3(url, method, deleteAt);\n CREATE INDEX IF NOT EXISTS idx_cacheInterceptorV3_deleteByUrlQuery ON cacheInterceptorV3(deleteAt);\n "),this.#a=this.#o.prepare("\n SELECT\n id,\n body,\n deleteAt,\n statusCode,\n statusMessage,\n headers,\n etag,\n cacheControlDirectives,\n vary,\n cachedAt,\n staleAt\n FROM cacheInterceptorV3\n WHERE\n url = ?\n AND method = ?\n ORDER BY\n deleteAt ASC\n "),this.#c=this.#o.prepare("\n UPDATE cacheInterceptorV3 SET\n body = ?,\n deleteAt = ?,\n statusCode = ?,\n statusMessage = ?,\n headers = ?,\n etag = ?,\n cacheControlDirectives = ?,\n cachedAt = ?,\n staleAt = ?\n WHERE\n id = ?\n "),this.#l=this.#o.prepare("\n INSERT INTO cacheInterceptorV3 (\n url,\n method,\n body,\n deleteAt,\n statusCode,\n statusMessage,\n headers,\n etag,\n cacheControlDirectives,\n vary,\n cachedAt,\n staleAt\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n "),this.#g=this.#o.prepare("DELETE FROM cacheInterceptorV3 WHERE url = ?"),this.#d=this.#o.prepare("SELECT COUNT(*) AS total FROM cacheInterceptorV3"),this.#h=this.#o.prepare("DELETE FROM cacheInterceptorV3 WHERE deleteAt <= ?"),this.#u=this.#e===1/0?null:this.#o.prepare("\n DELETE FROM cacheInterceptorV3\n WHERE id IN (\n SELECT\n id\n FROM cacheInterceptorV3\n ORDER BY cachedAt DESC\n LIMIT ?\n )\n ")}close(){this.#o.close()}get(e){n(e);const t=this.#E(e);return t?{body:t.body?Buffer.from(t.body.buffer,t.body.byteOffset,t.body.byteLength):void 0,statusCode:t.statusCode,statusMessage:t.statusMessage,headers:t.headers?JSON.parse(t.headers):void 0,etag:t.etag?t.etag:void 0,vary:t.vary?JSON.parse(t.vary):void 0,cacheControlDirectives:t.cacheControlDirectives?JSON.parse(t.cacheControlDirectives):void 0,cachedAt:t.cachedAt,staleAt:t.staleAt,deleteAt:t.deleteAt}:void 0}set(e,t){n(e);const s=this.#I(e),r=Array.isArray(t.body)?Buffer.concat(t.body):t.body,i=r?.byteLength;if(i&&i>this.#s)return;const A=this.#E(e,!0);A?this.#c.run(r,t.deleteAt,t.statusCode,t.statusMessage,t.headers?JSON.stringify(t.headers):null,t.etag?t.etag:null,t.cacheControlDirectives?JSON.stringify(t.cacheControlDirectives):null,t.cachedAt,t.staleAt,A.id):(this.#p(),this.#l.run(s,e.method,r,t.deleteAt,t.statusCode,t.statusMessage,t.headers?JSON.stringify(t.headers):null,t.etag?t.etag:null,t.cacheControlDirectives?JSON.stringify(t.cacheControlDirectives):null,t.vary?JSON.stringify(t.vary):null,t.cachedAt,t.staleAt))}createWriteStream(e,t){n(e),i(t);let s=0;const A=[],o=this;return new r({decodeStrings:!0,write(e,t,r){s+=e.byteLength,s<o.#s?A.push(e):this.destroy(),r()},final(s){o.set(e,{...t,body:A}),s()}})}delete(e){if("object"!=typeof e)throw new TypeError("expected key to be object, got "+typeof e);this.#g.run(this.#I(e))}#p(){if(Number.isFinite(this.#e)&&this.size<=this.#e)return 0;{const e=this.#h.run(Date.now()).changes;if(e)return e}{const e=this.#u?.run(Math.max(Math.floor(.1*this.#e),1)).changes;if(e)return e}return 0}get size(){const{total:e}=this.#d.get();return e}#I(e){return`${e.origin}/${e.path}`}#E(e,t=!1){const s=this.#I(e),{headers:r,method:n}=e,i=this.#a.all(s,n);if(0===i.length)return;const A=Date.now();for(const e of i){if(A>=e.deleteAt&&!t)return;let s=!0;if(e.vary){const t=JSON.parse(e.vary);for(const e in t)if(!a(r[e],t[e])){s=!1;break}}if(s)return e}}}},1986:(e,t,s)=>{"use strict";const r=s(7030),n=s(4589),i=s(2858),{InvalidArgumentError:A}=s(4465);let o;const a=class{constructor(e){this._maxCachedSessions=e,this._sessionCache=new Map,this._sessionRegistry=new FinalizationRegistry((e=>{if(this._sessionCache.size<this._maxCachedSessions)return;const t=this._sessionCache.get(e);void 0!==t&&void 0===t.deref()&&this._sessionCache.delete(e)}))}get(e){const t=this._sessionCache.get(e);return t?t.deref():null}set(e,t){0!==this._maxCachedSessions&&(this._sessionCache.set(e,new WeakRef(t)),this._sessionRegistry.register(t,e))}};e.exports=function({allowH2:e,maxCachedSessions:t,socketPath:c,timeout:l,session:h,...g}){if(null!=t&&(!Number.isInteger(t)||t<0))throw new A("maxCachedSessions must be a positive integer or zero");const d={path:c,...g},u=new a(null==t?100:t);return l=null==l?1e4:l,e=null!=e&&e,function({hostname:t,host:A,protocol:a,port:c,servername:g,localAddress:E,httpSocket:I},p){let C;if("https:"===a){o||(o=s(1692));const r=(g=g||d.servername||i.getServerName(A)||null)||t;n(r);const a=h||u.get(r)||null;c=c||443,C=o.connect({highWaterMark:16384,...d,servername:g,session:a,localAddress:E,ALPNProtocols:e?["http/1.1","h2"]:["http/1.1"],socket:I,port:c,host:t}),C.on("session",(function(e){u.set(r,e)}))}else n(!I,"httpSocket can only be sent on TLS update"),c=c||80,C=r.connect({highWaterMark:65536,...d,localAddress:E,port:c,host:t});if(null==d.keepAlive||d.keepAlive){const e=void 0===d.keepAliveInitialDelay?6e4:d.keepAliveInitialDelay;C.setKeepAlive(!0,e)}const B=i.setupConnectTimeout(new WeakRef(C),{timeout:l,hostname:t,port:c});return C.setNoDelay(!0).once("https:"===a?"secureConnect":"connect",(function(){if(queueMicrotask(B),p){const e=p;p=null,e(null,this)}})).on("error",(function(e){if(queueMicrotask(B),p){const t=p;p=null,t(e)}})),C}}},9605:e=>{"use strict";const t=["Accept","Accept-Encoding","Accept-Language","Accept-Ranges","Access-Control-Allow-Credentials","Access-Control-Allow-Headers","Access-Control-Allow-Methods","Access-Control-Allow-Origin","Access-Control-Expose-Headers","Access-Control-Max-Age","Access-Control-Request-Headers","Access-Control-Request-Method","Age","Allow","Alt-Svc","Alt-Used","Authorization","Cache-Control","Clear-Site-Data","Connection","Content-Disposition","Content-Encoding","Content-Language","Content-Length","Content-Location","Content-Range","Content-Security-Policy","Content-Security-Policy-Report-Only","Content-Type","Cookie","Cross-Origin-Embedder-Policy","Cross-Origin-Opener-Policy","Cross-Origin-Resource-Policy","Date","Device-Memory","Downlink","ECT","ETag","Expect","Expect-CT","Expires","Forwarded","From","Host","If-Match","If-Modified-Since","If-None-Match","If-Range","If-Unmodified-Since","Keep-Alive","Last-Modified","Link","Location","Max-Forwards","Origin","Permissions-Policy","Pragma","Proxy-Authenticate","Proxy-Authorization","RTT","Range","Referer","Referrer-Policy","Refresh","Retry-After","Sec-WebSocket-Accept","Sec-WebSocket-Extensions","Sec-WebSocket-Key","Sec-WebSocket-Protocol","Sec-WebSocket-Version","Server","Server-Timing","Service-Worker-Allowed","Service-Worker-Navigation-Preload","Set-Cookie","SourceMap","Strict-Transport-Security","Supports-Loading-Mode","TE","Timing-Allow-Origin","Trailer","Transfer-Encoding","Upgrade","Upgrade-Insecure-Requests","User-Agent","Vary","Via","WWW-Authenticate","X-Content-Type-Options","X-DNS-Prefetch-Control","X-Frame-Options","X-Permitted-Cross-Domain-Policies","X-Powered-By","X-Requested-With","X-XSS-Protection"],s={};Object.setPrototypeOf(s,null);const r={};Object.setPrototypeOf(r,null);for(let e=0;e<t.length;++e){const r=t[e],n=r.toLowerCase();s[r]=s[n]=n}e.exports={wellknownHeaderNames:t,headerNameLowerCasedRecord:s,getHeaderNameAsBuffer:function(e){let t=r[e];return void 0===t&&(t=Buffer.from(e)),t}}},772:(e,t,s)=>{"use strict";const r=s(3053),n=s(7975),i=n.debuglog("undici"),A=n.debuglog("fetch"),o=n.debuglog("websocket"),a={beforeConnect:r.channel("undici:client:beforeConnect"),connected:r.channel("undici:client:connected"),connectError:r.channel("undici:client:connectError"),sendHeaders:r.channel("undici:client:sendHeaders"),create:r.channel("undici:request:create"),bodySent:r.channel("undici:request:bodySent"),bodyChunkSent:r.channel("undici:request:bodyChunkSent"),bodyChunkReceived:r.channel("undici:request:bodyChunkReceived"),headers:r.channel("undici:request:headers"),trailers:r.channel("undici:request:trailers"),error:r.channel("undici:request:error"),open:r.channel("undici:websocket:open"),close:r.channel("undici:websocket:close"),socketError:r.channel("undici:websocket:socket_error"),ping:r.channel("undici:websocket:ping"),pong:r.channel("undici:websocket:pong")};let c=!1;function l(e=i){c||(c=!0,r.subscribe("undici:client:beforeConnect",(t=>{const{connectParams:{version:s,protocol:r,port:n,host:i}}=t;e("connecting to %s%s using %s%s",i,n?`:${n}`:"",r,s)})),r.subscribe("undici:client:connected",(t=>{const{connectParams:{version:s,protocol:r,port:n,host:i}}=t;e("connected to %s%s using %s%s",i,n?`:${n}`:"",r,s)})),r.subscribe("undici:client:connectError",(t=>{const{connectParams:{version:s,protocol:r,port:n,host:i},error:A}=t;e("connection to %s%s using %s%s errored - %s",i,n?`:${n}`:"",r,s,A.message)})),r.subscribe("undici:client:sendHeaders",(t=>{const{request:{method:s,path:r,origin:n}}=t;e("sending request to %s %s%s",s,n,r)})))}let h=!1;let g=!1;(i.enabled||A.enabled)&&(l(A.enabled?A:i),function(e=i){h||(h=!0,r.subscribe("undici:request:headers",(t=>{const{request:{method:s,path:r,origin:n},response:{statusCode:i}}=t;e("received response to %s %s%s - HTTP %d",s,n,r,i)})),r.subscribe("undici:request:trailers",(t=>{const{request:{method:s,path:r,origin:n}}=t;e("trailers received from %s %s%s",s,n,r)})),r.subscribe("undici:request:error",(t=>{const{request:{method:s,path:r,origin:n},error:i}=t;e("request to %s %s%s errored - %s",s,n,r,i.message)})))}(A.enabled?A:i)),o.enabled&&(l(i.enabled?i:o),function(e=o){g||(g=!0,r.subscribe("undici:websocket:open",(t=>{const{address:{address:s,port:r}}=t;e("connection opened %s%s",s,r?`:${r}`:"")})),r.subscribe("undici:websocket:close",(t=>{const{websocket:s,code:r,reason:n}=t;e("closed connection to %s - %s %s",s.url,r,n)})),r.subscribe("undici:websocket:socket_error",(t=>{e("connection errored - %s",t.message)})),r.subscribe("undici:websocket:ping",(t=>{e("ping received")})),r.subscribe("undici:websocket:pong",(t=>{e("pong received")})))}(o)),e.exports={channels:a}},4465:e=>{"use strict";const t=Symbol.for("undici.error.UND_ERR");class s extends Error{constructor(e,t){super(e,t),this.name="UndiciError",this.code="UND_ERR"}static[Symbol.hasInstance](e){return e&&!0===e[t]}get[t](){return!0}}const r=Symbol.for("undici.error.UND_ERR_CONNECT_TIMEOUT");class n extends s{constructor(e){super(e),this.name="ConnectTimeoutError",this.message=e||"Connect Timeout Error",this.code="UND_ERR_CONNECT_TIMEOUT"}static[Symbol.hasInstance](e){return e&&!0===e[r]}get[r](){return!0}}const i=Symbol.for("undici.error.UND_ERR_HEADERS_TIMEOUT");class A extends s{constructor(e){super(e),this.name="HeadersTimeoutError",this.message=e||"Headers Timeout Error",this.code="UND_ERR_HEADERS_TIMEOUT"}static[Symbol.hasInstance](e){return e&&!0===e[i]}get[i](){return!0}}const o=Symbol.for("undici.error.UND_ERR_HEADERS_OVERFLOW");class a extends s{constructor(e){super(e),this.name="HeadersOverflowError",this.message=e||"Headers Overflow Error",this.code="UND_ERR_HEADERS_OVERFLOW"}static[Symbol.hasInstance](e){return e&&!0===e[o]}get[o](){return!0}}const c=Symbol.for("undici.error.UND_ERR_BODY_TIMEOUT");class l extends s{constructor(e){super(e),this.name="BodyTimeoutError",this.message=e||"Body Timeout Error",this.code="UND_ERR_BODY_TIMEOUT"}static[Symbol.hasInstance](e){return e&&!0===e[c]}get[c](){return!0}}const h=Symbol.for("undici.error.UND_ERR_INVALID_ARG");class g extends s{constructor(e){super(e),this.name="InvalidArgumentError",this.message=e||"Invalid Argument Error",this.code="UND_ERR_INVALID_ARG"}static[Symbol.hasInstance](e){return e&&!0===e[h]}get[h](){return!0}}const d=Symbol.for("undici.error.UND_ERR_INVALID_RETURN_VALUE");class u extends s{constructor(e){super(e),this.name="InvalidReturnValueError",this.message=e||"Invalid Return Value Error",this.code="UND_ERR_INVALID_RETURN_VALUE"}static[Symbol.hasInstance](e){return e&&!0===e[d]}get[d](){return!0}}const E=Symbol.for("undici.error.UND_ERR_ABORT");class I extends s{constructor(e){super(e),this.name="AbortError",this.message=e||"The operation was aborted",this.code="UND_ERR_ABORT"}static[Symbol.hasInstance](e){return e&&!0===e[E]}get[E](){return!0}}const p=Symbol.for("undici.error.UND_ERR_ABORTED");class C extends I{constructor(e){super(e),this.name="AbortError",this.message=e||"Request aborted",this.code="UND_ERR_ABORTED"}static[Symbol.hasInstance](e){return e&&!0===e[p]}get[p](){return!0}}const B=Symbol.for("undici.error.UND_ERR_INFO");class f extends s{constructor(e){super(e),this.name="InformationalError",this.message=e||"Request information",this.code="UND_ERR_INFO"}static[Symbol.hasInstance](e){return e&&!0===e[B]}get[B](){return!0}}const Q=Symbol.for("undici.error.UND_ERR_REQ_CONTENT_LENGTH_MISMATCH");class m extends s{constructor(e){super(e),this.name="RequestContentLengthMismatchError",this.message=e||"Request body length does not match content-length header",this.code="UND_ERR_REQ_CONTENT_LENGTH_MISMATCH"}static[Symbol.hasInstance](e){return e&&!0===e[Q]}get[Q](){return!0}}const y=Symbol.for("undici.error.UND_ERR_RES_CONTENT_LENGTH_MISMATCH");class w extends s{constructor(e){super(e),this.name="ResponseContentLengthMismatchError",this.message=e||"Response body length does not match content-length header",this.code="UND_ERR_RES_CONTENT_LENGTH_MISMATCH"}static[Symbol.hasInstance](e){return e&&!0===e[y]}get[y](){return!0}}const S=Symbol.for("undici.error.UND_ERR_DESTROYED");class D extends s{constructor(e){super(e),this.name="ClientDestroyedError",this.message=e||"The client is destroyed",this.code="UND_ERR_DESTROYED"}static[Symbol.hasInstance](e){return e&&!0===e[S]}get[S](){return!0}}const b=Symbol.for("undici.error.UND_ERR_CLOSED");class v extends s{constructor(e){super(e),this.name="ClientClosedError",this.message=e||"The client is closed",this.code="UND_ERR_CLOSED"}static[Symbol.hasInstance](e){return e&&!0===e[b]}get[b](){return!0}}const R=Symbol.for("undici.error.UND_ERR_SOCKET");class N extends s{constructor(e,t){super(e),this.name="SocketError",this.message=e||"Socket error",this.code="UND_ERR_SOCKET",this.socket=t}static[Symbol.hasInstance](e){return e&&!0===e[R]}get[R](){return!0}}const k=Symbol.for("undici.error.UND_ERR_NOT_SUPPORTED");class T extends s{constructor(e){super(e),this.name="NotSupportedError",this.message=e||"Not supported error",this.code="UND_ERR_NOT_SUPPORTED"}static[Symbol.hasInstance](e){return e&&!0===e[k]}get[k](){return!0}}const F=Symbol.for("undici.error.UND_ERR_BPL_MISSING_UPSTREAM");class M extends s{constructor(e){super(e),this.name="MissingUpstreamError",this.message=e||"No upstream has been added to the BalancedPool",this.code="UND_ERR_BPL_MISSING_UPSTREAM"}static[Symbol.hasInstance](e){return e&&!0===e[F]}get[F](){return!0}}const U=Symbol.for("undici.error.UND_ERR_HTTP_PARSER");class L extends Error{constructor(e,t,s){super(e),this.name="HTTPParserError",this.code=t?`HPE_${t}`:void 0,this.data=s?s.toString():void 0}static[Symbol.hasInstance](e){return e&&!0===e[U]}get[U](){return!0}}const P=Symbol.for("undici.error.UND_ERR_RES_EXCEEDED_MAX_SIZE");class x extends s{constructor(e){super(e),this.name="ResponseExceededMaxSizeError",this.message=e||"Response content exceeded max size",this.code="UND_ERR_RES_EXCEEDED_MAX_SIZE"}static[Symbol.hasInstance](e){return e&&!0===e[P]}get[P](){return!0}}const H=Symbol.for("undici.error.UND_ERR_REQ_RETRY");class Y extends s{constructor(e,t,{headers:s,data:r}){super(e),this.name="RequestRetryError",this.message=e||"Request retry error",this.code="UND_ERR_REQ_RETRY",this.statusCode=t,this.data=r,this.headers=s}static[Symbol.hasInstance](e){return e&&!0===e[H]}get[H](){return!0}}const V=Symbol.for("undici.error.UND_ERR_RESPONSE");class O extends s{constructor(e,t,{headers:s,body:r}){super(e),this.name="ResponseError",this.message=e||"Response error",this.code="UND_ERR_RESPONSE",this.statusCode=t,this.body=r,this.headers=s}static[Symbol.hasInstance](e){return e&&!0===e[V]}get[V](){return!0}}const G=Symbol.for("undici.error.UND_ERR_PRX_TLS");class J extends s{constructor(e,t,s={}){super(t,{cause:e,...s}),this.name="SecureProxyConnectionError",this.message=t||"Secure Proxy Connection failed",this.code="UND_ERR_PRX_TLS",this.cause=e}static[Symbol.hasInstance](e){return e&&!0===e[G]}get[G](){return!0}}const W=Symbol.for("undici.error.UND_ERR_MAX_ORIGINS_REACHED");class _ extends s{constructor(e){super(e),this.name="MaxOriginsReachedError",this.message=e||"Maximum allowed origins reached",this.code="UND_ERR_MAX_ORIGINS_REACHED"}static[Symbol.hasInstance](e){return e&&!0===e[W]}get[W](){return!0}}e.exports={AbortError:I,HTTPParserError:L,UndiciError:s,HeadersTimeoutError:A,HeadersOverflowError:a,BodyTimeoutError:l,RequestContentLengthMismatchError:m,ConnectTimeoutError:n,InvalidArgumentError:g,InvalidReturnValueError:u,RequestAbortedError:C,ClientDestroyedError:D,ClientClosedError:v,InformationalError:f,SocketError:N,NotSupportedError:T,ResponseContentLengthMismatchError:w,BalancedPoolMissingUpstreamError:M,ResponseExceededMaxSizeError:x,RequestRetryError:Y,ResponseError:O,SecureProxyConnectionError:J,MaxOriginsReachedError:_}},5837:(e,t,s)=>{"use strict";const{InvalidArgumentError:r,NotSupportedError:n}=s(4465),i=s(4589),{isValidHTTPToken:A,isValidHeaderValue:o,isStream:a,destroy:c,isBuffer:l,isFormDataLike:h,isIterable:g,isBlobLike:d,serializePathWithQuery:u,assertRequestHandler:E,getServerName:I,normalizedMethodRecords:p,getProtocolFromUrlString:C}=s(2858),{channels:B}=s(772),{headerNameLowerCasedRecord:f}=s(9605),Q=/[^\u0021-\u00ff]/,m=Symbol("handler");function y(e,t,s){if(s&&"object"==typeof s&&!Array.isArray(s))throw new r(`invalid ${t} header`);if(void 0===s)return;let i=f[t];if(void 0===i&&(i=t.toLowerCase(),void 0===f[i]&&!A(i)))throw new r("invalid header key");if(Array.isArray(s)){const e=[];for(let n=0;n<s.length;n++)if("string"==typeof s[n]){if(!o(s[n]))throw new r(`invalid ${t} header`);e.push(s[n])}else if(null===s[n])e.push("");else{if("object"==typeof s[n])throw new r(`invalid ${t} header`);e.push(`${s[n]}`)}s=e}else if("string"==typeof s){if(!o(s))throw new r(`invalid ${t} header`)}else s=null===s?"":`${s}`;if(null===e.host&&"host"===i){if("string"!=typeof s)throw new r("invalid host header");e.host=s}else if(null===e.contentLength&&"content-length"===i){if(e.contentLength=parseInt(s,10),!Number.isFinite(e.contentLength))throw new r("invalid content-length header")}else if(null===e.contentType&&"content-type"===i)e.contentType=s,e.headers.push(t,s);else{if("transfer-encoding"===i||"keep-alive"===i||"upgrade"===i)throw new r(`invalid ${i} header`);if("connection"===i){const t="string"==typeof s?s.toLowerCase():null;if("close"!==t&&"keep-alive"!==t)throw new r("invalid connection header");"close"===t&&(e.reset=!0)}else{if("expect"===i)throw new n("expect header not supported");e.headers.push(t,s)}}}e.exports=class{constructor(e,{path:t,method:s,body:n,headers:i,query:o,idempotent:f,blocking:w,upgrade:S,headersTimeout:D,bodyTimeout:b,reset:v,expectContinue:R,servername:N,throwOnError:k,maxRedirections:T},F){if("string"!=typeof t)throw new r("path must be a string");if("/"!==t[0]&&!t.startsWith("http://")&&!t.startsWith("https://")&&"CONNECT"!==s)throw new r("path must be an absolute URL or start with a slash");if(Q.test(t))throw new r("invalid request path");if("string"!=typeof s)throw new r("method must be a string");if(void 0===p[s]&&!A(s))throw new r("invalid request method");if(S&&"string"!=typeof S)throw new r("upgrade must be a string");if(null!=D&&(!Number.isFinite(D)||D<0))throw new r("invalid headersTimeout");if(null!=b&&(!Number.isFinite(b)||b<0))throw new r("invalid bodyTimeout");if(null!=v&&"boolean"!=typeof v)throw new r("invalid reset");if(null!=R&&"boolean"!=typeof R)throw new r("invalid expectContinue");if(null!=k)throw new r("invalid throwOnError");if(null!=T&&0!==T)throw new r("maxRedirections is not supported, use the redirect interceptor");if(this.headersTimeout=D,this.bodyTimeout=b,this.method=s,this.abort=null,null==n)this.body=null;else if(a(n)){this.body=n;const e=this.body._readableState;e&&e.autoDestroy||(this.endHandler=function(){c(this)},this.body.on("end",this.endHandler)),this.errorHandler=e=>{this.abort?this.abort(e):this.error=e},this.body.on("error",this.errorHandler)}else if(l(n))this.body=n.byteLength?n:null;else if(ArrayBuffer.isView(n))this.body=n.buffer.byteLength?Buffer.from(n.buffer,n.byteOffset,n.byteLength):null;else if(n instanceof ArrayBuffer)this.body=n.byteLength?Buffer.from(n):null;else if("string"==typeof n)this.body=n.length?Buffer.from(n):null;else{if(!(h(n)||g(n)||d(n)))throw new r("body must be a string, a Buffer, a Readable stream, an iterable, or an async iterable");this.body=n}if(this.completed=!1,this.aborted=!1,this.upgrade=S||null,this.path=o?u(t,o):t,this.origin=e,this.protocol=C(e),this.idempotent=null==f?"HEAD"===s||"GET"===s:f,this.blocking=w??"HEAD"!==this.method,this.reset=null==v?null:v,this.host=null,this.contentLength=null,this.contentType=null,this.headers=[],this.expectContinue=null!=R&&R,Array.isArray(i)){if(i.length%2!=0)throw new r("headers array must be even");for(let e=0;e<i.length;e+=2)y(this,i[e],i[e+1])}else if(i&&"object"==typeof i)if(i[Symbol.iterator])for(const e of i){if(!Array.isArray(e)||2!==e.length)throw new r("headers must be in key-value pair format");y(this,e[0],e[1])}else{const e=Object.keys(i);for(let t=0;t<e.length;++t)y(this,e[t],i[e[t]])}else if(null!=i)throw new r("headers must be an object or an array");E(F,s,S),this.servername=N||I(this.host)||null,this[m]=F,B.create.hasSubscribers&&B.create.publish({request:this})}onBodySent(e){if(B.bodyChunkSent.hasSubscribers&&B.bodyChunkSent.publish({request:this,chunk:e}),this[m].onBodySent)try{return this[m].onBodySent(e)}catch(e){this.abort(e)}}onRequestSent(){if(B.bodySent.hasSubscribers&&B.bodySent.publish({request:this}),this[m].onRequestSent)try{return this[m].onRequestSent()}catch(e){this.abort(e)}}onConnect(e){if(i(!this.aborted),i(!this.completed),!this.error)return this.abort=e,this[m].onConnect(e);e(this.error)}onResponseStarted(){return this[m].onResponseStarted?.()}onHeaders(e,t,s,r){i(!this.aborted),i(!this.completed),B.headers.hasSubscribers&&B.headers.publish({request:this,response:{statusCode:e,headers:t,statusText:r}});try{return this[m].onHeaders(e,t,s,r)}catch(e){this.abort(e)}}onData(e){i(!this.aborted),i(!this.completed),B.bodyChunkReceived.hasSubscribers&&B.bodyChunkReceived.publish({request:this,chunk:e});try{return this[m].onData(e)}catch(e){return this.abort(e),!1}}onUpgrade(e,t,s){return i(!this.aborted),i(!this.completed),this[m].onUpgrade(e,t,s)}onComplete(e){this.onFinally(),i(!this.aborted),i(!this.completed),this.completed=!0,B.trailers.hasSubscribers&&B.trailers.publish({request:this,trailers:e});try{return this[m].onComplete(e)}catch(e){this.onError(e)}}onError(e){if(this.onFinally(),B.error.hasSubscribers&&B.error.publish({request:this,error:e}),!this.aborted)return this.aborted=!0,this[m].onError(e)}onFinally(){this.errorHandler&&(this.body.off("error",this.errorHandler),this.errorHandler=null),this.endHandler&&(this.body.off("end",this.endHandler),this.endHandler=null)}addHeader(e,t){return y(this,e,t),this}}},257:e=>{"use strict";e.exports={kClose:Symbol("close"),kDestroy:Symbol("destroy"),kDispatch:Symbol("dispatch"),kUrl:Symbol("url"),kWriting:Symbol("writing"),kResuming:Symbol("resuming"),kQueue:Symbol("queue"),kConnect:Symbol("connect"),kConnecting:Symbol("connecting"),kKeepAliveDefaultTimeout:Symbol("default keep alive timeout"),kKeepAliveMaxTimeout:Symbol("max keep alive timeout"),kKeepAliveTimeoutThreshold:Symbol("keep alive timeout threshold"),kKeepAliveTimeoutValue:Symbol("keep alive timeout"),kKeepAlive:Symbol("keep alive"),kHeadersTimeout:Symbol("headers timeout"),kBodyTimeout:Symbol("body timeout"),kServerName:Symbol("server name"),kLocalAddress:Symbol("local address"),kHost:Symbol("host"),kNoRef:Symbol("no ref"),kBodyUsed:Symbol("used"),kBody:Symbol("abstracted request body"),kRunning:Symbol("running"),kBlocking:Symbol("blocking"),kPending:Symbol("pending"),kSize:Symbol("size"),kBusy:Symbol("busy"),kQueued:Symbol("queued"),kFree:Symbol("free"),kConnected:Symbol("connected"),kClosed:Symbol("closed"),kNeedDrain:Symbol("need drain"),kReset:Symbol("reset"),kDestroyed:Symbol.for("nodejs.stream.destroyed"),kResume:Symbol("resume"),kOnError:Symbol("on error"),kMaxHeadersSize:Symbol("max headers size"),kRunningIdx:Symbol("running index"),kPendingIdx:Symbol("pending index"),kError:Symbol("error"),kClients:Symbol("clients"),kClient:Symbol("client"),kParser:Symbol("parser"),kOnDestroyed:Symbol("destroy callbacks"),kPipelining:Symbol("pipelining"),kSocket:Symbol("socket"),kHostHeader:Symbol("host header"),kConnector:Symbol("connector"),kStrictContentLength:Symbol("strict content length"),kMaxRedirections:Symbol("maxRedirections"),kMaxRequests:Symbol("maxRequestsPerClient"),kProxy:Symbol("proxy agent options"),kCounter:Symbol("socket request counter"),kMaxResponseSize:Symbol("max response size"),kHTTP2Session:Symbol("http2Session"),kHTTP2SessionState:Symbol("http2Session state"),kRetryHandlerDefaultRetry:Symbol("retry agent default retry"),kConstruct:Symbol("constructable"),kListeners:Symbol("listeners"),kHTTPContext:Symbol("http context"),kMaxConcurrentStreams:Symbol("max concurrent streams"),kNoProxyAgent:Symbol("no proxy agent"),kHttpProxyAgent:Symbol("http proxy agent"),kHttpsProxyAgent:Symbol("https proxy agent")}},1310:(e,t,s)=>{"use strict";const{wellknownHeaderNames:r,headerNameLowerCasedRecord:n}=s(9605);class i{value=null;left=null;middle=null;right=null;code;constructor(e,t,s){if(void 0===s||s>=e.length)throw new TypeError("Unreachable");if((this.code=e.charCodeAt(s))>127)throw new TypeError("key must be ascii string");e.length!==++s?this.middle=new i(e,t,s):this.value=t}add(e,t){const s=e.length;if(0===s)throw new TypeError("Unreachable");let r=0,n=this;for(;;){const A=e.charCodeAt(r);if(A>127)throw new TypeError("key must be ascii string");if(n.code===A){if(s===++r){n.value=t;break}if(null===n.middle){n.middle=new i(e,t,r);break}n=n.middle}else if(n.code<A){if(null===n.left){n.left=new i(e,t,r);break}n=n.left}else{if(null===n.right){n.right=new i(e,t,r);break}n=n.right}}}search(e){const t=e.length;let s=0,r=this;for(;null!==r&&s<t;){let n=e[s];for(n<=90&&n>=65&&(n|=32);null!==r;){if(n===r.code){if(t===++s)return r;r=r.middle;break}r=r.code<n?r.left:r.right}}return null}}class A{node=null;insert(e,t){null===this.node?this.node=new i(e,t,0):this.node.add(e,t)}lookup(e){return this.node?.search(e)?.value??null}}const o=new A;for(let e=0;e<r.length;++e){const t=n[r[e]];o.insert(t,t)}e.exports={TernarySearchTree:A,tree:o}},2858:(e,t,s)=>{"use strict";const r=s(4589),{kDestroyed:n,kBodyUsed:i,kListeners:A,kBody:o}=s(257),{IncomingMessage:a}=s(7067),c=s(7075),l=s(7030),{stringify:h}=s(1792),{EventEmitter:g}=s(8474),d=s(3801),{InvalidArgumentError:u,ConnectTimeoutError:E}=s(4465),{headerNameLowerCasedRecord:I}=s(9605),{tree:p}=s(1310),[C,B]=process.versions.node.split(".",2).map((e=>Number(e)));class f{constructor(e){this[o]=e,this[i]=!1}async*[Symbol.asyncIterator](){r(!this[i],"disturbed"),this[i]=!0,yield*this[o]}}function Q(){}function m(e){return e&&"object"==typeof e&&"function"==typeof e.pipe&&"function"==typeof e.on}function y(e){if(null===e)return!1;if(e instanceof Blob)return!0;if("object"!=typeof e)return!1;{const t=e[Symbol.toStringTag];return("Blob"===t||"File"===t)&&("stream"in e&&"function"==typeof e.stream||"arrayBuffer"in e&&"function"==typeof e.arrayBuffer)}}function w(e){return e.includes("?")||e.includes("#")}function S(e){const t=parseInt(e,10);return t===Number(e)&&t>=0&&t<=65535}function D(e){return null!=e&&"h"===e[0]&&"t"===e[1]&&"t"===e[2]&&"p"===e[3]&&(":"===e[4]||"s"===e[4]&&":"===e[5])}function b(e){if("string"==typeof e){if(!D((e=new URL(e)).origin||e.protocol))throw new u("Invalid URL protocol: the URL must start with `http:` or `https:`.");return e}if(!e||"object"!=typeof e)throw new u("Invalid URL: The URL argument must be a non-null object.");if(!(e instanceof URL)){if(null!=e.port&&""!==e.port&&!1===S(e.port))throw new u("Invalid URL: port must be a valid integer or a string representation of an integer.");if(null!=e.path&&"string"!=typeof e.path)throw new u("Invalid URL path: the path must be a string or null/undefined.");if(null!=e.pathname&&"string"!=typeof e.pathname)throw new u("Invalid URL pathname: the pathname must be a string or null/undefined.");if(null!=e.hostname&&"string"!=typeof e.hostname)throw new u("Invalid URL hostname: the hostname must be a string or null/undefined.");if(null!=e.origin&&"string"!=typeof e.origin)throw new u("Invalid URL origin: the origin must be a string or null/undefined.");if(!D(e.origin||e.protocol))throw new u("Invalid URL protocol: the URL must start with `http:` or `https:`.");const t=null!=e.port?e.port:"https:"===e.protocol?443:80;let s=null!=e.origin?e.origin:`${e.protocol||""}//${e.hostname||""}:${t}`,r=null!=e.path?e.path:`${e.pathname||""}${e.search||""}`;return"/"===s[s.length-1]&&(s=s.slice(0,s.length-1)),r&&"/"!==r[0]&&(r=`/${r}`),new URL(`${s}${r}`)}if(!D(e.origin||e.protocol))throw new u("Invalid URL protocol: the URL must start with `http:` or `https:`.");return e}function v(e){return!(null==e||"function"!=typeof e[Symbol.iterator]&&"function"!=typeof e[Symbol.asyncIterator])}function R(e){if(null==e)return 0;if(m(e)){const t=e._readableState;return t&&!1===t.objectMode&&!0===t.ended&&Number.isFinite(t.length)?t.length:null}return y(e)?null!=e.size?e.size:null:M(e)?e.byteLength:null}function N(e){return e&&!!(e.destroyed||e[n]||c.isDestroyed?.(e))}function k(e,t){null!=e&&m(e)&&!N(e)&&("function"==typeof e.destroy?(Object.getPrototypeOf(e).constructor===a&&(e.socket=null),e.destroy(t)):t&&queueMicrotask((()=>{e.emit("error",t)})),!0!==e.destroyed&&(e[n]=!0))}const T=/timeout=(\d+)/;function F(e){return"string"==typeof e?I[e]??e.toLowerCase():p.lookup(e)??e.toString("latin1").toLowerCase()}function M(e){return e instanceof Uint8Array||Buffer.isBuffer(e)}function U(e){switch(e){case 34:case 40:case 41:case 44:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 123:case 125:return!1;default:return e>=33&&e<=126}}const L=/[^\t\x20-\x7e\x80-\xff]/;const P=/^bytes (\d+)-(\d+)\/(\d+)?$/;const x="win32"===process.platform?(e,t)=>{if(!t.timeout)return Q;let s=null,r=null;const n=d.setFastTimeout((()=>{s=setImmediate((()=>{r=setImmediate((()=>H(e.deref(),t)))}))}),t.timeout);return()=>{d.clearFastTimeout(n),clearImmediate(s),clearImmediate(r)}}:(e,t)=>{if(!t.timeout)return Q;let s=null;const r=d.setFastTimeout((()=>{s=setImmediate((()=>{H(e.deref(),t)}))}),t.timeout);return()=>{d.clearFastTimeout(r),clearImmediate(s)}};function H(e,t){if(null==e)return;let s="Connect Timeout Error";Array.isArray(e.autoSelectFamilyAttemptedAddresses)?s+=` (attempted addresses: ${e.autoSelectFamilyAttemptedAddresses.join(", ")},`:s+=` (attempted address: ${t.hostname}:${t.port},`,s+=` timeout: ${t.timeout}ms)`,k(e,new E(s))}const Y=Object.create(null);Y.enumerable=!0;const V={delete:"DELETE",DELETE:"DELETE",get:"GET",GET:"GET",head:"HEAD",HEAD:"HEAD",options:"OPTIONS",OPTIONS:"OPTIONS",post:"POST",POST:"POST",put:"PUT",PUT:"PUT"},O={...V,patch:"patch",PATCH:"PATCH"};Object.setPrototypeOf(V,null),Object.setPrototypeOf(O,null),e.exports={kEnumerableProperty:Y,isDisturbed:function(e){return!(!e||!c.isDisturbed(e)&&!e[i])},isBlobLike:y,parseOrigin:function(e){if("/"!==(e=b(e)).pathname||e.search||e.hash)throw new u("invalid url");return e},parseURL:b,getServerName:function(e){if(!e)return null;r("string"==typeof e);const t=function(e){if("["===e[0]){const t=e.indexOf("]");return r(-1!==t),e.substring(1,t)}const t=e.indexOf(":");return-1===t?e:e.substring(0,t)}(e);return l.isIP(t)?"":t},isStream:m,isIterable:v,isAsyncIterable:function(e){return!(null==e||"function"!=typeof e[Symbol.asyncIterator])},isDestroyed:N,headerNameToString:F,bufferToLowerCasedHeaderName:function(e){return p.lookup(e)??e.toString("latin1").toLowerCase()},addListener:function(e,t,s){return(e[A]??=[]).push([t,s]),e.on(t,s),e},removeAllListeners:function(e){if(null!=e[A]){for(const[t,s]of e[A])e.removeListener(t,s);e[A]=null}return e},errorRequest:function(e,t,s){try{t.onError(s),r(t.aborted)}catch(s){e.emit("error",s)}},parseRawHeaders:function(e){const t=e.length,s=new Array(t);let r,n,i=!1,A=-1,o=0;for(let a=0;a<t;a+=2)r=e[a],n=e[a+1],"string"!=typeof r&&(r=r.toString()),"string"!=typeof n&&(n=n.toString("utf8")),o=r.length,14!==o||"-"!==r[7]||"content-length"!==r&&"content-length"!==r.toLowerCase()?19!==o||"-"!==r[7]||"content-disposition"!==r&&"content-disposition"!==r.toLowerCase()||(A=a+1):i=!0,s[a]=r,s[a+1]=n;return i&&-1!==A&&(s[A]=Buffer.from(s[A]).toString("latin1")),s},encodeRawHeaders:function(e){if(!Array.isArray(e))throw new TypeError("expected headers to be an array");return e.map((e=>Buffer.from(e)))},parseHeaders:function(e,t){void 0===t&&(t={});for(let s=0;s<e.length;s+=2){const r=F(e[s]);let n=t[r];if(n)"string"==typeof n&&(n=[n],t[r]=n),n.push(e[s+1].toString("utf8"));else{const n=e[s+1];t[r]="string"==typeof n?n:Array.isArray(n)?n.map((e=>e.toString("utf8"))):n.toString("utf8")}}return"content-length"in t&&"content-disposition"in t&&(t["content-disposition"]=Buffer.from(t["content-disposition"]).toString("latin1")),t},parseKeepAliveTimeout:function(e){const t=e.match(T);return t?1e3*parseInt(t[1],10):null},destroy:k,bodyLength:R,deepClone:function(e){return JSON.parse(JSON.stringify(e))},ReadableStreamFrom:function(e){let t;return new ReadableStream({start(){t=e[Symbol.asyncIterator]()},pull(e){return t.next().then((({done:t,value:s})=>{if(t)queueMicrotask((()=>{e.close(),e.byobRequest?.respond(0)}));else{const t=Buffer.isBuffer(s)?s:Buffer.from(s);if(!t.byteLength)return this.pull(e);e.enqueue(new Uint8Array(t))}}))},cancel:()=>t.return(),type:"bytes"})},isBuffer:M,assertRequestHandler:function(e,t,s){if(!e||"object"!=typeof e)throw new u("handler must be an object");if("function"!=typeof e.onRequestStart){if("function"!=typeof e.onConnect)throw new u("invalid onConnect method");if("function"!=typeof e.onError)throw new u("invalid onError method");if("function"!=typeof e.onBodySent&&void 0!==e.onBodySent)throw new u("invalid onBodySent method");if(s||"CONNECT"===t){if("function"!=typeof e.onUpgrade)throw new u("invalid onUpgrade method")}else{if("function"!=typeof e.onHeaders)throw new u("invalid onHeaders method");if("function"!=typeof e.onData)throw new u("invalid onData method");if("function"!=typeof e.onComplete)throw new u("invalid onComplete method")}}},getSocketInfo:function(e){return{localAddress:e.localAddress,localPort:e.localPort,remoteAddress:e.remoteAddress,remotePort:e.remotePort,remoteFamily:e.remoteFamily,timeout:e.timeout,bytesWritten:e.bytesWritten,bytesRead:e.bytesRead}},isFormDataLike:function(e){return e&&"object"==typeof e&&"function"==typeof e.append&&"function"==typeof e.delete&&"function"==typeof e.get&&"function"==typeof e.getAll&&"function"==typeof e.has&&"function"==typeof e.set&&"FormData"===e[Symbol.toStringTag]},pathHasQueryOrFragment:w,serializePathWithQuery:function(e,t){if(w(e))throw new Error('Query params cannot be passed when url already contains "?" or "#".');const s=h(t);return s&&(e+="?"+s),e},addAbortListener:function(e,t){return"addEventListener"in e?(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)):(e.once("abort",t),()=>e.removeListener("abort",t))},isValidHTTPToken:function(e){if(0===e.length)return!1;for(let t=0;t<e.length;++t)if(!U(e.charCodeAt(t)))return!1;return!0},isValidHeaderValue:function(e){return!L.test(e)},isTokenCharCode:U,parseRangeHeader:function(e){if(null==e||""===e)return{start:0,end:null,size:null};const t=e?e.match(P):null;return t?{start:parseInt(t[1]),end:t[2]?parseInt(t[2]):null,size:t[3]?parseInt(t[3]):null}:null},normalizedMethodRecordsBase:V,normalizedMethodRecords:O,isValidPort:S,isHttpOrHttpsPrefixed:D,nodeMajor:C,nodeMinor:B,safeHTTPMethods:Object.freeze(["GET","HEAD","OPTIONS","TRACE"]),wrapRequestBody:function(e){return m(e)?(0===R(e)&&e.on("data",(function(){r(!1)})),"boolean"!=typeof e.readableDidRead&&(e[i]=!1,g.prototype.on.call(e,"data",(function(){this[i]=!0}))),e):e&&"function"==typeof e.pipeTo||e&&"string"!=typeof e&&!ArrayBuffer.isView(e)&&v(e)?new f(e):e},setupConnectTimeout:x,getProtocolFromUrlString:function(e){if("h"===e[0]&&"t"===e[1]&&"t"===e[2]&&"p"===e[3])switch(e[4]){case":":return"http:";case"s":if(":"===e[5])return"https:"}return e.slice(0,e.indexOf(":")+1)}}},3315:(e,t,s)=>{"use strict";const{InvalidArgumentError:r,MaxOriginsReachedError:n}=s(4465),{kClients:i,kRunning:A,kClose:o,kDestroy:a,kDispatch:c,kUrl:l}=s(257),h=s(7779),g=s(8542),d=s(1167),u=s(2858),E=Symbol("onConnect"),I=Symbol("onDisconnect"),p=Symbol("onConnectionError"),C=Symbol("onDrain"),B=Symbol("factory"),f=Symbol("options"),Q=Symbol("origins");function m(e,t){return t&&1===t.connections?new d(e,t):new g(e,t)}e.exports=class extends h{constructor({factory:e=m,maxOrigins:t=1/0,connect:s,...n}={}){if("function"!=typeof e)throw new r("factory must be a function.");if(null!=s&&"function"!=typeof s&&"object"!=typeof s)throw new r("connect must be a function or an object");if("number"!=typeof t||Number.isNaN(t)||t<=0)throw new r("maxOrigins must be a number greater than 0");super(),s&&"function"!=typeof s&&(s={...s}),this[f]={...u.deepClone(n),maxOrigins:t,connect:s},this[B]=e,this[i]=new Map,this[Q]=new Set,this[C]=(e,t)=>{this.emit("drain",e,[this,...t])},this[E]=(e,t)=>{this.emit("connect",e,[this,...t])},this[I]=(e,t,s)=>{this.emit("disconnect",e,[this,...t],s)},this[p]=(e,t,s)=>{this.emit("connectionError",e,[this,...t],s)}}get[A](){let e=0;for(const{dispatcher:t}of this[i].values())e+=t[A];return e}[c](e,t){let s;if(!e.origin||!("string"==typeof e.origin||e.origin instanceof URL))throw new r("opts.origin must be a non-empty string or URL.");if(s=String(e.origin),this[Q].size>=this[f].maxOrigins&&!this[Q].has(s))throw new n;const A=this[i].get(s);let o=A&&A.dispatcher;if(!o){const t=e=>{const t=this[i].get(s);t&&(e&&(t.count-=1),t.count<=0&&(this[i].delete(s),t.dispatcher.close()),this[Q].delete(s))};o=this[B](e.origin,this[f]).on("drain",this[C]).on("connect",((e,t)=>{const r=this[i].get(s);r&&(r.count+=1),this[E](e,t)})).on("disconnect",((e,s,r)=>{t(!0),this[I](e,s,r)})).on("connectionError",((e,s,r)=>{t(!1),this[p](e,s,r)})),this[i].set(s,{count:0,dispatcher:o}),this[Q].add(s)}return o.dispatch(e,t)}[o](){const e=[];for(const{dispatcher:t}of this[i].values())e.push(t.close());return this[i].clear(),Promise.all(e)}[a](e){const t=[];for(const{dispatcher:s}of this[i].values())t.push(s.destroy(e));return this[i].clear(),Promise.all(t)}get stats(){const e={};for(const{dispatcher:t}of this[i].values())t.stats&&(e[t[l].origin]=t.stats);return e}}},8055:(e,t,s)=>{"use strict";const{BalancedPoolMissingUpstreamError:r,InvalidArgumentError:n}=s(4465),{PoolBase:i,kClients:A,kNeedDrain:o,kAddClient:a,kRemoveClient:c,kGetDispatcher:l}=s(1694),h=s(8542),{kUrl:g}=s(257),{parseOrigin:d}=s(2858),u=Symbol("factory"),E=Symbol("options"),I=Symbol("kGreatestCommonDivisor"),p=Symbol("kCurrentWeight"),C=Symbol("kIndex"),B=Symbol("kWeight"),f=Symbol("kMaxWeightPerServer"),Q=Symbol("kErrorPenalty");function m(e,t){if(0===e)return t;for(;0!==t;){const s=t;t=e%t,e=s}return e}function y(e,t){return new h(e,t)}e.exports=class extends i{constructor(e=[],{factory:t=y,...s}={}){if("function"!=typeof t)throw new n("factory must be a function.");super(),this[E]=s,this[C]=-1,this[p]=0,this[f]=this[E].maxWeightPerServer||100,this[Q]=this[E].errorPenalty||15,Array.isArray(e)||(e=[e]),this[u]=t;for(const t of e)this.addUpstream(t);this._updateBalancedPoolStats()}addUpstream(e){const t=d(e).origin;if(this[A].find((e=>e[g].origin===t&&!0!==e.closed&&!0!==e.destroyed)))return this;const s=this[u](t,Object.assign({},this[E]));this[a](s),s.on("connect",(()=>{s[B]=Math.min(this[f],s[B]+this[Q])})),s.on("connectionError",(()=>{s[B]=Math.max(1,s[B]-this[Q]),this._updateBalancedPoolStats()})),s.on("disconnect",((...e)=>{const t=e[2];t&&"UND_ERR_SOCKET"===t.code&&(s[B]=Math.max(1,s[B]-this[Q]),this._updateBalancedPoolStats())}));for(const e of this[A])e[B]=this[f];return this._updateBalancedPoolStats(),this}_updateBalancedPoolStats(){let e=0;for(let t=0;t<this[A].length;t++)e=m(this[A][t][B],e);this[I]=e}removeUpstream(e){const t=d(e).origin,s=this[A].find((e=>e[g].origin===t&&!0!==e.closed&&!0!==e.destroyed));return s&&this[c](s),this}get upstreams(){return this[A].filter((e=>!0!==e.closed&&!0!==e.destroyed)).map((e=>e[g].origin))}[l](){if(0===this[A].length)throw new r;if(!this[A].find((e=>!e[o]&&!0!==e.closed&&!0!==e.destroyed)))return;if(this[A].map((e=>e[o])).reduce(((e,t)=>e&&t),!0))return;let e=0,t=this[A].findIndex((e=>!e[o]));for(;e++<this[A].length;){this[C]=(this[C]+1)%this[A].length;const e=this[A][this[C]];if(e[B]>this[A][t][B]&&!e[o]&&(t=this[C]),0===this[C]&&(this[p]=this[p]-this[I],this[p]<=0&&(this[p]=this[f])),e[B]>=this[p]&&!e[o])return e}return this[p]=this[A][t][B],this[C]=t,this[A][t]}}},9355:(e,t,s)=>{"use strict";const r=s(4589),n=s(2858),{channels:i}=s(772),A=s(3801),{RequestContentLengthMismatchError:o,ResponseContentLengthMismatchError:a,RequestAbortedError:c,HeadersTimeoutError:l,HeadersOverflowError:h,SocketError:g,InformationalError:d,BodyTimeoutError:u,HTTPParserError:E,ResponseExceededMaxSizeError:I}=s(4465),{kUrl:p,kReset:C,kClient:B,kParser:f,kBlocking:Q,kRunning:m,kPending:y,kSize:w,kWriting:S,kQueue:D,kNoRef:b,kKeepAliveDefaultTimeout:v,kHostHeader:R,kPendingIdx:N,kRunningIdx:k,kError:T,kPipelining:F,kSocket:M,kKeepAliveTimeoutValue:U,kMaxHeadersSize:L,kKeepAliveMaxTimeout:P,kKeepAliveTimeoutThreshold:x,kHeadersTimeout:H,kBodyTimeout:Y,kStrictContentLength:V,kMaxRequests:O,kCounter:G,kMaxResponseSize:J,kOnError:W,kResume:_,kHTTPContext:$,kClosed:q}=s(257),z=s(4178),j=Buffer.alloc(0),X=Buffer[Symbol.species],Z=n.removeAllListeners;let K;let ee=null,te=null,se=null,re=0,ne=null;class ie{constructor(e,t,{exports:s}){this.llhttp=s,this.ptr=this.llhttp.llhttp_alloc(z.TYPE.RESPONSE),this.client=e,this.socket=t,this.timeout=null,this.timeoutValue=null,this.timeoutType=null,this.statusCode=0,this.statusText="",this.upgrade=!1,this.headers=[],this.headersSize=0,this.headersMaxSize=e[L],this.shouldKeepAlive=!1,this.paused=!1,this.resume=this.resume.bind(this),this.bytesRead=0,this.keepAlive="",this.contentLength="",this.connection="",this.maxResponseSize=e[J]}setTimeout(e,t){e!==this.timeoutValue||1&t^1&this.timeoutType?(this.timeout&&(A.clearTimeout(this.timeout),this.timeout=null),e&&(1&t?this.timeout=A.setFastTimeout(Ae,e,new WeakRef(this)):(this.timeout=setTimeout(Ae,e,new WeakRef(this)),this.timeout?.unref())),this.timeoutValue=e):this.timeout&&this.timeout.refresh&&this.timeout.refresh(),this.timeoutType=t}resume(){!this.socket.destroyed&&this.paused&&(r(null!=this.ptr),r(null===te),this.llhttp.llhttp_resume(this.ptr),r(5===this.timeoutType),this.timeout&&this.timeout.refresh&&this.timeout.refresh(),this.paused=!1,this.execute(this.socket.read()||j),this.readMore())}readMore(){for(;!this.paused&&this.ptr;){const e=this.socket.read();if(null===e)break;this.execute(e)}}execute(e){r(null===te),r(null!=this.ptr),r(!this.paused);const{socket:t,llhttp:s}=this;e.length>re&&(ne&&s.free(ne),re=4096*Math.ceil(e.length/4096),ne=s.malloc(re)),new Uint8Array(s.memory.buffer,ne,re).set(e);try{let r;try{se=e,te=this,r=s.llhttp_execute(this.ptr,ne,e.length)}finally{te=null,se=null}if(r!==z.ERROR.OK){const n=e.subarray(s.llhttp_get_error_pos(this.ptr)-ne);if(r===z.ERROR.PAUSED_UPGRADE)this.onUpgrade(n);else{if(r!==z.ERROR.PAUSED){const e=s.llhttp_get_error_reason(this.ptr);let t="";if(e){const r=new Uint8Array(s.memory.buffer,e).indexOf(0);t="Response does not match the HTTP/1.1 protocol ("+Buffer.from(s.memory.buffer,e,r).toString()+")"}throw new E(t,z.ERROR[r],n)}this.paused=!0,t.unshift(n)}}}catch(e){n.destroy(t,e)}}destroy(){r(null===te),r(null!=this.ptr),this.llhttp.llhttp_free(this.ptr),this.ptr=null,this.timeout&&A.clearTimeout(this.timeout),this.timeout=null,this.timeoutValue=null,this.timeoutType=null,this.paused=!1}onStatus(e){return this.statusText=e.toString(),0}onMessageBegin(){const{socket:e,client:t}=this;if(e.destroyed)return-1;const s=t[D][t[k]];return s?(s.onResponseStarted(),0):-1}onHeaderField(e){const t=this.headers.length;return 1&t?this.headers[t-1]=Buffer.concat([this.headers[t-1],e]):this.headers.push(e),this.trackHeader(e.length),0}onHeaderValue(e){let t=this.headers.length;1&~t?this.headers[t-1]=Buffer.concat([this.headers[t-1],e]):(this.headers.push(e),t+=1);const s=this.headers[t-2];if(10===s.length){const t=n.bufferToLowerCasedHeaderName(s);"keep-alive"===t?this.keepAlive+=e.toString():"connection"===t&&(this.connection+=e.toString())}else 14===s.length&&"content-length"===n.bufferToLowerCasedHeaderName(s)&&(this.contentLength+=e.toString());return this.trackHeader(e.length),0}trackHeader(e){this.headersSize+=e,this.headersSize>=this.headersMaxSize&&n.destroy(this.socket,new h)}onUpgrade(e){const{upgrade:t,client:s,socket:i,headers:A,statusCode:o}=this;r(t),r(s[M]===i),r(!i.destroyed),r(!this.paused),r(!(1&A.length));const a=s[D][s[k]];r(a),r(a.upgrade||"CONNECT"===a.method),this.statusCode=0,this.statusText="",this.shouldKeepAlive=!1,this.headers=[],this.headersSize=0,i.unshift(e),i[f].destroy(),i[f]=null,i[B]=null,i[T]=null,Z(i),s[M]=null,s[$]=null,s[D][s[k]++]=null,s.emit("disconnect",s[p],[s],new d("upgrade"));try{a.onUpgrade(o,A,i)}catch(e){n.destroy(i,e)}s[_]()}onHeadersComplete(e,t,s){const{client:i,socket:A,headers:o,statusText:a}=this;if(A.destroyed)return-1;const c=i[D][i[k]];if(!c)return-1;if(r(!this.upgrade),r(this.statusCode<200),100===e)return n.destroy(A,new g("bad response",n.getSocketInfo(A))),-1;if(t&&!c.upgrade)return n.destroy(A,new g("bad upgrade",n.getSocketInfo(A))),-1;if(r(3===this.timeoutType),this.statusCode=e,this.shouldKeepAlive=s||"HEAD"===c.method&&!A[C]&&"keep-alive"===this.connection.toLowerCase(),this.statusCode>=200){const e=null!=c.bodyTimeout?c.bodyTimeout:i[Y];this.setTimeout(e,5)}else this.timeout&&this.timeout.refresh&&this.timeout.refresh();if("CONNECT"===c.method)return r(1===i[m]),this.upgrade=!0,2;if(t)return r(1===i[m]),this.upgrade=!0,2;if(r(!(1&this.headers.length)),this.headers=[],this.headersSize=0,this.shouldKeepAlive&&i[F]){const e=this.keepAlive?n.parseKeepAliveTimeout(this.keepAlive):null;if(null!=e){const t=Math.min(e-i[x],i[P]);t<=0?A[C]=!0:i[U]=t}else i[U]=i[v]}else A[C]=!0;const l=!1===c.onHeaders(e,o,this.resume,a);return c.aborted?-1:"HEAD"===c.method||e<200?1:(A[Q]&&(A[Q]=!1,i[_]()),l?z.ERROR.PAUSED:0)}onBody(e){const{client:t,socket:s,statusCode:i,maxResponseSize:A}=this;if(s.destroyed)return-1;const o=t[D][t[k]];return r(o),r(5===this.timeoutType),this.timeout&&this.timeout.refresh&&this.timeout.refresh(),r(i>=200),A>-1&&this.bytesRead+e.length>A?(n.destroy(s,new I),-1):(this.bytesRead+=e.length,!1===o.onData(e)?z.ERROR.PAUSED:0)}onMessageComplete(){const{client:e,socket:t,statusCode:s,upgrade:i,headers:A,contentLength:o,bytesRead:c,shouldKeepAlive:l}=this;if(t.destroyed&&(!s||l))return-1;if(i)return 0;r(s>=100),r(!(1&this.headers.length));const h=e[D][e[k]];return r(h),this.statusCode=0,this.statusText="",this.bytesRead=0,this.contentLength="",this.keepAlive="",this.connection="",this.headers=[],this.headersSize=0,s<200?0:"HEAD"!==h.method&&o&&c!==parseInt(o,10)?(n.destroy(t,new a),-1):(h.onComplete(A),e[D][e[k]++]=null,t[S]?(r(0===e[m]),n.destroy(t,new d("reset")),z.ERROR.PAUSED):l?t[C]&&0===e[m]?(n.destroy(t,new d("reset")),z.ERROR.PAUSED):(null==e[F]||1===e[F]?setImmediate(e[_]):e[_](),0):(n.destroy(t,new d("reset")),z.ERROR.PAUSED))}}function Ae(e){const{socket:t,timeoutType:s,client:i,paused:A}=e.deref();3===s?(!t[S]||t.writableNeedDrain||i[m]>1)&&(r(!A,"cannot be paused while waiting for headers"),n.destroy(t,new l)):5===s?A||n.destroy(t,new u):8===s&&(r(0===i[m]&&i[U]),n.destroy(t,new d("socket idle timeout")))}function oe(e){r("ERR_TLS_CERT_ALTNAME_INVALID"!==e.code);const t=this[f];"ECONNRESET"!==e.code||!t.statusCode||t.shouldKeepAlive?(this[T]=e,this[B][W](e)):t.onMessageComplete()}function ae(){this[f]?.readMore()}function ce(){const e=this[f];!e.statusCode||e.shouldKeepAlive?n.destroy(this,new g("other side closed",n.getSocketInfo(this))):e.onMessageComplete()}function le(){const e=this[f];e&&(this[T]||!e.statusCode||e.shouldKeepAlive||e.onMessageComplete(),this[f].destroy(),this[f]=null);const t=this[T]||new g("closed",n.getSocketInfo(this)),s=this[B];if(s[M]=null,s[$]=null,s.destroyed){r(0===s[y]);const e=s[D].splice(s[k]);for(let r=0;r<e.length;r++){const i=e[r];n.errorRequest(s,i,t)}}else if(s[m]>0&&"UND_ERR_INFO"!==t.code){const e=s[D][s[k]];s[D][s[k]++]=null,n.errorRequest(s,e,t)}s[N]=s[k],r(0===s[m]),s.emit("disconnect",s[p],[s],t),s[_]()}function he(){this[q]=!0}function ge(e,t,s,i,A,o,a,c){try{t?n.isBuffer(t)&&(r(o===t.byteLength,"buffer body must have content length"),A.cork(),A.write(`${a}content-length: ${o}\r\n\r\n`,"latin1"),A.write(t),A.uncork(),i.onBodySent(t),c||!1===i.reset||(A[C]=!0)):0===o?A.write(`${a}content-length: 0\r\n\r\n`,"latin1"):(r(null===o,"no body must not have content length"),A.write(`${a}\r\n`,"latin1")),i.onRequestSent(),s[_]()}catch(t){e(t)}}async function de(e,t,s,n,i,A,o,a){r(0!==A||0===s[m],"iterator body cannot be pipelined");let c=null;function l(){if(c){const e=c;c=null,e()}}i.on("close",l).on("drain",l);const h=new ue({abort:e,socket:i,request:n,contentLength:A,client:s,expectsPayload:a,header:o});try{for await(const e of t){if(i[T])throw i[T];h.write(e)||await new Promise(((e,t)=>{r(null===c),i[T]?t(i[T]):c=e}))}h.end()}catch(e){h.destroy(e)}finally{i.off("close",l).off("drain",l)}}class ue{constructor({abort:e,socket:t,request:s,contentLength:r,client:n,expectsPayload:i,header:A}){this.socket=t,this.request=s,this.contentLength=r,this.client=n,this.bytesWritten=0,this.expectsPayload=i,this.header=A,this.abort=e,t[S]=!0}write(e){const{socket:t,request:s,contentLength:r,client:n,bytesWritten:i,expectsPayload:A,header:a}=this;if(t[T])throw t[T];if(t.destroyed)return!1;const c=Buffer.byteLength(e);if(!c)return!0;if(null!==r&&i+c>r){if(n[V])throw new o;process.emitWarning(new o)}t.cork(),0===i&&(A||!1===s.reset||(t[C]=!0),null===r?t.write(`${a}transfer-encoding: chunked\r\n`,"latin1"):t.write(`${a}content-length: ${r}\r\n\r\n`,"latin1")),null===r&&t.write(`\r\n${c.toString(16)}\r\n`,"latin1"),this.bytesWritten+=c;const l=t.write(e);return t.uncork(),s.onBodySent(e),l||t[f].timeout&&3===t[f].timeoutType&&t[f].timeout.refresh&&t[f].timeout.refresh(),l}end(){const{socket:e,contentLength:t,client:s,bytesWritten:r,expectsPayload:n,header:i,request:A}=this;if(A.onRequestSent(),e[S]=!1,e[T])throw e[T];if(!e.destroyed){if(0===r?n?e.write(`${i}content-length: 0\r\n\r\n`,"latin1"):e.write(`${i}\r\n`,"latin1"):null===t&&e.write("\r\n0\r\n\r\n","latin1"),null!==t&&r!==t){if(s[V])throw new o;process.emitWarning(new o)}e[f].timeout&&3===e[f].timeoutType&&e[f].timeout.refresh&&e[f].timeout.refresh(),s[_]()}}destroy(e){const{socket:t,client:s,abort:n}=this;t[S]=!1,e&&(r(s[m]<=1,"pipeline should only contain this request"),n(e))}}e.exports=function(e,t){if(e[M]=t,ee||(ee=function(){const e=process.env.JEST_WORKER_ID?s(4744):void 0;let t,n="ppc64"!==process.arch;if("1"===process.env.UNDICI_NO_WASM_SIMD?n=!0:"0"===process.env.UNDICI_NO_WASM_SIMD&&(n=!1),n)try{t=new WebAssembly.Module(s(7136))}catch{}return t||(t=new WebAssembly.Module(e||s(4744))),new WebAssembly.Instance(t,{env:{wasm_on_url:(e,t,s)=>0,wasm_on_status:(e,t,s)=>{r(te.ptr===e);const n=t-ne+se.byteOffset;return te.onStatus(new X(se.buffer,n,s))},wasm_on_message_begin:e=>(r(te.ptr===e),te.onMessageBegin()),wasm_on_header_field:(e,t,s)=>{r(te.ptr===e);const n=t-ne+se.byteOffset;return te.onHeaderField(new X(se.buffer,n,s))},wasm_on_header_value:(e,t,s)=>{r(te.ptr===e);const n=t-ne+se.byteOffset;return te.onHeaderValue(new X(se.buffer,n,s))},wasm_on_headers_complete:(e,t,s,n)=>(r(te.ptr===e),te.onHeadersComplete(t,1===s,1===n)),wasm_on_body:(e,t,s)=>{r(te.ptr===e);const n=t-ne+se.byteOffset;return te.onBody(new X(se.buffer,n,s))},wasm_on_message_complete:e=>(r(te.ptr===e),te.onMessageComplete())}})}()),t.errored)throw t.errored;if(t.destroyed)throw new g("destroyed");return t[b]=!1,t[S]=!1,t[C]=!1,t[Q]=!1,t[f]=new ie(e,t,ee),n.addListener(t,"error",oe),n.addListener(t,"readable",ae),n.addListener(t,"end",ce),n.addListener(t,"close",le),t[q]=!1,t.on("close",he),{version:"h1",defaultPipelining:1,write:t=>function(e,t){const{method:A,path:a,host:l,upgrade:h,blocking:g,reset:u}=t;let{body:E,headers:I,contentLength:p}=t;const B="PUT"===A||"POST"===A||"PATCH"===A||"QUERY"===A||"PROPFIND"===A||"PROPPATCH"===A;if(n.isFormDataLike(E)){K||(K=s(2530).extractBody);const[e,r]=K(E);null==t.contentType&&I.push("content-type",r),E=e.stream,p=e.length}else n.isBlobLike(E)&&null==t.contentType&&E.type&&I.push("content-type",E.type);E&&"function"==typeof E.read&&E.read(0);const f=n.bodyLength(E);p=f??p,null===p&&(p=t.contentLength);0!==p||B||(p=null);if(function(e){return"GET"!==e&&"HEAD"!==e&&"OPTIONS"!==e&&"TRACE"!==e&&"CONNECT"!==e}(A)&&p>0&&null!==t.contentLength&&t.contentLength!==p){if(e[V])return n.errorRequest(e,t,new o),!1;process.emitWarning(new o)}const y=e[M],w=s=>{t.aborted||t.completed||(n.errorRequest(e,t,s||new c),n.destroy(E),n.destroy(y,new d("aborted")))};try{t.onConnect(w)}catch(s){n.errorRequest(e,t,s)}if(t.aborted)return!1;"HEAD"===A&&(y[C]=!0);(h||"CONNECT"===A)&&(y[C]=!0);null!=u&&(y[C]=u);e[O]&&y[G]++>=e[O]&&(y[C]=!0);g&&(y[Q]=!0);let D=`${A} ${a} HTTP/1.1\r\n`;D+="string"==typeof l?`host: ${l}\r\n`:e[R];h?D+=`connection: upgrade\r\nupgrade: ${h}\r\n`:e[F]&&!y[C]?D+="connection: keep-alive\r\n":D+="connection: close\r\n";if(Array.isArray(I))for(let e=0;e<I.length;e+=2){const t=I[e+0],s=I[e+1];if(Array.isArray(s))for(let e=0;e<s.length;e++)D+=`${t}: ${s[e]}\r\n`;else D+=`${t}: ${s}\r\n`}i.sendHeaders.hasSubscribers&&i.sendHeaders.publish({request:t,headers:D,socket:y});E&&0!==f?n.isBuffer(E)?ge(w,E,e,t,y,p,D,B):n.isBlobLike(E)?"function"==typeof E.stream?de(w,E.stream(),e,t,y,p,D,B):async function(e,t,s,n,i,A,a,c){r(A===t.size,"blob body must have content length");try{if(null!=A&&A!==t.size)throw new o;const e=Buffer.from(await t.arrayBuffer());i.cork(),i.write(`${a}content-length: ${A}\r\n\r\n`,"latin1"),i.write(e),i.uncork(),n.onBodySent(e),n.onRequestSent(),c||!1===n.reset||(i[C]=!0),s[_]()}catch(t){e(t)}}(w,E,e,t,y,p,D,B):n.isStream(E)?function(e,t,s,i,A,o,a,l){r(0!==o||0===s[m],"stream body cannot be pipelined");let h=!1;const g=new ue({abort:e,socket:A,request:i,contentLength:o,client:s,expectsPayload:l,header:a}),d=function(e){if(!h)try{!g.write(e)&&this.pause&&this.pause()}catch(e){n.destroy(this,e)}},u=function(){h||t.resume&&t.resume()},E=function(){if(queueMicrotask((()=>{t.removeListener("error",I)})),!h){const e=new c;queueMicrotask((()=>I(e)))}},I=function(e){if(!h){if(h=!0,r(A.destroyed||A[S]&&s[m]<=1),A.off("drain",u).off("error",I),t.removeListener("data",d).removeListener("end",I).removeListener("close",E),!e)try{g.end()}catch(t){e=t}g.destroy(e),!e||"UND_ERR_INFO"===e.code&&"reset"===e.message?n.destroy(t):n.destroy(t,e)}};t.on("data",d).on("end",I).on("error",I).on("close",E),t.resume&&t.resume();A.on("drain",u).on("error",I),t.errorEmitted??t.errored?setImmediate(I,t.errored):(t.endEmitted??t.readableEnded)&&setImmediate(I,null);(t.closeEmitted??t.closed)&&setImmediate(E)}(w,E,e,t,y,p,D,B):n.isIterable(E)?de(w,E,e,t,y,p,D,B):r(!1):ge(w,null,e,t,y,p,D,B);return!0}(e,t),resume(){!function(e){const t=e[M];if(t&&!t.destroyed)if(0===e[w]?!t[b]&&t.unref&&(t.unref(),t[b]=!0):t[b]&&t.ref&&(t.ref(),t[b]=!1),0===e[w])8!==t[f].timeoutType&&t[f].setTimeout(e[U],8);else if(e[m]>0&&t[f].statusCode<200&&3!==t[f].timeoutType){const s=e[D][e[k]],r=null!=s.headersTimeout?s.headersTimeout:e[H];t[f].setTimeout(r,3)}}(e)},destroy(e,s){t[q]?queueMicrotask(s):(t.on("close",s),t.destroy(e))},get destroyed(){return t.destroyed},busy(s){if(t[S]||t[C]||t[Q])return!0;if(s){if(e[m]>0&&!s.idempotent)return!0;if(e[m]>0&&(s.upgrade||"CONNECT"===s.method))return!0;if(e[m]>0&&0!==n.bodyLength(s.body)&&(n.isStream(s.body)||n.isAsyncIterable(s.body)||n.isFormDataLike(s.body)))return!0}return!1}}}},8142:(e,t,s)=>{"use strict";const r=s(4589),{pipeline:n}=s(7075),i=s(2858),{RequestContentLengthMismatchError:A,RequestAbortedError:o,SocketError:a,InformationalError:c}=s(4465),{kUrl:l,kReset:h,kClient:g,kRunning:d,kPending:u,kQueue:E,kPendingIdx:I,kRunningIdx:p,kError:C,kSocket:B,kStrictContentLength:f,kOnError:Q,kMaxConcurrentStreams:m,kHTTP2Session:y,kResume:w,kSize:S,kHTTPContext:D,kClosed:b,kBodyTimeout:v}=s(257),{channels:R}=s(772),N=Symbol("open streams");let k,T;try{T=s(2467)}catch{T={constants:{}}}const{constants:{HTTP2_HEADER_AUTHORITY:F,HTTP2_HEADER_METHOD:M,HTTP2_HEADER_PATH:U,HTTP2_HEADER_SCHEME:L,HTTP2_HEADER_CONTENT_LENGTH:P,HTTP2_HEADER_EXPECT:x,HTTP2_HEADER_STATUS:H}}=T;function Y(e){r("ERR_TLS_CERT_ALTNAME_INVALID"!==e.code),this[B][C]=e,this[g][Q](e)}function V(e,t,s){if(0===s){const s=new c(`HTTP/2: "frameError" received - type ${e}, code ${t}`);this[B][C]=s,this[g][Q](s)}}function O(){const e=new a("other side closed",i.getSocketInfo(this[B]));this.destroy(e),i.destroy(this[B],e)}function G(e){const t=this[C]||new a(`HTTP/2: "GOAWAY" frame received with code ${e}`,i.getSocketInfo(this[B])),s=this[g];if(s[B]=null,s[D]=null,this.close(),this[y]=null,i.destroy(this[B],t),s[p]<s[E].length){const e=s[E][s[p]];s[E][s[p]++]=null,i.errorRequest(s,e,t),s[I]=s[p]}r(0===s[d]),s.emit("disconnect",s[l],[s],t),s.emit("connectionError",s[l],[s],t),s[w]()}function J(){const{[g]:e}=this,{[B]:t}=e,s=this[B][C]||this[C]||new a("closed",i.getSocketInfo(t));if(e[B]=null,e[D]=null,e.destroyed){r(0===e[u]);const t=e[E].splice(e[p]);for(let r=0;r<t.length;r++){const n=t[r];i.errorRequest(e,n,s)}}}function W(){const e=this[C]||new a("closed",i.getSocketInfo(this)),t=this[y][g];t[B]=null,t[D]=null,null!==this[y]&&this[y].destroy(e),t[I]=t[p],r(0===t[d]),t.emit("disconnect",t[l],[t],e),t[w]()}function _(e){r("ERR_TLS_CERT_ALTNAME_INVALID"!==e.code),this[C]=e,this[g][Q](e)}function $(){i.destroy(this,new a("other side closed",i.getSocketInfo(this)))}function q(){this[b]=!0}function z(e,t,s,n,A,o,a,c){try{null!=s&&i.isBuffer(s)&&(r(a===s.byteLength,"buffer body must have content length"),t.cork(),t.write(s),t.uncork(),t.end(),A.onBodySent(s)),c||(o[h]=!0),A.onRequestSent(),n[w]()}catch(t){e(t)}}async function j(e,t,s,n,i,A,o,a){r(0!==o||0===n[d],"iterator body cannot be pipelined");let c=null;function l(){if(c){const e=c;c=null,e()}}t.on("close",l).on("drain",l);try{for await(const e of s){if(A[C])throw A[C];const s=t.write(e);i.onBodySent(e),s||await new Promise(((e,t)=>{r(null===c),A[C]?t(A[C]):c=e}))}t.end(),i.onRequestSent(),a||(A[h]=!0),n[w]()}catch(t){e(t)}finally{t.off("close",l).off("drain",l)}}e.exports=function(e,t){e[B]=t;const a=T.connect(e[l],{createConnection:()=>t,peerMaxConcurrentStreams:e[m],settings:{enablePush:!1}});return a[N]=0,a[g]=e,a[B]=t,a[y]=null,i.addListener(a,"error",Y),i.addListener(a,"frameError",V),i.addListener(a,"end",O),i.addListener(a,"goaway",G),i.addListener(a,"close",J),a.unref(),e[y]=a,t[y]=a,i.addListener(t,"error",_),i.addListener(t,"end",$),i.addListener(t,"close",W),t[b]=!1,t.on("close",q),{version:"h2",defaultPipelining:1/0,write:t=>function(e,t){const a=t.bodyTimeout??e[v],g=e[y],{method:u,path:C,host:m,upgrade:S,expectContinue:D,signal:b,protocol:T,headers:Y}=t;let{body:V}=t;if(S)return i.errorRequest(e,t,new Error("Upgrade not supported for H2")),!1;const O={};for(let e=0;e<Y.length;e+=2){const t=Y[e+0],s=Y[e+1];if("cookie"!==t)if(Array.isArray(s))for(let e=0;e<s.length;e++)O[t]?O[t]+=`, ${s[e]}`:O[t]=s[e];else O[t]?O[t]+=`, ${s}`:O[t]=s;else null!=O[t]?O[t]=Array.isArray(O[t])?(O[t].push(s),O[t]):[O[t],s]:O[t]=s}let G=null;const{hostname:J,port:W}=e[l];O[F]=m||`${J}${W?`:${W}`:""}`,O[M]=u;const _=s=>{t.aborted||t.completed||(s=s||new o,i.errorRequest(e,t,s),null!=G&&(G.removeAllListeners("data"),G.close(),e[Q](s),e[w]()),i.destroy(V,s))};try{t.onConnect(_)}catch(s){i.errorRequest(e,t,s)}if(t.aborted)return!1;if("CONNECT"===u)return g.ref(),G=g.request(O,{endStream:!1,signal:b}),G.pending?G.once("ready",(()=>{t.onUpgrade(null,null,G),++g[N],e[E][e[p]++]=null})):(t.onUpgrade(null,null,G),++g[N],e[E][e[p]++]=null),G.once("close",(()=>{g[N]-=1,0===g[N]&&g.unref()})),G.setTimeout(a),!0;O[U]=C,O[L]="http:"===T?"http":"https";const $="PUT"===u||"POST"===u||"PATCH"===u;V&&"function"==typeof V.read&&V.read(0);let q=i.bodyLength(V);if(i.isFormDataLike(V)){k??=s(2530).extractBody;const[e,t]=k(V);O["content-type"]=t,V=e.stream,q=e.length}null==q&&(q=t.contentLength);0!==q&&$||(q=null);if(function(e){return"GET"!==e&&"HEAD"!==e&&"OPTIONS"!==e&&"TRACE"!==e&&"CONNECT"!==e}(u)&&q>0&&null!=t.contentLength&&t.contentLength!==q){if(e[f])return i.errorRequest(e,t,new A),!1;process.emitWarning(new A)}null!=q&&(r(V,"no body must not have content length"),O[P]=`${q}`);if(g.ref(),R.sendHeaders.hasSubscribers){let e="";for(const t in O)e+=`${t}: ${O[t]}\r\n`;R.sendHeaders.publish({request:t,headers:e,socket:g[B]})}const X="GET"===u||"HEAD"===u||null===V;D?(O[x]="100-continue",G=g.request(O,{endStream:X,signal:b}),G.once("continue",Z)):(G=g.request(O,{endStream:X,signal:b}),Z());return++g[N],G.setTimeout(a),G.once("response",(e=>{const{[H]:s,...r}=e;t.onResponseStarted(),t.aborted?G.removeAllListeners("data"):!1===t.onHeaders(Number(s),function(e){const t=[];for(const[s,r]of Object.entries(e))if(Array.isArray(r))for(const e of r)t.push(Buffer.from(s),Buffer.from(e));else t.push(Buffer.from(s),Buffer.from(r));return t}(r),G.resume.bind(G),"")&&G.pause()})),G.on("data",(e=>{!1===t.onData(e)&&G.pause()})),G.once("end",(s=>{G.removeAllListeners("data"),null==G.state?.state||G.state.state<6?(t.aborted||t.completed||t.onComplete({}),e[E][e[p]++]=null,e[w]()):(--g[N],0===g[N]&&g.unref(),_(s??new c("HTTP/2: stream half-closed (remote)")),e[E][e[p]++]=null,e[I]=e[p],e[w]())})),G.once("close",(()=>{G.removeAllListeners("data"),g[N]-=1,0===g[N]&&g.unref()})),G.once("error",(function(e){G.removeAllListeners("data"),_(e)})),G.once("frameError",((e,t)=>{G.removeAllListeners("data"),_(new c(`HTTP/2: "frameError" received - type ${e}, code ${t}`))})),G.on("aborted",(()=>{G.removeAllListeners("data")})),G.on("timeout",(()=>{const e=new c(`HTTP/2: "stream timeout after ${a}"`);G.removeAllListeners("data"),g[N]-=1,0===g[N]&&g.unref(),_(e)})),G.once("trailers",(e=>{t.aborted||t.completed||t.onComplete(e)})),!0;function Z(){V&&0!==q?i.isBuffer(V)?z(_,G,V,e,t,e[B],q,$):i.isBlobLike(V)?"function"==typeof V.stream?j(_,G,V.stream(),e,t,e[B],q,$):async function(e,t,s,n,i,o,a,c){r(a===s.size,"blob body must have content length");try{if(null!=a&&a!==s.size)throw new A;const e=Buffer.from(await s.arrayBuffer());t.cork(),t.write(e),t.uncork(),t.end(),i.onBodySent(e),i.onRequestSent(),c||(o[h]=!0),n[w]()}catch(t){e(t)}}(_,G,V,e,t,e[B],q,$):i.isStream(V)?function(e,t,s,A,o,a,c,l){r(0!==l||0===a[d],"stream body cannot be pipelined");const g=n(o,A,(r=>{r?(i.destroy(g,r),e(r)):(i.removeAllListeners(g),c.onRequestSent(),s||(t[h]=!0),a[w]())}));function u(e){c.onBodySent(e)}i.addListener(g,"data",u)}(_,e[B],$,G,V,e,t,q):i.isIterable(V)?j(_,G,V,e,t,e[B],q,$):r(!1):z(_,G,null,e,t,e[B],q,$)}}(e,t),resume(){!function(e){const t=e[B];!1===t?.destroyed&&(0===e[S]||0===e[m]?(t.unref(),e[y].unref()):(t.ref(),e[y].ref()))}(e)},destroy(e,s){t[b]?queueMicrotask(s):t.destroy(e).on("close",s)},get destroyed(){return t.destroyed},busy:()=>!1}}},1167:(e,t,s)=>{"use strict";const r=s(4589),n=s(7030),i=s(7067),A=s(2858),{ClientStats:o}=s(4304),{channels:a}=s(772),c=s(5837),l=s(7779),{InvalidArgumentError:h,InformationalError:g,ClientDestroyedError:d}=s(4465),u=s(1986),{kUrl:E,kServerName:I,kClient:p,kBusy:C,kConnect:B,kResuming:f,kRunning:Q,kPending:m,kSize:y,kQueue:w,kConnected:S,kConnecting:D,kNeedDrain:b,kKeepAliveDefaultTimeout:v,kHostHeader:R,kPendingIdx:N,kRunningIdx:k,kError:T,kPipelining:F,kKeepAliveTimeoutValue:M,kMaxHeadersSize:U,kKeepAliveMaxTimeout:L,kKeepAliveTimeoutThreshold:P,kHeadersTimeout:x,kBodyTimeout:H,kStrictContentLength:Y,kConnector:V,kMaxRequests:O,kCounter:G,kClose:J,kDestroy:W,kDispatch:_,kLocalAddress:$,kMaxResponseSize:q,kOnError:z,kHTTPContext:j,kMaxConcurrentStreams:X,kResume:Z}=s(257),K=s(9355),ee=s(8142),te=Symbol("kClosedResolve"),se=i&&i.maxHeaderSize&&Number.isInteger(i.maxHeaderSize)&&i.maxHeaderSize>0?()=>i.maxHeaderSize:()=>{throw new h("http module not available or http.maxHeaderSize invalid")},re=()=>{};function ne(e){return e[F]??e[j]?.defaultPipelining??1}function ie(e,t){if(0===e[Q]&&"UND_ERR_INFO"!==t.code&&"UND_ERR_SOCKET"!==t.code){r(e[N]===e[k]);const s=e[w].splice(e[k]);for(let r=0;r<s.length;r++){const n=s[r];A.errorRequest(e,n,t)}r(0===e[y])}}function Ae(e){r(!e[D]),r(!e[j]);let{host:t,hostname:s,protocol:i,port:o}=e[E];if("["===s[0]){const e=s.indexOf("]");r(-1!==e);const t=s.substring(1,e);r(n.isIPv6(t)),s=t}e[D]=!0,a.beforeConnect.hasSubscribers&&a.beforeConnect.publish({connectParams:{host:t,hostname:s,protocol:i,port:o,version:e[j]?.version,servername:e[I],localAddress:e[$]},connector:e[V]}),e[V]({host:t,hostname:s,protocol:i,port:o,servername:e[I],localAddress:e[$]},((n,c)=>{if(n)return oe(e,n,{host:t,hostname:s,protocol:i,port:o}),void e[Z]();if(e.destroyed)return A.destroy(c.on("error",re),new d),void e[Z]();r(c);try{e[j]="h2"===c.alpnProtocol?ee(e,c):K(e,c)}catch(n){return c.destroy().on("error",re),oe(e,n,{host:t,hostname:s,protocol:i,port:o}),void e[Z]()}e[D]=!1,c[G]=0,c[O]=e[O],c[p]=e,c[T]=null,a.connected.hasSubscribers&&a.connected.publish({connectParams:{host:t,hostname:s,protocol:i,port:o,version:e[j]?.version,servername:e[I],localAddress:e[$]},connector:e[V],socket:c}),e.emit("connect",e[E],[e]),e[Z]()}))}function oe(e,t,{host:s,hostname:n,protocol:i,port:o}){if(!e.destroyed){if(e[D]=!1,a.connectError.hasSubscribers&&a.connectError.publish({connectParams:{host:s,hostname:n,protocol:i,port:o,version:e[j]?.version,servername:e[I],localAddress:e[$]},connector:e[V],error:t}),"ERR_TLS_CERT_ALTNAME_INVALID"===t.code)for(r(0===e[Q]);e[m]>0&&e[w][e[N]].servername===e[I];){const s=e[w][e[N]++];A.errorRequest(e,s,t)}else ie(e,t);e.emit("connectionError",e[E],[e],t)}}function ae(e){e[b]=0,e.emit("drain",e[E],[e])}function ce(e,t){2!==e[f]&&(e[f]=2,function(e,t){for(;;){if(e.destroyed)return void r(0===e[m]);if(e[te]&&!e[y])return e[te](),void(e[te]=null);if(e[j]&&e[j].resume(),e[C])e[b]=2;else if(2===e[b]){t?(e[b]=1,queueMicrotask((()=>ae(e)))):ae(e);continue}if(0===e[m])return;if(e[Q]>=(ne(e)||1))return;const s=e[w][e[N]];if("https:"===e[E].protocol&&e[I]!==s.servername){if(e[Q]>0)return;e[I]=s.servername,e[j]?.destroy(new g("servername changed"),(()=>{e[j]=null,ce(e)}))}if(e[D])return;if(!e[j])return void Ae(e);if(e[j].destroyed)return;if(e[j].busy(s))return;!s.aborted&&e[j].write(s)?e[N]++:e[w].splice(e[N],1)}}(e,t),e[f]=0,e[k]>256&&(e[w].splice(0,e[k]),e[N]-=e[k],e[k]=0))}e.exports=class extends l{constructor(e,{maxHeaderSize:t,headersTimeout:s,socketTimeout:r,requestTimeout:i,connectTimeout:o,bodyTimeout:a,idleTimeout:c,keepAlive:l,keepAliveTimeout:g,maxKeepAliveTimeout:d,keepAliveMaxTimeout:p,keepAliveTimeoutThreshold:C,socketPath:B,pipelining:Q,tls:m,strictContentLength:y,maxCachedSessions:S,connect:D,maxRequestsPerClient:T,localAddress:G,maxResponseSize:J,autoSelectFamily:W,autoSelectFamilyAttemptTimeout:_,maxConcurrentStreams:K,allowH2:ee}={}){if(void 0!==l)throw new h("unsupported keepAlive, use pipelining=0 instead");if(void 0!==r)throw new h("unsupported socketTimeout, use headersTimeout & bodyTimeout instead");if(void 0!==i)throw new h("unsupported requestTimeout, use headersTimeout & bodyTimeout instead");if(void 0!==c)throw new h("unsupported idleTimeout, use keepAliveTimeout instead");if(void 0!==d)throw new h("unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead");if(null!=t){if(!Number.isInteger(t)||t<1)throw new h("invalid maxHeaderSize")}else t=se();if(null!=B&&"string"!=typeof B)throw new h("invalid socketPath");if(null!=o&&(!Number.isFinite(o)||o<0))throw new h("invalid connectTimeout");if(null!=g&&(!Number.isFinite(g)||g<=0))throw new h("invalid keepAliveTimeout");if(null!=p&&(!Number.isFinite(p)||p<=0))throw new h("invalid keepAliveMaxTimeout");if(null!=C&&!Number.isFinite(C))throw new h("invalid keepAliveTimeoutThreshold");if(null!=s&&(!Number.isInteger(s)||s<0))throw new h("headersTimeout must be a positive integer or zero");if(null!=a&&(!Number.isInteger(a)||a<0))throw new h("bodyTimeout must be a positive integer or zero");if(null!=D&&"function"!=typeof D&&"object"!=typeof D)throw new h("connect must be a function or an object");if(null!=T&&(!Number.isInteger(T)||T<0))throw new h("maxRequestsPerClient must be a positive number");if(null!=G&&("string"!=typeof G||0===n.isIP(G)))throw new h("localAddress must be valid string IP address");if(null!=J&&(!Number.isInteger(J)||J<-1))throw new h("maxResponseSize must be a positive number");if(null!=_&&(!Number.isInteger(_)||_<-1))throw new h("autoSelectFamilyAttemptTimeout must be a positive number");if(null!=ee&&"boolean"!=typeof ee)throw new h("allowH2 must be a valid boolean value");if(null!=K&&("number"!=typeof K||K<1))throw new h("maxConcurrentStreams must be a positive integer, greater than 0");super(),"function"!=typeof D&&(D=u({...m,maxCachedSessions:S,allowH2:ee,socketPath:B,timeout:o,..."boolean"==typeof W?{autoSelectFamily:W,autoSelectFamilyAttemptTimeout:_}:void 0,...D})),this[E]=A.parseOrigin(e),this[V]=D,this[F]=null!=Q?Q:1,this[U]=t,this[v]=null==g?4e3:g,this[L]=null==p?6e5:p,this[P]=null==C?2e3:C,this[M]=this[v],this[I]=null,this[$]=null!=G?G:null,this[f]=0,this[b]=0,this[R]=`host: ${this[E].hostname}${this[E].port?`:${this[E].port}`:""}\r\n`,this[H]=null!=a?a:3e5,this[x]=null!=s?s:3e5,this[Y]=null==y||y,this[O]=T,this[te]=null,this[q]=J>-1?J:-1,this[X]=null!=K?K:100,this[j]=null,this[w]=[],this[k]=0,this[N]=0,this[Z]=e=>ce(this,e),this[z]=e=>ie(this,e)}get pipelining(){return this[F]}set pipelining(e){this[F]=e,this[Z](!0)}get stats(){return new o(this)}get[m](){return this[w].length-this[N]}get[Q](){return this[N]-this[k]}get[y](){return this[w].length-this[k]}get[S](){return!!this[j]&&!this[D]&&!this[j].destroyed}get[C](){return Boolean(this[j]?.busy(null)||this[y]>=(ne(this)||1)||this[m]>0)}[B](e){Ae(this),this.once("connect",e)}[_](e,t){const s=new c(this[E].origin,e,t);return this[w].push(s),this[f]||(null==A.bodyLength(s.body)&&A.isIterable(s.body)?(this[f]=1,queueMicrotask((()=>ce(this)))):this[Z](!0)),this[f]&&2!==this[b]&&this[C]&&(this[b]=2),this[b]<2}[J](){return new Promise((e=>{this[y]?this[te]=e:e(null)}))}[W](e){return new Promise((t=>{const s=this[w].splice(this[N]);for(let t=0;t<s.length;t++){const r=s[t];A.errorRequest(this,r,e)}const r=()=>{this[te]&&(this[te](),this[te]=null),t(null)};this[j]?(this[j].destroy(e,r),this[j]=null):queueMicrotask(r),this[Z]()}))}}},7779:(e,t,s)=>{"use strict";const r=s(5497),n=s(4555),{ClientDestroyedError:i,ClientClosedError:A,InvalidArgumentError:o}=s(4465),{kDestroy:a,kClose:c,kClosed:l,kDestroyed:h,kDispatch:g}=s(257),d=Symbol("onDestroyed"),u=Symbol("onClosed");e.exports=class extends r{[h]=!1;[d]=null;[l]=!1;[u]=[];get destroyed(){return this[h]}get closed(){return this[l]}close(e){if(void 0===e)return new Promise(((e,t)=>{this.close(((s,r)=>s?t(s):e(r)))}));if("function"!=typeof e)throw new o("invalid callback");if(this[h])return void queueMicrotask((()=>e(new i,null)));if(this[l])return void(this[u]?this[u].push(e):queueMicrotask((()=>e(null,null))));this[l]=!0,this[u].push(e);const t=()=>{const e=this[u];this[u]=null;for(let t=0;t<e.length;t++)e[t](null,null)};this[c]().then((()=>this.destroy())).then((()=>{queueMicrotask(t)}))}destroy(e,t){if("function"==typeof e&&(t=e,e=null),void 0===t)return new Promise(((t,s)=>{this.destroy(e,((e,r)=>e?s(e):t(r)))}));if("function"!=typeof t)throw new o("invalid callback");if(this[h])return void(this[d]?this[d].push(t):queueMicrotask((()=>t(null,null))));e||(e=new i),this[h]=!0,this[d]=this[d]||[],this[d].push(t);const s=()=>{const e=this[d];this[d]=null;for(let t=0;t<e.length;t++)e[t](null,null)};this[a](e).then((()=>{queueMicrotask(s)}))}dispatch(e,t){if(!t||"object"!=typeof t)throw new o("handler must be an object");t=n.unwrap(t);try{if(!e||"object"!=typeof e)throw new o("opts must be an object.");if(this[h]||this[d])throw new i;if(this[l])throw new A;return this[g](e,t)}catch(e){if("function"!=typeof t.onError)throw e;return t.onError(e),!1}}}},5497:(e,t,s)=>{"use strict";const r=s(8474),n=s(832),i=e=>(t,s)=>e(t,n.wrap(s));e.exports=class extends r{dispatch(){throw new Error("not implemented")}close(){throw new Error("not implemented")}destroy(){throw new Error("not implemented")}compose(...e){const t=Array.isArray(e[0])?e[0]:e;let s=this.dispatch.bind(this);for(const e of t)if(null!=e){if("function"!=typeof e)throw new TypeError("invalid interceptor, expected function received "+typeof e);if(s=e(s),s=i(s),null==s||"function"!=typeof s||2!==s.length)throw new TypeError("invalid interceptor")}return new Proxy(this,{get:(e,t)=>"dispatch"===t?s:e[t]})}}},4667:(e,t,s)=>{"use strict";const r=s(7779),{kClose:n,kDestroy:i,kClosed:A,kDestroyed:o,kDispatch:a,kNoProxyAgent:c,kHttpProxyAgent:l,kHttpsProxyAgent:h}=s(257),g=s(9246),d=s(3315),u={"http:":80,"https:":443};e.exports=class extends r{#C=null;#B=null;#f=null;constructor(e={}){super(),this.#f=e;const{httpProxy:t,httpsProxy:s,noProxy:r,...n}=e;this[c]=new d(n);const i=t??process.env.http_proxy??process.env.HTTP_PROXY;this[l]=i?new g({...n,uri:i}):this[c];const A=s??process.env.https_proxy??process.env.HTTPS_PROXY;this[h]=A?new g({...n,uri:A}):this[l],this.#Q()}[a](e,t){const s=new URL(e.origin);return this.#m(s).dispatch(e,t)}[n](){return Promise.all([this[c].close(),!this[l][A]&&this[l].close(),!this[h][A]&&this[h].close()])}[i](e){return Promise.all([this[c].destroy(e),!this[l][o]&&this[l].destroy(e),!this[h][o]&&this[h].destroy(e)])}#m(e){let{protocol:t,host:s,port:r}=e;return s=s.replace(/:\d*$/,"").toLowerCase(),r=Number.parseInt(r,10)||u[t]||0,this.#y(s,r)?"https:"===t?this[h]:this[l]:this[c]}#y(e,t){if(this.#w&&this.#Q(),0===this.#B.length)return!0;if("*"===this.#C)return!1;for(let s=0;s<this.#B.length;s++){const r=this.#B[s];if(!r.port||r.port===t)if(/^[.*]/.test(r.hostname)){if(e.endsWith(r.hostname.replace(/^\*/,"")))return!1}else if(e===r.hostname)return!1}return!0}#Q(){const e=this.#f.noProxy??this.#S,t=e.split(/[,\s]/),s=[];for(let e=0;e<t.length;e++){const r=t[e];if(!r)continue;const n=r.match(/^(.+):(\d+)$/);s.push({hostname:(n?n[1]:r).toLowerCase(),port:n?Number.parseInt(n[2],10):0})}this.#C=e,this.#B=s}get#w(){return void 0===this.#f.noProxy&&this.#C!==this.#S}get#S(){return process.env.no_proxy??process.env.NO_PROXY??""}}},1726:e=>{"use strict";const t=2047;class s{bottom=0;top=0;list=new Array(2048).fill(void 0);next=null;isEmpty(){return this.top===this.bottom}isFull(){return(this.top+1&t)===this.bottom}push(e){this.list[this.top]=e,this.top=this.top+1&t}shift(){const e=this.list[this.bottom];return void 0===e?null:(this.list[this.bottom]=void 0,this.bottom=this.bottom+1&t,e)}}e.exports=class{constructor(){this.head=this.tail=new s}isEmpty(){return this.head.isEmpty()}push(e){this.head.isFull()&&(this.head=this.head.next=new s),this.head.push(e)}shift(){const e=this.tail,t=e.shift();return e.isEmpty()&&null!==e.next&&(this.tail=e.next,e.next=null),t}}},8297:(e,t,s)=>{"use strict";const{connect:r}=s(7030),{kClose:n,kDestroy:i}=s(257),{InvalidArgumentError:A}=s(4465),o=s(2858),a=s(1167),c=s(7779);e.exports=class extends c{#D=null;constructor(e,t){if("string"==typeof e&&(e=new URL(e)),"http:"!==e.protocol)throw new A("h2c-client: Only h2c protocol is supported");const{connect:s,maxConcurrentStreams:r,pipelining:n,...i}=t??{};let o=100,c=100;if(null!=r&&Number.isInteger(r)&&r>0&&(o=r),null!=n&&Number.isInteger(n)&&n>0&&(c=n),c>o)throw new A("h2c-client: pipelining cannot be greater than maxConcurrentStreams");super(),this.#D=new a(e,{...i,connect:this.#b(s),maxConcurrentStreams:o,pipelining:c,allowH2:!0})}#b(e){return(t,s)=>{const n=e?.connectOpts??1e4,{hostname:i,port:A,pathname:a}=t,c=r({...t,host:i,port:A,pathname:a});if(null==t.keepAlive||t.keepAlive){const e=null==t.keepAliveInitialDelay?6e4:t.keepAliveInitialDelay;c.setKeepAlive(!0,e)}c.alpnProtocol="h2";const l=o.setupConnectTimeout(new WeakRef(c),{timeout:n,hostname:i,port:A});return c.setNoDelay(!0).once("connect",(function(){if(queueMicrotask(l),s){const e=s;s=null,e(null,this)}})).on("error",(function(e){if(queueMicrotask(l),s){const t=s;s=null,t(e)}})),c}}dispatch(e,t){return this.#D.dispatch(e,t)}[n](){return this.#D.close()}[i](){return this.#D.destroy()}}},1694:(e,t,s)=>{"use strict";const{PoolStats:r}=s(4304),n=s(7779),i=s(1726),{kConnected:A,kSize:o,kRunning:a,kPending:c,kQueued:l,kBusy:h,kFree:g,kUrl:d,kClose:u,kDestroy:E,kDispatch:I}=s(257),p=Symbol("clients"),C=Symbol("needDrain"),B=Symbol("queue"),f=Symbol("closed resolve"),Q=Symbol("onDrain"),m=Symbol("onConnect"),y=Symbol("onDisconnect"),w=Symbol("onConnectionError"),S=Symbol("get dispatcher"),D=Symbol("add client"),b=Symbol("remove client");e.exports={PoolBase:class extends n{[B]=new i;[l]=0;[p]=[];[C]=!1;[Q](e,t,s){const r=this[B];let n=!1;for(;!n;){const t=r.shift();if(!t)break;this[l]--,n=!e.dispatch(t.opts,t.handler)}if(e[C]=n,!n&&this[C]&&(this[C]=!1,this.emit("drain",t,[this,...s])),this[f]&&r.isEmpty()){const e=new Array(this[p].length);for(let t=0;t<this[p].length;t++)e[t]=this[p][t].close();Promise.all(e).then(this[f])}}[m]=(e,t)=>{this.emit("connect",e,[this,...t])};[y]=(e,t,s)=>{this.emit("disconnect",e,[this,...t],s)};[w]=(e,t,s)=>{this.emit("connectionError",e,[this,...t],s)};get[h](){return this[C]}get[A](){let e=0;for(const{[A]:t}of this[p])e+=t;return e}get[g](){let e=0;for(const{[A]:t,[C]:s}of this[p])e+=t&&!s;return e}get[c](){let e=this[l];for(const{[c]:t}of this[p])e+=t;return e}get[a](){let e=0;for(const{[a]:t}of this[p])e+=t;return e}get[o](){let e=this[l];for(const{[o]:t}of this[p])e+=t;return e}get stats(){return new r(this)}[u](){if(this[B].isEmpty()){const e=new Array(this[p].length);for(let t=0;t<this[p].length;t++)e[t]=this[p][t].close();return Promise.all(e)}return new Promise((e=>{this[f]=e}))}[E](e){for(;;){const t=this[B].shift();if(!t)break;t.handler.onError(e)}const t=new Array(this[p].length);for(let s=0;s<this[p].length;s++)t[s]=this[p][s].destroy(e);return Promise.all(t)}[I](e,t){const s=this[S]();return s?s.dispatch(e,t)||(s[C]=!0,this[C]=!this[S]()):(this[C]=!0,this[B].push({opts:e,handler:t}),this[l]++),!this[C]}[D](e){return e.on("drain",this[Q].bind(this,e)).on("connect",this[m]).on("disconnect",this[y]).on("connectionError",this[w]),this[p].push(e),this[C]&&queueMicrotask((()=>{this[C]&&this[Q](e,e[d],[e,this])})),this}[b](e){e.close((()=>{const t=this[p].indexOf(e);-1!==t&&this[p].splice(t,1)})),this[C]=this[p].some((e=>!e[C]&&!0!==e.closed&&!0!==e.destroyed))}},kClients:p,kNeedDrain:C,kAddClient:D,kRemoveClient:b,kGetDispatcher:S}},8542:(e,t,s)=>{"use strict";const{PoolBase:r,kClients:n,kNeedDrain:i,kAddClient:A,kGetDispatcher:o,kRemoveClient:a}=s(1694),c=s(1167),{InvalidArgumentError:l}=s(4465),h=s(2858),{kUrl:g}=s(257),d=s(1986),u=Symbol("options"),E=Symbol("connections"),I=Symbol("factory");function p(e,t){return new c(e,t)}e.exports=class extends r{constructor(e,{connections:t,factory:s=p,connect:r,connectTimeout:i,tls:A,maxCachedSessions:o,socketPath:a,autoSelectFamily:c,autoSelectFamilyAttemptTimeout:C,allowH2:B,clientTtl:f,...Q}={}){if(null!=t&&(!Number.isFinite(t)||t<0))throw new l("invalid connections");if("function"!=typeof s)throw new l("factory must be a function.");if(null!=r&&"function"!=typeof r&&"object"!=typeof r)throw new l("connect must be a function or an object");"function"!=typeof r&&(r=d({...A,maxCachedSessions:o,allowH2:B,socketPath:a,timeout:i,..."boolean"==typeof c?{autoSelectFamily:c,autoSelectFamilyAttemptTimeout:C}:void 0,...r})),super(),this[E]=t||null,this[g]=h.parseOrigin(e),this[u]={...h.deepClone(Q),connect:r,allowH2:B,clientTtl:f},this[u].interceptors=Q.interceptors?{...Q.interceptors}:void 0,this[I]=s,this.on("connect",((e,t)=>{if(null!=f&&f>0)for(const e of t)Object.assign(e,{ttl:Date.now()})})),this.on("connectionError",((e,t,s)=>{for(const e of t){const t=this[n].indexOf(e);-1!==t&&this[n].splice(t,1)}}))}[o](){const e=this[u].clientTtl;for(const t of this[n])if(null!=e&&e>0&&t.ttl&&Date.now()-t.ttl>e)this[a](t);else if(!t[i])return t;if(!this[E]||this[n].length<this[E]){const e=this[I](this[g],this[u]);return this[A](e),e}}}},9246:(e,t,s)=>{"use strict";const{kProxy:r,kClose:n,kDestroy:i,kDispatch:A}=s(257),o=s(3315),a=s(8542),c=s(7779),{InvalidArgumentError:l,RequestAbortedError:h,SecureProxyConnectionError:g}=s(4465),d=s(1986),u=s(1167),E=Symbol("proxy agent"),I=Symbol("proxy client"),p=Symbol("proxy headers"),C=Symbol("request tls settings"),B=Symbol("proxy tls settings"),f=Symbol("connect endpoint function"),Q=Symbol("tunnel proxy");function m(e,t){return new a(e,t)}const y=()=>{};function w(e,t){return 1===t.connections?new u(e,t):new a(e,t)}class S extends c{#D;constructor(e,{headers:t={},connect:s,factory:r}){if(!e)throw new l("Proxy URL is mandatory");super(),this[p]=t,this.#D=r?r(e,{connect:s}):new u(e,{connect:s})}[A](e,t){const s=t.onHeaders;t.onHeaders=function(e,r,n){407!==e?s&&s.call(this,e,r,n):"function"==typeof t.onError&&t.onError(new l("Proxy Authentication Required (407)"))};const{origin:r,path:n="/",headers:i={}}=e;if(e.path=r+n,!("host"in i)&&!("Host"in i)){const{host:e}=new URL(r);i.host=e}return e.headers={...this[p],...i},this.#D[A](e,t)}[n](){return this.#D.close()}[i](e){return this.#D.destroy(e)}}e.exports=class extends c{constructor(e){if(!e||"object"==typeof e&&!(e instanceof URL)&&!e.uri)throw new l("Proxy uri is mandatory");const{clientFactory:t=m}=e;if("function"!=typeof t)throw new l("Proxy opts.clientFactory must be a function.");const{proxyTunnel:s=!0}=e;super();const n=this.#v(e),{href:i,origin:A,port:a,protocol:c,username:u,password:D,hostname:b}=n;if(this[r]={uri:i,protocol:c},this[C]=e.requestTls,this[B]=e.proxyTls,this[p]=e.headers||{},this[Q]=s,e.auth&&e.token)throw new l("opts.auth cannot be used in combination with opts.token");e.auth?this[p]["proxy-authorization"]=`Basic ${e.auth}`:e.token?this[p]["proxy-authorization"]=e.token:u&&D&&(this[p]["proxy-authorization"]=`Basic ${Buffer.from(`${decodeURIComponent(u)}:${decodeURIComponent(D)}`).toString("base64")}`);const v=d({...e.proxyTls});this[f]=d({...e.requestTls});const R=e.factory||w;this[I]=t(n,{connect:v}),this[E]=new o({...e,factory:(e,t)=>{const{protocol:s}=new URL(e);return this[Q]||"http:"!==s||"http:"!==this[r].protocol?R(e,t):new S(this[r].uri,{headers:this[p],connect:v,factory:R})},connect:async(e,t)=>{let s=e.host;e.port||(s+=`:${function(e){return"https:"===e?443:80}(e.protocol)}`);try{const{socket:r,statusCode:n}=await this[I].connect({origin:A,port:a,path:s,signal:e.signal,headers:{...this[p],host:e.host,...null==e.connections||e.connections>0?{"proxy-connection":"keep-alive"}:{}},servername:this[B]?.servername||b});if(200!==n&&(r.on("error",y).destroy(),t(new h(`Proxy response (${n}) !== 200 when HTTP Tunneling`))),"https:"!==e.protocol)return void t(null,r);let i;i=this[C]?this[C].servername:e.servername,this[f]({...e,servername:i,httpSocket:r},t)}catch(e){"ERR_TLS_CERT_ALTNAME_INVALID"===e.code?t(new g(e)):t(e)}}})}dispatch(e,t){const s=function(e){if(Array.isArray(e)){const t={};for(let s=0;s<e.length;s+=2)t[e[s]]=e[s+1];return t}return e}(e.headers);if(function(e){const t=e&&Object.keys(e).find((e=>"proxy-authorization"===e.toLowerCase()));if(t)throw new l("Proxy-Authorization should be sent in ProxyAgent constructor")}(s),s&&!("host"in s)&&!("Host"in s)){const{host:t}=new URL(e.origin);s.host=t}return this[E].dispatch({...e,headers:s},t)}#v(e){return"string"==typeof e?new URL(e):e instanceof URL?e:new URL(e.uri)}[n](){return Promise.all([this[E].close(),this[I].close()])}[i](){return Promise.all([this[E].destroy(),this[I].destroy()])}}},8712:(e,t,s)=>{"use strict";const r=s(5497),n=s(6294);e.exports=class extends r{#R=null;#N=null;constructor(e,t={}){super(t),this.#R=e,this.#N=t}dispatch(e,t){const s=new n({...e,retryOptions:this.#N},{dispatch:this.#R.dispatch.bind(this.#R),handler:t});return this.#R.dispatch(e,s)}close(){return this.#R.close()}destroy(){return this.#R.destroy()}}},9879:(e,t,s)=>{"use strict";const r=Symbol.for("undici.globalDispatcher.1"),{InvalidArgumentError:n}=s(4465),i=s(3315);function A(e){if(!e||"function"!=typeof e.dispatch)throw new n("Argument agent must implement Agent");Object.defineProperty(globalThis,r,{value:e,writable:!0,enumerable:!1,configurable:!1})}function o(){return globalThis[r]}void 0===o()&&A(new i);e.exports={setGlobalDispatcher:A,getGlobalDispatcher:o,installedExports:["fetch","Headers","Response","Request","FormData","WebSocket","CloseEvent","ErrorEvent","MessageEvent","EventSource"]}},8358:(e,t,s)=>{"use strict";const r=s(2858),{parseCacheControlHeader:n,parseVaryHeader:i,isEtagUsable:A}=s(9453),{parseHttpDate:o}=s(8851);function a(){}const c=[200,203,204,206,300,301,308,404,405,410,414,501],l=[206,304];e.exports=class{#k;#T;#F;#M;#U;#L;constructor({store:e,type:t,cacheByDefault:s},r,n){this.#M=e,this.#T=t,this.#F=s,this.#k=r,this.#U=n}onRequestStart(e,t){this.#L?.destroy(),this.#L=void 0,this.#U.onRequestStart?.(e,t)}onRequestUpgrade(e,t,s,r){this.#U.onRequestUpgrade?.(e,t,s,r)}onResponseStart(e,t,s,h){const g=()=>this.#U.onResponseStart?.(e,t,s,h);if(!r.safeHTTPMethods.includes(this.#k.method)&&t>=200&&t<=399){try{this.#M.delete(this.#k)?.catch?.(a)}catch{}return g()}const d=s["cache-control"],u=s["last-modified"]&&c.includes(t);if(!(d||s.expires||u||this.#F))return g();const E=d?n(d):{};if(!function(e,t,s,r){if(t<200||l.includes(t))return!1;if(!(c.includes(t)||s.expires||r.public||void 0!==r["max-age"]||r.private&&"private"===e||void 0!==r["s-maxage"]&&"shared"===e))return!1;if(r["no-store"])return!1;if("shared"===e&&!0===r.private)return!1;if(s.vary?.includes("*"))return!1;if(s.authorization){if(!r.public||"string"!=typeof s.authorization)return!1;if(Array.isArray(r["no-cache"])&&r["no-cache"].includes("authorization"))return!1;if(Array.isArray(r.private)&&r.private.includes("authorization"))return!1}return!0}(this.#T,t,s,E))return g();const I=Date.now(),p=s.age?function(e){const t=parseInt(Array.isArray(e)?e[0]:e);return isNaN(t)?void 0:1e3*t}(s.age):void 0;if(p&&p>=2147483647e3)return g();const C="string"==typeof s.date?o(s.date):void 0,B=function(e,t,s,r,n,i){if("shared"===e){const e=i["s-maxage"];if(void 0!==e)return e>0?1e3*e:void 0}const A=i["max-age"];if(void 0!==A)return A>0?1e3*A:void 0;if("string"==typeof r.expires){const e=o(r.expires);if(e){if(t>=e.getTime())return;if(n){if(n>=e)return;if(void 0!==s&&s>e-n)return}return e.getTime()-t}}if("string"==typeof r["last-modified"]){const e=new Date(r["last-modified"]);if((a=e)instanceof Date&&Number.isFinite(a.valueOf())){if(e.getTime()>=t)return;return.1*(t-e.getTime())}}var a;if(i.immutable)return 31536e3;return}(this.#T,I,p,s,C,E)??this.#F;if(void 0===B||p&&p>B)return g();const f=C?C.getTime():I,Q=B+f;if(I>=Q)return g();let m;if(this.#k.headers&&s.vary&&(m=i(s.vary,this.#k.headers),!m))return g();const y=function(e,t,s){let r=-1/0,n=-1/0,i=-1/0;t["stale-while-revalidate"]&&(r=s+1e3*t["stale-while-revalidate"]);t["stale-if-error"]&&(n=s+1e3*t["stale-if-error"]);r===-1/0&&n===-1/0&&(i=e+31536e6);return Math.max(s,r,n,i)}(f,E,Q),w=function(e,t){const s=["connection","proxy-authenticate","proxy-authentication-info","proxy-authorization","proxy-connection","te","transfer-encoding","upgrade","age"];e.connection&&(Array.isArray(e.connection)?s.push(...e.connection.map((e=>e.trim()))):s.push(...e.connection.split(",").map((e=>e.trim()))));Array.isArray(t["no-cache"])&&s.push(...t["no-cache"]);Array.isArray(t.private)&&s.push(...t.private);let r;for(const t of s)e[t]&&(r??={...e},delete r[t]);return r??e}(s,E),S={statusCode:t,statusMessage:h,headers:w,vary:m,cacheControlDirectives:E,cachedAt:p?I-p:I,staleAt:Q,deleteAt:y};if("string"==typeof s.etag&&A(s.etag)&&(S.etag=s.etag),this.#L=this.#M.createWriteStream(this.#k,S),!this.#L)return g();const D=this;return this.#L.on("drain",(()=>e.resume())).on("error",(function(){D.#L=void 0,D.#M.delete(D.#k)})).on("close",(function(){D.#L===this&&(D.#L=void 0),e.resume()})),g()}onResponseData(e,t){!1===this.#L?.write(t)&&e.pause(),this.#U.onResponseData?.(e,t)}onResponseEnd(e,t){this.#L?.end(),this.#U.onResponseEnd?.(e,t)}onResponseError(e,t){this.#L?.destroy(t),this.#L=void 0,this.#U.onResponseError?.(e,t)}}},6607:(e,t,s)=>{"use strict";const r=s(4589);e.exports=class{#P=!1;#x;#U;#H;#Y;constructor(e,t,s){if("function"!=typeof e)throw new TypeError("callback must be a function");this.#x=e,this.#U=t,this.#Y=s}onRequestStart(e,t){this.#P=!1,this.#H=t}onRequestUpgrade(e,t,s,r){this.#U.onRequestUpgrade?.(e,t,s,r)}onResponseStart(e,t,s,n){if(r(null!=this.#x),this.#P=304===t||this.#Y&&t>=500&&t<=504,this.#x(this.#P,this.#H),this.#x=null,this.#P)return!0;this.#U.onRequestStart?.(e,this.#H),this.#U.onResponseStart?.(e,t,s,n)}onResponseData(e,t){if(!this.#P)return this.#U.onResponseData?.(e,t)}onResponseEnd(e,t){this.#P||this.#U.onResponseEnd?.(e,t)}onResponseError(e,t){if(!this.#P){if(this.#x&&(this.#x(!1),this.#x=null),"function"!=typeof this.#U.onResponseError)throw t;this.#U.onResponseError(e,t)}}}},6917:(e,t,s)=>{"use strict";const r=s(4589),n=s(832);e.exports=class{#U;#V=!1;#O=!1;#G=!1;constructor(e){if("object"!=typeof e||null===e)throw new TypeError("handler must be an object");this.#U=n.wrap(e)}onRequestStart(...e){this.#U.onRequestStart?.(...e)}onRequestUpgrade(...e){return r(!this.#V),r(!this.#O),this.#U.onRequestUpgrade?.(...e)}onResponseStart(...e){return r(!this.#V),r(!this.#O),r(!this.#G),this.#G=!0,this.#U.onResponseStart?.(...e)}onResponseData(...e){return r(!this.#V),r(!this.#O),this.#U.onResponseData?.(...e)}onResponseEnd(...e){return r(!this.#V),r(!this.#O),this.#V=!0,this.#U.onResponseEnd?.(...e)}onResponseError(...e){return this.#O=!0,this.#U.onResponseError?.(...e)}onBodySent(){}}},8064:(e,t,s)=>{"use strict";const r=s(2858),{kBodyUsed:n}=s(257),i=s(4589),{InvalidArgumentError:A}=s(4465),o=s(8474),a=[300,301,302,303,307,308],c=Symbol("body"),l=()=>{};class h{constructor(e){this[c]=e,this[n]=!1}async*[Symbol.asyncIterator](){i(!this[n],"disturbed"),this[n]=!0,yield*this[c]}}class g{static buildDispatch(e,t){if(null!=t&&(!Number.isInteger(t)||t<0))throw new A("maxRedirections must be a positive number");const s=e.dispatch.bind(e);return(e,r)=>s(e,new g(s,t,e,r))}constructor(e,t,s,a){if(null!=t&&(!Number.isInteger(t)||t<0))throw new A("maxRedirections must be a positive number");this.dispatch=e,this.location=null;const{maxRedirections:c,...l}=s;this.opts=l,this.maxRedirections=t,this.handler=a,this.history=[],r.isStream(this.opts.body)?(0===r.bodyLength(this.opts.body)&&this.opts.body.on("data",(function(){i(!1)})),"boolean"!=typeof this.opts.body.readableDidRead&&(this.opts.body[n]=!1,o.prototype.on.call(this.opts.body,"data",(function(){this[n]=!0})))):(this.opts.body&&"function"==typeof this.opts.body.pipeTo||this.opts.body&&"string"!=typeof this.opts.body&&!ArrayBuffer.isView(this.opts.body)&&r.isIterable(this.opts.body)&&!r.isFormDataLike(this.opts.body))&&(this.opts.body=new h(this.opts.body))}onRequestStart(e,t){this.handler.onRequestStart?.(e,{...t,history:this.history})}onRequestUpgrade(e,t,s,r){this.handler.onRequestUpgrade?.(e,t,s,r)}onResponseStart(e,t,s,n){if(this.opts.throwOnMaxRedirect&&this.history.length>=this.maxRedirections)throw new Error("max redirects");if(301!==t&&302!==t||"POST"!==this.opts.method||(this.opts.method="GET",r.isStream(this.opts.body)&&r.destroy(this.opts.body.on("error",l)),this.opts.body=null),303===t&&"HEAD"!==this.opts.method&&(this.opts.method="GET",r.isStream(this.opts.body)&&r.destroy(this.opts.body.on("error",l)),this.opts.body=null),this.location=this.history.length>=this.maxRedirections||r.isDisturbed(this.opts.body)||-1===a.indexOf(t)?null:s.location,this.opts.origin&&this.history.push(new URL(this.opts.path,this.opts.origin)),!this.location)return void this.handler.onResponseStart?.(e,t,s,n);const{origin:o,pathname:c,search:h}=r.parseURL(new URL(this.location,this.opts.origin&&new URL(this.opts.path,this.opts.origin))),g=h?`${c}${h}`:c,u=`${o}${g}`;for(const e of this.history)if(e.toString()===u)throw new A(`Redirect loop detected. Cannot redirect to ${o}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);this.opts.headers=function(e,t,s){const r=[];if(Array.isArray(e))for(let n=0;n<e.length;n+=2)d(e[n],t,s)||r.push(e[n],e[n+1]);else if(e&&"object"==typeof e){const n="function"==typeof e[Symbol.iterator]?e:Object.entries(e);for(const[e,i]of n)d(e,t,s)||r.push(e,i)}else i(null==e,"headers must be an object or an array");return r}(this.opts.headers,303===t,this.opts.origin!==o),this.opts.path=g,this.opts.origin=o,this.opts.query=null}onResponseData(e,t){this.location||this.handler.onResponseData?.(e,t)}onResponseEnd(e,t){this.location?this.dispatch(this.opts,this):this.handler.onResponseEnd(e,t)}onResponseError(e,t){this.handler.onResponseError?.(e,t)}}function d(e,t,s){if(4===e.length)return"host"===r.headerNameToString(e);if(t&&r.headerNameToString(e).startsWith("content-"))return!0;if(s&&(13===e.length||6===e.length||19===e.length)){const t=r.headerNameToString(e);return"authorization"===t||"cookie"===t||"proxy-authorization"===t}return!1}e.exports=g},6294:(e,t,s)=>{"use strict";const r=s(4589),{kRetryHandlerDefaultRetry:n}=s(257),{RequestRetryError:i}=s(4465),A=s(832),{isDisturbed:o,parseRangeHeader:a,wrapRequestBody:c}=s(2858);class l{constructor(e,{dispatch:t,handler:s}){const{retryOptions:r,...i}=e,{retry:o,maxRetries:a,maxTimeout:h,minTimeout:g,timeoutFactor:d,methods:u,errorCodes:E,retryAfter:I,statusCodes:p,throwOnError:C}=r??{};this.error=null,this.dispatch=t,this.handler=A.wrap(s),this.opts={...i,body:c(e.body)},this.retryOpts={throwOnError:C??!0,retry:o??l[n],retryAfter:I??!0,maxTimeout:h??3e4,minTimeout:g??500,timeoutFactor:d??2,maxRetries:a??5,methods:u??["GET","HEAD","OPTIONS","PUT","DELETE","TRACE"],statusCodes:p??[500,502,503,504,429],errorCodes:E??["ECONNRESET","ECONNREFUSED","ENOTFOUND","ENETDOWN","ENETUNREACH","EHOSTDOWN","EHOSTUNREACH","EPIPE","UND_ERR_SOCKET"]},this.retryCount=0,this.retryCountCheckpoint=0,this.headersSent=!1,this.start=0,this.end=null,this.etag=null}onResponseStartWithRetry(e,t,s,r,n){if(this.retryOpts.throwOnError)!1===this.retryOpts.statusCodes.includes(t)?(this.headersSent=!0,this.handler.onResponseStart?.(e,t,s,r)):this.error=n;else{if(o(this.opts.body))return this.headersSent=!0,void this.handler.onResponseStart?.(e,t,s,r);e.pause(),this.retryOpts.retry(n,{state:{counter:this.retryCount},opts:{retryOptions:this.retryOpts,...this.opts}},function(i){if(i)return this.headersSent=!0,this.headersSent=!0,this.handler.onResponseStart?.(e,t,s,r),void e.resume();this.error=n,e.resume()}.bind(this))}}onRequestStart(e,t){this.headersSent||this.handler.onRequestStart?.(e,t)}onRequestUpgrade(e,t,s,r){this.handler.onRequestUpgrade?.(e,t,s,r)}static[n](e,{state:t,opts:s},r){const{statusCode:n,code:i,headers:A}=e,{method:o,retryOptions:a}=s,{maxRetries:c,minTimeout:l,maxTimeout:h,timeoutFactor:g,statusCodes:d,errorCodes:u,methods:E}=a,{counter:I}=t;if(i&&"UND_ERR_REQ_RETRY"!==i&&!u.includes(i))return void r(e);if(Array.isArray(E)&&!E.includes(o))return void r(e);if(null!=n&&Array.isArray(d)&&!d.includes(n))return void r(e);if(I>c)return void r(e);let p=A?.["retry-after"];p&&(p=Number(p),p=Number.isNaN(p)?function(e){const t=new Date(e).getTime();return isNaN(t)?0:t-Date.now()}(A["retry-after"]):1e3*p);const C=p>0?Math.min(p,h):Math.min(l*g**(I-1),h);setTimeout((()=>r(null)),C)}onResponseStart(e,t,s,n){if(this.error=null,this.retryCount+=1,t>=300){const r=new i("Request failed",t,{headers:s,data:{count:this.retryCount}});this.onResponseStartWithRetry(e,t,s,n,r)}else{if(this.headersSent){if(206!==t&&(this.start>0||200!==t))throw new i("server does not support the range header and the payload was partially consumed",t,{headers:s,data:{count:this.retryCount}});const e=a(s["content-range"]);if(!e)throw new i("Content-Range mismatch",t,{headers:s,data:{count:this.retryCount}});if(null!=this.etag&&this.etag!==s.etag)throw new i("ETag mismatch",t,{headers:s,data:{count:this.retryCount}});const{start:n,size:A,end:o=(A?A-1:null)}=e;return r(this.start===n,"content-range mismatch"),void r(null==this.end||this.end===o,"content-range mismatch")}if(null!=this.end)throw new i("Request failed",t,{headers:s,data:{count:this.retryCount}});if(206===t){const i=a(s["content-range"]);if(null==i)return this.headersSent=!0,void this.handler.onResponseStart?.(e,t,s,n);const{start:A,size:o,end:c=(o?o-1:null)}=i;r(null!=A&&Number.isFinite(A),"content-range mismatch"),r(null!=c&&Number.isFinite(c),"invalid content-length"),this.start=A,this.end=c}if(null==this.end){const e=s["content-length"];this.end=null!=e?Number(e)-1:null}r(Number.isFinite(this.start)),r(null==this.end||Number.isFinite(this.end),"invalid content-length"),this.resume=!0,this.etag=null!=s.etag?s.etag:null,null!=this.etag&&"W"===this.etag[0]&&"/"===this.etag[1]&&(this.etag=null),this.headersSent=!0,this.handler.onResponseStart?.(e,t,s,n)}}onResponseData(e,t){this.error||(this.start+=t.length,this.handler.onResponseData?.(e,t))}onResponseEnd(e,t){if(this.error&&this.retryOpts.throwOnError)throw this.error;if(!this.error)return this.retryCount=0,this.handler.onResponseEnd?.(e,t);this.retry(e)}retry(e){if(0!==this.start){const e={range:`bytes=${this.start}-${this.end??""}`};null!=this.etag&&(e["if-match"]=this.etag),this.opts={...this.opts,headers:{...this.opts.headers,...e}}}try{this.retryCountCheckpoint=this.retryCount,this.dispatch(this.opts,this)}catch(t){this.handler.onResponseError?.(e,t)}}onResponseError(e,t){e?.aborted||o(this.opts.body)?this.handler.onResponseError?.(e,t):(this.retryCount-this.retryCountCheckpoint>0?this.retryCount=this.retryCountCheckpoint+(this.retryCount-this.retryCountCheckpoint):this.retryCount+=1,this.retryOpts.retry(t,{state:{counter:this.retryCount},opts:{retryOptions:this.retryOpts,...this.opts}},function(t){t?this.handler?.onResponseError?.(e,t):this.retry(e)}.bind(this)))}}e.exports=l},4555:(e,t,s)=>{"use strict";const{parseHeaders:r}=s(2858),{InvalidArgumentError:n}=s(4465),i=Symbol("resume");class A{#J=!1;#W=null;#_=!1;#$;[i]=null;constructor(e){this.#$=e}pause(){this.#J=!0}resume(){this.#J&&(this.#J=!1,this[i]?.())}abort(e){this.#_||(this.#_=!0,this.#W=e,this.#$(e))}get aborted(){return this.#_}get reason(){return this.#W}get paused(){return this.#J}}e.exports=class e{#U;#q;constructor(e){this.#U=e}static unwrap(t){return t.onRequestStart?new e(t):t}onConnect(e,t){this.#q=new A(e),this.#U.onRequestStart?.(this.#q,t)}onUpgrade(e,t,s){this.#U.onRequestUpgrade?.(this.#q,e,r(t),s)}onHeaders(e,t,s,n){return this.#q[i]=s,this.#U.onResponseStart?.(this.#q,e,r(t),n),!this.#q.paused}onData(e){return this.#U.onResponseData?.(this.#q,e),!this.#q.paused}onComplete(e){this.#U.onResponseEnd?.(this.#q,r(e))}onError(e){if(!this.#U.onResponseError)throw new n("invalid onError method");this.#U.onResponseError?.(this.#q,e)}}},832:(e,t,s)=>{"use strict";const{InvalidArgumentError:r}=s(4465);e.exports=class e{#U;constructor(e){this.#U=e}static wrap(t){return t.onRequestStart?t:new e(t)}onConnect(e,t){return this.#U.onConnect?.(e,t)}onHeaders(e,t,s,r){return this.#U.onHeaders?.(e,t,s,r)}onUpgrade(e,t,s){return this.#U.onUpgrade?.(e,t,s)}onData(e){return this.#U.onData?.(e)}onComplete(e){return this.#U.onComplete?.(e)}onError(e){if(!this.#U.onError)throw e;return this.#U.onError?.(e)}onRequestStart(e,t){this.#U.onConnect?.((t=>e.abort(t)),t)}onRequestUpgrade(e,t,s,r){const n=[];for(const[e,t]of Object.entries(s))n.push(Buffer.from(e),Array.isArray(t)?t.map((e=>Buffer.from(e))):Buffer.from(t));this.#U.onUpgrade?.(t,n,r)}onResponseStart(e,t,s,r){const n=[];for(const[e,t]of Object.entries(s))n.push(Buffer.from(e),Array.isArray(t)?t.map((e=>Buffer.from(e))):Buffer.from(t));!1===this.#U.onHeaders?.(t,n,(()=>e.resume()),r)&&e.pause()}onResponseData(e,t){!1===this.#U.onData?.(t)&&e.pause()}onResponseEnd(e,t){const s=[];for(const[e,r]of Object.entries(t))s.push(Buffer.from(e),Array.isArray(r)?r.map((e=>Buffer.from(e))):Buffer.from(r));this.#U.onComplete?.(s)}onResponseError(e,t){if(!this.#U.onError)throw new r("invalid onError method");this.#U.onError?.(t)}}},5752:(e,t,s)=>{"use strict";const r=s(4589),{Readable:n}=s(7075),i=s(2858),A=s(8358),o=s(9903),a=s(6607),{assertCacheStore:c,assertCacheMethods:l,makeCacheKey:h,normalizeHeaders:g,parseCacheControlHeader:d}=s(9453),{AbortError:u}=s(4465);function E(e,t,s,A,o,a){const c=i.isStream(s.body)?s.body:n.from(s.body??[]);r(!c.destroyed,"stream should not be destroyed"),r(!c.readableDidRead,"stream should not be readableDidRead");const l={resume(){c.resume()},pause(){c.pause()},get paused(){return c.isPaused()},get aborted(){return c.destroyed},get reason(){return c.errored},abort(e){c.destroy(e??new u)}};if(c.on("error",(function(t){if(!this.readableEnded){if("function"!=typeof e.onResponseError)throw t;e.onResponseError(l,t)}})).on("close",(function(){this.errored||e.onResponseEnd?.(l,{})})),e.onRequestStart?.(l,o),c.destroyed)return;const h={...s.headers,age:String(A)};a&&(h.warning='110 - "response is stale"'),e.onResponseStart?.(l,s.statusCode,h,s.statusMessage),"HEAD"===t.method?c.destroy():c.on("data",(function(t){e.onResponseData?.(l,t)}))}function I(e,t,s,r,n,o,c){if(!c)return function(e,t,s,r,n,i){if(i?.["only-if-cached"]){let e=!1;try{if("function"==typeof r.onConnect&&(r.onConnect((()=>{e=!0})),e))return;if("function"==typeof r.onHeaders&&(r.onHeaders(504,[],(()=>{}),"Gateway Timeout"),e))return;"function"==typeof r.onComplete&&r.onComplete([])}catch(e){"function"==typeof r.onError&&r.onError(e)}return!0}return e(n,new A(t,s,r))}(e,t,s,r,n,o);const l=Date.now();if(l>c.deleteAt)return e(n,new A(t,s,r));const h=Math.round((l-c.cachedAt)/1e3);if(o?.["max-age"]&&h>=o["max-age"])return e(n,r);if(function(e,t){if(t?.["no-cache"])return!0;if(e.cacheControlDirectives?.["no-cache"]&&!Array.isArray(e.cacheControlDirectives["no-cache"]))return!0;const s=Date.now();if(s>e.staleAt)return!t?.["max-stale"]||s>e.staleAt+1e3*t["max-stale"];if(t?.["min-fresh"])return e.staleAt-s<=1e3*t["min-fresh"];return!1}(c,o)){if(i.isStream(n.body)&&0!==i.bodyLength(n.body))return e(n,new A(t,s,r));if(function(e){const t=e.cacheControlDirectives?.["stale-while-revalidate"];return!!t&&Date.now()<=e.staleAt+1e3*t}(c))return E(r,n,c,h,null,!0),queueMicrotask((()=>{let r={...n.headers,"if-modified-since":new Date(c.cachedAt).toUTCString()};c.etag&&(r["if-none-match"]=c.etag),c.vary&&(r={...r,...c.vary}),e({...n,headers:r},new A(t,s,{onRequestStart(){},onRequestUpgrade(){},onResponseStart(){},onResponseData(){},onResponseEnd(){},onResponseError(){}}))})),!0;let g=!1;const d=c.cacheControlDirectives["stale-if-error"]??o?.["stale-if-error"];d&&(g=l<c.staleAt+1e3*d);let u={...n.headers,"if-modified-since":new Date(c.cachedAt).toUTCString()};return c.etag&&(u["if-none-match"]=c.etag),c.vary&&(u={...u,...c.vary}),e({...n,headers:u},new a(((e,t)=>{e?E(r,n,c,h,t,!0):i.isStream(c.body)&&c.body.on("error",(()=>{})).destroy()}),new A(t,s,r),g))}i.isStream(n.body)&&n.body.on("error",(()=>{})).destroy(),E(r,n,c,h,null,!1)}e.exports=(e={})=>{const{store:t=new o,methods:s=["GET"],cacheByDefault:r,type:n="shared"}=e;if("object"!=typeof e||null===e)throw new TypeError("expected type of opts to be an Object, got "+(null===e?"null":typeof e));if(c(t,"opts.store"),l(s,"opts.methods"),"undefined"!=typeof r&&"number"!=typeof r)throw new TypeError("expected opts.cacheByDefault to be number or undefined, got "+typeof r);if("undefined"!=typeof n&&"shared"!==n&&"private"!==n)throw new TypeError("expected opts.type to be shared, private, or undefined, got "+typeof n);const A={store:t,methods:s,cacheByDefault:r,type:n},a=i.safeHTTPMethods.filter((e=>!1===s.includes(e)));return e=>(s,r)=>{if(!s.origin||a.includes(s.method))return e(s,r);s={...s,headers:g(s)};const n=s.headers?.["cache-control"]?d(s.headers["cache-control"]):void 0;if(n?.["no-store"])return e(s,r);const i=h(s),o=t.get(i);return o&&"function"==typeof o.then?o.then((t=>{I(e,A,i,r,s,n,t)})):I(e,A,i,r,s,n,o),!0}}},4951:(e,t,s)=>{"use strict";const{createInflate:r,createGunzip:n,createBrotliDecompress:i,createZstdDecompress:A}=s(8522),{pipeline:o}=s(7075),a=s(6917),c={gzip:n,"x-gzip":n,br:i,deflate:r,compress:r,"x-compress":r,...A?{zstd:A}:{}},l=[204,304];let h=!1;class g extends a{#z=[];#j;#X;#Z;constructor(e,{skipStatusCodes:t=l,skipErrorResponses:s=!0}={}){super(e),this.#X=t,this.#Z=s}#K(e,t){return!e||t<200||(!!this.#X.includes(t)||!!(this.#Z&&t>=400))}#ee(e){const t=e.split(","),s=[];for(let e=t.length-1;e>=0;e--){const r=t[e].trim();if(r){if(!c[r])return s.length=0,s;s.push(c[r]())}}return s}#te(e,t){e.on("readable",(()=>{let s;for(;null!==(s=e.read());){if(!1===super.onResponseData(t,s))break}})),e.on("error",(e=>{super.onResponseError(t,e)}))}#se(e){const t=this.#z[0];this.#te(t,e),t.on("end",(()=>{super.onResponseEnd(e,{})}))}#re(e){const t=this.#z[this.#z.length-1];this.#te(t,e),this.#j=o(this.#z,(t=>{t?super.onResponseError(e,t):super.onResponseEnd(e,{})}))}#ne(){this.#z.length=0,this.#j=null}onResponseStart(e,t,s,r){const n=s["content-encoding"];if(this.#K(n,t))return super.onResponseStart(e,t,s,r);const i=this.#ee(n.toLowerCase());if(0===i.length)return this.#ne(),super.onResponseStart(e,t,s,r);this.#z=i;const{"content-encoding":A,"content-length":o,...a}=s;1===this.#z.length?this.#se(e):this.#re(e),super.onResponseStart(e,t,a,r)}onResponseData(e,t){this.#z.length>0?this.#z[0].write(t):super.onResponseData(e,t)}onResponseEnd(e,t){if(this.#z.length>0)return this.#z[0].end(),void this.#ne();super.onResponseEnd(e,t)}onResponseError(e,t){if(this.#z.length>0){for(const e of this.#z)e.destroy(t);this.#ne()}super.onResponseError(e,t)}}e.exports=function(e={}){return h||(process.emitWarning("DecompressInterceptor is experimental and subject to change","ExperimentalWarning"),h=!0),t=>(s,r)=>{const n=new g(r,e);return t(s,n)}}},6677:(e,t,s)=>{"use strict";const{isIP:r}=s(7030),{lookup:n}=s(610),i=s(6917),{InvalidArgumentError:A,InformationalError:o}=s(4465),a=Math.pow(2,31)-1;class c{#ie=0;#Ae=0;#oe=new Map;dualStack=!0;affinity=null;lookup=null;pick=null;constructor(e){this.#ie=e.maxTTL,this.#Ae=e.maxItems,this.dualStack=e.dualStack,this.affinity=e.affinity,this.lookup=e.lookup??this.#ae,this.pick=e.pick??this.#ce}get full(){return this.#oe.size===this.#Ae}runLookup(e,t,s){const r=this.#oe.get(e.hostname);if(null==r&&this.full)return void s(null,e);const n={affinity:this.affinity,dualStack:this.dualStack,lookup:this.lookup,pick:this.pick,...t.dns,maxTTL:this.#ie,maxItems:this.#Ae};if(null==r)this.lookup(e,n,((t,r)=>{if(t||null==r||0===r.length)return void s(t??new o("No DNS entries found"));this.setRecords(e,r);const i=this.#oe.get(e.hostname),A=this.pick(e,i,n.affinity);let a;a="number"==typeof A.port?`:${A.port}`:""!==e.port?`:${e.port}`:"",s(null,new URL(`${e.protocol}//${6===A.family?`[${A.address}]`:A.address}${a}`))}));else{const i=this.pick(e,r,n.affinity);if(null==i)return this.#oe.delete(e.hostname),void this.runLookup(e,t,s);let A;A="number"==typeof i.port?`:${i.port}`:""!==e.port?`:${e.port}`:"",s(null,new URL(`${e.protocol}//${6===i.family?`[${i.address}]`:i.address}${A}`))}}#ae(e,t,s){n(e.hostname,{all:!0,family:!1===this.dualStack?this.affinity:0,order:"ipv4first"},((e,t)=>{if(e)return s(e);const r=new Map;for(const e of t)r.set(`${e.address}:${e.family}`,e);s(null,r.values())}))}#ce(e,t,s){let r=null;const{records:n,offset:i}=t;let A;if(this.dualStack?(null==s&&(null==i||i===a?(t.offset=0,s=4):(t.offset++,s=1&~t.offset?4:6)),A=null!=n[s]&&n[s].ips.length>0?n[s]:n[4===s?6:4]):A=n[s],null==A||0===A.ips.length)return r;null==A.offset||A.offset===a?A.offset=0:A.offset++;const o=A.offset%A.ips.length;return r=A.ips[o]??null,null==r?r:Date.now()-r.timestamp>r.ttl?(A.ips.splice(o,1),this.pick(e,t,s)):r}pickFamily(e,t){const s=this.#oe.get(e.hostname)?.records;if(!s)return null;const r=s[t];if(!r)return null;null==r.offset||r.offset===a?r.offset=0:r.offset++;const n=r.offset%r.ips.length,i=r.ips[n]??null;return null==i||Date.now()-i.timestamp>i.ttl&&r.ips.splice(n,1),i}setRecords(e,t){const s=Date.now(),r={records:{4:null,6:null}};for(const e of t){e.timestamp=s,"number"==typeof e.ttl?e.ttl=Math.min(e.ttl,this.#ie):e.ttl=this.#ie;const t=r.records[e.family]??{ips:[]};t.ips.push(e),r.records[e.family]=t}this.#oe.set(e.hostname,r)}deleteRecords(e){this.#oe.delete(e.hostname)}getHandler(e,t){return new l(this,e,t)}}class l extends i{#le=null;#f=null;#he=null;#ge=null;#q=null;#de=null;#ue=!0;constructor(e,{origin:t,handler:s,dispatch:r,newOrigin:n},i){super(s),this.#ge=t,this.#de=n,this.#f={...i},this.#le=e,this.#he=r}onResponseError(e,t){switch(t.code){case"ETIMEDOUT":case"ECONNREFUSED":if(this.#le.dualStack){if(!this.#ue)return void super.onResponseError(e,t);this.#ue=!1;const s="["===this.#de.hostname[0]?4:6,r=this.#le.pickFamily(this.#ge,s);if(null==r)return void super.onResponseError(e,t);let n;n="number"==typeof r.port?`:${r.port}`:""!==this.#ge.port?`:${this.#ge.port}`:"";const i={...this.#f,origin:`${this.#ge.protocol}//${6===r.family?`[${r.address}]`:r.address}${n}`};return void this.#he(i,this)}super.onResponseError(e,t);break;case"ENOTFOUND":this.#le.deleteRecords(this.#ge),super.onResponseError(e,t);break;default:super.onResponseError(e,t)}}}e.exports=e=>{if(null!=e?.maxTTL&&("number"!=typeof e?.maxTTL||e?.maxTTL<0))throw new A("Invalid maxTTL. Must be a positive number");if(null!=e?.maxItems&&("number"!=typeof e?.maxItems||e?.maxItems<1))throw new A("Invalid maxItems. Must be a positive number and greater than zero");if(null!=e?.affinity&&4!==e?.affinity&&6!==e?.affinity)throw new A("Invalid affinity. Must be either 4 or 6");if(null!=e?.dualStack&&"boolean"!=typeof e?.dualStack)throw new A("Invalid dualStack. Must be a boolean");if(null!=e?.lookup&&"function"!=typeof e?.lookup)throw new A("Invalid lookup. Must be a function");if(null!=e?.pick&&"function"!=typeof e?.pick)throw new A("Invalid pick. Must be a function");const t=e?.dualStack??!0;let s;s=t?e?.affinity??null:e?.affinity??4;const n=new c({maxTTL:e?.maxTTL??1e4,lookup:e?.lookup??null,pick:e?.pick??null,dualStack:t,affinity:s,maxItems:e?.maxItems??1/0});return e=>function(t,s){const i=t.origin.constructor===URL?t.origin:new URL(t.origin);return 0!==r(i.hostname)?e(t,s):(n.runLookup(i,t,((r,A)=>{if(r)return s.onResponseError(null,r);const o={...t,servername:i.hostname,origin:A.origin,headers:{host:i.host,...t.headers}};e(o,n.getHandler({origin:i,dispatch:e,handler:s,newOrigin:A},t))})),!0)}}},3562:(e,t,s)=>{"use strict";const{InvalidArgumentError:r,RequestAbortedError:n}=s(4465),i=s(6917);class A extends i{#t=1048576;#Ee=!1;#r=0;#q=null;aborted=!1;reason=!1;constructor({maxSize:e,signal:t},s){if(null!=e&&(!Number.isFinite(e)||e<1))throw new r("maxSize must be a number greater than 0");super(s),this.#t=e??this.#t}#$(e){this.aborted=!0,this.reason=e}onRequestStart(e,t){return e.abort=this.#$.bind(this),this.#q=e,super.onRequestStart(e,t)}onResponseStart(e,t,s,r){const i=s["content-length"];if(null!=i&&i>this.#t)throw new n(`Response size (${i}) larger than maxSize (${this.#t})`);return!0===this.aborted||super.onResponseStart(e,t,s,r)}onResponseError(e,t){this.#Ee||(t=this.#q?.reason??t,super.onResponseError(e,t))}onResponseData(e,t){return this.#r=this.#r+t.length,this.#r>=this.#t&&(this.#Ee=!0,!0===this.aborted?super.onResponseError(e,this.reason):super.onResponseEnd(e,{})),!0}onResponseEnd(e,t){this.#Ee||(!0!==this.#q.aborted?super.onResponseEnd(e,t):super.onResponseError(e,this.reason))}}e.exports=function({maxSize:e}={maxSize:1048576}){return t=>function(s,r){const{dumpMaxSize:n=e}=s,i=new A({maxSize:n,signal:s.signal},r);return t(s,i)}}},5132:(e,t,s)=>{"use strict";const r=s(8064);e.exports=function({maxRedirections:e}={}){return t=>function(s,n){const{maxRedirections:i=e,...A}=s;if(null==i||0===i)return t(s,n);const o={...A},a=new r(t,i,o,n);return t(o,a)}}},2936:(e,t,s)=>{"use strict";const r=s(6917),{ResponseError:n}=s(4465);class i extends r{#Ie;#pe;#Ce;#Be;#fe;constructor(e,{handler:t}){super(t)}#Qe(e){return 0===(this.#pe??"").indexOf(e)}onRequestStart(e,t){return this.#Ie=0,this.#pe=null,this.#Ce=null,this.#Be=null,this.#fe="",super.onRequestStart(e,t)}onResponseStart(e,t,s,r){if(this.#Ie=t,this.#Be=s,this.#pe=s["content-type"],this.#Ie<400)return super.onResponseStart(e,t,s,r);(this.#Qe("application/json")||this.#Qe("text/plain"))&&(this.#Ce=new TextDecoder("utf-8"))}onResponseData(e,t){if(this.#Ie<400)return super.onResponseData(e,t);this.#fe+=this.#Ce?.decode(t,{stream:!0})??""}onResponseEnd(e,t){if(this.#Ie>=400){if(this.#fe+=this.#Ce?.decode(void 0,{stream:!1})??"",this.#Qe("application/json"))try{this.#fe=JSON.parse(this.#fe)}catch{}let t;const s=Error.stackTraceLimit;Error.stackTraceLimit=0;try{t=new n("Response Error",this.#Ie,{body:this.#fe,headers:this.#Be})}finally{Error.stackTraceLimit=s}super.onResponseError(e,t)}else super.onResponseEnd(e,t)}onResponseError(e,t){super.onResponseError(e,t)}}e.exports=()=>e=>function(t,s){return e(t,new i(t,{handler:s}))}},532:(e,t,s)=>{"use strict";const r=s(6294);e.exports=e=>t=>function(s,n){return t(s,new r({...s,retryOptions:{...e,...s.retryOptions}},{handler:n,dispatch:t}))}},4178:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SPECIAL_HEADERS=t.MINOR=t.MAJOR=t.HTAB_SP_VCHAR_OBS_TEXT=t.QUOTED_STRING=t.CONNECTION_TOKEN_CHARS=t.HEADER_CHARS=t.TOKEN=t.HEX=t.URL_CHAR=t.USERINFO_CHARS=t.MARK=t.ALPHANUM=t.NUM=t.HEX_MAP=t.NUM_MAP=t.ALPHA=t.STATUSES_HTTP=t.H_METHOD_MAP=t.METHOD_MAP=t.METHODS_RTSP=t.METHODS_ICE=t.METHODS_HTTP=t.HEADER_STATE=t.FINISH=t.STATUSES=t.METHODS=t.LENIENT_FLAGS=t.FLAGS=t.TYPE=t.ERROR=void 0;const r=s(3530);t.ERROR={OK:0,INTERNAL:1,STRICT:2,CR_EXPECTED:25,LF_EXPECTED:3,UNEXPECTED_CONTENT_LENGTH:4,UNEXPECTED_SPACE:30,CLOSED_CONNECTION:5,INVALID_METHOD:6,INVALID_URL:7,INVALID_CONSTANT:8,INVALID_VERSION:9,INVALID_HEADER_TOKEN:10,INVALID_CONTENT_LENGTH:11,INVALID_CHUNK_SIZE:12,INVALID_STATUS:13,INVALID_EOF_STATE:14,INVALID_TRANSFER_ENCODING:15,CB_MESSAGE_BEGIN:16,CB_HEADERS_COMPLETE:17,CB_MESSAGE_COMPLETE:18,CB_CHUNK_HEADER:19,CB_CHUNK_COMPLETE:20,PAUSED:21,PAUSED_UPGRADE:22,PAUSED_H2_UPGRADE:23,USER:24,CB_URL_COMPLETE:26,CB_STATUS_COMPLETE:27,CB_METHOD_COMPLETE:32,CB_VERSION_COMPLETE:33,CB_HEADER_FIELD_COMPLETE:28,CB_HEADER_VALUE_COMPLETE:29,CB_CHUNK_EXTENSION_NAME_COMPLETE:34,CB_CHUNK_EXTENSION_VALUE_COMPLETE:35,CB_RESET:31,CB_PROTOCOL_COMPLETE:38},t.TYPE={BOTH:0,REQUEST:1,RESPONSE:2},t.FLAGS={CONNECTION_KEEP_ALIVE:1,CONNECTION_CLOSE:2,CONNECTION_UPGRADE:4,CHUNKED:8,UPGRADE:16,CONTENT_LENGTH:32,SKIPBODY:64,TRAILING:128,TRANSFER_ENCODING:512},t.LENIENT_FLAGS={HEADERS:1,CHUNKED_LENGTH:2,KEEP_ALIVE:4,TRANSFER_ENCODING:8,VERSION:16,DATA_AFTER_CLOSE:32,OPTIONAL_LF_AFTER_CR:64,OPTIONAL_CRLF_AFTER_CHUNK:128,OPTIONAL_CR_BEFORE_LF:256,SPACES_AFTER_CHUNK_SIZE:512},t.METHODS={DELETE:0,GET:1,HEAD:2,POST:3,PUT:4,CONNECT:5,OPTIONS:6,TRACE:7,COPY:8,LOCK:9,MKCOL:10,MOVE:11,PROPFIND:12,PROPPATCH:13,SEARCH:14,UNLOCK:15,BIND:16,REBIND:17,UNBIND:18,ACL:19,REPORT:20,MKACTIVITY:21,CHECKOUT:22,MERGE:23,"M-SEARCH":24,NOTIFY:25,SUBSCRIBE:26,UNSUBSCRIBE:27,PATCH:28,PURGE:29,MKCALENDAR:30,LINK:31,UNLINK:32,SOURCE:33,PRI:34,DESCRIBE:35,ANNOUNCE:36,SETUP:37,PLAY:38,PAUSE:39,TEARDOWN:40,GET_PARAMETER:41,SET_PARAMETER:42,REDIRECT:43,RECORD:44,FLUSH:45,QUERY:46},t.STATUSES={CONTINUE:100,SWITCHING_PROTOCOLS:101,PROCESSING:102,EARLY_HINTS:103,RESPONSE_IS_STALE:110,REVALIDATION_FAILED:111,DISCONNECTED_OPERATION:112,HEURISTIC_EXPIRATION:113,MISCELLANEOUS_WARNING:199,OK:200,CREATED:201,ACCEPTED:202,NON_AUTHORITATIVE_INFORMATION:203,NO_CONTENT:204,RESET_CONTENT:205,PARTIAL_CONTENT:206,MULTI_STATUS:207,ALREADY_REPORTED:208,TRANSFORMATION_APPLIED:214,IM_USED:226,MISCELLANEOUS_PERSISTENT_WARNING:299,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,FOUND:302,SEE_OTHER:303,NOT_MODIFIED:304,USE_PROXY:305,SWITCH_PROXY:306,TEMPORARY_REDIRECT:307,PERMANENT_REDIRECT:308,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,IM_A_TEAPOT:418,PAGE_EXPIRED:419,ENHANCE_YOUR_CALM:420,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,TOO_EARLY:425,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,REQUEST_HEADER_FIELDS_TOO_LARGE_UNOFFICIAL:430,REQUEST_HEADER_FIELDS_TOO_LARGE:431,LOGIN_TIMEOUT:440,NO_RESPONSE:444,RETRY_WITH:449,BLOCKED_BY_PARENTAL_CONTROL:450,UNAVAILABLE_FOR_LEGAL_REASONS:451,CLIENT_CLOSED_LOAD_BALANCED_REQUEST:460,INVALID_X_FORWARDED_FOR:463,REQUEST_HEADER_TOO_LARGE:494,SSL_CERTIFICATE_ERROR:495,SSL_CERTIFICATE_REQUIRED:496,HTTP_REQUEST_SENT_TO_HTTPS_PORT:497,INVALID_TOKEN:498,CLIENT_CLOSED_REQUEST:499,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,VARIANT_ALSO_NEGOTIATES:506,INSUFFICIENT_STORAGE:507,LOOP_DETECTED:508,BANDWIDTH_LIMIT_EXCEEDED:509,NOT_EXTENDED:510,NETWORK_AUTHENTICATION_REQUIRED:511,WEB_SERVER_UNKNOWN_ERROR:520,WEB_SERVER_IS_DOWN:521,CONNECTION_TIMEOUT:522,ORIGIN_IS_UNREACHABLE:523,TIMEOUT_OCCURED:524,SSL_HANDSHAKE_FAILED:525,INVALID_SSL_CERTIFICATE:526,RAILGUN_ERROR:527,SITE_IS_OVERLOADED:529,SITE_IS_FROZEN:530,IDENTITY_PROVIDER_AUTHENTICATION_ERROR:561,NETWORK_READ_TIMEOUT:598,NETWORK_CONNECT_TIMEOUT:599},t.FINISH={SAFE:0,SAFE_WITH_CB:1,UNSAFE:2},t.HEADER_STATE={GENERAL:0,CONNECTION:1,CONTENT_LENGTH:2,TRANSFER_ENCODING:3,UPGRADE:4,CONNECTION_KEEP_ALIVE:5,CONNECTION_CLOSE:6,CONNECTION_UPGRADE:7,TRANSFER_ENCODING_CHUNKED:8},t.METHODS_HTTP=[t.METHODS.DELETE,t.METHODS.GET,t.METHODS.HEAD,t.METHODS.POST,t.METHODS.PUT,t.METHODS.CONNECT,t.METHODS.OPTIONS,t.METHODS.TRACE,t.METHODS.COPY,t.METHODS.LOCK,t.METHODS.MKCOL,t.METHODS.MOVE,t.METHODS.PROPFIND,t.METHODS.PROPPATCH,t.METHODS.SEARCH,t.METHODS.UNLOCK,t.METHODS.BIND,t.METHODS.REBIND,t.METHODS.UNBIND,t.METHODS.ACL,t.METHODS.REPORT,t.METHODS.MKACTIVITY,t.METHODS.CHECKOUT,t.METHODS.MERGE,t.METHODS["M-SEARCH"],t.METHODS.NOTIFY,t.METHODS.SUBSCRIBE,t.METHODS.UNSUBSCRIBE,t.METHODS.PATCH,t.METHODS.PURGE,t.METHODS.MKCALENDAR,t.METHODS.LINK,t.METHODS.UNLINK,t.METHODS.PRI,t.METHODS.SOURCE,t.METHODS.QUERY],t.METHODS_ICE=[t.METHODS.SOURCE],t.METHODS_RTSP=[t.METHODS.OPTIONS,t.METHODS.DESCRIBE,t.METHODS.ANNOUNCE,t.METHODS.SETUP,t.METHODS.PLAY,t.METHODS.PAUSE,t.METHODS.TEARDOWN,t.METHODS.GET_PARAMETER,t.METHODS.SET_PARAMETER,t.METHODS.REDIRECT,t.METHODS.RECORD,t.METHODS.FLUSH,t.METHODS.GET,t.METHODS.POST],t.METHOD_MAP=(0,r.enumToMap)(t.METHODS),t.H_METHOD_MAP=Object.fromEntries(Object.entries(t.METHODS).filter((([e])=>e.startsWith("H")))),t.STATUSES_HTTP=[t.STATUSES.CONTINUE,t.STATUSES.SWITCHING_PROTOCOLS,t.STATUSES.PROCESSING,t.STATUSES.EARLY_HINTS,t.STATUSES.RESPONSE_IS_STALE,t.STATUSES.REVALIDATION_FAILED,t.STATUSES.DISCONNECTED_OPERATION,t.STATUSES.HEURISTIC_EXPIRATION,t.STATUSES.MISCELLANEOUS_WARNING,t.STATUSES.OK,t.STATUSES.CREATED,t.STATUSES.ACCEPTED,t.STATUSES.NON_AUTHORITATIVE_INFORMATION,t.STATUSES.NO_CONTENT,t.STATUSES.RESET_CONTENT,t.STATUSES.PARTIAL_CONTENT,t.STATUSES.MULTI_STATUS,t.STATUSES.ALREADY_REPORTED,t.STATUSES.TRANSFORMATION_APPLIED,t.STATUSES.IM_USED,t.STATUSES.MISCELLANEOUS_PERSISTENT_WARNING,t.STATUSES.MULTIPLE_CHOICES,t.STATUSES.MOVED_PERMANENTLY,t.STATUSES.FOUND,t.STATUSES.SEE_OTHER,t.STATUSES.NOT_MODIFIED,t.STATUSES.USE_PROXY,t.STATUSES.SWITCH_PROXY,t.STATUSES.TEMPORARY_REDIRECT,t.STATUSES.PERMANENT_REDIRECT,t.STATUSES.BAD_REQUEST,t.STATUSES.UNAUTHORIZED,t.STATUSES.PAYMENT_REQUIRED,t.STATUSES.FORBIDDEN,t.STATUSES.NOT_FOUND,t.STATUSES.METHOD_NOT_ALLOWED,t.STATUSES.NOT_ACCEPTABLE,t.STATUSES.PROXY_AUTHENTICATION_REQUIRED,t.STATUSES.REQUEST_TIMEOUT,t.STATUSES.CONFLICT,t.STATUSES.GONE,t.STATUSES.LENGTH_REQUIRED,t.STATUSES.PRECONDITION_FAILED,t.STATUSES.PAYLOAD_TOO_LARGE,t.STATUSES.URI_TOO_LONG,t.STATUSES.UNSUPPORTED_MEDIA_TYPE,t.STATUSES.RANGE_NOT_SATISFIABLE,t.STATUSES.EXPECTATION_FAILED,t.STATUSES.IM_A_TEAPOT,t.STATUSES.PAGE_EXPIRED,t.STATUSES.ENHANCE_YOUR_CALM,t.STATUSES.MISDIRECTED_REQUEST,t.STATUSES.UNPROCESSABLE_ENTITY,t.STATUSES.LOCKED,t.STATUSES.FAILED_DEPENDENCY,t.STATUSES.TOO_EARLY,t.STATUSES.UPGRADE_REQUIRED,t.STATUSES.PRECONDITION_REQUIRED,t.STATUSES.TOO_MANY_REQUESTS,t.STATUSES.REQUEST_HEADER_FIELDS_TOO_LARGE_UNOFFICIAL,t.STATUSES.REQUEST_HEADER_FIELDS_TOO_LARGE,t.STATUSES.LOGIN_TIMEOUT,t.STATUSES.NO_RESPONSE,t.STATUSES.RETRY_WITH,t.STATUSES.BLOCKED_BY_PARENTAL_CONTROL,t.STATUSES.UNAVAILABLE_FOR_LEGAL_REASONS,t.STATUSES.CLIENT_CLOSED_LOAD_BALANCED_REQUEST,t.STATUSES.INVALID_X_FORWARDED_FOR,t.STATUSES.REQUEST_HEADER_TOO_LARGE,t.STATUSES.SSL_CERTIFICATE_ERROR,t.STATUSES.SSL_CERTIFICATE_REQUIRED,t.STATUSES.HTTP_REQUEST_SENT_TO_HTTPS_PORT,t.STATUSES.INVALID_TOKEN,t.STATUSES.CLIENT_CLOSED_REQUEST,t.STATUSES.INTERNAL_SERVER_ERROR,t.STATUSES.NOT_IMPLEMENTED,t.STATUSES.BAD_GATEWAY,t.STATUSES.SERVICE_UNAVAILABLE,t.STATUSES.GATEWAY_TIMEOUT,t.STATUSES.HTTP_VERSION_NOT_SUPPORTED,t.STATUSES.VARIANT_ALSO_NEGOTIATES,t.STATUSES.INSUFFICIENT_STORAGE,t.STATUSES.LOOP_DETECTED,t.STATUSES.BANDWIDTH_LIMIT_EXCEEDED,t.STATUSES.NOT_EXTENDED,t.STATUSES.NETWORK_AUTHENTICATION_REQUIRED,t.STATUSES.WEB_SERVER_UNKNOWN_ERROR,t.STATUSES.WEB_SERVER_IS_DOWN,t.STATUSES.CONNECTION_TIMEOUT,t.STATUSES.ORIGIN_IS_UNREACHABLE,t.STATUSES.TIMEOUT_OCCURED,t.STATUSES.SSL_HANDSHAKE_FAILED,t.STATUSES.INVALID_SSL_CERTIFICATE,t.STATUSES.RAILGUN_ERROR,t.STATUSES.SITE_IS_OVERLOADED,t.STATUSES.SITE_IS_FROZEN,t.STATUSES.IDENTITY_PROVIDER_AUTHENTICATION_ERROR,t.STATUSES.NETWORK_READ_TIMEOUT,t.STATUSES.NETWORK_CONNECT_TIMEOUT],t.ALPHA=[];for(let e="A".charCodeAt(0);e<="Z".charCodeAt(0);e++)t.ALPHA.push(String.fromCharCode(e)),t.ALPHA.push(String.fromCharCode(e+32));t.NUM_MAP={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9},t.HEX_MAP={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},t.NUM=["0","1","2","3","4","5","6","7","8","9"],t.ALPHANUM=t.ALPHA.concat(t.NUM),t.MARK=["-","_",".","!","~","*","'","(",")"],t.USERINFO_CHARS=t.ALPHANUM.concat(t.MARK).concat(["%",";",":","&","=","+","$",","]),t.URL_CHAR=["!",'"',"$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","@","[","\\","]","^","_","`","{","|","}","~"].concat(t.ALPHANUM),t.HEX=t.NUM.concat(["a","b","c","d","e","f","A","B","C","D","E","F"]),t.TOKEN=["!","#","$","%","&","'","*","+","-",".","^","_","`","|","~"].concat(t.ALPHANUM),t.HEADER_CHARS=["\t"];for(let e=32;e<=255;e++)127!==e&&t.HEADER_CHARS.push(e);t.CONNECTION_TOKEN_CHARS=t.HEADER_CHARS.filter((e=>44!==e)),t.QUOTED_STRING=["\t"," "];for(let e=33;e<=255;e++)34!==e&&92!==e&&t.QUOTED_STRING.push(e);t.HTAB_SP_VCHAR_OBS_TEXT=["\t"," "];for(let e=33;e<=126;e++)t.HTAB_SP_VCHAR_OBS_TEXT.push(e);for(let e=128;e<=255;e++)t.HTAB_SP_VCHAR_OBS_TEXT.push(e);t.MAJOR=t.NUM_MAP,t.MINOR=t.MAJOR,t.SPECIAL_HEADERS={connection:t.HEADER_STATE.CONNECTION,"content-length":t.HEADER_STATE.CONTENT_LENGTH,"proxy-connection":t.HEADER_STATE.CONNECTION,"transfer-encoding":t.HEADER_STATE.TRANSFER_ENCODING,upgrade:t.HEADER_STATE.UPGRADE},t.default={ERROR:t.ERROR,TYPE:t.TYPE,FLAGS:t.FLAGS,LENIENT_FLAGS:t.LENIENT_FLAGS,METHODS:t.METHODS,STATUSES:t.STATUSES,FINISH:t.FINISH,HEADER_STATE:t.HEADER_STATE,ALPHA:t.ALPHA,NUM_MAP:t.NUM_MAP,HEX_MAP:t.HEX_MAP,NUM:t.NUM,ALPHANUM:t.ALPHANUM,MARK:t.MARK,USERINFO_CHARS:t.USERINFO_CHARS,URL_CHAR:t.URL_CHAR,HEX:t.HEX,TOKEN:t.TOKEN,HEADER_CHARS:t.HEADER_CHARS,CONNECTION_TOKEN_CHARS:t.CONNECTION_TOKEN_CHARS,QUOTED_STRING:t.QUOTED_STRING,HTAB_SP_VCHAR_OBS_TEXT:t.HTAB_SP_VCHAR_OBS_TEXT,MAJOR:t.MAJOR,MINOR:t.MINOR,SPECIAL_HEADERS:t.SPECIAL_HEADERS,METHODS_HTTP:t.METHODS_HTTP,METHODS_ICE:t.METHODS_ICE,METHODS_RTSP:t.METHODS_RTSP,METHOD_MAP:t.METHOD_MAP,H_METHOD_MAP:t.H_METHOD_MAP,STATUSES_HTTP:t.STATUSES_HTTP}},4744:(e,t,s)=>{"use strict";e=s.nmd(e);const{Buffer:r}=s(4573);let n;Object.defineProperty(e,"exports",{get:()=>n||(n=r.from("AGFzbQEAAAABJwdgAX8Bf2ADf39/AX9gAn9/AGABfwBgBH9/f38Bf2AAAGADf39/AALLAQgDZW52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AA2AhgLIAEgBGogBDYCACABIARBAXI2AgQgAUHY1QAoAgBHDQBBzNUAIAQ2AgAMAQsgBEH/AU0EQCAEQXhxQezVAGohAAJ/QcTVACgCACICQQEgBEEDdnQiA3FFBEBBxNUAIAIgA3I2AgAgAAwBCyAAKAIICyICIAE2AgwgACABNgIIIAEgADYCDCABIAI2AggMAQtBHyECIARB////B00EQCAEQSYgBEEIdmciAGt2QQFxIABBAXRrQT5qIQILIAEgAjYCHCABQgA3AhAgAkECdEH01wBqIQACQEHI1QAoAgAiA0EBIAJ0IgdxRQRAIAAgATYCAEHI1QAgAyAHcjYCACABIAA2AhggASABNgIIIAEgATYCDAwBCyAEQRkgAkEBdmtBACACQR9HG3QhAiAAKAIAIQACQANAIAAiAygCBEF4cSAERg0BIAJBHXYhACACQQF0IQIgAyAAQQRxakEQaiIHKAIAIgANAAsgByABNgIAIAEgAzYCGCABIAE2AgwgASABNgIIDAELIAMoAggiACABNgIMIAMgATYCCCABQQA2AhggASADNgIMIAEgADYCCAtB5NUAQeTVACgCAEEBayIAQX8gABs2AgALCwcAIAAtACgLBwAgAC0AKgsHACAALQArCwcAIAAtACkLBwAgAC8BNAsHACAALQAwC0ABBH8gACgCGCEBIAAvAS4hAiAALQAoIQMgACgCOCEEIAAQOCAAIAQ2AjggACADOgAoIAAgAjsBLiAAIAE2AhgL5YUCAgd/A34gASACaiEEAkAgACIDKAIMIgANACADKAIEBEAgAyABNgIECyMAQRBrIgkkAAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAn8CQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAA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A0EZNgIcIAMgADYCDCADIAFBAWo2AhQM9gILIAMoAgQhAEEAIQIgA0EANgIEIAMgACABEDQiAEUEQCABQQFqIQEM7wILIANBGjYCHCADIAA2AgwgAyABQQFqNgIUDPUCCyAAQRVGDR9BACECIANBADYCHCADIAE2AhQgA0HQDzYCECADQSI2AgwM9AILIAMoAgQhACADQQA2AgQgAyAAIAEQMyIARQRAIAFBAWohAQwbCyADQRw2AhwgAyAANgIMIAMgAUEBajYCFEEAIQIM8wILIAMoAgQhACADQQA2AgQgAyAAIAEQMyIARQRAIAFBAWohAQzrAgsgA0EdNgIcIAMgADYCDCADIAFBAWo2AhRBACECDPICCyAAQTtHDQEgAUEBaiEBC0EmIQIM1wILQQAhAiADQQA2AhwgAyABNgIUIANBnxU2AhAgA0EMNgIMDO8CCyABIARHBEADQCABLQAAQSBHDYQCIAQgAUEBaiIBRw0AC0EsIQIM7wILQSwhAgzuAgsgASAERgRAQTQhAgzuAgsCQAJAA0ACQCABLQAAQQprDgQCAAADAAsgBCABQQFqIgFHDQALQTQhAgzvAgsgAygCBCEAIANBADYCBCADIAAgARAxIgBFDZ8CIANBMjYCHCADIAE2AhQgAyAANgIMQQAhAgzuAgsgAygCBCEAIANBADYCBCADIAAgARAxIgBFBEAgAUEBaiEBDJ8CCyADQTI2AhwgAyAANgIMIAMgAUEBajYCFEEAIQIM7QILIAEgBEcEQAJAA0AgAS0AAEEwayIAQf8BcUEKTwRAQTohAgzXAgsgAykDICILQpmz5syZs+bMGVYNASADIAtCCn4iCjcDICAKIACtQv8BgyILQn+FVg0BIAMgCiALfDcDICAEIAFBAWoiAUcNAAtBwAAhAgzuAgsgAygCBCEAIANBADYCBCADIAAgAUEBaiIBEDEiAA0XDOICC0HAACECDOwCCyABIARGBEBByQAhAgzsAgsCQANAAkAgAS0AAEEJaw4YAAKiAqICqQKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogIAogILIAQgAUEBaiIBRw0AC0HJACECDOwCCyABQQFqIQEgA0Evai0AAEEBcQ2lAiADQQA2AhwgAyABNgIUIANBlxA2AhAgA0EKNgIMQQAhAgzrAgsgASAERwRAA0AgAS0AAEEgRw0VIAQgAUEBaiIBRw0AC0H4ACECDOsCC0H4ACECDOoCCyADQQI6ACgMOAtBACECIANBADYCHCADQb8LNgIQIANBAjYCDCADIAFBAWo2AhQM6AILQQAhAgzOAgtBDSECDM0CC0ETIQIMzAILQRUhAgzLAgtBFiECDMoCC0EYIQIMyQILQRkhAgzIAgtBGiECDMcCC0EbIQIMxgILQRwhAgzFAgtBHSECDMQCC0EeIQIMwwILQR8hAgzCAgtBICECDMECC0EiIQIMwAILQSMhAgy/AgtBJSECDL4CC0HlACECDL0CCyADQT02AhwgAyABNgIUIAMgADYCDEEAIQIM1QILIANBGzYCHCADIAE2AhQgA0GkHDYCECADQRU2AgxBACECDNQCCyADQSA2AhwgAyABNgIUIANBmBo2AhAgA0EVNgIMQQAhAgzTAgsgA0ETNgIcIAMgATYCFCADQZgaNgIQIANBFTYCDEEAIQIM0gILIANBCzYCHCADIAE2AhQgA0GYGjYCECADQRU2AgxBACECDNECCyADQRA2AhwgAyABNgIUIANBmBo2AhAgA0EVNgIMQQAhAgzQAgsgA0EgNgIcIAMgATYCFCADQaQcNgIQIANBFTYCDEEAIQIMzwILIANBCzYCHCADIAE2AhQgA0GkHDYCECADQRU2AgxBACECDM4CCyADQQw2AhwgAyABNgIUIANBpBw2AhAgA0EVNgIMQQAhAgzNAgtBACECIANBADYCHCADIAE2AhQgA0HdDjYCECADQRI2AgwMzAILAkADQAJAIAEtAABBCmsOBAACAgACCyAEIAFBAWoiAUcNAAtB/QEhAgzMAgsCQAJAIAMtADZBAUcNAEEAIQACQCADKAI4IgJFDQAgAigCYCICRQ0AIAMgAhEAACEACyAARQ0AIABBFUcNASADQfwBNgIcIAMgATYCFCADQdwZNgIQIANBFTYCDEEAIQIMzQILQdwBIQIMswILIANBADYCHCADIAE2AhQgA0H5CzYCECADQR82AgxBACECDMsCCwJAAkAgAy0AKEEBaw4CBAEAC0HbASECDLICC0HUASECDLECCyADQQI6ADFBACEAAkAgAygCOCICRQ0AIAIoAgAiAkUNACADIAIRAAAhAAsgAEUEQEHdASECDLECCyAAQRVHBEAgA0EANgIcIAMgATYCFCADQbQMNgIQIANBEDYCDEEAIQIMygILIANB+wE2AhwgAyABNgIUIANBgRo2AhAgA0EVNgIMQQAhAgzJAgsgASAERgRAQfoBIQIMyQILIAEtAABByABGDQEgA0EBOgAoC0HAASECDK4CC0HaASECDK0CCyABIARHBEAgA0EMNgIIIAMgATYCBEHZASECDK0CC0H5ASECDMUCCyABIARGBEBB+AEhAgzFAgsgAS0AAEHIAEcNBCABQQFqIQFB2AEhAgyrAgsgASAERgRAQfcBIQIMxAILAkACQCABLQAAQcUAaw4QAAUFBQUFBQUFBQUFBQUFAQULIAFBAWohAUHWASECDKsCCyABQQFqIQFB1wEhAgyqAgtB9gEhAiABIARGDcICIAMoAgAiACAEIAFraiEFIAEgAGtBAmohBgJAA0AgAS0AACAAQbrVAGotAABHDQMgAEECRg0BIABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADMMCCyADKAIEIQAgA0IANwMAIAMgACAGQQFqIgEQLiIARQRAQeMBIQIMqgILIANB9QE2AhwgAyABNgIUIAMgADYCDEEAIQIMwgILQfQBIQIgASAERg3BAiADKAIAIgAgBCABa2ohBSABIABrQQFqIQYCQANAIAEtAAAgAEG41QBqLQAARw0CIABBAUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAzCAgsgA0GBBDsBKCADKAIEIQAgA0IANwMAIAMgACAGQQFqIgEQLiIADQMMAgsgA0EANgIAC0EAIQIgA0EANgIcIAMgATYCFCADQeUfNgIQIANBCDYCDAy/AgtB1QEhAgylAgsgA0HzATYCHCADIAE2AhQgAyAANgIMQQAhAgy9AgtBACEAAkAgAygCOCICRQ0AIAIoAkAiAkUNACADIAIRAAAhAAsgAEUNbiAAQRVHBEAgA0EANgIcIAMgATYCFCADQYIPNgIQIANBIDYCDEEAIQIMvQILIANBjwE2AhwgAyABNgIUIANB7Bs2AhAgA0EVNgIMQQAhAgy8AgsgASAERwRAIANBDTYCCCADIAE2AgRB0wEhAgyjAgtB8gEhAgy7AgsgASAERgRAQfEBIQIMuwILAkACQAJAIAEtAABByABrDgsAAQgICAgICAgIAggLIAFBAWohAUHQASECDKMCCyABQQFqIQFB0QEhAgyiAgsgAUEBaiEBQdIBIQIMoQILQfABIQIgASAERg25AiADKAIAIgAgBCABa2ohBiABIABrQQJqIQUDQCABLQAAIABBtdUAai0AAEcNBCAAQQJGDQMgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAY2AgAMuQILQe8BIQIgASAERg24AiADKAIAIgAgBCABa2ohBiABIABrQQFqIQUDQCABLQAAIABBs9UAai0AAEcNAyAAQQFGDQIgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAY2AgAMuAILQe4BIQIgASAERg23AiADKAIAIgAgBCABa2ohBiABIABrQQJqIQUDQCABLQAAIABBsNUAai0AAEcNAiAAQQJGDQEgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAY2AgAMtwILIAMoAgQhACADQgA3AwAgAyAAIAVBAWoiARArIgBFDQIgA0HsATYCHCADIAE2AhQgAyAANgIMQQAhAgy2AgsgA0EANgIACyADKAIEIQAgA0EANgIEIAMgACABECsiAEUNnAIgA0HtATYCHCADIAE2AhQgAyAANgIMQQAhAgy0AgtBzwEhAgyaAgtBACEAAkAgAygCOCICRQ0AIAIoAjQiAkUNACADIAIRAAAhAAsCQCAABEAgAEEVRg0BIANBADYCHCADIAE2AhQgA0HqDTYCECADQSY2AgxBACECDLQCC0HOASECDJoCCyADQesBNgIcIAMgATYCFCADQYAbNgIQIANBFTYCDEEAIQIMsgILIAEgBEYEQEHrASECDLICCyABLQAAQS9GBEAgAUEBaiEBDAELIANBADYCHCADIAE2AhQgA0GyODYCECADQQg2AgxBACECDLECC0HNASECDJcCCyABIARHBEAgA0EONgIIIAMgATYCBEHMASECDJcCC0HqASECDK8CCyABIARGBEBB6QEhAgyvAgsgAS0AAEEwayIAQf8BcUEKSQRAIAMgADoAKiABQQFqIQFBywEhAgyWAgsgAygCBCEAIANBADYCBCADIAAgARAvIgBFDZcCIANB6AE2AhwgAyABNgIUIAMgADYCDEEAIQIMrgILIAEgBEYEQEHnASECDK4CCwJAIAEtAABBLkYEQCABQQFqIQEMAQsgAygCBCEAIANBADYCBCADIAAgARAvIgBFDZgCIANB5gE2AhwgAyABNgIUIAMgADYCDEEAIQIMrgILQcoBIQIMlAILIAEgBEYEQEHlASECDK0CC0EAIQBBASEFQQEhB0EAIQICQAJAAkACQAJAAn8CQAJAAkACQAJAAkACQCABLQAAQTBrDgoKCQABAgMEBQYICwtBAgwGC0EDDAULQQQMBAtBBQwDC0EGDAILQQcMAQtBCAshAkEAIQVBACEHDAILQQkhAkEBIQBBACEFQQAhBwwBC0EAIQVBASECCyADIAI6ACsgAUEBaiEBAkACQCADLQAuQRBxDQACQAJAAkAgAy0AKg4DAQACBAsgB0UNAwwCCyAADQEMAgsgBUUNAQsgAygCBCEAIANBADYCBCADIAAgARAvIgBFDQIgA0HiATYCHCADIAE2AhQgAyAANgIMQQAhAgyvAgsgAygCBCEAIANBADYCBCADIAAgARAvIgBFDZoCIANB4wE2AhwgAyABNgIUIAMgADYCDEEAIQIMrgILIAMoAgQhACADQQA2AgQgAyAAIAEQLyIARQ2YAiADQeQBNgIcIAMgATYCFCADIAA2AgwMrQILQckBIQIMkwILQQAhAAJAIAMoAjgiAkUNACACKAJEIgJFDQAgAyACEQAAIQALAkAgAARAIABBFUYNASADQQA2AhwgAyABNgIUIANBpA02AhAgA0EhNgIMQQAhAgytAgtByAEhAgyTAgsgA0HhATYCHCADIAE2AhQgA0HQGjYCECADQRU2AgxBACECDKsCCyABIARGBEBB4QEhAgyrAgsCQCABLQAAQSBGBEAgA0EAOwE0IAFBAWohAQwBCyADQQA2AhwgAyABNgIUIANBmRE2AhAgA0EJNgIMQQAhAgyrAgtBxwEhAgyRAgsgASAERgRAQeABIQIMqgILAkAgAS0AAEEwa0H/AXEiAkEKSQRAIAFBAWohAQJAIAMvATQiAEGZM0sNACADIABBCmwiADsBNCAAQf7/A3EgAkH//wNzSw0AIAMgACACajsBNAwCC0EAIQIgA0EANgIcIAMgATYCFCADQZUeNgIQIANBDTYCDAyrAgsgA0EANgIcIAMgATYCFCADQZUeNgIQIANBDTYCDEEAIQIMqgILQcYBIQIMkAILIAEgBEYEQEHfASECDKkCCwJAIAEtAABBMGtB/wFxIgJBCkkEQCABQQFqIQECQCADLwE0IgBBmTNLDQAgAyAAQQpsIgA7ATQgAEH+/wNxIAJB//8Dc0sNACADIAAgAmo7ATQMAgtBACECIANBADYCHCADIAE2AhQgA0GVHjYCECADQQ02AgwMqgILIANBADYCHCADIAE2AhQgA0GVHjYCECADQQ02AgxBACECDKkCC0HFASECDI8CCyABIARGBEBB3gEhAgyoAgsCQCABLQAAQTBrQf8BcSICQQpJBEAgAUEBaiEBAkAgAy8BNCIAQZkzSw0AIAMgAEEKbCIAOwE0IABB/v8DcSACQf//A3NLDQAgAyAAIAJqOwE0DAILQQAhAiADQQA2AhwgAyABNgIUIANBlR42AhAgA0ENNgIMDKkCCyADQQA2AhwgAyABNgIUIANBlR42AhAgA0ENNgIMQQAhAgyoAgtBxAEhAgyOAgsgASAERgRAQd0BIQIMpwILAkACQAJAAkAgAS0AAEEKaw4XAgMDAAMDAwMDAwMDAwMDAwMDAwMDAwEDCyABQQFqDAULIAFBAWohAUHDASECDI8CCyABQQFqIQEgA0Evai0AAEEBcQ0IIANBADYCHCADIAE2AhQgA0GNCzYCECADQQ02AgxBACECDKcCCyADQQA2AhwgAyABNgIUIANBjQs2AhAgA0ENNgIMQQAhAgymAgsgASAERwRAIANBDzYCCCADIAE2AgRBASECDI0CC0HcASECDKUCCwJAAkADQAJAIAEtAABBCmsOBAIAAAMACyAEIAFBAWoiAUcNAAtB2wEhAgymAgsgAygCBCEAIANBADYCBCADIAAgARAtIgBFBEAgAUEBaiEBDAQLIANB2gE2AhwgAyAANgIMIAMgAUEBajYCFEEAIQIMpQILIAMoAgQhACADQQA2AgQgAyAAIAEQLSIADQEgAUEBagshAUHBASECDIoCCyADQdkBNgIcIAMgADYCDCADIAFBAWo2AhRBACECDKICC0HCASECDIgCCyADQS9qLQAAQQFxDQEgA0EANgIcIAMgATYCFCADQeQcNgIQIANBGTYCDEEAIQIMoAILIAEgBEYEQEHZASECDKACCwJAAkACQCABLQAAQQprDgQBAgIAAgsgAUEBaiEBDAILIAFBAWohAQwBCyADLQAuQcAAcUUNAQtBACEAAkAgAygCOCICRQ0AIAIoAjwiAkUNACADIAIRAAAhAAsgAEUNoAEgAEEVRgRAIANB2QA2AhwgAyABNgIUIANBtxo2AhAgA0EVNgIMQQAhAgyfAgsgA0EANgIcIAMgATYCFCADQYANNgIQIANBGzYCDEEAIQIMngILIANBADYCHCADIAE2AhQgA0HcKDYCECADQQI2AgxBACECDJ0CCyABIARHBEAgA0EMNgIIIAMgATYCBEG/ASECDIQCC0HYASECDJwCCyABIARGBEBB1wEhAgycAgsCQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAIAEtAABBwQBrDhUAAQIDWgQFBlpaWgcICQoLDA0ODxBaCyABQQFqIQFB+wAhAgySAgsgAUEBaiEBQfwAIQIMkQILIAFBAWohAUGBASECDJACCyABQQFqIQFBhQEhAgyPAgsgAUEBaiEBQYYBIQIMjgILIAFBAWohAUGJASECDI0CCyABQQFqIQFBigEhAgyMAgsgAUEBaiEBQY0BIQIMiwILIAFBAWohAUGWASECDIoCCyABQQFqIQFBlwEhAgyJAgsgAUEBaiEBQZgBIQIMiAILIAFBAWohAUGlASECDIcCCyABQQFqIQFBpgEhAgyGAgsgAUEBaiEBQawBIQIMhQILIAFBAWohAUG0ASECDIQCCyABQQFqIQFBtwEhAgyDAgsgAUEBaiEBQb4BIQIMggILIAEgBEYEQEHWASECDJsCCyABLQAAQc4ARw1IIAFBAWohAUG9ASECDI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AGtBAWohBgJAA0AgAS0AACAAQejUAGotAABHDSUgAEEBRg0BIABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADPkBCyADQQA2AgAgBkEBaiEBQSYMJQsgASAERgRAQbMBIQIM+AELAkACQCABLQAAQdQAaw4CAAEnCyABQQFqIQFBmQEhAgzfAQsgAUEBaiEBQZoBIQIM3gELQbIBIQIgASAERg32ASADKAIAIgAgBCABa2ohBSABIABrQQFqIQYCQANAIAEtAAAgAEHm1ABqLQAARw0jIABBAUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAz3AQsgA0EANgIAIAZBAWohAUEnDCMLQbEBIQIgASAERg31ASADKAIAIgAgBCABa2ohBSABIABrQQFqIQYCQANAIAEtAAAgAEHk1ABqLQAARw0iIABBAUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAz2AQsgA0EANgIAIAZBAWohAUEcDCILQbABIQIgASAERg30ASADKAIAIgAgBCABa2ohBSABIABrQQVqIQYCQANAIAEtAAAgAEHe1ABqLQAARw0hIABBBUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAz1AQsgA0EANgIAIAZBAWohAUEGDCELQa8BIQIgASAERg3zASADKAIAIgAgBCABa2ohBSABIABrQQRqIQYCQANAIAEtAAAgAEHZ1ABqLQAARw0gIABBBEYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAz0AQsgA0EANgIAIAZBAWohAUEZDCALIAEgBEYEQEGuASECDPMBCwJAAkACQAJAIAEtAABBLWsOIwAkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJAEkJCQkJAIkJCQDJAsgAUEBaiEBQY4BIQIM3AELIAFBAWohAUGPASECDNsBCyABQQFqIQFBlAEhAgzaAQsgAUEBaiEBQZUBIQIM2QELQa0BIQIgASAERg3xASADKAIAIgAgBCABa2ohBSABIABrQQFqIQYCQANAIAEtAAAgAEHX1ABqLQAARw0eIABBAUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAM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IAU2AgAM6QELIANBADYCACAGQQFqIQFBCQwVC0GjASECIAEgBEYN5wEgAygCACIAIAQgAWtqIQUgASAAa0EBaiEGAkADQCABLQAAIABBpNUAai0AAEcNFCAAQQFGDQEgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAU2AgAM6AELIANBADYCACAGQQFqIQFBHwwUC0GiASECIAEgBEYN5gEgAygCACIAIAQgAWtqIQUgASAAa0ECaiEGAkADQCABLQAAIABBvtQAai0AAEcNEyAAQQJGDQEgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAU2AgAM5wELIANBADYCACAGQQFqIQFBAgwTC0GhASECIAEgBEYN5QEgAygCACIAIAQgAWtqIQUgASAAa0EBaiEGA0AgAS0AACAAQbzUAGotAABHDREgAEEBRg0CIABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADOUBCyABIARGBEBBoAEhAgzlAQtBASABLQAAQd8ARw0RGiABQQFqIQFBhwEhAgzLAQsgA0EANgIAIAZBAWohAUGIASECDMoBC0GfASECIAEgBEYN4gEgAygCACIAIAQgAWtqIQUgASAAa0EIaiEGAkADQCABLQAAIABBhNUAai0AAEcNDyAAQQhGDQEgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAU2AgAM4wELIANBADYCACAGQQFqIQFBKQwPC0GeASECIAEgBEYN4QEgAygCACIAIAQgAWtqIQUgASAAa0EDaiEGAkADQCABLQAAIABBuNQAai0AAEcNDiAAQQNGDQEgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAU2AgAM4gELIANBADYCACAGQQFqIQFBLQwOCyABIARGBEBBnQEhAgzhAQsgAS0AAEHFAEcNDiABQQFqIQFBhAEhAgzHAQsgASAERgRAQZwBIQIM4AELAkACQCABLQAAQcwAaw4IAA8PDw8PDwEPCyABQQFqIQFBggEhAgzHAQsgAUEBaiEBQYMBIQIMxgELQZsBIQIgASAERg3eASADKAIAIgAgBCABa2ohBSABIABrQQRqIQYCQANAIAEtAAAgAEGz1ABqLQAARw0LIABBBEYNASAA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ABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADNYBCyADQQA2AgAgBkEBaiEBQSQMAgsgA0EANgIADAILIAEgBEYEQEGRASECDNQBCyABLQAAQcwARw0BIAFBAWohAUETCzoAKSADKAIEIQAgA0EANgIEIAMgACABEC4iAA0CDAELQQAhAiADQQA2AhwgAyABNgIUIANB/h82AhAgA0EGNgIMDNEBC0H4ACECDLcBCyADQZABNgIcIAMgATYCFCADIAA2AgxBACECDM8BC0EAIQACQCADKAI4IgJFDQAgAigCQCICRQ0AIAMgAhEAACEACyAARQ0AIABBFUYNASADQQA2AhwgAyABNgIUIANBgg82AhAgA0EgNgIMQQAhAgzOAQtB9wAhAgy0AQsgA0GPATYCHCADIAE2AhQgA0HsGzYCECADQRU2AgxBACECDMwBCyABIARGBEBBjwEhAgzMAQsCQCABLQAAQSBGBEAgAUEBaiEBDAELIANBADYCHCADIAE2AhQgA0GbHzYCECADQQY2AgxBACECDMwBC0ECIQIMsgELA0AgAS0AAEEgRw0CIAQgAUEBaiIBRw0AC0GOASECDMoBCyABIARGBEBBjQEhAgzKAQsCQCABLQAAQQlrDgRKAABKAAtB9QAhAgywAQsgAy0AKUEFRgRAQfYAIQIMsAELQfQAIQIMrwELIAEgBEYEQEGMASECDMgBCyADQRA2AgggAyABNgIEDAoLIAEgBEYEQEGLASECDMcBCwJAIAEtAABBCWsOBEcAAEcAC0HzACECDK0BCyABIARHBEAgA0EQNgIIIAMgATYCBEHxACECDK0BC0GKASECDMUBCwJAIAEgBEcEQANAIAEtAABBoNAAai0AACIAQQNHBEACQCAAQQFrDgJJAAQLQfAAIQIMrwELIAQgAUEBaiIBRw0AC0GIASECDMYBC0GIASECDMUBCyADQQA2AhwgAyABNgIUIANB2yA2AhAgA0EHNgIMQQAhAgzEAQsgASAERgRAQYkBIQIMxAELAkACQAJAIAEtAABBoNIAai0AAEEBaw4DRgIAAQtB8gAhAgysAQsgA0EANgIcIAMgATYCFCADQbQSNgIQIANBBzYCDEEAIQIMxA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ACECDIIBCyADQfMANgIcIAMgATYCFCADQYAbNgIQIANBFTYCDEEAIQIMmgELIAMtACkiAEEja0ELSQ0JAkAgAEEGSw0AQQEgAHRBygBxRQ0ADAoLQQAhAiADQQA2AhwgAyABNgIUIANB7Qk2AhAgA0EINgIMDJkBC0HyACECIAEgBEYNmAEgAygCACIAIAQgAWtqIQUgASAAa0EBaiEGAkADQCABLQAAIABBs9UAai0AAEcNBSAAQQFGDQEgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAU2AgAMmQELIAMoAgQhACADQgA3AwAgAyAAIAZBAWoiARArIgAEQCADQfEANgIcIAMgATYCFCADIAA2AgxBACECDJkBC0HfACECDH8LQQAhAAJAIAMoAjgiAkUNACACKAI0IgJFDQAgAyACEQAAIQALAkAgAARAIABBFUYNASADQQA2AhwgAyABNgIUIANB6g02AhAgA0EmNgIMQQAhAgyZAQtB3gAhAgx/CyADQfAANgIcIAMgATYCFCADQYAbNgIQIANBFTYCDEEAIQIMlwELIAMtAClBIUYNBiADQQA2AhwgAyABNgIUIANBkQo2AhAgA0EINgIMQQAhAgyWAQtB7wAhAiABIARGDZUBIAMoAgAiACAEIAFraiEFIAEgAGtBAmohBgJAA0AgAS0AACAAQbDVAGotAABHDQIgAEECRg0BIABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADJYBCyADKAIEIQAgA0IANwMAIAMgACAGQQFqIgEQKyIARQ0CIANB7QA2AhwgAyABNgIUIAMgADYCDEEAIQIMlQELIANBADYCAAsgAygCBCEAIANBADYCBCADIAAgARArIgBFDYABIANB7gA2AhwgAyABNgIUIAMgADYCDEEAIQIMkwELQdwAIQIMeQtBACEAAkAgAygCOCICRQ0AIAIoAjQiAkUNACADIAIRAAAhAAsCQCAABEAgAEEVRg0BIANBADYCHCADIAE2AhQgA0HqDTYCECADQSY2AgxBACECDJMBC0HbACECDHkLIANB7AA2AhwgAyABNgIUIANBgBs2AhAgA0EVNgIMQQAhAgyRAQsgAy0AKSIAQSNJDQAgAEEuRg0AIANBADYCHCADIAE2AhQgA0HJCTYCECADQQg2AgxBACECDJABC0HaACECDHYLIAEgBEYEQEHrACECDI8BCwJAIAEtAABBL0YEQCABQQFqIQEMAQsgA0EANgIcIAMgATYCFCADQbI4NgIQIANBCDYCDEEAIQIMjwELQdkAIQIMdQsgASAERwRAIANBDjYCCCADIAE2AgRB2AAhAgx1C0HqACECDI0BCyABIARGBEBB6QAhAgyNAQsgAS0AAEEwayIAQf8BcUEKSQRAIAMgADoAKiABQQFqIQFB1wAhAgx0CyADKAIEIQAgA0EANgIEIAMgACABEC8iAEUNeiADQegANgIcIAMgATYCFCADIAA2AgxBACECDIwBCyABIARGBEBB5wAhAgyMAQsCQCABLQAAQS5GBEAgAUEBaiEBDAELIAMoAgQhACADQQA2AgQgAyAAIAEQLyIARQ17IANB5gA2AhwgAyABNgIUIAMgADYCDEEAIQIMjAELQdYAIQIMcgsgASAERgRAQeUAIQIMiwELQQAhAEEBIQVBASEHQQAhAgJAAkACQAJAAkACfwJAAkACQAJAAkACQAJAIAEtAABBMGsOCgoJAAECAwQFBggLC0ECDAYLQQMMBQtBBAwEC0EFDAMLQQYMAgtBBwwBC0EICyECQQAhBUEAIQcMAgtBCSECQQEhAEEAIQVBACEHDAELQQAhBUEBIQILIAMgAjoAKyABQQFqIQECQAJAIAMtAC5BEHENAAJAAkACQCADLQAqDgMBAAIECyAHRQ0DDAILIAANAQwCCyAFRQ0BCyADKAIEIQAgA0EANgIEIAMgACABEC8iAEUNAiADQeIANgIcIAMgATYCFCADIAA2AgxBACECDI0BCyADKAIEIQAgA0EANgIEIAMgACABEC8iAEUNfSADQeMANgIcIAMgATYCFCADIAA2AgxBACECDIwBCyADKAIEIQAgA0EANgIEIAMgACABEC8iAEUNeyADQeQANgIcIAMgATYCFCADIAA2AgwMiwELQdQAIQIMcQsgAy0AKUEiRg2GAUHTACECDHALQQAhAAJAIAMoAjgiAkUNACACKAJEIgJFDQAgAyACEQAAIQALIABFBEBB1QAhAgxwCyAAQRVHBEAgA0EANgIcIAMgATYCFCADQaQNNgIQIANBITYCDEEAIQIMiQELIANB4QA2AhwgAyABNgIUIANB0Bo2AhAgA0EVNgIMQQAhAgyIAQsgASAERgRAQeAAIQIMiAELAkACQAJAAkACQCABLQAAQQprDgQBBAQABAsgAUEBaiEBDAELIAFBAWohASADQS9qLQAAQQFxRQ0BC0HSACECDHALIANBADYCHCADIAE2AhQgA0G2ETYCECADQQk2AgxBACECDIgBCyADQQA2AhwgAyABNgIUIANBthE2AhAgA0EJNgIMQQAhAgyHAQsgASAERgRAQd8AIQIMhwELIAEtAABBCkYEQCABQQFqIQEMCQsgAy0ALkHAAHENCCADQQA2AhwgAyABNgIUIANBthE2AhAgA0ECNgIMQQAhAgyGAQsgASAERgRAQd0AIQIMhgELIAEtAAAiAkENRgRAIAFBAWohAUHQACECDG0LIAEhACACQQlrDgQFAQEFAQsgBCABIgBGBEBB3AAhAgyFAQsgAC0AAEEKRw0AIABBAWoMAgtBACECIANBADYCHCADIAA2AhQgA0HKLTYCECADQQc2AgwMgwELIAEgBEYEQEHbACECDIMBCwJAIAEtAABBCWsOBAMAAAMACyABQQFqCyEBQc4AIQIMaAsgASAERgRAQdoAIQIMgQELIAEtAABBCWsOBAABAQABC0EAIQIgA0EANgIcIANBmhI2AhAgA0EHNgIMIAMgAUEBajYCFAx/CyADQYASOwEqQQAhAAJAIAMoAjgiAkUNACACKAI4IgJFDQAgAyACEQAAIQALIABFDQAgAEEVRw0BIANB2QA2AhwgAyABNgIUIANB6ho2AhAgA0EVNgIMQQAhAgx+C0HNACECDGQLIANBADYCHCADIAE2AhQgA0HJDTYCECADQRo2AgxBACECDHwLIAEgBEYEQEHZACECDHwLIAEtAABBIEcNPSABQQFqIQEgAy0ALkEBcQ09IANBADYCHCADIAE2AhQgA0HCHDYCECADQR42AgxBACECDHsLIAEgBEYEQEHYACECDHsLAkACQAJAAkACQCABLQAAIgBBCmsOBAIDAwABCyABQQFqIQFBLCECDGULIABBOkcNASADQQ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BIHIgBSAFQcEAa0H/AXFBGkkbQf8BcUcNASABQQNGBEBBBiEBDD0LIAFBAWohASAEIABBAWoiAEcNAAsgAyAGNgIADFcLIANBADYCACAAIQEMAwsCQANAIAEtAAAiAEEgRwRAIABBCmsOBAcEBAcCCyAEIAFBAWoiAUcNAAtBOCECDFYLIABBLEcNASABQQFqIQBBASEBAkACQAJAAkACQCADLQAsQQVrDgQDAQIEAAsgACEBDAQLQQIhAQwBC0EEIQELIANBAToALCADIAMvATIgAXI7ATIgACEBDAELIAMgAy8BMkEIcjsBMiAAIQELQT4hAgw7CyADQQA6ACwLQTkhAgw5CyABIARGBEBBNiECDFILAkACQAJAAkACQCABLQAAQQprDgQAAgIBAgsgAygCBCEAIANBADYCBCADIAAgARAxIgBFDQIgA0EzNgIcIAMgATYCFCADIAA2AgxBACECDFULIAMoAgQhACADQQA2AgQgAyAAIAEQMSIARQRAIAFBAWohAQwGCyADQTI2AhwgAyAANgIMIAMgAUEBajYCFEEAIQIMVAsgAy0ALkEBcQRAQd8BIQIMOwsgAygCBCEAIANBADYCBCADIAAgARAxIgANAQxJC0E0IQIMOQsgA0E1NgIcIAMgATYCFCADIAA2AgxBACECDFELQTUhAgw3CyADQS9qLQAAQQFxDQAgA0EANgIcIAMgATYCFCADQesWNgIQIANBGTYCDEEAIQIMTwtBMyECDDULIAEgBEYEQEEyIQIMTgsCQCABLQAAQQpGBEAgAUEBaiEBDAELIANBADYCHCADIAE2AhQgA0GSFzYCECADQQM2AgxBACECDE4LQTIhAgw0CyABIARGBEBBMSECDE0LAkAgAS0AACIAQQlGDQAgAEEgRg0AQQEhAgJAIAMtACxBBWsOBAYEBQANCyADIAMvATJBCHI7ATIMDAsgAy0ALkEBcUUNASADLQAsQQhHDQAgA0EAOgAsC0E9IQIMMgsgA0EANgIcIAMgATYCFCADQcIWNgIQIANBCjYCDEEAIQIMSgtBAiECDAELQQQhAgsgA0EBOgAsIAMgAy8BMiACcjsBMgwGCyABIARGBEBBMCECDEcLIAEtAABBCkYEQCABQQFqIQEMAQsgAy0ALkEBcQ0AIANBADYCHCADIAE2AhQgA0HcKDYCECADQQI2AgxBACECDEYLQTAhAgwsCyABQQFqIQFBMSECDCsLIAEgBEYEQEEvIQIMRAsgAS0AACIAQQlHIABBIEdxRQRAIAFBAWohASADLQAuQQFxDQEgA0EANgIcIAMgATYCFCADQZcQNgIQIANBCjYCDEEAIQIMRAtBASECAkACQAJAAkACQAJAIAMtACxBAmsOBwUEBAMBAgAECyADIAMvATJBCHI7ATIMAwtBAiECDAELQQQhAgsgA0EBOgAsIAMgAy8BMiACcjsBMgtBLyECDCsLIANBADYCHCADIAE2AhQgA0GEEzYCECADQQs2AgxBACECDEMLQeEBIQIMKQsgASAERgRAQS4hAgxCCyADQQA2AgQgA0ESNgIIIAMgASABEDEiAA0BC0EuIQIMJwsgA0EtNgIcIAMgATYCFCADIAA2AgxBACECDD8LQQAhAAJAIAMoAjgiAkUNACACKAJMIgJFDQAgAyACEQAAIQALIABFDQAgAEEVRw0BIANB2AA2AhwgAyABNgIUIANBsxs2AhAgA0EVNgIMQQAhAgw+C0HMACECDCQLIANBADYCHCADIAE2AhQgA0GzDjYCECADQR02AgxBACECDDwLIAEgBEYEQEHOACECDDwLIAEtAAAiAEEgRg0CIABBOkYNAQsgA0EAOgAsQQkhAgwhCyADKAIEIQAgA0EANgIEIAMgACABEDAiAA0BDAILIAMtAC5BAXEEQEHeASECDCALIAMoAgQhACADQQA2AgQgAyAAIAEQMCIARQ0CIANBKjYCHCADIAA2AgwgAyABQQFqNgIUQQAhAgw4CyADQcsANgIcIAMgADYCDCADIAFBAWo2AhRBACECDDcLIAFBAWohAUHAACECDB0LIAFBAWohAQwsCyABIARGBEBBKyECDDULAkAgAS0AAEEKRgRAIAFBAWohAQwBCyADLQAuQcAAcUUNBgsgAy0AMkGAAXEEQEEAIQACQCADKAI4IgJFDQAgAigCXCICRQ0AIAMgAhEAACEACyAARQ0SIABBFUYEQCADQQU2AhwgAyABNgIUIANB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NSSUJFVFRQQ0VUU1BBRFRQLw==","base64"))})},7136:(e,t,s)=>{"use strict";e=s.nmd(e);const{Buffer:r}=s(4573);let n;Object.defineProperty(e,"exports",{get:()=>n||(n=r.from("AGFzbQEAAAABJwdgAX8Bf2ADf39/AX9gAn9/AGABfwBgBH9/f38Bf2AAAGADf39/AALLAQgDZW52GHdhc21fb25faGVhZGVyc19jb21wbGV0ZQAEA2VudhV3YXNtX29uX21lc3NhZ2VfYmVnaW4AAANlbnYLd2FzbV9vbl91cmwAAQNlbnYOd2FzbV9vbl9zdGF0dXMAAQNlbnYUd2FzbV9vbl9oZWFkZXJfZmllbGQAAQNlbnYUd2FzbV9vbl9oZWFkZXJfdmFsdWUAAQNlbnYMd2FzbV9vbl9ib2R5AAEDZW52GHdhc21fb25fbWVzc2FnZV9jb21wbGV0ZQAAAzU0BQYAAAMAAAAAAAADAQMAAwMDAAACAAAAAAICAgICAgICAgIBAQEBAQEBAQEBAwAAAwAAAAQFAXABExMFAwEAAgYIAX8BQcDZBAsHxQcoBm1lbW9yeQIAC19pbml0aWFsaXplAAgZX19pbmRpcmVjdF9mdW5jdGlvbl90YWJsZQEAC2xsaHR0cF9pbml0AAkYbGxodHRwX3Nob3VsZF9rZWVwX2FsaXZlADcMbGxodHRwX2FsbG9jAAsGbWFsbG9jADkLbGxodHRwX2ZyZWUADARmcmVlAAwPbGxodHRwX2dldF90eXBlAA0VbGxodHRwX2dldF9odHRwX21ham9yAA4VbGxodHRwX2dldF9odHRwX21pbm9yAA8RbGxodHRwX2dldF9tZXRob2QAEBZsbGh0dHBfZ2V0X3N0YXR1c19jb2RlABESbGxodHRwX2dldF91cGdyYWRlABIMbGxodHRwX3Jlc2V0ABMObGxodHRwX2V4ZWN1dGUAFBRsbGh0dHBfc2V0dGluZ3NfaW5pdAAVDWxsaHR0cF9maW5pc2gAFgxsbGh0dHBfcGF1c2UAFw1sbGh0dHBfcmVzdW1lABgbbGxodHRwX3Jlc3VtZV9hZnRlcl91cGdyY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RQ0AAkAgBSgCHCICQQJ0QfTXAGoiAygCACAFRgRAIAMgADYCACAADQFByNUAQcjVACgCAEF+IAJ3cTYCAAwCCyAGQRBBFCAGKAIQIAVGG2ogADYCACAARQ0BCyAAIAY2AhggBSgCECICBEAgACACNgIQIAIgADYCGAsgBUEUaigCACICRQ0AIABBFGogAjYCACACIAA2AhgLIAEgBGogBDYCACABIARBAXI2AgQgAUHY1QAoAgBHDQBBzNUAIAQ2AgAMAQsgBEH/AU0EQCAEQXhxQezVAGohAAJ/QcTVACgCACICQQEgBEEDdnQiA3FFBEBBxNUAIAIgA3I2AgAgAAwBCyAAKAIICyICIAE2AgwgACABNgIIIAEgADYCDCABIAI2AggMAQtBHyECIARB////B00EQCAEQSYgBEEIdmciAGt2QQFxIABBAXRrQT5qIQILIAEgAjYCHCABQgA3AhAgAkECdEH01wBqIQACQEHI1QAoAgAiA0EBIAJ0IgdxRQRAIAAgATYCAEHI1QAgAyAHcjYCACABIAA2AhggASABNgIIIAEgATYCDAwBCyAEQRkgAkEBdmtBACACQR9HG3QhAiAAKAIAIQACQANAIAAiAygCBEF4cSAERg0BIAJBHXYhACACQQF0IQIgAyAAQQRxakEQaiIHKAIAIgANAAsgByABNgIAIAEgAzYCGCABIAE2AgwgASABNgIIDAELIAMoAggiACABNgIMIAMgATYCCCABQQA2AhggASADNgIMIAEgADYCCAtB5NUAQeTVACgCAEEBayIAQX8gABs2AgALCwcAIAAtACgLBwAgAC0AKgsHACAALQArCwcAIAAtACkLBwAgAC8BNAsHACAALQAwC0ABBH8gACgCGCEBIAAvAS4hAiAALQAoIQMgACgCOCEEIAAQOCAAIAQ2AjggACADOgAoIAAgAjsBLiAAIAE2AhgLhocCAwd/A34BeyABIAJqIQQCQCAAIgMoAgwiAA0AIAMoAgQEQCADIAE2AgQLIwBBEGsiCSQAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACfwJAAkACQAJAAkACQAJAAkACQAJAA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QAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACfwJAAkACQAJAAkACQAJAAn8CQAJAAkACfwJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAgAwJ/AkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJ/AkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQCACDuMBAAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISMkJScoKZ4DmwOaA5EDigODA4AD/QL7AvgC8gLxAu8C7QLoAucC5gLlAuQC3ALbAtoC2QLYAtcC1gLVAs8CzgLMAssCygLJAsgCxwLGAsQCwwK+ArwCugK5ArgCtwK2ArUCtAKzArICsQKwAq4CrQKpAqgCpwKmAqUCpAKjAqICoQKgAp8CmAKQAowCiwKKAoEC/gH9AfwB+wH6AfkB+AH3AfUB8wHwAesB6QHoAecB5gHlAeQB4wHiAeEB4AHfAd4B3QHcAdoB2QHYAdcB1g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CIARQRAIAFBAWohAQzzAgsgA0EXNgIcIAMgADYCDCADIAFBAWo2AhQM+AILIABBFUYNI0EAIQIgA0EANgIcIAMgATYCFCADQdYMNgIQIANBIzYCDAz3AgsgAygCBCEAQQAhAiADQQA2AgQgAyAAIAEQNCIARQRAIAFBAWohAQwdCyADQRk2AhwgAyAANgIMIAMgAUEBajYCFAz2AgsgAygCBCEAQQAhAiADQQA2AgQgAyAAIAEQNCIARQRAIAFBAWohAQzvAgsgA0EaNgIcIAMgADYCDCADIAFBAWo2AhQM9QILIABBFUYNH0EAIQIgA0EANgIcIAMgATYCFCADQdAPNgIQIANBIjYCDAz0AgsgAygCBCEAIANBADYCBCADIAAgARAzIgBFBEAgAUEBaiEBDBsLIANBHDYCHCADIAA2AgwgAyABQQFqNgIUQQAhAgzzAgsgAygCBCEAIANBADYCBCADIAAgARAzIgBFBEAgAUEBaiEBDOsCCyADQR02AhwgAyAANgIMIAMgAUEBajYCFEEAIQIM8gILIABBO0cNASABQQFqIQELQSYhAgzXAgtBACECIANBADYCHCADIAE2AhQgA0GfFTYCECADQQw2AgwM7wILIAEgBEcEQANAIAEtAABBIEcNhAIgBCABQQFqIgFHDQALQSwhAgzvAgtBLCECDO4CCyABIARGBEBBNCECDO4CCwJAAkADQAJAIAEtAABBCmsOBAIAAAMACyAEIAFBAWoiAUcNAAtBNCECDO8CCyADKAIEIQAgA0EANgIEIAMgACABEDEiAEUNnwIgA0EyNgIcIAMgATYCFCADIAA2AgxBACECDO4CCyADKAIEIQAgA0EANgIEIAMgACABEDEiAEUEQCABQQFqIQEMnwILIANBMjYCHCADIAA2AgwgAyABQQFqNgIUQQAhAgztAgsgASAERwRAAkADQCABLQAAQTBrIgBB/wFxQQpPBEBBOiECDNcCCyADKQMgIgtCmbPmzJmz5swZVg0BIAMgC0IKfiIKNwMgIAogAK1C/wGDIgtCf4VWDQEgAyAKIAt8NwMgIAQgAUEBaiIBRw0AC0HAACECDO4CCyADKAIEIQAgA0EANgIEIAMgACABQQFqIgEQMSIADRcM4gILQcAAIQIM7AILIAEgBEYEQEHJACECDOwCCwJAA0ACQCABLQAAQQlrDhgAAqICogKpAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAgCiAgsgBCABQQFqIgFHDQALQckAIQIM7AILIAFBAWohASADQS9qLQAAQQFxDaUCIANBADYCHCADIAE2AhQgA0GXEDYCECADQQo2AgxBACECDOsCCyABIARHBEADQCABLQAAQSBHDRUgBCABQQFqIgFHDQALQfgAIQIM6wILQfgAIQIM6gILIANBAjoAKAw4C0EAIQIgA0EANgIcIANBvws2AhAgA0ECNgIMIAMgAUEBajYCFAzoAgtBACECDM4CC0ENIQIMzQILQRMhAgzMAgtBFSECDMsCC0EWIQIMygILQRghAgzJAgtBGSECDMgCC0EaIQIMxwILQRshAgzGAgtBHCECDMUCC0EdIQIMxAILQR4hAgzDAgtBHyECDMICC0EgIQIMwQILQSIhAgzAAgtBIyECDL8CC0ElIQIMvgILQeUAIQIMvQILIANBPTYCHCADIAE2AhQgAyAANgIMQQAhAgzVAgsgA0EbNgIcIAMgATYCFCADQaQcNgIQIANBFTYCDEEAIQIM1AILIANBIDYCHCADIAE2AhQgA0GYGjYCECADQRU2AgxBACECDNMCCyADQRM2AhwgAyABNgIUIANBmBo2AhAgA0EVNgIMQQAhAgzSAgsgA0ELNgIcIAMgATYCFCADQZgaNgIQIANBFTYCDEEAIQIM0QILIANBEDYCHCADIAE2AhQgA0GYGjYCECADQRU2AgxBACECDNACCyADQSA2AhwgAyABNgIUIANBpBw2AhAgA0EVNgIMQQAhAgzPAgsgA0ELNgIcIAMgATYCFCADQaQcNgIQIANBFTYCDEEAIQIMzgILIANBDDYCHCADIAE2AhQgA0GkHDYCECADQRU2AgxBACECDM0CC0EAIQIgA0EANgIcIAMgATYCFCADQd0ONgIQIANBEjYCDAzMAgsCQANAAkAgAS0AAEEKaw4EAAICAAILIAQgAUEBaiIBRw0AC0H9ASECDMwCCwJAAkAgAy0ANkEBRw0AQQAhA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A2AhwgAyABNgIUIANB5R82AhAgA0EINgIMDL8CC0HVASECDKUCCyADQfMBNgIcIAMgATYCFCADIAA2AgxBACECDL0CC0EAIQACQCADKAI4IgJFDQAgAigCQCICRQ0AIAMgAhEAACEACyAARQ1uIABBFUcEQCADQQA2AhwgAyABNgIUIANBgg82AhAgA0EgNgIMQQAhAgy9AgsgA0GPATYCHCADIAE2AhQgA0HsGzYCECADQRU2AgxBACECDLwCCyABIARHBEAgA0ENNgIIIAMgATYCBEHTASECDKMCC0HyASECDLsCCyABIARGBEBB8QEhAgy7AgsCQAJAAkAgAS0AAEHIAGsOCwABCAgICAgICAgCCAsgAUEBaiEBQdABIQIMowILIAFBAWohAUHRASECDKICCyABQQFqIQFB0gEhAgyhAgtB8AEhAiABIARGDbkCIAMoAgAiACAEIAFraiEGIAEgAGtBAmohBQNAIAEtAAAgAEG11QBqLQAARw0EIABBAkYNAyAAQQFqIQAgBCABQQFqIgFHDQALIAMgBjYCAAy5AgtB7wEhAiABIARGDbgCIAMoAgAiACAEIAFraiEGIAEgAGtBAWohBQNAIAEtAAAgAEGz1QBqLQAARw0DIABBAUYNAiAAQQFqIQAgBCABQQFqIgFHDQALIAMgBjYCAAy4AgtB7gEhAiABIARGDbcCIAMoAgAiACAEIAFraiEGIAEgAGtBAmohBQNAIAEtAAAgAEGw1QBqLQAARw0CIABBAkYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBjYCAAy3AgsgAygCBCEAIANCADcDACADIAAgBUEBaiIBECsiAEUNAiADQewBNgIcIAMgATYCFCADIAA2AgxBACECDLYCCyADQQA2AgALIAMoAgQhACADQQA2AgQgAyAAIAEQKyIARQ2cAiADQe0BNgIcIAMgATYCFCADIAA2AgxBACECDLQCC0HPASECDJoCC0EAIQACQCADKAI4IgJFDQAgAigCNCICRQ0AIAMgAhEAACEACwJAIAAEQCAAQRVGDQEgA0EANgIcIAMgATYCFCADQeoNNgIQIANBJjYCDEEAIQIMtAILQc4BIQIMmgILIANB6wE2AhwgAyABNgIUIANBgBs2AhAgA0EVNgIMQQAhAgyyAgsgASAERgRAQesBIQIMsgILIAEtAABBL0YEQCABQQFqIQEMAQsgA0EANgIcIAMgATYCFCADQbI4NgIQIANBCDYCDEEAIQIMsQILQc0BIQIMlwILIAEgBEcEQCADQQ42AgggAyABNgIEQcwBIQIMlwILQeoBIQIMrwILIAEgBEYEQEHpASECDK8CCyABLQAAQTBrIgBB/wFxQQpJBEAgAyAAOgAqIAFBAWohAUHLASECDJYCCyADKAIEIQAgA0EANgIEIAMgACABEC8iAEUNlwIgA0HoATYCHCADIAE2AhQgAyAANgIMQQAhAgyuAgsgASAERgRAQecBIQIMrgILAkAgAS0AAEEuRgRAIAFBAWohAQwBCyADKAIEIQAgA0EANgIEIAMgACABEC8iAEUNmAIgA0HmATYCHCADIAE2AhQgAyAANgIMQQAhAgyuAgtBygEhAgyUAgsgASAERgRAQeUBIQIMrQILQQAhAEEBIQVBASEHQQAhAgJAAkACQAJAAkACfwJAAkACQAJAAkACQAJAIAEtAABBMGsOCgoJAAECAwQFBggLC0ECDAYLQQMMBQtBBAwEC0EFDAMLQQYMAgtBBwwBC0EICyECQQAhBUEAIQcMAgtBCSECQQEhAEEAIQVBACEHDAELQQAhBUEBIQILIAMgAjoAKyABQQFqIQECQAJAIAMtAC5BEHENAAJAAkACQCADLQAqDgMBAAIECyAHRQ0DDAILIAANAQwCCyAFRQ0BCyADKAIEIQAgA0EANgIEIAMgACABEC8iAEUNAiADQeIBNgIcIAMgATYCFCADIAA2AgxBACECDK8CCyADKAIEIQAgA0EANgIEIAMgACABEC8iAEUNmgIgA0HjATYCHCADIAE2AhQgAyAANgIMQQAhAgyuAgsgAygCBCEAIANBADYCBCADIAAgARAvIgBFDZgCIANB5AE2AhwgAyABNgIUIAMgADYCDAytAgtByQEhAgyTAgtBACEAAkAgAygCOCICRQ0AIAIoAkQiAkUNACADIAIRAAAhAAsCQCAABEAgAEEVRg0BIANBADYCHCADIAE2AhQgA0GkDTYCECADQSE2AgxBACECDK0CC0HIASECDJMCCyADQeEBNgIcIAMgATYCFCADQdAaNgIQIANBFTYCDEEAIQIMqwILIAEgBEYEQEHhASECDKsCCwJAIAEtAABBIEYEQCADQQA7ATQgAUEBaiEBDAELIANBADYCHCADIAE2AhQgA0GZETYCECADQQk2AgxBACECDKsCC0HHASECDJECCyABIARGBEBB4AEhAgyqAgsCQCABLQAAQTBrQf8BcSICQQpJBEAgAUEBaiEBAkAgAy8BNCIAQZkzSw0AIAMgAEEKbCIAOwE0IABB/v8DcSACQf//A3NLDQAgAyAAIAJqOwE0DAILQQAhAiADQQA2AhwgAyABNgIUIANBlR42AhAgA0ENNgIMDKsCCyADQQA2AhwgAyABNgIUIANBlR42AhAgA0ENNgIMQQAhAgyqAgtBxgEhAgyQAgsgASAERgRAQd8BIQIMqQILAkAgAS0AAEEwa0H/AXEiAkEKSQRAIAFBAWohAQJAIAMvATQiAEGZM0sNACADIABBCmwiADsBNCAAQf7/A3EgAkH//wNzSw0AIAMgACACajsBNAwCC0EAIQIgA0EANgIcIAMgATYCFCADQZUeNgIQIANBDTYCDAyqAgsgA0EANgIcIAMgATYCFCADQZUeNgIQIANBDTYCDEEAIQIMqQILQcUBIQIMjwILIAEgBEYEQEHeASECDKgCCwJAIAEtAABBMGtB/wFxIgJBCkkEQCABQQFqIQECQCADLwE0IgBBmTNLDQAgAyAAQQpsIgA7ATQgAEH+/wNxIAJB//8Dc0sNACADIAAgAmo7ATQMAgtBACECIANBADYCHCADIAE2AhQgA0GVHjYCECADQQ02AgwMqQILIANBADYCHCADIAE2AhQgA0GVHjYCECADQQ02AgxBACECDKgCC0HEASECDI4CCyABIARGBEBB3QEhAgynAgsCQAJAAkACQCABLQAAQQprDhcCAwMAAwMDAwMDAwMDAwMDAwMDAwMDAQMLIAFBAWoMBQsgAUEBaiEBQcMBIQIMjwILIAFBAWohASADQS9qLQAAQQFxDQggA0EANgIcIAMgATYCFCADQY0LNgIQIANBDTYCDEEAIQIMpwILIANBADYCHCADIAE2AhQgA0GNCzYCECADQQ02AgxBACECDKYCCyABIARHBEAgA0EPNgIIIAMgATYCBEEBIQIMjQILQdwBIQIMpQILAkACQANAAkAgAS0AAEEKaw4EAgAAAwALIAQgAUEBaiIBRw0AC0HbASECDKYCCyADKAIEIQAgA0EANgIEIAMgACABEC0iAEUEQCABQQFqIQEMBAsgA0HaATYCHCADIAA2AgwgAyABQQFqNgIUQQAhAgylAgsgAygCBCEAIANBADYCBCADIAAgARAtIgANASABQQFqCyEBQcEBIQIMigILIANB2QE2AhwgAyAANgIMIAMgAUEBajYCFEEAIQIMogILQcIBIQIMiAILIANBL2otAABBAXENASADQQA2AhwgAyABNgIUIANB5Bw2AhAgA0EZNgIMQQAhAgygAgsgASAERgRAQdkBIQIMoAILAkACQAJAIAEtAABBCmsOBAECAgACCyABQQFqIQEMAgsgAUEBaiEBDAELIAMtAC5BwABxRQ0BC0EAIQACQCADKAI4IgJFDQAgAigCPCICRQ0AIAMgAhEAACEACyAARQ2gASAAQRVGBEAgA0HZADYCHCADIAE2AhQgA0G3GjYCECADQRU2AgxBACECDJ8CCyADQQA2AhwgAyABNgIUIANBgA02AhAgA0EbNgIMQQAhAgyeAgsgA0EANgIcIAMgATYCFCADQdwoNgIQIANBAjYCDEEAIQIMnQILIAEgBEcEQCADQQw2AgggAyABNgIEQb8BIQIMhAILQdgBIQIMnAILIAEgBEYEQEHXASECDJwCCwJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAgAS0AAEHBAGsOFQABAgNaBAUGWlpaBwgJCgsMDQ4PEFoLIAFBAWohAUH7ACECDJICCyABQQFqIQFB/AAhAgyRAgsgAUEBaiEBQYEBIQIMkAILIAFBAWohAUGFASECDI8CCyABQQFqIQFBhgEhAgyOAgsgAUEBaiEBQYkBIQIMjQILIAFBAWohAUGKASECDIwCCyABQQFqIQFBjQEhAgyLAgsgAUEBaiEBQZYBIQIMigILIAFBAWohAUGXASECDIkCCyABQQFqIQFBmAEhAgyIA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QEhAgz7AQsgAUEBaiEBQbYBIQIM+gELQc4BIQIgASAERg2SAiADKAIAIgAgBCABa2ohBSABIABrQQJqIQYCQANAIAEtAAAgAEGe1QBqLQAARw0/IABBAkYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAyTAgsgA0EANgIAIAZBAWohAUEHDD8LQc0BIQIgASAERg2RAiADKAIAIgAgBCABa2ohBSABIABrQQVqIQYCQANAIAEtAAAgAEGY1QBqLQAARw0+IABBBUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAySAgsgA0EANgIAIAZBAWohAUEoDD4LIAEgBEYEQEHMASECDJECCwJAAkACQCABLQAAQcUAaw4RAEFBQUFBQUFBQQFBQUFBQQJBCyABQQFqIQFBsQEhAgz5AQsgAUEBaiEBQbIBIQIM+AELIAFBAWohAUGzASECDPcBC0HLASECIAEgBEYNjwIgAygCACIAIAQgAWtqIQUgASAAa0EGaiEGAkADQCABLQAAIABBkdUAai0AAEcNPCAAQQZGDQEgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAU2AgAMkAILIANBADYCACAGQQFqIQFBGgw8C0HKASECIAEgBEYNjgIgAygCACIAIAQgAWtqIQUgASAAa0EDaiEGAkADQCABLQAAIABBjdUAai0AAEcNOyAAQQNGDQEgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAU2AgAMjwILIANBADYCACAGQQFqIQFBIQw7CyABIARGBEBByQEhAgyOAgsCQAJAIAEtAABBwQBrDhQAPT09PT09PT09PT09PT09PT09AT0LIAFBAWohAUGtASECDPUBCyABQQFqIQFBsAEhAgz0AQsgASAERgRAQcgBIQIMjQILAkACQCABLQAAQdUAaw4LADw8PDw8PDw8PAE8CyABQQFqIQFBrgEhAgz0AQsgAUEBaiEBQa8BIQIM8wELQccBIQIgASAERg2LAiADKAIAIgAgBCABa2ohBSABIABrQQhqIQYCQANAIAEtAAAgAEGE1QBqLQAARw04IABBCEYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAyMAgsgA0EANgIAIAZBAWohAUEqDDgLIAEgBEYEQEHGASECDIsCCyABLQAAQdAARw04IAFBAWohAUElDDcLQcUBIQIgASAERg2JAiADKAIAIgAgBCABa2ohBSABIABrQQJqIQYCQANAIAEtAAAgAEGB1QBqLQAARw02IABBAkYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAyKAgsgA0EANgIAIAZBAWohAUEODDYLIAEgBEYEQEHEASECDIkCCyABLQAAQcUARw02IAFBAWohAUGrASECDO8BCyABIARGBEBBwwEhAgyIAgsCQAJAAkACQCABLQAAQcIAaw4PAAECOTk5OTk5OTk5OTkDOQsgAUEBaiEBQacBIQIM8QELIAFBAWohAUGoASECDPABCyABQQFqIQFBqQEhAgzvAQsgAUEBaiEBQaoBIQIM7gELQcIBIQIgASAERg2GAiADKAIAIgAgBCABa2ohBSABIABrQQJqIQYCQANAIAEtAAAgAEH+1ABqLQAARw0zIABBAkYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAyHAgsgA0EANgIAIAZBAWohAUEUDDMLQcEBIQIgASAERg2FAiADKAIAIgAgBCABa2ohBSABIABrQQRqIQYCQANAIAEtAAAgAEH51ABqLQAARw0yIABBBEYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAyGAgsgA0EANgIAIAZBAWohAUErDDILQcABIQIgASAERg2EAiADKAIAIgAgBCABa2ohBSABIABrQQJqIQYCQANAIAEtAAAgAEH21ABqLQAARw0xIABBAkYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAyFAgsgA0EANgIAIAZBAWohAUEsDDELQb8BIQIgASAERg2DAiADKAIAIgAgBCABa2ohBSABIABrQQJqIQYCQANAIAEtAAAgAEGh1QBqLQAARw0wIABBAkYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAyEAgsgA0EANgIAIAZBAWohAUERDDALQb4BIQIgASAERg2CAiADKAIAIgAgBCABa2ohBSABIABrQQNqIQYCQANAIAEtAAAgAE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QsgAUEBaiEBQY8BIQIM2wELIAFBAWohAUGUASECDNoBCyABQQFqIQFBlQEhAgzZAQtBrQEhAiABIARGDfEBIAMoAgAiACAEIAFraiEFIAEgAGtBAWohBgJAA0AgAS0AACAAQdfUAGotAABHDR4gAEEBRg0BIABBAWohACAEIAFBAWoiAUcNAAsgAyAFNgIADPIBCyADQQA2AgAgBkEBaiEBQQsMHgsgASAERgRAQawBIQIM8QELAkACQCABLQAAQcEAaw4DACABIAsgAUEBaiEBQZABIQIM2AELIAFBAWohAUGTASECDNcBCyABIARGBEBBqwEhAgzwAQsCQAJAIAEtAABBwQBrDg8AHx8fHx8fHx8fHx8fHwEfCyABQQFqIQFBkQEhAgzXAQsgAUEBaiEBQZIBIQIM1gELIAEgBEYEQEGqASECDO8BCyABLQAAQcwARw0cIAFBAWohAUEKDBsLQakBIQIgASAERg3tASADKAIAIgAgBCABa2ohBSABIABrQQVqIQYCQANAIAEtAAAgAEHR1ABqLQAARw0aIABBBUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAzuAQsgA0EANgIAIAZBAWohAUEeDBoLQagBIQIgASAERg3sASADKAIAIgAgBCABa2ohBSABIABrQQZqIQYCQANAIAEtAAAgAEHK1ABqLQAARw0ZIABBBkYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAztAQsgA0EANgIAIAZBAWohAUEVDBkLQacBIQIgASAERg3rASADKAIAIgAgBCABa2ohBSABIABrQQJqIQYCQANAIAEtAAAgAEHH1ABqLQAARw0YIABBAkYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAzsAQsgA0EANgIAIAZBAWohAUEXDBgLQaYBIQIgASAERg3qASADKAIAIgAgBCABa2ohBSABIABrQQVqIQYCQANAIAEtAAAgAEHB1ABqLQAARw0XIABBBUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAzrAQsgA0EANgIAIAZBAWohAUEYDBcLIAEgBEYEQEGlASECDOoBCwJAAkAgAS0AAEHJAGsOBwAZGRkZGQEZCyABQQFqIQFBiwEhAgzRAQsgAUEBaiEBQYwBIQIM0AELQaQBIQIgASAERg3oASADKAIAIgAgBCABa2ohBSABIABrQQFqIQYCQANAIAEtAAAgAEGm1QBqLQAARw0VIABBAUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAzpAQsgA0EANgIAIAZBAWohAUEJDBULQaMBIQIgASAERg3nASADKAIAIgAgBCABa2ohBSABIABrQQFqIQYCQANAIAEtAAAgAEGk1QBqLQAARw0UIABBAUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAzoAQsgA0EANgIAIAZBAWohAUEfDBQLQaIBIQIgASAERg3mASADKAIAIgAgBCABa2ohBSABIABrQQJqIQYCQANAIAEtAAAgAEG+1ABqLQAARw0TIABBAkYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAznAQsgA0EANgIAIAZBAWohAUECDBMLQaEBIQIgASAERg3lASADKAIAIgAgBCABa2ohBSABIABrQQFqIQYDQCABLQAAIABBvNQAai0AAEcNESAAQQFGDQIgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAU2AgAM5QELIAEgBEYEQEGgASECDOUBC0EBIAEtAABB3wBHDREaIAFBAWohAUGHASECDMsBCyADQQA2AgAgBkEBaiEBQYgBIQIMygELQZ8BIQIgASAERg3iASADKAIAIgAgBCABa2ohBSABIABrQQhqIQYCQANAIAEtAAAgAEGE1QBqLQAARw0PIABBCEYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAzjAQsgA0EANgIAIAZBAWohAUEpDA8LQZ4BIQIgASAERg3hASADKAIAIgAgBCABa2ohBSABIABrQQNqIQYCQANAIAEtAAAgAEG41ABqLQAARw0OIABBA0YNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAziAQsgA0EANgIAIAZBAWohAUEtDA4LIAEgBEYEQEGdASECDOEBCyABLQAAQcUARw0OIAFBAWohAUGEASECDMcBCyABIARGBEBBnAEhAgz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ACQCABLQAAQcMAaw4MAAYGBgYGBgYGBgYBBgsgAUEBaiEBQfkAIQIMvgELIAFBAWohAUH6ACECDL0BC0GSASECIAEgBEYN1QEgAygCACIAIAQgAWtqIQUgASAAa0EFaiEGAkADQCABLQAAIABBoNQAai0AAEcNAiAAQQVGDQEgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAU2AgAM1gELIANBADYCACAGQQFqIQFBJAwCCyADQQA2AgAMAgsgASAERgRAQZEBIQIM1AELIAEtAABBzABHDQEgAUEBaiEBQRMLOgApIAMoAgQhACADQQA2AgQgAyAAIAEQLiIADQIMAQtBACECIANBADYCHCADIAE2AhQgA0H+HzYCECADQQY2AgwM0QELQfgAIQIMtwELIANBkAE2AhwgAyABNgIUIAMgADYCDEEAIQIMzwELQQAhAAJAIAMoAjgiAkUNACACKAJAIgJFDQAgAyACEQAAIQALIABFDQAgAEEVRg0BIANBADYCHCADIAE2AhQgA0GCDzYCECADQSA2AgxBACECDM4BC0H3ACECDLQBCyADQY8BNgIcIAMgATYCFCADQewbNgIQIANBFTYCDEEAIQIMzAELIAEgBEYEQEGPASECDMwBCwJAIAEtAABBIEYEQCABQQFqIQEMAQsgA0EANgIcIAMgATYCFCADQZsfNgIQIANBBjYCDEEAIQIMzAELQQIhAgyyAQsDQCABLQAAQSBHDQIgBCABQQFqIgFHDQALQY4BIQIMygELIAEgBEYEQEGNASECDMoBCwJAIAEtAABBCWsOBEoAAEoAC0H1ACECDLABCyADLQApQQVGBEBB9gAhAgywAQtB9AAhAgyvAQsgASAERgRAQYwBIQIMyAELIANBEDYCCCADIAE2AgQMCgsgASAERgRAQYsBIQIMxwELAkAgAS0AAEEJaw4ERwAARwALQfMAIQIMrQELIAEgBEcEQCADQRA2AgggAyABNgIEQfEAIQIMrQELQYoBIQIMxQELAkAgASAERwRAA0AgAS0AAEGg0ABqLQAAIgBBA0cEQAJAIABBAWsOAkkABAtB8AAhAgyvAQsgBCABQQFqIgFHDQALQYgBIQIMxgELQYgBIQIMxQELIANBADYCHCADIAE2AhQgA0HbIDYCECADQQc2AgxBACECDMQBCyABIARGBEBBiQEhAgzEAQsCQAJAAkAgAS0AAEGg0gBqLQAAQQFrDgNGAgABC0HyACECDKwBCyADQQA2AhwgAyABNgIUIANBtBI2AhAgA0EHNgIMQQAhAgzEAQtB6gAhAgyqAQsgASAERwRAIAFBAWohAUHvACECDKoBC0GHASECDMIBCyAEIAEiAEYEQEGGASECDMIBCyAALQAAIgFBL0YEQCAAQQFqIQFB7gAhAgypAQsgAUEJayICQRdLDQEgACEBQQEgAnRBm4CABHENQQwBCyAEIAEiAEYEQEGFASECDMEBCyAALQAAQS9HDQAgAEEBaiEBDAMLQQAhAiADQQA2AhwgAyAANgIUIANB2yA2AhAgA0EHNgIMDL8BCwJAAkACQAJAAkADQCABLQAAQaDOAGotAAAiAEEFRwRAAkACQCAAQQFrDghHBQYHCAAEAQgLQesAIQIMrQELIAFBAWohAUHtACECDKwBCyAEIAFBAWoiAUcNAAtBhAEhAgzDAQsgAUEBagwUCyADKAIEIQAgA0EANgIEIAMgACABECwiAEUNHiADQdsANgIcIAMgATYCFCADIAA2AgxBACECDMEBCyADKAIEIQAgA0EANgIEIAMgACABECwiAEUNHiADQd0ANgIcIAMgATYCFCADIAA2AgxBACECDMABCyADKAIEIQAgA0EANgIEIAMgACABECwiAEUNHiADQfoANgIcIAMgATYCFCADIAA2AgxBACECDL8BCyADQQA2AhwgAyABNgIUIANB+Q82AhAgA0EHNgIMQQAhAgy+AQsgASAERgRAQYMBIQIMvgELAkAgAS0AAEGgzgBqLQAAQQFrDgg+BAUGAAgCAwcLIAFBAWohAQtBAyECDKMBCyABQQFqDA0LQQAhAiADQQA2AhwgA0HREjYCECADQQc2AgwgAyABQQFqNgIUDLoBCyADKAIEIQAgA0EANgIEIAMgACABECwiAEUNFiADQdsANgIcIAMgATYCFCADIAA2AgxBACECDLkBCyADKAIEIQAgA0EANgIEIAMgACABECwiAEUNFiADQd0ANgIcIAMgATYCFCADIAA2AgxBACECDLgBCyADKAIEIQAgA0EANgIEIAMgACABECwiAEUNFiADQfoANgIcIAMgATYCFCADIAA2AgxBACECDLcBCyADQQA2AhwgAyABNgIUIANB+Q82AhAgA0EHNgIMQQAhAgy2AQtB7AAhAgycAQsgASAERgRAQYIBIQIMtQELIAFBAWoMAgsgASAERgRAQYEBIQIMtAELIAFBAWoMAQsgASAERg0BIAFBAWoLIQFBBCECDJgBC0GAASECDLABCwNAIAEtAABBoMwAai0AACIAQQJHBEAgAEEBRwRAQekAIQIMmQELDDELIAQgAUEBaiIBRw0AC0H/ACECDK8BCyABIARGBEBB/gAhAgyvAQsCQCABLQAAQQlrDjcvAwYvBAYGBgYGBgYGBgYGBgYGBgYGBgUGBgIGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYABgsgAUEBagshAUEFIQIMlAELIAFBAWoMBgsgAygCBCEAIANBADYCBCADIAAgARAsIgBFDQggA0HbADYCHCADIAE2AhQgAyAANgIMQQAhAgyrAQsgAygCBCEAIANBADYCBCADIAAgARAsIgBFDQggA0HdADYCHCADIAE2AhQgAyAANgIMQQAhAgyqAQsgAygCBCEAIANBADYCBCADIAAgARAsIgBFDQggA0H6ADYCHCADIAE2AhQgAyAANgIMQQAhAgypAQsgA0EANgIcIAMgATYCFCADQY0UNgIQIANBBzYCDEEAIQIMqAELAkACQAJAAkADQCABLQAAQaDKAGotAAAiAEEFRwRAAkAgAEEBaw4GLgMEBQYABgtB6AAhAgyUAQsgBCABQQFqIgFHDQALQf0AIQIMqwELIAMoAgQhACADQQA2AgQgAyAAIAEQLCIARQ0HIANB2wA2AhwgAyABNgIUIAMgADYCDEEAIQIMqgELIAMoAgQhACADQQA2AgQgAyAAIAEQLCIARQ0HIANB3QA2AhwgAyABNgIUIAMgADYCDEEAIQIMqQELIAMoAgQhACADQQA2AgQgAyAAIAEQLCIARQ0HIANB+gA2AhwgAyABNgIUIAMgADYCDEEAIQIMqAELIANBADYCHCADIAE2AhQgA0HkCDYCECADQQc2AgxBACECDKcBCyABIARGDQEgAUEBagshAUEGIQIMjAELQfwAIQIMpAELAkACQAJAAkADQCABLQAAQaDIAGotAAAiAEEFRwRAIABBAWsOBCkCAwQFCyAEIAFBAWoiAUcNAAtB+wAhAgynAQsgAygCBCEAIANBADYCBCADIAAgARAsIgBFDQMgA0HbADYCHCADIAE2AhQgAyAANgIMQQAhAgymAQsgAygCBCEAIANBADYCBCADIAAgARAsIgBFDQMgA0HdADYCHCADIAE2AhQgAyAANgIMQQAhAgylAQsgAygCBCEAIANBADYCBCADIAAgARAsIgBFDQMgA0H6ADYCHCADIAE2AhQgAyAANgIMQQAhAgykAQsgA0EANgIcIAMgATYCFCADQbwKNgIQIANBBzYCDEEAIQIMowELQc8AIQIMiQELQdEAIQIMiAELQecAIQIMhwELIAEgBEYEQEH6ACECDKABCwJAIAEtAABBCWsOBCAAACAACyABQQFqIQFB5gAhAgyGAQsgASAERgRAQfkAIQIMnwELAkAgAS0AAEEJaw4EHwAAHwALQQAhAAJAIAMoAjgiAkUNACACKAI4IgJFDQAgAyACEQAAIQALIABFBEBB4gEhAgyGAQsgAEEVRwRAIANBADYCHCADIAE2AhQgA0HJDTYCECADQRo2AgxBACECDJ8BCyADQfgANgIcIAMgATYCFCADQeoaNgIQIANBFTYCDEEAIQIMngELIAEgBEcEQCADQQ02AgggAyABNgIEQeQAIQIMhQELQfcAIQIMnQELIAEgBEYEQEH2ACECDJ0BCwJAAkACQCABLQAAQcgAaw4LAAELCwsLCwsLCwILCyABQQFqIQFB3QAhAgyFAQsgAUEBaiEBQeAAIQIMhAELIAFBAWohAUHjACECDIMBC0H1ACECIAEgBEYNmwEgAygCACIAIAQgAWtqIQUgASAAa0ECaiEGAkADQCABLQAAIABBtdUAai0AAEcNCCAAQQJGDQEgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAU2AgAMnAELIAMoAgQhACADQgA3AwAgAyAAIAZBAWoiARArIgAEQCADQfQANgIcIAMgATYCFCADIAA2AgxBACECDJwBC0HiACECDIIBC0EAIQACQCADKAI4IgJFDQAgAigCNCICRQ0AIAMgAhEAACEACwJAIAAEQCAAQRVGDQEgA0EANgIcIAMgATYCFCADQeoNNgIQIANBJjYCDEEAIQIMnAELQeEAIQIMggELIANB8wA2AhwgAyABNgIUIANBgBs2AhAgA0EVNgIMQQAhAgyaAQsgAy0AKSIAQSNrQQtJDQkCQCAAQQZLDQBBASAAdEHKAHFFDQAMCgtBACECIANBADYCHCADIAE2AhQgA0HtCTYCECADQQg2AgwMmQELQfIAIQIgASAERg2YASADKAIAIgAgBCABa2ohBSABIABrQQFqIQYCQANAIAEtAAAgAEGz1QBqLQAARw0FIABBAUYNASAAQQFqIQAgBCABQQFqIgFHDQALIAMgBTYCAAyZAQsgAygCBCEAIANCADcDACADIAAgBkEBaiIBECsiAARAIANB8QA2AhwgAyABNgIUIAMgADYCDEEAIQIMmQELQd8AIQIMfwtBACEAAkAgAygCOCICRQ0AIAIoAjQiAkUNACADIAIRAAAhAAsCQCAABEAgAEEVRg0BIANBADYCHCADIAE2AhQgA0HqDTYCECADQSY2AgxBACECDJkBC0HeACECDH8LIANB8AA2AhwgAyABNgIUIANBgBs2AhAgA0EVNgIMQQAhAgyXAQsgAy0AKUEhRg0GIANBADYCHCADIAE2AhQgA0GRCjYCECADQQg2AgxBACECDJYBC0HvACECIAEgBEYNlQEgAygCACIAIAQgAWtqIQUgASAAa0ECaiEGAkADQCABLQAAIABBsNUAai0AAEcNAiAAQQJGDQEgAEEBaiEAIAQgAUEBaiIBRw0ACyADIAU2AgAMlgELIAMoAgQhACADQgA3AwAgAyAAIAZBAWoiARArIgBFDQIgA0HtADYCHCADIAE2AhQgAyAANgIMQQAhAgyVAQsgA0EANgIACyADKAIEIQAgA0EANgIEIAMgACABECsiAEUNgAEgA0HuADYCHCADIAE2AhQgAyAANgIMQQAhAgyTAQtB3AAhAgx5C0EAIQACQCADKAI4IgJFDQAgAigCNCICRQ0AIAMgAhEAACEACwJAIAAEQCAAQRVGDQEgA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A0AALAQEAQdrQAAtBAgAAAAAAAAMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAAAAAAAAAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMAQanSAAsFAQEAAQEAQcDSAAsBAQBBytIACwYCAAAAAAIAQeHSAAs6AwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMAAAAAAAADAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwBBoNQAC50BTk9VTkNFRUNLT1VUTkVDVEVURUNSSUJFTFVTSEVURUFEU0VBUkNIUkdFQ1RJVklUWUxFTkRBUlZFT1RJRllQVElPTlNDSFNFQVlTVEFUQ0hHRVVFUllPUkRJUkVDVE9SVFJDSFBBUkFNRVRFUlVSQ0VCU0NSSUJFQVJET1dOQUNFSU5ETktDS1VCU0NSSUJFVFRQQ0VUU1BBRFRQLw==","base64"))})},3530:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.enumToMap=function(e,t=[],s=[]){const r=0===(t?.length??0),n=0===(s?.length??0);return Object.fromEntries(Object.entries(e).filter((([,e])=>"number"==typeof e&&(r||t.includes(e))&&(n||!s.includes(e)))))}},7467:(e,t,s)=>{"use strict";const{kClients:r}=s(257),n=s(3315),{kAgent:i,kMockAgentSet:A,kMockAgentGet:o,kDispatches:a,kIsMockActive:c,kNetConnect:l,kGetNetConnect:h,kOptions:g,kFactory:d,kMockAgentRegisterCallHistory:u,kMockAgentIsCallHistoryEnabled:E,kMockAgentAddCallHistoryLog:I,kMockAgentMockCallHistoryInstance:p,kMockAgentAcceptsNonStandardSearchParameters:C,kMockCallHistoryAddLog:B,kIgnoreTrailingSlash:f}=s(3435),Q=s(615),m=s(5846),{matchValue:y,normalizeSearchParams:w,buildAndValidateMockOptions:S}=s(991),{InvalidArgumentError:D,UndiciError:b}=s(4465),v=s(5497),R=s(164),{MockCallHistory:N}=s(4969);e.exports=class extends v{constructor(e={}){super(e);const t=S(e);if(this[l]=!0,this[c]=!0,this[E]=t.enableCallHistory??!1,this[C]=t.acceptNonStandardSearchParameters??!1,this[f]=t.ignoreTrailingSlash??!1,e?.agent&&"function"!=typeof e.agent.dispatch)throw new D("Argument opts.agent must implement Agent");const s=e?.agent?e.agent:new n(e);this[i]=s,this[r]=s[r],this[g]=t,this[E]&&this[u]()}get(e){const t=this[f]?e.replace(/\/$/,""):e;let s=this[o](t);return s||(s=this[d](t),this[A](t,s)),s}dispatch(e,t){this.get(e.origin),this[I](e);const s=this[C],r={...e};if(s&&r.path){const[e,t]=r.path.split("?"),n=w(t,s);r.path=`${e}?${n}`}return this[i].dispatch(r,t)}async close(){this.clearCallHistory(),await this[i].close(),this[r].clear()}deactivate(){this[c]=!1}activate(){this[c]=!0}enableNetConnect(e){if("string"==typeof e||"function"==typeof e||e instanceof RegExp)Array.isArray(this[l])?this[l].push(e):this[l]=[e];else{if("undefined"!=typeof e)throw new D("Unsupported matcher. Must be one of String|Function|RegExp.");this[l]=!0}}disableNetConnect(){this[l]=!1}enableCallHistory(){return this[E]=!0,this}disableCallHistory(){return this[E]=!1,this}getCallHistory(){return this[p]}clearCallHistory(){void 0!==this[p]&&this[p].clear()}get isMockActive(){return this[c]}[u](){void 0===this[p]&&(this[p]=new N)}[I](e){this[E]&&(this[u](),this[p][B](e))}[A](e,t){this[r].set(e,{count:0,dispatcher:t})}[d](e){const t=Object.assign({agent:this},this[g]);return this[g]&&1===this[g].connections?new Q(e,t):new m(e,t)}[o](e){const t=this[r].get(e);if(t?.dispatcher)return t.dispatcher;if("string"!=typeof e){const t=this[d]("http://localhost:9999");return this[A](e,t),t}for(const[t,s]of Array.from(this[r]))if(s&&"string"!=typeof t&&y(t,e)){const t=this[d](e);return this[A](e,t),t[a]=s.dispatcher[a],t}}[h](){return this[l]}pendingInterceptors(){const e=this[r];return Array.from(e.entries()).flatMap((([e,t])=>t.dispatcher[a].map((t=>({...t,origin:e}))))).filter((({pending:e})=>e))}assertNoPendingInterceptors({pendingInterceptorsFormatter:e=new R}={}){const t=this.pendingInterceptors();if(0!==t.length)throw new b(1===t.length?`1 interceptor is pending:\n\n${e.format(t)}`.trim():`${t.length} interceptors are pending:\n\n${e.format(t)}`.trim())}}},4969:(e,t,s)=>{"use strict";const{kMockCallHistoryAddLog:r}=s(3435),{InvalidArgumentError:n}=s(4465);function i(e,t,s,r){switch(t.operator){case"OR":return r.push(...s(e)),r;case"AND":return s.call({logs:r},e);default:throw new n("options.operator must to be a case insensitive string equal to 'OR' or 'AND'")}}function A(e={}){const t={};if("operator"in e){if("string"!=typeof e.operator||"OR"!==e.operator.toUpperCase()&&"AND"!==e.operator.toUpperCase())throw new n("options.operator must to be a case insensitive string equal to 'OR' or 'AND'");return{...t,operator:e.operator.toUpperCase()}}return t}function o(e){return t=>{if("string"==typeof t||null==t)return this.logs.filter((s=>s[e]===t));if(t instanceof RegExp)return this.logs.filter((s=>t.test(s[e])));throw new n(`${e} parameter should be one of string, regexp, undefined or null`)}}class a{constructor(e={}){this.body=e.body,this.headers=e.headers,this.method=e.method;const t=function(e){try{const t=new URL(e.path,e.origin);return 0!==t.search.length||(t.search=new URLSearchParams(e.query).toString()),t}catch(e){throw new n("An error occurred when computing MockCallHistoryLog.url",{cause:e})}}(e);this.fullUrl=t.toString(),this.origin=t.origin,this.path=t.pathname,this.searchParams=Object.fromEntries(t.searchParams),this.protocol=t.protocol,this.host=t.host,this.port=t.port,this.hash=t.hash}toMap(){return new Map([["protocol",this.protocol],["host",this.host],["port",this.port],["origin",this.origin],["path",this.path],["hash",this.hash],["searchParams",this.searchParams],["fullUrl",this.fullUrl],["method",this.method],["body",this.body],["headers",this.headers]])}toString(){const e="->",t="|";let s="";return this.toMap().forEach(((r,n)=>{"string"!=typeof r&&null!=r||(s=`${s}${n}${e}${r}${t}`),("object"==typeof r&&null!==r||Array.isArray(r))&&(s=`${s}${n}${e}${JSON.stringify(r)}${t}`)})),s.slice(0,-1)}}class c{logs=[];calls(){return this.logs}firstCall(){return this.logs.at(0)}lastCall(){return this.logs.at(-1)}nthCall(e){if("number"!=typeof e)throw new n("nthCall must be called with a number");if(!Number.isInteger(e))throw new n("nthCall must be called with an integer");if(1!==Math.sign(e))throw new n("nthCall must be called with a positive value. use firstCall or lastCall instead");return this.logs.at(e-1)}filterCalls(e,t){if(0===this.logs.length)return this.logs;if("function"==typeof e)return this.logs.filter(e);if(e instanceof RegExp)return this.logs.filter((t=>e.test(t.toString())));if("object"==typeof e&&null!==e){if(0===Object.keys(e).length)return this.logs;const s={operator:"OR",...A(t)};let r=[];"protocol"in e&&(r=i(e.protocol,s,this.filterCallsByProtocol,r)),"host"in e&&(r=i(e.host,s,this.filterCallsByHost,r)),"port"in e&&(r=i(e.port,s,this.filterCallsByPort,r)),"origin"in e&&(r=i(e.origin,s,this.filterCallsByOrigin,r)),"path"in e&&(r=i(e.path,s,this.filterCallsByPath,r)),"hash"in e&&(r=i(e.hash,s,this.filterCallsByHash,r)),"fullUrl"in e&&(r=i(e.fullUrl,s,this.filterCallsByFullUrl,r)),"method"in e&&(r=i(e.method,s,this.filterCallsByMethod,r));return[...new Set(r)]}throw new n("criteria parameter should be one of function, regexp, or object")}filterCallsByProtocol=o.call(this,"protocol");filterCallsByHost=o.call(this,"host");filterCallsByPort=o.call(this,"port");filterCallsByOrigin=o.call(this,"origin");filterCallsByPath=o.call(this,"path");filterCallsByHash=o.call(this,"hash");filterCallsByFullUrl=o.call(this,"fullUrl");filterCallsByMethod=o.call(this,"method");clear(){this.logs=[]}[r](e){const t=new a(e);return this.logs.push(t),t}*[Symbol.iterator](){for(const e of this.calls())yield e}}e.exports.MockCallHistory=c,e.exports.MockCallHistoryLog=a},615:(e,t,s)=>{"use strict";const{promisify:r}=s(7975),n=s(1167),{buildMockDispatch:i}=s(991),{kDispatches:A,kMockAgent:o,kClose:a,kOriginalClose:c,kOrigin:l,kOriginalDispatch:h,kConnected:g,kIgnoreTrailingSlash:d}=s(3435),{MockInterceptor:u}=s(193),E=s(257),{InvalidArgumentError:I}=s(4465);class p extends n{constructor(e,t){if(!t||!t.agent||"function"!=typeof t.agent.dispatch)throw new I("Argument opts.agent must implement Agent");super(e,t),this[o]=t.agent,this[l]=e,this[d]=t.ignoreTrailingSlash??!1,this[A]=[],this[g]=1,this[h]=this.dispatch,this[c]=this.close.bind(this),this.dispatch=i.call(this),this.close=this[a]}get[E.kConnected](){return this[g]}intercept(e){return new u(e&&{ignoreTrailingSlash:this[d],...e},this[A])}cleanMocks(){this[A]=[]}async[a](){await r(this[c])(),this[g]=0,this[o][E.kClients].delete(this[l])}}e.exports=p},3123:(e,t,s)=>{"use strict";const{UndiciError:r}=s(4465),n=Symbol.for("undici.error.UND_MOCK_ERR_MOCK_NOT_MATCHED");class i extends r{constructor(e){super(e),this.name="MockNotMatchedError",this.message=e||"The request does not match any registered mock dispatches",this.code="UND_MOCK_ERR_MOCK_NOT_MATCHED"}static[Symbol.hasInstance](e){return e&&!0===e[n]}get[n](){return!0}}e.exports={MockNotMatchedError:i}},193:(e,t,s)=>{"use strict";const{getResponseData:r,buildKey:n,addMockDispatch:i}=s(991),{kDispatches:A,kDispatchKey:o,kDefaultHeaders:a,kDefaultTrailers:c,kContentLength:l,kMockDispatch:h,kIgnoreTrailingSlash:g}=s(3435),{InvalidArgumentError:d}=s(4465),{serializePathWithQuery:u}=s(2858);class E{constructor(e){this[h]=e}delay(e){if("number"!=typeof e||!Number.isInteger(e)||e<=0)throw new d("waitInMs must be a valid integer > 0");return this[h].delay=e,this}persist(){return this[h].persist=!0,this}times(e){if("number"!=typeof e||!Number.isInteger(e)||e<=0)throw new d("repeatTimes must be a valid integer > 0");return this[h].times=e,this}}e.exports.MockInterceptor=class{constructor(e,t){if("object"!=typeof e)throw new d("opts must be an object");if("undefined"==typeof e.path)throw new d("opts.path must be defined");if("undefined"==typeof e.method&&(e.method="GET"),"string"==typeof e.path)if(e.query)e.path=u(e.path,e.query);else{const t=new URL(e.path,"data://");e.path=t.pathname+t.search}"string"==typeof e.method&&(e.method=e.method.toUpperCase()),this[o]=n(e),this[A]=t,this[g]=e.ignoreTrailingSlash??!1,this[a]={},this[c]={},this[l]=!1}createMockScopeDispatchData({statusCode:e,data:t,responseOptions:s}){const n=r(t),i=this[l]?{"content-length":n.length}:{};return{statusCode:e,data:t,headers:{...this[a],...i,...s.headers},trailers:{...this[c],...s.trailers}}}validateReplyParameters(e){if("undefined"==typeof e.statusCode)throw new d("statusCode must be defined");if("object"!=typeof e.responseOptions||null===e.responseOptions)throw new d("responseOptions must be an object")}reply(e){if("function"==typeof e){const t=t=>{const s=e(t);if("object"!=typeof s||null===s)throw new d("reply options callback must return an object");const r={data:"",responseOptions:{},...s};return this.validateReplyParameters(r),{...this.createMockScopeDispatchData(r)}},s=i(this[A],this[o],t,{ignoreTrailingSlash:this[g]});return new E(s)}const t={statusCode:e,data:void 0===arguments[1]?"":arguments[1],responseOptions:void 0===arguments[2]?{}:arguments[2]};this.validateReplyParameters(t);const s=this.createMockScopeDispatchData(t),r=i(this[A],this[o],s,{ignoreTrailingSlash:this[g]});return new E(r)}replyWithError(e){if("undefined"==typeof e)throw new d("error must be defined");const t=i(this[A],this[o],{error:e},{ignoreTrailingSlash:this[g]});return new E(t)}defaultReplyHeaders(e){if("undefined"==typeof e)throw new d("headers must be defined");return this[a]=e,this}defaultReplyTrailers(e){if("undefined"==typeof e)throw new d("trailers must be defined");return this[c]=e,this}replyContentLength(){return this[l]=!0,this}},e.exports.MockScope=E},5846:(e,t,s)=>{"use strict";const{promisify:r}=s(7975),n=s(8542),{buildMockDispatch:i}=s(991),{kDispatches:A,kMockAgent:o,kClose:a,kOriginalClose:c,kOrigin:l,kOriginalDispatch:h,kConnected:g,kIgnoreTrailingSlash:d}=s(3435),{MockInterceptor:u}=s(193),E=s(257),{InvalidArgumentError:I}=s(4465);class p extends n{constructor(e,t){if(!t||!t.agent||"function"!=typeof t.agent.dispatch)throw new I("Argument opts.agent must implement Agent");super(e,t),this[o]=t.agent,this[l]=e,this[d]=t.ignoreTrailingSlash??!1,this[A]=[],this[g]=1,this[h]=this.dispatch,this[c]=this.close.bind(this),this.dispatch=i.call(this),this.close=this[a]}get[E.kConnected](){return this[g]}intercept(e){return new u(e&&{ignoreTrailingSlash:this[d],...e},this[A])}cleanMocks(){this[A]=[]}async[a](){await r(this[c])(),this[g]=0,this[o][E.kClients].delete(this[l])}}e.exports=p},3435:e=>{"use strict";e.exports={kAgent:Symbol("agent"),kOptions:Symbol("options"),kFactory:Symbol("factory"),kDispatches:Symbol("dispatches"),kDispatchKey:Symbol("dispatch key"),kDefaultHeaders:Symbol("default headers"),kDefaultTrailers:Symbol("default trailers"),kContentLength:Symbol("content length"),kMockAgent:Symbol("mock agent"),kMockAgentSet:Symbol("mock agent set"),kMockAgentGet:Symbol("mock agent get"),kMockDispatch:Symbol("mock dispatch"),kClose:Symbol("close"),kOriginalClose:Symbol("original agent close"),kOriginalDispatch:Symbol("original dispatch"),kOrigin:Symbol("origin"),kIsMockActive:Symbol("is mock active"),kNetConnect:Symbol("net connect"),kGetNetConnect:Symbol("get net connect"),kConnected:Symbol("connected"),kIgnoreTrailingSlash:Symbol("ignore trailing slash"),kMockAgentMockCallHistoryInstance:Symbol("mock agent mock call history name"),kMockAgentRegisterCallHistory:Symbol("mock agent register mock call history"),kMockAgentAddCallHistoryLog:Symbol("mock agent add call history log"),kMockAgentIsCallHistoryEnabled:Symbol("mock agent is call history enabled"),kMockAgentAcceptsNonStandardSearchParameters:Symbol("mock agent accepts non standard search parameters"),kMockCallHistoryAddLog:Symbol("mock call history add log")}},991:(e,t,s)=>{"use strict";const{MockNotMatchedError:r}=s(3123),{kDispatches:n,kMockAgent:i,kOriginalDispatch:A,kOrigin:o,kGetNetConnect:a}=s(3435),{serializePathWithQuery:c}=s(2858),{STATUS_CODES:l}=s(7067),{types:{isPromise:h}}=s(7975),{InvalidArgumentError:g}=s(4465);function d(e,t){return"string"==typeof e?e===t:e instanceof RegExp?e.test(t):"function"==typeof e&&!0===e(t)}function u(e){return Object.fromEntries(Object.entries(e).map((([e,t])=>[e.toLocaleLowerCase(),t])))}function E(e,t){if(!Array.isArray(e))return"function"==typeof e.get?e.get(t):u(e)[t.toLocaleLowerCase()];for(let s=0;s<e.length;s+=2)if(e[s].toLocaleLowerCase()===t.toLocaleLowerCase())return e[s+1]}function I(e){const t=e.slice(),s=[];for(let e=0;e<t.length;e+=2)s.push([t[e],t[e+1]]);return Object.fromEntries(s)}function p(e,t){if("function"==typeof e.headers)return Array.isArray(t)&&(t=I(t)),e.headers(t?u(t):{});if("undefined"==typeof e.headers)return!0;if("object"!=typeof t||"object"!=typeof e.headers)return!1;for(const[s,r]of Object.entries(e.headers)){if(!d(r,E(t,s)))return!1}return!0}function C(e){if("string"!=typeof e)return e;const t=e.split("?",3);if(2!==t.length)return e;const s=new URLSearchParams(t.pop());return s.sort(),[...t,s.toString()].join("?")}function B(e){return Buffer.isBuffer(e)||e instanceof Uint8Array||e instanceof ArrayBuffer?e:"object"==typeof e?JSON.stringify(e):e?e.toString():""}function f(e,t){const s=t.query?c(t.path,t.query):t.path,n="string"==typeof s?C(s):s,i=m(n);let A=e.filter((({consumed:e})=>!e)).filter((({path:e,ignoreTrailingSlash:t})=>t?d(m(C(e)),i):d(C(e),n)));if(0===A.length)throw new r(`Mock dispatch not matched for path '${n}'`);if(A=A.filter((({method:e})=>d(e,t.method))),0===A.length)throw new r(`Mock dispatch not matched for method '${t.method}' on path '${n}'`);if(A=A.filter((({body:e})=>"undefined"==typeof e||d(e,t.body))),0===A.length)throw new r(`Mock dispatch not matched for body '${t.body}' on path '${n}'`);if(A=A.filter((e=>p(e,t.headers))),0===A.length){const e="object"==typeof t.headers?JSON.stringify(t.headers):t.headers;throw new r(`Mock dispatch not matched for headers '${e}' on path '${n}'`)}return A[0]}function Q(e,t){const s=e.findIndex((e=>!!e.consumed&&function(e,{path:t,method:s,body:r,headers:n}){const i=d(e.path,t),A=d(e.method,s),o="undefined"==typeof e.body||d(e.body,r),a=p(e,n);return i&&A&&o&&a}(e,t)));-1!==s&&e.splice(s,1)}function m(e){for(;e.endsWith("/");)e=e.slice(0,-1);return 0===e.length&&(e="/"),e}function y(e){const{path:t,method:s,body:r,headers:n,query:i}=e;return{path:t,method:s,body:r,headers:n,query:i}}function w(e){const t=Object.keys(e),s=[];for(let r=0;r<t.length;++r){const n=t[r],i=e[n],A=Buffer.from(`${n}`);if(Array.isArray(i))for(let e=0;e<i.length;++e)s.push(A,Buffer.from(`${i[e]}`));else s.push(A,Buffer.from(`${i}`))}return s}function S(e){return l[e]||"unknown"}function D(e,t){const s=y(e),r=f(this[n],s);r.timesInvoked++,r.data.callback&&(r.data={...r.data,...r.data.callback(e)});const{data:{statusCode:i,data:A,headers:o,trailers:a,error:c},delay:l,persist:g}=r,{timesInvoked:d,times:u}=r;if(r.consumed=!g&&d>=u,r.pending=d<u,null!==c)return Q(this[n],s),t.onError(c),!0;function E(r,n=A){const c=Array.isArray(e.headers)?I(e.headers):e.headers,l="function"==typeof n?n({...e,headers:c}):n;if(h(l))return void l.then((e=>E(r,e)));const g=B(l),d=w(o),u=w(a);t.onConnect?.((e=>t.onError(e)),null),t.onHeaders?.(i,d,p,S(i)),t.onData?.(Buffer.from(g)),t.onComplete?.(u),Q(r,s)}function p(){}return"number"==typeof l&&l>0?setTimeout((()=>{E(this[n])}),l):E(this[n]),!0}function b(e,t){const s=new URL(t);return!0===e||!(!Array.isArray(e)||!e.some((e=>d(e,s.host))))}e.exports={getResponseData:B,getMockDispatch:f,addMockDispatch:function(e,t,s,r){const n={...{timesInvoked:0,times:1,persist:!1,consumed:!1,...r},...t,pending:!0,data:{error:null,..."function"==typeof s?{callback:s}:{...s}}};return e.push(n),n},deleteMockDispatch:Q,buildKey:y,generateKeyValues:w,matchValue:d,getResponse:async function(e){const t=[];for await(const s of e)t.push(s);return Buffer.concat(t).toString("utf8")},getStatusText:S,mockDispatch:D,buildMockDispatch:function(){const e=this[i],t=this[o],s=this[A];return function(n,i){if(e.isMockActive)try{D.call(this,n,i)}catch(A){if("UND_MOCK_ERR_MOCK_NOT_MATCHED"!==A.code)throw A;{const o=e[a]();if(!1===o)throw new r(`${A.message}: subsequent request to origin ${t} was not allowed (net.connect disabled)`);if(!b(o,t))throw new r(`${A.message}: subsequent request to origin ${t} was not allowed (net.connect is not enabled for this origin)`);s.call(this,n,i)}}else s.call(this,n,i)}},checkNetConnect:b,buildAndValidateMockOptions:function(e){const{agent:t,...s}=e;if("enableCallHistory"in s&&"boolean"!=typeof s.enableCallHistory)throw new g("options.enableCallHistory must to be a boolean");if("acceptNonStandardSearchParameters"in s&&"boolean"!=typeof s.acceptNonStandardSearchParameters)throw new g("options.acceptNonStandardSearchParameters must to be a boolean");if("ignoreTrailingSlash"in s&&"boolean"!=typeof s.ignoreTrailingSlash)throw new g("options.ignoreTrailingSlash must to be a boolean");return s},getHeaderByName:E,buildHeadersFromArray:I,normalizeSearchParams:function(e){if("string"!=typeof e)return e;const t=new URLSearchParams(e),s=new URLSearchParams;for(let[e,r]of t.entries()){e=e.replace("[]","");if(/^(['"]).*\1$/.test(r))s.append(e,r);else if(r.includes(",")){const t=r.split(",");for(const r of t)s.append(e,r)}else s.append(e,r)}return s}}},164:(e,t,s)=>{"use strict";const{Transform:r}=s(7075),{Console:n}=s(7540),i=process.versions.icu?"✅":"Y ",A=process.versions.icu?"❌":"N ";e.exports=class{constructor({disableColors:e}={}){this.transform=new r({transform(e,t,s){s(null,e)}}),this.logger=new n({stdout:this.transform,inspectOptions:{colors:!e&&!process.env.CI}})}format(e){const t=e.map((({method:e,path:t,data:{statusCode:s},persist:r,times:n,timesInvoked:o,origin:a})=>({Method:e,Origin:a,Path:t,"Status code":s,Persistent:r?i:A,Invocations:o,Remaining:r?1/0:n-o})));return this.logger.table(t),this.transform.read().toString()}}},1313:(e,t,s)=>{"use strict";const r=s(3315),n=s(7467),{SnapshotRecorder:i}=s(6632),A=s(832),{InvalidArgumentError:o,UndiciError:a}=s(4465),{validateSnapshotMode:c}=s(5505),l=Symbol("kSnapshotRecorder"),h=Symbol("kSnapshotMode"),g=Symbol("kSnapshotPath"),d=Symbol("kSnapshotLoaded"),u=Symbol("kRealAgent");let E=!1;e.exports=class extends n{constructor(e={}){E||(process.emitWarning("SnapshotAgent is experimental and subject to change","ExperimentalWarning"),E=!0);const{mode:t="record",snapshotPath:s=null,...n}=e;if(super(n),c(t),("playback"===t||"update"===t)&&!s)throw new o(`snapshotPath is required when mode is '${t}'`);this[h]=t,this[g]=s,this[l]=new i({snapshotPath:this[g],mode:this[h],maxSnapshots:e.maxSnapshots,autoFlush:e.autoFlush,flushInterval:e.flushInterval,matchHeaders:e.matchHeaders,ignoreHeaders:e.ignoreHeaders,excludeHeaders:e.excludeHeaders,matchBody:e.matchBody,matchQuery:e.matchQuery,caseSensitive:e.caseSensitive,shouldRecord:e.shouldRecord,shouldPlayback:e.shouldPlayback,excludeUrls:e.excludeUrls}),this[d]=!1,"record"!==this[h]&&"update"!==this[h]||(this[u]=new r(e)),"playback"!==this[h]&&"update"!==this[h]||!this[g]||this.loadSnapshots().catch((()=>{}))}dispatch(e,t){t=A.wrap(t);const s=this[h];if("playback"===s||"update"===s){if(!this[d])return this.#me(e,t);const r=this[l].findSnapshot(e);if(r)return this.#ye(r,t);if("update"===s)return this.#we(e,t);{const s=new a(`No snapshot found for ${e.method||"GET"} ${e.path}`);if(t.onError)return void t.onError(s);throw s}}if("record"===s)return this.#we(e,t)}async#me(e,t){return await this.loadSnapshots(),this.dispatch(e,t)}#we(e,t){const s={statusCode:null,headers:{},trailers:{},body:[]},r=this,n={onRequestStart(e,s){return t.onRequestStart(e,{...s,history:this.history})},onRequestUpgrade:(e,s,r,n)=>t.onRequestUpgrade(e,s,r,n),onResponseStart:(e,r,n,i)=>(s.statusCode=r,s.headers=n,t.onResponseStart(e,r,n,i)),onResponseData:(e,r)=>(s.body.push(r),t.onResponseData(e,r)),onResponseEnd(n,i){s.trailers=i;const A=Buffer.concat(s.body);r[l].record(e,{statusCode:s.statusCode,headers:s.headers,body:A,trailers:s.trailers}).then((()=>{t.onResponseEnd(n,i)})).catch((e=>{t.onResponseError(n,e)}))}};return this[u].dispatch(e,n)}#ye(e,t){try{const{response:s}=e,r={pause(){},resume(){},abort(e){this.aborted=!0,this.reason=e},aborted:!1,paused:!1};t.onRequestStart(r),t.onResponseStart(r,s.statusCode,s.headers);const n=Buffer.from(s.body,"base64");t.onResponseData(r,n),t.onResponseEnd(r,s.trailers)}catch(e){t.onError?.(e)}}async loadSnapshots(e){await this[l].loadSnapshots(e||this[g]),this[d]=!0,"playback"===this[h]&&this.#Se()}async saveSnapshots(e){return this[l].saveSnapshots(e||this[g])}#Se(){for(const e of this[l].getSnapshots()){const{request:t,responses:s,response:r}=e,n=new URL(t.url),i=this.get(n.origin),A=s?s[0]:r;A&&i.intercept({path:n.pathname+n.search,method:t.method,headers:t.headers,body:t.body}).reply(A.statusCode,A.body,{headers:A.headers,trailers:A.trailers}).persist()}}getRecorder(){return this[l]}getMode(){return this[h]}clearSnapshots(){this[l].clear()}resetCallCounts(){this[l].resetCallCounts()}deleteSnapshot(e){return this[l].deleteSnapshot(e)}getSnapshotInfo(e){return this[l].getSnapshotInfo(e)}replaceSnapshots(e){this[l].replaceSnapshots(e)}async close(){await this[l].close(),await(this[u]?.close()),await super.close()}}},6632:(e,t,s)=>{"use strict";const{writeFile:r,readFile:n,mkdir:i}=s(1455),{dirname:A,resolve:o}=s(6760),{setTimeout:a,clearTimeout:c}=s(7997),{InvalidArgumentError:l,UndiciError:h}=s(4465),{hashId:g,isUrlExcludedFactory:d,normalizeHeaders:u,createHeaderFilters:E}=s(5505);function I(e,t,s={}){const r=new URL(e.path,e.origin),n=e._normalizedHeaders||u(e.headers);return e._normalizedHeaders||(e._normalizedHeaders=n),{method:e.method||"GET",url:!1!==s.matchQuery?r.toString():`${r.origin}${r.pathname}`,headers:p(n,t,s),body:!1!==s.matchBody&&e.body?String(e.body):""}}function p(e,t,s={}){if(!e||"object"!=typeof e)return{};const{caseSensitive:r=!1}=s,n={},{ignore:i,exclude:A,match:o}=t;for(const[t,s]of Object.entries(e)){const e=r?t:t.toLowerCase();A.has(e)||(i.has(e)||(0===o.size||o.has(e))&&(n[e]=s))}return n}function C(e,t,s={}){if(!e||"object"!=typeof e)return{};const{caseSensitive:r=!1}=s,n={},{exclude:i}=t;for(const[t,s]of Object.entries(e)){const e=r?t:t.toLowerCase();i.has(e)||(n[e]=s)}return n}function B(e){const t=[e.method,e.url];if(e.headers&&"object"==typeof e.headers){const s=Object.keys(e.headers).sort();for(const r of s){const s=Array.isArray(e.headers[r])?e.headers[r]:[e.headers[r]];t.push(r);for(const e of s.sort())t.push(String(e))}}t.push(e.body);const s=t.join("|");return g(s)}e.exports={SnapshotRecorder:class{#De;#be;#ve=new Map;#Re;#Ne=1/0;#ke=!1;#Te;constructor(e={}){this.#Re=e.snapshotPath,this.#Ne=e.maxSnapshots||1/0,this.#ke=e.autoFlush||!1,this.flushInterval=e.flushInterval||3e4,this._flushTimer=null,this.matchOptions={matchHeaders:e.matchHeaders||[],ignoreHeaders:e.ignoreHeaders||[],excludeHeaders:e.excludeHeaders||[],matchBody:!1!==e.matchBody,matchQuery:!1!==e.matchQuery,caseSensitive:e.caseSensitive||!1},this.#Te=E(this.matchOptions),this.shouldRecord=e.shouldRecord||(()=>!0),this.shouldPlayback=e.shouldPlayback||(()=>!0),this.#be=d(e.excludeUrls),this.#ke&&this.#Re&&this.#Fe()}async record(e,t){if(!this.shouldRecord(e))return;const s=new URL(e.path,e.origin).toString();if(this.#be(s))return;const r=I(e,this.#Te,this.matchOptions),n=B(r),i=u(t.headers),A={statusCode:t.statusCode,headers:C(i,this.#Te,this.matchOptions),body:Buffer.isBuffer(t.body)?t.body.toString("base64"):Buffer.from(String(t.body||"")).toString("base64"),trailers:t.trailers};if(this.#ve.size>=this.#Ne&&!this.#ve.has(n)){const e=this.#ve.keys().next().value;this.#ve.delete(e)}const o=this.#ve.get(n);o&&o.responses?(o.responses.push(A),o.timestamp=(new Date).toISOString()):this.#ve.set(n,{request:r,responses:[A],callCount:0,timestamp:(new Date).toISOString()}),this.#ke&&this.#Re&&this.#Me()}findSnapshot(e){if(!this.shouldPlayback(e))return;const t=new URL(e.path,e.origin).toString();if(this.#be(t))return;const s=B(I(e,this.#Te,this.matchOptions)),r=this.#ve.get(s);if(!r)return;const n=r.callCount||0,i=Math.min(n,r.responses.length-1);return r.callCount=n+1,{...r,response:r.responses[i]}}async loadSnapshots(e){const t=e||this.#Re;if(!t)throw new l("Snapshot path is required");try{const e=await n(o(t),"utf8"),s=JSON.parse(e);if(Array.isArray(s)){this.#ve.clear();for(const{hash:e,snapshot:t}of s)this.#ve.set(e,t)}else this.#ve=new Map(Object.entries(s))}catch(e){if("ENOENT"!==e.code)throw new h(`Failed to load snapshots from ${t}`,{cause:e});this.#ve.clear()}}async saveSnapshots(e){const t=e||this.#Re;if(!t)throw new l("Snapshot path is required");const s=o(t);await i(A(s),{recursive:!0});const n=Array.from(this.#ve.entries()).map((([e,t])=>({hash:e,snapshot:t})));await r(s,JSON.stringify(n,null,2),{flush:!0})}clear(){this.#ve.clear()}getSnapshots(){return Array.from(this.#ve.values())}size(){return this.#ve.size}resetCallCounts(){for(const e of this.#ve.values())e.callCount=0}deleteSnapshot(e){const t=B(I(e,this.#Te,this.matchOptions));return this.#ve.delete(t)}getSnapshotInfo(e){const t=B(I(e,this.#Te,this.matchOptions)),s=this.#ve.get(t);return s?{hash:t,request:s.request,responseCount:s.responses?s.responses.length:s.response?1:0,callCount:s.callCount||0,timestamp:s.timestamp}:null}replaceSnapshots(e){if(this.#ve.clear(),Array.isArray(e))for(const{hash:t,snapshot:s}of e)this.#ve.set(t,s);else e&&"object"==typeof e&&(this.#ve=new Map(Object.entries(e)))}#Fe(){return this.#Me()}#Ue(){this.#De&&(c(this.#De),this.saveSnapshots().catch((()=>{})),this.#De=null)}#Me(){this.#De=a((()=>{this.saveSnapshots().catch((()=>{})),this.#ke?this.#De?.refresh():this.#De=null}),1e3)}destroy(){this.#Ue(),this.#De&&(c(this.#De),this.#De=null)}async close(){this.#Re&&0!==this.#ve.size&&await this.saveSnapshots(),this.destroy()}},formatRequestKey:I,createRequestHash:B,filterHeadersForMatching:p,filterHeadersForStorage:C,createHeaderFilters:E}},5505:(e,t,s)=>{"use strict";const{InvalidArgumentError:r}=s(4465);let n;try{n=s(7598)}catch{}const i=n?.hash?e=>n.hash("sha256",e,"base64url"):e=>Buffer.from(e).toString("base64url");function A(e){return Array.isArray(e)&&!(1&e.length)}const o=["record","playback","update"];e.exports={createHeaderFilters:function(e={}){const{ignoreHeaders:t=[],excludeHeaders:s=[],matchHeaders:r=[],caseSensitive:n=!1}=e;return{ignore:new Set(t.map((e=>n?e:e.toLowerCase()))),exclude:new Set(s.map((e=>n?e:e.toLowerCase()))),match:new Set(r.map((e=>n?e:e.toLowerCase())))}},hashId:i,isUndiciHeaders:A,normalizeHeaders:function(e){const t={};if(!e)return t;if(A(e)){for(let s=0;s<e.length;s+=2){const r=e[s],n=e[s+1];if(r&&void 0!==n){const e=Buffer.isBuffer(r)?r.toString():r,s=Buffer.isBuffer(n)?n.toString():n;t[e.toLowerCase()]=s}}return t}if(e&&"object"==typeof e)for(const[s,r]of Object.entries(e))s&&"string"==typeof s&&(t[s.toLowerCase()]=Array.isArray(r)?r.join(", "):String(r));return t},isUrlExcludedFactory:function(e=[]){return 0===e.length?()=>!1:function(t){let s;for(const r of e)if("string"==typeof r){if(s||(s=t.toLowerCase()),s.includes(r.toLowerCase()))return!0}else if(r instanceof RegExp&&r.test(t))return!0;return!1}},validateSnapshotMode:function(e){if(!o.includes(e))throw new r(`Invalid snapshot mode: ${e}. Must be one of: ${o.join(", ")}`)}}},9453:(e,t,s)=>{"use strict";const{safeHTTPMethods:r,pathHasQueryOrFragment:n}=s(2858),{serializePathWithQuery:i}=s(2858);e.exports={makeCacheKey:function(e){if(!e.origin)throw new Error("opts.origin is undefined");let t=e.path||"/";return e.query&&!n(e.path)&&(t=i(t,e.query)),{origin:e.origin.toString(),method:e.method,path:t,headers:e.headers}},normalizeHeaders:function(e){let t;if(null==e.headers)t={};else if("function"==typeof e.headers[Symbol.iterator]){t={};for(const s of e.headers){if(!Array.isArray(s))throw new Error("opts.headers is not a valid header map");const[e,r]=s;if("string"!=typeof e||"string"!=typeof r)throw new Error("opts.headers is not a valid header map");t[e.toLowerCase()]=r}}else{if("object"!=typeof e.headers)throw new Error("opts.headers is not an object");t={};for(const s of Object.keys(e.headers))t[s.toLowerCase()]=e.headers[s]}return t},assertCacheKey:function(e){if("object"!=typeof e)throw new TypeError("expected key to be object, got "+typeof e);for(const t of["origin","method","path"])if("string"!=typeof e[t])throw new TypeError(`expected key.${t} to be string, got ${typeof e[t]}`);if(void 0!==e.headers&&"object"!=typeof e.headers)throw new TypeError("expected headers to be object, got "+typeof e)},assertCacheValue:function(e){if("object"!=typeof e)throw new TypeError("expected value to be object, got "+typeof e);for(const t of["statusCode","cachedAt","staleAt","deleteAt"])if("number"!=typeof e[t])throw new TypeError(`expected value.${t} to be number, got ${typeof e[t]}`);if("string"!=typeof e.statusMessage)throw new TypeError("expected value.statusMessage to be string, got "+typeof e.statusMessage);if(null!=e.headers&&"object"!=typeof e.headers)throw new TypeError("expected value.rawHeaders to be object, got "+typeof e.headers);if(void 0!==e.vary&&"object"!=typeof e.vary)throw new TypeError("expected value.vary to be object, got "+typeof e.vary);if(void 0!==e.etag&&"string"!=typeof e.etag)throw new TypeError("expected value.etag to be string, got "+typeof e.etag)},parseCacheControlHeader:function(e){const t={};let s;if(Array.isArray(e)){s=[];for(const t of e)s.push(...t.split(","))}else s=e.split(",");for(let e=0;e<s.length;e++){const r=s[e].toLowerCase(),n=r.indexOf("=");let i,A;switch(-1!==n?(i=r.substring(0,n).trimStart(),A=r.substring(n+1)):i=r.trim(),i){case"min-fresh":case"max-stale":case"max-age":case"s-maxage":case"stale-while-revalidate":case"stale-if-error":{if(void 0===A||" "===A[0])continue;A.length>=2&&'"'===A[0]&&'"'===A[A.length-1]&&(A=A.substring(1,A.length-1));const e=parseInt(A,10);if(e!=e)continue;if("max-age"===i&&i in t&&t[i]>=e)continue;t[i]=e;break}case"private":case"no-cache":if(A){if('"'===A[0]){const r=[A.substring(1)];let n='"'===A[A.length-1];if(!n)for(let t=e+1;t<s.length;t++){const e=s[t],i=e.length;if(r.push(e.trim()),0!==i&&'"'===e[i-1]){n=!0;break}}if(n){let e=r[r.length-1];'"'===e[e.length-1]&&(e=e.substring(0,e.length-1),r[r.length-1]=e),t[i]=i in t?t[i].concat(r):r}}else t[i]=i in t?t[i].concat(A):[A];break}case"public":case"no-store":case"must-revalidate":case"proxy-revalidate":case"immutable":case"no-transform":case"must-understand":case"only-if-cached":if(A)continue;t[i]=!0;break;default:continue}}return t},parseVaryHeader:function(e,t){if("string"==typeof e&&e.includes("*"))return t;const s={},r="string"==typeof e?e.split(","):e;for(const e of r){const r=e.trim().toLowerCase();s[r]=t[r]??null}return s},isEtagUsable:function(e){return!(e.length<=2)&&('"'===e[0]&&'"'===e[e.length-1]?!('"'===e[1]||e.startsWith('"W/')):!(!e.startsWith('W/"')||'"'!==e[e.length-1])&&4!==e.length)},assertCacheMethods:function(e,t="CacheMethods"){if(!Array.isArray(e))throw new TypeError(`expected type of ${t} needs to be an array, got ${null===e?"null":typeof e}`);if(0===e.length)throw new TypeError(`${t} needs to have at least one method`);for(const s of e)if(!r.includes(s))throw new TypeError(`element of ${t}-array needs to be one of following values: ${r.join(", ")}, got ${s}`)},assertCacheStore:function(e,t="CacheStore"){if("object"!=typeof e||null===e)throw new TypeError(`expected type of ${t} to be a CacheStore, got ${null===e?"null":typeof e}`);for(const s of["get","createWriteStream","delete"])if("function"!=typeof e[s])throw new TypeError(`${t} needs to have a \`${s}()\` function`)}}},8851:e=>{"use strict";e.exports={parseHttpDate:function(e){switch(e[3]){case",":return function(e){if(29!==e.length||" "!==e[4]||" "!==e[7]||" "!==e[11]||" "!==e[16]||":"!==e[19]||":"!==e[22]||" "!==e[25]||"G"!==e[26]||"M"!==e[27]||"T"!==e[28])return;let t=-1;if("S"===e[0]&&"u"===e[1]&&"n"===e[2])t=0;else if("M"===e[0]&&"o"===e[1]&&"n"===e[2])t=1;else if("T"===e[0]&&"u"===e[1]&&"e"===e[2])t=2;else if("W"===e[0]&&"e"===e[1]&&"d"===e[2])t=3;else if("T"===e[0]&&"h"===e[1]&&"u"===e[2])t=4;else if("F"===e[0]&&"r"===e[1]&&"i"===e[2])t=5;else{if("S"!==e[0]||"a"!==e[1]||"t"!==e[2])return;t=6}let s=0;if("0"===e[5]){const t=e.charCodeAt(6);if(t<49||t>57)return;s=t-48}else{const t=e.charCodeAt(5);if(t<49||t>51)return;const r=e.charCodeAt(6);if(r<48||r>57)return;s=10*(t-48)+(r-48)}let r=-1;if("J"===e[8]&&"a"===e[9]&&"n"===e[10])r=0;else if("F"===e[8]&&"e"===e[9]&&"b"===e[10])r=1;else if("M"===e[8]&&"a"===e[9])if("r"===e[10])r=2;else{if("y"!==e[10])return;r=4}else if("J"===e[8])if("a"===e[9]&&"n"===e[10])r=0;else{if("u"!==e[9])return;if("n"===e[10])r=5;else{if("l"!==e[10])return;r=6}}else if("A"===e[8])if("p"===e[9]&&"r"===e[10])r=3;else{if("u"!==e[9]||"g"!==e[10])return;r=7}else if("S"===e[8]&&"e"===e[9]&&"p"===e[10])r=8;else if("O"===e[8]&&"c"===e[9]&&"t"===e[10])r=9;else if("N"===e[8]&&"o"===e[9]&&"v"===e[10])r=10;else{if("D"!==e[8]||"e"!==e[9]||"c"!==e[10])return;r=11}const n=e.charCodeAt(12);if(n<48||n>57)return;const i=e.charCodeAt(13);if(i<48||i>57)return;const A=e.charCodeAt(14);if(A<48||A>57)return;const o=e.charCodeAt(15);if(o<48||o>57)return;const a=1e3*(n-48)+100*(i-48)+10*(A-48)+(o-48);let c=0;if("0"===e[17]){const t=e.charCodeAt(18);if(t<48||t>57)return;c=t-48}else{const t=e.charCodeAt(17);if(t<48||t>50)return;const s=e.charCodeAt(18);if(s<48||s>57)return;if(50===t&&s>51)return;c=10*(t-48)+(s-48)}let l=0;if("0"===e[20]){const t=e.charCodeAt(21);if(t<48||t>57)return;l=t-48}else{const t=e.charCodeAt(20);if(t<48||t>53)return;const s=e.charCodeAt(21);if(s<48||s>57)return;l=10*(t-48)+(s-48)}let h=0;if("0"===e[23]){const t=e.charCodeAt(24);if(t<48||t>57)return;h=t-48}else{const t=e.charCodeAt(23);if(t<48||t>53)return;const s=e.charCodeAt(24);if(s<48||s>57)return;h=10*(t-48)+(s-48)}const g=new Date(Date.UTC(a,r,s,c,l,h));return g.getUTCDay()===t?g:void 0}(e);case" ":return function(e){if(24!==e.length||" "!==e[7]||" "!==e[10]||" "!==e[19])return;let t=-1;if("S"===e[0]&&"u"===e[1]&&"n"===e[2])t=0;else if("M"===e[0]&&"o"===e[1]&&"n"===e[2])t=1;else if("T"===e[0]&&"u"===e[1]&&"e"===e[2])t=2;else if("W"===e[0]&&"e"===e[1]&&"d"===e[2])t=3;else if("T"===e[0]&&"h"===e[1]&&"u"===e[2])t=4;else if("F"===e[0]&&"r"===e[1]&&"i"===e[2])t=5;else{if("S"!==e[0]||"a"!==e[1]||"t"!==e[2])return;t=6}let s=-1;if("J"===e[4]&&"a"===e[5]&&"n"===e[6])s=0;else if("F"===e[4]&&"e"===e[5]&&"b"===e[6])s=1;else if("M"===e[4]&&"a"===e[5])if("r"===e[6])s=2;else{if("y"!==e[6])return;s=4}else if("J"===e[4])if("a"===e[5]&&"n"===e[6])s=0;else{if("u"!==e[5])return;if("n"===e[6])s=5;else{if("l"!==e[6])return;s=6}}else if("A"===e[4])if("p"===e[5]&&"r"===e[6])s=3;else{if("u"!==e[5]||"g"!==e[6])return;s=7}else if("S"===e[4]&&"e"===e[5]&&"p"===e[6])s=8;else if("O"===e[4]&&"c"===e[5]&&"t"===e[6])s=9;else if("N"===e[4]&&"o"===e[5]&&"v"===e[6])s=10;else{if("D"!==e[4]||"e"!==e[5]||"c"!==e[6])return;s=11}let r=0;if(" "===e[8]){const t=e.charCodeAt(9);if(t<49||t>57)return;r=t-48}else{const t=e.charCodeAt(8);if(t<49||t>51)return;const s=e.charCodeAt(9);if(s<48||s>57)return;r=10*(t-48)+(s-48)}let n=0;if("0"===e[11]){const t=e.charCodeAt(12);if(t<48||t>57)return;n=t-48}else{const t=e.charCodeAt(11);if(t<48||t>50)return;const s=e.charCodeAt(12);if(s<48||s>57)return;if(50===t&&s>51)return;n=10*(t-48)+(s-48)}let i=0;if("0"===e[14]){const t=e.charCodeAt(15);if(t<48||t>57)return;i=t-48}else{const t=e.charCodeAt(14);if(t<48||t>53)return;const s=e.charCodeAt(15);if(s<48||s>57)return;i=10*(t-48)+(s-48)}let A=0;if("0"===e[17]){const t=e.charCodeAt(18);if(t<48||t>57)return;A=t-48}else{const t=e.charCodeAt(17);if(t<48||t>53)return;const s=e.charCodeAt(18);if(s<48||s>57)return;A=10*(t-48)+(s-48)}const o=e.charCodeAt(20);if(o<48||o>57)return;const a=e.charCodeAt(21);if(a<48||a>57)return;const c=e.charCodeAt(22);if(c<48||c>57)return;const l=e.charCodeAt(23);if(l<48||l>57)return;const h=1e3*(o-48)+100*(a-48)+10*(c-48)+(l-48),g=new Date(Date.UTC(h,s,r,n,i,A));return g.getUTCDay()===t?g:void 0}(e);default:return function(e){let t=-1,s=-1;if("S"===e[0])"u"===e[1]&&"n"===e[2]&&"d"===e[3]&&"a"===e[4]&&"y"===e[5]?(s=0,t=6):"a"===e[1]&&"t"===e[2]&&"u"===e[3]&&"r"===e[4]&&"d"===e[5]&&"a"===e[6]&&"y"===e[7]&&(s=6,t=8);else if("M"===e[0]&&"o"===e[1]&&"n"===e[2]&&"d"===e[3]&&"a"===e[4]&&"y"===e[5])s=1,t=6;else if("T"===e[0])"u"===e[1]&&"e"===e[2]&&"s"===e[3]&&"d"===e[4]&&"a"===e[5]&&"y"===e[6]?(s=2,t=7):"h"===e[1]&&"u"===e[2]&&"r"===e[3]&&"s"===e[4]&&"d"===e[5]&&"a"===e[6]&&"y"===e[7]&&(s=4,t=8);else if("W"===e[0]&&"e"===e[1]&&"d"===e[2]&&"n"===e[3]&&"e"===e[4]&&"s"===e[5]&&"d"===e[6]&&"a"===e[7]&&"y"===e[8])s=3,t=9;else{if("F"!==e[0]||"r"!==e[1]||"i"!==e[2]||"d"!==e[3]||"a"!==e[4]||"y"!==e[5])return;s=5,t=6}if(","!==e[t]||e.length-t-1!=23||" "!==e[t+1]||"-"!==e[t+4]||"-"!==e[t+8]||" "!==e[t+11]||":"!==e[t+14]||":"!==e[t+17]||" "!==e[t+20]||"G"!==e[t+21]||"M"!==e[t+22]||"T"!==e[t+23])return;let r=0;if("0"===e[t+2]){const s=e.charCodeAt(t+3);if(s<49||s>57)return;r=s-48}else{const s=e.charCodeAt(t+2);if(s<49||s>51)return;const n=e.charCodeAt(t+3);if(n<48||n>57)return;r=10*(s-48)+(n-48)}let n=-1;if("J"===e[t+5]&&"a"===e[t+6]&&"n"===e[t+7])n=0;else if("F"===e[t+5]&&"e"===e[t+6]&&"b"===e[t+7])n=1;else if("M"===e[t+5]&&"a"===e[t+6]&&"r"===e[t+7])n=2;else if("A"===e[t+5]&&"p"===e[t+6]&&"r"===e[t+7])n=3;else if("M"===e[t+5]&&"a"===e[t+6]&&"y"===e[t+7])n=4;else if("J"===e[t+5]&&"u"===e[t+6]&&"n"===e[t+7])n=5;else if("J"===e[t+5]&&"u"===e[t+6]&&"l"===e[t+7])n=6;else if("A"===e[t+5]&&"u"===e[t+6]&&"g"===e[t+7])n=7;else if("S"===e[t+5]&&"e"===e[t+6]&&"p"===e[t+7])n=8;else if("O"===e[t+5]&&"c"===e[t+6]&&"t"===e[t+7])n=9;else if("N"===e[t+5]&&"o"===e[t+6]&&"v"===e[t+7])n=10;else{if("D"!==e[t+5]||"e"!==e[t+6]||"c"!==e[t+7])return;n=11}const i=e.charCodeAt(t+9);if(i<48||i>57)return;const A=e.charCodeAt(t+10);if(A<48||A>57)return;let o=10*(i-48)+(A-48);o+=o<70?2e3:1900;let a=0;if("0"===e[t+12]){const s=e.charCodeAt(t+13);if(s<48||s>57)return;a=s-48}else{const s=e.charCodeAt(t+12);if(s<48||s>50)return;const r=e.charCodeAt(t+13);if(r<48||r>57)return;if(50===s&&r>51)return;a=10*(s-48)+(r-48)}let c=0;if("0"===e[t+15]){const s=e.charCodeAt(t+16);if(s<48||s>57)return;c=s-48}else{const s=e.charCodeAt(t+15);if(s<48||s>53)return;const r=e.charCodeAt(t+16);if(r<48||r>57)return;c=10*(s-48)+(r-48)}let l=0;if("0"===e[t+18]){const s=e.charCodeAt(t+19);if(s<48||s>57)return;l=s-48}else{const s=e.charCodeAt(t+18);if(s<48||s>53)return;const r=e.charCodeAt(t+19);if(r<48||r>57)return;l=10*(s-48)+(r-48)}const h=new Date(Date.UTC(o,n,r,a,c,l));return h.getUTCDay()===s?h:void 0}(e)}}}},9250:e=>{"use strict";e.exports={createDeferredPromise:function(){let e,t;return{promise:new Promise(((s,r)=>{e=s,t=r})),resolve:e,reject:t}}}},4304:(e,t,s)=>{"use strict";const{kConnected:r,kPending:n,kRunning:i,kSize:A,kFree:o,kQueued:a}=s(257);e.exports={ClientStats:class{constructor(e){this.connected=e[r],this.pending=e[n],this.running=e[i],this.size=e[A]}},PoolStats:class{constructor(e){this.connected=e[r],this.free=e[o],this.pending=e[n],this.queued=e[a],this.running=e[i],this.size=e[A]}}}},3801:e=>{"use strict";let t=0;const s=1e3;let r;const n=Symbol("kFastTimer"),i=[];function A(){t+=499;let e=0,s=i.length;for(;e<s;){const r=i[e];0===r._state?(r._idleStart=t-499,r._state=1):1===r._state&&t>=r._idleStart+r._idleTimeout&&(r._state=-1,r._idleStart=-1,r._onTimeout(r._timerArg)),-1===r._state?(r._state=-2,0!=--s&&(i[e]=i[s])):++e}i.length=s,0!==i.length&&o()}function o(){r?.refresh?r.refresh():(clearTimeout(r),r=setTimeout(A,499),r?.unref())}class a{[n]=!0;_state=-2;_idleTimeout=-1;_idleStart=-1;_onTimeout;_timerArg;constructor(e,t,s){this._onTimeout=e,this._idleTimeout=t,this._timerArg=s,this.refresh()}refresh(){-2===this._state&&i.push(this),r&&1!==i.length||o(),this._state=0}clear(){this._state=-1,this._idleStart=-1}}e.exports={setTimeout:(e,t,r)=>t<=s?setTimeout(e,t,r):new a(e,t,r),clearTimeout(e){e[n]?e.clear():clearTimeout(e)},setFastTimeout:(e,t,s)=>new a(e,t,s),clearFastTimeout(e){e.clear()},now:()=>t,tick(e=0){t+=e-s+1,A(),A()},reset(){t=0,i.length=0,clearTimeout(r),r=null},kFastTimer:n}},4420:(e,t,s)=>{"use strict";const r=s(4589),{kConstruct:n}=s(257),{urlEquals:i,getFieldValues:A}=s(3932),{kEnumerableProperty:o,isDisturbed:a}=s(2858),{webidl:c}=s(6097),{cloneResponse:l,fromInnerResponse:h,getResponseState:g}=s(4821),{Request:d,fromInnerRequest:u,getRequestState:E}=s(4609),{fetching:I}=s(7388),{urlIsHttpHttpsScheme:p,readAllBytes:C}=s(6686),{createDeferredPromise:B}=s(9250);class f{#Le;constructor(){arguments[0]!==n&&c.illegalConstructor(),c.util.markAsUncloneable(this),this.#Le=arguments[1]}async match(e,t={}){c.brandCheck(this,f);const s="Cache.match";c.argumentLengthCheck(arguments,1,s),e=c.converters.RequestInfo(e),t=c.converters.CacheQueryOptions(t,s,"options");const r=this.#Pe(e,t,1);if(0!==r.length)return r[0]}async matchAll(e=void 0,t={}){c.brandCheck(this,f);return void 0!==e&&(e=c.converters.RequestInfo(e)),t=c.converters.CacheQueryOptions(t,"Cache.matchAll","options"),this.#Pe(e,t)}async add(e){c.brandCheck(this,f);c.argumentLengthCheck(arguments,1,"Cache.add");const t=[e=c.converters.RequestInfo(e)],s=this.addAll(t);return await s}async addAll(e){c.brandCheck(this,f);const t="Cache.addAll";c.argumentLengthCheck(arguments,1,t);const s=[],r=[];for(let s of e){if(void 0===s)throw c.errors.conversionFailed({prefix:t,argument:"Argument 1",types:["undefined is not allowed"]});if(s=c.converters.RequestInfo(s),"string"==typeof s)continue;const e=E(s);if(!p(e.url)||"GET"!==e.method)throw c.errors.exception({header:t,message:"Expected http/s scheme when method is not GET."})}const n=[];for(const i of e){const e=E(new d(i));if(!p(e.url))throw c.errors.exception({header:t,message:"Expected http/s scheme."});e.initiator="fetch",e.destination="subresource",r.push(e);const o=B();n.push(I({request:e,processResponse(e){if("error"===e.type||206===e.status||e.status<200||e.status>299)o.reject(c.errors.exception({header:"Cache.addAll",message:"Received an invalid status code or the request failed."}));else if(e.headersList.contains("vary")){const t=A(e.headersList.get("vary"));for(const e of t)if("*"===e){o.reject(c.errors.exception({header:"Cache.addAll",message:"invalid vary field value"}));for(const e of n)e.abort();return}}},processResponseEndOfBody(e){e.aborted?o.reject(new DOMException("aborted","AbortError")):o.resolve(e)}})),s.push(o.promise)}const i=Promise.all(s),o=await i,a=[];let l=0;for(const e of o){const t={type:"put",request:r[l],response:e};a.push(t),l++}const h=B();let g=null;try{this.#xe(a)}catch(e){g=e}return queueMicrotask((()=>{null===g?h.resolve(void 0):h.reject(g)})),h.promise}async put(e,t){c.brandCheck(this,f);const s="Cache.put";c.argumentLengthCheck(arguments,2,s),e=c.converters.RequestInfo(e),t=c.converters.Response(t,s,"response");let r=null;if(r=c.is.Request(e)?E(e):E(new d(e)),!p(r.url)||"GET"!==r.method)throw c.errors.exception({header:s,message:"Expected an http/s scheme when method is not GET"});const n=g(t);if(206===n.status)throw c.errors.exception({header:s,message:"Got 206 status"});if(n.headersList.contains("vary")){const e=A(n.headersList.get("vary"));for(const t of e)if("*"===t)throw c.errors.exception({header:s,message:"Got * vary field value"})}if(n.body&&(a(n.body.stream)||n.body.stream.locked))throw c.errors.exception({header:s,message:"Response body is locked or disturbed"});const i=l(n),o=B();if(null!=n.body){const e=n.body.stream.getReader();C(e,o.resolve,o.reject)}else o.resolve(void 0);const h=[],u={type:"put",request:r,response:i};h.push(u);const I=await o.promise;null!=i.body&&(i.body.source=I);const Q=B();let m=null;try{this.#xe(h)}catch(e){m=e}return queueMicrotask((()=>{null===m?Q.resolve():Q.reject(m)})),Q.promise}async delete(e,t={}){c.brandCheck(this,f);const s="Cache.delete";c.argumentLengthCheck(arguments,1,s),e=c.converters.RequestInfo(e),t=c.converters.CacheQueryOptions(t,s,"options");let n=null;if(c.is.Request(e)){if(n=E(e),"GET"!==n.method&&!t.ignoreMethod)return!1}else r("string"==typeof e),n=E(new d(e));const i=[],A={type:"delete",request:n,options:t};i.push(A);const o=B();let a,l=null;try{a=this.#xe(i)}catch(e){l=e}return queueMicrotask((()=>{null===l?o.resolve(!!a?.length):o.reject(l)})),o.promise}async keys(e=void 0,t={}){c.brandCheck(this,f);void 0!==e&&(e=c.converters.RequestInfo(e)),t=c.converters.CacheQueryOptions(t,"Cache.keys","options");let s=null;if(void 0!==e)if(c.is.Request(e)){if(s=E(e),"GET"!==s.method&&!t.ignoreMethod)return[]}else"string"==typeof e&&(s=E(new d(e)));const r=B(),n=[];if(void 0===e)for(const e of this.#Le)n.push(e[0]);else{const e=this.#He(s,t);for(const t of e)n.push(t[0])}return queueMicrotask((()=>{const e=[];for(const t of n){const s=u(t,void 0,(new AbortController).signal,"immutable");e.push(s)}r.resolve(Object.freeze(e))})),r.promise}#xe(e){const t=this.#Le,s=[...t],n=[],i=[];try{for(const s of e){if("delete"!==s.type&&"put"!==s.type)throw c.errors.exception({header:"Cache.#batchCacheOperations",message:'operation type does not match "delete" or "put"'});if("delete"===s.type&&null!=s.response)throw c.errors.exception({header:"Cache.#batchCacheOperations",message:"delete operation should not have an associated response"});if(this.#He(s.request,s.options,n).length)throw new DOMException("???","InvalidStateError");let e;if("delete"===s.type){if(e=this.#He(s.request,s.options),0===e.length)return[];for(const s of e){const e=t.indexOf(s);r(-1!==e),t.splice(e,1)}}else if("put"===s.type){if(null==s.response)throw c.errors.exception({header:"Cache.#batchCacheOperations",message:"put operation should have an associated response"});const i=s.request;if(!p(i.url))throw c.errors.exception({header:"Cache.#batchCacheOperations",message:"expected http or https scheme"});if("GET"!==i.method)throw c.errors.exception({header:"Cache.#batchCacheOperations",message:"not get method"});if(null!=s.options)throw c.errors.exception({header:"Cache.#batchCacheOperations",message:"options must not be defined"});e=this.#He(s.request);for(const s of e){const e=t.indexOf(s);r(-1!==e),t.splice(e,1)}t.push([s.request,s.response]),n.push([s.request,s.response])}i.push([s.request,s.response])}return i}catch(e){throw this.#Le.length=0,this.#Le=s,e}}#He(e,t,s){const r=[],n=s??this.#Le;for(const s of n){const[n,i]=s;this.#Ye(e,n,i,t)&&r.push(s)}return r}#Ye(e,t,s=null,r){const n=new URL(e.url),o=new URL(t.url);if(r?.ignoreSearch&&(o.search="",n.search=""),!i(n,o,!0))return!1;if(null==s||r?.ignoreVary||!s.headersList.contains("vary"))return!0;const a=A(s.headersList.get("vary"));for(const s of a){if("*"===s)return!1;if(t.headersList.get(s)!==e.headersList.get(s))return!1}return!0}#Pe(e,t,s=1/0){let r=null;if(void 0!==e)if(c.is.Request(e)){if(r=E(e),"GET"!==r.method&&!t.ignoreMethod)return[]}else"string"==typeof e&&(r=E(new d(e)));const n=[];if(void 0===e)for(const e of this.#Le)n.push(e[1]);else{const e=this.#He(r,t);for(const t of e)n.push(t[1])}const i=[];for(const e of n){const t=h(e,"immutable");if(i.push(t.clone()),i.length>=s)break}return Object.freeze(i)}}Object.defineProperties(f.prototype,{[Symbol.toStringTag]:{value:"Cache",configurable:!0},match:o,matchAll:o,add:o,addAll:o,put:o,delete:o,keys:o});const Q=[{key:"ignoreSearch",converter:c.converters.boolean,defaultValue:()=>!1},{key:"ignoreMethod",converter:c.converters.boolean,defaultValue:()=>!1},{key:"ignoreVary",converter:c.converters.boolean,defaultValue:()=>!1}];c.converters.CacheQueryOptions=c.dictionaryConverter(Q),c.converters.MultiCacheQueryOptions=c.dictionaryConverter([...Q,{key:"cacheName",converter:c.converters.DOMString}]),c.converters.Response=c.interfaceConverter(c.is.Response,"Response"),c.converters["sequence<RequestInfo>"]=c.sequenceConverter(c.converters.RequestInfo),e.exports={Cache:f}},6939:(e,t,s)=>{"use strict";const{Cache:r}=s(4420),{webidl:n}=s(6097),{kEnumerableProperty:i}=s(2858),{kConstruct:A}=s(257);class o{#Ve=new Map;constructor(){arguments[0]!==A&&n.illegalConstructor(),n.util.markAsUncloneable(this)}async match(e,t={}){if(n.brandCheck(this,o),n.argumentLengthCheck(arguments,1,"CacheStorage.match"),e=n.converters.RequestInfo(e),null!=(t=n.converters.MultiCacheQueryOptions(t)).cacheName){if(this.#Ve.has(t.cacheName)){const s=this.#Ve.get(t.cacheName),n=new r(A,s);return await n.match(e,t)}}else for(const s of this.#Ve.values()){const n=new r(A,s),i=await n.match(e,t);if(void 0!==i)return i}}async has(e){n.brandCheck(this,o);const t="CacheStorage.has";return n.argumentLengthCheck(arguments,1,t),e=n.converters.DOMString(e,t,"cacheName"),this.#Ve.has(e)}async open(e){n.brandCheck(this,o);const t="CacheStorage.open";if(n.argumentLengthCheck(arguments,1,t),e=n.converters.DOMString(e,t,"cacheName"),this.#Ve.has(e)){const t=this.#Ve.get(e);return new r(A,t)}const s=[];return this.#Ve.set(e,s),new r(A,s)}async delete(e){n.brandCheck(this,o);const t="CacheStorage.delete";return n.argumentLengthCheck(arguments,1,t),e=n.converters.DOMString(e,t,"cacheName"),this.#Ve.delete(e)}async keys(){n.brandCheck(this,o);return[...this.#Ve.keys()]}}Object.defineProperties(o.prototype,{[Symbol.toStringTag]:{value:"CacheStorage",configurable:!0},match:i,has:i,open:i,delete:i,keys:i}),e.exports={CacheStorage:o}},3932:(e,t,s)=>{"use strict";const r=s(4589),{URLSerializer:n}=s(9934),{isValidHeaderName:i}=s(6686);e.exports={urlEquals:function(e,t,s=!1){return n(e,s)===n(t,s)},getFieldValues:function(e){r(null!==e);const t=[];for(let s of e.split(","))s=s.trim(),i(s)&&t.push(s);return t}}},3042:e=>{"use strict";e.exports={maxAttributeValueSize:1024,maxNameValuePairSize:4096}},9391:(e,t,s)=>{"use strict";const{parseSetCookie:r}=s(6712),{stringify:n}=s(9871),{webidl:i}=s(6097),{Headers:A}=s(6558),o=i.brandCheckMultiple([A,globalThis.Headers].filter(Boolean));function a(e,t){i.argumentLengthCheck(arguments,2,"setCookie"),o(e),t=i.converters.Cookie(t);const s=n(t);s&&e.append("set-cookie",s,!0)}i.converters.DeleteCookieAttributes=i.dictionaryConverter([{converter:i.nullableConverter(i.converters.DOMString),key:"path",defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:"domain",defaultValue:()=>null}]),i.converters.Cookie=i.dictionaryConverter([{converter:i.converters.DOMString,key:"name"},{converter:i.converters.DOMString,key:"value"},{converter:i.nullableConverter((e=>"number"==typeof e?i.converters["unsigned long long"](e):new Date(e))),key:"expires",defaultValue:()=>null},{converter:i.nullableConverter(i.converters["long long"]),key:"maxAge",defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:"domain",defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:"path",defaultValue:()=>null},{converter:i.nullableConverter(i.converters.boolean),key:"secure",defaultValue:()=>null},{converter:i.nullableConverter(i.converters.boolean),key:"httpOnly",defaultValue:()=>null},{converter:i.converters.USVString,key:"sameSite",allowedValues:["Strict","Lax","None"]},{converter:i.sequenceConverter(i.converters.DOMString),key:"unparsed",defaultValue:()=>[]}]),e.exports={getCookies:function(e){i.argumentLengthCheck(arguments,1,"getCookies"),o(e);const t=e.get("cookie"),s={};if(!t)return s;for(const e of t.split(";")){const[t,...r]=e.split("=");s[t.trim()]=r.join("=")}return s},deleteCookie:function(e,t,s){o(e);const r="deleteCookie";i.argumentLengthCheck(arguments,2,r),t=i.converters.DOMString(t,r,"name"),s=i.converters.DeleteCookieAttributes(s),a(e,{name:t,value:"",expires:new Date(0),...s})},getSetCookies:function(e){i.argumentLengthCheck(arguments,1,"getSetCookies"),o(e);const t=e.getSetCookie();return t?t.map((e=>r(e))):[]},setCookie:a,parseCookie:function(e){return e=i.converters.DOMString(e),r(e)}}},6712:(e,t,s)=>{"use strict";const{maxNameValuePairSize:r,maxAttributeValueSize:n}=s(3042),{isCTLExcludingHtab:i}=s(9871),{collectASequenceOfCodePointsFast:A}=s(9934),o=s(4589),{unescape:a}=s(1792);function c(e,t={}){if(0===e.length)return t;o(";"===e[0]);let s="";(e=e.slice(1)).includes(";")?(s=A(";",e,{position:0}),e=e.slice(s.length)):(s=e,e="");let r="",i="";if(s.includes("=")){const e={position:0};r=A("=",s,e),i=s.slice(e.position+1)}else r=s;if(r=r.trim(),i=i.trim(),i.length>n)return c(e,t);const a=r.toLowerCase();if("expires"===a){const e=new Date(i);t.expires=e}else if("max-age"===a){const s=i.charCodeAt(0);if((s<48||s>57)&&"-"!==i[0])return c(e,t);if(!/^\d+$/.test(i))return c(e,t);const r=Number(i);t.maxAge=r}else if("domain"===a){let e=i;"."===e[0]&&(e=e.slice(1)),e=e.toLowerCase(),t.domain=e}else if("path"===a){let e="";e=0===i.length||"/"!==i[0]?"/":i,t.path=e}else if("secure"===a)t.secure=!0;else if("httponly"===a)t.httpOnly=!0;else if("samesite"===a){let e="Default";const s=i.toLowerCase();s.includes("none")&&(e="None"),s.includes("strict")&&(e="Strict"),s.includes("lax")&&(e="Lax"),t.sameSite=e}else t.unparsed??=[],t.unparsed.push(`${r}=${i}`);return c(e,t)}e.exports={parseSetCookie:function(e){if(i(e))return null;let t="",s="",n="",o="";if(e.includes(";")){const r={position:0};t=A(";",e,r),s=e.slice(r.position)}else t=e;if(t.includes("=")){const e={position:0};n=A("=",t,e),o=t.slice(e.position+1)}else o=t;return n=n.trim(),o=o.trim(),n.length+o.length>r?null:{name:n,value:a(o),...c(s)}},parseUnparsedAttributes:c}},9871:e=>{"use strict";function t(e){for(let t=0;t<e.length;++t){const s=e.charCodeAt(t);if(s<33||s>126||34===s||40===s||41===s||60===s||62===s||64===s||44===s||59===s||58===s||92===s||47===s||91===s||93===s||63===s||61===s||123===s||125===s)throw new Error("Invalid cookie name")}}function s(e){let t=e.length,s=0;if('"'===e[0]){if(1===t||'"'!==e[t-1])throw new Error("Invalid cookie value");--t,++s}for(;s<t;){const t=e.charCodeAt(s++);if(t<33||t>126||34===t||44===t||59===t||92===t)throw new Error("Invalid cookie value")}}function r(e){for(let t=0;t<e.length;++t){const s=e.charCodeAt(t);if(s<32||127===s||59===s)throw new Error("Invalid cookie path")}}const n=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],i=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],A=Array(61).fill(0).map(((e,t)=>t.toString().padStart(2,"0")));function o(e){return"number"==typeof e&&(e=new Date(e)),`${n[e.getUTCDay()]}, ${A[e.getUTCDate()]} ${i[e.getUTCMonth()]} ${e.getUTCFullYear()} ${A[e.getUTCHours()]}:${A[e.getUTCMinutes()]}:${A[e.getUTCSeconds()]} GMT`}e.exports={isCTLExcludingHtab:function(e){for(let t=0;t<e.length;++t){const s=e.charCodeAt(t);if(s>=0&&s<=8||s>=10&&s<=31||127===s)return!0}return!1},validateCookieName:t,validateCookiePath:r,validateCookieValue:s,toIMFDate:o,stringify:function(e){if(0===e.name.length)return null;t(e.name),s(e.value);const n=[`${e.name}=${e.value}`];e.name.startsWith("__Secure-")&&(e.secure=!0),e.name.startsWith("__Host-")&&(e.secure=!0,e.domain=null,e.path="/"),e.secure&&n.push("Secure"),e.httpOnly&&n.push("HttpOnly"),"number"==typeof e.maxAge&&(!function(e){if(e<0)throw new Error("Invalid cookie max-age")}(e.maxAge),n.push(`Max-Age=${e.maxAge}`)),e.domain&&(!function(e){if(e.startsWith("-")||e.endsWith(".")||e.endsWith("-"))throw new Error("Invalid cookie domain")}(e.domain),n.push(`Domain=${e.domain}`)),e.path&&(r(e.path),n.push(`Path=${e.path}`)),e.expires&&"Invalid Date"!==e.expires.toString()&&n.push(`Expires=${o(e.expires)}`),e.sameSite&&n.push(`SameSite=${e.sameSite}`);for(const t of e.unparsed){if(!t.includes("="))throw new Error("Invalid unparsed");const[e,...s]=t.split("=");n.push(`${e.trim()}=${s.join("=")}`)}return n.join("; ")}}},8813:(e,t,s)=>{"use strict";const{Transform:r}=s(7075),{isASCIINumber:n,isValidLastEventId:i}=s(4689),A=[239,187,191];e.exports={EventSourceStream:class extends r{state;checkBOM=!0;crlfCheck=!1;eventEndCheck=!1;buffer=null;pos=0;event={data:void 0,event:void 0,id:void 0,retry:void 0};constructor(e={}){e.readableObjectMode=!0,super(e),this.state=e.eventSourceSettings||{},e.push&&(this.push=e.push)}_transform(e,t,s){if(0!==e.length){if(this.buffer?this.buffer=Buffer.concat([this.buffer,e]):this.buffer=e,this.checkBOM)switch(this.buffer.length){case 1:return this.buffer[0]===A[0]||(this.checkBOM=!1),void s();case 2:if(this.buffer[0]===A[0]&&this.buffer[1]===A[1])return void s();this.checkBOM=!1;break;case 3:if(this.buffer[0]===A[0]&&this.buffer[1]===A[1]&&this.buffer[2]===A[2])return this.buffer=Buffer.alloc(0),this.checkBOM=!1,void s();this.checkBOM=!1;break;default:this.buffer[0]===A[0]&&this.buffer[1]===A[1]&&this.buffer[2]===A[2]&&(this.buffer=this.buffer.subarray(3)),this.checkBOM=!1}for(;this.pos<this.buffer.length;)if(this.eventEndCheck){if(this.crlfCheck){if(10===this.buffer[this.pos]){this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,this.crlfCheck=!1;continue}this.crlfCheck=!1}if(10===this.buffer[this.pos]||13===this.buffer[this.pos]){13===this.buffer[this.pos]&&(this.crlfCheck=!0),this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,(void 0!==this.event.data||this.event.event||void 0!==this.event.id||this.event.retry)&&this.processEvent(this.event),this.clearEvent();continue}this.eventEndCheck=!1}else 10!==this.buffer[this.pos]&&13!==this.buffer[this.pos]?this.pos++:(13===this.buffer[this.pos]&&(this.crlfCheck=!0),this.parseLine(this.buffer.subarray(0,this.pos),this.event),this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,this.eventEndCheck=!0);s()}else s()}parseLine(e,t){if(0===e.length)return;const s=e.indexOf(58);if(0===s)return;let r="",A="";if(-1!==s){r=e.subarray(0,s).toString("utf8");let t=s+1;32===e[t]&&++t,A=e.subarray(t).toString("utf8")}else r=e.toString("utf8"),A="";switch(r){case"data":void 0===t[r]?t[r]=A:t[r]+=`\n${A}`;break;case"retry":n(A)&&(t[r]=A);break;case"id":i(A)&&(t[r]=A);break;case"event":A.length>0&&(t[r]=A)}}processEvent(e){e.retry&&n(e.retry)&&(this.state.reconnectionTime=parseInt(e.retry,10)),void 0!==e.id&&i(e.id)&&(this.state.lastEventId=e.id),void 0!==e.data&&this.push({type:e.event||"message",options:{data:e.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}}}},7928:(e,t,s)=>{"use strict";const{pipeline:r}=s(7075),{fetching:n}=s(7388),{makeRequest:i}=s(4609),{webidl:A}=s(6097),{EventSourceStream:o}=s(8813),{parseMIMEType:a}=s(9934),{createFastMessageEvent:c}=s(878),{isNetworkError:l}=s(4821),{kEnumerableProperty:h}=s(2858),{environmentSettingsObject:g}=s(6686);let d=!1;class u extends EventTarget{#Oe={open:null,error:null,message:null};#Ge;#Je=!1;#We=0;#_e=null;#q=null;#$e;#le;constructor(e,t={}){super(),A.util.markAsUncloneable(this);const s="EventSource constructor";A.argumentLengthCheck(arguments,1,s),d||(d=!0,process.emitWarning("EventSource is experimental, expect them to change at any time.",{code:"UNDICI-ES"})),e=A.converters.USVString(e),t=A.converters.EventSourceInitDict(t,s,"eventSourceInitDict"),this.#$e=t.node.dispatcher||t.dispatcher,this.#le={lastEventId:"",reconnectionTime:t.node.reconnectionTime};const r=g;let n;try{n=new URL(e,r.settingsObject.baseUrl),this.#le.origin=n.origin}catch(e){throw new DOMException(e,"SyntaxError")}this.#Ge=n.href;let o="anonymous";!0===t.withCredentials&&(o="use-credentials",this.#Je=!0);const a={redirect:"follow",keepalive:!0,mode:"cors",credentials:"anonymous"===o?"same-origin":"omit",referrer:"no-referrer"};a.client=g.settingsObject,a.headersList=[["accept",{name:"accept",value:"text/event-stream"}]],a.cache="no-store",a.initiator="other",a.urlList=[new URL(this.#Ge)],this.#_e=i(a),this.#qe()}get readyState(){return this.#We}get url(){return this.#Ge}get withCredentials(){return this.#Je}#qe(){if(2===this.#We)return;this.#We=0;const e={request:this.#_e,dispatcher:this.#$e};e.processResponseEndOfBody=e=>{if(!l(e))return this.#ze()},e.processResponse=e=>{if(l(e))return e.aborted?(this.close(),void this.dispatchEvent(new Event("error"))):void this.#ze();const t=e.headersList.get("content-type",!0),s=null!==t?a(t):"failure",n="failure"!==s&&"text/event-stream"===s.essence;if(200!==e.status||!1===n)return this.close(),void this.dispatchEvent(new Event("error"));this.#We=1,this.dispatchEvent(new Event("open")),this.#le.origin=e.urlList[e.urlList.length-1].origin;const i=new o({eventSourceSettings:this.#le,push:e=>{this.dispatchEvent(c(e.type,e.options))}});r(e.body.stream,i,(e=>{!1===e?.aborted&&(this.close(),this.dispatchEvent(new Event("error")))}))},this.#q=n(e)}#ze(){2!==this.#We&&(this.#We=0,this.dispatchEvent(new Event("error")),setTimeout((()=>{0===this.#We&&(this.#le.lastEventId.length&&this.#_e.headersList.set("last-event-id",this.#le.lastEventId,!0),this.#qe())}),this.#le.reconnectionTime)?.unref())}close(){A.brandCheck(this,u),2!==this.#We&&(this.#We=2,this.#q.abort(),this.#_e=null)}get onopen(){return this.#Oe.open}set onopen(e){this.#Oe.open&&this.removeEventListener("open",this.#Oe.open);const t=A.converters.EventHandlerNonNull(e);null!==t?(this.addEventListener("open",t),this.#Oe.open=e):this.#Oe.open=null}get onmessage(){return this.#Oe.message}set onmessage(e){this.#Oe.message&&this.removeEventListener("message",this.#Oe.message);const t=A.converters.EventHandlerNonNull(e);null!==t?(this.addEventListener("message",t),this.#Oe.message=e):this.#Oe.message=null}get onerror(){return this.#Oe.error}set onerror(e){this.#Oe.error&&this.removeEventListener("error",this.#Oe.error);const t=A.converters.EventHandlerNonNull(e);null!==t?(this.addEventListener("error",t),this.#Oe.error=e):this.#Oe.error=null}}const E={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:0,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:1,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:2,writable:!1}};Object.defineProperties(u,E),Object.defineProperties(u.prototype,E),Object.defineProperties(u.prototype,{close:h,onerror:h,onmessage:h,onopen:h,readyState:h,url:h,withCredentials:h}),A.converters.EventSourceInitDict=A.dictionaryConverter([{key:"withCredentials",converter:A.converters.boolean,defaultValue:()=>!1},{key:"dispatcher",converter:A.converters.any},{key:"node",converter:A.dictionaryConverter([{key:"reconnectionTime",converter:A.converters["unsigned long"],defaultValue:()=>3e3},{key:"dispatcher",converter:A.converters.any}]),defaultValue:()=>({})}]),e.exports={EventSource:u,defaultReconnectionTime:3e3}},4689:e=>{"use strict";e.exports={isValidLastEventId:function(e){return-1===e.indexOf("\0")},isASCIINumber:function(e){if(0===e.length)return!1;for(let t=0;t<e.length;t++)if(e.charCodeAt(t)<48||e.charCodeAt(t)>57)return!1;return!0}}},2530:(e,t,s)=>{"use strict";const r=s(2858),{ReadableStreamFrom:n,readableStreamClose:i,fullyReadBody:A,extractMimeType:o,utf8DecodeBytes:a}=s(6686),{FormData:c,setFormDataState:l}=s(3944),{webidl:h}=s(6097),g=s(4589),{isErrored:d,isDisturbed:u}=s(7075),{isArrayBuffer:E}=s(3429),{serializeAMimeType:I}=s(9934),{multipartFormDataParser:p}=s(4614),{createDeferredPromise:C}=s(9250);let B;try{const e=s(7598);B=t=>e.randomInt(0,t)}catch{B=e=>Math.floor(Math.random()*e)}const f=new TextEncoder;function Q(){}const m=new FinalizationRegistry((e=>{const t=e.deref();!t||t.locked||u(t)||d(t)||t.cancel("Response object has been garbage collected").catch(Q)}));function y(e,t=!1){let s=null;s=h.is.ReadableStream(e)?e:h.is.Blob(e)?e.stream():new ReadableStream({pull(e){const t="string"==typeof o?f.encode(o):o;t.byteLength&&e.enqueue(t),queueMicrotask((()=>i(e)))},start(){},type:"bytes"}),g(h.is.ReadableStream(s));let A=null,o=null,a=null,c=null;if("string"==typeof e)o=e,c="text/plain;charset=UTF-8";else if(h.is.URLSearchParams(e))o=e.toString(),c="application/x-www-form-urlencoded;charset=UTF-8";else if(h.is.BufferSource(e))o=E(e)?new Uint8Array(e.slice()):new Uint8Array(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));else if(h.is.FormData(e)){const t=`----formdata-undici-0${`${B(1e11)}`.padStart(11,"0")}`,s=`--${t}\r\nContent-Disposition: form-data`,r=e=>e.replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22"),n=e=>e.replace(/\r?\n|\r/g,"\r\n"),i=[],l=new Uint8Array([13,10]);a=0;let h=!1;for(const[t,A]of e)if("string"==typeof A){const e=f.encode(s+`; name="${r(n(t))}"`+`\r\n\r\n${n(A)}\r\n`);i.push(e),a+=e.byteLength}else{const e=f.encode(`${s}; name="${r(n(t))}"`+(A.name?`; filename="${r(A.name)}"`:"")+"\r\n"+`Content-Type: ${A.type||"application/octet-stream"}\r\n\r\n`);i.push(e,A,l),"number"==typeof A.size?a+=e.byteLength+A.size+l.byteLength:h=!0}const g=f.encode(`--${t}--\r\n`);i.push(g),a+=g.byteLength,h&&(a=null),o=e,A=async function*(){for(const e of i)e.stream?yield*e.stream():yield e},c=`multipart/form-data; boundary=${t}`}else if(h.is.Blob(e))o=e,a=e.size,e.type&&(c=e.type);else if("function"==typeof e[Symbol.asyncIterator]){if(t)throw new TypeError("keepalive");if(r.isDisturbed(e)||e.locked)throw new TypeError("Response body object should not be disturbed or locked");s=h.is.ReadableStream(e)?e:n(e)}if(("string"==typeof o||r.isBuffer(o))&&(a=Buffer.byteLength(o)),null!=A){let t;s=new ReadableStream({async start(){t=A(e)[Symbol.asyncIterator]()},async pull(e){const{value:r,done:n}=await t.next();if(n)queueMicrotask((()=>{e.close(),e.byobRequest?.respond(0)}));else if(!d(s)){const t=new Uint8Array(r);t.byteLength&&e.enqueue(t)}return e.desiredSize>0},async cancel(e){await t.return()},type:"bytes"})}return[{stream:s,source:o,length:a},c]}function w(e,t,s,r){try{h.brandCheck(e,s)}catch(e){return Promise.reject(e)}const n=r(e);if(S(n))return Promise.reject(new TypeError("Body is unusable: Body has already been read"));if(n.aborted)return Promise.reject(new DOMException("The operation was aborted.","AbortError"));const i=C(),o=i.reject,a=e=>{try{i.resolve(t(e))}catch(e){o(e)}};return null==n.body?(a(Buffer.allocUnsafe(0)),i.promise):(A(n.body,a,o),i.promise)}function S(e){const t=e.body;return null!=t&&(t.stream.locked||r.isDisturbed(t.stream))}function D(e){return JSON.parse(a(e))}function b(e){const t=e.headersList,s=o(t);return"failure"===s?null:s}e.exports={extractBody:y,safelyExtractBody:function(e,t=!1){return h.is.ReadableStream(e)&&(g(!r.isDisturbed(e),"The body has already been consumed."),g(!e.locked,"The stream is locked.")),y(e,t)},cloneBody:function(e){const{0:t,1:s}=e.stream.tee();return e.stream=t,{stream:s,length:e.length,source:e.source}},mixinBody:function(e,t){Object.assign(e.prototype,function(e,t){return{blob(){return w(this,(e=>{let s=b(t(this));return null===s?s="":s&&(s=I(s)),new Blob([e],{type:s})}),e,t)},arrayBuffer(){return w(this,(e=>new Uint8Array(e).buffer),e,t)},text(){return w(this,a,e,t)},json(){return w(this,D,e,t)},formData(){return w(this,(e=>{const s=b(t(this));if(null!==s)switch(s.essence){case"multipart/form-data":{const t=p(e,s),r=new c;return l(r,t),r}case"application/x-www-form-urlencoded":{const t=new URLSearchParams(e.toString()),s=new c;for(const[e,r]of t)s.append(e,r);return s}}throw new TypeError('Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".')}),e,t)},bytes(){return w(this,(e=>new Uint8Array(e)),e,t)}}}(e,t))},streamRegistry:m,bodyUnusable:S}},9441:e=>{"use strict";const t=["GET","HEAD","POST"],s=new Set(t),r=[301,302,303,307,308],n=new Set(r),i=["1","7","9","11","13","15","17","19","20","21","22","23","25","37","42","43","53","69","77","79","87","95","101","102","103","104","109","110","111","113","115","117","119","123","135","137","139","143","161","179","389","427","465","512","513","514","515","526","530","531","532","540","548","554","556","563","587","601","636","989","990","993","995","1719","1720","1723","2049","3659","4045","4190","5060","5061","6000","6566","6665","6666","6667","6668","6669","6679","6697","10080"],A=new Set(i),o=["no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"],a=["",...o],c=new Set(o),l=["GET","HEAD","OPTIONS","TRACE"],h=new Set(l),g=["CONNECT","TRACE","TRACK"],d=new Set(g),u=["audio","audioworklet","font","image","manifest","paintworklet","script","style","track","video","xslt",""],E=new Set(u);e.exports={subresource:u,forbiddenMethods:g,requestBodyHeader:["content-encoding","content-language","content-location","content-type","content-length"],referrerPolicy:a,requestRedirect:["follow","manual","error"],requestMode:["navigate","same-origin","no-cors","cors"],requestCredentials:["omit","same-origin","include"],requestCache:["default","no-store","reload","no-cache","force-cache","only-if-cached"],redirectStatus:r,corsSafeListedMethods:t,nullBodyStatus:[101,204,205,304],safeMethods:l,badPorts:i,requestDuplex:["half"],subresourceSet:E,badPortsSet:A,redirectStatusSet:n,corsSafeListedMethodsSet:s,safeMethodsSet:h,forbiddenMethodsSet:d,referrerPolicyTokens:c}},9934:(e,t,s)=>{"use strict";const r=s(4589),n=new TextEncoder,i=/^[!#$%&'*+\-.^_|~A-Za-z0-9]+$/,A=/[\u000A\u000D\u0009\u0020]/,o=/[\u0009\u000A\u000C\u000D\u0020]/g,a=/^[\u0009\u0020-\u007E\u0080-\u00FF]+$/;function c(e,t=!1){if(!t)return e.href;const s=e.href,r=e.hash.length,n=0===r?s:s.substring(0,s.length-r);return!r&&s.endsWith("#")?n.slice(0,-1):n}function l(e,t,s){let r="";for(;s.position<t.length&&e(t[s.position]);)r+=t[s.position],s.position++;return r}function h(e,t,s){const r=t.indexOf(e,s.position),n=s.position;return-1===r?(s.position=t.length,t.slice(n)):(s.position=r,t.slice(n,s.position))}function g(e){return function(e){const t=e.length,s=new Uint8Array(t);let r=0;for(let n=0;n<t;++n){const t=e[n];37!==t?s[r++]=t:37!==t||d(e[n+1])&&d(e[n+2])?(s[r++]=u(e[n+1])<<4|u(e[n+2]),n+=2):s[r++]=37}return t===r?s:s.subarray(0,r)}(n.encode(e))}function d(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function u(e){return e>=48&&e<=57?e-48:(223&e)-55}function E(e){const t={position:0},s=h("/",e=C(e,!0,!0),t);if(0===s.length||!i.test(s))return"failure";if(t.position>=e.length)return"failure";t.position++;let r=h(";",e,t);if(r=C(r,!1,!0),0===r.length||!i.test(r))return"failure";const n=s.toLowerCase(),o=r.toLowerCase(),c={type:n,subtype:o,parameters:new Map,essence:`${n}/${o}`};for(;t.position<e.length;){t.position++,l((e=>A.test(e)),e,t);let s=l((e=>";"!==e&&"="!==e),e,t);if(s=s.toLowerCase(),t.position<e.length){if(";"===e[t.position])continue;t.position++}if(t.position>=e.length)break;let r=null;if('"'===e[t.position])r=I(e,t,!0),h(";",e,t);else if(r=h(";",e,t),r=C(r,!1,!0),0===r.length)continue;0===s.length||!i.test(s)||0!==r.length&&!a.test(r)||c.parameters.has(s)||c.parameters.set(s,r)}return c}function I(e,t,s=!1){const n=t.position;let i="";for(r('"'===e[t.position]),t.position++;i+=l((e=>'"'!==e&&"\\"!==e),e,t),!(t.position>=e.length);){const s=e[t.position];if(t.position++,"\\"!==s){r('"'===s);break}if(t.position>=e.length){i+="\\";break}i+=e[t.position],t.position++}return s?i:e.slice(n,t.position)}function p(e){return 13===e||10===e||9===e||32===e}function C(e,t=!0,s=!0){return f(e,t,s,p)}function B(e){return 13===e||10===e||9===e||12===e||32===e}function f(e,t,s,r){let n=0,i=e.length-1;if(t)for(;n<e.length&&r(e.charCodeAt(n));)n++;if(s)for(;i>0&&r(e.charCodeAt(i));)i--;return 0===n&&i===e.length-1?e:e.slice(n,i+1)}function Q(e){const t=e.length;if(65535>t)return String.fromCharCode.apply(null,e);let s="",r=0,n=65535;for(;r<t;)r+n>t&&(n=t-r),s+=String.fromCharCode.apply(null,e.subarray(r,r+=n));return s}e.exports={dataURLProcessor:function(e){r("data:"===e.protocol);let t=c(e,!0);t=t.slice(5);const s={position:0};let n=h(",",t,s);const i=n.length;if(n=function(e,t=!0,s=!0){return f(e,t,s,B)}(n,!0,!0),s.position>=t.length)return"failure";s.position++;let A=g(t.slice(i+1));if(/;(\u0020){0,}base64$/i.test(n)){if(A=function(e){let t=(e=e.replace(o,"")).length;t%4==0&&61===e.charCodeAt(t-1)&&(--t,61===e.charCodeAt(t-1)&&--t);if(t%4==1)return"failure";if(/[^+/0-9A-Za-z]/.test(e.length===t?e:e.substring(0,t)))return"failure";const s=Buffer.from(e,"base64");return new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}(Q(A)),"failure"===A)return"failure";n=n.slice(0,-6),n=n.replace(/(\u0020)+$/,""),n=n.slice(0,-1)}n.startsWith(";")&&(n="text/plain"+n);let a=E(n);return"failure"===a&&(a=E("text/plain;charset=US-ASCII")),{mimeType:a,body:A}},URLSerializer:c,collectASequenceOfCodePoints:l,collectASequenceOfCodePointsFast:h,stringPercentDecode:g,parseMIMEType:E,collectAnHTTPQuotedString:I,serializeAMimeType:function(e){r("failure"!==e);const{parameters:t,essence:s}=e;let n=s;for(let[e,s]of t.entries())n+=";",n+=e,n+="=",i.test(s)||(s=s.replace(/(\\|")/g,"\\$1"),s='"'+s,s+='"'),n+=s;return n},removeChars:f,removeHTTPWhitespace:C,minimizeSupportedMimeType:function(e){switch(e.essence){case"application/ecmascript":case"application/javascript":case"application/x-ecmascript":case"application/x-javascript":case"text/ecmascript":case"text/javascript":case"text/javascript1.0":case"text/javascript1.1":case"text/javascript1.2":case"text/javascript1.3":case"text/javascript1.4":case"text/javascript1.5":case"text/jscript":case"text/livescript":case"text/x-ecmascript":case"text/x-javascript":return"text/javascript";case"application/json":case"text/json":return"application/json";case"image/svg+xml":return"image/svg+xml";case"text/xml":case"application/xml":return"application/xml"}return e.subtype.endsWith("+json")?"application/json":e.subtype.endsWith("+xml")?"application/xml":""},HTTP_TOKEN_CODEPOINTS:i,isomorphicDecode:Q}},4614:(e,t,s)=>{"use strict";const{bufferToLowerCasedHeaderName:r}=s(2858),{utf8DecodeBytes:n}=s(6686),{HTTP_TOKEN_CODEPOINTS:i,isomorphicDecode:A}=s(9934),{makeEntry:o}=s(3944),{webidl:a}=s(6097),c=s(4589),l=Buffer.from('form-data; name="'),h=Buffer.from("filename"),g=Buffer.from("--"),d=Buffer.from("--\r\n");function u(e){for(let t=0;t<e.length;++t)if(-128&e.charCodeAt(t))return!1;return!0}function E(e,t){let s=null,n=null,o=null,a=null;for(;;){if(13===e[t.position]&&10===e[t.position+1]){if(null===s)throw f("header name is null");return{name:s,filename:n,contentType:o,encoding:a}}let c=p((e=>10!==e&&13!==e&&58!==e),e,t);if(c=C(c,!0,!0,(e=>9===e||32===e)),!i.test(c.toString()))throw f("header name does not match the field-name token production");if(58!==e[t.position])throw f("expected :");switch(t.position++,p((e=>32===e||9===e),e,t),r(c)){case"content-disposition":if(s=n=null,!B(e,l,t))throw f('expected form-data; name=" for content-disposition header');if(t.position+=17,s=I(e,t),59===e[t.position]&&32===e[t.position+1]){const s={position:t.position+2};if(B(e,h,s))if(42===e[s.position+8]){s.position+=10,p((e=>32===e||9===e),e,s);const r=p((e=>32!==e&&13!==e&&10!==e),e,s);if(117!==r[0]&&85!==r[0]||116!==r[1]&&84!==r[1]||102!==r[2]&&70!==r[2]||45!==r[3]||56!==r[4])throw f("unknown encoding, expected utf-8''");n=decodeURIComponent((new TextDecoder).decode(r.subarray(7))),t.position=s.position}else t.position+=11,p((e=>32===e||9===e),e,t),t.position++,n=I(e,t)}break;case"content-type":{let s=p((e=>10!==e&&13!==e),e,t);s=C(s,!1,!0,(e=>9===e||32===e)),o=A(s);break}case"content-transfer-encoding":{let s=p((e=>10!==e&&13!==e),e,t);s=C(s,!1,!0,(e=>9===e||32===e)),a=A(s);break}default:p((e=>10!==e&&13!==e),e,t)}if(13!==e[t.position]&&10!==e[t.position+1])throw f("expected CRLF");t.position+=2}}function I(e,t){c(34===e[t.position-1]);let s=p((e=>10!==e&&13!==e&&34!==e),e,t);if(34!==e[t.position])throw f('expected "');return t.position++,s=(new TextDecoder).decode(s).replace(/%0A/gi,"\n").replace(/%0D/gi,"\r").replace(/%22/g,'"'),s}function p(e,t,s){let r=s.position;for(;r<t.length&&e(t[r]);)++r;return t.subarray(s.position,s.position=r)}function C(e,t,s,r){let n=0,i=e.length-1;if(t)for(;n<e.length&&r(e[n]);)n++;if(s)for(;i>0&&r(e[i]);)i--;return 0===n&&i===e.length-1?e:e.subarray(n,i+1)}function B(e,t,s){if(e.length<t.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[s.position+r])return!1;return!0}function f(e){return new TypeError("Failed to parse body as FormData.",{cause:new TypeError(e)})}e.exports={multipartFormDataParser:function(e,t){c("failure"!==t&&"multipart/form-data"===t.essence);const s=t.parameters.get("boundary");if(void 0===s)throw f("missing boundary in content-type header");const r=Buffer.from(`--${s}`,"utf8"),i=[],A={position:0};for(;13===e[A.position]&&10===e[A.position+1];)A.position+=2;let l=e.length;for(;10===e[l-1]&&13===e[l-2];)l-=2;for(l!==e.length&&(e=e.subarray(0,l));;){if(!e.subarray(A.position,A.position+r.length).equals(r))throw f("expected a value starting with -- and the boundary");if(A.position+=r.length,A.position===e.length-2&&B(e,g,A)||A.position===e.length-4&&B(e,d,A))return i;if(13!==e[A.position]||10!==e[A.position+1])throw f("expected CRLF");A.position+=2;const t=E(e,A);let s,l,{name:h,filename:I,contentType:p,encoding:C}=t;A.position+=2;{const t=e.indexOf(r.subarray(2),A.position);if(-1===t)throw f("expected boundary after body");s=e.subarray(A.position,t-4),A.position+=s.length,"base64"===C&&(s=Buffer.from(s.toString(),"base64"))}if(13!==e[A.position]||10!==e[A.position+1])throw f("expected CRLF");A.position+=2,null!==I?(p??="text/plain",u(p)||(p=""),l=new File([s],I,{type:p})):l=n(Buffer.from(s)),c(a.is.USVString(h)),c("string"==typeof l&&a.is.USVString(l)||a.is.File(l)),i.push(o(h,l,I))}},validateBoundary:function(e){const t=e.length;if(t<27||t>70)return!1;for(let s=0;s<t;++s){const t=e.charCodeAt(s);if(!(t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||39===t||45===t||95===t))return!1}return!0}}},3944:(e,t,s)=>{"use strict";const{iteratorMixin:r}=s(6686),{kEnumerableProperty:n}=s(2858),{webidl:i}=s(6097),A=s(7975);class o{#le=[];constructor(e=void 0){if(i.util.markAsUncloneable(this),void 0!==e)throw i.errors.conversionFailed({prefix:"FormData constructor",argument:"Argument 1",types:["undefined"]})}append(e,t,s=void 0){i.brandCheck(this,o);const r="FormData.append";i.argumentLengthCheck(arguments,2,r),e=i.converters.USVString(e),3===arguments.length||i.is.Blob(t)?(t=i.converters.Blob(t,r,"value"),void 0!==s&&(s=i.converters.USVString(s))):t=i.converters.USVString(t);const n=l(e,t,s);this.#le.push(n)}delete(e){i.brandCheck(this,o);i.argumentLengthCheck(arguments,1,"FormData.delete"),e=i.converters.USVString(e),this.#le=this.#le.filter((t=>t.name!==e))}get(e){i.brandCheck(this,o);i.argumentLengthCheck(arguments,1,"FormData.get"),e=i.converters.USVString(e);const t=this.#le.findIndex((t=>t.name===e));return-1===t?null:this.#le[t].value}getAll(e){i.brandCheck(this,o);return i.argumentLengthCheck(arguments,1,"FormData.getAll"),e=i.converters.USVString(e),this.#le.filter((t=>t.name===e)).map((e=>e.value))}has(e){i.brandCheck(this,o);return i.argumentLengthCheck(arguments,1,"FormData.has"),e=i.converters.USVString(e),-1!==this.#le.findIndex((t=>t.name===e))}set(e,t,s=void 0){i.brandCheck(this,o);const r="FormData.set";i.argumentLengthCheck(arguments,2,r),e=i.converters.USVString(e),3===arguments.length||i.is.Blob(t)?(t=i.converters.Blob(t,r,"value"),void 0!==s&&(s=i.converters.USVString(s))):t=i.converters.USVString(t);const n=l(e,t,s),A=this.#le.findIndex((t=>t.name===e));-1!==A?this.#le=[...this.#le.slice(0,A),n,...this.#le.slice(A+1).filter((t=>t.name!==e))]:this.#le.push(n)}[A.inspect.custom](e,t){const s=this.#le.reduce(((e,t)=>(e[t.name]?Array.isArray(e[t.name])?e[t.name].push(t.value):e[t.name]=[e[t.name],t.value]:e[t.name]=t.value,e)),{__proto__:null});t.depth??=e,t.colors??=!0;const r=A.formatWithOptions(t,s);return`FormData ${r.slice(r.indexOf("]")+2)}`}static getFormDataState(e){return e.#le}static setFormDataState(e,t){e.#le=t}}const{getFormDataState:a,setFormDataState:c}=o;function l(e,t,s){if("string"==typeof t);else if(i.is.File(t)||(t=new File([t],"blob",{type:t.type})),void 0!==s){const e={type:t.type,lastModified:t.lastModified};t=new File([t],s,e)}return{name:e,value:t}}Reflect.deleteProperty(o,"getFormDataState"),Reflect.deleteProperty(o,"setFormDataState"),r("FormData",o,a,"name","value"),Object.defineProperties(o.prototype,{append:n,delete:n,get:n,getAll:n,has:n,set:n,[Symbol.toStringTag]:{value:"FormData",configurable:!0}}),i.is.FormData=i.util.MakeTypeAssertion(o),e.exports={FormData:o,makeEntry:l,setFormDataState:c}},2837:e=>{"use strict";const t=Symbol.for("undici.globalOrigin.1");e.exports={getGlobalOrigin:function(){return globalThis[t]},setGlobalOrigin:function(e){if(void 0===e)return void Object.defineProperty(globalThis,t,{value:void 0,writable:!0,enumerable:!1,configurable:!1});const s=new URL(e);if("http:"!==s.protocol&&"https:"!==s.protocol)throw new TypeError(`Only http & https urls are allowed, received ${s.protocol}`);Object.defineProperty(globalThis,t,{value:s,writable:!0,enumerable:!1,configurable:!1})}}},6558:(e,t,s)=>{"use strict";const{kConstruct:r}=s(257),{kEnumerableProperty:n}=s(2858),{iteratorMixin:i,isValidHeaderName:A,isValidHeaderValue:o}=s(6686),{webidl:a}=s(6097),c=s(4589),l=s(7975);function h(e){return 10===e||13===e||9===e||32===e}function g(e){let t=0,s=e.length;for(;s>t&&h(e.charCodeAt(s-1));)--s;for(;s>t&&h(e.charCodeAt(t));)++t;return 0===t&&s===e.length?e:e.substring(t,s)}function d(e,t){if(Array.isArray(t))for(let s=0;s<t.length;++s){const r=t[s];if(2!==r.length)throw a.errors.exception({header:"Headers constructor",message:`expected name/value pair to be length 2, found ${r.length}.`});u(e,r[0],r[1])}else{if("object"!=typeof t||null===t)throw a.errors.conversionFailed({prefix:"Headers constructor",argument:"Argument 1",types:["sequence<sequence<ByteString>>","record<ByteString, ByteString>"]});{const s=Object.keys(t);for(let r=0;r<s.length;++r)u(e,s[r],t[s[r]])}}}function u(e,t,s){if(s=g(s),!A(t))throw a.errors.invalidArgument({prefix:"Headers.append",value:t,type:"header name"});if(!o(s))throw a.errors.invalidArgument({prefix:"Headers.append",value:s,type:"header value"});if("immutable"===C(e))throw new TypeError("immutable");return f(e).append(t,s,!1)}function E(e,t){return e[0]<t[0]?-1:1}class I{cookies=null;sortedMap;headersMap;constructor(e){e instanceof I?(this.headersMap=new Map(e.headersMap),this.sortedMap=e.sortedMap,this.cookies=null===e.cookies?null:[...e.cookies]):(this.headersMap=new Map(e),this.sortedMap=null)}contains(e,t){return this.headersMap.has(t?e:e.toLowerCase())}clear(){this.headersMap.clear(),this.sortedMap=null,this.cookies=null}append(e,t,s){this.sortedMap=null;const r=s?e:e.toLowerCase(),n=this.headersMap.get(r);if(n){const e="cookie"===r?"; ":", ";this.headersMap.set(r,{name:n.name,value:`${n.value}${e}${t}`})}else this.headersMap.set(r,{name:e,value:t});"set-cookie"===r&&(this.cookies??=[]).push(t)}set(e,t,s){this.sortedMap=null;const r=s?e:e.toLowerCase();"set-cookie"===r&&(this.cookies=[t]),this.headersMap.set(r,{name:e,value:t})}delete(e,t){this.sortedMap=null,t||(e=e.toLowerCase()),"set-cookie"===e&&(this.cookies=null),this.headersMap.delete(e)}get(e,t){return this.headersMap.get(t?e:e.toLowerCase())?.value??null}*[Symbol.iterator](){for(const{0:e,1:{value:t}}of this.headersMap)yield[e,t]}get entries(){const e={};if(0!==this.headersMap.size)for(const{name:t,value:s}of this.headersMap.values())e[t]=s;return e}rawValues(){return this.headersMap.values()}get entriesList(){const e=[];if(0!==this.headersMap.size)for(const{0:t,1:{name:s,value:r}}of this.headersMap)if("set-cookie"===t)for(const t of this.cookies)e.push([s,t]);else e.push([s,r]);return e}toSortedArray(){const e=this.headersMap.size,t=new Array(e);if(e<=32){if(0===e)return t;const s=this.headersMap[Symbol.iterator](),r=s.next().value;t[0]=[r[0],r[1].value],c(null!==r[1].value);for(let r,n,i=1,A=0,o=0,a=0,l=0;i<e;++i){for(n=s.next().value,r=t[i]=[n[0],n[1].value],c(null!==r[1]),a=0,o=i;a<o;)l=a+(o-a>>1),t[l][0]<=r[0]?a=l+1:o=l;if(i!==l){for(A=i;A>a;)t[A]=t[--A];t[a]=r}}if(!s.next().done)throw new TypeError("Unreachable");return t}{let e=0;for(const{0:s,1:{value:r}}of this.headersMap)t[e++]=[s,r],c(null!==r);return t.sort(E)}}}class p{#je;#Xe;constructor(e=void 0){a.util.markAsUncloneable(this),e!==r&&(this.#Xe=new I,this.#je="none",void 0!==e&&d(this,e=a.converters.HeadersInit(e,"Headers constructor","init")))}append(e,t){a.brandCheck(this,p),a.argumentLengthCheck(arguments,2,"Headers.append");const s="Headers.append";return u(this,e=a.converters.ByteString(e,s,"name"),t=a.converters.ByteString(t,s,"value"))}delete(e){a.brandCheck(this,p),a.argumentLengthCheck(arguments,1,"Headers.delete");if(e=a.converters.ByteString(e,"Headers.delete","name"),!A(e))throw a.errors.invalidArgument({prefix:"Headers.delete",value:e,type:"header name"});if("immutable"===this.#je)throw new TypeError("immutable");this.#Xe.contains(e,!1)&&this.#Xe.delete(e,!1)}get(e){a.brandCheck(this,p),a.argumentLengthCheck(arguments,1,"Headers.get");const t="Headers.get";if(e=a.converters.ByteString(e,t,"name"),!A(e))throw a.errors.invalidArgument({prefix:t,value:e,type:"header name"});return this.#Xe.get(e,!1)}has(e){a.brandCheck(this,p),a.argumentLengthCheck(arguments,1,"Headers.has");const t="Headers.has";if(e=a.converters.ByteString(e,t,"name"),!A(e))throw a.errors.invalidArgument({prefix:t,value:e,type:"header name"});return this.#Xe.contains(e,!1)}set(e,t){a.brandCheck(this,p),a.argumentLengthCheck(arguments,2,"Headers.set");const s="Headers.set";if(e=a.converters.ByteString(e,s,"name"),t=g(t=a.converters.ByteString(t,s,"value")),!A(e))throw a.errors.invalidArgument({prefix:s,value:e,type:"header name"});if(!o(t))throw a.errors.invalidArgument({prefix:s,value:t,type:"header value"});if("immutable"===this.#je)throw new TypeError("immutable");this.#Xe.set(e,t,!1)}getSetCookie(){a.brandCheck(this,p);const e=this.#Xe.cookies;return e?[...e]:[]}[l.inspect.custom](e,t){return t.depth??=e,`Headers ${l.formatWithOptions(t,this.#Xe.entries)}`}static getHeadersGuard(e){return e.#je}static setHeadersGuard(e,t){e.#je=t}static getHeadersList(e){return e.#Xe}static setHeadersList(e,t){e.#Xe=t}}const{getHeadersGuard:C,setHeadersGuard:B,getHeadersList:f,setHeadersList:Q}=p;Reflect.deleteProperty(p,"getHeadersGuard"),Reflect.deleteProperty(p,"setHeadersGuard"),Reflect.deleteProperty(p,"getHeadersList"),Reflect.deleteProperty(p,"setHeadersList"),i("Headers",p,(function(e){const t=f(e);if(!t)return[];if(t.sortedMap)return t.sortedMap;const s=[],r=t.toSortedArray(),n=t.cookies;if(null===n||1===n.length)return t.sortedMap=r;for(let e=0;e<r.length;++e){const{0:t,1:i}=r[e];if("set-cookie"===t)for(let e=0;e<n.length;++e)s.push([t,n[e]]);else s.push([t,i])}return t.sortedMap=s}),0,1),Object.defineProperties(p.prototype,{append:n,delete:n,get:n,has:n,set:n,getSetCookie:n,[Symbol.toStringTag]:{value:"Headers",configurable:!0},[l.inspect.custom]:{enumerable:!1}}),a.converters.HeadersInit=function(e,t,s){if(a.util.Type(e)===a.util.Types.OBJECT){const r=Reflect.get(e,Symbol.iterator);if(!l.types.isProxy(e)&&r===p.prototype.entries)try{return f(e).entriesList}catch{}return"function"==typeof r?a.converters["sequence<sequence<ByteString>>"](e,t,s,r.bind(e)):a.converters["record<ByteString, ByteString>"](e,t,s)}throw a.errors.conversionFailed({prefix:"Headers constructor",argument:"Argument 1",types:["sequence<sequence<ByteString>>","record<ByteString, ByteString>"]})},e.exports={fill:d,compareHeaderName:E,Headers:p,HeadersList:I,getHeadersGuard:C,setHeadersGuard:B,setHeadersList:Q,getHeadersList:f}},7388:(e,t,s)=>{"use strict";const{makeNetworkError:r,makeAppropriateNetworkError:n,filterResponse:i,makeResponse:A,fromInnerResponse:o,getResponseState:a}=s(4821),{HeadersList:c}=s(6558),{Request:l,cloneRequest:h,getRequestDispatcher:g,getRequestState:d}=s(4609),u=s(8522),{makePolicyContainer:E,clonePolicyContainer:I,requestBadPort:p,TAOCheck:C,appendRequestOriginHeader:B,responseLocationURL:f,requestCurrentURL:Q,setRequestReferrerPolicyOnRedirect:m,tryUpgradeRequestToAPotentiallyTrustworthyURL:y,createOpaqueTimingInfo:w,appendFetchMetadata:S,corsCheck:D,crossOriginResourcePolicyCheck:b,determineRequestsReferrer:v,coarsenedSharedCurrentTime:R,sameOrigin:N,isCancelled:k,isAborted:T,isErrorLike:F,fullyReadBody:M,readableStreamClose:U,isomorphicEncode:L,urlIsLocal:P,urlIsHttpHttpsScheme:x,urlHasHttpsScheme:H,clampAndCoarsenConnectionTimingInfo:Y,simpleRangeHeaderValue:V,buildContentRange:O,createInflate:G,extractMimeType:J}=s(6686),W=s(4589),{safelyExtractBody:_,extractBody:$}=s(2530),{redirectStatusSet:q,nullBodyStatus:z,safeMethodsSet:j,requestBodyHeader:X,subresourceSet:Z}=s(9441),K=s(8474),{Readable:ee,pipeline:te,finished:se,isErrored:re,isReadable:ne}=s(7075),{addAbortListener:ie,bufferToLowerCasedHeaderName:Ae}=s(2858),{dataURLProcessor:oe,serializeAMimeType:ae,minimizeSupportedMimeType:ce}=s(9934),{getGlobalDispatcher:le}=s(9879),{webidl:he}=s(6097),{STATUS_CODES:ge}=s(7067),{bytesMatch:de}=s(7420),{createDeferredPromise:ue}=s(9250),Ee="function"==typeof u.createZstdDecompress,Ie=["GET","HEAD"],pe="undefined"!=typeof __UNDICI_IS_NODE__||"undefined"!=typeof esbuildDetection?"node":"undici";let Ce;class Be extends K{constructor(e){super(),this.dispatcher=e,this.connection=null,this.dump=!1,this.state="ongoing"}terminate(e){"ongoing"===this.state&&(this.state="terminated",this.connection?.destroy(e),this.emit("terminated",e))}abort(e){"ongoing"===this.state&&(this.state="aborted",e||(e=new DOMException("The operation was aborted.","AbortError")),this.serializedAbortReason=e,this.connection?.destroy(e),this.emit("terminated",e))}}function fe(e){Qe(e,"fetch")}function Qe(e,t="other"){if("error"===e.type&&e.aborted)return;if(!e.urlList?.length)return;const s=e.urlList[0];let r=e.timingInfo,n=e.cacheState;x(s)&&null!==r&&(e.timingAllowPassed||(r=w({startTime:r.startTime}),n=""),r.endTime=R(),e.timingInfo=r,me(r,s.href,t,globalThis,n,"",e.status))}const me=performance.markResourceTiming;function ye(e,t,s,r){if(e&&e.reject(r),null!=t.body?.stream&&ne(t.body.stream)&&t.body.stream.cancel(r).catch((e=>{if("ERR_INVALID_STATE"!==e.code)throw e})),null==s)return;const n=a(s);null!=n.body?.stream&&ne(n.body.stream)&&n.body.stream.cancel(r).catch((e=>{if("ERR_INVALID_STATE"!==e.code)throw e}))}function we({request:e,processRequestBodyChunkLength:t,processRequestEndOfBody:s,processResponse:r,processResponseEndOfBody:n,processResponseConsumeBody:i,useParallelQueue:A=!1,dispatcher:o=le()}){W(o);let a=null,c=!1;null!=e.client&&(a=e.client.globalObject,c=e.client.crossOriginIsolatedCapability);const l=R(c),h=w({startTime:l}),g={controller:new Be(o),request:e,timingInfo:h,processRequestBodyChunkLength:t,processRequestEndOfBody:s,processResponse:r,processResponseConsumeBody:i,processResponseEndOfBody:n,taskDestination:a,crossOriginIsolatedCapability:c};if(W(!e.body||e.body.stream),"client"===e.window&&(e.window="Window"===e.client?.globalObject?.constructor?.name?e.client:"no-window"),"client"===e.origin&&(e.origin=e.client.origin),"client"===e.policyContainer&&(null!=e.client?e.policyContainer=I(e.client.policyContainer):e.policyContainer=E()),!e.headersList.contains("accept",!0)){const t="*/*";e.headersList.append("accept",t,!0)}return e.headersList.contains("accept-language",!0)||e.headersList.append("accept-language","*",!0),e.priority,Z.has(e.destination),Se(g,!1),g.controller}async function Se(e,t){try{const s=e.request;let n=null;if(s.localURLsOnly&&!P(Q(s))&&(n=r("local URLs only")),y(s),"blocked"===p(s)&&(n=r("bad port")),""===s.referrerPolicy&&(s.referrerPolicy=s.policyContainer.referrerPolicy),"no-referrer"!==s.referrer&&(s.referrer=v(s)),null===n){const t=Q(s);N(t,s.url)&&"basic"===s.responseTainting||"data:"===t.protocol||"navigate"===s.mode||"websocket"===s.mode?(s.responseTainting="basic",n=await De(e)):"same-origin"===s.mode?n=r('request mode cannot be "same-origin"'):"no-cors"===s.mode?"follow"!==s.redirect?n=r('redirect mode cannot be "follow" for "no-cors" request'):(s.responseTainting="opaque",n=await De(e)):x(Q(s))?(s.responseTainting="cors",n=await Re(e)):n=r("URL scheme must be a HTTP(S) scheme")}if(t)return n;0===n.status||n.internalResponse||(s.responseTainting,"basic"===s.responseTainting?n=i(n,"basic"):"cors"===s.responseTainting?n=i(n,"cors"):"opaque"===s.responseTainting?n=i(n,"opaque"):W(!1));let A=0===n.status?n:n.internalResponse;if(0===A.urlList.length&&A.urlList.push(...s.urlList),s.timingAllowFailed||(n.timingAllowPassed=!0),"opaque"===n.type&&206===A.status&&A.rangeRequested&&!s.headers.contains("range",!0)&&(n=A=r()),0===n.status||"HEAD"!==s.method&&"CONNECT"!==s.method&&!z.includes(A.status)||(A.body=null,e.controller.dump=!0),s.integrity){const t=t=>ve(e,r(t));if("opaque"===s.responseTainting||null==n.body)return void t(n.error);const i=r=>{de(r,s.integrity)?(n.body=_(r)[0],ve(e,n)):t("integrity mismatch")};M(n.body,i,t)}else ve(e,n)}catch(t){e.controller.terminate(t)}}function De(e){if(k(e)&&0===e.request.redirectCount)return Promise.resolve(n(e));const{request:t}=e,{protocol:i}=Q(t);switch(i){case"about:":return Promise.resolve(r("about scheme is not supported"));case"blob:":{Ce||(Ce=s(4573).resolveObjectURL);const e=Q(t);if(0!==e.search.length)return Promise.resolve(r("NetworkError when attempting to fetch resource."));const n=Ce(e.toString());if("GET"!==t.method||!he.is.Blob(n))return Promise.resolve(r("invalid method"));const i=A(),o=n.size,a=L(`${o}`),c=n.type;if(t.headersList.contains("range",!0)){i.rangeRequested=!0;const e=t.headersList.get("range",!0),s=V(e,!0);if("failure"===s)return Promise.resolve(r("failed to fetch the data URL"));let{rangeStartValue:A,rangeEndValue:a}=s;if(null===A)A=o-a,a=A+a-1;else{if(A>=o)return Promise.resolve(r("Range start is greater than the blob's size."));(null===a||a>=o)&&(a=o-1)}const l=n.slice(A,a,c),h=$(l);i.body=h[0];const g=L(`${l.size}`),d=O(A,a,o);i.status=206,i.statusText="Partial Content",i.headersList.set("content-length",g,!0),i.headersList.set("content-type",c,!0),i.headersList.set("content-range",d,!0)}else{const e=$(n);i.statusText="OK",i.body=e[0],i.headersList.set("content-length",a,!0),i.headersList.set("content-type",c,!0)}return Promise.resolve(i)}case"data:":{const e=Q(t),s=oe(e);if("failure"===s)return Promise.resolve(r("failed to fetch the data URL"));const n=ae(s.mimeType);return Promise.resolve(A({statusText:"OK",headersList:[["content-type",{name:"Content-Type",value:n}]],body:_(s.body)[0]}))}case"file:":return Promise.resolve(r("not implemented... yet..."));case"http:":case"https:":return Re(e).catch((e=>r(e)));default:return Promise.resolve(r("unknown scheme"))}}function be(e,t){e.request.done=!0,null!=e.processResponseDone&&queueMicrotask((()=>e.processResponseDone(t)))}function ve(e,t){let s=e.timingInfo;const r=()=>{const r=Date.now();"document"===e.request.destination&&(e.controller.fullTimingInfo=s),e.controller.reportTimingSteps=()=>{if(!x(e.request.url))return;s.endTime=r;let n=t.cacheState;const i=t.bodyInfo;t.timingAllowPassed||(s=w(s),n="");let A=0;if("navigator"!==e.request.mode||!t.hasCrossOriginRedirects){A=t.status;const e=J(t.headersList);"failure"!==e&&(i.contentType=ce(e))}null!=e.request.initiatorType&&me(s,e.request.url.href,e.request.initiatorType,globalThis,n,i,A)};queueMicrotask((()=>(e.request.done=!0,null!=e.processResponseEndOfBody&&queueMicrotask((()=>e.processResponseEndOfBody(t))),void(null!=e.request.initiatorType&&e.controller.reportTimingSteps()))))};null!=e.processResponse&&queueMicrotask((()=>{e.processResponse(t),e.processResponse=null}));const n="error"===t.type?t:t.internalResponse??t;null==n.body?r():se(n.body.stream,(()=>{r()}))}async function Re(e){const t=e.request;let s=null,n=null;const i=e.timingInfo;if(t.serviceWorkers,null===s){if("follow"===t.redirect&&(t.serviceWorkers="none"),n=s=await Ne(e),"cors"===t.responseTainting&&"failure"===D(t,s))return r("cors failure");"failure"===C(t,s)&&(t.timingAllowFailed=!0)}return"opaque"!==t.responseTainting&&"opaque"!==s.type||"blocked"!==b(t.origin,t.client,t.destination,n)?(q.has(n.status)&&("manual"!==t.redirect&&e.controller.connection.destroy(void 0,!1),"error"===t.redirect?s=r("unexpected redirect"):"manual"===t.redirect?s=n:"follow"===t.redirect?s=await function(e,t){const s=e.request,n=t.internalResponse?t.internalResponse:t;let i;try{if(i=f(n,Q(s).hash),null==i)return t}catch(e){return Promise.resolve(r(e))}if(!x(i))return Promise.resolve(r("URL scheme must be a HTTP(S) scheme"));if(20===s.redirectCount)return Promise.resolve(r("redirect count exceeded"));if(s.redirectCount+=1,"cors"===s.mode&&(i.username||i.password)&&!N(s,i))return Promise.resolve(r('cross origin not allowed for request mode "cors"'));if("cors"===s.responseTainting&&(i.username||i.password))return Promise.resolve(r('URL cannot contain credentials for request mode "cors"'));if(303!==n.status&&null!=s.body&&null==s.body.source)return Promise.resolve(r());if([301,302].includes(n.status)&&"POST"===s.method||303===n.status&&!Ie.includes(s.method)){s.method="GET",s.body=null;for(const e of X)s.headersList.delete(e)}N(Q(s),i)||(s.headersList.delete("authorization",!0),s.headersList.delete("proxy-authorization",!0),s.headersList.delete("cookie",!0),s.headersList.delete("host",!0));null!=s.body&&(W(null!=s.body.source),s.body=_(s.body.source)[0]);const A=e.timingInfo;A.redirectEndTime=A.postRedirectStartTime=R(e.crossOriginIsolatedCapability),0===A.redirectStartTime&&(A.redirectStartTime=A.startTime);return s.urlList.push(i),m(s,n),Se(e,!0)}(e,s):W(!1)),s.timingInfo=i,s):r("blocked")}async function Ne(e,t=!1,s=!1){const i=e.request;let o=null,a=null,l=null;"no-window"===i.window&&"error"===i.redirect?(o=e,a=i):(a=h(i),o={...e},o.request=a);const g="include"===i.credentials||"same-origin"===i.credentials&&"basic"===i.responseTainting,d=a.body?a.body.length:null;let E=null;if(null==a.body&&["POST","PUT"].includes(a.method)&&(E="0"),null!=d&&(E=L(`${d}`)),null!=E&&a.headersList.append("content-length",E,!0),null!=d&&a.keepalive,he.is.URL(a.referrer)&&a.headersList.append("referer",L(a.referrer.href),!0),B(a),S(a),a.headersList.contains("user-agent",!0)||a.headersList.append("user-agent",pe,!0),"default"===a.cache&&(a.headersList.contains("if-modified-since",!0)||a.headersList.contains("if-none-match",!0)||a.headersList.contains("if-unmodified-since",!0)||a.headersList.contains("if-match",!0)||a.headersList.contains("if-range",!0))&&(a.cache="no-store"),"no-cache"!==a.cache||a.preventNoCacheCacheControlHeaderModification||a.headersList.contains("cache-control",!0)||a.headersList.append("cache-control","max-age=0",!0),"no-store"!==a.cache&&"reload"!==a.cache||(a.headersList.contains("pragma",!0)||a.headersList.append("pragma","no-cache",!0),a.headersList.contains("cache-control",!0)||a.headersList.append("cache-control","no-cache",!0)),a.headersList.contains("range",!0)&&a.headersList.append("accept-encoding","identity",!0),a.headersList.contains("accept-encoding",!0)||(H(Q(a))?a.headersList.append("accept-encoding","br, gzip, deflate",!0):a.headersList.append("accept-encoding","gzip, deflate",!0)),a.headersList.delete("host",!0),a.cache="no-store","no-store"!==a.cache&&a.cache,null==l){if("only-if-cached"===a.cache)return r("only if cached");const e=await async function(e){W(!e.controller.connection||e.controller.connection.destroyed),e.controller.connection={abort:null,destroyed:!1,destroy(e,t=!0){this.destroyed||(this.destroyed=!0,t&&this.abort?.(e??new DOMException("The operation was aborted.","AbortError")))}};const t=e.request;let s=null;const i=e.timingInfo,o=null;null==o&&(t.cache="no-store");t.mode;let a=null;if(null==t.body&&e.processRequestEndOfBody)queueMicrotask((()=>e.processRequestEndOfBody()));else if(null!=t.body){const s=async function*(t){k(e)||(yield t,e.processRequestBodyChunkLength?.(t.byteLength))},r=()=>{k(e)||e.processRequestEndOfBody&&e.processRequestEndOfBody()},n=t=>{k(e)||("AbortError"===t.name?e.controller.abort():e.controller.terminate(t))};a=async function*(){try{for await(const e of t.body.stream)yield*s(e);r()}catch(e){n(e)}}()}try{const{body:t,status:r,statusText:n,headersList:i,socket:o}=await E({body:a});if(o)s=A({status:r,statusText:n,headersList:i,socket:o});else{const o=t[Symbol.asyncIterator]();e.controller.next=()=>o.next(),s=A({status:r,statusText:n,headersList:i})}}catch(t){return"AbortError"===t.name?(e.controller.connection.destroy(),n(e,t)):r(t)}const l=()=>e.controller.resume(),h=t=>{k(e)||e.controller.abort(t)},g=new ReadableStream({start(t){e.controller.controller=t},pull:l,cancel:h,type:"bytes"});s.body={stream:g,source:null,length:null},e.controller.resume||e.controller.on("terminated",d);function d(t){T(e)?(s.aborted=!0,ne(g)&&e.controller.controller.error(e.controller.serializedAbortReason)):ne(g)&&e.controller.controller.error(new TypeError("terminated",{cause:F(t)?t:void 0})),e.controller.connection.destroy()}return e.controller.resume=async()=>{for(;;){let t,r;try{const{done:s,value:r}=await e.controller.next();if(T(e))break;t=s?void 0:r}catch(s){e.controller.ended&&!i.encodedBodySize?t=void 0:(t=s,r=!0)}if(void 0===t)return U(e.controller.controller),void be(e,s);if(i.decodedBodySize+=t?.byteLength??0,r)return void e.controller.terminate(t);const n=new Uint8Array(t);if(n.byteLength&&e.controller.controller.enqueue(n),re(g))return void e.controller.terminate();if(e.controller.controller.desiredSize<=0)return}},s;function E({body:s}){const r=Q(t),n=e.controller.dispatcher;return new Promise(((A,o)=>n.dispatch({path:r.pathname+r.search,origin:r.origin,method:t.method,body:n.isMockActive?t.body&&(t.body.source||t.body.stream):s,headers:t.headersList.entries,maxRedirections:0,upgrade:"websocket"===t.mode?"websocket":void 0},{body:null,abort:null,onConnect(t){const{connection:s}=e.controller;i.finalConnectionTimingInfo=Y(void 0,i.postRedirectStartTime,e.crossOriginIsolatedCapability),s.destroyed?t(new DOMException("The operation was aborted.","AbortError")):(e.controller.on("terminated",t),this.abort=s.abort=t),i.finalNetworkRequestStartTime=R(e.crossOriginIsolatedCapability)},onResponseStarted(){i.finalNetworkResponseStartTime=R(e.crossOriginIsolatedCapability)},onHeaders(e,s,r,n){if(e<200)return!1;const i=new c;for(let e=0;e<s.length;e+=2)i.append(Ae(s[e]),s[e+1].toString("latin1"),!0);const o=i.get("location",!0);this.body=new ee({read:r});const a=o&&"follow"===t.redirect&&q.has(e),l=[];if("HEAD"!==t.method&&"CONNECT"!==t.method&&!z.includes(e)&&!a){const e=i.get("content-encoding",!0),t=e?e.toLowerCase().split(","):[];for(let e=t.length-1;e>=0;--e){const s=t[e].trim();if("x-gzip"===s||"gzip"===s)l.push(u.createGunzip({flush:u.constants.Z_SYNC_FLUSH,finishFlush:u.constants.Z_SYNC_FLUSH}));else if("deflate"===s)l.push(G({flush:u.constants.Z_SYNC_FLUSH,finishFlush:u.constants.Z_SYNC_FLUSH}));else if("br"===s)l.push(u.createBrotliDecompress({flush:u.constants.BROTLI_OPERATION_FLUSH,finishFlush:u.constants.BROTLI_OPERATION_FLUSH}));else{if("zstd"!==s||!Ee){l.length=0;break}l.push(u.createZstdDecompress({flush:u.constants.ZSTD_e_continue,finishFlush:u.constants.ZSTD_e_end}))}}}const h=this.onError.bind(this);return A({status:e,statusText:n,headersList:i,body:l.length?te(this.body,...l,(e=>{e&&this.onError(e)})).on("error",h):this.body.on("error",h)}),!0},onData(t){if(e.controller.dump)return;const s=t;return i.encodedBodySize+=s.byteLength,this.body.push(s)},onComplete(){this.abort&&e.controller.off("terminated",this.abort),e.controller.ended=!0,this.body.push(null)},onError(t){this.abort&&e.controller.off("terminated",this.abort),this.body?.destroy(t),e.controller.terminate(t),o(t)},onUpgrade(e,t,s){if(101!==e)return;const r=new c;for(let e=0;e<t.length;e+=2)r.append(Ae(t[e]),t[e+1].toString("latin1"),!0);return A({status:e,statusText:ge[e],headersList:r,socket:s}),!0}})))}}(o,g,s);!j.has(a.method)&&e.status>=200&&e.status,null==l&&(l=e)}if(l.urlList=[...a.urlList],a.headersList.contains("range",!0)&&(l.rangeRequested=!0),l.requestIncludesCredentials=g,407===l.status)return"no-window"===i.window?r():k(e)?n(e):r("proxy authentication required");if(421===l.status&&!s&&(null==i.body||null!=i.body.source)){if(k(e))return n(e);e.controller.connection.destroy(),l=await Ne(e,t,!0)}return l}e.exports={fetch:function(e,t=void 0){he.argumentLengthCheck(arguments,1,"globalThis.fetch");let s,r=ue();try{s=new l(e,t)}catch(e){return r.reject(e),r.promise}const n=d(s);if(s.signal.aborted)return ye(r,n,null,s.signal.reason),r.promise;const i=n.client.globalObject;"ServiceWorkerGlobalScope"===i?.constructor?.name&&(n.serviceWorkers="none");let A=null,a=!1,c=null;return ie(s.signal,(()=>{a=!0,W(null!=c),c.abort(s.signal.reason);const e=A?.deref();ye(r,n,e,s.signal.reason)})),c=we({request:n,processResponseEndOfBody:fe,processResponse:e=>{a||(e.aborted?ye(r,n,A,c.serializedAbortReason):"error"!==e.type?(A=new WeakRef(o(e,"immutable")),r.resolve(A.deref()),r=null):r.reject(new TypeError("fetch failed",{cause:e.error})))},dispatcher:g(s)}),r.promise},Fetch:Be,fetching:we,finalizeAndReportTiming:Qe}},4609:(e,t,s)=>{"use strict";const{extractBody:r,mixinBody:n,cloneBody:i,bodyUnusable:A}=s(2530),{Headers:o,fill:a,HeadersList:c,setHeadersGuard:l,getHeadersGuard:h,setHeadersList:g,getHeadersList:d}=s(6558),u=s(2858),E=s(7975),{isValidHTTPToken:I,sameOrigin:p,environmentSettingsObject:C}=s(6686),{forbiddenMethodsSet:B,corsSafeListedMethodsSet:f,referrerPolicy:Q,requestRedirect:m,requestMode:y,requestCredentials:w,requestCache:S,requestDuplex:D}=s(9441),{kEnumerableProperty:b,normalizedMethodRecordsBase:v,normalizedMethodRecords:R}=u,{webidl:N}=s(6097),{URLSerializer:k}=s(9934),{kConstruct:T}=s(257),F=s(4589),{getMaxListeners:M,setMaxListeners:U,defaultMaxListeners:L}=s(8474),P=Symbol("abortController"),x=new FinalizationRegistry((({signal:e,abort:t})=>{e.removeEventListener("abort",t)})),H=new WeakMap;let Y;try{Y=M((new AbortController).signal)>0}catch{Y=!1}function V(e){return function t(){const s=e.deref();if(void 0!==s){x.unregister(t),this.removeEventListener("abort",t),s.abort(this.reason);const e=H.get(s.signal);if(void 0!==e){if(0!==e.size){for(const t of e){const e=t.deref();void 0!==e&&e.abort(this.reason)}e.clear()}H.delete(s.signal)}}}}let O=!1;class G{#Ze;#$e;#Be;#le;constructor(e,t=void 0){if(N.util.markAsUncloneable(this),e===T)return;N.argumentLengthCheck(arguments,1,"Request constructor"),e=N.converters.RequestInfo(e),t=N.converters.RequestInit(t);let s=null,n=null;const i=C.settingsObject.baseUrl;let h=null;if("string"==typeof e){let r;this.#$e=t.dispatcher;try{r=new URL(e,i)}catch(t){throw new TypeError("Failed to parse URL from "+e,{cause:t})}if(r.username||r.password)throw new TypeError("Request cannot be constructed from a URL that includes credentials: "+e);s=j({urlList:[r]}),n="cors"}else F(N.is.Request(e)),s=e.#le,h=e.#Ze,this.#$e=t.dispatcher||e.#$e;const E=C.settingsObject.origin;let Q="client";if("EnvironmentSettingsObject"===s.window?.constructor?.name&&p(s.window,E)&&(Q=s.window),null!=t.window)throw new TypeError(`'window' option '${Q}' must be null`);"window"in t&&(Q="no-window"),s=j({method:s.method,headersList:s.headersList,unsafeRequest:s.unsafeRequest,client:C.settingsObject,window:Q,priority:s.priority,origin:s.origin,referrer:s.referrer,referrerPolicy:s.referrerPolicy,mode:s.mode,credentials:s.credentials,cache:s.cache,redirect:s.redirect,integrity:s.integrity,keepalive:s.keepalive,reloadNavigation:s.reloadNavigation,historyNavigation:s.historyNavigation,urlList:[...s.urlList]});const m=0!==Object.keys(t).length;if(m&&("navigate"===s.mode&&(s.mode="same-origin"),s.reloadNavigation=!1,s.historyNavigation=!1,s.origin="client",s.referrer="client",s.referrerPolicy="",s.url=s.urlList[s.urlList.length-1],s.urlList=[s.url]),void 0!==t.referrer){const e=t.referrer;if(""===e)s.referrer="no-referrer";else{let t;try{t=new URL(e,i)}catch(t){throw new TypeError(`Referrer "${e}" is not a valid URL.`,{cause:t})}"about:"===t.protocol&&"client"===t.hostname||E&&!p(t,C.settingsObject.baseUrl)?s.referrer="client":s.referrer=t}}let y;if(void 0!==t.referrerPolicy&&(s.referrerPolicy=t.referrerPolicy),y=void 0!==t.mode?t.mode:n,"navigate"===y)throw N.errors.exception({header:"Request constructor",message:"invalid request mode navigate."});if(null!=y&&(s.mode=y),void 0!==t.credentials&&(s.credentials=t.credentials),void 0!==t.cache&&(s.cache=t.cache),"only-if-cached"===s.cache&&"same-origin"!==s.mode)throw new TypeError("'only-if-cached' can be set only with 'same-origin' mode");if(void 0!==t.redirect&&(s.redirect=t.redirect),null!=t.integrity&&(s.integrity=String(t.integrity)),void 0!==t.keepalive&&(s.keepalive=Boolean(t.keepalive)),void 0!==t.method){let e=t.method;const r=R[e];if(void 0!==r)s.method=r;else{if(!I(e))throw new TypeError(`'${e}' is not a valid HTTP method.`);const t=e.toUpperCase();if(B.has(t))throw new TypeError(`'${e}' HTTP method is unsupported.`);e=v[t]??e,s.method=e}O||"patch"!==s.method||(process.emitWarning("Using `patch` is highly likely to result in a `405 Method Not Allowed`. `PATCH` is much more likely to succeed.",{code:"UNDICI-FETCH-patch"}),O=!0)}void 0!==t.signal&&(h=t.signal),this.#le=s;const w=new AbortController;if(this.#Ze=w.signal,null!=h)if(h.aborted)w.abort(h.reason);else{this[P]=w;const e=V(new WeakRef(w));Y&&M(h)===L&&U(1500,h),u.addAbortListener(h,e),x.register(w,{signal:h,abort:e},e)}if(this.#Be=new o(T),g(this.#Be,s.headersList),l(this.#Be,"request"),"no-cors"===y){if(!f.has(s.method))throw new TypeError(`'${s.method} is unsupported in no-cors mode.`);l(this.#Be,"request-no-cors")}if(m){const e=d(this.#Be),s=void 0!==t.headers?t.headers:new c(e);if(e.clear(),s instanceof c){for(const{name:t,value:r}of s.rawValues())e.append(t,r,!1);e.cookies=s.cookies}else a(this.#Be,s)}const S=N.is.Request(e)?e.#le.body:null;if(!(null==t.body&&null==S||"GET"!==s.method&&"HEAD"!==s.method))throw new TypeError("Request with GET/HEAD method cannot have body.");let D=null;if(null!=t.body){const[e,n]=r(t.body,s.keepalive);D=e,n&&!d(this.#Be).contains("content-type",!0)&&this.#Be.append("content-type",n,!0)}const b=D??S;if(null!=b&&null==b.source){if(null!=D&&null==t.duplex)throw new TypeError("RequestInit: duplex option is required when sending a body.");if("same-origin"!==s.mode&&"cors"!==s.mode)throw new TypeError('If request is made from ReadableStream, mode should be "same-origin" or "cors"');s.useCORSPreflightFlag=!0}let k=b;if(null==D&&null!=S){if(A(e.#le))throw new TypeError("Cannot construct a Request with a Request object that has already been used.");const t=new TransformStream;S.stream.pipeThrough(t),k={source:S.source,length:S.length,stream:t.readable}}this.#le.body=k}get method(){return N.brandCheck(this,G),this.#le.method}get url(){return N.brandCheck(this,G),k(this.#le.url)}get headers(){return N.brandCheck(this,G),this.#Be}get destination(){return N.brandCheck(this,G),this.#le.destination}get referrer(){return N.brandCheck(this,G),"no-referrer"===this.#le.referrer?"":"client"===this.#le.referrer?"about:client":this.#le.referrer.toString()}get referrerPolicy(){return N.brandCheck(this,G),this.#le.referrerPolicy}get mode(){return N.brandCheck(this,G),this.#le.mode}get credentials(){return N.brandCheck(this,G),this.#le.credentials}get cache(){return N.brandCheck(this,G),this.#le.cache}get redirect(){return N.brandCheck(this,G),this.#le.redirect}get integrity(){return N.brandCheck(this,G),this.#le.integrity}get keepalive(){return N.brandCheck(this,G),this.#le.keepalive}get isReloadNavigation(){return N.brandCheck(this,G),this.#le.reloadNavigation}get isHistoryNavigation(){return N.brandCheck(this,G),this.#le.historyNavigation}get signal(){return N.brandCheck(this,G),this.#Ze}get body(){return N.brandCheck(this,G),this.#le.body?this.#le.body.stream:null}get bodyUsed(){return N.brandCheck(this,G),!!this.#le.body&&u.isDisturbed(this.#le.body.stream)}get duplex(){return N.brandCheck(this,G),"half"}clone(){if(N.brandCheck(this,G),A(this.#le))throw new TypeError("unusable");const e=X(this.#le),t=new AbortController;if(this.signal.aborted)t.abort(this.signal.reason);else{let e=H.get(this.signal);void 0===e&&(e=new Set,H.set(this.signal,e));const s=new WeakRef(t);e.add(s),u.addAbortListener(t.signal,V(s))}return Z(e,this.#$e,t.signal,h(this.#Be))}[E.inspect.custom](e,t){null===t.depth&&(t.depth=2),t.colors??=!0;const s={method:this.method,url:this.url,headers:this.headers,destination:this.destination,referrer:this.referrer,referrerPolicy:this.referrerPolicy,mode:this.mode,credentials:this.credentials,cache:this.cache,redirect:this.redirect,integrity:this.integrity,keepalive:this.keepalive,isReloadNavigation:this.isReloadNavigation,isHistoryNavigation:this.isHistoryNavigation,signal:this.signal};return`Request ${E.formatWithOptions(t,s)}`}static setRequestSignal(e,t){return e.#Ze=t,e}static getRequestDispatcher(e){return e.#$e}static setRequestDispatcher(e,t){e.#$e=t}static setRequestHeaders(e,t){e.#Be=t}static getRequestState(e){return e.#le}static setRequestState(e,t){e.#le=t}}const{setRequestSignal:J,getRequestDispatcher:W,setRequestDispatcher:_,setRequestHeaders:$,getRequestState:q,setRequestState:z}=G;function j(e){return{method:e.method??"GET",localURLsOnly:e.localURLsOnly??!1,unsafeRequest:e.unsafeRequest??!1,body:e.body??null,client:e.client??null,reservedClient:e.reservedClient??null,replacesClientId:e.replacesClientId??"",window:e.window??"client",keepalive:e.keepalive??!1,serviceWorkers:e.serviceWorkers??"all",initiator:e.initiator??"",destination:e.destination??"",priority:e.priority??null,origin:e.origin??"client",policyContainer:e.policyContainer??"client",referrer:e.referrer??"client",referrerPolicy:e.referrerPolicy??"",mode:e.mode??"no-cors",useCORSPreflightFlag:e.useCORSPreflightFlag??!1,credentials:e.credentials??"same-origin",useCredentials:e.useCredentials??!1,cache:e.cache??"default",redirect:e.redirect??"follow",integrity:e.integrity??"",cryptoGraphicsNonceMetadata:e.cryptoGraphicsNonceMetadata??"",parserMetadata:e.parserMetadata??"",reloadNavigation:e.reloadNavigation??!1,historyNavigation:e.historyNavigation??!1,userActivation:e.userActivation??!1,taintedOrigin:e.taintedOrigin??!1,redirectCount:e.redirectCount??0,responseTainting:e.responseTainting??"basic",preventNoCacheCacheControlHeaderModification:e.preventNoCacheCacheControlHeaderModification??!1,done:e.done??!1,timingAllowFailed:e.timingAllowFailed??!1,urlList:e.urlList,url:e.urlList[0],headersList:e.headersList?new c(e.headersList):new c}}function X(e){const t=j({...e,body:null});return null!=e.body&&(t.body=i(e.body)),t}function Z(e,t,s,r){const n=new G(T);z(n,e),_(n,t),J(n,s);const i=new o(T);return $(n,i),g(i,e.headersList),l(i,r),n}Reflect.deleteProperty(G,"setRequestSignal"),Reflect.deleteProperty(G,"getRequestDispatcher"),Reflect.deleteProperty(G,"setRequestDispatcher"),Reflect.deleteProperty(G,"setRequestHeaders"),Reflect.deleteProperty(G,"getRequestState"),Reflect.deleteProperty(G,"setRequestState"),n(G,q),Object.defineProperties(G.prototype,{method:b,url:b,headers:b,redirect:b,clone:b,signal:b,duplex:b,destination:b,body:b,bodyUsed:b,isHistoryNavigation:b,isReloadNavigation:b,keepalive:b,integrity:b,cache:b,credentials:b,attribute:b,referrerPolicy:b,referrer:b,mode:b,[Symbol.toStringTag]:{value:"Request",configurable:!0}}),N.is.Request=N.util.MakeTypeAssertion(G),N.converters.RequestInfo=function(e){return"string"==typeof e?N.converters.USVString(e):N.is.Request(e)?e:N.converters.USVString(e)},N.converters.RequestInit=N.dictionaryConverter([{key:"method",converter:N.converters.ByteString},{key:"headers",converter:N.converters.HeadersInit},{key:"body",converter:N.nullableConverter(N.converters.BodyInit)},{key:"referrer",converter:N.converters.USVString},{key:"referrerPolicy",converter:N.converters.DOMString,allowedValues:Q},{key:"mode",converter:N.converters.DOMString,allowedValues:y},{key:"credentials",converter:N.converters.DOMString,allowedValues:w},{key:"cache",converter:N.converters.DOMString,allowedValues:S},{key:"redirect",converter:N.converters.DOMString,allowedValues:m},{key:"integrity",converter:N.converters.DOMString},{key:"keepalive",converter:N.converters.boolean},{key:"signal",converter:N.nullableConverter((e=>N.converters.AbortSignal(e,"RequestInit","signal")))},{key:"window",converter:N.converters.any},{key:"duplex",converter:N.converters.DOMString,allowedValues:D},{key:"dispatcher",converter:N.converters.any}]),e.exports={Request:G,makeRequest:j,fromInnerRequest:Z,cloneRequest:X,getRequestDispatcher:W,getRequestState:q}},4821:(e,t,s)=>{"use strict";const{Headers:r,HeadersList:n,fill:i,getHeadersGuard:A,setHeadersGuard:o,setHeadersList:a}=s(6558),{extractBody:c,cloneBody:l,mixinBody:h,streamRegistry:g,bodyUnusable:d}=s(2530),u=s(2858),E=s(7975),{kEnumerableProperty:I}=u,{isValidReasonPhrase:p,isCancelled:C,isAborted:B,serializeJavascriptValueToJSONString:f,isErrorLike:Q,isomorphicEncode:m,environmentSettingsObject:y}=s(6686),{redirectStatusSet:w,nullBodyStatus:S}=s(9441),{webidl:D}=s(6097),{URLSerializer:b}=s(9934),{kConstruct:v}=s(257),R=s(4589),N=new TextEncoder("utf-8");class k{#Be;#le;static error(){return O(x(),"immutable")}static json(e,t=void 0){D.argumentLengthCheck(arguments,1,"Response.json"),null!==t&&(t=D.converters.ResponseInit(t));const s=N.encode(f(e)),r=c(s),n=O(P({}),"response");return V(n,t,{body:r[0],type:"application/json"}),n}static redirect(e,t=302){let s;D.argumentLengthCheck(arguments,1,"Response.redirect"),e=D.converters.USVString(e),t=D.converters["unsigned short"](t);try{s=new URL(e,y.settingsObject.baseUrl)}catch(t){throw new TypeError(`Failed to parse URL from ${e}`,{cause:t})}if(!w.has(t))throw new RangeError(`Invalid status code ${t}`);const r=O(P({}),"immutable");r.#le.status=t;const n=m(b(s));return r.#le.headersList.append("location",n,!0),r}constructor(e=null,t=void 0){if(D.util.markAsUncloneable(this),e===v)return;null!==e&&(e=D.converters.BodyInit(e,"Response","body")),t=D.converters.ResponseInit(t),this.#le=P({}),this.#Be=new r(v),o(this.#Be,"response"),a(this.#Be,this.#le.headersList);let s=null;if(null!=e){const[t,r]=c(e);s={body:t,type:r}}V(this,t,s)}get type(){return D.brandCheck(this,k),this.#le.type}get url(){D.brandCheck(this,k);const e=this.#le.urlList,t=e[e.length-1]??null;return null===t?"":b(t,!0)}get redirected(){return D.brandCheck(this,k),this.#le.urlList.length>1}get status(){return D.brandCheck(this,k),this.#le.status}get ok(){return D.brandCheck(this,k),this.#le.status>=200&&this.#le.status<=299}get statusText(){return D.brandCheck(this,k),this.#le.statusText}get headers(){return D.brandCheck(this,k),this.#Be}get body(){return D.brandCheck(this,k),this.#le.body?this.#le.body.stream:null}get bodyUsed(){return D.brandCheck(this,k),!!this.#le.body&&u.isDisturbed(this.#le.body.stream)}clone(){if(D.brandCheck(this,k),d(this.#le))throw D.errors.exception({header:"Response.clone",message:"Body has already been consumed."});const e=L(this.#le);return this.#le.body?.stream&&g.register(this,new WeakRef(this.#le.body.stream)),O(e,A(this.#Be))}[E.inspect.custom](e,t){null===t.depth&&(t.depth=2),t.colors??=!0;const s={status:this.status,statusText:this.statusText,headers:this.headers,body:this.body,bodyUsed:this.bodyUsed,ok:this.ok,redirected:this.redirected,type:this.type,url:this.url};return`Response ${E.formatWithOptions(t,s)}`}static getResponseHeaders(e){return e.#Be}static setResponseHeaders(e,t){e.#Be=t}static getResponseState(e){return e.#le}static setResponseState(e,t){e.#le=t}}const{getResponseHeaders:T,setResponseHeaders:F,getResponseState:M,setResponseState:U}=k;function L(e){if(e.internalResponse)return Y(L(e.internalResponse),e.type);const t=P({...e,body:null});return null!=e.body&&(t.body=l(e.body)),t}function P(e){return{aborted:!1,rangeRequested:!1,timingAllowPassed:!1,requestIncludesCredentials:!1,type:"default",status:200,timingInfo:null,cacheState:"",statusText:"",...e,headersList:e?.headersList?new n(e?.headersList):new n,urlList:e?.urlList?[...e.urlList]:[]}}function x(e){return P({type:"error",status:0,error:Q(e)?e:new Error(e?String(e):e),aborted:e&&"AbortError"===e.name})}function H(e,t){return t={internalResponse:e,...t},new Proxy(e,{get:(e,s)=>s in t?t[s]:e[s],set:(e,s,r)=>(R(!(s in t)),e[s]=r,!0)})}function Y(e,t){return"basic"===t?H(e,{type:"basic",headersList:e.headersList}):"cors"===t?H(e,{type:"cors",headersList:e.headersList}):"opaque"===t?H(e,{type:"opaque",urlList:Object.freeze([]),status:0,statusText:"",body:null}):"opaqueredirect"===t?H(e,{type:"opaqueredirect",status:0,statusText:"",headersList:[],body:null}):void R(!1)}function V(e,t,s){if(null!==t.status&&(t.status<200||t.status>599))throw new RangeError('init["status"] must be in the range of 200 to 599, inclusive.');if("statusText"in t&&null!=t.statusText&&!p(String(t.statusText)))throw new TypeError("Invalid statusText");if("status"in t&&null!=t.status&&(M(e).status=t.status),"statusText"in t&&null!=t.statusText&&(M(e).statusText=t.statusText),"headers"in t&&null!=t.headers&&i(T(e),t.headers),s){if(S.includes(e.status))throw D.errors.exception({header:"Response constructor",message:`Invalid response status code ${e.status}`});M(e).body=s.body,null==s.type||M(e).headersList.contains("content-type",!0)||M(e).headersList.append("content-type",s.type,!0)}}function O(e,t){const s=new k(v);U(s,e);const n=new r(v);return F(s,n),a(n,e.headersList),o(n,t),e.body?.stream&&g.register(s,new WeakRef(e.body.stream)),s}Reflect.deleteProperty(k,"getResponseHeaders"),Reflect.deleteProperty(k,"setResponseHeaders"),Reflect.deleteProperty(k,"getResponseState"),Reflect.deleteProperty(k,"setResponseState"),h(k,M),Object.defineProperties(k.prototype,{type:I,url:I,status:I,ok:I,redirected:I,statusText:I,headers:I,clone:I,body:I,bodyUsed:I,[Symbol.toStringTag]:{value:"Response",configurable:!0}}),Object.defineProperties(k,{json:I,redirect:I,error:I}),D.converters.XMLHttpRequestBodyInit=function(e,t,s){return"string"==typeof e?D.converters.USVString(e,t,s):D.is.Blob(e)||D.is.BufferSource(e)||D.is.FormData(e)||D.is.URLSearchParams(e)?e:D.converters.DOMString(e,t,s)},D.converters.BodyInit=function(e,t,s){return D.is.ReadableStream(e)||e?.[Symbol.asyncIterator]?e:D.converters.XMLHttpRequestBodyInit(e,t,s)},D.converters.ResponseInit=D.dictionaryConverter([{key:"status",converter:D.converters["unsigned short"],defaultValue:()=>200},{key:"statusText",converter:D.converters.ByteString,defaultValue:()=>""},{key:"headers",converter:D.converters.HeadersInit}]),D.is.Response=D.util.MakeTypeAssertion(k),e.exports={isNetworkError:function(e){return"error"===e.type&&0===e.status},makeNetworkError:x,makeResponse:P,makeAppropriateNetworkError:function(e,t=null){return R(C(e)),B(e)?x(Object.assign(new DOMException("The operation was aborted.","AbortError"),{cause:t})):x(Object.assign(new DOMException("Request was cancelled."),{cause:t}))},filterResponse:Y,Response:k,cloneResponse:L,fromInnerResponse:O,getResponseState:M}},6686:(e,t,s)=>{"use strict";const{Transform:r}=s(7075),n=s(8522),{redirectStatusSet:i,referrerPolicyTokens:A,badPortsSet:o}=s(9441),{getGlobalOrigin:a}=s(2837),{collectASequenceOfCodePoints:c,collectAnHTTPQuotedString:l,removeChars:h,parseMIMEType:g}=s(9934),{performance:d}=s(643),{ReadableStreamFrom:u,isValidHTTPToken:E,normalizedMethodRecordsBase:I}=s(2858),p=s(4589),{isUint8Array:C}=s(3429),{webidl:B}=s(6097);function f(e){const t=e.urlList,s=t.length;return 0===s?null:t[s-1].toString()}function Q(e){for(let t=0;t<e.length;++t){const s=e.charCodeAt(t);if(s>126||s<32)return!1}return!0}function m(e){return e.urlList[e.urlList.length-1]}const y=E;function w(e){return!1===("\t"===e[0]||" "===e[0]||"\t"===e[e.length-1]||" "===e[e.length-1]||e.includes("\n")||e.includes("\r")||e.includes("\0"))}function S(e,t){return e}function D(){return{referrerPolicy:"strict-origin-when-cross-origin"}}function b(e,t=!1){return p(B.is.URL(e)),x(e=new URL(e))?"no-referrer":(e.username="",e.password="",e.hash="",!0===t&&(e.pathname="",e.search=""),e)}const v=RegExp.prototype.test.bind(/^127\.(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){2}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)$/),R=RegExp.prototype.test.bind(/^(?:(?:0{1,4}:){7}|(?:0{1,4}:){1,6}:|::)0{0,3}1$/);function N(e){return e.includes(":")?("["===e[0]&&"]"===e[e.length-1]&&(e=e.slice(1,-1)),R(e)):v(e)}function k(e){return!!B.is.URL(e)&&("about:blank"===e.href||"about:srcdoc"===e.href||("data:"===e.protocol||("blob:"===e.protocol||!(null==(t=e.origin)||"null"===t||"https:"!==(t=new URL(t)).protocol&&"wss:"!==t.protocol&&!N(t.hostname)&&"localhost"!==t.hostname&&"localhost."!==t.hostname&&!t.hostname.endsWith(".localhost")&&!t.hostname.endsWith(".localhost.")&&"file:"!==t.protocol))));var t}function T(e,t){return e.origin===t.origin&&"null"===e.origin||e.protocol===t.protocol&&e.hostname===t.hostname&&e.port===t.port}const F=Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()));function M(e,t,s=0,r=1){class n{#Ke;#et;#tt;constructor(e,t){this.#Ke=e,this.#et=t,this.#tt=0}next(){if("object"!=typeof this||null===this||!(#Ke in this))throw new TypeError(`'next' called on an object that does not implement interface ${e} Iterator.`);const n=this.#tt,i=t(this.#Ke);if(n>=i.length)return{value:void 0,done:!0};const{[s]:A,[r]:o}=i[n];let a;switch(this.#tt=n+1,this.#et){case"key":a=A;break;case"value":a=o;break;case"key+value":a=[A,o]}return{value:a,done:!1}}}return delete n.prototype.constructor,Object.setPrototypeOf(n.prototype,F),Object.defineProperties(n.prototype,{[Symbol.toStringTag]:{writable:!1,enumerable:!1,configurable:!0,value:`${e} Iterator`},next:{writable:!0,enumerable:!0,configurable:!0}}),function(e,t){return new n(e,t)}}const U=/[^\x00-\xFF]/;function L(e){return p(!U.test(e)),e}async function P(e,t,s){try{const r=[];let n=0;for(;;){const{done:i,value:A}=await e.read();if(i)return void t(Buffer.concat(r,n));if(!C(A))return void s(new TypeError("Received non-Uint8Array chunk"));r.push(A),n+=A.length}}catch(e){s(e)}}function x(e){p("protocol"in e);const t=e.protocol;return"about:"===t||"blob:"===t||"data:"===t}function H(e){return"string"==typeof e&&":"===e[5]&&"h"===e[0]&&"t"===e[1]&&"t"===e[2]&&"p"===e[3]&&"s"===e[4]||"https:"===e.protocol}function Y(e){p("protocol"in e);const t=e.protocol;return"http:"===t||"https:"===t}class V extends r{#st;constructor(e){super(),this.#st=e}_transform(e,t,s){if(!this._inflateStream){if(0===e.length)return void s();this._inflateStream=8==(15&e[0])?n.createInflate(this.#st):n.createInflateRaw(this.#st),this._inflateStream.on("data",this.push.bind(this)),this._inflateStream.on("end",(()=>this.push(null))),this._inflateStream.on("error",(e=>this.destroy(e)))}this._inflateStream.write(e,t,s)}_final(e){this._inflateStream&&(this._inflateStream.end(),this._inflateStream=null),e()}}function O(e,t){const s=t.get(e,!0);return null===s?null:function(e){const t=e,s={position:0},r=[];let n="";for(;s.position<t.length;){if(n+=c((e=>'"'!==e&&","!==e),t,s),s.position<t.length)if(34===t.charCodeAt(s.position)){if(n+=l(t,s),s.position<t.length)continue}else p(44===t.charCodeAt(s.position)),s.position++;n=h(n,!0,!0,(e=>9===e||32===e)),r.push(n),n=""}return r}(s)}const G=new TextDecoder;class J{get baseUrl(){return a()}get origin(){return this.baseUrl?.origin}policyContainer={referrerPolicy:"strict-origin-when-cross-origin"}}const W=new class{settingsObject=new J};e.exports={isAborted:function(e){return"aborted"===e.controller.state},isCancelled:function(e){return"aborted"===e.controller.state||"terminated"===e.controller.state},isValidEncodedURL:Q,ReadableStreamFrom:u,tryUpgradeRequestToAPotentiallyTrustworthyURL:function(e){},clampAndCoarsenConnectionTimingInfo:function(e,t,s){return!e?.startTime||e.startTime<t?{domainLookupStartTime:t,domainLookupEndTime:t,connectionStartTime:t,connectionEndTime:t,secureConnectionStartTime:t,ALPNNegotiatedProtocol:e?.ALPNNegotiatedProtocol}:{domainLookupStartTime:S(e.domainLookupStartTime),domainLookupEndTime:S(e.domainLookupEndTime),connectionStartTime:S(e.connectionStartTime),connectionEndTime:S(e.connectionEndTime),secureConnectionStartTime:S(e.secureConnectionStartTime),ALPNNegotiatedProtocol:e.ALPNNegotiatedProtocol}},coarsenedSharedCurrentTime:function(e){return S(d.now())},determineRequestsReferrer:function(e){const t=e.referrerPolicy;p(t);let s=null;if("client"===e.referrer){const e=a();if(!e||"null"===e.origin)return"no-referrer";s=new URL(e)}else B.is.URL(e.referrer)&&(s=e.referrer);let r=b(s);const n=b(s,!0);switch(r.toString().length>4096&&(r=n),t){case"no-referrer":return"no-referrer";case"origin":return null!=n?n:b(s,!0);case"unsafe-url":return r;case"strict-origin":{const t=m(e);return k(r)&&!k(t)?"no-referrer":n}case"strict-origin-when-cross-origin":{const t=m(e);return T(r,t)?r:k(r)&&!k(t)?"no-referrer":n}case"same-origin":return T(e,r)?r:"no-referrer";case"origin-when-cross-origin":return T(e,r)?r:n;case"no-referrer-when-downgrade":{const t=m(e);return k(r)&&!k(t)?"no-referrer":r}}},makePolicyContainer:D,clonePolicyContainer:function(e){return{referrerPolicy:e.referrerPolicy}},appendFetchMetadata:function(e){let t=null;t=e.mode,e.headersList.set("sec-fetch-mode",t,!0)},appendRequestOriginHeader:function(e){let t=e.origin;if("client"!==t&&void 0!==t)if("cors"===e.responseTainting||"websocket"===e.mode)e.headersList.append("origin",t,!0);else if("GET"!==e.method&&"HEAD"!==e.method){switch(e.referrerPolicy){case"no-referrer":t=null;break;case"no-referrer-when-downgrade":case"strict-origin":case"strict-origin-when-cross-origin":e.origin&&H(e.origin)&&!H(m(e))&&(t=null);break;case"same-origin":T(e,m(e))||(t=null)}e.headersList.append("origin",t,!0)}},TAOCheck:function(){return"success"},corsCheck:function(){return"success"},crossOriginResourcePolicyCheck:function(){return"allowed"},createOpaqueTimingInfo:function(e){return{startTime:e.startTime??0,redirectStartTime:0,redirectEndTime:0,postRedirectStartTime:e.startTime??0,finalServiceWorkerStartTime:0,finalNetworkResponseStartTime:0,finalNetworkRequestStartTime:0,endTime:0,encodedBodySize:0,decodedBodySize:0,finalConnectionTimingInfo:null}},setRequestReferrerPolicyOnRedirect:function(e,t){const s=function(e){const t=(e.headersList.get("referrer-policy",!0)??"").split(",");let s="";if(t.length)for(let e=t.length;0!==e;e--){const r=t[e-1].trim();if(A.has(r)){s=r;break}}return s}(t);""!==s&&(e.referrerPolicy=s)},isValidHTTPToken:E,requestBadPort:function(e){const t=m(e);return Y(t)&&o.has(t.port)?"blocked":"allowed"},requestCurrentURL:m,responseURL:f,responseLocationURL:function(e,t){if(!i.has(e.status))return null;let s=e.headersList.get("location",!0);var r;return null!==s&&w(s)&&(Q(s)||(r=s,s=Buffer.from(r,"binary").toString("utf8")),s=new URL(s,f(e))),s&&!s.hash&&(s.hash=t),s},isURLPotentiallyTrustworthy:k,isValidReasonPhrase:function(e){for(let t=0;t<e.length;++t){const s=e.charCodeAt(t);if(!(9===s||s>=32&&s<=126||s>=128&&s<=255))return!1}return!0},sameOrigin:T,normalizeMethod:function(e){return I[e.toLowerCase()]??e},serializeJavascriptValueToJSONString:function(e){const t=JSON.stringify(e);if(void 0===t)throw new TypeError("Value is not JSON serializable");return p("string"==typeof t),t},iteratorMixin:function(e,t,s,r=0,n=1){const i=M(e,s,r,n),A={keys:{writable:!0,enumerable:!0,configurable:!0,value:function(){return B.brandCheck(this,t),i(this,"key")}},values:{writable:!0,enumerable:!0,configurable:!0,value:function(){return B.brandCheck(this,t),i(this,"value")}},entries:{writable:!0,enumerable:!0,configurable:!0,value:function(){return B.brandCheck(this,t),i(this,"key+value")}},forEach:{writable:!0,enumerable:!0,configurable:!0,value:function(s,r=globalThis){if(B.brandCheck(this,t),B.argumentLengthCheck(arguments,1,`${e}.forEach`),"function"!=typeof s)throw new TypeError(`Failed to execute 'forEach' on '${e}': parameter 1 is not of type 'Function'.`);for(const{0:e,1:t}of i(this,"key+value"))s.call(r,t,e,this)}}};return Object.defineProperties(t.prototype,{...A,[Symbol.iterator]:{writable:!0,enumerable:!1,configurable:!0,value:A.entries.value}})},createIterator:M,isValidHeaderName:y,isValidHeaderValue:w,isErrorLike:function(e){return e instanceof Error||"Error"===e?.constructor?.name||"DOMException"===e?.constructor?.name},fullyReadBody:function(e,t,s){const r=t,n=s;try{P(e.stream.getReader(),r,n)}catch(e){n(e)}},readableStreamClose:function(e){try{e.close(),e.byobRequest?.respond(0)}catch(e){if(!e.message.includes("Controller is already closed")&&!e.message.includes("ReadableStream is already closed"))throw e}},isomorphicEncode:L,urlIsLocal:x,urlHasHttpsScheme:H,urlIsHttpHttpsScheme:Y,readAllBytes:P,simpleRangeHeaderValue:function(e,t){const s=e;if(!s.startsWith("bytes"))return"failure";const r={position:5};if(t&&c((e=>"\t"===e||" "===e),s,r),61!==s.charCodeAt(r.position))return"failure";r.position++,t&&c((e=>"\t"===e||" "===e),s,r);const n=c((e=>{const t=e.charCodeAt(0);return t>=48&&t<=57}),s,r),i=n.length?Number(n):null;if(t&&c((e=>"\t"===e||" "===e),s,r),45!==s.charCodeAt(r.position))return"failure";r.position++,t&&c((e=>"\t"===e||" "===e),s,r);const A=c((e=>{const t=e.charCodeAt(0);return t>=48&&t<=57}),s,r),o=A.length?Number(A):null;return r.position<s.length||null===o&&null===i||i>o?"failure":{rangeStartValue:i,rangeEndValue:o}},buildContentRange:function(e,t,s){let r="bytes ";return r+=L(`${e}`),r+="-",r+=L(`${t}`),r+="/",r+=L(`${s}`),r},createInflate:function(e){return new V(e)},extractMimeType:function(e){let t=null,s=null,r=null;const n=O("content-type",e);if(null===n)return"failure";for(const e of n){const n=g(e);"failure"!==n&&"*/*"!==n.essence&&(r=n,r.essence!==s?(t=null,r.parameters.has("charset")&&(t=r.parameters.get("charset")),s=r.essence):r.parameters.has("charset")||null===t||r.parameters.set("charset",t))}return null==r?"failure":r},getDecodeSplit:O,utf8DecodeBytes:function(e){return 0===e.length?"":(239===e[0]&&187===e[1]&&191===e[2]&&(e=e.subarray(3)),G.decode(e))},environmentSettingsObject:W,isOriginIPPotentiallyTrustworthy:N}},7420:(e,t,s)=>{"use strict";const r=s(4589),n=new Map([["sha256",0],["sha384",1],["sha512",2]]);let i;try{i=s(7598);const e=i.getHashes();0===e.length&&n.clear();for(const t of n.keys())!1===e.includes(t)&&n.delete(t)}catch{n.clear()}const A=Map.prototype.get.bind(n),o=Map.prototype.has.bind(n),a=void 0===i||0===n.size?()=>!0:(e,t)=>{const s=l(t);if(0===s.length)return!0;const r=c(s);for(const t of r){const s=t.alg,r=t.val;if(g(h(s,e),r))return!0}return!1};function c(e){const t=[];let s=null;for(const n of e){if(r(o(n.alg),"Invalid SRI hash algorithm token"),0===t.length){t.push(n),s=n;continue}const e=s.alg,i=A(e),a=n.alg,c=A(a);c<i||(c>i?(s=n,t[0]=n,t.length=1):t.push(n))}return t}function l(e){const t=[];for(const s of e.split(" ")){const e=s.split("?",1)[0];let r="";const n=[e.slice(0,6),e.slice(7)],i=n[0];if(!o(i))continue;n[1]&&(r=n[1]);const A={alg:i,val:r};t.push(A)}return t}const h=(e,t)=>i.hash(e,t,"base64");function g(e,t){let s=e.length;0!==s&&"="===e[s-1]&&(s-=1),0!==s&&"="===e[s-1]&&(s-=1);let r=t.length;if(0!==r&&"="===t[r-1]&&(r-=1),0!==r&&"="===t[r-1]&&(r-=1),s!==r)return!1;for(let r=0;r<s;++r)if(!(e[r]===t[r]||"+"===e[r]&&"-"===t[r]||"/"===e[r]&&"_"===t[r]))return!1;return!0}e.exports={applyAlgorithmToBytes:h,bytesMatch:a,caseSensitiveMatch:g,isValidSRIHashAlgorithm:o,getStrongestMetadata:c,parseMetadata:l}},6097:(e,t,s)=>{"use strict";const{types:r,inspect:n}=s(7975),{markAsUncloneable:i}=s(5919),A=Function.call.bind(Function.prototype[Symbol.hasInstance]),o={converters:{},util:{},errors:{},is:{}};o.errors.exception=function(e){return new TypeError(`${e.header}: ${e.message}`)},o.errors.conversionFailed=function(e){const t=1===e.types.length?"":" one of",s=`${e.argument} could not be converted to${t}: ${e.types.join(", ")}.`;return o.errors.exception({header:e.prefix,message:s})},o.errors.invalidArgument=function(e){return o.errors.exception({header:e.prefix,message:`"${e.value}" is an invalid ${e.type}.`})},o.brandCheck=function(e,t){if(!A(t,e)){const e=new TypeError("Illegal invocation");throw e.code="ERR_INVALID_THIS",e}},o.brandCheckMultiple=function(e){const t=e.map((e=>o.util.MakeTypeAssertion(e)));return e=>{if(t.every((t=>!t(e)))){const e=new TypeError("Illegal invocation");throw e.code="ERR_INVALID_THIS",e}}},o.argumentLengthCheck=function({length:e},t,s){if(e<t)throw o.errors.exception({message:`${t} argument${1!==t?"s":""} required, but${e?" only":""} ${e} found.`,header:s})},o.illegalConstructor=function(){throw o.errors.exception({header:"TypeError",message:"Illegal constructor"})},o.util.MakeTypeAssertion=function(e){return t=>A(e,t)},o.util.Type=function(e){switch(typeof e){case"undefined":return 1;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"bigint":return 6;case"function":case"object":return null===e?7:8}},o.util.Types={UNDEFINED:1,BOOLEAN:2,STRING:3,SYMBOL:4,NUMBER:5,BIGINT:6,NULL:7,OBJECT:8},o.util.TypeValueToString=function(e){switch(o.util.Type(e)){case 1:return"Undefined";case 2:return"Boolean";case 3:return"String";case 4:return"Symbol";case 5:return"Number";case 6:return"BigInt";case 7:return"Null";case 8:return"Object"}},o.util.markAsUncloneable=i||(()=>{}),o.util.ConvertToInt=function(e,t,s,r){let n,i;64===t?(n=Math.pow(2,53)-1,i="unsigned"===s?0:Math.pow(-2,53)+1):"unsigned"===s?(i=0,n=Math.pow(2,t)-1):(i=Math.pow(-2,t)-1,n=Math.pow(2,t-1)-1);let A=Number(e);if(0===A&&(A=0),o.util.HasFlag(r,o.attributes.EnforceRange)){if(Number.isNaN(A)||A===Number.POSITIVE_INFINITY||A===Number.NEGATIVE_INFINITY)throw o.errors.exception({header:"Integer conversion",message:`Could not convert ${o.util.Stringify(e)} to an integer.`});if(A=o.util.IntegerPart(A),A<i||A>n)throw o.errors.exception({header:"Integer conversion",message:`Value must be between ${i}-${n}, got ${A}.`});return A}return!Number.isNaN(A)&&o.util.HasFlag(r,o.attributes.Clamp)?(A=Math.min(Math.max(A,i),n),A=Math.floor(A)%2==0?Math.floor(A):Math.ceil(A),A):Number.isNaN(A)||0===A&&Object.is(0,A)||A===Number.POSITIVE_INFINITY||A===Number.NEGATIVE_INFINITY?0:(A=o.util.IntegerPart(A),A%=Math.pow(2,t),"signed"===s&&A>=Math.pow(2,t)-1?A-Math.pow(2,t):A)},o.util.IntegerPart=function(e){const t=Math.floor(Math.abs(e));return e<0?-1*t:t},o.util.Stringify=function(e){switch(o.util.Type(e)){case 4:return`Symbol(${e.description})`;case 8:return n(e);case 3:return`"${e}"`;case 6:return`${e}n`;default:return`${e}`}},o.util.IsResizableArrayBuffer=function(e){if(r.isArrayBuffer(e))return e.resizable;if(r.isSharedArrayBuffer(e))return e.growable;throw o.errors.exception({header:"IsResizableArrayBuffer",message:`"${o.util.Stringify(e)}" is not an array buffer.`})},o.util.HasFlag=function(e,t){return"number"==typeof e&&(e&t)===t},o.sequenceConverter=function(e){return(t,s,r,n)=>{if(8!==o.util.Type(t))throw o.errors.exception({header:s,message:`${r} (${o.util.Stringify(t)}) is not iterable.`});const i="function"==typeof n?n():t?.[Symbol.iterator]?.(),A=[];let a=0;if(void 0===i||"function"!=typeof i.next)throw o.errors.exception({header:s,message:`${r} is not iterable.`});for(;;){const{done:t,value:n}=i.next();if(t)break;A.push(e(n,s,`${r}[${a++}]`))}return A}},o.recordConverter=function(e,t){return(s,n,i)=>{if(8!==o.util.Type(s))throw o.errors.exception({header:n,message:`${i} ("${o.util.TypeValueToString(s)}") is not an Object.`});const A={};if(!r.isProxy(s)){const r=[...Object.getOwnPropertyNames(s),...Object.getOwnPropertySymbols(s)];for(const a of r){const r=o.util.Stringify(a),c=e(a,n,`Key ${r} in ${i}`),l=t(s[a],n,`${i}[${r}]`);A[c]=l}return A}const a=Reflect.ownKeys(s);for(const r of a){const o=Reflect.getOwnPropertyDescriptor(s,r);if(o?.enumerable){const o=e(r,n,i),a=t(s[r],n,i);A[o]=a}}return A}},o.interfaceConverter=function(e,t){return(s,r,n)=>{if(!e(s))throw o.errors.exception({header:r,message:`Expected ${n} ("${o.util.Stringify(s)}") to be an instance of ${t}.`});return s}},o.dictionaryConverter=function(e){return(t,s,r)=>{const n={};if(null!=t&&8!==o.util.Type(t))throw o.errors.exception({header:s,message:`Expected ${t} to be one of: Null, Undefined, Object.`});for(const i of e){const{key:e,defaultValue:A,required:a,converter:c}=i;if(!0===a&&(null==t||!Object.hasOwn(t,e)))throw o.errors.exception({header:s,message:`Missing required key "${e}".`});let l=t?.[e];const h=void 0!==A;if(h&&void 0===l&&(l=A()),a||h||void 0!==l){if(l=c(l,s,`${r}.${e}`),i.allowedValues&&!i.allowedValues.includes(l))throw o.errors.exception({header:s,message:`${l} is not an accepted type. Expected one of ${i.allowedValues.join(", ")}.`});n[e]=l}}return n}},o.nullableConverter=function(e){return(t,s,r)=>null===t?t:e(t,s,r)},o.is.USVString=function(e){return"string"==typeof e&&e.isWellFormed()},o.is.ReadableStream=o.util.MakeTypeAssertion(ReadableStream),o.is.Blob=o.util.MakeTypeAssertion(Blob),o.is.URLSearchParams=o.util.MakeTypeAssertion(URLSearchParams),o.is.File=o.util.MakeTypeAssertion(File),o.is.URL=o.util.MakeTypeAssertion(URL),o.is.AbortSignal=o.util.MakeTypeAssertion(AbortSignal),o.is.MessagePort=o.util.MakeTypeAssertion(MessagePort),o.is.BufferSource=function(e){return r.isArrayBuffer(e)||ArrayBuffer.isView(e)&&r.isArrayBuffer(e.buffer)},o.converters.DOMString=function(e,t,s,r){if(null===e&&o.util.HasFlag(r,o.attributes.LegacyNullToEmptyString))return"";if("symbol"==typeof e)throw o.errors.exception({header:t,message:`${s} is a symbol, which cannot be converted to a DOMString.`});return String(e)},o.converters.ByteString=function(e,t,s){if("symbol"==typeof e)throw o.errors.exception({header:t,message:`${s} is a symbol, which cannot be converted to a ByteString.`});const r=String(e);for(let e=0;e<r.length;e++)if(r.charCodeAt(e)>255)throw new TypeError(`Cannot convert argument to a ByteString because the character at index ${e} has a value of ${r.charCodeAt(e)} which is greater than 255.`);return r},o.converters.USVString=function(e){return"string"==typeof e?e.toWellFormed():`${e}`.toWellFormed()},o.converters.boolean=function(e){return Boolean(e)},o.converters.any=function(e){return e},o.converters["long long"]=function(e,t,s){return o.util.ConvertToInt(e,64,"signed",0,t,s)},o.converters["unsigned long long"]=function(e,t,s){return o.util.ConvertToInt(e,64,"unsigned",0,t,s)},o.converters["unsigned long"]=function(e,t,s){return o.util.ConvertToInt(e,32,"unsigned",0,t,s)},o.converters["unsigned short"]=function(e,t,s,r){return o.util.ConvertToInt(e,16,"unsigned",r,t,s)},o.converters.ArrayBuffer=function(e,t,s,n){if(8!==o.util.Type(e)||!r.isArrayBuffer(e))throw o.errors.conversionFailed({prefix:t,argument:`${s} ("${o.util.Stringify(e)}")`,types:["ArrayBuffer"]});if(!o.util.HasFlag(n,o.attributes.AllowResizable)&&o.util.IsResizableArrayBuffer(e))throw o.errors.exception({header:t,message:`${s} cannot be a resizable ArrayBuffer.`});return e},o.converters.SharedArrayBuffer=function(e,t,s,n){if(8!==o.util.Type(e)||!r.isSharedArrayBuffer(e))throw o.errors.conversionFailed({prefix:t,argument:`${s} ("${o.util.Stringify(e)}")`,types:["SharedArrayBuffer"]});if(!o.util.HasFlag(n,o.attributes.AllowResizable)&&o.util.IsResizableArrayBuffer(e))throw o.errors.exception({header:t,message:`${s} cannot be a resizable SharedArrayBuffer.`});return e},o.converters.TypedArray=function(e,t,s,n,i){if(8!==o.util.Type(e)||!r.isTypedArray(e)||e.constructor.name!==t.name)throw o.errors.conversionFailed({prefix:s,argument:`${n} ("${o.util.Stringify(e)}")`,types:[t.name]});if(!o.util.HasFlag(i,o.attributes.AllowShared)&&r.isSharedArrayBuffer(e.buffer))throw o.errors.exception({header:s,message:`${n} cannot be a view on a shared array buffer.`});if(!o.util.HasFlag(i,o.attributes.AllowResizable)&&o.util.IsResizableArrayBuffer(e.buffer))throw o.errors.exception({header:s,message:`${n} cannot be a view on a resizable array buffer.`});return e},o.converters.DataView=function(e,t,s,n){if(8!==o.util.Type(e)||!r.isDataView(e))throw o.errors.conversionFailed({prefix:t,argument:`${s} ("${o.util.Stringify(e)}")`,types:["DataView"]});if(!o.util.HasFlag(n,o.attributes.AllowShared)&&r.isSharedArrayBuffer(e.buffer))throw o.errors.exception({header:t,message:`${s} cannot be a view on a shared array buffer.`});if(!o.util.HasFlag(n,o.attributes.AllowResizable)&&o.util.IsResizableArrayBuffer(e.buffer))throw o.errors.exception({header:t,message:`${s} cannot be a view on a resizable array buffer.`});return e},o.converters.ArrayBufferView=function(e,t,s,n){if(8!==o.util.Type(e)||!r.isArrayBufferView(e))throw o.errors.conversionFailed({prefix:t,argument:`${s} ("${o.util.Stringify(e)}")`,types:["ArrayBufferView"]});if(!o.util.HasFlag(n,o.attributes.AllowShared)&&r.isSharedArrayBuffer(e.buffer))throw o.errors.exception({header:t,message:`${s} cannot be a view on a shared array buffer.`});if(!o.util.HasFlag(n,o.attributes.AllowResizable)&&o.util.IsResizableArrayBuffer(e.buffer))throw o.errors.exception({header:t,message:`${s} cannot be a view on a resizable array buffer.`});return e},o.converters.BufferSource=function(e,t,s,n){if(r.isArrayBuffer(e))return o.converters.ArrayBuffer(e,t,s,n);if(r.isArrayBufferView(e))return n&=~o.attributes.AllowShared,o.converters.ArrayBufferView(e,t,s,n);if(r.isSharedArrayBuffer(e))throw o.errors.exception({header:t,message:`${s} cannot be a SharedArrayBuffer.`});throw o.errors.conversionFailed({prefix:t,argument:`${s} ("${o.util.Stringify(e)}")`,types:["ArrayBuffer","ArrayBufferView"]})},o.converters.AllowSharedBufferSource=function(e,t,s,n){if(r.isArrayBuffer(e))return o.converters.ArrayBuffer(e,t,s,n);if(r.isSharedArrayBuffer(e))return o.converters.SharedArrayBuffer(e,t,s,n);if(r.isArrayBufferView(e))return n|=o.attributes.AllowShared,o.converters.ArrayBufferView(e,t,s,n);throw o.errors.conversionFailed({prefix:t,argument:`${s} ("${o.util.Stringify(e)}")`,types:["ArrayBuffer","SharedArrayBuffer","ArrayBufferView"]})},o.converters["sequence<ByteString>"]=o.sequenceConverter(o.converters.ByteString),o.converters["sequence<sequence<ByteString>>"]=o.sequenceConverter(o.converters["sequence<ByteString>"]),o.converters["record<ByteString, ByteString>"]=o.recordConverter(o.converters.ByteString,o.converters.ByteString),o.converters.Blob=o.interfaceConverter(o.is.Blob,"Blob"),o.converters.AbortSignal=o.interfaceConverter(o.is.AbortSignal,"AbortSignal"),o.converters.EventHandlerNonNull=function(e){return 8!==o.util.Type(e)?null:"function"==typeof e?e:()=>{}},o.attributes={Clamp:1,EnforceRange:2,AllowShared:4,AllowResizable:8,LegacyNullToEmptyString:16},e.exports={webidl:o}},8251:(e,t,s)=>{"use strict";const{uid:r,states:n,sentCloseFrameState:i,emptyBuffer:A,opcodes:o}=s(6490),{parseExtensions:a,isClosed:c,isClosing:l,isEstablished:h,validateCloseCodeAndReason:g}=s(8983),{makeRequest:d}=s(4609),{fetching:u}=s(7388),{Headers:E,getHeadersList:I}=s(6558),{getDecodeSplit:p}=s(6686),{WebsocketFrameSend:C}=s(6834),B=s(4589);let f;try{f=s(7598)}catch{}function Q(e,t,s,r=!1){if(t??=null,s??="",r&&g(t,s),c(e.readyState)||l(e.readyState));else if(h(e.readyState))if(e.closeState.has(i.SENT)||e.closeState.has(i.RECEIVED))e.readyState=n.CLOSING;else{const r=new C;0!==s.length&&null===t&&(t=1e3),B(null===t||Number.isInteger(t)),null===t&&0===s.length?r.frameData=A:null!==t&&null===s?(r.frameData=Buffer.allocUnsafe(2),r.frameData.writeUInt16BE(t,0)):null!==t&&null!==s?(r.frameData=Buffer.allocUnsafe(2+Buffer.byteLength(s)),r.frameData.writeUInt16BE(t,0),r.frameData.write(s,2,"utf-8")):r.frameData=A,e.socket.write(r.createFrame(o.CLOSE)),e.closeState.add(i.SENT),e.readyState=n.CLOSING}else m(e),e.readyState=n.CLOSING}function m(e,t,s,r){h(e.readyState)&&Q(e,t,s,!1),e.controller.abort(),e.socket?!1===e.socket.destroyed&&e.socket.destroy():e.onSocketClose()}e.exports={establishWebSocketConnection:function(e,t,s,i,A){const o=e;o.protocol="ws:"===e.protocol?"http:":"https:";const c=d({urlList:[o],client:s,serviceWorkers:"none",referrer:"no-referrer",mode:"websocket",credentials:"include",cache:"no-store",redirect:"error"});if(A.headers){const e=I(new E(A.headers));c.headersList=e}const l=f.randomBytes(16).toString("base64");c.headersList.append("sec-websocket-key",l,!0),c.headersList.append("sec-websocket-version","13",!0);for(const e of t)c.headersList.append("sec-websocket-protocol",e,!0);return c.headersList.append("sec-websocket-extensions","permessage-deflate; client_max_window_bits",!0),u({request:c,useParallelQueue:!0,dispatcher:A.dispatcher,processResponse(e){if("error"===e.type&&(i.readyState=n.CLOSED),"error"===e.type||101!==e.status)return void m(i,1002,"Received network error or non-101 status code.",e.error);if(0!==t.length&&!e.headersList.get("Sec-WebSocket-Protocol"))return void m(i,1002,"Server did not respond with sent protocols.");if("websocket"!==e.headersList.get("Upgrade")?.toLowerCase())return void m(i,1002,'Server did not set Upgrade header to "websocket".');if("upgrade"!==e.headersList.get("Connection")?.toLowerCase())return void m(i,1002,'Server did not set Connection header to "upgrade".');if(e.headersList.get("Sec-WebSocket-Accept")!==f.createHash("sha1").update(l+r).digest("base64"))return void m(i,1002,"Incorrect hash received in Sec-WebSocket-Accept header.");const s=e.headersList.get("Sec-WebSocket-Extensions");let A;if(null!==s&&(A=a(s),!A.has("permessage-deflate")))return void m(i,1002,"Sec-WebSocket-Extensions header does not match.");const o=e.headersList.get("Sec-WebSocket-Protocol");if(null!==o){if(!p("sec-websocket-protocol",c.headersList).includes(o))return void m(i,1002,"Protocol was not set in the opening handshake.")}e.socket.on("data",i.onSocketData),e.socket.on("close",i.onSocketClose),e.socket.on("error",i.onSocketError),i.wasEverConnected=!0,i.onConnectionEstablished(e,A)}})},failWebsocketConnection:m,closeWebSocketConnection:Q}},6490:e=>{"use strict";const t=Buffer.allocUnsafe(0);e.exports={uid:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",sentCloseFrameState:{SENT:1,RECEIVED:2},staticPropertyDescriptors:{enumerable:!0,writable:!1,configurable:!1},states:{CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3},opcodes:{CONTINUATION:0,TEXT:1,BINARY:2,CLOSE:8,PING:9,PONG:10},maxUnsigned16Bit:65535,parserStates:{INFO:0,PAYLOADLENGTH_16:2,PAYLOADLENGTH_64:3,READ_DATA:4},emptyBuffer:t,sendHints:{text:1,typedArray:2,arrayBuffer:3,blob:4}}},878:(e,t,s)=>{"use strict";const{webidl:r}=s(6097),{kEnumerableProperty:n}=s(2858),{kConstruct:i}=s(257);class A extends Event{#rt;constructor(e,t={}){if(e===i)return super(arguments[1],arguments[2]),void r.util.markAsUncloneable(this);const s="MessageEvent constructor";r.argumentLengthCheck(arguments,1,s),super(e=r.converters.DOMString(e,s,"type"),t=r.converters.MessageEventInit(t,s,"eventInitDict")),this.#rt=t,r.util.markAsUncloneable(this)}get data(){return r.brandCheck(this,A),this.#rt.data}get origin(){return r.brandCheck(this,A),this.#rt.origin}get lastEventId(){return r.brandCheck(this,A),this.#rt.lastEventId}get source(){return r.brandCheck(this,A),this.#rt.source}get ports(){return r.brandCheck(this,A),Object.isFrozen(this.#rt.ports)||Object.freeze(this.#rt.ports),this.#rt.ports}initMessageEvent(e,t=!1,s=!1,n=null,i="",o="",a=null,c=[]){return r.brandCheck(this,A),r.argumentLengthCheck(arguments,1,"MessageEvent.initMessageEvent"),new A(e,{bubbles:t,cancelable:s,data:n,origin:i,lastEventId:o,source:a,ports:c})}static createFastMessageEvent(e,t){const s=new A(i,e,t);return s.#rt=t,s.#rt.data??=null,s.#rt.origin??="",s.#rt.lastEventId??="",s.#rt.source??=null,s.#rt.ports??=[],s}}const{createFastMessageEvent:o}=A;delete A.createFastMessageEvent;class a extends Event{#rt;constructor(e,t={}){const s="CloseEvent constructor";r.argumentLengthCheck(arguments,1,s),super(e=r.converters.DOMString(e,s,"type"),t=r.converters.CloseEventInit(t)),this.#rt=t,r.util.markAsUncloneable(this)}get wasClean(){return r.brandCheck(this,a),this.#rt.wasClean}get code(){return r.brandCheck(this,a),this.#rt.code}get reason(){return r.brandCheck(this,a),this.#rt.reason}}class c extends Event{#rt;constructor(e,t){const s="ErrorEvent constructor";r.argumentLengthCheck(arguments,1,s),super(e,t),r.util.markAsUncloneable(this),e=r.converters.DOMString(e,s,"type"),t=r.converters.ErrorEventInit(t??{}),this.#rt=t}get message(){return r.brandCheck(this,c),this.#rt.message}get filename(){return r.brandCheck(this,c),this.#rt.filename}get lineno(){return r.brandCheck(this,c),this.#rt.lineno}get colno(){return r.brandCheck(this,c),this.#rt.colno}get error(){return r.brandCheck(this,c),this.#rt.error}}Object.defineProperties(A.prototype,{[Symbol.toStringTag]:{value:"MessageEvent",configurable:!0},data:n,origin:n,lastEventId:n,source:n,ports:n,initMessageEvent:n}),Object.defineProperties(a.prototype,{[Symbol.toStringTag]:{value:"CloseEvent",configurable:!0},reason:n,code:n,wasClean:n}),Object.defineProperties(c.prototype,{[Symbol.toStringTag]:{value:"ErrorEvent",configurable:!0},message:n,filename:n,lineno:n,colno:n,error:n}),r.converters.MessagePort=r.interfaceConverter(r.is.MessagePort,"MessagePort"),r.converters["sequence<MessagePort>"]=r.sequenceConverter(r.converters.MessagePort);const l=[{key:"bubbles",converter:r.converters.boolean,defaultValue:()=>!1},{key:"cancelable",converter:r.converters.boolean,defaultValue:()=>!1},{key:"composed",converter:r.converters.boolean,defaultValue:()=>!1}];r.converters.MessageEventInit=r.dictionaryConverter([...l,{key:"data",converter:r.converters.any,defaultValue:()=>null},{key:"origin",converter:r.converters.USVString,defaultValue:()=>""},{key:"lastEventId",converter:r.converters.DOMString,defaultValue:()=>""},{key:"source",converter:r.nullableConverter(r.converters.MessagePort),defaultValue:()=>null},{key:"ports",converter:r.converters["sequence<MessagePort>"],defaultValue:()=>[]}]),r.converters.CloseEventInit=r.dictionaryConverter([...l,{key:"wasClean",converter:r.converters.boolean,defaultValue:()=>!1},{key:"code",converter:r.converters["unsigned short"],defaultValue:()=>0},{key:"reason",converter:r.converters.USVString,defaultValue:()=>""}]),r.converters.ErrorEventInit=r.dictionaryConverter([...l,{key:"message",converter:r.converters.DOMString,defaultValue:()=>""},{key:"filename",converter:r.converters.USVString,defaultValue:()=>""},{key:"lineno",converter:r.converters["unsigned long"],defaultValue:()=>0},{key:"colno",converter:r.converters["unsigned long"],defaultValue:()=>0},{key:"error",converter:r.converters.any}]),e.exports={MessageEvent:A,CloseEvent:a,ErrorEvent:c,createFastMessageEvent:o}},6834:(e,t,s)=>{"use strict";const{maxUnsigned16Bit:r,opcodes:n}=s(6490),i=8192;let A,o=null,a=i;try{A=s(7598)}catch{A={randomFillSync:function(e,t,s){for(let t=0;t<e.length;++t)e[t]=255*Math.random()|0;return e}}}function c(){return a===i&&(a=0,A.randomFillSync(o??=Buffer.allocUnsafeSlow(i),0,i)),[o[a++],o[a++],o[a++],o[a++]]}e.exports={WebsocketFrameSend:class{constructor(e){this.frameData=e}createFrame(e){const t=this.frameData,s=c(),n=t?.byteLength??0;let i=n,A=6;n>r?(A+=8,i=127):n>125&&(A+=2,i=126);const o=Buffer.allocUnsafe(n+A);o[0]=o[1]=0,o[0]|=128,o[0]=(240&o[0])+e,o[A-4]=s[0],o[A-3]=s[1],o[A-2]=s[2],o[A-1]=s[3],o[1]=i,126===i?o.writeUInt16BE(n,2):127===i&&(o[2]=o[3]=0,o.writeUIntBE(n,4,6)),o[1]|=128;for(let e=0;e<n;++e)o[A+e]=t[e]^s[3&e];return o}static createFastTextFrame(e){const t=c(),s=e.length;for(let r=0;r<s;++r)e[r]^=t[3&r];let i=s,A=6;s>r?(A+=8,i=127):s>125&&(A+=2,i=126);const o=Buffer.allocUnsafeSlow(A);return o[0]=128|n.TEXT,o[1]=128|i,o[A-4]=t[0],o[A-3]=t[1],o[A-2]=t[2],o[A-1]=t[3],126===i?o.writeUInt16BE(s,2):127===i&&(o[2]=o[3]=0,o.writeUIntBE(s,4,6)),[o,e]}},generateMask:c}},8975:(e,t,s)=>{"use strict";const{createInflateRaw:r,Z_DEFAULT_WINDOWBITS:n}=s(8522),{isValidClientWindowBits:i}=s(8983),A=Buffer.from([0,0,255,255]),o=Symbol("kBuffer"),a=Symbol("kLength");e.exports={PerMessageDeflate:class{#nt;#N={};constructor(e){this.#N.serverNoContextTakeover=e.has("server_no_context_takeover"),this.#N.serverMaxWindowBits=e.get("server_max_window_bits")}decompress(e,t,s){if(!this.#nt){let e=n;if(this.#N.serverMaxWindowBits){if(!i(this.#N.serverMaxWindowBits))return void s(new Error("Invalid server_max_window_bits"));e=Number.parseInt(this.#N.serverMaxWindowBits)}this.#nt=r({windowBits:e}),this.#nt[o]=[],this.#nt[a]=0,this.#nt.on("data",(e=>{this.#nt[o].push(e),this.#nt[a]+=e.length})),this.#nt.on("error",(e=>{this.#nt=null,s(e)}))}this.#nt.write(e),t&&this.#nt.write(A),this.#nt.flush((()=>{const e=Buffer.concat(this.#nt[o],this.#nt[a]);this.#nt[o].length=0,this.#nt[a]=0,s(null,e)}))}}}},834:(e,t,s)=>{"use strict";const{Writable:r}=s(7075),n=s(4589),{parserStates:i,opcodes:A,states:o,emptyBuffer:a,sentCloseFrameState:c}=s(6490),{isValidStatusCode:l,isValidOpcode:h,websocketMessageReceived:g,utf8Decode:d,isControlFrame:u,isTextBinaryFrame:E,isContinuationFrame:I}=s(8983),{failWebsocketConnection:p}=s(8251),{WebsocketFrameSend:C}=s(6834),{PerMessageDeflate:B}=s(8975);e.exports={ByteParser:class extends r{#it=[];#At=0;#ot=0;#at=!1;#le=i.INFO;#ct={};#lt=[];#ht;#U;constructor(e,t){super(),this.#U=e,this.#ht=null==t?new Map:t,this.#ht.has("permessage-deflate")&&this.#ht.set("permessage-deflate",new B(t))}_write(e,t,s){this.#it.push(e),this.#ot+=e.length,this.#at=!0,this.run(s)}run(e){for(;this.#at;)if(this.#le===i.INFO){if(this.#ot<2)return e();const t=this.consume(2),s=!!(128&t[0]),r=15&t[0],n=!(128&~t[1]),o=!s&&r!==A.CONTINUATION,a=127&t[1],c=64&t[0],l=32&t[0],g=16&t[0];if(!h(r))return p(this.#U,1002,"Invalid opcode received"),e();if(n)return p(this.#U,1002,"Frame cannot be masked"),e();if(0!==c&&!this.#ht.has("permessage-deflate"))return void p(this.#U,1002,"Expected RSV1 to be clear.");if(0!==l||0!==g)return void p(this.#U,1002,"RSV1, RSV2, RSV3 must be clear");if(o&&!E(r))return void p(this.#U,1002,"Invalid frame type was fragmented.");if(E(r)&&this.#lt.length>0)return void p(this.#U,1002,"Expected continuation frame");if(this.#ct.fragmented&&o)return void p(this.#U,1002,"Fragmented frame exceeded 125 bytes.");if((a>125||o)&&u(r))return void p(this.#U,1002,"Control frame either too large or fragmented");if(I(r)&&0===this.#lt.length&&!this.#ct.compressed)return void p(this.#U,1002,"Unexpected continuation frame");a<=125?(this.#ct.payloadLength=a,this.#le=i.READ_DATA):126===a?this.#le=i.PAYLOADLENGTH_16:127===a&&(this.#le=i.PAYLOADLENGTH_64),E(r)&&(this.#ct.binaryType=r,this.#ct.compressed=0!==c),this.#ct.opcode=r,this.#ct.masked=n,this.#ct.fin=s,this.#ct.fragmented=o}else if(this.#le===i.PAYLOADLENGTH_16){if(this.#ot<2)return e();const t=this.consume(2);this.#ct.payloadLength=t.readUInt16BE(0),this.#le=i.READ_DATA}else if(this.#le===i.PAYLOADLENGTH_64){if(this.#ot<8)return e();const t=this.consume(8),s=t.readUInt32BE(0);if(s>2**31-1)return void p(this.#U,1009,"Received payload length > 2^31 bytes.");const r=t.readUInt32BE(4);this.#ct.payloadLength=(s<<8)+r,this.#le=i.READ_DATA}else if(this.#le===i.READ_DATA){if(this.#ot<this.#ct.payloadLength)return e();const t=this.consume(this.#ct.payloadLength);if(u(this.#ct.opcode))this.#at=this.parseControlFrame(t),this.#le=i.INFO;else{if(this.#ct.compressed){this.#ht.get("permessage-deflate").decompress(t,this.#ct.fin,((t,s)=>{if(t)p(this.#U,1007,t.message);else{if(this.writeFragments(s),!this.#ct.fin)return this.#le=i.INFO,this.#at=!0,void this.run(e);g(this.#U,this.#ct.binaryType,this.consumeFragments()),this.#at=!0,this.#le=i.INFO,this.run(e)}})),this.#at=!1;break}this.writeFragments(t),!this.#ct.fragmented&&this.#ct.fin&&g(this.#U,this.#ct.binaryType,this.consumeFragments()),this.#le=i.INFO}}}consume(e){if(e>this.#ot)throw new Error("Called consume() before buffers satiated.");if(0===e)return a;this.#ot-=e;const t=this.#it[0];if(t.length>e)return this.#it[0]=t.subarray(e,t.length),t.subarray(0,e);if(t.length===e)return this.#it.shift();{let t=0;const s=Buffer.allocUnsafeSlow(e);for(;t!==e;){const r=this.#it[0],n=r.length;if(n+t===e){s.set(this.#it.shift(),t);break}if(n+t>e){s.set(r.subarray(0,e-t),t),this.#it[0]=r.subarray(e-t);break}s.set(this.#it.shift(),t),t+=n}return s}}writeFragments(e){this.#At+=e.length,this.#lt.push(e)}consumeFragments(){const e=this.#lt;if(1===e.length)return this.#At=0,e.shift();let t=0;const s=Buffer.allocUnsafeSlow(this.#At);for(let r=0;r<e.length;++r){const n=e[r];s.set(n,t),t+=n.length}return this.#lt=[],this.#At=0,s}parseCloseBody(e){let t;if(n(1!==e.length),e.length>=2&&(t=e.readUInt16BE(0)),void 0!==t&&!l(t))return{code:1002,reason:"Invalid status code",error:!0};let s=e.subarray(2);239===s[0]&&187===s[1]&&191===s[2]&&(s=s.subarray(3));try{s=d(s)}catch{return{code:1007,reason:"Invalid UTF-8",error:!0}}return{code:t,reason:s,error:!1}}parseControlFrame(e){const{opcode:t,payloadLength:s}=this.#ct;if(t===A.CLOSE){if(1===s)return p(this.#U,1002,"Received close frame with a 1-byte body."),!1;if(this.#ct.closeInfo=this.parseCloseBody(e),this.#ct.closeInfo.error){const{code:e,reason:t}=this.#ct.closeInfo;return p(this.#U,e,t),!1}if(!this.#U.closeState.has(c.SENT)&&!this.#U.closeState.has(c.RECEIVED)){let e=a;this.#ct.closeInfo.code&&(e=Buffer.allocUnsafe(2),e.writeUInt16BE(this.#ct.closeInfo.code,0));const t=new C(e);this.#U.socket.write(t.createFrame(A.CLOSE)),this.#U.closeState.add(c.SENT)}return this.#U.readyState=o.CLOSING,this.#U.closeState.add(c.RECEIVED),!1}if(t===A.PING){if(!this.#U.closeState.has(c.RECEIVED)){const t=new C(e);this.#U.socket.write(t.createFrame(A.PONG)),this.#U.onPing(e)}}else t===A.PONG&&this.#U.onPong(e);return!0}get closingInfo(){return this.#ct.closeInfo}}}},2534:(e,t,s)=>{"use strict";const{WebsocketFrameSend:r}=s(6834),{opcodes:n,sendHints:i}=s(6490),A=s(1726);function o(e,t){return new r(function(e,t){switch(t){case i.text:case i.typedArray:return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);case i.arrayBuffer:case i.blob:return new Uint8Array(e)}}(e,t)).createFrame(t===i.text?n.TEXT:n.BINARY)}e.exports={SendQueue:class{#gt=new A;#dt=!1;#ut;constructor(e){this.#ut=e}add(e,t,s){if(s!==i.blob){if(this.#dt){const r={promise:null,callback:t,frame:o(e,s)};this.#gt.push(r)}else if(s===i.text){const{0:s,1:n}=r.createFastTextFrame(e);this.#ut.cork(),this.#ut.write(s),this.#ut.write(n,t),this.#ut.uncork()}else this.#ut.write(o(e,s),t);return}const n={promise:e.arrayBuffer().then((e=>{n.promise=null,n.frame=o(e,s)})),callback:t,frame:null};this.#gt.push(n),this.#dt||this.#Et()}async#Et(){this.#dt=!0;const e=this.#gt;for(;!e.isEmpty();){const t=e.shift();null!==t.promise&&await t.promise,this.#ut.write(t.frame,t.callback),t.callback=t.frame=null}this.#dt=!1}}}},7053:(e,t,s)=>{"use strict";const{webidl:r}=s(6097),{validateCloseCodeAndReason:n}=s(8983),{kConstruct:i}=s(257),{kEnumerableProperty:A}=s(2858);class o extends(function(){class e extends DOMException{get reason(){return""}}return void 0!==(new e).reason?DOMException:new Proxy(DOMException,{construct(e,t,s){const r=Reflect.construct(e,t,e);return Object.setPrototypeOf(r,s.prototype),r}})}()){#It;#W;constructor(e="",t=void 0){if(super(e=r.converters.DOMString(e,"WebSocketError","message"),"WebSocketError"),t===i)return;null!==t&&(t=r.converters.WebSocketCloseInfo(t));let s=t.closeCode??null;const A=t.reason??"";n(s,A),0!==A.length&&null===s&&(s=1e3),this.#It=s,this.#W=A}get closeCode(){return this.#It}get reason(){return this.#W}static createUnvalidatedWebSocketError(e,t,s){const r=new o(e,i);return r.#It=t,r.#W=s,r}}const{createUnvalidatedWebSocketError:a}=o;delete o.createUnvalidatedWebSocketError,Object.defineProperties(o.prototype,{closeCode:A,reason:A,[Symbol.toStringTag]:{value:"WebSocketError",writable:!1,enumerable:!1,configurable:!0}}),r.is.WebSocketError=r.util.MakeTypeAssertion(o),e.exports={WebSocketError:o,createUnvalidatedWebSocketError:a}},27:(e,t,s)=>{"use strict";const{createDeferredPromise:r}=s(9250),{environmentSettingsObject:n}=s(6686),{states:i,opcodes:A,sentCloseFrameState:o}=s(6490),{webidl:a}=s(6097),{getURLRecord:c,isValidSubprotocol:l,isEstablished:h,utf8Decode:g}=s(8983),{establishWebSocketConnection:d,failWebsocketConnection:u,closeWebSocketConnection:E}=s(8251),{channels:I}=s(772),{WebsocketFrameSend:p}=s(6834),{ByteParser:C}=s(834),{WebSocketError:B,createUnvalidatedWebSocketError:f}=s(7053),{utf8DecodeBytes:Q}=s(6686),{kEnumerableProperty:m}=s(2858);let y=!1;class w{#Ge;#pt;#Ct;#Bt;#ft;#Qt;#mt=!1;#U={onConnectionEstablished:(e,t)=>this.#yt(e,t),onMessage:(e,t)=>this.#wt(e,t),onParserError:e=>u(this.#U,null,e.message),onParserDrain:()=>this.#U.socket.resume(),onSocketData:e=>{this.#St.write(e)||this.#U.socket.pause()},onSocketError:e=>{this.#U.readyState=i.CLOSING,I.socketError.hasSubscribers&&I.socketError.publish(e),this.#U.socket.destroy()},onSocketClose:()=>this.#Dt(),onPing:()=>{},onPong:()=>{},readyState:i.CONNECTING,socket:null,closeState:new Set,controller:null,wasEverConnected:!1};#St;constructor(e,t=void 0){y||(process.emitWarning("WebSocketStream is experimental! Expect it to change at any time.",{code:"UNDICI-WSS"}),y=!0),a.argumentLengthCheck(arguments,1,"WebSocket"),e=a.converters.USVString(e),null!==t&&(t=a.converters.WebSocketStreamOptions(t));const s=n.settingsObject.baseUrl,A=c(e,s),o=t.protocols;if(o.length!==new Set(o.map((e=>e.toLowerCase()))).size)throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");if(o.length>0&&!o.every((e=>l(e))))throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");if(this.#Ge=A.toString(),this.#pt=r(),this.#Ct=r(),null!=t.signal){const e=t.signal;if(e.aborted)return this.#pt.reject(e.reason),void this.#Ct.reject(e.reason);e.addEventListener("abort",(()=>{h(this.#U.readyState)||(u(this.#U),this.#U.readyState=i.CLOSING,this.#pt.reject(e.reason),this.#Ct.reject(e.reason),this.#mt=!0)}),{once:!0})}const g=n.settingsObject;this.#U.controller=d(A,o,g,this.#U,t)}get url(){return this.#Ge.toString()}get opened(){return this.#pt.promise}get closed(){return this.#Ct.promise}close(e=void 0){null!==e&&(e=a.converters.WebSocketCloseInfo(e));const t=e.closeCode??null,s=e.reason;E(this.#U,t,s,!0)}#bt(e){e=a.converters.WebSocketStreamWrite(e);const t=r();let s=null,n=null;if(a.is.BufferSource(e))s=new Uint8Array(ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e.slice()),n=A.BINARY;else{let r;try{r=a.converters.DOMString(e)}catch(e){return t.reject(e),t.promise}s=(new TextEncoder).encode(r),n=A.TEXT}if(!this.#U.closeState.has(o.SENT)&&!this.#U.closeState.has(o.RECEIVED)){const e=new p(s);this.#U.socket.write(e.createFrame(n),(()=>{t.resolve(void 0)}))}return t.promise}#yt(e,t){this.#U.socket=e.socket;const s=new C(this.#U,t);s.on("drain",(()=>this.#U.onParserDrain())),s.on("error",(e=>this.#U.onParserError(e))),this.#St=s,this.#U.readyState=i.OPEN;const r=t??"",n=e.headersList.get("sec-websocket-protocol")??"",A=new ReadableStream({start:e=>{this.#ft=e},pull(t){let s;for(;t.desiredSize>0&&null!==(s=e.socket.read());)t.enqueue(s)},cancel:e=>this.#vt(e)}),o=new WritableStream({write:e=>this.#bt(e),close:()=>E(this.#U,null,null),abort:e=>this.#Rt(e)});this.#Bt=A,this.#Qt=o,this.#pt.resolve({extensions:r,protocol:n,readable:A,writable:o})}#wt(e,t){if(this.#U.readyState!==i.OPEN)return;let s;if(e===A.TEXT)try{s=g(t)}catch{return void u(this.#U,"Received invalid UTF-8 in text frame.")}else e===A.BINARY&&(s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength));this.#ft.enqueue(s)}#Dt(){const e=this.#U.closeState.has(o.SENT)&&this.#U.closeState.has(o.RECEIVED);if(this.#U.readyState=i.CLOSED,this.#mt)return;this.#U.wasEverConnected||this.#pt.reject(new B("Socket never opened"));const t=this.#St.closingInfo;let s=t?.code??1005;this.#U.closeState.has(o.SENT)||this.#U.closeState.has(o.RECEIVED)||(s=1006);const r=null==t?.reason?"":Q(Buffer.from(t.reason));if(e)this.#ft.close(),this.#Qt.locked||this.#Qt.abort(new DOMException("A closed WebSocketStream cannot be written to","InvalidStateError")),this.#Ct.resolve({closeCode:s,reason:r});else{const e=f("unclean close",s,r);this.#ft.error(e),this.#Qt.abort(e),this.#Ct.reject(e)}}#Rt(e){let t=null,s="";a.is.WebSocketError(e)&&(t=e.closeCode,s=e.reason),E(this.#U,t,s)}#vt(e){this.#Rt(e)}}Object.defineProperties(w.prototype,{url:m,opened:m,closed:m,close:m,[Symbol.toStringTag]:{value:"WebSocketStream",writable:!1,enumerable:!1,configurable:!0}}),a.converters.WebSocketStreamOptions=a.dictionaryConverter([{key:"protocols",converter:a.sequenceConverter(a.converters.USVString),defaultValue:()=>[]},{key:"signal",converter:a.nullableConverter(a.converters.AbortSignal),defaultValue:()=>null}]),a.converters.WebSocketCloseInfo=a.dictionaryConverter([{key:"closeCode",converter:e=>a.converters["unsigned short"](e,a.attributes.EnforceRange)},{key:"reason",converter:a.converters.USVString,defaultValue:()=>""}]),a.converters.WebSocketStreamWrite=function(e){return"string"==typeof e?a.converters.USVString(e):a.converters.BufferSource(e)},e.exports={WebSocketStream:w}},8983:(e,t,s)=>{"use strict";const{states:r,opcodes:n}=s(6490),{isUtf8:i}=s(4573),{collectASequenceOfCodePointsFast:A,removeHTTPWhitespace:o}=s(9934);function a(e){return e===n.CLOSE||e===n.PING||e===n.PONG}function c(e){return e===n.CONTINUATION}function l(e){return e===n.TEXT||e===n.BINARY}const h=(()=>{if("string"==typeof process.versions.icu){const e=new TextDecoder("utf-8",{fatal:!0});return e.decode.bind(e)}return function(e){if(i(e))return e.toString("utf-8");throw new TypeError("Invalid utf-8 received.")}})();e.exports={isConnecting:function(e){return e===r.CONNECTING},isEstablished:function(e){return e===r.OPEN},isClosing:function(e){return e===r.CLOSING},isClosed:function(e){return e===r.CLOSED},fireEvent:function(e,t,s=(e,t)=>new Event(e,t),r={}){const n=s(e,r);t.dispatchEvent(n)},isValidSubprotocol:function(e){if(0===e.length)return!1;for(let t=0;t<e.length;++t){const s=e.charCodeAt(t);if(s<33||s>126||34===s||40===s||41===s||44===s||47===s||58===s||59===s||60===s||61===s||62===s||63===s||64===s||91===s||92===s||93===s||123===s||125===s)return!1}return!0},isValidStatusCode:function(e){return e>=1e3&&e<1015?1004!==e&&1005!==e&&1006!==e:e>=3e3&&e<=4999},websocketMessageReceived:function(e,t,s){e.onMessage(t,s)},utf8Decode:h,isControlFrame:a,isContinuationFrame:c,isTextBinaryFrame:l,isValidOpcode:function(e){return l(e)||c(e)||a(e)},parseExtensions:function(e){const t={position:0},s=new Map;for(;t.position<e.length;){const r=A(";",e,t),[n,i=""]=r.split("=",2);s.set(o(n,!0,!1),o(i,!1,!0)),t.position++}return s},isValidClientWindowBits:function(e){for(let t=0;t<e.length;t++){const s=e.charCodeAt(t);if(s<48||s>57)return!1}return!0},toArrayBuffer:function(e){return e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer},getURLRecord:function(e,t){let s;try{s=new URL(e,t)}catch(e){throw new DOMException(e,"SyntaxError")}if("http:"===s.protocol?s.protocol="ws:":"https:"===s.protocol&&(s.protocol="wss:"),"ws:"!==s.protocol&&"wss:"!==s.protocol)throw new DOMException("expected a ws: or wss: url","SyntaxError");if(s.hash.length||s.href.endsWith("#"))throw new DOMException("hash","SyntaxError");return s},validateCloseCodeAndReason:function(e,t){if(null!==e&&1e3!==e&&(e<3e3||e>4999))throw new DOMException("invalid code","InvalidAccessError");if(null!==t){const e=Buffer.byteLength(t);if(e>123)throw new DOMException(`Reason must be less than 123 bytes; received ${e}`,"SyntaxError")}}}},2984:(e,t,s)=>{"use strict";const{isArrayBuffer:r}=s(3429),{webidl:n}=s(6097),{URLSerializer:i}=s(9934),{environmentSettingsObject:A}=s(6686),{staticPropertyDescriptors:o,states:a,sentCloseFrameState:c,sendHints:l,opcodes:h}=s(6490),{isConnecting:g,isEstablished:d,isClosing:u,isClosed:E,isValidSubprotocol:I,fireEvent:p,utf8Decode:C,toArrayBuffer:B,getURLRecord:f}=s(8983),{establishWebSocketConnection:Q,closeWebSocketConnection:m,failWebsocketConnection:y}=s(8251),{ByteParser:w}=s(834),{kEnumerableProperty:S}=s(2858),{getGlobalDispatcher:D}=s(9879),{ErrorEvent:b,CloseEvent:v,createFastMessageEvent:R}=s(878),{SendQueue:N}=s(2534),{WebsocketFrameSend:k}=s(6834),{channels:T}=s(772);class F extends EventTarget{#Oe={open:null,error:null,close:null,message:null};#Nt=0;#kt="";#ht="";#Tt;#U={onConnectionEstablished:(e,t)=>this.#yt(e,t),onMessage:(e,t)=>this.#wt(e,t),onParserError:e=>y(this.#U,null,e.message),onParserDrain:()=>this.#Ft(),onSocketData:e=>{this.#St.write(e)||this.#U.socket.pause()},onSocketError:e=>{this.#U.readyState=a.CLOSING,T.socketError.hasSubscribers&&T.socketError.publish(e),this.#U.socket.destroy()},onSocketClose:()=>this.#Dt(),onPing:e=>{T.ping.hasSubscribers&&T.ping.publish({payload:e,websocket:this})},onPong:e=>{T.pong.hasSubscribers&&T.pong.publish({payload:e,websocket:this})},readyState:a.CONNECTING,socket:null,closeState:new Set,controller:null,wasEverConnected:!1};#Ge;#Mt;#St;constructor(e,t=[]){super(),n.util.markAsUncloneable(this);const s="WebSocket constructor";n.argumentLengthCheck(arguments,1,s);const r=n.converters["DOMString or sequence<DOMString> or WebSocketInit"](t,s,"options");e=n.converters.USVString(e),t=r.protocols;const i=A.settingsObject.baseUrl,o=f(e,i);if("string"==typeof t&&(t=[t]),t.length!==new Set(t.map((e=>e.toLowerCase()))).size)throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");if(t.length>0&&!t.every((e=>I(e))))throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");this.#Ge=new URL(o.href);const a=A.settingsObject;this.#U.controller=Q(o,t,a,this.#U,r),this.#U.readyState=F.CONNECTING,this.#Mt="blob"}close(e=void 0,t=void 0){n.brandCheck(this,F);void 0!==e&&(e=n.converters["unsigned short"](e,"WebSocket.close","code",n.attributes.Clamp)),void 0!==t&&(t=n.converters.USVString(t)),e??=null,t??="",m(this.#U,e,t,!0)}send(e){n.brandCheck(this,F);const t="WebSocket.send";if(n.argumentLengthCheck(arguments,1,t),e=n.converters.WebSocketSendData(e,t,"data"),g(this.#U.readyState))throw new DOMException("Sent before connected.","InvalidStateError");if(d(this.#U.readyState)&&!u(this.#U.readyState))if("string"==typeof e){const t=Buffer.from(e);this.#Nt+=t.byteLength,this.#Tt.add(t,(()=>{this.#Nt-=t.byteLength}),l.text)}else r(e)?(this.#Nt+=e.byteLength,this.#Tt.add(e,(()=>{this.#Nt-=e.byteLength}),l.arrayBuffer)):ArrayBuffer.isView(e)?(this.#Nt+=e.byteLength,this.#Tt.add(e,(()=>{this.#Nt-=e.byteLength}),l.typedArray)):n.is.Blob(e)&&(this.#Nt+=e.size,this.#Tt.add(e,(()=>{this.#Nt-=e.size}),l.blob))}get readyState(){return n.brandCheck(this,F),this.#U.readyState}get bufferedAmount(){return n.brandCheck(this,F),this.#Nt}get url(){return n.brandCheck(this,F),i(this.#Ge)}get extensions(){return n.brandCheck(this,F),this.#ht}get protocol(){return n.brandCheck(this,F),this.#kt}get onopen(){return n.brandCheck(this,F),this.#Oe.open}set onopen(e){n.brandCheck(this,F),this.#Oe.open&&this.removeEventListener("open",this.#Oe.open);const t=n.converters.EventHandlerNonNull(e);null!==t?(this.addEventListener("open",t),this.#Oe.open=e):this.#Oe.open=null}get onerror(){return n.brandCheck(this,F),this.#Oe.error}set onerror(e){n.brandCheck(this,F),this.#Oe.error&&this.removeEventListener("error",this.#Oe.error);const t=n.converters.EventHandlerNonNull(e);null!==t?(this.addEventListener("error",t),this.#Oe.error=e):this.#Oe.error=null}get onclose(){return n.brandCheck(this,F),this.#Oe.close}set onclose(e){n.brandCheck(this,F),this.#Oe.close&&this.removeEventListener("close",this.#Oe.close);const t=n.converters.EventHandlerNonNull(e);null!==t?(this.addEventListener("close",t),this.#Oe.close=e):this.#Oe.close=null}get onmessage(){return n.brandCheck(this,F),this.#Oe.message}set onmessage(e){n.brandCheck(this,F),this.#Oe.message&&this.removeEventListener("message",this.#Oe.message);const t=n.converters.EventHandlerNonNull(e);null!==t?(this.addEventListener("message",t),this.#Oe.message=e):this.#Oe.message=null}get binaryType(){return n.brandCheck(this,F),this.#Mt}set binaryType(e){n.brandCheck(this,F),this.#Mt="blob"!==e&&"arraybuffer"!==e?"blob":e}#yt(e,t){this.#U.socket=e.socket;const s=new w(this.#U,t);s.on("drain",(()=>this.#U.onParserDrain())),s.on("error",(e=>this.#U.onParserError(e))),this.#St=s,this.#Tt=new N(e.socket),this.#U.readyState=a.OPEN;const r=e.headersList.get("sec-websocket-extensions");null!==r&&(this.#ht=r);const n=e.headersList.get("sec-websocket-protocol");if(null!==n&&(this.#kt=n),p("open",this),T.open.hasSubscribers){const t=e.headersList.entries;T.open.publish({address:e.socket.address(),protocol:this.#kt,extensions:this.#ht,websocket:this,handshakeResponse:{status:e.status,statusText:e.statusText,headers:t}})}}#wt(e,t){if(this.#U.readyState!==a.OPEN)return;let s;if(e===h.TEXT)try{s=C(t)}catch{return void y(this.#U,1007,"Received invalid UTF-8 in text frame.")}else e===h.BINARY&&(s="blob"===this.#Mt?new Blob([t]):B(t));p("message",this,R,{origin:this.#Ge.origin,data:s})}#Ft(){this.#U.socket.resume()}#Dt(){const e=this.#U.closeState.has(c.SENT)&&this.#U.closeState.has(c.RECEIVED);let t=1005,s="";const r=this.#St?.closingInfo;r&&!r.error&&(t=r.code??1005,s=r.reason),this.#U.readyState=a.CLOSED,this.#U.closeState.has(c.RECEIVED)||(t=1006,p("error",this,((e,t)=>new b(e,t)),{error:new TypeError(s)})),p("close",this,((e,t)=>new v(e,t)),{wasClean:e,code:t,reason:s}),T.close.hasSubscribers&&T.close.publish({websocket:this,code:t,reason:s})}static ping(e,t){if(Buffer.isBuffer(t)){if(t.length>125)throw new TypeError("A PING frame cannot have a body larger than 125 bytes.")}else if(void 0!==t)throw new TypeError("Expected buffer payload");const s=e.#U.readyState;if(d(s)&&!u(s)&&!E(s)){const s=new k(t);e.#U.socket.write(s.createFrame(h.PING))}}}const{ping:M}=F;Reflect.deleteProperty(F,"ping"),F.CONNECTING=F.prototype.CONNECTING=a.CONNECTING,F.OPEN=F.prototype.OPEN=a.OPEN,F.CLOSING=F.prototype.CLOSING=a.CLOSING,F.CLOSED=F.prototype.CLOSED=a.CLOSED,Object.defineProperties(F.prototype,{CONNECTING:o,OPEN:o,CLOSING:o,CLOSED:o,url:S,readyState:S,bufferedAmount:S,onopen:S,onerror:S,onclose:S,close:S,onmessage:S,binaryType:S,send:S,extensions:S,protocol:S,[Symbol.toStringTag]:{value:"WebSocket",writable:!1,enumerable:!1,configurable:!0}}),Object.defineProperties(F,{CONNECTING:o,OPEN:o,CLOSING:o,CLOSED:o}),n.converters["sequence<DOMString>"]=n.sequenceConverter(n.converters.DOMString),n.converters["DOMString or sequence<DOMString>"]=function(e,t,s){return n.util.Type(e)===n.util.Types.OBJECT&&Symbol.iterator in e?n.converters["sequence<DOMString>"](e):n.converters.DOMString(e,t,s)},n.converters.WebSocketInit=n.dictionaryConverter([{key:"protocols",converter:n.converters["DOMString or sequence<DOMString>"],defaultValue:()=>[]},{key:"dispatcher",converter:n.converters.any,defaultValue:()=>D()},{key:"headers",converter:n.nullableConverter(n.converters.HeadersInit)}]),n.converters["DOMString or sequence<DOMString> or WebSocketInit"]=function(e){return n.util.Type(e)!==n.util.Types.OBJECT||Symbol.iterator in e?{protocols:n.converters["DOMString or sequence<DOMString>"](e)}:n.converters.WebSocketInit(e)},n.converters.WebSocketSendData=function(e){if(n.util.Type(e)===n.util.Types.OBJECT){if(n.is.Blob(e))return e;if(n.is.BufferSource(e))return e}return n.converters.USVString(e)},e.exports={WebSocket:F,ping:M}},6822:(e,t,s)=>{var r=s(9896),n=s(2203).Transform,i=s(2203).PassThrough,A=s(3106),o=s(9023),a=s(4434).EventEmitter,c=s(4434).errorMonitor,l=s(5537);function h(){this.outputStream=new i,this.entries=[],this.outputStreamCursor=0,this.ended=!1,this.allDone=!1,this.forceZip64Eocd=!1,this.errored=!1,this.on(c,(function(){this.errored=!0}))}t.u=h,o.inherits(h,a),h.prototype.addFile=function(e,t,s){var n=this;if(t=f(t,!1),null==s&&(s={}),!I(n)){var i=new m(t,!1,s);n.entries.push(i),r.stat(e,(function(t,A){return t?n.emit("error",t):A.isFile()?(i.uncompressedSize=A.size,null==s.mtime&&i.setLastModDate(A.mtime),null==s.mode&&i.setFileAttributesMode(A.mode),i.setFileDataPumpFunction((function(){var t=r.createReadStream(e);i.state=m.FILE_DATA_IN_PROGRESS,t.on("error",(function(e){n.emit("error",e)})),u(n,i,t)})),void E(n)):n.emit("error",new Error("not a file: "+e))}))}},h.prototype.addReadStream=function(e,t,s){this.addReadStreamLazy(t,s,(function(t){t(null,e)}))},h.prototype.addReadStreamLazy=function(e,t,s){var r=this;if("function"==typeof t&&(s=t,t=null),null==t&&(t={}),e=f(e,!1),!I(r)){var n=new m(e,!1,t);r.entries.push(n),n.setFileDataPumpFunction((function(){n.state=m.FILE_DATA_IN_PROGRESS,s((function(e,t){if(e)return r.emit("error",e);u(r,n,t)}))})),E(r)}},h.prototype.addBuffer=function(e,t,s){var r=this;if(t=f(t,!1),e.length>1073741823)throw new Error("buffer too large: "+e.length+" > 1073741823");if(null==s&&(s={}),null!=s.size)throw new Error("options.size not allowed");if(!I(r)){var n=new m(t,!1,s);n.uncompressedSize=e.length,n.crc32=l.unsigned(e),n.crcAndFileSizeKnown=!0,r.entries.push(n),0===n.compressionLevel?i(e):A.deflateRaw(e,{level:n.compressionLevel},(function(e,t){i(t)}))}function i(e){n.compressedSize=e.length,n.setFileDataPumpFunction((function(){d(r,e),d(r,n.getDataDescriptor()),n.state=m.FILE_DATA_DONE,setImmediate((function(){E(r)}))})),E(r)}},h.prototype.addEmptyDirectory=function(e,t){var s=this;if(e=f(e,!0),null==t&&(t={}),null!=t.size)throw new Error("options.size not allowed");if(null!=t.compress)throw new Error("options.compress not allowed");if(null!=t.compressionLevel)throw new Error("options.compressionLevel not allowed");if(!I(s)){var r=new m(e,!0,t);s.entries.push(r),r.setFileDataPumpFunction((function(){d(s,r.getDataDescriptor()),r.state=m.FILE_DATA_DONE,E(s)})),E(s)}};var g=Y([80,75,5,6]);function d(e,t){e.outputStream.write(t),e.outputStreamCursor+=t.length}function u(e,t,s){var r=new L,n=new U,o=0!==t.compressionLevel?new A.DeflateRaw({level:t.compressionLevel}):new i,a=new U;s.pipe(r).pipe(n).pipe(o).pipe(a).pipe(e.outputStream,{end:!1}),a.on("end",(function(){if(t.crc32=r.crc32,null==t.uncompressedSize)t.uncompressedSize=n.byteCount;else if(t.uncompressedSize!==n.byteCount)return e.emit("error",new Error("file data stream has unexpected number of bytes"));t.compressedSize=a.byteCount,e.outputStreamCursor+=t.compressedSize,d(e,t.getDataDescriptor()),t.state=m.FILE_DATA_DONE,E(e)}))}function E(e){if(!e.allDone&&!e.errored){if(e.ended&&null!=e.calculatedTotalSizeCallback){var t=function(e){for(var t=0,s=0,r=0;r<e.entries.length;r++){var n=e.entries[r];if(0!==n.compressionLevel)return-1;if(n.state>=m.READY_TO_PUMP_FILE_DATA){if(null==n.uncompressedSize)return-1}else if(null==n.uncompressedSize)return null;n.relativeOffsetOfLocalHeader=t;var i=n.useZip64Format();t+=y+n.utf8FileName.length,t+=n.uncompressedSize,n.crcAndFileSizeKnown||(t+=i?b:D),s+=v+n.utf8FileName.length+n.fileComment.length,n.forceDosTimestamp||(s+=R),i&&(s+=N)}var A=0;(e.forceZip64Eocd||e.entries.length>=65535||s>=65535||t>=4294967295)&&(A+=p+C);return A+=B+e.comment.length,t+s+A}(e);null!=t&&(e.calculatedTotalSizeCallback(t),e.calculatedTotalSizeCallback=null)}var s=function(){for(var t=0;t<e.entries.length;t++){var s=e.entries[t];if(s.state<m.FILE_DATA_DONE)return s}return null}();if(null!=s){if(s.state<m.READY_TO_PUMP_FILE_DATA)return;if(s.state===m.FILE_DATA_IN_PROGRESS)return;s.relativeOffsetOfLocalHeader=e.outputStreamCursor;var r=s.getLocalFileHeader();d(e,r),s.doFileDataPump()}else e.ended&&(e.offsetOfStartOfCentralDirectory=e.outputStreamCursor,e.entries.forEach((function(t){var s=t.getCentralDirectoryRecord();d(e,s)})),d(e,function(e,t){var s=!1,r=e.entries.length;(e.forceZip64Eocd||e.entries.length>=65535)&&(r=65535,s=!0);var n=e.outputStreamCursor-e.offsetOfStartOfCentralDirectory,i=n;(e.forceZip64Eocd||n>=4294967295)&&(i=4294967295,s=!0);var A=e.offsetOfStartOfCentralDirectory;(e.forceZip64Eocd||e.offsetOfStartOfCentralDirectory>=4294967295)&&(A=4294967295,s=!0);if(t)return s?p+C+B:B;var o=H(B+e.comment.length);if(o.writeUInt32LE(101010256,0),o.writeUInt16LE(0,4),o.writeUInt16LE(0,6),o.writeUInt16LE(r,8),o.writeUInt16LE(r,10),o.writeUInt32LE(i,12),o.writeUInt32LE(A,16),o.writeUInt16LE(e.comment.length,20),e.comment.copy(o,22),!s)return o;var a=H(p);a.writeUInt32LE(101075792,0),M(a,p-12,4),a.writeUInt16LE(S,12),a.writeUInt16LE(w,14),a.writeUInt32LE(0,16),a.writeUInt32LE(0,20),M(a,e.entries.length,24),M(a,e.entries.length,32),M(a,n,40),M(a,e.offsetOfStartOfCentralDirectory,48);var c=H(C);return c.writeUInt32LE(117853008,0),c.writeUInt32LE(0,4),M(c,e.outputStreamCursor,8),c.writeUInt32LE(1,16),Buffer.concat([a,c,o])}(e)),e.outputStream.end(),e.allDone=!0)}}function I(e){if(e.ended)throw new Error("cannot add entries after calling end()");return!!e.errored}h.prototype.end=function(e,t){if("function"==typeof e&&(t=e,e=null),null==e&&(e={}),!this.ended&&(this.ended=!0,!this.errored)){if(this.calculatedTotalSizeCallback=t,this.forceZip64Eocd=!!e.forceZip64Format,e.comment){if("string"==typeof e.comment?this.comment=function(e){if(/^[\x20-\x7e]*$/.test(e))return Y(e,"utf-8");if(null==x){x={};for(var t=0;t<P.length;t++)x[P[t]]=t}var s=H(e.length);for(t=0;t<e.length;t++){var r=x[e[t]];if(null==r)throw new Error("character not encodable in CP437: "+JSON.stringify(e[t]));s[t]=r}return s}(e.comment):this.comment=e.comment,this.comment.length>65535)throw new Error("comment is too large");if(V(this.comment,g))throw new Error("comment contains end of central directory record signature")}else this.comment=Q;E(this)}};var p=56,C=20,B=22;function f(e,t){if(""===e)throw new Error("empty metadataPath");if(e=e.replace(/\\/g,"/"),/^[a-zA-Z]:/.test(e)||/^\//.test(e))throw new Error("absolute path: "+e);if(-1!==e.split("/").indexOf(".."))throw new Error("invalid relative path: "+e);var s=/\/$/.test(e);if(t)s||(e+="/");else if(s)throw new Error("file path cannot end with '/': "+e);return e}var Q=H(0);function m(e,t,s){if(this.utf8FileName=Y(e),this.utf8FileName.length>65535)throw new Error("utf8 file name too long. "+utf8FileName.length+" > 65535");if(this.isDirectory=t,this.state=m.WAITING_FOR_METADATA,this.setLastModDate(null!=s.mtime?s.mtime:new Date),this.forceDosTimestamp=!!s.forceDosTimestamp,null!=s.mode?this.setFileAttributesMode(s.mode):this.setFileAttributesMode(t?16893:33204),t?(this.crcAndFileSizeKnown=!0,this.crc32=0,this.uncompressedSize=0,this.compressedSize=0):(this.crcAndFileSizeKnown=!1,this.crc32=null,this.uncompressedSize=null,this.compressedSize=null,null!=s.size&&(this.uncompressedSize=s.size)),this.compressionLevel=t?0:function(e){if(null!=e.compress&&null!=e.compressionLevel&&!!e.compress!=!!e.compressionLevel)throw new Error("conflicting settings for compress and compressionLevel");return null!=e.compressionLevel?e.compressionLevel:!1===e.compress?0:6}(s),this.forceZip64Format=!!s.forceZip64Format,s.fileComment){if("string"==typeof s.fileComment?this.fileComment=Y(s.fileComment,"utf-8"):this.fileComment=s.fileComment,this.fileComment.length>65535)throw new Error("fileComment is too large")}else this.fileComment=Q}m.WAITING_FOR_METADATA=0,m.READY_TO_PUMP_FILE_DATA=1,m.FILE_DATA_IN_PROGRESS=2,m.FILE_DATA_DONE=3,m.prototype.setLastModDate=function(e){this.mtime=e;var t=F(e);this.lastModFileTime=t.time,this.lastModFileDate=t.date},m.prototype.setFileAttributesMode=function(e){if((65535&e)!==e)throw new Error("invalid mode. expected: 0 <= "+e+" <= 65535");this.externalFileAttributes=e<<16>>>0},m.prototype.setFileDataPumpFunction=function(e){this.doFileDataPump=e,this.state=m.READY_TO_PUMP_FILE_DATA},m.prototype.useZip64Format=function(){return this.forceZip64Format||null!=this.uncompressedSize&&this.uncompressedSize>4294967294||null!=this.compressedSize&&this.compressedSize>4294967294||null!=this.relativeOffsetOfLocalHeader&&this.relativeOffsetOfLocalHeader>4294967294};var y=30,w=45,S=831;m.prototype.getLocalFileHeader=function(){var e=0,t=0,s=0;this.crcAndFileSizeKnown&&(e=this.crc32,t=this.compressedSize,s=this.uncompressedSize);var r=H(y),n=2048;return this.crcAndFileSizeKnown||(n|=8),r.writeUInt32LE(67324752,0),r.writeUInt16LE(20,4),r.writeUInt16LE(n,6),r.writeUInt16LE(this.getCompressionMethod(),8),r.writeUInt16LE(this.lastModFileTime,10),r.writeUInt16LE(this.lastModFileDate,12),r.writeUInt32LE(e,14),r.writeUInt32LE(t,18),r.writeUInt32LE(s,22),r.writeUInt16LE(this.utf8FileName.length,26),r.writeUInt16LE(0,28),Buffer.concat([r,this.utf8FileName])};var D=16,b=24;m.prototype.getDataDescriptor=function(){return this.crcAndFileSizeKnown?Q:this.useZip64Format()?((e=H(b)).writeUInt32LE(134695760,0),e.writeUInt32LE(this.crc32,4),M(e,this.compressedSize,8),M(e,this.uncompressedSize,16),e):((e=H(D)).writeUInt32LE(134695760,0),e.writeUInt32LE(this.crc32,4),e.writeUInt32LE(this.compressedSize,8),e.writeUInt32LE(this.uncompressedSize,12),e);var e};var v=46,R=9,N=28;m.prototype.getCentralDirectoryRecord=function(){var e=H(v),t=2048;this.crcAndFileSizeKnown||(t|=8);var s=Q;if(!this.forceDosTimestamp){(s=H(R)).writeUInt16LE(21589,0),s.writeUInt16LE(R-4,2);s.writeUInt8(3,4);var r=Math.floor(this.mtime.getTime()/1e3);r<-2147483648&&(r=-2147483648),r>2147483647&&(r=2147483647),s.writeUInt32LE(r,5)}var n=this.compressedSize,i=this.uncompressedSize,A=this.relativeOffsetOfLocalHeader,o=20,a=Q;return this.useZip64Format()&&(n=4294967295,i=4294967295,A=4294967295,o=w,(a=H(N)).writeUInt16LE(1,0),a.writeUInt16LE(N-4,2),M(a,this.uncompressedSize,4),M(a,this.compressedSize,12),M(a,this.relativeOffsetOfLocalHeader,20)),e.writeUInt32LE(33639248,0),e.writeUInt16LE(S,4),e.writeUInt16LE(o,6),e.writeUInt16LE(t,8),e.writeUInt16LE(this.getCompressionMethod(),10),e.writeUInt16LE(this.lastModFileTime,12),e.writeUInt16LE(this.lastModFileDate,14),e.writeUInt32LE(this.crc32,16),e.writeUInt32LE(n,20),e.writeUInt32LE(i,24),e.writeUInt16LE(this.utf8FileName.length,28),e.writeUInt16LE(s.length+a.length,30),e.writeUInt16LE(this.fileComment.length,32),e.writeUInt16LE(0,34),e.writeUInt16LE(0,36),e.writeUInt32LE(this.externalFileAttributes,38),e.writeUInt32LE(A,42),Buffer.concat([e,this.utf8FileName,s,a,this.fileComment])},m.prototype.getCompressionMethod=function(){return 0===this.compressionLevel?0:8};var k=new Date(1980,0,1),T=new Date(2107,11,31,23,59,58);function F(e){e<k?e=k:e>T&&(e=T);var t=0;t|=31&e.getDate(),t|=(e.getMonth()+1&15)<<5,t|=(e.getFullYear()-1980&127)<<9;var s=0;return s|=Math.floor(e.getSeconds()/2),s|=(63&e.getMinutes())<<5,{date:t,time:s|=(31&e.getHours())<<11}}function M(e,t,s){var r=Math.floor(t/4294967296),n=t%4294967296;e.writeUInt32LE(n,s),e.writeUInt32LE(r,s+4)}function U(e){n.call(this,e),this.byteCount=0}function L(e){n.call(this,e),this.crc32=0}o.inherits(U,n),U.prototype._transform=function(e,t,s){this.byteCount+=e.length,s(null,e)},o.inherits(L,n),L.prototype._transform=function(e,t,s){this.crc32=l.unsigned(e,this.crc32),s(null,e)};var P="\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ";if(256!==P.length)throw new Error("assertion failure");var x=null;function H(e){H=function(e){return Buffer.allocUnsafe(e)};try{return H(e)}catch(t){return H=function(e){return new Buffer(e)},H(e)}}function Y(e,t){Y=function(e,t){return Buffer.from(e,t)};try{return Y(e,t)}catch(s){return Y=function(e,t){return new Buffer(e,t)},Y(e,t)}}function V(e,t){V=function(e,t){return e.includes(t)};try{return V(e,t)}catch(s){return V=function(e,t){for(var s=0;s<=e.length-t.length;s++)for(var r=0;;r++){if(r===t.length)return!0;if(e[s+r]!==t[r])break}return!1},V(e,t)}}},7562:function(e,t,s){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,n)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),n=this&&this.__exportStar||function(e,t){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(t,s)||r(t,e,s)};Object.defineProperty(t,"__esModule",{value:!0}),t.sdk=t.MixinDeviceBase=t.ScryptedDeviceBase=void 0,n(s(4192),t);const i=s(4192);s(3339);class A extends i.DeviceBase{constructor(e){super(),this.nativeId=e}get storage(){return this._storage||(this._storage=t.sdk.deviceManager.getDeviceStorage(this.nativeId)),this._storage}get log(){return this._log||(this._log=t.sdk.deviceManager.getDeviceLogger(this.nativeId)),this._log}get console(){return this._console||(this._console=t.sdk.deviceManager.getDeviceConsole(this.nativeId)),this._console}async createMediaObject(e,s){return t.sdk.mediaManager.createMediaObject(e,s,{sourceId:this.id})}getMediaObjectConsole(e){return"string"!=typeof e.sourceId?this.console:t.sdk.deviceManager.getMixinConsole(e.sourceId,this.nativeId)}_lazyLoadDeviceState(){this._deviceState||(this.nativeId?this._deviceState=t.sdk.deviceManager.getDeviceState(this.nativeId):this._deviceState=t.sdk.deviceManager.getDeviceState())}onDeviceEvent(e,s){return t.sdk.deviceManager.onDeviceEvent(this.nativeId,e,s)}}t.ScryptedDeviceBase=A;class o extends i.DeviceBase{constructor(e){super(),this._listeners=new Set,this.mixinDevice=e.mixinDevice,this.mixinDeviceInterfaces=e.mixinDeviceInterfaces,this.mixinStorageSuffix=e.mixinStorageSuffix,this._deviceState=e.mixinDeviceState,this.nativeId=t.sdk.systemManager.getDeviceById(this.id).nativeId,this.mixinProviderNativeId=e.mixinProviderNativeId,this._deviceState.__rpcproxy_traps_all_properties&&"string"==typeof this._deviceState.id&&(this._deviceState=t.sdk.deviceManager.createDeviceState(this._deviceState.id,this._deviceState.setState))}get storage(){if(!this._storage){const e=this.mixinStorageSuffix,s=this.id+(e?":"+e:"");this._storage=t.sdk.deviceManager.getMixinStorage(s,this.mixinProviderNativeId)}return this._storage}get console(){return this._console||(t.sdk.deviceManager.getMixinConsole?this._console=t.sdk.deviceManager.getMixinConsole(this.id,this.mixinProviderNativeId):this._console=t.sdk.deviceManager.getDeviceConsole(this.mixinProviderNativeId)),this._console}async createMediaObject(e,s){return t.sdk.mediaManager.createMediaObject(e,s,{sourceId:this.id})}getMediaObjectConsole(e){return"string"!=typeof e.sourceId?this.console:t.sdk.deviceManager.getMixinConsole(e.sourceId,this.mixinProviderNativeId)}onDeviceEvent(e,s){return t.sdk.deviceManager.onMixinEvent(this.id,this,e,s)}_lazyLoadDeviceState(){}manageListener(e){this._listeners.add(e)}release(){for(const e of this._listeners)e.removeListener()}}t.MixinDeviceBase=o,function(){function e(e){return function(){return this._lazyLoadDeviceState(),this._deviceState?.[e]}}function t(e){return function(t){this._lazyLoadDeviceState(),this._deviceState?this._deviceState[e]=t:console.warn("device state is unavailable. the device must be discovered with deviceManager.onDeviceDiscovered or deviceManager.onDevicesChanged before the state can be set.")}}for(const s of Object.values(i.ScryptedInterfaceProperty))s!==i.ScryptedInterfaceProperty.nativeId&&(Object.defineProperty(A.prototype,s,{set:t(s),get:e(s)}),Object.defineProperty(o.prototype,s,{set:t(s),get:e(s)}))}(),t.sdk={};try{let e=!1;try{process.env.SCRYPTED_SDK_ES_MODULE||process.env.SCRYPTED_SDK_MODULE;const r=process.env.SCRYPTED_SDK_CJS_MODULE||process.env.SCRYPTED_SDK_MODULE;if(r)if("undefined"!=typeof require){const s=require(process.env.SCRYPTED_SDK_MODULE);Object.assign(t.sdk,s.getScryptedStatic()),e=!0}else{const n=s(3891)(r);Object.assign(t.sdk,n.getScryptedStatic()),e=!0}}catch(e){throw console.warn("failed to load sdk module",e),e}if(!e){let e;try{e=pluginRuntimeAPI}catch(e){}Object.assign(t.sdk,{log:deviceManager.getDeviceLogger(void 0),deviceManager,endpointManager,mediaManager,systemManager,pluginHostAPI,...e})}try{t.sdk.systemManager.setScryptedInterfaceDescriptors?.(i.TYPES_VERSION,i.ScryptedInterfaceDescriptors)?.catch((()=>{}))}catch(e){}}catch(e){console.error("sdk initialization error, import @scrypted/types or use @scrypted/client instead",e)}t.default=t.sdk},6117:function(e,t,s){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,n)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.prototype.hasOwnProperty.call(e,s)&&r(t,e,s);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.StorageSettings=void 0;const A=i(s(7562)),{systemManager:o}=A.default;t.StorageSettings=class{constructor(e,t){this.device=e,this.settings=t,this.values={},this.hasValue={};for(const e of Object.keys(t)){const s=t[e],r=()=>this.getItem(e);let n;n="clippath"!==s.type?r:()=>{try{return JSON.parse(r())}catch(e){}},Object.defineProperty(this.values,e,{get:n,set:t=>this.putSetting(e,t),enumerable:!0}),Object.defineProperty(this.hasValue,e,{get:()=>null!=this.device.storage.getItem(e),enumerable:!0})}}get keys(){const e={};for(const t of Object.keys(this.settings))e[t]=t;return e}async getSettings(){const e=await(this.options?.onGet?.()),t=[];for(const[s,r]of Object.entries(this.settings)){let n=Object.assign({},r);e?.[s]&&(n=Object.assign(n,e[s])),n.onGet&&(n=Object.assign(n,await n.onGet())),n.hide||await(this.options?.hide?.[s]?.())||(n.key=s,n.value=this.getItemInternal(s,n,!0),"function"==typeof n.deviceFilter&&(n.deviceFilter=n.deviceFilter.toString()),t.push(n),delete n.onPut,delete n.onGet,delete n.mapPut,delete n.mapGet)}return t}async putSetting(e,t){const s=this.settings[e];let r;return s&&(r=this.getItemInternal(e,s)),this.putSettingInternal(s,r,e,t)}putSettingInternal(e,t,s,r){e?.noStore||(e?.mapPut&&(r=e.mapPut(t,r)),null==r?this.device.storage.removeItem(s):"object"==typeof r?this.device.storage.setItem(s,JSON.stringify(r)):this.device.storage.setItem(s,r?.toString())),e?.onPut?.(t,r),e?.hide||this.device.onDeviceEvent(A.ScryptedInterface.Settings,void 0)}getItemInternal(e,t,s){if(!t)return this.device.storage.getItem(e);const r=function(e,t,s,r){if(null==e)return s();const n=t.multiple?"array":t.type;if("boolean"===n)return"true"===e||"false"!==e&&(s()||!1);if("number"===n){const t=parseFloat(e);return isNaN(t)?s()||0:t}if("integer"===n){const t=parseInt(e);return isNaN(t)?s()||0:t}if("array"===n){if(!e)return s()||[];try{return JSON.parse(e)}catch(e){return s()||[]}}if("device"===n)return r?e:o.getDeviceById(e)||o.getDeviceById(s());if(e&&t.json)try{return JSON.parse(e)}catch(e){return s()}return e||s()}(this.device.storage.getItem(e),t,(()=>null!=t.persistedDefaultValue?(this.putSettingInternal(t,void 0,e,t.persistedDefaultValue),t.persistedDefaultValue):t.defaultValue),s);return t.mapGet?t.mapGet(r):r}getItem(e){return this.getItemInternal(e,this.settings[e])}}},3891:e=>{function t(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=3891,e.exports=t},4192:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ScryptedMimeTypes=t.ScryptedInterface=t.MediaPlayerState=t.SecuritySystemObstruction=t.SecuritySystemMode=t.AirQuality=t.AirPurifierMode=t.AirPurifierStatus=t.ChargeState=t.LockState=t.PanTiltZoomMovement=t.ThermostatMode=t.TemperatureUnit=t.FanMode=t.HumidityMode=t.ScryptedDeviceType=t.ScryptedInterfaceDescriptors=t.ScryptedInterfaceMethod=t.ScryptedInterfaceProperty=t.DeviceBase=t.TYPES_VERSION=void 0,t.TYPES_VERSION="0.3.108";var s,r,n,i,A,o,a,c,l,h,g,d,u,E,I,p,C,B;t.DeviceBase=class{},function(e){e.id="id",e.info="info",e.interfaces="interfaces",e.mixins="mixins",e.name="name",e.nativeId="nativeId",e.pluginId="pluginId",e.providedInterfaces="providedInterfaces",e.providedName="providedName",e.providedRoom="providedRoom",e.providedType="providedType",e.providerId="providerId",e.room="room",e.type="type",e.scryptedRuntimeArguments="scryptedRuntimeArguments",e.on="on",e.brightness="brightness",e.colorTemperature="colorTemperature",e.rgb="rgb",e.hsv="hsv",e.buttons="buttons",e.sensors="sensors",e.running="running",e.paused="paused",e.docked="docked",e.temperatureSetting="temperatureSetting",e.temperature="temperature",e.temperatureUnit="temperatureUnit",e.humidity="humidity",e.audioVolumes="audioVolumes",e.recordingActive="recordingActive",e.ptzCapabilities="ptzCapabilities",e.lockState="lockState",e.entryOpen="entryOpen",e.batteryLevel="batteryLevel",e.chargeState="chargeState",e.online="online",e.fromMimeType="fromMimeType",e.toMimeType="toMimeType",e.converters="converters",e.binaryState="binaryState",e.tampered="tampered",e.sleeping="sleeping",e.powerDetected="powerDetected",e.audioDetected="audioDetected",e.motionDetected="motionDetected",e.ambientLight="ambientLight",e.occupied="occupied",e.flooded="flooded",e.ultraviolet="ultraviolet",e.luminance="luminance",e.position="position",e.securitySystemState="securitySystemState",e.pm10Density="pm10Density",e.pm25Density="pm25Density",e.vocDensity="vocDensity",e.noxDensity="noxDensity",e.co2ppm="co2ppm",e.airQuality="airQuality",e.airPurifierState="airPurifierState",e.filterChangeIndication="filterChangeIndication",e.filterLifeLevel="filterLifeLevel",e.humiditySetting="humiditySetting",e.fan="fan",e.applicationInfo="applicationInfo",e.systemDevice="systemDevice"}(s||(t.ScryptedInterfaceProperty=s={})),function(e){e.listen="listen",e.probe="probe",e.setMixins="setMixins",e.setName="setName",e.setRoom="setRoom",e.setType="setType",e.getPluginJson="getPluginJson",e.turnOff="turnOff",e.turnOn="turnOn",e.setBrightness="setBrightness",e.getTemperatureMaxK="getTemperatureMaxK",e.getTemperatureMinK="getTemperatureMinK",e.setColorTemperature="setColorTemperature",e.setRgb="setRgb",e.setHsv="setHsv",e.pressButton="pressButton",e.sendNotification="sendNotification",e.start="start",e.stop="stop",e.pause="pause",e.resume="resume",e.dock="dock",e.setTemperature="setTemperature",e.setTemperatureUnit="setTemperatureUnit",e.getPictureOptions="getPictureOptions",e.takePicture="takePicture",e.getAudioStream="getAudioStream",e.setAudioVolumes="setAudioVolumes",e.startDisplay="startDisplay",e.stopDisplay="stopDisplay",e.getVideoStream="getVideoStream",e.getVideoStreamOptions="getVideoStreamOptions",e.getPrivacyMasks="getPrivacyMasks",e.setPrivacyMasks="setPrivacyMasks",e.getVideoTextOverlays="getVideoTextOverlays",e.setVideoTextOverlay="setVideoTextOverlay",e.getRecordingStream="getRecordingStream",e.getRecordingStreamCurrentTime="getRecordingStreamCurrentTime",e.getRecordingStreamOptions="getRecordingStreamOptions",e.getRecordingStreamThumbnail="getRecordingStreamThumbnail",e.deleteRecordingStream="deleteRecordingStream",e.setRecordingActive="setRecordingActive",e.ptzCommand="ptzCommand",e.getRecordedEvents="getRecordedEvents",e.getVideoClip="getVideoClip",e.getVideoClips="getVideoClips",e.getVideoClipThumbnail="getVideoClipThumbnail",e.removeVideoClips="removeVideoClips",e.setVideoStreamOptions="setVideoStreamOptions",e.startIntercom="startIntercom",e.stopIntercom="stopIntercom",e.lock="lock",e.unlock="unlock",e.addPassword="addPassword",e.getPasswords="getPasswords",e.removePassword="removePassword",e.activate="activate",e.deactivate="deactivate",e.isReversible="isReversible",e.closeEntry="closeEntry",e.openEntry="openEntry",e.getDevice="getDevice",e.releaseDevice="releaseDevice",e.adoptDevice="adoptDevice",e.discoverDevices="discoverDevices",e.createDevice="createDevice",e.getCreateDeviceSettings="getCreateDeviceSettings",e.reboot="reboot",e.getRefreshFrequency="getRefreshFrequency",e.refresh="refresh",e.getMediaStatus="getMediaStatus",e.load="load",e.seek="seek",e.skipNext="skipNext",e.skipPrevious="skipPrevious",e.convert="convert",e.convertMedia="convertMedia",e.getSettings="getSettings",e.putSetting="putSetting",e.armSecuritySystem="armSecuritySystem",e.disarmSecuritySystem="disarmSecuritySystem",e.setAirPurifierState="setAirPurifierState",e.getReadmeMarkdown="getReadmeMarkdown",e.getOauthUrl="getOauthUrl",e.onOauthCallback="onOauthCallback",e.canMixin="canMixin",e.getMixin="getMixin",e.releaseMixin="releaseMixin",e.onRequest="onRequest",e.onConnection="onConnection",e.onPush="onPush",e.run="run",e.eval="eval",e.loadScripts="loadScripts",e.saveScript="saveScript",e.forkInterface="forkInterface",e.trackObjects="trackObjects",e.getDetectionInput="getDetectionInput",e.getObjectTypes="getObjectTypes",e.detectObjects="detectObjects",e.generateObjectDetections="generateObjectDetections",e.getDetectionModel="getDetectionModel",e.setHumidity="setHumidity",e.setFan="setFan",e.startRTCSignalingSession="startRTCSignalingSession",e.createRTCSignalingSession="createRTCSignalingSession",e.getScryptedUserAccessControl="getScryptedUserAccessControl",e.generateVideoFrames="generateVideoFrames",e.connectStream="connectStream",e.getTTYSettings="getTTYSettings"}(r||(t.ScryptedInterfaceMethod=r={})),t.ScryptedInterfaceDescriptors={ScryptedDevice:{name:"ScryptedDevice",methods:["listen","probe","setMixins","setName","setRoom","setType"],properties:["id","info","interfaces","mixins","name","nativeId","pluginId","providedInterfaces","providedName","providedRoom","providedType","providerId","room","type"]},ScryptedPlugin:{name:"ScryptedPlugin",methods:["getPluginJson"],properties:[]},ScryptedPluginRuntime:{name:"ScryptedPluginRuntime",methods:[],properties:["scryptedRuntimeArguments"]},OnOff:{name:"OnOff",methods:["turnOff","turnOn"],properties:["on"]},Brightness:{name:"Brightness",methods:["setBrightness"],properties:["brightness"]},ColorSettingTemperature:{name:"ColorSettingTemperature",methods:["getTemperatureMaxK","getTemperatureMinK","setColorTemperature"],properties:["colorTemperature"]},ColorSettingRgb:{name:"ColorSettingRgb",methods:["setRgb"],properties:["rgb"]},ColorSettingHsv:{name:"ColorSettingHsv",methods:["setHsv"],properties:["hsv"]},Buttons:{name:"Buttons",methods:[],properties:["buttons"]},PressButtons:{name:"PressButtons",methods:["pressButton"],properties:[]},Sensors:{name:"Sensors",methods:[],properties:["sensors"]},Notifier:{name:"Notifier",methods:["sendNotification"],properties:[]},StartStop:{name:"StartStop",methods:["start","stop"],properties:["running"]},Pause:{name:"Pause",methods:["pause","resume"],properties:["paused"]},Dock:{name:"Dock",methods:["dock"],properties:["docked"]},TemperatureSetting:{name:"TemperatureSetting",methods:["setTemperature"],properties:["temperatureSetting"]},Thermometer:{name:"Thermometer",methods:["setTemperatureUnit"],properties:["temperature","temperatureUnit"]},HumiditySensor:{name:"HumiditySensor",methods:[],properties:["humidity"]},Camera:{name:"Camera",methods:["getPictureOptions","takePicture"],properties:[]},Microphone:{name:"Microphone",methods:["getAudioStream"],properties:[]},AudioVolumeControl:{name:"AudioVolumeControl",methods:["setAudioVolumes"],properties:["audioVolumes"]},Display:{name:"Display",methods:["startDisplay","stopDisplay"],properties:[]},VideoCamera:{name:"VideoCamera",methods:["getVideoStream","getVideoStreamOptions"],properties:[]},VideoCameraMask:{name:"VideoCameraMask",methods:["getPrivacyMasks","setPrivacyMasks"],properties:[]},VideoTextOverlays:{name:"VideoTextOverlays",methods:["getVideoTextOverlays","setVideoTextOverlay"],properties:[]},VideoRecorder:{name:"VideoRecorder",methods:["getRecordingStream","getRecordingStreamCurrentTime","getRecordingStreamOptions","getRecordingStreamThumbnail"],properties:["recordingActive"]},VideoRecorderManagement:{name:"VideoRecorderManagement",methods:["deleteRecordingStream","setRecordingActive"],properties:[]},PanTiltZoom:{name:"PanTiltZoom",methods:["ptzCommand"],properties:["ptzCapabilities"]},EventRecorder:{name:"EventRecorder",methods:["getRecordedEvents"],properties:[]},VideoClips:{name:"VideoClips",methods:["getVideoClip","getVideoClips","getVideoClipThumbnail","removeVideoClips"],properties:[]},VideoCameraConfiguration:{name:"VideoCameraConfiguration",methods:["setVideoStreamOptions"],properties:[]},Intercom:{name:"Intercom",methods:["startIntercom","stopIntercom"],properties:[]},Lock:{name:"Lock",methods:["lock","unlock"],properties:["lockState"]},PasswordStore:{name:"PasswordStore",methods:["addPassword","getPasswords","removePassword"],properties:[]},Scene:{name:"Scene",methods:["activate","deactivate","isReversible"],properties:[]},Entry:{name:"Entry",methods:["closeEntry","openEntry"],properties:[]},EntrySensor:{name:"EntrySensor",methods:[],properties:["entryOpen"]},DeviceProvider:{name:"DeviceProvider",methods:["getDevice","releaseDevice"],properties:[]},DeviceDiscovery:{name:"DeviceDiscovery",methods:["adoptDevice","discoverDevices"],properties:[]},DeviceCreator:{name:"DeviceCreator",methods:["createDevice","getCreateDeviceSettings"],properties:[]},Battery:{name:"Battery",methods:[],properties:["batteryLevel"]},Charger:{name:"Charger",methods:[],properties:["chargeState"]},Reboot:{name:"Reboot",methods:["reboot"],properties:[]},Refresh:{name:"Refresh",methods:["getRefreshFrequency","refresh"],properties:[]},MediaPlayer:{name:"MediaPlayer",methods:["getMediaStatus","load","seek","skipNext","skipPrevious"],properties:[]},Online:{name:"Online",methods:[],properties:["online"]},BufferConverter:{name:"BufferConverter",methods:["convert"],properties:["fromMimeType","toMimeType"]},MediaConverter:{name:"MediaConverter",methods:["convertMedia"],properties:["converters"]},Settings:{name:"Settings",methods:["getSettings","putSetting"],properties:[]},BinarySensor:{name:"BinarySensor",methods:[],properties:["binaryState"]},TamperSensor:{name:"TamperSensor",methods:[],properties:["tampered"]},Sleep:{name:"Sleep",methods:[],properties:["sleeping"]},PowerSensor:{name:"PowerSensor",methods:[],properties:["powerDetected"]},AudioSensor:{name:"AudioSensor",methods:[],properties:["audioDetected"]},MotionSensor:{name:"MotionSensor",methods:[],properties:["motionDetected"]},AmbientLightSensor:{name:"AmbientLightSensor",methods:[],properties:["ambientLight"]},OccupancySensor:{name:"OccupancySensor",methods:[],properties:["occupied"]},FloodSensor:{name:"FloodSensor",methods:[],properties:["flooded"]},UltravioletSensor:{name:"UltravioletSensor",methods:[],properties:["ultraviolet"]},LuminanceSensor:{name:"LuminanceSensor",methods:[],properties:["luminance"]},PositionSensor:{name:"PositionSensor",methods:[],properties:["position"]},SecuritySystem:{name:"SecuritySystem",methods:["armSecuritySystem","disarmSecuritySystem"],properties:["securitySystemState"]},PM10Sensor:{name:"PM10Sensor",methods:[],properties:["pm10Density"]},PM25Sensor:{name:"PM25Sensor",methods:[],properties:["pm25Density"]},VOCSensor:{name:"VOCSensor",methods:[],properties:["vocDensity"]},NOXSensor:{name:"NOXSensor",methods:[],properties:["noxDensity"]},CO2Sensor:{name:"CO2Sensor",methods:[],properties:["co2ppm"]},AirQualitySensor:{name:"AirQualitySensor",methods:[],properties:["airQuality"]},AirPurifier:{name:"AirPurifier",methods:["setAirPurifierState"],properties:["airPurifierState"]},FilterMaintenance:{name:"FilterMaintenance",methods:[],properties:["filterChangeIndication","filterLifeLevel"]},Readme:{name:"Readme",methods:["getReadmeMarkdown"],properties:[]},OauthClient:{name:"OauthClient",methods:["getOauthUrl","onOauthCallback"],properties:[]},MixinProvider:{name:"MixinProvider",methods:["canMixin","getMixin","releaseMixin"],properties:[]},HttpRequestHandler:{name:"HttpRequestHandler",methods:["onRequest"],properties:[]},EngineIOHandler:{name:"EngineIOHandler",methods:["onConnection"],properties:[]},PushHandler:{name:"PushHandler",methods:["onPush"],properties:[]},Program:{name:"Program",methods:["run"],properties:[]},Scriptable:{name:"Scriptable",methods:["eval","loadScripts","saveScript"],properties:[]},ClusterForkInterface:{name:"ClusterForkInterface",methods:["forkInterface"],properties:[]},ObjectTracker:{name:"ObjectTracker",methods:["trackObjects"],properties:[]},ObjectDetector:{name:"ObjectDetector",methods:["getDetectionInput","getObjectTypes"],properties:[]},ObjectDetection:{name:"ObjectDetection",methods:["detectObjects","generateObjectDetections","getDetectionModel"],properties:[]},ObjectDetectionPreview:{name:"ObjectDetectionPreview",methods:[],properties:[]},ObjectDetectionGenerator:{name:"ObjectDetectionGenerator",methods:[],properties:[]},HumiditySetting:{name:"HumiditySetting",methods:["setHumidity"],properties:["humiditySetting"]},Fan:{name:"Fan",methods:["setFan"],properties:["fan"]},RTCSignalingChannel:{name:"RTCSignalingChannel",methods:["startRTCSignalingSession"],properties:[]},RTCSignalingClient:{name:"RTCSignalingClient",methods:["createRTCSignalingSession"],properties:[]},LauncherApplication:{name:"LauncherApplication",methods:[],properties:["applicationInfo"]},ScryptedUser:{name:"ScryptedUser",methods:["getScryptedUserAccessControl"],properties:[]},VideoFrameGenerator:{name:"VideoFrameGenerator",methods:["generateVideoFrames"],properties:[]},StreamService:{name:"StreamService",methods:["connectStream"],properties:[]},TTY:{name:"TTY",methods:[],properties:[]},TTYSettings:{name:"TTYSettings",methods:["getTTYSettings"],properties:[]},ScryptedSystemDevice:{name:"ScryptedSystemDevice",methods:[],properties:["systemDevice"]},ScryptedDeviceCreator:{name:"ScryptedDeviceCreator",methods:[],properties:[]},ScryptedSettings:{name:"ScryptedSettings",methods:[],properties:[]}},function(e){e.Builtin="Builtin",e.Camera="Camera",e.Fan="Fan",e.Light="Light",e.Switch="Switch",e.Outlet="Outlet",e.Sensor="Sensor",e.Scene="Scene",e.Program="Program",e.Automation="Automation",e.Vacuum="Vacuum",e.Notifier="Notifier",e.Thermostat="Thermostat",e.Lock="Lock",e.PasswordControl="PasswordControl",e.Display="Display",e.SmartDisplay="SmartDisplay",e.Speaker="Speaker",e.SmartSpeaker="SmartSpeaker",e.Event="Event",e.Entry="Entry",e.Garage="Garage",e.DeviceProvider="DeviceProvider",e.DataSource="DataSource",e.API="API",e.Doorbell="Doorbell",e.Irrigation="Irrigation",e.Valve="Valve",e.Person="Person",e.SecuritySystem="SecuritySystem",e.WindowCovering="WindowCovering",e.Siren="Siren",e.AirPurifier="AirPurifier",e.Unknown="Unknown"}(n||(t.ScryptedDeviceType=n={})),function(e){e.Humidify="Humidify",e.Dehumidify="Dehumidify",e.Auto="Auto",e.Off="Off"}(i||(t.HumidityMode=i={})),function(e){e.Auto="Auto",e.Manual="Manual"}(A||(t.FanMode=A={})),function(e){e.C="C",e.F="F"}(o||(t.TemperatureUnit=o={})),function(e){e.Off="Off",e.Cool="Cool",e.Heat="Heat",e.HeatCool="HeatCool",e.Auto="Auto",e.FanOnly="FanOnly",e.Purifier="Purifier",e.Eco="Eco",e.Dry="Dry",e.On="On"}(a||(t.ThermostatMode=a={})),function(e){e.Absolute="Absolute",e.Relative="Relative",e.Continuous="Continuous",e.Preset="Preset",e.Home="Home"}(c||(t.PanTiltZoomMovement=c={})),function(e){e.Locked="Locked",e.Unlocked="Unlocked",e.Jammed="Jammed"}(l||(t.LockState=l={})),function(e){e.Trickle="trickle",e.Charging="charging",e.NotCharging="not-charging"}(h||(t.ChargeState=h={})),function(e){e.Inactive="Inactive",e.Idle="Idle",e.Active="Active",e.ActiveNightMode="ActiveNightMode"}(g||(t.AirPurifierStatus=g={})),function(e){e.Manual="Manual",e.Automatic="Automatic"}(d||(t.AirPurifierMode=d={})),function(e){e.Unknown="Unknown",e.Excellent="Excellent",e.Good="Good",e.Fair="Fair",e.Inferior="Inferior",e.Poor="Poor"}(u||(t.AirQuality=u={})),function(e){e.Disarmed="Disarmed",e.HomeArmed="HomeArmed",e.AwayArmed="AwayArmed",e.NightArmed="NightArmed"}(E||(t.SecuritySystemMode=E={})),function(e){e.Sensor="Sensor",e.Occupied="Occupied",e.Time="Time",e.Error="Error"}(I||(t.SecuritySystemObstruction=I={})),function(e){e.Idle="Idle",e.Playing="Playing",e.Paused="Paused",e.Buffering="Buffering"}(p||(t.MediaPlayerState=p={})),function(e){e.ScryptedDevice="ScryptedDevice",e.ScryptedPlugin="ScryptedPlugin",e.ScryptedPluginRuntime="ScryptedPluginRuntime",e.OnOff="OnOff",e.Brightness="Brightness",e.ColorSettingTemperature="ColorSettingTemperature",e.ColorSettingRgb="ColorSettingRgb",e.ColorSettingHsv="ColorSettingHsv",e.Buttons="Buttons",e.PressButtons="PressButtons",e.Sensors="Sensors",e.Notifier="Notifier",e.StartStop="StartStop",e.Pause="Pause",e.Dock="Dock",e.TemperatureSetting="TemperatureSetting",e.Thermometer="Thermometer",e.HumiditySensor="HumiditySensor",e.Camera="Camera",e.Microphone="Microphone",e.AudioVolumeControl="AudioVolumeControl",e.Display="Display",e.VideoCamera="VideoCamera",e.VideoCameraMask="VideoCameraMask",e.VideoTextOverlays="VideoTextOverlays",e.VideoRecorder="VideoRecorder",e.VideoRecorderManagement="VideoRecorderManagement",e.PanTiltZoom="PanTiltZoom",e.EventRecorder="EventRecorder",e.VideoClips="VideoClips",e.VideoCameraConfiguration="VideoCameraConfiguration",e.Intercom="Intercom",e.Lock="Lock",e.PasswordStore="PasswordStore",e.Scene="Scene",e.Entry="Entry",e.EntrySensor="EntrySensor",e.DeviceProvider="DeviceProvider",e.DeviceDiscovery="DeviceDiscovery",e.DeviceCreator="DeviceCreator",e.Battery="Battery",e.Charger="Charger",e.Reboot="Reboot",e.Refresh="Refresh",e.MediaPlayer="MediaPlayer",e.Online="Online",e.BufferConverter="BufferConverter",e.MediaConverter="MediaConverter",e.Settings="Settings",e.BinarySensor="BinarySensor",e.TamperSensor="TamperSensor",e.Sleep="Sleep",e.PowerSensor="PowerSensor",e.AudioSensor="AudioSensor",e.MotionSensor="MotionSensor",e.AmbientLightSensor="AmbientLightSensor",e.OccupancySensor="OccupancySensor",e.FloodSensor="FloodSensor",e.UltravioletSensor="UltravioletSensor",e.LuminanceSensor="LuminanceSensor",e.PositionSensor="PositionSensor",e.SecuritySystem="SecuritySystem",e.PM10Sensor="PM10Sensor",e.PM25Sensor="PM25Sensor",e.VOCSensor="VOCSensor",e.NOXSensor="NOXSensor",e.CO2Sensor="CO2Sensor",e.AirQualitySensor="AirQualitySensor",e.AirPurifier="AirPurifier",e.FilterMaintenance="FilterMaintenance",e.Readme="Readme",e.OauthClient="OauthClient",e.MixinProvider="MixinProvider",e.HttpRequestHandler="HttpRequestHandler",e.EngineIOHandler="EngineIOHandler",e.PushHandler="PushHandler",e.Program="Program",e.Scriptable="Scriptable",e.ClusterForkInterface="ClusterForkInterface",e.ObjectTracker="ObjectTracker",e.ObjectDetector="ObjectDetector",e.ObjectDetection="ObjectDetection",e.ObjectDetectionPreview="ObjectDetectionPreview",e.ObjectDetectionGenerator="ObjectDetectionGenerator",e.HumiditySetting="HumiditySetting",e.Fan="Fan",e.RTCSignalingChannel="RTCSignalingChannel",e.RTCSignalingClient="RTCSignalingClient",e.LauncherApplication="LauncherApplication",e.ScryptedUser="ScryptedUser",e.VideoFrameGenerator="VideoFrameGenerator",e.StreamService="StreamService",e.TTY="TTY",e.TTYSettings="TTYSettings",e.ScryptedSystemDevice="ScryptedSystemDevice",e.ScryptedDeviceCreator="ScryptedDeviceCreator",e.ScryptedSettings="ScryptedSettings"}(C||(t.ScryptedInterface=C={})),function(e){e.Url="text/x-uri",e.InsecureLocalUrl="text/x-insecure-local-uri",e.LocalUrl="text/x-local-uri",e.ServerId="text/x-server-id",e.PushEndpoint="text/x-push-endpoint",e.SchemePrefix="x-scrypted/x-scrypted-scheme-",e.MediaStreamUrl="text/x-media-url",e.MediaObject="x-scrypted/x-scrypted-media-object",e.RequestMediaObject="x-scrypted/x-scrypted-request-media-object",e.RequestMediaStream="x-scrypted/x-scrypted-request-stream",e.MediaStreamFeedback="x-scrypted/x-media-stream-feedback",e.FFmpegInput="x-scrypted/x-ffmpeg-input",e.FFmpegTranscodeStream="x-scrypted/x-ffmpeg-transcode-stream",e.RTCSignalingChannel="x-scrypted/x-scrypted-rtc-signaling-channel",e.RTCSignalingSession="x-scrypted/x-scrypted-rtc-signaling-session",e.RTCConnectionManagement="x-scrypted/x-scrypted-rtc-connection-management",e.Image="x-scrypted/x-scrypted-image"}(B||(t.ScryptedMimeTypes=B={}))},5164:e=>{const t=require("sharp");e.exports=t},7077:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseBaichuanClass=t.BaichuanLogger=void 0;const r=s(7562),n=s(5098);class i{constructor(e,t,s){this.baseLogger=e,this.deviceName=t,this.isDebugEnabledCallback=s}formatMessage(e,...t){const s=(new Date).toLocaleString();return`${`[${this.deviceName}] [${s}] [${e}]`} ${t.map((e=>"object"==typeof e?JSON.stringify(e):String(e))).join(" ")}`}log(...e){this.baseLogger.log(this.formatMessage("LOG",...e))}error(...e){this.baseLogger.error(this.formatMessage("ERROR",...e))}warn(...e){this.baseLogger.warn(this.formatMessage("WARN",...e))}debug(...e){this.isDebugEnabledCallback()&&this.baseLogger.debug(this.formatMessage("DEBUG",...e))}assert(e,...t){this.baseLogger.assert(e,...t)}clear(){this.baseLogger.clear()}count(e){this.baseLogger.count(e)}countReset(e){this.baseLogger.countReset(e)}dir(e,t){this.baseLogger.dir(e,t)}dirxml(...e){this.baseLogger.dirxml(...e)}group(...e){this.baseLogger.group(...e)}groupCollapsed(...e){this.baseLogger.groupCollapsed(...e)}groupEnd(){this.baseLogger.groupEnd()}info(...e){this.baseLogger.info(this.formatMessage("INFO",...e))}table(e,t){this.baseLogger.table(e,t)}time(e){this.baseLogger.time(e)}timeEnd(e){this.baseLogger.timeEnd(e)}timeLog(e,...t){this.baseLogger.timeLog(e,...t)}trace(...e){this.baseLogger.trace(...e)}get memory(){return this.baseLogger.memory}get Console(){return this.baseLogger.Console}profile(e){"function"==typeof this.baseLogger.profile&&this.baseLogger.profile(e)}profileEnd(e){"function"==typeof this.baseLogger.profileEnd&&this.baseLogger.profileEnd(e)}timeStamp(e){"function"==typeof this.baseLogger.timeStamp&&this.baseLogger.timeStamp(e)}context(...e){"function"==typeof this.baseLogger.context&&this.baseLogger.context(...e)}}t.BaichuanLogger=i;class A extends r.ScryptedDeviceBase{constructor(){super(...arguments),this.lastDisconnectTime=0,this.reconnectBackoffMs=2e3,this.eventSubscriptionActive=!1}getBaichuanLogger(){return new i(this.console,this.getDeviceName(),(()=>this.isDebugEnabled()))}async onBeforeCleanup(){}async ensureBaichuanClient(){if(this.baichuanApi&&this.baichuanApi.client.isSocketConnected()&&this.baichuanApi.client.loggedIn)return this.baichuanApi;if(this.ensureClientPromise)return await this.ensureClientPromise;if(this.lastDisconnectTime>0){const e=Date.now()-this.lastDisconnectTime;if(e<this.reconnectBackoffMs){const t=this.reconnectBackoffMs-e;this.getBaichuanLogger().log(`Waiting ${t}ms before reconnection (backoff)`),await new Promise((e=>setTimeout(e,t)))}}this.ensureClientPromise=(async()=>{const e=this.getConnectionConfig();this.baichuanApi&&await this.cleanupBaichuanApi();const t=this.getBaichuanLogger(),s=await(0,n.createBaichuanApi)({inputs:{host:e.host,username:e.username,password:e.password,uid:e.uid,logger:t,debugOptions:e.debugOptions},transport:e.transport});if(await s.login(),!s.client.isSocketConnected())throw new Error("Socket not connected after login");return this.attachBaichuanListeners(s),this.baichuanApi=s,this.connectionTime=Date.now(),s})();try{return await this.ensureClientPromise}finally{this.ensureClientPromise=void 0}}attachBaichuanListeners(e){const t=this.getBaichuanLogger(),s=this.getConnectionCallbacks();this.errorListener=e=>{const r=e?.message||e?.toString?.()||String(e);if("string"==typeof r&&(r.includes("Baichuan socket closed")||r.includes("Baichuan UDP stream closed")||r.includes("Not running")))t.debug(`error (recoverable): ${r}`);else if(t.error(`error: ${r}`),s.onError)try{s.onError(e)}catch{}},this.closeListener=async()=>{try{const s=e.client.isSocketConnected(),r=e.client.loggedIn;t.log(`Connection state before close: connected=${s}, loggedIn=${r}`);const n=e.client;(n?.lastRx||n?.lastTx)&&t.debug(`Last message info: lastRx=${JSON.stringify(n.lastRx)}, lastTx=${JSON.stringify(n.lastTx)}`)}catch(e){t.debug(`Could not get connection state: ${e}`)}const r=Date.now(),n=r-this.lastDisconnectTime;if(this.lastDisconnectTime=r,t.log(`Socket closed, resetting client state for reconnection (last disconnect ${n}ms ago)`),await this.cleanupBaichuanApi(),s.onClose)try{await s.onClose()}catch{}},e.client.on("error",this.errorListener),e.client.on("close",this.closeListener)}async cleanupBaichuanApi(){if(!this.baichuanApi)return;const e=this.baichuanApi;if(await this.unsubscribeFromEvents(),await this.onBeforeCleanup(),this.closeListener){try{e.client.off("close",this.closeListener)}catch{}this.closeListener=void 0}if(this.errorListener){try{e.client.off("error",this.errorListener)}catch{}this.errorListener=void 0}try{e.client.isSocketConnected()&&await e.close()}catch{}this.baichuanApi=void 0,this.ensureClientPromise=void 0}async subscribeToEvents(){const e=this.getBaichuanLogger(),t=this.getConnectionCallbacks();if(!t.onSimpleEvent)return;if(this.eventSubscriptionActive&&this.baichuanApi){if(this.baichuanApi.client.isSocketConnected()&&this.baichuanApi.client.loggedIn)return void e.debug("Event subscription already active");this.eventSubscriptionActive=!1}await this.unsubscribeFromEvents();const s=await this.ensureBaichuanClient();if(s.client.isSocketConnected()&&s.client.loggedIn)if(!t.getEventSubscriptionEnabled||t.getEventSubscriptionEnabled())try{await s.onSimpleEvent(t.onSimpleEvent),this.eventSubscriptionActive=!0,e.log("Subscribed to Baichuan events")}catch(t){e.warn("Failed to subscribe to events",t),this.eventSubscriptionActive=!1}else e.debug("Event subscription disabled");else e.warn("Cannot subscribe to events: connection not ready")}async unsubscribeFromEvents(){const e=this.getBaichuanLogger(),t=this.getConnectionCallbacks();if(this.eventSubscriptionActive&&this.baichuanApi&&t.onSimpleEvent)try{this.baichuanApi.offSimpleEvent(t.onSimpleEvent),e.debug("Unsubscribed from Baichuan events")}catch(t){e.warn("Error unsubscribing from events",t)}this.eventSubscriptionActive=!1}}t.BaseBaichuanClass=A},6125:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReolinkNativeBatteryCamera=void 0;const r=s(8799);class n extends r.CommonCameraMixin{constructor(e,t,s,r){super(e,t,{type:"battery",nvrDevice:s,multiFocalDevice:r}),this.plugin=t,this.motionDetected=!1,this.periodicStarted=!1,this.batteryUpdateInProgress=!1}async init(){this.startPeriodicTasks(),await this.alignAuxDevicesState(),await this.updateBatteryInfo()}async release(){return this.stopPeriodicTasks(),this.resetBaichuanClient()}stopPeriodicTasks(){this.sleepCheckTimer&&(clearInterval(this.sleepCheckTimer),this.sleepCheckTimer=void 0),this.batteryUpdateTimer&&(clearInterval(this.batteryUpdateTimer),this.batteryUpdateTimer=void 0),this.periodicStarted=!1}startPeriodicTasks(){if(this.periodicStarted)return;const e=this.getBaichuanLogger();this.periodicStarted=!0,e.log("Starting periodic tasks for battery camera"),this.nvrDevice||this.multiFocalDevice||(this.sleepCheckTimer=setInterval((async()=>{try{const t=this.baichuanApi,s=this.storageSettings.values.rtspChannel;if(!t)return void(this.sleeping||(e.log("Camera is sleeping: no active Baichuan client"),this.sleeping=!0));const r=t.getSleepStatus({channel:s});await this.updateSleepingState(r)}catch(t){e.warn("Error checking sleeping state:",t)}}),5e3));const{batteryUpdateIntervalMinutes:t=10}=this.storageSettings.values,s=6e4*t;this.batteryUpdateTimer=setInterval((()=>{this.updateBatteryAndSnapshot().catch((()=>{}))}),s),e.log(`Periodic tasks started: sleep check every 5s, battery update every ${t} minutes`)}async updateSleepingState(e){try{if(this.isDebugEnabled()&&this.getBaichuanLogger().debug("getSleepStatus result:",JSON.stringify(e)),"sleeping"===e.state)this.sleeping||(this.getBaichuanLogger().log(`Camera is sleeping: ${e.reason}`),this.sleeping=!0);else if("awake"===e.state){const t=this.sleeping;t&&(this.getBaichuanLogger().log(`Camera woke up: ${e.reason}`),this.sleeping=!1),t&&(this.alignAuxDevicesState().catch((()=>{})),this.forceNewSnapshot&&this.takePicture().catch((()=>{})))}else this.getBaichuanLogger().debug(`Sleep status unknown: ${e.reason}`)}catch(e){this.getBaichuanLogger().debug("Error in checkSleepingState:",e)}}async checkRecordingAction(e){const t=this.plugin.nvrDeviceId;if(t&&this.mixins.includes(t)){const t=this.getBaichuanLogger(),s=await this.thisDevice.getSettings(),r=!s.find((e=>"recording:privacyMode"===e.key))?.value,{lowThresholdBatteryRecording:n,highThresholdBatteryRecording:i}=this.storageSettings.values;r&&e<n?(t.log(`Recording is enabled, but battery level is below low threshold (${e}% < ${n}%), disabling recording`),await this.thisDevice.putSetting("recording:privacyMode",!0)):!r&&e>i&&(t.log(`Recording is disabled, but battery level is above high threshold (${e}% > ${i}%), enabling recording`),await this.thisDevice.putSetting("recording:privacyMode",!1))}}async updateBatteryInfo(){const e=await this.ensureClient(),t=this.storageSettings.values.rtspChannel,s=await e.getBatteryInfo(t);if(this.isDebugEnabled()&&this.getBaichuanLogger().debug("getBatteryInfo result:",JSON.stringify(s)),void 0!==s.batteryPercent){const e=this.lastBatteryLevel;this.batteryLevel=s.batteryPercent,this.lastBatteryLevel=s.batteryPercent;let t=!0;if(void 0!==e&&e!==s.batteryPercent)if(void 0!==s.chargeStatus){const t="0"===s.chargeStatus||"2"===s.chargeStatus;this.getBaichuanLogger().log(`Battery level changed: ${e}% → ${s.batteryPercent}% (charging: ${t})`)}else this.getBaichuanLogger().log(`Battery level changed: ${e}% → ${s.batteryPercent}%`);else if(void 0===e)if(void 0!==s.chargeStatus){const e="0"===s.chargeStatus||"2"===s.chargeStatus;this.getBaichuanLogger().log(`Battery level set: ${s.batteryPercent}% (charging: ${e})`)}else this.getBaichuanLogger().log(`Battery level set: ${s.batteryPercent}%`);else t=!1;t&&await this.checkRecordingAction(s.batteryPercent)}}async updateBatteryAndSnapshot(){if(this.batteryUpdateInProgress)this.getBaichuanLogger().debug("Battery update already in progress, skipping");else{this.batteryUpdateInProgress=!0;try{const e=this.storageSettings.values.rtspChannel,t=this.storageSettings.values.batteryUpdateIntervalMinutes??10;this.getBaichuanLogger().log(`Force battery update interval started (every ${t} minutes)`);const s=await this.ensureClient();if(!s)return void this.getBaichuanLogger().warn("Failed to ensure client connection for battery update");let r=s.getSleepStatus({channel:e});if("sleeping"===r.state){this.getBaichuanLogger().log("Camera is sleeping, waking up for periodic update...");try{await s.wakeUp(e,{waitAfterWakeMs:2e3}),this.getBaichuanLogger().log("Wake command sent, waiting for camera to wake up...")}catch(e){return void this.getBaichuanLogger().warn("Failed to wake up camera:",e)}const t=3e4,n=Date.now();let i=!1;for(;Date.now()-n<t;)if(await new Promise((e=>setTimeout(e,1e3))),r=s.getSleepStatus({channel:e}),"awake"===r.state){i=!0,this.getBaichuanLogger().log("Camera is now awake"),this.sleeping=!1;break}if(!i)return void this.getBaichuanLogger().warn("Camera did not wake up within timeout, skipping update")}else"awake"===r.state&&(this.sleeping=!1);try{await this.updateBatteryInfo()}catch(e){this.getBaichuanLogger().warn("Failed to get battery info during periodic update:",e)}try{await this.alignAuxDevicesState()}catch(e){this.getBaichuanLogger().warn("Failed to align auxiliary devices state:",e)}try{this.forceNewSnapshot=!0,await this.takePicture(),this.getBaichuanLogger().log("Snapshot updated during periodic update")}catch(e){this.getBaichuanLogger().warn("Failed to update snapshot during periodic update:",e)}}catch(e){this.getBaichuanLogger().warn("Failed to update battery and snapshot",e)}finally{this.batteryUpdateInProgress=!1}}}async resetBaichuanClient(e){try{if(this.unsubscribedToEvents?.(),this.streamManager){const t=e?.message||e?.toString?.()||"connection reset";await this.streamManager.closeAllStreams(t)}await(this.baichuanApi?.close())}catch(e){this.getBaichuanLogger().warn("Error closing Baichuan client during reset",e)}finally{this.baichuanApi=void 0,this.connectionTime=void 0,this.ensureClientPromise=void 0,this.sleepCheckTimer&&(clearInterval(this.sleepCheckTimer),this.sleepCheckTimer=void 0),this.batteryUpdateTimer&&(clearInterval(this.batteryUpdateTimer),this.batteryUpdateTimer=void 0)}if(e){const t=e?.message||e?.toString?.()||e;this.getBaichuanLogger().warn(`Baichuan client reset requested: ${t}`)}}async withBaichuanClient(e){return e(await this.ensureClient())}async createStreamClient(){return await this.ensureClient()}}t.ReolinkNativeBatteryCamera=n},4417:function(e,t,s){"use strict";var r,n=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,n)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),A=this&&this.__importStar||(r=function(e){return r=Object.getOwnPropertyNames||function(e){var t=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[t.length]=s);return t},r(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s=r(e),A=0;A<s.length;A++)"default"!==s[A]&&n(t,e,s[A]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.ReolinkNativeCamera=t.b64ToMo=t.moToB64=void 0;const o=A(s(7562)),a=s(8799),c=s(5098);t.moToB64=async e=>{const t=await o.default.mediaManager.convertMediaObjectToBuffer(e,"image/jpeg");return t?.toString("base64")};t.b64ToMo=async e=>{const t=Buffer.from(e,"base64");return await o.default.mediaManager.createMediaObject(t,"image/jpeg")};class l extends a.CommonCameraMixin{constructor(e,t,s,r){super(e,t,{type:"regular",nvrDevice:s,multiFocalDevice:r}),this.plugin=t,this.initComplete=!1,this.periodicStarted=!1}async resetBaichuanClient(e){try{this.unsubscribedToEvents?.(),await(this.baichuanApi?.close())}catch(e){this.getBaichuanLogger().warn("Error closing Baichuan client during reset",e)}finally{this.baichuanApi=void 0,this.connectionTime=void 0,this.ensureClientPromise=void 0,this.passiveRefreshTimer&&(clearTimeout(this.passiveRefreshTimer),this.passiveRefreshTimer=void 0)}if(e){const t=e?.message||e?.toString?.()||e;this.getBaichuanLogger().warn(`Baichuan client reset requested: ${t}`)}}async init(){this.startPeriodicTasks(),await this.alignAuxDevicesState()}async createStreamClient(){const{ipAddress:e,username:t,password:s}=this.storageSettings.values,r=this.getBaichuanLogger(),n=this.getBaichuanDebugOptions(),i=await(0,c.createBaichuanApi)({inputs:{host:e,username:t,password:s,logger:r,debugOptions:n},transport:"tcp"});return await i.login(),i}async release(){return this.statusPollTimer&&clearInterval(this.statusPollTimer),this.passiveRefreshTimer&&(clearTimeout(this.passiveRefreshTimer),this.passiveRefreshTimer=void 0),this.resetBaichuanClient()}startPeriodicTasks(){this.periodicStarted||(this.periodicStarted=!0,this.getBaichuanLogger().log("Starting periodic tasks for regular camera"),this.statusPollTimer=setInterval((()=>{this.periodic10sTick().catch((()=>{}))}),1e4),this.getBaichuanLogger().log("Periodic tasks started: status poll every 10s"))}async periodic10sTick(){await this.ensureClient(),await this.alignAuxDevicesState()}async getDetectionInput(e,t){return null}async processEvents(e){const t=this.getBaichuanLogger();if(this.isEventDispatchEnabled()&&(this.storageSettings.values.dispatchEvents.includes("eventLogs")&&t.debug(`Events received: ${JSON.stringify(e)}`),this.shouldDispatchMotion()&&e.motion!==this.motionDetected&&(e.motion?(this.motionDetected=!0,this.motionTimeout&&clearTimeout(this.motionTimeout),this.motionTimeout=setTimeout((()=>this.motionDetected=!1),1e3*this.storageSettings.values.motionTimeout)):(this.motionDetected=!1,this.motionTimeout&&clearTimeout(this.motionTimeout))),this.shouldDispatchObjects()&&e.objects?.length)){const t={timestamp:Date.now(),detections:[]};for(const s of e.objects)t.detections.push({className:s,score:1});o.default.deviceManager.onDeviceEvent(this.nativeId,o.ScryptedInterface.ObjectDetector,t)}}async withBaichuanClient(e){return e(await this.ensureClient())}async getPictureOptions(){return[]}async getOtherSettings(){return await this.getSettings()}showRtspUrlOverride(){return!1}async startIntercom(e){await this.intercom.start(e)}stopIntercom(){return this.intercom.stop()}}t.ReolinkNativeCamera=l},8799:function(e,t,s){"use strict";var r,n=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,n)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),A=this&&this.__importStar||(r=function(e){return r=Object.getOwnPropertyNames||function(e){var t=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[t.length]=s);return t},r(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s=r(e),A=0;A<s.length;A++)"default"!==s[A]&&n(t,e,s[A]);return i(t,e),t}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CommonCameraMixin=void 0;const a=A(s(7562)),c=s(6117),l=o(s(6928)),h=s(7077),g=s(5098),d=s(9560),u=s(5741),E=s(840),I=s(5050),p=s(6185);class C extends a.ScryptedDeviceBase{constructor(e,t){super(t),this.camera=e}async turnOff(){this.camera.getBaichuanLogger().log(`Siren toggle: turnOff (device=${this.nativeId})`),this.on=!1;try{await this.camera.setSirenEnabled(!1),this.camera.getBaichuanLogger().log(`Siren toggle: turnOff ok (device=${this.nativeId})`)}catch(e){throw this.camera.getBaichuanLogger().warn(`Siren toggle: turnOff failed (device=${this.nativeId})`,e),e}}async turnOn(){this.camera.getBaichuanLogger().log(`Siren toggle: turnOn (device=${this.nativeId})`),this.on=!0;try{await this.camera.setSirenEnabled(!0),this.camera.getBaichuanLogger().log(`Siren toggle: turnOn ok (device=${this.nativeId})`)}catch(e){throw this.camera.getBaichuanLogger().warn(`Siren toggle: turnOn failed (device=${this.nativeId})`,e),e}}}class B extends a.ScryptedDeviceBase{constructor(e,t){super(t),this.camera=e}async setBrightness(e){this.camera.getBaichuanLogger().log(`Floodlight toggle: setBrightness (device=${this.nativeId} brightness=${e})`),this.brightness=e;try{await this.camera.setFloodlightState(void 0,e),this.camera.getBaichuanLogger().log(`Floodlight toggle: setBrightness ok (device=${this.nativeId} brightness=${e})`)}catch(t){throw this.camera.getBaichuanLogger().warn(`Floodlight toggle: setBrightness failed (device=${this.nativeId} brightness=${e})`,t),t}}async turnOff(){this.camera.getBaichuanLogger().log(`Floodlight toggle: turnOff (device=${this.nativeId})`),this.on=!1;try{await this.camera.setFloodlightState(!1),this.camera.getBaichuanLogger().log(`Floodlight toggle: turnOff ok (device=${this.nativeId})`)}catch(e){throw this.camera.getBaichuanLogger().warn(`Floodlight toggle: turnOff failed (device=${this.nativeId})`,e),e}}async turnOn(){this.camera.getBaichuanLogger().log(`Floodlight toggle: turnOn (device=${this.nativeId})`),this.on=!0;try{await this.camera.setFloodlightState(!0),this.camera.getBaichuanLogger().log(`Floodlight toggle: turnOn ok (device=${this.nativeId})`)}catch(e){throw this.camera.getBaichuanLogger().warn(`Floodlight toggle: turnOn failed (device=${this.nativeId})`,e),e}}}class f extends a.ScryptedDeviceBase{constructor(e,t){super(t),this.camera=e,this.storageSettings=new c.StorageSettings(this,{sensitive:{title:"PIR Sensitivity",description:"Detection sensitivity/threshold (higher = more sensitive)",type:"number",defaultValue:50,range:[0,100]},reduceAlarm:{title:"Reduce False Alarms",description:"Enable reduction of false alarm rate",type:"boolean",defaultValue:!1},interval:{title:"PIR Detection Interval",description:"Detection interval in seconds",type:"number",defaultValue:5,range:[1,60]}})}async getSettings(){return await this.storageSettings.getSettings()}async putSetting(e,t){await this.storageSettings.putSetting(e,t);const s=this.camera.storageSettings.values.rtspChannel,r=this.on?1:0,n=this.storageSettings.values.sensitive,i=this.storageSettings.values.reduceAlarm?1:0,A=this.storageSettings.values.interval;await this.camera.withBaichuanRetry((async()=>{const e=await this.camera.ensureClient();await e.setPirInfo(s,{enable:r,sensitive:n,reduceAlarm:i,interval:A})}))}async turnOff(){this.on=!1,await this.updatePirSettings()}async turnOn(){this.on=!0,await this.updatePirSettings()}async updatePirSettings(){const e=this.camera.storageSettings.values.rtspChannel,t=this.on?1:0,s=this.storageSettings.values.sensitive,r=this.storageSettings.values.reduceAlarm?1:0,n=this.storageSettings.values.interval;await this.camera.withBaichuanRetry((async()=>{const i=await this.camera.ensureClient();await i.setPirInfo(e,{enable:t,sensitive:s,reduceAlarm:r,interval:n})}))}}class Q extends h.BaseBaichuanClass{constructor(e,t,s){super(e),this.plugin=t,this.options=s,this.storageSettings=new c.StorageSettings(this,{ipAddress:{title:"IP Address",type:"string",onPut:async()=>{await this.credentialsChanged()}},username:{type:"string",title:"Username",onPut:async()=>{await this.credentialsChanged()}},password:{type:"password",title:"Password",onPut:async()=>{await this.credentialsChanged()}},rtspChannel:{type:"number",hide:!0,defaultValue:0},capabilities:{json:!0,hide:!0},multifocalInfo:{json:!0,hide:!0},pipPosition:{title:"PIP Position",description:"Position of the tele lens overlay on the wider lens view",type:"string",defaultValue:"bottom-right",choices:["top-left","top-right","bottom-left","bottom-right","center","top-center","bottom-center","left-center","right-center"],hide:!0},pipSize:{title:"PIP Size",description:"Relative size of the PIP overlay (0.1 = 10%, 0.3 = 30%, etc.)",type:"number",defaultValue:.25,hide:!0},pipMargin:{title:"PIP Margin",description:"Margin from edge in pixels",type:"number",defaultValue:10,hide:!0},widerChannel:{title:"Wider Channel",description:"Channel number for wider lens (typically 0)",type:"number",defaultValue:0,hide:!0},teleChannel:{title:"Tele Channel",description:"Channel number for tele lens (typically 1)",type:"number",defaultValue:1,hide:!0},uid:{title:"UID",description:"Reolink UID (required for battery cameras / BCUDP).",type:"string",hide:!0,onPut:async()=>{await this.credentialsChanged()}},debugLogs:{title:"Debug logs",type:"boolean",immediate:!0},mixinsSetup:{type:"boolean",hide:!0},dispatchEvents:{subgroup:"Advanced",title:"Dispatch Events",description:"Select which events to emit. Empty disables event subscription entirely.",multiple:!0,combobox:!0,immediate:!0,defaultValue:["motion","objects"],choices:["motion","objects"],onPut:async()=>{await this.subscribeToEvents()}},socketApiDebugLogs:{subgroup:"Advanced",title:"Socket API Debug Logs",description:"Enable specific debug logs.",multiple:!0,combobox:!0,immediate:!0,defaultValue:[],choices:(0,d.getDebugLogChoices)(),onPut:async(e,t)=>{const s=this.getBaichuanLogger(),r=(0,d.getApiRelevantDebugLogs)(e||[]),n=(0,d.getApiRelevantDebugLogs)(t||[]),i=new Set(r),A=new Set(n);(i.size!==A.size||Array.from(i).some((e=>!A.has(e))))&&this.resetBaichuanClient&&(this.debugLogsResetTimeout&&(clearTimeout(this.debugLogsResetTimeout),this.debugLogsResetTimeout=void 0),this.debugLogsResetTimeout=setTimeout((async()=>{this.debugLogsResetTimeout=void 0;try{await this.resetBaichuanClient("debugLogs changed"),this.baichuanApi=void 0,this.ensureClientPromise=void 0,await this.ensureClient()}catch(e){s.warn("Failed to reset client after debug logs change",e)}}),2e3))}},motionTimeout:{subgroup:"Advanced",title:"Motion Timeout",defaultValue:20,type:"number"},cachedOsd:{multiple:!0,hide:!0,json:!0,defaultValue:[]},intercomBlocksPerPayload:{subgroup:"Advanced",title:"Intercom Blocks Per Payload",description:"Lower reduces latency (more packets). Typical: 1-4. Requires restarting talk session to take effect.",type:"number",defaultValue:1},presets:{subgroup:"PTZ",title:"Presets to enable",description:'PTZ Presets in the format "id=name". Where id is the PTZ Preset identifier and name is a friendly name.',multiple:!0,defaultValue:[],combobox:!0,hide:!0,onPut:async(e,t)=>{const s={...this.ptzCapabilities||{},presets:{}};for(const e of t){const[t,r]=e.split("=");s.presets[t]=r}this.ptzCapabilities=s},mapGet:()=>{const e=this.ptzCapabilities?.presets||{};return Object.entries(e).map((([e,t])=>e+"="+t))}},ptzMoveDurationMs:{title:"PTZ Move Duration (ms)",description:"How long a PTZ command moves before sending stop. Higher = more movement per click.",type:"number",defaultValue:300,subgroup:"PTZ",hide:!0},ptzZoomStep:{subgroup:"PTZ",title:"PTZ Zoom Step",description:"How much to change zoom per zoom command (in zoom factor units, where 1.0 is normal).",type:"number",defaultValue:.1,hide:!0},ptzCreatePreset:{subgroup:"PTZ",title:"Create Preset",description:"Enter a name and press Save to create a new PTZ preset at the current position.",type:"string",placeholder:"e.g. Door",defaultValue:"",hide:!0,onPut:async(e,t)=>{const s=String(t??"").trim();if(!s)return void(""!==String(t??"")&&(this.storageSettings.values.ptzCreatePreset=""));const r=this.getBaichuanLogger();r.log(`PTZ presets: create preset requested (name=${s})`);const n=await this.withBaichuanRetry((async()=>{if(await this.ensureClient(),!this.ptzPresets)throw new Error("PTZ presets not available");return await this.ptzPresets.createPtzPreset(s)})),i=`${n.id}=${n.name}`;this.storageSettings.values.ptzSelectedPreset=i,this.storageSettings.values.ptzCreatePreset="",r.log(`PTZ presets: created preset id=${n.id} name=${n.name}`)}},ptzSelectedPreset:{subgroup:"PTZ",title:"Selected Preset",description:'Select the preset to update or delete. Format: "id=name".',type:"string",combobox:!1,immediate:!0,hide:!0},ptzUpdateSelectedPreset:{subgroup:"PTZ",title:"Update Selected Preset Position",description:"Overwrite the selected preset with the current PTZ position.",type:"button",immediate:!0,hide:!0,onPut:async()=>{const e=this.getSelectedPresetId();if(void 0===e)throw new Error("No preset selected");const t=this.getBaichuanLogger();t.log(`PTZ presets: update position requested (presetId=${e})`),await this.withBaichuanRetry((async()=>(await this.ensureClient(),await this.ptzPresets.updatePtzPresetToCurrentPosition(e)))),t.log(`PTZ presets: update position ok (presetId=${e})`)}},ptzDeleteSelectedPreset:{subgroup:"PTZ",title:"Delete Selected Preset",description:"Delete the selected preset (firmware dependent).",type:"button",immediate:!0,hide:!0,onPut:async()=>{const e=this.getSelectedPresetId();if(void 0===e)throw new Error("No preset selected");const t=this.getBaichuanLogger();t.log(`PTZ presets: delete requested (presetId=${e})`),await this.withBaichuanRetry((async()=>(await this.ensureClient(),await this.ptzPresets.deletePtzPreset(e)))),this.storageSettings.values.ptzSelectedPreset="",t.log(`PTZ presets: delete ok (presetId=${e})`)}},batteryUpdateIntervalMinutes:{title:"Battery Update Interval (minutes)",subgroup:"Advanced",description:"How often to wake up the camera and update battery status and snapshot (default: 60 minutes).",type:"number",defaultValue:60,hide:!0},lowThresholdBatteryRecording:{title:"Low Threshold Battery Recording (%)",subgroup:"Recording",description:"Battery level threshold below which recording is disabled (default: 15%).",type:"number",defaultValue:15,hide:!0},highThresholdBatteryRecording:{title:"High Threshold Battery Recording (%)",subgroup:"Recording",description:"Battery level threshold above which recording is enabled (default: 35%).",type:"number",defaultValue:35,hide:!0},diagnosticsOutputPath:{title:"Diagnostics Output Path",subgroup:"Diagnostics",description:"Directory where diagnostics files will be saved (default: plugin volume).",type:"string",defaultValue:l.default.join(process.env.SCRYPTED_PLUGIN_VOLUME,"diagnostics",this.name)},diagnosticsRun:{subgroup:"Diagnostics",title:"Run Diagnostics",description:"Run all diagnostics and save results to the output path.",type:"button",immediate:!0,onPut:async()=>{await this.runDiagnostics()}}}),this.ptzPresets=new E.ReolinkPtzPresets(this),this.refreshingState=!1,this.classes=[],this.presets=[],this.forceNewSnapshot=!1,this.fetchingStreams=!1,this.lastNetPortCacheAttempt=0,this.netPortCacheBackoffMs=5e3,this.onSimpleEvent=e=>{const t=this.getBaichuanLogger();try{const t=this.getBaichuanLogger();if(t.debug(`Baichuan event: ${JSON.stringify(e)}`),!this.isEventDispatchEnabled())return void t.debug("Event dispatch is disabled, ignoring event");const s=this.storageSettings.values.rtspChannel;if(void 0!==e?.channel&&e.channel!==s)return void t.error(`Event channel ${e.channel} does not match camera channel ${s}, ignoring`);const r=[];let n=!1;switch(e?.type){case"motion":n=!0;break;case"doorbell":this.handleDoorbellEvent(),n=!0;break;case"people":case"vehicle":case"animal":case"face":case"package":case"other":this.shouldDispatchObjects()&&r.push(e.type),n=!0;break;default:return void t.error(`Unknown event type: ${e?.type}`)}this.processEvents({motion:n,objects:r}).catch((e=>{t.warn("Error processing events",e)}))}catch(e){t.warn("Error in onSimpleEvent handler",e)}},this.nvrDevice=s.nvrDevice,this.multiFocalDevice=s.multiFocalDevice,this.thisDevice=a.default.systemManager.getDeviceById(this.id);const r="battery"===s.type||"multi-focal-battery"===s.type;this.protocol=r?"udp":"tcp",setTimeout((async()=>{await this.parentInit()}),2e3)}async reboot(){const e=await this.ensureBaichuanClient();await e.reboot()}getConnectionConfig(){const{ipAddress:e,username:t,password:s,uid:r}=this.storageSettings.values,n=this.getBaichuanDebugOptions(),i="udp"===this.protocol?(0,g.normalizeUid)(r):void 0;if("udp"===this.protocol&&!i)throw new Error("UID is required for battery cameras (BCUDP)");return{host:e,username:t,password:s,uid:i,transport:this.protocol,logger:this.console,debugOptions:n}}getConnectionCallbacks(){return{onError:void 0,onClose:async()=>{"battery"===this.options.type||setTimeout((async()=>{try{await this.subscribeToEvents()}catch(e){this.getBaichuanLogger().warn("Failed to resubscribe to events after reconnection",e)}}),1e3)},onSimpleEvent:this.onSimpleEvent,getEventSubscriptionEnabled:()=>this.isEventDispatchEnabled?.()??!1}}isDebugEnabled(){return this.storageSettings.values.debugLogs}getDeviceName(){return this.name||"Camera"}async withBaichuanRetry(e){if("udp"===this.protocol)return await e();try{return await e()}catch(t){if(!this.isRecoverableBaichuanError(t))throw t;await this.resetBaichuanClient(t);try{return await e()}catch(e){throw e}}}async runDiagnostics(){const e=this.getBaichuanLogger(),t=this.storageSettings.values.diagnosticsOutputPath||process.env.SCRYPTED_PLUGIN_VOLUME||"";if(!t)throw new Error("Diagnostics output path is required");const s=this.storageSettings.values.rtspChannel||0,r={kinds:["native"],profiles:["main","ext","sub"]};e.log(`Starting diagnostics with parameters: outDir=${t}, channel=${s}, durationSeconds=15, selection=${JSON.stringify(r)}`);try{const n=await this.ensureClient(),i=await n.runAllDiagnosticsConsecutively({outDir:t,channel:s,durationSeconds:15,selection:r});e.log(`Diagnostics completed successfully. Output directory: ${i.runDir}`),e.log(`Diagnostics file: ${i.diagnosticsPath}`),e.log(`Streams directory: ${i.streamsDir}`)}catch(t){throw e.error("Failed to run diagnostics",t),t}}async onBeforeCleanup(){if(this.onSimpleEvent&&this.baichuanApi)try{this.baichuanApi.offSimpleEvent(this.onSimpleEvent)}catch{}}createStreamClient(){throw new Error("Method not implemented.")}getAbilities(){return this.multiFocalDevice?this.multiFocalDevice.getInterfaces(this.storageSettings.values.rtspChannel).capabilities:this.storageSettings.values.capabilities}getBaichuanDebugOptions(){const e=this.storageSettings.values.debugLogs||[];return(0,d.convertDebugLogsToApiOptions)(e)}isRecoverableBaichuanError(e){const t=e?.message||e?.toString?.()||"";return"string"==typeof t&&(t.includes("Baichuan socket closed")||t.includes("Baichuan UDP stream closed")||t.includes("Baichuan TCP socket is not connected")||t.includes("socket hang up")||t.includes("ECONNRESET")||t.includes("EPIPE"))}updatePtzCaps(){const{hasPan:e,hasTilt:t,hasZoom:s}=this.getAbilities();this.ptzCapabilities={...this.ptzCapabilities,pan:e,tilt:t,zoom:s}}unsubscribedToEvents(){this.unsubscribeFromEvents().catch((()=>{})),this.motionDetected&&(this.motionDetected=!1)}async subscribeToEvents(){if(this.nvrDevice||this.multiFocalDevice)return;const e=this.getBaichuanLogger(),t=Array.from(this.getDispatchEventsSelection?.()??new Set).sort(),s=t.length>0;e.debug(`subscribeToEvents called: enabled=${s}, selection=[${t.join(", ")}], protocol=${this.protocol}`),this.unsubscribedToEvents();if(t.includes("motion")||(this.motionTimeout&&clearTimeout(this.motionTimeout),this.motionDetected=!1),!s)return e.log("Event subscription disabled, unsubscribing"),this.doorbellBinaryTimeout&&(clearTimeout(this.doorbellBinaryTimeout),this.doorbellBinaryTimeout=void 0),void(this.binaryState=!1);const r=await this.ensureClient();try{await r.onSimpleEvent(this.onSimpleEvent),e.log(`Subscribed to events (${t.join(", ")}) on ${this.protocol} connection`)}catch(t){return void e.warn("Failed to attach Baichuan event handler",t)}}async getVideoTextOverlays(){const e=await this.ensureClient(),t=this.storageSettings.values.rtspChannel;let s=this.storageSettings.values.cachedOsd;return s?.length||(s=await e.getOsd(t),this.storageSettings.values.cachedOsd=s),{osdChannel:{text:s?.osdChannel?.enable?s.osdChannel.name:void 0},osdTime:{text:!!s?.osdTime?.enable,readonly:!0}}}async setVideoTextOverlay(e,t){const s=await this.ensureClient(),r=this.storageSettings.values.rtspChannel,n=await s.getOsd(r);if("osdChannel"===e){const e="string"==typeof t?.text?t.text.trim():"",s=!!e||!0===t?.text;n.osdChannel.enable=s?1:0,s&&(n.osdChannel.name=e||n.osdChannel.name||this.name||"Camera")}else{if("osdTime"!==e)throw new Error("unknown overlay: "+e);n.osdTime.enable=t?.text?1:0}await s.setOsd(r,n)}async ptzCommand(e){const t=this.getBaichuanLogger(),s=await this.ensureClient();if(!s)return;const r=this.storageSettings.values.rtspChannel,n=e.preset;if(null!=n){const e=Number(n);return Number.isFinite(e)?void(this.ptzPresets?await this.ptzPresets.moveToPreset(e):t.warn("PTZ presets not available")):void t.warn(`Invalid PTZ preset id: ${n}`)}let i="start",A="Left";if(void 0!==e.pan)0===e.pan?(i="stop",A="Left"):(A=e.pan>0?"Right":"Left",i="start");else if(void 0!==e.tilt)0===e.tilt?(i="stop",A="Up"):(A=e.tilt>0?"Up":"Down",i="start");else if(void 0!==e.zoom){const n=Number(e.zoom);if(!Number.isFinite(n)||0===n)return;const i=Number(this.storageSettings.values.ptzZoomStep);if(!Number.isFinite(i)||i<=0)return void t.warn("Invalid PTZ zoom step, using default 0.1");const A=await s.getZoomFocus(r);if(!A?.zoom)return void t.warn("Zoom command requested but camera did not report zoom support.");const o=(A.zoom.curPos??1e3)/1e3,a=(A.zoom.minPos??1e3)/1e3,c=(A.zoom.maxPos??1e3)/1e3,l=i,h=n>0?1:-1,g=Math.min(c,Math.max(a,o+h*l));return void await s.zoomToFactor(r,g)}const o={action:i,command:A,speed:"number"==typeof e.speed?e.speed:32,autoStopMs:Number(this.storageSettings.values.ptzMoveDurationMs)||500};await s.ptz(r,o)}async getObjectTypes(){return{classes:this.classes}}async getDetectionInput(e,t){return null}getDispatchEventsSelection(){return new Set(this.storageSettings.values.dispatchEvents)}isEventDispatchEnabled(){return this.getDispatchEventsSelection().size>0}shouldDispatchMotion(){return this.getDispatchEventsSelection().has("motion")}shouldDispatchObjects(){return this.getDispatchEventsSelection().has("objects")}async processEvents(e){if(!(this.isEventDispatchEnabled?.()??!0))return;const t=this.getDispatchEventsSelection?.()??new Set(["motion","objects"]),s=t.has("motion"),r=t.has("objects");if(s&&void 0!==e.motion){const t=e.motion;if(t!==this.motionDetected)if(this.motionDetected=t,t){this.motionTimeout&&clearTimeout(this.motionTimeout);const e=1e3*(this.storageSettings.values.motionTimeout||30);this.motionTimeout=setTimeout((()=>{this.motionDetected=!1}),e)}else this.motionTimeout&&clearTimeout(this.motionTimeout)}if(r&&e.objects?.length){const t={timestamp:Date.now(),detections:[]};for(const s of e.objects)t.detections.push({className:s,score:1});this.nativeId&&a.default.deviceManager.onDeviceEvent(this.nativeId,a.ScryptedInterface.ObjectDetector,t)}}handleDoorbellEvent(){this.doorbellBinaryTimeout||(this.binaryState=!0,this.doorbellBinaryTimeout=setTimeout((()=>{this.binaryState=!1,this.doorbellBinaryTimeout=void 0}),5e3))}clearDoorbellBinary(){this.doorbellBinaryTimeout&&(clearTimeout(this.doorbellBinaryTimeout),this.doorbellBinaryTimeout=void 0),this.binaryState=!1}async reportDevices(){const e=this.getAbilities(),{hasSiren:t,hasFloodlight:s,hasPir:r}=e;if(t){const e=`${this.nativeId}${p.sirenSuffix}`,t={providerNativeId:this.nativeId,name:`${this.name} Siren`,nativeId:e,info:{...this.info||{}},interfaces:[a.ScryptedInterface.OnOff,a.ScryptedInterface.Settings],type:a.ScryptedDeviceType.Siren};a.default.deviceManager.onDeviceDiscovered(t)}if(s){const e=`${this.nativeId}${p.floodlightSuffix}`,t={providerNativeId:this.nativeId,name:`${this.name} Floodlight`,nativeId:e,info:{...this.info||{}},interfaces:[a.ScryptedInterface.OnOff,a.ScryptedInterface.Settings],type:a.ScryptedDeviceType.Light};a.default.deviceManager.onDeviceDiscovered(t)}if(r){const e=`${this.nativeId}${p.pirSuffix}`,t={providerNativeId:this.nativeId,name:`${this.name} PIR`,nativeId:e,info:{...this.info||{}},interfaces:[a.ScryptedInterface.OnOff,a.ScryptedInterface.Settings],type:a.ScryptedDeviceType.Switch};a.default.deviceManager.onDeviceDiscovered(t)}}async getSettings(){return await this.storageSettings.getSettings()}async putSetting(e,t){await this.storageSettings.putSetting(e,t)}async takePicture(e){if("tcp"===this.protocol)try{return this.withBaichuanRetry((async()=>{const e=await this.ensureClient(),t=await e.getSnapshot(this.storageSettings.values.rtspChannel);return await this.createMediaObject(t,"image/jpeg")}))}catch(e){throw this.getBaichuanLogger().error("Error taking snapshot",e),e}else{const e=this.getBaichuanLogger();if(!this.forceNewSnapshot&&this.lastPicture)return e.log(`Returning cached snapshot, taken at ${new Date(this.lastPicture.atMs).toLocaleString()}`),this.lastPicture.mo;if(this.takePictureInFlight)return await this.takePictureInFlight;e.log(`Taking new snapshot from camera (forceNewSnapshot: ${this.forceNewSnapshot})`),this.forceNewSnapshot=!1,this.takePictureInFlight=(async()=>{const t=this.storageSettings.values.rtspChannel,s=await this.withBaichuanClient((async e=>await e.getSnapshot(t))),r=await a.default.mediaManager.createMediaObject(s,"image/jpeg");return this.lastPicture={mo:r,atMs:Date.now()},e.log(`Snapshot taken at ${new Date(this.lastPicture.atMs).toLocaleString()}`),r})();try{return await this.takePictureInFlight}finally{this.takePictureInFlight=void 0}}}async getPictureOptions(){return[]}async startIntercom(e){if(!this.intercom)throw new Error("Intercom not initialized");await this.intercom.start(e)}async stopIntercom(){if(this.intercom)return await this.intercom.stop();throw new Error("Intercom not initialized")}async updateDeviceInfo(){const e=this.getBaichuanLogger();if(this.multiFocalDevice)return void(this.info=this.multiFocalDevice.info);const{ipAddress:t,rtspChannel:s}=this.storageSettings.values;try{const r=await this.ensureClient(),n=await r.getInfo(this.nvrDevice||this.multiFocalDevice?s:void 0);await(0,p.updateDeviceInfo)({device:this,ipAddress:t,deviceData:n,logger:e})}catch(t){e.warn("Failed to fetch device info",t)}}async getDevice(e){return e.endsWith(p.sirenSuffix)?(this.siren||=new C(this,e),this.siren):e.endsWith(p.floodlightSuffix)?(this.floodlight||=new B(this,e),this.floodlight):e.endsWith(p.pirSuffix)?(this.pirSensor||=new f(this,e),this.pirSensor):void 0}async releaseDevice(e,t){t.endsWith(p.sirenSuffix)?this.siren=void 0:t.endsWith(p.floodlightSuffix)?this.floodlight=void 0:t.endsWith(p.pirSuffix)&&(this.pirSensor=void 0)}async setSirenEnabled(e){const t=this.storageSettings.values.rtspChannel;await this.withBaichuanRetry((async()=>{const s=await this.ensureClient();return await s.setSiren(t,e)}))}async setFloodlightState(e,t){const s=this.storageSettings.values.rtspChannel;await this.withBaichuanRetry((async()=>{const r=await this.ensureClient();return await r.setWhiteLedState(s,e,t)}))}async setPirEnabled(e){const t=this.storageSettings.values.rtspChannel;let s,r,n;this.pirSensor&&(s=this.pirSensor.storageSettings.values.sensitive,r=this.pirSensor.storageSettings.values.reduceAlarm?1:0,n=this.pirSensor.storageSettings.values.interval),await this.withBaichuanRetry((async()=>{const i=await this.ensureClient();return await i.setPirInfo(t,{enable:e?1:0,...void 0!==s?{sensitive:s}:{},...void 0!==r?{reduceAlarm:r}:{},...void 0!==n?{interval:n}:{}})}))}async alignAuxDevicesState(){const e=this.getBaichuanLogger(),t=this.baichuanApi;if(!t)return;const s=this.storageSettings.values.rtspChannel,{hasSiren:r,hasFloodlight:n,hasPir:i}=this.getAbilities();try{if(r&&this.siren)try{const e=await t.getSiren(s);this.siren.on=e.enabled}catch(t){e.debug("Failed to align siren state",t)}if(n&&this.floodlight)try{const e=await t.getWhiteLedState(s);this.floodlight.on=!!e.enabled,void 0!==e.brightness&&(this.floodlight.brightness=e.brightness)}catch(t){e.debug("Failed to align floodlight state",t)}if(i&&this.pirSensor)try{const e=await t.getPirInfo(s);this.pirSensor.on=e.enabled,e.state&&(void 0!==e.state.sensitive&&(this.pirSensor.storageSettings.values.sensitive=e.state.sensitive),void 0!==e.state.reduceAlarm&&(this.pirSensor.storageSettings.values.reduceAlarm=!!e.state.reduceAlarm),void 0!==e.state.interval&&(this.pirSensor.storageSettings.values.interval=e.state.interval))}catch(t){e.debug("Failed to align PIR state",t)}}catch(t){e.debug("Failed to align auxiliary devices state",t)}}addRtspCredentials(e){const t=this.getBaichuanLogger(),{username:s,password:r}=this.storageSettings.values;if(!s)return e;try{const t=new URL(e);if("rtmp:"===t.protocol){const e=t.searchParams;e.set("user",s),e.set("password",r||"")}else t.username=s,t.password=r||"";return t.toString()}catch(s){return t.warn("Failed to parse URL for credentials",s),e}}async getVideoStreamOptions(){const e=this.getBaichuanLogger();if(this.cachedVideoStreamOptions?.length)return this.cachedVideoStreamOptions;if(this.fetchingStreams)return[];this.fetchingStreams=!0;let t=[];const s=await this.ensureClient(),r="multi-focal"===this.options.type||"multi-focal-battery"===this.options.type?void 0:this.storageSettings.values.rtspChannel;try{const{nativeStreams:e,rtmpStreams:n,rtspStreams:i}=await s.buildVideoStreamOptions(r);let A=[];A=this.nvrDevice&&"HOMEHUB"===this.nvrDevice.info.model?[...e,...i,...n]:[...i,...n,...e];for(const e of A){const{id:s,metadata:r,url:n,name:i,container:A}=e,o=String(r.videoEncType||"").includes("264")?"h264":String(r.videoEncType||"").includes("265")?"h265":String(r.videoEncType||"").toLowerCase();t.push({id:s,name:i,url:n,container:A,video:{codec:o,width:r.width,height:r.height}})}}catch(t){this.isRecoverableBaichuanError?.(t)||e.warn("Failed to build RTSP/RTMP stream options, falling back to Native",t)}if(t.length)return e.log("Fetched video stream options",t.map((e=>e.name)).join(", ")),e.debug(JSON.stringify(t)),this.cachedVideoStreamOptions=t,t;this.fetchingStreams=!1}async getVideoStream(e){if(!e)throw new Error("video streams not set up or no longer exists.");const t=await this.getVideoStreamOptions(),s=(0,I.selectStreamOption)(t,e);if(s.url&&("rtsp"===s.container||"rtmp"===s.container)){const e=this.addRtspCredentials(s.url),t={container:s.container,url:e,mediaStreamOptions:s};return await this.createMediaObject(t,a.ScryptedMimeTypes.MediaStreamUrl)}if(!this.streamManager)throw new Error("StreamManager not initialized");const r=s.id?.startsWith("composite_");if(r&&this.options&&("multi-focal"===this.options.type||"multi-focal-battery"===this.options.type)){const e=(0,I.parseStreamProfileFromId)(s.id.replace("composite_",""))||"main",t=`composite_${e}`,r=(0,I.expectedVideoTypeFromUrlMediaStreamOptions)(s),n=async()=>await(0,I.createRfc4571CompositeMediaObjectFromStreamManager)({streamManager:this.streamManager,profile:e,streamKey:t,expectedVideoType:r,selected:s,sourceId:this.id});return await this.withBaichuanRetry(n)}const n=(0,I.parseStreamProfileFromId)(s.id)||"main",i=this.storageSettings.values.rtspChannel,A=`${i}_${n}`,o=(0,I.expectedVideoTypeFromUrlMediaStreamOptions)(s);return await this.withBaichuanRetry((async()=>await(0,I.createRfc4571MediaObjectFromStreamManager)({streamManager:this.streamManager,channel:i,profile:n,streamKey:A,expectedVideoType:o,selected:s,sourceId:this.id})))}async ensureClient(){return this.nvrDevice?await this.nvrDevice.ensureBaichuanClient():this.multiFocalDevice?await this.multiFocalDevice.ensureBaichuanClient():await this.ensureBaichuanClient()}async credentialsChanged(){this.cachedVideoStreamOptions=void 0}getSelectedPresetId(){const e=this.storageSettings.values.ptzSelectedPreset;if(!e)return;const t=e.includes("=")?e.split("=")[0]:e,s=Number(t);return Number.isFinite(s)?s:void 0}async refreshDeviceState(){if(this.refreshingState)return;this.refreshingState=!0;const e=this.getBaichuanLogger(),t=this.storageSettings.values.rtspChannel;try{const{capabilities:s,abilities:r,support:n,presets:i,objects:A}=await this.withBaichuanRetry((async()=>{const e=await this.ensureClient();return await e.getDeviceCapabilities(t)}));this.classes=A,this.presets=i,this.ptzPresets.setCachedPtzPresets(i);try{const{interfaces:t,type:r}=(0,p.getDeviceInterfaces)({capabilities:s,logger:this.console}),n={nativeId:this.nativeId,providerNativeId:this.nvrDevice?.nativeId??this.multiFocalDevice?.nativeId??this.plugin?.nativeId,name:this.name,interfaces:t,type:r,info:this.info};await a.default.deviceManager.onDeviceDiscovered(n),e.log("Device interfaces updated"),e.debug(`${JSON.stringify(n)}`)}catch(t){e.error("Failed to update device interfaces",t)}e.log(`Refreshed device capabilities: ${JSON.stringify(s)}`),e.debug(`Refreshed device capabilities: ${JSON.stringify({abilities:r,support:n,presets:i,objects:A})}`)}catch(t){e.error("Failed to refresh abilities",t)}this.refreshingState=!1}async parentInit(){const e=this.getBaichuanLogger();try{await this.ensureClient(),await this.updateDeviceInfo()}catch(t){e.warn("Failed to update device info during init",t)}if(!this.multiFocalDevice)try{await this.refreshDeviceState(),await this.reportDevices()}catch(t){e.warn("Failed to connect/refresh during init",t)}const{username:t,password:s}=this.storageSettings.values,r=["multi-focal-battery","battery"].includes(this.options.type),n=["multi-focal","multi-focal"].includes(this.options.type);if(this.storageSettings.settings.uid.hide=!r,this.storageSettings.settings.batteryUpdateIntervalMinutes.hide=!r,this.storageSettings.settings.lowThresholdBatteryRecording.hide=!r,this.storageSettings.settings.highThresholdBatteryRecording.hide=!r,this.storageSettings.settings.pipPosition.hide=!n,this.storageSettings.settings.pipSize.hide=!n,this.storageSettings.settings.pipMargin.hide=!n,this.storageSettings.settings.widerChannel.hide=!n,this.storageSettings.settings.teleChannel.hide=!n,r&&!this.storageSettings.values.mixinsSetup)try{const t=a.default.systemManager.getDeviceById(this.id);t&&(e.log("Disabling prebuffer and snapshots from prebuffer"),await t.putSetting("prebuffer:enabledStreams","[]"),await t.putSetting("snapshot:snapshotsFromPrebuffer","Disabled"),this.storageSettings.values.mixinsSetup=!0)}catch(t){e.warn("Failed to setup mixins during init",t)}try{await this.subscribeToEvents()}catch(t){e.warn("Failed to subscribe to Baichuan events",t)}this.streamManager=new I.StreamManager({createStreamClient:()=>this.createStreamClient(),getLogger:()=>e,credentials:{username:t,password:s},sharedConnection:r});const{hasIntercom:i,hasPtz:A}=this.getAbilities();if(i&&(this.intercom=new u.ReolinkBaichuanIntercom(this)),A){const e=(this.presets||[]).map((e=>e.id+"="+e.name));this.storageSettings.settings.presets.choices=e,this.storageSettings.settings.ptzSelectedPreset.choices=e,this.storageSettings.settings.presets.hide=!1,this.storageSettings.settings.ptzMoveDurationMs.hide=!1,this.storageSettings.settings.ptzZoomStep.hide=!1,this.storageSettings.settings.ptzCreatePreset.hide=!1,this.storageSettings.settings.ptzSelectedPreset.hide=!1,this.storageSettings.settings.ptzUpdateSelectedPreset.hide=!1,this.storageSettings.settings.ptzDeleteSelectedPreset.hide=!1,this.updatePtzCaps()}(this.nvrDevice||this.multiFocalDevice)&&(this.storageSettings.settings.username.hide=!0,this.storageSettings.settings.password.hide=!0,this.storageSettings.settings.ipAddress.hide=!0,this.storageSettings.settings.uid.hide=!0,this.storageSettings.settings.username.defaultValue=this.nvrDevice.storageSettings.values.username,this.storageSettings.settings.password.defaultValue=this.nvrDevice.storageSettings.values.password,this.storageSettings.settings.ipAddress.defaultValue=this.nvrDevice.storageSettings.values.ipAddress),await this.init(),this.initComplete=!0}}t.CommonCameraMixin=Q},5098:(e,t,s)=>{"use strict";function r(e){const t=e?.trim();return t||void 0}Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeUid=r,t.createBaichuanApi=async function(e){const{inputs:t,transport:n}=e,{logger:i}=t,{ReolinkBaichuanApi:A}=await Promise.resolve().then(s.bind(s,863)),o={host:t.host,username:t.username,password:t.password,logger:i,debugOptions:t.debugOptions??{}},a=e=>{try{e.client.on("error",(e=>{if(!i)return;const s=e?.message||e?.toString?.()||String(e);"string"==typeof s&&(s.includes("Baichuan socket closed")||s.includes("Baichuan UDP stream closed")||s.includes("Not running"))||i.error(`[BaichuanClient] error (${n}) ${t.host}: ${s}`)})),e.client.on("close",(()=>{}))}catch{}};if("tcp"===n){const e=new A({...o,transport:"tcp"});return a(e),e}const c=r(t.uid);if(!c)throw new Error("UID is required for battery cameras (BCUDP)");const l=new A({...o,transport:"udp",uid:c,idleDisconnect:!0});return a(l),l}},9560:(e,t)=>{"use strict";var s;function r(e){return{[s.General]:"general",[s.DebugRtsp]:"debugRtsp",[s.TraceStream]:"traceStream",[s.TraceTalk]:"traceTalk",[s.TraceEvents]:"traceEvents",[s.DebugH264]:"debugH264",[s.DebugParamSets]:"debugParamSets"}[e]}Object.defineProperty(t,"__esModule",{value:!0}),t.DebugLogDisplayNames=t.DebugLogOption=void 0,t.mapDebugLogToApiOption=r,t.convertDebugLogsToApiOptions=function(e){const s={},n=new Set(e);for(const[e,i]of Object.entries(t.DebugLogDisplayNames))if(n.has(i)){const t=r(e);t&&(s[t]=!0)}return Object.keys(s).length>0?s:void 0},t.getApiRelevantDebugLogs=function(e){return e.filter((e=>null!==r(e)))},t.getDebugLogChoices=function(){return Object.values(s).map((e=>`${t.DebugLogDisplayNames[e]}`))},function(e){e.General="general",e.DebugRtsp="debugRtsp",e.TraceStream="traceStream",e.TraceTalk="traceTalk",e.TraceEvents="traceEvents",e.DebugH264="debugH264",e.DebugParamSets="debugParamSets"}(s||(t.DebugLogOption=s={})),t.DebugLogDisplayNames={[s.General]:"General",[s.DebugRtsp]:"RTSP",[s.TraceStream]:"Trace stream",[s.TraceTalk]:"Trace talk",[s.TraceEvents]:"Trace events XML",[s.DebugH264]:"H264",[s.DebugParamSets]:"Video param sets"}},5741:function(e,t,s){"use strict";var r,n=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,n)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),A=this&&this.__importStar||(r=function(e){return r=Object.getOwnPropertyNames||function(e){var t=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[t.length]=s);return t},r(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s=r(e),A=0;A<s.length;A++)"default"!==s[A]&&n(t,e,s[A]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.ReolinkBaichuanIntercom=void 0;const o=A(s(7562)),a=s(1421);t.ReolinkBaichuanIntercom=class{constructor(e){this.camera=e,this.loggedCodecInfo=!1,this.maxBacklogMs=40,this.sendChain=Promise.resolve(),this.pcmBuffer=Buffer.alloc(0)}get blocksPerPayload(){return Math.max(1,Math.min(8,this.camera.storageSettings.values.intercomBlocksPerPayload??1))}async start(e){const t=this.camera.getBaichuanLogger(),s=await o.default.mediaManager.convertMediaObjectToJSON(e,o.ScryptedMimeTypes.FFmpegInput);await this.stop();const r=this.camera.storageSettings.values.rtspChannel;if(!this.loggedCodecInfo){this.loggedCodecInfo=!0;try{const e=await this.camera.ensureClient(),s=await e.getTalkAbility(r),n=s.audioConfigList?.map((e=>({audioType:e.audioType,sampleRate:e.sampleRate,samplePrecision:e.samplePrecision,lengthPerEncoder:e.lengthPerEncoder,soundTrack:e.soundTrack})));t.log("Intercom TalkAbility",{channel:r,duplexList:s.duplexList,audioStreamModeList:s.audioStreamModeList,audioConfigList:n})}catch(e){t.warn("Intercom: unable to fetch TalkAbility",e)}}const n=await this.camera.withBaichuanRetry((async()=>{const e=await this.camera.ensureClient();if("battery"===this.camera.options?.type)try{"sleeping"===e.getSleepStatus({channel:r}).state&&(t.log("Camera is sleeping, waking up for intercom..."),await e.wakeUp(r,{waitAfterWakeMs:2e3}),await new Promise((e=>setTimeout(e,1e3))))}catch(e){t.debug("Failed to check/wake camera for intercom, proceeding anyway",e)}return await e.createTalkSession(r,{blocksPerPayload:this.blocksPerPayload})}));this.session=n,this.pcmBuffer=Buffer.alloc(0),this.sendChain=Promise.resolve();const{audioConfig:i,blockSize:A,fullBlockSize:c}=n.info,l=i.sampleRate,h=2*A+1,g=2*h;if(this.maxBacklogBytes=Math.max(g,Math.floor(this.maxBacklogMs/1e3*l*1*2)),!Number.isFinite(l)||l<=0)throw await this.stop(),new Error(`Invalid talk sampleRate: ${l}`);if(!Number.isFinite(A)||A<=0||!Number.isFinite(c)||c!==A+4)throw await this.stop(),new Error(`Invalid talk block sizes: blockSize=${A} fullBlockSize=${c}`);t.log("Starting intercom (baichuan/native-api flow)",{channel:r,audioType:i.audioType,sampleRate:i.sampleRate,samplePrecision:i.samplePrecision,lengthPerEncoder:i.lengthPerEncoder,soundTrack:i.soundTrack,blockSize:A,fullBlockSize:c,samplesPerBlock:h,bytesNeeded:g,maxBacklogMs:this.maxBacklogMs,maxBacklogBytes:this.maxBacklogBytes,blocksPerPayload:this.blocksPerPayload});const d=this.buildFfmpegPcmArgs(s,{sampleRate:l,channels:1});t.log("Intercom ffmpeg decode args",d);const u=(0,a.spawn)("ffmpeg",d,{stdio:["ignore","pipe","pipe"]});if(this.session!==n){try{u.kill("SIGKILL")}catch{}return}this.ffmpeg=u,u.stdout.on("data",(e=>{this.session===n&&e?.length&&this.enqueuePcm(n,e,g,A)}));let E=0;u.stderr.on("data",(e=>{E++<12&&t.warn("Intercom ffmpeg",e.toString().trim())})),u.on("exit",((e,s)=>{t.warn(`Intercom ffmpeg exited code=${e} signal=${s}`),this.stop().catch((()=>{}))})),t.log("Intercom started (ffmpeg decode -> PCM -> IMA ADPCM)")}stop(){return this.stopping||(this.stopping=(async()=>{const e=this.camera.getBaichuanLogger(),t=this.ffmpeg;this.ffmpeg=void 0;const s=this.session;this.session=void 0,this.pcmBuffer=Buffer.alloc(0);const r=async e=>new Promise((t=>setTimeout(t,e)));if(t&&null==t.exitCode){try{t.kill("SIGKILL")}catch{}try{await Promise.race([new Promise((e=>t.once("exit",(()=>e())))),r(1e3)])}catch{}}try{await Promise.race([this.sendChain,r(250)])}catch{}if(this.sendChain=Promise.resolve(),s)try{await Promise.race([s.stop(),r(2e3)])}catch(t){e.warn("Intercom session stop error",t)}})().finally((()=>{this.stopping=void 0}))),this.stopping}clamp16(e){return e>32767?32767:e<-32768?-32768:0|e}enqueuePcm(e,t,s,r){const n=this.camera.getBaichuanLogger();this.sendChain=this.sendChain.then((async()=>{if(this.session!==e)return;this.pcmBuffer=this.pcmBuffer.length?Buffer.concat([this.pcmBuffer,t]):t;const n=this.maxBacklogBytes??s;if(this.pcmBuffer.length>n){const e=n-n%2;this.pcmBuffer=this.pcmBuffer.subarray(this.pcmBuffer.length-e)}for(;this.pcmBuffer.length>=s;){const t=this.pcmBuffer.subarray(0,s);this.pcmBuffer=this.pcmBuffer.subarray(s);const n=new Int16Array(t.buffer,t.byteOffset,t.length/2),i=this.encodeImaAdpcm(n,r);await e.sendAudio(i)}})).catch((e=>{n.warn("Intercom PCM->ADPCM pipeline error",e)}))}buildFfmpegPcmArgs(e,t){const s=e.inputArguments??[],r=[];let n;for(let e=0;e<s.length;e++){const t=s[e];if("-i"===t){const t=s[e+1];if("string"==typeof t){n||(n=t),e++;continue}}r.push(t)}const i=n??e.url;if(!i)throw new Error("FFmpegInput missing url/input");return[...r,"-i",i,"-map","0:a:0?","-fflags","nobuffer","-flags","low_delay","-flush_packets","1","-vn","-sn","-dn","-acodec","pcm_s16le","-ar",t.sampleRate.toString(),"-ac",t.channels.toString(),"-f","s16le","pipe:1"]}encodeImaAdpcm(e,t){const s=2*t+1,r=Math.ceil(e.length/s),n=[],i=Int8Array.from([-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8]),A=Int16Array.from([7,8,9,10,11,12,13,14,16,17,19,21,23,25,28,31,34,37,41,45,50,55,60,66,73,80,88,97,107,118,130,143,157,173,190,209,230,253,279,307,337,371,408,449,494,544,598,658,724,796,876,963,1060,1166,1282,1411,1552,1707,1878,2066,2272,2499,2749,3024,3327,3660,4026,4428,4871,5358,5894,6484,7132,7845,8630,9493,10442,11487,12635,13899,15289,16818,18500,20350,22385,24623,27086,29794,32767]);let o=0;for(let s=0;s<r;s++){const s=Buffer.alloc(4+t);let r=e[o]??0,a=0;s.writeInt16LE(r,0),s.writeUInt8(a,2),s.writeUInt8(0,3),o++;const c=new Uint8Array(2*t);for(let t=0;t<c.length;t++){const s=e[o]??r;o++;let n=s-r,l=0;n<0&&(l=8,n=-n);let h=A[a]??7,g=0,d=h>>3;n>=h&&(g|=4,n-=h,d+=h),h>>=1,n>=h&&(g|=2,n-=h,d+=h),h>>=1,n>=h&&(g|=1,d+=h),l?r-=d:r+=d,r=this.clamp16(r),a+=i[g]??0,a<0&&(a=0),a>88&&(a=88),c[t]=15&(g|l)}for(let e=0;e<t;e++){const t=c[2*e]??0,r=c[2*e+1]??0;s[4+e]=15&t|(15&r)<<4}n.push(s)}return Buffer.concat(n)}}},7927:function(e,t,s){"use strict";var r,n=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,n)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),A=this&&this.__importStar||(r=function(e){return r=Object.getOwnPropertyNames||function(e){var t=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[t.length]=s);return t},r(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s=r(e),A=0;A<s.length;A++)"default"!==s[A]&&n(t,e,s[A]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0});const o=A(s(7562)),a=s(4417),c=s(6125),l=s(5582),h=s(6185),g=s(2256);class d extends o.ScryptedDeviceBase{constructor(e){super(e),this.devices=new Map;const t=o.default.systemManager.getDeviceByName("Scrypted NVR");this.nvrDeviceId=t?.id}getScryptedDeviceCreator(){return"Reolink Native camera"}async getDevice(e){if(this.devices.has(e))return this.devices.get(e);const t=this.createCamera(e);return this.devices.set(e,t),t}async createDevice(e,t){const r=e.ip?.toString(),n=e.username?.toString(),i=e.password?.toString(),A=e.uid?.toString();if(!r||!n||!i)throw new Error("IP address, username, and password are required");this.console.log(`[AutoDetect] Starting device type detection for ${r}...`);const{autoDetectDeviceType:a}=await Promise.resolve().then(s.bind(s,863)),c=await a({host:r,username:n,password:i,uid:A,logger:this.console});this.console.log(`[AutoDetect] Detected device type: ${c.type} (transport: ${c.transport})`);const d=c.api;if("multifocal"===c.type){const s=c.deviceInfo||{},A=s.name||"Reolink Multi-Focal";t=`${s.serialNumber||s.itemNo||`multifocal-${Date.now()}`}${"udp"===c.transport?h.batteryMultifocalSuffix:h.multifocalSuffix}`,e.newCamera||=A;const{capabilities:a,objects:l,presets:u}=await d.getDeviceCapabilities(),{interfaces:E}=(0,h.getDeviceInterfaces)({capabilities:a,logger:this.console});await o.default.deviceManager.onDeviceDiscovered({nativeId:t,name:A,interfaces:E,type:o.ScryptedDeviceType.DeviceProvider,providerNativeId:this.nativeId});const I=await this.getDevice(t);if(!(I instanceof g.ReolinkNativeMultiFocalDevice))throw new Error("Expected multi-focal device but got different type");return I.classes=l,I.presets=u,I.storageSettings.values.ipAddress=r,I.storageSettings.values.username=n,I.storageSettings.values.password=i,I.storageSettings.values.uid=c.uid||"",I.storageSettings.values.capabilities=a,t}if("nvr"===c.type){const s=c.deviceInfo||{},A=s?.name||"Reolink NVR";t=`${s?.serialNumber||s?.itemNo||`nvr-${Date.now()}`}${h.nvrSuffix}`,e.newCamera||=A,await o.default.deviceManager.onDeviceDiscovered({nativeId:t,name:A,interfaces:[o.ScryptedInterface.Settings,o.ScryptedInterface.DeviceDiscovery,o.ScryptedInterface.DeviceProvider,o.ScryptedInterface.Reboot],type:o.ScryptedDeviceType.DeviceProvider,providerNativeId:this.nativeId});const a=await this.getDevice(t);if(!(a instanceof l.ReolinkNativeNvrDevice))throw new Error("Expected NVR device but got different type");return a.storageSettings.values.ipAddress=r,a.storageSettings.values.username=n,a.storageSettings.values.password=i,t}const u=c.deviceInfo||{},E=u?.name||"Reolink Camera",I=u?.serialNumber||u?.itemNo||`unknown-${Date.now()}`;t="battery-cam"===c.type?`${I}${h.batteryCameraSuffix}`:`${I}${h.cameraSuffix}`,e.newCamera||=E;try{const e=0,{capabilities:s,objects:A,presets:a}=await d.getDeviceCapabilities(e),{interfaces:l,type:g}=(0,h.getDeviceInterfaces)({capabilities:s,logger:this.console});await o.default.deviceManager.onDeviceDiscovered({nativeId:t,name:E,interfaces:l,type:g,providerNativeId:this.nativeId});const I=await this.getDevice(t);return I.info=u,I.classes=A,I.presets=a,I.storageSettings.values.username=n,I.storageSettings.values.password=i,I.storageSettings.values.rtspChannel=e,I.storageSettings.values.ipAddress=r,I.storageSettings.values.capabilities=s,I.storageSettings.values.uid=c.uid,t}catch(e){throw this.console.error("Error adding Reolink device",e),e}}async releaseDevice(e,t){if(this.devices.has(t)){const e=this.devices.get(t);e&&"release"in e&&"function"==typeof e.release&&await e.release(),this.devices.delete(t)}}async getCreateDeviceSettings(){return[{key:"ip",title:"IP Address",placeholder:"192.168.2.222",value:"192.168."},{key:"username",title:"Username",value:"admin"},{key:"password",title:"Password",type:"password"},{key:"uid",title:"UID",description:"Reolink UID (optional, required for battery cameras if TCP connection fails)"}]}createCamera(e){return e.endsWith(h.batteryCameraSuffix)?new c.ReolinkNativeBatteryCamera(e,this):e.endsWith(h.nvrSuffix)?new l.ReolinkNativeNvrDevice(e,this):e.endsWith(h.batteryMultifocalSuffix)?new g.ReolinkNativeMultiFocalDevice(e,this,"multi-focal-battery"):e.endsWith(h.multifocalSuffix)?new g.ReolinkNativeMultiFocalDevice(e,this,"multi-focal"):new a.ReolinkNativeCamera(e,this)}}t.default=d},2256:function(e,t,s){"use strict";var r,n=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,n)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),A=this&&this.__importStar||(r=function(e){return r=Object.getOwnPropertyNames||function(e){var t=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[t.length]=s);return t},r(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s=r(e),A=0;A<s.length;A++)"default"!==s[A]&&n(t,e,s[A]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.ReolinkNativeMultiFocalDevice=void 0;const o=A(s(7562)),a=s(4417),c=s(6125),l=s(8799),h=s(5050),g=s(6185);class d extends l.CommonCameraMixin{constructor(e,t,s){super(e,t,{type:s}),this.cameraNativeMap=new Map,this.channelToNativeIdMap=new Map,this.plugin=t,this.scheduleInit()}getAbilities(){const{capabilities:e}=this.storageSettings.values;return{...e,hasPan:!1,hasTilt:!1,hasZoom:!1,hasPresets:!1,hasIntercom:!1}}getConnectionCallbacks(){return{onError:void 0,onClose:async()=>{await this.reinit(),this.isBattery||setTimeout((async()=>{try{await this.subscribeToEvents()}catch(e){this.getBaichuanLogger().warn("Failed to resubscribe to events after reconnection",e)}}),1e3)},onSimpleEvent:e=>this.forwardNativeEvent(e),getEventSubscriptionEnabled:()=>!0}}async onBeforeCleanup(){await this.unsubscribeFromAllEvents()}getDeviceName(){return this.name||"Multi-Focal Device"}async reinit(){this.initReinitTimeout&&(clearTimeout(this.initReinitTimeout),this.initReinitTimeout=void 0),this.scheduleInit(!0)}scheduleInit(e=!1){this.initReinitTimeout&&clearTimeout(this.initReinitTimeout),this.initReinitTimeout=setTimeout((async()=>{const t=this.getBaichuanLogger();e&&(t.log("Reinitializing multi-focal device..."),await this.cleanupBaichuanApi()),await this.init(),this.initReinitTimeout=void 0}),e?500:2e3)}async init(){const e=this.getBaichuanLogger();try{this.storageSettings.settings.uid.hide=!this.isBattery,await this.ensureBaichuanClient(),await this.updateDeviceInfo(),await this.reportDevices(),await this.subscribeToEvents()}catch(t){e.error("Failed to initialize multi-focal device",t),t instanceof Error?(e.error(`Error message: ${t.message}`),e.error(`Error stack: ${t.stack}`)):e.error(`Error details: ${JSON.stringify(t)}`)}}async updateDeviceInfo(){const e=this.getBaichuanLogger();try{const t=await this.ensureBaichuanClient(),s=await t.getInfo();await(0,g.updateDeviceInfo)({device:this,deviceData:s,ipAddress:this.storageSettings.values.ipAddress,logger:e})}catch(t){e.warn("Failed to fetch device info",t)}}getInterfaces(e){const t=this.getBaichuanLogger(),s=this.storageSettings.values,{capabilities:r,multifocalInfo:n}=s,i=n.channels.find((t=>t.channel===e)),A={...r,hasPan:i.hasPan,hasTilt:i.hasTilt,hasZoom:i.hasZoom,hasPresets:i.hasPresets,hasIntercom:i.hasIntercom},{interfaces:o}=(0,g.getDeviceInterfaces)({capabilities:A,logger:t});return{interfaces:o,capabilities:A}}async reportDevices(){const e=await this.ensureBaichuanClient(),t=this.getBaichuanLogger(),{username:s,password:r,ipAddress:n,uid:i}=this.storageSettings.values,{capabilities:A,support:a,abilities:c,features:l,objects:d,presets:u}=await e.getDeviceCapabilities(),E=await e.getDualLensChannelInfo();t.log(`Sync entities from remote for ${E.channels.length} channels`),this.storageSettings.values.multifocalInfo=E,this.storageSettings.values.capabilities=A,t.log(`Multichannel info: ${JSON.stringify({multifocalInfo:E,capabilities:A,support:a,abilities:c,features:l,objects:d,presets:u})}`);for(const e of E?.channels??[]){const{channel:A,lensType:a}=e,c=`${this.name} - ${a}`,l=`${this.nativeId}-channel${A}${this.isBattery?g.batteryCameraSuffix:g.cameraSuffix}`;this.channelToNativeIdMap.set(A,l);const{interfaces:h,capabilities:E}=this.getInterfaces(A),I={providerNativeId:this.nativeId,name:c,nativeId:l,info:{...this.info,metadata:{channel:A,lensType:a}},interfaces:h,type:o.ScryptedDeviceType.Camera};await o.default.deviceManager.onDeviceDiscovered(I),t.log(`Discovering lens device ${l}: ${JSON.stringify({interfaces:h,deviceCapabilities:E})}`);const p=await this.getDevice(l);p?(p.storageSettings.values.rtspChannel=A,p.classes=d,p.presets=u,p.storageSettings.values.username=s,p.storageSettings.values.password=r,p.storageSettings.values.ipAddress=n,p.storageSettings.values.capabilities=E,this.isBattery&&(p.storageSettings.values.uid=i)):t.error(`Failed to get device ${l}`)}await super.reportDevices();const I=this.storageSettings.values,p=I.pipPosition||"bottom-right",C=I.pipSize??.25,B=I.pipMargin??10,f=I.widerChannel??0,Q=I.teleChannel??1;this.streamManager,this.streamManager=new h.StreamManager({createStreamClient:()=>this.createStreamClient(),getLogger:()=>t,credentials:{username:s,password:r},sharedConnection:this.isBattery,compositeOptions:{widerChannel:f,teleChannel:Q,pipPosition:p,pipSize:C,pipMargin:B}})}async getDevice(e){if(e.endsWith(g.cameraSuffix)||e.endsWith(g.batteryCameraSuffix)){let t=this.cameraNativeMap.get(e);return t||(t=e.endsWith(g.batteryCameraSuffix)?new c.ReolinkNativeBatteryCamera(e,this.plugin,void 0,this):new a.ReolinkNativeCamera(e,this.plugin,void 0,this)),t}return super.getDevice(e)}async getSettings(){return await this.storageSettings.getSettings()}async putSetting(e,t){return this.storageSettings.putSetting(e,t)}async releaseDevice(e,t){this.cameraNativeMap.delete(t),super.releaseDevice(e,t)}forwardNativeEvent(e){const t=this.getBaichuanLogger(),s=e?.channel;if(void 0===s)return void t.debug("Event missing channel, ignoring");const r=this.channelToNativeIdMap.get(s);if(!r)return void t.debug(`No camera found for channel ${s}, ignoring event`);const n=this.cameraNativeMap.get(r);n?n.onSimpleEvent(e):t.debug(`Camera ${r} not yet initialized, ignoring event`)}async unsubscribeFromAllEvents(){await super.unsubscribeFromEvents()}async runDiagnostics(){const e=this.getBaichuanLogger();e.log("Starting Multifocal diagnostics...");try{const{ipAddress:t,username:s,password:r}=this.storageSettings.values;if(!t||!s||!r)throw new Error("Missing device credentials");const n=await this.ensureBaichuanClient(),i=await n.collectMultifocalDiagnostics(e);e.log("NVR diagnostics completed successfully."),e.log(JSON.stringify(i))}catch(t){throw e.error("Failed to run NVR diagnostics",t),t}}}t.ReolinkNativeMultiFocalDevice=d},5582:function(e,t,s){"use strict";var r,n=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,n)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),A=this&&this.__importStar||(r=function(e){return r=Object.getOwnPropertyNames||function(e){var t=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[t.length]=s);return t},r(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s=r(e),A=0;A<s.length;A++)"default"!==s[A]&&n(t,e,s[A]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.ReolinkNativeNvrDevice=void 0;const o=A(s(7562)),a=s(6117),c=s(7077),l=s(4417),h=s(6125),g=s(5098),d=s(6185);class u extends c.BaseBaichuanClass{constructor(e,t){super(e),this.storageSettings=new a.StorageSettings(this,{debugLogs:{title:"Debug Events",type:"boolean",immediate:!0},eventSource:{title:"Event Source",description:"Select the source for camera events: Native (Baichuan) or CGI (HTTP polling)",type:"string",choices:["Native","CGI"],defaultValue:"Native",immediate:!0,onPut:async()=>{await this.reinitEventSubscriptions()}},ipAddress:{title:"IP address",type:"string",onPut:async()=>await this.reinit()},username:{title:"Username",placeholder:"admin",defaultValue:"admin",type:"string",onPut:async()=>await this.reinit()},password:{title:"Password",type:"password",onPut:async()=>await this.reinit()},diagnosticsRun:{subgroup:"Diagnostics",title:"Run NVR Diagnostics",description:"Collect NVR diagnostics and display results in logs.",type:"button",immediate:!0,onPut:async()=>{await this.runNvrDiagnostics()}}}),this.discoveredDevices=new Map,this.cameraNativeMap=new Map,this.channelToNativeIdMap=new Map,this.processing=!1,this.plugin=t,this.scheduleInit()}async reboot(){const e=await this.ensureClient();await e.Reboot()}getConnectionConfig(){const{ipAddress:e,username:t,password:s}=this.storageSettings.values;if(!e||!t||!s)throw new Error("Missing NVR credentials");return{host:e,username:t,password:s,transport:"tcp",logger:this.console}}getConnectionCallbacks(){return{onError:void 0,onClose:async()=>{await this.reinit()},onSimpleEvent:e=>this.forwardNativeEvent(e),getEventSubscriptionEnabled:()=>"Native"===(this.storageSettings.values.eventSource||"Native")}}isDebugEnabled(){return this.storageSettings.values.debugLogs||!1}getDeviceName(){return this.name||"NVR"}async onBeforeCleanup(){await this.unsubscribeFromAllEvents()}async reinit(){this.initReinitTimeout&&(clearTimeout(this.initReinitTimeout),this.initReinitTimeout=void 0),this.scheduleInit(!0)}scheduleInit(e=!1){this.initReinitTimeout&&clearTimeout(this.initReinitTimeout),this.initReinitTimeout=setTimeout((async()=>{if(e){if(this.nvrApi)try{await this.nvrApi.logout()}catch{}this.nvrApi=void 0,await super.cleanupBaichuanApi()}await this.init(),this.initReinitTimeout=void 0}),e?500:2e3)}async ensureClient(){if(this.nvrApi)return this.nvrApi;const{ipAddress:e,username:t,password:r}=this.storageSettings.values;if(!e||!t||!r)throw new Error("Missing NVR credentials");const{ReolinkCgiApi:n}=await Promise.resolve().then(s.bind(s,863));return this.nvrApi=new n({host:e,username:t,password:r}),await this.nvrApi.login(),this.nvrApi}forwardNativeEvent(e){const t=this.getBaichuanLogger();if("Native"===(this.storageSettings.values.eventSource||"Native"))try{t.debug(`Baichuan event: ${JSON.stringify(e)}`);const s=e?.channel;if(void 0===s)return void t.error("Event has no channel, ignoring");const r=this.channelToNativeIdMap.get(s),n=r?this.cameraNativeMap.get(r):void 0;if(!n)return void t.debug(`No camera found for channel ${s}, ignoring event`);const i=[];let A=!1;switch(e?.type){case"motion":A=!0;break;case"doorbell":try{"function"==typeof n.handleDoorbellEvent&&n.handleDoorbellEvent()}catch(e){t.warn(`Error handling doorbell event for camera channel ${s}`,e)}A=!0;break;case"people":case"vehicle":case"animal":case"face":case"package":case"other":i.push(e.type),A=!0;break;default:return void t.error(`Unknown event type: ${e?.type}`)}n.processEvents({motion:A,objects:i}).catch((e=>{t.warn(`Error processing events for camera channel ${s}`,e)}))}catch(e){t.warn("Error in NVR Native event forwarder",e)}}async ensureBaichuanClient(){return await super.ensureBaichuanClient()}async subscribeToAllEvents(){"Native"!==(this.storageSettings.values.eventSource||"Native")?await this.unsubscribeFromAllEvents():await super.subscribeToEvents()}async runNvrDiagnostics(){const e=this.getBaichuanLogger();e.log("Starting NVR diagnostics...");try{const t=await this.ensureClient(),s=await t.collectNvrDiagnostics({logger:this.console});e.log("NVR diagnostics completed successfully."),t.printNvrDiagnostics(s,this.console)}catch(t){throw e.error("Failed to run NVR diagnostics",t),t}}async unsubscribeFromAllEvents(){await super.unsubscribeFromEvents()}async reinitEventSubscriptions(){const e=this.getBaichuanLogger(),{eventSource:t}=this.storageSettings.values;"Native"!==t?await this.unsubscribeFromAllEvents():this.subscribeToAllEvents().catch((t=>{e.warn("Failed to subscribe to Native events",t)})),e.log(`Event source set to: ${t}`)}forwardCgiEvents(e){this.getBaichuanLogger().debug(`CGI Events call result: ${JSON.stringify(e)}`);for(const[t,s]of this.channelToNativeIdMap.entries()){const r=s?this.cameraNativeMap.get(s):void 0,n=e[t];n&&r&&r.processEvents(n)}}async init(){const e=this.getBaichuanLogger(),t=await this.ensureClient();await this.ensureBaichuanClient(),await this.updateDeviceInfo(),await this.reinitEventSubscriptions(),setInterval((async()=>{if(!this.processing&&t){this.processing=!0;try{const s=Date.now();if((!this.lastErrorsCheck||s-this.lastErrorsCheck>6e4)&&(this.lastErrorsCheck=s),!this.lastNvrInfoCheck||s-this.lastNvrInfoCheck>3e5){this.lastNvrInfoCheck=s;const{nvrData:r}=await t.getNvrInfo(),{devicesData:n,channelsResponse:i,response:A}=await t.getDevicesInfo();e.log("NVR info data fetched"),e.debug(`${JSON.stringify({nvrData:r,devicesData:n,channelsResponse:i,response:A})}`),await this.discoverDevices(!0)}const{eventSource:r}=this.storageSettings.values;if("CGI"===r){const e=await t.getAllChannelsEvents();this.forwardCgiEvents(e.parsed)}const{batteryInfoData:n,response:i}=await t.getAllChannelsBatteryInfo();e.debug(`Battery info call result: ${JSON.stringify({batteryInfoData:n,response:i})}`),this.cameraNativeMap.forEach((e=>{if(e){const t=e.storageSettings.values.rtspChannel,s=n[t];s&&e.updateSleepingState({reason:"NVR",state:s.sleeping?"sleeping":"awake",idleMs:0,lastRxAtMs:0}).catch((()=>{}))}}))}catch(t){e.error("Error on events flow",t)}finally{this.processing=!1}}}),1e3)}async updateDeviceInfo(){const e=this.getBaichuanLogger(),{ipAddress:t}=this.storageSettings.values;try{const s=await this.ensureClient(),r=await s.getInfo();await(0,d.updateDeviceInfo)({device:this,ipAddress:t,deviceData:r,logger:e})}catch(t){e.warn("Failed to fetch device info",t)}}async getSettings(){return await this.storageSettings.getSettings()}async putSetting(e,t){return this.storageSettings.putSetting(e,t)}async releaseDevice(e,t){this.cameraNativeMap.delete(t)}async getDevice(e){let t=this.cameraNativeMap.get(e);return t||(t=e.endsWith("-battery-cam")?new h.ReolinkNativeBatteryCamera(e,this.plugin,this):new l.ReolinkNativeCamera(e,this.plugin,this),this.cameraNativeMap.set(e,t)),t}buildNativeId(e,t,s){const r=s?"-battery-cam":"-cam";return t?`${this.nativeId}-ch${e}-${t}${r}`:`${this.nativeId}-ch${e}${r}`}getCameraInterfaces(){return[o.ScryptedInterface.VideoCameraConfiguration,o.ScryptedInterface.Camera,o.ScryptedInterface.MotionSensor,o.ScryptedInterface.VideoTextOverlays,o.ScryptedInterface.VideoCamera,o.ScryptedInterface.Settings,o.ScryptedInterface.ObjectDetector]}async syncEntitiesFromRemote(){const e=this.getBaichuanLogger(),t=await this.ensureClient(),s=await this.ensureBaichuanClient();if(s?.client&&!s.client.isSocketConnected()){e.debug("Waiting for Baichuan connection to be established...");let t=0;for(;!s.client.isSocketConnected()&&t<50;)await new Promise((e=>setTimeout(e,100))),t++;s.client.isSocketConnected()?e.debug("Baichuan connection established"):e.warn("Baichuan connection not established after waiting, proceeding anyway")}const{devicesData:r,channels:n}=await t.getDevicesInfo();if(n.length){e.log(`Sync entities from remote for ${n.length} channels`);for(const t of n)try{const{channelStatus:s,channelInfo:n,abilities:i}=r[t],A=s?.name,a=s?.uid,c=!!i?.battery?.ver,l=this.buildNativeId(t,a,c),h=[o.ScryptedInterface.VideoCamera];c&&h.push(o.ScryptedInterface.Battery);const g=i.supportDoorbellLight?o.ScryptedDeviceType.Doorbell:o.ScryptedDeviceType.Camera,d={nativeId:l,name:A,providerNativeId:this.nativeId,interfaces:h,type:g,info:{manufacturer:"Reolink",model:n?.typeInfo,serialNumber:a}};if(this.channelToNativeIdMap.set(t,l),o.default.deviceManager.getNativeIds().includes(l))continue;if(this.discoveredDevices.has(l))continue;this.discoveredDevices.set(l,{device:d,description:`${A} (Channel ${t})`,rtspChannel:t,deviceData:r[t]}),e.debug(`Discovered channel ${t}: ${A}`)}catch(s){e.debug(`Error processing channel ${t}: ${s?.message||String(s)}`)}e.debug(`Channel discovery completed. ${JSON.stringify({devicesData:r,channels:n})}`)}else e.debug(`No channels found, ${JSON.stringify({devicesData:r,channels:n})}`)}async discoverDevices(e){return this.discoverDevicesPromise?await this.discoverDevicesPromise:e?(this.discoverDevicesPromise=(async()=>{try{return await this.syncEntitiesFromRemote(),[...this.discoveredDevices.values()].map((e=>({...e.device,description:e.description})))}finally{this.discoverDevicesPromise=void 0}})(),await this.discoverDevicesPromise):[...this.discoveredDevices.values()].map((e=>({...e.device,description:e.description})))}async adoptDevice(e){const t=this.discoveredDevices.get(e.nativeId);if(!t)throw new Error("device not found");await this.onDeviceEvent(o.ScryptedInterface.DeviceDiscovery,await this.discoverDevices());const r=t.device.interfaces.includes(o.ScryptedInterface.Battery),{channelStatus:n}=t.deviceData,{ReolinkBaichuanApi:i}=await Promise.resolve().then(s.bind(s,863)),A=n?.uid,a=r&&A?(0,g.normalizeUid)(A):void 0,c=new i({host:this.storageSettings.values.ipAddress,username:this.storageSettings.values.username,password:this.storageSettings.values.password,transport:"tcp",channel:t.rtspChannel,...a?{uid:a}:{}});await c.login();const{capabilities:l,objects:h,presets:u}=await c.getDeviceCapabilities(t.rtspChannel),{interfaces:E,type:I}=(0,d.getDeviceInterfaces)({capabilities:l,logger:this.console}),p={...t.device,interfaces:E,type:I};await o.default.deviceManager.onDeviceDiscovered(p);const C=await this.getDevice(e.nativeId),B=this.getBaichuanLogger();B.log("Adopted device",C?.name),B.log(JSON.stringify(t));const{username:f,password:Q,ipAddress:m}=this.storageSettings.values;return C.storageSettings.values.rtspChannel=t.rtspChannel,C.classes=h,C.presets=u,C.storageSettings.values.username=f,C.storageSettings.values.password=Q,C.storageSettings.values.rtspChannel=t.rtspChannel,C.storageSettings.values.ipAddress=m,C.storageSettings.values.capabilities=l,C.storageSettings.values.uid=t.deviceData.channelStatus.uid,this.discoveredDevices.delete(e.nativeId),C?.id}}t.ReolinkNativeNvrDevice=u},840:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReolinkPtzPresets=void 0;t.ReolinkPtzPresets=class{constructor(e){this.camera=e}get storageSettings(){return this.camera.storageSettings}getPtzCapabilitiesStore(){return this.camera.ptzCapabilities}setPtzCapabilitiesStore(e){this.camera.ptzCapabilities=e}parsePresetIdFromSettingValue(e){const t=String(e??"").trim();if(!t)return;const s=t.includes("=")?t.split("=")[0]:t,r=Number(s);return Number.isFinite(r)?r:void 0}syncEnabledPresetsSettingAndCaps(e){const t=this.storageSettings.values.presets??[];if(!t.length)return;const s=new Map(e.map((e=>[e.id,e.name]))),r={};for(const e of t){const t=this.parsePresetIdFromSettingValue(e);if(void 0===t)continue;const n=(e.includes("=")?e.substring(e.indexOf("=")+1).trim():"")||s.get(t);n&&(r[String(t)]=n)}this.setPtzCapabilitiesStore({...this.getPtzCapabilitiesStore()??{},presets:r})}setCachedPtzPresets(e){const t=Array.isArray(e)?e:[];this.camera.presets=t;const s={};for(const e of t)s[String(e.id)]=e.name;this.setPtzCapabilitiesStore({...this.getPtzCapabilitiesStore()??{},presets:s})}getCachedPtzPresets(){const e=this.camera.presets;return Array.isArray(e)?e:[]}nextFreePresetId(e){const t=new Set(e.map((e=>e.id)));for(let e=1;e<=255;e++)if(!t.has(e))return e;throw new Error("No free PTZ preset id available (1..255)")}async refreshPtzPresets(){const e=await this.camera.ensureClient(),t=this.camera.storageSettings.values.rtspChannel,s=await e.getPtzPresets(t);return this.setCachedPtzPresets(s),this.syncEnabledPresetsSettingAndCaps(s),s}async moveToPreset(e){const t=await this.camera.ensureClient(),s=this.camera.storageSettings.values.rtspChannel;await t.moveToPtzPreset(s,e)}async createPtzPreset(e,t){const s=await this.camera.ensureClient(),r=this.camera.storageSettings.values.rtspChannel,n=String(e??"").trim();if(!n)throw new Error("Preset name is required");const i=await s.getPtzPresets(r),A=new Set(i.map((e=>e.id))),o=t??this.nextFreePresetId(i);if(void 0===t&&A.has(o))throw new Error(`PTZ preset id already in use: ${o}`);await s.setPtzPreset(r,o,n);const a=await s.getPtzPresets(r),c=a.some((e=>e.id===o));if(this.setCachedPtzPresets(a),!c)throw this.syncEnabledPresetsSettingAndCaps(a),new Error("PTZ preset save did not persist (camera returned an empty/unchanged preset list). Try again.");const l=this.storageSettings.values.presets??[];if(l.length){l.some((e=>this.parsePresetIdFromSettingValue(e)===o))||(l.push(`${o}=${n}`),this.storageSettings.values.presets=l)}return this.syncEnabledPresetsSettingAndCaps(a),{id:o,name:n}}async updatePtzPresetToCurrentPosition(e){const t=await this.camera.ensureClient(),s=this.camera.storageSettings.values.rtspChannel,r=this.getCachedPtzPresets().find((t=>t.id===e)),n=r?.name??`Preset ${e}`;await t.setPtzPreset(s,e,n),await this.refreshPtzPresets()}async deletePtzPreset(e){const t=await this.camera.ensureClient(),s=this.camera.storageSettings.values.rtspChannel;await t.deletePtzPreset(s,e);const r=this.storageSettings.values.presets;if(Array.isArray(r)&&r.length){const t=r.filter((e=>"string"==typeof e)).filter((t=>this.parsePresetIdFromSettingValue(t)!==e));this.storageSettings.values.presets=t}await this.refreshPtzPresets()}async renamePtzPreset(e,t){const s=await this.camera.ensureClient(),r=this.camera.storageSettings.values.rtspChannel,n=String(t??"").trim();if(!n)throw new Error("Preset name is required");await s.moveToPtzPreset(r,e),await s.setPtzPreset(r,e,n),await this.refreshPtzPresets()}}},5050:function(e,t,s){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StreamManager=void 0,t.parseStreamProfileFromId=function(e){if(!e)return;if(e.startsWith("native_")){return e.replace("native_","")}if(e.endsWith(".bcs")){return e.replace(".bcs","")}if(e.startsWith("h264Preview_")){if(e.endsWith("_main"))return"main";if(e.endsWith("_sub"))return"sub"}return},t.selectStreamOption=function(e,t){if(!t)throw new Error("video streams not set up or no longer exists.");const s=e?.find((e=>e.id===t.id))||e?.[0];if(!s)throw new Error("No stream options available");return s},t.expectedVideoTypeFromUrlMediaStreamOptions=function(e){const t=e?.video?.codec;return"string"!=typeof t?void 0:t.includes("265")?"H265":t.includes("264")?"H264":void 0},t.createRfc4571MediaObjectFromStreamManager=async function(e){const{streamManager:t,channel:s,profile:r,streamKey:i,expectedVideoType:A,selected:o,sourceId:a,onDetectedCodec:c}=e,{host:l,port:h,sdp:g,audio:d,username:u,password:E}=await t.getRfcStream(s,r,i,A);try{const e=/a=rtpmap:\d+\s+(H26[45])\//.exec(g)?.[1];if(e){const t="H265"===e?"h265":"h264";c?.(t)}}catch{}const{url:I,...p}=o;p.container="rtp",d&&(p.audio||={},p.audio.codec=d.codec,p.audio.sampleRate=d.sampleRate,p.audio.channels=d.channels);const C=new URL(l);C.port=h.toString(),C.protocol="tcp",C.username=u,C.password=E;const B={url:C,sdp:g,mediaStreamOptions:p};return await n.default.mediaManager.createMediaObject(Buffer.from(JSON.stringify(B)),"x-scrypted/x-rfc4571",{sourceId:a})},t.createRfc4571CompositeMediaObjectFromStreamManager=async function(e){const{streamManager:t,profile:s,streamKey:r,expectedVideoType:i,selected:A,sourceId:o,onDetectedCodec:a}=e,{host:c,port:l,sdp:h,audio:g,username:d,password:u}=await t.getRfcCompositeStream(s,r,i);try{const e=/a=rtpmap:\d+\s+(H26[45])\//.exec(h)?.[1];if(e){const t="H265"===e?"h265":"h264";a?.(t)}}catch{}const{url:E,...I}=A;I.container="rtp",g&&(I.audio||={},I.audio.codec=g.codec,I.audio.sampleRate=g.sampleRate,I.audio.channels=g.channels);const p=encodeURIComponent(d||""),C=encodeURIComponent(u||""),B={url:`tcp://${p}:${C}@${c}:${l}`,sdp:h,mediaStreamOptions:I};return await n.default.mediaManager.createMediaObject(Buffer.from(JSON.stringify(B)),"x-scrypted/x-rfc4571",{sourceId:o})};const n=r(s(7562));t.StreamManager=class{constructor(e){this.opts=e,this.nativeRfcServers=new Map,this.nativeRfcServerCreatePromises=new Map}getLogger(){return this.opts.getLogger()}async ensureNativeRfcServer(e,t,r,n){const i=this.nativeRfcServerCreatePromises.get(e);if(i)return await i;const A=(async()=>{const i=this.nativeRfcServers.get(e);if(i?.server?.listening){if(!n||i.videoType===n)return{host:i.host,port:i.port,sdp:i.sdp,audio:i.audio,username:i.username||this.opts.credentials.username,password:i.password||this.opts.credentials.password};this.getLogger().warn(`Native RFC cache codec mismatch for ${e}: cached=${i.videoType} expected=${n}; recreating server.`)}if(i){try{await i.close("recreate")}catch{}this.nativeRfcServers.delete(e)}const A=await this.opts.createStreamClient(),{createRfc4571TcpServer:o}=await Promise.resolve().then(s.bind(s,863)),{username:a,password:c}=this.opts.credentials,l=!this.opts.sharedConnection,h=await o({api:A,channel:t,profile:r,logger:this.getLogger(),expectedVideoType:n,closeApiOnTeardown:l,username:a,password:c});return this.nativeRfcServers.set(e,h),h.server.once("close",(()=>{const t=this.nativeRfcServers.get(e);t?.server===h.server&&this.nativeRfcServers.delete(e)})),{host:h.host,port:h.port,sdp:h.sdp,audio:h.audio,username:h.username||this.opts.credentials.username,password:h.password||this.opts.credentials.password}})();this.nativeRfcServerCreatePromises.set(e,A);try{return await A}finally{this.nativeRfcServerCreatePromises.delete(e)}}async getRfcStream(e,t,s,r){return await this.ensureNativeRfcServer(s,e,t,r)}async getRfcCompositeStream(e,t,r){const n=this.nativeRfcServerCreatePromises.get(t);if(n)return await n;const i=(async()=>{const n=this.nativeRfcServers.get(t);if(n?.server?.listening){if(!r||n.videoType===r)return{host:n.host,port:n.port,sdp:n.sdp,audio:n.audio,username:n.username||this.opts.credentials.username,password:n.password||this.opts.credentials.password};this.getLogger().warn(`Native RFC composite cache codec mismatch for ${t}: cached=${n.videoType} expected=${r}; recreating server.`)}if(n){try{await n.close("recreate")}catch{}this.nativeRfcServers.delete(t)}const i=await this.opts.createStreamClient(),{createRfc4571TcpServer:A}=await Promise.resolve().then(s.bind(s,863)),{username:o,password:a}=this.opts.credentials,c=!this.opts.sharedConnection,l=await A({api:i,channel:void 0,profile:e,logger:this.getLogger(),expectedVideoType:r,closeApiOnTeardown:c,username:o,password:a,compositeOptions:this.opts.compositeOptions});return this.nativeRfcServers.set(t,l),l.server.once("close",(()=>{const e=this.nativeRfcServers.get(t);e?.server===l.server&&this.nativeRfcServers.delete(t)})),{host:l.host,port:l.port,sdp:l.sdp,audio:l.audio,username:l.username||this.opts.credentials.username,password:l.password||this.opts.credentials.password}})();this.nativeRfcServerCreatePromises.set(t,i);try{return await i}finally{this.nativeRfcServerCreatePromises.delete(t)}}async closeAllStreams(e){const t=Array.from(this.nativeRfcServers.values());this.nativeRfcServers.clear(),await Promise.allSettled(t.map((async t=>{try{await t.close(e||"connection reset")}catch(e){this.getLogger().debug("Error closing stream server",e)}})))}}},6185:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateDeviceInfo=t.getDeviceInterfaces=t.pirSuffix=t.floodlightSuffix=t.sirenSuffix=t.cameraSuffix=t.batteryMultifocalSuffix=t.multifocalSuffix=t.batteryCameraSuffix=t.nvrSuffix=t.OperationChannelType=void 0;const r=s(7562);var n;!function(e){e.PAN="pan",e.TILT="tilt",e.ZOOM="zoom",e.INTERCOM="intercom",e.GOTO="goto",e.PRESET="preset",e.PATROL="patrol",e.TRACK="track"}(n||(t.OperationChannelType=n={})),t.nvrSuffix="-nvr",t.batteryCameraSuffix="-battery-cam",t.multifocalSuffix="-multifocal",t.batteryMultifocalSuffix="-battery-multifocal",t.cameraSuffix="-cam",t.sirenSuffix="-siren",t.floodlightSuffix="-floodlight",t.pirSuffix="-pir";t.getDeviceInterfaces=e=>{const{capabilities:t,logger:s}=e,n=[r.ScryptedInterface.VideoCamera,r.ScryptedInterface.Settings,r.ScryptedInterface.Reboot,r.ScryptedInterface.VideoCameraConfiguration,r.ScryptedInterface.Camera,r.ScryptedInterface.AudioSensor,r.ScryptedInterface.MotionSensor,r.ScryptedInterface.VideoTextOverlays];try{const{hasPtz:e,hasSiren:s,hasFloodlight:i,hasPir:A,hasBattery:o,hasIntercom:a,isDoorbell:c}=t;e&&n.push(r.ScryptedInterface.PanTiltZoom),n.push(r.ScryptedInterface.ObjectDetector),(s||i||A)&&n.push(r.ScryptedInterface.DeviceProvider),o&&n.push(r.ScryptedInterface.Battery,r.ScryptedInterface.Sleep),a&&n.push(r.ScryptedInterface.Intercom),c&&n.push(r.ScryptedInterface.BinarySensor)}catch(e){s.error("Error getting device interfaces",e)}return{interfaces:n,type:t.isDoorbell?r.ScryptedDeviceType.Doorbell:r.ScryptedDeviceType.Camera}};t.updateDeviceInfo=async e=>{const{device:t,ipAddress:s,deviceData:r,logger:n}=e;try{const e=t.info||{};e.ip=s,e.serialNumber=r?.serialNumber||r?.itemNo,e.firmware=r?.firmwareVersion,e.version=r?.hardwareVersion,e.model=r?.type,e.manufacturer="Reolink",e.managementUrl=`http://${s}`,t.info=e}catch(e){const r=t.info||{};throw r.ip=s,r.manufacturer="Reolink native",r.managementUrl=`http://${s}`,t.info=r,e}finally{n.log("Device info updated"),n.debug(`${JSON.stringify({newInfo:t.info,deviceData:r})}`)}}},5317:e=>{"use strict";e.exports=require("child_process")},4434:e=>{"use strict";e.exports=require("events")},9896:e=>{"use strict";e.exports=require("fs")},3339:e=>{"use strict";e.exports=require("module")},4589:e=>{"use strict";e.exports=require("node:assert")},6698:e=>{"use strict";e.exports=require("node:async_hooks")},4573:e=>{"use strict";e.exports=require("node:buffer")},1421:e=>{"use strict";e.exports=require("node:child_process")},7540:e=>{"use strict";e.exports=require("node:console")},7598:e=>{"use strict";e.exports=require("node:crypto")},3053:e=>{"use strict";e.exports=require("node:diagnostics_channel")},610:e=>{"use strict";e.exports=require("node:dns")},8474:e=>{"use strict";e.exports=require("node:events")},1455:e=>{"use strict";e.exports=require("node:fs/promises")},7067:e=>{"use strict";e.exports=require("node:http")},2467:e=>{"use strict";e.exports=require("node:http2")},7030:e=>{"use strict";e.exports=require("node:net")},6760:e=>{"use strict";e.exports=require("node:path")},643:e=>{"use strict";e.exports=require("node:perf_hooks")},1792:e=>{"use strict";e.exports=require("node:querystring")},99:e=>{"use strict";e.exports=require("node:sqlite")},7075:e=>{"use strict";e.exports=require("node:stream")},7997:e=>{"use strict";e.exports=require("node:timers")},1692:e=>{"use strict";e.exports=require("node:tls")},7975:e=>{"use strict";e.exports=require("node:util")},3429:e=>{"use strict";e.exports=require("node:util/types")},5919:e=>{"use strict";e.exports=require("node:worker_threads")},8522:e=>{"use strict";e.exports=require("node:zlib")},6928:e=>{"use strict";e.exports=require("path")},2203:e=>{"use strict";e.exports=require("stream")},9023:e=>{"use strict";e.exports=require("util")},3106:e=>{"use strict";e.exports=require("zlib")},5537:e=>{"use strict";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const s=new Int32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);function r(e){if(Buffer.isBuffer(e))return e;if("number"==typeof e)return Buffer.alloc(e);if("string"==typeof e)return Buffer.from(e);throw new Error("input must be buffer, number, or string, received "+typeof e)}function n(e,t){e=r(e),Buffer.isBuffer(t)&&(t=t.readUInt32BE(0));let n=~t;for(var i=0;i<e.length;i++)n=s[255&(n^e[i])]^n>>>8;return~n}function i(){return function(e){const t=r(4);return t.writeInt32BE(e,0),t}(n.apply(null,arguments))}i.signed=function(){return n.apply(null,arguments)},i.unsigned=function(){return n.apply(null,arguments)>>>0};const A=t(i);e.exports=A},6546:(e,t,s)=>{"use strict";s.d(t,{collectMultifocalDiagnostics:()=>r.RA,testChannelStreams:()=>r.bH});var r=s(5940)},5940:(e,t,s)=>{"use strict";s.d(t,{$8:()=>a,$v:()=>Se,AG:()=>Pe,Bz:()=>it,Ck:()=>ce,F3:()=>Re,Fi:()=>Be,Gz:()=>K,H9:()=>Ne,I4:()=>Z,KC:()=>se,Kv:()=>y,Mg:()=>d,N_:()=>Y,O1:()=>fe,Oh:()=>Ce,RA:()=>at,Rp:()=>O,S1:()=>g,S8:()=>U,T$:()=>we,TB:()=>Ee,Uh:()=>ne,VY:()=>re,XN:()=>ye,XW:()=>pe,Xf:()=>he,YF:()=>xe,YO:()=>V,aQ:()=>h,as:()=>Le,ax:()=>oe,bH:()=>ot,cY:()=>l,dB:()=>ue,d_:()=>Ae,f9:()=>Ie,fP:()=>Fe,fg:()=>Ye,fk:()=>Ve,g7:()=>te,gB:()=>be,gW:()=>At,gZ:()=>ee,iI:()=>Qe,kV:()=>nt,ki:()=>o,l$:()=>de,lp:()=>Xe,m8:()=>He,nf:()=>F,pH:()=>Me,pT:()=>ve,qD:()=>me,rB:()=>m,rJ:()=>ke,rO:()=>ge,tj:()=>j,ts:()=>le,uQ:()=>P,uy:()=>Oe,vF:()=>De,zt:()=>Te,zu:()=>Ue,zw:()=>ae});var r=s(9896),n=s(6928),i=s(5317),A=s(4434),o=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)((function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}));function a(e){const t=!0===e?.general,s=!0===e?.debugRtsp,r=!0===e?.traceStream,i=!0===e?.traceTalk,A=!0===e?.traceEvents,o=!0===e?.debugH264,a=!0===e?.debugParamSets,c=!0===e?.dump?.enabled;return{general:t,debugRtsp:s,traceStream:r,traceTalk:i,traceEvents:A,debugH264:o,debugParamSets:a,dumpEnabled:c,dumpDir:e?.dump?.dir&&e.dump.dir.trim()||n.join(process.cwd(),"test","frames-debug"),dumpBcMedia:e?.dump?.bcmedia??c,dumpNals:e?.dump?.nals??c}}function c(e){e.dumpEnabled&&r.mkdirSync(e.dumpDir,{recursive:!0})}function l(e,t,s,r){e.general&&t.debug(`[${s}] ${r}`)}function h(e,t,s,r){e.traceStream&&t.debug(`[${s}] ${r}`)}function g(e,t,s,r){e.traceTalk&&t.debug(`[${s}] ${r}`)}function d(e,t,s,r){e.traceEvents&&t.debug(`[${s}] ${r}`)}function u(e){if(e.length<4)return null;const t=e.readUInt32LE(0);return 825241649===t?function(e){if(e.length<32)return null;const t=e.readUInt32LE(4);if(32!==t)return null;const s={type:"InfoV1",videoWidth:e.readUInt32LE(8),videoHeight:e.readUInt32LE(12),fps:e.readUInt8(17),startYear:e.readUInt8(18),startMonth:e.readUInt8(19),startDay:e.readUInt8(20),startHour:e.readUInt8(21),startMin:e.readUInt8(22),startSeconds:e.readUInt8(23),endYear:e.readUInt8(24),endMonth:e.readUInt8(25),endDay:e.readUInt8(26),endHour:e.readUInt8(27),endMin:e.readUInt8(28),endSeconds:e.readUInt8(29)};return{media:s,consumed:32}}(e):842018865===t?function(e){if(e.length<32)return null;const t=e.readUInt32LE(4);if(32!==t)return null;const s={type:"InfoV2",videoWidth:e.readUInt32LE(8),videoHeight:e.readUInt32LE(12),fps:e.readUInt8(17),startYear:e.readUInt8(18),startMonth:e.readUInt8(19),startDay:e.readUInt8(20),startHour:e.readUInt8(21),startMin:e.readUInt8(22),startSeconds:e.readUInt8(23),endYear:e.readUInt8(24),endMonth:e.readUInt8(25),endDay:e.readUInt8(26),endHour:e.readUInt8(27),endMin:e.readUInt8(28),endSeconds:e.readUInt8(29)};return{media:s,consumed:32}}(e):t>=1667510320&&t<=1667510329?function(e){if(e.length<20)return null;const t=e.toString("utf8",4,8);if("H264"!==t&&"H265"!==t)return null;const s=t,r=e.readUInt32LE(8),n=e.readUInt32LE(12),i=e.readUInt32LE(16);let A=20;const o=e.readUInt32LE(A);let a;if(A+=4,e.length<A+n)return null;const c=e.subarray(A,A+n);n>=4&&(a=c.readUInt32LE(0));if(A+=n,e.length<A+r)return null;const l=e.subarray(A,A+r);A+=r;const h=r%8==0?0:8-r%8;if(e.length<A+h)return null;A+=h;return{media:{type:"Iframe",videoType:s,microseconds:i,...void 0!==a?{time:a}:{},additionalHeader:c,additionalHeaderSize:n,unknown:o,data:l},consumed:A}}(e):t>=1667510576&&t<=1667510585?function(e){if(e.length<20)return null;const t=e.toString("utf8",4,8);if("H264"!==t&&"H265"!==t)return null;const s=t,r=e.readUInt32LE(8),n=e.readUInt32LE(12),i=e.readUInt32LE(16);let A=20;const o=e.readUInt32LE(A);if(A+=4,e.length<A+n)return null;const a=e.subarray(A,A+n);if(A+=n,e.length<A+r)return null;const c=e.subarray(A,A+r);A+=r;const l=r%8==0?0:8-r%8;if(e.length<A+l)return null;A+=l;return{media:{type:"Pframe",videoType:s,microseconds:i,additionalHeader:a,additionalHeaderSize:n,unknown:o,data:c},consumed:A}}(e):1651979568===t?function(e){if(e.length<12)return null;const t=e.readUInt16LE(4),s=e.readUInt16LE(6);if(t!==s)return null;const r=8,n=r+t+(t%8==0?0:8-t%8);if(e.length<n)return null;const i=e.subarray(r,r+t);return{media:{type:"Aac",data:i},consumed:n}}(e):1651978544===t?function(e){if(e.length<12)return null;const t=e.readUInt16LE(4),s=e.readUInt16LE(6);if(t!==s)return null;const r=e.readUInt16LE(8);if(256!==r)return null;e.readUInt16LE(10);const n=4;if(t<n)return null;const i=t-n,A=12,o=A+i+(t%8==0?0:8-t%8);if(e.length<o)return null;const a=e.subarray(A,A+i);return{media:{type:"Adpcm",data:a},consumed:o}}(e):null}var E=class{buffer=Buffer.alloc(0);strict;amountSkipped=0;logger;constructor(e=!1,t){this.strict=e,this.logger=t}decode(e){this.buffer=0===this.buffer.length?e:Buffer.concat([this.buffer,e]);const t=[];for(;this.buffer.length>=4;){const e=u(this.buffer);if(!e){const e=this.buffer.readUInt32LE(0);if(825241649===e||842018865===e||e>=1667510320&&e<=1667510329||e>=1667510576&&e<=1667510585||1651979568===e||1651978544===e)break;if(this.strict)throw new Error(`[BcMediaCodec] Invalid data in stream (no valid magic at buffer start, len=${this.buffer.length})`);0===this.amountSkipped&&this.logger?.warn("[BcMediaCodec] Error in stream, attempting to recover..."),this.amountSkipped+=this.buffer.length,this.buffer=Buffer.alloc(0);break}this.amountSkipped>0&&(this.strict,this.logger?.warn(`[BcMediaCodec] Recovered stream after skipping ${this.amountSkipped} bytes`),this.amountSkipped=0),t.push(e.media),this.buffer=this.buffer.subarray(e.consumed)}return t}getRemainingBuffer(){return this.buffer}clear(){this.buffer=Buffer.alloc(0),this.amountSkipped=0}},I=Buffer.from([0,0,0,1]),p=Buffer.from([0,0,1]);function C(e){return!(e.length<4)&&(!!e.subarray(0,4).equals(I)||!!e.subarray(0,3).equals(p))}function B(e,t){const s=[];let r=0,n=0;for(;r<e.length;){if(r+4>e.length)return null;const i=t(e,r);if(r+=4,i<=0)return null;if(i>e.length-r)return null;s.push(I),s.push(e.subarray(r,r+i)),r+=i,n++}return 0===n?null:Buffer.concat(s)}function f(e,t){const s=[];let r=0,n=0;for(;r<e.length;){if(r+2>e.length)return null;const i=t(e,r);if(r+=2,i<=0)return null;if(i>e.length-r)return null;s.push(I),s.push(e.subarray(r,r+i)),r+=i,n++}return 0===n?null:Buffer.concat(s)}function Q(e,t){const s=[];let r=0,n=0;const i=(e,s)=>{if(s+3>e.length)return 0;const r=e[s],n=e[s+1],i=e[s+2];return"be"===t?(r<<16|n<<8|i)>>>0:(i<<16|n<<8|r)>>>0};for(;r<e.length;){if(r+3>e.length)return null;const t=i(e,r);if(r+=3,t<=0)return null;if(t>e.length-r)return null;s.push(I),s.push(e.subarray(r,r+t)),r+=t,n++}return 0===n?null:Buffer.concat(s)}function m(e){if(C(e))return e;const t=Buffer.from([0,0,0,1]),s=Buffer.from([0,0,1]),r=Math.min(64,e.length),n=e.subarray(0,r).indexOf(t);if(n>0)return e.subarray(n);const i=e.subarray(0,r).indexOf(s);if(i>0)return e.subarray(i);const A=B(e,((e,t)=>e.readUInt32BE(t)));if(A)return A;const o=B(e,((e,t)=>e.readUInt32LE(t)));if(o)return o;const a=Q(e,"be");if(a)return a;const c=Q(e,"le");if(c)return c;const l=f(e,((e,t)=>e.readUInt16BE(t)));if(l)return l;const h=f(e,((e,t)=>e.readUInt16LE(t)));if(h)return h;const g=function(e){if(e.length<1)return null;const t=31&e[0],s=[],r=e=>{0!==e.length&&s.push(I,e)};if(24===t){let t=1;for(;t+2<=e.length;){const s=e.readUInt16BE(t);if(t+=2,s<=0||t+s>e.length)return null;r(e.subarray(t,t+s)),t+=s}return s.length?Buffer.concat(s):null}if(25===t){let t=3;if(t>e.length)return null;for(;t+2<=e.length;){const s=e.readUInt16BE(t);if(t+=2,s<=0||t+s>e.length)return null;r(e.subarray(t,t+s)),t+=s}return s.length?Buffer.concat(s):null}if(26===t){let t=3;if(t>e.length)return null;for(;t+2<=e.length;){const s=e.readUInt16BE(t);if(t+=2,t+1+2>e.length)return null;if(t+=1,t+=2,s<=0||t+s>e.length)return null;r(e.subarray(t,t+s)),t+=s}return s.length?Buffer.concat(s):null}if(27===t){let t=3;if(t>e.length)return null;for(;t+2<=e.length;){const s=e.readUInt16BE(t);if(t+=2,t+1+3>e.length)return null;if(t+=1,t+=3,s<=0||t+s>e.length)return null;r(e.subarray(t,t+s)),t+=s}return s.length?Buffer.concat(s):null}return null}(e);return g||(function(e){if(e.length<1)return!1;const t=e[0];if(void 0===t)return!1;if(128&t)return!1;const s=31&t;return s>=1&&s<=23}(e)?Buffer.concat([I,e]):e)}function y(e){const t=[];for(let s=0;s<e.length-3;s++)0===e[s]&&0===e[s+1]&&(1===e[s+2]?(t.push({idx:s,len:3}),s+=2):0===e[s+2]&&1===e[s+3]&&(t.push({idx:s,len:4}),s+=3));if(0===t.length)return[];const s=[];for(let r=0;r<t.length;r++){const n=t[r],i=n.idx+n.len,A=t[r+1]?t[r+1].idx:e.length;A>i&&s.push(e.subarray(i,A))}return s}function w(e){if(!C(e))return!1;const t=y(e);if(0===t.length)return!1;for(const e of t){if(e.length<1)return!1;const t=e[0];if(void 0===t)return!1;if(128&t)return!1;const s=31&t;if(0===s||s>=24)return!1}return!0}function S(e){const t=y(e);let s=!1,r=!1,n=!1;for(const e of t){const t=31&(e[0]??0);7===t&&(s=!0),8===t&&(r=!0),5===t&&(n=!0)}return n&&s&&r}var D=class e{fuNalHeader=null;fuParts=[];static parseRtpPayload(e){if(!e||e.length<12)return null;if(2!==(e[0]>>6&3))return null;const t=!!(32&e[0]),s=!!(16&e[0]);let r=12+4*(15&e[0]);if(r>e.length)return null;if(s){if(r+4>e.length)return null;if(r+=4+4*e.readUInt16BE(r+2),r>e.length)return null}let n=e.length;if(t){const t=e[e.length-1];if(t<=0||t>e.length)return null;if(n=e.length-t,n<r)return null}return n<=r?null:e.subarray(r,n)}reset(){this.fuNalHeader=null,this.fuParts=[]}push(t){if(0===t.length)return[];const s=e.parseRtpPayload(t);if(s&&(t=s),C(t))return[t];const r=t[0];if(128&r)return[];const n=31&r;if(n>=1&&n<=23)return[Buffer.concat([I,t])];if(24===n){if(t.length<3)return[];let e=1;const s=[];for(;e+2<=t.length;){const r=t.readUInt16BE(e);if(e+=2,r<=0||e+r>t.length)return[];const n=t.subarray(e,e+r);if(e+=r,n.length<1)return[];if(128&n[0])return[];const i=31&n[0];if(0===i||i>=24)return[];s.push(Buffer.concat([I,n]))}return s}if(28===n||29===n){if(t.length<2)return[];const e=t[0],s=t[1],r=!!(128&s),i=!!(64&s),A=224&e|31&s;let o=2;if(29===n){if(t.length<o+2)return[];o+=2}const a=t.subarray(o);if(r)this.fuNalHeader=A,this.fuParts=[a];else{if(null==this.fuNalHeader)return[];this.fuParts.push(a)}if(i&&null!=this.fuNalHeader){const e=Buffer.concat([Buffer.from([this.fuNalHeader]),...this.fuParts]);return this.reset(),[Buffer.concat([I,e])]}return[]}return[]}};var b=Buffer.from([0,0,0,1]),v=Buffer.from([0,0,1]);function R(e){return!(e.length<4)&&(!!e.subarray(0,4).equals(b)||!!e.subarray(0,3).equals(v))}function N(e,t){const s=[];let r=0,n=0;for(;r<e.length;){if(r+4>e.length)return null;const i=t(e,r);if(r+=4,i<=0)return null;if(i>e.length-r)return null;s.push(b),s.push(e.subarray(r,r+i)),r+=i,n++}return 0===n?null:Buffer.concat(s)}function k(e,t){const s=[];let r=0,n=0;for(;r<e.length;){if(r+2>e.length)return null;const i=t(e,r);if(r+=2,i<=0)return null;if(i>e.length-r)return null;s.push(b),s.push(e.subarray(r,r+i)),r+=i,n++}return 0===n?null:Buffer.concat(s)}function T(e,t){const s=[];let r=0,n=0;const i=(e,s)=>{if(s+3>e.length)return 0;const r=e[s],n=e[s+1],i=e[s+2];return"be"===t?(r<<16|n<<8|i)>>>0:(i<<16|n<<8|r)>>>0};for(;r<e.length;){if(r+3>e.length)return null;const t=i(e,r);if(r+=3,t<=0)return null;if(t>e.length-r)return null;s.push(b),s.push(e.subarray(r,r+t)),r+=t,n++}return 0===n?null:Buffer.concat(s)}function F(e){if(R(e))return e;const t=Buffer.from([0,0,0,1]),s=Buffer.from([0,0,1]),r=Math.min(64,e.length),n=e.subarray(0,r).indexOf(t);if(n>0)return e.subarray(n);const i=e.subarray(0,r).indexOf(s);if(i>0)return e.subarray(i);const A=N(e,((e,t)=>e.readUInt32BE(t)));if(A)return A;const o=N(e,((e,t)=>e.readUInt32LE(t)));if(o)return o;const a=T(e,"be");if(a)return a;const c=T(e,"le");if(c)return c;const l=k(e,((e,t)=>e.readUInt16BE(t)));if(l)return l;const h=k(e,((e,t)=>e.readUInt16LE(t)));return h||(function(e){if(e.length<2)return!1;const t=e[0],s=e[1];return void 0!==t&&void 0!==s&&(!(128&t)&&(t>>1&63)<=40)}(e)?Buffer.concat([b,e]):e)}var M=class e{fuParts=null;reset(){this.fuParts=null}static parseRtpPayload(e){if(!e||e.length<12)return null;if(2!==(e[0]>>6&3))return null;const t=!!(32&e[0]),s=!!(16&e[0]);let r=12+4*(15&e[0]);if(r>e.length)return null;if(s){if(r+4>e.length)return null;if(r+=4+4*e.readUInt16BE(r+2),r>e.length)return null}let n=e.length;if(t){const t=e[e.length-1];if(t<=0||t>e.length)return null;if(n=e.length-t,n<r)return null}return n<=r?null:e.subarray(r,n)}push(t){if(!t||t.length<2)return[];const s=e.parseRtpPayload(t);s&&(t=s);const r=t[0],n=t[1];if(128&r)return[];const i=r>>1&63;if(48===i){let e=2;const s=[];for(;e+2<=t.length;){const r=t.readUInt16BE(e);if(e+=2,r<=0||e+r>t.length)return[];const n=t.subarray(e,e+r);e+=r,n.length&&s.push(b,n)}return s.length?[Buffer.concat(s)]:[]}if(49===i){if(t.length<3)return[];const e=t[2],s=!!(128&e),i=!!(64&e),A=129&r|(63&(63&e))<<1,o=n,a=t.subarray(3);if(s)this.fuParts=[b,Buffer.from([A,o]),a];else{if(!this.fuParts)return[];this.fuParts.push(a)}if(i){if(!this.fuParts)return[];const e=Buffer.concat(this.fuParts);return this.fuParts=null,[e]}return[]}return[Buffer.concat([b,t])]}};function U(e){const t=[];for(let s=0;s<e.length-3;s++)0===e[s]&&0===e[s+1]&&(1===e[s+2]?(t.push({idx:s,len:3}),s+=2):0===e[s+2]&&1===e[s+3]&&(t.push({idx:s,len:4}),s+=3));if(0===t.length)return[];const s=[];for(let r=0;r<t.length;r++){const n=t[r],i=n.idx+n.len,A=t[r+1]?t[r+1].idx:e.length;A>i&&s.push(e.subarray(i,A))}return s}function L(e){if(e.length<1)return null;const t=e[0];return void 0===t||128&t?null:t>>1&63}function P(e){return e>=16&&e<=23}function x(e){if(!R(e))return!1;const t=U(e);if(0===t.length)return!1;for(const e of t){if(e.length<2)return!1;const t=e[0];if(void 0===t)return!1;if(128&t)return!1;const s=L(e);if(null===s)return!1;if(s>40)return!1}return!0}function H(e){const t=U(e);let s=!1,r=!1,n=!1,i=!1;for(const e of t){const t=L(e);null!==t&&(32===t&&(s=!0),33===t&&(r=!0),34===t&&(n=!0),P(t)&&(i=!0))}return i&&s&&r&&n}function Y(e){const t=U(e);for(const e of t){if(32===L(e))return e}return null}function V(e){const t=U(e);for(const e of t){if(33===L(e))return e}return null}function O(e){const t=U(e);for(const e of t){if(34===L(e))return e}return null}var G=Buffer.from([0,0,0,1]),J=class{running=!1;queue=[];maxQueueSize;constructor(e){this.maxQueueSize=e}enqueue(e){this.queue.length>=this.maxQueueSize||(this.queue.push(e),this.pump())}pump(){this.running||(this.running=!0,this.run())}async run(){try{for(;this.queue.length>0;){const e=this.queue.shift();if(e)try{await e()}catch{}}}finally{this.running=!1}}};function W(e){const t=[];for(let s=0;s<e.length;s++)s>=2&&3===e[s]&&0===e[s-1]&&0===e[s-2]||t.push(e[s]);return Buffer.from(t)}var _=class{b;bitPos=0;constructor(e){this.b=e}readBits(e){if(e<=0)return 0;let t=0;for(let s=0;s<e;s++){const e=this.bitPos>>3;if(e>=this.b.length)return null;const s=7-(7&this.bitPos);t=t<<1|this.b[e]>>s&1,this.bitPos++}return t>>>0}readUE(){let e=0;for(;;){const t=this.readBits(1);if(null==t)return null;if(0!==t)break;if(e++,e>31)return null}const t=e?this.readBits(e):0;return null==t?null:(1<<e)-1+t>>>0}};function $(e){if(7!=(31&(e[0]??0)))return null;const t=W(e.subarray(1)),s=new _(t);return null==s.readBits(8)||null==s.readBits(8)||null==s.readBits(8)?null:s.readUE()}function q(e){if(8!=(31&(e[0]??0)))return null;const t=W(e.subarray(1)),s=new _(t),r=s.readUE(),n=s.readUE();return null==r||null==n?null:{ppsId:r,spsId:n}}function z(e){const t=31&(e[0]??0);if(1!==t&&5!==t)return null;const s=W(e.subarray(1)),r=new _(s);return null==r.readUE()||null==r.readUE()?null:r.readUE()}var j=class e extends A.EventEmitter{client;api;channel;profile;logger;active=!1;videoFrameHandler;expectedStreamType;activeMsgNum;bcMediaCodec;debugH264LogsLeft;debugSavedSamples;warnedNonAnnexBOnce=!1;depacketizer=new D;depacketizerH265=new M;dumpChunkIdx=0;dumpNalLines=0;dumpIo=new J(200);spsById=new Map;ppsById=new Map;lastSps=null;lastPps=null;lastPrependedPpsId=null;lastVps=null;lastSpsH265=null;lastPpsH265=null;lastPrependedParamSetsH265=!1;lastMediaAtMs=0;watchdogTimer;restarting=!1;restartWindowStartMs=0;restartCountInWindow=0;idleRestartMs;static scoreBcMediaLike(e){if(e.length<4)return{score:-1,first:-1};const t=Math.min(65536,e.length-4);let s=0,r=-1;for(let n=0;n<=t;n++){const t=e.readUInt32LE(n);if((825241649===t||842018865===t||t>=1667510320&&t<=1667510329||t>=1667510576&&t<=1667510585||1651979568===t||1651978544===t)&&(s++,r<0&&(r=n),s>32&&0===r))break}return{score:1e3*s-(r<0?5e4:r),first:r}}chooseDecryptedOrRawCandidate(t){const{raw:s,enc:r,channelId:n,allowResync:i}=t,A=e.scoreBcMediaLike(s),o="aes"===this.client.enc.kind||"full_aes"===this.client.enc.kind||"bc"===this.client.enc.kind?this.client.tryDecryptBinary(s,n,r):s,a=e.scoreBcMediaLike(o).score>A.score?o:s;if(!i)return a;const c=e.scoreBcMediaLike(a);return c.first>0?a.subarray(c.first):a}constructor(e){super(),this.client=e.client,this.api=e.api,this.channel=e.channel,this.profile=e.profile,this.logger=e.logger,this.expectedStreamType="sub"===this.profile?1:0,this.bcMediaCodec=new E(!1,this.logger);const t=this.client.getDebugConfig();this.debugH264LogsLeft=t.debugH264?200:0,this.debugSavedSamples=!1,this.dumpChunkIdx=0,this.spsById=new Map,this.ppsById=new Map,this.lastSps=null,this.lastPps=null,this.lastPrependedPpsId=null,this.lastVps=null,this.lastSpsH265=null,this.lastPpsH265=null,this.lastPrependedParamSetsH265=!1;const s=this.client.getTransport?.();this.idleRestartMs="udp"===s?6e3:15e3}noteMediaActivity(){this.lastMediaAtMs=Date.now()}startWatchdog(){this.api&&(this.watchdogTimer||(this.restartWindowStartMs=Date.now(),this.restartCountInWindow=0,this.watchdogTimer=setInterval((()=>{this.watchdogTick()}),1e3)))}stopWatchdog(){this.watchdogTimer&&clearInterval(this.watchdogTimer),this.watchdogTimer=void 0}async watchdogTick(){if(!this.active)return;if(!this.api)return;if(this.restarting)return;if(this.lastMediaAtMs<=0)return;const e=Date.now(),t=e-this.lastMediaAtMs;t<this.idleRestartMs||(e-this.restartWindowStartMs>6e4&&(this.restartWindowStartMs=e,this.restartCountInWindow=0),this.restartCountInWindow++,this.restartNativeStream({reason:`idle ${t}ms`}))}async restartNativeStream(e){if(this.api&&this.active&&!this.restarting){this.restarting=!0;try{const t=this.client.getTransport?.()??"unknown",s=this.activeMsgNum??"unknown";this.logger?.warn(`[BaichuanVideoStream] Watchdog restarting native stream (channel=${this.channel} profile=${this.profile} streamType=${this.expectedStreamType} msgNum=${s} transport=${t} reason=${e.reason})`),this.depacketizer.reset(),this.depacketizerH265.reset(),this.bcMediaCodec.clear(),this.activeMsgNum=void 0,this.lastPrependedPpsId=null,this.lastPrependedParamSetsH265=!1;try{await this.api.stopVideoStream(this.channel,this.profile)}catch{}await this.api.startVideoStream(this.channel,this.profile);try{const e=this.api.getActiveVideoMsgNum;this.activeMsgNum="function"==typeof e?e(this.channel,this.profile):void 0}catch{this.activeMsgNum=void 0}this.lastMediaAtMs=Date.now()}catch(e){const t=e instanceof Error?e:new Error(String(e));this.emit("error",t)}finally{this.restarting=!1}}}async start(){if(this.active)throw new Error("Video stream already active");if(this.depacketizer.reset(),this.depacketizerH265.reset(),this.api)try{await this.api.startVideoStream(this.channel,this.profile);try{const e=this.api.getActiveVideoMsgNum;this.activeMsgNum="function"==typeof e?e(this.channel,this.profile):void 0}catch{this.activeMsgNum=void 0}}catch(e){const t=e instanceof Error?e:new Error(String(e));if("udp"===this.client.getTransport?.())throw t;this.emit("error",t)}let e=0,t=0;this.videoFrameHandler=s=>{if(3!==s.header.cmdId)return;if(s.header.streamType!==this.expectedStreamType)return;if(void 0!==this.activeMsgNum&&s.header.msgNum!==this.activeMsgNum)return;e++;const i=this.client.getDebugConfig(),A=i.debugRtsp;1===e&&A&&this.logger?.log(`[BaichuanVideoStream] First cmd_id=3 frame received (bodyLen: ${s.body.length}, channelId: ${s.header.channelId})`),(e%10==0||e<=5)&&A&&this.logger?.log(`[BaichuanVideoStream] Received ${e} Baichuan frames (cmd_id=3)`);const o=this.client.enc,a=s.payload.length>0?s.payload:s.body;let l=a;if(0===s.payload.length){let e=0;const t=a.indexOf(Buffer.from("</Extension>")),s=a.indexOf(Buffer.from("</body>"));-1!==t?e=t+Buffer.from("</Extension>").length:-1!==s&&(e=s+Buffer.from("</body>").length),l=a.subarray(e)}const h=this.chooseDecryptedOrRawCandidate({raw:l,enc:o,channelId:s.header.channelId,allowResync:0===s.payload.length});if(1===e&&A&&this.logger?.log(`[BaichuanVideoStream] Data after XML: ${h.length} bytes, first 32 bytes: ${h.subarray(0,Math.min(32,h.length)).toString("hex")}`),i.dumpEnabled&&c(i),i.dumpBcMedia&&this.dumpChunkIdx<200){const e=i.dumpDir,t=String(this.dumpChunkIdx).padStart(4,"0"),s=n.join(e,`bcmedia_chunk_${t}.bin`),A=n.join(e,"bcmedia_info.json"),o=Buffer.from(h),a=0===this.dumpChunkIdx,c=a?JSON.stringify({note:"Chunks fed into the BcMedia decoder (after XML stripping/alignment).",profile:this.profile,channel:this.channel,encKind:this.client.enc.kind},null,2):"";this.dumpIo.enqueue((async()=>{await r.promises.writeFile(s,o),a&&await r.promises.writeFile(A,c)})),this.dumpChunkIdx++}const g=this.bcMediaCodec.decode(h);t+=g.length;const d=new Map;for(const e of g)d.set(e.type,(d.get(e.type)||0)+1);if(e<=10||e%20==0){const s=this.bcMediaCodec.getRemainingBuffer(),r=Array.from(d.entries()).map((([e,t])=>`${e}:${t}`)).join(", ");A&&this.logger?.log(`[BaichuanVideoStream] Frame #${e}: dataToParse=${h.length} bytes, parsed ${g.length} BcMedia packets (${r||"none"}), total: ${t}, remaining buffer: ${s.length} bytes`)}let u=0,E=0;for(const t of g){const s=(e,t,s)=>{if("H264"===s){const t=y(e);for(const e of t){const t=31&(e[0]??0);if(7===t){const t=$(e);if(null!=t){if(!l(e))continue;this.spsById.set(t,e),i.debugParamSets&&this.logger?.warn(`[BaichuanVideoStream] Cached H.264 SPS id=${t} len=${e.length}`)}l(e)&&(this.lastSps=e)}if(8===t){const t=q(e);if(t){const s=this.spsById.get(t.spsId);if(s&&!l(s))continue;this.ppsById.set(t.ppsId,{nal:e,spsId:t.spsId}),i.debugParamSets&&this.logger?.warn(`[BaichuanVideoStream] Cached H.264 PPS id=${t.ppsId} (spsId=${t.spsId}) len=${e.length}`)}this.lastPps=e}}}else if("H265"===s){const t=Y(e);t&&(this.lastVps=t,i.debugParamSets&&this.logger?.warn(`[BaichuanVideoStream] Cached H.265 VPS len=${t.length}`));const s=V(e);s&&(this.lastSpsH265=s,i.debugParamSets&&this.logger?.warn(`[BaichuanVideoStream] Cached H.265 SPS len=${s.length}`));const r=O(e);r&&(this.lastPpsH265=r,i.debugParamSets&&this.logger?.warn(`[BaichuanVideoStream] Cached H.265 PPS len=${r.length}`))}},o=(e,t)=>{if("H264"===t){const t=y(e);if(0===t.length)return e;const s=t.map((e=>31&(e[0]??0)));if(s.includes(7)&&s.includes(8))return e;if(!s.some((e=>1===e||5===e||19===e||20===e)))return e;let r=null;for(const e of t){const t=31&(e[0]??0);if(1===t||5===t){r=z(e);break}}if(i.debugParamSets&&this.logger?.warn(`[BaichuanVideoStream] Slice references ppsId=${r??"?"} lastPrepended=${this.lastPrependedPpsId??"?"}`),null==r||r>255)return null!=this.lastPrependedPpsId?e:this.lastSps&&this.lastPps?(this.lastPrependedPpsId=-1,Buffer.concat([G,this.lastSps,G,this.lastPps,e])):e;if(this.lastPrependedPpsId===r)return e;const n=this.ppsById.get(r);if(n){const t=this.spsById.get(n.spsId);if(t)return this.lastPrependedPpsId=r,Buffer.concat([G,t,G,n.nal,e])}return Buffer.alloc(0)}if("H265"===t){const t=U(e);if(0===t.length)return e;const s=t.map((e=>L(e))).filter((e=>null!==e));if(s.includes(32)&&s.includes(33)&&s.includes(34))return e;return s.some((e=>e>=0&&e<=9||e>=16&&e<=23))?this.lastPrependedParamSetsH265?e:this.lastVps&&this.lastSpsH265&&this.lastPpsH265?(this.lastPrependedParamSetsH265=!0,i.debugParamSets&&this.logger?.warn("[BaichuanVideoStream] Prepending H.265 VPS/SPS/PPS to frame"),Buffer.concat([G,this.lastVps,G,this.lastSpsH265,G,this.lastPpsH265,e])):e:e}return e},a=(e,t,s)=>{if(i.dumpNals)try{i.dumpEnabled&&c(i);const A=i.dumpDir,o=y(e),a=o.map((e=>31&(e[0]??0)));let l=null;const h=[],g=[];for(const e of o){const t=31&(e[0]??0);if(1!==t&&5!==t||null!=l||(l=z(e)),7===t){const t=$(e);null!=t&&h.push(t)}if(8===t){const t=q(e);t&&g.push(t.ppsId)}}if(this.dumpNalLines>=2e4)return;const d=JSON.stringify({label:t,microseconds:s,len:e.length,nalTypes:a,slicePpsId:l,auSpsIds:h,auPpsIds:g,cachedSps:this.spsById.size,cachedPps:this.ppsById.size,lastPrependedPpsId:this.lastPrependedPpsId})+"\n";this.dumpNalLines++;const u=n.join(A,"nal_dump.ndjson");this.dumpIo.enqueue((async()=>{await r.promises.appendFile(u,d)}))}catch{}},l=e=>{if(e.length<4)return!1;if(7!=(31&(e[0]??0)))return!1;const t=e[1]??0,s=e[3]??0;return!!new Set([66,77,88,100,110,122,244]).has(t)&&!(0===s||s>255)};if("Iframe"===t.type){const c="H265"===t.videoType?F(t.data):m(t.data),l=!0;s(c,"Iframe",t.videoType);const h=o(c,t.videoType);if(0===h.length)continue;if(a(h,"Iframe",t.microseconds),"H264"===t.videoType){if(!w(h)||!S(h)){i.debugH264&&this.logger?.warn(`[BaichuanVideoStream] Dropping invalid H.264 Iframe (Annex-B) len=${h.length}`);continue}}else if("H265"===t.videoType){if(!x(h)){i.debugH264&&this.logger?.warn(`[BaichuanVideoStream] Dropping invalid H.265 Iframe (Annex-B) len=${h.length}`);continue}H(h)||i.debugH264&&this.logger?.warn(`[BaichuanVideoStream] H.265 Iframe missing VPS/SPS/PPS or IRAP, but continuing len=${h.length}`)}if(i.debugH264&&!this.debugSavedSamples)try{const e=i.dumpDir;r.mkdirSync(e,{recursive:!0}),"Iframe"===t.type&&C(c)&&r.writeFileSync(n.join(e,"iframe_annexb.bin"),c)}catch{}if(!this.warnedNonAnnexBOnce&&!C(c)){this.warnedNonAnnexBOnce=!0;const e=t.data,s=e.subarray(0,Math.min(24,e.length)).toString("hex"),r=c.subarray(0,Math.min(24,c.length)).toString("hex");this.logger?.warn(`[BaichuanVideoStream] WARNING: non-AnnexB frame after conversion (${t.type} ${t.videoType}) len=${e.length} head=${s} convertedLen=${c.length} convertedHead=${r}`)}if(this.emit("videoFrame",h),this.emit("videoAccessUnit",{data:h,isKeyframe:l,videoType:t.videoType,microseconds:t.microseconds,..."Iframe"===t.type&&"time"in t&&void 0!==t.time?{time:t.time}:{}}),u++,e<=5||u<=5){const e=C(c)?"yes":"no";A&&this.logger?.log(`[BaichuanVideoStream] Emitted ${t.type} (${t.videoType}) ${t.data.length} bytes -> ${c.length} bytes (Annex-B, startCode:${e})`)}}else if("Pframe"===t.type){const e=t.data,r=C(e)?e:"H265"===t.videoType?F(e):m(e),n=C(r)?[r]:"H265"===t.videoType?this.depacketizerH265.push(e):this.depacketizer.push(e);if(0===n.length)continue;for(const e of n){s(e,"Pframe",t.videoType);const r=o(e,t.videoType);if(0===r.length)continue;const n=r;a(n,"Pframe",t.microseconds);if("H265"===t.videoType?x(n):w(n))this.emit("videoFrame",n),this.emit("videoAccessUnit",{data:n,isKeyframe:!1,videoType:t.videoType,microseconds:t.microseconds}),u++;else if(i.debugH264&&this.debugH264LogsLeft>0){this.debugH264LogsLeft--;const e=n.subarray(0,Math.min(24,n.length)).toString("hex");this.logger?.warn(`[BaichuanVideoStream] Dropping invalid Pframe (${t.videoType}): len=${n.length} head=${e}`)}}}"Aac"!==t.type&&"Adpcm"!==t.type||(E++,this.emit("audioFrame",t.data)),"InfoV1"===t.type||t.type}if((e<=10||e%20==0&&(u>0||E>0))&&A&&this.logger?.log(`[BaichuanVideoStream] Frame #${e}: emitted ${u} video frames, ${E} audio frames`),(u>0||E>0)&&this.noteMediaActivity(),u>0&&(e<=10||e%50==0)){}},this.client.on("push",this.videoFrameHandler),this.active=!0,this.lastMediaAtMs=Date.now(),this.startWatchdog()}async stop(){if(this.active){if(this.stopWatchdog(),this.depacketizer.reset(),this.depacketizerH265.reset(),this.videoFrameHandler&&this.client.removeListener("push",this.videoFrameHandler),this.videoFrameHandler=void 0,this.bcMediaCodec.clear(),this.activeMsgNum=void 0,this.api)try{await this.api.stopVideoStream(this.channel,this.profile)}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}this.active=!1,this.emit("close")}}isActive(){return this.active}};function X(e){const t=e.port??554,s=function(e,t){let s;return s="main"===t?"main":"sub"===t?"sub":"ext",`/h264Preview_${String(e+1).padStart(2,"0")}_${s}`}(e.channel,e.stream);return`rtsp://${encodeURIComponent(e.username)}:${encodeURIComponent(e.password)}@${e.host}:${t}${s}`}var Z=9e3,K=Buffer.from([240,222,188,10]),ee=Buffer.from([160,203,237,15]),te=Uint8Array.from([31,45,60,75,90,105,120,255]),se=Buffer.from("0123456789abcdef","utf8"),re=25876,ne=25620,ie=0,Ae=25730;function oe(e){return e===ne||e===ie||e===Ae}var ae=3,ce=4,le=13,he=14,ge=15,de=16,ue=272,Ee=273,Ie=274,pe=10,Ce=11,Be=201,fe=202,Qe=18,me=19,ye=190,we=433,Se=294,De=295,be=252,ve=253,Re=234,Ne=212,ke=213,Te=47,Fe=343,Me=547,Ue=263,Le=289,Pe=288,xe=290,He=291,Ye=151,Ve=199,Oe=93;function Ge(e){if(e instanceof Error)return e.stack||e.message;try{return JSON.stringify(e)}catch{return String(e)}}async function Je(e){try{return{ok:!0,value:await e()}}catch(e){return{ok:!1,error:Ge(e)}}}function We(e){r.mkdirSync(e,{recursive:!0})}function _e(e,t){We(n.dirname(e)),r.writeFileSync(e,JSON.stringify(t,null,2))}function $e(e,t){We(n.dirname(e)),r.appendFileSync(e,JSON.stringify(t)+"\n")}function qe(e){return new Promise((t=>setTimeout(t,e)))}function ze(){return(new Date).toISOString().replace(/[:.]/g,"-")}function je(e,t){if("H264"===e){return y(t).map((e=>31&(e[0]??0)))}return U(t).map((e=>L(e))).filter((e=>"number"==typeof e))}async function Xe(e){const t=e.outDir;We(t);const[s,r]=await Promise.all([e.native?Je((()=>async function(e){const{api:t}=e,s=e.channel??0,r={kind:"native",channel:s,transport:t.client.getTransport?.(),encKind:t.client.enc?.kind,collectedAt:(new Date).toISOString()},[n,i,A,o,a,c,l]=await Promise.all([Je((()=>t.getInfo(s))),Je((()=>t.getPorts())),Je((()=>t.getStreamMetadata(s))),Je((()=>t.getAbilityInfo())),Je((()=>t.getDeviceCapabilities(s,{probe:!1}))),Je((()=>t.getTalkAbility(s))),Je((()=>t.getTwoWayAudioConfig(s)))]);if(r.info=n,r.ports=i,r.streamMetadata=A,r.abilityInfo=o,r.deviceCapabilities=a,r.talkAbility=c,r.twoWayAudio=l,c?.ok&&c.value){const e=c.value,t={duplex:Array.isArray(e.duplexList)?e.duplexList[0]:void 0,audioStreamMode:Array.isArray(e.audioStreamModeList)?e.audioStreamModeList[0]:void 0,audioConfig:Array.isArray(e.audioConfigList)?e.audioConfigList[0]:void 0};r.intercomRecommended=t}return r}(e.native))):Promise.resolve(void 0),e.cgi?Je((()=>async function(e){const{cgi:t}=e,s=e.channel??0,r={kind:"cgi",channel:s,collectedAt:(new Date).toISOString()},[n,i,A,o,a,c,l]=await Promise.all([Je((()=>t.getInfo(s))),Je((()=>t.GetNetPort())),Je((()=>t.GetAbility())),Je((()=>t.GetEnc(s))),Je((()=>t.GetChannelstatus())),Je((()=>t.GetChnTypeInfo(s))),Je((()=>t.GetAiState(s)))]);return r.info=n,r.netPort=i,r.ability=A,r.enc=o,r.channelStatus=a,r.channelTypeInfo=c,r.aiState=l,r.devicesInfo=await Je((()=>t.getDevicesInfo())),r}(e.cgi))):Promise.resolve(void 0)]),i={createdAt:(new Date).toISOString(),native:s,cgi:r,...e.extra?{extra:e.extra}:{}},A=n.join(t,"diagnostics.json");return _e(A,i),{outDir:t,diagnosticsPath:A}}function Ze(e){return e.replace(/([a-z]+:\/\/)([^:@\/\s]+):([^@\/\s]+)@/gi,((e,t,s,r)=>`${t}***:***@`))}function Ke(e,t){return new Promise((s=>{We(n.dirname(t));const A=r.createWriteStream(t,{flags:"a"}),o=(0,i.spawn)("ffmpeg",e,{stdio:["ignore","ignore","pipe"]});o.on("error",(e=>{A.write(`ffmpeg spawn error: ${e instanceof Error?e.message:String(e)}\n`),A.end(),s({ok:!1,error:e instanceof Error?e.message:String(e)})}));let a="";o.stderr.on("data",(e=>{const t=e.toString();a+=t,A.write(Ze(t))})),o.on("close",(e=>{if(A.end(),0===e)return void s({ok:!0});const t=`ffmpeg exited with code ${e}\n${a.slice(-4e3)}`;s({ok:!1,error:Ze(t)})}))}))}async function et(e){const t=e.durationSeconds??2,s=["-hide_banner","-loglevel","error",..."rtsp"===e.kind?["-rtsp_transport","tcp"]:[],"-i",e.url,"-t",String(t),"-f","null","-"];return new Promise((e=>{const r=(0,i.spawn)("ffmpeg",s,{stdio:["ignore","ignore","pipe"]});let n="",A=!1;r.stderr.on("data",(e=>{const t=e.toString();n+=t,(t.includes("Stream #0")||t.includes("Video:")||t.includes("Audio:")||t.includes("Duration:"))&&(A=!0)})),r.on("close",(s=>{if(0===s||A)e({ok:!0,value:{duration:t}});else{const t=`ffmpeg exited with code ${s}\n${n.slice(-1e3)}`;e({ok:!1,error:Ze(t)})}})),r.on("error",(t=>{const s=t instanceof Error?t.message:String(t);e({ok:!1,error:Ze(s)})}))}))}async function tt(e){const t=["-hide_banner","-loglevel","warning","-stats",..."rtsp"===e.kind?["-rtsp_transport","tcp"]:[],"-i",e.url,"-t",String(e.durationSeconds),"-c","copy","-y",e.outputMp4];return await Ke(t,e.logPath)}async function st(e){const t=`fps=1/${Math.max(.25,e.snapshotIntervalSeconds)}`,s=["-hide_banner","-loglevel","warning","-stats",..."rtsp"===e.kind?["-rtsp_transport","tcp"]:[],"-i",e.url,"-t",String(e.durationSeconds),"-vf",t,"-q:v","2","-y",e.snapshotsPattern];return await Ke(s,e.logPath)}async function rt(e){const t=["-hide_banner","-loglevel","warning","-stats","-f","H265"===e.videoType?"hevc":"h264","-i",e.snapshotAnnexBPath,"-frames:v","1","-q:v","2","-y",e.outputJpegPath];await Ke(t,e.logPath)}async function nt(e){const t=e.channel??0,s=Math.max(250,Math.round(1e3*e.durationSeconds)),i=e.snapshotIntervalSeconds??2,A=e.logger,o=(e,t,s)=>{const r=A?.[e]??A?.log;r&&(void 0!==s?r.call(A,t,s):r.call(A,t))},a=function(e){const t=[];for(const s of e??[])"main"!==s&&"sub"!==s&&"ext"!==s||t.includes(s)||t.push(s);return t}(e.selection.profiles),c=a.length?a:["main","sub","ext"],l=e.outDir;We(l),o("log","[Diagnostics] stream sampling start",{outDir:l,channel:t,durationSeconds:e.durationSeconds,snapshotIntervalSeconds:i,selection:e.selection});const h=n.join(l,"events.ndjson");$e(h,{t:Date.now(),type:"sampling_start",channel:t,durationSeconds:e.durationSeconds,snapshotIntervalSeconds:i,selection:e.selection});for(const A of c)for(const a of e.selection.kinds){const c=`${a}_${A}`,g=n.join(l,c);if(We(g),$e(h,{t:Date.now(),type:"stream_begin",kind:a,profile:A,channel:t}),o("log","[Diagnostics] stream begin",{kind:a,profile:A,channel:t}),"native"!==a)if("rtsp"!==a)if("rtmp"!==a);else{const s=e.rtmp?.urlsByProfile?.[A];if(!s){$e(h,{t:Date.now(),type:"stream_skip",kind:a,profile:A,reason:"rtmp url missing"}),o("warn","[Diagnostics] stream skip (rtmp url missing)",{kind:a,profile:A,channel:t});continue}const r=n.join(g,`clip_${ze()}.mp4`),c=n.join(g,"ffmpeg_record.log"),l=n.join(g,"snapshots");We(l);const d=n.join(l,"snap_%05d.jpg");$e(h,{t:Date.now(),type:"rtmp_url",kind:a,profile:A,url:s});const[u,E]=await Promise.all([tt({kind:"rtmp",url:s,outputMp4:r,durationSeconds:e.durationSeconds,logPath:c}),st({kind:"rtmp",url:s,snapshotsPattern:d,durationSeconds:e.durationSeconds,snapshotIntervalSeconds:i,logPath:n.join(g,"ffmpeg_snapshots.log")})]);$e(h,{t:Date.now(),type:"rtmp_done",kind:a,profile:A,mp4Path:r,record:u,snapshots:E}),o("log","[Diagnostics] stream done",{kind:a,profile:A,channel:t,mp4Path:r,record:u,snapshots:E})}else{if(!e.rtsp){$e(h,{t:Date.now(),type:"stream_skip",kind:a,profile:A,reason:"rtsp config missing"}),o("warn","[Diagnostics] stream skip (rtsp config missing)",{kind:a,profile:A,channel:t});continue}const s=X({host:e.rtsp.host,username:e.rtsp.username,password:e.rtsp.password,channel:t,stream:A,...null!=e.rtsp.port?{port:e.rtsp.port}:{}}),r=n.join(g,`clip_${ze()}.mp4`),c=n.join(g,"ffmpeg_record.log"),l=n.join(g,"snapshots");We(l);const d=n.join(l,"snap_%05d.jpg");$e(h,{t:Date.now(),type:"rtsp_url",kind:a,profile:A,url:s});const[u,E]=await Promise.all([tt({kind:"rtsp",url:s,outputMp4:r,durationSeconds:e.durationSeconds,logPath:c}),st({kind:"rtsp",url:s,snapshotsPattern:d,durationSeconds:e.durationSeconds,snapshotIntervalSeconds:i,logPath:n.join(g,"ffmpeg_snapshots.log")})]);$e(h,{t:Date.now(),type:"rtsp_done",kind:a,profile:A,mp4Path:r,record:u,snapshots:E}),o("log","[Diagnostics] stream done",{kind:a,profile:A,channel:t,mp4Path:r,record:u,snapshots:E})}else{const c=e.native?.api;if(!c){$e(h,{t:Date.now(),type:"stream_skip",kind:a,profile:A,reason:"native api missing"}),o("warn","[Diagnostics] stream skip (native api missing)",{kind:a,profile:A,channel:t});continue}const l=n.join(g,"raw_frames"),d=n.join(g,"snapshots");We(l),We(d);const u=e.limits?.maxNativeRawFrames??400,E=e.limits?.maxNativeRawBytes??52428800;let I=0,p=0;const C="sub"===A?1:0,B=e=>{if(!e?.header)return;if(3!==e.header.cmdId)return;if(e.header.streamType!==C)return;if(I>=u)return;const t=Buffer.isBuffer(e.payload)&&e.payload.length?e.payload:e.body;if(!Buffer.isBuffer(t)||0===t.length)return;if(p+t.length>E)return;I++,p+=t.length;const s=String(I).padStart(6,"0"),i=n.join(l,`frame_${s}.bin`);try{r.writeFileSync(i,t)}catch{}$e(h,{t:Date.now(),type:"native_raw_frame",kind:a,profile:A,idx:I,bytes:t.length,header:e.header,bodyLen:e.body?.length??0,payloadLen:e.payload?.length??0})};c.client.on("frame",B);const f=new j({client:c.client,api:c,channel:t,profile:A}),Q=n.join(g,`clip_${ze()}`),m=Q+".annexb",y=Q+".audio.bin",w=Q+".json",S=r.createWriteStream(m,{flags:"w"}),D=r.createWriteStream(y,{flags:"w"});let b,v=null,R=0,N=0,k=0,T=null;const F=e=>{if(!e||!Buffer.isBuffer(e.data))return;b||(b=e.videoType),R++;try{S.write(e.data)}catch{}e.isKeyframe&&null==v&&(v=Date.now());const t=je(e.videoType,e.data);$e(h,{t:Date.now(),type:"native_access_unit",kind:a,profile:A,isKeyframe:!!e.isKeyframe,videoType:e.videoType,microseconds:e.microseconds,bytes:e.data.length,nalTypes:t});const s=Date.now();if(e.isKeyframe&&s-k>=1e3*i){k=s;const t=ze(),i=n.join(d,`snap_${t}.${"H265"===e.videoType?"h265":"h264"}`);try{r.writeFileSync(i,e.data),$e(h,{t:Date.now(),type:"native_snapshot_saved",kind:a,profile:A,path:i});const s=n.join(d,`snap_${t}.jpg`);rt({videoType:e.videoType,snapshotAnnexBPath:i,outputJpegPath:s,logPath:n.join(g,"ffmpeg_snapshot.log")})}catch{}}},M=e=>{if(Buffer.isBuffer(e)&&0!==e.length){N++;try{D.write(e)}catch{}$e(h,{t:Date.now(),type:"native_audio",kind:a,profile:A,bytes:e.length})}};f.on("videoAccessUnit",F),f.on("audioFrame",M),f.on("error",(e=>{$e(h,{t:Date.now(),type:"native_error",kind:a,profile:A,error:Ge(e)})}));try{for(await f.start(),$e(h,{t:Date.now(),type:"native_started",kind:a,profile:A}),T=Date.now();Date.now()-T<s;)await qe(200)}finally{try{await f.stop()}catch{}c.client.removeListener("frame",B);try{S.end()}catch{}try{D.end()}catch{}const s={kind:a,profile:A,channel:t,durationSeconds:e.durationSeconds,videoAccessUnits:R,audioFrames:N,videoType:b,firstKeyframeLatencyMs:null==v||null==T?null:Math.max(0,v-T),rawFrames:I,rawBytes:p};_e(w,s),$e(h,{t:Date.now(),type:"native_done",...s}),o("log","[Diagnostics] stream done",s)}}}$e(h,{t:Date.now(),type:"sampling_done"})}async function it(e){const{cgi:t,logger:s}=e,r=(e,t)=>{s?.log?void 0!==t?s.log(e,t):s.log(e):(console.log(e),void 0!==t&&console.log(JSON.stringify(t,null,2)))},n={kind:"nvr_diagnostics",collectedAt:(new Date).toISOString()};r("=".repeat(80)),r("NVR/HUB DIAGNOSTICS - Starting comprehensive data collection"),r("=".repeat(80)),r("\n[1/7] Collecting NVR/HUB device information...");const i=await Je((()=>t.getNvrInfo()));n.nvrInfo=i,i.ok?r("✓ NVR/HUB info collected",{model:i.value.devInfo?.type,name:i.value.devInfo?.name,firmware:i.value.devInfo?.firmVer,hardware:i.value.devInfo?.hardVer,serial:i.value.devInfo?.serial}):r("✗ Failed to collect NVR/HUB info",i.error),r("\n[2/7] Discovering channels...");const A=await Je((()=>t.getChannels({useChannelNumFallback:!0})));n.channels=A;let o=[];A.ok?(o=A.value.channels,r(`✓ Found ${o.length} channel(s): ${o.join(", ")}`),n.channelList=o):(r("✗ Failed to discover channels",A.error),n.channelList=[]),r("\n[3/7] Collecting devices information for all channels...");const a=await Je((()=>t.getDevicesInfo({useChannelNumFallback:!0})));if(n.devicesInfo=a,a.ok){r(`✓ Devices info collected for ${Object.keys(a.value.devicesData).length} channel(s)`);for(const[e,t]of Object.entries(a.value.devicesData)){const s=t;r(` Channel ${Number(e)}:`,{model:s.channelInfo?.typeInfo||s.channelStatus?.typeInfo,name:s.channelStatus?.name,online:1===s.channelStatus?.online,sleeping:1===s.channelStatus?.sleep,uid:s.channelStatus?.uid,firmware:s.channelInfo?.firmVer,boardInfo:s.channelInfo?.boardInfo})}}else r("✗ Failed to collect devices info",a.error);r("\n[4/7] Collecting events and detection states for all channels...");const c=await Je((()=>t.getAllChannelsEvents({useChannelNumFallback:!0})));if(n.eventsInfo=c,c.ok){r(`✓ Events info collected for ${Object.keys(c.value.parsed).length} channel(s)`);for(const[e,t]of Object.entries(c.value.parsed)){const s=t;r(` Channel ${Number(e)}:`,{motion:s.motion,detectedObjects:s.objects})}}else r("✗ Failed to collect events info",c.error);r("\n[5/7] Collecting battery information for all channels...");const l=await Je((()=>t.getAllChannelsBatteryInfo({useChannelNumFallback:!0})));if(n.batteryInfo=l,l.ok){r(`✓ Battery info collected for ${Object.keys(l.value.batteryInfoData).length} channel(s)`);for(const[e,t]of Object.entries(l.value.batteryInfoData)){const s=t;r(` Channel ${Number(e)}:`,{batteryLevel:s.batteryLevel,sleeping:s.sleeping})}}else r("✗ Failed to collect battery info",l.error);r("\n[6/7] Building device capabilities map...");const h=new Map;if(a.ok&&l.ok){for(const e of o){const t=a.value.devicesData[e],s=l.value.batteryInfoData[e],r=t?.abilities;h.set(e,{hasBattery:void 0!==s?.batteryLevel&&s.batteryLevel>0,hasPirEvents:!!r?.pirAlarm,hasFloodlight:!!r?.ledCtrl,hasPtz:!!r?.ptz,sleeping:s?.sleeping??!1})}r(`✓ Built capabilities map for ${h.size} channel(s)`)}r("\n[7/7] Collecting status information (OSD, Floodlight, PIR, PTZ) for all channels...");const g=await Je((()=>t.getStatusInfo(h)));if(n.statusInfo=g,g.ok){r(`✓ Status info collected for ${Object.keys(g.value.deviceStatusData).length} channel(s)`);for(const[e,t]of Object.entries(g.value.deviceStatusData)){const s=t;r(` Channel ${Number(e)}:`,{osd:s.osd?"configured":"not available",floodlightEnabled:s.floodlightEnabled,pirEnabled:s.pirEnabled,ptzPresets:s.ptzPresets?.length??0})}}else r("✗ Failed to collect status info",g.error);r("\n[8/8] Collecting additional per-channel details...");const d={};for(const e of o){const s={},n=await Je((()=>t.GetOsd(e)));n.ok&&(s.osd=n.value);const i=await Je((()=>t.getLocalLink(e)));i.ok&&(s.localLink=i.value);const A=await Je((()=>t.getPirState(e)));A.ok&&(s.pirState=A.value);const o=await Je((()=>t.getSiren(e)));o.ok&&(s.siren=o.value);const a=await Je((()=>t.GetPtzPreset(e)));a.ok&&(s.ptzPresets=a.value);const c=await Je((()=>t.GetWhiteLed(e)));c.ok&&(s.whiteLed=c.value);const l=await Je((()=>t.GetEnc(e)));l.ok&&(s.encoding=l.value);const h=await Je((()=>t.GetAiState(e)));h.ok&&(s.aiState=h.value);const g=await Je((()=>t.GetMdState(e)));g.ok&&(s.motionDetection=g.value);const u=await Je((()=>t.GetBatteryInfo(e)));u.ok&&(s.battery=u.value);const E=await Je((()=>t.GetChnTypeInfo(e)));E.ok&&(s.channelType=E.value);const I=await Je((()=>t.GetWifiSignal(e)));I.ok&&(s.wifiSignal=I.value),d[e]=s,r(` Channel ${e}: collected ${Object.keys(s).length} detail(s)`)}return n.perChannelDetails=d,r(`✓ Additional details collected for ${Object.keys(d).length} channel(s)`),r("\n"+"=".repeat(80)),r("NVR/HUB DIAGNOSTICS - Summary"),r("=".repeat(80)),r(`Total Channels: ${o.length}`),r("NVR Info: "+(i.ok?"✓":"✗")),r("Devices Info: "+(a.ok?"✓":"✗")),r("Events Info: "+(c.ok?"✓":"✗")),r("Battery Info: "+(l.ok?"✓":"✗")),r("Status Info: "+(g.ok?"✓":"✗")),r(`Per-Channel Details: ✓ (${Object.keys(d).length} channels)`),r("=".repeat(80)),n}function At(e,t){const s=(e,s)=>{t?.log?void 0!==s?t.log(e,s):t.log(e):(console.log(e),void 0!==s&&console.log(JSON.stringify(s,null,2)))};s("\n"+"=".repeat(80)),s("NVR/HUB DIAGNOSTICS REPORT"),s("=".repeat(80));const r=e.nvrInfo;if(r?.ok){s("\n📡 NVR/HUB DEVICE:");const e=r.value.devInfo;e&&(s(` Model: ${e.type||"N/A"}`),s(` Name: ${e.name||"N/A"}`),s(` Firmware: ${e.firmVer||"N/A"}`),s(` Hardware: ${e.hardVer||"N/A"}`),s(` Serial: ${e.serial||"N/A"}`),s(` Item No: ${e.exactType||e.model||"N/A"}`))}const n=e.channelList||[];s(`\n📺 CHANNELS (${n.length}):`);const i=e.devicesInfo;if(i?.ok)for(const t of n){const r=i.value.devicesData?.[t];if(!r)continue;s(`\n ┌─ Channel ${t} ────────────────────────────────────────────────────`);const n=r.channelStatus;n&&(s(" │ Status:"),s(" │ Online: "+(1===n.online?"✓":"✗")),s(" │ Sleeping: "+(1===n.sleep?"Yes":"No")),s(` │ UID: ${n.uid||"N/A"}`),s(` │ Name: ${n.name||"N/A"}`));const A=r.channelInfo;A&&(s(" │ Device Info:"),s(` │ Model: ${A.typeInfo||"N/A"}`),s(` │ Firmware: ${A.firmVer||"N/A"}`),s(` │ Board Info: ${A.boardInfo||"N/A"}`));const o=r.enc;if(o){const e=o.Enc;s(" │ Encoding:"),e&&(s(` │ Main Stream: ${e.mainStream?.vType||"N/A"} ${e.mainStream?.vSize||""}`),s(` │ Sub Stream: ${e.subStream?.vType||"N/A"} ${e.subStream?.vSize||""}`))}const a=r.ai;if(a){s(" │ AI Detection:");const e=Object.keys(a).filter((e=>"channel"!==e));if(e.length>0)for(const t of e){const e=a[t];1===e?.support&&s(` │ ${t}: ${1===e.alarm_state?"Enabled":"Disabled"}`)}else s(" │ No AI detection available")}const c=r.abilities;c&&(s(" │ Capabilities:"),s(" │ Battery: "+(c.battery?"Yes":"No")),s(" │ PTZ: "+(c.ptz?"Yes":"No")),s(" │ Floodlight: "+(c.ledCtrl?"Yes":"No")),s(" │ PIR: "+(c.pirAlarm?"Yes":"No")));const l=e.eventsInfo;if(l?.ok){const e=l.value.parsed?.[t];e&&(s(" │ Events:"),s(" │ Motion: "+(e.motion?"Yes":"No")),s(` │ Detected Objects: ${e.objects?.join(", ")||"None"}`))}const h=e.batteryInfo;if(h?.ok){const e=h.value.batteryInfoData?.[t];e&&(s(" │ Battery:"),s(` │ Level: ${e.batteryLevel}%`),s(" │ Sleeping: "+(e.sleeping?"Yes":"No")))}const g=e.statusInfo;if(g?.ok){const e=g.value.deviceStatusData?.[t];e&&(s(" │ Status:"),e.osd&&s(" │ OSD: Configured"),void 0!==e.floodlightEnabled&&s(" │ Floodlight: "+(e.floodlightEnabled?"On":"Off")),void 0!==e.pirEnabled&&s(" │ PIR: "+(e.pirEnabled?"Enabled":"Disabled")),e.ptzPresets&&s(` │ PTZ Presets: ${e.ptzPresets.length}`))}const d=e.perChannelDetails;if(d?.[t]){const e=d[t];if(s(" │ Additional Details:"),e.localLink){const t=e.localLink;s(` │ Connection: ${t.activeLink||"N/A"}`),s(" │ WiFi Signal: "+(void 0!==t.wifiSignal?`${t.wifiSignal}/4`:"N/A"))}if(e.siren){s(" │ Siren: "+(e.siren.enabled?"Enabled":"Disabled"))}}s(" └────────────────────────────────────────────────────────────────────")}s("\n"+"=".repeat(80))}async function ot(e){const{api:t,channel:s,logger:r}=e,n=(e,t)=>{r?.log?void 0!==t?r.log(e,t):r.log(e):(console.log(e),void 0!==t&&console.log(JSON.stringify(t,null,2)))},i={kind:"channel_stream_test",channel:s,collectedAt:(new Date).toISOString(),streams:{}};n("=".repeat(80)),n(`STREAM TEST - Channel ${s}`),n("=".repeat(80)),n(`\n[1/3] Getting available stream options for channel ${s}...`);const A=await Je((()=>t.getEncXml(s)));if(A.ok){const e=A.value,r={mainStream:/<mainStream\b/.test(e),subStream:/<subStream\b/.test(e),extStream:/<extStream\b/.test(e),thirdStream:/<thirdStream\b/.test(e),externStream:/<externStream\b/.test(e),extraStream:/<extraStream\b/.test(e)};n(` Raw GetEnc XML stream tags present: ${JSON.stringify(r)}`);n(` GetEnc XML preview:\n${e.length>2e3?e.substring(0,2e3)+`\n... (truncated, total length: ${e.length})`:e}`);const o=await Je((()=>t.getStreamMetadata(s)));if(o.ok){const t=o.value.streams.map((e=>e.profile));n(` Parsed streams from metadata: ${t.join(", ")} (${t.length} total)`),i.rawEncXml=e,i.encXmlTagsPresent=r,i.parsedStreamProfiles=t}}const o=await Je((()=>t.buildVideoStreamOptions(s)));if(!o.ok)return n(`✗ Failed to get stream options: ${o.error}`),i.error=o.error,i;const{nativeStreams:a,rtspStreams:c,rtmpStreams:l}=o.value;n(`✓ Found ${a.length} native, ${c.length} RTSP, ${l.length} RTMP stream(s)`);const h=a.map((e=>e.profile)).join(", "),g=c.map((e=>e.profile)).join(", "),d=l.map((e=>e.profile)).join(", ");n(` Native profiles: [${h||"none"}]`),n(` RTSP profiles: [${g||"none"}]`),n(` RTMP profiles: [${d||"none"}]`);const u={};n("\n[2/3] Testing RTSP streams with ffmpeg...");for(const e of c){const t=`rtsp_${e.profile}`;n(` Testing RTSP ${e.profile}...`);const s={available:!1,profile:e.profile,container:e.container,url:e.url,urlWithAuth:e.urlWithAuth,metadata:e.metadata},r=e.urlWithAuth,i=await et({url:r,kind:"rtsp",durationSeconds:2});i.ok?(s.available=!0,s.ffmpegSuccess=!0,e.metadata?(s.codec=e.metadata.videoEncType,s.width=e.metadata.width,s.height=e.metadata.height,s.fps=e.metadata.frameRate,s.bitRate=e.metadata.bitRate,s.audio=1===e.metadata.audio,n(` ✓ Available: ${e.metadata.width}x${e.metadata.height} @ ${e.metadata.frameRate}fps, ${e.metadata.videoEncType}`)):n(" ✓ Available (ffmpeg test passed)")):(s.available=!1,s.error=i.error,n(` ✗ Not available: ${i.error}`)),u[t]=s}n("\n[3/4] Testing RTMP streams with ffmpeg...");for(const e of l){const t=`rtmp_${e.profile}`;n(` Testing RTMP ${e.profile}...`);const s={available:!1,profile:e.profile,container:e.container,url:e.url,urlWithAuth:e.urlWithAuth,metadata:e.metadata},r=e.urlWithAuth,i=await et({url:r,kind:"rtmp",durationSeconds:2});i.ok?(s.available=!0,s.ffmpegSuccess=!0,e.metadata?(s.codec=e.metadata.videoEncType,s.width=e.metadata.width,s.height=e.metadata.height,s.fps=e.metadata.frameRate,s.bitRate=e.metadata.bitRate,s.audio=1===e.metadata.audio,n(` ✓ Available: ${e.metadata.width}x${e.metadata.height} @ ${e.metadata.frameRate}fps, ${e.metadata.videoEncType}`)):n(" ✓ Available (ffmpeg test passed)")):(s.available=!1,s.error=i.error,n(` ✗ Not available: ${i.error}`)),u[t]=s}n("\n[4/4] Testing native Baichuan streams...");for(const e of a){const r=`native_${e.profile}`;n(` Testing native ${e.profile}...`);const i={available:!1,profile:e.profile,container:e.container,metadata:e.metadata};try{await t.startVideoStream(s,e.profile);const r=new Promise((e=>{let s=!1;const r=setTimeout((()=>{t.client.off("push",n),e(s)}),5e3),n=i=>{i?.header?.cmdId===ae&&(s=!0,clearTimeout(r),t.client.off("push",n),e(!0))};t.client.on("push",n)}));await r?(i.available=!0,i.frameReceived=!0,e.metadata?(i.codec=e.metadata.videoEncType,i.width=e.metadata.width,i.height=e.metadata.height,i.fps=e.metadata.frameRate,i.bitRate=e.metadata.bitRate,i.audio=1===e.metadata.audio,n(` ✓ Available: ${e.metadata.width}x${e.metadata.height} @ ${e.metadata.frameRate}fps, ${e.metadata.videoEncType}`)):n(" ✓ Available (frame received)")):(i.available=!1,i.error="Timeout waiting for video frame",n(" ✗ Not available: timeout waiting for video frame")),await t.stopVideoStream(s,e.profile)}catch(e){i.available=!1,i.error=Ge(e),n(` ✗ Not available: ${i.error}`)}u[r]=i}i.streams=u,n("\n"+"=".repeat(80)),n("STREAM TEST SUMMARY"),n("=".repeat(80));n(`Available streams: ${Object.values(u).filter((e=>!0===e.available)).length}/${Object.keys(u).length}`);for(const[e,t]of Object.entries(u)){const s=t;n(` ${e}: ${s.available?"✓":"✗"} ${s.codec||"N/A"} ${s.width||""}x${s.height||""}`)}return n("=".repeat(80)),i}async function at(e){const{api:t,logger:s}=e,r=(e,t)=>{s?.log?void 0!==t?s.log(e,t):s.log(e):(console.log(e),void 0!==t&&console.log(JSON.stringify(t,null,2)))},n={kind:"multifocal_diagnostics",collectedAt:(new Date).toISOString()};r("=".repeat(80)),r("MULTI-FOCAL DEVICE DIAGNOSTICS - Starting comprehensive analysis"),r("=".repeat(80)),r("\n[1/4] Checking device capabilities...");const i=await Je((()=>t.getDeviceCapabilities()));if(!i.ok)return r(`✗ Failed to get device capabilities: ${i.error}`),n.error=i.error,n;const A=i.value.support,o=A?.channelNum??1;r(`✓ Device channelNum: ${o}`),2!==o&&3!==o&&(r(`⚠ Warning: channelNum is ${o}, expected 2 or 3 for multi-focal device`),n.warning=`channelNum is ${o}, expected 2 or 3`),n.channelNum=o,n.deviceInfo=await Je((()=>t.getInfo())),r("\n[2/4] Getting device information...");const a=await Je((()=>t.getInfo()));a.ok&&(r(`✓ Device: ${a.value.type||"N/A"}`),n.deviceInfo=a.value),r(`\n[3/4] Testing all ${o} channel(s)...`);const c={};for(let e=0;e<o;e++){r(`\n--- Channel ${e} ---`);const n=await ot({api:t,channel:e,logger:s});c[e]=n}n.channels=c,r("\n"+"=".repeat(80)),r("MULTI-FOCAL DIAGNOSTICS SUMMARY"),r("=".repeat(80)),r(`Total Channels: ${o}`);for(let e=0;e<o;e++){const t=c[e];if(t?.streams){const s=t.streams;r(` Channel ${e}: ${Object.values(s).filter((e=>!0===e.available)).length}/${Object.keys(s).length} streams available`)}}return r("=".repeat(80)),n}},863:(e,t,s)=>{"use strict";s.d(t,{ReolinkBaichuanApi:()=>Le,ReolinkCgiApi:()=>K,autoDetectDeviceType:()=>Ye,createRfc4571TcpServer:()=>et});var r=s(5940);const n=require("crypto"),i=require("dgram");var A=s(4434);const o=require("timers"),a=require("net");var c=s(9038),l=s(5317),h=s(9896),g=s(6928),d=s(6822);const u=require("fs/promises");var E=s(5164);function I(e){return function(e){return(0,n.createHash)("md5").update(e,"utf8").digest("hex").toUpperCase()}(e).slice(0,31)}function p(e,t){const s=I(`${e}-${t}`).slice(0,16);return Buffer.from(s,"utf8")}function C(e,t){const s=255&t,n=Buffer.allocUnsafe(e.length);for(let t=0;t<e.length;t++){const i=r.g7[(s+t)%r.g7.length];n[t]=e[t]^i^s}return n}function B(e,t){return C(e,t)}function f(e,t){if(0===e.length)return Buffer.alloc(0);const s=(0,n.createCipheriv)("aes-128-cfb",t,r.KC);return s.setAutoPadding(!1),Buffer.concat([s.update(e),s.final()])}function Q(e,t){if(0===e.length)return Buffer.alloc(0);const s=(0,n.createDecipheriv)("aes-128-cfb",t,r.KC);return s.setAutoPadding(!1),Buffer.concat([s.update(e),s.final()])}function m(e){const t=(0,r.ax)(e.messageClass),s=t?24:20,n=Buffer.alloc(s),i=e.magic??r.Gz;if(4!==i.length)throw new Error("magic must be 4 bytes");return i.copy(n,0),n.writeUInt32LE(e.cmdId>>>0,4),n.writeUInt32LE(e.bodyLen>>>0,8),n.writeUInt8(255&e.channelId,12),n.writeUInt8(255&e.streamType,13),n.writeUInt16LE(65535&e.msgNum,14),n.writeUInt16LE(65535&e.responseCode,16),n.writeUInt16LE(65535&e.messageClass,18),t&&n.writeUInt32LE((e.payloadOffset??0)>>>0,20),n}function y(e){if(e.length<20)throw new Error("not enough data for Baichuan header");const t=e.subarray(0,4);if(!t.equals(r.Gz)&&!t.equals(r.gZ))throw new Error(`invalid Baichuan magic: ${t.toString("hex")}`);const s=e.readUInt32LE(4),n=e.readUInt32LE(8),i=e.readUInt8(12),A=e.readUInt8(13),o=e.readUInt16LE(14),a=e.readUInt16LE(16),c=e.readUInt16LE(18),l=(0,r.ax)(c)?24:20;if(e.length<l)throw new Error("not enough data for Baichuan header (needs 24 bytes)");const h=e.readUInt32LE(12),g={magic:Buffer.from(t),cmdId:s,bodyLen:n,channelId:i,streamType:A,msgNum:o,responseCode:a,messageClass:c};return 24===l&&(g.payloadOffset=e.readUInt32LE(20)),{header:g,headerLen:l,messageKey:h}}var w=class{buffer=Buffer.alloc(0);push(e){if(0===e.length)return[];const t=e;this.buffer=0===this.buffer.length?t:Buffer.concat([this.buffer,t]);const s=[];for(;!(this.buffer.length<4);){if(!this.buffer.subarray(0,4).equals(r.Gz)&&!this.buffer.subarray(0,4).equals(r.gZ)){const e=this.buffer.indexOf(r.Gz),t=this.buffer.indexOf(r.gZ),s=-1===e?t:-1===t?e:Math.min(e,t);if(-1===s){this.buffer=this.buffer.subarray(Math.max(0,this.buffer.length-3));break}if(this.buffer=this.buffer.subarray(s),this.buffer.length<20)break}if(this.buffer.length<20)break;let e;try{e=y(this.buffer)}catch{break}const{header:t,headerLen:n,messageKey:i}=e,A=n+t.bodyLen;if(this.buffer.length<A)break;const o=this.buffer.subarray(0,A),a=o.subarray(n);let c=0;if(24===n){const e=t.payloadOffset??0;c=e>0?Math.min(e,t.bodyLen):0}const l=a.subarray(0,c),h=a.subarray(c);s.push({header:t,body:a,extension:l,payload:h,messageKey:i,raw:o}),this.buffer=this.buffer.subarray(A)}return s}};function S(e){if(null==e||"string"!=typeof e){throw new Error(`xmlEscape: expected string but got ${typeof e}: ${e}`)}return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function D(e){return null==e?'<?xml version="1.0" encoding="UTF-8" ?><Extension version="1.1"></Extension>':`<?xml version="1.0" encoding="UTF-8" ?>\n<Extension version="1.1">\n<channelId>${e}</channelId>\n</Extension>`}function b(e){return null==e?'<?xml version="1.0" encoding="UTF-8" ?><Extension version="1.1"><binaryData>1</binaryData></Extension>':`<?xml version="1.0" encoding="UTF-8" ?>\n<Extension version="1.1">\n<binaryData>1</binaryData>\n<channelId>${e}</channelId>\n</Extension>`}function v(e,t){const s=new RegExp(`<${t}>([^<]*)</${t}>`).exec(e);return s?.[1]}function R(e,t,s,r){let n="";const i=r?.name;"setPos"===s&&void 0!==i&&(n=`<name>${S(i)}</name>`);let A="";return void 0!==r?.enable&&(A=`<enable>${r.enable}</enable>`),`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<PtzPreset version="1.1">\n<channelId>${e}</channelId>\n<presetList>\n<preset>\n<id>${t}</id>\n<command>${s}</command>\n${n}\n${A}\n</preset>\n</presetList>\n</PtzPreset>\n</body>`}function N(e,t){return`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<audioPlayInfo version="1.1">\n${void 0!==e?`<channelId>${e}</channelId>`:""}\n<playMode>2</playMode>\n<playDuration>10</playDuration>\n<playTimes>1</playTimes>\n<onOff>${t}</onOff>\n</audioPlayInfo>\n</body>`}function k(e,t){return`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<audioPlayInfo version="1.1">\n${void 0!==e?`<channelId>${e}</channelId>`:""}\n<playMode>0</playMode>\n<playDuration>10</playDuration>\n<playTimes>${t}</playTimes>\n<onOff>1</onOff>\n</audioPlayInfo>\n</body>`}function T(e,t,s=180){return`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<FloodlightManual version="1.1">\n<channelId>${e}</channelId>\n<status>${t}</status>\n<duration>${s}</duration>\n</FloodlightManual>\n</body>`}var F,M=713543482,U=713543456,L=713543440;function P(e){const t=function(){if(F)return F;const e=new Uint32Array(256);for(let t=0;t<256;t++){let s=t;for(let e=0;e<8;e++)s=1&s?3988292384^s>>>1:s>>>1;e[t]=s>>>0}return F=e,e}();let s=0;for(let r=0;r<e.length;r++){s=(t[255&(s^e[r])]^s>>>8)>>>0}return s>>>0}var x=Uint32Array.from([523058251,1517059981,941043275,2188469082,2252282411,2781280216,2205278644,401789861]);function H(e,t){const s=Buffer.allocUnsafe(t.length),r=function*(e){let t=0;for(;;){const s=x[t%x.length]+(e>>>0)>>>0;yield 255&s,yield s>>>8&255,yield s>>>16&255,yield s>>>24&255,t++}}(e>>>0);for(let e=0;e<t.length;e++)s[e]=t[e]^r.next().value;return s}function Y(e,t){return e.readInt32LE(t)}function V(e,t){const s=H(e,Buffer.from(t,"utf8")),r=P(s),n=Buffer.alloc(20);return n.writeUInt32LE(M,0),n.writeUInt32LE(s.length>>>0,4),n.writeUInt32LE(1,8),n.writeUInt32LE(e>>>0,12),n.writeUInt32LE(r>>>0,16),Buffer.concat([n,s])}function O(e){const t=Buffer.alloc(20);return t.writeUInt32LE(L,0),t.writeInt32LE(0|e.connectionId,4),t.writeUInt32LE(0,8),t.writeUInt32LE(e.packetId>>>0,12),t.writeUInt32LE(e.payload.length>>>0,16),Buffer.concat([t,e.payload])}function G(e){if(e.length<4)throw new Error("BCUDP packet too short");const t=e.readUInt32LE(0);if(t===M){if(e.length<20)throw new Error("BCUDP discovery header too short");const t=e.readUInt32LE(4),s=e.readUInt32LE(8);if(1!==s)throw new Error(`BCUDP discovery unknownA expected 1, got ${s}`);const r=e.readUInt32LE(12),n=e.readUInt32LE(16),i=e.subarray(20);if(i.length<t)throw new Error("BCUDP discovery payload truncated");const A=i.subarray(0,t);if(n>>>0!=P(A)>>>0)throw new Error("BCUDP discovery CRC mismatch");const o=function(e,t){return H(e,t)}(r,A);return{kind:"discovery",tid:r,xml:o.toString("utf8")}}if(t===U){if(e.length<28)throw new Error("BCUDP ack header too short");const t=Y(e,4),s=e.readUInt32LE(8);if(0!==s)throw new Error(`BCUDP ack unknownA expected 0, got ${s}`);const r=e.readUInt32LE(12),n=e.readUInt32LE(16),i=e.readUInt32LE(20),A=e.readUInt32LE(24),o=e.subarray(28);if(o.length<A)throw new Error("BCUDP ack payload truncated");return{kind:"ack",connectionId:t,groupId:r,packetId:n,maybeLatency:i,payload:o.subarray(0,A)}}if(t===L){if(e.length<20)throw new Error("BCUDP data header too short");const t=Y(e,4),s=e.readUInt32LE(8);if(0!==s)throw new Error(`BCUDP data unknownA expected 0, got ${s}`);const r=e.readUInt32LE(12),n=e.readUInt32LE(16),i=e.subarray(20);if(i.length<n)throw new Error("BCUDP data payload truncated");return{kind:"data",connectionId:t,packetId:r,payload:i.subarray(0,n)}}throw new Error(`Unknown BCUDP magic 0x${t.toString(16)}`)}function J(e){return`<P2P>${e}</P2P>`}function W(e){const t=e.conn??"local";return J(`<C2D_A><sid>${e.sid}</sid><conn>${S(t)}</conn><cid>${e.cid}</cid><did>${e.did}</did><mtu>${e.mtu}</mtu></C2D_A>`)}function _(e){const t=/<D2C_CFM>([\s\S]*?)<\/D2C_CFM>/.exec(e);if(!t)return;const s=t[1]??"",r=/<sid>(-?\d+)<\/sid>/.exec(s)?.[1];if(null==r)return;const n=/<conn>([^<]+)<\/conn>/.exec(s)?.[1],i=/<rsp>(-?\d+)<\/rsp>/.exec(s)?.[1],A=/<cid>(-?\d+)<\/cid>/.exec(s)?.[1],o=/<did>(-?\d+)<\/did>/.exec(s)?.[1];return{sid:Number(r),...null!=n?{conn:n}:{},...null!=i?{rsp:Number(i)}:{},...null!=A?{cid:Number(A)}:{},...null!=o?{did:Number(o)}:{}}}function $(e){const t=/<D2C_T>([\s\S]*?)<\/D2C_T>/.exec(e);if(!t)return;const s=t[1]??"",r=/<sid>(-?\d+)<\/sid>/.exec(s)?.[1],n=/<cid>(-?\d+)<\/cid>/.exec(s)?.[1],i=/<did>(-?\d+)<\/did>/.exec(s)?.[1];if(null==r||null==n||null==i)return;const A=/<conn>([^<]+)<\/conn>/.exec(s)?.[1];return{sid:Number(r),cid:Number(n),did:Number(i),...null!=A?{conn:A}:{}}}var q=class{currentValues=[];lastReceiveTime=null;displayValue=0;lastDisplayTime=null;getValue(){return this.displayValue}feed(){const e=performance.now();if(null!==this.lastReceiveTime){const t=1e3*(e-this.lastReceiveTime);this.currentValues.push(t)}if(this.lastReceiveTime=e,null!==this.lastDisplayTime){if(e-this.lastDisplayTime>1e3){this.lastDisplayTime=e;const t=this.currentValues.length;if(t>0){const e=this.currentValues.reduce(((e,t)=>e+t),0);this.displayValue=Math.floor(e/t)}else this.displayValue=0;this.currentValues=[]}}else this.lastDisplayTime=e,this.displayValue=0}},z=class extends A.EventEmitter{opts;sock;remote;mtu;clientId;cameraId;sid;sendPacketId=0;packetsWant=0;received=new Map;sent=new Map;ackTimer;resendTimer;hbTimer;discoveryTid;acceptSent=!1;lastAcceptAtMs;ackScheduled=!1;ackLatency=new q;lastAckPacket=Buffer.alloc(0);ackSentCount=0;pendingData=[];pendingDataOffset=0;drainScheduled=!1;getKeepAliveTid(){return null!=this.discoveryTid?this.discoveryTid:(0|Math.floor(255*Math.random()))>>>0}constructor(e){super(),this.opts=e,this.mtu=1350}isConnected(){return!!this.sock&&!!this.remote&&null!=this.cameraId}async connect(){if(this.sock)return;const e=i.createSocket("udp4");this.sock=e;try{e.setRecvBufferSize(4194304),e.setSendBufferSize(4194304)}catch(e){}e.on("message",((e,t)=>{try{const s=G(e);this.handlePacket(s,t.address,t.port)}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}})),e.on("error",(e=>this.emit("error",e))),e.on("close",(()=>this.emit("close"))),await new Promise((t=>e.bind(0,"0.0.0.0",(()=>t())))),"direct"===this.opts.mode?(this.remote={host:this.opts.host,port:this.opts.port},this.clientId=this.opts.clientId,this.cameraId=this.opts.cameraId):await this.discoveryUid(e),this.startTimers()}async discoveryUid(e){if("uid"!==this.opts.mode)throw new Error("Internal: discoveryUid called for non-uid mode");const t=[2015,2018],s="255.255.255.255";e.setBroadcast(!0);const r=e.address(),n="string"==typeof r?0:r.port,i=0|Math.floor(2147483647*Math.random())||82e3,A=function(e){const t=e.os??"MAC";return J(`<C2D_C><uid>${S(e.uid)}</uid><cli><port>${e.clientPort}</port></cli><cid>${e.cid}</cid><mtu>${e.mtu}</mtu><debug>false</debug><p>${S(t)}</p></C2D_C>`)}({uid:this.opts.uid,clientPort:n,cid:i,mtu:this.mtu}),a=await new Promise(((r,n)=>{const i=setTimeout((()=>{a&&clearInterval(a),e.off("message",f),n(new Error("BCUDP discovery timeout after 30000ms (camera may be sleeping or unreachable)"))}),3e4);let a,c,l,h,g,d=0,u=!1,E=!1,I=!1;const p=t=>{h&&(g||(g=setTimeout((()=>{const s=h,n=c,A=l;s&&(e.off("message",f),clearTimeout(i),a&&clearInterval(a),this.emit("debug","discovery_finalize",{reason:t,...null!=n?{sid:n}:{},...s}),r({...s,...null!=n?{sid:n}:{},...null!=A?{tid:A}:{}}))}),250)))},C=(t,s)=>{if(!u&&h&&null!=c)try{const r=(0|Math.floor(2147483647*Math.random()))>>>0,n=V(r,function(e){const t=e.conn??"local";return J("<C2D_T>"+(null!=e.sid?`<sid>${e.sid}</sid>`:"")+`<conn>${S(t)}</conn><cid>${e.cid}</cid><mtu>${e.mtu}</mtu></C2D_T>`)}({...null!=c?{sid:c}:{},cid:h.cid,mtu:this.mtu,conn:"local"}));e.send(n,s,t),u=!0,this.emit("debug","discovery_t_send",{sid:c,cid:h.cid,did:h.did,rhost:t,rport:s})}catch(e){this.emit("debug","discovery_t_send_error",e)}},B=(t,s,r,n)=>{if(!I)try{const i=V(t,W({sid:n.sid,conn:n.conn??"local",cid:n.cid,did:n.did,mtu:this.mtu}));e.send(i,r,s),I=!0,this.emit("debug","discovery_a_send",{sid:n.sid,cid:n.cid,did:n.did,rhost:s,rport:r})}catch(e){this.emit("debug","discovery_a_send_error",e)}},f=(e,t)=>{try{const s=G(e);if("discovery"!==s.kind)return;this.emit("debug","discovery_rx",{tid:s.tid,rhost:t.address,rport:t.port,xmlPreview:s.xml.slice(0,120)});const r=_(s.xml);r&&(c=r.sid,h||null==r.cid||null==r.did||(h={cid:r.cid,did:r.did,rhost:t.address,rport:t.port}),h&&(C(t.address,t.port),p("cfm")));const n=$(s.xml);if(n)return E=!0,c=n.sid,h||(h={cid:n.cid,did:n.did,rhost:t.address,rport:t.port}),this.emit("debug","discovery_t_rx",{sid:n.sid,cid:n.cid,did:n.did,rhost:t.address,rport:t.port}),B(s.tid,t.address,t.port,n),void p("t_a");const i=function(e){const t=/<D2C_C_R>([\s\S]*?)<\/D2C_C_R>/.exec(e);if(!t)return;const s=t[1]??"",r=/<rsp>(-?\d+)<\/rsp>/.exec(s)?.[1],n=/<cid>(-?\d+)<\/cid>/.exec(s)?.[1],i=/<did>(-?\d+)<\/did>/.exec(s)?.[1];if(null==r||null==n||null==i)return;const A=/<sid>(-?\d+)<\/sid>/.exec(s)?.[1],o=/<timer>([\s\S]*?)<\/timer>/.exec(s)?.[1],a=o?/<def>(-?\d+)<\/def>/.exec(o)?.[1]:void 0,c=o?/<hb>(-?\d+)<\/hb>/.exec(o)?.[1]:void 0,l=o?/<hbt>(-?\d+)<\/hbt>/.exec(o)?.[1]:void 0,h=null!=a||null!=c||null!=l?{...null!=a?{def:Number(a)}:{},...null!=c?{hb:Number(c)}:{},...null!=l?{hbt:Number(l)}:{}}:void 0;return{rsp:Number(r),cid:Number(n),did:Number(i),...null!=A?{sid:Number(A)}:{},...h?{timer:h}:{}}}(s.xml);if(!i)return;if(0!==i.rsp)return;return this.emit("debug","discovery_success",{retryCount:d,rhost:t.address,rport:t.port,sid:i.sid??c,timer:i.timer}),l=s.tid,h={cid:i.cid,did:i.did,rhost:t.address,rport:t.port},null!=i.sid&&(c=i.sid),C(t.address,t.port),void(E||I?p("cr_t"):null!=c?(g&&clearTimeout(g),g=setTimeout((()=>{p("cr_timeout")}),1500)):p("cr_no_sid"))}catch{}};e.on("message",f);const Q=()=>{const r=V((0|Math.floor(255*Math.random()))>>>0,A);for(const n of t)try{e.send(r,n,s),d++,this.emit("debug","discovery_send",{retryCount:d,host:s,port:n})}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}};Q(),a=(0,o.setInterval)((()=>{Q()}),500)}));this.clientId=a.cid,this.cameraId=a.did,this.sid=a.sid,this.discoveryTid=a.tid,this.remote={host:a.rhost,port:a.rport}}startTimers(){if(!this.sock||!this.remote||null==this.clientId||null==this.cameraId)throw new Error("BCUDP not ready");this.updateAckPacket(),this.sendHeartbeat(),this.ackTimer=(0,o.setInterval)((()=>{try{this.sendAckFast()}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}}),10),this.resendTimer=(0,o.setInterval)((()=>{try{this.resendOutstanding()}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}}),500),this.hbTimer=(0,o.setInterval)((()=>{try{this.sendHeartbeat()}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}}),1e3)}sendHeartbeat(){if(!this.sock||!this.remote||null==this.clientId||null==this.cameraId)return;const e=this.getKeepAliveTid();let t;var s;t=J(`<C2D_HB><cid>${(s={cid:this.clientId,did:this.cameraId}).cid}</cid><did>${s.did}</did></C2D_HB>`);const r=V(e,t);this.emit("debug","udp_hb_send",{tid:e,xml:t,host:this.remote.host,port:this.remote.port}),this.sock.send(r,this.remote.port,this.remote.host)}buildAckPayload(){if(0===this.packetsWant)return{packetId:4294967295,payload:Buffer.alloc(0)};let e=this.packetsWant;for(;this.received.has(e);)e++;let t=e-1;for(const e of this.received.keys())e>t&&(t=e);const s=e+200-1;if(t>s&&(t=s),t<e)return{packetId:e-1>>>0,payload:Buffer.alloc(0)};const r=t-e+1,n=Buffer.allocUnsafe(r);for(let t=0;t<r;t++)n[t]=this.received.has(e+t)?1:0;return{packetId:e-1>>>0,payload:n}}updateAckPacket(){if(null==this.cameraId)return;const{packetId:e,payload:t}=this.buildAckPayload();this.lastAckPacket=function(e){const t=e.payload??Buffer.alloc(0),s=Buffer.alloc(28);return s.writeUInt32LE(U,0),s.writeInt32LE(0|e.connectionId,4),s.writeUInt32LE(0,8),s.writeUInt32LE(e.groupId>>>0,12),s.writeUInt32LE(e.packetId>>>0,16),s.writeUInt32LE((e.maybeLatency??0)>>>0,20),s.writeUInt32LE(t.length>>>0,24),Buffer.concat([s,t])}({connectionId:this.cameraId,groupId:4294967295===e&&0===t.length?4294967295:0,packetId:e,maybeLatency:this.ackLatency.getValue(),payload:t})}sendAckFast(){this.sock&&this.remote&&0!==this.lastAckPacket.length&&(this.sock.send(this.lastAckPacket,this.remote.port,this.remote.host),this.ackSentCount++,this.ackSentCount%100==0&&this.emit("debug","ack_sent_100",{latency:this.ackLatency.getValue()}))}scheduleAck(e="data"){if("manual"===e){if(this.ackScheduled)return;this.ackScheduled=!0,setImmediate((()=>{this.ackScheduled=!1;try{this.sendAckFast()}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}})),this.emit("debug","ack_scheduled",{reason:e})}}resendOutstanding(){if(this.sock&&this.remote)for(const[,e]of this.sent)this.sock.send(e.buf,this.remote.port,this.remote.host)}handleAckFromCamera(e,t){if(4294967295!==e){for(const t of this.sent.keys())t<=e&&this.sent.delete(t);for(let s=0;s<t.length;s++){if((t[s]??0)>0){const t=e+1+s>>>0;this.sent.delete(t)}}}this.ackLatency.feed()}scheduleDrain(){this.drainScheduled||(this.drainScheduled=!0,setImmediate((()=>{this.drainScheduled=!1;try{for(;this.pendingDataOffset<this.pendingData.length;this.pendingDataOffset++)this.emit("data",this.pendingData[this.pendingDataOffset])}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}finally{this.pendingDataOffset>=this.pendingData.length&&(this.pendingData=[],this.pendingDataOffset=0)}})))}flushReceived(){for(;this.received.has(this.packetsWant);){const e=this.received.get(this.packetsWant);this.received.delete(this.packetsWant),this.packetsWant++,this.pendingData.push(e)}this.pendingData.length>this.pendingDataOffset&&this.scheduleDrain()}handlePacket(e,t,s){const r=e=>{this.remote&&this.remote.host===t&&this.remote.port===s||(this.remote={host:t,port:s},this.emit("debug","remote_update",{reason:e,host:t,port:s}))};if(this.remote||r("first_packet"),"ack"!==e.kind)if("data"!==e.kind){if("discovery"===e.kind){this.emit("debug","discovery_rx_connected",{tid:e.tid,xml:e.xml});const n=function(e){const t=/<D2C_HB>([\s\S]*?)<\/D2C_HB>/.exec(e);if(!t)return;const s=t[1]??"",r=/<cid>(-?\d+)<\/cid>/.exec(s)?.[1],n=/<did>(-?\d+)<\/did>/.exec(s)?.[1];return null!=r&&null!=n?{cid:Number(r),did:Number(n)}:void 0}(e.xml);if(n&&null!=this.clientId&&null!=this.cameraId&&n.cid===this.clientId&&n.did===this.cameraId){this.emit("debug","discovery_hb_rx_connected",{...n,rhost:t,rport:s});try{r("d2c_hb"),this.sendHeartbeat()}catch(e){this.emit("debug","discovery_hb_reply_error",e)}return}const i=$(e.xml);if(i&&null!=this.clientId&&null!=this.cameraId&&i.cid===this.clientId&&i.did===this.cameraId){try{r("d2c_t"),this.sid=i.sid,this.emit("debug","discovery_t_rx_connected",{sid:i.sid,cid:i.cid,did:i.did,rhost:t,rport:s});const n=Date.now(),A=750;if(null==this.lastAcceptAtMs||n-this.lastAcceptAtMs>=A){const r=W({sid:i.sid,conn:i.conn??"local",cid:i.cid,did:i.did,mtu:this.mtu}),A=V(e.tid,r);this.sock?.send(A,s,t),this.acceptSent=!0,this.lastAcceptAtMs=n,this.emit("debug","discovery_a_send_connected",{sid:i.sid,cid:i.cid,did:i.did,rhost:t,rport:s})}else this.emit("debug","discovery_a_skip_throttle",{sinceMs:n-this.lastAcceptAtMs,throttleMs:A,sid:i.sid,cid:i.cid,did:i.did,rhost:t,rport:s})}catch(e){this.emit("debug","discovery_a_send_connected_error",e)}return}const A=_(e.xml);if(A&&null!=this.clientId&&null!=this.cameraId&&A.cid===this.clientId&&A.did===this.cameraId)return this.sid=A.sid,void this.emit("debug","discovery_cfm_rx_connected",A);const o=function(e){const t=/<D2C_DISC>([\s\S]*?)<\/D2C_DISC>/.exec(e);if(!t)return;const s=t[1]??"",r=/<cid>(-?\d+)<\/cid>/.exec(s)?.[1],n=/<did>(-?\d+)<\/did>/.exec(s)?.[1];return null!=r&&null!=n?{cid:Number(r),did:Number(n)}:void 0}(e.xml);if(o&&null!=this.clientId&&null!=this.cameraId&&o.cid===this.clientId&&o.did===this.cameraId)return this.emit("debug","discovery_disc_rx_connected",{...o,rhost:t,rport:s}),this.emit("error",new Error("BCUDP disconnected by camera (D2C_DISC)")),void this.close()}}else null!=this.clientId&&e.connectionId===this.clientId&&(r("data"),e.packetId>=this.packetsWant&&(this.received.set(e.packetId,e.payload),this.flushReceived(),this.updateAckPacket(),this.packetsWant%100==0&&this.emit("debug","udp_progress",{packetsWant:this.packetsWant})));else null!=this.clientId&&e.connectionId===this.clientId&&(r("ack"),this.handleAckFromCamera(e.packetId,e.payload))}write(e){if(!this.sock||!this.remote||null==this.cameraId)throw new Error("BCUDP stream is not connected");const t=this.mtu-20;for(let s=0;s<e.length;s+=t){const r=e.subarray(s,Math.min(e.length,s+t)),n=this.sendPacketId>>>0;this.sendPacketId=this.sendPacketId+1>>>0;const i=O({connectionId:this.cameraId,packetId:n,payload:Buffer.from(r)});this.sent.set(n,{packetId:n,buf:i,ts:Date.now()}),this.sock.send(i,this.remote.port,this.remote.host)}}async close(){this.ackTimer&&clearInterval(this.ackTimer),this.resendTimer&&clearInterval(this.resendTimer),this.hbTimer&&clearInterval(this.hbTimer),this.ackTimer=void 0,this.resendTimer=void 0,this.hbTimer=void 0;const e=this.sock;this.sock=void 0,e&&await new Promise((t=>e.close((()=>t()))))}};function j(e){return e===r.XW||e===r.Oh||e===r.Fi||e===r.O1}var X=class e extends A.EventEmitter{static streamingRegistry=new Map;opts;debugCfg;logger;tcpSocket;udpSocket;transport="tcp";parser=new w;pending=new Map;socketClosed=!1;pendingCloseInfo;lastDisconnectInfo;msgNum=0;loggedIn=!1;subscribed=!1;keepAliveTimer;keepAlivePingInFlight=!1;idleDisconnectTimer;lastUserActivityAtMs;permitSeq=1;permits=new Map;lastRxAtMs;lastTxAtMs;lastRxInfo;lastTxInfo;rxHistory=[];txHistory=[];enc={kind:"none"};nonce;videoSubscriptions=new Map;contributesToGlobalStreamingRegistry=!1;streamTraceStats=new Map;rxCmdTraceStats=new Map;constructor(e){super(),this.opts=e,this.logger=e.logger??console,this.debugCfg=(0,r.$8)(e.debugOptions)}logFixed(e,t){const s=`[BaichuanClient] ${e}`,r=this.logger;"function"!=typeof r.info?"function"!=typeof r.log?"function"==typeof r.warn&&r.warn(s,t):r.log(s,t):r.info(s,t)}getIdleDisconnectTimeoutMs(){const e=this.opts.idleDisconnectTimeoutMs;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:3e4}isIdleDisconnectEnabled(){return!0===this.opts.idleDisconnect}clearIdleDisconnectTimer(){this.idleDisconnectTimer&&(clearTimeout(this.idleDisconnectTimer),this.idleDisconnectTimer=void 0)}touchUserActivity(e){this.lastUserActivityAtMs=Date.now(),this.logDebug("user_activity",{reason:e,atMs:this.lastUserActivityAtMs})}isIdleDisconnectEligibleNow(){return!!this.isIdleDisconnectEnabled()&&(!!this.isSocketConnected()&&(!(this.pending.size>0)&&(!this.hasActiveVideoSubscriptionsInternal()&&!(this.permits.size>0))))}kickIdleDisconnectTimer(){if(!this.isIdleDisconnectEnabled())return;if(this.clearIdleDisconnectTimer(),!this.isIdleDisconnectEligibleNow())return;if(null==this.lastUserActivityAtMs)return;const e=this.getIdleDisconnectTimeoutMs(),t=Date.now()-this.lastUserActivityAtMs,s=Math.max(0,e-t);this.idleDisconnectTimer=setTimeout((()=>{try{if(!this.isIdleDisconnectEligibleNow())return;if(null==this.lastUserActivityAtMs)return;const t=Date.now()-this.lastUserActivityAtMs;if(t<e)return void this.kickIdleDisconnectTimer();this.logDebug("idle_disconnect",{elapsedMs:t,timeoutMs:e,transport:this.transport}),this.logFixed("idle_disconnect",{elapsedMs:t,timeoutMs:e,transport:this.transport,host:this.opts.host}),this.close({reason:"idle_disconnect"})}catch(e){this.logDebug("idle_disconnect_error",e)}}),s),this.idleDisconnectTimer.unref?.()}getLastDisconnectInfo(){return this.lastDisconnectInfo}acquirePermit(e=this.getIdleDisconnectTimeoutMs(),t){const s=Math.max(0,Math.floor(e)),r=this.permitSeq++,n=Date.now()+s;let i;return s>0&&(i=setTimeout((()=>this.releasePermit(r,"timeout")),s),i.unref?.()),this.permits.set(r,{timer:i,untilMs:n,reason:t}),this.logDebug("permit_acquired",{id:r,holdMs:s,untilMs:n,reason:t,permits:this.permits.size}),this.clearIdleDisconnectTimer(),()=>this.releasePermit(r,"manual")}releasePermit(e,t){const s=this.permits.get(e);s&&(s.timer&&clearTimeout(s.timer),this.permits.delete(e),this.logDebug("permit_released",{id:e,how:t,permits:this.permits.size}),this.kickIdleDisconnectTimer())}getDeviceRegistryKey(){const e=(this.opts.uid??"").trim().toUpperCase();return`${(this.opts.host??"").trim()}|${e}|${this.opts.channel??0}`}recomputeGlobalStreamingContribution(){const t=this.hasActiveVideoSubscriptionsInternal();if(t===this.contributesToGlobalStreamingRegistry)return;const s=this.getDeviceRegistryKey(),r=e.streamingRegistry.get(s)??{activeStreamClients:0},n=Math.max(0,r.activeStreamClients+(t?1:-1));0===n?e.streamingRegistry.delete(s):e.streamingRegistry.set(s,{activeStreamClients:n}),this.contributesToGlobalStreamingRegistry=t}isDeviceStreamingActive(){if(this.hasActiveVideoSubscriptionsInternal())return!0;const t=this.getDeviceRegistryKey(),s=e.streamingRegistry.get(t);return(s?.activeStreamClients??0)>0}logDebug(e,t){this.debugCfg.general&&(this.logger.debug(`[BaichuanClient] ${e}`,t),this.emit("debug",e,t))}getTransport(){return this.transport}getConfiguredChannel(){return this.opts.channel??0}refreshKeepAlive(){this.stopKeepAlive(),this.isSocketConnected()&&this.startKeepAlive()}getLastRxAtMs(){return this.lastRxAtMs}getLastRxInfo(){return this.lastRxInfo}getRxHistory(){return this.rxHistory}getLastTxAtMs(){return this.lastTxAtMs}getLastTxInfo(){return this.lastTxInfo}getTxHistory(){return this.txHistory}recordTx(e){const t=Date.now();this.lastTxAtMs=t,this.lastTxInfo={atMs:t,...e},this.txHistory.push(this.lastTxInfo),this.txHistory.length>32&&this.txHistory.shift()}isProbablySleeping(e=15e3){return"udp"===this.transport&&(this.isIdleDisconnectEnabled()?!this.isSocketConnected():!this.isSocketConnected()||!this.isDeviceStreamingActive()&&(null!=this.lastRxAtMs&&Date.now()-this.lastRxAtMs>=e))}getDebugConfig(){return this.debugCfg}isSocketConnected(){return"tcp"===this.transport?void 0!==this.tcpSocket&&!this.tcpSocket.destroyed:"udp"===this.transport&&(void 0!==this.udpSocket&&(this.udpSocket.isConnected?.()??!0))}get username(){return this.opts.username}startKeepAlive(){if(this.keepAliveTimer)return;let e=3e4;if("udp"===this.transport){if(!this.shouldSendUdpKeepAlive())return;e=2500}e<=0||(this.keepAliveTimer=setInterval((()=>{if("udp"!==this.transport)this.keepAlivePingInFlight||(this.keepAlivePingInFlight=!0,(async()=>{try{await this.sendPing()}catch(e){this.logDebug("keepalive_ping_error",e)}finally{this.keepAlivePingInFlight=!1}})());else try{this.sendUdpKeepAlive()}catch(e){this.logDebug("udp_keepalive_ping_error",e)}}),e),this.keepAliveTimer.unref?.())}hasActiveVideoSubscriptionsInternal(){for(const e of this.videoSubscriptions.values())if(e.size>0)return!0;return!1}hasActiveVideoSubscriptions(){return this.hasActiveVideoSubscriptionsInternal()}shouldSendUdpKeepAlive(){return"udp"===this.transport&&(!!this.udpSocket&&(!!this.loggedIn&&!!this.hasActiveVideoSubscriptionsInternal()))}sendUdpKeepAlive(){if("udp"!==this.transport)return;if(!this.udpSocket)return;if(!this.loggedIn)return;const e=this.nextMsgNum(),t=m({cmdId:r.F3,bodyLen:0,channelId:0,streamType:0,msgNum:e,responseCode:0,messageClass:r.Uh,payloadOffset:0});this.logDebug("udp_keepalive_ping_tx",{msgNum:e,channelId:0,streamType:0}),this.recordTx({cmdId:r.F3,responseCode:0,msgNum:e,channelId:0,streamType:0}),this.writeWire(t)}stopKeepAlive(){this.keepAliveTimer&&(clearInterval(this.keepAliveTimer),this.keepAliveTimer=void 0),this.keepAlivePingInFlight=!1}async sendPing(){if((this.tcpSocket||this.udpSocket)&&this.loggedIn)try{await this.sendFrame({cmdId:r.uy,channel:this.opts.channel??0,channelIdOverride:0,messageClass:r.Uh,streamType:0,extensionXml:"",internal:!0})}catch(e){this.logDebug("keepalive_ping_failed",e)}}async connect(){const e=this.opts.transport??"tcp";if("tcp"!==e)if("udp"!==e)try{await Promise.race([this.connectTcp(),new Promise(((e,t)=>setTimeout((()=>t(new Error("TCP connection timeout (falling back to UDP)"))),4e3)))])}catch(e){if(this.logDebug("auto:tcp_failed",e),!this.opts.uid)throw new Error("TCP connection failed and UDP fallback requires `options.uid` (BCUDP discovery UID).");await this.connectUdp()}else await this.connectUdp();else await this.connectTcp()}async connectTcp(){if(this.tcpSocket&&!this.tcpSocket.destroyed)return void(this.transport="tcp");const e=this.opts.port??r.I4,t=a.createConnection({host:this.opts.host,port:e});this.tcpSocket=t,this.transport="tcp",this.socketClosed=!1;try{t.setKeepAlive(!0,3e4)}catch(e){this.logDebug("tcp_setKeepAlive_failed",e)}t.on("data",(e=>{const t=this.parser.push(e);for(const e of t)this.handleFrame(e)})),t.on("close",(()=>{this.stopKeepAlive(),this.socketClosed=!0;const e=this.pendingCloseInfo;this.pendingCloseInfo=void 0,this.lastDisconnectInfo={atMs:Date.now(),transport:"tcp",voluntary:null!=e,reason:e?.reason??"socket_closed"};const t=["transport=tcp",`host=${this.opts.host}`],s=this.opts.port??r.I4;null!=s&&t.push(`port=${s}`),null!=this.lastRxInfo?.cmdId&&t.push(`lastRxCmdId=${this.lastRxInfo.cmdId}`),null!=this.lastTxInfo?.cmdId&&t.push(`lastTxCmdId=${this.lastTxInfo.cmdId}`),this.logFixed("disconnected",t.join(" ")),this.emit("close");const n=Array.from(this.pending.entries());this.pending.clear();for(const[,e]of n)setImmediate((()=>{try{e.reject(new Error("Baichuan socket closed"))}catch(e){}}))})),t.on("error",(e=>this.emit("error",e))),await new Promise(((e,s)=>{t.once("connect",(()=>e())),t.once("error",(e=>s(e)))})),this.logFixed("connected",`transport=tcp host=${this.opts.host} port=${e}`),this.startKeepAlive(),this.kickIdleDisconnectTimer()}async connectUdp(){if(this.udpSocket){if(this.udpSocket.isConnected?.())return void(this.transport="udp");try{await this.udpSocket.close()}catch{}this.udpSocket=void 0}if(!this.opts.uid)throw new Error("Baichuan UDP requested but `options.uid` is not set (required for BCUDP discovery).");const e=new z({mode:"uid",uid:this.opts.uid});this.udpSocket=e,this.transport="udp",this.socketClosed=!1,e.on("data",(e=>{const t=this.parser.push(e);for(const e of t)this.handleFrame(e)})),e.on("close",(()=>{this.stopKeepAlive(),this.socketClosed=!0;const t=this.pendingCloseInfo;this.pendingCloseInfo=void 0,this.lastDisconnectInfo={atMs:Date.now(),transport:"udp",voluntary:null!=t,reason:t?.reason??"socket_closed"};const s=["transport=udp",`host=${this.opts.host}`];if(this.opts.uid){const e=this.opts.uid.substring(0,5);s.push(`uid=${e}`)}null!=this.lastRxInfo?.cmdId&&s.push(`lastRxCmdId=${this.lastRxInfo.cmdId}`),null!=this.lastTxInfo?.cmdId&&s.push(`lastTxCmdId=${this.lastTxInfo.cmdId}`),this.logFixed("disconnected",s.join(" ")),this.loggedIn=!1,this.subscribed=!1,this.contributesToGlobalStreamingRegistry&&(this.videoSubscriptions.clear(),this.recomputeGlobalStreamingContribution()),this.udpSocket===e&&(this.udpSocket=void 0),this.emit("close");const r=Array.from(this.pending.entries());this.pending.clear();for(const[,e]of r)setImmediate((()=>{try{e.reject(new Error("Baichuan UDP stream closed"))}catch(e){}}))})),e.on("error",(e=>{e?.message?.includes("D2C_DISC")&&(this.stopKeepAlive(),this.loggedIn=!1,this.subscribed=!1,this.contributesToGlobalStreamingRegistry&&(this.videoSubscriptions.clear(),this.recomputeGlobalStreamingContribution())),this.emit("error",e)})),e.on("debug",((e,t)=>{this.logDebug(`udp_${e}`,t)})),await e.connect();const t=this.opts.uid?this.opts.uid.substring(0,5):"";this.logFixed("connected",`transport=udp host=${this.opts.host} uid=${t}`),this.startKeepAlive(),this.kickIdleDisconnectTimer()}async close(e){Boolean(this.tcpSocket&&!this.tcpSocket.destroyed||this.udpSocket)&&(this.pendingCloseInfo={atMs:Date.now(),reason:(e?.reason??"manual_close").trim()||"manual_close"}),this.stopKeepAlive(),this.clearIdleDisconnectTimer();for(const e of Array.from(this.permits.keys()))this.releasePermit(e,"close");this.contributesToGlobalStreamingRegistry&&(this.videoSubscriptions.clear(),this.recomputeGlobalStreamingContribution());const t=this.tcpSocket;this.tcpSocket=void 0,t&&await new Promise((e=>{t.once("close",(()=>e())),t.destroy()}));const s=this.udpSocket;this.udpSocket=void 0,s&&await s.close()}handleFrame(e){const t=Date.now();if(this.lastRxAtMs=t,this.lastRxInfo={atMs:t,cmdId:e.header.cmdId,responseCode:e.header.responseCode,msgNum:e.header.msgNum,channelId:e.header.channelId,streamType:e.header.streamType},this.rxHistory.push(this.lastRxInfo),this.rxHistory.length>32&&this.rxHistory.shift(),this.debugCfg.general)if(3===e.header.cmdId){const s=this.rxCmdTraceStats.get(3)??{lastLogMs:t,frames:0};s.frames++,t-s.lastLogMs>=1e3&&((0,r.cY)(this.debugCfg,this.logger,"BaichuanRx",`rx cmdId=3 frames=${s.frames} lastMsgNum=${e.header.msgNum} lastResponseCode=${e.header.responseCode} lastChannelId=${e.header.channelId} lastStreamType=${e.header.streamType} lastBodyLen=${e.body.length} lastPayloadLen=${e.payload.length}`),s.lastLogMs=t,s.frames=0),this.rxCmdTraceStats.set(3,s)}else(0,r.cY)(this.debugCfg,this.logger,"BaichuanRx",`rx cmdId=${e.header.cmdId} msgNum=${e.header.msgNum} responseCode=${e.header.responseCode} channelId=${e.header.channelId} streamType=${e.header.streamType} bodyLen=${e.body.length} payloadLen=${e.payload.length} payloadOffset=${e.header.payloadOffset??0}`);if("udp"===this.transport&&e.header.cmdId===r.F3){try{const t=m({cmdId:e.header.cmdId,bodyLen:0,channelId:e.header.channelId,streamType:e.header.streamType,msgNum:e.header.msgNum,responseCode:200,messageClass:e.header.messageClass,payloadOffset:0});this.logDebug("udp_keepalive_rx",{msgNum:e.header.msgNum,channelId:e.header.channelId,streamType:e.header.streamType,responseCode:e.header.responseCode}),this.recordTx({cmdId:e.header.cmdId,responseCode:200,msgNum:e.header.msgNum,channelId:e.header.channelId,streamType:e.header.streamType}),this.writeWire(t),this.logDebug("udp_keepalive_tx",{msgNum:e.header.msgNum,channelId:e.header.channelId,streamType:e.header.streamType})}catch(e){this.logDebug("udp_keepalive_error",e)}return}this.debugCfg.traceTalk&&j(e.header.cmdId)&&(0,r.S1)(this.debugCfg,this.logger,"BaichuanTalk",`rx cmdId=${e.header.cmdId} msgNum=${e.header.msgNum} responseCode=${e.header.responseCode} channelId=${e.header.channelId} bodyLen=${e.body.length} payloadLen=${e.payload.length} payloadOffset=${e.header.payloadOffset??0}`),this.emit("frame",e);const s=`${e.header.cmdId}:${e.header.msgNum}`,n=this.pending.get(s);if(n)return this.pending.delete(s),void n.resolve(e);const i=this.videoSubscriptions.get(e.header.cmdId);if(i&&i.size>0){if(i.has(e.header.msgNum)){if(this.debugCfg.traceStream&&3===e.header.cmdId){const t=Date.now(),s=e.header.msgNum,n=this.streamTraceStats.get(s)??{lastLogMs:t,frames:0};n.frames++,t-n.lastLogMs>=500&&((0,r.aQ)(this.debugCfg,this.logger,"BaichuanTrace",`rx stream frames cmdId=3 msgNum=${e.header.msgNum} frames=${n.frames} lastChannelId=${e.header.channelId} lastBodyLen=${e.body.length} lastPayloadLen=${e.payload.length} lastPayloadOffset=${e.header.payloadOffset??0}`),n.lastLogMs=t,n.frames=0),this.streamTraceStats.set(s,n)}this.emit("push",e)}}else if(this.emit("push",e),33===e.header.cmdId)try{const t=this.parseEvents(e);for(const s of t)(0,r.Mg)(this.debugCfg,this.logger,"BaichuanEvent",`dispatch cmdId=33 msgNum=${e.header.msgNum} channelId=${e.header.channelId} type=${s.type} eventChannel=${s.channel}`+("ai"===s.type?` aiType=${s.ai?.type??"unknown"} detected=${s.ai?.detected??""}`:"")+("motion"===s.type?` source=${s.motion?.source??""}`:"")),this.emit("event",s)}catch(e){this.logDebug("event_parse_error",e)}}subscribeVideoStream(e,t){this.videoSubscriptions.has(e)||this.videoSubscriptions.set(e,new Set),this.videoSubscriptions.get(e).add(t),3!==e||this.streamTraceStats.has(t)||this.streamTraceStats.set(t,{lastLogMs:Date.now(),frames:0}),"udp"===this.transport&&this.refreshKeepAlive(),this.recomputeGlobalStreamingContribution(),this.kickIdleDisconnectTimer()}unsubscribeVideoStream(e,t){const s=this.videoSubscriptions.get(e);s&&(void 0!==t?(s.delete(t),0===s.size&&this.videoSubscriptions.delete(e),3===e&&this.streamTraceStats.delete(t)):(this.videoSubscriptions.delete(e),3===e&&this.streamTraceStats.clear()),"udp"===this.transport&&this.refreshKeepAlive(),this.recomputeGlobalStreamingContribution(),this.kickIdleDisconnectTimer())}parseEvents(e){const t=e.body;if(0===t.length)return[];const s=this.tryDecryptXml(t,e.header.channelId,this.enc);if(!s||!s.startsWith("<?xml"))return[];if(this.debugCfg.traceEvents){const t=s.length>500?`${s.slice(0,500)}...`:s;(0,r.Mg)(this.debugCfg,this.logger,"BaichuanEventRaw",`rx cmdId=${e.header.cmdId} msgNum=${e.header.msgNum} responseCode=${e.header.responseCode} channelId=${e.header.channelId} xml=${JSON.stringify(t)}`)}const n=e.header.channelId,i=250===n?0:Math.max(0,n-1),A=Date.now();if(s.includes("<AlarmEventList")){const e=[],t=s.matchAll(/<AlarmEvent\b[^>]*>([\s\S]*?)<\/AlarmEvent>/g);for(const s of t){const t=s[1]??"",n=v(t,"channelId"),o=void 0!==n?Number(n):i,a=(v(t,"status")??"").trim(),c=a.toUpperCase(),l=(v(t,"AItype")??v(t,"aiType")??v(t,"aitype")??"").trim();this.debugCfg.traceEvents&&(0,r.Mg)(this.debugCfg,this.logger,"BaichuanEventRaw",`AlarmEvent channel=${o} status=${JSON.stringify(a)} aiType=${JSON.stringify(l)}`);const h=a.toLowerCase(),g=h.length>0&&"none"!==h,d=l.trim().length>0&&"none"!==l.trim().toLowerCase();if(g||d){const t=c.includes("MD")?"md":c.includes("PIR")||c.includes("OTHER")?"pir":"unknown";e.push({channel:o,type:"motion",motion:{channel:o,state:!0,timestamp:A,source:t},timestamp:A})}const u=l?l.split(",").map((e=>e.trim())).find((e=>e.length>0&&"none"!==e.toLowerCase())):void 0;if(u){const t=u.toLowerCase(),s={people:"people",person:"people",human:"people",vehicle:"vehicle",car:"vehicle",dog_cat:"dog_cat",dog:"dog_cat",cat:"dog_cat",pet:"dog_cat",face:"face",package:"package"};e.push({channel:o,type:"ai",ai:{channel:o,type:s[t]??"other",detected:!0,timestamp:A},timestamp:A})}else c.includes("AI")&&e.push({channel:o,type:"ai",ai:{channel:o,type:"other",detected:!0,timestamp:A},timestamp:A});c.includes("VIS")&&e.push({channel:o,type:"visitor",timestamp:A}),c.includes("DN")&&e.push({channel:o,type:"daynight",timestamp:A})}return e}const o=s.match(/<Event\b[^>]*>([\s\S]*?)<\/Event>/);if(!o)return[];const a=o[1]??"",c=(v(a,"status")??"").trim(),l=c.toUpperCase(),h=(v(a,"AItype")??v(a,"aiType")??v(a,"aitype")??"").trim(),g=[],d=c.toLowerCase(),u=d.length>0&&"none"!==d,E=h.trim().length>0&&"none"!==h.trim().toLowerCase();if(u||E){const e=l.includes("MD")?"md":l.includes("PIR")||l.includes("OTHER")?"pir":"unknown";g.push({channel:i,type:"motion",motion:{channel:i,state:!0,timestamp:A,source:e},timestamp:A})}const I=h?h.split(",").map((e=>e.trim())).find((e=>e.length>0&&"none"!==e.toLowerCase())):void 0;if(I){const e=I.toLowerCase(),t={people:"people",person:"people",human:"people",vehicle:"vehicle",car:"vehicle",dog_cat:"dog_cat",dog:"dog_cat",cat:"dog_cat",pet:"dog_cat",face:"face",package:"package"};g.push({channel:i,type:"ai",ai:{channel:i,type:t[e]??"other",detected:!0,timestamp:A},timestamp:A})}else l.includes("AI")&&g.push({channel:i,type:"ai",ai:{channel:i,type:"other",detected:!0,timestamp:A},timestamp:A});return l.includes("VIS")&&g.push({channel:i,type:"visitor",timestamp:A}),l.includes("DN")&&g.push({channel:i,type:"daynight",timestamp:A}),g}nextMsgNum(){return this.msgNum=this.msgNum+1&65535,this.msgNum}peekNextMsgNum(){return this.msgNum+1&65535}requireSocket(){if("tcp"!==this.transport)throw new Error("Internal: requireSocket called while not using TCP");if(!this.tcpSocket||this.tcpSocket.destroyed)throw new Error("Baichuan TCP socket is not connected");return this.tcpSocket}writeWire(e){if(this.lastTxAtMs=Date.now(),"tcp"!==this.transport){if(!this.udpSocket)throw new Error("Baichuan UDP stream is not connected");this.udpSocket.write(e)}else this.requireSocket().write(e)}encodeBodyXml(e,t,s,r){const n=Buffer.from(e,"utf8"),i=Buffer.from(t,"utf8");return"none"===r.kind?Buffer.concat([n,i]):"bc"===r.kind?Buffer.concat([C(n,s),C(i,s)]):"aes"===r.kind||"full_aes"===r.kind?Buffer.concat([f(n,r.key),f(i,r.key)]):Buffer.concat([n,i])}encodeBodyBinary(e,t,s,r){const n=Buffer.from(e,"utf8");return"none"===r.kind?Buffer.concat([n,t]):"bc"===r.kind?Buffer.concat([C(n,s),t]):"aes"===r.kind||"full_aes"===r.kind?Buffer.concat([f(n,r.key),t]):Buffer.concat([n,t])}async sendBinaryPayloadNoReply(e){const t=!0===e.internal;t||this.touchUserActivity(`sendBinaryPayloadNoReply cmdId=${e.cmdId}`),await this.connect(),t||this.kickIdleDisconnectTimer();const s=e.channel??this.opts.channel??0,n=e.channelIdOverride??(null==e.channel?250:s+1),i=this.nextMsgNum(),A=e.cmdId,o=e.extensionXml??b(s),a=Buffer.byteLength(o,"utf8"),c=a+e.payload.length,l=e.messageClass??r.Uh,h=m({cmdId:A,bodyLen:c,channelId:n,streamType:e.streamType??0,msgNum:i,responseCode:0,messageClass:l,payloadOffset:a}),g=e.encryption??this.enc,d=this.encodeBodyBinary(o,e.payload,n,g),u=Buffer.concat([h,d]);this.logDebug("tx",{cmdId:A,msgNum:i,channelId:n,messageClass:l,bodyLen:c,binaryPayload:!0}),this.debugCfg.traceTalk&&j(A)&&(0,r.S1)(this.debugCfg,this.logger,"BaichuanTalk",`tx cmdId=${A} msgNum=${i} channelId=${n} streamType=${e.streamType??0} class=0x${l.toString(16)} bodyLen=${c} payloadOffset=${a} binaryPayloadLen=${e.payload.length}`),this.recordTx({cmdId:A,responseCode:0,msgNum:i,channelId:n,streamType:e.streamType??0}),this.writeWire(u),t||this.kickIdleDisconnectTimer()}tryDecryptXml(e,t,s){const r=e=>e.toString("utf8"),n=s=>{let n;try{n="none"===s.kind?e:"bc"===s.kind?B(e,t):Q(e,s.key)}catch{return}const i=r(n);return i.startsWith("<?xml")?i:void 0};return n(s)??("bc"!==s.kind?n({kind:"bc"}):void 0)??n({kind:"none"})??r(e)}async sendXml(e){const t=!0===e.internal;t||this.touchUserActivity(`sendXml cmdId=${e.cmdId}`),await this.connect(),t||this.kickIdleDisconnectTimer();const s=e.channel??this.opts.channel??0,n=e.channelIdOverride??(null==e.channel?250:s+1),i=this.nextMsgNum(),A=e.cmdId,o=e.extensionXml??(null!=e.channel?D(s):""),a=e.payloadXml??"",c=e.messageClass??r.Uh,l=Buffer.byteLength(o,"utf8"),h=l+Buffer.byteLength(a,"utf8"),g=m({cmdId:A,bodyLen:h,channelId:n,streamType:e.streamType??0,msgNum:i,responseCode:0,messageClass:c,payloadOffset:l}),d=`${A}:${i}`,u=e.encryption??this.enc,E=this.encodeBodyXml(o,a,n,u),I=Buffer.concat([g,E]),p=e.timeoutMs??1e4;let C;const B=new Promise(((e,t)=>{C=t;const s=setTimeout((()=>{this.pending.delete(d),t(new Error(`Baichuan timeout cmdId=${A} msgNum=${i}`))}),p);this.pending.set(d,{resolve:t=>{clearTimeout(s),e(t)},reject:e=>{clearTimeout(s),t(e)}})}));B.catch((()=>{})),this.logDebug("tx",{cmdId:A,msgNum:i,channelId:n,messageClass:c,bodyLen:h}),!this.debugCfg.traceStream||3!==A&&4!==A||(0,r.aQ)(this.debugCfg,this.logger,"BaichuanTrace",`tx cmdId=${A} msgNum=${i} channelId=${n} streamType=${e.streamType??0} class=0x${c.toString(16)} bodyLen=${h} payloadOffset=${l}`),this.debugCfg.traceTalk&&j(A)&&(0,r.S1)(this.debugCfg,this.logger,"BaichuanTalk",`tx cmdId=${A} msgNum=${i} channelId=${n} streamType=${e.streamType??0} class=0x${c.toString(16)} bodyLen=${h} payloadOffset=${l}`),this.recordTx({cmdId:A,responseCode:0,msgNum:i,channelId:n,streamType:e.streamType??0}),this.writeWire(I);const f=await B;if(this.logDebug("rx",{cmdId:f.header.cmdId,responseCode:f.header.responseCode,msgNum:f.header.msgNum}),!this.debugCfg.traceStream||3!==A&&4!==A||(0,r.aQ)(this.debugCfg,this.logger,"BaichuanTrace",`rx cmdId=${f.header.cmdId} msgNum=${f.header.msgNum} responseCode=${f.header.responseCode} channelId=${f.header.channelId} bodyLen=${f.body.length} payloadLen=${f.payload.length} payloadOffset=${f.header.payloadOffset??0}`),this.debugCfg.traceTalk&&j(A)&&(0,r.S1)(this.debugCfg,this.logger,"BaichuanTalk",`rx cmdId=${f.header.cmdId} msgNum=${f.header.msgNum} responseCode=${f.header.responseCode} channelId=${f.header.channelId} bodyLen=${f.body.length} payloadLen=${f.payload.length} payloadOffset=${f.header.payloadOffset??0}`),400===f.header.responseCode){if(0===f.body.length)throw new Error("Baichuan authentication failed (responseCode 400, empty body) - check username/password")}const Q=f.body;if(0===Q.length)return t||this.kickIdleDisconnectTimer(),"";const y=this.tryDecryptXml(Q,f.header.channelId,u);return t||this.kickIdleDisconnectTimer(),y}async sendFrame(e){const t=!0===e.internal;t||this.touchUserActivity(`sendFrame cmdId=${e.cmdId}`),await this.connect(),t||this.kickIdleDisconnectTimer();const s=e.channel??this.opts.channel??0,n=e.channelIdOverride??(null==e.channel?250:s+1),i=e.msgNumOverride??this.nextMsgNum(),A=e.cmdId,o=e.extensionXml??(null!=e.channel?D(s):""),a=e.payloadXml??"",c=e.messageClass??r.Uh,l=Buffer.byteLength(o,"utf8"),h=l+Buffer.byteLength(a,"utf8"),g=m({cmdId:A,bodyLen:h,channelId:n,streamType:e.streamType??0,msgNum:i,responseCode:0,messageClass:c,payloadOffset:l}),d=`${A}:${i}`,u=e.encryption??this.enc,E=this.encodeBodyXml(o,a,n,u),I=Buffer.concat([g,E]),p=e.timeoutMs??1e4;let C;const B=new Promise(((e,t)=>{C=t;const s=setTimeout((()=>{this.pending.delete(d),t(new Error(`Baichuan timeout cmdId=${A} msgNum=${i}`))}),p);this.pending.set(d,{resolve:t=>{clearTimeout(s),e(t)},reject:e=>{clearTimeout(s),t(e)}})}));B.catch((()=>{})),this.logDebug("tx",{cmdId:A,msgNum:i,channelId:n,messageClass:c,bodyLen:h}),!this.debugCfg.traceStream||3!==A&&4!==A||(0,r.aQ)(this.debugCfg,this.logger,"BaichuanTrace",`tx cmdId=${A} msgNum=${i} channelId=${n} streamType=${e.streamType??0} class=0x${c.toString(16)} bodyLen=${h} payloadOffset=${l}`),this.debugCfg.traceTalk&&j(A)&&(0,r.S1)(this.debugCfg,this.logger,"BaichuanTalk",`tx cmdId=${A} msgNum=${i} channelId=${n} streamType=${e.streamType??0} class=0x${c.toString(16)} bodyLen=${h} payloadOffset=${l}`),this.recordTx({cmdId:A,responseCode:0,msgNum:i,channelId:n,streamType:e.streamType??0}),this.writeWire(I);const f=await B;return this.logDebug("rx",{cmdId:f.header.cmdId,responseCode:f.header.responseCode,msgNum:f.header.msgNum}),!this.debugCfg.traceStream||3!==A&&4!==A||(0,r.aQ)(this.debugCfg,this.logger,"BaichuanTrace",`rx cmdId=${f.header.cmdId} msgNum=${f.header.msgNum} responseCode=${f.header.responseCode} channelId=${f.header.channelId} bodyLen=${f.body.length} payloadLen=${f.payload.length} payloadOffset=${f.header.payloadOffset??0}`),this.debugCfg.traceTalk&&j(A)&&(0,r.S1)(this.debugCfg,this.logger,"BaichuanTalk",`rx cmdId=${f.header.cmdId} msgNum=${f.header.msgNum} responseCode=${f.header.responseCode} channelId=${f.header.channelId} bodyLen=${f.body.length} payloadLen=${f.payload.length} payloadOffset=${f.header.payloadOffset??0}`),t||this.kickIdleDisconnectTimer(),f}async sendBinary(e){const t=!0===e.internal;if(t||this.touchUserActivity(`sendBinary cmdId=${e.cmdId}`),109===e.cmdId){const s=await this.sendBinarySnapshot109(e);return t||this.kickIdleDisconnectTimer(),s}if((e.messageClass??r.Uh)===r.d_){const s=await this.sendBinaryFileDownload6482(e);return t||this.kickIdleDisconnectTimer(),s}await this.connect(),t||this.kickIdleDisconnectTimer();const s=e.channel??this.opts.channel??0,n=e.channelIdOverride??(null==e.channel?250:s+1),i=this.nextMsgNum(),A=e.cmdId,o=e.extensionXml??(null!=e.channel?b(s):b(void 0)),a=e.payloadXml??"",c=e.messageClass??r.Uh,l=Buffer.byteLength(o,"utf8"),h=l+Buffer.byteLength(a,"utf8"),g=m({cmdId:A,bodyLen:h,channelId:n,streamType:0,msgNum:i,responseCode:0,messageClass:c,payloadOffset:l}),d=`${A}:${i}`,u=e.encryption??this.enc,E=this.encodeBodyXml(o,a,n,u),I=Buffer.concat([g,E]),p=e.timeoutMs??1e4;let C;const B=new Promise(((e,t)=>{C=t;const s=setTimeout((()=>{this.pending.delete(d),t(new Error(`Baichuan timeout cmdId=${A} msgNum=${i}`))}),p);this.pending.set(d,{resolve:t=>{clearTimeout(s),e(t)},reject:e=>{clearTimeout(s),t(e)}})}));B.catch((()=>{})),this.logDebug("tx",{cmdId:A,msgNum:i,channelId:n,messageClass:c,bodyLen:h,binary:!0}),this.recordTx({cmdId:A,responseCode:0,msgNum:i,channelId:n,streamType:0}),this.writeWire(I);const f=await B;if(this.logDebug("rx",{cmdId:f.header.cmdId,responseCode:f.header.responseCode,msgNum:f.header.msgNum,binary:!0}),400===f.header.responseCode){if(0===f.body.length)throw new Error("Baichuan binary request failed (responseCode 400, empty body)")}const Q=f.payload;if(0===Q.length)return Buffer.alloc(0);const y=this.tryDecryptBinary(Q,f.header.channelId,u);return t||this.kickIdleDisconnectTimer(),y}async sendBinaryFileDownload6482(e){await this.connect();const t=e.channel??this.opts.channel??0,s=e.channelIdOverride??(null==e.channel?250:t+1),n=this.nextMsgNum(),i=e.cmdId,A=e.extensionXml??b(t),o=e.payloadXml??"",a=e.messageClass??r.d_,c=Buffer.byteLength(A,"utf8"),l=c+Buffer.byteLength(o,"utf8"),h=m({cmdId:i,bodyLen:l,channelId:s,streamType:e.streamType??0,msgNum:n,responseCode:0,messageClass:a,payloadOffset:c}),g=e.encryption??this.enc,d=this.encodeBodyXml(A,o,s,g),u=Buffer.concat([h,d]),E=e.timeoutMs??6e4,I=[];let p=0,C=0;return await new Promise(((t,r)=>{let A,o=!1;const c=()=>{this.off("frame",d),A&&clearTimeout(A)},h=e=>{o||(o=!0,c(),r(e instanceof Error?e:new Error(String(e))))},d=e=>{var s;if(e.header.cmdId===i)if(e.header.msgNum===n&&e.header.responseCode>=400)h(new Error(`Baichuan file download request rejected (cmdId=${i} msgNum=${n} responseCode=${e.header.responseCode})`));else try{let r=!1;if(e.extension.length>0)try{this.tryDecryptXml(e.extension,e.header.channelId,g).includes("<binaryData>1</binaryData>")&&(r=!0)}catch{}const A=this.tryDecryptBinary(e.payload,e.header.channelId,g);if(0===A.length)return;if(!r&&(e=>{let t=0;for(;t<e.length&&(0===e[t]||9===e[t]||10===e[t]||13===e[t]||32===e[t]);)t++;return!(t>=e.length)&&60===e[t]})(A))return;I.push(A),p+=A.length;const a=Date.now();this.debugCfg.general&&a-C>=2e3&&(C=a,this.logDebug("file_download_progress",{cmdId:i,msgNum:n,bytes:p})),201===e.header.responseCode&&(s=Buffer.concat(I),o||(o=!0,c(),t(s)))}catch(e){h(e)}};A=setTimeout((()=>{h(new Error(`Baichuan timeout waiting file download chunks cmdId=${i} msgNum=${n}`))}),E),this.on("frame",d);try{this.logDebug("tx",{cmdId:i,msgNum:n,channelId:s,messageClass:a,bodyLen:l,binary:!0,fileDownload:!0}),this.recordTx({cmdId:i,responseCode:0,msgNum:n,channelId:s,streamType:e.streamType??0}),this.writeWire(u)}catch(e){h(e)}}))}async sendBinarySnapshot109(e){await this.connect();const t=e.channel??this.opts.channel??0,s=e.channelIdOverride??(null==e.channel?250:t+1),n=this.nextMsgNum(),i=e.cmdId,A=e.extensionXml??(null!=e.channel?D(t):""),o=e.payloadXml??"",a=e.messageClass??r.Uh,c=Buffer.byteLength(A,"utf8"),l=c+Buffer.byteLength(o,"utf8"),h=m({cmdId:i,bodyLen:l,channelId:s,streamType:e.streamType??0,msgNum:n,responseCode:0,messageClass:a,payloadOffset:c}),g=e.encryption??this.enc,d=this.encodeBodyXml(A,o,s,g),u=Buffer.concat([h,d]),E=e.timeoutMs??15e3,I=[];let p=!1;return await new Promise(((t,r)=>{let A,o=!1;const c=()=>{this.off("frame",C),A&&clearTimeout(A)},h=e=>{o||(o=!0,c(),t(e))},d=e=>{o||(o=!0,c(),r(e instanceof Error?e:new Error(String(e))))},C=e=>{if(e.header.cmdId===i)if(e.header.msgNum===n&&e.header.responseCode>=400)d(new Error(`Baichuan snapshot request rejected (cmdId=${i} msgNum=${n} responseCode=${e.header.responseCode})`));else try{let t=!1;if(e.extension.length>0){this.tryDecryptXml(e.extension,e.header.channelId,g).includes("<binaryData>1</binaryData>")&&(t=!0)}const s=this.tryDecryptBinary(e.payload,e.header.channelId,g);if(0===s.length)return;const r=s.subarray(0,Math.min(16,s.length)).toString("utf8"),n=r.startsWith("<?xml")||r.trimStart().startsWith("<");if(!t&&n)return;let i=s;if(!p){const r=(e=>{for(let t=0;t+1<e.length;t++)if(255===e[t]&&216===e[t+1])return t;return-1})(s);if(-1===r){if(!t)return;i=s,I.push(i);const r=Buffer.concat(I);return void(201===e.header.responseCode&&h(r))}p=!0,i=s.subarray(r)}I.push(i);const A=Buffer.concat(I);if((e=>{for(let t=0;t+1<e.length;t++)if(255===e[t]&&217===e[t+1])return!0;return!1})(A)||201===e.header.responseCode){const e=A.indexOf(Buffer.from([255,217]));if(-1!==e)return void h(A.subarray(0,e+2));h(A)}}catch(e){d(e)}};A=setTimeout((()=>{d(new Error(`Baichuan timeout waiting snapshot push cmdId=${i} msgNum=${n}`))}),E),this.on("frame",C);try{this.logDebug("tx",{cmdId:i,msgNum:n,channelId:s,messageClass:a,bodyLen:l,binary:!0,snapshot:!0}),this.recordTx({cmdId:i,responseCode:0,msgNum:n,channelId:s,streamType:e.streamType??0}),this.writeWire(u)}catch(e){d(e)}}))}tryDecryptBinary(e,t,s){if(0===e.length)return e;const r=s=>{try{return"none"===s.kind?e:"bc"===s.kind?B(e,t):"aes"===s.kind||"full_aes"===s.kind?Q(e,s.key):null}catch{return null}};return r(s)??("bc"===s.kind||"none"===this.enc.kind||"aes"!==this.enc.kind&&"full_aes"!==this.enc.kind?null:r(this.enc))??("bc"!==s.kind?r({kind:"bc"}):null)??r({kind:"none"})??e}async login(e="full_aes"){if(this.loggedIn)return;let t,s=e;const n=e=>new Promise((t=>setTimeout(t,e)));for(let e=1;e<=3;e++)try{const e="none"===s?56320:"bc"===s?56321:56338;await this.connect();const t=this.nextMsgNum(),n=1,A=m({cmdId:n,bodyLen:0,channelId:250,streamType:0,msgNum:t,responseCode:e,messageClass:r.VY}),o=`${n}:${t}`,a=new Promise(((e,t)=>{const s=setTimeout((()=>{this.pending.delete(o),t(new Error("Baichuan timeout waiting for nonce"))}),1e4);this.pending.set(o,{resolve:t=>{clearTimeout(s),e(t)},reject:e=>{clearTimeout(s),t(e)}})}));a.catch((()=>{})),this.writeWire(A);const c=await a,l=c.header.responseCode;if(l>>>8!=221)throw new Error(`Baichuan login: expected encryption info (0xDDxx), got 0x${l.toString(16)}`);const h=255&l,g=v(this.tryDecryptXml(c.body,c.header.channelId,0===h?{kind:"none"}:{kind:"bc"}),"nonce");if(!g)throw new Error("Baichuan login: nonce not found in XML");if(this.nonce=g,0===h)this.enc={kind:"none"};else if(1===h)this.enc={kind:"bc"};else if(2===h)this.enc={kind:"aes",key:p(g,this.opts.password)};else{if(18!==h)throw new Error(`Baichuan login: unknown encType=0x${h.toString(16)}`);this.enc={kind:"full_aes",key:p(g,this.opts.password)}}const d=I(`${this.opts.username}${g}`),u=I(`${this.opts.password}${g}`),E=(i=u,`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<LoginUser version="1.1">\n<userName>${S(d)}</userName>\n<password>${S(i)}</password>\n<userVer>1</userVer>\n</LoginUser>\n<LoginNet version="1.1">\n<type>LAN</type>\n<udpPort>0</udpPort>\n</LoginNet>\n</body>`);this.logDebug("login_hash",{username:this.opts.username,nonce:g,userHash:d,passHashLength:u.length,loginXmlLength:E.length,loginXmlPreview:E.substring(0,200)});const C=await this.sendFrame({cmdId:1,payloadXml:E,extensionXml:"",messageClass:r.Uh,encryption:{kind:"bc"},timeoutMs:1e4}),B=this.tryDecryptXml(C.body,C.header.channelId,{kind:"bc"});if(this.logDebug("login_reply",{replyLength:B.length,replyPreview:B.substring(0,200),startsWithXml:B.startsWith("<?xml")}),0===B.length)throw new Error("Baichuan login failed: empty reply (camera may be sleeping/waking, session may be stale, or username/password may be invalid)");if(!B.startsWith("<?xml")){const e=B.length>0?B.substring(0,100):"(empty)";throw new Error(`Baichuan login: unexpected non-XML reply (length: ${B.length}, preview: ${e})`)}return void(this.loggedIn=!0)}catch(r){t=r,this.loggedIn=!1;const i=String(r&&"object"==typeof r&&"message"in r?r.message:r);(i.includes("timeout waiting for nonce")||i.includes("expected encryption info")||i.includes("Baichuan socket closed")||i.includes("ECONNRESET")||i.includes("EPIPE"))&&("full_aes"===s||"aes"===s?s="bc":"bc"===s&&(s="none"));try{await this.close()}catch{}if(e<3){await n(1500);continue}throw r}var i;throw t instanceof Error?t:new Error(String(t))}},Z=class e{static sessionPool=new Map;host;username;password;port;useHttps;insecureTLS;timeoutMs;token;tokenExpiresAt;httpsAgent;constructor(e){this.host=e.host,this.username=e.username,this.password=e.password,this.port=e.port,this.useHttps=e.useHttps,this.insecureTLS=e.insecureTLS??!0,this.timeoutMs=e.timeoutMs??3e4,this.insecureTLS&&(this.httpsAgent=new c.g6({connect:{rejectUnauthorized:!1}}))}getUsername(){return this.username}getToken(){return this.token}clearToken(){this.token=void 0,this.tokenExpiresAt=void 0}sessionKey(){const e=this.useHttps?"https":"http",t=this.port??(this.useHttps?443:80);return`${e}://${this.host}:${t}|${this.username}`}getSharedSession(){const t=this.sessionKey(),s=e.sessionPool.get(t);if(s)return s;const r={};return e.sessionPool.set(t,r),r}baseUrl(){const e=this.useHttps?"https":"http",t=this.port??(this.useHttps?443:80);return`${e}://${this.host}:${t}`}apiUrl(e){const t=new URLSearchParams;for(const[s,r]of Object.entries(e))null!=r&&t.set(s,String(r));return`${this.baseUrl()}/cgi-bin/api.cgi?${t.toString()}`}isTokenValid(){return!(!this.token||!this.tokenExpiresAt)&&Date.now()+1e4<this.tokenExpiresAt}isSharedTokenValid(e){return!(!e.token||!e.tokenExpiresAt)&&Date.now()+1e4<e.tokenExpiresAt}async performLogin(){const e=[{cmd:"Login",action:0,param:{User:{userName:this.username,password:this.password}}}],t=await this.sendJson(e,{cmd:"Login"},{includeToken:!1}),s=t[0];if(!s||0!==s.code||!s.value?.Token?.name)throw new Error(`Login failed: ${JSON.stringify(t)}`);const r=Number(s.value.Token.leaseTime),n=s.value.Token.name,i=Date.now()+(Number.isFinite(r)?1e3*r:0);this.token=n,this.tokenExpiresAt=i;const A=this.getSharedSession();A.token=n,A.tokenExpiresAt=i}async login(){if(this.isTokenValid())return;const e=this.getSharedSession();return this.isSharedTokenValid(e)?(this.token=e.token,void(this.tokenExpiresAt=e.tokenExpiresAt)):e.loginInFlight?(await e.loginInFlight,void(this.isSharedTokenValid(e)&&(this.token=e.token,this.tokenExpiresAt=e.tokenExpiresAt))):(e.loginInFlight=(async()=>{try{await this.performLogin()}finally{delete e.loginInFlight}})(),void await e.loginInFlight)}async logout(){if(this.token)try{await this.call("Logout",{action:0,param:{}})}finally{this.clearToken();const e=this.getSharedSession();delete e.token,delete e.tokenExpiresAt}}async call(e,t){await this.login();const s=[{cmd:e,action:t?.action??0,...t&&"param"in t&&void 0!==t.param?{param:t.param}:{}}];return await this.sendJson(s,{cmd:e,token:this.token},{includeToken:!0})}async callMany(e){return await this.login(),await this.sendJson(e,{token:this.token},{includeToken:!0})}async sendJson(e,t,s){const r=this.apiUrl(t),n=new AbortController,i=setTimeout((()=>n.abort()),this.timeoutMs);try{const t={method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json"},signal:n.signal};this.useHttps&&this.httpsAgent&&(t.dispatcher=this.httpsAgent);const s=await fetch(r,t),i=await s.text();if(!s.ok)throw new Error(`HTTP ${s.status}: ${i}`);return JSON.parse(i)}finally{clearTimeout(i)}}async snap(e,t){if(await this.login(),!this.token)throw new Error("Missing token after login");const s=t?.rs??Date.now().toString(),r=this.apiUrl({cmd:"Snap",channel:e,rs:s,token:this.token}),n=new AbortController,i=setTimeout((()=>n.abort()),t?.timeoutMs??this.timeoutMs);try{const e={method:"GET",signal:n.signal};this.useHttps&&this.httpsAgent&&(e.dispatcher=this.httpsAgent);const t=await fetch(r,e);if(!t.ok){const e=await t.text().catch((()=>""));throw new Error(`HTTP ${t.status}: ${e}`)}const s=await t.arrayBuffer();return Buffer.from(s)}finally{clearTimeout(i)}}async downloadVod(e,t,s){if(await this.login(),!this.token)throw new Error("Missing token after login");const r=this.useHttps?"https":"http",n=this.port??(this.useHttps?443:80),i=e.replaceAll(" ","%20"),A=t?encodeURIComponent(t):void 0,o=s?encodeURIComponent(s):void 0,a=encodeURIComponent(this.token),c=`${r}://${this.host}:${n}/cgi-bin/api.cgi?cmd=Download&source=${i}${A?`&output=${A}`:""}${o?`&start=${o}`:""}&token=${a}`,l=new AbortController,h=setTimeout((()=>l.abort()),this.timeoutMs);try{const e={method:"POST",body:"[{}]",headers:{"Content-Type":"application/json"},signal:l.signal};this.useHttps&&this.httpsAgent&&(e.dispatcher=this.httpsAgent);const t=await fetch(c,e);if(!t.ok){const e=await t.text().catch((()=>""));throw new Error(`HTTP ${t.status}: ${e}`)}const s=await t.arrayBuffer();return Buffer.from(s)}finally{clearTimeout(h)}}},K=class{client;constructor(e){this.client=new Z(e)}async login(){await this.client.login()}async logout(){await this.client.logout()}async call(e,t,s=0){return void 0===t?await this.client.call(e,{action:s}):await this.client.call(e,{action:s,param:t})}async callMany(e){return await this.client.callMany(e)}async GetDevInfo(e){const t=null==e?{}:{channel:e};return await this.call("GetDevInfo",t)}async getInfo(e,t){const s=await this.GetDevInfo(e),r=s?.[0]?.value?.DevInfo,n={},i=r?.type??r?.model??r?.exactType,A=r?.exactType??r?.model??r?.detail;"string"==typeof i&&(n.type=i),"string"==typeof r?.hardVer&&(n.hardwareVersion=r.hardVer),"string"==typeof r?.firmVer&&(n.firmwareVersion=r.firmVer),"string"==typeof A&&(n.itemNo=A),"string"==typeof r?.serial&&(n.serialNumber=r.serial),"string"==typeof r?.name&&(n.name=r.name);const o=t?.tags?.length?t.tags:["type","hardwareVersion","firmwareVersion","itemNo","serialNumber","name"],a={};for(const e of o){const t=n[e];"string"==typeof t&&(a[e]=t)}return a}async GetChnTypeInfo(e){const t=null==e?{}:{channel:e};return await this.call("GetChnTypeInfo",t)}async GetChannelstatus(){return await this.call("GetChannelstatus",void 0,0)}async GetLocalLink(e){const t=null==e?{}:{channel:e};return await this.call("GetLocalLink",t)}async GetWifiSignal(e){const t=null==e?{}:{channel:e};return await this.call("GetWifiSignal",t)}async GetOsd(e){const t=null==e?{}:{channel:e};return await this.call("GetOsd",t,1)}async SetOsd(e){return await this.call("SetOsd",e,0)}async GetEnc(e){const t=null==e?{}:{channel:e};return await this.call("GetEnc",t,1)}async GetAiState(e){const t=null==e?{}:{channel:e};return await this.call("GetAiState",t,0)}async GetMdState(e){const t=null==e?{}:{channel:e};return await this.call("GetMdState",t,0)}async GetEvents(e){const t=null==e?{}:{channel:e};return await this.call("GetEvents",t,0)}async GetBatteryInfo(e){const t=null==e?{}:{channel:e};return await this.call("GetBatteryInfo",t,0)}async GetWhiteLed(e){const t=null==e?{}:{channel:e};return await this.call("GetWhiteLed",t,0)}async SetWhiteLed(e){return await this.call("SetWhiteLed",e,0)}async GetPirInfo(e){const t=null==e?{}:{channel:e};return await this.call("GetPirInfo",t,0)}async SetPirInfo(e){return await this.call("SetPirInfo",e,0)}async GetPtzPreset(e){const t=null==e?{}:{channel:e};return await this.call("GetPtzPreset",t,1)}async GetAudioAlarmV20(e){const t=null==e?{}:{channel:e};return await this.call("GetAudioAlarmV20",t,0)}async AudioAlarmPlay(e){return await this.call("AudioAlarmPlay",e,0)}async GetNetPort(){return await this.call("GetNetPort",{})}async SetNetPort(e){return await this.call("SetNetPort",{NetPort:e})}async Reboot(e){const t=null==e?{}:{channel:e};return await this.call("Reboot",t)}async GetAbility(){const e=this.client.getUsername();return await this.call("GetAbility",{User:{userName:e}})}async getChannels(e){const t=await this.GetChannelstatus(),s=t?.[0]?.value?.status;let r=(s??[]).filter((e=>!!e?.uid)).map((e=>Number(e?.channel))).filter((e=>Number.isFinite(e)));if(0===r.length&&e?.useChannelNumFallback)try{const e=await this.GetDevInfo(),t=e?.[0]?.value?.DevInfo,s=t?.channelNum;null!=s&&s>0&&(r=Array.from({length:s},((e,t)=>t)))}catch(e){}return{channels:r,channelsResponse:t}}async getNvrInfo(){const e=[{cmd:"GetAbility",action:0,param:{User:{userName:this.client.getUsername()}}},{cmd:"GetDevInfo",action:0,param:{}}],t=await this.callMany(e),s=t.find((e=>"GetAbility"===e?.cmd))?.value,r=t.find((e=>"GetDevInfo"===e?.cmd))?.value,n=r?.DevInfo;return{abilities:s,nvrData:r,devInfo:n,response:t}}async getDevicesInfo(e){const{channels:t,channelsResponse:s}=await this.getChannels(e),r=this.client.getUsername(),n=[];n.push({cmd:"GetAbility",action:0,param:{User:{userName:r}}});for(const e of t)n.push({cmd:"GetChnTypeInfo",action:0,param:{channel:e}},{cmd:"GetAiState",action:0,param:{channel:e}},{cmd:"GetEnc",action:1,param:{channel:e}});const i=await this.callMany(n),A=i[0]?.value,o=A?.Ability?.abilityChn,a={};for(let e=0;e<t.length;e++){const r=t[e],n=1+3*e,A=i[n],c=i[n+1],l=i[n+2],h=s?.[0]?.value?.status?.find((e=>e?.channel===r)),g={entries:[A,c,l]};h&&(g.channelStatus=h);const d=o?.[r];d&&(g.abilities=d),A?.error||(g.channelInfo=A?.value),c?.error||(g.ai=c?.value),l?.error||(g.enc=l?.value),a[r]=g}return{devicesData:a,response:i,channels:t,channelsResponse:s,requestBody:n}}async getAllChannelsEvents(e){const{channels:t,channelsResponse:s}=await this.getChannels(e),r=[],n={};for(const e of t)n[e]={},r.push({cmd:"GetEvents",action:0,param:{channel:e}}),n[e].events=r.length-1,r.push({cmd:"GetMdState",action:0,param:{channel:e}}),n[e].motion=r.length-1,r.push({cmd:"GetAiState",action:0,param:{channel:e}}),n[e].ai=r.length-1;const i=await this.callMany(r),A=e=>{const t=[];for(const s of Object.keys(e??{})){if("channel"===s)continue;const r=e?.[s]?.alarm_state;r&&t.push(s)}return t},o={};for(const e of t){const{events:t,motion:s,ai:r}=n[e]??{},a=null!=t?i[t]:void 0,c=null!=s?i[s]:void 0,l=null!=r?i[r]:void 0,h=new Set;for(const e of A(l?.value))h.add(e);for(const e of A(a?.value?.ai??a?.value))h.add(e);const g=Array.from(h),d=g.filter((e=>"other"!==e)),u=!!c?.value?.state||g.length>0;o[e]={motion:u,objects:d,entries:[a,c,l]}}return{parsed:o,response:i,channels:t,channelsResponse:s,requestBody:r}}async getAllChannelsBatteryInfo(e){const{channels:t,channelsResponse:s}=await this.getChannels(e),r=[{cmd:"GetChannelstatus"}],n={};for(const e of t)r.push({cmd:"GetBatteryInfo",action:0,param:{channel:e}}),n[e]=r.length-1;const i=await this.callMany(r),A=i[0],o={};for(const e of t){const t=i[n[e]]?.value?.Battery??void 0,s=A?.value?.status?.find((t=>t?.channel===e));o[e]={entries:[t,s],batteryLevel:Number(t?.batteryPercent??0),sleeping:1===s?.sleep}}return{batteryInfoData:o,response:i,channels:t,channelsResponse:s,requestBody:r}}async getStatusInfo(e){const t=[],s={};for(const[r,n]of e.entries())s[r]={},n.sleeping||(t.push({cmd:"GetOsd",action:1,param:{channel:r}}),s[r].osd=t.length-1,n.hasFloodlight&&(t.push({cmd:"GetWhiteLed",action:0,param:{channel:r}}),s[r].floodlight=t.length-1),n.hasPirEvents&&(t.push({cmd:"GetPirInfo",action:0,param:{channel:r}}),s[r].pir=t.length-1),n.hasPtz&&(t.push({cmd:"GetPtzPreset",action:1,param:{channel:r}}),s[r].presets=t.length-1));const r=await this.callMany(t),n={};for(const[t,i]of e.entries()){const{osd:e,floodlight:A,pir:o,presets:a}=s[t]??{};if(n[t]={entries:[]},null!=e){const s=r[e];n[t].osd=s,n[t].entries.push(s)}if(i.hasFloodlight&&null!=A){const e=r[A];n[t].floodlightEnabled=1===e?.value?.WhiteLed?.state,n[t].entries.push(e)}if(i.hasPirEvents&&null!=o){const e=r[o];n[t].pirEnabled=1===e?.value?.pirInfo?.enable,n[t].entries.push(e)}if(i.hasPtz&&null!=a){const e=r[a],s=e?.value?.PtzPreset;n[t].ptzPresets=Array.isArray(s)?s.filter((e=>1===e?.enable)):[],n[t].entries.push(e)}}return{deviceStatusData:n,response:r}}async getOsd(e){const t=await this.GetOsd(e);return t?.[0]}async setOsd(e,t){const s=t?.value?.Osd??t?.Osd,r={Osd:{channel:e,osdChannel:s?.osdChannel??t?.osdChannel,osdTime:s?.osdTime??t?.osdTime}};await this.call("SetOsd",r,0)}async getEncoderConfiguration(e){const t=await this.GetEnc(e);return t?.[0]?.value?.Enc}async jpegSnapshot(e,t=1e4){return await this.client.snap(e,{timeoutMs:t})}async getSiren(e){const t=await this.GetAudioAlarmV20(e);return{enabled:1===t?.[0]?.value?.Audio?.enable}}async setSiren(e,t,s){const r=s?{channel:e,alarm_mode:"times",times:s}:{channel:e,alarm_mode:"manul",manual_switch:t?1:0},n=await this.AudioAlarmPlay(r);return{value:n?.[0]?.value??n?.value,data:n}}async setWhiteLedState(e,t,s){const r={channel:e};void 0!==t&&(r.state=t?1:0),void 0!==s&&(r.bright=s),await this.SetWhiteLed({WhiteLed:r})}async getPirState(e){const t=await this.GetPirInfo(e),s=t?.[0]?.value?.pirInfo;return{enabled:1===s?.enable,state:s}}async setPirState(e,t){const s=await this.getPirState(e),r=t?1:0,n=s?.state?.enable;if(n===r)return;const i={...s?.state&&"object"==typeof s.state?s.state:{},channel:e,enable:r};await this.SetPirInfo({pirInfo:i})}async getLocalLink(e){const t=[{cmd:"GetLocalLink",action:0,param:{}},{cmd:"GetWifiSignal",action:0,param:{channel:e}}],s=await this.callMany(t),r=s.find((e=>"GetLocalLink"===e?.cmd))?.value?.LocalLink?.activeLink,n=s.find((e=>"GetWifiSignal"===e?.cmd))?.value?.wifiSignal;let i=!1;return void 0!==n&&(i=n>=0&&n<=4),!i&&r&&(i="LAN"!==r),{activeLink:r,wifiSignal:n,isWifi:i}}async collectNvrDiagnostics(e){return await(0,r.Bz)({cgi:this,logger:e.logger})}printNvrDiagnostics(e,t){(0,r.gW)(e,t)}};async function*ee(e,t,s){const n=new r.tj({client:e.client,api:e,channel:t,profile:s,logger:e.logger});let i=null,A=null,o=null,a=!1,c=!1;const l=e=>{c=!0},h=()=>{c=!0};try{await n.start(),n.on("error",l),n.on("close",h);const e=new Promise((e=>{const t=s=>{s.isKeyframe&&!i&&(i={sps:null,pps:null},n.removeListener("videoAccessUnit",t),e(i))};n.on("videoAccessUnit",t),setTimeout((()=>{i||(i={sps:null,pps:null},n.removeListener("videoAccessUnit",t),e(i))}),5e3)}));await Promise.race([e,new Promise((e=>setTimeout(e,5e3)))]);const t=[],s=200;let r=null;for(n.on("videoAccessUnit",(e=>{c||(t.push({audio:!1,data:e.data,codec:null,sampleRate:null,microseconds:e.microseconds,videoType:e.videoType}),t.length>s&&t.splice(0,t.length-s),r&&(r(),r=null))})),n.on("audioFrame",(e=>{c||(A||(A="aac",o=8e3),t.push({audio:!0,data:e,codec:A,sampleRate:o,microseconds:null}),t.length>s&&t.splice(0,t.length-s),r&&(r(),r=null))})),a=!0;!c;)if(t.length>0){const e=t.shift();yield e}else await new Promise((e=>{r=e,setTimeout((()=>{r===e&&(r=null,e())}),1e3)}))}finally{c=!0;try{await n.stop()}catch{}n.removeListener("error",l),n.removeListener("close",h)}}var te=class{key;transport;videoType;keepAliveTimer;constructor(e,t){this.transport=e,this.videoType=t,this.key=function(e,t){return`${e}-${"H264"===t?"h264":"h265"}`}(e,t)}async startKeepAlive(e){this.stopKeepAlive(),e.client.getTransport()}stopKeepAlive(){this.keepAliveTimer&&(clearInterval(this.keepAliveTimer),this.keepAliveTimer=void 0)}},se=Buffer.from([0,0,0,1]);function re(...e){const t=e.filter((e=>!!e&&e.length>0));if(0===t.length)return null;const s=[];for(const e of t)s.push(se,e);return Buffer.concat(s)}var ne=class extends te{ffmpegFormat="h264";sdpCodec="H264";sps=null;pps=null;constructor(e){super(e,"H264")}extractParameterSets(e){const t=(0,r.Kv)(e);for(const e of t){if(e.length<1)continue;const t=31&(e[0]??0);if(7!==t||this.sps||(this.sps=e),8!==t||this.pps||(this.pps=e),this.sps&&this.pps)break}}getFmtp(){let e="packetization-mode=1";if(this.sps&&this.sps.length>=4){e+=`;profile-level-id=${Buffer.from([this.sps[1],this.sps[2],this.sps[3]]).toString("hex")}`}return this.sps&&this.pps?(e+=`;sprop-parameter-sets=${this.sps.toString("base64")},${this.pps.toString("base64")}`,{fmtp:e,hasParamSets:!0}):{fmtp:e,hasParamSets:!1}}getParameterSetsAnnexB(){return re(this.sps,this.pps)}},ie=class extends te{ffmpegFormat="hevc";sdpCodec="H265";vps=null;sps=null;pps=null;constructor(e){super(e,"H265")}extractParameterSets(e){const t=(0,r.N_)(e),s=(0,r.YO)(e),n=(0,r.Rp)(e);t&&!this.vps&&(this.vps=t),s&&!this.sps&&(this.sps=s),n&&!this.pps&&(this.pps=n)}getFmtp(){let e="";return this.vps&&this.sps&&this.pps?(e=`sprop-vps=${this.vps.toString("base64")};sprop-sps=${this.sps.toString("base64")};sprop-pps=${this.pps.toString("base64")}`,{fmtp:e,hasParamSets:!0}):{fmtp:e,hasParamSets:!1}}getParameterSetsAnnexB(){return re(this.vps,this.sps,this.pps)}};function Ae(e,t){return"H264"===t?new ne(e):new ie(e)}var oe=class{maxItems;queue=[];waiting;closed=!1;constructor(e){this.maxItems=Math.max(1,0|e)}push(e){if(!this.closed){if(this.waiting){const{resolve:t}=this.waiting;return this.waiting=void 0,void t({value:e,done:!1})}this.queue.push(e),this.queue.length>this.maxItems&&this.queue.splice(0,this.queue.length-this.maxItems)}}close(){if(!this.closed&&(this.closed=!0,this.waiting)){const{resolve:e}=this.waiting;this.waiting=void 0,e({value:void 0,done:!0})}}async next(){if(this.closed)return{value:void 0,done:!0};const e=this.queue.shift();return void 0!==e?{value:e,done:!1}:await new Promise((e=>{this.waiting={resolve:e}}))}},ae=class{opts;queues=new Map;source=null;running=!1;pumpPromise=null;constructor(e){this.opts=e}start(){this.running||(this.running=!0,this.source=this.opts.createSource(),this.pumpPromise=(async()=>{try{for await(const e of this.source){try{this.opts.onFrame?.(e)}catch{}for(const t of this.queues.values())t.push(e)}}catch(e){this.opts.onError?.(e)}finally{for(const e of this.queues.values())e.close();this.queues.clear()}})())}subscribe(e){const t=new oe(this.opts.maxQueueItems);this.queues.set(e,t);const s=this;return async function*(){try{for(;;){const e=await t.next();if(e.done)return;yield e.value}}finally{t.close(),s.queues.delete(e)}}()}async stop(){if(!this.running)return;this.running=!1;const e=this.source;this.source=null;for(const e of this.queues.values())e.close();this.queues.clear();try{await(e?.return(void 0))}catch{}try{await this.pumpPromise}catch{}this.pumpPromise=null}};var ce=class e extends A.EventEmitter{api;channel;profile;listenHost;listenPort;path;logger;tcpRtpFraming;active=!1;flow;connectedClients=new Set;nativeStreamActive=!1;clientConnectionServer;streamMetadata=null;clientResources=new Map;isRtspDebugEnabled(){return this.api.client.getDebugConfig().debugRtsp||function(e,t){if(null==e)return t;const s=e.trim().toLowerCase();return"1"===s||"true"===s||"yes"===s||"on"===s||"0"!==s&&"false"!==s&&"no"!==s&&"off"!==s&&t}(process.env.BAICHUAN_DEBUG_RTSP,!1)}rtspDebugLog(e){this.isRtspDebugEnabled()&&this.logger.debug(`[BaichuanRtspServer] ${e}`)}firstFramePromise=null;firstFrameResolve=null;firstFrameReceived=!1;firstAudioPromise=null;firstAudioResolve=null;firstAudioDetected=!1;hasAudio=!1;audioInfo=null;audioPrimingFrame=null;tempStreamGenerator=null;nativeFanout=null;noClientAutoStopTimer;static isAdtsAacFrame(e){return e.length>=2&&255===e[0]&&!(240&~e[1])}static parseAdtsSamplingInfo(t){if(t.length<7)return null;if(!e.isAdtsAacFrame(t))return null;const s=t[2]>>2&15,r=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][s]??null;if(!r)return null;const n=(1&t[2])<<2|t[3]>>6&3,i=0===n?1:n,A=(t[2]>>6&3)+1<<11|s<<7|n<<3;return{sampleRate:r,channels:i,configHex:Buffer.from([A>>8&255,255&A]).toString("hex")}}static parseInterleavedChannels(e){const t=e.match(/interleaved\s*=\s*(\d+)\s*-\s*(\d+)/i);if(!t)return null;const s=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10);return Number.isFinite(s)&&Number.isFinite(r)?{rtp:s,rtcp:r}:null}static splitAnnexBNals(e){const t=[],s=e.length,r=t=>{if(t+3<=s&&0===e[t]&&0===e[t+1]){if(1===e[t+2])return 3;if(t+4<=s&&0===e[t+2]&&1===e[t+3])return 4}return 0};let n=0;for(;n<s;){if(r(n))break;n++}for(;n<s;){const i=r(n);if(!i){n++;continue}const A=n+i;let o=A;for(;o<s;){if(r(o))break;o++}if(A<o){const s=e.subarray(A,o);s.length>0&&t.push(s)}n=o}return t}static stripAdtsHeader(t){if(!e.isAdtsAacFrame(t))return null;if(t.length<7)return null;const s=!(1&~t[1])?7:9;return t.length<=s?null:t.subarray(s)}constructor(e){super(),this.api=e.api,this.channel=e.channel,this.profile=e.profile,this.listenHost=e.listenHost??"127.0.0.1",this.listenPort=e.listenPort??8554,this.path=e.path??`/stream/${this.profile}`,this.logger=e.logger??console,this.tcpRtpFraming=e.tcpRtpFraming??"rfc4571";const t=this.api.client.getTransport();this.flow=Ae(t,"H264")}clearNoClientAutoStopTimer(){this.noClientAutoStopTimer&&(clearTimeout(this.noClientAutoStopTimer),this.noClientAutoStopTimer=void 0)}setFlowVideoType(e,t){if(this.flow.videoType===e)return;const s=this.api.client.getTransport();this.flow.stopKeepAlive(),this.flow=Ae(s,e),this.rtspDebugLog(`Using RTSP flow ${this.flow.key} (${t})`)}async start(){if(this.active)throw new Error("RTSP server is already active");try{const e=(await this.api.getStreamMetadata(this.channel)).streams.find((e=>e.profile===this.profile));if(e){this.streamMetadata={frameRate:e.frameRate||25,width:e.width,height:e.height};const t=String(e.videoEncType??"").trim().toLowerCase(),s=t.includes("265")||t.includes("hevc")?"H265":"H264";this.setFlowVideoType(s,"metadata")}}catch(e){this.logger.warn(`[BaichuanRtspServer] Could not get stream metadata: ${e}`),this.streamMetadata={frameRate:25,width:1920,height:1080},this.setFlowVideoType("H264","metadata unavailable")}this.clientConnectionServer=a.createServer((e=>{this.handleRtspConnection(e)})),await new Promise(((e,t)=>{this.clientConnectionServer.listen(this.listenPort,this.listenHost,(()=>{const t=this.clientConnectionServer.address();t&&"object"==typeof t&&"port"in t&&(this.listenPort=t.port),e()})),this.clientConnectionServer.on("error",(e=>{t(e)}))})),this.active=!0,this.logger.info(`[BaichuanRtspServer] RTSP server started on ${this.listenHost}:${this.listenPort}, path: ${this.path}`)}handleRtspConnection(t){const s=`${t.remoteAddress}:${t.remotePort}`;this.logger.info(`[BaichuanRtspServer] RTSP client connected: ${s}`);let r,n="",i=Buffer.alloc(0),A=!1,o=null,a=null;const c=()=>{this.removeClient(s);const e=this.clientResources.get(s);if(e){if(e.ffmpeg)try{e.ffmpeg.stdin?.end(),e.ffmpeg.kill("SIGTERM"),setTimeout((()=>{try{e.ffmpeg?.kill("SIGKILL")}catch{}}),1e3)}catch{}if(e.udpSocket)try{e.udpSocket.close()}catch{}if(e.udpSocketAudio)try{e.udpSocketAudio.close()}catch{}if(e.rtspSocket&&!e.rtspSocket.destroyed)try{e.rtspSocket.destroy()}catch{}this.clientResources.delete(s)}if(r){try{r.stdin?.end(),r.kill("SIGTERM"),setTimeout((()=>{try{r?.kill("SIGKILL")}catch{}}),1e3)}catch{}r=void 0}if(o){try{o.close()}catch{}o=null}if(a){try{a.close()}catch{}a=null}};t.on("close",c),t.on("error",(e=>{e&&"object"==typeof e&&"code"in e&&"EPIPE"!==e.code&&this.logger.error("[BaichuanRtspServer] RTSP client error:",e),c()})),t.on("data",(async l=>{for(i=Buffer.concat([i,l]);i.includes("\r\n\r\n");){const l=i.indexOf("\r\n\r\n"),h=i.subarray(0,l).toString();if(i=i.subarray(l+4),!h.trim())continue;const g=h.split("\r\n"),d=g[0]?.split(" ");if(!d||d.length<3)continue;const u=d[0],E=d[1],I=d[2],p=h.match(/CSeq:\s*(\d+)/i),C=p?parseInt(p[1]??"0",10):0,B=(e,s,r={},n)=>{let i=`${I} ${e} ${s}\r\n`;i+=`CSeq: ${C}\r\n`;for(const[e,t]of Object.entries(r))i+=`${e}: ${t}\r\n`;n&&(i+=`Content-Length: ${Buffer.byteLength(n,"utf8")}\r\n`),i+="\r\n",n&&(i+=n),t.write(i)};if(this.rtspDebugLog(`RTSP ${u} ${E}`),"OPTIONS"===u)B(200,"OK",{Public:"DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, OPTIONS"});else if("DESCRIBE"===u){if(!this.firstFrameReceived&&0===this.connectedClients.size){try{this.nativeStreamActive||await this.startNativeStream()}catch(e){this.logger.warn(`[BaichuanRtspServer] Failed to start native stream for SDP priming: ${e}`)}const{hasParamSets:e}=this.flow.getFmtp();if(!e){const e="udp"===this.api.client.getTransport()?4e3:1500;try{await Promise.race([this.firstFramePromise||Promise.resolve(),new Promise((t=>setTimeout(t,e)))])}catch{}}}{const{fmtp:e,hasParamSets:t}=this.flow.getFmtp(),r=e.length>160?`${e.slice(0,160)}...`:e;this.logger.info(`[BaichuanRtspServer] DESCRIBE SDP for ${s} path=${this.path} codec=${this.flow.sdpCodec} hasParamSets=${t} fmtp=${r}`),t||this.rtspDebugLog(`DESCRIBE responding without parameter sets yet (client=${s}, path=${this.path}, flow=${this.flow.key})`)}const e=this.generateSdp();B(200,"OK",{"Content-Type":"application/sdp","Content-Base":`rtsp://${this.listenHost}:${this.listenPort}${this.path}/`},e)}else if("SETUP"===u){const i=E?.includes("track0"),c=E?.includes("track1");if(!i&&!c){B(404,"Not Found",{Session:n||`session_${Date.now()}_${Math.random().toString(36).substring(7)}`});continue}if(c&&!this.hasAudio){B(404,"Not Found",{Session:n||`session_${Date.now()}_${Math.random().toString(36).substring(7)}`});continue}this.connectedClients.add(s),this.emit("client",s),this.clearNoClientAutoStopTimer(),1!==this.connectedClients.size||this.nativeStreamActive||await this.startNativeStream();const l=h.match(/Transport:\s*([^\r\n]+)/i),g=(l?.[1]??"").trim();A=!g||(g.includes("TCP")||g.includes("tcp")),n||(n=`session_${Date.now()}_${Math.random().toString(36).substring(7)}`);const d=this.clientResources.get(s);if(d?d.rtspSocket=t:this.clientResources.set(s,{ffmpeg:void 0,udpSocket:null,udpSocketAudio:null,rtspSocket:t,pipelineStarted:!1,seenFirstVideoKeyframe:!1,setupTrack0:!1,setupTrack1:!1,isPlaying:!1}),A){const t=this.clientResources.get(s),r=e.parseInterleavedChannels(g);if(t)if(c){const e=r??{rtp:2,rtcp:3};t.track1RtpChannel=e.rtp,t.track1RtcpChannel=e.rtcp}else{const e=r??{rtp:0,rtcp:1};t.track0RtpChannel=e.rtp,t.track0RtcpChannel=e.rtcp}}{const e=this.clientResources.get(s);e&&!e.pipelineStarted&&(e.pipelineStarted=!0,await this.startClientFfmpeg(s,t,A,((e,t,n)=>{r=e,o=t,a=n;const i=this.clientResources.get(s);i&&(i.ffmpeg=e,i.udpSocket=t,i.udpSocketAudio=n)})))}{const e=this.clientResources.get(s);e&&(c?e.setupTrack1=!0:e.setupTrack0=!0,this.rtspDebugLog(`SETUP done for ${s}: track0=${!!e.setupTrack0} track1=${!!e.setupTrack1} playing=${!!e.isPlaying}`))}if(A){const e=this.clientResources.get(s),t=c?{rtp:2,rtcp:3}:{rtp:0,rtcp:1};B(200,"OK",{Transport:`RTP/AVP/TCP;unicast;interleaved=${`${c?e?.track1RtpChannel??t.rtp:e?.track0RtpChannel??t.rtp}-${c?e?.track1RtcpChannel??t.rtcp:e?.track0RtcpChannel??t.rtcp}`}`,Session:n})}else B(200,"OK",{Transport:"RTP/AVP/UDP;unicast;client_port=5004-5005;server_port=5004-5005",Session:n})}else if("PLAY"===u){{const e=this.clientResources.get(s);e&&(e.isPlaying=!0,this.rtspDebugLog(`PLAY for ${s}: track0=${!!e.setupTrack0} track1=${!!e.setupTrack1} playing=${!!e.isPlaying}`))}B(200,"OK",{Session:n,Range:"npt=0.000-"})}else"TEARDOWN"===u?(c(),B(200,"OK",{Session:n}),t.end()):B(501,"Not Implemented")}}))}generateSdp(){const e=this.flow.sdpCodec;let t="v=0\r\n";t+=`o=- ${Date.now()} ${Date.now()} IN IP4 ${this.listenHost}\r\n`,t+="s=Baichuan Stream\r\n",t+=`c=IN IP4 ${this.listenHost}\r\n`,t+="t=0 0\r\n",t+="m=video 0 RTP/AVP 96\r\n",t+=`a=rtpmap:96 ${e}/90000\r\n`,this.streamMetadata?.frameRate&&(t+=`a=framerate:${this.streamMetadata.frameRate}\r\n`),this.streamMetadata?.width&&this.streamMetadata?.height&&(t+=`a=framesize:96 ${this.streamMetadata.width}-${this.streamMetadata.height}\r\n`),t+="a=control:track0\r\n";const{fmtp:s,hasParamSets:r}=this.flow.getFmtp();if(r||this.logger.warn(`[BaichuanRtspServer] SDP missing parameter sets for flow ${this.flow.key}`),s&&(t+=`a=fmtp:96 ${s}\r\n`),this.hasAudio){t+="m=audio 0 RTP/AVP 97\r\n";const e=this.audioInfo,s=e?.sampleRate??8e3,r=e?.channels??1,n=e?.configHex??"";t+=`a=rtpmap:97 mpeg4-generic/${s}/${r}\r\n`,n&&(t+=`a=fmtp:97 streamtype=5; profile-level-id=15; mode=AAC-hbr; config=${n}; SizeLength=13; IndexLength=3; IndexDeltaLength=3;\r\n`),t+="a=control:track1\r\n"}return t+="a=setup:passive\r\n",t+="a=connection:new\r\n",t}async startClientFfmpeg(t,s,n,A){let o=this.streamMetadata;if(!o||!o.frameRate)try{const e=(await this.api.getStreamMetadata(this.channel)).streams.find((e=>e.profile===this.profile));e&&(o={frameRate:e.frameRate||25,width:e.width,height:e.height},this.rtspDebugLog(`Fetched metadata for profile ${this.profile}: ${o.frameRate} fps`))}catch(e){this.logger.warn(`[BaichuanRtspServer] Could not fetch stream metadata: ${e}`),o={frameRate:25,width:1920,height:1080}}const a=this.flow.ffmpegFormat;let c=0,h=0,g=null,d=null;const u=n,E=(e,t)=>{if("rfc4571"===(n?"rtsp-interleaved":this.tcpRtpFraming)){const e=Buffer.alloc(2);return e.writeUInt16BE(65535&t.length,0),Buffer.concat([e,t])}const s=Buffer.alloc(4);return s[0]=36,s[1]=255&e,s[2]=t.length>>8&255,s[3]=255&t.length,Buffer.concat([s,t])};if(n&&!u){c=5e4+Math.floor(1e4*Math.random()),g=i.createSocket("udp4"),await new Promise(((e,t)=>{g.once("listening",(()=>e())),g.once("error",t),g.bind(c,"127.0.0.1")}));const e=(e,r)=>{if(!s||s.destroyed||!s.writable)return!1;if(r.length<12)return!1;if(2!==(r[0]>>6&3))return!1;const n=this.clientResources.get(t);if(!n?.isPlaying)return!1;const i=n?.track0RtpChannel??0,A=n?.track1RtpChannel??2;if(e===i&&!n?.setupTrack0)return!1;if(e===A&&!n?.setupTrack1)return!1;try{return s.write(E(e,r))}catch(e){if(e&&"object"==typeof e&&"code"in e&&"EPIPE"===e.code)return!1}return!1};if(g){const s=this.clientResources.get(t),r=s?.track0RtpChannel??0;let n=0,i=!1,A=!1;g.on("message",(s=>{i||(i=!0,this.rtspDebugLog(`First video RTP packet received from ffmpeg for client ${t} (len=${s.length})`));e(r,s)&&!A&&(A=!0,this.rtspDebugLog(`First video RTP packet forwarded via TCP interleaved for client ${t}`)),n++,n%1e3==0&&this.rtspDebugLog(`Forwarded ${n} RTP packets to client ${t} via TCP interleaved`)}))}if(this.hasAudio){h=c+2+2*Math.floor(1e3*Math.random()),d=i.createSocket("udp4"),await new Promise(((e,t)=>{d.once("listening",(()=>e())),d.once("error",t),d.bind(h,"127.0.0.1")}));let s=0,r=!1,n=!1;d.on("message",(i=>{const A=this.clientResources.get(t),o=A?.track1RtpChannel??2;s++,r||(r=!0,this.rtspDebugLog(`First audio RTP packet received from ffmpeg for client ${t} (len=${i.length})`));e(o,i)&&!n&&(n=!0,this.rtspDebugLog(`First audio RTP packet forwarded via TCP interleaved for client ${t}`)),s%1e3==0&&this.rtspDebugLog(`Forwarded ${s} audio RTP packets to client ${t} via TCP interleaved`)}))}}const I=this.clientResources.get(t),p=this.isRtspDebugEnabled(),C=e=>this.rtspDebugLog(e),B=(e,t)=>{if(!s||s.destroyed||!s.writable)return!1;try{return s.write(E(e,t))}catch(e){if(e&&"object"==typeof e&&"code"in e&&"EPIPE"===e.code)return!1}return!1},f=(e,t,s,r,n)=>{const i=Buffer.alloc(12);return i[0]=128,i[1]=(t?128:0)|127&e,i.writeUInt16BE(65535&s,2),i.writeUInt32BE(r>>>0,4),i.writeUInt32BE(n>>>0,8),i},Q=(e,t,s)=>{const r=e?97:96;if(I?.isPlaying&&(!e||I?.setupTrack1)&&(e||I?.setupTrack0))if(e){void 0===I.rtpAudioSeq&&(I.rtpAudioSeq=Math.floor(65536*Math.random())),void 0===I.rtpAudioTimestamp&&(I.rtpAudioTimestamp=0),void 0===I.rtpAudioSsrc&&(I.rtpAudioSsrc=4294967295*Math.random()>>>0);const e=f(r,s,I.rtpAudioSeq,I.rtpAudioTimestamp,I.rtpAudioSsrc);I.rtpAudioSeq=I.rtpAudioSeq+1&65535,B(I?.track1RtpChannel??2,Buffer.concat([e,t]))}else{void 0===I.rtpVideoSeq&&(I.rtpVideoSeq=Math.floor(65536*Math.random())),void 0===I.rtpVideoTimestamp&&(I.rtpVideoTimestamp=0),void 0===I.rtpVideoSsrc&&(I.rtpVideoSsrc=4294967295*Math.random()>>>0);const e=f(r,s,I.rtpVideoSeq,I.rtpVideoTimestamp,I.rtpVideoSsrc);I.rtpVideoSeq=I.rtpVideoSeq+1&65535,B(I?.track0RtpChannel??0,Buffer.concat([e,t]))}},m=1200,y=t=>{const s=e.splitAnnexBNals(t);for(const e of s){if(e.length<1)continue;if(5===(31&(e[0]??0)))return!0}return!1},w=(e,t)=>{if(e.length<=m)return void Q(!1,e,t);const s=e[0],r=31&s,n=224&s|28,i=e.subarray(1);let A=0;for(;A<i.length;){const e=i.length-A,s=Math.min(e,1198),o=0===A,a=A+s>=i.length,c=(o?128:0)|(a?64:0)|r,l=i.subarray(A,A+s),h=Buffer.concat([Buffer.from([n,c]),l]);Q(!1,h,t&&a),A+=s}},S=(e,t)=>{if(e.length<=m)return void Q(!1,e,t);if(e.length<3)return;const s=e[0],r=s>>1&63,n=129&s|98,i=e[1],A=e.subarray(2);let o=0;for(;o<A.length;){const e=A.length-o,s=Math.min(e,1197),a=0===o,c=o+s>=A.length,l=(a?128:0)|(c?64:0)|63&r,h=A.subarray(o,o+s),g=Buffer.concat([Buffer.from([n,i,l]),h]);Q(!1,g,t&&c),o+=s}},D=o?.frameRate&&o.frameRate>0?o.frameRate:25,b=Math.max(1,Math.round(9e4/D)),v=e=>{if(!I)return;if(null==e)return;if(!Number.isFinite(e))return;if(void 0===I.rtpVideoTimestamp&&(I.rtpVideoTimestamp=0),void 0===I.rtpVideoBaseTimestamp&&(I.rtpVideoBaseTimestamp=I.rtpVideoTimestamp),void 0===I.rtpVideoBaseMicroseconds)return I.rtpVideoBaseMicroseconds=e>>>0,void(I.rtpVideoLastTimestamp=I.rtpVideoTimestamp);const t=(e>>>0)-(I.rtpVideoBaseMicroseconds>>>0)>>>0;let s=((I.rtpVideoBaseTimestamp??0)>>>0)+Math.round(9e4*t/1e6)>>>0;const r=I.rtpVideoLastTimestamp;void 0!==r&&s<=r>>>0&&(s=1+(r>>>0)>>>0),I.rtpVideoTimestamp=s,I.rtpVideoLastTimestamp=s},R=(t,s,r=!0)=>{const n=e.splitAnnexBNals(s);if(0!==n.length){for(let e=0;e<n.length;e++){const s=n[e],r=e===n.length-1;"H265"===t?S(s,r):w(s,r)}r&&void 0!==I?.rtpVideoTimestamp&&void 0===I?.rtpVideoBaseMicroseconds&&(I.rtpVideoTimestamp=I.rtpVideoTimestamp+b>>>0)}},N=t=>{const s=e.stripAdtsHeader(t);if(!s)return;const r=Buffer.from([0,16]),n=8191&s.length,i=Buffer.alloc(2);i[0]=n>>5&255,i[1]=(31&n)<<3;const A=Buffer.concat([r,i,s]);Q(!0,A,!0),void 0!==I?.rtpAudioTimestamp&&(I.rtpAudioTimestamp=I.rtpAudioTimestamp+1024>>>0)},k=e=>{const t=(0,r.S8)(e);for(const e of t){if(e.length<2)continue;const t=e[0];if(void 0===t)continue;if(128&t)continue;const s=t>>1&63;if((0,r.uQ)(s))return!0}return!1};let T,F;if(u&&A(void 0,null,null),!u){const e=["-hide_banner","-loglevel","error","-fflags","+genpts+igndts"],s=o?.frameRate||25;if(s>0&&(e.push("-r",s.toString()),this.rtspDebugLog(`Using frame rate ${s} fps for client ${t}`)),e.push("-f",a,"-i","pipe:0"),this.hasAudio&&e.push("-f","aac","-i","pipe:3"),n){if(e.push("-map","0:v:0","-c:v","copy","-vsync","cfr","-avoid_negative_ts","make_zero","-f","rtp","-payload_type","96",`rtp://127.0.0.1:${c}?pkt_size=1300`),this.hasAudio&&d&&h){const t=this.audioInfo,s=t?.sampleRate??8e3,r=t?.channels??1;e.push("-map","1:a:0","-c:a","aac","-profile:a","aac_low","-ar",String(s),"-ac",String(r),"-flags:a","+global_header","-f","rtp","-payload_type","97",`rtp://127.0.0.1:${h}?pkt_size=1300`)}}else e.push("-map","0:v:0","-c:v","copy","-vsync","cfr","-avoid_negative_ts","make_zero","-f","rtp","-payload_type","96","rtp://127.0.0.1:5004?pkt_size=1300");const r=["pipe","ignore","pipe"];this.hasAudio&&r.push("pipe"),this.rtspDebugLog(`Spawning ffmpeg for client ${t}: ffmpeg ${e.join(" ")}`),T=(0,l.spawn)("ffmpeg",e,{stdio:r});try{const e=this.flow.getParameterSetsAnnexB();e&&e.length>0&&T?.stdin&&(T.stdin.write(e),this.rtspDebugLog(`Wrote video parameter sets to ffmpeg stdin for client ${t} (len=${e.length})`))}catch(e){this.logger.warn(`[BaichuanRtspServer] Failed to write video parameter sets to ffmpeg for client ${t}: ${e}`)}if(T.on("error",(e=>{this.logger.error(`[BaichuanRtspServer] Failed to spawn ffmpeg for client ${t}:`,e)})),T.on("close",((e,s)=>{this.rtspDebugLog(`ffmpeg exited for client ${t} (code=${e}, signal=${s})`)})),A(T,g,d),T.stdin?.on("error",(e=>{const s=e?.code;"EPIPE"!==s&&"ERR_STREAM_WRITE_AFTER_END"!==s?this.logger.error(`[BaichuanRtspServer] FFmpeg stdin error for client ${t}:`,e):this.rtspDebugLog(`FFmpeg stdin error (${s}) for client ${t}`)})),F=this.hasAudio?T.stdio?.[3]:void 0,F?.on?.("error",(e=>{const s=e?.code;"EPIPE"!==s&&"ERR_STREAM_WRITE_AFTER_END"!==s?this.logger.error(`[BaichuanRtspServer] FFmpeg audio pipe error for client ${t}:`,e):this.rtspDebugLog(`FFmpeg audio pipe error (${s}) for client ${t}`)})),F&&this.audioPrimingFrame)try{F.write(this.audioPrimingFrame)}catch{}}this.rtspDebugLog(`Creating native stream iterator for client ${t}`);const M=this.nativeFanout?this.nativeFanout.subscribe(t):ee(this.api,this.channel,this.profile);this.tempStreamGenerator=null;let U=0,L=Date.now();const P=o&&o.frameRate>0?1e3/o.frameRate:40;(async()=>{try{this.rtspDebugLog(`Starting to feed frames to client ${t} (target FPS: ${o?.frameRate||25}, interval: ${P}ms)`);let s=0,n=!1,i=!1,A=!1,a=!1,c=!1;for await(const o of M){if(!this.connectedClients.has(t)){this.rtspDebugLog(`Client ${t} disconnected, stopping frame feed`);break}const l=T?.stdin;if(!u&&(!l||l.destroyed||l.writableEnded||l.writableFinished)){this.rtspDebugLog(`FFmpeg stdin closed for client ${t}`);break}if(0===o.data.length)continue;if(!o.audio&&!A&&(A=!0,p)){const e=o.data.subarray(0,16).toString("hex");C(`First video frame received from generator for client ${t} (len=${o.data.length}, videoType=${String(o.videoType??this.flow.videoType)}, head=${e})`)}if(o.audio){if(s++,1===s&&this.rtspDebugLog(`Audio frames detected (codec: ${o.codec||"unknown"}, sampleRate: ${o.sampleRate||"unknown"})`),s%100==0&&this.rtspDebugLog(`Received ${s} audio frames (not sent to RTSP yet)`),u){if(!I?.seenFirstVideoKeyframe)continue;if(this.hasAudio&&e.isAdtsAacFrame(o.data)){if(p&&!i){i=!0;const e=o.data.subarray(0,16).toString("hex");C(`First audio ADTS frame packetized to RTP for client ${t} (len=${o.data.length}, head=${e})`)}N(o.data)}continue}if(this.hasAudio&&F&&!F.writableEnded&&!F.writableFinished){const s=F;if(!s)continue;if(e.isAdtsAacFrame(o.data))try{if(!i){i=!0;const e=o.data.subarray(0,16).toString("hex");this.rtspDebugLog(`First audio frame written to ffmpeg pipe for client ${t} (len=${o.data.length}, head=${e})`)}s.write(o.data)||await new Promise((e=>s.once("drain",(()=>e()))))}catch{}}continue}if("H264"===o.videoType||"H265"===o.videoType){const e="H264"===o.videoType?(0,r.rB)(o.data):(0,r.nf)(o.data);0===U&&this.setFlowVideoType(o.videoType,"first video frame");if(this.flow.getFmtp().hasParamSets)this.firstFrameReceived||this.markFirstFrameReceived();else{this.flow.extractParameterSets(e);this.flow.getFmtp().hasParamSets&&this.markFirstFrameReceived()}}U++,U%100==0&&this.rtspDebugLog(`Sent ${U} frames to client ${t} (frame size: ${o.data.length} bytes)`);const h=Date.now(),g=P-(h-L);if(g>0&&await new Promise((e=>setTimeout(e,Math.min(g,2*P)))),L=Date.now(),u){const e=o.videoType??this.flow.videoType,s="H264"===e?(0,r.rB)(o.data):(0,r.nf)(o.data);if(!I?.seenFirstVideoKeyframe)if("H265"===e){const{hasParamSets:r}=this.flow.getFmtp();if(!r){p&&!a&&(a=!0,C(`H265 gating: waiting for VPS/SPS/PPS before sending RTP to client ${t}`));continue}if(!I?.rtpSentVideoConfig){const t=this.flow.getParameterSetsAnnexB();t&&t.length>0&&(R(e,t,!1),I.rtpSentVideoConfig=!0)}I.h265WaitStartMs||(I.h265WaitStartMs=Date.now());const n=k(s),i=Date.now()-I.h265WaitStartMs;if(!n&&i<2e3){p&&!c&&(c=!0,C(`H265 gating: waiting for IRAP (or timeout) for client ${t}`));continue}I.seenFirstVideoKeyframe=!0}else{const{hasParamSets:r}=this.flow.getFmtp();if(!r){p&&!a&&(a=!0,C(`H264 gating: waiting for SPS/PPS before sending RTP to client ${t}`));continue}if(!I?.rtpSentVideoConfig){const t=this.flow.getParameterSetsAnnexB();t&&t.length>0&&(R(e,t,!1),I.rtpSentVideoConfig=!0)}if(!y(s))continue;I.seenFirstVideoKeyframe=!0}const i=o.microseconds;if(v(i),!I?.rtpSentVideoConfig){const t=this.flow.getParameterSetsAnnexB();t&&t.length>0&&(R(e,t,!1),I.rtpSentVideoConfig=!0)}if(!n&&(n=!0,p)){const e=o.data.subarray(0,16).toString("hex");C(`First video access unit packetized to RTP for client ${t} (len=${o.data.length}, head=${e})`)}R(e,s,!0)}else try{if(l&&!l.destroyed&&!l.writableEnded&&!l.writableFinished){if(!n){n=!0;const e=o.data.subarray(0,16).toString("hex");this.rtspDebugLog(`First video frame written to ffmpeg stdin for client ${t} (len=${o.data.length}, head=${e})`)}l.write("H264"===o.videoType?(0,r.rB)(o.data):o.data)||await new Promise((e=>{l?l.once("drain",(()=>e())):e()}))}}catch(e){const s=e?.code;if("EPIPE"===s||"ERR_STREAM_WRITE_AFTER_END"===s){this.rtspDebugLog(`EPIPE writing to ffmpeg for client ${t}`);break}this.logger.error(`[BaichuanRtspServer] Error writing frame to ffmpeg for client ${t}:`,e)}}this.rtspDebugLog(`Finished feeding frames to client ${t} (total: ${U} frames)`)}catch(e){this.logger.error(`[BaichuanRtspServer] Error in feedFrames for client ${t}:`,e)}})().catch((e=>{this.logger.error(`[BaichuanRtspServer] Error feeding frames to client ${t}:`,e)})),T?.stderr?.on("data",(e=>{const s=e.toString();(s.includes("error")||s.includes("Error"))&&this.logger.error(`[BaichuanRtspServer] FFmpeg error for client ${t}: ${s}`)}))}async startNativeStream(){this.nativeStreamActive||(this.nativeStreamActive=!0,this.firstFrameReceived=!1,this.firstAudioDetected=!1,this.hasAudio=!1,this.audioInfo=null,this.audioPrimingFrame=null,this.firstFramePromise=new Promise((e=>{this.firstFrameResolve=e})),this.firstAudioPromise=new Promise((e=>{this.firstAudioResolve=e})),this.rtspDebugLog(`Starting native stream for profile ${this.profile} (waiting for camera to start transmitting...)`),await this.flow.startKeepAlive(this.api),this.nativeFanout=new ae({maxQueueItems:200,createSource:()=>ee(this.api,this.channel,this.profile),onFrame:t=>{if(t.audio){if(!this.hasAudio&&"tcp"===this.api.client.getTransport()&&e.isAdtsAacFrame(t.data)){const s=e.parseAdtsSamplingInfo(t.data);s&&(this.hasAudio=!0,this.audioInfo={codec:"aac-adts",sampleRate:s.sampleRate,channels:s.channels,configHex:s.configHex},this.audioPrimingFrame=Buffer.from(t.data),this.markFirstAudioDetected(),this.rtspDebugLog(`Audio detected (AAC/ADTS ${s.sampleRate}Hz ch=${s.channels}); advertising RTSP track1 as mpeg4-generic`))}return}if(0===t.data.length)return;"H264"!==t.videoType&&"H265"!==t.videoType||this.setFlowVideoType(t.videoType,"native stream"),this.flow.extractParameterSets(t.data);const{hasParamSets:s}=this.flow.getFmtp();s&&this.markFirstFrameReceived()},onError:e=>{this.logger.warn(`[BaichuanRtspServer] Shared native stream error: ${e}`)}}),this.nativeFanout.start(),this.clearNoClientAutoStopTimer(),this.noClientAutoStopTimer=setTimeout((()=>{0===this.connectedClients.size&&(this.rtspDebugLog("Auto-stopping primed native stream (no clients connected)"),this.stopNativeStream())}),15e3),this.noClientAutoStopTimer?.unref?.())}markFirstFrameReceived(){!this.firstFrameReceived&&this.firstFrameResolve&&(this.firstFrameReceived=!0,this.rtspDebugLog(`First frame received from camera for profile ${this.profile}`),this.firstFrameResolve(),this.firstFrameResolve=null)}markFirstAudioDetected(){!this.firstAudioDetected&&this.firstAudioResolve&&(this.firstAudioDetected=!0,this.firstAudioResolve(),this.firstAudioResolve=null)}async stopNativeStream(){if(this.nativeStreamActive){if(this.rtspDebugLog("Stopping native stream"),this.flow.stopKeepAlive(),this.clearNoClientAutoStopTimer(),this.nativeStreamActive=!1,this.firstFrameReceived=!1,this.firstFramePromise=null,this.firstFrameResolve&&(this.firstFrameResolve=null),this.firstAudioDetected=!1,this.firstAudioPromise=null,this.firstAudioResolve&&(this.firstAudioResolve=null),this.nativeFanout){const e=this.nativeFanout;this.nativeFanout=null,await e.stop()}if(this.tempStreamGenerator){try{await this.tempStreamGenerator.return(void 0)}catch{}this.tempStreamGenerator=null}}}removeClient(e){this.connectedClients.has(e)&&(this.connectedClients.delete(e),this.emit("clientDisconnected",e),this.logger.info(`[BaichuanRtspServer] RTSP client disconnected: ${e}`),0===this.connectedClients.size&&this.stopNativeStream())}async waitUntilReady(e=3e4){return new Promise(((t,s)=>{if(!this.clientConnectionServer)return void s(new Error("RTSP server not started"));const r=setTimeout((()=>{s(new Error(`Timeout waiting for RTSP server to be ready (${e}ms). Camera may be sleeping or not responding.`))}),e),n=()=>{const e=new a.Socket;e.setTimeout(1e3),e.on("connect",(()=>{e.destroy(),this.nativeStreamActive&&this.firstFramePromise?(this.rtspDebugLog("Port is listening, waiting for camera to start transmitting frames..."),this.firstFramePromise.then((()=>{clearTimeout(r),t()})).catch((e=>{clearTimeout(r),s(e)}))):(clearTimeout(r),t())})),e.on("timeout",(()=>{e.destroy(),setTimeout(n,500)})),e.on("error",(()=>{e.destroy(),setTimeout(n,500)})),e.connect(this.listenPort,this.listenHost)};n()}))}async stop(){if(!this.active)return;this.logger.info(`[BaichuanRtspServer] Stopping RTSP server on ${this.listenHost}:${this.listenPort}...`),await this.stopNativeStream();const e=Array.from(this.connectedClients);for(const t of e){const e=this.clientResources.get(t);if(e){if(e.ffmpeg)try{e.ffmpeg.stdin?.end(),e.ffmpeg.kill("SIGTERM"),setTimeout((()=>{try{e.ffmpeg?.kill("SIGKILL")}catch{}}),1e3)}catch{}if(e.udpSocket)try{e.udpSocket.close()}catch{}if(e.rtspSocket&&!e.rtspSocket.destroyed)try{e.rtspSocket.destroy()}catch{}}}this.clientResources.clear(),this.clientConnectionServer&&(await new Promise((e=>{this.clientConnectionServer?.close((()=>{e()}))})),this.clientConnectionServer=void 0),this.active=!1,this.connectedClients.clear(),this.emit("close"),this.logger.info("[BaichuanRtspServer] RTSP server stopped")}getRtspUrl(){return`rtsp://${this.listenHost}:${this.listenPort}${this.path}`}isActive(){return this.active}getClientCount(){return this.connectedClients.size}};async function le(e,t){const s=await h.promises.readdir(t,{withFileTypes:!0}),r=[];for(const n of s){const s=g.join(t,n.name),i=g.relative(e,s).replace(/\\/g,"/");n.isDirectory()?(r.push({absPath:s,relPath:i,isDir:!0}),r.push(...await le(e,s))):n.isFile()&&r.push({absPath:s,relPath:i,isDir:!1})}return r}async function he(e){const{sourceDir:t,zipPath:s}=e;await h.promises.mkdir(g.dirname(s),{recursive:!0});const r=new d.u,n=await le(t,t),i=n.filter((e=>e.isDir)),A=n.filter((e=>!e.isDir));for(const e of i){const t=e.relPath.endsWith("/")?e.relPath:e.relPath+"/";r.addEmptyDirectory(t)}for(const e of A)r.addFile(e.absPath,e.relPath);const o=h.createWriteStream(s);await new Promise(((e,t)=>{o.on("error",t),r.outputStream.on("error",t),o.on("close",e),r.outputStream.pipe(o),r.end()}))}var ge={resolution_index:[0,7],tv_system:[7,1],framerate:[8,7],audio_index:[15,2],ai_pd:[17,1],ai_fd:[18,1],ai_vd:[19,1],ai_ad:[20,1],encoder_type_index:[21,2],is_schedule_record:[23,1],is_motion_record:[24,1],is_rf_record:[25,1],is_doorbell_record:[26,1],ai_other:[27,1]},de={resolution_index:[0,7],tv_system:[7,1],framerate:[8,7],audio_index:[15,2],ai_pd:[17,1],ai_fd:[18,1],ai_vd:[19,1],ai_ad:[20,1],encoder_type_index:[21,2],is_schedule_record:[23,1],is_motion_record:[24,1],is_rf_record:[25,1],is_doorbell_record:[26,1],is_ai_other_record:[27,1],picture_layout_index:[28,7],package_delivered:[35,1],package_takenaway:[36,1]},ue={cam:{2:ge,3:ge,4:ge,7:ge,9:ge,10:ge},hub:{0:de,1:{...de,package_event:[37,1]},2:{resolution_index:[0,7],tv_system:[7,1],framerate:[8,7],audio_index:[15,2],ai_pd:[17,1],ai_fd:[18,1],ai_vd:[19,1],ai_ad:[20,1],ai_other:[21,2],encoder_type_index:[23,1],is_schedule_record:[24,1],is_motion_record:[25,1],is_rf_record:[26,1],is_doorbell_record:[27,1],picture_layout_index:[28,7],package_delivered:[35,1],package_takenaway:[36,1],package_event:[37,1],upload_flag:[38,1]}}};function Ee(e,t,s){const r=ue[e],n=r[t]??r[Math.max(...Object.keys(r).map((e=>Number(e))))];if(!n)return;const i=function(e,t){if(!e)return;if(!/^[0-9a-fA-F]+$/.test(e))return;const s=4*e.length,r=BigInt(`0x${e}`).toString(2).padStart(s,"0").split("").reverse().join(""),n=BigInt(`0b${r}`),i={};for(const[e,[s,r]]of Object.entries(t)){const t=BigInt(s),A=((n&(1n<<BigInt(r))-1n<<t)>>t).toString(2).padStart(r,"0").split("").reverse().join("");i[e]=Number.parseInt(A,2)}return i}(s,n);if(!i)return;return{raw:i,flags:{aiPerson:1===i.ai_pd,aiVehicle:1===i.ai_vd,aiAnimal:1===i.ai_ad,aiFace:1===i.ai_fd,aiOther:1===i.is_ai_other_record||1===i.ai_other||(i.ai_other??0)>0,schedule:1===i.is_schedule_record,motion:1===i.is_motion_record,rf:1===i.is_rf_record,doorbell:1===i.is_doorbell_record,package:1===i.package_event||1===i.package_delivered||1===i.package_takenaway}}}function Ie(e,t){if(!/^\d{8}$/.test(e))return;if(!/^\d{6}$/.test(t))return;const s=Number.parseInt(e.slice(0,4),10),r=Number.parseInt(e.slice(4,6),10),n=Number.parseInt(e.slice(6,8),10),i=Number.parseInt(t.slice(0,2),10),A=Number.parseInt(t.slice(2,4),10),o=Number.parseInt(t.slice(4,6),10);return[s,r,n,i,A,o].every(Number.isFinite)?new Date(s,r-1,n,i,A,o):void 0}function pe(e){const t=e.lastIndexOf(".");if(t<=0||t===e.length-1)return;const s=e.slice(t+1),r=e.slice(0,t).split("/").filter(Boolean).at(-1);if(!r)return;const n=r.split("_"),i=n[0]??"";if(!i.startsWith("Rec")||6!==i.length)return;const A=i[3],o="M"===A?"main":"S"===A?"sub":"unknown",a=Number.parseInt(i.slice(4,6),16);if(!Number.isFinite(a))return;let c,l,h,g="cam",d="",u="",E="",I="";if(6===n.length)d=n[1]??"",u=n[2]??"",E=n[3]??"",I=n[4]??"";else if(7===n.length)d=n[1]??"",u=n[2]??"",E=n[3]??"",c=n[4],I=n[5]??"";else{if(9!==n.length)return;g="hub",d=n[1]??"",u=n[2]??"",E=n[3]??"",c=n[4],l=n[5],h=n[6],I=n[7]??""}d=d.toLowerCase().replace("dst","");const p=Ie(d,u);if(!p)return;const C="000000"===E?p:Ie(d,E);if(!C)return;const B=Math.max(0,C.getTime()-p.getTime()),f={baseName:r,ext:s,streamHint:o,version:a,devType:g,start:p,end:C,durationMs:B},Q=Ee(g,a,I);return Q&&(f.flags=Q.flags,f.rawFlags=Q.raw),null!=c&&(f.animalTypeRaw=c),null!=l&&(f.widthRaw=l),null!=h&&(f.heightRaw=h),f}function Ce(e){if(null==e)return;const t=Number(e);return Number.isFinite(t)?t:void 0}function Be(e){if("number"==typeof e)return e>0;if("string"==typeof e){const t=Number(e);return Number.isFinite(t)?t>0:e.length>0&&"0"!==e}return Boolean(e)}function fe(e,t){if(!e||"object"!=typeof e)return;const s=e,r=s[t],n=s.Host,i={...n&&"object"==typeof n?n:{},...r&&"object"==typeof r?r:{}};return Object.keys(i).length?i:void 0}function Qe(e,t){if(!e)return!1;for(const[s,r]of Object.entries(e))if(t.test(s)&&Be(r))return!0;return!1}function me(e){if(!e)return;const t=e.match(/<Support[^>]*>([\s\S]*?)<\/Support>/i);if(!t)return;const s=t[1]??"",r=s.match(/<ptzMode>([^<]*)<\/ptzMode>/i)?.[1],n=[];for(const e of s.matchAll(/<item[^>]*>([\s\S]*?)<\/item>/gi)){const t=e[1]??"",s={chnID:Ce(t.match(/<chnID>([^<]*)<\/chnID>/i)?.[1])??0};for(const e of t.matchAll(/<([A-Za-z0-9_]+)>([^<]*)<\/\1>/g)){const t=e[1],r=e[2];if(!t)continue;if("chnID"===t)continue;const n=Ce(r);s[t]=n??r}n.push(s)}const i={items:n};void 0!==r&&(i.ptzMode=r);const A=(e,t)=>{const r=(e=>{const t=s.match(new RegExp(`<${e}>([^<]*)<\\/${e}>`,"i"));return Ce(t?.[1])})(t);void 0!==r&&(i[e]=r)};A("IOInputPortNum","IOInputPortNum"),A("IOOutputPortNum","IOOutputPortNum"),A("diskNum","diskNum"),A("channelNum","channelNum"),A("audioNum","audioNum"),A("ptzCfg","ptzCfg"),A("B485","B485"),A("autoUpdate","autoUpdate"),A("pushAlarm","pushAlarm"),A("ftp","ftp"),A("ftpTest","ftpTest"),A("email","email"),A("wifi","wifi"),A("record","record"),A("wifiTest","wifiTest"),A("rtsp","rtsp"),A("onvif","onvif"),A("audioTalk","audioTalk");const o=(e=>{const t=s.match(new RegExp(`<${e}>([^<]*)<\\/${e}>`,"i"));return t?.[1]})("subVersion");return void 0!==o&&(i.subVersion=o),i}function ye(e){const{channel:t}=e,s=fe(e.abilities,t),r=function(e,t){if(!e?.items?.length)return;const s=e=>{const t=e;let s=0;null==t.name&&(s+=2);const r=["ptzType","ptzControl","ptzPreset","ledCtrl","lightType","battery","audioVersion","motion","encCtrl","newIspCfg","remoteAbility"];for(const e of r)void 0!==t[e]&&(s+=3);return s+=Math.min(10,Math.max(0,Object.keys(t).length-1)),s};return(t=>{const r=e.items.filter((e=>e.chnID===t));if(r.length)return r.slice().sort(((e,t)=>s(t)-s(e)))[0]})(t)}(e.support,t),n=e.support?.ptzMode,i="string"==typeof n?n.toLowerCase():void 0,A=r?r.ptzType:void 0,o=r?r.ptzControl:void 0,a=Be(A)||Be(o)||Be(r?.ptzPreset),c=("none"===i||"0"===i)&&!a,l=!!r&&Be(r.battery),h=!!r&&Be(r.ptzPreset),g=r?r.doorbellVersion:void 0,d=Number.isFinite(Number(g))?Number(g)>0:Be(g),u=r?r.lightType:void 0,E="number"==typeof u?u:"string"==typeof u?Number(u):void 0,I=a||!!i&&("none"!==i&&"0"!==i),p=!!i&&(i.includes("pt")||"pt"===i||"ptz"===i),C=!!i&&i.includes("z"),B=Qe(s,/battery/i),f=Qe(s,/white\s*led|whiteLed|flood\s*light|floodlight/i),Q=Qe(s,/audio\s*alarm|audioAlarm|siren|pushAlarn|audioPlay/i),m=Be(e.support?.audioTalk)||!!r&&Be(r.ipcAudioTalk),y=Qe(s,/ptz/i),w=Qe(s,/zoom|zoomFocus|StartZoomFocus/i),S=Qe(s,/preset/i),D=Qe(s,/(^|_)pir/i)||Qe(s,/rfAlarm/i)||Qe(s,/mdWithPir/i),b=!!r&&(Be(r.rfCfg)||Be(r.newRfCfg)||Be(r.rfVersion)||Be(r.battery)),v=!c&&(p||y),R=!c&&(p||y),N=!c&&(C||w),k=!c&&(h||S),T={channel:t,hasPan:v,hasTilt:R,hasZoom:N,hasPresets:k,hasPtz:!c&&(I||v||R||N||k),hasBattery:l||B,hasIntercom:m,hasSiren:Q,hasFloodlight:Number.isFinite(E)?E>0:f,hasPir:D||b,isDoorbell:d};return void 0!==i&&(T.ptzMode=i),T}function we(e){if(null!=e){if("boolean"==typeof e)return e;if("number"==typeof e)return 1===e;if("string"==typeof e){const t=e.trim().toLowerCase();if("1"===t||"true"===t||"yes"===t||"on"===t)return!0;if("0"===t||"false"===t||"no"===t||"off"===t)return!1}}}function Se(e){const t=function(e){if(!e||0===e.length)return[];const t=e[0]?.value;if(!t)return[];let s=t?.status??t?.Channelstatus??t?.ChannelStatus??t?.channelStatus??t?.channelstatus;if(!Array.isArray(s))if(Array.isArray(t))s=t;else if(s=t?.channels??t?.Channels??t?.channel??t?.Channel,!Array.isArray(s)){const e=Object.keys(t).filter((e=>/^channel\d+$/i.test(e)||/^ch\d+$/i.test(e)));e.length>0&&(s=e.map((e=>{const s=t[e];return"object"==typeof s&&null!==s?s:{channel:parseInt(e.replace(/\D/g,""),10)}})))}return Array.isArray(s)?s:[]}(e);if(!t.length)return[];const s=[];for(const e of t){if("object"!=typeof e||null===e)continue;const t=e?.channel??e?.id??e?.channelId??e?.Channel??e?.ID??e?.ChannelId;if("number"!=typeof t||!Number.isFinite(t))continue;const r="string"==typeof e?.name?e.name:void 0,n="string"==typeof e?.uid?e.uid:void 0,i="string"==typeof e?.typeInfo?e.typeInfo:void 0,A=we(e?.online),o=we(e?.sleep);s.push({channel:t,...void 0!==A?{online:A}:{},...void 0!==o?{sleep:o}:{},...r?{name:r}:{},...n?{uid:n}:{},...i?{typeInfo:i}:{}})}return s.sort(((e,t)=>e.channel-t.channel)),s}function De(e){return new Promise((t=>setTimeout(t,e)))}function be(e,t){const s=new RegExp(`<${t}\\b[^>]*>([\\s\\S]*?)<\\/${t}>`,"g"),r=[];let n;for(;n=s.exec(e);)r.push(n[1]??"");return r}function ve(e){const t=Number.parseInt(v(e,"year")??"",10),s=Number.parseInt(v(e,"month")??"",10),r=Number.parseInt(v(e,"day")??"",10),n=Number.parseInt(v(e,"hour")??"",10),i=Number.parseInt(v(e,"minute")??"",10),A=Number.parseInt(v(e,"second")??"",10);if([t,s,r,n,i,A].every(Number.isFinite))return new Date(t,s-1,r,n,i,A)}function Re(e,t){return`<${e}><year>${t.getFullYear()}</year><month>${t.getMonth()+1}</month><day>${t.getDate()}</day><hour>${t.getHours()}</hour><minute>${t.getMinutes()}</minute><second>${t.getSeconds()}</second></${e}>`}function Ne(e){const t=[],s=be(e,"FileInfo");for(const e of s){const s=v(e,"Id")??v(e,"ID")??v(e,"id"),r=v(e,"name")??v(e,"fileName"),n=(s??r)?.trim();if(!n)continue;const i={fileName:n};null!=r&&r.trim()&&(i.name=r.trim()),null!=s&&s.trim()&&(i.id=s.trim());const A=v(e,"type")??v(e,"recordType")??v(e,"alarmType");null!=A&&(i.recordType=A);const o=v(e,"size")??v(e,"fileSize"),a=o?Number.parseInt(o,10):void 0;null!=a&&Number.isFinite(a)&&(i.sizeBytes=a);const c=be(e,"startTime")[0],l=be(e,"endTime")[0],h=c?ve(c):void 0,g=l?ve(l):void 0;h&&(i.startTime=h),g&&(i.endTime=g);const d=pe(i.name??i.fileName);d&&(i.parsedFileName=d,i.startTime||(i.startTime=d.start),i.endTime||(i.endTime=d.end)),t.push(i)}const r=be(e,"File");for(const e of r){const s=v(e,"fileName")??v(e,"name");if(!s)continue;const r=v(e,"size")??v(e,"fileSize"),n=r?Number.parseInt(r,10):void 0,i=v(e,"type")??v(e,"recordType")??v(e,"alarmType"),A=be(e,"startTime")[0],o=be(e,"endTime")[0],a={fileName:s};null!=n&&Number.isFinite(n)&&(a.sizeBytes=n),null!=i&&(a.recordType=i);const c=A?ve(A):void 0,l=o?ve(o):void 0;c&&(a.startTime=c),l&&(a.endTime=l);const h=pe(a.fileName);h&&(a.parsedFileName=h,a.startTime||(a.startTime=h.start),a.endTime||(a.endTime=h.end)),t.push(a)}if(0===t.length){const s=/<fileName>([\s\S]*?)<\/fileName>/g;let r;for(;r=s.exec(e);){const e=(r[1]??"").trim();if(!e)continue;const s={fileName:e},n=pe(e);n&&(s.parsedFileName=n,s.startTime=n.start,s.endTime=n.end),t.push(s)}}if(0===t.length){const s=be(e,"alarmVideo");for(const e of s){const s=v(e,"fileName")??v(e,"name");if(!s)continue;const r={fileName:s},n=v(e,"alarmType");null!=n&&(r.recordType=n);const i=be(e,"startTime")[0],A=be(e,"endTime")[0],o=i?ve(i):void 0,a=A?ve(A):void 0;o&&(r.startTime=o),a&&(r.endTime=a);const c=pe(r.fileName);c&&(r.parsedFileName=c,r.startTime||(r.startTime=c.start),r.endTime||(r.endTime=c.end)),t.push(r)}}const n=new Set;return t.filter((e=>!n.has(e.fileName)&&(n.add(e.fileName),!0)))}function ke(e){const t=v(e,"audioType"),s=Number.parseInt(v(e,"sampleRate")??"",10),r=Number.parseInt(v(e,"samplePrecision")??"",10),n=Number.parseInt(v(e,"lengthPerEncoder")??"",10),i=v(e,"soundTrack"),A=v(e,"priority");if(!(t&&Number.isFinite(s)&&Number.isFinite(r)&&Number.isFinite(n)&&i))return null;const o={audioType:t,sampleRate:s,samplePrecision:r,lengthPerEncoder:n,soundTrack:i};if(void 0!==A){const e=Number.parseInt(A,10);Number.isFinite(e)&&(o.priority=e)}return o}var Te=new Set(["Reolink Duo PoE","Reolink Duo WiFi"]),Fe=new Set(["Reolink TrackMix PoE","Reolink TrackMix WiFi","RLC-81MA"]),Me=new Set([...Te,...Fe]);function Ue(e,t){const s=4+e.length,r=s%8==0?0:8-s%8,n=12+e.length+r,i=Buffer.alloc(n);return i.writeUInt32LE(1651978544,0),i.writeUInt16LE(s,4),i.writeUInt16LE(s,6),i.writeUInt16LE(256,8),i.writeUInt16LE(t,10),e.copy(i,12),i}var Le=class{client;logger;httpClient;host;username;password;rebootAfterDisconnectionsPerMinute;disconnectStormVoluntaryAtMs=[];disconnectStormRebootInFlight;disconnectStormLastRebootAtMs;simpleEventListeners=new Set;simpleEventSubscribed=!1;simpleEventSubscribeInFlight;simpleEventUnsubscribeInFlight;simpleEventResubscribeTimer;simpleEventResubscribeInFlight;simpleEventResubscribeIntervalMs=3e5;statePollingInterval;lastMotionState;lastAiState;aiStatePollingDisabled=!1;aiStatePollingDisabledLogged=!1;rtspServers=new Set;activeVideoMsgNums=new Map;lastSleepProbe;constructor(e){this.logger=e.logger??console,this.client=new X(e),this.host=e.host,this.username=e.username,this.password=e.password,this.httpClient=new Z({host:e.host,username:e.username,password:e.password,timeoutMs:6e5}),this.client.on("event",(e=>{const t=function(e){const t=e.timestamp??Date.now();if("motion"===e.type)return{type:"motion",channel:e.channel,timestamp:t};if("visitor"===e.type)return{type:"doorbell",channel:e.channel,timestamp:t};if("daynight"===e.type)return{type:"daynight",channel:e.channel,timestamp:t};if("ai"===e.type){const s=e.ai,r=s?.type;return{type:r?{people:"people",vehicle:"vehicle",dog_cat:"animal",face:"face",package:"package",other:"other"}[r]:"other",channel:e.channel,timestamp:t}}return null}(e);if(t)for(const e of this.simpleEventListeners)try{e(t)}catch(e){(this.logger.warn??this.logger.error).call(this.logger,"[ReolinkBaichuanApi] onSimpleEvent handler error",e)}}));const t=e.rebootAfterDisconnectionsPerMinute;"number"==typeof t&&Number.isFinite(t)&&t>0&&(this.rebootAfterDisconnectionsPerMinute=Math.floor(t),this.client.on("close",(()=>{try{this.maybeRebootOnDisconnectStorm()}catch{}})))}async runAllDiagnosticsConsecutively(e){const t=e.channel??0,s=e.outDir,n=(new Date).toISOString().replace(/[:.]/g,"-"),i=(0,g.join)(s,n);(this.logger.log??console.log).call(this.logger,"[Diagnostics] starting run",{outDir:s,runDir:i,channel:t,durationSeconds:e.durationSeconds,selection:e.selection});const A=!0===e.cgi||"object"==typeof e.cgi&&null!=e.cgi,o=A?new K({host:("object"==typeof e.cgi?e.cgi.host:void 0)??this.host,username:("object"==typeof e.cgi?e.cgi.username:void 0)??this.username,password:("object"==typeof e.cgi?e.cgi.password:void 0)??this.password,..."object"==typeof e.cgi&&null!=e.cgi.port?{port:e.cgi.port}:{},..."object"==typeof e.cgi&&null!=e.cgi.useHttps?{useHttps:e.cgi.useHttps}:{},..."object"==typeof e.cgi&&null!=e.cgi.insecureTLS?{insecureTLS:e.cgi.insecureTLS}:{},..."object"==typeof e.cgi&&null!=e.cgi.timeoutMs?{timeoutMs:e.cgi.timeoutMs}:{}}):void 0,a=await(0,r.lp)({outDir:i,native:{api:this,channel:t},...o?{cgi:{cgi:o,channel:t}}:{},...e.extra?{extra:e.extra}:{}});(this.logger.log??console.log).call(this.logger,"[Diagnostics] diagnostics bundle collected",{diagnosticsPath:a.diagnosticsPath,runDir:a.outDir,cgiEnabled:A});const c=(0,g.join)(i,"streams"),l=!0===e.rtsp||"object"==typeof e.rtsp&&null!=e.rtsp?{host:("object"==typeof e.rtsp?e.rtsp.host:void 0)??this.host,username:("object"==typeof e.rtsp?e.rtsp.username:void 0)??this.username,password:("object"==typeof e.rtsp?e.rtsp.password:void 0)??this.password,..."object"==typeof e.rtsp&&null!=e.rtsp.port?{port:e.rtsp.port}:{}}:void 0;await(0,r.kV)({outDir:c,durationSeconds:e.durationSeconds,...null!=e.snapshotIntervalSeconds?{snapshotIntervalSeconds:e.snapshotIntervalSeconds}:{},channel:t,selection:e.selection,...l?{rtsp:l}:{},...e.rtmp?{rtmp:e.rtmp}:{},native:{api:this},...e.limits?{limits:e.limits}:{},logger:this.logger}),(this.logger.log??console.log).call(this.logger,"[Diagnostics] stream sampling completed",{streamsDir:c});const h=(0,g.join)(s,`${n}.zip`);return(this.logger.log??console.log).call(this.logger,"[Diagnostics] creating zip bundle",{zipPath:h}),await he({sourceDir:i,zipPath:h}),(this.logger.log??console.log).call(this.logger,"[Diagnostics] zip bundle created",{zipPath:h}),{runDir:a.outDir,zipPath:h,diagnosticsPath:a.diagnosticsPath,streamsDir:c}}async maybeRebootOnDisconnectStorm(){const e=this.rebootAfterDisconnectionsPerMinute;if(null==e)return;const t=this.client.getLastDisconnectInfo?.();if(!t?.voluntary)return;const s=Date.now(),r=s-6e4;for(;this.disconnectStormVoluntaryAtMs.length&&this.disconnectStormVoluntaryAtMs[0]<r;)this.disconnectStormVoluntaryAtMs.shift();if(this.disconnectStormVoluntaryAtMs.push(s),this.disconnectStormVoluntaryAtMs.length<e)return;if(this.disconnectStormRebootInFlight)return;const n=6e5;null!=this.disconnectStormLastRebootAtMs&&s-this.disconnectStormLastRebootAtMs<n||(this.disconnectStormLastRebootAtMs=s,(this.logger.warn??this.logger.error).call(this.logger,"[ReolinkBaichuanApi] disconnect storm detected; rebooting device",{transport:t.transport,reason:t.reason,voluntaryDisconnectsInWindow:this.disconnectStormVoluntaryAtMs.length,windowMs:6e4,threshold:e,cooldownMs:n,method:"auto"}),this.disconnectStormRebootInFlight=this.rebootFromDisconnectStorm("auto").catch((e=>{(this.logger.warn??this.logger.error).call(this.logger,"[ReolinkBaichuanApi] disconnect-storm reboot failed",e)})).finally((()=>{this.disconnectStormRebootInFlight=void 0})))}async rebootFromDisconnectStorm(e){let t;if("auto"===e||"baichuan"===e)try{return void await this.reboot()}catch(s){if(t=s,"baichuan"===e)throw s}if("auto"===e||"cgi"===e){const e=new K({host:this.host,username:this.username,password:this.password,timeoutMs:6e4});try{return await e.login(),void await e.Reboot()}catch(e){throw t=e,e}finally{try{await e.logout()}catch{}}}throw t instanceof Error?t:new Error(String(t??"disconnect-storm reboot failed"))}async onSimpleEvent(e){this.simpleEventListeners.add(e),await this.ensureSimpleEventSubscribed(),this.startSimpleEventResubscribeTimer()}async offSimpleEvent(e){if(e?this.simpleEventListeners.delete(e):this.simpleEventListeners.clear(),0===this.simpleEventListeners.size)this.stopSimpleEventResubscribeTimer(),await this.ensureSimpleEventUnsubscribed();else{"udp"===this.client.getTransport?.()||this.startStatePolling()}}startSimpleEventResubscribeTimer(){this.simpleEventResubscribeTimer||0!==this.simpleEventListeners.size&&(this.simpleEventResubscribeTimer=setInterval((()=>{this.renewSimpleEventSubscription()}),this.simpleEventResubscribeIntervalMs))}stopSimpleEventResubscribeTimer(){this.simpleEventResubscribeTimer&&(clearInterval(this.simpleEventResubscribeTimer),this.simpleEventResubscribeTimer=void 0)}async renewSimpleEventSubscription(){if(0!==this.simpleEventListeners.size)return this.simpleEventResubscribeInFlight||(this.simpleEventResubscribeInFlight=(async()=>{try{await this.subscribeEvents(),this.simpleEventSubscribed=!0,(this.logger.debug??this.logger.log).call(this.logger,"[ReolinkBaichuanApi] renewed simple event subscription",{intervalMs:this.simpleEventResubscribeIntervalMs})}catch(e){(this.logger.debug??this.logger.log).call(this.logger,"[ReolinkBaichuanApi] failed to renew event subscription",e)}})().finally((()=>{this.simpleEventResubscribeInFlight=void 0}))),await this.simpleEventResubscribeInFlight}async ensureSimpleEventSubscribed(){if(0!==this.simpleEventListeners.size&&!this.simpleEventSubscribed)return this.simpleEventSubscribeInFlight||(this.simpleEventSubscribeInFlight=(async()=>{this.client.subscribed||await this.subscribeEvents(),this.simpleEventSubscribed=!0;if(!("udp"===this.client.getTransport?.())){const e=this.client.getConfiguredChannel?.()??0;await this.checkAndDispatchCurrentState(e),this.startStatePolling()}})().finally((()=>{this.simpleEventSubscribeInFlight=void 0}))),await this.simpleEventSubscribeInFlight}async ensureSimpleEventUnsubscribed(){if(this.simpleEventSubscribed||this.client.subscribed){if(this.simpleEventUnsubscribeInFlight)return await this.simpleEventUnsubscribeInFlight;if(this.simpleEventSubscribeInFlight)try{await this.simpleEventSubscribeInFlight}catch{}return this.simpleEventUnsubscribeInFlight=(async()=>{await this.unsubscribeEvents(),this.simpleEventSubscribed=!1,this.stopSimpleEventResubscribeTimer(),this.stopStatePolling()})().finally((()=>{this.simpleEventUnsubscribeInFlight=void 0})),await this.simpleEventUnsubscribeInFlight}}normalizeChannel(e){return null==e?0:e}async login(e){await this.client.login(e)}async close(){this.stopStatePolling(),await this.cleanup(),await this.client.close()}async cleanup(){const e=Array.from(this.rtspServers);this.rtspServers.clear(),await Promise.allSettled(e.map((async e=>{try{await e.stop()}catch(e){this.logger.error("[ReolinkBaichuanApi] Error stopping RTSP server during cleanup:",e)}}))),e.length>0&&this.logger.info(`[ReolinkBaichuanApi] Cleaned up ${e.length} RTSP server(s)`)}async sendXml(e,t=3){this.client.loggedIn||await this.client.login();try{const s=await this.client.sendFrame(e);if(400===s.header.responseCode){if(t>0){if(0===s.body.length)try{this.client.loggedIn=!1,await this.client.login()}catch{}const r=1500;return await new Promise((e=>setTimeout(e,r))),await this.sendXml(e,t-1)}if(0===s.body.length)throw new Error("Baichuan request failed (responseCode 400, empty body). Possible causes: camera sleeping/waking (battery), expired session, or invalid username/password.")}if(0===s.body.length)return"";return this.client.tryDecryptXml(s.body,s.header.channelId,this.client.enc)}catch(e){throw e}}async getTalkAbility(e){return function(e){const t=be(e,"TalkAbility")[0];if(!t)throw new Error("TalkAbility XML not found in response");return{duplexList:be(t,"duplexList").map((e=>v(e,"duplex"))).filter((e=>!!e)),audioStreamModeList:be(t,"audioStreamModeList").map((e=>v(e,"audioStreamMode"))).filter((e=>!!e)),audioConfigList:be(t,"audioConfig").map(ke).filter((e=>!!e))}}(await this.sendXml({cmdId:r.XW,...void 0!==e?{channel:e}:{}}))}async createTalkSession(e=0,t){this.client.loggedIn||await this.client.login();const s="udp"===this.client.getTransport?.()?e:void 0,n=await this.getTalkAbility(e),i=n.audioConfigList.find((e=>"adpcm"===e.audioType.toLowerCase()))??n.audioConfigList[0];if(!i)throw new Error(`Talk not supported on channel ${e} (no audioConfig in TalkAbility)`);const A=n.duplexList[0]??"FDX",o=n.audioStreamModeList[0]??"followVideoStream",a={channel:e,duplex:A,audioStreamMode:o,audioConfig:i},c=Math.floor(i.lengthPerEncoder/2),l=c+4;if(c<=0||l<=4)throw new Error(`Invalid talk audio config: lengthPerEncoder=${i.lengthPerEncoder}`);const h=function(e){const t=e.audioConfig;return`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<TalkConfig version="1.1">\n<channelId>${e.channel}</channelId>\n<duplex>${S(e.duplex)}</duplex>\n<audioStreamMode>${S(e.audioStreamMode)}</audioStreamMode>\n<audioConfig>\n<audioType>${S(t.audioType)}</audioType>\n<sampleRate>${t.sampleRate}</sampleRate>\n<samplePrecision>${t.samplePrecision}</samplePrecision>\n<lengthPerEncoder>${t.lengthPerEncoder}</lengthPerEncoder>\n<soundTrack>${S(t.soundTrack)}</soundTrack>\n</audioConfig>\n</TalkConfig>\n</body>`}(a);await(async()=>{const t=await this.client.sendFrame({cmdId:r.Fi,channel:e,...null!=s?{channelIdOverride:s}:{},payloadXml:h,messageClass:r.Uh});if(422!==t.header.responseCode){if(200!==t.header.responseCode)throw new Error(`TalkConfig rejected (responseCode ${t.header.responseCode})`)}else{await this.client.sendFrame({cmdId:r.Oh,channel:e,...null!=s?{channelIdOverride:s}:{},payloadXml:"",messageClass:r.Uh});const t=await this.client.sendFrame({cmdId:r.Fi,channel:e,...null!=s?{channelIdOverride:s}:{},payloadXml:h,messageClass:r.Uh});if(200!==t.header.responseCode)throw new Error(`TalkConfig rejected after reset (responseCode ${t.header.responseCode})`)}})();const g={channel:e,audioConfig:i,blockSize:c,fullBlockSize:l};let d=Buffer.alloc(0),u=!1,E=!1,I=Date.now();const p=Math.max(1,Math.min(8,Math.floor(t?.blocksPerPayload??1))),C=async t=>{if(0===t.length)return;if(t.length>p)throw new Error(`Internal error: too many blocks in payload (${t.length})`);const n=[];let A=0;for(const e of t)n.push(Ue(e,c)),A+=Math.max(0,2*(e.length-4)+1);await this.client.sendBinaryPayloadNoReply({cmdId:r.O1,channel:e,...null!=s?{channelIdOverride:s}:{},extensionXml:b(e),payload:Buffer.concat(n),messageClass:r.Uh});const o=A/i.sampleRate*1e3,a=Date.now();a>I?I=a+o:I+=o;const l=I-Date.now();l>0&&await De(l)},B=async()=>{if(!E){E=!0;try{for(;;){if(!(d.length>=l)){if(u){if(d.length>0){const e=Buffer.alloc(l,255);d.copy(e,0),d=Buffer.alloc(0),await C([e])}break}break}{const e=[];for(;e.length<p&&d.length>=l;)e.push(d.subarray(0,l)),d=d.subarray(l);await C(e)}}}finally{E=!1}}};return{info:g,sendAudio:async e=>{if(u)throw new Error("Talk session is closed");0!==e.length&&(d=0===d.length?e:Buffer.concat([d,e]),await B())},stop:async()=>{if(u)return;u=!0,await B();const t=I-Date.now();t>0?await De(t+100):await De(100);const n=await this.client.sendFrame({cmdId:r.Oh,channel:e,...null!=s?{channelIdOverride:s}:{},payloadXml:"",messageClass:r.Uh});if(200!==n.header.responseCode)throw new Error(`TalkReset rejected (responseCode ${n.header.responseCode})`)}}}async sendBinary(e){return await this.client.login(),await this.client.sendBinary(e)}async getNetPort(){const e={},t=(await this.sendXml({cmdId:37})).matchAll(/<([A-Za-z]+)Port[^>]*>([\s\S]*?)<\/\1Port>/g);for(const s of t){const t=(s[1]??"").toLowerCase(),r=s[2]??"",n={};for(const e of r.matchAll(/<([A-Za-z]+)>(-?\d+)<\/\1>/g)){const t=(e[1]??"").toLowerCase(),s=Number(e[2]);Number.isFinite(s)&&(n[t]=s)}Object.keys(n).length&&(e[t]=n)}return e}async getPorts(){return this.getNetPort()}async setPortEnabled(e){const t=`${e.port[0].toUpperCase()}${e.port.slice(1)}Port`,s=`<?xml version="1.0" encoding="UTF-8" ?><body><${t} version="1.1"><enable>${e.enable?1:0}</enable></${t}></body>`;await this.sendXml({cmdId:36,payloadXml:s})}async getInfo(e,t){const s={cmdId:null==e?80:318};void 0!==e&&(s.channel=e),null!=t?.timeoutMs&&(s.timeoutMs=t.timeoutMs);return function(e,t){const s={};for(const r of t){const t=v(e,r);void 0!==t&&(s[r]=t)}return s}(await this.sendXml(s),t?.tags?.length?t.tags:["type","hardwareVersion","firmwareVersion","itemNo","serialNumber","name"])}async getChannelIdentity(e,t){const s=await this.getInfo(e,{...null!=t?.timeoutMs?{timeoutMs:t.timeoutMs}:{},tags:["type","name"]});return{channel:e,model:(s.type??"").trim(),name:(s.name??"").trim()}}async getNvrChannelsInfo(e){const t=e?.source??"cgi",s=e?.timeoutMs??3500,r=e?.maxChannels??16,n=e?.cgiTimeoutMs??3e4;if("cgi"===t){const e=new K({host:this.host,username:this.username,password:this.password,timeoutMs:n});try{await e.login();const t=Number.isFinite(r)&&r>0?r:16,s=[{cmd:"GetChannelstatus",action:0},...Array.from({length:t},((e,t)=>({cmd:"GetChnTypeInfo",action:0,param:{channel:t}})))],n=await e.callMany(s),i=Se(n.length?[n[0]]:[]),A=new Map;for(const e of i)A.set(e.channel,e);const o=i.map((e=>e.channel)),a=o.length?[...new Set(o)].sort(((e,t)=>e-t)):Array.from({length:t},((e,t)=>t)),c=[];for(const e of a){const s=A.get(e);let r,i,o;if(e>=0&&e<t){const t=n[1+e],s=t?.value;s&&"object"==typeof s&&("string"==typeof s.typeInfo&&s.typeInfo.trim()&&(r=s.typeInfo.trim()),"string"==typeof s.firmVer&&s.firmVer.trim()&&(i=s.firmVer.trim()),"string"==typeof s.boardInfo&&s.boardInfo.trim()&&(o=s.boardInfo.trim()))}const a=s?.name?.trim(),l=(r??s?.typeInfo)?.trim(),h=s?.uid?.trim();c.push({channel:e,...l?{model:l}:{},...a?{name:a}:{},...h?{uid:h}:{},...void 0!==s?.online?{online:s.online}:{},...void 0!==s?.sleep?{sleep:s.sleep}:{},...i?{firmwareVersion:i}:{},...o?{boardInfo:o}:{},source:"cgi"})}return c}finally{}}let i=[];try{const e=await this.getAbilityInfo();i=Object.keys(e??{}).filter((e=>"Host"!==e)).map((e=>Number(e))).filter((e=>Number.isFinite(e))).sort(((e,t)=>e-t))}catch{}if(0===i.length){const e=Number.isFinite(r)&&r>0?r:16;i=Array.from({length:e},((e,t)=>t))}const A=[];for(const e of i)try{const t=await this.getInfo(e,{timeoutMs:s,tags:["type","name","firmwareVersion"]}),r=(t.type??"").trim(),n=(t.name??"").trim(),i=(t.firmwareVersion??"").trim();if(!!!(r||n||i))continue;A.push({channel:e,...r?{model:r}:{},...n?{name:n}:{},...i?{firmwareVersion:i}:{},source:"baichuan"})}catch{}return A.sort(((e,t)=>e.channel-t.channel))}async getEncXml(e,t){const s=this.normalizeChannel(e);return await this.sendXml({cmdId:56,channel:s,...null!=t?.timeoutMs?{timeoutMs:t.timeoutMs}:{}})}async getStreamMetadata(e){const t=this.normalizeChannel(e),s=await this.getEncXml(t),r=[];let n=!0;const i=this.client.getDebugConfig?.(),A=!0===i?.debugParamSets,o=e=>e.width>0&&e.height>0&&(e.frameRate>0||e.bitRate>0),a=(e,s)=>{if(!A)return;if(!s)return void(this.logger.warn??this.logger.log).call(this.logger,`[ReolinkBaichuanApi] getStreamMetadata(debugParamSets): channel=${t} tag=<${e}> missing`);const r=s,n=v(r,"width")??v(r,"Width"),i=v(r,"height")??v(r,"Height"),a=v(r,"frame")??v(r,"Frame"),c=v(r,"bitRate")??v(r,"BitRate"),l=v(r,"videoEncType")??v(r,"VideoEncType"),h=v(r,"audio")??v(r,"Audio"),g=v(r,"enable")??v(r,"Enable"),d=Number(n??"0"),u=Number(i??"0"),E=Number(a??"0"),I=Number(c??"0"),p=Number(h??"0"),C=void 0===g||"1"===g||"true"===g,B=C&&o({width:d,height:u,frameRate:E,bitRate:I}),f=1400,Q=r.length<=f?r:r.slice(0,f)+`\n...truncated (+${r.length-f} chars)`;(this.logger.warn??this.logger.log).call(this.logger,`[ReolinkBaichuanApi] getStreamMetadata(debugParamSets): channel=${t} tag=<${e}> enabled=${C} plausible=${B} width=${d} height=${u} frame=${E} bitRate=${I} audio=${p} videoEncType=${l??"?"} rawFields=${JSON.stringify({widthText:n,heightText:i,frameText:a,bitRateText:c,videoEncTypeText:l,audioText:h,enableText:g})} blockXml=${JSON.stringify(Q)}`)};if(A){const e=1600,r=s.length<=e?s:s.slice(0,e)+`\n...truncated (+${s.length-e} chars)`,n={mainStream:/<mainStream\b/.test(s),subStream:/<subStream\b/.test(s),extStream:/<extStream\b/.test(s),thirdStream:/<thirdStream\b/.test(s),externStream:/<externStream\b/.test(s),extraStream:/<extraStream\b/.test(s)};(this.logger.warn??this.logger.log).call(this.logger,`[ReolinkBaichuanApi] getStreamMetadata(debugParamSets): channel=${t} xmlLen=${s.length} tagsPresent=${JSON.stringify(n)} xmlHead=${JSON.stringify(r)}`)}const c={0:"H.264",1:"H.265",2:"MJPEG",3:"MPEG4"},l=s.match(/<mainStream[^>]*>([\s\S]*?)<\/mainStream>/);if(l){const e=l[1]??"";a("mainStream",e);const t=Number(v(e,"width")??"0"),s=Number(v(e,"height")??"0"),i=Number(v(e,"videoEncType")??"0"),A=Number(v(e,"frame")??"0"),h=Number(v(e,"bitRate")??"0"),g=Number(v(e,"audio")??"0"),d=v(e,"enable");(void 0===d||"1"===d||"true"===d)&&o({width:t,height:s,frameRate:A,bitRate:h})&&(r.push({profile:"main",audio:g,width:t,height:s,videoEncType:c[i]??`Unknown(${i})`,videoEncTypeInt:i,frameRate:A,bitRate:h,audioCodec:"aac"}),n=n&&1===g)}const h=s.match(/<subStream[^>]*>([\s\S]*?)<\/subStream>/);if(h){const e=h[1]??"";a("subStream",e);const t=Number(v(e,"width")??"0"),s=Number(v(e,"height")??"0"),i=Number(v(e,"videoEncType")??"0"),A=Number(v(e,"frame")??"0"),l=Number(v(e,"bitRate")??"0"),g=Number(v(e,"audio")??"0"),d=v(e,"enable");(void 0===d||"1"===d||"true"===d)&&o({width:t,height:s,frameRate:A,bitRate:l})&&(r.push({profile:"sub",audio:g,width:t,height:s,videoEncType:c[i]??`Unknown(${i})`,videoEncTypeInt:i,frameRate:A,bitRate:l,audioCodec:"aac"}),n=n&&1===g)}const g=["extStream","thirdStream","externStream","extraStream"];for(const e of g){const t=s.match(new RegExp(`<${e}[^>]*>([\\s\\S]*?)<\\/${e}>`));if(!t)continue;const i=t[1]??"";a(e,i);const A=Number(v(i,"width")??"0"),l=Number(v(i,"height")??"0"),h=Number(v(i,"videoEncType")??"0"),g=Number(v(i,"frame")??"0"),d=Number(v(i,"bitRate")??"0"),u=Number(v(i,"audio")??"0"),E=v(i,"enable");(void 0===E||"1"===E||"true"===E)&&o({width:A,height:l,frameRate:g,bitRate:d})&&(r.push({profile:"ext",audio:u,width:A,height:l,videoEncType:c[h]??`Unknown(${h})`,videoEncTypeInt:h,frameRate:g,bitRate:d,audioCodec:"aac"}),n=n&&1===u);break}return{channel:t,streams:r,audioEnabled:n}}async setEncXml(e,t){const s="number"==typeof e?this.normalizeChannel(e):0,r="number"==typeof e?t:e;await this.sendXml({cmdId:57,channel:s,payloadXml:r})}async setStreamVideoCodec(e,t,s){const r="number"==typeof e?this.normalizeChannel(e):this.normalizeChannel(s),n="number"==typeof e?t:e,i="H.265"===("number"==typeof e?s:t)?1:0,A="main"===n?["mainStream"]:"sub"===n?["subStream"]:["extStream","thirdStream","externStream","extraStream"],o=await this.getEncXml(r);let a=null;for(const e of A){const t=new RegExp(`(<${e}[^>]*>[\\s\\S]*?<videoEncType>)(\\d+)(</videoEncType>)`);if(!t.test(o))continue;const s=o.replace(t,`$1${i}$3`);if(s!==o){a=s;break}}if(!a)throw new Error(`Could not find <videoEncType> for profile=${n} (tags=${A.join(",")}) in GetEnc XML (channel=${r}).`);await this.setEncXml(r,a)}async setNetPort(e){null!=e.onvifEnable&&await this.setPortEnabled({port:"onvif",enable:1===e.onvifEnable}),null!=e.rtmpEnable&&await this.setPortEnabled({port:"rtmp",enable:1===e.rtmpEnable}),null!=e.rtspEnable&&await this.setPortEnabled({port:"rtsp",enable:1===e.rtspEnable})}async reboot(e){const t={cmdId:23};void 0!==e&&(t.channel=e),await this.sendXml(t)}async ping(){await this.sendXml({cmdId:93})}async getGeneralXml(e){const t={cmdId:104};return void 0!==e&&(t.channel=e),await this.sendXml(t)}async setGeneralXml(e,t){const s="number"==typeof e||void 0===e?e:void 0,r="string"==typeof e?e:t;await this.sendXml({cmdId:105,...void 0===s?{}:{channel:s},payloadXml:r})}static buildChannelExtensionXml(e){return`<?xml version="1.0" encoding="UTF-8" ?><Extension version="1.1"><channelId>${S(String(e))}</channelId></Extension>`}async getMotionState(e){const t=v(await this.sendXml({cmdId:46,...void 0!==e?{channel:e}:{}}),"enable");return"1"===t||"true"===t}async getOsd(e){const t=this.normalizeChannel(e),s=await this.sendXml({cmdId:26,channel:t});return{channel:t,osdChannel:{enable:Number(v(s,"enable")??"0"),name:v(s,"name")??"",pos:v(s,"pos")??""},osdTime:{enable:Number(v(s,"timeEnable")??"0"),pos:v(s,"timePos")??""},watermark:Number(v(s,"watermark")??"0")}}async setOsd(e,t){const s="number"==typeof e?this.normalizeChannel(e):this.normalizeChannel(t),r="number"==typeof e?t:e,n=`<?xml version="1.0" encoding="UTF-8" ?><body><Osd version="1.1"><channel>${s}</channel><osdChannel><enable>${r.osdChannel.enable}</enable><name>${S(r.osdChannel.name)}</name><pos>${S(r.osdChannel.pos)}</pos></osdChannel><osdTime><enable>${r.osdTime.enable}</enable><pos>${S(r.osdTime.pos)}</pos></osdTime><watermark>${r.watermark}</watermark></Osd></body>`;await this.sendXml({cmdId:25,channel:s,payloadXml:n})}async getAiState(e){const t=this.normalizeChannel(e),s=["people","vehicle","dog_cat","face","package"];let r;const n=async(e,s)=>{const r=`<?xml version="1.0" encoding="UTF-8" ?><body><AiDetectCfg version="1.1"><chn>${t}</chn><type>${S(e)}</type></AiDetectCfg></body>`;return await this.sendXml({cmdId:342,channel:t,payloadXml:r,...null!=s?{channelIdOverride:s}:{}},0)};for(const e of s)try{const s=await n(e,t);if(s)return{channel:t,alarm_state:Number(v(s,"alarm_state")??"0"),support:Number(v(s,"support")??"0")}}catch(e){r=e}for(const e of s)try{const s=await n(e,void 0);if(s)return{channel:t,alarm_state:Number(v(s,"alarm_state")??"0"),support:Number(v(s,"support")??"0")}}catch(e){r=e}throw r instanceof Error?r:new Error(String(r??"getAiState failed"))}async getSnapshot(e,t){if(t){const e=t.widerChannel??0,s=t.teleChannel??1,r=t.pipPosition??"bottom-right",n=t.pipSize??.25,i=t.pipMargin??10,[A,o]=await Promise.all([this.getSnapshot(e),this.getSnapshot(s)]);try{const e=E(A),t=E(o),s=await e.metadata(),a=await t.metadata(),c=s.width??1920,l=s.height??1080,h=a.width??1920,g=a.height??1080,d=Math.floor(c*n),u=Math.floor(g/h*d),{x:I,y:p}=this.calculateSnapshotOverlayPosition(r,c,l,d,u,i);return await e.composite([{input:await t.resize(d,u).toBuffer(),left:I,top:p}]).jpeg().toBuffer()}catch(e){if(e instanceof Error&&e.message.includes("Cannot find module 'sharp'"))throw new Error("sharp library is required for composite snapshots. Install it with: npm install sharp");throw e}}const s=void 0!==e?this.normalizeChannel(e):0,r=`<body><Snap version="1.1"><channelId>${s}</channelId><logicChannel>${s}</logicChannel><time>0</time><fullFrame>0</fullFrame><streamType>main</streamType></Snap></body>`;return await this.client.login(),await this.client.sendBinary({cmdId:109,channel:s,payloadXml:r,extensionXml:D(s),timeoutMs:15e3})}calculateSnapshotOverlayPosition(e,t,s,r,n,i){const A=Math.floor(r),o=Math.floor(n),a=i;switch(e){case"top-left":default:return{x:a,y:a};case"top-right":return{x:t-A-a,y:a};case"bottom-left":return{x:a,y:s-o-a};case"bottom-right":return{x:t-A-a,y:s-o-a};case"center":return{x:Math.floor((t-A)/2),y:Math.floor((s-o)/2)};case"top-center":return{x:Math.floor((t-A)/2),y:a};case"bottom-center":return{x:Math.floor((t-A)/2),y:s-o-a};case"left-center":return{x:a,y:Math.floor((s-o)/2)};case"right-center":return{x:t-A-a,y:Math.floor((s-o)/2)}}}async listRecordings(e){await this.client.login();const t=this.normalizeChannel(e.channel),s=e.uid,n=e.streamType??"mainStream",i=e.recordType??"manual, sched, io, md, people, face, vehicle, dog_cat, visitor, other, package",A=e.maxIterations??50,o=e.fallbackToAlarmVideo??!0,a=`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<FileInfoList version="1.1">\n<FileInfo>\n<uid>${S(s)}</uid>\n<searchAITrack>1</searchAITrack>\n<channelId>${t}</channelId>\n<logicChnBitmap>255</logicChnBitmap>\n<streamType>${S(n)}</streamType>\n<recordType>${S(i)}</recordType>\n${Re("startTime",e.start)}\n${Re("endTime",e.end)}\n</FileInfo>\n</FileInfoList>\n</body>`,c=v(await this.sendXml({cmdId:r.Xf,channel:t,payloadXml:a}),"handle");if(!c)throw new Error("FileInfoList open did not return <handle>");const l=Number.parseInt(c,10);if(!Number.isFinite(l))throw new Error(`FileInfoList open returned invalid handle: ${c}`);const h=`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<FileInfoList version="1.1">\n<FileInfo>\n<channelId>${t}</channelId>\n<uid>${S(s)}</uid>\n<searchAITrack>1</searchAITrack>\n<handle>${l}</handle>\n</FileInfo>\n</FileInfoList>\n</body>`,g=[];try{let e=!1;for(let s=0;s<A&&!e;s++){const s=await this.sendXml({cmdId:r.rO,channel:t,payloadXml:h});g.push(...Ne(s));const n=v(s,"bFinished")??v(s,"finished");e=null==n||"1"===n.trim()}}finally{try{await this.sendXml({cmdId:r.l$,channel:t,payloadXml:h})}catch{}}const d=new Set,u=g.filter((e=>!d.has(e.fileName)&&(d.add(e.fileName),!0)));if(u.length>0||!o)return u;const E=s.split("_")[0]??s,I="subStream"===n?1:0,p=e=>`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<findAlarmVideo version="1.1">\n<channelId>${t}</channelId>\n<fileHandle>${S(e)}</fileHandle>\n</findAlarmVideo>\n</body>`,C=[];let B=e.start;for(let s=0;s<A;s++){const s=await this.sendXml({cmdId:r.dB,channel:t,payloadXml:(f=B,Q=e.end,`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<findAlarmVideo version="1.1">\n<channelId>${t}</channelId>\n<uid>${S(E)}</uid>\n<logicChnBitmap>255</logicChnBitmap>\n<streamType>${I}</streamType>\n<notSearchVideo>0</notSearchVideo>\n${Re("startTime",f)}\n${Re("endTime",Q)}\n<alarmType>md, pir, io, people, face, vehicle, dog_cat, visitor, other, package, cry, crossline, intrusion, loitering, legacy, loss</alarmType>\n</findAlarmVideo>\n</body>`)}),n=v(s,"fileHandle")?.trim();if(!n)break;const i=p(n);try{const e=await this.sendXml({cmdId:r.TB,channel:t,payloadXml:i}),s=Ne(e);C.push(...s);const n=v(e,"bFinished")?.trim();if("1"===n)break;const A=[...s].reverse().find((e=>null!=e.startTime));if(!A?.startTime)break;B=A.startTime}finally{try{await this.sendXml({cmdId:r.f9,channel:t,payloadXml:i})}catch{}}}var f,Q;const m=new Set;return C.filter((e=>!m.has(e.fileName)&&(m.add(e.fileName),!0)))}async listRecordingFileNames(e){return(await this.listRecordings(e)).map((e=>e.fileName))}async getVodRtmpUrl(e){await this.client.login();const t=this.normalizeChannel(e.channel),s=e.streamType??"mainStream",r=e.ensureEnabled??!0;let n=e.rtmpPort;try{const e=(await this.getNetPort()).rtmp,t="number"==typeof e?.enable?e.enable:void 0,s="number"==typeof e?.port?e.port:void 0;null==n&&null!=s&&Number.isFinite(s)&&s>0&&(n=s),r&&0===t&&await this.setPortEnabled({port:"rtmp",enable:!0})}catch{}null==n&&(n=1935);const i="subStream"===s?1:0;let A=e.fileName.trim();const o=A.indexOf("Mp4Record/");o>=0&&(A=A.slice(o)),A=A.replace(/^\/+/,"");const a=A.replace(/\//g,"%20").replace(/ /g,"%20"),c=encodeURIComponent(this.username),l=encodeURIComponent(this.password);return`rtmp://${this.host}:${n}/vod/${a}?channel=${t}&stream=${i}&user=${c}&password=${l}`}async predownloadRecordingMp4(e){await this.client.login();const t=this.normalizeChannel(e.channel),s=e.streamType??"mainStream",r=e.ensureAwake??!1,n=e.ffmpegPath??"ffmpeg",i=e.overwrite??!0;await(0,u.mkdir)((0,g.dirname)(e.outputPath),{recursive:!0});const A=async()=>{r&&await this.wakeUp(t,{waitAfterWakeMs:1500,attempts:3});const A=await this.getVodRtmpUrl({channel:t,fileName:e.fileName,streamType:s,ensureEnabled:!0});await new Promise(((t,s)=>{const r=(0,l.spawn)(n,["-hide_banner","-loglevel","error",...i?["-y"]:[],"-rtmp_live","live","-i",A,"-c","copy","-movflags","frag_keyframe+empty_moov","-f","mp4",e.outputPath]);let o="";r.stderr.on("data",(e=>{o+=String(e)})),r.on("close",(e=>{if(0===e)return t();s(new Error(`ffmpeg exited with code ${e}\n${o}`))})),r.on("error",s)}))};try{await A()}catch(e){if(r)try{await this.wakeUp(t,{waitAfterWakeMs:3e3,attempts:3,reconnect:!0})}catch{}await A()}}async generateMp4Screenshot(e){const t=e.ffmpegPath??"ffmpeg",s=Number.isFinite(e.atSeconds)&&e.atSeconds>=0?e.atSeconds:0;await(0,u.mkdir)((0,g.dirname)(e.outputPath),{recursive:!0}),await new Promise(((r,n)=>{const i=(0,l.spawn)(t,["-hide_banner","-loglevel","error","-y","-ss",String(s),"-i",e.inputPath,"-frames:v","1","-q:v","2",e.outputPath]);let A="";i.stderr.on("data",(e=>{A+=String(e)})),i.on("close",(e=>{if(0===e)return r();n(new Error(`ffmpeg screenshot exited with code ${e}\n${A}`))})),i.on("error",n)}))}async downloadRecording(e){await this.client.login();const t=this.normalizeChannel(e.channel),s=e.uid,n=e.fileName,i=n.includes("/")?n.split("/").filter(Boolean).at(-1)??n:n,A=`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<FileInfoList version="1.1">\n<FileInfo>\n<channelId>${t}</channelId>\n<uid>${S(s)}</uid>\n<fileName>${S(n)}</fileName>\n<name>${S(i)}</name>\n<Id>${S(n)}</Id>\n</FileInfo>\n</FileInfoList>\n</body>`,o=e.fallbackToHttp??!1;try{return await this.client.sendBinary({cmdId:r.ts,channel:t,messageClass:r.d_,extensionXml:b(t),payloadXml:A,timeoutMs:e.timeoutMs??12e4})}catch(e){if(!o)throw e;const t=n.replaceAll("/","_").replaceAll("\\","_");try{const e=/Rec(\w{3})(?:_|_DST)(\d{8})_(\d{6})_.*/.exec(n),s=e?`${e[2]}${e[3]}`:void 0,r=[],i=e=>{const t=e?.trim();t&&(r.includes(t)||r.push(t))};let A;i(n),i(n.replace(/^\/mnt\/[a-zA-Z0-9]+\//,"")),i(n.replace(/^\//,""));for(const e of r)try{return await this.httpClient.downloadVod(e,t,s)}catch(e){A=e;if((e instanceof Error?e.message:String(e)).startsWith("HTTP 404"))continue;throw e}throw A instanceof Error?A:new Error(String(A))}catch(t){const s=e instanceof Error?e.message:String(e),r=t instanceof Error?t.message:String(t);throw new Error(`downloadRecording failed (baichuan then http). baichuanErr=${s}; httpErr=${r}`)}}}async subscribeEvents(){await this.client.login();const e=this.client.getConfiguredChannel?.()??0,t=[{label:`channelId=${e} bodyLen=0`,params:{cmdId:31,channelIdOverride:e,messageClass:r.Uh}},{label:"push channelId=251 bodyLen=0",params:{cmdId:31,channelIdOverride:251,messageClass:r.Uh}},{label:"host channelId=250 bodyLen=0",params:{cmdId:31,channelIdOverride:250,messageClass:r.Uh}},{label:"legacy Extension channelId=251",params:{cmdId:31,channelIdOverride:250,messageClass:r.Uh,extensionXml:'<?xml version="1.0" encoding="UTF-8" ?><Extension version="1.1"><channelId>251</channelId></Extension>'}}];let s;for(const e of t){const t=await this.client.sendFrame({...e.params,timeoutMs:1e4});if(s=t.header.responseCode,200===t.header.responseCode)return this.client.subscribed=!0,void this.client.refreshKeepAlive?.();(this.logger.debug??this.logger.log).call(this.logger,`[ReolinkBaichuanApi] subscribeEvents rejected (${e.label}) responseCode=${t.header.responseCode}`)}throw this.client.subscribed=!1,this.client.refreshKeepAlive?.(),new Error(`subscribeEvents failed: camera rejected cmdId=31 (last responseCode=${s??"unknown"})`)}async subscribeToAllEvents(e){await this.client.login();const t=e?.preferCgi??!0,s=e?.maxChannels??16,n=e?.timeoutMs??1e4;let i=[];try{const e=await this.getNvrChannelsInfo({source:t?"cgi":"baichuan",maxChannels:s}),r=e.filter((e=>Boolean((e.uid??"").trim())||Boolean((e.name??"").trim())||!0===e.online||!0===e.sleep)).map((e=>e.channel)).filter((e=>Number.isInteger(e)&&e>=0));i=(r.length?r:e.map((e=>e.channel))).filter((e=>Number.isInteger(e)&&e>=0)).slice(0,s)}catch{}if(!i.length){i=[this.client.getConfiguredChannel?.()??0]}i=[...new Set(i)].sort(((e,t)=>e-t));let A,o=0;for(const e of i){const t=await this.client.sendFrame({cmdId:31,channelIdOverride:e,messageClass:r.Uh,timeoutMs:n});A=t.header.responseCode,200===t.header.responseCode?o++:(this.logger.debug??this.logger.log).call(this.logger,`[ReolinkBaichuanApi] subscribeToAllEvents rejected (channel=${e}) responseCode=${t.header.responseCode}`)}if(o>0)return this.client.subscribed=!0,void this.client.refreshKeepAlive?.();try{return void await this.subscribeEvents()}catch{}throw this.client.subscribed=!1,this.client.refreshKeepAlive?.(),new Error(`subscribeToAllEvents failed: camera rejected cmdId=31 for all channels (last responseCode=${A??"unknown"})`)}async unsubscribeEvents(){this.client.subscribed=!1,this.client.refreshKeepAlive?.()}async checkAndDispatchCurrentState(e=0){try{const t=await this.getMotionState(e);if(t!==this.lastMotionState&&(this.lastMotionState=t,t)){const t={type:"motion",channel:e,timestamp:Date.now()};this.dispatchSimpleEvent(t)}if(!this.aiStatePollingDisabled)try{const t=await this.getAiState(e);if(t&&void 0!==t.alarm_state){if((!this.lastAiState||this.lastAiState.alarm_state!==t.alarm_state||this.lastAiState.support!==t.support)&&(this.lastAiState=t,1===t.alarm_state)){const t={type:"other",channel:e,timestamp:Date.now()};this.dispatchSimpleEvent(t)}}}catch(e){this.aiStatePollingDisabled=!0;const t=String(e&&"object"==typeof e&&"message"in e?e.message:e);t.includes("not supported")||t.includes("unsupported")||(this.logger.debug??this.logger.log)?.call(this.logger,"[ReolinkBaichuanApi] getAiState failed; disabling AI polling",e),this.aiStatePollingDisabledLogged||(this.aiStatePollingDisabledLogged=!0,this.logger.debug?.("[ReolinkBaichuanApi] AI polling disabled after getAiState failure",e))}}catch(e){(this.logger.warn??this.logger.error)?.call(this.logger,"[ReolinkBaichuanApi] Error checking current state",e)}}dispatchSimpleEvent(e){for(const t of this.simpleEventListeners)try{t(e)}catch(e){(this.logger.warn??this.logger.error)?.call(this.logger,"[ReolinkBaichuanApi] onSimpleEvent handler error",e)}}startStatePolling(){if(0===this.simpleEventListeners.size)return;"udp"===this.client.getTransport?.()||this.statePollingInterval||(this.statePollingInterval=setInterval((async()=>{try{if(0===this.simpleEventListeners.size)return void this.stopStatePolling();const e=this.client.getConfiguredChannel?.()??0;await this.checkAndDispatchCurrentState(e)}catch(e){this.logger.debug?.("[ReolinkBaichuanApi] state polling tick failed",e)}}),5e3))}stopStatePolling(){this.statePollingInterval&&(clearInterval(this.statePollingInterval),this.statePollingInterval=void 0)}async getEvents(e){const t=await this.sendXml({cmdId:33,...void 0!==e?{channel:e}:{}}),s=this.normalizeChannel(e),r=Date.now(),n={channel:s};if(t.includes("<AlarmEventList")){const e=t.matchAll(/<AlarmEvent\b[^>]*>([\s\S]*?)<\/AlarmEvent>/g);for(const t of e){const e=t[1]??"",i=v(e,"channelId");if((void 0!==i?Number(i):s)!==s)continue;const A=(v(e,"status")??"").trim().toUpperCase(),o=(v(e,"AItype")??v(e,"aiType")??v(e,"aitype")??"").trim();A.includes("MD")&&(n.motion={state:1,timestamp:r,source:"md"}),A.includes("PIR")&&(n.motion={state:1,timestamp:r,source:"pir"});const a=o?o.split(",").map((e=>e.trim())).find((e=>e.length>0&&"none"!==e.toLowerCase())):void 0;(a||A.includes("AI"))&&(n.ai={channel:s,alarm_state:1,type:a}),A.includes("VIS")&&(n.visitor={detected:!0,timestamp:r})}return n}const i=(v(t,"status")??"").trim().toUpperCase(),A=(v(t,"AItype")??v(t,"aiType")??v(t,"aitype")??"").trim();return i.includes("MD")&&(n.motion={state:1,timestamp:r,source:"md"}),i.includes("PIR")&&(n.motion={state:1,timestamp:r,source:"pir"}),(A||i.includes("AI"))&&(n.ai={channel:s,alarm_state:1,type:A||void 0}),i.includes("VIS")&&(n.visitor={detected:!0,timestamp:r}),n}async getTwoWayAudioConfig(e){const t=v(await this.sendXml({cmdId:10,...void 0!==e?{channel:e}:{}}),"audioStreamMode"),s={channel:e??0,enabled:"mixAudioStream"===t||"followVideoStream"===t};return t&&(s.mode=t),s}async startTwoWayAudio(e){await this.sendXml({cmdId:10,...void 0!==e?{channel:e}:{}})}async sendAudioData(e,t){const s={cmdId:10,payloadXml:""};void 0!==t&&(s.channel=t),await this.client.sendBinary(s)}async stopTwoWayAudio(e){}async startVideoStream(e,t="sub"){const s=this.normalizeChannel(e),n=s,i={main:{handle:0,streamType:0,streamName:"mainStream"},sub:{handle:256,streamType:1,streamName:"subStream"},ext:{handle:1024,streamType:0,streamName:"externStream"}}[t];if(!i)throw new Error(`Invalid stream profile: ${t}`);if(!i.streamName)throw new Error(`Stream name not found for profile: ${t}, config: ${JSON.stringify(i)}`);const A=i.streamName;if("string"!=typeof A)throw new Error(`streamName is not a string: ${typeof A}, value: ${A}, config: ${JSON.stringify(i)}`);const o=function(e,t,s){if(!t||"string"!=typeof t)throw new Error(`buildPreviewXml: streamType is required (string) but got: ${typeof t} = ${t}`);return`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<Preview version="1.0">\n${void 0!==s?`<channelId>${s}</channelId>\n`:""}<handle>${e}</handle>\n<streamType>${S(t)}</streamType>\n</Preview>\n</body>`}(i.handle,A,n),a="udp"===this.client.getTransport?.()?3:1;let c;for(let e=1;e<=a;e++){const A=this.client.peekNextMsgNum();this.client.subscribeVideoStream(r.zw,A);try{const e={cmdId:r.zw,channel:s,channelIdOverride:n,extensionXml:D(n),payloadXml:o,messageClass:r.Uh,streamType:i.streamType},A=await this.client.sendFrame(e);if(200!==A.header.responseCode)throw new Error(`Video stream request rejected (response_code ${A.header.responseCode}). Expected response_code 200, camera returned ${A.header.responseCode}`);return void this.activeVideoMsgNums.set(`${s}:${t}`,A.header.msgNum)}catch(t){c=t;try{this.client.unsubscribeVideoStream(r.zw,A)}catch{}if(e<a){await new Promise((e=>setTimeout(e,250)));continue}}}throw c instanceof Error?c:new Error(String(c))}getActiveVideoMsgNum(e,t="sub"){const s=this.normalizeChannel(e);return this.activeVideoMsgNums.get(`${s}:${t}`)}async stopVideoStream(e,t="sub"){const s=this.normalizeChannel(e),n=s,i={main:{handle:0,streamType:0},sub:{handle:256,streamType:1},ext:{handle:1024,streamType:0}}[t],A=function(e,t){return`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<Preview version="1.0">\n${void 0!==t?`<channelId>${t}</channelId>\n`:""}<handle>${e}</handle>\n</Preview>\n</body>`}(i.handle,n),o=`${s}:${t}`,a=this.activeVideoMsgNums.get(o);this.activeVideoMsgNums.delete(o);try{await this.client.sendFrame({cmdId:r.Ck,channel:s,channelIdOverride:n,extensionXml:D(n),payloadXml:A,messageClass:r.Uh,streamType:i.streamType,...void 0!==a?{msgNumOverride:a}:{},timeoutMs:2e3})}catch{}finally{try{void 0!==a&&this.client.unsubscribeVideoStream(r.zw,a)}catch{}}}async getPtzPresets(e){const t=this.normalizeChannel(e),s=t,n=await this.sendXml({cmdId:r.XN,channel:t,channelIdOverride:s,extensionXml:D(s),messageClass:r.Uh,streamType:0});return this.parsePtzPresetList(n).filter((e=>void 0===e.enable||"1"===e.enable)).filter((e=>void 0===e.name||""!==String(e.name).trim())).map((e=>({id:e.id,name:e.name??`Preset ${e.id}`})))}parsePtzPresetList(e){const t=[],s=e.matchAll(/<preset\b[^>]*>([\s\S]*?)<\/preset>/gi);for(const e of s){const s=e[1]??"",r=/<id>([^<]*)<\/id>/i.exec(s)?.[1];if(!r)continue;const n=Number(r);if(!Number.isFinite(n))continue;const i=/<name>([^<]*)<\/name>/i.exec(s),A=/<enable>([^<]*)<\/enable>/i.exec(s),o={id:n},a=i?.[1],c=A?.[1];void 0!==a&&(o.name=a),void 0!==c&&(o.enable=c),t.push(o)}return t}async getPtzPresetsRaw(e){const t=this.normalizeChannel(e),s=t,n=await this.sendXml({cmdId:r.XN,channel:t,channelIdOverride:s,extensionXml:D(s),messageClass:r.Uh,streamType:0});return this.parsePtzPresetList(n)}async ptz(e,t){const s="number"==typeof e?this.normalizeChannel(e):0,n="number"==typeof e?t:e,i=s;let A,o;if("stop"===n.action)A="stop";else{const e={Left:"left",Right:"right",Up:"up",Down:"down"}[n.command];if(!e)throw new Error(`Unsupported PTZ command for MSG_ID_PTZ_CONTROL: ${n.command}`);A=e}if("stop"===A)o=0;else{const e=n.speed;o=void 0===e?32:e>0&&e<=1?Math.max(1,64*e):e}const a=function(e,t,s){return`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<PtzControl version="1.1">\n<channelId>${e}</channelId>\n<command>${S(t)}</command>\n<speed>${s}</speed>\n</PtzControl>\n</body>`}(i,A,o),c=D(i),l=await this.client.sendFrame({cmdId:r.iI,channel:s,channelIdOverride:i,extensionXml:c,payloadXml:a,messageClass:r.Uh,streamType:0});if(200!==l.header.responseCode){let e="";if(l.body.length>0)try{const t=this.client.tryDecryptXml;if(t){const s=t.call(this.client,l.body,l.header.channelId,this.client.enc);s&&(e=` - Error details: ${s.substring(0,200)}`)}}catch{}throw new Error(`PTZ control rejected (response_code ${l.header.responseCode})${e}`)}if("start"===n.action&&"stop"!==A){const e=n.autoStopMs??500;e>0&&setTimeout((()=>{this.ptz(s,{action:"stop",command:n.command}).catch((()=>{}))}),e)}}async moveToPtzPreset(e,t){const s=void 0===t?this.normalizeChannel(void 0):this.normalizeChannel(e),n=s,i=function(e,t,s,r){return R(e,t,s,void 0===r?void 0:{name:r})}(n,void 0===t?e:t,"toPos"),A=D(n),o=await this.client.sendFrame({cmdId:r.qD,channel:s,channelIdOverride:n,extensionXml:A,payloadXml:i,messageClass:r.Uh,streamType:0});if(200!==o.header.responseCode)throw new Error(`PTZ preset move rejected (response_code ${o.header.responseCode})`)}async setPtzPreset(e,t,s){const n="string"==typeof t?this.normalizeChannel(s):this.normalizeChannel(e),i=n,A=R(i,"string"==typeof t?e:t,"setPos",{name:"string"==typeof t?t:s,enable:1}),o=D(i),a=await this.client.sendFrame({cmdId:r.qD,channel:n,channelIdOverride:i,extensionXml:o,payloadXml:A,messageClass:r.Uh,streamType:0});if(200!==a.header.responseCode)throw new Error(`PTZ preset save rejected (response_code ${a.header.responseCode})`)}async deletePtzPreset(e,t){const s=void 0===t?this.normalizeChannel(void 0):this.normalizeChannel(e),n=void 0===t?e:t,i=s,A=D(i);let o;try{const e=await this.getPtzPresetsRaw(s);o=e.find((e=>e.id===n))?.name}catch{}const a=[{label:"command=delPos",payloadXml:R(i,n,"delPos")},{label:"enable=0 (no name)",payloadXml:R(i,n,"setPos",{enable:0})},{label:"name='' (no enable)",payloadXml:R(i,n,"setPos",{name:""})},{label:"enable=0 name=''",payloadXml:R(i,n,"setPos",{name:"",enable:0})},...o?[{label:"enable=0 name=current",payloadXml:R(i,n,"setPos",{name:o,enable:0})}]:[],{label:"enable=0 name='Preset N'",payloadXml:R(i,n,"setPos",{name:`Preset ${n}`,enable:0})}];let c,l=!1;for(const e of a)try{const t=await this.client.sendFrame({cmdId:r.qD,channel:s,channelIdOverride:i,extensionXml:A,payloadXml:e.payloadXml,messageClass:r.Uh,streamType:0});if(200!==t.header.responseCode)throw new Error(`PTZ preset delete rejected (response_code ${t.header.responseCode})`);l=!0;try{const e=(await this.getPtzPresetsRaw(s)).find((e=>e.id===n));if(!e)return;const t=void 0!==e.name&&""===String(e.name).trim(),r=void 0!==e.enable&&"0"===String(e.enable).trim();if(t||r)return}catch(e){c=e}}catch(e){c=e}if(!l)throw c instanceof Error?c:new Error("PTZ preset delete failed");this.logger.warn("PTZ presets (baichuan): deletePtzPreset did not take effect (firmware ignored request)",{channel:s,channelId:i,presetId:n})}async getPtzPosition(e){const t=this.normalizeChannel(e),s=await this.sendXml({cmdId:r.T$,channel:t}),n=v(s,"pPos"),i=v(s,"tPos"),A={};return void 0!==n&&(A.pan=Number(n)),void 0!==i&&(A.tilt=Number(i)),A}async getZoomFocus(e){const t=this.normalizeChannel(e),s=t,n=await this.sendXml({cmdId:r.$v,channel:t,channelIdOverride:s,extensionXml:D(s),messageClass:r.Uh,streamType:0}),i=e=>{const t=new RegExp(`<${e}>([\\s\\S]*?)</${e}>`).exec(n),s=t?.[1];if(!s)return;const r=v(s,"maxPos"),i=v(s,"minPos"),A=v(s,"curPos");return void 0!==r&&void 0!==i&&void 0!==A?{maxPos:Number(r),minPos:Number(i),curPos:Number(A)}:void 0},A={},o=i("zoom"),a=i("focus");return o&&(A.zoom=o),a&&(A.focus=a),A}async zoomToFactor(e,t){const s=void 0===t?0:this.normalizeChannel(e),n=void 0===t?e:t,i=s,A=(await this.getZoomFocus(s)).zoom;if(!A)throw new Error("Camera did not return <zoom> info (zoom may be unsupported)");const o=Math.round(1e3*n),a=function(e,t){return`<?xml version="1.0" encoding="UTF-8" ?>\n<body>\n<StartZoomFocus version="1.1">\n<channelId>${e}</channelId>\n<command>zoomPos</command>\n<movePos>${Math.trunc(t)}</movePos>\n</StartZoomFocus>\n</body>`}(i,Math.min(A.maxPos,Math.max(A.minPos,o))),c=D(i),l=await this.client.sendFrame({cmdId:r.vF,channel:s,channelIdOverride:i,extensionXml:c,payloadXml:a,messageClass:r.Uh,streamType:0});if(200!==l.header.responseCode)throw new Error(`Zoom rejected (response_code ${l.header.responseCode})`)}parseBatteryInfoXml(e,t){const s=e=>{if(void 0===e)return;const t=Number(e);return Number.isFinite(t)?t:void 0},r=be(e,"BatteryInfo"),n=r.find((e=>v(e,"channelId")===String(t)))??r[0]??e,i={},A=s(v(n,"batteryPercent"));void 0!==A&&(i.batteryPercent=A);const o=v(n,"chargeStatus");void 0!==o&&(i.chargeStatus=o);const a=v(n,"adapterStatus");void 0!==a&&(i.adapterStatus=a);const c=s(v(n,"voltage"));void 0!==c&&(i.voltage=c);const l=s(v(n,"current"));void 0!==l&&(i.current=l);const h=s(v(n,"temperature"));void 0!==h&&(i.temperature=h);const g=s(v(n,"lowPower"));void 0!==g&&(i.lowPower=g);const d=s(v(n,"batteryVersion"));return void 0!==d&&(i.batteryVersion=d),i}getSleepStatus(e){const t=e?.windowMs??e?.idleMs??1e4,s=new Set(e?.nonWakingCmdIds??e?.ignoreCmdIds??[r.F3,r.gB,r.pT,r.m8]),n=this.client.getTransport?.();if("udp"!==n)return{state:"unknown",reason:"sleep inference supported only for UDP/battery"};if(this.activeVideoMsgNums.size>0||this.rtspServers.size>0||this.client.isDeviceStreamingActive?.())return{state:"awake",reason:"active streaming"};const i=this.client.isSocketConnected?.()??!1,A=Date.now(),o=A-t,a=(this.client.getRxHistory?.()??[]).filter((e=>e.atMs>=o)),c=(this.client.getTxHistory?.()??[]).filter((e=>e.atMs>=o));if(0===a.length&&0===c.length)return{state:"sleeping",reason:`no rx/tx activity in last ${t}ms${i?"":" (socket disconnected)"}`,idleMs:t};const l=a.find((e=>!s.has(e.cmdId)));if(l)return{state:"awake",reason:`waking rx cmdId=${l.cmdId} responseCode=${l.responseCode} seen ${A-l.atMs}ms ago`,lastRxAtMs:l.atMs,idleMs:A-l.atMs};const h=c.find((e=>!s.has(e.cmdId)));return h?{state:"awake",reason:`waking tx cmdId=${h.cmdId} seen ${A-h.atMs}ms ago`,idleMs:A-h.atMs}:{state:"sleeping",reason:`only non-waking cmdIds observed in last ${t}ms (non-waking: ${Array.from(s).join(",")})`,idleMs:t}}async probeSleepStatus(e){const t=this.client.getTransport?.();if("udp"!==t)return{state:"unknown",reason:"sleep probe supported only for UDP/battery"};if(this.activeVideoMsgNums.size>0||this.rtspServers.size>0||this.client.isDeviceStreamingActive?.())return{state:"awake",reason:"active streaming"};const s=Date.now(),n=e?.minIntervalMs??5e3;if(this.lastSleepProbe&&s-this.lastSleepProbe.atMs<n)return{...this.lastSleepProbe.status,reason:`${this.lastSleepProbe.status.reason} (cached)`};if(!this.client.isSocketConnected()){const e={state:"unknown",reason:"udp socket not connected"};return this.lastSleepProbe={atMs:s,status:e},e}if(!this.client.loggedIn){const e={state:"unknown",reason:"not logged in"};return this.lastSleepProbe={atMs:s,status:e},e}const i=this.normalizeChannel(e?.channel),A=e?.timeoutMs??700,o=Math.max(1,e?.attempts??1),a=e?.cmdId??r.pT;for(let e=0;e<o;e++)try{const e=await this.client.sendFrame({cmdId:a,channel:i,timeoutMs:A}),t={state:200===e.header.responseCode?"awake":"unknown",reason:`probe cmdId=${a} responseCode=${e.header.responseCode}`};return this.lastSleepProbe={atMs:Date.now(),status:t},t}catch(t){const s=t instanceof Error?t.message:String(t);if(s.includes("Baichuan timeout")||s.toLowerCase().includes("timeout")){const e={state:"sleeping",reason:`probe timeout cmdId=${a} timeoutMs=${A}`};return this.lastSleepProbe={atMs:Date.now(),status:e},e}if(e===o-1){const e={state:"unknown",reason:`probe error cmdId=${a}: ${s}`};return this.lastSleepProbe={atMs:Date.now(),status:e},e}}const c={state:"unknown",reason:"probe exhausted"};return this.lastSleepProbe={atMs:Date.now(),status:c},c}async getBatteryStatus(e){const t=this.normalizeChannel(e);if("sleeping"===this.getSleepStatus({channel:t}).state)return{channel:t,sleeping:!0};try{const e=await Promise.race([this.sendXml({cmdId:r.pT,channel:t}),new Promise(((e,t)=>setTimeout((()=>t(new Error("Timeout"))),5e3)))]),s={channel:t,sleeping:!1};return Object.assign(s,this.parseBatteryInfoXml(e,t)),s}catch(e){const s={channel:t};return"sleeping"===this.getSleepStatus({channel:t}).state&&(s.sleeping=!0),e instanceof Error&&"Timeout"===e.message&&null==s.sleeping&&(s.sleeping=!0),s}}async getBatteryInfo(e){const t=this.normalizeChannel(e),s=this.client.getTransport?.();if(!("udp"!==s||this.client.isSocketConnected?.()&&this.client.loggedIn))return{channel:t,sleeping:!0};const n=await this.client.sendXml({cmdId:r.pT,channel:t}),i={channel:t};return Object.assign(i,this.parseBatteryInfoXml(n,t)),i}async wakeUp(e,t){const s=this.normalizeChannel(e),r="number"==typeof t?{waitAfterWakeMs:t}:t??{},n=r.timeoutMs??2e4,i=r.attempts??3,A=r.waitAfterWakeMs??1500,o=r.backoffMs??1500,a="udp"===this.client.getTransport?.(),c=r.reconnect??a;let l;for(let e=1;e<=i;e++)try{return await this.getEncXml(s,{timeoutMs:n}),void(A>0&&await new Promise((e=>setTimeout(e,A))))}catch(t){l=t;const s=t instanceof Error?t.message:String(t),r=s.includes("Baichuan timeout"),n=s.toLowerCase().includes("socket closed")||s.toLowerCase().includes("stream closed");if(e<i){if(c&&(r||n))try{this.client.loggedIn=!1,await this.client.close()}catch{}o>0&&await new Promise((e=>setTimeout(e,o)));continue}}throw l instanceof Error?l:new Error(String(l))}async isSleeping(e){const t=this.normalizeChannel(e);try{return await Promise.race([this.getBatteryInfo(t),new Promise(((e,t)=>setTimeout((()=>t(new Error("Timeout"))),5e3)))]),!1}catch(e){return!0}}async getPirInfo(e){const t=this.normalizeChannel(e),s=await this.sendXml({cmdId:r.H9,channel:t}),n=e=>{if(void 0===e)return;const t=e.trim().toLowerCase();if("true"===t)return 1;if("false"===t)return 0;const s=Number(t);return Number.isFinite(s)?s:void 0},i=v(s,"enable"),A=v(s,"sensiValue"),o=v(s,"reduceFalseAlarm"),a=v(s,"interval"),c=v(s,"intervalSecMax"),l={channel:t};if(void 0!==i){const e=n(i);void 0!==e&&(l.enable=e)}if(void 0!==A&&(l.sensitive=Number(A)),void 0!==o){const e=n(o);void 0!==e&&(l.reduceAlarm=e)}if(void 0!==a){const e=n(a);void 0!==e&&(l.interval=e)}if(void 0!==c){const e=n(c);void 0!==e&&(l.intervalMax=e)}return{enabled:(e=>{if(void 0===e)return!1;const t=e.trim().toLowerCase();return"1"===t||"true"===t})(i),state:l}}async setPirInfo(e,t){const s="number"==typeof e?e:t,n="number"==typeof e?t:e,i=this.normalizeChannel(s);let A=await this.sendXml({cmdId:r.H9,channel:i});if(void 0!==n.enable&&(A=A.replace(/<enable>[^<]*<\/enable>/,`<enable>${n.enable}</enable>`)),void 0!==n.sensitive){const e=(o=n.sensitive,Math.trunc(101-o));A=A.replace(/<sensiValue>[^<]*<\/sensiValue>/,`<sensiValue>${e}</sensiValue>`)}var o;if(void 0!==n.reduceAlarm){const e=(e=>{if(null==e)return;if("boolean"==typeof e)return e?1:0;const t=Number(e);return Number.isFinite(t)?t:void 0})(n.reduceAlarm);void 0!==e&&(A=A.replace(/<reduceFalseAlarm>[^<]*<\/reduceFalseAlarm>/,`<reduceFalseAlarm>${e}</reduceFalseAlarm>`))}void 0!==n.interval&&(A=A.replace(/<interval>[^<]*<\/interval>/,`<interval>${n.interval}</interval>`)),await this.sendXml({cmdId:r.rJ,channel:i,payloadXml:A})}async setMotionDetection(e,t,s){const n="number"==typeof e?e:s,i="number"==typeof e?t:e,A="number"==typeof e?s:t,o=this.normalizeChannel(n);let a=await this.sendXml({cmdId:46,channel:o});void 0!==i&&(a=a.replace(/<enable>[^<]*<\/enable>/,`<enable>${i?"1":"0"}</enable>`)),void 0!==A&&(a=a.replace(/<sensitivityDefault>[^<]*<\/sensitivityDefault>/,`<sensitivityDefault>${A}</sensitivityDefault>`)),await this.sendXml({cmdId:r.zt,channel:o,payloadXml:a})}async setAiDetection(e,t,s,n){const i="number"==typeof e?e:n,A="number"==typeof e?t:e,o="number"==typeof e?s:t,a="number"==typeof e?n:s,c=this.normalizeChannel(i),l=`<?xml version="1.0" encoding="UTF-8" ?>\n <body>\n <AiDetectCfg version="1.1">\n <chn>${c}</chn>\n <type>${S(A)}</type>\n </AiDetectCfg>\n </body>`;let h=await this.sendXml({cmdId:342,channel:c,payloadXml:l});void 0!==o&&(h=h.replace(/<sensitivity>[^<]*<\/sensitivity>/,`<sensitivity>${o}</sensitivity>`)),void 0!==a&&(h=h.replace(/<stayTime>[^<]*<\/stayTime>/,`<stayTime>${a}</stayTime>`)),await this.sendXml({cmdId:r.fP,channel:c,payloadXml:h})}async getSiren(e){try{const t=await this.sendXml({cmdId:r.pH,...void 0!==e?{channel:e}:{}});return{enabled:"1"===v(t,"status")}}catch{return{enabled:!1}}}async setSiren(e,t,s){const n="boolean"==typeof e?s??0:e,i="boolean"==typeof e?e:t,A="boolean"==typeof e?t:s,o=void 0!==n?n+1:void 0;let a;if(void 0!==A)a=k(o,A);else{a=N(o,i?1:0)}try{await this.sendXml({cmdId:r.zu,...void 0!==n?{channel:n}:{},payloadXml:a})}catch(e){if(!0!==i||void 0!==A)throw e;a=k(o,2),await this.sendXml({cmdId:r.zu,...void 0!==n?{channel:n}:{},payloadXml:a})}}async getWhiteLedState(e){const t=this.normalizeChannel(e),s=await this.sendXml({cmdId:r.as,channel:t}),n=v(s,"enable"),i=v(s,"state"),A=v(s,"status"),o=v(s,"brightness_cur"),a={enabled:"1"===n||"1"===i||"1"===A};return void 0!==o&&(a.brightness=Number(o)),a}async setWhiteLedState(e,t,s){const n="number"==typeof e?e:s??0,i="number"==typeof e?t:e,A="number"==typeof e?s:t,o=this.normalizeChannel(n);if(void 0!==i)try{const e=T(o,i?1:0,i?180:0);await this.sendXml({cmdId:r.AG,channel:o,payloadXml:e})}catch(e){let t=await this.sendXml({cmdId:r.as,channel:o});/<enable>[^<]*<\/enable>/i.test(t)&&(t=t.replace(/<enable>[^<]*<\/enable>/i,`<enable>${i?1:0}</enable>`)),/<state>[^<]*<\/state>/i.test(t)&&(t=t.replace(/<state>[^<]*<\/state>/i,`<state>${i?1:0}</state>`)),/<status>[^<]*<\/status>/i.test(t)&&(t=t.replace(/<status>[^<]*<\/status>/i,`<status>${i?1:0}</status>`)),await this.sendXml({cmdId:r.YF,channel:o,payloadXml:t})}if(void 0!==A){let e=await this.sendXml({cmdId:r.as,channel:o});/<brightness_cur>[^<]*<\/brightness_cur>/i.test(e)&&(e=e.replace(/<brightness_cur>[^<]*<\/brightness_cur>/i,`<brightness_cur>${A}</brightness_cur>`)),/<enable>[^<]*<\/enable>/i.test(e)&&(e=e.replace(/<enable>[^<]*<\/enable>/i,"<enable>1</enable>")),await this.sendXml({cmdId:r.YF,channel:o,payloadXml:e})}}async getAbilityInfo(){const e=this.client.username,t=`<?xml version="1.0" encoding="UTF-8" ?>\n<Extension version="1.1">\n<userName>${S(e)}</userName>\n<token>system, streaming, PTZ, IO, security, replay, disk, network, alarm, record, video, image</token>\n</Extension>`;const s=await this.sendXml({cmdId:r.fg,extensionXml:t}),n={},i=["system","streaming","PTZ","IO","security","replay","disk","network","alarm","record","video","image"];for(const e of i){const t=new RegExp(`<${e}[^>]*>([\\s\\S]*?)<\\/${e}>`,"i"),r=s.match(t);if(r){const e=(r[1]??"").matchAll(/<subModule[^>]*>([\s\S]*?)<\/subModule>/g);for(const t of e){const e=t[1]??"",s=v(e,"channelId")||v(e,"chnID"),r=v(e,"abilityValue");if(r){const e=s?Number(s):"Host";n[e]||(n[e]={});const t=r.split(",").map((e=>e.trim())).filter(Boolean);for(const s of t)n[e][s]=1}}}}const A=s.match(/<AbilityInfo[^>]*>([\s\S]*?)<\/AbilityInfo>/);if(A){const e=(A[1]??"").matchAll(/<([A-Za-z]+)[^>]*>([^<]*)<\/\1>/g);n.Host||(n.Host={});for(const t of e){const e=t[1],s=t[2];if(e&&void 0!==s&&!["image","video","subModule"].includes(e)&&"channelId"!==e&&"abilityValue"!==e){const t=Number(s);n.Host[e]=Number.isNaN(t)?s:t}}}return n.Host&&0===Object.keys(n.Host).length&&delete n.Host,n}async getAbilityVersion(e,t){const s=(await this.getAbilityInfo())[null!=t?t:"Host"];if(!s)return 0;const r=s[e];if("number"==typeof r)return r;if("string"==typeof r){const e=Number(r);return Number.isNaN(e)?0:e}return 0}async getSupportInfo(){return me(await this.sendXml({cmdId:r.fk}))}async getDeviceCapabilities(e,t){const s=null!=e,n=this.normalizeChannel(e),i=t?.probe??!0,A=t?.probeSiren??!0,o=t?.probeFloodlight??!0,[a,c]=await Promise.allSettled([this.getAbilityInfo(),this.getSupportInfo()]),l="fulfilled"===a.status?a.value:void 0,h="fulfilled"===c.status?c.value:void 0,g=l?s?{..."object"==typeof l.Host?{Host:l.Host}:{},..."object"==typeof l[n]?{[n]:l[n]}:{}}:l:void 0,d=h?s?{...h,items:(h.items??[]).filter((e=>e.chnID===n))}:h:void 0,u={channel:n};g&&(u.abilities=g),d&&(u.support=d);const E=ye(u),I=fe(g,n),p=e=>{if("number"==typeof e)return e>0;if("string"==typeof e){const t=Number(e);return Number.isFinite(t)?t>0:e.length>0&&"0"!==e}return Boolean(e)},C=d?{rtsp:p(d.rtsp),onvif:p(d.onvif),wifi:p(d.wifi),record:p(d.record),ftp:p(d.ftp),email:p(d.email),pushAlarm:p(d.pushAlarm),audioTalk:p(d.audioTalk)}:void 0;if(i&&A&&!E.hasSiren){const e=async()=>{try{return await this.sendXml({cmdId:r.pH,channel:n,timeoutMs:1e3}),!0}catch{return!1}},t=async()=>{try{const e=N(n+1,0);return await this.sendXml({cmdId:r.zu,channel:n,payloadXml:e,timeoutMs:1e3}),!0}catch{return!1}};(await e()||await t())&&(E.hasSiren=!0)}if(i&&o&&!E.hasFloodlight){const e=(d?.items??[]).filter((e=>e.chnID===n||e.chnID===n+1)),t=e=>{const t=e?.lightType;if("number"==typeof t)return t;if("string"==typeof t){const e=Number(t);return Number.isFinite(e)?e:void 0}},s=e.map((e=>t(e))).filter((e=>Number.isFinite(e)));if(s.some((e=>0===e)));else if(s.some((e=>e>0)))E.hasFloodlight=!0;else try{const e=await this.sendXml({cmdId:r.as,channel:n,timeoutMs:1e3});/(<FloodlightTask\b|<FloodlightManual\b|<FloodlightStatusList\b|<WhiteLed\b)/i.test(e)&&(E.hasFloodlight=!0)}catch{}}let B,f;try{const e=(v(await this.sendXml({cmdId:299,channel:n,timeoutMs:1500}),"detectType")??"").trim();if(e){const t=e.split(",").map((e=>e.trim())).filter(Boolean);t.length>0&&(B=t)}}catch{}if(E.hasPresets){const e=(await Promise.allSettled([this.getPtzPresets(n)]))[0];"fulfilled"===e?.status&&(f=e.value,E.hasPresets=f.length>0)}const Q={channel:n,channelId1Based:n+1,transport:this.client.getTransport(),encryptionKind:this.client.enc.kind,loggedIn:this.client.loggedIn,subscribed:this.client.subscribed,abilitiesAvailable:Boolean(g),supportAvailable:Boolean(d)};I&&(Q.abilityMergedKeyCount=Object.keys(I).length),d?.items&&(Q.supportItemCount=d.items.length);const m={capabilities:E,debug:Q};return g&&(m.abilities=g),d&&(m.support=d),f&&(m.presets=f),B&&(m.objects=B),C&&(m.features=C),m}async getDualLensChannelInfo(){let e,t,s;try{const t=await this.getInfo(0,{tags:["type"]});e=t.type?.trim()}catch{}try{const e=await this.getDeviceCapabilities(0);t=e.support?.channelNum,s=e.support}catch{}let r=e?e.trim():void 0;if(!r&&s)for(const e of s.items??[])if(e.typeInfo){r=String(e.typeInfo).trim();break}r?.toLowerCase().trim();const n=(e,t)=>{if(!t||0===t.length)return!1;const s=t.toLowerCase().trim();for(const t of e){const e=t.toLowerCase().trim();if(s===e)return!0;if(s.includes(e)||e.includes(s))return!0;if(s.includes("trackmix")&&e.includes("trackmix"))return!0;if(s.includes("duo")&&e.includes("duo"))return!0}return!1},i=!!r&&n(Te,r),A=!!r&&n(Fe,r),o="string"==typeof t?Number.parseInt(t,10):t,a=(2===o||3===o)&&Number.isFinite(o);if(!(i||A||a))return{isDualLens:!1,model:r,streamChannelCount:t,logicalChannelCount:t,channels:[],capabilityChannels:{pan:[],tilt:[],zoom:[],motion:[],intercom:[],presets:[]}};let c=i?"dual_motion":A?"single_motion":void 0;if(!c&&a){const e=r?.toLowerCase()??"";e.includes("trackmix")?c="single_motion":e.includes("duo")?c="dual_motion":2===o&&(c="single_motion")}const l=[],h=[];if("single_motion"===c)l.push(0,1),h.push(0);else if("dual_motion"===c)2===o?(l.push(0,1),h.push(0,1)):(l.push(0),h.push(0));else if(o&&Number.isFinite(o)&&o>=2)for(let e=0;e<o;e++)l.push(e),h.push(e);else l.push(0,1),h.push(0);const g=[];for(const e of l)try{const t=await this.getDeviceCapabilities(e),s=t.capabilities,r=t.support,n=t.features;let i=!1;i="single_motion"===c?0===e:"dual_motion"===c?h.includes(e):0===e;const A={rtsp:!1,rtmp:!1,native:!0};if(n?.rtsp||r?.rtsp)A.rtsp=!0;else try{r&&"number"==typeof r.rtsp&&r.rtsp>0&&(A.rtsp=!0)}catch{}let o;r&&"number"==typeof r.rtmp&&r.rtmp>0&&(A.rtmp=!0),0===e?o="wide":1===e&&(o="telephoto");let a=s.hasZoom??!1;"single_motion"===c&&1===e&&"telephoto"===o&&(a=!0),g.push({channel:e,hasPan:s.hasPan??!1,hasTilt:s.hasTilt??!1,hasZoom:a,hasMotion:i,hasIntercom:s.hasIntercom??!1,hasPresets:s.hasPresets??!1,lensType:o,availableStreams:A})}catch(t){(this.logger.warn??this.logger.log).call(this.logger,`[ReolinkBaichuanApi] getDualLensChannelInfo: error in channel ${e}: ${t}`)}const d={pan:g.filter((e=>e.hasPan)).map((e=>e.channel)),tilt:g.filter((e=>e.hasTilt)).map((e=>e.channel)),zoom:g.filter((e=>e.hasZoom)).map((e=>e.channel)),motion:g.filter((e=>e.hasMotion)).map((e=>e.channel)),intercom:g.filter((e=>e.hasIntercom)).map((e=>e.channel)),presets:g.filter((e=>e.hasPresets)).map((e=>e.channel))};return{isDualLens:!0,dualLensType:c,model:r,streamChannelCount:l.length,logicalChannelCount:h.length,channels:g,capabilityChannels:d}}async createRtspStream(e,t,s){const r="number"==typeof e?this.normalizeChannel(e):0,n="number"==typeof e?t:e,i="number"==typeof e?s:t;let A;try{const e=await this.getStreamMetadata(r);if(Array.isArray(e)){const t=e.find((e=>e.profile===n));t?.videoEncType&&(A=t.videoEncType)}else if(e&&"object"==typeof e&&"streams"in e){const t=e.streams;if(Array.isArray(t)){const e=t.find((e=>e?.profile===n));e?.videoEncType&&(A=e.videoEncType)}}}catch(e){this.logger.warn(`[ReolinkBaichuanApi] Could not fetch stream metadata, will auto-detect codec: ${e instanceof Error?e.message:e}`)}const o={api:this,channel:r,profile:n,...void 0!==i?.listenHost?{listenHost:i.listenHost}:{},...void 0!==i?.listenPort?{listenPort:i.listenPort}:{},...void 0!==i?.path?{path:i.path}:{},logger:this.logger},a=new ce(o);return await a.start(),this.rtspServers.add(a),a.once("close",(()=>{this.rtspServers.delete(a)})),a}async buildVideoStreamOptions(e,t){const s=t?.includeAuth,r=[],n=[],i=[];if(void 0===e){const e=await this.getStreamMetadata(0),t=e?.streams||[];for(const e of t){const t=e.profile,s=new URL(`baichuan://${this.host}/composite/profile/${t}`),r=new URL(`baichuan://${this.host}/composite/profile/${t}`);r.username=this.username,r.password=this.password,i.push({name:`Composite ${t}`,id:`composite_${t}`,container:"rtp",profile:t,url:s.toString(),urlWithAuth:r.toString(),metadata:e})}return{nativeStreams:i,rtmpStreams:n,rtspStreams:r}}const A=this.normalizeChannel(e),o=await this.getNetPort(),a=1===o.rtsp?.enable,c=1===o.rtmp?.enable,l=o.rtsp?.port??554,h=o.rtmp?.port??1935,g=await this.getStreamMetadata(A),d=g?.streams||[];for(const e of d){const t=e.profile;if(a&&"ext"!==t){const s=String(A+1).padStart(2,"0"),n="main"===t?"main":"sub",i=`/h264Preview_${s}_${n}`,o=`h264Preview_${s}_${n}`,a=new URL(`rtsp://${this.host}:${l}${i}`),c=new URL(`rtsp://${this.host}:${l}${i}`);c.username=this.username,c.password=this.password,r.push({name:`RTSP ${o}`,id:o,container:"rtsp",channel:A,profile:t,url:a.toString(),urlWithAuth:c.toString(),path:i,port:l,metadata:e})}if(c){const r="main"===t?"main":"sub"===t?"sub":"ext",i="sub"===t?1:0,o=`${r}.bcs`,a=`/bcs/channel${A}_${r}.bcs`,c=new URL(`rtmp://${this.host}:${h}${a}`),l=c.searchParams;l.set("channel",A.toString()),l.set("stream",i.toString());const g=new URL(`rtmp://${this.host}:${h}${a}`),d=g.searchParams;d.set("channel",A.toString()),d.set("stream",i.toString()),d.set("user",this.username),d.set("password",this.password),n.push({name:`RTMP ${o}`,id:o,container:"rtmp",channel:A,profile:t,url:s?g.toString():c.toString(),urlWithAuth:g.toString(),path:a,port:h,streamType:i,metadata:e})}const o=new URL(`baichuan://${this.host}/channel/${A}/profile/${t}`),g=new URL(`baichuan://${this.host}/channel/${A}/profile/${t}`);g.username=this.username,g.password=this.password,i.push({name:`Native ${t}`,id:`native_${t}`,container:"rtp",channel:A,profile:t,url:o.toString(),urlWithAuth:g.toString(),metadata:e})}return{nativeStreams:i,rtmpStreams:n,rtspStreams:r}}async testChannelStreams(e,t){const{testChannelStreams:r}=await Promise.resolve().then(s.bind(s,6546));return await r({api:this,channel:this.normalizeChannel(e),...void 0!==t?{logger:t}:{}})}async collectMultifocalDiagnostics(e){const{collectMultifocalDiagnostics:t}=await Promise.resolve().then(s.bind(s,6546));return await t({api:this,logger:e})}};function Pe(e){const t=e?.trim();return t||void 0}function xe(e,t){const s={host:e.host,username:e.username,password:e.password,...void 0!==e.logger?{logger:e.logger}:{},debugOptions:e.debugOptions??{}};if("tcp"===t){const r=new Le({...s,transport:"tcp"});return He(r,t,e),r}const r=Pe(e.uid);if(!r)throw new Error("UID is required for battery cameras (BCUDP)");const n=new Le({...s,transport:"udp",uid:r,idleDisconnect:!0});return He(n,t,e),n}function He(e,t,s){try{e.client.on("error",(e=>{if(!s.logger)return;const r=e?.message||e?.toString?.()||String(e);"string"==typeof r&&(r.includes("Baichuan socket closed")||r.includes("Baichuan UDP stream closed")||r.includes("Not running"))||s.logger?.log?.(`[BaichuanClient] error (${t}) ${s.host}: ${r}`)})),e.client.on("close",(()=>{}))}catch{}}async function Ye(e){const{host:t,uid:s,logger:n}=e;n?.log?.(`[AutoDetect] Pinging ${t}...`);const i=await async function(e,t=3e3){return new Promise((s=>{const{exec:n}=(0,r.ki)("child_process");n("win32"===process.platform?`ping -n 1 -w ${t} ${e}`:`ping -c 1 -W ${Math.floor(t/1e3)} ${e}`,(e=>{s(!e)}))}))}(t);let A;n?.log?.(i?`[AutoDetect] Host ${t} is reachable`:`[AutoDetect] Host ${t} is not reachable via ping, but continuing with connection attempt...`);try{n?.log?.(`[AutoDetect] Trying TCP connection to ${t}...`),A=xe(e,"tcp"),await A.login();const r=await A.getInfo(),i=await A.getDeviceCapabilities(),o=i?.support?.channelNum??1,a=r.type?.trim();n?.log?.(`[AutoDetect] TCP connection successful. channelNum=${o}, model=${a??"unknown"}`);const c=a?a.trim():void 0,l=!!c&&Me.has(c),h="string"==typeof o?Number.parseInt(o,10):o,g=(2===h||3===h)&&Number.isFinite(h);if(l||g){const e=l?"model match":"channelNum fallback";return n?.log?.(`[AutoDetect] Detected multi-focal device (${e}: model=${c??"unknown"}, channelNum=${o})`),{type:"multifocal",transport:"tcp",uid:s||"",deviceInfo:r,channelNum:o,api:A}}return o>1?(n?.log?.(`[AutoDetect] Detected NVR (${o} channels)`),{type:"nvr",transport:"tcp",uid:s||"",deviceInfo:r,channelNum:o,api:A}):(n?.log?.("[AutoDetect] Detected regular camera (single channel)"),{type:"camera",transport:"tcp",uid:s||"",deviceInfo:r,channelNum:1,api:A})}catch(r){if(A)try{await A.close()}catch{}if(!function(e){const t=e?.message||e?.toString?.()||"";return"string"==typeof t&&(t.includes("ECONNREFUSED")||t.includes("ETIMEDOUT")||t.includes("EHOSTUNREACH")||t.includes("ENETUNREACH")||t.includes("socket hang up")||t.includes("TCP connection timeout")||t.includes("Baichuan socket closed"))}(r))throw r;n?.log?.("[AutoDetect] TCP failed, trying UDP (battery camera)...");const i=Pe(s);if(!i)throw new Error(`TCP connection failed and device likely requires UDP/BCUDP. UID is required for battery cameras (ip=${t}).`);try{const t=xe({...e,uid:i},"udp");await t.login();const s=await t.getInfo(),r=await t.getDeviceCapabilities(),A=r?.support?.channelNum??1,o=s.type?.trim(),a=o?o.trim():void 0,c=!!a&&Me.has(a),l="string"==typeof A?Number.parseInt(A,10):A,h=(2===l||3===l)&&Number.isFinite(l);if(c||h){const e=c?"model match":"channelNum fallback";return n?.log?.(`[AutoDetect] UDP connection successful. Detected multi-focal device (${e}: model=${a??"unknown"}, channelNum=${A}).`),{type:"multifocal",transport:"udp",uid:i,deviceInfo:s,channelNum:A,api:t}}return n?.log?.("[AutoDetect] UDP connection successful. Detected battery camera."),{type:"battery-cam",transport:"udp",uid:i,deviceInfo:s,channelNum:1,api:t}}catch(e){throw n?.log?.(`[AutoDetect] Both TCP and UDP failed. TCP error: ${r}, UDP error: ${e}`),new Error(`Failed to connect via both TCP and UDP. TCP: ${r?.message||r}, UDP: ${e?.message||e}`)}}}require("os");const Ve=require("http");function Oe(e,t,s){const r=[];let n=0;const i=(e,r)=>{if(4===t)return"be"===s?e.readUInt32BE(r):e.readUInt32LE(r);if(2===t)return"be"===s?e.readUInt16BE(r):e.readUInt16LE(r);if(3===t){const t=e[r],n=e[r+1],i=e[r+2];return"be"===s?(t<<16|n<<8|i)>>>0:(i<<16|n<<8|t)>>>0}return e.readUInt8(r)};for(;n+t<=e.length;){const s=i(e,n);if(n+=t,!s)return[];if(n+s>e.length)return[];const A=e.subarray(n,n+s);n+=s,A.length&&r.push(A)}return n!==e.length?[]:r}function Ge(e,t){if(!t.length)return Number.POSITIVE_INFINITY;let s=0;for(const r of t)if(r.length){if(128&r[0])s+=10;else if("H264"===e){const e=31&r[0];(e<1||e>23)&&s++}else if("H265"===e){if(r.length<2){s++;continue}const e=r[0]>>1&63;e>=0&&e<=29||e>=32&&e<=40||e>=48&&e<=50||s++}}else s++;return s}function Je(e,t){if(!e?.length)return[];const s=[],r=function(e,t=64){if(!e?.length)return-1;const s=Math.min(e.length,Math.max(0,t));for(let t=0;t+3<s;t++)if(0===e[t]&&0===e[t+1]){if(1===e[t+2])return t;if(0===e[t+2]&&1===e[t+3])return t}return-1}(e,64);if(r>=0){const t=function(e){const t=[],s=e.length,r=t=>{if(t+3<=s&&0===e[t]&&0===e[t+1]){if(1===e[t+2])return 3;if(t+4<=s&&0===e[t+2]&&1===e[t+3])return 4}return 0};let n=0;for(;n<s&&!r(n);)n++;for(;n<s;){const i=r(n);if(!i){n++;continue}const A=n+i;let o=A;for(;o<s&&!r(o);)o++;if(A<o){const s=e.subarray(A,o);s.length>0&&t.push(s)}n=o}return t}(0===r?e:e.subarray(r));t.length&&s.push(t)}s.push(Oe(e,4,"be")),s.push(Oe(e,4,"le")),s.push(Oe(e,3,"be")),s.push(Oe(e,3,"le")),s.push(Oe(e,2,"be")),s.push(Oe(e,2,"le")),s.push(Oe(e,1,"be"));const n=function(e){if(e.length>=4&&0===e[0]&&0===e[1]){if(1===e[2])return e.subarray(3);if(0===e[2]&&1===e[3])return e.subarray(4)}return e}(e);n.length&&s.push([n]);let i=[],A=Number.POSITIVE_INFINITY;for(const e of s){if(!e.length)continue;const s=Ge(t,e);if(s<A&&(A=s,i=e,0===A))break}return i}function We(e){const t=Je(e,"H264");let s,r,n;for(const e of t){if(e.length<1)continue;const t=31&e[0];if(7===t){if(s=e,e.length>=4){n=Buffer.from([e[1],e[2],e[3]]).toString("hex")}}else 8===t&&(r=e)}const i={};return s&&(i.sps=s),r&&(i.pps=r),n&&(i.profileLevelId=n),i}function _e(e){const t=Je(e,"H265");let s,r,n;for(const e of t){if(e.length<2)continue;const t=e[0]>>1&63;32===t?s=e:33===t?r=e:34===t&&(n=e)}const i={};return s&&(i.vps=s),r&&(i.sps=r),n&&(i.pps=n),i}var $e=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];function qe(e){if(e.length<7)return null;if(255!==e[0]||240&~e[1])return null;const t=!(1&~e[1]),s=((192&e[2])>>6)+1,r=(60&e[2])>>2,n=$e[r]??0,i=(1&e[2])<<2|(192&e[3])>>6;if(!n||!i)return null;const A=t?7:9;if(e.length<A)return null;return{headerLength:A,sampleRate:n,channels:i,configHex:((31&s)<<11|(15&r)<<7|(15&i)<<3).toString(16).padStart(4,"0")}}var ze=class{constructor(e){this.payloadType=e,this.seq=n.randomBytes(2).readUInt16BE(0)}seq=0;timestamp=0;ssrc=n.randomBytes(4).readUInt32BE(0);setTimestamp(e){this.timestamp=e>>>0}getTimestamp(){return this.timestamp>>>0}advanceTimestamp(e){this.timestamp=this.timestamp+(e>>>0)>>>0}writePacket(e,t){const s=Buffer.alloc(12);return s[0]=128,s[1]=(t?128:0)|127&this.payloadType,s.writeUInt16BE(65535&this.seq,2),s.writeUInt32BE(this.timestamp>>>0,4),s.writeUInt32BE(this.ssrc>>>0,8),this.seq=this.seq+1&65535,Buffer.concat([s,e])}};function je(e,t,s,r,n){const i=s.maxRtpPayload,A=[];if(e.length<=i)return A.push(t.writePacket(e,r&&n)),A;const o=e[0],a=31&o,c=128&o|96&o|28,l=e.subarray(1);let h=0;for(;h<l.length;){const e=l.length-h,s=Math.min(e,i-2),o=0===h,g=h+s>=l.length,d=(o?128:0)|(g?64:0)|31&a,u=Buffer.concat([Buffer.from([c,d]),l.subarray(h,h+s)]);A.push(t.writePacket(u,r&&n&&g)),h+=s}return A}function Xe(e,t,s,r,n){const i=s.maxRtpPayload,A=[];if(e.length<=i)return A.push(t.writePacket(e,r&&n)),A;if(e.length<3)return A;const o=e[0],a=o>>1&63,c=129&o|98,l=e[1],h=e.subarray(2);let g=0;for(;g<h.length;){const e=h.length-g,s=Math.min(e,i-3),o=0===g,d=g+s>=h.length,u=(o?128:0)|(d?64:0)|63&a,E=Buffer.concat([Buffer.from([c,l,u]),h.subarray(g,g+s)]);A.push(t.writePacket(E,r&&n&&d)),g+=s}return A}var Ze=class e{constructor(e,t,s,r=25,n=1200){this.logger=e,this.videoPayloadType=t,this.maxRtpPayload=n,this.videoRtp=new ze(t),void 0!==s&&(this.audioRtp=new ze(s)),this.fallbackVideoIncrement=Math.max(1,Math.round(this.videoClockRate/Math.max(1,r))),this.fallbackVideoDeltaUs=Math.max(1,Math.round(1e6*this.fallbackVideoIncrement/this.videoClockRate))}clients=new Set;closed=!1;videoRtp;audioRtp;videoLastUsRaw;videoUsWrapOffset=0;videoLastAbsUs;videoAvgDeltaUs;videoClockRate=9e4;fallbackVideoIncrement;fallbackVideoDeltaUs;maxTrustedDeltaUs=5e5;emaAlpha=.1;videoTimingLogState={lastUntrustedDeltaLogMs:0,lastWrapLogMs:0,lastResetLogMs:0,untrustedDeltaCount:0,wrapCount:0,resetCount:0};cachedH264ParamSetsAnnexB;cachedH265ParamSetsAnnexB;addClient(e){if(this.closed)return void e.destroy();const t={socket:e,needsKeyframe:!0,sentVideoConfig:!1};this.clients.add(t);const s=()=>{this.clients.delete(t);try{e.destroy()}catch{}};e.on("error",s),e.on("close",s)}static ANNEXB_START_CODE=Buffer.from([0,0,0,1]);static joinAnnexBNals(...t){const s=t.filter((e=>!!e&&e.length>0));if(!s.length)return;const r=[];for(const t of s)r.push(e.ANNEXB_START_CODE,t);return Buffer.concat(r)}updateVideoParamSetsFromAccessUnit(t,s){if(!s?.length)return;if("H264"===t){const{sps:t,pps:r}=We(s);return void(t&&r&&(this.cachedH264ParamSetsAnnexB=e.joinAnnexBNals(t,r)))}const{vps:r,sps:n,pps:i}=_e(s);r&&n&&i&&(this.cachedH265ParamSetsAnnexB=e.joinAnnexBNals(r,n,i))}sendCachedVideoConfigToClient(e,t){if(this.closed)return;if(t.sentVideoConfig)return;const s="H265"===e?this.cachedH265ParamSetsAnnexB:this.cachedH264ParamSetsAnnexB;if(!s?.length)return;const r=Je(s,e);if(!r.length)return;const n={maxRtpPayload:this.maxRtpPayload};for(let s=0;s<r.length;s++){const i=r[s],A=s===r.length-1,o="H265"===e?Xe(i,this.videoRtp,n,!1,A):je(i,this.videoRtp,n,!1,A);for(const e of o)this.writeRtpPacketToClient(t,e)}t.sentVideoConfig=!0}close(){if(!this.closed){this.closed=!0;for(const e of Array.from(this.clients))try{e.socket.destroy()}catch{}this.clients.clear()}}writeRtpPacketToClient(e,t){if(e.socket.destroyed||!e.socket.writable)return;const s=Buffer.alloc(2);s.writeUInt16BE(65535&t.length,0);const r=Buffer.concat([s,t]);try{e.socket.write(r)}catch{try{e.socket.destroy()}catch{}}}writeRtpPacketToClients(e,t){for(const s of this.clients)t(s)&&this.writeRtpPacketToClient(s,e)}resetVideoTimestampMapping(){this.videoLastUsRaw=void 0,this.videoUsWrapOffset=0,this.videoLastAbsUs=void 0,this.videoAvgDeltaUs=void 0}logVideoTiming(e,t){const s=Date.now(),r=5e3,n=this.videoTimingLogState;if("untrusted-delta"===e){if(n.untrustedDeltaCount++,s-n.lastUntrustedDeltaLogMs<r)return;return n.lastUntrustedDeltaLogMs=s,void this.logger.warn(`[rfc4571] video timing: ${t} (untrustedDeltaCount=${n.untrustedDeltaCount})`)}if("wrap"===e){if(n.wrapCount++,s-n.lastWrapLogMs<r)return;return n.lastWrapLogMs=s,void this.logger.warn(`[rfc4571] video timing: ${t} (wrapCount=${n.wrapCount})`)}n.resetCount++,s-n.lastResetLogMs<r||(n.lastResetLogMs=s,this.logger.warn(`[rfc4571] video timing: ${t} (resetCount=${n.resetCount})`))}advanceVideoTimestampFallback(){this.videoRtp.advanceTimestamp(this.fallbackVideoIncrement)}setVideoTimestampFromMicroseconds(e){if(null==e)return void this.advanceVideoTimestampFallback();if(!Number.isFinite(e))return void this.advanceVideoTimestampFallback();const t=e>>>0;if(void 0!==this.videoLastUsRaw){const e=this.videoLastUsRaw;if(t<e){e>4026531840&&t<268435455?(this.videoUsWrapOffset+=4294967296,this.logVideoTiming("wrap",`detected u32 wrap (lastUsRaw=${e} curUsRaw=${t} wrapOffset=${this.videoUsWrapOffset})`)):(this.logVideoTiming("reset",`detected backwards jump; resetting mapping (lastUsRaw=${e} curUsRaw=${t})`),this.resetVideoTimestampMapping())}}this.videoLastUsRaw=t;const s=this.videoUsWrapOffset+t;if(void 0===this.videoLastAbsUs)return this.videoLastAbsUs=s,void(void 0===this.videoAvgDeltaUs&&(this.videoAvgDeltaUs=this.fallbackVideoDeltaUs));const r=s-this.videoLastAbsUs;this.videoLastAbsUs=s;let n;if(Number.isFinite(r)&&r>0&&r<=this.maxTrustedDeltaUs){const e=this.videoAvgDeltaUs??r;this.videoAvgDeltaUs=e+(r-e)*this.emaAlpha,n=r}else this.logVideoTiming("untrusted-delta",`discarded deltaUs=${r} (absUs=${s} lastAbsUs=${this.videoLastAbsUs} avgDeltaUs=${this.videoAvgDeltaUs??"n/a"}); using fallback`),n=this.videoAvgDeltaUs??this.fallbackVideoDeltaUs;const i=Math.max(1,Math.round(n*this.videoClockRate/1e6));this.videoRtp.advanceTimestamp(i)}sendVideoAccessUnit(e,t,s,r){if(this.closed)return;this.updateVideoParamSetsFromAccessUnit(e,t);const n=Je(t,e);if(!n.length)return;let i=!1;if("H264"===e)for(const e of n){if(5===(31&e[0])){i=!0;break}}else for(const e of n){if(e.length<2)continue;const t=e[0]>>1&63;if(t>=16&&t<=23){i=!0;break}}const A=s||i,o=e=>!!A||!e.needsKeyframe;let a=!1;for(const e of this.clients)if(o(e)){a=!0;break}if(!a){for(const t of this.clients)t.needsKeyframe&&this.sendCachedVideoConfigToClient(e,t);return}this.setVideoTimestampFromMicroseconds(r);for(const t of this.clients)t.needsKeyframe&&this.sendCachedVideoConfigToClient(e,t);const c={maxRtpPayload:this.maxRtpPayload};for(let t=0;t<n.length;t++){const s=n[t],r=t===n.length-1,i="H265"===e?Xe(s,this.videoRtp,c,!0,r):je(s,this.videoRtp,c,!0,r);for(const e of i)this.writeRtpPacketToClients(e,o)}if(A)for(const e of this.clients)e.needsKeyframe=!1}sendAudioAdtsFrame(e){if(this.closed)return{};if(!this.audioRtp)return{};const{packets:t,config:s}=function(e,t){const s=qe(e);if(!s)return{packets:[]};const r=e.subarray(s.headerLength);if(!r.length)return{packets:[]};const n=Buffer.from([0,16]),i=8191&r.length,A=Buffer.alloc(2);A[0]=i>>5&255,A[1]=(31&i)<<3;const o=Buffer.concat([n,A,r]);return{packets:[t.writePacket(o,!0)],config:{sampleRate:s.sampleRate,channels:s.channels,configHex:s.configHex}}}(e,this.audioRtp);for(const e of t)this.writeRtpPacketToClients(e,(e=>!e.needsKeyframe));return t.length&&this.audioRtp.advanceTimestamp(1024),s?{parsed:s}:{}}sendAudioRtpPacket(e){if(this.closed)return;if(!e||e.length<12)return;2===(e[0]>>6&3)&&this.writeRtpPacketToClients(e,(e=>!e.needsKeyframe))}static parseRtpPayload(e){if(!e||e.length<12)return;if(2!==(e[0]>>6&3))return;const t=!!(32&e[0]),s=!!(16&e[0]);let r=12+4*(15&e[0]);if(r>e.length)return;if(s){if(r+4>e.length)return;if(r+=4+4*e.readUInt16BE(r+2),r>e.length)return}let n=e.length;if(t){const t=e[e.length-1];if(t<=0||t>e.length)return;if(n=e.length-t,n<r)return}return n<=r?void 0:e.subarray(r,n)}static isH264KeyframeLikeRtpPacket(t){const s=e.parseRtpPayload(t);if(!s||s.length<1)return!1;const r=31&s[0];if(r>=1&&r<=23)return 5===r||7===r||8===r;if(24===r){let e=1;for(;e+2<=s.length;){const t=s.readUInt16BE(e);if(e+=2,!t||e+t>s.length)break;const r=31&s[e];if(5===r||7===r||8===r)return!0;e+=t}return!1}if(28===r&&s.length>=2){const e=s[1],t=31&e;return!!!!(128&e)&&(5===t||7===t||8===t)}return!1}static isH265KeyframeLikeRtpPacket(t){const s=e.parseRtpPayload(t);if(!s||s.length<2)return!1;const r=s[0]>>1&63,n=e=>e>=16&&e<=21||(32===e||33===e||34===e);if(49===r&&s.length>=3){const e=s[2];return!!!!(128&e)&&n(63&e)}return n(r)}sendVideoRtpPacket(t,s){if(this.closed)return;if(!s||s.length<12)return;if(2!==(s[0]>>6&3))return;const r="H265"===t?e.isH265KeyframeLikeRtpPacket(s):e.isH264KeyframeLikeRtpPacket(s);if(this.writeRtpPacketToClients(s,(e=>!!r||!e.needsKeyframe)),r)for(const e of this.clients)e.needsKeyframe=!1}};var Ke=class extends A.EventEmitter{options;widerStream=null;teleStream=null;ffmpegProcess=null;active=!1;logger;constructor(e){super(),this.options={pipPosition:"bottom-right",pipSize:.25,pipMargin:10,...e},this.logger=e.logger??console}async start(){if(this.active)throw new Error("Composite stream already active");this.active=!0,this.logger.log?.("[CompositeStream] Starting composite stream...");try{const e=await this.options.api.getStreamMetadata(this.options.widerChannel),t=await this.options.api.getStreamMetadata(this.options.teleChannel),s=e.streams.find((e=>e.profile===this.options.widerProfile)),r=t.streams.find((e=>e.profile===this.options.teleProfile));if(!s||!r)throw new Error("Stream metadata not found");const n=s.width,i=s.height,A=Math.floor(r.width*(this.options.pipSize??.25)),o=Math.floor(r.height*(this.options.pipSize??.25)),a=function(e,t,s,r,n,i){const A=Math.floor(r),o=Math.floor(n),a=i;switch(e){case"top-left":default:return{x:a,y:a};case"top-right":return{x:t-A-a,y:a};case"bottom-left":return{x:a,y:s-o-a};case"bottom-right":return{x:t-A-a,y:s-o-a};case"center":return{x:Math.floor((t-A)/2),y:Math.floor((s-o)/2)};case"top-center":return{x:Math.floor((t-A)/2),y:a};case"bottom-center":return{x:Math.floor((t-A)/2),y:s-o-a};case"left-center":return{x:a,y:Math.floor((s-o)/2)};case"right-center":return{x:t-A-a,y:Math.floor((s-o)/2)}}}(this.options.pipPosition??"bottom-right",n,i,A,o,this.options.pipMargin??10);this.logger.log?.(`[CompositeStream] Main: ${n}x${i}, PIP: ${A}x${o} at (${a.x}, ${a.y})`),this.widerStream=ee(this.options.api,this.options.widerChannel,this.options.widerProfile),this.teleStream=ee(this.options.api,this.options.teleChannel,this.options.teleProfile),await this.startFfmpegComposition(n,i,A,o,a),this.logger.log?.("[CompositeStream] Composite stream started")}catch(e){throw this.active=!1,this.emit("error",e),e}}async startFfmpegComposition(e,t,s,r,n){const i=(await this.options.api.getStreamMetadata(this.options.widerChannel)).streams.find((e=>e.profile===this.options.widerProfile)),A=i?.videoEncType?.toLowerCase().includes("265")?"hevc":"h264",o=["-hide_banner","-loglevel","error","-fflags","+genpts","-f","hevc"===A?"hevc":"h264","-i","pipe:0","-f","hevc"===A?"hevc":"h264","-i","pipe:1","-filter_complex",`[1:v]scale=${s}:${r}[pip];[0:v][pip]overlay=${n.x}:${n.y}[out]`,"-map","[out]","-c:v","libx264","-preset","ultrafast","-tune","zerolatency","-crf","23","-f","h264","pipe:2"];this.logger.log?.(`[CompositeStream] Starting ffmpeg: ${o.join(" ")}`),this.ffmpegProcess=(0,l.spawn)("ffmpeg",o,{stdio:["pipe","pipe","pipe"]}),this.ffmpegProcess.on("error",(e=>{this.logger.error?.("[CompositeStream] FFmpeg error:",e),this.emit("error",e)})),this.ffmpegProcess.on("close",(e=>{0!==e&&null!==e&&this.logger.warn?.(`[CompositeStream] FFmpeg exited with code ${e}`),this.emit("close")})),this.ffmpegProcess.stdout?.on("data",(e=>{this.emit("videoFrame",e)})),this.ffmpegProcess.stderr?.on("data",(e=>{const t=e.toString();(t.includes("error")||t.includes("Error"))&&this.logger.error?.("[CompositeStream] FFmpeg stderr:",t)})),this.feedFramesToFfmpeg()}async feedFramesToFfmpeg(){if(!this.ffmpegProcess||!this.widerStream||!this.teleStream)return;const e=this.ffmpegProcess.stdio[0],t=this.ffmpegProcess.stdio[1];if(!e||!t)return void this.logger.error?.("[CompositeStream] FFmpeg stdin not available");Promise.all([(async()=>{try{for await(const t of this.widerStream){if(!this.active)break;if(!t.audio)try{e.write(t.data)||await new Promise((t=>{e.once("drain",(()=>t()))}))}catch(e){const t=e?.code;if("EPIPE"===t||"ERR_STREAM_WRITE_AFTER_END"===t){this.logger.log?.("[CompositeStream] FFmpeg wider stdin closed");break}this.logger.error?.("[CompositeStream] Error writing wider frame:",e)}}}catch(e){this.active&&this.logger.error?.("[CompositeStream] Error in wider stream:",e)}finally{try{e.end()}catch{}}})(),(async()=>{try{for await(const e of this.teleStream){if(!this.active)break;if(!e.audio)try{t.write(e.data)||await new Promise((e=>{t.once("drain",(()=>e()))}))}catch(e){const t=e?.code;if("EPIPE"===t||"ERR_STREAM_WRITE_AFTER_END"===t){this.logger.log?.("[CompositeStream] FFmpeg tele stdin closed");break}this.logger.error?.("[CompositeStream] Error writing tele frame:",e)}}}catch(e){this.active&&this.logger.error?.("[CompositeStream] Error in tele stream:",e)}finally{try{t.end()}catch{}}})()]).catch((e=>{this.active&&(this.logger.error?.("[CompositeStream] Error in frame processing:",e),this.emit("error",e))}))}async stop(){if(this.active){if(this.active=!1,this.logger.log?.("[CompositeStream] Stopping composite stream..."),this.ffmpegProcess){try{this.ffmpegProcess.stdin?.end(),this.ffmpegProcess.kill("SIGTERM"),setTimeout((()=>{try{this.ffmpegProcess?.kill("SIGKILL")}catch{}}),1e3)}catch{}this.ffmpegProcess=null}this.widerStream=null,this.teleStream=null,this.logger.log?.("[CompositeStream] Composite stream stopped")}}isActive(){return this.active}};async function et(e){const{api:t,channel:s,profile:n,logger:i,expectedVideoType:A,host:o="127.0.0.1",videoPayloadType:c=96,audioPayloadType:l=97,keyframeTimeoutMs:h=5e3,uptimeRestartMs:g=1e4,idleTeardownMs:d=2500,closeApiOnTeardown:u=!0,username:E,password:I,requireAuth:p=!1,compositeOptions:C}=e,B=void 0===s,f=B?`[native-rfc4571 composite profile=${n}]`:`[native-rfc4571 ch=${s} profile=${n}]`,Q=e=>i.warn(`${f} ${e}`);let m;Q(`starting (host=${o} videoPT=${c} audioPT=${l} expectedVideoType=${A??"n/a"} keyframeTimeoutMs=${h} uptimeRestartMs=${g} idleTeardownMs=${d} composite=${B})`);let y=!1;if(B){const e=C?.widerChannel??0,s=C?.teleChannel??1,r=n,A=n;Q(`creating composite stream: wider(ch=${e}, profile=${r}), tele(ch=${s}, profile=${A})`),m=new Ke({api:t,widerChannel:e,teleChannel:s,widerProfile:r,teleProfile:A,pipPosition:C?.pipPosition??"bottom-right",pipSize:C?.pipSize??.25,pipMargin:C?.pipMargin??10,logger:i}),y=!0,await m.start(),Q("composite stream started; waiting for keyframe to extract parameter sets")}else m=new r.tj({client:t.client,api:t,channel:s,profile:n,logger:i}),await m.start(),Q("baichuan stream started; waiting for keyframe to extract parameter sets");const w=await(async()=>y?await new Promise(((e,t)=>{const s=setTimeout((()=>{A(),t(new Error(`Timeout waiting for keyframe on composite stream profile=${n}`))}),h),r=e=>{A(),t(e instanceof Error?e:new Error(String(e)))},i=t=>{try{const{sps:s,pps:r,profileLevelId:n}=We(t);if(!s||!r)return;A(),e({videoType:"H264",accessUnit:t,...n?{profileLevelId:n}:{},h264:{sps:s,pps:r}})}catch(e){return}},A=()=>{clearTimeout(s),m.removeListener("error",r),m.removeListener("videoFrame",i)};m.on("error",r),m.on("videoFrame",i)})):await new Promise(((e,t)=>{const r=setTimeout((()=>{o(),t(new Error(`Timeout waiting for keyframe on native stream channel=${s} profile=${n}`))}),h),i=e=>{o(),t(e instanceof Error?e:new Error(String(e)))},A=t=>{if(!t?.isKeyframe)return;const s=t.videoType,r=t.data;if("H264"===s){const{sps:t,pps:n,profileLevelId:i}=We(r);if(!t||!n)return;return o(),void e({videoType:s,accessUnit:r,...i?{profileLevelId:i}:{},h264:{sps:t,pps:n}})}const{vps:n,sps:i,pps:A}=_e(r);n&&i&&A&&(o(),e({videoType:s,accessUnit:r,h265:{vps:n,sps:i,pps:A}}))},o=()=>{clearTimeout(r),m.removeListener("error",i),m.removeListener("videoAccessUnit",A)};m.on("error",i),m.on("videoAccessUnit",A)})))();A&&w.videoType!==A&&Q(`expectedVideoType mismatch (expected=${A} actual=${w.videoType})`),Q(`video detected: codec=${w.videoType} (primed via keyframe)`);let S,D=25;try{if(B){const e=C?.widerChannel??0,s=await t.getStreamMetadata(e),r=(Array.isArray(s)?s:Array.isArray(s?.streams)?s.streams:[]).find((e=>e?.profile===n)),i=Number(r?.frameRate);Number.isFinite(i)&&i>0&&(D=i)}else{const e=await t.getStreamMetadata(s),r=(Array.isArray(e)?e:Array.isArray(e?.streams)?e.streams:[]).find((e=>e?.profile===n)),i=Number(r?.frameRate);Number.isFinite(i)&&i>0&&(D=i)}}catch{}Q(`video framerate hint: ${D} fps`);S=await(async()=>{if(!y)return await new Promise((e=>{let t=!1,s=3;const r=setTimeout((()=>{A(),t&&i.warn("Native audio frames seen but not ADTS AAC; cannot advertise audio track."),e(void 0)}),5e3),n=r=>{t=!0;const n=qe(r);if(n)A(),e({sampleRate:n.sampleRate,channels:n.channels,configHex:n.configHex});else if(s-- >0){const e=r.subarray(0,Math.min(16,r.length)).toString("hex");i.warn(`Native audioFrame not ADTS: len=${r.length} head=${e}`)}},A=()=>{clearTimeout(r),m.removeListener("audioFrame",n)};m.on("audioFrame",n)}))})(),Q(S?`audio detected: codec=aac sampleRate=${S.sampleRate} channels=${S.channels}`:"audio not detected/advertised (no ADTS AAC config within timeout)");const b={videoType:w.videoType,payloadType:c,..."H264"===w.videoType?{h264:{sps:w.h264.sps,pps:w.h264.pps,...w.profileLevelId?{profileLevelId:w.profileLevelId}:{}}}:{h265:{vps:w.h265.vps,sps:w.h265.sps,pps:w.h265.pps}}},v=S?{codec:"aac",payloadType:l,sampleRate:S.sampleRate,channels:S.channels,configHex:S.configHex}:void 0,R=function(e,t){let s="v=0\r\n";if(s+="o=- 0 0 IN IP4 0.0.0.0\r\n",s+="s=No Name\r\n",s+="t=0 0\r\n",s+=`m=video 0 RTP/AVP ${e.payloadType}\r\n`,s+="c=IN IP4 0.0.0.0\r\n",s+=`a=rtpmap:${e.payloadType} ${e.videoType}/90000\r\n`,"H264"===e.videoType&&e.h264){const t=e.h264.sps.toString("base64"),r=e.h264.pps.toString("base64"),n=e.h264.profileLevelId?`profile-level-id=${e.h264.profileLevelId};`:"";s+=`a=fmtp:${e.payloadType} packetization-mode=1;${n}sprop-parameter-sets=${t},${r}\r\n`}if("H265"===e.videoType&&e.h265){const t=e.h265.vps.toString("base64"),r=e.h265.sps.toString("base64"),n=e.h265.pps.toString("base64");s+=`a=fmtp:${e.payloadType} sprop-vps=${t};sprop-sps=${r};sprop-pps=${n}\r\n`}return"aac"===t?.codec&&(s+=`m=audio 0 RTP/AVP ${t.payloadType}\r\n`,s+="c=IN IP4 0.0.0.0\r\n",s+="b=AS:128\r\n",s+=`a=rtpmap:${t.payloadType} MPEG4-GENERIC/${t.sampleRate}/${t.channels}\r\n`,s+=`a=fmtp:${t.payloadType} profile-level-id=1; mode=AAC-hbr; sizelength=13; indexlength=3; indexdeltalength=3; config=${t.configHex}\r\n`),"opus"===t?.codec&&(s+=`m=audio 0 RTP/AVP ${t.payloadType}\r\n`,s+="c=IN IP4 0.0.0.0\r\n",s+="b=AS:128\r\n",s+=`a=rtpmap:${t.payloadType} opus/${t.sampleRate}/${t.channels}\r\n`),s}(b,v),N=()=>new Ze(i,c,v?l:void 0,D);let k=N();Q(`SDP ready (video=${w.videoType}/90000 pt=${c}${v?`, audio=aac/${v.sampleRate}/${v.channels} pt=${l}`:", audio=none"})`);let T=0;const F=new Set;let M,U=!1,L=!1,P=Date.now();const x=()=>{P=Date.now()},H=()=>{M&&(clearTimeout(M),M=void 0)};let Y;const V=e=>{d&&(M||(M=setTimeout((()=>{M=void 0,0===T&&e(new Error("No RFC4571 clients (idle)")).catch((()=>{}))}),d)))},O=a.createServer(),G=async e=>{if(U)return;if(L)return;L=!0,x(),H();const t=e?.message||e?.toString?.()||e,s=O.address(),r=s&&"string"!=typeof s?`${s.address}:${s.port}`:"unbound";Q(t?`uptime watchdog: restarting (addr=${r} clients=${T} reason=${t})`:`uptime watchdog: restarting (addr=${r} clients=${T})`);for(const e of Array.from(F))try{e.destroy()}catch{}F.clear();try{k.close()}catch{}k=N();try{await m.stop()}catch{}try{await m.start()}catch(e){return L=!1,void J(e).catch((()=>{}))}L=!1,x(),Q("uptime watchdog: restart complete"),0===T&&V(J)},J=async e=>{if(U)return;U=!0,Y&&(clearInterval(Y),Y=void 0),H();const s=e?.message||e?.toString?.()||e,r=O.address(),n=r&&"string"!=typeof r?`${r.address}:${r.port}`:"unbound";Q(s?`teardown requested (addr=${n} clients=${T} reason=${s})`:`teardown requested (addr=${n} clients=${T})`),k.close();try{await m.stop()}catch{}if(u)try{await t.close()}catch{}try{O.close()}catch{}Q("teardown complete")};O.on("connection",(e=>{x();const t=`${e.remoteAddress??"unknown"}:${e.remotePort??"unknown"}`;Q(`client connecting (remote=${t} requireAuth=${p})`);const s=()=>{T++,H(),F.add(e),e.on("data",(()=>x()));try{const t=e.write.bind(e);e.write=(...e)=>(x(),t(...e))}catch{}k.addClient(e),Q(`client connected (remote=${t} clients=${T})`)};if(p){let r=!1,n=Buffer.alloc(0);const i=setTimeout((()=>{r||(Q(`client authentication timeout (remote=${t})`),e.destroy())}),5e3),A=o=>{if(x(),!r){n=Buffer.concat([n,o]);const a=n.toString("utf8").match(/^([^:]+):([^\n]+)\n/);if(a){const[,o,c]=a;if(o!==E||c!==I)return Q(`client authentication failed (remote=${t})`),void e.destroy();{r=!0,clearTimeout(i),s();const t=a[0].length,o=n.subarray(t);e.removeListener("data",A),e.on("data",(()=>x())),o.length>0&&e.emit("data",o)}}else if(n.length>1024)return Q(`client authentication buffer overflow (remote=${t})`),void e.destroy()}};e.on("data",A)}else s();let r=!0;const n=()=>{r&&(r=!1,T=Math.max(0,T-1),F.delete(e),Q(`client disconnected (remote=${t} clients=${T})`),0===T&&V(J))};e.once("close",n),e.once("error",n)})),y?m.on("videoFrame",(e=>{x();try{let t=!1;try{for(let s=0;s<e.length-4;s++)if(0===e[s]&&0===e[s+1]){let r=-1;if(1===e[s+2]?r=s+3:0===e[s+2]&&1===e[s+3]&&(r=s+4),r>=0&&r<e.length){if(5===(31&(e[r]??0))){t=!0;break}}}}catch{}k.sendVideoAccessUnit("H264",e,t,void 0)}catch(e){J(e).catch((()=>{}))}})):(m.on("videoAccessUnit",(e=>{x();try{k.sendVideoAccessUnit(e.videoType,e.data,e.isKeyframe,e.microseconds)}catch(e){J(e).catch((()=>{}))}})),v&&m.on("audioFrame",(e=>{x();try{k.sendAudioAdtsFrame(e)}catch(e){J(e).catch((()=>{}))}}))),m.on("error",(e=>{L||J(e).catch((()=>{}))})),m.on("close",(e=>{L||J(e).catch((()=>{}))})),await new Promise(((e,t)=>{O.once("error",t),O.listen(0,o,(()=>e()))}));const W=O.address();if(!W||"string"==typeof W)throw new Error("Failed to bind RFC TCP server");const _=W.port;if(!_)throw new Error("Failed to bind RFC TCP server");Q(`listening (addr=${o}:${_})`);const $=v?{codec:"aac",sampleRate:v.sampleRate,channels:v.channels}:void 0;return V(J),(()=>{if(!g||g<=0)return;if(Y)return;const e=Math.max(250,Math.min(1e3,Math.floor(g/2)));Y=setInterval((()=>{if(U||L)return;const e=Date.now()-P;e<g||G(new Error(`No stream activity for ${e}ms (threshold=${g}ms)`)).catch((()=>{}))}),e)})(),{host:o,port:_,sdp:R,videoType:w.videoType,...$?{audio:$}:{},username:E,password:I,server:O,videoStream:m,close:J}}var tt=Buffer.from([0,0,0,1]),st=Buffer.from([0,0,1]);function rt(e){const t=[];for(let s=0;s<e.length-3;s++)0===e[s]&&0===e[s+1]&&(1===e[s+2]?(t.push({idx:s,len:3}),s+=2):0===e[s+2]&&1===e[s+3]&&(t.push({idx:s,len:4}),s+=3));if(0===t.length)return[];const s=[];for(let r=0;r<t.length;r++){const n=t[r],i=n.idx+n.len,A=t[r+1],o=A?A.idx:e.length;o>i&&s.push(e.subarray(i,o))}return s}function nt(e){if(e.length<1)return null;const t=e[0];return void 0===t?null:31&t}A.EventEmitter,A.EventEmitter}},t={};function s(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,s),i.loaded=!0,i.exports}s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var r=s(7927),n=exports="undefined"==typeof exports?{}:exports;for(var i in r)n[i]=r[i];r.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();
|
|
3
3
|
//# sourceMappingURL=main.nodejs.js.map
|