@camstack/addon-admin-ui 1.2.22 → 1.2.23

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 (86) hide show
  1. package/dist/assets/{AddLocationWizard-CXH0Vd7P.js → AddLocationWizard-Dq7esXUF.js} +1 -1
  2. package/dist/assets/{AddonCollectionPage-BDrreBA_.js → AddonCollectionPage-zISnCSia.js} +1 -1
  3. package/dist/assets/{Addons-BBee3W_5.js → Addons-CgUw615i.js} +1 -1
  4. package/dist/assets/{AdminTabs-C2h2Ess6.js → AdminTabs-Dm5dIblA.js} +1 -1
  5. package/dist/assets/{AiProfiles-CaMvgEcu.js → AiProfiles-n9YYWZm0.js} +1 -1
  6. package/dist/assets/{BrokerForm-Dg4179gd.js → BrokerForm-D3HfLXNS.js} +1 -1
  7. package/dist/assets/{Capabilities-CTViRMUz.js → Capabilities-DM9m0y2O.js} +1 -1
  8. package/dist/assets/{CapabilityBadges-CWTCenZn.js → CapabilityBadges-YLTOm6PM.js} +1 -1
  9. package/dist/assets/{Cluster-CyCE0oc3.js → Cluster-C2xbxwVH.js} +1 -1
  10. package/dist/assets/{ClusterRecordingTab-BFeUBRQL.js → ClusterRecordingTab-Dm3Biopz.js} +1 -1
  11. package/dist/assets/{Dashboard-kAuj8Qql.js → Dashboard-D-wnzhTu.js} +1 -1
  12. package/dist/assets/{Data-cxkPOpjt.js → Data-CIDrzfAW.js} +1 -1
  13. package/dist/assets/{DetectionIntelligence-BhkMTGhd.js → DetectionIntelligence-DqbLakFE.js} +1 -1
  14. package/dist/assets/{DeviceAggregateSection-nG_okgKX.js → DeviceAggregateSection-Bu8VWBW5.js} +1 -1
  15. package/dist/assets/{DeviceDetail-Bn6Ds2YE.js → DeviceDetail-Br2-0p9A.js} +1 -1
  16. package/dist/assets/{Devices-B95hLZbr.js → Devices-DI07Ba43.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-D7BKC58D.js → EmbedPlayerPage-CGwxGZ8a.js} +1 -1
  18. package/dist/assets/{Events-CQFwNvkG.js → Events-oKrdnmzL.js} +1 -1
  19. package/dist/assets/{FormBuilder-DjEl_aGp.js → FormBuilder-WQJMcWst.js} +1 -1
  20. package/dist/assets/{Identity-60VJAx02.js → Identity-jSwJ6Iv7.js} +1 -1
  21. package/dist/assets/{IntegrationDetail-BjZloyK4.js → IntegrationDetail-B-LhIl4a.js} +1 -1
  22. package/dist/assets/{Integrations-D9v-_8r-.js → Integrations-BXraNBU9.js} +1 -1
  23. package/dist/assets/{Integrations-CxEpaCLq.js → Integrations-XXz_SSij.js} +1 -1
  24. package/dist/assets/{Logs-C7F-ma4x.js → Logs-DwZnQjRw.js} +1 -1
  25. package/dist/assets/{MotionZonesSettings-DSIn5-s5.js → MotionZonesSettings-DfEKV9Q_.js} +1 -1
  26. package/dist/assets/{MyAccess-t85_pORz.js → MyAccess-Ds9GtLyA.js} +1 -1
  27. package/dist/assets/{Network-D7V-dc6V.js → Network-Bxr6yA2G.js} +1 -1
  28. package/dist/assets/{NodeAddonsSettingsPanel-ujvGtNzi.js → NodeAddonsSettingsPanel-DLk9BjoX.js} +1 -1
  29. package/dist/assets/{NodeInferenceDevices-fwySdAtB.js → NodeInferenceDevices-D8UFJ7N-.js} +1 -1
  30. package/dist/assets/Notifications-BGACh7EA.js +1 -0
  31. package/dist/assets/{Pipeline-CA-9DIEs.js → Pipeline-BJMxtRsG.js} +1 -1
  32. package/dist/assets/{Plates-BWcRlxDR.js → Plates-BYT1Sys7.js} +1 -1
  33. package/dist/assets/{PrivacyMaskSettings-Bfj57HiI.js → PrivacyMaskSettings-DHEZLINm.js} +1 -1
  34. package/dist/assets/{ProviderIcon-Bu6M7fez.js → ProviderIcon-qFD5vx-c.js} +1 -1
  35. package/dist/assets/{Recordings-DqkJ9Ane.js → Recordings-EdS7D4Nu.js} +1 -1
  36. package/dist/assets/{ScanNetworkModal-CkeHCFgJ.js → ScanNetworkModal-C2nxQYpR.js} +1 -1
  37. package/dist/assets/{Settings-CTvsgafi.js → Settings-DTvThy5s.js} +1 -1
  38. package/dist/assets/{Showroom-B43mwuk7.js → Showroom-CoCz7BCl.js} +1 -1
  39. package/dist/assets/{Terminal-BDSI390X.js → Terminal-CdHc7JGW.js} +1 -1
  40. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-W4TOU_HF.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Qwbl6leh.js} +1 -1
  41. package/dist/assets/{build-cluster-graph-C4zGQLGF.js → build-cluster-graph-DCa5BVOm.js} +1 -1
  42. package/dist/assets/circle-check-big-BrI-BnLX.js +1 -0
  43. package/dist/assets/clock-BaUOxVoD.js +1 -0
  44. package/dist/assets/{copy-BgYRNf8b.js → copy-DT1LpWnW.js} +1 -1
  45. package/dist/assets/{debounced-invalidate-o_asci0-.js → debounced-invalidate-COlXMKcK.js} +1 -1
  46. package/dist/assets/dist-CavlSg96.js +7 -0
  47. package/dist/assets/{dist-CYCjmuN8.js → dist-pwV-cUFg.js} +1 -1
  48. package/dist/assets/{download-CdPioKV1.js → download-C5pWNY_z.js} +1 -1
  49. package/dist/assets/{face-bbox-BpDfTsFx.js → face-bbox-CQezXcbm.js} +1 -1
  50. package/dist/assets/{hostInit-DJ_7rd1-.js → hostInit-17HFqvQi.js} +1 -1
  51. package/dist/assets/{index-D0JhMwHm.js → index-CpIk9zzP.js} +3 -3
  52. package/dist/assets/{key-round-DDzoqyJC.js → key-round-BvJWrH6G.js} +1 -1
  53. package/dist/assets/{mf-entry-bootstrap-0-7d8a6853.js → mf-entry-bootstrap-0-11f10035.js} +2 -2
  54. package/dist/assets/{pencil-DjXB5Bxq.js → pencil-B6M2nE2x.js} +1 -1
  55. package/dist/assets/{player-overlays-BfUh6z3V.js → player-overlays-Cip1zMzf.js} +1 -1
  56. package/dist/assets/plus-CJX-7qpV.js +1 -0
  57. package/dist/assets/{radio-DdH4qqug.js → radio-7rKfflkG.js} +1 -1
  58. package/dist/assets/{refresh-cw-BSTOsxS_.js → refresh-cw-meywvLr6.js} +1 -1
  59. package/dist/assets/remoteEntry-CpGnB6JJ.js +1 -0
  60. package/dist/assets/{rotate-ccw-DIwpplTj.js → rotate-ccw-DG0IoVOG.js} +1 -1
  61. package/dist/assets/rotate-cw-BaaybXts.js +1 -0
  62. package/dist/assets/search-DqwBNJOd.js +1 -0
  63. package/dist/assets/{send-CcHJh0KO.js → send-BYEhx4h6.js} +1 -1
  64. package/dist/assets/{server-DwOZ36mY.js → server-Bmc0CVZj.js} +1 -1
  65. package/dist/assets/square-BphxIfpl.js +1 -0
  66. package/dist/assets/{square-check-big-D7LCZj5L.js → square-check-big-89xbxgw8.js} +1 -1
  67. package/dist/assets/{src-DmLu_IGX.js → src-Bz1FM7Iz.js} +10 -10
  68. package/dist/assets/src-CMBOTyxw.js +7 -0
  69. package/dist/assets/{upload-Tv3ztf7H.js → upload-CzKEUpu7.js} +1 -1
  70. package/dist/assets/{useEventInvalidation-CQK0jRw6.js → useEventInvalidation-Bwgjtt0n.js} +1 -1
  71. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-B_wRVm4F.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-OzBzXogt.js} +2 -2
  72. package/dist/assets/{wifi-C6b9pnss.js → wifi-SBwRQpGK.js} +1 -1
  73. package/dist/assets/{zap-CWvZQmfa.js → zap-CG1_c3Ri.js} +1 -1
  74. package/dist/index.html +5 -5
  75. package/dist/server/addon.js +237 -7
  76. package/package.json +1 -1
  77. package/dist/assets/Notifications-CUekQNjA.js +0 -1
  78. package/dist/assets/circle-check-big-C-IoJG5A.js +0 -1
  79. package/dist/assets/clock-J8ftFeJL.js +0 -1
  80. package/dist/assets/dist-ygAVnmuC.js +0 -7
  81. package/dist/assets/plus-BEbdi_Iz.js +0 -1
  82. package/dist/assets/remoteEntry-BVkvjsQm.js +0 -1
  83. package/dist/assets/rotate-cw-EHQK_WNV.js +0 -1
  84. package/dist/assets/search-BK_1ulaR.js +0 -1
  85. package/dist/assets/square-nYV2-xBc.js +0 -1
  86. package/dist/assets/src-D11G7q5Q.js +0 -7
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
- //#region ../types/dist/event-category-Bz24uP1U.mjs
3
+ //#region ../types/dist/event-category-41fKf-q9.mjs
4
4
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
5
5
  EventCategory["SystemBoot"] = "system.boot";
6
6
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -60,6 +60,26 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
60
60
  */
61
61
  EventCategory["AddonRetryScheduled"] = "addon.retry-scheduled";
62
62
  /**
63
+ * A liveness invariant of this node is false — it has no devices, every
64
+ * camera is offline, or a camera that was recording has stopped producing
65
+ * segments. Emitted by the `liveness-monitor` builtin, once per fault (the
66
+ * `findingId` is stable across ticks), only after its boot grace period.
67
+ * AlertCenter raises a persistent operator-visible alert.
68
+ *
69
+ * It exists because on 2026-08-03 the hub ran four hours with zero devices
70
+ * and zero recordings while every surface stayed quiet.
71
+ *
72
+ * Payload: `{ findingId, severity, title, message, deviceId? }`.
73
+ */
74
+ EventCategory["SystemLivenessFailed"] = "system.liveness-failed";
75
+ /**
76
+ * A previously reported liveness fault is true again. AlertCenter dismisses
77
+ * the matching `SystemLivenessFailed` alert.
78
+ *
79
+ * Payload: `{ findingId }`.
80
+ */
81
+ EventCategory["SystemLivenessRecovered"] = "system.liveness-recovered";
82
+ /**
63
83
  * Monitor is attempting to reload a failed addon NOW. UI uses this
64
84
  * to show a spinner during the retry attempt. Same transient nature
65
85
  * as AddonRetryScheduled.
@@ -9305,6 +9325,14 @@ var NcMediaPolicySchema = object({
9305
9325
  clipPreRollSec: number().int().min(0).max(30).optional(),
9306
9326
  clipPostRollSec: number().int().min(0).max(30).optional(),
9307
9327
  /**
9328
+ * Playback rate of the attached gif / clip. Absent = 2x.
9329
+ *
9330
+ * A notification clip is GLANCED at on a lock screen, not watched: at real
9331
+ * time an eight-second passage is eight seconds of the recipient's attention
9332
+ * and twice the bytes. 1 is real time for the operator who wants it.
9333
+ */
9334
+ clipSpeed: number().min(1).max(8).optional(),
9335
+ /**
9308
9336
  * Which stream profile the footage is cut from. Absent = the CHEAPEST
9309
9337
  * assigned profile: a notification is watched on a phone, so the 4K
9310
9338
  * rendition would burn CPU to produce a file the client downscales anyway.
@@ -9376,7 +9404,21 @@ var NcRuleInputSchema = object({
9376
9404
  * behaviour, visible to all, read-only in the viewer). Present = personal
9377
9405
  * rule owned by this userId. Server-stamped; never trusted from a client.
9378
9406
  */
