@elaraai/e3-ui 1.0.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 (53) hide show
  1. package/CLA.md +26 -0
  2. package/CONTRIBUTING.md +28 -0
  3. package/LICENSE.md +31 -0
  4. package/README.md +149 -0
  5. package/dist/src/buttons.d.ts +2 -0
  6. package/dist/src/buttons.d.ts.map +1 -0
  7. package/dist/src/buttons.js +2 -0
  8. package/dist/src/buttons.js.map +1 -0
  9. package/dist/src/data.d.ts +241 -0
  10. package/dist/src/data.d.ts.map +1 -0
  11. package/dist/src/data.js +195 -0
  12. package/dist/src/data.js.map +1 -0
  13. package/dist/src/derive.d.ts +33 -0
  14. package/dist/src/derive.d.ts.map +1 -0
  15. package/dist/src/derive.js +64 -0
  16. package/dist/src/derive.js.map +1 -0
  17. package/dist/src/diff.d.ts +335 -0
  18. package/dist/src/diff.d.ts.map +1 -0
  19. package/dist/src/diff.js +197 -0
  20. package/dist/src/diff.js.map +1 -0
  21. package/dist/src/index.d.ts +25 -0
  22. package/dist/src/index.d.ts.map +1 -0
  23. package/dist/src/index.js +25 -0
  24. package/dist/src/index.js.map +1 -0
  25. package/dist/src/manifest.d.ts +27 -0
  26. package/dist/src/manifest.d.ts.map +1 -0
  27. package/dist/src/manifest.js +29 -0
  28. package/dist/src/manifest.js.map +1 -0
  29. package/dist/src/ontology.d.ts +517 -0
  30. package/dist/src/ontology.d.ts.map +1 -0
  31. package/dist/src/ontology.js +311 -0
  32. package/dist/src/ontology.js.map +1 -0
  33. package/dist/src/ui.d.ts +57 -0
  34. package/dist/src/ui.d.ts.map +1 -0
  35. package/dist/src/ui.js +72 -0
  36. package/dist/src/ui.js.map +1 -0
  37. package/dist/src/utils.d.ts +21 -0
  38. package/dist/src/utils.d.ts.map +1 -0
  39. package/dist/src/utils.js +24 -0
  40. package/dist/src/utils.js.map +1 -0
  41. package/dist/test/data.examples.d.ts +20 -0
  42. package/dist/test/data.examples.d.ts.map +1 -0
  43. package/dist/test/data.examples.js +156 -0
  44. package/dist/test/data.examples.js.map +1 -0
  45. package/dist/test/diff.examples.d.ts +138 -0
  46. package/dist/test/diff.examples.d.ts.map +1 -0
  47. package/dist/test/diff.examples.js +964 -0
  48. package/dist/test/diff.examples.js.map +1 -0
  49. package/dist/test/ontology.examples.d.ts +412 -0
  50. package/dist/test/ontology.examples.d.ts.map +1 -0
  51. package/dist/test/ontology.examples.js +298 -0
  52. package/dist/test/ontology.examples.js.map +1 -0
  53. package/package.json +80 -0
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ import { East, FloatType, FunctionType, IntegerType, NullType, StringType, PatchType, variant, example } from "@elaraai/east";
6
+ import { Reactive, Slider, Stack, Stat, Text, Input, Button, UIComponentType } from "@elaraai/east-ui";
7
+ import { Data } from "@elaraai/e3-ui";
8
+ import * as e3 from "@elaraai/e3";
9
+ export const thresholdInput = e3.input('threshold', FloatType, 50.0);
10
+ export const thresholdPatchInput = e3.input('threshold_patch', PatchType(FloatType), variant("unchanged", null));
11
+ export const countInput = e3.input('count', IntegerType, 0n);
12
+ export const nameInput = e3.input('name', StringType, '');
13
+ export const dataBindFloat = example({
14
+ keywords: ["Data", "bind", "Reactive", "Float", "dataset", "read"],
15
+ description: "Bind to a Float dataset and display its current value",
16
+ fn: East.function([], UIComponentType, (_$) => {
17
+ return Reactive.Root(East.function([], UIComponentType, $ => {
18
+ const thresh = $.let(Data.bind([FloatType], thresholdInput.path));
19
+ const value = $.let(thresh.read());
20
+ return Stat.Root("Threshold", value);
21
+ }));
22
+ }),
23
+ inputs: [],
24
+ });
25
+ export const dataBindSliderWriteback = example({
26
+ keywords: ["Data", "bind", "Reactive", "Slider", "onChange", "write", "interactive"],
27
+ description: "Slider whose value is bound to a dataset — onChange writes back",
28
+ fn: East.function([], UIComponentType, (_$) => {
29
+ return Reactive.Root(East.function([], UIComponentType, $ => {
30
+ const thresh = $.let(Data.bind([FloatType], thresholdInput.path));
31
+ const value = $.let(thresh.read());
32
+ return Slider.Root(value, {
33
+ min: 0,
34
+ max: 100,
35
+ onChangeEnd: thresh.writeAndStart,
36
+ disabled: thresh.status().hasTag('stale')
37
+ });
38
+ }));
39
+ }),
40
+ inputs: [],
41
+ });
42
+ export const dataBindInteger = example({
43
+ keywords: ["Data", "bind", "Integer", "Input", "write", "interactive"],
44
+ description: "Integer dataset bound to a number input with writeback",
45
+ fn: East.function([], UIComponentType, (_$) => {
46
+ return Reactive.Root(East.function([], UIComponentType, $ => {
47
+ const count = $.let(Data.bind([IntegerType], countInput.path));
48
+ const value = $.let(count.read());
49
+ return Input.Integer(value, { onChange: count.write });
50
+ }));
51
+ }),
52
+ inputs: [],
53
+ });
54
+ export const dataBindStringReset = example({
55
+ keywords: ["Data", "bind", "String", "callback", "Button", "reset", "write"],
56
+ description: "String dataset with a reset button that writes an empty string",
57
+ fn: East.function([], UIComponentType, (_$) => {
58
+ return Reactive.Root(East.function([], UIComponentType, $ => {
59
+ const name = $.let(Data.bind([StringType], nameInput.path));
60
+ const value = $.let(name.read());
61
+ const reset = $.const(East.function([], NullType, $ => {
62
+ $(name.write(""));
63
+ }));
64
+ return Stack.VStack([
65
+ Stat.Root("Name", value),
66
+ Button.Root("Reset", { style: { variant: "outline" }, onClick: reset }),
67
+ ], { gap: "3", align: "stretch" });
68
+ }));
69
+ }),
70
+ inputs: [],
71
+ });
72
+ export const dataBindHasGuard = example({
73
+ keywords: ["Data", "bind", "has", "guard", "conditional", "Reactive"],
74
+ description: "Use has() to gate UI on whether a dataset has been written",
75
+ fn: East.function([], UIComponentType, (_$) => {
76
+ return Reactive.Root(East.function([], UIComponentType, $ => {
77
+ const thresh = $.let(Data.bind([FloatType], thresholdInput.path));
78
+ const ready = $.let(thresh.has());
79
+ const message = $.let("(no data)");
80
+ $.if(ready, $ => {
81
+ $.assign(message, East.print(thresh.read()));
82
+ });
83
+ return Text.Root(message);
84
+ }));
85
+ }),
86
+ inputs: [],
87
+ });
88
+ export const dataBindStagedFloat = example({
89
+ keywords: ["Data", "bindStaged", "Reactive", "Float", "buffered", "transactional"],
90
+ description: "Stage edits to a Float dataset; read returns overlay (buffered or server)",
91
+ fn: East.function([], UIComponentType, (_$) => {
92
+ return Reactive.Root(East.function([], UIComponentType, $ => {
93
+ const thresh = $.let(Data.bind([FloatType], thresholdInput.path, { mode: "staged" }));
94
+ const value = $.let(thresh.read(), FloatType);
95
+ return Stat.Root("Threshold (live)", value);
96
+ }));
97
+ }),
98
+ inputs: [],
99
+ });
100
+ export const dataBindStagedSliderWrite = example({
101
+ keywords: ["Data", "bindStaged", "Slider", "write", "buffer", "interactive"],
102
+ description: "Slider whose onChange writes to the staged buffer instead of the server",
103
+ fn: East.function([], UIComponentType, (_$) => {
104
+ return Reactive.Root(East.function([], UIComponentType, $ => {
105
+ const thresh = $.let(Data.bind([FloatType], thresholdInput.path, { mode: "staged" }));
106
+ const value = $.let(thresh.read(), FloatType);
107
+ return Slider.Root(value, {
108
+ min: 0,
109
+ max: 100,
110
+ onChange: thresh.write,
111
+ });
112
+ }));
113
+ }),
114
+ inputs: [],
115
+ });
116
+ export const dataBindStagedCommitDiscard = example({
117
+ keywords: ["Data", "bindStaged", "commit", "discard", "pending", "transactional"],
118
+ description: "Two buttons that commit or discard the staged buffer for a path",
119
+ fn: East.function([], UIComponentType, (_$) => {
120
+ return Reactive.Root(East.function([], UIComponentType, $ => {
121
+ const thresh = $.let(Data.bind([FloatType], thresholdInput.path, { mode: "staged" }));
122
+ const commit = $.const(East.function([], NullType, $ => {
123
+ $(thresh.commit());
124
+ }), FunctionType([], NullType));
125
+ const discard = $.const(East.function([], NullType, $ => {
126
+ $(thresh.discard());
127
+ }), FunctionType([], NullType));
128
+ return Stack.VStack([
129
+ Text.Root("Pending edits"),
130
+ Button.Root("Commit", { onClick: commit }),
131
+ Button.Root("Discard", {
132
+ style: { variant: "outline" },
133
+ onClick: discard,
134
+ }),
135
+ ], { gap: "3", align: "stretch" });
136
+ }));
137
+ }),
138
+ inputs: [],
139
+ });
140
+ export const dataBindStagedOriginalVsRead = example({
141
+ keywords: ["Data", "bindStaged", "original", "read", "overlay", "diff"],
142
+ description: "Show server snapshot (original) and overlay (read) side by side",
143
+ fn: East.function([], UIComponentType, (_$) => {
144
+ return Reactive.Root(East.function([], UIComponentType, $ => {
145
+ const thresh = $.let(Data.bind([FloatType], thresholdInput.path, { mode: "staged", patch: thresholdPatchInput.path }));
146
+ const live = $.let(thresh.read(), FloatType);
147
+ const server = $.let(thresh.source(), FloatType);
148
+ return Stack.VStack([
149
+ Stat.Root("Server", server),
150
+ Stat.Root("Live (with stage)", live),
151
+ ], { gap: "3", align: "stretch" });
152
+ }));
153
+ }),
154
+ inputs: [],
155
+ });
156
+ //# sourceMappingURL=data.examples.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.examples.js","sourceRoot":"","sources":["../../test/data.examples.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC9H,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACvG,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAElC,MAAM,CAAC,MAAM,cAAc,GAAQ,EAAE,CAAC,KAAK,CAAC,WAAW,EAAQ,SAAS,EAAE,IAAI,CAAC,CAAC;AAChF,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC,KAAK,CAAC,iBAAiB,EAAE,SAAS,CAAC,SAAS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EAAE,CAAC,CAAC,CAAC;YACvH,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS,CAAC,CAAC;YAC7C,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,CAAC,CAAC;YACjD,OAAO,KAAK,CAAC,MAAM,CAAC;gBAChB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAC3B,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC;aACvC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC,CAAC;IACR,CAAC,CAAC;IACF,MAAM,EAAE,EAAE;CACb,CAAC,CAAC"}
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * Diff component examples — realistic editing scenes that combine
7
+ * `Data.bindStaged` with east-ui form components and a `Diff` panel
8
+ * surfacing the pending changes for sign-off.
9
+ *
10
+ * Coverage:
11
+ * 1. Slider-driven editor → workforcePolicyEditor
12
+ * 2. Heterogeneous inputs → serviceConfigForm
13
+ * 3. Editable Table cells → rosterTableEditor
14
+ * 4. Mixed sliders + inputs → pricingRulesEditor (side-by-side mode)
15
+ * 5. Minimal call site → diffDefaults (IR-roundtrip)
16
+ *
17
+ * Pattern:
18
+ * 1. Declare an `e3.input(name, type, default)` per editable scalar.
19
+ * 2. Inside `Reactive.Root`, bind each via `Data.bindStaged`.
20
+ * 3. Wire form components — `read()` for the current value,
21
+ * `write()` on change.
22
+ * 4. Close the scene with `Diff.Root({ staged: [...inputs.path] })` —
23
+ * Apply commits the merged batch; Discard drops the buffer.
24
+ */
25
+ import { FloatType, IntegerType, StringType, BooleanType, DateTimeType, ArrayType, StructType, SetType, DictType, VariantType, NullType, variant } from "@elaraai/east";
26
+ import * as e3 from "@elaraai/e3";
27
+ export declare const maxWeeklyHoursInput: e3.DatasetDef<FloatType, [variant<"field", "inputs">, variant<"field", "max_weekly_hours">]>;
28
+ export declare const overtimeThresholdInput: e3.DatasetDef<FloatType, [variant<"field", "inputs">, variant<"field", "overtime_threshold_hours">]>;
29
+ export declare const restGapHoursInput: e3.DatasetDef<FloatType, [variant<"field", "inputs">, variant<"field", "mandatory_rest_gap_hours">]>;
30
+ export declare const holidayPenaltyInput: e3.DatasetDef<FloatType, [variant<"field", "inputs">, variant<"field", "public_holiday_penalty">]>;
31
+ export declare const serviceNameInput: e3.DatasetDef<StringType, [variant<"field", "inputs">, variant<"field", "service_name">]>;
32
+ export declare const replicasInput: e3.DatasetDef<IntegerType, [variant<"field", "inputs">, variant<"field", "replicas">]>;
33
+ export declare const autoScaleInput: e3.DatasetDef<BooleanType, [variant<"field", "inputs">, variant<"field", "auto_scale">]>;
34
+ export declare const regionInput: e3.DatasetDef<StringType, [variant<"field", "inputs">, variant<"field", "region">]>;
35
+ export declare const deployAfterInput: e3.DatasetDef<DateTimeType, [variant<"field", "inputs">, variant<"field", "deploy_after">]>;
36
+ export declare const rosterInput: e3.DatasetDef<ArrayType<StructType<{
37
+ readonly id: StringType;
38
+ readonly name: StringType;
39
+ readonly rate: FloatType;
40
+ readonly shiftLength: IntegerType;
41
+ }>>, [variant<"field", "inputs">, variant<"field", "roster">]>;
42
+ export declare const mergeDemoHoursInput: e3.DatasetDef<FloatType, [variant<"field", "inputs">, variant<"field", "merge_demo_hours">]>;
43
+ export declare const listPriceInput: e3.DatasetDef<FloatType, [variant<"field", "inputs">, variant<"field", "list_price">]>;
44
+ export declare const discountPctInput: e3.DatasetDef<FloatType, [variant<"field", "inputs">, variant<"field", "discount_pct">]>;
45
+ export declare const minOrderQtyInput: e3.DatasetDef<IntegerType, [variant<"field", "inputs">, variant<"field", "min_order_qty">]>;
46
+ export declare const currencyCodeInput: e3.DatasetDef<StringType, [variant<"field", "inputs">, variant<"field", "currency_code">]>;
47
+ export declare const featureFlagsInput: e3.DatasetDef<SetType<StringType>, [variant<"field", "inputs">, variant<"field", "feature_flags">]>;
48
+ export declare const regionalPricesInput: e3.DatasetDef<DictType<StringType, FloatType>, [variant<"field", "inputs">, variant<"field", "regional_prices">]>;
49
+ export declare const deploymentStatusInput: e3.DatasetDef<VariantType<{
50
+ readonly pending: NullType;
51
+ readonly in_progress: NullType;
52
+ readonly complete: NullType;
53
+ readonly failed: NullType;
54
+ }>, [variant<"field", "inputs">, variant<"field", "deployment_status">]>;
55
+ export declare const workforcePolicyEditor: import("@elaraai/east").ExampleDef<[], any>;
56
+ export declare const serviceConfigForm: import("@elaraai/east").ExampleDef<[], any>;
57
+ export declare const rosterTableEditor: import("@elaraai/east").ExampleDef<[], any>;
58
+ export declare const pricingRulesEditor: import("@elaraai/east").ExampleDef<[], any>;
59
+ export declare const featureFlagsEditor: import("@elaraai/east").ExampleDef<[], any>;
60
+ export declare const regionalPricingEditor: import("@elaraai/east").ExampleDef<[], any>;
61
+ export declare const deploymentStatusEditor: import("@elaraai/east").ExampleDef<[], any>;
62
+ export declare const diffDefaults: import("@elaraai/east").ExampleDef<[], any>;
63
+ /**
64
+ * Demonstrates the staged-mode merge tool / orange chooser. Workflow:
65
+ *
66
+ * 1. Drag the slider — your edit gets staged (snapshot pinned in StagedStore).
67
+ * 2. Click "Simulate concurrent edit" — `Data.bind.write(42.0)` writes 42 to
68
+ * the same path through the live cache, mimicking another session
69
+ * committing while you have edits open. Server view is now 42; your
70
+ * pinned snapshot is still 38; your buffer is whatever you dragged to.
71
+ * 3. Click Apply — `detectConflictsFor(userPatch, serverPatch)` finds both
72
+ * sides touching the root, switches the renderer to conflict mode, and
73
+ * shows the orange chooser row: keep yours (your dragged value), keep
74
+ * theirs (42), or manual (type a fresh number).
75
+ */
76
+ export declare const mergeConflictDemo: import("@elaraai/east").ExampleDef<[], any>;
77
+ /**
78
+ * Pricing-rules editor at `compact` density — tighter row padding and smaller
79
+ * type scale than the default `comfortable`. Suited to data-dense pages where
80
+ * the Diff card is one of several panels competing for vertical space.
81
+ */
82
+ export declare const pricingRulesEditorCompact: import("@elaraai/east").ExampleDef<[], any>;
83
+ /**
84
+ * Pricing-rules editor at `condensed` density — mission-control sizing.
85
+ * Tightest row padding and smallest type scale; pairs with status dashboards
86
+ * and other read-heavy contexts where a diff list is reference data, not the
87
+ * main interaction surface.
88
+ */
89
+ export declare const pricingRulesEditorCondensed: import("@elaraai/east").ExampleDef<[], any>;
90
+ export declare const maxWeeklyHoursPatchInput: e3.DatasetDef<import("@elaraai/east").EastType, [variant<"field", "inputs">, variant<"field", "max_weekly_hours_patch">]>;
91
+ export declare const regionalPricesPatchInput: e3.DatasetDef<import("@elaraai/east").EastType, [variant<"field", "inputs">, variant<"field", "regional_prices_patch">]>;
92
+ export declare const rosterPatchInput: e3.DatasetDef<import("@elaraai/east").EastType, [variant<"field", "inputs">, variant<"field", "roster_patch">]>;
93
+ export declare const regionalPricesDriftPatchInput: e3.DatasetDef<import("@elaraai/east").EastType, [variant<"field", "inputs">, variant<"field", "regional_prices_drift_patch">]>;
94
+ export declare const rosterDriftPatchInput: e3.DatasetDef<import("@elaraai/east").EastType, [variant<"field", "inputs">, variant<"field", "roster_drift_patch">]>;
95
+ /**
96
+ * Single-Float overlay editor — Slider edits go to `max_weekly_hours_patch`,
97
+ * the Diff card surfaces the patch against the source.
98
+ */
99
+ export declare const policyOverlayEditor: import("@elaraai/east").ExampleDef<[], any>;
100
+ /**
101
+ * Overlay binding whose patch input *starts* with a non-trivial patch that
102
+ * is stale relative to the source. Demonstrates what the Diff card displays
103
+ * when a server-stored patch was authored against an older revision of its
104
+ * source — stale delete, stale insert, stale replace.
105
+ *
106
+ * No form components: `view.read()` calls `apply(source, patch)`, which
107
+ * throws `ConflictError` on the stale ops. The Diff card walks the patch IR
108
+ * directly from cache bytes (no apply) so it renders cleanly. The
109
+ * `bindOverlay` call is kept so the renderer's overlay-type registry knows
110
+ * how to decode the patch bytes for this binding.
111
+ */
112
+ export declare const regionalPricingOverlayDrift: import("@elaraai/east").ExampleDef<[], any>;
113
+ /**
114
+ * Roster overlay drift — array-of-structs patch surfaced by the Diff card,
115
+ * exercising nested grouping (binding → `[index]` → struct field). The patch
116
+ * touches only `rate` on the first two entries, so the card renders
117
+ * `ROSTER → [0] → rate`, `[1] → rate`.
118
+ */
119
+ export declare const rosterOverlayDrift: import("@elaraai/east").ExampleDef<[], any>;
120
+ /**
121
+ * Roster table editor in overlay mode — patches stored in `roster_patch`,
122
+ * survive page reload and are visible to other workspace sessions.
123
+ */
124
+ export declare const rosterTableEditorOverlay: import("@elaraai/east").ExampleDef<[], any>;
125
+ /**
126
+ * Single-Float staged-with-patch editor — buffered Slider edits publish to
127
+ * `max_weekly_hours_patch` on Apply. The source `max_weekly_hours` stays
128
+ * untouched until a separate apply-patch-to-source step.
129
+ */
130
+ export declare const policyStagedPatchEditor: import("@elaraai/east").ExampleDef<[], any>;
131
+ /**
132
+ * Roster table editor in staged + patch mode. Cell edits buffer in
133
+ * IndexedDB until Apply, which publishes a fresh patch to `roster_patch`.
134
+ * Survives reload as a draft; multi-session reviewers see the patch only
135
+ * after the author commits.
136
+ */
137
+ export declare const rosterStagedPatchEditor: import("@elaraai/east").ExampleDef<[], any>;
138
+ //# sourceMappingURL=diff.examples.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.examples.d.ts","sourceRoot":"","sources":["../../test/diff.examples.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAEH,SAAS,EACT,WAAW,EACX,UAAU,EACV,WAAW,EACX,YAAY,EACZ,SAAS,EACT,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EACX,QAAQ,EAIR,OAAO,EAEV,MAAM,eAAe,CAAC;AAMvB,OAAO,KAAK,EAAE,MAAM,aAAa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