@camstack/addon-provider-reolink 1.2.139 → 1.2.140

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/addon.js CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("./chunk-Cek0wNdY.js");
3
- const require_chunk_KWWUCNIY = require("./chunk-KWWUCNIY-BtO6U6BT.js");
3
+ const require_chunk_ZQFQRCLQ = require("./chunk-ZQFQRCLQ-CR7OOtpp.js");
4
4
  let node_crypto = require("node:crypto");
5
5
  let events = require("events");
6
6
  let fs = require("fs");
@@ -5386,7 +5386,7 @@ var ZodIssueCode = {
5386
5386
  var ZodFirstPartyTypeKind;
5387
5387
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5388
5388
  //#endregion
5389
- //#region ../types/dist/sleep-B1y0Fo1U.mjs
5389
+ //#region ../types/dist/sleep-vl6nBE8d.mjs
5390
5390
  /**
5391
5391
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5392
5392
  * window to float samples (D455).
@@ -31879,6 +31879,47 @@ var ptzCapability = {
31879
31879
  auth: "admin"
31880
31880
  }),
31881
31881
  /**
31882
+ * Make WHERE THE HEAD IS POINTING RIGHT NOW this camera's home.
31883
+ *
31884
+ * `setHomePreset` takes a preset id, and a preset id is the wrong shape for
31885
+ * the most natural thing an operator does: aim the camera, then say "here".
31886
+ * It is also the only shape a camera whose home is NOT a preset can accept
31887
+ * -- Reolink's home is a guard point, a stored position with no id at all,
31888
+ * and hiding the control for that case (as the UI briefly did) left the one
31889
+ * vendor with a native home unable to set it.
31890
+ *
31891
+ * Each provider does it its own way:
31892
+ * reolink `setGrd` with `needSetPos`, pinning the guard point here
31893
+ * hikvision / amcrest save a preset, then pin it as home
31894
+ * onvif REFUSES -- its home is the PTZ origin and cannot be moved
31895
+ *
31896
+ * A provider that cannot honour it throws rather than silently doing
31897
+ * nothing: an operator who pressed "set home here" and saw no error would
31898
+ * believe it took.
31899
+ */
31900
+ captureHomeHere: method(object({ deviceId: number() }), _void(), {
31901
+ kind: "mutation",
31902
+ auth: "admin"
31903
+ }),
31904
+ /**
31905
+ * How long the camera waits, idle, before returning home on its own --
31906
+ * `null` when it has no such behaviour.
31907
+ *
31908
+ * Reolink's guard point carries one (`timeout`, freely settable in
31909
+ * seconds). It is a real function of the camera that we did not expose at
31910
+ * all, and it belongs next to the home it governs rather than in a vendor
31911
+ * settings page nobody associates with Home.
31912
+ */
31913
+ getHomeReturnSeconds: method(object({ deviceId: number() }), number().int().nullable()),
31914
+ /** Set the idle-return delay. Refused by a camera that has no such timer. */
31915
+ setHomeReturnSeconds: method(object({
31916
+ deviceId: number(),
31917
+ seconds: number().int().min(0).max(3600)
31918
+ }), _void(), {
31919
+ kind: "mutation",
31920
+ auth: "admin"
31921
+ }),
31922
+ /**
31882
31923
  * Pull the current PTZ position. Redundant with the auto-injected
31883
31924
  * `getStatus` method (see `status` below); kept for callers that
31884
31925
  * haven't migrated. Will be folded into `getStatus` in a future
@@ -41536,6 +41577,12 @@ Object.freeze({
41536
41577
  addonId: null,
41537
41578
  access: "create"
41538
41579
  },
41580
+ "ptz.captureHomeHere": {
41581
+ capName: "ptz",
41582
+ capScope: "device",
41583
+ addonId: null,
41584
+ access: "create"
41585
+ },
41539
41586
  "ptz.continuousMove": {
41540
41587
  capName: "ptz",
41541
41588
  capScope: "device",
@@ -41554,6 +41601,12 @@ Object.freeze({
41554
41601
  addonId: null,
41555
41602
  access: "view"
41556
41603
  },
41604
+ "ptz.getHomeReturnSeconds": {
41605
+ capName: "ptz",
41606
+ capScope: "device",
41607
+ addonId: null,
41608
+ access: "view"
41609
+ },
41557
41610
  "ptz.getOptions": {
41558
41611
  capName: "ptz",
41559
41612
  capScope: "device",
@@ -41608,6 +41661,12 @@ Object.freeze({
41608
41661
  addonId: null,
41609
41662
  access: "create"
41610
41663
  },
41664
+ "ptz.setHomeReturnSeconds": {
41665
+ capName: "ptz",
41666
+ capScope: "device",
41667
+ addonId: null,
41668
+ access: "create"
41669
+ },
41611
41670
  "ptz.stop": {
41612
41671
  capName: "ptz",
41613
41672
  capScope: "device",
@@ -44771,6 +44830,11 @@ Object.freeze({
44771
44830
  form: "single",
44772
44831
  optional: false
44773
44832
  }],
44833
+ "ptz.captureHomeHere": [{
44834
+ name: "deviceId",
44835
+ form: "single",
44836
+ optional: false
44837
+ }],
44774
44838
  "ptz.continuousMove": [{
44775
44839
  name: "deviceId",
44776
44840
  form: "single",
@@ -44786,6 +44850,11 @@ Object.freeze({
44786
44850
  form: "single",
44787
44851
  optional: false
44788
44852
  }],
44853
+ "ptz.getHomeReturnSeconds": [{
44854
+ name: "deviceId",
44855
+ form: "single",
44856
+ optional: false
44857
+ }],
44789
44858
  "ptz.getOptions": [{
44790
44859
  name: "deviceId",
44791
44860
  form: "single",
@@ -44831,6 +44900,11 @@ Object.freeze({
44831
44900
  form: "single",
44832
44901
  optional: false
44833
44902
  }],
44903
+ "ptz.setHomeReturnSeconds": [{
44904
+ name: "deviceId",
44905
+ form: "single",
44906
+ optional: false
44907
+ }],
44834
44908
  "ptz.stop": [{
44835
44909
  name: "deviceId",
44836
44910
  form: "single",
@@ -68515,7 +68589,7 @@ var require_yazl = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
68515
68589
  }
68516
68590
  }));
68517
68591
  //#endregion
68518
- //#region node_modules/@apocaliss92/nodelink-js/dist/chunk-HL6TWIAL.js
68592
+ //#region node_modules/@apocaliss92/nodelink-js/dist/chunk-KWQVN7H5.js
68519
68593
  var import_undici = require_undici();
68520
68594
  var import_yazl = /* @__PURE__ */ require_chunk.__toESM(require_yazl(), 1);
68521
68595
  var FLAGS_CAM_V2 = {
@@ -69792,13 +69866,13 @@ var ReolinkCgiApi = class _ReolinkCgiApi {
69792
69866
  sec: 59
69793
69867
  };
69794
69868
  }
69795
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Date conversion: start=${start.toISOString()} -> ReolinkTime=${JSON.stringify(startTime)}, end=${end.toISOString()} -> ReolinkTime=${JSON.stringify(endTime)}`);
69869
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Date conversion: start=${start.toISOString()} -> ReolinkTime=${JSON.stringify(startTime)}, end=${end.toISOString()} -> ReolinkTime=${JSON.stringify(endTime)}`);
69796
69870
  if (!bypassCache) {
69797
69871
  this.cleanRecordingsCache();
69798
69872
  const cacheKey = this.getNvrRecordingsCacheKey(channel, startTime, endTime, streamType, iLogicChannel, autoSearchByDay);
69799
69873
  const cached = this.recordingsCache.get(cacheKey);
69800
69874
  if (cached && cached.expiresAt > Date.now()) {
69801
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Cache hit: returning ${cached.data.length} cached enriched recordings`);
69875
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Cache hit: returning ${cached.data.length} cached enriched recordings`);
69802
69876
  return cached.data;
69803
69877
  }
69804
69878
  }