9379
- ownerUserId: string().optional()
9407
+ ownerUserId: string().optional(),
9408
+ /**
9409
+ * May a non-admin snooze this rule for EVERYONE, not just themselves?
9410
+ *
9411
+ * A snooze is personal by default — it silences the person who set it. This
9412
+ * opts THIS rule into the "the gardener is here all afternoon" case, where
9413
+ * silencing the camera for the whole household is legitimate. It silences
9414
+ * other people, so it is off unless a rule deliberately allows it.
9415
+ *
9416
+ * `.optional()`, deliberately NOT `.default()`: a Zod default does not run on
9417
+ * the addon cap path (three production failures in one day), so absent is
9418
+ * read as `false` by {@link canSetGlobal} in the engine. Admins are not bound
9419
+ * by this flag — see the scope rules on that function.
9420
+ */
9421
+ snoozeAllowGlobal: boolean().optional()
9380
9422
  });
9381
9423
  /**
9382
9424
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -9461,7 +9503,28 @@ var NcConditionDescriptorSchema = object({
9461
9503
  /** Which delivery kinds the condition applies to. */
9462
9504
  appliesTo: array(NcDeliverySchema),
9463
9505
  phase: string(),
9464
- description: string().optional()
9506
+ description: string().optional(),
9507
+ /**
9508
+ * The CHOICES for a single-choice widget (`sourceSelect`, `crossingSelect`,
9509
+ * `packagePhase`, …), served with the descriptor.
9510
+ *
9511
+ * Before this the descriptor said which widget to render and not what to put
9512
+ * in it, so every option list lived in three places: this file's enums, the
9513
+ * admin's `NC_*_OPTIONS` and the viewer's `NC_*_VALUES`. That triple mirror
9514
+ * is the drift that emptied the viewer's rule editor on 2026-08-04 — the app
9515
+ * mirrors the cap by hand, so it is only ever as current as its last build.
9516
+ *
9517
+ * With the options on the wire, a condition of an EXISTING `valueType` costs
9518
+ * zero client changes. Clients keep a local fallback for an older hub that
9519
+ * does not send them; absent here is "use your own list", not "no choices".
9520
+ */
9521
+ options: array(object({
9522
+ /** Written to the rule verbatim. `''` means the ABSENT state. */
9523
+ value: string(),
9524
+ label: string(),
9525
+ /** What THIS choice matches — shown one at a time, under the control. */
9526
+ hint: string().optional()
9527
+ })).readonly().optional()
9465
9528
  });
9466
9529
  /**
9467
9530
  * The delivery lifecycle status of a history row — a straight read of the
@@ -9546,6 +9609,74 @@ var NcHistoryFilterSchema = object({
9546
9609
  until: number().optional(),
9547
9610
  limit: number().int().min(1).max(500).default(100)
9548
9611
  });
9612
+ /**
9613
+ * What a snooze covers. Broader scopes win when several overlap, so one window
9614
+ * leaves ONE digest rather than a rule snooze and a whole-feed snooze both
9615
+ * summarising the same silence.
9616
+ */
9617
+ var NcSnoozeScopeSchema = _enum([
9618
+ "rule",
9619
+ "device",
9620
+ "all"
9621
+ ]);
9622
+ /**
9623
+ * Client-authored snooze. The server stamps `userId`, `startedAt` and
9624
+ * `expiresAt` — a DURATION is sent rather than an instant so a client with a
9625
+ * skewed clock cannot author a window that is already over, or never ends.
9626
+ */
9627
+ var NcSnoozeInputSchema = object({
9628
+ scope: NcSnoozeScopeSchema,
9629
+ /** Required when `scope: 'rule'` — a scoped snooze with no id matches
9630
+ * NOTHING rather than degrading to "everything". */
9631
+ ruleId: string().optional(),
9632
+ /** Required when `scope: 'device'`. */
9633
+ deviceId: number().int().optional(),
9634
+ durationMinutes: number().int().min(1).max(1440),
9635
+ /**
9636
+ * Silence this for EVERY recipient, not just the caller. Permission is
9637
+ * checked server-side (the rule's `snoozeAllowGlobal`, or admin for the
9638
+ * broader scopes). Absent = personal.
9639
+ */
9640
+ global: boolean().optional(),
9641
+ /**
9642
+ * Deliver a summary of what was suppressed when the window ends. Absent =
9643
+ * ON: someone silencing a nuisance camera wants it off, someone silencing a
9644
+ * SECURITY camera wants to know what they missed, and choosing "off" for
9645
+ * everybody is how a snooze becomes an outage. Resolved to a concrete
9646
+ * boolean by the server at create time — never left to a Zod default, which
9647
+ * does not run on the addon cap path.
9648
+ */
9649
+ summary: boolean().optional()
9650
+ });
9651
+ /** A persisted snooze window. */
9652
+ var NcSnoozeSchema = object({
9653
+ id: string(),
9654
+ /** Who set it. Also who it silences, unless `global`. */
9655
+ userId: string(),
9656
+ scope: NcSnoozeScopeSchema,
9657
+ ruleId: string().optional(),
9658
+ deviceId: number().int().optional(),
9659
+ startedAt: number(),
9660
+ /** Exclusive: at exactly this instant the snooze is over. Expiry is a
9661
+ * COMPARISON, not a job — no sweeper can leave the operator silenced. */
9662
+ expiresAt: number(),
9663
+ global: boolean(),
9664
+ summary: boolean(),
9665
+ /** When the end-of-window digest went out. Absent = not sent (yet, or the
9666
+ * window has not closed, or `summary` is false). */
9667
+ digestSentAt: number().optional()
9668
+ });
9669
+ object({
9670
+ snoozeId: string(),
9671
+ targetId: string(),
9672
+ ruleId: string(),
9673
+ ruleName: string(),
9674
+ deviceId: number().int(),
9675
+ /** How many notifications this snooze hid for that pair. */
9676
+ count: number().int(),
9677
+ firstAt: number(),
9678
+ lastAt: number()
9679
+ });
9549
9680
  method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), method(object({ ruleId: string() }), object({ rule: NcRuleSchema.nullable() }), { auth: "admin" }), method(object({ rule: NcRuleInputSchema }), object({ rule: NcRuleSchema }), {
9550
9681
  kind: "mutation",
9551
9682
  auth: "admin",
@@ -9575,7 +9706,13 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
9575
9706
  }), method(object({}), object({
9576
9707
  catalog: array(NcConditionDescriptorSchema),
9577
9708
  taxonomy: NcTaxonomySchema.optional()
9578
- })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
9709
+ })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" }), method(object({}), object({ snoozes: array(NcSnoozeSchema) }), { caller: "required" }), method(object({ snooze: NcSnoozeInputSchema }), object({ snooze: NcSnoozeSchema }), {
9710
+ kind: "mutation",
9711
+ caller: "required"
9712
+ }), method(object({ snoozeId: string() }), object({ success: literal(true) }), {
9713
+ kind: "mutation",
9714
+ caller: "required"
9715
+ });
9579
9716
  /**
9580
9717
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
9581
9718
  *
@@ -10323,7 +10460,15 @@ method(object({
10323
10460
  format: _enum(["gif", "mp4"]).default("gif"),
10324
10461
  maxWidth: number().int().min(120).max(1920).default(480),
10325
10462
  /** GIF only — MP4 keeps the source cadence. */
