@homedev/objector 1.2.61 → 1.2.63

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.
@@ -0,0 +1,751 @@
1
+ declare const AsyncFunction_2: FunctionConstructor;
2
+ export { AsyncFunction_2 as AsyncFunction }
3
+
4
+ /**
5
+ * Maps an array asynchronously using Promise.all for parallel execution
6
+ * @typeParam T - Type of input array items
7
+ * @typeParam U - Type of async result items
8
+ * @param arr - Array to map
9
+ * @param fn - Async mapping function
10
+ * @returns Promise of mapped array
11
+ * @public
12
+ */
13
+ export declare const asyncMap: <T, U>(arr: T[], fn: (item: T, index: number, array: T[]) => Promise<U>) => Promise<U[]>;
14
+
15
+ /**
16
+ * Converts a string to camelCase (lowerCamelCase).
17
+ * Handles spaces, underscores, and hyphens as word separators.
18
+ *
19
+ * @example
20
+ * camel('hello_world') // 'helloWorld'
21
+ * camel('hello world') // 'helloWorld'
22
+ * camel('HelloWorld') // 'helloWorld'
23
+ *
24
+ * @param v - The string to convert
25
+ * @returns The string in camelCase
26
+ */
27
+ export declare const camel: (v: string) => string;
28
+
29
+ /**
30
+ * Converts a string to Capital Case (each word capitalized, spaces preserved).
31
+ * Only capitalizes words following spaces.
32
+ *
33
+ * @example
34
+ * capital('hello world') // 'Hello World'
35
+ * capital('hello_world') // 'hello_World'
36
+ *
37
+ * @param v - The string to convert
38
+ * @returns The string with each space-separated word capitalized
39
+ */
40
+ export declare const capital: (v: string) => string;
41
+
42
+ /**
43
+ * Changes the case of a string to uppercase, lowercase, or returns unchanged.
44
+ *
45
+ * @example
46
+ * changeCase('Hello', 'upper') // 'HELLO'
47
+ * changeCase('Hello', 'lower') // 'hello'
48
+ * changeCase('Hello') // 'Hello'
49
+ *
50
+ * @param v - The string to transform
51
+ * @param arg - The case type: 'upper', 'lower', or undefined to return unchanged
52
+ * @returns The transformed string
53
+ */
54
+ export declare const changeCase: (v: string, arg?: string) => string;
55
+
56
+ /**
57
+ * @public
58
+ */
59
+ export declare const conditionPredicates: Record<string, (...args: any[]) => boolean>;
60
+
61
+ export declare const decoder: (options?: DecoderOptions) => (_: any, ctx: ClassMethodDecoratorContext<ObjectorPlugin, (data: string) => unknown>) => void;
62
+
63
+ declare type DecoderOptions = ObjectorDecoratorOptions;
64
+
65
+ /**
66
+ * Deep clones an object using structuredClone (faster) with JSON fallback
67
+ * - Uses structuredClone for better performance and broader type support (Date, RegExp, etc.)
68
+ * - Falls back to JSON serialization if structuredClone fails or is unavailable
69
+ * - Note: Functions, symbols, and undefined values are lost in JSON fallback
70
+ * @typeParam T - Type of object to clone
71
+ * @param model - Object to clone
72
+ * @returns Deep clone of the object
73
+ * @public
74
+ */
75
+ export declare const deepClone: <T>(model: T) => T;
76
+
77
+ /**
78
+ * Asserts that a value is defined, throwing an error if undefined
79
+ * @typeParam T - Type of the value
80
+ * @param value - Value to check
81
+ * @param msg - Error message to throw if value is undefined or null
82
+ * @returns The value if defined
83
+ * @throws Error if value is undefined
84
+ * @public
85
+ */
86
+ export declare const defined: <T>(value: T | undefined | null, msg?: string) => T;
87
+
88
+ declare interface Encoder {
89
+ fn: (data: unknown, ...args: any[]) => string | Promise<string>;
90
+ options?: EncoderOptions;
91
+ }
92
+
93
+ export declare const encoder: (options?: EncoderOptions_2) => (_: any, ctx: ClassMethodDecoratorContext<ObjectorPlugin, (data: unknown) => string | Promise<string>>) => void;
94
+
95
+ declare interface EncoderOptions {
96
+ includeTags?: boolean;
97
+ }
98
+
99
+ declare type EncoderOptions_2 = ObjectorDecoratorOptions;
100
+
101
+ export declare const exists: (fileName: string) => Promise<boolean>;
102
+
103
+ export declare interface FieldContext {
104
+ path: string;
105
+ root: any;
106
+ options: ProcessFieldsOptions;
107
+ value: string | object | number | NavigateResult | null;
108
+ key: string;
109
+ args: any[];
110
+ rawArgs: {
111
+ value: string;
112
+ quoted: boolean;
113
+ }[];
114
+ tags: Record<string, string[]>;
115
+ parent?: any;
116
+ }
117
+
118
+ export declare interface FieldProcessor {
119
+ fn: FieldProcessorFunc;
120
+ options: FieldProcessorOptions;
121
+ }
122
+
123
+ export declare type FieldProcessorFunc = (context: FieldContext) => any;
124
+
125
+ export declare type FieldProcessorMap = Record<string, FieldProcessorTypedFunc>;
126
+
127
+ export declare interface FieldProcessorOptions {
128
+ filters?: RegExp[];
129
+ processArgs?: boolean;
130
+ types?: Record<number, string | any[] | ((value: string, root: any, index: number, quoted: boolean) => any)> | FieldProcessorTypeChecker;
131
+ }
132
+
133
+ export declare interface FieldProcessorSection {
134
+ config: Record<string, any>;
135
+ content: string;
136
+ trim?: boolean;
137
+ indent?: number;
138
+ show?: boolean;
139
+ }
140
+
141
+ export declare type FieldProcessorSectionConfigFunc = (context: FieldProcessorSectionContext) => Promise<boolean | void> | boolean | void;
142
+
143
+ export declare interface FieldProcessorSectionContext {
144
+ section: FieldProcessorSection;
145
+ content: string;
146
+ path: string;
147
+ root: Record<string, any>;
148
+ options: ProcessFieldsOptions;
149
+ }
150
+
151
+ export declare type FieldProcessorSectionFunc = (context: FieldProcessorSectionContext) => Promise<void | boolean | string> | void | boolean | string;
152
+
153
+ export declare type FieldProcessorSectionMap = Record<string, FieldProcessorSectionFunc>;
154
+
155
+ export declare type FieldProcessorTypeChecker = (n: number, value: any, args: any[]) => any;
156
+
157
+ export declare type FieldProcessorTypeCheckers<T = unknown> = Record<keyof T, FieldProcessorTypeChecker>;
158
+
159
+ export declare type FieldProcessorTypedFunc = FieldProcessorFunc | (FieldProcessorOptions & {
160
+ fn: FieldProcessorFunc;
161
+ });
162
+
163
+ declare interface FilePatternOptions {
164
+ cwd: string;
165
+ filter?: (fileName: string, index: number, array: string[]) => boolean;
166
+ map: (fileName: string, index: number, array: string[]) => Promise<any>;
167
+ }
168
+
169
+ /**
170
+ * Finds values in an object tree that match a predicate function.
171
+ *
172
+ * @public
173
+ * @param from - The object to search through
174
+ * @param cb - Predicate function that receives the path and value, returns true for matches
175
+ * @returns Array of matching values
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * const obj = { a: { b: 1 }, c: { d: 2 } }
180
+ * const results = await find(obj, (path, value) => value === 2)
181
+ * // results: [2]
182
+ * ```
183
+ */
184
+ export declare const find: (from: any, cb: (path: string, value: any) => boolean) => Promise<any[]>;
185
+
186
+ export declare const globMap: <T>(pattern: string | string[], options: FilePatternOptions) => Promise<T[] | T>;
187
+
188
+ /**
189
+ * @public
190
+ */
191
+ export declare const importGlob: (patterns: string[], options?: ImportOptions) => Promise<any[]>;
192
+
193
+ /**
194
+ * @public
195
+ */
196
+ export declare const importList: (modules: string[], options?: ImportOptions) => Promise<any[]>;
197
+
198
+ /**
199
+ * @public
200
+ */
201
+ export declare interface ImportOptions {
202
+ cwd?: string;
203
+ resolveDefault?: boolean | 'only';
204
+ filter?: (name: string) => boolean | undefined;
205
+ fail?: (name: string, error: any) => boolean | undefined;
206
+ map?: (module: any, name: string) => any;
207
+ }
208
+
209
+ export declare const key: (options?: KeyOptions) => (_: any, ctx: ClassMethodDecoratorContext<ObjectorPlugin, (value: any) => any>) => void;
210
+
211
+ declare type KeyOptions = ObjectorDecoratorOptions;
212
+
213
+ /**
214
+ * @public
215
+ */
216
+ export declare interface LoadContext {
217
+ included: string[];
218
+ document: unknown;
219
+ }
220
+
221
+ /**
222
+ * @public
223
+ * @param fileName
224
+ * @param options
225
+ * @returns
226
+ */
227
+ export declare const loadFormat: <T = any>(fileName: string, options?: LoadOptions) => Promise<LoadResult<T>>;
228
+
229
+ /**
230
+ * @public
231
+ */
232
+ export declare interface LoadFormatParser {
233
+ matching?: string[];
234
+ fn: (data: string) => any;
235
+ }
236
+
237
+ /**
238
+ * @public
239
+ */
240
+ export declare interface LoadObjectOptions {
241
+ fileName: string;
242
+ fullPath: string;
243
+ folderPath: string;
244
+ }
245
+
246
+ /**
247
+ * @public
248
+ */
249
+ export declare interface LoadOptions {
250
+ dirs?: string[];
251
+ parsers?: Record<string, LoadFormatParser>;
252
+ format?: string;
253
+ }
254
+
255
+ export declare interface LoadResult<T> {
256
+ fullPath: string;
257
+ folderPath: string;
258
+ content: T;
259
+ }
260
+
261
+ export declare const locate: (fileName: string, dirs?: string[]) => Promise<string>;
262
+
263
+ export declare type LogFunction = (className: string, ...args: any[]) => void;
264
+
265
+ export declare class Logger {
266
+ options: LoggerOptions;
267
+ constructor(options?: Partial<LoggerOptions>);
268
+ write(className: string, ...args: any[]): void;
269
+ info(...args: any[]): void;
270
+ error(...args: any[]): void;
271
+ warn(...args: any[]): void;
272
+ debug(...args: any[]): void;
273
+ verbose(...args: any[]): void;
274
+ }
275
+
276
+ export declare interface LoggerOptions {
277
+ level: string;
278
+ showClass: boolean;
279
+ levels: string[];
280
+ timeStamp: boolean;
281
+ timeLocale?: string;
282
+ timeOptions?: Intl.DateTimeFormatOptions;
283
+ logFunction: LogFunction;
284
+ }
285
+
286
+ export declare const macro: (options?: MacroOptions) => (_: any, ctx: ClassMethodDecoratorContext<ObjectorPlugin, (...args: any[]) => any>) => void;
287
+
288
+ declare type MacroOptions = ObjectorDecoratorOptions;
289
+
290
+ export declare const makeFieldProcessor: (fn: SourceFunc, types?: FieldProcessorTypeChecker) => FieldProcessorTypedFunc;
291
+
292
+ export declare const makeFieldProcessorList: <T = unknown>(source: SourceFunc[], options?: {
293
+ types?: FieldProcessorTypeCheckers<T>;
294
+ }) => FieldProcessorMap;
295
+
296
+ export declare const makeFieldProcessorMap: <T = unknown>(source: Record<keyof T, SourceFunc>, options?: {
297
+ types?: FieldProcessorTypeCheckers<T>;
298
+ keys?: (keyof T)[];
299
+ }) => FieldProcessorMap;
300
+
301
+ /**
302
+ * @public
303
+ * @param source
304
+ * @param target
305
+ * @param options
306
+ */
307
+ export declare const merge: (source: any, target: any, options?: MergeOptions) => void;
308
+
309
+ /**
310
+ * @public
311
+ * @param elements
312
+ * @param options
313
+ */
314
+ export declare const mergeAll: (elements: any[], options?: MergeOptions) => any;
315
+
316
+ /**
317
+ * @public
318
+ */
319
+ export declare type MergeMode = 'merge' | 'source' | 'target' | 'skip';
320
+
321
+ /**
322
+ * @public
323
+ */
324
+ export declare interface MergeOptions {
325
+ conflict?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => any;
326
+ mismatch?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => any;
327
+ navigate?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => boolean | undefined;
328
+ mode?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => MergeMode | void;
329
+ }
330
+
331
+ /**
332
+ * Recursively navigates through an object tree, invoking a callback for each property.
333
+ * Supports various actions like replacing, deleting, or merging values during traversal.
334
+ * Includes circular reference detection to prevent infinite loops.
335
+ *
336
+ * Performance optimizations:
337
+ * - Caches static NavigateResult instances
338
+ * - Uses WeakSet for O(1) circular reference detection
339
+ * - Avoids Object.entries() to prevent array allocations
340
+ * - Optimizes switch statement order for common cases
341
+ *
342
+ * @public
343
+ * @param o - The object to navigate
344
+ * @param cb - Callback function invoked for each property
345
+ * @throws {Error} When attempting to replace the root object
346
+ */
347
+ export declare const navigate: (o: any, cb: NavigateCallback) => Promise<void>;
348
+
349
+ /**
350
+ * @public
351
+ */
352
+ export declare enum NavigateAction {
353
+ Explore = 0,
354
+ SkipSiblings = 1,
355
+ NoExplore = 2,
356
+ ReplaceParent = 3,
357
+ DeleteParent = 4,
358
+ MergeParent = 5,
359
+ ReplaceItem = 6,
360
+ DeleteItem = 7
361
+ }
362
+
363
+ /**
364
+ * @public
365
+ */
366
+ export declare type NavigateCallback = (context: NavigateContext) => Promise<NavigateResult> | NavigateResult;
367
+
368
+ /**
369
+ * @public
370
+ */
371
+ export declare interface NavigateContext {
372
+ key: string;
373
+ value: any;
374
+ path: string[];
375
+ parent: any;
376
+ parents: any[];
377
+ }
378
+
379
+ /**
380
+ * @public
381
+ */
382
+ export declare class NavigateResult {
383
+ readonly action: NavigateAction;
384
+ by?: any | undefined;
385
+ skipSiblings?: boolean | undefined;
386
+ reexplore?: boolean | undefined;
387
+ constructor(action: NavigateAction, by?: any | undefined, skipSiblings?: boolean | undefined, reexplore?: boolean | undefined);
388
+ private static readonly _explore;
389
+ private static readonly _noExplore;
390
+ private static readonly _skipSiblings;
391
+ private static readonly _deleteParent;
392
+ static ReplaceParent(by: any, reexplore?: boolean): NavigateResult;
393
+ static SkipSiblings(): NavigateResult;
394
+ static Explore(): NavigateResult;
395
+ static NoExplore(): NavigateResult;
396
+ static DeleteParent(): NavigateResult;
397
+ static MergeParent(by: any): NavigateResult;
398
+ static ReplaceItem(by: any, skipSiblings?: boolean): NavigateResult;
399
+ static DeleteItem(skipSiblings?: boolean): NavigateResult;
400
+ }
401
+
402
+ /**
403
+ * Maps an array while filtering out null/undefined values (performance optimized)
404
+ * Combines filter and map operations to avoid double iteration
405
+ * @typeParam T - Type of input array items
406
+ * @typeParam U - Type of mapped result items
407
+ * @param arr - Array to map (can be undefined)
408
+ * @param fn - Mapping function
409
+ * @returns Mapped array with nulls/undefined filtered out, or empty array if input is undefined
410
+ * @public
411
+ */
412
+ export declare const nonNullMap: <T, U>(arr: T[] | undefined, fn: (item: T, index: number, array: T[]) => U) => U[];
413
+
414
+ /**
415
+ * @public
416
+ */
417
+ export declare class Objector {
418
+ private includeManager;
419
+ private includeProcessor;
420
+ private cacheManager;
421
+ private outputs;
422
+ private vars;
423
+ private funcs;
424
+ private fields;
425
+ private objectMetadata;
426
+ private currentContext;
427
+ private storedSections;
428
+ private dataEncoders;
429
+ private dataDecoders;
430
+ constructor();
431
+ use(handler: ObjectorPluginConstructor | ObjectorPluginFunction): this;
432
+ includeDirectory(...dirs: string[]): this;
433
+ getIncludeDirectories(): string[];
434
+ include(...files: string[]): this;
435
+ keys(keys: FieldProcessorMap): this;
436
+ sources(sources: FieldProcessorMap): this;
437
+ sections(sections: Record<string, FieldProcessorSectionFunc>): this;
438
+ variables(vars: Record<string, unknown>): this;
439
+ functions(funcs: Record<string, AsyncFunction>): this;
440
+ getFunctions(): Record<string, AsyncFunction>;
441
+ getOutputs(): Output[];
442
+ output(o: Output): this;
443
+ metadata(path: string, o: unknown): this;
444
+ getMetadata(path: string): unknown;
445
+ getAllMetadata(): Record<string, unknown>;
446
+ setCacheMaxSize(size: number): this;
447
+ clearCache(): this;
448
+ getCurrentContext(): LoadContext | null;
449
+ fieldOptions(options: ProcessFieldsOptions): this;
450
+ section(section: FieldProcessorSection): this;
451
+ getSection(name: string): FieldProcessorSection | undefined;
452
+ encoders(encoders: Record<string, Encoder>): this;
453
+ decoders(decoders: Record<string, LoadFormatParser>): this;
454
+ getEncoder(name: string): Encoder | undefined;
455
+ getDecoder(name: string): LoadFormatParser | undefined;
456
+ filter(f: RegExp): this;
457
+ loadObject<T = any>(data: T, container?: any, options?: LoadObjectOptions): Promise<T>;
458
+ load<T = unknown>(fileName: string, cwd?: string, container?: unknown, noProcess?: boolean, ld?: LoadContext): Promise<T | null>;
459
+ writeAll(option?: WriteOutputsOption): Promise<void>;
460
+ }
461
+
462
+ declare interface ObjectorDecoratorOptions {
463
+ name?: string;
464
+ }
465
+
466
+ export declare class ObjectorPlugin {
467
+ protected readonly o: Objector;
468
+ protected readonly context: {
469
+ path: string;
470
+ root: any;
471
+ options: ProcessFieldsOptions;
472
+ value?: string | object | number | null;
473
+ key?: string;
474
+ args?: any[];
475
+ rawArgs?: {
476
+ value: string;
477
+ quoted: boolean;
478
+ }[];
479
+ tags?: Record<string, string[]>;
480
+ parent?: any;
481
+ config?: Record<string, any>;
482
+ };
483
+ constructor(o: Objector);
484
+ }
485
+
486
+ export declare type ObjectorPluginConstructor = new (o: Objector, ...args: any[]) => ObjectorPlugin;
487
+
488
+ declare type ObjectorPluginFunction = (o: Objector) => void;
489
+
490
+ export declare interface Output {
491
+ name: string;
492
+ type?: 'json' | 'yaml' | 'text';
493
+ value: any;
494
+ class?: string;
495
+ }
496
+
497
+ /**
498
+ * Adds indentation to each line of a string.
499
+ * Useful for formatting multi-line text with consistent indentation.
500
+ *
501
+ * @example
502
+ * padBlock('hello\\nworld', 2) // ' hello\\n world'
503
+ * padBlock('a|b|c', 1, '|', '-') // '-a|-b|-c'
504
+ *
505
+ * @param str - The string to indent
506
+ * @param indent - The number of padding units to add
507
+ * @param separator - The separator between lines (default: '\\n')
508
+ * @param padder - The character to repeat for padding (default: ' ')
509
+ * @returns The indented string
510
+ */
511
+ export declare const padBlock: (str: string, indent: number, separator?: string, padder?: string) => string;
512
+
513
+ /**
514
+ * Converts a string to PascalCase (UpperCamelCase).
515
+ * Handles spaces, underscores, and hyphens as word separators.
516
+ *
517
+ * @example
518
+ * pascal('hello_world') // 'HelloWorld'
519
+ * pascal('hello world') // 'HelloWorld'
520
+ * pascal('helloWorld') // 'HelloWorld'
521
+ *
522
+ * @param v - The string to convert
523
+ * @returns The string in PascalCase
524
+ */
525
+ export declare const pascal: (v: string) => string;
526
+
527
+ /**
528
+ * @public
529
+ * @param obj
530
+ * @param options
531
+ * @returns
532
+ */
533
+ export declare const processFields: (obj: any, options?: ProcessFieldsOptions) => Promise<any>;
534
+
535
+ export declare interface ProcessFieldsOptions {
536
+ sources?: FieldProcessorMap;
537
+ keys?: FieldProcessorMap;
538
+ sections?: FieldProcessorSectionMap;
539
+ filters?: RegExp[];
540
+ root?: Record<any, any>;
541
+ globalContext?: any;
542
+ onSection?: FieldProcessorSectionFunc;
543
+ onSectionConfig?: FieldProcessorSectionConfigFunc;
544
+ configParser?: (configText: string) => any;
545
+ }
546
+
547
+ export declare const section: (options?: SectionOptions) => (_: any, ctx: ClassMethodDecoratorContext<ObjectorPlugin, (section: FieldProcessorSection) => any>) => void;
548
+
549
+ declare type SectionOptions = ObjectorDecoratorOptions;
550
+
551
+ /**
552
+ * Selects a value from a nested object using a path string with advanced querying capabilities
553
+ *
554
+ * Supports:
555
+ * - Dot notation: 'user.profile.name'
556
+ * - Array indexing: 'users.0' or 'users[0]'
557
+ * - Array filtering: 'users.[name=John].age'
558
+ * - References: 'users.\{activeUserId\}.name'
559
+ * - Optional paths: 'user.profile?.bio'
560
+ * - Default values: 'config.timeout?=5000'
561
+ *
562
+ * @public
563
+ * @param from - The root object to select from
564
+ * @param path - The path string to navigate
565
+ * @param options - Optional configuration
566
+ * @returns The selected value or undefined
567
+ *
568
+ * @example
569
+ * ```typescript
570
+ * const obj = { user: { name: 'Alice', age: 30 } }
571
+ * select(obj, 'user.name') // 'Alice'
572
+ * select(obj, 'user.email', { defaultValue: 'N/A' }) // 'N/A'
573
+ * ```
574
+ */
575
+ export declare const select: <T = any>(from: any, path: string, options?: SelectOptions) => T | undefined;
576
+
577
+ /**
578
+ * Options for configuring the select function behavior
579
+ * @public
580
+ */
581
+ export declare interface SelectOptions {
582
+ /** Value to set at the selected path */
583
+ set?: any;
584
+ /** Alternative key to use (currently unused) */
585
+ key?: string;
586
+ /** Path separator character (default: '.') */
587
+ separator?: string;
588
+ /** Default value to return when path is not found */
589
+ defaultValue?: any;
590
+ /** If true, returns undefined instead of throwing on missing paths */
591
+ optional?: boolean;
592
+ }
593
+
594
+ export declare const sharedFunction: (options?: SharedFunctionOptions) => (_: any, ctx: ClassMethodDecoratorContext<ObjectorPlugin, (...args: any[]) => any>) => void;
595
+
596
+ declare type SharedFunctionOptions = ObjectorDecoratorOptions;
597
+
598
+ /**
599
+ * Converts a string to snake_case or custom_case.
600
+ * Inserts the separator between lowercase and uppercase characters.
601
+ *
602
+ * @example
603
+ * snake('helloWorld', '_') // 'hello_world'
604
+ * snake('HelloWorld', '-') // 'hello-world'
605
+ * snake('hello world', '_') // 'hello_world'
606
+ *
607
+ * @param v - The string to convert
608
+ * @param separator - The separator to use between words (default: '_')
609
+ * @returns The string in snake case with the specified separator
610
+ */
611
+ export declare const snake: (v: string, separator?: string) => string;
612
+
613
+ /**
614
+ * Sorts an array by a selector function with custom comparison
615
+ * Uses a shallow copy to avoid mutating the original array
616
+ * @typeParam T - Type of array items
617
+ * @typeParam U - Type of comparison values
618
+ * @param arr - Array to sort
619
+ * @param selector - Function to extract comparison value from item
620
+ * @param compare - Comparison function (default: numeric comparison)
621
+ * @returns New sorted array
622
+ * @public
623
+ */
624
+ export declare const sortBy: <T, U>(arr: T[], selector: (item: T) => U, compare?: (a: U, b: U) => number) => T[];
625
+
626
+ declare type SourceFunc = (...args: any[]) => any;
627
+
628
+ export declare const splitNested: (str: string, separator: string, open?: string, close?: string) => string[];
629
+
630
+ /**
631
+ * Splits a string by a separator while respecting quoted values.
632
+ * Quoted values can contain the separator without being split.
633
+ * Supports both single (') and double (") quotes.
634
+ *
635
+ * @param input - The string to split
636
+ * @param separator - Single or multi-character separator (default: ',')
637
+ * @returns Array of objects with value and quoted status
638
+ *
639
+ * @example
640
+ * splitWithQuotes('hello, "world", test')
641
+ * // Returns: [
642
+ * // { value: 'hello', quoted: false },
643
+ * // { value: 'world', quoted: true },
644
+ * // { value: 'test', quoted: false }
645
+ * // ]
646
+ *
647
+ * @example
648
+ * splitWithQuotes('a:: "b:: c":: d', '::')
649
+ * // Returns: [
650
+ * // { value: 'a', quoted: false },
651
+ * // { value: 'b:: c', quoted: true },
652
+ * // { value: 'd', quoted: false }
653
+ * // ]
654
+ */
655
+ export declare const splitWithQuotes: (input: string, separator?: string) => {
656
+ value: string;
657
+ quoted: boolean;
658
+ }[];
659
+
660
+ export declare const stripIndent: (value: string) => string;
661
+
662
+ /**
663
+ * Replaces tokens in a string with values from an object.
664
+ * Tokens are in the format `$\{key\}`.
665
+ *
666
+ * @example
667
+ * tokenize('Hello $\{name\}', { name: 'World' }) // 'Hello World'
668
+ * tokenize('$\{greeting\} $\{name\}!', { greeting: 'Hi', name: 'Alice' }) // 'Hi Alice!'
669
+ * tokenize('$\{missing\}', {}) // ''
670
+ *
671
+ * @param str - The string containing tokens
672
+ * @param from - An object with key-value pairs for token replacement
673
+ * @param tokenizer - The regex pattern for token matching (default: `/\$\{([^}]+)\}/g`)
674
+ * @returns The string with tokens replaced by values from the object
675
+ */
676
+ export declare const tokenize: (str: string, from: Record<string, unknown>, tokenizer?: RegExp) => string;
677
+
678
+ /**
679
+ * Converts an object's entries into an array of objects with a key property
680
+ * @typeParam T - The type of items in the resulting array
681
+ * @param from - Object to convert
682
+ * @param key - Property name to use for keys (default: 'name')
683
+ * @returns Array of objects with key properties
684
+ * @example
685
+ * toList({ a: { value: 1 }, b: { value: 2 } }) // [{ name: 'a', value: 1 }, { name: 'b', value: 2 }]
686
+ * @public
687
+ */
688
+ export declare const toList: <T>(from: Record<string, unknown>, key?: string) => T[];
689
+
690
+ /**
691
+ * Converts an array into an object indexed by a key property, excluding the key from items
692
+ * @typeParam T - The type of the resulting object values
693
+ * @param from - Array to convert
694
+ * @param key - Property name to use as key (default: 'name')
695
+ * @returns Object indexed by key values, without the key property in values
696
+ * @example
697
+ * toObject([{ name: 'a', value: 1 }]) // { a: { value: 1 } }
698
+ * @public
699
+ */
700
+ export declare const toObject: <T extends Record<string, unknown>>(from: T[], key?: string) => Record<string, Omit<T, typeof key>>;
701
+
702
+ /**
703
+ * Converts an array into an object indexed by a key property, keeping the full items
704
+ * @typeParam T - The type of the resulting object
705
+ * @param from - Array to convert
706
+ * @param key - Property name to use as key (default: 'name')
707
+ * @returns Object indexed by key values
708
+ * @example
709
+ * toObjectWithKey([{ name: 'a', value: 1 }]) // { a: { name: 'a', value: 1 } }
710
+ * @public
711
+ */
712
+ export declare const toObjectWithKey: <T extends Record<string, unknown>>(from: T[], key?: string) => Record<string, T>;
713
+
714
+ export declare const variable: (options?: VariableOptions) => (_: any, ctx: ClassFieldDecoratorContext<ObjectorPlugin, any>) => void;
715
+
716
+ declare type VariableOptions = ObjectorDecoratorOptions;
717
+
718
+ export declare const writeFormat: (filePath: string, content: any, options?: WriteFormatOptions) => Promise<void>;
719
+
720
+ /**
721
+ * @public
722
+ */
723
+ export declare interface WriteFormatEncoder {
724
+ matching?: string[];
725
+ fn: (data: any) => Promise<string> | string;
726
+ }
727
+
728
+ /**
729
+ * @public
730
+ */
731
+ export declare interface WriteFormatOptions {
732
+ format: string;
733
+ encoders?: Record<string, WriteFormatEncoder>;
734
+ }
735
+
736
+ export declare const writeOutput: (o: Output, options?: WriteOutputOption) => Promise<void>;
737
+
738
+ export declare interface WriteOutputOption {
739
+ targetDirectory?: string;
740
+ writing?: (output: Output) => boolean | undefined | void;
741
+ classes?: string[];
742
+ classRequired?: boolean;
743
+ }
744
+
745
+ export declare const writeOutputs: (outputs: Output[], options?: WriteOutputsOption) => Promise<void>;
746
+
747
+ export declare interface WriteOutputsOption extends WriteOutputOption {
748
+ removeFirst?: boolean;
749
+ }
750
+
751
+ export { }
package/dist/index.js CHANGED
@@ -1,23 +1,23 @@
1
- var Ar=Object.create;var{getPrototypeOf:ro,defineProperty:Q,getOwnPropertyNames:Er,getOwnPropertyDescriptor:to}=Object,Qe=Object.prototype.hasOwnProperty;function Xe(e){return this[e]}var R=(e,r,t)=>{var n=Er(r);for(let o of n)if(!Qe.call(e,o)&&o!=="default")Q(e,o,{get:Xe.bind(r,o),enumerable:!0});if(t){for(let o of n)if(!Qe.call(t,o)&&o!=="default")Q(t,o,{get:Xe.bind(r,o),enumerable:!0});return t}},no,oo,io=(e,r,t)=>{var n=e!=null&&typeof e==="object";if(n){var o=r?no??=new WeakMap:oo??=new WeakMap,i=o.get(e);if(i)return i}t=e!=null?Ar(ro(e)):{};let l=r||!e||!e.__esModule?Q(t,"default",{value:e,enumerable:!0}):t;for(let a of Er(e))if(!Qe.call(l,a))Q(l,a,{get:Xe.bind(e,a),enumerable:!0});if(n)o.set(e,l);return l};var so=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),br=(e,r)=>{return Object.defineProperty(e,"name",{value:r,enumerable:!1,configurable:!0}),e},ao=(e)=>e;function lo(e,r){this[e]=ao.bind(null,r)}var W=(e,r)=>{for(var t in r)Q(e,t,{get:r[t],enumerable:!0,configurable:!0,set:lo.bind(r,t)})};var Mr=(e,r)=>(r=Symbol[e])?r:Symbol.for("Symbol."+e),ae=(e)=>{throw TypeError(e)},uo=(e,r,t)=>(r in e)?Q(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var Ve=(e,r,t)=>r.has(e)||ae("Cannot "+t),po=(e,r)=>Object(r)!==r?ae('Cannot use the "in" operator on this value'):e.has(r),Or=(e,r,t)=>(Ve(e,r,"read from private field"),t?t.call(e):r.get(e));var vr=(e,r,t,n)=>(Ve(e,r,"write to private field"),n?n.call(e,t):r.set(e,t),t),fo=(e,r,t)=>(Ve(e,r,"access private method"),t),Sr=(e)=>[,,,Ar(e?.[Mr("metadata")]??null)],jr=["class","method","getter","setter","accessor","field","value","get","set"],se=(e)=>e!==void 0&&typeof e!=="function"?ae("Function expected"):e,co=(e,r,t,n,o)=>({kind:jr[e],name:r,metadata:n,addInitializer:(i)=>t._?ae("Already initialized"):o.push(se(i||null))}),Ze=(e,r)=>uo(r,Mr("metadata"),e[3]),kr=(e,r,t,n)=>{for(var o=0,i=e[r>>1],l=i&&i.length;o<l;o++)r&1?i[o].call(t):n=i[o].call(t,n);return n},m=(e,r,t,n,o,i)=>{var l,a,p,h,O,y=r&7,u=!!(r&8),d=!!(r&16),A=y>3?e.length+1:y?u?1:2:0,g=jr[y+5],v=y>3&&(e[A-1]=[]),f=e[A]||(e[A]=[]),j=y&&(!d&&!u&&(o=o.prototype),y<5&&(y>3||!d)&&to(y<4?o:{get[t](){return Or(this,i)},set[t](S){vr(this,i,S)}},t));y?d&&y<4&&br(i,(y>2?"set ":y>1?"get ":"")+t):br(o,t);for(var b=n.length-1;b>=0;b--){if(h=co(y,t,p={},e[3],f),y){if(h.static=u,h.private=d,O=h.access={has:d?(S)=>po(o,S):(S)=>(t in S)},y^3)O.get=d?(S)=>(y^1?Or:fo)(S,o,y^4?i:j.get):(S)=>S[t];if(y>2)O.set=d?(S,k)=>vr(S,o,k,y^4?i:j.set):(S,k)=>S[t]=k}if(a=(0,n[b])(y?y<4?d?i:j[g]:y>4?void 0:{get:j.get,set:j.set}:o,h),p._=1,y^4||a===void 0)se(a)&&(y>4?v.unshift(a):y?d?i=a:j[g]=a:o=a);else if(typeof a!=="object"||a===null)ae("Object expected");else se(l=a.get)&&(j.get=l),se(l=a.set)&&(j.set=l),se(l=a.init)&&v.unshift(l)}return y||Ze(e,o),j&&Q(o,t,j),d?y^4?i:j:o};var Rt=so((pl,Ft)=>{var{defineProperty:hr,getOwnPropertyNames:ci,getOwnPropertyDescriptor:mi}=Object,gi=Object.prototype.hasOwnProperty,kt=new WeakMap,yi=(e)=>{var r=kt.get(e),t;if(r)return r;if(r=hr({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function")ci(e).map((n)=>!gi.call(r,n)&&hr(r,n,{get:()=>e[n],enumerable:!(t=mi(e,n))||t.enumerable}));return kt.set(e,r),r},di=(e,r)=>{for(var t in r)hr(e,t,{get:r[t],enumerable:!0,configurable:!0,set:(n)=>r[t]=()=>n})},Dt={};di(Dt,{splitWithQuotes:()=>hi,splitNested:()=>wi});Ft.exports=yi(Dt);var wi=(e,r,t="(",n=")")=>{let o=0,i="",l=[];for(let a of e){if(i+=a,a===t)o++;if(a===n)o--;if(o===0&&a===r)l.push(i.slice(0,-1)),i=""}if(i)l.push(i);return l},hi=(e,r=",")=>{let t=[],n=e.length,o=r.length,i=0,l=(a)=>{if(a+o>n)return!1;for(let p=0;p<o;p++)if(e[a+p]!==r[p])return!1;return!0};while(i<n){while(i<n&&e[i]===" ")i++;if(i>=n)break;let a="",p=e[i]==='"'||e[i]==="'";if(p){let h=e[i++];while(i<n&&e[i]!==h)a+=e[i++];if(i<n)i++}else{while(i<n&&!l(i)){let h=e[i];if(h==='"'||h==="'"){a+=h,i++;while(i<n&&e[i]!==h)a+=e[i++];if(i<n)a+=e[i++]}else a+=e[i++]}a=a.trim()}if(a)t.push({value:a,quoted:p});if(l(i))i+=o}return t}});var N={};W(N,{writeOutputs:()=>me,writeOutput:()=>xe,writeFormat:()=>Re,variable:()=>Yr,tokenize:()=>yr,toObjectWithKey:()=>or,toObject:()=>ge,toList:()=>Z,stripIndent:()=>dr,sortBy:()=>ar,snake:()=>re,sharedFunction:()=>Gr,select:()=>D,section:()=>Tr,processFields:()=>C,pascal:()=>ee,padBlock:()=>T,nonNullMap:()=>ir,navigate:()=>We,mergeAll:()=>z,merge:()=>_,makeFieldProcessorMap:()=>K,makeFieldProcessorList:()=>qe,makeFieldProcessor:()=>pe,macro:()=>c,locate:()=>V,loadFormat:()=>fe,key:()=>Kr,importList:()=>$e,importGlob:()=>tr,globMap:()=>ce,getProcessor:()=>ue,getArgs:()=>Fe,find:()=>fr,exists:()=>q,encoder:()=>Qr,defined:()=>sr,deepClone:()=>I,decoder:()=>Xr,conditionPredicates:()=>L,changeCase:()=>te,capital:()=>we,camel:()=>he,asyncMap:()=>lr,ObjectorPlugin:()=>H,Objector:()=>$t,NavigateResult:()=>M,NavigateAction:()=>Ce,Logger:()=>Ke,AsyncFunction:()=>gr});var ze={};W(ze,{processFields:()=>C,makeFieldProcessorMap:()=>K,makeFieldProcessorList:()=>qe,makeFieldProcessor:()=>pe,getProcessor:()=>ue,getArgs:()=>Fe});var mo=Object.create,{getPrototypeOf:go,defineProperty:Dr,getOwnPropertyNames:yo}=Object,wo=Object.prototype.hasOwnProperty,ho=(e,r,t)=>{t=e!=null?mo(go(e)):{};let n=r||!e||!e.__esModule?Dr(t,"default",{value:e,enumerable:!0}):t;for(let o of yo(e))if(!wo.call(n,o))Dr(n,o,{get:()=>e[o],enumerable:!0});return n},bo=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Oo=bo((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,i=Object.prototype.hasOwnProperty,l=new WeakMap,a=(u)=>{var d=l.get(u),A;if(d)return d;if(d=t({},"__esModule",{value:!0}),u&&typeof u==="object"||typeof u==="function")n(u).map((g)=>!i.call(d,g)&&t(d,g,{get:()=>u[g],enumerable:!(A=o(u,g))||A.enumerable}));return l.set(u,d),d},p=(u,d)=>{for(var A in d)t(u,A,{get:d[A],enumerable:!0,configurable:!0,set:(g)=>d[A]=()=>g})},h={};p(h,{splitWithQuotes:()=>y,splitNested:()=>O}),r.exports=a(h);var O=(u,d,A="(",g=")")=>{let v=0,f="",j=[];for(let b of u){if(f+=b,b===A)v++;if(b===g)v--;if(v===0&&b===d)j.push(f.slice(0,-1)),f=""}if(f)j.push(f);return j},y=(u,d=",")=>{let A=[],g=u.length,v=d.length,f=0,j=(b)=>{if(b+v>g)return!1;for(let S=0;S<v;S++)if(u[b+S]!==d[S])return!1;return!0};while(f<g){while(f<g&&u[f]===" ")f++;if(f>=g)break;let b="",S=u[f]==='"'||u[f]==="'";if(S){let k=u[f++];while(f<g&&u[f]!==k)b+=u[f++];if(f<g)f++}else{while(f<g&&!j(f)){let k=u[f];if(k==='"'||k==="'"){b+=k,f++;while(f<g&&u[f]!==k)b+=u[f++];if(f<g)b+=u[f++]}else b+=u[f++]}b=b.trim()}if(b)A.push({value:b,quoted:S});if(j(f))f+=v}return A}}),vo=ho(Oo(),1),X;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})(X||={});class x{action;by;skipSiblings;reexplore;constructor(e,r,t,n){this.action=e,this.by=r,this.skipSiblings=t,this.reexplore=n}static _explore=new x(0);static _noExplore=new x(2);static _skipSiblings=new x(1);static _deleteParent=new x(4);static ReplaceParent(e,r){return new x(3,e,void 0,r)}static SkipSiblings(){return x._skipSiblings}static Explore(){return x._explore}static NoExplore(){return x._noExplore}static DeleteParent(){return x._deleteParent}static MergeParent(e){return new x(5,e)}static ReplaceItem(e,r){return new x(6,e,r)}static DeleteItem(e){return new x(7,void 0,e)}}var Ao=async(e,r)=>{let t=new WeakSet,n=[],o=[],i=async(a,p,h)=>{let O=a===null,y=O?x.Explore():await r({key:a,value:p,path:n,parent:h,parents:o});if(p&&typeof p==="object"&&y.action===0){if(t.has(p))return y;if(t.add(p),!O)n.push(a),o.push(h);let u=p;while(await l(u,a,h))u=h[a];if(!O)o.pop(),n.pop()}return y},l=async(a,p,h)=>{let O=Object.keys(a),y=O.length;for(let u=0;u<y;u++){let d=O[u],A=a[d],g=await i(d,A,a),v=g.action;if(v===0||v===2)continue;if(v===6){if(a[d]=g.by,g.skipSiblings)return;continue}if(v===7){if(delete a[d],g.skipSiblings)return;continue}if(v===1)return;if(v===3){if(p===null)throw Error("Cannot replace root object");if(h[p]=g.by,g.reexplore)return!0;return}if(v===4){if(p===null)throw Error("Cannot delete root object");delete h[p];return}if(v===5)delete a[d],Object.assign(a,g.by)}};await i(null,e,null)},Eo=Object.create,{getPrototypeOf:Mo,defineProperty:Fr,getOwnPropertyNames:So}=Object,jo=Object.prototype.hasOwnProperty,ko=(e,r,t)=>{t=e!=null?Eo(Mo(e)):{};let n=r||!e||!e.__esModule?Fr(t,"default",{value:e,enumerable:!0}):t;for(let o of So(e))if(!jo.call(n,o))Fr(n,o,{get:()=>e[o],enumerable:!0});return n},Do=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Fo=Do((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,i=Object.prototype.hasOwnProperty,l=new WeakMap,a=(u)=>{var d=l.get(u),A;if(d)return d;if(d=t({},"__esModule",{value:!0}),u&&typeof u==="object"||typeof u==="function")n(u).map((g)=>!i.call(d,g)&&t(d,g,{get:()=>u[g],enumerable:!(A=o(u,g))||A.enumerable}));return l.set(u,d),d},p=(u,d)=>{for(var A in d)t(u,A,{get:d[A],enumerable:!0,configurable:!0,set:(g)=>d[A]=()=>g})},h={};p(h,{splitWithQuotes:()=>y,splitNested:()=>O}),r.exports=a(h);var O=(u,d,A="(",g=")")=>{let v=0,f="",j=[];for(let b of u){if(f+=b,b===A)v++;if(b===g)v--;if(v===0&&b===d)j.push(f.slice(0,-1)),f=""}if(f)j.push(f);return j},y=(u,d=",")=>{let A=[],g=u.length,v=d.length,f=0,j=(b)=>{if(b+v>g)return!1;for(let S=0;S<v;S++)if(u[b+S]!==d[S])return!1;return!0};while(f<g){while(f<g&&u[f]===" ")f++;if(f>=g)break;let b="",S=u[f]==='"'||u[f]==="'";if(S){let k=u[f++];while(f<g&&u[f]!==k)b+=u[f++];if(f<g)f++}else{while(f<g&&!j(f)){let k=u[f];if(k==='"'||k==="'"){b+=k,f++;while(f<g&&u[f]!==k)b+=u[f++];if(f<g)b+=u[f++]}else b+=u[f++]}b=b.trim()}if(b)A.push({value:b,quoted:S});if(j(f))f+=v}return A}}),Ro=ko(Fo(),1),xo=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,$o=/^([^[\]]*)\[([^\]]*)]$/,He=(e,r,t,n)=>{if(e.startsWith("{")&&e.endsWith("}")){let o=e.substring(1,e.length-1);return le(r,o,t)?.toString()}return n?e:void 0},Co=(e,r,t,n)=>{let o=He(r,t,n);if(o)return le(e,o,n);let i=xo.exec(r);if(i){let[,a,p,h]=i,O=He(a.trim(),t,n,!0),y=He(h.trim(),t,n,!0);if(Array.isArray(e)&&(p==="="||p==="==")&&O)return e.find((u)=>u?.[O]==y)}let l=$o.exec(r);if(l){let[,a,p]=l;return e?.[a]?.[p]}return e?.[r]},le=(e,r,t)=>{let n=void 0,o=void 0,i=r??"",l=(y)=>{if(!y)return[y,!1];return y.endsWith("?")?[y.substring(0,y.length-1),!0]:[y,!1]},a=(y,u)=>{let[d,A]=l(u.pop());if(!d){if(t?.set!==void 0&&o!==void 0&&n!==void 0)n[o]=t.set;return y}let g=Co(y,d,e,t);if(g===void 0){if(A||t?.optional||t?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${d}" in "${i}"`)}return n=y,o=d,a(g,u)},p=Ro.splitNested(i,t?.separator??".","{","}"),h=void 0;if(p.length>0&&p[p.length-1].startsWith("?="))h=p.pop()?.substring(2);p.reverse();let O=a(e,p);if(O===void 0)return h??t?.defaultValue;return O},Rr=(e,r)=>{if(typeof e.value==="string"){if(e.quoted)return e.value;if(e.value.startsWith("[")&&e.value.endsWith("]")){let t=e.value.slice(1,-1);if(t.trim()==="")return[];return t.split(";").map((n)=>{let o=n.trim();if(!isNaN(+o))return+o;return o})}if(e.value.startsWith("{")&&e.value.endsWith("}")){if(e.value.slice(1,-1).trim()==="")return{}}if(e.value==="null")return null;if(e.value==="undefined")return;if(e.value.startsWith("@"))return e.value.slice(1);if(!isNaN(+e.value))return+e.value}return r(e.value)},De=(e,r,t,n,o,i)=>{let l=n?.(e)??e,a=o(l);if(a[0])return a[1];if(!r){let p=le(t,e),h=o(p);if(h[0])return h[1]}throw Error(i)},$r=(e,r,t,n,o)=>{let i=typeof e.types==="function"?e.types(n,r.value,o):e.types?.[n];if(!i||i==="ref")return Rr(r,(a)=>le(t,a));let l=Rr(r,()=>r.value);if(Array.isArray(i)){if(!i.includes(l))throw Error(`Argument ${n.toString()} must be one of [${i.join(", ")}]: ${l}`);return l}if(typeof i==="string"){if(i.endsWith("?")){let a=i.slice(0,-1);if(r.value==="null")return x.ReplaceItem(null);if(r.value==="undefined")return x.ReplaceItem(void 0);if(r.value==="")return"";i=a}switch(i){case"any":return l;case"array":return De(l,r.quoted,t,null,(a)=>[Array.isArray(a),a],`Argument ${n.toString()} must be an array: ${l}`);case"object":return De(l,r.quoted,t,null,(a)=>[typeof a==="object"&&a!==null,a],`Argument ${n.toString()} must be an object: ${l}`);case"number":return De(l,r.quoted,t,(a)=>Number(a),(a)=>[!isNaN(a),a],`Argument ${n.toString()} must be a number: ${l}`);case"boolean":return De(l,r.quoted,t,null,(a)=>{if([!0,"true","1",1,"yes","on"].includes(a))return[!0,!0];if([!1,"false","0",0,"no","off"].includes(a))return[!0,!1];if([null,"null","undefined",void 0,""].includes(a))return[!0,!1];if(Array.isArray(a))return[!0,a.length>0];return[!1,!1]},`Argument ${n.toString()} must be a boolean: ${l}`);case"string":return l.toString();default:throw Error(`Unknown type for argument ${n.toString()}: ${i}`)}}return i(l,t,n,r.quoted)},ue=(e,r)=>{let t=e?.[r];if(t===void 0)throw Error(`Unhandled field processor type: ${r}`);return typeof t==="function"?{options:{},fn:t}:{options:t,fn:t.fn}},Cr=(e)=>!e.quoted&&e.value.startsWith("."),Wo=(e)=>{let r={};for(let t of e){if(!Cr(t))continue;let n=t.value.indexOf("="),o=n>-1?t.value.slice(1,n):t.value.slice(1),i=n>-1?t.value.slice(n+1):"";if(i.length>=2){let l=i[0],a=i[i.length-1];if(l==='"'&&a==='"'||l==="'"&&a==="'")i=i.slice(1,-1)}if(!r[o])r[o]=[];r[o].push(i)}return r},Fe=(e,r,t)=>{let n=vo.splitWithQuotes(e??""),o=Wo(n),i=n.filter((a)=>!Cr(a)),l=r.options.processArgs===!1?[]:i.map((a,p)=>$r(r.options,a,t,p,i));return{rawArgs:i,parsedArgs:l,tags:o}},No=(e)=>{return e!==null&&typeof e==="object"&&"action"in e},Io=(e,r)=>r.keys!==void 0&&e.key.startsWith(".")&&r.keys[e.key.substring(1)]!==void 0,Lo=async(e,r,t,n)=>{let{key:o,parent:i}=e,l=ue(n.keys,o.substring(1));if(l.options.processArgs!==!1&&(typeof l.options.types==="function"||l.options.types?.[0]!==void 0))e.value=$r(l.options,{value:e.value,quoted:!1},t,0,[]);if(typeof e.value!=="string")await C(e.value,{...n,root:{...t,parent:e.parent,parents:e.parents},filters:[...n.filters??[],...l.options.filters??[]]});let a=await l.fn({path:r,root:t,parent:i,key:o,options:n,value:e.value,args:[],rawArgs:[],tags:{}});return No(a)?a:x.ReplaceParent(a)},xr=(e)=>{let r=e.split(/\r?\n/),t=r.filter((o)=>o.trim().length>0).map((o)=>/^[ \t]*/.exec(o)?.[0].length??0),n=t.length>0?Math.min(...t):0;if(n===0)return e;return r.map((o)=>o.slice(n)).join(`
2
- `)},_o=async(e,r,t,n)=>{if(!r?.onSection&&!r?.onSectionConfig&&!r?.sections)return[e,!1];let o=/<@\s*section(?:\s*:\s*([\w-]+))?\s*@>([\s\S]*?)<@\s*\/\s*section\s*@>/g,i,l=e,a=0,p=!1,h={content:l,root:n,path:t,options:r,section:{}};while((i=o.exec(e))!==null){p=!0;let[O,y,u]=i,d=i.index,A=d+O.length,g=e[A]===`
3
- `;if(g)A++;let v=d+a,f=A+a,j={},b=u,S=/(^|\r?\n)[ \t]*---[ \t]*(\r?\n|$)/m.exec(u);if(S){let oe=u.slice(0,S.index),Ye=S.index+S[0].length;b=u.slice(Ye);let je=xr(oe).trim();if(je.length>0)try{j=r?.configParser?.(je)??{}}catch(Ge){throw Error(`Failed to parse YAML config for section: ${Ge.message}`)}}else if(/^\r?\n/.test(b))b=b.replace(/^\r?\n/,"");b=xr(b),b=b.replace(/(?:\r?\n[ \t]*)+$/,""),b=b.replace(/[ \t]+$/,"");let k={config:y?{...j,type:y}:j,content:b};if(h.content=l,h.section=k,Object.keys(k.config).length>0){if(await r.onSectionConfig?.(h)!==!1)await C(k.config,{...r,root:n})}let Ae=h.section.config.type?r.sections?.[h.section.config.type]:void 0,G;if(Ae)G=await Ae(h);else if(r.onSection)G=await r.onSection(h);if(k.trim)k.content=k.content.trim();if(k.indent)k.content=k.content.split(`
1
+ var xr=Object.create;var{getPrototypeOf:to,defineProperty:G,getOwnPropertyNames:Fr,getOwnPropertyDescriptor:no}=Object,Ye=Object.prototype.hasOwnProperty;function Ge(e){return this[e]}var D=(e,r,t)=>{var n=Fr(r);for(let o of n)if(!Ye.call(e,o)&&o!=="default")G(e,o,{get:Ge.bind(r,o),enumerable:!0});if(t){for(let o of n)if(!Ye.call(t,o)&&o!=="default")G(t,o,{get:Ge.bind(r,o),enumerable:!0});return t}},oo,io,so=(e,r,t)=>{var n=e!=null&&typeof e==="object";if(n){var o=r?oo??=new WeakMap:io??=new WeakMap,i=o.get(e);if(i)return i}t=e!=null?xr(to(e)):{};let l=r||!e||!e.__esModule?G(t,"default",{value:e,enumerable:!0}):t;for(let a of Fr(e))if(!Ye.call(l,a))G(l,a,{get:Ge.bind(e,a),enumerable:!0});if(n)o.set(e,l);return l};var ao=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Mr=(e,r)=>{return Object.defineProperty(e,"name",{value:r,enumerable:!1,configurable:!0}),e},lo=(e)=>e;function uo(e,r){this[e]=lo.bind(null,r)}var C=(e,r)=>{for(var t in r)G(e,t,{get:r[t],enumerable:!0,configurable:!0,set:uo.bind(r,t)})};var Dr=(e,r)=>(r=Symbol[e])?r:Symbol.for("Symbol."+e),ae=(e)=>{throw TypeError(e)},co=(e,r,t)=>(r in e)?G(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var Qe=(e,r,t)=>r.has(e)||ae("Cannot "+t),fo=(e,r)=>Object(r)!==r?ae('Cannot use the "in" operator on this value'):e.has(r),Sr=(e,r,t)=>(Qe(e,r,"read from private field"),t?t.call(e):r.get(e));var kr=(e,r,t,n)=>(Qe(e,r,"write to private field"),n?n.call(e,t):r.set(e,t),t),po=(e,r,t)=>(Qe(e,r,"access private method"),t),jr=(e)=>[,,,xr(e?.[Dr("metadata")]??null)],Rr=["class","method","getter","setter","accessor","field","value","get","set"],se=(e)=>e!==void 0&&typeof e!=="function"?ae("Function expected"):e,mo=(e,r,t,n,o)=>({kind:Rr[e],name:r,metadata:n,addInitializer:(i)=>t._?ae("Already initialized"):o.push(se(i||null))}),Xe=(e,r)=>co(r,Dr("metadata"),e[3]),$r=(e,r,t,n)=>{for(var o=0,i=e[r>>1],l=i&&i.length;o<l;o++)r&1?i[o].call(t):n=i[o].call(t,n);return n},m=(e,r,t,n,o,i)=>{var l,a,c,w,O,y=r&7,u=!!(r&8),d=!!(r&16),v=y>3?e.length+1:y?u?1:2:0,g=Rr[y+5],A=y>3&&(e[v-1]=[]),f=e[v]||(e[v]=[]),S=y&&(!d&&!u&&(o=o.prototype),y<5&&(y>3||!d)&&no(y<4?o:{get[t](){return Sr(this,i)},set[t](M){kr(this,i,M)}},t));y?d&&y<4&&Mr(i,(y>2?"set ":y>1?"get ":"")+t):Mr(o,t);for(var b=n.length-1;b>=0;b--){if(w=mo(y,t,c={},e[3],f),y){if(w.static=u,w.private=d,O=w.access={has:d?(M)=>fo(o,M):(M)=>(t in M)},y^3)O.get=d?(M)=>(y^1?Sr:po)(M,o,y^4?i:S.get):(M)=>M[t];if(y>2)O.set=d?(M,k)=>kr(M,o,k,y^4?i:S.set):(M,k)=>M[t]=k}if(a=(0,n[b])(y?y<4?d?i:S[g]:y>4?void 0:{get:S.get,set:S.set}:o,w),c._=1,y^4||a===void 0)se(a)&&(y>4?A.unshift(a):y?d?i=a:S[g]=a:o=a);else if(typeof a!=="object"||a===null)ae("Object expected");else se(l=a.get)&&(S.get=l),se(l=a.set)&&(S.set=l),se(l=a.init)&&A.unshift(l)}return y||Xe(e,o),S&&G(o,t,S),d?y^4?i:S:o};var Dt=ao((ol,Ft)=>{var{defineProperty:Tr,getOwnPropertyNames:mi,getOwnPropertyDescriptor:gi}=Object,yi=Object.prototype.hasOwnProperty,kt=new WeakMap,di=(e)=>{var r=kt.get(e),t;if(r)return r;if(r=Tr({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function")mi(e).map((n)=>!yi.call(r,n)&&Tr(r,n,{get:()=>e[n],enumerable:!(t=gi(e,n))||t.enumerable}));return kt.set(e,r),r},hi=(e,r)=>{for(var t in r)Tr(e,t,{get:r[t],enumerable:!0,configurable:!0,set:(n)=>r[t]=()=>n})},xt={};hi(xt,{splitWithQuotes:()=>bi,splitNested:()=>wi});Ft.exports=di(xt);var wi=(e,r,t="(",n=")")=>{let o=0,i="",l=[];for(let a of e){if(i+=a,a===t)o++;if(a===n)o--;if(o===0&&a===r)l.push(i.slice(0,-1)),i=""}if(i)l.push(i);return l},bi=(e,r=",")=>{let t=[],n=e.length,o=r.length,i=0,l=(a)=>{if(a+o>n)return!1;for(let c=0;c<o;c++)if(e[a+c]!==r[c])return!1;return!0};while(i<n){while(i<n&&e[i]===" ")i++;if(i>=n)break;let a="",c=e[i]==='"'||e[i]==="'";if(c){let w=e[i++];while(i<n&&e[i]!==w)a+=e[i++];if(i<n)i++}else{while(i<n&&!l(i)){let w=e[i];if(w==='"'||w==="'"){a+=w,i++;while(i<n&&e[i]!==w)a+=e[i++];if(i<n)a+=e[i++]}else a+=e[i++]}a=a.trim()}if(a)t.push({value:a,quoted:c});if(l(i))i+=o}return t}});var N={};C(N,{writeOutputs:()=>me,writeOutput:()=>je,writeFormat:()=>De,variable:()=>pr,tokenize:()=>Or,toObjectWithKey:()=>or,toObject:()=>ge,toList:()=>Z,stripIndent:()=>Ar,sortBy:()=>ar,snake:()=>re,sharedFunction:()=>mr,select:()=>x,section:()=>cr,processFields:()=>$,pascal:()=>ee,padBlock:()=>_,nonNullMap:()=>ir,navigate:()=>Ce,mergeAll:()=>z,merge:()=>U,makeFieldProcessorMap:()=>B,makeFieldProcessorList:()=>qe,makeFieldProcessor:()=>ce,macro:()=>p,locate:()=>X,loadFormat:()=>fe,key:()=>fr,importList:()=>Re,importGlob:()=>tr,globMap:()=>pe,getProcessor:()=>ue,getArgs:()=>Fe,find:()=>hr,exists:()=>q,encoder:()=>gr,defined:()=>sr,deepClone:()=>W,decoder:()=>yr,conditionPredicates:()=>K,changeCase:()=>te,capital:()=>he,camel:()=>we,asyncMap:()=>lr,ObjectorPlugin:()=>P,Objector:()=>$t,NavigateResult:()=>E,NavigateAction:()=>$e,Logger:()=>Be,AsyncFunction:()=>Er});var ze={};C(ze,{processFields:()=>$,makeFieldProcessorMap:()=>B,makeFieldProcessorList:()=>qe,makeFieldProcessor:()=>ce,getProcessor:()=>ue,getArgs:()=>Fe});var go=Object.create,{getPrototypeOf:yo,defineProperty:Cr,getOwnPropertyNames:ho}=Object,wo=Object.prototype.hasOwnProperty,bo=(e,r,t)=>{t=e!=null?go(yo(e)):{};let n=r||!e||!e.__esModule?Cr(t,"default",{value:e,enumerable:!0}):t;for(let o of ho(e))if(!wo.call(n,o))Cr(n,o,{get:()=>e[o],enumerable:!0});return n},Oo=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Ao=Oo((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,i=Object.prototype.hasOwnProperty,l=new WeakMap,a=(u)=>{var d=l.get(u),v;if(d)return d;if(d=t({},"__esModule",{value:!0}),u&&typeof u==="object"||typeof u==="function")n(u).map((g)=>!i.call(d,g)&&t(d,g,{get:()=>u[g],enumerable:!(v=o(u,g))||v.enumerable}));return l.set(u,d),d},c=(u,d)=>{for(var v in d)t(u,v,{get:d[v],enumerable:!0,configurable:!0,set:(g)=>d[v]=()=>g})},w={};c(w,{splitWithQuotes:()=>y,splitNested:()=>O}),r.exports=a(w);var O=(u,d,v="(",g=")")=>{let A=0,f="",S=[];for(let b of u){if(f+=b,b===v)A++;if(b===g)A--;if(A===0&&b===d)S.push(f.slice(0,-1)),f=""}if(f)S.push(f);return S},y=(u,d=",")=>{let v=[],g=u.length,A=d.length,f=0,S=(b)=>{if(b+A>g)return!1;for(let M=0;M<A;M++)if(u[b+M]!==d[M])return!1;return!0};while(f<g){while(f<g&&u[f]===" ")f++;if(f>=g)break;let b="",M=u[f]==='"'||u[f]==="'";if(M){let k=u[f++];while(f<g&&u[f]!==k)b+=u[f++];if(f<g)f++}else{while(f<g&&!S(f)){let k=u[f];if(k==='"'||k==="'"){b+=k,f++;while(f<g&&u[f]!==k)b+=u[f++];if(f<g)b+=u[f++]}else b+=u[f++]}b=b.trim()}if(b)v.push({value:b,quoted:M});if(S(f))f+=A}return v}}),vo=bo(Ao(),1),Q;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})(Q||={});class j{action;by;skipSiblings;reexplore;constructor(e,r,t,n){this.action=e,this.by=r,this.skipSiblings=t,this.reexplore=n}static _explore=new j(0);static _noExplore=new j(2);static _skipSiblings=new j(1);static _deleteParent=new j(4);static ReplaceParent(e,r){return new j(3,e,void 0,r)}static SkipSiblings(){return j._skipSiblings}static Explore(){return j._explore}static NoExplore(){return j._noExplore}static DeleteParent(){return j._deleteParent}static MergeParent(e){return new j(5,e)}static ReplaceItem(e,r){return new j(6,e,r)}static DeleteItem(e){return new j(7,void 0,e)}}var To=async(e,r)=>{let t=new WeakSet,n=[],o=[],i=async(a,c,w)=>{let O=a===null,y=O?j.Explore():await r({key:a,value:c,path:n,parent:w,parents:o});if(c&&typeof c==="object"&&y.action===0){if(t.has(c))return y;if(t.add(c),!O)n.push(a),o.push(w);let u=c;while(await l(u,a,w))u=w[a];if(!O)o.pop(),n.pop()}return y},l=async(a,c,w)=>{let O=Object.keys(a),y=O.length;for(let u=0;u<y;u++){let d=O[u],v=a[d],g=await i(d,v,a),A=g.action;if(A===0||A===2)continue;if(A===6){if(a[d]=g.by,g.skipSiblings)return;continue}if(A===7){if(delete a[d],g.skipSiblings)return;continue}if(A===1)return;if(A===3){if(c===null)throw Error("Cannot replace root object");if(w[c]=g.by,g.reexplore)return!0;return}if(A===4){if(c===null)throw Error("Cannot delete root object");delete w[c];return}if(A===5)delete a[d],Object.assign(a,g.by)}};await i(null,e,null)},Eo=Object.create,{getPrototypeOf:Mo,defineProperty:Wr,getOwnPropertyNames:So}=Object,ko=Object.prototype.hasOwnProperty,xo=(e,r,t)=>{t=e!=null?Eo(Mo(e)):{};let n=r||!e||!e.__esModule?Wr(t,"default",{value:e,enumerable:!0}):t;for(let o of So(e))if(!ko.call(n,o))Wr(n,o,{get:()=>e[o],enumerable:!0});return n},Fo=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Do=Fo((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,i=Object.prototype.hasOwnProperty,l=new WeakMap,a=(u)=>{var d=l.get(u),v;if(d)return d;if(d=t({},"__esModule",{value:!0}),u&&typeof u==="object"||typeof u==="function")n(u).map((g)=>!i.call(d,g)&&t(d,g,{get:()=>u[g],enumerable:!(v=o(u,g))||v.enumerable}));return l.set(u,d),d},c=(u,d)=>{for(var v in d)t(u,v,{get:d[v],enumerable:!0,configurable:!0,set:(g)=>d[v]=()=>g})},w={};c(w,{splitWithQuotes:()=>y,splitNested:()=>O}),r.exports=a(w);var O=(u,d,v="(",g=")")=>{let A=0,f="",S=[];for(let b of u){if(f+=b,b===v)A++;if(b===g)A--;if(A===0&&b===d)S.push(f.slice(0,-1)),f=""}if(f)S.push(f);return S},y=(u,d=",")=>{let v=[],g=u.length,A=d.length,f=0,S=(b)=>{if(b+A>g)return!1;for(let M=0;M<A;M++)if(u[b+M]!==d[M])return!1;return!0};while(f<g){while(f<g&&u[f]===" ")f++;if(f>=g)break;let b="",M=u[f]==='"'||u[f]==="'";if(M){let k=u[f++];while(f<g&&u[f]!==k)b+=u[f++];if(f<g)f++}else{while(f<g&&!S(f)){let k=u[f];if(k==='"'||k==="'"){b+=k,f++;while(f<g&&u[f]!==k)b+=u[f++];if(f<g)b+=u[f++]}else b+=u[f++]}b=b.trim()}if(b)v.push({value:b,quoted:M});if(S(f))f+=A}return v}}),jo=xo(Do(),1),Ro=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,$o=/^([^[\]]*)\[([^\]]*)]$/,Ze=(e,r,t,n)=>{if(e.startsWith("{")&&e.endsWith("}")){let o=e.substring(1,e.length-1);return le(r,o,t)?.toString()}return n?e:void 0},Co=(e,r,t,n)=>{let o=Ze(r,t,n);if(o)return le(e,o,n);let i=Ro.exec(r);if(i){let[,a,c,w]=i,O=Ze(a.trim(),t,n,!0),y=Ze(w.trim(),t,n,!0);if(Array.isArray(e)&&(c==="="||c==="==")&&O)return e.find((u)=>u?.[O]==y)}let l=$o.exec(r);if(l){let[,a,c]=l;return e?.[a]?.[c]}return e?.[r]},le=(e,r,t)=>{let n=void 0,o=void 0,i=r??"",l=(y)=>{if(!y)return[y,!1];return y.endsWith("?")?[y.substring(0,y.length-1),!0]:[y,!1]},a=(y,u)=>{let[d,v]=l(u.pop());if(!d){if(t?.set!==void 0&&o!==void 0&&n!==void 0)n[o]=t.set;return y}let g=Co(y,d,e,t);if(g===void 0){if(v||t?.optional||t?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${d}" in "${i}"`)}return n=y,o=d,a(g,u)},c=jo.splitNested(i,t?.separator??".","{","}"),w=void 0;if(c.length>0&&c[c.length-1].startsWith("?="))w=c.pop()?.substring(2);c.reverse();let O=a(e,c);if(O===void 0)return w??t?.defaultValue;return O},Nr=(e,r)=>{if(typeof e.value==="string"){if(e.quoted)return e.value;if(e.value.startsWith("[")&&e.value.endsWith("]")){let t=e.value.slice(1,-1);if(t.trim()==="")return[];return t.split(";").map((n)=>{let o=n.trim();if(!isNaN(+o))return+o;return o})}if(e.value.startsWith("{")&&e.value.endsWith("}")){if(e.value.slice(1,-1).trim()==="")return{}}if(e.value==="null")return null;if(e.value==="undefined")return;if(e.value.startsWith("@"))return e.value.slice(1);if(!isNaN(+e.value))return+e.value}return r(e.value)},xe=(e,r,t,n,o,i)=>{let l=n?.(e)??e,a=o(l);if(a[0])return a[1];if(!r){let c=le(t,e),w=o(c);if(w[0])return w[1]}throw Error(i)},Ur=(e,r,t,n,o)=>{let i=typeof e.types==="function"?e.types(n,r.value,o):e.types?.[n];if(!i||i==="ref")return Nr(r,(a)=>le(t,a));let l=Nr(r,()=>r.value);if(Array.isArray(i)){if(!i.includes(l))throw Error(`Argument ${n.toString()} must be one of [${i.join(", ")}]: ${l}`);return l}if(typeof i==="string"){if(i.endsWith("?")){let a=i.slice(0,-1);if(r.value==="null")return j.ReplaceItem(null);if(r.value==="undefined")return j.ReplaceItem(void 0);if(r.value==="")return"";i=a}switch(i){case"any":return l;case"array":return xe(l,r.quoted,t,null,(a)=>[Array.isArray(a),a],`Argument ${n.toString()} must be an array: ${l}`);case"object":return xe(l,r.quoted,t,null,(a)=>[typeof a==="object"&&a!==null,a],`Argument ${n.toString()} must be an object: ${l}`);case"number":return xe(l,r.quoted,t,(a)=>Number(a),(a)=>[!isNaN(a),a],`Argument ${n.toString()} must be a number: ${l}`);case"boolean":return xe(l,r.quoted,t,null,(a)=>{if([!0,"true","1",1,"yes","on"].includes(a))return[!0,!0];if([!1,"false","0",0,"no","off"].includes(a))return[!0,!1];if([null,"null","undefined",void 0,""].includes(a))return[!0,!1];if(Array.isArray(a))return[!0,a.length>0];return[!1,!1]},`Argument ${n.toString()} must be a boolean: ${l}`);case"string":return l.toString();default:throw Error(`Unknown type for argument ${n.toString()}: ${i}`)}}return i(l,t,n,r.quoted)},ue=(e,r)=>{let t=e?.[r];if(t===void 0)throw Error(`Unhandled field processor type: ${r}`);return typeof t==="function"?{options:{},fn:t}:{options:t,fn:t.fn}},Ir=(e)=>!e.quoted&&e.value.startsWith("."),Wo=(e)=>{let r={};for(let t of e){if(!Ir(t))continue;let n=t.value.indexOf("="),o=n>-1?t.value.slice(1,n):t.value.slice(1),i=n>-1?t.value.slice(n+1):"";if(i.length>=2){let l=i[0],a=i[i.length-1];if(l==='"'&&a==='"'||l==="'"&&a==="'")i=i.slice(1,-1)}if(!r[o])r[o]=[];r[o].push(i)}return r},Fe=(e,r,t)=>{let n=vo.splitWithQuotes(e??""),o=Wo(n),i=n.filter((a)=>!Ir(a)),l=r.options.processArgs===!1?[]:i.map((a,c)=>Ur(r.options,a,t,c,i));return{rawArgs:i,parsedArgs:l,tags:o}},No=(e)=>{return e!==null&&typeof e==="object"&&"action"in e},Ko=(e,r)=>r.keys!==void 0&&e.key.startsWith(".")&&r.keys[e.key.substring(1)]!==void 0,Uo=async(e,r,t,n)=>{let{key:o,parent:i}=e,l=ue(n.keys,o.substring(1));if(l.options.processArgs!==!1&&(typeof l.options.types==="function"||l.options.types?.[0]!==void 0))e.value=Ur(l.options,{value:e.value,quoted:!1},t,0,[]);if(typeof e.value!=="string")await $(e.value,{...n,root:{...t,parent:e.parent,parents:e.parents},filters:[...n.filters??[],...l.options.filters??[]]});let a=await l.fn({path:r,root:t,parent:i,key:o,options:n,value:e.value,args:[],rawArgs:[],tags:{}});return No(a)?a:j.ReplaceParent(a)},Kr=(e)=>{let r=e.split(/\r?\n/),t=r.filter((o)=>o.trim().length>0).map((o)=>/^[ \t]*/.exec(o)?.[0].length??0),n=t.length>0?Math.min(...t):0;if(n===0)return e;return r.map((o)=>o.slice(n)).join(`
2
+ `)},Io=async(e,r,t,n)=>{if(!r?.onSection&&!r?.onSectionConfig&&!r?.sections)return[e,!1];let o=/<@\s*section(?:\s*:\s*([\w-]+))?\s*@>([\s\S]*?)<@\s*\/\s*section\s*@>/g,i,l=e,a=0,c=!1,w={content:l,root:n,path:t,options:r,section:{}};while((i=o.exec(e))!==null){c=!0;let[O,y,u]=i,d=i.index,v=d+O.length,g=e[v]===`
3
+ `;if(g)v++;let A=d+a,f=v+a,S={},b=u,M=/(^|\r?\n)[ \t]*---[ \t]*(\r?\n|$)/m.exec(u);if(M){let oe=u.slice(0,M.index),Pe=M.index+M[0].length;b=u.slice(Pe);let Se=Kr(oe).trim();if(Se.length>0)try{S=r?.configParser?.(Se)??{}}catch(Ve){throw Error(`Failed to parse YAML config for section: ${Ve.message}`)}}else if(/^\r?\n/.test(b))b=b.replace(/^\r?\n/,"");b=Kr(b),b=b.replace(/(?:\r?\n[ \t]*)+$/,""),b=b.replace(/[ \t]+$/,"");let k={config:y?{...S,type:y}:S,content:b};if(w.content=l,w.section=k,Object.keys(k.config).length>0){if(await r.onSectionConfig?.(w)!==!1)await $(k.config,{...r,root:n})}let ve=w.section.config.type?r.sections?.[w.section.config.type]:void 0,Y;if(ve)Y=await ve(w);else if(r.onSection)Y=await r.onSection(w);if(k.trim)k.content=k.content.trim();if(k.indent)k.content=k.content.split(`
4
4
  `).map((oe)=>" ".repeat(k.indent)+oe).join(`
5
- `);let B="";if(G===!0||k.show)B=k.content;else if(typeof G==="string")B=G;if(g&&B!==""&&!B.endsWith(`
6
- `))B+=`
7
- `;let Ee=l.lastIndexOf(`
8
- `,v-1),Me=Ee===-1?0:Ee+1,Se=l.slice(Me,v).trim().length===0?Me:v;l=l.slice(0,Se)+B+l.slice(f),a+=B.length-(f-Se),h.content=l}return[l,p]},Wr=(e)=>{let r=[],t=0;while(t<e.length)if(e[t]==="$"&&e[t+1]==="("&&(t===0||e[t-1]!=="\\")){let n=t;t+=2;let o=1;for(;t<e.length;t++)if(e[t]==="(")o++;else if(e[t]===")"){if(o--,o===0){r.push([n,t]);break}}if(o!==0)throw Error(`Unmatched opening $( at position ${n.toString()}`);t++}else t++;return r},Pe=Symbol.for("@homedev/fields:OverrideResult"),Uo=(e)=>({[Pe]:!0,value:e}),Bo=(e)=>{return e!==null&&typeof e==="object"&&Pe in e&&e[Pe]===!0},Nr=async(e,r,t)=>{for(let n=r.length-1;n>=0;n--){let[o,i]=r[n],l=e.slice(o+2,i),a=await Nr(l,Wr(l),t);if(typeof a==="object")return a;let p=await t(a,e);if(Bo(p))return p.value;e=e.slice(0,o)+p+e.slice(i+1)}return e},To=async(e,r)=>Nr(e,Wr(e),r),Ko=(e)=>{return e!==null&&typeof e==="object"&&"action"in e},Yo=/([\w\d.-_/]+):(.+)/,Go=async(e,r,t,n)=>{let o=await(async()=>{let i=Yo.exec(e);if(!i)return await le(r,e);let[l,a,p]=i,h=ue(n.sources,a),O=Fe(p,h,r);return await h.fn({args:O.parsedArgs,rawArgs:O.rawArgs,tags:O.tags,key:a,options:n,root:r,path:t,value:null})})();if(o===null||o===void 0)return"";if(typeof o==="object")return Uo(o);return o},Ir=async(e,r,t,n)=>{let o=await To(r,(i)=>Go(i,t,e,n));if(Ko(o))return o;if(o===r)return x.Explore();if(typeof o==="string"){let i=await Ir(e,o,t,n);if(i.action!==X.Explore)return i;return x.ReplaceItem(o)}return x.ReplaceItem(o)},C=async(e,r)=>{return r??={},await Ao(e,async(t)=>{let n=[...t.path,t.key].join(".");if(r?.filters?.length&&r.filters.some((a)=>a.test(n)))return x.NoExplore();let o=t.path.length===0,i=t.parents.length>0?t.parents.toReversed():[];if(o){if(i.length>0)throw Error("Root object should not have a parent");i=r?.root?.parents?[r.root.parent,...r.root.parents.toReversed()]:[]}let l={...e,...r.root,this:t.parent,parent:i.length>0?i[0]:null,parents:i};try{if(t.key.startsWith("$"))return x.NoExplore();let a=x.Explore();if(typeof t.value==="string"){let p=t.value,h=!1;while(!0){let[O,y]=await _o(p,r,n,l);if(h=h||y,a=await Ir(n,O,l,r),a.action===X.ReplaceItem&&typeof a.by==="string"){p=a.by;continue}if(a.action===X.Explore&&y&&O!==p)a=x.ReplaceItem(O);break}if(a.action===X.Explore&&p!==t.value)a=x.ReplaceItem(p);switch(a.action){case X.Explore:break;case X.ReplaceItem:t.value=a.by;break;default:return a}}if(Io(t,r))a=await Lo(t,n,l,r);return a}catch(a){throw Error(`${a.message}
9
- (${n})`)}}),e},pe=(e,r)=>r?{fn:(t)=>e(...t.args),types:r}:(t)=>e(...t.args),qe=(e,r)=>Object.fromEntries(e.map((t)=>[t.name,pe(t,r?.types?.[t.name])])),K=(e,r)=>Object.fromEntries((r?.keys??Object.keys(e)).map((t)=>[t,pe(e[t],r?.types?.[t])]));var nr={};W(nr,{writeOutputs:()=>me,writeOutput:()=>xe,writeFormat:()=>Re,locate:()=>V,loadFormat:()=>fe,importList:()=>$e,importGlob:()=>tr,globMap:()=>ce,exists:()=>q});import Lr from"fs/promises";import Je from"path";import Qo from"fs/promises";import Xo from"path";import Vo from"fs/promises";import Zo from"fs/promises";import Br from"fs/promises";import _r from"path";import Ho from"fs/promises";import er from"path";import Ur from"path";var q=async(e)=>{try{return await Lr.access(e,Lr.constants.R_OK),!0}catch{return!1}},V=async(e,r)=>{let t=!Je.isAbsolute(e)&&r?["",...r]:[""];for(let n of t){let o=Je.join(n,e);if(await q(o))return Je.resolve(o)}throw Error(`File not found: "${e}"`)},fe=async(e,r)=>{let t=await V(e,r?.dirs),n=await Qo.readFile(t,"utf-8"),o=Xo.dirname(t),i={text:{fn:(a)=>a,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.parse,matching:["\\.json$"]},...r?.parsers},l=r?.format?i[r.format]:Object.values(i).find((a)=>a.matching?.some((p)=>new RegExp(p).test(e)));if(!l)throw Error(`Unsupported format for file "${e}" and no matching parser found`);return{content:await l.fn(n),fullPath:t,folderPath:o}},Re=async(e,r,t)=>{let n={text:{fn:(i)=>i,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.stringify,matching:["\\.json$"]},...t?.encoders},o=t?.format?n[t.format]:Object.values(n).find((i)=>i.matching?.some((l)=>new RegExp(l).test(e)));if(!o)throw Error(`Unsupported format for file "${e}" and no matching encoder found`);await Vo.writeFile(e,await o.fn(r))},ce=async(e,r)=>{if(typeof e==="string"&&!e.includes("*"))return await r.map(e,0,[]);let t=await Array.fromAsync(Zo.glob(e,{cwd:r.cwd})),n=r.filter?t.filter(r.filter):t;return await Promise.all(n.map(r.map))},me=async(e,r)=>{if(r?.targetDirectory&&r?.removeFirst)try{await Br.rm(r?.targetDirectory,{recursive:!0,force:!0})}catch(t){throw Error(`Failed to clean the output directory: ${t.message}`)}for(let t of e)await xe(t,r)},xe=async(e,r)=>{let t=_r.join(r?.targetDirectory??".",e.name),n=_r.dirname(t);if(r?.classes){if(e.class!==void 0&&!r.classes.includes(e.class))return;if(r.classRequired&&e.class===void 0)throw Error(`Output "${e.name}" is missing class field`)}if(r?.writing?.(e)===!1)return;try{await Br.mkdir(n,{recursive:!0})}catch(o){throw Error(`Failed to create target directory "${n}" for output "${t}": ${o.message}`)}try{await Re(t,e.value,{format:e.type??"text"})}catch(o){throw Error(`Failed to write output "${t}": ${o.message}`)}},rr=(e)=>e?Ur.isAbsolute(e)?e:Ur.join(process.cwd(),e):process.cwd(),$e=async(e,r)=>{let t=[];for(let n of e)try{let o=!er.isAbsolute(n)?er.join(rr(r?.cwd),n):n;if(r?.filter?.(o)===!1)continue;let i=await import(o);if(r?.resolveDefault==="only"&&!i.default)throw Error(`Module ${n} does not have a default export`);let l=r?.resolveDefault?i.default??i:i,a=r?.map?await r.map(l,n):l;if(a!==void 0)t.push(a)}catch(o){if(r?.fail?.(n,o)===!1)continue;throw Error(`Failed to import module ${n}: ${o.message??o}`)}return t},tr=async(e,r)=>{let t=[];for(let n of e){let o=(await Array.fromAsync(Ho.glob(n,{cwd:rr(r?.cwd)}))).map((i)=>er.join(rr(r?.cwd),i));t.push(...await $e(o,r))}return t};var ur={};W(ur,{toObjectWithKey:()=>or,toObject:()=>ge,toList:()=>Z,sortBy:()=>ar,nonNullMap:()=>ir,defined:()=>sr,deepClone:()=>I,asyncMap:()=>lr});var Z=(e,r="name")=>Object.entries(e).map(([t,n])=>({[r]:t,...n})),or=(e,r="name")=>Object.fromEntries(e.map((t)=>[t[r],t])),ge=(e,r="name")=>Object.fromEntries(e.map((t)=>{let{[r]:n,...o}=t;return[n,o]})),ir=(e,r)=>{if(!e)return[];let t=[],n=0;for(let o of e)if(o!==null&&o!==void 0)t.push(r(o,n,e)),n++;return t},sr=(e,r="Value is undefined")=>{if(e===void 0||e===null)throw Error(r);return e},ar=(e,r,t=(n,o)=>n-o)=>e.slice().sort((n,o)=>t(r(n),r(o))),lr=async(e,r)=>Promise.all(e.map(r)),I=(e)=>{if(typeof structuredClone<"u")try{return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))};var pr={};W(pr,{variable:()=>Yr,sharedFunction:()=>Gr,section:()=>Tr,macro:()=>c,key:()=>Kr,encoder:()=>Qr,decoder:()=>Xr,ObjectorPlugin:()=>H});class H{o;context;constructor(e){this.o=e}}var c=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.sources({[o]:(i)=>n.apply({...this,context:i},i.args)})})},Tr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.sections({[o]:(i)=>{return n.call({...this,context:i},i.section)}})})},Kr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.keys({[o]:(i)=>n.call({...this,context:i},i.value)})})},Yr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.variables({[o]:n})})},Gr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.functions({[o]:n})})},Qr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.encoders({[o]:{fn:n}})})},Xr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.decoders({[o]:{fn:n}})})};var St={};W(St,{defaultProcessors:()=>wr});import{createHash as ne}from"crypto";import Y from"path";var Vr={};W(Vr,{navigate:()=>We,find:()=>fr,NavigateResult:()=>M,NavigateAction:()=>Ce});var Ce;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})(Ce||={});class M{action;by;skipSiblings;reexplore;constructor(e,r,t,n){this.action=e,this.by=r,this.skipSiblings=t,this.reexplore=n}static _explore=new M(0);static _noExplore=new M(2);static _skipSiblings=new M(1);static _deleteParent=new M(4);static ReplaceParent(e,r){return new M(3,e,void 0,r)}static SkipSiblings(){return M._skipSiblings}static Explore(){return M._explore}static NoExplore(){return M._noExplore}static DeleteParent(){return M._deleteParent}static MergeParent(e){return new M(5,e)}static ReplaceItem(e,r){return new M(6,e,r)}static DeleteItem(e){return new M(7,void 0,e)}}var We=async(e,r)=>{let t=new WeakSet,n=[],o=[],i=async(a,p,h)=>{let O=a===null,y=O?M.Explore():await r({key:a,value:p,path:n,parent:h,parents:o});if(p&&typeof p==="object"&&y.action===0){if(t.has(p))return y;if(t.add(p),!O)n.push(a),o.push(h);let u=p;while(await l(u,a,h))u=h[a];if(!O)o.pop(),n.pop()}return y},l=async(a,p,h)=>{let O=Object.keys(a),y=O.length;for(let u=0;u<y;u++){let d=O[u],A=a[d],g=await i(d,A,a),v=g.action;if(v===0||v===2)continue;if(v===6){if(a[d]=g.by,g.skipSiblings)return;continue}if(v===7){if(delete a[d],g.skipSiblings)return;continue}if(v===1)return;if(v===3){if(p===null)throw Error("Cannot replace root object");if(h[p]=g.by,g.reexplore)return!0;return}if(v===4){if(p===null)throw Error("Cannot delete root object");delete h[p];return}if(v===5)delete a[d],Object.assign(a,g.by)}};await i(null,e,null)},fr=async(e,r)=>{let t=[];return await We(e,(n)=>{if(r([...n.path,n.key].join("."),n.value))t.push(n.value);return M.Explore()}),t};var Zr=(e)=>({output:(r)=>{delete r.parent[r.key];for(let t of Array.isArray(r.value)?r.value:[r.value])if(typeof t==="string")e.output({name:t,value:r.parent});else e.output({...t,value:t.value??r.parent});return M.SkipSiblings()}});import Po from"path";var Hr=(e)=>({load:async(r)=>{let t=r.options.globalContext;for(let{file:n}of Array.isArray(r.value)?r.value:[r.value]){if(!n)throw Error("File reference required");await e.load(n,t.file&&Po.dirname(t.file))}return M.DeleteItem()}});var Pr={};W(Pr,{mergeAll:()=>z,merge:()=>_});var _=(e,r,t)=>{for(let n of Object.keys(r)){if(e[n]===void 0)continue;let o=r[n],i=e[n];if(typeof i!==typeof o||Array.isArray(i)!==Array.isArray(o)){let a=t?.mismatch?.(n,i,o,e,r);if(a!==void 0){r[n]=a;continue}throw Error(`Type mismatch: ${n}`)}let l=t?.mode?.(n,i,o,e,r)??r[".merge"]??"merge";switch(l){case"source":r[n]=i;continue;case"target":continue;case"skip":delete r[n],delete e[n];continue;case"merge":break;default:throw Error(`Unknown merge mode: ${l}`)}if(typeof i==="object")if(Array.isArray(i))o.push(...i);else{if(t?.navigate?.(n,i,o,e,r)===!1)continue;_(i,o,t)}else{if(i===o)continue;let a=t?.conflict?.(n,i,o,e,r);r[n]=a===void 0?o:a}}for(let n of Object.keys(e))if(r[n]===void 0)r[n]=e[n]},z=(e,r)=>{let t={};for(let n of e.toReversed())_(n,t,r);return t};var qr={};W(qr,{CacheManager:()=>Ne});class Ne{cache=new Map;maxSize;constructor(e=100){this.maxSize=e}get(e){return this.cache.get(e)}set(e,r){this.evictIfNeeded(),this.cache.set(e,r)}has(e){return this.cache.has(e)}clear(){this.cache.clear()}setMaxSize(e){this.maxSize=e}size(){return this.cache.size}evictIfNeeded(){if(this.cache.size>=this.maxSize){let e=null,r=1/0;for(let[t,n]of this.cache.entries())if(n.timestamp<r)r=n.timestamp,e=t;if(e)this.cache.delete(e)}}}var Jr={};W(Jr,{select:()=>D});var qo=Object.create,{getPrototypeOf:zo,defineProperty:zr,getOwnPropertyNames:Jo}=Object,ei=Object.prototype.hasOwnProperty,ri=(e,r,t)=>{t=e!=null?qo(zo(e)):{};let n=r||!e||!e.__esModule?zr(t,"default",{value:e,enumerable:!0}):t;for(let o of Jo(e))if(!ei.call(n,o))zr(n,o,{get:()=>e[o],enumerable:!0});return n},ti=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),ni=ti((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,i=Object.prototype.hasOwnProperty,l=new WeakMap,a=(u)=>{var d=l.get(u),A;if(d)return d;if(d=t({},"__esModule",{value:!0}),u&&typeof u==="object"||typeof u==="function")n(u).map((g)=>!i.call(d,g)&&t(d,g,{get:()=>u[g],enumerable:!(A=o(u,g))||A.enumerable}));return l.set(u,d),d},p=(u,d)=>{for(var A in d)t(u,A,{get:d[A],enumerable:!0,configurable:!0,set:(g)=>d[A]=()=>g})},h={};p(h,{splitWithQuotes:()=>y,splitNested:()=>O}),r.exports=a(h);var O=(u,d,A="(",g=")")=>{let v=0,f="",j=[];for(let b of u){if(f+=b,b===A)v++;if(b===g)v--;if(v===0&&b===d)j.push(f.slice(0,-1)),f=""}if(f)j.push(f);return j},y=(u,d=",")=>{let A=[],g=u.length,v=d.length,f=0,j=(b)=>{if(b+v>g)return!1;for(let S=0;S<v;S++)if(u[b+S]!==d[S])return!1;return!0};while(f<g){while(f<g&&u[f]===" ")f++;if(f>=g)break;let b="",S=u[f]==='"'||u[f]==="'";if(S){let k=u[f++];while(f<g&&u[f]!==k)b+=u[f++];if(f<g)f++}else{while(f<g&&!j(f)){let k=u[f];if(k==='"'||k==="'"){b+=k,f++;while(f<g&&u[f]!==k)b+=u[f++];if(f<g)b+=u[f++]}else b+=u[f++]}b=b.trim()}if(b)A.push({value:b,quoted:S});if(j(f))f+=v}return A}}),oi=ri(ni(),1),ii=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,si=/^([^[\]]*)\[([^\]]*)]$/,cr=(e,r,t,n)=>{if(e.startsWith("{")&&e.endsWith("}")){let o=e.substring(1,e.length-1);return D(r,o,t)?.toString()}return n?e:void 0},ai=(e,r,t,n)=>{let o=cr(r,t,n);if(o)return D(e,o,n);let i=ii.exec(r);if(i){let[,a,p,h]=i,O=cr(a.trim(),t,n,!0),y=cr(h.trim(),t,n,!0);if(Array.isArray(e)&&(p==="="||p==="==")&&O)return e.find((u)=>u?.[O]==y)}let l=si.exec(r);if(l){let[,a,p]=l;return e?.[a]?.[p]}return e?.[r]},D=(e,r,t)=>{let n=void 0,o=void 0,i=r??"",l=(y)=>{if(!y)return[y,!1];return y.endsWith("?")?[y.substring(0,y.length-1),!0]:[y,!1]},a=(y,u)=>{let[d,A]=l(u.pop());if(!d){if(t?.set!==void 0&&o!==void 0&&n!==void 0)n[o]=t.set;return y}let g=ai(y,d,e,t);if(g===void 0){if(A||t?.optional||t?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${d}" in "${i}"`)}return n=y,o=d,a(g,u)},p=oi.splitNested(i,t?.separator??".","{","}"),h=void 0;if(p.length>0&&p[p.length-1].startsWith("?="))h=p.pop()?.substring(2);p.reverse();let O=a(e,p);if(O===void 0)return h??t?.defaultValue;return O};var Ie=(e)=>{if(typeof e.value==="string")return e.parent;let r=e.value.model;if(!r)return e.parent;if(typeof r==="string")return D(e.root,r);return r};var Le=(e)=>{if(typeof e.value==="string")return D(e.root,e.value);if(Array.isArray(e.value))return e.value;let r=e.value;if(typeof r.from==="string")return D(e.root,r.from);return r.from};var _e=async(e,r)=>{let t=e.value;if(t.selector===void 0)return r;if(typeof t.selector!=="string"){let n=JSON.parse(JSON.stringify(t.selector));return await C(n,{...e.options,root:{...e.root,result:r}}),n}return await D({...e.root,result:r},t.selector)};var et={};W(et,{PathManager:()=>P});import J from"path";class P{constructor(){}static normalize(e){return J.normalize(J.resolve(e))}static resolveInContext(e,r){let t=r??process.cwd(),n=J.isAbsolute(e)?e:J.join(t,e);return this.normalize(n)}static isDirectoryPattern(e){return e.endsWith("/")}static isGlobPattern(e){return e.includes("*")}static toAbsolute(e,r){if(J.isAbsolute(e))return e;return J.join(r??process.cwd(),e)}}var rt={};W(rt,{conditionPredicatesTypes:()=>ye,conditionPredicates:()=>L});var L={and:(...e)=>e.every((r)=>!!r),or:(...e)=>e.some((r)=>!!r),xor:(...e)=>e.filter((r)=>!!r).length===1,true:(...e)=>e.every((r)=>!!r),false:(...e)=>e.every((r)=>!r),eq:(...e)=>e.every((r)=>r===e[0]),ne:(...e)=>e.some((r)=>r!==e[0]),lt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<r),le:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<=r),gt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>r),ge:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>=r),in:(e,r)=>{if(Array.isArray(r))return r.includes(e);if(typeof e==="string")return e.includes(r);if(Array.isArray(e))return e.includes(r);return!1},notin:(e,r)=>!L.in(e,r),contains:(e,r)=>e.includes(r),notcontains:(e,r)=>!e.includes(r),containsi:(e,r)=>e.toLowerCase().includes(r.toLowerCase()),notcontainsi:(e,r)=>!e.toLowerCase().includes(r.toLowerCase()),null:(...e)=>e.every((r)=>r===null||r===void 0),notnull:(...e)=>e.every((r)=>r!==null&&r!==void 0),empty:(...e)=>e.every((r)=>r===""),notempty:(...e)=>e.every((r)=>r!==""),nullorempty:(...e)=>e.every((r)=>r===null||r===void 0||r===""),notnullorempty:(...e)=>e.every((r)=>r!==null&&r!==void 0&&r!=="")},ye={and:()=>"boolean",or:()=>"boolean",xor:()=>"boolean",true:()=>"boolean",false:()=>"boolean",lt:()=>"number",le:()=>"number",gt:()=>"number",ge:()=>"number"};var tt=()=>({each:{filters:[/select|model/],fn:async(e)=>{let r=e.value;delete e.parent[e.key];let t=await Le(e),n=await Ie(e);if(!Array.isArray(t))throw Error('Key "each" requires a source list');if(n===void 0)throw Error('Key "each" must define a model');if(r.extend?.model)n=z([r.model,...Array.isArray(r.extend.model)?r.extend.model:[r.extend.model]]);let o=[];for(let i=0;i<t.length;i++){let l=I(n);if(await C(l,{...e.options,root:{...e.root,index:i,item:t[i],instance:l}}),r.extend?.result){let a=r.extend.result;l=z([l,...Array.isArray(a)?a:[a]])}o.push(await _e(e,l))}return o}}});var nt=()=>({map:{filters:[/select|model/],fn:async(e)=>{delete e.parent[e.key];let r=await Le(e),t=await Ie(e);if(!Array.isArray(r))throw Error('Key "map" requires a source list');if(t===void 0)throw Error('Key "map" must define a model');let n=[];for(let o=0;o<r.length;o++){let i=I(t);await C(i,{...e.options,root:{...e.root,index:o,item:r[o],instance:i}}),n.push(await _e(e,i))}return n}}});var ot=()=>({concat:async(e)=>{let r=[];for(let t of Array.isArray(e.value)?e.value:[e.value])r.push(...await D(e.root,t));return r.filter((t)=>t!==void 0)}});var it=()=>({extends:async(e)=>{let r=async(t,n)=>{for(let o of Array.isArray(n)?n:[n]){let i=await D(e.root,o),l=I(i);if(l[e.key])await r(l,l[e.key]);await C(l,{...e.options}),_(l,t),delete t[e.key]}};return await r(e.parent,e.value),M.Explore()},group:(e)=>{let r=e.root.parent,t=e.value,{items:n,...o}=t;return t.items.forEach((i)=>r.push({...o,...i})),M.DeleteParent()}});var st=(e)=>({skip:{types:{0:"boolean"},fn:(r)=>r.value?M.DeleteParent():M.DeleteItem()},metadata:({path:r,value:t})=>{return e.metadata(r,t),M.DeleteItem()},if:{types:{0:"boolean"},fn:async(r)=>{let t=r.parent[".then"],n=r.parent[".else"];if(t!==void 0)delete r.parent[".then"];if(n!==void 0)delete r.parent[".else"];let o=r.value?t:n;if(o===void 0)return M.DeleteItem();if(typeof o==="string")return(await C({value:o},{...r.options,root:{...r.root}})).value;return M.ReplaceParent(o,!0)}},switch:(r)=>{let t=r.value;if(!t.cases)throw Error("Missing cases for switch");if(t.cases[t.from]!==void 0)return M.ReplaceParent(t.cases[t.from],!0);if(t.default!==void 0)return M.ReplaceParent(t.default,!0);return M.DeleteParent()}});var at=()=>({from:async({root:e,parent:r,value:t})=>{let n=await D(e,t);if(n===null||n===void 0)throw Error(`Unable to resolve reference: ${t}`);if(r.content){if(Array.isArray(r.content)&&Array.isArray(n))return[...n,...r.content];return _(n,r.content),r.content}return n}});import lt from"node:vm";var ut=(e)=>({modules:async(r)=>{for(let[t,n]of Object.entries(r.value)){let o=lt.createContext({console,objector:e,document:r.root}),i=new lt.SourceTextModule(n,{identifier:t,context:o});await i.link((l)=>{throw Error(`Module ${l} is not allowed`)}),await i.evaluate(),e.sources(Object.fromEntries(Object.entries(i.namespace).map(([l,a])=>[`${t}.${l}`,(p)=>a(p,...p.args)])))}return M.DeleteItem()}});var pt=()=>({try:{fn:(e)=>{let r=e.parent[".catch"];if(r!==void 0)delete e.parent[".catch"];try{return e.value}catch(t){if(r!==void 0)return r;return M.DeleteItem()}}}});var ft=()=>({let:{fn:(e)=>{let r=e.value;return Object.assign(e.root,r),M.DeleteItem()}}});var ct=()=>({tap:{fn:(e)=>{return console.log(`[tap] ${e.path}:`,e.value),e.value}}});var li=(e,r)=>{let t=r.section.config.using,n=e.getFunctions();return t?Object.fromEntries(t.map((o)=>{if(o in n)return[o,n[o]];if(o in r.root)return[o,r.root[o]];throw Error(`Function or variable "${o}" not found for script section`)})):n},mr=(e,r,t,n,o=[])=>{let i=li(e,t),l=["section","context","config","system",...Object.keys(i),...o],a=[r,t.root,t.section.config,e,...Object.values(i)];return[new gr(...l,n).bind(t),a]},ui=(e,r)=>{let t={write:(...n)=>{return r.push(...n),t},writeLine:(...n)=>{return r.push(...n.map((o)=>o+`
5
+ `);let L="";if(Y===!0||k.show)L=k.content;else if(typeof Y==="string")L=Y;if(g&&L!==""&&!L.endsWith(`
6
+ `))L+=`
7
+ `;let Te=l.lastIndexOf(`
8
+ `,A-1),Ee=Te===-1?0:Te+1,Me=l.slice(Ee,A).trim().length===0?Ee:A;l=l.slice(0,Me)+L+l.slice(f),a+=L.length-(f-Me),w.content=l}return[l,c]},Lr=(e)=>{let r=[],t=0;while(t<e.length)if(e[t]==="$"&&e[t+1]==="("&&(t===0||e[t-1]!=="\\")){let n=t;t+=2;let o=1;for(;t<e.length;t++)if(e[t]==="(")o++;else if(e[t]===")"){if(o--,o===0){r.push([n,t]);break}}if(o!==0)throw Error(`Unmatched opening $( at position ${n.toString()}`);t++}else t++;return r},He=Symbol.for("@homedev/fields:OverrideResult"),Lo=(e)=>({[He]:!0,value:e}),_o=(e)=>{return e!==null&&typeof e==="object"&&He in e&&e[He]===!0},_r=async(e,r,t)=>{for(let n=r.length-1;n>=0;n--){let[o,i]=r[n],l=e.slice(o+2,i),a=await _r(l,Lr(l),t);if(typeof a==="object")return a;let c=await t(a,e);if(_o(c))return c.value;e=e.slice(0,o)+c+e.slice(i+1)}return e},Bo=async(e,r)=>_r(e,Lr(e),r),Po=(e)=>{return e!==null&&typeof e==="object"&&"action"in e},Vo=/([\w\d.-_/]+):(.+)/,Yo=async(e,r,t,n)=>{let o=await(async()=>{let i=Vo.exec(e);if(!i)return await le(r,e);let[l,a,c]=i,w=ue(n.sources,a),O=Fe(c,w,r);return await w.fn({args:O.parsedArgs,rawArgs:O.rawArgs,tags:O.tags,key:a,options:n,root:r,path:t,value:null})})();if(o===null||o===void 0)return"";if(typeof o==="object")return Lo(o);return o},Br=async(e,r,t,n)=>{let o=await Bo(r,(i)=>Yo(i,t,e,n));if(Po(o))return o;if(o===r)return j.Explore();if(typeof o==="string"){let i=await Br(e,o,t,n);if(i.action!==Q.Explore)return i;return j.ReplaceItem(o)}return j.ReplaceItem(o)},$=async(e,r)=>{return r??={},await To(e,async(t)=>{let n=[...t.path,t.key].join(".");if(r?.filters?.length&&r.filters.some((a)=>a.test(n)))return j.NoExplore();let o=t.path.length===0,i=t.parents.length>0?t.parents.toReversed():[];if(o){if(i.length>0)throw Error("Root object should not have a parent");i=r?.root?.parents?[r.root.parent,...r.root.parents.toReversed()]:[]}let l={...e,...r.root,this:t.parent,parent:i.length>0?i[0]:null,parents:i};try{if(t.key.startsWith("$"))return j.NoExplore();let a=j.Explore();if(typeof t.value==="string"){let c=t.value,w=!1;while(!0){let[O,y]=await Io(c,r,n,l);if(w=w||y,a=await Br(n,O,l,r),a.action===Q.ReplaceItem&&typeof a.by==="string"){c=a.by;continue}if(a.action===Q.Explore&&y&&O!==c)a=j.ReplaceItem(O);break}if(a.action===Q.Explore&&c!==t.value)a=j.ReplaceItem(c);switch(a.action){case Q.Explore:break;case Q.ReplaceItem:t.value=a.by;break;default:return a}}if(Ko(t,r))a=await Uo(t,n,l,r);return a}catch(a){throw Error(`${a.message}
9
+ (${n})`)}}),e},ce=(e,r)=>r?{fn:(t)=>e(...t.args),types:r}:(t)=>e(...t.args),qe=(e,r)=>Object.fromEntries(e.map((t)=>[t.name,ce(t,r?.types?.[t.name])])),B=(e,r)=>Object.fromEntries((r?.keys??Object.keys(e)).map((t)=>[t,ce(e[t],r?.types?.[t])]));var nr={};C(nr,{writeOutputs:()=>me,writeOutput:()=>je,writeFormat:()=>De,locate:()=>X,loadFormat:()=>fe,importList:()=>Re,importGlob:()=>tr,globMap:()=>pe,exists:()=>q});import Pr from"fs/promises";import Je from"path";import Go from"fs/promises";import Qo from"path";import Xo from"fs/promises";import Zo from"fs/promises";import Gr from"fs/promises";import Vr from"path";import Ho from"fs/promises";import er from"path";import Yr from"path";var q=async(e)=>{try{return await Pr.access(e,Pr.constants.R_OK),!0}catch{return!1}},X=async(e,r)=>{let t=!Je.isAbsolute(e)&&r?["",...r]:[""];for(let n of t){let o=Je.join(n,e);if(await q(o))return Je.resolve(o)}throw Error(`File not found: "${e}"`)},fe=async(e,r)=>{let t=await X(e,r?.dirs),n=await Go.readFile(t,"utf-8"),o=Qo.dirname(t),i={text:{fn:(a)=>a,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.parse,matching:["\\.json$"]},...r?.parsers},l=r?.format?i[r.format]:Object.values(i).find((a)=>a.matching?.some((c)=>new RegExp(c).test(e)));if(!l)throw Error(`Unsupported format for file "${e}" and no matching parser found`);return{content:await l.fn(n),fullPath:t,folderPath:o}},De=async(e,r,t)=>{let n={text:{fn:(i)=>i,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.stringify,matching:["\\.json$"]},...t?.encoders},o=t?.format?n[t.format]:Object.values(n).find((i)=>i.matching?.some((l)=>new RegExp(l).test(e)));if(!o)throw Error(`Unsupported format for file "${e}" and no matching encoder found`);await Xo.writeFile(e,await o.fn(r))},pe=async(e,r)=>{if(typeof e==="string"&&!e.includes("*"))return await r.map(e,0,[]);let t=await Array.fromAsync(Zo.glob(e,{cwd:r.cwd})),n=r.filter?t.filter(r.filter):t;return await Promise.all(n.map(r.map))},me=async(e,r)=>{if(r?.targetDirectory&&r?.removeFirst)try{await Gr.rm(r?.targetDirectory,{recursive:!0,force:!0})}catch(t){throw Error(`Failed to clean the output directory: ${t.message}`)}for(let t of e)await je(t,r)},je=async(e,r)=>{let t=Vr.join(r?.targetDirectory??".",e.name),n=Vr.dirname(t);if(r?.classes){if(e.class!==void 0&&!r.classes.includes(e.class))return;if(r.classRequired&&e.class===void 0)throw Error(`Output "${e.name}" is missing class field`)}if(r?.writing?.(e)===!1)return;try{await Gr.mkdir(n,{recursive:!0})}catch(o){throw Error(`Failed to create target directory "${n}" for output "${t}": ${o.message}`)}try{await De(t,e.value,{format:e.type??"text"})}catch(o){throw Error(`Failed to write output "${t}": ${o.message}`)}},rr=(e)=>e?Yr.isAbsolute(e)?e:Yr.join(process.cwd(),e):process.cwd(),Re=async(e,r)=>{let t=[];for(let n of e)try{let o=!er.isAbsolute(n)?er.join(rr(r?.cwd),n):n;if(r?.filter?.(o)===!1)continue;let i=await import(o);if(r?.resolveDefault==="only"&&!i.default)throw Error(`Module ${n} does not have a default export`);let l=r?.resolveDefault?i.default??i:i,a=r?.map?await r.map(l,n):l;if(a!==void 0)t.push(a)}catch(o){if(r?.fail?.(n,o)===!1)continue;throw Error(`Failed to import module ${n}: ${o.message??o}`)}return t},tr=async(e,r)=>{let t=[];for(let n of e){let o=(await Array.fromAsync(Ho.glob(n,{cwd:rr(r?.cwd)}))).map((i)=>er.join(rr(r?.cwd),i));t.push(...await Re(o,r))}return t};var ur={};C(ur,{toObjectWithKey:()=>or,toObject:()=>ge,toList:()=>Z,sortBy:()=>ar,nonNullMap:()=>ir,defined:()=>sr,deepClone:()=>W,asyncMap:()=>lr});var Z=(e,r="name")=>Object.entries(e).map(([t,n])=>({[r]:t,...n})),or=(e,r="name")=>Object.fromEntries(e.map((t)=>[t[r],t])),ge=(e,r="name")=>Object.fromEntries(e.map((t)=>{let{[r]:n,...o}=t;return[n,o]})),ir=(e,r)=>{if(!e)return[];let t=[],n=0;for(let o of e)if(o!==null&&o!==void 0)t.push(r(o,n,e)),n++;return t},sr=(e,r="Value is undefined")=>{if(e===void 0||e===null)throw Error(r);return e},ar=(e,r,t=(n,o)=>n-o)=>e.slice().sort((n,o)=>t(r(n),r(o))),lr=async(e,r)=>Promise.all(e.map(r)),W=(e)=>{if(typeof structuredClone<"u")try{return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))};var dr={};C(dr,{variable:()=>pr,sharedFunction:()=>mr,section:()=>cr,macro:()=>p,key:()=>fr,encoder:()=>gr,decoder:()=>yr,ObjectorPlugin:()=>P});class P{o;context;constructor(e){this.o=e}}var p=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.sources({[o]:(i)=>n.apply({...this,context:i},i.args)})})},cr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.sections({[o]:(i)=>{return n.call({...this,context:i},i.section)}})})},fr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.keys({[o]:(i)=>n.call({...this,context:i},i.value)})})},pr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.variables({[o]:n})})},mr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.functions({[o]:n})})},gr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.encoders({[o]:{fn:n}})})},yr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.decoders({[o]:{fn:n}})})};var Mt={};C(Mt,{defaultProcessors:()=>vr});import{createHash as ne}from"crypto";import V from"path";var Qr={};C(Qr,{navigate:()=>Ce,find:()=>hr,NavigateResult:()=>E,NavigateAction:()=>$e});var $e;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})($e||={});class E{action;by;skipSiblings;reexplore;constructor(e,r,t,n){this.action=e,this.by=r,this.skipSiblings=t,this.reexplore=n}static _explore=new E(0);static _noExplore=new E(2);static _skipSiblings=new E(1);static _deleteParent=new E(4);static ReplaceParent(e,r){return new E(3,e,void 0,r)}static SkipSiblings(){return E._skipSiblings}static Explore(){return E._explore}static NoExplore(){return E._noExplore}static DeleteParent(){return E._deleteParent}static MergeParent(e){return new E(5,e)}static ReplaceItem(e,r){return new E(6,e,r)}static DeleteItem(e){return new E(7,void 0,e)}}var Ce=async(e,r)=>{let t=new WeakSet,n=[],o=[],i=async(a,c,w)=>{let O=a===null,y=O?E.Explore():await r({key:a,value:c,path:n,parent:w,parents:o});if(c&&typeof c==="object"&&y.action===0){if(t.has(c))return y;if(t.add(c),!O)n.push(a),o.push(w);let u=c;while(await l(u,a,w))u=w[a];if(!O)o.pop(),n.pop()}return y},l=async(a,c,w)=>{let O=Object.keys(a),y=O.length;for(let u=0;u<y;u++){let d=O[u],v=a[d],g=await i(d,v,a),A=g.action;if(A===0||A===2)continue;if(A===6){if(a[d]=g.by,g.skipSiblings)return;continue}if(A===7){if(delete a[d],g.skipSiblings)return;continue}if(A===1)return;if(A===3){if(c===null)throw Error("Cannot replace root object");if(w[c]=g.by,g.reexplore)return!0;return}if(A===4){if(c===null)throw Error("Cannot delete root object");delete w[c];return}if(A===5)delete a[d],Object.assign(a,g.by)}};await i(null,e,null)},hr=async(e,r)=>{let t=[];return await Ce(e,(n)=>{if(r([...n.path,n.key].join("."),n.value))t.push(n.value);return E.Explore()}),t};var Xr=(e)=>({output:(r)=>{delete r.parent[r.key];for(let t of Array.isArray(r.value)?r.value:[r.value])if(typeof t==="string")e.output({name:t,value:r.parent});else e.output({...t,value:t.value??r.parent});return E.SkipSiblings()}});import qo from"path";var Zr=(e)=>({load:async(r)=>{let t=r.options.globalContext;for(let{file:n}of Array.isArray(r.value)?r.value:[r.value]){if(!n)throw Error("File reference required");await e.load(n,t.file&&qo.dirname(t.file))}return E.DeleteItem()}});var Hr={};C(Hr,{mergeAll:()=>z,merge:()=>U});var U=(e,r,t)=>{for(let n of Object.keys(r)){if(e[n]===void 0)continue;let o=r[n],i=e[n];if(typeof i!==typeof o||Array.isArray(i)!==Array.isArray(o)){let a=t?.mismatch?.(n,i,o,e,r);if(a!==void 0){r[n]=a;continue}throw Error(`Type mismatch: ${n}`)}let l=t?.mode?.(n,i,o,e,r)??r[".merge"]??"merge";switch(l){case"source":r[n]=i;continue;case"target":continue;case"skip":delete r[n],delete e[n];continue;case"merge":break;default:throw Error(`Unknown merge mode: ${l}`)}if(typeof i==="object")if(Array.isArray(i))o.push(...i);else{if(t?.navigate?.(n,i,o,e,r)===!1)continue;U(i,o,t)}else{if(i===o)continue;let a=t?.conflict?.(n,i,o,e,r);r[n]=a===void 0?o:a}}for(let n of Object.keys(e))if(r[n]===void 0)r[n]=e[n]},z=(e,r)=>{let t={};for(let n of e.toReversed())U(n,t,r);return t};var qr={};C(qr,{CacheManager:()=>We});class We{cache=new Map;maxSize;constructor(e=100){this.maxSize=e}get(e){return this.cache.get(e)}set(e,r){this.evictIfNeeded(),this.cache.set(e,r)}has(e){return this.cache.has(e)}clear(){this.cache.clear()}setMaxSize(e){this.maxSize=e}size(){return this.cache.size}evictIfNeeded(){if(this.cache.size>=this.maxSize){let e=null,r=1/0;for(let[t,n]of this.cache.entries())if(n.timestamp<r)r=n.timestamp,e=t;if(e)this.cache.delete(e)}}}var Jr={};C(Jr,{select:()=>x});var zo=Object.create,{getPrototypeOf:Jo,defineProperty:zr,getOwnPropertyNames:ei}=Object,ri=Object.prototype.hasOwnProperty,ti=(e,r,t)=>{t=e!=null?zo(Jo(e)):{};let n=r||!e||!e.__esModule?zr(t,"default",{value:e,enumerable:!0}):t;for(let o of ei(e))if(!ri.call(n,o))zr(n,o,{get:()=>e[o],enumerable:!0});return n},ni=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),oi=ni((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,i=Object.prototype.hasOwnProperty,l=new WeakMap,a=(u)=>{var d=l.get(u),v;if(d)return d;if(d=t({},"__esModule",{value:!0}),u&&typeof u==="object"||typeof u==="function")n(u).map((g)=>!i.call(d,g)&&t(d,g,{get:()=>u[g],enumerable:!(v=o(u,g))||v.enumerable}));return l.set(u,d),d},c=(u,d)=>{for(var v in d)t(u,v,{get:d[v],enumerable:!0,configurable:!0,set:(g)=>d[v]=()=>g})},w={};c(w,{splitWithQuotes:()=>y,splitNested:()=>O}),r.exports=a(w);var O=(u,d,v="(",g=")")=>{let A=0,f="",S=[];for(let b of u){if(f+=b,b===v)A++;if(b===g)A--;if(A===0&&b===d)S.push(f.slice(0,-1)),f=""}if(f)S.push(f);return S},y=(u,d=",")=>{let v=[],g=u.length,A=d.length,f=0,S=(b)=>{if(b+A>g)return!1;for(let M=0;M<A;M++)if(u[b+M]!==d[M])return!1;return!0};while(f<g){while(f<g&&u[f]===" ")f++;if(f>=g)break;let b="",M=u[f]==='"'||u[f]==="'";if(M){let k=u[f++];while(f<g&&u[f]!==k)b+=u[f++];if(f<g)f++}else{while(f<g&&!S(f)){let k=u[f];if(k==='"'||k==="'"){b+=k,f++;while(f<g&&u[f]!==k)b+=u[f++];if(f<g)b+=u[f++]}else b+=u[f++]}b=b.trim()}if(b)v.push({value:b,quoted:M});if(S(f))f+=A}return v}}),ii=ti(oi(),1),si=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,ai=/^([^[\]]*)\[([^\]]*)]$/,wr=(e,r,t,n)=>{if(e.startsWith("{")&&e.endsWith("}")){let o=e.substring(1,e.length-1);return x(r,o,t)?.toString()}return n?e:void 0},li=(e,r,t,n)=>{let o=wr(r,t,n);if(o)return x(e,o,n);let i=si.exec(r);if(i){let[,a,c,w]=i,O=wr(a.trim(),t,n,!0),y=wr(w.trim(),t,n,!0);if(Array.isArray(e)&&(c==="="||c==="==")&&O)return e.find((u)=>u?.[O]==y)}let l=ai.exec(r);if(l){let[,a,c]=l;return e?.[a]?.[c]}return e?.[r]},x=(e,r,t)=>{let n=void 0,o=void 0,i=r??"",l=(y)=>{if(!y)return[y,!1];return y.endsWith("?")?[y.substring(0,y.length-1),!0]:[y,!1]},a=(y,u)=>{let[d,v]=l(u.pop());if(!d){if(t?.set!==void 0&&o!==void 0&&n!==void 0)n[o]=t.set;return y}let g=li(y,d,e,t);if(g===void 0){if(v||t?.optional||t?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${d}" in "${i}"`)}return n=y,o=d,a(g,u)},c=ii.splitNested(i,t?.separator??".","{","}"),w=void 0;if(c.length>0&&c[c.length-1].startsWith("?="))w=c.pop()?.substring(2);c.reverse();let O=a(e,c);if(O===void 0)return w??t?.defaultValue;return O};var Ne=(e)=>{if(typeof e.value==="string")return e.parent;let r=e.value.model;if(!r)return e.parent;if(typeof r==="string")return x(e.root,r);return r};var Ke=(e)=>{if(typeof e.value==="string")return x(e.root,e.value);if(Array.isArray(e.value))return e.value;let r=e.value;if(typeof r.from==="string")return x(e.root,r.from);return r.from};var Ue=async(e,r)=>{let t=e.value;if(t.selector===void 0)return r;if(typeof t.selector!=="string"){let n=JSON.parse(JSON.stringify(t.selector));return await $(n,{...e.options,root:{...e.root,result:r}}),n}return await x({...e.root,result:r},t.selector)};var et={};C(et,{PathManager:()=>H});import J from"path";class H{constructor(){}static normalize(e){return J.normalize(J.resolve(e))}static resolveInContext(e,r){let t=r??process.cwd(),n=J.isAbsolute(e)?e:J.join(t,e);return this.normalize(n)}static isDirectoryPattern(e){return e.endsWith("/")}static isGlobPattern(e){return e.includes("*")}static toAbsolute(e,r){if(J.isAbsolute(e))return e;return J.join(r??process.cwd(),e)}}var rt={};C(rt,{conditionPredicatesTypes:()=>ye,conditionPredicates:()=>K});var K={and:(...e)=>e.every((r)=>!!r),or:(...e)=>e.some((r)=>!!r),xor:(...e)=>e.filter((r)=>!!r).length===1,true:(...e)=>e.every((r)=>!!r),false:(...e)=>e.every((r)=>!r),eq:(...e)=>e.every((r)=>r===e[0]),ne:(...e)=>e.some((r)=>r!==e[0]),lt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<r),le:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<=r),gt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>r),ge:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>=r),in:(e,r)=>{if(Array.isArray(r))return r.includes(e);if(typeof e==="string")return e.includes(r);if(Array.isArray(e))return e.includes(r);return!1},notin:(e,r)=>!K.in(e,r),contains:(e,r)=>e.includes(r),notcontains:(e,r)=>!e.includes(r),containsi:(e,r)=>e.toLowerCase().includes(r.toLowerCase()),notcontainsi:(e,r)=>!e.toLowerCase().includes(r.toLowerCase()),null:(...e)=>e.every((r)=>r===null||r===void 0),notnull:(...e)=>e.every((r)=>r!==null&&r!==void 0),empty:(...e)=>e.every((r)=>r===""),notempty:(...e)=>e.every((r)=>r!==""),nullorempty:(...e)=>e.every((r)=>r===null||r===void 0||r===""),notnullorempty:(...e)=>e.every((r)=>r!==null&&r!==void 0&&r!=="")},ye={and:()=>"boolean",or:()=>"boolean",xor:()=>"boolean",true:()=>"boolean",false:()=>"boolean",lt:()=>"number",le:()=>"number",gt:()=>"number",ge:()=>"number"};var tt=()=>({each:{filters:[/select|model/],fn:async(e)=>{let r=e.value;delete e.parent[e.key];let t=await Ke(e),n=await Ne(e);if(!Array.isArray(t))throw Error('Key "each" requires a source list');if(n===void 0)throw Error('Key "each" must define a model');if(r.extend?.model)n=z([r.model,...Array.isArray(r.extend.model)?r.extend.model:[r.extend.model]]);let o=[];for(let i=0;i<t.length;i++){let l=W(n);if(await $(l,{...e.options,root:{...e.root,index:i,item:t[i],instance:l}}),r.extend?.result){let a=r.extend.result;l=z([l,...Array.isArray(a)?a:[a]])}o.push(await Ue(e,l))}return o}}});var nt=()=>({map:{filters:[/select|model/],fn:async(e)=>{delete e.parent[e.key];let r=await Ke(e),t=await Ne(e);if(!Array.isArray(r))throw Error('Key "map" requires a source list');if(t===void 0)throw Error('Key "map" must define a model');let n=[];for(let o=0;o<r.length;o++){let i=W(t);await $(i,{...e.options,root:{...e.root,index:o,item:r[o],instance:i}}),n.push(await Ue(e,i))}return n}}});var ot=()=>({concat:async(e)=>{let r=[];for(let t of Array.isArray(e.value)?e.value:[e.value])r.push(...await x(e.root,t));return r.filter((t)=>t!==void 0)}});var it=()=>({extends:async(e)=>{let r=async(t,n)=>{for(let o of Array.isArray(n)?n:[n]){let i=await x(e.root,o),l=W(i);if(l[e.key])await r(l,l[e.key]);await $(l,{...e.options}),U(l,t),delete t[e.key]}};return await r(e.parent,e.value),E.Explore()},group:(e)=>{let r=e.root.parent,t=e.value,{items:n,...o}=t;return t.items.forEach((i)=>r.push({...o,...i})),E.DeleteParent()}});var st=(e)=>({skip:{types:{0:"boolean"},fn:(r)=>r.value?E.DeleteParent():E.DeleteItem()},metadata:({path:r,value:t})=>{return e.metadata(r,t),E.DeleteItem()},if:{types:{0:"boolean"},fn:async(r)=>{let t=r.parent[".then"],n=r.parent[".else"];if(t!==void 0)delete r.parent[".then"];if(n!==void 0)delete r.parent[".else"];let o=r.value?t:n;if(o===void 0)return E.DeleteItem();if(typeof o==="string")return(await $({value:o},{...r.options,root:{...r.root}})).value;return E.ReplaceParent(o,!0)}},switch:(r)=>{let t=r.value;if(!t.cases)throw Error("Missing cases for switch");if(t.cases[t.from]!==void 0)return E.ReplaceParent(t.cases[t.from],!0);if(t.default!==void 0)return E.ReplaceParent(t.default,!0);return E.DeleteParent()}});var at=()=>({from:async({root:e,parent:r,value:t})=>{let n=await x(e,t);if(n===null||n===void 0)throw Error(`Unable to resolve reference: ${t}`);if(r.content){if(Array.isArray(r.content)&&Array.isArray(n))return[...n,...r.content];return U(n,r.content),r.content}return n}});import lt from"node:vm";var ut=(e)=>({modules:async(r)=>{for(let[t,n]of Object.entries(r.value)){let o=lt.createContext({console,objector:e,document:r.root}),i=new lt.SourceTextModule(n,{identifier:t,context:o});await i.link((l)=>{throw Error(`Module ${l} is not allowed`)}),await i.evaluate(),e.sources(Object.fromEntries(Object.entries(i.namespace).map(([l,a])=>[`${t}.${l}`,(c)=>a(c,...c.args)])))}return E.DeleteItem()}});var ct=()=>({try:{fn:(e)=>{let r=e.parent[".catch"];if(r!==void 0)delete e.parent[".catch"];try{return e.value}catch(t){if(r!==void 0)return r;return E.DeleteItem()}}}});var ft=()=>({let:{fn:(e)=>{let r=e.value;return Object.assign(e.root,r),E.DeleteItem()}}});var pt=()=>({tap:{fn:(e)=>{return console.log(`[tap] ${e.path}:`,e.value),e.value}}});var ui=(e,r)=>{let t=r.section.config.using,n=e.getFunctions();return t?Object.fromEntries(t.map((o)=>{if(o in n)return[o,n[o]];if(o in r.root)return[o,r.root[o]];throw Error(`Function or variable "${o}" not found for script section`)})):n},br=(e,r,t,n,o=[])=>{let i=ui(e,t),l=["section","context","config","system",...Object.keys(i),...o],a=[r,t.root,t.section.config,e,...Object.values(i)];return[new AsyncFunction(...l,n).bind(t),a]},ci=(e,r)=>{let t={write:(...n)=>{return r.push(...n),t},writeLine:(...n)=>{return r.push(...n.map((o)=>o+`
10
10
  `)),t},clear:()=>{return r.splice(0,r.length),t},prepend:(...n)=>{return r.unshift(...n),t},prependLine:(...n)=>{return r.unshift(...n.map((o)=>o+`
11
- `)),t},setOptions:(n)=>{return Object.assign(e.section,n),t},use:(n)=>{return n(t),t},getLines:()=>r};return t},pi=async(e,r,t)=>{let n=t.section.config.condition;if(n!==void 0){let[o,i]=mr(e,r,t,`return (${n})`);if(!await o(...i))return!1}return!0},mt=(e)=>async(r)=>{let t=[],n=ui(r,t);if(!await pi(e,n,r))return!1;let[o,i]=mr(e,n,r,r.section.content,["item"]),l=r.section.config.each;if(l){let[a,p]=mr(e,n,r,`return (${l})`),h=Array.isArray(l)?l:await a(...p);if(!Array.isArray(h))throw Error('The "each" property of a script section must return an array');for(let O of h){let y=await o(...i,O);if(typeof y<"u")t.push(y)}}else{let a=await o(...i);if(typeof a<"u")return a}if(t.length===0)return!1;return t.join("")};var gt=(e)=>({script:mt(e)});import yt from"fs/promises";import de from"path";var dt=(e)=>({include:async(r)=>{let{file:t}=r.options.globalContext;return await ce(r.args[0],{cwd:de.dirname(t),filter:(n)=>de.basename(t)!==n,map:async(n)=>e.load(n,de.dirname(t),r.root)})},exists:async({args:[r]})=>await q(r),file:async(r)=>await yt.readFile(await V(r.args[0],e.getIncludeDirectories())).then((t)=>t.toString()),scan:async(r)=>{let t=[],o=(()=>{let a=r.args[2]??["**/node_modules/**"],p=typeof a==="string"?a.split(",").map((h)=>h.trim()):a;if(!Array.isArray(p))throw Error("Scan exclusion must be a list");return p})(),{file:i}=r.options.globalContext,l=r.args[1]?await V(r.args[1],e.getIncludeDirectories()):de.dirname(i);for await(let a of yt.glob(r.args[0],{cwd:l,exclude:(p)=>o.some((h)=>de.matchesGlob(p,h))}))t.push(a);return t}});var wt={};W(wt,{tokenize:()=>yr,stripIndent:()=>dr,snake:()=>re,pascal:()=>ee,padBlock:()=>T,changeCase:()=>te,capital:()=>we,camel:()=>he});var ee=(e)=>e.replace(/((?:[_ ]+)\w|^\w)/g,(r,t)=>t.toUpperCase()).replace(/[_ ]/g,""),we=(e)=>e.replace(/((?:[ ]+)\w|^\w)/g,(r,t)=>t.toUpperCase()),he=(e)=>{let r=ee(e);return r.charAt(0).toLowerCase()+r.slice(1)},re=(e,r="_")=>e.replace(/([a-z])([A-Z])/g,`$1${r}$2`).replace(/\s+/g,r).toLowerCase(),te=(e,r)=>{switch(r){case"upper":return e.toUpperCase();case"lower":return e.toLowerCase();default:return e}},T=(e,r,t=`
12
- `,n=" ")=>{let o=n.repeat(r);return e.split(t).map((i)=>o+i).join(t)},yr=(e,r,t=/\${([^}]+)}/g)=>{return e.replace(t,(n,o)=>{let i=r[o];if(i===null||i===void 0)return"";if(typeof i==="string")return i;if(typeof i==="number"||typeof i==="boolean")return String(i);return String(i)})},dr=(e)=>{let r=e.split(/\r?\n/),t=r.filter((o)=>o.trim().length>0).map((o)=>/^[ \t]*/.exec(o)?.[0].length??0),n=t.length>0?Math.min(...t):0;if(n===0)return e;return r.map((o)=>o.slice(n)).join(`
13
- `)};var ht=(e)=>({substring:{types:{0:"ref",1:"number",2:"number"},fn:(r)=>r.args[0].substring(r.args[1],r.args[2])},repeat:{types:{0:"ref",1:"number"},fn:({args:[r,t]})=>r.repeat(t)},pad:{types:{0:"ref",1:"number",2:"string"},fn:({args:[r,t],tags:n})=>{let o=n.join?.[0]??`
14
- `,i=n.padChar?.[0]??" ";return T(r,t??2,o,i)}},formatAs:{fn:({args:[r,t],tags:n})=>{let o=e.getEncoder(t);if(!o)throw Error("Unsupported format: "+String(t));let i=[];if(o.options?.includeTags)i=[n];return o.fn(r,...i)}}});var Ue=(e,r=0,t)=>{let n=" ".repeat(r),o=" ".repeat(r+1);if(e===null||e===void 0)return"null";else if(typeof e==="boolean")return String(e);else if(typeof e==="number")return String(e);else if(typeof e==="string")return`"${e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`;else if(Array.isArray(e)){if(e.length===0)return"[]";return`[
15
- ${e.map((l)=>`${o}${Ue(l,r+1)},`).join(`
11
+ `)),t},setOptions:(n)=>{return Object.assign(e.section,n),t},use:(n)=>{return n(t),t},getLines:()=>r};return t},fi=async(e,r,t)=>{let n=t.section.config.condition;if(n!==void 0){let[o,i]=br(e,r,t,`return (${n})`);if(!await o(...i))return!1}return!0},mt=(e)=>async(r)=>{let t=[],n=ci(r,t);if(!await fi(e,n,r))return!1;let[o,i]=br(e,n,r,r.section.content,["item"]),l=r.section.config.each;if(l){let[a,c]=br(e,n,r,`return (${l})`),w=Array.isArray(l)?l:await a(...c);if(!Array.isArray(w))throw Error('The "each" property of a script section must return an array');for(let O of w){let y=await o(...i,O);if(typeof y<"u")t.push(y)}}else{let a=await o(...i);if(typeof a<"u")return a}if(t.length===0)return!1;return t.join("")};var gt=(e)=>({script:mt(e)});import yt from"fs/promises";import de from"path";var dt=(e)=>({include:async(r)=>{let{file:t}=r.options.globalContext;return await pe(r.args[0],{cwd:de.dirname(t),filter:(n)=>de.basename(t)!==n,map:async(n)=>e.load(n,de.dirname(t),r.root)})},exists:async({args:[r]})=>await q(r),file:async(r)=>await yt.readFile(await X(r.args[0],e.getIncludeDirectories())).then((t)=>t.toString()),scan:async(r)=>{let t=[],o=(()=>{let a=r.args[2]??["**/node_modules/**"],c=typeof a==="string"?a.split(",").map((w)=>w.trim()):a;if(!Array.isArray(c))throw Error("Scan exclusion must be a list");return c})(),{file:i}=r.options.globalContext,l=r.args[1]?await X(r.args[1],e.getIncludeDirectories()):de.dirname(i);for await(let a of yt.glob(r.args[0],{cwd:l,exclude:(c)=>o.some((w)=>de.matchesGlob(c,w))}))t.push(a);return t}});var ht={};C(ht,{tokenize:()=>Or,stripIndent:()=>Ar,snake:()=>re,pascal:()=>ee,padBlock:()=>_,changeCase:()=>te,capital:()=>he,camel:()=>we});var ee=(e)=>e.replace(/((?:[_ ]+)\w|^\w)/g,(r,t)=>t.toUpperCase()).replace(/[_ ]/g,""),he=(e)=>e.replace(/((?:[ ]+)\w|^\w)/g,(r,t)=>t.toUpperCase()),we=(e)=>{let r=ee(e);return r.charAt(0).toLowerCase()+r.slice(1)},re=(e,r="_")=>e.replace(/([a-z])([A-Z])/g,`$1${r}$2`).replace(/\s+/g,r).toLowerCase(),te=(e,r)=>{switch(r){case"upper":return e.toUpperCase();case"lower":return e.toLowerCase();default:return e}},_=(e,r,t=`
12
+ `,n=" ")=>{let o=n.repeat(r);return e.split(t).map((i)=>o+i).join(t)},Or=(e,r,t=/\${([^}]+)}/g)=>{return e.replace(t,(n,o)=>{let i=r[o];if(i===null||i===void 0)return"";if(typeof i==="string")return i;if(typeof i==="number"||typeof i==="boolean")return String(i);return String(i)})},Ar=(e)=>{let r=e.split(/\r?\n/),t=r.filter((o)=>o.trim().length>0).map((o)=>/^[ \t]*/.exec(o)?.[0].length??0),n=t.length>0?Math.min(...t):0;if(n===0)return e;return r.map((o)=>o.slice(n)).join(`
13
+ `)};var wt=(e)=>({substring:{types:{0:"ref",1:"number",2:"number"},fn:(r)=>r.args[0].substring(r.args[1],r.args[2])},repeat:{types:{0:"ref",1:"number"},fn:({args:[r,t]})=>r.repeat(t)},pad:{types:{0:"ref",1:"number",2:"string"},fn:({args:[r,t],tags:n})=>{let o=n.join?.[0]??`
14
+ `,i=n.padChar?.[0]??" ";return _(r,t??2,o,i)}},formatAs:{fn:({args:[r,t],tags:n})=>{let o=e.getEncoder(t);if(!o)throw Error("Unsupported format: "+String(t));let i=[];if(o.options?.includeTags)i=[n];return o.fn(r,...i)}}});var Ie=(e,r=0,t)=>{let n=" ".repeat(r),o=" ".repeat(r+1);if(e===null||e===void 0)return"null";else if(typeof e==="boolean")return String(e);else if(typeof e==="number")return String(e);else if(typeof e==="string")return`"${e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`;else if(Array.isArray(e)){if(e.length===0)return"[]";return`[
15
+ ${e.map((l)=>`${o}${Ie(l,r+1)},`).join(`
16
16
  `)}
17
- ${n}]`}else if(typeof e==="object"){let i=Object.entries(e).sort((a,p)=>t?.sortKeys?a[0].localeCompare(p[0]):0);if(i.length===0)return"{}";return`{
18
- ${i.map(([a,p])=>`${o}${a} = ${Ue(p,r+1,t)}`).join(`
17
+ ${n}]`}else if(typeof e==="object"){let i=Object.entries(e).sort((a,c)=>t?.sortKeys?a[0].localeCompare(c[0]):0);if(i.length===0)return"{}";return`{
18
+ ${i.map(([a,c])=>`${o}${a} = ${Ie(c,r+1,t)}`).join(`
19
19
  `)}
20
20
  ${n}}`}else return String(e)},be=(e)=>{if(!e)return e;return e.replaceAll("\\n",`
21
- `).replaceAll("\\$","$").replaceAll("\\t","\t")};var bt=()=>({...K({merge:(...e)=>e.flatMap((r)=>r)}),join:({args:[e],root:r,tags:t})=>{let n=t.key?.[0],o=t.separator?.[0]??t.sep?.[0],i=t.finalize?.length>0,l=be(o);if(typeof e==="string"){if(i&&e.length&&l)return e+l;return e}if(!Array.isArray(e))throw Error("Object is not a list");let a=((n?.length)?e.map((y)=>D({...r,...y},n)):e).join(l),p=t.pad?.[0]??"0",h=t.padChar?.[0]??" ",O=i&&a.length&&l?a+l:a;return p?T(O,parseInt(p),`
22
- `,h):O},range:({args:[e,r,t]})=>{let n=parseInt(e),o=parseInt(r),i=parseInt(t)||1;if(isNaN(n))throw Error("Invalid range: start value '"+String(e)+"' is not a number");if(isNaN(o))throw Error("Invalid range: end value '"+String(r)+"' is not a number");if(i===0)throw Error("Invalid range: step cannot be zero");if((o-n)/i<0)throw Error("Invalid range: step "+String(i)+" has wrong direction for range "+String(n)+" to "+String(o));return Array.from({length:Math.floor((o-n)/i)+1},(l,a)=>n+a*i)},filter:{types:(e,r,t)=>{switch(e){case 0:return"array";case 1:return Object.keys(L)}return ye[t[1].value]?.(e-2,r,t.slice(2))},fn:({args:[e,r,t],root:n,tags:o})=>{if(e===null||e===void 0)throw Error("Filter source cannot be null or undefined");if(!Array.isArray(e))throw Error("Filter source must be an array");let i=o.key?.[0],l=L[r];if(i){let p=Array(e.length);for(let O=0;O<e.length;O++)try{p[O]=D({...n,...e[O]},i)}catch{p[O]=Symbol("invalid")}let h=[];for(let O=0;O<e.length;O++){let y=p[O];if(typeof y!=="symbol"&&t===void 0?l(y):l(y,t))h.push(e[O])}return h}let a=[];for(let p of e)if(t===void 0?l(p):l(p,t))a.push(p);return a}}});var Ot=()=>({each:{processArgs:!1,fn:async({rawArgs:[e,r,...t],root:n,options:o,tags:i})=>{let l=async(g)=>g.quoted?be(g.value):await D(n,g.value),a=await D(n,e.value),p=await l(r),h=i.key?.[0],O=Array.isArray(a)?a:Z(a),y=[],u=await Promise.all(t.map(async(g)=>await l(g))),d={...n,item:void 0,index:0,params:u,instance:void 0,parent:n.this,tags:i},A={...o,root:d};for(let g=0;g<O.length;g++){let v=I(p),f={instance:v},j=typeof p==="string"?f:v;if(d.item=O[g],d.index=g,d.instance=v,i?.root?.[0])Object.assign(d,await D(d,i.root[0]));if(await C(j,A),h!==void 0)y.push(await D(f.instance,h));else y.push(f.instance)}if(i.join?.length){if(y.length===0)return"";let g=be(i.join[0]),v=i.pad?.[0]??"0",f=i.padChar?.[0]??" ",j=i.finalize?.length&&g?g:"",b=`${y.join(g)}${j}`;return v?T(b,parseInt(v),`
23
- `,f):b}return y}}});var Oe=async(e,r,t)=>e.rawArgs[r].quoted?e.rawArgs[r].value:await D(e.root,e.rawArgs[r].value,{defaultValue:t}),vt=()=>({switch:{processArgs:!1,fn:async(e)=>{let r=await Oe(e,0,!1),t=await Oe(e,1);if(t[r]===void 0){if(e.rawArgs.length>2)return Oe(e,2);throw Error(`Unhandled switch case: ${r}`)}return t[r]}}});var At=()=>({if:{types:{0:"boolean"},fn:(e)=>e.args[0]?e.args[1]:e.args[2]},check:{types:{0:Object.keys(L)},fn:(e)=>L[e.args[0]](...e.args.slice(1))},...K(L,{types:ye})});var Et=(e)=>({default:{processArgs:!1,fn:async(r)=>{for(let t=0;t<r.rawArgs.length;t++)if(r.rawArgs[t]?.value!==void 0){let o=await Oe(r,t,null);if(o!==null)return o}if(r.tags.nullable?.length)return M.DeleteItem();if(r.tags.fail?.length)throw Error(`No valid value found for default (${r.rawArgs.map((t)=>t.value).join(", ")})`);return""}},section:{types:["string","boolean"],fn:(r)=>{let t=r.args[0];if(!(r.args[1]??!0))return null;let o=e.getSection(t);if(!o)throw Error(`Section not found: ${t}`);return o.content}}});var Mt=()=>({convert:({args:[e,r,t]})=>{switch(r){case"string":return String(e);case"number":{let n=Number(e);if(!isNaN(n))return M.ReplaceItem(n);break}case"boolean":if(e==="true"||e===!0||e===1||e==="1"||e==="yes"||e==="on")return M.ReplaceItem(!0);else if(e==="false"||e===!1||e===0||e==="0"||e==="no"||e==="off")return M.ReplaceItem(!1);break;default:throw Error(`Unsupported type for convert: ${r}`)}if(t!==void 0)return M.ReplaceItem(t);throw Error(`Failed to convert value to ${r}`)},isType:({args:[e,r]})=>{let n=(()=>{switch(r){case"string":return typeof e==="string";case"number":return typeof e==="number";case"boolean":return typeof e==="boolean";case"object":return e!==null&&typeof e==="object"&&!Array.isArray(e);case"array":return Array.isArray(e);case"null":return e===null;case"undefined":return e===void 0;case"function":return typeof e==="function";default:throw Error(`Unknown type for isType: ${r}`)}})();return M.ReplaceItem(n)},typeOf:({args:[e]})=>{if(e===null)return"null";else if(Array.isArray(e))return"array";else return typeof e}});var wr=(e)=>{var r,t,n,o,i,l,a,p,h,O,y,u,d,A,g,v,f,j,b,S,k,Ae,G,B,Ee,Me,Se,oe,Ye,je,Ge,Ct,Wt,Nt,It,Lt,_t,Ut,Bt,Tt,Kt,Yt,Gt,Qt,Xt,Vt,Zt,Ht,Pt,qt,zt,Jt,en,rn,tn,nn,on,sn,an,ln,un,pn,fn,cn,mn,gn,yn,dn,wn,hn,bn,On,vn,An,En,Mn,Sn,jn,kn,Dn,Fn,Rn,xn,$n,Cn,Wn,Nn,In,Ln,_n,Un,Bn,Tn,Kn,Yn,Gn,Qn,Xn,Vn,Zn,Hn,Pn,qn,zn,o,i,l,a,p,h,O,y,u,d,A,g,v,f,j,b,S,k,Ae,G,B,Ee,Me,Se,oe,Ye,je,Ge,Ct,Wt,Nt,It,Lt,_t,Ut,Bt,Tt,Kt,Yt,Gt,Qt,Xt,Vt,Zt,Ht,Pt,qt,zt,Jt,en,rn,tn,nn,on,sn,an,ln,un,pn,fn,cn,mn,gn,yn,dn,wn,hn,bn,On,vn,An,En,Mn,Sn,jn,kn,Dn,Fn,Rn,xn,$n,Cn,Wn,Nn,In,Ln,_n,Un,Bn,Tn,Kn,Yn,Gn,Qn,Xn,Vn,Zn,Hn,Pn,qn,zn;return e.use((n=H,o=[c()],i=[c()],l=[c()],a=[c()],p=[c()],h=[c()],O=[c()],y=[c()],u=[c()],d=[c()],A=[c()],g=[c()],v=[c()],f=[c()],j=[c()],b=[c()],S=[c()],k=[c()],Ae=[c()],G=[c()],B=[c()],Ee=[c()],Me=[c()],Se=[c()],oe=[c()],Ye=[c()],je=[c()],Ge=[c()],Ct=[c()],Wt=[c()],Nt=[c()],It=[c()],Lt=[c()],_t=[c()],Ut=[c()],Bt=[c()],Tt=[c()],Kt=[c()],Yt=[c()],Gt=[c()],Qt=[c()],Xt=[c()],Vt=[c()],Zt=[c()],Ht=[c()],Pt=[c()],qt=[c()],zt=[c()],Jt=[c()],en=[c()],rn=[c()],tn=[c()],nn=[c()],on=[c()],sn=[c()],an=[c()],ln=[c()],un=[c()],pn=[c()],fn=[c()],cn=[c()],mn=[c()],gn=[c()],yn=[c()],dn=[c()],wn=[c()],hn=[c()],bn=[c()],On=[c()],vn=[c()],An=[c()],En=[c()],Mn=[c()],Sn=[c()],jn=[c()],kn=[c()],Dn=[c()],Fn=[c()],Rn=[c()],xn=[c()],$n=[c()],Cn=[c()],Wn=[c()],Nn=[c()],In=[c()],Ln=[c()],_n=[c()],Un=[c()],Bn=[c()],Tn=[c()],Kn=[c()],Yn=[c()],Gn=[c()],Qn=[c()],Xn=[c()],Vn=[c()],Zn=[c()],Hn=[c()],Pn=[c()],qn=[c()],zn=[c()],t=Sr(n),r=class extends n{constructor(){super(...arguments);kr(t,5,this)}env(s){return process.env[s]}uuid(){return crypto.randomUUID()}pascal(s){return ee(s)}camel(s){return he(s)}capital(s){return we(s)}snake(s,w){return te(re(s,"_"),w)}kebab(s,w){return te(re(s,"-"),w)}len(s){return s.length}reverse(s){return s.split("").reverse().join("")}concat(...s){return s.join("")}trim(s){return s.trim()}ltrim(s){return s.trimStart()}rtrim(s){return s.trimEnd()}lower(s){return s.toLowerCase()}upper(s){return s.toUpperCase()}encode(s,w){return Buffer.from(s).toString(w??"base64")}decode(s,w){return Buffer.from(s,w??"base64").toString()}list(s,w){return Z(s,w)}object(s,w){return ge(s,w)}pathJoin(...s){return Y.join(...s)}resolve(...s){return Y.resolve(...s)}dirname(s){return Y.dirname(s)}basename(s,w){return Y.basename(s,w)}normalize(s){return Y.normalize(s)}extname(s){return Y.extname(s)}relative(s,w){return Y.relative(s,w)}isAbsolute(s){return Y.isAbsolute(s)}segments(s){return s.split("/").filter(Boolean)}log(...s){console.log(...s)}md5(s){return ne("md5").update(s).digest("hex")}sha1(s){return ne("sha1").update(s).digest("hex")}sha256(s){return ne("sha256").update(s).digest("hex")}sha512(s){return ne("sha512").update(s).digest("hex")}hash(s,w="sha256"){return ne(w).update(s).digest("hex")}hmac(s,w,E="sha256"){return ne(E).update(s).digest("hex")}base64Encode(s){return Buffer.from(s).toString("base64")}base64Decode(s){return Buffer.from(s,"base64").toString("utf-8")}hexEncode(s){return Buffer.from(s).toString("hex")}hexDecode(s){return Buffer.from(s,"hex").toString("utf-8")}add(...s){return s.reduce((w,E)=>w+E,0)}subtract(s,w){return s-w}multiply(...s){return s.reduce((w,E)=>w*E,1)}divide(s,w){if(w===0)throw Error("Division by zero");return s/w}modulo(s,w){return s%w}power(s,w){return Math.pow(s,w)}sqrt(s){return Math.sqrt(s)}abs(s){return Math.abs(s)}floor(s){return Math.floor(s)}ceil(s){return Math.ceil(s)}round(s,w){let E=Math.pow(10,w??0);return Math.round(s*E)/E}min(...s){return Math.min(...s)}max(...s){return Math.max(...s)}clamp(s,w,E){return Math.max(w,Math.min(E,s))}random(s,w){let E=s??0,$=w??1;return Math.random()*($-E)+E}timestamp(s){return new Date(s).getTime()}iso(s){return new Date(s).toISOString()}utc(s){return new Date(s).toUTCString()}formatDate(s,w){let E=new Date(s),$=E.getFullYear(),U=String(E.getMonth()+1).padStart(2,"0"),ke=String(E.getDate()).padStart(2,"0"),ie=String(E.getHours()).padStart(2,"0"),Jn=String(E.getMinutes()).padStart(2,"0"),eo=String(E.getSeconds()).padStart(2,"0");return w.replace("YYYY",String($)).replace("MM",U).replace("DD",ke).replace("HH",ie).replace("mm",Jn).replace("ss",eo)}parseDate(s){return new Date(s).getTime()}year(s){return new Date(s).getFullYear()}month(s){return new Date(s).getMonth()+1}day(s){return new Date(s).getDate()}dayOfWeek(s){return new Date(s).getDay()}hours(s){return new Date(s).getHours()}minutes(s){return new Date(s).getMinutes()}seconds(s){return new Date(s).getSeconds()}regexTest(s,w,E){return new RegExp(s,E).test(w)}regexMatch(s,w,E){return new RegExp(s,E).exec(w)}regexMatchAll(s,w,E){return Array.from(w.matchAll(new RegExp(s,E)))}regexReplace(s,w,E,$){return E.replace(new RegExp(s,$),w)}regexReplaceAll(s,w,E,$){return E.replace(new RegExp(s,$??"g"),w)}regexSplit(s,w,E){return w.split(new RegExp(s,E))}regexExec(s,w,E){return new RegExp(s,E).exec(w)}regexSearch(s,w,E){return w.search(new RegExp(s,E))}unique(s,w){if(!Array.isArray(s))return s;let E=new Set;return s.filter(($)=>{let U=w?$[w]:$;if(E.has(U))return!1;return E.add(U),!0})}groupBy(s,w){if(!Array.isArray(s))return s;let E={};return s.forEach(($)=>{let U=String($[w]);if(!E[U])E[U]=[];E[U].push($)}),E}chunk(s,w=1){if(!Array.isArray(s))return[];let E=[];for(let $=0;$<s.length;$+=w)E.push(s.slice($,$+w));return E}flatten(s,w=1){if(!Array.isArray(s))return[s];let E=[],$=(U,ke)=>{for(let ie of U)if(Array.isArray(ie)&&ke>0)$(ie,ke-1);else E.push(ie)};return $(s,w),E}compact(s){if(!Array.isArray(s))return s;return s.filter((w)=>w!==null&&w!==void 0)}head(s,w){if(!Array.isArray(s))return s;return w?s.slice(0,w):s[0]}tail(s,w){if(!Array.isArray(s))return s;return w?s.slice(-w):s[s.length-1]}isEmail(s){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s)}isUrl(s){try{return new URL(s),!0}catch{return!1}}isJson(s){try{return JSON.parse(s),!0}catch{return!1}}isUuid(s){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s)}minLength(s,w){return s?.length>=w}maxLength(s,w){return s?.length<=w}lengthEquals(s,w){return s?.length===w}isNumber(s){return typeof s==="number"&&!isNaN(s)}isString(s){return typeof s==="string"}isBoolean(s){return typeof s==="boolean"}isArray(s){return Array.isArray(s)}isObject(s){return s!==null&&typeof s==="object"&&!Array.isArray(s)}isEmpty(s){if(s===null||s===void 0)return!0;if(typeof s==="string"||Array.isArray(s))return s.length===0;if(typeof s==="object")return Object.keys(s).length===0;return!1}isTruthy(s){return!!s}isFalsy(s){return!s}inRange(s,w,E){return s>=w&&s<=E}matchesPattern(s,w){return new RegExp(w).test(s)}includes(s,w){if(typeof s==="string")return s.includes(String(w));return Array.isArray(s)&&s.includes(w)}startsWith(s,w){return s.startsWith(w)}endsWith(s,w){return s.endsWith(w)}},m(t,1,"env",o,r),m(t,1,"uuid",i,r),m(t,1,"pascal",l,r),m(t,1,"camel",a,r),m(t,1,"capital",p,r),m(t,1,"snake",h,r),m(t,1,"kebab",O,r),m(t,1,"len",y,r),m(t,1,"reverse",u,r),m(t,1,"concat",d,r),m(t,1,"trim",A,r),m(t,1,"ltrim",g,r),m(t,1,"rtrim",v,r),m(t,1,"lower",f,r),m(t,1,"upper",j,r),m(t,1,"encode",b,r),m(t,1,"decode",S,r),m(t,1,"list",k,r),m(t,1,"object",Ae,r),m(t,1,"pathJoin",G,r),m(t,1,"resolve",B,r),m(t,1,"dirname",Ee,r),m(t,1,"basename",Me,r),m(t,1,"normalize",Se,r),m(t,1,"extname",oe,r),m(t,1,"relative",Ye,r),m(t,1,"isAbsolute",je,r),m(t,1,"segments",Ge,r),m(t,1,"log",Ct,r),m(t,1,"md5",Wt,r),m(t,1,"sha1",Nt,r),m(t,1,"sha256",It,r),m(t,1,"sha512",Lt,r),m(t,1,"hash",_t,r),m(t,1,"hmac",Ut,r),m(t,1,"base64Encode",Bt,r),m(t,1,"base64Decode",Tt,r),m(t,1,"hexEncode",Kt,r),m(t,1,"hexDecode",Yt,r),m(t,1,"add",Gt,r),m(t,1,"subtract",Qt,r),m(t,1,"multiply",Xt,r),m(t,1,"divide",Vt,r),m(t,1,"modulo",Zt,r),m(t,1,"power",Ht,r),m(t,1,"sqrt",Pt,r),m(t,1,"abs",qt,r),m(t,1,"floor",zt,r),m(t,1,"ceil",Jt,r),m(t,1,"round",en,r),m(t,1,"min",rn,r),m(t,1,"max",tn,r),m(t,1,"clamp",nn,r),m(t,1,"random",on,r),m(t,1,"timestamp",sn,r),m(t,1,"iso",an,r),m(t,1,"utc",ln,r),m(t,1,"formatDate",un,r),m(t,1,"parseDate",pn,r),m(t,1,"year",fn,r),m(t,1,"month",cn,r),m(t,1,"day",mn,r),m(t,1,"dayOfWeek",gn,r),m(t,1,"hours",yn,r),m(t,1,"minutes",dn,r),m(t,1,"seconds",wn,r),m(t,1,"regexTest",hn,r),m(t,1,"regexMatch",bn,r),m(t,1,"regexMatchAll",On,r),m(t,1,"regexReplace",vn,r),m(t,1,"regexReplaceAll",An,r),m(t,1,"regexSplit",En,r),m(t,1,"regexExec",Mn,r),m(t,1,"regexSearch",Sn,r),m(t,1,"unique",jn,r),m(t,1,"groupBy",kn,r),m(t,1,"chunk",Dn,r),m(t,1,"flatten",Fn,r),m(t,1,"compact",Rn,r),m(t,1,"head",xn,r),m(t,1,"tail",$n,r),m(t,1,"isEmail",Cn,r),m(t,1,"isUrl",Wn,r),m(t,1,"isJson",Nn,r),m(t,1,"isUuid",In,r),m(t,1,"minLength",Ln,r),m(t,1,"maxLength",_n,r),m(t,1,"lengthEquals",Un,r),m(t,1,"isNumber",Bn,r),m(t,1,"isString",Tn,r),m(t,1,"isBoolean",Kn,r),m(t,1,"isArray",Yn,r),m(t,1,"isObject",Gn,r),m(t,1,"isEmpty",Qn,r),m(t,1,"isTruthy",Xn,r),m(t,1,"isFalsy",Vn,r),m(t,1,"inRange",Zn,r),m(t,1,"matchesPattern",Hn,r),m(t,1,"includes",Pn,r),m(t,1,"startsWith",qn,r),m(t,1,"endsWith",zn,r),Ze(t,r),r)).keys({...Zr(e),...Hr(e),...tt(),...nt(),...at(),...ot(),...it(),...st(e),...ut(e),...pt(),...ft(),...ct()}).sources({...dt(e),...ht(e),...Mt(),...bt(),...Ot(),...vt(),...At(),...Et(e)}).sections(gt(e)).fieldOptions({configParser:Bun.YAML.parse,onSection:(s)=>{if(s.section.config.name)e.section(s.section)}}).decoders({yaml:{matching:["\\.yml$","\\.yaml$"],fn:Bun.YAML.parse}}).encoders({json:{fn:(s)=>JSON.stringify(s,null,2)},yaml:{fn:(s)=>Bun.YAML.stringify(s,null,2)},terraform:{options:{includeTags:!0},fn:(s,w)=>Ue(s,0,{sortKeys:!!(w?.sort?.length??w?.sortKeys?.length)})}})};var jt={};W(jt,{IncludeManager:()=>Be,DocumentIncludeProcessor:()=>Te});import fi from"fs/promises";import ve from"path";class Be{includeDirectories=[];baseIncludeDirectories=[];includes=[];addDirectories(...e){this.includeDirectories.push(...e),this.baseIncludeDirectories.push(...e)}getDirectories(){return this.includeDirectories}reset(){this.includeDirectories=[...this.baseIncludeDirectories]}restore(e){this.includeDirectories=[...e]}snapshot(){return[...this.includeDirectories]}addFiles(...e){this.includes.push(...e)}getPendingAndClear(){let e=[...this.includes];return this.includes.length=0,e}async processPatterns(e,r,t){let n=[];for(let o of e)if(P.isGlobPattern(o)){let i=(await Array.fromAsync(fi.glob(o,{cwd:r}))).map((l)=>ve.join(r,l));for(let l of i)if(!t.included.includes(l))n.push(l)}else if(P.isDirectoryPattern(o)){let i=ve.isAbsolute(o)?o:ve.join(r,o);if(!this.includeDirectories.includes(i))this.includeDirectories.push(i)}else n.push(o);return n}buildSearchDirs(e){let r=e?[e]:[];return r.push(...this.includeDirectories.map((t)=>ve.isAbsolute(t)?t:ve.join(e??process.cwd(),t))),r}}class Te{includeManager;loadFn;constructor(e,r){this.includeManager=e;this.loadFn=r}async processIncludes(e,r,t){let n=[];if(e.content.includes)n.push(...e.content.includes),delete e.content.includes;n.push(...this.includeManager.getPendingAndClear());let o=await this.includeManager.processPatterns(n,e.folderPath,t);for(let i of o)_(await this.loadFn(i,e.folderPath,{parent:e.content,...r},!0,t),e.content)}}var F={};W(F,{writeOutputs:()=>me,writeOutput:()=>xe,writeFormat:()=>Re,tokenize:()=>yr,toObjectWithKey:()=>or,toObject:()=>ge,toList:()=>Z,stripIndent:()=>dr,sortBy:()=>ar,snake:()=>re,select:()=>D,processFields:()=>C,pascal:()=>ee,padBlock:()=>T,nonNullMap:()=>ir,navigate:()=>We,mergeAll:()=>z,merge:()=>_,makeFieldProcessorMap:()=>K,makeFieldProcessorList:()=>qe,makeFieldProcessor:()=>pe,locate:()=>V,loadFormat:()=>fe,importList:()=>$e,importGlob:()=>tr,globMap:()=>ce,getProcessor:()=>ue,getArgs:()=>Fe,find:()=>fr,exists:()=>q,defined:()=>sr,deepClone:()=>I,conditionPredicates:()=>L,changeCase:()=>te,capital:()=>we,camel:()=>he,asyncMap:()=>lr,NavigateResult:()=>M,NavigateAction:()=>Ce,Logger:()=>Ke});R(F,io(Rt(),1));var xt={};W(xt,{Logger:()=>Ke});class Ke{options;constructor(e){this.options={level:"INFO",showClass:!1,levels:["DEBUG","VERBOSE","INFO","WARN","ERROR"],timeStamp:!1,timeOptions:{second:"2-digit",minute:"2-digit",hour:"2-digit",day:"2-digit",month:"2-digit",year:"2-digit"},logFunction:(r,...t)=>{switch(r){case"ERROR":console.error(...t);break;case"WARN":console.warn(...t);break;case"DEBUG":console.debug(...t);break;case"VERBOSE":console.log(...t);break;default:console.log(...t)}},...e}}write(e,...r){if(this.options.level){let o=this.options.levels.indexOf(this.options.level)??-1,i=this.options.levels.indexOf(e);if(i===-1)throw Error(`Unknown log level: ${e}`);if(i<o)return}let t=[],n=[];if(this.options.timeStamp)n.push(new Date().toLocaleString(this.options.timeLocale,this.options.timeOptions));if(this.options.showClass)n.push(e);if(n.length>0)t.push(`[${n.join(" ")}]`);t.push(...r),this.options.logFunction(e,...t)}info(...e){this.write("INFO",...e)}error(...e){this.write("ERROR",...e)}warn(...e){this.write("WARN",...e)}debug(...e){this.write("DEBUG",...e)}verbose(...e){this.write("VERBOSE",...e)}}R(N,F);var gr=Object.getPrototypeOf(async function(){}).constructor;class $t{includeManager=new Be;includeProcessor;cacheManager=new Ne(100);outputs=[];vars={};funcs={};fields={sources:{},keys:{},sections:{}};objectMetadata={};currentContext=null;storedSections={};dataEncoders={};dataDecoders={};constructor(){this.includeProcessor=new Te(this.includeManager,this.load.bind(this)),this.use(wr)}use(e){if(e.prototype instanceof H)new e(this);else e(this);return this}includeDirectory(...e){return this.includeManager.addDirectories(...e),this}getIncludeDirectories(){return this.includeManager.getDirectories()}include(...e){return this.includeManager.addFiles(...e),this}keys(e){return Object.assign(this.fields.keys,{...this.fields.keys,...e}),this}sources(e){return Object.assign(this.fields.sources,{...this.fields.sources,...e}),this}sections(e){return Object.assign(this.fields.sections,{...this.fields.sections,...e}),this}variables(e){return this.vars={...this.vars,...e},this}functions(e){return this.funcs={...this.funcs,...e},this}getFunctions(){return this.funcs}getOutputs(){return this.outputs}output(e){return this.outputs.push(e),this}metadata(e,r){return this.objectMetadata[e]=r,this}getMetadata(e){return this.objectMetadata[e]}getAllMetadata(){return this.objectMetadata}setCacheMaxSize(e){return this.cacheManager.setMaxSize(e),this}clearCache(){return this.cacheManager.clear(),this}getCurrentContext(){return this.currentContext}fieldOptions(e){return this.fields={...this.fields,...e},this}section(e){return this.storedSections[e.config.name]=e,this}getSection(e){return this.storedSections[e]}encoders(e){return this.dataEncoders={...this.dataEncoders,...e},this}decoders(e){return this.dataDecoders={...this.dataDecoders,...e},this}getEncoder(e){return this.dataEncoders[e]}getDecoder(e){return this.dataDecoders[e]}filter(e){return this.fields.filters??=[],this.fields.filters.push(e),this}async loadObject(e,r,t){return C(e,{...this.fields,globalContext:{file:t?.fullPath??"@internal"},root:{...r,...this.fields.root,...this.vars,functions:this.funcs,context:this.currentContext,sections:this.storedSections,$document:{root:{content:e},fileName:t?.fileName??"@internal",folder:t?.folderPath??"@internal",fullPath:t?.fullPath??"@internal"}}})}async load(e,r,t,n,o){let i=this.includeManager.snapshot();try{this.includeManager.reset();let l=this.includeManager.buildSearchDirs(r);if(o)this.currentContext=o;this.currentContext??={included:[],document:null};let a=await fe(e,{dirs:l,parsers:this.dataDecoders,format:"yaml"}),p=P.normalize(a.fullPath);if(this.currentContext.included.push(p),!a.content)return null;let h=this.cacheManager.get(p),O;if(h)O=h.raw;else O=a.content,this.cacheManager.set(p,{raw:O,timestamp:Date.now()});let y=I(O);a.content=y,await this.includeProcessor.processIncludes(a,t,this.currentContext);let u;if(n!==!0)u=await this.loadObject(a.content,t,{fileName:a.fullPath,folderPath:a.folderPath,fullPath:a.fullPath});else u=a.content;return this.currentContext.document=u,u}catch(l){throw this.includeManager.restore(i),l}finally{this.includeManager.restore(i)}}async writeAll(e){await me(this.getOutputs(),e)}}export{me as writeOutputs,xe as writeOutput,Re as writeFormat,Yr as variable,yr as tokenize,or as toObjectWithKey,ge as toObject,Z as toList,dr as stripIndent,ar as sortBy,re as snake,Gr as sharedFunction,D as select,Tr as section,C as processFields,ee as pascal,T as padBlock,ir as nonNullMap,We as navigate,z as mergeAll,_ as merge,K as makeFieldProcessorMap,qe as makeFieldProcessorList,pe as makeFieldProcessor,c as macro,V as locate,fe as loadFormat,Kr as key,$e as importList,tr as importGlob,ce as globMap,ue as getProcessor,Fe as getArgs,fr as find,q as exists,Qr as encoder,sr as defined,I as deepClone,Xr as decoder,L as conditionPredicates,te as changeCase,we as capital,he as camel,lr as asyncMap,H as ObjectorPlugin,$t as Objector,M as NavigateResult,Ce as NavigateAction,Ke as Logger,gr as AsyncFunction};
21
+ `).replaceAll("\\$","$").replaceAll("\\t","\t")};var bt=()=>({...B({merge:(...e)=>e.flatMap((r)=>r)}),join:({args:[e],root:r,tags:t})=>{let n=t.key?.[0],o=t.separator?.[0]??t.sep?.[0],i=t.finalize?.length>0,l=be(o);if(typeof e==="string"){if(i&&e.length&&l)return e+l;return e}if(!Array.isArray(e))throw Error("Object is not a list");let a=((n?.length)?e.map((y)=>x({...r,...y},n)):e).join(l),c=t.pad?.[0]??"0",w=t.padChar?.[0]??" ",O=i&&a.length&&l?a+l:a;return c?_(O,parseInt(c),`
22
+ `,w):O},range:({args:[e,r,t]})=>{let n=parseInt(e),o=parseInt(r),i=parseInt(t)||1;if(isNaN(n))throw Error("Invalid range: start value '"+String(e)+"' is not a number");if(isNaN(o))throw Error("Invalid range: end value '"+String(r)+"' is not a number");if(i===0)throw Error("Invalid range: step cannot be zero");if((o-n)/i<0)throw Error("Invalid range: step "+String(i)+" has wrong direction for range "+String(n)+" to "+String(o));return Array.from({length:Math.floor((o-n)/i)+1},(l,a)=>n+a*i)},filter:{types:(e,r,t)=>{switch(e){case 0:return"array";case 1:return Object.keys(K)}return ye[t[1].value]?.(e-2,r,t.slice(2))},fn:({args:[e,r,t],root:n,tags:o})=>{if(e===null||e===void 0)throw Error("Filter source cannot be null or undefined");if(!Array.isArray(e))throw Error("Filter source must be an array");let i=o.key?.[0],l=K[r];if(i){let c=Array(e.length);for(let O=0;O<e.length;O++)try{c[O]=x({...n,...e[O]},i)}catch{c[O]=Symbol("invalid")}let w=[];for(let O=0;O<e.length;O++){let y=c[O];if(typeof y!=="symbol"&&t===void 0?l(y):l(y,t))w.push(e[O])}return w}let a=[];for(let c of e)if(t===void 0?l(c):l(c,t))a.push(c);return a}}});var Ot=()=>({each:{processArgs:!1,fn:async({rawArgs:[e,r,...t],root:n,options:o,tags:i})=>{let l=async(g)=>g.quoted?be(g.value):await x(n,g.value),a=await x(n,e.value),c=await l(r),w=i.key?.[0],O=Array.isArray(a)?a:Z(a),y=[],u=await Promise.all(t.map(async(g)=>await l(g))),d={...n,item:void 0,index:0,params:u,instance:void 0,parent:n.this,tags:i},v={...o,root:d};for(let g=0;g<O.length;g++){let A=W(c),f={instance:A},S=typeof c==="string"?f:A;if(d.item=O[g],d.index=g,d.instance=A,i?.root?.[0])Object.assign(d,await x(d,i.root[0]));if(await $(S,v),w!==void 0)y.push(await x(f.instance,w));else y.push(f.instance)}if(i.join?.length){if(y.length===0)return"";let g=be(i.join[0]),A=i.pad?.[0]??"0",f=i.padChar?.[0]??" ",S=i.finalize?.length&&g?g:"",b=`${y.join(g)}${S}`;return A?_(b,parseInt(A),`
23
+ `,f):b}return y}}});var Oe=async(e,r,t)=>e.rawArgs[r].quoted?e.rawArgs[r].value:await x(e.root,e.rawArgs[r].value,{defaultValue:t}),At=()=>({switch:{processArgs:!1,fn:async(e)=>{let r=await Oe(e,0,!1),t=await Oe(e,1);if(t[r]===void 0){if(e.rawArgs.length>2)return Oe(e,2);throw Error(`Unhandled switch case: ${r}`)}return t[r]}}});var vt=()=>({if:{types:{0:"boolean"},fn:(e)=>e.args[0]?e.args[1]:e.args[2]},check:{types:{0:Object.keys(K)},fn:(e)=>K[e.args[0]](...e.args.slice(1))},...B(K,{types:ye})});var Tt=(e)=>({default:{processArgs:!1,fn:async(r)=>{for(let t=0;t<r.rawArgs.length;t++)if(r.rawArgs[t]?.value!==void 0){let o=await Oe(r,t,null);if(o!==null)return o}if(r.tags.nullable?.length)return E.DeleteItem();if(r.tags.fail?.length)throw Error(`No valid value found for default (${r.rawArgs.map((t)=>t.value).join(", ")})`);return""}},section:{types:["string","boolean"],fn:(r)=>{let t=r.args[0];if(!(r.args[1]??!0))return null;let o=e.getSection(t);if(!o)throw Error(`Section not found: ${t}`);return o.content}}});var Et=()=>({convert:({args:[e,r,t]})=>{switch(r){case"string":return String(e);case"number":{let n=Number(e);if(!isNaN(n))return E.ReplaceItem(n);break}case"boolean":if(e==="true"||e===!0||e===1||e==="1"||e==="yes"||e==="on")return E.ReplaceItem(!0);else if(e==="false"||e===!1||e===0||e==="0"||e==="no"||e==="off")return E.ReplaceItem(!1);break;default:throw Error(`Unsupported type for convert: ${r}`)}if(t!==void 0)return E.ReplaceItem(t);throw Error(`Failed to convert value to ${r}`)},isType:({args:[e,r]})=>{let n=(()=>{switch(r){case"string":return typeof e==="string";case"number":return typeof e==="number";case"boolean":return typeof e==="boolean";case"object":return e!==null&&typeof e==="object"&&!Array.isArray(e);case"array":return Array.isArray(e);case"null":return e===null;case"undefined":return e===void 0;case"function":return typeof e==="function";default:throw Error(`Unknown type for isType: ${r}`)}})();return E.ReplaceItem(n)},typeOf:({args:[e]})=>{if(e===null)return"null";else if(Array.isArray(e))return"array";else return typeof e}});var vr=(e)=>{var r,t,n,o,i,l,a,c,w,O,y,u,d,v,g,A,f,S,b,M,k,ve,Y,L,Te,Ee,Me,oe,Pe,Se,Ve,Ct,Wt,Nt,Kt,Ut,It,Lt,_t,Bt,Pt,Vt,Yt,Gt,Qt,Xt,Zt,Ht,qt,zt,Jt,en,rn,tn,nn,on,sn,an,ln,un,cn,fn,pn,mn,gn,yn,dn,hn,wn,bn,On,An,vn,Tn,En,Mn,Sn,kn,xn,Fn,Dn,jn,Rn,$n,Cn,Wn,Nn,Kn,Un,In,Ln,_n,Bn,Pn,Vn,Yn,Gn,Qn,Xn,Zn,Hn,qn,zn,Jn,o,i,l,a,c,w,O,y,u,d,v,g,A,f,S,b,M,k,ve,Y,L,Te,Ee,Me,oe,Pe,Se,Ve,Ct,Wt,Nt,Kt,Ut,It,Lt,_t,Bt,Pt,Vt,Yt,Gt,Qt,Xt,Zt,Ht,qt,zt,Jt,en,rn,tn,nn,on,sn,an,ln,un,cn,fn,pn,mn,gn,yn,dn,hn,wn,bn,On,An,vn,Tn,En,Mn,Sn,kn,xn,Fn,Dn,jn,Rn,$n,Cn,Wn,Nn,Kn,Un,In,Ln,_n,Bn,Pn,Vn,Yn,Gn,Qn,Xn,Zn,Hn,qn,zn,Jn;return e.use((n=P,o=[p()],i=[p()],l=[p()],a=[p()],c=[p()],w=[p()],O=[p()],y=[p()],u=[p()],d=[p()],v=[p()],g=[p()],A=[p()],f=[p()],S=[p()],b=[p()],M=[p()],k=[p()],ve=[p()],Y=[p()],L=[p()],Te=[p()],Ee=[p()],Me=[p()],oe=[p()],Pe=[p()],Se=[p()],Ve=[p()],Ct=[p()],Wt=[p()],Nt=[p()],Kt=[p()],Ut=[p()],It=[p()],Lt=[p()],_t=[p()],Bt=[p()],Pt=[p()],Vt=[p()],Yt=[p()],Gt=[p()],Qt=[p()],Xt=[p()],Zt=[p()],Ht=[p()],qt=[p()],zt=[p()],Jt=[p()],en=[p()],rn=[p()],tn=[p()],nn=[p()],on=[p()],sn=[p()],an=[p()],ln=[p()],un=[p()],cn=[p()],fn=[p()],pn=[p()],mn=[p()],gn=[p()],yn=[p()],dn=[p()],hn=[p()],wn=[p()],bn=[p()],On=[p()],An=[p()],vn=[p()],Tn=[p()],En=[p()],Mn=[p()],Sn=[p()],kn=[p()],xn=[p()],Fn=[p()],Dn=[p()],jn=[p()],Rn=[p()],$n=[p()],Cn=[p()],Wn=[p()],Nn=[p()],Kn=[p()],Un=[p()],In=[p()],Ln=[p()],_n=[p()],Bn=[p()],Pn=[p()],Vn=[p()],Yn=[p()],Gn=[p()],Qn=[p()],Xn=[p()],Zn=[p()],Hn=[p()],qn=[p()],zn=[p()],Jn=[p()],t=jr(n),r=class extends n{constructor(){super(...arguments);$r(t,5,this)}env(s){return process.env[s]}uuid(){return crypto.randomUUID()}pascal(s){return ee(s)}camel(s){return we(s)}capital(s){return he(s)}snake(s,h){return te(re(s,"_"),h)}kebab(s,h){return te(re(s,"-"),h)}len(s){return s.length}reverse(s){return s.split("").reverse().join("")}concat(...s){return s.join("")}trim(s){return s.trim()}ltrim(s){return s.trimStart()}rtrim(s){return s.trimEnd()}lower(s){return s.toLowerCase()}upper(s){return s.toUpperCase()}encode(s,h){return Buffer.from(s).toString(h??"base64")}decode(s,h){return Buffer.from(s,h??"base64").toString()}list(s,h){return Z(s,h)}object(s,h){return ge(s,h)}pathJoin(...s){return V.join(...s)}resolve(...s){return V.resolve(...s)}dirname(s){return V.dirname(s)}basename(s,h){return V.basename(s,h)}normalize(s){return V.normalize(s)}extname(s){return V.extname(s)}relative(s,h){return V.relative(s,h)}isAbsolute(s){return V.isAbsolute(s)}segments(s){return s.split("/").filter(Boolean)}log(...s){console.log(...s)}md5(s){return ne("md5").update(s).digest("hex")}sha1(s){return ne("sha1").update(s).digest("hex")}sha256(s){return ne("sha256").update(s).digest("hex")}sha512(s){return ne("sha512").update(s).digest("hex")}hash(s,h="sha256"){return ne(h).update(s).digest("hex")}hmac(s,h,T="sha256"){return ne(T).update(s).digest("hex")}base64Encode(s){return Buffer.from(s).toString("base64")}base64Decode(s){return Buffer.from(s,"base64").toString("utf-8")}hexEncode(s){return Buffer.from(s).toString("hex")}hexDecode(s){return Buffer.from(s,"hex").toString("utf-8")}add(...s){return s.reduce((h,T)=>h+T,0)}subtract(s,h){return s-h}multiply(...s){return s.reduce((h,T)=>h*T,1)}divide(s,h){if(h===0)throw Error("Division by zero");return s/h}modulo(s,h){return s%h}power(s,h){return Math.pow(s,h)}sqrt(s){return Math.sqrt(s)}abs(s){return Math.abs(s)}floor(s){return Math.floor(s)}ceil(s){return Math.ceil(s)}round(s,h){let T=Math.pow(10,h??0);return Math.round(s*T)/T}min(...s){return Math.min(...s)}max(...s){return Math.max(...s)}clamp(s,h,T){return Math.max(h,Math.min(T,s))}random(s,h){let T=s??0,R=h??1;return Math.random()*(R-T)+T}timestamp(s){return new Date(s).getTime()}iso(s){return new Date(s).toISOString()}utc(s){return new Date(s).toUTCString()}formatDate(s,h){let T=new Date(s),R=T.getFullYear(),I=String(T.getMonth()+1).padStart(2,"0"),ke=String(T.getDate()).padStart(2,"0"),ie=String(T.getHours()).padStart(2,"0"),eo=String(T.getMinutes()).padStart(2,"0"),ro=String(T.getSeconds()).padStart(2,"0");return h.replace("YYYY",String(R)).replace("MM",I).replace("DD",ke).replace("HH",ie).replace("mm",eo).replace("ss",ro)}parseDate(s){return new Date(s).getTime()}year(s){return new Date(s).getFullYear()}month(s){return new Date(s).getMonth()+1}day(s){return new Date(s).getDate()}dayOfWeek(s){return new Date(s).getDay()}hours(s){return new Date(s).getHours()}minutes(s){return new Date(s).getMinutes()}seconds(s){return new Date(s).getSeconds()}regexTest(s,h,T){return new RegExp(s,T).test(h)}regexMatch(s,h,T){return new RegExp(s,T).exec(h)}regexMatchAll(s,h,T){return Array.from(h.matchAll(new RegExp(s,T)))}regexReplace(s,h,T,R){return T.replace(new RegExp(s,R),h)}regexReplaceAll(s,h,T,R){return T.replace(new RegExp(s,R??"g"),h)}regexSplit(s,h,T){return h.split(new RegExp(s,T))}regexExec(s,h,T){return new RegExp(s,T).exec(h)}regexSearch(s,h,T){return h.search(new RegExp(s,T))}unique(s,h){if(!Array.isArray(s))return s;let T=new Set;return s.filter((R)=>{let I=h?R[h]:R;if(T.has(I))return!1;return T.add(I),!0})}groupBy(s,h){if(!Array.isArray(s))return s;let T={};return s.forEach((R)=>{let I=String(R[h]);if(!T[I])T[I]=[];T[I].push(R)}),T}chunk(s,h=1){if(!Array.isArray(s))return[];let T=[];for(let R=0;R<s.length;R+=h)T.push(s.slice(R,R+h));return T}flatten(s,h=1){if(!Array.isArray(s))return[s];let T=[],R=(I,ke)=>{for(let ie of I)if(Array.isArray(ie)&&ke>0)R(ie,ke-1);else T.push(ie)};return R(s,h),T}compact(s){if(!Array.isArray(s))return s;return s.filter((h)=>h!==null&&h!==void 0)}head(s,h){if(!Array.isArray(s))return s;return h?s.slice(0,h):s[0]}tail(s,h){if(!Array.isArray(s))return s;return h?s.slice(-h):s[s.length-1]}isEmail(s){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s)}isUrl(s){try{return new URL(s),!0}catch{return!1}}isJson(s){try{return JSON.parse(s),!0}catch{return!1}}isUuid(s){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s)}minLength(s,h){return s?.length>=h}maxLength(s,h){return s?.length<=h}lengthEquals(s,h){return s?.length===h}isNumber(s){return typeof s==="number"&&!isNaN(s)}isString(s){return typeof s==="string"}isBoolean(s){return typeof s==="boolean"}isArray(s){return Array.isArray(s)}isObject(s){return s!==null&&typeof s==="object"&&!Array.isArray(s)}isEmpty(s){if(s===null||s===void 0)return!0;if(typeof s==="string"||Array.isArray(s))return s.length===0;if(typeof s==="object")return Object.keys(s).length===0;return!1}isTruthy(s){return!!s}isFalsy(s){return!s}inRange(s,h,T){return s>=h&&s<=T}matchesPattern(s,h){return new RegExp(h).test(s)}includes(s,h){if(typeof s==="string")return s.includes(String(h));return Array.isArray(s)&&s.includes(h)}startsWith(s,h){return s.startsWith(h)}endsWith(s,h){return s.endsWith(h)}},m(t,1,"env",o,r),m(t,1,"uuid",i,r),m(t,1,"pascal",l,r),m(t,1,"camel",a,r),m(t,1,"capital",c,r),m(t,1,"snake",w,r),m(t,1,"kebab",O,r),m(t,1,"len",y,r),m(t,1,"reverse",u,r),m(t,1,"concat",d,r),m(t,1,"trim",v,r),m(t,1,"ltrim",g,r),m(t,1,"rtrim",A,r),m(t,1,"lower",f,r),m(t,1,"upper",S,r),m(t,1,"encode",b,r),m(t,1,"decode",M,r),m(t,1,"list",k,r),m(t,1,"object",ve,r),m(t,1,"pathJoin",Y,r),m(t,1,"resolve",L,r),m(t,1,"dirname",Te,r),m(t,1,"basename",Ee,r),m(t,1,"normalize",Me,r),m(t,1,"extname",oe,r),m(t,1,"relative",Pe,r),m(t,1,"isAbsolute",Se,r),m(t,1,"segments",Ve,r),m(t,1,"log",Ct,r),m(t,1,"md5",Wt,r),m(t,1,"sha1",Nt,r),m(t,1,"sha256",Kt,r),m(t,1,"sha512",Ut,r),m(t,1,"hash",It,r),m(t,1,"hmac",Lt,r),m(t,1,"base64Encode",_t,r),m(t,1,"base64Decode",Bt,r),m(t,1,"hexEncode",Pt,r),m(t,1,"hexDecode",Vt,r),m(t,1,"add",Yt,r),m(t,1,"subtract",Gt,r),m(t,1,"multiply",Qt,r),m(t,1,"divide",Xt,r),m(t,1,"modulo",Zt,r),m(t,1,"power",Ht,r),m(t,1,"sqrt",qt,r),m(t,1,"abs",zt,r),m(t,1,"floor",Jt,r),m(t,1,"ceil",en,r),m(t,1,"round",rn,r),m(t,1,"min",tn,r),m(t,1,"max",nn,r),m(t,1,"clamp",on,r),m(t,1,"random",sn,r),m(t,1,"timestamp",an,r),m(t,1,"iso",ln,r),m(t,1,"utc",un,r),m(t,1,"formatDate",cn,r),m(t,1,"parseDate",fn,r),m(t,1,"year",pn,r),m(t,1,"month",mn,r),m(t,1,"day",gn,r),m(t,1,"dayOfWeek",yn,r),m(t,1,"hours",dn,r),m(t,1,"minutes",hn,r),m(t,1,"seconds",wn,r),m(t,1,"regexTest",bn,r),m(t,1,"regexMatch",On,r),m(t,1,"regexMatchAll",An,r),m(t,1,"regexReplace",vn,r),m(t,1,"regexReplaceAll",Tn,r),m(t,1,"regexSplit",En,r),m(t,1,"regexExec",Mn,r),m(t,1,"regexSearch",Sn,r),m(t,1,"unique",kn,r),m(t,1,"groupBy",xn,r),m(t,1,"chunk",Fn,r),m(t,1,"flatten",Dn,r),m(t,1,"compact",jn,r),m(t,1,"head",Rn,r),m(t,1,"tail",$n,r),m(t,1,"isEmail",Cn,r),m(t,1,"isUrl",Wn,r),m(t,1,"isJson",Nn,r),m(t,1,"isUuid",Kn,r),m(t,1,"minLength",Un,r),m(t,1,"maxLength",In,r),m(t,1,"lengthEquals",Ln,r),m(t,1,"isNumber",_n,r),m(t,1,"isString",Bn,r),m(t,1,"isBoolean",Pn,r),m(t,1,"isArray",Vn,r),m(t,1,"isObject",Yn,r),m(t,1,"isEmpty",Gn,r),m(t,1,"isTruthy",Qn,r),m(t,1,"isFalsy",Xn,r),m(t,1,"inRange",Zn,r),m(t,1,"matchesPattern",Hn,r),m(t,1,"includes",qn,r),m(t,1,"startsWith",zn,r),m(t,1,"endsWith",Jn,r),Xe(t,r),r)).keys({...Xr(e),...Zr(e),...tt(),...nt(),...at(),...ot(),...it(),...st(e),...ut(e),...ct(),...ft(),...pt()}).sources({...dt(e),...wt(e),...Et(),...bt(),...Ot(),...At(),...vt(),...Tt(e)}).sections(gt(e)).fieldOptions({configParser:Bun.YAML.parse,onSection:(s)=>{if(s.section.config.name)e.section(s.section)}}).decoders({yaml:{matching:["\\.yml$","\\.yaml$"],fn:Bun.YAML.parse}}).encoders({json:{fn:(s)=>JSON.stringify(s,null,2)},yaml:{fn:(s)=>Bun.YAML.stringify(s,null,2)},terraform:{options:{includeTags:!0},fn:(s,h)=>Ie(s,0,{sortKeys:!!(h?.sort?.length??h?.sortKeys?.length)})}})};var St={};C(St,{IncludeManager:()=>Le,DocumentIncludeProcessor:()=>_e});import pi from"fs/promises";import Ae from"path";class Le{includeDirectories=[];baseIncludeDirectories=[];includes=[];addDirectories(...e){this.includeDirectories.push(...e),this.baseIncludeDirectories.push(...e)}getDirectories(){return this.includeDirectories}reset(){this.includeDirectories=[...this.baseIncludeDirectories]}restore(e){this.includeDirectories=[...e]}snapshot(){return[...this.includeDirectories]}addFiles(...e){this.includes.push(...e)}getPendingAndClear(){let e=[...this.includes];return this.includes.length=0,e}async processPatterns(e,r,t){let n=[];for(let o of e)if(H.isGlobPattern(o)){let i=(await Array.fromAsync(pi.glob(o,{cwd:r}))).map((l)=>Ae.join(r,l));for(let l of i)if(!t.included.includes(l))n.push(l)}else if(H.isDirectoryPattern(o)){let i=Ae.isAbsolute(o)?o:Ae.join(r,o);if(!this.includeDirectories.includes(i))this.includeDirectories.push(i)}else n.push(o);return n}buildSearchDirs(e){let r=e?[e]:[];return r.push(...this.includeDirectories.map((t)=>Ae.isAbsolute(t)?t:Ae.join(e??process.cwd(),t))),r}}class _e{includeManager;loadFn;constructor(e,r){this.includeManager=e;this.loadFn=r}async processIncludes(e,r,t){let n=[];if(e.content.includes)n.push(...e.content.includes),delete e.content.includes;n.push(...this.includeManager.getPendingAndClear());let o=await this.includeManager.processPatterns(n,e.folderPath,t);for(let i of o)U(await this.loadFn(i,e.folderPath,{parent:e.content,...r},!0,t),e.content)}}var F={};C(F,{writeOutputs:()=>me,writeOutput:()=>je,writeFormat:()=>De,variable:()=>pr,tokenize:()=>Or,toObjectWithKey:()=>or,toObject:()=>ge,toList:()=>Z,stripIndent:()=>Ar,sortBy:()=>ar,snake:()=>re,sharedFunction:()=>mr,select:()=>x,section:()=>cr,processFields:()=>$,pascal:()=>ee,padBlock:()=>_,nonNullMap:()=>ir,navigate:()=>Ce,mergeAll:()=>z,merge:()=>U,makeFieldProcessorMap:()=>B,makeFieldProcessorList:()=>qe,makeFieldProcessor:()=>ce,macro:()=>p,locate:()=>X,loadFormat:()=>fe,key:()=>fr,importList:()=>Re,importGlob:()=>tr,globMap:()=>pe,getProcessor:()=>ue,getArgs:()=>Fe,find:()=>hr,exists:()=>q,encoder:()=>gr,defined:()=>sr,deepClone:()=>W,decoder:()=>yr,conditionPredicates:()=>K,changeCase:()=>te,capital:()=>he,camel:()=>we,asyncMap:()=>lr,ObjectorPlugin:()=>P,NavigateResult:()=>E,NavigateAction:()=>$e,Logger:()=>Be,AsyncFunction:()=>Er});D(F,so(Dt(),1));var jt={};C(jt,{Logger:()=>Be});class Be{options;constructor(e){this.options={level:"INFO",showClass:!1,levels:["DEBUG","VERBOSE","INFO","WARN","ERROR"],timeStamp:!1,timeOptions:{second:"2-digit",minute:"2-digit",hour:"2-digit",day:"2-digit",month:"2-digit",year:"2-digit"},logFunction:(r,...t)=>{switch(r){case"ERROR":console.error(...t);break;case"WARN":console.warn(...t);break;case"DEBUG":console.debug(...t);break;case"VERBOSE":console.log(...t);break;default:console.log(...t)}},...e}}write(e,...r){if(this.options.level){let o=this.options.levels.indexOf(this.options.level)??-1,i=this.options.levels.indexOf(e);if(i===-1)throw Error(`Unknown log level: ${e}`);if(i<o)return}let t=[],n=[];if(this.options.timeStamp)n.push(new Date().toLocaleString(this.options.timeLocale,this.options.timeOptions));if(this.options.showClass)n.push(e);if(n.length>0)t.push(`[${n.join(" ")}]`);t.push(...r),this.options.logFunction(e,...t)}info(...e){this.write("INFO",...e)}error(...e){this.write("ERROR",...e)}warn(...e){this.write("WARN",...e)}debug(...e){this.write("DEBUG",...e)}verbose(...e){this.write("VERBOSE",...e)}}var Rt={};C(Rt,{AsyncFunction:()=>Er});Array.prototype.mapAsync=async function(e){let r=[];for(let t=0;t<this.length;t++)r.push(await e(this[t],t,this));return r};Array.prototype.nonNullMap=function(e){let r=[];for(let t=0;t<this.length;t++){let n=e(this[t],t,this);if(n!=null)r.push(n)}return r};Array.prototype.nonNullMapAsync=async function(e){let r=[];for(let t=0;t<this.length;t++){let n=await e(this[t],t,this);if(n!=null)r.push(n)}return r};Array.prototype.sortBy=function(e,r=!0){return this.slice().sort((t,n)=>{let o=e(t),i=e(n);if(o<i)return r?-1:1;if(o>i)return r?1:-1;return 0})};Array.prototype.forEachAsync=async function(e){for(let r=0;r<this.length;r++)await e(this[r],r,this)};Array.prototype.unique=function(){return Array.from(new Set(this))};Array.prototype.uniqueBy=function(e){let r=new Set;return this.filter((t)=>{let n=e(t);if(r.has(n))return!1;else return r.add(n),!0})};Array.prototype.groupBy=function(e){return this.reduce((r,t)=>{let n=e(t);if(!r[n])r[n]=[];return r[n].push(t),r},{})};Array.prototype.toObject=function(e,r){return Object.fromEntries(this.map((t)=>{let n=e(t),o=r?r(t):t;return[n,o]}))};Array.prototype.toObjectWithKey=function(e){return Object.fromEntries(this.map((r)=>[String(r[e]),r]))};Array.prototype.findOrFail=function(e,r,t){let n=this.find(e,t);if(n===void 0)throw Error(r??"Element not found");return n};Array.prototype.selectFor=function(e,r,t,n){let o=this.find(e,n);if(o===void 0)throw Error(t??"Element not found");return r(o)};Array.flat=function(e){if(Array.isArray(e))return e.flat(2);else return[e]};Array.prototype.createInstances=function(e,...r){return this.map((t,n)=>new e(...r,t,n))};Object.mapEntries=function(e,r){let n=Object.entries(e).map(([o,i])=>r(o,i));return Object.fromEntries(n)};Object.toList=function(e,r){return Object.entries(e).map(([t,n])=>({[r]:t,...n}))};Object.deepClone=function(e){if(typeof structuredClone<"u")try{return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))};Object.find=function(e,r){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n=e[t];if(n!==void 0&&r(n,t))return[t,n]}return};Object.findAll=function(e,r){let t=[];for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)){let o=e[n];if(o!==void 0&&r(o,n))t.push([n,o])}return t};global.AsyncFunction=Object.getPrototypeOf(async function(){}).constructor;var Er=global.AsyncFunction;D(N,F);class $t{includeManager=new Le;includeProcessor;cacheManager=new We(100);outputs=[];vars={};funcs={};fields={sources:{},keys:{},sections:{}};objectMetadata={};currentContext=null;storedSections={};dataEncoders={};dataDecoders={};constructor(){this.includeProcessor=new _e(this.includeManager,this.load.bind(this)),this.use(vr)}use(e){if(e.prototype instanceof P)new e(this);else e(this);return this}includeDirectory(...e){return this.includeManager.addDirectories(...e),this}getIncludeDirectories(){return this.includeManager.getDirectories()}include(...e){return this.includeManager.addFiles(...e),this}keys(e){return Object.assign(this.fields.keys,{...this.fields.keys,...e}),this}sources(e){return Object.assign(this.fields.sources,{...this.fields.sources,...e}),this}sections(e){return Object.assign(this.fields.sections,{...this.fields.sections,...e}),this}variables(e){return this.vars={...this.vars,...e},this}functions(e){return this.funcs={...this.funcs,...e},this}getFunctions(){return this.funcs}getOutputs(){return this.outputs}output(e){return this.outputs.push(e),this}metadata(e,r){return this.objectMetadata[e]=r,this}getMetadata(e){return this.objectMetadata[e]}getAllMetadata(){return this.objectMetadata}setCacheMaxSize(e){return this.cacheManager.setMaxSize(e),this}clearCache(){return this.cacheManager.clear(),this}getCurrentContext(){return this.currentContext}fieldOptions(e){return this.fields={...this.fields,...e},this}section(e){return this.storedSections[e.config.name]=e,this}getSection(e){return this.storedSections[e]}encoders(e){return this.dataEncoders={...this.dataEncoders,...e},this}decoders(e){return this.dataDecoders={...this.dataDecoders,...e},this}getEncoder(e){return this.dataEncoders[e]}getDecoder(e){return this.dataDecoders[e]}filter(e){return this.fields.filters??=[],this.fields.filters.push(e),this}async loadObject(e,r,t){return $(e,{...this.fields,globalContext:{file:t?.fullPath??"@internal"},root:{...r,...this.fields.root,...this.vars,functions:this.funcs,context:this.currentContext,sections:this.storedSections,$document:{root:{content:e},fileName:t?.fileName??"@internal",folder:t?.folderPath??"@internal",fullPath:t?.fullPath??"@internal"}}})}async load(e,r,t,n,o){let i=this.includeManager.snapshot();try{this.includeManager.reset();let l=this.includeManager.buildSearchDirs(r);if(o)this.currentContext=o;this.currentContext??={included:[],document:null};let a=await fe(e,{dirs:l,parsers:this.dataDecoders,format:"yaml"}),c=H.normalize(a.fullPath);if(this.currentContext.included.push(c),!a.content)return null;let w=this.cacheManager.get(c),O;if(w)O=w.raw;else O=a.content,this.cacheManager.set(c,{raw:O,timestamp:Date.now()});let y=W(O);a.content=y,await this.includeProcessor.processIncludes(a,t,this.currentContext);let u;if(n!==!0)u=await this.loadObject(a.content,t,{fileName:a.fullPath,folderPath:a.folderPath,fullPath:a.fullPath});else u=a.content;return this.currentContext.document=u,u}catch(l){throw this.includeManager.restore(i),l}finally{this.includeManager.restore(i)}}async writeAll(e){await me(this.getOutputs(),e)}}export{me as writeOutputs,je as writeOutput,De as writeFormat,pr as variable,Or as tokenize,or as toObjectWithKey,ge as toObject,Z as toList,Ar as stripIndent,ar as sortBy,re as snake,mr as sharedFunction,x as select,cr as section,$ as processFields,ee as pascal,_ as padBlock,ir as nonNullMap,Ce as navigate,z as mergeAll,U as merge,B as makeFieldProcessorMap,qe as makeFieldProcessorList,ce as makeFieldProcessor,p as macro,X as locate,fe as loadFormat,fr as key,Re as importList,tr as importGlob,pe as globMap,ue as getProcessor,Fe as getArgs,hr as find,q as exists,gr as encoder,sr as defined,W as deepClone,yr as decoder,K as conditionPredicates,te as changeCase,he as capital,we as camel,lr as asyncMap,P as ObjectorPlugin,$t as Objector,E as NavigateResult,$e as NavigateAction,Be as Logger,Er as AsyncFunction};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homedev/objector",
3
- "version": "1.2.61",
3
+ "version": "1.2.63",
4
4
  "description": "object extensions for YAML/JSON",
5
5
  "author": "julzor",
6
6
  "license": "ISC",