@@ -69850,7 +69924,7 @@ var ReolinkCgiApi = class _ReolinkCgiApi {
69850
69924
  const firstResult = dayResponse[0];
69851
69925
  if (firstResult && firstResult.code === 0 && firstResult.value?.SearchResult?.File) {
69852
69926
  const files = firstResult.value.SearchResult.File;
69853
- if (files.length > 0 && files[0]) require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Raw API response for day ${day}/${month}/${year}: ${JSON.stringify({
69927
+ if (files.length > 0 && files[0]) require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Raw API response for day ${day}/${month}/${year}: ${JSON.stringify({
69854
69928
  fileCount: files.length,
69855
69929
  sampleFile: {
69856
69930
  name: files[0].name,
@@ -69886,7 +69960,7 @@ var ReolinkCgiApi = class _ReolinkCgiApi {
69886
69960
  } catch (e) {}
69887
69961
  enriched2.push(this.enrichVodFile(vodFile, channel, streamUrl));
69888
69962
  }
69889
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Returning ${enriched2.length} enriched recording files from autoSearchByDay`);
69963
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Returning ${enriched2.length} enriched recording files from autoSearchByDay`);
69890
69964
  if (!bypassCache) {
69891
69965
  const cacheKey = this.getNvrRecordingsCacheKey(channel, startTime, endTime, streamType, iLogicChannel, autoSearchByDay);
69892
69966
  this.recordingsCache.set(cacheKey, {
@@ -69914,7 +69988,7 @@ var ReolinkCgiApi = class _ReolinkCgiApi {
69914
69988
  const response = await this.call("Search", param, 0);
69915
69989
  allResults.push(...response);
69916
69990
  } else {
69917
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Range spans ${dayRanges.length} days, splitting into separate day queries`);
69991
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Range spans ${dayRanges.length} days, splitting into separate day queries`);
69918
69992
  for (const range of dayRanges) {
69919
69993
  const param = { Search: {
69920
69994
  channel,
@@ -69924,7 +69998,7 @@ var ReolinkCgiApi = class _ReolinkCgiApi {
69924
69998
  EndTime: range.end
69925
69999
  } };
69926
70000
  if (iLogicChannel > 0) param.Search.iLogicChannel = iLogicChannel;
69927
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Querying day: ${range.start.year}-${range.start.mon}-${range.start.day} (${range.start.hour}:${range.start.min}:${range.start.sec} to ${range.end.hour}:${range.end.min}:${range.end.sec})`);
70001
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Querying day: ${range.start.year}-${range.start.mon}-${range.start.day} (${range.start.hour}:${range.start.min}:${range.start.sec} to ${range.end.hour}:${range.end.min}:${range.end.sec})`);
69928
70002
  const response = await this.call("Search", param, 0);
69929
70003
  allResults.push(...response);
69930
70004
  }
@@ -69934,7 +70008,7 @@ var ReolinkCgiApi = class _ReolinkCgiApi {
69934
70008
  const firstResult = result[0];
69935
70009
  if (firstResult && firstResult.code === 0 && firstResult.value?.SearchResult?.File) {
69936
70010
  const files = firstResult.value.SearchResult.File;
69937
- if (files.length > 0 && files[0]) require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Raw API response (normal search): ${JSON.stringify({
70011
+ if (files.length > 0 && files[0]) require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Raw API response (normal search): ${JSON.stringify({
69938
70012
  fileCount: files.length,
69939
70013
  sampleFile: {
69940
70014
  name: files[0].name,
@@ -69951,12 +70025,12 @@ var ReolinkCgiApi = class _ReolinkCgiApi {
69951
70025
  const searchResult = res.value?.SearchResult;
69952
70026
  if (searchResult?.File) allFiles.push(...searchResult.File);
69953
70027
  }
69954
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Collected ${allFiles.length} raw VodFiles from API search results`);
70028
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Collected ${allFiles.length} raw VodFiles from API search results`);
69955
70029
  if (allFiles.length > 0) {
69956
70030
  const sampleSize = Math.min(3, allFiles.length);
69957
70031
  for (let i = 0; i < sampleSize; i++) {
69958
70032
  const file = allFiles[i];
69959
- if (file) require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Sample file ${i + 1}/${allFiles.length}: ${JSON.stringify({
70033
+ if (file) require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Sample file ${i + 1}/${allFiles.length}: ${JSON.stringify({
69960
70034
  name: file.name,
69961
70035
  type: file.type,
69962
70036
  size: file.size,
@@ -69979,7 +70053,7 @@ var ReolinkCgiApi = class _ReolinkCgiApi {
69979
70053
  } catch (e) {}
69980
70054
  enriched.push(this.enrichVodFile(vodFile, channel, streamUrl));
69981
70055
  }
69982
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Returning ${enriched.length} enriched recording files`);
70056
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclips", `Returning ${enriched.length} enriched recording files`);
69983
70057
  if (!bypassCache) {
69984
70058
  const cacheKey = this.getNvrRecordingsCacheKey(channel, startTime, endTime, streamType, iLogicChannel, autoSearchByDay);
69985
70059
  this.recordingsCache.set(cacheKey, {
@@ -70016,7 +70090,7 @@ var ReolinkCgiApi = class _ReolinkCgiApi {
70016
70090
  prepare: true,
70017
70091
  seek: seekSeconds
70018
70092
  });
70019
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclipThumbnailJpeg", `Extracting thumbnail from VOD URL (FLV): ${vodUrl.substring(0, 100)}... (seek=${seekSeconds}s)`);
70093
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclipThumbnailJpeg", `Extracting thumbnail from VOD URL (FLV): ${vodUrl.substring(0, 100)}... (seek=${seekSeconds}s)`);
70020
70094
  const { spawn: spawn2 } = await import("child_process");
70021
70095
  return new Promise((resolve, reject) => {
70022
70096
  const chunks = [];
@@ -70064,7 +70138,7 @@ var ReolinkCgiApi = class _ReolinkCgiApi {
70064
70138
  reject(/* @__PURE__ */ new Error(`ffmpeg produced too small output: ${jpeg.length} bytes`));
70065
70139
  return;
70066
70140
  }
70067
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclipThumbnailJpeg", `Successfully extracted thumbnail: ${jpeg.length} bytes`);
70141
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "getVideoclipThumbnailJpeg", `Successfully extracted thumbnail: ${jpeg.length} bytes`);
70068
70142
  resolve(jpeg);
70069
70143
  } else reject(/* @__PURE__ */ new Error(`ffmpeg exited with code ${code}: ${stderr.slice(-500)}`));
70070
70144
  });
@@ -70113,10 +70187,10 @@ var ReolinkCgiApi = class _ReolinkCgiApi {
70113
70187
  }
70114
70188
  } }
70115
70189
  }];
70116
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "prepareNvrVodDownload", `Request body: ${JSON.stringify(body)}`);
70190
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "prepareNvrVodDownload", `Request body: ${JSON.stringify(body)}`);
70117
70191
  try {
70118
70192
  const response = await this.callMany(body);
70119
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "prepareNvrVodDownload", `Response: ${JSON.stringify(response)}`);
70193
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "prepareNvrVodDownload", `Response: ${JSON.stringify(response)}`);
70120
70194
  const first = response[0];
70121
70195
  if (!first || first.code !== 0 || !first.value?.fileList) {
70122
70196
  const rspCode = first?.error?.rspCode;
@@ -70137,7 +70211,7 @@ var ReolinkCgiApi = class _ReolinkCgiApi {
70137
70211
  if (!filename) throw new Error(`NvrDownload: no files found in response`);
70138
70212
  return filename;
70139
70213
  } catch (error) {
70140
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "prepareNvrVodDownload", `Error: ${error instanceof Error ? error.message : String(error)}`);
70214
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "prepareNvrVodDownload", `Error: ${error instanceof Error ? error.message : String(error)}`);
70141
70215
  throw error;
70142
70216
  }
70143
70217
  }
@@ -70333,7 +70407,7 @@ var ReolinkCgiApi = class _ReolinkCgiApi {
70333
70407
  * Convert a VodFile to RecordingFile with parsed metadata.
70334
70408
  */
70335
70409
  enrichVodFile(vodFile, channel, streamUrl) {
70336
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "enrichVodFile", `RAW VodFile from API: ${JSON.stringify({
70410
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "enrichVodFile", `RAW VodFile from API: ${JSON.stringify({
70337
70411
  name: vodFile.name,
70338
70412
  type: vodFile.type,
70339
70413
  size: vodFile.size,
@@ -70386,7 +70460,7 @@ var ReolinkCgiApi = class _ReolinkCgiApi {
70386
70460
  hashBits0to15: hashRevBin.slice(0, 16)
70387
70461
  };
70388
70462
  }
70389
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "enrichVodFile", `Parsed filename: ${JSON.stringify({
70463
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "enrichVodFile", `Parsed filename: ${JSON.stringify({
70390
70464
  fileName: vodFile.name,
70391
70465
  filenameParts,
70392
70466
  hexValueFromFilename,
@@ -70413,13 +70487,13 @@ var ReolinkCgiApi = class _ReolinkCgiApi {
70413
70487
  const hexFlags = parsed?.flags;
70414
70488
  if (parsed?.devType === "hub" && parsed?.version === 4) {
70415
70489
  if (hexValueFromFilename && hexValueFromFilename !== "unknown") {
70416
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "enrichVodFile", `WARNING: Hub v4 hex value "${hexValueFromFilename}" appears to be constant across files. Detection flags are likely NOT encoded in filename for this version. Detection information may need to be retrieved via a separate API call or may not be available.`);
70417
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "enrichVodFile", `NOTE: For Hub v4, the API response only provides 'type' field which is "${vodFile.type}". No detection-specific fields are available in the Search API response.`);
70490
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "enrichVodFile", `WARNING: Hub v4 hex value "${hexValueFromFilename}" appears to be constant across files. Detection flags are likely NOT encoded in filename for this version. Detection information may need to be retrieved via a separate API call or may not be available.`);
70491
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "enrichVodFile", `NOTE: For Hub v4, the API response only provides 'type' field which is "${vodFile.type}". No detection-specific fields are available in the Search API response.`);
70418
70492
  }
70419
70493
  }
70420
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "enrichVodFile", `Hex flags from filename: ${JSON.stringify(hexFlags)}`);
70494
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "enrichVodFile", `Hex flags from filename: ${JSON.stringify(hexFlags)}`);
70421
70495
  const typeFlags = this.parseRecordTypeFlags(vodFile.type);
70422
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "enrichVodFile", `Type flags from recordType "${vodFile.type}": ${JSON.stringify(typeFlags)}`);
70496
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "enrichVodFile", `Type flags from recordType "${vodFile.type}": ${JSON.stringify(typeFlags)}`);
70423
70497
  const hasPerson = (hexFlags?.aiPerson ?? false) || typeFlags.hasPerson;
70424
70498
  const hasVehicle = (hexFlags?.aiVehicle ?? false) || typeFlags.hasVehicle;
70425
70499
  const hasAnimal = (hexFlags?.aiAnimal ?? false) || typeFlags.hasAnimal;
@@ -70430,7 +70504,7 @@ var ReolinkCgiApi = class _ReolinkCgiApi {
70430
70504
  const hasPackage = (hexFlags?.package ?? false) || typeFlags.hasPackage;
70431
70505
  const hasRf = (hexFlags?.rf ?? false) || typeFlags.hasRf;
70432
70506
  const hasOther = (hexFlags?.aiOther ?? false) || typeFlags.hasOther;
70433
- require_chunk_KWWUCNIY.recordingsTraceLog(this.debugConfig, this.logger, "enrichVodFile", `Final merged flags: ${JSON.stringify({
70507
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugConfig, this.logger, "enrichVodFile", `Final merged flags: ${JSON.stringify({
70434
70508
  hasPerson,
70435
70509
  hasVehicle,
70436
70510
  hasAnimal,
@@ -70836,8 +70910,8 @@ function nowIsoCompact() {
70836
70910
  return (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
70837
70911
  }
70838
70912
  function nalTypesSummary(videoType, accessUnitAnnexB) {
70839
- if (videoType === "H264") return require_chunk_KWWUCNIY.splitAnnexBToNalPayloads(accessUnitAnnexB).map((n) => (n[0] ?? 0) & 31);
70840
- return require_chunk_KWWUCNIY.splitAnnexBToNalPayloads2(accessUnitAnnexB).map((nal) => require_chunk_KWWUCNIY.getH265NalType(nal)).filter((t) => typeof t === "number");
70913
+ if (videoType === "H264") return require_chunk_ZQFQRCLQ.splitAnnexBToNalPayloads(accessUnitAnnexB).map((n) => (n[0] ?? 0) & 31);
70914
+ return require_chunk_ZQFQRCLQ.splitAnnexBToNalPayloads2(accessUnitAnnexB).map((nal) => require_chunk_ZQFQRCLQ.getH265NalType(nal)).filter((t) => typeof t === "number");
70841
70915
  }
70842
70916
  function normalizeProfiles(p) {
70843
70917
  const out = [];
@@ -71277,7 +71351,7 @@ async function sampleStreams(opts) {
71277
71351
  });
71278
71352
  };
71279
71353
  api.client.on("frame", onFrame);
71280
- const videoStream = new require_chunk_KWWUCNIY.BaichuanVideoStream({
71354
+ const videoStream = new require_chunk_ZQFQRCLQ.BaichuanVideoStream({
71281
71355
  client: api.client,
71282
71356
  api,
71283
71357
  channel,
@@ -72327,7 +72401,7 @@ async function runMultifocalDiagnosticsConsecutively(params) {
72327
72401
  let audioFrames = 0;
72328
72402
  let lastSnapshotAtMs = 0;
72329
72403
  const client = params.api.client;
72330
- const videoStream = new require_chunk_KWWUCNIY.BaichuanVideoStream({
72404
+ const videoStream = new require_chunk_ZQFQRCLQ.BaichuanVideoStream({
72331
72405
  client,
72332
72406
  channel: chNative,
72333
72407
  profile,
@@ -72411,7 +72485,7 @@ async function runMultifocalDiagnosticsConsecutively(params) {
72411
72485
  const baseStreamName = profile === "main" ? "mainStream" : profile === "sub" ? "subStream" : "externStream";
72412
72486
  const headerStreamTypeCandidates = profile === "sub" ? [1, 3] : profile === "main" ? [0, 2] : [0];
72413
72487
  const channelIdTagCandidates = uniq([chNative, chNative + 1].filter((n) => Number.isFinite(n) && n >= 0));
72414
- const messageClassCandidates = params.probeFull ? [require_chunk_KWWUCNIY.BC_CLASS_MODERN_24, 0] : [require_chunk_KWWUCNIY.BC_CLASS_MODERN_24];
72488
+ const messageClassCandidates = params.probeFull ? [require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24, 0] : [require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24];
72415
72489
  const extensionXmlCandidates = params.probeFull ? ["", buildChannelExtensionXml(chNative)] : [buildChannelExtensionXml(chNative)];
72416
72490
  const attempts = [];
72417
72491
  for (const messageClass of messageClassCandidates) for (const streamTypeHeader of headerStreamTypeCandidates) for (const extensionXml of extensionXmlCandidates) {
@@ -74932,14 +75006,14 @@ var require_lz4 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
74932
75006
  };
74933
75007
  }));
74934
75008
  //#endregion
74935
- //#region node_modules/@apocaliss92/nodelink-js/dist/chunk-3SEJZ2U5.js
75009
+ //#region node_modules/@apocaliss92/nodelink-js/dist/chunk-CE77DTET.js
74936
75010
  var import_fxp = require_fxp();
74937
75011
  var import_lz4 = /* @__PURE__ */ require_chunk.__toESM(require_lz4(), 1);
74938
75012
  function encodeHeader(h) {
74939
- const hasOffset = require_chunk_KWWUCNIY.bcHeaderHasPayloadOffset(h.messageClass);
75013
+ const hasOffset = require_chunk_ZQFQRCLQ.bcHeaderHasPayloadOffset(h.messageClass);
74940
75014
  const headerLen = hasOffset ? 24 : 20;
74941
75015
  const buf = Buffer.alloc(headerLen);
74942
- const magic = h.magic ?? require_chunk_KWWUCNIY.BC_MAGIC;
75016
+ const magic = h.magic ?? require_chunk_ZQFQRCLQ.BC_MAGIC;
74943
75017
  if (magic.length !== 4) throw new Error("magic must be 4 bytes");
74944
75018
  magic.copy(buf, 0);
74945
75019
  buf.writeUInt32LE(h.cmdId >>> 0, 4);
@@ -74955,7 +75029,7 @@ function encodeHeader(h) {
74955
75029
  function decodeHeader(buf) {
74956
75030
  if (buf.length < 20) throw new Error("not enough data for Baichuan header");
74957
75031
  const magic = buf.subarray(0, 4);
74958
- if (!magic.equals(require_chunk_KWWUCNIY.BC_MAGIC) && !magic.equals(require_chunk_KWWUCNIY.BC_MAGIC_REV)) throw new Error(`invalid Baichuan magic: ${magic.toString("hex")}`);
75032
+ if (!magic.equals(require_chunk_ZQFQRCLQ.BC_MAGIC) && !magic.equals(require_chunk_ZQFQRCLQ.BC_MAGIC_REV)) throw new Error(`invalid Baichuan magic: ${magic.toString("hex")}`);
74959
75033
  const cmdId = buf.readUInt32LE(4);
74960
75034
  const bodyLen = buf.readUInt32LE(8);
74961
75035
  const channelId = buf.readUInt8(12);
@@ -74963,7 +75037,7 @@ function decodeHeader(buf) {
74963
75037
  const msgNum = buf.readUInt16LE(14);
74964
75038
  const responseCode = buf.readUInt16LE(16);
74965
75039
  const messageClass = buf.readUInt16LE(18);
74966
- const headerLen = require_chunk_KWWUCNIY.bcHeaderHasPayloadOffset(messageClass) ? 24 : 20;
75040
+ const headerLen = require_chunk_ZQFQRCLQ.bcHeaderHasPayloadOffset(messageClass) ? 24 : 20;
74967
75041
  if (buf.length < headerLen) throw new Error("not enough data for Baichuan header (needs 24 bytes)");
74968
75042
  const messageKey = buf.readUInt32LE(12);
74969
75043
  const header = {
@@ -75033,9 +75107,9 @@ var BaichuanFrameParser = class {
75033
75107
  this.needed = 4;
75034
75108
  break;
75035
75109
  }
75036
- if (!this.buffer.subarray(0, 4).equals(require_chunk_KWWUCNIY.BC_MAGIC) && !this.buffer.subarray(0, 4).equals(require_chunk_KWWUCNIY.BC_MAGIC_REV)) {
75037
- const idx = this.buffer.indexOf(require_chunk_KWWUCNIY.BC_MAGIC);
75038
- const idxRev = this.buffer.indexOf(require_chunk_KWWUCNIY.BC_MAGIC_REV);
75110
+ if (!this.buffer.subarray(0, 4).equals(require_chunk_ZQFQRCLQ.BC_MAGIC) && !this.buffer.subarray(0, 4).equals(require_chunk_ZQFQRCLQ.BC_MAGIC_REV)) {
75111
+ const idx = this.buffer.indexOf(require_chunk_ZQFQRCLQ.BC_MAGIC);
75112
+ const idxRev = this.buffer.indexOf(require_chunk_ZQFQRCLQ.BC_MAGIC_REV);
75039
75113
  const next = idx === -1 ? idxRev : idxRev === -1 ? idx : Math.min(idx, idxRev);
75040
75114
  if (next === -1) {
75041
75115
  this.buffer = this.buffer.subarray(Math.max(0, this.buffer.length - 3));
@@ -75251,8 +75325,8 @@ function buildC2mQ(params) {
75251
75325
  const os$5 = params.os ?? "MAC";
75252
75326
  return buildP2pXml(`<C2M_Q><uid>${xmlEscape(params.uid)}</uid><p>${xmlEscape(os$5)}</p></C2M_Q>`);
75253
75327
  }
75254
- function parseIpPortBlock(tag, body) {
75255
- const m = new RegExp(`<${tag}>([\\s\\S]*?)</${tag}>`, "i").exec(body);
75328
+ function parseIpPortBlock(tag2, body) {
75329
+ const m = new RegExp(`<${tag2}>([\\s\\S]*?)</${tag2}>`, "i").exec(body);
75256
75330
  if (!m) return void 0;
75257
75331
  const block = m[1] ?? "";
75258
75332
  const ip = /<ip>([^<]+)<\/ip>/i.exec(block)?.[1];
@@ -75297,8 +75371,8 @@ function parseR2cCr(xml) {
75297
75371
  if (!Number.isFinite(rsp)) return void 0;
75298
75372
  const sidStr = /<sid>(-?\d+)<\/sid>/i.exec(body)?.[1];
75299
75373
  const sid = sidStr != null ? Number(sidStr) : void 0;
75300
- const parseCustom = (tag) => {
75301
- const mm = new RegExp(`<${tag}>([\\s\\S]*?)</${tag}>`, "i").exec(body);
75374
+ const parseCustom = (tag2) => {
75375
+ const mm = new RegExp(`<${tag2}>([\\s\\S]*?)</${tag2}>`, "i").exec(body);
75302
75376
  if (!mm) return void 0;
75303
75377
  const block = mm[1] ?? "";
75304
75378
  const ip = /<ip>([^<]+)<\/ip>/i.exec(block)?.[1];
@@ -76858,12 +76932,12 @@ function asLogger(logger) {
76858
76932
  error: resolveMethod(base, "error"),
76859
76933
  debug: resolveMethod(base, "debug")
76860
76934
  };
76861
- out.child = (tag) => createTaggedLogger(out, tag);
76935
+ out.child = (tag2) => createTaggedLogger(out, tag2);
76862
76936
  return out;
76863
76937
  }
76864
- function createTaggedLogger(base, tag) {
76938
+ function createTaggedLogger(base, tag2) {
76865
76939
  const b = base.log ? base : asLogger(base);
76866
- const prefix = `[${tag}] `;
76940
+ const prefix = `[${tag2}] `;
76867
76941
  const wrap = (fn) => {
76868
76942
  return (message, ...optionalParams) => {
76869
76943
  if (typeof message === "string") fn(`${prefix}${message}`, ...optionalParams);
@@ -76890,7 +76964,7 @@ function createDebugGateLogger(base, enabled = false) {
76890
76964
  error: b.error,
76891
76965
  debug: enabled ? b.debug : noop
76892
76966
  };
76893
- out.child = (tag) => createDebugGateLogger(createTaggedLogger(out, tag), enabled);
76967
+ out.child = (tag2) => createDebugGateLogger(createTaggedLogger(out, tag2), enabled);
76894
76968
  return out;
76895
76969
  }
76896
76970
  function isTalkCmd(cmdId) {
@@ -77050,7 +77124,7 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
77050
77124
  constructor(options) {
77051
77125
  super();
77052
77126
  this.opts = options;
77053
- this.debugCfg = require_chunk_KWWUCNIY.normalizeDebugOptions(options.debugOptions);
77127
+ this.debugCfg = require_chunk_ZQFQRCLQ.normalizeDebugOptions(options.debugOptions);
77054
77128
  this.logger = createDebugGateLogger(options.logger, this.debugCfg.general || this.debugCfg.traceNativeStream || this.debugCfg.traceRecordings || this.debugCfg.traceTalk || this.debugCfg.traceEvents || this.debugCfg.debugRtsp);
77055
77129
  this.on("error", (err) => {
77056
77130
  this.logFixed("error", {
@@ -77532,7 +77606,7 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
77532
77606
  streamType: 0,
77533
77607
  msgNum,
77534
77608
  responseCode: 0,
77535
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
77609
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
77536
77610
  payloadOffset: 0
77537
77611
  });
77538
77612
  this.logDebug("udp_keepalive_ping_tx", {
@@ -77564,7 +77638,7 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
77564
77638
  cmdId: 93,
77565
77639
  channel: this.opts.channel ?? 0,
77566
77640
  channelIdOverride: 0,
77567
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
77641
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
77568
77642
  streamType: 0,
77569
77643
  extensionXml: "",
77570
77644
  internal: true
@@ -77903,7 +77977,7 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
77903
77977
  cmdId: 2,
77904
77978
  payloadXml: logoutXml,
77905
77979
  extensionXml: "",
77906
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
77980
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
77907
77981
  channelIdOverride: effectiveHostChannelId,
77908
77982
  timeoutMs: 5e3
77909
77983
  })).header.responseCode;
@@ -78016,12 +78090,12 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
78016
78090
  };
78017
78091
  s.frames++;
78018
78092
  if (now - s.lastLogMs >= 1e3) {
78019
- require_chunk_KWWUCNIY.debugLog(this.debugCfg, this.logger, "BaichuanRx", `rx cmdId=3 frames=${s.frames} lastMsgNum=${frame.header.msgNum} lastResponseCode=${frame.header.responseCode} lastChannelId=${frame.header.channelId} lastStreamType=${frame.header.streamType} lastBodyLen=${frame.body.length} lastPayloadLen=${frame.payload.length}`);
78093
+ require_chunk_ZQFQRCLQ.debugLog(this.debugCfg, this.logger, "BaichuanRx", `rx cmdId=3 frames=${s.frames} lastMsgNum=${frame.header.msgNum} lastResponseCode=${frame.header.responseCode} lastChannelId=${frame.header.channelId} lastStreamType=${frame.header.streamType} lastBodyLen=${frame.body.length} lastPayloadLen=${frame.payload.length}`);
78020
78094
  s.lastLogMs = now;
78021
78095
  s.frames = 0;
78022
78096
  }
78023
78097
  this.rxCmdTraceStats.set(3, s);
78024
- } else require_chunk_KWWUCNIY.debugLog(this.debugCfg, this.logger, "BaichuanRx", `rx cmdId=${frame.header.cmdId} msgNum=${frame.header.msgNum} responseCode=${frame.header.responseCode} channelId=${frame.header.channelId} streamType=${frame.header.streamType} bodyLen=${frame.body.length} payloadLen=${frame.payload.length} payloadOffset=${frame.header.payloadOffset ?? 0}`);
78098
+ } else require_chunk_ZQFQRCLQ.debugLog(this.debugCfg, this.logger, "BaichuanRx", `rx cmdId=${frame.header.cmdId} msgNum=${frame.header.msgNum} responseCode=${frame.header.responseCode} channelId=${frame.header.channelId} streamType=${frame.header.streamType} bodyLen=${frame.body.length} payloadLen=${frame.payload.length} payloadOffset=${frame.header.payloadOffset ?? 0}`);
78025
78099
  if (this.transport === "udp" && frame.header.cmdId === 234) {
78026
78100
  try {
78027
78101
  const header = encodeHeader({
@@ -78058,7 +78132,7 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
78058
78132
  }
78059
78133
  return;
78060
78134
  }
78061
- if (this.debugCfg.traceTalk && isTalkCmd(frame.header.cmdId)) require_chunk_KWWUCNIY.talkTraceLog(this.debugCfg, this.logger, "BaichuanTalk", `rx cmdId=${frame.header.cmdId} msgNum=${frame.header.msgNum} responseCode=${frame.header.responseCode} channelId=${frame.header.channelId} bodyLen=${frame.body.length} payloadLen=${frame.payload.length} payloadOffset=${frame.header.payloadOffset ?? 0}`);
78135
+ if (this.debugCfg.traceTalk && isTalkCmd(frame.header.cmdId)) require_chunk_ZQFQRCLQ.talkTraceLog(this.debugCfg, this.logger, "BaichuanTalk", `rx cmdId=${frame.header.cmdId} msgNum=${frame.header.msgNum} responseCode=${frame.header.responseCode} channelId=${frame.header.channelId} bodyLen=${frame.body.length} payloadLen=${frame.payload.length} payloadOffset=${frame.header.payloadOffset ?? 0}`);
78062
78136
  this.emit("frame", frame);
78063
78137
  const key = `${frame.header.cmdId}:${frame.header.msgNum}`;
78064
78138
  const pending = this.pending.get(key);
@@ -78079,7 +78153,7 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
78079
78153
  };
78080
78154
  s.frames++;
78081
78155
  if (now2 - s.lastLogMs >= 500) {
78082
- require_chunk_KWWUCNIY.traceLog(this.debugCfg, this.logger, "BaichuanTrace", `rx stream frames cmdId=3 msgNum=${frame.header.msgNum} frames=${s.frames} lastChannelId=${frame.header.channelId} lastBodyLen=${frame.body.length} lastPayloadLen=${frame.payload.length} lastPayloadOffset=${frame.header.payloadOffset ?? 0}`);
78156
+ require_chunk_ZQFQRCLQ.traceLog(this.debugCfg, this.logger, "BaichuanTrace", `rx stream frames cmdId=3 msgNum=${frame.header.msgNum} frames=${s.frames} lastChannelId=${frame.header.channelId} lastBodyLen=${frame.body.length} lastPayloadLen=${frame.payload.length} lastPayloadOffset=${frame.header.payloadOffset ?? 0}`);
78083
78157
  s.lastLogMs = now2;
78084
78158
  s.frames = 0;
78085
78159
  }
@@ -78110,7 +78184,7 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
78110
78184
  const eventLogTag = sid ? `BaichuanEvent sid=${sid}` : "BaichuanEvent";
78111
78185
  const events$1 = this.parseEvents(frame);
78112
78186
  for (const event of events$1) {
78113
- require_chunk_KWWUCNIY.eventTraceLog(this.debugCfg, this.logger, eventLogTag, `dispatch cmdId=33 msgNum=${frame.header.msgNum} channelId=${frame.header.channelId} type=${event.type} eventChannel=${event.channel}` + (event.type === "ai" ? ` aiType=${event.ai?.type ?? "unknown"} detected=${event.ai?.detected ?? ""}` : "") + (event.type === "motion" ? ` source=${event.motion?.source ?? ""}` : ""));
78187
+ require_chunk_ZQFQRCLQ.eventTraceLog(this.debugCfg, this.logger, eventLogTag, `dispatch cmdId=33 msgNum=${frame.header.msgNum} channelId=${frame.header.channelId} type=${event.type} eventChannel=${event.channel}` + (event.type === "ai" ? ` aiType=${event.ai?.type ?? "unknown"} detected=${event.ai?.detected ?? ""}` : "") + (event.type === "motion" ? ` source=${event.motion?.source ?? ""}` : ""));
78114
78188
  this.emit("event", event);
78115
78189
  }
78116
78190
  } catch (error) {
@@ -78169,7 +78243,7 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
78169
78243
  if (!xml || !xml.startsWith("<?xml")) return [];
78170
78244
  if (this.debugCfg.traceEvents) {
78171
78245
  const snippet = xml.length > 500 ? `${xml.slice(0, 500)}...` : xml;
78172
- require_chunk_KWWUCNIY.eventTraceLog(this.debugCfg, this.logger, eventRawLogTag, `rx cmdId=${frame.header.cmdId} msgNum=${frame.header.msgNum} responseCode=${frame.header.responseCode} channelId=${frame.header.channelId} xml=${JSON.stringify(snippet)}`);
78246
+ require_chunk_ZQFQRCLQ.eventTraceLog(this.debugCfg, this.logger, eventRawLogTag, `rx cmdId=${frame.header.cmdId} msgNum=${frame.header.msgNum} responseCode=${frame.header.responseCode} channelId=${frame.header.channelId} xml=${JSON.stringify(snippet)}`);
78173
78247
  }
78174
78248
  const fallbackChannelId = frame.header.channelId;
78175
78249
  const fallbackChannel = fallbackChannelId === 250 ? 0 : Math.max(0, fallbackChannelId - 1);
@@ -78187,7 +78261,7 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
78187
78261
  const timeStampRaw2 = (getXmlText(alarmXml, "timeStamp") ?? getXmlText(alarmXml, "timestamp") ?? "").trim();
78188
78262
  const timeStampNum2 = timeStampRaw2.length ? Number(timeStampRaw2) : void 0;
78189
78263
  const alarmTimeStamp2 = Number.isFinite(timeStampNum2) ? timeStampNum2 : void 0;
78190
- if (this.debugCfg.traceEvents) require_chunk_KWWUCNIY.eventTraceLog(this.debugCfg, this.logger, eventRawLogTag, `AlarmEvent channel=${channel} status=${JSON.stringify(status2)} aiType=${JSON.stringify(aiTypeRaw2)}`);
78264
+ if (this.debugCfg.traceEvents) require_chunk_ZQFQRCLQ.eventTraceLog(this.debugCfg, this.logger, eventRawLogTag, `AlarmEvent channel=${channel} status=${JSON.stringify(status2)} aiType=${JSON.stringify(aiTypeRaw2)}`);
78191
78265
  const statusTokens2 = status2.toLowerCase().split(",").map((t) => t.trim()).filter((t) => t.length > 0);
78192
78266
  const visitorActive2 = statusTokens2.includes("visitor");
78193
78267
  const dayNightActive2 = statusTokens2.includes("dn") || statusTokens2.includes("daynight");
@@ -78461,15 +78535,15 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
78461
78535
  const extBuf = Buffer.from(extXml, "utf8");
78462
78536
  const payloadBuf = Buffer.from(payloadXml, "utf8");
78463
78537
  if (enc.kind === "none") return Buffer.concat([extBuf, payloadBuf]);
78464
- if (enc.kind === "bc") return Buffer.concat([require_chunk_KWWUCNIY.bcEncrypt(extBuf, channelId), require_chunk_KWWUCNIY.bcEncrypt(payloadBuf, channelId)]);
78465
- if (enc.kind === "aes" || enc.kind === "full_aes") return Buffer.concat([require_chunk_KWWUCNIY.aesEncrypt(extBuf, enc.key), require_chunk_KWWUCNIY.aesEncrypt(payloadBuf, enc.key)]);
78538
+ if (enc.kind === "bc") return Buffer.concat([require_chunk_ZQFQRCLQ.bcEncrypt(extBuf, channelId), require_chunk_ZQFQRCLQ.bcEncrypt(payloadBuf, channelId)]);
78539
+ if (enc.kind === "aes" || enc.kind === "full_aes") return Buffer.concat([require_chunk_ZQFQRCLQ.aesEncrypt(extBuf, enc.key), require_chunk_ZQFQRCLQ.aesEncrypt(payloadBuf, enc.key)]);
78466
78540
  return Buffer.concat([extBuf, payloadBuf]);
78467
78541
  }
78468
78542
  encodeBodyBinary(extXml, payload, channelId, enc) {
78469
78543
  const extBuf = Buffer.from(extXml, "utf8");
78470
78544
  if (enc.kind === "none") return Buffer.concat([extBuf, payload]);
78471
- if (enc.kind === "bc") return Buffer.concat([require_chunk_KWWUCNIY.bcEncrypt(extBuf, channelId), payload]);
78472
- if (enc.kind === "aes" || enc.kind === "full_aes") return Buffer.concat([require_chunk_KWWUCNIY.aesEncrypt(extBuf, enc.key), payload]);
78545
+ if (enc.kind === "bc") return Buffer.concat([require_chunk_ZQFQRCLQ.bcEncrypt(extBuf, channelId), payload]);
78546
+ if (enc.kind === "aes" || enc.kind === "full_aes") return Buffer.concat([require_chunk_ZQFQRCLQ.aesEncrypt(extBuf, enc.key), payload]);
78473
78547
  return Buffer.concat([extBuf, payload]);
78474
78548
  }
78475
78549
  /**
@@ -78514,7 +78588,7 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
78514
78588
  bodyLen,
78515
78589
  binaryPayload: true
78516
78590
  });
78517
- if (this.debugCfg.traceTalk && isTalkCmd(cmdId)) require_chunk_KWWUCNIY.talkTraceLog(this.debugCfg, this.logger, "BaichuanTalk", `tx cmdId=${cmdId} msgNum=${msgNum} channelId=${channelId} streamType=${params.streamType ?? 0} class=0x${messageClass.toString(16)} bodyLen=${bodyLen} payloadOffset=${payloadOffset} binaryPayloadLen=${params.payload.length}`);
78591
+ if (this.debugCfg.traceTalk && isTalkCmd(cmdId)) require_chunk_ZQFQRCLQ.talkTraceLog(this.debugCfg, this.logger, "BaichuanTalk", `tx cmdId=${cmdId} msgNum=${msgNum} channelId=${channelId} streamType=${params.streamType ?? 0} class=0x${messageClass.toString(16)} bodyLen=${bodyLen} payloadOffset=${payloadOffset} binaryPayloadLen=${params.payload.length}`);
78518
78592
  this.recordTx({
78519
78593
  cmdId,
78520
78594
  responseCode: 0,
@@ -78531,8 +78605,8 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
78531
78605
  let dec;
78532
78606
  try {
78533
78607
  if (enc.kind === "none") dec = buf;
78534
- else if (enc.kind === "bc") dec = require_chunk_KWWUCNIY.bcDecrypt(buf, channelId);
78535
- else dec = require_chunk_KWWUCNIY.aesDecrypt(buf, enc.key);
78608
+ else if (enc.kind === "bc") dec = require_chunk_ZQFQRCLQ.bcDecrypt(buf, channelId);
78609
+ else dec = require_chunk_ZQFQRCLQ.aesDecrypt(buf, enc.key);
78536
78610
  } catch {
78537
78611
  return;
78538
78612
  }
@@ -78598,8 +78672,8 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
78598
78672
  messageClass,
78599
78673
  bodyLen
78600
78674
  });
78601
- if (this.debugCfg.traceNativeStream && (cmdId === 3 || cmdId === 4)) require_chunk_KWWUCNIY.traceLog(this.debugCfg, this.logger, "BaichuanTrace", `tx cmdId=${cmdId} msgNum=${msgNum} channelId=${channelId} streamType=${params.streamType ?? 0} class=0x${messageClass.toString(16)} bodyLen=${bodyLen} payloadOffset=${payloadOffset}`);
78602
- if (this.debugCfg.traceTalk && isTalkCmd(cmdId)) require_chunk_KWWUCNIY.talkTraceLog(this.debugCfg, this.logger, "BaichuanTalk", `tx cmdId=${cmdId} msgNum=${msgNum} channelId=${channelId} streamType=${params.streamType ?? 0} class=0x${messageClass.toString(16)} bodyLen=${bodyLen} payloadOffset=${payloadOffset}`);
78675
+ if (this.debugCfg.traceNativeStream && (cmdId === 3 || cmdId === 4)) require_chunk_ZQFQRCLQ.traceLog(this.debugCfg, this.logger, "BaichuanTrace", `tx cmdId=${cmdId} msgNum=${msgNum} channelId=${channelId} streamType=${params.streamType ?? 0} class=0x${messageClass.toString(16)} bodyLen=${bodyLen} payloadOffset=${payloadOffset}`);
78676
+ if (this.debugCfg.traceTalk && isTalkCmd(cmdId)) require_chunk_ZQFQRCLQ.talkTraceLog(this.debugCfg, this.logger, "BaichuanTalk", `tx cmdId=${cmdId} msgNum=${msgNum} channelId=${channelId} streamType=${params.streamType ?? 0} class=0x${messageClass.toString(16)} bodyLen=${bodyLen} payloadOffset=${payloadOffset}`);
78603
78677
  this.recordTx({
78604
78678
  cmdId,
78605
78679
  responseCode: 0,
@@ -78614,8 +78688,8 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
78614
78688
  responseCode: frame.header.responseCode,
78615
78689
  msgNum: frame.header.msgNum
78616
78690
  });
78617
- if (this.debugCfg.traceNativeStream && (cmdId === 3 || cmdId === 4)) require_chunk_KWWUCNIY.traceLog(this.debugCfg, this.logger, "BaichuanTrace", `rx cmdId=${frame.header.cmdId} msgNum=${frame.header.msgNum} responseCode=${frame.header.responseCode} channelId=${frame.header.channelId} bodyLen=${frame.body.length} payloadLen=${frame.payload.length} payloadOffset=${frame.header.payloadOffset ?? 0}`);
78618
- if (this.debugCfg.traceTalk && isTalkCmd(cmdId)) require_chunk_KWWUCNIY.talkTraceLog(this.debugCfg, this.logger, "BaichuanTalk", `rx cmdId=${frame.header.cmdId} msgNum=${frame.header.msgNum} responseCode=${frame.header.responseCode} channelId=${frame.header.channelId} bodyLen=${frame.body.length} payloadLen=${frame.payload.length} payloadOffset=${frame.header.payloadOffset ?? 0}`);
78691
+ if (this.debugCfg.traceNativeStream && (cmdId === 3 || cmdId === 4)) require_chunk_ZQFQRCLQ.traceLog(this.debugCfg, this.logger, "BaichuanTrace", `rx cmdId=${frame.header.cmdId} msgNum=${frame.header.msgNum} responseCode=${frame.header.responseCode} channelId=${frame.header.channelId} bodyLen=${frame.body.length} payloadLen=${frame.payload.length} payloadOffset=${frame.header.payloadOffset ?? 0}`);
78692
+ if (this.debugCfg.traceTalk && isTalkCmd(cmdId)) require_chunk_ZQFQRCLQ.talkTraceLog(this.debugCfg, this.logger, "BaichuanTalk", `rx cmdId=${frame.header.cmdId} msgNum=${frame.header.msgNum} responseCode=${frame.header.responseCode} channelId=${frame.header.channelId} bodyLen=${frame.body.length} payloadLen=${frame.payload.length} payloadOffset=${frame.header.payloadOffset ?? 0}`);
78619
78693
  if (frame.header.responseCode === 400) {
78620
78694
  if (frame.body.length === 0) throw new Error("Baichuan authentication failed (responseCode 400, empty body) - check username/password");
78621
78695
  }
@@ -78685,9 +78759,9 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
78685
78759
  messageClass,
78686
78760
  bodyLen
78687
78761
  });
78688
- if (_BaichuanClient.recordingCmdIds.has(cmdId)) require_chunk_KWWUCNIY.recordingsTraceLog(this.debugCfg, this.logger, "BaichuanRecordings", `tx recording cmdId=${cmdId} msgNum=${msgNum} channelId=${channelId} streamType=${params.streamType ?? 0} bodyLen=${bodyLen}`);
78689
- if (this.debugCfg.traceNativeStream && (cmdId === 3 || cmdId === 4)) require_chunk_KWWUCNIY.traceLog(this.debugCfg, this.logger, "BaichuanTrace", `tx cmdId=${cmdId} msgNum=${msgNum} channelId=${channelId} streamType=${params.streamType ?? 0} class=0x${messageClass.toString(16)} bodyLen=${bodyLen} payloadOffset=${payloadOffset}`);
78690
- if (this.debugCfg.traceTalk && isTalkCmd(cmdId)) require_chunk_KWWUCNIY.talkTraceLog(this.debugCfg, this.logger, "BaichuanTalk", `tx cmdId=${cmdId} msgNum=${msgNum} channelId=${channelId} streamType=${params.streamType ?? 0} class=0x${messageClass.toString(16)} bodyLen=${bodyLen} payloadOffset=${payloadOffset}`);
78762
+ if (_BaichuanClient.recordingCmdIds.has(cmdId)) require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugCfg, this.logger, "BaichuanRecordings", `tx recording cmdId=${cmdId} msgNum=${msgNum} channelId=${channelId} streamType=${params.streamType ?? 0} bodyLen=${bodyLen}`);
78763
+ if (this.debugCfg.traceNativeStream && (cmdId === 3 || cmdId === 4)) require_chunk_ZQFQRCLQ.traceLog(this.debugCfg, this.logger, "BaichuanTrace", `tx cmdId=${cmdId} msgNum=${msgNum} channelId=${channelId} streamType=${params.streamType ?? 0} class=0x${messageClass.toString(16)} bodyLen=${bodyLen} payloadOffset=${payloadOffset}`);
78764
+ if (this.debugCfg.traceTalk && isTalkCmd(cmdId)) require_chunk_ZQFQRCLQ.talkTraceLog(this.debugCfg, this.logger, "BaichuanTalk", `tx cmdId=${cmdId} msgNum=${msgNum} channelId=${channelId} streamType=${params.streamType ?? 0} class=0x${messageClass.toString(16)} bodyLen=${bodyLen} payloadOffset=${payloadOffset}`);
78691
78765
  this.recordTx({
78692
78766
  cmdId,
78693
78767
  responseCode: 0,
@@ -78702,9 +78776,9 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
78702
78776
  responseCode: frame.header.responseCode,
78703
78777
  msgNum: frame.header.msgNum
78704
78778
  });
78705
- if (_BaichuanClient.recordingCmdIds.has(frame.header.cmdId)) require_chunk_KWWUCNIY.recordingsTraceLog(this.debugCfg, this.logger, "BaichuanRecordings", `rx recording cmdId=${frame.header.cmdId} msgNum=${frame.header.msgNum} responseCode=${frame.header.responseCode} channelId=${frame.header.channelId} bodyLen=${frame.body.length} payloadLen=${frame.payload.length} payloadOffset=${frame.header.payloadOffset ?? 0}`);
78706
- if (this.debugCfg.traceNativeStream && (cmdId === 3 || cmdId === 4)) require_chunk_KWWUCNIY.traceLog(this.debugCfg, this.logger, "BaichuanTrace", `rx cmdId=${frame.header.cmdId} msgNum=${frame.header.msgNum} responseCode=${frame.header.responseCode} channelId=${frame.header.channelId} bodyLen=${frame.body.length} payloadLen=${frame.payload.length} payloadOffset=${frame.header.payloadOffset ?? 0}`);
78707
- if (this.debugCfg.traceTalk && isTalkCmd(cmdId)) require_chunk_KWWUCNIY.talkTraceLog(this.debugCfg, this.logger, "BaichuanTalk", `rx cmdId=${frame.header.cmdId} msgNum=${frame.header.msgNum} responseCode=${frame.header.responseCode} channelId=${frame.header.channelId} bodyLen=${frame.body.length} payloadLen=${frame.payload.length} payloadOffset=${frame.header.payloadOffset ?? 0}`);
78779
+ if (_BaichuanClient.recordingCmdIds.has(frame.header.cmdId)) require_chunk_ZQFQRCLQ.recordingsTraceLog(this.debugCfg, this.logger, "BaichuanRecordings", `rx recording cmdId=${frame.header.cmdId} msgNum=${frame.header.msgNum} responseCode=${frame.header.responseCode} channelId=${frame.header.channelId} bodyLen=${frame.body.length} payloadLen=${frame.payload.length} payloadOffset=${frame.header.payloadOffset ?? 0}`);
78780
+ if (this.debugCfg.traceNativeStream && (cmdId === 3 || cmdId === 4)) require_chunk_ZQFQRCLQ.traceLog(this.debugCfg, this.logger, "BaichuanTrace", `rx cmdId=${frame.header.cmdId} msgNum=${frame.header.msgNum} responseCode=${frame.header.responseCode} channelId=${frame.header.channelId} bodyLen=${frame.body.length} payloadLen=${frame.payload.length} payloadOffset=${frame.header.payloadOffset ?? 0}`);
78781
+ if (this.debugCfg.traceTalk && isTalkCmd(cmdId)) require_chunk_ZQFQRCLQ.talkTraceLog(this.debugCfg, this.logger, "BaichuanTalk", `rx cmdId=${frame.header.cmdId} msgNum=${frame.header.msgNum} responseCode=${frame.header.responseCode} channelId=${frame.header.channelId} bodyLen=${frame.body.length} payloadLen=${frame.payload.length} payloadOffset=${frame.header.payloadOffset ?? 0}`);
78708
78782
  if (!internal) this.kickIdleDisconnectTimer();
78709
78783
  return frame;
78710
78784
  }
@@ -79526,8 +79600,8 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
79526
79600
  const tryAs = (enc) => {
79527
79601
  try {
79528
79602
  if (enc.kind === "none") return buf;
79529
- if (enc.kind === "bc") return require_chunk_KWWUCNIY.bcDecrypt(buf, channelId);
79530
- if (enc.kind === "aes" || enc.kind === "full_aes") return require_chunk_KWWUCNIY.aesDecrypt(buf, enc.key);
79603
+ if (enc.kind === "bc") return require_chunk_ZQFQRCLQ.bcDecrypt(buf, channelId);
79604
+ if (enc.kind === "aes" || enc.kind === "full_aes") return require_chunk_ZQFQRCLQ.aesDecrypt(buf, enc.key);
79531
79605
  return null;
79532
79606
  } catch {
79533
79607
  return null;
@@ -79557,7 +79631,7 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
79557
79631
  streamType: 0,
79558
79632
  msgNum,
79559
79633
  responseCode: encByte,
79560
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_LEGACY
79634
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_LEGACY
79561
79635
  });
79562
79636
  const pendingKey = `${cmdId}:${msgNum}`;
79563
79637
  const framePromise = new Promise((resolve, reject) => {
@@ -79589,15 +79663,15 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
79589
79663
  else if (encType === 1) this.enc = { kind: "bc" };
79590
79664
  else if (encType === 2) this.enc = {
79591
79665
  kind: "aes",
79592
- key: require_chunk_KWWUCNIY.deriveAesKey(nonce, this.opts.password)
79666
+ key: require_chunk_ZQFQRCLQ.deriveAesKey(nonce, this.opts.password)
79593
79667
  };
79594
79668
  else if (encType === 18) this.enc = {
79595
79669
  kind: "full_aes",
79596
- key: require_chunk_KWWUCNIY.deriveAesKey(nonce, this.opts.password)
79670
+ key: require_chunk_ZQFQRCLQ.deriveAesKey(nonce, this.opts.password)
79597
79671
  };
79598
79672
  else throw new Error(`Baichuan login: unknown encType=0x${encType.toString(16)}`);
79599
- const userHash = require_chunk_KWWUCNIY.md5StrModern(`${this.opts.username}${nonce}`);
79600
- const passHash = require_chunk_KWWUCNIY.md5StrModern(`${this.opts.password}${nonce}`);
79673
+ const userHash = require_chunk_ZQFQRCLQ.md5StrModern(`${this.opts.username}${nonce}`);
79674
+ const passHash = require_chunk_ZQFQRCLQ.md5StrModern(`${this.opts.password}${nonce}`);
79601
79675
  const loginXml = buildLoginXml(userHash, passHash);
79602
79676
  this.logDebug("login_hash", {
79603
79677
  username: this.opts.username,
@@ -79612,7 +79686,7 @@ var BaichuanClient = class _BaichuanClient extends events.EventEmitter {
79612
79686
  cmdId: 1,
79613
79687
  payloadXml: loginXml,
79614
79688
  extensionXml: "",
79615
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
79689
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
79616
79690
  channelIdOverride: effectiveHostChannelId,
79617
79691
  encryption: loginEnc,
79618
79692
  timeoutMs: 1e4
@@ -79672,7 +79746,7 @@ async function* createNativeStream(api, channel, profile, options) {
79672
79746
  client = api.client;
79673
79747
  }
79674
79748
  }
79675
- const videoStream = new require_chunk_KWWUCNIY.BaichuanVideoStream({
79749
+ const videoStream = new require_chunk_ZQFQRCLQ.BaichuanVideoStream({
79676
79750
  client,
79677
79751
  api,
79678
79752
  channel,
@@ -80190,7 +80264,7 @@ var H264Flow = class extends BaseFlow {
80190
80264
  super(transport, "H264");
80191
80265
  }
80192
80266
  extractParameterSets(accessUnitAnnexB) {
80193
- const nals = require_chunk_KWWUCNIY.splitAnnexBToNalPayloads(accessUnitAnnexB);
80267
+ const nals = require_chunk_ZQFQRCLQ.splitAnnexBToNalPayloads(accessUnitAnnexB);
80194
80268
  for (const nal of nals) {
80195
80269
  if (nal.length < 1) continue;
80196
80270
  const nalType = (nal[0] ?? 0) & 31;
@@ -80235,9 +80309,9 @@ var H265Flow = class extends BaseFlow {
80235
80309
  super(transport, "H265");
80236
80310
  }
80237
80311
  extractParameterSets(accessUnitAnnexB) {
80238
- const vps = require_chunk_KWWUCNIY.extractVpsFromAnnexB(accessUnitAnnexB);
80239
- const sps = require_chunk_KWWUCNIY.extractSpsFromAnnexB(accessUnitAnnexB);
80240
- const pps = require_chunk_KWWUCNIY.extractPpsFromAnnexB(accessUnitAnnexB);
80312
+ const vps = require_chunk_ZQFQRCLQ.extractVpsFromAnnexB(accessUnitAnnexB);
80313
+ const sps = require_chunk_ZQFQRCLQ.extractSpsFromAnnexB(accessUnitAnnexB);
80314
+ const pps = require_chunk_ZQFQRCLQ.extractPpsFromAnnexB(accessUnitAnnexB);
80241
80315
  if (vps && !this.vps) this.vps = vps;
80242
80316
  if (sps && !this.sps) this.sps = sps;
80243
80317
  if (pps && !this.pps) this.pps = pps;
@@ -80621,8 +80695,8 @@ var BaichuanRtspServer = class _BaichuanRtspServer extends events.EventEmitter {
80621
80695
  /** Returns true if the raw (packed/Annex B) frame is an IDR (H.264) or IRAP (H.265). */
80622
80696
  isRawFrameKeyframe(frame) {
80623
80697
  try {
80624
- if (frame.videoType === "H264") return _BaichuanRtspServer.splitAnnexBNals(require_chunk_KWWUCNIY.convertToAnnexB(frame.data)).some((n) => n.length >= 1 && (n[0] & 31) === 5);
80625
- if (frame.videoType === "H265") return require_chunk_KWWUCNIY.splitAnnexBToNalPayloads2(require_chunk_KWWUCNIY.convertToAnnexB2(frame.data)).some((n) => n.length >= 2 && require_chunk_KWWUCNIY.isH265Irap(n[0] >> 1 & 63));
80698
+ if (frame.videoType === "H264") return _BaichuanRtspServer.splitAnnexBNals(require_chunk_ZQFQRCLQ.convertToAnnexB(frame.data)).some((n) => n.length >= 1 && (n[0] & 31) === 5);
80699
+ if (frame.videoType === "H265") return require_chunk_ZQFQRCLQ.splitAnnexBToNalPayloads2(require_chunk_ZQFQRCLQ.convertToAnnexB2(frame.data)).some((n) => n.length >= 2 && require_chunk_ZQFQRCLQ.isH265Irap(n[0] >> 1 & 63));
80626
80700
  } catch {}
80627
80701
  return false;
80628
80702
  }
@@ -81522,13 +81596,13 @@ var BaichuanRtspServer = class _BaichuanRtspServer extends events.EventEmitter {
81522
81596
  if (resources?.rtpAudioTimestamp !== void 0) resources.rtpAudioTimestamp = resources.rtpAudioTimestamp + 1024 >>> 0;
81523
81597
  };
81524
81598
  const isH265IrapAccessUnit = (annexB) => {
81525
- const nals = require_chunk_KWWUCNIY.splitAnnexBToNalPayloads2(annexB);
81599
+ const nals = require_chunk_ZQFQRCLQ.splitAnnexBToNalPayloads2(annexB);
81526
81600
  for (const nal of nals) {
81527
81601
  if (nal.length < 2) continue;
81528
81602
  const b0 = nal[0];
81529
81603
  if (b0 === void 0) continue;
81530
81604
  if ((b0 & 128) !== 0) continue;
81531
- if (require_chunk_KWWUCNIY.isH265Irap(b0 >> 1 & 63)) return true;
81605
+ if (require_chunk_ZQFQRCLQ.isH265Irap(b0 >> 1 & 63)) return true;
81532
81606
  }
81533
81607
  return false;
81534
81608
  };
@@ -81684,7 +81758,7 @@ var BaichuanRtspServer = class _BaichuanRtspServer extends events.EventEmitter {
81684
81758
  continue;
81685
81759
  }
81686
81760
  if (frame.videoType === "H264" || frame.videoType === "H265") {
81687
- const normalizedVideoData = frame.videoType === "H264" ? require_chunk_KWWUCNIY.convertToAnnexB(frame.data) : require_chunk_KWWUCNIY.convertToAnnexB2(frame.data);
81761
+ const normalizedVideoData = frame.videoType === "H264" ? require_chunk_ZQFQRCLQ.convertToAnnexB(frame.data) : require_chunk_ZQFQRCLQ.convertToAnnexB2(frame.data);
81688
81762
  if (frameCount === 0) this.setFlowVideoType(frame.videoType, "first video frame");
81689
81763
  if (!this.flow.getFmtp().hasParamSets) {
81690
81764
  this.flow.extractParameterSets(normalizedVideoData);
@@ -81700,7 +81774,7 @@ var BaichuanRtspServer = class _BaichuanRtspServer extends events.EventEmitter {
81700
81774
  }
81701
81775
  if (useDirectRtp) {
81702
81776
  const videoType = frame.videoType ?? this.flow.videoType;
81703
- const normalizedVideoData = videoType === "H264" ? require_chunk_KWWUCNIY.convertToAnnexB(frame.data) : require_chunk_KWWUCNIY.convertToAnnexB2(frame.data);
81777
+ const normalizedVideoData = videoType === "H264" ? require_chunk_ZQFQRCLQ.convertToAnnexB(frame.data) : require_chunk_ZQFQRCLQ.convertToAnnexB2(frame.data);
81704
81778
  if (!resources?.seenFirstVideoKeyframe) if (videoType === "H265") {
81705
81779
  const { hasParamSets } = this.flow.getFmtp();
81706
81780
  if (!hasParamSets) {
@@ -81776,7 +81850,7 @@ var BaichuanRtspServer = class _BaichuanRtspServer extends events.EventEmitter {
81776
81850
  const headHex = frame.data.subarray(0, 16).toString("hex");
81777
81851
  this.rtspDebugLog(`First video frame written to ffmpeg stdin for client ${clientId} (len=${frame.data.length}, head=${headHex})`);
81778
81852
  }
81779
- if (!stdin.write(frame.videoType === "H264" ? require_chunk_KWWUCNIY.convertToAnnexB(frame.data) : frame.data)) await new Promise((resolve) => {
81853
+ if (!stdin.write(frame.videoType === "H264" ? require_chunk_ZQFQRCLQ.convertToAnnexB(frame.data) : frame.data)) await new Promise((resolve) => {
81780
81854
  if (stdin) stdin.once("drain", () => resolve());
81781
81855
  else resolve();
81782
81856
  });
@@ -81888,7 +81962,7 @@ var BaichuanRtspServer = class _BaichuanRtspServer extends events.EventEmitter {
81888
81962
  ensureContinuousStream(dedicatedClient) {
81889
81963
  if (this.continuousStream) return this.continuousStream;
81890
81964
  const createLiveStream = async () => {
81891
- return new require_chunk_KWWUCNIY.BaichuanVideoStream({
81965
+ return new require_chunk_ZQFQRCLQ.BaichuanVideoStream({
81892
81966
  client: dedicatedClient ?? this.api.client,
81893
81967
  api: this.api,
81894
81968
  channel: this.channel,
@@ -82584,29 +82658,29 @@ function parseSupportXml(xml) {
82584
82658
  if (!match) return void 0;
82585
82659
  const supportXml = match[1] ?? "";
82586
82660
  const ptzMode = supportXml.match(/<ptzMode>([^<]*)<\/ptzMode>/i)?.[1];
82587
- const topLevelInt = (tag) => {
82588
- return toNumberOrUndefined(supportXml.match(new RegExp(`<${tag}>([^<]*)<\\/${tag}>`, "i"))?.[1]);
82661
+ const topLevelInt = (tag2) => {
82662
+ return toNumberOrUndefined(supportXml.match(new RegExp(`<${tag2}>([^<]*)<\\/${tag2}>`, "i"))?.[1]);
82589
82663
  };
82590
- const topLevelString = (tag) => {
82591
- return supportXml.match(new RegExp(`<${tag}>([^<]*)<\\/${tag}>`, "i"))?.[1];
82664
+ const topLevelString = (tag2) => {
82665
+ return supportXml.match(new RegExp(`<${tag2}>([^<]*)<\\/${tag2}>`, "i"))?.[1];
82592
82666
  };
82593
82667
  const items = [];
82594
82668
  for (const itemMatch of supportXml.matchAll(/<item[^>]*>([\s\S]*?)<\/item>/gi)) {
82595
82669
  const itemXml = itemMatch[1] ?? "";
82596
82670
  const item = { chnID: toNumberOrUndefined(itemXml.match(/<chnID>([^<]*)<\/chnID>/i)?.[1]) ?? 0 };
82597
82671
  for (const tagMatch of itemXml.matchAll(/<([A-Za-z0-9_]+)>([^<]*)<\/\1>/g)) {
82598
- const tag = tagMatch[1];
82672
+ const tag2 = tagMatch[1];
82599
82673
  const value = tagMatch[2];
82600
- if (!tag) continue;
82601
- if (tag === "chnID") continue;
82602
- item[tag] = toNumberOrUndefined(value) ?? value;
82674
+ if (!tag2) continue;
82675
+ if (tag2 === "chnID") continue;
82676
+ item[tag2] = toNumberOrUndefined(value) ?? value;
82603
82677
  }
82604
82678
  items.push(item);
82605
82679
  }
82606
82680
  const support = { items };
82607
82681
  if (ptzMode !== void 0) support.ptzMode = ptzMode;
82608
- const assignInt = (key, tag) => {
82609
- const v = topLevelInt(tag);
82682
+ const assignInt = (key, tag2) => {
82683
+ const v = topLevelInt(tag2);
82610
82684
  if (v !== void 0) support[key] = v;
82611
82685
  };
82612
82686
  assignInt("IOInputPortNum", "IOInputPortNum");
@@ -82833,15 +82907,15 @@ function extractCanvasFromShelterXml(xml) {
82833
82907
  const yMatch = xml.match(/<topLeftY>(\d+)<\/topLeftY>/g) ?? [];
82834
82908
  let canvasX = 0;
82835
82909
  let canvasY = 0;
82836
- for (const tag of xMatch) {
82837
- const v = Number(tag.replace(/<\/?topLeftX>/g, "")) | 0;
82910
+ for (const tag2 of xMatch) {
82911
+ const v = Number(tag2.replace(/<\/?topLeftX>/g, "")) | 0;
82838
82912
  if (v > 0) {
82839
82913
  canvasX = v & 65535;
82840
82914
  break;
82841
82915
  }
82842
82916
  }
82843
- for (const tag of yMatch) {
82844
- const v = Number(tag.replace(/<\/?topLeftY>/g, "")) | 0;
82917
+ for (const tag2 of yMatch) {
82918
+ const v = Number(tag2.replace(/<\/?topLeftY>/g, "")) | 0;
82845
82919
  if (v > 0) {
82846
82920
  canvasY = v & 65535;
82847
82921
  break;
@@ -82854,9 +82928,9 @@ function extractCanvasFromShelterXml(xml) {
82854
82928
  }
82855
82929
  function parseRectTags(block) {
82856
82930
  const out = {};
82857
- const grab = (tag) => {
82858
- const m = block.match(new RegExp(`<${tag}>([^<]*)<\\/${tag}>`));
82859
- if (m && m[1] !== void 0) out[tag] = m[1];
82931
+ const grab = (tag2) => {
82932
+ const m = block.match(new RegExp(`<${tag2}>([^<]*)<\\/${tag2}>`));
82933
+ if (m && m[1] !== void 0) out[tag2] = m[1];
82860
82934
  };
82861
82935
  grab("id");
82862
82936
  grab("name");
@@ -83101,9 +83175,9 @@ var buildDetectionClasses = (parsed, recordType) => {
83101
83175
  };
83102
83176
  var getXmlTexts = (xml, tags) => {
83103
83177
  const out = {};
83104
- for (const tag of tags) {
83105
- const v = getXmlText(xml, tag);
83106
- if (v !== void 0) out[tag] = v;
83178
+ for (const tag2 of tags) {
83179
+ const v = getXmlText(xml, tag2);
83180
+ if (v !== void 0) out[tag2] = v;
83107
83181
  }
83108
83182
  return out;
83109
83183
  };
@@ -83365,11 +83439,11 @@ function patchBlock(xml, block, fields) {
83365
83439
  const end = xml.indexOf(`</${block}>`, start);
83366
83440
  if (end < 0) return xml;
83367
83441
  let body = xml.slice(start, end);
83368
- for (const [tag, value] of Object.entries(fields)) {
83442
+ for (const [tag2, value] of Object.entries(fields)) {
83369
83443
  if (value === void 0) continue;
83370
83444
  const escaped = escapeXmlText(typeof value === "boolean" ? value ? "1" : "0" : String(value));
83371
- if (body.includes(`<${tag}>`)) body = body.replace(new RegExp(`<${tag}>[^<]*<\\/${tag}>`), `<${tag}>${escaped}</${tag}>`);
83372
- else body += `<${tag}>${escaped}</${tag}>`;
83445
+ if (body.includes(`<${tag2}>`)) body = body.replace(new RegExp(`<${tag2}>[^<]*<\\/${tag2}>`), `<${tag2}>${escaped}</${tag2}>`);
83446
+ else body += `<${tag2}>${escaped}</${tag2}>`;
83373
83447
  }
83374
83448
  return xml.slice(0, start) + body + xml.slice(end);
83375
83449
  }
@@ -83437,6 +83511,66 @@ var OSD_CORNER_LABELS = {
83437
83511
  "bottom-left": "Bottom left",
83438
83512
  "bottom-right": "Bottom right"
83439
83513
  };
83514
+ function wireFloat(value) {
83515
+ return value.toExponential(6).replace(/e([+-])(\d)$/, "e$10$2");
83516
+ }
83517
+ function buildPtzGuardExtensionXml(channelId, direction) {
83518
+ return `<?xml version="1.0" encoding="UTF-8" ?>
83519
+ <Extension version="1.1">
83520
+ <channelId>${channelId}</channelId>${direction === "read" ? `
83521
+ <chnType>0</chnType>` : ""}
83522
+ </Extension>
83523
+ `;
83524
+ }
83525
+ function guardBody(channelId, command, fields) {
83526
+ return [
83527
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>",
83528
+ "<body>",
83529
+ "<PtzGuard version=\"1.1\">",
83530
+ `<channelId>${channelId}</channelId>`,
83531
+ ...fields,
83532
+ `<command>${command}</command>`,
83533
+ "<imageName></imageName>",
83534
+ `<xpos>${wireFloat(0)}</xpos>`,
83535
+ `<ypos>${wireFloat(0)}</ypos>`,
83536
+ `<height>${wireFloat(0)}</height>`,
83537
+ `<width>${wireFloat(0)}</width>`,
83538
+ "<mode>global</mode>",
83539
+ "</PtzGuard>",
83540
+ "</body>",
83541
+ ""
83542
+ ].join("\n");
83543
+ }
83544
+ function buildPtzGuardGoXml(channelId) {
83545
+ return guardBody(channelId, "toGrd", ["<benable>0</benable>", "<timeout>68</timeout>"]);
83546
+ }
83547
+ function buildPtzGuardSetXml(input) {
83548
+ return guardBody(input.channelId, "setGrd", [
83549
+ `<benable>${input.enabled ? 1 : 0}</benable>`,
83550
+ `<timeout>${Math.round(input.timeoutSeconds)}</timeout>`,
83551
+ ...input.setPosition ? ["<needSetPos>1</needSetPos>"] : []
83552
+ ]);
83553
+ }
83554
+ function tag(xml, name) {
83555
+ const m = new RegExp(`<${name}>([\\s\\S]*?)</${name}>`).exec(xml);
83556
+ return m === null ? null : (m[1] ?? "").trim();
83557
+ }
83558
+ function parsePtzGuardXml(xml) {
83559
+ if (!xml.includes("<PtzGuard")) return null;
83560
+ const enabled = tag(xml, "benable");
83561
+ const valid = tag(xml, "bvalid");
83562
+ const timeout = tag(xml, "timeout");
83563
+ if (enabled === null || valid === null || timeout === null) return null;
83564
+ const timeoutSeconds = Number.parseInt(timeout, 10);
83565
+ if (!Number.isFinite(timeoutSeconds)) return null;
83566
+ return {
83567
+ enabled: enabled === "1",
83568
+ valid: valid === "1",
83569
+ timeoutSeconds,
83570
+ mode: tag(xml, "mode") ?? "global",
83571
+ imageName: tag(xml, "imageName") ?? ""
83572
+ };
83573
+ }
83440
83574
  var emitter = new events.EventEmitter();
83441
83575
  var lastEventByCamera = /* @__PURE__ */ new Map();
83442
83576
  var MAX_GLOBAL_EVENTS = 300;
@@ -84649,8 +84783,8 @@ var buildFileInfoListStopXml = (params) => {
84649
84783
  </body>`;
84650
84784
  };
84651
84785
  var sleepMs = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
84652
- var xmlDateTimePayload = (tag, d) => {
84653
- return `<${tag}><year>${d.getFullYear()}</year><month>${d.getMonth() + 1}</month><day>${d.getDate()}</day><hour>${d.getHours()}</hour><minute>${d.getMinutes()}</minute><second>${d.getSeconds()}</second></${tag}>`;
84786
+ var xmlDateTimePayload = (tag2, d) => {
84787
+ return `<${tag2}><year>${d.getFullYear()}</year><month>${d.getMonth() + 1}</month><day>${d.getDate()}</day><hour>${d.getHours()}</hour><minute>${d.getMinutes()}</minute><second>${d.getSeconds()}</second></${tag2}>`;
84654
84788
  };
84655
84789
  var buildFileInfoListOpenXml = (params) => {
84656
84790
  return `<?xml version="1.0" encoding="UTF-8" ?>
@@ -84838,10 +84972,10 @@ var isPlausibleStream = (s) => {
84838
84972
  return s.width > 0 && s.height > 0 && (s.frameRate > 0 || s.bitRate > 0);
84839
84973
  };
84840
84974
  var logDebugStreamBlock = (params) => {
84841
- const { logger, traceNativeStream, channel, tag, blockXml } = params;
84975
+ const { logger, traceNativeStream, channel, tag: tag2, blockXml } = params;
84842
84976
  if (!traceNativeStream) return;
84843
84977
  if (!blockXml) {
84844
- (logger.warn ?? logger.log).call(logger, `[ReolinkBaichuanApi] getStreamMetadata(traceNativeStream): channel=${channel} tag=<${tag}> missing`);
84978
+ (logger.warn ?? logger.log).call(logger, `[ReolinkBaichuanApi] getStreamMetadata(traceNativeStream): channel=${channel} tag=<${tag2}> missing`);
84845
84979
  return;
84846
84980
  }
84847
84981
  const raw = blockXml;
@@ -84868,7 +85002,7 @@ var logDebugStreamBlock = (params) => {
84868
85002
  const previewMax = 1400;
84869
85003
  const xmlPreview = raw.length <= previewMax ? raw : raw.slice(0, previewMax) + `
84870
85004
  ...truncated (+${raw.length - previewMax} chars)`;
84871
- (logger.warn ?? logger.log).call(logger, `[ReolinkBaichuanApi] getStreamMetadata(traceNativeStream): channel=${channel} tag=<${tag}> enabled=${isEnabled} plausible=${plausible} width=${width} height=${height} frame=${frameRate} bitRate=${bitRate} audio=${audio} videoEncType=${videoEncTypeText ?? "?"} rawFields=${JSON.stringify({
85005
+ (logger.warn ?? logger.log).call(logger, `[ReolinkBaichuanApi] getStreamMetadata(traceNativeStream): channel=${channel} tag=<${tag2}> enabled=${isEnabled} plausible=${plausible} width=${width} height=${height} frame=${frameRate} bitRate=${bitRate} audio=${audio} videoEncType=${videoEncTypeText ?? "?"} rawFields=${JSON.stringify({
84872
85006
  widthText,
84873
85007
  heightText,
84874
85008
  frameText,
@@ -84961,20 +85095,20 @@ var parseChannelStreamMetadataFromGetEncXml = (params) => {
84961
85095
  audioEnabled = audioEnabled && s.audio === 1;
84962
85096
  }
84963
85097
  }
84964
- for (const tag of [
85098
+ for (const tag2 of [
84965
85099
  "extStream",
84966
85100
  "thirdStream",
84967
85101
  "externStream",
84968
85102
  "extraStream"
84969
85103
  ]) {
84970
- const extMatch = xml.match(new RegExp(`<${tag}[^>]*>([\\s\\S]*?)<\\/${tag}>`));
85104
+ const extMatch = xml.match(new RegExp(`<${tag2}[^>]*>([\\s\\S]*?)<\\/${tag2}>`));
84971
85105
  if (!extMatch) continue;
84972
85106
  const extXml = extMatch[1] ?? "";
84973
85107
  logDebugStreamBlock({
84974
85108
  logger,
84975
85109
  traceNativeStream,
84976
85110
  channel,
84977
- tag,
85111
+ tag: tag2,
84978
85112
  blockXml: extXml
84979
85113
  });
84980
85114
  const s = buildStream({
@@ -85065,7 +85199,7 @@ var sendTalkConfigWithReset = async (params) => {
85065
85199
  channel: params.channel,
85066
85200
  ...params.channelIdOverride != null ? { channelIdOverride: params.channelIdOverride } : {},
85067
85201
  payloadXml: params.payloadXml,
85068
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24
85202
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24
85069
85203
  })).header.responseCode;
85070
85204
  };
85071
85205
  const code = await trySend();
@@ -85075,7 +85209,7 @@ var sendTalkConfigWithReset = async (params) => {
85075
85209
  channel: params.channel,
85076
85210
  ...params.channelIdOverride != null ? { channelIdOverride: params.channelIdOverride } : {},
85077
85211
  payloadXml: "",
85078
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24
85212
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24
85079
85213
  });
85080
85214
  const retryCode = await trySend();
85081
85215
  if (retryCode !== 200) throw new Error(`TalkConfig rejected after reset (responseCode ${retryCode})`);
@@ -85142,7 +85276,7 @@ var createBufferedTalkSession = (params) => {
85142
85276
  ...channelIdOverride != null ? { channelIdOverride } : {},
85143
85277
  extensionXml: buildBinaryExtensionXml(channel),
85144
85278
  payload: Buffer.concat(parts),
85145
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24
85279
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24
85146
85280
  });
85147
85281
  const playLengthMs = samplesSent / info.audioConfig.sampleRate * 1e3;
85148
85282
  const now = Date.now();
@@ -85188,7 +85322,7 @@ var createBufferedTalkSession = (params) => {
85188
85322
  channel,
85189
85323
  ...channelIdOverride != null ? { channelIdOverride } : {},
85190
85324
  payloadXml: "",
85191
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24
85325
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24
85192
85326
  });
85193
85327
  if (frame.header.responseCode !== 200) throw new Error(`TalkReset rejected (responseCode ${frame.header.responseCode})`);
85194
85328
  if (params.closeSocketOnStop) try {
@@ -86567,7 +86701,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
86567
86701
  * @param logger - Optional logger for debug output
86568
86702
  * @returns The socket and a release function
86569
86703
  */
86570
- async acquirePooledSocket(tag, logger) {
86704
+ async acquirePooledSocket(tag2, logger) {
86571
86705
  const log = logger ?? this.logger;
86572
86706
  const now = Date.now();
86573
86707
  const cooldownEntry = this.socketPoolCooldowns.get(this.host);
@@ -86578,12 +86712,12 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
86578
86712
  } else if (now < cooldownEntry.cooldownUntil) {
86579
86713
  const remainingMs = cooldownEntry.cooldownUntil - now;
86580
86714
  const reason = this.lastD2cDiscAtMs > 0 && now - this.lastD2cDiscAtMs < 12e4 ? "D2C_DISC (camera sleeping)" : "repeated login failures";
86581
- const error = /* @__PURE__ */ new Error(`[SocketPool] Host ${this.host} is in cooldown for ${Math.ceil(remainingMs / 1e3)}s due to ${reason}. tag=${tag}`);
86715
+ const error = /* @__PURE__ */ new Error(`[SocketPool] Host ${this.host} is in cooldown for ${Math.ceil(remainingMs / 1e3)}s due to ${reason}. tag=${tag2}`);
86582
86716
  log?.debug?.(error.message);
86583
86717
  throw error;
86584
86718
  }
86585
86719
  }
86586
- const existing = this.socketPool.get(tag);
86720
+ const existing = this.socketPool.get(tag2);
86587
86721
  if (existing) {
86588
86722
  if (existing.idleCloseTimer) {
86589
86723
  clearTimeout(existing.idleCloseTimer);
@@ -86593,35 +86727,35 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
86593
86727
  const client2 = await existing.pendingPromise;
86594
86728
  existing.refCount++;
86595
86729
  existing.lastUsedAt = Date.now();
86596
- log?.debug?.(`[SocketPool] Waited for pending socket creation for tag=${tag} (refCount=${existing.refCount})`);
86730
+ log?.debug?.(`[SocketPool] Waited for pending socket creation for tag=${tag2} (refCount=${existing.refCount})`);
86597
86731
  return {
86598
86732
  client: client2,
86599
- release: () => this.releasePooledSocket(tag, logger)
86733
+ release: () => this.releasePooledSocket(tag2, logger)
86600
86734
  };
86601
86735
  }
86602
86736
  if (existing.refCount === 0) {
86603
86737
  existing.refCount = 1;
86604
86738
  existing.lastUsedAt = Date.now();
86605
- log?.debug?.(`[SocketPool] Reusing idle socket for tag=${tag}`);
86739
+ log?.debug?.(`[SocketPool] Reusing idle socket for tag=${tag2}`);
86606
86740
  try {
86607
86741
  if (!existing.client.loggedIn) await existing.client.login();
86608
86742
  } catch {}
86609
86743
  if (existing.client.loggedIn) return {
86610
86744
  client: existing.client,
86611
- release: () => this.releasePooledSocket(tag, logger)
86745
+ release: () => this.releasePooledSocket(tag2, logger)
86612
86746
  };
86613
- } else if (tag.startsWith("replay:")) log?.debug?.(`[SocketPool] Preempting active replay socket for tag=${tag}`);
86747
+ } else if (tag2.startsWith("replay:")) log?.debug?.(`[SocketPool] Preempting active replay socket for tag=${tag2}`);
86614
86748
  else {
86615
86749
  existing.refCount++;
86616
86750
  existing.lastUsedAt = Date.now();
86617
- log?.debug?.(`[SocketPool] Reusing active socket for tag=${tag} (refCount=${existing.refCount})`);
86751
+ log?.debug?.(`[SocketPool] Reusing active socket for tag=${tag2} (refCount=${existing.refCount})`);
86618
86752
  return {
86619
86753
  client: existing.client,
86620
- release: () => this.releasePooledSocket(tag, logger)
86754
+ release: () => this.releasePooledSocket(tag2, logger)
86621
86755
  };
86622
86756
  }
86623
- log?.debug?.(`[SocketPool] Closing existing socket for tag=${tag} (recreating)`);
86624
- this.socketPool.delete(tag);
86757
+ log?.debug?.(`[SocketPool] Closing existing socket for tag=${tag2} (recreating)`);
86758
+ this.socketPool.delete(tag2);
86625
86759
  if (existing.generalPermitRelease) {
86626
86760
  try {
86627
86761
  existing.generalPermitRelease();
@@ -86634,10 +86768,10 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
86634
86768
  skipLogout: true
86635
86769
  });
86636
86770
  } catch (e) {
86637
- log?.warn?.(`[SocketPool] Error closing old socket for tag=${tag}: ${e}`);
86771
+ log?.warn?.(`[SocketPool] Error closing old socket for tag=${tag2}: ${e}`);
86638
86772
  }
86639
86773
  }
86640
- log?.log?.(`[SocketPool] Creating new socket for tag=${tag}`);
86774
+ log?.log?.(`[SocketPool] Creating new socket for tag=${tag2}`);
86641
86775
  const entry = {
86642
86776
  client: void 0,
86643
86777
  refCount: 0,
@@ -86654,7 +86788,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
86654
86788
  } : this.clientOptions);
86655
86789
  this.attachD2cDiscListener(newClient);
86656
86790
  newClient.on("error", (err) => {
86657
- log?.debug?.(`[SocketPool] tag=${tag} client error: ${err?.message ?? err}`);
86791
+ log?.debug?.(`[SocketPool] tag=${tag2} client error: ${err?.message ?? err}`);
86658
86792
  });
86659
86793
  await newClient.login();
86660
86794
  const existingCooldown = this.socketPoolCooldowns.get(this.host);
@@ -86666,10 +86800,10 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
86666
86800
  entry.refCount = 1;
86667
86801
  entry.lastUsedAt = Date.now();
86668
86802
  delete entry.pendingPromise;
86669
- log?.log?.(`[SocketPool] Socket connected for tag=${tag}`);
86670
- if (tag !== "general") try {
86803
+ log?.log?.(`[SocketPool] Socket connected for tag=${tag2}`);
86804
+ if (tag2 !== "general") try {
86671
86805
  const generalEntry = this.socketPool.get("general");
86672
- if (generalEntry?.client) entry.generalPermitRelease = generalEntry.client.acquirePermit(0, `streaming-peer:${tag}`);
86806
+ if (generalEntry?.client) entry.generalPermitRelease = generalEntry.client.acquirePermit(0, `streaming-peer:${tag2}`);
86673
86807
  } catch {}
86674
86808
  if (this.sessionGuardEnabled) this.maybeRebootOnTooManySessions();
86675
86809
  return newClient;
@@ -86680,21 +86814,21 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
86680
86814
  if (failureCount >= _ReolinkBaichuanApi.SOCKET_POOL_FAILURE_THRESHOLD) {
86681
86815
  const backoffMs = Math.min(_ReolinkBaichuanApi.SOCKET_POOL_BASE_COOLDOWN_MS * Math.pow(2, failureCount - _ReolinkBaichuanApi.SOCKET_POOL_FAILURE_THRESHOLD), _ReolinkBaichuanApi.SOCKET_POOL_MAX_COOLDOWN_MS);
86682
86816
  cooldownUntil = now2 + backoffMs;
86683
- log?.warn?.(`[SocketPool] Login failed for host=${this.host} (failure #${failureCount}). Entering cooldown for ${Math.ceil(backoffMs / 1e3)}s. tag=${tag}`);
86684
- } else log?.warn?.(`[SocketPool] Login failed for host=${this.host} (failure #${failureCount}/${_ReolinkBaichuanApi.SOCKET_POOL_FAILURE_THRESHOLD} before cooldown). tag=${tag}`);
86817
+ log?.warn?.(`[SocketPool] Login failed for host=${this.host} (failure #${failureCount}). Entering cooldown for ${Math.ceil(backoffMs / 1e3)}s. tag=${tag2}`);
86818
+ } else log?.warn?.(`[SocketPool] Login failed for host=${this.host} (failure #${failureCount}/${_ReolinkBaichuanApi.SOCKET_POOL_FAILURE_THRESHOLD} before cooldown). tag=${tag2}`);
86685
86819
  this.socketPoolCooldowns.set(this.host, {
86686
86820
  failureCount,
86687
86821
  lastFailureAt: now2,
86688
86822
  cooldownUntil
86689
86823
  });
86690
- this.socketPool.delete(tag);
86824
+ this.socketPool.delete(tag2);
86691
86825
  throw loginError;
86692
86826
  }
86693
86827
  })();
86694
- this.socketPool.set(tag, entry);
86828
+ this.socketPool.set(tag2, entry);
86695
86829
  return {
86696
86830
  client: await entry.pendingPromise,
86697
- release: () => this.releasePooledSocket(tag, logger)
86831
+ release: () => this.releasePooledSocket(tag2, logger)
86698
86832
  };
86699
86833
  }
86700
86834
  /**
@@ -86702,31 +86836,31 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
86702
86836
  * For shared sockets (general, streaming), just decrements refCount.
86703
86837
  * For replay sockets, schedules idle close.
86704
86838
  */
86705
- async releasePooledSocket(tag, logger) {
86839
+ async releasePooledSocket(tag2, logger) {
86706
86840
  const log = logger ?? this.logger;
86707
- const entry = this.socketPool.get(tag);
86841
+ const entry = this.socketPool.get(tag2);
86708
86842
  if (!entry) return;
86709
86843
  entry.refCount = Math.max(0, entry.refCount - 1);
86710
86844
  entry.lastUsedAt = Date.now();
86711
- log?.debug?.(`[SocketPool] Released socket for tag=${tag} (refCount=${entry.refCount})`);
86845
+ log?.debug?.(`[SocketPool] Released socket for tag=${tag2} (refCount=${entry.refCount})`);
86712
86846
  if (entry.refCount > 0) return;
86713
- const isReplayTag = tag.startsWith("replay:");
86714
- const isStreamingTag = tag.startsWith("streaming:");
86715
- if (tag === "general") return;
86847
+ const isReplayTag = tag2.startsWith("replay:");
86848
+ const isStreamingTag = tag2.startsWith("streaming:");
86849
+ if (tag2 === "general") return;
86716
86850
  if (isStreamingTag) {
86717
86851
  if (entry.idleCloseTimer) return;
86718
86852
  entry.idleCloseTimer = setTimeout(async () => {
86719
- const current = this.socketPool.get(tag);
86853
+ const current = this.socketPool.get(tag2);
86720
86854
  if (!current) return;
86721
86855
  if (current.refCount > 0) return;
86722
- this.socketPool.delete(tag);
86856
+ this.socketPool.delete(tag2);
86723
86857
  if (current.generalPermitRelease) {
86724
86858
  try {
86725
86859
  current.generalPermitRelease();
86726
86860
  } catch {}
86727
86861
  current.generalPermitRelease = void 0;
86728
86862
  }
86729
- log?.log?.(`[SocketPool] Closing idle streaming socket for tag=${tag}`);
86863
+ log?.log?.(`[SocketPool] Closing idle streaming socket for tag=${tag2}`);
86730
86864
  try {
86731
86865
  await current.client.close({
86732
86866
  reason: "streaming idle close",
@@ -86739,11 +86873,11 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
86739
86873
  if (isReplayTag) {
86740
86874
  if (entry.idleCloseTimer) return;
86741
86875
  entry.idleCloseTimer = setTimeout(async () => {
86742
- const current = this.socketPool.get(tag);
86876
+ const current = this.socketPool.get(tag2);
86743
86877
  if (!current) return;
86744
86878
  if (current.refCount > 0) return;
86745
- this.socketPool.delete(tag);
86746
- log?.debug?.(`[SocketPool] Closing idle replay socket for tag=${tag} (keepalive expired)`);
86879
+ this.socketPool.delete(tag2);
86880
+ log?.debug?.(`[SocketPool] Closing idle replay socket for tag=${tag2} (keepalive expired)`);
86747
86881
  try {
86748
86882
  await current.client.close({
86749
86883
  reason: "replay idle keepalive expired",
@@ -86753,24 +86887,24 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
86753
86887
  }, _ReolinkBaichuanApi.SOCKET_POOL_KEEPALIVE_MS);
86754
86888
  return;
86755
86889
  }
86756
- this.socketPool.delete(tag);
86890
+ this.socketPool.delete(tag2);
86757
86891
  try {
86758
86892
  await entry.client.close({
86759
86893
  reason: "socket pool release",
86760
86894
  skipLogout: true
86761
86895
  });
86762
- log?.log?.(`[SocketPool] Closed socket for tag=${tag}`);
86896
+ log?.log?.(`[SocketPool] Closed socket for tag=${tag2}`);
86763
86897
  } catch (e) {
86764
- log?.warn?.(`[SocketPool] Error closing socket for tag=${tag}: ${e}`);
86898
+ log?.warn?.(`[SocketPool] Error closing socket for tag=${tag2}: ${e}`);
86765
86899
  }
86766
86900
  }
86767
86901
  /**
86768
86902
  * Force-close a socket by tag.
86769
86903
  * Used to preempt existing connections before acquiring a new one.
86770
86904
  */
86771
- async forceClosePooledSocket(tag, logger) {
86905
+ async forceClosePooledSocket(tag2, logger) {
86772
86906
  const log = logger ?? this.logger;
86773
- const entry = this.socketPool.get(tag);
86907
+ const entry = this.socketPool.get(tag2);
86774
86908
  if (!entry) return false;
86775
86909
  if (entry.idleCloseTimer) {
86776
86910
  clearTimeout(entry.idleCloseTimer);
@@ -86782,16 +86916,16 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
86782
86916
  } catch {}
86783
86917
  entry.generalPermitRelease = void 0;
86784
86918
  }
86785
- log?.debug?.(`[SocketPool] Force-closing socket for tag=${tag}`);
86786
- this.socketPool.delete(tag);
86919
+ log?.debug?.(`[SocketPool] Force-closing socket for tag=${tag2}`);
86920
+ this.socketPool.delete(tag2);
86787
86921
  try {
86788
86922
  await entry.client.close({
86789
86923
  reason: "force closed",
86790
86924
  skipLogout: true
86791
86925
  });
86792
- log?.log?.(`[SocketPool] Force-closed socket for tag=${tag}`);
86926
+ log?.log?.(`[SocketPool] Force-closed socket for tag=${tag2}`);
86793
86927
  } catch (e) {
86794
- log?.warn?.(`[SocketPool] Error during force-close for tag=${tag}: ${e}`);
86928
+ log?.warn?.(`[SocketPool] Error during force-close for tag=${tag2}: ${e}`);
86795
86929
  }
86796
86930
  return true;
86797
86931
  }
@@ -86801,7 +86935,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
86801
86935
  async cleanupSocketPool() {
86802
86936
  const entries = Array.from(this.socketPool.entries());
86803
86937
  this.socketPool.clear();
86804
- await Promise.allSettled(entries.map(async ([tag, entry]) => {
86938
+ await Promise.allSettled(entries.map(async ([tag2, entry]) => {
86805
86939
  try {
86806
86940
  if (entry.idleCloseTimer) clearTimeout(entry.idleCloseTimer);
86807
86941
  if (entry.generalPermitRelease) {
@@ -86810,7 +86944,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
86810
86944
  } catch {}
86811
86945
  entry.generalPermitRelease = void 0;
86812
86946
  }
86813
- this.logger?.debug?.(`[SocketPool] Cleanup: closing tag=${tag}`);
86947
+ this.logger?.debug?.(`[SocketPool] Cleanup: closing tag=${tag2}`);
86814
86948
  await entry.client.close({
86815
86949
  reason: "API cleanup",
86816
86950
  skipLogout: true
@@ -86843,17 +86977,17 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
86843
86977
  * ```
86844
86978
  */
86845
86979
  async createDedicatedSession(sessionKey, logger) {
86846
- const tag = this.resolveSocketTag(sessionKey);
86847
- (logger ?? this.logger)?.debug?.(`[SocketPool] createDedicatedSession sessionKey=${sessionKey} \u2192 tag=${tag}`);
86848
- return await this.acquirePooledSocket(tag, logger);
86980
+ const tag2 = this.resolveSocketTag(sessionKey);
86981
+ (logger ?? this.logger)?.debug?.(`[SocketPool] createDedicatedSession sessionKey=${sessionKey} \u2192 tag=${tag2}`);
86982
+ return await this.acquirePooledSocket(tag2, logger);
86849
86983
  }
86850
86984
  /**
86851
86985
  * @deprecated Use forceClosePooledSocket via createDedicatedSession instead.
86852
86986
  * Force-close a dedicated client if it exists.
86853
86987
  */
86854
86988
  async forceCloseDedicatedClient(sessionKey, logger) {
86855
- const tag = this.resolveSocketTag(sessionKey);
86856
- return await this.forceClosePooledSocket(tag, logger);
86989
+ const tag2 = this.resolveSocketTag(sessionKey);
86990
+ return await this.forceClosePooledSocket(tag2, logger);
86857
86991
  }
86858
86992
  /**
86859
86993
  * @deprecated Cleanup handled by cleanupSocketPool now.
@@ -86868,8 +87002,8 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
86868
87002
  const debugCfg = this.client.getDebugConfig?.();
86869
87003
  if (debugCfg) {
86870
87004
  const sid = this.client.getSocketSessionId?.();
86871
- const tag = sid ? `ReolinkSimpleEvent sid=${sid}` : "ReolinkSimpleEvent";
86872
- require_chunk_KWWUCNIY.eventTraceLog(debugCfg, this.logger, tag, `dispatch type=${evt.type} channel=${evt.channel} timestamp=${evt.timestamp}`);
87005
+ const tag2 = sid ? `ReolinkSimpleEvent sid=${sid}` : "ReolinkSimpleEvent";
87006
+ require_chunk_ZQFQRCLQ.eventTraceLog(debugCfg, this.logger, tag2, `dispatch type=${evt.type} channel=${evt.channel} timestamp=${evt.timestamp}`);
86873
87007
  }
86874
87008
  for (const cb of this.simpleEventListeners) try {
86875
87009
  Promise.resolve(cb(evt)).catch((e) => {
@@ -86880,7 +87014,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
86880
87014
  }
86881
87015
  }
86882
87016
  constructor(opts) {
86883
- const dbg = require_chunk_KWWUCNIY.normalizeDebugOptions(opts.debugOptions);
87017
+ const dbg = require_chunk_ZQFQRCLQ.normalizeDebugOptions(opts.debugOptions);
86884
87018
  this.logger = createDebugGateLogger(opts.logger, dbg.general || dbg.traceNativeStream || dbg.traceRecordings || dbg.traceTalk || dbg.traceEvents || dbg.debugRtsp);
86885
87019
  this.clientOptions = {
86886
87020
  host: opts.host,
@@ -87467,7 +87601,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
87467
87601
  return;
87468
87602
  }
87469
87603
  entry.startInFlight = (async () => {
87470
- const { BaichuanVideoStream: BaichuanVideoStream2 } = await Promise.resolve().then(() => require("./BaichuanVideoStream-PBJL3EB5-qv_JKCPo.js"));
87604
+ const { BaichuanVideoStream: BaichuanVideoStream2 } = await Promise.resolve().then(() => require("./BaichuanVideoStream-2M4UO7MB-Cqjt1oxu.js"));
87471
87605
  const sessionKey = `live:object-detections:ch${entry.channel}:${entry.profile}`;
87472
87606
  const dedicated = await this.createDedicatedSession(sessionKey);
87473
87607
  const stream$12 = new BaichuanVideoStream2({
@@ -87944,7 +88078,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
87944
88078
  channel: ch,
87945
88079
  ...channelIdOverride != null ? { channelIdOverride } : {},
87946
88080
  payloadXml: "",
87947
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24
88081
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24
87948
88082
  });
87949
88083
  if (frame.header.responseCode !== 200) throw new Error(`TalkReset rejected (responseCode ${frame.header.responseCode})`);
87950
88084
  }
@@ -87963,7 +88097,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
87963
88097
  channel: ch,
87964
88098
  ...channelIdOverride != null ? { channelIdOverride } : {},
87965
88099
  payloadXml,
87966
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24
88100
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24
87967
88101
  })).header.responseCode;
87968
88102
  };
87969
88103
  const code = await trySend();
@@ -88034,8 +88168,8 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
88034
88168
  const idleTimeoutMs = options?.idleTimeoutMs ?? 3e4;
88035
88169
  const sessionKey = `talk:${options?.deviceId ?? "unknown"}:ch${channel}:${Date.now()}`;
88036
88170
  logger?.info?.(`[DedicatedTalk] Creating session: ${sessionKey} (idleTimeout=${idleTimeoutMs}ms)`);
88037
- const tag = this.resolveSocketTag(sessionKey);
88038
- const { client: dedicatedClient, release } = await this.acquirePooledSocket(tag, logger);
88171
+ const tag2 = this.resolveSocketTag(sessionKey);
88172
+ const { client: dedicatedClient, release } = await this.acquirePooledSocket(tag2, logger);
88039
88173
  const summary = this.getSocketPoolSummary();
88040
88174
  logger?.info?.(`[DedicatedTalk] Session created [sessions: ${summary.count} active${summary.count > 0 ? ` (${summary.tags.join(", ")})` : ""}]`);
88041
88175
  try {
@@ -88115,7 +88249,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
88115
88249
  cmdId: 10,
88116
88250
  channel,
88117
88251
  payloadXml: "",
88118
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24
88252
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24
88119
88253
  });
88120
88254
  return parseTalkAbilityXml(frame.body.length === 0 ? "" : client.tryDecryptXml(frame.body, frame.header.channelId, client.enc));
88121
88255
  }
@@ -88148,8 +88282,8 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
88148
88282
  }
88149
88283
  /** SetNetPort via Baichuan: cmd_id 36 (enable/disable rtsp/rtmp/onvif/http/https) */
88150
88284
  async setPortEnabled(params) {
88151
- const tag = `${params.port[0].toUpperCase()}${params.port.slice(1)}Port`;
88152
- const xml = `<?xml version="1.0" encoding="UTF-8" ?><body><${tag} version="1.1"><enable>${params.enable ? 1 : 0}</enable></${tag}></body>`;
88285
+ const tag2 = `${params.port[0].toUpperCase()}${params.port.slice(1)}Port`;
88286
+ const xml = `<?xml version="1.0" encoding="UTF-8" ?><body><${tag2} version="1.1"><enable>${params.enable ? 1 : 0}</enable></${tag2}></body>`;
88153
88287
  await this.sendXml({
88154
88288
  cmdId: 36,
88155
88289
  payloadXml: xml
@@ -88180,13 +88314,13 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
88180
88314
  */
88181
88315
  async setPortConfig(patch) {
88182
88316
  const blocks = [];
88183
- const append = (tag, portField, cfg) => {
88317
+ const append = (tag2, portField, cfg) => {
88184
88318
  if (!cfg) return;
88185
88319
  if (cfg.port === void 0 && cfg.enable === void 0) return;
88186
88320
  const inner = [];
88187
88321
  if (cfg.port !== void 0) inner.push(`<${portField}>${cfg.port}</${portField}>`);
88188
88322
  if (cfg.enable !== void 0) inner.push(`<enable>${cfg.enable ? 1 : 0}</enable>`);
88189
- blocks.push(`<${tag} version="1.1">${inner.join("")}</${tag}>`);
88323
+ blocks.push(`<${tag2} version="1.1">${inner.join("")}</${tag2}>`);
88190
88324
  };
88191
88325
  append("ServerPort", "serverPort", patch.server);
88192
88326
  append("HttpPort", "httpPort", patch.http);
@@ -88700,8 +88834,8 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
88700
88834
  ];
88701
88835
  const current = await this.getEncXml(ch);
88702
88836
  let updated = null;
88703
- for (const tag of candidateTags) {
88704
- const sectionRe = new RegExp(`(<${tag}[^>]*>[\\s\\S]*?<videoEncType>)(\\d+)(</videoEncType>)`);
88837
+ for (const tag2 of candidateTags) {
88838
+ const sectionRe = new RegExp(`(<${tag2}[^>]*>[\\s\\S]*?<videoEncType>)(\\d+)(</videoEncType>)`);
88705
88839
  if (!sectionRe.test(current)) continue;
88706
88840
  const next = current.replace(sectionRe, `$1${desired}$3`);
88707
88841
  if (next !== current) {
@@ -89187,8 +89321,8 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
89187
89321
  const start = params.start;
89188
89322
  const endOfStartDay = new Date(start.getFullYear(), start.getMonth(), start.getDate(), 23, 59, 59, 999);
89189
89323
  const end = params.end.getTime() > endOfStartDay.getTime() ? endOfStartDay : params.end;
89190
- require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "getVideoclips", `Query: start=${start.toISOString()}, end=${end.toISOString()} (forced same day)`);
89191
- require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "getVideoclips", `Using UID for channel ${channel}: ${uid}`);
89324
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "getVideoclips", `Query: start=${start.toISOString()}, end=${end.toISOString()} (forced same day)`);
89325
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "getVideoclips", `Using UID for channel ${channel}: ${uid}`);
89192
89326
  const streamType = params.streamType ?? "subStream";
89193
89327
  const recordType = params.recordType ?? "manual, sched, io, md, people, face, vehicle, dog_cat, visitor, other, package";
89194
89328
  const maxIterations = params.maxIterations ?? 50;
@@ -89208,7 +89342,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
89208
89342
  ...params.timeoutMs != null ? { timeoutMs: params.timeoutMs } : {}
89209
89343
  });
89210
89344
  const unique = dedupeRecordingFiles(files);
89211
- require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "getVideoclips", `FileInfoList complete: ${unique.length} unique files (from ${files.length} total)`);
89345
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "getVideoclips", `FileInfoList complete: ${unique.length} unique files (from ${files.length} total)`);
89212
89346
  return unique;
89213
89347
  });
89214
89348
  }
@@ -89231,9 +89365,9 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
89231
89365
  const streamType = params.streamType;
89232
89366
  const logger = params.logger ?? this.logger;
89233
89367
  const sessionKey = params.deviceId ? `replay:${params.deviceId}:ch${channel}` : `replay:standalone:ch${channel}:${Date.now()}`;
89234
- const tag = this.resolveSocketTag(sessionKey);
89235
- logger?.debug?.(`[startRecordingReplayStreamStandalone] sessionKey=${sessionKey} -> tag=${tag}`);
89236
- const { client: dedicatedClient, release: releaseDedicatedClient } = await this.acquirePooledSocket(tag, logger);
89368
+ const tag2 = this.resolveSocketTag(sessionKey);
89369
+ logger?.debug?.(`[startRecordingReplayStreamStandalone] sessionKey=${sessionKey} -> tag=${tag2}`);
89370
+ const { client: dedicatedClient, release: releaseDedicatedClient } = await this.acquirePooledSocket(tag2, logger);
89237
89371
  const uid = await this.ensureUidForRecordings(channel, void 0);
89238
89372
  const payloadXml = buildFileInfoListReplayByNameXml({
89239
89373
  channel,
@@ -89244,7 +89378,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
89244
89378
  });
89245
89379
  const msgNum = 0;
89246
89380
  dedicatedClient.subscribeVideoStream(5, msgNum);
89247
- const stream$14 = new require_chunk_KWWUCNIY.BaichuanVideoStream({
89381
+ const stream$14 = new require_chunk_ZQFQRCLQ.BaichuanVideoStream({
89248
89382
  client: dedicatedClient,
89249
89383
  channel,
89250
89384
  profile: streamType === "subStream" ? "sub" : "main",
@@ -89263,7 +89397,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
89263
89397
  channel,
89264
89398
  channelIdOverride: sessionCounter,
89265
89399
  payloadXml,
89266
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
89400
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
89267
89401
  msgNumOverride: 0,
89268
89402
  timeoutMs: params.timeoutMs,
89269
89403
  internal: true
@@ -89295,7 +89429,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
89295
89429
  cmdId: 7,
89296
89430
  channel,
89297
89431
  payloadXml: stopXml,
89298
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
89432
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
89299
89433
  timeoutMs: 2e3,
89300
89434
  internal: true
89301
89435
  });
@@ -89336,8 +89470,8 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
89336
89470
  const streamType = params.streamType;
89337
89471
  const logger = params.logger ?? this.logger;
89338
89472
  const sessionKey = params.deviceId ? `replay:${params.deviceId}:ch${channel}` : `replay:nvr:ch${channel}:${Date.now()}`;
89339
- const tag = this.resolveSocketTag(sessionKey);
89340
- const { client: dedicatedClient, release: releaseDedicatedClient } = await this.acquirePooledSocket(tag, logger);
89473
+ const tag2 = this.resolveSocketTag(sessionKey);
89474
+ const { client: dedicatedClient, release: releaseDedicatedClient } = await this.acquirePooledSocket(tag2, logger);
89341
89475
  let uid;
89342
89476
  try {
89343
89477
  uid = await this.ensureUidForRecordings(channel, void 0);
@@ -89352,7 +89486,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
89352
89486
  });
89353
89487
  const msgNum = 0;
89354
89488
  dedicatedClient.subscribeVideoStream(5, msgNum);
89355
- const stream$15 = new require_chunk_KWWUCNIY.BaichuanVideoStream({
89489
+ const stream$15 = new require_chunk_ZQFQRCLQ.BaichuanVideoStream({
89356
89490
  client: dedicatedClient,
89357
89491
  channel,
89358
89492
  profile: streamType === "subStream" ? "sub" : "main",
@@ -89372,7 +89506,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
89372
89506
  channelIdOverride,
89373
89507
  payloadXml,
89374
89508
  extensionXml: "",
89375
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
89509
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
89376
89510
  msgNumOverride: msgNum,
89377
89511
  timeoutMs: params.timeoutMs,
89378
89512
  internal: true
@@ -89404,7 +89538,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
89404
89538
  cmdId: 7,
89405
89539
  channel,
89406
89540
  payloadXml: stopXml,
89407
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
89541
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
89408
89542
  timeoutMs: 2e3,
89409
89543
  internal: true
89410
89544
  });
@@ -89491,30 +89625,30 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
89491
89625
  async ensureUidForRecordings(channel, explicitUid) {
89492
89626
  const dbg = this.client.getDebugConfig?.();
89493
89627
  const logger = this.logger;
89494
- require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Checking UID: explicitUid=${explicitUid}, this.uid=${this.uid}`);
89628
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Checking UID: explicitUid=${explicitUid}, this.uid=${this.uid}`);
89495
89629
  const trimmedExplicit = explicitUid?.trim();
89496
89630
  if (trimmedExplicit) {
89497
- require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Using explicit UID: ${trimmedExplicit}`);
89631
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Using explicit UID: ${trimmedExplicit}`);
89498
89632
  return trimmedExplicit;
89499
89633
  }
89500
89634
  const perChannel = await this.discoverUidForRecordingsForChannel(channel);
89501
89635
  if (perChannel) {
89502
- require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Using per-channel UID: ${perChannel}`);
89636
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Using per-channel UID: ${perChannel}`);
89503
89637
  return perChannel;
89504
89638
  }
89505
89639
  const configured = this.uid?.trim();
89506
89640
  if (configured) {
89507
- require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Using configured UID: ${configured}`);
89641
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Using configured UID: ${configured}`);
89508
89642
  return configured;
89509
89643
  }
89510
89644
  if (this.nativeOnly) {
89511
- require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Native-only: no UID available (channel=${channel})`);
89645
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Native-only: no UID available (channel=${channel})`);
89512
89646
  throw new Error("UID is required to access recordings in native-only mode. Provide a UID explicitly, configure the client with a UID, or wait for cmd_id=145 push cache to populate per-channel UIDs.");
89513
89647
  }
89514
- require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `No UID available, attempting device auto-discovery (ch=${channel})`);
89648
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `No UID available, attempting device auto-discovery (ch=${channel})`);
89515
89649
  const discovered = await this.discoverDeviceUidForRecordings(channel);
89516
89650
  if (discovered) return discovered;
89517
- require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Auto-discovery failed - no UID found`);
89651
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Auto-discovery failed - no UID found`);
89518
89652
  throw new Error("UID is required to access recordings. Provide a UID explicitly or configure the client with a UID.");
89519
89653
  }
89520
89654
  cacheChannelUid(channel, uid) {
@@ -89537,35 +89671,35 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
89537
89671
  const logger = this.logger;
89538
89672
  const fromPush = this.getUidFromPushCacheForChannel(channel);
89539
89673
  if (fromPush) {
89540
- require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Using per-channel UID from push cache: ${fromPush}`);
89674
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Using per-channel UID from push cache: ${fromPush}`);
89541
89675
  return fromPush;
89542
89676
  }
89543
89677
  if (this.nativeOnly) {
89544
- require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Native-only: skipping per-channel UID discovery via HTTP/CGI (channel=${channel})`);
89678
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Native-only: skipping per-channel UID discovery via HTTP/CGI (channel=${channel})`);
89545
89679
  return;
89546
89680
  }
89547
89681
  try {
89548
- require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Attempting per-channel UID discovery via HTTP CGI GetChannelstatus (channel=${channel})`);
89682
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Attempting per-channel UID discovery via HTTP CGI GetChannelstatus (channel=${channel})`);
89549
89683
  const uidCandidate = await discoverPerChannelUidViaCgiChannelstatus({
89550
89684
  channel,
89551
89685
  login: () => this.cgiApi.login(),
89552
89686
  getChannelstatus: () => this.cgiApi.GetChannelstatus()
89553
89687
  });
89554
- require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `[HTTP CGI] GetChannelstatus channel=${channel} uid=${uidCandidate || "(missing)"}`);
89688
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `[HTTP CGI] GetChannelstatus channel=${channel} uid=${uidCandidate || "(missing)"}`);
89555
89689
  if (uidCandidate) {
89556
89690
  this.cacheChannelUid(channel, uidCandidate);
89557
- require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Using per-channel UID from GetChannelstatus: ${uidCandidate}`);
89691
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `Using per-channel UID from GetChannelstatus: ${uidCandidate}`);
89558
89692
  return uidCandidate;
89559
89693
  }
89560
89694
  } catch (e) {
89561
- require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `[HTTP CGI] GetChannelstatus failed: ${formatErrorForLog(e)}`);
89695
+ require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", `[HTTP CGI] GetChannelstatus failed: ${formatErrorForLog(e)}`);
89562
89696
  }
89563
89697
  }
89564
89698
  async discoverDeviceUidForRecordings(channel) {
89565
89699
  if (this.nativeOnly) return void 0;
89566
89700
  const dbg = this.client.getDebugConfig?.();
89567
89701
  const logger = this.logger;
89568
- const trace = (message) => require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", message);
89702
+ const trace = (message) => require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "ensureUidForRecordings", message);
89569
89703
  const discoveredUid = await discoverDeviceUidForRecordings({
89570
89704
  channel,
89571
89705
  getInfo: () => this.getInfo(),
@@ -89640,7 +89774,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
89640
89774
  await this.client.login();
89641
89775
  const dbg = this.client.getDebugConfig?.();
89642
89776
  const logger = this.logger;
89643
- const trace = (message) => require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "getVideoclipThumbnail", message);
89777
+ const trace = (message) => require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "getVideoclipThumbnail", message);
89644
89778
  const channel = this.normalizeChannel(params.channel);
89645
89779
  const snapStreamType = (params.snapType ?? "sub") === "main" ? "mainStream" : "subStream";
89646
89780
  const timeoutMs = params.timeoutMs ?? 3e4;
@@ -89691,7 +89825,7 @@ ${xml}`);
89691
89825
  cmdId: 298,
89692
89826
  ...isNvr && headerChannelIdOverride != null ? { channelIdOverride: headerChannelIdOverride } : {},
89693
89827
  msgNumOverride: 0,
89694
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
89828
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
89695
89829
  streamType: 0,
89696
89830
  payloadXml: xml,
89697
89831
  timeoutMs
@@ -90168,7 +90302,7 @@ ${stderr}`));
90168
90302
  await this.client.login();
90169
90303
  const dbg = this.client.getDebugConfig?.();
90170
90304
  const logger = this.logger;
90171
- const trace = (message) => require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "fileInfoListDownload", message);
90305
+ const trace = (message) => require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "fileInfoListDownload", message);
90172
90306
  const channel = this.normalizeChannel(params.channel);
90173
90307
  const uid = await this.ensureUidForRecordings(channel, params.uid);
90174
90308
  const headerChannelIdOverride = this.resolveHeaderChannelIdForLogicalChannel(channel);
@@ -90214,7 +90348,7 @@ ${stderr}`));
90214
90348
  cmdId: 13,
90215
90349
  channel,
90216
90350
  ...typeof chId === "number" ? { channelIdOverride: chId } : {},
90217
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_FILE_DOWNLOAD,
90351
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_FILE_DOWNLOAD,
90218
90352
  extensionXml: buildBinaryExtensionXml(channel),
90219
90353
  payloadXml,
90220
90354
  streamType: st,
@@ -90243,7 +90377,7 @@ ${stderr}`));
90243
90377
  await this.client.login();
90244
90378
  const dbg = this.client.getDebugConfig?.();
90245
90379
  const logger = this.logger;
90246
- const trace = (message) => require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "fileInfoListPagedDownload", message);
90380
+ const trace = (message) => require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "fileInfoListPagedDownload", message);
90247
90381
  const channel = this.normalizeChannel(params.channel);
90248
90382
  const uid = await this.ensureUidForRecordings(channel, params.uid);
90249
90383
  trace(`Starting paged download: channel=${channel}, uid=${uid}, fileName=${params.fileName}`);
@@ -90280,7 +90414,7 @@ ${stderr}`));
90280
90414
  await this.client.login();
90281
90415
  const dbg = this.client.getDebugConfig?.();
90282
90416
  const logger = this.logger;
90283
- const trace = (message) => require_chunk_KWWUCNIY.recordingsTraceLog(dbg, logger, "fileInfoListReplayBinaryDownload", message);
90417
+ const trace = (message) => require_chunk_ZQFQRCLQ.recordingsTraceLog(dbg, logger, "fileInfoListReplayBinaryDownload", message);
90284
90418
  const channel = this.normalizeChannel(params.channel);
90285
90419
  const headerChannelIdOverride = this.resolveHeaderChannelIdForLogicalChannel(channel);
90286
90420
  const ident = params.fileName;
@@ -90309,7 +90443,7 @@ ${stderr}`));
90309
90443
  channel,
90310
90444
  ...isNvr ? { channelIdOverride: headerChannelIdOverride ?? 82 } : {},
90311
90445
  msgNumOverride: 0,
90312
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
90446
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
90313
90447
  payloadXml,
90314
90448
  streamType: 0,
90315
90449
  timeoutMs
@@ -90393,7 +90527,7 @@ ${stderr}`));
90393
90527
  async downloadRecordingDemuxed(params) {
90394
90528
  const raw = await this.downloadRecording(params);
90395
90529
  const frames = [];
90396
- const decoder = new require_chunk_KWWUCNIY.BcMediaAnnexBDecoder({
90530
+ const decoder = new require_chunk_ZQFQRCLQ.BcMediaAnnexBDecoder({
90397
90531
  strict: false,
90398
90532
  logger: this.logger,
90399
90533
  onVideoAccessUnit: ({ annexB }) => {
@@ -90440,7 +90574,7 @@ ${stderr}`));
90440
90574
  const videoFrames = [];
90441
90575
  const audioFrames = [];
90442
90576
  let audioCodec = null;
90443
- const decoder = new require_chunk_KWWUCNIY.BcMediaAnnexBDecoder({
90577
+ const decoder = new require_chunk_ZQFQRCLQ.BcMediaAnnexBDecoder({
90444
90578
  strict: false,
90445
90579
  logger: this.logger,
90446
90580
  onVideoAccessUnit: ({ annexB, microseconds }) => {
@@ -90854,7 +90988,7 @@ ${stderr}`));
90854
90988
  params: {
90855
90989
  cmdId: 31,
90856
90990
  channelIdOverride: channel,
90857
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24
90991
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24
90858
90992
  }
90859
90993
  },
90860
90994
  {
@@ -90862,7 +90996,7 @@ ${stderr}`));
90862
90996
  params: {
90863
90997
  cmdId: 31,
90864
90998
  channelIdOverride: 251,
90865
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24
90999
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24
90866
91000
  }
90867
91001
  },
90868
91002
  {
@@ -90870,7 +91004,7 @@ ${stderr}`));
90870
91004
  params: {
90871
91005
  cmdId: 31,
90872
91006
  channelIdOverride: 250,
90873
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24
91007
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24
90874
91008
  }
90875
91009
  },
90876
91010
  {
@@ -90878,7 +91012,7 @@ ${stderr}`));
90878
91012
  params: {
90879
91013
  cmdId: 31,
90880
91014
  channelIdOverride: 250,
90881
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
91015
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
90882
91016
  extensionXml: `<?xml version="1.0" encoding="UTF-8" ?><Extension version="1.1"><channelId>251</channelId></Extension>`
90883
91017
  }
90884
91018
  }
@@ -90921,7 +91055,7 @@ ${stderr}`));
90921
91055
  const frame = await this.client.sendFrame({
90922
91056
  cmdId: 31,
90923
91057
  channelIdOverride: Number(channel),
90924
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
91058
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
90925
91059
  timeoutMs
90926
91060
  });
90927
91061
  lastCode = frame.header.responseCode;
@@ -91202,7 +91336,7 @@ ${stderr}`));
91202
91336
  msgNumOverride: msgNum,
91203
91337
  extensionXml: buildChannelExtensionXml(channelId),
91204
91338
  payloadXml,
91205
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
91339
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
91206
91340
  streamType: config.streamType,
91207
91341
  timeoutMs: 2e4
91208
91342
  };
@@ -91334,7 +91468,7 @@ ${stderr}`));
91334
91468
  channelIdOverride: channelId,
91335
91469
  extensionXml: a.extensionXml,
91336
91470
  payloadXml: a.payloadXml,
91337
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
91471
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
91338
91472
  streamType: a.streamType,
91339
91473
  ...msgNum !== void 0 ? { msgNumOverride: msgNum } : {},
91340
91474
  timeoutMs: 2e3
@@ -91364,7 +91498,7 @@ ${stderr}`));
91364
91498
  channel: ch,
91365
91499
  channelIdOverride: channelId,
91366
91500
  extensionXml: buildChannelExtensionXml(channelId),
91367
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
91501
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
91368
91502
  streamType: 0
91369
91503
  });
91370
91504
  } catch (e) {
@@ -91406,7 +91540,7 @@ ${stderr}`));
91406
91540
  channel: ch,
91407
91541
  channelIdOverride: channelId,
91408
91542
  extensionXml: buildChannelExtensionXml(channelId),
91409
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
91543
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
91410
91544
  streamType: 0
91411
91545
  });
91412
91546
  } catch (e) {
@@ -91428,7 +91562,7 @@ ${stderr}`));
91428
91562
  channelIdOverride: channelId,
91429
91563
  extensionXml,
91430
91564
  payloadXml,
91431
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
91565
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
91432
91566
  streamType: 0
91433
91567
  });
91434
91568
  if (frame.header.responseCode !== 200) {
@@ -91460,7 +91594,7 @@ ${stderr}`));
91460
91594
  channelIdOverride: channelId,
91461
91595
  extensionXml,
91462
91596
  payloadXml,
91463
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
91597
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
91464
91598
  streamType: 0
91465
91599
  });
91466
91600
  if (frame.header.responseCode !== 200) throw new Error(`PTZ preset move rejected (response_code ${frame.header.responseCode})`);
@@ -91481,7 +91615,7 @@ ${stderr}`));
91481
91615
  channelIdOverride: channelId,
91482
91616
  extensionXml,
91483
91617
  payloadXml,
91484
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
91618
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
91485
91619
  streamType: 0
91486
91620
  });
91487
91621
  if (frame.header.responseCode !== 200) throw new Error(`PTZ preset save rejected (response_code ${frame.header.responseCode})`);
@@ -91498,7 +91632,7 @@ ${stderr}`));
91498
91632
  channelIdOverride: channelId,
91499
91633
  extensionXml,
91500
91634
  payloadXml,
91501
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
91635
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
91502
91636
  streamType: 0
91503
91637
  });
91504
91638
  if (frame.header.responseCode !== 200) throw new Error(`PTZ goto preset rejected (response_code ${frame.header.responseCode})`);
@@ -91525,7 +91659,7 @@ ${stderr}`));
91525
91659
  channelIdOverride: channelId,
91526
91660
  extensionXml,
91527
91661
  payloadXml,
91528
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
91662
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
91529
91663
  streamType: 0
91530
91664
  })).header.responseCode };
91531
91665
  },
@@ -91564,6 +91698,73 @@ ${stderr}`));
91564
91698
  return result;
91565
91699
  }
91566
91700
  /**
91701
+ * Read the PTZ guard point ("monitoring point" in the app).
91702
+ *
91703
+ * cmd_id: 332
91704
+ *
91705
+ * Returns `null` when the camera has no readable guard configuration — never
91706
+ * a fabricated "none", because that answer is what a consumer uses to decide
91707
+ * whether to move the head.
91708
+ */
91709
+ async getPtzGuard(channel) {
91710
+ const ch = this.normalizeChannel(channel);
91711
+ return parsePtzGuardXml(await this.sendXml({
91712
+ cmdId: 332,
91713
+ channel: ch,
91714
+ channelIdOverride: ch,
91715
+ extensionXml: buildPtzGuardExtensionXml(ch, "read"),
91716
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
91717
+ streamType: 0
91718
+ }));
91719
+ }
91720
+ /**
91721
+ * Configure the PTZ guard point.
91722
+ *
91723
+ * cmd_id: 331 with `<command>setGrd</command>`
91724
+ *
91725
+ * `setPosition` pins the guard point to the head's CURRENT position. Leave it
91726
+ * false when only changing the timeout or the enable flag: re-sending it
91727
+ * would silently move a point the operator had already placed.
91728
+ */
91729
+ async setPtzGuard(options, channel) {
91730
+ const ch = this.normalizeChannel(channel);
91731
+ await this.sendXml({
91732
+ cmdId: 331,
91733
+ channel: ch,
91734
+ channelIdOverride: ch,
91735
+ extensionXml: buildPtzGuardExtensionXml(ch, "write"),
91736
+ payloadXml: buildPtzGuardSetXml({
91737
+ channelId: ch,
91738
+ enabled: options.enabled,
91739
+ timeoutSeconds: options.timeoutSeconds,
91740
+ setPosition: options.setPosition === true
91741
+ }),
91742
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
91743
+ streamType: 0
91744
+ });
91745
+ }
91746
+ /**
91747
+ * Send the head to the guard point NOW.
91748
+ *
91749
+ * cmd_id: 331 with `<command>toGrd</command>`
91750
+ *
91751
+ * This is the closest thing Baichuan has to a "go home": the guard point is
91752
+ * an operator-placed position, unlike preset slot 0 which merely happens to
91753
+ * be first.
91754
+ */
91755
+ async goToPtzGuard(channel) {
91756
+ const ch = this.normalizeChannel(channel);
91757
+ await this.sendXml({
91758
+ cmdId: 331,
91759
+ channel: ch,
91760
+ channelIdOverride: ch,
91761
+ extensionXml: buildPtzGuardExtensionXml(ch, "write"),
91762
+ payloadXml: buildPtzGuardGoXml(ch),
91763
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
91764
+ streamType: 0
91765
+ });
91766
+ }
91767
+ /**
91567
91768
  * Read zoom/focus min/max/current positions.
91568
91769
  * cmd_id: 294 (MSG_ID_GET_ZOOM_FOCUS)
91569
91770
  */
@@ -91575,7 +91776,7 @@ ${stderr}`));
91575
91776
  channel: ch,
91576
91777
  channelIdOverride: channelId,
91577
91778
  extensionXml: buildChannelExtensionXml(channelId),
91578
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
91779
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
91579
91780
  streamType: 0
91580
91781
  });
91581
91782
  const parseTriplet = (sectionTag) => {
@@ -91613,7 +91814,7 @@ ${stderr}`));
91613
91814
  channelIdOverride: channelId,
91614
91815
  extensionXml,
91615
91816
  payloadXml,
91616
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24,
91817
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24,
91617
91818
  streamType: 0
91618
91819
  });
91619
91820
  if (frame.header.responseCode !== 200) throw new Error(`Zoom rejected (response_code ${frame.header.responseCode})`);
@@ -91656,10 +91857,10 @@ ${stderr}`));
91656
91857
  notifyD2cDisc() {
91657
91858
  const now = Date.now();
91658
91859
  this.lastD2cDiscAtMs = now;
91659
- const streamingTags = Array.from(this.socketPool.keys()).filter((tag) => tag.startsWith("streaming:"));
91860
+ const streamingTags = Array.from(this.socketPool.keys()).filter((tag2) => tag2.startsWith("streaming:"));
91660
91861
  if (streamingTags.length > 0) {
91661
91862
  this.logger?.log?.(`[D2C_DISC] Force-closing ${streamingTags.length} streaming socket(s): ${streamingTags.join(", ")}`);
91662
- for (const tag of streamingTags) this.forceClosePooledSocket(tag, this.logger).catch(() => {});
91863
+ for (const tag2 of streamingTags) this.forceClosePooledSocket(tag2, this.logger).catch(() => {});
91663
91864
  }
91664
91865
  const immediateCooldownUntil = now + _ReolinkBaichuanApi.D2C_DISC_IMMEDIATE_COOLDOWN_MS;
91665
91866
  const existing = this.socketPoolCooldowns.get(this.host);
@@ -91692,15 +91893,15 @@ ${stderr}`));
91692
91893
  * Returns undefined if the client is not in the pool (e.g. it's the general socket used directly).
91693
91894
  */
91694
91895
  findSocketTagForClient(client) {
91695
- for (const [tag, entry] of this.socketPool) if (entry.client === client) return tag;
91896
+ for (const [tag2, entry] of this.socketPool) if (entry.client === client) return tag2;
91696
91897
  }
91697
91898
  /**
91698
91899
  * Reset the consecutive stream-start timeout counter for a streaming socket.
91699
91900
  * Called on successful stream start.
91700
91901
  */
91701
91902
  resetStreamTimeoutCounter(client) {
91702
- const tag = this.findSocketTagForClient(client);
91703
- if (tag) this.consecutiveStreamTimeouts.delete(tag);
91903
+ const tag2 = this.findSocketTagForClient(client);
91904
+ if (tag2) this.consecutiveStreamTimeouts.delete(tag2);
91704
91905
  }
91705
91906
  /**
91706
91907
  * Track a stream-start timeout on a streaming socket.
@@ -91708,14 +91909,14 @@ ${stderr}`));
91708
91909
  * socket so the next attempt creates a fresh connection.