10326
- fps: number().int().min(1).max(15).default(5)
10463
+ fps: number().int().min(1).max(15).default(5),
10464
+ /**
10465
+ * Playback rate. A notification clip is GLANCED at on a lock screen,
10466
+ * not watched, so 2x is the default: the recipient sees the whole
10467
+ * passage in half the time and the GIF is half the bytes. `1` is real
10468
+ * time. Applies to MP4 as well — the operator set a speed, not a GIF
10469
+ * speed.
10470
+ */
10471
+ speed: number().min(1).max(8).default(2)
10327
10472
  }), object({
10328
10473
  base64: string(),
10329
10474
  mime: string(),
@@ -15082,6 +15227,20 @@ var QueryFilterSchema = object({
15082
15227
  limit: number().optional(),
15083
15228
  offset: number().optional()
15084
15229
  });
15230
+ /**
15231
+ * The predicate half of a filter, for BULK MUTATIONS.
15232
+ *
15233
+ * Deliberately not `QueryFilterSchema`: `orderBy` / `limit` / `offset` have no
15234
+ * meaning for a statement that rewrites a set, and accepting them would invite
15235
+ * a caller to believe `limit` bounds the damage. Every field is optional here
15236
+ * only so the shape stays composable — the implementation REJECTS a filter
15237
+ * that compiles to no predicate, because that is the whole collection.
15238
+ */
15239
+ var MutationFilterSchema = object({
15240
+ where: record(string(), unknown()).optional(),
15241
+ whereIn: record(string(), array(unknown())).optional(),
15242
+ whereBetween: record(string(), tuple([unknown(), unknown()])).optional()
15243
+ });
15085
15244
  /** A single stored record: `{ id, data }`. */
15086
15245
  var SettingsRecordSchema = object({
15087
15246
  id: string(),
@@ -15107,7 +15266,18 @@ var CollectionColumnSchema = object({
15107
15266
  ]),
15108
15267
  primaryKey: boolean().optional(),
15109
15268
  notNull: boolean().optional(),
15110
- unique: boolean().optional()
15269
+ unique: boolean().optional(),
15270
+ /**
15271
+ * Column DEFAULT. Required for B2: the four `ensureTable` consumers declare
15272
+ * columns like `enabled INTEGER NOT NULL DEFAULT 1`, and without this the
15273
+ * collection surface simply cannot express their existing tables — which is
15274
+ * why they were still on the uncapped `table*` API.
15275
+ */
15276
+ defaultValue: union([
15277
+ string(),
15278
+ number(),
15279
+ boolean()
15280
+ ]).optional()
15111
15281
  });
15112
15282
  var CollectionIndexSchema = object({
15113
15283
  name: string(),
@@ -15141,6 +15311,15 @@ method(object({
15141
15311
  collection: string(),
15142
15312
  key: string()
15143
15313
  }), _void(), { kind: "mutation" }), method(object({
15314
+ namespace: string().optional(),
15315
+ collection: string(),
15316
+ filter: MutationFilterSchema
15317
+ }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
15318
+ namespace: string().optional(),
15319
+ collection: string(),
15320
+ filter: MutationFilterSchema,
15321
+ data: record(string(), unknown())
15322
+ }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
15144
15323
  namespace: string().optional(),
15145
15324
  collection: string(),
15146
15325
  filter: QueryFilterSchema.optional()
@@ -15207,6 +15386,15 @@ method(_void(), EngineInfoSchema), method(object({
15207
15386
  collection: string(),
15208
15387
  key: string()
15209
15388
  }), _void(), { kind: "mutation" }), method(object({
15389
+ namespace: string().optional(),
15390
+ collection: string(),
15391
+ filter: MutationFilterSchema
15392
+ }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
15393
+ namespace: string().optional(),
15394
+ collection: string(),
15395
+ filter: MutationFilterSchema,
15396
+ data: record(string(), unknown())
15397
+ }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
15210
15398
  namespace: string().optional(),
15211
15399
  collection: string(),
15212
15400
  filter: QueryFilterSchema.optional()
@@ -22475,6 +22663,12 @@ Object.freeze({
22475
22663
  addonId: null,
22476
22664
  access: "delete"
22477
22665
  },
22666
+ "dataStoreProvider.deleteWhere": {
22667
+ capName: "data-store-provider",
22668
+ capScope: "system",
22669
+ addonId: null,
22670
+ access: "delete"
22671
+ },
22478
22672
  "dataStoreProvider.get": {
22479
22673
  capName: "data-store-provider",
22480
22674
  capScope: "system",
@@ -22523,6 +22717,12 @@ Object.freeze({
22523
22717
  addonId: null,
22524
22718
  access: "create"
22525
22719
  },
22720
+ "dataStoreProvider.updateWhere": {
22721
+ capName: "data-store-provider",
22722
+ capScope: "system",
22723
+ addonId: null,
22724
+ access: "create"
22725
+ },
22526
22726
  "dayNight.getOptions": {
22527
22727
  capName: "day-night",
22528
22728
  capScope: "device",
@@ -24317,12 +24517,24 @@ Object.freeze({
24317
24517
  addonId: null,
24318
24518
  access: "create"
24319
24519
  },
24520
+ "notificationRules.cancelSnooze": {
24521
+ capName: "notification-rules",
24522
+ capScope: "system",
24523
+ addonId: null,
24524
+ access: "create"
24525
+ },
24320
24526
  "notificationRules.createRule": {
24321
24527
  capName: "notification-rules",
24322
24528
  capScope: "system",
24323
24529
  addonId: null,
24324
24530
  access: "create"
24325
24531
  },
24532
+ "notificationRules.createSnooze": {
24533
+ capName: "notification-rules",
24534
+ capScope: "system",
24535
+ addonId: null,
24536
+ access: "create"
24537
+ },
24326
24538
  "notificationRules.deleteRule": {
24327
24539
  capName: "notification-rules",
24328
24540
  capScope: "system",
@@ -24353,6 +24565,12 @@ Object.freeze({
24353
24565
  addonId: null,
24354
24566
  access: "view"
24355
24567
  },
24568
+ "notificationRules.listSnoozes": {
24569
+ capName: "notification-rules",
24570
+ capScope: "system",
24571
+ addonId: null,
24572
+ access: "view"
24573
+ },
24356
24574
  "notificationRules.setRuleEnabled": {
24357
24575
  capName: "notification-rules",
24358
24576
  capScope: "system",
@@ -25601,6 +25819,12 @@ Object.freeze({
25601
25819
  addonId: null,
25602
25820
  access: "delete"
25603
25821
  },
25822
+ "settingsStore.deleteWhere": {
25823
+ capName: "settings-store",
25824
+ capScope: "system",
25825
+ addonId: null,
25826
+ access: "delete"
25827
+ },
25604
25828
  "settingsStore.get": {
25605
25829
  capName: "settings-store",
25606
25830
  capScope: "system",
@@ -25643,6 +25867,12 @@ Object.freeze({
25643
25867
  addonId: null,
25644
25868
  access: "create"
25645
25869
  },
25870
+ "settingsStore.updateWhere": {
25871
+ capName: "settings-store",
25872
+ capScope: "system",
25873
+ addonId: null,
25874
+ access: "create"
25875
+ },
25646
25876
  "smtpProvider.getStatus": {
25647
25877
  capName: "smtp-provider",
25648
25878
  capScope: "system",
@@ -26686,7 +26916,7 @@ var AdminUIAddon = class extends BaseAddon {
26686
26916
  capability: adminUiCapability,
26687
26917
  provider: {
26688
26918
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
26689
- getVersion: async () => ({ version: "1.2.22" })
26919
+ getVersion: async () => ({ version: "1.2.23" })
26690
26920
  }
26691
26921
  }];
26692
26922
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.22",
3
+ "version": "1.2.23",
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{$n as e,Ao as t,Co as n,Do as r,Eo as i,Ka as a,Ki as o,Oo as s,S as c,So as l,To as u,bo as d,ko as f,oo as p,wo as m,yo as h}from"./src-DmLu_IGX.js";import{Q as g,S as _,W as v,a as y,b,i as x,q as S,t as C,x as w}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{E as T,T as E,k as D,w as O}from"./src-D11G7q5Q.js";import{p as k}from"./player-overlays-BfUh6z3V.js";import{t as A}from"./circle-check-big-C-IoJG5A.js";import{t as j}from"./copy-BgYRNf8b.js";import{t as ee}from"./pencil-DjXB5Bxq.js";import{t as M}from"./plus-BEbdi_Iz.js";import{t as N}from"./refresh-cw-BSTOsxS_.js";import{t as te}from"./search-BK_1ulaR.js";import{t as P}from"./send-CcHJh0KO.js";import{N as ne,S as F,V as re,W as I,i as ie,s as L}from"./index-D0JhMwHm.js";import{t as R}from"./AdminPage-Dq33XE9j.js";import{t as ae}from"./AdminTabs-C2h2Ess6.js";var oe=I(`bell-ring`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]),se=I(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),z=I(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]);g();var B=e=>typeof e==`string`&&e.length>0;function ce(e){return{levels:e.levels,formats:e.format,bodyMaxLen:e.bodyMaxLen,attachmentSlots:e.attachments.mediaTypes,attachmentMode:e.attachments.mode,attachmentMax:e.attachments.max,attachmentMaxBytes:e.attachments.maxBytes,maxActions:e.actions,showActions:e.actions>0,showClickUrl:e.clickUrl,showSound:e.sound,showTtl:e.ttl,showTag:!0}}function le(e,t){return e.format.includes(t)?t:e.format[0]??`text`}function ue(e,t){let n=[];for(let r of e.attachments.mediaTypes){if(n.length>=e.attachments.max)break;let i=t[r];B(i)&&n.push({mediaType:r,url:i})}return n}function de(e,t){if(e.actions<=0)return[];let n=[];for(let r of t){if(n.length>=e.actions)break;let t=B(r.label),i=B(r.url);!t&&!i||n.push({id:`test-${n.length+1}`,label:t?r.label:`Action ${n.length+1}`,...i?{url:r.url}:{}})}return n}function fe(e,t){let n=e.levels.some(e=>e.id===t.level)?t.level:void 0,r=ue(e,t.attachmentUrls),i=de(e,t.actions),a=e.ttl&&B(t.ttl)?Number(t.ttl):void 0;return{body:t.body,format:le(e,t.format),priority:pe(t.priority),...B(t.title)?{title:t.title}:{},...n?{level:n}:{},...r.length>0?{attachments:r}:{},...i.length>0?{actions:i}:{},...e.clickUrl&&B(t.clickUrl)?{clickUrl:t.clickUrl}:{},...e.sound&&B(t.sound)?{sound:t.sound}:{},...a!==void 0&&Number.isFinite(a)?{ttl:a}:{},...B(t.tag)?{tag:t.tag}:{}}}function pe(e){return Number.isFinite(e)?Math.min(5,Math.max(1,Math.round(e))):3}function me(e){return e.levels.find(e=>e.flags?.critical===!0)||e.levels.filter(e=>typeof e.ordinal==`number`).sort((e,t)=>t.ordinal-e.ordinal)[0]}function V(e){return{level:``,priority:3,format:e.format[0]??`text`,title:``,body:``,attachmentUrls:{},actions:[],clickUrl:``,sound:``,ttl:``,tag:``}}var he={image:`/addon/notifiers/samples/image`,video:`/addon/notifiers/samples/video`,gif:`/addon/notifiers/samples/gif`,audio:`/addon/notifiers/samples/audio`,icon:`/addon/notifiers/samples/icon`};function ge(e,t){return e.attachments.max>0&&e.attachments.mediaTypes.includes(t)}function _e(e){let t=[`text`];for(let n of[`image`,`gif`,`video`,`audio`])ge(e,n)&&t.push(n);return e.actions>0&&t.push(`actions`),e.levels.length>0&&t.push(`critical`),t.push(`overflow`),t}function H(e,t,n){let r=V(e);return ge(e,t)?{...r,body:n,attachmentUrls:{[t]:he[t]}}:{...r,body:n}}function ve(e,t){let n=V(e);switch(t){case`text`:return{...n,title:`CamStack`,body:`Test notification — text only.`};case`image`:return H(e,`image`,`Test notification with an image.`);case`gif`:return H(e,`gif`,`Test notification with an animation.`);case`video`:return H(e,`video`,`Test notification with a video.`);case`audio`:return H(e,`audio`,`Test notification with audio.`);case`actions`:{let t=Array.from({length:e.actions},(e,t)=>({label:`Action ${t+1}`,url:`/`}));return{...n,title:`CamStack`,body:`Test notification with action buttons.`,actions:t,...e.clickUrl?{clickUrl:`/`}:{}}}case`critical`:{let t=me(e);return{...n,title:`CamStack`,body:`Critical test notification.`,priority:5,level:t?.id??``}}case`overflow`:return{...n,body:`X`.repeat(e.bodyMaxLen+50)}}}var ye={text:`Text only`,image:`With image`,gif:`With GIF`,video:`With video`,audio:`With audio`,actions:`With buttons`,critical:`Critical`,overflow:`Overflow (advanced)`},U=`w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none`,W=`block text-[11px] font-medium text-foreground mb-1`;function be({target:e,kind:r,open:i,onClose:a}){let o=k(),s=v(()=>ce(r.caps),[r.caps]),c=v(()=>_e(r.caps),[r.caps]),[u,p]=S(()=>V(r.caps)),[g,y]=S(null),b=v(()=>fe(r.caps,u),[r.caps,u]),x=u.body.length,T=x>s.bodyMaxLen,E=e=>p(t=>({...t,...e})),D=C({mutationFn:()=>o.trpcClient.notificationOutput.testTarget.mutate({addonId:e.addonId,targetId:e.id,sample:fe(r.caps,u)}),onMutate:()=>y(null),onSuccess:e=>y(e),onError:e=>y({success:!1,error:e instanceof Error?e.message:`Test failed`})}),O=e=>{p(ve(r.caps,e)),y(null)},A=(e,t,n)=>{let r=u.actions.length>0?[...u.actions]:[];for(;r.length<=e;)r.push({label:``,url:``});r[e]={...r[e],[t]:n},E({actions:r})};return w(h,{open:i,onOpenChange:e=>!e&&a(),children:_(d,{width:`lg`,className:`!max-w-2xl`,children:[w(n,{children:_(m,{children:[`Test "`,e.name,`" (`,r.label,`)`]})}),_(`div`,{className:`space-y-4 max-h-[60vh] overflow-y-auto pr-1`,children:[w(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map(e=>w(t,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>O(e),children:ye[e]},e))}),_(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[s.levels.length>0&&_(`div`,{children:[w(`label`,{className:W,children:`Level`}),_(`select`,{className:U,value:u.level,onChange:e=>E({level:e.target.value}),children:[w(`option`,{value:``,children:`— derive from priority —`}),s.levels.map(e=>_(`option`,{value:e.id,children:[e.label,e.ordinal===null?` (qualitative)`:` (p${e.ordinal})`]},e.id))]}),(()=>{let e=s.levels.find(e=>e.id===u.level);return e?_(`div`,{className:`mt-1 space-y-1`,children:[e.description&&w(`p`,{className:`text-[10px] text-foreground-subtle`,children:e.description}),_(`div`,{className:`flex flex-wrap gap-1`,children:[e.flags?.critical&&w(f,{variant:`danger`,"data-testid":`flag-critical`,children:`critical`}),e.flags?.silent&&w(f,{variant:`info`,children:`silent`}),e.flags?.noPush&&w(f,{variant:`warning`,children:`no-push`})]}),e.requires&&e.requires.length>0&&_(`p`,{className:`text-[10px] text-warning`,children:[`Requires target config: `,e.requires.join(`, `)]})]}):null})()]}),_(`div`,{children:[_(`label`,{className:W,children:[`Priority (ordinal): `,u.priority]}),w(`input`,{type:`range`,min:1,max:5,step:1,value:u.priority,onChange:e=>E({priority:Number(e.target.value)}),className:`w-full accent-primary`,"aria-label":`priority`})]})]}),s.formats.length>0&&_(`div`,{children:[w(`label`,{className:W,children:`Format`}),w(`div`,{className:`flex flex-wrap gap-2`,children:s.formats.map(e=>_(`label`,{className:`flex items-center gap-1.5 text-xs text-foreground cursor-pointer`,children:[w(`input`,{type:`radio`,name:`format`,className:`accent-primary`,checked:u.format===e,onChange:()=>E({format:e})}),e]},e))})]}),_(`div`,{children:[w(`label`,{className:W,children:`Title`}),w(`input`,{className:U,value:u.title,onChange:e=>E({title:e.target.value})})]}),_(`div`,{children:[_(`label`,{className:W,children:[`Body`,` `,_(`span`,{className:T?`text-danger`:`text-foreground-subtle`,children:[`(`,x,`/`,s.bodyMaxLen,T?` — overflow`:``,`)`]})]}),w(`textarea`,{className:`${U} min-h-[80px] resize-y`,value:u.body,onChange:e=>E({body:e.target.value})})]}),s.attachmentSlots.length>0&&_(`div`,{children:[_(`label`,{className:W,children:[`Attachments`,` `,_(`span`,{className:`text-foreground-subtle`,children:[`(mode: `,s.attachmentMode,`, max `,s.attachmentMax,s.attachmentMaxBytes?`, ≤${Math.round(s.attachmentMaxBytes/1024/1024)}MB`:``,`)`]})]}),w(`div`,{className:`space-y-1.5`,children:s.attachmentSlots.map(e=>_(`div`,{className:`flex items-center gap-2`,children:[w(`span`,{className:`text-[10px] w-12 shrink-0 text-foreground-subtle`,children:e}),w(`input`,{className:U,placeholder:`${e} URL`,value:u.attachmentUrls[e]??``,onChange:t=>E({attachmentUrls:{...u.attachmentUrls,[e]:t.target.value}})})]},e))})]}),s.showActions&&_(`div`,{children:[_(`label`,{className:W,children:[`Actions (up to `,s.maxActions,`)`]}),w(`div`,{className:`space-y-1.5`,children:Array.from({length:Math.min(s.maxActions,3)},(e,t)=>_(`div`,{className:`flex items-center gap-2`,children:[w(`input`,{className:U,placeholder:`label`,value:u.actions[t]?.label??``,onChange:e=>A(t,`label`,e.target.value)}),w(`input`,{className:U,placeholder:`url`,value:u.actions[t]?.url??``,onChange:e=>A(t,`url`,e.target.value)})]},t))})]}),_(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[s.showClickUrl&&_(`div`,{children:[w(`label`,{className:W,children:`Click URL`}),w(`input`,{className:U,value:u.clickUrl,onChange:e=>E({clickUrl:e.target.value})})]}),s.showSound&&_(`div`,{children:[w(`label`,{className:W,children:`Sound`}),w(`input`,{className:U,value:u.sound,onChange:e=>E({sound:e.target.value})})]}),s.showTtl&&_(`div`,{children:[w(`label`,{className:W,children:`TTL (seconds)`}),w(`input`,{className:U,type:`number`,value:u.ttl,onChange:e=>E({ttl:e.target.value})})]}),s.showTag&&_(`div`,{children:[w(`label`,{className:W,children:`Tag`}),w(`input`,{className:U,value:u.tag,onChange:e=>E({tag:e.target.value})})]})]}),g&&w(xe,{result:g}),_(`details`,{className:`text-[10px]`,children:[w(`summary`,{className:`cursor-pointer text-foreground-subtle`,children:`Payload preview`}),w(`pre`,{className:`mt-1 overflow-x-auto rounded bg-surface p-2 text-foreground-subtle`,children:JSON.stringify(b,null,2)})]})]}),_(l,{children:[w(t,{variant:`secondary`,size:`sm`,type:`button`,onClick:a,children:`Close`}),_(t,{size:`sm`,type:`button`,disabled:D.isPending||u.body.length===0,onClick:()=>D.mutate(),children:[D.isPending?w(F,{className:`h-3.5 w-3.5 animate-spin`}):w(P,{className:`h-3.5 w-3.5`}),`Send test`]})]})]})})}function xe({result:e}){let t=e.renderedAs;return _(`div`,{className:`rounded-md border px-3 py-2 text-xs ${e.success?`border-success/40 bg-success/10`:`border-danger/40 bg-danger/10`}`,"data-testid":`test-result`,children:[_(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.success?w(A,{className:`h-3.5 w-3.5 text-success`}):w(ne,{className:`h-3.5 w-3.5 text-danger`}),w(`span`,{children:e.success?`Delivered`:`Failed`})]}),e.error&&w(`p`,{className:`mt-1 text-danger`,children:e.error}),t&&_(`dl`,{className:`mt-2 grid grid-cols-2 gap-x-3 gap-y-0.5 text-[11px] text-foreground-subtle`,children:[w(`dt`,{children:`Resolved level`}),w(`dd`,{className:`text-foreground`,children:t.level}),w(`dt`,{children:`Format sent`}),w(`dd`,{className:`text-foreground`,children:t.format}),w(`dt`,{children:`Attachments sent`}),w(`dd`,{className:`text-foreground`,children:t.attachmentsSent}),w(`dt`,{children:`Actions sent`}),w(`dd`,{className:`text-foreground`,children:t.actionsSent}),w(`dt`,{children:`Truncated`}),w(`dd`,{className:`text-foreground`,children:t.truncated?`yes`:`no`}),w(`dt`,{children:`Dropped`}),w(`dd`,{className:`text-foreground`,children:t.dropped.length>0?t.dropped.join(`, `):`—`})]})]})}function Se(e){let t=[],n=new Map;for(let r of e){let e=n.get(r.addonId);e?e.push(r):(n.set(r.addonId,[r]),t.push(r.addonId))}return t.map(e=>({addonId:e,kinds:n.get(e)??[]}))}function Ce(e){let t=[],n=e=>{for(let r of e){if(r.type===`password`){t.push(r.key);continue}if(r.type===`group`){n(r.fields);continue}if(r.type===`sub-tabs`)for(let e of r.tabs)n(e.fields)}};for(let t of e.sections)n(t.fields);return t}function we(e,t,n){let r=new Set(n),i={};for(let[n,a]of Object.entries(e)){if(!r.has(n)){i[n]=a;continue}a==null||a===``||a!==t[n]&&(i[n]=a)}return i}function Te(e,t){let n=new Set(t),r={};for(let[t,i]of Object.entries(e))r[t]=n.has(t)?``:i;return r}g();var Ee=[`notificationOutput`,`listTargets`],De=[`notificationOutput`,`listTargetKinds`],Oe=[`userManagement`,`listUsers`],G=`ownerUserId`;function ke(e){let t=e.config[G];return typeof t==`string`&&t.length>0?t:null}function Ae(e){return[{key:`name`,header:`Target`,render:t=>{let n=e.kindByKey.get(t.kind);return _(`span`,{className:`flex items-center gap-2`,children:[w(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface text-xs`,title:n?.label??t.kind,children:w(K,{kind:n,imgClassName:`h-5 w-5 object-contain`,fallbackClassName:``})}),w(`span`,{className:`truncate text-sm font-medium text-foreground`,children:t.name}),!t.enabled&&w(f,{variant:`warning`,children:`disabled`})]})}},{key:`kind`,header:`Kind`,nowrap:!0,render:t=>w(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.kindByKey.get(t.kind)?.label??t.kind})},{key:`owner`,header:`Owner`,nowrap:!0,render:t=>{let n=ke(t);return n===null?w(f,{variant:`default`,children:`system`}):w(`span`,{className:`text-[11px] text-foreground`,children:e.userNameById.get(n)??n})}},{key:`enabled`,header:`On`,align:`center`,nowrap:!0,render:t=>w(u,{checked:t.enabled,onCheckedChange:n=>e.onToggle(t,n),"aria-label":`toggle ${t.name}`})},{key:`actions`,header:``,align:`right`,nowrap:!0,render:n=>{let r=e.kindByKey.get(n.kind);return _(`span`,{className:`flex items-center justify-end gap-1`,children:[w(t,{size:`sm`,variant:`ghost`,type:`button`,disabled:!r,onClick:()=>e.onTest(n),title:`Test`,children:w(P,{className:`h-3.5 w-3.5`})}),w(t,{size:`sm`,variant:`ghost`,type:`button`,disabled:!r,onClick:()=>r&&e.onEdit(n,r),title:`Edit`,children:w(ee,{className:`h-3.5 w-3.5`})}),w(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onDelete(n),title:`Delete`,children:w(L,{className:`h-3.5 w-3.5 text-danger`})})]})}}]}function K({kind:e,imgClassName:t,fallbackClassName:n}){return e?.iconUrl?w(`img`,{src:e.iconUrl,alt:e.label,className:t,loading:`lazy`,draggable:!1}):w(`span`,{className:n,children:e?.icon??`🔔`})}function je(){let e=k(),[n,r]=S({mode:`closed`}),[i,o]=S(null),c=y({queryKey:Ee,queryFn:()=>e.trpcClient.notificationOutput.listTargets.query({})}),l=y({queryKey:De,queryFn:async()=>(await e.trpcClient.notificationOutput.listTargetKinds.query({})).map(e=>{let t=e.iconUrl;return{...e,configSchema:e.configSchema,iconUrl:t}})}),u=v(()=>l.data??[],[l.data]),d=v(()=>{let e=new Map;for(let t of u)e.set(t.kind,t);return e},[u]),f=y({queryKey:Oe,queryFn:()=>e.trpcClient.userManagement.listUsers.query()}),m=v(()=>{let e=new Map;for(let t of f.data??[])e.set(t.id,t.username);return e},[f.data]),h=C({mutationFn:t=>e.trpcClient.notificationOutput.setTargetEnabled.mutate({addonId:t.target.addonId,targetId:t.target.id,enabled:t.enabled}),onSuccess:()=>void c.refetch()}),g=C({mutationFn:t=>e.trpcClient.notificationOutput.deleteTarget.mutate({addonId:t.addonId,targetId:t.id}),onSuccess:()=>void c.refetch()}),b=i?d.get(i.kind):void 0;return _(R,{icon:re,title:`Notification Targets`,subtitle:`Deliver notifications to ntfy, Pushover, Telegram, Home Assistant and more. Each target's kind declares its capabilities; the test panel shows exactly what a message degrades to.`,actions:_(t,{size:`sm`,type:`button`,onClick:()=>r({mode:`pick-kind`}),children:[w(M,{className:`h-3.5 w-3.5`}),`Add target`]}),children:[c.isLoading&&w(`div`,{className:`flex items-center justify-center py-16`,children:w(F,{className:`h-6 w-6 animate-spin text-primary`})}),c.isError&&!c.isLoading&&w(a,{title:`Failed to load targets`,message:c.error instanceof Error?c.error.message:`Unknown error`,onRetry:()=>void c.refetch()}),!c.isLoading&&!c.isError&&(c.data??[]).length===0&&w(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:`No notification targets yet. Click "Add target" to configure one.`}),(c.data??[]).length>0&&w(s,{children:w(p,{columns:Ae({kindByKey:d,userNameById:m,onToggle:(e,t)=>h.mutate({target:e,enabled:t}),onTest:o,onEdit:(e,t)=>r({mode:`form`,kind:t,target:e}),onDelete:e=>g.mutate(e)}),rows:c.data??[],rowKey:e=>e.id,minWidthPx:720,bordered:!1})}),n.mode===`pick-kind`&&w(Me,{kinds:u,onCancel:()=>r({mode:`closed`}),onPick:e=>r({mode:`form`,kind:e,target:null})}),n.mode===`form`&&w(Ne,{kind:n.kind,target:n.target,users:f.data??[],onCancel:()=>r({mode:`closed`}),onSaved:()=>{r({mode:`closed`}),c.refetch()}}),i&&b&&w(be,{target:i,kind:b,open:!0,onClose:()=>o(null)})]})}function Me({kinds:e,onPick:n,onCancel:r}){let i=v(()=>Se(e),[e]);return _(s,{className:`p-4 space-y-4`,children:[_(`div`,{className:`flex items-center justify-between`,children:[w(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Choose a notification kind`}),w(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:r,children:`Cancel`})]}),i.length===0&&w(`p`,{className:`text-xs text-foreground-subtle`,children:`No notification providers are installed. Install the notifiers addon (or connect Home Assistant) to add targets.`}),i.map(e=>_(`div`,{children:[w(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1.5`,children:e.addonId}),w(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2`,children:e.kinds.map(t=>_(`button`,{type:`button`,onClick:()=>n(t),className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-xs hover:border-primary/50 hover:bg-surface-hover transition-colors`,children:[w(K,{kind:t,imgClassName:`h-7 w-7 object-contain`,fallbackClassName:`text-lg leading-7`}),w(`span`,{className:`font-medium text-foreground`,children:t.label}),t.supportsDiscovery&&w(f,{variant:`info`,style:`outline`,children:`discover`})]},`${e.addonId}:${t.kind}`))})]},e.addonId))]})}function Ne({kind:e,target:n,users:r,onSaved:a,onCancel:o}){let l=k(),u=v(()=>Ce(e.configSchema),[e.configSchema]),d=v(()=>n?.config??{},[n]),[f,p]=S(n?.name??e.label),[m,h]=S(()=>n?Te(n.config,u):{}),[g,y]=S(null),[b,x]=S(null),[T,E]=S(n?ke(n)??``:``),D=C({mutationFn:()=>l.trpcClient.notificationOutput.discoverTargets.query({addonId:e.addonId,kind:e.kind,config:m}),onSuccess:e=>y(e),onError:e=>x(e instanceof Error?e.message:`Discovery failed`)}),O=C({mutationFn:()=>{let{[G]:t,...r}=we(m,d,u),i=T===``?r:{...r,[G]:T},a={id:n?.id??`${e.kind}-${Date.now()}`,name:f,kind:e.kind,addonId:e.addonId,enabled:n?.enabled??!0,config:i};return l.trpcClient.notificationOutput.upsertTarget.mutate({addonId:e.addonId,target:a})},onSuccess:a,onError:e=>x(e instanceof Error?e.message:`Save failed`)}),A=e=>{p(e.suggestedName),h(t=>({...t,...e.config})),y(null)};return _(s,{className:`p-4 space-y-4`,children:[_(`div`,{className:`flex items-center justify-between`,children:[_(`h3`,{className:`text-sm font-semibold text-foreground flex items-center gap-2`,children:[w(K,{kind:e,imgClassName:`h-5 w-5 object-contain`,fallbackClassName:`text-lg`}),n?`Edit ${n.name}`:`Add ${e.label} target`]}),w(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:o,children:`Cancel`})]}),b&&w(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:b}),_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Name`}),w(`input`,{className:`w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none`,value:f,onChange:e=>p(e.target.value)})]}),_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Owner`}),w(i,{value:T,options:[{value:``,label:`System (shared, admin-managed)`},...r.map(e=>({value:e.id,label:e.username}))],onChange:e=>E(e.target.value)}),w(`p`,{className:`mt-0.5 text-[10px] text-foreground-subtle`,children:`A user-owned target belongs to that user: it shows in their viewer and their own rules may deliver to it. System targets stay admin-managed.`})]}),e.supportsDiscovery&&_(`div`,{className:`space-y-2`,children:[_(t,{size:`sm`,variant:`outline`,type:`button`,disabled:D.isPending,onClick:()=>{x(null),D.mutate()},children:[D.isPending?w(F,{className:`h-3.5 w-3.5 animate-spin`}):w(te,{className:`h-3.5 w-3.5`}),`Discover`]}),g&&g.length===0&&w(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No candidates discovered.`}),g&&g.length>0&&w(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:g.map((e,t)=>_(`button`,{type:`button`,onClick:()=>A(e),className:`flex w-full items-center justify-between px-3 py-1.5 text-xs hover:bg-surface-hover`,children:[w(`span`,{className:`text-foreground`,children:e.suggestedName}),w(`span`,{className:`text-[10px] text-primary`,children:`use`})]},`${e.suggestedName}-${t}`))})]}),u.length>0&&n&&w(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Secret fields are hidden. Leave them blank to keep the stored value; type a new value to replace it.`}),w(c,{schema:e.configSchema,values:m,onChange:h}),_(`div`,{className:`flex justify-end gap-2`,children:[w(t,{variant:`secondary`,size:`sm`,type:`button`,onClick:o,children:`Cancel`}),_(t,{size:`sm`,type:`button`,disabled:O.isPending||f.trim().length===0,onClick:()=>{x(null),O.mutate()},children:[O.isPending&&w(F,{className:`h-3.5 w-3.5 animate-spin`}),n?`Save changes`:`Create target`]})]})]})}function q(e){return t=>Object.prototype.hasOwnProperty.call(e,t)}var Pe=q({devices:!0}),Fe=q({classes:!0,classesExclude:!0,labelEquals:!0,identities:!0,identitiesExclude:!0,eventTypeTokens:!0,sensorKinds:!0}),Ie=q({zonesExclude:!0}),Le=q({minConfidence:!0,minImportance:!0,minLabelConfidence:!0}),Re=q({minDwellSeconds:!0}),ze=q({source:!0}),Be=q({crossing:!0}),Ve=q({packagePhase:!0}),He=q({zones:!0}),Ue=q({plates:!0}),We=q({occupancy:!0});function J(e,t){let n=e[t];return Array.isArray(n)?n:[]}function Ge(e,t){let n=e[t];return typeof n==`number`?n:void 0}var Ke=[{id:`scope`,label:`Scope`},{id:`class`,label:`Classes`},{id:`zones`,label:`Zones`},{id:`quality`,label:`Quality`},{id:`label`,label:`Identity & plates`},{id:`device`,label:`Device event`},{id:`package`,label:`Package`},{id:`occupancy`,label:`Occupancy`},{id:`schedule`,label:`Schedule`}];function qe(e){let t=e.replace(/[-_]/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function Je(e,t){let n=e.filter(t),r=new Set(Ke.map(e=>e.id)),i=[];for(let e of Ke){let t=n.filter(t=>t.group===e.id);t.length>0&&i.push({id:e.id,label:e.label,descriptors:t})}let a=[];for(let e of n)r.has(e.group)||a.includes(e.group)||a.push(e.group);for(let e of a)i.push({id:e,label:qe(e),descriptors:n.filter(t=>t.group===e)});return i}g();function Ye(e,t){let n=k().trpcClient,r=x({queries:e.map(e=>({queryKey:[[`nc-pickers`,`zones`],{deviceId:e}],staleTime:3e4,queryFn:async()=>({deviceId:e,zones:(await n.zones.listZones.query({deviceId:e})).map(e=>({id:e.id,name:e.name}))})}))});return v(()=>{let e=[],n=new Set;for(let i of r){if(!i.data)continue;let r=t.find(e=>e.id===i.data.deviceId)?.name;for(let t of i.data.zones)n.has(t.id)||(n.add(t.id),e.push({value:t.id,label:t.name,...r===void 0?{}:{hint:r}}))}return{options:e,loading:r.some(e=>e.isLoading)}},[r,t])}function Xe(e){let t=k().trpcClient,n=x({queries:e.map(e=>({queryKey:[[`nc-pickers`,`event-kinds`],{deviceId:e}],staleTime:6e4,queryFn:async()=>(await t.pipelineAnalytics.listEventKinds.query({deviceId:e})).map(e=>({kind:e.kind,label:e.label}))}))});return v(()=>{let e=new Map;for(let t of n)for(let n of t.data??[])e.has(n.kind)||e.set(n.kind,n.label);let t=[...e.entries()].map(([e,t])=>({value:e,label:t}));return t.sort((e,t)=>e.label.localeCompare(t.label)),{options:t,loading:n.some(e=>e.isLoading)}},[n])}function Ze(){let t=e();return v(()=>({options:(t.data??[]).map(e=>({value:e.name,label:e.name})),loading:t.isLoading}),[t.data,t.isLoading])}function Qe(){let e=o({limit:200});return v(()=>{let t=new Set;for(let n of e.data??[])n.text.trim().length>0&&t.add(n.text);return[...t].sort()},[e.data])}function Y({options:e,value:t,onChange:n,loading:r,emptyHint:i,placeholder:a}){let[o,s]=S(``),c=v(()=>new Set(e.map(e=>e.value)),[e]),l=v(()=>new Set(t),[t]),u=t.filter(e=>!c.has(e)),d=e=>{n(l.has(e)?t.filter(t=>t!==e):[...t,e])},f=()=>{let e=o.trim();e.length===0||t.includes(e)||(n([...t,e]),s(``))};return _(`div`,{className:`mt-1 space-y-1.5`,children:[u.length>0&&w(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>_(`button`,{type:`button`,onClick:()=>n(t.filter(t=>t!==e)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:`Custom value — click to remove`,children:[e,` ×`]},e))}),e.length>0?w(`div`,{className:`max-h-40 overflow-y-auto rounded-md border border-border divide-y divide-border`,children:e.map(e=>_(`label`,{className:`flex items-center gap-2.5 px-3 py-1.5 text-xs text-foreground cursor-pointer hover:bg-surface-hover`,children:[w(`input`,{type:`checkbox`,checked:l.has(e.value),onChange:()=>d(e.value),className:`accent-primary`}),w(`span`,{className:`flex-1 truncate`,children:e.label}),e.hint!==void 0&&w(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.hint})]},e.value))}):w(`p`,{className:`text-[10px] text-foreground-subtle`,children:r===!0?`Loading…`:i}),w(`input`,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f())},placeholder:a,className:`w-full rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground placeholder:text-foreground-subtle`})]})}var X=[{value:`immediate`,label:`Immediate`,hint:`Fires on the first matching detection of a track (lowest latency).`},{value:`track-end`,label:`Track end`,hint:`Evaluates the finalised track record when it closes.`},{value:`device-event`,label:`Device event`,hint:`Doorbell press / sensor state change on a linked device.`},{value:`package-event`,label:`Package event`,hint:`A parcel delivery or pick-up.`}];function $e(e){return X.find(t=>t.value===e)?.label??e}function et(e){return X.find(t=>t.value===e)?.value}var Z=[{value:`best`,label:`Best available image`,description:`The best subject crop available when the notification is sent.`},{value:`best-matching`,label:`Best matching image`,description:`The image that explains why the rule fired — the face crop for an identity rule, the plate crop for a plate rule; falls back to the best image otherwise.`},{value:`keyFrame`,label:`Key frame`,description:`The clean full scene frame with no subject box.`},{value:`none`,label:`No attachment`,description:`Send the notification with no image.`}];function tt(e){return Z.find(t=>t.value===e)?.value}var nt=[{value:``,label:`Automatic`},{value:`cropped`,label:`Cropped on the subject`},{value:`full`,label:`Full frame`},{value:`boxed`,label:`Full frame with boxes`}];function rt(e){let t=nt.find(t=>t.value===e)?.value;return t===``?void 0:t}var it=[{value:``,label:`Lowest available`},{value:`low`,label:`Low`},{value:`mid`,label:`Medium`},{value:`high`,label:`High`}];function at(e){let t=it.find(t=>t.value===e)?.value;return t===``?void 0:t}var ot=[{value:`any`,label:`Any source`},{value:`pipeline`,label:`Pipeline`},{value:`onboard`,label:`Onboard (camera)`},{value:`sensor`,label:`Sensor`}],st=[{value:`delivered`,label:`Delivered`},{value:`picked-up`,label:`Picked up`},{value:`both`,label:`Both`}],Q=[{value:``,label:`Not set — entering`,hint:`Entries, and every detection that is not a crossing at all. Exits are excluded. This is what a rule without a crossing condition already does, and choosing it writes nothing to the rule.`},{value:`enter`,label:`Entered a zone`,hint:`The same matches as "not set", stated explicitly: entries and non-crossing detections pass, exits do not.`},{value:`exit`,label:`Left a zone`,hint:`ONLY an exit crossing. A detection that is not a crossing fails, so this rule cannot fire on ordinary movement — pair it with the zones the subject must have left.`},{value:`any`,label:`Entered or left`,hint:`No direction filter: entries, exits and non-crossing detections alike. This is the only choice that adds exits to what the rule already matched.`}];function ct(e){let t=Q.find(t=>t.value===e)?.value;return t===``||t===void 0?void 0:t}var lt=[{value:`any`,label:`Any of`},{value:`all`,label:`All of`}],ut=[{value:1,label:`1 — Min`},{value:2,label:`2 — Low`},{value:3,label:`3 — Default`},{value:4,label:`4 — High`},{value:5,label:`5 — Max`}];function dt(){return{name:``,enabled:!0,delivery:`immediate`,targetIds:[],targetUsers:[],targetParams:{},priority:3,mediaAttach:`best`,mediaZoneCrop:!1,mediaFrame:void 0,mediaGif:!1,mediaClip:!1,mediaProfile:void 0,templateTitle:``,templateBody:``,conditions:{},schedule:void 0}}function ft(e){let t={};for(let n of e.targets)n.params&&Object.keys(n.params).length>0&&(t[n.targetId]=n.params);return{name:e.name,enabled:e.enabled,delivery:e.delivery,targetIds:e.targets.map(e=>e.targetId),targetUsers:e.targetUsers??[],targetParams:t,priority:e.priority,mediaAttach:e.media.attach,mediaZoneCrop:e.media.zoneCrop===!0,mediaFrame:e.media.frame,mediaGif:e.media.gif===!0,mediaClip:e.media.clip===!0,mediaProfile:e.media.profile,templateTitle:e.template?.title??``,templateBody:e.template?.body??``,conditions:e.conditions,schedule:e.schedule}}function pt(e){return e.name.trim().length>0&&(e.targetIds.length>0||e.targetUsers.length>0)}function mt(e,t){return e.appliesTo.includes(t)}var ht={source:`any`};function gt(e,t){if(t==null)return!0;if(Array.isArray(t))return t.length===0;if(typeof t==`string`)return t.length===0||ht[e]===t;if(typeof t==`number`)return!Number.isFinite(t);if(typeof t==`object`){if(`ids`in t){let e=t.ids;return!Array.isArray(e)||e.length===0}if(`values`in t){let e=t.values;return!Array.isArray(e)||e.length===0}return!1}return!1}function _t(e,t,n){let r=n.length===0?null:new Set(n.filter(e=>e.id!==`schedule`&&mt(e,t)).map(e=>e.id)),i={};for(let[t,n]of Object.entries(e))r!==null&&!r.has(t)||gt(t,n)||(i[t]=n);return i}function vt(e){return e!==void 0&&e.windows.length>0}function yt(e,t,n=[]){let r=e.templateTitle.trim(),i=e.templateBody.trim(),a=r.length>0||i.length>0?{...r.length>0?{title:r}:{},...i.length>0?{body:i}:{}}:void 0,o=(n.length===0||n.some(t=>t.id===`schedule`&&mt(t,e.delivery)))&&vt(e.schedule)?e.schedule:void 0;return{name:e.name.trim(),enabled:e.enabled,delivery:e.delivery,conditions:_t(e.conditions,e.delivery,n),...o?{schedule:o}:{},targets:e.targetIds.map(t=>{let n=e.targetParams[t];return n&&Object.keys(n).length>0?{targetId:t,params:n}:{targetId:t}}),...e.targetUsers.length>0?{targetUsers:[...e.targetUsers]}:{},media:{attach:e.mediaAttach,...e.mediaZoneCrop?{zoneCrop:!0}:{},...e.mediaFrame===void 0?{}:{frame:e.mediaFrame},...e.mediaGif?{gif:!0}:{},...e.mediaClip?{clip:!0}:{},...e.mediaProfile===void 0?{}:{profile:e.mediaProfile}},throttle:t?.throttle??{cooldownSec:60,scope:`rule-device`},priority:e.priority,...a?{template:a}:{}}}g();var bt=`block text-[11px] font-medium text-foreground`,$=`text-[10px] text-foreground-subtle mt-0.5`;function xt({cameras:e,value:t,onChange:n}){if(e.length===0)return w(`p`,{className:$,children:`No cameras available — the rule applies to all devices.`});let r=e=>n(t.includes(e)?t.filter(t=>t!==e):[...t,e]);return w(`div`,{className:`mt-1 max-h-40 overflow-y-auto rounded-md border border-border divide-y divide-border`,children:e.map(e=>_(`label`,{className:`flex items-center gap-2.5 px-3 py-1.5 text-xs text-foreground cursor-pointer hover:bg-surface-hover`,children:[w(`input`,{type:`checkbox`,checked:t.includes(e.id),onChange:()=>r(e.id),className:`accent-primary`}),w(`span`,{className:`flex-1 truncate`,children:e.name})]},e.id))})}function St({value:e,placeholder:t,onChange:n}){let[i,a]=S(``),o=()=>{let t=i.trim();if(t.length===0||e.includes(t)){a(``);return}n([...e,t]),a(``)},s=t=>n(e.filter(e=>e!==t));return _(`div`,{className:`mt-1 space-y-1.5`,children:[e.length>0&&w(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>_(`span`,{className:`inline-flex items-center gap-1 rounded bg-surface-hover px-1.5 py-0.5 text-[11px] text-foreground`,children:[e,w(`button`,{type:`button`,onClick:()=>s(e),"aria-label":`remove ${e}`,className:`text-foreground-subtle hover:text-danger`,children:w(ie,{className:`h-3 w-3`})})]},e))}),w(r,{value:i,placeholder:t,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())},onBlur:o})]})}function Ct({picker:e,value:t,onChange:n}){let r=v(()=>E(e),[e]),i=v(()=>new Set(t),[t]),a=t.filter(e=>!r.has(e)),o=e=>{n(i.has(e)?t.filter(t=>t!==e):[...t,e])};return _(`div`,{className:`space-y-2`,children:[a.length>0&&w(`div`,{className:`flex flex-wrap gap-1`,children:a.map(e=>_(`button`,{type:`button`,onClick:()=>n(t.filter(t=>t!==e)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:`Custom value — click to remove`,children:[e,` ×`]},e))}),e.groups.map(e=>_(`div`,{children:[w(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-muted mb-1`,children:e.fallbackLabel}),w(`div`,{className:`flex flex-wrap gap-1`,children:e.options.map(e=>{let t=i.has(e.value);return w(`button`,{type:`button`,"aria-pressed":t,onClick:()=>o(e.value),className:t?`rounded border border-primary bg-primary/15 px-1.5 py-0.5 text-[10px] text-foreground`:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,children:e.label},e.value)})})]},e.key))]})}function wt({value:e,min:t,max:n,step:i,onChange:a}){return _(`div`,{className:`mt-1 flex items-center gap-2`,children:[w(r,{type:`number`,value:e??``,min:t,max:n,step:i,className:`max-w-[8rem]`,onChange:e=>{let t=e.target.value;if(t===``){a(void 0);return}let n=Number(t);a(Number.isFinite(n)?n:void 0)}}),e!==void 0&&n!==void 0&&w(`input`,{type:`range`,min:t,max:n,step:i,value:e,onChange:e=>a(Number(e.target.value)),className:`flex-1 accent-primary`,"aria-label":`value`})]})}function Tt({value:e,onChange:t}){let n=e??``,r=Q.find(e=>e.value===n);return _(`div`,{className:`mt-1 space-y-1`,children:[w(i,{value:n,options:Q.map(e=>({value:e.value,label:e.label})),onChange:e=>t(ct(e.target.value))}),r!==void 0&&w(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:r.hint})]})}function Et({deviceIds:e,cameras:t,value:n,onChange:r}){let a=n?.ids??[],o=n?.match??`any`,s=e=>r(e.length>0?{ids:e,match:o}:void 0),c=e=>r(a.length>0?{ids:a,match:e}:void 0);return _(`div`,{className:`mt-1 space-y-1.5`,children:[w(`div`,{className:`max-w-[10rem]`,children:w(i,{value:o,options:lt.map(e=>({value:e.value,label:e.label})),onChange:e=>c(e.target.value===`all`?`all`:`any`)})}),w(Dt,{deviceIds:e,cameras:t,value:a,onChange:s})]})}function Dt({deviceIds:e,cameras:t,value:n,onChange:r}){let{options:i,loading:a}=Ye(e,t);return w(Y,{options:i,value:n,onChange:r,loading:a,emptyHint:e.length===0?`Select cameras above to pick their zones by name — or type a zone id.`:`The selected cameras have no zones — type a zone id if you know one.`,placeholder:`Zone id…`})}function Ot({value:e,onChange:t}){let{options:n,loading:r}=Ze();return w(Y,{options:n,value:e,onChange:t,loading:r,emptyHint:`No identities in the face gallery yet — type a name.`,placeholder:`Identity name…`})}function kt({deviceIds:e,value:t,onChange:n}){let{options:r,loading:i}=Xe(e);return w(Y,{options:r,value:t,onChange:n,loading:i,emptyHint:e.length===0?`Select cameras above to pick their event kinds — or type a token.`:`No event kinds reported for the selected cameras — type a token.`,placeholder:`Event token…`})}var At=[{value:`became-occupied`,label:`Became occupied`},{value:`became-free`,label:`Became free`},{value:`>=`,label:`Count ≥`},{value:`<=`,label:`Count ≤`}],jt={op:`became-occupied`,count:1,sustainSeconds:15};function Mt({deviceIds:e,cameras:t,classOptions:n,value:a,onChange:o}){let{options:s,loading:c}=Ye(e,t),l=a??jt,u=e=>o({...l,...e}),d=l.op===`became-occupied`||l.op===`became-free`;return _(`div`,{className:`mt-1 space-y-1.5`,children:[_(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[w(`div`,{className:`min-w-[10rem]`,children:w(i,{value:l.zoneId??``,options:[{value:``,label:c?`Loading zones…`:`— whole frame —`},...s.map(e=>({value:e.value,label:e.label}))],onChange:e=>u({zoneId:e.target.value===``?void 0:e.target.value})})}),w(`div`,{className:`min-w-[9rem]`,children:w(i,{value:l.className??``,options:[{value:``,label:`— any class —`},...n.map(e=>({value:e.value,label:e.label}))],onChange:e=>u({className:e.target.value===``?void 0:e.target.value})})}),w(`div`,{className:`min-w-[9rem]`,children:w(i,{value:l.op,options:At.map(e=>({value:e.value,label:e.label})),onChange:e=>{let t=At.find(t=>t.value===e.target.value);t&&u({op:t.value})}})})]}),_(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[_(`label`,{className:`flex items-center gap-1`,children:[d?`Threshold`:`Count`,w(r,{type:`number`,min:0,className:`w-16`,value:String(l.count),onChange:e=>u({count:Math.max(0,Number(e.target.value)||0)})})]}),_(`label`,{className:`flex items-center gap-1`,children:[`Hold for`,w(r,{type:`number`,min:0,max:3600,className:`w-16`,value:String(l.sustainSeconds),onChange:e=>u({sustainSeconds:Math.min(3600,Math.max(0,Number(e.target.value)||0))})}),`s`]}),a===void 0?null:w(`button`,{type:`button`,onClick:()=>o(void 0),className:`underline hover:text-foreground`,children:`Clear`})]}),w(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Counts confirmed tracked objects from zone analytics. The change must hold for the sustain window before it fires; with no snapshot for the camera or zone the rule never fires.`})]})}function Nt({value:e,onChange:t}){let n=e?.values??[],i=e?.maxDistance??1,a=e=>t(e.length>0?{values:e,maxDistance:i}:void 0),o=e=>t(n.length>0?{values:n,maxDistance:e}:void 0),s=Qe().filter(e=>!n.includes(e));return _(`div`,{className:`mt-1 space-y-1.5`,children:[w(St,{value:n,placeholder:`Plate text…`,onChange:a}),s.length>0&&_(`div`,{className:`flex flex-wrap items-center gap-1`,children:[w(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Seen:`}),s.slice(0,12).map(e=>w(`button`,{type:`button`,onClick:()=>a([...n,e]),className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:e},e))]}),_(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Max distance`,w(r,{type:`number`,min:0,max:3,step:1,value:i,className:`max-w-[5rem]`,onChange:e=>{let t=Number(e.target.value);o(Number.isFinite(t)?Math.max(0,Math.min(3,t)):1)}})]})]})}var Pt=[{value:1,label:`Mon`},{value:2,label:`Tue`},{value:3,label:`Wed`},{value:4,label:`Thu`},{value:5,label:`Fri`},{value:6,label:`Sat`},{value:0,label:`Sun`}];function Ft(e){let t=Math.floor(e/60),n=e%60;return`${String(t).padStart(2,`0`)}:${String(n).padStart(2,`0`)}`}function It(e){let[t,n]=e.split(`:`),r=Number(t)*60+Number(n);return Number.isFinite(r)?Math.max(0,Math.min(1439,r)):0}function Lt(){return{days:[1,2,3,4,5],startMinute:540,endMinute:1080}}function Rt({value:e,onChange:t}){let n=e?.windows??[],r=e?.invert??!1,i=(n,r)=>{if(n.length===0){t(void 0);return}t({windows:n,...r?{invert:!0}:{},...e?.timezone?{timezone:e.timezone}:{}})},a=()=>i([...n,Lt()],r),o=e=>i(n.filter((t,n)=>n!==e),r),s=(e,t)=>i(n.map((n,r)=>r===e?t:n),r);return _(`div`,{className:`mt-1 space-y-2`,children:[n.length===0?w(`p`,{className:$,children:`Always active — add a window to restrict when the rule fires.`}):n.map((e,t)=>w(zt,{window:e,onChange:e=>s(t,e),onRemove:()=>o(t)},t)),_(`div`,{className:`flex items-center gap-3`,children:[_(`button`,{type:`button`,onClick:a,className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[w(M,{className:`h-3 w-3`}),` Add window`]}),n.length>0&&_(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[w(`input`,{type:`checkbox`,checked:r,onChange:e=>i([...n],e.target.checked),className:`accent-primary`}),`Active outside the windows`]})]})]})}function zt({window:e,onChange:t,onRemove:n}){let r=n=>{let r=e.days.includes(n)?e.days.filter(e=>e!==n):[...e.days,n];r.length!==0&&t({...e,days:r})};return _(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[_(`div`,{className:`flex items-center gap-2 text-xs`,children:[w(`input`,{type:`time`,value:Ft(e.startMinute),onChange:n=>t({...e,startMinute:It(n.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),w(`span`,{className:`text-foreground-subtle`,children:`→`}),w(`input`,{type:`time`,value:Ft(e.endMinute),onChange:n=>t({...e,endMinute:It(n.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),w(`span`,{className:`flex-1`}),w(`button`,{type:`button`,onClick:n,"aria-label":`Remove window`,className:`text-foreground-subtle hover:text-danger`,children:w(L,{className:`h-3.5 w-3.5`})})]}),w(`div`,{className:`flex flex-wrap gap-1`,children:Pt.map(t=>w(`button`,{type:`button`,onClick:()=>r(t.value),className:`rounded px-1.5 py-0.5 text-[10px] ${e.days.includes(t.value)?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:t.label},t.value))})]})}g();function Bt({catalog:e,taxonomy:t,delivery:n,conditions:r,schedule:i,cameras:a,onConditionsChange:o,onScheduleChange:s}){let c=(e,t)=>{let n={...r};t===void 0?delete n[e]:n[e]=t,o(n)},l=v(()=>Je(e,e=>O(e.id)),[e]),u=v(()=>Je(e,e=>!O(e.id)),[e]),[d,p]=S(()=>{if(Ht(r,i))return!0;try{return localStorage.getItem(Vt)===`1`}catch{return!1}}),m=()=>{let e=!d;p(e);try{localStorage.setItem(Vt,e?`1`:`0`)}catch{}},h=e=>e.map(e=>_(`div`,{className:`space-y-2.5`,children:[w(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:e.label}),e.descriptors.map(e=>{let o=mt(e,n);return _(`div`,{className:o?``:`opacity-50`,"data-testid":`condition-${e.id}`,children:[_(`div`,{className:`flex items-center justify-between gap-2`,children:[w(`label`,{className:bt,children:e.label}),!o&&_(f,{variant:`default`,children:[`not for `,e.appliesTo.join(` / `)]})]}),o?w(Ut,{descriptor:e,taxonomy:t,conditions:r,schedule:i,cameras:a,onFieldChange:c,onScheduleChange:s}):w(`p`,{className:$,children:`Not evaluated for the selected trigger — switch the trigger to use it.`}),o&&e.description&&w(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:e.description})]},e.id)})]},e.id));return _(`div`,{className:`space-y-4`,children:[h(l),u.length>0&&w(`button`,{type:`button`,onClick:m,"data-testid":`nc-advanced-toggle`,className:`w-full rounded-md border border-border px-3 py-1.5 text-left text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:d?`▾ Hide advanced configurations`:`▸ Show more configurations`}),d&&h(u)]})}var Vt=`camstack.nc.showAdvanced`;function Ht(e,t){for(let[t,n]of Object.entries(e))if(!O(t)&&n!==void 0&&!(Array.isArray(n)&&n.length===0))return!0;return t!==void 0&&t.windows.length>0}function Ut({descriptor:e,taxonomy:t,conditions:n,schedule:r,cameras:a,onFieldChange:o,onScheduleChange:s}){switch(e.valueType){case`deviceIdList`:{if(!Pe(e.id))break;let t=e.id;return w(xt,{cameras:a,value:n[t]??[],onChange:e=>o(t,e.length>0?e:void 0)})}case`stringList`:{if(!Fe(e.id))break;let r=e.id,i=e=>o(r,e.length>0?e:void 0);if(r===`identities`||r===`identitiesExclude`)return w(Ot,{value:J(n,r),onChange:i});if(r===`eventTypeTokens`)return w(kt,{deviceIds:n.devices??[],value:J(n,r),onChange:i});let a=T(r,t);return a===null?w(St,{value:J(n,r),placeholder:`Add value…`,onChange:i}):w(Ct,{picker:a,value:J(n,r),onChange:i})}case`zoneIdList`:{if(!Ie(e.id))break;let t=e.id;return w(Dt,{deviceIds:n.devices??[],cameras:a,value:J(n,t),onChange:e=>o(t,e.length>0?e:void 0)})}case`number01`:{if(!Le(e.id))break;let t=e.id;return w(wt,{value:Ge(n,t),min:0,max:1,step:.05,onChange:e=>o(t,e)})}case`number`:{if(!Re(e.id))break;let t=e.id;return w(wt,{value:Ge(n,t),min:0,step:1,onChange:e=>o(t,e)})}case`sourceSelect`:{if(!ze(e.id))break;let t=e.id;return w(i,{value:n[t]??`any`,options:ot.map(e=>({value:e.value,label:e.label})),onChange:e=>o(t,Kt(e.target.value))})}case`crossingSelect`:{if(!Be(e.id))break;let t=e.id;return w(Tt,{value:n[t],onChange:e=>o(t,e)})}case`packagePhase`:{if(!Ve(e.id))break;let t=e.id;return w(i,{value:n[t]??``,options:[{value:``,label:`— any phase —`},...st.map(e=>({value:e.value,label:e.label}))],onChange:e=>o(t,qt(e.target.value))})}case`zoneSelection`:{if(!He(e.id))break;let t=e.id;return w(Et,{deviceIds:n.devices??[],cameras:a,value:n[t],onChange:e=>o(t,e)})}case`plateMatcher`:{if(!Ue(e.id))break;let t=e.id;return w(Nt,{value:n[t],onChange:e=>o(t,e)})}case`occupancy`:{if(!We(e.id))break;let r=e.id;return w(Mt,{deviceIds:n.devices??[],cameras:a,classOptions:Wt(t),value:n[r],onChange:e=>o(r,e)})}case`schedule`:return w(Rt,{value:r,onChange:s});default:break}return w(Gt,{descriptor:e,conditions:n})}function Wt(e){let t=T(`classes`,e);return t===null?[]:t.groups.flatMap(e=>e.options)}function Gt({descriptor:e,conditions:t}){let n=Object.entries(t).find(([t])=>t===e.id);return _(`p`,{className:$,children:[n!==void 0&&n[1]!==void 0?`Authored elsewhere and preserved — this admin editor cannot change it yet.`:`Not editable here yet — this condition has no admin editor.`,` `,_(`span`,{className:`text-foreground-muted`,children:[`(`,e.valueType,`)`]})]})}function Kt(e){if(e===`pipeline`||e===`onboard`||e===`sensor`||e===`any`)return e}function qt(e){return st.find(t=>t.value===e)?.value}g();var Jt=[`notificationRules`,`listRules`],Yt=[`notificationOutput`,`listTargets`,`forRules`],Xt=[`notificationRules`,`getConditionCatalog`],Zt=[`deviceManager`,`listAll`,`forRules`];function Qt(){let e=k(),[n,r]=S({mode:`closed`}),[i,o]=S(null),c=y({queryKey:Jt,queryFn:async()=>(await e.trpcClient.notificationRules.listRules.query({})).rules}),l=y({queryKey:Yt,queryFn:()=>e.trpcClient.notificationOutput.listTargets.query({})}),u=y({queryKey:Xt,queryFn:()=>e.trpcClient.notificationRules.getConditionCatalog.query({})}),d=y({queryKey:Zt,queryFn:async()=>(await e.trpcClient.deviceManager.listAll.query({})).filter(e=>e.type===D.Camera).map(e=>({id:e.id,name:e.name}))}),f=v(()=>{let e=new Map;for(let t of l.data??[])e.set(t.id,t.name);return e},[l.data]),m=C({mutationFn:t=>e.trpcClient.notificationRules.setRuleEnabled.mutate(t),onSuccess:()=>void c.refetch()}),h=C({mutationFn:t=>e.trpcClient.notificationRules.deleteRule.mutate({ruleId:t}),onSuccess:()=>{o(null),c.refetch()}}),g=c.data??[];return _(R,{icon:oe,title:`Notification Rules`,subtitle:`Author rules that turn detections, doorbell presses and package events into notifications. Each rule picks a trigger, matches conditions and fans out to one or more delivery targets.`,actions:_(t,{size:`sm`,type:`button`,onClick:()=>r({mode:`form`,rule:null}),children:[w(M,{className:`h-3.5 w-3.5`}),`New rule`]}),children:[c.isLoading&&w(`div`,{className:`flex items-center justify-center py-16`,children:w(F,{className:`h-6 w-6 animate-spin text-primary`})}),c.isError&&!c.isLoading&&w(a,{title:`Failed to load rules`,message:c.error instanceof Error?c.error.message:`Unknown error`,onRetry:()=>void c.refetch()}),!c.isLoading&&!c.isError&&g.length===0&&w(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:`No notification rules yet. Click "New rule" to author one.`}),g.length>0&&w(s,{children:w(p,{columns:$t({targetNameById:f,confirmDeleteId:i,deletePending:h.isPending,onToggle:(e,t)=>m.mutate({ruleId:e.id,enabled:t}),onEdit:e=>r({mode:`form`,rule:e}),onDuplicate:e=>r({mode:`form`,rule:{...e,id:``,name:`${e.name} (copy)`}}),onAskDelete:o,onConfirmDelete:e=>h.mutate(e.id)}),rows:g,rowKey:e=>e.id,minWidthPx:760,bordered:!1})}),n.mode===`form`&&w(en,{rule:n.rule,targets:l.data??[],catalog:u.data?.catalog??[],taxonomy:u.data?.taxonomy,cameras:d.data??[],onCancel:()=>r({mode:`closed`}),onSaved:()=>{r({mode:`closed`}),c.refetch()}})]})}function $t(e){return[{key:`name`,header:`Rule`,render:e=>_(`span`,{className:`flex items-center gap-2`,children:[w(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),!e.enabled&&w(f,{variant:`warning`,children:`disabled`})]})},{key:`trigger`,header:`Trigger`,nowrap:!0,render:e=>w(`span`,{className:`text-[11px] text-foreground-subtle`,children:$e(e.delivery)})},{key:`targets`,header:`Targets`,render:t=>{let n=t.targets[0],r=n?e.targetNameById.get(n.targetId)??n.targetId:null;return w(`span`,{className:`text-[11px] text-foreground-subtle`,children:t.targets.length===1&&r?r:`${t.targets.length} target${t.targets.length===1?``:`s`}`})}},{key:`priority`,header:`Priority`,align:`center`,nowrap:!0,render:e=>w(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.priority})},{key:`enabled`,header:`On`,align:`center`,nowrap:!0,render:t=>w(u,{checked:t.enabled,onCheckedChange:n=>e.onToggle(t,n),"aria-label":`toggle ${t.name}`})},{key:`actions`,header:``,align:`right`,nowrap:!0,render:n=>_(`span`,{className:`flex items-center justify-end gap-1`,children:[w(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onEdit(n),title:`Edit`,children:w(ee,{className:`h-3.5 w-3.5`})}),w(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onDuplicate(n),title:`Duplicate`,children:w(j,{className:`h-3.5 w-3.5`})}),e.confirmDeleteId===n.id?_(b,{children:[_(t,{size:`sm`,variant:`danger`,type:`button`,disabled:e.deletePending,onClick:()=>e.onConfirmDelete(n),children:[e.deletePending&&w(F,{className:`h-3.5 w-3.5 animate-spin`}),`Confirm`]}),w(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onAskDelete(null),children:`Cancel`})]}):w(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onAskDelete(n.id),title:`Delete`,children:w(L,{className:`h-3.5 w-3.5 text-danger`})})]})}]}function en({rule:e,targets:n,catalog:a,taxonomy:o,cameras:s,onSaved:c,onCancel:l}){let p=k(),m=e!=null&&e.id.length>0,[g,v]=S(()=>e?ft(e):dt()),[b,x]=S(null),[T,E]=S(null),D=e=>v(t=>({...t,...e})),O=m&&e?{throttle:e.throttle}:void 0,A=C({mutationFn:async()=>{let t=yt(g,O,a);m&&e?await p.trpcClient.notificationRules.updateRule.mutate({ruleId:e.id,patch:t}):await p.trpcClient.notificationRules.createRule.mutate({rule:t})},onSuccess:c,onError:e=>x(e instanceof Error?e.message:`Save failed`)}),j=C({mutationFn:async()=>{let e=yt(g,O,a);return(await p.trpcClient.notificationRules.testRule.mutate({rule:e,lookbackMinutes:60})).results},onMutate:()=>E(null),onSuccess:e=>E(e),onError:e=>x(e instanceof Error?e.message:`Test failed`)}),ee=g.targetIds.map(e=>n.find(t=>t.id===e)?.name??e),M=e=>D({targetIds:g.targetIds.includes(e)?g.targetIds.filter(t=>t!==e):[...g.targetIds,e]}),N=y({queryKey:[`userManagement`,`listUsers`],queryFn:()=>p.trpcClient.userManagement.listUsers.query()}).data,te=e=>D({targetUsers:g.targetUsers.includes(e)?g.targetUsers.filter(t=>t!==e):[...g.targetUsers,e]}),P=X.find(e=>e.value===g.delivery)?.hint;return w(h,{open:!0,onOpenChange:e=>!e&&l(),children:_(d,{width:`lg`,placement:`sheet-on-mobile`,children:[_(`div`,{className:`flex items-center justify-between mb-3`,children:[_(`h3`,{className:`text-sm font-semibold text-foreground flex items-center gap-2`,children:[w(oe,{className:`h-4 w-4 text-foreground-subtle`}),m?`Edit ${e?.name}`:`New notification rule`]}),w(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:l,children:`Cancel`})]}),b&&w(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger mb-3`,children:b}),_(`div`,{className:`space-y-4`,children:[_(`div`,{className:`flex items-end gap-3`,children:[_(`div`,{className:`min-w-0 flex-1`,children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Name`}),w(r,{value:g.name,onChange:e=>D({name:e.target.value}),placeholder:`e.g. Front door package`})]}),_(`label`,{className:`flex items-center gap-2 pb-1.5 text-[11px] font-medium text-foreground`,children:[w(u,{checked:g.enabled,onCheckedChange:e=>D({enabled:e}),"aria-label":`enabled`}),`Enabled`]})]}),_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Trigger`}),w(i,{value:g.delivery,onChange:e=>{let t=et(e.target.value);t&&D({delivery:t})},options:X.map(e=>({value:e.value,label:e.label}))}),P&&w(`p`,{className:`text-[10px] text-foreground-subtle mt-1`,children:P})]}),_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Delivery targets`}),n.length===0?w(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No delivery targets configured. Add one under the Targets tab first.`}):w(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:n.map(e=>_(`label`,{className:`flex items-center gap-2.5 px-3 py-1.5 text-xs text-foreground cursor-pointer hover:bg-surface-hover`,children:[w(`input`,{type:`checkbox`,checked:g.targetIds.includes(e.id),onChange:()=>M(e.id),className:`accent-primary`}),w(`span`,{className:`flex-1 truncate`,children:e.name}),!e.enabled&&w(f,{variant:`warning`,children:`disabled`})]},e.id))})]}),_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Notify users`}),(N??[]).length===0?w(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No users to notify.`}):w(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:(N??[]).map(e=>_(`label`,{className:`flex items-center gap-2.5 px-3 py-1.5 text-xs text-foreground cursor-pointer hover:bg-surface-hover`,children:[w(`input`,{type:`checkbox`,checked:g.targetUsers.includes(e.id),onChange:()=>te(e.id),className:`accent-primary`}),w(`span`,{className:`flex-1 truncate`,children:e.username}),e.isAdmin&&w(f,{variant:`info`,children:`admin`})]},e.id))}),w(`p`,{className:`text-[10px] text-foreground-subtle mt-1`,children:`Delivers to the targets each user owns, only for cameras that user can access.`})]}),_(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Priority`}),w(i,{value:String(g.priority),onChange:e=>D({priority:Number(e.target.value)}),options:ut.map(e=>({value:String(e.value),label:e.label}))})]}),_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Media attachment`}),w(i,{value:g.mediaAttach,onChange:e=>{let t=tt(e.target.value);t&&D({mediaAttach:t})},options:Z.map(e=>({value:e.value,label:e.label}))}),w(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:Z.find(e=>e.value===g.mediaAttach)?.description}),_(`div`,{className:`mt-2 space-y-1`,children:[_(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[w(`input`,{type:`checkbox`,checked:g.mediaZoneCrop,onChange:e=>D({mediaZoneCrop:e.target.checked}),className:`accent-primary`}),`Crop the image to the rule's zone`]}),_(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[w(`input`,{type:`checkbox`,checked:g.mediaGif,onChange:e=>D({mediaGif:e.target.checked}),className:`accent-primary`}),`Attach a GIF around the event`]}),_(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[w(`input`,{type:`checkbox`,checked:g.mediaClip,onChange:e=>D({mediaClip:e.target.checked}),className:`accent-primary`}),`Attach an MP4 clip around the event`]})]}),(g.mediaGif||g.mediaClip)&&_(`div`,{className:`mt-2`,children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Video quality`}),w(i,{value:g.mediaProfile??``,onChange:e=>D({mediaProfile:at(e.target.value)}),options:it.map(e=>({value:e.value,label:e.label}))}),w(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:`A notification is watched on a phone — the cheapest stream is normally the right one, and the high profile only costs CPU to render.`})]})]}),_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Image frame`}),w(i,{value:g.mediaFrame??``,onChange:e=>D({mediaFrame:rt(e.target.value)}),options:nt.map(e=>({value:e.value,label:e.label}))}),w(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:`What the attached still shows. "Automatic" leaves it to the attachment mode above.`})]})]}),_(`div`,{className:`space-y-2`,children:[_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Notification title`}),w(r,{value:g.templateTitle,onChange:e=>D({templateTitle:e.target.value}),placeholder:`{{camera}} — {{class}}`})]}),_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Notification body`}),w(`textarea`,{value:g.templateBody,onChange:e=>D({templateBody:e.target.value}),rows:2,placeholder:`{{label}} seen in {{zone}} at {{time}}`,className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`})]}),_(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Leave blank to use the backend default text. Supported variables include`,` `,w(`code`,{children:`{{camera}}`}),`, `,w(`code`,{children:`{{class}}`}),`, `,w(`code`,{children:`{{label}}`}),`,`,` `,w(`code`,{children:`{{zone}}`}),`, `,w(`code`,{children:`{{confidence}}`}),`, `,w(`code`,{children:`{{time}}`}),`.`]})]}),_(`div`,{className:`rounded-md border border-border px-3 py-3`,children:[w(`div`,{className:`mb-2 text-[11px] font-semibold text-foreground`,children:`Conditions`}),a.length===0?w(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Condition catalog unavailable — this rule matches on its trigger and targets alone.`}):w(Bt,{catalog:a,taxonomy:o,delivery:g.delivery,conditions:g.conditions,schedule:g.schedule,cameras:s,onConditionsChange:e=>D({conditions:e}),onScheduleChange:e=>D({schedule:e})})]}),_(`div`,{className:`rounded-md border border-border px-3 py-3`,children:[_(`div`,{className:`flex items-center justify-between gap-2`,children:[w(`div`,{className:`text-[11px] font-semibold text-foreground`,children:`Test rule`}),_(t,{size:`sm`,variant:`outline`,type:`button`,disabled:j.isPending||!pt(g),onClick:()=>{x(null),j.mutate()},children:[j.isPending?w(F,{className:`h-3.5 w-3.5 animate-spin`}):w(se,{className:`h-3.5 w-3.5`}),`Dry-run (last 60 min)`]})]}),w(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:`Evaluate the CURRENT (unsaved) rule against recently persisted records — no notification is sent.`}),T!==null&&w(tn,{delivery:g.delivery,results:T,targetNames:ee})]})]}),_(`div`,{className:`flex justify-end gap-2 mt-4`,children:[w(t,{variant:`secondary`,size:`sm`,type:`button`,onClick:l,children:`Cancel`}),_(t,{size:`sm`,type:`button`,disabled:A.isPending||!pt(g),onClick:()=>{x(null),A.mutate()},children:[A.isPending&&w(F,{className:`h-3.5 w-3.5 animate-spin`}),m?`Save changes`:`Create rule`]})]})]})})}function tn({delivery:e,results:t,targetNames:n}){if(e===`device-event`)return w(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:`Device-event rules cannot be dry-run: the sensor-event store has no cross-device scan surface, so a test returns no candidate records. The rule still fires live on a matching doorbell press / sensor change.`});if(t.length===0)return w(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:`No records in the last 60 minutes matched — nothing to evaluate.`});let r=t.filter(e=>e.wouldFire).length;return _(`div`,{className:`mt-2 space-y-1.5`,children:[_(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r,` of `,t.length,` evaluated record`,t.length===1?``:`s`,` would fire.`]}),w(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.slice(0,50).map(e=>_(`li`,{className:`flex items-center gap-2 px-2.5 py-1.5 text-[11px]`,children:[e.wouldFire?w(A,{className:`h-3.5 w-3.5 shrink-0 text-success`}):w(ne,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),w(`span`,{className:`w-32 shrink-0 text-foreground-subtle`,children:new Date(e.timestamp).toLocaleString()}),_(`span`,{className:`w-14 shrink-0 text-foreground-subtle`,children:[`#`,e.deviceId]}),w(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.label??e.className??`object`}),e.wouldFire?_(`span`,{className:`shrink-0 truncate text-success`,children:[`→ `,n.join(`, `)||`targets`]}):e.failedCondition&&_(`span`,{className:`shrink-0 text-foreground-subtle`,children:[`failed: `,e.failedCondition]})]},e.recordId))})]})}g();var nn=[{value:1,label:`Last hour`},{value:24,label:`Last 24 hours`},{value:168,label:`Last 7 days`},{value:0,label:`All time`}],rn=[{value:``,label:`Any status`},{value:`pending`,label:`Pending`},{value:`sent`,label:`Sent`},{value:`dead`,label:`Dead`}],an=[50,100,250,500];function on(){return{ruleId:``,deviceId:``,status:``,windowHours:24,limit:100}}function sn(e){return e===`pending`||e===`sent`||e===`dead`?e:void 0}function cn(e){switch(e){case`pending`:return`info`;case`sent`:return`success`;case`dead`:return`danger`}}function ln(){let e=k(),[t,n]=S(on),r=e=>n(t=>({...t,...e})),a=y({queryKey:[`notificationRules`,`listRules`,`forHistory`],queryFn:async()=>(await e.trpcClient.notificationRules.listRules.query({})).rules}),o=y({queryKey:[`deviceManager`,`listAll`,`forHistory`],queryFn:async()=>(await e.trpcClient.deviceManager.listAll.query({})).filter(e=>e.type===D.Camera).map(e=>({id:e.id,name:e.name}))}),c=Date.now(),l=y({queryKey:[`notificationRules`,`getHistory`,t],retry:!1,queryFn:async()=>{let n=t.windowHours>0?c-t.windowHours*36e5:void 0;return(await e.trpcClient.notificationRules.getHistory.query({filter:{limit:t.limit,...t.ruleId?{ruleId:t.ruleId}:{},...t.deviceId?{deviceId:Number(t.deviceId)}:{},...sn(t.status)?{status:sn(t.status)}:{},...n===void 0?{}:{since:n}}})).entries}}),u=v(()=>{let e=new Map;for(let t of o.data??[])e.set(t.id,t.name);return e},[o.data]),d=e=>u.get(e)??`Camera #${String(e)}`,f=l.data??[],m=l.isError;return _(R,{icon:z,title:`Delivery history`,subtitle:`A searchable log of every notification the rules delivered (or failed to deliver).`,children:[_(`div`,{className:`mb-4 grid grid-cols-2 gap-2 sm:grid-cols-5`,children:[_(`div`,{children:[w(`label`,{className:`mb-1 block text-[10px] font-medium text-foreground-subtle`,children:`Rule`}),w(i,{value:t.ruleId,onChange:e=>r({ruleId:e.target.value}),options:[{value:``,label:`All rules`},...(a.data??[]).map(e=>({value:e.id,label:e.name}))]})]}),_(`div`,{children:[w(`label`,{className:`mb-1 block text-[10px] font-medium text-foreground-subtle`,children:`Camera`}),w(i,{value:t.deviceId,onChange:e=>r({deviceId:e.target.value}),options:[{value:``,label:`All cameras`},...(o.data??[]).map(e=>({value:String(e.id),label:e.name}))]})]}),_(`div`,{children:[w(`label`,{className:`mb-1 block text-[10px] font-medium text-foreground-subtle`,children:`Status`}),w(i,{value:t.status,onChange:e=>r({status:e.target.value}),options:rn.map(e=>({value:e.value,label:e.label}))})]}),_(`div`,{children:[w(`label`,{className:`mb-1 block text-[10px] font-medium text-foreground-subtle`,children:`Window`}),w(i,{value:String(t.windowHours),onChange:e=>r({windowHours:Number(e.target.value)}),options:nn.map(e=>({value:String(e.value),label:e.label}))})]}),_(`div`,{children:[w(`label`,{className:`mb-1 block text-[10px] font-medium text-foreground-subtle`,children:`Limit`}),w(i,{value:String(t.limit),onChange:e=>r({limit:Number(e.target.value)}),options:an.map(e=>({value:String(e),label:String(e)}))})]})]}),l.isLoading&&w(`div`,{className:`flex items-center justify-center py-16`,children:w(F,{className:`h-6 w-6 animate-spin text-primary`})}),m&&!l.isLoading&&w(s,{children:_(`div`,{className:`flex flex-col items-center gap-2 px-4 py-14 text-center`,children:[w(z,{className:`h-6 w-6 text-foreground-subtle`}),w(`div`,{className:`text-sm font-medium text-foreground`,children:`Delivery history requires a server update`}),w(`p`,{className:`max-w-md text-xs text-foreground-subtle`,children:`The history query is not available on this hub yet. It becomes queryable after the next server update ships the notification-center history endpoint. Rules still deliver and record their outcome in the meantime.`}),_(`button`,{type:`button`,onClick:()=>void l.refetch(),className:`mt-1 inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:[w(N,{className:`h-3 w-3`}),` Retry`]})]})}),!m&&!l.isLoading&&f.length===0&&w(`div`,{className:`py-16 text-center text-xs text-foreground-subtle`,children:`No deliveries match these filters.`}),!m&&f.length>0&&w(s,{children:w(p,{columns:un(d),rows:f,rowKey:e=>e.id,minWidthPx:720,bordered:!1})})]})}function un(e){return[{key:`when`,header:`When`,nowrap:!0,render:e=>w(`span`,{className:`text-[11px] text-foreground-subtle`,children:new Date(e.createdAt).toLocaleString()})},{key:`rule`,header:`Rule`,render:e=>w(`span`,{className:`text-xs font-medium text-foreground`,children:e.ruleName})},{key:`camera`,header:`Camera`,nowrap:!0,render:t=>w(`span`,{className:`text-[11px] text-foreground-subtle`,children:e(t.deviceId)})},{key:`subject`,header:`Subject`,render:e=>_(`span`,{className:`text-[11px] text-foreground-subtle`,children:[e.subject.label??e.subject.className,e.subject.confidence===void 0?``:` · ${Math.round(e.subject.confidence*100)}%`]})},{key:`status`,header:`Status`,nowrap:!0,render:e=>_(`span`,{className:`flex items-center gap-1.5`,children:[w(f,{variant:cn(e.status),children:e.status}),e.attempts>1?_(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`×`,e.attempts]}):null]})},{key:`error`,header:`Detail`,render:e=>e.error?w(`span`,{className:`text-[11px] text-danger`,children:e.error}):w(`span`,{className:`text-[11px] text-foreground-subtle`,children:`—`})}]}function dn(){return w(`div`,{className:`flex flex-col p-4`,children:w(ae,{tabs:[{id:`targets`,label:`Targets`,icon:re,content:w(je,{})},{id:`rules`,label:`Rules`,icon:oe,content:w(Qt,{})},{id:`history`,label:`History`,icon:z,content:w(ln,{})}]})})}export{dn as NotificationsPage,dn as default};
@@ -1 +0,0 @@
1
- import{W as e}from"./index-D0JhMwHm.js";var t=e(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]);export{t};
@@ -1 +0,0 @@
1
- import{W as e}from"./index-D0JhMwHm.js";var t=e(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]);export{t};