@camstack/addon-admin-ui 1.2.254 → 1.2.255

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 (99) hide show
  1. package/dist/assets/{AddonCollectionPage-B8AAfSDL.js → AddonCollectionPage-TLv5xNu6.js} +1 -1
  2. package/dist/assets/Addons-Dls32PKZ.js +1 -0
  3. package/dist/assets/{AdminTabs-B7ouLZYU.js → AdminTabs-CeF5bQah.js} +1 -1
  4. package/dist/assets/AiProfiles-FyPKhUI8.js +3 -0
  5. package/dist/assets/{BrokerForm-BCGZaeFv.js → BrokerForm-BrHyHapW.js} +1 -1
  6. package/dist/assets/Build-spy6jDGJ.js +32 -0
  7. package/dist/assets/{Capabilities-BSXS0iic.js → Capabilities-ByefzKBo.js} +1 -1
  8. package/dist/assets/{CapabilityBadges-BuH5ZnqV.js → CapabilityBadges-D1tpftVm.js} +1 -1
  9. package/dist/assets/Cluster-BQEjfP4M.js +11 -0
  10. package/dist/assets/Data-Bprx4i-Z.js +1 -0
  11. package/dist/assets/DetectionIntelligence-BCzteuN_.js +1 -0
  12. package/dist/assets/{DeviceAggregateSection-b0OleJRy.js → DeviceAggregateSection-nw3RoL3p.js} +1 -1
  13. package/dist/assets/DeviceDetail-DfeLMBGq.js +2 -0
  14. package/dist/assets/{Devices-rGfEfZtd.js → Devices-jZ26Lhsa.js} +1 -1
  15. package/dist/assets/EmbedPlayerPage-BLJSZnte.js +1 -0
  16. package/dist/assets/Events-CyukpZa7.js +1 -0
  17. package/dist/assets/{FormBuilder-2CUIzwN1.js → FormBuilder-De1QE6lR.js} +1 -1
  18. package/dist/assets/Identity-BTln8XQq.js +1 -0
  19. package/dist/assets/IntegrationDetail-D5RBd9Xg.js +1 -0
  20. package/dist/assets/Integrations-C4ZF4m0r.js +1 -0
  21. package/dist/assets/{Integrations-Gf6hFFde.js → Integrations-DaRmmkEL.js} +1 -1
  22. package/dist/assets/Locations-DrVdjsGp.js +1 -0
  23. package/dist/assets/{Logs-1N8JVuXz.js → Logs-BELAMuom.js} +1 -1
  24. package/dist/assets/{MotionZonesSettings-CKtgk8II.js → MotionZonesSettings-D-XKdWtc.js} +1 -1
  25. package/dist/assets/{MyAccess-B6IxFAGd.js → MyAccess-B941Y0Cz.js} +1 -1
  26. package/dist/assets/Network-TNBr3Neo.js +1 -0
  27. package/dist/assets/{NodeAddonsSettingsPanel-C1PvlIa8.js → NodeAddonsSettingsPanel-oif7nm1j.js} +1 -1
  28. package/dist/assets/{NodeInferenceDevices-DtUfJgUh.js → NodeInferenceDevices-D7pyunSF.js} +1 -1
  29. package/dist/assets/Notifications-MfFUsRzg.js +1 -0
  30. package/dist/assets/Pipeline-KaU_7eeP.js +1 -0
  31. package/dist/assets/Plates-XpGCrpKe.js +1 -0
  32. package/dist/assets/{PrivacyMaskSettings-BiGDAhR5.js → PrivacyMaskSettings-BBlQhRMB.js} +1 -1
  33. package/dist/assets/{ProviderIcon-DsoksU9G.js → ProviderIcon-Bg794Mtq.js} +1 -1
  34. package/dist/assets/Recordings-Cug4bh00.js +1 -0
  35. package/dist/assets/{ScanNetworkModal-v5I6Xrjn.js → ScanNetworkModal-DKRk-XOO.js} +1 -1
  36. package/dist/assets/{SceneMonitorEditor-DdsV-ikb.js → SceneMonitorEditor-a1_SCVCa.js} +1 -1
  37. package/dist/assets/{Scenes-D2H-frDr.js → Scenes-CPci9RQ1.js} +1 -1
  38. package/dist/assets/{Settings-2Xdg4_Tx.js → Settings-BbTydmUn.js} +1 -1
  39. package/dist/assets/{Showroom-BUzDc9kl.js → Showroom-ChbUwBiW.js} +1 -1
  40. package/dist/assets/{StorageLocationsPanel-DAdm4WAs.js → StorageLocationsPanel-BNcSCHDt.js} +1 -1
  41. package/dist/assets/{Terminal-CH8j9bOM.js → Terminal-C-ptIDdQ.js} +3 -3
  42. package/dist/assets/{Viewer-DApbUpBN.js → Viewer-CpgJCjGH.js} +1 -1
  43. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DDDHg4zu.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-B_G0NXOx.js} +1 -1
  44. package/dist/assets/{archive-DCwAUlJk.js → archive-CRbdCaSb.js} +1 -1
  45. package/dist/assets/{authed-media-CASTZ2s6.js → authed-media-DqKlKsS-.js} +1 -1
  46. package/dist/assets/{boxes-DMME9Zl5.js → boxes-D2Bh3fCW.js} +1 -1
  47. package/dist/assets/circle-slash-C82SplXa.js +1 -0
  48. package/dist/assets/{debounced-invalidate-BF0f8sKt.js → debounced-invalidate-ByCI4xMt.js} +1 -1
  49. package/dist/assets/dist-DSCC6R_U.js +349 -0
  50. package/dist/assets/{dist-BvyglcWp.js → dist-DpeXs_gb.js} +1 -1
  51. package/dist/assets/{face-bbox-B7m4iLC5.js → face-bbox-BhHLNds-.js} +1 -1
  52. package/dist/assets/{hard-drive-download-CRJa-Ozw.js → hard-drive-download-DkCZL0SH.js} +1 -1
  53. package/dist/assets/{hostInit-BKeZVFZM.js → hostInit-Bj_Q0Yr4.js} +1 -1
  54. package/dist/assets/index-Dp0LzduO.js +4 -0
  55. package/dist/assets/{layers-CQIh7Ljo.js → layers-BzRE3UYG.js} +1 -1
  56. package/dist/assets/{location-owned-usage-BHuDXjK4.js → location-owned-usage-CAX9UBx3.js} +1 -1
  57. package/dist/assets/{mf-entry-bootstrap-0-caf103fa.js → mf-entry-bootstrap-0-8b404875.js} +2 -2
  58. package/dist/assets/{player-overlays-cGqx0daW.js → player-overlays-HoF9Jw8W.js} +1 -1
  59. package/dist/assets/remoteEntry-v--6s6XS.js +1 -0
  60. package/dist/assets/{send-CuMuPKN3.js → send-D-Q-sXrM.js} +1 -1
  61. package/dist/assets/{settings-2-0GprkbJ0.js → settings-2-DRKX9ot6.js} +1 -1
  62. package/dist/assets/{square-check-big-Dw87w9Lp.js → square-check-big-QPzSbntH.js} +1 -1
  63. package/dist/assets/src-DB65F6cI.js +349 -0
  64. package/dist/assets/src-DztYcNSO.js +67 -0
  65. package/dist/assets/{use-scenes-feed-Bz_P-UUW.js → use-scenes-feed-C5S7alGb.js} +1 -1
  66. package/dist/assets/{use-stationary-objects-CUqzUFmU.js → use-stationary-objects-DZpJ3-U8.js} +1 -1
  67. package/dist/assets/useEventInvalidation-q7euk8tm.js +1 -0
  68. package/dist/assets/{useNodeUrlSelection-D4CKB8Mz.js → useNodeUrlSelection-Dl0OTBNl.js} +1 -1
  69. package/dist/assets/user-round-BpmEOgJl.js +1 -0
  70. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-PdKodF5K.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-B-sghvB9.js} +2 -2
  71. package/dist/index.html +5 -5
  72. package/dist/server/addon.js +433 -2
  73. package/package.json +1 -1
  74. package/dist/assets/Addons-_1vCBFUm.js +0 -1
  75. package/dist/assets/AiProfiles-DqRGDSmO.js +0 -3
  76. package/dist/assets/Build-Di5YwT9N.js +0 -32
  77. package/dist/assets/Cluster-YL9WIHzx.js +0 -11
  78. package/dist/assets/Data-CG4nNgai.js +0 -1
  79. package/dist/assets/DetectionIntelligence-CM_0G0Zq.js +0 -1
  80. package/dist/assets/DeviceDetail-D1ooLB2B.js +0 -2
  81. package/dist/assets/EmbedPlayerPage-ChrCL219.js +0 -1
  82. package/dist/assets/Events-DoIdqLLe.js +0 -1
  83. package/dist/assets/Identity-BWPZuIZX.js +0 -1
  84. package/dist/assets/IntegrationDetail-BqMdLRMT.js +0 -1
  85. package/dist/assets/Integrations-CBq8427X.js +0 -1
  86. package/dist/assets/Locations-V84awjOS.js +0 -1
  87. package/dist/assets/Network-V8fFOLt_.js +0 -1
  88. package/dist/assets/Notifications-Ay8pIT2l.js +0 -1
  89. package/dist/assets/Pipeline-C6jeUzXu.js +0 -1
  90. package/dist/assets/Plates-Cj5n8DWS.js +0 -1
  91. package/dist/assets/Recordings-BcwXFfbz.js +0 -1
  92. package/dist/assets/circle-slash-BenfPMYw.js +0 -1
  93. package/dist/assets/dist-C0D2rFCN.js +0 -349
  94. package/dist/assets/index-DBT1CKJD.js +0 -4
  95. package/dist/assets/remoteEntry-DFknBykK.js +0 -1
  96. package/dist/assets/src-DFbDFQF1.js +0 -67
  97. package/dist/assets/src-sSNtH9vX.js +0 -349
  98. package/dist/assets/useEventInvalidation-BMBF3OCT.js +0 -1
  99. package/dist/assets/user-round-QtB1-gqL.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-De1BvmWo.mjs
