@camstack/addon-admin-ui 1.2.242 → 1.2.244

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/assets/{AddonCollectionPage-DZiwhfq7.js → AddonCollectionPage-OO1QY8pf.js} +1 -1
  2. package/dist/assets/Addons-CDlJDhrN.js +1 -0
  3. package/dist/assets/{AdminTabs-CiWYZgPS.js → AdminTabs-BL2ZwadN.js} +1 -1
  4. package/dist/assets/AiProfiles-CM2kGtX3.js +3 -0
  5. package/dist/assets/{BrokerForm-BBWOUBfw.js → BrokerForm-CTIOktmx.js} +1 -1
  6. package/dist/assets/Build-BUY6mhfO.js +32 -0
  7. package/dist/assets/{Capabilities-trE3blsQ.js → Capabilities-N5hGc1kR.js} +1 -1
  8. package/dist/assets/{CapabilityBadges-DvZI06eL.js → CapabilityBadges-CytkOINH.js} +1 -1
  9. package/dist/assets/Cluster-Yqz6K4B8.js +11 -0
  10. package/dist/assets/Data-DQs98cfJ.js +1 -0
  11. package/dist/assets/DetectionIntelligence-Bd554Coz.js +1 -0
  12. package/dist/assets/{DeviceAggregateSection-Cx3Z4y8-.js → DeviceAggregateSection-CV4-mIyi.js} +1 -1
  13. package/dist/assets/DeviceDetail-C-rM9qyb.js +2 -0
  14. package/dist/assets/{Devices-DxVZZ-Zx.js → Devices-DUh6Ej5B.js} +1 -1
  15. package/dist/assets/{EmbedPlayerPage-DtKTcjws.js → EmbedPlayerPage-B4cWYsVd.js} +1 -1
  16. package/dist/assets/Events-qfb6DVS1.js +1 -0
  17. package/dist/assets/{FormBuilder-CnHo18o9.js → FormBuilder-rlscBNqn.js} +1 -1
  18. package/dist/assets/Identity-BFzPd8el.js +1 -0
  19. package/dist/assets/IntegrationDetail-CbybUNBC.js +1 -0
  20. package/dist/assets/Integrations-B3AyncNG.js +1 -0
  21. package/dist/assets/{Integrations-CHttEs-B.js → Integrations-ByrSDrjV.js} +1 -1
  22. package/dist/assets/Locations-Cg75VsPK.js +1 -0
  23. package/dist/assets/{Logs-T1boxWbu.js → Logs-CbLGaJCG.js} +1 -1
  24. package/dist/assets/{MotionZonesSettings-BMRYYoK9.js → MotionZonesSettings-Dkwied0J.js} +1 -1
  25. package/dist/assets/{MyAccess-D1VEDaD0.js → MyAccess-CoBuaPdE.js} +1 -1
  26. package/dist/assets/Network-9QOAmJa8.js +1 -0
  27. package/dist/assets/{NodeAddonsSettingsPanel-FUKLGt5Z.js → NodeAddonsSettingsPanel-YlBO_FEY.js} +1 -1
  28. package/dist/assets/{NodeInferenceDevices-BOs3sO_a.js → NodeInferenceDevices-DobUMlNX.js} +1 -1
  29. package/dist/assets/Notifications--0d6G3jE.js +1 -0
  30. package/dist/assets/Pipeline-BCvpEtVY.js +1 -0
  31. package/dist/assets/Plates-Dg-XsN9v.js +1 -0
  32. package/dist/assets/{PrivacyMaskSettings-DtG28LRw.js → PrivacyMaskSettings-BjtthT58.js} +1 -1
  33. package/dist/assets/{ProviderIcon-j5s-FJ-T.js → ProviderIcon-CFgCGh0F.js} +1 -1
  34. package/dist/assets/Recordings-Cn3QJDp3.js +1 -0
  35. package/dist/assets/{ScanNetworkModal-BriGiKz8.js → ScanNetworkModal-DpKoUp6B.js} +1 -1
  36. package/dist/assets/{SceneMonitorEditor-DwYozJtC.js → SceneMonitorEditor-CLXH0_YA.js} +1 -1
  37. package/dist/assets/{Scenes-C0AXe3FJ.js → Scenes-I0cVtdX6.js} +1 -1
  38. package/dist/assets/{Settings-B2bkhUHg.js → Settings-CyHx5v6Y.js} +1 -1
  39. package/dist/assets/{Showroom-9PU2jaOO.js → Showroom-B6Wnjd9B.js} +1 -1
  40. package/dist/assets/{StorageLocationsPanel-ldNxIVFu.js → StorageLocationsPanel-CXsbBjlc.js} +1 -1
  41. package/dist/assets/{Terminal-BBoroflb.js → Terminal-CC7MWTIy.js} +3 -3
  42. package/dist/assets/{Viewer-Ckf3MEmi.js → Viewer-EaJDf91u.js} +1 -1
  43. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Co8hXlE1.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-fDVjO96p.js} +1 -1
  44. package/dist/assets/{archive-C4exqh8O.js → archive-uhFR7t-v.js} +1 -1
  45. package/dist/assets/{authed-media-Bq38PoMF.js → authed-media-B3SD3kbD.js} +1 -1
  46. package/dist/assets/{bell-off-CAEq4a9m.js → bell-off-BpHTHtND.js} +1 -1
  47. package/dist/assets/{boxes-BmVWLRTr.js → boxes-uLBPptsh.js} +1 -1
  48. package/dist/assets/circle-slash-CrQ0fc3j.js +1 -0
  49. package/dist/assets/{debounced-invalidate-f9nnLjzk.js → debounced-invalidate-BwHUlczs.js} +1 -1
  50. package/dist/assets/{dist-ClDQb6R0.js → dist-BRCGJOZy.js} +1 -1
  51. package/dist/assets/dist-Bn-0Vqau.js +349 -0
  52. package/dist/assets/{face-bbox-wowUEFAD.js → face-bbox-DwjQQ6uR.js} +1 -1
  53. package/dist/assets/{hard-drive-download-CkV3AW1R.js → hard-drive-download-BEk_UjeU.js} +1 -1
  54. package/dist/assets/{hostInit-D4F6bVI-.js → hostInit-FA8VLrLH.js} +1 -1
  55. package/dist/assets/index-BL9peQNP.css +2 -0
  56. package/dist/assets/index-MtZejo7C.js +4 -0
  57. package/dist/assets/{key-round-2afL45nn.js → key-round-J073zy9w.js} +1 -1
  58. package/dist/assets/{layers-C2Df53wj.js → layers-DE_GTkoO.js} +1 -1
  59. package/dist/assets/{location-owned-usage-C9lTPM3x.js → location-owned-usage-RyMY9FR2.js} +1 -1
  60. package/dist/assets/{mf-entry-bootstrap-0-ce2aaa71.js → mf-entry-bootstrap-0-636f780f.js} +2 -2
  61. package/dist/assets/{player-overlays-BBc72WM3.js → player-overlays-aC8PhA0A.js} +1 -1
  62. package/dist/assets/remoteEntry-DGfdncKg.js +1 -0
  63. package/dist/assets/{send-C8Vx2lBu.js → send-uZyQkYtV.js} +1 -1
  64. package/dist/assets/{settings-2-BFAg0J5u.js → settings-2-Bb3ut7lh.js} +1 -1
  65. package/dist/assets/{square-check-big-D4waDUkC.js → square-check-big-CzXilNJm.js} +1 -1
  66. package/dist/assets/src-BdpK4c4C.js +67 -0
  67. package/dist/assets/src-D0ro00gM.js +349 -0
  68. package/dist/assets/{use-scenes-feed-BlBrLlDo.js → use-scenes-feed-0jG_OBDD.js} +1 -1
  69. package/dist/assets/{use-stationary-objects-DuPV--pN.js → use-stationary-objects-9nvVxiK9.js} +1 -1
  70. package/dist/assets/useEventInvalidation-BCz664O2.js +1 -0
  71. package/dist/assets/{useNodeUrlSelection-COGzsEiT.js → useNodeUrlSelection-C-rZP_Gj.js} +1 -1
  72. package/dist/assets/user-round-De1dbdTd.js +1 -0
  73. package/dist/assets/{video-BBVppgXo.js → video-CknQ8d2j.js} +1 -1
  74. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DsMwhexE.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BNx6ZyUj.js} +2 -2
  75. package/dist/index.html +6 -6
  76. package/dist/server/addon.js +336 -15
  77. package/package.json +1 -1
  78. package/dist/assets/Addons-DIE9N8F-.js +0 -1
  79. package/dist/assets/AiProfiles-DHt626oe.js +0 -3
  80. package/dist/assets/Build-DOi1qHVN.js +0 -32
  81. package/dist/assets/Cluster-Cmy6ZmjE.js +0 -11
  82. package/dist/assets/Data-Cy-VkjLA.js +0 -1
  83. package/dist/assets/DetectionIntelligence-BcmxWzp5.js +0 -1
  84. package/dist/assets/DeviceDetail-BAwfHU6F.js +0 -2
  85. package/dist/assets/Events-DjZLU7Ed.js +0 -1
  86. package/dist/assets/Identity-B7RdwQRP.js +0 -1
  87. package/dist/assets/IntegrationDetail-D-WoL3bT.js +0 -1
  88. package/dist/assets/Integrations-cnY2S64P.js +0 -1
  89. package/dist/assets/Locations-CEB_KR1k.js +0 -1
  90. package/dist/assets/Network-Mlh_6U7M.js +0 -1
  91. package/dist/assets/Notifications-BbV6cDK0.js +0 -1
  92. package/dist/assets/Pipeline-DbeOCwA3.js +0 -1
  93. package/dist/assets/Plates-R-u2BGN3.js +0 -1
  94. package/dist/assets/Recordings-BQlGCKeB.js +0 -1
  95. package/dist/assets/circle-slash-OoLNC_6k.js +0 -1
  96. package/dist/assets/dist-BpdyETtj.js +0 -349
  97. package/dist/assets/index-BunqRJOa.css +0 -2
  98. package/dist/assets/index-CuMRyGV2.js +0 -4
  99. package/dist/assets/remoteEntry-VWrEeGt9.js +0 -1
  100. package/dist/assets/src-CT-qu-nZ.js +0 -67
  101. package/dist/assets/src-qpAVbSCx.js +0 -349
  102. package/dist/assets/useEventInvalidation-DAv2WIvv.js +0 -1
  103. package/dist/assets/user-round-BzVozCoR.js +0 -1
