@voidhash/mimic 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as OperationPath_d_exports, a as InferSetInput, c as InferUpdateInput, d as ProxyEnvironment_d_exports, g as Operation_d_exports, h as Operation, i as InferProxy, m as Transaction_d_exports, n as AnyTreeNodePrimitive, o as InferSnapshot, p as Transaction, r as AnyPrimitive, s as InferState, t as Primitive_d_exports, u as Transform_d_exports, v as __export } from "./Primitive-CvFVxR8_.cjs";
1
+ import { $ as InferState, A as InferLazyProxy, B as ArraySnapshot, C as TreeNodeSelfType, D as InferUnionSnapshot, E as ScalarPrimitive, F as ArrayElementSetInput, G as StructProxy, H as ArrayUpdateInput, I as ArrayEntry, J as AnyPrimitive, K as StructSetInput, L as ArrayEntrySnapshot, M as InferLazySnapshot, N as InferLazyState, O as InferUnionState, P as InferLazyUpdateInput, Q as InferSnapshot, R as ArrayProxy, S as TreeNodeSelf, T as InferEitherState, U as InferStructSnapshot, V as ArrayState, W as InferStructState, X as InferProxy, Y as HasDefault, Z as InferSetInput, _ as InferTreeNodeDataState, _t as OperationPath_d_exports, a as TreeNodeSnapshot, at as Optional, b as TreeNodeConfig, c as TreePrimitive, ct as Validator, d as TreeState, dt as ProxyEnvironment_d_exports, et as InferUpdateInput, f as TreeUpdateInput, g as InferTreeNodeChildren, gt as Operation_d_exports, h as AnyTreeNodePrimitive, ht as Operation, i as TreeNodeProxyBase, it as NeedsValue, j as InferLazySetInput, k as UnionVariants, l as TreeProxy, m as TypedTreeNodeState, mt as Transaction_d_exports, n as InferTreeSnapshot, nt as IsRequired, o as TreeNodeState, ot as Primitive, p as TypedNodeProxy, pt as Transaction, q as StructUpdateValue, r as TreeNodeDataSetInput, rt as MaybeUndefined, s as TreeNodeUpdateValue, st as PrimitiveInternal, t as Primitive_d_exports, tt as IsDefined, u as TreeSetInput, ut as Transform_d_exports, v as InferTreeNodeType, vt as __export, w as InferEitherSnapshot, x as TreeNodePrimitive, y as TreeNodeChildrenInput, z as ArraySetInput } from "./Primitive-awpEjnKL.cjs";
2
2
  import { i as Presence_d_exports } from "./Presence-DKKP4v5X.cjs";
3
3
  import { Schema } from "effect";
4
4
 
@@ -138,6 +138,282 @@ declare function toSetSchema<T extends AnyTreeNodePrimitive>(primitive: T): ToTr
138
138
  */
139
139
  declare function toUpdateSchema<T extends AnyPrimitive>(primitive: T): ToUpdateSchema<T>;
140
140
  declare function toUpdateSchema<T extends AnyTreeNodePrimitive>(primitive: T): ToTreeNodeUpdateSchema<T>;