5364
+ //#region ../types/dist/sleep-i3eUVc-d.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).
@@ -13310,6 +13310,97 @@ method(object({ integrationId: string() }), object({ filters: array(AdoptionFilt
13310
13310
  auth: "admin"
13311
13311
  });
13312
13312
  /**
13313
+ * device-admin-link — "this device has a management page of its own, and here
13314
+ * is its address".
13315
+ *
13316
+ * ## Why this is not a `deviceConfig` cap
13317
+ *
13318
+ * There is nothing to edit. A `deviceConfig` cap (D14) exists so the framework
13319
+ * can DERIVE a settings form from `getOptions` + `getStatus` and route a flat
13320
+ * patch back through a setter; it costs a `builderId` reducer in
13321
+ * `device-config-contribution.ts` and a `*-config-schema.ts` beside it, and it
13322
+ * renders a form section. This cap answers ONE question with ONE read and
13323
+ * renders a button. Nothing about it is a form, so it carries no `deviceConfig`
13324
+ * block, no `settings`, no `runtimeState` and no reducer — exactly like
13325
+ * `reboot`, the other pure-RPC device-native cap.
13326
+ *
13327
+ * ## Absent, and the difference between "no page" and "we cannot say"
13328
+ *
13329
+ * The two are answered at DIFFERENT layers, on purpose:
13330
+ *
13331
+ * - **"We cannot say"** → the provider never registers the cap for that
13332
+ * device. A VeSync humidifier, a Petkit feeder, a Dreame vacuum and a Dreo
13333
+ * fan are reached only through a vendor cloud; there is no address to hand
13334
+ * out and no page to open. A Tuya plug, a Wyze camera and a Gree air
13335
+ * conditioner DO have a LAN IP, and still have no HTTP management page
13336
+ * behind it. None of them register, so `deviceManager.getBindings` never
13337
+ * lists the cap and no surface asks.
13338
+ * - **"This device has no page, and I know that"** → the provider registers
13339
+ * and `getAdminLink` returns `null`. This is the answer for a device whose
13340
+ * sibling DOES have a page: a Reolink battery camera reached over UDP by
13341
+ * `uid` with a blank `host`, an Ecowitt gateway configured in `listener`
13342
+ * transport, a Home Assistant broker authenticated by supervisor token
13343
+ * (which carries no `baseUrl` at all).
13344
+ *
13345
+ * Both draw NOTHING. A button that opens a browser error is worse than no
13346
+ * button, and D62 is the same rule from the other side: an off switch is
13347
+ * reported off, never made to look broken. There is no third state where the
13348
+ * UI renders a disabled button "because the device might have a page".
13349
+ *
13350
+ * ## The URL never carries credentials
13351
+ *
13352
+ * Not in userinfo, not in a query string. Every provider builds through
13353
+ * `buildDeviceAdminUrl` (`device-admin-link-url.ts`), which takes host, port,
13354
+ * scheme and path as separate arguments — there is no parameter a secret could
13355
+ * arrive in — and re-checks its own output for the `scheme://user:pass@` shape
13356
+ * that `scripts/check-no-credential-urls-in-fixtures.ts` bans from recorded
13357
+ * output. `scripts/check-admin-link-builder-is-the-only-url-source.ts` is what
13358
+ * keeps providers from hand-rolling one anyway.
13359
+ *
13360
+ * This matters here more than anywhere else in the repo, because every provider
13361
+ * that knows a device's host knows its PASSWORD too: `{ host, port, username,
13362
+ * password }` sit in one object on Hikvision, Amcrest, Reolink and ONVIF alike,
13363
+ * and `http://admin:hunter2@192.168.50.139/` is a URL a browser accepts. The
13364
+ * camera's own page will ask for its own login. That is correct, and pre-
13365
+ * filling it is the operator's business, not ours.
13366
+ *
13367
+ * ## It is a LAN fact
13368
+ *
13369
+ * The URL addresses the device where the NODE can see it. It is not proxied,
13370
+ * not made reachable from outside, and not sent anywhere. A surface renders it
13371
+ * as a link the operator's own browser follows, on the operator's own network,
13372
+ * or renders nothing.
13373
+ */
13374
+ /**
13375
+ * Whose page is it. The distinction is for the OPERATOR, who needs to know
13376
+ * before clicking whether he is about to land on a camera's own web server or
13377
+ * inside Home Assistant.
13378
+ */
13379
+ var AdminLinkTargetEnum = _enum(["device", "integration"]);
13380
+ var DeviceAdminLinkSchema = object({
13381
+ /**
13382
+ * Absolute `http(s)://` URL. Built by `buildDeviceAdminUrl` and therefore
13383
+ * free of userinfo and of any credential-shaped query key.
13384
+ */
13385
+ url: string(),
13386
+ /**
13387
+ * What the surface calls it — "Web UI", "Home Assistant", "UniFi controller".
13388
+ * The PROVIDER names it, because only the provider knows what the page is;
13389
+ * a UI that invented the label from the addon id would call the Home
13390
+ * Assistant device page "Provider Homeassistant".
13391
+ */
13392
+ label: string(),
13393
+ target: AdminLinkTargetEnum,
13394
+ /**
13395
+ * Host the URL points at, without scheme, port or path — for the tooltip, so
13396
+ * an operator can see WHERE the button goes before he follows it. Redundant
13397
+ * with `url` by construction; carried separately so no surface has to parse
13398
+ * a URL to show it.
13399
+ */
13400
+ host: string()
13401
+ });
13402
+ method(object({ deviceId: number().int().nonnegative() }), DeviceAdminLinkSchema.nullable(), { auth: "admin" });
13403
+ /**
13313
13404
  * `device-export` — collection cap for addons that export camstack
13314
13405
  * devices to external ecosystems (HomeAssistant via MQTT discovery,
13315
13406
  * HomeKit/HAP, Alexa Smart Home, …).
@@ -26087,6 +26178,307 @@ DeviceType.Camera, method(object({ deviceId: number() }), DayNightOptionsSchema)
26087
26178
  auth: "admin"
26088
26179
  });
26089
26180
  /**
26181
+ * Vendor-neutral **onboard** recording + storage cap — what the CAMERA
26182
+ * writes to the CAMERA's own card, on the camera's own schedule.
26183
+ *
26184
+ * This is NOT `recording.cap.ts`. That one is CamStack's recorder: our
26185
+ * footage ledger, our storage locations, our retention. This one has a
26186
+ * different authority — the camera's firmware — and per D62 it stores
26187
+ * nothing of its own. Every value here is read from the camera and every
26188
+ * write goes back to the camera; there is no CamStack-side mirror that
26189
+ * could disagree with the device.
26190
+ *
26191
+ * ## One shape, two firmwares
26192
+ *
26193
+ * Measured 2026-09-22 against the live fleet:
26194
+ *
26195
+ * | fact | Hikvision (ISAPI) | Reolink (Baichuan) |
26196
+ * | --- | --- | --- |
26197
+ * | storage | `ContentMgmt/Storage` `<hdd>` rows: status, capacity, freeSpace (MB) | `getHddInfoList` (cmd 102): `mount`, `format`, `capacity` GB + `capacityM` MB remainder |
26198
+ * | tracks | several (101 **and** 103 on both 1436 and 3833), each with its own schedule | one per channel |
26199
+ * | schedule | per track, 7 `ScheduleAction` blocks: DayOfWeek + TimeOfDay range + ONE `ActionRecordingMode` | per trigger type, a 168-char weekly HOUR mask |
26200
+ * | triggers | `CMR`, `MOTION` | `Normal`, `MD`, `people`, `vehicle`, `dog_cat`, `crossline`, `intrude`, `loitering` |
26201
+ * | pre-record | `PreRecordTimeSeconds` | `preRecordTime` |
26202
+ * | post-record | `PostRecordTimeSeconds` | `recordDelayTime` |
26203
+ * | overwrite | per track `LoopEnable` | `cycle`, with `cycleList` enumerating the accepted values |
26204
+ * | segment length | not exposed on V5.7.1 | `packageTime` (minutes) |
26205
+ *
26206
+ * The two schedule models look different and are the same thing in
26207
+ * different coordinates: both answer "for this trigger, during which
26208
+ * weekly windows does the camera record". {@link RecordWindow} is that
26209
+ * question in one shape — Hikvision's ranges map straight onto it,
26210
+ * Reolink's mask expands into hour-aligned windows.
26211
+ *
26212
+ * ## Union, not intersection
26213
+ *
26214
+ * **The same fields exist on every camera.** What differs per device is
26215
+ * which VALUES that device accepts, and that is what {@link
26216
+ * RecordingOnboardOptions} reports — a `{ readable, writable, reason }`
26217
+ * per field plus the schedule's own limits. A control a camera cannot
26218
+ * honour is rendered DISABLED WITH ITS REASON, never missing and never
26219
+ * dead: disabled must not look like broken.
26220
+ *
26221
+ * ## Refusal by name
26222
+ *
26223
+ * A write a camera cannot honour is refused with a sentence the operator
26224
+ * can read — never accepted and dropped. Both providers refuse through
26225
+ * {@link describeOnboardRefusal}, so the vocabulary is one function and
26226
+ * one test, not two hand-written vendor opinions.
26227
+ *
26228
+ * Follows the D14 `deviceConfig` archetype (see `stream-params.cap.ts`):
26229
+ * `getOptions` advertises per-camera availability, `getStatus` (auto-
26230
+ * injected from `status`) reports the live values, and a single
26231
+ * `setSettings` mutation applies a partial change. No hand-written
26232
+ * settings-contribution methods.
26233
+ */
26234
+ /**
26235
+ * What makes the camera start recording during a window.
26236
+ *
26237
+ * The union of both vendors' vocabularies. `continuous` is Hikvision's
26238
+ * `CMR` and Reolink's `Normal`; `motion` is `MOTION` / `MD`. The
26239
+ * object-class triggers are Reolink-only today and the smart-event ones
26240
+ * (`lineCrossing`, `intrusion`, `loitering`) are Reolink-only on the
26241
+ * firmwares measured — a camera that cannot record on a trigger simply
26242
+ * does not list it in `options.schedule.triggers`, and a window naming
26243
+ * it is REFUSED, not dropped.
26244
+ */
26245
+ var RecordTriggerSchema = _enum([
26246
+ "continuous",
26247
+ "motion",
26248
+ "person",
26249
+ "vehicle",
26250
+ "animal",
26251
+ "lineCrossing",
26252
+ "intrusion",
26253
+ "loitering",
26254
+ "alarmInput"
26255
+ ]);
26256
+ /**
26257
+ * One weekly recording window: "on `day`, from `startMinute` to
26258
+ * `endMinute`, record on `trigger`".
26259
+ *
26260
+ * `day` is 0 = Monday … 6 = Sunday (ISO order, which is also the order
26261
+ * both firmwares enumerate). Minutes are local camera time since
26262
+ * midnight; `endMinute` may be 1440, meaning end of day — that is
26263
+ * Hikvision's literal `24:00` and Reolink's 24th mask slot, and
26264
+ * collapsing it to 0 would turn a whole-day window into an empty one.
26265
+ */
26266
+ var RecordWindowSchema = object({
26267
+ trigger: RecordTriggerSchema,
26268
+ day: number().int().min(0).max(6),
26269
+ startMinute: number().int().min(0).max(1439),
26270
+ endMinute: number().int().min(1).max(1440)
26271
+ });
26272
+ /** Status of one physical volume, as the camera itself describes it. */
26273
+ var OnboardStorageVolumeSchema = object({
26274
+ /** The camera's own id for the volume (`hdd/id`, Reolink `HddInfo/number`). */
26275
+ id: string(),
26276
+ /** The camera's own name for it, when it gives one (`hddName`). */
26277
+ label: string().optional(),
26278
+ status: _enum([
26279
+ "ok",
26280
+ "unformatted",
26281
+ "error",
26282
+ "offline",
26283
+ "unknown"
26284
+ ]),
26285
+ /**
26286
+ * Total size in MB, or **null when the camera did not say**.
26287
+ *
26288
+ * Never 0 for an unreadable value: a measurement that failed is not a
26289
+ * measurement (D393), and a card whose size is unknown must not be
26290
+ * rendered as a card of size zero.
26291
+ */
26292
+ capacityMb: number().nullable(),
26293
+ /**
26294
+ * Free space in MB, or null when unknown.
26295
+ *
26296
+ * **Not a proxy for "has footage".** Measured 2026-09-22: 1436 and
26297
+ * 1439 both report exactly 11776 MB free — the fixed reserve a looping
26298
+ * card converges on once it has wrapped. At loop steady state the
26299
+ * number is identical whether the camera recorded yesterday or stopped
26300
+ * a month ago.
26301
+ */
26302
+ freeMb: number().nullable(),
26303
+ /** True when the camera reports the volume writable (`property` RW). */
26304
+ writable: boolean().optional()
26305
+ });
26306
+ object({
26307
+ storage: discriminatedUnion("kind", [
26308
+ object({
26309
+ kind: literal("present"),
26310
+ volumes: array(OnboardStorageVolumeSchema)
26311
+ }),
26312
+ object({
26313
+ kind: literal("absent"),
26314
+ reason: string()
26315
+ }),
26316
+ object({
26317
+ kind: literal("unknown"),
26318
+ reason: string()
26319
+ })
26320
+ ]),
26321
+ tracks: array(object({
26322
+ id: string(),
26323
+ enabled: boolean(),
26324
+ isVideo: boolean(),
26325
+ /** From the camera's own track description. Null when it does not say. */
26326
+ codec: string().nullable(),
26327
+ resolution: string().nullable(),
26328
+ /** Per-track overwrite flag, where the firmware keeps it per track. */
26329
+ overwriteWhenFull: boolean().nullable()
26330
+ })),
26331
+ /**
26332
+ * The track the write path targets — the enabled VIDEO one. Null when
26333
+ * no track could be identified, which is itself a refusal reason.
26334
+ */
26335
+ primaryTrackId: string().nullable(),
26336
+ /** Master "record to the card at all" switch. */
26337
+ enabled: boolean().nullable(),
26338
+ overwriteWhenFull: boolean().nullable(),
26339
+ preRecordSec: number().nullable(),
26340
+ postRecordSec: number().nullable(),
26341
+ /** Length of one recorded file, in minutes. */
26342
+ segmentMinutes: number().nullable(),
26343
+ /** The primary track's weekly windows, flattened. */
26344
+ windows: array(RecordWindowSchema),
26345
+ /**
26346
+ * How many windows the camera described that CamStack could NOT read —
26347
+ * an unrecognised trigger, an unparseable clock, a weekday it does not
26348
+ * name.
26349
+ *
26350
+ * A dropped window is work the reader threw away, and a schedule that
26351
+ * silently shows fewer rows than the camera holds is how an operator
26352
+ * saves back a schedule shorter than the one they were looking at
26353
+ * (D391). Non-zero means the window list is INCOMPLETE and a write
26354
+ * that replaces it would delete what was not shown — which is why a
26355
+ * provider reporting a non-zero count also reports the schedule as not
26356
+ * writable.
26357
+ */
26358
+ unreadableWindows: number(),
26359
+ /**
26360
+ * The camera is scheduled to record and has NO usable storage.
26361
+ *
26362
+ * A first-class fact because it is the fleet's most common silent
26363
+ * defect: measured 2026-09-22, 1441 and 3831 are both motion-recording
26364
+ * to a card that is not there. Neither the schedule nor the storage
26365
+ * read says anything wrong on its own; only the pair does.
26366
+ */
26367
+ recordingToNowhere: boolean(),
26368
+ lastFetchedAt: number()
26369
+ });
26370
+ /** Numeric range descriptor — `{ min, max, step }` per the getOptions convention. */
26371
+ var RangeSchema = object({
26372
+ min: number(),
26373
+ max: number(),
26374
+ step: number()
26375
+ });
26376
+ /**
26377
+ * The values a camera actually takes for a numeric field, when they are a SET
26378
+ * rather than a range.
26379
+ *
26380
+ * `{min,max,step}` cannot say what these two firmwares do. Measured on 1436
26381
+ * (I91DN) on 2026-09-22 by writing each value and reading it back:
26382
+ *
26383
+ * - pre-record: `0, 5, 10, 15, 20, 25, 30` and `2147483647` (INT32_MAX, the
26384
+ * camera's "no limit" — `-1` and `4294967295` both land on it);
26385
+ * - post-record: `5, 10, 30, 60, 120, 300, 600`.
26386
+ *
26387
+ * Neither is expressible as a step: the first has a sentinel two billion away
26388
+ * from its neighbours, the second doubles and then jumps. A range that tried
26389
+ * would forbid values the camera takes AND permit values it silently replaces
26390
+ * with 5 — wrong in both directions at once.
26391
+ *
26392
+ * `sentinel` names the member that is not a duration, so a surface can render
26393
+ * "no limit" instead of `2147483647` seconds.
26394
+ */
26395
+ var AllowedValuesSchema = object({
26396
+ values: array(number()).min(1),
26397
+ sentinel: object({
26398
+ value: number(),
26399
+ meaning: _enum(["no-limit", "disabled"])
26400
+ }).optional()
26401
+ });
26402
+ /**
26403
+ * Per-field availability on ONE camera.
26404
+ *
26405
+ * The field exists on every camera — this says whether this one can be
26406
+ * read and whether it can be written, and `reason` says why not when
26407
+ * either is false. The UI renders the control DISABLED with the reason
26408
+ * rather than hiding it, so a limitation is legible instead of looking
26409
+ * like a missing feature.
26410
+ */
26411
+ var OnboardFieldSupportSchema = object({
26412
+ readable: boolean(),
26413
+ writable: boolean(),
26414
+ /** Required whenever `readable` or `writable` is false. */
26415
+ reason: string().optional()
26416
+ });
26417
+ /** What this camera's schedule model can express. */
26418
+ var OnboardScheduleSupportSchema = object({
26419
+ support: OnboardFieldSupportSchema,
26420
+ /**
26421
+ * The smallest time step the camera can express, in minutes.
26422
+ *
26423
+ * Hikvision takes arbitrary minutes (`00:05:00`–`23:57:00` observed on
26424
+ * 1436's track 103). Reolink's schedule is a 7×24 HOUR mask, so 60. A
26425
+ * window whose edges are not a multiple of this is REFUSED rather than
26426
+ * quietly rounded — rounding is how an operator's 06:30 becomes 06:00
26427
+ * and nothing says so.
26428
+ */
26429
+ granularityMinutes: number(),
26430
+ /** Triggers this camera can record on. A window naming another is refused. */
26431
+ triggers: array(RecordTriggerSchema),
26432
+ /**
26433
+ * False when the camera stores ONE trigger per time range, so two
26434
+ * windows overlapping on the same day cannot carry different triggers.
26435
+ * True on Reolink, whose mask is per-trigger and independent.
26436
+ */
26437
+ supportsOverlappingTriggers: boolean()
26438
+ });
26439
+ var RecordingOnboardOptionsSchema = object({
26440
+ enabled: OnboardFieldSupportSchema,
26441
+ overwriteWhenFull: OnboardFieldSupportSchema,
26442
+ preRecordSec: OnboardFieldSupportSchema,
26443
+ preRecordSecRange: RangeSchema.optional(),
26444
+ /** Preferred over the range when the camera takes a SET, not a span. */
26445
+ preRecordSecAllowed: AllowedValuesSchema.optional(),
26446
+ postRecordSec: OnboardFieldSupportSchema,
26447
+ postRecordSecRange: RangeSchema.optional(),
26448
+ /** Preferred over the range when the camera takes a SET, not a span. */
26449
+ postRecordSecAllowed: AllowedValuesSchema.optional(),
26450
+ segmentMinutes: OnboardFieldSupportSchema,
26451
+ segmentMinutesRange: RangeSchema.optional(),
26452
+ /** Preferred over the range when the camera takes a SET, not a span. */
26453
+ segmentMinutesAllowed: AllowedValuesSchema.optional(),
26454
+ schedule: OnboardScheduleSupportSchema
26455
+ });
26456
+ /**
26457
+ * A partial change. Every field optional.
26458
+ *
26459
+ * Unlike the other `deviceConfig` caps, a provider here does **NOT**
26460
+ * silently ignore a field it cannot support — it refuses, by name,
26461
+ * through {@link describeOnboardRefusal}. Silence on a recording setting
26462
+ * is the failure D62 exists to prevent: the operator believes the camera
26463
+ * is recording the way the form says, and it is not.
26464
+ */
26465
+ var RecordingOnboardPatchSchema = object({
26466
+ enabled: boolean().optional(),
26467
+ overwriteWhenFull: boolean().optional(),
26468
+ preRecordSec: number().optional(),
26469
+ postRecordSec: number().optional(),
26470
+ segmentMinutes: number().optional(),
26471
+ /** The complete new window set for the primary track — not a delta. */
26472
+ windows: array(RecordWindowSchema).optional()
26473
+ });
26474
+ DeviceType.Camera, method(object({ deviceId: number() }), RecordingOnboardOptionsSchema), method(object({
26475
+ deviceId: number(),
26476
+ settings: RecordingOnboardPatchSchema
26477
+ }), _void(), {
26478
+ kind: "mutation",
26479
+ auth: "admin"
26480
+ });
26481
+ /**
26090
26482
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
26091
26483
  * for every device, regardless of provider — the kernel needs a uniform
26092
26484
  * cap-keyed slice for the basic device flags every consumer expects to
@@ -35079,6 +35471,12 @@ Object.freeze({
35079
35471
  addonId: null,
35080
35472
  access: "view"
35081
35473
  },
35474
+ "deviceAdminLink.getAdminLink": {
35475
+ capName: "device-admin-link",
35476
+ capScope: "device",
35477
+ addonId: null,
35478
+ access: "view"
35479
+ },
35082
35480
  "deviceAdoption.adopt": {
35083
35481
  capName: "device-adoption",
35084
35482
  capScope: "system",
@@ -39117,6 +39515,24 @@ Object.freeze({
39117
39515
  addonId: null,
39118
39516
  access: "view"
39119
39517
  },
39518
+ "recordingOnboard.getOptions": {
39519
+ capName: "recording-onboard",
39520
+ capScope: "device",
39521
+ addonId: null,
39522
+ access: "view"
39523
+ },
39524
+ "recordingOnboard.getStatus": {
39525
+ capName: "recording-onboard",
39526
+ capScope: "device",
39527
+ addonId: null,
39528
+ access: "view"
39529
+ },
39530
+ "recordingOnboard.setSettings": {
39531
+ capName: "recording-onboard",
39532
+ capScope: "device",
39533
+ addonId: null,
39534
+ access: "create"
39535
+ },
39120
39536
  "recordingSignal.getStatus": {
39121
39537
  capName: "recording-signal",
39122
39538
  capScope: "device",
@@ -41003,6 +41419,11 @@ Object.freeze({
41003
41419
  form: "single",
41004
41420
  optional: true
41005
41421
  }],
41422
+ "deviceAdminLink.getAdminLink": [{
41423
+ name: "deviceId",
41424
+ form: "single",
41425
+ optional: false
41426
+ }],
41006
41427
  "deviceAdoption.release": [{
41007
41428
  name: "camDeviceId",
41008
41429
  form: "single",
@@ -42388,6 +42809,16 @@ Object.freeze({
42388
42809
  form: "single",
42389
42810
  optional: true
42390
42811
  }],
42812
+ "recordingOnboard.getOptions": [{
42813
+ name: "deviceId",
42814
+ form: "single",
42815
+ optional: false
42816
+ }],
42817
+ "recordingOnboard.setSettings": [{
42818
+ name: "deviceId",
42819
+ form: "single",
42820
+ optional: false
42821
+ }],
42391
42822
  "recordingSignal.getStatus": [{
42392
42823
  name: "deviceId",
42393
42824
  form: "single",
@@ -43316,7 +43747,7 @@ var AdminUIAddon = class extends BaseAddon {
43316
43747
  capability: adminUiCapability,
43317
43748
  provider: {
43318
43749
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
43319
- getVersion: async () => ({ version: "1.2.254" })
43750
+ getVersion: async () => ({ version: "1.2.255" })
43320
43751
  }
43321
43752
  }];
43322
43753
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.254",
3
+ "version": "1.2.255",
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,gt as f,st as p,vt as m}from"./player-overlays-cGqx0daW.js";import{$n as h,Fl as g,Fn as _,Hn as v,In as y,Jn as b,Kn as ee,Lc as x,Ln as S,Nn as C,Pn as w,Q as T,Qn as te,Rn as ne,T as re,Ta as E,Tc as D,Un as ie,Vn as O,Wn as ae,Yn as k,Z as oe,Zn as se,_ as A,du as j,el as M,gl as N,gu as P,jn as ce,ll as F,mn as le,qn as ue,ru as I,sl as L,ul as de,vc as R,wl as fe,xc as z,xl as B,xu as V,yu as pe,zn as H}from"./src-DFbDFQF1.js";import{tn as U}from"./src-sSNtH9vX.js";import{a as me,d as W,s as he}from"./index-DBT1CKJD.js";import{t as G}from"./AdminPage-CiKtOLQm.js";import{t as ge}from"./NodeAddonsSettingsPanel-C1PvlIa8.js";import{r as K,t as q}from"./useNodeUrlSelection-D4CKB8Mz.js";var J=m(`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}=O({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=z(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:j,cls:`bg-muted text-foreground-subtle`,label:`queued`},fetching:{icon:g,cls:`bg-primary/10 text-primary`,label:`fetching`,spin:!0},staged:{icon:g,cls:`bg-primary/10 text-primary`,label:`staged`,spin:!0},validating:{icon:g,cls:`bg-primary/10 text-primary`,label:`validating`,spin:!0},applying:{icon:g,cls:`bg-primary/10 text-primary`,label:`applying`,spin:!0},restarting:{icon:g,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,label:`restarting`,spin:!0},applied:{icon:g,cls:`bg-primary/10 text-primary`,label:`finalizing`,spin:!0},done:{icon:V,cls:`bg-success/10 text-success`,label:`updated`},failed:{icon:J,cls:`bg-danger/10 text-danger`,label:`failed`},skipped:{icon:M,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}=S({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(D,{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(x,{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(g,{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(V,{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(V,{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(I,{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:j,bg:`bg-muted text-foreground-subtle`,label:`queued`},updating:{icon:g,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:V,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(x,{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(g,{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(I,{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(f,{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(f,{className:`h-3 w-3 opacity-50`})]}),u]})}function De({addonId:e}){let t=s(),{data:n=`inherit`}=w({addonId:e}),r=b({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:m,jobProgress:h,bundle:g,bulkItem:_,disabledByBulk:v,isSystem:y}){let[b,x]=c(!1),[S,C]=c(!1),[w,E]=c(!1),[ie,O]=c(null);u(()=>{O(null)},[a]);let k=ie??a,[se,A]=c(!1),[j,M]=c(!1),[P,ce]=c(`logs`),F=s(),ue=me(),I=le(),{manifest:R}=e,z=e.installedOn??[],V=!g&&!R.protected&&R.removable!==!1,H=!!g,U=g?.displayName??R.name,W=g?.packageName??R.packageName,he=g?.version??R.packageVersion??R.version,G=g?.installSource??e.installSource,K=g?g.bundle?.description??g.addons[0]?.manifest.description:R.description,q=te({onSuccess:()=>{F.invalidateQueries({queryKey:[[`addons`]]}),F.invalidateQueries({queryKey:[[`addonPages`]]}),F.invalidateQueries({queryKey:[[`capabilities`]]})}}),Y=ae({onSuccess:()=>{F.invalidateQueries({queryKey:[[`addons`]]})}}),_e=ne({onSuccess:()=>{F.invalidateQueries({queryKey:[[`addons`]]}),F.invalidateQueries({queryKey:[[`addonPages`]]}),F.invalidateQueries({queryKey:[[`capabilities`]]}),F.invalidateQueries({queryKey:[[`integrations`]]})}}),X=ee({onSuccess:()=>{F.invalidateQueries({queryKey:[[`addons`]]}),F.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(N,{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:H||!!R.components&&R.components.length>1,installSource:G,addonId:H?g.addons[0]?.manifest.id:R.id,iconPath:H?g.bundle?.icon??g.addons[0]?.manifest.icon:R.icon,color:H?g.addons[0]?.manifest.color:R.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,...k===void 0?{}:{selectedVersion:k},isUpdating:m,installSource:G,disabled:v,...d&&k!==void 0?{onUpdate:()=>d(k)}:{},onOpenPicker:()=>E(e=>!e),children:w&&l(xe,{packageName:W,currentVersion:he,...G?{installSource:G}:{},...a!==void 0&&k!==void 0?{selectedVersion:k,onSelect:e=>{O(e),E(!1)}}:{},onInstall:e=>{E(!1),_e.mutate({packageName:W,version:e})},onClose:()=>E(!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}),H&&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`}),g.addons.length]}),y&&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(N,{className:`h-3 w-3`}),`System`]}),_!=null&&l(Q,{item:_}),h!=null&&l(be,{progress:h})]}),K&&l(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:K}),!H&&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})]})]})]}),!H&&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:R.id})},disabled:Y.isPending||v,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(N,{className:`h-3 w-3 ${Y.isPending?`animate-spin`:``}`}),`Restart`]}),i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),A(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${se?`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(de,{className:`h-3 w-3`}),`Logs`]}),!H&&i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),M(!0)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${j?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[l(L,{className:`h-3 w-3`}),`Settings`]}),l(`div`,{className:`flex-1`}),V&&i(`button`,{type:`button`,onClick:async e=>{e.stopPropagation(),await I({title:`Uninstall ${R.name}?`,message:`This will remove the addon package and all its data. This action cannot be undone.`,confirmLabel:`Uninstall`,variant:`danger`})&&q.mutate({packageName:R.packageName})},disabled:q.isPending||v,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(p,{className:`h-3 w-3`}),q.isPending?`Removing...`:`Uninstall`]})]}),n&&n.nodes.length>1&&!H&&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))})]}),se&&!H&&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:()=>ce(`logs`),className:`px-2 py-0.5 transition-colors ${P===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Logs`}),l(`button`,{type:`button`,onClick:()=>ce(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${P===`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(),A(!1)},className:`text-foreground-subtle hover:text-foreground`,children:l(D,{className:`h-3.5 w-3.5`})})]}),P===`logs`&&l(T,{addonId:R.id,maxHeight:`max-h-64`,showFilters:!1}),P===`events`&&l(oe,{addonId:R.id,category:`addon.*`,maxHeight:`max-h-64`})]}),H&&i(o,{children:[l(`button`,{type:`button`,onClick:()=>x(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(b?pe:f,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),b&&l(`div`,{className:`border-t border-border px-3 py-2 space-y-2`,children:g.addons.map(e=>l(Oe,{addon:e,agents:t,hideVersion:!0},e.manifest.id))})]}),j&&!H&&l(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4`,onClick:()=>M(!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(L,{className:`h-4 w-4 text-primary`}),i(`h2`,{className:`text-sm font-semibold text-foreground`,children:[U,` Settings`]})]}),l(`button`,{onClick:()=>M(!1),className:`text-foreground-subtle hover:text-foreground transition-colors p-1 rounded`,children:l(D,{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:[R.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(R)&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Device export`}),l(re,{addonId:R.id,onOpenDevice:e=>ue(`/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:R.id})]}),R.components&&R.components.length>0&&i(`div`,{children:[i(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Components (`,R.components.length,`)`]}),l(`div`,{className:`flex flex-wrap gap-1`,children:R.components.map(e=>l(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]}),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:[z.length===0&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Hub (local)`}),z.map(e=>l(`span`,{className:`rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle`,children:e},e)),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(B,{className:`h-3 w-3`}),`Add agent`]}),S&&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&&!z.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&&!z.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:()=>M(!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(g,{className:`w-3.5 h-3.5 animate-spin`}):l(x,{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(),[b,ee]=c(``),x=r(b),[S,C]=c(!1),w=t(null);u(()=>{if(!S)return;let e=e=>{w.current&&!w.current.contains(e.target)&&C(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[S]);let{data:T}=v({nodeId:d.id}),te=a(()=>{let e=new Map;for(let t of T??[])e.set(t.name,t.latestVersion);return e},[T]),re=a(()=>(T??[]).filter(e=>!e.isSystem).length,[T]),[E,D]=c(()=>new Set),[ie,O]=c(()=>new Map),ae=e(e=>{D(t=>new Set(t).add(e))},[]),oe=e(e=>{D(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),A=e((e,t)=>{O(n=>new Map(n).set(e,t))},[]),j=e(e=>{O(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),M=h({onMutate:e=>{ae(e.name),j(e.name)},onSuccess:(e,t)=>{oe(t.name);let n=e;if(n&&n.success===!1){A(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)=>{oe(t.name),A(t.name,e instanceof Error?e.message:String(e))}}),L=ve(),de=t(new Set);u(()=>{let e=new Set;for(let[t,n]of L)X(n)&&e.add(t);let t=[...de.current].some(t=>!e.has(t));de.current=e,t&&(m.invalidateQueries({queryKey:[[`addons`]]}),m.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[L,m]);let{data:R}=_(void 0),fe=ce({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),z=k({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:B,isFetching:pe}=ue({query:x||void 0},{enabled:S}),H=se(),{data:U}=y(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]),le();let q=e(async()=>{let e=(T??[]).filter(e=>!e.isSystem);if(e.length!==0){if(!d.isHub){for(let t of e)await M.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]})}},[T,d.id,d.isHub,H,M]),J=ne({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:[[...ie.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:()=>j(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(N,{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 ${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))})]}),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:R?.updateCheckIntervalSeconds??21600,disabled:z.isPending||R===void 0,onChange:e=>{R!==void 0&&z.mutate({channel:R.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:je.map(e=>l(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),re>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(g,{className:`w-3 h-3 animate-spin`}):l(I,{className:`w-3 h-3`}),H.isPending?`Updating…`:`Update All (${re})`]}),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(N,{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:w,children:[l(F,{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:b,onChange:e=>{ee(e.target.value),C(!0)},onFocus:()=>C(!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`}),pe&&l(g,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin`}),S&&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(V,{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(g,{className:`h-3 w-3 animate-spin`}):l(I,{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(P,{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=te.get(t),r=$(e)?e.representative:e,i=n?e=>M.mutate({name:t,version:e,nodeId:d.id}):void 0,a=L.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:E.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}=H(),{data:o}=E(void 0),{nodes:c}=R(),{selection:d,selectNode:f,requestedNodeId:p}=q(c.length>0?c:[Pe]),m=d.node??Pe,h=m.id,g=c.length>0?d.staleNodeId:null,_=C(),v=ie(),y=_.isPending||v.isPending,b=async()=>{await _.mutateAsync({nodeId:h}),await v.mutateAsync(),e.invalidateQueries({queryKey:[[`addons`]]})},ee=t(_);ee.current=_;let x=t(p??`hub`);u(()=>{ee.current.mutate({nodeId:x.current})},[]);let S=(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(A,{selectedNodeId:h,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:[S.length,` installed`]}),i(`button`,{type:`button`,onClick:()=>void b(),disabled:y,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(N,{className:`w-3 h-3 ${y?`animate-spin`:``}`}),`Check for updates`]})]})]}),l(K,{staleNodeId:g,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:S,clusterStatus:o,selectedNode:m,onRefresh:()=>void b(),isRefreshing:y})]})}export{ze as AddonsPage};