@@ -5361,7 +5361,7 @@ var ZodIssueCode = {
5361
5361
  var ZodFirstPartyTypeKind;
5362
5362
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5363
5363
  //#endregion
5364
- //#region ../types/dist/sleep-CiR4z7r9.mjs
5364
+ //#region ../types/dist/sleep-CopaBJss.mjs
5365
5365
  /**
5366
5366
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5367
5367
  * window to float samples (D455).
@@ -5561,6 +5561,12 @@ Object.fromEntries([
5561
5561
  icon: "circle-dot",
5562
5562
  order: 40
5563
5563
  },
5564
+ {
5565
+ id: "clips",
5566
+ label: "Clips",
5567
+ icon: "clapperboard",
5568
+ order: 41
5569
+ },
5564
5570
  {
5565
5571
  id: "engine",
5566
5572
  label: "Inference Engine",
@@ -14058,6 +14064,8 @@ method(object({
14058
14064
  deviceId: number(),
14059
14065
  capName: string(),
14060
14066
  wrapperAddonId: string(),
14067
+ /** The `ClipSource.source` id to toggle. Absent = all of the addon's. */
14068
+ sourceId: string().optional(),
14061
14069
  active: boolean()
14062
14070
  }), _void(), {
14063
14071
  kind: "mutation",
@@ -22635,10 +22643,9 @@ var ServerBootModeSchema = _enum([
22635
22643
  * - `idle` / `checking` / `staging` — steady / in-flight registry work.
22636
22644
  * - `pending-restart` — a version is staged and the node has NOT yet
22637
22645
  * restarted onto it (still running the OLD version).
22638
- * - `awaiting-confirmation` — the node HAS restarted onto the staged version
22639
- * (it is the active probation boot) and is waiting to confirm boot-health.
22640
- * Apply/rollback are refused in this state and the node must NOT be
22641
- * manually restarted, or the probation boot auto-rolls-back.
22646
+ * - `awaiting-confirmation` — RETIRED with the probation boot (single-copy
22647
+ * collapse, 2026-07-18). Kept in the enum so an older client still parses;
22648
+ * no provider emits it.
22642
22649
  */
22643
22650
  var ServerUpdateStateSchema = _enum([
22644
22651
  "idle",
@@ -22727,12 +22734,35 @@ var ServerRollbackInfoSchema = object({
22727
22734
  var ServerPackageStatusSchema = object({
22728
22735
  /** Root package name (`@camstack/server` on the hub). */
22729
22736
  packageName: string(),
22730
- /** Version of the code the running process ACTUALLY loaded. */
22737
+ /**
22738
+ * Version of the code THIS PROCESS loaded — captured once, at boot, from the
22739
+ * package.json of the copy the code was loaded from, and never re-read. A
22740
+ * copy replaced on disk under a live process must not move this number;
22741
+ * that divergence is what `installedVersion` is for. Before 2026-09-20 this
22742
+ * was a lazy disk read that would have followed such a swap silently.
22743
+ */
22731
22744
  runningVersion: string().nullable(),
22732
22745
  /** Node.js runtime version the node's process runs on (`process.versions.node`). */
22733
22746
  nodeRuntimeVersion: string().nullable(),
22734
22747
  /** Active data-dir root version; null when booted from seed/workspace. */
22735
22748
  activeVersion: string().nullable(),
22749
+ /**
22750
+ * Version of the root package in the data-root `current/` copy RIGHT NOW —
22751
+ * what the next boot would load if nothing is staged. Normally equal to
22752
+ * `runningVersion`; differs only when the copy on disk changed under the
22753
+ * live process. `null` when there is no data-root copy (baked seed or
22754
+ * workspace boot). Optional for version skew: an older provider omits it.
22755
+ */
22756
+ installedVersion: string().nullable().optional(),
22757
+ /**
22758
+ * True when the code that would run after a restart is NOT the code running
22759
+ * now: a version is staged (`pendingVersion`), or `installedVersion` differs
22760
+ * from `runningVersion`. Derived on every read, never stored. This is the
22761
+ * one field that lets an operator or a script say "1.2.353 is installed and
22762
+ * will run after a restart" instead of reading it off a number that means
22763
+ * "installed". Optional for version skew.
22764
+ */
22765
+ restartRequired: boolean().optional(),
22736
22766
  /** N-1 version kept for rollback; null when no previous version exists. */
22737
22767
  previousVersion: string().nullable(),
22738
22768
  /** Version of the immutable baked seed closure (image fallback). */
@@ -22767,19 +22797,71 @@ var ServerPackageStatusSchema = object({
22767
22797
  });
22768
22798
  var ServerUpdateCheckResultSchema = object({
22769
22799
  packageName: string(),
22800
+ /** Same meaning as on the status payload: what THIS process loaded. */
22770
22801
  runningVersion: string().nullable(),
22771
22802
  latestVersion: string().nullable(),
22803
+ /**
22804
+ * `latestVersion` is newer than `runningVersion` AND is not the version
22805
+ * already staged on this node. A staged-and-waiting version is not "an
22806
+ * update available" — applying it again is refused (`already-staged`), and
22807
+ * a button that announced "updating…" on this boolean then got refused
22808
+ * would be lying. It is reported through `pendingVersion` instead.
22809
+ */
22772
22810
  updateAvailable: boolean(),
22773
22811
  checkedAtMs: number(),
22774
22812
  /** Non-null when the registry lookup failed (offline, bad registry, …). */
22775
- error: string().nullable()
22813
+ error: string().nullable(),
22814
+ /**
22815
+ * Version staged on this node and awaiting its restart, when one is. Before
22816
+ * 2026-09-20 a check answered `{runningVersion, updateAvailable:false}` for a
22817
+ * node whose staged closure had never booted, and the caller had no way to
22818
+ * see the difference. Optional for version skew.
22819
+ */
22820
+ pendingVersion: string().nullable().optional(),
22821
+ /** See the status payload: staged, or installed-on-disk ≠ running. Optional for skew. */
22822
+ restartRequired: boolean().optional()
22776
22823
  });
22824
+ /**
22825
+ * What an action DID — the discriminant `accepted` cannot carry. Before
22826
+ * 2026-09-20 `applyServerUpdate` answered `accepted:false` both for a refusal
22827
+ * where nothing was wrong (already current, already staged) and for a staging
22828
+ * install that died on `npm error code ECONNRESET`; the only difference was
22829
+ * prose in `message`, and an operator restarted a container on the strength of
22830
+ * it, booting the previous version.
22831
+ *
22832
+ * - `staged` — the closure is installed and validated; the node
22833
+ * restarts to apply it (`restarting:true`). NOTHING
22834
+ * runs the new code until that restart completes.
22835
+ * - `restart-scheduled` — a plain, version-preserving restart was accepted.
22836
+ * - `already-current` — the target IS the running version; nothing done.
22837
+ * - `refused` — dropped by a gate; `reason` names which.
22838
+ * - `failed` — attempted and did not land; `error` says why.
22839
+ */
22840
+ var ServerUpdateOutcomeSchema = _enum([
22841
+ "staged",
22842
+ "restart-scheduled",
22843
+ "already-current",
22844
+ "refused",
22845
+ "failed"
22846
+ ]);
22777
22847
  var ServerUpdateActionResultSchema = object({
22778
22848
  accepted: boolean(),
22779
22849
  targetVersion: string().nullable(),
22780
22850
  /** True when a graceful restart was scheduled to apply the change. */
22781
22851
  restarting: boolean(),
22782
- message: string()
22852
+ message: string(),
22853
+ /** See {@link ServerUpdateOutcomeSchema}. Optional for version skew. */
22854
+ outcome: ServerUpdateOutcomeSchema.optional(),
22855
+ /**
22856
+ * Stable, greppable cause for `refused` / `failed` (the engine's
22857
+ * `UpdateRefusalReason`, `staging-failed`, …). `null` on success.
22858
+ */
22859
+ reason: string().nullable().optional(),
22860
+ /**
22861
+ * The failure itself, verbatim enough to act on (the npm output for a
22862
+ * staging install). Non-null only for `failed`.
22863
+ */
22864
+ error: string().nullable().optional()
22783
22865
  });
22784
22866
  method(_void(), ServerPackageStatusSchema, { auth: "admin" }), method(_void(), ServerUpdateCheckResultSchema, {
22785
22867
  kind: "mutation",
@@ -23962,29 +24044,257 @@ var ClipSchema = object({
23962
24044
  holes: array(object({
23963
24045
  startMs: number(),
23964
24046
  endMs: number()
23965
- })).optional()
24047
+ })).optional(),
24048
+ /**
24049
+ * A URL that MAY produce this clip's still, asked only for rows actually on
24050
+ * screen. The opposite of {@link ClipSchema.thumbnail}: that one is VOUCHED
24051
+ * (a JPEG is already on disk), this one is an offer. The route answers 200
24052
+ * with the image, or 204 with `x-camstack-reason` when it could not mint one
24053
+ * — a surface latches that refusal to the instant rather than retrying.
24054
+ *
24055
+ * Never both: a clip with a vouched `thumbnail` needs no mint.
24056
+ */
24057
+ thumbnailMint: string().optional(),
24058
+ /**
24059
+ * Why no still will be produced for this clip RIGHT NOW — set when the
24060
+ * provider already knows, so the surface draws the glyph and the reason
24061
+ * instead of firing a mint that cannot succeed.
24062
+ *
24063
+ * `sleeping` — a standalone battery camera; a read would be a wake (D549 4).
24064
+ * `camera-refused` — the camera answered the CoverPreview with a refusal.
24065
+ * `no-keyframe` — the window holds no decodable I-frame (an event that sits
24066
+ * inside no file is the measured case).
24067
+ * `unsupported` — this source cannot mint stills at all.
24068
+ */
24069
+ thumbnailUnavailable: object({ reason: _enum([
24070
+ "sleeping",
24071
+ "camera-refused",
24072
+ "no-keyframe",
24073
+ "unsupported"
24074
+ ]) }).optional(),
24075
+ /**
24076
+ * When the catalog this row came from was last CONFIRMED against the device.
24077
+ * Absent means "this row was read live". A persisted catalog served while a
24078
+ * camera sleeps carries the age it really has — a cached list is never drawn
24079
+ * as current (D549 13).
24080
+ */
24081
+ catalogAsOf: number().optional(),
24082
+ /**
24083
+ * The camera's OWN type strings for this clip, all of them, unmapped
24084
+ * (`md`, `people`, `dog_cat`, `sched`, …). Kept beside {@link labels}
24085
+ * because a firmware inventing a type must not vanish: the mapping into our
24086
+ * filter vocabulary is lossy on purpose and this is the lossless copy
24087
+ * (D549 20).
24088
+ */
24089
+ nativeTypes: array(string()).optional(),
24090
+ /**
24091
+ * What the subject DID — `crossline`, `intrude`, `loitering`. A behaviour
24092
+ * travels BESIDE a class, never instead of one, and the class filter ignores
24093
+ * it: "a person crossed a line" is still a person (D549 20).
24094
+ */
24095
+ behaviours: array(string()).optional(),
24096
+ /**
24097
+ * The same recording as two files — the sub twin (what the row and its
24098
+ * thumbnail are) and its main twin, matched at listing time so a quality
24099
+ * change never re-searches the camera (D549 15). `getClipPlayback`'s
24100
+ * `profile` picks between them: `low | mid` → sub, `high` → main.
24101
+ */
24102
+ streams: object({
24103
+ sub: object({
24104
+ id: string(),
24105
+ bytes: number().optional()
24106
+ }).optional(),
24107
+ main: object({
24108
+ id: string(),
24109
+ bytes: number().optional()
24110
+ }).optional()
24111
+ }).optional(),
24112
+ /** The camera says it holds a sub-stream copy of this recording. */
24113
+ supportSub: boolean().optional(),
24114
+ /**
24115
+ * Whether this row has bytes behind it. ABSENT means yes — every clip that
24116
+ * IS a file is playable, and only a source that lists EVENTS can produce a
24117
+ * row with nothing to play (the measured case: 1 of 29 hub events on 3628
24118
+ * fell inside no file). Such a row is shown, never dropped and never offered
24119
+ * as playable-then-failing (D549 19).
24120
+ */
24121
+ playable: boolean().optional(),
24122
+ /** Why {@link playable} is false, verbatim (`no-file-for-window`). */
24123
+ unplayableReason: string().optional()
23966
24124
  });
23967
24125
  var ClipPlaybackSchema = object({
23968
- /** HLS master URL through the hub data-plane (Range + token in path). */
24126
+ /**
24127
+ * A media URL through the hub data-plane. {@link ClipPlaybackSchema.format}
24128
+ * says what kind — an HLS master playlist for a recording-derived clip, a
24129
+ * progressive MP4 for a native file the vendor addon muxed and serves with
24130
+ * `Range`. The URL is NOT a credential: both planes are registered
24131
+ * `access: 'authenticated'` and the hub's `/addon/<id>/<prefix>` proxy takes
24132
+ * the session cookie, so nothing is appended to it (D549 22).
24133
+ */
23969
24134
  playbackUrl: string(),
24135
+ /**
24136
+ * How to play {@link playbackUrl}. Absent means `hls` — the shape every
24137
+ * existing consumer already assumes. A player that branches on this is the
24138
+ * one change a native clip needs; a player that ignores it will hand an MP4
24139
+ * to hls.js and fail parsing it as a manifest.
24140
+ */
24141
+ format: _enum(["hls", "mp4"]).optional(),
24142
+ /**
24143
+ * Which twin was actually served. A clip that holds only one stream answers
24144
+ * with the one it has, and the surface SAYS so — a missing main twin is
24145
+ * never served silently as if it were the asked-for quality (D549 15).
24146
+ */
24147
+ served: CamProfileSchema.optional(),
23970
24148
  /** Optional LAN/remote alternates for the same clip. */
23971
24149
  playbackEndpoints: array(string()).optional(),
23972
24150
  token: string().optional()
23973
24151
  });
24152
+ /**
24153
+ * Why a source cannot answer right now — per SOURCE, never fleet-wide.
24154
+ *
24155
+ * `ok` is the only state whose clip list may be read as complete. The other
24156
+ * three exist because an empty list from a sleeping camera reads as "this
24157
+ * camera has no recordings", which is the defect this whole line of work is
24158
+ * about: a battery camera nobody woke (`sleeping`), a camera that could not be
24159
+ * reached at all (`unreachable`, also what a provider that THREW reports), a
24160
+ * camera whose SD card is not mounted (`no-storage`, measured on 640 —
24161
+ * `HddInfo mount 0`, honestly nothing to list rather than "no clips"), and a
24162
+ * camera whose OWN index disagrees with its OWN calendar (`index-empty`,
24163
+ * measured on 618: the calendar marks 3–20 September, days 6–20 list zero
24164
+ * files on both streams and both filters, with 177 GB free). That last one is
24165
+ * a defect ON THE CAMERA, and the only honest thing a provider can do is say
24166
+ * which days it asked for and got nothing — "no clips" would be a lie about a
24167
+ * card that is full of them.
24168
+ */
24169
+ var ClipSourceAvailabilitySchema = object({
24170
+ state: _enum([
24171
+ "ok",
24172
+ "sleeping",
24173
+ "unreachable",
24174
+ "no-storage",
24175
+ "index-empty"
24176
+ ]),
24177
+ /** Free text, shown verbatim. Names the camera's own refusal when there is one. */
24178
+ reason: string().optional(),
24179
+ /** When this source's catalog was last CONFIRMED. A cached list is never
24180
+ * drawn as current: the surface shows the age whenever it is older than the
24181
+ * refresh interval. */
24182
+ catalogAsOf: number().optional()
24183
+ });
24184
+ /**
24185
+ * One SOURCE of clips for a camera — a row of the picker, and the namespace
24186
+ * every clip id from it is prefixed with (`analytics`,
24187
+ * `native:reolink:onboard`, `hksv`, …).
24188
+ *
24189
+ * A provider lists the sources IT serves for that device, and answers for each
24190
+ * of them whether it can answer at all. A provider with nothing to offer on a
24191
+ * camera returns `[]` — it is not that camera's business.
24192
+ */
24193
+ var ClipSourceSchema = object({
24194
+ /** The value this source stamps on {@link ClipSchema.source}, and the prefix
24195
+ * of every clip id it mints. `getClipPlayback` routes on it. */
24196
+ source: string(),
24197
+ /** Operator-facing name of the source ("CamStack recordings", "SD card"). */
24198
+ label: string(),
24199
+ /**
24200
+ * The addon that SERVES this row.
24201
+ *
24202
+ * A surface cannot otherwise resolve a source to who answers it, and the
24203
+ * alternative — a `native:reolink:* → provider-reolink` table inside the
24204
+ * widget — is a second authority on provider identity living in the one
24205
+ * package with no business knowing it, wrong the day a third source appears
24206
+ * (D557). One addon may serve SEVERAL sources: `addon-provider-reolink`
24207
+ * answers a hub child with both `native:reolink:onboard` and
24208
+ * `native:reolink:hub`, which is why the per-device switch is keyed by
24209
+ * SOURCE and not by this (D555).
24210
+ *
24211
+ * Optional for version skew only. The collection dispatcher stamps it from
24212
+ * the registry, so a row that travelled through the fan-out carries the
24213
+ * authoritative id whatever the provider filled in.
24214
+ */
24215
+ addonId: string().optional(),
24216
+ /**
24217
+ * Which API this source resolved to FOR THIS CAMERA, when it has a choice.
24218
+ *
24219
+ * A source may cover one store through more than one surface — the Reolink
24220
+ * provider reads a hub child through the parent's event log and a standalone
24221
+ * through its own file list, because that is what each camera answers. The
24222
+ * CHOICE is the provider's, made from what the camera is, and is never a row
24223
+ * the operator has to understand; but it is REPORTED, because a source that
24224
+ * silently reads a different API on two cameras and then behaves differently
24225
+ * is the thing nobody can debug later. Absent when the source has only one
24226
+ * way to read its store.
24227
+ */
24228
+ via: string().optional(),
24229
+ availability: ClipSourceAvailabilitySchema,
24230
+ /**
24231
+ * The operator switched this source OFF for this camera.
24232
+ *
24233
+ * Deliberately NOT a member of {@link ClipSourceAvailabilitySchema}'s
24234
+ * vocabulary. That enum models what the source CAN do — a sleeping camera, an
24235
+ * unmounted card, an index that disagrees with its own calendar — and a
24236
+ * switched-off source could answer perfectly well; the operator decided it
24237
+ * should not. Folding the choice in is how `disabled` and `broken` stop being
24238
+ * distinguishable, which is the D62 rule this repo has already paid for twice:
24239
+ * an off switch is REPORTED off (`CameraStatus.switchedOff`, the same word),
24240
+ * and disabled must never look like broken. It is also what lets every
24241
+ * exhaustive consumer of the availability enum keep compiling.
24242
+ *
24243
+ * A switched-off source contributes NO clips (`listClips` never calls it) and
24244
+ * its row carries no `catalogAsOf`: nothing confirms a catalog it is not
24245
+ * allowed to serve, and a frozen age that can only grow draws a stalling
24246
+ * source rather than an off switch.
24247
+ *
24248
+ * The row survives BECAUSE it is the control the operator switches the source
24249
+ * back on from — D554 decision 4's rule ("a source that cannot answer
24250
+ * produces a ROW, not an absence") applied to the one case D556 carved out of
24251
+ * it, and D557's own kept property ("a source is never hidden, only its
24252
+ * rows"). Absent means on.
24253
+ *
24254
+ * A provider never sets this — like {@link ClipSourceSchema.addonId} it is
24255
+ * stamped by the collection dispatcher, which holds the registry's projection
24256
+ * of the persisted authority (D556) and is the only place that knows it.
24257
+ */
24258
+ switchedOff: boolean().optional()
24259
+ });
23974
24260
  DeviceType.Camera, method(object({
23975
24261
  deviceId: number(),
23976
24262
  since: number(),
23977
24263
  until: number(),
23978
- limit: number().int().positive().optional()
24264
+ limit: number().int().positive().optional(),
24265
+ /**
24266
+ * View filter over {@link ClipSourceSchema.source} values — the
24267
+ * picker's selection, forwarded so a provider need not list what
24268
+ * nobody is looking at. ABSENT means every source this camera has,
24269
+ * which is the honest default for a surface whose whole point is that
24270
+ * nothing is hidden (D554 3). A provider with one source ignores it.
24271
+ */
24272
+ sources: array(string()).optional()
23979
24273
  }), array(ClipSchema).readonly(), {
23980
24274
  kind: "query",
23981
- auth: "admin"
24275
+ auth: "protected"
24276
+ }), method(object({ deviceId: number() }), array(ClipSourceSchema).readonly(), {
24277
+ kind: "query",
24278
+ auth: "protected"
23982
24279
  }), method(object({
23983
24280
  deviceId: number(),
23984
- clipId: string()
24281
+ clipId: string(),
24282
+ /**
24283
+ * Which twin to serve, on the ONE quality scale the system already has
24284
+ * (`CamProfileSchema`). `low | mid` → the sub file, `high` → the main
24285
+ * twin; both ids are already on the row so this never re-searches the
24286
+ * camera. Absent means the provider's own default (the sub file, which
24287
+ * every source is measured to hold).
24288
+ *
24289
+ * `auto` is deliberately NOT accepted here: a stored file has no
24290
+ * broker session, so the adaptive tier cannot be resolved for it. The
24291
+ * viewer resolves `auto` to a profile the same way live does, before
24292
+ * it calls (D549 15).
24293
+ */
24294
+ profile: CamProfileSchema.optional()
23985
24295
  }), ClipPlaybackSchema, {
23986
24296
  kind: "query",
23987
- auth: "admin"
24297
+ auth: "protected"
23988
24298
  });
23989
24299
  /**
23990
24300
  * Optional client-side hints sent at session creation to help the provider
@@ -37955,6 +38265,12 @@ Object.freeze({
37955
38265
  addonId: null,
37956
38266
  access: "view"
37957
38267
  },
38268
+ "videoclips.listSources": {
38269
+ capName: "videoclips",
38270
+ capScope: "device",
38271
+ addonId: null,
38272
+ access: "view"
38273
+ },
37958
38274
  "viewerUi.getStaticDir": {
37959
38275
  capName: "viewer-ui",
37960
38276
  capScope: "system",
@@ -39963,6 +40279,11 @@ Object.freeze({
39963
40279
  form: "single",
39964
40280
  optional: false
39965
40281
  }],
40282
+ "videoclips.listSources": [{
40283
+ name: "deviceId",
40284
+ form: "single",
40285
+ optional: false
40286
+ }],
39966
40287
  "waterHeater.setAway": [{
39967
40288
  name: "deviceId",
39968
40289
  form: "single",
@@ -40640,7 +40961,7 @@ var AdminUIAddon = class extends BaseAddon {
40640
40961
  capability: adminUiCapability,
40641
40962
  provider: {
40642
40963
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
40643
- getVersion: async () => ({ version: "1.2.242" })
40964
+ getVersion: async () => ({ version: "1.2.244" })
40644
40965
  }
40645
40966
  }];
40646
40967
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.242",
3
+ "version": "1.2.244",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -1 +0,0 @@
1
- import{I as e,K as t,Q as n,R as r,S as i,W as a,b as o,o as s,q as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as d,_t as f,ht as p,st as m}from"./player-overlays-BBc72WM3.js";import{$c as h,$l as g,An as _,Dc as v,En as y,Hn as b,Il as x,In as S,Jc as ee,Jl as C,Jn as te,Kc as ne,Kn as w,Ln as re,Mn as T,Nn as ie,On as E,Pn as D,Rn as O,Un as ae,Vn as oe,Wl as k,Wn as A,X as se,Y as ce,Yc as le,Zl as ue,_ as j,_l as M,ba as N,fc as P,hc as F,il as I,jn as L,kn as R,ln as de,qn as z,sl as fe,w as pe,yc as B,zc as V,zn as H}from"./src-CT-qu-nZ.js";import{Xt as U}from"./src-qpAVbSCx.js";import{a as me,d as W,s as he}from"./index-CuMRyGV2.js";import{t as G}from"./AdminPage-CiKtOLQm.js";import{t as ge}from"./NodeAddonsSettingsPanel-FUKLGt5Z.js";import{r as K,t as q}from"./useNodeUrlSelection-COGzsEiT.js";var J=f(`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`}]]);n();var Y=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),_e=new Set([`done`,`failed`,`skipped`]);function X(e){return!_e.has(e.phase)&&!Y.has(e.jobState)}function Z(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Y.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 ve(){let{data:e}=S({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=F(U.AddonsJobProgress,e=>e.job.jobId);return a(()=>{let n=new Map;for(let t of e??[])n.set(t.jobId,t);for(let[e,r]of t)n.set(e,r.job);return Z([...n.values()],Date.now())},[e,t])}var ye={queued:{icon:k,cls:`bg-muted text-foreground-subtle`,label:`queued`},fetching:{icon:M,cls:`bg-primary/10 text-primary`,label:`fetching`,spin:!0},staged:{icon:M,cls:`bg-primary/10 text-primary`,label:`staged`,spin:!0},validating:{icon:M,cls:`bg-primary/10 text-primary`,label:`validating`,spin:!0},applying:{icon:M,cls:`bg-primary/10 text-primary`,label:`applying`,spin:!0},restarting:{icon:M,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,label:`restarting`,spin:!0},applied:{icon:M,cls:`bg-primary/10 text-primary`,label:`finalizing`,spin:!0},done:{icon:g,cls:`bg-success/10 text-success`,label:`updated`},failed:{icon:J,cls:`bg-danger/10 text-danger`,label:`failed`},skipped:{icon:V,cls:`bg-muted text-foreground-subtle`,label:`skipped`}};function be({progress:e}){let t=ye[e.phase],n=t.icon,r=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return i(`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:[l(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label,i(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function xe({packageName:e,currentVersion:t,installSource:n,onInstall:r,onClose:a,onSelect:s,selectedVersion:c}){let u=n===`upload`||n===`local`,{data:d,isLoading:f}=T({name:e});return i(`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:[i(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[l(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:`Versions`}),l(`button`,{type:`button`,onClick:a,className:`text-foreground-subtle hover:text-foreground`,children:l(B,{className:`h-3 w-3`})})]}),u&&i(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[l(v,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),i(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[i(`span`,{className:`font-semibold`,children:[n===`upload`?`Uploaded copy`:`Local copy`,` in place.`]}),` `,`Re-install `,l(`span`,{className:`font-mono`,children:t}),` from npm to track upstream releases again.`]})]}),f&&i(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[l(M,{className:`h-3.5 w-3.5 animate-spin`}),`Loading versions...`]}),d&&l(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:d.map(e=>{let n=e.version===t,a=s!==void 0&&e.version===c,d=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),f=i(o,{children:[l(`span`,{className:`font-mono flex-1 text-left ${n?`text-primary font-semibold`:d?`text-amber-400`:`text-foreground`}`,children:e.version}),n&&l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:`current`}),e.distTags.map(e=>l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),e.deprecated&&l(`span`,{className:`text-[9px] text-red-400 line-through`,children:`deprecated`}),l(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return s?i(`button`,{type:`button`,"aria-label":`Select ${e.version}`,onClick:()=>s(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${a?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,a?l(g,{className:`h-3 w-3 text-primary shrink-0`}):l(`span`,{className:`w-3 shrink-0`})]},e.version):i(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${n?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,n&&!u?l(g,{className:`h-3 w-3 text-primary shrink-0`}):l(`button`,{type:`button`,onClick:()=>r(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:n?`Re-install ${e.version} from npm`:`Install ${e.version}`,children:l(x,{className:`h-3 w-3`})})]},e.version)})}),d&&d.length===0&&l(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:`No versions found`})]})}var Se={queued:{icon:k,bg:`bg-muted text-foreground-subtle`,label:`queued`},updating:{icon:M,bg:`bg-primary/10 text-primary`,label:`updating`,spin:!0},"done-pending-restart":{icon:h,bg:`bg-amber-500/10 text-amber-700`,label:`pending restart`},done:{icon:g,bg:`bg-success/10 text-success`,label:`done`},failed:{icon:J,bg:`bg-danger/10 text-danger`,label:`failed`}};function Q({item:e}){let t=Se[e.status],n=t.icon;return i(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${t.bg}`,title:e.error,children:[l(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label]})}n();var Ce=`device-export`;function we(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===Ce)}function Te({isBundle:e,installSource:t,addonId:n,iconPath:r,color:a}){let[o,s]=c(!1),u=a?{backgroundColor:`${a.startsWith(`#`)?a:`#${a}`}26`}:void 0,f=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,p=n&&r?d(`/api/addon-assets/${n}/${r}`):null,m=!!p&&!o;return i(`div`,{className:`relative flex-shrink-0`,children:[l(`div`,{className:`h-9 w-9 rounded-lg flex items-center justify-center ${u?``:f}`,style:u,children:m?l(`img`,{src:p,alt:n,className:`h-5 w-5`,onError:()=>s(!0)}):l(e?fe:W,{className:`h-4 w-4`})}),t===`local`&&l(`span`,{className:`absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm`,children:`DEV`}),t===`npm`&&l(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:l(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:l(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),t===`upload`&&l(`span`,{className:`absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm`,children:l(v,{className:`h-2.5 w-2.5 text-white`})})]})}function Ee({version:e,availableUpdate:t,selectedVersion:n,isUpdating:r,installSource:a,disabled:o,onUpdate:s,onOpenPicker:c,children:u}){if(r)return i(`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:[l(M,{className:`h-3 w-3 animate-spin`}),`Updating…`]});if(t){let r=n??t;return i(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[s&&i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:o,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:[l(x,{className:`h-3 w-3`}),`Update`]}),i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:o,"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:[l(`span`,{className:`font-normal opacity-70`,children:e}),l(`span`,{className:`font-normal opacity-70`,children:`→`}),r,l(p,{className:`h-3 w-3`})]}),u]})}return i(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:o,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`,a===`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,l(p,{className:`h-3 w-3 opacity-50`})]}),u]})}function De({addonId:e}){let t=s(),{data:n=`inherit`}=R({addonId:e}),r=ae({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return l(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>l(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}function Oe({addon:e,agents:t=[],clusterStatus:n,hideVersion:r,availableUpdate:a,onUpdate:d,isUpdating:f,jobProgress:g,bundle:_,bulkItem:v,disabledByBulk:y,isSystem:b}){let[x,S]=c(!1),[ee,C]=c(!1),[te,w]=c(!1),[re,T]=c(null);u(()=>{T(null)},[a]);let E=re??a,[D,O]=c(!1),[ae,k]=c(!1),[A,j]=c(`logs`),M=s(),N=me(),P=de(),{manifest:F}=e,L=e.installedOn??[],R=!_&&!F.protected&&F.removable!==!1,V=!!_,U=_?.displayName??F.name,W=_?.packageName??F.packageName,he=_?.version??F.packageVersion??F.version,G=_?.installSource??e.installSource,K=_?_.bundle?.description??_.addons[0]?.manifest.description:F.description,q=z({onSuccess:()=>{M.invalidateQueries({queryKey:[[`addons`]]}),M.invalidateQueries({queryKey:[[`addonPages`]]}),M.invalidateQueries({queryKey:[[`capabilities`]]})}}),Y=H({onSuccess:()=>{M.invalidateQueries({queryKey:[[`addons`]]})}}),_e=ie({onSuccess:()=>{M.invalidateQueries({queryKey:[[`addons`]]}),M.invalidateQueries({queryKey:[[`addonPages`]]}),M.invalidateQueries({queryKey:[[`capabilities`]]}),M.invalidateQueries({queryKey:[[`integrations`]]})}}),X=oe({onSuccess:()=>{M.invalidateQueries({queryKey:[[`addons`]]}),M.invalidateQueries({queryKey:[[`alerts`]]})}}),Z=e.health,ve=Z?.phase===`failed`&&!Z.inGracePeriod,ye=ve&&Z?.nextRetryAt&&!Z.retrying;return i(`div`,{className:`rounded-lg border bg-surface overflow-hidden ${ve?`border-red-500/50`:`border-border`}`,children:[ve&&Z&&i(`div`,{className:`bg-danger/10 border-b border-danger/30 px-4 py-2.5 flex items-start gap-2.5`,children:[l(J,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`text-xs font-semibold text-danger`,children:[`Failed to load (attempt #`,Z.retryCount,`)`]}),l(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:Z.lastError?.message??`Unknown error`}),ye&&Z.nextRetryAt&&i(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:[`Auto-retry at `,new Date(Z.nextRetryAt).toLocaleTimeString()]})]}),i(`button`,{type:`button`,disabled:X.isPending||Z.retrying,onClick:e=>{e.stopPropagation(),X.mutate({packageName:W})},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:[l(h,{className:`h-3 w-3 ${X.isPending||Z.retrying?`animate-spin`:``}`}),`Retry now`]})]}),i(`div`,{className:`flex items-start gap-3 px-4 py-3`,children:[l(Te,{isBundle:V||!!F.components&&F.components.length>1,installSource:G,addonId:V?_.addons[0]?.manifest.id:F.id,iconPath:V?_.bundle?.icon??_.addons[0]?.manifest.icon:F.icon,color:V?_.addons[0]?.manifest.color:F.color}),i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`flex items-start justify-between gap-2`,children:[l(`span`,{className:`text-sm font-semibold text-foreground truncate min-w-0`,children:U}),!r&&l(Ee,{version:he,availableUpdate:a,...E===void 0?{}:{selectedVersion:E},isUpdating:f,installSource:G,disabled:y,...d&&E!==void 0?{onUpdate:()=>d(E)}:{},onOpenPicker:()=>w(e=>!e),children:te&&l(xe,{packageName:W,currentVersion:he,...G?{installSource:G}:{},...a!==void 0&&E!==void 0?{selectedVersion:E,onSelect:e=>{T(e),w(!1)}}:{},onInstall:e=>{w(!1),_e.mutate({packageName:W,version:e})},onClose:()=>w(!1)})})]}),i(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[W!==U&&l(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:W}),V&&i(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,children:[l(fe,{className:`h-3 w-3`}),_.addons.length]}),b&&i(`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:[l(h,{className:`h-3 w-3`}),`System`]}),v!=null&&l(Q,{item:v}),g!=null&&l(be,{progress:g})]}),K&&l(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:K}),!V&&e.process&&i(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode===`forked`?`bg-blue-500/15 text-blue-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.mode===`forked`?`forked`:`in-process`}),e.process.pid!=null&&i(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state===`running`?`bg-emerald-500/15 text-emerald-400`: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})]})]})]}),!V&&i(`div`,{className:`flex items-center gap-1 px-4 py-1.5 border-t border-border/50 bg-surface-hover/20`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Y.mutate({addonId:F.id})},disabled:Y.isPending||y,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:[l(h,{className:`h-3 w-3 ${Y.isPending?`animate-spin`:``}`}),`Restart`]}),i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),O(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${D?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[l(le,{className:`h-3 w-3`}),`Logs`]}),!V&&i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),k(!0)},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:[l(ne,{className:`h-3 w-3`}),`Settings`]}),l(`div`,{className:`flex-1`}),R&&i(`button`,{type:`button`,onClick:async e=>{e.stopPropagation(),await P({title:`Uninstall ${F.name}?`,message:`This will remove the addon package and all its data. This action cannot be undone.`,confirmLabel:`Uninstall`,variant:`danger`})&&q.mutate({packageName:F.packageName})},disabled:q.isPending||y,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:[l(m,{className:`h-3 w-3`}),q.isPending?`Removing...`:`Uninstall`]})]}),n&&n.nodes.length>1&&!V&&i(`div`,{className:`border-t border-border px-4 py-2 bg-muted/10`,children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:`Cluster Deployment`}),l(`div`,{className:`space-y-1`,children:n.nodes.map(e=>i(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[l(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`offline`?`bg-muted-foreground/30`:e.synced?`bg-success`:`bg-amber-500`}`}),l(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),l(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:`outdated`}),e.status===`offline`&&l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:`offline`}),e.synced&&e.status!==`offline`&&l(`span`,{className:`text-[9px] text-success`,children:`synced`})]},e.nodeId))})]}),D&&!V&&i(`div`,{className:`border-t border-border`,children:[i(`div`,{className:`flex items-center px-4 py-1 bg-surface-hover/20 border-b border-border/50`,children:[i(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[l(`button`,{type:`button`,onClick:()=>j(`logs`),className:`px-2 py-0.5 transition-colors ${A===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Logs`}),l(`button`,{type:`button`,onClick:()=>j(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${A===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Events`})]}),l(`div`,{className:`flex-1`}),l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),O(!1)},className:`text-foreground-subtle hover:text-foreground`,children:l(B,{className:`h-3.5 w-3.5`})})]}),A===`logs`&&l(se,{addonId:F.id,maxHeight:`max-h-64`,showFilters:!1}),A===`events`&&l(ce,{addonId:F.id,category:`addon.*`,maxHeight:`max-h-64`})]}),V&&i(o,{children:[l(`button`,{type:`button`,onClick:()=>S(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:l(x?ue:p,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),x&&l(`div`,{className:`border-t border-border px-3 py-2 space-y-2`,children:_.addons.map(e=>l(Oe,{addon:e,agents:t,hideVersion:!0},e.manifest.id))})]}),ae&&!V&&l(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4`,onClick:()=>k(!1),children:i(`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:[i(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-border flex-shrink-0`,children:[i(`div`,{className:`flex items-center gap-2`,children:[l(ne,{className:`h-4 w-4 text-primary`}),i(`h2`,{className:`text-sm font-semibold text-foreground`,children:[U,` Settings`]})]}),l(`button`,{onClick:()=>k(!1),className:`text-foreground-subtle hover:text-foreground transition-colors p-1 rounded`,children:l(B,{className:`h-4 w-4`})})]}),i(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[l(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`}),l(ge,{nodeId:null,addonIds:[F.id],level:`global`,fieldScope:`cluster`,emptyMessage:`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`}),we(F)&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Device export`}),l(pe,{addonId:F.id,onOpenDevice:e=>N(`/devices/${e}`)})]}),G===`npm`&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Auto-Update`}),l(De,{addonId:F.id})]}),F.components&&F.components.length>0&&i(`div`,{children:[i(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Components (`,F.components.length,`)`]}),l(`div`,{className:`flex flex-wrap gap-1`,children:F.components.map(e=>l(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]}),t.length>=2&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Installed on`}),i(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[L.length===0&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Hub (local)`}),L.map(e=>l(`span`,{className:`rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle`,children:e},e)),i(`div`,{className:`relative`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),C(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:[l(I,{className:`h-3 w-3`}),`Add agent`]}),ee&&i(`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&&!L.includes(e.name)).map(e=>l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),C(!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&&!L.includes(e.name)).length===0&&l(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle`,children:`No available agents`})]})]})]})]})]}),l(`div`,{className:`flex items-center justify-end px-5 py-3 border-t border-border flex-shrink-0`,children:l(`button`,{type:`button`,onClick:()=>k(!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`})})]})})]})}n();var ke=`.tgz,.tar.gz,.zip`;function Ae({onUploadSuccess:n}){let[r,a]=c(!1),s=t(null),u=e(async e=>{a(!0);let t=new FormData;t.append(`file`,e);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(d(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:t})).json()).success&&n()}finally{a(!1)}},[n]);return i(o,{children:[l(`input`,{ref:s,type:`file`,accept:ke,onChange:e(e=>{let t=e.target.files?.[0];t&&u(t),e.target.value=``},[u]),className:`hidden`}),i(`button`,{type:`button`,onClick:()=>s.current?.click(),disabled:r,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:[r?l(M,{className:`w-3.5 h-3.5 animate-spin`}):l(v,{className:`w-3.5 h-3.5`}),r?`Uploading...`:`Upload`]})]})}n();var je=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],Me=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/shm-ring`,`@camstack/ui-library`]);function Ne(e){return e!==void 0&&Me.has(e)}var Pe={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function Fe(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function Ie(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 Le(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 Re({addons:n,clusterStatus:o,selectedNode:d,onRefresh:f,isRefreshing:p}){let m=s(),[v,S]=c(``),ne=r(v),[T,E]=c(!1),D=t(null);u(()=>{if(!T)return;let e=e=>{D.current&&!D.current.contains(e.target)&&E(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[T]);let{data:O}=re({nodeId:d.id}),ae=a(()=>{let e=new Map;for(let t of O??[])e.set(t.name,t.latestVersion);return e},[O]),oe=a(()=>(O??[]).filter(e=>!e.isSystem).length,[O]),[k,se]=c(()=>new Set),[ce,le]=c(()=>new Map),ue=e(e=>{se(t=>new Set(t).add(e))},[]),j=e(e=>{se(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),N=e((e,t)=>{le(n=>new Map(n).set(e,t))},[]),P=e(e=>{le(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),F=te({onMutate:e=>{ue(e.name),P(e.name)},onSuccess:(e,t)=>{j(t.name);let n=e;if(n&&n.success===!1){N(t.name,n.error??`Update failed (no error message returned by server)`);return}m.invalidateQueries({queryKey:[[`addons`]]}),m.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{j(t.name),N(t.name,e instanceof Error?e.message:String(e))}}),I=ve(),R=t(new Set);u(()=>{let e=new Set;for(let[t,n]of I)X(n)&&e.add(t);let t=[...R.current].some(t=>!e.has(t));R.current=e,t&&(m.invalidateQueries({queryKey:[[`addons`]]}),m.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[I,m]);let{data:z}=_(void 0),fe=y({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),pe=A({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:B,isFetching:V}=b({query:ne||void 0},{enabled:T}),H=w(),{data:U}=L(void 0),me=U?.requestedAt,[W,G]=c(null),[ge,K]=c(!1);u(()=>{if(U?.kind===`framework-bulk-update`&&U.requestedAt!==W){G(U.requestedAt),K(!0);let e=window.setTimeout(()=>K(!1),6e3);return()=>window.clearTimeout(e)}},[me,W,U]),de();let q=e(async()=>{let e=(O??[]).filter(e=>!e.isSystem);if(e.length!==0){if(!d.isHub){for(let t of e)await F.mutateAsync({name:t.name,version:t.latestVersion,nodeId:d.id});return}await H.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[d.id]})}},[O,d.id,d.isHub,H,F]),J=ie({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`]]}),m.invalidateQueries({queryKey:[[`addonPages`]]}),m.invalidateQueries({queryKey:[[`capabilities`]]}),m.invalidateQueries({queryKey:[[`integrations`]]})}}),[Y,_e]=c(`type`),[Z,ye]=c(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),be=e=>{ye(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[xe,Se]=he(),Q=xe.get(`capability`),Ce=a(()=>{let e=n.filter(e=>!Ne(e.manifest.packageName));return d.isHub||(e=e.filter(e=>Fe(e.placement,d.isHub))),Q&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===Q))),e},[n,d.isHub,Q]),we=()=>{let e=new URLSearchParams(xe);e.delete(`capability`),Se(e,{replace:!0})},Te=Z===`flat`?Ce:Le(Ce),Ee=a(()=>{let e=[...Te];switch(Y){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},[Te,Y]);return i(`div`,{className:`space-y-4`,children:[[...ce.entries()].map(([e,t])=>l(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px]`,children:i(`div`,{className:`flex items-start justify-between gap-3`,children:[i(`div`,{className:`space-y-0.5`,children:[i(`div`,{className:`font-medium text-danger`,children:[`Failed to update `,e]}),l(`div`,{className:`text-foreground-subtle font-mono`,children:t})]}),l(`button`,{type:`button`,onClick:()=>P(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:`dismiss`})]})},e)),i(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[i(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Sort:`}),i(`select`,{value:Y,onChange:e=>_e(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:[l(`option`,{value:`type`,children:`Bundles first`}),l(`option`,{value:`name`,children:`Name`}),l(`option`,{value:`source`,children:`Install source`})]})]}),i(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`View:`}),l(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>l(`button`,{type:`button`,onClick:()=>be(e),className:`px-2.5 py-1.5 transition-colors capitalize ${Z===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))})]}),d.isHub&&i(`div`,{className:`flex items-center gap-1.5`,children:[l(h,{className:`h-3 w-3 text-foreground-subtle`}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Auto-Update:`}),l(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>l(`button`,{type:`button`,onClick:()=>fe.mutate({channel:e}),disabled:fe.isPending,className:`px-2.5 py-1.5 transition-colors capitalize ${z?.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))})]}),d.isHub&&i(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Check every:`}),l(`select`,{className:`rounded-md border border-border bg-transparent px-1.5 py-1 text-[10px] font-medium text-foreground-subtle`,value:z?.updateCheckIntervalSeconds??21600,disabled:pe.isPending||z===void 0,onChange:e=>{z!==void 0&&pe.mutate({channel:z.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:je.map(e=>l(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),oe>0&&i(`button`,{type:`button`,onClick:()=>void q(),disabled:H.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:[H.isPending?l(M,{className:`w-3 h-3 animate-spin`}):l(x,{className:`w-3 h-3`}),H.isPending?`Updating…`:`Update All (${oe})`]}),i(`button`,{type:`button`,onClick:f,disabled:p||H.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:[l(h,{className:`w-3 h-3 ${p?`animate-spin`:``}`}),`Refresh`]})]}),i(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[i(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:D,children:[l(ee,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),l(`input`,{type:`text`,value:v,onChange:e=>{S(e.target.value),E(!0)},onFocus:()=>E(!0),placeholder:`Search addons on npm...`,disabled:H.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`}),V&&l(M,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin`}),T&&B&&B.length>0&&i(`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&&i(`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&&l(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:B.map(e=>i(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[l(`div`,{className:`w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0`,children:e.name.replace(`@camstack/addon-`,``).charAt(0).toUpperCase()}),i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[l(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),i(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),l(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&l(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?i(`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:[l(g,{className:`h-3 w-3`}),e.installedVersion??`Installed`]}):i(`button`,{type:`button`,onClick:()=>J.mutate({packageName:e.name}),disabled:J.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:[J.isPending?l(M,{className:`h-3 w-3 animate-spin`}):l(x,{className:`h-3 w-3`}),`Install`]})]},e.name))})]})]}),l(Ae,{onUploadSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`]]}),f()}})]}),Q&&i(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-primary/10 border border-primary/30 text-sm`,children:[l(`span`,{className:`text-foreground-subtle`,children:`Filtering by capability:`}),l(`span`,{className:`font-mono text-primary font-semibold`,children:Q}),l(`button`,{type:`button`,onClick:we,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:`Clear`})]}),ge&&i(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg backdrop-blur-sm max-w-sm pointer-events-auto`,children:[l(C,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),i(`div`,{children:[l(`div`,{className:`text-[11px] font-semibold text-foreground`,children:`Bulk update completed`}),l(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:`System packages updated — hub restarted successfully.`})]})]}),Ce.length===0&&l(`div`,{className:`text-xs text-foreground-subtle`,children:n.length===0?`No addons installed`:Q?`No installed addons declare the "${Q}" capability. Browse the npm catalog above to find a compatible addon.`:`No addons compatible with ${d.name} (placement filter active)`}),l(`div`,{className:`space-y-2`,children:Ee.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=ae.get(t),r=$(e)?e.representative:e,i=n?e=>F.mutate({name:t,version:e,nodeId:d.id}):void 0,a=I.get(t)??null,s=a!==null&&X(a);return l(Oe,{addon:r,clusterStatus:o?.[r.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,isUpdating:k.has(t)||s,jobProgress:a,onUpdate:i,disabledByBulk:H.isPending},$(e)?t:e.manifest.id)})})]})}function ze(){let e=s(),{data:n,isLoading:r,isError:a}=D(),{data:o}=N(void 0),{nodes:c}=P(),{selection:d,selectNode:f,requestedNodeId:p}=q(c.length>0?c:[Pe]),m=d.node??Pe,g=m.id,_=c.length>0?d.staleNodeId:null,v=E(),y=O(),b=v.isPending||y.isPending,x=async()=>{await v.mutateAsync({nodeId:g}),await y.mutateAsync(),e.invalidateQueries({queryKey:[[`addons`]]})},S=t(v);S.current=v;let ee=t(p??`hub`);u(()=>{S.current.mutate({nodeId:ee.current})},[]);let C=(n??[]).map(Ie).filter(e=>e!==null);return i(G,{children:[i(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[l(j,{selectedNodeId:g,onSelect:f}),i(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[!r&&!a&&i(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:[C.length,` installed`]}),i(`button`,{type:`button`,onClick:()=>void x(),disabled:b,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:[l(h,{className:`w-3 h-3 ${b?`animate-spin`:``}`}),`Check for updates`]})]})]}),l(K,{staleNodeId:_,shownNodeName:m.name}),!m.isHub&&i(`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`,` `,l(`span`,{className:`font-medium text-foreground`,children:m.name}),` — agents only run`,` `,l(`code`,{className:`font-mono`,children:`agent-only`}),` and`,` `,l(`code`,{className:`font-mono`,children:`any-node`}),` addons. Install / uninstall is hub-driven; agents auto-sync from the hub.`]}),r&&l(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading…`}),a&&l(`div`,{className:`text-xs text-danger`,children:`Failed to load addons`}),!r&&!a&&l(Re,{addons:C,clusterStatus:o,selectedNode:m,onRefresh:()=>void x(),isRefreshing:b})]})}export{ze as AddonsPage};