@camstack/addon-admin-ui 1.2.57 → 1.2.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/AddLocationWizard-BXcL90QM.js +1 -0
- package/dist/assets/AddonCollectionPage-C7QSc0L5.js +1 -0
- package/dist/assets/Addons-BjibMtF0.js +1 -0
- package/dist/assets/{AdminTabs-DDP_K0On.js → AdminTabs-Co61VJ4U.js} +1 -1
- package/dist/assets/AiProfiles-BTRgo8wQ.js +3 -0
- package/dist/assets/{BrokerForm-CTQc34Yj.js → BrokerForm-dYfcx-yx.js} +1 -1
- package/dist/assets/{Build-DJf08M0_.js → Build-CeZh7cjz.js} +4 -4
- package/dist/assets/Capabilities-DqpHPDt5.js +1 -0
- package/dist/assets/CapabilityBadges-Do48_jzx.js +1 -0
- package/dist/assets/Cluster-C1ow3yuB.js +1 -0
- package/dist/assets/{Data-BqzTvGIJ.js → Data-Bmealxcc.js} +1 -1
- package/dist/assets/DetectionIntelligence-DSjppxYS.js +1 -0
- package/dist/assets/{DeviceAggregateSection-C4-4Kcmy.js → DeviceAggregateSection-n3hYy5qm.js} +1 -1
- package/dist/assets/DeviceDetail-f12eUwKC.js +2 -0
- package/dist/assets/Devices-CMuMzwTK.js +1 -0
- package/dist/assets/EmbedPlayerPage-D5CGJj62.js +1 -0
- package/dist/assets/Events-CWhiAlpv.js +1 -0
- package/dist/assets/{FormBuilder-CJFGO362.js → FormBuilder-DVbN4jV5.js} +1 -1
- package/dist/assets/Identity-BxlWiwaZ.js +1 -0
- package/dist/assets/IntegrationDetail-D-EyePxA.js +1 -0
- package/dist/assets/Integrations-CVh8WXwB.js +1 -0
- package/dist/assets/Integrations-fubIeAyS.js +1 -0
- package/dist/assets/{Logs-DOHKNl_v.js → Logs-BRgM3t9y.js} +1 -1
- package/dist/assets/MotionZonesSettings-BQz60XWV.js +1 -0
- package/dist/assets/MyAccess-kWZq3W2o.js +2 -0
- package/dist/assets/Network-CgSVh1De.js +1 -0
- package/dist/assets/NodeAddonsSettingsPanel-DJKQxT7V.js +1 -0
- package/dist/assets/{NodeInferenceDevices-D3PgYaRG.js → NodeInferenceDevices-BTPZ_wyg.js} +1 -1
- package/dist/assets/Notifications-NpPQQefM.js +1 -0
- package/dist/assets/Pipeline-BaYygdkg.js +1 -0
- package/dist/assets/{Plates-BwRAYoZq.js → Plates-jNVVmALy.js} +1 -1
- package/dist/assets/PrivacyMaskSettings-C4YaoDu_.js +1 -0
- package/dist/assets/{ProviderIcon-DKV4fNZq.js → ProviderIcon-B5c5wlw9.js} +1 -1
- package/dist/assets/Recordings-D5v6ma1R.js +1 -0
- package/dist/assets/ScanNetworkModal-WPD06cKp.js +1 -0
- package/dist/assets/SceneMonitorEditor-Czf-iZgv.js +1 -0
- package/dist/assets/{Settings-DxoQvkXs.js → Settings-DvWeXqKw.js} +1 -1
- package/dist/assets/{Showroom-pKeXfFWl.js → Showroom-CBvbRA83.js} +1 -1
- package/dist/assets/{Terminal-D0Oo79zy.js → Terminal-BSwEKm0g.js} +2 -2
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DZIVD-QA.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-xKOm5ETc.js} +1 -1
- package/dist/assets/{bell-ring-N7kmSzeD.js → bell-ring-BqgJ8dnI.js} +1 -1
- package/dist/assets/{boxes-Do_ZLG0o.js → boxes-BCCj5PaE.js} +1 -1
- package/dist/assets/{build-cluster-graph-ByKyxovQ.js → build-cluster-graph-DMQ4vDW2.js} +2 -2
- package/dist/assets/circle-check-big-CQsfhCrZ.js +1 -0
- package/dist/assets/{circle-x-DtfQ73Pb.js → circle-x-DmD78bDU.js} +1 -1
- package/dist/assets/clock-0kqs7-NB.js +1 -0
- package/dist/assets/{copy-B3YYNY_1.js → copy-lMFz0Is-.js} +1 -1
- package/dist/assets/{debounced-invalidate-cC2as9q-.js → debounced-invalidate-CCYTebYW.js} +1 -1
- package/dist/assets/dist-BX6atE5N.js +345 -0
- package/dist/assets/{dist-DDhcO86n.js → dist-CK_B4BKB.js} +1 -1
- package/dist/assets/{download-CuiiYAI6.js → download-CXXQf3fF.js} +1 -1
- package/dist/assets/{face-bbox-DvA4dmMy.js → face-bbox-DAP66Zl4.js} +1 -1
- package/dist/assets/{hard-drive-Kg6gxxkp.js → hard-drive-gxnGyiw0.js} +1 -1
- package/dist/assets/{hostInit-BysItbfP.js → hostInit-B_AsKiXE.js} +1 -1
- package/dist/assets/index-B6kDpXr5.js +4 -0
- package/dist/assets/index-C_00GTmn.css +2 -0
- package/dist/assets/{key-round-9EQG_IZr.js → key-round-ClzJuSaS.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-2fefb3b5.js → mf-entry-bootstrap-0-53feb26e.js} +2 -2
- package/dist/assets/{pencil-BejnV1Fc.js → pencil-OtLKJIw8.js} +1 -1
- package/dist/assets/play-Q-R5vHEh.js +1 -0
- package/dist/assets/plus-vrCV3Fn-.js +1 -0
- package/dist/assets/power-Dw-9Qin8.js +1 -0
- package/dist/assets/{radio-QcoQdeOv.js → radio-B8HIjRjm.js} +1 -1
- package/dist/assets/{refresh-cw-CeTudtXW.js → refresh-cw-BwezRSth.js} +1 -1
- package/dist/assets/remoteEntry-DOOomD9n.js +1 -0
- package/dist/assets/rotate-ccw-uOQBDtri.js +1 -0
- package/dist/assets/rotate-cw-B6qXQ5pJ.js +1 -0
- package/dist/assets/search-iOwuoJNQ.js +1 -0
- package/dist/assets/send-DLoLyQZY.js +1 -0
- package/dist/assets/{server-CiKv0Gaj.js → server-jIBmmmio.js} +1 -1
- package/dist/assets/square-CgzDPTwM.js +1 -0
- package/dist/assets/{square-check-big-D3rQHPub.js → square-check-big-CKAjnVKI.js} +1 -1
- package/dist/assets/src-BizjMCcy.js +345 -0
- package/dist/assets/{src-D9X1qL3P.js → src-BmAmiAXy.js} +17 -17
- package/dist/assets/{undo-2-a3jGLPVr.js → undo-2-8_qvXX1O.js} +1 -1
- package/dist/assets/{upload-BUxm_j1O.js → upload-DUXkaKq1.js} +1 -1
- package/dist/assets/useEventInvalidation-Dovpg3no.js +1 -0
- package/dist/assets/{video-CpviqnLs.js → video-DKFg6rjo.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BvyQR7oV.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DRkfmg3i.js} +2 -2
- package/dist/assets/widget-panel-BF8s8cZY.js +1 -0
- package/dist/assets/{wifi-CjEywx2c.js → wifi-DT5Z6S_y.js} +1 -1
- package/dist/assets/{zap-DLLjJyp5.js → zap-B5xlyN9v.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/server/addon.js +219 -9
- package/package.json +1 -1
- package/dist/assets/AddLocationWizard-wyBp0PEZ.js +0 -1
- package/dist/assets/AddonCollectionPage-XrJpslqG.js +0 -1
- package/dist/assets/Addons-MWslOjGT.js +0 -1
- package/dist/assets/AiProfiles-Dg7ZBUae.js +0 -1
- package/dist/assets/Capabilities-BvhyN7Sn.js +0 -1
- package/dist/assets/CapabilityBadges-KAPv2FDI.js +0 -1
- package/dist/assets/Cluster-DCAJH-Ay.js +0 -1
- package/dist/assets/DetectionIntelligence-D9vG54QK.js +0 -1
- package/dist/assets/DeviceDetail-BkYvlYHi.js +0 -2
- package/dist/assets/Devices-DCysZxfV.js +0 -1
- package/dist/assets/EmbedPlayerPage-BRJE-WoS.js +0 -1
- package/dist/assets/Events-SJwPkXhm.js +0 -1
- package/dist/assets/Identity-DfN6oCz0.js +0 -1
- package/dist/assets/IntegrationDetail-CoSDmIoW.js +0 -1
- package/dist/assets/Integrations-BU32OLej.js +0 -1
- package/dist/assets/Integrations-C0MiYY6u.js +0 -1
- package/dist/assets/MotionZonesSettings-AJ3V-Or5.js +0 -1
- package/dist/assets/MyAccess-XQ_nEZgp.js +0 -2
- package/dist/assets/Network-BAwA-60Q.js +0 -1
- package/dist/assets/NodeAddonsSettingsPanel-DHMNNYDC.js +0 -1
- package/dist/assets/Notifications-C3Qq-KIL.js +0 -1
- package/dist/assets/Pipeline-CykfGM2b.js +0 -1
- package/dist/assets/PrivacyMaskSettings-C9e32eRl.js +0 -1
- package/dist/assets/Recordings-Bv3cJlqg.js +0 -1
- package/dist/assets/ScanNetworkModal-DJOEr2Wv.js +0 -1
- package/dist/assets/circle-check-big-CUWMrtHz.js +0 -1
- package/dist/assets/clock-DGDv9b38.js +0 -1
- package/dist/assets/dist-D-Z-PJsl.js +0 -345
- package/dist/assets/index-BAP-BLu1.js +0 -4
- package/dist/assets/index-BhFZLP1H.css +0 -2
- package/dist/assets/play-kt-O4eaO.js +0 -1
- package/dist/assets/player-overlays-C8AKvjIL.js +0 -1
- package/dist/assets/plus-CteUN0IC.js +0 -1
- package/dist/assets/power-DonE1e-i.js +0 -1
- package/dist/assets/remoteEntry-v8lslOYD.js +0 -1
- package/dist/assets/rotate-ccw-BJ670BHO.js +0 -1
- package/dist/assets/rotate-cw-B2f8hHt9.js +0 -1
- package/dist/assets/search-Co_38A3R.js +0 -1
- package/dist/assets/send-DJH3Zx9e.js +0 -1
- package/dist/assets/square-DJu_i8VC.js +0 -1
- package/dist/assets/src-DhrZwy6-.js +0 -345
- package/dist/assets/useEventInvalidation-ThF75_Ru.js +0 -1
package/dist/server/addon.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
//#region ../types/dist/event-category-
|
|
3
|
+
//#region ../types/dist/event-category-Bxo5yJjt.mjs
|
|
4
4
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
5
5
|
EventCategory["SystemBoot"] = "system.boot";
|
|
6
6
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -207,6 +207,33 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
207
207
|
EventCategory["PipelineCameraAssigned"] = "pipeline.camera-assigned";
|
|
208
208
|
EventCategory["PipelineCameraUnassigned"] = "pipeline.camera-unassigned";
|
|
209
209
|
/**
|
|
210
|
+
* A node the orchestrator would otherwise place cameras on has NO usable
|
|
211
|
+
* inference device: the operator enabled one or more accelerators there and
|
|
212
|
+
* the live probe reports every one of them unavailable. Emitted once per
|
|
213
|
+
* TRANSITION into that state (never per dispatch), and the node is dropped
|
|
214
|
+
* from the placement candidate set for as long as it holds.
|
|
215
|
+
*
|
|
216
|
+
* This exists because the state was previously invisible: little-unraid
|
|
217
|
+
* absorbed 283k inference errors in a day while still being handed cameras,
|
|
218
|
+
* and nothing in the system said so.
|
|
219
|
+
*
|
|
220
|
+
* A node with no accelerators configured at all is NOT this — its devices
|
|
221
|
+
* are `disabled`, not `unavailable`, and the runner's default CPU pool
|
|
222
|
+
* serves it exactly as before.
|
|
223
|
+
*/
|
|
224
|
+
EventCategory["PipelineNodeInferenceUnavailable"] = "pipeline.node-inference-unavailable";
|
|
225
|
+
/**
|
|
226
|
+
* A camera has an OPEN detection session and has produced no detection at
|
|
227
|
+
* all for longer than the blind threshold — the camera is being decoded and
|
|
228
|
+
* inferred and is returning nothing. Emitted once per transition into blind,
|
|
229
|
+
* per camera.
|
|
230
|
+
*
|
|
231
|
+
* The failure it reports: a 1h43 detection blackout on the entrance camera
|
|
232
|
+
* that nobody noticed, because "a camera that detects nothing" and "a quiet
|
|
233
|
+
* camera" produce byte-identical silence.
|
|
234
|
+
*/
|
|
235
|
+
EventCategory["PipelineDetectionBlind"] = "pipeline.detection-blind";
|
|
236
|
+
/**
|
|
210
237
|
* Per-camera pipeline config was mutated by the orchestrator
|
|
211
238
|
* (3-level settings change via `setAgentAddonDefaults` /
|
|
212
239
|
* `setCameraStepToggle` / `setCameraPipelineForAgent` or a
|
|
@@ -5371,6 +5398,12 @@ Object.fromEntries([
|
|
|
5371
5398
|
icon: "shapes",
|
|
5372
5399
|
order: 38
|
|
5373
5400
|
},
|
|
5401
|
+
{
|
|
5402
|
+
id: "scenes",
|
|
5403
|
+
label: "Scenes",
|
|
5404
|
+
icon: "scan-eye",
|
|
5405
|
+
order: 36
|
|
5406
|
+
},
|
|
5374
5407
|
{
|
|
5375
5408
|
id: "analytics",
|
|
5376
5409
|
label: "Analytics",
|
|
@@ -13995,6 +14028,8 @@ var NcSystemEventKindSchema = _enum([
|
|
|
13995
14028
|
"stream-offline",
|
|
13996
14029
|
"node-online",
|
|
13997
14030
|
"node-offline",
|
|
14031
|
+
"node-inference-unavailable",
|
|
14032
|
+
"detection-blind",
|
|
13998
14033
|
"addon-update-available",
|
|
13999
14034
|
"server-update-available",
|
|
14000
14035
|
"alarm-triggered",
|
|
@@ -14766,7 +14801,50 @@ var NcRuleInputSchema = object({
|
|
|
14766
14801
|
* tests every zone the track visited and a `crossing` condition can no longer
|
|
14767
14802
|
* be satisfied, because a closed track carries no crossing.
|
|
14768
14803
|
*/
|
|
14769
|
-
waitForEnhancement: boolean().optional()
|
|
14804
|
+
waitForEnhancement: boolean().optional(),
|
|
14805
|
+
/**
|
|
14806
|
+
* GROUP a burst of subjects into ONE notification that grows.
|
|
14807
|
+
*
|
|
14808
|
+
* Seconds of quiet after the last matching subject before the burst is
|
|
14809
|
+
* considered over. While it is open, the first subject enqueues immediately —
|
|
14810
|
+
* **exactly as today, with no added latency** — and every real growth (a new
|
|
14811
|
+
* subject, or a name confirmed on one already in it) REPLACES that
|
|
14812
|
+
* notification with an updated one naming everybody. The push carries the
|
|
14813
|
+
* group's own coalescing tag, so the phone replaces rather than stacks.
|
|
14814
|
+
*
|
|
14815
|
+
* `0` / absent = off, and off is today's behaviour byte for byte.
|
|
14816
|
+
*
|
|
14817
|
+
* ### Why an idle cutoff and not a window
|
|
14818
|
+
*
|
|
14819
|
+
* The measured seven-person arrival on device 590 spans 110 s with every
|
|
14820
|
+
* internal gap under 30 s. A 12 s fixed window cuts it into three groups; an
|
|
14821
|
+
* idle cutoff holds it as one and ends it when the arrival actually ends.
|
|
14822
|
+
* 30 is Frigate's shipped value for the same decision.
|
|
14823
|
+
*
|
|
14824
|
+
* ### What it replaces
|
|
14825
|
+
*
|
|
14826
|
+
* The blind cooldown, which collapses a burst by DISCARDING it. Measured on
|
|
14827
|
+
* device 615 / *Persona su Uscio* over six days: 116 qualifying tracks → 74
|
|
14828
|
+
* notifications, **44 (37.9%) suppressed outright**, 23 of them overlapping a
|
|
14829
|
+
* track that did fire and 7 carrying a confirmed identity nobody heard about.
|
|
14830
|
+
* A group collapses the same volume by MERGING, so the cooldown becomes a
|
|
14831
|
+
* budget over GROUPS — which is what it always meant — and a growth is never
|
|
14832
|
+
* throttled by the window its own first member spent.
|
|
14833
|
+
*
|
|
14834
|
+
* ### Interaction with {@link waitForEnhancement}
|
|
14835
|
+
*
|
|
14836
|
+
* They compose, and the order matters. `waitForEnhancement` defers the rule to
|
|
14837
|
+
* TRACK CLOSE, so with both set the group is opened by the first member to
|
|
14838
|
+
* CLOSE — already carrying its name — and grows as later members close. That
|
|
14839
|
+
* is later, and complete. With grouping alone the group opens on the first
|
|
14840
|
+
* object event and picks up names as they are confirmed, through the growth
|
|
14841
|
+
* path. Neither combination fires twice for one subject.
|
|
14842
|
+
*
|
|
14843
|
+
* `.optional()` and deliberately NOT `.default()`: a Zod default does not run
|
|
14844
|
+
* on the addon cap path, so absent must keep meaning what it meant before this
|
|
14845
|
+
* field existed.
|
|
14846
|
+
*/
|
|
14847
|
+
groupIdleSec: number().int().min(0).max(600).optional()
|
|
14770
14848
|
});
|
|
14771
14849
|
/**
|
|
14772
14850
|
* Partial patch for `updateRule` — any subset of the input fields, plus the
|
|
@@ -15692,7 +15770,7 @@ var TrackEnvelopeSchema = object({
|
|
|
15692
15770
|
* `snapshots[]` references — megabytes across a page of tracks. `slim`
|
|
15693
15771
|
* keeps every scalar the list surfaces actually render (ids, class(es),
|
|
15694
15772
|
* label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
|
|
15695
|
-
* zonesVisited, bestEventId, envelope, hasFace) and returns `positions` /
|
|
15773
|
+
* zonesVisited, bestEventId, envelope, hasFace, hasRider) and returns `positions` /
|
|
15696
15774
|
* `snapshots` as EMPTY arrays — detail views re-fetch the full row via
|
|
15697
15775
|
* `getTrack`. Mirrors the event-store `projection` convention
|
|
15698
15776
|
* (`getObjectEvents` et al.).
|
|
@@ -15979,6 +16057,28 @@ var TrackSchema = object({
|
|
|
15979
16057
|
* `=== true` and render nothing otherwise, never infer "no face".
|
|
15980
16058
|
*/
|
|
15981
16059
|
hasFace: boolean().optional(),
|
|
16060
|
+
/**
|
|
16061
|
+
* This subject CONTAINS a folded rider — a person the rider-pairing step
|
|
16062
|
+
* ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
|
|
16063
|
+
* so the passage is tracked once and as a VEHICLE.
|
|
16064
|
+
*
|
|
16065
|
+
* It exists because the fold's record was dishonest. D34 and the code both
|
|
16066
|
+
* said "the person is not lost — it is reported so both entities stay on the
|
|
16067
|
+
* record"; in fact the pair went into a per-processor RAM field behind an
|
|
16068
|
+
* accessor nobody called, and every durable surface said `vehicle`, full
|
|
16069
|
+
* stop. This is the composition note that makes the row true.
|
|
16070
|
+
*
|
|
16071
|
+
* A COMPOSITION, never a class and never a label. "This vehicle contains a
|
|
16072
|
+
* person" is not an answer to "what is this" — both label tiers would refuse
|
|
16073
|
+
* a macro token anyway (D89), and correctly. Nothing here changes what the
|
|
16074
|
+
* subject IS: a cyclist stays one vehicle track, occupancy still counts one,
|
|
16075
|
+
* and a `person` rule still does not fire for someone cycling past.
|
|
16076
|
+
*
|
|
16077
|
+
* **Absent ≠ false**, exactly like {@link hasFace}: every row written before
|
|
16078
|
+
* the column, and every hub that predates the field, omits it. Test
|
|
16079
|
+
* `=== true` and render nothing otherwise — never infer "no rider".
|
|
16080
|
+
*/
|
|
16081
|
+
hasRider: boolean().optional(),
|
|
15982
16082
|
...TrackFlagFields,
|
|
15983
16083
|
...TrackRetrainFields
|
|
15984
16084
|
});
|
|
@@ -24030,9 +24130,33 @@ method(object({
|
|
|
24030
24130
|
* settings-contribution methods. `status.kind:'push'` — the engine pushes on
|
|
24031
24131
|
* every hysteresis flip / availability change; consumers never poll.
|
|
24032
24132
|
*/
|
|
24033
|
-
/** Extensible condition tag. Seeded 'day' | '
|
|
24034
|
-
*
|
|
24133
|
+
/** Extensible condition tag. Seeded 'day' | 'ir' (the two variants the operator
|
|
24134
|
+
* captures) plus 'night' | 'dawn' | 'dusk' from the resolver's sun-times band.
|
|
24135
|
+
* Open by design so more can be added without a wire break.
|
|
24136
|
+
*
|
|
24137
|
+
* Matching does NOT fall back across conditions: cross-condition cosines are
|
|
24138
|
+
* not comparable, so "I have never seen this scene in this light" is reported
|
|
24139
|
+
* as `unknown`, never guessed. A day reference scored against an IR frame
|
|
24140
|
+
* collapses the cosine and would latch a false alarm every single night. */
|
|
24035
24141
|
var SceneConditionSchema = string();
|
|
24142
|
+
/** `matched` = the baseline is what we see; `diverged` = it demonstrably is not;
|
|
24143
|
+
* `unknown` = we cannot judge (no reference for this condition, encoder model
|
|
24144
|
+
* changed, view shifted, no snapshot). `unknown` is a real value, not a null,
|
|
24145
|
+
* and never counts toward hysteresis in either direction. */
|
|
24146
|
+
var SceneVerdictSchema = _enum([
|
|
24147
|
+
"matched",
|
|
24148
|
+
"diverged",
|
|
24149
|
+
"unknown"
|
|
24150
|
+
]);
|
|
24151
|
+
/** Why a scene cannot judge. Named, because this feature's failure mode is
|
|
24152
|
+
* silence that reads as "nothing has happened". */
|
|
24153
|
+
var SceneUnavailableSchema = _enum([
|
|
24154
|
+
"no-reference-for-condition",
|
|
24155
|
+
"view-shifted",
|
|
24156
|
+
"no-vision-profile",
|
|
24157
|
+
"encoder-model-changed",
|
|
24158
|
+
"no-snapshot"
|
|
24159
|
+
]);
|
|
24036
24160
|
/** One captured reference — condition-tagged, model-version-gated. `embedding`
|
|
24037
24161
|
* is `number[]` (Float32Array does NOT survive MsgPack/UDS). */
|
|
24038
24162
|
var SceneReferenceSchema = object({
|
|
@@ -24040,7 +24164,14 @@ var SceneReferenceSchema = object({
|
|
|
24040
24164
|
modelId: string(),
|
|
24041
24165
|
condition: SceneConditionSchema,
|
|
24042
24166
|
capturedAt: number(),
|
|
24043
|
-
thumbnailMediaId: string().optional()
|
|
24167
|
+
thumbnailMediaId: string().optional(),
|
|
24168
|
+
/** Whole-frame (downscaled) embedding captured alongside the ROI crop. The
|
|
24169
|
+
* anti-view-shift anchor: a bumped camera, a PTZ preset or a re-aim makes the
|
|
24170
|
+
* normalized rect frame a different piece of world, and the scene would
|
|
24171
|
+
* diverge forever with a perfectly plausible cosine. Checked LAZILY, only
|
|
24172
|
+
* when hysteresis is about to flip — one extra encode per candidate
|
|
24173
|
+
* transition, not per poll. */
|
|
24174
|
+
anchorEmbedding: array(number()).optional()
|
|
24044
24175
|
});
|
|
24045
24176
|
var SceneMonitorStateSchema = object({
|
|
24046
24177
|
id: string(),
|
|
@@ -24062,6 +24193,25 @@ var SceneCheckSchema = discriminatedUnion("mode", [object({
|
|
|
24062
24193
|
profileId: string().optional(),
|
|
24063
24194
|
hysteresisCount: number().int().positive()
|
|
24064
24195
|
})]);
|
|
24196
|
+
var SCENE_DEFAULT_ANCHOR_THRESHOLD = .85;
|
|
24197
|
+
/**
|
|
24198
|
+
* Vision-model adjudication of a candidate flip. Field names deliberately
|
|
24199
|
+
* mirror `NcConfirmSchema` so an operator meets one vocabulary, not two.
|
|
24200
|
+
*
|
|
24201
|
+
* `onTimeout` defaults to **'hold'**, the OPPOSITE of `NcConfirmGate`'s
|
|
24202
|
+
* fail-open: a notification suppressed is the worse error there, but a vision
|
|
24203
|
+
* model that timed out has not told us the bin is gone, and a latch is a
|
|
24204
|
+
* stateful claim that costs the operator a trip to reset.
|
|
24205
|
+
*/
|
|
24206
|
+
var SceneConfirmSchema = object({
|
|
24207
|
+
enabled: boolean().default(false),
|
|
24208
|
+
prompt: string().min(1).max(1e3),
|
|
24209
|
+
profileId: string().optional(),
|
|
24210
|
+
timeoutMs: number().int().min(1e3).max(2e4).default(8e3),
|
|
24211
|
+
maxImagePx: number().int().min(64).max(2048).default(448),
|
|
24212
|
+
/** What a timeout / unavailable model means for the PENDING flip. */
|
|
24213
|
+
onTimeout: _enum(["flip", "hold"]).default("hold")
|
|
24214
|
+
});
|
|
24065
24215
|
var SceneMonitorSchema = object({
|
|
24066
24216
|
id: string(),
|
|
24067
24217
|
label: string(),
|
|
@@ -24080,7 +24230,41 @@ var SceneMonitorSchema = object({
|
|
|
24080
24230
|
lastConfidence: number().nullable(),
|
|
24081
24231
|
currentCondition: SceneConditionSchema.nullable(),
|
|
24082
24232
|
availability: _enum(["ok", "unavailable"]),
|
|
24083
|
-
unavailableReason: string().nullable()
|
|
24233
|
+
unavailableReason: string().nullable(),
|
|
24234
|
+
/** Which state is "the initial screen". `null` until the first capture. */
|
|
24235
|
+
baselineStateId: string().nullable(),
|
|
24236
|
+
/** Which boolean drives notification rules and any export. */
|
|
24237
|
+
emit: _enum(["latched", "live"]).default("latched"),
|
|
24238
|
+
/** Live: does the region match the baseline RIGHT NOW. */
|
|
24239
|
+
verdict: SceneVerdictSchema,
|
|
24240
|
+
/** Has it been `diverged` at least once since `armedAt` — the operator's boolean. */
|
|
24241
|
+
latched: boolean(),
|
|
24242
|
+
/** Last reset (or creation). */
|
|
24243
|
+
armedAt: number(),
|
|
24244
|
+
divergedAt: number().nullable(),
|
|
24245
|
+
restoredAt: number().nullable(),
|
|
24246
|
+
/** A check is only COUNTED when the device has been quiet this long. Motion
|
|
24247
|
+
* during the window DISCARDS the observation — a car pulling up in front of
|
|
24248
|
+
* the bin must not be able to spend hysteresis credit. */
|
|
24249
|
+
quietSeconds: number().int().min(0).max(3600).default(60),
|
|
24250
|
+
/** An observation only advances the pending count when it is at least this
|
|
24251
|
+
* far from the previously counted one, so N agreeing checks span real time
|
|
24252
|
+
* rather than N adjacent polls inside one occlusion. */
|
|
24253
|
+
minObservationSpacingSec: number().int().min(0).max(3600).default(120),
|
|
24254
|
+
/** Vision-model adjudication of a candidate flip. Similarity primary only. */
|
|
24255
|
+
confirm: SceneConfirmSchema.optional(),
|
|
24256
|
+
/** Whole-frame anchor cosine below which a flip is REFUSED as `view-shifted`. */
|
|
24257
|
+
anchorThreshold: number().min(0).max(1).default(SCENE_DEFAULT_ANCHOR_THRESHOLD),
|
|
24258
|
+
/** Clear the latch on its own when the scene matches again? Default false —
|
|
24259
|
+
* `restoredAt` and the `scene-restored` edge are recorded regardless, so an
|
|
24260
|
+
* automation can react to the bin coming back without the operator's own
|
|
24261
|
+
* alarm silently clearing itself. */
|
|
24262
|
+
autoRestore: boolean().default(false),
|
|
24263
|
+
/** Named cause when `verdict === 'unknown'`. */
|
|
24264
|
+
unavailable: SceneUnavailableSchema.nullable(),
|
|
24265
|
+
/** Conditions that have at least one comparable reference — the coverage line
|
|
24266
|
+
* ("day ✓ · ir ✓ · dusk ✗") that turns a silent fallback into a visible fact. */
|
|
24267
|
+
coveredConditions: array(SceneConditionSchema)
|
|
24084
24268
|
});
|
|
24085
24269
|
var SceneMonitorStatusSchema = object({
|
|
24086
24270
|
monitors: array(SceneMonitorSchema),
|
|
@@ -24113,7 +24297,14 @@ DeviceType.Camera, method(object({ deviceId: number() }), SceneMonitorStatusSche
|
|
|
24113
24297
|
"both"
|
|
24114
24298
|
]).optional(),
|
|
24115
24299
|
checkIntervalSec: number().optional(),
|
|
24116
|
-
check: SceneCheckSchema.optional()
|
|
24300
|
+
check: SceneCheckSchema.optional(),
|
|
24301
|
+
emit: _enum(["latched", "live"]).optional(),
|
|
24302
|
+
quietSeconds: number().int().min(0).max(3600).optional(),
|
|
24303
|
+
minObservationSpacingSec: number().int().min(0).max(3600).optional(),
|
|
24304
|
+
anchorThreshold: number().min(0).max(1).optional(),
|
|
24305
|
+
autoRestore: boolean().optional(),
|
|
24306
|
+
/** `null` clears the vision-model adjudicator. */
|
|
24307
|
+
confirm: SceneConfirmSchema.nullable().optional()
|
|
24117
24308
|
})
|
|
24118
24309
|
}), _void(), {
|
|
24119
24310
|
kind: "mutation",
|
|
@@ -24150,6 +24341,14 @@ DeviceType.Camera, method(object({ deviceId: number() }), SceneMonitorStatusSche
|
|
|
24150
24341
|
}), _void(), {
|
|
24151
24342
|
kind: "mutation",
|
|
24152
24343
|
auth: "admin"
|
|
24344
|
+
}), method(object({
|
|
24345
|
+
deviceId: number(),
|
|
24346
|
+
monitorId: string(),
|
|
24347
|
+
/** Defaults to TRUE at the provider seam — see `SCENE_RESET_RECAPTURES`. */
|
|
24348
|
+
recapture: boolean().optional()
|
|
24349
|
+
}), _void(), {
|
|
24350
|
+
kind: "mutation",
|
|
24351
|
+
auth: "admin"
|
|
24153
24352
|
});
|
|
24154
24353
|
/**
|
|
24155
24354
|
* Per-stage gating mode applied to the zones a rule references.
|
|
@@ -29443,6 +29642,12 @@ Object.freeze({
|
|
|
29443
29642
|
addonId: null,
|
|
29444
29643
|
access: "create"
|
|
29445
29644
|
},
|
|
29645
|
+
"sceneMonitor.resetScene": {
|
|
29646
|
+
capName: "scene-monitor",
|
|
29647
|
+
capScope: "device",
|
|
29648
|
+
addonId: null,
|
|
29649
|
+
access: "delete"
|
|
29650
|
+
},
|
|
29446
29651
|
"sceneMonitor.updateScene": {
|
|
29447
29652
|
capName: "scene-monitor",
|
|
29448
29653
|
capScope: "device",
|
|
@@ -32125,6 +32330,11 @@ Object.freeze({
|
|
|
32125
32330
|
form: "single",
|
|
32126
32331
|
optional: false
|
|
32127
32332
|
}],
|
|
32333
|
+
"sceneMonitor.resetScene": [{
|
|
32334
|
+
name: "deviceId",
|
|
32335
|
+
form: "single",
|
|
32336
|
+
optional: false
|
|
32337
|
+
}],
|
|
32128
32338
|
"sceneMonitor.updateScene": [{
|
|
32129
32339
|
name: "deviceId",
|
|
32130
32340
|
form: "single",
|
|
@@ -32803,7 +33013,7 @@ var AdminUIAddon = class extends BaseAddon {
|
|
|
32803
33013
|
capability: adminUiCapability,
|
|
32804
33014
|
provider: {
|
|
32805
33015
|
getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
|
|
32806
|
-
getVersion: async () => ({ version: "1.2.
|
|
33016
|
+
getVersion: async () => ({ version: "1.2.59" })
|
|
32807
33017
|
}
|
|
32808
33018
|
}];
|
|
32809
33019
|
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{La as e,Ma as t,wo as n}from"./src-D9X1qL3P.js";import{I as r,Q as i,S as a,W as o,a as s,o as c,q as l,x as u,z as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p as f}from"./player-overlays-C8AKvjIL.js";import{t as p}from"./FormBuilder-CJFGO362.js";import{t as m}from"./pencil-BejnV1Fc.js";import{t as h}from"./plus-CteUN0IC.js";import{t as g}from"./power-DonE1e-i.js";import{P as _,S as v,W as y,i as b,s as x}from"./index-BAP-BLu1.js";var S=y(`star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]);i();function C(e){return e.enabled!==!1}function w(e){return e.isDefault}function T(e,t){let n={id:e.id,type:e.type,displayName:t.displayName??e.displayName,providerId:e.providerId,config:e.config,isDefault:t.isDefault??e.isDefault,isSystem:e.isSystem},r=e.nodeId===void 0?n:{...n,nodeId:e.nodeId},i=t.enabled??e.enabled;return i===void 0?r:{...r,enabled:i}}function E(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function D({location:e}){let t=e.capacity;return t==null?null:a(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[E(t.availableBytes),` free of `,E(t.totalBytes)]})}function O(e){let t=e.basePath;if(typeof t==`string`&&t.length>0)return t;let n=Object.keys(e);return n.length===0?``:n.join(`, `)}function k({location:e,cardinality:t,onEdit:n,onDelete:r,onSetDefault:i,onToggleEnabled:o}){let s=O(e.config),c=C(e),l=w(e);return a(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 px-3 py-2 border-t border-border first:border-t-0 hover:bg-primary/5`,children:[a(`div`,{className:`flex flex-wrap items-center gap-2 min-w-0 flex-1 basis-64`,children:[u(`div`,{className:`w-[88px] shrink-0`,children:e.isDefault?a(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-primary/10 border border-primary/20 px-1.5 py-0.5 text-[10px] font-semibold text-primary uppercase tracking-wide`,title:`Default location for this type`,children:[u(S,{className:`h-2.5 w-2.5 fill-primary`}),`Default`]}):a(`button`,{onClick:()=>i(e),className:`inline-flex items-center gap-0.5 rounded border border-border px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 hover:border-primary/30 uppercase tracking-wide`,title:`Promote to default for this type`,children:[u(S,{className:`h-2.5 w-2.5`}),`Set default`]})}),u(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:e.providerId}),!c&&u(`span`,{className:`text-[10px] uppercase tracking-wide text-warning bg-warning/10 border border-warning/30 rounded px-1.5 py-0.5`,title:`Disabled — nothing new is written here. Existing data stays readable and is still pruned by age.`,children:`disabled`}),e.isSystem&&u(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5`,title:`System-managed location — cannot be deleted; edit config to relocate`,children:`system`}),e.config.readOnly===!0&&u(`span`,{className:`text-[10px] uppercase tracking-wide text-warning bg-warning/10 border border-warning/30 rounded px-1.5 py-0.5`,title:`Drain mode — reads and age retention continue; nothing new is written here and disk-pressure eviction skips it`,children:`read-only`}),a(`div`,{className:`min-w-0`,children:[u(`div`,{className:`text-xs font-medium text-foreground truncate`,children:e.displayName}),a(`div`,{className:`flex flex-wrap items-center gap-x-2`,children:[s&&u(`span`,{className:`text-[10px] text-foreground-subtle truncate font-mono`,children:s}),u(D,{location:e})]})]})]}),a(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[a(`button`,{type:`button`,role:`switch`,"aria-label":`Writes enabled`,"aria-checked":c,disabled:l,onClick:()=>o(e,!c),title:l?`The default location of a type is always enabled — it is the fallback every balancing consumer falls back to. Promote another location to default first.`:c?`Enabled — balancing consumers may write new data here. Click to stop new writes.`:`Disabled — no new data is written here. Existing data stays readable. Click to enable.`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border disabled:cursor-not-allowed ${c?`border-success/30 text-success hover:bg-success/10`:`border-warning/40 text-warning hover:bg-warning/10`}`,children:[u(g,{className:`h-3 w-3`}),c?`Enabled`:`Disabled`]}),!e.isDefault&&a(`button`,{onClick:()=>i(e),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10`,title:`Set as default for this type`,children:[u(S,{className:`h-3 w-3`}),`Set default`]}),a(`button`,{onClick:()=>n(e),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10`,children:[u(m,{className:`h-3 w-3`}),`Edit`]}),!e.isSystem&&t!==`single`&&u(`button`,{onClick:()=>r(e),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,title:`Delete location`,children:u(x,{className:`h-3 w-3`})})]})]})}function A({type:e,displayName:t,description:n,cardinality:r,locations:i,onAdd:s,onEdit:c,onDelete:l,onSetDefault:d,onToggleEnabled:f}){let p=o(()=>{let e=[...i];return e.sort((e,t)=>e.isDefault===t.isDefault?e.displayName.localeCompare(t.displayName):e.isDefault?-1:1),e},[i]);return a(`div`,{className:`rounded-lg border border-border bg-surface`,children:[a(`div`,{className:`flex items-start justify-between border-b border-border px-3 py-2`,children:[a(`div`,{className:`space-y-0.5`,children:[a(`div`,{className:`flex items-center gap-2`,children:[u(`span`,{className:`text-sm font-semibold text-foreground capitalize`,children:t}),u(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:e})]}),n&&u(`p`,{className:`text-[11px] text-foreground-subtle`,children:n}),r===`single`&&u(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:`Single — one location per type. Edit the existing entry; it can't be split.`})]}),r===`multi`&&a(`button`,{onClick:()=>s(e),className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90`,children:[u(h,{className:`h-3 w-3`}),`Add`]})]}),p.length===0?u(`div`,{className:`px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:r===`multi`?`No location registered. Click "Add" to register one.`:`No location registered yet — should be auto-seeded at next boot.`}):u(`div`,{children:p.map(e=>u(k,{location:e,cardinality:r,onEdit:c,onDelete:l,onSetDefault:d,onToggleEnabled:f},e.id))})]})}var j=new Set([`proc`,`sys`,`dev`,`run`,`boot`,`lost+found`,`snap`,`bin`,`sbin`,`lib`,`lib32`,`lib64`,`libx32`,`usr`,`etc`,`var`,`opt`,`tmp`,`srv`,`root`,`System`,`Library`,`Applications`,`cores`,`private`]),M=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function N(e){let t=M.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?M.length:t}function P(e){return e.filter(e=>!e.name.startsWith(`.`)&&!j.has(e.name)).toSorted((e,t)=>{let n=N(e.name)-N(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}i();function F({nodeId:e,value:t,onChange:n}){let i=f().trpcClient,[o,s]=l([]),[c,p]=l(t),[m,h]=l(null),[g,_]=l(null),[v,y]=l(``),b=r(async(t,r)=>{_(null);try{let a=await i.filesystemBrowse.browse.query({nodeId:e,path:t});h(a),p(a.path),r&&n(a.path)}catch(e){_(e instanceof Error?e.message:`browse failed`)}},[i,e,n]);d(()=>{p(t),(async()=>{let n=await i.filesystemBrowse.browse.query({nodeId:e,path:`/`}).then(e=>e).catch(()=>null);if(n){s(P(n.entries)),await b(t.startsWith(`/`)?t:`/`,!1);return}try{let n=await i.filesystemBrowse.listAllowedRoots.query({nodeId:e});s(n),await b(t&&n.some(e=>t.startsWith(e))?t:n[0]??``,!1)}catch(e){s([]),h(null),_(e instanceof Error&&/not available on node/i.test(e.message)?`This node can't be browsed remotely. Enter the path manually.`:e instanceof Error?e.message:`browse unavailable`)}})()},[e]);let x=async()=>{if(!(!v.trim()||!m)){_(null);try{let t=`${m.path.replace(/\/+$/,``)}/${v.trim()}`;await i.filesystemBrowse.createDir.mutate({nodeId:e,path:t}),y(``),await b(m.path,!0)}catch(e){_(e instanceof Error?e.message:`create failed`)}}},S=e=>`${(e/1e9).toFixed(1)} GB`;return a(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[u(`div`,{className:`flex flex-wrap gap-1`,children:o.map(e=>u(`button`,{onClick:()=>void b(e,!0),className:`rounded border border-border px-2 py-0.5 text-[10px] font-mono hover:border-primary/40`,children:e},e))}),u(`input`,{value:c,onChange:e=>{p(e.target.value),n(e.target.value)},placeholder:`/absolute/path`,className:`w-full rounded border border-border bg-background px-2 py-1 text-[11px] font-mono`}),m&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:[S(m.freeBytes),` free / `,S(m.totalBytes)]}),u(`div`,{className:`max-h-40 space-y-0.5 overflow-y-auto`,children:m?.entries.map(e=>a(`button`,{onClick:()=>void b(e.path,!0),className:`block w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-primary/5`,children:[`📁 `,e.name]},e.path))}),a(`div`,{className:`flex gap-1`,children:[u(`input`,{value:v,onChange:e=>y(e.target.value),placeholder:`new folder`,className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs`}),u(`button`,{onClick:()=>void x(),className:`rounded border border-border px-2 py-1 text-xs hover:border-primary/40`,children:`Create`})]}),g&&u(`div`,{className:`text-[10px] text-red-400`,children:g})]})}i();function I({location:r,onClose:i,onSaved:d}){let m=c(),h=f().trpcClient,[g,_]=l({...r.config}),[y,x]=l(r.displayName),[S,C]=l(null),[w,T]=l(!1),E=t(),D=o(()=>{let e=E.data;return Array.isArray(e)?e.find(e=>e.providerId===r.providerId)??null:null},[E.data,r.providerId]),O=e({onSuccess:()=>{m.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),d()}}),k=D?.shouldSaveDiskSpace===!0,A=D?.nodeLocal===!0,[j,M]=l(typeof r.nodeId==`string`?r.nodeId:`hub`),N=typeof g.basePath==`string`?g.basePath:``,P=e=>_(t=>({...t,basePath:e})),I=g.readOnly===!0,L=s({queryKey:[`storage`,`listLocations`,`ro-guard`],queryFn:()=>h.storage.listLocations.query({})}),R=(L.data??[]).filter(e=>e.type===r.type&&e.id!==r.id&&e.config.readOnly!==!0).length,z=!I&&L.data!==void 0&&R===0,B=e=>_(t=>{let n={...t};return delete n.readOnly,e?{...n,readOnly:!0}:n}),V=typeof g.maxUsedGb==`number`?g.maxUsedGb:``,H=e=>{let t=e.trim(),n=t===``?void 0:Number(t);_(e=>{let t={...e};return n===void 0||!Number.isFinite(n)||n<=0?delete t.maxUsedGb:t.maxUsedGb=n,t})},U=typeof g.minFreePercent==`number`?g.minFreePercent:``,W=e=>{let t=e.trim(),n=t===``?void 0:Number(t);_(e=>{let t={...e};return n===void 0||!Number.isFinite(n)?delete t.minFreePercent:t.minFreePercent=Math.min(100,Math.max(0,n)),t})},G=async()=>{T(!0),C(null);try{C(await(e=>h.storage.testConfig.query(e))({providerId:r.providerId,config:g}))}catch(e){C({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{T(!1)}};return u(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:i,children:a(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[a(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[a(`div`,{className:`space-y-0.5`,children:[a(`h2`,{className:`text-sm font-semibold text-foreground`,children:[`Edit `,r.displayName]}),a(`p`,{className:`text-xs text-foreground-subtle`,children:[u(`span`,{className:`font-mono`,children:r.id}),` ·`,` `,D?.displayName??r.providerId]})]}),u(`button`,{onClick:i,className:`text-foreground-subtle hover:text-foreground`,children:u(b,{className:`h-4 w-4`})})]}),a(`div`,{className:`p-4 space-y-3 max-h-[60vh] overflow-y-auto`,children:[a(`div`,{className:`space-y-1`,children:[u(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Display name`}),u(`input`,{type:`text`,value:y,onChange:e=>x(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),D&&u(p,{schema:D.configSchema,values:g,onChange:_}),a(`div`,{className:`space-y-1`,children:[a(`label`,{className:`flex items-center gap-2 text-xs ${z?`text-foreground-subtle cursor-not-allowed`:`text-foreground cursor-pointer`}`,children:[u(`input`,{type:`checkbox`,checked:I,disabled:z,onChange:e=>B(e.target.checked),className:`accent-primary`}),`Read-only (drain mode)`]}),u(`p`,{className:`text-[10px] text-foreground-subtle`,children:z?`Blocked: this is the last writable location of its type — new footage would have nowhere to go.`:`Reads and age-based retention continue; nothing new is written here and disk-pressure eviction skips it. Use it to slowly decommission a disk.`})]}),A&&a(`div`,{className:`space-y-2`,children:[u(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Node`}),u(n,{selectedNodeId:j,onSelect:M,alwaysShow:!0}),u(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Path`}),u(F,{nodeId:j,value:N,onChange:P})]}),k&&a(`div`,{className:`space-y-1`,children:[u(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Min free disk %`}),u(`input`,{type:`number`,min:0,max:100,value:U,placeholder:D?.minFreePercent==null?``:String(D.minFreePercent),onChange:e=>W(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),a(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`When free space on this volume drops below this %, the oldest data stored here is evicted to reclaim space.`,D?.minFreePercent==null?` Empty = use the default.`:` Empty = use the default (${D.minFreePercent}%).`]}),u(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Max used (GB)`}),u(`input`,{type:`number`,min:1,value:V,placeholder:`unlimited`,onChange:e=>H(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),u(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Hard cap on the TOTAL bytes evictable data (recordings) may occupy on this location, independent of disk free space — oldest footage is evicted past it. Empty = unlimited.`})]}),!D&&!E.isLoading&&a(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:[`Provider `,u(`code`,{className:`font-mono`,children:r.providerId}),` is no longer registered. Field schema unavailable; raw config is preserved on save.`]}),S&&u(`div`,{className:`rounded border px-3 py-2 text-[11px] ${S.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:S.ok?`Connection OK.`:`Test failed: ${S.error??`unknown error`}`}),O.isError&&u(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:O.error instanceof Error?O.error.message:String(O.error)})]}),a(`div`,{className:`flex items-center justify-between gap-2 border-t border-border px-4 py-3`,children:[u(`button`,{onClick:i,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),a(`div`,{className:`flex items-center gap-2`,children:[u(`button`,{onClick:()=>{G()},disabled:w||!D,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:w?`Testing…`:`Test connection`}),a(`button`,{onClick:()=>{O.mutate({id:r.id,type:r.type,providerId:r.providerId,isDefault:r.isDefault,displayName:y.trim(),config:g,nodeId:A?j:void 0})},disabled:O.isPending||y.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[O.isPending?u(v,{className:`h-3.5 w-3.5 animate-spin`}):null,O.isPending?`Saving…`:`Save`]})]})]})]})})}function L(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function R(e,t){let n=L(t);return`${e}:${n.length>0?n:`default`}`}i();function z({initialType:r,onClose:i,onCreated:s}){let d=c(),m=f().trpcClient,[h,g]=l(`picker`),[y,x]=l(r),[S,C]=l(null),[w,T]=l({}),[E,D]=l(``),[O,k]=l(null),[A,j]=l(!1),[M,N]=l(!1),[P,I]=l(`hub`),[L,z]=l(null),[B,V]=l(!1),H=e=>T(t=>({...t,basePath:e})),U=typeof w.basePath==`string`?w.basePath:``,W=t(),G=o(()=>{let e=W.data;return Array.isArray(e)?e:[]},[W.data]),K=W.isLoading,q=e({onSuccess:()=>{d.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),s()}}),J=o(()=>O!==null&&O.length>0?O:R(y,E),[y,E,O]),Y=async()=>{if(S){V(!0),z(null);try{z(await(e=>m.storage.testConfig.query(e))({providerId:S.providerId,config:w}))}catch(e){z({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{V(!1)}}};return u(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:i,children:a(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[a(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[a(`div`,{className:`space-y-0.5`,children:[u(`h2`,{className:`text-sm font-semibold text-foreground`,children:{picker:`Add Location — Pick provider`,config:`Add Location — ${S?.displayName??``}`,naming:`Add Location — Name & defaults`}[h]}),a(`p`,{className:`text-xs text-foreground-subtle`,children:[`Type: `,u(`span`,{className:`font-mono`,children:y})]})]}),u(`button`,{onClick:i,className:`text-foreground-subtle hover:text-foreground`,children:u(b,{className:`h-4 w-4`})})]}),h===`picker`&&a(`div`,{className:`p-4 space-y-2`,children:[K&&u(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading providers…`}),!K&&G.length===0&&a(`div`,{className:`rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle`,children:[`No storage-provider supports type "`,y,`". Install a compatible addon (e.g.`,` `,u(`code`,{className:`font-mono`,children:`remote-storage`}),`) to enable it.`]}),G.map(e=>a(`button`,{onClick:()=>{C(e),g(`config`)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background p-3 text-left hover:border-primary/40 hover:bg-primary/5 transition-colors`,children:[a(`div`,{className:`flex-1 min-w-0`,children:[u(`p`,{className:`text-xs font-semibold text-foreground`,children:e.displayName}),u(`p`,{className:`text-[10px] text-foreground-subtle font-mono mt-0.5 truncate`,children:e.providerId})]}),u(_,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},e.providerId))]}),h===`config`&&S&&a(`div`,{className:`p-4 space-y-3 max-h-[60vh] overflow-y-auto`,children:[u(p,{schema:S.configSchema,values:w,onChange:T}),S.nodeLocal&&a(`div`,{className:`space-y-2`,children:[u(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Node`}),u(n,{selectedNodeId:P,onSelect:I,alwaysShow:!0}),u(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Path`}),u(F,{nodeId:P,value:U,onChange:H})]}),L&&u(`div`,{className:`rounded border px-3 py-2 text-[11px] ${L.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:L.ok?`Connection OK.`:`Test failed: ${L.error??`unknown error`}`}),a(`div`,{className:`flex items-center justify-between pt-1`,children:[u(`button`,{onClick:()=>g(`picker`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Back`}),a(`div`,{className:`flex items-center gap-2`,children:[u(`button`,{onClick:()=>{Y()},disabled:B,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:B?`Testing…`:`Test connection`}),u(`button`,{onClick:()=>g(`naming`),className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:`Next`})]})]})]}),h===`naming`&&S&&a(`div`,{className:`p-4 space-y-3`,children:[a(`div`,{className:`space-y-1`,children:[u(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Display name`}),u(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:`${y} on ${S.displayName}`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),a(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:[`Id`,` `,u(`span`,{className:`lowercase tracking-normal text-foreground-subtle`,children:`— auto-derived; override if needed`})]}),u(`input`,{type:`text`,value:J,onChange:e=>k(e.target.value),placeholder:R(y,E),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-1 focus:ring-primary`}),a(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Format: `,u(`code`,{className:`font-mono`,children:`<type>:<slug>`}),`. Lowercase letters, digits, and hyphens only.`]})]}),a(`label`,{className:`flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5`,children:[u(`input`,{type:`checkbox`,checked:A,onChange:e=>j(e.target.checked),className:`accent-primary mt-0.5`}),a(`div`,{className:`space-y-0.5`,children:[a(`div`,{className:`text-xs font-medium text-foreground`,children:[`Mark as default for type "`,y,`"`]}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:[`Setting this as default will demote the current default for this type. References like `,a(`code`,{className:`font-mono`,children:[`"`,y,`"`]}),` resolve to whichever location is the default.`]})]})]}),a(`label`,{className:`flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5`,children:[u(`input`,{type:`checkbox`,checked:M,onChange:e=>N(e.target.checked),className:`accent-primary mt-0.5`}),a(`div`,{className:`space-y-0.5`,children:[u(`div`,{className:`text-xs font-medium text-foreground`,children:`Enable immediately`}),u(`div`,{className:`text-[10px] text-foreground-subtle`,children:`A disabled location receives no writes until enabled — reads and age-based retention still work, nothing new lands here. Leave this off to register the disk now and start using it later.`})]})]}),q.isError&&u(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:q.error instanceof Error?q.error.message:String(q.error)}),a(`div`,{className:`flex items-center justify-between pt-1`,children:[u(`button`,{onClick:()=>g(`config`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Back`}),a(`div`,{className:`flex items-center gap-2`,children:[u(`button`,{onClick:()=>{x(r),C(null),T({}),D(``),k(null),j(!1),N(!1),z(null),g(`picker`)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Reset`}),a(`button`,{onClick:()=>{S&&q.mutate({id:J,type:y,displayName:E.trim(),providerId:S.providerId,config:w,isDefault:A,enabled:M,nodeId:S.nodeLocal?P:void 0})},disabled:q.isPending||E.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[q.isPending?u(v,{className:`h-3.5 w-3.5 animate-spin`}):null,q.isPending?`Saving…`:`Save`]})]})]})]})]})})}export{T as i,I as n,A as r,z as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Co as e,Et as t,So as n,fs as r,g as i,jt as a,ms as o,p as s,v as c}from"./src-D9X1qL3P.js";import{Q as l,S as u,o as d,q as f,x as p,z as m}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{t as h}from"./play-kt-O4eaO.js";import{t as g}from"./plus-CteUN0IC.js";import{t as _}from"./refresh-cw-CeTudtXW.js";import{t as v}from"./square-DJu_i8VC.js";import{G as y,I as b,S as x,V as S,m as C}from"./index-BAP-BLu1.js";import{t as w}from"./AdminPage-Dq33XE9j.js";import{t as T}from"./NodeAddonsSettingsPanel-DHMNNYDC.js";l();function E({addonId:e,fallback:t,tileClassName:n,iconPath:r=`assets/icon.svg`}){let[i,a]=f(!1),o=`/api/addon-assets/${e}/${r}`;return p(`div`,{className:`h-10 w-10 rounded-lg flex items-center justify-center shrink-0 ${n}`,children:i?p(t,{className:`h-5 w-5`}):p(`img`,{src:o,alt:e,className:`h-7 w-7 rounded-md bg-white p-1 ring-1 ring-black/5`,onError:()=>a(!0)})})}l();function D({addonId:e,defaultActivity:t,showActivity:n=!0,maxHeight:r=`max-h-64`,defaultTab:a,capability:o}){let[s,l]=f(t??(a===`events`?`events`:`logs`));return u(`div`,{className:`flex flex-col gap-4`,children:[p(T,{nodeId:`hub`,addonIds:[e],level:`global`,capability:o}),n&&u(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[u(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border bg-surface-hover/20`,children:[p(`span`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:`Activity`}),u(`div`,{className:`flex items-center gap-1`,children:[p(O,{kind:`logs`,active:s===`logs`,onClick:()=>l(`logs`)}),p(O,{kind:`events`,active:s===`events`,onClick:()=>l(`events`)})]})]}),s===`logs`?p(c,{addonId:e,maxHeight:r,showFilters:!1}):p(i,{addonId:e,category:`addon.*`,maxHeight:r})]})]})}function O({kind:e,active:t,onClick:n}){return u(`button`,{onClick:n,className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${t?`bg-primary/10 text-primary`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[p(e===`logs`?C:S,{className:`h-3 w-3`}),e===`logs`?`Logs`:`Events`]})}l();function k(t){let{title:i,subtitle:a,pageIcon:s,itemIcon:c,capability:l,installButtonLabel:d=`Add addon`,items:h,isLoading:_,emptyTitle:v=`No addons installed for this capability`,emptyDescription:x,itemIconColor:S,renderStatusBadges:C,renderPrimaryAction:T,itemError:O,renderExpandedPanel:k,workspaceMaxHeight:N=`max-h-72`,trailing:P,showChrome:F=!1}=t,I=h.length>1,[L,R]=f(()=>h[0]?.addonId??null);m(()=>{L&&(h.some(e=>e.addonId===L)||R(h[0]?.addonId??null))},[h,L]);let z=e=>R(t=>t===e?null:e),B=`/system/addons?capability=${encodeURIComponent(l)}`;return p(w,{icon:F?s:void 0,title:F?i:void 0,subtitle:F?a:void 0,actions:F?p(y,{to:B,children:u(o,{variant:`primary`,size:`sm`,children:[p(g,{className:`h-3.5 w-3.5 mr-1`}),d]})}):void 0,children:_?p(r,{children:p(`div`,{className:`p-6 text-sm text-foreground-subtle`,children:`Loading…`})}):h.length===0?p(r,{children:p(e,{title:v,description:x??`Install an addon that declares the "${l}" capability to get started.`,action:F?p(y,{to:B,children:u(o,{variant:`primary`,size:`sm`,children:[p(g,{className:`h-3.5 w-3.5 mr-1`}),d]})}):void 0})}):u(`div`,{className:`flex flex-col gap-4`,children:[h.map(e=>{let t=!I||L===e.addonId,i=S?.(e)??(e.isActive?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`),a=O?.(e)??null;return u(r,{children:[u(`div`,{className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-center ${t?`border-b border-border`:``}`,children:[u(`div`,{className:`flex items-center gap-3 flex-1 min-w-0`,children:[I&&p(`button`,{type:`button`,onClick:()=>z(e.addonId),"aria-label":t?`Collapse`:`Expand`,className:`shrink-0 p-1 rounded hover:bg-foreground-subtle/10 transition-colors`,children:p(b,{className:`h-4 w-4 text-foreground-subtle transition-transform ${t?`rotate-180`:``}`})}),u(`button`,{type:`button`,onClick:()=>I&&z(e.addonId),className:`flex items-center gap-4 flex-1 min-w-0 text-left ${I?`hover:opacity-80 transition-opacity`:``}`,disabled:!I,children:[p(E,{addonId:e.addonId,fallback:c,tileClassName:i}),u(`div`,{className:`flex-1 min-w-0`,children:[u(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[p(`span`,{className:`font-semibold text-foreground`,children:e.displayName}),p(A,{isActive:e.isActive}),C?.(e)]}),p(`div`,{className:`text-xs text-foreground-subtle mt-1 font-mono break-all`,children:e.addonId})]})]})]}),u(`div`,{className:`flex items-center gap-1 shrink-0 flex-wrap justify-end`,children:[T?.(e),p(j,{capName:e.capName??l,addonId:e.addonId,isActive:e.isActive}),p(M,{addonId:e.addonId,displayName:e.displayName})]})]}),t&&u(`div`,{className:`p-4 flex flex-col gap-3`,children:[a!==null&&p(n,{message:a}),k?.(e),p(D,{addonId:e.addonId,maxHeight:N,capability:e.capName??l})]})]},e.addonId)}),P]})})}function A({isActive:e}){return p(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${e?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`}`,children:e?`Enabled`:`Disabled`})}function j({capName:e,addonId:t,isActive:n}){let r=d(),i=a({onSuccess:()=>{r.invalidateQueries({queryKey:[[`addons`,`listCapabilityProviders`]]})}}),s=i.isPending;return u(o,{size:`sm`,variant:n?`secondary`:`primary`,disabled:s,onClick:()=>i.mutate({capName:e,addonId:t,enabled:!n}),children:[s?p(x,{className:`h-3 w-3 animate-spin`}):p(n?v:h,{className:`h-3 w-3`}),n?`Disable`:`Enable`]})}function M({addonId:e,displayName:n}){let r=d(),i=t({onSuccess:()=>{r.invalidateQueries({queryKey:[[`addons`,`listCapabilityProviders`]]})}});return p(s,{label:`Restart`,icon:_,size:`sm`,title:`Restart "${n}"?`,description:`Restarting the addon bounces its subprocess — the provider will briefly drop and reconnect automatically.`,confirmLabel:`Restart`,triggerVariant:`ghost`,confirmVariant:`danger`,disabled:i.isPending,action:()=>i.mutateAsync({addonId:e})})}export{k as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{At as e,Ct as t,Do as n,Et as r,Gr as i,Mt as a,Nt as o,Ot as s,Pt as c,Tt as l,_t as u,b as d,bt as f,g as p,gt as m,ht as h,kt as g,mt as _,v,vt as ee,wo as te,wt as ne,xo as re,xt as y,yt as ie,zr as b}from"./src-D9X1qL3P.js";import{I as x,K as S,Q as C,R as ae,S as w,W as T,b as E,o as oe,q as D,x as O,z as k}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{yt as A}from"./src-DhrZwy6-.js";import{p as se}from"./player-overlays-C8AKvjIL.js";import{t as j}from"./clock-DGDv9b38.js";import{t as M}from"./download-CuiiYAI6.js";import{t as ce}from"./plus-CteUN0IC.js";import{t as N}from"./refresh-cw-CeTudtXW.js";import{t as le}from"./search-Co_38A3R.js";import{t as P}from"./upload-BUxm_j1O.js";import{I as F,J as ue,K as de,L as I,M as fe,S as L,W as R,g as z,i as B,m as pe,p as V,s as H}from"./index-BAP-BLu1.js";import{t as U}from"./AdminPage-Dq33XE9j.js";import{t as me}from"./NodeAddonsSettingsPanel-DHMNNYDC.js";var he=R(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),W=R(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),G=R(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),K=R(`skip-forward`,[[`polygon`,{points:`5 4 15 12 5 20 5 4`,key:`16p6eg`}],[`line`,{x1:`19`,x2:`19`,y1:`5`,y2:`19`,key:`futhcm`}]]);C();var q=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),J=new Set([`done`,`failed`,`skipped`]);function Y(e){return!J.has(e.phase)&&!q.has(e.jobState)}function ge(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 _e(){let{data:e}=t({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:r}=n(A.AddonsJobProgress,e=>e.job.jobId);return T(()=>{let t=new Map;for(let n of e??[])t.set(n.jobId,n);for(let[e,n]of r)t.set(e,n.job);return ge([...t.values()],Date.now())},[e,r])}var X={queued:{icon:j,cls:`bg-muted text-foreground-subtle`,label:`queued`},fetching:{icon:L,cls:`bg-primary/10 text-primary`,label:`fetching`,spin:!0},staged:{icon:L,cls:`bg-primary/10 text-primary`,label:`staged`,spin:!0},validating:{icon:L,cls:`bg-primary/10 text-primary`,label:`validating`,spin:!0},applying:{icon:L,cls:`bg-primary/10 text-primary`,label:`applying`,spin:!0},restarting:{icon:L,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,label:`restarting`,spin:!0},applied:{icon:L,cls:`bg-primary/10 text-primary`,label:`finalizing`,spin:!0},done:{icon:I,cls:`bg-success/10 text-success`,label:`updated`},failed:{icon:W,cls:`bg-danger/10 text-danger`,label:`failed`},skipped:{icon:K,cls:`bg-muted text-foreground-subtle`,label:`skipped`}};function ve({progress:e}){let t=X[e.phase],n=t.icon,r=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return w(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${t.cls}`,title:r,children:[O(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label,w(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function ye({packageName:e,currentVersion:t,installSource:n,onInstall:r,onClose:i,onSelect:a,selectedVersion:o}){let s=n===`upload`||n===`local`,{data:c,isLoading:l}=ie({name:e});return w(`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:[w(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[O(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:`Versions`}),O(`button`,{type:`button`,onClick:i,className:`text-foreground-subtle hover:text-foreground`,children:O(B,{className:`h-3 w-3`})})]}),s&&w(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[O(P,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),w(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[w(`span`,{className:`font-semibold`,children:[n===`upload`?`Uploaded copy`:`Local copy`,` in place.`]}),` `,`Re-install `,O(`span`,{className:`font-mono`,children:t}),` from npm to track upstream releases again.`]})]}),l&&w(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[O(L,{className:`h-3.5 w-3.5 animate-spin`}),`Loading versions...`]}),c&&O(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:c.map(e=>{let n=e.version===t,i=a!==void 0&&e.version===o,c=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),l=w(E,{children:[O(`span`,{className:`font-mono flex-1 text-left ${n?`text-primary font-semibold`:c?`text-amber-400`:`text-foreground`}`,children:e.version}),n&&O(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:`current`}),e.distTags.map(e=>O(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),e.deprecated&&O(`span`,{className:`text-[9px] text-red-400 line-through`,children:`deprecated`}),O(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return a?w(`button`,{type:`button`,"aria-label":`Select ${e.version}`,onClick:()=>a(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${i?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[l,i?O(I,{className:`h-3 w-3 text-primary shrink-0`}):O(`span`,{className:`w-3 shrink-0`})]},e.version):w(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${n?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[l,n&&!s?O(I,{className:`h-3 w-3 text-primary shrink-0`}):O(`button`,{type:`button`,onClick:()=>r(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:n?`Re-install ${e.version} from npm`:`Install ${e.version}`,children:O(M,{className:`h-3 w-3`})})]},e.version)})}),c&&c.length===0&&O(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:`No versions found`})]})}var be={queued:{icon:j,bg:`bg-muted text-foreground-subtle`,label:`queued`},updating:{icon:L,bg:`bg-primary/10 text-primary`,label:`updating`,spin:!0},"done-pending-restart":{icon:N,bg:`bg-amber-500/10 text-amber-700`,label:`pending restart`},done:{icon:I,bg:`bg-success/10 text-success`,label:`done`},failed:{icon:W,bg:`bg-danger/10 text-danger`,label:`failed`}};function xe({item:e}){let t=be[e.status],n=t.icon;return w(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${t.bg}`,title:e.error,children:[O(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label]})}C();var Z=`device-export`;function Se(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===Z)}function Ce({isBundle:e,installSource:t,addonId:n,iconPath:r,color:i}){let[a,o]=D(!1),s=i?{backgroundColor:`${i.startsWith(`#`)?i:`#${i}`}26`}:void 0,c=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,l=n&&r?`/api/addon-assets/${n}/${r}`:null,u=!!l&&!a;return w(`div`,{className:`relative flex-shrink-0`,children:[O(`div`,{className:`h-9 w-9 rounded-lg flex items-center justify-center ${s?``:c}`,style:s,children:u?O(`img`,{src:l,alt:n,className:`h-5 w-5`,onError:()=>o(!0)}):O(e?G:z,{className:`h-4 w-4`})}),t===`local`&&O(`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`}),t===`npm`&&O(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:O(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:O(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),t===`upload`&&O(`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:O(P,{className:`h-2.5 w-2.5 text-white`})})]})}function we({version:e,availableUpdate:t,selectedVersion:n,isUpdating:r,installSource:i,disabled:a,onUpdate:o,onOpenPicker:s,children:c}){if(r)return w(`span`,{className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400 shrink-0`,children:[O(L,{className:`h-3 w-3 animate-spin`}),`Updating…`]});if(t){let r=n??t;return w(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[o&&w(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o()},disabled:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 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:`Update to ${r}`,children:[O(M,{className:`h-3 w-3`}),`Update`]}),w(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:a,"aria-label":`Select version to install`,title:`Installed ${e} — update available. Selected ${r}; tap to choose another version.`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 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:[O(`span`,{className:`font-normal opacity-70`,children:e}),O(`span`,{className:`font-normal opacity-70`,children:`→`}),r,O(F,{className:`h-3 w-3`})]}),c]})}return w(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[w(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:a,className:[`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,i===`local`?`border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20`].join(` `),title:`Version ${e} — tap to view all versions`,children:[e,O(F,{className:`h-3 w-3 opacity-50`})]}),c]})}function Te({addonId:t}){let n=oe(),{data:r=`inherit`}=m({addonId:t}),i=e({onSuccess:()=>{n.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return O(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(e=>O(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),i.mutate({addonId:t,channel:e})},disabled:i.isPending,className:`px-2.5 py-1 transition-colors capitalize ${r===e?e===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:e===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`: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===`inherit`?``:`border-l border-border`}`,children:e},e))})}function Ee({addon:e,agents:t=[],clusterStatus:n,hideVersion:i,availableUpdate:a,onUpdate:c,isUpdating:l,jobProgress:u,bundle:m,bulkItem:h,disabledByBulk:g,isSystem:_}){let[ee,te]=D(!1),[ne,y]=D(!1),[ie,b]=D(!1),[x,S]=D(null);k(()=>{S(null)},[a]);let C=x??a,[ae,T]=D(!1),[A,j]=D(!1),[M,le]=D(`logs`),P=oe(),ue=se(),I=de(),fe=re(),{manifest:L}=e,R=e.installedOn??[],z=!m&&!L.protected&&L.removable!==!1,U=!!m,K=m?.displayName??L.name,q=m?.packageName??L.packageName,J=m?.version??L.packageVersion??L.version,Y=m?.installSource??e.installSource,ge=m?m.bundle?.description??m.addons[0]?.manifest.description:L.description,_e=o({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]}),P.invalidateQueries({queryKey:[[`addonPages`]]}),P.invalidateQueries({queryKey:[[`capabilities`]]})}}),X=r({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]})}}),be=f({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]}),P.invalidateQueries({queryKey:[[`addonPages`]]}),P.invalidateQueries({queryKey:[[`capabilities`]]}),P.invalidateQueries({queryKey:[[`integrations`]]})}}),Z=s({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]}),P.invalidateQueries({queryKey:[[`alerts`]]})}}),Q=e.health,De=Q?.phase===`failed`&&!Q.inGracePeriod,Oe=De&&Q?.nextRetryAt&&!Q.retrying;return w(`div`,{className:`rounded-lg border bg-surface overflow-hidden ${De?`border-red-500/50`:`border-border`}`,children:[De&&Q&&w(`div`,{className:`bg-danger/10 border-b border-danger/30 px-4 py-2.5 flex items-start gap-2.5`,children:[O(W,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),w(`div`,{className:`flex-1 min-w-0`,children:[w(`div`,{className:`text-xs font-semibold text-danger`,children:[`Failed to load (attempt #`,Q.retryCount,`)`]}),O(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:Q.lastError?.message??`Unknown error`}),Oe&&Q.nextRetryAt&&w(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:[`Auto-retry at `,new Date(Q.nextRetryAt).toLocaleTimeString()]})]}),w(`button`,{type:`button`,disabled:Z.isPending||Q.retrying,onClick:e=>{e.stopPropagation(),Z.mutate({packageName:q})},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:`Reset retry counter and force immediate reload`,children:[O(N,{className:`h-3 w-3 ${Z.isPending||Q.retrying?`animate-spin`:``}`}),`Retry now`]})]}),w(`div`,{className:`flex items-start gap-3 px-4 py-3`,children:[O(Ce,{isBundle:U||!!L.components&&L.components.length>1,installSource:Y,addonId:U?m.addons[0]?.manifest.id:L.id,iconPath:U?m.bundle?.icon??m.addons[0]?.manifest.icon:L.icon,color:U?m.addons[0]?.manifest.color:L.color}),w(`div`,{className:`flex-1 min-w-0`,children:[w(`div`,{className:`flex items-start justify-between gap-2`,children:[O(`span`,{className:`text-sm font-semibold text-foreground truncate min-w-0`,children:K}),!i&&O(we,{version:J,availableUpdate:a,...C===void 0?{}:{selectedVersion:C},isUpdating:l,installSource:Y,disabled:g,...c&&C!==void 0?{onUpdate:()=>c(C)}:{},onOpenPicker:()=>b(e=>!e),children:ie&&O(ye,{packageName:q,currentVersion:J,...Y?{installSource:Y}:{},...a!==void 0&&C!==void 0?{selectedVersion:C,onSelect:e=>{S(e),b(!1)}}:{},onInstall:e=>{b(!1),be.mutate({packageName:q,version:e})},onClose:()=>b(!1)})})]}),w(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[q!==K&&O(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:q}),U&&w(`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:[O(G,{className:`h-3 w-3`}),m.addons.length]}),_&&w(`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:`System package — updating restarts the hub`,children:[O(N,{className:`h-3 w-3`}),`System`]}),h!=null&&O(xe,{item:h}),u!=null&&O(ve,{progress:u})]}),ge&&O(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:ge}),!U&&e.process&&w(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[O(`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`?`forked`:`in-process`}),e.process.pid!=null&&w(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),O(`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`:e.process.state===`crashed`||e.process.state===`failed`?`bg-red-500/15 text-red-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.state})]})]})]}),!U&&w(`div`,{className:`flex items-center gap-1 px-4 py-1.5 border-t border-border/50 bg-surface-hover/20`,children:[w(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),X.mutate({addonId:L.id})},disabled:X.isPending||g,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 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:[O(N,{className:`h-3 w-3 ${X.isPending?`animate-spin`:``}`}),`Restart`]}),w(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),T(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${ae?`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:[O(pe,{className:`h-3 w-3`}),`Logs`]}),!U&&w(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),j(!0)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${A?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[O(V,{className:`h-3 w-3`}),`Settings`]}),O(`div`,{className:`flex-1`}),z&&w(`button`,{type:`button`,onClick:async e=>{e.stopPropagation(),await fe({title:`Uninstall ${L.name}?`,message:`This will remove the addon package and all its data. This action cannot be undone.`,confirmLabel:`Uninstall`,variant:`danger`})&&_e.mutate({packageName:L.packageName})},disabled:_e.isPending||g,className:`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`,children:[O(H,{className:`h-3 w-3`}),_e.isPending?`Removing...`:`Uninstall`]})]}),n&&n.nodes.length>1&&!U&&w(`div`,{className:`border-t border-border px-4 py-2 bg-muted/10`,children:[O(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:`Cluster Deployment`}),O(`div`,{className:`space-y-1`,children:n.nodes.map(e=>w(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[O(`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`}`}),O(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),O(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&O(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:`outdated`}),e.status===`offline`&&O(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:`offline`}),e.synced&&e.status!==`offline`&&O(`span`,{className:`text-[9px] text-success`,children:`synced`})]},e.nodeId))})]}),ae&&!U&&w(`div`,{className:`border-t border-border`,children:[w(`div`,{className:`flex items-center px-4 py-1 bg-surface-hover/20 border-b border-border/50`,children:[w(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[O(`button`,{type:`button`,onClick:()=>le(`logs`),className:`px-2 py-0.5 transition-colors ${M===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Logs`}),O(`button`,{type:`button`,onClick:()=>le(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${M===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Events`})]}),O(`div`,{className:`flex-1`}),O(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),T(!1)},className:`text-foreground-subtle hover:text-foreground`,children:O(B,{className:`h-3.5 w-3.5`})})]}),M===`logs`&&O(v,{addonId:L.id,maxHeight:`max-h-64`,showFilters:!1}),M===`events`&&O(p,{addonId:L.id,category:`addon.*`,maxHeight:`max-h-64`})]}),U&&w(E,{children:[O(`button`,{type:`button`,onClick:()=>te(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:O(ee?he:F,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),ee&&O(`div`,{className:`border-t border-border px-3 py-2 space-y-2`,children:m.addons.map(e=>O(Ee,{addon:e,agents:t,hideVersion:!0},e.manifest.id))})]}),A&&!U&&O(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4`,onClick:()=>j(!1),children:w(`div`,{className:`w-full max-w-lg max-h-[80vh] rounded-xl border border-border bg-surface shadow-2xl flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[w(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-border flex-shrink-0`,children:[w(`div`,{className:`flex items-center gap-2`,children:[O(V,{className:`h-4 w-4 text-primary`}),w(`h2`,{className:`text-sm font-semibold text-foreground`,children:[K,` Settings`]})]}),O(`button`,{onClick:()=>j(!1),className:`text-foreground-subtle hover:text-foreground transition-colors p-1 rounded`,children:O(B,{className:`h-4 w-4`})})]}),w(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[O(me,{nodeId:`hub`,addonIds:[L.id],level:`global`}),Se(L)&&w(`div`,{children:[O(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Device export`}),O(d,{addonId:L.id,trpc:ue.trpcClient,onOpenDevice:e=>I(`/devices/${e}`)})]}),Y===`npm`&&w(`div`,{children:[O(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Auto-Update`}),O(Te,{addonId:L.id})]}),L.components&&L.components.length>0&&w(`div`,{children:[w(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Components (`,L.components.length,`)`]}),O(`div`,{className:`flex flex-wrap gap-1`,children:L.components.map(e=>O(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]}),t.length>=2&&w(`div`,{children:[O(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Installed on`}),w(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[R.length===0&&O(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Hub (local)`}),R.map(e=>O(`span`,{className:`rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle`,children:e},e)),w(`div`,{className:`relative`,children:[w(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),y(e=>!e)},className:`inline-flex items-center gap-1 rounded-full border border-dashed border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground hover:border-primary transition-colors`,title:`Install on more agents`,children:[O(ce,{className:`h-3 w-3`}),`Add agent`]}),ne&&w(`div`,{className:`absolute left-0 top-full mt-1 z-10 min-w-[160px] rounded-md border border-border bg-surface shadow-lg overflow-hidden`,children:[t.filter(e=>!e.isHub&&!R.includes(e.name)).map(e=>O(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),y(!1)},className:`w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors`,children:e.name},e.id)),t.filter(e=>!e.isHub&&!R.includes(e.name)).length===0&&O(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle`,children:`No available agents`})]})]})]})]})]}),O(`div`,{className:`flex items-center justify-end px-5 py-3 border-t border-border flex-shrink-0`,children:O(`button`,{type:`button`,onClick:()=>j(!1),className:`rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:`Close`})})]})})]})}C();var Q=`.tgz,.tar.gz,.zip`;function De({onUploadSuccess:e}){let[t,n]=D(!1),r=S(null),i=x(async t=>{n(!0);let r=new FormData;r.append(`file`,t);let i=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(`/api/addons/upload`,{method:`POST`,headers:{Authorization:`Bearer ${i}`},body:r})).json()).success&&e()}finally{n(!1)}},[e]);return w(E,{children:[O(`input`,{ref:r,type:`file`,accept:Q,onChange:x(e=>{let t=e.target.files?.[0];t&&i(t),e.target.value=``},[i]),className:`hidden`}),w(`button`,{type:`button`,onClick:()=>r.current?.click(),disabled:t,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:[t?O(L,{className:`w-3.5 h-3.5 animate-spin`}):O(P,{className:`w-3.5 h-3.5`}),t?`Uploading...`:`Upload`]})]})}C();var Oe=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/shm-ring`,`@camstack/ui-library`]);function ke(e){return e!==void 0&&Oe.has(e)}function Ae(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function je(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`}: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 Me(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 Ne({addons:e,clusterStatus:t,selectedNode:n,onRefresh:r,isRefreshing:i}){let o=oe(),[s,l]=D(``),d=ae(s),[p,m]=D(!1),h=S(null);k(()=>{if(!p)return;let e=e=>{h.current&&!h.current.contains(e.target)&&m(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[p]);let{data:v}=ne({nodeId:n.id}),te=T(()=>{let e=new Map;for(let t of v??[])e.set(t.name,t.latestVersion);return e},[v]),y=T(()=>(v??[]).filter(e=>!e.isSystem).length,[v]),[ie,b]=D(()=>new Set),[C,E]=D(()=>new Map),A=x(e=>{b(t=>new Set(t).add(e))},[]),se=x(e=>{b(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),j=x((e,t)=>{E(n=>new Map(n).set(e,t))},[]),ce=x(e=>{E(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),P=c({onMutate:e=>{A(e.name),ce(e.name)},onSuccess:(e,t)=>{se(t.name);let n=e;if(n&&n.success===!1){j(t.name,n.error??`Update failed (no error message returned by server)`);return}o.invalidateQueries({queryKey:[[`addons`]]}),o.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{se(t.name),j(t.name,e instanceof Error?e.message:String(e))}}),F=_e(),de=S(new Set);k(()=>{let e=new Set;for(let[t,n]of F)Y(n)&&e.add(t);let t=[...de.current].some(t=>!e.has(t));de.current=e,t&&(o.invalidateQueries({queryKey:[[`addons`]]}),o.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[F,o]);let{data:R}=u(void 0),z=_({onSuccess:()=>{o.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:B,isFetching:pe}=g({query:d||void 0},{enabled:p}),V=a(),{data:H}=ee(void 0),U=H?.requestedAt,[me,he]=D(null),[W,G]=D(!1);k(()=>{if(H?.kind===`framework-bulk-update`&&H.requestedAt!==me){he(H.requestedAt),G(!0);let e=window.setTimeout(()=>G(!1),6e3);return()=>window.clearTimeout(e)}},[U,me,H]),re();let K=x(async()=>{let e=(v??[]).filter(e=>!e.isSystem);if(e.length!==0){if(!n.isHub){for(let t of e)await P.mutateAsync({name:t.name,version:t.latestVersion,nodeId:n.id});return}await V.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[n.id]})}},[v,n.id,n.isHub,V,P]),q=f({onSuccess:()=>{o.invalidateQueries({queryKey:[[`addons`]]}),o.invalidateQueries({queryKey:[[`addonPages`]]}),o.invalidateQueries({queryKey:[[`capabilities`]]}),o.invalidateQueries({queryKey:[[`integrations`]]})}}),[J,ge]=D(`type`),[X,ve]=D(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),ye=e=>{ve(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[be,xe]=ue(),Z=be.get(`capability`),Se=T(()=>{let t=e.filter(e=>!ke(e.manifest.packageName));return n.isHub||(t=t.filter(e=>Ae(e.placement,n.isHub))),Z&&(t=t.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===Z))),t},[e,n.isHub,Z]),Ce=()=>{let e=new URLSearchParams(be);e.delete(`capability`),xe(e,{replace:!0})},we=X===`flat`?Se:Me(Se),Te=T(()=>{let e=[...we];switch(J){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},[we,J]);return w(`div`,{className:`space-y-4`,children:[[...C.entries()].map(([e,t])=>O(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px]`,children:w(`div`,{className:`flex items-start justify-between gap-3`,children:[w(`div`,{className:`space-y-0.5`,children:[w(`div`,{className:`font-medium text-danger`,children:[`Failed to update `,e]}),O(`div`,{className:`text-foreground-subtle font-mono`,children:t})]}),O(`button`,{type:`button`,onClick:()=>ce(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:`dismiss`})]})},e)),w(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[w(`div`,{className:`flex items-center gap-1.5`,children:[O(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Sort:`}),w(`select`,{value:J,onChange:e=>ge(e.target.value),className:`rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] text-foreground focus:outline-none focus:border-primary/50`,children:[O(`option`,{value:`type`,children:`Bundles first`}),O(`option`,{value:`name`,children:`Name`}),O(`option`,{value:`source`,children:`Install source`})]})]}),w(`div`,{className:`flex items-center gap-1.5`,children:[O(`span`,{className:`text-[10px] text-foreground-subtle`,children:`View:`}),O(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>O(`button`,{type:`button`,onClick:()=>ye(e),className:`px-2.5 py-1.5 transition-colors capitalize ${X===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?`Group multi-addon packages into a bundle card`:`Show every addon as its own card`,children:e},e))})]}),n.isHub&&w(`div`,{className:`flex items-center gap-1.5`,children:[O(N,{className:`h-3 w-3 text-foreground-subtle`}),O(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Auto-Update:`}),O(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>O(`button`,{type:`button`,onClick:()=>z.mutate({channel:e}),disabled:z.isPending,className:`px-2.5 py-1.5 transition-colors capitalize ${R?.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))})]}),y>0&&w(`button`,{type:`button`,onClick:()=>void K(),disabled:V.isPending,className:`flex items-center gap-1.5 px-2.5 py-1.5 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:[V.isPending?O(L,{className:`w-3 h-3 animate-spin`}):O(M,{className:`w-3 h-3`}),V.isPending?`Updating…`:`Update All (${y})`]}),w(`button`,{type:`button`,onClick:r,disabled:i||V.isPending,className:`flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[O(N,{className:`w-3 h-3 ${i?`animate-spin`:``}`}),`Refresh`]})]}),w(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[w(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:h,children:[O(le,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),O(`input`,{type:`text`,value:s,onChange:e=>{l(e.target.value),m(!0)},onFocus:()=>m(!0),placeholder:`Search addons on npm...`,disabled:V.isPending,className:`w-full rounded-lg border border-border bg-background pl-9 pr-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 disabled:cursor-not-allowed`}),pe&&O(L,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin`}),p&&B&&B.length>0&&w(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,children:[B.length>0&&w(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[`npm results (`,B.length,`)`]}),B&&B.length>0&&O(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:B.map(e=>w(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[O(`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()}),w(`div`,{className:`flex-1 min-w-0`,children:[w(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[O(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),w(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),O(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&O(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?w(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md border border-emerald-500/30 bg-emerald-500/10 text-emerald-400 shrink-0`,children:[O(I,{className:`h-3 w-3`}),e.installedVersion??`Installed`]}):w(`button`,{type:`button`,onClick:()=>q.mutate({packageName:e.name}),disabled:q.isPending,className:`inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0`,children:[q.isPending?O(L,{className:`h-3 w-3 animate-spin`}):O(M,{className:`h-3 w-3`}),`Install`]})]},e.name))})]})]}),O(De,{onUploadSuccess:()=>{o.invalidateQueries({queryKey:[[`addons`]]}),r()}})]}),Z&&w(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-primary/10 border border-primary/30 text-sm`,children:[O(`span`,{className:`text-foreground-subtle`,children:`Filtering by capability:`}),O(`span`,{className:`font-mono text-primary font-semibold`,children:Z}),O(`button`,{type:`button`,onClick:Ce,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:`Clear`})]}),W&&w(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg backdrop-blur-sm max-w-sm pointer-events-auto`,children:[O(fe,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),w(`div`,{children:[O(`div`,{className:`text-[11px] font-semibold text-foreground`,children:`Bulk update completed`}),O(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:`System packages updated — hub restarted successfully.`})]})]}),Se.length===0&&O(`div`,{className:`text-xs text-foreground-subtle`,children:e.length===0?`No addons installed`:Z?`No installed addons declare the "${Z}" capability. Browse the npm catalog above to find a compatible addon.`:`No addons compatible with ${n.name} (placement filter active)`}),O(`div`,{className:`space-y-2`,children:Te.map(e=>{let r=$(e)?e.bundle.packageName:e.manifest.packageName,i=te.get(r),a=$(e)?e.representative:e,o=i?e=>P.mutate({name:r,version:e,nodeId:n.id}):void 0,s=F.get(r)??null,c=s!==null&&Y(s);return O(Ee,{addon:a,clusterStatus:t?.[a.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:i,isUpdating:ie.has(r)||c,jobProgress:s,onUpdate:o,disabledByBulk:V.isPending},$(e)?r:e.manifest.id)})})]})}function Pe(){let e=oe(),{data:t,isLoading:n,isError:r}=y(),{data:a}=b(void 0),{data:o}=i(void 0,{refetchInterval:1e4}),s=T(()=>{let e=new Map;e.set(`hub`,{id:`hub`,name:`Hub`,isHub:!0});for(let t of o??[]){let n=String(t.id??``);n&&e.set(n,{id:n,name:String(t.name??n),isHub:!!t.isHub})}return[...e.values()]},[o]),[c,u]=D(`hub`),d=s.find(e=>e.id===c)??s[0],f=h(),p=l(),m=f.isPending||p.isPending,g=async()=>{await f.mutateAsync({nodeId:c}),await p.mutateAsync(),e.invalidateQueries({queryKey:[[`addons`]]})},_=S(f);_.current=f,k(()=>{_.current.mutate({nodeId:`hub`})},[]);let v=(t??[]).map(je).filter(e=>e!==null);return w(U,{children:[w(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[O(te,{selectedNodeId:c,onSelect:u}),w(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[!n&&!r&&w(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:[v.length,` installed`]}),w(`button`,{type:`button`,onClick:()=>void g(),disabled:m,className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,title:`Re-fetch addons + check npm for new versions`,children:[O(N,{className:`w-3 h-3 ${m?`animate-spin`:``}`}),`Check for updates`]})]})]}),!d.isHub&&w(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle`,children:[`Showing only addons compatible with`,` `,O(`span`,{className:`font-medium text-foreground`,children:d.name}),` — agents only run`,` `,O(`code`,{className:`font-mono`,children:`agent-only`}),` and`,` `,O(`code`,{className:`font-mono`,children:`any-node`}),` addons. Install / uninstall is hub-driven; agents auto-sync from the hub.`]}),n&&O(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading…`}),r&&O(`div`,{className:`text-xs text-danger`,children:`Failed to load addons`}),!n&&!r&&O(Ne,{addons:v,clusterStatus:a,selectedNode:d,onRefresh:()=>void g(),isRefreshing:m})]})}export{Pe as AddonsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{So as e,cs as t,fs as n,ms as r,ps as i,w as a,wo as o}from"./src-D9X1qL3P.js";import{Q as s,S as c,W as l,a as u,q as d,t as f,x as p}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p as m}from"./player-overlays-C8AKvjIL.js";import{t as h}from"./pencil-BejnV1Fc.js";import{t as g}from"./plus-CteUN0IC.js";import{t as _}from"./send-DJH3Zx9e.js";import{t as v}from"./server-CiKv0Gaj.js";import{S as y,l as b,s as x}from"./index-BAP-BLu1.js";import{t as S}from"./AdminPage-Dq33XE9j.js";s();var C=`__redacted__`,w=`ai`,T=[`llm`,`listProfiles`],E=[`llm`,`listProfileKinds`],D=[`llm`,`getDefaults`],O=[`llm`,`listRuntimeNodes`],k=[{purpose:`vision`,label:`Default vision profile`,visionOnly:!0},{purpose:`text`,label:`Default text profile`,visionOnly:!1}],A=[`llm`,`listModelCatalog`],j=[`llm`,`getUsage`];function M(e){return typeof e==`string`&&e.length>0?e:void 0}function N(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:void 0}}function P(e){return e===!0}function F(e){return{model:e.model,baseUrl:e.baseUrl,apiKey:e.apiKey,supportsVision:e.supportsVision,temperature:e.temperature,maxTokens:e.maxTokens,timeoutMs:e.timeoutMs,contextSize:e.runtime?.contextSize,gpuLayers:e.runtime?.gpuLayers,threads:e.runtime?.threads,parallel:e.runtime?.parallel,idleStopMinutes:e.runtime?.idleStopMinutes}}function I(e,t,n){return{nodeId:t,engine:`llama-cpp`,model:{kind:`catalog`,catalogId:n},contextSize:N(e.contextSize)??4096,gpuLayers:N(e.gpuLayers)??0,...N(e.threads)===void 0?{}:{threads:N(e.threads)},parallel:N(e.parallel)??1,autoStart:P(e.autoStart),idleStopMinutes:N(e.idleStopMinutes)??30}}function L(e,t,n,r,i){let a={id:n?.id??crypto.randomUUID(),name:t,kind:e,addonId:w,enabled:n?.enabled??!0,model:M(r.model)??n?.model??``,supportsVision:i?.supportsVision??P(r.supportsVision),timeoutMs:N(r.timeoutMs)??6e4},o=M(r.baseUrl),s=M(r.apiKey),c=N(r.temperature),l=N(r.maxTokens);return{...a,...o===void 0?{}:{baseUrl:o},...s===void 0?{}:{apiKey:s},...c===void 0?{}:{temperature:c},...l===void 0?{}:{maxTokens:l},...i===void 0?{}:{model:i.catalogId,runtime:I(r,i.nodeId,i.catalogId)}}}function R(e){let t=new Map;for(let n of e){let e=t.get(n.addonId)??[];e.push(n),t.set(n.addonId,e)}return t}function z(){let t=m(),[n,i]=d(`profiles`),[a,o]=d({mode:`closed`}),[s,l]=d(null),h=u({queryKey:T,queryFn:()=>t.trpcClient.llm.listProfiles.query({})}),_=u({queryKey:E,queryFn:async()=>(await t.trpcClient.llm.listProfileKinds.query({})).map(e=>({...e,configSchema:e.configSchema}))}),v=()=>{h.refetch()},y=f({mutationFn:e=>t.trpcClient.llm.upsertProfile.mutate({profile:e}),onSuccess:()=>{o({mode:`closed`}),v()}}),x=f({mutationFn:e=>t.trpcClient.llm.deleteProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:v}),w=f({mutationFn:e=>t.trpcClient.llm.testProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:(e,t)=>l({id:t.id,ok:e.ok,text:e.ok?`${e.text} (${e.usage.outputTokens} tok, ${e.latencyMs}ms)`:`${e.code}: ${e.message}`})}),D=e=>y.mutate({...e,enabled:!e.enabled,apiKey:C}),O=h.data??[];return c(S,{icon:b,title:`AI`,subtitle:`LLM profiles, managed runtimes and usage`,actions:c(r,{onClick:()=>o({mode:`pick-kind`}),children:[p(g,{className:`h-4 w-4`}),` Add profile`]}),children:[p(`div`,{className:`mb-4 flex gap-2`,children:[`profiles`,`runtimes`,`usage`].map(e=>p(r,{variant:n===e?`primary`:`ghost`,onClick:()=>i(e),children:e[0].toUpperCase()+e.slice(1)},e))}),h.error!=null&&p(e,{message:String(h.error)}),n===`profiles`&&p(B,{profiles:O}),n===`profiles`&&p(V,{profiles:O,testResult:s,onToggle:D,onEdit:e=>{let t=_.data?.find(t=>t.kind===e.kind);t!==void 0&&o({mode:`form`,kind:t,profile:e})},onTest:e=>w.mutate(e),onDelete:e=>x.mutate(e)}),n===`runtimes`&&p(W,{}),n===`usage`&&p(G,{profiles:O}),a.mode===`pick-kind`&&p(H,{kinds:_.data??[],onPick:e=>o({mode:`form`,kind:e,profile:null}),onCancel:()=>o({mode:`closed`})}),a.mode===`form`&&p(U,{kind:a.kind,existing:a.profile,catalog:a.kind.kind===`managed-local`,onSave:e=>y.mutate(e),onCancel:()=>o({mode:`closed`}),saving:y.isPending})]})}function B({profiles:e}){let t=m(),r=u({queryKey:D,queryFn:()=>t.trpcClient.llm.getDefaults.query({})}),i=f({mutationFn:e=>t.trpcClient.llm.setDefault.mutate({selector:{purpose:e.purpose},profileId:e.profileId}),onSuccess:()=>{r.refetch()}}),a=e=>(r.data??[]).find(t=>`purpose`in t.selector&&t.selector.purpose===e)?.profileId??``;return p(n,{children:p(`div`,{className:`grid gap-4 p-4 sm:grid-cols-2`,children:k.map(({purpose:t,label:n,visionOnly:r})=>{let o=r?e.filter(e=>e.supportsVision):e,s=a(t),l=e.find(e=>e.id===s);return c(`div`,{children:[p(`label`,{className:`mb-1 block text-sm font-medium`,htmlFor:`llm-default-${t}`,children:n}),c(`select`,{id:`llm-default-${t}`,"aria-label":n,className:`w-full rounded-md border border-border bg-background p-2 text-sm`,value:s,onChange:e=>i.mutate({purpose:t,profileId:e.target.value===``?null:e.target.value}),children:[p(`option`,{value:``,children:`None`}),s!==``&&!o.some(e=>e.id===s)&&p(`option`,{value:s,children:l?.name??s}),o.map(e=>c(`option`,{value:e.id,children:[e.name,` · `,e.model]},e.id))]}),s!==``&&l===void 0&&c(`p`,{className:`mt-1 text-xs text-danger`,children:[`This default names a profile that no longer exists (`,s,`).`]}),l!==void 0&&!l.enabled&&p(`p`,{className:`mt-1 text-xs text-warning`,children:`This default profile is disabled — callers resolve to no profile.`}),i.error!=null&&p(`p`,{className:`mt-1 text-xs text-danger`,children:String(i.error)})]},t)})})})}function V({profiles:e,testResult:a,onToggle:o,onEdit:s,onTest:l,onDelete:u}){return e.length===0?p(n,{children:p(`p`,{className:`p-4 text-sm text-foreground-subtle`,children:`No profiles yet.`})}):p(n,{children:p(`ul`,{className:`divide-y divide-border`,children:e.map(e=>c(`li`,{className:`flex items-center gap-3 p-3`,children:[p(`span`,{className:`text-lg`,children:e.kind===`managed-local`?`🖥️`:`🔌`}),c(`div`,{className:`min-w-0 flex-1`,children:[c(`div`,{className:`flex items-center gap-2`,children:[p(`span`,{className:`truncate font-medium`,children:e.name}),e.kind===`managed-local`&&e.runtime!==void 0&&p(i,{variant:`info`,children:e.runtime.nodeId}),!e.enabled&&p(i,{variant:`warning`,children:`disabled`})]}),c(`p`,{className:`truncate text-xs text-foreground-subtle`,children:[e.kind,` · `,e.model]}),a?.id===e.id&&p(`p`,{className:`text-xs ${a.ok?`text-success`:`text-danger`}`,children:a.text})]}),p(t,{checked:e.enabled,onCheckedChange:()=>o(e)}),p(r,{variant:`ghost`,onClick:()=>l(e),title:`Test`,children:p(_,{className:`h-4 w-4`})}),p(r,{variant:`ghost`,onClick:()=>s(e),title:`Edit`,children:p(h,{className:`h-4 w-4`})}),p(r,{variant:`ghost`,onClick:()=>u(e),title:`Delete`,children:p(x,{className:`h-4 w-4`})})]},e.id))})})}function H({kinds:e,onPick:t,onCancel:i}){let a=l(()=>R(e),[e]);return p(n,{children:c(`div`,{className:`p-4`,children:[p(`h3`,{className:`mb-3 font-medium`,children:`Choose a profile type`}),[...a.entries()].map(([e,n])=>p(`div`,{className:`mb-3`,children:p(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:n.map(e=>c(r,{variant:`ghost`,onClick:()=>t(e),children:[p(`span`,{className:`mr-2`,children:e.icon}),e.label]},e.kind))})},e)),p(r,{variant:`ghost`,onClick:i,children:`Cancel`})]})})}function U({kind:e,existing:t,catalog:i,onSave:s,onCancel:l,saving:f}){let h=m(),[g,_]=d(t?.name??``),[v,b]=d(t===null?{}:F(t)),[x,S]=d(t?.runtime?.nodeId??`hub`),[C,w]=d(t?.runtime?.model.kind===`catalog`?t.runtime.model.catalogId:``),T=u({queryKey:A,enabled:i,queryFn:()=>h.trpcClient.llm.listModelCatalog.query({})});return p(n,{children:c(`div`,{className:`space-y-4 p-4`,children:[c(`h3`,{className:`font-medium`,children:[t===null?`New`:`Edit`,` `,e.label]}),c(`label`,{className:`block text-sm`,children:[p(`span`,{className:`text-foreground-subtle`,children:`Name`}),p(`input`,{className:`mt-1 w-full rounded border border-border bg-background px-2 py-1`,value:g,onChange:e=>_(e.target.value)})]}),i&&c(`div`,{className:`space-y-3`,children:[p(o,{selectedNodeId:x,onSelect:S,label:`Runtime node`,alwaysShow:!0}),c(`label`,{className:`block text-sm`,children:[p(`span`,{className:`text-foreground-subtle`,children:`Model`}),c(`select`,{className:`mt-1 w-full rounded border border-border bg-background px-2 py-1`,value:C,onChange:e=>w(e.target.value),children:[p(`option`,{value:``,children:`Select a model…`}),(T.data??[]).map(e=>c(`option`,{value:e.id,children:[e.label,` · `,e.quantization,` ·`,` `,(e.sizeBytes/1e9).toFixed(1),` GB`]},e.id))]})]})]}),p(a,{schema:e.configSchema,values:v,onChange:b}),c(`div`,{className:`flex gap-2`,children:[c(r,{onClick:()=>{if(i){let n=T.data?.find(e=>e.id===C);s(L(e.kind,g,t,v,{nodeId:x,catalogId:C,supportsVision:n?.purpose===`vision`}))}else s(L(e.kind,g,t,v))},disabled:f||g.trim()===``||i&&C===``,children:[f&&p(y,{className:`h-4 w-4 animate-spin`}),` Save`]}),p(r,{variant:`ghost`,onClick:l,children:`Cancel`})]})]})})}function W(){let e=m(),t=u({queryKey:O,refetchInterval:5e3,queryFn:()=>e.trpcClient.llm.listRuntimeNodes.query({})}).data??[];return t.length===0?p(n,{children:p(`p`,{className:`p-4 text-sm text-foreground-subtle`,children:`No runtime nodes advertise the llm-runtime capability.`})}):p(n,{children:p(`ul`,{className:`divide-y divide-border`,children:t.map(e=>c(`li`,{className:`flex items-center gap-3 p-3`,children:[p(v,{className:`h-4 w-4 text-foreground-subtle`}),c(`div`,{className:`min-w-0 flex-1`,children:[c(`div`,{className:`flex items-center gap-2`,children:[p(`span`,{className:`font-medium`,children:e.nodeId}),p(i,{variant:e.reachable?`success`:`danger`,children:e.reachable?e.status?.state??`ready`:`unreachable`}),e.status?.downloadProgress!==void 0&&c(i,{variant:`info`,children:[Math.round(e.status.downloadProgress*100),`%`]})]}),c(`p`,{className:`truncate text-xs text-foreground-subtle`,children:[e.status?.modelId??`—`,e.disk!==void 0&&` · ${(e.disk.modelsBytes/1e9).toFixed(1)} GB on disk`,e.error!==void 0&&` · ${e.error}`]})]})]},e.nodeId))})})}function G({profiles:e}){let t=m(),r=l(()=>Date.now()-10080*60*1e3,[]),i=u({queryKey:[...j,r],queryFn:()=>t.trpcClient.llm.getUsage.query({since:r})}),a=t=>e.find(e=>e.id===t)?.name??t,o=i.data??[];return o.length===0?p(n,{children:p(`p`,{className:`p-4 text-sm text-foreground-subtle`,children:`No usage in the last 7 days.`})}):p(n,{children:p(`div`,{className:`overflow-x-auto`,children:c(`table`,{className:`w-full text-sm`,children:[p(`thead`,{children:c(`tr`,{className:`text-left text-foreground-subtle`,children:[p(`th`,{className:`p-2`,children:`Day`}),p(`th`,{className:`p-2`,children:`Consumer`}),p(`th`,{className:`p-2`,children:`Profile`}),p(`th`,{className:`p-2`,children:`Calls`}),p(`th`,{className:`p-2`,children:`OK/Err`}),p(`th`,{className:`p-2`,children:`In/Out tok`}),p(`th`,{className:`p-2`,children:`Avg ms`})]})}),p(`tbody`,{children:o.map(e=>c(`tr`,{className:`border-t border-border`,children:[p(`td`,{className:`p-2`,children:e.day}),p(`td`,{className:`p-2`,children:e.consumer}),p(`td`,{className:`p-2`,children:a(e.profileId)}),p(`td`,{className:`p-2`,children:e.calls}),c(`td`,{className:`p-2`,children:[e.okCalls,`/`,e.errorCalls]}),c(`td`,{className:`p-2`,children:[e.inputTokens,`/`,e.outputTokens]}),p(`td`,{className:`p-2`,children:Math.round(e.avgLatencyMs)})]},`${e.day}|${e.consumer}|${e.profileId}`))})]})})})}export{z as AiProfilesPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{So as e}from"./src-D9X1qL3P.js";import{Q as t,S as n,W as r,a as i,q as a,t as o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p as c}from"./player-overlays-C8AKvjIL.js";import{t as l}from"./circle-check-big-CUWMrtHz.js";import{N as u,S as d,d as f}from"./index-BAP-BLu1.js";import{t as p}from"./AdminPage-Dq33XE9j.js";t();var m={detection:`border-green-500`,detector:`border-green-500`,streaming:`border-blue-500`,decode:`border-blue-500`,decoder:`border-blue-500`,recording:`border-orange-500`,recorder:`border-orange-500`,transcoding:`border-purple-500`,transcoder:`border-purple-500`,restream:`border-cyan-500`,restreamer:`border-cyan-500`,storage:`border-yellow-500`,notification:`border-pink-500`,notifier:`border-pink-500`,faces:`border-indigo-500`},h={detection:`bg-green-500/5`,detector:`bg-green-500/5`,streaming:`bg-blue-500/5`,decode:`bg-blue-500/5`,decoder:`bg-blue-500/5`,recording:`bg-orange-500/5`,recorder:`bg-orange-500/5`,transcoding:`bg-purple-500/5`,transcoder:`bg-purple-500/5`,restream:`bg-cyan-500/5`,restreamer:`bg-cyan-500/5`,storage:`bg-yellow-500/5`,notification:`bg-pink-500/5`,notifier:`bg-pink-500/5`,faces:`bg-indigo-500/5`};function g({entry:e,actions:t}){let r=e.name.toLowerCase(),i=m[r]??`border-primary`,a=h[r]??`bg-primary/5`,o=e.providers.find(e=>e.active),c=t?.pendingCapability===e.name;return n(`div`,{className:`rounded-lg border-t-2 border border-border ${i} ${a} p-3 space-y-2`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[n(`span`,{className:`text-xs font-semibold text-foreground capitalize flex items-center gap-1.5`,children:[e.name,c&&s(d,{className:`h-3 w-3 animate-spin text-primary`})]}),s(`span`,{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ${e.mode===`singleton`?`bg-primary/10 text-primary`:`bg-info/10 text-info`}`,children:e.mode})]}),e.mode===`singleton`?s(_,{entry:e,actions:t,activeProvider:o,isPending:c}):s(v,{entry:e,actions:t,isPending:c})]})}function _({entry:e,actions:t,activeProvider:r,isPending:i}){if(!t)return s(`div`,{children:r?n(`div`,{className:`flex items-center gap-1.5 text-[10px] text-foreground`,children:[s(l,{className:`h-3 w-3 text-green-400 shrink-0`}),s(`span`,{className:`font-medium`,children:r.addonName}),s(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto`,children:`ACTIVE`})]}):s(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No active provider`})});if(e.providers.length===0)return s(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No providers`});let a=`__inherit__`;return n(`div`,{className:`space-y-2`,children:[s(`div`,{className:`space-y-1`,children:e.providers.map(r=>{let a=r.active;return n(`button`,{type:`button`,disabled:i||a,onClick:()=>t.onSelectSingleton(e.name,r.addonId),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${a?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[s(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${a?`border-green-400 bg-green-400`:`border-border`}`}),s(`span`,{className:`font-medium truncate`,children:r.addonName}),a&&s(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},r.addonId)})}),e.perNode&&e.perNode.length>0&&s(`div`,{className:`space-y-2 pt-1 border-t border-border/40`,children:e.perNode.map(r=>{let o=r.hasOverride&&r.resolvedActive?r.resolvedActive:a,c=[{value:a,label:`Inherit global${r.resolvedActive?` (${r.resolvedActive})`:``}`},...r.providers.map(e=>({value:e,label:e}))],l=n=>{n===a?t.onClearNodeSingleton(e.name,r.nodeId):t.onSelectNodeSingleton(e.name,r.nodeId,n)},u=i;return n(`div`,{className:`space-y-0.5`,children:[n(`div`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60 px-1.5`,children:[r.nodeId,r.hasOverride&&s(`span`,{className:`ml-1.5 rounded-full bg-primary/10 text-primary px-1 py-0.5 normal-case tracking-normal font-medium`,children:`override`})]}),c.map(e=>{let t=o===e.value;return n(`button`,{type:`button`,disabled:u||t,onClick:()=>l(e.value),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${t?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[s(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${t?`border-green-400 bg-green-400`:`border-border`}`}),s(`span`,{className:`font-medium truncate`,children:e.label}),t&&e.value!==a&&s(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},e.value)})]},r.nodeId)})})]})}function v({entry:e,actions:t,isPending:r}){if(e.providers.length===0)return s(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No providers`});if(!t)return s(`div`,{className:`space-y-1`,children:e.providers.map(e=>n(`div`,{className:`flex items-center justify-between gap-2 text-[10px]`,children:[s(`span`,{className:`text-foreground-subtle`,children:e.addonName}),e.active&&s(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium`,children:`ACTIVE`})]},e.addonId))});let i=e.providers.filter(e=>e.active).map(e=>e.addonId),a=(n,r)=>{let a=r?[...new Set([...i,n])]:i.filter(e=>e!==n);t.onToggleCollection(e.name,a)};return s(`div`,{className:`space-y-1`,children:e.providers.map(e=>n(`label`,{className:`flex items-center justify-between gap-2 text-[10px] rounded px-1.5 py-1 transition-colors ${r?`opacity-50`:`hover:bg-surface-hover cursor-pointer`}`,children:[n(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[s(`input`,{type:`checkbox`,checked:e.active,disabled:r,onChange:t=>a(e.addonId,t.target.checked),className:`h-3 w-3 accent-green-500 shrink-0`}),s(`span`,{className:`text-foreground truncate`,children:e.addonName})]}),e.active&&s(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium shrink-0`,children:`ACTIVE`})]},e.addonId))})}function y({capabilities:e,actions:t}){return e.length===0?s(`div`,{className:`text-xs text-foreground-subtle text-center py-8`,children:`No capabilities registered`}):s(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:e.map(e=>s(g,{entry:e,actions:t},e.name))})}var b=[`capabilities`,`listCapabilities`];function x(e){return e===`singleton`||e===`collection`}function S(e){let t=e.indexOf(`@`);return t===-1?`${e} (hub)`:`${e.slice(0,t)} (${e.slice(t+1)})`}function C(e,t){return{name:e.name,mode:t,providers:e.providers.map(n=>({addonId:n,addonName:S(n),active:t===`singleton`?e.activeProvider===n:!e.disabledProviders.includes(n)})),...t===`singleton`&&e.perNode?{perNode:e.perNode}:{}}}function w(){let t=c(),[d,m]=a(null),[h,g]=a(null),_=i({queryKey:b,queryFn:()=>t.trpcClient.capabilities.listCapabilities.query()}),v=r(()=>{let e=(_.data??[]).flatMap(e=>x(e.mode)?[C(e,e.mode)]:[]),t=e.filter(e=>e.mode===`singleton`).toSorted((e,t)=>e.name.localeCompare(t.name)),n=e.filter(e=>e.mode===`collection`).toSorted((e,t)=>e.name.localeCompare(t.name));return[...t,...n]},[_.data]),S=r(()=>v.filter(e=>e.mode===`singleton`),[v]),w=r(()=>v.filter(e=>e.mode===`collection`),[v]),T=o({mutationFn:e=>t.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName} → ${t.addonId} is now active.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to set ${t.capName}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),E=o({mutationFn:e=>t.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId,nodeId:e.nodeId}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName} @ ${t.nodeId} → ${t.addonId}.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to set ${t.capName} @ ${t.nodeId}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),D=o({mutationFn:e=>t.trpcClient.capabilities.clearSingletonNodeOverride.mutate({capability:e.capName,nodeId:e.nodeId}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName} @ ${t.nodeId} now inherits the global default.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to clear ${t.capName} @ ${t.nodeId}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),O=o({mutationFn:e=>t.trpcClient.capabilities.setCollectionEnabledProviders.mutate({capability:e.capName,enabledAddonIds:[...e.enabledAddonIds]}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName}: ${t.enabledAddonIds.length} provider(s) enabled.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to update ${t.capName}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),k={onSelectSingleton:(e,t)=>T.mutate({capName:e,addonId:t}),onSelectNodeSingleton:(e,t,n)=>E.mutate({capName:e,nodeId:t,addonId:n}),onClearNodeSingleton:(e,t)=>D.mutate({capName:e,nodeId:t}),onToggleCollection:(e,t)=>O.mutate({capName:e,enabledAddonIds:t}),pendingCapability:d};return n(p,{icon:f,title:`Capabilities`,subtitle:`Choose which provider is active for each system capability. Singleton caps pick exactly one provider; collection caps enable a set.`,children:[h&&n(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-xs ${h.kind===`success`?`border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300`:`border-danger/40 bg-danger/10 text-danger`}`,children:[h.kind===`success`?s(l,{className:`h-3.5 w-3.5 shrink-0`}):s(u,{className:`h-3.5 w-3.5 shrink-0`}),s(`span`,{children:h.message})]}),_.isLoading&&s(`div`,{className:`flex items-center justify-center py-16`,children:s(`div`,{className:`animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full`})}),_.isError&&!_.isLoading&&s(e,{title:`Failed to load capabilities`,message:_.error instanceof Error?_.error.message:`Unknown error`,onRetry:()=>void _.refetch()}),!_.isLoading&&!_.isError&&v.length===0&&s(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:`No capabilities registered.`}),!_.isLoading&&!_.isError&&v.length>0&&n(`div`,{className:`space-y-6`,children:[S.length>0&&n(`section`,{className:`space-y-2`,children:[s(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:`Singleton — pick one provider`}),s(y,{capabilities:S,actions:k})]}),w.length>0&&n(`section`,{className:`space-y-2`,children:[s(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:`Collection — enable a set`}),s(y,{capabilities:w,actions:k})]})]})]})}export{w as CapabilitiesPage,w as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,x as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{n,t as r}from"./video-CpviqnLs.js";import{t as i}from"./radio-QcoQdeOv.js";import{t as a}from"./refresh-cw-CeTudtXW.js";import{t as o}from"./zap-DLLjJyp5.js";import{B as s,D as c,V as l,W as u,j as d,l as f,p,z as m}from"./index-BAP-BLu1.js";var h=u(`battery-full`,[[`rect`,{width:`16`,height:`10`,x:`2`,y:`7`,rx:`2`,ry:`2`,key:`1w10f2`}],[`line`,{x1:`22`,x2:`22`,y1:`11`,y2:`13`,key:`4dh1rd`}],[`line`,{x1:`6`,x2:`6`,y1:`11`,y2:`13`,key:`1wd6dw`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`13`,key:`haxvl5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`13`,key:`c6fn6x`}]]),g=u(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),_=u(`grid-2x2`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),v=u(`map`,[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]),y=u(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),b={streaming:{icon:r,label:`Streaming`},detection:{icon:c,label:`Detection`},recording:{icon:g,label:`Recording`},audio:{icon:n,label:`Audio`},snapshot:{icon:m,label:`Snapshot`},motion:{icon:o,label:`Motion`},ptz:{icon:p,label:`PTZ`},webrtc:{icon:i,label:`WebRTC`},onvif:{icon:y,label:`ONVIF`},analytics:{icon:d,label:`Analytics`},"battery-operated":{icon:h,label:`Battery`},"native-snapshot":{icon:m,label:`Native Snapshot`},"pan-tilt-zoom":{icon:p,label:`PTZ`},"two-way-audio":{icon:n,label:`Two-way Audio`},"doorbell-button":{icon:l,label:`Doorbell`},rebootable:{icon:a,label:`Rebootable`},"vacuum-has-map":{icon:v,label:`Map`},"vacuum-has-ai":{icon:f,label:`AI Obstacle`},"mower-has-map":{icon:v,label:`Map`},"mower-has-targeted-mowing":{icon:_,label:`Targeted Mowing`}},x=s;function S({capabilities:n,showLabels:r=!1}){return t(`div`,{className:`flex items-center gap-1 flex-wrap`,children:n.map(n=>{let i=b[n],a=i?.icon??x,o=i?.label??n;return e(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] text-foreground-subtle`,title:o,children:[t(a,{className:`h-3 w-3`}),r&&t(`span`,{children:o})]},n)})})}export{S as t};
|