@camstack/addon-admin-ui 1.2.345 → 1.2.347

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 (111) hide show
  1. package/dist/assets/{AddonCollectionPage-DxzFTU90.js → AddonCollectionPage-BloDRZPM.js} +1 -1
  2. package/dist/assets/Addons-DAbqE0o4.js +1 -0
  3. package/dist/assets/{AdminTabs-Bd1950KJ.js → AdminTabs-CxRZ-Ns-.js} +1 -1
  4. package/dist/assets/AiProfiles-DHNGBnSp.js +3 -0
  5. package/dist/assets/{BrokerForm-DGf9yo4j.js → BrokerForm-BraVqHDR.js} +1 -1
  6. package/dist/assets/Build-DHrOFICq.js +40 -0
  7. package/dist/assets/{Calendars-JBqHHqwt.js → Calendars-CzePf8mk.js} +1 -1
  8. package/dist/assets/{Capabilities-DNJjHmDV.js → Capabilities-C1DNqcbB.js} +1 -1
  9. package/dist/assets/Cluster-DRz07MKJ.js +11 -0
  10. package/dist/assets/CompositionEditor-DretlZvS.js +1 -0
  11. package/dist/assets/{CompositionEditorPage-DEZ49NcG.js → CompositionEditorPage-Cdok4IhA.js} +1 -1
  12. package/dist/assets/Data-BSFjWEqS.js +1 -0
  13. package/dist/assets/DetectionIntelligence-BjdUEEk6.js +1 -0
  14. package/dist/assets/DeviceDetail-Bngg-Hlf.js +2 -0
  15. package/dist/assets/{DeviceDoActionFields-Dplk9SjD.js → DeviceDoActionFields-Cjf27YZP.js} +1 -1
  16. package/dist/assets/{Devices-Bj6CscpP.js → Devices-Pa9MHJVp.js} +1 -1
  17. package/dist/assets/EmbedPlayerPage-CT37f5Da.js +1 -0
  18. package/dist/assets/Events-BCa4H-nD.js +1 -0
  19. package/dist/assets/Identity-CJQNbRdc.js +1 -0
  20. package/dist/assets/IntegrationDetail-CXLyibqE.js +1 -0
  21. package/dist/assets/Integrations-B1i-bv16.js +1 -0
  22. package/dist/assets/{Integrations-DzdnfEyW.js → Integrations-C3vPU2-6.js} +1 -1
  23. package/dist/assets/Locations-DcQpfbIG.js +3 -0
  24. package/dist/assets/{Logs-B2mIIrxC.js → Logs-MJSaoa_O.js} +1 -1
  25. package/dist/assets/MotionZonesSettings-DePSiRAB.js +1 -0
  26. package/dist/assets/MyAccess-CzJKeKcu.js +2 -0
  27. package/dist/assets/Network-BJM6MsCc.js +1 -0
  28. package/dist/assets/{NodeAddonsSettingsPanel-DQJQkGit.js → NodeAddonsSettingsPanel-DFJKLbOR.js} +1 -1
  29. package/dist/assets/{NodeInferenceDevices-B6dsiztC.js → NodeInferenceDevices-C0ekrdhi.js} +1 -1
  30. package/dist/assets/Notifications-BK4MN4z4.js +1 -0
  31. package/dist/assets/Pipeline-DsdTy6ox.js +1 -0
  32. package/dist/assets/Plates-B_gbheoU.js +1 -0
  33. package/dist/assets/{PrivacyMaskSettings-FZCxSmjS.js → PrivacyMaskSettings-BRkNbl3p.js} +1 -1
  34. package/dist/assets/Recordings-DsXeAGoc.js +1 -0
  35. package/dist/assets/{ScanNetworkModal-D6Y37vtZ.js → ScanNetworkModal-BRWva-gj.js} +1 -1
  36. package/dist/assets/SceneMonitorEditor-CWYZmoxd.js +1 -0
  37. package/dist/assets/{Scenes-De2-tih3.js → Scenes-BWSH1It4.js} +1 -1
  38. package/dist/assets/{Settings-oXKmMjDx.js → Settings-CG7fer-h.js} +1 -1
  39. package/dist/assets/{Showroom-BxckpAzn.js → Showroom-D8gxeUSA.js} +1 -1
  40. package/dist/assets/{StorageLocationsPanel-Bw4Hv9Rt.js → StorageLocationsPanel-DGIL9j5h.js} +1 -1
  41. package/dist/assets/{Terminal-DvpEoxU5.js → Terminal-uJTnigh_.js} +5 -5
  42. package/dist/assets/{Viewer-Bsb1cIj5.js → Viewer-Dk3OOSaD.js} +1 -1
  43. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Cpf2xhdF.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-3HY6cQ-x.js} +1 -1
  44. package/dist/assets/{archive-DQZ5FHxg.js → archive-CGPOIBn7.js} +1 -1
  45. package/dist/assets/{authed-media-CM12USJq.js → authed-media-Dn598rPH.js} +1 -1
  46. package/dist/assets/{boxes-CI1-aWI-.js → boxes-CO1kdEQA.js} +1 -1
  47. package/dist/assets/circle-slash-DaaX1K-n.js +1 -0
  48. package/dist/assets/client-DSlEHaa4.js +357 -0
  49. package/dist/assets/{debounced-invalidate-vJGPGlle.js → debounced-invalidate-mW12ajLc.js} +1 -1
  50. package/dist/assets/{device-integration-icon-D000Gtf3.js → device-integration-icon-DLRp4QHG.js} +1 -1
  51. package/dist/assets/device-picker-model-DBeWQItf.js +1 -0
  52. package/dist/assets/{dist-CQ4IkN0R.js → dist-Ce-ggKp4.js} +1 -1
  53. package/dist/assets/dist-DFXoD3dx.js +357 -0
  54. package/dist/assets/{face-bbox-BKfPOkK2.js → face-bbox-GOW9VwOC.js} +1 -1
  55. package/dist/assets/{hard-drive-download-BZpsY3VN.js → hard-drive-download-85gvHw4p.js} +1 -1
  56. package/dist/assets/{hostInit-hPe7d63f.js → hostInit-B4pEjSfM.js} +1 -1
  57. package/dist/assets/{index-a-YFw77c.css → index-BJCZa1JH.css} +1 -1
  58. package/dist/assets/index-DjWUD8TM.js +4 -0
  59. package/dist/assets/{layers-epIRZStd.js → layers-CrV11Qfh.js} +1 -1
  60. package/dist/assets/{location-owned-usage-B1G_o9cu.js → location-owned-usage-BnHfXGXt.js} +1 -1
  61. package/dist/assets/{mf-entry-bootstrap-0-fdd3f5f7.js → mf-entry-bootstrap-0-25880b2e.js} +2 -2
  62. package/dist/assets/mount-DBeWQItf.js +1 -0
  63. package/dist/assets/notification-schedule-field-DAFrqRNK.js +1 -0
  64. package/dist/assets/{player-overlays-8C7Chgtp.js → player-overlays-cPTznd9K.js} +1 -1
  65. package/dist/assets/remoteEntry-eX8IOSk0.js +1 -0
  66. package/dist/assets/{send-DZeFKKhQ.js → send-DcHTbbQP.js} +1 -1
  67. package/dist/assets/{settings-2-B70kPnTR.js → settings-2-FmHgu3yu.js} +1 -1
  68. package/dist/assets/{square-check-big-D5MuMUSA.js → square-check-big-DglRhQIn.js} +1 -1
  69. package/dist/assets/src-BgRXoWYI.js +67 -0
  70. package/dist/assets/{use-scenes-feed-CX9FNB3x.js → use-scenes-feed-BFjJlNQ2.js} +1 -1
  71. package/dist/assets/{use-stationary-objects-CA2kqBy5.js → use-stationary-objects-DDyFcu7n.js} +1 -1
  72. package/dist/assets/useEventInvalidation-DBeWQItf.js +1 -0
  73. package/dist/assets/{useNodeUrlSelection-4PSI9SqT.js → useNodeUrlSelection-DENvluDA.js} +1 -1
  74. package/dist/assets/user-round-C5tSWJcI.js +1 -0
  75. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-j2hvdY7k.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DIbYB7cO.js} +2 -2
  76. package/dist/index.html +8 -8
  77. package/dist/server/addon.js +215 -172
  78. package/package.json +1 -1
  79. package/dist/assets/Addons-DRMpHsp4.js +0 -1
  80. package/dist/assets/AiProfiles-C2nPDM3i.js +0 -3
  81. package/dist/assets/Build-BzWFkHjF.js +0 -40
  82. package/dist/assets/Cluster-DlGhBZIn.js +0 -11
  83. package/dist/assets/CompositionEditor-vKgiATLA.js +0 -1
  84. package/dist/assets/Data-Bds4gE2c.js +0 -1
  85. package/dist/assets/DetectionIntelligence-CTpq1Y6I.js +0 -1
  86. package/dist/assets/DeviceDetail-BW60HW9h.js +0 -2
  87. package/dist/assets/EmbedPlayerPage-DZMOEPWR.js +0 -1
  88. package/dist/assets/Events-DPcNWJss.js +0 -1
  89. package/dist/assets/Identity-Be4gOAIe.js +0 -1
  90. package/dist/assets/IntegrationDetail-DuroxAAE.js +0 -1
  91. package/dist/assets/Integrations-B6oOd-nv.js +0 -1
  92. package/dist/assets/Locations-CbwsKjt0.js +0 -3
  93. package/dist/assets/MotionZonesSettings-MTt6ORez.js +0 -1
  94. package/dist/assets/MyAccess-Dxp2pgZV.js +0 -2
  95. package/dist/assets/Network-DvRubcMm.js +0 -1
  96. package/dist/assets/Notifications-Ze3GwOK6.js +0 -1
  97. package/dist/assets/Pipeline-gwJZ7DOT.js +0 -1
  98. package/dist/assets/Plates-DT6xndAE.js +0 -1
  99. package/dist/assets/Recordings-BnCv_e-x.js +0 -1
  100. package/dist/assets/SceneMonitorEditor-Dh2nvXgH.js +0 -1
  101. package/dist/assets/circle-slash-B43tX-bj.js +0 -1
  102. package/dist/assets/client-Dc_lJW_Z.js +0 -357
  103. package/dist/assets/device-picker-model-DhESFLV5.js +0 -1
  104. package/dist/assets/dist-BlILRcih.js +0 -357
  105. package/dist/assets/index-DlFwo3E1.js +0 -4
  106. package/dist/assets/mount-DhESFLV5.js +0 -1
  107. package/dist/assets/notification-schedule-field-Dw7iSL3z.js +0 -1
  108. package/dist/assets/remoteEntry-CCqI3Jvb.js +0 -1
  109. package/dist/assets/src-CnGTho8r.js +0 -67
  110. package/dist/assets/useEventInvalidation-DhESFLV5.js +0 -1
  111. package/dist/assets/user-round-CUchN6hz.js +0 -1
