@willh/copilotstatusline 0.2.2 → 0.2.4

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.
@@ -15623,6 +15623,9 @@ function renderValue(config2, label, value) {
15623
15623
  return `${config2.prefix}${body}${config2.suffix}`;
15624
15624
  }
15625
15625
  function numericValue(config2, label, value, formatter = formatTokens) {
15626
+ if (value === undefined) {
15627
+ return null;
15628
+ }
15626
15629
  if (config2.hideWhenZero && value === 0) {
15627
15630
  return null;
15628
15631
  }
@@ -15632,7 +15635,7 @@ function contextUsed(status) {
15632
15635
  if (status.context.usedPercentage !== undefined) {
15633
15636
  return status.context.usedPercentage;
15634
15637
  }
15635
- if (status.context.limitTokens <= 0) {
15638
+ if (status.context.currentTokens === undefined || status.context.limitTokens === undefined || status.context.limitTokens <= 0) {
15636
15639
  return null;
15637
15640
  }
15638
15641
  return status.context.currentTokens / status.context.limitTokens * 100;
@@ -15684,7 +15687,7 @@ function renderWidget(config2, context) {
15684
15687
  case "model":
15685
15688
  return status.modelName === undefined ? null : renderValue(config2, "Model", status.modelName);
15686
15689
  case "model-id":
15687
- return status.modelId === undefined ? null : renderValue(config2, "Model", status.modelId);
15690
+ return status.modelId === undefined ? null : renderValue(config2, "Model ID", status.modelId);
15688
15691
  case "reasoning":
15689
15692
  return status.reasoningEffort === undefined ? null : renderValue(config2, "Effort", status.reasoningEffort);
15690
15693
  case "copilot-version":
@@ -15692,7 +15695,7 @@ function renderWidget(config2, context) {
15692
15695
  case "session-id":
15693
15696
  return status.sessionId === undefined ? null : renderValue(config2, "Session", status.sessionId);
15694
15697
  case "session-name":
15695
- return status.sessionName === undefined ? null : renderValue(config2, "Session", status.sessionName);
15698
+ return status.sessionName === undefined ? null : renderValue(config2, "Session Name", status.sessionName);
15696
15699
  case "cwd":
15697
15700
  return status.cwd === undefined ? null : renderValue(config2, "", status.cwd);
15698
15701
  case "context-used": {
@@ -15714,7 +15717,7 @@ function renderWidget(config2, context) {
15714
15717
  case "lines-removed":
15715
15718
  return numericValue(config2, "-", status.cost.linesRemoved, (value) => String(value));
15716
15719
  case "allow-all":
15717
- return status.allowAll === true ? renderValue(config2, "", "YOLO") : null;
15720
+ return status.allowAll === undefined ? null : renderValue(config2, "Allow All", status.allowAll ? "ON" : "OFF");
15718
15721
  case "git-branch": {
15719
15722
  const branch = cachedCommand(`git-branch:${status.cwd ?? ""}`, context.gitCacheTtlSeconds, () => runFile("git", ["--no-optional-locks", "branch", "--show-current"], status.cwd));
15720
15723
  return branch === null ? null : renderValue(config2, "", branch);
@@ -15786,7 +15789,7 @@ var init_catalog = __esm(() => {
15786
15789
  { type: "session-duration", name: "Session Duration", description: "累計 session 時間", defaultColor: "brightBlack" },
15787
15790
  { type: "lines-added", name: "Lines Added", description: "本 session 新增行數", defaultColor: "green" },
15788
15791
  { type: "lines-removed", name: "Lines Removed", description: "本 session 刪除行數", defaultColor: "red" },
15789
- { type: "allow-all", name: "Allow All", description: "Allow-all/YOLO 狀態", defaultColor: "brightRed" },
15792
+ { type: "allow-all", name: "Allow All", description: "是否啟用所有工具與路徑權限", defaultColor: "brightRed" },
15790
15793
  { type: "git-branch", name: "Git Branch", description: "目前 Git branch", defaultColor: "magenta" },
15791
15794
  { type: "git-changes", name: "Git Changes", description: "Git staged/unstaged/untracked 數量", defaultColor: "yellow" },
15792
15795
  { type: "jj-change", name: "Jujutsu Change", description: "目前 jj change ID", defaultColor: "magenta" },
@@ -19180,9 +19183,9 @@ var require_scheduler_development = __commonJS((exports) => {
19180
19183
  return localPerformance.now();
19181
19184
  };
19182
19185
  } else {
19183
- var localDate = Date, initialTime = localDate.now();
19186
+ var localDate2 = Date, initialTime = localDate2.now();
19184
19187
  exports.unstable_now = function() {
19185
- return localDate.now() - initialTime;
19188
+ return localDate2.now() - initialTime;
19186
19189
  };
19187
19190
  }
19188
19191
  var taskQueue = [], timerQueue = [], taskIdCounter = 1, currentTask = null, currentPriorityLevel = 3, isPerformingWork = false, isHostCallbackScheduled = false, isHostTimeoutScheduled = false, needsPaint = false, localSetTimeout = typeof setTimeout === "function" ? setTimeout : null, localClearTimeout = typeof clearTimeout === "function" ? clearTimeout : null, localSetImmediate = typeof setImmediate !== "undefined" ? setImmediate : null, isMessageLoopRunning = false, taskTimeoutID = -1, frameInterval = 5, startTime = -1;
@@ -19321,11 +19324,11 @@ var require_react_reconciler_development = __commonJS((exports, module) => {
19321
19324
  fiber = fiber.next, id--;
19322
19325
  return fiber;
19323
19326
  }
19324
- function copyWithSetImpl(obj, path3, index, value) {
19325
- if (index >= path3.length)
19327
+ function copyWithSetImpl(obj, path4, index, value) {
19328
+ if (index >= path4.length)
19326
19329
  return value;
19327
- var key = path3[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
19328
- updated[key] = copyWithSetImpl(obj[key], path3, index + 1, value);
19330
+ var key = path4[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
19331
+ updated[key] = copyWithSetImpl(obj[key], path4, index + 1, value);
19329
19332
  return updated;
19330
19333
  }
19331
19334
  function copyWithRename(obj, oldPath, newPath) {
@@ -19345,11 +19348,11 @@ var require_react_reconciler_development = __commonJS((exports, module) => {
19345
19348
  index + 1 === oldPath.length ? (updated[newPath[index]] = updated[oldKey], isArrayImpl(updated) ? updated.splice(oldKey, 1) : delete updated[oldKey]) : updated[oldKey] = copyWithRenameImpl(obj[oldKey], oldPath, newPath, index + 1);
19346
19349
  return updated;
19347
19350
  }
19348
- function copyWithDeleteImpl(obj, path3, index) {
19349
- var key = path3[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
19350
- if (index + 1 === path3.length)
19351
+ function copyWithDeleteImpl(obj, path4, index) {
19352
+ var key = path4[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
19353
+ if (index + 1 === path4.length)
19351
19354
  return isArrayImpl(updated) ? updated.splice(key, 1) : delete updated[key], updated;
19352
- updated[key] = copyWithDeleteImpl(obj[key], path3, index + 1);
19355
+ updated[key] = copyWithDeleteImpl(obj[key], path4, index + 1);
19353
19356
  return updated;
19354
19357
  }
19355
19358
  function shouldSuspendImpl() {
@@ -27061,9 +27064,9 @@ Check the render method of %s.`, getComponentNameFromFiber(current) || "Unknown"
27061
27064
  return localPerformance.now();
27062
27065
  };
27063
27066
  } else {
27064
- var localDate = Date;
27067
+ var localDate2 = Date;
27065
27068
  getCurrentTime = function() {
27066
- return localDate.now();
27069
+ return localDate2.now();
27067
27070
  };
27068
27071
  }
27069
27072
  var objectIs = typeof Object.is === "function" ? Object.is : is, NoMode = 0, valueCursor = createCursor(null);
@@ -28381,29 +28384,29 @@ Check the top-level render call using <` + componentName2 + ">.");
28381
28384
  var didWarnAboutNestedUpdates = false;
28382
28385
  var didWarnAboutFindNodeInStrictMode = {};
28383
28386
  var overrideHookState = null, overrideHookStateDeletePath = null, overrideHookStateRenamePath = null, overrideProps = null, overridePropsDeletePath = null, overridePropsRenamePath = null, scheduleUpdate = null, setErrorHandler = null, setSuspenseHandler = null;
28384
- overrideHookState = function(fiber, id, path3, value) {
28387
+ overrideHookState = function(fiber, id, path4, value) {
28385
28388
  id = findHook(fiber, id);
28386
- id !== null && (path3 = copyWithSetImpl(id.memoizedState, path3, 0, value), id.memoizedState = path3, id.baseState = path3, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path3 = enqueueConcurrentRenderForLane(fiber, 2), path3 !== null && scheduleUpdateOnFiber(path3, fiber, 2));
28389
+ id !== null && (path4 = copyWithSetImpl(id.memoizedState, path4, 0, value), id.memoizedState = path4, id.baseState = path4, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path4 = enqueueConcurrentRenderForLane(fiber, 2), path4 !== null && scheduleUpdateOnFiber(path4, fiber, 2));
28387
28390
  };
28388
- overrideHookStateDeletePath = function(fiber, id, path3) {
28391
+ overrideHookStateDeletePath = function(fiber, id, path4) {
28389
28392
  id = findHook(fiber, id);
28390
- id !== null && (path3 = copyWithDeleteImpl(id.memoizedState, path3, 0), id.memoizedState = path3, id.baseState = path3, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path3 = enqueueConcurrentRenderForLane(fiber, 2), path3 !== null && scheduleUpdateOnFiber(path3, fiber, 2));
28393
+ id !== null && (path4 = copyWithDeleteImpl(id.memoizedState, path4, 0), id.memoizedState = path4, id.baseState = path4, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path4 = enqueueConcurrentRenderForLane(fiber, 2), path4 !== null && scheduleUpdateOnFiber(path4, fiber, 2));
28391
28394
  };
28392
28395
  overrideHookStateRenamePath = function(fiber, id, oldPath, newPath) {
28393
28396
  id = findHook(fiber, id);
28394
28397
  id !== null && (oldPath = copyWithRename(id.memoizedState, oldPath, newPath), id.memoizedState = oldPath, id.baseState = oldPath, fiber.memoizedProps = assign2({}, fiber.memoizedProps), oldPath = enqueueConcurrentRenderForLane(fiber, 2), oldPath !== null && scheduleUpdateOnFiber(oldPath, fiber, 2));
28395
28398
  };
28396
- overrideProps = function(fiber, path3, value) {
28397
- fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path3, 0, value);
28399
+ overrideProps = function(fiber, path4, value) {
28400
+ fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path4, 0, value);
28398
28401
  fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
28399
- path3 = enqueueConcurrentRenderForLane(fiber, 2);
28400
- path3 !== null && scheduleUpdateOnFiber(path3, fiber, 2);
28402
+ path4 = enqueueConcurrentRenderForLane(fiber, 2);
28403
+ path4 !== null && scheduleUpdateOnFiber(path4, fiber, 2);
28401
28404
  };
28402
- overridePropsDeletePath = function(fiber, path3) {
28403
- fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path3, 0);
28405
+ overridePropsDeletePath = function(fiber, path4) {
28406
+ fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path4, 0);
28404
28407
  fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
28405
- path3 = enqueueConcurrentRenderForLane(fiber, 2);
28406
- path3 !== null && scheduleUpdateOnFiber(path3, fiber, 2);
28408
+ path4 = enqueueConcurrentRenderForLane(fiber, 2);
28409
+ path4 !== null && scheduleUpdateOnFiber(path4, fiber, 2);
28407
28410
  };
28408
28411
  overridePropsRenamePath = function(fiber, oldPath, newPath) {
28409
28412
  fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath);
@@ -36229,8 +36232,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36229
36232
  }
36230
36233
  return false;
36231
36234
  }
36232
- function utils_getInObject(object2, path3) {
36233
- return path3.reduce(function(reduced, attr) {
36235
+ function utils_getInObject(object2, path4) {
36236
+ return path4.reduce(function(reduced, attr) {
36234
36237
  if (reduced) {
36235
36238
  if (utils_hasOwnProperty.call(reduced, attr)) {
36236
36239
  return reduced[attr];
@@ -36242,11 +36245,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36242
36245
  return null;
36243
36246
  }, object2);
36244
36247
  }
36245
- function deletePathInObject(object2, path3) {
36246
- var length = path3.length;
36247
- var last2 = path3[length - 1];
36248
+ function deletePathInObject(object2, path4) {
36249
+ var length = path4.length;
36250
+ var last2 = path4[length - 1];
36248
36251
  if (object2 != null) {
36249
- var parent = utils_getInObject(object2, path3.slice(0, length - 1));
36252
+ var parent = utils_getInObject(object2, path4.slice(0, length - 1));
36250
36253
  if (parent) {
36251
36254
  if (src_isArray(parent)) {
36252
36255
  parent.splice(last2, 1);
@@ -36272,11 +36275,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36272
36275
  }
36273
36276
  }
36274
36277
  }
36275
- function utils_setInObject(object2, path3, value) {
36276
- var length = path3.length;
36277
- var last2 = path3[length - 1];
36278
+ function utils_setInObject(object2, path4, value) {
36279
+ var length = path4.length;
36280
+ var last2 = path4[length - 1];
36278
36281
  if (object2 != null) {
36279
- var parent = utils_getInObject(object2, path3.slice(0, length - 1));
36282
+ var parent = utils_getInObject(object2, path4.slice(0, length - 1));
36280
36283
  if (parent) {
36281
36284
  parent[last2] = value;
36282
36285
  }
@@ -36807,8 +36810,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36807
36810
  unserializable: Symbol("unserializable")
36808
36811
  };
36809
36812
  var LEVEL_THRESHOLD = 2;
36810
- function createDehydrated(type, inspectable, data, cleaned, path3) {
36811
- cleaned.push(path3);
36813
+ function createDehydrated(type, inspectable, data, cleaned, path4) {
36814
+ cleaned.push(path4);
36812
36815
  var dehydrated = {
36813
36816
  inspectable,
36814
36817
  type,
@@ -36826,13 +36829,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36826
36829
  }
36827
36830
  return dehydrated;
36828
36831
  }
36829
- function dehydrate(data, cleaned, unserializable, path3, isPathAllowed) {
36832
+ function dehydrate(data, cleaned, unserializable, path4, isPathAllowed) {
36830
36833
  var level = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
36831
36834
  var type = getDataType(data);
36832
36835
  var isPathAllowedCheck;
36833
36836
  switch (type) {
36834
36837
  case "html_element":
36835
- cleaned.push(path3);
36838
+ cleaned.push(path4);
36836
36839
  return {
36837
36840
  inspectable: false,
36838
36841
  preview_short: formatDataForPreview(data, false),
@@ -36841,7 +36844,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36841
36844
  type
36842
36845
  };
36843
36846
  case "function":
36844
- cleaned.push(path3);
36847
+ cleaned.push(path4);
36845
36848
  return {
36846
36849
  inspectable: false,
36847
36850
  preview_short: formatDataForPreview(data, false),
@@ -36850,14 +36853,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36850
36853
  type
36851
36854
  };
36852
36855
  case "string":
36853
- isPathAllowedCheck = isPathAllowed(path3);
36856
+ isPathAllowedCheck = isPathAllowed(path4);
36854
36857
  if (isPathAllowedCheck) {
36855
36858
  return data;
36856
36859
  } else {
36857
36860
  return data.length <= 500 ? data : data.slice(0, 500) + "...";
36858
36861
  }
36859
36862
  case "bigint":
36860
- cleaned.push(path3);
36863
+ cleaned.push(path4);
36861
36864
  return {
36862
36865
  inspectable: false,
36863
36866
  preview_short: formatDataForPreview(data, false),
@@ -36866,7 +36869,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36866
36869
  type
36867
36870
  };
36868
36871
  case "symbol":
36869
- cleaned.push(path3);
36872
+ cleaned.push(path4);
36870
36873
  return {
36871
36874
  inspectable: false,
36872
36875
  preview_short: formatDataForPreview(data, false),
@@ -36875,9 +36878,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36875
36878
  type
36876
36879
  };
36877
36880
  case "react_element": {
36878
- isPathAllowedCheck = isPathAllowed(path3);
36881
+ isPathAllowedCheck = isPathAllowed(path4);
36879
36882
  if (level >= LEVEL_THRESHOLD && !isPathAllowedCheck) {
36880
- cleaned.push(path3);
36883
+ cleaned.push(path4);
36881
36884
  return {
36882
36885
  inspectable: true,
36883
36886
  preview_short: formatDataForPreview(data, false),
@@ -36894,19 +36897,19 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36894
36897
  preview_long: formatDataForPreview(data, true),
36895
36898
  name: getDisplayNameForReactElement(data) || "Unknown"
36896
36899
  };
36897
- unserializableValue.key = dehydrate(data.key, cleaned, unserializable, path3.concat(["key"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
36900
+ unserializableValue.key = dehydrate(data.key, cleaned, unserializable, path4.concat(["key"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
36898
36901
  if (data.$$typeof === REACT_LEGACY_ELEMENT_TYPE) {
36899
- unserializableValue.ref = dehydrate(data.ref, cleaned, unserializable, path3.concat(["ref"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
36902
+ unserializableValue.ref = dehydrate(data.ref, cleaned, unserializable, path4.concat(["ref"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
36900
36903
  }
36901
- unserializableValue.props = dehydrate(data.props, cleaned, unserializable, path3.concat(["props"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
36902
- unserializable.push(path3);
36904
+ unserializableValue.props = dehydrate(data.props, cleaned, unserializable, path4.concat(["props"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
36905
+ unserializable.push(path4);
36903
36906
  return unserializableValue;
36904
36907
  }
36905
36908
  case "react_lazy": {
36906
- isPathAllowedCheck = isPathAllowed(path3);
36909
+ isPathAllowedCheck = isPathAllowed(path4);
36907
36910
  var payload = data._payload;
36908
36911
  if (level >= LEVEL_THRESHOLD && !isPathAllowedCheck) {
36909
- cleaned.push(path3);
36912
+ cleaned.push(path4);
36910
36913
  var inspectable = payload !== null && hydration_typeof(payload) === "object" && (payload._status === 1 || payload._status === 2 || payload.status === "fulfilled" || payload.status === "rejected");
36911
36914
  return {
36912
36915
  inspectable,
@@ -36923,13 +36926,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36923
36926
  preview_long: formatDataForPreview(data, true),
36924
36927
  name: "lazy()"
36925
36928
  };
36926
- _unserializableValue._payload = dehydrate(payload, cleaned, unserializable, path3.concat(["_payload"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
36927
- unserializable.push(path3);
36929
+ _unserializableValue._payload = dehydrate(payload, cleaned, unserializable, path4.concat(["_payload"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
36930
+ unserializable.push(path4);
36928
36931
  return _unserializableValue;
36929
36932
  }
36930
36933
  case "array_buffer":
36931
36934
  case "data_view":
36932
- cleaned.push(path3);
36935
+ cleaned.push(path4);
36933
36936
  return {
36934
36937
  inspectable: false,
36935
36938
  preview_short: formatDataForPreview(data, false),
@@ -36939,21 +36942,21 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36939
36942
  type
36940
36943
  };
36941
36944
  case "array":
36942
- isPathAllowedCheck = isPathAllowed(path3);
36945
+ isPathAllowedCheck = isPathAllowed(path4);
36943
36946
  if (level >= LEVEL_THRESHOLD && !isPathAllowedCheck) {
36944
- return createDehydrated(type, true, data, cleaned, path3);
36947
+ return createDehydrated(type, true, data, cleaned, path4);
36945
36948
  }
36946
36949
  var arr = [];
36947
36950
  for (var i = 0;i < data.length; i++) {
36948
- arr[i] = dehydrateKey(data, i, cleaned, unserializable, path3.concat([i]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
36951
+ arr[i] = dehydrateKey(data, i, cleaned, unserializable, path4.concat([i]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
36949
36952
  }
36950
36953
  return arr;
36951
36954
  case "html_all_collection":
36952
36955
  case "typed_array":
36953
36956
  case "iterator":
36954
- isPathAllowedCheck = isPathAllowed(path3);
36957
+ isPathAllowedCheck = isPathAllowed(path4);
36955
36958
  if (level >= LEVEL_THRESHOLD && !isPathAllowedCheck) {
36956
- return createDehydrated(type, true, data, cleaned, path3);
36959
+ return createDehydrated(type, true, data, cleaned, path4);
36957
36960
  } else {
36958
36961
  var _unserializableValue2 = {
36959
36962
  unserializable: true,
@@ -36965,13 +36968,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36965
36968
  name: typeof data.constructor !== "function" || typeof data.constructor.name !== "string" || data.constructor.name === "Object" ? "" : data.constructor.name
36966
36969
  };
36967
36970
  Array.from(data).forEach(function(item, i2) {
36968
- return _unserializableValue2[i2] = dehydrate(item, cleaned, unserializable, path3.concat([i2]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
36971
+ return _unserializableValue2[i2] = dehydrate(item, cleaned, unserializable, path4.concat([i2]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
36969
36972
  });
36970
- unserializable.push(path3);
36973
+ unserializable.push(path4);
36971
36974
  return _unserializableValue2;
36972
36975
  }
36973
36976
  case "opaque_iterator":
36974
- cleaned.push(path3);
36977
+ cleaned.push(path4);
36975
36978
  return {
36976
36979
  inspectable: false,
36977
36980
  preview_short: formatDataForPreview(data, false),
@@ -36980,7 +36983,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36980
36983
  type
36981
36984
  };
36982
36985
  case "date":
36983
- cleaned.push(path3);
36986
+ cleaned.push(path4);
36984
36987
  return {
36985
36988
  inspectable: false,
36986
36989
  preview_short: formatDataForPreview(data, false),
@@ -36989,7 +36992,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36989
36992
  type
36990
36993
  };
36991
36994
  case "regexp":
36992
- cleaned.push(path3);
36995
+ cleaned.push(path4);
36993
36996
  return {
36994
36997
  inspectable: false,
36995
36998
  preview_short: formatDataForPreview(data, false),
@@ -36998,9 +37001,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36998
37001
  type
36999
37002
  };
37000
37003
  case "thenable":
37001
- isPathAllowedCheck = isPathAllowed(path3);
37004
+ isPathAllowedCheck = isPathAllowed(path4);
37002
37005
  if (level >= LEVEL_THRESHOLD && !isPathAllowedCheck) {
37003
- cleaned.push(path3);
37006
+ cleaned.push(path4);
37004
37007
  return {
37005
37008
  inspectable: data.status === "fulfilled" || data.status === "rejected",
37006
37009
  preview_short: formatDataForPreview(data, false),
@@ -37021,8 +37024,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37021
37024
  preview_long: formatDataForPreview(data, true),
37022
37025
  name: "fulfilled Thenable"
37023
37026
  };
37024
- _unserializableValue3.value = dehydrate(data.value, cleaned, unserializable, path3.concat(["value"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
37025
- unserializable.push(path3);
37027
+ _unserializableValue3.value = dehydrate(data.value, cleaned, unserializable, path4.concat(["value"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
37028
+ unserializable.push(path4);
37026
37029
  return _unserializableValue3;
37027
37030
  }
37028
37031
  case "rejected": {
@@ -37033,12 +37036,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37033
37036
  preview_long: formatDataForPreview(data, true),
37034
37037
  name: "rejected Thenable"
37035
37038
  };
37036
- _unserializableValue4.reason = dehydrate(data.reason, cleaned, unserializable, path3.concat(["reason"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
37037
- unserializable.push(path3);
37039
+ _unserializableValue4.reason = dehydrate(data.reason, cleaned, unserializable, path4.concat(["reason"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
37040
+ unserializable.push(path4);
37038
37041
  return _unserializableValue4;
37039
37042
  }
37040
37043
  default:
37041
- cleaned.push(path3);
37044
+ cleaned.push(path4);
37042
37045
  return {
37043
37046
  inspectable: false,
37044
37047
  preview_short: formatDataForPreview(data, false),
@@ -37048,21 +37051,21 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37048
37051
  };
37049
37052
  }
37050
37053
  case "object":
37051
- isPathAllowedCheck = isPathAllowed(path3);
37054
+ isPathAllowedCheck = isPathAllowed(path4);
37052
37055
  if (level >= LEVEL_THRESHOLD && !isPathAllowedCheck) {
37053
- return createDehydrated(type, true, data, cleaned, path3);
37056
+ return createDehydrated(type, true, data, cleaned, path4);
37054
37057
  } else {
37055
37058
  var object2 = {};
37056
37059
  getAllEnumerableKeys(data).forEach(function(key) {
37057
37060
  var name = key.toString();
37058
- object2[name] = dehydrateKey(data, key, cleaned, unserializable, path3.concat([name]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
37061
+ object2[name] = dehydrateKey(data, key, cleaned, unserializable, path4.concat([name]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
37059
37062
  });
37060
37063
  return object2;
37061
37064
  }
37062
37065
  case "class_instance": {
37063
- isPathAllowedCheck = isPathAllowed(path3);
37066
+ isPathAllowedCheck = isPathAllowed(path4);
37064
37067
  if (level >= LEVEL_THRESHOLD && !isPathAllowedCheck) {
37065
- return createDehydrated(type, true, data, cleaned, path3);
37068
+ return createDehydrated(type, true, data, cleaned, path4);
37066
37069
  }
37067
37070
  var value = {
37068
37071
  unserializable: true,
@@ -37074,15 +37077,15 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37074
37077
  };
37075
37078
  getAllEnumerableKeys(data).forEach(function(key) {
37076
37079
  var keyAsString = key.toString();
37077
- value[keyAsString] = dehydrate(data[key], cleaned, unserializable, path3.concat([keyAsString]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
37080
+ value[keyAsString] = dehydrate(data[key], cleaned, unserializable, path4.concat([keyAsString]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
37078
37081
  });
37079
- unserializable.push(path3);
37082
+ unserializable.push(path4);
37080
37083
  return value;
37081
37084
  }
37082
37085
  case "error": {
37083
- isPathAllowedCheck = isPathAllowed(path3);
37086
+ isPathAllowedCheck = isPathAllowed(path4);
37084
37087
  if (level >= LEVEL_THRESHOLD && !isPathAllowedCheck) {
37085
- return createDehydrated(type, true, data, cleaned, path3);
37088
+ return createDehydrated(type, true, data, cleaned, path4);
37086
37089
  }
37087
37090
  var _value = {
37088
37091
  unserializable: true,
@@ -37092,22 +37095,22 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37092
37095
  preview_long: formatDataForPreview(data, true),
37093
37096
  name: data.name
37094
37097
  };
37095
- _value.message = dehydrate(data.message, cleaned, unserializable, path3.concat(["message"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
37096
- _value.stack = dehydrate(data.stack, cleaned, unserializable, path3.concat(["stack"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
37098
+ _value.message = dehydrate(data.message, cleaned, unserializable, path4.concat(["message"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
37099
+ _value.stack = dehydrate(data.stack, cleaned, unserializable, path4.concat(["stack"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
37097
37100
  if ("cause" in data) {
37098
- _value.cause = dehydrate(data.cause, cleaned, unserializable, path3.concat(["cause"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
37101
+ _value.cause = dehydrate(data.cause, cleaned, unserializable, path4.concat(["cause"]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
37099
37102
  }
37100
37103
  getAllEnumerableKeys(data).forEach(function(key) {
37101
37104
  var keyAsString = key.toString();
37102
- _value[keyAsString] = dehydrate(data[key], cleaned, unserializable, path3.concat([keyAsString]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
37105
+ _value[keyAsString] = dehydrate(data[key], cleaned, unserializable, path4.concat([keyAsString]), isPathAllowed, isPathAllowedCheck ? 1 : level + 1);
37103
37106
  });
37104
- unserializable.push(path3);
37107
+ unserializable.push(path4);
37105
37108
  return _value;
37106
37109
  }
37107
37110
  case "infinity":
37108
37111
  case "nan":
37109
37112
  case "undefined":
37110
- cleaned.push(path3);
37113
+ cleaned.push(path4);
37111
37114
  return {
37112
37115
  type
37113
37116
  };
@@ -37115,10 +37118,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37115
37118
  return data;
37116
37119
  }
37117
37120
  }
37118
- function dehydrateKey(parent, key, cleaned, unserializable, path3, isPathAllowed) {
37121
+ function dehydrateKey(parent, key, cleaned, unserializable, path4, isPathAllowed) {
37119
37122
  var level = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;
37120
37123
  try {
37121
- return dehydrate(parent[key], cleaned, unserializable, path3, isPathAllowed, level);
37124
+ return dehydrate(parent[key], cleaned, unserializable, path4, isPathAllowed, level);
37122
37125
  } catch (error51) {
37123
37126
  var preview = "";
37124
37127
  if (hydration_typeof(error51) === "object" && error51 !== null && typeof error51.stack === "string") {
@@ -37126,7 +37129,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37126
37129
  } else if (typeof error51 === "string") {
37127
37130
  preview = error51;
37128
37131
  }
37129
- cleaned.push(path3);
37132
+ cleaned.push(path4);
37130
37133
  return {
37131
37134
  inspectable: false,
37132
37135
  preview_short: "[Exception]",
@@ -37136,8 +37139,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37136
37139
  };
37137
37140
  }
37138
37141
  }
37139
- function fillInPath(object2, data, path3, value) {
37140
- var target = getInObject(object2, path3);
37142
+ function fillInPath(object2, data, path4, value) {
37143
+ var target = getInObject(object2, path4);
37141
37144
  if (target != null) {
37142
37145
  if (!target[meta3.unserializable]) {
37143
37146
  delete target[meta3.inspectable];
@@ -37152,9 +37155,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37152
37155
  }
37153
37156
  if (value !== null && data.unserializable.length > 0) {
37154
37157
  var unserializablePath = data.unserializable[0];
37155
- var isMatch2 = unserializablePath.length === path3.length;
37156
- for (var i = 0;i < path3.length; i++) {
37157
- if (path3[i] !== unserializablePath[i]) {
37158
+ var isMatch2 = unserializablePath.length === path4.length;
37159
+ for (var i = 0;i < path4.length; i++) {
37160
+ if (path4[i] !== unserializablePath[i]) {
37158
37161
  isMatch2 = false;
37159
37162
  break;
37160
37163
  }
@@ -37163,13 +37166,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37163
37166
  upgradeUnserializable(value, value);
37164
37167
  }
37165
37168
  }
37166
- setInObject(object2, path3, value);
37169
+ setInObject(object2, path4, value);
37167
37170
  }
37168
37171
  function hydrate(object2, cleaned, unserializable) {
37169
- cleaned.forEach(function(path3) {
37170
- var length = path3.length;
37171
- var last2 = path3[length - 1];
37172
- var parent = getInObject(object2, path3.slice(0, length - 1));
37172
+ cleaned.forEach(function(path4) {
37173
+ var length = path4.length;
37174
+ var last2 = path4[length - 1];
37175
+ var parent = getInObject(object2, path4.slice(0, length - 1));
37173
37176
  if (!parent || !parent.hasOwnProperty(last2)) {
37174
37177
  return;
37175
37178
  }
@@ -37195,10 +37198,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37195
37198
  parent[last2] = replaced;
37196
37199
  }
37197
37200
  });
37198
- unserializable.forEach(function(path3) {
37199
- var length = path3.length;
37200
- var last2 = path3[length - 1];
37201
- var parent = getInObject(object2, path3.slice(0, length - 1));
37201
+ unserializable.forEach(function(path4) {
37202
+ var length = path4.length;
37203
+ var last2 = path4[length - 1];
37204
+ var parent = getInObject(object2, path4.slice(0, length - 1));
37202
37205
  if (!parent || !parent.hasOwnProperty(last2)) {
37203
37206
  return;
37204
37207
  }
@@ -37319,11 +37322,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37319
37322
  return gte2(version2, FIRST_DEVTOOLS_BACKEND_LOCKSTEP_VER);
37320
37323
  }
37321
37324
  function cleanForBridge(data, isPathAllowed) {
37322
- var path3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
37325
+ var path4 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
37323
37326
  if (data !== null) {
37324
37327
  var cleanedPaths = [];
37325
37328
  var unserializablePaths = [];
37326
- var cleanedData = dehydrate(data, cleanedPaths, unserializablePaths, path3, isPathAllowed);
37329
+ var cleanedData = dehydrate(data, cleanedPaths, unserializablePaths, path4, isPathAllowed);
37327
37330
  return {
37328
37331
  data: cleanedData,
37329
37332
  cleaned: cleanedPaths,
@@ -37333,18 +37336,18 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37333
37336
  return null;
37334
37337
  }
37335
37338
  }
37336
- function copyWithDelete(obj, path3) {
37339
+ function copyWithDelete(obj, path4) {
37337
37340
  var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
37338
- var key = path3[index];
37341
+ var key = path4[index];
37339
37342
  var updated = shared_isArray(obj) ? obj.slice() : utils_objectSpread({}, obj);
37340
- if (index + 1 === path3.length) {
37343
+ if (index + 1 === path4.length) {
37341
37344
  if (shared_isArray(updated)) {
37342
37345
  updated.splice(key, 1);
37343
37346
  } else {
37344
37347
  delete updated[key];
37345
37348
  }
37346
37349
  } else {
37347
- updated[key] = copyWithDelete(obj[key], path3, index + 1);
37350
+ updated[key] = copyWithDelete(obj[key], path4, index + 1);
37348
37351
  }
37349
37352
  return updated;
37350
37353
  }
@@ -37365,14 +37368,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37365
37368
  }
37366
37369
  return updated;
37367
37370
  }
37368
- function copyWithSet(obj, path3, value) {
37371
+ function copyWithSet(obj, path4, value) {
37369
37372
  var index = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
37370
- if (index >= path3.length) {
37373
+ if (index >= path4.length) {
37371
37374
  return value;
37372
37375
  }
37373
- var key = path3[index];
37376
+ var key = path4[index];
37374
37377
  var updated = shared_isArray(obj) ? obj.slice() : utils_objectSpread({}, obj);
37375
- updated[key] = copyWithSet(obj[key], path3, value, index + 1);
37378
+ updated[key] = copyWithSet(obj[key], path4, value, index + 1);
37376
37379
  return updated;
37377
37380
  }
37378
37381
  function getEffectDurations(root) {
@@ -38700,12 +38703,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
38700
38703
  }
38701
38704
  });
38702
38705
  bridge_defineProperty(_this, "overrideValueAtPath", function(_ref) {
38703
- var { id, path: path3, rendererID, type, value } = _ref;
38706
+ var { id, path: path4, rendererID, type, value } = _ref;
38704
38707
  switch (type) {
38705
38708
  case "context":
38706
38709
  _this.send("overrideContext", {
38707
38710
  id,
38708
- path: path3,
38711
+ path: path4,
38709
38712
  rendererID,
38710
38713
  wasForwarded: true,
38711
38714
  value
@@ -38714,7 +38717,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
38714
38717
  case "hooks":
38715
38718
  _this.send("overrideHookState", {
38716
38719
  id,
38717
- path: path3,
38720
+ path: path4,
38718
38721
  rendererID,
38719
38722
  wasForwarded: true,
38720
38723
  value
@@ -38723,7 +38726,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
38723
38726
  case "props":
38724
38727
  _this.send("overrideProps", {
38725
38728
  id,
38726
- path: path3,
38729
+ path: path4,
38727
38730
  rendererID,
38728
38731
  wasForwarded: true,
38729
38732
  value
@@ -38732,7 +38735,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
38732
38735
  case "state":
38733
38736
  _this.send("overrideState", {
38734
38737
  id,
38735
- path: path3,
38738
+ path: path4,
38736
38739
  rendererID,
38737
38740
  wasForwarded: true,
38738
38741
  value
@@ -39066,12 +39069,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
39066
39069
  }
39067
39070
  });
39068
39071
  agent_defineProperty(_this, "copyElementPath", function(_ref5) {
39069
- var { id, path: path3, rendererID } = _ref5;
39072
+ var { id, path: path4, rendererID } = _ref5;
39070
39073
  var renderer = _this._rendererInterfaces[rendererID];
39071
39074
  if (renderer == null) {
39072
39075
  console.warn('Invalid renderer id "'.concat(rendererID, '" for element "').concat(id, '"'));
39073
39076
  } else {
39074
- var value = renderer.getSerializedElementValueByPath(id, path3);
39077
+ var value = renderer.getSerializedElementValueByPath(id, path4);
39075
39078
  if (value != null) {
39076
39079
  _this._bridge.send("saveToClipboard", value);
39077
39080
  } else {
@@ -39080,12 +39083,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
39080
39083
  }
39081
39084
  });
39082
39085
  agent_defineProperty(_this, "deletePath", function(_ref6) {
39083
- var { hookID, id, path: path3, rendererID, type } = _ref6;
39086
+ var { hookID, id, path: path4, rendererID, type } = _ref6;
39084
39087
  var renderer = _this._rendererInterfaces[rendererID];
39085
39088
  if (renderer == null) {
39086
39089
  console.warn('Invalid renderer id "'.concat(rendererID, '" for element "').concat(id, '"'));
39087
39090
  } else {
39088
- renderer.deletePath(type, id, hookID, path3);
39091
+ renderer.deletePath(type, id, hookID, path4);
39089
39092
  }
39090
39093
  });
39091
39094
  agent_defineProperty(_this, "getBackendVersion", function() {
@@ -39122,12 +39125,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
39122
39125
  }
39123
39126
  });
39124
39127
  agent_defineProperty(_this, "inspectElement", function(_ref9) {
39125
- var { forceFullData, id, path: path3, rendererID, requestID } = _ref9;
39128
+ var { forceFullData, id, path: path4, rendererID, requestID } = _ref9;
39126
39129
  var renderer = _this._rendererInterfaces[rendererID];
39127
39130
  if (renderer == null) {
39128
39131
  console.warn('Invalid renderer id "'.concat(rendererID, '" for element "').concat(id, '"'));
39129
39132
  } else {
39130
- _this._bridge.send("inspectedElement", renderer.inspectElement(requestID, id, path3, forceFullData));
39133
+ _this._bridge.send("inspectedElement", renderer.inspectElement(requestID, id, path4, forceFullData));
39131
39134
  if (_this._persistedSelectionMatch === null || _this._persistedSelectionMatch.id !== id) {
39132
39135
  _this._persistedSelection = null;
39133
39136
  _this._persistedSelectionMatch = null;
@@ -39161,15 +39164,15 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
39161
39164
  }
39162
39165
  for (var rendererID in _this._rendererInterfaces) {
39163
39166
  var renderer = _this._rendererInterfaces[rendererID];
39164
- var path3 = null;
39167
+ var path4 = null;
39165
39168
  if (suspendedByPathIndex !== null && rendererPath !== null) {
39166
39169
  var suspendedByPathRendererIndex = suspendedByPathIndex - suspendedByOffset;
39167
39170
  var rendererHasRequestedSuspendedByPath = renderer.getElementAttributeByPath(id, ["suspendedBy", suspendedByPathRendererIndex]) !== undefined;
39168
39171
  if (rendererHasRequestedSuspendedByPath) {
39169
- path3 = ["suspendedBy", suspendedByPathRendererIndex].concat(rendererPath);
39172
+ path4 = ["suspendedBy", suspendedByPathRendererIndex].concat(rendererPath);
39170
39173
  }
39171
39174
  }
39172
- var inspectedRootsPayload = renderer.inspectElement(requestID, id, path3, forceFullData);
39175
+ var inspectedRootsPayload = renderer.inspectElement(requestID, id, path4, forceFullData);
39173
39176
  switch (inspectedRootsPayload.type) {
39174
39177
  case "hydrated-path":
39175
39178
  inspectedRootsPayload.path[1] += suspendedByOffset;
@@ -39263,20 +39266,20 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
39263
39266
  }
39264
39267
  });
39265
39268
  agent_defineProperty(_this, "overrideValueAtPath", function(_ref15) {
39266
- var { hookID, id, path: path3, rendererID, type, value } = _ref15;
39269
+ var { hookID, id, path: path4, rendererID, type, value } = _ref15;
39267
39270
  var renderer = _this._rendererInterfaces[rendererID];
39268
39271
  if (renderer == null) {
39269
39272
  console.warn('Invalid renderer id "'.concat(rendererID, '" for element "').concat(id, '"'));
39270
39273
  } else {
39271
- renderer.overrideValueAtPath(type, id, hookID, path3, value);
39274
+ renderer.overrideValueAtPath(type, id, hookID, path4, value);
39272
39275
  }
39273
39276
  });
39274
39277
  agent_defineProperty(_this, "overrideContext", function(_ref16) {
39275
- var { id, path: path3, rendererID, wasForwarded, value } = _ref16;
39278
+ var { id, path: path4, rendererID, wasForwarded, value } = _ref16;
39276
39279
  if (!wasForwarded) {
39277
39280
  _this.overrideValueAtPath({
39278
39281
  id,
39279
- path: path3,
39282
+ path: path4,
39280
39283
  rendererID,
39281
39284
  type: "context",
39282
39285
  value
@@ -39284,11 +39287,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
39284
39287
  }
39285
39288
  });
39286
39289
  agent_defineProperty(_this, "overrideHookState", function(_ref17) {
39287
- var { id, hookID, path: path3, rendererID, wasForwarded, value } = _ref17;
39290
+ var { id, hookID, path: path4, rendererID, wasForwarded, value } = _ref17;
39288
39291
  if (!wasForwarded) {
39289
39292
  _this.overrideValueAtPath({
39290
39293
  id,
39291
- path: path3,
39294
+ path: path4,
39292
39295
  rendererID,
39293
39296
  type: "hooks",
39294
39297
  value
@@ -39296,11 +39299,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
39296
39299
  }
39297
39300
  });
39298
39301
  agent_defineProperty(_this, "overrideProps", function(_ref18) {
39299
- var { id, path: path3, rendererID, wasForwarded, value } = _ref18;
39302
+ var { id, path: path4, rendererID, wasForwarded, value } = _ref18;
39300
39303
  if (!wasForwarded) {
39301
39304
  _this.overrideValueAtPath({
39302
39305
  id,
39303
- path: path3,
39306
+ path: path4,
39304
39307
  rendererID,
39305
39308
  type: "props",
39306
39309
  value
@@ -39308,11 +39311,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
39308
39311
  }
39309
39312
  });
39310
39313
  agent_defineProperty(_this, "overrideState", function(_ref19) {
39311
- var { id, path: path3, rendererID, wasForwarded, value } = _ref19;
39314
+ var { id, path: path4, rendererID, wasForwarded, value } = _ref19;
39312
39315
  if (!wasForwarded) {
39313
39316
  _this.overrideValueAtPath({
39314
39317
  id,
39315
- path: path3,
39318
+ path: path4,
39316
39319
  rendererID,
39317
39320
  type: "state",
39318
39321
  value
@@ -39379,12 +39382,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
39379
39382
  _this._bridge.send("stopInspectingHost", selected);
39380
39383
  });
39381
39384
  agent_defineProperty(_this, "storeAsGlobal", function(_ref23) {
39382
- var { count, id, path: path3, rendererID } = _ref23;
39385
+ var { count, id, path: path4, rendererID } = _ref23;
39383
39386
  var renderer = _this._rendererInterfaces[rendererID];
39384
39387
  if (renderer == null) {
39385
39388
  console.warn('Invalid renderer id "'.concat(rendererID, '" for element "').concat(id, '"'));
39386
39389
  } else {
39387
- renderer.storeAsGlobal(id, path3, count);
39390
+ renderer.storeAsGlobal(id, path4, count);
39388
39391
  }
39389
39392
  });
39390
39393
  agent_defineProperty(_this, "updateHookSettings", function(settings) {
@@ -39401,12 +39404,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
39401
39404
  var rendererID = +rendererIDString;
39402
39405
  var renderer = _this._rendererInterfaces[rendererID];
39403
39406
  if (_this._lastSelectedRendererID === rendererID) {
39404
- var path3 = renderer.getPathForElement(_this._lastSelectedElementID);
39405
- if (path3 !== null) {
39406
- renderer.setTrackedPath(path3);
39407
+ var path4 = renderer.getPathForElement(_this._lastSelectedElementID);
39408
+ if (path4 !== null) {
39409
+ renderer.setTrackedPath(path4);
39407
39410
  _this._persistedSelection = {
39408
39411
  rendererID,
39409
- path: path3
39412
+ path: path4
39410
39413
  };
39411
39414
  }
39412
39415
  }
@@ -39481,11 +39484,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
39481
39484
  var rendererID = _this._lastSelectedRendererID;
39482
39485
  var id = _this._lastSelectedElementID;
39483
39486
  var renderer = _this._rendererInterfaces[rendererID];
39484
- var path3 = renderer != null ? renderer.getPathForElement(id) : null;
39485
- if (path3 !== null) {
39487
+ var path4 = renderer != null ? renderer.getPathForElement(id) : null;
39488
+ if (path4 !== null) {
39486
39489
  storage_sessionStorageSetItem(SESSION_STORAGE_LAST_SELECTION_KEY, JSON.stringify({
39487
39490
  rendererID,
39488
- path: path3
39491
+ path: path4
39489
39492
  }));
39490
39493
  } else {
39491
39494
  storage_sessionStorageRemoveItem(SESSION_STORAGE_LAST_SELECTION_KEY);
@@ -40208,7 +40211,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
40208
40211
  hasElementWithId: function hasElementWithId() {
40209
40212
  return false;
40210
40213
  },
40211
- inspectElement: function inspectElement(requestID, id, path3) {
40214
+ inspectElement: function inspectElement(requestID, id, path4) {
40212
40215
  return {
40213
40216
  id,
40214
40217
  responseID: requestID,
@@ -45478,9 +45481,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
45478
45481
  }
45479
45482
  return null;
45480
45483
  }
45481
- function getElementAttributeByPath(id, path3) {
45484
+ function getElementAttributeByPath(id, path4) {
45482
45485
  if (isMostRecentlyInspectedElement(id)) {
45483
- return utils_getInObject(mostRecentlyInspectedElement, path3);
45486
+ return utils_getInObject(mostRecentlyInspectedElement, path4);
45484
45487
  }
45485
45488
  return;
45486
45489
  }
@@ -46183,9 +46186,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
46183
46186
  function isMostRecentlyInspectedElementCurrent(id) {
46184
46187
  return isMostRecentlyInspectedElement(id) && !hasElementUpdatedSinceLastInspected;
46185
46188
  }
46186
- function mergeInspectedPaths(path3) {
46189
+ function mergeInspectedPaths(path4) {
46187
46190
  var current = currentlyInspectedPaths;
46188
- path3.forEach(function(key) {
46191
+ path4.forEach(function(key) {
46189
46192
  if (!current[key]) {
46190
46193
  current[key] = {};
46191
46194
  }
@@ -46193,21 +46196,21 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
46193
46196
  });
46194
46197
  }
46195
46198
  function createIsPathAllowed(key, secondaryCategory) {
46196
- return function isPathAllowed(path3) {
46199
+ return function isPathAllowed(path4) {
46197
46200
  switch (secondaryCategory) {
46198
46201
  case "hooks":
46199
- if (path3.length === 1) {
46202
+ if (path4.length === 1) {
46200
46203
  return true;
46201
46204
  }
46202
- if (path3[path3.length - 2] === "hookSource" && path3[path3.length - 1] === "fileName") {
46205
+ if (path4[path4.length - 2] === "hookSource" && path4[path4.length - 1] === "fileName") {
46203
46206
  return true;
46204
46207
  }
46205
- if (path3[path3.length - 1] === "subHooks" || path3[path3.length - 2] === "subHooks") {
46208
+ if (path4[path4.length - 1] === "subHooks" || path4[path4.length - 2] === "subHooks") {
46206
46209
  return true;
46207
46210
  }
46208
46211
  break;
46209
46212
  case "suspendedBy":
46210
- if (path3.length < 5) {
46213
+ if (path4.length < 5) {
46211
46214
  return true;
46212
46215
  }
46213
46216
  break;
@@ -46218,8 +46221,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
46218
46221
  if (!current) {
46219
46222
  return false;
46220
46223
  }
46221
- for (var i = 0;i < path3.length; i++) {
46222
- current = current[path3[i]];
46224
+ for (var i = 0;i < path4.length; i++) {
46225
+ current = current[path4[i]];
46223
46226
  if (!current) {
46224
46227
  return false;
46225
46228
  }
@@ -46273,38 +46276,38 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
46273
46276
  break;
46274
46277
  }
46275
46278
  }
46276
- function storeAsGlobal(id, path3, count) {
46279
+ function storeAsGlobal(id, path4, count) {
46277
46280
  if (isMostRecentlyInspectedElement(id)) {
46278
- var value = utils_getInObject(mostRecentlyInspectedElement, path3);
46281
+ var value = utils_getInObject(mostRecentlyInspectedElement, path4);
46279
46282
  var key = "$reactTemp".concat(count);
46280
46283
  window[key] = value;
46281
46284
  console.log(key);
46282
46285
  console.log(value);
46283
46286
  }
46284
46287
  }
46285
- function getSerializedElementValueByPath(id, path3) {
46288
+ function getSerializedElementValueByPath(id, path4) {
46286
46289
  if (isMostRecentlyInspectedElement(id)) {
46287
- var valueToCopy = utils_getInObject(mostRecentlyInspectedElement, path3);
46290
+ var valueToCopy = utils_getInObject(mostRecentlyInspectedElement, path4);
46288
46291
  return serializeToString(valueToCopy);
46289
46292
  }
46290
46293
  }
46291
- function inspectElement(requestID, id, path3, forceFullData) {
46292
- if (path3 !== null) {
46293
- mergeInspectedPaths(path3);
46294
+ function inspectElement(requestID, id, path4, forceFullData) {
46295
+ if (path4 !== null) {
46296
+ mergeInspectedPaths(path4);
46294
46297
  }
46295
46298
  if (isMostRecentlyInspectedElement(id) && !forceFullData) {
46296
46299
  if (!hasElementUpdatedSinceLastInspected) {
46297
- if (path3 !== null) {
46300
+ if (path4 !== null) {
46298
46301
  var secondaryCategory = null;
46299
- if (path3[0] === "hooks" || path3[0] === "suspendedBy") {
46300
- secondaryCategory = path3[0];
46302
+ if (path4[0] === "hooks" || path4[0] === "suspendedBy") {
46303
+ secondaryCategory = path4[0];
46301
46304
  }
46302
46305
  return {
46303
46306
  id,
46304
46307
  responseID: requestID,
46305
46308
  type: "hydrated-path",
46306
- path: path3,
46307
- value: cleanForBridge(utils_getInObject(mostRecentlyInspectedElement, path3), createIsPathAllowed(null, secondaryCategory), path3)
46309
+ path: path4,
46310
+ value: cleanForBridge(utils_getInObject(mostRecentlyInspectedElement, path4), createIsPathAllowed(null, secondaryCategory), path4)
46308
46311
  };
46309
46312
  } else {
46310
46313
  return {
@@ -46500,7 +46503,7 @@ The error thrown in the component is:
46500
46503
  console.groupEnd();
46501
46504
  }
46502
46505
  }
46503
- function deletePath(type, id, hookID, path3) {
46506
+ function deletePath(type, id, hookID, path4) {
46504
46507
  var devtoolsInstance = idToDevToolsInstanceMap.get(id);
46505
46508
  if (devtoolsInstance === undefined) {
46506
46509
  console.warn('Could not find DevToolsInstance with id "'.concat(id, '"'));
@@ -46514,11 +46517,11 @@ The error thrown in the component is:
46514
46517
  var instance = fiber.stateNode;
46515
46518
  switch (type) {
46516
46519
  case "context":
46517
- path3 = path3.slice(1);
46520
+ path4 = path4.slice(1);
46518
46521
  switch (fiber.tag) {
46519
46522
  case ClassComponent:
46520
- if (path3.length === 0) {} else {
46521
- deletePathInObject(instance.context, path3);
46523
+ if (path4.length === 0) {} else {
46524
+ deletePathInObject(instance.context, path4);
46522
46525
  }
46523
46526
  instance.forceUpdate();
46524
46527
  break;
@@ -46528,21 +46531,21 @@ The error thrown in the component is:
46528
46531
  break;
46529
46532
  case "hooks":
46530
46533
  if (typeof overrideHookStateDeletePath === "function") {
46531
- overrideHookStateDeletePath(fiber, hookID, path3);
46534
+ overrideHookStateDeletePath(fiber, hookID, path4);
46532
46535
  }
46533
46536
  break;
46534
46537
  case "props":
46535
46538
  if (instance === null) {
46536
46539
  if (typeof overridePropsDeletePath === "function") {
46537
- overridePropsDeletePath(fiber, path3);
46540
+ overridePropsDeletePath(fiber, path4);
46538
46541
  }
46539
46542
  } else {
46540
- fiber.pendingProps = copyWithDelete(instance.props, path3);
46543
+ fiber.pendingProps = copyWithDelete(instance.props, path4);
46541
46544
  instance.forceUpdate();
46542
46545
  }
46543
46546
  break;
46544
46547
  case "state":
46545
- deletePathInObject(instance.state, path3);
46548
+ deletePathInObject(instance.state, path4);
46546
46549
  instance.forceUpdate();
46547
46550
  break;
46548
46551
  }
@@ -46597,7 +46600,7 @@ The error thrown in the component is:
46597
46600
  }
46598
46601
  }
46599
46602
  }
46600
- function overrideValueAtPath(type, id, hookID, path3, value) {
46603
+ function overrideValueAtPath(type, id, hookID, path4, value) {
46601
46604
  var devtoolsInstance = idToDevToolsInstanceMap.get(id);
46602
46605
  if (devtoolsInstance === undefined) {
46603
46606
  console.warn('Could not find DevToolsInstance with id "'.concat(id, '"'));
@@ -46611,13 +46614,13 @@ The error thrown in the component is:
46611
46614
  var instance = fiber.stateNode;
46612
46615
  switch (type) {
46613
46616
  case "context":
46614
- path3 = path3.slice(1);
46617
+ path4 = path4.slice(1);
46615
46618
  switch (fiber.tag) {
46616
46619
  case ClassComponent:
46617
- if (path3.length === 0) {
46620
+ if (path4.length === 0) {
46618
46621
  instance.context = value;
46619
46622
  } else {
46620
- utils_setInObject(instance.context, path3, value);
46623
+ utils_setInObject(instance.context, path4, value);
46621
46624
  }
46622
46625
  instance.forceUpdate();
46623
46626
  break;
@@ -46627,18 +46630,18 @@ The error thrown in the component is:
46627
46630
  break;
46628
46631
  case "hooks":
46629
46632
  if (typeof overrideHookState === "function") {
46630
- overrideHookState(fiber, hookID, path3, value);
46633
+ overrideHookState(fiber, hookID, path4, value);
46631
46634
  }
46632
46635
  break;
46633
46636
  case "props":
46634
46637
  switch (fiber.tag) {
46635
46638
  case ClassComponent:
46636
- fiber.pendingProps = copyWithSet(instance.props, path3, value);
46639
+ fiber.pendingProps = copyWithSet(instance.props, path4, value);
46637
46640
  instance.forceUpdate();
46638
46641
  break;
46639
46642
  default:
46640
46643
  if (typeof overrideProps === "function") {
46641
- overrideProps(fiber, path3, value);
46644
+ overrideProps(fiber, path4, value);
46642
46645
  }
46643
46646
  break;
46644
46647
  }
@@ -46646,7 +46649,7 @@ The error thrown in the component is:
46646
46649
  case "state":
46647
46650
  switch (fiber.tag) {
46648
46651
  case ClassComponent:
46649
- utils_setInObject(instance.state, path3, value);
46652
+ utils_setInObject(instance.state, path4, value);
46650
46653
  instance.forceUpdate();
46651
46654
  break;
46652
46655
  }
@@ -46932,14 +46935,14 @@ The error thrown in the component is:
46932
46935
  var trackedPathMatchInstance = null;
46933
46936
  var trackedPathMatchDepth = -1;
46934
46937
  var mightBeOnTrackedPath = false;
46935
- function setTrackedPath(path3) {
46936
- if (path3 === null) {
46938
+ function setTrackedPath(path4) {
46939
+ if (path4 === null) {
46937
46940
  trackedPathMatchFiber = null;
46938
46941
  trackedPathMatchInstance = null;
46939
46942
  trackedPathMatchDepth = -1;
46940
46943
  mightBeOnTrackedPath = false;
46941
46944
  }
46942
- trackedPath = path3;
46945
+ trackedPath = path4;
46943
46946
  }
46944
46947
  function updateTrackedPathStateBeforeMount(fiber, fiberInstance) {
46945
46948
  if (trackedPath === null || !mightBeOnTrackedPath) {
@@ -47703,9 +47706,9 @@ The error thrown in the component is:
47703
47706
  }
47704
47707
  var currentlyInspectedElementID = null;
47705
47708
  var currentlyInspectedPaths = {};
47706
- function mergeInspectedPaths(path3) {
47709
+ function mergeInspectedPaths(path4) {
47707
47710
  var current = currentlyInspectedPaths;
47708
- path3.forEach(function(key) {
47711
+ path4.forEach(function(key) {
47709
47712
  if (!current[key]) {
47710
47713
  current[key] = {};
47711
47714
  }
@@ -47713,13 +47716,13 @@ The error thrown in the component is:
47713
47716
  });
47714
47717
  }
47715
47718
  function createIsPathAllowed(key) {
47716
- return function isPathAllowed(path3) {
47719
+ return function isPathAllowed(path4) {
47717
47720
  var current = currentlyInspectedPaths[key];
47718
47721
  if (!current) {
47719
47722
  return false;
47720
47723
  }
47721
- for (var i = 0;i < path3.length; i++) {
47722
- current = current[path3[i]];
47724
+ for (var i = 0;i < path4.length; i++) {
47725
+ current = current[path4[i]];
47723
47726
  if (!current) {
47724
47727
  return false;
47725
47728
  }
@@ -47769,24 +47772,24 @@ The error thrown in the component is:
47769
47772
  break;
47770
47773
  }
47771
47774
  }
47772
- function storeAsGlobal(id, path3, count) {
47775
+ function storeAsGlobal(id, path4, count) {
47773
47776
  var inspectedElement = inspectElementRaw(id);
47774
47777
  if (inspectedElement !== null) {
47775
- var value = utils_getInObject(inspectedElement, path3);
47778
+ var value = utils_getInObject(inspectedElement, path4);
47776
47779
  var key = "$reactTemp".concat(count);
47777
47780
  window[key] = value;
47778
47781
  console.log(key);
47779
47782
  console.log(value);
47780
47783
  }
47781
47784
  }
47782
- function getSerializedElementValueByPath(id, path3) {
47785
+ function getSerializedElementValueByPath(id, path4) {
47783
47786
  var inspectedElement = inspectElementRaw(id);
47784
47787
  if (inspectedElement !== null) {
47785
- var valueToCopy = utils_getInObject(inspectedElement, path3);
47788
+ var valueToCopy = utils_getInObject(inspectedElement, path4);
47786
47789
  return serializeToString(valueToCopy);
47787
47790
  }
47788
47791
  }
47789
- function inspectElement(requestID, id, path3, forceFullData) {
47792
+ function inspectElement(requestID, id, path4, forceFullData) {
47790
47793
  if (forceFullData || currentlyInspectedElementID !== id) {
47791
47794
  currentlyInspectedElementID = id;
47792
47795
  currentlyInspectedPaths = {};
@@ -47799,8 +47802,8 @@ The error thrown in the component is:
47799
47802
  type: "not-found"
47800
47803
  };
47801
47804
  }
47802
- if (path3 !== null) {
47803
- mergeInspectedPaths(path3);
47805
+ if (path4 !== null) {
47806
+ mergeInspectedPaths(path4);
47804
47807
  }
47805
47808
  updateSelectedElement(id);
47806
47809
  inspectedElement.context = cleanForBridge(inspectedElement.context, createIsPathAllowed("context"));
@@ -48003,10 +48006,10 @@ The error thrown in the component is:
48003
48006
  console.groupEnd();
48004
48007
  }
48005
48008
  }
48006
- function getElementAttributeByPath(id, path3) {
48009
+ function getElementAttributeByPath(id, path4) {
48007
48010
  var inspectedElement = inspectElementRaw(id);
48008
48011
  if (inspectedElement !== null) {
48009
- return utils_getInObject(inspectedElement, path3);
48012
+ return utils_getInObject(inspectedElement, path4);
48010
48013
  }
48011
48014
  return;
48012
48015
  }
@@ -48023,14 +48026,14 @@ The error thrown in the component is:
48023
48026
  }
48024
48027
  return element.type;
48025
48028
  }
48026
- function deletePath(type, id, hookID, path3) {
48029
+ function deletePath(type, id, hookID, path4) {
48027
48030
  var internalInstance = idToInternalInstanceMap.get(id);
48028
48031
  if (internalInstance != null) {
48029
48032
  var publicInstance = internalInstance._instance;
48030
48033
  if (publicInstance != null) {
48031
48034
  switch (type) {
48032
48035
  case "context":
48033
- deletePathInObject(publicInstance.context, path3);
48036
+ deletePathInObject(publicInstance.context, path4);
48034
48037
  forceUpdate(publicInstance);
48035
48038
  break;
48036
48039
  case "hooks":
@@ -48038,12 +48041,12 @@ The error thrown in the component is:
48038
48041
  case "props":
48039
48042
  var element = internalInstance._currentElement;
48040
48043
  internalInstance._currentElement = legacy_renderer_objectSpread(legacy_renderer_objectSpread({}, element), {}, {
48041
- props: copyWithDelete(element.props, path3)
48044
+ props: copyWithDelete(element.props, path4)
48042
48045
  });
48043
48046
  forceUpdate(publicInstance);
48044
48047
  break;
48045
48048
  case "state":
48046
- deletePathInObject(publicInstance.state, path3);
48049
+ deletePathInObject(publicInstance.state, path4);
48047
48050
  forceUpdate(publicInstance);
48048
48051
  break;
48049
48052
  }
@@ -48077,14 +48080,14 @@ The error thrown in the component is:
48077
48080
  }
48078
48081
  }
48079
48082
  }
48080
- function overrideValueAtPath(type, id, hookID, path3, value) {
48083
+ function overrideValueAtPath(type, id, hookID, path4, value) {
48081
48084
  var internalInstance = idToInternalInstanceMap.get(id);
48082
48085
  if (internalInstance != null) {
48083
48086
  var publicInstance = internalInstance._instance;
48084
48087
  if (publicInstance != null) {
48085
48088
  switch (type) {
48086
48089
  case "context":
48087
- utils_setInObject(publicInstance.context, path3, value);
48090
+ utils_setInObject(publicInstance.context, path4, value);
48088
48091
  forceUpdate(publicInstance);
48089
48092
  break;
48090
48093
  case "hooks":
@@ -48092,12 +48095,12 @@ The error thrown in the component is:
48092
48095
  case "props":
48093
48096
  var element = internalInstance._currentElement;
48094
48097
  internalInstance._currentElement = legacy_renderer_objectSpread(legacy_renderer_objectSpread({}, element), {}, {
48095
- props: copyWithSet(element.props, path3, value)
48098
+ props: copyWithSet(element.props, path4, value)
48096
48099
  });
48097
48100
  forceUpdate(publicInstance);
48098
48101
  break;
48099
48102
  case "state":
48100
- utils_setInObject(publicInstance.state, path3, value);
48103
+ utils_setInObject(publicInstance.state, path4, value);
48101
48104
  forceUpdate(publicInstance);
48102
48105
  break;
48103
48106
  }
@@ -48138,7 +48141,7 @@ The error thrown in the component is:
48138
48141
  return [];
48139
48142
  }
48140
48143
  function setTraceUpdatesEnabled(enabled) {}
48141
- function setTrackedPath(path3) {}
48144
+ function setTrackedPath(path4) {}
48142
48145
  function getOwnersList(id) {
48143
48146
  return null;
48144
48147
  }
@@ -51582,7 +51585,7 @@ var init_Text = __esm(() => {
51582
51585
  });
51583
51586
 
51584
51587
  // node_modules/ink/build/components/ErrorOverview.js
51585
- import * as fs3 from "node:fs";
51588
+ import * as fs4 from "node:fs";
51586
51589
  import { cwd } from "node:process";
51587
51590
  function ErrorOverview({ error: error51 }) {
51588
51591
  const stack = error51.stack ? error51.stack.split(`
@@ -51591,8 +51594,8 @@ function ErrorOverview({ error: error51 }) {
51591
51594
  const filePath = cleanupPath(origin?.file);
51592
51595
  let excerpt;
51593
51596
  let lineWidth = 0;
51594
- if (filePath && origin?.line && fs3.existsSync(filePath)) {
51595
- const sourceCode = fs3.readFileSync(filePath, "utf8");
51597
+ if (filePath && origin?.line && fs4.existsSync(filePath)) {
51598
+ const sourceCode = fs4.readFileSync(filePath, "utf8");
51596
51599
  excerpt = dist_default3(sourceCode, origin.line);
51597
51600
  if (excerpt) {
51598
51601
  for (const { line } of excerpt) {
@@ -51609,8 +51612,8 @@ function ErrorOverview({ error: error51 }) {
51609
51612
  return import_react11.default.createElement(Box_default, { key: line }, import_react11.default.createElement(Text, { dimColor: true }, "- "), import_react11.default.createElement(Text, { dimColor: true, bold: true }, parsedLine.function), import_react11.default.createElement(Text, { dimColor: true, color: "gray", "aria-label": `at ${cleanupPath(parsedLine.file) ?? ""} line ${parsedLine.line} column ${parsedLine.column}` }, " ", "(", cleanupPath(parsedLine.file) ?? "", ":", parsedLine.line, ":", parsedLine.column, ")"));
51610
51613
  })));
51611
51614
  }
51612
- var import_react11, import_stack_utils, cleanupPath = (path3) => {
51613
- return path3?.replace(`file://${cwd()}/`, "");
51615
+ var import_react11, import_stack_utils, cleanupPath = (path4) => {
51616
+ return path4?.replace(`file://${cwd()}/`, "");
51614
51617
  }, stackUtils;
51615
51618
  var init_ErrorOverview = __esm(() => {
51616
51619
  init_dist3();
@@ -53171,21 +53174,21 @@ var require_tinycolor = __commonJS((exports, module) => {
53171
53174
  };
53172
53175
  }
53173
53176
  function rgbToHex(r, g, b, allow3Char) {
53174
- var hex3 = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
53177
+ var hex3 = [pad22(Math.round(r).toString(16)), pad22(Math.round(g).toString(16)), pad22(Math.round(b).toString(16))];
53175
53178
  if (allow3Char && hex3[0].charAt(0) == hex3[0].charAt(1) && hex3[1].charAt(0) == hex3[1].charAt(1) && hex3[2].charAt(0) == hex3[2].charAt(1)) {
53176
53179
  return hex3[0].charAt(0) + hex3[1].charAt(0) + hex3[2].charAt(0);
53177
53180
  }
53178
53181
  return hex3.join("");
53179
53182
  }
53180
53183
  function rgbaToHex(r, g, b, a, allow4Char) {
53181
- var hex3 = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16)), pad2(convertDecimalToHex(a))];
53184
+ var hex3 = [pad22(Math.round(r).toString(16)), pad22(Math.round(g).toString(16)), pad22(Math.round(b).toString(16)), pad22(convertDecimalToHex(a))];
53182
53185
  if (allow4Char && hex3[0].charAt(0) == hex3[0].charAt(1) && hex3[1].charAt(0) == hex3[1].charAt(1) && hex3[2].charAt(0) == hex3[2].charAt(1) && hex3[3].charAt(0) == hex3[3].charAt(1)) {
53183
53186
  return hex3[0].charAt(0) + hex3[1].charAt(0) + hex3[2].charAt(0) + hex3[3].charAt(0);
53184
53187
  }
53185
53188
  return hex3.join("");
53186
53189
  }
53187
53190
  function rgbaToArgbHex(r, g, b, a) {
53188
- var hex3 = [pad2(convertDecimalToHex(a)), pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
53191
+ var hex3 = [pad22(convertDecimalToHex(a)), pad22(Math.round(r).toString(16)), pad22(Math.round(g).toString(16)), pad22(Math.round(b).toString(16))];
53189
53192
  return hex3.join("");
53190
53193
  }
53191
53194
  tinycolor.equals = function(color1, color2) {
@@ -53563,7 +53566,7 @@ var require_tinycolor = __commonJS((exports, module) => {
53563
53566
  function isPercentage(n) {
53564
53567
  return typeof n === "string" && n.indexOf("%") != -1;
53565
53568
  }
53566
- function pad2(c) {
53569
+ function pad22(c) {
53567
53570
  return c.length == 1 ? "0" + c : "" + c;
53568
53571
  }
53569
53572
  function convertToPercentage(n) {
@@ -54312,7 +54315,7 @@ var package_default;
54312
54315
  var init_package = __esm(() => {
54313
54316
  package_default = {
54314
54317
  name: "@willh/copilotstatusline",
54315
- version: "0.2.2",
54318
+ version: "0.2.4",
54316
54319
  bugs: {
54317
54320
  url: "https://github.com/doggy8088/copilotstatusline/issues"
54318
54321
  },
@@ -54398,6 +54401,26 @@ var init_package = __esm(() => {
54398
54401
  };
54399
54402
  });
54400
54403
 
54404
+ // src/tui/vertical-navigation.ts
54405
+ function getVerticalNavigationDirection(input, key) {
54406
+ if (key.upArrow) {
54407
+ return -1;
54408
+ }
54409
+ if (key.downArrow) {
54410
+ return 1;
54411
+ }
54412
+ if (key.ctrl || key.meta) {
54413
+ return null;
54414
+ }
54415
+ if (input === "k") {
54416
+ return -1;
54417
+ }
54418
+ if (input === "j") {
54419
+ return 1;
54420
+ }
54421
+ return null;
54422
+ }
54423
+
54401
54424
  // node_modules/react/cjs/react-jsx-dev-runtime.development.js
54402
54425
  var require_react_jsx_dev_runtime_development = __commonJS((exports) => {
54403
54426
  var React11 = __toESM(require_react());
@@ -54649,14 +54672,13 @@ function List({
54649
54672
  latestSelectionChange.current?.(selectedValue, selectedIndex);
54650
54673
  }
54651
54674
  }, [selectedIndex, selectedValue]);
54652
- use_input_default((_, key) => {
54675
+ use_input_default((input, key) => {
54653
54676
  if (selectableItems.length === 0) {
54654
54677
  return;
54655
54678
  }
54656
- if (key.upArrow) {
54657
- setSelectedIndex((index) => index === 0 ? selectableItems.length - 1 : index - 1);
54658
- } else if (key.downArrow) {
54659
- setSelectedIndex((index) => index === selectableItems.length - 1 ? 0 : index + 1);
54679
+ const direction = getVerticalNavigationDirection(input, key);
54680
+ if (direction !== null) {
54681
+ setSelectedIndex((index) => (index + direction + selectableItems.length) % selectableItems.length);
54660
54682
  } else if (key.return && selectedItem !== undefined) {
54661
54683
  onSelect(selectedItem.value, selectedIndex);
54662
54684
  }
@@ -54799,13 +54821,13 @@ function ColorEditor({
54799
54821
  }
54800
54822
  return;
54801
54823
  }
54802
- if (key.upArrow || key.downArrow) {
54803
- const direction = key.upArrow ? -1 : 1;
54804
- setSelectedIndex((selectedIndex + direction + widgets.length) % widgets.length);
54824
+ const direction = getVerticalNavigationDirection(input, key);
54825
+ if (direction !== null) {
54826
+ setSelectedIndex((index) => (index + direction + widgets.length) % widgets.length);
54805
54827
  } else if ((key.leftArrow || key.rightArrow) && selectedWidget !== undefined) {
54806
- const direction = key.leftArrow ? -1 : 1;
54828
+ const direction2 = key.leftArrow ? -1 : 1;
54807
54829
  const field = editingBackground ? "backgroundColor" : "color";
54808
- onUpdate(widgets.map((widget2, index) => index === selectedIndex ? { ...widget2, [field]: cycleColor(widget2[field], direction) } : widget2));
54830
+ onUpdate(widgets.map((widget2, index) => index === selectedIndex ? { ...widget2, [field]: cycleColor(widget2[field], direction2) } : widget2));
54809
54831
  } else if (input === "f") {
54810
54832
  setEditingBackground((value) => !value);
54811
54833
  } else if (input === "b" && selectedWidget !== undefined) {
@@ -54881,7 +54903,7 @@ function ColorEditor({
54881
54903
  /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
54882
54904
  dimColor: true,
54883
54905
  children: [
54884
- "↑↓ select, ←→ cycle",
54906
+ "↑↓/j/k select, ←→ cycle",
54885
54907
  " ",
54886
54908
  editingBackground ? "background" : "foreground",
54887
54909
  ", (f) toggle bg/fg, (b)old, (r)eset, (c)lear all, ESC back"
@@ -55014,8 +55036,8 @@ function LineSelector({
55014
55036
  return;
55015
55037
  }
55016
55038
  if (moveMode) {
55017
- if ((key.upArrow || key.downArrow) && lines.length > 1) {
55018
- const direction = key.upArrow ? -1 : 1;
55039
+ const direction = getVerticalNavigationDirection(input, key);
55040
+ if (direction !== null && lines.length > 1) {
55019
55041
  const target = (selectedIndex + direction + lines.length) % lines.length;
55020
55042
  const reordered = [...lines];
55021
55043
  const current = reordered[selectedIndex];
@@ -55080,7 +55102,7 @@ function LineSelector({
55080
55102
  }, undefined, false, undefined, this),
55081
55103
  /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
55082
55104
  dimColor: true,
55083
- children: moveMode ? "↑↓ to move line, ESC or Enter to exit move mode" : allowEditing ? "(a) append line, (d) delete line, (m) move line, ESC back" : "ESC to go back"
55105
+ children: moveMode ? "↑↓/j/k to move line, ESC or Enter to exit move mode" : allowEditing ? "↑↓/j/k select, (a) append line, (d) delete line, (m) move line, ESC back" : "↑↓/j/k select, ESC to go back"
55084
55106
  }, undefined, false, undefined, this),
55085
55107
  moveMode ? /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
55086
55108
  marginTop: 1,
@@ -55209,6 +55231,10 @@ function MainMenu({
55209
55231
  bold: true,
55210
55232
  children: "Main Menu"
55211
55233
  }, undefined, false, undefined, this),
55234
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
55235
+ dimColor: true,
55236
+ children: "↑↓ or j/k to select, Enter to open"
55237
+ }, undefined, false, undefined, this),
55212
55238
  /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(List, {
55213
55239
  items: menuItems(integration, hasChanges),
55214
55240
  marginTop: 1,
@@ -55464,8 +55490,8 @@ function WidgetEditor({
55464
55490
  return;
55465
55491
  }
55466
55492
  const current = pickerIndex < 0 ? 0 : pickerIndex;
55467
- const direction = key.upArrow ? -1 : 1;
55468
- const nextIndex = (current + direction + filteredCatalog.length) % filteredCatalog.length;
55493
+ const direction2 = key.upArrow ? -1 : 1;
55494
+ const nextIndex = (current + direction2 + filteredCatalog.length) % filteredCatalog.length;
55469
55495
  setPicker({ ...picker, selectedType: filteredCatalog[nextIndex]?.type ?? null });
55470
55496
  } else if (key.return && selectedPickerEntry !== undefined) {
55471
55497
  applyPicker(selectedPickerEntry.type);
@@ -55481,9 +55507,9 @@ function WidgetEditor({
55481
55507
  return;
55482
55508
  }
55483
55509
  if (moveMode) {
55484
- if ((key.upArrow || key.downArrow) && widgets.length > 1) {
55485
- const direction = key.upArrow ? -1 : 1;
55486
- const target = (selectedIndex + direction + widgets.length) % widgets.length;
55510
+ const direction2 = getVerticalNavigationDirection(input, key);
55511
+ if (direction2 !== null && widgets.length > 1) {
55512
+ const target = (selectedIndex + direction2 + widgets.length) % widgets.length;
55487
55513
  const reordered = [...widgets];
55488
55514
  const current = reordered[selectedIndex];
55489
55515
  const replacement = reordered[target];
@@ -55506,9 +55532,9 @@ function WidgetEditor({
55506
55532
  if (globalKeyAction === "ignore") {
55507
55533
  return;
55508
55534
  }
55509
- if ((key.upArrow || key.downArrow) && widgets.length > 0) {
55510
- const direction = key.upArrow ? -1 : 1;
55511
- setSelectedIndex((selectedIndex + direction + widgets.length) % widgets.length);
55535
+ const direction = getVerticalNavigationDirection(input, key);
55536
+ if (direction !== null && widgets.length > 0) {
55537
+ setSelectedIndex((index) => (index + direction + widgets.length) % widgets.length);
55512
55538
  } else if ((key.leftArrow || key.rightArrow) && currentWidget !== undefined) {
55513
55539
  openPicker("change");
55514
55540
  } else if (key.return && currentWidget !== undefined) {
@@ -55521,7 +55547,7 @@ function WidgetEditor({
55521
55547
  const next = widgets.filter((_, index) => index !== selectedIndex);
55522
55548
  onUpdate(next);
55523
55549
  setSelectedIndex(Math.max(0, Math.min(selectedIndex, next.length - 1)));
55524
- } else if (input === "k" && currentWidget !== undefined) {
55550
+ } else if (input === "y" && currentWidget !== undefined) {
55525
55551
  const clone3 = { ...currentWidget, id: randomUUID() };
55526
55552
  const next = [...widgets];
55527
55553
  next.splice(selectedIndex + 1, 0, clone3);
@@ -55686,7 +55712,7 @@ function WidgetEditor({
55686
55712
  }, undefined, true, undefined, this),
55687
55713
  /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
55688
55714
  dimColor: true,
55689
- children: moveMode ? "↑↓ move widget, ESC or Enter exit move mode" : "↑↓ select, ←→ change, Enter move, (a)dd, (i)nsert, (k) clone, (d)elete, (c)lear"
55715
+ children: moveMode ? "↑↓/j/k move widget, ESC or Enter exit move mode" : "↑↓/j/k select, ←→ change, Enter move, (a)dd, (i)nsert, (y) clone, (d)elete, (c)lear"
55690
55716
  }, undefined, false, undefined, this),
55691
55717
  /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
55692
55718
  dimColor: true,
@@ -56484,7 +56510,7 @@ var CopilotStatusSchema = exports_external.looseObject({
56484
56510
  allow_all: exports_external.boolean().optional()
56485
56511
  });
56486
56512
  function finiteNumber(value) {
56487
- return typeof value === "number" && Number.isFinite(value) ? value : 0;
56513
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
56488
56514
  }
56489
56515
  function normalizeCopilotStatus(status) {
56490
56516
  const model = status.model;
@@ -56497,7 +56523,15 @@ function normalizeCopilotStatus(status) {
56497
56523
  const cacheWriteTokens = finiteNumber(context?.total_cache_write_tokens);
56498
56524
  const reasoningTokens = finiteNumber(context?.total_reasoning_tokens);
56499
56525
  const reportedTotal = finiteNumber(context?.total_tokens);
56500
- const totalTokens = reportedTotal > 0 ? reportedTotal : inputTokens + outputTokens + cacheReadTokens + cacheWriteTokens + reasoningTokens;
56526
+ const componentTokens = [
56527
+ inputTokens,
56528
+ outputTokens,
56529
+ cacheReadTokens,
56530
+ cacheWriteTokens,
56531
+ reasoningTokens
56532
+ ];
56533
+ const derivedTotal = componentTokens.some((value) => value !== undefined) ? componentTokens.reduce((sum, value) => sum + (value ?? 0), 0) : undefined;
56534
+ const totalTokens = reportedTotal ?? derivedTotal;
56501
56535
  return {
56502
56536
  sessionId: status.session_id,
56503
56537
  sessionName: status.session_name ?? undefined,
@@ -56535,7 +56569,338 @@ function normalizeCopilotStatus(status) {
56535
56569
  init_app_settings();
56536
56570
  init_copilot_settings();
56537
56571
  init_renderer();
56538
- var PACKAGE_VERSION = "0.2.2";
56572
+
56573
+ // src/utils/token-usage.ts
56574
+ init_zod();
56575
+ init_copilot_settings();
56576
+ import * as fs3 from "node:fs";
56577
+ import * as path3 from "node:path";
56578
+ var USAGE_RECORDING_DISABLE_ENV = "COPILOTSTATUSLINE_DISABLE_USAGE_RECORDING";
56579
+ var STATE_VERSION = 1;
56580
+ var MAX_TRACKED_SESSIONS = 100;
56581
+ var DEFAULT_LOCK_TIMEOUT_MS = 100;
56582
+ var DEFAULT_STALE_LOCK_MS = 5000;
56583
+ var nonNegativeInteger = exports_external.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
56584
+ var sessionStateSchema = exports_external.object({
56585
+ sessionId: exports_external.string(),
56586
+ turnNo: nonNegativeInteger,
56587
+ model: exports_external.string(),
56588
+ modelId: exports_external.string(),
56589
+ inputTokens: nonNegativeInteger,
56590
+ outputTokens: nonNegativeInteger,
56591
+ cacheReadTokens: nonNegativeInteger,
56592
+ cacheWriteTokens: nonNegativeInteger,
56593
+ reasoningTokens: nonNegativeInteger,
56594
+ totalTokens: nonNegativeInteger,
56595
+ updatedAt: exports_external.string(),
56596
+ updatedAtEpochMs: nonNegativeInteger
56597
+ });
56598
+ var usageStateSchema = exports_external.object({
56599
+ version: exports_external.literal(STATE_VERSION),
56600
+ sessions: exports_external.record(exports_external.string(), sessionStateSchema)
56601
+ });
56602
+ var legacyStateSchema = exports_external.looseObject({
56603
+ session_id: exports_external.string(),
56604
+ turn_no: nonNegativeInteger.optional(),
56605
+ model: exports_external.string().optional(),
56606
+ model_id: exports_external.string().optional(),
56607
+ input_tokens: nonNegativeInteger.optional(),
56608
+ output_tokens: nonNegativeInteger.optional(),
56609
+ cache_read_tokens: nonNegativeInteger.optional(),
56610
+ cache_write_tokens: nonNegativeInteger.optional(),
56611
+ reasoning_tokens: nonNegativeInteger.optional(),
56612
+ total_tokens: nonNegativeInteger.optional()
56613
+ });
56614
+ function emptyState() {
56615
+ return {
56616
+ version: STATE_VERSION,
56617
+ sessions: {}
56618
+ };
56619
+ }
56620
+ function isNodeError(error51, code) {
56621
+ return error51.code === code;
56622
+ }
56623
+ function pad(value, length = 2) {
56624
+ return String(value).padStart(length, "0");
56625
+ }
56626
+ function localDate(date5) {
56627
+ return `${date5.getFullYear()}-${pad(date5.getMonth() + 1)}-${pad(date5.getDate())}`;
56628
+ }
56629
+ function localIsoTimestamp(date5) {
56630
+ const offsetMinutes = -date5.getTimezoneOffset();
56631
+ const offsetSign = offsetMinutes >= 0 ? "+" : "-";
56632
+ const absoluteOffset = Math.abs(offsetMinutes);
56633
+ const offsetHours = Math.floor(absoluteOffset / 60);
56634
+ const remainingMinutes = absoluteOffset % 60;
56635
+ return `${localDate(date5)}T${pad(date5.getHours())}:${pad(date5.getMinutes())}:${pad(date5.getSeconds())}` + `${offsetSign}${pad(offsetHours)}:${pad(remainingMinutes)}`;
56636
+ }
56637
+ function delay(milliseconds) {
56638
+ return new Promise((resolve3) => setTimeout(resolve3, milliseconds));
56639
+ }
56640
+ async function acquireLock(lockPath, timeoutMs, staleLockMs) {
56641
+ const startedAt = Date.now();
56642
+ for (;; ) {
56643
+ try {
56644
+ await fs3.promises.mkdir(lockPath);
56645
+ return async () => fs3.promises.rm(lockPath, { recursive: true, force: true });
56646
+ } catch (error51) {
56647
+ if (!isNodeError(error51, "EEXIST")) {
56648
+ throw error51;
56649
+ }
56650
+ const stats = await fs3.promises.stat(lockPath).catch(() => {
56651
+ return;
56652
+ });
56653
+ if (stats !== undefined && Date.now() - stats.mtimeMs > staleLockMs) {
56654
+ await fs3.promises.rm(lockPath, { recursive: true, force: true });
56655
+ continue;
56656
+ }
56657
+ if (Date.now() - startedAt >= timeoutMs) {
56658
+ throw new Error(`timed out waiting for usage lock after ${timeoutMs} ms`, { cause: error51 });
56659
+ }
56660
+ await delay(Math.min(10, Math.max(1, timeoutMs)));
56661
+ }
56662
+ }
56663
+ }
56664
+ async function atomicWriteJson2(filePath, value) {
56665
+ const temporaryPath = path3.join(path3.dirname(filePath), `${path3.basename(filePath)}.${process.pid}.${Date.now()}.tmp`);
56666
+ try {
56667
+ await fs3.promises.writeFile(temporaryPath, `${JSON.stringify(value, null, 2)}
56668
+ `, "utf8");
56669
+ await fs3.promises.rename(temporaryPath, filePath);
56670
+ } catch (error51) {
56671
+ await fs3.promises.unlink(temporaryPath).catch(() => {
56672
+ return;
56673
+ });
56674
+ throw error51;
56675
+ }
56676
+ }
56677
+ function legacySessionState(input, sessionId, updatedAt, updatedAtEpochMs) {
56678
+ const parsed = legacyStateSchema.safeParse(input);
56679
+ if (!parsed.success || parsed.data.session_id !== sessionId) {
56680
+ return;
56681
+ }
56682
+ return {
56683
+ sessionId,
56684
+ turnNo: parsed.data.turn_no ?? 0,
56685
+ model: parsed.data.model ?? "unknown",
56686
+ modelId: parsed.data.model_id ?? "unknown",
56687
+ inputTokens: parsed.data.input_tokens ?? 0,
56688
+ outputTokens: parsed.data.output_tokens ?? 0,
56689
+ cacheReadTokens: parsed.data.cache_read_tokens ?? 0,
56690
+ cacheWriteTokens: parsed.data.cache_write_tokens ?? 0,
56691
+ reasoningTokens: parsed.data.reasoning_tokens ?? 0,
56692
+ totalTokens: parsed.data.total_tokens ?? 0,
56693
+ updatedAt,
56694
+ updatedAtEpochMs
56695
+ };
56696
+ }
56697
+ async function loadLegacyState(copilotHome, sessionId, updatedAt, updatedAtEpochMs) {
56698
+ try {
56699
+ const input = await fs3.promises.readFile(path3.join(copilotHome, "statusline-state.json"), "utf8");
56700
+ const legacy = legacySessionState(JSON.parse(input), sessionId, updatedAt, updatedAtEpochMs);
56701
+ const state = emptyState();
56702
+ if (legacy !== undefined) {
56703
+ state.sessions[sessionId] = legacy;
56704
+ }
56705
+ return state;
56706
+ } catch {
56707
+ return emptyState();
56708
+ }
56709
+ }
56710
+ async function loadState(statePath, copilotHome, sessionId, updatedAt, updatedAtEpochMs) {
56711
+ let input;
56712
+ try {
56713
+ input = await fs3.promises.readFile(statePath, "utf8");
56714
+ } catch (error51) {
56715
+ if (!isNodeError(error51, "ENOENT")) {
56716
+ throw error51;
56717
+ }
56718
+ return { state: await loadLegacyState(copilotHome, sessionId, updatedAt, updatedAtEpochMs) };
56719
+ }
56720
+ try {
56721
+ const parsedJson = JSON.parse(input);
56722
+ const parsed = usageStateSchema.safeParse(parsedJson);
56723
+ if (!parsed.success) {
56724
+ throw new Error("state schema is invalid");
56725
+ }
56726
+ return { state: parsed.data };
56727
+ } catch {
56728
+ const corruptPath = `${statePath}.corrupt.${Date.now()}.${process.pid}`;
56729
+ await fs3.promises.rename(statePath, corruptPath);
56730
+ return {
56731
+ state: emptyState(),
56732
+ warning: `recovered invalid usage state as ${corruptPath}`
56733
+ };
56734
+ }
56735
+ }
56736
+ function tokenCounters(status) {
56737
+ const cumulative = [
56738
+ status.context.inputTokens,
56739
+ status.context.outputTokens,
56740
+ status.context.cacheReadTokens,
56741
+ status.context.cacheWriteTokens,
56742
+ status.context.reasoningTokens,
56743
+ status.context.totalTokens
56744
+ ];
56745
+ const optional2 = [
56746
+ status.context.lastCallInputTokens,
56747
+ status.context.lastCallOutputTokens,
56748
+ status.context.currentTokens,
56749
+ status.context.limitTokens
56750
+ ];
56751
+ const present = [...cumulative, ...optional2].filter((value) => value !== undefined);
56752
+ if (!present.every((value) => Number.isSafeInteger(value) && value >= 0)) {
56753
+ throw new Error("token counters must be non-negative safe integers");
56754
+ }
56755
+ if (cumulative.some((value) => value === undefined)) {
56756
+ return;
56757
+ }
56758
+ const [
56759
+ inputTokens,
56760
+ outputTokens,
56761
+ cacheReadTokens,
56762
+ cacheWriteTokens,
56763
+ reasoningTokens,
56764
+ totalTokens
56765
+ ] = cumulative;
56766
+ return {
56767
+ inputTokens: inputTokens ?? 0,
56768
+ outputTokens: outputTokens ?? 0,
56769
+ cacheReadTokens: cacheReadTokens ?? 0,
56770
+ cacheWriteTokens: cacheWriteTokens ?? 0,
56771
+ reasoningTokens: reasoningTokens ?? 0,
56772
+ totalTokens: totalTokens ?? 0
56773
+ };
56774
+ }
56775
+ function delta(current, previous) {
56776
+ return Math.max(0, current - (previous ?? 0));
56777
+ }
56778
+ function sessionStateKey(sessionId) {
56779
+ return Buffer.from(sessionId, "utf8").toString("base64url");
56780
+ }
56781
+ function pruneSessions(state) {
56782
+ const sessions = Object.entries(state.sessions);
56783
+ if (sessions.length <= MAX_TRACKED_SESSIONS) {
56784
+ return;
56785
+ }
56786
+ sessions.sort((left, right) => {
56787
+ return right[1].updatedAtEpochMs - left[1].updatedAtEpochMs;
56788
+ });
56789
+ state.sessions = Object.fromEntries(sessions.slice(0, MAX_TRACKED_SESSIONS));
56790
+ }
56791
+ async function recordTokenUsage(status, options = {}) {
56792
+ if (process.env[USAGE_RECORDING_DISABLE_ENV] === "1") {
56793
+ return { recorded: false };
56794
+ }
56795
+ const sessionId = status.sessionId;
56796
+ if (sessionId === undefined || sessionId.trim() === "") {
56797
+ return { recorded: false };
56798
+ }
56799
+ const counters = tokenCounters(status);
56800
+ if (counters === undefined) {
56801
+ return { recorded: false };
56802
+ }
56803
+ const now = options.now ?? new Date;
56804
+ const timestamp = localIsoTimestamp(now);
56805
+ const copilotHome = options.copilotHome ?? getCopilotHome();
56806
+ const usageDirectory = path3.join(copilotHome, "usage");
56807
+ const statePath = path3.join(copilotHome, "copilotstatusline-usage-state.json");
56808
+ const lockPath = path3.join(copilotHome, "copilotstatusline-usage.lock");
56809
+ await fs3.promises.mkdir(copilotHome, { recursive: true });
56810
+ const releaseLock = await acquireLock(lockPath, options.lockTimeoutMs ?? DEFAULT_LOCK_TIMEOUT_MS, options.staleLockMs ?? DEFAULT_STALE_LOCK_MS);
56811
+ try {
56812
+ const loaded = await loadState(statePath, copilotHome, sessionId, timestamp, now.getTime());
56813
+ const state = loaded.state;
56814
+ const sessionKey = sessionStateKey(sessionId);
56815
+ const previous = state.sessions[sessionKey] ?? state.sessions[sessionId];
56816
+ const model = status.modelName ?? status.modelId ?? "unknown";
56817
+ const modelId = status.modelId ?? "unknown";
56818
+ const deltaInput = delta(counters.inputTokens, previous?.inputTokens);
56819
+ const deltaOutput = delta(counters.outputTokens, previous?.outputTokens);
56820
+ const deltaCacheRead = delta(counters.cacheReadTokens, previous?.cacheReadTokens);
56821
+ const deltaCacheWrite = delta(counters.cacheWriteTokens, previous?.cacheWriteTokens);
56822
+ const deltaReasoning = delta(counters.reasoningTokens, previous?.reasoningTokens);
56823
+ const deltaTotal = delta(counters.totalTokens, previous?.totalTokens);
56824
+ const previousModel = previous?.model ?? "";
56825
+ const modelChanged = previousModel !== "" && previousModel !== model;
56826
+ const turnNo = (previous?.turnNo ?? 0) + (deltaTotal > 0 ? 1 : 0);
56827
+ if (deltaTotal > 0) {
56828
+ const entry = {
56829
+ timestamp,
56830
+ session_id: sessionId,
56831
+ session_name: status.sessionName ?? "",
56832
+ transcript_path: status.transcriptPath ?? "",
56833
+ cwd: status.cwd ?? "",
56834
+ version: status.version ?? "",
56835
+ turn_no: turnNo,
56836
+ model,
56837
+ model_id: modelId,
56838
+ previous_model: previousModel,
56839
+ model_changed: modelChanged,
56840
+ tokens: {
56841
+ input: counters.inputTokens,
56842
+ output: counters.outputTokens,
56843
+ cache_read: counters.cacheReadTokens,
56844
+ cache_write: counters.cacheWriteTokens,
56845
+ reasoning: counters.reasoningTokens,
56846
+ total: counters.totalTokens,
56847
+ last_call_input: status.context.lastCallInputTokens,
56848
+ last_call_output: status.context.lastCallOutputTokens
56849
+ },
56850
+ delta_tokens: {
56851
+ input: deltaInput,
56852
+ output: deltaOutput,
56853
+ cache_read: deltaCacheRead,
56854
+ cache_write: deltaCacheWrite,
56855
+ reasoning: deltaReasoning,
56856
+ total: deltaTotal
56857
+ },
56858
+ context: {
56859
+ current_context_tokens: status.context.currentTokens,
56860
+ displayed_context_limit: status.context.limitTokens,
56861
+ current_context_used_percentage: status.context.usedPercentage === undefined ? "" : String(status.context.usedPercentage)
56862
+ },
56863
+ cost: {
56864
+ total_api_duration_ms: status.cost.apiDurationMs,
56865
+ total_duration_ms: status.cost.durationMs,
56866
+ total_premium_requests: status.cost.premiumRequests,
56867
+ total_lines_added: status.cost.linesAdded,
56868
+ total_lines_removed: status.cost.linesRemoved
56869
+ }
56870
+ };
56871
+ await fs3.promises.mkdir(usageDirectory, { recursive: true });
56872
+ const jsonlPath = path3.join(usageDirectory, `usage-${localDate(now)}.jsonl`);
56873
+ await fs3.promises.appendFile(jsonlPath, `${JSON.stringify(entry)}
56874
+ `, "utf8");
56875
+ }
56876
+ Reflect.deleteProperty(state.sessions, sessionId);
56877
+ state.sessions[sessionKey] = {
56878
+ sessionId,
56879
+ turnNo,
56880
+ model,
56881
+ modelId,
56882
+ inputTokens: counters.inputTokens,
56883
+ outputTokens: counters.outputTokens,
56884
+ cacheReadTokens: counters.cacheReadTokens,
56885
+ cacheWriteTokens: counters.cacheWriteTokens,
56886
+ reasoningTokens: counters.reasoningTokens,
56887
+ totalTokens: counters.totalTokens,
56888
+ updatedAt: timestamp,
56889
+ updatedAtEpochMs: now.getTime()
56890
+ };
56891
+ pruneSessions(state);
56892
+ await atomicWriteJson2(statePath, state);
56893
+ return {
56894
+ recorded: deltaTotal > 0,
56895
+ ...loaded.warning === undefined ? {} : { warning: loaded.warning }
56896
+ };
56897
+ } finally {
56898
+ await releaseLock();
56899
+ }
56900
+ }
56901
+
56902
+ // src/copilotstatusline.ts
56903
+ var PACKAGE_VERSION = "0.2.4";
56539
56904
  async function readStdin() {
56540
56905
  process.stdin.setEncoding("utf8");
56541
56906
  const chunks = [];
@@ -56566,12 +56931,21 @@ async function renderPipedStatus() {
56566
56931
  if (!parsed.success) {
56567
56932
  throw new Error(`Invalid Copilot status JSON: ${parsed.error.message}`);
56568
56933
  }
56934
+ const status = normalizeCopilotStatus(parsed.data);
56935
+ try {
56936
+ const recording = await recordTokenUsage(status);
56937
+ if (recording.warning !== undefined) {
56938
+ console.error(`copilotstatusline: ${recording.warning}`);
56939
+ }
56940
+ } catch (error51) {
56941
+ const message = error51 instanceof Error ? error51.message : String(error51);
56942
+ console.error(`copilotstatusline: unable to record token usage: ${message}`);
56943
+ }
56569
56944
  const settings = await loadSettings();
56570
56945
  const warning = getSettingsLoadError();
56571
56946
  if (warning !== null) {
56572
56947
  console.error(`copilotstatusline: ${warning}; using defaults without overwriting the file`);
56573
56948
  }
56574
- const status = normalizeCopilotStatus(parsed.data);
56575
56949
  for (const line of renderStatusLines(status, settings)) {
56576
56950
  console.log(line);
56577
56951
  }