91709
91910
  */
91710
91911
  trackStreamTimeout(client) {
91711
- const tag = this.findSocketTagForClient(client);
91712
- if (!tag || !tag.startsWith("streaming:")) return;
91713
- const count = (this.consecutiveStreamTimeouts.get(tag) ?? 0) + 1;
91714
- this.consecutiveStreamTimeouts.set(tag, count);
91912
+ const tag2 = this.findSocketTagForClient(client);
91913
+ if (!tag2 || !tag2.startsWith("streaming:")) return;
91914
+ const count = (this.consecutiveStreamTimeouts.get(tag2) ?? 0) + 1;
91915
+ this.consecutiveStreamTimeouts.set(tag2, count);
91715
91916
  if (count >= _ReolinkBaichuanApi.MAX_CONSECUTIVE_STREAM_TIMEOUTS) {
91716
- this.logger?.warn?.(`[SocketPool] ${count} consecutive stream timeouts on tag=${tag}, force-closing socket`);
91717
- this.consecutiveStreamTimeouts.delete(tag);
91718
- this.forceClosePooledSocket(tag, this.logger).catch(() => {});
91917
+ this.logger?.warn?.(`[SocketPool] ${count} consecutive stream timeouts on tag=${tag2}, force-closing socket`);
91918
+ this.consecutiveStreamTimeouts.delete(tag2);
91919
+ this.forceClosePooledSocket(tag2, this.logger).catch(() => {});
91719
91920
  }
91720
91921
  }
