@camstack/addon-admin-ui 1.2.435 → 1.2.436

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.
Files changed (134) hide show
  1. package/dist/assets/{AddonAssetIcon-DwyvMm0j.js → AddonAssetIcon-BPpbpBRb.js} +1 -1
  2. package/dist/assets/Addons-BKpZvzxZ.js +4 -0
  3. package/dist/assets/{AdminPage-Dla2hgly.js → AdminPage-Dq8Ikceb.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-C6laWV2D.js → AdminSectionedPage-CMXlVHaE.js} +1 -1
  5. package/dist/assets/AiProfiles-BNa-wvuk.js +3 -0
  6. package/dist/assets/{BrokerForm-XPsm7VqN.js → BrokerForm-CTEvkdiJ.js} +1 -1
  7. package/dist/assets/Build-BtwPkUNT.js +40 -0
  8. package/dist/assets/{Calendars-D9aQ6xfy.js → Calendars-BDEesia0.js} +1 -1
  9. package/dist/assets/Cluster-CPOYtnsH.js +1 -0
  10. package/dist/assets/ClusterStepModel-CD3lGILg.js +1 -0
  11. package/dist/assets/{CompositionEditor-Djw5jKF1.js → CompositionEditor-thMDSEPc.js} +1 -1
  12. package/dist/assets/CompositionEditorPage-sur0OoTs.js +1 -0
  13. package/dist/assets/Data-DYZzdYTt.js +2 -0
  14. package/dist/assets/DeviceDetail-Dfkdbk5S.js +2 -0
  15. package/dist/assets/{DeviceDoActionFields-DLWA9-J9.js → DeviceDoActionFields-C3Dz4KrE.js} +1 -1
  16. package/dist/assets/{Devices-C1k3PqRv.js → Devices-xUTbIFJe.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-Dz0lVYTn.js → EmbedPlayerPage-DYCZQ47V.js} +1 -1
  18. package/dist/assets/Identity-DRemX8Kt.js +1 -0
  19. package/dist/assets/IntegrationDetail-CVONA8Vu.js +1 -0
  20. package/dist/assets/IntegrationHub-CKPuIBCW.js +1 -0
  21. package/dist/assets/{Integrations-B3EhTwi-.js → Integrations-D8689xLx.js} +1 -1
  22. package/dist/assets/Integrations-RmhoSCir.js +1 -0
  23. package/dist/assets/{Library-BLUxFISX.js → Library-bvbXCasj.js} +1 -1
  24. package/dist/assets/Locations-DvnbXzXE.js +3 -0
  25. package/dist/assets/{Logs-C5wdcV2o.js → Logs-BCis7K87.js} +1 -1
  26. package/dist/assets/{MaskShapeCanvas-WPSz6MvT.js → MaskShapeCanvas-BDELFcW-.js} +1 -1
  27. package/dist/assets/{MotionZonesSettings-CxZucl1G.js → MotionZonesSettings-B4Sz3Hxi.js} +1 -1
  28. package/dist/assets/MyAccess-SjNSbZFI.js +2 -0
  29. package/dist/assets/Network-BvT1oKui.js +1 -0
  30. package/dist/assets/{NodeAddonsSettingsPanel-CSyREPja.js → NodeAddonsSettingsPanel-DPOu3bzA.js} +1 -1
  31. package/dist/assets/Notifications-CdyKO4mW.js +1 -0
  32. package/dist/assets/{PrivacyMaskSettings-DQ7Xe8cq.js → PrivacyMaskSettings-DHIoMgiM.js} +1 -1
  33. package/dist/assets/Recordings-DaqBEWTR.js +1 -0
  34. package/dist/assets/{ScanNetworkModal-Dw7_YiJk.js → ScanNetworkModal-C5ek4_xr.js} +1 -1
  35. package/dist/assets/{SceneMonitorEditor-CQtUJ-Cg.js → SceneMonitorEditor-BPo9HYQH.js} +1 -1
  36. package/dist/assets/SessionsList-CLdfIlct.js +2 -0
  37. package/dist/assets/{Showroom-DZRq9gks.js → Showroom-DNWKiETZ.js} +1 -1
  38. package/dist/assets/{System-n6EeqhH2.js → System-BEpuTl2A.js} +1 -1
  39. package/dist/assets/{Terminal-Dt_ribAu.js → Terminal-CZxQeSQv.js} +3 -3
  40. package/dist/assets/{Viewer-DbBh61dj.js → Viewer-DRzTXkJf.js} +1 -1
  41. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CEvIRFB4.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C5raVFJt.js} +1 -1
  42. package/dist/assets/{addon-icons-context-r49093mC.js → addon-icons-context-PT674I68.js} +1 -1
  43. package/dist/assets/{archive-CgDcyTmT.js → archive-Ciq6-gRM.js} +1 -1
  44. package/dist/assets/{authed-media-CN55sP4S.js → authed-media-Dj1jG_u8.js} +1 -1
  45. package/dist/assets/{bell-off-CdHPL528.js → bell-off-BSKweN0I.js} +1 -1
  46. package/dist/assets/{board-model-DXmUHcnO.js → board-model-5GbhsRIK.js} +1 -1
  47. package/dist/assets/{boxes-DJvrVSZy.js → boxes-Be_6S2Ig.js} +1 -1
  48. package/dist/assets/circle-slash-CtNDkZYp.js +1 -0
  49. package/dist/assets/client-CPwvt_HG.js +358 -0
  50. package/dist/assets/{cloud-upload-BkTrXwKr.js → cloud-upload-B9nCTjv1.js} +1 -1
  51. package/dist/assets/crop-D5vMVrdf.js +1 -0
  52. package/dist/assets/{device-integration-icon-CViPS882.js → device-integration-icon-C31xC4qv.js} +1 -1
  53. package/dist/assets/device-picker-model-zmV5eDza.js +1 -0
  54. package/dist/assets/{dist-0P_zMe7Y.js → dist-B6sP5E_m.js} +1 -1
  55. package/dist/assets/dist-Sy-AM1_J.js +358 -0
  56. package/dist/assets/{eraser-BCiOGK5K.js → eraser-BIioNznG.js} +1 -1
  57. package/dist/assets/{hard-drive-download-Df-zlQQG.js → hard-drive-download-B4JsHavv.js} +1 -1
  58. package/dist/assets/{history-CWpQe6k9.js → history-DjLzg0Rr.js} +1 -1
  59. package/dist/assets/{hostInit-Cnw529bc.js → hostInit-BwwyWMg1.js} +1 -1
  60. package/dist/assets/i18n-GaxP0h6E.js +1 -0
  61. package/dist/assets/{icons-aI8aLvw4.js → icons-4P43FpmR.js} +1 -1
  62. package/dist/assets/index-i0Y8_-ur.css +2 -0
  63. package/dist/assets/{index-DkNBNJNl.js → index-tgPOSbne.js} +3 -3
  64. package/dist/assets/{key-CZcpRn4A.js → key-BMcy7xHz.js} +1 -1
  65. package/dist/assets/{key-round-BBPO5HDK.js → key-round-C__KHy-x.js} +1 -1
  66. package/dist/assets/{layers-DLOgDOBH.js → layers-Dbn6yDeS.js} +1 -1
  67. package/dist/assets/{linked-devices-model-f_SAvOZs.js → linked-devices-model-D8dKG29p.js} +1 -1
  68. package/dist/assets/{list-ordered-BaNkdvWk.js → list-ordered-CwWFTuog.js} +1 -1
  69. package/dist/assets/{location-owned-usage-BFxIuzRL.js → location-owned-usage-kz2UtPi1.js} +1 -1
  70. package/dist/assets/{log-in-CL3_o1dD.js → log-in-D-fa0CNC.js} +1 -1
  71. package/dist/assets/{memory-stick-CHkvUw7C.js → memory-stick-BNvRqOgn.js} +1 -1
  72. package/dist/assets/{message-square-plus-CIeWtcNn.js → message-square-plus-yiE3dC2J.js} +1 -1
  73. package/dist/assets/{mf-entry-bootstrap-0-657dd3ff.js → mf-entry-bootstrap-0-3d7ac4be.js} +2 -2
  74. package/dist/assets/{mic-off-DS8OGDQW.js → mic-off-Ct9OQSHX.js} +1 -1
  75. package/dist/assets/{monitor-off-DC9Xug5Z.js → monitor-off-gNZ5sErH.js} +1 -1
  76. package/dist/assets/{monitor-smartphone-CS_5BZqr.js → monitor-smartphone-B9ZL4epZ.js} +1 -1
  77. package/dist/assets/mount-zmV5eDza.js +1 -0
  78. package/dist/assets/{notification-schedule-field-aMkV5LtX.js → notification-schedule-field-91fTFul7.js} +1 -1
  79. package/dist/assets/{octagon-alert-Cdtac8l_.js → octagon-alert-CkSZIflH.js} +1 -1
  80. package/dist/assets/{player-overlays-CZXV2ES3.js → player-overlays-CVyuEj4x.js} +1 -1
  81. package/dist/assets/{recycle-wY_-o-u0.js → recycle-CH0GJM3I.js} +1 -1
  82. package/dist/assets/remoteEntry-CEVdKgl-.js +1 -0
  83. package/dist/assets/{scan-eye-A6IBODIs.js → scan-eye-D6obPT9p.js} +1 -1
  84. package/dist/assets/{scissors-BzZpfzIa.js → scissors-BXMmNEgj.js} +1 -1
  85. package/dist/assets/{search-x-DqjVJK7_.js → search-x-ByAKuo4f.js} +1 -1
  86. package/dist/assets/{send-BDCQEx8-.js → send-CholqiEk.js} +1 -1
  87. package/dist/assets/{settings-2-BBgeb4tF.js → settings-2-3k9hj27t.js} +1 -1
  88. package/dist/assets/{speaker-Bw_8wVkA.js → speaker-Ca4eeGU9.js} +1 -1
  89. package/dist/assets/src-D7EY8vSW.js +67 -0
  90. package/dist/assets/{timer-reset-CNH944ar.js → timer-reset-bq-8RFf6.js} +1 -1
  91. package/dist/assets/{ungroup-D4fdKtA6.js → ungroup-DMrJzuO_.js} +1 -1
  92. package/dist/assets/{unlink-BKDNubwr.js → unlink-CgiLXfCU.js} +1 -1
  93. package/dist/assets/{usb-CU5DhEWn.js → usb-BpqC1Eim.js} +1 -1
  94. package/dist/assets/{use-scenes-feed-Bk660KRI.js → use-scenes-feed-CtmmYk4L.js} +1 -1
  95. package/dist/assets/{use-stationary-objects-BVxOU14q.js → use-stationary-objects-DsURgc1b.js} +1 -1
  96. package/dist/assets/useEventInvalidation-zmV5eDza.js +1 -0
  97. package/dist/assets/{useNodeUrlSelection-Bg0rHiIl.js → useNodeUrlSelection-nj7EK04j.js} +1 -1
  98. package/dist/assets/user-round-B0EP32hl.js +1 -0
  99. package/dist/assets/{user-x-DRzptq94.js → user-x-CpjXT41_.js} +1 -1
  100. package/dist/assets/{video-CEzO-5-D.js → video-BAANd9N-.js} +1 -1
  101. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DzDhE-1_.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Bp8_lhik.js} +2 -2
  102. package/dist/index.html +11 -11
  103. package/dist/server/addon.js +44 -22
  104. package/package.json +1 -1
  105. package/dist/assets/Addons-N1hcMjwi.js +0 -4
  106. package/dist/assets/AiProfiles-CW5cr9nz.js +0 -3
  107. package/dist/assets/Build-Dg7gaee7.js +0 -40
  108. package/dist/assets/Cluster-NV3ZrTk7.js +0 -1
  109. package/dist/assets/ClusterStepModel-BUROhnKA.js +0 -1
  110. package/dist/assets/CompositionEditorPage-BNAhOgDE.js +0 -1
  111. package/dist/assets/Data-Bkq3Cr_h.js +0 -2
  112. package/dist/assets/DeviceDetail-BR_FSl-i.js +0 -2
  113. package/dist/assets/Identity-CJN1MNrJ.js +0 -1
  114. package/dist/assets/IntegrationDetail-DomJ4oV8.js +0 -1
  115. package/dist/assets/IntegrationHub-BTJM3uSD.js +0 -1
  116. package/dist/assets/Integrations-w1Zb-AYc.js +0 -1
  117. package/dist/assets/Locations-5WWzr64x.js +0 -3
  118. package/dist/assets/MyAccess-2bAujGDI.js +0 -2
  119. package/dist/assets/Network-DFt5Vib8.js +0 -1
  120. package/dist/assets/Notifications-KG9O3i8q.js +0 -1
  121. package/dist/assets/Recordings-BbQTlUaN.js +0 -1
  122. package/dist/assets/SessionsList-BuiRHWv-.js +0 -2
  123. package/dist/assets/circle-slash-BvkFL8F1.js +0 -1
  124. package/dist/assets/client-CVIfL49c.js +0 -358
  125. package/dist/assets/crop-DUVdBcFC.js +0 -1
  126. package/dist/assets/device-picker-model-mxypQ5EF.js +0 -1
  127. package/dist/assets/dist-U5_IP253.js +0 -358
  128. package/dist/assets/i18n-CmGpgquB.js +0 -1
  129. package/dist/assets/index-DKqvG7BE.css +0 -2
  130. package/dist/assets/mount-mxypQ5EF.js +0 -1
  131. package/dist/assets/remoteEntry-BFNP-i5_.js +0 -1
  132. package/dist/assets/src-DOs8Kg5s.js +0 -67
  133. package/dist/assets/useEventInvalidation-mxypQ5EF.js +0 -1
  134. package/dist/assets/user-round-CYlbEszq.js +0 -1
