@camstack/addon-admin-ui 1.2.649 → 1.2.651
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/assets/Addons-B8ltQOv0.js +5 -0
- package/dist/assets/{AdminPage-a5x3JamG.js → AdminPage-j7wlZJaX.js} +1 -1
- package/dist/assets/{AdminSectionedPage-C_Xcom2n.js → AdminSectionedPage-Bff3Jex6.js} +1 -1
- package/dist/assets/AiProfiles-BKV84wBr.js +3 -0
- package/dist/assets/{BootstrapSettingsForm-gwEmOCOw.js → BootstrapSettingsForm-BybQlvQs.js} +1 -1
- package/dist/assets/Build-RULxbWDd.js +40 -0
- package/dist/assets/{Calendars-B71AHi8a.js → Calendars-CG2avL1-.js} +1 -1
- package/dist/assets/{CameraGrids-BOvAtaoj.js → CameraGrids-dfX8bLpt.js} +1 -1
- package/dist/assets/{Cluster-CvA-GBsH.js → Cluster-ddOQtA0z.js} +1 -1
- package/dist/assets/CompositionBlockEditor-E9dJvNcn.js +2 -0
- package/dist/assets/{CompositionEditorPage-BdTBwrAp.js → CompositionEditorPage-CIYtKsgd.js} +1 -1
- package/dist/assets/{Data-DViGCVbI.js → Data-40hNsswQ.js} +2 -2
- package/dist/assets/DeviceDetail-DIOgBXBE.js +2 -0
- package/dist/assets/{Devices-baYBN34H.js → Devices-D82RrdaQ.js} +1 -1
- package/dist/assets/{EmbedDevicePage-l8wAVLqx.js → EmbedDevicePage-DCqyPvjt.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-DhwYDIti.js → EmbedPlayerPage-CoUvRfeW.js} +1 -1
- package/dist/assets/{History-BBHnnwco.js → History-LROTE-3F.js} +1 -1
- package/dist/assets/Identity-B59zHLA3.js +1 -0
- package/dist/assets/{InstancesTable-Dzt_ZD_8.js → InstancesTable-I61ipsWQ.js} +1 -1
- package/dist/assets/IntegrationDetail-rOO7_tpX.js +1 -0
- package/dist/assets/{IntegrationWizard-CuTjXuIh.js → IntegrationWizard-D-DvT_nc.js} +1 -1
- package/dist/assets/{Integrations-DTo3e0AL.js → Integrations-CqTN93AE.js} +2 -2
- package/dist/assets/Integrations-D9I8f_dT.js +1 -0
- package/dist/assets/{Library-W3VA0vMC.js → Library-BIn-La3n.js} +1 -1
- package/dist/assets/Locations-Dhv1Kc76.js +3 -0
- package/dist/assets/{Logs-CI_K8DdA.js → Logs-q8mnPoZt.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-0z0o1CmM.js → MaskShapeCanvas-C5CA5ArA.js} +1 -1
- package/dist/assets/{MotionZonesSettings-BghbU1K3.js → MotionZonesSettings-CuEdW4kg.js} +1 -1
- package/dist/assets/MyAccess-BuMfiAQv.js +2 -0
- package/dist/assets/{Network-D8ZwZsNt.js → Network-Cb8igqGd.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-CT6b4R4c.js → NodeAddonsSettingsPanel-Epb11fvO.js} +2 -2
- package/dist/assets/Notifications-Dqd_UOOG.js +1 -0
- package/dist/assets/{Pipeline-CjQ_g5Ra.js → Pipeline-BmIjO9-D.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-Kz5m0O7l.js → PrivacyMaskSettings-CRGHDdXy.js} +1 -1
- package/dist/assets/Recordings-DwV6-ANm.js +1 -0
- package/dist/assets/{RemoteGrid-Dyh0od5O.js → RemoteGrid-JW_jcrRL.js} +1 -1
- package/dist/assets/{ScanSubnetEditor-CjpZhe61.js → ScanSubnetEditor-Bp0ZzAGR.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-BjJyeBEk.js → SceneMonitorEditor-Q7jXeGpo.js} +1 -1
- package/dist/assets/SessionsList-CmpxjyUF.js +2 -0
- package/dist/assets/{Showroom-D32EhuTm.js → Showroom-B3_xGKQA.js} +1 -1
- package/dist/assets/{StorageLocationsTable-C64-zmrX.js → StorageLocationsTable-BvMGBanJ.js} +1 -1
- package/dist/assets/{System-Bd2XMdpV.js → System-JVEKqDtH.js} +1 -1
- package/dist/assets/{Templates-BcASnjcc.js → Templates-CjBsCi25.js} +1 -1
- package/dist/assets/{Terminal-CX_P3djl.js → Terminal-BvsE40TJ.js} +3 -3
- package/dist/assets/{TrainingProviders-Bm8VXCkV.js → TrainingProviders-CqyzYHwE.js} +1 -1
- package/dist/assets/{Viewer-i95FQfUb.js → Viewer-Cz5LM-ZD.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DdrXO22M.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-GRzbN4aL.js} +1 -1
- package/dist/assets/{action-draft-CLxOlN3v.js → action-draft-BVTi9xo9.js} +1 -1
- package/dist/assets/{ai-page.helpers-BceORsq5.js → ai-page.helpers-DNcaXg8W.js} +1 -1
- package/dist/assets/{assignment-candidates-DsHDR5YQ.js → assignment-candidates-Brt1TfBJ.js} +1 -1
- package/dist/assets/{authed-media-dm4GdCKO.js → authed-media-BDz2D3wE.js} +1 -1
- package/dist/assets/{board-model-CpYPkmlj.js → board-model-fGSLbQlQ.js} +1 -1
- package/dist/assets/client-D5elicir.js +1114 -0
- package/dist/assets/{command-vocab-Ch6bCpeT.js → command-vocab-GNKqYgCN.js} +1 -1
- package/dist/assets/create-composition-DTVI2eEi.js +1 -0
- package/dist/assets/device-detail-BRYKrKpX.js +1 -0
- package/dist/assets/{device-integration-icon-C1tT_gx2.js → device-integration-icon-BaZamKTr.js} +1 -1
- package/dist/assets/device-picker-model-DoO_DpCX.js +1 -0
- package/dist/assets/dist-B6ZlvtdW.js +1114 -0
- package/dist/assets/{dist-XnvNJt1-.js → dist-Cv10wXXS.js} +1 -1
- package/dist/assets/{format-DWAycAFG.js → format-CD_iudtm.js} +1 -1
- package/dist/assets/{hostInit-HrqqiwVG.js → hostInit-C7q5ZVa2.js} +1 -1
- package/dist/assets/i18n-BNkA6jrS.js +1 -0
- package/dist/assets/{icons-Bu52cGsB.js → icons-DGI91n0_.js} +1 -1
- package/dist/assets/index-BKgdp64z.js +4 -0
- package/dist/assets/{linked-devices-model-m9SG2P2S.js → linked-devices-model-DdmaPBcx.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-2685693c.js → mf-entry-bootstrap-0-72008839.js} +2 -2
- package/dist/assets/mount-DoO_DpCX.js +1 -0
- package/dist/assets/{notification-rule-status-BUGrM94L.js → notification-rule-status-DorPFV4O.js} +1 -1
- package/dist/assets/{player-overlays-C92tUBpz.js → player-overlays-BhrNQiuF.js} +1 -1
- package/dist/assets/remoteEntry-C0hl0rQE.js +1 -0
- package/dist/assets/src-B_Sz8ZXm.js +252 -0
- package/dist/assets/{step-inspector-model-jqHTs0N6.js → step-inspector-model-CCXeB8Qp.js} +1 -1
- package/dist/assets/{use-scenes-feed-FsHwLqsd.js → use-scenes-feed-BlDgjdbB.js} +1 -1
- package/dist/assets/{use-stationary-objects-XLHAhwbH.js → use-stationary-objects-X5LldesX.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-CRnQv6Iu.js → useAdminDeviceRemoval-DPzuxsjZ.js} +1 -1
- package/dist/assets/useEventInvalidation-DoO_DpCX.js +1 -0
- package/dist/assets/{useNodeUrlSelection-DB-QVsC2.js → useNodeUrlSelection-qjXl6qTX.js} +1 -1
- package/dist/assets/useTemplateSave-msQZOGf6.js +1 -0
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CC-TW8gU.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Pzb2Fskx.js} +2 -2
- package/dist/index.html +7 -7
- package/dist/server/addon.js +240 -17
- package/package.json +2 -2
- package/dist/assets/Addons-CIhFgQkc.js +0 -5
- package/dist/assets/AiProfiles-C84EP_cC.js +0 -3
- package/dist/assets/Build-CtavtCki.js +0 -40
- package/dist/assets/CompositionBlockEditor-Dxq0Hk8x.js +0 -2
- package/dist/assets/DeviceDetail-BjIgUxeI.js +0 -2
- package/dist/assets/Identity-BqSMytgc.js +0 -1
- package/dist/assets/IntegrationDetail-BlIntnkm.js +0 -1
- package/dist/assets/Integrations-B5pGLzkU.js +0 -1
- package/dist/assets/Locations-BvL1S_Yx.js +0 -3
- package/dist/assets/MyAccess-8KqkNTje.js +0 -2
- package/dist/assets/Notifications-CxA4JqZI.js +0 -1
- package/dist/assets/Recordings-CtwtOGPM.js +0 -1
- package/dist/assets/SessionsList-C9ogUSGk.js +0 -2
- package/dist/assets/client-DM5tcoga.js +0 -1114
- package/dist/assets/create-composition-C2bdkjGW.js +0 -1
- package/dist/assets/device-detail-DRsIQkC1.js +0 -1
- package/dist/assets/device-picker-model-DdNgdYpo.js +0 -1
- package/dist/assets/dist-xzDYmBSA.js +0 -1114
- package/dist/assets/i18n-CwgPYzYg.js +0 -1
- package/dist/assets/index-Wmx2JgTc.js +0 -4
- package/dist/assets/mount-DdNgdYpo.js +0 -1
- package/dist/assets/remoteEntry-DwE_0hKK.js +0 -1
- package/dist/assets/src-wYH5IrPO.js +0 -250
- package/dist/assets/useEventInvalidation-DdNgdYpo.js +0 -1
- package/dist/assets/useTemplateSave-CzAC1u4c.js +0 -1
package/dist/server/addon.js
CHANGED
|
@@ -5912,7 +5912,7 @@ var ZodIssueCode = {
|
|
|
5912
5912
|
var ZodFirstPartyTypeKind;
|
|
5913
5913
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5914
5914
|
//#endregion
|
|
5915
|
-
//#region ../types/dist/sleep-
|
|
5915
|
+
//#region ../types/dist/sleep-Ba1dJYDo.mjs
|
|
5916
5916
|
/**
|
|
5917
5917
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5918
5918
|
* window to float samples (D455).
|
|
@@ -11356,7 +11356,10 @@ var ACTUATOR_CAP_VOCABULARY = {
|
|
|
11356
11356
|
"ir-transmitter": {
|
|
11357
11357
|
scope: "device",
|
|
11358
11358
|
noun: t("IR / RF transmitter", "Trasmettitore IR / RF"),
|
|
11359
|
-
notOperatorFacing: {
|
|
11359
|
+
notOperatorFacing: {
|
|
11360
|
+
send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it",
|
|
11361
|
+
learn: "an interactive capture the operator starts from the source dialog and answers by pressing a physical remote; no automation can supply the signal"
|
|
11362
|
+
}
|
|
11360
11363
|
},
|
|
11361
11364
|
control: {
|
|
11362
11365
|
scope: "device",
|
|
@@ -48921,11 +48924,13 @@ var IrCodecError = class extends Error {
|
|
|
48921
48924
|
this.code = code;
|
|
48922
48925
|
}
|
|
48923
48926
|
};
|
|
48927
|
+
/** Maximum number of mark/space entries one pulse train may carry. */
|
|
48928
|
+
var IR_TIMINGS_MAX = 1024;
|
|
48924
48929
|
/**
|
|
48925
48930
|
* A pulse train in signed microseconds: mark (+) first, then space (-), strictly
|
|
48926
48931
|
* alternating, no zeros, 2..1024 entries.
|
|
48927
48932
|
*/
|
|
48928
|
-
var IrTimingsSchema = array(number$1().int()).min(2).max(
|
|
48933
|
+
var IrTimingsSchema = array(number$1().int()).min(2).max(IR_TIMINGS_MAX).superRefine((timings, ctx) => {
|
|
48929
48934
|
timings.forEach((value, index) => {
|
|
48930
48935
|
const expectMark = index % 2 === 0;
|
|
48931
48936
|
if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
|
|
@@ -48972,15 +48977,186 @@ function decodePronto(code) {
|
|
|
48972
48977
|
carrierHz: Math.round(1e6 / unitUs)
|
|
48973
48978
|
};
|
|
48974
48979
|
}
|
|
48975
|
-
/**
|
|
48976
|
-
|
|
48977
|
-
|
|
48978
|
-
|
|
48979
|
-
|
|
48980
|
-
|
|
48981
|
-
|
|
48982
|
-
|
|
48983
|
-
|
|
48980
|
+
/**
|
|
48981
|
+
* FastLZ level 1: a byte-oriented LZ77 stream. A control byte below 32 starts a
|
|
48982
|
+
* literal run of `ctrl + 1` bytes; otherwise it is a back-reference whose length
|
|
48983
|
+
* is `ctrl >> 5` (extended by one byte when 7) and whose distance is split
|
|
48984
|
+
* between the low 5 bits and the next byte.
|
|
48985
|
+
*/
|
|
48986
|
+
var MAX_DISTANCE = 8192;
|
|
48987
|
+
var MAX_LITERAL_RUN = 32;
|
|
48988
|
+
var MIN_MATCH = 3;
|
|
48989
|
+
var MAX_MATCH = 264;
|
|
48990
|
+
/**
|
|
48991
|
+
* Most bytes a decoded IR code may hold: two bytes per timing. A level-1 stream
|
|
48992
|
+
* can expand ~130x, so the decoder checks this bound before every write.
|
|
48993
|
+
*/
|
|
48994
|
+
var IR_DECOMPRESSED_MAX = IR_TIMINGS_MAX * 2;
|
|
48995
|
+
function fastlzDecompress(input) {
|
|
48996
|
+
const out = [];
|
|
48997
|
+
let ip = 0;
|
|
48998
|
+
const room = (count) => {
|
|
48999
|
+
if (out.length + count > IR_DECOMPRESSED_MAX) throw new IrCodecError("tuya-malformed", "decompressed code is larger than any IR train");
|
|
49000
|
+
};
|
|
49001
|
+
const next = () => {
|
|
49002
|
+
const byte = input[ip++];
|
|
49003
|
+
if (byte === void 0) throw new IrCodecError("tuya-malformed", "compressed stream is truncated");
|
|
49004
|
+
return byte;
|
|
49005
|
+
};
|
|
49006
|
+
while (ip < input.length) {
|
|
49007
|
+
const ctrl = next();
|
|
49008
|
+
if (ctrl < 32) {
|
|
49009
|
+
room(ctrl + 1);
|
|
49010
|
+
for (let i = 0; i <= ctrl; i++) out.push(next());
|
|
49011
|
+
continue;
|
|
49012
|
+
}
|
|
49013
|
+
let len = (ctrl >> 5) - 1;
|
|
49014
|
+
if (len === 6) len += next();
|
|
49015
|
+
const distance = ((ctrl & 31) << 8) + next() + 1;
|
|
49016
|
+
const start = out.length - distance;
|
|
49017
|
+
if (start < 0) throw new IrCodecError("tuya-malformed", "back-reference points before the stream");
|
|
49018
|
+
room(len + 3);
|
|
49019
|
+
for (let i = 0; i < len + 3; i++) {
|
|
49020
|
+
const byte = out[start + i];
|
|
49021
|
+
if (byte === void 0) throw new IrCodecError("tuya-malformed", "back-reference is invalid");
|
|
49022
|
+
out.push(byte);
|
|
49023
|
+
}
|
|
49024
|
+
}
|
|
49025
|
+
return Uint8Array.from(out);
|
|
49026
|
+
}
|
|
49027
|
+
function fastlzCompress(input) {
|
|
49028
|
+
const out = [];
|
|
49029
|
+
const lastSeen = /* @__PURE__ */ new Map();
|
|
49030
|
+
let literalStart = 0;
|
|
49031
|
+
const flushLiterals = (end) => {
|
|
49032
|
+
for (let from = literalStart; from < end; from += MAX_LITERAL_RUN) {
|
|
49033
|
+
const to = Math.min(from + MAX_LITERAL_RUN, end);
|
|
49034
|
+
out.push(to - from - 1);
|
|
49035
|
+
for (let i = from; i < to; i++) out.push(input[i] ?? 0);
|
|
49036
|
+
}
|
|
49037
|
+
};
|
|
49038
|
+
let pos = 0;
|
|
49039
|
+
while (pos < input.length) {
|
|
49040
|
+
let matchLen = 0;
|
|
49041
|
+
let matchDistance = 0;
|
|
49042
|
+
if (pos + MIN_MATCH <= input.length) {
|
|
49043
|
+
const key = (input[pos] ?? 0) << 16 | (input[pos + 1] ?? 0) << 8 | (input[pos + 2] ?? 0);
|
|
49044
|
+
const candidate = lastSeen.get(key);
|
|
49045
|
+
lastSeen.set(key, pos);
|
|
49046
|
+
if (candidate !== void 0 && pos - candidate <= MAX_DISTANCE) {
|
|
49047
|
+
let len = 0;
|
|
49048
|
+
while (pos + len < input.length && len < MAX_MATCH && input[candidate + len] === input[pos + len]) len++;
|
|
49049
|
+
if (len >= MIN_MATCH) {
|
|
49050
|
+
matchLen = len;
|
|
49051
|
+
matchDistance = pos - candidate - 1;
|
|
49052
|
+
}
|
|
49053
|
+
}
|
|
49054
|
+
}
|
|
49055
|
+
if (matchLen === 0) {
|
|
49056
|
+
pos++;
|
|
49057
|
+
continue;
|
|
49058
|
+
}
|
|
49059
|
+
flushLiterals(pos);
|
|
49060
|
+
const enc = matchLen - 2;
|
|
49061
|
+
if (enc < 7) out.push(enc << 5 | matchDistance >> 8);
|
|
49062
|
+
else out.push(224 | matchDistance >> 8, enc - 7);
|
|
49063
|
+
out.push(matchDistance & 255);
|
|
49064
|
+
pos += matchLen;
|
|
49065
|
+
literalStart = pos;
|
|
49066
|
+
}
|
|
49067
|
+
flushLiterals(input.length);
|
|
49068
|
+
return Uint8Array.from(out);
|
|
49069
|
+
}
|
|
49070
|
+
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
49071
|
+
var MAX_DURATION_US = 65535;
|
|
49072
|
+
function toBase64(bytes) {
|
|
49073
|
+
let out = "";
|
|
49074
|
+
for (let i = 0; i < bytes.length; i += 3) {
|
|
49075
|
+
const a = bytes[i] ?? 0;
|
|
49076
|
+
const b = bytes[i + 1] ?? 0;
|
|
49077
|
+
const c = bytes[i + 2] ?? 0;
|
|
49078
|
+
const word = a << 16 | b << 8 | c;
|
|
49079
|
+
out += ALPHABET[word >> 18 & 63];
|
|
49080
|
+
out += ALPHABET[word >> 12 & 63];
|
|
49081
|
+
out += i + 1 < bytes.length ? ALPHABET[word >> 6 & 63] : "=";
|
|
49082
|
+
out += i + 2 < bytes.length ? ALPHABET[word & 63] : "=";
|
|
49083
|
+
}
|
|
49084
|
+
return out;
|
|
49085
|
+
}
|
|
49086
|
+
function fromBase64(text) {
|
|
49087
|
+
const clean = text.trim().replace(/=+$/, "");
|
|
49088
|
+
if (clean.length === 0 || clean.length % 4 === 1) throw new IrCodecError("tuya-malformed", "not a base64 string");
|
|
49089
|
+
const out = [];
|
|
49090
|
+
let bits = 0;
|
|
49091
|
+
let acc = 0;
|
|
49092
|
+
for (const ch of clean) {
|
|
49093
|
+
const value = ALPHABET.indexOf(ch);
|
|
49094
|
+
if (value < 0) throw new IrCodecError("tuya-malformed", "not a base64 string");
|
|
49095
|
+
acc = acc << 6 | value;
|
|
49096
|
+
bits += 6;
|
|
49097
|
+
if (bits >= 8) {
|
|
49098
|
+
bits -= 8;
|
|
49099
|
+
out.push(acc >> bits & 255);
|
|
49100
|
+
}
|
|
49101
|
+
}
|
|
49102
|
+
return Uint8Array.from(out);
|
|
49103
|
+
}
|
|
49104
|
+
/** Signed pulse train to a Tuya IR code: base64(FastLZ(uint16 LE durations)). */
|
|
49105
|
+
function encodeTuya(timings) {
|
|
49106
|
+
const bytes = new Uint8Array(timings.length * 2);
|
|
49107
|
+
timings.forEach((value, index) => {
|
|
49108
|
+
const duration = Math.abs(value);
|
|
49109
|
+
if (duration === 0 || duration > MAX_DURATION_US) throw new IrCodecError("invalid-timings", `timing ${index} does not fit 16 bits`);
|
|
49110
|
+
bytes[index * 2] = duration & 255;
|
|
49111
|
+
bytes[index * 2 + 1] = duration >> 8;
|
|
49112
|
+
});
|
|
49113
|
+
return toBase64(fastlzCompress(bytes));
|
|
49114
|
+
}
|
|
49115
|
+
/** A Tuya IR code to a signed pulse train (mark first). Throws `IrCodecError`. */
|
|
49116
|
+
function decodeTuya(code) {
|
|
49117
|
+
const bytes = fastlzDecompress(fromBase64(code));
|
|
49118
|
+
if (bytes.length === 0 || bytes.length % 2 !== 0) throw new IrCodecError("tuya-malformed", "payload is not a list of 16-bit durations");
|
|
49119
|
+
const timings = [];
|
|
49120
|
+
for (let i = 0; i < bytes.length; i += 2) {
|
|
49121
|
+
const duration = (bytes[i] ?? 0) | (bytes[i + 1] ?? 0) << 8;
|
|
49122
|
+
timings.push(i / 2 % 2 === 0 ? duration : -duration);
|
|
49123
|
+
}
|
|
49124
|
+
const checked = IrTimingsSchema.safeParse(timings);
|
|
49125
|
+
if (!checked.success) throw new IrCodecError("tuya-malformed", checked.error.message);
|
|
49126
|
+
return checked.data;
|
|
49127
|
+
}
|
|
49128
|
+
/** Device-native IR code formats a transmitter can replay verbatim. */
|
|
49129
|
+
var IrNativeFormatSchema = _enum(["tuya"]);
|
|
49130
|
+
/**
|
|
49131
|
+
* Longest native code accepted: base64 of the worst-case compressed stream
|
|
49132
|
+
* (every decoded byte as a literal, plus one control byte per 32), with margin.
|
|
49133
|
+
*/
|
|
49134
|
+
var IR_NATIVE_CODE_MAX_CHARS = Math.ceil((IR_DECOMPRESSED_MAX + Math.ceil(IR_DECOMPRESSED_MAX / 32)) / 3) * 4 + 256;
|
|
49135
|
+
var IrNativeCodeSchema = object({
|
|
49136
|
+
format: IrNativeFormatSchema,
|
|
49137
|
+
code: string().min(1).max(IR_NATIVE_CODE_MAX_CHARS)
|
|
49138
|
+
});
|
|
49139
|
+
var IR_NATIVE_CODECS = { tuya: {
|
|
49140
|
+
encode: encodeTuya,
|
|
49141
|
+
decode: decodeTuya
|
|
49142
|
+
} };
|
|
49143
|
+
/** What a remote command stores: a raw pulse train, a learned Pronto code, or a device-native code. */
|
|
49144
|
+
var IrPayloadSchema = discriminatedUnion("kind", [
|
|
49145
|
+
object({
|
|
49146
|
+
kind: literal("raw"),
|
|
49147
|
+
timings: array(number$1().int()),
|
|
49148
|
+
settings: TransmitSettingsSchema.optional()
|
|
49149
|
+
}),
|
|
49150
|
+
object({
|
|
49151
|
+
kind: literal("pronto"),
|
|
49152
|
+
code: string()
|
|
49153
|
+
}),
|
|
49154
|
+
object({
|
|
49155
|
+
kind: literal("native"),
|
|
49156
|
+
format: IrNativeFormatSchema,
|
|
49157
|
+
code: string()
|
|
49158
|
+
})
|
|
49159
|
+
]);
|
|
48984
49160
|
/** Resolve a payload to what `ir-transmitter.send` takes. Throws `IrCodecError`. */
|
|
48985
49161
|
function toTimings(payload) {
|
|
48986
49162
|
if (payload.kind === "pronto") {
|
|
@@ -48990,6 +49166,10 @@ function toTimings(payload) {
|
|
|
48990
49166
|
settings: { carrierHz: decoded.carrierHz }
|
|
48991
49167
|
};
|
|
48992
49168
|
}
|
|
49169
|
+
if (payload.kind === "native") return {
|
|
49170
|
+
timings: IR_NATIVE_CODECS[payload.format].decode(payload.code),
|
|
49171
|
+
settings: {}
|
|
49172
|
+
};
|
|
48993
49173
|
const checked = IrTimingsSchema.safeParse(payload.timings);
|
|
48994
49174
|
if (!checked.success) throw new IrCodecError("invalid-timings", checked.error.message);
|
|
48995
49175
|
return {
|
|
@@ -56592,13 +56772,32 @@ var IrSendResultSchema = object({
|
|
|
56592
56772
|
var IrTransmitterInfoSchema = object({
|
|
56593
56773
|
media: array(IrMediumSchema),
|
|
56594
56774
|
settable: array(TransmitSettingKeySchema),
|
|
56595
|
-
maxTimings: number$1().int().positive()
|
|
56775
|
+
maxTimings: number$1().int().positive(),
|
|
56776
|
+
/** The transmitter can learn a code (`learn`). */
|
|
56777
|
+
learn: boolean().default(false),
|
|
56778
|
+
/** Native code formats the transmitter replays verbatim (`send.native`). */
|
|
56779
|
+
formats: array(IrNativeFormatSchema).default([])
|
|
56780
|
+
});
|
|
56781
|
+
var IR_LEARN_TIMEOUT_DEFAULT_MS = 2e4;
|
|
56782
|
+
var IR_LEARN_TIMEOUT_MAX_MS = 6e4;
|
|
56783
|
+
var IrLearnResultSchema = object({
|
|
56784
|
+
/** The code in the device's own format, when it reports one. */
|
|
56785
|
+
native: IrNativeCodeSchema.nullable(),
|
|
56786
|
+
timings: IrTimingsSchema,
|
|
56787
|
+
carrierHz: number$1().int().positive().nullable()
|
|
56596
56788
|
});
|
|
56597
56789
|
DeviceType.Generic, method(object({
|
|
56598
56790
|
deviceId: number$1().int().nonnegative(),
|
|
56599
|
-
timings: IrTimingsSchema,
|
|
56791
|
+
timings: IrTimingsSchema.optional(),
|
|
56792
|
+
native: IrNativeCodeSchema.optional(),
|
|
56600
56793
|
settings: TransmitSettingsSchema.optional()
|
|
56601
|
-
}), IrSendResultSchema, {
|
|
56794
|
+
}).refine((input) => input.timings === void 0 !== (input.native === void 0), { message: "send takes exactly one of timings or native" }), IrSendResultSchema, {
|
|
56795
|
+
kind: "mutation",
|
|
56796
|
+
auth: "protected"
|
|
56797
|
+
}), method(object({
|
|
56798
|
+
deviceId: number$1().int().nonnegative(),
|
|
56799
|
+
timeoutMs: number$1().int().positive().max(IR_LEARN_TIMEOUT_MAX_MS).default(IR_LEARN_TIMEOUT_DEFAULT_MS)
|
|
56800
|
+
}), IrLearnResultSchema, {
|
|
56602
56801
|
kind: "mutation",
|
|
56603
56802
|
auth: "protected"
|
|
56604
56803
|
}), method(object({ deviceId: number$1().int().nonnegative() }), IrTransmitterInfoSchema, {
|
|
@@ -66899,6 +67098,13 @@ var NcRuleInputSchema = object({
|
|
|
66899
67098
|
*/
|
|
66900
67099
|
groupingSec: number$1().int().min(5).max(60).optional(),
|
|
66901
67100
|
/**
|
|
67101
|
+
* Hold deliveries of this rule to one target and, when two or more arrive
|
|
67102
|
+
* before the window ends, send them as one summary. Absent = the kind's
|
|
67103
|
+
* default (`groupWithinSecOf`): 5 s for a system-event rule, 0 for every
|
|
67104
|
+
* other kind. `0` sends each delivery as it does today.
|
|
67105
|
+
*/
|
|
67106
|
+
groupWithinSec: number$1().int().min(0).max(300).optional(),
|
|
67107
|
+
/**
|
|
66902
67108
|
* ASK ME TO CONFIRM DETECTIONS (#243): a DETECTION notification of this rule
|
|
66903
67109
|
* carries "Correct" / "Wrong" buttons (and, where the channel has room, a
|
|
66904
67110
|
* "Wrong, it is a <class>" choice). A tap marks the track for retraining, the
|
|
@@ -67335,7 +67541,12 @@ var NcHistoryEntrySchema = object({
|
|
|
67335
67541
|
* Assistant export) must render as "no image right now", never as a
|
|
67336
67542
|
* broken link.
|
|
67337
67543
|
*/
|
|
67338
|
-
artifactIds: array(string().min(1)).optional()
|
|
67544
|
+
artifactIds: array(string().min(1)).optional(),
|
|
67545
|
+
/**
|
|
67546
|
+
* When this row was folded into a group-window summary, the outbox id of
|
|
67547
|
+
* that one notification. Absent on a row that was sent as itself.
|
|
67548
|
+
*/
|
|
67549
|
+
groupedInto: string().min(1).optional()
|
|
67339
67550
|
});
|
|
67340
67551
|
/**
|
|
67341
67552
|
* Query filter for `getHistory` (spec §4.2). Every field is a narrowing
|
|
@@ -84718,6 +84929,13 @@ Object.freeze({
|
|
|
84718
84929
|
access: "view",
|
|
84719
84930
|
role: "viewer"
|
|
84720
84931
|
},
|
|
84932
|
+
"irTransmitter.learn": {
|
|
84933
|
+
capName: "ir-transmitter",
|
|
84934
|
+
capScope: "device",
|
|
84935
|
+
addonId: null,
|
|
84936
|
+
access: "create",
|
|
84937
|
+
role: "viewer"
|
|
84938
|
+
},
|
|
84721
84939
|
"irTransmitter.send": {
|
|
84722
84940
|
capName: "ir-transmitter",
|
|
84723
84941
|
capScope: "device",
|
|
@@ -92569,6 +92787,11 @@ Object.freeze({
|
|
|
92569
92787
|
form: "single",
|
|
92570
92788
|
optional: false
|
|
92571
92789
|
}],
|
|
92790
|
+
"irTransmitter.learn": [{
|
|
92791
|
+
name: "deviceId",
|
|
92792
|
+
form: "single",
|
|
92793
|
+
optional: false
|
|
92794
|
+
}],
|
|
92572
92795
|
"irTransmitter.send": [{
|
|
92573
92796
|
name: "deviceId",
|
|
92574
92797
|
form: "single",
|
|
@@ -95795,7 +96018,7 @@ var AdminUIAddon = class extends BaseAddon {
|
|
|
95795
96018
|
capability: adminUiCapability,
|
|
95796
96019
|
provider: {
|
|
95797
96020
|
getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
|
|
95798
|
-
getVersion: async () => ({ version: "1.2.
|
|
96021
|
+
getVersion: async () => ({ version: "1.2.651" })
|
|
95799
96022
|
}
|
|
95800
96023
|
}];
|
|
95801
96024
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-admin-ui",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.651",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Admin UI — Vite frontend build and server-side addon",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
}
|
|
51
51
|
],
|
|
52
52
|
"requires": {
|
|
53
|
-
"server": ">=1.2.
|
|
53
|
+
"server": ">=1.2.848"
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{B as e,C as t,J as n,K as r,R as i,S as a,V as o,Y as s,et as c,o 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-CEyXHAdg.js";import{Bn as d,Bt as f,Er as p,Gn as m,Hi as h,Kt as g,Mi as _,Mn as v,Q as y,St as b,Yt as x,ar as S,ci as C,ct as w,jn as ee,kn as te,ot as T,ut as ne,vn as E,wi as D,zi as O}from"./player-overlays-C92tUBpz.js";import{lc as k}from"./client-DM5tcoga.js";import{t as re}from"./chevron-down-CBb-F8DT.js";import{a as A,f as j}from"./video-De6y5yax.js";import{$i as ie,Cn as ae,Gi as oe,Gr as se,Ic as ce,Ji as le,Jr as ue,Lf as M,Pf as N,Qi as P,Sn as de,Ur as fe,Wd as F,Wr as pe,Ws as I,Xi as me,Yi as L,Yr as he,Zi as R,aa as z,ca as B,cf as ge,cr as V,da as _e,ea as H,ef as U,ha as ve,hr as W,ia as ye,la as be,lr as G,ma as xe,na as Se,oa as Ce,or as K,pa as we,pt as Te,qi as Ee,qr as De,ra as Oe,rt as ke,sr as Ae,ua as je}from"./src-wYH5IrPO.js";import{t as q}from"./useTranslation-BJr-n0es.js";import"./mount-DdNgdYpo.js";import{Kr as Me,Qr as Ne,Xr as Pe}from"./index-Wmx2JgTc.js";import{t as Fe}from"./AdminPage-a5x3JamG.js";import{i as Ie,r as Le,t as Re}from"./addon-kind-filter-CEGKkC1O.js";import{n as J,t as ze}from"./framework-packages-B0ugw-Ay.js";import{t as Y}from"./NodeAddonsSettingsPanel-CT6b4R4c.js";import{n as X,r as Be,t as Ve}from"./useNodeUrlSelection-DB-QVsC2.js";function He(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}}c();var Ue={queued:{icon:D,bg:`bg-muted text-foreground-subtle`,labelKey:`addons.addonRowBadge.queued`},updating:{icon:p,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:h,bg:`bg-success/10 text-success`,labelKey:`addons.addonRowBadge.done`},failed:{icon:A,bg:`bg-danger/10 text-danger`,labelKey:`addons.addonRowBadge.failed`}};function Z({item:e}){let{t:n}=q(),r=Ue[e.status],i=r.icon;return t(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${r.bg}`,title:e.error,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey)]})}var Q=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),We=new Set([`done`,`failed`,`skipped`]);function Ge(e){return!We.has(e.phase)&&!Q.has(e.jobState)}function Ke(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Q.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 qe(){let{data:e}=Oe({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=M(k.AddonsJobProgress,e=>e.job.jobId);return r(()=>{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 Ke([...n.values()],Date.now())},[e,t])}var Je={queued:{icon:D,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.queued`},fetching:{icon:p,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.fetching`,spin:!0},staged:{icon:p,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.staged`,spin:!0},validating:{icon:p,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.validating`,spin:!0},applying:{icon:p,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.applying`,spin:!0},restarting:{icon:p,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,labelKey:`addons.jobProgress.restarting`,spin:!0},applied:{icon:p,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.finalizing`,spin:!0},done:{icon:h,cls:`bg-success/10 text-success`,labelKey:`addons.jobProgress.updated`},failed:{icon:A,cls:`bg-danger/10 text-danger`,labelKey:`addons.jobProgress.failed`},skipped:{icon:E,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.skipped`}};function Ye({progress:e}){let{t:n}=q(),r=Je[e.phase],i=r.icon,o=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return t(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${r.cls}`,title:o,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey),t(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function Xe(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 Ze(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function Qe(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(Ze)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
|
|
2
|
-
`)}function $e(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 et={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function tt(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)}: ${et[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 nt={},rt=3e4,it=`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 at({packageName:e,displayName:n,selectedNode:r,hideNodeAction:i,disabled:o}){let{t:s}=q(),c=l(),u=w(),d=T(),f=Se(nt,{staleTime:rt}),p=f.data?.installations??[],m=(f.data?.unreachable??[]).map(e=>e.nodeId),h=Xe(p,e),g=e=>h.find(t=>t.nodeId===e)?.nodeName??(e===r.id?r.name:e),_=xe({onSettled:()=>{c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addonPages`]]}),c.invalidateQueries({queryKey:[[`capabilities`]]}),c.invalidateQueries({queryKey:[[`nodes`]]})}}),v=async e=>{await d({title:e.success?s(`addons.addonUninstallControls.uninstalled`,`{{displayName}} uninstalled`,{displayName:n}):s(`addons.addonUninstallControls.notEveryNodeWasCleaned`,`{{displayName}}: not every node was cleaned`,{displayName:n}),message:tt(e,g),variant:e.success?`default`:`danger`})},y=async t=>{try{await v(await _.mutateAsync({packageName:e,...t}))}catch(e){await d({title:s(`addons.addonUninstallControls.uninstallFailed`,`Uninstall {{displayName}} failed`,{displayName:n}),message:e instanceof Error?e.message:String(e),variant:`danger`})}},b=async()=>{let e=h.filter(e=>e.nodeId!==r.id);await u({title:s(`addons.addonUninstallControls.uninstallFrom`,`Uninstall {{displayName}} from {{name}}?`,{displayName:n,name:r.name}),message:$e(n,r.name,e),confirmLabel:s(`addons.addonUninstallControls.uninstall`,`Uninstall`),variant:`danger`})&&await y(r.isHub?{}:{nodeId:r.id})},S=async()=>{let t=(await f.refetch()).data;if(t===void 0){await d({title:s(`addons.addonUninstallControls.cannotListTheNodes`,`Cannot list the nodes`),message:s(`addons.addonUninstallControls.theHubDidNotAnswer`,`The hub did not answer which nodes have this package — nothing was removed.`),variant:`danger`});return}let r=Xe(t.installations,e);await u({title:s(`addons.addonUninstallControls.uninstallEverywhere`,`Uninstall {{displayName}} everywhere?`,{displayName:n}),message:Qe(n,r,t.unreachable.map(e=>e.nodeId)),confirmLabel:s(`addons.addonUninstallControls.uninstallFromNodeS`,`Uninstall from {{length}} node(s)`,{length:r.length}),variant:`danger`})&&await y({everywhere:!0})},C=_.isPending||o===!0;return t(`div`,{className:`flex items-center gap-1.5`,children:[i!==!0&&t(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),b()},disabled:C,className:it,title:s(`addons.addonUninstallControls.uninstallFrom2`,`Uninstall from {{name}}`,{name:r.name}),children:[a(x,{className:`h-3 w-3`}),_.isPending?s(`addons.addonUninstallControls.removing`,`Removing...`):s(`addons.addonUninstallControls.uninstall`,`Uninstall`)]}),(h.length>1||i===!0||m.length>0)&&t(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),S()},disabled:C,className:it,title:s(`addons.addonUninstallControls.uninstallFromEveryNodeThat`,`Uninstall from every node that has it`),children:[a(j,{className:`h-3 w-3`}),h.length>0?s(`addons.uninstallControls.everywhereCount`,{count:h.length}):s(`addons.uninstallControls.everywhere`)]})]})}function ot(e){return typeof e.deprecated==`string`&&e.deprecated.length>0}function st(e,t){return t?e:e.filter(e=>e.distTags.includes(`latest`)||!ot(e))}function ct(e){return e.length-st(e,!1).length}c();function lt({packageName:e,currentVersion:n,installSource:r,onInstall:i,onClose:o,onSelect:c,selectedVersion:l}){let{t:d}=q(),m=r===`upload`||r===`local`,[g,_]=s(!1),{data:v,isLoading:y,isError:x}=P({name:e}),S=v?st(v,g):[],w=v?ct(v):0;return t(`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:[t(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[a(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:d(`addons.versionPicker.versions`,`Versions`)}),a(U,{variant:`unstyled`,type:`button`,onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:a(b,{className:`h-3 w-3`})})]}),m&&t(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[a(f,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),t(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[a(`span`,{className:`font-semibold`,children:d(`addons.versionPicker.inPlace`,{kind:r===`upload`?d(`addons.versionPicker.uploadedCopy`,`Uploaded copy`):d(`addons.versionPicker.localCopy`,`Local copy`)})}),` `,a(Me,{i18nKey:`addons.versionPicker.reinstall`,values:{version:n},components:{mono:a(`span`,{className:`font-mono`})}})]})]}),y&&t(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[a(p,{className:`h-3.5 w-3.5 animate-spin`}),d(`addons.versionPicker.loadingVersions`,`Loading versions...`)]}),x&&a(`div`,{className:`px-3 py-4 text-center text-[10px] text-danger`,children:d(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),S.length>0&&a(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:S.map(e=>{let r=e.version===n,o=c!==void 0&&e.version===l,s=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),f=t(u,{children:[a(`span`,{className:`font-mono flex-1 text-left ${r?`text-primary font-semibold`:s?`text-amber-400`:`text-foreground`}`,children:e.version}),r&&a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:d(`common.current`)}),e.distTags.map(e=>a(`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)),ot(e)&&a(`span`,{className:`text-[9px] text-red-400 line-through`,children:d(`common.deprecated`)}),a(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return c?t(U,{variant:`unstyled`,type:`button`,"aria-label":d(`addons.versionPicker.select`,`Select {{version}}`,{version:e.version}),onClick:()=>c(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${o?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,o?a(h,{className:`h-3 w-3 text-primary shrink-0`}):a(`span`,{className:`w-3 shrink-0`})]},e.version):t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${r?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,a(U,{variant:`unstyled`,type:`button`,onClick:()=>i(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:r?d(`addons.versionPicker.reInstallFromNpm`,`Re-install {{version}} from npm`,{version:e.version}):d(`addons.versionPicker.install`,`Install {{version}}`,{version:e.version}),children:a(C,{className:`h-3 w-3`})})]},e.version)})}),!y&&!x&&v&&v.length===0&&a(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:d(`addons.versionPicker.noVersionsFound`,`No versions found`)}),w>0&&a(U,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto w-full justify-start rounded-none border-t border-border px-3 py-2 text-left text-[10px] font-normal text-foreground-subtle`,onClick:()=>_(e=>!e),children:g?d(`addons.versionPicker.hideOlder`,`Hide older versions`):d(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:w})})]})}c();var ut=`device-export`;function dt(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===ut)}function ft(e){return e!==`local`&&e!==`upload`}function pt({isBundle:e,installSource:n,addonId:r,iconPath:i,color:o}){let[c,l]=s(!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`,p=r&&i?y(`/api/addon-assets/${r}/${i}`):null,h=!!p&&!c;return t(`div`,{className:`relative flex-shrink-0`,children:[a(`div`,{className:`h-8 w-8 rounded-md flex items-center justify-center ${u?``:d}`,style:u,children:h?a(`img`,{src:p,alt:r,className:`h-4 w-4`,onError:()=>l(!0)}):a(e?S:m,{className:`h-3.5 w-3.5`})}),n===`local`&&a(`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`}),ft(n)&&a(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:a(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:a(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),n===`upload`&&a(`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:a(f,{className:`h-2.5 w-2.5 text-white`})})]})}function mt({version:e,availableUpdate:n,selectedVersion:r,isUpdating:i,installSource:o,disabled:s,onUpdate:c,onOpenPicker:l,children:u}){let{t:d}=q();if(i)return t(`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:[a(p,{className:`h-3 w-3 animate-spin`}),d(`addons.addonCard.updating`,`Updating…`)]});if(n){let i=r??n;return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[c&&t(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:s,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:d(`addons.addonCard.updateTo`,`Update to {{target}}`,{target:i}),children:[a(C,{className:`h-3 w-3`}),d(`addons.addonCard.update`,`Update`)]}),t(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,"aria-label":d(`addons.addonCard.selectVersionToInstall`,`Select version to install`),title:d(`addons.addonCard.installedUpdateAvailableSelectedTap`,`Installed {{version}} — update available. Selected {{target}}; tap to choose another version.`,{version:e,target:i}),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:[a(`span`,{className:`font-normal opacity-70`,children:e}),a(`span`,{className:`font-normal opacity-70`,children:`→`}),i,a(re,{className:`h-3 w-3`})]}),u]})}return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[t(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,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`,o===`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:d(`addons.addonCard.versionTapToViewAll`,`Version {{version}} — tap to view all versions`,{version:e}),children:[e,a(re,{className:`h-3 w-3 opacity-50`})]}),u]})}function ht({addonId:e}){let t=l(),{data:n=`inherit`}=le({addonId:e}),r=je({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return a(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>a(U,{variant:`unstyled`,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 gt={id:`hub`,name:`Hub`,isHub:!0};function _t({addon:e,clusterStatus:n,hideVersion:r,availableUpdate:i,blockedUpdate:c,onUpdateServer:f,onUpdate:p,isUpdating:m,jobProgress:h,bundle:g,bulkItem:_,disabledByBulk:y,isSystem:x,selectedNode:C}){let{t:w}=q(),[ee,T]=s(!1),[ne,E]=s(!1),[D,k]=s(null);o(()=>{k(null)},[i]);let j=D??i,[oe,ce]=s(!1),[le,M]=s(!1),[N,P]=s(`logs`),I=l(),me=Pe(),{manifest:L}=e,R=!g&&!L.protected&&L.removable!==!1,z=!!g,ge=g?.displayName??L.name,V=g?.packageName??L.packageName,_e=g?.version??L.packageVersion??L.version,H=g?.installSource??e.installSource,ve=g?g.bundle?.description??g.addons[0]?.manifest.description:L.description,W=Ce({onSuccess:()=>{I.invalidateQueries({queryKey:[[`addons`]]})}}),ye=ie({onSuccess:()=>{I.invalidateQueries({queryKey:[[`addons`]]}),I.invalidateQueries({queryKey:[[`addonPages`]]}),I.invalidateQueries({queryKey:[[`capabilities`]]}),I.invalidateQueries({queryKey:[[`integrations`]]})}}),be=B({onSuccess:()=>{I.invalidateQueries({queryKey:[[`addons`]]}),I.invalidateQueries({queryKey:[[`alerts`]]})}}),G=e.health,xe=G?.phase===`failed`&&!G.inGracePeriod,Se=xe&&G?.nextRetryAt&&!G.retrying,K=He(e.process);return t(`div`,{className:`rounded-md border bg-surface overflow-hidden ${xe?`border-red-500/50`:`border-border`}`,children:[xe&&G&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(A,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:w(`addons.addonCard.failedToLoad`,{attempt:G.retryCount})}),a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:G.lastError?.message??w(`addons.addonCard.unknownError`,`Unknown error`)}),Se&&G.nextRetryAt&&a(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:w(`addons.addonCard.autoRetryAt`,{time:new Date(G.nextRetryAt).toLocaleTimeString()})})]}),t(U,{variant:`unstyled`,type:`button`,disabled:be.isPending||G.retrying,onClick:e=>{e.stopPropagation(),be.mutate({packageName:V})},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:w(`addons.addonCard.resetRetryCounterAndForce`,`Reset retry counter and force immediate reload`),children:[a(d,{className:`h-3 w-3 ${be.isPending||G.retrying?`animate-spin`:``}`}),w(`addons.addonCard.retryNow`,`Retry now`)]})]}),K!==null&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(A,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:w(`addons.addonCard.processProblem.${K.kind}`)}),K.reason!==void 0&&a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:K.reason})]})]}),t(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[a(pt,{isBundle:z||!!L.components&&L.components.length>1,installSource:H,addonId:z?g.addons[0]?.manifest.id:L.id,iconPath:z?g.bundle?.icon??g.addons[0]?.manifest.icon:L.icon,color:z?g.addons[0]?.manifest.color:L.color}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-start justify-between gap-2`,children:[a(`span`,{className:`text-xs font-semibold text-foreground truncate min-w-0`,children:ge}),!r&&a(mt,{version:_e,availableUpdate:i,...j===void 0?{}:{selectedVersion:j},isUpdating:m,installSource:H,disabled:y,...p&&j!==void 0?{onUpdate:()=>p(j)}:{},onOpenPicker:()=>E(e=>!e),children:ne&&a(lt,{packageName:V,currentVersion:_e,...H?{installSource:H}:{},...i!==void 0&&j!==void 0?{selectedVersion:j,onSelect:e=>{k(e),E(!1)}}:{},onInstall:e=>{E(!1),ye.mutate({packageName:V,version:e})},onClose:()=>E(!1)})})]}),t(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[V!==ge&&a(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:V}),z&&t(`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:[a(S,{className:`h-3 w-3`}),g.addons.length]}),x&&t(`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:w(`addons.addonCard.systemPackageUpdatingRestartsThe`,`System package — updating restarts the hub`),children:[a(d,{className:`h-3 w-3`}),w(`addons.addonCard.system`,`System`)]}),_!=null&&a(Z,{item:_}),c!==void 0&&a(F,{variant:`warning`,title:w(`addons.addonCard.updateHeldTitle`,{defaultValue:`{{latest}} is held until the server is {{required}} or newer`,latest:c.latestVersion,required:c.requiredServer}),children:w(`addons.addonCard.requiresServer`,{defaultValue:`requires server ≥ {{version}}`,version:c.requiredServer})}),c!==void 0&&f!==void 0&&a(U,{type:`button`,size:`sm`,variant:`secondary`,onClick:f,children:w(`clusterUpdate.updateServer`,`Update server`)}),h!=null&&a(Ye,{progress:h})]}),ve&&a(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:ve}),!z&&e.process&&t(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[a(`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`?w(`addons.addonCard.forked`):w(`addons.addonCard.inProcess`)}),e.process.pid!=null&&t(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),a(`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`:K===null?`bg-gray-500/15 text-gray-400`:`bg-red-500/15 text-red-400`}`,children:e.process.state})]})]})]}),!z&&t(`div`,{className:`flex items-center gap-1 px-3 py-1 border-t border-border/50 bg-surface-hover/20`,children:[t(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),W.mutate({addonId:L.id})},disabled:W.isPending||y,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:[a(d,{className:`h-3 w-3 ${W.isPending?`animate-spin`:``}`}),w(`addons.addonCard.restart`,`Restart`)]}),t(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),ce(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${oe?`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:[a(v,{className:`h-3 w-3`}),w(`addons.addonCard.logs`,`Logs`)]}),!z&&t(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),M(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${le?`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:[a(te,{className:`h-3 w-3`}),w(`addons.addonCard.settings`,`Settings`)]}),a(`div`,{className:`flex-1`}),R&&a(at,{packageName:L.packageName,displayName:L.name,selectedNode:C??gt,disabled:y})]}),n&&n.nodes.length>1&&!z&&t(`div`,{className:`border-t border-border px-3 py-1.5 bg-muted/10`,children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:w(`addons.addonCard.clusterDeployment`,`Cluster Deployment`)}),a(`div`,{className:`space-y-1`,children:n.nodes.map(e=>t(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[a(`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`}`}),a(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),a(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:w(`addons.addonCard.outdated`)}),e.status===`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:w(`common.offline`)}),e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] text-success`,children:w(`common.synced`)})]},e.nodeId))})]}),oe&&!z&&t(`div`,{className:`border-t border-border`,children:[t(`div`,{className:`flex items-center px-3 py-0.5 bg-surface-hover/20 border-b border-border/50`,children:[t(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[a(U,{variant:`unstyled`,type:`button`,onClick:()=>P(`logs`),className:`px-2 py-0.5 transition-colors ${N===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:w(`addons.addonCard.logs`,`Logs`)}),a(U,{variant:`unstyled`,type:`button`,onClick:()=>P(`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:w(`addons.addonCard.events`,`Events`)})]}),a(`div`,{className:`flex-1`}),a(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),ce(!1)},className:`text-foreground-subtle hover:text-foreground`,children:a(b,{className:`h-3.5 w-3.5`})})]}),N===`logs`&&a(ae,{addonId:L.id,maxHeight:`max-h-64`,showFilters:!1}),N===`events`&&a(de,{addonId:L.id,category:`addon.*`,maxHeight:`max-h-64`})]}),z&&t(u,{children:[a(U,{variant:`unstyled`,type:`button`,onClick:()=>T(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:a(ee?O:re,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),ee&&a(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:g.addons.map(e=>a(_t,{addon:e,hideVersion:!0},e.manifest.id))})]}),le&&!z&&a(fe,{open:!0,onOpenChange:e=>!e&&M(!1),children:t(se,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(ue,{children:t(he,{className:`flex items-center gap-2`,children:[a(te,{className:`h-4 w-4 text-primary`}),w(`addons.addonCard.settingsTitle`,{name:ge})]})}),t(pe,{className:`space-y-4`,children:[a(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:w(`addons.addonCard.clusterWideSettingsOneValue`,`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`)}),a(Y,{nodeId:null,addonIds:[L.id],level:`global`,fieldScope:`cluster`,emptyMessage:w(`addons.addonCard.thisAddonExposesNoCluster`,`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`)}),dt(L)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.deviceExport`,`Device export`)}),a(Te,{addonId:L.id,onOpenDevice:e=>me(`/devices/${e}`)})]}),ft(H)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.autoUpdate`,`Auto-Update`)}),a(ht,{addonId:L.id})]}),L.components&&L.components.length>0&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.components`,{count:L.components.length})}),a(`div`,{className:`flex flex-wrap gap-1`,children:L.components.map(e=>a(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]})]}),a(De,{children:a(U,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>M(!1),children:w(`common.close`,`Close`)})})]})})]})}c();var vt=`.tgz,.tar.gz,.zip`;function yt({onUploadSuccess:e}){let{t:r}=q(),[o,c]=s(!1),l=n(null),d=i(async t=>{c(!0);let n=new FormData;n.append(`file`,t);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(y(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:n})).json()).success&&e()}finally{c(!1)}},[e]);return t(u,{children:[a(W,{ref:l,accept:vt,onChange:i(e=>{let t=e.target.files?.[0];t&&d(t),e.target.value=``},[d]),className:`hidden`}),t(U,{variant:`unstyled`,type:`button`,onClick:()=>l.current?.click(),disabled:o,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:[o?a(p,{className:`w-3.5 h-3.5 animate-spin`}):a(f,{className:`w-3.5 h-3.5`}),o?r(`addons.addonUploadZone.uploading`,`Uploading...`):r(`addons.addonUploadZone.upload`,`Upload`)]})]})}var bt=/```[^\n]*\n([\s\S]*?)```/g;function xt(e){let t=[],n=0;for(let r of e.matchAll(bt)){let i=r.index??0;i>n&&t.push({kind:`text`,body:e.slice(n,i)}),t.push({kind:`code`,body:r[1]??``}),n=i+r[0].length}return n<e.length&&t.push({kind:`text`,body:e.slice(n)}),t}function St(e){let t=e.trim();return t.startsWith(`https://`)||t.startsWith(`http://`)?t:null}function Ct(e,t){let n=[],r=/(\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g,i=0,o=0;for(let s of e.matchAll(r)){let r=s.index??0;r>i&&n.push(e.slice(i,r));let c=s[0],l=`${t}-${o}`;if(o+=1,c.startsWith(`**`))n.push(a(`strong`,{children:c.slice(2,-2)},l));else if(c.startsWith("`"))n.push(a(`code`,{className:`font-mono text-[0.9em]`,children:c.slice(1,-1)},l));else{let e=/^\[([^\]]+)\]\(([^)]+)\)$/.exec(c),t=e?.[1]??c,r=e?St(e[2]??``):null;n.push(r?a(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:`text-primary underline`,children:t},l):a(`span`,{children:t},l))}i=r+c.length}return i<e.length&&n.push(e.slice(i)),n}function wt(e,t){let n=e.split(`
|
|
5
|
-
`),r=[],i=[],o=[],s=0,c=()=>{if(i.length===0)return;let e=i.join(` `).trim();i=[],e.length!==0&&(r.push(a(`p`,{className:`mb-2 last:mb-0`,children:Ct(e,`${t}-p-${s}`)},`${t}-p-${s}`)),s+=1)},l=()=>{if(o.length===0)return;let e=o;o=[],r.push(a(`ul`,{className:`mb-2 list-disc pl-4 last:mb-0`,children:e.map((e,n)=>a(`li`,{children:Ct(e,`${t}-li-${s}-${n}`)},`${t}-li-${s}-${n}`))},`${t}-ul-${s}`)),s+=1};for(let e of n){let n=/^(#{1,3})\s+(.*)$/.exec(e),u=/^\s*[-*]\s+(.*)$/.exec(e);if(n){c(),l();let e=n[1]?.length??1,i=Ct(n[2]??``,`${t}-h-${s}`),o=e===1?`text-sm font-semibold mb-2`:`text-xs font-semibold mb-1.5 mt-2`;r.push(a(e===1?`h3`:`h4`,{className:o,children:i},`${t}-h-${s}`)),s+=1;continue}if(u){c(),o=[...o,u[1]??``];continue}if(e.trim().length===0){c(),l();continue}l(),i=[...i,e.trim()]}return c(),l(),r}function Tt({markdown:e}){return a(`div`,{className:`text-xs text-foreground leading-relaxed`,children:xt(e).map((e,t)=>e.kind===`code`?a(`pre`,{className:`mb-2 overflow-auto rounded-md bg-surface-hover p-2 font-mono text-[10px] last:mb-0`,children:e.body.replace(/\n$/,``)},`code-${t}`):a(`div`,{children:wt(e.body,`b${t}`)},`text-${t}`))})}c();function Et(e){return e.replace(/^@camstack\/(addon-)?/,``)}function Dt(e,t,n){let r=st(e,n);return r.some(e=>e.version===t)?r:[{version:t,distTags:[],deprecated:void 0},...r]}function Ot({pending:e,failed:n,body:r,missing:i}){let{t:o}=q();return e?t(`div`,{className:`flex items-center gap-2 py-6 text-xs text-foreground-subtle`,children:[a(p,{className:`h-3.5 w-3.5 animate-spin`}),o(`addons.installDialog.loadingDocument`,`Loading…`)]}):n||r===void 0?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.couldNotLoadDocument`,`Could not load this file from the registry.`)}):r.status===`ok`&&r.markdown!==void 0?a(Tt,{markdown:r.markdown}):r.status===`error`?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.documentError`,`Could not load this file. {{message}}`,{message:r.message??``})}):a(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:i})}function kt({target:e,installing:n,installError:r,onClose:i,onInstall:o}){let{t:c}=q(),[l,u]=s(e.version),[d,f]=s(!1),m=P({name:e.name}),h=R({name:e.name,version:l}),g=m.data??[],_=ct(g),v=Dt(g,l,d),y=h.data;return a(fe,{open:!0,onOpenChange:e=>!e&&i(),children:t(se,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(ue,{children:a(he,{children:c(`addons.installDialog.title`,`Install {{name}}`,{name:Et(e.name)})})}),t(pe,{className:`space-y-3`,children:[a(`p`,{className:`font-mono text-[10px] text-foreground-subtle`,children:e.name}),e.description.length>0&&a(`p`,{className:`text-xs text-foreground`,children:e.description}),t(`div`,{className:`space-y-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:c(`addons.installDialog.version`,`Version`)}),a(ne,{"aria-label":c(`addons.installDialog.version`,`Version`),value:l,options:v.map(e=>({value:e.version,label:ot(e)?c(`addons.installDialog.deprecatedVersion`,`{{version}} (deprecated)`,{version:e.version}):e.version})),onChange:e=>u(e.target.value)}),m.isError&&a(`p`,{className:`text-[10px] text-danger`,children:c(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),_>0&&a(U,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto justify-start px-0 text-[10px] font-normal text-foreground-subtle underline`,onClick:()=>f(e=>!e),children:d?c(`addons.versionPicker.hideOlder`,`Hide older versions`):c(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:_})})]}),t(K,{defaultValue:`readme`,children:[t(V,{children:[a(G,{value:`readme`,children:c(`addons.installDialog.readme`,`README`)}),a(G,{value:`changelog`,children:c(`addons.installDialog.changelog`,`CHANGELOG`)})]}),a(Ae,{value:`readme`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(Ot,{pending:h.isPending,failed:h.isError,body:y?.readme,missing:c(`addons.installDialog.missingReadme`,`This package has no README.`)})})}),a(Ae,{value:`changelog`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(Ot,{pending:h.isPending,failed:h.isError,body:y?.changelog,missing:c(`addons.installDialog.missingChangelog`,`This package has no CHANGELOG.`)})})})]}),r!=null&&r.length>0&&a(`p`,{className:`text-xs text-danger`,children:r})]}),t(De,{children:[a(U,{type:`button`,variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),a(U,{type:`button`,size:`sm`,disabled:n||l.length===0,onClick:()=>o(e.name,l),children:n?a(p,{className:`h-3.5 w-3.5 animate-spin`}):c(`addons.installDialog.install`,`Install`)})]})]})})}function At(e,t){let n=new Map;for(let r of e){if(r.isHub||r.onHub||J(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 jt({selectedNode:e}){let{t:n}=q(),{data:r}=Se(nt,{staleTime:rt});if(r===void 0)return null;let i=At(r.installations,e),o=r.unreachable.filter(t=>e.isHub||t.nodeId===e.id);return i.length===0&&o.length===0?null:t(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2.5 space-y-2`,children:[t(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-foreground`,children:[a(g,{className:`h-3.5 w-3.5 text-warning`}),e.isHub?n(`addons.nodeOnlyPackagesPanel.installedOnAgentsButNot`,`Installed on agents but not on the hub`):n(`addons.nodeOnlyPackagesPanel.installedOnButNotOn`,`Installed on {{name}} but not on the hub`,{name:e.name})]}),o.length>0&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n(`addons.nodeOnlyPackagesPanel.unreachable`,{nodes:o.map(e=>e.nodeId).join(`, `)})}),i.map(n=>t(`div`,{className:`flex items-center justify-between gap-3 flex-wrap rounded-md border border-border bg-surface px-3 py-2`,children:[t(`div`,{className:`min-w-0`,children:[a(`div`,{className:`text-xs font-mono text-foreground break-all`,children:n.packageName}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n.rows.map(e=>`${e.nodeName}${e.version===null?``:` ${e.version}`}${e.isOnline?``:` (offline)`}`).join(` · `)})]}),a(at,{packageName:n.packageName,displayName:n.packageName,selectedNode:e,hideNodeAction:e.isHub})]},n.packageName))]})}function Mt({addon:e,installing:n,onInstall:r}){let{t:i}=q();return t(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[a(`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()}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[a(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),t(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),a(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&a(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?a(F,{variant:`success`,icon:a(h,{className:`h-3 w-3`}),children:e.installedVersion??i(`system.capabilityCatalog.installed`,`Installed`)}):t(U,{size:`sm`,onClick:()=>r(e),disabled:n,className:`shrink-0`,children:[n?a(p,{className:`h-3 w-3 animate-spin`}):a(C,{className:`h-3 w-3`}),i(`system.capabilityCatalog.install`,`Install`)]})]})}function Nt({capability:e,installing:n,onInstall:r}){let{t:i}=q(),{data:o,isPending:s,isError:c}=be({capability:e}),l;if(c)l=a(`div`,{className:`px-3 py-2 text-xs text-danger`,children:i(`system.capabilityCatalog.couldNotSearchTheNpm`,`Could not search the npm catalog right now. Try again in a moment.`)});else if(s||o===void 0)l=t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground-subtle`,children:[a(p,{className:`h-3 w-3 animate-spin`}),i(`system.capabilityCatalog.searchingTheNpmCatalog`,`Searching the npm catalog…`)]});else{let t=o.filter(e=>!e.installed);l=t.length===0?a(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:o.length===0?i(`system.capabilityCatalog.noPublishedAddonDeclaresThe`,`No published addon declares the "{{capability}}" capability.`,{capability:e}):i(`system.capabilityCatalog.everyPublishedAddonThatDeclares`,`Every published addon that declares "{{capability}}" is already installed.`,{capability:e})}):a(`div`,{className:`divide-y divide-border`,children:t.map(e=>a(Mt,{addon:e,installing:n,onInstall:r},e.name))})}return t(`section`,{className:`rounded-md border border-border bg-surface overflow-hidden`,"aria-label":i(`system.capabilityCatalog.availableToInstall`,`Available to install`),children:[a(`h2`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:i(`system.capabilityCatalog.availableToInstall`,`Available to install`)}),l]})}c();function Pt(e){return e===`npm`||e===`dev`?e:null}var Ft=`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`,It=`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,Lt=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],Rt={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function zt(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function Bt(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 Ht(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 Ut({addons:c,clusterStatus:u,selectedNode:f,onRefresh:m,listPhase:h}){let{t:g}=q(),v=l(),[y,b]=s(``),[x,S]=s(!1),te=e(y),[T,E]=s(!1),D=n(null);o(()=>{if(!T)return;let e=e=>{D.current&&!D.current.contains(e.target)&&E(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[T]);let{data:O}=ye({nodeId:f.id}),k=r(()=>{let e=new Map;for(let t of O??[])t.blockedBy===void 0&&e.set(t.name,t.latestVersion);return e},[O]),re=r(()=>{let e=new Map;for(let t of O??[]){let n=t.blockedBy?.find(e=>e.kind===`server-too-old`);n!==void 0&&e.set(t.name,{latestVersion:t.latestVersion,requiredServer:n.required})}return e},[O]),A=r(()=>(O??[]).filter(e=>!e.isSystem&&e.blockedBy===void 0).length,[O]),[j,ae]=s(()=>new Set),[se,ce]=s(()=>new Map),le=i(e=>{ae(t=>new Set(t).add(e))},[]),ue=i(e=>{ae(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),M=i((e,t)=>{ce(n=>new Map(n).set(e,t))},[]),N=i(e=>{ce(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),P=ve({onMutate:e=>{le(e.name),N(e.name)},onSuccess:(e,t)=>{ue(t.name);let n=e;if(n&&n.success===!1){M(t.name,n.error??`Update failed (no error message returned by server)`);return}v.invalidateQueries({queryKey:[[`addons`]]}),v.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{ue(t.name),M(t.name,e instanceof Error?e.message:String(e))}}),de=qe(),fe=n(new Set);o(()=>{let e=new Set;for(let[t,n]of de)Ge(n)&&e.add(t);let t=[...fe.current].some(t=>!e.has(t));fe.current=e,t&&(v.invalidateQueries({queryKey:[[`addons`]]}),v.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[de,v]);let{data:F}=L(void 0),pe=oe({onSuccess:()=>{v.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),he=_e({onSuccess:()=>{v.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:R,isFetching:z}=be({query:te||void 0},{enabled:T}),B=we(),{data:V}=me(void 0),H=V?.requestedAt,[W,G]=s(null),[xe,Se]=s(!1);o(()=>{if(V?.kind===`framework-bulk-update`&&V.requestedAt!==W){G(V.requestedAt),Se(!0);let e=window.setTimeout(()=>Se(!1),6e3);return()=>window.clearTimeout(e)}},[H,W,V]),w();let Ce=i(async()=>{let e=(O??[]).filter(e=>!e.isSystem&&e.blockedBy===void 0);if(e.length!==0){if(!f.isHub){for(let t of e)await P.mutateAsync({name:t.name,version:t.latestVersion,nodeId:f.id});return}await B.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[f.id]})}},[O,f.id,f.isHub,B,P]),[K,Te]=s(null),[Ee,De]=s(null),Oe=e=>{De(null),Te(e)},ke=ie({onSuccess:()=>{Te(null),De(null),v.invalidateQueries({queryKey:[[`addons`]]}),v.invalidateQueries({queryKey:[[`addonPages`]]}),v.invalidateQueries({queryKey:[[`capabilities`]]}),v.invalidateQueries({queryKey:[[`integrations`]]})},onError:e=>{De(e instanceof Error?e.message:`Install failed`)}}),[Ae,je]=s(`type`),[Me,Pe]=s(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),Fe=e=>{Pe(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[J,Y]=Ne(),X=J.get(`capability`),Ve=J.get(`updatable`)===`1`,Ue=J.get(`error`)===`1`,Z=Pt(J.get(`source`)),Q=Ie(J.get(Re))===`integration`,{data:We}=I(void 0,{enabled:Q}),Ke=r(()=>We===void 0?null:new Set(We.map(e=>e.addonId)),[We]),Je=i(e=>{let t=new URLSearchParams(J);e?t.set(Re,`integration`):t.delete(Re),Y(t,{replace:!0})},[J,Y]),Ye=i(e=>{let t=new URLSearchParams(J);e?t.set(`updatable`,`1`):t.delete(`updatable`),Y(t,{replace:!0})},[J,Y]),Xe=i(e=>{let t=new URLSearchParams(J);e?t.set(`error`,`1`):t.delete(`error`),Y(t,{replace:!0})},[J,Y]),Ze=i(e=>{let t=new URLSearchParams(J);e===null?t.delete(`source`):t.set(`source`,e),Y(t,{replace:!0})},[J,Y]),Qe=r(()=>c.filter(e=>He(e.process)!==null).length,[c]),$e=r(()=>{let e=c.filter(e=>!ze(e.manifest.packageName));return f.isHub||(e=e.filter(e=>zt(e.placement,f.isHub))),X&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===X))),Q&&(e=[...Le(e,Ke)]),Ve&&(e=e.filter(e=>{let t=e.manifest.packageName;return t!==void 0&&k.has(t)})),Z!==null&&(e=e.filter(e=>Bt(e.installSource)===Z)),Ue&&(e=e.filter(e=>He(e.process)!==null)),e},[c,f.isHub,X,Ve,Z,Ue,Q,Ke,k]),et=()=>{let e=new URLSearchParams(J);e.delete(`capability`),Y(e,{replace:!0})},tt=Me===`flat`?$e:Ht($e),nt=r(()=>{let e=[...tt];switch(Ae){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},[tt,Ae]);return t(`div`,{className:`space-y-3`,children:[a(Be,{open:x,onOpenChange:S}),[...se.entries()].map(([e,n])=>a(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2.5 py-1.5 text-[11px]`,children:t(`div`,{className:`flex items-start justify-between gap-3`,children:[t(`div`,{className:`space-y-0.5`,children:[a(`div`,{className:`font-medium text-danger`,children:g(`systemPage.addons.updateFailed`,{name:e})}),a(`div`,{className:`text-foreground-subtle font-mono`,children:n})]}),a(U,{variant:`unstyled`,type:`button`,onClick:()=>N(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:g(`common.dismiss`)})]})},e)),t(`div`,{className:`flex items-center gap-x-2 gap-y-1.5 flex-wrap`,children:[t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:g(`admin.system.addons.sort`,`Sort:`)}),t(ne,{wrapperClassName:`inline-block w-auto`,value:Ae,onChange:e=>je(e.target.value),children:[a(`option`,{value:`type`,children:g(`admin.system.addons.bundlesFirst`,`Bundles first`)}),a(`option`,{value:`name`,children:g(`admin.system.addons.name`,`Name`)}),a(`option`,{value:`source`,children:g(`admin.system.addons.installSource`,`Install source`)})]})]}),t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:g(`admin.system.addons.view`,`View:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>a(U,{variant:`unstyled`,type:`button`,onClick:()=>Fe(e),className:`px-2 py-1 transition-colors capitalize ${Me===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?g(`admin.system.addons.groupMultiAddonPackagesInto`,`Group multi-addon packages into a bundle card`):g(`admin.system.addons.showEveryAddonAsIts`,`Show every addon as its own card`),children:e},e))})]}),f.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(d,{className:`h-3 w-3 text-foreground-subtle`}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:g(`admin.system.addons.autoUpdate`,`Auto-Update:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>a(U,{variant:`unstyled`,type:`button`,onClick:()=>pe.mutate({channel:e}),disabled:pe.isPending,className:`px-2 py-1 transition-colors capitalize ${F?.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&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:g(`admin.system.addons.checkEvery`,`Check every:`)}),a(ne,{wrapperClassName:`inline-block w-auto`,className:`font-medium text-foreground-subtle`,value:F?.updateCheckIntervalSeconds??21600,disabled:he.isPending||F===void 0,onChange:e=>{F!==void 0&&he.mutate({channel:F.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:Lt.map(e=>a(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),A>0&&t(U,{variant:`unstyled`,type:`button`,onClick:()=>void Ce(),disabled:B.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:[B.isPending?a(p,{className:`w-3 h-3 animate-spin`}):a(C,{className:`w-3 h-3`}),B.isPending?g(`admin.system.addons.updating`,`Updating…`):g(`admin.system.addons.updateAll`,`Update All ({{nonSystemUpdateCount}})`,{nonSystemUpdateCount:A})]})]}),t(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`group`,"aria-label":g(`admin.system.addons.filterInstalledAddons`,`Filter installed addons`),children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:g(`admin.system.addons.filter`,`Filter:`)}),[{id:`integrations`,label:g(`admin.system.addons.integrations`,`Integrations`),pressed:Q,toggle:()=>Je(!Q)},{id:`updatable`,label:g(`admin.system.addons.updatable`,`Updatable`),pressed:Ve,toggle:()=>Ye(!Ve)},{id:`error`,label:g(`admin.system.addons.inError`,`In error ({{count}})`,{count:Qe}),pressed:Ue,toggle:()=>Xe(!Ue)},{id:`npm`,label:`npm`,pressed:Z===`npm`,toggle:()=>Ze(Z===`npm`?null:`npm`)},{id:`dev`,label:g(`admin.system.addons.dev`,`Dev`),pressed:Z===`dev`,toggle:()=>Ze(Z===`dev`?null:`dev`)}].map(e=>a(U,{variant:`unstyled`,type:`button`,"aria-pressed":e.pressed,onClick:e.toggle,className:e.pressed?Ft:It,children:e.label},e.id))]}),t(`div`,{className:`flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-2`,children:[t(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:D,children:[a(ge,{type:`text`,searchHotkey:!0,value:y,onChange:e=>{b(e.target.value),E(!0)},onFocus:()=>E(!0),placeholder:g(`admin.system.addons.searchAddonsOnNpm`,`Search addons on npm...`),"aria-label":g(`admin.system.addons.searchAddonsOnNpm2`,`Search addons on npm`),disabled:B.isPending,leftSlot:a(ee,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),rightSlot:z?a(p,{className:`h-3 w-3 animate-spin`}):void 0}),T&&R&&R.length>0&&t(`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:[R.length>0&&a(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:g(`systemPage.addons.npmResults`,{count:R.length})}),R&&R.length>0&&a(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:R.map(e=>a(Mt,{addon:e,installing:ke.isPending,onInstall:e=>Oe({name:e.name,version:e.version,description:e.description})},e.name))})]})]}),a(yt,{onUploadSuccess:()=>{v.invalidateQueries({queryKey:[[`addons`]]}),m()}})]}),X&&t(`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:[a(`span`,{className:`text-foreground-subtle`,children:g(`admin.system.addons.filteringByCapability`,`Filtering by capability:`)}),a(`span`,{className:`font-mono text-primary font-semibold`,children:X}),a(U,{variant:`unstyled`,type:`button`,onClick:et,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:g(`admin.system.addons.clear`,`Clear`)})]}),X&&a(Nt,{capability:X,installing:ke.isPending,onInstall:e=>Oe({name:e.name,version:e.version,description:e.description})}),X&&$e.length>0&&a(`h2`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:g(`admin.system.addons.installed`,`Installed`)}),xe&&t(`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 max-w-sm pointer-events-auto`,children:[a(_,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),t(`div`,{children:[a(`div`,{className:`text-[11px] font-semibold text-foreground`,children:g(`admin.system.addons.bulkUpdateCompleted`,`Bulk update completed`)}),a(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:g(`admin.system.addons.systemPackagesUpdatedHubRestarted`,`System packages updated — hub restarted successfully.`)})]})]}),h===`pending`&&t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(p,{className:`h-3 w-3 animate-spin`}),g(`admin.system.addons.loadingInstalled`,`Loading installed addons…`)]}),h===`error`&&a(`div`,{className:`text-xs text-danger`,children:g(`admin.system.addons.failedToLoadAddons`,`Failed to load addons`)}),h===`ready`&&$e.length===0&&a(`div`,{className:`text-xs text-foreground-subtle`,children:c.length===0?g(`admin.system.addons.noAddonsInstalled`,`No addons installed`):X?g(`admin.system.addons.noInstalledAddonDeclaresThe`,`No installed addon declares the "{{capabilityFilter}}" capability. Any addon you can install appears under "Available to install" above.`,{capabilityFilter:X}):g(`admin.system.addons.noAddonsCompatibleWithPlacement`,`No addons compatible with {{name}} (placement filter active)`,{name:f.name})}),a(`div`,{className:`space-y-1.5`,children:h===`ready`&&nt.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=k.get(t),r=re.get(t),i=$(e)?e.representative:e,o=n?e=>P.mutate({name:t,version:e,nodeId:f.id}):void 0,s=de.get(t)??null,c=s!==null&&Ge(s);return a(_t,{addon:i,clusterStatus:u?.[i.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,...r===void 0?{}:{blockedUpdate:r},...r===void 0?{}:{onUpdateServer:()=>S(!0)},isUpdating:j.has(t)||c,jobProgress:s,onUpdate:o,disabledByBulk:B.isPending,selectedNode:f},$(e)?t:e.manifest.id)})}),K!==null&&a(kt,{target:K,installing:ke.isPending,installError:Ee,onClose:()=>Te(null),onInstall:(e,t)=>ke.mutate({packageName:e,version:t})})]})}function Wt(){let{t:e}=q(),r=l(),{data:i}=ce(void 0),{nodes:s}=N(),{selection:c,selectNode:u,requestedNodeId:f}=Ve(s.length>0?s:[Rt]),p=c.node??Rt,m=p.id,h=s.length>0?c.staleNodeId:null,{data:g,isLoading:_,isError:v}=H({nodeId:m}),y=Ee(),b=z(),x=y.isPending||b.isPending,S=async()=>{await y.mutateAsync({nodeId:m}),await b.mutateAsync(),r.invalidateQueries({queryKey:[[`addons`]]})},C=n(y);C.current=y;let w=n(f??`hub`);o(()=>{C.current.mutate({nodeId:w.current})},[]);let ee=(g??[]).map(Vt).filter(e=>e!==null);return t(Fe,{children:[t(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[a(ke,{selectedNodeId:m,onSelect:u}),t(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[!_&&!v&&a(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:e(`systemPage.addons.installedCount`,{count:ee.length})}),t(U,{variant:`unstyled`,type:`button`,onClick:()=>void S(),disabled:x,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:[a(d,{className:`w-3 h-3 ${x?`animate-spin`:``}`}),e(`admin.system.addons.checkForUpdates`,`Check for updates`)]})]})]}),a(X,{staleNodeId:h,shownNodeName:p.name}),a(jt,{selectedNode:p}),a(Ut,{addons:ee,clusterStatus:i,selectedNode:p,onRefresh:()=>void S(),listPhase:_?`pending`:v?`error`:`ready`})]})}export{Wt as AddonsPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,t as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$i as d,An as f,D as p,Er as m,G as h,L as g,Q as _,St as v,Yt as y,ci as b,cn as x,gt as S,jn as C,pn as w,qi as T,qr as E,ut as D}from"./player-overlays-C92tUBpz.js";import{vi as O}from"./client-DM5tcoga.js";import{n as k,t as A}from"./send-D_NAoo3n.js";import{t as j}from"./message-square-plus-_aGccjyj.js";import{Ai as M,Gd as N,Gn as P,H as ee,Hd as F,Hn as I,Lo as L,Nf as te,Wd as R,Wn as z,_r as ne,ai as B,at as V,cf as re,ef as H,fi as U,ki as W,lf as ie}from"./src-wYH5IrPO.js";import{t as G}from"./i18n-CwgPYzYg.js";import{t as K}from"./useTranslation-BJr-n0es.js";import"./mount-DdNgdYpo.js";import{Qr as q,X as J,x as Y}from"./index-Wmx2JgTc.js";import{t as X}from"./AdminSectionedPage-C_Xcom2n.js";import{t as ae}from"./AdminPage-a5x3JamG.js";import{t as oe}from"./InstancesTable-Dzt_ZD_8.js";import{a as se,c as ce,d as le,f as ue,i as de,l as Z,n as fe,o as pe,p as me,r as he,s as ge,t as _e,u as ve}from"./ai-page.helpers-BceORsq5.js";c();function ye(){let{t}=K(),n=S(),r=M({functionCap:`llm`}).data??[],a=s({queryKey:fe,queryFn:()=>n.trpcClient.llm.getDefaults.query({})}),o=u({mutationFn:e=>n.trpcClient.llm.setDefault.mutate({selector:{purpose:e.purpose},profileId:e.profileId}),onSuccess:()=>{a.refetch()}}),c=e=>(a.data??[]).find(t=>`purpose`in t.selector&&t.selector.purpose===e)?.profileId??``,l=e=>e===`vision`?t(`ai.defaultVision`,`Default vision profile`):t(`ai.defaultText`,`Default text profile`);return i(I,{headingId:`ai-profiles-defaults`,title:t(`ai.defaultsTitle`,`Defaults`),children:i(`div`,{className:`${p} grid gap-4 sm:grid-cols-2`,children:he.map(({purpose:n,visionOnly:a})=>{let s=a?r.filter(Z):r,u=c(n),d=r.find(e=>e.id===u);return e(`div`,{children:[i(ne,{className:`mb-1 block`,htmlFor:`llm-default-${n}`,children:l(n)}),i(D,{id:`llm-default-${n}`,"aria-label":l(n),value:u,onChange:e=>o.mutate({purpose:n,profileId:e.target.value===``?null:e.target.value}),options:[{value:``,label:t(`ai.none`,`None`)},...u!==``&&!s.some(e=>e.id===u)?[{value:u,label:d?.name??u}]:[],...s.map(e=>({value:e.id,label:ge(e)===``?e.name:`${e.name} · ${ge(e)}`}))]}),u!==``&&d===void 0&&i(`p`,{className:`mt-1 text-xs text-danger`,children:t(`ai.defaultMissing`,`This default names a profile that no longer exists.`)}),d!==void 0&&!d.enabled&&i(`p`,{className:`mt-1 text-xs text-warning`,children:t(`ai.defaultDisabled`,`This default profile is disabled — callers resolve to no profile.`)}),o.error!=null&&i(`p`,{className:`mt-1 text-xs text-danger`,children:String(o.error)})]},n)})})})}var be=2e3;function Q(e){return G.t(`system.aiModelPicker.sizeGb`,{value:(e/1e9).toFixed(2)})}function xe(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function Se({nodeId:t,value:r,onChange:a}){let{t:c}=K(),l=S(),[d,f]=o(``),[p,h]=o(null),[g,_]=o(!1),v=s({queryKey:_e,queryFn:()=>l.trpcClient.llm.listModelCatalog.query({})}),y=s({queryKey:[`llm`,`listNodeModels`,t],queryFn:()=>l.trpcClient.llm.listNodeModels.query({nodeId:t})}),x=u({mutationFn:e=>l.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{h(e),_(!1),e.ok&&a({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),w=u({mutationFn:e=>l.trpcClient.llm.installModel.mutate({nodeId:t,model:e}),onSuccess:()=>{_(!0),y.refetch()}}),T=s({queryKey:de,enabled:w.isPending,refetchInterval:w.isPending?be:!1,queryFn:()=>l.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(e=>e.nodeId===t)?.status?.download,E=n(()=>{let e=(v.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${Q(e.sizeBytes)}`})),n=(y.data??[]).filter(e=>e.catalogId===void 0&&e.path!==void 0).map(e=>({value:`node:${e.file}`,label:c(`ai.onNode`,`{{file}} · {{size}} · on {{node}}`,{file:e.file,size:Q(e.sizeBytes),node:t})})),r=p?.ok===!0?[{value:`custom`,label:`${p.label} · ${Q(p.totalBytes)}`}]:[];return[{value:``,label:c(`ai.selectModel`,`Select a model…`)},...e,...n,...r]},[v.data,y.data,p,t,c]),O=e=>{if(e===``){a(null);return}if(e===`custom`){if(p?.ok!==!0)return;a({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);a({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&&a({model:{kind:`path`,path:n.path},modelId:t,supportsVision:!1})},k=e=>{d.trim()!==``&&x.mutate({ref:d.trim(),...e===void 0?{}:{maxBytes:e}})};return e(`div`,{className:`space-y-3`,children:[i(V,{label:c(`ai.model`,`Model`),required:!0,children:i(D,{id:`ai-model`,"aria-label":c(`ai.model`,`Model`),value:xe(r),options:E,onChange:e=>O(e.target.value)})}),i(V,{label:c(`ai.hfTitle`,`Add a model from Hugging Face`),description:c(`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.`),children:e(`div`,{className:`flex gap-2`,children:[i(re,{"aria-label":c(`ai.hfTitle`,`Add a model from Hugging Face`),value:d,onChange:e=>f(e.target.value),placeholder:c(`system.aiModelPicker.unslothQwen3635bA3b`,`unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M`),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),k())}}),e(H,{size:`sm`,variant:`secondary`,type:`button`,disabled:d.trim()===``||x.isPending,onClick:()=>k(),children:[x.isPending?i(m,{className:`h-3.5 w-3.5 animate-spin`}):i(C,{className:`h-3.5 w-3.5`}),c(`ai.hfCheck`,`Check`)]})]})}),x.isError&&i(F,{message:x.error instanceof Error?x.error.message:c(`common.error`,`Error`)}),p?.ok===!1&&i(F,{message:p.message,action:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(p.candidates??[]).map(e=>i(H,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{let t=`${d.trim().split(`:`)[0]??``}:${e}`;f(t),x.mutate({ref:t})},children:e},e)),p.requiredBytes!==void 0&&i(H,{size:`sm`,variant:`secondary`,type:`button`,onClick:()=>k(p.requiredBytes),children:c(`ai.hfOverride`,`Install anyway ({{size}})`,{size:Q(p.requiredBytes)})})]})}),p?.ok===!0&&e(`div`,{className:`space-y-2 rounded-md border border-border bg-surface p-2.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`span`,{className:`text-[11px] font-medium text-foreground`,children:p.label}),i(R,{variant:p.purpose===`vision`?`info`:`default`,children:p.purpose}),i(R,{variant:`default`,children:Q(p.totalBytes)})]}),p.extraFilenames.length>0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:c(`ai.hfExtras`,`Also downloads: {{files}}`,{files:p.extraFilenames.join(`, `)})}),e(`div`,{className:`flex items-center gap-2`,children:[e(H,{size:`sm`,type:`button`,disabled:w.isPending||g,onClick:()=>w.mutate(p.model),children:[w.isPending?i(m,{className:`h-3.5 w-3.5 animate-spin`}):i(b,{className:`h-3.5 w-3.5`}),g?c(`ai.hfInstalled`,`Downloaded`):c(`ai.hfInstall`,`Download to {{node}}`,{node:t})]}),T!==void 0&&i(`span`,{className:`text-[10px] text-foreground-subtle`,children:T.phase===`verifying`?c(`ai.hfVerifying`,`verifying {{file}}…`,{file:T.file}):c(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:T.file,index:T.fileIndex,count:T.fileCount,done:Q(T.downloadedBytes),total:T.totalBytes===void 0?``:` / ${Q(T.totalBytes)}`})})]}),w.isError&&i(F,{message:w.error instanceof Error?w.error.message:c(`common.error`,`Error`)})]})]})}function Ce({value:t,onChange:n}){let{t:r}=K(),a=S(),o=s({queryKey:de,queryFn:()=>a.trpcClient.llm.listRuntimeNodes.query({})});return e(`div`,{children:[i(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:r(`ai.appleNode`,`Mac that runs it`)}),o.isPending&&e(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(m,{className:`h-3.5 w-3.5 animate-spin`}),r(`ai.appleAsking`,`Asking the nodes…`)]}),o.isError&&i(`p`,{className:`text-[11px] text-danger`,children:o.error instanceof Error?o.error.message:r(`ai.runtimesFailed`,`Failed to read runtime nodes`)}),o.isSuccess&&o.data.length===0&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}),o.isSuccess&&o.data.length>0&&i(`div`,{role:`radiogroup`,className:`space-y-1.5`,children:o.data.map(a=>{let o=pe(a),s=o.nodeId===t;return e(H,{variant:`unstyled`,type:`button`,role:`radio`,"aria-checked":s,disabled:!o.selectable&&!s,onClick:()=>n(o.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 ${s?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[e(`span`,{className:`min-w-0`,children:[i(`span`,{className:`block font-medium text-foreground`,children:o.nodeId}),o.detail!==null&&i(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:o.detail})]}),i(R,{variant:o.tone,children:r(o.labelKey,o.labelDefault)})]},o.nodeId)})}),i(`p`,{className:`mt-1.5 text-[10px] leading-relaxed text-foreground-subtle`,children:r(`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.`)})]})}function we(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Te({providerConfig:e,onProviderConfigChange:t}){return i(Ce,{value:we(e,`nodeId`),onChange:n=>t({...e,nodeId:n})})}function Ee({providerConfig:e,onProviderConfigChange:t,model:n,onModelChange:r}){let a=O.safeParse(e.model),o=a.success?{model:a.data,modelId:n.id,supportsVision:n.supportsVision}:null;return i(Se,{nodeId:we(e,`nodeId`)??`hub`,value:o,onChange:n=>{if(n===null){let{model:n,...i}=e;t(i),r({id:``,supportsVision:!1});return}t({...e,model:n.model}),r({id:n.modelId,supportsVision:n.supportsVision})}})}var De=new Map([[`ai/apple-node`,Te],[`ai/managed-model`,Ee]]);function Oe(e){return De.get(e)??null}c();function $(e,t){let n=e[t];return typeof n==`string`?n:``}function ke({row:a}){let{t:c}=K(),d=S(),f=l(),p=s({queryKey:n(()=>[J,a.addonId,`ai-lead`,a.id],[a]),queryFn:async()=>{let e=d.trpcClient.integrationInstances,[t,n]=await Promise.all([e.describe.query({addonId:a.addonId}),e.getInstance.query({addonId:a.addonId,id:a.id})]);return{description:t,instance:n}}}),[h,g]=o({}),_=t({}),v=t(!1),y=u({mutationFn:e=>d.trpcClient.integrationInstances.updateInstance.mutate({addonId:a.addonId,id:a.id,values:e}),onSuccess:async()=>{await f.invalidateQueries({queryKey:[J]}),await f.invalidateQueries({queryKey:[W]}),g({})}}),b=r(e=>{_.current={..._.current,...e},g(t=>({...t,...e})),!v.current&&(v.current=!0,queueMicrotask(()=>{let e=_.current;_.current={},v.current=!1,y.mutate(e)}))},[y]),x=p.data?.description.kinds?.find(e=>e.id===a.kindId),C=p.data?.instance?.formValues,w=n(()=>({...C,...h}),[C,h]),T=x?.widgets??[],E=T.some(e=>e.placement===`model`),O=n(()=>({...$(w,`nodeId`)===``?{}:{nodeId:$(w,`nodeId`)},...typeof w.modelRef==`object`&&w.modelRef!==null?{model:w.modelRef}:{}}),[w]),k={id:$(w,`model`),supportsVision:w.supportsVision===!0},A=u({mutationFn:()=>d.trpcClient.llm.listModels.mutate({addonId:a.addonId,kind:a.kindId??``,profileId:a.id})});if(p.isPending)return null;if(p.isError)return i(F,{variant:`warning`,message:p.error.message});let j=A.data?.ok===!0?A.data.models:[],M=A.data?.ok===!1?A.data:null,N=e=>{let t=j.find(t=>t.id===e);b({model:e,...t?.features?.vision===void 0?{}:{supportsVision:t.features.vision}})};return e(`div`,{className:`space-y-3`,"data-testid":`ai-profile-lead`,children:[T.map(({id:e})=>{let t=Oe(e);return t===null?i(F,{variant:`warning`,message:c(`ai.unknownWidget`,`This provider needs an editor part this build does not have ({{id}}).`,{id:e})},e):i(t,{providerConfig:O,onProviderConfigChange:e=>b({...$(e,`nodeId`)===$(O,`nodeId`)?{}:{nodeId:$(e,`nodeId`)},...e.model!==void 0&&e.model!==O.model?{modelRef:e.model}:{}}),model:k,onModelChange:e=>b({model:e.id,supportsVision:e.supportsVision})},e)}),!E&&e(V,{label:c(`ai.model`,`Model`),children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(H,{size:`sm`,variant:`secondary`,type:`button`,disabled:A.isPending,onClick:()=>A.mutate(),children:[A.isPending?i(m,{className:`h-3.5 w-3.5 animate-spin`}):null,c(`ai.loadModels`,`Load models`)]}),j.length>0&&i(D,{"aria-label":c(`ai.model`,`Model`),value:k.id,onChange:e=>N(e.target.value),options:[...j.some(e=>e.id===k.id)||k.id===``?[]:[{value:k.id,label:k.id}],...j.map(e=>({value:e.id,label:e.label??e.id}))]})]}),M!==null&&i(`p`,{className:`mt-1 text-xs text-danger`,children:M.message}),A.isError&&i(`p`,{className:`mt-1 text-xs text-danger`,children:A.error.message})]}),y.isError&&i(F,{variant:`warning`,message:y.error.message})]})}c();var Ae=5e3;function je(e){return G.t(`system.aiRuntimes.sizeGb`,{value:(e/1e9).toFixed(1)})}function Me(){let{t}=K(),r=S(),a=s({queryKey:de,refetchInterval:Ae,queryFn:()=>r.trpcClient.llm.listRuntimeNodes.query({})}),o=n(()=>[{key:`node`,header:t(`ai.colNode`,`Node`),render:e=>i(`span`,{className:`font-medium text-foreground`,children:e.nodeId})},{key:`state`,header:t(`ai.colState`,`State`),nowrap:!0,render:n=>e(`span`,{className:`flex items-center gap-1.5`,children:[i(R,{variant:me(n),children:t(ue(n))}),n.status?.downloadProgress!==void 0&&i(R,{variant:`info`,children:`${String(Math.round(n.status.downloadProgress*100))}%`})]})},{key:`model`,header:t(`ai.colModel`,`Model`),render:e=>i(`span`,{className:`text-foreground`,children:e.status?.modelId??`—`})},{key:`disk`,header:t(`ai.colDisk`,`On disk`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums text-foreground-muted`,children:e.disk===void 0?`—`:je(e.disk.modelsBytes)})},{key:`features`,header:t(`ai.colFeature`,`Feature`),render:n=>{let r=le(n);if(r.length===0)return i(`span`,{className:`text-foreground-subtle`,children:`—`});let a=r.flatMap(e=>e.detail===null?[]:[e.detail]);return e(`span`,{className:`flex flex-col items-start gap-0.5`,children:[i(`span`,{className:`flex flex-wrap gap-1`,children:r.map(e=>i(R,{variant:e.tone,children:t(e.labelKey)},e.id))}),a.length>0&&i(`span`,{className:`text-foreground-subtle`,children:a.join(` · `)})]})}},{key:`error`,header:t(`ai.colError`,`Error`),render:e=>e.error===void 0?i(`span`,{className:`text-foreground-subtle`,children:`—`}):i(`span`,{className:`text-danger`,children:e.error})}],[t]),c=a.data??[];return i(I,{headingId:`ai-runtimes-list`,title:t(`ai.runtimesList`,`Nodes`),children:a.isPending?e(`div`,{className:`${p} space-y-2`,"data-testid":`ai-runtimes-loading`,children:[i(N,{className:`h-8 w-full`}),i(N,{className:`h-8 w-full`})]}):a.isError?i(`div`,{className:p,children:i(F,{title:t(`ai.runtimesFailed`,`Failed to read runtime nodes`),message:a.error instanceof Error?a.error.message:t(`common.error`,`Error`),onRetry:()=>void a.refetch()})}):c.length===0?i(B,{icon:f,title:t(`ai.noRuntimesTitle`,`No runtime nodes`),description:t(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):i(z,{columns:o,rows:c,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,maxBodyHeight:P})})}var Ne=_(`/addon/ai/test-chat`),Pe=_(`/addon/ai/test-chat/chats`),Fe=6e5;function Ie(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),Fe)}function Le(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Re(e){if(!Le(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 ze=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function Be(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Le(t))return null;switch(t.kind){case`status`:{let e=ze.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:Re(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:G.t(`helpers.aiTestChat.providerError`)};default:return null}}async function*Ve(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=Be(e);t!==null&&(yield t)}a=r.indexOf(`
|
|
3
|
-
`)}}let e=r.trim();if(e.length>0){let t=Be(e);t!==null&&(yield t)}}finally{t.releaseLock()}}function He(e){return e.filter(e=>e.failed!==!0&&e.content.length>0).map(e=>({role:e.role,content:e.content}))}function Ue(e){return e.thumbnailBase64===void 0||e.thumbnailBase64.length===0?null:`data:${e.mimeType};base64,${e.thumbnailBase64}`}function We(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 Ge(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 Ke(e,t){switch(e){case`resolving-image`:return G.t(`helpers.aiTestChat.phaseImage`);case`connecting`:return G.t(`helpers.aiTestChat.phaseConnecting`);case`first-token-wait`:return t>0?G.t(`helpers.aiTestChat.phaseWaitUpTo`,{seconds:Math.round(t/1e3)}):G.t(`helpers.aiTestChat.phaseWait`);case`streaming`:return G.t(`helpers.aiTestChat.phaseAnswering`)}}c();var qe=[`pipelineAnalytics`,`listRecentTracks`,`ai-test`],Je=360*60*1e3,Ye=40,Xe=160,Ze={phase:`connecting`,firstTokenTimeoutMs:0,text:``,mediaSent:null};function Qe(){let{t:s}=K();S();let[c,l]=o(``),[u,f]=o(``),[m,h]=o(``),[_,b]=o([]),[C,w]=o(null),[E,O]=o(`none`),[k,N]=o(`throwaway`),[P,L]=o(null),[te,R]=o([]),[z,B]=o(null),[V,U]=o(null),W=t(null);a(()=>()=>W.current?.abort(),[]);let G=r(async()=>{let e=await fetch(Pe,{credentials:`same-origin`});e.ok&&R((await e.json()).chats??[])},[]);a(()=>{k===`persistent`&&G()},[k,G]);let q=M({functionCap:`llm`}),J=n(()=>(q.data??[]).filter(e=>e.enabled),[q.data]),Y=J.find(e=>e.id===c)??null,X=V!==null,ae=r(async(e,t)=>{let n=new AbortController;W.current=n,B(null);let r=Ie(Y===null?{}:ve(Y));U({...Ze,firstTokenTimeoutMs:r??0});let i=``,a=null,o,l=null,d=null,f;try{let s=await fetch(Ne,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,signal:n.signal,body:JSON.stringify({profileId:c,messages:e,...u.trim()===``?{}:{system:u.trim()},...t===void 0?{}:{attachment:t},...r===void 0?{}:{firstTokenTimeoutMs:r},...k===`persistent`?{persist:!0,...P===null?{}:{conversationId:P}}:{}})});if(!s.ok||s.body===null){let e=await s.text().catch(()=>``);throw Error(e.length>0?e:`HTTP ${String(s.status)}`)}for await(let e of Ve(s.body))switch(e.kind){case`status`:U(t=>({...t??Ze,phase:e.phase}));break;case`meta`:a=e.mediaSent,o=e.model,U(t=>({...t??Ze,firstTokenTimeoutMs:e.firstTokenTimeoutMs,mediaSent:e.mediaSent}));break;case`token`:i+=e.text,U(e=>({...e??Ze,text:i}));break;case`done`:d={outputTokens:e.outputTokens,latencyMs:e.latencyMs},f=e.conversationId;break;case`error`:l=`${e.code}: ${e.message}`;break}}catch(e){n.signal.aborted||B(e instanceof Error?e.message:s(`common.error`,`Error`))}finally{W.current=null,U(null)}f!==void 0&&(L(f),G());let p=n.signal.aborted&&i.length>0;l===null&&i.length===0&&!p||b(e=>[...e,{id:`a-${String(Date.now())}`,role:`assistant`,content:l??i,...l===null?{}:{failed:!0},...a===null?{}:{attachment:a},...o!==void 0&&l===null?{model:o}:{},...d===null?{}:d}])},[k,P,Y,c,G,u,s]),oe=r(()=>{let e=m.trim();if(e===``||c===``||X)return;let t={id:`u-${String(Date.now())}`,role:`user`,content:e,...C===null?{}:{attachmentLabel:C.label,attachmentKind:C.ref.kind}},n=[..._,t];b(n),h(``);let r=C?.ref;w(null),O(`none`),ae(k===`persistent`&&P!==null?[{role:`user`,content:e}]:He(n),r)},[k,P,m,C,c,ae,X,_]),se=()=>W.current?.abort(),ce=()=>{W.current?.abort(),b([]),w(null),h(``),B(null),U(null),L(null)},le=async e=>{W.current?.abort();let t=await fetch(`${Pe}/${e}`,{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();L(e),b(We(n)),U(null),B(null)};return e(`div`,{className:g,children:[i(I,{headingId:`ai-test-setup`,title:s(`ai.testSetup`,`Setup`),children:e(`div`,{className:`${p} space-y-3`,children:[e(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[e(`div`,{children:[i(ne,{className:`mb-1 block`,htmlFor:`ai-test-profile`,children:s(`ai.profile`,`Profile`)}),i(D,{id:`ai-test-profile`,value:c,onChange:e=>l(e.target.value),options:[{value:``,label:s(`ai.selectProfile`,`Select a profile…`)},...J.map(e=>({value:e.id,label:`${e.name} · ${ge(e)}${Z(e)?` · vision`:``}`}))]}),J.length===0&&!q.isLoading&&i(`p`,{className:`mt-1 text-xs text-foreground-subtle`,children:s(`ai.noEnabledProfiles`,`No enabled profile. Add one on the Profiles tab.`)})]}),e(`div`,{children:[i(ne,{className:`mb-1 block`,htmlFor:`ai-test-system`,children:s(`ai.systemPrompt`,`System prompt (optional)`)}),i(re,{id:`ai-test-system`,value:u,onChange:e=>f(e.target.value),placeholder:s(`ai.systemPlaceholder`,`Answer in one short sentence.`)})]})]}),i(ee,{label:s(`ai.chatMode`,`Conversation mode`),value:k,options:[{value:`throwaway`,label:s(`ai.throwawayMode`,`Throwaway`)},{value:`persistent`,label:s(`ai.saveConversation`,`Save conversation`)}],onChange:e=>{N(e),e===`throwaway`&&L(null)}}),k===`persistent`&&e(`div`,{className:`space-y-2`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`ai.testSubtitlePersistent`,`Conversations are saved for you and can be reopened. Throwaway mode is still available.`)}),e(H,{size:`sm`,variant:`secondary`,type:`button`,onClick:ce,children:[i(j,{className:`h-3.5 w-3.5`}),s(`ai.newChat`,`New chat`)]}),te.length>0&&i(`div`,{className:`max-h-36 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:te.map(e=>i(`button`,{type:`button`,onClick:()=>void le(e.id),className:`flex w-full px-2.5 py-1.5 text-left text-xs hover:bg-surface-hover ${e.id===P?`bg-primary/10`:``}`,children:i(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.title})},e.id))})]}),i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`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.`)}),Y!==null&&!Z(Y)&&i(`p`,{className:`text-xs text-warning`,children:s(`ai.notVision`,`This profile is not vision-capable — an attached image will be refused before anything is read.`)})]})}),z!==null&&i(F,{title:s(`ai.chatFailed`,`The test call failed`),message:z}),e(I,{headingId:`ai-test-conversation`,title:s(`ai.testConversation`,`Conversation`),actions:e(H,{size:`sm`,variant:`ghost`,type:`button`,disabled:_.length===0&&C===null,onClick:ce,children:[i(y,{className:`h-3.5 w-3.5`}),s(`ai.clearChat`,`Clear`)]}),children:[i($e,{turns:_,live:V}),e(`div`,{className:`${p} space-y-2 border-t border-border`,children:[C!==null&&e(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5`,children:[C.ref.kind===`snapshot`?i(T,{className:`h-3.5 w-3.5 text-foreground-subtle`}):i(d,{className:`h-3.5 w-3.5 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:C.label}),i(ie,{size:`sm`,variant:`ghost`,type:`button`,icon:v,"aria-label":s(`ai.removeAttachment`,`Remove attachment`),onClick:()=>w(null)})]}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(H,{size:`sm`,variant:E===`snapshot`?`primary`:`outline`,type:`button`,onClick:()=>O(E===`snapshot`?`none`:`snapshot`),children:[i(T,{className:`h-3.5 w-3.5`}),s(`ai.attachSnapshot`,`Camera snapshot`)]}),e(H,{size:`sm`,variant:E===`track`?`primary`:`outline`,type:`button`,onClick:()=>O(E===`track`?`none`:`track`),children:[i(d,{className:`h-3.5 w-3.5`}),s(`ai.attachTrack`,`Recent track`)]})]}),E===`snapshot`&&i(nt,{onPick:(e,t)=>{w({ref:{kind:`snapshot`,deviceId:e.id},label:s(`ai.snapshotOf`,`Snapshot of {{name}}`,{name:t})}),O(`none`)}}),E===`track`&&i(it,{onPick:(e,t)=>{w({ref:{kind:`track`,trackId:e.trackId,deviceId:e.deviceId},label:s(`ai.trackOf`,`{{class}} on {{name}}`,{class:e.label??e.className,name:t})}),O(`none`)}}),e(`div`,{className:`flex items-center gap-2`,children:[i(re,{value:m,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),oe())},placeholder:s(`ai.messagePlaceholder`,`Ask the model something…`),"aria-label":s(`ai.message`,`Message`)}),X?e(H,{size:`sm`,variant:`secondary`,type:`button`,onClick:se,children:[i(x,{className:`h-3.5 w-3.5`}),s(`ai.stop`,`Stop`)]}):e(H,{size:`sm`,type:`button`,disabled:m.trim()===``||c===``,onClick:oe,children:[i(A,{className:`h-3.5 w-3.5`}),s(`ai.send`,`Send`)]})]})]})]})]})}function $e({turns:t,live:n}){let{t:r}=K();return t.length===0&&n===null?i(B,{icon:k,title:r(`ai.chatEmptyTitle`,`No messages yet`),description:r(`ai.chatEmpty`,`Pick a profile, optionally attach a camera snapshot or a recent track, and send a message. Nothing here is saved.`)}):e(`div`,{className:`max-h-[50vh] space-y-2 overflow-y-auto ${p}`,children:[t.map(e=>i(et,{turn:e},e.id)),n!==null&&e(`div`,{className:`space-y-1`,children:[n.mediaSent!==null&&i(tt,{attachment:n.mediaSent}),n.text.length>0&&i(et,{turn:{id:`live`,role:`assistant`,content:n.text},streaming:!0}),e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(m,{className:`h-3.5 w-3.5 animate-spin`}),Ke(n.phase,n.firstTokenTimeoutMs)]})]})]})}function et({turn:t,streaming:n=!1}){let{t:r}=K(),a=t.role===`user`,o=t.failed===!0?`border-danger/40 bg-danger/10`:`border-border bg-surface`;return i(`div`,{className:`flex ${a?`justify-end`:`justify-start`}`,children:e(`div`,{className:`max-w-[85%] rounded-lg border px-3 py-2 ${a?`border-primary/40 bg-primary/10`:o}`,children:[e(`p`,{className:`whitespace-pre-wrap break-words text-xs text-foreground`,children:[t.content,n&&i(`span`,{className:`ml-0.5 animate-pulse text-primary`,children:`▌`})]}),t.attachment!==void 0&&i(tt,{attachment:t.attachment}),t.attachmentLabel!==void 0&&e(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[t.attachmentKind===`track`?i(d,{className:`h-3 w-3`}):i(T,{className:`h-3 w-3`}),t.attachmentLabel]}),t.attachment!==void 0&&e(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[t.attachment.kind===`snapshot`?i(T,{className:`h-3 w-3`}):i(d,{className:`h-3 w-3`}),Ge(t.attachment)]}),t.model!==void 0&&i(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:r(`system.aiTestChat.tokMs`,`{{model}} · {{value2}} tok · {{value3}} ms`,{model:t.model,value2:String(t.outputTokens??0),value3:String(t.latencyMs??0)})})]})})}function tt({attachment:e}){let{t}=K(),n=Ue(e);return n===null?null:i(`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 nt({onPick:e}){let{t}=K(),n=L({isCamera:!0,projection:`slim`}),r=(n.data??[]).filter(e=>!e.disabled);return n.isLoading?i(m,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noCameras`,`No camera found.`)}):i(`div`,{className:`grid max-h-56 grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-4`,children:r.map(t=>i(rt,{device:t,onPick:e},t.id))})}function rt({device:t,onPick:n}){let{t:r}=K(),a=U(t,`compact`),{src:o}=h(t.id,{width:Xe});return e(`button`,{type:`button`,onClick:()=>n(t,a),className:`overflow-hidden rounded-md border border-border bg-surface text-left transition-colors hover:border-primary/50`,children:[i(`span`,{className:`block aspect-video w-full bg-background-elevated`,children:o!==null&&i(`img`,{src:o,alt:``,className:`h-full w-full object-cover`,loading:`lazy`})}),e(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[!t.online&&i(R,{variant:`warning`,children:r(`common.off`)}),i(`span`,{className:`truncate text-[10px] text-foreground`,children:a})]})]})}function it({onPick:t}){let{t:r}=K(),a=S(),o=L({isCamera:!0,projection:`slim`}),c=n(()=>(o.data??[]).map(e=>e.id),[o.data]),l=n(()=>{let e=new Map;for(let t of o.data??[])e.set(t.id,t.name);return e},[o.data]),u=s({queryKey:[...qe,c.length],enabled:c.length>0,queryFn:()=>a.trpcClient.pipelineAnalytics.listRecentTracks.query({deviceIds:[...c],since:Date.now()-Je,limit:Ye,projection:`slim`})});if(o.isLoading||u.isLoading)return i(m,{className:`h-4 w-4 animate-spin text-foreground-subtle`});let f=u.data?.tracks??[];return f.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`ai.noTracks`,`No track in the last 6 hours.`)}):i(`div`,{className:`max-h-56 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:f.map(n=>e(`button`,{type:`button`,onClick:()=>t(n,l.get(n.deviceId)??String(n.deviceId)),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover`,children:[i(d,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:n.label??n.className}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:l.get(n.deviceId)??n.deviceId}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:new Date(n.lastSeen).toLocaleTimeString()})]},n.trackId))})}c();var at=1440*60*1e3,ot=[1,7,30,90];function st(){let{t}=K(),r=S(),[a,c]=o(7),l=n(()=>{let e=new Date;return e.setHours(0,0,0,0),e.getTime()-(a-1)*at},[a]),u=M({functionCap:`llm`}),d=s({queryKey:[...se,a],queryFn:()=>r.trpcClient.llm.getUsage.query({since:l})}),f=n(()=>{let e=new Map;for(let t of u.data??[])e.set(t.id,t.name);return e},[u.data]),m=n(()=>[{key:`day`,header:t(`ai.colDay`,`Day`),nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:e.day})},{key:`consumer`,header:t(`ai.colConsumer`,`Consumer`),nowrap:!0,render:e=>i(`span`,{className:`text-foreground`,children:e.consumer})},{key:`profile`,header:t(`ai.colProfile`,`Profile`),render:e=>i(`span`,{className:`text-foreground`,children:f.get(e.profileId)??e.profileId})},{key:`calls`,header:t(`ai.colCalls`,`Calls`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:String(e.calls)})},{key:`okErr`,header:t(`ai.colOkErr`,`OK / err`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums ${e.errorCalls>0?`text-danger`:``}`,children:`${String(e.okCalls)} / ${String(e.errorCalls)}`})},{key:`tokens`,header:t(`ai.colTokens`,`In / out tok`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:`${String(e.inputTokens)} / ${String(e.outputTokens)}`})},{key:`latency`,header:t(`ai.colAvgMs`,`Avg ms`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:String(Math.round(e.avgLatencyMs))})}],[f,t]),h=d.data??[],g=i(`div`,{className:`w-36`,children:i(D,{"aria-label":t(`ai.window`,`Window`),value:String(a),options:ot.map(e=>({value:String(e),label:t(`ai.lastDays`,`Last {{days}} days`,{days:e})})),onChange:e=>c(Number(e.target.value))})});return i(I,{headingId:`ai-usage-list`,title:t(`ai.usageList`,`Rollup`),actions:g,children:d.isPending?e(`div`,{className:`${p} space-y-2`,"data-testid":`ai-usage-loading`,children:[i(N,{className:`h-8 w-full`}),i(N,{className:`h-8 w-full`}),i(N,{className:`h-8 w-full`})]}):d.isError?i(`div`,{className:p,children:i(F,{title:t(`ai.usageFailed`,`Failed to read usage`),message:d.error instanceof Error?d.error.message:t(`common.error`,`Error`),onRetry:()=>void d.refetch()})}):h.length===0?i(B,{icon:E,title:t(`ai.noUsage`,`No AI calls in this window.`)}):i(z,{columns:m,rows:h,rowKey:e=>`${e.day}|${e.consumer}|${e.profileId}`,minWidthPx:720,bordered:!1,maxBodyHeight:P})})}c();var ct=`llm`,lt=[`profiles`,`runtimes`,`usage`,`test`],ut=[`instance`,`instance-new`];function dt(e){return lt.some(t=>t===e)}function ft(){let{t:e}=K(),t=te(ct),[n]=q(),r=Y(`/system/ai`,{t:e,isAdmin:!0})??{icon:w,title:e(`system.ai`,`AI`)};if(t!==`present`)return i(ae,{icon:r.icon,title:r.title,children:i(gt,{presence:t})});let a=n.get(`tab`),o=dt(a)?a:`profiles`,s={profiles:e(`ai.profilesSubtitle`,`One row = one usable model endpoint. The defaults below decide who answers when a feature names no profile.`),runtimes: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.`),usage: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.`),test:e(`ai.testSubtitle`,`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.`)};return i(X,{icon:r.icon,title:r.title,subtitle:s[o],defaultSection:`profiles`,sectionsLabel:`${r.title} sections`,sections:[{id:`profiles`,label:e(`ai.tabProfiles`,`Profiles`),content:i(ht,{}),ownedParams:ut},{id:`runtimes`,label:e(`ai.tabRuntimes`,`Runtimes`),content:i(Me,{})},{id:`usage`,label:e(`ai.tabUsage`,`Usage`),content:i(st,{})},{id:`test`,label:e(`ai.tabTest`,`Test`),content:i(Qe,{})}]})}function pt(e,t,n){let r=e.kind===`instance`?t.get(e.id):void 0;return r===void 0?void 0:n(r)}function mt(e,t){let n=t=>pt(t,e,ge)??``,r=t=>pt(t,e,Z)??!1,a=t=>pt(t,e,ce)??``;return[{key:`model`,header:t(`ai.colModel`,`Model`),sortValue:n,render:e=>i(`span`,{className:`font-mono text-xs text-foreground-muted`,children:n(e)||`—`})},{key:`vision`,header:t(`ai.colVision`,`Vision`),sortValue:e=>+!!r(e),render:e=>r(e)?i(R,{variant:`info`,children:t(`ai.vision`,`vision`)}):null},{key:`node`,header:t(`ai.colNode`,`Node`),sortValue:a,render:e=>i(`span`,{className:`text-xs text-foreground-muted`,children:a(e)||`—`})}]}function ht(){let{t}=K(),r=M({functionCap:ct}),a=n(()=>new Map((r.data??[]).map(e=>[e.id,e])),[r.data]),o=n(()=>mt(a,t),[a,t]);return e(`div`,{className:g,children:[i(ye,{}),i(oe,{functionCap:ct,icon:w,title:t(`ai.profilesList`,`Profiles`),subtitle:t(`ai.profilesTableSubtitle`,`Each profile is one model endpoint; switch one off to keep it without using it.`),emptyTitle:t(`ai.noProfilesTitle`,`No AI profiles yet`),emptyDescription:t(`ai.noProfilesDescription`,`Add a profile to give features a model to talk to.`),addLabel:t(`ai.addProfile`,`Add profile`),extraColumns:o,lead:e=>i(ke,{row:e})})]})}function gt({presence:t}){let{t:n}=K();return t===`pending`?e(`div`,{className:`space-y-3`,"data-testid":`ai-presence-pending`,children:[i(N,{className:`h-8 w-64`}),i(N,{className:`h-40 w-full`})]}):t===`unknown`?i(F,{title:n(`ai.presenceUnknownTitle`,`Could not check whether AI is installed`),message:n(`ai.presenceUnknown`,`The hub did not answer the capability check. Reload the page to try again.`)}):i(B,{icon:w,title:n(`ai.absentTitle`,`AI is not installed`),description:n(`ai.absentDescription`,`Install the AI addon from System → Addons to add model profiles.`)})}export{ft as AiProfilesPage,ft as default};
|