141
+ declare namespace index_d_exports {
142
+ export { AnyPrimitive, AnyTreeNodePrimitive, ArrayElementSetInput, ArrayEntry, ArrayEntrySnapshot, ArrayProxy, ArraySetInput, ArraySnapshot, ArrayState, ArrayUpdateInput, HasDefault, InferEitherSnapshot, InferEitherState, InferLazyProxy, InferLazySetInput, InferLazySnapshot, InferLazyState, InferLazyUpdateInput, InferProxy, InferSetInput, InferSnapshot, InferState, InferStructSnapshot, InferStructState, InferTreeNodeChildren, InferTreeNodeDataState, InferTreeNodeType, InferTreeSnapshot, InferUnionSnapshot, InferUnionState, InferUpdateInput, IsDefined, IsRequired, MaybeUndefined, NeedsValue, Optional, Primitive, PrimitiveInternal, ScalarPrimitive, StructProxy, StructSetInput, StructUpdateValue, TreeNodeChildrenInput, TreeNodeConfig, TreeNodeDataSetInput, TreeNodePrimitive, TreeNodeProxyBase, TreeNodeSelf, TreeNodeSelfType, TreeNodeSnapshot, TreeNodeState, TreeNodeUpdateValue, TreeProxy, TreeSetInput, TreeState, TreeUpdateInput, TypedNodeProxy, TypedTreeNodeState, UnionVariants, Validator };
143
+ }
144
+ declare namespace tree_helpers_d_exports {
145
+ export { FlattenedNode, NodeSearchResult, ParentSearchResult, TraverseOptions, buildNodeTypeMap, canAddChildType, findNode, findNodeById, findNodeWithPath, findNodes, flattenTree, getAllNodeTypes, getAllowedChildTypes, getAllowedChildTypesForNode, getAncestors, getDescendants, getNodeDepth, getNodePrimitive, getNodeTypeByName, getParent, getSiblings, getSubtree, isAncestorOf, isChildTypeAllowed, mapTree, traverse };
146
+ }
147
+ /**
148
+ * Result of finding a node with path information.
149
+ */
150
+ interface NodeSearchResult<TNode extends AnyTreeNodePrimitive> {
151
+ readonly node: TreeNodeSnapshot<TNode>;
152
+ readonly path: readonly string[];
153
+ readonly depth: number;
154
+ }
155
+ /**
156
+ * Result of finding a parent node.
157
+ */
158
+ interface ParentSearchResult<TNode extends AnyTreeNodePrimitive> {
159
+ readonly parent: TreeNodeSnapshot<TNode>;
160
+ readonly childIndex: number;
161
+ }
162
+ /**
163
+ * Flattened node with parent information.
164
+ */
165
+ interface FlattenedNode<TNode extends AnyTreeNodePrimitive> {
166
+ readonly node: TreeNodeSnapshot<TNode>;
167
+ readonly parentId: string | null;
168
+ readonly depth: number;
169
+ }
170
+ /**
171
+ * Options for tree traversal.
172
+ */
173
+ interface TraverseOptions {
174
+ readonly order?: "pre" | "post";
175
+ }
176
+ /**
177
+ * Find a node by ID in a tree snapshot.
178
+ *
179
+ * @param snapshot - The root tree snapshot
180
+ * @param id - The node ID to find
181
+ * @returns The node snapshot if found, undefined otherwise
182
+ */
183
+ declare function findNodeById<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, id: string): TreeNodeSnapshot<TNode> | undefined;
184
+ /**
185
+ * Find a node by ID with full path information.
186
+ *
187
+ * @param snapshot - The root tree snapshot
188
+ * @param id - The node ID to find
189
+ * @returns NodeSearchResult with node, path, and depth, or undefined if not found
190
+ */
191
+ declare function findNodeWithPath<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, id: string): NodeSearchResult<TNode> | undefined;
192
+ /**
193
+ * Get the parent node of a given node ID.
194
+ *
195
+ * @param snapshot - The root tree snapshot
196
+ * @param nodeId - The ID of the node whose parent we want
197
+ * @returns ParentSearchResult with parent node and child index, or undefined
198
+ */
199
+ declare function getParent<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, nodeId: string): ParentSearchResult<TNode> | undefined;
200
+ /**
201
+ * Get a subtree rooted at a specific node ID.
202
+ *
203
+ * @param snapshot - The root tree snapshot
204
+ * @param nodeId - The ID of the node to use as new root
205
+ * @returns The subtree snapshot, or undefined if node not found
206
+ */
207
+ declare function getSubtree<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, nodeId: string): TreeNodeSnapshot<TNode> | undefined;
208
+ /**
209
+ * Get all ancestor nodes from a node up to the root.
210
+ *
211
+ * @param snapshot - The root tree snapshot
212
+ * @param nodeId - The ID of the node
213
+ * @returns Array of ancestor snapshots from immediate parent to root, or empty array
214
+ */
215
+ declare function getAncestors<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, nodeId: string): readonly TreeNodeSnapshot<TNode>[];
216
+ /**
217
+ * Get all descendant nodes of a given node (flat array).
218
+ *
219
+ * @param snapshot - The root tree snapshot
220
+ * @param nodeId - The ID of the node (if undefined, returns all descendants of root)
221
+ * @returns Flat array of all descendant node snapshots
222
+ */
223
+ declare function getDescendants<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, nodeId?: string): readonly TreeNodeSnapshot<TNode>[];
224
+ /**
225
+ * Get siblings of a node (nodes with the same parent).
226
+ *
227
+ * @param snapshot - The root tree snapshot
228
+ * @param nodeId - The ID of the node
229
+ * @param includeSelf - Whether to include the node itself (default: false)
230
+ * @returns Array of sibling snapshots
231
+ */
232
+ declare function getSiblings<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, nodeId: string, includeSelf?: boolean): readonly TreeNodeSnapshot<TNode>[];
233
+ /**
234
+ * Find the first node matching a predicate.
235
+ *
236
+ * @param snapshot - The root tree snapshot
237
+ * @param predicate - Function to test each node
238
+ * @returns First matching node snapshot, or undefined
239
+ */
240
+ declare function findNode<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, predicate: (node: TreeNodeSnapshot<TNode>) => boolean): TreeNodeSnapshot<TNode> | undefined;
241
+ /**
242
+ * Find all nodes matching a predicate.
243
+ *
244
+ * @param snapshot - The root tree snapshot
245
+ * @param predicate - Function to test each node
246
+ * @returns Array of matching node snapshots
247
+ */
248
+ declare function findNodes<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, predicate: (node: TreeNodeSnapshot<TNode>) => boolean): readonly TreeNodeSnapshot<TNode>[];
249
+ /**
250
+ * Get the depth of a specific node (0 = root).
251
+ *
252
+ * @param snapshot - The root tree snapshot
253
+ * @param nodeId - The ID of the node
254
+ * @returns The depth, or -1 if not found
255
+ */
256
+ declare function getNodeDepth<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, nodeId: string): number;
257
+ /**
258
+ * Check if one node is an ancestor of another.
259
+ *
260
+ * @param snapshot - The root tree snapshot
261
+ * @param ancestorId - Potential ancestor node ID
262
+ * @param descendantId - Potential descendant node ID
263
+ * @returns true if ancestorId is an ancestor of descendantId
264
+ */
265
+ declare function isAncestorOf<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, ancestorId: string, descendantId: string): boolean;
266
+ /**
267
+ * Traverse the tree and call a visitor function for each node.
268
+ * Return false from visitor to stop traversal.
269
+ *
270
+ * @param snapshot - The root tree snapshot
271
+ * @param visitor - Function called for each node (return false to stop)
272
+ * @param options - Traversal options (order: 'pre' | 'post')
273
+ */
274
+ declare function traverse<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, visitor: (node: TreeNodeSnapshot<TNode>, depth: number) => void | false, options?: TraverseOptions): void;
275
+ /**
276
+ * Flatten the tree into an array with parent information.
277
+ *
278
+ * @param snapshot - The root tree snapshot
279
+ * @returns Array of { node, parentId, depth } objects
280
+ */
281
+ declare function flattenTree<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined): readonly FlattenedNode<TNode>[];
282
+ /**
283
+ * Map over all nodes in the tree, transforming each node's data.
284
+ * Preserves tree structure while transforming node content.
285
+ *
286
+ * @param snapshot - The root tree snapshot
287
+ * @param mapper - Function to transform each node
288
+ * @returns New tree structure with transformed nodes, or undefined
289
+ */
290
+ declare function mapTree<TNode extends AnyTreeNodePrimitive, R>(snapshot: TreeNodeSnapshot<TNode> | undefined, mapper: (node: TreeNodeSnapshot<TNode>, depth: number) => R): {
291
+ value: R;
292
+ children: ReturnType<typeof mapTree<TNode, R>>[];
293
+ } | undefined;
294
+ /**
295
+ * Build a lookup map from node type strings to their TreeNodePrimitive definitions.
296
+ * Useful for resolving snapshot node types back to their schema definitions.
297
+ *
298
+ * @param tree - The TreePrimitive to analyze
299
+ * @returns Map from type string to TreeNodePrimitive
300
+ *
301
+ * @example
302
+ * ```ts
303
+ * const typeMap = buildNodeTypeMap(fileTree);
304
+ * const folderPrimitive = typeMap.get("folder"); // FolderNode
305
+ * ```
306
+ */
307
+ declare function buildNodeTypeMap<TRoot extends AnyTreeNodePrimitive>(tree: TreePrimitive<TRoot>): Map<string, AnyTreeNodePrimitive>;
308
+ /**
309
+ * Get the TreeNodePrimitive definition for a snapshot node.
310
+ * Requires the tree schema to resolve the type string to its primitive.
311
+ *
312
+ * @param tree - The TreePrimitive schema
313
+ * @param snapshot - The node snapshot to get the primitive for
314
+ * @returns The TreeNodePrimitive, or undefined if not found
315
+ *
316
+ * @example
317
+ * ```ts
318
+ * const node = findNodeById(treeSnapshot, "some-id");
319
+ * const primitive = getNodePrimitive(fileTree, node);
320
+ * // primitive is FolderNode or FileNode depending on node.type
321
+ * ```
322
+ */
323
+ declare function getNodePrimitive<TRoot extends AnyTreeNodePrimitive>(tree: TreePrimitive<TRoot>, snapshot: TreeNodeSnapshot<AnyTreeNodePrimitive>): AnyTreeNodePrimitive | undefined;
324
+ /**
325
+ * Get the allowed child types for a snapshot node.
326
+ * Combines schema lookup with the node's allowed children.
327
+ *
328
+ * @param tree - The TreePrimitive schema
329
+ * @param snapshot - The node snapshot to get allowed children for
330
+ * @returns Array of allowed child TreeNodePrimitives, or empty array if not found
331
+ *
332
+ * @example
333
+ * ```ts
334
+ * const node = findNodeById(treeSnapshot, "folder-id");
335
+ * const allowedChildren = getAllowedChildTypesForNode(fileTree, node);
336
+ * // Returns [FolderNode, FileNode] if the folder can contain both
337
+ * ```
338
+ */
339
+ declare function getAllowedChildTypesForNode<TRoot extends AnyTreeNodePrimitive>(tree: TreePrimitive<TRoot>, snapshot: TreeNodeSnapshot<AnyTreeNodePrimitive>): readonly AnyTreeNodePrimitive[];
340
+ /**
341
+ * Check if a child type is allowed for a specific snapshot node.
342
+ *
343
+ * @param tree - The TreePrimitive schema
344
+ * @param parentSnapshot - The parent node snapshot
345
+ * @param childTypeName - The type string of the potential child
346
+ * @returns true if the child type is allowed
347
+ *
348
+ * @example
349
+ * ```ts
350
+ * const folder = findNodeById(treeSnapshot, "folder-id");
351
+ * canAddChildType(fileTree, folder, "file"); // true
352
+ * canAddChildType(fileTree, folder, "unknown"); // false
353
+ * ```
354
+ */
355
+ declare function canAddChildType<TRoot extends AnyTreeNodePrimitive>(tree: TreePrimitive<TRoot>, parentSnapshot: TreeNodeSnapshot<AnyTreeNodePrimitive>, childTypeName: string): boolean;
356
+ /**
357
+ * Get all allowed child node types for a specific node type.
358
+ *
359
+ * @param nodeType - The TreeNodePrimitive to get children for
360
+ * @returns Array of allowed child TreeNodePrimitives
361
+ *
362
+ * @example
363
+ * ```ts
364
+ * const FolderNode = TreeNode("folder", { ... });
365
+ * const FileNode = TreeNode("file", { ... });
366
+ *
367
+ * // Get allowed children for FolderNode
368
+ * const allowedChildren = getAllowedChildTypes(FolderNode);
369
+ * // Returns [FolderNode, FileNode] if folder can contain both
370
+ * ```
371
+ */
372
+ declare function getAllowedChildTypes<TNode extends AnyTreeNodePrimitive>(nodeType: TNode): readonly AnyTreeNodePrimitive[];
373
+ /**
374
+ * Get all unique node types reachable in a tree schema.
375
+ * Recursively traverses the tree structure starting from the root.
376
+ *
377
+ * @param tree - The TreePrimitive to analyze
378
+ * @returns Array of all unique TreeNodePrimitives in the tree schema
379
+ *
380
+ * @example
381
+ * ```ts
382
+ * const fileTree = Tree({ root: FolderNode });
383
+ * const allNodeTypes = getAllNodeTypes(fileTree);
384
+ * // Returns [FolderNode, FileNode] - all possible node types
385
+ * ```
386
+ */
387
+ declare function getAllNodeTypes<TRoot extends AnyTreeNodePrimitive>(tree: TreePrimitive<TRoot>): readonly AnyTreeNodePrimitive[];
388
+ /**
389
+ * Get the node type primitive by its type string from a tree schema.
390
+ *
391
+ * @param tree - The TreePrimitive to search
392
+ * @param typeName - The type string to find (e.g., "folder", "file")
393
+ * @returns The matching TreeNodePrimitive, or undefined if not found
394
+ *
395
+ * @example
396
+ * ```ts
397
+ * const fileTree = Tree({ root: FolderNode });
398
+ * const folderType = getNodeTypeByName(fileTree, "folder");
399
+ * // Returns FolderNode
400
+ * ```
401
+ */
402
+ declare function getNodeTypeByName<TRoot extends AnyTreeNodePrimitive>(tree: TreePrimitive<TRoot>, typeName: string): AnyTreeNodePrimitive | undefined;
403
+ /**
404
+ * Check if a child type is allowed under a parent type.
405
+ *
406
+ * @param parentType - The parent TreeNodePrimitive
407
+ * @param childTypeName - The type string of the potential child
408
+ * @returns true if the child type is allowed
409
+ *
410
+ * @example
411
+ * ```ts
412
+ * isChildTypeAllowed(FolderNode, "file"); // true if folder can contain files
413
+ * isChildTypeAllowed(FileNode, "folder"); // false - files can't have children
414
+ * ```
415
+ */
416
+ declare function isChildTypeAllowed(parentType: AnyTreeNodePrimitive, childTypeName: string): boolean;
141
417
  //#endregion
