@echothink-ui/domain-widgets 0.1.0

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.
package/dist/index.js ADDED
@@ -0,0 +1,3029 @@
1
+ // src/index.tsx
2
+ import * as React from "react";
3
+ import { DownloadIcon, PlusIcon, TableIcon } from "@echothink-ui/icons";
4
+ import {
5
+ Badge,
6
+ Button,
7
+ Checkbox,
8
+ LinkButton,
9
+ Select,
10
+ Surface,
11
+ StatusDot,
12
+ TextInput,
13
+ createSurfaceComponent,
14
+ statusLabel
15
+ } from "@echothink-ui/core";
16
+ import { Fragment as Fragment2, jsx, jsxs } from "react/jsx-runtime";
17
+ function textFromNode(node) {
18
+ if (typeof node === "string" || typeof node === "number") return String(node);
19
+ if (Array.isArray(node)) return node.map(textFromNode).join(" ");
20
+ return "";
21
+ }
22
+ function getContactInitials(label) {
23
+ const words = textFromNode(label).trim().split(/\s+/).filter(Boolean);
24
+ if (!words.length) return "CT";
25
+ return words.slice(0, 2).map((word) => word.charAt(0).toUpperCase()).join("");
26
+ }
27
+ function safeDomId(value) {
28
+ return value.replace(/[^A-Za-z0-9_-]+/g, "-");
29
+ }
30
+ function splitTicketPriority(label) {
31
+ if (typeof label !== "string" && typeof label !== "number") {
32
+ return { priority: void 0, label };
33
+ }
34
+ const text = String(label);
35
+ const match = text.match(/^\[(P[0-4])\]\s*(.+)$/i);
36
+ if (!match) return { priority: void 0, label };
37
+ return {
38
+ priority: match[1].toUpperCase(),
39
+ label: match[2]
40
+ };
41
+ }
42
+ function healthTone(status) {
43
+ if (status === "blocked" || status === "failed" || status === "stale") return "risk";
44
+ if (status === "warning" || status === "pending-approval" || status === "approval-required") {
45
+ return "watch";
46
+ }
47
+ if (status === "queued" || status === "not-started") return "new";
48
+ return "healthy";
49
+ }
50
+ function healthLabel(status) {
51
+ if (status === "blocked" || status === "failed" || status === "stale") return "Needs attention";
52
+ if (status === "warning" || status === "pending-approval" || status === "approval-required") {
53
+ return "Monitor closely";
54
+ }
55
+ if (status === "queued" || status === "not-started") return "New relationship";
56
+ return "Healthy";
57
+ }
58
+ function CRMContactActions({ actions }) {
59
+ if (!actions?.length) return null;
60
+ return /* @__PURE__ */ jsx("div", { className: "eth-domain-crm-contact-panel__contact-actions", children: actions.slice(0, 2).map(
61
+ (action) => action.href ? /* @__PURE__ */ jsx(
62
+ LinkButton,
63
+ {
64
+ href: action.disabled ? void 0 : action.href,
65
+ intent: action.intent ?? "ghost",
66
+ density: "compact",
67
+ "aria-disabled": action.disabled ? true : void 0,
68
+ tabIndex: action.disabled ? -1 : void 0,
69
+ children: action.label
70
+ },
71
+ action.id
72
+ ) : /* @__PURE__ */ jsx(
73
+ Button,
74
+ {
75
+ type: "button",
76
+ intent: action.intent ?? "ghost",
77
+ density: "compact",
78
+ disabled: action.disabled,
79
+ onClick: action.onSelect,
80
+ children: action.label
81
+ },
82
+ action.id
83
+ )
84
+ ) });
85
+ }
86
+ function SupportTicketActions({ actions }) {
87
+ if (!actions?.length) return null;
88
+ return /* @__PURE__ */ jsx("div", { className: "eth-domain-support-ticket-queue__actions", "aria-label": "Ticket actions", children: actions.slice(0, 2).map(
89
+ (action) => action.href ? /* @__PURE__ */ jsx(
90
+ LinkButton,
91
+ {
92
+ href: action.disabled ? void 0 : action.href,
93
+ intent: action.intent ?? "ghost",
94
+ density: "compact",
95
+ "aria-disabled": action.disabled ? true : void 0,
96
+ tabIndex: action.disabled ? -1 : void 0,
97
+ children: action.label
98
+ },
99
+ action.id
100
+ ) : /* @__PURE__ */ jsx(
101
+ Button,
102
+ {
103
+ type: "button",
104
+ intent: action.intent ?? "ghost",
105
+ density: "compact",
106
+ disabled: action.disabled,
107
+ onClick: action.onSelect,
108
+ children: action.label
109
+ },
110
+ action.id
111
+ )
112
+ ) });
113
+ }
114
+ function CRMContactPanel({
115
+ title = "Account relationship",
116
+ description,
117
+ status = "active",
118
+ metadata,
119
+ items,
120
+ contacts,
121
+ actions,
122
+ footer,
123
+ children,
124
+ className,
125
+ relationshipHealthLabel,
126
+ engagementLabel,
127
+ nextStep,
128
+ ...props
129
+ }) {
130
+ const contactItems = contacts ?? items ?? [];
131
+ const contactsHeadingId = React.useId();
132
+ const signalsHeadingId = React.useId();
133
+ const tone = healthTone(status);
134
+ const health = relationshipHealthLabel ?? healthLabel(status);
135
+ const engagement = engagementLabel ?? `${contactItems.length} contact${contactItems.length === 1 ? "" : "s"} mapped`;
136
+ const nextActivity = nextStep ?? "Review next activity";
137
+ return /* @__PURE__ */ jsxs(
138
+ Surface,
139
+ {
140
+ ...props,
141
+ "data-eth-component": "CRMContactPanel",
142
+ title,
143
+ description,
144
+ status,
145
+ metadata,
146
+ actions,
147
+ footer,
148
+ className: ["eth-domain-crm-contact-panel", className].filter(Boolean).join(" "),
149
+ children: [
150
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-crm-contact-panel__body", children: [
151
+ /* @__PURE__ */ jsxs(
152
+ "section",
153
+ {
154
+ className: "eth-domain-crm-contact-panel__contacts",
155
+ "aria-labelledby": contactsHeadingId,
156
+ children: [
157
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-crm-contact-panel__section-header", children: [
158
+ /* @__PURE__ */ jsxs("div", { children: [
159
+ /* @__PURE__ */ jsx("span", { children: "Relationship map" }),
160
+ /* @__PURE__ */ jsx("h3", { id: contactsHeadingId, children: "Key contacts" })
161
+ ] }),
162
+ /* @__PURE__ */ jsx("strong", { children: engagement })
163
+ ] }),
164
+ contactItems.length ? /* @__PURE__ */ jsx("div", { className: "eth-domain-crm-contact-panel__contact-list", role: "list", children: contactItems.map((item) => /* @__PURE__ */ jsxs(
165
+ "article",
166
+ {
167
+ className: "eth-domain-crm-contact-panel__contact",
168
+ role: "listitem",
169
+ children: [
170
+ /* @__PURE__ */ jsx("span", { className: "eth-domain-crm-contact-panel__avatar", "aria-hidden": "true", children: getContactInitials(item.label) }),
171
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-crm-contact-panel__contact-main", children: [
172
+ /* @__PURE__ */ jsx("strong", { children: item.href ? /* @__PURE__ */ jsx("a", { href: item.href, children: item.label }) : item.label }),
173
+ item.description ? /* @__PURE__ */ jsx("p", { children: item.description }) : null,
174
+ item.meta ? /* @__PURE__ */ jsx("span", { className: "eth-domain-crm-contact-panel__contact-meta", children: item.meta }) : null
175
+ ] }),
176
+ item.status || item.actions?.length ? /* @__PURE__ */ jsxs("div", { className: "eth-domain-crm-contact-panel__contact-aside", children: [
177
+ item.status ? /* @__PURE__ */ jsx(StatusDot, { status: item.status, label: statusLabel(item.status) }) : null,
178
+ /* @__PURE__ */ jsx(CRMContactActions, { actions: item.actions })
179
+ ] }) : null
180
+ ]
181
+ },
182
+ item.id
183
+ )) }) : /* @__PURE__ */ jsx("p", { className: "eth-domain-crm-contact-panel__empty", children: "No contacts linked." })
184
+ ]
185
+ }
186
+ ),
187
+ /* @__PURE__ */ jsxs("aside", { className: "eth-domain-crm-contact-panel__signals", "aria-labelledby": signalsHeadingId, children: [
188
+ /* @__PURE__ */ jsx("div", { className: "eth-domain-crm-contact-panel__section-header", children: /* @__PURE__ */ jsxs("div", { children: [
189
+ /* @__PURE__ */ jsx("span", { children: "Account signals" }),
190
+ /* @__PURE__ */ jsx("h3", { id: signalsHeadingId, children: "Relationship health" })
191
+ ] }) }),
192
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-crm-contact-panel__signal-list", children: [
193
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-crm-contact-panel__signal", "data-tone": tone, children: [
194
+ /* @__PURE__ */ jsx("span", { children: "Health" }),
195
+ /* @__PURE__ */ jsx("strong", { children: health })
196
+ ] }),
197
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-crm-contact-panel__signal", children: [
198
+ /* @__PURE__ */ jsx("span", { children: "Coverage" }),
199
+ /* @__PURE__ */ jsx("strong", { children: engagement })
200
+ ] }),
201
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-crm-contact-panel__signal", children: [
202
+ /* @__PURE__ */ jsx("span", { children: "Next step" }),
203
+ /* @__PURE__ */ jsx("strong", { children: nextActivity })
204
+ ] })
205
+ ] })
206
+ ] })
207
+ ] }),
208
+ children
209
+ ]
210
+ }
211
+ );
212
+ }
213
+ function SupportTicketQueue({
214
+ title = "Support queue",
215
+ description,
216
+ status,
217
+ metadata,
218
+ items,
219
+ tickets,
220
+ actions,
221
+ footer,
222
+ children,
223
+ className,
224
+ ...props
225
+ }) {
226
+ const ticketItems = tickets ?? items ?? [];
227
+ const queueId = React.useId().replace(/:/g, "");
228
+ const blockedCount = ticketItems.filter(
229
+ (item) => ["blocked", "failed", "approval-required"].includes(item.status ?? "")
230
+ ).length;
231
+ const runningCount = ticketItems.filter(
232
+ (item) => ["running", "in-progress"].includes(item.status ?? "")
233
+ ).length;
234
+ const nextSla = textFromNode(
235
+ ticketItems.find((item) => item.status === "blocked")?.description ?? ticketItems[0]?.description
236
+ ) || "No active SLA";
237
+ const summary = metadata ?? [
238
+ { label: "Open tickets", value: ticketItems.length.toLocaleString() },
239
+ { label: "Blocked", value: blockedCount.toLocaleString() },
240
+ { label: "In progress", value: runningCount.toLocaleString() },
241
+ { label: "Next SLA", value: nextSla }
242
+ ];
243
+ return /* @__PURE__ */ jsxs(
244
+ Surface,
245
+ {
246
+ ...props,
247
+ "data-eth-component": "SupportTicketQueue",
248
+ title,
249
+ description,
250
+ status,
251
+ metadata: summary,
252
+ actions,
253
+ footer,
254
+ className: ["eth-domain-support-ticket-queue", className].filter(Boolean).join(" "),
255
+ children: [
256
+ ticketItems.length ? /* @__PURE__ */ jsx(
257
+ "div",
258
+ {
259
+ className: "eth-domain-support-ticket-queue__list",
260
+ role: "list",
261
+ "aria-label": "Support tickets",
262
+ children: ticketItems.map((item) => {
263
+ const { priority, label } = splitTicketPriority(item.label);
264
+ const ticketId = `${queueId}-${safeDomId(item.id)}`;
265
+ const labelId = `${ticketId}-label`;
266
+ const slaId = item.description ? `${ticketId}-sla` : void 0;
267
+ return /* @__PURE__ */ jsxs(
268
+ "article",
269
+ {
270
+ className: "eth-domain-support-ticket-queue__row",
271
+ "data-status": item.status,
272
+ role: "listitem",
273
+ "aria-labelledby": labelId,
274
+ "aria-describedby": slaId,
275
+ children: [
276
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-support-ticket-queue__ticket", children: [
277
+ priority ? /* @__PURE__ */ jsx(
278
+ "span",
279
+ {
280
+ className: "eth-domain-support-ticket-queue__priority",
281
+ "data-priority": priority,
282
+ children: priority
283
+ }
284
+ ) : null,
285
+ /* @__PURE__ */ jsx("strong", { id: labelId, children: item.href ? /* @__PURE__ */ jsx("a", { href: item.href, children: label }) : label })
286
+ ] }),
287
+ item.description ? /* @__PURE__ */ jsxs(
288
+ "div",
289
+ {
290
+ className: [
291
+ "eth-domain-support-ticket-queue__field",
292
+ "eth-domain-support-ticket-queue__field--sla"
293
+ ].join(" "),
294
+ id: slaId,
295
+ children: [
296
+ /* @__PURE__ */ jsx("span", { children: "SLA" }),
297
+ /* @__PURE__ */ jsx("strong", { children: item.description })
298
+ ]
299
+ }
300
+ ) : null,
301
+ item.meta ? /* @__PURE__ */ jsxs(
302
+ "div",
303
+ {
304
+ className: [
305
+ "eth-domain-support-ticket-queue__field",
306
+ "eth-domain-support-ticket-queue__field--owner"
307
+ ].join(" "),
308
+ children: [
309
+ /* @__PURE__ */ jsx("span", { children: "Owner" }),
310
+ /* @__PURE__ */ jsx("strong", { children: item.meta })
311
+ ]
312
+ }
313
+ ) : null,
314
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-support-ticket-queue__status", children: [
315
+ item.status ? /* @__PURE__ */ jsx(StatusDot, { status: item.status, label: statusLabel(item.status) }) : null,
316
+ /* @__PURE__ */ jsx(SupportTicketActions, { actions: item.actions })
317
+ ] })
318
+ ]
319
+ },
320
+ item.id
321
+ );
322
+ })
323
+ }
324
+ ) : /* @__PURE__ */ jsx("p", { className: "eth-domain-support-ticket-queue__empty", children: "No active support tickets." }),
325
+ children
326
+ ]
327
+ }
328
+ );
329
+ }
330
+ var defaultApproverOptions = [
331
+ { value: "", label: "Select approver", disabled: true },
332
+ { value: "team-lead", label: "Team lead" },
333
+ { value: "finance-ops", label: "Finance operations" },
334
+ { value: "legal-review", label: "Legal review" },
335
+ { value: "security-office", label: "Security office" },
336
+ { value: "executive-sponsor", label: "Executive sponsor" }
337
+ ];
338
+ var defaultApprovalSteps = [
339
+ {
340
+ id: "manager-review",
341
+ label: "Manager review",
342
+ approver: "team-lead",
343
+ condition: "Spend is above requester limit",
344
+ required: true,
345
+ status: "completed"
346
+ },
347
+ {
348
+ id: "finance-check",
349
+ label: "Finance control check",
350
+ approver: "finance-ops",
351
+ condition: "Amount is greater than $10,000",
352
+ required: true,
353
+ status: "pending-approval"
354
+ },
355
+ {
356
+ id: "legal-signoff",
357
+ label: "Legal sign-off",
358
+ approver: "legal-review",
359
+ condition: "Vendor terms changed",
360
+ required: false,
361
+ status: "queued"
362
+ }
363
+ ];
364
+ var modeOptions = [
365
+ { value: "sequential", label: "Sequential route" },
366
+ { value: "parallel", label: "Parallel quorum" },
367
+ { value: "conditional", label: "Conditional branch" }
368
+ ];
369
+ var defaultProcessItems = [
370
+ {
371
+ id: "start",
372
+ label: "HRIS trigger",
373
+ description: "New employee record received from Workday.",
374
+ status: "completed",
375
+ kind: "start",
376
+ owner: "People ops",
377
+ lane: "Intake",
378
+ duration: "Instant",
379
+ x: 96,
380
+ y: 170
381
+ },
382
+ {
383
+ id: "profile",
384
+ label: "Collect profile",
385
+ description: "Manager confirms role, location, and start date.",
386
+ status: "completed",
387
+ kind: "task",
388
+ owner: "Hiring manager",
389
+ lane: "Intake",
390
+ duration: "4h SLA",
391
+ x: 278,
392
+ y: 170
393
+ },
394
+ {
395
+ id: "approval",
396
+ label: "Approval required?",
397
+ description: "Route privileged roles through security approval.",
398
+ status: "warning",
399
+ kind: "decision",
400
+ owner: "People systems",
401
+ lane: "Policy",
402
+ duration: "Conditional",
403
+ x: 460,
404
+ y: 170
405
+ },
406
+ {
407
+ id: "security",
408
+ label: "Security review",
409
+ description: "Validate device, access groups, and background check.",
410
+ status: "pending-approval",
411
+ kind: "task",
412
+ owner: "Security office",
413
+ lane: "Controls",
414
+ duration: "24h SLA",
415
+ x: 642,
416
+ y: 92
417
+ },
418
+ {
419
+ id: "provision",
420
+ label: "Provision access",
421
+ description: "Create accounts and assign application entitlements.",
422
+ status: "in-progress",
423
+ kind: "task",
424
+ owner: "IT operations",
425
+ lane: "Fulfillment",
426
+ duration: "2h SLA",
427
+ x: 642,
428
+ y: 248
429
+ },
430
+ {
431
+ id: "complete",
432
+ label: "Day-one ready",
433
+ description: "Welcome package, access, and training tasks are complete.",
434
+ status: "queued",
435
+ kind: "end",
436
+ owner: "People ops",
437
+ lane: "Fulfillment",
438
+ duration: "Start date",
439
+ x: 824,
440
+ y: 248
441
+ }
442
+ ];
443
+ var defaultProcessConnections = [
444
+ { from: "start", to: "profile" },
445
+ { from: "profile", to: "approval" },
446
+ { from: "approval", to: "security", label: "Needs review", status: "warning" },
447
+ { from: "approval", to: "provision", label: "Auto approve" },
448
+ { from: "security", to: "provision", label: "Approved" },
449
+ { from: "provision", to: "complete" }
450
+ ];
451
+ var defaultProcessValidationIssues = [
452
+ {
453
+ id: "backup-owner",
454
+ target: "Approval required?",
455
+ message: "Privileged access branch needs a backup owner.",
456
+ status: "warning"
457
+ },
458
+ {
459
+ id: "sla-policy",
460
+ target: "Security review",
461
+ message: "Security review SLA is waiting on policy confirmation.",
462
+ status: "pending-approval"
463
+ }
464
+ ];
465
+ function nextApprovalStepId(steps) {
466
+ let index = steps.length + 1;
467
+ let id = `approval-step-${index}`;
468
+ while (steps.some((step) => step.id === id)) {
469
+ index += 1;
470
+ id = `approval-step-${index}`;
471
+ }
472
+ return id;
473
+ }
474
+ function formatApprovalStatus(status, required) {
475
+ if (status === "completed") return "Completed";
476
+ if (status === "pending-approval") return "Pending";
477
+ if (status === "blocked" || status === "failed") return "Blocked";
478
+ if (status === "queued") return "Queued";
479
+ return required ? "Required" : "Optional";
480
+ }
481
+ function isComplianceComplete(status) {
482
+ return status === "completed" || status === "succeeded" || status === "synced";
483
+ }
484
+ function needsComplianceAttention(status) {
485
+ return status === "approval-required" || status === "blocked" || status === "failed" || status === "pending-approval" || status === "stale" || status === "warning";
486
+ }
487
+ function deriveComplianceStatus(items) {
488
+ if (!items.length) return void 0;
489
+ if (items.some((item) => item.status === "blocked" || item.status === "failed")) {
490
+ return "blocked";
491
+ }
492
+ if (items.some((item) => item.status === "approval-required")) {
493
+ return "approval-required";
494
+ }
495
+ if (items.every((item) => isComplianceComplete(item.status))) {
496
+ return "completed";
497
+ }
498
+ return "in-progress";
499
+ }
500
+ function hasComplianceEvidence(item) {
501
+ return Boolean(item.evidence ?? item.evidenceLabel ?? item.evidenceHref ?? item.meta);
502
+ }
503
+ function hasDisplayValue(value) {
504
+ return value !== void 0 && value !== null && value !== "";
505
+ }
506
+ function isReportSectionIncluded(status) {
507
+ return status !== "inactive" && status !== "not-started" && status !== "blocked" && status !== "failed";
508
+ }
509
+ function needsReportSectionAttention(status) {
510
+ return status === "approval-required" || status === "blocked" || status === "failed" || status === "pending-approval" || status === "stale" || status === "warning";
511
+ }
512
+ function deriveReportBuilderStatus(items) {
513
+ if (!items.length) return "not-started";
514
+ if (items.some((item) => item.status === "blocked" || item.status === "failed")) {
515
+ return "blocked";
516
+ }
517
+ if (items.some((item) => needsReportSectionAttention(item.status))) return "warning";
518
+ if (items.some((item) => item.status === "in-progress" || item.status === "running")) {
519
+ return "in-progress";
520
+ }
521
+ return "active";
522
+ }
523
+ function reportBuilderReadinessLabel(status, attentionCount) {
524
+ if (attentionCount) {
525
+ return `${attentionCount} ${attentionCount === 1 ? "issue" : "issues"} to resolve`;
526
+ }
527
+ if (status === "not-started") return "Not started";
528
+ if (status === "in-progress" || status === "running") return "Draft in progress";
529
+ if (status === "blocked" || status === "failed") return "Blocked";
530
+ return "Ready";
531
+ }
532
+ function reportSectionMeta(item, index) {
533
+ return item.meta ?? item.updatedAt ?? item.source ?? `Section ${index + 1}`;
534
+ }
535
+ var riskImpactLevels = ["critical", "high", "medium", "low"];
536
+ var riskProbabilityLevels = ["low", "medium", "high"];
537
+ var riskImpactRank = {
538
+ low: 1,
539
+ medium: 2,
540
+ high: 3,
541
+ critical: 4
542
+ };
543
+ var riskProbabilityRank = {
544
+ low: 1,
545
+ medium: 2,
546
+ high: 3
547
+ };
548
+ var riskSeverityRank = {
549
+ low: 1,
550
+ medium: 2,
551
+ high: 3,
552
+ critical: 4
553
+ };
554
+ var riskImpactLabels = {
555
+ low: "Low",
556
+ medium: "Medium",
557
+ high: "High",
558
+ critical: "Critical"
559
+ };
560
+ var riskProbabilityLabels = {
561
+ low: "Low",
562
+ medium: "Medium",
563
+ high: "High"
564
+ };
565
+ function isRiskImpact(value) {
566
+ return value === "low" || value === "medium" || value === "high" || value === "critical";
567
+ }
568
+ function isRiskProbability(value) {
569
+ return value === "low" || value === "medium" || value === "high";
570
+ }
571
+ function normalizeRiskImpact(value) {
572
+ if (typeof value !== "string") return void 0;
573
+ const normalized = value.trim().toLowerCase();
574
+ return isRiskImpact(normalized) ? normalized : void 0;
575
+ }
576
+ function normalizeRiskProbability(value) {
577
+ if (typeof value !== "string") return void 0;
578
+ const normalized = value.trim().toLowerCase();
579
+ return isRiskProbability(normalized) ? normalized : void 0;
580
+ }
581
+ function riskFieldFromDescription(item, field) {
582
+ const text = textFromNode(item.description);
583
+ const match = text.match(new RegExp(`${field}\\s*[:=]\\s*(critical|high|medium|low)`, "i"));
584
+ return match?.[1];
585
+ }
586
+ function fallbackImpactForStatus(status) {
587
+ if (status === "blocked" || status === "failed" || status === "approval-required") {
588
+ return "critical";
589
+ }
590
+ if (status === "warning" || status === "stale" || status === "pending-approval") {
591
+ return "high";
592
+ }
593
+ if (status === "completed" || status === "succeeded" || status === "synced") return "low";
594
+ return "medium";
595
+ }
596
+ function riskSeverityFromScore(impact, probability) {
597
+ const score = riskImpactRank[impact] * riskProbabilityRank[probability];
598
+ if (score >= 9) return "critical";
599
+ if (score >= 6) return "high";
600
+ if (score >= 3) return "medium";
601
+ return "low";
602
+ }
603
+ function resolveRiskMatrixItem(item) {
604
+ const resolvedImpact = normalizeRiskImpact(item.impact) ?? normalizeRiskImpact(riskFieldFromDescription(item, "impact")) ?? fallbackImpactForStatus(item.status);
605
+ const resolvedProbability = normalizeRiskProbability(item.probability) ?? normalizeRiskProbability(riskFieldFromDescription(item, "probability")) ?? "medium";
606
+ const resolvedSeverity = item.severity ?? (item.status === "blocked" || item.status === "failed" ? "critical" : riskSeverityFromScore(resolvedImpact, resolvedProbability));
607
+ return {
608
+ ...item,
609
+ resolvedImpact,
610
+ resolvedProbability,
611
+ resolvedSeverity,
612
+ resolvedScore: riskImpactRank[resolvedImpact] * riskProbabilityRank[resolvedProbability]
613
+ };
614
+ }
615
+ function compareRiskPriority(a, b) {
616
+ return riskSeverityRank[b.resolvedSeverity] - riskSeverityRank[a.resolvedSeverity] || b.resolvedScore - a.resolvedScore || riskImpactRank[b.resolvedImpact] - riskImpactRank[a.resolvedImpact] || riskProbabilityRank[b.resolvedProbability] - riskProbabilityRank[a.resolvedProbability];
617
+ }
618
+ function deriveRiskMatrixStatus(items) {
619
+ if (!items.length) return void 0;
620
+ if (items.some((item) => item.resolvedSeverity === "critical")) return "blocked";
621
+ if (items.some((item) => item.resolvedSeverity === "high")) return "warning";
622
+ if (items.some((item) => item.resolvedSeverity === "medium")) return "in-progress";
623
+ return "active";
624
+ }
625
+ function deriveRiskMatrixSurfaceSeverity(items) {
626
+ if (items.some((item) => item.resolvedSeverity === "critical")) return "danger";
627
+ if (items.some((item) => item.resolvedSeverity === "high")) return "warning";
628
+ return void 0;
629
+ }
630
+ function riskCountLabel(count) {
631
+ return `${count} risk${count === 1 ? "" : "s"}`;
632
+ }
633
+ function isCompletedProcessStep(status) {
634
+ return status === "completed" || status === "succeeded" || status === "synced";
635
+ }
636
+ function processStepKind(item, index, total) {
637
+ if (item.kind) return item.kind;
638
+ if (index === 0) return "start";
639
+ if (index === total - 1) return "end";
640
+ return "task";
641
+ }
642
+ function deriveProcessStatus(items, validationIssues) {
643
+ if (validationIssues.some((issue) => issue.status === "blocked" || issue.status === "failed")) {
644
+ return "blocked";
645
+ }
646
+ if (validationIssues.some(
647
+ (issue) => issue.status === "warning" || issue.status === "pending-approval" || issue.status === "approval-required"
648
+ )) {
649
+ return "warning";
650
+ }
651
+ if (!items.length) return void 0;
652
+ if (items.some((item) => item.status === "blocked" || item.status === "failed")) {
653
+ return "blocked";
654
+ }
655
+ if (items.every((item) => isCompletedProcessStep(item.status))) {
656
+ return "completed";
657
+ }
658
+ if (items.some(
659
+ (item) => item.status === "active" || item.status === "in-progress" || item.status === "running"
660
+ )) {
661
+ return "in-progress";
662
+ }
663
+ return "queued";
664
+ }
665
+ function sequentialProcessConnections(items) {
666
+ return items.slice(1).map((item, index) => ({ from: items[index].id, to: item.id }));
667
+ }
668
+ function processNodePoint(item, index) {
669
+ return {
670
+ x: item.x ?? 110 + index % 4 * 210,
671
+ y: item.y ?? 140 + Math.floor(index / 4) * 140
672
+ };
673
+ }
674
+ function graphLabelLines(value, fallback) {
675
+ const label = textFromNode(value).trim() || fallback;
676
+ if (label.length <= 18) return [label];
677
+ const lines = [];
678
+ let current = "";
679
+ for (const word of label.split(/\s+/)) {
680
+ const next = current ? `${current} ${word}` : word;
681
+ if (next.length > 18 && current) {
682
+ lines.push(current);
683
+ current = word;
684
+ } else {
685
+ current = next;
686
+ }
687
+ }
688
+ if (current) lines.push(current);
689
+ if (lines.length <= 2) return lines;
690
+ return [lines[0], `${lines.slice(1).join(" ").slice(0, 16)}...`];
691
+ }
692
+ var defaultOrderFulfillmentItems = [
693
+ {
694
+ id: "received",
695
+ label: "Order received",
696
+ description: "Purchase order matched against contract pricing and customer terms.",
697
+ owner: "Sales operations",
698
+ timestamp: "May 29, 08:12",
699
+ status: "completed"
700
+ },
701
+ {
702
+ id: "payment",
703
+ label: "Payment terms cleared",
704
+ description: "Net 30 credit check passed; release hold removed by finance.",
705
+ owner: "Finance operations",
706
+ timestamp: "May 29, 09:05",
707
+ status: "completed"
708
+ },
709
+ {
710
+ id: "pick-pack",
711
+ label: "Pick and pack",
712
+ description: "Warehouse B is staging the final cartons for carrier handoff.",
713
+ owner: "Fulfillment team",
714
+ location: "Warehouse B",
715
+ quantity: "18 / 20 cartons",
716
+ timestamp: "May 29, 14:40",
717
+ status: "in-progress"
718
+ },
719
+ {
720
+ id: "carrier",
721
+ label: "Carrier handoff",
722
+ description: "FedEx pickup booked; ASN will post when scan is received.",
723
+ owner: "FedEx Ground",
724
+ location: "Dock 4",
725
+ timestamp: "May 29, 17:00",
726
+ status: "queued"
727
+ }
728
+ ];
729
+ function isOrderStepComplete(status) {
730
+ return status === "completed" || status === "succeeded" || status === "synced";
731
+ }
732
+ function isOrderStepCurrent(status) {
733
+ return status === "active" || status === "in-progress" || status === "running";
734
+ }
735
+ function needsOrderAttention(item) {
736
+ return hasDisplayValue(item.exception) || item.status === "approval-required" || item.status === "blocked" || item.status === "failed" || item.status === "pending-approval" || item.status === "stale" || item.status === "warning";
737
+ }
738
+ function deriveOrderStatus(items) {
739
+ if (!items.length) return void 0;
740
+ if (items.some((item) => item.status === "blocked" || item.status === "failed")) {
741
+ return "blocked";
742
+ }
743
+ if (items.some((item) => item.status === "approval-required")) {
744
+ return "approval-required";
745
+ }
746
+ if (items.every((item) => isOrderStepComplete(item.status))) return "completed";
747
+ if (items.some((item) => isOrderStepCurrent(item.status))) return "in-progress";
748
+ if (items.some((item) => item.status === "pending-approval" || item.status === "warning")) {
749
+ return "pending-approval";
750
+ }
751
+ return "queued";
752
+ }
753
+ function currentOrderStepIndex(items) {
754
+ const activeIndex = items.findIndex((item) => isOrderStepCurrent(item.status));
755
+ if (activeIndex >= 0) return activeIndex;
756
+ const nextIndex = items.findIndex((item) => !isOrderStepComplete(item.status));
757
+ return nextIndex >= 0 ? nextIndex : Math.max(items.length - 1, 0);
758
+ }
759
+ function OrderFulfillmentActions({ actions }) {
760
+ if (!actions?.length) return null;
761
+ return /* @__PURE__ */ jsx("div", { className: "eth-domain-order-management__step-actions", children: actions.slice(0, 2).map(
762
+ (action) => action.href ? /* @__PURE__ */ jsx(
763
+ LinkButton,
764
+ {
765
+ href: action.disabled ? void 0 : action.href,
766
+ intent: action.intent ?? "ghost",
767
+ density: "compact",
768
+ "aria-disabled": action.disabled ? true : void 0,
769
+ tabIndex: action.disabled ? -1 : void 0,
770
+ children: action.label
771
+ },
772
+ action.id
773
+ ) : /* @__PURE__ */ jsx(
774
+ Button,
775
+ {
776
+ type: "button",
777
+ intent: action.intent ?? "ghost",
778
+ density: "compact",
779
+ disabled: action.disabled,
780
+ onClick: action.onSelect,
781
+ children: action.label
782
+ },
783
+ action.id
784
+ )
785
+ ) });
786
+ }
787
+ function parseInventoryNumber(value) {
788
+ if (typeof value === "number") return Number.isFinite(value) ? value : null;
789
+ if (typeof value !== "string") return null;
790
+ const normalized = value.replace(/,/g, "").trim();
791
+ if (!/^-?\d+(\.\d+)?$/.test(normalized)) return null;
792
+ const parsed = Number(normalized);
793
+ return Number.isFinite(parsed) ? parsed : null;
794
+ }
795
+ function formatInventoryValue(value) {
796
+ if (!hasDisplayValue(value)) return "--";
797
+ if (typeof value === "number") return new Intl.NumberFormat("en-US").format(value);
798
+ return value;
799
+ }
800
+ function parseInventoryStockDescription(description) {
801
+ const text = textFromNode(description);
802
+ const match = text.match(
803
+ /\bOn hand:\s*([0-9,]+(?:\.\d+)?)\s*(?:[^A-Za-z0-9]+\s*)?Reorder:\s*([0-9,]+(?:\.\d+)?)/i
804
+ );
805
+ if (!match) return null;
806
+ return {
807
+ onHand: Number(match[1].replace(/,/g, "")),
808
+ reorderPoint: Number(match[2].replace(/,/g, ""))
809
+ };
810
+ }
811
+ function inventoryStatusFromLevels(item, onHandNumber, reorderNumber) {
812
+ if (item.status) return item.status;
813
+ if (onHandNumber !== null && onHandNumber <= 0) return "failed";
814
+ if (onHandNumber !== null && reorderNumber !== null && onHandNumber <= reorderNumber) {
815
+ return "warning";
816
+ }
817
+ return "active";
818
+ }
819
+ function inventoryStatusLabel(status) {
820
+ if (status === "failed" || status === "blocked") return "Stockout";
821
+ if (status === "warning" || status === "stale") return "Reorder";
822
+ if (status === "in-progress" || status === "running") return "Replenishing";
823
+ if (status === "queued" || status === "not-started") return "Pending count";
824
+ if (status === "active" || status === "completed" || status === "succeeded" || status === "synced") {
825
+ return "In stock";
826
+ }
827
+ return statusLabel(status);
828
+ }
829
+ function normalizeInventoryRow(item) {
830
+ const parsedStockDescription = parseInventoryStockDescription(item.description);
831
+ const onHand = item.onHand ?? parsedStockDescription?.onHand;
832
+ const reorderPoint = item.reorderPoint ?? parsedStockDescription?.reorderPoint;
833
+ const onHandNumber = parseInventoryNumber(onHand);
834
+ const reorderNumber = parseInventoryNumber(reorderPoint);
835
+ const allocatedNumber = parseInventoryNumber(item.allocated);
836
+ const available = item.available ?? (onHandNumber !== null && allocatedNumber !== null ? onHandNumber - allocatedNumber : void 0);
837
+ const status = inventoryStatusFromLevels(item, onHandNumber, reorderNumber);
838
+ return {
839
+ item,
840
+ parsedStockDescription: Boolean(parsedStockDescription),
841
+ onHand,
842
+ onHandNumber,
843
+ reorderPoint,
844
+ reorderNumber,
845
+ available,
846
+ status
847
+ };
848
+ }
849
+ function inventoryLevelPercent(row) {
850
+ if (row.onHandNumber === null || row.reorderNumber === null) return 0;
851
+ const capacity = Math.max(row.reorderNumber * 2, row.onHandNumber, 1);
852
+ return Math.max(0, Math.min(100, Math.round(row.onHandNumber / capacity * 100)));
853
+ }
854
+ function isInventoryReorderRow(row) {
855
+ if (row.onHandNumber !== null && row.reorderNumber !== null) {
856
+ return row.onHandNumber <= row.reorderNumber;
857
+ }
858
+ return row.status === "warning" || row.status === "failed" || row.status === "blocked";
859
+ }
860
+ function isInventoryStockoutRow(row) {
861
+ if (row.onHandNumber !== null) return row.onHandNumber <= 0;
862
+ return row.status === "failed" || row.status === "blocked";
863
+ }
864
+ function InventoryTable({
865
+ title = "Inventory",
866
+ description = "SKU availability, reorder thresholds, and fulfillment readiness.",
867
+ items = [],
868
+ metadata,
869
+ actions,
870
+ footer,
871
+ children,
872
+ className,
873
+ ...props
874
+ }) {
875
+ const rows = items.map(normalizeInventoryRow);
876
+ const totalOnHand = rows.reduce(
877
+ (sum, row) => row.onHandNumber === null ? sum : sum + row.onHandNumber,
878
+ 0
879
+ );
880
+ const hasOnHandTotal = rows.some((row) => row.onHandNumber !== null);
881
+ const reorderCount = rows.filter(isInventoryReorderRow).length;
882
+ const stockoutCount = rows.filter(isInventoryStockoutRow).length;
883
+ const computedMetadata = metadata ?? (rows.length ? [
884
+ { label: "SKUs", value: rows.length },
885
+ { label: "Below reorder", value: reorderCount },
886
+ { label: "Stockouts", value: stockoutCount },
887
+ ...hasOnHandTotal ? [{ label: "On hand", value: new Intl.NumberFormat("en-US").format(totalOnHand) }] : []
888
+ ] : void 0);
889
+ return /* @__PURE__ */ jsxs(
890
+ Surface,
891
+ {
892
+ ...props,
893
+ "data-eth-component": "InventoryTable",
894
+ title,
895
+ description,
896
+ metadata: computedMetadata,
897
+ actions,
898
+ footer,
899
+ className: ["eth-domain-inventory-table", className].filter(Boolean).join(" "),
900
+ children: [
901
+ rows.length ? /* @__PURE__ */ jsx("div", { className: "eth-domain-inventory-table__table-wrap", children: /* @__PURE__ */ jsxs("table", { className: "eth-domain-inventory-table__table", children: [
902
+ /* @__PURE__ */ jsx("caption", { className: "eth-domain-inventory-table__caption", children: "Inventory stock by SKU and reorder threshold" }),
903
+ /* @__PURE__ */ jsxs("colgroup", { children: [
904
+ /* @__PURE__ */ jsx("col", { className: "eth-domain-inventory-table__sku-col" }),
905
+ /* @__PURE__ */ jsx("col", { className: "eth-domain-inventory-table__location-col" }),
906
+ /* @__PURE__ */ jsx("col", { className: "eth-domain-inventory-table__quantity-col" }),
907
+ /* @__PURE__ */ jsx("col", { className: "eth-domain-inventory-table__quantity-col" }),
908
+ /* @__PURE__ */ jsx("col", { className: "eth-domain-inventory-table__quantity-col" }),
909
+ /* @__PURE__ */ jsx("col", { className: "eth-domain-inventory-table__status-col" })
910
+ ] }),
911
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
912
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "SKU" }),
913
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Location" }),
914
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "On hand" }),
915
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Available" }),
916
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Reorder point" }),
917
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Stock status" })
918
+ ] }) }),
919
+ /* @__PURE__ */ jsx("tbody", { children: rows.map((row) => {
920
+ const { item } = row;
921
+ const labelContent = item.href ? /* @__PURE__ */ jsx("a", { href: item.href, children: item.label }) : item.label;
922
+ const showDescription = hasDisplayValue(item.description) && !row.parsedStockDescription;
923
+ const location = item.location ?? item.meta;
924
+ const statusLabelText = inventoryStatusLabel(row.status);
925
+ return /* @__PURE__ */ jsxs("tr", { "data-status": row.status, children: [
926
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("div", { className: "eth-domain-inventory-table__sku", children: [
927
+ /* @__PURE__ */ jsx("span", { children: item.sku ?? item.id }),
928
+ /* @__PURE__ */ jsx("strong", { children: labelContent }),
929
+ showDescription ? /* @__PURE__ */ jsx("p", { children: item.description }) : null
930
+ ] }) }),
931
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("div", { className: "eth-domain-inventory-table__cell-stack", children: [
932
+ /* @__PURE__ */ jsx("strong", { children: formatInventoryValue(location) }),
933
+ hasDisplayValue(item.updatedAt) ? /* @__PURE__ */ jsx("span", { children: item.updatedAt }) : /* @__PURE__ */ jsx("span", { children: "Cycle count current" })
934
+ ] }) }),
935
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("div", { className: "eth-domain-inventory-table__quantity", children: [
936
+ /* @__PURE__ */ jsx("strong", { children: formatInventoryValue(row.onHand) }),
937
+ /* @__PURE__ */ jsx("span", { className: "eth-domain-inventory-table__level", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
938
+ "span",
939
+ {
940
+ className: "eth-domain-inventory-table__level-fill",
941
+ style: { inlineSize: `${inventoryLevelPercent(row)}%` }
942
+ }
943
+ ) })
944
+ ] }) }),
945
+ /* @__PURE__ */ jsx("td", { className: "eth-domain-inventory-table__numeric", children: formatInventoryValue(row.available) }),
946
+ /* @__PURE__ */ jsx("td", { className: "eth-domain-inventory-table__numeric", children: formatInventoryValue(row.reorderPoint) }),
947
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("div", { className: "eth-domain-inventory-table__state", children: [
948
+ /* @__PURE__ */ jsx(StatusDot, { status: row.status, label: statusLabelText }),
949
+ hasDisplayValue(item.incoming) ? /* @__PURE__ */ jsxs("span", { children: [
950
+ "Incoming ",
951
+ formatInventoryValue(item.incoming)
952
+ ] }) : null
953
+ ] }) })
954
+ ] }, item.id);
955
+ }) })
956
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "eth-domain-inventory-table__empty", children: "No inventory items configured." }),
957
+ children
958
+ ]
959
+ }
960
+ );
961
+ }
962
+ function OrderManagementPanel({
963
+ title = "Order",
964
+ description,
965
+ status,
966
+ metadata,
967
+ actions,
968
+ footer,
969
+ children,
970
+ className,
971
+ items = defaultOrderFulfillmentItems,
972
+ customer,
973
+ orderTotal,
974
+ paymentTerms,
975
+ shipTo,
976
+ carrier,
977
+ eta,
978
+ fulfillmentOwner = "Fulfillment operations",
979
+ ...props
980
+ }) {
981
+ const orderStatus = status ?? deriveOrderStatus(items) ?? "not-started";
982
+ const currentIndex = currentOrderStepIndex(items);
983
+ const currentStep = items[currentIndex];
984
+ const completedCount = items.filter((item) => isOrderStepComplete(item.status)).length;
985
+ const attentionCount = items.filter(needsOrderAttention).length;
986
+ const lifecycleHeadingId = React.useId();
987
+ const executionHeadingId = React.useId();
988
+ const computedMetadata = metadata ?? [
989
+ {
990
+ label: "Fulfillment",
991
+ value: items.length ? `${completedCount}/${items.length} checkpoints` : void 0
992
+ },
993
+ { label: "Carrier", value: carrier },
994
+ { label: "ETA", value: eta },
995
+ {
996
+ label: "Exceptions",
997
+ value: attentionCount ? `${attentionCount} open` : "None"
998
+ }
999
+ ].filter((item) => hasDisplayValue(item.value));
1000
+ const executionSummary = [
1001
+ { label: "Customer", value: customer },
1002
+ { label: "Current checkpoint", value: currentStep?.label },
1003
+ { label: "Owner", value: currentStep?.owner ?? fulfillmentOwner },
1004
+ { label: "Ship to", value: shipTo },
1005
+ { label: "Payment terms", value: paymentTerms },
1006
+ { label: "Order total", value: orderTotal }
1007
+ ].filter((item) => hasDisplayValue(item.value));
1008
+ const activeException = items.find(needsOrderAttention);
1009
+ return /* @__PURE__ */ jsxs(
1010
+ Surface,
1011
+ {
1012
+ ...props,
1013
+ "data-eth-component": "OrderManagementPanel",
1014
+ title,
1015
+ description,
1016
+ status: orderStatus,
1017
+ metadata: computedMetadata.length ? computedMetadata : void 0,
1018
+ actions,
1019
+ footer,
1020
+ className: ["eth-domain-order-management", className].filter(Boolean).join(" "),
1021
+ children: [
1022
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-order-management__body", children: [
1023
+ /* @__PURE__ */ jsxs(
1024
+ "section",
1025
+ {
1026
+ className: "eth-domain-order-management__timeline",
1027
+ "aria-labelledby": lifecycleHeadingId,
1028
+ children: [
1029
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-order-management__section-header", children: [
1030
+ /* @__PURE__ */ jsxs("div", { children: [
1031
+ /* @__PURE__ */ jsx("span", { children: "Fulfillment" }),
1032
+ /* @__PURE__ */ jsx("h3", { id: lifecycleHeadingId, children: "Lifecycle" })
1033
+ ] }),
1034
+ /* @__PURE__ */ jsx("strong", { children: items.length ? `${completedCount} of ${items.length} complete` : "No checkpoints" })
1035
+ ] }),
1036
+ items.length ? /* @__PURE__ */ jsx("ol", { className: "eth-domain-order-management__steps", children: items.map((item, index) => {
1037
+ const itemStatus = item.status ?? "not-started";
1038
+ const labelContent = item.href ? /* @__PURE__ */ jsx("a", { href: item.href, children: item.label }) : item.label;
1039
+ const detailRows = [
1040
+ { label: "Owner", value: item.owner },
1041
+ { label: "Location", value: item.location },
1042
+ { label: "Quantity", value: item.quantity },
1043
+ { label: "Time", value: item.timestamp ?? item.meta }
1044
+ ].filter((detail) => hasDisplayValue(detail.value));
1045
+ return /* @__PURE__ */ jsxs(
1046
+ "li",
1047
+ {
1048
+ "aria-current": index === currentIndex ? "step" : void 0,
1049
+ "data-current": index === currentIndex ? "true" : void 0,
1050
+ "data-status": itemStatus,
1051
+ children: [
1052
+ /* @__PURE__ */ jsx("span", { className: "eth-domain-order-management__step-marker", "aria-hidden": "true", children: index + 1 }),
1053
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-order-management__step-main", children: [
1054
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-order-management__step-heading", children: [
1055
+ /* @__PURE__ */ jsx("strong", { children: labelContent }),
1056
+ /* @__PURE__ */ jsx(StatusDot, { status: itemStatus, label: statusLabel(itemStatus) })
1057
+ ] }),
1058
+ item.description ? /* @__PURE__ */ jsx("p", { children: item.description }) : null,
1059
+ detailRows.length ? /* @__PURE__ */ jsx("dl", { className: "eth-domain-order-management__step-meta", children: detailRows.map((detail, detailIndex) => /* @__PURE__ */ jsxs("div", { children: [
1060
+ /* @__PURE__ */ jsx("dt", { children: detail.label }),
1061
+ /* @__PURE__ */ jsx("dd", { children: detail.value })
1062
+ ] }, detailIndex)) }) : null,
1063
+ item.exception ? /* @__PURE__ */ jsx("div", { className: "eth-domain-order-management__step-exception", children: item.exception }) : null,
1064
+ /* @__PURE__ */ jsx(OrderFulfillmentActions, { actions: item.actions })
1065
+ ] })
1066
+ ]
1067
+ },
1068
+ item.id
1069
+ );
1070
+ }) }) : /* @__PURE__ */ jsx("div", { className: "eth-domain-order-management__empty", children: "No fulfillment checkpoints configured." })
1071
+ ]
1072
+ }
1073
+ ),
1074
+ /* @__PURE__ */ jsxs(
1075
+ "aside",
1076
+ {
1077
+ className: "eth-domain-order-management__execution",
1078
+ "aria-labelledby": executionHeadingId,
1079
+ children: [
1080
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-order-management__section-header", children: [
1081
+ /* @__PURE__ */ jsxs("div", { children: [
1082
+ /* @__PURE__ */ jsx("span", { children: "Execution" }),
1083
+ /* @__PURE__ */ jsx("h3", { id: executionHeadingId, children: "Order controls" })
1084
+ ] }),
1085
+ /* @__PURE__ */ jsx(StatusDot, { status: orderStatus, label: statusLabel(orderStatus) })
1086
+ ] }),
1087
+ executionSummary.length ? /* @__PURE__ */ jsx("dl", { className: "eth-domain-order-management__summary", children: executionSummary.map((item, index) => /* @__PURE__ */ jsxs("div", { children: [
1088
+ /* @__PURE__ */ jsx("dt", { children: item.label }),
1089
+ /* @__PURE__ */ jsx("dd", { children: item.value })
1090
+ ] }, index)) }) : null,
1091
+ /* @__PURE__ */ jsxs(
1092
+ "div",
1093
+ {
1094
+ className: "eth-domain-order-management__attention",
1095
+ "data-status": activeException ? activeException.status ?? "warning" : "completed",
1096
+ children: [
1097
+ /* @__PURE__ */ jsx("span", { children: "Exception state" }),
1098
+ /* @__PURE__ */ jsx("strong", { children: activeException ? activeException.label : "No active fulfillment exceptions" }),
1099
+ activeException?.exception ? /* @__PURE__ */ jsx("p", { children: activeException.exception }) : null
1100
+ ]
1101
+ }
1102
+ )
1103
+ ]
1104
+ }
1105
+ )
1106
+ ] }),
1107
+ children
1108
+ ]
1109
+ }
1110
+ );
1111
+ }
1112
+ var defaultKnowledgeBaseSections = [
1113
+ {
1114
+ id: "routing",
1115
+ title: "Approval routing",
1116
+ body: "Requests with external recipients enter legal review before delivery. The route records each approver, decision, exception reason, and timestamp for audit export.",
1117
+ status: "active"
1118
+ },
1119
+ {
1120
+ id: "exceptions",
1121
+ title: "Exception handling",
1122
+ body: "If legal requests a change, the article owner receives a revision task and external send remains disabled until the legal approval returns.",
1123
+ status: "pending-approval"
1124
+ }
1125
+ ];
1126
+ var defaultKnowledgeBaseRelatedArticles = [
1127
+ {
1128
+ id: "legal-review-sla",
1129
+ label: "Legal review SLA",
1130
+ description: "Response windows, backup approvers, and overdue escalation paths.",
1131
+ meta: "Policy",
1132
+ type: "Policy",
1133
+ updatedAt: "Updated May 20",
1134
+ status: "active"
1135
+ },
1136
+ {
1137
+ id: "external-send-controls",
1138
+ label: "External send controls",
1139
+ description: "Controls that keep outbound delivery locked while approval is open.",
1140
+ meta: "Runbook",
1141
+ type: "Runbook",
1142
+ updatedAt: "Updated May 18",
1143
+ status: "in-progress"
1144
+ }
1145
+ ];
1146
+ var defaultKnowledgeBaseCitations = [
1147
+ {
1148
+ id: "approval-policy",
1149
+ label: "External send approval policy",
1150
+ source: "Policy KB-214",
1151
+ excerpt: "Outbound delivery requires recorded legal approval.",
1152
+ status: "completed"
1153
+ },
1154
+ {
1155
+ id: "audit-control",
1156
+ label: "Audit evidence control",
1157
+ source: "Control AE-09",
1158
+ excerpt: "Approval decisions must include owner, timestamp, and reason.",
1159
+ status: "active"
1160
+ }
1161
+ ];
1162
+ function knowledgeBaseStatusLabel(status) {
1163
+ return status ? statusLabel(status) : "Published";
1164
+ }
1165
+ function hasKnowledgeBaseNode(node) {
1166
+ return node !== void 0 && node !== null && node !== false && node !== "";
1167
+ }
1168
+ function renderKnowledgeBaseNode(node) {
1169
+ if (!hasKnowledgeBaseNode(node)) return null;
1170
+ if (typeof node === "string" || typeof node === "number") return /* @__PURE__ */ jsx("p", { children: node });
1171
+ return node;
1172
+ }
1173
+ function ComplianceChecklist({
1174
+ title = "Compliance checklist",
1175
+ description = "Evidence readiness, control ownership, and audit state for the current review.",
1176
+ items = [],
1177
+ metadata,
1178
+ status,
1179
+ footer,
1180
+ children,
1181
+ className,
1182
+ ...props
1183
+ }) {
1184
+ const completeCount = items.filter((item) => isComplianceComplete(item.status)).length;
1185
+ const attentionCount = items.filter((item) => needsComplianceAttention(item.status)).length;
1186
+ const evidenceCount = items.filter(hasComplianceEvidence).length;
1187
+ const computedMetadata = metadata ?? (items.length ? [
1188
+ { label: "Complete", value: `${completeCount}/${items.length}` },
1189
+ { label: "Needs attention", value: attentionCount },
1190
+ { label: "Evidence linked", value: `${evidenceCount}/${items.length}` }
1191
+ ] : void 0);
1192
+ return /* @__PURE__ */ jsxs(
1193
+ Surface,
1194
+ {
1195
+ ...props,
1196
+ "data-eth-component": "ComplianceChecklist",
1197
+ title,
1198
+ description,
1199
+ status: status ?? deriveComplianceStatus(items),
1200
+ metadata: computedMetadata,
1201
+ footer,
1202
+ className: ["eth-domain-compliance-checklist", className].filter(Boolean).join(" "),
1203
+ children: [
1204
+ items.length ? /* @__PURE__ */ jsx("div", { className: "eth-domain-compliance-checklist__table-wrap", children: /* @__PURE__ */ jsxs("table", { className: "eth-domain-compliance-checklist__table", children: [
1205
+ /* @__PURE__ */ jsx("caption", { className: "eth-domain-compliance-checklist__caption", children: "Compliance evidence checklist" }),
1206
+ /* @__PURE__ */ jsxs("colgroup", { children: [
1207
+ /* @__PURE__ */ jsx("col", { className: "eth-domain-compliance-checklist__control-col" }),
1208
+ /* @__PURE__ */ jsx("col", { className: "eth-domain-compliance-checklist__owner-col" }),
1209
+ /* @__PURE__ */ jsx("col", { className: "eth-domain-compliance-checklist__evidence-col" }),
1210
+ /* @__PURE__ */ jsx("col", { className: "eth-domain-compliance-checklist__state-col" })
1211
+ ] }),
1212
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
1213
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Control" }),
1214
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Owner" }),
1215
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Evidence" }),
1216
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Audit state" })
1217
+ ] }) }),
1218
+ /* @__PURE__ */ jsx("tbody", { children: items.map((item) => {
1219
+ const itemStatus = item.status ?? "not-started";
1220
+ const labelContent = item.href ? /* @__PURE__ */ jsx("a", { href: item.href, children: item.label }) : item.label;
1221
+ const evidenceContent = item.evidence ?? item.evidenceLabel ?? item.meta;
1222
+ return /* @__PURE__ */ jsxs("tr", { "data-status": itemStatus, children: [
1223
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("div", { className: "eth-domain-compliance-checklist__control", children: [
1224
+ item.controlId ? /* @__PURE__ */ jsx("span", { className: "eth-domain-compliance-checklist__control-id", children: item.controlId }) : null,
1225
+ /* @__PURE__ */ jsx("strong", { children: labelContent }),
1226
+ item.description ? /* @__PURE__ */ jsx("p", { children: item.description }) : null
1227
+ ] }) }),
1228
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("div", { className: "eth-domain-compliance-checklist__cell-stack", children: [
1229
+ /* @__PURE__ */ jsx("strong", { children: item.owner ?? "Unassigned" }),
1230
+ item.dueDate ? /* @__PURE__ */ jsxs("span", { className: "eth-domain-compliance-checklist__secondary", children: [
1231
+ "Due ",
1232
+ item.dueDate
1233
+ ] }) : null
1234
+ ] }) }),
1235
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("div", { className: "eth-domain-compliance-checklist__cell-stack", children: [
1236
+ evidenceContent ? item.evidenceHref ? /* @__PURE__ */ jsx(
1237
+ "a",
1238
+ {
1239
+ className: "eth-domain-compliance-checklist__evidence-link",
1240
+ href: item.evidenceHref,
1241
+ children: evidenceContent
1242
+ }
1243
+ ) : /* @__PURE__ */ jsx("strong", { children: evidenceContent }) : /* @__PURE__ */ jsx("span", { className: "eth-domain-compliance-checklist__secondary", children: "Evidence not linked" }),
1244
+ item.updatedAt ? /* @__PURE__ */ jsx("span", { className: "eth-domain-compliance-checklist__secondary", children: item.updatedAt }) : null
1245
+ ] }) }),
1246
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("div", { className: "eth-domain-compliance-checklist__state", children: [
1247
+ /* @__PURE__ */ jsx(StatusDot, { status: itemStatus, label: statusLabel(itemStatus) }),
1248
+ item.required ? /* @__PURE__ */ jsx("span", { className: "eth-domain-compliance-checklist__requirement", children: "Required" }) : null
1249
+ ] }) })
1250
+ ] }, item.id);
1251
+ }) })
1252
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "eth-domain-compliance-checklist__empty", children: "No compliance controls configured." }),
1253
+ children
1254
+ ]
1255
+ }
1256
+ );
1257
+ }
1258
+ function RiskMatrixActions({ actions }) {
1259
+ if (!actions?.length) return null;
1260
+ return /* @__PURE__ */ jsx("div", { className: "eth-domain-risk-matrix__item-actions", children: actions.map(
1261
+ (action) => action.href ? /* @__PURE__ */ jsx(
1262
+ LinkButton,
1263
+ {
1264
+ href: action.disabled ? void 0 : action.href,
1265
+ intent: action.intent ?? "ghost",
1266
+ density: "compact",
1267
+ "aria-disabled": action.disabled ? true : void 0,
1268
+ tabIndex: action.disabled ? -1 : void 0,
1269
+ children: action.label
1270
+ },
1271
+ action.id
1272
+ ) : /* @__PURE__ */ jsx(
1273
+ Button,
1274
+ {
1275
+ type: "button",
1276
+ intent: action.intent ?? "ghost",
1277
+ density: "compact",
1278
+ disabled: action.disabled,
1279
+ onClick: action.onSelect,
1280
+ children: action.label
1281
+ },
1282
+ action.id
1283
+ )
1284
+ ) });
1285
+ }
1286
+ function RiskMatrixFact({
1287
+ label,
1288
+ value
1289
+ }) {
1290
+ if (!hasDisplayValue(value)) return null;
1291
+ return /* @__PURE__ */ jsxs("div", { children: [
1292
+ /* @__PURE__ */ jsx("dt", { children: label }),
1293
+ /* @__PURE__ */ jsx("dd", { children: value })
1294
+ ] });
1295
+ }
1296
+ function RiskMatrix({
1297
+ title = "Risk register",
1298
+ description = "Impact and probability register with mitigation ownership.",
1299
+ status,
1300
+ severity,
1301
+ metadata,
1302
+ actions,
1303
+ footer,
1304
+ children,
1305
+ className,
1306
+ items = [],
1307
+ selectedItemId,
1308
+ view,
1309
+ reviewCadence,
1310
+ onViewChange,
1311
+ ...props
1312
+ }) {
1313
+ const matrixHeadingId = React.useId();
1314
+ const registerHeadingId = React.useId();
1315
+ const [internalView, setInternalView] = React.useState("matrix");
1316
+ const currentView = view ?? internalView;
1317
+ const risks = items.map(resolveRiskMatrixItem).sort(compareRiskPriority);
1318
+ const priorityRisk = selectedItemId ? risks.find((item) => item.id === selectedItemId) ?? risks[0] : risks[0];
1319
+ const criticalCount = risks.filter((item) => item.resolvedSeverity === "critical").length;
1320
+ const highCount = risks.filter((item) => item.resolvedSeverity === "high").length;
1321
+ const mediumCount = risks.filter((item) => item.resolvedSeverity === "medium").length;
1322
+ const priorityStatus = priorityRisk ? priorityRisk.status ?? deriveRiskMatrixStatus([priorityRisk]) ?? "active" : "active";
1323
+ const computedMetadata = metadata ?? [
1324
+ { label: "Open risks", value: risks.length },
1325
+ { label: "Critical", value: criticalCount },
1326
+ { label: "High", value: highCount },
1327
+ { label: "Medium", value: mediumCount }
1328
+ ];
1329
+ const changeView = (nextView) => {
1330
+ if (view === void 0) setInternalView(nextView);
1331
+ onViewChange?.(nextView);
1332
+ };
1333
+ return /* @__PURE__ */ jsxs(
1334
+ Surface,
1335
+ {
1336
+ ...props,
1337
+ "data-eth-component": "RiskMatrix",
1338
+ title,
1339
+ description,
1340
+ status: status ?? deriveRiskMatrixStatus(risks),
1341
+ severity: severity ?? deriveRiskMatrixSurfaceSeverity(risks),
1342
+ metadata: computedMetadata,
1343
+ actions,
1344
+ footer,
1345
+ className: ["eth-domain-risk-matrix", className].filter(Boolean).join(" "),
1346
+ children: [
1347
+ /* @__PURE__ */ jsxs(
1348
+ "div",
1349
+ {
1350
+ className: "eth-domain-risk-matrix__toolbar",
1351
+ role: "group",
1352
+ "aria-label": "Risk matrix controls",
1353
+ children: [
1354
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-risk-matrix__view-switch", role: "group", "aria-label": "Risk view", children: [
1355
+ /* @__PURE__ */ jsx(
1356
+ Button,
1357
+ {
1358
+ type: "button",
1359
+ intent: currentView === "matrix" ? "secondary" : "ghost",
1360
+ density: "compact",
1361
+ "aria-label": "Matrix view",
1362
+ "aria-pressed": currentView === "matrix",
1363
+ onClick: () => changeView("matrix"),
1364
+ children: "Matrix"
1365
+ }
1366
+ ),
1367
+ /* @__PURE__ */ jsx(
1368
+ Button,
1369
+ {
1370
+ type: "button",
1371
+ intent: currentView === "register" ? "secondary" : "ghost",
1372
+ density: "compact",
1373
+ "aria-label": "Register view",
1374
+ "aria-pressed": currentView === "register",
1375
+ onClick: () => changeView("register"),
1376
+ children: "Register"
1377
+ }
1378
+ )
1379
+ ] }),
1380
+ reviewCadence ? /* @__PURE__ */ jsxs("span", { className: "eth-domain-risk-matrix__cadence", children: [
1381
+ "Review ",
1382
+ /* @__PURE__ */ jsx("strong", { children: reviewCadence })
1383
+ ] }) : null,
1384
+ criticalCount || highCount ? /* @__PURE__ */ jsxs("span", { className: "eth-domain-risk-matrix__attention", children: [
1385
+ criticalCount,
1386
+ " critical / ",
1387
+ highCount,
1388
+ " high"
1389
+ ] }) : null
1390
+ ]
1391
+ }
1392
+ ),
1393
+ risks.length ? /* @__PURE__ */ jsxs("div", { className: "eth-domain-risk-matrix__workspace", "data-view": currentView, children: [
1394
+ currentView === "matrix" ? /* @__PURE__ */ jsxs(
1395
+ "section",
1396
+ {
1397
+ className: "eth-domain-risk-matrix__matrix-panel",
1398
+ "aria-labelledby": matrixHeadingId,
1399
+ children: [
1400
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-risk-matrix__panel-header", children: [
1401
+ /* @__PURE__ */ jsxs("div", { children: [
1402
+ /* @__PURE__ */ jsx("span", { children: "Matrix" }),
1403
+ /* @__PURE__ */ jsx("h3", { id: matrixHeadingId, children: "Impact x probability" })
1404
+ ] }),
1405
+ /* @__PURE__ */ jsx(
1406
+ "div",
1407
+ {
1408
+ className: "eth-domain-risk-matrix__legend",
1409
+ role: "list",
1410
+ "aria-label": "Risk severity legend",
1411
+ children: ["low", "medium", "high", "critical"].map(
1412
+ (riskSeverity) => /* @__PURE__ */ jsx("span", { "data-severity": riskSeverity, role: "listitem", children: riskImpactLabels[riskSeverity] }, riskSeverity)
1413
+ )
1414
+ }
1415
+ )
1416
+ ] }),
1417
+ /* @__PURE__ */ jsxs(
1418
+ "div",
1419
+ {
1420
+ className: "eth-domain-risk-matrix__grid",
1421
+ role: "grid",
1422
+ "aria-label": "Impact probability risk matrix",
1423
+ children: [
1424
+ /* @__PURE__ */ jsxs(
1425
+ "div",
1426
+ {
1427
+ className: "eth-domain-risk-matrix__grid-row eth-domain-risk-matrix__grid-row--header",
1428
+ role: "row",
1429
+ children: [
1430
+ /* @__PURE__ */ jsx("div", { className: "eth-domain-risk-matrix__corner", role: "columnheader", children: "Impact" }),
1431
+ riskProbabilityLevels.map((probability) => /* @__PURE__ */ jsxs(
1432
+ "div",
1433
+ {
1434
+ className: "eth-domain-risk-matrix__axis",
1435
+ role: "columnheader",
1436
+ children: [
1437
+ /* @__PURE__ */ jsx("span", { children: "Probability" }),
1438
+ /* @__PURE__ */ jsx("strong", { children: riskProbabilityLabels[probability] })
1439
+ ]
1440
+ },
1441
+ probability
1442
+ ))
1443
+ ]
1444
+ }
1445
+ ),
1446
+ riskImpactLevels.map((impact) => /* @__PURE__ */ jsxs("div", { className: "eth-domain-risk-matrix__grid-row", role: "row", children: [
1447
+ /* @__PURE__ */ jsxs(
1448
+ "div",
1449
+ {
1450
+ className: "eth-domain-risk-matrix__axis eth-domain-risk-matrix__row-axis",
1451
+ role: "rowheader",
1452
+ children: [
1453
+ /* @__PURE__ */ jsx("span", { children: "Impact" }),
1454
+ /* @__PURE__ */ jsx("strong", { children: riskImpactLabels[impact] })
1455
+ ]
1456
+ }
1457
+ ),
1458
+ riskProbabilityLevels.map((probability) => {
1459
+ const cellRisks = risks.filter(
1460
+ (item) => item.resolvedImpact === impact && item.resolvedProbability === probability
1461
+ );
1462
+ const cellSeverity = cellRisks[0]?.resolvedSeverity ?? riskSeverityFromScore(impact, probability);
1463
+ return /* @__PURE__ */ jsx(
1464
+ "div",
1465
+ {
1466
+ className: "eth-domain-risk-matrix__cell",
1467
+ "data-severity": cellSeverity,
1468
+ role: "gridcell",
1469
+ "aria-label": `${riskImpactLabels[impact]} impact, ${riskProbabilityLabels[probability]} probability: ${riskCountLabel(cellRisks.length)}`,
1470
+ children: cellRisks.length ? /* @__PURE__ */ jsx("div", { className: "eth-domain-risk-matrix__cell-risks", role: "list", children: cellRisks.map((risk) => {
1471
+ const labelContent = risk.href ? /* @__PURE__ */ jsx("a", { href: risk.href, children: risk.label }) : risk.label;
1472
+ return /* @__PURE__ */ jsxs(
1473
+ "article",
1474
+ {
1475
+ className: "eth-domain-risk-matrix__risk-card",
1476
+ "data-severity": risk.resolvedSeverity,
1477
+ role: "listitem",
1478
+ children: [
1479
+ /* @__PURE__ */ jsx("span", { className: "eth-domain-risk-matrix__risk-score", children: risk.score ?? risk.resolvedScore }),
1480
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-risk-matrix__risk-card-main", children: [
1481
+ /* @__PURE__ */ jsx("strong", { children: labelContent }),
1482
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-risk-matrix__risk-card-meta", children: [
1483
+ risk.owner ? /* @__PURE__ */ jsx("span", { children: risk.owner }) : null,
1484
+ risk.dueDate ? /* @__PURE__ */ jsx("span", { children: risk.dueDate }) : null
1485
+ ] })
1486
+ ] })
1487
+ ]
1488
+ },
1489
+ risk.id
1490
+ );
1491
+ }) }) : /* @__PURE__ */ jsx("span", { className: "eth-domain-risk-matrix__empty-cell", children: "No risks" })
1492
+ },
1493
+ `${impact}-${probability}`
1494
+ );
1495
+ })
1496
+ ] }, impact))
1497
+ ]
1498
+ }
1499
+ )
1500
+ ]
1501
+ }
1502
+ ) : null,
1503
+ /* @__PURE__ */ jsxs("aside", { className: "eth-domain-risk-matrix__detail", "aria-label": "Highest priority risk", children: [
1504
+ priorityRisk ? /* @__PURE__ */ jsxs(Fragment2, { children: [
1505
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-risk-matrix__panel-header", children: [
1506
+ /* @__PURE__ */ jsxs("div", { children: [
1507
+ /* @__PURE__ */ jsx("span", { children: "Highest priority" }),
1508
+ /* @__PURE__ */ jsx("h3", { children: priorityRisk.label })
1509
+ ] }),
1510
+ /* @__PURE__ */ jsx(StatusDot, { status: priorityStatus, label: statusLabel(priorityStatus) })
1511
+ ] }),
1512
+ priorityRisk.description ? /* @__PURE__ */ jsx("p", { children: priorityRisk.description }) : null,
1513
+ /* @__PURE__ */ jsxs("dl", { className: "eth-domain-risk-matrix__facts", children: [
1514
+ /* @__PURE__ */ jsx(
1515
+ RiskMatrixFact,
1516
+ {
1517
+ label: "Impact",
1518
+ value: riskImpactLabels[priorityRisk.resolvedImpact]
1519
+ }
1520
+ ),
1521
+ /* @__PURE__ */ jsx(
1522
+ RiskMatrixFact,
1523
+ {
1524
+ label: "Probability",
1525
+ value: riskProbabilityLabels[priorityRisk.resolvedProbability]
1526
+ }
1527
+ ),
1528
+ /* @__PURE__ */ jsx(RiskMatrixFact, { label: "Owner", value: priorityRisk.owner }),
1529
+ /* @__PURE__ */ jsx(RiskMatrixFact, { label: "Due", value: priorityRisk.dueDate }),
1530
+ /* @__PURE__ */ jsx(
1531
+ RiskMatrixFact,
1532
+ {
1533
+ label: "Score",
1534
+ value: priorityRisk.score ?? priorityRisk.resolvedScore
1535
+ }
1536
+ ),
1537
+ /* @__PURE__ */ jsx(RiskMatrixFact, { label: "Review", value: reviewCadence })
1538
+ ] }),
1539
+ priorityRisk.mitigation ? /* @__PURE__ */ jsxs("div", { className: "eth-domain-risk-matrix__mitigation", children: [
1540
+ /* @__PURE__ */ jsx("span", { children: "Mitigation" }),
1541
+ /* @__PURE__ */ jsx("strong", { children: priorityRisk.mitigation })
1542
+ ] }) : null,
1543
+ /* @__PURE__ */ jsx(RiskMatrixActions, { actions: priorityRisk.actions })
1544
+ ] }) : /* @__PURE__ */ jsx("p", { className: "eth-domain-risk-matrix__empty", children: "No priority risk selected." }),
1545
+ /* @__PURE__ */ jsxs(
1546
+ "section",
1547
+ {
1548
+ className: "eth-domain-risk-matrix__register",
1549
+ "aria-labelledby": registerHeadingId,
1550
+ children: [
1551
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-risk-matrix__panel-header", children: [
1552
+ /* @__PURE__ */ jsxs("div", { children: [
1553
+ /* @__PURE__ */ jsx("span", { children: "Register" }),
1554
+ /* @__PURE__ */ jsx("h3", { id: registerHeadingId, children: "Mapped risks" })
1555
+ ] }),
1556
+ /* @__PURE__ */ jsx("strong", { children: riskCountLabel(risks.length) })
1557
+ ] }),
1558
+ /* @__PURE__ */ jsx("div", { className: "eth-domain-risk-matrix__register-list", role: "list", children: risks.map((risk) => {
1559
+ const itemStatus = risk.status ?? deriveRiskMatrixStatus([risk]) ?? "active";
1560
+ return /* @__PURE__ */ jsxs(
1561
+ "article",
1562
+ {
1563
+ className: "eth-domain-risk-matrix__register-item",
1564
+ "data-severity": risk.resolvedSeverity,
1565
+ role: "listitem",
1566
+ children: [
1567
+ /* @__PURE__ */ jsxs("div", { children: [
1568
+ /* @__PURE__ */ jsx("strong", { children: risk.label }),
1569
+ /* @__PURE__ */ jsxs("span", { children: [
1570
+ riskImpactLabels[risk.resolvedImpact],
1571
+ " /",
1572
+ " ",
1573
+ riskProbabilityLabels[risk.resolvedProbability]
1574
+ ] })
1575
+ ] }),
1576
+ /* @__PURE__ */ jsx(StatusDot, { status: itemStatus, label: statusLabel(itemStatus) })
1577
+ ]
1578
+ },
1579
+ risk.id
1580
+ );
1581
+ }) })
1582
+ ]
1583
+ }
1584
+ )
1585
+ ] })
1586
+ ] }) : /* @__PURE__ */ jsx("div", { className: "eth-domain-risk-matrix__empty", children: "No risks mapped." }),
1587
+ children
1588
+ ]
1589
+ }
1590
+ );
1591
+ }
1592
+ function InvoiceViewer({
1593
+ title = "Invoice",
1594
+ description,
1595
+ status = "pending-approval",
1596
+ items = [],
1597
+ metadata,
1598
+ actions,
1599
+ footer,
1600
+ children,
1601
+ className,
1602
+ customer,
1603
+ dueDate,
1604
+ terms,
1605
+ owner,
1606
+ subtotal,
1607
+ tax,
1608
+ total,
1609
+ amountDue,
1610
+ payments = [],
1611
+ ...props
1612
+ }) {
1613
+ const computedMetadata = metadata ?? [
1614
+ { label: "Amount due", value: amountDue ?? total },
1615
+ { label: "Due date", value: dueDate },
1616
+ { label: "Terms", value: terms },
1617
+ { label: "Owner", value: owner ?? customer }
1618
+ ].filter((item) => hasDisplayValue(item.value));
1619
+ const summaryRows = [
1620
+ { label: "Subtotal", value: subtotal },
1621
+ { label: "Tax", value: tax },
1622
+ { label: "Total", value: total },
1623
+ { label: "Amount due", value: amountDue ?? total, emphasis: true }
1624
+ ].filter((item) => hasDisplayValue(item.value));
1625
+ return /* @__PURE__ */ jsxs(
1626
+ Surface,
1627
+ {
1628
+ ...props,
1629
+ "data-eth-component": "InvoiceViewer",
1630
+ title,
1631
+ description,
1632
+ status,
1633
+ metadata: computedMetadata.length ? computedMetadata : void 0,
1634
+ actions,
1635
+ footer,
1636
+ className: ["eth-domain-invoice-viewer", className].filter(Boolean).join(" "),
1637
+ children: [
1638
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-invoice-viewer__body", children: [
1639
+ /* @__PURE__ */ jsxs("section", { className: "eth-domain-invoice-viewer__section", "aria-label": "Invoice line items", children: [
1640
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-invoice-viewer__section-header", children: [
1641
+ /* @__PURE__ */ jsxs("div", { children: [
1642
+ /* @__PURE__ */ jsx("span", { children: "Charges" }),
1643
+ /* @__PURE__ */ jsx("h3", { children: "Line items" })
1644
+ ] }),
1645
+ /* @__PURE__ */ jsxs("strong", { children: [
1646
+ items.length,
1647
+ " item",
1648
+ items.length === 1 ? "" : "s"
1649
+ ] })
1650
+ ] }),
1651
+ items.length ? /* @__PURE__ */ jsx("div", { className: "eth-domain-invoice-viewer__table-wrap", children: /* @__PURE__ */ jsxs("table", { className: "eth-domain-invoice-viewer__table", children: [
1652
+ /* @__PURE__ */ jsx("caption", { className: "eth-domain-invoice-viewer__caption", children: "Invoice line items" }),
1653
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
1654
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Item" }),
1655
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Qty" }),
1656
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Rate" }),
1657
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Amount" })
1658
+ ] }) }),
1659
+ /* @__PURE__ */ jsx("tbody", { children: items.map((item) => {
1660
+ const itemStatus = item.status ?? "not-started";
1661
+ const labelContent = item.href ? /* @__PURE__ */ jsx("a", { href: item.href, children: item.label }) : item.label;
1662
+ return /* @__PURE__ */ jsxs("tr", { "data-status": itemStatus, children: [
1663
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("div", { className: "eth-domain-invoice-viewer__line-item", children: [
1664
+ /* @__PURE__ */ jsx("strong", { children: labelContent }),
1665
+ item.description ? /* @__PURE__ */ jsx("p", { children: item.description }) : null,
1666
+ item.status ? /* @__PURE__ */ jsx(StatusDot, { status: item.status, label: statusLabel(item.status) }) : null
1667
+ ] }) }),
1668
+ /* @__PURE__ */ jsx("td", { children: item.quantity ?? "1" }),
1669
+ /* @__PURE__ */ jsx("td", { children: item.rate ?? "-" }),
1670
+ /* @__PURE__ */ jsx("td", { children: item.amount ?? item.meta ?? "-" })
1671
+ ] }, item.id);
1672
+ }) })
1673
+ ] }) }) : /* @__PURE__ */ jsx("p", { className: "eth-domain-invoice-viewer__empty", children: "No invoice line items available." })
1674
+ ] }),
1675
+ /* @__PURE__ */ jsxs("aside", { className: "eth-domain-invoice-viewer__section", "aria-label": "Payment summary", children: [
1676
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-invoice-viewer__section-header", children: [
1677
+ /* @__PURE__ */ jsxs("div", { children: [
1678
+ /* @__PURE__ */ jsx("span", { children: "Payment" }),
1679
+ /* @__PURE__ */ jsx("h3", { children: "Summary" })
1680
+ ] }),
1681
+ /* @__PURE__ */ jsx(StatusDot, { status, label: statusLabel(status) })
1682
+ ] }),
1683
+ summaryRows.length ? /* @__PURE__ */ jsx("dl", { className: "eth-domain-invoice-viewer__totals", children: summaryRows.map((row, index) => /* @__PURE__ */ jsxs(
1684
+ "div",
1685
+ {
1686
+ className: row.emphasis ? "eth-domain-invoice-viewer__total" : void 0,
1687
+ children: [
1688
+ /* @__PURE__ */ jsx("dt", { children: row.label }),
1689
+ /* @__PURE__ */ jsx("dd", { children: row.value })
1690
+ ]
1691
+ },
1692
+ index
1693
+ )) }) : null,
1694
+ payments.length ? /* @__PURE__ */ jsx("ol", { className: "eth-domain-invoice-viewer__payments", "aria-label": "Payment milestones", children: payments.map((payment) => {
1695
+ const paymentStatus = payment.status ?? "queued";
1696
+ return /* @__PURE__ */ jsxs("li", { "data-status": paymentStatus, children: [
1697
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-invoice-viewer__payment-main", children: [
1698
+ /* @__PURE__ */ jsx("strong", { children: payment.label }),
1699
+ payment.dueDate || payment.description ? /* @__PURE__ */ jsx("span", { children: payment.dueDate ?? payment.description }) : null
1700
+ ] }),
1701
+ hasDisplayValue(payment.amount ?? payment.meta) ? /* @__PURE__ */ jsx("span", { className: "eth-domain-invoice-viewer__payment-amount", children: payment.amount ?? payment.meta }) : null
1702
+ ] }, payment.id);
1703
+ }) }) : null
1704
+ ] })
1705
+ ] }),
1706
+ children
1707
+ ]
1708
+ }
1709
+ );
1710
+ }
1711
+ function KnowledgeBaseArticleViewer({
1712
+ title = "Knowledge base article",
1713
+ description,
1714
+ status = "active",
1715
+ metadata,
1716
+ actions,
1717
+ footer,
1718
+ children,
1719
+ className,
1720
+ body,
1721
+ sections,
1722
+ relatedArticles,
1723
+ citations = defaultKnowledgeBaseCitations,
1724
+ items,
1725
+ articleStatusLabel,
1726
+ ...props
1727
+ }) {
1728
+ const hasBody = hasKnowledgeBaseNode(body) || React.Children.count(children) > 0;
1729
+ const articleSections = sections ?? (hasBody ? [] : defaultKnowledgeBaseSections);
1730
+ const related = relatedArticles ?? items ?? defaultKnowledgeBaseRelatedArticles;
1731
+ const articleHeadingId = React.useId();
1732
+ const relatedHeadingId = React.useId();
1733
+ const citationsHeadingId = React.useId();
1734
+ return /* @__PURE__ */ jsx(
1735
+ Surface,
1736
+ {
1737
+ ...props,
1738
+ "data-eth-component": "KnowledgeBaseArticleViewer",
1739
+ title,
1740
+ description,
1741
+ status,
1742
+ metadata,
1743
+ actions,
1744
+ footer,
1745
+ className: ["eth-domain-knowledge-base-viewer", className].filter(Boolean).join(" "),
1746
+ children: /* @__PURE__ */ jsxs("div", { className: "eth-domain-knowledge-base-viewer__workspace", children: [
1747
+ /* @__PURE__ */ jsxs(
1748
+ "article",
1749
+ {
1750
+ className: "eth-domain-knowledge-base-viewer__article",
1751
+ "aria-labelledby": articleHeadingId,
1752
+ children: [
1753
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-knowledge-base-viewer__article-header", children: [
1754
+ /* @__PURE__ */ jsxs("div", { children: [
1755
+ /* @__PURE__ */ jsx("span", { children: "Article body" }),
1756
+ /* @__PURE__ */ jsx("h3", { id: articleHeadingId, children: "Guidance" })
1757
+ ] }),
1758
+ /* @__PURE__ */ jsx(
1759
+ StatusDot,
1760
+ {
1761
+ status,
1762
+ label: articleStatusLabel ?? knowledgeBaseStatusLabel(status)
1763
+ }
1764
+ )
1765
+ ] }),
1766
+ hasBody ? /* @__PURE__ */ jsxs("div", { className: "eth-domain-knowledge-base-viewer__body", children: [
1767
+ renderKnowledgeBaseNode(body),
1768
+ children
1769
+ ] }) : null,
1770
+ articleSections.length ? /* @__PURE__ */ jsx("div", { className: "eth-domain-knowledge-base-viewer__sections", children: articleSections.map((section) => /* @__PURE__ */ jsxs(
1771
+ "section",
1772
+ {
1773
+ className: "eth-domain-knowledge-base-viewer__section",
1774
+ "data-status": section.status,
1775
+ children: [
1776
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-knowledge-base-viewer__section-heading", children: [
1777
+ /* @__PURE__ */ jsx("h4", { children: section.title }),
1778
+ section.status ? /* @__PURE__ */ jsx(StatusDot, { status: section.status, label: statusLabel(section.status) }) : null
1779
+ ] }),
1780
+ renderKnowledgeBaseNode(section.body)
1781
+ ]
1782
+ },
1783
+ section.id
1784
+ )) }) : null
1785
+ ]
1786
+ }
1787
+ ),
1788
+ /* @__PURE__ */ jsxs("aside", { className: "eth-domain-knowledge-base-viewer__rail", children: [
1789
+ /* @__PURE__ */ jsxs(
1790
+ "section",
1791
+ {
1792
+ className: "eth-domain-knowledge-base-viewer__panel",
1793
+ "aria-labelledby": relatedHeadingId,
1794
+ children: [
1795
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-knowledge-base-viewer__panel-header", children: [
1796
+ /* @__PURE__ */ jsx("span", { children: "Knowledge graph" }),
1797
+ /* @__PURE__ */ jsx("h3", { id: relatedHeadingId, children: "Related content" })
1798
+ ] }),
1799
+ related.length ? /* @__PURE__ */ jsx("div", { className: "eth-domain-knowledge-base-viewer__related-list", role: "list", children: related.map((item) => {
1800
+ const labelContent = item.href ? /* @__PURE__ */ jsx("a", { href: item.href, children: item.label }) : item.label;
1801
+ return /* @__PURE__ */ jsxs(
1802
+ "article",
1803
+ {
1804
+ className: "eth-domain-knowledge-base-viewer__related-item",
1805
+ role: "listitem",
1806
+ children: [
1807
+ /* @__PURE__ */ jsxs("div", { children: [
1808
+ /* @__PURE__ */ jsx("strong", { children: labelContent }),
1809
+ item.description ? /* @__PURE__ */ jsx("p", { children: item.description }) : null
1810
+ ] }),
1811
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-knowledge-base-viewer__item-meta", children: [
1812
+ item.type ?? item.meta ? /* @__PURE__ */ jsx("span", { children: item.type ?? item.meta }) : null,
1813
+ item.updatedAt ? /* @__PURE__ */ jsx("span", { children: item.updatedAt }) : null,
1814
+ item.status ? /* @__PURE__ */ jsx(StatusDot, { status: item.status, label: statusLabel(item.status) }) : null
1815
+ ] })
1816
+ ]
1817
+ },
1818
+ item.id
1819
+ );
1820
+ }) }) : /* @__PURE__ */ jsx("p", { className: "eth-domain-knowledge-base-viewer__empty", children: "No related content linked." })
1821
+ ]
1822
+ }
1823
+ ),
1824
+ /* @__PURE__ */ jsxs(
1825
+ "section",
1826
+ {
1827
+ className: "eth-domain-knowledge-base-viewer__panel",
1828
+ "aria-labelledby": citationsHeadingId,
1829
+ children: [
1830
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-knowledge-base-viewer__panel-header", children: [
1831
+ /* @__PURE__ */ jsx("span", { children: "Evidence" }),
1832
+ /* @__PURE__ */ jsx("h3", { id: citationsHeadingId, children: "Citations" })
1833
+ ] }),
1834
+ citations.length ? /* @__PURE__ */ jsx("ol", { className: "eth-domain-knowledge-base-viewer__citations", children: citations.map((citation) => {
1835
+ const labelContent = citation.href ? /* @__PURE__ */ jsx("a", { href: citation.href, children: citation.label }) : citation.label;
1836
+ return /* @__PURE__ */ jsxs("li", { children: [
1837
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-knowledge-base-viewer__citation-main", children: [
1838
+ /* @__PURE__ */ jsx("strong", { children: labelContent }),
1839
+ citation.source ? /* @__PURE__ */ jsx("span", { children: citation.source }) : null,
1840
+ renderKnowledgeBaseNode(citation.excerpt)
1841
+ ] }),
1842
+ citation.status ? /* @__PURE__ */ jsx(StatusDot, { status: citation.status, label: statusLabel(citation.status) }) : null
1843
+ ] }, citation.id);
1844
+ }) }) : /* @__PURE__ */ jsx("p", { className: "eth-domain-knowledge-base-viewer__empty", children: "No citations attached." })
1845
+ ]
1846
+ }
1847
+ )
1848
+ ] })
1849
+ ] })
1850
+ }
1851
+ );
1852
+ }
1853
+ var defaultDataImportSteps = [
1854
+ {
1855
+ id: "upload",
1856
+ label: "Upload CSV",
1857
+ description: "File accepted and parsed into a preview set.",
1858
+ status: "completed"
1859
+ },
1860
+ {
1861
+ id: "map",
1862
+ label: "Map fields",
1863
+ description: "Match source columns to the destination object.",
1864
+ status: "in-progress"
1865
+ },
1866
+ {
1867
+ id: "validate",
1868
+ label: "Validate",
1869
+ description: "Run required field and duplicate checks.",
1870
+ status: "queued"
1871
+ },
1872
+ {
1873
+ id: "submit",
1874
+ label: "Submit",
1875
+ description: "Create records after validation passes.",
1876
+ status: "not-started"
1877
+ }
1878
+ ];
1879
+ function dataImportStatusFromSteps(steps) {
1880
+ if (!steps.length) return void 0;
1881
+ if (steps.some((step) => step.status === "blocked" || step.status === "failed")) {
1882
+ return "blocked";
1883
+ }
1884
+ if (steps.every((step) => step.status === "completed" || step.status === "succeeded")) {
1885
+ return "completed";
1886
+ }
1887
+ if (steps.some(
1888
+ (step) => step.status === "in-progress" || step.status === "running" || step.status === "active"
1889
+ )) {
1890
+ return "in-progress";
1891
+ }
1892
+ if (steps.some((step) => step.status === "queued" || step.status === "pending-approval")) {
1893
+ return "queued";
1894
+ }
1895
+ return "not-started";
1896
+ }
1897
+ function isCompletedImportStep(status) {
1898
+ return status === "completed" || status === "succeeded" || status === "synced";
1899
+ }
1900
+ function isCurrentImportStep(status) {
1901
+ return status === "in-progress" || status === "running" || status === "active";
1902
+ }
1903
+ function currentImportStepIndex(steps) {
1904
+ const activeIndex = steps.findIndex((step) => isCurrentImportStep(step.status));
1905
+ if (activeIndex >= 0) return activeIndex;
1906
+ const nextIndex = steps.findIndex((step) => !isCompletedImportStep(step.status));
1907
+ return nextIndex >= 0 ? nextIndex : Math.max(steps.length - 1, 0);
1908
+ }
1909
+ function DataImportWizard({
1910
+ title = "Data import",
1911
+ description = "Import, map, validate, and submit records.",
1912
+ items = defaultDataImportSteps,
1913
+ metadata,
1914
+ status,
1915
+ actions,
1916
+ footer,
1917
+ children,
1918
+ className,
1919
+ fileName,
1920
+ sourceLabel,
1921
+ rowCount,
1922
+ columnCount,
1923
+ mappingCount,
1924
+ validationSummary,
1925
+ mappings = [],
1926
+ validationIssues = [],
1927
+ ...props
1928
+ }) {
1929
+ const currentIndex = currentImportStepIndex(items);
1930
+ const completeCount = items.filter((item) => isCompletedImportStep(item.status)).length;
1931
+ const computedMetadata = metadata ?? [
1932
+ { label: "File", value: fileName },
1933
+ { label: "Rows", value: rowCount },
1934
+ { label: "Columns", value: columnCount },
1935
+ { label: "Mapped", value: mappingCount },
1936
+ { label: "Validation", value: validationSummary }
1937
+ ].filter((item) => hasDisplayValue(item.value));
1938
+ return /* @__PURE__ */ jsxs(
1939
+ Surface,
1940
+ {
1941
+ ...props,
1942
+ "data-eth-component": "DataImportWizard",
1943
+ title,
1944
+ description,
1945
+ status: status ?? dataImportStatusFromSteps(items),
1946
+ metadata: computedMetadata.length ? computedMetadata : void 0,
1947
+ actions,
1948
+ footer,
1949
+ className: ["eth-domain-data-import-wizard", className].filter(Boolean).join(" "),
1950
+ children: [
1951
+ /* @__PURE__ */ jsx("ol", { className: "eth-domain-data-import-wizard__steps", "aria-label": "Data import progress", children: items.map((step, index) => {
1952
+ const stepStatus = step.status ?? "not-started";
1953
+ return /* @__PURE__ */ jsxs(
1954
+ "li",
1955
+ {
1956
+ "aria-current": index === currentIndex ? "step" : void 0,
1957
+ className: "eth-domain-data-import-wizard__step",
1958
+ "data-current": index === currentIndex ? "true" : void 0,
1959
+ "data-status": stepStatus,
1960
+ children: [
1961
+ /* @__PURE__ */ jsx("span", { className: "eth-domain-data-import-wizard__step-marker", "aria-hidden": "true", children: index + 1 }),
1962
+ /* @__PURE__ */ jsxs("span", { className: "eth-domain-data-import-wizard__step-copy", children: [
1963
+ /* @__PURE__ */ jsx("strong", { children: step.label }),
1964
+ step.description ? /* @__PURE__ */ jsx("span", { children: step.description }) : null
1965
+ ] }),
1966
+ /* @__PURE__ */ jsx(StatusDot, { status: stepStatus, label: statusLabel(stepStatus) })
1967
+ ]
1968
+ },
1969
+ step.id
1970
+ );
1971
+ }) }),
1972
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-data-import-wizard__workspace", children: [
1973
+ /* @__PURE__ */ jsxs("section", { className: "eth-domain-data-import-wizard__panel", "aria-label": "Upload summary", children: [
1974
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-data-import-wizard__panel-header", children: [
1975
+ /* @__PURE__ */ jsx("span", { children: "Source" }),
1976
+ /* @__PURE__ */ jsx("strong", { children: fileName ?? "No file selected" })
1977
+ ] }),
1978
+ /* @__PURE__ */ jsxs("dl", { className: "eth-domain-data-import-wizard__facts", children: [
1979
+ hasDisplayValue(sourceLabel) ? /* @__PURE__ */ jsxs("div", { children: [
1980
+ /* @__PURE__ */ jsx("dt", { children: "Import type" }),
1981
+ /* @__PURE__ */ jsx("dd", { children: sourceLabel })
1982
+ ] }) : null,
1983
+ hasDisplayValue(rowCount) ? /* @__PURE__ */ jsxs("div", { children: [
1984
+ /* @__PURE__ */ jsx("dt", { children: "Rows detected" }),
1985
+ /* @__PURE__ */ jsx("dd", { children: rowCount })
1986
+ ] }) : null,
1987
+ hasDisplayValue(columnCount) ? /* @__PURE__ */ jsxs("div", { children: [
1988
+ /* @__PURE__ */ jsx("dt", { children: "Columns" }),
1989
+ /* @__PURE__ */ jsx("dd", { children: columnCount })
1990
+ ] }) : null,
1991
+ /* @__PURE__ */ jsxs("div", { children: [
1992
+ /* @__PURE__ */ jsx("dt", { children: "Progress" }),
1993
+ /* @__PURE__ */ jsx("dd", { children: items.length ? `${completeCount}/${items.length} steps complete` : "No steps configured" })
1994
+ ] })
1995
+ ] })
1996
+ ] }),
1997
+ mappings.length ? /* @__PURE__ */ jsxs("section", { className: "eth-domain-data-import-wizard__panel eth-domain-data-import-wizard__panel--wide", children: [
1998
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-data-import-wizard__panel-header", children: [
1999
+ /* @__PURE__ */ jsx("span", { children: "Field mapping" }),
2000
+ /* @__PURE__ */ jsx("strong", { children: mappingCount ?? `${mappings.length} fields` })
2001
+ ] }),
2002
+ /* @__PURE__ */ jsx("div", { className: "eth-domain-data-import-wizard__table-wrap", children: /* @__PURE__ */ jsxs("table", { className: "eth-domain-data-import-wizard__table", children: [
2003
+ /* @__PURE__ */ jsx("caption", { children: "CSV fields mapped to destination properties" }),
2004
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
2005
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Source field" }),
2006
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Destination" }),
2007
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Sample" }),
2008
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "State" })
2009
+ ] }) }),
2010
+ /* @__PURE__ */ jsx("tbody", { children: mappings.map((mapping) => {
2011
+ const mappingStatus = mapping.status ?? "not-started";
2012
+ return /* @__PURE__ */ jsxs("tr", { "data-status": mappingStatus, children: [
2013
+ /* @__PURE__ */ jsxs("td", { children: [
2014
+ /* @__PURE__ */ jsx("strong", { children: mapping.sourceField }),
2015
+ mapping.required ? /* @__PURE__ */ jsx("span", { children: "Required" }) : null
2016
+ ] }),
2017
+ /* @__PURE__ */ jsx("td", { children: mapping.targetField }),
2018
+ /* @__PURE__ */ jsx("td", { children: mapping.sample ?? "No sample" }),
2019
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx(StatusDot, { status: mappingStatus, label: statusLabel(mappingStatus) }) })
2020
+ ] }, mapping.id);
2021
+ }) })
2022
+ ] }) })
2023
+ ] }) : null,
2024
+ validationIssues.length || hasDisplayValue(validationSummary) ? /* @__PURE__ */ jsxs("section", { className: "eth-domain-data-import-wizard__panel", children: [
2025
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-data-import-wizard__panel-header", children: [
2026
+ /* @__PURE__ */ jsx("span", { children: "Validation" }),
2027
+ /* @__PURE__ */ jsx("strong", { children: validationSummary ?? "Ready to run" })
2028
+ ] }),
2029
+ validationIssues.length ? /* @__PURE__ */ jsx("ul", { className: "eth-domain-data-import-wizard__issues", "aria-label": "Validation issues", children: validationIssues.map((issue) => {
2030
+ const issueStatus = issue.status ?? "warning";
2031
+ return /* @__PURE__ */ jsxs("li", { "data-status": issueStatus, children: [
2032
+ /* @__PURE__ */ jsxs("div", { children: [
2033
+ /* @__PURE__ */ jsx("strong", { children: issue.field }),
2034
+ /* @__PURE__ */ jsx("span", { children: issue.message })
2035
+ ] }),
2036
+ hasDisplayValue(issue.count) ? /* @__PURE__ */ jsx("span", { children: issue.count }) : null
2037
+ ] }, issue.id);
2038
+ }) }) : /* @__PURE__ */ jsx("p", { className: "eth-domain-data-import-wizard__empty-note", children: "No validation issues have been detected." })
2039
+ ] }) : null
2040
+ ] }),
2041
+ children
2042
+ ]
2043
+ }
2044
+ );
2045
+ }
2046
+ var defaultMappingTargetOptions = [
2047
+ { value: "", label: "Select target field", disabled: true },
2048
+ { value: "contact.firstName", label: "Contact / First name" },
2049
+ { value: "contact.lastName", label: "Contact / Last name" },
2050
+ { value: "account.name", label: "Account / Name" },
2051
+ { value: "account.domain", label: "Account / Domain" },
2052
+ { value: "opportunity.amount", label: "Opportunity / Amount" },
2053
+ { value: "opportunity.closeDate", label: "Opportunity / Close date" }
2054
+ ];
2055
+ function parseMappingLabel(label) {
2056
+ const text = textFromNode(label).trim();
2057
+ const match = text.match(/^(.*?)\s*(?:→|->)\s*(.*?)$/);
2058
+ if (!match) return void 0;
2059
+ return {
2060
+ source: match[1].trim(),
2061
+ target: match[2].trim()
2062
+ };
2063
+ }
2064
+ function mappingSource(item) {
2065
+ return item.sourceField ?? parseMappingLabel(item.label)?.source ?? item.label;
2066
+ }
2067
+ function mappingTarget(item) {
2068
+ return item.targetField ?? parseMappingLabel(item.label)?.target;
2069
+ }
2070
+ function selectableValue(value) {
2071
+ if (typeof value === "string" || typeof value === "number") return String(value);
2072
+ return void 0;
2073
+ }
2074
+ function mappingItemStatus(item) {
2075
+ return item.status ?? (hasDisplayValue(mappingTarget(item)) ? "active" : "warning");
2076
+ }
2077
+ function isMappingUnresolved(item) {
2078
+ const status = mappingItemStatus(item);
2079
+ return !hasDisplayValue(mappingTarget(item)) || status === "warning" || status === "blocked" || status === "failed" || status === "approval-required";
2080
+ }
2081
+ function mappingWizardStatus(items, issues) {
2082
+ if (!items.length) return "not-started";
2083
+ if (items.some(
2084
+ (item) => ["blocked", "failed", "approval-required"].includes(mappingItemStatus(item))
2085
+ ) || issues.some(
2086
+ (issue) => ["blocked", "failed", "approval-required"].includes(issue.status ?? "warning")
2087
+ )) {
2088
+ return "blocked";
2089
+ }
2090
+ if (items.some(isMappingUnresolved) || issues.length) return "warning";
2091
+ return "active";
2092
+ }
2093
+ function optionsForMapping(options, value) {
2094
+ if (!value || options.some((option) => option.value === value)) return options;
2095
+ return [...options, { value, label: value }];
2096
+ }
2097
+ function MappingConfigurationWizard({
2098
+ title = "Mapping configuration",
2099
+ description = "Configure how source fields map into destination objects.",
2100
+ items = [],
2101
+ sourceObject,
2102
+ targetObject,
2103
+ mappingCount,
2104
+ validationSummary,
2105
+ targetOptions = defaultMappingTargetOptions,
2106
+ validationIssues = [],
2107
+ metadata,
2108
+ status,
2109
+ actions,
2110
+ footer,
2111
+ children,
2112
+ className,
2113
+ onMappingChange,
2114
+ onAutoMap,
2115
+ onValidate,
2116
+ onSubmit,
2117
+ ...props
2118
+ }) {
2119
+ const [targetOverrides, setTargetOverrides] = React.useState({});
2120
+ React.useEffect(() => {
2121
+ setTargetOverrides({});
2122
+ }, [items]);
2123
+ const resolvedMappingTarget = React.useCallback(
2124
+ (item) => targetOverrides[item.id] ?? mappingTarget(item),
2125
+ [targetOverrides]
2126
+ );
2127
+ const resolvedMappingStatus = React.useCallback(
2128
+ (item) => item.status ?? (hasDisplayValue(resolvedMappingTarget(item)) ? "active" : "warning"),
2129
+ [resolvedMappingTarget]
2130
+ );
2131
+ const isResolvedMappingUnresolved = React.useCallback(
2132
+ (item) => {
2133
+ const itemStatus = resolvedMappingStatus(item);
2134
+ return !hasDisplayValue(resolvedMappingTarget(item)) || itemStatus === "warning" || itemStatus === "blocked" || itemStatus === "failed" || itemStatus === "approval-required";
2135
+ },
2136
+ [resolvedMappingStatus, resolvedMappingTarget]
2137
+ );
2138
+ const mappedCount = items.filter((item) => hasDisplayValue(resolvedMappingTarget(item))).length;
2139
+ const unresolvedCount = items.filter(isResolvedMappingUnresolved).length + validationIssues.length;
2140
+ const resolvedItems = items.map((item) => ({
2141
+ ...item,
2142
+ targetField: resolvedMappingTarget(item),
2143
+ status: resolvedMappingStatus(item)
2144
+ }));
2145
+ const computedStatus = status ?? mappingWizardStatus(resolvedItems, validationIssues);
2146
+ const computedValidationSummary = validationSummary ?? (unresolvedCount ? `${unresolvedCount} ${unresolvedCount === 1 ? "issue" : "issues"} to resolve` : "Ready to apply");
2147
+ const mappingProgressLabel = mappingCount ?? (items.length ? `${mappedCount}/${items.length}` : "No fields");
2148
+ const computedMetadata = metadata ?? [
2149
+ { label: "Source object", value: sourceObject },
2150
+ { label: "Target object", value: targetObject },
2151
+ { label: "Mapped", value: mappingProgressLabel },
2152
+ { label: "Validation", value: computedValidationSummary }
2153
+ ].filter((item) => hasDisplayValue(item.value));
2154
+ const wizardSteps = [
2155
+ {
2156
+ id: "source",
2157
+ label: "Source",
2158
+ description: items.length ? `${items.length} fields detected` : "No fields loaded",
2159
+ status: items.length ? "completed" : "not-started"
2160
+ },
2161
+ {
2162
+ id: "mapping",
2163
+ label: "Map",
2164
+ description: items.length ? `${mappedCount}/${items.length} mapped` : "Awaiting source",
2165
+ status: !items.length ? "not-started" : mappedCount === items.length ? "completed" : "in-progress"
2166
+ },
2167
+ {
2168
+ id: "validation",
2169
+ label: "Validate",
2170
+ description: computedValidationSummary,
2171
+ status: computedStatus === "blocked" ? "blocked" : unresolvedCount ? "warning" : "completed"
2172
+ },
2173
+ {
2174
+ id: "review",
2175
+ label: "Review",
2176
+ description: unresolvedCount ? "Resolve issues first" : "Ready for sync",
2177
+ status: unresolvedCount ? "not-started" : "queued"
2178
+ }
2179
+ ];
2180
+ const currentStepIndex = wizardSteps.findIndex((step) => !isCompletedImportStep(step.status));
2181
+ const currentIndex = currentStepIndex >= 0 ? currentStepIndex : wizardSteps.length - 1;
2182
+ return /* @__PURE__ */ jsxs(
2183
+ Surface,
2184
+ {
2185
+ ...props,
2186
+ "data-eth-component": "MappingConfigurationWizard",
2187
+ title,
2188
+ description,
2189
+ status: computedStatus,
2190
+ metadata: computedMetadata.length ? computedMetadata : void 0,
2191
+ actions,
2192
+ className: ["eth-domain-mapping-config-wizard", className].filter(Boolean).join(" "),
2193
+ children: [
2194
+ /* @__PURE__ */ jsx("ol", { className: "eth-domain-mapping-config-wizard__steps", "aria-label": "Mapping progress", children: wizardSteps.map((step, index) => /* @__PURE__ */ jsxs(
2195
+ "li",
2196
+ {
2197
+ "aria-current": index === currentIndex ? "step" : void 0,
2198
+ className: "eth-domain-mapping-config-wizard__step",
2199
+ "data-current": index === currentIndex ? "true" : void 0,
2200
+ "data-status": step.status,
2201
+ children: [
2202
+ /* @__PURE__ */ jsx("span", { className: "eth-domain-mapping-config-wizard__step-marker", "aria-hidden": "true", children: index + 1 }),
2203
+ /* @__PURE__ */ jsxs("span", { className: "eth-domain-mapping-config-wizard__step-copy", children: [
2204
+ /* @__PURE__ */ jsx("strong", { children: step.label }),
2205
+ /* @__PURE__ */ jsx("span", { children: step.description })
2206
+ ] }),
2207
+ /* @__PURE__ */ jsx(StatusDot, { status: step.status, label: statusLabel(step.status) })
2208
+ ]
2209
+ },
2210
+ step.id
2211
+ )) }),
2212
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-mapping-config-wizard__workspace", children: [
2213
+ /* @__PURE__ */ jsxs("aside", { className: "eth-domain-mapping-config-wizard__panel", "aria-label": "Object scope", children: [
2214
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-mapping-config-wizard__panel-header", children: [
2215
+ /* @__PURE__ */ jsx("span", { children: "Objects" }),
2216
+ /* @__PURE__ */ jsxs("strong", { children: [
2217
+ sourceObject ?? "Source object",
2218
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: " -> " }),
2219
+ targetObject ?? "Target object"
2220
+ ] })
2221
+ ] }),
2222
+ /* @__PURE__ */ jsxs("dl", { className: "eth-domain-mapping-config-wizard__facts", children: [
2223
+ /* @__PURE__ */ jsxs("div", { children: [
2224
+ /* @__PURE__ */ jsx("dt", { children: "Source object" }),
2225
+ /* @__PURE__ */ jsx("dd", { children: sourceObject ?? "Not selected" })
2226
+ ] }),
2227
+ /* @__PURE__ */ jsxs("div", { children: [
2228
+ /* @__PURE__ */ jsx("dt", { children: "Target object" }),
2229
+ /* @__PURE__ */ jsx("dd", { children: targetObject ?? "Not selected" })
2230
+ ] }),
2231
+ /* @__PURE__ */ jsxs("div", { children: [
2232
+ /* @__PURE__ */ jsx("dt", { children: "Mapped fields" }),
2233
+ /* @__PURE__ */ jsx("dd", { children: mappingProgressLabel })
2234
+ ] }),
2235
+ /* @__PURE__ */ jsxs("div", { children: [
2236
+ /* @__PURE__ */ jsx("dt", { children: "Validation" }),
2237
+ /* @__PURE__ */ jsx("dd", { children: computedValidationSummary })
2238
+ ] })
2239
+ ] })
2240
+ ] }),
2241
+ /* @__PURE__ */ jsxs(
2242
+ "section",
2243
+ {
2244
+ className: "eth-domain-mapping-config-wizard__panel eth-domain-mapping-config-wizard__panel--mapping",
2245
+ "aria-label": "Field mappings",
2246
+ children: [
2247
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-mapping-config-wizard__panel-header eth-domain-mapping-config-wizard__panel-header--inline", children: [
2248
+ /* @__PURE__ */ jsxs("div", { children: [
2249
+ /* @__PURE__ */ jsx("span", { children: "Field mapping" }),
2250
+ /* @__PURE__ */ jsx("strong", { children: mappingCount ?? (items.length ? `${mappedCount}/${items.length} mapped` : "No fields") })
2251
+ ] }),
2252
+ /* @__PURE__ */ jsx(Button, { type: "button", intent: "tertiary", density: "compact", onClick: onAutoMap, children: "Auto-map" })
2253
+ ] }),
2254
+ items.length ? /* @__PURE__ */ jsx("div", { className: "eth-domain-mapping-config-wizard__table-wrap", children: /* @__PURE__ */ jsxs("table", { className: "eth-domain-mapping-config-wizard__table", children: [
2255
+ /* @__PURE__ */ jsx("caption", { children: "Source fields mapped to destination fields" }),
2256
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
2257
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Source field" }),
2258
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Destination field" }),
2259
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "Transform" }),
2260
+ /* @__PURE__ */ jsx("th", { scope: "col", children: "State" })
2261
+ ] }) }),
2262
+ /* @__PURE__ */ jsx("tbody", { children: items.map((item) => {
2263
+ const source = mappingSource(item);
2264
+ const target = resolvedMappingTarget(item);
2265
+ const targetValue = selectableValue(target);
2266
+ const itemStatus = resolvedMappingStatus(item);
2267
+ const sourceLabel = textFromNode(source) || `mapping-${item.id}`;
2268
+ return /* @__PURE__ */ jsxs("tr", { "data-status": itemStatus, children: [
2269
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("div", { className: "eth-domain-mapping-config-wizard__field-stack", children: [
2270
+ /* @__PURE__ */ jsx("strong", { children: source }),
2271
+ hasDisplayValue(item.sourceType) ? /* @__PURE__ */ jsx("span", { children: item.sourceType }) : null,
2272
+ hasDisplayValue(item.sample) ? /* @__PURE__ */ jsxs("p", { children: [
2273
+ "Sample: ",
2274
+ item.sample
2275
+ ] }) : null
2276
+ ] }) }),
2277
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("div", { className: "eth-domain-mapping-config-wizard__target-field", children: [
2278
+ /* @__PURE__ */ jsx(
2279
+ Select,
2280
+ {
2281
+ labelText: `Destination for ${sourceLabel}`,
2282
+ hideLabel: true,
2283
+ density: "compact",
2284
+ value: targetValue ?? "",
2285
+ options: optionsForMapping(targetOptions, targetValue),
2286
+ invalid: !hasDisplayValue(target),
2287
+ invalidText: "Select a destination field.",
2288
+ onChange: (event) => {
2289
+ const nextTarget = event.currentTarget.value;
2290
+ setTargetOverrides((current) => ({
2291
+ ...current,
2292
+ [item.id]: nextTarget
2293
+ }));
2294
+ onMappingChange?.(item.id, nextTarget);
2295
+ }
2296
+ }
2297
+ ),
2298
+ hasDisplayValue(item.targetType) ? /* @__PURE__ */ jsx("span", { children: item.targetType }) : null
2299
+ ] }) }),
2300
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("div", { className: "eth-domain-mapping-config-wizard__field-stack", children: [
2301
+ /* @__PURE__ */ jsx("strong", { children: item.transform ?? "Direct copy" }),
2302
+ hasDisplayValue(item.description) ? /* @__PURE__ */ jsx("p", { children: item.description }) : null
2303
+ ] }) }),
2304
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("div", { className: "eth-domain-mapping-config-wizard__state", children: [
2305
+ /* @__PURE__ */ jsx(StatusDot, { status: itemStatus, label: statusLabel(itemStatus) }),
2306
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-mapping-config-wizard__badges", children: [
2307
+ item.required ? /* @__PURE__ */ jsx(Badge, { severity: "info", children: "Required" }) : null,
2308
+ hasDisplayValue(item.confidence) ? /* @__PURE__ */ jsx(Badge, { severity: itemStatus === "warning" ? "warning" : "neutral", children: item.confidence }) : null
2309
+ ] })
2310
+ ] }) })
2311
+ ] }, item.id);
2312
+ }) })
2313
+ ] }) }) : /* @__PURE__ */ jsx("p", { className: "eth-domain-mapping-config-wizard__empty", children: "No fields are ready to map." })
2314
+ ]
2315
+ }
2316
+ ),
2317
+ /* @__PURE__ */ jsxs("aside", { className: "eth-domain-mapping-config-wizard__panel", "aria-label": "Validation issues", children: [
2318
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-mapping-config-wizard__panel-header", children: [
2319
+ /* @__PURE__ */ jsx("span", { children: "Validation" }),
2320
+ /* @__PURE__ */ jsx("strong", { children: computedValidationSummary })
2321
+ ] }),
2322
+ validationIssues.length ? /* @__PURE__ */ jsx(
2323
+ "ul",
2324
+ {
2325
+ className: "eth-domain-mapping-config-wizard__issues",
2326
+ "aria-label": "Mapping validation issues",
2327
+ children: validationIssues.map((issue) => {
2328
+ const issueStatus = issue.status ?? "warning";
2329
+ return /* @__PURE__ */ jsxs("li", { "data-status": issueStatus, children: [
2330
+ /* @__PURE__ */ jsxs("div", { children: [
2331
+ /* @__PURE__ */ jsx("strong", { children: issue.field }),
2332
+ /* @__PURE__ */ jsx("span", { children: issue.message })
2333
+ ] }),
2334
+ hasDisplayValue(issue.count) ? /* @__PURE__ */ jsx("span", { children: issue.count }) : null
2335
+ ] }, issue.id);
2336
+ })
2337
+ }
2338
+ ) : /* @__PURE__ */ jsx("p", { className: "eth-domain-mapping-config-wizard__empty-note", children: "No mapping validation issues." })
2339
+ ] })
2340
+ ] }),
2341
+ children,
2342
+ /* @__PURE__ */ jsx("footer", { className: "eth-domain-mapping-config-wizard__footer", children: footer ?? /* @__PURE__ */ jsxs(Fragment2, { children: [
2343
+ /* @__PURE__ */ jsx("span", { children: computedValidationSummary }),
2344
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-mapping-config-wizard__footer-actions", children: [
2345
+ /* @__PURE__ */ jsx(Button, { type: "button", intent: "ghost", density: "compact", children: "Back" }),
2346
+ /* @__PURE__ */ jsx(Button, { type: "button", intent: "secondary", density: "compact", onClick: onValidate, children: "Validate" }),
2347
+ /* @__PURE__ */ jsx(
2348
+ Button,
2349
+ {
2350
+ type: "button",
2351
+ intent: "primary",
2352
+ density: "compact",
2353
+ disabled: Boolean(unresolvedCount),
2354
+ onClick: onSubmit,
2355
+ children: "Apply mapping"
2356
+ }
2357
+ )
2358
+ ] })
2359
+ ] }) })
2360
+ ]
2361
+ }
2362
+ );
2363
+ }
2364
+ function ReportBuilder({
2365
+ title = "Report builder",
2366
+ description,
2367
+ status,
2368
+ metadata,
2369
+ actions,
2370
+ footer,
2371
+ children,
2372
+ className,
2373
+ items = [],
2374
+ formatLabel = "PDF / CSV",
2375
+ owner,
2376
+ updatedAt,
2377
+ onAddSection,
2378
+ onExportPdf,
2379
+ onExportCsv,
2380
+ ...props
2381
+ }) {
2382
+ const sectionsHeadingId = React.useId();
2383
+ const previewHeadingId = React.useId();
2384
+ const includedSections = items.filter((item) => isReportSectionIncluded(item.status));
2385
+ const attentionCount = items.filter((item) => needsReportSectionAttention(item.status)).length;
2386
+ const computedStatus = status ?? deriveReportBuilderStatus(items);
2387
+ const readinessLabel = reportBuilderReadinessLabel(computedStatus, attentionCount);
2388
+ const computedMetadata = metadata ?? [
2389
+ {
2390
+ label: "Sections",
2391
+ value: items.length ? `${items.length} ${items.length === 1 ? "section" : "sections"}` : "No sections"
2392
+ },
2393
+ {
2394
+ label: "Included",
2395
+ value: items.length ? `${includedSections.length}/${items.length}` : "0/0"
2396
+ },
2397
+ { label: "Readiness", value: readinessLabel },
2398
+ { label: "Export", value: formatLabel }
2399
+ ].filter((item) => hasDisplayValue(item.value));
2400
+ const currentSectionIndex = items.findIndex(
2401
+ (item) => item.status === "in-progress" || item.status === "running"
2402
+ );
2403
+ const currentIndex = currentSectionIndex >= 0 ? currentSectionIndex : 0;
2404
+ const exportSummary = items.length ? `${includedSections.length}/${items.length} sections included` : "No sections selected";
2405
+ return /* @__PURE__ */ jsxs(
2406
+ Surface,
2407
+ {
2408
+ ...props,
2409
+ "data-eth-component": "ReportBuilder",
2410
+ title,
2411
+ description,
2412
+ status: computedStatus,
2413
+ metadata: computedMetadata.length ? computedMetadata : void 0,
2414
+ actions,
2415
+ footer,
2416
+ className: ["eth-domain-report-builder", className].filter(Boolean).join(" "),
2417
+ children: [
2418
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-report-builder__workspace", children: [
2419
+ /* @__PURE__ */ jsxs(
2420
+ "section",
2421
+ {
2422
+ className: "eth-domain-report-builder__sections",
2423
+ "aria-labelledby": sectionsHeadingId,
2424
+ children: [
2425
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-report-builder__panel-header eth-domain-report-builder__panel-header--inline", children: [
2426
+ /* @__PURE__ */ jsxs("div", { children: [
2427
+ /* @__PURE__ */ jsx("span", { children: "Composition" }),
2428
+ /* @__PURE__ */ jsx("h3", { id: sectionsHeadingId, children: "Report sections" })
2429
+ ] }),
2430
+ /* @__PURE__ */ jsx(
2431
+ Button,
2432
+ {
2433
+ type: "button",
2434
+ intent: "tertiary",
2435
+ density: "compact",
2436
+ icon: /* @__PURE__ */ jsx(PlusIcon, { size: 16 }),
2437
+ onClick: onAddSection,
2438
+ children: "Add section"
2439
+ }
2440
+ )
2441
+ ] }),
2442
+ items.length ? /* @__PURE__ */ jsx("ol", { className: "eth-domain-report-builder__section-list", "aria-label": "Report sections", children: items.map((item, index) => {
2443
+ const itemStatus = item.status ?? "not-started";
2444
+ const labelContent = item.href ? /* @__PURE__ */ jsx("a", { href: item.href, children: item.label }) : item.label;
2445
+ const meta = reportSectionMeta(item, index);
2446
+ return /* @__PURE__ */ jsxs(
2447
+ "li",
2448
+ {
2449
+ "aria-current": index === currentIndex ? "step" : void 0,
2450
+ className: "eth-domain-report-builder__section-item",
2451
+ "data-current": index === currentIndex ? "true" : void 0,
2452
+ "data-status": itemStatus,
2453
+ children: [
2454
+ /* @__PURE__ */ jsx("span", { className: "eth-domain-report-builder__section-index", "aria-hidden": "true", children: index + 1 }),
2455
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-report-builder__section-main", children: [
2456
+ /* @__PURE__ */ jsx("strong", { children: labelContent }),
2457
+ item.description ? /* @__PURE__ */ jsx("p", { children: item.description }) : null,
2458
+ hasDisplayValue(meta) ? /* @__PURE__ */ jsx("span", { className: "eth-domain-report-builder__section-meta", children: meta }) : null
2459
+ ] }),
2460
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-report-builder__section-state", children: [
2461
+ /* @__PURE__ */ jsx(StatusDot, { status: itemStatus, label: statusLabel(itemStatus) }),
2462
+ item.required ? /* @__PURE__ */ jsx(Badge, { severity: "info", children: "Required" }) : null
2463
+ ] })
2464
+ ]
2465
+ },
2466
+ item.id
2467
+ );
2468
+ }) }) : /* @__PURE__ */ jsx("p", { className: "eth-domain-report-builder__empty", children: "No report sections configured." })
2469
+ ]
2470
+ }
2471
+ ),
2472
+ /* @__PURE__ */ jsxs("section", { className: "eth-domain-report-builder__preview", "aria-label": "Report preview", children: [
2473
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-report-builder__panel-header eth-domain-report-builder__panel-header--inline", children: [
2474
+ /* @__PURE__ */ jsxs("div", { children: [
2475
+ /* @__PURE__ */ jsx("span", { children: "Preview" }),
2476
+ /* @__PURE__ */ jsx("h3", { id: previewHeadingId, children: title })
2477
+ ] }),
2478
+ /* @__PURE__ */ jsx(StatusDot, { status: computedStatus, label: statusLabel(computedStatus) })
2479
+ ] }),
2480
+ /* @__PURE__ */ jsxs(
2481
+ "div",
2482
+ {
2483
+ className: "eth-domain-report-builder__preview-page",
2484
+ "aria-labelledby": previewHeadingId,
2485
+ children: [
2486
+ /* @__PURE__ */ jsx("span", { className: "eth-domain-report-builder__preview-kicker", children: "Draft report" }),
2487
+ /* @__PURE__ */ jsx("strong", { className: "eth-domain-report-builder__preview-title", children: title }),
2488
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-report-builder__preview-meta", children: [
2489
+ hasDisplayValue(owner) ? /* @__PURE__ */ jsxs("span", { children: [
2490
+ "Owner: ",
2491
+ owner
2492
+ ] }) : null,
2493
+ hasDisplayValue(updatedAt) ? /* @__PURE__ */ jsxs("span", { children: [
2494
+ "Updated: ",
2495
+ updatedAt
2496
+ ] }) : null,
2497
+ /* @__PURE__ */ jsx("span", { children: formatLabel })
2498
+ ] }),
2499
+ includedSections.length ? /* @__PURE__ */ jsx("div", { className: "eth-domain-report-builder__preview-lines", children: includedSections.slice(0, 4).map((item, index) => /* @__PURE__ */ jsxs("div", { className: "eth-domain-report-builder__preview-line", children: [
2500
+ /* @__PURE__ */ jsx("span", { children: item.label }),
2501
+ /* @__PURE__ */ jsx("span", { children: reportSectionMeta(item, index) })
2502
+ ] }, item.id)) }) : /* @__PURE__ */ jsx("p", { className: "eth-domain-report-builder__empty-note", children: "Select at least one section to generate a preview." })
2503
+ ]
2504
+ }
2505
+ ),
2506
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-report-builder__export-bar", "aria-label": "Export actions", children: [
2507
+ /* @__PURE__ */ jsx("span", { children: exportSummary }),
2508
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-report-builder__export-actions", children: [
2509
+ /* @__PURE__ */ jsx(
2510
+ Button,
2511
+ {
2512
+ type: "button",
2513
+ intent: "primary",
2514
+ density: "compact",
2515
+ icon: /* @__PURE__ */ jsx(DownloadIcon, { size: 16 }),
2516
+ disabled: !includedSections.length,
2517
+ onClick: onExportPdf,
2518
+ children: "Export PDF"
2519
+ }
2520
+ ),
2521
+ /* @__PURE__ */ jsx(
2522
+ Button,
2523
+ {
2524
+ type: "button",
2525
+ intent: "secondary",
2526
+ density: "compact",
2527
+ icon: /* @__PURE__ */ jsx(TableIcon, { size: 16 }),
2528
+ disabled: !includedSections.length,
2529
+ onClick: onExportCsv,
2530
+ children: "Export CSV"
2531
+ }
2532
+ )
2533
+ ] })
2534
+ ] })
2535
+ ] })
2536
+ ] }),
2537
+ children
2538
+ ]
2539
+ }
2540
+ );
2541
+ }
2542
+ function ApprovalWorkflowEditor({
2543
+ title = "Approval workflow",
2544
+ description = "Configure approval routing, ownership, and conditional gates.",
2545
+ steps,
2546
+ approverOptions = defaultApproverOptions,
2547
+ mode,
2548
+ onChange,
2549
+ onModeChange,
2550
+ className,
2551
+ status,
2552
+ ...props
2553
+ }) {
2554
+ const [internalSteps, setInternalSteps] = React.useState(
2555
+ () => defaultApprovalSteps.map((step) => ({ ...step }))
2556
+ );
2557
+ const [internalMode, setInternalMode] = React.useState("sequential");
2558
+ const currentSteps = steps ?? internalSteps;
2559
+ const currentMode = mode ?? internalMode;
2560
+ const missingApproverCount = currentSteps.filter((step) => !step.approver).length;
2561
+ const requiredCount = currentSteps.filter((step) => step.required).length;
2562
+ const readyCount = currentSteps.length - missingApproverCount;
2563
+ const validationMessage = missingApproverCount ? `${missingApproverCount} approval ${missingApproverCount === 1 ? "step needs" : "steps need"} an approver.` : "All approval steps have owners and can be simulated.";
2564
+ const commitSteps = (nextSteps) => {
2565
+ if (!steps) setInternalSteps(nextSteps);
2566
+ onChange?.(nextSteps);
2567
+ };
2568
+ const updateStep = (index, next) => {
2569
+ const nextSteps = [...currentSteps];
2570
+ nextSteps[index] = next;
2571
+ commitSteps(nextSteps);
2572
+ };
2573
+ const addStep = () => {
2574
+ commitSteps([
2575
+ ...currentSteps,
2576
+ {
2577
+ id: nextApprovalStepId(currentSteps),
2578
+ label: "Approval step",
2579
+ approver: "",
2580
+ condition: "Define routing condition",
2581
+ required: true,
2582
+ status: "queued"
2583
+ }
2584
+ ]);
2585
+ };
2586
+ const removeStep = (id) => {
2587
+ commitSteps(currentSteps.filter((step) => step.id !== id));
2588
+ };
2589
+ const changeMode = (nextMode) => {
2590
+ if (!mode) setInternalMode(nextMode);
2591
+ onModeChange?.(nextMode);
2592
+ };
2593
+ return /* @__PURE__ */ jsxs(
2594
+ Surface,
2595
+ {
2596
+ ...props,
2597
+ "data-eth-component": "ApprovalWorkflowEditor",
2598
+ title,
2599
+ description,
2600
+ status: status ?? (missingApproverCount ? "pending-approval" : "active"),
2601
+ metadata: [
2602
+ { label: "Steps", value: currentSteps.length },
2603
+ { label: "Required gates", value: requiredCount },
2604
+ { label: "Ready", value: `${readyCount}/${currentSteps.length || 0}` }
2605
+ ],
2606
+ className: `eth-domain-approval-workflow-editor ${className ?? ""}`,
2607
+ children: [
2608
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-approval-workflow-editor__settings", children: [
2609
+ /* @__PURE__ */ jsx(
2610
+ Select,
2611
+ {
2612
+ labelText: "Routing mode",
2613
+ density: "compact",
2614
+ value: currentMode,
2615
+ options: modeOptions,
2616
+ onChange: (event) => changeMode(event.currentTarget.value)
2617
+ }
2618
+ ),
2619
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-approval-workflow-editor__validation", role: "status", children: [
2620
+ /* @__PURE__ */ jsx("span", { children: "Validation" }),
2621
+ /* @__PURE__ */ jsx("strong", { children: validationMessage })
2622
+ ] })
2623
+ ] }),
2624
+ currentSteps.length ? /* @__PURE__ */ jsxs(Fragment2, { children: [
2625
+ /* @__PURE__ */ jsx("div", { className: "eth-domain-approval-workflow-editor__route", "aria-label": "Approval route", children: currentSteps.map((step, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
2626
+ /* @__PURE__ */ jsxs("span", { className: "eth-domain-approval-workflow-editor__route-node", children: [
2627
+ /* @__PURE__ */ jsx("strong", { children: index + 1 }),
2628
+ /* @__PURE__ */ jsx("span", { children: step.label })
2629
+ ] }),
2630
+ index < currentSteps.length - 1 ? /* @__PURE__ */ jsx(
2631
+ "span",
2632
+ {
2633
+ className: "eth-domain-approval-workflow-editor__route-arrow",
2634
+ "aria-hidden": "true",
2635
+ children: "->"
2636
+ }
2637
+ ) : null
2638
+ ] }, step.id)) }),
2639
+ /* @__PURE__ */ jsx("ol", { className: "eth-domain-approval-workflow-editor__steps", children: currentSteps.map((step, index) => /* @__PURE__ */ jsxs("li", { className: "eth-domain-approval-workflow-editor__step", children: [
2640
+ /* @__PURE__ */ jsx("div", { className: "eth-domain-approval-workflow-editor__step-index", "aria-hidden": "true", children: index + 1 }),
2641
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-approval-workflow-editor__step-main", children: [
2642
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-approval-workflow-editor__step-header", children: [
2643
+ /* @__PURE__ */ jsxs("div", { children: [
2644
+ /* @__PURE__ */ jsxs("span", { children: [
2645
+ "Gate ",
2646
+ index + 1
2647
+ ] }),
2648
+ /* @__PURE__ */ jsx("strong", { children: formatApprovalStatus(step.status, step.required) })
2649
+ ] }),
2650
+ /* @__PURE__ */ jsx(
2651
+ Button,
2652
+ {
2653
+ type: "button",
2654
+ intent: "ghost",
2655
+ density: "compact",
2656
+ disabled: currentSteps.length <= 1,
2657
+ onClick: () => removeStep(step.id),
2658
+ children: "Remove"
2659
+ }
2660
+ )
2661
+ ] }),
2662
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-approval-workflow-editor__fields", children: [
2663
+ /* @__PURE__ */ jsx(
2664
+ TextInput,
2665
+ {
2666
+ labelText: "Step name",
2667
+ density: "compact",
2668
+ value: step.label,
2669
+ onChange: (event) => updateStep(index, { ...step, label: event.currentTarget.value })
2670
+ }
2671
+ ),
2672
+ /* @__PURE__ */ jsx(
2673
+ Select,
2674
+ {
2675
+ labelText: "Approver",
2676
+ density: "compact",
2677
+ value: step.approver ?? "",
2678
+ options: approverOptions,
2679
+ invalid: !step.approver,
2680
+ invalidText: "Choose an approver.",
2681
+ onChange: (event) => updateStep(index, { ...step, approver: event.currentTarget.value })
2682
+ }
2683
+ ),
2684
+ /* @__PURE__ */ jsx(
2685
+ TextInput,
2686
+ {
2687
+ labelText: "Condition",
2688
+ density: "compact",
2689
+ value: step.condition ?? "",
2690
+ onChange: (event) => updateStep(index, { ...step, condition: event.currentTarget.value })
2691
+ }
2692
+ )
2693
+ ] }),
2694
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-approval-workflow-editor__step-footer", children: [
2695
+ /* @__PURE__ */ jsx(
2696
+ Checkbox,
2697
+ {
2698
+ label: "Required gate",
2699
+ checked: Boolean(step.required),
2700
+ onChange: (event) => updateStep(index, { ...step, required: event.currentTarget.checked })
2701
+ }
2702
+ ),
2703
+ /* @__PURE__ */ jsx("span", { children: "Escalates to workflow owner when overdue by 24h." })
2704
+ ] })
2705
+ ] })
2706
+ ] }, step.id)) })
2707
+ ] }) : /* @__PURE__ */ jsx("div", { className: "eth-domain-approval-workflow-editor__empty", children: "No approval steps configured." }),
2708
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-approval-workflow-editor__footer", children: [
2709
+ /* @__PURE__ */ jsx(Button, { type: "button", intent: "secondary", density: "compact", onClick: addStep, children: "Add approval" }),
2710
+ /* @__PURE__ */ jsx(
2711
+ Button,
2712
+ {
2713
+ type: "button",
2714
+ intent: "tertiary",
2715
+ density: "compact",
2716
+ disabled: Boolean(missingApproverCount),
2717
+ children: "Simulate route"
2718
+ }
2719
+ )
2720
+ ] })
2721
+ ]
2722
+ }
2723
+ );
2724
+ }
2725
+ function ProcessDesigner({
2726
+ title = "Business process",
2727
+ description = "Design, validate, and inspect a multi-step process.",
2728
+ items,
2729
+ connections,
2730
+ validationIssues: validationIssuesProp,
2731
+ selectedItemId,
2732
+ metadata,
2733
+ actions,
2734
+ footer,
2735
+ children,
2736
+ className,
2737
+ status,
2738
+ onAddStep,
2739
+ onValidate,
2740
+ ...props
2741
+ }) {
2742
+ const canvasTitleId = React.useId();
2743
+ const graphTitleId = React.useId();
2744
+ const graphDescriptionId = React.useId();
2745
+ const markerId = React.useId().replace(/:/g, "");
2746
+ const panelTitleId = React.useId();
2747
+ const processItems = items ?? defaultProcessItems;
2748
+ const validationIssues = validationIssuesProp ?? (items ? [] : defaultProcessValidationIssues);
2749
+ const processConnections = connections ?? (items ? sequentialProcessConnections(processItems) : defaultProcessConnections);
2750
+ const titleText = textFromNode(title).trim() || "Business process";
2751
+ const [internalSelectedId, setInternalSelectedId] = React.useState(
2752
+ selectedItemId ?? processItems[0]?.id
2753
+ );
2754
+ React.useEffect(() => {
2755
+ if (selectedItemId) {
2756
+ setInternalSelectedId(selectedItemId);
2757
+ return;
2758
+ }
2759
+ setInternalSelectedId(
2760
+ (current) => processItems.some((item) => item.id === current) ? current : processItems[0]?.id
2761
+ );
2762
+ }, [processItems, selectedItemId]);
2763
+ const activeItem = processItems.find((item) => item.id === (selectedItemId ?? internalSelectedId)) ?? processItems[0];
2764
+ const completedCount = processItems.filter((item) => isCompletedProcessStep(item.status)).length;
2765
+ const decisionCount = processItems.filter(
2766
+ (item, index) => processStepKind(item, index, processItems.length) === "decision"
2767
+ ).length;
2768
+ const processStatus = status ?? deriveProcessStatus(processItems, validationIssues);
2769
+ const validationLabel = validationIssues.length ? `${validationIssues.length} open ${validationIssues.length === 1 ? "issue" : "issues"}` : "No open issues";
2770
+ const selectNode = (id) => {
2771
+ if (!selectedItemId) setInternalSelectedId(id);
2772
+ };
2773
+ return /* @__PURE__ */ jsxs(
2774
+ Surface,
2775
+ {
2776
+ ...props,
2777
+ "data-eth-component": "ProcessDesigner",
2778
+ title,
2779
+ description,
2780
+ status: processStatus,
2781
+ metadata: metadata ?? [
2782
+ { label: "Steps", value: processItems.length },
2783
+ { label: "Completed", value: `${completedCount}/${processItems.length || 0}` },
2784
+ { label: "Branches", value: decisionCount },
2785
+ { label: "Validation", value: validationLabel }
2786
+ ],
2787
+ actions,
2788
+ footer: footer ?? /* @__PURE__ */ jsxs("div", { className: "eth-domain-process-designer__footer", children: [
2789
+ /* @__PURE__ */ jsxs("span", { children: [
2790
+ "Draft process: ",
2791
+ titleText
2792
+ ] }),
2793
+ /* @__PURE__ */ jsx("span", { children: "Last validated 12 minutes ago" })
2794
+ ] }),
2795
+ className: `eth-domain-process-designer ${className ?? ""}`,
2796
+ children: [
2797
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-process-designer__workspace", children: [
2798
+ /* @__PURE__ */ jsxs(
2799
+ "section",
2800
+ {
2801
+ className: "eth-domain-process-designer__canvas-shell",
2802
+ "aria-labelledby": canvasTitleId,
2803
+ children: [
2804
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-process-designer__toolbar", children: [
2805
+ /* @__PURE__ */ jsxs("div", { children: [
2806
+ /* @__PURE__ */ jsx("span", { children: "Canvas" }),
2807
+ /* @__PURE__ */ jsx("strong", { id: canvasTitleId, children: processItems.length ? titleText : "No workflow steps" })
2808
+ ] }),
2809
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-process-designer__toolbar-actions", children: [
2810
+ processStatus ? /* @__PURE__ */ jsx(StatusDot, { status: processStatus, label: validationLabel }) : null,
2811
+ /* @__PURE__ */ jsx(Button, { type: "button", intent: "secondary", density: "compact", onClick: onAddStep, children: "Add step" }),
2812
+ /* @__PURE__ */ jsx(Button, { type: "button", intent: "tertiary", density: "compact", onClick: onValidate, children: "Validate" })
2813
+ ] })
2814
+ ] }),
2815
+ processItems.length ? /* @__PURE__ */ jsx("div", { className: "eth-domain-process-designer__canvas", children: /* @__PURE__ */ jsxs(
2816
+ "svg",
2817
+ {
2818
+ viewBox: "0 0 920 340",
2819
+ role: "group",
2820
+ "aria-labelledby": graphTitleId,
2821
+ "aria-describedby": graphDescriptionId,
2822
+ children: [
2823
+ /* @__PURE__ */ jsx("title", { id: graphTitleId, children: "Business process graph" }),
2824
+ /* @__PURE__ */ jsxs("desc", { id: graphDescriptionId, children: [
2825
+ "Process graph with ",
2826
+ processItems.length,
2827
+ " steps and ",
2828
+ processConnections.length,
2829
+ " ",
2830
+ "connections."
2831
+ ] }),
2832
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx(
2833
+ "marker",
2834
+ {
2835
+ id: markerId,
2836
+ viewBox: "0 0 10 10",
2837
+ refX: "8",
2838
+ refY: "5",
2839
+ markerWidth: "6",
2840
+ markerHeight: "6",
2841
+ orient: "auto-start-reverse",
2842
+ children: /* @__PURE__ */ jsx("path", { d: "M 0 0 L 10 5 L 0 10 z" })
2843
+ }
2844
+ ) }),
2845
+ processConnections.map((connection, index) => {
2846
+ const fromIndex = processItems.findIndex((item) => item.id === connection.from);
2847
+ const toIndex = processItems.findIndex((item) => item.id === connection.to);
2848
+ const from = processItems[fromIndex];
2849
+ const to = processItems[toIndex];
2850
+ if (!from || !to) return null;
2851
+ const fromPoint = processNodePoint(from, fromIndex);
2852
+ const toPoint = processNodePoint(to, toIndex);
2853
+ const midX = (fromPoint.x + toPoint.x) / 2;
2854
+ const midY = (fromPoint.y + toPoint.y) / 2;
2855
+ const label = textFromNode(connection.label).trim();
2856
+ return /* @__PURE__ */ jsxs(
2857
+ "g",
2858
+ {
2859
+ className: "eth-domain-process-designer__edge",
2860
+ "data-status": connection.status,
2861
+ children: [
2862
+ /* @__PURE__ */ jsx(
2863
+ "line",
2864
+ {
2865
+ x1: fromPoint.x,
2866
+ y1: fromPoint.y,
2867
+ x2: toPoint.x,
2868
+ y2: toPoint.y,
2869
+ markerEnd: `url(#${markerId})`
2870
+ }
2871
+ ),
2872
+ label ? /* @__PURE__ */ jsx("text", { x: midX, y: midY - 10, textAnchor: "middle", children: label }) : null
2873
+ ]
2874
+ },
2875
+ `${connection.from}-${connection.to}-${index}`
2876
+ );
2877
+ }),
2878
+ processItems.map((item, index) => {
2879
+ const point = processNodePoint(item, index);
2880
+ const kind = processStepKind(item, index, processItems.length);
2881
+ const selected = activeItem?.id === item.id;
2882
+ const lines = graphLabelLines(item.label, item.id);
2883
+ return /* @__PURE__ */ jsxs(
2884
+ "g",
2885
+ {
2886
+ className: "eth-domain-process-designer__node",
2887
+ "data-kind": kind,
2888
+ "data-status": item.status,
2889
+ "data-selected": selected ? "true" : void 0,
2890
+ transform: `translate(${point.x}, ${point.y})`,
2891
+ role: "button",
2892
+ tabIndex: 0,
2893
+ "aria-label": `${textFromNode(item.label) || item.id}, ${statusLabel(
2894
+ item.status ?? "queued"
2895
+ )}`,
2896
+ onClick: () => selectNode(item.id),
2897
+ onKeyDown: (event) => {
2898
+ if (event.key === "Enter" || event.key === " ") {
2899
+ event.preventDefault();
2900
+ selectNode(item.id);
2901
+ }
2902
+ },
2903
+ children: [
2904
+ kind === "decision" ? /* @__PURE__ */ jsx("polygon", { points: "0,-44 78,0 0,44 -78,0" }) : /* @__PURE__ */ jsx("rect", { x: "-72", y: "-36", width: "144", height: "72", rx: "0" }),
2905
+ /* @__PURE__ */ jsx(
2906
+ "circle",
2907
+ {
2908
+ className: "eth-domain-process-designer__node-status",
2909
+ cx: kind === "decision" ? -44 : -52,
2910
+ cy: kind === "decision" ? -18 : -18,
2911
+ r: "5"
2912
+ }
2913
+ ),
2914
+ /* @__PURE__ */ jsx("text", { textAnchor: "middle", children: lines.map((line, lineIndex) => /* @__PURE__ */ jsx(
2915
+ "tspan",
2916
+ {
2917
+ x: "0",
2918
+ dy: lineIndex === 0 ? lines.length > 1 ? "-0.35em" : "0.35em" : "1.2em",
2919
+ children: line
2920
+ },
2921
+ `${line}-${lineIndex}`
2922
+ )) })
2923
+ ]
2924
+ },
2925
+ item.id
2926
+ );
2927
+ })
2928
+ ]
2929
+ }
2930
+ ) }) : /* @__PURE__ */ jsx("div", { className: "eth-domain-process-designer__empty", children: "No process steps configured." })
2931
+ ]
2932
+ }
2933
+ ),
2934
+ /* @__PURE__ */ jsxs("aside", { className: "eth-domain-process-designer__inspector", "aria-labelledby": panelTitleId, children: [
2935
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-process-designer__panel-header", children: [
2936
+ /* @__PURE__ */ jsx("span", { children: "Step properties" }),
2937
+ /* @__PURE__ */ jsx("h3", { id: panelTitleId, children: activeItem ? activeItem.label : "No step selected" })
2938
+ ] }),
2939
+ activeItem ? /* @__PURE__ */ jsxs(Fragment2, { children: [
2940
+ /* @__PURE__ */ jsx(
2941
+ StatusDot,
2942
+ {
2943
+ status: activeItem.status ?? "queued",
2944
+ label: statusLabel(activeItem.status ?? "queued")
2945
+ }
2946
+ ),
2947
+ activeItem.description ? /* @__PURE__ */ jsx("p", { className: "eth-domain-process-designer__description", children: activeItem.description }) : null,
2948
+ /* @__PURE__ */ jsxs("dl", { className: "eth-domain-process-designer__facts", children: [
2949
+ /* @__PURE__ */ jsxs("div", { children: [
2950
+ /* @__PURE__ */ jsx("dt", { children: "Owner" }),
2951
+ /* @__PURE__ */ jsx("dd", { children: activeItem.owner ?? "Unassigned" })
2952
+ ] }),
2953
+ /* @__PURE__ */ jsxs("div", { children: [
2954
+ /* @__PURE__ */ jsx("dt", { children: "Lane" }),
2955
+ /* @__PURE__ */ jsx("dd", { children: activeItem.lane ?? "Default lane" })
2956
+ ] }),
2957
+ /* @__PURE__ */ jsxs("div", { children: [
2958
+ /* @__PURE__ */ jsx("dt", { children: "SLA" }),
2959
+ /* @__PURE__ */ jsx("dd", { children: activeItem.duration ?? activeItem.meta ?? "Not set" })
2960
+ ] })
2961
+ ] })
2962
+ ] }) : /* @__PURE__ */ jsx("p", { className: "eth-domain-process-designer__description", children: "No selected step." }),
2963
+ /* @__PURE__ */ jsxs("section", { className: "eth-domain-process-designer__validation", "aria-label": "Validation", children: [
2964
+ /* @__PURE__ */ jsxs("div", { className: "eth-domain-process-designer__panel-header", children: [
2965
+ /* @__PURE__ */ jsx("span", { children: "Validation" }),
2966
+ /* @__PURE__ */ jsx("strong", { children: validationLabel })
2967
+ ] }),
2968
+ validationIssues.length ? /* @__PURE__ */ jsx("ul", { children: validationIssues.map((issue) => /* @__PURE__ */ jsxs("li", { "data-status": issue.status ?? "warning", children: [
2969
+ /* @__PURE__ */ jsx(
2970
+ StatusDot,
2971
+ {
2972
+ status: issue.status ?? "warning",
2973
+ label: statusLabel(issue.status ?? "warning")
2974
+ }
2975
+ ),
2976
+ /* @__PURE__ */ jsxs("div", { children: [
2977
+ issue.target ? /* @__PURE__ */ jsx("strong", { children: issue.target }) : null,
2978
+ /* @__PURE__ */ jsx("span", { children: issue.message })
2979
+ ] })
2980
+ ] }, issue.id)) }) : /* @__PURE__ */ jsx("p", { className: "eth-domain-process-designer__empty-note", children: "No validation issues detected." })
2981
+ ] })
2982
+ ] })
2983
+ ] }),
2984
+ children
2985
+ ]
2986
+ }
2987
+ );
2988
+ }
2989
+ var SalesPipelineBoard = createSurfaceComponent("SalesPipelineBoard");
2990
+ var ContractReviewPanel = createSurfaceComponent("ContractReviewPanel");
2991
+ var RuleSimulationPanel = createSurfaceComponent("RuleSimulationPanel");
2992
+ var DomainWidgetsComponentNames = [
2993
+ "CRMContactPanel",
2994
+ "SalesPipelineBoard",
2995
+ "SupportTicketQueue",
2996
+ "KnowledgeBaseArticleViewer",
2997
+ "InventoryTable",
2998
+ "OrderManagementPanel",
2999
+ "InvoiceViewer",
3000
+ "ContractReviewPanel",
3001
+ "ComplianceChecklist",
3002
+ "RiskMatrix",
3003
+ "ApprovalWorkflowEditor",
3004
+ "DataImportWizard",
3005
+ "MappingConfigurationWizard",
3006
+ "ReportBuilder",
3007
+ "ProcessDesigner",
3008
+ "RuleSimulationPanel"
3009
+ ];
3010
+ export {
3011
+ ApprovalWorkflowEditor,
3012
+ CRMContactPanel,
3013
+ ComplianceChecklist,
3014
+ ContractReviewPanel,
3015
+ DataImportWizard,
3016
+ DomainWidgetsComponentNames,
3017
+ InventoryTable,
3018
+ InvoiceViewer,
3019
+ KnowledgeBaseArticleViewer,
3020
+ MappingConfigurationWizard,
3021
+ OrderManagementPanel,
3022
+ ProcessDesigner,
3023
+ ReportBuilder,
3024
+ RiskMatrix,
3025
+ RuleSimulationPanel,
3026
+ SalesPipelineBoard,
3027
+ SupportTicketQueue
3028
+ };
3029
+ //# sourceMappingURL=index.js.map