91721
91922
  /**
@@ -92582,8 +92783,20 @@ ${xml}`);
92582
92783
  const support = supportResult.status === "fulfilled" ? supportResult.value : void 0;
92583
92784
  const abilities = abilitiesResult.status === "fulfilled" ? abilitiesResult.value : void 0;
92584
92785
  const supportItem = getSupportItemForChannel(support, ch);
92786
+ let model;
92787
+ try {
92788
+ const info = await this.getInfo(void 0, { timeoutMs: 5e3 });
92789
+ model = typeof info?.type === "string" ? info.type : void 0;
92790
+ } catch (e) {
92791
+ this.logger.debug("[ReolinkBaichuanApi] getDeviceCapabilities: getInfo(type) failed", {
92792
+ host: this.host,
92793
+ channel: ch,
92794
+ err: e instanceof Error ? e.message : String(e)
92795
+ });
92796
+ }
92585
92797
  const capabilities = computeDeviceCapabilities({
92586
92798
  channel: ch,
92799
+ ...model != null && { model },
92587
92800
  ...support != null && { support },
92588
92801
  ...abilities != null && { abilities }
92589
92802
  });
@@ -93352,7 +93565,7 @@ ${xml}`);
93352
93565
  * @returns Test results for all stream types and profiles
93353
93566
  */
