xcode-graph 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4906 @@
1
+ import { O as Origin, D as DependencyKind, P as Platform$1, N as NodeType } from './xcode-graph.js';
2
+
3
+ /**
4
+ * AUTO-GENERATED from XcodeGraph Swift sources
5
+ * Do not edit manually - regenerate using:
6
+ * swift run transform-graph --source-dir <xcodegraph-sources> -o xcode-graph.schema.generated.ts
7
+ *
8
+ * @generated
9
+ */
10
+ var GraphDependency_PackageProductType;
11
+ (function (GraphDependency_PackageProductType) {
12
+ GraphDependency_PackageProductType["Runtime"] = "runtime";
13
+ GraphDependency_PackageProductType["RuntimeEmbedded"] = "runtimeEmbedded";
14
+ GraphDependency_PackageProductType["Plugin"] = "plugin";
15
+ GraphDependency_PackageProductType["Macro"] = "macro";
16
+ })(GraphDependency_PackageProductType || (GraphDependency_PackageProductType = {}));
17
+ var BinaryArchitecture;
18
+ (function (BinaryArchitecture) {
19
+ BinaryArchitecture["X8664"] = "x8664";
20
+ BinaryArchitecture["I386"] = "i386";
21
+ BinaryArchitecture["Armv7"] = "armv7";
22
+ BinaryArchitecture["Armv7s"] = "armv7s";
23
+ BinaryArchitecture["Arm64"] = "arm64";
24
+ BinaryArchitecture["Armv7k"] = "armv7k";
25
+ BinaryArchitecture["Arm6432"] = "arm6432";
26
+ BinaryArchitecture["Arm64e"] = "arm64e";
27
+ })(BinaryArchitecture || (BinaryArchitecture = {}));
28
+ var BinaryLinking;
29
+ (function (BinaryLinking) {
30
+ BinaryLinking["Static"] = "static";
31
+ BinaryLinking["Dynamic"] = "dynamic";
32
+ })(BinaryLinking || (BinaryLinking = {}));
33
+ var BuildConfiguration_Variant;
34
+ (function (BuildConfiguration_Variant) {
35
+ BuildConfiguration_Variant["Debug"] = "debug";
36
+ BuildConfiguration_Variant["Release"] = "release";
37
+ })(BuildConfiguration_Variant || (BuildConfiguration_Variant = {}));
38
+ var CompilerSpec;
39
+ (function (CompilerSpec) {
40
+ CompilerSpec["AppIntentsMetadataExtractor"] = "appIntentsMetadataExtractor";
41
+ CompilerSpec["AppShortcutStringsMetadataExtractor"] = "appShortcutStringsMetadataExtractor";
42
+ CompilerSpec["AppleClang"] = "appleClang";
43
+ CompilerSpec["AssetCatalogCompiler"] = "assetCatalogCompiler";
44
+ CompilerSpec["CodeSign"] = "codeSign";
45
+ CompilerSpec["CompileRealityComposerProject"] = "compileRealityComposerProject";
46
+ CompilerSpec["CompileSceneKitShaders"] = "compileSceneKitShaders";
47
+ CompilerSpec["CompileSkybox"] = "compileSkybox";
48
+ CompilerSpec["CompileUSDZ"] = "compileUSDZ";
49
+ CompilerSpec["CompressPNG"] = "compressPNG";
50
+ CompilerSpec["CopyPlistFile"] = "copyPlistFile";
51
+ CompilerSpec["CopySceneKitAssets"] = "copySceneKitAssets";
52
+ CompilerSpec["CopyStringsFile"] = "copyStringsFile";
53
+ CompilerSpec["CopyTiffFile"] = "copyTiffFile";
54
+ CompilerSpec["CoreDataMappingModelCompiler"] = "coreDataMappingModelCompiler";
55
+ CompilerSpec["CoreMLModelCompiler"] = "coreMLModelCompiler";
56
+ CompilerSpec["DataModelCompiler"] = "dataModelCompiler";
57
+ CompilerSpec["DefaultCompiler"] = "defaultCompiler";
58
+ CompilerSpec["DocumentationCompiler"] = "documentationCompiler";
59
+ CompilerSpec["DTrace"] = "dTrace";
60
+ CompilerSpec["GenerateSpriteKitTextureAtlas"] = "generateSpriteKitTextureAtlas";
61
+ CompilerSpec["Iconutil"] = "iconutil";
62
+ CompilerSpec["InstrumetsPackageBuilder"] = "instrumetsPackageBuilder";
63
+ CompilerSpec["IntentDefinitionCompiler"] = "intentDefinitionCompiler";
64
+ CompilerSpec["InterfaceBuilderNIBPostprocessor"] = "interfaceBuilderNIBPostprocessor";
65
+ CompilerSpec["InterfaceBuilderStoryboardCompiler"] = "interfaceBuilderStoryboardCompiler";
66
+ CompilerSpec["InterfaceBuilderStoryboardLinker"] = "interfaceBuilderStoryboardLinker";
67
+ CompilerSpec["InterfaceBuilderStoryboardPostprocessor"] = "interfaceBuilderStoryboardPostprocessor";
68
+ CompilerSpec["InterfaceBuilderXIBCompiler"] = "interfaceBuilderXIBCompiler";
69
+ CompilerSpec["IoKitInterfaceGenerator"] = "ioKitInterfaceGenerator";
70
+ CompilerSpec["Lex"] = "lex";
71
+ CompilerSpec["LsRegisterURL"] = "lsRegisterURL";
72
+ CompilerSpec["MetalCompiler"] = "metalCompiler";
73
+ CompilerSpec["MetalLinker"] = "metalLinker";
74
+ CompilerSpec["Mig"] = "mig";
75
+ CompilerSpec["Nasm"] = "nasm";
76
+ CompilerSpec["Nmedit"] = "nmedit";
77
+ CompilerSpec["OpenCL"] = "openCL";
78
+ CompilerSpec["OsaCompile"] = "osaCompile";
79
+ CompilerSpec["Pbxcp"] = "pbxcp";
80
+ CompilerSpec["ProcessSceneKitDocument"] = "processSceneKitDocument";
81
+ CompilerSpec["ProcessXCAppExtensionPoints"] = "processXCAppExtensionPoints";
82
+ CompilerSpec["Rez"] = "rez";
83
+ CompilerSpec["StripSymbols"] = "stripSymbols";
84
+ CompilerSpec["SwiftCompiler"] = "swiftCompiler";
85
+ CompilerSpec["SwiftABIBaselineGenerator"] = "swiftABIBaselineGenerator";
86
+ CompilerSpec["SwiftFrameworkABIChecker"] = "swiftFrameworkABIChecker";
87
+ CompilerSpec["TextBasedAPITool"] = "textBasedAPITool";
88
+ CompilerSpec["Unifdef"] = "unifdef";
89
+ CompilerSpec["Yacc"] = "yacc";
90
+ CompilerSpec["CustomScript"] = "customScript";
91
+ })(CompilerSpec || (CompilerSpec = {}));
92
+ var FileType;
93
+ (function (FileType) {
94
+ FileType["InstrumentsPackageDefinition"] = "instrumentsPackageDefinition";
95
+ FileType["MetalAIR"] = "metalAIR";
96
+ FileType["MachO"] = "machO";
97
+ FileType["MachOObject"] = "machOObject";
98
+ FileType["SiriKitIntent"] = "siriKitIntent";
99
+ FileType["CoreMLMachineLearning"] = "coreMLMachineLearning";
100
+ FileType["RcProjectDocument"] = "rcProjectDocument";
101
+ FileType["SkyboxDocument"] = "skyboxDocument";
102
+ FileType["InterfaceBuilderStoryboard"] = "interfaceBuilderStoryboard";
103
+ FileType["InterfaceBuilder"] = "interfaceBuilder";
104
+ FileType["DocumentationCatalog"] = "documentationCatalog";
105
+ FileType["CoreMLMachineLearningModelPackage"] = "coreMLMachineLearningModelPackage";
106
+ FileType["AssemblyAsm"] = "assemblyAsm";
107
+ FileType["AssemblyAsmAsm"] = "assemblyAsmAsm";
108
+ FileType["LlvmAssembly"] = "llvmAssembly";
109
+ FileType["CSource"] = "cSource";
110
+ FileType["ClipsSource"] = "clipsSource";
111
+ FileType["CppSource"] = "cppSource";
112
+ FileType["DtraceSource"] = "dtraceSource";
113
+ FileType["DylanSource"] = "dylanSource";
114
+ FileType["FortranSource"] = "fortranSource";
115
+ FileType["GlslSource"] = "glslSource";
116
+ FileType["IigSource"] = "iigSource";
117
+ FileType["JavaSource"] = "javaSource";
118
+ FileType["LexSource"] = "lexSource";
119
+ FileType["MetalShaderSource"] = "metalShaderSource";
120
+ FileType["MigSource"] = "migSource";
121
+ FileType["NasmAssembly"] = "nasmAssembly";
122
+ FileType["OpenCLSource"] = "openCLSource";
123
+ FileType["PascalSource"] = "pascalSource";
124
+ FileType["ProtobufSource"] = "protobufSource";
125
+ FileType["RezSource"] = "rezSource";
126
+ FileType["SwiftSource"] = "swiftSource";
127
+ FileType["YaccSource"] = "yaccSource";
128
+ FileType["LocalizationString"] = "localizationString";
129
+ FileType["LocalizationStringDictionary"] = "localizationStringDictionary";
130
+ FileType["XcAppExtensionPoints"] = "xcAppExtensionPoints";
131
+ FileType["XcodeSpecificationPlist"] = "xcodeSpecificationPlist";
132
+ FileType["Dae"] = "dae";
133
+ FileType["Nib"] = "nib";
134
+ FileType["InterfaceBuilderStoryboardPackage"] = "interfaceBuilderStoryboardPackage";
135
+ FileType["ClassModel"] = "classModel";
136
+ FileType["DataModel"] = "dataModel";
137
+ FileType["DataModelVersion"] = "dataModelVersion";
138
+ FileType["MappingModel"] = "mappingModel";
139
+ FileType["SourceFilesWithNamesMatching"] = "sourceFilesWithNamesMatching";
140
+ })(FileType || (FileType = {}));
141
+ var CopyFilesAction_Destination;
142
+ (function (CopyFilesAction_Destination) {
143
+ CopyFilesAction_Destination["AbsolutePath"] = "absolutePath";
144
+ CopyFilesAction_Destination["ProductsDirectory"] = "productsDirectory";
145
+ CopyFilesAction_Destination["Wrapper"] = "wrapper";
146
+ CopyFilesAction_Destination["Executables"] = "executables";
147
+ CopyFilesAction_Destination["Resources"] = "resources";
148
+ CopyFilesAction_Destination["JavaResources"] = "javaResources";
149
+ CopyFilesAction_Destination["Frameworks"] = "frameworks";
150
+ CopyFilesAction_Destination["SharedFrameworks"] = "sharedFrameworks";
151
+ CopyFilesAction_Destination["SharedSupport"] = "sharedSupport";
152
+ CopyFilesAction_Destination["Plugins"] = "plugins";
153
+ CopyFilesAction_Destination["Other"] = "other";
154
+ })(CopyFilesAction_Destination || (CopyFilesAction_Destination = {}));
155
+ var Destination;
156
+ (function (Destination) {
157
+ Destination["IPhone"] = "iPhone";
158
+ Destination["IPad"] = "iPad";
159
+ Destination["Mac"] = "mac";
160
+ Destination["MacWithiPadDesign"] = "macWithiPadDesign";
161
+ Destination["MacCatalyst"] = "macCatalyst";
162
+ Destination["AppleWatch"] = "appleWatch";
163
+ Destination["AppleTv"] = "appleTv";
164
+ Destination["AppleVision"] = "appleVision";
165
+ Destination["AppleVisionWithiPadDesign"] = "appleVisionWithiPadDesign";
166
+ })(Destination || (Destination = {}));
167
+ var FileCodeGen;
168
+ (function (FileCodeGen) {
169
+ FileCodeGen["Public"] = "public";
170
+ FileCodeGen["Private"] = "private";
171
+ FileCodeGen["Project"] = "project";
172
+ FileCodeGen["Disabled"] = "disabled";
173
+ })(FileCodeGen || (FileCodeGen = {}));
174
+ var LaunchStyle;
175
+ (function (LaunchStyle) {
176
+ LaunchStyle["Automatically"] = "automatically";
177
+ LaunchStyle["WaitForExecutableToBeLaunched"] = "waitForExecutableToBeLaunched";
178
+ })(LaunchStyle || (LaunchStyle = {}));
179
+ var Platform;
180
+ (function (Platform) {
181
+ Platform["IOS"] = "iOS";
182
+ Platform["MacOS"] = "macOS";
183
+ Platform["TvOS"] = "tvOS";
184
+ Platform["WatchOS"] = "watchOS";
185
+ Platform["VisionOS"] = "visionOS";
186
+ })(Platform || (Platform = {}));
187
+ var PackagePlatform;
188
+ (function (PackagePlatform) {
189
+ PackagePlatform["IOS"] = "iOS";
190
+ PackagePlatform["MacCatalyst"] = "macCatalyst";
191
+ PackagePlatform["MacOS"] = "macOS";
192
+ PackagePlatform["TvOS"] = "tvOS";
193
+ PackagePlatform["WatchOS"] = "watchOS";
194
+ PackagePlatform["VisionOS"] = "visionOS";
195
+ })(PackagePlatform || (PackagePlatform = {}));
196
+ var PlatformFilter;
197
+ (function (PlatformFilter) {
198
+ PlatformFilter["Ios"] = "ios";
199
+ PlatformFilter["Macos"] = "macos";
200
+ PlatformFilter["Tvos"] = "tvos";
201
+ PlatformFilter["Catalyst"] = "catalyst";
202
+ PlatformFilter["Driverkit"] = "driverkit";
203
+ PlatformFilter["Watchos"] = "watchos";
204
+ PlatformFilter["Visionos"] = "visionos";
205
+ })(PlatformFilter || (PlatformFilter = {}));
206
+ var Product;
207
+ (function (Product) {
208
+ Product["App"] = "app";
209
+ Product["StaticLibrary"] = "staticLibrary";
210
+ Product["DynamicLibrary"] = "dynamicLibrary";
211
+ Product["Framework"] = "framework";
212
+ Product["StaticFramework"] = "staticFramework";
213
+ Product["UnitTests"] = "unitTests";
214
+ Product["UiTests"] = "uiTests";
215
+ Product["Bundle"] = "bundle";
216
+ Product["CommandLineTool"] = "commandLineTool";
217
+ Product["AppExtension"] = "appExtension";
218
+ Product["Watch2App"] = "watch2App";
219
+ Product["Watch2Extension"] = "watch2Extension";
220
+ Product["TvTopShelfExtension"] = "tvTopShelfExtension";
221
+ Product["MessagesExtension"] = "messagesExtension";
222
+ Product["StickerPackExtension"] = "stickerPackExtension";
223
+ Product["AppClip"] = "appClip";
224
+ Product["Xpc"] = "xpc";
225
+ Product["SystemExtension"] = "systemExtension";
226
+ Product["ExtensionKitExtension"] = "extensionKitExtension";
227
+ Product["Macro"] = "macro";
228
+ })(Product || (Product = {}));
229
+ var ResourceSynthesizer_Parser;
230
+ (function (ResourceSynthesizer_Parser) {
231
+ ResourceSynthesizer_Parser["Strings"] = "strings";
232
+ ResourceSynthesizer_Parser["StringsCatalog"] = "stringsCatalog";
233
+ ResourceSynthesizer_Parser["Assets"] = "assets";
234
+ ResourceSynthesizer_Parser["Plists"] = "plists";
235
+ ResourceSynthesizer_Parser["Fonts"] = "fonts";
236
+ ResourceSynthesizer_Parser["CoreData"] = "coreData";
237
+ ResourceSynthesizer_Parser["InterfaceBuilder"] = "interfaceBuilder";
238
+ ResourceSynthesizer_Parser["Json"] = "json";
239
+ ResourceSynthesizer_Parser["Yaml"] = "yaml";
240
+ ResourceSynthesizer_Parser["Files"] = "files";
241
+ })(ResourceSynthesizer_Parser || (ResourceSynthesizer_Parser = {}));
242
+ var RunActionOptions_GPUFrameCaptureMode;
243
+ (function (RunActionOptions_GPUFrameCaptureMode) {
244
+ RunActionOptions_GPUFrameCaptureMode["AutoEnabled"] = "autoEnabled";
245
+ RunActionOptions_GPUFrameCaptureMode["Metal"] = "metal";
246
+ RunActionOptions_GPUFrameCaptureMode["OpenGL"] = "openGL";
247
+ RunActionOptions_GPUFrameCaptureMode["Disabled"] = "disabled";
248
+ })(RunActionOptions_GPUFrameCaptureMode || (RunActionOptions_GPUFrameCaptureMode = {}));
249
+ var SDKSource;
250
+ (function (SDKSource) {
251
+ SDKSource["Developer"] = "developer";
252
+ SDKSource["System"] = "system";
253
+ })(SDKSource || (SDKSource = {}));
254
+ var SDKType;
255
+ (function (SDKType) {
256
+ SDKType["Framework"] = "framework";
257
+ SDKType["Library"] = "library";
258
+ SDKType["SwiftLibrary"] = "swiftLibrary";
259
+ })(SDKType || (SDKType = {}));
260
+ var ScreenCaptureFormat;
261
+ (function (ScreenCaptureFormat) {
262
+ ScreenCaptureFormat["Screenshots"] = "screenshots";
263
+ ScreenCaptureFormat["ScreenRecording"] = "screenRecording";
264
+ })(ScreenCaptureFormat || (ScreenCaptureFormat = {}));
265
+ var LinkingStatus;
266
+ (function (LinkingStatus) {
267
+ LinkingStatus["Required"] = "required";
268
+ LinkingStatus["Optional"] = "optional";
269
+ LinkingStatus["None"] = "none";
270
+ })(LinkingStatus || (LinkingStatus = {}));
271
+ var TargetDependency_PackageType;
272
+ (function (TargetDependency_PackageType) {
273
+ TargetDependency_PackageType["Runtime"] = "runtime";
274
+ TargetDependency_PackageType["RuntimeEmbedded"] = "runtimeEmbedded";
275
+ TargetDependency_PackageType["Plugin"] = "plugin";
276
+ TargetDependency_PackageType["Macro"] = "macro";
277
+ })(TargetDependency_PackageType || (TargetDependency_PackageType = {}));
278
+ var TargetScript_Order;
279
+ (function (TargetScript_Order) {
280
+ TargetScript_Order["Pre"] = "pre";
281
+ TargetScript_Order["Post"] = "post";
282
+ })(TargetScript_Order || (TargetScript_Order = {}));
283
+ var TargetType;
284
+ (function (TargetType) {
285
+ TargetType["Local"] = "local";
286
+ TargetType["Remote"] = "remote";
287
+ })(TargetType || (TargetType = {}));
288
+ var TestableTarget_Parallelization;
289
+ (function (TestableTarget_Parallelization) {
290
+ TestableTarget_Parallelization["None"] = "none";
291
+ TestableTarget_Parallelization["SwiftTestingOnly"] = "swiftTestingOnly";
292
+ TestableTarget_Parallelization["All"] = "all";
293
+ })(TestableTarget_Parallelization || (TestableTarget_Parallelization = {}));
294
+ var XCFrameworkInfoPlist_Library_Platform;
295
+ (function (XCFrameworkInfoPlist_Library_Platform) {
296
+ XCFrameworkInfoPlist_Library_Platform["IOS"] = "iOS";
297
+ XCFrameworkInfoPlist_Library_Platform["MacOS"] = "macOS";
298
+ XCFrameworkInfoPlist_Library_Platform["TvOS"] = "tvOS";
299
+ XCFrameworkInfoPlist_Library_Platform["WatchOS"] = "watchOS";
300
+ XCFrameworkInfoPlist_Library_Platform["VisionOS"] = "visionOS";
301
+ })(XCFrameworkInfoPlist_Library_Platform || (XCFrameworkInfoPlist_Library_Platform = {}));
302
+ var PackageInfo_Product_ProductType_LibraryType;
303
+ (function (PackageInfo_Product_ProductType_LibraryType) {
304
+ PackageInfo_Product_ProductType_LibraryType["Static"] = "static";
305
+ PackageInfo_Product_ProductType_LibraryType["Dynamic"] = "dynamic";
306
+ PackageInfo_Product_ProductType_LibraryType["Automatic"] = "automatic";
307
+ })(PackageInfo_Product_ProductType_LibraryType || (PackageInfo_Product_ProductType_LibraryType = {}));
308
+ var PackageInfo_Target_Resource_Rule;
309
+ (function (PackageInfo_Target_Resource_Rule) {
310
+ PackageInfo_Target_Resource_Rule["Process"] = "process";
311
+ PackageInfo_Target_Resource_Rule["Copy"] = "copy";
312
+ })(PackageInfo_Target_Resource_Rule || (PackageInfo_Target_Resource_Rule = {}));
313
+ var PackageInfo_Target_Resource_Localization;
314
+ (function (PackageInfo_Target_Resource_Localization) {
315
+ PackageInfo_Target_Resource_Localization["Default"] = "default";
316
+ PackageInfo_Target_Resource_Localization["Base"] = "base";
317
+ })(PackageInfo_Target_Resource_Localization || (PackageInfo_Target_Resource_Localization = {}));
318
+ var PackageInfo_Target_TargetType;
319
+ (function (PackageInfo_Target_TargetType) {
320
+ PackageInfo_Target_TargetType["Regular"] = "regular";
321
+ PackageInfo_Target_TargetType["Executable"] = "executable";
322
+ PackageInfo_Target_TargetType["Test"] = "test";
323
+ PackageInfo_Target_TargetType["System"] = "system";
324
+ PackageInfo_Target_TargetType["Binary"] = "binary";
325
+ PackageInfo_Target_TargetType["Plugin"] = "plugin";
326
+ PackageInfo_Target_TargetType["Macro"] = "macro";
327
+ })(PackageInfo_Target_TargetType || (PackageInfo_Target_TargetType = {}));
328
+ var PackageInfo_Target_TargetBuildSettingDescription_Tool;
329
+ (function (PackageInfo_Target_TargetBuildSettingDescription_Tool) {
330
+ PackageInfo_Target_TargetBuildSettingDescription_Tool["C"] = "c";
331
+ PackageInfo_Target_TargetBuildSettingDescription_Tool["Cxx"] = "cxx";
332
+ PackageInfo_Target_TargetBuildSettingDescription_Tool["Swift"] = "swift";
333
+ PackageInfo_Target_TargetBuildSettingDescription_Tool["Linker"] = "linker";
334
+ })(PackageInfo_Target_TargetBuildSettingDescription_Tool || (PackageInfo_Target_TargetBuildSettingDescription_Tool = {}));
335
+ var PackageInfo_Target_TargetBuildSettingDescription_SettingName;
336
+ (function (PackageInfo_Target_TargetBuildSettingDescription_SettingName) {
337
+ PackageInfo_Target_TargetBuildSettingDescription_SettingName["SwiftLanguageMode"] = "swiftLanguageMode";
338
+ PackageInfo_Target_TargetBuildSettingDescription_SettingName["HeaderSearchPath"] = "headerSearchPath";
339
+ PackageInfo_Target_TargetBuildSettingDescription_SettingName["Define"] = "define";
340
+ PackageInfo_Target_TargetBuildSettingDescription_SettingName["LinkedLibrary"] = "linkedLibrary";
341
+ PackageInfo_Target_TargetBuildSettingDescription_SettingName["LinkedFramework"] = "linkedFramework";
342
+ PackageInfo_Target_TargetBuildSettingDescription_SettingName["UnsafeFlags"] = "unsafeFlags";
343
+ PackageInfo_Target_TargetBuildSettingDescription_SettingName["EnableUpcomingFeature"] = "enableUpcomingFeature";
344
+ PackageInfo_Target_TargetBuildSettingDescription_SettingName["EnableExperimentalFeature"] = "enableExperimentalFeature";
345
+ })(PackageInfo_Target_TargetBuildSettingDescription_SettingName || (PackageInfo_Target_TargetBuildSettingDescription_SettingName = {}));
346
+
347
+ /** A special constant with type `never` */
348
+ function $constructor(name, initializer, params) {
349
+ function init(inst, def) {
350
+ if (!inst._zod) {
351
+ Object.defineProperty(inst, "_zod", {
352
+ value: {
353
+ def,
354
+ constr: _,
355
+ traits: new Set(),
356
+ },
357
+ enumerable: false,
358
+ });
359
+ }
360
+ if (inst._zod.traits.has(name)) {
361
+ return;
362
+ }
363
+ inst._zod.traits.add(name);
364
+ initializer(inst, def);
365
+ // support prototype modifications
366
+ const proto = _.prototype;
367
+ const keys = Object.keys(proto);
368
+ for (let i = 0; i < keys.length; i++) {
369
+ const k = keys[i];
370
+ if (!(k in inst)) {
371
+ inst[k] = proto[k].bind(inst);
372
+ }
373
+ }
374
+ }
375
+ // doesn't work if Parent has a constructor with arguments
376
+ const Parent = params?.Parent ?? Object;
377
+ class Definition extends Parent {
378
+ }
379
+ Object.defineProperty(Definition, "name", { value: name });
380
+ function _(def) {
381
+ var _a;
382
+ const inst = params?.Parent ? new Definition() : this;
383
+ init(inst, def);
384
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
385
+ for (const fn of inst._zod.deferred) {
386
+ fn();
387
+ }
388
+ return inst;
389
+ }
390
+ Object.defineProperty(_, "init", { value: init });
391
+ Object.defineProperty(_, Symbol.hasInstance, {
392
+ value: (inst) => {
393
+ if (params?.Parent && inst instanceof params.Parent)
394
+ return true;
395
+ return inst?._zod?.traits?.has(name);
396
+ },
397
+ });
398
+ Object.defineProperty(_, "name", { value: name });
399
+ return _;
400
+ }
401
+ class $ZodAsyncError extends Error {
402
+ constructor() {
403
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
404
+ }
405
+ }
406
+ class $ZodEncodeError extends Error {
407
+ constructor(name) {
408
+ super(`Encountered unidirectional transform during encode: ${name}`);
409
+ this.name = "ZodEncodeError";
410
+ }
411
+ }
412
+ const globalConfig = {};
413
+ function config(newConfig) {
414
+ return globalConfig;
415
+ }
416
+
417
+ // functions
418
+ function getEnumValues(entries) {
419
+ const numericValues = Object.values(entries).filter((v) => typeof v === "number");
420
+ const values = Object.entries(entries)
421
+ .filter(([k, _]) => numericValues.indexOf(+k) === -1)
422
+ .map(([_, v]) => v);
423
+ return values;
424
+ }
425
+ function jsonStringifyReplacer(_, value) {
426
+ if (typeof value === "bigint")
427
+ return value.toString();
428
+ return value;
429
+ }
430
+ function cached(getter) {
431
+ return {
432
+ get value() {
433
+ {
434
+ const value = getter();
435
+ Object.defineProperty(this, "value", { value });
436
+ return value;
437
+ }
438
+ },
439
+ };
440
+ }
441
+ function nullish(input) {
442
+ return input === null || input === undefined;
443
+ }
444
+ function cleanRegex(source) {
445
+ const start = source.startsWith("^") ? 1 : 0;
446
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
447
+ return source.slice(start, end);
448
+ }
449
+ const EVALUATING = Symbol("evaluating");
450
+ function defineLazy(object, key, getter) {
451
+ let value = undefined;
452
+ Object.defineProperty(object, key, {
453
+ get() {
454
+ if (value === EVALUATING) {
455
+ // Circular reference detected, return undefined to break the cycle
456
+ return undefined;
457
+ }
458
+ if (value === undefined) {
459
+ value = EVALUATING;
460
+ value = getter();
461
+ }
462
+ return value;
463
+ },
464
+ set(v) {
465
+ Object.defineProperty(object, key, {
466
+ value: v,
467
+ // configurable: true,
468
+ });
469
+ // object[key] = v;
470
+ },
471
+ configurable: true,
472
+ });
473
+ }
474
+ function assignProp(target, prop, value) {
475
+ Object.defineProperty(target, prop, {
476
+ value,
477
+ writable: true,
478
+ enumerable: true,
479
+ configurable: true,
480
+ });
481
+ }
482
+ function mergeDefs(...defs) {
483
+ const mergedDescriptors = {};
484
+ for (const def of defs) {
485
+ const descriptors = Object.getOwnPropertyDescriptors(def);
486
+ Object.assign(mergedDescriptors, descriptors);
487
+ }
488
+ return Object.defineProperties({}, mergedDescriptors);
489
+ }
490
+ function esc(str) {
491
+ return JSON.stringify(str);
492
+ }
493
+ function slugify(input) {
494
+ return input
495
+ .toLowerCase()
496
+ .trim()
497
+ .replace(/[^\w\s-]/g, "")
498
+ .replace(/[\s_-]+/g, "-")
499
+ .replace(/^-+|-+$/g, "");
500
+ }
501
+ const captureStackTrace = ("captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => { });
502
+ function isObject(data) {
503
+ return typeof data === "object" && data !== null && !Array.isArray(data);
504
+ }
505
+ const allowsEval = cached(() => {
506
+ // @ts-ignore
507
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
508
+ return false;
509
+ }
510
+ try {
511
+ const F = Function;
512
+ new F("");
513
+ return true;
514
+ }
515
+ catch (_) {
516
+ return false;
517
+ }
518
+ });
519
+ function isPlainObject(o) {
520
+ if (isObject(o) === false)
521
+ return false;
522
+ // modified constructor
523
+ const ctor = o.constructor;
524
+ if (ctor === undefined)
525
+ return true;
526
+ if (typeof ctor !== "function")
527
+ return true;
528
+ // modified prototype
529
+ const prot = ctor.prototype;
530
+ if (isObject(prot) === false)
531
+ return false;
532
+ // ctor doesn't have static `isPrototypeOf`
533
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
534
+ return false;
535
+ }
536
+ return true;
537
+ }
538
+ function shallowClone(o) {
539
+ if (isPlainObject(o))
540
+ return { ...o };
541
+ if (Array.isArray(o))
542
+ return [...o];
543
+ return o;
544
+ }
545
+ const propertyKeyTypes = new Set(["string", "number", "symbol"]);
546
+ function escapeRegex(str) {
547
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
548
+ }
549
+ // zod-specific utils
550
+ function clone(inst, def, params) {
551
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
552
+ if (!def || params?.parent)
553
+ cl._zod.parent = inst;
554
+ return cl;
555
+ }
556
+ function normalizeParams(_params) {
557
+ const params = _params;
558
+ if (!params)
559
+ return {};
560
+ if (typeof params === "string")
561
+ return { error: () => params };
562
+ if (params?.message !== undefined) {
563
+ if (params?.error !== undefined)
564
+ throw new Error("Cannot specify both `message` and `error` params");
565
+ params.error = params.message;
566
+ }
567
+ delete params.message;
568
+ if (typeof params.error === "string")
569
+ return { ...params, error: () => params.error };
570
+ return params;
571
+ }
572
+ function optionalKeys(shape) {
573
+ return Object.keys(shape).filter((k) => {
574
+ return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
575
+ });
576
+ }
577
+ function pick(schema, mask) {
578
+ const currDef = schema._zod.def;
579
+ const checks = currDef.checks;
580
+ const hasChecks = checks && checks.length > 0;
581
+ if (hasChecks) {
582
+ throw new Error(".pick() cannot be used on object schemas containing refinements");
583
+ }
584
+ const def = mergeDefs(schema._zod.def, {
585
+ get shape() {
586
+ const newShape = {};
587
+ for (const key in mask) {
588
+ if (!(key in currDef.shape)) {
589
+ throw new Error(`Unrecognized key: "${key}"`);
590
+ }
591
+ if (!mask[key])
592
+ continue;
593
+ newShape[key] = currDef.shape[key];
594
+ }
595
+ assignProp(this, "shape", newShape); // self-caching
596
+ return newShape;
597
+ },
598
+ checks: [],
599
+ });
600
+ return clone(schema, def);
601
+ }
602
+ function omit(schema, mask) {
603
+ const currDef = schema._zod.def;
604
+ const checks = currDef.checks;
605
+ const hasChecks = checks && checks.length > 0;
606
+ if (hasChecks) {
607
+ throw new Error(".omit() cannot be used on object schemas containing refinements");
608
+ }
609
+ const def = mergeDefs(schema._zod.def, {
610
+ get shape() {
611
+ const newShape = { ...schema._zod.def.shape };
612
+ for (const key in mask) {
613
+ if (!(key in currDef.shape)) {
614
+ throw new Error(`Unrecognized key: "${key}"`);
615
+ }
616
+ if (!mask[key])
617
+ continue;
618
+ delete newShape[key];
619
+ }
620
+ assignProp(this, "shape", newShape); // self-caching
621
+ return newShape;
622
+ },
623
+ checks: [],
624
+ });
625
+ return clone(schema, def);
626
+ }
627
+ function extend(schema, shape) {
628
+ if (!isPlainObject(shape)) {
629
+ throw new Error("Invalid input to extend: expected a plain object");
630
+ }
631
+ const checks = schema._zod.def.checks;
632
+ const hasChecks = checks && checks.length > 0;
633
+ if (hasChecks) {
634
+ // Only throw if new shape overlaps with existing shape
635
+ // Use getOwnPropertyDescriptor to check key existence without accessing values
636
+ const existingShape = schema._zod.def.shape;
637
+ for (const key in shape) {
638
+ if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
639
+ throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
640
+ }
641
+ }
642
+ }
643
+ const def = mergeDefs(schema._zod.def, {
644
+ get shape() {
645
+ const _shape = { ...schema._zod.def.shape, ...shape };
646
+ assignProp(this, "shape", _shape); // self-caching
647
+ return _shape;
648
+ },
649
+ });
650
+ return clone(schema, def);
651
+ }
652
+ function safeExtend(schema, shape) {
653
+ if (!isPlainObject(shape)) {
654
+ throw new Error("Invalid input to safeExtend: expected a plain object");
655
+ }
656
+ const def = mergeDefs(schema._zod.def, {
657
+ get shape() {
658
+ const _shape = { ...schema._zod.def.shape, ...shape };
659
+ assignProp(this, "shape", _shape); // self-caching
660
+ return _shape;
661
+ },
662
+ });
663
+ return clone(schema, def);
664
+ }
665
+ function merge(a, b) {
666
+ const def = mergeDefs(a._zod.def, {
667
+ get shape() {
668
+ const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
669
+ assignProp(this, "shape", _shape); // self-caching
670
+ return _shape;
671
+ },
672
+ get catchall() {
673
+ return b._zod.def.catchall;
674
+ },
675
+ checks: [], // delete existing checks
676
+ });
677
+ return clone(a, def);
678
+ }
679
+ function partial(Class, schema, mask) {
680
+ const currDef = schema._zod.def;
681
+ const checks = currDef.checks;
682
+ const hasChecks = checks && checks.length > 0;
683
+ if (hasChecks) {
684
+ throw new Error(".partial() cannot be used on object schemas containing refinements");
685
+ }
686
+ const def = mergeDefs(schema._zod.def, {
687
+ get shape() {
688
+ const oldShape = schema._zod.def.shape;
689
+ const shape = { ...oldShape };
690
+ if (mask) {
691
+ for (const key in mask) {
692
+ if (!(key in oldShape)) {
693
+ throw new Error(`Unrecognized key: "${key}"`);
694
+ }
695
+ if (!mask[key])
696
+ continue;
697
+ // if (oldShape[key]!._zod.optin === "optional") continue;
698
+ shape[key] = Class
699
+ ? new Class({
700
+ type: "optional",
701
+ innerType: oldShape[key],
702
+ })
703
+ : oldShape[key];
704
+ }
705
+ }
706
+ else {
707
+ for (const key in oldShape) {
708
+ // if (oldShape[key]!._zod.optin === "optional") continue;
709
+ shape[key] = Class
710
+ ? new Class({
711
+ type: "optional",
712
+ innerType: oldShape[key],
713
+ })
714
+ : oldShape[key];
715
+ }
716
+ }
717
+ assignProp(this, "shape", shape); // self-caching
718
+ return shape;
719
+ },
720
+ checks: [],
721
+ });
722
+ return clone(schema, def);
723
+ }
724
+ function required(Class, schema, mask) {
725
+ const def = mergeDefs(schema._zod.def, {
726
+ get shape() {
727
+ const oldShape = schema._zod.def.shape;
728
+ const shape = { ...oldShape };
729
+ if (mask) {
730
+ for (const key in mask) {
731
+ if (!(key in shape)) {
732
+ throw new Error(`Unrecognized key: "${key}"`);
733
+ }
734
+ if (!mask[key])
735
+ continue;
736
+ // overwrite with non-optional
737
+ shape[key] = new Class({
738
+ type: "nonoptional",
739
+ innerType: oldShape[key],
740
+ });
741
+ }
742
+ }
743
+ else {
744
+ for (const key in oldShape) {
745
+ // overwrite with non-optional
746
+ shape[key] = new Class({
747
+ type: "nonoptional",
748
+ innerType: oldShape[key],
749
+ });
750
+ }
751
+ }
752
+ assignProp(this, "shape", shape); // self-caching
753
+ return shape;
754
+ },
755
+ });
756
+ return clone(schema, def);
757
+ }
758
+ // invalid_type | too_big | too_small | invalid_format | not_multiple_of | unrecognized_keys | invalid_union | invalid_key | invalid_element | invalid_value | custom
759
+ function aborted(x, startIndex = 0) {
760
+ if (x.aborted === true)
761
+ return true;
762
+ for (let i = startIndex; i < x.issues.length; i++) {
763
+ if (x.issues[i]?.continue !== true) {
764
+ return true;
765
+ }
766
+ }
767
+ return false;
768
+ }
769
+ function prefixIssues(path, issues) {
770
+ return issues.map((iss) => {
771
+ var _a;
772
+ (_a = iss).path ?? (_a.path = []);
773
+ iss.path.unshift(path);
774
+ return iss;
775
+ });
776
+ }
777
+ function unwrapMessage(message) {
778
+ return typeof message === "string" ? message : message?.message;
779
+ }
780
+ function finalizeIssue(iss, ctx, config) {
781
+ const full = { ...iss, path: iss.path ?? [] };
782
+ // for backwards compatibility
783
+ if (!iss.message) {
784
+ const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??
785
+ unwrapMessage(ctx?.error?.(iss)) ??
786
+ unwrapMessage(config.customError?.(iss)) ??
787
+ unwrapMessage(config.localeError?.(iss)) ??
788
+ "Invalid input";
789
+ full.message = message;
790
+ }
791
+ // delete (full as any).def;
792
+ delete full.inst;
793
+ delete full.continue;
794
+ if (!ctx?.reportInput) {
795
+ delete full.input;
796
+ }
797
+ return full;
798
+ }
799
+ function getLengthableOrigin(input) {
800
+ if (Array.isArray(input))
801
+ return "array";
802
+ if (typeof input === "string")
803
+ return "string";
804
+ return "unknown";
805
+ }
806
+ function issue(...args) {
807
+ const [iss, input, inst] = args;
808
+ if (typeof iss === "string") {
809
+ return {
810
+ message: iss,
811
+ code: "custom",
812
+ input,
813
+ inst,
814
+ };
815
+ }
816
+ return { ...iss };
817
+ }
818
+
819
+ const initializer$1 = (inst, def) => {
820
+ inst.name = "$ZodError";
821
+ Object.defineProperty(inst, "_zod", {
822
+ value: inst._zod,
823
+ enumerable: false,
824
+ });
825
+ Object.defineProperty(inst, "issues", {
826
+ value: def,
827
+ enumerable: false,
828
+ });
829
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
830
+ Object.defineProperty(inst, "toString", {
831
+ value: () => inst.message,
832
+ enumerable: false,
833
+ });
834
+ };
835
+ const $ZodError = $constructor("$ZodError", initializer$1);
836
+ const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
837
+ function flattenError(error, mapper = (issue) => issue.message) {
838
+ const fieldErrors = {};
839
+ const formErrors = [];
840
+ for (const sub of error.issues) {
841
+ if (sub.path.length > 0) {
842
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
843
+ fieldErrors[sub.path[0]].push(mapper(sub));
844
+ }
845
+ else {
846
+ formErrors.push(mapper(sub));
847
+ }
848
+ }
849
+ return { formErrors, fieldErrors };
850
+ }
851
+ function formatError(error, mapper = (issue) => issue.message) {
852
+ const fieldErrors = { _errors: [] };
853
+ const processError = (error) => {
854
+ for (const issue of error.issues) {
855
+ if (issue.code === "invalid_union" && issue.errors.length) {
856
+ issue.errors.map((issues) => processError({ issues }));
857
+ }
858
+ else if (issue.code === "invalid_key") {
859
+ processError({ issues: issue.issues });
860
+ }
861
+ else if (issue.code === "invalid_element") {
862
+ processError({ issues: issue.issues });
863
+ }
864
+ else if (issue.path.length === 0) {
865
+ fieldErrors._errors.push(mapper(issue));
866
+ }
867
+ else {
868
+ let curr = fieldErrors;
869
+ let i = 0;
870
+ while (i < issue.path.length) {
871
+ const el = issue.path[i];
872
+ const terminal = i === issue.path.length - 1;
873
+ if (!terminal) {
874
+ curr[el] = curr[el] || { _errors: [] };
875
+ }
876
+ else {
877
+ curr[el] = curr[el] || { _errors: [] };
878
+ curr[el]._errors.push(mapper(issue));
879
+ }
880
+ curr = curr[el];
881
+ i++;
882
+ }
883
+ }
884
+ }
885
+ };
886
+ processError(error);
887
+ return fieldErrors;
888
+ }
889
+
890
+ const _parse = (_Err) => (schema, value, _ctx, _params) => {
891
+ const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
892
+ const result = schema._zod.run({ value, issues: [] }, ctx);
893
+ if (result instanceof Promise) {
894
+ throw new $ZodAsyncError();
895
+ }
896
+ if (result.issues.length) {
897
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
898
+ captureStackTrace(e, _params?.callee);
899
+ throw e;
900
+ }
901
+ return result.value;
902
+ };
903
+ const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
904
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
905
+ let result = schema._zod.run({ value, issues: [] }, ctx);
906
+ if (result instanceof Promise)
907
+ result = await result;
908
+ if (result.issues.length) {
909
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
910
+ captureStackTrace(e, params?.callee);
911
+ throw e;
912
+ }
913
+ return result.value;
914
+ };
915
+ const _safeParse = (_Err) => (schema, value, _ctx) => {
916
+ const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
917
+ const result = schema._zod.run({ value, issues: [] }, ctx);
918
+ if (result instanceof Promise) {
919
+ throw new $ZodAsyncError();
920
+ }
921
+ return result.issues.length
922
+ ? {
923
+ success: false,
924
+ error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config()))),
925
+ }
926
+ : { success: true, data: result.value };
927
+ };
928
+ const safeParse$1 = /* @__PURE__*/ _safeParse($ZodRealError);
929
+ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
930
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
931
+ let result = schema._zod.run({ value, issues: [] }, ctx);
932
+ if (result instanceof Promise)
933
+ result = await result;
934
+ return result.issues.length
935
+ ? {
936
+ success: false,
937
+ error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config()))),
938
+ }
939
+ : { success: true, data: result.value };
940
+ };
941
+ const safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
942
+ const _encode = (_Err) => (schema, value, _ctx) => {
943
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
944
+ return _parse(_Err)(schema, value, ctx);
945
+ };
946
+ const _decode = (_Err) => (schema, value, _ctx) => {
947
+ return _parse(_Err)(schema, value, _ctx);
948
+ };
949
+ const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
950
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
951
+ return _parseAsync(_Err)(schema, value, ctx);
952
+ };
953
+ const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
954
+ return _parseAsync(_Err)(schema, value, _ctx);
955
+ };
956
+ const _safeEncode = (_Err) => (schema, value, _ctx) => {
957
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
958
+ return _safeParse(_Err)(schema, value, ctx);
959
+ };
960
+ const _safeDecode = (_Err) => (schema, value, _ctx) => {
961
+ return _safeParse(_Err)(schema, value, _ctx);
962
+ };
963
+ const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
964
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
965
+ return _safeParseAsync(_Err)(schema, value, ctx);
966
+ };
967
+ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
968
+ return _safeParseAsync(_Err)(schema, value, _ctx);
969
+ };
970
+
971
+ const cuid = /^[cC][^\s-]{8,}$/;
972
+ const cuid2 = /^[0-9a-z]+$/;
973
+ const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
974
+ const xid = /^[0-9a-vA-V]{20}$/;
975
+ const ksuid = /^[A-Za-z0-9]{27}$/;
976
+ const nanoid = /^[a-zA-Z0-9_-]{21}$/;
977
+ /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
978
+ const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
979
+ /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
980
+ const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
981
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
982
+ *
983
+ * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
984
+ const uuid = (version) => {
985
+ if (!version)
986
+ return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
987
+ return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
988
+ };
989
+ /** Practical email validation */
990
+ const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
991
+ // from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
992
+ const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
993
+ function emoji() {
994
+ return new RegExp(_emoji$1, "u");
995
+ }
996
+ const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
997
+ const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
998
+ const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
999
+ const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
1000
+ // https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
1001
+ const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
1002
+ const base64url = /^[A-Za-z0-9_-]*$/;
1003
+ // https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
1004
+ // E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15
1005
+ const e164 = /^\+[1-9]\d{6,14}$/;
1006
+ // const dateSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
1007
+ const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
1008
+ const date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
1009
+ function timeSource(args) {
1010
+ const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
1011
+ const regex = typeof args.precision === "number"
1012
+ ? args.precision === -1
1013
+ ? `${hhmm}`
1014
+ : args.precision === 0
1015
+ ? `${hhmm}:[0-5]\\d`
1016
+ : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}`
1017
+ : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
1018
+ return regex;
1019
+ }
1020
+ function time$1(args) {
1021
+ return new RegExp(`^${timeSource(args)}$`);
1022
+ }
1023
+ // Adapted from https://stackoverflow.com/a/3143231
1024
+ function datetime$1(args) {
1025
+ const time = timeSource({ precision: args.precision });
1026
+ const opts = ["Z"];
1027
+ if (args.local)
1028
+ opts.push("");
1029
+ // if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`);
1030
+ if (args.offset)
1031
+ opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
1032
+ const timeRegex = `${time}(?:${opts.join("|")})`;
1033
+ return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
1034
+ }
1035
+ const string$1 = (params) => {
1036
+ const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
1037
+ return new RegExp(`^${regex}$`);
1038
+ };
1039
+ // regex for string with no uppercase letters
1040
+ const lowercase = /^[^A-Z]*$/;
1041
+ // regex for string with no lowercase letters
1042
+ const uppercase = /^[^a-z]*$/;
1043
+
1044
+ // import { $ZodType } from "./schemas.js";
1045
+ const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
1046
+ var _a;
1047
+ inst._zod ?? (inst._zod = {});
1048
+ inst._zod.def = def;
1049
+ (_a = inst._zod).onattach ?? (_a.onattach = []);
1050
+ });
1051
+ const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
1052
+ var _a;
1053
+ $ZodCheck.init(inst, def);
1054
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1055
+ const val = payload.value;
1056
+ return !nullish(val) && val.length !== undefined;
1057
+ });
1058
+ inst._zod.onattach.push((inst) => {
1059
+ const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY);
1060
+ if (def.maximum < curr)
1061
+ inst._zod.bag.maximum = def.maximum;
1062
+ });
1063
+ inst._zod.check = (payload) => {
1064
+ const input = payload.value;
1065
+ const length = input.length;
1066
+ if (length <= def.maximum)
1067
+ return;
1068
+ const origin = getLengthableOrigin(input);
1069
+ payload.issues.push({
1070
+ origin,
1071
+ code: "too_big",
1072
+ maximum: def.maximum,
1073
+ inclusive: true,
1074
+ input,
1075
+ inst,
1076
+ continue: !def.abort,
1077
+ });
1078
+ };
1079
+ });
1080
+ const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
1081
+ var _a;
1082
+ $ZodCheck.init(inst, def);
1083
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1084
+ const val = payload.value;
1085
+ return !nullish(val) && val.length !== undefined;
1086
+ });
1087
+ inst._zod.onattach.push((inst) => {
1088
+ const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY);
1089
+ if (def.minimum > curr)
1090
+ inst._zod.bag.minimum = def.minimum;
1091
+ });
1092
+ inst._zod.check = (payload) => {
1093
+ const input = payload.value;
1094
+ const length = input.length;
1095
+ if (length >= def.minimum)
1096
+ return;
1097
+ const origin = getLengthableOrigin(input);
1098
+ payload.issues.push({
1099
+ origin,
1100
+ code: "too_small",
1101
+ minimum: def.minimum,
1102
+ inclusive: true,
1103
+ input,
1104
+ inst,
1105
+ continue: !def.abort,
1106
+ });
1107
+ };
1108
+ });
1109
+ const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
1110
+ var _a;
1111
+ $ZodCheck.init(inst, def);
1112
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1113
+ const val = payload.value;
1114
+ return !nullish(val) && val.length !== undefined;
1115
+ });
1116
+ inst._zod.onattach.push((inst) => {
1117
+ const bag = inst._zod.bag;
1118
+ bag.minimum = def.length;
1119
+ bag.maximum = def.length;
1120
+ bag.length = def.length;
1121
+ });
1122
+ inst._zod.check = (payload) => {
1123
+ const input = payload.value;
1124
+ const length = input.length;
1125
+ if (length === def.length)
1126
+ return;
1127
+ const origin = getLengthableOrigin(input);
1128
+ const tooBig = length > def.length;
1129
+ payload.issues.push({
1130
+ origin,
1131
+ ...(tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length }),
1132
+ inclusive: true,
1133
+ exact: true,
1134
+ input: payload.value,
1135
+ inst,
1136
+ continue: !def.abort,
1137
+ });
1138
+ };
1139
+ });
1140
+ const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
1141
+ var _a, _b;
1142
+ $ZodCheck.init(inst, def);
1143
+ inst._zod.onattach.push((inst) => {
1144
+ const bag = inst._zod.bag;
1145
+ bag.format = def.format;
1146
+ if (def.pattern) {
1147
+ bag.patterns ?? (bag.patterns = new Set());
1148
+ bag.patterns.add(def.pattern);
1149
+ }
1150
+ });
1151
+ if (def.pattern)
1152
+ (_a = inst._zod).check ?? (_a.check = (payload) => {
1153
+ def.pattern.lastIndex = 0;
1154
+ if (def.pattern.test(payload.value))
1155
+ return;
1156
+ payload.issues.push({
1157
+ origin: "string",
1158
+ code: "invalid_format",
1159
+ format: def.format,
1160
+ input: payload.value,
1161
+ ...(def.pattern ? { pattern: def.pattern.toString() } : {}),
1162
+ inst,
1163
+ continue: !def.abort,
1164
+ });
1165
+ });
1166
+ else
1167
+ (_b = inst._zod).check ?? (_b.check = () => { });
1168
+ });
1169
+ const $ZodCheckRegex = /*@__PURE__*/ $constructor("$ZodCheckRegex", (inst, def) => {
1170
+ $ZodCheckStringFormat.init(inst, def);
1171
+ inst._zod.check = (payload) => {
1172
+ def.pattern.lastIndex = 0;
1173
+ if (def.pattern.test(payload.value))
1174
+ return;
1175
+ payload.issues.push({
1176
+ origin: "string",
1177
+ code: "invalid_format",
1178
+ format: "regex",
1179
+ input: payload.value,
1180
+ pattern: def.pattern.toString(),
1181
+ inst,
1182
+ continue: !def.abort,
1183
+ });
1184
+ };
1185
+ });
1186
+ const $ZodCheckLowerCase = /*@__PURE__*/ $constructor("$ZodCheckLowerCase", (inst, def) => {
1187
+ def.pattern ?? (def.pattern = lowercase);
1188
+ $ZodCheckStringFormat.init(inst, def);
1189
+ });
1190
+ const $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (inst, def) => {
1191
+ def.pattern ?? (def.pattern = uppercase);
1192
+ $ZodCheckStringFormat.init(inst, def);
1193
+ });
1194
+ const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
1195
+ $ZodCheck.init(inst, def);
1196
+ const escapedRegex = escapeRegex(def.includes);
1197
+ const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
1198
+ def.pattern = pattern;
1199
+ inst._zod.onattach.push((inst) => {
1200
+ const bag = inst._zod.bag;
1201
+ bag.patterns ?? (bag.patterns = new Set());
1202
+ bag.patterns.add(pattern);
1203
+ });
1204
+ inst._zod.check = (payload) => {
1205
+ if (payload.value.includes(def.includes, def.position))
1206
+ return;
1207
+ payload.issues.push({
1208
+ origin: "string",
1209
+ code: "invalid_format",
1210
+ format: "includes",
1211
+ includes: def.includes,
1212
+ input: payload.value,
1213
+ inst,
1214
+ continue: !def.abort,
1215
+ });
1216
+ };
1217
+ });
1218
+ const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (inst, def) => {
1219
+ $ZodCheck.init(inst, def);
1220
+ const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
1221
+ def.pattern ?? (def.pattern = pattern);
1222
+ inst._zod.onattach.push((inst) => {
1223
+ const bag = inst._zod.bag;
1224
+ bag.patterns ?? (bag.patterns = new Set());
1225
+ bag.patterns.add(pattern);
1226
+ });
1227
+ inst._zod.check = (payload) => {
1228
+ if (payload.value.startsWith(def.prefix))
1229
+ return;
1230
+ payload.issues.push({
1231
+ origin: "string",
1232
+ code: "invalid_format",
1233
+ format: "starts_with",
1234
+ prefix: def.prefix,
1235
+ input: payload.value,
1236
+ inst,
1237
+ continue: !def.abort,
1238
+ });
1239
+ };
1240
+ });
1241
+ const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst, def) => {
1242
+ $ZodCheck.init(inst, def);
1243
+ const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
1244
+ def.pattern ?? (def.pattern = pattern);
1245
+ inst._zod.onattach.push((inst) => {
1246
+ const bag = inst._zod.bag;
1247
+ bag.patterns ?? (bag.patterns = new Set());
1248
+ bag.patterns.add(pattern);
1249
+ });
1250
+ inst._zod.check = (payload) => {
1251
+ if (payload.value.endsWith(def.suffix))
1252
+ return;
1253
+ payload.issues.push({
1254
+ origin: "string",
1255
+ code: "invalid_format",
1256
+ format: "ends_with",
1257
+ suffix: def.suffix,
1258
+ input: payload.value,
1259
+ inst,
1260
+ continue: !def.abort,
1261
+ });
1262
+ };
1263
+ });
1264
+ const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst, def) => {
1265
+ $ZodCheck.init(inst, def);
1266
+ inst._zod.check = (payload) => {
1267
+ payload.value = def.tx(payload.value);
1268
+ };
1269
+ });
1270
+
1271
+ class Doc {
1272
+ constructor(args = []) {
1273
+ this.content = [];
1274
+ this.indent = 0;
1275
+ if (this)
1276
+ this.args = args;
1277
+ }
1278
+ indented(fn) {
1279
+ this.indent += 1;
1280
+ fn(this);
1281
+ this.indent -= 1;
1282
+ }
1283
+ write(arg) {
1284
+ if (typeof arg === "function") {
1285
+ arg(this, { execution: "sync" });
1286
+ arg(this, { execution: "async" });
1287
+ return;
1288
+ }
1289
+ const content = arg;
1290
+ const lines = content.split("\n").filter((x) => x);
1291
+ const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
1292
+ const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
1293
+ for (const line of dedented) {
1294
+ this.content.push(line);
1295
+ }
1296
+ }
1297
+ compile() {
1298
+ const F = Function;
1299
+ const args = this?.args;
1300
+ const content = this?.content ?? [``];
1301
+ const lines = [...content.map((x) => ` ${x}`)];
1302
+ // console.log(lines.join("\n"));
1303
+ return new F(...args, lines.join("\n"));
1304
+ }
1305
+ }
1306
+
1307
+ const version = {
1308
+ major: 4,
1309
+ minor: 3,
1310
+ patch: 6,
1311
+ };
1312
+
1313
+ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1314
+ var _a;
1315
+ inst ?? (inst = {});
1316
+ inst._zod.def = def; // set _def property
1317
+ inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
1318
+ inst._zod.version = version;
1319
+ const checks = [...(inst._zod.def.checks ?? [])];
1320
+ // if inst is itself a checks.$ZodCheck, run it as a check
1321
+ if (inst._zod.traits.has("$ZodCheck")) {
1322
+ checks.unshift(inst);
1323
+ }
1324
+ for (const ch of checks) {
1325
+ for (const fn of ch._zod.onattach) {
1326
+ fn(inst);
1327
+ }
1328
+ }
1329
+ if (checks.length === 0) {
1330
+ // deferred initializer
1331
+ // inst._zod.parse is not yet defined
1332
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
1333
+ inst._zod.deferred?.push(() => {
1334
+ inst._zod.run = inst._zod.parse;
1335
+ });
1336
+ }
1337
+ else {
1338
+ const runChecks = (payload, checks, ctx) => {
1339
+ let isAborted = aborted(payload);
1340
+ let asyncResult;
1341
+ for (const ch of checks) {
1342
+ if (ch._zod.def.when) {
1343
+ const shouldRun = ch._zod.def.when(payload);
1344
+ if (!shouldRun)
1345
+ continue;
1346
+ }
1347
+ else if (isAborted) {
1348
+ continue;
1349
+ }
1350
+ const currLen = payload.issues.length;
1351
+ const _ = ch._zod.check(payload);
1352
+ if (_ instanceof Promise && ctx?.async === false) {
1353
+ throw new $ZodAsyncError();
1354
+ }
1355
+ if (asyncResult || _ instanceof Promise) {
1356
+ asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
1357
+ await _;
1358
+ const nextLen = payload.issues.length;
1359
+ if (nextLen === currLen)
1360
+ return;
1361
+ if (!isAborted)
1362
+ isAborted = aborted(payload, currLen);
1363
+ });
1364
+ }
1365
+ else {
1366
+ const nextLen = payload.issues.length;
1367
+ if (nextLen === currLen)
1368
+ continue;
1369
+ if (!isAborted)
1370
+ isAborted = aborted(payload, currLen);
1371
+ }
1372
+ }
1373
+ if (asyncResult) {
1374
+ return asyncResult.then(() => {
1375
+ return payload;
1376
+ });
1377
+ }
1378
+ return payload;
1379
+ };
1380
+ const handleCanaryResult = (canary, payload, ctx) => {
1381
+ // abort if the canary is aborted
1382
+ if (aborted(canary)) {
1383
+ canary.aborted = true;
1384
+ return canary;
1385
+ }
1386
+ // run checks first, then
1387
+ const checkResult = runChecks(payload, checks, ctx);
1388
+ if (checkResult instanceof Promise) {
1389
+ if (ctx.async === false)
1390
+ throw new $ZodAsyncError();
1391
+ return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
1392
+ }
1393
+ return inst._zod.parse(checkResult, ctx);
1394
+ };
1395
+ inst._zod.run = (payload, ctx) => {
1396
+ if (ctx.skipChecks) {
1397
+ return inst._zod.parse(payload, ctx);
1398
+ }
1399
+ if (ctx.direction === "backward") {
1400
+ // run canary
1401
+ // initial pass (no checks)
1402
+ const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
1403
+ if (canary instanceof Promise) {
1404
+ return canary.then((canary) => {
1405
+ return handleCanaryResult(canary, payload, ctx);
1406
+ });
1407
+ }
1408
+ return handleCanaryResult(canary, payload, ctx);
1409
+ }
1410
+ // forward
1411
+ const result = inst._zod.parse(payload, ctx);
1412
+ if (result instanceof Promise) {
1413
+ if (ctx.async === false)
1414
+ throw new $ZodAsyncError();
1415
+ return result.then((result) => runChecks(result, checks, ctx));
1416
+ }
1417
+ return runChecks(result, checks, ctx);
1418
+ };
1419
+ }
1420
+ // Lazy initialize ~standard to avoid creating objects for every schema
1421
+ defineLazy(inst, "~standard", () => ({
1422
+ validate: (value) => {
1423
+ try {
1424
+ const r = safeParse$1(inst, value);
1425
+ return r.success ? { value: r.data } : { issues: r.error?.issues };
1426
+ }
1427
+ catch (_) {
1428
+ return safeParseAsync$1(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
1429
+ }
1430
+ },
1431
+ vendor: "zod",
1432
+ version: 1,
1433
+ }));
1434
+ });
1435
+ const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
1436
+ $ZodType.init(inst, def);
1437
+ inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? string$1(inst._zod.bag);
1438
+ inst._zod.parse = (payload, _) => {
1439
+ if (def.coerce)
1440
+ try {
1441
+ payload.value = String(payload.value);
1442
+ }
1443
+ catch (_) { }
1444
+ if (typeof payload.value === "string")
1445
+ return payload;
1446
+ payload.issues.push({
1447
+ expected: "string",
1448
+ code: "invalid_type",
1449
+ input: payload.value,
1450
+ inst,
1451
+ });
1452
+ return payload;
1453
+ };
1454
+ });
1455
+ const $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (inst, def) => {
1456
+ // check initialization must come first
1457
+ $ZodCheckStringFormat.init(inst, def);
1458
+ $ZodString.init(inst, def);
1459
+ });
1460
+ const $ZodGUID = /*@__PURE__*/ $constructor("$ZodGUID", (inst, def) => {
1461
+ def.pattern ?? (def.pattern = guid);
1462
+ $ZodStringFormat.init(inst, def);
1463
+ });
1464
+ const $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (inst, def) => {
1465
+ if (def.version) {
1466
+ const versionMap = {
1467
+ v1: 1,
1468
+ v2: 2,
1469
+ v3: 3,
1470
+ v4: 4,
1471
+ v5: 5,
1472
+ v6: 6,
1473
+ v7: 7,
1474
+ v8: 8,
1475
+ };
1476
+ const v = versionMap[def.version];
1477
+ if (v === undefined)
1478
+ throw new Error(`Invalid UUID version: "${def.version}"`);
1479
+ def.pattern ?? (def.pattern = uuid(v));
1480
+ }
1481
+ else
1482
+ def.pattern ?? (def.pattern = uuid());
1483
+ $ZodStringFormat.init(inst, def);
1484
+ });
1485
+ const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
1486
+ def.pattern ?? (def.pattern = email);
1487
+ $ZodStringFormat.init(inst, def);
1488
+ });
1489
+ const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
1490
+ $ZodStringFormat.init(inst, def);
1491
+ inst._zod.check = (payload) => {
1492
+ try {
1493
+ // Trim whitespace from input
1494
+ const trimmed = payload.value.trim();
1495
+ // @ts-ignore
1496
+ const url = new URL(trimmed);
1497
+ if (def.hostname) {
1498
+ def.hostname.lastIndex = 0;
1499
+ if (!def.hostname.test(url.hostname)) {
1500
+ payload.issues.push({
1501
+ code: "invalid_format",
1502
+ format: "url",
1503
+ note: "Invalid hostname",
1504
+ pattern: def.hostname.source,
1505
+ input: payload.value,
1506
+ inst,
1507
+ continue: !def.abort,
1508
+ });
1509
+ }
1510
+ }
1511
+ if (def.protocol) {
1512
+ def.protocol.lastIndex = 0;
1513
+ if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
1514
+ payload.issues.push({
1515
+ code: "invalid_format",
1516
+ format: "url",
1517
+ note: "Invalid protocol",
1518
+ pattern: def.protocol.source,
1519
+ input: payload.value,
1520
+ inst,
1521
+ continue: !def.abort,
1522
+ });
1523
+ }
1524
+ }
1525
+ // Set the output value based on normalize flag
1526
+ if (def.normalize) {
1527
+ // Use normalized URL
1528
+ payload.value = url.href;
1529
+ }
1530
+ else {
1531
+ // Preserve the original input (trimmed)
1532
+ payload.value = trimmed;
1533
+ }
1534
+ return;
1535
+ }
1536
+ catch (_) {
1537
+ payload.issues.push({
1538
+ code: "invalid_format",
1539
+ format: "url",
1540
+ input: payload.value,
1541
+ inst,
1542
+ continue: !def.abort,
1543
+ });
1544
+ }
1545
+ };
1546
+ });
1547
+ const $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
1548
+ def.pattern ?? (def.pattern = emoji());
1549
+ $ZodStringFormat.init(inst, def);
1550
+ });
1551
+ const $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
1552
+ def.pattern ?? (def.pattern = nanoid);
1553
+ $ZodStringFormat.init(inst, def);
1554
+ });
1555
+ const $ZodCUID = /*@__PURE__*/ $constructor("$ZodCUID", (inst, def) => {
1556
+ def.pattern ?? (def.pattern = cuid);
1557
+ $ZodStringFormat.init(inst, def);
1558
+ });
1559
+ const $ZodCUID2 = /*@__PURE__*/ $constructor("$ZodCUID2", (inst, def) => {
1560
+ def.pattern ?? (def.pattern = cuid2);
1561
+ $ZodStringFormat.init(inst, def);
1562
+ });
1563
+ const $ZodULID = /*@__PURE__*/ $constructor("$ZodULID", (inst, def) => {
1564
+ def.pattern ?? (def.pattern = ulid);
1565
+ $ZodStringFormat.init(inst, def);
1566
+ });
1567
+ const $ZodXID = /*@__PURE__*/ $constructor("$ZodXID", (inst, def) => {
1568
+ def.pattern ?? (def.pattern = xid);
1569
+ $ZodStringFormat.init(inst, def);
1570
+ });
1571
+ const $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
1572
+ def.pattern ?? (def.pattern = ksuid);
1573
+ $ZodStringFormat.init(inst, def);
1574
+ });
1575
+ const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
1576
+ def.pattern ?? (def.pattern = datetime$1(def));
1577
+ $ZodStringFormat.init(inst, def);
1578
+ });
1579
+ const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
1580
+ def.pattern ?? (def.pattern = date$1);
1581
+ $ZodStringFormat.init(inst, def);
1582
+ });
1583
+ const $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
1584
+ def.pattern ?? (def.pattern = time$1(def));
1585
+ $ZodStringFormat.init(inst, def);
1586
+ });
1587
+ const $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
1588
+ def.pattern ?? (def.pattern = duration$1);
1589
+ $ZodStringFormat.init(inst, def);
1590
+ });
1591
+ const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
1592
+ def.pattern ?? (def.pattern = ipv4);
1593
+ $ZodStringFormat.init(inst, def);
1594
+ inst._zod.bag.format = `ipv4`;
1595
+ });
1596
+ const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
1597
+ def.pattern ?? (def.pattern = ipv6);
1598
+ $ZodStringFormat.init(inst, def);
1599
+ inst._zod.bag.format = `ipv6`;
1600
+ inst._zod.check = (payload) => {
1601
+ try {
1602
+ // @ts-ignore
1603
+ new URL(`http://[${payload.value}]`);
1604
+ // return;
1605
+ }
1606
+ catch {
1607
+ payload.issues.push({
1608
+ code: "invalid_format",
1609
+ format: "ipv6",
1610
+ input: payload.value,
1611
+ inst,
1612
+ continue: !def.abort,
1613
+ });
1614
+ }
1615
+ };
1616
+ });
1617
+ const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
1618
+ def.pattern ?? (def.pattern = cidrv4);
1619
+ $ZodStringFormat.init(inst, def);
1620
+ });
1621
+ const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
1622
+ def.pattern ?? (def.pattern = cidrv6); // not used for validation
1623
+ $ZodStringFormat.init(inst, def);
1624
+ inst._zod.check = (payload) => {
1625
+ const parts = payload.value.split("/");
1626
+ try {
1627
+ if (parts.length !== 2)
1628
+ throw new Error();
1629
+ const [address, prefix] = parts;
1630
+ if (!prefix)
1631
+ throw new Error();
1632
+ const prefixNum = Number(prefix);
1633
+ if (`${prefixNum}` !== prefix)
1634
+ throw new Error();
1635
+ if (prefixNum < 0 || prefixNum > 128)
1636
+ throw new Error();
1637
+ // @ts-ignore
1638
+ new URL(`http://[${address}]`);
1639
+ }
1640
+ catch {
1641
+ payload.issues.push({
1642
+ code: "invalid_format",
1643
+ format: "cidrv6",
1644
+ input: payload.value,
1645
+ inst,
1646
+ continue: !def.abort,
1647
+ });
1648
+ }
1649
+ };
1650
+ });
1651
+ ////////////////////////////// ZodBase64 //////////////////////////////
1652
+ function isValidBase64(data) {
1653
+ if (data === "")
1654
+ return true;
1655
+ if (data.length % 4 !== 0)
1656
+ return false;
1657
+ try {
1658
+ // @ts-ignore
1659
+ atob(data);
1660
+ return true;
1661
+ }
1662
+ catch {
1663
+ return false;
1664
+ }
1665
+ }
1666
+ const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
1667
+ def.pattern ?? (def.pattern = base64);
1668
+ $ZodStringFormat.init(inst, def);
1669
+ inst._zod.bag.contentEncoding = "base64";
1670
+ inst._zod.check = (payload) => {
1671
+ if (isValidBase64(payload.value))
1672
+ return;
1673
+ payload.issues.push({
1674
+ code: "invalid_format",
1675
+ format: "base64",
1676
+ input: payload.value,
1677
+ inst,
1678
+ continue: !def.abort,
1679
+ });
1680
+ };
1681
+ });
1682
+ ////////////////////////////// ZodBase64 //////////////////////////////
1683
+ function isValidBase64URL(data) {
1684
+ if (!base64url.test(data))
1685
+ return false;
1686
+ const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
1687
+ const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
1688
+ return isValidBase64(padded);
1689
+ }
1690
+ const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
1691
+ def.pattern ?? (def.pattern = base64url);
1692
+ $ZodStringFormat.init(inst, def);
1693
+ inst._zod.bag.contentEncoding = "base64url";
1694
+ inst._zod.check = (payload) => {
1695
+ if (isValidBase64URL(payload.value))
1696
+ return;
1697
+ payload.issues.push({
1698
+ code: "invalid_format",
1699
+ format: "base64url",
1700
+ input: payload.value,
1701
+ inst,
1702
+ continue: !def.abort,
1703
+ });
1704
+ };
1705
+ });
1706
+ const $ZodE164 = /*@__PURE__*/ $constructor("$ZodE164", (inst, def) => {
1707
+ def.pattern ?? (def.pattern = e164);
1708
+ $ZodStringFormat.init(inst, def);
1709
+ });
1710
+ ////////////////////////////// ZodJWT //////////////////////////////
1711
+ function isValidJWT(token, algorithm = null) {
1712
+ try {
1713
+ const tokensParts = token.split(".");
1714
+ if (tokensParts.length !== 3)
1715
+ return false;
1716
+ const [header] = tokensParts;
1717
+ if (!header)
1718
+ return false;
1719
+ // @ts-ignore
1720
+ const parsedHeader = JSON.parse(atob(header));
1721
+ if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
1722
+ return false;
1723
+ if (!parsedHeader.alg)
1724
+ return false;
1725
+ if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
1726
+ return false;
1727
+ return true;
1728
+ }
1729
+ catch {
1730
+ return false;
1731
+ }
1732
+ }
1733
+ const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
1734
+ $ZodStringFormat.init(inst, def);
1735
+ inst._zod.check = (payload) => {
1736
+ if (isValidJWT(payload.value, def.alg))
1737
+ return;
1738
+ payload.issues.push({
1739
+ code: "invalid_format",
1740
+ format: "jwt",
1741
+ input: payload.value,
1742
+ inst,
1743
+ continue: !def.abort,
1744
+ });
1745
+ };
1746
+ });
1747
+ const $ZodUnknown = /*@__PURE__*/ $constructor("$ZodUnknown", (inst, def) => {
1748
+ $ZodType.init(inst, def);
1749
+ inst._zod.parse = (payload) => payload;
1750
+ });
1751
+ const $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (inst, def) => {
1752
+ $ZodType.init(inst, def);
1753
+ inst._zod.parse = (payload, _ctx) => {
1754
+ payload.issues.push({
1755
+ expected: "never",
1756
+ code: "invalid_type",
1757
+ input: payload.value,
1758
+ inst,
1759
+ });
1760
+ return payload;
1761
+ };
1762
+ });
1763
+ function handleArrayResult(result, final, index) {
1764
+ if (result.issues.length) {
1765
+ final.issues.push(...prefixIssues(index, result.issues));
1766
+ }
1767
+ final.value[index] = result.value;
1768
+ }
1769
+ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1770
+ $ZodType.init(inst, def);
1771
+ inst._zod.parse = (payload, ctx) => {
1772
+ const input = payload.value;
1773
+ if (!Array.isArray(input)) {
1774
+ payload.issues.push({
1775
+ expected: "array",
1776
+ code: "invalid_type",
1777
+ input,
1778
+ inst,
1779
+ });
1780
+ return payload;
1781
+ }
1782
+ payload.value = Array(input.length);
1783
+ const proms = [];
1784
+ for (let i = 0; i < input.length; i++) {
1785
+ const item = input[i];
1786
+ const result = def.element._zod.run({
1787
+ value: item,
1788
+ issues: [],
1789
+ }, ctx);
1790
+ if (result instanceof Promise) {
1791
+ proms.push(result.then((result) => handleArrayResult(result, payload, i)));
1792
+ }
1793
+ else {
1794
+ handleArrayResult(result, payload, i);
1795
+ }
1796
+ }
1797
+ if (proms.length) {
1798
+ return Promise.all(proms).then(() => payload);
1799
+ }
1800
+ return payload; //handleArrayResultsAsync(parseResults, final);
1801
+ };
1802
+ });
1803
+ function handlePropertyResult(result, final, key, input, isOptionalOut) {
1804
+ if (result.issues.length) {
1805
+ // For optional-out schemas, ignore errors on absent keys
1806
+ if (isOptionalOut && !(key in input)) {
1807
+ return;
1808
+ }
1809
+ final.issues.push(...prefixIssues(key, result.issues));
1810
+ }
1811
+ if (result.value === undefined) {
1812
+ if (key in input) {
1813
+ final.value[key] = undefined;
1814
+ }
1815
+ }
1816
+ else {
1817
+ final.value[key] = result.value;
1818
+ }
1819
+ }
1820
+ function normalizeDef(def) {
1821
+ const keys = Object.keys(def.shape);
1822
+ for (const k of keys) {
1823
+ if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
1824
+ throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1825
+ }
1826
+ }
1827
+ const okeys = optionalKeys(def.shape);
1828
+ return {
1829
+ ...def,
1830
+ keys,
1831
+ keySet: new Set(keys),
1832
+ numKeys: keys.length,
1833
+ optionalKeys: new Set(okeys),
1834
+ };
1835
+ }
1836
+ function handleCatchall(proms, input, payload, ctx, def, inst) {
1837
+ const unrecognized = [];
1838
+ // iterate over input keys
1839
+ const keySet = def.keySet;
1840
+ const _catchall = def.catchall._zod;
1841
+ const t = _catchall.def.type;
1842
+ const isOptionalOut = _catchall.optout === "optional";
1843
+ for (const key in input) {
1844
+ if (keySet.has(key))
1845
+ continue;
1846
+ if (t === "never") {
1847
+ unrecognized.push(key);
1848
+ continue;
1849
+ }
1850
+ const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1851
+ if (r instanceof Promise) {
1852
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
1853
+ }
1854
+ else {
1855
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
1856
+ }
1857
+ }
1858
+ if (unrecognized.length) {
1859
+ payload.issues.push({
1860
+ code: "unrecognized_keys",
1861
+ keys: unrecognized,
1862
+ input,
1863
+ inst,
1864
+ });
1865
+ }
1866
+ if (!proms.length)
1867
+ return payload;
1868
+ return Promise.all(proms).then(() => {
1869
+ return payload;
1870
+ });
1871
+ }
1872
+ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1873
+ // requires cast because technically $ZodObject doesn't extend
1874
+ $ZodType.init(inst, def);
1875
+ // const sh = def.shape;
1876
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
1877
+ if (!desc?.get) {
1878
+ const sh = def.shape;
1879
+ Object.defineProperty(def, "shape", {
1880
+ get: () => {
1881
+ const newSh = { ...sh };
1882
+ Object.defineProperty(def, "shape", {
1883
+ value: newSh,
1884
+ });
1885
+ return newSh;
1886
+ },
1887
+ });
1888
+ }
1889
+ const _normalized = cached(() => normalizeDef(def));
1890
+ defineLazy(inst._zod, "propValues", () => {
1891
+ const shape = def.shape;
1892
+ const propValues = {};
1893
+ for (const key in shape) {
1894
+ const field = shape[key]._zod;
1895
+ if (field.values) {
1896
+ propValues[key] ?? (propValues[key] = new Set());
1897
+ for (const v of field.values)
1898
+ propValues[key].add(v);
1899
+ }
1900
+ }
1901
+ return propValues;
1902
+ });
1903
+ const isObject$1 = isObject;
1904
+ const catchall = def.catchall;
1905
+ let value;
1906
+ inst._zod.parse = (payload, ctx) => {
1907
+ value ?? (value = _normalized.value);
1908
+ const input = payload.value;
1909
+ if (!isObject$1(input)) {
1910
+ payload.issues.push({
1911
+ expected: "object",
1912
+ code: "invalid_type",
1913
+ input,
1914
+ inst,
1915
+ });
1916
+ return payload;
1917
+ }
1918
+ payload.value = {};
1919
+ const proms = [];
1920
+ const shape = value.shape;
1921
+ for (const key of value.keys) {
1922
+ const el = shape[key];
1923
+ const isOptionalOut = el._zod.optout === "optional";
1924
+ const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1925
+ if (r instanceof Promise) {
1926
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
1927
+ }
1928
+ else {
1929
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
1930
+ }
1931
+ }
1932
+ if (!catchall) {
1933
+ return proms.length ? Promise.all(proms).then(() => payload) : payload;
1934
+ }
1935
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
1936
+ };
1937
+ });
1938
+ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
1939
+ // requires cast because technically $ZodObject doesn't extend
1940
+ $ZodObject.init(inst, def);
1941
+ const superParse = inst._zod.parse;
1942
+ const _normalized = cached(() => normalizeDef(def));
1943
+ const generateFastpass = (shape) => {
1944
+ const doc = new Doc(["shape", "payload", "ctx"]);
1945
+ const normalized = _normalized.value;
1946
+ const parseStr = (key) => {
1947
+ const k = esc(key);
1948
+ return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1949
+ };
1950
+ doc.write(`const input = payload.value;`);
1951
+ const ids = Object.create(null);
1952
+ let counter = 0;
1953
+ for (const key of normalized.keys) {
1954
+ ids[key] = `key_${counter++}`;
1955
+ }
1956
+ // A: preserve key order {
1957
+ doc.write(`const newResult = {};`);
1958
+ for (const key of normalized.keys) {
1959
+ const id = ids[key];
1960
+ const k = esc(key);
1961
+ const schema = shape[key];
1962
+ const isOptionalOut = schema?._zod?.optout === "optional";
1963
+ doc.write(`const ${id} = ${parseStr(key)};`);
1964
+ if (isOptionalOut) {
1965
+ // For optional-out schemas, ignore errors on absent keys
1966
+ doc.write(`
1967
+ if (${id}.issues.length) {
1968
+ if (${k} in input) {
1969
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1970
+ ...iss,
1971
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1972
+ })));
1973
+ }
1974
+ }
1975
+
1976
+ if (${id}.value === undefined) {
1977
+ if (${k} in input) {
1978
+ newResult[${k}] = undefined;
1979
+ }
1980
+ } else {
1981
+ newResult[${k}] = ${id}.value;
1982
+ }
1983
+
1984
+ `);
1985
+ }
1986
+ else {
1987
+ doc.write(`
1988
+ if (${id}.issues.length) {
1989
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1990
+ ...iss,
1991
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1992
+ })));
1993
+ }
1994
+
1995
+ if (${id}.value === undefined) {
1996
+ if (${k} in input) {
1997
+ newResult[${k}] = undefined;
1998
+ }
1999
+ } else {
2000
+ newResult[${k}] = ${id}.value;
2001
+ }
2002
+
2003
+ `);
2004
+ }
2005
+ }
2006
+ doc.write(`payload.value = newResult;`);
2007
+ doc.write(`return payload;`);
2008
+ const fn = doc.compile();
2009
+ return (payload, ctx) => fn(shape, payload, ctx);
2010
+ };
2011
+ let fastpass;
2012
+ const isObject$1 = isObject;
2013
+ const jit = !globalConfig.jitless;
2014
+ const allowsEval$1 = allowsEval;
2015
+ const fastEnabled = jit && allowsEval$1.value; // && !def.catchall;
2016
+ const catchall = def.catchall;
2017
+ let value;
2018
+ inst._zod.parse = (payload, ctx) => {
2019
+ value ?? (value = _normalized.value);
2020
+ const input = payload.value;
2021
+ if (!isObject$1(input)) {
2022
+ payload.issues.push({
2023
+ expected: "object",
2024
+ code: "invalid_type",
2025
+ input,
2026
+ inst,
2027
+ });
2028
+ return payload;
2029
+ }
2030
+ if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
2031
+ // always synchronous
2032
+ if (!fastpass)
2033
+ fastpass = generateFastpass(def.shape);
2034
+ payload = fastpass(payload, ctx);
2035
+ if (!catchall)
2036
+ return payload;
2037
+ return handleCatchall([], input, payload, ctx, value, inst);
2038
+ }
2039
+ return superParse(payload, ctx);
2040
+ };
2041
+ });
2042
+ function handleUnionResults(results, final, inst, ctx) {
2043
+ for (const result of results) {
2044
+ if (result.issues.length === 0) {
2045
+ final.value = result.value;
2046
+ return final;
2047
+ }
2048
+ }
2049
+ const nonaborted = results.filter((r) => !aborted(r));
2050
+ if (nonaborted.length === 1) {
2051
+ final.value = nonaborted[0].value;
2052
+ return nonaborted[0];
2053
+ }
2054
+ final.issues.push({
2055
+ code: "invalid_union",
2056
+ input: final.value,
2057
+ inst,
2058
+ errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config()))),
2059
+ });
2060
+ return final;
2061
+ }
2062
+ const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
2063
+ $ZodType.init(inst, def);
2064
+ defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined);
2065
+ defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
2066
+ defineLazy(inst._zod, "values", () => {
2067
+ if (def.options.every((o) => o._zod.values)) {
2068
+ return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
2069
+ }
2070
+ return undefined;
2071
+ });
2072
+ defineLazy(inst._zod, "pattern", () => {
2073
+ if (def.options.every((o) => o._zod.pattern)) {
2074
+ const patterns = def.options.map((o) => o._zod.pattern);
2075
+ return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
2076
+ }
2077
+ return undefined;
2078
+ });
2079
+ const single = def.options.length === 1;
2080
+ const first = def.options[0]._zod.run;
2081
+ inst._zod.parse = (payload, ctx) => {
2082
+ if (single) {
2083
+ return first(payload, ctx);
2084
+ }
2085
+ let async = false;
2086
+ const results = [];
2087
+ for (const option of def.options) {
2088
+ const result = option._zod.run({
2089
+ value: payload.value,
2090
+ issues: [],
2091
+ }, ctx);
2092
+ if (result instanceof Promise) {
2093
+ results.push(result);
2094
+ async = true;
2095
+ }
2096
+ else {
2097
+ if (result.issues.length === 0)
2098
+ return result;
2099
+ results.push(result);
2100
+ }
2101
+ }
2102
+ if (!async)
2103
+ return handleUnionResults(results, payload, inst, ctx);
2104
+ return Promise.all(results).then((results) => {
2105
+ return handleUnionResults(results, payload, inst, ctx);
2106
+ });
2107
+ };
2108
+ });
2109
+ const $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def) => {
2110
+ $ZodType.init(inst, def);
2111
+ inst._zod.parse = (payload, ctx) => {
2112
+ const input = payload.value;
2113
+ const left = def.left._zod.run({ value: input, issues: [] }, ctx);
2114
+ const right = def.right._zod.run({ value: input, issues: [] }, ctx);
2115
+ const async = left instanceof Promise || right instanceof Promise;
2116
+ if (async) {
2117
+ return Promise.all([left, right]).then(([left, right]) => {
2118
+ return handleIntersectionResults(payload, left, right);
2119
+ });
2120
+ }
2121
+ return handleIntersectionResults(payload, left, right);
2122
+ };
2123
+ });
2124
+ function mergeValues(a, b) {
2125
+ // const aType = parse.t(a);
2126
+ // const bType = parse.t(b);
2127
+ if (a === b) {
2128
+ return { valid: true, data: a };
2129
+ }
2130
+ if (a instanceof Date && b instanceof Date && +a === +b) {
2131
+ return { valid: true, data: a };
2132
+ }
2133
+ if (isPlainObject(a) && isPlainObject(b)) {
2134
+ const bKeys = Object.keys(b);
2135
+ const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
2136
+ const newObj = { ...a, ...b };
2137
+ for (const key of sharedKeys) {
2138
+ const sharedValue = mergeValues(a[key], b[key]);
2139
+ if (!sharedValue.valid) {
2140
+ return {
2141
+ valid: false,
2142
+ mergeErrorPath: [key, ...sharedValue.mergeErrorPath],
2143
+ };
2144
+ }
2145
+ newObj[key] = sharedValue.data;
2146
+ }
2147
+ return { valid: true, data: newObj };
2148
+ }
2149
+ if (Array.isArray(a) && Array.isArray(b)) {
2150
+ if (a.length !== b.length) {
2151
+ return { valid: false, mergeErrorPath: [] };
2152
+ }
2153
+ const newArray = [];
2154
+ for (let index = 0; index < a.length; index++) {
2155
+ const itemA = a[index];
2156
+ const itemB = b[index];
2157
+ const sharedValue = mergeValues(itemA, itemB);
2158
+ if (!sharedValue.valid) {
2159
+ return {
2160
+ valid: false,
2161
+ mergeErrorPath: [index, ...sharedValue.mergeErrorPath],
2162
+ };
2163
+ }
2164
+ newArray.push(sharedValue.data);
2165
+ }
2166
+ return { valid: true, data: newArray };
2167
+ }
2168
+ return { valid: false, mergeErrorPath: [] };
2169
+ }
2170
+ function handleIntersectionResults(result, left, right) {
2171
+ // Track which side(s) report each key as unrecognized
2172
+ const unrecKeys = new Map();
2173
+ let unrecIssue;
2174
+ for (const iss of left.issues) {
2175
+ if (iss.code === "unrecognized_keys") {
2176
+ unrecIssue ?? (unrecIssue = iss);
2177
+ for (const k of iss.keys) {
2178
+ if (!unrecKeys.has(k))
2179
+ unrecKeys.set(k, {});
2180
+ unrecKeys.get(k).l = true;
2181
+ }
2182
+ }
2183
+ else {
2184
+ result.issues.push(iss);
2185
+ }
2186
+ }
2187
+ for (const iss of right.issues) {
2188
+ if (iss.code === "unrecognized_keys") {
2189
+ for (const k of iss.keys) {
2190
+ if (!unrecKeys.has(k))
2191
+ unrecKeys.set(k, {});
2192
+ unrecKeys.get(k).r = true;
2193
+ }
2194
+ }
2195
+ else {
2196
+ result.issues.push(iss);
2197
+ }
2198
+ }
2199
+ // Report only keys unrecognized by BOTH sides
2200
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
2201
+ if (bothKeys.length && unrecIssue) {
2202
+ result.issues.push({ ...unrecIssue, keys: bothKeys });
2203
+ }
2204
+ if (aborted(result))
2205
+ return result;
2206
+ const merged = mergeValues(left.value, right.value);
2207
+ if (!merged.valid) {
2208
+ throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
2209
+ }
2210
+ result.value = merged.data;
2211
+ return result;
2212
+ }
2213
+ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
2214
+ $ZodType.init(inst, def);
2215
+ const values = getEnumValues(def.entries);
2216
+ const valuesSet = new Set(values);
2217
+ inst._zod.values = valuesSet;
2218
+ inst._zod.pattern = new RegExp(`^(${values
2219
+ .filter((k) => propertyKeyTypes.has(typeof k))
2220
+ .map((o) => (typeof o === "string" ? escapeRegex(o) : o.toString()))
2221
+ .join("|")})$`);
2222
+ inst._zod.parse = (payload, _ctx) => {
2223
+ const input = payload.value;
2224
+ if (valuesSet.has(input)) {
2225
+ return payload;
2226
+ }
2227
+ payload.issues.push({
2228
+ code: "invalid_value",
2229
+ values,
2230
+ input,
2231
+ inst,
2232
+ });
2233
+ return payload;
2234
+ };
2235
+ });
2236
+ const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
2237
+ $ZodType.init(inst, def);
2238
+ inst._zod.parse = (payload, ctx) => {
2239
+ if (ctx.direction === "backward") {
2240
+ throw new $ZodEncodeError(inst.constructor.name);
2241
+ }
2242
+ const _out = def.transform(payload.value, payload);
2243
+ if (ctx.async) {
2244
+ const output = _out instanceof Promise ? _out : Promise.resolve(_out);
2245
+ return output.then((output) => {
2246
+ payload.value = output;
2247
+ return payload;
2248
+ });
2249
+ }
2250
+ if (_out instanceof Promise) {
2251
+ throw new $ZodAsyncError();
2252
+ }
2253
+ payload.value = _out;
2254
+ return payload;
2255
+ };
2256
+ });
2257
+ function handleOptionalResult(result, input) {
2258
+ if (result.issues.length && input === undefined) {
2259
+ return { issues: [], value: undefined };
2260
+ }
2261
+ return result;
2262
+ }
2263
+ const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
2264
+ $ZodType.init(inst, def);
2265
+ inst._zod.optin = "optional";
2266
+ inst._zod.optout = "optional";
2267
+ defineLazy(inst._zod, "values", () => {
2268
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
2269
+ });
2270
+ defineLazy(inst._zod, "pattern", () => {
2271
+ const pattern = def.innerType._zod.pattern;
2272
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : undefined;
2273
+ });
2274
+ inst._zod.parse = (payload, ctx) => {
2275
+ if (def.innerType._zod.optin === "optional") {
2276
+ const result = def.innerType._zod.run(payload, ctx);
2277
+ if (result instanceof Promise)
2278
+ return result.then((r) => handleOptionalResult(r, payload.value));
2279
+ return handleOptionalResult(result, payload.value);
2280
+ }
2281
+ if (payload.value === undefined) {
2282
+ return payload;
2283
+ }
2284
+ return def.innerType._zod.run(payload, ctx);
2285
+ };
2286
+ });
2287
+ const $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
2288
+ // Call parent init - inherits optin/optout = "optional"
2289
+ $ZodOptional.init(inst, def);
2290
+ // Override values/pattern to NOT add undefined
2291
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2292
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2293
+ // Override parse to just delegate (no undefined handling)
2294
+ inst._zod.parse = (payload, ctx) => {
2295
+ return def.innerType._zod.run(payload, ctx);
2296
+ };
2297
+ });
2298
+ const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
2299
+ $ZodType.init(inst, def);
2300
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2301
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2302
+ defineLazy(inst._zod, "pattern", () => {
2303
+ const pattern = def.innerType._zod.pattern;
2304
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : undefined;
2305
+ });
2306
+ defineLazy(inst._zod, "values", () => {
2307
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
2308
+ });
2309
+ inst._zod.parse = (payload, ctx) => {
2310
+ // Forward direction (decode): allow null to pass through
2311
+ if (payload.value === null)
2312
+ return payload;
2313
+ return def.innerType._zod.run(payload, ctx);
2314
+ };
2315
+ });
2316
+ const $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
2317
+ $ZodType.init(inst, def);
2318
+ // inst._zod.qin = "true";
2319
+ inst._zod.optin = "optional";
2320
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2321
+ inst._zod.parse = (payload, ctx) => {
2322
+ if (ctx.direction === "backward") {
2323
+ return def.innerType._zod.run(payload, ctx);
2324
+ }
2325
+ // Forward direction (decode): apply defaults for undefined input
2326
+ if (payload.value === undefined) {
2327
+ payload.value = def.defaultValue;
2328
+ /**
2329
+ * $ZodDefault returns the default value immediately in forward direction.
2330
+ * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
2331
+ return payload;
2332
+ }
2333
+ // Forward direction: continue with default handling
2334
+ const result = def.innerType._zod.run(payload, ctx);
2335
+ if (result instanceof Promise) {
2336
+ return result.then((result) => handleDefaultResult(result, def));
2337
+ }
2338
+ return handleDefaultResult(result, def);
2339
+ };
2340
+ });
2341
+ function handleDefaultResult(payload, def) {
2342
+ if (payload.value === undefined) {
2343
+ payload.value = def.defaultValue;
2344
+ }
2345
+ return payload;
2346
+ }
2347
+ const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
2348
+ $ZodType.init(inst, def);
2349
+ inst._zod.optin = "optional";
2350
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2351
+ inst._zod.parse = (payload, ctx) => {
2352
+ if (ctx.direction === "backward") {
2353
+ return def.innerType._zod.run(payload, ctx);
2354
+ }
2355
+ // Forward direction (decode): apply prefault for undefined input
2356
+ if (payload.value === undefined) {
2357
+ payload.value = def.defaultValue;
2358
+ }
2359
+ return def.innerType._zod.run(payload, ctx);
2360
+ };
2361
+ });
2362
+ const $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
2363
+ $ZodType.init(inst, def);
2364
+ defineLazy(inst._zod, "values", () => {
2365
+ const v = def.innerType._zod.values;
2366
+ return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
2367
+ });
2368
+ inst._zod.parse = (payload, ctx) => {
2369
+ const result = def.innerType._zod.run(payload, ctx);
2370
+ if (result instanceof Promise) {
2371
+ return result.then((result) => handleNonOptionalResult(result, inst));
2372
+ }
2373
+ return handleNonOptionalResult(result, inst);
2374
+ };
2375
+ });
2376
+ function handleNonOptionalResult(payload, inst) {
2377
+ if (!payload.issues.length && payload.value === undefined) {
2378
+ payload.issues.push({
2379
+ code: "invalid_type",
2380
+ expected: "nonoptional",
2381
+ input: payload.value,
2382
+ inst,
2383
+ });
2384
+ }
2385
+ return payload;
2386
+ }
2387
+ const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
2388
+ $ZodType.init(inst, def);
2389
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2390
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2391
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2392
+ inst._zod.parse = (payload, ctx) => {
2393
+ if (ctx.direction === "backward") {
2394
+ return def.innerType._zod.run(payload, ctx);
2395
+ }
2396
+ // Forward direction (decode): apply catch logic
2397
+ const result = def.innerType._zod.run(payload, ctx);
2398
+ if (result instanceof Promise) {
2399
+ return result.then((result) => {
2400
+ payload.value = result.value;
2401
+ if (result.issues.length) {
2402
+ payload.value = def.catchValue({
2403
+ ...payload,
2404
+ error: {
2405
+ issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())),
2406
+ },
2407
+ input: payload.value,
2408
+ });
2409
+ payload.issues = [];
2410
+ }
2411
+ return payload;
2412
+ });
2413
+ }
2414
+ payload.value = result.value;
2415
+ if (result.issues.length) {
2416
+ payload.value = def.catchValue({
2417
+ ...payload,
2418
+ error: {
2419
+ issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())),
2420
+ },
2421
+ input: payload.value,
2422
+ });
2423
+ payload.issues = [];
2424
+ }
2425
+ return payload;
2426
+ };
2427
+ });
2428
+ const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2429
+ $ZodType.init(inst, def);
2430
+ defineLazy(inst._zod, "values", () => def.in._zod.values);
2431
+ defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2432
+ defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2433
+ defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2434
+ inst._zod.parse = (payload, ctx) => {
2435
+ if (ctx.direction === "backward") {
2436
+ const right = def.out._zod.run(payload, ctx);
2437
+ if (right instanceof Promise) {
2438
+ return right.then((right) => handlePipeResult(right, def.in, ctx));
2439
+ }
2440
+ return handlePipeResult(right, def.in, ctx);
2441
+ }
2442
+ const left = def.in._zod.run(payload, ctx);
2443
+ if (left instanceof Promise) {
2444
+ return left.then((left) => handlePipeResult(left, def.out, ctx));
2445
+ }
2446
+ return handlePipeResult(left, def.out, ctx);
2447
+ };
2448
+ });
2449
+ function handlePipeResult(left, next, ctx) {
2450
+ if (left.issues.length) {
2451
+ // prevent further checks
2452
+ left.aborted = true;
2453
+ return left;
2454
+ }
2455
+ return next._zod.run({ value: left.value, issues: left.issues }, ctx);
2456
+ }
2457
+ const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2458
+ $ZodType.init(inst, def);
2459
+ defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2460
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2461
+ defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2462
+ defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2463
+ inst._zod.parse = (payload, ctx) => {
2464
+ if (ctx.direction === "backward") {
2465
+ return def.innerType._zod.run(payload, ctx);
2466
+ }
2467
+ const result = def.innerType._zod.run(payload, ctx);
2468
+ if (result instanceof Promise) {
2469
+ return result.then(handleReadonlyResult);
2470
+ }
2471
+ return handleReadonlyResult(result);
2472
+ };
2473
+ });
2474
+ function handleReadonlyResult(payload) {
2475
+ payload.value = Object.freeze(payload.value);
2476
+ return payload;
2477
+ }
2478
+ const $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
2479
+ $ZodCheck.init(inst, def);
2480
+ $ZodType.init(inst, def);
2481
+ inst._zod.parse = (payload, _) => {
2482
+ return payload;
2483
+ };
2484
+ inst._zod.check = (payload) => {
2485
+ const input = payload.value;
2486
+ const r = def.fn(input);
2487
+ if (r instanceof Promise) {
2488
+ return r.then((r) => handleRefineResult(r, payload, input, inst));
2489
+ }
2490
+ handleRefineResult(r, payload, input, inst);
2491
+ return;
2492
+ };
2493
+ });
2494
+ function handleRefineResult(result, payload, input, inst) {
2495
+ if (!result) {
2496
+ const _iss = {
2497
+ code: "custom",
2498
+ input,
2499
+ inst, // incorporates params.error into issue reporting
2500
+ path: [...(inst._zod.def.path ?? [])], // incorporates params.error into issue reporting
2501
+ continue: !inst._zod.def.abort,
2502
+ // params: inst._zod.def.params,
2503
+ };
2504
+ if (inst._zod.def.params)
2505
+ _iss.params = inst._zod.def.params;
2506
+ payload.issues.push(issue(_iss));
2507
+ }
2508
+ }
2509
+
2510
+ var _a;
2511
+ class $ZodRegistry {
2512
+ constructor() {
2513
+ this._map = new WeakMap();
2514
+ this._idmap = new Map();
2515
+ }
2516
+ add(schema, ..._meta) {
2517
+ const meta = _meta[0];
2518
+ this._map.set(schema, meta);
2519
+ if (meta && typeof meta === "object" && "id" in meta) {
2520
+ this._idmap.set(meta.id, schema);
2521
+ }
2522
+ return this;
2523
+ }
2524
+ clear() {
2525
+ this._map = new WeakMap();
2526
+ this._idmap = new Map();
2527
+ return this;
2528
+ }
2529
+ remove(schema) {
2530
+ const meta = this._map.get(schema);
2531
+ if (meta && typeof meta === "object" && "id" in meta) {
2532
+ this._idmap.delete(meta.id);
2533
+ }
2534
+ this._map.delete(schema);
2535
+ return this;
2536
+ }
2537
+ get(schema) {
2538
+ // return this._map.get(schema) as any;
2539
+ // inherit metadata
2540
+ const p = schema._zod.parent;
2541
+ if (p) {
2542
+ const pm = { ...(this.get(p) ?? {}) };
2543
+ delete pm.id; // do not inherit id
2544
+ const f = { ...pm, ...this._map.get(schema) };
2545
+ return Object.keys(f).length ? f : undefined;
2546
+ }
2547
+ return this._map.get(schema);
2548
+ }
2549
+ has(schema) {
2550
+ return this._map.has(schema);
2551
+ }
2552
+ }
2553
+ // registries
2554
+ function registry() {
2555
+ return new $ZodRegistry();
2556
+ }
2557
+ (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2558
+ const globalRegistry = globalThis.__zod_globalRegistry;
2559
+
2560
+ // @__NO_SIDE_EFFECTS__
2561
+ function _string(Class, params) {
2562
+ return new Class({
2563
+ type: "string",
2564
+ ...normalizeParams(params),
2565
+ });
2566
+ }
2567
+ // @__NO_SIDE_EFFECTS__
2568
+ function _email(Class, params) {
2569
+ return new Class({
2570
+ type: "string",
2571
+ format: "email",
2572
+ check: "string_format",
2573
+ abort: false,
2574
+ ...normalizeParams(params),
2575
+ });
2576
+ }
2577
+ // @__NO_SIDE_EFFECTS__
2578
+ function _guid(Class, params) {
2579
+ return new Class({
2580
+ type: "string",
2581
+ format: "guid",
2582
+ check: "string_format",
2583
+ abort: false,
2584
+ ...normalizeParams(params),
2585
+ });
2586
+ }
2587
+ // @__NO_SIDE_EFFECTS__
2588
+ function _uuid(Class, params) {
2589
+ return new Class({
2590
+ type: "string",
2591
+ format: "uuid",
2592
+ check: "string_format",
2593
+ abort: false,
2594
+ ...normalizeParams(params),
2595
+ });
2596
+ }
2597
+ // @__NO_SIDE_EFFECTS__
2598
+ function _uuidv4(Class, params) {
2599
+ return new Class({
2600
+ type: "string",
2601
+ format: "uuid",
2602
+ check: "string_format",
2603
+ abort: false,
2604
+ version: "v4",
2605
+ ...normalizeParams(params),
2606
+ });
2607
+ }
2608
+ // @__NO_SIDE_EFFECTS__
2609
+ function _uuidv6(Class, params) {
2610
+ return new Class({
2611
+ type: "string",
2612
+ format: "uuid",
2613
+ check: "string_format",
2614
+ abort: false,
2615
+ version: "v6",
2616
+ ...normalizeParams(params),
2617
+ });
2618
+ }
2619
+ // @__NO_SIDE_EFFECTS__
2620
+ function _uuidv7(Class, params) {
2621
+ return new Class({
2622
+ type: "string",
2623
+ format: "uuid",
2624
+ check: "string_format",
2625
+ abort: false,
2626
+ version: "v7",
2627
+ ...normalizeParams(params),
2628
+ });
2629
+ }
2630
+ // @__NO_SIDE_EFFECTS__
2631
+ function _url(Class, params) {
2632
+ return new Class({
2633
+ type: "string",
2634
+ format: "url",
2635
+ check: "string_format",
2636
+ abort: false,
2637
+ ...normalizeParams(params),
2638
+ });
2639
+ }
2640
+ // @__NO_SIDE_EFFECTS__
2641
+ function _emoji(Class, params) {
2642
+ return new Class({
2643
+ type: "string",
2644
+ format: "emoji",
2645
+ check: "string_format",
2646
+ abort: false,
2647
+ ...normalizeParams(params),
2648
+ });
2649
+ }
2650
+ // @__NO_SIDE_EFFECTS__
2651
+ function _nanoid(Class, params) {
2652
+ return new Class({
2653
+ type: "string",
2654
+ format: "nanoid",
2655
+ check: "string_format",
2656
+ abort: false,
2657
+ ...normalizeParams(params),
2658
+ });
2659
+ }
2660
+ // @__NO_SIDE_EFFECTS__
2661
+ function _cuid(Class, params) {
2662
+ return new Class({
2663
+ type: "string",
2664
+ format: "cuid",
2665
+ check: "string_format",
2666
+ abort: false,
2667
+ ...normalizeParams(params),
2668
+ });
2669
+ }
2670
+ // @__NO_SIDE_EFFECTS__
2671
+ function _cuid2(Class, params) {
2672
+ return new Class({
2673
+ type: "string",
2674
+ format: "cuid2",
2675
+ check: "string_format",
2676
+ abort: false,
2677
+ ...normalizeParams(params),
2678
+ });
2679
+ }
2680
+ // @__NO_SIDE_EFFECTS__
2681
+ function _ulid(Class, params) {
2682
+ return new Class({
2683
+ type: "string",
2684
+ format: "ulid",
2685
+ check: "string_format",
2686
+ abort: false,
2687
+ ...normalizeParams(params),
2688
+ });
2689
+ }
2690
+ // @__NO_SIDE_EFFECTS__
2691
+ function _xid(Class, params) {
2692
+ return new Class({
2693
+ type: "string",
2694
+ format: "xid",
2695
+ check: "string_format",
2696
+ abort: false,
2697
+ ...normalizeParams(params),
2698
+ });
2699
+ }
2700
+ // @__NO_SIDE_EFFECTS__
2701
+ function _ksuid(Class, params) {
2702
+ return new Class({
2703
+ type: "string",
2704
+ format: "ksuid",
2705
+ check: "string_format",
2706
+ abort: false,
2707
+ ...normalizeParams(params),
2708
+ });
2709
+ }
2710
+ // @__NO_SIDE_EFFECTS__
2711
+ function _ipv4(Class, params) {
2712
+ return new Class({
2713
+ type: "string",
2714
+ format: "ipv4",
2715
+ check: "string_format",
2716
+ abort: false,
2717
+ ...normalizeParams(params),
2718
+ });
2719
+ }
2720
+ // @__NO_SIDE_EFFECTS__
2721
+ function _ipv6(Class, params) {
2722
+ return new Class({
2723
+ type: "string",
2724
+ format: "ipv6",
2725
+ check: "string_format",
2726
+ abort: false,
2727
+ ...normalizeParams(params),
2728
+ });
2729
+ }
2730
+ // @__NO_SIDE_EFFECTS__
2731
+ function _cidrv4(Class, params) {
2732
+ return new Class({
2733
+ type: "string",
2734
+ format: "cidrv4",
2735
+ check: "string_format",
2736
+ abort: false,
2737
+ ...normalizeParams(params),
2738
+ });
2739
+ }
2740
+ // @__NO_SIDE_EFFECTS__
2741
+ function _cidrv6(Class, params) {
2742
+ return new Class({
2743
+ type: "string",
2744
+ format: "cidrv6",
2745
+ check: "string_format",
2746
+ abort: false,
2747
+ ...normalizeParams(params),
2748
+ });
2749
+ }
2750
+ // @__NO_SIDE_EFFECTS__
2751
+ function _base64(Class, params) {
2752
+ return new Class({
2753
+ type: "string",
2754
+ format: "base64",
2755
+ check: "string_format",
2756
+ abort: false,
2757
+ ...normalizeParams(params),
2758
+ });
2759
+ }
2760
+ // @__NO_SIDE_EFFECTS__
2761
+ function _base64url(Class, params) {
2762
+ return new Class({
2763
+ type: "string",
2764
+ format: "base64url",
2765
+ check: "string_format",
2766
+ abort: false,
2767
+ ...normalizeParams(params),
2768
+ });
2769
+ }
2770
+ // @__NO_SIDE_EFFECTS__
2771
+ function _e164(Class, params) {
2772
+ return new Class({
2773
+ type: "string",
2774
+ format: "e164",
2775
+ check: "string_format",
2776
+ abort: false,
2777
+ ...normalizeParams(params),
2778
+ });
2779
+ }
2780
+ // @__NO_SIDE_EFFECTS__
2781
+ function _jwt(Class, params) {
2782
+ return new Class({
2783
+ type: "string",
2784
+ format: "jwt",
2785
+ check: "string_format",
2786
+ abort: false,
2787
+ ...normalizeParams(params),
2788
+ });
2789
+ }
2790
+ // @__NO_SIDE_EFFECTS__
2791
+ function _isoDateTime(Class, params) {
2792
+ return new Class({
2793
+ type: "string",
2794
+ format: "datetime",
2795
+ check: "string_format",
2796
+ offset: false,
2797
+ local: false,
2798
+ precision: null,
2799
+ ...normalizeParams(params),
2800
+ });
2801
+ }
2802
+ // @__NO_SIDE_EFFECTS__
2803
+ function _isoDate(Class, params) {
2804
+ return new Class({
2805
+ type: "string",
2806
+ format: "date",
2807
+ check: "string_format",
2808
+ ...normalizeParams(params),
2809
+ });
2810
+ }
2811
+ // @__NO_SIDE_EFFECTS__
2812
+ function _isoTime(Class, params) {
2813
+ return new Class({
2814
+ type: "string",
2815
+ format: "time",
2816
+ check: "string_format",
2817
+ precision: null,
2818
+ ...normalizeParams(params),
2819
+ });
2820
+ }
2821
+ // @__NO_SIDE_EFFECTS__
2822
+ function _isoDuration(Class, params) {
2823
+ return new Class({
2824
+ type: "string",
2825
+ format: "duration",
2826
+ check: "string_format",
2827
+ ...normalizeParams(params),
2828
+ });
2829
+ }
2830
+ // @__NO_SIDE_EFFECTS__
2831
+ function _unknown(Class) {
2832
+ return new Class({
2833
+ type: "unknown",
2834
+ });
2835
+ }
2836
+ // @__NO_SIDE_EFFECTS__
2837
+ function _never(Class, params) {
2838
+ return new Class({
2839
+ type: "never",
2840
+ ...normalizeParams(params),
2841
+ });
2842
+ }
2843
+ // @__NO_SIDE_EFFECTS__
2844
+ function _maxLength(maximum, params) {
2845
+ const ch = new $ZodCheckMaxLength({
2846
+ check: "max_length",
2847
+ ...normalizeParams(params),
2848
+ maximum,
2849
+ });
2850
+ return ch;
2851
+ }
2852
+ // @__NO_SIDE_EFFECTS__
2853
+ function _minLength(minimum, params) {
2854
+ return new $ZodCheckMinLength({
2855
+ check: "min_length",
2856
+ ...normalizeParams(params),
2857
+ minimum,
2858
+ });
2859
+ }
2860
+ // @__NO_SIDE_EFFECTS__
2861
+ function _length(length, params) {
2862
+ return new $ZodCheckLengthEquals({
2863
+ check: "length_equals",
2864
+ ...normalizeParams(params),
2865
+ length,
2866
+ });
2867
+ }
2868
+ // @__NO_SIDE_EFFECTS__
2869
+ function _regex(pattern, params) {
2870
+ return new $ZodCheckRegex({
2871
+ check: "string_format",
2872
+ format: "regex",
2873
+ ...normalizeParams(params),
2874
+ pattern,
2875
+ });
2876
+ }
2877
+ // @__NO_SIDE_EFFECTS__
2878
+ function _lowercase(params) {
2879
+ return new $ZodCheckLowerCase({
2880
+ check: "string_format",
2881
+ format: "lowercase",
2882
+ ...normalizeParams(params),
2883
+ });
2884
+ }
2885
+ // @__NO_SIDE_EFFECTS__
2886
+ function _uppercase(params) {
2887
+ return new $ZodCheckUpperCase({
2888
+ check: "string_format",
2889
+ format: "uppercase",
2890
+ ...normalizeParams(params),
2891
+ });
2892
+ }
2893
+ // @__NO_SIDE_EFFECTS__
2894
+ function _includes(includes, params) {
2895
+ return new $ZodCheckIncludes({
2896
+ check: "string_format",
2897
+ format: "includes",
2898
+ ...normalizeParams(params),
2899
+ includes,
2900
+ });
2901
+ }
2902
+ // @__NO_SIDE_EFFECTS__
2903
+ function _startsWith(prefix, params) {
2904
+ return new $ZodCheckStartsWith({
2905
+ check: "string_format",
2906
+ format: "starts_with",
2907
+ ...normalizeParams(params),
2908
+ prefix,
2909
+ });
2910
+ }
2911
+ // @__NO_SIDE_EFFECTS__
2912
+ function _endsWith(suffix, params) {
2913
+ return new $ZodCheckEndsWith({
2914
+ check: "string_format",
2915
+ format: "ends_with",
2916
+ ...normalizeParams(params),
2917
+ suffix,
2918
+ });
2919
+ }
2920
+ // @__NO_SIDE_EFFECTS__
2921
+ function _overwrite(tx) {
2922
+ return new $ZodCheckOverwrite({
2923
+ check: "overwrite",
2924
+ tx,
2925
+ });
2926
+ }
2927
+ // normalize
2928
+ // @__NO_SIDE_EFFECTS__
2929
+ function _normalize(form) {
2930
+ return _overwrite((input) => input.normalize(form));
2931
+ }
2932
+ // trim
2933
+ // @__NO_SIDE_EFFECTS__
2934
+ function _trim() {
2935
+ return _overwrite((input) => input.trim());
2936
+ }
2937
+ // toLowerCase
2938
+ // @__NO_SIDE_EFFECTS__
2939
+ function _toLowerCase() {
2940
+ return _overwrite((input) => input.toLowerCase());
2941
+ }
2942
+ // toUpperCase
2943
+ // @__NO_SIDE_EFFECTS__
2944
+ function _toUpperCase() {
2945
+ return _overwrite((input) => input.toUpperCase());
2946
+ }
2947
+ // slugify
2948
+ // @__NO_SIDE_EFFECTS__
2949
+ function _slugify() {
2950
+ return _overwrite((input) => slugify(input));
2951
+ }
2952
+ // @__NO_SIDE_EFFECTS__
2953
+ function _array(Class, element, params) {
2954
+ return new Class({
2955
+ type: "array",
2956
+ element,
2957
+ // get element() {
2958
+ // return element;
2959
+ // },
2960
+ ...normalizeParams(params),
2961
+ });
2962
+ }
2963
+ // same as _custom but defaults to abort:false
2964
+ // @__NO_SIDE_EFFECTS__
2965
+ function _refine(Class, fn, _params) {
2966
+ const schema = new Class({
2967
+ type: "custom",
2968
+ check: "custom",
2969
+ fn: fn,
2970
+ ...normalizeParams(_params),
2971
+ });
2972
+ return schema;
2973
+ }
2974
+ // @__NO_SIDE_EFFECTS__
2975
+ function _superRefine(fn) {
2976
+ const ch = _check((payload) => {
2977
+ payload.addIssue = (issue$1) => {
2978
+ if (typeof issue$1 === "string") {
2979
+ payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
2980
+ }
2981
+ else {
2982
+ // for Zod 3 backwards compatibility
2983
+ const _issue = issue$1;
2984
+ if (_issue.fatal)
2985
+ _issue.continue = false;
2986
+ _issue.code ?? (_issue.code = "custom");
2987
+ _issue.input ?? (_issue.input = payload.value);
2988
+ _issue.inst ?? (_issue.inst = ch);
2989
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort); // abort is always undefined, so this is always true...
2990
+ payload.issues.push(issue(_issue));
2991
+ }
2992
+ };
2993
+ return fn(payload.value, payload);
2994
+ });
2995
+ return ch;
2996
+ }
2997
+ // @__NO_SIDE_EFFECTS__
2998
+ function _check(fn, params) {
2999
+ const ch = new $ZodCheck({
3000
+ check: "custom",
3001
+ ...normalizeParams(params),
3002
+ });
3003
+ ch._zod.check = fn;
3004
+ return ch;
3005
+ }
3006
+
3007
+ // function initializeContext<T extends schemas.$ZodType>(inputs: JSONSchemaGeneratorParams<T>): ToJSONSchemaContext<T> {
3008
+ // return {
3009
+ // processor: inputs.processor,
3010
+ // metadataRegistry: inputs.metadata ?? globalRegistry,
3011
+ // target: inputs.target ?? "draft-2020-12",
3012
+ // unrepresentable: inputs.unrepresentable ?? "throw",
3013
+ // };
3014
+ // }
3015
+ function initializeContext(params) {
3016
+ // Normalize target: convert old non-hyphenated versions to hyphenated versions
3017
+ let target = params?.target ?? "draft-2020-12";
3018
+ if (target === "draft-4")
3019
+ target = "draft-04";
3020
+ if (target === "draft-7")
3021
+ target = "draft-07";
3022
+ return {
3023
+ processors: params.processors ?? {},
3024
+ metadataRegistry: params?.metadata ?? globalRegistry,
3025
+ target,
3026
+ unrepresentable: params?.unrepresentable ?? "throw",
3027
+ override: params?.override ?? (() => { }),
3028
+ io: params?.io ?? "output",
3029
+ counter: 0,
3030
+ seen: new Map(),
3031
+ cycles: params?.cycles ?? "ref",
3032
+ reused: params?.reused ?? "inline",
3033
+ external: params?.external ?? undefined,
3034
+ };
3035
+ }
3036
+ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
3037
+ var _a;
3038
+ const def = schema._zod.def;
3039
+ // check for schema in seens
3040
+ const seen = ctx.seen.get(schema);
3041
+ if (seen) {
3042
+ seen.count++;
3043
+ // check if cycle
3044
+ const isCycle = _params.schemaPath.includes(schema);
3045
+ if (isCycle) {
3046
+ seen.cycle = _params.path;
3047
+ }
3048
+ return seen.schema;
3049
+ }
3050
+ // initialize
3051
+ const result = { schema: {}, count: 1, cycle: undefined, path: _params.path };
3052
+ ctx.seen.set(schema, result);
3053
+ // custom method overrides default behavior
3054
+ const overrideSchema = schema._zod.toJSONSchema?.();
3055
+ if (overrideSchema) {
3056
+ result.schema = overrideSchema;
3057
+ }
3058
+ else {
3059
+ const params = {
3060
+ ..._params,
3061
+ schemaPath: [..._params.schemaPath, schema],
3062
+ path: _params.path,
3063
+ };
3064
+ if (schema._zod.processJSONSchema) {
3065
+ schema._zod.processJSONSchema(ctx, result.schema, params);
3066
+ }
3067
+ else {
3068
+ const _json = result.schema;
3069
+ const processor = ctx.processors[def.type];
3070
+ if (!processor) {
3071
+ throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
3072
+ }
3073
+ processor(schema, ctx, _json, params);
3074
+ }
3075
+ const parent = schema._zod.parent;
3076
+ if (parent) {
3077
+ // Also set ref if processor didn't (for inheritance)
3078
+ if (!result.ref)
3079
+ result.ref = parent;
3080
+ process(parent, ctx, params);
3081
+ ctx.seen.get(parent).isParent = true;
3082
+ }
3083
+ }
3084
+ // metadata
3085
+ const meta = ctx.metadataRegistry.get(schema);
3086
+ if (meta)
3087
+ Object.assign(result.schema, meta);
3088
+ if (ctx.io === "input" && isTransforming(schema)) {
3089
+ // examples/defaults only apply to output type of pipe
3090
+ delete result.schema.examples;
3091
+ delete result.schema.default;
3092
+ }
3093
+ // set prefault as default
3094
+ if (ctx.io === "input" && result.schema._prefault)
3095
+ (_a = result.schema).default ?? (_a.default = result.schema._prefault);
3096
+ delete result.schema._prefault;
3097
+ // pulling fresh from ctx.seen in case it was overwritten
3098
+ const _result = ctx.seen.get(schema);
3099
+ return _result.schema;
3100
+ }
3101
+ function extractDefs(ctx, schema
3102
+ // params: EmitParams
3103
+ ) {
3104
+ // iterate over seen map;
3105
+ const root = ctx.seen.get(schema);
3106
+ if (!root)
3107
+ throw new Error("Unprocessed schema. This is a bug in Zod.");
3108
+ // Track ids to detect duplicates across different schemas
3109
+ const idToSchema = new Map();
3110
+ for (const entry of ctx.seen.entries()) {
3111
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
3112
+ if (id) {
3113
+ const existing = idToSchema.get(id);
3114
+ if (existing && existing !== entry[0]) {
3115
+ throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
3116
+ }
3117
+ idToSchema.set(id, entry[0]);
3118
+ }
3119
+ }
3120
+ // returns a ref to the schema
3121
+ // defId will be empty if the ref points to an external schema (or #)
3122
+ const makeURI = (entry) => {
3123
+ // comparing the seen objects because sometimes
3124
+ // multiple schemas map to the same seen object.
3125
+ // e.g. lazy
3126
+ // external is configured
3127
+ const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
3128
+ if (ctx.external) {
3129
+ const externalId = ctx.external.registry.get(entry[0])?.id; // ?? "__shared";// `__schema${ctx.counter++}`;
3130
+ // check if schema is in the external registry
3131
+ const uriGenerator = ctx.external.uri ?? ((id) => id);
3132
+ if (externalId) {
3133
+ return { ref: uriGenerator(externalId) };
3134
+ }
3135
+ // otherwise, add to __shared
3136
+ const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
3137
+ entry[1].defId = id; // set defId so it will be reused if needed
3138
+ return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
3139
+ }
3140
+ if (entry[1] === root) {
3141
+ return { ref: "#" };
3142
+ }
3143
+ // self-contained schema
3144
+ const uriPrefix = `#`;
3145
+ const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
3146
+ const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
3147
+ return { defId, ref: defUriPrefix + defId };
3148
+ };
3149
+ // stored cached version in `def` property
3150
+ // remove all properties, set $ref
3151
+ const extractToDef = (entry) => {
3152
+ // if the schema is already a reference, do not extract it
3153
+ if (entry[1].schema.$ref) {
3154
+ return;
3155
+ }
3156
+ const seen = entry[1];
3157
+ const { ref, defId } = makeURI(entry);
3158
+ seen.def = { ...seen.schema };
3159
+ // defId won't be set if the schema is a reference to an external schema
3160
+ // or if the schema is the root schema
3161
+ if (defId)
3162
+ seen.defId = defId;
3163
+ // wipe away all properties except $ref
3164
+ const schema = seen.schema;
3165
+ for (const key in schema) {
3166
+ delete schema[key];
3167
+ }
3168
+ schema.$ref = ref;
3169
+ };
3170
+ // throw on cycles
3171
+ // break cycles
3172
+ if (ctx.cycles === "throw") {
3173
+ for (const entry of ctx.seen.entries()) {
3174
+ const seen = entry[1];
3175
+ if (seen.cycle) {
3176
+ throw new Error("Cycle detected: " +
3177
+ `#/${seen.cycle?.join("/")}/<root>` +
3178
+ '\n\nSet the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.');
3179
+ }
3180
+ }
3181
+ }
3182
+ // extract schemas into $defs
3183
+ for (const entry of ctx.seen.entries()) {
3184
+ const seen = entry[1];
3185
+ // convert root schema to # $ref
3186
+ if (schema === entry[0]) {
3187
+ extractToDef(entry); // this has special handling for the root schema
3188
+ continue;
3189
+ }
3190
+ // extract schemas that are in the external registry
3191
+ if (ctx.external) {
3192
+ const ext = ctx.external.registry.get(entry[0])?.id;
3193
+ if (schema !== entry[0] && ext) {
3194
+ extractToDef(entry);
3195
+ continue;
3196
+ }
3197
+ }
3198
+ // extract schemas with `id` meta
3199
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
3200
+ if (id) {
3201
+ extractToDef(entry);
3202
+ continue;
3203
+ }
3204
+ // break cycles
3205
+ if (seen.cycle) {
3206
+ // any
3207
+ extractToDef(entry);
3208
+ continue;
3209
+ }
3210
+ // extract reused schemas
3211
+ if (seen.count > 1) {
3212
+ if (ctx.reused === "ref") {
3213
+ extractToDef(entry);
3214
+ // biome-ignore lint:
3215
+ continue;
3216
+ }
3217
+ }
3218
+ }
3219
+ }
3220
+ function finalize(ctx, schema) {
3221
+ const root = ctx.seen.get(schema);
3222
+ if (!root)
3223
+ throw new Error("Unprocessed schema. This is a bug in Zod.");
3224
+ // flatten refs - inherit properties from parent schemas
3225
+ const flattenRef = (zodSchema) => {
3226
+ const seen = ctx.seen.get(zodSchema);
3227
+ // already processed
3228
+ if (seen.ref === null)
3229
+ return;
3230
+ const schema = seen.def ?? seen.schema;
3231
+ const _cached = { ...schema };
3232
+ const ref = seen.ref;
3233
+ seen.ref = null; // prevent infinite recursion
3234
+ if (ref) {
3235
+ flattenRef(ref);
3236
+ const refSeen = ctx.seen.get(ref);
3237
+ const refSchema = refSeen.schema;
3238
+ // merge referenced schema into current
3239
+ if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
3240
+ // older drafts can't combine $ref with other properties
3241
+ schema.allOf = schema.allOf ?? [];
3242
+ schema.allOf.push(refSchema);
3243
+ }
3244
+ else {
3245
+ Object.assign(schema, refSchema);
3246
+ }
3247
+ // restore child's own properties (child wins)
3248
+ Object.assign(schema, _cached);
3249
+ const isParentRef = zodSchema._zod.parent === ref;
3250
+ // For parent chain, child is a refinement - remove parent-only properties
3251
+ if (isParentRef) {
3252
+ for (const key in schema) {
3253
+ if (key === "$ref" || key === "allOf")
3254
+ continue;
3255
+ if (!(key in _cached)) {
3256
+ delete schema[key];
3257
+ }
3258
+ }
3259
+ }
3260
+ // When ref was extracted to $defs, remove properties that match the definition
3261
+ if (refSchema.$ref && refSeen.def) {
3262
+ for (const key in schema) {
3263
+ if (key === "$ref" || key === "allOf")
3264
+ continue;
3265
+ if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) {
3266
+ delete schema[key];
3267
+ }
3268
+ }
3269
+ }
3270
+ }
3271
+ // If parent was extracted (has $ref), propagate $ref to this schema
3272
+ // This handles cases like: readonly().meta({id}).describe()
3273
+ // where processor sets ref to innerType but parent should be referenced
3274
+ const parent = zodSchema._zod.parent;
3275
+ if (parent && parent !== ref) {
3276
+ // Ensure parent is processed first so its def has inherited properties
3277
+ flattenRef(parent);
3278
+ const parentSeen = ctx.seen.get(parent);
3279
+ if (parentSeen?.schema.$ref) {
3280
+ schema.$ref = parentSeen.schema.$ref;
3281
+ // De-duplicate with parent's definition
3282
+ if (parentSeen.def) {
3283
+ for (const key in schema) {
3284
+ if (key === "$ref" || key === "allOf")
3285
+ continue;
3286
+ if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) {
3287
+ delete schema[key];
3288
+ }
3289
+ }
3290
+ }
3291
+ }
3292
+ }
3293
+ // execute overrides
3294
+ ctx.override({
3295
+ zodSchema: zodSchema,
3296
+ jsonSchema: schema,
3297
+ path: seen.path ?? [],
3298
+ });
3299
+ };
3300
+ for (const entry of [...ctx.seen.entries()].reverse()) {
3301
+ flattenRef(entry[0]);
3302
+ }
3303
+ const result = {};
3304
+ if (ctx.target === "draft-2020-12") {
3305
+ result.$schema = "https://json-schema.org/draft/2020-12/schema";
3306
+ }
3307
+ else if (ctx.target === "draft-07") {
3308
+ result.$schema = "http://json-schema.org/draft-07/schema#";
3309
+ }
3310
+ else if (ctx.target === "draft-04") {
3311
+ result.$schema = "http://json-schema.org/draft-04/schema#";
3312
+ }
3313
+ else if (ctx.target === "openapi-3.0") ;
3314
+ else ;
3315
+ if (ctx.external?.uri) {
3316
+ const id = ctx.external.registry.get(schema)?.id;
3317
+ if (!id)
3318
+ throw new Error("Schema is missing an `id` property");
3319
+ result.$id = ctx.external.uri(id);
3320
+ }
3321
+ Object.assign(result, root.def ?? root.schema);
3322
+ // build defs object
3323
+ const defs = ctx.external?.defs ?? {};
3324
+ for (const entry of ctx.seen.entries()) {
3325
+ const seen = entry[1];
3326
+ if (seen.def && seen.defId) {
3327
+ defs[seen.defId] = seen.def;
3328
+ }
3329
+ }
3330
+ // set definitions in result
3331
+ if (ctx.external) ;
3332
+ else {
3333
+ if (Object.keys(defs).length > 0) {
3334
+ if (ctx.target === "draft-2020-12") {
3335
+ result.$defs = defs;
3336
+ }
3337
+ else {
3338
+ result.definitions = defs;
3339
+ }
3340
+ }
3341
+ }
3342
+ try {
3343
+ // this "finalizes" this schema and ensures all cycles are removed
3344
+ // each call to finalize() is functionally independent
3345
+ // though the seen map is shared
3346
+ const finalized = JSON.parse(JSON.stringify(result));
3347
+ Object.defineProperty(finalized, "~standard", {
3348
+ value: {
3349
+ ...schema["~standard"],
3350
+ jsonSchema: {
3351
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
3352
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors),
3353
+ },
3354
+ },
3355
+ enumerable: false,
3356
+ writable: false,
3357
+ });
3358
+ return finalized;
3359
+ }
3360
+ catch (_err) {
3361
+ throw new Error("Error converting schema to JSON.");
3362
+ }
3363
+ }
3364
+ function isTransforming(_schema, _ctx) {
3365
+ const ctx = _ctx ?? { seen: new Set() };
3366
+ if (ctx.seen.has(_schema))
3367
+ return false;
3368
+ ctx.seen.add(_schema);
3369
+ const def = _schema._zod.def;
3370
+ if (def.type === "transform")
3371
+ return true;
3372
+ if (def.type === "array")
3373
+ return isTransforming(def.element, ctx);
3374
+ if (def.type === "set")
3375
+ return isTransforming(def.valueType, ctx);
3376
+ if (def.type === "lazy")
3377
+ return isTransforming(def.getter(), ctx);
3378
+ if (def.type === "promise" ||
3379
+ def.type === "optional" ||
3380
+ def.type === "nonoptional" ||
3381
+ def.type === "nullable" ||
3382
+ def.type === "readonly" ||
3383
+ def.type === "default" ||
3384
+ def.type === "prefault") {
3385
+ return isTransforming(def.innerType, ctx);
3386
+ }
3387
+ if (def.type === "intersection") {
3388
+ return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
3389
+ }
3390
+ if (def.type === "record" || def.type === "map") {
3391
+ return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
3392
+ }
3393
+ if (def.type === "pipe") {
3394
+ return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
3395
+ }
3396
+ if (def.type === "object") {
3397
+ for (const key in def.shape) {
3398
+ if (isTransforming(def.shape[key], ctx))
3399
+ return true;
3400
+ }
3401
+ return false;
3402
+ }
3403
+ if (def.type === "union") {
3404
+ for (const option of def.options) {
3405
+ if (isTransforming(option, ctx))
3406
+ return true;
3407
+ }
3408
+ return false;
3409
+ }
3410
+ if (def.type === "tuple") {
3411
+ for (const item of def.items) {
3412
+ if (isTransforming(item, ctx))
3413
+ return true;
3414
+ }
3415
+ if (def.rest && isTransforming(def.rest, ctx))
3416
+ return true;
3417
+ return false;
3418
+ }
3419
+ return false;
3420
+ }
3421
+ /**
3422
+ * Creates a toJSONSchema method for a schema instance.
3423
+ * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
3424
+ */
3425
+ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
3426
+ const ctx = initializeContext({ ...params, processors });
3427
+ process(schema, ctx);
3428
+ extractDefs(ctx, schema);
3429
+ return finalize(ctx, schema);
3430
+ };
3431
+ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
3432
+ const { libraryOptions, target } = params ?? {};
3433
+ const ctx = initializeContext({ ...(libraryOptions ?? {}), target, io, processors });
3434
+ process(schema, ctx);
3435
+ extractDefs(ctx, schema);
3436
+ return finalize(ctx, schema);
3437
+ };
3438
+
3439
+ const formatMap = {
3440
+ guid: "uuid",
3441
+ url: "uri",
3442
+ datetime: "date-time",
3443
+ json_string: "json-string",
3444
+ regex: "", // do not set
3445
+ };
3446
+ // ==================== SIMPLE TYPE PROCESSORS ====================
3447
+ const stringProcessor = (schema, ctx, _json, _params) => {
3448
+ const json = _json;
3449
+ json.type = "string";
3450
+ const { minimum, maximum, format, patterns, contentEncoding } = schema._zod
3451
+ .bag;
3452
+ if (typeof minimum === "number")
3453
+ json.minLength = minimum;
3454
+ if (typeof maximum === "number")
3455
+ json.maxLength = maximum;
3456
+ // custom pattern overrides format
3457
+ if (format) {
3458
+ json.format = formatMap[format] ?? format;
3459
+ if (json.format === "")
3460
+ delete json.format; // empty format is not valid
3461
+ // JSON Schema format: "time" requires a full time with offset or Z
3462
+ // z.iso.time() does not include timezone information, so format: "time" should never be used
3463
+ if (format === "time") {
3464
+ delete json.format;
3465
+ }
3466
+ }
3467
+ if (contentEncoding)
3468
+ json.contentEncoding = contentEncoding;
3469
+ if (patterns && patterns.size > 0) {
3470
+ const regexes = [...patterns];
3471
+ if (regexes.length === 1)
3472
+ json.pattern = regexes[0].source;
3473
+ else if (regexes.length > 1) {
3474
+ json.allOf = [
3475
+ ...regexes.map((regex) => ({
3476
+ ...(ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0"
3477
+ ? { type: "string" }
3478
+ : {}),
3479
+ pattern: regex.source,
3480
+ })),
3481
+ ];
3482
+ }
3483
+ }
3484
+ };
3485
+ const neverProcessor = (_schema, _ctx, json, _params) => {
3486
+ json.not = {};
3487
+ };
3488
+ const unknownProcessor = (_schema, _ctx, _json, _params) => {
3489
+ // empty schema accepts anything
3490
+ };
3491
+ const enumProcessor = (schema, _ctx, json, _params) => {
3492
+ const def = schema._zod.def;
3493
+ const values = getEnumValues(def.entries);
3494
+ // Number enums can have both string and number values
3495
+ if (values.every((v) => typeof v === "number"))
3496
+ json.type = "number";
3497
+ if (values.every((v) => typeof v === "string"))
3498
+ json.type = "string";
3499
+ json.enum = values;
3500
+ };
3501
+ const customProcessor = (_schema, ctx, _json, _params) => {
3502
+ if (ctx.unrepresentable === "throw") {
3503
+ throw new Error("Custom types cannot be represented in JSON Schema");
3504
+ }
3505
+ };
3506
+ const transformProcessor = (_schema, ctx, _json, _params) => {
3507
+ if (ctx.unrepresentable === "throw") {
3508
+ throw new Error("Transforms cannot be represented in JSON Schema");
3509
+ }
3510
+ };
3511
+ // ==================== COMPOSITE TYPE PROCESSORS ====================
3512
+ const arrayProcessor = (schema, ctx, _json, params) => {
3513
+ const json = _json;
3514
+ const def = schema._zod.def;
3515
+ const { minimum, maximum } = schema._zod.bag;
3516
+ if (typeof minimum === "number")
3517
+ json.minItems = minimum;
3518
+ if (typeof maximum === "number")
3519
+ json.maxItems = maximum;
3520
+ json.type = "array";
3521
+ json.items = process(def.element, ctx, { ...params, path: [...params.path, "items"] });
3522
+ };
3523
+ const objectProcessor = (schema, ctx, _json, params) => {
3524
+ const json = _json;
3525
+ const def = schema._zod.def;
3526
+ json.type = "object";
3527
+ json.properties = {};
3528
+ const shape = def.shape;
3529
+ for (const key in shape) {
3530
+ json.properties[key] = process(shape[key], ctx, {
3531
+ ...params,
3532
+ path: [...params.path, "properties", key],
3533
+ });
3534
+ }
3535
+ // required keys
3536
+ const allKeys = new Set(Object.keys(shape));
3537
+ const requiredKeys = new Set([...allKeys].filter((key) => {
3538
+ const v = def.shape[key]._zod;
3539
+ if (ctx.io === "input") {
3540
+ return v.optin === undefined;
3541
+ }
3542
+ else {
3543
+ return v.optout === undefined;
3544
+ }
3545
+ }));
3546
+ if (requiredKeys.size > 0) {
3547
+ json.required = Array.from(requiredKeys);
3548
+ }
3549
+ // catchall
3550
+ if (def.catchall?._zod.def.type === "never") {
3551
+ // strict
3552
+ json.additionalProperties = false;
3553
+ }
3554
+ else if (!def.catchall) {
3555
+ // regular
3556
+ if (ctx.io === "output")
3557
+ json.additionalProperties = false;
3558
+ }
3559
+ else if (def.catchall) {
3560
+ json.additionalProperties = process(def.catchall, ctx, {
3561
+ ...params,
3562
+ path: [...params.path, "additionalProperties"],
3563
+ });
3564
+ }
3565
+ };
3566
+ const unionProcessor = (schema, ctx, json, params) => {
3567
+ const def = schema._zod.def;
3568
+ // Exclusive unions (inclusive === false) use oneOf (exactly one match) instead of anyOf (one or more matches)
3569
+ // This includes both z.xor() and discriminated unions
3570
+ const isExclusive = def.inclusive === false;
3571
+ const options = def.options.map((x, i) => process(x, ctx, {
3572
+ ...params,
3573
+ path: [...params.path, isExclusive ? "oneOf" : "anyOf", i],
3574
+ }));
3575
+ if (isExclusive) {
3576
+ json.oneOf = options;
3577
+ }
3578
+ else {
3579
+ json.anyOf = options;
3580
+ }
3581
+ };
3582
+ const intersectionProcessor = (schema, ctx, json, params) => {
3583
+ const def = schema._zod.def;
3584
+ const a = process(def.left, ctx, {
3585
+ ...params,
3586
+ path: [...params.path, "allOf", 0],
3587
+ });
3588
+ const b = process(def.right, ctx, {
3589
+ ...params,
3590
+ path: [...params.path, "allOf", 1],
3591
+ });
3592
+ const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
3593
+ const allOf = [
3594
+ ...(isSimpleIntersection(a) ? a.allOf : [a]),
3595
+ ...(isSimpleIntersection(b) ? b.allOf : [b]),
3596
+ ];
3597
+ json.allOf = allOf;
3598
+ };
3599
+ const nullableProcessor = (schema, ctx, json, params) => {
3600
+ const def = schema._zod.def;
3601
+ const inner = process(def.innerType, ctx, params);
3602
+ const seen = ctx.seen.get(schema);
3603
+ if (ctx.target === "openapi-3.0") {
3604
+ seen.ref = def.innerType;
3605
+ json.nullable = true;
3606
+ }
3607
+ else {
3608
+ json.anyOf = [inner, { type: "null" }];
3609
+ }
3610
+ };
3611
+ const nonoptionalProcessor = (schema, ctx, _json, params) => {
3612
+ const def = schema._zod.def;
3613
+ process(def.innerType, ctx, params);
3614
+ const seen = ctx.seen.get(schema);
3615
+ seen.ref = def.innerType;
3616
+ };
3617
+ const defaultProcessor = (schema, ctx, json, params) => {
3618
+ const def = schema._zod.def;
3619
+ process(def.innerType, ctx, params);
3620
+ const seen = ctx.seen.get(schema);
3621
+ seen.ref = def.innerType;
3622
+ json.default = JSON.parse(JSON.stringify(def.defaultValue));
3623
+ };
3624
+ const prefaultProcessor = (schema, ctx, json, params) => {
3625
+ const def = schema._zod.def;
3626
+ process(def.innerType, ctx, params);
3627
+ const seen = ctx.seen.get(schema);
3628
+ seen.ref = def.innerType;
3629
+ if (ctx.io === "input")
3630
+ json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
3631
+ };
3632
+ const catchProcessor = (schema, ctx, json, params) => {
3633
+ const def = schema._zod.def;
3634
+ process(def.innerType, ctx, params);
3635
+ const seen = ctx.seen.get(schema);
3636
+ seen.ref = def.innerType;
3637
+ let catchValue;
3638
+ try {
3639
+ catchValue = def.catchValue(undefined);
3640
+ }
3641
+ catch {
3642
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
3643
+ }
3644
+ json.default = catchValue;
3645
+ };
3646
+ const pipeProcessor = (schema, ctx, _json, params) => {
3647
+ const def = schema._zod.def;
3648
+ const innerType = ctx.io === "input" ? (def.in._zod.def.type === "transform" ? def.out : def.in) : def.out;
3649
+ process(innerType, ctx, params);
3650
+ const seen = ctx.seen.get(schema);
3651
+ seen.ref = innerType;
3652
+ };
3653
+ const readonlyProcessor = (schema, ctx, json, params) => {
3654
+ const def = schema._zod.def;
3655
+ process(def.innerType, ctx, params);
3656
+ const seen = ctx.seen.get(schema);
3657
+ seen.ref = def.innerType;
3658
+ json.readOnly = true;
3659
+ };
3660
+ const optionalProcessor = (schema, ctx, _json, params) => {
3661
+ const def = schema._zod.def;
3662
+ process(def.innerType, ctx, params);
3663
+ const seen = ctx.seen.get(schema);
3664
+ seen.ref = def.innerType;
3665
+ };
3666
+
3667
+ const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
3668
+ $ZodISODateTime.init(inst, def);
3669
+ ZodStringFormat.init(inst, def);
3670
+ });
3671
+ function datetime(params) {
3672
+ return _isoDateTime(ZodISODateTime, params);
3673
+ }
3674
+ const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
3675
+ $ZodISODate.init(inst, def);
3676
+ ZodStringFormat.init(inst, def);
3677
+ });
3678
+ function date(params) {
3679
+ return _isoDate(ZodISODate, params);
3680
+ }
3681
+ const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
3682
+ $ZodISOTime.init(inst, def);
3683
+ ZodStringFormat.init(inst, def);
3684
+ });
3685
+ function time(params) {
3686
+ return _isoTime(ZodISOTime, params);
3687
+ }
3688
+ const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
3689
+ $ZodISODuration.init(inst, def);
3690
+ ZodStringFormat.init(inst, def);
3691
+ });
3692
+ function duration(params) {
3693
+ return _isoDuration(ZodISODuration, params);
3694
+ }
3695
+
3696
+ const initializer = (inst, issues) => {
3697
+ $ZodError.init(inst, issues);
3698
+ inst.name = "ZodError";
3699
+ Object.defineProperties(inst, {
3700
+ format: {
3701
+ value: (mapper) => formatError(inst, mapper),
3702
+ // enumerable: false,
3703
+ },
3704
+ flatten: {
3705
+ value: (mapper) => flattenError(inst, mapper),
3706
+ // enumerable: false,
3707
+ },
3708
+ addIssue: {
3709
+ value: (issue) => {
3710
+ inst.issues.push(issue);
3711
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3712
+ },
3713
+ // enumerable: false,
3714
+ },
3715
+ addIssues: {
3716
+ value: (issues) => {
3717
+ inst.issues.push(...issues);
3718
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3719
+ },
3720
+ // enumerable: false,
3721
+ },
3722
+ isEmpty: {
3723
+ get() {
3724
+ return inst.issues.length === 0;
3725
+ },
3726
+ // enumerable: false,
3727
+ },
3728
+ });
3729
+ // Object.defineProperty(inst, "isEmpty", {
3730
+ // get() {
3731
+ // return inst.issues.length === 0;
3732
+ // },
3733
+ // });
3734
+ };
3735
+ const ZodRealError = $constructor("ZodError", initializer, {
3736
+ Parent: Error,
3737
+ });
3738
+ // /** @deprecated Use `z.core.$ZodErrorMapCtx` instead. */
3739
+ // export type ErrorMapCtx = core.$ZodErrorMapCtx;
3740
+
3741
+ const parse = /* @__PURE__ */ _parse(ZodRealError);
3742
+ const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
3743
+ const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
3744
+ const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
3745
+ // Codec functions
3746
+ const encode = /* @__PURE__ */ _encode(ZodRealError);
3747
+ const decode = /* @__PURE__ */ _decode(ZodRealError);
3748
+ const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
3749
+ const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
3750
+ const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
3751
+ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3752
+ const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3753
+ const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3754
+
3755
+ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
3756
+ $ZodType.init(inst, def);
3757
+ Object.assign(inst["~standard"], {
3758
+ jsonSchema: {
3759
+ input: createStandardJSONSchemaMethod(inst, "input"),
3760
+ output: createStandardJSONSchemaMethod(inst, "output"),
3761
+ },
3762
+ });
3763
+ inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
3764
+ inst.def = def;
3765
+ inst.type = def.type;
3766
+ Object.defineProperty(inst, "_def", { value: def });
3767
+ // base methods
3768
+ inst.check = (...checks) => {
3769
+ return inst.clone(mergeDefs(def, {
3770
+ checks: [
3771
+ ...(def.checks ?? []),
3772
+ ...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
3773
+ ],
3774
+ }), {
3775
+ parent: true,
3776
+ });
3777
+ };
3778
+ inst.with = inst.check;
3779
+ inst.clone = (def, params) => clone(inst, def, params);
3780
+ inst.brand = () => inst;
3781
+ inst.register = ((reg, meta) => {
3782
+ reg.add(inst, meta);
3783
+ return inst;
3784
+ });
3785
+ // parsing
3786
+ inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
3787
+ inst.safeParse = (data, params) => safeParse(inst, data, params);
3788
+ inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
3789
+ inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
3790
+ inst.spa = inst.safeParseAsync;
3791
+ // encoding/decoding
3792
+ inst.encode = (data, params) => encode(inst, data, params);
3793
+ inst.decode = (data, params) => decode(inst, data, params);
3794
+ inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
3795
+ inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
3796
+ inst.safeEncode = (data, params) => safeEncode(inst, data, params);
3797
+ inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3798
+ inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3799
+ inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
3800
+ // refinements
3801
+ inst.refine = (check, params) => inst.check(refine(check, params));
3802
+ inst.superRefine = (refinement) => inst.check(superRefine(refinement));
3803
+ inst.overwrite = (fn) => inst.check(_overwrite(fn));
3804
+ // wrappers
3805
+ inst.optional = () => optional(inst);
3806
+ inst.exactOptional = () => exactOptional(inst);
3807
+ inst.nullable = () => nullable(inst);
3808
+ inst.nullish = () => optional(nullable(inst));
3809
+ inst.nonoptional = (params) => nonoptional(inst, params);
3810
+ inst.array = () => array(inst);
3811
+ inst.or = (arg) => union([inst, arg]);
3812
+ inst.and = (arg) => intersection(inst, arg);
3813
+ inst.transform = (tx) => pipe(inst, transform(tx));
3814
+ inst.default = (def) => _default(inst, def);
3815
+ inst.prefault = (def) => prefault(inst, def);
3816
+ // inst.coalesce = (def, params) => coalesce(inst, def, params);
3817
+ inst.catch = (params) => _catch(inst, params);
3818
+ inst.pipe = (target) => pipe(inst, target);
3819
+ inst.readonly = () => readonly(inst);
3820
+ // meta
3821
+ inst.describe = (description) => {
3822
+ const cl = inst.clone();
3823
+ globalRegistry.add(cl, { description });
3824
+ return cl;
3825
+ };
3826
+ Object.defineProperty(inst, "description", {
3827
+ get() {
3828
+ return globalRegistry.get(inst)?.description;
3829
+ },
3830
+ configurable: true,
3831
+ });
3832
+ inst.meta = (...args) => {
3833
+ if (args.length === 0) {
3834
+ return globalRegistry.get(inst);
3835
+ }
3836
+ const cl = inst.clone();
3837
+ globalRegistry.add(cl, args[0]);
3838
+ return cl;
3839
+ };
3840
+ // helpers
3841
+ inst.isOptional = () => inst.safeParse(undefined).success;
3842
+ inst.isNullable = () => inst.safeParse(null).success;
3843
+ inst.apply = (fn) => fn(inst);
3844
+ return inst;
3845
+ });
3846
+ /** @internal */
3847
+ const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
3848
+ $ZodString.init(inst, def);
3849
+ ZodType.init(inst, def);
3850
+ inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json);
3851
+ const bag = inst._zod.bag;
3852
+ inst.format = bag.format ?? null;
3853
+ inst.minLength = bag.minimum ?? null;
3854
+ inst.maxLength = bag.maximum ?? null;
3855
+ // validations
3856
+ inst.regex = (...args) => inst.check(_regex(...args));
3857
+ inst.includes = (...args) => inst.check(_includes(...args));
3858
+ inst.startsWith = (...args) => inst.check(_startsWith(...args));
3859
+ inst.endsWith = (...args) => inst.check(_endsWith(...args));
3860
+ inst.min = (...args) => inst.check(_minLength(...args));
3861
+ inst.max = (...args) => inst.check(_maxLength(...args));
3862
+ inst.length = (...args) => inst.check(_length(...args));
3863
+ inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
3864
+ inst.lowercase = (params) => inst.check(_lowercase(params));
3865
+ inst.uppercase = (params) => inst.check(_uppercase(params));
3866
+ // transforms
3867
+ inst.trim = () => inst.check(_trim());
3868
+ inst.normalize = (...args) => inst.check(_normalize(...args));
3869
+ inst.toLowerCase = () => inst.check(_toLowerCase());
3870
+ inst.toUpperCase = () => inst.check(_toUpperCase());
3871
+ inst.slugify = () => inst.check(_slugify());
3872
+ });
3873
+ const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
3874
+ $ZodString.init(inst, def);
3875
+ _ZodString.init(inst, def);
3876
+ inst.email = (params) => inst.check(_email(ZodEmail, params));
3877
+ inst.url = (params) => inst.check(_url(ZodURL, params));
3878
+ inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
3879
+ inst.emoji = (params) => inst.check(_emoji(ZodEmoji, params));
3880
+ inst.guid = (params) => inst.check(_guid(ZodGUID, params));
3881
+ inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
3882
+ inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
3883
+ inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
3884
+ inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
3885
+ inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
3886
+ inst.guid = (params) => inst.check(_guid(ZodGUID, params));
3887
+ inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
3888
+ inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
3889
+ inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
3890
+ inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
3891
+ inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
3892
+ inst.xid = (params) => inst.check(_xid(ZodXID, params));
3893
+ inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
3894
+ inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
3895
+ inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
3896
+ inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
3897
+ inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
3898
+ inst.e164 = (params) => inst.check(_e164(ZodE164, params));
3899
+ // iso
3900
+ inst.datetime = (params) => inst.check(datetime(params));
3901
+ inst.date = (params) => inst.check(date(params));
3902
+ inst.time = (params) => inst.check(time(params));
3903
+ inst.duration = (params) => inst.check(duration(params));
3904
+ });
3905
+ function string(params) {
3906
+ return _string(ZodString, params);
3907
+ }
3908
+ const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def) => {
3909
+ $ZodStringFormat.init(inst, def);
3910
+ _ZodString.init(inst, def);
3911
+ });
3912
+ const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
3913
+ // ZodStringFormat.init(inst, def);
3914
+ $ZodEmail.init(inst, def);
3915
+ ZodStringFormat.init(inst, def);
3916
+ });
3917
+ const ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def) => {
3918
+ // ZodStringFormat.init(inst, def);
3919
+ $ZodGUID.init(inst, def);
3920
+ ZodStringFormat.init(inst, def);
3921
+ });
3922
+ const ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (inst, def) => {
3923
+ // ZodStringFormat.init(inst, def);
3924
+ $ZodUUID.init(inst, def);
3925
+ ZodStringFormat.init(inst, def);
3926
+ });
3927
+ const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def) => {
3928
+ // ZodStringFormat.init(inst, def);
3929
+ $ZodURL.init(inst, def);
3930
+ ZodStringFormat.init(inst, def);
3931
+ });
3932
+ const ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def) => {
3933
+ // ZodStringFormat.init(inst, def);
3934
+ $ZodEmoji.init(inst, def);
3935
+ ZodStringFormat.init(inst, def);
3936
+ });
3937
+ const ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def) => {
3938
+ // ZodStringFormat.init(inst, def);
3939
+ $ZodNanoID.init(inst, def);
3940
+ ZodStringFormat.init(inst, def);
3941
+ });
3942
+ const ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def) => {
3943
+ // ZodStringFormat.init(inst, def);
3944
+ $ZodCUID.init(inst, def);
3945
+ ZodStringFormat.init(inst, def);
3946
+ });
3947
+ const ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (inst, def) => {
3948
+ // ZodStringFormat.init(inst, def);
3949
+ $ZodCUID2.init(inst, def);
3950
+ ZodStringFormat.init(inst, def);
3951
+ });
3952
+ const ZodULID = /*@__PURE__*/ $constructor("ZodULID", (inst, def) => {
3953
+ // ZodStringFormat.init(inst, def);
3954
+ $ZodULID.init(inst, def);
3955
+ ZodStringFormat.init(inst, def);
3956
+ });
3957
+ const ZodXID = /*@__PURE__*/ $constructor("ZodXID", (inst, def) => {
3958
+ // ZodStringFormat.init(inst, def);
3959
+ $ZodXID.init(inst, def);
3960
+ ZodStringFormat.init(inst, def);
3961
+ });
3962
+ const ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (inst, def) => {
3963
+ // ZodStringFormat.init(inst, def);
3964
+ $ZodKSUID.init(inst, def);
3965
+ ZodStringFormat.init(inst, def);
3966
+ });
3967
+ const ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (inst, def) => {
3968
+ // ZodStringFormat.init(inst, def);
3969
+ $ZodIPv4.init(inst, def);
3970
+ ZodStringFormat.init(inst, def);
3971
+ });
3972
+ const ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (inst, def) => {
3973
+ // ZodStringFormat.init(inst, def);
3974
+ $ZodIPv6.init(inst, def);
3975
+ ZodStringFormat.init(inst, def);
3976
+ });
3977
+ const ZodCIDRv4 = /*@__PURE__*/ $constructor("ZodCIDRv4", (inst, def) => {
3978
+ $ZodCIDRv4.init(inst, def);
3979
+ ZodStringFormat.init(inst, def);
3980
+ });
3981
+ const ZodCIDRv6 = /*@__PURE__*/ $constructor("ZodCIDRv6", (inst, def) => {
3982
+ $ZodCIDRv6.init(inst, def);
3983
+ ZodStringFormat.init(inst, def);
3984
+ });
3985
+ const ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (inst, def) => {
3986
+ // ZodStringFormat.init(inst, def);
3987
+ $ZodBase64.init(inst, def);
3988
+ ZodStringFormat.init(inst, def);
3989
+ });
3990
+ const ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (inst, def) => {
3991
+ // ZodStringFormat.init(inst, def);
3992
+ $ZodBase64URL.init(inst, def);
3993
+ ZodStringFormat.init(inst, def);
3994
+ });
3995
+ const ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (inst, def) => {
3996
+ // ZodStringFormat.init(inst, def);
3997
+ $ZodE164.init(inst, def);
3998
+ ZodStringFormat.init(inst, def);
3999
+ });
4000
+ const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
4001
+ // ZodStringFormat.init(inst, def);
4002
+ $ZodJWT.init(inst, def);
4003
+ ZodStringFormat.init(inst, def);
4004
+ });
4005
+ const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
4006
+ $ZodUnknown.init(inst, def);
4007
+ ZodType.init(inst, def);
4008
+ inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor();
4009
+ });
4010
+ function unknown() {
4011
+ return _unknown(ZodUnknown);
4012
+ }
4013
+ const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
4014
+ $ZodNever.init(inst, def);
4015
+ ZodType.init(inst, def);
4016
+ inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json);
4017
+ });
4018
+ function never(params) {
4019
+ return _never(ZodNever, params);
4020
+ }
4021
+ const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
4022
+ $ZodArray.init(inst, def);
4023
+ ZodType.init(inst, def);
4024
+ inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
4025
+ inst.element = def.element;
4026
+ inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
4027
+ inst.nonempty = (params) => inst.check(_minLength(1, params));
4028
+ inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
4029
+ inst.length = (len, params) => inst.check(_length(len, params));
4030
+ inst.unwrap = () => inst.element;
4031
+ });
4032
+ function array(element, params) {
4033
+ return _array(ZodArray, element, params);
4034
+ }
4035
+ const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
4036
+ $ZodObjectJIT.init(inst, def);
4037
+ ZodType.init(inst, def);
4038
+ inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
4039
+ defineLazy(inst, "shape", () => {
4040
+ return def.shape;
4041
+ });
4042
+ inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
4043
+ inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall: catchall });
4044
+ inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
4045
+ inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
4046
+ inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
4047
+ inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
4048
+ inst.extend = (incoming) => {
4049
+ return extend(inst, incoming);
4050
+ };
4051
+ inst.safeExtend = (incoming) => {
4052
+ return safeExtend(inst, incoming);
4053
+ };
4054
+ inst.merge = (other) => merge(inst, other);
4055
+ inst.pick = (mask) => pick(inst, mask);
4056
+ inst.omit = (mask) => omit(inst, mask);
4057
+ inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
4058
+ inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
4059
+ });
4060
+ // looseObject
4061
+ function looseObject(shape, params) {
4062
+ return new ZodObject({
4063
+ type: "object",
4064
+ shape,
4065
+ catchall: unknown(),
4066
+ ...normalizeParams(params),
4067
+ });
4068
+ }
4069
+ const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
4070
+ $ZodUnion.init(inst, def);
4071
+ ZodType.init(inst, def);
4072
+ inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
4073
+ inst.options = def.options;
4074
+ });
4075
+ function union(options, params) {
4076
+ return new ZodUnion({
4077
+ type: "union",
4078
+ options: options,
4079
+ ...normalizeParams(params),
4080
+ });
4081
+ }
4082
+ const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
4083
+ $ZodIntersection.init(inst, def);
4084
+ ZodType.init(inst, def);
4085
+ inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
4086
+ });
4087
+ function intersection(left, right) {
4088
+ return new ZodIntersection({
4089
+ type: "intersection",
4090
+ left: left,
4091
+ right: right,
4092
+ });
4093
+ }
4094
+ const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
4095
+ $ZodEnum.init(inst, def);
4096
+ ZodType.init(inst, def);
4097
+ inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json);
4098
+ inst.enum = def.entries;
4099
+ inst.options = Object.values(def.entries);
4100
+ const keys = new Set(Object.keys(def.entries));
4101
+ inst.extract = (values, params) => {
4102
+ const newEntries = {};
4103
+ for (const value of values) {
4104
+ if (keys.has(value)) {
4105
+ newEntries[value] = def.entries[value];
4106
+ }
4107
+ else
4108
+ throw new Error(`Key ${value} not found in enum`);
4109
+ }
4110
+ return new ZodEnum({
4111
+ ...def,
4112
+ checks: [],
4113
+ ...normalizeParams(params),
4114
+ entries: newEntries,
4115
+ });
4116
+ };
4117
+ inst.exclude = (values, params) => {
4118
+ const newEntries = { ...def.entries };
4119
+ for (const value of values) {
4120
+ if (keys.has(value)) {
4121
+ delete newEntries[value];
4122
+ }
4123
+ else
4124
+ throw new Error(`Key ${value} not found in enum`);
4125
+ }
4126
+ return new ZodEnum({
4127
+ ...def,
4128
+ checks: [],
4129
+ ...normalizeParams(params),
4130
+ entries: newEntries,
4131
+ });
4132
+ };
4133
+ });
4134
+ function _enum(values, params) {
4135
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
4136
+ return new ZodEnum({
4137
+ type: "enum",
4138
+ entries,
4139
+ ...normalizeParams(params),
4140
+ });
4141
+ }
4142
+ const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
4143
+ $ZodTransform.init(inst, def);
4144
+ ZodType.init(inst, def);
4145
+ inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx);
4146
+ inst._zod.parse = (payload, _ctx) => {
4147
+ if (_ctx.direction === "backward") {
4148
+ throw new $ZodEncodeError(inst.constructor.name);
4149
+ }
4150
+ payload.addIssue = (issue$1) => {
4151
+ if (typeof issue$1 === "string") {
4152
+ payload.issues.push(issue(issue$1, payload.value, def));
4153
+ }
4154
+ else {
4155
+ // for Zod 3 backwards compatibility
4156
+ const _issue = issue$1;
4157
+ if (_issue.fatal)
4158
+ _issue.continue = false;
4159
+ _issue.code ?? (_issue.code = "custom");
4160
+ _issue.input ?? (_issue.input = payload.value);
4161
+ _issue.inst ?? (_issue.inst = inst);
4162
+ // _issue.continue ??= true;
4163
+ payload.issues.push(issue(_issue));
4164
+ }
4165
+ };
4166
+ const output = def.transform(payload.value, payload);
4167
+ if (output instanceof Promise) {
4168
+ return output.then((output) => {
4169
+ payload.value = output;
4170
+ return payload;
4171
+ });
4172
+ }
4173
+ payload.value = output;
4174
+ return payload;
4175
+ };
4176
+ });
4177
+ function transform(fn) {
4178
+ return new ZodTransform({
4179
+ type: "transform",
4180
+ transform: fn,
4181
+ });
4182
+ }
4183
+ const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
4184
+ $ZodOptional.init(inst, def);
4185
+ ZodType.init(inst, def);
4186
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4187
+ inst.unwrap = () => inst._zod.def.innerType;
4188
+ });
4189
+ function optional(innerType) {
4190
+ return new ZodOptional({
4191
+ type: "optional",
4192
+ innerType: innerType,
4193
+ });
4194
+ }
4195
+ const ZodExactOptional = /*@__PURE__*/ $constructor("ZodExactOptional", (inst, def) => {
4196
+ $ZodExactOptional.init(inst, def);
4197
+ ZodType.init(inst, def);
4198
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4199
+ inst.unwrap = () => inst._zod.def.innerType;
4200
+ });
4201
+ function exactOptional(innerType) {
4202
+ return new ZodExactOptional({
4203
+ type: "optional",
4204
+ innerType: innerType,
4205
+ });
4206
+ }
4207
+ const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
4208
+ $ZodNullable.init(inst, def);
4209
+ ZodType.init(inst, def);
4210
+ inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
4211
+ inst.unwrap = () => inst._zod.def.innerType;
4212
+ });
4213
+ function nullable(innerType) {
4214
+ return new ZodNullable({
4215
+ type: "nullable",
4216
+ innerType: innerType,
4217
+ });
4218
+ }
4219
+ const ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def) => {
4220
+ $ZodDefault.init(inst, def);
4221
+ ZodType.init(inst, def);
4222
+ inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
4223
+ inst.unwrap = () => inst._zod.def.innerType;
4224
+ inst.removeDefault = inst.unwrap;
4225
+ });
4226
+ function _default(innerType, defaultValue) {
4227
+ return new ZodDefault({
4228
+ type: "default",
4229
+ innerType: innerType,
4230
+ get defaultValue() {
4231
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
4232
+ },
4233
+ });
4234
+ }
4235
+ const ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (inst, def) => {
4236
+ $ZodPrefault.init(inst, def);
4237
+ ZodType.init(inst, def);
4238
+ inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
4239
+ inst.unwrap = () => inst._zod.def.innerType;
4240
+ });
4241
+ function prefault(innerType, defaultValue) {
4242
+ return new ZodPrefault({
4243
+ type: "prefault",
4244
+ innerType: innerType,
4245
+ get defaultValue() {
4246
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
4247
+ },
4248
+ });
4249
+ }
4250
+ const ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (inst, def) => {
4251
+ $ZodNonOptional.init(inst, def);
4252
+ ZodType.init(inst, def);
4253
+ inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
4254
+ inst.unwrap = () => inst._zod.def.innerType;
4255
+ });
4256
+ function nonoptional(innerType, params) {
4257
+ return new ZodNonOptional({
4258
+ type: "nonoptional",
4259
+ innerType: innerType,
4260
+ ...normalizeParams(params),
4261
+ });
4262
+ }
4263
+ const ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def) => {
4264
+ $ZodCatch.init(inst, def);
4265
+ ZodType.init(inst, def);
4266
+ inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
4267
+ inst.unwrap = () => inst._zod.def.innerType;
4268
+ inst.removeCatch = inst.unwrap;
4269
+ });
4270
+ function _catch(innerType, catchValue) {
4271
+ return new ZodCatch({
4272
+ type: "catch",
4273
+ innerType: innerType,
4274
+ catchValue: (typeof catchValue === "function" ? catchValue : () => catchValue),
4275
+ });
4276
+ }
4277
+ const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
4278
+ $ZodPipe.init(inst, def);
4279
+ ZodType.init(inst, def);
4280
+ inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
4281
+ inst.in = def.in;
4282
+ inst.out = def.out;
4283
+ });
4284
+ function pipe(in_, out) {
4285
+ return new ZodPipe({
4286
+ type: "pipe",
4287
+ in: in_,
4288
+ out: out,
4289
+ // ...util.normalizeParams(params),
4290
+ });
4291
+ }
4292
+ const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
4293
+ $ZodReadonly.init(inst, def);
4294
+ ZodType.init(inst, def);
4295
+ inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
4296
+ inst.unwrap = () => inst._zod.def.innerType;
4297
+ });
4298
+ function readonly(innerType) {
4299
+ return new ZodReadonly({
4300
+ type: "readonly",
4301
+ innerType: innerType,
4302
+ });
4303
+ }
4304
+ const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
4305
+ $ZodCustom.init(inst, def);
4306
+ ZodType.init(inst, def);
4307
+ inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx);
4308
+ });
4309
+ function refine(fn, _params = {}) {
4310
+ return _refine(ZodCustom, fn, _params);
4311
+ }
4312
+ // superRefine
4313
+ function superRefine(fn) {
4314
+ return _superRefine(fn);
4315
+ }
4316
+
4317
+ /**
4318
+ * XcodeGraph Boundary Validation
4319
+ *
4320
+ * Lenient Zod schema that validates the minimal required shape of raw
4321
+ * XcodeGraph JSON without being strict about every field. Uses z.looseObject()
4322
+ * so unknown fields pass through, allowing forward-compatibility when
4323
+ * XcodeGraph adds new fields or enum values.
4324
+ *
4325
+ * @module services/xcode-graph.validation
4326
+ */
4327
+ const RawGraphSchema = looseObject({
4328
+ name: string(),
4329
+ path: string(),
4330
+ projects: array(unknown()),
4331
+ dependencies: array(unknown()),
4332
+ });
4333
+ /**
4334
+ * Validate raw Tuist graph JSON at the boundary.
4335
+ * Returns warnings for unexpected shapes rather than throwing.
4336
+ *
4337
+ * @param raw - Raw JSON value to validate
4338
+ * @returns Parse result with success flag, validated data (if successful), and warnings
4339
+ */
4340
+ function safeParseGraph(raw) {
4341
+ const warnings = [];
4342
+ if (raw === null || raw === undefined || typeof raw !== 'object') {
4343
+ return {
4344
+ success: false,
4345
+ data: undefined,
4346
+ warnings: ['Raw graph input is not an object'],
4347
+ };
4348
+ }
4349
+ const result = RawGraphSchema.safeParse(raw);
4350
+ if (!result.success) {
4351
+ const issues = result.error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`);
4352
+ return {
4353
+ success: false,
4354
+ data: undefined,
4355
+ warnings: [`Graph validation failed: ${issues.join('; ')}`],
4356
+ };
4357
+ }
4358
+ const data = result.data;
4359
+ // Collect warnings for unexpected shapes
4360
+ if (data.projects.length === 0) {
4361
+ warnings.push('Graph has no projects');
4362
+ }
4363
+ if (data.projects.length % 2 !== 0) {
4364
+ warnings.push('Projects array has odd length — expected flat alternating [path, Project, ...] pairs');
4365
+ }
4366
+ if (data.dependencies.length > 0 && data.dependencies.length % 2 !== 0) {
4367
+ warnings.push('Dependencies array has odd length — expected flat alternating [source, targets[], ...] pairs');
4368
+ }
4369
+ // Check for unknown top-level fields that might indicate a schema change
4370
+ const knownFields = new Set([
4371
+ 'name',
4372
+ 'path',
4373
+ 'workspace',
4374
+ 'projects',
4375
+ 'packages',
4376
+ 'dependencies',
4377
+ 'dependencyConditions',
4378
+ ]);
4379
+ const rawObj = raw;
4380
+ for (const key of Object.keys(rawObj)) {
4381
+ if (!knownFields.has(key)) {
4382
+ warnings.push(`Unknown top-level field: "${key}"`);
4383
+ }
4384
+ }
4385
+ return { success: true, data, warnings };
4386
+ }
4387
+
4388
+ /**
4389
+ * XcodeGraph Service
4390
+ *
4391
+ * Transforms raw XcodeGraph JSON into the application's GraphData format.
4392
+ * Uses types generated from XcodeGraph Swift sources via JSON Schema.
4393
+ *
4394
+ * Designed for forward-compatibility: unknown enum values, missing optional
4395
+ * fields, and new XcodeGraph fields produce warnings instead of crashes.
4396
+ */
4397
+ /** Mutable warning collector threaded through the transform */
4398
+ class WarningCollector {
4399
+ warnings = [];
4400
+ warn(message) {
4401
+ this.warnings.push(message);
4402
+ }
4403
+ }
4404
+ /** Product string -> NodeType lookup (covers both camelCase and snake_case variants) */
4405
+ const PRODUCT_NODE_TYPE_MAP = new Map([
4406
+ [Product.App, NodeType.App],
4407
+ [Product.AppClip, NodeType.App],
4408
+ [Product.Framework, NodeType.Framework],
4409
+ [Product.StaticFramework, NodeType.Framework],
4410
+ ['static_framework', NodeType.Framework],
4411
+ [Product.StaticLibrary, NodeType.Library],
4412
+ [Product.DynamicLibrary, NodeType.Library],
4413
+ ['static_library', NodeType.Library],
4414
+ ['dynamic_library', NodeType.Library],
4415
+ [Product.UnitTests, NodeType.TestUnit],
4416
+ ['unit_tests', NodeType.TestUnit],
4417
+ [Product.UiTests, NodeType.TestUi],
4418
+ ['ui_tests', NodeType.TestUi],
4419
+ [Product.CommandLineTool, NodeType.Cli],
4420
+ ['command_line_tool', NodeType.Cli],
4421
+ ]);
4422
+ /** Known extension/bundle products that map to Library without warning */
4423
+ const KNOWN_EXTENSION_PRODUCTS = new Set([
4424
+ Product.AppExtension,
4425
+ Product.Watch2App,
4426
+ Product.Watch2Extension,
4427
+ Product.TvTopShelfExtension,
4428
+ Product.MessagesExtension,
4429
+ Product.StickerPackExtension,
4430
+ Product.Xpc,
4431
+ Product.SystemExtension,
4432
+ Product.ExtensionKitExtension,
4433
+ Product.Macro,
4434
+ Product.Bundle,
4435
+ ]);
4436
+ /** Map Tuist Product enum to our NodeType enum.
4437
+ * Handles both camelCase (generated schema) and snake_case (actual Tuist JSON output).
4438
+ * Returns NodeType.Library as fallback for unknown products. */
4439
+ function productToNodeType(product, collector) {
4440
+ const mapped = PRODUCT_NODE_TYPE_MAP.get(product);
4441
+ if (mapped)
4442
+ return mapped;
4443
+ if (!KNOWN_EXTENSION_PRODUCTS.has(product)) {
4444
+ collector.warn(`Unknown product type "${product}", falling back to Library`);
4445
+ }
4446
+ return NodeType.Library;
4447
+ }
4448
+ /** Determine the primary platform from deployment targets */
4449
+ function getPrimaryPlatform(deploymentTargets) {
4450
+ if (!deploymentTargets)
4451
+ return Platform$1.macOS;
4452
+ if (deploymentTargets.iOS)
4453
+ return Platform$1.iOS;
4454
+ if (deploymentTargets.macOS)
4455
+ return Platform$1.macOS;
4456
+ if (deploymentTargets.tvOS)
4457
+ return Platform$1.tvOS;
4458
+ if (deploymentTargets.watchOS)
4459
+ return Platform$1.watchOS;
4460
+ if (deploymentTargets.visionOS)
4461
+ return Platform$1.visionOS;
4462
+ return Platform$1.macOS;
4463
+ }
4464
+ /** Convert raw deployment targets to our format */
4465
+ function mapDeploymentTargets(raw) {
4466
+ if (!raw)
4467
+ return undefined;
4468
+ const result = {};
4469
+ if (raw.iOS)
4470
+ result.iOS = raw.iOS;
4471
+ if (raw.macOS)
4472
+ result.macOS = raw.macOS;
4473
+ if (raw.tvOS)
4474
+ result.tvOS = raw.tvOS;
4475
+ if (raw.watchOS)
4476
+ result.watchOS = raw.watchOS;
4477
+ if (raw.visionOS)
4478
+ result.visionOS = raw.visionOS;
4479
+ return Object.keys(result).length > 0 ? result : undefined;
4480
+ }
4481
+ /** Map raw destinations to our Destination type */
4482
+ function mapDestinations(raw) {
4483
+ if (!raw || typeof raw !== 'object')
4484
+ return undefined;
4485
+ const destinationMap = {
4486
+ iPhone: 'iPhone',
4487
+ iPad: 'iPad',
4488
+ mac: 'mac',
4489
+ macCatalyst: 'macCatalyst',
4490
+ macWithiPadDesign: 'macWithiPadDesign',
4491
+ appleTv: 'appleTv',
4492
+ appleWatch: 'appleWatch',
4493
+ appleVision: 'appleVision',
4494
+ appleVisionWithiPadDesign: 'appleVisionWithiPadDesign',
4495
+ };
4496
+ const rawObj = raw;
4497
+ const destinations = Object.keys(rawObj)
4498
+ .map((key) => destinationMap[key])
4499
+ .filter((d) => d !== undefined);
4500
+ return destinations.length > 0 ? destinations : undefined;
4501
+ }
4502
+ /** Read a string value from build settings base */
4503
+ function getBaseString(base, key) {
4504
+ const value = base[key];
4505
+ return typeof value === 'string' ? value : undefined;
4506
+ }
4507
+ /** Parse compilation conditions from build settings */
4508
+ function parseCompilationConditions(base) {
4509
+ // biome-ignore lint/complexity/useLiteralKeys: TS noPropertyAccessFromIndexSignature requires bracket notation
4510
+ const conditions = base['SWIFT_ACTIVE_COMPILATION_CONDITIONS'];
4511
+ if (!conditions)
4512
+ return undefined;
4513
+ if (Array.isArray(conditions))
4514
+ return conditions.map(String);
4515
+ if (typeof conditions === 'string')
4516
+ return conditions.split(' ').filter(Boolean);
4517
+ return undefined;
4518
+ }
4519
+ /** Extract curated build settings from Release config (base settings) */
4520
+ function extractBuildSettings(settings, collector) {
4521
+ if (!settings?.base)
4522
+ return undefined;
4523
+ try {
4524
+ const base = settings.base;
4525
+ const result = {};
4526
+ const swiftVersion = getBaseString(base, 'SWIFT_VERSION');
4527
+ if (swiftVersion)
4528
+ result.swiftVersion = swiftVersion;
4529
+ const compilationConditions = parseCompilationConditions(base);
4530
+ if (compilationConditions)
4531
+ result.compilationConditions = compilationConditions;
4532
+ const codeSign = getBaseString(base, 'CODE_SIGN_IDENTITY');
4533
+ if (codeSign)
4534
+ result.codeSignIdentity = codeSign;
4535
+ const devTeam = getBaseString(base, 'DEVELOPMENT_TEAM');
4536
+ if (devTeam)
4537
+ result.developmentTeam = devTeam;
4538
+ const profile = getBaseString(base, 'PROVISIONING_PROFILE_SPECIFIER');
4539
+ if (profile)
4540
+ result.provisioningProfile = profile;
4541
+ return Object.keys(result).length > 0 ? result : undefined;
4542
+ }
4543
+ catch (error) {
4544
+ collector.warn(`Failed to extract build settings: ${error instanceof Error ? error.message : String(error)}`);
4545
+ return undefined;
4546
+ }
4547
+ }
4548
+ /** Classify foreign build inputs by type */
4549
+ function classifyForeignInputs(inputs) {
4550
+ const files = [];
4551
+ const folders = [];
4552
+ const scripts = [];
4553
+ for (const input of inputs ?? []) {
4554
+ if ('file' in input)
4555
+ files.push(input.file._0);
4556
+ else if ('folder' in input)
4557
+ folders.push(input.folder._0);
4558
+ else if ('script' in input)
4559
+ scripts.push(input.script._0);
4560
+ }
4561
+ return { files, folders, scripts };
4562
+ }
4563
+ /** Extract foreign build info from target */
4564
+ function extractForeignBuild(foreignBuild, collector) {
4565
+ if (!foreignBuild)
4566
+ return undefined;
4567
+ try {
4568
+ const outputPath = foreignBuild.output?.xcframework?.path ?? '';
4569
+ const outputFilename = outputPath.split('/').pop() ?? outputPath;
4570
+ return {
4571
+ script: foreignBuild.script,
4572
+ outputPath: outputFilename,
4573
+ outputLinking: foreignBuild.output?.xcframework?.linking ?? 'static',
4574
+ inputCount: foreignBuild.inputs?.length ?? 0,
4575
+ inputs: classifyForeignInputs(foreignBuild.inputs),
4576
+ };
4577
+ }
4578
+ catch (error) {
4579
+ collector.warn(`Failed to extract foreign build info: ${error instanceof Error ? error.message : String(error)}`);
4580
+ return undefined;
4581
+ }
4582
+ }
4583
+ /** Notable resource file patterns */
4584
+ const NOTABLE_RESOURCE_PATTERNS = [
4585
+ 'PrivacyInfo.xcprivacy',
4586
+ '.storyboard',
4587
+ '.xcassets',
4588
+ '.entitlements',
4589
+ '.xcdatamodeld',
4590
+ 'LaunchScreen',
4591
+ ];
4592
+ function getResourceFilePath(res) {
4593
+ if ('file' in res)
4594
+ return res.file.path;
4595
+ if ('folderReference' in res)
4596
+ return res.folderReference.path;
4597
+ return '';
4598
+ }
4599
+ function collectNotablePatterns(resources, notableResources) {
4600
+ for (const res of resources) {
4601
+ const path = getResourceFilePath(res);
4602
+ for (const pattern of NOTABLE_RESOURCE_PATTERNS) {
4603
+ if (path.includes(pattern) && !notableResources.includes(pattern)) {
4604
+ notableResources.push(pattern);
4605
+ }
4606
+ }
4607
+ }
4608
+ }
4609
+ /** Extract resource metadata from target */
4610
+ function extractResourceMetadata(resources, collector) {
4611
+ try {
4612
+ const resourceCount = resources?.resources?.length ?? 0;
4613
+ const notableResources = [];
4614
+ if (resources?.privacyManifest) {
4615
+ notableResources.push('PrivacyInfo.xcprivacy');
4616
+ }
4617
+ if (resources?.resources) {
4618
+ collectNotablePatterns(resources.resources, notableResources);
4619
+ }
4620
+ return { resourceCount, notableResources };
4621
+ }
4622
+ catch (error) {
4623
+ collector.warn(`Failed to extract resource metadata: ${error instanceof Error ? error.message : String(error)}`);
4624
+ return { resourceCount: 0, notableResources: [] };
4625
+ }
4626
+ }
4627
+ /** Determine origin based on project type and path */
4628
+ function getOriginFromProject(projectPath, projectType) {
4629
+ if ('external' in projectType)
4630
+ return Origin.External;
4631
+ const externalPaths = ['.build/checkouts/', '.build/registry/downloads/'];
4632
+ if (externalPaths.some((p) => projectPath.includes(p)))
4633
+ return Origin.External;
4634
+ return Origin.Local;
4635
+ }
4636
+ function getDependencyKey(dep) {
4637
+ if ('target' in dep)
4638
+ return `target:${dep.target.path}:${dep.target.name}`;
4639
+ if ('packageProduct' in dep)
4640
+ return `package:${dep.packageProduct.path}:${dep.packageProduct.product}`;
4641
+ if ('xcframework' in dep)
4642
+ return `xcframework:${dep.xcframework._0.path}`;
4643
+ if ('sdk' in dep)
4644
+ return `sdk:${dep.sdk.name}`;
4645
+ if ('framework' in dep)
4646
+ return `framework:${dep.framework.path}`;
4647
+ if ('library' in dep)
4648
+ return `library:${dep.library.path}`;
4649
+ if ('bundle' in dep)
4650
+ return `bundle:${dep.bundle.path}`;
4651
+ if ('macro' in dep)
4652
+ return `macro:${dep.macro.path}`;
4653
+ return `unknown:${JSON.stringify(dep)}`;
4654
+ }
4655
+ function getNameFromPath(path, extensions) {
4656
+ const filename = path.split('/').pop() ?? 'Unknown';
4657
+ let result = filename;
4658
+ for (const ext of extensions) {
4659
+ result = result.replace(ext, '');
4660
+ }
4661
+ return result;
4662
+ }
4663
+ function getDependencyName(dep) {
4664
+ if ('target' in dep)
4665
+ return dep.target.name;
4666
+ if ('packageProduct' in dep)
4667
+ return dep.packageProduct.product;
4668
+ if ('xcframework' in dep)
4669
+ return getNameFromPath(dep.xcframework._0.path, ['.xcframework']);
4670
+ if ('sdk' in dep)
4671
+ return dep.sdk.name.replace('.framework', '');
4672
+ if ('framework' in dep)
4673
+ return getNameFromPath(dep.framework.path, ['.framework']);
4674
+ if ('library' in dep)
4675
+ return getNameFromPath(dep.library.path, ['.a', '.dylib']);
4676
+ if ('bundle' in dep)
4677
+ return getNameFromPath(dep.bundle.path, ['.bundle']);
4678
+ if ('macro' in dep)
4679
+ return getNameFromPath(dep.macro.path, []);
4680
+ return 'Unknown';
4681
+ }
4682
+ function getNodeTypeForDependency(dep) {
4683
+ if ('sdk' in dep || 'xcframework' in dep || 'framework' in dep)
4684
+ return NodeType.Framework;
4685
+ if ('packageProduct' in dep)
4686
+ return NodeType.Package;
4687
+ return NodeType.Library;
4688
+ }
4689
+ function getOriginForDependency(dep) {
4690
+ if ('sdk' in dep || 'xcframework' in dep || 'packageProduct' in dep)
4691
+ return Origin.External;
4692
+ if ('target' in dep) {
4693
+ const externalPaths = ['.build/checkouts/', '.build/registry/downloads/'];
4694
+ if (externalPaths.some((p) => dep.target.path.includes(p)))
4695
+ return Origin.External;
4696
+ }
4697
+ return Origin.Local;
4698
+ }
4699
+ function getDependencyKind(dep) {
4700
+ if ('target' in dep)
4701
+ return DependencyKind.Target;
4702
+ if ('packageProduct' in dep)
4703
+ return DependencyKind.Project;
4704
+ if ('xcframework' in dep)
4705
+ return DependencyKind.XCFramework;
4706
+ if ('sdk' in dep || 'framework' in dep)
4707
+ return DependencyKind.Sdk;
4708
+ return DependencyKind.Target; // default for library, bundle, macro
4709
+ }
4710
+ /** Populate source paths from either sources or buildable folders */
4711
+ function populateSourcePaths(node, target) {
4712
+ if (target.sources?.length) {
4713
+ node.sourcePaths = target.sources.map((s) => s.path);
4714
+ node.sourceCount = target.sources.length;
4715
+ }
4716
+ else if ('buildableFolders' in target) {
4717
+ const folders = target.buildableFolders;
4718
+ if (folders?.length) {
4719
+ const resolvedFiles = folders.flatMap((bf) => bf.resolvedFiles);
4720
+ if (resolvedFiles.length > 0) {
4721
+ node.sourcePaths = resolvedFiles.map((f) => f.path);
4722
+ node.sourceCount = resolvedFiles.length;
4723
+ }
4724
+ }
4725
+ }
4726
+ }
4727
+ /** Populate optional metadata fields (tags, remote, build settings, resources) */
4728
+ function populateOptionalMetadata(node, target, collector) {
4729
+ if (target.metadata?.tags?.length > 0) {
4730
+ node.tags = target.metadata.tags;
4731
+ }
4732
+ if (target.type === TargetType.Remote) {
4733
+ node.isRemote = true;
4734
+ }
4735
+ const buildSettings = extractBuildSettings(target.settings, collector);
4736
+ if (buildSettings) {
4737
+ node.buildSettings = buildSettings;
4738
+ }
4739
+ const { resourceCount, notableResources } = extractResourceMetadata(target.resources, collector);
4740
+ if (resourceCount > 0) {
4741
+ node.resourceCount = resourceCount;
4742
+ }
4743
+ if (notableResources.length > 0) {
4744
+ node.notableResources = notableResources;
4745
+ }
4746
+ if ('foreignBuild' in target) {
4747
+ const foreignBuildInfo = extractForeignBuild(target.foreignBuild, collector);
4748
+ if (foreignBuildInfo) {
4749
+ node.foreignBuild = foreignBuildInfo;
4750
+ }
4751
+ }
4752
+ }
4753
+ /** Create a rich GraphNode from target data */
4754
+ function createNodeFromTarget(key, target, projectName, projectPath, origin, collector) {
4755
+ const node = {
4756
+ id: key,
4757
+ name: target.name,
4758
+ type: productToNodeType(target.product, collector),
4759
+ platform: getPrimaryPlatform(target.deploymentTargets),
4760
+ origin,
4761
+ project: projectName,
4762
+ bundleId: target.bundleId,
4763
+ productName: target.productName,
4764
+ path: projectPath,
4765
+ };
4766
+ const deploymentTargets = mapDeploymentTargets(target.deploymentTargets);
4767
+ if (deploymentTargets)
4768
+ node.deploymentTargets = deploymentTargets;
4769
+ const destinations = mapDestinations(target.destinations);
4770
+ if (destinations)
4771
+ node.destinations = destinations;
4772
+ populateSourcePaths(node, target);
4773
+ populateOptionalMetadata(node, target, collector);
4774
+ return node;
4775
+ }
4776
+ /** Create a basic GraphNode from dependency info */
4777
+ function createNodeFromDependency(dep, project) {
4778
+ return {
4779
+ id: getDependencyKey(dep),
4780
+ name: getDependencyName(dep),
4781
+ type: getNodeTypeForDependency(dep),
4782
+ platform: Platform$1.macOS,
4783
+ origin: getOriginForDependency(dep),
4784
+ project,
4785
+ };
4786
+ }
4787
+ /** Build lookup map and initial nodes from projects (flat alternating array) */
4788
+ function extractProjectTargets(projects, collector) {
4789
+ const nodes = new Map();
4790
+ const lookup = new Map();
4791
+ // Projects is flat alternating: [path, Project, path, Project, ...]
4792
+ for (let i = 0; i < projects.length; i += 2) {
4793
+ const projectPath = projects[i];
4794
+ const project = projects[i + 1];
4795
+ if (typeof projectPath !== 'string' || !project || typeof project !== 'object') {
4796
+ collector.warn(`Unexpected project entry shape at index ${i}`);
4797
+ continue;
4798
+ }
4799
+ if (!('targets' in project)) {
4800
+ collector.warn(`Skipping invalid project entry at index ${i + 1}`);
4801
+ continue;
4802
+ }
4803
+ const origin = getOriginFromProject(projectPath, project.type);
4804
+ // Targets is { [key: string]: Target } because key is String
4805
+ for (const [, target] of Object.entries(project.targets)) {
4806
+ const key = `target:${projectPath}:${target.name}`;
4807
+ lookup.set(key, { target, projectName: project.name, projectPath, origin });
4808
+ nodes.set(key, createNodeFromTarget(key, target, project.name, projectPath, origin, collector));
4809
+ }
4810
+ }
4811
+ return { nodes, lookup };
4812
+ }
4813
+ /** Ensure a node exists for a dependency, creating it if missing */
4814
+ function ensureDependencyNode(dep, nodes, lookup, fallbackProject, collector) {
4815
+ const key = getDependencyKey(dep);
4816
+ if (nodes.has(key))
4817
+ return key;
4818
+ const lookupData = lookup.get(key);
4819
+ if (lookupData) {
4820
+ const { target, projectName, projectPath, origin } = lookupData;
4821
+ nodes.set(key, createNodeFromTarget(key, target, projectName, projectPath, origin, collector));
4822
+ }
4823
+ else {
4824
+ nodes.set(key, createNodeFromDependency(dep, fallbackProject));
4825
+ }
4826
+ return key;
4827
+ }
4828
+ /** Process dependencies (flat alternating array) to create edges and missing nodes */
4829
+ function processDependencies(dependencies, nodes, lookup, collector) {
4830
+ const edges = [];
4831
+ // Dependencies is flat alternating: [sourceDep, targetDeps[], sourceDep, targetDeps[], ...]
4832
+ for (let i = 0; i < dependencies.length; i += 2) {
4833
+ const sourceDep = dependencies[i];
4834
+ const targetDeps = dependencies[i + 1];
4835
+ if (!sourceDep || typeof sourceDep !== 'object' || !Array.isArray(targetDeps)) {
4836
+ collector.warn(`Unexpected dependency entry shape at index ${i}`);
4837
+ continue;
4838
+ }
4839
+ // After the Array.isArray guard above, sourceDep is the single-object branch
4840
+ const sourceDepObj = sourceDep;
4841
+ const sourceProject = lookup.get(getDependencyKey(sourceDepObj))?.projectName ??
4842
+ nodes.get(getDependencyKey(sourceDepObj))?.project;
4843
+ const sourceKey = ensureDependencyNode(sourceDepObj, nodes, lookup, sourceProject, collector);
4844
+ for (const targetDep of targetDeps) {
4845
+ const targetKey = ensureDependencyNode(targetDep, nodes, lookup, sourceProject, collector);
4846
+ edges.push({ source: sourceKey, target: targetKey, kind: getDependencyKind(targetDep) });
4847
+ }
4848
+ }
4849
+ return edges;
4850
+ }
4851
+ /**
4852
+ * Transform a raw XcodeGraph JSON into our GraphData format.
4853
+ * Extracts all rich metadata from projects, targets, and dependencies.
4854
+ * Returns warnings for non-fatal issues instead of throwing.
4855
+ *
4856
+ * @param raw - Raw JSON value from Tuist graph dump
4857
+ * @returns Transformed graph data and any non-fatal warnings
4858
+ */
4859
+ function transformXcodeGraph(raw) {
4860
+ const parseResult = safeParseGraph(raw);
4861
+ const collector = new WarningCollector();
4862
+ // Propagate boundary validation warnings
4863
+ collector.warnings.push(...parseResult.warnings);
4864
+ if (!parseResult.success) {
4865
+ return {
4866
+ data: { nodes: [], edges: [] },
4867
+ warnings: collector.warnings,
4868
+ };
4869
+ }
4870
+ // Boundary validation ensures top-level shape; transform functions handle field-level mismatches.
4871
+ // RawGraph (projects: unknown[], dependencies: unknown[]) is structurally incompatible with
4872
+ // Graph (projects: (string | Project)[], dependencies: ...) — the double cast is intentional.
4873
+ const graph = parseResult.data;
4874
+ const { nodes, lookup } = extractProjectTargets(graph.projects, collector);
4875
+ const edges = processDependencies(graph.dependencies, nodes, lookup, collector);
4876
+ return {
4877
+ data: {
4878
+ nodes: Array.from(nodes.values()),
4879
+ edges,
4880
+ },
4881
+ warnings: collector.warnings,
4882
+ };
4883
+ }
4884
+ /**
4885
+ * Load and transform an XcodeGraph from a JSON file URL.
4886
+ *
4887
+ * @param jsonPath - URL or path to the JSON file
4888
+ * @returns Transformed graph data and any non-fatal warnings
4889
+ */
4890
+ async function loadXcodeGraph(jsonPath) {
4891
+ const response = await fetch(jsonPath);
4892
+ const raw = await response.json();
4893
+ return transformXcodeGraph(raw);
4894
+ }
4895
+ /**
4896
+ * Parse and transform an XcodeGraph from a JSON string.
4897
+ *
4898
+ * @param jsonString - Raw JSON string to parse
4899
+ * @returns Transformed graph data and any non-fatal warnings
4900
+ */
4901
+ function parseXcodeGraph(jsonString) {
4902
+ const raw = JSON.parse(jsonString);
4903
+ return transformXcodeGraph(raw);
4904
+ }
4905
+
4906
+ export { loadXcodeGraph, parseXcodeGraph, transformXcodeGraph };