@@ -5380,7 +5380,7 @@ var ZodIssueCode = {
5380
5380
  var ZodFirstPartyTypeKind;
5381
5381
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5382
5382
  //#endregion
5383
- //#region ../types/dist/sleep-C16NCZR2.mjs
5383
+ //#region ../types/dist/sleep-DAJ9Er57.mjs
5384
5384
  /**
5385
5385
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5386
5386
  * window to float samples (D455).
@@ -23659,148 +23659,17 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
23659
23659
  settings: record(string(), unknown()).optional()
23660
23660
  }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
23661
23661
  /**
23662
- * Wire shapes of the Load balancing surface (D748): the session placement
23663
- * policy, the atomic share write, the observed placement statistics, the
23664
- * hardware share suggestion and the stale device pins.
23665
- */
23666
- /**
23667
- * How a new detection session picks its node and device.
23668
- * - `least-loaded` — the historical rule: lowest `attached / weight`, a
23669
- * constant node order at a tie (D37). An idle node always ties at 0, so a
23670
- * weight only bites once a node already holds a session.
23671
- * - `share` — the share of PARALLEL sessions is held to the weights, and a
23672
- * full or drowning node yields to a free one (D748).
23673
- */
23674
- var SessionPlacementPolicySchema = _enum(["least-loaded", "share"]);
23675
- var LoadBalancingSharesInputSchema = object({
23676
- /** nodeId → share (> 0). A node left out keeps its weight. */
23677
- nodes: record(string(), number().positive()).default({}),
23678
- /** nodeId → deviceKey → share (> 0). A device left out keeps its weight. */
23679
- devices: record(string(), record(string(), number().positive())).default({})
23680
- });
23681
- var PlacementStatsInputSchema = object({
23682
- /** Window the observed shares are averaged over (default 1 h, max 24 h). */
23683
- windowMs: number().int().min(6e4).max(1440 * 60 * 1e3).default(3600 * 1e3) });
23684
- var PlacementDeviceStatsSchema = object({
23685
- deviceKey: string(),
23686
- /** Sessions running on this device now. */
23687
- sessionsNow: number(),
23688
- /** Sessions started on this device inside the window. */
23689
- sessionsStarted: number(),
23690
- /** Time-weighted share of the node's parallel sessions over the window (0–1); null = no session ran. */
23691
- observedShare: number().nullable()
23692
- });
23693
- var PlacementNodeStatsSchema = object({
23694
- nodeId: string(),
23695
- sessionsNow: number(),
23696
- sessionsStarted: number(),
23697
- /** Time-weighted share of the cluster's parallel sessions over the window (0–1); null = none ran. */
23698
- observedShare: number().nullable(),
23699
- /** Most sessions this node ran at once inside the window. */
23700
- peakSessions: number(),
23701
- /** Sessions a share election handed elsewhere because this node was full or drowning. */
23702
- yieldsAway: number(),
23703
- devices: array(PlacementDeviceStatsSchema).readonly()
23704
- });
23705
- /** A camera's device pin that the session path cannot honour. */
23706
- var StaleDevicePinSchema = object({
23707
- deviceId: number(),
23708
- deviceKey: string(),
23709
- /** `disabled` — the key exists on some node but is not enabled anywhere; `absent` — no node has it. */
23710
- reason: _enum(["disabled", "absent"])
23711
- });
23712
- var PlacementStatsSchema = object({
23713
- policy: SessionPlacementPolicySchema,
23714
- windowMs: number(),
23715
- /** How much of the window was actually observed (the hub keeps it in memory). */
23716
- observedForMs: number(),
23717
- sessionsNow: number(),
23718
- /** Most parallel sessions across the cluster inside the window. */
23719
- clusterPeakSessions: number(),
23720
- nodes: array(PlacementNodeStatsSchema).readonly(),
23721
- stalePins: array(StaleDevicePinSchema).readonly()
23722
- });
23723
- var SuggestSharesInputSchema = object({ headroom: number().min(.3).max(.5).default(.4) });
23724
- var SuggestedDeviceShareSchema = object({
23725
- deviceKey: string(),
23726
- /** Share of the node (0–100, rounded). */
23727
- share: number(),
23728
- modelId: string().nullable(),
23729
- /** Inferences per second at that model, from the measured table. */
23730
- fps: number().nullable(),
23731
- measured: boolean(),
23732
- /** Advisory session cap: ⌊fps × (1 − headroom) / camera fps⌋. Never enforced. */
23733
- suggestedMaxSessions: number().nullable()
23734
- });
23735
- var SuggestedNodeShareSchema = object({
23736
- nodeId: string(),
23737
- /** Share of the cluster (0–100, rounded); null = node skipped (offline, unknown hardware). */
23738
- share: number().nullable(),
23739
- /** Parallel sessions the node sustains at the suggested models with the headroom kept free. */
23740
- capacitySessions: number(),
23741
- devices: array(SuggestedDeviceShareSchema).readonly(),
23742
- skippedReason: string().nullable()
23743
- });
23744
- var SuggestSharesResultSchema = object({
23745
- headroom: number(),
23746
- /** Camera detection rate the capacity is counted in (the fastest camera's fps). */
23747
- cameraFps: number(),
23748
- /** How many share → model → capacity rounds ran before the shares stopped moving (≤ 3). */
23749
- iterations: number(),
23750
- nodes: array(SuggestedNodeShareSchema).readonly()
23751
- });
23752
- /**
23753
- * Where the node and device shares come from (D750).
23754
- * - `auto` — computed by the system from the cluster's measured capacity at
23755
- * the Auto tune models, and recomputed whenever a node or device joins,
23756
- * leaves, is switched on or off, or changes model.
23757
- * - `manual` — the operator's stored sliders. A node or device that cannot
23758
- * take sessions gives its share to the others in proportion; the stored
23759
- * values are never rewritten for that.
23760
- */
23761
- var ShareSourceSchema = _enum(["auto", "manual"]);
23762
- var SetShareSourceInputSchema = object({ source: ShareSourceSchema });
23763
- object({
23764
- nodes: record(string(), number()),
23765
- devices: record(string(), record(string(), number()))
23766
- });
23767
- var EffectiveDeviceShareSchema = object({
23768
- deviceKey: string(),
23769
- /** Can take sessions now (enabled, available, can run the root). */
23770
- eligible: boolean(),
23771
- /** The share the source assigns, as a percentage of the node's devices. */
23772
- configuredPct: number(),
23773
- /** The share actually used, after an ineligible device's share went to the others. */
23774
- effectivePct: number()
23775
- });
23776
- var EffectiveNodeShareSchema = object({
23777
- nodeId: string(),
23778
- eligible: boolean(),
23779
- configuredPct: number(),
23780
- effectivePct: number(),
23781
- devices: array(EffectiveDeviceShareSchema).readonly()
23782
- });
23783
- var EffectiveSharesSchema = object({
23784
- source: ShareSourceSchema,
23785
- policy: SessionPlacementPolicySchema,
23786
- /** `auto` with no computed answer yet: the stored sliders are used meanwhile. */
23787
- autoPending: boolean(),
23788
- /** When the automatic shares were last computed (ms epoch); null = never. */
23789
- computedAt: number().nullable(),
23790
- /** What made the system recompute them last. */
23791
- trigger: string().nullable(),
23792
- nodes: array(EffectiveNodeShareSchema).readonly(),
23793
- /** The relative weights the election reads (before eligibility). */
23794
- nodeWeights: record(string(), number()),
23795
- deviceWeights: record(string(), record(string(), number()))
23796
- });
23797
- /**
23798
23662
  * The wire shapes of the Auto tune plan and apply (D745), used by the
23799
23663
  * `pipeline-orchestrator` cap. The recommender's own types
23800
- * (`recommend.ts`, `demand.ts`) are the TS face of the same data; these
23664
+ * (`recommend.ts`) are the TS face of the same data; these
23801
23665
  * schemas are what crosses the cap boundary.
23802
23666
  */
23803
23667
  var ModelFormatSchema$1 = _enum(MODEL_FORMATS);
23668
+ /** The operator's range for it. */
23669
+ var MIN_SESSIONS_PER_DEVICE_RANGE = {
23670
+ min: 1,
23671
+ max: 8
23672
+ };
23804
23673
  var HardwareClassIdSchema = _enum([
23805
23674
  "intel-core-ultra",
23806
23675
  "intel-n-series",
@@ -23818,8 +23687,9 @@ var AcceleratorKindSchema = _enum([
23818
23687
  ]);
23819
23688
  var RecommendationReasonSchema = discriminatedUnion("kind", [
23820
23689
  object({
23821
- kind: literal("fits"),
23822
- utilisation: number()
23690
+ kind: literal("capacity"),
23691
+ sessions: number(),
23692
+ minSessions: number()
23823
23693
  }),
23824
23694
  object({
23825
23695
  kind: literal("tie-faster"),
@@ -23834,16 +23704,13 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
23834
23704
  }),
23835
23705
  object({
23836
23706
  kind: literal("no-fit-lightest"),
23837
- utilisation: number()
23707
+ sessions: number(),
23708
+ minSessions: number()
23838
23709
  }),
23839
23710
  object({
23840
23711
  kind: literal("derived-latency"),
23841
23712
  modelId: string()
23842
23713
  }),
23843
- object({
23844
- kind: literal("estimated-load"),
23845
- observedForMs: number().nullable()
23846
- }),
23847
23714
  object({ kind: literal("cpu-device") }),
23848
23715
  object({ kind: literal("coral-untouched") }),
23849
23716
  object({ kind: literal("device-disabled") }),
@@ -23859,28 +23726,13 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
23859
23726
  format: ModelFormatSchema$1
23860
23727
  })
23861
23728
  ]);
23862
- var DeviceDemandSchema = object({
23863
- nodeId: string(),
23864
- deviceKey: string(),
23865
- demandFps: number(),
23866
- maxCameraFps: number(),
23867
- alwaysOnCameras: number(),
23868
- onMotionSessions: number(),
23869
- onMotionSource: _enum([
23870
- "observed-24h",
23871
- "estimate",
23872
- "none"
23873
- ]),
23874
- observedForMs: number().nullable(),
23875
- /** How on-motion sessions were charged: per-device observation, or split by share (D748). */
23876
- placement: SessionPlacementPolicySchema
23877
- });
23878
23729
  var DeviceModelChoiceSchema = object({
23879
23730
  modelId: string(),
23880
23731
  p50Ms: number(),
23881
23732
  fps: number(),
23882
23733
  measured: boolean(),
23883
- utilisation: number(),
23734
+ /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
23735
+ capacitySessions: number(),
23884
23736
  personRecall: number()
23885
23737
  });
23886
23738
  var DeviceRecommendationSchema = object({
@@ -23888,7 +23740,6 @@ var DeviceRecommendationSchema = object({
23888
23740
  accelerator: AcceleratorKindSchema.nullable(),
23889
23741
  enabled: boolean(),
23890
23742
  available: boolean(),
23891
- demand: DeviceDemandSchema.nullable(),
23892
23743
  chosen: DeviceModelChoiceSchema.nullable(),
23893
23744
  reasons: array(RecommendationReasonSchema).readonly()
23894
23745
  });
@@ -23949,20 +23800,20 @@ var AutoTuneOptionsSchema = object({
23949
23800
  /** Share of each accelerator's throughput kept free (0.3–0.5). */
23950
23801
  headroom: number().min(.3).max(.5).default(.4),
23951
23802
  /**
23952
- * What-if shares (D748): plan as if these node/device shares were stored
23953
- * and the policy were `share`. Absent = the stored shares under the stored
23954
- * policy. A what-if plan is for display; apply always re-plans from what
23955
- * is stored.
23803
+ * The least number of parallel sessions every device must sustain at the
23804
+ * camera rate with the headroom kept free (D755). The most accurate model
23805
+ * that reaches it wins.
23956
23806
  */
23957
- shares: LoadBalancingSharesInputSchema.optional()
23807
+ minSessionsPerDevice: number().int().min(MIN_SESSIONS_PER_DEVICE_RANGE.min).max(MIN_SESSIONS_PER_DEVICE_RANGE.max).default(2)
23958
23808
  });
23959
23809
  var AutoTunePlanSchema = object({
23960
23810
  /** Hash of everything the apply will write — the apply refuses a different one. */
23961
23811
  planHash: string(),
23962
23812
  family: literal("yolov9"),
23963
23813
  headroom: number(),
23964
- /** Planned under what-if shares (D748): for display — apply refuses it as stale. */
23965
- whatIf: boolean(),
23814
+ minSessionsPerDevice: number(),
23815
+ /** The detection rate a session is counted at (the fastest camera running the pipeline root). */
23816
+ cameraFps: number(),
23966
23817
  generatedAt: number(),
23967
23818
  nodes: array(NodeRecommendationSchema).readonly(),
23968
23819
  nodeChanges: array(NodeDeviceChangeSchema).readonly(),
@@ -23972,7 +23823,8 @@ var AutoTunePlanSchema = object({
23972
23823
  });
23973
23824
  var AutoTuneApplyInputSchema = object({
23974
23825
  planHash: string(),
23975
- headroom: number().min(.3).max(.5).default(.4)
23826
+ headroom: number().min(.3).max(.5).default(.4),
23827
+ minSessionsPerDevice: number().int().min(MIN_SESSIONS_PER_DEVICE_RANGE.min).max(MIN_SESSIONS_PER_DEVICE_RANGE.max).default(2)
23976
23828
  });
23977
23829
  var AutoTunePhaseResultSchema = object({
23978
23830
  phase: _enum([
@@ -24004,6 +23856,177 @@ var AutoTuneApplyResultSchema = discriminatedUnion("kind", [
24004
23856
  reason: _enum(["apply-in-progress"])
24005
23857
  })
24006
23858
  ]);
23859
+ /**
23860
+ * Wire shapes of the Load balancing surface (D748): the session placement
23861
+ * policy, the atomic share write, the observed placement statistics, the
23862
+ * hardware share suggestion and the stale device pins.
23863
+ */
23864
+ /**
23865
+ * How a new detection session picks its node and device.
23866
+ * - `least-loaded` — the historical rule: lowest `attached / weight`, a
23867
+ * constant node order at a tie (D37). An idle node always ties at 0, so a
23868
+ * weight only bites once a node already holds a session.
23869
+ * - `share` — the share of PARALLEL sessions is held to the weights, and a
23870
+ * full or drowning node yields to a free one (D748).
23871
+ */
23872
+ var SessionPlacementPolicySchema = _enum(["least-loaded", "share"]);
23873
+ var LoadBalancingSharesInputSchema = object({
23874
+ /** nodeId → share (> 0). A node left out keeps its weight. */
23875
+ nodes: record(string(), number().positive()).default({}),
23876
+ /** nodeId → deviceKey → share (> 0). A device left out keeps its weight. */
23877
+ devices: record(string(), record(string(), number().positive())).default({})
23878
+ });
23879
+ var PlacementStatsInputSchema = object({
23880
+ /** Window the observed shares are averaged over (default 1 h, max 24 h). */
23881
+ windowMs: number().int().min(6e4).max(1440 * 60 * 1e3).default(3600 * 1e3) });
23882
+ var PlacementDeviceStatsSchema = object({
23883
+ deviceKey: string(),
23884
+ /** Sessions running on this device now. */
23885
+ sessionsNow: number(),
23886
+ /** Sessions started on this device inside the window. */
23887
+ sessionsStarted: number(),
23888
+ /** Time-weighted share of the node's parallel sessions over the window (0–1); null = no session ran. */
23889
+ observedShare: number().nullable()
23890
+ });
23891
+ var PlacementNodeStatsSchema = object({
23892
+ nodeId: string(),
23893
+ sessionsNow: number(),
23894
+ sessionsStarted: number(),
23895
+ /** Time-weighted share of the cluster's parallel sessions over the window (0–1); null = none ran. */
23896
+ observedShare: number().nullable(),
23897
+ /** Most sessions this node ran at once inside the window. */
23898
+ peakSessions: number(),
23899
+ /** Sessions a share election handed elsewhere because this node was full or drowning. */
23900
+ yieldsAway: number(),
23901
+ devices: array(PlacementDeviceStatsSchema).readonly()
23902
+ });
23903
+ /** A camera's device pin that the session path cannot honour. */
23904
+ var StaleDevicePinSchema = object({
23905
+ deviceId: number(),
23906
+ deviceKey: string(),
23907
+ /** `disabled` — the key exists on some node but is not enabled anywhere; `absent` — no node has it. */
23908
+ reason: _enum(["disabled", "absent"])
23909
+ });
23910
+ var PlacementStatsSchema = object({
23911
+ policy: SessionPlacementPolicySchema,
23912
+ windowMs: number(),
23913
+ /** How much of the window was actually observed (the hub keeps it in memory). */
23914
+ observedForMs: number(),
23915
+ sessionsNow: number(),
23916
+ /** Most parallel sessions across the cluster inside the window. */
23917
+ clusterPeakSessions: number(),
23918
+ nodes: array(PlacementNodeStatsSchema).readonly(),
23919
+ stalePins: array(StaleDevicePinSchema).readonly()
23920
+ });
23921
+ /**
23922
+ * Where an automatic share's capacity comes from (D755).
23923
+ * - `hardware` — the static capacity of each device at its Auto tune model:
23924
+ * the measured latency table for the node's hardware class.
23925
+ * - `benchmark` — the node's own measured capacity (node benchmark results).
23926
+ * A node with no results falls back to `hardware`, and says so.
23927
+ */
23928
+ var CapacitySourceSchema = _enum(["hardware", "benchmark"]);
23929
+ /** Why a node under the `benchmark` source was sized from hardware instead. */
23930
+ var CapacityFallbackSchema = _enum(["no-benchmark-results", "partial-benchmark-results"]);
23931
+ var SuggestSharesInputSchema = object({
23932
+ headroom: number().min(.3).max(.5).default(.4),
23933
+ /** Default `hardware`. */
23934
+ source: CapacitySourceSchema.default("hardware")
23935
+ });
23936
+ var SuggestedDeviceShareSchema = object({
23937
+ deviceKey: string(),
23938
+ /** Share of the node (0–100, rounded). */
23939
+ share: number(),
23940
+ modelId: string().nullable(),
23941
+ /** Inferences per second at that model, from the measured table; null when sized by a benchmark. */
23942
+ fps: number().nullable(),
23943
+ /** False for a table cell derived from another chip; true for a measured cell or a benchmark. */
23944
+ measured: boolean(),
23945
+ /**
23946
+ * Advisory session cap: ⌊fps × (1 − headroom) / camera fps⌋ from the table,
23947
+ * or the benchmark's measured max sessions. Never enforced.
23948
+ */
23949
+ suggestedMaxSessions: number().nullable()
23950
+ });
23951
+ var SuggestedNodeShareSchema = object({
23952
+ nodeId: string(),
23953
+ /** Share of the cluster (0–100, rounded); null = node skipped (offline, unknown hardware). */
23954
+ share: number().nullable(),
23955
+ /** Parallel sessions the node sustains at the suggested models with the headroom kept free. */
23956
+ capacitySessions: number(),
23957
+ devices: array(SuggestedDeviceShareSchema).readonly(),
23958
+ skippedReason: string().nullable(),
23959
+ /** What this node's capacity was read from; null when the node is skipped. */
23960
+ capacitySource: CapacitySourceSchema.nullable(),
23961
+ /** Set when the `benchmark` source was asked for and this node used `hardware`. */
23962
+ capacityFallback: CapacityFallbackSchema.nullable()
23963
+ });
23964
+ var SuggestSharesResultSchema = object({
23965
+ headroom: number(),
23966
+ /** The source asked for; each node says what it actually used. */
23967
+ source: CapacitySourceSchema,
23968
+ /** Camera detection rate the capacity is counted in (the fastest camera's fps). */
23969
+ cameraFps: number(),
23970
+ /** The Auto tune capacity floor the models were picked at. */
23971
+ minSessionsPerDevice: number(),
23972
+ nodes: array(SuggestedNodeShareSchema).readonly()
23973
+ });
23974
+ /**
23975
+ * Where the node and device shares come from (D750, D755).
23976
+ * - `hardware` (default) — computed by the system from each node's static
23977
+ * capacity (its accelerators at their Auto tune models, from the measured
23978
+ * latency table), recomputed whenever a node or device joins, leaves, is
23979
+ * switched on or off, or changes model. No load input.
23980
+ * - `benchmark` — the same, from each node's measured capacity (node
23981
+ * benchmark results); a node without results falls back to `hardware`.
23982
+ * - `manual` — the operator's stored sliders.
23983
+ * Either way a node or device that cannot take sessions gives its share to
23984
+ * the others in proportion; the stored values are never rewritten for that.
23985
+ */
23986
+ var ShareSourceSchema = _enum([
23987
+ "hardware",
23988
+ "benchmark",
23989
+ "manual"
23990
+ ]);
23991
+ var SetShareSourceInputSchema = object({ source: ShareSourceSchema });
23992
+ object({
23993
+ nodes: record(string(), number()),
23994
+ devices: record(string(), record(string(), number()))
23995
+ });
23996
+ var EffectiveDeviceShareSchema = object({
23997
+ deviceKey: string(),
23998
+ /** Can take sessions now (enabled, available, can run the root). */
23999
+ eligible: boolean(),
24000
+ /** The share the source assigns, as a percentage of the node's devices. */
24001
+ configuredPct: number(),
24002
+ /** The share actually used, after an ineligible device's share went to the others. */
24003
+ effectivePct: number()
24004
+ });
24005
+ var EffectiveNodeShareSchema = object({
24006
+ nodeId: string(),
24007
+ eligible: boolean(),
24008
+ configuredPct: number(),
24009
+ effectivePct: number(),
24010
+ /** Automatic sources: what this node's share was computed from; null under `manual` or before the first answer. */
24011
+ capacitySource: CapacitySourceSchema.nullable(),
24012
+ /** Automatic `benchmark`: why this node used `hardware` instead. */
24013
+ capacityFallback: CapacityFallbackSchema.nullable(),
24014
+ devices: array(EffectiveDeviceShareSchema).readonly()
24015
+ });
24016
+ var EffectiveSharesSchema = object({
24017
+ source: ShareSourceSchema,
24018
+ policy: SessionPlacementPolicySchema,
24019
+ /** An automatic source with no computed answer yet: the stored sliders are used meanwhile. */
24020
+ autoPending: boolean(),
24021
+ /** When the automatic shares were last computed (ms epoch); null = never. */
24022
+ computedAt: number().nullable(),
24023
+ /** What made the system recompute them last. */
24024
+ trigger: string().nullable(),
24025
+ nodes: array(EffectiveNodeShareSchema).readonly(),
24026
+ /** The relative weights the election reads (before eligibility). */
24027
+ nodeWeights: record(string(), number()),
24028
+ deviceWeights: record(string(), record(string(), number()))
24029
+ });
24007
24030
  object({
24008
24031
  activeCameras: number(),
24009
24032
  throttledCameras: number(),
@@ -25183,8 +25206,10 @@ var CameraStepOverridePatchSchema = object({
25183
25206
  modelId: string().optional(),
25184
25207
  settings: record(string(), unknown()).readonly().optional()
25185
25208
  });
25209
+ var CameraStepSettingsSchema = record(string(), record(string(), unknown()).readonly());
25186
25210
  var CameraPipelineSettingsSchema = object({
25187
25211
  stepToggles: record(string(), boolean()).optional(),
25212
+ stepSettings: CameraStepSettingsSchema.optional(),
25188
25213
  stepOverridesByDevice: record(string(), record(string(), record(string(), CameraStepOverridePatchSchema))).optional(),
25189
25214
  pipelineByAgent: record(string(), CameraPipelineForAgentSchema).optional()
25190
25215
  });
@@ -25748,6 +25773,13 @@ method(object({
25748
25773
  }), object({ success: literal(true) }), {
25749
25774
  kind: "mutation",
25750
25775
  auth: "admin"
25776
+ }), method(object({
25777
+ deviceId: number(),
25778
+ addonId: string(),
25779
+ settings: record(string(), unknown()).nullable()
25780
+ }), object({ success: literal(true) }), {
25781
+ kind: "mutation",
25782
+ auth: "admin"
25751
25783
  }), method(object({
25752
25784
  deviceId: number(),
25753
25785
  agentNodeId: string(),
@@ -41823,6 +41855,12 @@ Object.freeze({
41823
41855
  addonId: null,
41824
41856
  access: "create"
41825
41857
  },
41858
+ "pipelineOrchestrator.setCameraStepSettings": {
41859
+ capName: "pipeline-orchestrator",
41860
+ capScope: "system",
41861
+ addonId: null,
41862
+ access: "create"
41863
+ },
41826
41864
  "pipelineOrchestrator.setCameraStepToggle": {
41827
41865
  capName: "pipeline-orchestrator",
41828
41866
  capScope: "system",
@@ -47271,6 +47309,11 @@ Object.freeze({
47271
47309
  form: "single",
47272
47310
  optional: false
47273
47311
  }],
47312
+ "pipelineOrchestrator.setCameraStepSettings": [{
47313
+ name: "deviceId",
47314
+ form: "single",
47315
+ optional: false
47316
+ }],
47274
47317
  "pipelineOrchestrator.setCameraStepToggle": [{
47275
47318
  name: "deviceId",
47276
47319
  form: "single",
@@ -49205,7 +49248,7 @@ var AdminUIAddon = class extends BaseAddon {
49205
49248
  capability: adminUiCapability,
49206
49249
  provider: {
49207
49250
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
49208
- getVersion: async () => ({ version: "1.2.345" })
49251
+ getVersion: async () => ({ version: "1.2.347" })
49209
49252
  }
49210
49253
  }];
49211
49254
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.345",
3
+ "version": "1.2.347",
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-8C7Chgtp.js";import{Au as h,Du as g,Ed as _,El as v,Er as y,Gl as b,In as x,Nl as S,Nu as C,Sr as w,Tr as T,Wu as E,_r as ee,_u as te,bo as D,br as ne,cr as O,cu as re,dr as ie,fr as k,gr as A,gt as ae,hr as oe,ht as se,hu as ce,ir as le,jd as j,k as M,kd as ue,kl as N,lr as de,mr as P,or as F,pd as I,sr as L,ur as R,vu as fe,wr as pe,wu as z,xd as B,xr as V,yr as H,z as U}from"./src-CnGTho8r.js";import{Gr as W}from"./client-Dc_lJW_Z.js";import"./mount-DhESFLV5.js";import{F as me,N as he}from"./index-DlFwo3E1.js";import{t as G}from"./AdminPage-CiKtOLQm.js";import{t as ge}from"./NodeAddonsSettingsPanel-DQJQkGit.js";import{r as K,t as q}from"./useNodeUrlSelection-4PSI9SqT.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}=P({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=N(W.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:B,cls:`bg-muted text-foreground-subtle`,label:`queued`},fetching:{icon:E,cls:`bg-primary/10 text-primary`,label:`fetching`,spin:!0},staged:{icon:E,cls:`bg-primary/10 text-primary`,label:`staged`,spin:!0},validating:{icon:E,cls:`bg-primary/10 text-primary`,label:`validating`,spin:!0},applying:{icon:E,cls:`bg-primary/10 text-primary`,label:`applying`,spin:!0},restarting:{icon:E,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,label:`restarting`,spin:!0},applied:{icon:E,cls:`bg-primary/10 text-primary`,label:`finalizing`,spin:!0},done:{icon:j,cls:`bg-success/10 text-success`,label:`updated`},failed:{icon:J,cls:`bg-danger/10 text-danger`,label:`failed`},skipped:{icon:re,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}=R({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(S,{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(b,{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(E,{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(j,{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(j,{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:B,bg:`bg-muted text-foreground-subtle`,label:`queued`},updating:{icon:E,bg:`bg-primary/10 text-primary`,label:`updating`,spin:!0},"done-pending-restart":{icon:z,bg:`bg-amber-500/10 text-amber-700`,label:`pending restart`},done:{icon:j,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?C:g,{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(b,{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(E,{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`}=L({addonId:e}),r=V({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:g,bundle:_,bulkItem:v,disabledByBulk:y,isSystem:b}){let[w,E]=c(!1),[te,D]=c(!1),[ne,O]=c(!1),[re,k]=c(null);u(()=>{k(null)},[a]);let A=re??a,[oe,le]=c(!1),[j,M]=c(!1),[N,de]=c(`logs`),P=s(),F=he(),I=x(),{manifest:L}=e,R=e.installedOn??[],pe=!_&&!L.protected&&L.removable!==!1,B=!!_,V=_?.displayName??L.name,W=_?.packageName??L.packageName,me=_?.version??L.packageVersion??L.version,G=_?.installSource??e.installSource,K=_?_.bundle?.description??_.addons[0]?.manifest.description:L.description,q=T({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]}),P.invalidateQueries({queryKey:[[`addonPages`]]}),P.invalidateQueries({queryKey:[[`capabilities`]]})}}),Y=ee({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]})}}),_e=ie({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]}),P.invalidateQueries({queryKey:[[`addonPages`]]}),P.invalidateQueries({queryKey:[[`capabilities`]]}),P.invalidateQueries({queryKey:[[`integrations`]]})}}),X=H({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]}),P.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(z,{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:B||!!L.components&&L.components.length>1,installSource:G,addonId:B?_.addons[0]?.manifest.id:L.id,iconPath:B?_.bundle?.icon??_.addons[0]?.manifest.icon:L.icon,color:B?_.addons[0]?.manifest.color:L.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:V}),!r&&l(Ee,{version:me,availableUpdate:a,...A===void 0?{}:{selectedVersion:A},isUpdating:m,installSource:G,disabled:y,...d&&A!==void 0?{onUpdate:()=>d(A)}:{},onOpenPicker:()=>O(e=>!e),children:ne&&l(xe,{packageName:W,currentVersion:me,...G?{installSource:G}:{},...a!==void 0&&A!==void 0?{selectedVersion:A,onSelect:e=>{k(e),O(!1)}}:{},onInstall:e=>{O(!1),_e.mutate({packageName:W,version:e})},onClose:()=>O(!1)})})]}),i(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[W!==V&&l(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:W}),B&&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(C,{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(z,{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}),!B&&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})]})]})]}),!B&&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:L.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(z,{className:`h-3 w-3 ${Y.isPending?`animate-spin`:``}`}),`Restart`]}),i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),le(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${oe?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[l(fe,{className:`h-3 w-3`}),`Logs`]}),!B&&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(ce,{className:`h-3 w-3`}),`Settings`]}),l(`div`,{className:`flex-1`}),pe&&i(`button`,{type:`button`,onClick:async e=>{e.stopPropagation(),await I({title:`Uninstall ${L.name}?`,message:`This will remove the addon package and all its data. This action cannot be undone.`,confirmLabel:`Uninstall`,variant:`danger`})&&q.mutate({packageName:L.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(p,{className:`h-3 w-3`}),q.isPending?`Removing...`:`Uninstall`]})]}),n&&n.nodes.length>1&&!B&&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))})]}),oe&&!B&&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:()=>de(`logs`),className:`px-2 py-0.5 transition-colors ${N===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Logs`}),l(`button`,{type:`button`,onClick:()=>de(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${N===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Events`})]}),l(`div`,{className:`flex-1`}),l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),le(!1)},className:`text-foreground-subtle hover:text-foreground`,children:l(S,{className:`h-3.5 w-3.5`})})]}),N===`logs`&&l(ae,{addonId:L.id,maxHeight:`max-h-64`,showFilters:!1}),N===`events`&&l(se,{addonId:L.id,category:`addon.*`,maxHeight:`max-h-64`})]}),B&&i(o,{children:[l(`button`,{type:`button`,onClick:()=>E(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:l(w?ue:f,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),w&&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))})]}),j&&!B&&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(ce,{className:`h-4 w-4 text-primary`}),i(`h2`,{className:`text-sm font-semibold text-foreground`,children:[V,` Settings`]})]}),l(`button`,{onClick:()=>M(!1),className:`text-foreground-subtle hover:text-foreground transition-colors p-1 rounded`,children:l(S,{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:[L.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(L)&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Device export`}),l(U,{addonId:L.id,onOpenDevice:e=>F(`/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:L.id})]}),L.components&&L.components.length>0&&i(`div`,{children:[i(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Components (`,L.components.length,`)`]}),l(`div`,{className:`flex flex-wrap gap-1`,children:L.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:[R.length===0&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Hub (local)`}),R.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(),D(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(h,{className:`h-3 w-3`}),`Add agent`]}),te&&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&&!R.includes(e.name)).map(e=>l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),D(!1)},className:`w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors`,children:e.name},e.id)),t.filter(e=>!e.isHub&&!R.includes(e.name)).length===0&&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(E,{className:`w-3.5 h-3.5 animate-spin`}):l(b,{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(),[h,g]=c(``),v=r(h),[b,S]=c(!1),C=t(null);u(()=>{if(!b)return;let e=e=>{C.current&&!C.current.contains(e.target)&&S(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[b]);let{data:T}=oe({nodeId:d.id}),ee=a(()=>{let e=new Map;for(let t of T??[])e.set(t.name,t.latestVersion);return e},[T]),D=a(()=>(T??[]).filter(e=>!e.isSystem).length,[T]),[re,k]=c(()=>new Set),[A,ae]=c(()=>new Map),se=e(e=>{k(t=>new Set(t).add(e))},[]),ce=e(e=>{k(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),M=e((e,t)=>{ae(n=>new Map(n).set(e,t))},[]),ue=e(e=>{ae(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),N=y({onMutate:e=>{se(e.name),ue(e.name)},onSuccess:(e,t)=>{ce(t.name);let n=e;if(n&&n.success===!1){M(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)=>{ce(t.name),M(t.name,e instanceof Error?e.message:String(e))}}),P=ve(),F=t(new Set);u(()=>{let e=new Set;for(let[t,n]of P)X(n)&&e.add(t);let t=[...F.current].some(t=>!e.has(t));F.current=e,t&&(m.invalidateQueries({queryKey:[[`addons`]]}),m.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[P,m]);let{data:L}=O(void 0),R=le({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),fe=w({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:B,isFetching:V}=ne({query:v||void 0},{enabled:b}),H=pe(),{data:U}=de(void 0),W=U?.requestedAt,[he,G]=c(null),[ge,K]=c(!1);u(()=>{if(U?.kind===`framework-bulk-update`&&U.requestedAt!==he){G(U.requestedAt),K(!0);let e=window.setTimeout(()=>K(!1),6e3);return()=>window.clearTimeout(e)}},[W,he,U]),x();let q=e(async()=>{let e=(T??[]).filter(e=>!e.isSystem);if(e.length!==0){if(!d.isHub){for(let t of e)await N.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,N]),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]=me(),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:[[...A.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:()=>ue(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(z,{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:()=>R.mutate({channel:e}),disabled:R.isPending,className:`px-2.5 py-1.5 transition-colors capitalize ${L?.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:L?.updateCheckIntervalSeconds??21600,disabled:fe.isPending||L===void 0,onChange:e=>{L!==void 0&&fe.mutate({channel:L.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:je.map(e=>l(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),D>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(E,{className:`w-3 h-3 animate-spin`}):l(I,{className:`w-3 h-3`}),H.isPending?`Updating…`:`Update All (${D})`]}),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(z,{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:C,children:[l(te,{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:h,onChange:e=>{g(e.target.value),S(!0)},onFocus:()=>S(!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(E,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin`}),b&&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(j,{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(E,{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(_,{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=ee.get(t),r=$(e)?e.representative:e,i=n?e=>N.mutate({name:t,version:e,nodeId:d.id}):void 0,a=P.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:re.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}=k(),{data:o}=D(void 0),{nodes:c}=v(),{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,_=F(),y=A(),b=_.isPending||y.isPending,x=async()=>{await _.mutateAsync({nodeId:h}),await y.mutateAsync(),e.invalidateQueries({queryKey:[[`addons`]]})},S=t(_);S.current=_;let C=t(p??`hub`);u(()=>{S.current.mutate({nodeId:C.current})},[]);let w=(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(M,{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:[w.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(z,{className:`w-3 h-3 ${b?`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:w,clusterStatus:o,selectedNode:m,onRefresh:()=>void x(),isRefreshing:b})]})}export{ze as AddonsPage};