@algomotion/spec 0.0.0-stage → 1.0.0-alpha.1
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 +675 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/common.d.ts +136 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +181 -0
- package/dist/common.js.map +1 -0
- package/dist/errors.d.ts +71 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +43 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/json-schema.d.ts +3 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/json-schema.js +16 -0
- package/dist/json-schema.js.map +1 -0
- package/dist/kinds/array.d.ts +171 -0
- package/dist/kinds/array.d.ts.map +1 -0
- package/dist/kinds/array.js +179 -0
- package/dist/kinds/array.js.map +1 -0
- package/dist/kinds/btree.d.ts +190 -0
- package/dist/kinds/btree.d.ts.map +1 -0
- package/dist/kinds/btree.js +274 -0
- package/dist/kinds/btree.js.map +1 -0
- package/dist/kinds/graph.d.ts +227 -0
- package/dist/kinds/graph.d.ts.map +1 -0
- package/dist/kinds/graph.js +229 -0
- package/dist/kinds/graph.js.map +1 -0
- package/dist/kinds/hash-table.d.ts +108 -0
- package/dist/kinds/hash-table.d.ts.map +1 -0
- package/dist/kinds/hash-table.js +133 -0
- package/dist/kinds/hash-table.js.map +1 -0
- package/dist/kinds/index.d.ts +98 -0
- package/dist/kinds/index.d.ts.map +1 -0
- package/dist/kinds/index.js +53 -0
- package/dist/kinds/index.js.map +1 -0
- package/dist/kinds/kind.d.ts +73 -0
- package/dist/kinds/kind.d.ts.map +1 -0
- package/dist/kinds/kind.js +4 -0
- package/dist/kinds/kind.js.map +1 -0
- package/dist/kinds/linear.d.ts +24 -0
- package/dist/kinds/linear.d.ts.map +1 -0
- package/dist/kinds/linear.js +26 -0
- package/dist/kinds/linear.js.map +1 -0
- package/dist/kinds/linked-list.d.ts +132 -0
- package/dist/kinds/linked-list.d.ts.map +1 -0
- package/dist/kinds/linked-list.js +95 -0
- package/dist/kinds/linked-list.js.map +1 -0
- package/dist/kinds/plane.d.ts +190 -0
- package/dist/kinds/plane.d.ts.map +1 -0
- package/dist/kinds/plane.js +206 -0
- package/dist/kinds/plane.js.map +1 -0
- package/dist/kinds/priority-queue.d.ts +120 -0
- package/dist/kinds/priority-queue.d.ts.map +1 -0
- package/dist/kinds/priority-queue.js +108 -0
- package/dist/kinds/priority-queue.js.map +1 -0
- package/dist/kinds/queue.d.ts +94 -0
- package/dist/kinds/queue.d.ts.map +1 -0
- package/dist/kinds/queue.js +59 -0
- package/dist/kinds/queue.js.map +1 -0
- package/dist/kinds/stack.d.ts +70 -0
- package/dist/kinds/stack.d.ts.map +1 -0
- package/dist/kinds/stack.js +50 -0
- package/dist/kinds/stack.js.map +1 -0
- package/dist/kinds/table.d.ts +65 -0
- package/dist/kinds/table.d.ts.map +1 -0
- package/dist/kinds/table.js +116 -0
- package/dist/kinds/table.js.map +1 -0
- package/dist/kinds/tree.d.ts +272 -0
- package/dist/kinds/tree.d.ts.map +1 -0
- package/dist/kinds/tree.js +380 -0
- package/dist/kinds/tree.js.map +1 -0
- package/dist/parse.d.ts +26 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +380 -0
- package/dist/parse.js.map +1 -0
- package/dist/result.d.ts +16 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +3 -0
- package/dist/result.js.map +1 -0
- package/dist/share.d.ts +68 -0
- package/dist/share.d.ts.map +1 -0
- package/dist/share.js +319 -0
- package/dist/share.js.map +1 -0
- package/dist/version.d.ts +108 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +167 -0
- package/dist/version.js.map +1 -0
- package/dist/visualization.d.ts +3591 -0
- package/dist/visualization.d.ts.map +1 -0
- package/dist/visualization.js +131 -0
- package/dist/visualization.js.map +1 -0
- package/package.json +45 -4
- package/schema/visualization.schema.json +5717 -0
- package/README.md +0 -3
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `plane` kind (ADR 0038): points at coordinates and the segments
|
|
3
|
+
* between them, with named vertical lines (a sweep line, a dividing line)
|
|
4
|
+
* and optional axes, for computational geometry. Points and segments have
|
|
5
|
+
* ids, unique within the structure; a segment names its two end points.
|
|
6
|
+
*
|
|
7
|
+
* Marks: `highlight` and `compare` last one step; `visit`, `settle`,
|
|
8
|
+
* `select`, `pointer` and `line` persist.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { ElementId, isSafeKey, LIMITS, Place, PointerName } from "../common.js";
|
|
12
|
+
import { typesOf } from "./kind.js";
|
|
13
|
+
/** Most points, segments and lines a plane holds. */
|
|
14
|
+
export const MAX_POINTS = 64;
|
|
15
|
+
export const MAX_SEGMENTS = 128;
|
|
16
|
+
export const MAX_LINES = 8;
|
|
17
|
+
/** A coordinate: a finite number from −10⁶ to 10⁶. */
|
|
18
|
+
export const Coordinate = z.number().min(-1e6).max(1e6);
|
|
19
|
+
const Label = z.string().min(1).max(16);
|
|
20
|
+
export const PlanePoint = z
|
|
21
|
+
.strictObject({
|
|
22
|
+
id: ElementId,
|
|
23
|
+
x: Coordinate,
|
|
24
|
+
y: Coordinate,
|
|
25
|
+
label: Label.optional().describe('Shown beside the point; its id if absent.'),
|
|
26
|
+
})
|
|
27
|
+
.describe('A point at (x, y).');
|
|
28
|
+
export const PlaneSegment = z
|
|
29
|
+
.strictObject({
|
|
30
|
+
id: ElementId,
|
|
31
|
+
from: ElementId.describe('The id of one end point.'),
|
|
32
|
+
to: ElementId.describe('The id of the other end point.'),
|
|
33
|
+
label: Label.optional().describe('Shown beside the segment.'),
|
|
34
|
+
})
|
|
35
|
+
.describe('A segment between two points.');
|
|
36
|
+
const shape = {
|
|
37
|
+
kind: z.literal('plane'),
|
|
38
|
+
label: z.string().max(LIMITS.textLength).optional(),
|
|
39
|
+
place: Place.optional(),
|
|
40
|
+
axes: z
|
|
41
|
+
.boolean()
|
|
42
|
+
.optional()
|
|
43
|
+
.describe('Draw the x and y axes (default false).'),
|
|
44
|
+
};
|
|
45
|
+
export const PlaneDecl = z
|
|
46
|
+
.strictObject({
|
|
47
|
+
...shape,
|
|
48
|
+
points: z.array(PlanePoint).max(MAX_POINTS),
|
|
49
|
+
segments: z.array(PlaneSegment).max(MAX_SEGMENTS).optional(),
|
|
50
|
+
})
|
|
51
|
+
.describe('Points and segments in the plane, for computational geometry.');
|
|
52
|
+
export const PlaneDeclInput = z
|
|
53
|
+
.strictObject({
|
|
54
|
+
...shape,
|
|
55
|
+
points: z
|
|
56
|
+
.array(PlanePoint)
|
|
57
|
+
.max(MAX_POINTS)
|
|
58
|
+
.optional()
|
|
59
|
+
.describe('The points; none by default.'),
|
|
60
|
+
segments: z.array(PlaneSegment).max(MAX_SEGMENTS).optional(),
|
|
61
|
+
})
|
|
62
|
+
.describe('Points and segments in the plane, for computational geometry.');
|
|
63
|
+
/** A segment's two ends, in either order. */
|
|
64
|
+
const pairKey = (a, b) => (a < b ? `${a} ${b}` : `${b} ${a}`);
|
|
65
|
+
/** Points apart, segment ends known and distinct, one segment per pair. */
|
|
66
|
+
export function validatePlaneDecl(decl) {
|
|
67
|
+
const issues = [];
|
|
68
|
+
const at = new Map();
|
|
69
|
+
decl.points.forEach((p, k) => {
|
|
70
|
+
const where = `${p.x} ${p.y}`;
|
|
71
|
+
const other = at.get(where);
|
|
72
|
+
if (other !== undefined)
|
|
73
|
+
issues.push({
|
|
74
|
+
path: ['points', k],
|
|
75
|
+
message: `Points "${other}" and "${p.id}" are both at (${p.x}, ${p.y}); they would draw as one`,
|
|
76
|
+
});
|
|
77
|
+
else
|
|
78
|
+
at.set(where, p.id);
|
|
79
|
+
});
|
|
80
|
+
const ids = new Set(decl.points.map((p) => p.id));
|
|
81
|
+
const pairs = new Set();
|
|
82
|
+
(decl.segments ?? []).forEach((s, k) => {
|
|
83
|
+
for (const end of ['from', 'to'])
|
|
84
|
+
if (!ids.has(s[end]))
|
|
85
|
+
issues.push({
|
|
86
|
+
path: ['segments', k, end],
|
|
87
|
+
message: `Segment "${s.id}" ends at "${s[end]}", which is not a point`,
|
|
88
|
+
});
|
|
89
|
+
if (s.from === s.to)
|
|
90
|
+
issues.push({
|
|
91
|
+
path: ['segments', k, 'to'],
|
|
92
|
+
message: `Segment "${s.id}" goes from "${s.from}" to itself`,
|
|
93
|
+
});
|
|
94
|
+
const pair = pairKey(s.from, s.to);
|
|
95
|
+
if (pairs.has(pair))
|
|
96
|
+
issues.push({
|
|
97
|
+
path: ['segments', k],
|
|
98
|
+
message: `Two segments join "${s.from}" and "${s.to}"`,
|
|
99
|
+
});
|
|
100
|
+
pairs.add(pair);
|
|
101
|
+
});
|
|
102
|
+
return issues;
|
|
103
|
+
}
|
|
104
|
+
const PointRef = ElementId.describe('A point id.');
|
|
105
|
+
const SegmentRef = ElementId.describe('A segment id.');
|
|
106
|
+
const LineName = z
|
|
107
|
+
.string()
|
|
108
|
+
// No control characters, and no space at either end.
|
|
109
|
+
.regex(/^[^\s\p{Cc}](?:[^\p{Cc}]{0,10}[^\s\p{Cc}])?$/u)
|
|
110
|
+
.refine(isSafeKey, {
|
|
111
|
+
message: 'Line names may not be the names of object properties',
|
|
112
|
+
})
|
|
113
|
+
.describe('A line name of up to 12 characters, e.g. "sweep", "l" or "l + δ".');
|
|
114
|
+
const actions = z.discriminatedUnion('type', [
|
|
115
|
+
z
|
|
116
|
+
.strictObject({ type: z.literal('addPoint'), point: PlanePoint })
|
|
117
|
+
.describe('Add a point.'),
|
|
118
|
+
z
|
|
119
|
+
.strictObject({ type: z.literal('removePoint'), id: PointRef })
|
|
120
|
+
.describe('Remove a point that ends no segment.'),
|
|
121
|
+
z
|
|
122
|
+
.strictObject({ type: z.literal('addSegment'), segment: PlaneSegment })
|
|
123
|
+
.describe('Add a segment between two points.'),
|
|
124
|
+
z
|
|
125
|
+
.strictObject({ type: z.literal('removeSegment'), id: SegmentRef })
|
|
126
|
+
.describe('Remove a segment.'),
|
|
127
|
+
z
|
|
128
|
+
.strictObject({
|
|
129
|
+
type: z.literal('label'),
|
|
130
|
+
segment: SegmentRef,
|
|
131
|
+
text: Label.nullable(),
|
|
132
|
+
})
|
|
133
|
+
.describe("Change a segment's label, such as a distance; null removes it."),
|
|
134
|
+
z
|
|
135
|
+
.strictObject({
|
|
136
|
+
type: z.literal('highlight'),
|
|
137
|
+
points: z.array(PointRef).max(MAX_POINTS).optional(),
|
|
138
|
+
segments: z.array(SegmentRef).max(MAX_SEGMENTS).optional(),
|
|
139
|
+
})
|
|
140
|
+
.refine((a) => a.points !== undefined || a.segments !== undefined, {
|
|
141
|
+
message: 'Give `points`, `segments` or both',
|
|
142
|
+
})
|
|
143
|
+
.describe('Highlight points and segments (this step).'),
|
|
144
|
+
z
|
|
145
|
+
.strictObject({
|
|
146
|
+
type: z.literal('compare'),
|
|
147
|
+
points: z.array(PointRef).min(2).max(3),
|
|
148
|
+
})
|
|
149
|
+
.describe('Mark two or three points as being compared, as an orientation test or a distance does (this step).'),
|
|
150
|
+
z
|
|
151
|
+
.strictObject({ type: z.literal('visit'), point: PointRef })
|
|
152
|
+
.describe('Mark a point as considered (persists).'),
|
|
153
|
+
z
|
|
154
|
+
.strictObject({ type: z.literal('settle'), point: PointRef })
|
|
155
|
+
.describe('Mark a point as final, such as a hull vertex (persists).'),
|
|
156
|
+
z
|
|
157
|
+
.strictObject({
|
|
158
|
+
type: z.literal('select'),
|
|
159
|
+
segment: SegmentRef,
|
|
160
|
+
on: z.boolean(),
|
|
161
|
+
})
|
|
162
|
+
.describe('Mark a segment as chosen, such as a hull edge or a closest pair, or clear the mark (persists).'),
|
|
163
|
+
z
|
|
164
|
+
.strictObject({
|
|
165
|
+
type: z.literal('pointer'),
|
|
166
|
+
name: PointerName,
|
|
167
|
+
point: PointRef.nullable(),
|
|
168
|
+
})
|
|
169
|
+
.describe('A named badge at a point; null removes it (persists).'),
|
|
170
|
+
z
|
|
171
|
+
.strictObject({
|
|
172
|
+
type: z.literal('line'),
|
|
173
|
+
name: LineName,
|
|
174
|
+
x: Coordinate.nullable(),
|
|
175
|
+
})
|
|
176
|
+
.describe('A named vertical line at x, such as a sweep line; null removes it (persists).'),
|
|
177
|
+
]);
|
|
178
|
+
export const PlaneAction = actions;
|
|
179
|
+
export const PlaneActionInput = actions;
|
|
180
|
+
export const planeSpec = {
|
|
181
|
+
kind: 'plane',
|
|
182
|
+
decl: PlaneDecl,
|
|
183
|
+
declInput: PlaneDeclInput,
|
|
184
|
+
action: PlaneAction,
|
|
185
|
+
actionInput: PlaneActionInput,
|
|
186
|
+
actionTypes: typesOf(PlaneAction),
|
|
187
|
+
normalizeDecl: ({ points, ...rest }) => ({ ...rest, points: points ?? [] }),
|
|
188
|
+
declIds: (decl) => [
|
|
189
|
+
...decl.points.map((p, k) => ({
|
|
190
|
+
id: p.id,
|
|
191
|
+
path: ['points', k, 'id'],
|
|
192
|
+
})),
|
|
193
|
+
...(decl.segments ?? []).map((s, k) => ({
|
|
194
|
+
id: s.id,
|
|
195
|
+
path: ['segments', k, 'id'],
|
|
196
|
+
})),
|
|
197
|
+
],
|
|
198
|
+
validateDecl: validatePlaneDecl,
|
|
199
|
+
normalizeAction: (input) => input,
|
|
200
|
+
introducedIds: (action) => action.type === 'addPoint'
|
|
201
|
+
? [{ id: action.point.id, path: ['point', 'id'] }]
|
|
202
|
+
: action.type === 'addSegment'
|
|
203
|
+
? [{ id: action.segment.id, path: ['segment', 'id'] }]
|
|
204
|
+
: [],
|
|
205
|
+
};
|
|
206
|
+
//# sourceMappingURL=plane.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plane.js","sourceRoot":"","sources":["../../src/kinds/plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAA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AE,IAAI,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC;YACtD,CAAC,CAAC,EAAE;CACX,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `priorityQueue` kind (ADR 0029): items with keys, kept in key order,
|
|
3
|
+
* for algorithms such as Dijkstra's and Prim's that keep a min-priority
|
|
4
|
+
* queue. Items are named by id, as their positions change with every key
|
|
5
|
+
* change.
|
|
6
|
+
*
|
|
7
|
+
* Order (implemented by the core reducer and layout, documented here
|
|
8
|
+
* because it is part of the protocol):
|
|
9
|
+
* - The front is the item of least key (`order: "min"`, the default) or
|
|
10
|
+
* greatest key (`"max"`). A null key, no key yet, comes after every
|
|
11
|
+
* number in either order.
|
|
12
|
+
* - Ties keep insertion order, also after a key change.
|
|
13
|
+
*
|
|
14
|
+
* Marks: `highlight`, `peek` and the mark `setKey` leaves last one step.
|
|
15
|
+
*/
|
|
16
|
+
import { z } from 'zod';
|
|
17
|
+
import { type KindSpec } from './kind.ts';
|
|
18
|
+
/** A key: a number, or null for none yet (∞, or −∞ in a max-queue). */
|
|
19
|
+
export declare const PriorityKey: z.ZodNullable<z.ZodNumber>;
|
|
20
|
+
export type PriorityKey = z.infer<typeof PriorityKey>;
|
|
21
|
+
/** An element with its key. */
|
|
22
|
+
export declare const PriorityItem: z.ZodObject<{
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
25
|
+
key: z.ZodNullable<z.ZodNumber>;
|
|
26
|
+
}, z.core.$strict>;
|
|
27
|
+
export type PriorityItem = z.infer<typeof PriorityItem>;
|
|
28
|
+
/** Authoring form of an item: `id` may be left out, and is then generated. */
|
|
29
|
+
export declare const PriorityItemInput: z.ZodObject<{
|
|
30
|
+
id: z.ZodOptional<z.ZodString>;
|
|
31
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
32
|
+
key: z.ZodNullable<z.ZodNumber>;
|
|
33
|
+
}, z.core.$strict>;
|
|
34
|
+
export type PriorityItemInput = z.infer<typeof PriorityItemInput>;
|
|
35
|
+
export declare const PriorityQueueDecl: z.ZodObject<{
|
|
36
|
+
kind: z.ZodLiteral<"priorityQueue">;
|
|
37
|
+
label: z.ZodOptional<z.ZodString>;
|
|
38
|
+
place: z.ZodOptional<z.ZodEnum<{
|
|
39
|
+
main: "main";
|
|
40
|
+
side: "side";
|
|
41
|
+
}>>;
|
|
42
|
+
order: z.ZodOptional<z.ZodEnum<{
|
|
43
|
+
min: "min";
|
|
44
|
+
max: "max";
|
|
45
|
+
}>>;
|
|
46
|
+
initial: z.ZodArray<z.ZodObject<{
|
|
47
|
+
id: z.ZodString;
|
|
48
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
49
|
+
key: z.ZodNullable<z.ZodNumber>;
|
|
50
|
+
}, z.core.$strict>>;
|
|
51
|
+
}, z.core.$strict>;
|
|
52
|
+
export type PriorityQueueDecl = z.infer<typeof PriorityQueueDecl>;
|
|
53
|
+
export declare const PriorityQueueDeclInput: z.ZodObject<{
|
|
54
|
+
kind: z.ZodLiteral<"priorityQueue">;
|
|
55
|
+
label: z.ZodOptional<z.ZodString>;
|
|
56
|
+
place: z.ZodOptional<z.ZodEnum<{
|
|
57
|
+
main: "main";
|
|
58
|
+
side: "side";
|
|
59
|
+
}>>;
|
|
60
|
+
order: z.ZodOptional<z.ZodEnum<{
|
|
61
|
+
min: "min";
|
|
62
|
+
max: "max";
|
|
63
|
+
}>>;
|
|
64
|
+
initial: z.ZodArray<z.ZodObject<{
|
|
65
|
+
id: z.ZodOptional<z.ZodString>;
|
|
66
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
67
|
+
key: z.ZodNullable<z.ZodNumber>;
|
|
68
|
+
}, z.core.$strict>>;
|
|
69
|
+
}, z.core.$strict>;
|
|
70
|
+
export type PriorityQueueDeclInput = z.infer<typeof PriorityQueueDeclInput>;
|
|
71
|
+
/** Gives every item of the authoring form an id: e0, e1, … by position. */
|
|
72
|
+
export declare function normalizePriorityQueueDecl(input: PriorityQueueDeclInput): PriorityQueueDecl;
|
|
73
|
+
export declare const PriorityQueueAction: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
74
|
+
type: z.ZodLiteral<"insert">;
|
|
75
|
+
element: z.ZodObject<{
|
|
76
|
+
id: z.ZodString;
|
|
77
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
key: z.ZodNullable<z.ZodNumber>;
|
|
80
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
81
|
+
type: z.ZodLiteral<"extract">;
|
|
82
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
83
|
+
type: z.ZodLiteral<"setKey">;
|
|
84
|
+
id: z.ZodString;
|
|
85
|
+
key: z.ZodNullable<z.ZodNumber>;
|
|
86
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
87
|
+
type: z.ZodLiteral<"peek">;
|
|
88
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
89
|
+
type: z.ZodLiteral<"highlight">;
|
|
90
|
+
ids: z.ZodArray<z.ZodString>;
|
|
91
|
+
}, z.core.$strict>], "type">;
|
|
92
|
+
export type PriorityQueueAction = z.infer<typeof PriorityQueueAction>;
|
|
93
|
+
/** Authoring actions: `insert` also takes a bare value, given an id. */
|
|
94
|
+
export declare const PriorityQueueActionInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
95
|
+
type: z.ZodLiteral<"insert">;
|
|
96
|
+
element: z.ZodUnion<readonly [z.ZodObject<{
|
|
97
|
+
id: z.ZodString;
|
|
98
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
99
|
+
}, z.core.$strict>, z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>]>;
|
|
100
|
+
key: z.ZodNullable<z.ZodNumber>;
|
|
101
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
102
|
+
type: z.ZodLiteral<"extract">;
|
|
103
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
104
|
+
type: z.ZodLiteral<"setKey">;
|
|
105
|
+
id: z.ZodString;
|
|
106
|
+
key: z.ZodNullable<z.ZodNumber>;
|
|
107
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
108
|
+
type: z.ZodLiteral<"peek">;
|
|
109
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
110
|
+
type: z.ZodLiteral<"highlight">;
|
|
111
|
+
ids: z.ZodArray<z.ZodString>;
|
|
112
|
+
}, z.core.$strict>], "type">;
|
|
113
|
+
export type PriorityQueueActionInput = z.infer<typeof PriorityQueueActionInput>;
|
|
114
|
+
export declare const priorityQueueSpec: KindSpec<{
|
|
115
|
+
decl: PriorityQueueDecl;
|
|
116
|
+
declInput: PriorityQueueDeclInput;
|
|
117
|
+
action: PriorityQueueAction;
|
|
118
|
+
actionInput: PriorityQueueActionInput;
|
|
119
|
+
}>;
|
|
120
|
+
//# sourceMappingURL=priority-queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"priority-queue.d.ts","sourceRoot":"","sources":["../../src/kinds/priority-queue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGnD,uEAAuE;AACvE,eAAO,MAAM,WAAW,4BAKrB,CAAC;AACJ,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,+BAA+B;AAC/B,e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
3
|
+
* for algorithms such as Dijkstra's and Prim's that keep a min-priority
|
|
4
|
+
* queue. Items are named by id, as their positions change with every key
|
|
5
|
+
* change.
|
|
6
|
+
*
|
|
7
|
+
* Order (implemented by the core reducer and layout, documented here
|
|
8
|
+
* because it is part of the protocol):
|
|
9
|
+
* - The front is the item of least key (`order: "min"`, the default) or
|
|
10
|
+
* greatest key (`"max"`). A null key, no key yet, comes after every
|
|
11
|
+
* number in either order.
|
|
12
|
+
* - Ties keep insertion order, also after a key change.
|
|
13
|
+
*
|
|
14
|
+
* Marks: `highlight`, `peek` and the mark `setKey` leaves last one step.
|
|
15
|
+
*/
|
|
16
|
+
import { z } from 'zod';
|
|
17
|
+
import { Element, ElementId, ElementInput, LIMITS, Place, Scalar, } from "../common.js";
|
|
18
|
+
import { typesOf } from "./kind.js";
|
|
19
|
+
import { elementFieldIds, normalizeElementField } from "./linear.js";
|
|
20
|
+
/** A key: a number, or null for none yet (∞, or −∞ in a max-queue). */
|
|
21
|
+
export const PriorityKey = z
|
|
22
|
+
.number()
|
|
23
|
+
.nullable()
|
|
24
|
+
.describe('The priority: a number, or null for no key yet, drawn as ∞ (−∞ in a max-priority queue) and ordered after every number.');
|
|
25
|
+
/** An element with its key. */
|
|
26
|
+
export const PriorityItem = z
|
|
27
|
+
.strictObject({ id: ElementId, value: Scalar, key: PriorityKey })
|
|
28
|
+
.describe('An item: an element with its key.');
|
|
29
|
+
/** Authoring form of an item: `id` may be left out, and is then generated. */
|
|
30
|
+
export const PriorityItemInput = z
|
|
31
|
+
.strictObject({
|
|
32
|
+
id: ElementId.optional(),
|
|
33
|
+
value: Scalar,
|
|
34
|
+
key: PriorityKey,
|
|
35
|
+
})
|
|
36
|
+
.describe('An item `{ "value", "key" }`, with an `id` to choose one (ids "e0", "e1", … are generated otherwise).');
|
|
37
|
+
const Order = z
|
|
38
|
+
.enum(['min', 'max'])
|
|
39
|
+
.optional()
|
|
40
|
+
.describe('"min" (default): the least key is at the front, as for EXTRACT-MIN; "max": the greatest.');
|
|
41
|
+
export const PriorityQueueDecl = z
|
|
42
|
+
.strictObject({
|
|
43
|
+
kind: z.literal('priorityQueue'),
|
|
44
|
+
label: z.string().max(LIMITS.textLength).optional(),
|
|
45
|
+
place: Place.optional(),
|
|
46
|
+
order: Order,
|
|
47
|
+
initial: z
|
|
48
|
+
.array(PriorityItem)
|
|
49
|
+
.max(LIMITS.elementsPerStructure)
|
|
50
|
+
.describe('Items in insertion order, which breaks ties between keys.'),
|
|
51
|
+
})
|
|
52
|
+
.describe('A priority queue: items with keys, kept in key order.');
|
|
53
|
+
export const PriorityQueueDeclInput = PriorityQueueDecl.extend({
|
|
54
|
+
initial: z
|
|
55
|
+
.array(PriorityItemInput)
|
|
56
|
+
.max(LIMITS.elementsPerStructure)
|
|
57
|
+
.describe('Items in insertion order, which breaks ties between keys: [{ "value": "A", "key": 0 }, { "value": "B", "key": null }]; give "id" to choose an id.'),
|
|
58
|
+
});
|
|
59
|
+
/** Gives every item of the authoring form an id: e0, e1, … by position. */
|
|
60
|
+
export function normalizePriorityQueueDecl(input) {
|
|
61
|
+
const initial = input.initial.map((item, k) => ({
|
|
62
|
+
id: item.id ?? `e${k}`,
|
|
63
|
+
value: item.value,
|
|
64
|
+
key: item.key,
|
|
65
|
+
}));
|
|
66
|
+
return { ...input, initial };
|
|
67
|
+
}
|
|
68
|
+
const Ids = z.array(ElementId).min(1).max(LIMITS.elementsPerStructure);
|
|
69
|
+
const actions = (element) => z.discriminatedUnion('type', [
|
|
70
|
+
z
|
|
71
|
+
.strictObject({ type: z.literal('insert'), element, key: PriorityKey })
|
|
72
|
+
.describe('INSERT: add `element` with `key`; it takes its place in key order, after items of equal key.'),
|
|
73
|
+
z
|
|
74
|
+
.strictObject({ type: z.literal('extract') })
|
|
75
|
+
.describe('EXTRACT-MIN (or EXTRACT-MAX): remove the item at the front. The queue must not be empty.'),
|
|
76
|
+
z
|
|
77
|
+
.strictObject({
|
|
78
|
+
type: z.literal('setKey'),
|
|
79
|
+
id: ElementId,
|
|
80
|
+
key: PriorityKey,
|
|
81
|
+
})
|
|
82
|
+
.describe('DECREASE-KEY (or INCREASE-KEY): give item `id` a new key; it moves to its place and is highlighted this step.'),
|
|
83
|
+
z
|
|
84
|
+
.strictObject({ type: z.literal('peek') })
|
|
85
|
+
.describe('MINIMUM (or MAXIMUM): highlight the item at the front (this step only).'),
|
|
86
|
+
z
|
|
87
|
+
.strictObject({ type: z.literal('highlight'), ids: Ids })
|
|
88
|
+
.describe('Highlight items by id (this step only).'),
|
|
89
|
+
]);
|
|
90
|
+
export const PriorityQueueAction = actions(Element);
|
|
91
|
+
/** Authoring actions: `insert` also takes a bare value, given an id. */
|
|
92
|
+
export const PriorityQueueActionInput = actions(ElementInput);
|
|
93
|
+
export const priorityQueueSpec = {
|
|
94
|
+
kind: 'priorityQueue',
|
|
95
|
+
decl: PriorityQueueDecl,
|
|
96
|
+
declInput: PriorityQueueDeclInput,
|
|
97
|
+
action: PriorityQueueAction,
|
|
98
|
+
actionInput: PriorityQueueActionInput,
|
|
99
|
+
actionTypes: typesOf(PriorityQueueAction),
|
|
100
|
+
normalizeDecl: normalizePriorityQueueDecl,
|
|
101
|
+
declIds: (decl) => decl.initial.map((item, k) => ({
|
|
102
|
+
id: item.id,
|
|
103
|
+
path: ['initial', k, 'id'],
|
|
104
|
+
})),
|
|
105
|
+
normalizeAction: (action, ctx) => normalizeElementField(action, ctx),
|
|
106
|
+
introducedIds: (action) => action.type === 'insert' ? elementFieldIds(action) : [],
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=priority-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"priority-queue.js","sourceRoot":"","sources":["../../src/kinds/priority-queue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,OAAO,EACP,SAAS,EACT,YAAY,EACZ,MAAM,EACN,KA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MAAM,EAAE,EAAE,CACxB,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;CAC1D,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `queue` kind: a double-ended queue. Positions count from the front (0).
|
|
3
|
+
*
|
|
4
|
+
* Marks: `highlight` and `peek` last one step.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { type KindSpec } from './kind.ts';
|
|
8
|
+
export declare const QueueDecl: z.ZodObject<{
|
|
9
|
+
kind: z.ZodLiteral<"queue">;
|
|
10
|
+
label: z.ZodOptional<z.ZodString>;
|
|
11
|
+
place: z.ZodOptional<z.ZodEnum<{
|
|
12
|
+
main: "main";
|
|
13
|
+
side: "side";
|
|
14
|
+
}>>;
|
|
15
|
+
initial: z.ZodArray<z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
18
|
+
}, z.core.$strict>>;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
export type QueueDecl = z.infer<typeof QueueDecl>;
|
|
21
|
+
export declare const QueueDeclInput: z.ZodObject<{
|
|
22
|
+
kind: z.ZodLiteral<"queue">;
|
|
23
|
+
label: z.ZodOptional<z.ZodString>;
|
|
24
|
+
place: z.ZodOptional<z.ZodEnum<{
|
|
25
|
+
main: "main";
|
|
26
|
+
side: "side";
|
|
27
|
+
}>>;
|
|
28
|
+
initial: z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
29
|
+
id: z.ZodString;
|
|
30
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
31
|
+
}, z.core.$strict>>, z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>]>;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
export type QueueDeclInput = z.infer<typeof QueueDeclInput>;
|
|
34
|
+
export declare const QueueAction: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
35
|
+
type: z.ZodLiteral<"enqueue">;
|
|
36
|
+
element: z.ZodObject<{
|
|
37
|
+
id: z.ZodString;
|
|
38
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
41
|
+
type: z.ZodLiteral<"dequeue">;
|
|
42
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
43
|
+
type: z.ZodLiteral<"pushFront">;
|
|
44
|
+
element: z.ZodObject<{
|
|
45
|
+
id: z.ZodString;
|
|
46
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
49
|
+
type: z.ZodLiteral<"popBack">;
|
|
50
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
51
|
+
type: z.ZodLiteral<"peek">;
|
|
52
|
+
end: z.ZodOptional<z.ZodEnum<{
|
|
53
|
+
front: "front";
|
|
54
|
+
back: "back";
|
|
55
|
+
}>>;
|
|
56
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
57
|
+
type: z.ZodLiteral<"highlight">;
|
|
58
|
+
indices: z.ZodArray<z.ZodInt>;
|
|
59
|
+
}, z.core.$strict>], "type">;
|
|
60
|
+
export type QueueAction = z.infer<typeof QueueAction>;
|
|
61
|
+
export declare const QueueActionInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
62
|
+
type: z.ZodLiteral<"enqueue">;
|
|
63
|
+
element: z.ZodUnion<readonly [z.ZodObject<{
|
|
64
|
+
id: z.ZodString;
|
|
65
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
66
|
+
}, z.core.$strict>, z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>]>;
|
|
67
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
68
|
+
type: z.ZodLiteral<"dequeue">;
|
|
69
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
70
|
+
type: z.ZodLiteral<"pushFront">;
|
|
71
|
+
element: z.ZodUnion<readonly [z.ZodObject<{
|
|
72
|
+
id: z.ZodString;
|
|
73
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
74
|
+
}, z.core.$strict>, z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>]>;
|
|
75
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
76
|
+
type: z.ZodLiteral<"popBack">;
|
|
77
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
78
|
+
type: z.ZodLiteral<"peek">;
|
|
79
|
+
end: z.ZodOptional<z.ZodEnum<{
|
|
80
|
+
front: "front";
|
|
81
|
+
back: "back";
|
|
82
|
+
}>>;
|
|
83
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
84
|
+
type: z.ZodLiteral<"highlight">;
|
|
85
|
+
indices: z.ZodArray<z.ZodInt>;
|
|
86
|
+
}, z.core.$strict>], "type">;
|
|
87
|
+
export type QueueActionInput = z.infer<typeof QueueActionInput>;
|
|
88
|
+
export declare const queueSpec: KindSpec<{
|
|
89
|
+
decl: QueueDecl;
|
|
90
|
+
declInput: QueueDeclInput;
|
|
91
|
+
action: QueueAction;
|
|
92
|
+
actionInput: QueueActionInput;
|
|
93
|
+
}>;
|
|
94
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/kinds/queue.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAWnD,eAAO,MAAM,SAAS;;;;;;;;;;;kBAO8C,CAAC;AACrE,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD,eAAO,MAAM,cAAc;;;;;;;;;;;kBAA+C,CAAC;AAC3E,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AA4B5D,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;4BAAmB,CAAC;AAC5C,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AACtD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;4BAAwB,CAAC;AACtD,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC;IAC/B,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,cAAc,CAAC;IAC1B,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,EAAE,gBAAgB,CAAC;CAC/B,CAkBA,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `queue` kind: a double-ended queue. Positions count from the front (0).
|
|
3
|
+
*
|
|
4
|
+
* Marks: `highlight` and `peek` last one step.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { Element, ElementInput, LIMITS, Place } from "../common.js";
|
|
8
|
+
import { typesOf } from "./kind.js";
|
|
9
|
+
import { elementFieldIds, elementIds, Elements, ElementsInput, Indices, normalizeElementField, normalizeElements, } from "./linear.js";
|
|
10
|
+
export const QueueDecl = z
|
|
11
|
+
.strictObject({
|
|
12
|
+
kind: z.literal('queue'),
|
|
13
|
+
label: z.string().max(LIMITS.textLength).optional(),
|
|
14
|
+
place: Place.optional(),
|
|
15
|
+
initial: Elements.describe('Elements from front to back.'),
|
|
16
|
+
})
|
|
17
|
+
.describe('A queue; also supports deque operations at both ends.');
|
|
18
|
+
export const QueueDeclInput = QueueDecl.extend({ initial: ElementsInput });
|
|
19
|
+
const End = z.enum(['front', 'back']);
|
|
20
|
+
const actions = (element) => z.discriminatedUnion('type', [
|
|
21
|
+
z
|
|
22
|
+
.strictObject({ type: z.literal('enqueue'), element })
|
|
23
|
+
.describe('Add `element` at the back.'),
|
|
24
|
+
z
|
|
25
|
+
.strictObject({ type: z.literal('dequeue') })
|
|
26
|
+
.describe('Remove the element at the front.'),
|
|
27
|
+
z
|
|
28
|
+
.strictObject({ type: z.literal('pushFront'), element })
|
|
29
|
+
.describe('Add `element` at the front (deque).'),
|
|
30
|
+
z
|
|
31
|
+
.strictObject({ type: z.literal('popBack') })
|
|
32
|
+
.describe('Remove the element at the back (deque).'),
|
|
33
|
+
z
|
|
34
|
+
.strictObject({ type: z.literal('peek'), end: End.optional() })
|
|
35
|
+
.describe('Highlight the element at `end` (default "front"), this step only.'),
|
|
36
|
+
z
|
|
37
|
+
.strictObject({ type: z.literal('highlight'), indices: Indices })
|
|
38
|
+
.describe('Highlight positions counted from the front (this step only).'),
|
|
39
|
+
]);
|
|
40
|
+
export const QueueAction = actions(Element);
|
|
41
|
+
export const QueueActionInput = actions(ElementInput);
|
|
42
|
+
export const queueSpec = {
|
|
43
|
+
kind: 'queue',
|
|
44
|
+
decl: QueueDecl,
|
|
45
|
+
declInput: QueueDeclInput,
|
|
46
|
+
action: QueueAction,
|
|
47
|
+
actionInput: QueueActionInput,
|
|
48
|
+
actionTypes: typesOf(QueueAction),
|
|
49
|
+
normalizeDecl: (input) => ({
|
|
50
|
+
...input,
|
|
51
|
+
initial: normalizeElements(input.initial),
|
|
52
|
+
}),
|
|
53
|
+
declIds: (decl) => elementIds(decl.initial),
|
|
54
|
+
normalizeAction: (action, ctx) => normalizeElementField(action, ctx),
|
|
55
|
+
introducedIds: (action) => action.type === 'enqueue' || action.type === 'pushFront'
|
|
56
|
+
? elementFieldIds(action)
|
|
57
|
+
: [],
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/kinds/queue.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,OAAO,EAAiB,MAAM,WAAW,CAAC;AACnD,OAAO,EACL,eAAe,EACf,UAAU,EACV,QAAQ,EACR,aAAa,EACb,OAAO,EACP,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC;KACvB,YAAY,CAAC;IACZ,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACxB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE;IACnD,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE;IACvB,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,8BAA8B,CAAC;CAC3D,CAAC;KACD,QAAQ,CAAC,uDAAuD,CAAC,CAAC;AAGrE,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;AAG3E,MAAM,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAEtC,MA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