93354
93567
  async testChannelStreams(channel, logger) {
93355
- const { testChannelStreams } = await Promise.resolve().then(() => require("./DiagnosticsTools-TID5M22B-CD4rRF8a.js"));
93568
+ const { testChannelStreams } = await Promise.resolve().then(() => require("./DiagnosticsTools-GOFDNGAY-CD4rRF8a.js"));
93356
93569
  return await testChannelStreams({
93357
93570
  api: this,
93358
93571
  channel: this.normalizeChannel(channel),
@@ -93368,7 +93581,7 @@ ${xml}`);
93368
93581
  * @returns Complete diagnostics for all channels and streams
93369
93582
  */
93370
93583
  async collectMultifocalDiagnostics(logger) {
93371
- const { collectMultifocalDiagnostics } = await Promise.resolve().then(() => require("./DiagnosticsTools-TID5M22B-CD4rRF8a.js"));
93584
+ const { collectMultifocalDiagnostics } = await Promise.resolve().then(() => require("./DiagnosticsTools-GOFDNGAY-CD4rRF8a.js"));
93372
93585
  return await collectMultifocalDiagnostics({
93373
93586
  api: this,
93374
93587
  logger
@@ -95402,7 +95615,7 @@ ${scheduleItems}
95402
95615
  if (raw.length === 0) throw new Error("Downloaded recording is empty");
95403
95616
  const videoFrames = [];
95404
95617
  let videoType = null;
95405
- const decoder = new require_chunk_KWWUCNIY.BcMediaAnnexBDecoder({
95618
+ const decoder = new require_chunk_ZQFQRCLQ.BcMediaAnnexBDecoder({
95406
95619
  strict: false,
95407
95620
  logger: this.logger,
95408
95621
  onVideoAccessUnit: ({ annexB: annexB2, microseconds }) => {
@@ -95750,7 +95963,7 @@ ${scheduleItems}
95750
95963
  return {
95751
95964
  getPlaylist: () => {
95752
95965
  try {
95753
- const { readFileSync } = require_chunk_KWWUCNIY.__require("fs");
95966
+ const { readFileSync } = require_chunk_ZQFQRCLQ.__require("fs");
95754
95967
  return readFileSync(playlistPath, "utf8");
95755
95968
  } catch {
95756
95969
  return "#EXTM3U\n#EXT-X-VERSION:3\n#EXT-X-TARGETDURATION:4\n";
@@ -95759,7 +95972,7 @@ ${scheduleItems}
95759
95972
  getSegment: (name) => {
95760
95973
  if (segments.has(name)) return segments.get(name);
95761
95974
  try {
95762
- const { readFileSync } = require_chunk_KWWUCNIY.__require("fs");
95975
+ const { readFileSync } = require_chunk_ZQFQRCLQ.__require("fs");
95763
95976
  const data = readFileSync(path$3.join(tempDir, name));
95764
95977
  segments.set(name, data);
95765
95978
  return data;
@@ -95769,7 +95982,7 @@ ${scheduleItems}
95769
95982
  },
95770
95983
  listSegments: () => {
95771
95984
  try {
95772
- const { readdirSync } = require_chunk_KWWUCNIY.__require("fs");
95985
+ const { readdirSync } = require_chunk_ZQFQRCLQ.__require("fs");
95773
95986
  return readdirSync(tempDir).filter((f) => f.endsWith(".ts"));
95774
95987
  } catch {
95775
95988
  return [];
@@ -97354,41 +97567,41 @@ async function autoDetectDeviceType(inputs) {
97354
97567
  variant: "cmd80 class=0x6414",
97355
97568
  op: () => api.getInfo(void 0, {
97356
97569
  timeoutMs: 2500,
97357
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24
97570
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24
97358
97571
  })
97359
97572
  },
97360
97573
  {
97361
97574
  variant: "cmd80 class=0x6614",
97362
97575
  op: () => api.getInfo(void 0, {
97363
97576
  timeoutMs: 3e3,
97364
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_20
97577
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_20
97365
97578
  })
97366
97579
  },
97367
97580
  {
97368
97581
  variant: "cmd318(ch0) class=0x6414",
97369
97582
  op: () => api.getInfo(0, {
97370
97583
  timeoutMs: 3e3,
97371
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24
97584
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24
97372
97585
  })
97373
97586
  },
97374
97587
  {
97375
97588
  variant: "cmd318(ch0) class=0x6614",
97376
97589
  op: () => api.getInfo(0, {
97377
97590
  timeoutMs: 3500,
97378
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_20
97591
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_20
97379
97592
  })
97380
97593
  }
97381
97594
  ]), runProbeVariants("getSupportInfo", [{
97382
97595
  variant: "cmd199 class=0x6414",
97383
97596
  op: () => api.getSupportInfo({
97384
97597
  timeoutMs: 2500,
97385
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_24
97598
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_24
97386
97599
  })
97387
97600
  }, {
97388
97601
  variant: "cmd199 class=0x6614",
97389
97602
  op: () => api.getSupportInfo({
97390
97603
  timeoutMs: 3500,
97391
- messageClass: require_chunk_KWWUCNIY.BC_CLASS_MODERN_20
97604
+ messageClass: require_chunk_ZQFQRCLQ.BC_CLASS_MODERN_20
97392
97605
  })
97393
97606
  }])]);
97394
97607
  const deviceInfo = infoProbe?.value;
@@ -143917,7 +144130,7 @@ async function createRfc4571TcpServerInternal(options) {
143917
144130
  streamClient = dedicatedSession.client;
143918
144131
  logSessionsSummary(`dedicated session created: ${sessionKey}`);
143919
144132
  } else streamClient = baseApi.client;
143920
- const createLiveStream = async () => new require_chunk_KWWUCNIY.BaichuanVideoStream({
144133
+ const createLiveStream = async () => new require_chunk_ZQFQRCLQ.BaichuanVideoStream({
143921
144134
  client: streamClient,
143922
144135
  api: baseApi,
143923
144136
  channel: ch,
@@ -150160,15 +150373,39 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
150160
150373
  */
150161
150374
  async resolveHomePreset() {
150162
150375
  const chosen = this.config.get("homePresetId") ?? "";
150163
- if (chosen === "") return {
150376
+ if (chosen !== "") return {
150377
+ presetId: chosen,
150378
+ source: "operator"
150379
+ };
150380
+ if ((await this.readGuardStatus())?.valid === true) return {
150164
150381
  presetId: null,
150165
- source: "none"
150382
+ source: "native"
150166
150383
  };
150167
150384
  return {
150168
- presetId: chosen,
150169
- source: "operator"
150385
+ presetId: null,
150386
+ source: "none"
150170
150387
  };
150171
150388
  }
150389
+ /**
150390
+ * The camera's guard-point configuration, or `null` when it cannot be read.
150391
+ *
150392
+ * Never a fabricated "no guard configured": that answer decides whether
150393
+ * `goHome` moves the head, and an unreadable camera is not evidence that no
150394
+ * guard point exists (D393).
150395
+ */
150396
+ async readGuardStatus() {
150397
+ try {
150398
+ const api = await this.ensureApi();
150399
+ const channel = this.getChannel();
150400
+ return await api.getPtzGuard(channel);
150401
+ } catch (err) {
150402
+ this.ctx.logger.warn("reolink guard point unreadable — goHome will fall back", {
150403
+ tags: { deviceId: this.id },
150404
+ meta: { error: err instanceof Error ? err.message : String(err) }
150405
+ });
150406
+ return null;
150407
+ }
150408
+ }
150172
150409
  getChannel() {
150173
150410
  const ch = this.config.get("channel");
150174
150411
  if (typeof ch === "number" && ch >= 0) return ch;
@@ -153621,7 +153858,11 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
153621
153858
  goHome: async ({ deviceId }) => {
153622
153859
  if (deviceId !== this.id) return;
153623
153860
  const home = await this.resolveHomePreset();
153624
- if (home.source === "none" || home.presetId === null) throw new Error("No home preset configured for this camera — set one in the PTZ settings");
153861
+ if (home.source === "native") {
153862
+ await (await this.ensureApi()).goToPtzGuard(this.getChannel());
153863
+ return;
153864
+ }
153865
+ if (home.source === "none" || home.presetId === null) throw new Error("No home preset configured for this camera, and it has no guard point set — set one in the PTZ settings, or place a guard point on the camera");
153625
153866
  const id = Number(home.presetId);
153626
153867
  if (!Number.isFinite(id)) throw new Error(`Configured home preset is not a Baichuan id: ${home.presetId}`);
153627
153868
  const api = await this.ensureApi();
@@ -153635,6 +153876,34 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
153635
153876
  };
153636
153877
  return this.resolveHomePreset();
153637
153878
  },
153879
+ captureHomeHere: async ({ deviceId }) => {
153880
+ if (deviceId !== this.id) return;
153881
+ const current = await this.readGuardStatus();
153882
+ const api = await this.ensureApi();
153883
+ const channel = this.getChannel();
153884
+ await api.setPtzGuard({
153885
+ enabled: current?.enabled ?? false,
153886
+ timeoutSeconds: current?.timeoutSeconds ?? 60,
153887
+ setPosition: true
153888
+ }, channel);
153889
+ this.ctx.logger.info("reolink: guard point pinned to the current position", { tags: { deviceId: this.id } });
153890
+ },
153891
+ getHomeReturnSeconds: async ({ deviceId }) => {
153892
+ if (deviceId !== this.id) return null;
153893
+ const guard = await this.readGuardStatus();
153894
+ return guard === null ? null : guard.timeoutSeconds;
153895
+ },
153896
+ setHomeReturnSeconds: async ({ deviceId, seconds }) => {
153897
+ if (deviceId !== this.id) return;
153898
+ const current = await this.readGuardStatus();
153899
+ const api = await this.ensureApi();
153900
+ const channel = this.getChannel();
153901
+ await api.setPtzGuard({
153902
+ enabled: current?.enabled ?? true,
153903
+ timeoutSeconds: seconds,
153904
+ setPosition: false
153905
+ }, channel);
153906
+ },
153638
153907
  setHomePreset: async ({ deviceId, presetId }) => {
153639
153908
  if (deviceId !== this.id) return;
153640
153909
  await this.config.setAll({ homePresetId: presetId ?? "" });