142
- export { Document_d_exports as Document, EffectSchema_d_exports as EffectSchema, Operation_d_exports as Operation, OperationPath_d_exports as OperationPath, Presence_d_exports as Presence, Primitive_d_exports as Primitive, ProxyEnvironment_d_exports as ProxyEnvironment, Transaction_d_exports as Transaction, Transform_d_exports as Transform };
418
+ export { Document_d_exports as Document, EffectSchema_d_exports as EffectSchema, Operation_d_exports as Operation, OperationPath_d_exports as OperationPath, Presence_d_exports as Presence, type Primitive_d_exports as Primitive, ProxyEnvironment_d_exports as ProxyEnvironment, Transaction_d_exports as Transaction, Transform_d_exports as Transform, tree_helpers_d_exports as TreeHelpers, index_d_exports as Types };
143
419
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/Document.ts","../src/EffectSchema.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;cAaa,sBAAA,SAA+B,KAAA;;;;;;AAA5C;AAWa,cAAA,cAAA,SAAuB,KAAA,CAAK;EAexB,SAAA,IAAQ,GAAA,gBAAA;EAAiB,WAAA,CAAA,OAAA,EAAA,MAAA;;;;;AAQjC,UARQ,QAQR,CAAA,gBARiC,YAQjC,CAAA,CAAA;EAQ+B;EAAxB,SAAA,MAAA,EAdG,OAcH;EAQiC;EAArB,SAAA,IAAA,EAnBX,UAmBW,CAnBU,OAmBV,CAAA;EAAkC;EAAI,GAAA,EAAA,EAhBzD,UAgByD,CAhBpC,OAgBoC,CAAA,GAAA,SAAA;EAMvC;;;;AAY3B;;EAE0C,UAAA,EAAA,EA5B1B,aA4B0B,CA5BF,OA4BE,CAAA;EAArB;;AAUrB;;;;EAEY,WAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,IAAA,EAhCgB,UAgChB,CAhCqC,OAgCrC,CAAA,EAAA,GAhCkD,CAgClD,CAAA,EAhCsD,CAgCtD;EACA;;;;aA3BC,cAAc;;;;WAKhB;;UAOM,gCAAgC;;qBAE5B,WAAqB;;;AC7D1C;;AAA8E,cDuEjE,ICvEiE,EAAA,CAAA,gBDuEzC,YCvEyC,CAAA,CAAA,MAAA,EDwEpE,OCxEoE,EAAA,OAAA,CAAA,EDyElE,eCzEk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9Td,CAAA,UA8TuC,oBA9TvC,CAAA,CAAA,SAAA,EA8TwE,CA9TxE,CAAA,EA8T4E,sBA9T5E,CA8TmG,CA9TnG,CAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/Document.ts","../src/EffectSchema.ts","../src/types/index.ts","../src/utils/tree-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;cAaa,sBAAA,SAA+B,KAAA;;;;;;AAA5C;AAWa,cAAA,cAAA,SAAuB,KAAA,CAAK;EAexB,SAAA,IAAQ,GAAA,gBAAA;EAAiB,WAAA,CAAA,OAAA,EAAA,MAAA;;;;;AAQjC,UARQ,QAQR,CAAA,gBARiC,YAQjC,CAAA,CAAA;EAQ+B;EAAxB,SAAA,MAAA,EAdG,OAcH;EAQiC;EAArB,SAAA,IAAA,EAnBX,UAmBW,CAnBU,OAmBV,CAAA;EAAkC;EAAI,GAAA,EAAA,EAhBzD,UAgByD,CAhBpC,OAgBoC,CAAA,GAAA,SAAA;EAMvC;;;;AAY3B;;EAE0C,UAAA,EAAA,EA5B1B,aA4B0B,CA5BF,OA4BE,CAAA;EAArB;;AAUrB;;;;EAEY,WAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,IAAA,EAhCgB,UAgChB,CAhCqC,OAgCrC,CAAA,EAAA,GAhCkD,CAgClD,CAAA,EAhCsD,CAgCtD;EACA;;;;aA3BC,cAAc;;;;WAKhB;;UAOM,gCAAgC;;qBAE5B,WAAqB;;;AC7D1C;;AAA8E,cDuEjE,ICvEiE,EAAA,CAAA,gBDuEzC,YCvEyC,CAAA,CAAA,MAAA,EDwEpE,OCxEoE,EAAA,OAAA,CAAA,EDyElE,eCzEkE,CDyElD,OCzEkD,CAAA,EAAA,GD0E3E,QC1E2E,CD0ElE,OC1EkE,CAAA;AAAA;;;;;;KAAlE,sBAAsB,gBAAgB,MAAA,CAAO,OAAO,cAAc;ADT9E;AAWA;AAeA;AAA0C,KCZ9B,cDY8B,CAAA,U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AA0B;SAChD;YAAa,kBAAkB,QAAQ,OAAO;;;;;;;;;;;;;;;iBAkC1C,+BAA+B,4BACvC,cAAc,SACnB,YAAY;;;;;;;;;;;;;;;;iBAiCC,+BAA+B,4BACvC,cAAc,kBACV,iBAAiB,wBAC1B;;;;;;;;;;;;;;;;iBAmBa,0CAA0C,4BAClD,cAAc,kBACV,iBAAiB,iCACjB;;;;;;;AArfZ;;;;;AASA;;;;AACmC,iBAggBnB,eAhgBmB,CAAA,cAggBW,oBAhgBX,CAAA,CAAA,IAAA,EAigB3B,aAjgB2B,CAigBb,KAjgBa,CAAA,EAAA,cAAA,EAkgBjB,gBAlgBiB,CAkgBA,oBAlgBA,CAAA,EAAA,aAAA,EAAA,MAAA,CAAA,EAAA,OAAA;AAOnC;;;;;AASA;AAeA;;;;;;;AAsBA;;;AACY,iBAoeI,oBApeJ,CAAA,cAoeuC,oBApevC,CAAA,CAAA,QAAA,EAqeA,KAreA,CAAA,EAAA,SAseA,oBAteA,EAAA;;;;AAkCZ;;;;;;;AAiCA;;;;AAGoB,iBAkbJ,eAlbI,CAAA,cAkb0B,oBAlb1B,CAAA,CAAA,IAAA,EAmbZ,aAnbY,CAmbE,KAnbF,CAAA,CAAA,EAAA,SAobR,oBApbQ,EAAA;;;AAWpB;;;;;;;AAkCA;;;;;AAGY,iBAoaI,iBApaJ,CAAA,cAoaoC,oBApapC,CAAA,CAAA,IAAA,EAqaJ,aAraI,CAqaU,KAraV,CAAA,EAAA,QAAA,EAAA,MAAA,CAAA,EAuaT,oBAvaS,GAAA,SAAA;;AA2BZ;;;;;;;AAgCA;;;;;AAEoB,iBA4XJ,kBAAA,CA5XI,UAAA,EA6XN,oBA7XM,EAAA,aAAA,EAAA,MAAA,CAAA,EAAA,OAAA"}
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { i as Presence_d_exports } from "./Presence-N8u7Eppr.mjs";
2
- import { _ as OperationPath_d_exports, a as InferSetInput, c as InferUpdateInput, d as ProxyEnvironment_d_exports, g as Operation_d_exports, h as Operation, i as InferProxy, m as Transaction_d_exports, n as AnyTreeNodePrimitive, o as InferSnapshot, p as Transaction, r as AnyPrimitive, s as InferState, t as Primitive_d_exports, u as Transform_d_exports } from "./Primitive-lEhQyGVL.mjs";
2
+ import { $ as InferState, A as InferLazyProxy, B as ArraySnapshot, C as TreeNodeSelfType, D as InferUnionSnapshot, E as ScalarPrimitive, F as ArrayElementSetInput, G as StructProxy, H as ArrayUpdateInput, I as ArrayEntry, J as AnyPrimitive, K as StructSetInput, L as ArrayEntrySnapshot, M as InferLazySnapshot, N as InferLazyState, O as InferUnionState, P as InferLazyUpdateInput, Q as InferSnapshot, R as ArrayProxy, S as TreeNodeSelf, T as InferEitherState, U as InferStructSnapshot, V as ArrayState, W as InferStructState, X as InferProxy, Y as HasDefault, Z as InferSetInput, _ as InferTreeNodeDataState, _t as OperationPath_d_exports, a as TreeNodeSnapshot, at as Optional, b as TreeNodeConfig, c as TreePrimitive, ct as Validator, d as TreeState, dt as ProxyEnvironment_d_exports, et as InferUpdateInput, f as TreeUpdateInput, g as InferTreeNodeChildren, gt as Operation_d_exports, h as AnyTreeNodePrimitive, ht as Operation, i as TreeNodeProxyBase, it as NeedsValue, j as InferLazySetInput, k as UnionVariants, l as TreeProxy, m as TypedTreeNodeState, mt as Transaction_d_exports, n as InferTreeSnapshot, nt as IsRequired, o as TreeNodeState, ot as Primitive, p as TypedNodeProxy, pt as Transaction, q as StructUpdateValue, r as TreeNodeDataSetInput, rt as MaybeUndefined, s as TreeNodeUpdateValue, st as PrimitiveInternal, t as Primitive_d_exports, tt as IsDefined, u as TreeSetInput, ut as Transform_d_exports, v as InferTreeNodeType, w as InferEitherSnapshot, x as TreeNodePrimitive, y as TreeNodeChildrenInput, z as ArraySetInput } from "./Primitive-DqQFc3Gu.mjs";
3
3
  import { Schema } from "effect";
