@tracepass/dpp-validate 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +79 -0
- package/dist/battery-applicability.d.ts +84 -0
- package/dist/battery-applicability.d.ts.map +1 -0
- package/dist/battery-applicability.js +175 -0
- package/dist/battery-applicability.js.map +1 -0
- package/dist/eu-countries.d.ts +24 -0
- package/dist/eu-countries.d.ts.map +1 -0
- package/dist/eu-countries.js +37 -0
- package/dist/eu-countries.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/rules.d.ts +40 -0
- package/dist/rules.d.ts.map +1 -0
- package/dist/rules.js +376 -0
- package/dist/rules.js.map +1 -0
- package/dist/types.d.ts +75 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +26 -0
- package/dist/types.js.map +1 -0
- package/dist/vendor/counts.d.ts +32 -0
- package/dist/vendor/counts.d.ts.map +1 -0
- package/dist/vendor/counts.js +28 -0
- package/dist/vendor/counts.js.map +1 -0
- package/dist/vendor/publish-gate.d.ts +41 -0
- package/dist/vendor/publish-gate.d.ts.map +1 -0
- package/dist/vendor/publish-gate.js +85 -0
- package/dist/vendor/publish-gate.js.map +1 -0
- package/dist/vendor/required-roles.d.ts +72 -0
- package/dist/vendor/required-roles.d.ts.map +1 -0
- package/dist/vendor/required-roles.js +144 -0
- package/dist/vendor/required-roles.js.map +1 -0
- package/dist/verdict.d.ts +30 -0
- package/dist/verdict.d.ts.map +1 -0
- package/dist/verdict.js +189 -0
- package/dist/verdict.js.map +1 -0
- package/package.json +22 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://www.tracepass.eu"><img src="https://www.tracepass.eu/tracepass-logo.svg" alt="TracePass" height="72"></a>
|
|
3
|
+
|
|
4
|
+
# @tracepass/dpp-validate
|
|
5
|
+
|
|
6
|
+
**Evaluate an EU Digital Product Passport against its category field spec. Pure functions, no third-party runtime dependencies, 28 tests.**
|
|
7
|
+
|
|
8
|
+
[](../../LICENSE)
|
|
9
|
+
[](#)
|
|
10
|
+
|
|
11
|
+
Part of [**tracepass-open**](https://github.com/malinoto/tracepass-open) · Maintained by [TracePass](https://www.tracepass.eu)
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
Given a passport and the template for its product category, `evaluateCompliance` returns a
|
|
17
|
+
three-tier verdict with findings that cite the article of EU law each one rests on. It
|
|
18
|
+
reads no database, opens no socket, and consults no clock.
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @tracepass/dpp-validate @tracepass/dpp-schemas
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { evaluateCompliance } from "@tracepass/dpp-validate";
|
|
26
|
+
|
|
27
|
+
const result = evaluateCompliance(passport, batteryTemplate, "battery");
|
|
28
|
+
|
|
29
|
+
result.verdict; // "compliant" | "compliant_with_warnings" | "incomplete"
|
|
30
|
+
result.critical; // findings that block
|
|
31
|
+
result.warnings; // findings that don't
|
|
32
|
+
result.conditionalCoverage; // "evaluated" | "static-only"
|
|
33
|
+
result.checkedRules; // ["static:required-fields", ..., "BAT-1", "CC-1"]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Three tiers
|
|
37
|
+
|
|
38
|
+
**Static** — required fields are present and approved, required economic operators are
|
|
39
|
+
identified, values match their datatype, enum, pattern, and bounds.
|
|
40
|
+
|
|
41
|
+
**Conditional** — obligations that only fire under a condition. Battery carbon-footprint
|
|
42
|
+
fields apply only to rechargeable batteries; REACH Article 33 disclosure triggers above
|
|
43
|
+
0.1% w/w of an SVHC. Three categories carry these rules — battery, chemicals,
|
|
44
|
+
construction — plus one cross-cutting rule for every category.
|
|
45
|
+
|
|
46
|
+
**Coverage** — the engine reports whether it evaluated conditionals at all. For the other
|
|
47
|
+
nine categories `conditionalCoverage` is `"static-only"`, so silence is never mistaken for
|
|
48
|
+
a compliance claim.
|
|
49
|
+
|
|
50
|
+
## It will not pass what it could not check
|
|
51
|
+
|
|
52
|
+
When the field that decides a conditional is absent, the result is an
|
|
53
|
+
`unverifiable_conditional` warning naming what could not be determined — never a quiet
|
|
54
|
+
pass:
|
|
55
|
+
|
|
56
|
+
```jsonc
|
|
57
|
+
{
|
|
58
|
+
"type": "unverifiable_conditional",
|
|
59
|
+
"ruleId": "BAT-1",
|
|
60
|
+
"target": "batteryCategory",
|
|
61
|
+
"article": "Art. 77(1)",
|
|
62
|
+
"why": "Battery category isn't set, so battery-passport scope couldn't be evaluated.",
|
|
63
|
+
"fix": "Set batteryCategory. Portable and SLI batteries are out of scope; LMT, EV and industrial >2 kWh require a battery passport."
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The same principle governs the battery applicability gates: an unknown classifier shows
|
|
68
|
+
the dependent field and warns. A mis-classified battery must never silently lose a
|
|
69
|
+
legally-required field.
|
|
70
|
+
|
|
71
|
+
## Not legal advice
|
|
72
|
+
|
|
73
|
+
A `compliant` verdict means *this passport satisfies the rules encoded here* — not *this
|
|
74
|
+
product may be placed on the market*. Delegated acts are still landing. Verify against
|
|
75
|
+
[EUR-Lex](https://eur-lex.europa.eu).
|
|
76
|
+
|
|
77
|
+
## License
|
|
78
|
+
|
|
79
|
+
[Apache-2.0](../../LICENSE)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Battery field-applicability predicate — the single source of truth for
|
|
3
|
+
* "does this Annex XIII field apply to *this* battery?"
|
|
4
|
+
*
|
|
5
|
+
* Consumed by the compliance verdict engine, which flags a filled field that
|
|
6
|
+
* doesn't apply and warns when applicability can't be determined. A passport
|
|
7
|
+
* editor can use the same predicate to collapse not-applicable fields rather
|
|
8
|
+
* than asking a reviewer for data the regulation doesn't require.
|
|
9
|
+
*
|
|
10
|
+
* Derives from Regulation (EU) 2023/1542 (the EU Battery Regulation), Annex
|
|
11
|
+
* XIII, and its per-category applicability matrix: EV batteries carry every
|
|
12
|
+
* field; LMT omits the capacity-threshold-for-exhaustion field; industrial
|
|
13
|
+
* batteries are conditional on BMS / rechargeable / external-storage gates.
|
|
14
|
+
*
|
|
15
|
+
* Design contract — the SAFETY rule that makes A safe:
|
|
16
|
+
* "unknown" (a gate's trigger field is absent) ⇒ treat as APPLIES for the
|
|
17
|
+
* UI (show the field) and as `unverifiable_conditional` for the verdict
|
|
18
|
+
* (warn, never assert). We NEVER hide or suppress a field on uncertainty —
|
|
19
|
+
* a mis-classified battery must never lose a legally-required field.
|
|
20
|
+
*
|
|
21
|
+
* Triggers:
|
|
22
|
+
* - batteryCategory — a real template field in battery.json (enum: LMT |
|
|
23
|
+
* EV | industrial_gt_2kwh | industrial_lte_2kwh | SLI
|
|
24
|
+
* | portable). Read from `passport.fields`.
|
|
25
|
+
* - hasBMS, rechargeable, externalStorageOnly — tri-state booleans on
|
|
26
|
+
* `passport.batteryProfile` (a separate block, NOT
|
|
27
|
+
* template fields — keeps the "91 fields" count
|
|
28
|
+
* intact). Absent ⇒ the dependent gate resolves to
|
|
29
|
+
* "unknown" (show + warn), not a guess.
|
|
30
|
+
*
|
|
31
|
+
* Pure + IO-free → unit-tested in tests/compliance/battery-applicability.test.ts.
|
|
32
|
+
*/
|
|
33
|
+
import type { Passport } from "@tracepass/dpp-types";
|
|
34
|
+
export type Applicability = "applies" | "not_applicable" | "unknown";
|
|
35
|
+
/** Battery categories that are *in scope* for a battery passport at all
|
|
36
|
+
* (BAT-1). Used only to keep this module self-contained; the passport-
|
|
37
|
+
* level scope gate still lives in rules.ts BAT-1. */
|
|
38
|
+
export declare const IN_SCOPE_BATTERY_CATEGORIES: readonly ["LMT", "EV", "industrial_gt_2kwh"];
|
|
39
|
+
/** Field keys whose applicability is conditional, with a short reason +
|
|
40
|
+
* the deck article they map to. Everything NOT listed here is always
|
|
41
|
+
* "applies". Kept as data so the rules engine + editor can enumerate the
|
|
42
|
+
* conditional set and so a reader can audit each gate against the deck. */
|
|
43
|
+
export interface FieldGate {
|
|
44
|
+
/** Battery template field keys this gate governs. */
|
|
45
|
+
keys: string[];
|
|
46
|
+
/** Annex XIII / deck reference, for the verdict citation. */
|
|
47
|
+
article: string;
|
|
48
|
+
/** One-line reason, surfaced in the verdict + editor tooltip. */
|
|
49
|
+
reason: string;
|
|
50
|
+
/** Decide applicability from the resolved trigger values. */
|
|
51
|
+
decide(t: Triggers): Applicability;
|
|
52
|
+
}
|
|
53
|
+
interface Triggers {
|
|
54
|
+
category: string | undefined;
|
|
55
|
+
hasBMS: boolean | undefined;
|
|
56
|
+
rechargeable: boolean | undefined;
|
|
57
|
+
externalStorageOnly: boolean | undefined;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The conditional gates, one per applicability rule from the deck. Order
|
|
61
|
+
* doesn't matter — each governs a disjoint set of field keys.
|
|
62
|
+
*/
|
|
63
|
+
export declare const BATTERY_FIELD_GATES: FieldGate[];
|
|
64
|
+
/** Every field key under any gate (the conditional set). */
|
|
65
|
+
export declare const GATED_FIELD_KEYS: ReadonlySet<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Applicability for a single battery field key. Ungated keys are always
|
|
68
|
+
* "applies". This is the granular accessor the editor uses per-field.
|
|
69
|
+
*/
|
|
70
|
+
export declare function fieldApplicability(passport: Passport, key: string): Applicability;
|
|
71
|
+
/**
|
|
72
|
+
* Full map for the gated fields only (callers default everything else to
|
|
73
|
+
* "applies"). The verdict engine iterates this to emit findings; the
|
|
74
|
+
* editor reads it once per render and looks up per field.
|
|
75
|
+
*
|
|
76
|
+
* Returns an empty map for non-battery passports — `category` here is the
|
|
77
|
+
* template category, NOT batteryCategory; callers pass it so this is a
|
|
78
|
+
* no-op outside battery and the predicate stays battery-scoped.
|
|
79
|
+
*/
|
|
80
|
+
export declare function batteryFieldApplicability(passport: Passport, category: string): Record<string, Applicability>;
|
|
81
|
+
/** Look up the gate metadata (article + reason) for a gated field key. */
|
|
82
|
+
export declare function gateForKey(key: string): FieldGate | undefined;
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=battery-applicability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"battery-applicability.d.ts","sourceRoot":"","sources":["../src/battery-applicability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAkB,MAAM,sBAAsB,CAAC;AAErE,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAErE;;sDAEsD;AACtD,eAAO,MAAM,2BAA2B,8CAA+C,CAAC;AAExF;;;4EAG4E;AAC5E,MAAM,WAAW,SAAS;IACxB,qDAAqD;IACrD,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,MAAM,CAAC,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC;CACpC;AAED,UAAU,QAAQ;IAChB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,YAAY,EAAE,OAAO,GAAG,SAAS,CAAC;IAClC,mBAAmB,EAAE,OAAO,GAAG,SAAS,CAAC;CAC1C;AAwBD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,EAiE1C,CAAC;AAQF,4DAA4D;AAC5D,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAA+B,CAAC;AAEjF;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,aAAa,CAIjF;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,MAAM,GACf,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAS/B;AAED,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAE7D"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Battery field-applicability predicate — the single source of truth for
|
|
3
|
+
* "does this Annex XIII field apply to *this* battery?"
|
|
4
|
+
*
|
|
5
|
+
* Consumed by the compliance verdict engine, which flags a filled field that
|
|
6
|
+
* doesn't apply and warns when applicability can't be determined. A passport
|
|
7
|
+
* editor can use the same predicate to collapse not-applicable fields rather
|
|
8
|
+
* than asking a reviewer for data the regulation doesn't require.
|
|
9
|
+
*
|
|
10
|
+
* Derives from Regulation (EU) 2023/1542 (the EU Battery Regulation), Annex
|
|
11
|
+
* XIII, and its per-category applicability matrix: EV batteries carry every
|
|
12
|
+
* field; LMT omits the capacity-threshold-for-exhaustion field; industrial
|
|
13
|
+
* batteries are conditional on BMS / rechargeable / external-storage gates.
|
|
14
|
+
*
|
|
15
|
+
* Design contract — the SAFETY rule that makes A safe:
|
|
16
|
+
* "unknown" (a gate's trigger field is absent) ⇒ treat as APPLIES for the
|
|
17
|
+
* UI (show the field) and as `unverifiable_conditional` for the verdict
|
|
18
|
+
* (warn, never assert). We NEVER hide or suppress a field on uncertainty —
|
|
19
|
+
* a mis-classified battery must never lose a legally-required field.
|
|
20
|
+
*
|
|
21
|
+
* Triggers:
|
|
22
|
+
* - batteryCategory — a real template field in battery.json (enum: LMT |
|
|
23
|
+
* EV | industrial_gt_2kwh | industrial_lte_2kwh | SLI
|
|
24
|
+
* | portable). Read from `passport.fields`.
|
|
25
|
+
* - hasBMS, rechargeable, externalStorageOnly — tri-state booleans on
|
|
26
|
+
* `passport.batteryProfile` (a separate block, NOT
|
|
27
|
+
* template fields — keeps the "91 fields" count
|
|
28
|
+
* intact). Absent ⇒ the dependent gate resolves to
|
|
29
|
+
* "unknown" (show + warn), not a guess.
|
|
30
|
+
*
|
|
31
|
+
* Pure + IO-free → unit-tested in tests/compliance/battery-applicability.test.ts.
|
|
32
|
+
*/
|
|
33
|
+
/** Battery categories that are *in scope* for a battery passport at all
|
|
34
|
+
* (BAT-1). Used only to keep this module self-contained; the passport-
|
|
35
|
+
* level scope gate still lives in rules.ts BAT-1. */
|
|
36
|
+
export const IN_SCOPE_BATTERY_CATEGORIES = ["LMT", "EV", "industrial_gt_2kwh"];
|
|
37
|
+
/**
|
|
38
|
+
* Resolve a profile flag to a confirmed boolean. Only an `approved` flag
|
|
39
|
+
* counts — a `pending_review` (AI-suggested, unconfirmed) flag resolves to
|
|
40
|
+
* `undefined` ("unknown") so it can NEVER hard-hide a field. This is the
|
|
41
|
+
* safety contract: AI may suggest, but gating tightens only on confirmation.
|
|
42
|
+
*/
|
|
43
|
+
function confirmed(flag) {
|
|
44
|
+
if (!flag)
|
|
45
|
+
return undefined;
|
|
46
|
+
return flag.status === "approved" ? flag.value : undefined;
|
|
47
|
+
}
|
|
48
|
+
function readTriggers(passport) {
|
|
49
|
+
const cat = passport.fields["batteryCategory"];
|
|
50
|
+
const profile = passport.batteryProfile;
|
|
51
|
+
return {
|
|
52
|
+
category: cat && cat.value != null && cat.value !== "" ? String(cat.value) : undefined,
|
|
53
|
+
hasBMS: confirmed(profile?.hasBMS),
|
|
54
|
+
rechargeable: confirmed(profile?.rechargeable),
|
|
55
|
+
externalStorageOnly: confirmed(profile?.externalStorageOnly),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The conditional gates, one per applicability rule from the deck. Order
|
|
60
|
+
* doesn't matter — each governs a disjoint set of field keys.
|
|
61
|
+
*/
|
|
62
|
+
export const BATTERY_FIELD_GATES = [
|
|
63
|
+
{
|
|
64
|
+
// Deck 1(k): "capacity threshold for exhaustion (only for electric
|
|
65
|
+
// vehicle batteries)". Resolvable today — trigger is batteryCategory.
|
|
66
|
+
keys: ["capacityThresholdForExhaustion"],
|
|
67
|
+
article: "Annex XIII 1(k)",
|
|
68
|
+
reason: "Capacity threshold for exhaustion applies only to electric-vehicle (EV) batteries.",
|
|
69
|
+
decide: (t) => {
|
|
70
|
+
if (t.category === undefined)
|
|
71
|
+
return "unknown";
|
|
72
|
+
return t.category === "EV" ? "applies" : "not_applicable";
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
// Deck 4(b): state of health (Art. 14) applies to stationary ESS / LMT
|
|
77
|
+
// / EV batteries AND only if they have a battery management system.
|
|
78
|
+
// We don't model "stationary ESS" as a distinct category, so we gate
|
|
79
|
+
// on (in-scope category) AND (hasBMS). hasBMS absent ⇒ unknown.
|
|
80
|
+
keys: ["stateOfHealth"],
|
|
81
|
+
article: "Annex XIII 4(b) / Art. 14",
|
|
82
|
+
reason: "State of health applies only to EV / LMT / stationary-storage batteries that have a battery management system (BMS).",
|
|
83
|
+
decide: (t) => {
|
|
84
|
+
if (t.category === undefined || t.hasBMS === undefined)
|
|
85
|
+
return "unknown";
|
|
86
|
+
const inScope = IN_SCOPE_BATTERY_CATEGORIES.includes(t.category);
|
|
87
|
+
return inScope && t.hasBMS ? "applies" : "not_applicable";
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
// Deck (c): carbon footprint cross-references Art. 7, which is
|
|
92
|
+
// rechargeable-only ("If the battery is non-rechargeable, (c) remains
|
|
93
|
+
// empty"). rechargeable absent ⇒ unknown.
|
|
94
|
+
keys: [
|
|
95
|
+
"carbonFootprintTotal",
|
|
96
|
+
"carbonFootprintPerformanceClass",
|
|
97
|
+
"carbonFootprintLabel",
|
|
98
|
+
"carbonFootprintStudyUrl",
|
|
99
|
+
"cfRawMaterialAcquisition",
|
|
100
|
+
"cfMainProductProduction",
|
|
101
|
+
"cfDistribution",
|
|
102
|
+
"cfEndOfLifeRecycling",
|
|
103
|
+
],
|
|
104
|
+
article: "Annex XIII 1(c) / Art. 7",
|
|
105
|
+
reason: "Carbon-footprint declaration applies only to rechargeable batteries.",
|
|
106
|
+
decide: (t) => {
|
|
107
|
+
if (t.rechargeable === undefined)
|
|
108
|
+
return "unknown";
|
|
109
|
+
return t.rechargeable ? "applies" : "not_applicable";
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
// Deck (e): recycled content cross-references Art. 8 ("If the battery
|
|
114
|
+
// has external storage only, (e) remains empty"). externalStorageOnly
|
|
115
|
+
// absent ⇒ unknown.
|
|
116
|
+
keys: [
|
|
117
|
+
"recycledContentCobalt",
|
|
118
|
+
"recycledContentLead",
|
|
119
|
+
"recycledContentLithium",
|
|
120
|
+
"recycledContentNickel",
|
|
121
|
+
"recycledContentDocumentation",
|
|
122
|
+
],
|
|
123
|
+
article: "Annex XIII 1(e) / Art. 8",
|
|
124
|
+
reason: "Recycled-content information does not apply to batteries with external storage only.",
|
|
125
|
+
decide: (t) => {
|
|
126
|
+
if (t.externalStorageOnly === undefined)
|
|
127
|
+
return "unknown";
|
|
128
|
+
return t.externalStorageOnly ? "not_applicable" : "applies";
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
/** Pre-computed map from field key → the gate governing it. */
|
|
133
|
+
const KEY_TO_GATE = new Map();
|
|
134
|
+
for (const gate of BATTERY_FIELD_GATES) {
|
|
135
|
+
for (const k of gate.keys)
|
|
136
|
+
KEY_TO_GATE.set(k, gate);
|
|
137
|
+
}
|
|
138
|
+
/** Every field key under any gate (the conditional set). */
|
|
139
|
+
export const GATED_FIELD_KEYS = new Set(KEY_TO_GATE.keys());
|
|
140
|
+
/**
|
|
141
|
+
* Applicability for a single battery field key. Ungated keys are always
|
|
142
|
+
* "applies". This is the granular accessor the editor uses per-field.
|
|
143
|
+
*/
|
|
144
|
+
export function fieldApplicability(passport, key) {
|
|
145
|
+
const gate = KEY_TO_GATE.get(key);
|
|
146
|
+
if (!gate)
|
|
147
|
+
return "applies";
|
|
148
|
+
return gate.decide(readTriggers(passport));
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Full map for the gated fields only (callers default everything else to
|
|
152
|
+
* "applies"). The verdict engine iterates this to emit findings; the
|
|
153
|
+
* editor reads it once per render and looks up per field.
|
|
154
|
+
*
|
|
155
|
+
* Returns an empty map for non-battery passports — `category` here is the
|
|
156
|
+
* template category, NOT batteryCategory; callers pass it so this is a
|
|
157
|
+
* no-op outside battery and the predicate stays battery-scoped.
|
|
158
|
+
*/
|
|
159
|
+
export function batteryFieldApplicability(passport, category) {
|
|
160
|
+
if (category !== "battery")
|
|
161
|
+
return {};
|
|
162
|
+
const triggers = readTriggers(passport);
|
|
163
|
+
const out = {};
|
|
164
|
+
for (const gate of BATTERY_FIELD_GATES) {
|
|
165
|
+
const verdict = gate.decide(triggers);
|
|
166
|
+
for (const k of gate.keys)
|
|
167
|
+
out[k] = verdict;
|
|
168
|
+
}
|
|
169
|
+
return out;
|
|
170
|
+
}
|
|
171
|
+
/** Look up the gate metadata (article + reason) for a gated field key. */
|
|
172
|
+
export function gateForKey(key) {
|
|
173
|
+
return KEY_TO_GATE.get(key);
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=battery-applicability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"battery-applicability.js","sourceRoot":"","sources":["../src/battery-applicability.ts"],"names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I,CAAC,IAAI;YAAE,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAC9C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EU/EEA membership check for ISO 3166-1 alpha-2 country codes.
|
|
3
|
+
*
|
|
4
|
+
* Used by the compliance engine's cross-cutting economic-operator rule
|
|
5
|
+
* (CC-1): when a manufacturer is established OUTSIDE the EU, Reg (EU)
|
|
6
|
+
* 2019/1020 Art. 4 requires an EU-established operator (importer / AR /
|
|
7
|
+
* fulfilment service provider) to be present. We need to know whether a
|
|
8
|
+
* `Party.country` is inside the Union to decide if that rule fires.
|
|
9
|
+
*
|
|
10
|
+
* EEA (Norway, Iceland, Liechtenstein) is included: the Art. 4 obligation
|
|
11
|
+
* extends to the EEA via the EEA Agreement, and a manufacturer established
|
|
12
|
+
* in an EEA state is treated as in-territory for placing-on-market purposes.
|
|
13
|
+
* Switzerland is NOT in the EEA → treated as third-country.
|
|
14
|
+
*
|
|
15
|
+
* Codes are upper-cased before lookup so callers can pass either case.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* True when `country` is an EU or EEA member state. Returns false for
|
|
19
|
+
* undefined / empty / unknown codes — callers treat "unknown origin" as
|
|
20
|
+
* NOT-confirmed-EU and let the engine emit a warning rather than assert
|
|
21
|
+
* compliance on a country it can't place.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isEuEeaCountry(country: string | undefined | null): boolean;
|
|
24
|
+
//# sourceMappingURL=eu-countries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eu-countries.d.ts","sourceRoot":"","sources":["../src/eu-countries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAcH;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAG1E"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EU/EEA membership check for ISO 3166-1 alpha-2 country codes.
|
|
3
|
+
*
|
|
4
|
+
* Used by the compliance engine's cross-cutting economic-operator rule
|
|
5
|
+
* (CC-1): when a manufacturer is established OUTSIDE the EU, Reg (EU)
|
|
6
|
+
* 2019/1020 Art. 4 requires an EU-established operator (importer / AR /
|
|
7
|
+
* fulfilment service provider) to be present. We need to know whether a
|
|
8
|
+
* `Party.country` is inside the Union to decide if that rule fires.
|
|
9
|
+
*
|
|
10
|
+
* EEA (Norway, Iceland, Liechtenstein) is included: the Art. 4 obligation
|
|
11
|
+
* extends to the EEA via the EEA Agreement, and a manufacturer established
|
|
12
|
+
* in an EEA state is treated as in-territory for placing-on-market purposes.
|
|
13
|
+
* Switzerland is NOT in the EEA → treated as third-country.
|
|
14
|
+
*
|
|
15
|
+
* Codes are upper-cased before lookup so callers can pass either case.
|
|
16
|
+
*/
|
|
17
|
+
/** EU-27 member states (ISO 3166-1 alpha-2). */
|
|
18
|
+
const EU_27 = [
|
|
19
|
+
"AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR",
|
|
20
|
+
"DE", "GR", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL",
|
|
21
|
+
"PL", "PT", "RO", "SK", "SI", "ES", "SE",
|
|
22
|
+
];
|
|
23
|
+
/** EEA-only states (not EU members but inside the single market). */
|
|
24
|
+
const EEA_EXTRA = ["NO", "IS", "LI"];
|
|
25
|
+
const EU_EEA_SET = new Set([...EU_27, ...EEA_EXTRA]);
|
|
26
|
+
/**
|
|
27
|
+
* True when `country` is an EU or EEA member state. Returns false for
|
|
28
|
+
* undefined / empty / unknown codes — callers treat "unknown origin" as
|
|
29
|
+
* NOT-confirmed-EU and let the engine emit a warning rather than assert
|
|
30
|
+
* compliance on a country it can't place.
|
|
31
|
+
*/
|
|
32
|
+
export function isEuEeaCountry(country) {
|
|
33
|
+
if (!country)
|
|
34
|
+
return false;
|
|
35
|
+
return EU_EEA_SET.has(country.trim().toUpperCase());
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=eu-countries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eu-countries.js","sourceRoot":"","sources":["../src/eu-countries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,gDAAgD;AAChD,MAAM,KAAK,GAAG;IACZ,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC1D,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC1D,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;CAChC,CAAC;AAEX,qEAAqE;AACrE,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC;AAE9C,MAAM,UAAU,GAAG,IAAI,GAAG,CAAS,CAAC,GAAG,KAAK,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,OAAkC;IAC/D,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,OAAO,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AACtD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluate a Digital Product Passport against its category field-spec.
|
|
3
|
+
*
|
|
4
|
+
* `evaluateCompliance` takes a passport and its template as plain objects and
|
|
5
|
+
* returns a three-tier verdict with regulation-cited findings. It reads no
|
|
6
|
+
* database and makes no network calls.
|
|
7
|
+
*/
|
|
8
|
+
export { evaluateCompliance } from "./verdict.js";
|
|
9
|
+
export type { ComplianceVerdict, ComplianceResult, ComplianceFinding, ConditionalCoverage, FindingSeverity, FindingType, } from "./types.js";
|
|
10
|
+
export { isEuEeaCountry } from "./eu-countries.js";
|
|
11
|
+
export { CONDITIONAL_RULES, CROSS_CUTTING_RULES, } from "./rules.js";
|
|
12
|
+
export type { ConditionalRule } from "./rules.js";
|
|
13
|
+
export { IN_SCOPE_BATTERY_CATEGORIES, BATTERY_FIELD_GATES, GATED_FIELD_KEYS, batteryFieldApplicability, gateForKey, } from "./battery-applicability.js";
|
|
14
|
+
export type { Applicability, FieldGate } from "./battery-applicability.js";
|
|
15
|
+
export { checkPublishReady } from "./vendor/publish-gate.js";
|
|
16
|
+
export { getPartyRoles, isRequiredRole, allRolesForCategory, CATEGORY_PARTY_ROLES } from "./vendor/required-roles.js";
|
|
17
|
+
export type { CategoryKey } from "./vendor/required-roles.js";
|
|
18
|
+
export { derivePassportCounts } from "./vendor/counts.js";
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EACL,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,EAChB,yBAAyB,EACzB,UAAU,GACX,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAI3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACtH,YAAY,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
|