@tantainnovative/ndpr-toolkit 3.13.0 → 4.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.
Files changed (102) hide show
  1. package/CHANGELOG.md +131 -0
  2. package/README.md +1 -1
  3. package/dist/breach.d.mts +2 -7
  4. package/dist/breach.d.ts +2 -7
  5. package/dist/breach.js +1 -1
  6. package/dist/breach.mjs +1 -1
  7. package/dist/chunk-3APT25XO.mjs +1 -0
  8. package/dist/chunk-45D7AMB3.js +1 -0
  9. package/dist/chunk-63WM5PHZ.js +1 -0
  10. package/dist/chunk-65J4P5ID.js +1 -0
  11. package/dist/chunk-6A6VI7ZP.mjs +1 -0
  12. package/dist/{chunk-NB6SKG76.mjs → chunk-6H6IXTHA.mjs} +1 -1
  13. package/dist/chunk-6OPGI27L.mjs +1 -0
  14. package/dist/{chunk-3XU6FL2I.js → chunk-6YFPDGNB.js} +1 -1
  15. package/dist/{chunk-IHNAFXDM.mjs → chunk-7Z7NURIA.mjs} +1 -1
  16. package/dist/chunk-D2UWB5OI.js +2 -0
  17. package/dist/chunk-D3HHDWBR.js +1 -0
  18. package/dist/chunk-DK7P5JEG.mjs +2 -0
  19. package/dist/chunk-DSIIEUAD.mjs +1 -0
  20. package/dist/chunk-H2FDWK4F.js +6 -0
  21. package/dist/chunk-HLFS3NXG.js +1 -0
  22. package/dist/chunk-JGY65SHX.mjs +1 -0
  23. package/dist/chunk-NI54X543.mjs +1 -0
  24. package/dist/chunk-O4ATGGVK.js +1 -0
  25. package/dist/chunk-P5MPUC5F.js +1 -0
  26. package/dist/{chunk-BGV2AKT7.mjs → chunk-PSPYIRIF.mjs} +1 -1
  27. package/dist/{chunk-HOAC5VUF.js → chunk-ROOUYQD4.js} +1 -1
  28. package/dist/{chunk-WMISQDSV.js → chunk-UJGNW6CH.js} +1 -1
  29. package/dist/chunk-UTXDZDYF.mjs +6 -0
  30. package/dist/chunk-W6VVLHRQ.mjs +1 -0
  31. package/dist/consent.d.mts +2 -0
  32. package/dist/consent.d.ts +2 -0
  33. package/dist/consent.js +1 -1
  34. package/dist/consent.mjs +1 -1
  35. package/dist/core.d.mts +13 -0
  36. package/dist/core.d.ts +13 -0
  37. package/dist/core.js +1 -1
  38. package/dist/core.mjs +1 -1
  39. package/dist/cross-border.d.mts +24 -0
  40. package/dist/cross-border.d.ts +24 -0
  41. package/dist/cross-border.js +1 -1
  42. package/dist/cross-border.mjs +1 -1
  43. package/dist/dsr.d.mts +15 -3
  44. package/dist/dsr.d.ts +15 -3
  45. package/dist/dsr.js +1 -1
  46. package/dist/dsr.mjs +1 -1
  47. package/dist/headless.d.mts +34 -4
  48. package/dist/headless.d.ts +34 -4
  49. package/dist/headless.js +1 -1
  50. package/dist/headless.mjs +1 -1
  51. package/dist/hooks.d.mts +34 -4
  52. package/dist/hooks.d.ts +34 -4
  53. package/dist/hooks.js +1 -1
  54. package/dist/hooks.mjs +1 -1
  55. package/dist/index.d.mts +229 -11
  56. package/dist/index.d.ts +229 -11
  57. package/dist/index.js +1 -1
  58. package/dist/index.mjs +1 -1
  59. package/dist/lawful-basis.d.mts +21 -0
  60. package/dist/lawful-basis.d.ts +21 -0
  61. package/dist/lawful-basis.js +1 -1
  62. package/dist/lawful-basis.mjs +1 -1
  63. package/dist/presets-consent.d.mts +5 -1
  64. package/dist/presets-consent.d.ts +5 -1
  65. package/dist/presets-consent.js +1 -1
  66. package/dist/presets-consent.mjs +1 -1
  67. package/dist/presets.d.mts +103 -22
  68. package/dist/presets.d.ts +103 -22
  69. package/dist/presets.js +1 -1
  70. package/dist/presets.mjs +1 -1
  71. package/dist/ropa-lite.d.mts +13 -1
  72. package/dist/ropa-lite.d.ts +13 -1
  73. package/dist/ropa-lite.js +1 -1
  74. package/dist/ropa-lite.mjs +1 -1
  75. package/dist/ropa.d.mts +43 -1
  76. package/dist/ropa.d.ts +43 -1
  77. package/dist/ropa.js +1 -1
  78. package/dist/ropa.mjs +1 -1
  79. package/dist/server.d.mts +135 -0
  80. package/dist/server.d.ts +135 -0
  81. package/dist/server.js +1 -1
  82. package/dist/server.mjs +1 -1
  83. package/dist/styles.css +18 -16
  84. package/package.json +3 -3
  85. package/dist/chunk-42JPSNVV.mjs +0 -6
  86. package/dist/chunk-737EMUUC.mjs +0 -1
  87. package/dist/chunk-7FXNGGMO.js +0 -1
  88. package/dist/chunk-B46SJB5V.js +0 -1
  89. package/dist/chunk-BL5W472Q.js +0 -1
  90. package/dist/chunk-NUIRMJKQ.mjs +0 -2
  91. package/dist/chunk-O2WEABB3.js +0 -1
  92. package/dist/chunk-OZHUINWS.js +0 -1
  93. package/dist/chunk-PJNKQPQP.mjs +0 -1
  94. package/dist/chunk-PXDSPF5B.js +0 -2
  95. package/dist/chunk-QGUOFGVJ.js +0 -2
  96. package/dist/chunk-RBKFNCGO.mjs +0 -1
  97. package/dist/chunk-VPNK7OID.mjs +0 -1
  98. package/dist/chunk-WHQ4PEYS.mjs +0 -2
  99. package/dist/chunk-WKUC65HL.mjs +0 -1
  100. package/dist/chunk-XYGGUGTO.js +0 -6
  101. package/dist/chunk-Z2M5VJX2.mjs +0 -1
  102. package/dist/chunk-ZM5DLFCZ.js +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,137 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [4.1.0](https://github.com/mr-tanta/ndpr-toolkit/compare/v4.0.0...v4.1.0) (2026-05-27)
6
+
7
+ Additive minor. Closes the post-4.0 audit work and opens the deprecation window for 5.0. No breaks: every change here is opt-in or a new alias. If your 4.0 install is clean, drop in 4.1 with no code changes — then if you're using any of the legacy callback names below, your dev console will tell you what to rename ahead of 5.0.
8
+
9
+ ### Features
10
+
11
+ #### Two new shipped locales: Arabic + French
12
+
13
+ `ar` (Modern Standard Arabic, neutral register; "NDPA"/"NDPC" kept as identifiers; Western Arabic numerals for NDPA section references per Nigerian legal convention) and `fr` (Francophone West African register; uses GDPR-equivalent French terms — "personne concernée", "AIPD" — where they carry meaning).
14
+
15
+ ```ts
16
+ import { ar, fr } from '@tantainnovative/ndpr-toolkit/locales';
17
+ <NDPRProvider locale={ar}>...</NDPRProvider>
18
+ ```
19
+
20
+ Both export from the `/locales` subpath and roll up into `NDPRLocale` without type changes.
21
+
22
+ #### RTL-correct CSS via logical properties
23
+
24
+ Converted 13 physical directional declarations in `styles/styles.css` to logical equivalents (`margin-left` → `margin-inline-start`, `text-align: left` → `text-align: start`, `left: 0; right: 0` → `inset-inline: 0`, etc.). Setting `dir="rtl"` on a parent now mirrors the layout correctly — Arabic users no longer see consent banner buttons hanging off the wrong edge.
25
+
26
+ #### Uniform `onAdd` / `onUpdate` / `onArchive` callbacks across list managers
27
+
28
+ `LawfulBasisTracker`, `CrossBorderTransferManager`, `ROPAManager`, and the `useROPA` hook each gain `onAdd` / `onUpdate` / `onArchive` callback names. The legacy module-specific names (`onAddActivity`, `onAddTransfer`, `onAddRecord`, `onRecordAdd`, etc.) still fire — both are called when set, so consumer code doesn't break — but they emit a one-shot dev-only deprecation warn.
29
+
30
+ **Slated for 5.0 removal:** `onAddActivity`, `onUpdateActivity`, `onArchiveActivity`, `onAddTransfer`, `onUpdateTransfer`, `onRemoveTransfer`, `onAddRecord`, `onUpdateRecord`, `onArchiveRecord`, and the matching `useROPA` options `onRecordAdd`, `onRecordUpdate`, `onRecordArchive`.
31
+
32
+ #### `NDPRDPIA` gains `onResult(result: DPIAResult)`
33
+
34
+ The preset previously fired `onComplete(answers)` with just the raw answer map, discarding the computed risk score. The new `onResult` callback receives the full `DPIAResult` — `overallRiskLevel`, `canProceed`, `conclusion`, `recommendations`, all of it — so consumers can branch on the outcome without re-running the assessment client-side. `onComplete` still fires for back-compat (and dev-warns ahead of 5.0).
35
+
36
+ #### `ROPAManagerLite` accepts the full `ropa` shape
37
+
38
+ `ROPAManagerLite` now accepts a `ropa?: RecordOfProcessingActivities` prop alongside the legacy `records?: ProcessingRecord[]`. When `ropa` is set, it wins; otherwise the component wraps the legacy `records` array in a stub. This matches the full `ROPAManager` API. Legacy `records` dev-warns for 5.0.
39
+
40
+ #### Structured validator family — `validate*Structured()`
41
+
42
+ New sibling functions return `{ valid; errors: Array<{ field; code; message }>; data? }` instead of `string[]`:
43
+
44
+ - `validateConsentStructured` (codes: `consents_required`, `timestamp_required`, `timestamp_invalid`, `version_required`, `method_required`, `has_interacted_required`, `consent_stale`)
45
+ - `validateConsentOptionsStructured` (`options_required`, `purpose_required`)
46
+ - `validateDsrSubmissionStructured` (`payload_not_object`, `request_type_required`, `request_type_not_allowed`, `data_subject_required`, `full_name_required`, `email_required`, `email_invalid_format`, `phone_invalid_type`, `identifier_type_required`, `identifier_value_required`, `submitted_at_invalid`, `additional_info_invalid_type`, `payload_final_narrowing_failed`)
47
+ - `formatDSRRequestStructured` (`request_id_required`, `request_type_required`, `request_status_required`, `created_at_required`, `subject_name_required`, `subject_email_required`)
48
+
49
+ Consumers can now branch on stable `code` values instead of regex-matching English strings — and the new shape is locale-independent. Legacy string-returning versions still work and dev-warn once per module-load. **Slated for 5.0 removal:** legacy string-returning shape.
50
+
51
+ ### Repo hygiene
52
+
53
+ - Deleted six dead inner config files from `packages/ndpr-toolkit/` (`tsup.config.ts`, `tsconfig.json`, `tsconfig.lib.json`, `eslint.config.mjs`, `jest.config.js`, `rollup.config.js`). All build/test/lint config lives at the repo root; the inner copies haven't been read by any tool since 3.7. The inner `package.json` stays for now (still `private: true`) — its `exports` field is referenced by some IDE tooling for jump-to-definition.
54
+
55
+ ### Verification
56
+
57
+ - `pnpm jest --no-coverage` — 1277 pass / 90 suites / 0 fail (+14 new structured-validator cases)
58
+ - `pnpm verify:tarball` — all 22 subpaths resolve in ESM + CJS + TS
59
+ - `npx tsc --noEmit -p tsconfig.json` — clean
60
+
61
+ ## [4.0.0](https://github.com/mr-tanta/ndpr-toolkit/compare/v3.13.0...v4.0.0) (2026-05-27)
62
+
63
+ The consolidated breaking-change window. Every removal here was already deprecated and dev-warned in 3.13.x — if your 3.13.x dev console was clean, your 4.0 upgrade is a one-line bump. Full migration table in [`/docs/guides/migrating-3-13-to-4-0`](https://ndprtoolkit.com.ng/docs/guides/migrating-3-13-to-4-0).
64
+
65
+ ### Breaking changes
66
+
67
+ #### React 17 dropped from peer range
68
+
69
+ `peerDependencies.react` is now `^18.0.0 || ^19.0.0` (was `^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0`). The toolkit uses `React.useId` (18+) in several components, so the previous claim was a lie — React 17 consumers installed cleanly then hit cryptic errors at runtime. This release just makes the peer range match reality.
70
+
71
+ **Migration:** if you're on React 17 or earlier, upgrade your app to React 18+ before bumping. React 18 / 19 consumers: no action.
72
+
73
+ #### `formDescription` removed; use `description`
74
+
75
+ `BreachReportForm` and `NDPRBreachReport` previously accepted both `description` and a legacy `formDescription` alias (with a dev warn). The alias is gone.
76
+
77
+ **Migration:** rename every `formDescription` to `description`. (3.13's dev warn told you where.)
78
+
79
+ #### `initialActivities` / `initialTransfers` removed; use `initialData`
80
+
81
+ `NDPRLawfulBasis` and `NDPRCrossBorder` presets now accept `initialData` only, matching `NDPRROPA`. The module-specific aliases are gone.
82
+
83
+ **Migration:**
84
+ ```diff
85
+ - <NDPRLawfulBasis initialActivities={activities} />
86
+ + <NDPRLawfulBasis initialData={activities} />
87
+
88
+ - <NDPRCrossBorder initialTransfers={transfers} />
89
+ + <NDPRCrossBorder initialData={transfers} />
90
+ ```
91
+
92
+ #### `extraOptions` removed from `NDPRConsent`
93
+
94
+ The one-off pattern that extended the toolkit's default options is gone. Pass the full options array via `options` instead.
95
+
96
+ **Migration:** copy the default option set (or build your own) and pass it via `options`. Example in the migration guide.
97
+
98
+ #### `useDSR` default storage flipped to in-memory
99
+
100
+ `useDSR` is the admin tracker hook — its state contains data subjects' PII. The previous default (`useLocalStorage: true`) persisted that PII to the admin's browser's localStorage, which is rarely appropriate. The default is now `useLocalStorage: false`.
101
+
102
+ **Migration:**
103
+ - If you intentionally relied on localStorage persistence, pass `useLocalStorage: true` explicitly (and reconsider whether you actually want it).
104
+ - If you want production persistence, pass `adapter: apiAdapter('/api/dsr')` (or any other `StorageAdapter`).
105
+ - If you don't need persistence, no action — the tracker now starts empty on every reload, which is correct for most admin UI use cases.
106
+
107
+ #### `examples/dsr-backend-prod` renamed to `examples/dsr-backend-reference`
108
+
109
+ The "prod" name oversold what the example does. It demonstrates DSR receipt and confirmation — not the full fulfilment pipeline (identity verification, audit logging, status transitions, request-type-specific handling, deadline tracking, DPO routing). The renamed example ships a "What you still need to build" checklist in its README so consumers don't ship it as-is.
110
+
111
+ **Migration:** if you bookmarked or cloned `examples/dsr-backend-prod/`, update to `examples/dsr-backend-reference/`. The contents and contract are unchanged.
112
+
113
+ ### New
114
+
115
+ - New migration guide page at `/docs/guides/migrating-3-13-to-4-0` walks through each break with diffs.
116
+
117
+ ### Not in this 4.0
118
+
119
+ The plan originally also included:
120
+
121
+ - list-manager callback rename (`onArchiveActivity` / `onRemoveTransfer` / `onArchiveRecord` → uniform `onArchive`)
122
+ - `NDPRDPIA.onComplete(result: DPIAResult)` instead of `onComplete(answers)`
123
+ - `ROPAManagerLite` accepts `ropa: RecordOfProcessingActivities` instead of `records: ProcessingRecord[]`
124
+ - pure structured validator returns (legacy string returns removed)
125
+ - discriminated-union `onSubmitError`
126
+ - delete the inner `packages/ndpr-toolkit/{tsup.config.ts, tsconfig.json, etc.}` (already marked `private: true` in 3.10.5)
127
+
128
+ Each adds API churn for marginal gain. Deferred to **4.1** so 4.0 stays focused on the items already deprecated in the 3.13 window. The inner-package deletion can land any time; behaviour change otherwise.
129
+
130
+ ### Verification
131
+
132
+ - Jest: **1258 / 1258 passing** (no test count drift — deprecated-prop tests were updated to use the canonical names)
133
+ - `tsc --noEmit -p tsconfig.json` clean
134
+ - `pnpm verify:tarball --skip-ts` clean across all 22 subpaths
135
+
5
136
  ## [3.13.0](https://github.com/mr-tanta/ndpr-toolkit/compare/v3.12.0...v3.13.0) (2026-05-27)
6
137
 
7
138
  Release 5 of 6 on the post-audit roadmap. The **deprecation-window minor** — strictly additive, but every prop alias and behavior change that 4.0 will commit to gets fired here first as a dev-mode warning. Existing 3.x consumers see no breakage; new code can adopt the canonical surface.
package/README.md CHANGED
@@ -18,7 +18,7 @@ v3 ships **zero-config presets**, **pluggable storage adapters**, **compound com
18
18
 
19
19
  > **What's new in 3.11.0:** Every component's `Props` interface is now re-exported from the root (consumers can finally wrap toolkit components without copying types). Adapter ecosystem types (`ApiAdapterErrorContext`, `StorageAdapter<T>`, …) and DSR validator types reachable from `/server` + root. 9 new component docs pages cover `NDPRThemeProvider`, `NDPRProvider`, `NDPRDashboard`, `AdaptivePolicyWizard`, `PolicyPage`, the 3 Lite manager variants, and `LegalNotice`.
20
20
  >
21
- > **3.10.x highlights:** Typed theming via `<NDPRThemeProvider>`, a `/headless` subpath alias of `/hooks`, the production-grade DSR backend reference at `examples/dsr-backend-prod/`, plus the `verify:tarball` CI gate that catches broken exports at PR time. Upgrading from 3.7.x? See the [3.7 → 3.10 upgrade guide](https://ndprtoolkit.com.ng/docs/guides/upgrading-3-7-to-3-10). Full history in the [CHANGELOG](https://github.com/mr-tanta/ndpr-toolkit/blob/main/CHANGELOG.md).
21
+ > **3.10.x highlights:** Typed theming via `<NDPRThemeProvider>`, a `/headless` subpath alias of `/hooks`, the production-grade DSR backend reference at `examples/dsr-backend-reference/`, plus the `verify:tarball` CI gate that catches broken exports at PR time. Upgrading from 3.7.x? See the [3.7 → 3.10 upgrade guide](https://ndprtoolkit.com.ng/docs/guides/upgrading-3-7-to-3-10). Full history in the [CHANGELOG](https://github.com/mr-tanta/ndpr-toolkit/blob/main/CHANGELOG.md).
22
22
 
23
23
  <p align="center">
24
24
  <img src="https://raw.githubusercontent.com/mr-tanta/ndpr-toolkit/v3.11.0/public/screenshots/hero.png" alt="NDPA Toolkit — NDPA Compliance Made Beautiful" width="800" />
package/dist/breach.d.mts CHANGED
@@ -353,16 +353,11 @@ declare interface BreachReportFormProps {
353
353
  */
354
354
  title?: string;
355
355
  /**
356
- * Description text displayed on the form. Canonical name in 3.13+.
357
- * Takes precedence over `formDescription` if both are set.
356
+ * Description text displayed on the form.
357
+ *
358
358
  * @default "Use this form to report a suspected or confirmed data breach in accordance with NDPA Section 40. All fields marked with * are required."
359
359
  */
360
360
  description?: string;
361
- /**
362
- * @deprecated Renamed to `description`. Will be removed in 4.0.
363
- * If both are set, `description` wins.
364
- */
365
- formDescription?: string;
366
361
  /**
367
362
  * Text for the submit button
368
363
  * @default "Submit Report"
package/dist/breach.d.ts CHANGED
@@ -353,16 +353,11 @@ declare interface BreachReportFormProps {
353
353
  */
354
354
  title?: string;
355
355
  /**
356
- * Description text displayed on the form. Canonical name in 3.13+.
357
- * Takes precedence over `formDescription` if both are set.
356
+ * Description text displayed on the form.
357
+ *
358
358
  * @default "Use this form to report a suspected or confirmed data breach in accordance with NDPA Section 40. All fields marked with * are required."
359
359
  */
360
360
  description?: string;
361
- /**
362
- * @deprecated Renamed to `description`. Will be removed in 4.0.
363
- * If both are set, `description` wins.
364
- */
365
- formDescription?: string;
366
361
  /**
367
362
  * Text for the submit button
368
363
  * @default "Submit Report"
package/dist/breach.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- 'use strict';var chunk3I6FYA5C_js=require('./chunk-3I6FYA5C.js'),chunkQGUOFGVJ_js=require('./chunk-QGUOFGVJ.js'),chunkEHQVTFYO_js=require('./chunk-EHQVTFYO.js'),chunk3YTAOT5O_js=require('./chunk-3YTAOT5O.js');require('./chunk-UXUMYP4L.js'),require('./chunk-ZVOIR4QH.js'),require('./chunk-AME4HJR4.js'),require('./chunk-YDKWD6MQ.js'),require('./chunk-TTMGFC6C.js'),require('./chunk-VWED6UTN.js');var chunkRFPLZDIO_js=require('./chunk-RFPLZDIO.js'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var c=react.createContext(null);function P(){let e=react.useContext(c);if(!e)throw new Error("Breach compound components must be wrapped in <Breach.Provider>. Example: <Breach.Provider categories={...}><Breach.ReportForm /></Breach.Provider>");return e}var p=({categories:e,adapter:m,storageKey:h,useLocalStorage:B,initialReports:f,onReport:R,onAssessment:x,onNotification:u,children:d})=>{let y=chunkEHQVTFYO_js.a({categories:e,adapter:m,storageKey:h,useLocalStorage:B,initialReports:f,onReport:R,onAssessment:x,onNotification:u}),l=chunkRFPLZDIO_js.b(chunkRFPLZDIO_js.a({},y),{categories:e});return jsxRuntime.jsx(c.Provider,{value:l,children:d})};var A={Provider:p,ReportForm:chunkQGUOFGVJ_js.a,RiskAssessment:chunk3I6FYA5C_js.a,NotificationManager:chunk3I6FYA5C_js.b,ReportGenerator:chunk3I6FYA5C_js.c};Object.defineProperty(exports,"BreachNotificationManager",{enumerable:true,get:function(){return chunk3I6FYA5C_js.b}});Object.defineProperty(exports,"BreachRiskAssessment",{enumerable:true,get:function(){return chunk3I6FYA5C_js.a}});Object.defineProperty(exports,"RegulatoryReportGenerator",{enumerable:true,get:function(){return chunk3I6FYA5C_js.c}});Object.defineProperty(exports,"BreachReportForm",{enumerable:true,get:function(){return chunkQGUOFGVJ_js.a}});Object.defineProperty(exports,"useBreach",{enumerable:true,get:function(){return chunkEHQVTFYO_js.a}});Object.defineProperty(exports,"calculateBreachSeverity",{enumerable:true,get:function(){return chunk3YTAOT5O_js.a}});exports.Breach=A;exports.BreachProvider=p;exports.useBreachCompound=P;
2
+ 'use strict';var chunk3I6FYA5C_js=require('./chunk-3I6FYA5C.js'),chunkD2UWB5OI_js=require('./chunk-D2UWB5OI.js'),chunkEHQVTFYO_js=require('./chunk-EHQVTFYO.js'),chunk3YTAOT5O_js=require('./chunk-3YTAOT5O.js');require('./chunk-UXUMYP4L.js'),require('./chunk-ZVOIR4QH.js'),require('./chunk-AME4HJR4.js'),require('./chunk-YDKWD6MQ.js'),require('./chunk-TTMGFC6C.js'),require('./chunk-VWED6UTN.js');var chunkRFPLZDIO_js=require('./chunk-RFPLZDIO.js'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var c=react.createContext(null);function P(){let e=react.useContext(c);if(!e)throw new Error("Breach compound components must be wrapped in <Breach.Provider>. Example: <Breach.Provider categories={...}><Breach.ReportForm /></Breach.Provider>");return e}var p=({categories:e,adapter:m,storageKey:h,useLocalStorage:B,initialReports:f,onReport:R,onAssessment:x,onNotification:u,children:d})=>{let y=chunkEHQVTFYO_js.a({categories:e,adapter:m,storageKey:h,useLocalStorage:B,initialReports:f,onReport:R,onAssessment:x,onNotification:u}),l=chunkRFPLZDIO_js.b(chunkRFPLZDIO_js.a({},y),{categories:e});return jsxRuntime.jsx(c.Provider,{value:l,children:d})};var A={Provider:p,ReportForm:chunkD2UWB5OI_js.a,RiskAssessment:chunk3I6FYA5C_js.a,NotificationManager:chunk3I6FYA5C_js.b,ReportGenerator:chunk3I6FYA5C_js.c};Object.defineProperty(exports,"BreachNotificationManager",{enumerable:true,get:function(){return chunk3I6FYA5C_js.b}});Object.defineProperty(exports,"BreachRiskAssessment",{enumerable:true,get:function(){return chunk3I6FYA5C_js.a}});Object.defineProperty(exports,"RegulatoryReportGenerator",{enumerable:true,get:function(){return chunk3I6FYA5C_js.c}});Object.defineProperty(exports,"BreachReportForm",{enumerable:true,get:function(){return chunkD2UWB5OI_js.a}});Object.defineProperty(exports,"useBreach",{enumerable:true,get:function(){return chunkEHQVTFYO_js.a}});Object.defineProperty(exports,"calculateBreachSeverity",{enumerable:true,get:function(){return chunk3YTAOT5O_js.a}});exports.Breach=A;exports.BreachProvider=p;exports.useBreachCompound=P;
package/dist/breach.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import {c as c$1,b,a}from'./chunk-J7BIJ45O.mjs';export{b as BreachNotificationManager,a as BreachRiskAssessment,c as RegulatoryReportGenerator}from'./chunk-J7BIJ45O.mjs';import {a as a$1}from'./chunk-NUIRMJKQ.mjs';export{a as BreachReportForm}from'./chunk-NUIRMJKQ.mjs';import {a as a$2}from'./chunk-RFXGD5NE.mjs';export{a as useBreach}from'./chunk-RFXGD5NE.mjs';export{a as calculateBreachSeverity}from'./chunk-WTGKZX7J.mjs';import'./chunk-EWVK45Z3.mjs';import'./chunk-ITCY2Z66.mjs';import'./chunk-SFGW37LE.mjs';import'./chunk-FRQFU44F.mjs';import'./chunk-V5TZJJWU.mjs';import'./chunk-DBZSN4WP.mjs';import {b as b$1,a as a$3}from'./chunk-ZJYULEER.mjs';import {createContext,useContext}from'react';import {jsx}from'react/jsx-runtime';var c=createContext(null);function P(){let e=useContext(c);if(!e)throw new Error("Breach compound components must be wrapped in <Breach.Provider>. Example: <Breach.Provider categories={...}><Breach.ReportForm /></Breach.Provider>");return e}var p=({categories:e,adapter:m,storageKey:h,useLocalStorage:B,initialReports:f,onReport:R,onAssessment:x,onNotification:u,children:d})=>{let y=a$2({categories:e,adapter:m,storageKey:h,useLocalStorage:B,initialReports:f,onReport:R,onAssessment:x,onNotification:u}),l=b$1(a$3({},y),{categories:e});return jsx(c.Provider,{value:l,children:d})};var A={Provider:p,ReportForm:a$1,RiskAssessment:a,NotificationManager:b,ReportGenerator:c$1};export{A as Breach,p as BreachProvider,P as useBreachCompound};
2
+ import {c as c$1,b,a}from'./chunk-J7BIJ45O.mjs';export{b as BreachNotificationManager,a as BreachRiskAssessment,c as RegulatoryReportGenerator}from'./chunk-J7BIJ45O.mjs';import {a as a$1}from'./chunk-DK7P5JEG.mjs';export{a as BreachReportForm}from'./chunk-DK7P5JEG.mjs';import {a as a$2}from'./chunk-RFXGD5NE.mjs';export{a as useBreach}from'./chunk-RFXGD5NE.mjs';export{a as calculateBreachSeverity}from'./chunk-WTGKZX7J.mjs';import'./chunk-EWVK45Z3.mjs';import'./chunk-ITCY2Z66.mjs';import'./chunk-SFGW37LE.mjs';import'./chunk-FRQFU44F.mjs';import'./chunk-V5TZJJWU.mjs';import'./chunk-DBZSN4WP.mjs';import {b as b$1,a as a$3}from'./chunk-ZJYULEER.mjs';import {createContext,useContext}from'react';import {jsx}from'react/jsx-runtime';var c=createContext(null);function P(){let e=useContext(c);if(!e)throw new Error("Breach compound components must be wrapped in <Breach.Provider>. Example: <Breach.Provider categories={...}><Breach.ReportForm /></Breach.Provider>");return e}var p=({categories:e,adapter:m,storageKey:h,useLocalStorage:B,initialReports:f,onReport:R,onAssessment:x,onNotification:u,children:d})=>{let y=a$2({categories:e,adapter:m,storageKey:h,useLocalStorage:B,initialReports:f,onReport:R,onAssessment:x,onNotification:u}),l=b$1(a$3({},y),{categories:e});return jsx(c.Provider,{value:l,children:d})};var A={Provider:p,ReportForm:a$1,RiskAssessment:a,NotificationManager:b,ReportGenerator:c$1};export{A as Breach,p as BreachProvider,P as useBreachCompound};
@@ -0,0 +1 @@
1
+ var f=false,l=false;function m(e){if(e.length===0||e.length>254)return false;let t=e.indexOf("@");if(t<=0||t!==e.lastIndexOf("@"))return false;let d=e.slice(0,t),n=e.slice(t+1);return !(d.length===0||n.length===0||/\s/.test(e)||!n.includes(".")||n.startsWith(".")||n.endsWith("."))}function s(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function a(e){return typeof e=="string"&&e.trim().length>0}function c(e){if(!s(e)||!a(e.requestType)||!s(e.dataSubject))return false;let t=e.dataSubject;return !(!a(t.fullName)||!a(t.email)||typeof e.submittedAt!="number"||!Number.isFinite(e.submittedAt))}function b(e,t={}){var u,o;f||(f=true,console.warn("[ndpr-toolkit] `validateDsrSubmission()` returns a field-keyed `Record<string, string>` of English messages and will be removed in 5.0. Use `validateDsrSubmissionStructured()` for typed `{ field, code, message }[]` errors."));let{requireIdentityVerification:d=true,allowedRequestTypes:n}=t,i={};if(!s(e))return {valid:false,errors:{_root:"Payload must be an object"}};a(e.requestType)?n&&!n.includes(e.requestType)&&(i.requestType=`Request type "${e.requestType}" is not in the allowed set`):i.requestType="Request type is required";let r=e.dataSubject;return s(r)?(a(r.fullName)||(i["dataSubject.fullName"]="Full name is required"),a(r.email)?m(r.email)||(i["dataSubject.email"]="Email address format is invalid"):i["dataSubject.email"]="Email address is required",r.phone!==void 0&&typeof r.phone!="string"&&(i["dataSubject.phone"]="Phone must be a string when provided"),d&&(a(r.identifierType)||(i["dataSubject.identifierType"]="Identifier type is required"),a(r.identifierValue)||(i["dataSubject.identifierValue"]="Identifier value is required"))):i.dataSubject="Data subject information is required",(typeof e.submittedAt!="number"||!Number.isFinite(e.submittedAt))&&(i.submittedAt="submittedAt must be a finite number (ms timestamp)"),e.additionalInfo!==void 0&&!s(e.additionalInfo)&&(i.additionalInfo="additionalInfo must be an object when provided"),Object.keys(i).length>0?{valid:false,errors:i}:c(e)?{valid:true,errors:{},data:{requestType:e.requestType,dataSubject:{fullName:e.dataSubject.fullName,email:e.dataSubject.email,phone:e.dataSubject.phone,identifierType:(u=e.dataSubject.identifierType)!=null?u:"",identifierValue:(o=e.dataSubject.identifierValue)!=null?o:""},additionalInfo:e.additionalInfo,submittedAt:e.submittedAt}}:{valid:false,errors:{_root:"Payload failed final narrowing"}}}function p(e){var n,i;l||(l=true,console.warn("[ndpr-toolkit] `formatDSRRequest()` returns English error strings in `validationErrors` and will be removed in 5.0. Use `formatDSRRequestStructured()` for typed `{ field, code, message }[]` errors."));let t=[];return e.id||t.push("Request ID is required"),e.type||t.push("Request type is required"),e.status||t.push("Request status is required"),e.createdAt||t.push("Creation timestamp is required"),(n=e.subject)!=null&&n.name||t.push("Data subject name is required"),(i=e.subject)!=null&&i.email||t.push("Data subject email is required"),{formattedRequest:{requestId:e.id,requestType:e.type,status:e.status,createdDate:new Date(e.createdAt).toISOString(),lastUpdated:e.updatedAt?new Date(e.updatedAt).toISOString():void 0,dueDate:e.dueDate?new Date(e.dueDate).toISOString():void 0,dataSubject:e.subject?{name:e.subject.name,email:e.subject.email,phone:e.subject.phone||"Not provided",identifier:{type:e.subject.identifierType||"Not specified",value:e.subject.identifierValue||"Not provided"}}:void 0,additionalInformation:e.additionalInfo||{},verificationStatus:e.verification?`${e.verification.verified?"Verified":"Not verified"}${e.verification.method?` via ${e.verification.method}`:""}`:"Pending verification",attachments:e.attachments?e.attachments.map(r=>({name:r.name,type:r.type,addedOn:new Date(r.addedAt).toISOString()})):[]},isValid:t.length===0,validationErrors:t}}function S(e,t={}){var u,o;let{requireIdentityVerification:d=true,allowedRequestTypes:n}=t,i=[];if(!s(e))return {valid:false,errors:[{field:"_root",code:"payload_not_object",message:"Payload must be an object"}]};a(e.requestType)?n&&!n.includes(e.requestType)&&i.push({field:"requestType",code:"request_type_not_allowed",message:`Request type "${e.requestType}" is not in the allowed set`}):i.push({field:"requestType",code:"request_type_required",message:"Request type is required"});let r=e.dataSubject;return s(r)?(a(r.fullName)||i.push({field:"dataSubject.fullName",code:"full_name_required",message:"Full name is required"}),a(r.email)?m(r.email)||i.push({field:"dataSubject.email",code:"email_invalid_format",message:"Email address format is invalid"}):i.push({field:"dataSubject.email",code:"email_required",message:"Email address is required"}),r.phone!==void 0&&typeof r.phone!="string"&&i.push({field:"dataSubject.phone",code:"phone_invalid_type",message:"Phone must be a string when provided"}),d&&(a(r.identifierType)||i.push({field:"dataSubject.identifierType",code:"identifier_type_required",message:"Identifier type is required"}),a(r.identifierValue)||i.push({field:"dataSubject.identifierValue",code:"identifier_value_required",message:"Identifier value is required"}))):i.push({field:"dataSubject",code:"data_subject_required",message:"Data subject information is required"}),(typeof e.submittedAt!="number"||!Number.isFinite(e.submittedAt))&&i.push({field:"submittedAt",code:"submitted_at_invalid",message:"submittedAt must be a finite number (ms timestamp)"}),e.additionalInfo!==void 0&&!s(e.additionalInfo)&&i.push({field:"additionalInfo",code:"additional_info_invalid_type",message:"additionalInfo must be an object when provided"}),i.length>0?{valid:false,errors:i}:c(e)?{valid:true,errors:[],data:{requestType:e.requestType,dataSubject:{fullName:e.dataSubject.fullName,email:e.dataSubject.email,phone:e.dataSubject.phone,identifierType:(u=e.dataSubject.identifierType)!=null?u:"",identifierValue:(o=e.dataSubject.identifierValue)!=null?o:""},additionalInfo:e.additionalInfo,submittedAt:e.submittedAt}}:{valid:false,errors:[{field:"_root",code:"payload_final_narrowing_failed",message:"Payload failed final narrowing"}]}}function g(e){var n,i;let t=[];e.id||t.push({field:"id",code:"request_id_required",message:"Request ID is required"}),e.type||t.push({field:"type",code:"request_type_required",message:"Request type is required"}),e.status||t.push({field:"status",code:"request_status_required",message:"Request status is required"}),e.createdAt||t.push({field:"createdAt",code:"created_at_required",message:"Creation timestamp is required"}),(n=e.subject)!=null&&n.name||t.push({field:"subject.name",code:"subject_name_required",message:"Data subject name is required"}),(i=e.subject)!=null&&i.email||t.push({field:"subject.email",code:"subject_email_required",message:"Data subject email is required"});let d={requestId:e.id,requestType:e.type,status:e.status,createdDate:new Date(e.createdAt).toISOString(),lastUpdated:e.updatedAt?new Date(e.updatedAt).toISOString():void 0,dueDate:e.dueDate?new Date(e.dueDate).toISOString():void 0,dataSubject:e.subject?{name:e.subject.name,email:e.subject.email,phone:e.subject.phone||"Not provided",identifier:{type:e.subject.identifierType||"Not specified",value:e.subject.identifierValue||"Not provided"}}:void 0,additionalInformation:e.additionalInfo||{},verificationStatus:e.verification?`${e.verification.verified?"Verified":"Not verified"}${e.verification.method?` via ${e.verification.method}`:""}`:"Pending verification",attachments:e.attachments?e.attachments.map(r=>({name:r.name,type:r.type,addedOn:new Date(r.addedAt).toISOString()})):[]};return t.length>0?{valid:false,errors:t,formattedRequest:d}:{valid:true,errors:[],formattedRequest:d,data:e}}export{b as a,p as b,S as c,g as d};
@@ -0,0 +1 @@
1
+ 'use strict';var f=false,l=false;function m(e){if(e.length===0||e.length>254)return false;let t=e.indexOf("@");if(t<=0||t!==e.lastIndexOf("@"))return false;let d=e.slice(0,t),n=e.slice(t+1);return !(d.length===0||n.length===0||/\s/.test(e)||!n.includes(".")||n.startsWith(".")||n.endsWith("."))}function s(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function a(e){return typeof e=="string"&&e.trim().length>0}function c(e){if(!s(e)||!a(e.requestType)||!s(e.dataSubject))return false;let t=e.dataSubject;return !(!a(t.fullName)||!a(t.email)||typeof e.submittedAt!="number"||!Number.isFinite(e.submittedAt))}function b(e,t={}){var u,o;f||(f=true,console.warn("[ndpr-toolkit] `validateDsrSubmission()` returns a field-keyed `Record<string, string>` of English messages and will be removed in 5.0. Use `validateDsrSubmissionStructured()` for typed `{ field, code, message }[]` errors."));let{requireIdentityVerification:d=true,allowedRequestTypes:n}=t,i={};if(!s(e))return {valid:false,errors:{_root:"Payload must be an object"}};a(e.requestType)?n&&!n.includes(e.requestType)&&(i.requestType=`Request type "${e.requestType}" is not in the allowed set`):i.requestType="Request type is required";let r=e.dataSubject;return s(r)?(a(r.fullName)||(i["dataSubject.fullName"]="Full name is required"),a(r.email)?m(r.email)||(i["dataSubject.email"]="Email address format is invalid"):i["dataSubject.email"]="Email address is required",r.phone!==void 0&&typeof r.phone!="string"&&(i["dataSubject.phone"]="Phone must be a string when provided"),d&&(a(r.identifierType)||(i["dataSubject.identifierType"]="Identifier type is required"),a(r.identifierValue)||(i["dataSubject.identifierValue"]="Identifier value is required"))):i.dataSubject="Data subject information is required",(typeof e.submittedAt!="number"||!Number.isFinite(e.submittedAt))&&(i.submittedAt="submittedAt must be a finite number (ms timestamp)"),e.additionalInfo!==void 0&&!s(e.additionalInfo)&&(i.additionalInfo="additionalInfo must be an object when provided"),Object.keys(i).length>0?{valid:false,errors:i}:c(e)?{valid:true,errors:{},data:{requestType:e.requestType,dataSubject:{fullName:e.dataSubject.fullName,email:e.dataSubject.email,phone:e.dataSubject.phone,identifierType:(u=e.dataSubject.identifierType)!=null?u:"",identifierValue:(o=e.dataSubject.identifierValue)!=null?o:""},additionalInfo:e.additionalInfo,submittedAt:e.submittedAt}}:{valid:false,errors:{_root:"Payload failed final narrowing"}}}function p(e){var n,i;l||(l=true,console.warn("[ndpr-toolkit] `formatDSRRequest()` returns English error strings in `validationErrors` and will be removed in 5.0. Use `formatDSRRequestStructured()` for typed `{ field, code, message }[]` errors."));let t=[];return e.id||t.push("Request ID is required"),e.type||t.push("Request type is required"),e.status||t.push("Request status is required"),e.createdAt||t.push("Creation timestamp is required"),(n=e.subject)!=null&&n.name||t.push("Data subject name is required"),(i=e.subject)!=null&&i.email||t.push("Data subject email is required"),{formattedRequest:{requestId:e.id,requestType:e.type,status:e.status,createdDate:new Date(e.createdAt).toISOString(),lastUpdated:e.updatedAt?new Date(e.updatedAt).toISOString():void 0,dueDate:e.dueDate?new Date(e.dueDate).toISOString():void 0,dataSubject:e.subject?{name:e.subject.name,email:e.subject.email,phone:e.subject.phone||"Not provided",identifier:{type:e.subject.identifierType||"Not specified",value:e.subject.identifierValue||"Not provided"}}:void 0,additionalInformation:e.additionalInfo||{},verificationStatus:e.verification?`${e.verification.verified?"Verified":"Not verified"}${e.verification.method?` via ${e.verification.method}`:""}`:"Pending verification",attachments:e.attachments?e.attachments.map(r=>({name:r.name,type:r.type,addedOn:new Date(r.addedAt).toISOString()})):[]},isValid:t.length===0,validationErrors:t}}function S(e,t={}){var u,o;let{requireIdentityVerification:d=true,allowedRequestTypes:n}=t,i=[];if(!s(e))return {valid:false,errors:[{field:"_root",code:"payload_not_object",message:"Payload must be an object"}]};a(e.requestType)?n&&!n.includes(e.requestType)&&i.push({field:"requestType",code:"request_type_not_allowed",message:`Request type "${e.requestType}" is not in the allowed set`}):i.push({field:"requestType",code:"request_type_required",message:"Request type is required"});let r=e.dataSubject;return s(r)?(a(r.fullName)||i.push({field:"dataSubject.fullName",code:"full_name_required",message:"Full name is required"}),a(r.email)?m(r.email)||i.push({field:"dataSubject.email",code:"email_invalid_format",message:"Email address format is invalid"}):i.push({field:"dataSubject.email",code:"email_required",message:"Email address is required"}),r.phone!==void 0&&typeof r.phone!="string"&&i.push({field:"dataSubject.phone",code:"phone_invalid_type",message:"Phone must be a string when provided"}),d&&(a(r.identifierType)||i.push({field:"dataSubject.identifierType",code:"identifier_type_required",message:"Identifier type is required"}),a(r.identifierValue)||i.push({field:"dataSubject.identifierValue",code:"identifier_value_required",message:"Identifier value is required"}))):i.push({field:"dataSubject",code:"data_subject_required",message:"Data subject information is required"}),(typeof e.submittedAt!="number"||!Number.isFinite(e.submittedAt))&&i.push({field:"submittedAt",code:"submitted_at_invalid",message:"submittedAt must be a finite number (ms timestamp)"}),e.additionalInfo!==void 0&&!s(e.additionalInfo)&&i.push({field:"additionalInfo",code:"additional_info_invalid_type",message:"additionalInfo must be an object when provided"}),i.length>0?{valid:false,errors:i}:c(e)?{valid:true,errors:[],data:{requestType:e.requestType,dataSubject:{fullName:e.dataSubject.fullName,email:e.dataSubject.email,phone:e.dataSubject.phone,identifierType:(u=e.dataSubject.identifierType)!=null?u:"",identifierValue:(o=e.dataSubject.identifierValue)!=null?o:""},additionalInfo:e.additionalInfo,submittedAt:e.submittedAt}}:{valid:false,errors:[{field:"_root",code:"payload_final_narrowing_failed",message:"Payload failed final narrowing"}]}}function g(e){var n,i;let t=[];e.id||t.push({field:"id",code:"request_id_required",message:"Request ID is required"}),e.type||t.push({field:"type",code:"request_type_required",message:"Request type is required"}),e.status||t.push({field:"status",code:"request_status_required",message:"Request status is required"}),e.createdAt||t.push({field:"createdAt",code:"created_at_required",message:"Creation timestamp is required"}),(n=e.subject)!=null&&n.name||t.push({field:"subject.name",code:"subject_name_required",message:"Data subject name is required"}),(i=e.subject)!=null&&i.email||t.push({field:"subject.email",code:"subject_email_required",message:"Data subject email is required"});let d={requestId:e.id,requestType:e.type,status:e.status,createdDate:new Date(e.createdAt).toISOString(),lastUpdated:e.updatedAt?new Date(e.updatedAt).toISOString():void 0,dueDate:e.dueDate?new Date(e.dueDate).toISOString():void 0,dataSubject:e.subject?{name:e.subject.name,email:e.subject.email,phone:e.subject.phone||"Not provided",identifier:{type:e.subject.identifierType||"Not specified",value:e.subject.identifierValue||"Not provided"}}:void 0,additionalInformation:e.additionalInfo||{},verificationStatus:e.verification?`${e.verification.verified?"Verified":"Not verified"}${e.verification.method?` via ${e.verification.method}`:""}`:"Pending verification",attachments:e.attachments?e.attachments.map(r=>({name:r.name,type:r.type,addedOn:new Date(r.addedAt).toISOString()})):[]};return t.length>0?{valid:false,errors:t,formattedRequest:d}:{valid:true,errors:[],formattedRequest:d,data:e}}exports.a=b;exports.b=p;exports.c=S;exports.d=g;
@@ -0,0 +1 @@
1
+ 'use strict';var chunkZD2W3YU2_js=require('./chunk-ZD2W3YU2.js'),jsxRuntime=require('react/jsx-runtime');var m=[{id:"essential",label:"Essential Cookies",description:"Required for basic site functionality. Cannot be disabled.",required:true,purpose:"Site operation"},{id:"analytics",label:"Analytics",description:"Help us understand how visitors use our site to improve the experience.",required:false,purpose:"Usage analytics"},{id:"marketing",label:"Marketing",description:"Used to deliver relevant advertisements and track campaign effectiveness.",required:false,purpose:"Targeted advertising"},{id:"preferences",label:"Preferences",description:"Remember your settings and preferences for a personalised experience.",required:false,purpose:"Personalisation"}],g=({options:t,adapter:n,position:a="bottom",classNames:o,unstyled:l,onSave:s,copy:e})=>{let d=t!=null?t:m;return jsxRuntime.jsx(chunkZD2W3YU2_js.a,{options:d,onSave:i=>{n&&n.save(i),s==null||s(i);},position:a,classNames:o,unstyled:l,manageStorage:!n,title:e==null?void 0:e.title,description:e==null?void 0:e.description,acceptAllButtonText:e==null?void 0:e.acceptAll,rejectAllButtonText:e==null?void 0:e.rejectAll,customizeButtonText:e==null?void 0:e.customize,saveButtonText:e==null?void 0:e.save})};exports.a=g;
@@ -0,0 +1 @@
1
+ 'use strict';var chunkWZYCBW2R_js=require('./chunk-WZYCBW2R.js'),chunkAME4HJR4_js=require('./chunk-AME4HJR4.js'),chunkYDKWD6MQ_js=require('./chunk-YDKWD6MQ.js'),chunkRFPLZDIO_js=require('./chunk-RFPLZDIO.js'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var W={name:"",description:"",lawfulBasis:"consent",lawfulBasisJustification:"",dataCategories:"",involvesSensitiveData:false,sensitiveDataCondition:"",dataSubjectCategories:"",purposes:"",retentionPeriod:"",retentionJustification:"",recipients:"",crossBorderTransfer:false,reviewDate:"",liaPurposeTest:"",liaNecessityTest:"",liaBalancingTest:"",liaSafeguards:"",liaConclusion:""},de=[{value:"consent",label:"Consent"},{value:"contract",label:"Contract"},{value:"legal_obligation",label:"Legal Obligation"},{value:"vital_interests",label:"Vital Interests"},{value:"public_interest",label:"Public Interest"},{value:"legitimate_interests",label:"Legitimate Interests"}],oe=[{value:"explicit_consent",label:"Explicit Consent"},{value:"employment_law",label:"Employment Law"},{value:"vital_interests_incapable",label:"Vital Interests (Incapable)"},{value:"nonprofit_legitimate",label:"Nonprofit Legitimate Activities"},{value:"publicly_available",label:"Publicly Available Data"},{value:"legal_claims",label:"Legal Claims"},{value:"substantial_public_interest",label:"Substantial Public Interest"},{value:"health_purposes",label:"Health Purposes"},{value:"public_health",label:"Public Health"},{value:"archiving_research",label:"Archiving / Research"}],Le={active:"ndpr-badge ndpr-badge--success",inactive:"ndpr-badge ndpr-badge--neutral",under_review:"ndpr-badge ndpr-badge--warning",archived:"ndpr-badge ndpr-badge--destructive"},Te={active:"Active",inactive:"Inactive",under_review:"Under Review",archived:"Archived"},Fe={consent:"ndpr-badge ndpr-badge--info",contract:"ndpr-badge ndpr-badge--info",legal_obligation:"ndpr-badge ndpr-badge--info",vital_interests:"ndpr-badge ndpr-badge--destructive",public_interest:"ndpr-badge ndpr-badge--warning",legitimate_interests:"bg-indigo-100 text-indigo-800 dark:bg-indigo-900 dark:text-indigo-200"},Ie={consent:"Consent",contract:"Contract",legal_obligation:"Legal Obligation",vital_interests:"Vital Interests",public_interest:"Public Interest",legitimate_interests:"Legitimate Interests"},$e=({activities:g,onAddActivity:f,onUpdateActivity:b,onArchiveActivity:h,onAdd:_,onUpdate:w,onArchive:x,title:R,description:N,className:se="",buttonClassName:C="",showSummary:pe=true,showComplianceGaps:ue=true,classNames:i,unstyled:l})=>{var ie,re;let Y=react.useRef(false);react.useEffect(()=>{if(process.env.NODE_ENV==="production"||Y.current)return;let e=[];f!==void 0&&_===void 0&&e.push("onAddActivity -> onAdd"),b!==void 0&&w===void 0&&e.push("onUpdateActivity -> onUpdate"),h!==void 0&&x===void 0&&e.push("onArchiveActivity -> onArchive"),e.length>0&&(Y.current=true,console.warn(`[ndpr-toolkit/lawful-basis] Deprecated callback prop name(s): ${e.join(", ")}. Will be removed in 5.0.`));},[f,b,h,_,w,x]);let z=chunkYDKWD6MQ_js.c(),ce=(ie=R!=null?R:z.lawfulBasis.title)!=null?ie:"Lawful Basis Tracker",ge=(re=N!=null?N:z.lawfulBasis.description)!=null?re:"Document and track the lawful basis for each processing activity as required by NDPA 2023 Section 25.",[S,D]=react.useState("list"),[a,A]=react.useState(W),[m,O]=react.useState(null),[$,ve]=react.useState(null),[T,me]=react.useState("all"),[F,fe]=react.useState("all"),[I,be]=react.useState(""),[c,P]=react.useState([]),K=react.useMemo(()=>{let e=[...g];if(T!=="all"&&(e=e.filter(o=>o.status===T)),F!=="all"&&(e=e.filter(o=>o.lawfulBasis===F)),I){let o=I.toLowerCase();e=e.filter(p=>p.name.toLowerCase().includes(o)||p.description.toLowerCase().includes(o)||p.purposes.some(V=>V.toLowerCase().includes(o)));}return e.sort((o,p)=>p.updatedAt-o.updatedAt),e},[g,T,F,I]),k=react.useCallback(e=>new Date(e).toLocaleDateString(),[]),j=react.useMemo(()=>chunkWZYCBW2R_js.d(g),[g]),B=react.useMemo(()=>chunkWZYCBW2R_js.c(g),[g]),L=react.useCallback(e=>e.split(",").map(o=>o.trim()).filter(o=>o.length>0),[]),he=react.useCallback(()=>{A(W),O(null),P([]),D("form");},[]),Q=react.useCallback(e=>{A({name:e.name,description:e.description,lawfulBasis:e.lawfulBasis,lawfulBasisJustification:e.lawfulBasisJustification,dataCategories:e.dataCategories.join(", "),involvesSensitiveData:e.involvesSensitiveData,sensitiveDataCondition:e.sensitiveDataCondition||"",dataSubjectCategories:e.dataSubjectCategories.join(", "),purposes:e.purposes.join(", "),retentionPeriod:e.retentionPeriod,retentionJustification:e.retentionJustification||"",recipients:(e.recipients||[]).join(", "),crossBorderTransfer:e.crossBorderTransfer,reviewDate:e.reviewDate?new Date(e.reviewDate).toISOString().split("T")[0]:"",liaPurposeTest:"",liaNecessityTest:"",liaBalancingTest:"",liaSafeguards:"",liaConclusion:""}),O(e.id),P([]),D("form");},[]),_e=react.useCallback(()=>{let e={name:a.name,description:a.description,lawfulBasis:a.lawfulBasis,lawfulBasisJustification:a.lawfulBasisJustification,dataCategories:L(a.dataCategories),involvesSensitiveData:a.involvesSensitiveData,sensitiveDataCondition:a.sensitiveDataCondition||void 0,dataSubjectCategories:L(a.dataSubjectCategories),purposes:L(a.purposes),retentionPeriod:a.retentionPeriod,retentionJustification:a.retentionJustification||void 0,recipients:a.recipients?L(a.recipients):void 0,crossBorderTransfer:a.crossBorderTransfer,reviewDate:a.reviewDate?new Date(a.reviewDate).getTime():void 0,status:"active"},o=chunkRFPLZDIO_js.b(chunkRFPLZDIO_js.a({},e),{id:m||"temp",createdAt:Date.now(),updatedAt:Date.now()}),p=chunkWZYCBW2R_js.a(o);if(!p.isValid){P(p.errors);return}m?(w==null||w(m,e),b==null||b(m,e)):(_==null||_(e),f==null||f(e)),A(W),O(null),P([]),D("list");},[a,m,b,f,w,_,L]),X=react.useCallback(e=>{x==null||x(e),h==null||h(e);},[h,x]),we=react.useCallback(e=>{ve(e),D("detail");},[]),n=react.useMemo(()=>$?g.find(e=>e.id===$):null,[g,$]),Z=react.useCallback(e=>jsxRuntime.jsx("span",{className:chunkAME4HJR4_js.a(`px-2 py-1 rounded text-xs font-medium ${Le[e]}`,i==null?void 0:i.statusBadge,l),children:Te[e]}),[i==null?void 0:i.statusBadge,l]),U=react.useCallback(e=>jsxRuntime.jsx("span",{className:`px-2 py-1 rounded text-xs font-medium ${Fe[e]}`,children:Ie[e]}),[]),ee=react.useCallback(e=>e.dpoApproval?e.dpoApproval.approved?jsxRuntime.jsx("span",{className:"ndpr-badge ndpr-badge--success",children:"Approved"}):jsxRuntime.jsx("span",{className:"ndpr-badge ndpr-badge--warning",children:"Pending Approval"}):jsxRuntime.jsx("span",{className:"px-2 py-1 rounded text-xs font-medium bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400",children:"No DPO Review"}),[]),xe=()=>jsxRuntime.jsxs("div",{"data-ndpr-component":"lawful-basis-tracker",className:chunkAME4HJR4_js.a("grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",i==null?void 0:i.summary,l),role:"status","aria-label":"Compliance summary",children:[jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a("ndpr-alert ndpr-alert--info",i==null?void 0:i.summaryCard,l),children:[jsxRuntime.jsx("p",{className:"ndpr-stat__value ndpr-text-info",children:j.totalActivities}),jsxRuntime.jsx("p",{className:"text-sm ndpr-text-info",children:"Total Activities"})]}),jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a("bg-orange-50 dark:bg-orange-900/20 p-4 rounded-lg",i==null?void 0:i.summaryCard,l),children:[jsxRuntime.jsx("p",{className:"ndpr-stat__value ndpr-text-warning",children:j.sensitiveDataActivities}),jsxRuntime.jsx("p",{className:"text-sm ndpr-text-warning",children:"Sensitive Data"})]}),jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a("ndpr-alert ndpr-alert--info",i==null?void 0:i.summaryCard,l),children:[jsxRuntime.jsx("p",{className:"ndpr-stat__value ndpr-text-info",children:j.crossBorderActivities}),jsxRuntime.jsx("p",{className:"text-sm ndpr-text-info",children:"Cross-Border Transfers"})]}),jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a("ndpr-alert ndpr-alert--destructive",i==null?void 0:i.summaryCard,l),children:[jsxRuntime.jsx("p",{className:"ndpr-stat__value ndpr-text-destructive",children:j.activitiesWithoutApproval.length}),jsxRuntime.jsx("p",{className:"text-sm ndpr-text-destructive",children:"Pending Approval"})]})]}),G=react.useMemo(()=>B.filter(e=>e.severity==="high"),[B]),q=react.useMemo(()=>B.filter(e=>e.severity==="medium"),[B]),Ce=()=>B.length===0?jsxRuntime.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 p-4 rounded-lg mb-6",role:"status","aria-label":"No compliance gaps",children:[jsxRuntime.jsx("p",{className:"text-sm ndpr-text-success font-medium",children:"No compliance gaps detected."}),jsxRuntime.jsx("p",{className:"text-xs ndpr-text-success mt-1",children:"All processing activities appear to be properly documented."})]}):jsxRuntime.jsxs("div",{className:"mb-6",role:"status","aria-label":`${B.length} compliance gaps detected`,children:[G.length>0&&jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a("bg-red-50 dark:bg-red-900/20 p-4 rounded-lg mb-3",i==null?void 0:i.gapAlert,l),children:[jsxRuntime.jsxs("p",{className:"text-sm ndpr-text-destructive font-medium mb-2",children:["High Priority (",G.length,")"]}),jsxRuntime.jsx("ul",{className:"space-y-1",children:G.map((e,o)=>jsxRuntime.jsx("li",{className:"text-xs ndpr-text-destructive",children:e.description},o))})]}),q.length>0&&jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a("ndpr-alert ndpr-alert--warning",i==null?void 0:i.gapAlert,l),children:[jsxRuntime.jsxs("p",{className:"text-sm ndpr-text-warning font-medium mb-2",children:["Medium Priority (",q.length,")"]}),jsxRuntime.jsx("ul",{className:"space-y-1",children:q.map((e,o)=>jsxRuntime.jsx("li",{className:"text-xs ndpr-text-warning",children:e.description},o))})]})]}),te=react.useCallback(()=>{D("list"),P([]);},[]),De=react.useCallback(()=>{D("list");},[]),s=react.useCallback((e,o)=>{A(p=>chunkRFPLZDIO_js.b(chunkRFPLZDIO_js.a({},p),{[e]:o}));},[]),Be=react.useCallback(e=>{A(o=>chunkRFPLZDIO_js.b(chunkRFPLZDIO_js.a({},o),{involvesSensitiveData:e,sensitiveDataCondition:e?o.sensitiveDataCondition:""}));},[]),ye=()=>jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a("",i==null?void 0:i.form,l),children:[jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a("flex justify-between items-center mb-4",i==null?void 0:i.header,l),children:[jsxRuntime.jsx("h3",{className:"ndpr-section-heading",children:m?"Edit Processing Activity":"New Processing Activity"}),jsxRuntime.jsx("button",{onClick:te,className:`px-4 py-2 ndpr-text-muted bg-gray-100 dark:bg-gray-700 rounded hover:bg-gray-200 dark:hover:bg-gray-600 ${C}`,children:"Cancel"})]}),c.length>0&&jsxRuntime.jsxs("div",{id:"form-errors",className:"bg-red-50 dark:bg-red-900/20 p-4 rounded-lg mb-4",role:"alert",children:[jsxRuntime.jsx("p",{className:"text-sm ndpr-text-destructive font-medium mb-2",children:"Please correct the following errors:"}),jsxRuntime.jsx("ul",{className:"list-disc list-inside space-y-1",children:c.map((e,o)=>jsxRuntime.jsx("li",{className:"text-xs ndpr-text-destructive",children:e},o))})]}),jsxRuntime.jsxs("div",{className:"ndpr-form-section",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"activityName",className:"ndpr-form-field__label",children:"Activity Name *"}),jsxRuntime.jsx("input",{type:"text",id:"activityName",value:a.name,onChange:e=>s("name",e.target.value),placeholder:"e.g., Customer Account Management","aria-required":"true","aria-describedby":c.length>0?"form-errors":void 0,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"activityDescription",className:"ndpr-form-field__label",children:"Description *"}),jsxRuntime.jsx("textarea",{id:"activityDescription",value:a.description,onChange:e=>s("description",e.target.value),placeholder:"Describe what processing is performed...",rows:3,"aria-required":"true","aria-describedby":c.length>0?"form-errors":void 0,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"lawfulBasis",className:"ndpr-form-field__label",children:"Lawful Basis (NDPA Section 25) *"}),jsxRuntime.jsx("select",{id:"lawfulBasis",value:a.lawfulBasis,onChange:e=>s("lawfulBasis",e.target.value),"aria-required":"true",className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.select,l),children:de.map(e=>jsxRuntime.jsx("option",{value:e.value,children:e.label},e.value))}),jsxRuntime.jsx("p",{className:"mt-1 text-xs ndpr-text-muted",children:chunkWZYCBW2R_js.b(a.lawfulBasis)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"justification",className:"ndpr-form-field__label",children:"Lawful Basis Justification *"}),jsxRuntime.jsx("textarea",{id:"justification",value:a.lawfulBasisJustification,onChange:e=>s("lawfulBasisJustification",e.target.value),placeholder:"Document why this lawful basis applies to this processing activity...",rows:3,"aria-required":"true","aria-describedby":c.length>0?"form-errors":void 0,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),a.lawfulBasis==="legitimate_interests"&&jsxRuntime.jsxs("div",{className:"border border-indigo-200 dark:border-indigo-800 rounded-lg p-4 bg-indigo-50 dark:bg-indigo-900/20",children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold text-indigo-800 dark:text-indigo-200 mb-3",children:"Legitimate Interest Assessment (LIA)"}),jsxRuntime.jsx("p",{className:"text-xs text-indigo-600 dark:text-indigo-300 mb-4",children:"NDPA Section 25(1)(f) requires a balancing test when relying on legitimate interests."}),jsxRuntime.jsxs("div",{className:"ndpr-form-section",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"liaPurpose",className:"ndpr-form-field__label",children:"Purpose Test"}),jsxRuntime.jsx("textarea",{id:"liaPurpose",value:a.liaPurposeTest,onChange:e=>s("liaPurposeTest",e.target.value),placeholder:"Describe the legitimate interest being pursued...",rows:2,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"liaNecessity",className:"ndpr-form-field__label",children:"Necessity Test"}),jsxRuntime.jsx("textarea",{id:"liaNecessity",value:a.liaNecessityTest,onChange:e=>s("liaNecessityTest",e.target.value),placeholder:"Explain why this processing is necessary for the stated purpose...",rows:2,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"liaBalancing",className:"ndpr-form-field__label",children:"Balancing Test"}),jsxRuntime.jsx("textarea",{id:"liaBalancing",value:a.liaBalancingTest,onChange:e=>s("liaBalancingTest",e.target.value),placeholder:"Assess the impact on data subjects' rights and interests...",rows:2,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"liaSafeguards",className:"ndpr-form-field__label",children:"Safeguards"}),jsxRuntime.jsx("input",{type:"text",id:"liaSafeguards",value:a.liaSafeguards,onChange:e=>s("liaSafeguards",e.target.value),placeholder:"List safeguards (comma-separated)...",className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"liaConclusion",className:"ndpr-form-field__label",children:"Conclusion"}),jsxRuntime.jsx("textarea",{id:"liaConclusion",value:a.liaConclusion,onChange:e=>s("liaConclusion",e.target.value),placeholder:"State your overall conclusion...",rows:2,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"dataCategories",className:"ndpr-form-field__label",children:"Data Categories *"}),jsxRuntime.jsx("input",{type:"text",id:"dataCategories",value:a.dataCategories,onChange:e=>s("dataCategories",e.target.value),placeholder:"e.g., Name, Email, Phone Number (comma-separated)","aria-required":"true","aria-describedby":c.length>0?"form-errors":void 0,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsxs("label",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:a.involvesSensitiveData,onChange:e=>Be(e.target.checked),className:"rounded border-gray-300 dark:border-gray-600 text-[rgb(var(--ndpr-primary))] focus:ring-[rgb(var(--ndpr-ring))]"}),jsxRuntime.jsx("span",{className:"ndpr-text-sm ndpr-font-medium",children:"Involves Sensitive Personal Data (NDPA Section 27)"})]})}),a.involvesSensitiveData&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"sensitiveCondition",className:"ndpr-form-field__label",children:"Sensitive Data Condition (NDPA Section 27) *"}),jsxRuntime.jsxs("select",{id:"sensitiveCondition",value:a.sensitiveDataCondition,onChange:e=>s("sensitiveDataCondition",e.target.value),"aria-required":"true",className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.select,l),children:[jsxRuntime.jsx("option",{value:"",children:"Select a condition..."}),oe.map(e=>jsxRuntime.jsx("option",{value:e.value,children:e.label},e.value))]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"dataSubjectCategories",className:"ndpr-form-field__label",children:"Data Subject Categories *"}),jsxRuntime.jsx("input",{type:"text",id:"dataSubjectCategories",value:a.dataSubjectCategories,onChange:e=>s("dataSubjectCategories",e.target.value),placeholder:"e.g., Customers, Employees, Vendors (comma-separated)","aria-required":"true","aria-describedby":c.length>0?"form-errors":void 0,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"purposes",className:"ndpr-form-field__label",children:"Processing Purposes *"}),jsxRuntime.jsx("input",{type:"text",id:"purposes",value:a.purposes,onChange:e=>s("purposes",e.target.value),placeholder:"e.g., Account management, Service delivery (comma-separated)","aria-required":"true","aria-describedby":c.length>0?"form-errors":void 0,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{className:"ndpr-form-grid ndpr-form-grid--2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"retentionPeriod",className:"ndpr-form-field__label",children:"Retention Period *"}),jsxRuntime.jsx("input",{type:"text",id:"retentionPeriod",value:a.retentionPeriod,onChange:e=>s("retentionPeriod",e.target.value),placeholder:"e.g., 3 years after account closure","aria-required":"true","aria-describedby":c.length>0?"form-errors":void 0,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"retentionJustification",className:"ndpr-form-field__label",children:"Retention Justification"}),jsxRuntime.jsx("input",{type:"text",id:"retentionJustification",value:a.retentionJustification,onChange:e=>s("retentionJustification",e.target.value),placeholder:"Reason for the retention period",className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"recipients",className:"ndpr-form-field__label",children:"Recipients"}),jsxRuntime.jsx("input",{type:"text",id:"recipients",value:a.recipients,onChange:e=>s("recipients",e.target.value),placeholder:"e.g., Payment processor, Cloud provider (comma-separated)",className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsxs("label",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:a.crossBorderTransfer,onChange:e=>s("crossBorderTransfer",e.target.checked),className:"rounded border-gray-300 dark:border-gray-600 text-[rgb(var(--ndpr-primary))] focus:ring-[rgb(var(--ndpr-ring))]"}),jsxRuntime.jsx("span",{className:"ndpr-text-sm ndpr-font-medium",children:"Involves Cross-Border Transfer Outside Nigeria"})]})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"reviewDate",className:"ndpr-form-field__label",children:"Next Review Date"}),jsxRuntime.jsx("input",{type:"date",id:"reviewDate",value:a.reviewDate,onChange:e=>s("reviewDate",e.target.value),className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{className:"flex justify-end space-x-3 pt-4",children:[jsxRuntime.jsx("button",{onClick:te,className:`px-4 py-2 ndpr-text-muted bg-gray-100 dark:bg-gray-700 rounded hover:bg-gray-200 dark:hover:bg-gray-600 ${C}`,children:"Cancel"}),jsxRuntime.jsx("button",{onClick:_e,className:chunkAME4HJR4_js.a(`px-4 py-2 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] ${C}`,(i==null?void 0:i.primaryButton)||(i==null?void 0:i.submitButton),l),children:m?"Update Activity":"Create Activity"})]})]})]}),Se=()=>{var o;if(!n)return jsxRuntime.jsx("div",{className:"ndpr-empty-state",children:jsxRuntime.jsx("p",{className:"ndpr-card__subtitle",children:"Activity not found."})});let e=chunkWZYCBW2R_js.a(n);return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("button",{onClick:De,className:"text-sm ndpr-text-primary hover:underline mb-2","aria-label":"Back to activities list",children:"Back to list"}),jsxRuntime.jsx("h3",{className:"ndpr-section-heading",children:n.name})]}),jsxRuntime.jsxs("div",{className:"ndpr-card__footer",children:[U(n.lawfulBasis),Z(n.status),ee(n)]})]}),e.warnings.length>0&&jsxRuntime.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 p-3 rounded-md mb-4",children:[jsxRuntime.jsx("p",{className:"text-sm ndpr-text-warning font-medium mb-1",children:"Warnings"}),jsxRuntime.jsx("ul",{className:"list-disc list-inside space-y-1",children:e.warnings.map((p,V)=>jsxRuntime.jsx("li",{className:"text-xs ndpr-text-warning",children:p},V))})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("p",{className:"ndpr-text-sm",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Description:"})," ",n.description]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Lawful Basis:"})," ",chunkWZYCBW2R_js.b(n.lawfulBasis)]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Justification:"})," ",n.lawfulBasisJustification]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("p",{className:"ndpr-text-sm",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Data Categories:"})," ",n.dataCategories.join(", ")]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Data Subject Categories:"})," ",n.dataSubjectCategories.join(", ")]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Purposes:"})," ",n.purposes.join(", ")]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Retention Period:"})," ",n.retentionPeriod,n.retentionJustification&&jsxRuntime.jsxs("span",{className:"ndpr-card__subtitle",children:[" ","(",n.retentionJustification,")"]})]})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("p",{className:"ndpr-text-sm",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Sensitive Data:"})," ",n.involvesSensitiveData?"Yes":"No",n.sensitiveDataCondition&&jsxRuntime.jsxs("span",{children:[" ","(Condition:"," ",((o=oe.find(p=>p.value===n.sensitiveDataCondition))==null?void 0:o.label)||n.sensitiveDataCondition,")"]})]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Cross-Border Transfer:"})," ",n.crossBorderTransfer?"Yes":"No"]}),n.recipients&&n.recipients.length>0&&jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Recipients:"})," ",n.recipients.join(", ")]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("p",{className:"ndpr-text-sm",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Created:"})," ",k(n.createdAt)]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Last Updated:"})," ",k(n.updatedAt)]}),n.reviewDate&&jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Next Review:"})," ",k(n.reviewDate),n.reviewDate<Date.now()&&jsxRuntime.jsx("span",{className:"ndpr-text-destructive font-medium",children:" (Overdue)"})]})]})]}),n.dpoApproval&&jsxRuntime.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-4 rounded-md mb-6",children:[jsxRuntime.jsx("h4",{className:"ndpr-section-heading",children:"DPO Approval"}),jsxRuntime.jsxs("p",{className:"ndpr-text-sm",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Status:"})," ",n.dpoApproval.approved?"Approved":"Not Approved"]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Approved By:"})," ",n.dpoApproval.approvedBy]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Date:"})," ",k(n.dpoApproval.approvedAt)]}),n.dpoApproval.notes&&jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Notes:"})," ",n.dpoApproval.notes]})]}),jsxRuntime.jsxs("div",{className:"flex space-x-3",children:[jsxRuntime.jsx("button",{onClick:()=>Q(n),"aria-label":`Edit ${n.name}`,className:`px-4 py-2 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] ${C}`,children:"Edit"}),n.status!=="archived"&&jsxRuntime.jsx("button",{onClick:()=>X(n.id),"aria-label":`Archive ${n.name}`,className:`px-4 py-2 bg-gray-600 text-white rounded hover:bg-gray-700 ${C}`,children:"Archive"})]})]})},Ae=()=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"mb-6 grid grid-cols-1 md:grid-cols-4 gap-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"basisFilter",className:"ndpr-form-field__label",children:"Lawful Basis"}),jsxRuntime.jsxs("select",{id:"basisFilter",value:F,onChange:e=>fe(e.target.value),"aria-label":"Filter by lawful basis",className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.select,l),children:[jsxRuntime.jsx("option",{value:"all",children:"All Bases"}),de.map(e=>jsxRuntime.jsx("option",{value:e.value,children:e.label},e.value))]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"statusFilterSelect",className:"ndpr-form-field__label",children:"Status"}),jsxRuntime.jsxs("select",{id:"statusFilterSelect",value:T,onChange:e=>me(e.target.value),"aria-label":"Filter by status",className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.select,l),children:[jsxRuntime.jsx("option",{value:"all",children:"All Statuses"}),jsxRuntime.jsx("option",{value:"active",children:"Active"}),jsxRuntime.jsx("option",{value:"inactive",children:"Inactive"}),jsxRuntime.jsx("option",{value:"under_review",children:"Under Review"}),jsxRuntime.jsx("option",{value:"archived",children:"Archived"})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"searchInput",className:"ndpr-form-field__label",children:"Search"}),jsxRuntime.jsx("input",{type:"text",id:"searchInput",value:I,onChange:e=>be(e.target.value),placeholder:"Search activities...",className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsx("div",{className:"flex items-end",children:jsxRuntime.jsx("button",{onClick:he,className:chunkAME4HJR4_js.a(`w-full px-4 py-2 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] ${C}`,(i==null?void 0:i.primaryButton)||(i==null?void 0:i.submitButton),l),children:"Add Activity"})})]}),K.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-32 bg-gray-50 dark:bg-gray-700 rounded-md",children:jsxRuntime.jsx("p",{className:"ndpr-card__subtitle",children:"No processing activities found."})}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:chunkAME4HJR4_js.a("w-full text-sm text-left",i==null?void 0:i.table,l),children:[jsxRuntime.jsx("thead",{className:chunkAME4HJR4_js.a("ndpr-table__head",i==null?void 0:i.tableHeader,l),children:jsxRuntime.jsxs("tr",{children:[jsxRuntime.jsx("th",{className:"ndpr-table__cell",children:"Activity"}),jsxRuntime.jsx("th",{className:"ndpr-table__cell",children:"Lawful Basis"}),jsxRuntime.jsx("th",{className:"ndpr-table__cell",children:"Status"}),jsxRuntime.jsx("th",{className:"ndpr-table__cell",children:"DPO Approval"}),jsxRuntime.jsx("th",{className:"ndpr-table__cell",children:"Sensitive Data"}),jsxRuntime.jsx("th",{className:"ndpr-table__cell",children:"Last Updated"}),jsxRuntime.jsx("th",{className:"ndpr-table__cell",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{children:K.map(e=>jsxRuntime.jsxs("tr",{className:chunkAME4HJR4_js.a("border-b border-gray-200 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700",i==null?void 0:i.tableRow,l),children:[jsxRuntime.jsxs("td",{className:"ndpr-table__cell",children:[jsxRuntime.jsx("button",{onClick:()=>we(e.id),className:"font-medium ndpr-text-primary hover:underline text-left",children:e.name}),jsxRuntime.jsx("p",{className:"text-xs ndpr-text-muted mt-1 truncate max-w-xs",children:e.description})]}),jsxRuntime.jsx("td",{className:"ndpr-table__cell",children:U(e.lawfulBasis)}),jsxRuntime.jsx("td",{className:"ndpr-table__cell",children:Z(e.status)}),jsxRuntime.jsx("td",{className:"ndpr-table__cell",children:ee(e)}),jsxRuntime.jsx("td",{className:"ndpr-table__cell",children:jsxRuntime.jsx("span",{className:`text-xs ${e.involvesSensitiveData?"ndpr-text-warning font-medium":"ndpr-card__subtitle"}`,children:e.involvesSensitiveData?"Yes":"No"})}),jsxRuntime.jsx("td",{className:"ndpr-table__cell ndpr-table__cell--muted",children:k(e.updatedAt)}),jsxRuntime.jsx("td",{className:"ndpr-table__cell",children:jsxRuntime.jsxs("div",{className:"ndpr-card__footer",children:[jsxRuntime.jsx("button",{onClick:()=>Q(e),"aria-label":`Edit ${e.name}`,className:"text-xs ndpr-text-primary hover:underline",children:"Edit"}),e.status!=="archived"&&jsxRuntime.jsx("button",{onClick:()=>X(e.id),"aria-label":`Archive ${e.name}`,className:"text-xs ndpr-text-muted hover:underline",children:"Archive"})]})})]},e.id))})]})})]});return jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a(`bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md ${se}`,i==null?void 0:i.root,l),children:[jsxRuntime.jsx("h2",{className:chunkAME4HJR4_js.a("ndpr-section-heading",i==null?void 0:i.title,l),children:ce}),jsxRuntime.jsx("p",{className:"ndpr-card__subtitle",children:ge}),pe&&S==="list"&&xe(),ue&&S==="list"&&Ce(),S==="list"&&Ae(),S==="form"&&ye(),S==="detail"&&Se()]})};exports.a=$e;
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-I2ZBMR7F.mjs';import {jsx}from'react/jsx-runtime';var m=[{id:"essential",label:"Essential Cookies",description:"Required for basic site functionality. Cannot be disabled.",required:true,purpose:"Site operation"},{id:"analytics",label:"Analytics",description:"Help us understand how visitors use our site to improve the experience.",required:false,purpose:"Usage analytics"},{id:"marketing",label:"Marketing",description:"Used to deliver relevant advertisements and track campaign effectiveness.",required:false,purpose:"Targeted advertising"},{id:"preferences",label:"Preferences",description:"Remember your settings and preferences for a personalised experience.",required:false,purpose:"Personalisation"}],g=({options:t,adapter:n,position:a$1="bottom",classNames:o,unstyled:l,onSave:s,copy:e})=>{let d=t!=null?t:m;return jsx(a,{options:d,onSave:i=>{n&&n.save(i),s==null||s(i);},position:a$1,classNames:o,unstyled:l,manageStorage:!n,title:e==null?void 0:e.title,description:e==null?void 0:e.description,acceptAllButtonText:e==null?void 0:e.acceptAll,rejectAllButtonText:e==null?void 0:e.rejectAll,customizeButtonText:e==null?void 0:e.customize,saveButtonText:e==null?void 0:e.save})};export{g as a};
@@ -1 +1 @@
1
- import {b}from'./chunk-VPNK7OID.mjs';import {a}from'./chunk-SFGW37LE.mjs';import {c}from'./chunk-FRQFU44F.mjs';import {useState,useEffect}from'react';import {jsxs,jsx}from'react/jsx-runtime';var pe=({requests:w,onSelectRequest:I,onUpdateStatus:j,onAssignRequest:C,title:V,description:M,className:X="",buttonClassName:L="",showRequestDetails:Z=true,showRequestTimeline:ee=true,showDeadlineAlerts:U=true,assignees:i=[],classNames:l,unstyled:R=false})=>{var u,v;let E=c(),te=(u=V!=null?V:E.dsr.dashboardTitle)!=null?u:"Data Subject Request Dashboard",_=(v=M!=null?M:E.dsr.dashboardDescription)!=null?v:"Track and manage data subject requests in compliance with NDPA Part IV requirements.",[f,y]=useState(null),[D,q]=useState(w),[T,K]=useState("all"),[P,$]=useState("all"),[A,H]=useState(""),[F,ae]=useState("createdAt"),[W,de]=useState("desc"),[S,re]=useState("");useEffect(()=>{let e=[...w];if(T!=="all"&&(e=e.filter(r=>r.status===T)),P!=="all"&&(e=e.filter(r=>r.type===P)),A){let r=A.toLowerCase();e=e.filter(p=>p.subject.name.toLowerCase().includes(r)||p.subject.email.toLowerCase().includes(r)||p.description&&p.description.toLowerCase().includes(r));}e.sort((r,p)=>{let h=0;switch(F){case "createdAt":h=r.createdAt-p.createdAt;break;case "dueDate":h=(r.dueDate||0)-(p.dueDate||0);break;case "type":h=r.type.localeCompare(p.type);break;case "status":h=r.status.localeCompare(p.status);break;default:h=r.createdAt-p.createdAt;}return W==="asc"?h:-h}),q(e);},[w,T,P,A,F,W]),useEffect(()=>{D.length>0&&(f&&D.some(r=>r.id===f)||y(D[0].id));},[D,f]);let J=e=>{y(e),I&&I(e);},Y=e=>{f&&j&&j(f,e);},ie=()=>{f&&S&&C&&(C(f,S),re(""));},k=e=>new Date(e).toLocaleDateString(),z=e=>{let r=Date.now(),p=(e-r)/(1440*60*1e3);return Math.ceil(p)},m=f?w.find(e=>e.id===f):null,B=e=>{let r={information:"bg-teal-100 text-teal-800 dark:bg-teal-900 dark:text-teal-200",access:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",rectification:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",erasure:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",restriction:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",portability:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200",objection:"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200",automated_decision_making:"bg-indigo-100 text-indigo-800 dark:bg-indigo-900 dark:text-indigo-200",withdraw_consent:"bg-pink-100 text-pink-800 dark:bg-pink-900 dark:text-pink-200"},p={information:"Information",access:"Access",rectification:"Rectification",erasure:"Erasure",restriction:"Restriction",portability:"Portability",objection:"Objection",automated_decision_making:"Automated Decision-Making",withdraw_consent:"Withdraw Consent"};return jsx("span",{className:`px-2 py-1 rounded text-xs font-medium ${r[e]}`,children:p[e]})},O=e=>jsx("span",{className:a(`px-2 py-1 rounded text-xs font-medium ${{pending:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",inProgress:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",completed:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",rejected:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",awaitingVerification:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200"}[e]}`,l==null?void 0:l.statusBadge,R),children:e==="inProgress"?"In Progress":e==="awaitingVerification"?"Awaiting Verification":e.charAt(0).toUpperCase()+e.slice(1)}),t=e=>{if(!e.dueDate)return null;let r=z(e.dueDate);return r<=0?jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 p-3 rounded-md",role:"alert","aria-live":"polite",children:[jsx("p",{className:"text-sm text-red-800 dark:text-red-200 font-medium",children:"Deadline Passed"}),jsx("p",{className:"text-xs text-red-700 dark:text-red-300 mt-1",children:"The response deadline has passed. Immediate action is required."})]}):r<=3?jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 p-3 rounded-md",role:"alert","aria-live":"polite",children:[jsx("p",{className:"text-sm text-red-800 dark:text-red-200 font-medium",children:"Urgent: Deadline Approaching"}),jsxs("p",{className:"text-xs text-red-700 dark:text-red-300 mt-1",children:["Only ",r," day",r!==1?"s":""," remaining until the response deadline."]})]}):r<=7?jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 p-3 rounded-md","aria-live":"polite",children:[jsx("p",{className:"text-sm text-yellow-800 dark:text-yellow-200 font-medium",children:"Deadline Approaching"}),jsxs("p",{className:"text-xs text-yellow-700 dark:text-yellow-300 mt-1",children:[r," days remaining until the response deadline."]})]}):jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 p-3 rounded-md","aria-live":"polite",children:[jsx("p",{className:"text-sm text-green-800 dark:text-green-200 font-medium",children:"Deadline Tracking"}),jsxs("p",{className:"text-xs text-green-700 dark:text-green-300 mt-1",children:[r," days remaining until the response deadline."]})]})},s=e=>{let r=[{title:"Request Received",date:e.createdAt,completed:true,description:`Request was received on ${k(e.createdAt)}.`}];return e.verifiedAt?r.push({title:"Identity Verified",date:e.verifiedAt,completed:true,description:`Data subject's identity was verified on ${k(e.verifiedAt)}.`}):e.status==="awaitingVerification"&&r.push({title:"Identity Verification",date:Date.now(),completed:false,description:"Awaiting verification of data subject's identity."}),(e.status==="inProgress"||e.status==="completed"||e.status==="rejected")&&r.push({title:"Processing Started",date:e.updatedAt,completed:true,description:`Request processing started on ${k(e.updatedAt)}.`}),e.status==="completed"?r.push({title:"Request Completed",date:e.completedAt||Date.now(),completed:true,description:`Request was completed on ${k(e.completedAt||Date.now())}.`}):e.status==="rejected"&&r.push({title:"Request Rejected",date:e.completedAt||Date.now(),completed:true,description:`Request was rejected on ${k(e.completedAt||Date.now())}.${e.rejectionReason?` Reason: ${e.rejectionReason}`:""}`}),e.dueDate&&r.push({title:"Response Deadline",date:e.dueDate,completed:Date.now()>e.dueDate,description:`Response is due by ${k(e.dueDate)}.`}),jsxs("div",{className:"mt-6",children:[jsx("h3",{className:"text-lg font-medium mb-4",children:"Request Timeline"}),jsx("ol",{className:"relative border-l border-gray-200 dark:border-gray-700",children:r.map((p,h)=>jsxs("li",{className:"mb-6 ml-4",children:[jsx("div",{className:`absolute w-3 h-3 rounded-full mt-1.5 -left-1.5 border ${p.completed?"bg-green-500 border-green-500 dark:border-green-500":"bg-gray-200 border-gray-200 dark:bg-gray-700 dark:border-gray-700"}`}),jsx("time",{className:"mb-1 text-sm font-normal leading-none text-gray-600 dark:text-gray-500",children:p.date?k(p.date):"Pending"}),jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:p.title}),jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:p.description})]},h))})]})},g=()=>[{value:"all",label:"All Types"},{value:"information",label:"Information (NDPA Section 27)"},{value:"access",label:"Access (NDPA Section 34(1)(a))"},{value:"rectification",label:"Rectification (NDPA Section 34(1)(c))"},{value:"erasure",label:"Erasure (NDPA Section 34(1)(d))"},{value:"restriction",label:"Restriction (NDPA Section 34(1)(e))"},{value:"portability",label:"Portability (NDPA Section 38)"},{value:"objection",label:"Objection (NDPA Section 36)"},{value:"automated_decision_making",label:"Automated Decision-Making (NDPA Section 37)"},{value:"withdraw_consent",label:"Withdraw Consent (NDPA Section 35)"}].map(r=>jsx("option",{value:r.value,children:r.label},r.value)),x=()=>[{value:"all",label:"All Statuses"},{value:"pending",label:"Pending"},{value:"awaitingVerification",label:"Awaiting Verification"},{value:"inProgress",label:"In Progress"},{value:"completed",label:"Completed"},{value:"rejected",label:"Rejected"}].map(r=>jsx("option",{value:r.value,children:r.label},r.value)),o=()=>[{value:"pending",label:"Pending"},{value:"awaitingVerification",label:"Awaiting Verification"},{value:"inProgress",label:"In Progress"},{value:"completed",label:"Completed"},{value:"rejected",label:"Rejected"}].map(r=>jsx("option",{value:r.value,children:r.label},r.value));return jsxs("div",{className:a(`bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md ${X}`,l==null?void 0:l.root,R),children:[jsxs("div",{className:a("",l==null?void 0:l.header,R),children:[jsx("h2",{className:a("text-xl font-bold mb-2",l==null?void 0:l.title,R),children:te}),jsx("p",{className:"mb-6 text-gray-600 dark:text-gray-300",children:_})]}),jsxs("div",{className:a("mb-6 grid grid-cols-1 md:grid-cols-4 gap-4",l==null?void 0:l.filters,R),children:[jsxs("div",{children:[jsx("label",{htmlFor:"statusFilter",className:"block text-sm font-medium mb-1",children:"Status Filter"}),jsx("select",{id:"statusFilter",value:T,onChange:e=>K(e.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-[rgb(var(--ndpr-ring))]",children:x()})]}),jsxs("div",{children:[jsx("label",{htmlFor:"typeFilter",className:"block text-sm font-medium mb-1",children:"Request Type Filter"}),jsx("select",{id:"typeFilter",value:P,onChange:e=>$(e.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-[rgb(var(--ndpr-ring))]",children:g()})]}),jsxs("div",{children:[jsx("label",{htmlFor:"sortBy",className:"block text-sm font-medium mb-1",children:"Sort By"}),jsxs("select",{id:"sortBy",value:F,onChange:e=>ae(e.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-[rgb(var(--ndpr-ring))]",children:[jsx("option",{value:"createdAt",children:"Date Received"}),jsx("option",{value:"dueDate",children:"Due Date"}),jsx("option",{value:"type",children:"Request Type"}),jsx("option",{value:"status",children:"Status"})]})]}),jsxs("div",{children:[jsx("label",{htmlFor:"searchTerm",className:"block text-sm font-medium mb-1",children:"Search"}),jsx("input",{type:"text",id:"searchTerm",value:A,onChange:e=>H(e.target.value),placeholder:"Search requests...",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-[rgb(var(--ndpr-ring))]"})]})]}),jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[jsxs("div",{className:"md:col-span-1",children:[jsx("h3",{className:"text-lg font-medium mb-3",children:"DSR Requests"}),D.length===0?jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm",children:"No data subject requests found."}):jsx("div",{className:a("space-y-2 max-h-96 overflow-y-auto pr-2",l==null?void 0:l.requestList,R),children:D.map(e=>{let r=e.dueDate?z(e.dueDate):null,p=null;return r!==null&&(r<=0?p=jsx("span",{className:"text-xs text-red-600 dark:text-red-400 font-bold",children:"Overdue"}):r<=3?p=jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:"Urgent"}):r<=7&&(p=jsx("span",{className:"text-xs text-yellow-600 dark:text-yellow-400",children:"Soon"}))),jsxs("div",{role:"button",tabIndex:0,"aria-label":`View request from ${e.subject.name}`,"aria-selected":f===e.id,className:a(`p-3 rounded-md cursor-pointer ${f===e.id?"bg-[rgb(var(--ndpr-primary)/0.05)] dark:bg-[rgb(var(--ndpr-primary)/0.1)] border border-[rgb(var(--ndpr-primary)/0.2)] dark:border-[rgb(var(--ndpr-primary)/0.3)]":"bg-gray-50 dark:bg-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600"}`,l==null?void 0:l.requestItem,R),onClick:()=>J(e.id),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),J(e.id));},children:[jsxs("div",{className:"flex justify-between items-start mb-1",children:[jsx("h4",{className:"font-medium text-sm",children:e.subject.name}),B(e.type)]}),jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mb-1",children:e.subject.email}),jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400 mb-1",children:["Received: ",k(e.createdAt)]}),jsxs("div",{className:"flex justify-between items-center mt-2",children:[jsx("div",{children:O(e.status)}),jsx("div",{children:p})]})]},e.id)})})]}),jsx("div",{className:a("md:col-span-2",l==null?void 0:l.detailPanel,R),children:m?jsxs("div",{children:[jsxs("div",{className:"flex justify-between items-start mb-4",children:[jsx("h3",{className:"text-lg font-medium",children:m.subject.name}),jsxs("div",{className:"flex space-x-2",children:[B(m.type),O(m.status)]})]}),U&&m.dueDate&&jsx("div",{className:"mb-4",children:t(m)}),Z&&jsxs("div",{className:"mb-6",children:[jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[jsxs("div",{children:[jsxs("p",{className:"text-sm",children:[jsx("span",{className:"font-medium",children:"Email:"})," ",m.subject.email]}),m.subject.phone&&jsxs("p",{className:"text-sm",children:[jsx("span",{className:"font-medium",children:"Phone:"})," ",m.subject.phone]}),jsxs("p",{className:"text-sm",children:[jsx("span",{className:"font-medium",children:"Received:"})," ",k(m.createdAt)]})]}),jsxs("div",{children:[jsxs("p",{className:"text-sm",children:[jsx("span",{className:"font-medium",children:"Request Type:"})," ",{information:"Information",access:"Access",rectification:"Rectification",erasure:"Erasure",restriction:"Restriction",portability:"Portability",objection:"Objection",automated_decision_making:"Automated Decision-Making"}[m.type]||m.type]}),jsxs("p",{className:"text-sm",children:[jsx("span",{className:"font-medium",children:"Status:"})," ",m.status==="inProgress"?"In Progress":m.status==="awaitingVerification"?"Awaiting Verification":m.status.charAt(0).toUpperCase()+m.status.slice(1)]}),m.dueDate&&jsxs("p",{className:"text-sm",children:[jsx("span",{className:"font-medium",children:"Due Date:"})," ",k(m.dueDate)]})]})]}),m.description&&jsxs("div",{className:"mb-4",children:[jsx("p",{className:"text-sm font-medium",children:"Request Details:"}),jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 bg-gray-50 dark:bg-gray-700 p-2 rounded-md mt-1",children:m.description})]}),m.additionalInfo&&jsxs("div",{children:[jsx("p",{className:"text-sm font-medium",children:"Additional Information:"}),jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 bg-gray-50 dark:bg-gray-700 p-2 rounded-md mt-1",children:typeof m.additionalInfo=="object"?JSON.stringify(m.additionalInfo,null,2):String(m.additionalInfo||"No additional information provided")})]})]}),jsxs("div",{className:"mb-6 grid grid-cols-1 md:grid-cols-2 gap-4",children:[jsxs("div",{children:[jsx("h3",{id:"update-status-heading",className:"text-md font-medium mb-2",children:"Update Status"}),jsxs("div",{className:"flex space-x-2",children:[jsx("select",{"aria-label":"Update request status",value:m.status,onChange:e=>Y(e.target.value),className:"flex-grow px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-[rgb(var(--ndpr-ring))]",children:o()}),jsx("button",{onClick:()=>Y(m.status),"aria-label":"Apply status update",className:`px-4 py-2 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] ${L}`,children:"Update"})]})]}),i.length>0&&jsxs("div",{children:[jsx("h3",{id:"assign-request-heading",className:"text-md font-medium mb-2",children:"Assign Request"}),jsxs("div",{className:"flex space-x-2",children:[jsxs("select",{"aria-label":"Select assignee",value:S,onChange:e=>re(e.target.value),className:"flex-grow px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-[rgb(var(--ndpr-ring))]",children:[jsx("option",{value:"",children:"Select Assignee"}),i.map(e=>jsx("option",{value:e,children:e},e))]}),jsx("button",{onClick:ie,disabled:!S,"aria-label":"Assign request to selected person",className:`px-4 py-2 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] disabled:bg-gray-300 disabled:text-gray-500 ${L}`,children:"Assign"})]})]})]}),jsxs("div",{className:"mb-6",children:[jsx("h3",{className:"text-lg font-medium mb-3",children:"Request Summary"}),jsx("div",{className:"bg-gray-50 dark:bg-gray-700 p-3 rounded-md",children:jsx("pre",{className:"whitespace-pre-wrap text-sm font-mono text-gray-800 dark:text-gray-200",children:jsx("pre",{children:JSON.stringify(b(m),null,2)})})})]}),ee&&s(m)]}):jsx("div",{className:"flex items-center justify-center h-64 bg-gray-50 dark:bg-gray-700 rounded-md",children:jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Select a request to view details"})})})]})]})};var ke=({requests:w,onSelectRequest:I,title:j,description:C,className:V="",buttonClassName:M="",showSummaryStats:X=true,showTypeBreakdown:L=true,showStatusBreakdown:Z=true,showTimelineChart:ee=true,showOverdueRequests:U=true,classNames:i,unstyled:l=false})=>{var B,O;let R=c(),E=(B=j!=null?j:R.dsr.trackerTitle)!=null?B:"DSR Request Tracker",te=(O=C!=null?C:R.dsr.trackerDescription)!=null?O:"Track the status and progress of data subject requests as required by NDPA Part IV.",[_,f]=useState("30days"),[y,D]=useState(w),[q,T]=useState([]),[K,P]=useState([]);useEffect(()=>{let t=Date.now(),s;switch(_){case "7days":s=w.filter(o=>t-o.createdAt<=10080*60*1e3);break;case "30days":s=w.filter(o=>t-o.createdAt<=720*60*60*1e3);break;case "90days":s=w.filter(o=>t-o.createdAt<=2160*60*60*1e3);break;default:s=[...w];}D(s);let g=s.filter(o=>o.dueDate&&t>o.dueDate&&o.status!=="completed"&&o.status!=="rejected");T(g);let x=s.filter(o=>o.dueDate&&t<o.dueDate&&o.dueDate-t<=10080*60*1e3&&o.status!=="completed"&&o.status!=="rejected");P(x);},[w,_]);let $=t=>{I&&I(t);},A=t=>new Date(t).toLocaleDateString(),H=t=>{let s=Date.now(),g=(t-s)/(1440*60*1e3);return Math.ceil(g)},F=()=>{let t=y.filter(g=>g.status==="completed"&&g.completedAt&&g.createdAt);if(t.length===0)return null;let s=t.reduce((g,x)=>{let o=((x.completedAt||0)-x.createdAt)/864e5;return g+o},0);return Number((s/t.length).toFixed(1))},ae=()=>{let t=y.filter(g=>(g.status==="completed"||g.status==="rejected")&&g.completedAt&&g.dueDate);if(t.length===0)return null;let s=t.filter(g=>(g.completedAt||0)<=(g.dueDate||0));return Math.round(s.length/t.length*100)},W=()=>{let t={};return y.forEach(s=>{t[s.type]=(t[s.type]||0)+1;}),{information:t.information||0,access:t.access||0,rectification:t.rectification||0,erasure:t.erasure||0,restriction:t.restriction||0,portability:t.portability||0,objection:t.objection||0,automated_decision_making:t.automated_decision_making||0,withdraw_consent:t.withdraw_consent||0}},de=()=>{let t={};return y.forEach(s=>{t[s.status]=(t[s.status]||0)+1;}),{pending:t.pending||0,awaitingVerification:t.awaitingVerification||0,inProgress:t.inProgress||0,completed:t.completed||0,rejected:t.rejected||0}},S=t=>{let s={information:"bg-teal-100 text-teal-800 dark:bg-teal-900 dark:text-teal-200",access:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",rectification:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",erasure:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",restriction:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",portability:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200",objection:"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200",automated_decision_making:"bg-indigo-100 text-indigo-800 dark:bg-indigo-900 dark:text-indigo-200",withdraw_consent:"bg-pink-100 text-pink-800 dark:bg-pink-900 dark:text-pink-200"},g={information:"Information",access:"Access",rectification:"Rectification",erasure:"Erasure",restriction:"Restriction",portability:"Portability",objection:"Objection",automated_decision_making:"Automated Decision-Making",withdraw_consent:"Withdraw Consent"};return jsx("span",{className:`px-2 py-1 rounded text-xs font-medium ${s[t]}`,children:g[t]})},J=()=>{let t=y.length,s=y.filter(u=>u.status!=="completed"&&u.status!=="rejected").length;y.filter(u=>u.status==="completed"||u.status==="rejected").length;let x=F(),o=ae();return jsxs("div",{className:a("grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",i==null?void 0:i.stats,l),children:[jsxs("div",{className:a("bg-white dark:bg-gray-700 p-4 rounded-lg shadow",i==null?void 0:i.statCard,l),children:[jsx("h4",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Total Requests"}),jsx("p",{className:"text-2xl font-bold",children:t})]}),jsxs("div",{className:a("bg-white dark:bg-gray-700 p-4 rounded-lg shadow",i==null?void 0:i.statCard,l),children:[jsx("h4",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Pending Requests"}),jsx("p",{className:"text-2xl font-bold",children:s})]}),jsxs("div",{className:a("bg-white dark:bg-gray-700 p-4 rounded-lg shadow",i==null?void 0:i.statCard,l),children:[jsx("h4",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Avg. Response Time"}),jsx("p",{className:"text-2xl font-bold",children:x!==null?`${x} days`:"N/A"})]}),jsxs("div",{className:a("bg-white dark:bg-gray-700 p-4 rounded-lg shadow",i==null?void 0:i.statCard,l),children:[jsx("h4",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Compliance Rate"}),jsx("p",{className:"text-2xl font-bold",children:o!==null?`${o}%`:"N/A"})]})]})},Y=()=>{let t=W(),s=y.length,g=Object.entries(t).sort(([,x],[,o])=>o-x).map(([x])=>x);return jsxs("div",{className:a("bg-white dark:bg-gray-700 p-4 rounded-lg shadow mb-6",i==null?void 0:i.table,l),children:[jsx("h3",{className:a("text-lg font-medium mb-4",i==null?void 0:i.tableHeader,l),children:"Request Types"}),s===0?jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm",children:"No data available for the selected timeframe."}):jsx("div",{className:"space-y-4",children:g.map(x=>{let o=t[x],u=Math.round(o/s*100);return jsxs("div",{children:[jsxs("div",{className:"flex justify-between items-center mb-1",children:[jsxs("div",{className:"flex items-center",children:[S(x),jsxs("span",{className:"ml-2 text-sm",children:[o," requests"]})]}),jsxs("span",{className:"text-sm font-medium",children:[u,"%"]})]}),jsx("div",{className:"w-full bg-gray-200 dark:bg-gray-600 rounded-full h-2.5",children:jsx("div",{className:"bg-[rgb(var(--ndpr-primary))] h-2.5 rounded-full",style:{width:`${u}%`}})})]},x)})})]})},ie=()=>{let t=de(),s=y.length,g=["pending","awaitingVerification","inProgress","completed","rejected"],x={pending:"bg-yellow-500",awaitingVerification:"bg-purple-500",inProgress:"bg-blue-500",completed:"bg-green-500",rejected:"bg-red-500"};return jsxs("div",{className:a("bg-white dark:bg-gray-700 p-4 rounded-lg shadow mb-6",i==null?void 0:i.table,l),children:[jsx("h3",{className:a("text-lg font-medium mb-4",i==null?void 0:i.tableHeader,l),children:"Request Status"}),s===0?jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm",children:"No data available for the selected timeframe."}):jsxs("div",{children:[jsx("div",{className:"flex h-4 mb-2",children:g.map(o=>{let u=t[o],v=u/s*100;return v>0?jsx("div",{className:`${x[o]} first:rounded-l-full last:rounded-r-full`,style:{width:`${v}%`},title:`${o}: ${u} (${Math.round(v)}%)`},o):null})}),jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-2 mt-4",children:g.map(o=>{let u=t[o],v=Math.round(u/s*100);return jsxs("div",{className:"flex items-center",children:[jsx("div",{className:`w-3 h-3 rounded-full ${x[o]} mr-2`}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium",children:o==="inProgress"?"In Progress":o==="awaitingVerification"?"Awaiting Verification":o.charAt(0).toUpperCase()+o.slice(1)}),jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:[u," (",v,"%)"]})]})]},o)})})]})]})},k=()=>{let t={};y.forEach(u=>{let v=new Date(u.createdAt),e=`${v.getFullYear()}-${String(v.getMonth()+1).padStart(2,"0")}`;t[e]=(t[e]||0)+1;});let g=Object.keys(t).sort().slice(-6),x=Math.max(...Object.values(t).filter(u=>u>0),1),o=u=>{let[v,e]=u.split("-");return `${e}/${v.slice(2)}`};return jsxs("div",{className:"bg-white dark:bg-gray-700 p-4 rounded-lg shadow mb-6",children:[jsx("h3",{className:"text-lg font-medium mb-4",children:"Request Timeline"}),g.length===0?jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm",children:"No data available for the selected timeframe."}):jsxs("div",{className:"h-40",children:[jsx("div",{className:"flex h-32 items-end justify-between space-x-2",children:g.map(u=>{let v=t[u],e=`${v/x*100}%`;return jsx("div",{className:"flex flex-col items-center flex-1",children:jsx("div",{className:"w-full bg-[rgb(var(--ndpr-primary))] rounded-t",style:{height:e},title:`${o(u)}: ${v} requests`})},u)})}),jsx("div",{className:"flex justify-between mt-2",children:g.map(u=>jsx("div",{className:"text-xs text-center",children:o(u)},u))})]})]})},z=()=>jsxs("div",{className:"bg-white dark:bg-gray-700 p-4 rounded-lg shadow mb-6","aria-live":"polite",children:[jsx("h3",{className:"text-lg font-medium mb-4",children:"Overdue Requests"}),q.length===0?jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm",children:"No overdue requests."}):jsx("div",{className:"space-y-2 max-h-60 overflow-y-auto",children:q.map(t=>jsxs("div",{role:"button",tabIndex:0,"aria-label":`View overdue request from ${t.subject.name}`,className:a("p-3 bg-red-50 dark:bg-red-900/20 rounded-md cursor-pointer hover:bg-red-100 dark:hover:bg-red-900/30",i==null?void 0:i.tableRow,l),onClick:()=>$(t.id),onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),$(t.id));},children:[jsxs("div",{className:"flex justify-between items-start mb-1",children:[jsx("h4",{className:"font-medium text-sm",children:t.subject.name}),S(t.type)]}),jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mb-1",children:t.subject.email}),jsxs("div",{className:"flex justify-between items-center",children:[jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:["Due: ",A(t.dueDate||0)]}),jsxs("p",{className:"text-xs font-bold text-red-600 dark:text-red-400",children:["Overdue by ",Math.abs(H(t.dueDate||0))," days"]})]})]},t.id))})]}),m=()=>jsxs("div",{className:"bg-white dark:bg-gray-700 p-4 rounded-lg shadow mb-6","aria-live":"polite",children:[jsx("h3",{className:"text-lg font-medium mb-4",children:"Upcoming Deadlines"}),K.length===0?jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm",children:"No upcoming deadlines in the next 7 days."}):jsx("div",{className:"space-y-2 max-h-60 overflow-y-auto",children:K.map(t=>{let s=H(t.dueDate||0);return jsxs("div",{role:"button",tabIndex:0,"aria-label":`View upcoming deadline for ${t.subject.name}`,className:a("p-3 bg-yellow-50 dark:bg-yellow-900/20 rounded-md cursor-pointer hover:bg-yellow-100 dark:hover:bg-yellow-900/30",i==null?void 0:i.tableRow,l),onClick:()=>$(t.id),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),$(t.id));},children:[jsxs("div",{className:"flex justify-between items-start mb-1",children:[jsx("h4",{className:"font-medium text-sm",children:t.subject.name}),S(t.type)]}),jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mb-1",children:t.subject.email}),jsxs("div",{className:"flex justify-between items-center",children:[jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:["Due: ",A(t.dueDate||0)]}),jsxs("p",{className:`text-xs font-bold ${s<=3?"text-red-600 dark:text-red-400":"text-yellow-600 dark:text-yellow-400"}`,children:["Due in ",s," days"]})]})]},t.id)})})]});return jsxs("div",{className:a(`bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md ${V}`,i==null?void 0:i.root,l),children:[jsxs("div",{className:a("flex flex-col md:flex-row md:justify-between md:items-center mb-6",i==null?void 0:i.header,l),children:[jsxs("div",{children:[jsx("h2",{className:a("text-xl font-bold mb-2",i==null?void 0:i.title,l),children:E}),jsx("p",{className:"text-gray-600 dark:text-gray-300",children:te})]}),jsxs("div",{className:"mt-4 md:mt-0",children:[jsx("label",{htmlFor:"timeframe",className:"block text-sm font-medium mb-1",children:"Timeframe"}),jsxs("select",{id:"timeframe",value:_,onChange:t=>f(t.target.value),className:"px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-[rgb(var(--ndpr-ring))]",children:[jsx("option",{value:"7days",children:"Last 7 Days"}),jsx("option",{value:"30days",children:"Last 30 Days"}),jsx("option",{value:"90days",children:"Last 90 Days"}),jsx("option",{value:"all",children:"All Time"})]})]})]}),X&&J(),jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[jsxs("div",{children:[L&&Y(),Z&&ie()]}),jsxs("div",{children:[ee&&k(),U&&z(),U&&m()]})]})]})};export{pe as a,ke as b};
1
+ import {b}from'./chunk-3APT25XO.mjs';import {a}from'./chunk-SFGW37LE.mjs';import {c}from'./chunk-FRQFU44F.mjs';import {useState,useEffect}from'react';import {jsxs,jsx}from'react/jsx-runtime';var pe=({requests:w,onSelectRequest:I,onUpdateStatus:j,onAssignRequest:C,title:V,description:M,className:X="",buttonClassName:L="",showRequestDetails:Z=true,showRequestTimeline:ee=true,showDeadlineAlerts:U=true,assignees:i=[],classNames:l,unstyled:R=false})=>{var u,v;let E=c(),te=(u=V!=null?V:E.dsr.dashboardTitle)!=null?u:"Data Subject Request Dashboard",_=(v=M!=null?M:E.dsr.dashboardDescription)!=null?v:"Track and manage data subject requests in compliance with NDPA Part IV requirements.",[f,y]=useState(null),[D,q]=useState(w),[T,K]=useState("all"),[P,$]=useState("all"),[A,H]=useState(""),[F,ae]=useState("createdAt"),[W,de]=useState("desc"),[S,re]=useState("");useEffect(()=>{let e=[...w];if(T!=="all"&&(e=e.filter(r=>r.status===T)),P!=="all"&&(e=e.filter(r=>r.type===P)),A){let r=A.toLowerCase();e=e.filter(p=>p.subject.name.toLowerCase().includes(r)||p.subject.email.toLowerCase().includes(r)||p.description&&p.description.toLowerCase().includes(r));}e.sort((r,p)=>{let h=0;switch(F){case "createdAt":h=r.createdAt-p.createdAt;break;case "dueDate":h=(r.dueDate||0)-(p.dueDate||0);break;case "type":h=r.type.localeCompare(p.type);break;case "status":h=r.status.localeCompare(p.status);break;default:h=r.createdAt-p.createdAt;}return W==="asc"?h:-h}),q(e);},[w,T,P,A,F,W]),useEffect(()=>{D.length>0&&(f&&D.some(r=>r.id===f)||y(D[0].id));},[D,f]);let J=e=>{y(e),I&&I(e);},Y=e=>{f&&j&&j(f,e);},ie=()=>{f&&S&&C&&(C(f,S),re(""));},k=e=>new Date(e).toLocaleDateString(),z=e=>{let r=Date.now(),p=(e-r)/(1440*60*1e3);return Math.ceil(p)},m=f?w.find(e=>e.id===f):null,B=e=>{let r={information:"bg-teal-100 text-teal-800 dark:bg-teal-900 dark:text-teal-200",access:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",rectification:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",erasure:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",restriction:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",portability:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200",objection:"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200",automated_decision_making:"bg-indigo-100 text-indigo-800 dark:bg-indigo-900 dark:text-indigo-200",withdraw_consent:"bg-pink-100 text-pink-800 dark:bg-pink-900 dark:text-pink-200"},p={information:"Information",access:"Access",rectification:"Rectification",erasure:"Erasure",restriction:"Restriction",portability:"Portability",objection:"Objection",automated_decision_making:"Automated Decision-Making",withdraw_consent:"Withdraw Consent"};return jsx("span",{className:`px-2 py-1 rounded text-xs font-medium ${r[e]}`,children:p[e]})},O=e=>jsx("span",{className:a(`px-2 py-1 rounded text-xs font-medium ${{pending:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",inProgress:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",completed:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",rejected:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",awaitingVerification:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200"}[e]}`,l==null?void 0:l.statusBadge,R),children:e==="inProgress"?"In Progress":e==="awaitingVerification"?"Awaiting Verification":e.charAt(0).toUpperCase()+e.slice(1)}),t=e=>{if(!e.dueDate)return null;let r=z(e.dueDate);return r<=0?jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 p-3 rounded-md",role:"alert","aria-live":"polite",children:[jsx("p",{className:"text-sm text-red-800 dark:text-red-200 font-medium",children:"Deadline Passed"}),jsx("p",{className:"text-xs text-red-700 dark:text-red-300 mt-1",children:"The response deadline has passed. Immediate action is required."})]}):r<=3?jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 p-3 rounded-md",role:"alert","aria-live":"polite",children:[jsx("p",{className:"text-sm text-red-800 dark:text-red-200 font-medium",children:"Urgent: Deadline Approaching"}),jsxs("p",{className:"text-xs text-red-700 dark:text-red-300 mt-1",children:["Only ",r," day",r!==1?"s":""," remaining until the response deadline."]})]}):r<=7?jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 p-3 rounded-md","aria-live":"polite",children:[jsx("p",{className:"text-sm text-yellow-800 dark:text-yellow-200 font-medium",children:"Deadline Approaching"}),jsxs("p",{className:"text-xs text-yellow-700 dark:text-yellow-300 mt-1",children:[r," days remaining until the response deadline."]})]}):jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 p-3 rounded-md","aria-live":"polite",children:[jsx("p",{className:"text-sm text-green-800 dark:text-green-200 font-medium",children:"Deadline Tracking"}),jsxs("p",{className:"text-xs text-green-700 dark:text-green-300 mt-1",children:[r," days remaining until the response deadline."]})]})},s=e=>{let r=[{title:"Request Received",date:e.createdAt,completed:true,description:`Request was received on ${k(e.createdAt)}.`}];return e.verifiedAt?r.push({title:"Identity Verified",date:e.verifiedAt,completed:true,description:`Data subject's identity was verified on ${k(e.verifiedAt)}.`}):e.status==="awaitingVerification"&&r.push({title:"Identity Verification",date:Date.now(),completed:false,description:"Awaiting verification of data subject's identity."}),(e.status==="inProgress"||e.status==="completed"||e.status==="rejected")&&r.push({title:"Processing Started",date:e.updatedAt,completed:true,description:`Request processing started on ${k(e.updatedAt)}.`}),e.status==="completed"?r.push({title:"Request Completed",date:e.completedAt||Date.now(),completed:true,description:`Request was completed on ${k(e.completedAt||Date.now())}.`}):e.status==="rejected"&&r.push({title:"Request Rejected",date:e.completedAt||Date.now(),completed:true,description:`Request was rejected on ${k(e.completedAt||Date.now())}.${e.rejectionReason?` Reason: ${e.rejectionReason}`:""}`}),e.dueDate&&r.push({title:"Response Deadline",date:e.dueDate,completed:Date.now()>e.dueDate,description:`Response is due by ${k(e.dueDate)}.`}),jsxs("div",{className:"mt-6",children:[jsx("h3",{className:"text-lg font-medium mb-4",children:"Request Timeline"}),jsx("ol",{className:"relative border-l border-gray-200 dark:border-gray-700",children:r.map((p,h)=>jsxs("li",{className:"mb-6 ml-4",children:[jsx("div",{className:`absolute w-3 h-3 rounded-full mt-1.5 -left-1.5 border ${p.completed?"bg-green-500 border-green-500 dark:border-green-500":"bg-gray-200 border-gray-200 dark:bg-gray-700 dark:border-gray-700"}`}),jsx("time",{className:"mb-1 text-sm font-normal leading-none text-gray-600 dark:text-gray-500",children:p.date?k(p.date):"Pending"}),jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:p.title}),jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:p.description})]},h))})]})},g=()=>[{value:"all",label:"All Types"},{value:"information",label:"Information (NDPA Section 27)"},{value:"access",label:"Access (NDPA Section 34(1)(a))"},{value:"rectification",label:"Rectification (NDPA Section 34(1)(c))"},{value:"erasure",label:"Erasure (NDPA Section 34(1)(d))"},{value:"restriction",label:"Restriction (NDPA Section 34(1)(e))"},{value:"portability",label:"Portability (NDPA Section 38)"},{value:"objection",label:"Objection (NDPA Section 36)"},{value:"automated_decision_making",label:"Automated Decision-Making (NDPA Section 37)"},{value:"withdraw_consent",label:"Withdraw Consent (NDPA Section 35)"}].map(r=>jsx("option",{value:r.value,children:r.label},r.value)),x=()=>[{value:"all",label:"All Statuses"},{value:"pending",label:"Pending"},{value:"awaitingVerification",label:"Awaiting Verification"},{value:"inProgress",label:"In Progress"},{value:"completed",label:"Completed"},{value:"rejected",label:"Rejected"}].map(r=>jsx("option",{value:r.value,children:r.label},r.value)),o=()=>[{value:"pending",label:"Pending"},{value:"awaitingVerification",label:"Awaiting Verification"},{value:"inProgress",label:"In Progress"},{value:"completed",label:"Completed"},{value:"rejected",label:"Rejected"}].map(r=>jsx("option",{value:r.value,children:r.label},r.value));return jsxs("div",{className:a(`bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md ${X}`,l==null?void 0:l.root,R),children:[jsxs("div",{className:a("",l==null?void 0:l.header,R),children:[jsx("h2",{className:a("text-xl font-bold mb-2",l==null?void 0:l.title,R),children:te}),jsx("p",{className:"mb-6 text-gray-600 dark:text-gray-300",children:_})]}),jsxs("div",{className:a("mb-6 grid grid-cols-1 md:grid-cols-4 gap-4",l==null?void 0:l.filters,R),children:[jsxs("div",{children:[jsx("label",{htmlFor:"statusFilter",className:"block text-sm font-medium mb-1",children:"Status Filter"}),jsx("select",{id:"statusFilter",value:T,onChange:e=>K(e.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-[rgb(var(--ndpr-ring))]",children:x()})]}),jsxs("div",{children:[jsx("label",{htmlFor:"typeFilter",className:"block text-sm font-medium mb-1",children:"Request Type Filter"}),jsx("select",{id:"typeFilter",value:P,onChange:e=>$(e.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-[rgb(var(--ndpr-ring))]",children:g()})]}),jsxs("div",{children:[jsx("label",{htmlFor:"sortBy",className:"block text-sm font-medium mb-1",children:"Sort By"}),jsxs("select",{id:"sortBy",value:F,onChange:e=>ae(e.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-[rgb(var(--ndpr-ring))]",children:[jsx("option",{value:"createdAt",children:"Date Received"}),jsx("option",{value:"dueDate",children:"Due Date"}),jsx("option",{value:"type",children:"Request Type"}),jsx("option",{value:"status",children:"Status"})]})]}),jsxs("div",{children:[jsx("label",{htmlFor:"searchTerm",className:"block text-sm font-medium mb-1",children:"Search"}),jsx("input",{type:"text",id:"searchTerm",value:A,onChange:e=>H(e.target.value),placeholder:"Search requests...",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-[rgb(var(--ndpr-ring))]"})]})]}),jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[jsxs("div",{className:"md:col-span-1",children:[jsx("h3",{className:"text-lg font-medium mb-3",children:"DSR Requests"}),D.length===0?jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm",children:"No data subject requests found."}):jsx("div",{className:a("space-y-2 max-h-96 overflow-y-auto pr-2",l==null?void 0:l.requestList,R),children:D.map(e=>{let r=e.dueDate?z(e.dueDate):null,p=null;return r!==null&&(r<=0?p=jsx("span",{className:"text-xs text-red-600 dark:text-red-400 font-bold",children:"Overdue"}):r<=3?p=jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:"Urgent"}):r<=7&&(p=jsx("span",{className:"text-xs text-yellow-600 dark:text-yellow-400",children:"Soon"}))),jsxs("div",{role:"button",tabIndex:0,"aria-label":`View request from ${e.subject.name}`,"aria-selected":f===e.id,className:a(`p-3 rounded-md cursor-pointer ${f===e.id?"bg-[rgb(var(--ndpr-primary)/0.05)] dark:bg-[rgb(var(--ndpr-primary)/0.1)] border border-[rgb(var(--ndpr-primary)/0.2)] dark:border-[rgb(var(--ndpr-primary)/0.3)]":"bg-gray-50 dark:bg-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600"}`,l==null?void 0:l.requestItem,R),onClick:()=>J(e.id),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),J(e.id));},children:[jsxs("div",{className:"flex justify-between items-start mb-1",children:[jsx("h4",{className:"font-medium text-sm",children:e.subject.name}),B(e.type)]}),jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mb-1",children:e.subject.email}),jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400 mb-1",children:["Received: ",k(e.createdAt)]}),jsxs("div",{className:"flex justify-between items-center mt-2",children:[jsx("div",{children:O(e.status)}),jsx("div",{children:p})]})]},e.id)})})]}),jsx("div",{className:a("md:col-span-2",l==null?void 0:l.detailPanel,R),children:m?jsxs("div",{children:[jsxs("div",{className:"flex justify-between items-start mb-4",children:[jsx("h3",{className:"text-lg font-medium",children:m.subject.name}),jsxs("div",{className:"flex space-x-2",children:[B(m.type),O(m.status)]})]}),U&&m.dueDate&&jsx("div",{className:"mb-4",children:t(m)}),Z&&jsxs("div",{className:"mb-6",children:[jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[jsxs("div",{children:[jsxs("p",{className:"text-sm",children:[jsx("span",{className:"font-medium",children:"Email:"})," ",m.subject.email]}),m.subject.phone&&jsxs("p",{className:"text-sm",children:[jsx("span",{className:"font-medium",children:"Phone:"})," ",m.subject.phone]}),jsxs("p",{className:"text-sm",children:[jsx("span",{className:"font-medium",children:"Received:"})," ",k(m.createdAt)]})]}),jsxs("div",{children:[jsxs("p",{className:"text-sm",children:[jsx("span",{className:"font-medium",children:"Request Type:"})," ",{information:"Information",access:"Access",rectification:"Rectification",erasure:"Erasure",restriction:"Restriction",portability:"Portability",objection:"Objection",automated_decision_making:"Automated Decision-Making"}[m.type]||m.type]}),jsxs("p",{className:"text-sm",children:[jsx("span",{className:"font-medium",children:"Status:"})," ",m.status==="inProgress"?"In Progress":m.status==="awaitingVerification"?"Awaiting Verification":m.status.charAt(0).toUpperCase()+m.status.slice(1)]}),m.dueDate&&jsxs("p",{className:"text-sm",children:[jsx("span",{className:"font-medium",children:"Due Date:"})," ",k(m.dueDate)]})]})]}),m.description&&jsxs("div",{className:"mb-4",children:[jsx("p",{className:"text-sm font-medium",children:"Request Details:"}),jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 bg-gray-50 dark:bg-gray-700 p-2 rounded-md mt-1",children:m.description})]}),m.additionalInfo&&jsxs("div",{children:[jsx("p",{className:"text-sm font-medium",children:"Additional Information:"}),jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 bg-gray-50 dark:bg-gray-700 p-2 rounded-md mt-1",children:typeof m.additionalInfo=="object"?JSON.stringify(m.additionalInfo,null,2):String(m.additionalInfo||"No additional information provided")})]})]}),jsxs("div",{className:"mb-6 grid grid-cols-1 md:grid-cols-2 gap-4",children:[jsxs("div",{children:[jsx("h3",{id:"update-status-heading",className:"text-md font-medium mb-2",children:"Update Status"}),jsxs("div",{className:"flex space-x-2",children:[jsx("select",{"aria-label":"Update request status",value:m.status,onChange:e=>Y(e.target.value),className:"flex-grow px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-[rgb(var(--ndpr-ring))]",children:o()}),jsx("button",{onClick:()=>Y(m.status),"aria-label":"Apply status update",className:`px-4 py-2 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] ${L}`,children:"Update"})]})]}),i.length>0&&jsxs("div",{children:[jsx("h3",{id:"assign-request-heading",className:"text-md font-medium mb-2",children:"Assign Request"}),jsxs("div",{className:"flex space-x-2",children:[jsxs("select",{"aria-label":"Select assignee",value:S,onChange:e=>re(e.target.value),className:"flex-grow px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-[rgb(var(--ndpr-ring))]",children:[jsx("option",{value:"",children:"Select Assignee"}),i.map(e=>jsx("option",{value:e,children:e},e))]}),jsx("button",{onClick:ie,disabled:!S,"aria-label":"Assign request to selected person",className:`px-4 py-2 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] disabled:bg-gray-300 disabled:text-gray-500 ${L}`,children:"Assign"})]})]})]}),jsxs("div",{className:"mb-6",children:[jsx("h3",{className:"text-lg font-medium mb-3",children:"Request Summary"}),jsx("div",{className:"bg-gray-50 dark:bg-gray-700 p-3 rounded-md",children:jsx("pre",{className:"whitespace-pre-wrap text-sm font-mono text-gray-800 dark:text-gray-200",children:jsx("pre",{children:JSON.stringify(b(m),null,2)})})})]}),ee&&s(m)]}):jsx("div",{className:"flex items-center justify-center h-64 bg-gray-50 dark:bg-gray-700 rounded-md",children:jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Select a request to view details"})})})]})]})};var ke=({requests:w,onSelectRequest:I,title:j,description:C,className:V="",buttonClassName:M="",showSummaryStats:X=true,showTypeBreakdown:L=true,showStatusBreakdown:Z=true,showTimelineChart:ee=true,showOverdueRequests:U=true,classNames:i,unstyled:l=false})=>{var B,O;let R=c(),E=(B=j!=null?j:R.dsr.trackerTitle)!=null?B:"DSR Request Tracker",te=(O=C!=null?C:R.dsr.trackerDescription)!=null?O:"Track the status and progress of data subject requests as required by NDPA Part IV.",[_,f]=useState("30days"),[y,D]=useState(w),[q,T]=useState([]),[K,P]=useState([]);useEffect(()=>{let t=Date.now(),s;switch(_){case "7days":s=w.filter(o=>t-o.createdAt<=10080*60*1e3);break;case "30days":s=w.filter(o=>t-o.createdAt<=720*60*60*1e3);break;case "90days":s=w.filter(o=>t-o.createdAt<=2160*60*60*1e3);break;default:s=[...w];}D(s);let g=s.filter(o=>o.dueDate&&t>o.dueDate&&o.status!=="completed"&&o.status!=="rejected");T(g);let x=s.filter(o=>o.dueDate&&t<o.dueDate&&o.dueDate-t<=10080*60*1e3&&o.status!=="completed"&&o.status!=="rejected");P(x);},[w,_]);let $=t=>{I&&I(t);},A=t=>new Date(t).toLocaleDateString(),H=t=>{let s=Date.now(),g=(t-s)/(1440*60*1e3);return Math.ceil(g)},F=()=>{let t=y.filter(g=>g.status==="completed"&&g.completedAt&&g.createdAt);if(t.length===0)return null;let s=t.reduce((g,x)=>{let o=((x.completedAt||0)-x.createdAt)/864e5;return g+o},0);return Number((s/t.length).toFixed(1))},ae=()=>{let t=y.filter(g=>(g.status==="completed"||g.status==="rejected")&&g.completedAt&&g.dueDate);if(t.length===0)return null;let s=t.filter(g=>(g.completedAt||0)<=(g.dueDate||0));return Math.round(s.length/t.length*100)},W=()=>{let t={};return y.forEach(s=>{t[s.type]=(t[s.type]||0)+1;}),{information:t.information||0,access:t.access||0,rectification:t.rectification||0,erasure:t.erasure||0,restriction:t.restriction||0,portability:t.portability||0,objection:t.objection||0,automated_decision_making:t.automated_decision_making||0,withdraw_consent:t.withdraw_consent||0}},de=()=>{let t={};return y.forEach(s=>{t[s.status]=(t[s.status]||0)+1;}),{pending:t.pending||0,awaitingVerification:t.awaitingVerification||0,inProgress:t.inProgress||0,completed:t.completed||0,rejected:t.rejected||0}},S=t=>{let s={information:"bg-teal-100 text-teal-800 dark:bg-teal-900 dark:text-teal-200",access:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",rectification:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",erasure:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",restriction:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",portability:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200",objection:"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200",automated_decision_making:"bg-indigo-100 text-indigo-800 dark:bg-indigo-900 dark:text-indigo-200",withdraw_consent:"bg-pink-100 text-pink-800 dark:bg-pink-900 dark:text-pink-200"},g={information:"Information",access:"Access",rectification:"Rectification",erasure:"Erasure",restriction:"Restriction",portability:"Portability",objection:"Objection",automated_decision_making:"Automated Decision-Making",withdraw_consent:"Withdraw Consent"};return jsx("span",{className:`px-2 py-1 rounded text-xs font-medium ${s[t]}`,children:g[t]})},J=()=>{let t=y.length,s=y.filter(u=>u.status!=="completed"&&u.status!=="rejected").length;y.filter(u=>u.status==="completed"||u.status==="rejected").length;let x=F(),o=ae();return jsxs("div",{className:a("grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",i==null?void 0:i.stats,l),children:[jsxs("div",{className:a("bg-white dark:bg-gray-700 p-4 rounded-lg shadow",i==null?void 0:i.statCard,l),children:[jsx("h4",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Total Requests"}),jsx("p",{className:"text-2xl font-bold",children:t})]}),jsxs("div",{className:a("bg-white dark:bg-gray-700 p-4 rounded-lg shadow",i==null?void 0:i.statCard,l),children:[jsx("h4",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Pending Requests"}),jsx("p",{className:"text-2xl font-bold",children:s})]}),jsxs("div",{className:a("bg-white dark:bg-gray-700 p-4 rounded-lg shadow",i==null?void 0:i.statCard,l),children:[jsx("h4",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Avg. Response Time"}),jsx("p",{className:"text-2xl font-bold",children:x!==null?`${x} days`:"N/A"})]}),jsxs("div",{className:a("bg-white dark:bg-gray-700 p-4 rounded-lg shadow",i==null?void 0:i.statCard,l),children:[jsx("h4",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Compliance Rate"}),jsx("p",{className:"text-2xl font-bold",children:o!==null?`${o}%`:"N/A"})]})]})},Y=()=>{let t=W(),s=y.length,g=Object.entries(t).sort(([,x],[,o])=>o-x).map(([x])=>x);return jsxs("div",{className:a("bg-white dark:bg-gray-700 p-4 rounded-lg shadow mb-6",i==null?void 0:i.table,l),children:[jsx("h3",{className:a("text-lg font-medium mb-4",i==null?void 0:i.tableHeader,l),children:"Request Types"}),s===0?jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm",children:"No data available for the selected timeframe."}):jsx("div",{className:"space-y-4",children:g.map(x=>{let o=t[x],u=Math.round(o/s*100);return jsxs("div",{children:[jsxs("div",{className:"flex justify-between items-center mb-1",children:[jsxs("div",{className:"flex items-center",children:[S(x),jsxs("span",{className:"ml-2 text-sm",children:[o," requests"]})]}),jsxs("span",{className:"text-sm font-medium",children:[u,"%"]})]}),jsx("div",{className:"w-full bg-gray-200 dark:bg-gray-600 rounded-full h-2.5",children:jsx("div",{className:"bg-[rgb(var(--ndpr-primary))] h-2.5 rounded-full",style:{width:`${u}%`}})})]},x)})})]})},ie=()=>{let t=de(),s=y.length,g=["pending","awaitingVerification","inProgress","completed","rejected"],x={pending:"bg-yellow-500",awaitingVerification:"bg-purple-500",inProgress:"bg-blue-500",completed:"bg-green-500",rejected:"bg-red-500"};return jsxs("div",{className:a("bg-white dark:bg-gray-700 p-4 rounded-lg shadow mb-6",i==null?void 0:i.table,l),children:[jsx("h3",{className:a("text-lg font-medium mb-4",i==null?void 0:i.tableHeader,l),children:"Request Status"}),s===0?jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm",children:"No data available for the selected timeframe."}):jsxs("div",{children:[jsx("div",{className:"flex h-4 mb-2",children:g.map(o=>{let u=t[o],v=u/s*100;return v>0?jsx("div",{className:`${x[o]} first:rounded-l-full last:rounded-r-full`,style:{width:`${v}%`},title:`${o}: ${u} (${Math.round(v)}%)`},o):null})}),jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-2 mt-4",children:g.map(o=>{let u=t[o],v=Math.round(u/s*100);return jsxs("div",{className:"flex items-center",children:[jsx("div",{className:`w-3 h-3 rounded-full ${x[o]} mr-2`}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium",children:o==="inProgress"?"In Progress":o==="awaitingVerification"?"Awaiting Verification":o.charAt(0).toUpperCase()+o.slice(1)}),jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:[u," (",v,"%)"]})]})]},o)})})]})]})},k=()=>{let t={};y.forEach(u=>{let v=new Date(u.createdAt),e=`${v.getFullYear()}-${String(v.getMonth()+1).padStart(2,"0")}`;t[e]=(t[e]||0)+1;});let g=Object.keys(t).sort().slice(-6),x=Math.max(...Object.values(t).filter(u=>u>0),1),o=u=>{let[v,e]=u.split("-");return `${e}/${v.slice(2)}`};return jsxs("div",{className:"bg-white dark:bg-gray-700 p-4 rounded-lg shadow mb-6",children:[jsx("h3",{className:"text-lg font-medium mb-4",children:"Request Timeline"}),g.length===0?jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm",children:"No data available for the selected timeframe."}):jsxs("div",{className:"h-40",children:[jsx("div",{className:"flex h-32 items-end justify-between space-x-2",children:g.map(u=>{let v=t[u],e=`${v/x*100}%`;return jsx("div",{className:"flex flex-col items-center flex-1",children:jsx("div",{className:"w-full bg-[rgb(var(--ndpr-primary))] rounded-t",style:{height:e},title:`${o(u)}: ${v} requests`})},u)})}),jsx("div",{className:"flex justify-between mt-2",children:g.map(u=>jsx("div",{className:"text-xs text-center",children:o(u)},u))})]})]})},z=()=>jsxs("div",{className:"bg-white dark:bg-gray-700 p-4 rounded-lg shadow mb-6","aria-live":"polite",children:[jsx("h3",{className:"text-lg font-medium mb-4",children:"Overdue Requests"}),q.length===0?jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm",children:"No overdue requests."}):jsx("div",{className:"space-y-2 max-h-60 overflow-y-auto",children:q.map(t=>jsxs("div",{role:"button",tabIndex:0,"aria-label":`View overdue request from ${t.subject.name}`,className:a("p-3 bg-red-50 dark:bg-red-900/20 rounded-md cursor-pointer hover:bg-red-100 dark:hover:bg-red-900/30",i==null?void 0:i.tableRow,l),onClick:()=>$(t.id),onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),$(t.id));},children:[jsxs("div",{className:"flex justify-between items-start mb-1",children:[jsx("h4",{className:"font-medium text-sm",children:t.subject.name}),S(t.type)]}),jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mb-1",children:t.subject.email}),jsxs("div",{className:"flex justify-between items-center",children:[jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:["Due: ",A(t.dueDate||0)]}),jsxs("p",{className:"text-xs font-bold text-red-600 dark:text-red-400",children:["Overdue by ",Math.abs(H(t.dueDate||0))," days"]})]})]},t.id))})]}),m=()=>jsxs("div",{className:"bg-white dark:bg-gray-700 p-4 rounded-lg shadow mb-6","aria-live":"polite",children:[jsx("h3",{className:"text-lg font-medium mb-4",children:"Upcoming Deadlines"}),K.length===0?jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm",children:"No upcoming deadlines in the next 7 days."}):jsx("div",{className:"space-y-2 max-h-60 overflow-y-auto",children:K.map(t=>{let s=H(t.dueDate||0);return jsxs("div",{role:"button",tabIndex:0,"aria-label":`View upcoming deadline for ${t.subject.name}`,className:a("p-3 bg-yellow-50 dark:bg-yellow-900/20 rounded-md cursor-pointer hover:bg-yellow-100 dark:hover:bg-yellow-900/30",i==null?void 0:i.tableRow,l),onClick:()=>$(t.id),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),$(t.id));},children:[jsxs("div",{className:"flex justify-between items-start mb-1",children:[jsx("h4",{className:"font-medium text-sm",children:t.subject.name}),S(t.type)]}),jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mb-1",children:t.subject.email}),jsxs("div",{className:"flex justify-between items-center",children:[jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:["Due: ",A(t.dueDate||0)]}),jsxs("p",{className:`text-xs font-bold ${s<=3?"text-red-600 dark:text-red-400":"text-yellow-600 dark:text-yellow-400"}`,children:["Due in ",s," days"]})]})]},t.id)})})]});return jsxs("div",{className:a(`bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md ${V}`,i==null?void 0:i.root,l),children:[jsxs("div",{className:a("flex flex-col md:flex-row md:justify-between md:items-center mb-6",i==null?void 0:i.header,l),children:[jsxs("div",{children:[jsx("h2",{className:a("text-xl font-bold mb-2",i==null?void 0:i.title,l),children:E}),jsx("p",{className:"text-gray-600 dark:text-gray-300",children:te})]}),jsxs("div",{className:"mt-4 md:mt-0",children:[jsx("label",{htmlFor:"timeframe",className:"block text-sm font-medium mb-1",children:"Timeframe"}),jsxs("select",{id:"timeframe",value:_,onChange:t=>f(t.target.value),className:"px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-[rgb(var(--ndpr-ring))]",children:[jsx("option",{value:"7days",children:"Last 7 Days"}),jsx("option",{value:"30days",children:"Last 30 Days"}),jsx("option",{value:"90days",children:"Last 90 Days"}),jsx("option",{value:"all",children:"All Time"})]})]})]}),X&&J(),jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[jsxs("div",{children:[L&&Y(),Z&&ie()]}),jsxs("div",{children:[ee&&k(),U&&z(),U&&m()]})]})]})};export{pe as a,ke as b};
@@ -0,0 +1 @@
1
+ import {b as b$1}from'./chunk-3APT25XO.mjs';import {a as a$1}from'./chunk-DBZSN4WP.mjs';import {a,b}from'./chunk-ZJYULEER.mjs';import {useRef,useState,useEffect,useCallback}from'react';function K(f,R){return R?a$1(f):{load:()=>null,save:()=>{},remove:()=>{}}}function G({initialRequests:f=[],requestTypes:R,adapter:p,storageKey:T="ndpr_dsr_requests",useLocalStorage:h=false,onSubmit:g,onUpdate:m}){let y=p!=null?p:K(T,h),a$1=useRef(y);a$1.current=y;let[n,i]=useState(f),[k,l]=useState(true);useEffect(()=>{let e=false;try{let t=a$1.current.load();t instanceof Promise?t.then(s=>{e||(s&&i(s),l(!1));},()=>{e||l(!1);}):(t&&i(t),l(!1));}catch(t){e||l(false);}return ()=>{e=true;}},[]);let c=useCallback(e=>{Promise.resolve(a$1.current.save(e)).catch(t=>{console.warn("[ndpr-toolkit] Failed to save DSR requests:",t);});},[]),x=()=>"dsr_"+Date.now()+"_"+Math.random().toString(36).substr(2,9),P=useCallback(e=>{let t=R.find(o=>o.id===e.type),s=(t==null?void 0:t.estimatedCompletionTime)||30,r=Date.now(),d=r+s*24*60*60*1e3,q=a({id:x(),status:"pending",createdAt:r,updatedAt:r,dueDate:d},e);return i(o=>{let S=[...o,q];return c(S),S}),g&&g(q),q},[R,c,g]),B=useCallback((e,t)=>{let s=null;return i(r=>{let d=r.findIndex(S=>S.id===e);if(d===-1)return r;let q=r[d];s=b(a(a({},q),t),{updatedAt:Date.now()});let o=[...r];return o[d]=s,c(o),o}),s&&m&&m(s),s},[c,m]),C=useCallback(e=>n.find(t=>t.id===e)||null,[n]),I=useCallback(e=>n.filter(t=>t.status===e),[n]),L=useCallback(e=>n.filter(t=>t.type===e),[n]),O=useCallback(e=>R.find(t=>t.id===e),[R]),_=useCallback(e=>{let{formattedRequest:t}=b$1(e);return t},[]),U=useCallback(()=>{i([]),Promise.resolve(a$1.current.remove()).catch(e=>{console.warn("[ndpr-toolkit] Failed to remove DSR requests:",e);});},[a$1]);return {requests:n,submitRequest:P,updateRequest:B,getRequest:C,getRequestsByStatus:I,getRequestsByType:L,getRequestType:O,formatRequest:_,clearRequests:U,isLoading:k}}export{G as a};