4
4
 
5
5
  //#region src/Document.d.ts
@@ -138,6 +138,282 @@ declare function toSetSchema<T extends AnyTreeNodePrimitive>(primitive: T): ToTr
138
138
  */
139
139
  declare function toUpdateSchema<T extends AnyPrimitive>(primitive: T): ToUpdateSchema<T>;
140
140
  declare function toUpdateSchema<T extends AnyTreeNodePrimitive>(primitive: T): ToTreeNodeUpdateSchema<T>;
141
+ declare namespace index_d_exports {
142
+ export { AnyPrimitive, AnyTreeNodePrimitive, ArrayElementSetInput, ArrayEntry, ArrayEntrySnapshot, ArrayProxy, ArraySetInput, ArraySnapshot, ArrayState, ArrayUpdateInput, HasDefault, InferEitherSnapshot, InferEitherState, InferLazyProxy, InferLazySetInput, InferLazySnapshot, InferLazyState, InferLazyUpdateInput, InferProxy, InferSetInput, InferSnapshot, InferState, InferStructSnapshot, InferStructState, InferTreeNodeChildren, InferTreeNodeDataState, InferTreeNodeType, InferTreeSnapshot, InferUnionSnapshot, InferUnionState, InferUpdateInput, IsDefined, IsRequired, MaybeUndefined, NeedsValue, Optional, Primitive, PrimitiveInternal, ScalarPrimitive, StructProxy, StructSetInput, StructUpdateValue, TreeNodeChildrenInput, TreeNodeConfig, TreeNodeDataSetInput, TreeNodePrimitive, TreeNodeProxyBase, TreeNodeSelf, TreeNodeSelfType, TreeNodeSnapshot, TreeNodeState, TreeNodeUpdateValue, TreeProxy, TreeSetInput, TreeState, TreeUpdateInput, TypedNodeProxy, TypedTreeNodeState, UnionVariants, Validator };
143
+ }
144
+ declare namespace tree_helpers_d_exports {
145
+ export { FlattenedNode, NodeSearchResult, ParentSearchResult, TraverseOptions, buildNodeTypeMap, canAddChildType, findNode, findNodeById, findNodeWithPath, findNodes, flattenTree, getAllNodeTypes, getAllowedChildTypes, getAllowedChildTypesForNode, getAncestors, getDescendants, getNodeDepth, getNodePrimitive, getNodeTypeByName, getParent, getSiblings, getSubtree, isAncestorOf, isChildTypeAllowed, mapTree, traverse };
146
+ }
147
+ /**
148
+ * Result of finding a node with path information.
149
+ */
150
+ interface NodeSearchResult<TNode extends AnyTreeNodePrimitive> {
151
+ readonly node: TreeNodeSnapshot<TNode>;
152
+ readonly path: readonly string[];
153
+ readonly depth: number;
154
+ }
155
+ /**
156
+ * Result of finding a parent node.
157
+ */
158
+ interface ParentSearchResult<TNode extends AnyTreeNodePrimitive> {
159
+ readonly parent: TreeNodeSnapshot<TNode>;
160
+ readonly childIndex: number;
161
+ }
162
+ /**
163
+ * Flattened node with parent information.
164
+ */
165
+ interface FlattenedNode<TNode extends AnyTreeNodePrimitive> {
166
+ readonly node: TreeNodeSnapshot<TNode>;
167
+ readonly parentId: string | null;
168
+ readonly depth: number;
169
+ }
170
+ /**
171
+ * Options for tree traversal.
172
+ */
173
+ interface TraverseOptions {
174
+ readonly order?: "pre" | "post";
175
+ }
176
+ /**
177
+ * Find a node by ID in a tree snapshot.
178
+ *
179
+ * @param snapshot - The root tree snapshot
180
+ * @param id - The node ID to find
181
+ * @returns The node snapshot if found, undefined otherwise
182
+ */
183
+ declare function findNodeById<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, id: string): TreeNodeSnapshot<TNode> | undefined;
184
+ /**
185
+ * Find a node by ID with full path information.
186
+ *
187
+ * @param snapshot - The root tree snapshot
188
+ * @param id - The node ID to find
189
+ * @returns NodeSearchResult with node, path, and depth, or undefined if not found
190
+ */
191
+ declare function findNodeWithPath<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, id: string): NodeSearchResult<TNode> | undefined;
192
+ /**
193
+ * Get the parent node of a given node ID.
194
+ *
195
+ * @param snapshot - The root tree snapshot
196
+ * @param nodeId - The ID of the node whose parent we want
197
+ * @returns ParentSearchResult with parent node and child index, or undefined
198
+ */
199
+ declare function getParent<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, nodeId: string): ParentSearchResult<TNode> | undefined;
200
+ /**
201
+ * Get a subtree rooted at a specific node ID.
202
+ *
203
+ * @param snapshot - The root tree snapshot
204
+ * @param nodeId - The ID of the node to use as new root
205
+ * @returns The subtree snapshot, or undefined if node not found
206
+ */
207
+ declare function getSubtree<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, nodeId: string): TreeNodeSnapshot<TNode> | undefined;
208
+ /**
209
+ * Get all ancestor nodes from a node up to the root.
210
+ *
211
+ * @param snapshot - The root tree snapshot
212
+ * @param nodeId - The ID of the node
213
+ * @returns Array of ancestor snapshots from immediate parent to root, or empty array
214
+ */
215
+ declare function getAncestors<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, nodeId: string): readonly TreeNodeSnapshot<TNode>[];
216
+ /**
217
+ * Get all descendant nodes of a given node (flat array).
218
+ *
219
+ * @param snapshot - The root tree snapshot
220
+ * @param nodeId - The ID of the node (if undefined, returns all descendants of root)
221
+ * @returns Flat array of all descendant node snapshots
222
+ */
223
+ declare function getDescendants<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, nodeId?: string): readonly TreeNodeSnapshot<TNode>[];
224
+ /**
225
+ * Get siblings of a node (nodes with the same parent).
226
+ *
227
+ * @param snapshot - The root tree snapshot
228
+ * @param nodeId - The ID of the node
229
+ * @param includeSelf - Whether to include the node itself (default: false)
230
+ * @returns Array of sibling snapshots
231
+ */
232
+ declare function getSiblings<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, nodeId: string, includeSelf?: boolean): readonly TreeNodeSnapshot<TNode>[];
233
+ /**
234
+ * Find the first node matching a predicate.
235
+ *
236
+ * @param snapshot - The root tree snapshot
237
+ * @param predicate - Function to test each node
238
+ * @returns First matching node snapshot, or undefined
239
+ */
240
+ declare function findNode<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, predicate: (node: TreeNodeSnapshot<TNode>) => boolean): TreeNodeSnapshot<TNode> | undefined;
241
+ /**
242
+ * Find all nodes matching a predicate.
243
+ *
244
+ * @param snapshot - The root tree snapshot
245
+ * @param predicate - Function to test each node
246
+ * @returns Array of matching node snapshots
247
+ */
248
+ declare function findNodes<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, predicate: (node: TreeNodeSnapshot<TNode>) => boolean): readonly TreeNodeSnapshot<TNode>[];
249
+ /**
250
+ * Get the depth of a specific node (0 = root).
251
+ *
252
+ * @param snapshot - The root tree snapshot
253
+ * @param nodeId - The ID of the node
254
+ * @returns The depth, or -1 if not found
255
+ */
256
+ declare function getNodeDepth<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, nodeId: string): number;
257
+ /**
258
+ * Check if one node is an ancestor of another.
259
+ *
260
+ * @param snapshot - The root tree snapshot
261
+ * @param ancestorId - Potential ancestor node ID
262
+ * @param descendantId - Potential descendant node ID
263
+ * @returns true if ancestorId is an ancestor of descendantId
264
+ */
265
+ declare function isAncestorOf<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, ancestorId: string, descendantId: string): boolean;
266
+ /**
267
+ * Traverse the tree and call a visitor function for each node.
268
+ * Return false from visitor to stop traversal.
269
+ *
270
+ * @param snapshot - The root tree snapshot
271
+ * @param visitor - Function called for each node (return false to stop)
272
+ * @param options - Traversal options (order: 'pre' | 'post')
273
+ */
274
+ declare function traverse<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined, visitor: (node: TreeNodeSnapshot<TNode>, depth: number) => void | false, options?: TraverseOptions): void;
275
+ /**
276
+ * Flatten the tree into an array with parent information.
277
+ *
278
+ * @param snapshot - The root tree snapshot
279
+ * @returns Array of { node, parentId, depth } objects
280
+ */
281
+ declare function flattenTree<TNode extends AnyTreeNodePrimitive>(snapshot: TreeNodeSnapshot<TNode> | undefined): readonly FlattenedNode<TNode>[];
282
+ /**
283
+ * Map over all nodes in the tree, transforming each node's data.
284
+ * Preserves tree structure while transforming node content.
285
+ *
286
+ * @param snapshot - The root tree snapshot
287
+ * @param mapper - Function to transform each node
288
+ * @returns New tree structure with transformed nodes, or undefined
289
+ */
290
+ declare function mapTree<TNode extends AnyTreeNodePrimitive, R>(snapshot: TreeNodeSnapshot<TNode> | undefined, mapper: (node: TreeNodeSnapshot<TNode>, depth: number) => R): {
291
+ value: R;
292
+ children: ReturnType<typeof mapTree<TNode, R>>[];
293
+ } | undefined;
294
+ /**
295
+ * Build a lookup map from node type strings to their TreeNodePrimitive definitions.
296
+ * Useful for resolving snapshot node types back to their schema definitions.
297
+ *
298
+ * @param tree - The TreePrimitive to analyze
299
+ * @returns Map from type string to TreeNodePrimitive
300
+ *
301
+ * @example
302
+ * ```ts
303
+ * const typeMap = buildNodeTypeMap(fileTree);
304
+ * const folderPrimitive = typeMap.get("folder"); // FolderNode
305
+ * ```
306
+ */
307
+ declare function buildNodeTypeMap<TRoot extends AnyTreeNodePrimitive>(tree: TreePrimitive<TRoot>): Map<string, AnyTreeNodePrimitive>;
308
+ /**
309
+ * Get the TreeNodePrimitive definition for a snapshot node.
310
+ * Requires the tree schema to resolve the type string to its primitive.
311
+ *
312
+ * @param tree - The TreePrimitive schema
313
+ * @param snapshot - The node snapshot to get the primitive for
314
+ * @returns The TreeNodePrimitive, or undefined if not found
315
+ *
316
+ * @example
317
+ * ```ts
318
+ * const node = findNodeById(treeSnapshot, "some-id");
319
+ * const primitive = getNodePrimitive(fileTree, node);
320
+ * // primitive is FolderNode or FileNode depending on node.type
321
+ * ```
322
+ */
323
+ declare function getNodePrimitive<TRoot extends AnyTreeNodePrimitive>(tree: TreePrimitive<TRoot>, snapshot: TreeNodeSnapshot<AnyTreeNodePrimitive>): AnyTreeNodePrimitive | undefined;
324
+ /**
325
+ * Get the allowed child types for a snapshot node.
326
+ * Combines schema lookup with the node's allowed children.
327
+ *
328
+ * @param tree - The TreePrimitive schema
329
+ * @param snapshot - The node snapshot to get allowed children for
330
+ * @returns Array of allowed child TreeNodePrimitives, or empty array if not found
331
+ *
332
+ * @example
333
+ * ```ts
334
+ * const node = findNodeById(treeSnapshot, "folder-id");
335
+ * const allowedChildren = getAllowedChildTypesForNode(fileTree, node);
336
+ * // Returns [FolderNode, FileNode] if the folder can contain both
337
+ * ```
338
+ */
339
+ declare function getAllowedChildTypesForNode<TRoot extends AnyTreeNodePrimitive>(tree: TreePrimitive<TRoot>, snapshot: TreeNodeSnapshot<AnyTreeNodePrimitive>): readonly AnyTreeNodePrimitive[];
340
+ /**
341
+ * Check if a child type is allowed for a specific snapshot node.
342
+ *
343
+ * @param tree - The TreePrimitive schema
344
+ * @param parentSnapshot - The parent node snapshot
345
+ * @param childTypeName - The type string of the potential child
346
+ * @returns true if the child type is allowed
347
+ *
348
+ * @example
349
+ * ```ts
350
+ * const folder = findNodeById(treeSnapshot, "folder-id");
351
+ * canAddChildType(fileTree, folder, "file"); // true
352
+ * canAddChildType(fileTree, folder, "unknown"); // false
353
+ * ```
354
+ */
355
+ declare function canAddChildType<TRoot extends AnyTreeNodePrimitive>(tree: TreePrimitive<TRoot>, parentSnapshot: TreeNodeSnapshot<AnyTreeNodePrimitive>, childTypeName: string): boolean;
356
+ /**
357
+ * Get all allowed child node types for a specific node type.
358
+ *
359
+ * @param nodeType - The TreeNodePrimitive to get children for
360
+ * @returns Array of allowed child TreeNodePrimitives
361
+ *
362
+ * @example
363
+ * ```ts
364
+ * const FolderNode = TreeNode("folder", { ... });
365
+ * const FileNode = TreeNode("file", { ... });
366
+ *
367
+ * // Get allowed children for FolderNode
368
+ * const allowedChildren = getAllowedChildTypes(FolderNode);
369
+ * // Returns [FolderNode, FileNode] if folder can contain both
370
+ * ```
371
+ */
372
+ declare function getAllowedChildTypes<TNode extends AnyTreeNodePrimitive>(nodeType: TNode): readonly AnyTreeNodePrimitive[];
373
+ /**
374
+ * Get all unique node types reachable in a tree schema.
375
+ * Recursively traverses the tree structure starting from the root.
376
+ *
377
+ * @param tree - The TreePrimitive to analyze
378
+ * @returns Array of all unique TreeNodePrimitives in the tree schema
379
+ *
380
+ * @example
381
+ * ```ts
382
+ * const fileTree = Tree({ root: FolderNode });
383
+ * const allNodeTypes = getAllNodeTypes(fileTree);
384
+ * // Returns [FolderNode, FileNode] - all possible node types
385
+ * ```
386
+ */
387
+ declare function getAllNodeTypes<TRoot extends AnyTreeNodePrimitive>(tree: TreePrimitive<TRoot>): readonly AnyTreeNodePrimitive[];
388
+ /**
389
+ * Get the node type primitive by its type string from a tree schema.
390
+ *
391
+ * @param tree - The TreePrimitive to search
392
+ * @param typeName - The type string to find (e.g., "folder", "file")
393
+ * @returns The matching TreeNodePrimitive, or undefined if not found
394
+ *
395
+ * @example
396
+ * ```ts
397
+ * const fileTree = Tree({ root: FolderNode });
398
+ * const folderType = getNodeTypeByName(fileTree, "folder");
399
+ * // Returns FolderNode
400
+ * ```
401
+ */
402
+ declare function getNodeTypeByName<TRoot extends AnyTreeNodePrimitive>(tree: TreePrimitive<TRoot>, typeName: string): AnyTreeNodePrimitive | undefined;
403
+ /**
404
+ * Check if a child type is allowed under a parent type.
405
+ *
406
+ * @param parentType - The parent TreeNodePrimitive
407
+ * @param childTypeName - The type string of the potential child
408
+ * @returns true if the child type is allowed
409
+ *
410
+ * @example
411
+ * ```ts
412
+ * isChildTypeAllowed(FolderNode, "file"); // true if folder can contain files
413
+ * isChildTypeAllowed(FileNode, "folder"); // false - files can't have children
414
+ * ```
415
+ */
416
+ declare function isChildTypeAllowed(parentType: AnyTreeNodePrimitive, childTypeName: string): boolean;
141
417
  //#endregion
