chordia-ui 3.9.5 → 3.9.7

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.
@@ -0,0 +1,1046 @@
1
+ import { jsxs as r, jsx as e, Fragment as E } from "react/jsx-runtime";
2
+ import { useState as W, useRef as ue, useEffect as P, useMemo as G } from "react";
3
+ import { MoreHorizontal as xe, CloudOff as ve, CloudCheck as ke, Check as we, ScrollText as fe, X as Fe, Pencil as Se, Plus as ze, Filter as De, Search as Be } from "lucide-react";
4
+ import { u as Ie } from "../useMediaQuery.es.js";
5
+ const u = {
6
+ ink: "var(--Grey-Strong, #2E3236)",
7
+ muted: "var(--Grey-Muted, #808183)",
8
+ cardBorder: "var(--neutral-300, #B2B2B0)",
9
+ white: "var(--Grey-White, #FFFFFF)",
10
+ btnBorder: "var(--Grey-absent, #D9D9D9)",
11
+ dark: "var(--neutral-850, #272727)",
12
+ onDark: "var(--neutral-50, #F2F2F0)",
13
+ menuHover: "var(--neutral-100, #E6E6E6)"
14
+ }, T = "var(--font-sans, 'Averta', ui-sans-serif, system-ui, sans-serif)", We = (t) => ({
15
+ display: "-webkit-box",
16
+ WebkitLineClamp: t,
17
+ WebkitBoxOrient: "vertical",
18
+ overflow: "hidden"
19
+ }), Ee = (t) => /disabled|inactive|off|available/i.test(String(t || ""));
20
+ function re({ children: t, onClick: l }) {
21
+ return /* @__PURE__ */ e(
22
+ "button",
23
+ {
24
+ type: "button",
25
+ onClick: l,
26
+ style: {
27
+ display: "inline-flex",
28
+ alignItems: "center",
29
+ justifyContent: "center",
30
+ height: 28,
31
+ padding: "0 10px",
32
+ borderRadius: 10,
33
+ border: `1px solid ${u.btnBorder}`,
34
+ background: u.white,
35
+ color: u.ink,
36
+ fontFamily: T,
37
+ fontSize: 14,
38
+ fontWeight: 600,
39
+ cursor: "pointer",
40
+ whiteSpace: "nowrap"
41
+ },
42
+ children: t
43
+ }
44
+ );
45
+ }
46
+ function le({ children: t, onClick: l }) {
47
+ return /* @__PURE__ */ e(
48
+ "button",
49
+ {
50
+ type: "button",
51
+ onClick: l,
52
+ style: {
53
+ display: "inline-flex",
54
+ alignItems: "center",
55
+ justifyContent: "center",
56
+ height: 28,
57
+ padding: "0 16px",
58
+ borderRadius: 10,
59
+ border: "none",
60
+ background: u.dark,
61
+ color: u.onDark,
62
+ fontFamily: T,
63
+ fontSize: 14,
64
+ fontWeight: 500,
65
+ cursor: "pointer",
66
+ whiteSpace: "nowrap"
67
+ },
68
+ children: t
69
+ }
70
+ );
71
+ }
72
+ function He({ items: t, onClose: l }) {
73
+ const d = ue(null);
74
+ return P(() => {
75
+ const a = (c) => {
76
+ d.current && !d.current.contains(c.target) && (l == null || l());
77
+ }, s = (c) => {
78
+ c.key === "Escape" && (l == null || l());
79
+ };
80
+ return document.addEventListener("mousedown", a), document.addEventListener("keydown", s), () => {
81
+ document.removeEventListener("mousedown", a), document.removeEventListener("keydown", s);
82
+ };
83
+ }, [l]), /* @__PURE__ */ e(
84
+ "div",
85
+ {
86
+ ref: d,
87
+ role: "menu",
88
+ style: {
89
+ position: "absolute",
90
+ top: "calc(100% + 4px)",
91
+ right: 0,
92
+ zIndex: 50,
93
+ minWidth: 168,
94
+ display: "flex",
95
+ flexDirection: "column",
96
+ background: u.white,
97
+ border: `1px solid ${u.btnBorder}`,
98
+ borderRadius: 8,
99
+ boxShadow: "var(--shadow-popover, 0 12px 32px rgba(11,11,11,0.12))",
100
+ overflow: "hidden"
101
+ },
102
+ children: t.map((a, s) => /* @__PURE__ */ e(
103
+ "button",
104
+ {
105
+ type: "button",
106
+ role: "menuitem",
107
+ onClick: a.onClick,
108
+ style: {
109
+ display: "flex",
110
+ alignItems: "center",
111
+ width: "100%",
112
+ padding: "10px 12px",
113
+ border: "none",
114
+ borderTop: s === 0 ? "none" : "1px solid var(--color-divider, #E5E7EB)",
115
+ background: "transparent",
116
+ cursor: "pointer",
117
+ textAlign: "left",
118
+ fontFamily: T,
119
+ fontSize: 13,
120
+ color: u.ink,
121
+ lineHeight: 1.2,
122
+ whiteSpace: "nowrap"
123
+ },
124
+ onMouseEnter: (c) => {
125
+ c.currentTarget.style.background = u.menuHover;
126
+ },
127
+ onMouseLeave: (c) => {
128
+ c.currentTarget.style.background = "transparent";
129
+ },
130
+ children: a.label
131
+ },
132
+ a.label
133
+ ))
134
+ }
135
+ );
136
+ }
137
+ function oe({
138
+ policy: t = {},
139
+ variant: l = "active",
140
+ onTest: d,
141
+ onViewDetails: a,
142
+ onApply: s,
143
+ onToggleStatus: c,
144
+ onEdit: p
145
+ }) {
146
+ const f = l === "browse", g = t.status || (f ? "Disabled" : "Active"), y = Ee(g), z = y ? ve : ke, [F, w] = W(!1), m = [];
147
+ c && m.push({
148
+ label: y ? "Enable Policy" : "Disable Policy",
149
+ onClick: () => {
150
+ w(!1), c(t);
151
+ }
152
+ }), p && m.push({
153
+ label: "Edit definition",
154
+ onClick: () => {
155
+ w(!1), p(t);
156
+ }
157
+ });
158
+ const H = m.length > 0;
159
+ return /* @__PURE__ */ r(
160
+ "article",
161
+ {
162
+ style: {
163
+ display: "flex",
164
+ flexDirection: "column",
165
+ gap: 12,
166
+ alignItems: "flex-start",
167
+ minHeight: 82,
168
+ padding: 16,
169
+ borderRadius: 8,
170
+ border: `1px solid ${u.cardBorder}`,
171
+ background: u.white,
172
+ boxSizing: "border-box",
173
+ width: "100%",
174
+ fontFamily: T
175
+ },
176
+ children: [
177
+ /* @__PURE__ */ r("div", { style: { display: "flex", flexDirection: "column", gap: 8, width: "100%" }, children: [
178
+ /* @__PURE__ */ r("div", { style: { display: "flex", gap: 8, alignItems: "center", width: "100%" }, children: [
179
+ /* @__PURE__ */ e(
180
+ "p",
181
+ {
182
+ style: {
183
+ flex: 1,
184
+ minWidth: 0,
185
+ margin: 0,
186
+ fontSize: 14,
187
+ fontWeight: 600,
188
+ color: u.ink,
189
+ lineHeight: "normal"
190
+ },
191
+ children: t.name || "Untitled policy"
192
+ }
193
+ ),
194
+ H && /* @__PURE__ */ r("div", { style: { position: "relative", display: "inline-flex", flexShrink: 0 }, children: [
195
+ /* @__PURE__ */ e(
196
+ "button",
197
+ {
198
+ type: "button",
199
+ "aria-label": "More actions",
200
+ "aria-haspopup": "menu",
201
+ "aria-expanded": F,
202
+ onClick: () => w((v) => !v),
203
+ style: {
204
+ display: "inline-flex",
205
+ alignItems: "center",
206
+ justifyContent: "center",
207
+ width: 16,
208
+ height: 16,
209
+ padding: 0,
210
+ border: "none",
211
+ background: "transparent",
212
+ color: u.ink,
213
+ cursor: "pointer"
214
+ },
215
+ children: /* @__PURE__ */ e(xe, { size: 16, strokeWidth: 2 })
216
+ }
217
+ ),
218
+ F && /* @__PURE__ */ e(He, { items: m, onClose: () => w(!1) })
219
+ ] })
220
+ ] }),
221
+ /* @__PURE__ */ r("div", { style: { display: "flex", flexDirection: "column", gap: 5, width: "100%" }, children: [
222
+ !f && /* @__PURE__ */ e(
223
+ "p",
224
+ {
225
+ style: {
226
+ margin: 0,
227
+ fontSize: 13,
228
+ color: u.ink,
229
+ lineHeight: "normal",
230
+ overflow: "hidden",
231
+ textOverflow: "ellipsis",
232
+ whiteSpace: "nowrap",
233
+ width: "100%"
234
+ },
235
+ children: t.paradigms || "All paradigms"
236
+ }
237
+ ),
238
+ /* @__PURE__ */ e(
239
+ "p",
240
+ {
241
+ style: {
242
+ margin: 0,
243
+ fontSize: 13,
244
+ color: u.muted,
245
+ lineHeight: "normal",
246
+ minHeight: 32,
247
+ width: "100%",
248
+ ...We(2)
249
+ },
250
+ children: t.description || ""
251
+ }
252
+ )
253
+ ] })
254
+ ] }),
255
+ /* @__PURE__ */ e("div", { style: { display: "flex", flexDirection: "column", width: "100%" }, children: f ? /* @__PURE__ */ e(N, { label: "Policy Count", value: t.policyCount ?? "—" }) : /* @__PURE__ */ r(E, { children: [
256
+ /* @__PURE__ */ e(N, { label: "Updated", value: t.updatedLabel || "—" }),
257
+ /* @__PURE__ */ e(N, { label: "Updated By", value: t.updatedBy || "—" })
258
+ ] }) }),
259
+ /* @__PURE__ */ r(
260
+ "div",
261
+ {
262
+ style: {
263
+ display: "flex",
264
+ alignItems: "center",
265
+ justifyContent: "space-between",
266
+ gap: 12,
267
+ width: "100%"
268
+ },
269
+ children: [
270
+ /* @__PURE__ */ r(
271
+ "span",
272
+ {
273
+ style: {
274
+ display: "inline-flex",
275
+ alignItems: "center",
276
+ gap: 4,
277
+ fontSize: 12,
278
+ color: u.ink,
279
+ lineHeight: "16px"
280
+ },
281
+ children: [
282
+ /* @__PURE__ */ e(z, { size: 20, strokeWidth: 1.5, style: { color: u.ink } }),
283
+ g
284
+ ]
285
+ }
286
+ ),
287
+ /* @__PURE__ */ e("div", { style: { display: "flex", alignItems: "center", gap: 12 }, children: f ? /* @__PURE__ */ r(E, { children: [
288
+ a && /* @__PURE__ */ e(re, { onClick: () => a(t), children: "View Details" }),
289
+ s && /* @__PURE__ */ e(le, { onClick: () => s(t), children: "Apply" })
290
+ ] }) : /* @__PURE__ */ r(E, { children: [
291
+ d && /* @__PURE__ */ e(re, { onClick: () => d(t), children: "Test" }),
292
+ a && /* @__PURE__ */ e(le, { onClick: () => a(t), children: "View Details" })
293
+ ] }) })
294
+ ]
295
+ }
296
+ )
297
+ ]
298
+ }
299
+ );
300
+ }
301
+ function N({ label: t, value: l }) {
302
+ return /* @__PURE__ */ r(
303
+ "div",
304
+ {
305
+ style: {
306
+ display: "flex",
307
+ flexWrap: "wrap",
308
+ alignItems: "center",
309
+ gap: 24,
310
+ padding: "8px 8px 12px 0",
311
+ fontSize: 13,
312
+ lineHeight: 1.2
313
+ },
314
+ children: [
315
+ /* @__PURE__ */ e("span", { style: { width: 80, color: u.ink }, children: t }),
316
+ /* @__PURE__ */ e("span", { style: { color: u.muted }, children: l })
317
+ ]
318
+ }
319
+ );
320
+ }
321
+ const I = {
322
+ ink: "var(--Grey-Strong, #2E3236)",
323
+ border: "var(--Grey-absent, #D9D9D9)",
324
+ white: "var(--Grey-White, #FFFFFF)"
325
+ }, ae = "var(--font-sans, 'Averta', ui-sans-serif, system-ui, sans-serif)";
326
+ function Ce({ options: t = [], value: l = "all", onChange: d, onClose: a }) {
327
+ const s = ue(null);
328
+ P(() => {
329
+ const p = (g) => {
330
+ s.current && !s.current.contains(g.target) && (a == null || a());
331
+ }, f = (g) => {
332
+ g.key === "Escape" && (a == null || a());
333
+ };
334
+ return document.addEventListener("mousedown", p), document.addEventListener("keydown", f), () => {
335
+ document.removeEventListener("mousedown", p), document.removeEventListener("keydown", f);
336
+ };
337
+ }, [a]);
338
+ const c = [{ id: "all", label: "All" }, ...t];
339
+ return /* @__PURE__ */ r(
340
+ "div",
341
+ {
342
+ ref: s,
343
+ role: "listbox",
344
+ style: {
345
+ position: "absolute",
346
+ top: "calc(100% + 6px)",
347
+ left: 0,
348
+ zIndex: 50,
349
+ minWidth: 200,
350
+ display: "flex",
351
+ flexDirection: "column",
352
+ alignItems: "stretch",
353
+ background: I.white,
354
+ border: `1px solid ${I.border}`,
355
+ borderRadius: 4,
356
+ boxShadow: "var(--shadow-dropdown, -2px 2px 1px rgba(0,0,0,0.25))",
357
+ fontFamily: ae,
358
+ overflow: "hidden"
359
+ },
360
+ children: [
361
+ /* @__PURE__ */ e("div", { style: { padding: 12 }, children: /* @__PURE__ */ e("p", { style: { margin: 0, fontSize: 13, fontWeight: 700, color: I.ink, lineHeight: 1.2 }, children: "Filter by" }) }),
362
+ c.map((p) => {
363
+ const f = p.id === l;
364
+ return /* @__PURE__ */ r(
365
+ "button",
366
+ {
367
+ type: "button",
368
+ role: "option",
369
+ "aria-selected": f,
370
+ onClick: () => d == null ? void 0 : d(p.id),
371
+ style: {
372
+ display: "flex",
373
+ alignItems: "center",
374
+ gap: 8,
375
+ width: "100%",
376
+ // Selected row shows the check at pl-12; unselected rows indent to
377
+ // pl-40 (12 + 20 check + 8 gap) so their labels line up.
378
+ padding: f ? "12px" : "12px 12px 12px 40px",
379
+ borderTop: `1px solid ${I.border}`,
380
+ background: "transparent",
381
+ cursor: "pointer",
382
+ textAlign: "left",
383
+ fontFamily: ae,
384
+ fontSize: 13,
385
+ color: I.ink,
386
+ lineHeight: 1.2
387
+ },
388
+ children: [
389
+ f && /* @__PURE__ */ e(we, { size: 20, strokeWidth: 2, style: { color: I.ink, flexShrink: 0 } }),
390
+ p.label
391
+ ]
392
+ },
393
+ p.id
394
+ );
395
+ })
396
+ ]
397
+ }
398
+ );
399
+ }
400
+ const o = {
401
+ ink: "var(--Grey-Strong, #2E3236)",
402
+ muted: "var(--Grey-Muted, #808183)",
403
+ cardBorder: "var(--neutral-300, #B2B2B0)",
404
+ white: "var(--Grey-White, #FFFFFF)",
405
+ btnBorder: "var(--Grey-absent, #D9D9D9)",
406
+ editBorder: "var(--neutral-250, #BFBFBF)",
407
+ editText: "var(--neutral-800, #323232)",
408
+ dark: "var(--neutral-850, #272727)",
409
+ onDark: "var(--neutral-50, #F2F2F0)",
410
+ iconBg: "var(--surface-hover, #F3F7F7)",
411
+ line: "var(--color-divider, #E5E7EB)"
412
+ }, j = "var(--font-sans, 'Averta', ui-sans-serif, system-ui, sans-serif)", M = () => /* @__PURE__ */ e("div", { style: { width: "100%", height: 1, background: o.line, flexShrink: 0 } });
413
+ function de({ label: t, value: l }) {
414
+ return /* @__PURE__ */ r(
415
+ "div",
416
+ {
417
+ style: {
418
+ display: "flex",
419
+ flexWrap: "wrap",
420
+ alignItems: "center",
421
+ gap: 24,
422
+ padding: "8px 8px 12px 0",
423
+ fontSize: 13,
424
+ lineHeight: 1.2
425
+ },
426
+ children: [
427
+ /* @__PURE__ */ e("span", { style: { width: 80, color: o.ink }, children: t }),
428
+ /* @__PURE__ */ e("span", { style: { color: o.muted }, children: l })
429
+ ]
430
+ }
431
+ );
432
+ }
433
+ function $e({
434
+ open: t,
435
+ onClose: l,
436
+ mode: d = "browse",
437
+ title: a,
438
+ paradigms: s,
439
+ description: c,
440
+ definition: p,
441
+ updatedLabel: f,
442
+ updatedBy: g,
443
+ onEdit: y,
444
+ items: z = [],
445
+ primaryLabel: F,
446
+ onPrimary: w,
447
+ primaryDisabled: m = !1,
448
+ secondaryLabel: H = "Cancel",
449
+ topOffset: v
450
+ }) {
451
+ const D = Ie("(max-width: 640px)"), k = v != null, C = typeof v == "number" ? `${v}px` : v, $ = d === "active";
452
+ return P(() => {
453
+ if (!t)
454
+ return;
455
+ const b = (i) => {
456
+ i.key === "Escape" && (l == null || l());
457
+ };
458
+ return document.addEventListener("keydown", b), () => document.removeEventListener("keydown", b);
459
+ }, [t, l]), t ? /* @__PURE__ */ r(E, { children: [
460
+ /* @__PURE__ */ e(
461
+ "div",
462
+ {
463
+ onClick: l,
464
+ style: { position: "fixed", inset: 0, zIndex: 1200, background: "rgba(0,0,0,0.20)" }
465
+ }
466
+ ),
467
+ /* @__PURE__ */ r(
468
+ "div",
469
+ {
470
+ style: {
471
+ position: "fixed",
472
+ top: D ? 0 : k ? C : 0,
473
+ right: 0,
474
+ zIndex: 1201,
475
+ display: "flex",
476
+ flexDirection: "column",
477
+ gap: 16,
478
+ width: D ? "100vw" : 490,
479
+ maxWidth: "100vw",
480
+ height: D ? "100dvh" : k ? `calc(100vh - ${C})` : "100vh",
481
+ padding: 20,
482
+ boxSizing: "border-box",
483
+ background: o.white,
484
+ borderRadius: D ? 0 : "12px 0 0 12px",
485
+ boxShadow: "-8px 0 40px rgba(0,0,0,0.18)",
486
+ fontFamily: j
487
+ },
488
+ children: [
489
+ /* @__PURE__ */ r("div", { style: { display: "flex", alignItems: "center", gap: 8, width: "100%", flexShrink: 0 }, children: [
490
+ /* @__PURE__ */ r("div", { style: { display: "flex", flex: 1, minWidth: 0, gap: 8, alignItems: "center" }, children: [
491
+ /* @__PURE__ */ e(
492
+ "span",
493
+ {
494
+ style: {
495
+ display: "inline-flex",
496
+ alignItems: "center",
497
+ justifyContent: "center",
498
+ width: 34,
499
+ height: 34,
500
+ borderRadius: 9999,
501
+ background: o.iconBg,
502
+ flexShrink: 0
503
+ },
504
+ children: /* @__PURE__ */ e(fe, { size: 20, strokeWidth: 1.75, style: { color: o.ink } })
505
+ }
506
+ ),
507
+ /* @__PURE__ */ e(
508
+ "p",
509
+ {
510
+ style: {
511
+ margin: 0,
512
+ fontSize: 16,
513
+ fontWeight: 550,
514
+ color: o.ink,
515
+ lineHeight: 1.2,
516
+ overflow: "hidden",
517
+ textOverflow: "ellipsis",
518
+ whiteSpace: "nowrap"
519
+ },
520
+ children: a
521
+ }
522
+ )
523
+ ] }),
524
+ /* @__PURE__ */ e(
525
+ "button",
526
+ {
527
+ type: "button",
528
+ "aria-label": "Close",
529
+ onClick: l,
530
+ style: {
531
+ display: "inline-flex",
532
+ alignItems: "center",
533
+ justifyContent: "center",
534
+ width: 20,
535
+ height: 20,
536
+ padding: 0,
537
+ border: "none",
538
+ background: "transparent",
539
+ color: o.ink,
540
+ cursor: "pointer",
541
+ flexShrink: 0
542
+ },
543
+ children: /* @__PURE__ */ e(Fe, { size: 20, strokeWidth: 2 })
544
+ }
545
+ )
546
+ ] }),
547
+ /* @__PURE__ */ e(M, {}),
548
+ /* @__PURE__ */ e(
549
+ "div",
550
+ {
551
+ className: "custom-thin-scrollbar",
552
+ style: {
553
+ flex: 1,
554
+ minHeight: 0,
555
+ width: "100%",
556
+ overflowY: "auto",
557
+ display: "flex",
558
+ flexDirection: "column",
559
+ gap: 16
560
+ },
561
+ children: $ ? /* @__PURE__ */ r(E, { children: [
562
+ /* @__PURE__ */ e("p", { style: { margin: 0, fontSize: 14, fontWeight: 600, color: o.ink, lineHeight: "normal" }, children: s || "All Paradigms" }),
563
+ c && /* @__PURE__ */ e("p", { style: { margin: 0, fontSize: 13, color: o.muted, lineHeight: "normal" }, children: c }),
564
+ /* @__PURE__ */ e(M, {}),
565
+ /* @__PURE__ */ r(
566
+ "div",
567
+ {
568
+ style: {
569
+ display: "flex",
570
+ alignItems: "center",
571
+ justifyContent: "space-between",
572
+ gap: 24,
573
+ width: "100%"
574
+ },
575
+ children: [
576
+ /* @__PURE__ */ e("span", { style: { fontSize: 13, color: o.ink, lineHeight: 1.5 }, children: "Definition" }),
577
+ y && /* @__PURE__ */ r(
578
+ "button",
579
+ {
580
+ type: "button",
581
+ onClick: y,
582
+ style: {
583
+ display: "inline-flex",
584
+ alignItems: "center",
585
+ justifyContent: "center",
586
+ gap: 8,
587
+ height: 28,
588
+ padding: "0 10px",
589
+ borderRadius: 10,
590
+ border: `1px solid ${o.editBorder}`,
591
+ background: o.white,
592
+ color: o.editText,
593
+ fontFamily: j,
594
+ fontSize: 14,
595
+ cursor: "pointer"
596
+ },
597
+ children: [
598
+ /* @__PURE__ */ e(Se, { size: 16, strokeWidth: 1.75, style: { color: o.editText } }),
599
+ "Edit"
600
+ ]
601
+ }
602
+ )
603
+ ]
604
+ }
605
+ ),
606
+ p && /* @__PURE__ */ e(
607
+ "p",
608
+ {
609
+ style: {
610
+ margin: 0,
611
+ fontSize: 13,
612
+ color: o.muted,
613
+ lineHeight: "normal",
614
+ whiteSpace: "pre-wrap"
615
+ },
616
+ children: p
617
+ }
618
+ ),
619
+ /* @__PURE__ */ r("div", { style: { display: "flex", flexDirection: "column", width: "100%" }, children: [
620
+ /* @__PURE__ */ e(de, { label: "Updated", value: f || "—" }),
621
+ /* @__PURE__ */ e(de, { label: "Updated By", value: g || "—" })
622
+ ] })
623
+ ] }) : /* @__PURE__ */ r(E, { children: [
624
+ c && /* @__PURE__ */ e("p", { style: { margin: 0, fontSize: 13, color: o.muted, lineHeight: "normal" }, children: c }),
625
+ /* @__PURE__ */ e(M, {}),
626
+ z.length === 0 && /* @__PURE__ */ e("p", { style: { margin: 0, fontSize: 13, color: o.muted }, children: "No details available." }),
627
+ z.map((b, i) => /* @__PURE__ */ e(
628
+ "div",
629
+ {
630
+ style: {
631
+ display: "flex",
632
+ alignItems: "center",
633
+ padding: 16,
634
+ borderRadius: 8,
635
+ border: `1px solid ${o.cardBorder}`,
636
+ background: o.white,
637
+ width: "100%",
638
+ boxSizing: "border-box"
639
+ },
640
+ children: /* @__PURE__ */ r("div", { style: { display: "flex", flexDirection: "column", gap: 8, width: "100%" }, children: [
641
+ /* @__PURE__ */ e("p", { style: { margin: 0, fontSize: 14, fontWeight: 600, color: o.ink, lineHeight: "normal" }, children: b.title }),
642
+ b.description && /* @__PURE__ */ e("p", { style: { margin: 0, fontSize: 13, color: o.muted, lineHeight: "normal" }, children: b.description })
643
+ ] })
644
+ },
645
+ b.id || `${b.title}-${i}`
646
+ ))
647
+ ] })
648
+ }
649
+ ),
650
+ /* @__PURE__ */ e(M, {}),
651
+ /* @__PURE__ */ r(
652
+ "div",
653
+ {
654
+ style: {
655
+ display: "flex",
656
+ alignItems: "center",
657
+ justifyContent: "flex-end",
658
+ gap: 12,
659
+ width: "100%",
660
+ flexShrink: 0
661
+ },
662
+ children: [
663
+ /* @__PURE__ */ e(
664
+ "button",
665
+ {
666
+ type: "button",
667
+ onClick: l,
668
+ style: {
669
+ display: "inline-flex",
670
+ alignItems: "center",
671
+ justifyContent: "center",
672
+ height: 32,
673
+ padding: "0 16px",
674
+ borderRadius: 10,
675
+ border: `1px solid ${o.btnBorder}`,
676
+ background: o.white,
677
+ color: o.ink,
678
+ fontFamily: j,
679
+ fontSize: 14,
680
+ fontWeight: 600,
681
+ cursor: "pointer"
682
+ },
683
+ children: H
684
+ }
685
+ ),
686
+ F && /* @__PURE__ */ e(
687
+ "button",
688
+ {
689
+ type: "button",
690
+ onClick: w,
691
+ disabled: m,
692
+ style: {
693
+ display: "inline-flex",
694
+ alignItems: "center",
695
+ justifyContent: "center",
696
+ height: 32,
697
+ padding: "0 16px",
698
+ borderRadius: 10,
699
+ border: "none",
700
+ background: o.dark,
701
+ color: o.onDark,
702
+ fontFamily: j,
703
+ fontSize: 14,
704
+ fontWeight: 550,
705
+ cursor: m ? "default" : "pointer",
706
+ opacity: m ? 0.5 : 1
707
+ },
708
+ children: F
709
+ }
710
+ )
711
+ ]
712
+ }
713
+ )
714
+ ]
715
+ }
716
+ )
717
+ ] }) : null;
718
+ }
719
+ const h = {
720
+ ink: "var(--Grey-Strong, #2E3236)",
721
+ muted: "var(--Grey-Muted, #808183)",
722
+ white: "var(--Grey-White, #FFFFFF)",
723
+ border: "var(--Grey-absent, #D9D9D9)",
724
+ tabBorder: "var(--color-divider, #F2F1EF)",
725
+ tabActive: "var(--neutral-900, #0B0B0B)",
726
+ pillActive: "var(--neutral-900, #0B0B0B)",
727
+ pillIdle: "var(--rail-surface-2, #E3E1D7)",
728
+ searchTrack: "var(--neutral-150, #D8D8D8)",
729
+ searchText: "var(--neutral-400, #989898)",
730
+ accent: "var(--rail-orange, #C98A5A)",
731
+ dark: "var(--neutral-850, #272727)",
732
+ onDark: "var(--neutral-50, #F2F2F0)"
733
+ }, S = "var(--font-sans, 'Averta', ui-sans-serif, system-ui, sans-serif)", Re = (t) => String(t).padStart(2, "0"), se = (t, l) => l ? `${(t == null ? void 0 : t.name) || ""} ${(t == null ? void 0 : t.description) || ""} ${(t == null ? void 0 : t.paradigms) || ""}`.toLowerCase().includes(l) : !0;
734
+ function Te({
735
+ activePolicies: t = [],
736
+ activeSectionLabel: l = "Custom Policies",
737
+ browseCategories: d = [],
738
+ defaultTab: a = "active",
739
+ isAdmin: s = !1,
740
+ onTest: c,
741
+ onApplyPolicy: p,
742
+ onAddPolicy: f,
743
+ onEditPolicy: g,
744
+ onToggleStatus: y,
745
+ topOffset: z,
746
+ emptyActiveMessage: F = "No active policies yet.",
747
+ emptyBrowseMessage: w = "No policies available to browse."
748
+ }) {
749
+ var X, Y, q, J, Z, _, ee, te, ie, ne;
750
+ const [m, H] = W(a === "browse" ? "browse" : "active"), [v, D] = W(""), [k, C] = W("all"), [$, b] = W(!1), [i, A] = W(null), B = v.trim().toLowerCase(), ge = G(
751
+ () => d.reduce((n, x) => {
752
+ var R;
753
+ return n + (((R = x.policies) == null ? void 0 : R.length) || 0);
754
+ }, 0),
755
+ [d]
756
+ ), U = G(
757
+ () => d.map((n) => ({ id: n.id, label: n.name })),
758
+ [d]
759
+ ), ye = k === "all" ? "All" : ((X = U.find((n) => n.id === k)) == null ? void 0 : X.label) || "All", K = G(
760
+ () => t.filter((n) => se(n, B)),
761
+ [t, B]
762
+ ), Q = G(
763
+ () => d.filter((n) => k === "all" || n.id === k).map((n) => ({
764
+ ...n,
765
+ policies: (n.policies || []).filter((x) => se(x, B))
766
+ })).filter((n) => n.policies.length > 0),
767
+ [d, B, k]
768
+ ), me = (n) => A({ policy: n, mode: "active" }), be = (n) => A({ policy: n, mode: "browse" }), O = () => A(null), V = ({ id: n, label: x, count: R }) => {
769
+ const L = m === n;
770
+ return /* @__PURE__ */ r(
771
+ "button",
772
+ {
773
+ type: "button",
774
+ onClick: () => H(n),
775
+ style: {
776
+ display: "inline-flex",
777
+ alignItems: "center",
778
+ justifyContent: "center",
779
+ gap: 4,
780
+ padding: "4px 4px 12px",
781
+ border: "none",
782
+ borderBottom: L ? `2px solid ${h.tabActive}` : "2px solid transparent",
783
+ borderRadius: "4px 4px 0 0",
784
+ background: "transparent",
785
+ cursor: "pointer",
786
+ fontFamily: S
787
+ },
788
+ children: [
789
+ /* @__PURE__ */ e("span", { style: { fontSize: 14, color: L ? "#1E1E1E" : "#313131", lineHeight: 1.2 }, children: x }),
790
+ /* @__PURE__ */ e(
791
+ "span",
792
+ {
793
+ style: {
794
+ display: "inline-flex",
795
+ alignItems: "center",
796
+ justifyContent: "center",
797
+ minWidth: 18,
798
+ height: 18,
799
+ padding: "2px 6px",
800
+ borderRadius: 9,
801
+ background: L ? h.pillActive : h.pillIdle,
802
+ color: L ? "#FFFFFF" : "#313131",
803
+ fontSize: 12,
804
+ lineHeight: 1.2
805
+ },
806
+ children: R
807
+ }
808
+ )
809
+ ]
810
+ }
811
+ );
812
+ };
813
+ return /* @__PURE__ */ r("div", { style: { display: "flex", flexDirection: "column", gap: 16, fontFamily: S }, children: [
814
+ /* @__PURE__ */ r("div", { style: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: 12, width: "100%" }, children: [
815
+ /* @__PURE__ */ e("h1", { style: { flex: 1, minWidth: 160, margin: 0, fontSize: 24, fontWeight: 400, color: h.ink }, children: "Policies" }),
816
+ /* @__PURE__ */ r("div", { style: { display: "flex", alignItems: "center", gap: 16 }, children: [
817
+ m === "active" ? f && /* @__PURE__ */ r(
818
+ "button",
819
+ {
820
+ type: "button",
821
+ onClick: () => f(),
822
+ style: {
823
+ display: "inline-flex",
824
+ alignItems: "center",
825
+ gap: 8,
826
+ height: 32,
827
+ padding: "0 16px 0 12px",
828
+ borderRadius: 10,
829
+ border: "none",
830
+ background: h.dark,
831
+ color: h.onDark,
832
+ fontFamily: S,
833
+ fontSize: 14,
834
+ fontWeight: 500,
835
+ cursor: "pointer"
836
+ },
837
+ children: [
838
+ /* @__PURE__ */ e(ze, { size: 20, strokeWidth: 2, style: { color: h.onDark } }),
839
+ "Policy"
840
+ ]
841
+ }
842
+ ) : /* @__PURE__ */ r("div", { style: { position: "relative", display: "inline-flex" }, children: [
843
+ /* @__PURE__ */ r(
844
+ "button",
845
+ {
846
+ type: "button",
847
+ onClick: () => b((n) => !n),
848
+ "aria-haspopup": "listbox",
849
+ "aria-expanded": $,
850
+ style: {
851
+ display: "inline-flex",
852
+ alignItems: "center",
853
+ gap: 10,
854
+ height: 32,
855
+ padding: "0 16px",
856
+ borderRadius: 10,
857
+ border: `1px solid ${h.border}`,
858
+ background: h.white,
859
+ color: h.ink,
860
+ fontFamily: S,
861
+ fontSize: 14,
862
+ fontWeight: 600,
863
+ cursor: "pointer"
864
+ },
865
+ children: [
866
+ /* @__PURE__ */ e(De, { size: 20, strokeWidth: 1.75, style: { color: h.ink } }),
867
+ ye
868
+ ]
869
+ }
870
+ ),
871
+ $ && /* @__PURE__ */ e(
872
+ Ce,
873
+ {
874
+ options: U,
875
+ value: k,
876
+ onChange: (n) => {
877
+ C(n), b(!1);
878
+ },
879
+ onClose: () => b(!1)
880
+ }
881
+ )
882
+ ] }),
883
+ /* @__PURE__ */ e(
884
+ "div",
885
+ {
886
+ style: {
887
+ display: "flex",
888
+ alignItems: "center",
889
+ height: 32,
890
+ width: 260,
891
+ padding: 2,
892
+ borderRadius: 11,
893
+ background: h.searchTrack,
894
+ boxSizing: "border-box"
895
+ },
896
+ children: /* @__PURE__ */ r(
897
+ "div",
898
+ {
899
+ style: {
900
+ display: "flex",
901
+ flex: 1,
902
+ minWidth: 0,
903
+ alignItems: "center",
904
+ gap: 8,
905
+ height: 28,
906
+ padding: "0 8px",
907
+ borderRadius: 10,
908
+ background: h.white
909
+ },
910
+ children: [
911
+ /* @__PURE__ */ e(Be, { size: 18, strokeWidth: 2, style: { color: h.searchText, flexShrink: 0 } }),
912
+ /* @__PURE__ */ e(
913
+ "input",
914
+ {
915
+ value: v,
916
+ onChange: (n) => D(n.target.value),
917
+ placeholder: "Search",
918
+ style: {
919
+ flex: 1,
920
+ minWidth: 0,
921
+ border: "none",
922
+ outline: "none",
923
+ background: "transparent",
924
+ fontFamily: S,
925
+ fontSize: 14,
926
+ color: h.ink
927
+ }
928
+ }
929
+ )
930
+ ]
931
+ }
932
+ )
933
+ }
934
+ )
935
+ ] })
936
+ ] }),
937
+ /* @__PURE__ */ r(
938
+ "div",
939
+ {
940
+ style: {
941
+ display: "flex",
942
+ alignItems: "center",
943
+ gap: 12,
944
+ width: "100%",
945
+ borderBottom: `1px solid ${h.tabBorder}`
946
+ },
947
+ children: [
948
+ /* @__PURE__ */ e(V, { id: "active", label: "Active Policies", count: Re(t.length) }),
949
+ /* @__PURE__ */ e(V, { id: "browse", label: "Browse Policies", count: ge })
950
+ ]
951
+ }
952
+ ),
953
+ m === "active" ? /* @__PURE__ */ e(ce, { icon: !0, label: l, children: K.length === 0 ? /* @__PURE__ */ e(he, { text: B ? "No policies match your search." : F }) : /* @__PURE__ */ e(pe, { children: K.map((n) => /* @__PURE__ */ e(
954
+ oe,
955
+ {
956
+ policy: n,
957
+ variant: "active",
958
+ onTest: c ? () => c(n) : void 0,
959
+ onViewDetails: () => me(n),
960
+ onToggleStatus: s && y ? y : void 0,
961
+ onEdit: s && g ? g : void 0
962
+ },
963
+ n.id
964
+ )) }) }) : Q.length === 0 ? /* @__PURE__ */ e(he, { text: B || k !== "all" ? "No policies match your search." : w }) : /* @__PURE__ */ e("div", { style: { display: "flex", flexDirection: "column", gap: 24 }, children: Q.map((n) => /* @__PURE__ */ e(ce, { icon: !0, label: n.name, children: /* @__PURE__ */ e(pe, { children: n.policies.map((x) => /* @__PURE__ */ e(
965
+ oe,
966
+ {
967
+ policy: x,
968
+ variant: "browse",
969
+ onViewDetails: () => be(x),
970
+ onApply: s && !x.alreadyApplied ? () => p == null ? void 0 : p(x) : void 0
971
+ },
972
+ x.id
973
+ )) }) }, n.id)) }),
974
+ /* @__PURE__ */ e(
975
+ $e,
976
+ {
977
+ open: !!i,
978
+ onClose: O,
979
+ mode: i == null ? void 0 : i.mode,
980
+ title: (Y = i == null ? void 0 : i.policy) == null ? void 0 : Y.name,
981
+ paradigms: (q = i == null ? void 0 : i.policy) == null ? void 0 : q.paradigms,
982
+ description: (J = i == null ? void 0 : i.policy) == null ? void 0 : J.description,
983
+ definition: (Z = i == null ? void 0 : i.policy) == null ? void 0 : Z.definition,
984
+ updatedLabel: (_ = i == null ? void 0 : i.policy) == null ? void 0 : _.updatedLabel,
985
+ updatedBy: (ee = i == null ? void 0 : i.policy) == null ? void 0 : ee.updatedBy,
986
+ items: ((te = i == null ? void 0 : i.policy) == null ? void 0 : te.items) || [],
987
+ topOffset: z,
988
+ onEdit: (i == null ? void 0 : i.mode) === "active" && s && g ? () => {
989
+ const n = i.policy;
990
+ O(), g(n);
991
+ } : void 0,
992
+ primaryLabel: (i == null ? void 0 : i.mode) === "browse" ? s && !((ie = i == null ? void 0 : i.policy) != null && ie.alreadyApplied) ? "Apply Policy" : void 0 : s && y ? ((ne = i == null ? void 0 : i.policy) == null ? void 0 : ne.status) === "Active" ? "Disable Policy" : "Enable Policy" : void 0,
993
+ onPrimary: () => {
994
+ const n = i == null ? void 0 : i.policy;
995
+ n && (O(), i.mode === "browse" ? p == null || p(n) : y == null || y(n));
996
+ }
997
+ }
998
+ )
999
+ ] });
1000
+ }
1001
+ function ce({ label: t, icon: l, children: d }) {
1002
+ return /* @__PURE__ */ r("section", { style: { display: "flex", flexDirection: "column", gap: 16, width: "100%" }, children: [
1003
+ /* @__PURE__ */ r("div", { style: { display: "flex", alignItems: "center", gap: 8, height: 40 }, children: [
1004
+ l && /* @__PURE__ */ e(fe, { size: 24, strokeWidth: 1.75, style: { color: h.accent } }),
1005
+ /* @__PURE__ */ e(
1006
+ "span",
1007
+ {
1008
+ style: {
1009
+ fontFamily: S,
1010
+ fontSize: 16,
1011
+ fontWeight: 600,
1012
+ color: h.ink,
1013
+ textTransform: "uppercase",
1014
+ lineHeight: 1.2
1015
+ },
1016
+ children: t
1017
+ }
1018
+ )
1019
+ ] }),
1020
+ d
1021
+ ] });
1022
+ }
1023
+ function pe({ children: t }) {
1024
+ return /* @__PURE__ */ e(
1025
+ "div",
1026
+ {
1027
+ style: {
1028
+ display: "grid",
1029
+ gridTemplateColumns: "repeat(auto-fill, minmax(320px, 360px))",
1030
+ gap: 24,
1031
+ width: "100%"
1032
+ },
1033
+ children: t
1034
+ }
1035
+ );
1036
+ }
1037
+ function he({ text: t }) {
1038
+ return /* @__PURE__ */ e("p", { style: { margin: 0, fontSize: 14, color: h.muted, fontFamily: S }, children: t });
1039
+ }
1040
+ export {
1041
+ Ce as FilterDropdown,
1042
+ Te as PoliciesPage,
1043
+ oe as PolicyCard,
1044
+ $e as PolicyDetailsDrawer
1045
+ };
1046
+ //# sourceMappingURL=policies.es.js.map