@@ -5406,7 +5406,7 @@ var ZodIssueCode = {
5406
5406
  var ZodFirstPartyTypeKind;
5407
5407
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5408
5408
  //#endregion
5409
- //#region ../types/dist/sleep-WsrozGDL.mjs
5409
+ //#region ../types/dist/sleep-bZIhUvjd.mjs
5410
5410
  /**
5411
5411
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5412
5412
  * window to float samples (D455).
@@ -5523,7 +5523,7 @@ function isKeychainStoredField(field) {
5523
5523
  var SECRET_CLEAR = { $secretClear: true };
5524
5524
  /** The `'***'` token D634 redaction writes for non-admins. */
5525
5525
  var LEGACY_DEVICE_REDACTION = "***";
5526
- function isRecord$4(value) {
5526
+ function isRecord$5(value) {
5527
5527
  return typeof value === "object" && value !== null && !Array.isArray(value);
5528
5528
  }
5529
5529
  function makeSecretMarker(ref) {
@@ -5534,12 +5534,12 @@ function makeSecretMarker(ref) {
5534
5534
  }
5535
5535
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5536
5536
  function isSecretMarker(value) {
5537
- if (!isRecord$4(value)) return false;
5537
+ if (!isRecord$5(value)) return false;
5538
5538
  const ref = value["$secret"];
5539
5539
  return typeof ref === "string" && ref.length > 0;
5540
5540
  }
5541
5541
  function isSecretClear(value) {
5542
- return isRecord$4(value) && value["$secretClear"] === true;
5542
+ return isRecord$5(value) && value["$secretClear"] === true;
5543
5543
  }
5544
5544
  /**
5545
5545
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6149,7 +6149,7 @@ var KeychainWriteRefusedError = class extends Error {
6149
6149
  }
6150
6150
  };
6151
6151
  var KEEP = { kind: "keep" };
6152
- function isRecord$3(value) {
6152
+ function isRecord$4(value) {
6153
6153
  return typeof value === "object" && value !== null && !Array.isArray(value);
6154
6154
  }
6155
6155
  function defaultMintId() {
@@ -6162,7 +6162,7 @@ function collectSecretMarkerRefs(value, out = []) {
6162
6162
  return out;
6163
6163
  }
6164
6164
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6165
- else if (isRecord$3(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6165
+ else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6166
6166
  return out;
6167
6167
  }
6168
6168
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6217,7 +6217,7 @@ function rowId(row, idKey) {
6217
6217
  return null;
6218
6218
  }
6219
6219
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6220
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$3) : [];
6220
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
6221
6221
  if (!Array.isArray(incoming)) {
6222
6222
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6223
6223
  return {
@@ -6233,7 +6233,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6233
6233
  const kept = /* @__PURE__ */ new Set();
6234
6234
  const rows = [];
6235
6235
  for (const row of incoming) {
6236
- if (!isRecord$3(row)) {
6236
+ if (!isRecord$4(row)) {
6237
6237
  rows.push(row);
6238
6238
  continue;
6239
6239
  }
@@ -6258,7 +6258,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6258
6258
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6259
6259
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6260
6260
  case "object": {
6261
- if (!isRecord$3(incoming)) {
6261
+ if (!isRecord$4(incoming)) {
6262
6262
  if (incoming === void 0) return KEEP;
6263
6263
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6264
6264
  return {
@@ -6266,7 +6266,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6266
6266
  value: incoming
6267
6267
  };
6268
6268
  }
6269
- const storedObj = isRecord$3(stored) ? stored : {};
6269
+ const storedObj = isRecord$4(stored) ? stored : {};
6270
6270
  return {
6271
6271
  kind: "value",
6272
6272
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6389,7 +6389,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
6389
6389
  value: items
6390
6390
  };
6391
6391
  }
6392
- if (isRecord$3(v)) {
6392
+ if (isRecord$4(v)) {
6393
6393
  const out = {};
6394
6394
  for (const [k, child] of Object.entries(v)) {
6395
6395
  const s = substitute(child);
@@ -6421,7 +6421,7 @@ var SecretOverwriteRefusedError = class extends Error {
6421
6421
  this.name = "SecretOverwriteRefusedError";
6422
6422
  }
6423
6423
  };
6424
- function isRecord$2(value) {
6424
+ function isRecord$3(value) {
6425
6425
  return typeof value === "object" && value !== null && !Array.isArray(value);
6426
6426
  }
6427
6427
  function resolvedValue(pass, marker) {
@@ -6450,7 +6450,7 @@ function inArray(pass, incoming, stored) {
6450
6450
  return incoming.map((item, index) => {
6451
6451
  const twin = stored[index];
6452
6452
  if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6453
- if (isRecord$2(item) && isRecord$2(twin)) return inArrayRow(pass, item, twin);
6453
+ if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
6454
6454
  if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6455
6455
  return item;
6456
6456
  });
@@ -6461,7 +6461,7 @@ function inArrayRow(pass, incoming, stored) {
6461
6461
  const twin = stored[key];
6462
6462
  if (isSecretMarker(twin)) {
6463
6463
  if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6464
- } else if (isRecord$2(value) && isRecord$2(twin)) out[key] = inArrayRow(pass, value, twin);
6464
+ } else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
6465
6465
  else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6466
6466
  }
6467
6467
  return out;
@@ -6469,7 +6469,7 @@ function inArrayRow(pass, incoming, stored) {
6469
6469
  async function walk(pass, incoming, stored) {
6470
6470
  if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6471
6471
  if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6472
- if (!isRecord$2(incoming) || !isRecord$2(stored)) return incoming;
6472
+ if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
6473
6473
  const out = { ...incoming };
6474
6474
  for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6475
6475
  return out;
@@ -6500,7 +6500,7 @@ async function restoreUnchangedSecrets(input) {
6500
6500
  function isJsonEqual(a, b) {
6501
6501
  if (Object.is(a, b)) return true;
6502
6502
  if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6503
- if (isRecord$2(a) && isRecord$2(b)) {
6503
+ if (isRecord$3(a) && isRecord$3(b)) {
6504
6504
  const keys = Object.keys(a);
6505
6505
  if (keys.length !== Object.keys(b).length) return false;
6506
6506
  return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
@@ -6524,7 +6524,7 @@ function markerKeysOf(blob, owner) {
6524
6524
  }
6525
6525
  function nodeFromStored(value, owner) {
6526
6526
  if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6527
- if (!isRecord$2(value)) return null;
6527
+ if (!isRecord$3(value)) return null;
6528
6528
  const children = /* @__PURE__ */ new Map();
6529
6529
  for (const [key, child] of Object.entries(value)) {
6530
6530
  const node = nodeFromStored(child, owner);
@@ -7312,7 +7312,7 @@ var BaseAddon = class {
7312
7312
  if (!ctx) return;
7313
7313
  const addonId = ctx.id;
7314
7314
  setImmediate(() => {
7315
- ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
7315
+ ctx.api.addons.restartAddon.mutate({ addonId }).then(() => {
7316
7316
  ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
7317
7317
  }).catch((err) => {
7318
7318
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
@@ -16340,13 +16340,23 @@ method(object({ ownerPrefix: string().min(1).optional() }), object({ tables: arr
16340
16340
  }), RecordQueryResultSchema, { auth: "admin" }), method(object({
16341
16341
  owner: string().min(1),
16342
16342
  kind: RecordKindNameSchema,
16343
- records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX),
16343
+ records: array(RecordInputSchema).max(RECORD_BATCH_MAX),
16344
16344
  /** The LAST batch: the copy is complete, the boot guard stops asking. */
16345
16345
  complete: boolean().optional()
16346
- }), object({ adopted: number().int() }), {
16346
+ }).refine((input) => input.records.length > 0 || input.complete === true, { message: "records must be non-empty unless complete is true" }), object({ adopted: number().int() }), {
16347
16347
  kind: "mutation",
16348
16348
  auth: "admin"
16349
- });
16349
+ }), method(object({
16350
+ collection: string().min(1),
16351
+ cursor: string().optional(),
16352
+ limit: number().int().min(1).max(1e3).optional()
16353
+ }), object({
16354
+ rows: array(object({
16355
+ id: string(),
16356
+ data: record(string(), unknown())
16357
+ })),
16358
+ nextCursor: string().nullable()
16359
+ }), { auth: "admin" }), method(object({ collection: string().min(1) }), object({ adopted: boolean() }), { auth: "admin" });
16350
16360
  /**
16351
16361
  * record-entries - the ONE admin surface for every list of user-created entries
16352
16362
  * (D881): notification targets, brokers, LLM profiles, anything an addon
@@ -68318,6 +68328,12 @@ Object.freeze({
68318
68328
  addonId: null,
68319
68329
  access: "delete"
68320
68330
  },
68331
+ "storageAdmin.isAdoptedLegacyTable": {
68332
+ capName: "storage-admin",
68333
+ capScope: "system",
68334
+ addonId: null,
68335
+ access: "view"
68336
+ },
68321
68337
  "storageAdmin.listKinds": {
68322
68338
  capName: "storage-admin",
68323
68339
  capScope: "system",
@@ -68330,6 +68346,12 @@ Object.freeze({
68330
68346
  addonId: null,
68331
68347
  access: "view"
68332
68348
  },
68349
+ "storageAdmin.readLegacyCollection": {
68350
+ capName: "storage-admin",
68351
+ capScope: "system",
68352
+ addonId: null,
68353
+ access: "view"
68354
+ },
68333
68355
  "storageAdmin.readRecords": {
68334
68356
  capName: "storage-admin",
68335
68357
  capScope: "system",
@@ -73556,7 +73578,7 @@ var AdminUIAddon = class extends BaseAddon {
73556
73578
  capability: adminUiCapability,
73557
73579
  provider: {
73558
73580
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
73559
- getVersion: async () => ({ version: "1.2.435" })
73581
+ getVersion: async () => ({ version: "1.2.436" })
73560
73582
  }
73561
73583
  }];
73562
73584
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.435",
3
+ "version": "1.2.436",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -1,4 +0,0 @@
1
- import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,o as s,q as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{Hr as d,It as f,Ln as p,Nt as m,On as h,Ot as g,Q as _,ar as v,bi as y,di as b,dn as x,dt as S,en as C,fn as w,gi as ee,ln as T,ri as E,wn as te,yi as ne,yn as D}from"./player-overlays-CZXV2ES3.js";import{c as re}from"./video-CEzO-5-D.js";import{t as ie}from"./octagon-alert-Cdtac8l_.js";import{Ti as ae}from"./client-CVIfL49c.js";import{$l as O,An as oe,Ar as se,Bn as ce,Br as le,Cr as k,Dn as ue,En as de,Er as A,Fr as fe,Ir as j,Lr as pe,Mr as M,Or as N,Pr as me,Q as P,Qo as he,Sr as F,Tn as I,Tr as ge,Tt as L,U as _e,Vr as R,Xn as z,Zn as ve,_u as B,ar as V,br as H,jn as ye,jr as U,kn as be,kr as W,mu as G,vr as xe,wr as Se,wt as Ce,xr as K,zr as q}from"./src-DOs8Kg5s.js";import{t as J}from"./useTranslation-D3Is_4B6.js";import"./mount-mxypQ5EF.js";import{Q as Y,Y as X,et as we}from"./index-DkNBNJNl.js";import{t as Z}from"./AdminPage-Dla2hgly.js";import{t as Te}from"./NodeAddonsSettingsPanel-CSyREPja.js";import{n as Q,t as Ee}from"./useNodeUrlSelection-Bg0rHiIl.js";function De(e){if(e===void 0)return null;switch(e.state){case`failed`:case`refused`:case`missing`:case`crashed`:return{kind:e.state,...e.reason===void 0?{}:{reason:e.reason}};default:return null}}e();var Oe={queued:{icon:E,bg:`bg-muted text-foreground-subtle`,labelKey:`addons.addonRowBadge.queued`},updating:{icon:v,bg:`bg-primary/10 text-primary`,labelKey:`addons.addonRowBadge.updating`,spin:!0},"done-pending-restart":{icon:D,bg:`bg-amber-500/10 text-amber-700`,labelKey:`addons.addonRowBadge.pendingRestart`},done:{icon:y,bg:`bg-success/10 text-success`,labelKey:`addons.addonRowBadge.done`},failed:{icon:ie,bg:`bg-danger/10 text-danger`,labelKey:`addons.addonRowBadge.failed`}};function ke({item:e}){let{t}=J(),n=Oe[e.status],r=n.icon;return a(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${n.bg}`,title:e.error,children:[l(r,{className:`w-2.5 h-2.5 ${n.spin?`animate-spin`:``}`}),t(n.labelKey)]})}var Ae=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),je=new Set([`done`,`failed`,`skipped`]);function Me(e){return!je.has(e.phase)&&!Ae.has(e.jobState)}function Ne(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Ae.has(e.state);for(let i of e.tasks)r&&i.finishedAtMs!==null&&t-i.finishedAtMs>6e4||n.set(i.packageName,{jobId:e.jobId,packageName:i.packageName,phase:i.phase,fromVersion:i.fromVersion,toVersion:i.toVersion,error:i.error,jobState:e.state,finishedAtMs:i.finishedAtMs})}return n}function Pe(){let{data:e}=W({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=B(ae.AddonsJobProgress,e=>e.job.jobId);return n(()=>{let n=new Map;for(let t of e??[])n.set(t.jobId,t);for(let[e,r]of t)n.set(e,r.job);return Ne([...n.values()],Date.now())},[e,t])}var Fe={queued:{icon:E,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.queued`},fetching:{icon:v,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.fetching`,spin:!0},staged:{icon:v,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.staged`,spin:!0},validating:{icon:v,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.validating`,spin:!0},applying:{icon:v,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.applying`,spin:!0},restarting:{icon:v,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,labelKey:`addons.jobProgress.restarting`,spin:!0},applied:{icon:v,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.finalizing`,spin:!0},done:{icon:y,cls:`bg-success/10 text-success`,labelKey:`addons.jobProgress.updated`},failed:{icon:ie,cls:`bg-danger/10 text-danger`,labelKey:`addons.jobProgress.failed`},skipped:{icon:C,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.skipped`}};function Ie({progress:e}){let{t}=J(),n=Fe[e.phase],r=n.icon,i=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return a(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${n.cls}`,title:i,children:[l(r,{className:`w-2.5 h-2.5 ${n.spin?`animate-spin`:``}`}),t(n.labelKey),a(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function Le(e,t){return e.filter(e=>e.packageName===t).slice().sort((e,t)=>e.isHub===t.isHub?e.nodeName.localeCompare(t.nodeName):e.isHub?-1:1)}function Re(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function ze(e,t,n){let r=[`${e} will be uninstalled from ${t.length} node(s). Its runners stop, its capabilities are deregistered and its code is deleted:`,...t.map(Re)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
2
- `)}function Be(e,t,n){let r=[`${e} will be uninstalled from ${t}: its runners stop and its code is deleted.`];return n.length>0&&r.push(`It stays installed on: ${n.map(e=>e.nodeName).join(`, `)}. Use "Everywhere" to remove it from every node.`),r.push(`This cannot be undone.`),r.join(`
3
- `)}var Ve={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function He(e,t){let n=[];for(let r of e.results){let e=r.runnersStopped.length>0?` (stopped ${r.runnersStopped.join(`, `)})`:``;n.push(`${t(r.nodeId)}: ${Ve[r.outcome]}${e}`),r.error!==void 0&&n.push(` ${r.error}`);for(let e of r.warnings)n.push(` ${e}`)}return n.join(`
4
- `)}var Ue={},We=3e4,Ge=`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-red-400 hover:border-red-500/30 hover:bg-red-500/10 disabled:opacity-50 transition-colors`;function Ke({packageName:e,displayName:t,selectedNode:n,hideNodeAction:r,disabled:i}){let{t:o}=J(),c=s(),u=ve(),d=z(),p=N(Ue,{staleTime:We}),m=p.data?.installations??[],h=(p.data?.unreachable??[]).map(e=>e.nodeId),g=Le(m,e),_=e=>g.find(t=>t.nodeId===e)?.nodeName??(e===n.id?n.name:e),v=le({onSettled:()=>{c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addonPages`]]}),c.invalidateQueries({queryKey:[[`capabilities`]]}),c.invalidateQueries({queryKey:[[`nodes`]]})}}),y=async e=>{await d({title:e.success?o(`addons.addonUninstallControls.uninstalled`,`{{displayName}} uninstalled`,{displayName:t}):o(`addons.addonUninstallControls.notEveryNodeWasCleaned`,`{{displayName}}: not every node was cleaned`,{displayName:t}),message:He(e,_),variant:e.success?`default`:`danger`})},b=async n=>{try{await y(await v.mutateAsync({packageName:e,...n}))}catch(e){await d({title:o(`addons.addonUninstallControls.uninstallFailed`,`Uninstall {{displayName}} failed`,{displayName:t}),message:e instanceof Error?e.message:String(e),variant:`danger`})}},x=async()=>{let e=g.filter(e=>e.nodeId!==n.id);await u({title:o(`addons.addonUninstallControls.uninstallFrom`,`Uninstall {{displayName}} from {{name}}?`,{displayName:t,name:n.name}),message:Be(t,n.name,e),confirmLabel:o(`addons.addonUninstallControls.uninstall`,`Uninstall`),variant:`danger`})&&await b(n.isHub?{}:{nodeId:n.id})},S=async()=>{let n=(await p.refetch()).data;if(n===void 0){await d({title:o(`addons.addonUninstallControls.cannotListTheNodes`,`Cannot list the nodes`),message:o(`addons.addonUninstallControls.theHubDidNotAnswer`,`The hub did not answer which nodes have this package — nothing was removed.`),variant:`danger`});return}let r=Le(n.installations,e);await u({title:o(`addons.addonUninstallControls.uninstallEverywhere`,`Uninstall {{displayName}} everywhere?`,{displayName:t}),message:ze(t,r,n.unreachable.map(e=>e.nodeId)),confirmLabel:o(`addons.addonUninstallControls.uninstallFromNodeS`,`Uninstall from {{length}} node(s)`,{length:r.length}),variant:`danger`})&&await b({everywhere:!0})},C=v.isPending||i===!0;return a(`div`,{className:`flex items-center gap-1.5`,children:[r!==!0&&a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),x()},disabled:C,className:Ge,title:o(`addons.addonUninstallControls.uninstallFrom2`,`Uninstall from {{name}}`,{name:n.name}),children:[l(f,{className:`h-3 w-3`}),v.isPending?o(`addons.addonUninstallControls.removing`,`Removing...`):o(`addons.addonUninstallControls.uninstall`,`Uninstall`)]}),(g.length>1||r===!0||h.length>0)&&a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),S()},disabled:C,className:Ge,title:o(`addons.addonUninstallControls.uninstallFromEveryNodeThat`,`Uninstall from every node that has it`),children:[l(re,{className:`h-3 w-3`}),g.length>0?o(`addons.uninstallControls.everywhereCount`,{count:g.length}):o(`addons.uninstallControls.everywhere`)]})]})}function qe({packageName:e,currentVersion:t,installSource:n,onInstall:r,onClose:i,onSelect:s,selectedVersion:c}){let{t:u}=J(),f=n===`upload`||n===`local`,{data:p,isLoading:m}=Se({name:e});return a(`div`,{className:`fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,style:{top:`auto`,bottom:`auto`},ref:e=>{if(!e)return;let t=e.parentElement?.getBoundingClientRect();if(!t)return;let n=window.innerHeight-t.bottom,r=t.top;n<280&&r>n?(e.style.bottom=`${window.innerHeight-t.top+4}px`,e.style.top=`auto`):(e.style.top=`${t.bottom+4}px`,e.style.bottom=`auto`),e.style.right=`${window.innerWidth-t.right}px`},onClick:e=>e.stopPropagation(),children:[a(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[l(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:u(`addons.versionPicker.versions`,`Versions`)}),l(`button`,{type:`button`,onClick:i,className:`text-foreground-subtle hover:text-foreground`,children:l(S,{className:`h-3 w-3`})})]}),f&&a(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[l(g,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),a(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[l(`span`,{className:`font-semibold`,children:u(`addons.versionPicker.inPlace`,{kind:n===`upload`?u(`addons.versionPicker.uploadedCopy`,`Uploaded copy`):u(`addons.versionPicker.localCopy`,`Local copy`)})}),` `,l(X,{i18nKey:`addons.versionPicker.reinstall`,values:{version:t},components:{mono:l(`span`,{className:`font-mono`})}})]})]}),m&&a(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[l(v,{className:`h-3.5 w-3.5 animate-spin`}),u(`addons.versionPicker.loadingVersions`,`Loading versions...`)]}),p&&l(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:p.map(e=>{let n=e.version===t,i=s!==void 0&&e.version===c,f=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),p=a(o,{children:[l(`span`,{className:`font-mono flex-1 text-left ${n?`text-primary font-semibold`:f?`text-amber-400`:`text-foreground`}`,children:e.version}),n&&l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:u(`common.current`)}),e.distTags.map(e=>l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),e.deprecated&&l(`span`,{className:`text-[9px] text-red-400 line-through`,children:u(`common.deprecated`)}),l(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return s?a(`button`,{type:`button`,"aria-label":u(`addons.versionPicker.select`,`Select {{version}}`,{version:e.version}),onClick:()=>s(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${i?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[p,i?l(y,{className:`h-3 w-3 text-primary shrink-0`}):l(`span`,{className:`w-3 shrink-0`})]},e.version):a(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${n?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[p,l(`button`,{type:`button`,onClick:()=>r(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:n?u(`addons.versionPicker.reInstallFromNpm`,`Re-install {{version}} from npm`,{version:e.version}):u(`addons.versionPicker.install`,`Install {{version}}`,{version:e.version}),children:l(d,{className:`h-3 w-3`})})]},e.version)})}),p&&p.length===0&&l(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:u(`addons.versionPicker.noVersionsFound`,`No versions found`)})]})}e();var Je=`device-export`;function Ye(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===Je)}function Xe(e){return e!==`local`&&e!==`upload`}function Ze({isBundle:e,installSource:t,addonId:n,iconPath:i,color:o}){let[s,c]=r(!1),u=o?{backgroundColor:`${o.startsWith(`#`)?o:`#${o}`}26`}:void 0,d=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,f=n&&i?_(`/api/addon-assets/${n}/${i}`):null,m=!!f&&!s;return a(`div`,{className:`relative flex-shrink-0`,children:[l(`div`,{className:`h-8 w-8 rounded-md flex items-center justify-center ${u?``:d}`,style:u,children:m?l(`img`,{src:f,alt:n,className:`h-4 w-4`,onError:()=>c(!0)}):l(e?p:te,{className:`h-3.5 w-3.5`})}),t===`local`&&l(`span`,{className:`absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm`,children:`DEV`}),Xe(t)&&l(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:l(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:l(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),t===`upload`&&l(`span`,{className:`absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm`,children:l(g,{className:`h-2.5 w-2.5 text-white`})})]})}function Qe({version:e,availableUpdate:t,selectedVersion:n,isUpdating:r,installSource:i,disabled:o,onUpdate:s,onOpenPicker:c,children:u}){let{t:f}=J();if(r)return a(`span`,{className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400 shrink-0`,children:[l(v,{className:`h-3 w-3 animate-spin`}),f(`addons.addonCard.updating`,`Updating…`)]});if(t){let r=n??t;return a(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[s&&a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:o,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-semibold border border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:f(`addons.addonCard.updateTo`,`Update to {{target}}`,{target:r}),children:[l(d,{className:`h-3 w-3`}),f(`addons.addonCard.update`,`Update`)]}),a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:o,"aria-label":f(`addons.addonCard.selectVersionToInstall`,`Select version to install`),title:f(`addons.addonCard.installedUpdateAvailableSelectedTap`,`Installed {{version}} — update available. Selected {{target}}; tap to choose another version.`,{version:e,target:r}),className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border border-amber-500/40 bg-amber-500/15 text-amber-500 hover:bg-amber-500/25 animate-pulse disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[l(`span`,{className:`font-normal opacity-70`,children:e}),l(`span`,{className:`font-normal opacity-70`,children:`→`}),r,l(ne,{className:`h-3 w-3`})]}),u]})}return a(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:o,className:[`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,i===`local`?`border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20`].join(` `),title:f(`addons.addonCard.versionTapToViewAll`,`Version {{version}} — tap to view all versions`,{version:e}),children:[e,l(ne,{className:`h-3 w-3 opacity-50`})]}),u]})}function $e({addonId:e}){let t=s(),{data:n=`inherit`}=K({addonId:e}),r=j({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return l(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>l(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}var et={id:`hub`,name:`Hub`,isHub:!0};function tt({addon:e,agents:n=[],clusterStatus:i,hideVersion:c,availableUpdate:u,onUpdate:d,isUpdating:f,jobProgress:m,bundle:g,bulkItem:_,disabledByBulk:v,isSystem:y,selectedNode:b}){let{t:x}=J(),[C,E]=r(!1),[te,re]=r(!1),[ae,O]=r(!1),[se,le]=r(null);t(()=>{le(null)},[u]);let k=se??u,[A,fe]=r(!1),[j,pe]=r(!1),[N,he]=r(`logs`),F=s(),_e=Y(),{manifest:R}=e,z=e.installedOn??[],ve=!g&&!R.protected&&R.removable!==!1,B=!!g,V=g?.displayName??R.name,H=g?.packageName??R.packageName,U=g?.version??R.packageVersion??R.version,W=g?.installSource??e.installSource,G=g?g.bundle?.description??g.addons[0]?.manifest.description:R.description,xe=M({onSuccess:()=>{F.invalidateQueries({queryKey:[[`addons`]]})}}),Se=ge({onSuccess:()=>{F.invalidateQueries({queryKey:[[`addons`]]}),F.invalidateQueries({queryKey:[[`addonPages`]]}),F.invalidateQueries({queryKey:[[`capabilities`]]}),F.invalidateQueries({queryKey:[[`integrations`]]})}}),K=me({onSuccess:()=>{F.invalidateQueries({queryKey:[[`addons`]]}),F.invalidateQueries({queryKey:[[`alerts`]]})}}),q=e.health,X=q?.phase===`failed`&&!q.inGracePeriod,we=X&&q?.nextRetryAt&&!q.retrying,Z=De(e.process);return a(`div`,{className:`rounded-md border bg-surface overflow-hidden ${X?`border-red-500/50`:`border-border`}`,children:[X&&q&&a(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[l(ie,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),a(`div`,{className:`flex-1 min-w-0`,children:[l(`div`,{className:`text-xs font-semibold text-danger`,children:x(`addons.addonCard.failedToLoad`,{attempt:q.retryCount})}),l(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:q.lastError?.message??x(`addons.addonCard.unknownError`,`Unknown error`)}),we&&q.nextRetryAt&&l(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:x(`addons.addonCard.autoRetryAt`,{time:new Date(q.nextRetryAt).toLocaleTimeString()})})]}),a(`button`,{type:`button`,disabled:K.isPending||q.retrying,onClick:e=>{e.stopPropagation(),K.mutate({packageName:H})},className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0`,title:x(`addons.addonCard.resetRetryCounterAndForce`,`Reset retry counter and force immediate reload`),children:[l(D,{className:`h-3 w-3 ${K.isPending||q.retrying?`animate-spin`:``}`}),x(`addons.addonCard.retryNow`,`Retry now`)]})]}),Z!==null&&a(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[l(ie,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),a(`div`,{className:`flex-1 min-w-0`,children:[l(`div`,{className:`text-xs font-semibold text-danger`,children:x(`addons.addonCard.processProblem.${Z.kind}`)}),Z.reason!==void 0&&l(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:Z.reason})]})]}),a(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[l(Ze,{isBundle:B||!!R.components&&R.components.length>1,installSource:W,addonId:B?g.addons[0]?.manifest.id:R.id,iconPath:B?g.bundle?.icon??g.addons[0]?.manifest.icon:R.icon,color:B?g.addons[0]?.manifest.color:R.color}),a(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`flex items-start justify-between gap-2`,children:[l(`span`,{className:`text-xs font-semibold text-foreground truncate min-w-0`,children:V}),!c&&l(Qe,{version:U,availableUpdate:u,...k===void 0?{}:{selectedVersion:k},isUpdating:f,installSource:W,disabled:v,...d&&k!==void 0?{onUpdate:()=>d(k)}:{},onOpenPicker:()=>O(e=>!e),children:ae&&l(qe,{packageName:H,currentVersion:U,...W?{installSource:W}:{},...u!==void 0&&k!==void 0?{selectedVersion:k,onSelect:e=>{le(e),O(!1)}}:{},onInstall:e=>{O(!1),Se.mutate({packageName:H,version:e})},onClose:()=>O(!1)})})]}),a(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[H!==V&&l(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:H}),B&&a(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,children:[l(p,{className:`h-3 w-3`}),g.addons.length]}),y&&a(`span`,{className:`text-[10px] rounded-full bg-amber-500/15 text-amber-700 dark:text-amber-300 px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,title:x(`addons.addonCard.systemPackageUpdatingRestartsThe`,`System package — updating restarts the hub`),children:[l(D,{className:`h-3 w-3`}),x(`addons.addonCard.system`,`System`)]}),_!=null&&l(ke,{item:_}),m!=null&&l(Ie,{progress:m})]}),G&&l(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:G}),!B&&e.process&&a(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode===`forked`?`bg-blue-500/15 text-blue-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.mode===`forked`?x(`addons.addonCard.forked`):x(`addons.addonCard.inProcess`)}),e.process.pid!=null&&a(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state===`running`?`bg-emerald-500/15 text-emerald-400`:Z===null?`bg-gray-500/15 text-gray-400`:`bg-red-500/15 text-red-400`}`,children:e.process.state})]})]})]}),!B&&a(`div`,{className:`flex items-center gap-1 px-3 py-1 border-t border-border/50 bg-surface-hover/20`,children:[a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),xe.mutate({addonId:R.id})},disabled:xe.isPending||v,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors`,children:[l(D,{className:`h-3 w-3 ${xe.isPending?`animate-spin`:``}`}),x(`addons.addonCard.restart`,`Restart`)]}),a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),fe(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${A?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[l(w,{className:`h-3 w-3`}),x(`addons.addonCard.logs`,`Logs`)]}),!B&&a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),pe(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${j?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[l(T,{className:`h-3 w-3`}),x(`addons.addonCard.settings`,`Settings`)]}),l(`div`,{className:`flex-1`}),ve&&l(Ke,{packageName:R.packageName,displayName:R.name,selectedNode:b??et,disabled:v})]}),i&&i.nodes.length>1&&!B&&a(`div`,{className:`border-t border-border px-3 py-1.5 bg-muted/10`,children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:x(`addons.addonCard.clusterDeployment`,`Cluster Deployment`)}),l(`div`,{className:`space-y-1`,children:i.nodes.map(e=>a(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[l(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`offline`?`bg-muted-foreground/30`:e.synced?`bg-success`:`bg-amber-500`}`}),l(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),l(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:x(`addons.addonCard.outdated`)}),e.status===`offline`&&l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:x(`common.offline`)}),e.synced&&e.status!==`offline`&&l(`span`,{className:`text-[9px] text-success`,children:x(`common.synced`)})]},e.nodeId))})]}),A&&!B&&a(`div`,{className:`border-t border-border`,children:[a(`div`,{className:`flex items-center px-3 py-0.5 bg-surface-hover/20 border-b border-border/50`,children:[a(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[l(`button`,{type:`button`,onClick:()=>he(`logs`),className:`px-2 py-0.5 transition-colors ${N===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:x(`addons.addonCard.logs`,`Logs`)}),l(`button`,{type:`button`,onClick:()=>he(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${N===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:x(`addons.addonCard.events`,`Events`)})]}),l(`div`,{className:`flex-1`}),l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),fe(!1)},className:`text-foreground-subtle hover:text-foreground`,children:l(S,{className:`h-3.5 w-3.5`})})]}),N===`logs`&&l(L,{addonId:R.id,maxHeight:`max-h-64`,showFilters:!1}),N===`events`&&l(Ce,{addonId:R.id,category:`addon.*`,maxHeight:`max-h-64`})]}),B&&a(o,{children:[l(`button`,{type:`button`,onClick:()=>E(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:l(C?ee:ne,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),C&&l(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:g.addons.map(e=>l(tt,{addon:e,agents:n,hideVersion:!0},e.manifest.id))})]}),j&&!B&&l(I,{open:!0,onOpenChange:e=>!e&&pe(!1),children:a(ue,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[l(oe,{children:a(ye,{className:`flex items-center gap-2`,children:[l(T,{className:`h-4 w-4 text-primary`}),x(`addons.addonCard.settingsTitle`,{name:V})]})}),a(de,{className:`space-y-4`,children:[l(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:x(`addons.addonCard.clusterWideSettingsOneValue`,`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`)}),l(Te,{nodeId:null,addonIds:[R.id],level:`global`,fieldScope:`cluster`,emptyMessage:x(`addons.addonCard.thisAddonExposesNoCluster`,`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`)}),Ye(R)&&a(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:x(`addons.addonCard.deviceExport`,`Device export`)}),l(P,{addonId:R.id,onOpenDevice:e=>_e(`/devices/${e}`)})]}),Xe(W)&&a(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:x(`addons.addonCard.autoUpdate`,`Auto-Update`)}),l($e,{addonId:R.id})]}),R.components&&R.components.length>0&&a(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:x(`addons.addonCard.components`,{count:R.components.length})}),l(`div`,{className:`flex flex-wrap gap-1`,children:R.components.map(e=>l(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]}),n.length>=2&&a(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:x(`addons.addonCard.installedOn`,`Installed on`)}),a(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[z.length===0&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:x(`addons.addonCard.hubLocal`,`Hub (local)`)}),z.map(e=>l(`span`,{className:`rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle`,children:e},e)),a(`div`,{className:`relative`,children:[a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),re(e=>!e)},className:`inline-flex items-center gap-1 rounded-full border border-dashed border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground hover:border-primary transition-colors`,title:x(`addons.addonCard.installOnMoreAgents`,`Install on more agents`),children:[l(h,{className:`h-3 w-3`}),x(`addons.addonCard.addAgent`,`Add agent`)]}),te&&a(`div`,{className:`absolute left-0 top-full mt-1 z-10 min-w-[160px] rounded-md border border-border bg-surface shadow-lg overflow-hidden`,children:[n.filter(e=>!e.isHub&&!z.includes(e.name)).map(e=>l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),re(!1)},className:`w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors`,children:e.name},e.id)),n.filter(e=>!e.isHub&&!z.includes(e.name)).length===0&&l(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle`,children:x(`addons.addonCard.noAvailableAgents`,`No available agents`)})]})]})]})]})]}),l(be,{children:l(ce,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>pe(!1),children:x(`common.close`,`Close`)})})]})})]})}e();var nt=`.tgz,.tar.gz,.zip`;function rt({onUploadSuccess:e}){let{t}=J(),[n,s]=r(!1),u=c(null),d=i(async t=>{s(!0);let n=new FormData;n.append(`file`,t);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(_(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:n})).json()).success&&e()}finally{s(!1)}},[e]);return a(o,{children:[l(`input`,{ref:u,type:`file`,accept:nt,onChange:i(e=>{let t=e.target.files?.[0];t&&d(t),e.target.value=``},[d]),className:`hidden`}),a(`button`,{type:`button`,onClick:()=>u.current?.click(),disabled:n,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[n?l(v,{className:`w-3.5 h-3.5 animate-spin`}):l(g,{className:`w-3.5 h-3.5`}),n?t(`addons.addonUploadZone.uploading`,`Uploading...`):t(`addons.addonUploadZone.upload`,`Upload`)]})]})}var it=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/ui-library`,`@camstack/addon-agent-ui`]);function at(e,t){let n=new Map;for(let r of e){if(r.isHub||r.onHub||it.has(r.packageName)||!t.isHub&&r.nodeId!==t.id)continue;let e=n.get(r.packageName)??[];e.push(r),n.set(r.packageName,e)}return[...n].map(([e,t])=>({packageName:e,rows:t})).sort((e,t)=>e.packageName.localeCompare(t.packageName))}function ot({selectedNode:e}){let{t}=J(),{data:n}=N(Ue,{staleTime:We});if(n===void 0)return null;let r=at(n.installations,e),i=n.unreachable.filter(t=>e.isHub||t.nodeId===e.id);return r.length===0&&i.length===0?null:a(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2.5 space-y-2`,children:[a(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-foreground`,children:[l(m,{className:`h-3.5 w-3.5 text-warning`}),e.isHub?t(`addons.nodeOnlyPackagesPanel.installedOnAgentsButNot`,`Installed on agents but not on the hub`):t(`addons.nodeOnlyPackagesPanel.installedOnButNotOn`,`Installed on {{name}} but not on the hub`,{name:e.name})]}),i.length>0&&l(`div`,{className:`text-[10px] text-foreground-subtle`,children:t(`addons.nodeOnlyPackagesPanel.unreachable`,{nodes:i.map(e=>e.nodeId).join(`, `)})}),r.map(t=>a(`div`,{className:`flex items-center justify-between gap-3 flex-wrap rounded-md border border-border bg-surface px-3 py-2`,children:[a(`div`,{className:`min-w-0`,children:[l(`div`,{className:`text-xs font-mono text-foreground break-all`,children:t.packageName}),l(`div`,{className:`text-[10px] text-foreground-subtle`,children:t.rows.map(e=>`${e.nodeName}${e.version===null?``:` ${e.version}`}${e.isOnline?``:` (offline)`}`).join(` · `)})]}),l(Ke,{packageName:t.packageName,displayName:t.packageName,selectedNode:e,hideNodeAction:e.isHub})]},t.packageName))]})}function st({addon:e,installing:t,onInstall:n}){let{t:r}=J();return a(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[l(`div`,{className:`w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0`,children:e.name.replace(`@camstack/addon-`,``).charAt(0).toUpperCase()}),a(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[l(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),a(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),l(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&l(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?l(V,{variant:`success`,icon:l(y,{className:`h-3 w-3`}),children:e.installedVersion??r(`system.capabilityCatalog.installed`,`Installed`)}):a(ce,{size:`sm`,onClick:()=>n(e.name),disabled:t,className:`shrink-0`,children:[t?l(v,{className:`h-3 w-3 animate-spin`}):l(d,{className:`h-3 w-3`}),r(`system.capabilityCatalog.install`,`Install`)]})]})}function ct({capability:e,installing:t,onInstall:n}){let{t:r}=J(),{data:i,isPending:o,isError:s}=fe({capability:e}),c;if(s)c=l(`div`,{className:`px-3 py-2 text-xs text-danger`,children:r(`system.capabilityCatalog.couldNotSearchTheNpm`,`Could not search the npm catalog right now. Try again in a moment.`)});else if(o||i===void 0)c=a(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground-subtle`,children:[l(v,{className:`h-3 w-3 animate-spin`}),r(`system.capabilityCatalog.searchingTheNpmCatalog`,`Searching the npm catalog…`)]});else{let a=i.filter(e=>!e.installed);c=a.length===0?l(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:i.length===0?r(`system.capabilityCatalog.noPublishedAddonDeclaresThe`,`No published addon declares the "{{capability}}" capability.`,{capability:e}):r(`system.capabilityCatalog.everyPublishedAddonThatDeclares`,`Every published addon that declares "{{capability}}" is already installed.`,{capability:e})}):l(`div`,{className:`divide-y divide-border`,children:a.map(e=>l(st,{addon:e,installing:t,onInstall:n},e.name))})}return a(`section`,{className:`rounded-md border border-border bg-surface overflow-hidden`,"aria-label":r(`system.capabilityCatalog.availableToInstall`,`Available to install`),children:[l(`h2`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:r(`system.capabilityCatalog.availableToInstall`,`Available to install`)}),c]})}e();function lt(e){return e===`npm`||e===`dev`?e:null}var ut=`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`,dt=`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,ft=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],pt=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/shm-ring`,`@camstack/ui-library`]);function mt(e){return e!==void 0&&pt.has(e)}var ht={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function gt(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function _t(e){return e===`local`?`dev`:`npm`}function vt(e){let t=e;if(!t?.manifest)return null;let n={...t.manifest,name:t.manifest.name??t.manifest.id,version:t.manifest.version??`0.0.0`,capabilities:t.manifest.capabilities??[]},r=t.process,i=r?{pid:r.pid,mode:r.mode===`forked`?`forked`:`in-process`,state:r.state??`unknown`,...r.reason===void 0?{}:{reason:r.reason}}:void 0,a=t.health,o=t.declaration?.execution,s=t.manifest.execution,c=o?.placement??s?.placement;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...i?{process:i}:{},hasBackup:t.hasBackup,...a?{health:a}:{},...c?{placement:c}:{}}}function yt(e){let t=new Map,n=[];for(let r of e){let e=r.manifest.packageName;if(!e){n.push(r);continue}let i=t.get(e);if(i)i.addons.push(r);else{let n=r.manifest.bundle,i={packageName:e,displayName:n?.displayName??r.manifest.packageDisplayName??r.manifest.name,version:r.manifest.packageVersion,addons:[r],...r.installSource===void 0?{}:{installSource:r.installSource},...n===void 0?{}:{bundle:n}};t.set(e,i)}}let r=[];for(let e of t.values())e.bundle!==void 0||e.addons.length>=2?r.push({bundle:e,representative:e.addons[0]}):r.push(e.addons[0]);return r.push(...n),r}function $(e){return`bundle`in e}function bt({addons:e,clusterStatus:o,selectedNode:f,onRefresh:p,isRefreshing:m}){let{t:h}=J(),g=s(),[_,y]=r(``),S=u(_),[C,w]=r(!1),ee=c(null);t(()=>{if(!C)return;let e=e=>{ee.current&&!ee.current.contains(e.target)&&w(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[C]);let{data:T}=se({nodeId:f.id}),E=n(()=>{let e=new Map;for(let t of T??[])e.set(t.name,t.latestVersion);return e},[T]),te=n(()=>(T??[]).filter(e=>!e.isSystem).length,[T]),[ne,re]=r(()=>new Set),[ie,ae]=r(()=>new Map),oe=i(e=>{re(t=>new Set(t).add(e))},[]),ce=i(e=>{re(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),le=i((e,t)=>{ae(n=>new Map(n).set(e,t))},[]),ue=i(e=>{ae(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),de=R({onMutate:e=>{oe(e.name),ue(e.name)},onSuccess:(e,t)=>{ce(t.name);let n=e;if(n&&n.success===!1){le(t.name,n.error??`Update failed (no error message returned by server)`);return}g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{ce(t.name),le(t.name,e instanceof Error?e.message:String(e))}}),A=Pe(),j=c(new Set);t(()=>{let e=new Set;for(let[t,n]of A)Me(n)&&e.add(t);let t=[...j.current].some(t=>!e.has(t));j.current=e,t&&(g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[A,g]);let{data:M}=F(void 0),N=xe({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),me=pe({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:P,isFetching:he}=fe({query:S||void 0},{enabled:C}),I=q(),{data:L}=k(void 0),_e=L?.requestedAt,[z,B]=r(null),[V,H]=r(!1);t(()=>{if(L?.kind===`framework-bulk-update`&&L.requestedAt!==z){B(L.requestedAt),H(!0);let e=window.setTimeout(()=>H(!1),6e3);return()=>window.clearTimeout(e)}},[_e,z,L]),ve();let ye=i(async()=>{let e=(T??[]).filter(e=>!e.isSystem);if(e.length!==0){if(!f.isHub){for(let t of e)await de.mutateAsync({name:t.name,version:t.latestVersion,nodeId:f.id});return}await I.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[f.id]})}},[T,f.id,f.isHub,I,de]),U=ge({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addonPages`]]}),g.invalidateQueries({queryKey:[[`capabilities`]]}),g.invalidateQueries({queryKey:[[`integrations`]]})}}),[be,W]=r(`type`),[G,Se]=r(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),Ce=e=>{Se(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[K,Y]=we(),X=K.get(`capability`),Z=K.get(`updatable`)===`1`,Te=K.get(`error`)===`1`,Q=lt(K.get(`source`)),Ee=i(e=>{let t=new URLSearchParams(K);e?t.set(`updatable`,`1`):t.delete(`updatable`),Y(t,{replace:!0})},[K,Y]),Oe=i(e=>{let t=new URLSearchParams(K);e?t.set(`error`,`1`):t.delete(`error`),Y(t,{replace:!0})},[K,Y]),ke=i(e=>{let t=new URLSearchParams(K);e===null?t.delete(`source`):t.set(`source`,e),Y(t,{replace:!0})},[K,Y]),Ae=n(()=>e.filter(e=>De(e.process)!==null).length,[e]),je=n(()=>{let t=e.filter(e=>!mt(e.manifest.packageName));return f.isHub||(t=t.filter(e=>gt(e.placement,f.isHub))),X&&(t=t.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===X))),Z&&(t=t.filter(e=>{let t=e.manifest.packageName;return t!==void 0&&E.has(t)})),Q!==null&&(t=t.filter(e=>_t(e.installSource)===Q)),Te&&(t=t.filter(e=>De(e.process)!==null)),t},[e,f.isHub,X,Z,Q,Te,E]),Ne=()=>{let e=new URLSearchParams(K);e.delete(`capability`),Y(e,{replace:!0})},Fe=G===`flat`?je:yt(je),Ie=n(()=>{let e=[...Fe];switch(be){case`type`:e.sort((e,t)=>{let n=+!$(e),r=+!$(t);if(n!==r)return n-r;let i=$(e)?e.bundle.displayName:e.manifest.name,a=$(t)?t.bundle.displayName:t.manifest.name;return i.localeCompare(a)});break;case`name`:e.sort((e,t)=>{let n=$(e)?e.bundle.displayName:e.manifest.name,r=$(t)?t.bundle.displayName:t.manifest.name;return n.localeCompare(r)});break;case`source`:e.sort((e,t)=>{let n=$(e)?e.bundle.installSource??``:e.installSource??``,r=$(t)?t.bundle.installSource??``:t.installSource??``;return n.localeCompare(r)});break}return e},[Fe,be]);return a(`div`,{className:`space-y-3`,children:[[...ie.entries()].map(([e,t])=>l(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2.5 py-1.5 text-[11px]`,children:a(`div`,{className:`flex items-start justify-between gap-3`,children:[a(`div`,{className:`space-y-0.5`,children:[l(`div`,{className:`font-medium text-danger`,children:h(`systemPage.addons.updateFailed`,{name:e})}),l(`div`,{className:`text-foreground-subtle font-mono`,children:t})]}),l(`button`,{type:`button`,onClick:()=>ue(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:h(`common.dismiss`)})]})},e)),a(`div`,{className:`flex items-center gap-x-2 gap-y-1.5 flex-wrap`,children:[a(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.sort`,`Sort:`)}),a(`select`,{value:be,onChange:e=>W(e.target.value),className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary/50`,children:[l(`option`,{value:`type`,children:h(`admin.system.addons.bundlesFirst`,`Bundles first`)}),l(`option`,{value:`name`,children:h(`admin.system.addons.name`,`Name`)}),l(`option`,{value:`source`,children:h(`admin.system.addons.installSource`,`Install source`)})]})]}),a(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.view`,`View:`)}),l(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>l(`button`,{type:`button`,onClick:()=>Ce(e),className:`px-2 py-1 transition-colors capitalize ${G===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?h(`admin.system.addons.groupMultiAddonPackagesInto`,`Group multi-addon packages into a bundle card`):h(`admin.system.addons.showEveryAddonAsIts`,`Show every addon as its own card`),children:e},e))})]}),f.isHub&&a(`div`,{className:`flex items-center gap-1.5`,children:[l(D,{className:`h-3 w-3 text-foreground-subtle`}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.autoUpdate`,`Auto-Update:`)}),l(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>l(`button`,{type:`button`,onClick:()=>N.mutate({channel:e}),disabled:N.isPending,className:`px-2 py-1 transition-colors capitalize ${M?.channel===e?e===`off`?`bg-gray-700 text-gray-200`:e===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${e===`off`?``:`border-l border-border`}`,children:e},e))})]}),f.isHub&&a(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.checkEvery`,`Check every:`)}),l(`select`,{className:`rounded-md border border-border bg-transparent px-1.5 py-1 text-[10px] font-medium text-foreground-subtle`,value:M?.updateCheckIntervalSeconds??21600,disabled:me.isPending||M===void 0,onChange:e=>{M!==void 0&&me.mutate({channel:M.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:ft.map(e=>l(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),te>0&&a(`button`,{type:`button`,onClick:()=>void ye(),disabled:I.isPending,className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 border border-blue-500/30 disabled:opacity-50 transition-colors font-medium`,children:[I.isPending?l(v,{className:`w-3 h-3 animate-spin`}):l(d,{className:`w-3 h-3`}),I.isPending?h(`admin.system.addons.updating`,`Updating…`):h(`admin.system.addons.updateAll`,`Update All ({{nonSystemUpdateCount}})`,{nonSystemUpdateCount:te})]}),a(`button`,{type:`button`,onClick:p,disabled:m||I.isPending,className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[l(D,{className:`w-3 h-3 ${m?`animate-spin`:``}`}),h(`common.refresh`,`Refresh`)]})]}),a(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`group`,"aria-label":h(`admin.system.addons.filterInstalledAddons`,`Filter installed addons`),children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.filter`,`Filter:`)}),[{id:`updatable`,label:h(`admin.system.addons.updatable`,`Updatable`),pressed:Z,toggle:()=>Ee(!Z)},{id:`error`,label:h(`admin.system.addons.inError`,`In error ({{count}})`,{count:Ae}),pressed:Te,toggle:()=>Oe(!Te)},{id:`npm`,label:`npm`,pressed:Q===`npm`,toggle:()=>ke(Q===`npm`?null:`npm`)},{id:`dev`,label:h(`admin.system.addons.dev`,`Dev`),pressed:Q===`dev`,toggle:()=>ke(Q===`dev`?null:`dev`)}].map(e=>l(`button`,{type:`button`,"aria-pressed":e.pressed,onClick:e.toggle,className:e.pressed?ut:dt,children:e.label},e.id))]}),a(`div`,{className:`flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-2`,children:[a(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:ee,children:[l(O,{type:`text`,value:_,onChange:e=>{y(e.target.value),w(!0)},onFocus:()=>w(!0),placeholder:h(`admin.system.addons.searchAddonsOnNpm`,`Search addons on npm...`),"aria-label":h(`admin.system.addons.searchAddonsOnNpm2`,`Search addons on npm`),disabled:I.isPending,leftSlot:l(x,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),rightSlot:he?l(v,{className:`h-3 w-3 animate-spin`}):void 0}),C&&P&&P.length>0&&a(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-md border border-border bg-surface shadow-xl overflow-hidden`,children:[P.length>0&&l(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:h(`systemPage.addons.npmResults`,{count:P.length})}),P&&P.length>0&&l(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:P.map(e=>l(st,{addon:e,installing:U.isPending,onInstall:e=>U.mutate({packageName:e})},e.name))})]})]}),l(rt,{onUploadSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`]]}),p()}})]}),X&&a(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5 rounded-md bg-primary/10 border border-primary/30 text-xs`,children:[l(`span`,{className:`text-foreground-subtle`,children:h(`admin.system.addons.filteringByCapability`,`Filtering by capability:`)}),l(`span`,{className:`font-mono text-primary font-semibold`,children:X}),l(`button`,{type:`button`,onClick:Ne,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:h(`admin.system.addons.clear`,`Clear`)})]}),X&&l(ct,{capability:X,installing:U.isPending,onInstall:e=>U.mutate({packageName:e})}),X&&je.length>0&&l(`h2`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:h(`admin.system.addons.installed`,`Installed`)}),V&&a(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg backdrop-blur-sm max-w-sm pointer-events-auto`,children:[l(b,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),a(`div`,{children:[l(`div`,{className:`text-[11px] font-semibold text-foreground`,children:h(`admin.system.addons.bulkUpdateCompleted`,`Bulk update completed`)}),l(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:h(`admin.system.addons.systemPackagesUpdatedHubRestarted`,`System packages updated — hub restarted successfully.`)})]})]}),je.length===0&&l(`div`,{className:`text-xs text-foreground-subtle`,children:e.length===0?h(`admin.system.addons.noAddonsInstalled`,`No addons installed`):X?h(`admin.system.addons.noInstalledAddonDeclaresThe`,`No installed addon declares the "{{capabilityFilter}}" capability. Any addon you can install appears under "Available to install" above.`,{capabilityFilter:X}):h(`admin.system.addons.noAddonsCompatibleWithPlacement`,`No addons compatible with {{name}} (placement filter active)`,{name:f.name})}),l(`div`,{className:`space-y-1.5`,children:Ie.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=E.get(t),r=$(e)?e.representative:e,i=n?e=>de.mutate({name:t,version:e,nodeId:f.id}):void 0,a=A.get(t)??null,s=a!==null&&Me(a);return l(tt,{addon:r,clusterStatus:o?.[r.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,isUpdating:ne.has(t)||s,jobProgress:a,onUpdate:i,disabledByBulk:I.isPending,selectedNode:f},$(e)?t:e.manifest.id)})})]})}function xt(){let{t:e}=J(),n=s(),{data:r}=he(void 0),{nodes:i}=G(),{selection:o,selectNode:u,requestedNodeId:d}=Ee(i.length>0?i:[ht]),f=o.node??ht,p=f.id,m=i.length>0?o.staleNodeId:null,{data:h,isLoading:g,isError:_}=A({nodeId:p}),v=H(),y=U(),b=v.isPending||y.isPending,x=async()=>{await v.mutateAsync({nodeId:p}),await y.mutateAsync(),n.invalidateQueries({queryKey:[[`addons`]]})},S=c(v);S.current=v;let C=c(d??`hub`);t(()=>{S.current.mutate({nodeId:C.current})},[]);let w=(h??[]).map(vt).filter(e=>e!==null);return a(Z,{children:[a(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[l(_e,{selectedNodeId:p,onSelect:u}),a(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[!g&&!_&&l(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:e(`systemPage.addons.installedCount`,{count:w.length})}),a(`button`,{type:`button`,onClick:()=>void x(),disabled:b,className:`inline-flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,title:e(`admin.system.addons.reFetchAddonsCheckNpm`,`Re-fetch addons + check npm for new versions`),children:[l(D,{className:`w-3 h-3 ${b?`animate-spin`:``}`}),e(`admin.system.addons.checkForUpdates`,`Check for updates`)]})]})]}),l(Q,{staleNodeId:m,shownNodeName:f.name}),l(ot,{selectedNode:f}),g&&l(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:e(`common.loading`,`Loading…`)}),_&&l(`div`,{className:`text-xs text-danger`,children:e(`admin.system.addons.failedToLoadAddons`,`Failed to load addons`)}),!g&&!_&&l(bt,{addons:w,clusterStatus:r,selectedNode:f,onRefresh:()=>void x(),isRefreshing:b})]})}export{xt as AddonsPage};
@@ -1,3 +0,0 @@
1
- import{$ as e,B as t,G as n,J as r,L as i,S as a,a as o,b as s,q as c,t as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{D as d,Dn as f,G as p,Hr as m,It as h,Jr as g,Jt as _,Oi as v,On as y,Pn as b,Q as x,Tr as S,Xt as C,Zr as w,ar as T,dn as E,dt as D,kr as ee,ot as O,un as k,wi as A}from"./player-overlays-CZXV2ES3.js";import{t as te}from"./message-square-plus-CIeWtcNn.js";import{t as j}from"./send-BDCQEx8-.js";import{Wn as M}from"./client-CVIfL49c.js";import{$l as N,Bn as P,Jl as F,L as ne,Ln as I,Pn as L,U as re,Ut as R,Vt as z,Wt as B,ar as V,bn as H,ha as U,in as W,z as G}from"./src-DOs8Kg5s.js";import{t as K}from"./i18n-CmGpgquB.js";import{t as q}from"./useTranslation-D3Is_4B6.js";import"./mount-mxypQ5EF.js";import{C as J}from"./index-DkNBNJNl.js";import{t as ie}from"./AdminSectionedPage-C6laWV2D.js";import{t as ae}from"./AdminPage-Dla2hgly.js";e();var oe=[`llm`,`listProfiles`],se=[`llm`,`listProfileKinds`],ce=[`llm`,`getDefaults`],Y=[`llm`,`listRuntimeNodes`],le=[`llm`,`listModelCatalog`],ue=[`llm`,`getUsage`],de=[{purpose:`vision`,visionOnly:!0},{purpose:`text`,visionOnly:!1}],fe=new Map(Object.entries({openai:w,anthropic:w,google:w,"openai-compatible":f,"managed-local":g,"apple-foundation":g}));function pe(e){return fe.get(e)??null}function X(e){return typeof e==`string`&&e.length>0?e:void 0}function Z(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:void 0}}function Q(e){return e===!0}function me(e){return{model:e.model,baseUrl:e.baseUrl,apiKey:e.apiKey,supportsVision:e.supportsVision,temperature:e.temperature,topP:e.topP,topK:e.topK,maxTokens:e.maxTokens,contextLength:e.contextLength,systemPrompt:e.systemPrompt,timeoutMs:e.timeoutMs,connectTimeoutMs:e.connectTimeoutMs,firstTokenTimeoutMs:e.firstTokenTimeoutMs,idleTimeoutMs:e.idleTimeoutMs,retryEnabled:e.retry.enabled,retryMaxAttempts:e.retry.maxAttempts,toolsEnabled:e.toolsEnabled,contextSize:e.runtime?.contextSize,gpuLayers:e.runtime?.gpuLayers,threads:e.runtime?.threads,parallel:e.runtime?.parallel,idleStopMinutes:e.runtime?.idleStopMinutes,batchSize:e.runtime?.batchSize,ubatchSize:e.runtime?.ubatchSize,flashAttention:e.runtime?.flashAttention,mlock:e.runtime?.mlock,noMmap:e.runtime?.noMmap,cacheTypeK:e.runtime?.cacheTypeK,cacheTypeV:e.runtime?.cacheTypeV,extraArgs:ve(e.runtime?.extraArgs??[])}}var he=[`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`];function ge(e){return typeof e==`string`&&he.includes(e)?e:void 0}function _e(e){let t=[],n=``,r=null;for(let i of e){if(r!==null){i===r?r=null:n+=i;continue}if(i===`"`||i===`'`){r=i;continue}if(/\s/.test(i)){n!==``&&t.push(n),n=``;continue}n+=i}return n!==``&&t.push(n),t}function ve(e){return e.map(e=>/\s/.test(e)?`"${e}"`:e).join(` `)}var ye=[`--jinja`,`--cont-batching`];function be(e,t,n){let r=Z(e.threads),i=Z(e.batchSize),a=Z(e.ubatchSize),o=ge(e.cacheTypeK),s=ge(e.cacheTypeV);return{nodeId:t,engine:`llama-cpp`,model:n,extraArgs:[..._e(X(e.extraArgs)??``)],contextSize:Z(e.contextSize)??4096,gpuLayers:Z(e.gpuLayers)??0,...r===void 0?{}:{threads:r},parallel:Z(e.parallel)??1,...i===void 0?{}:{batchSize:i},...a===void 0?{}:{ubatchSize:a},flashAttention:Q(e.flashAttention),mlock:Q(e.mlock),noMmap:Q(e.noMmap),...o===void 0?{}:{cacheTypeK:o},...s===void 0?{}:{cacheTypeV:s},autoStart:Q(e.autoStart),idleStopMinutes:Z(e.idleStopMinutes)??30}}function xe(e,t,n,r,i){let a={id:n?.id??crypto.randomUUID(),name:t,kind:e,addonId:`ai`,enabled:n?.enabled??!0,model:X(r.model)??n?.model??``,supportsVision:i?.supportsVision??Q(r.supportsVision),timeoutMs:Z(r.timeoutMs)??M.totalMs,connectTimeoutMs:Z(r.connectTimeoutMs)??M.connectMs,firstTokenTimeoutMs:Z(r.firstTokenTimeoutMs)??M.firstTokenMs,idleTimeoutMs:Z(r.idleTimeoutMs)??M.idleMs,retry:{enabled:Q(r.retryEnabled),maxAttempts:Z(r.retryMaxAttempts)??1},toolsEnabled:Q(r.toolsEnabled)},o=X(r.baseUrl),s=X(r.apiKey),c=Z(r.temperature),l=Z(r.topP),u=Z(r.topK),d=Z(r.maxTokens),f=Z(r.contextLength),p=X(r.systemPrompt);return{...a,...o===void 0?{}:{baseUrl:o},...s===void 0?{}:{apiKey:s},...c===void 0?{}:{temperature:c},...l===void 0?{}:{topP:l},...u===void 0?{}:{topK:u},...d===void 0?{}:{maxTokens:d},...f===void 0?{}:{contextLength:f},...p===void 0?{}:{systemPrompt:p},...i===void 0?{}:{model:i.modelId,runtime:be(r,i.nodeId,i.model)}}}function Se(e){let t=new Map;for(let n of e){let e=t.get(n.addonId)??[];e.push(n),t.set(n.addonId,e)}return[...t.entries()].map(([e,t])=>({addonId:e,kinds:t}))}var Ce=`apple-system`;function we(e,t,n,r){return{...xe(`apple-foundation`,e,t,n),model:Ce,supportsVision:!1,appleFoundation:{nodeId:r}}}var Te={deviceNotEligible:{key:`ai.appleNotEligible`,tone:`default`},appleIntelligenceNotEnabled:{key:`ai.appleIntelligenceOff`,tone:`warning`},modelNotReady:{key:`ai.appleModelNotReady`,tone:`warning`},osTooOld:{key:`ai.appleOsTooOld`,tone:`default`},helperMissing:{key:`ai.appleHelperMissing`,tone:`danger`},helperCrashed:{key:`ai.appleHelperCrashed`,tone:`danger`}};function Ee(e){let t=t=>({nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleUnknown`,labelDefault:K.t(`ai.appleUnknown`),detail:t,tone:`default`});if(!e.reachable)return t(e.error??null);let n=e.apple;if(n===void 0)return t(null);switch(n.state){case`available`:return{nodeId:e.nodeId,selectable:!0,labelKey:`ai.appleAvailable`,labelDefault:K.t(`ai.appleAvailable`),detail:K.t(n.imageInput?`helpers.aiPage.appleDetailImages`:`helpers.aiPage.appleDetailText`,{version:n.osVersion}),tone:`success`};case`unavailable`:{let t=Te[n.reason];return{nodeId:e.nodeId,selectable:!1,labelKey:t.key,labelDefault:K.t(t.key),detail:n.detail,tone:t.tone}}case`unsupported-platform`:return{nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleNotMac`,labelDefault:K.t(`ai.appleNotMac`),detail:n.platform,tone:`default`};case`unknown`:return t(n.error)}}var De=2e3;function $(e){return K.t(`system.aiModelPicker.sizeGb`,{value:(e/1e9).toFixed(2)})}function Oe(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function ke({nodeId:e,value:t,onChange:i}){let{t:s}=q(),c=O(),[d,f]=r(``),[p,h]=r(null),[g,_]=r(!1),v=o({queryKey:le,queryFn:()=>c.trpcClient.llm.listModelCatalog.query({})}),y=o({queryKey:[`llm`,`listNodeModels`,e],queryFn:()=>c.trpcClient.llm.listNodeModels.query({nodeId:e})}),b=l({mutationFn:e=>c.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{h(e),_(!1),e.ok&&i({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),x=l({mutationFn:t=>c.trpcClient.llm.installModel.mutate({nodeId:e,model:t}),onSuccess:()=>{_(!0),y.refetch()}}),S=o({queryKey:Y,enabled:x.isPending,refetchInterval:x.isPending?De:!1,queryFn:()=>c.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(t=>t.nodeId===e)?.status?.download,C=n(()=>{let t=(v.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${$(e.sizeBytes)}`})),n=(y.data??[]).filter(e=>e.catalogId===void 0&&e.path!==void 0).map(t=>({value:`node:${t.file}`,label:s(`ai.onNode`,`{{file}} · {{size}} · on {{node}}`,{file:t.file,size:$(t.sizeBytes),node:e})})),r=p?.ok===!0?[{value:`custom`,label:`${p.label} · ${$(p.totalBytes)}`}]:[];return[{value:``,label:s(`ai.selectModel`,`Select a model…`)},...t,...n,...r]},[v.data,y.data,p,e,s]),w=e=>{if(e===``){i(null);return}if(e===`custom`){if(p?.ok!==!0)return;i({model:p.model,modelId:p.label,supportsVision:p.purpose===`vision`});return}if(e.startsWith(`catalog:`)){let t=e.slice(8),n=v.data?.find(e=>e.id===t);i({model:{kind:`catalog`,catalogId:t},modelId:t,supportsVision:n?.purpose===`vision`});return}let t=e.slice(5),n=y.data?.find(e=>e.file===t);n?.path!==void 0&&i({model:{kind:`path`,path:n.path},modelId:t,supportsVision:!1})},D=e=>{d.trim()!==``&&b.mutate({ref:d.trim(),...e===void 0?{}:{maxBytes:e}})};return a(`div`,{className:`space-y-2`,children:[a(`div`,{children:[u(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-model`,children:s(`ai.model`,`Model`)}),u(F,{id:`ai-model`,value:Oe(t),options:C,onChange:e=>w(e.target.value)})]}),a(`div`,{className:`rounded-md border border-border bg-surface-subtle px-3 py-2.5`,children:[u(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:s(`ai.hfTitle`,`Add a model from Hugging Face`)}),u(`p`,{className:`mb-2 text-[10px] leading-relaxed text-foreground-subtle`,children:s(`ai.hfHint`,`Paste a GGUF file URL, or type org/repo — add :QUANT (e.g. unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M) when the repo publishes more than one quantization.`)}),a(`div`,{className:`flex gap-2`,children:[u(N,{value:d,onChange:e=>f(e.target.value),placeholder:s(`system.aiModelPicker.unslothQwen3635bA3b`,`unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M`),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),D())}}),a(P,{size:`sm`,variant:`secondary`,type:`button`,disabled:d.trim()===``||b.isPending,onClick:()=>D(),children:[b.isPending?u(T,{className:`h-3.5 w-3.5 animate-spin`}):u(E,{className:`h-3.5 w-3.5`}),s(`ai.hfCheck`,`Check`)]})]}),b.isError&&u(`p`,{className:`mt-2 text-[11px] text-danger`,children:b.error instanceof Error?b.error.message:s(`common.error`,`Error`)}),p?.ok===!1&&a(`div`,{className:`mt-2 rounded-md border border-danger/40 bg-danger/10 px-2.5 py-2`,children:[u(`p`,{className:`text-[11px] text-danger`,children:p.message}),p.candidates!==void 0&&p.candidates.length>0&&u(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:p.candidates.map(e=>u(`button`,{type:`button`,className:`rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] text-foreground hover:border-primary/50`,onClick:()=>{let t=`${d.trim().split(`:`)[0]??``}:${e}`;f(t),b.mutate({ref:t})},children:e},e))}),p.requiredBytes!==void 0&&u(P,{size:`sm`,variant:`secondary`,type:`button`,className:`mt-2`,onClick:()=>D(p.requiredBytes),children:s(`ai.hfOverride`,`Install anyway ({{size}})`,{size:$(p.requiredBytes)})})]}),p?.ok===!0&&a(`div`,{className:`mt-2 rounded-md border border-border bg-surface px-2.5 py-2`,children:[a(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[u(`span`,{className:`text-[11px] font-medium text-foreground`,children:p.label}),u(V,{variant:p.purpose===`vision`?`info`:`default`,children:p.purpose}),u(V,{variant:`default`,children:$(p.totalBytes)})]}),p.extraFilenames.length>0&&u(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:s(`ai.hfExtras`,`Also downloads: {{files}}`,{files:p.extraFilenames.join(`, `)})}),a(`div`,{className:`mt-2 flex items-center gap-2`,children:[a(P,{size:`sm`,type:`button`,disabled:x.isPending||g,onClick:()=>x.mutate(p.model),children:[x.isPending?u(T,{className:`h-3.5 w-3.5 animate-spin`}):u(m,{className:`h-3.5 w-3.5`}),g?s(`ai.hfInstalled`,`Downloaded`):s(`ai.hfInstall`,`Download to {{node}}`,{node:e})]}),S!==void 0&&u(`span`,{className:`text-[10px] text-foreground-subtle`,children:S.phase===`verifying`?s(`ai.hfVerifying`,`verifying {{file}}…`,{file:S.file}):s(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:S.file,index:S.fileIndex,count:S.fileCount,done:$(S.downloadedBytes),total:S.totalBytes===void 0?``:` / ${$(S.totalBytes)}`})})]}),x.isError&&u(`p`,{className:`mt-1.5 text-[11px] text-danger`,children:x.error instanceof Error?x.error.message:s(`common.error`,`Error`)})]})]})]})}function Ae({value:e,onChange:t}){let{t:n}=q(),r=O(),i=o({queryKey:Y,queryFn:()=>r.trpcClient.llm.listRuntimeNodes.query({})});return a(`div`,{children:[u(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:n(`ai.appleNode`,`Mac that runs it`)}),i.isPending&&a(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[u(T,{className:`h-3.5 w-3.5 animate-spin`}),n(`ai.appleAsking`,`Asking the nodes…`)]}),i.isError&&u(`p`,{className:`text-[11px] text-danger`,children:i.error instanceof Error?i.error.message:n(`ai.runtimesFailed`,`Failed to read runtime nodes`)}),i.isSuccess&&i.data.length===0&&u(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}),i.isSuccess&&i.data.length>0&&u(`div`,{role:`radiogroup`,className:`space-y-1.5`,children:i.data.map(r=>{let i=Ee(r),o=i.nodeId===e;return a(`button`,{type:`button`,role:`radio`,"aria-checked":o,disabled:!i.selectable&&!o,onClick:()=>t(i.nodeId),className:`flex w-full items-center justify-between gap-2 rounded-md border px-3 py-2 text-left text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-60 ${o?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[a(`span`,{className:`min-w-0`,children:[u(`span`,{className:`block font-medium text-foreground`,children:i.nodeId}),i.detail!==null&&u(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:i.detail})]}),u(V,{variant:i.tone,children:n(i.labelKey,i.labelDefault)})]},i.nodeId)})}),u(`p`,{className:`mt-1.5 text-[10px] leading-relaxed text-foreground-subtle`,children:n(`ai.appleHint`,`Text only for now — notification titles and summaries. Apple refuses prompts framed as surveillance; when it does, the next profile in the chain answers instead.`)})]})}e();function je({kind:e,className:t}){let n=pe(e.kind);return n===null?u(`span`,{className:t,children:e.icon}):u(n,{className:t})}function Me({kinds:e,onPick:t,onCancel:r}){let{t:i}=q(),o=n(()=>Se(e),[e]);return u(G,{open:!0,onClose:r,title:i(`ai.chooseKind`,`Choose a profile type`),width:`lg`,testId:`ai-kind-picker`,children:a(`div`,{className:`space-y-4`,children:[o.length===0&&u(`p`,{className:`text-xs text-foreground-subtle`,children:i(`ai.noKinds`,`No AI provider is installed.`)}),o.map(e=>a(`div`,{children:[u(`div`,{className:`mb-1.5 text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:e.addonId}),u(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:e.kinds.map(n=>a(`button`,{type:`button`,onClick:()=>t(n),className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-xs transition-colors hover:border-primary/50 hover:bg-surface-hover`,children:[u(je,{kind:n,className:`h-5 w-5 text-foreground-subtle`}),u(`span`,{className:`font-medium text-foreground`,children:n.label})]},`${e.addonId}:${n.kind}`))})]},e.addonId))]})})}function Ne({kind:e,existing:t,onSave:i,onCancel:o,saving:c,error:l}){let{t:d}=q(),f=e.kind===`managed-local`,p=e.kind===`apple-foundation`,[m,h]=r(t?.appleFoundation?.nodeId??null),[g,_]=r(t?.name??e.label),[v,y]=r(()=>t===null?{}:me(t)),[b,x]=r(t?.runtime?.nodeId??`hub`),[S,C]=r(()=>t?.runtime===void 0?null:{model:t.runtime.model,modelId:t.model,supportsVision:t.supportsVision}),w=n(()=>_e(X(v.extraArgs)??``),[v.extraArgs]),E=()=>{if(p){if(m===null)return;i(we(g,t,v,m));return}if(!f){i(xe(e.kind,g,t,v));return}S!==null&&i(xe(e.kind,g,t,v,{nodeId:b,model:S.model,modelId:S.modelId,supportsVision:S.supportsVision}))},D=c||g.trim()===``||f&&S===null||p&&m===null;return u(G,{open:!0,onClose:o,title:t===null?d(`ai.newProfile`,`New {{kind}} profile`,{kind:e.label}):d(`ai.editProfile`,`Edit {{name}}`,{name:t.name}),error:l,width:`lg`,testId:`ai-profile-editor`,footer:a(s,{children:[f&&S===null&&u(V,{variant:`warning`,children:d(`ai.pickModelFirst`,`pick a model`)}),p&&m===null&&u(V,{variant:`warning`,children:d(`ai.pickAppleNodeFirst`,`pick a Mac`)}),a(P,{size:`sm`,type:`button`,disabled:D,onClick:E,children:[c&&u(T,{className:`h-3.5 w-3.5 animate-spin`}),t===null?d(`ai.createProfile`,`Create profile`):d(`ai.saveChanges`,`Save changes`)]})]}),children:a(`div`,{className:`space-y-3`,children:[a(`div`,{children:[u(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-profile-name`,children:d(`ai.name`,`Name`)}),u(N,{id:`ai-profile-name`,value:g,onChange:e=>_(e.target.value),placeholder:e.label})]}),f&&a(s,{children:[u(re,{selectedNodeId:b,onSelect:x,label:d(`ai.runtimeNode`,`Runtime node`),alwaysShow:!0}),u(ke,{nodeId:b,value:S,onChange:C}),a(`div`,{children:[u(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-extra-args`,children:d(`ai.extraArgs`,`Additional llama-server arguments`)}),u(N,{id:`ai-extra-args`,value:X(v.extraArgs)??``,onChange:e=>y({...v,extraArgs:e.target.value}),placeholder:ye.join(` `)}),w.length>0&&u(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:w.map((e,t)=>u(V,{variant:`default`,children:e},`${e}-${String(t)}`))}),u(`p`,{className:`mt-1 text-[10px] leading-relaxed text-foreground-subtle`,children:d(`ai.extraArgsHint`,`Flags this form does not already own. Vision models generally need --jinja; some language-only models do not like it. Context size, GPU layers, parallel slots, flash attention and the KV-cache types are set in the fields below — repeating one here is rejected at start.`)})]})]}),p&&u(Ae,{value:m,onChange:h}),u(H,{schema:e.configSchema,values:v,onChange:y}),t!==null&&u(`p`,{className:`text-[10px] text-foreground-subtle`,children:d(`ai.secretHint`,`A stored API key is never shown. Leave it as-is to keep it; type a new value to replace it.`)})]})})}e();function Pe(e){return[{key:`name`,header:e.t(`ai.colProfile`,`Profile`),render:t=>{let n=e.kindByName.get(t.kind);return a(`span`,{className:`flex items-center gap-2`,children:[u(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface`,title:n?.label??t.kind,children:n===void 0?u(`span`,{className:`text-xs text-foreground-subtle`,children:`?`}):u(je,{kind:n,className:`h-4 w-4 text-foreground-subtle`})}),a(`span`,{className:`min-w-0`,children:[u(`span`,{className:`block truncate text-sm font-medium text-foreground`,children:t.name}),e.testResult?.id===t.id&&u(`span`,{className:`block truncate text-[10px] ${e.testResult.ok?`text-success`:`text-danger`}`,children:e.testResult.text})]})]})}},{key:`kind`,header:e.t(`ai.colKind`,`Kind`),nowrap:!0,render:t=>u(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.kindByName.get(t.kind)?.label??t.kind})},{key:`model`,header:e.t(`ai.colModel`,`Model`),render:e=>u(`span`,{className:`text-[11px] text-foreground`,children:e.model})},{key:`vision`,header:e.t(`ai.colVision`,`Vision`),align:`center`,nowrap:!0,render:t=>t.supportsVision?u(V,{variant:`info`,style:`outline`,children:e.t(`ai.vision`,`vision`)}):u(`span`,{className:`text-[11px] text-foreground-subtle`,children:`—`})},{key:`node`,header:e.t(`ai.colNode`,`Node`),nowrap:!0,render:e=>e.runtime===void 0?u(`span`,{className:`text-[11px] text-foreground-subtle`,children:`—`}):u(V,{variant:`default`,children:e.runtime.nodeId})},{key:`enabled`,header:e.t(`ai.colOn`,`On`),align:`center`,nowrap:!0,render:t=>u(W,{checked:t.enabled,onCheckedChange:()=>e.onToggle(t),"aria-label":K.t(`system.aiProfilesTab.toggle`,`toggle {{name}}`,{name:t.name})})},{key:`actions`,header:``,align:`right`,nowrap:!0,render:t=>a(`span`,{className:`flex items-center justify-end gap-1`,children:[u(P,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onTest(t),title:e.t(`ai.test`,`Test`),children:e.testingId===t.id?u(T,{className:`h-3.5 w-3.5 animate-spin`}):u(j,{className:`h-3.5 w-3.5`})}),u(P,{size:`sm`,variant:`ghost`,type:`button`,disabled:!e.kindByName.has(t.kind),onClick:()=>e.onEdit(t),title:e.t(`common.edit`,`Edit`),children:u(b,{className:`h-3.5 w-3.5`})}),u(P,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onDelete(t),title:e.t(`common.delete`,`Delete`),children:u(h,{className:`h-3.5 w-3.5 text-danger`})})]})}]}function Fe(){let{t:e}=q(),s=O(),{state:c,openNew:d,openEdit:f,close:p}=ne(),[m,h]=r(null),[g,_]=r(null),[v,b]=r(null),x=o({queryKey:oe,queryFn:()=>s.trpcClient.llm.listProfiles.query({})}),S=o({queryKey:se,queryFn:async()=>(await s.trpcClient.llm.listProfileKinds.query({})).map(e=>({...e,configSchema:e.configSchema}))}),w=()=>{x.refetch()},E=i(()=>{h(null),b(null),p()},[p]);t(()=>{c.mode===`closed`&&h(null)},[c.mode]);let D=l({mutationFn:e=>s.trpcClient.llm.upsertProfile.mutate({profile:e}),onSuccess:()=>{E(),w()},onError:t=>b(t instanceof Error?t.message:e(`ai.saveFailed`,`Save failed`))}),ee=l({mutationFn:e=>s.trpcClient.llm.deleteProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:w}),k=l({mutationFn:e=>s.trpcClient.llm.testProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:(e,t)=>_({id:t.id,ok:e.ok,text:e.ok?K.t(`system.aiProfilesTab.testOk`,{text:e.text,tokens:e.usage.outputTokens,ms:e.latencyMs}):`${e.code}: ${e.message}`})}),A=x.data??[],te=n(()=>S.data??[],[S.data]),j=n(()=>{let e=new Map;for(let t of te)e.set(t.kind,t);return e},[te]),M=c.mode===`edit`?A.find(e=>e.id===c.id)??null:null,N=M===null?null:j.get(M.kind)??null,F=c.mode===`new`&&m===null,L=c.mode===`new`?m:N,re=c.mode===`edit`?M:null,B=L!==null&&(c.mode===`new`||re!==null);return a(ae,{embedded:!0,icon:C,title:e(`ai.profilesTitle`,`AI profiles`),subtitle:e(`ai.profilesSubtitle`,`One row = one usable model endpoint. The defaults below decide who answers when a feature names no profile.`),children:[u(`div`,{className:`flex justify-end`,children:a(P,{size:`sm`,type:`button`,onClick:()=>{b(null),h(null),d()},children:[u(y,{className:`h-3.5 w-3.5`}),e(`ai.addProfile`,`Add profile`)]})}),x.isError&&u(I,{title:e(`ai.loadFailed`,`Failed to load profiles`),message:x.error instanceof Error?x.error.message:e(`common.error`,`Error`),onRetry:()=>void x.refetch()}),u(Ie,{profiles:A}),x.isLoading&&u(`div`,{className:`flex items-center justify-center py-16`,children:u(T,{className:`h-6 w-6 animate-spin text-primary`})}),!x.isLoading&&A.length===0&&u(`div`,{className:`py-16 text-center text-xs text-foreground-subtle`,children:e(`ai.noProfiles`,`No AI profiles yet. Click "Add profile" to configure one.`)}),A.length>0&&u(z,{headingId:`ai-profiles-list`,title:e(`ai.profilesList`,`Profiles`),children:u(R,{columns:Pe({kindByName:j,testResult:g,testingId:k.isPending?k.variables?.id??null:null,t:e,onToggle:e=>D.mutate({...e,enabled:!e.enabled,apiKey:`__redacted__`}),onTest:e=>k.mutate(e),onEdit:e=>{j.has(e.kind)&&(b(null),h(null),f(e.id))},onDelete:e=>ee.mutate(e)}),rows:A,rowKey:e=>e.id,minWidthPx:760,bordered:!1,maxBodyHeight:`max-h-[60vh]`})}),F&&u(Me,{kinds:te,onCancel:E,onPick:e=>{b(null),h(e)}}),B&&L!==null&&u(Ne,{kind:L,existing:re,saving:D.isPending,error:v,onSave:e=>D.mutate(e),onCancel:E})]})}function Ie({profiles:e}){let{t}=q(),n=O(),r=o({queryKey:ce,queryFn:()=>n.trpcClient.llm.getDefaults.query({})}),i=l({mutationFn:e=>n.trpcClient.llm.setDefault.mutate({selector:{purpose:e.purpose},profileId:e.profileId}),onSuccess:()=>{r.refetch()}}),s=e=>(r.data??[]).find(t=>`purpose`in t.selector&&t.selector.purpose===e)?.profileId??``,c=e=>e===`vision`?t(`ai.defaultVision`,`Default vision profile`):t(`ai.defaultText`,`Default text profile`);return u(z,{headingId:`ai-profiles-defaults`,title:t(`ai.defaultsTitle`,`Defaults`),children:u(`div`,{className:`${d} grid gap-4 sm:grid-cols-2`,children:de.map(({purpose:n,visionOnly:r})=>{let o=r?e.filter(e=>e.supportsVision):e,l=s(n),d=e.find(e=>e.id===l);return a(`div`,{children:[u(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`llm-default-${n}`,children:c(n)}),u(F,{id:`llm-default-${n}`,"aria-label":c(n),className:`h-7 text-xs`,value:l,onChange:e=>i.mutate({purpose:n,profileId:e.target.value===``?null:e.target.value}),options:[{value:``,label:t(`ai.none`,`None`)},...l!==``&&!o.some(e=>e.id===l)?[{value:l,label:d?.name??l}]:[],...o.map(e=>({value:e.id,label:`${e.name} · ${e.model}`}))]}),l!==``&&d===void 0&&u(`p`,{className:`mt-1 text-[10px] text-danger`,children:t(`ai.defaultMissing`,`This default names a profile that no longer exists.`)}),d!==void 0&&!d.enabled&&u(`p`,{className:`mt-1 text-[10px] text-warning`,children:t(`ai.defaultDisabled`,`This default profile is disabled — callers resolve to no profile.`)}),i.error!=null&&u(`p`,{className:`mt-1 text-[10px] text-danger`,children:String(i.error)})]},n)})})})}e();var Le=5e3;function Re(e){return K.t(`system.aiRuntimes.sizeGb`,{value:(e/1e9).toFixed(1)})}function ze(){let{t:e}=q(),t=O(),r=o({queryKey:Y,refetchInterval:Le,queryFn:()=>t.trpcClient.llm.listRuntimeNodes.query({})}),i=n(()=>[{key:`node`,header:e(`ai.colNode`,`Node`),render:e=>u(`span`,{className:`text-sm font-medium text-foreground`,children:e.nodeId})},{key:`state`,header:e(`ai.colState`,`State`),nowrap:!0,render:t=>a(`span`,{className:`flex items-center gap-1.5`,children:[u(V,{variant:t.reachable?`success`:`danger`,children:t.reachable?t.status?.state??e(`ai.ready`,`ready`):e(`ai.unreachable`,`unreachable`)}),t.status?.downloadProgress!==void 0&&u(V,{variant:`info`,children:`${String(Math.round(t.status.downloadProgress*100))}%`})]})},{key:`model`,header:e(`ai.colModel`,`Model`),render:e=>u(`span`,{className:`text-[11px] text-foreground`,children:e.status?.modelId??`—`})},{key:`disk`,header:e(`ai.colDisk`,`On disk`),align:`right`,nowrap:!0,render:e=>u(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.disk===void 0?`—`:Re(e.disk.modelsBytes)})},{key:`apple`,header:e(`ai.colApple`,`Apple on-device`),render:t=>{let n=Ee(t);return a(`span`,{className:`flex flex-col items-start gap-0.5`,children:[u(V,{variant:n.tone,children:e(n.labelKey,n.labelDefault)}),n.detail!==null&&u(`span`,{className:`text-[10px] text-foreground-subtle`,children:n.detail})]})}},{key:`error`,header:e(`ai.colError`,`Error`),render:e=>e.error===void 0?u(`span`,{className:`text-[11px] text-foreground-subtle`,children:`—`}):u(`span`,{className:`text-[11px] text-danger`,children:e.error})}],[e]),s=r.data??[];return a(ae,{embedded:!0,icon:k,title:e(`ai.runtimesTitle`,`Managed runtimes`),subtitle:e(`ai.runtimesSubtitle`,`Nodes advertising the llm-runtime capability: what each has loaded, what it is downloading, and how much model data sits on its disk.`),children:[r.isError&&u(I,{title:e(`ai.runtimesFailed`,`Failed to read runtime nodes`),message:r.error instanceof Error?r.error.message:e(`common.error`,`Error`),onRetry:()=>void r.refetch()}),s.length===0?u(`div`,{className:`py-16 text-center text-xs text-foreground-subtle`,children:e(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):u(z,{headingId:`ai-runtimes-list`,title:e(`ai.runtimesList`,`Nodes`),children:u(R,{columns:i,rows:s,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,maxBodyHeight:B})})]})}var Be=x(`/addon/ai/test-chat`),Ve=x(`/addon/ai/test-chat/chats`),He=6e5;function Ue(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),He)}function We(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ge(e){if(!We(e))return null;let t=e.kind;return t!==`snapshot`&&t!==`track`||typeof e.mimeType!=`string`||typeof e.sizeBytes!=`number`?null:{kind:t,mimeType:e.mimeType,sizeBytes:e.sizeBytes,...typeof e.mediaKind==`string`?{mediaKind:e.mediaKind}:{},...typeof e.capturedAt==`number`?{capturedAt:e.capturedAt}:{},...typeof e.thumbnailBase64==`string`?{thumbnailBase64:e.thumbnailBase64}:{}}}var Ke=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function qe(e){let t;try{t=JSON.parse(e)}catch{return null}if(!We(t))return null;switch(t.kind){case`status`:{let e=Ke.find(e=>e===t.phase);return e===void 0?null:{kind:`status`,phase:e}}case`meta`:return typeof t.profileName!=`string`||typeof t.model!=`string`?null:{kind:`meta`,profileName:t.profileName,model:t.model,mediaSent:Ge(t.mediaSent),streamed:t.streamed===!0,firstTokenTimeoutMs:typeof t.firstTokenTimeoutMs==`number`?t.firstTokenTimeoutMs:0};case`token`:return typeof t.text==`string`?{kind:`token`,text:t.text}:null;case`done`:return{kind:`done`,inputTokens:typeof t.inputTokens==`number`?t.inputTokens:0,outputTokens:typeof t.outputTokens==`number`?t.outputTokens:0,latencyMs:typeof t.latencyMs==`number`?t.latencyMs:0,truncated:t.truncated===!0,...typeof t.conversationId==`string`?{conversationId:t.conversationId}:{}};case`error`:return{kind:`error`,code:typeof t.code==`string`?t.code:`adapter-error`,message:typeof t.message==`string`?t.message:K.t(`helpers.aiTestChat.providerError`)};default:return null}}async function*Je(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.indexOf(`
2
- `);for(;a>=0;){let e=r.slice(0,a).trim();if(r=r.slice(a+1),e.length>0){let t=qe(e);t!==null&&(yield t)}a=r.indexOf(`
3
- `)}}let e=r.trim();if(e.length>0){let t=qe(e);t!==null&&(yield t)}}finally{t.releaseLock()}}function Ye(e){return e.filter(e=>e.failed!==!0&&e.content.length>0).map(e=>({role:e.role,content:e.content}))}function Xe(e){return e.thumbnailBase64===void 0||e.thumbnailBase64.length===0?null:`data:${e.mimeType};base64,${e.thumbnailBase64}`}function Ze(e){return e.messages.map((t,n)=>{let r=t.mediaSent??void 0;return{id:`${e.id}-${String(n)}`,role:t.role,content:t.content,...t.attachment===void 0?{}:{attachmentRef:t.attachment,attachmentKind:t.attachment.kind},...r===void 0?{}:{attachment:r}}})}function Qe(e){let t=e.sizeBytes<1024*1024?`${(e.sizeBytes/1024).toFixed(0)} KB`:`${(e.sizeBytes/(1024*1024)).toFixed(1)} MB`,n=[e.kind===`snapshot`?`camera snapshot`:`track best-shot`,t];return e.mediaKind!==void 0&&n.push(e.mediaKind),e.capturedAt!==void 0&&n.push(new Date(e.capturedAt).toLocaleTimeString()),n.join(` · `)}function $e(e,t){switch(e){case`resolving-image`:return K.t(`helpers.aiTestChat.phaseImage`);case`connecting`:return K.t(`helpers.aiTestChat.phaseConnecting`);case`first-token-wait`:return t>0?K.t(`helpers.aiTestChat.phaseWaitUpTo`,{seconds:Math.round(t/1e3)}):K.t(`helpers.aiTestChat.phaseWait`);case`streaming`:return K.t(`helpers.aiTestChat.phaseAnswering`)}}e();var et=[`pipelineAnalytics`,`listRecentTracks`,`ai-test`],tt=360*60*1e3,nt=40,rt=160,it={phase:`connecting`,firstTokenTimeoutMs:0,text:``,mediaSent:null};function at(){let{t:e}=q(),s=O(),[l,d]=r(``),[f,p]=r(``),[m,g]=r(``),[y,b]=r([]),[x,S]=r(null),[C,w]=r(`none`),[T,E]=r(`throwaway`),[k,M]=r(null),[ne,re]=r([]),[R,z]=r(null),[B,V]=r(null),H=c(null);t(()=>()=>H.current?.abort(),[]);let U=i(async()=>{let e=await fetch(Ve,{credentials:`same-origin`});e.ok&&re((await e.json()).chats??[])},[]);t(()=>{T===`persistent`&&U()},[T,U]);let W=o({queryKey:oe,queryFn:()=>s.trpcClient.llm.listProfiles.query({})}),G=n(()=>(W.data??[]).filter(e=>e.enabled),[W.data]),K=G.find(e=>e.id===l)??null,J=B!==null,ie=i(async(t,n)=>{let r=new AbortController;H.current=r,z(null);let i=Ue(K??{});V({...it,firstTokenTimeoutMs:i??0});let a=``,o=null,s,c=null,u=null,d;try{let e=await fetch(Be,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,signal:r.signal,body:JSON.stringify({profileId:l,messages:t,...f.trim()===``?{}:{system:f.trim()},...n===void 0?{}:{attachment:n},...i===void 0?{}:{firstTokenTimeoutMs:i},...T===`persistent`?{persist:!0,...k===null?{}:{conversationId:k}}:{}})});if(!e.ok||e.body===null){let t=await e.text().catch(()=>``);throw Error(t.length>0?t:`HTTP ${String(e.status)}`)}for await(let t of Je(e.body))switch(t.kind){case`status`:V(e=>({...e??it,phase:t.phase}));break;case`meta`:o=t.mediaSent,s=t.model,V(e=>({...e??it,firstTokenTimeoutMs:t.firstTokenTimeoutMs,mediaSent:t.mediaSent}));break;case`token`:a+=t.text,V(e=>({...e??it,text:a}));break;case`done`:u={outputTokens:t.outputTokens,latencyMs:t.latencyMs},d=t.conversationId;break;case`error`:c=`${t.code}: ${t.message}`;break}}catch(t){r.signal.aborted||z(t instanceof Error?t.message:e(`common.error`,`Error`))}finally{H.current=null,V(null)}d!==void 0&&(M(d),U());let p=r.signal.aborted&&a.length>0;c===null&&a.length===0&&!p||b(e=>[...e,{id:`a-${String(Date.now())}`,role:`assistant`,content:c??a,...c===null?{}:{failed:!0},...o===null?{}:{attachment:o},...s!==void 0&&c===null?{model:s}:{},...u===null?{}:u}])},[T,k,K,l,U,f,e]),se=i(()=>{let e=m.trim();if(e===``||l===``||J)return;let t={id:`u-${String(Date.now())}`,role:`user`,content:e,...x===null?{}:{attachmentLabel:x.label,attachmentKind:x.ref.kind}},n=[...y,t];b(n),g(``);let r=x?.ref;S(null),w(`none`),ie(T===`persistent`&&k!==null?[{role:`user`,content:e}]:Ye(n),r)},[T,k,m,x,l,ie,J,y]),ce=()=>H.current?.abort(),Y=()=>{H.current?.abort(),b([]),S(null),g(``),z(null),V(null),M(null)},le=async e=>{H.current?.abort();let t=await fetch(`${Ve}/${e}`,{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();M(e),b(Ze(n)),V(null),z(null)};return a(ae,{embedded:!0,icon:ee,title:e(`ai.testTitle`,`Test chat`),subtitle:e(T===`persistent`?`ai.testSubtitlePersistent`:`ai.testSubtitle`,T===`persistent`?`Conversations are saved for you and can be reopened. Throwaway mode is still available.`:`A throwaway conversation with one profile. Attach a live camera snapshot or a recent track to check the model can actually read a picture. Nothing is saved — only the usage row.`),children:[u(`div`,{className:`flex justify-end`,children:a(P,{size:`sm`,variant:`secondary`,type:`button`,disabled:y.length===0&&x===null,onClick:Y,children:[u(h,{className:`h-3.5 w-3.5`}),e(`ai.clearChat`,`Clear`)]})}),a(L,{className:`space-y-3 p-4`,children:[a(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[a(`div`,{children:[u(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-test-profile`,children:e(`ai.profile`,`Profile`)}),u(F,{id:`ai-test-profile`,value:l,onChange:e=>d(e.target.value),options:[{value:``,label:e(`ai.selectProfile`,`Select a profile…`)},...G.map(e=>({value:e.id,label:`${e.name} · ${e.model}${e.supportsVision?` · vision`:``}`}))]}),G.length===0&&!W.isLoading&&u(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:e(`ai.noEnabledProfiles`,`No enabled profile. Add one on the Profiles tab.`)})]}),a(`div`,{children:[u(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-test-system`,children:e(`ai.systemPrompt`,`System prompt (optional)`)}),u(N,{id:`ai-test-system`,value:f,onChange:e=>p(e.target.value),placeholder:e(`ai.systemPlaceholder`,`Answer in one short sentence.`)})]})]}),a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[u(P,{size:`sm`,variant:T===`throwaway`?`primary`:`outline`,type:`button`,onClick:()=>{E(`throwaway`),M(null)},children:e(`ai.throwawayMode`,`Throwaway`)}),u(P,{size:`sm`,variant:T===`persistent`?`primary`:`outline`,type:`button`,onClick:()=>E(`persistent`),children:e(`ai.saveConversation`,`Save conversation`)})]}),T===`persistent`&&a(`div`,{className:`space-y-2`,children:[u(`div`,{className:`flex items-center gap-2`,children:a(P,{size:`sm`,variant:`secondary`,type:`button`,onClick:Y,children:[u(te,{className:`h-3.5 w-3.5`}),e(`ai.newChat`,`New chat`)]})}),ne.length>0&&u(`div`,{className:`max-h-36 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:ne.map(e=>u(`button`,{type:`button`,onClick:()=>void le(e.id),className:`flex w-full px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover ${e.id===k?`bg-primary/10`:``}`,children:u(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.title})},e.id))})]}),u(`p`,{className:`text-[10px] text-foreground-subtle`,children:e(`ai.streamNote`,`The answer streams as the model produces it. A cold model can take a while to load — the status line says which phase it is in.`)}),K!==null&&!K.supportsVision&&u(`p`,{className:`text-[10px] text-warning`,children:e(`ai.notVision`,`This profile is not vision-capable — an attached image will be refused before anything is read.`)})]}),R!==null&&u(I,{title:e(`ai.chatFailed`,`The test call failed`),message:R}),u(ot,{turns:y,live:B}),a(L,{className:`space-y-2 p-3`,children:[x!==null&&a(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-surface px-2.5 py-1.5`,children:[x.ref.kind===`snapshot`?u(A,{className:`h-3.5 w-3.5 text-foreground-subtle`}):u(v,{className:`h-3.5 w-3.5 text-foreground-subtle`}),u(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-foreground`,children:x.label}),u(P,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>S(null),children:u(D,{className:`h-3.5 w-3.5`})})]}),a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a(P,{size:`sm`,variant:C===`snapshot`?`primary`:`outline`,type:`button`,onClick:()=>w(C===`snapshot`?`none`:`snapshot`),children:[u(A,{className:`h-3.5 w-3.5`}),e(`ai.attachSnapshot`,`Camera snapshot`)]}),a(P,{size:`sm`,variant:C===`track`?`primary`:`outline`,type:`button`,onClick:()=>w(C===`track`?`none`:`track`),children:[u(v,{className:`h-3.5 w-3.5`}),e(`ai.attachTrack`,`Recent track`)]})]}),C===`snapshot`&&u(lt,{onPick:t=>{S({ref:{kind:`snapshot`,deviceId:t.id},label:e(`ai.snapshotOf`,`Snapshot of {{name}}`,{name:t.name})}),w(`none`)}}),C===`track`&&u(dt,{onPick:(t,n)=>{S({ref:{kind:`track`,trackId:t.trackId,deviceId:t.deviceId},label:e(`ai.trackOf`,`{{class}} on {{name}}`,{class:t.label??t.className,name:n})}),w(`none`)}}),a(`div`,{className:`flex items-center gap-2`,children:[u(N,{value:m,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),se())},placeholder:e(`ai.messagePlaceholder`,`Ask the model something…`),"aria-label":e(`ai.message`,`Message`)}),J?a(P,{size:`sm`,variant:`secondary`,type:`button`,onClick:ce,children:[u(_,{className:`h-3.5 w-3.5`}),e(`ai.stop`,`Stop`)]}):a(P,{size:`sm`,type:`button`,disabled:m.trim()===``||l===``,onClick:se,children:[u(j,{className:`h-3.5 w-3.5`}),e(`ai.send`,`Send`)]})]})]})]})}function ot({turns:e,live:t}){let{t:n}=q();return e.length===0&&t===null?u(`div`,{className:`py-12 text-center text-xs text-foreground-subtle`,children:n(`ai.chatEmpty`,`Pick a profile, optionally attach a camera snapshot or a recent track, and send a message. Nothing here is saved.`)}):u(L,{children:a(`div`,{className:`max-h-[50vh] space-y-2 overflow-y-auto p-3`,children:[e.map(e=>u(st,{turn:e},e.id)),t!==null&&a(`div`,{className:`space-y-1`,children:[t.mediaSent!==null&&u(ct,{attachment:t.mediaSent}),t.text.length>0&&u(st,{turn:{id:`live`,role:`assistant`,content:t.text},streaming:!0}),a(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[u(T,{className:`h-3.5 w-3.5 animate-spin`}),$e(t.phase,t.firstTokenTimeoutMs)]})]})]})})}function st({turn:e,streaming:t=!1}){let{t:n}=q(),r=e.role===`user`,i=e.failed===!0?`border-danger/40 bg-danger/10`:`border-border bg-surface`;return u(`div`,{className:`flex ${r?`justify-end`:`justify-start`}`,children:a(`div`,{className:`max-w-[85%] rounded-lg border px-3 py-2 ${r?`border-primary/40 bg-primary/10`:i}`,children:[a(`p`,{className:`whitespace-pre-wrap break-words text-xs text-foreground`,children:[e.content,t&&u(`span`,{className:`ml-0.5 animate-pulse text-primary`,children:`▌`})]}),e.attachment!==void 0&&u(ct,{attachment:e.attachment}),e.attachmentLabel!==void 0&&a(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[e.attachmentKind===`track`?u(v,{className:`h-3 w-3`}):u(A,{className:`h-3 w-3`}),e.attachmentLabel]}),e.attachment!==void 0&&a(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[e.attachment.kind===`snapshot`?u(A,{className:`h-3 w-3`}):u(v,{className:`h-3 w-3`}),Qe(e.attachment)]}),e.model!==void 0&&u(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:n(`system.aiTestChat.tokMs`,`{{model}} · {{value2}} tok · {{value3}} ms`,{model:e.model,value2:String(e.outputTokens??0),value3:String(e.latencyMs??0)})})]})})}function ct({attachment:e}){let{t}=q(),n=Xe(e);return n===null?null:u(`img`,{src:n,alt:t(`system.aiTestChat.sentToTheModel`,`sent to the model`),className:`mt-1 max-h-32 rounded-md border border-border object-contain`})}function lt({onPick:e}){let{t}=q(),n=U({isCamera:!0,projection:`slim`}),r=(n.data??[]).filter(e=>!e.disabled);return n.isLoading?u(T,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r.length===0?u(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noCameras`,`No camera found.`)}):u(`div`,{className:`grid max-h-56 grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-4`,children:r.map(t=>u(ut,{device:t,onPick:e},t.id))})}function ut({device:e,onPick:t}){let{t:n}=q(),{src:r}=p(e.id,{width:rt});return a(`button`,{type:`button`,onClick:()=>t(e),className:`overflow-hidden rounded-md border border-border bg-surface text-left transition-colors hover:border-primary/50`,children:[u(`span`,{className:`block aspect-video w-full bg-background-elevated`,children:r!==null&&u(`img`,{src:r,alt:``,className:`h-full w-full object-cover`,loading:`lazy`})}),a(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[!e.online&&u(V,{variant:`warning`,children:n(`common.off`)}),u(`span`,{className:`truncate text-[10px] text-foreground`,children:e.name})]})]})}function dt({onPick:e}){let{t}=q(),r=O(),i=U({isCamera:!0,projection:`slim`}),s=n(()=>(i.data??[]).map(e=>e.id),[i.data]),c=n(()=>{let e=new Map;for(let t of i.data??[])e.set(t.id,t.name);return e},[i.data]),l=o({queryKey:[...et,s.length],enabled:s.length>0,queryFn:()=>r.trpcClient.pipelineAnalytics.listRecentTracks.query({deviceIds:[...s],since:Date.now()-tt,limit:nt,projection:`slim`})});if(i.isLoading||l.isLoading)return u(T,{className:`h-4 w-4 animate-spin text-foreground-subtle`});let d=l.data?.tracks??[];return d.length===0?u(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noTracks`,`No track in the last 6 hours.`)}):u(`div`,{className:`max-h-56 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:d.map(t=>a(`button`,{type:`button`,onClick:()=>e(t,c.get(t.deviceId)??String(t.deviceId)),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover`,children:[u(v,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),u(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:t.label??t.className}),u(`span`,{className:`shrink-0 text-foreground-subtle`,children:c.get(t.deviceId)??t.deviceId}),u(`span`,{className:`shrink-0 text-foreground-subtle`,children:new Date(t.lastSeen).toLocaleTimeString()})]},t.trackId))})}e();var ft=1440*60*1e3,pt=[1,7,30,90];function mt(){let{t:e}=q(),t=O(),[i,s]=r(7),c=n(()=>{let e=new Date;return e.setHours(0,0,0,0),e.getTime()-(i-1)*ft},[i]),l=o({queryKey:oe,queryFn:()=>t.trpcClient.llm.listProfiles.query({})}),d=o({queryKey:[...ue,i],queryFn:()=>t.trpcClient.llm.getUsage.query({since:c})}),f=n(()=>{let e=new Map;for(let t of l.data??[])e.set(t.id,t.name);return e},[l.data]),p=n(()=>[{key:`day`,header:e(`ai.colDay`,`Day`),nowrap:!0,render:e=>e.day},{key:`consumer`,header:e(`ai.colConsumer`,`Consumer`),nowrap:!0,render:e=>u(`span`,{className:`text-[11px] text-foreground`,children:e.consumer})},{key:`profile`,header:e(`ai.colProfile`,`Profile`),render:e=>u(`span`,{className:`text-[11px] text-foreground`,children:f.get(e.profileId)??e.profileId})},{key:`calls`,header:e(`ai.colCalls`,`Calls`),align:`right`,nowrap:!0,render:e=>String(e.calls)},{key:`okErr`,header:e(`ai.colOkErr`,`OK / err`),align:`right`,nowrap:!0,render:e=>u(`span`,{className:e.errorCalls>0?`text-danger`:void 0,children:`${String(e.okCalls)} / ${String(e.errorCalls)}`})},{key:`tokens`,header:e(`ai.colTokens`,`In / out tok`),align:`right`,nowrap:!0,render:e=>`${String(e.inputTokens)} / ${String(e.outputTokens)}`},{key:`latency`,header:e(`ai.colAvgMs`,`Avg ms`),align:`right`,nowrap:!0,render:e=>String(Math.round(e.avgLatencyMs))}],[f,e]),m=d.data??[];return a(ae,{embedded:!0,icon:S,title:e(`ai.usageTitle`,`Usage`),subtitle:e(`ai.usageSubtitle`,`Server-side rollup per day, consumer and profile — never raw call rows. Errors are counted, so a profile that always fails is visible here before a feature reports it.`),actions:u(`div`,{className:`w-40`,children:u(F,{"aria-label":e(`ai.window`,`Window`),value:String(i),options:pt.map(t=>({value:String(t),label:e(`ai.lastDays`,`Last {{days}} days`,{days:t})})),onChange:e=>s(Number(e.target.value))})}),children:[d.isError&&u(I,{title:e(`ai.usageFailed`,`Failed to read usage`),message:d.error instanceof Error?d.error.message:e(`common.error`,`Error`),onRetry:()=>void d.refetch()}),m.length===0?u(`div`,{className:`py-16 text-center text-xs text-foreground-subtle`,children:e(`ai.noUsage`,`No AI calls in this window.`)}):u(z,{headingId:`ai-usage-list`,title:e(`ai.usageList`,`Rollup`),children:u(R,{columns:p,rows:m,rowKey:e=>`${e.day}|${e.consumer}|${e.profileId}`,minWidthPx:720,bordered:!1,maxBodyHeight:B})})]})}function ht(){let{t:e}=q(),t=J(`/system/ai`,{t:e,isAdmin:!0})??{icon:C,title:e(`system.ai`,`AI`)};return u(ie,{icon:t.icon,title:t.title,defaultSection:`profiles`,sectionsLabel:`${t.title} sections`,sections:[{id:`profiles`,label:e(`ai.tabProfiles`,`Profiles`),content:u(Fe,{})},{id:`runtimes`,label:e(`ai.tabRuntimes`,`Runtimes`),content:u(ze,{})},{id:`usage`,label:e(`ai.tabUsage`,`Usage`),content:u(mt,{})},{id:`test`,label:e(`ai.tabTest`,`Test`),content:u(at,{})}]})}export{ht as AiProfilesPage,ht as default};