142
- export { Document_d_exports as Document, EffectSchema_d_exports as EffectSchema, Operation_d_exports as Operation, OperationPath_d_exports as OperationPath, Presence_d_exports as Presence, Primitive_d_exports as Primitive, ProxyEnvironment_d_exports as ProxyEnvironment, Transaction_d_exports as Transaction, Transform_d_exports as Transform };
418
+ export { Document_d_exports as Document, EffectSchema_d_exports as EffectSchema, Operation_d_exports as Operation, OperationPath_d_exports as OperationPath, Presence_d_exports as Presence, type Primitive_d_exports as Primitive, ProxyEnvironment_d_exports as ProxyEnvironment, Transaction_d_exports as Transaction, Transform_d_exports as Transform, tree_helpers_d_exports as TreeHelpers, index_d_exports as Types };
143
419
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/Document.ts","../src/EffectSchema.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;cAaa,sBAAA,SAA+B,KAAA;;;;;;;AAA/B,cAWA,cAAA,SAAuB,KAAA,CAXa;EAWpC,SAAA,IAAA,GAAA,gBAAuB;EAenB,WAAQ,CAAA,OAAA,EAAA,MAAA;;;;;AAQK,UARb,QAQa,CAAA,gBARY,YAQZ,CAAA,CAAA;EAArB;EAQ+B,SAAA,MAAA,EAdrB,OAcqB;EAAxB;EAQiC,SAAA,IAAA,EAnBhC,UAmBgC,CAnBX,OAmBW,CAAA;EAArB;EAAkC,GAAA,EAAA,EAhBrD,UAgBqD,CAhBhC,OAgBgC,CAAA,GAAA,SAAA;EAAI;;;;;AAkBlE;EAAiD,UAAA,EAAA,EA1BjC,aA0BiC,CA1BT,OA0BS,CAAA;EAEP;;;AAU1C;;;EAE4B,WAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,IAAA,EAhCA,UAgCA,CAhCqB,OAgCrB,CAAA,EAAA,GAhCkC,CAgClC,CAAA,EAhCsC,CAgCtC;EAAhB;;;;aA1BC,cAAc;;;;WAKhB;;UAOM,gCAAgC;;qBAE5B,WAAqB;;;;AC7D1C;AAAkC,cDuErB,ICvEqB,EAAA,CAAA,gBDuEG,YCvEH,CAAA,CAAA,MAAA,EDwExB,OCxEwB,EAAA,OAAA,CAAA,EDyEtB,eCzEsB,CDyEN,OCzEM,CAAA,EAAA,GD0E/B,QC1E+B,CD0EtB,OC1EsB,CAAA;AAAA;;;;;;KAAtB,sBAAsB,gBAAgB,MAAA,CAAO,OAAO,cAAc;;ADT9E;AAWA;AAeiB,KCZL,cDYa,CAAA,UCZY,YDYZ,CAAA,GCZ4B,MAAA,CAAO,MDYnC,CCZ0C,gBDY1C,CCZ2D,CD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