@deepseek-ai/dsh-client-ui-sidebar-right 0.2.1-alpha.2 → 0.2.1-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -32,6 +32,7 @@ window.__ModuleLoader__.load({
32
32
  let react = require("react");
33
33
  let _deepseek_ai_dsh_client_ui_dockkit = require("@deepseek-ai/dsh-client-ui-dockkit");
34
34
  let _deepseek_ai_dsh_client_store = require("@deepseek-ai/dsh-client-store");
35
+ let zod = require("zod");
35
36
  let react_dom = require("react-dom");
36
37
  //#region lib/types/client/focus.js
37
38
  /**
@@ -639,4320 +640,53 @@ window.__ModuleLoader__.load({
639
640
  };
640
641
  }
641
642
  //#endregion
642
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
643
- var _a$1;
644
- function $constructor(name, initializer, params) {
645
- function init(inst, def) {
646
- if (!inst._zod) Object.defineProperty(inst, "_zod", {
647
- value: {
648
- def,
649
- constr: _,
650
- traits: /* @__PURE__ */ new Set()
651
- },
652
- enumerable: false
653
- });
654
- if (inst._zod.traits.has(name)) return;
655
- inst._zod.traits.add(name);
656
- initializer(inst, def);
657
- const proto = _.prototype;
658
- const keys = Object.keys(proto);
659
- for (let i = 0; i < keys.length; i++) {
660
- const k = keys[i];
661
- if (!(k in inst)) inst[k] = proto[k].bind(inst);
662
- }
663
- }
664
- const Parent = params?.Parent ?? Object;
665
- class Definition extends Parent {}
666
- Object.defineProperty(Definition, "name", { value: name });
667
- function _(def) {
668
- var _a;
669
- const inst = params?.Parent ? new Definition() : this;
670
- init(inst, def);
671
- (_a = inst._zod).deferred ?? (_a.deferred = []);
672
- for (const fn of inst._zod.deferred) fn();
673
- return inst;
674
- }
675
- Object.defineProperty(_, "init", { value: init });
676
- Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
677
- if (params?.Parent && inst instanceof params.Parent) return true;
678
- return inst?._zod?.traits?.has(name);
679
- } });
680
- Object.defineProperty(_, "name", { value: name });
681
- return _;
682
- }
683
- var $ZodAsyncError = class extends Error {
684
- constructor() {
685
- super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
686
- }
687
- };
688
- var $ZodEncodeError = class extends Error {
689
- constructor(name) {
690
- super(`Encountered unidirectional transform during encode: ${name}`);
691
- this.name = "ZodEncodeError";
692
- }
693
- };
694
- (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
695
- const globalConfig = globalThis.__zod_globalConfig;
696
- function config(newConfig) {
697
- if (newConfig) Object.assign(globalConfig, newConfig);
698
- return globalConfig;
699
- }
700
- //#endregion
701
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.js
702
- function getEnumValues(entries) {
703
- const numericValues = Object.values(entries).filter((v) => typeof v === "number");
704
- return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
705
- }
706
- function jsonStringifyReplacer(_, value) {
707
- if (typeof value === "bigint") return value.toString();
708
- return value;
709
- }
710
- function cached(getter) {
711
- return { get value() {
712
- {
713
- const value = getter();
714
- Object.defineProperty(this, "value", { value });
715
- return value;
716
- }
717
- throw new Error("cached value already set");
718
- } };
719
- }
720
- function nullish(input) {
721
- return input === null || input === void 0;
722
- }
723
- function cleanRegex(source) {
724
- const start = source.startsWith("^") ? 1 : 0;
725
- const end = source.endsWith("$") ? source.length - 1 : source.length;
726
- return source.slice(start, end);
727
- }
728
- function floatSafeRemainder(val, step) {
729
- const ratio = val / step;
730
- const roundedRatio = Math.round(ratio);
731
- const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
732
- if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
733
- return ratio - roundedRatio;
734
- }
735
- const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
736
- function defineLazy(object, key, getter) {
737
- let value = void 0;
738
- Object.defineProperty(object, key, {
739
- get() {
740
- if (value === EVALUATING) return;
741
- if (value === void 0) {
742
- value = EVALUATING;
743
- value = getter();
744
- }
745
- return value;
746
- },
747
- set(v) {
748
- Object.defineProperty(object, key, { value: v });
749
- },
750
- configurable: true
751
- });
752
- }
753
- function assignProp(target, prop, value) {
754
- Object.defineProperty(target, prop, {
755
- value,
756
- writable: true,
757
- enumerable: true,
758
- configurable: true
759
- });
760
- }
761
- function mergeDefs(...defs) {
762
- const mergedDescriptors = {};
763
- for (const def of defs) Object.assign(mergedDescriptors, Object.getOwnPropertyDescriptors(def));
764
- return Object.defineProperties({}, mergedDescriptors);
765
- }
766
- function esc(str) {
767
- return JSON.stringify(str);
768
- }
769
- function slugify(input) {
770
- return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
771
- }
772
- const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
773
- function isObject(data) {
774
- return typeof data === "object" && data !== null && !Array.isArray(data);
775
- }
776
- const allowsEval = /* @__PURE__*/ cached(() => {
777
- if (globalConfig.jitless) return false;
778
- if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
779
- try {
780
- new Function("");
781
- return true;
782
- } catch (_) {
783
- return false;
784
- }
785
- });
786
- function isPlainObject(o) {
787
- if (isObject(o) === false) return false;
788
- const ctor = o.constructor;
789
- if (ctor === void 0) return true;
790
- if (typeof ctor !== "function") return true;
791
- const prot = ctor.prototype;
792
- if (isObject(prot) === false) return false;
793
- if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
794
- return true;
795
- }
796
- function shallowClone(o) {
797
- if (isPlainObject(o)) return { ...o };
798
- if (Array.isArray(o)) return [...o];
799
- if (o instanceof Map) return new Map(o);
800
- if (o instanceof Set) return new Set(o);
801
- return o;
802
- }
803
- const propertyKeyTypes = /* @__PURE__*/ new Set([
804
- "string",
805
- "number",
806
- "symbol"
807
- ]);
808
- function escapeRegex(str) {
809
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
810
- }
811
- function clone(inst, def, params) {
812
- const cl = new inst._zod.constr(def ?? inst._zod.def);
813
- if (!def || params?.parent) cl._zod.parent = inst;
814
- return cl;
815
- }
816
- function normalizeParams(_params) {
817
- const params = _params;
818
- if (!params) return {};
819
- if (typeof params === "string") return { error: () => params };
820
- if (params?.message !== void 0) {
821
- if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
822
- params.error = params.message;
823
- }
824
- delete params.message;
825
- if (typeof params.error === "string") return {
826
- ...params,
827
- error: () => params.error
828
- };
829
- return params;
830
- }
831
- function optionalKeys(shape) {
832
- return Object.keys(shape).filter((k) => {
833
- return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
834
- });
835
- }
836
- const NUMBER_FORMAT_RANGES = {
837
- safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
838
- int32: [-2147483648, 2147483647],
839
- uint32: [0, 4294967295],
840
- float32: [-34028234663852886e22, 34028234663852886e22],
841
- float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
842
- };
843
- function pick(schema, mask) {
844
- const currDef = schema._zod.def;
845
- const checks = currDef.checks;
846
- if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
847
- return clone(schema, mergeDefs(schema._zod.def, {
848
- get shape() {
849
- const newShape = {};
850
- for (const key in mask) {
851
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
852
- if (!mask[key]) continue;
853
- newShape[key] = currDef.shape[key];
854
- }
855
- assignProp(this, "shape", newShape);
856
- return newShape;
857
- },
858
- checks: []
859
- }));
860
- }
861
- function omit(schema, mask) {
862
- const currDef = schema._zod.def;
863
- const checks = currDef.checks;
864
- if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
865
- return clone(schema, mergeDefs(schema._zod.def, {
866
- get shape() {
867
- const newShape = { ...schema._zod.def.shape };
868
- for (const key in mask) {
869
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
870
- if (!mask[key]) continue;
871
- delete newShape[key];
872
- }
873
- assignProp(this, "shape", newShape);
874
- return newShape;
875
- },
876
- checks: []
877
- }));
878
- }
879
- function extend(schema, shape) {
880
- if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
881
- const checks = schema._zod.def.checks;
882
- if (checks && checks.length > 0) {
883
- const existingShape = schema._zod.def.shape;
884
- for (const key in shape) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
885
- }
886
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
887
- const _shape = {
888
- ...schema._zod.def.shape,
889
- ...shape
890
- };
891
- assignProp(this, "shape", _shape);
892
- return _shape;
893
- } }));
894
- }
895
- function safeExtend(schema, shape) {
896
- if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
897
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
898
- const _shape = {
899
- ...schema._zod.def.shape,
900
- ...shape
901
- };
902
- assignProp(this, "shape", _shape);
903
- return _shape;
904
- } }));
905
- }
906
- function merge(a, b) {
907
- if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
908
- return clone(a, mergeDefs(a._zod.def, {
909
- get shape() {
910
- const _shape = {
911
- ...a._zod.def.shape,
912
- ...b._zod.def.shape
913
- };
914
- assignProp(this, "shape", _shape);
915
- return _shape;
916
- },
917
- get catchall() {
918
- return b._zod.def.catchall;
919
- },
920
- checks: b._zod.def.checks ?? []
921
- }));
922
- }
923
- function partial(Class, schema, mask) {
924
- const checks = schema._zod.def.checks;
925
- if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
926
- return clone(schema, mergeDefs(schema._zod.def, {
927
- get shape() {
928
- const oldShape = schema._zod.def.shape;
929
- const shape = { ...oldShape };
930
- if (mask) for (const key in mask) {
931
- if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
932
- if (!mask[key]) continue;
933
- shape[key] = Class ? new Class({
934
- type: "optional",
935
- innerType: oldShape[key]
936
- }) : oldShape[key];
937
- }
938
- else for (const key in oldShape) shape[key] = Class ? new Class({
939
- type: "optional",
940
- innerType: oldShape[key]
941
- }) : oldShape[key];
942
- assignProp(this, "shape", shape);
943
- return shape;
944
- },
945
- checks: []
946
- }));
947
- }
948
- function required(Class, schema, mask) {
949
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
950
- const oldShape = schema._zod.def.shape;
951
- const shape = { ...oldShape };
952
- if (mask) for (const key in mask) {
953
- if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
954
- if (!mask[key]) continue;
955
- shape[key] = new Class({
956
- type: "nonoptional",
957
- innerType: oldShape[key]
958
- });
959
- }
960
- else for (const key in oldShape) shape[key] = new Class({
961
- type: "nonoptional",
962
- innerType: oldShape[key]
963
- });
964
- assignProp(this, "shape", shape);
965
- return shape;
966
- } }));
967
- }
968
- function aborted(x, startIndex = 0) {
969
- if (x.aborted === true) return true;
970
- for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
971
- return false;
972
- }
973
- function explicitlyAborted(x, startIndex = 0) {
974
- if (x.aborted === true) return true;
975
- for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue === false) return true;
976
- return false;
977
- }
978
- function prefixIssues(path, issues) {
979
- return issues.map((iss) => {
980
- var _a;
981
- (_a = iss).path ?? (_a.path = []);
982
- iss.path.unshift(path);
983
- return iss;
984
- });
985
- }
986
- function unwrapMessage(message) {
987
- return typeof message === "string" ? message : message?.message;
988
- }
989
- function finalizeIssue(iss, ctx, config) {
990
- const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
991
- const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
992
- rest.path ?? (rest.path = []);
993
- rest.message = message;
994
- if (ctx?.reportInput) rest.input = _input;
995
- return rest;
996
- }
997
- function getLengthableOrigin(input) {
998
- if (Array.isArray(input)) return "array";
999
- if (typeof input === "string") return "string";
1000
- return "unknown";
1001
- }
1002
- function issue(...args) {
1003
- const [iss, input, inst] = args;
1004
- if (typeof iss === "string") return {
1005
- message: iss,
1006
- code: "custom",
1007
- input,
1008
- inst
1009
- };
1010
- return { ...iss };
1011
- }
1012
- //#endregion
1013
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/errors.js
1014
- const initializer$1 = (inst, def) => {
1015
- inst.name = "$ZodError";
1016
- Object.defineProperty(inst, "_zod", {
1017
- value: inst._zod,
1018
- enumerable: false
1019
- });
1020
- Object.defineProperty(inst, "issues", {
1021
- value: def,
1022
- enumerable: false
1023
- });
1024
- inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
1025
- Object.defineProperty(inst, "toString", {
1026
- value: () => inst.message,
1027
- enumerable: false
1028
- });
1029
- };
1030
- const $ZodError = $constructor("$ZodError", initializer$1);
1031
- const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
1032
- function flattenError(error, mapper = (issue) => issue.message) {
1033
- const fieldErrors = {};
1034
- const formErrors = [];
1035
- for (const sub of error.issues) if (sub.path.length > 0) {
1036
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
1037
- fieldErrors[sub.path[0]].push(mapper(sub));
1038
- } else formErrors.push(mapper(sub));
1039
- return {
1040
- formErrors,
1041
- fieldErrors
1042
- };
1043
- }
1044
- function formatError(error, mapper = (issue) => issue.message) {
1045
- const fieldErrors = { _errors: [] };
1046
- const processError = (error, path = []) => {
1047
- for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
1048
- else if (issue.code === "invalid_key") processError({ issues: issue.issues }, [...path, ...issue.path]);
1049
- else if (issue.code === "invalid_element") processError({ issues: issue.issues }, [...path, ...issue.path]);
1050
- else {
1051
- const fullpath = [...path, ...issue.path];
1052
- if (fullpath.length === 0) fieldErrors._errors.push(mapper(issue));
1053
- else {
1054
- let curr = fieldErrors;
1055
- let i = 0;
1056
- while (i < fullpath.length) {
1057
- const el = fullpath[i];
1058
- if (!(i === fullpath.length - 1)) curr[el] = curr[el] || { _errors: [] };
1059
- else {
1060
- curr[el] = curr[el] || { _errors: [] };
1061
- curr[el]._errors.push(mapper(issue));
1062
- }
1063
- curr = curr[el];
1064
- i++;
1065
- }
1066
- }
1067
- }
1068
- };
1069
- processError(error);
1070
- return fieldErrors;
1071
- }
1072
- //#endregion
1073
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/parse.js
1074
- const _parse = (_Err) => (schema, value, _ctx, _params) => {
1075
- const ctx = _ctx ? {
1076
- ..._ctx,
1077
- async: false
1078
- } : { async: false };
1079
- const result = schema._zod.run({
1080
- value,
1081
- issues: []
1082
- }, ctx);
1083
- if (result instanceof Promise) throw new $ZodAsyncError();
1084
- if (result.issues.length) {
1085
- const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
1086
- captureStackTrace(e, _params?.callee);
1087
- throw e;
1088
- }
1089
- return result.value;
1090
- };
1091
- const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
1092
- const ctx = _ctx ? {
1093
- ..._ctx,
1094
- async: true
1095
- } : { async: true };
1096
- let result = schema._zod.run({
1097
- value,
1098
- issues: []
1099
- }, ctx);
1100
- if (result instanceof Promise) result = await result;
1101
- if (result.issues.length) {
1102
- const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
1103
- captureStackTrace(e, params?.callee);
1104
- throw e;
1105
- }
1106
- return result.value;
1107
- };
1108
- const _safeParse = (_Err) => (schema, value, _ctx) => {
1109
- const ctx = _ctx ? {
1110
- ..._ctx,
1111
- async: false
1112
- } : { async: false };
1113
- const result = schema._zod.run({
1114
- value,
1115
- issues: []
1116
- }, ctx);
1117
- if (result instanceof Promise) throw new $ZodAsyncError();
1118
- return result.issues.length ? {
1119
- success: false,
1120
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
1121
- } : {
1122
- success: true,
1123
- data: result.value
1124
- };
1125
- };
1126
- const safeParse$1 = /* @__PURE__*/ _safeParse($ZodRealError);
1127
- const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
1128
- const ctx = _ctx ? {
1129
- ..._ctx,
1130
- async: true
1131
- } : { async: true };
1132
- let result = schema._zod.run({
1133
- value,
1134
- issues: []
1135
- }, ctx);
1136
- if (result instanceof Promise) result = await result;
1137
- return result.issues.length ? {
1138
- success: false,
1139
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
1140
- } : {
1141
- success: true,
1142
- data: result.value
1143
- };
1144
- };
1145
- const safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
1146
- const _encode = (_Err) => (schema, value, _ctx) => {
1147
- const ctx = _ctx ? {
1148
- ..._ctx,
1149
- direction: "backward"
1150
- } : { direction: "backward" };
1151
- return _parse(_Err)(schema, value, ctx);
1152
- };
1153
- const _decode = (_Err) => (schema, value, _ctx) => {
1154
- return _parse(_Err)(schema, value, _ctx);
1155
- };
1156
- const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
1157
- const ctx = _ctx ? {
1158
- ..._ctx,
1159
- direction: "backward"
1160
- } : { direction: "backward" };
1161
- return _parseAsync(_Err)(schema, value, ctx);
1162
- };
1163
- const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
1164
- return _parseAsync(_Err)(schema, value, _ctx);
1165
- };
1166
- const _safeEncode = (_Err) => (schema, value, _ctx) => {
1167
- const ctx = _ctx ? {
1168
- ..._ctx,
1169
- direction: "backward"
1170
- } : { direction: "backward" };
1171
- return _safeParse(_Err)(schema, value, ctx);
1172
- };
1173
- const _safeDecode = (_Err) => (schema, value, _ctx) => {
1174
- return _safeParse(_Err)(schema, value, _ctx);
1175
- };
1176
- const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
1177
- const ctx = _ctx ? {
1178
- ..._ctx,
1179
- direction: "backward"
1180
- } : { direction: "backward" };
1181
- return _safeParseAsync(_Err)(schema, value, ctx);
1182
- };
1183
- const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
1184
- return _safeParseAsync(_Err)(schema, value, _ctx);
1185
- };
1186
- //#endregion
1187
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/regexes.js
1188
- /**
1189
- * @deprecated CUID v1 is deprecated by its authors due to information leakage
1190
- * (timestamps embedded in the id). Use {@link cuid2} instead.
1191
- * See https://github.com/paralleldrive/cuid.
1192
- */
1193
- const cuid = /^[cC][0-9a-z]{6,}$/;
1194
- const cuid2 = /^[0-9a-z]+$/;
1195
- const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
1196
- const xid = /^[0-9a-vA-V]{20}$/;
1197
- const ksuid = /^[A-Za-z0-9]{27}$/;
1198
- const nanoid = /^[a-zA-Z0-9_-]{21}$/;
1199
- /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
1200
- 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)?)?)$/;
1201
- /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
1202
- 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})$/;
1203
- /** Returns a regex for validating an RFC 9562/4122 UUID.
1204
- *
1205
- * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
1206
- const uuid = (version) => {
1207
- if (!version) 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)$/;
1208
- 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})$`);
1209
- };
1210
- /** Practical email validation */
1211
- const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
1212
- const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1213
- function emoji() {
1214
- return new RegExp(_emoji$1, "u");
1215
- }
1216
- 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])$/;
1217
- 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}|:))$/;
1218
- 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])$/;
1219
- 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])$/;
1220
- const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
1221
- const base64url = /^[A-Za-z0-9_-]*$/;
1222
- const httpProtocol = /^https?$/;
1223
- const e164 = /^\+[1-9]\d{6,14}$/;
1224
- 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])))`;
1225
- const date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
1226
- function timeSource(args) {
1227
- const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
1228
- return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
1229
- }
1230
- function time$1(args) {
1231
- return new RegExp(`^${timeSource(args)}$`);
1232
- }
1233
- function datetime$1(args) {
1234
- const time = timeSource({ precision: args.precision });
1235
- const opts = ["Z"];
1236
- if (args.local) opts.push("");
1237
- if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
1238
- const timeRegex = `${time}(?:${opts.join("|")})`;
1239
- return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
1240
- }
1241
- const string$1 = (params) => {
1242
- const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
1243
- return new RegExp(`^${regex}$`);
1244
- };
1245
- const integer = /^-?\d+$/;
1246
- const number$1 = /^-?\d+(?:\.\d+)?$/;
1247
- const boolean$1 = /^(?:true|false)$/i;
1248
- const lowercase = /^[^A-Z]*$/;
1249
- const uppercase = /^[^a-z]*$/;
1250
- //#endregion
1251
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/checks.js
1252
- const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
1253
- var _a;
1254
- inst._zod ?? (inst._zod = {});
1255
- inst._zod.def = def;
1256
- (_a = inst._zod).onattach ?? (_a.onattach = []);
1257
- });
1258
- const numericOriginMap = {
1259
- number: "number",
1260
- bigint: "bigint",
1261
- object: "date"
1262
- };
1263
- const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
1264
- $ZodCheck.init(inst, def);
1265
- const origin = numericOriginMap[typeof def.value];
1266
- inst._zod.onattach.push((inst) => {
1267
- const bag = inst._zod.bag;
1268
- const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
1269
- if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
1270
- else bag.exclusiveMaximum = def.value;
1271
- });
1272
- inst._zod.check = (payload) => {
1273
- if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
1274
- payload.issues.push({
1275
- origin,
1276
- code: "too_big",
1277
- maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
1278
- input: payload.value,
1279
- inclusive: def.inclusive,
1280
- inst,
1281
- continue: !def.abort
1282
- });
1283
- };
1284
- });
1285
- const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
1286
- $ZodCheck.init(inst, def);
1287
- const origin = numericOriginMap[typeof def.value];
1288
- inst._zod.onattach.push((inst) => {
1289
- const bag = inst._zod.bag;
1290
- const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
1291
- if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
1292
- else bag.exclusiveMinimum = def.value;
1293
- });
1294
- inst._zod.check = (payload) => {
1295
- if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
1296
- payload.issues.push({
1297
- origin,
1298
- code: "too_small",
1299
- minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
1300
- input: payload.value,
1301
- inclusive: def.inclusive,
1302
- inst,
1303
- continue: !def.abort
1304
- });
1305
- };
1306
- });
1307
- const $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
1308
- $ZodCheck.init(inst, def);
1309
- inst._zod.onattach.push((inst) => {
1310
- var _a;
1311
- (_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
1312
- });
1313
- inst._zod.check = (payload) => {
1314
- if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
1315
- if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
1316
- payload.issues.push({
1317
- origin: typeof payload.value,
1318
- code: "not_multiple_of",
1319
- divisor: def.value,
1320
- input: payload.value,
1321
- inst,
1322
- continue: !def.abort
1323
- });
1324
- };
1325
- });
1326
- const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat", (inst, def) => {
1327
- $ZodCheck.init(inst, def);
1328
- def.format = def.format || "float64";
1329
- const isInt = def.format?.includes("int");
1330
- const origin = isInt ? "int" : "number";
1331
- const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
1332
- inst._zod.onattach.push((inst) => {
1333
- const bag = inst._zod.bag;
1334
- bag.format = def.format;
1335
- bag.minimum = minimum;
1336
- bag.maximum = maximum;
1337
- if (isInt) bag.pattern = integer;
1338
- });
1339
- inst._zod.check = (payload) => {
1340
- const input = payload.value;
1341
- if (isInt) {
1342
- if (!Number.isInteger(input)) {
1343
- payload.issues.push({
1344
- expected: origin,
1345
- format: def.format,
1346
- code: "invalid_type",
1347
- continue: false,
1348
- input,
1349
- inst
1350
- });
1351
- return;
1352
- }
1353
- if (!Number.isSafeInteger(input)) {
1354
- if (input > 0) payload.issues.push({
1355
- input,
1356
- code: "too_big",
1357
- maximum: Number.MAX_SAFE_INTEGER,
1358
- note: "Integers must be within the safe integer range.",
1359
- inst,
1360
- origin,
1361
- inclusive: true,
1362
- continue: !def.abort
1363
- });
1364
- else payload.issues.push({
1365
- input,
1366
- code: "too_small",
1367
- minimum: Number.MIN_SAFE_INTEGER,
1368
- note: "Integers must be within the safe integer range.",
1369
- inst,
1370
- origin,
1371
- inclusive: true,
1372
- continue: !def.abort
1373
- });
1374
- return;
1375
- }
1376
- }
1377
- if (input < minimum) payload.issues.push({
1378
- origin: "number",
1379
- input,
1380
- code: "too_small",
1381
- minimum,
1382
- inclusive: true,
1383
- inst,
1384
- continue: !def.abort
1385
- });
1386
- if (input > maximum) payload.issues.push({
1387
- origin: "number",
1388
- input,
1389
- code: "too_big",
1390
- maximum,
1391
- inclusive: true,
1392
- inst,
1393
- continue: !def.abort
1394
- });
1395
- };
1396
- });
1397
- const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
1398
- var _a;
1399
- $ZodCheck.init(inst, def);
1400
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1401
- const val = payload.value;
1402
- return !nullish(val) && val.length !== void 0;
1403
- });
1404
- inst._zod.onattach.push((inst) => {
1405
- const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
1406
- if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
1407
- });
1408
- inst._zod.check = (payload) => {
1409
- const input = payload.value;
1410
- if (input.length <= def.maximum) return;
1411
- const origin = getLengthableOrigin(input);
1412
- payload.issues.push({
1413
- origin,
1414
- code: "too_big",
1415
- maximum: def.maximum,
1416
- inclusive: true,
1417
- input,
1418
- inst,
1419
- continue: !def.abort
1420
- });
1421
- };
1422
- });
1423
- const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
1424
- var _a;
1425
- $ZodCheck.init(inst, def);
1426
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1427
- const val = payload.value;
1428
- return !nullish(val) && val.length !== void 0;
1429
- });
1430
- inst._zod.onattach.push((inst) => {
1431
- const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
1432
- if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
1433
- });
1434
- inst._zod.check = (payload) => {
1435
- const input = payload.value;
1436
- if (input.length >= def.minimum) return;
1437
- const origin = getLengthableOrigin(input);
1438
- payload.issues.push({
1439
- origin,
1440
- code: "too_small",
1441
- minimum: def.minimum,
1442
- inclusive: true,
1443
- input,
1444
- inst,
1445
- continue: !def.abort
1446
- });
1447
- };
1448
- });
1449
- const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
1450
- var _a;
1451
- $ZodCheck.init(inst, def);
1452
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1453
- const val = payload.value;
1454
- return !nullish(val) && val.length !== void 0;
1455
- });
1456
- inst._zod.onattach.push((inst) => {
1457
- const bag = inst._zod.bag;
1458
- bag.minimum = def.length;
1459
- bag.maximum = def.length;
1460
- bag.length = def.length;
1461
- });
1462
- inst._zod.check = (payload) => {
1463
- const input = payload.value;
1464
- const length = input.length;
1465
- if (length === def.length) return;
1466
- const origin = getLengthableOrigin(input);
1467
- const tooBig = length > def.length;
1468
- payload.issues.push({
1469
- origin,
1470
- ...tooBig ? {
1471
- code: "too_big",
1472
- maximum: def.length
1473
- } : {
1474
- code: "too_small",
1475
- minimum: def.length
1476
- },
1477
- inclusive: true,
1478
- exact: true,
1479
- input: payload.value,
1480
- inst,
1481
- continue: !def.abort
1482
- });
1483
- };
1484
- });
1485
- const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
1486
- var _a, _b;
1487
- $ZodCheck.init(inst, def);
1488
- inst._zod.onattach.push((inst) => {
1489
- const bag = inst._zod.bag;
1490
- bag.format = def.format;
1491
- if (def.pattern) {
1492
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1493
- bag.patterns.add(def.pattern);
1494
- }
1495
- });
1496
- if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
1497
- def.pattern.lastIndex = 0;
1498
- if (def.pattern.test(payload.value)) return;
1499
- payload.issues.push({
1500
- origin: "string",
1501
- code: "invalid_format",
1502
- format: def.format,
1503
- input: payload.value,
1504
- ...def.pattern ? { pattern: def.pattern.toString() } : {},
1505
- inst,
1506
- continue: !def.abort
1507
- });
1508
- });
1509
- else (_b = inst._zod).check ?? (_b.check = () => {});
1510
- });
1511
- const $ZodCheckRegex = /*@__PURE__*/ $constructor("$ZodCheckRegex", (inst, def) => {
1512
- $ZodCheckStringFormat.init(inst, def);
1513
- inst._zod.check = (payload) => {
1514
- def.pattern.lastIndex = 0;
1515
- if (def.pattern.test(payload.value)) return;
1516
- payload.issues.push({
1517
- origin: "string",
1518
- code: "invalid_format",
1519
- format: "regex",
1520
- input: payload.value,
1521
- pattern: def.pattern.toString(),
1522
- inst,
1523
- continue: !def.abort
1524
- });
1525
- };
1526
- });
1527
- const $ZodCheckLowerCase = /*@__PURE__*/ $constructor("$ZodCheckLowerCase", (inst, def) => {
1528
- def.pattern ?? (def.pattern = lowercase);
1529
- $ZodCheckStringFormat.init(inst, def);
1530
- });
1531
- const $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (inst, def) => {
1532
- def.pattern ?? (def.pattern = uppercase);
1533
- $ZodCheckStringFormat.init(inst, def);
1534
- });
1535
- const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
1536
- $ZodCheck.init(inst, def);
1537
- const escapedRegex = escapeRegex(def.includes);
1538
- const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
1539
- def.pattern = pattern;
1540
- inst._zod.onattach.push((inst) => {
1541
- const bag = inst._zod.bag;
1542
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1543
- bag.patterns.add(pattern);
1544
- });
1545
- inst._zod.check = (payload) => {
1546
- if (payload.value.includes(def.includes, def.position)) return;
1547
- payload.issues.push({
1548
- origin: "string",
1549
- code: "invalid_format",
1550
- format: "includes",
1551
- includes: def.includes,
1552
- input: payload.value,
1553
- inst,
1554
- continue: !def.abort
1555
- });
1556
- };
1557
- });
1558
- const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (inst, def) => {
1559
- $ZodCheck.init(inst, def);
1560
- const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
1561
- def.pattern ?? (def.pattern = pattern);
1562
- inst._zod.onattach.push((inst) => {
1563
- const bag = inst._zod.bag;
1564
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1565
- bag.patterns.add(pattern);
1566
- });
1567
- inst._zod.check = (payload) => {
1568
- if (payload.value.startsWith(def.prefix)) return;
1569
- payload.issues.push({
1570
- origin: "string",
1571
- code: "invalid_format",
1572
- format: "starts_with",
1573
- prefix: def.prefix,
1574
- input: payload.value,
1575
- inst,
1576
- continue: !def.abort
1577
- });
1578
- };
1579
- });
1580
- const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst, def) => {
1581
- $ZodCheck.init(inst, def);
1582
- const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
1583
- def.pattern ?? (def.pattern = pattern);
1584
- inst._zod.onattach.push((inst) => {
1585
- const bag = inst._zod.bag;
1586
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1587
- bag.patterns.add(pattern);
1588
- });
1589
- inst._zod.check = (payload) => {
1590
- if (payload.value.endsWith(def.suffix)) return;
1591
- payload.issues.push({
1592
- origin: "string",
1593
- code: "invalid_format",
1594
- format: "ends_with",
1595
- suffix: def.suffix,
1596
- input: payload.value,
1597
- inst,
1598
- continue: !def.abort
1599
- });
1600
- };
1601
- });
1602
- const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst, def) => {
1603
- $ZodCheck.init(inst, def);
1604
- inst._zod.check = (payload) => {
1605
- payload.value = def.tx(payload.value);
1606
- };
1607
- });
1608
- //#endregion
1609
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/doc.js
1610
- var Doc = class {
1611
- constructor(args = []) {
1612
- this.content = [];
1613
- this.indent = 0;
1614
- if (this) this.args = args;
1615
- }
1616
- indented(fn) {
1617
- this.indent += 1;
1618
- fn(this);
1619
- this.indent -= 1;
1620
- }
1621
- write(arg) {
1622
- if (typeof arg === "function") {
1623
- arg(this, { execution: "sync" });
1624
- arg(this, { execution: "async" });
1625
- return;
1626
- }
1627
- const lines = arg.split("\n").filter((x) => x);
1628
- const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
1629
- const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
1630
- for (const line of dedented) this.content.push(line);
1631
- }
1632
- compile() {
1633
- const F = Function;
1634
- const args = this?.args;
1635
- const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
1636
- return new F(...args, lines.join("\n"));
1637
- }
1638
- };
1639
- //#endregion
1640
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/versions.js
1641
- const version = {
1642
- major: 4,
1643
- minor: 4,
1644
- patch: 3
1645
- };
1646
- //#endregion
1647
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/schemas.js
1648
- const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1649
- var _a;
1650
- inst ?? (inst = {});
1651
- inst._zod.def = def;
1652
- inst._zod.bag = inst._zod.bag || {};
1653
- inst._zod.version = version;
1654
- const checks = [...inst._zod.def.checks ?? []];
1655
- if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
1656
- for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
1657
- if (checks.length === 0) {
1658
- (_a = inst._zod).deferred ?? (_a.deferred = []);
1659
- inst._zod.deferred?.push(() => {
1660
- inst._zod.run = inst._zod.parse;
1661
- });
1662
- } else {
1663
- const runChecks = (payload, checks, ctx) => {
1664
- let isAborted = aborted(payload);
1665
- let asyncResult;
1666
- for (const ch of checks) {
1667
- if (ch._zod.def.when) {
1668
- if (explicitlyAborted(payload)) continue;
1669
- if (!ch._zod.def.when(payload)) continue;
1670
- } else if (isAborted) continue;
1671
- const currLen = payload.issues.length;
1672
- const _ = ch._zod.check(payload);
1673
- if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
1674
- if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
1675
- await _;
1676
- if (payload.issues.length === currLen) return;
1677
- if (!isAborted) isAborted = aborted(payload, currLen);
1678
- });
1679
- else {
1680
- if (payload.issues.length === currLen) continue;
1681
- if (!isAborted) isAborted = aborted(payload, currLen);
1682
- }
1683
- }
1684
- if (asyncResult) return asyncResult.then(() => {
1685
- return payload;
1686
- });
1687
- return payload;
1688
- };
1689
- const handleCanaryResult = (canary, payload, ctx) => {
1690
- if (aborted(canary)) {
1691
- canary.aborted = true;
1692
- return canary;
1693
- }
1694
- const checkResult = runChecks(payload, checks, ctx);
1695
- if (checkResult instanceof Promise) {
1696
- if (ctx.async === false) throw new $ZodAsyncError();
1697
- return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
1698
- }
1699
- return inst._zod.parse(checkResult, ctx);
1700
- };
1701
- inst._zod.run = (payload, ctx) => {
1702
- if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
1703
- if (ctx.direction === "backward") {
1704
- const canary = inst._zod.parse({
1705
- value: payload.value,
1706
- issues: []
1707
- }, {
1708
- ...ctx,
1709
- skipChecks: true
1710
- });
1711
- if (canary instanceof Promise) return canary.then((canary) => {
1712
- return handleCanaryResult(canary, payload, ctx);
1713
- });
1714
- return handleCanaryResult(canary, payload, ctx);
1715
- }
1716
- const result = inst._zod.parse(payload, ctx);
1717
- if (result instanceof Promise) {
1718
- if (ctx.async === false) throw new $ZodAsyncError();
1719
- return result.then((result) => runChecks(result, checks, ctx));
1720
- }
1721
- return runChecks(result, checks, ctx);
1722
- };
1723
- }
1724
- defineLazy(inst, "~standard", () => ({
1725
- validate: (value) => {
1726
- try {
1727
- const r = safeParse$1(inst, value);
1728
- return r.success ? { value: r.data } : { issues: r.error?.issues };
1729
- } catch (_) {
1730
- return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
1731
- }
1732
- },
1733
- vendor: "zod",
1734
- version: 1
1735
- }));
1736
- });
1737
- const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
1738
- $ZodType.init(inst, def);
1739
- inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
1740
- inst._zod.parse = (payload, _) => {
1741
- if (def.coerce) try {
1742
- payload.value = String(payload.value);
1743
- } catch (_) {}
1744
- if (typeof payload.value === "string") return payload;
1745
- payload.issues.push({
1746
- expected: "string",
1747
- code: "invalid_type",
1748
- input: payload.value,
1749
- inst
1750
- });
1751
- return payload;
1752
- };
1753
- });
1754
- const $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (inst, def) => {
1755
- $ZodCheckStringFormat.init(inst, def);
1756
- $ZodString.init(inst, def);
1757
- });
1758
- const $ZodGUID = /*@__PURE__*/ $constructor("$ZodGUID", (inst, def) => {
1759
- def.pattern ?? (def.pattern = guid);
1760
- $ZodStringFormat.init(inst, def);
1761
- });
1762
- const $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (inst, def) => {
1763
- if (def.version) {
1764
- const v = {
1765
- v1: 1,
1766
- v2: 2,
1767
- v3: 3,
1768
- v4: 4,
1769
- v5: 5,
1770
- v6: 6,
1771
- v7: 7,
1772
- v8: 8
1773
- }[def.version];
1774
- if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
1775
- def.pattern ?? (def.pattern = uuid(v));
1776
- } else def.pattern ?? (def.pattern = uuid());
1777
- $ZodStringFormat.init(inst, def);
1778
- });
1779
- const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
1780
- def.pattern ?? (def.pattern = email);
1781
- $ZodStringFormat.init(inst, def);
1782
- });
1783
- const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
1784
- $ZodStringFormat.init(inst, def);
1785
- inst._zod.check = (payload) => {
1786
- try {
1787
- const trimmed = payload.value.trim();
1788
- if (!def.normalize && def.protocol?.source === httpProtocol.source) {
1789
- if (!/^https?:\/\//i.test(trimmed)) {
1790
- payload.issues.push({
1791
- code: "invalid_format",
1792
- format: "url",
1793
- note: "Invalid URL format",
1794
- input: payload.value,
1795
- inst,
1796
- continue: !def.abort
1797
- });
1798
- return;
1799
- }
1800
- }
1801
- const url = new URL(trimmed);
1802
- if (def.hostname) {
1803
- def.hostname.lastIndex = 0;
1804
- if (!def.hostname.test(url.hostname)) payload.issues.push({
1805
- code: "invalid_format",
1806
- format: "url",
1807
- note: "Invalid hostname",
1808
- pattern: def.hostname.source,
1809
- input: payload.value,
1810
- inst,
1811
- continue: !def.abort
1812
- });
1813
- }
1814
- if (def.protocol) {
1815
- def.protocol.lastIndex = 0;
1816
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
1817
- code: "invalid_format",
1818
- format: "url",
1819
- note: "Invalid protocol",
1820
- pattern: def.protocol.source,
1821
- input: payload.value,
1822
- inst,
1823
- continue: !def.abort
1824
- });
1825
- }
1826
- if (def.normalize) payload.value = url.href;
1827
- else payload.value = trimmed;
1828
- return;
1829
- } catch (_) {
1830
- payload.issues.push({
1831
- code: "invalid_format",
1832
- format: "url",
1833
- input: payload.value,
1834
- inst,
1835
- continue: !def.abort
1836
- });
1837
- }
1838
- };
1839
- });
1840
- const $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
1841
- def.pattern ?? (def.pattern = emoji());
1842
- $ZodStringFormat.init(inst, def);
1843
- });
1844
- const $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
1845
- def.pattern ?? (def.pattern = nanoid);
1846
- $ZodStringFormat.init(inst, def);
1847
- });
1848
- /**
1849
- * @deprecated CUID v1 is deprecated by its authors due to information leakage
1850
- * (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
1851
- * See https://github.com/paralleldrive/cuid.
1852
- */
1853
- const $ZodCUID = /*@__PURE__*/ $constructor("$ZodCUID", (inst, def) => {
1854
- def.pattern ?? (def.pattern = cuid);
1855
- $ZodStringFormat.init(inst, def);
1856
- });
1857
- const $ZodCUID2 = /*@__PURE__*/ $constructor("$ZodCUID2", (inst, def) => {
1858
- def.pattern ?? (def.pattern = cuid2);
1859
- $ZodStringFormat.init(inst, def);
1860
- });
1861
- const $ZodULID = /*@__PURE__*/ $constructor("$ZodULID", (inst, def) => {
1862
- def.pattern ?? (def.pattern = ulid);
1863
- $ZodStringFormat.init(inst, def);
1864
- });
1865
- const $ZodXID = /*@__PURE__*/ $constructor("$ZodXID", (inst, def) => {
1866
- def.pattern ?? (def.pattern = xid);
1867
- $ZodStringFormat.init(inst, def);
1868
- });
1869
- const $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
1870
- def.pattern ?? (def.pattern = ksuid);
1871
- $ZodStringFormat.init(inst, def);
1872
- });
1873
- const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
1874
- def.pattern ?? (def.pattern = datetime$1(def));
1875
- $ZodStringFormat.init(inst, def);
1876
- });
1877
- const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
1878
- def.pattern ?? (def.pattern = date$1);
1879
- $ZodStringFormat.init(inst, def);
1880
- });
1881
- const $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
1882
- def.pattern ?? (def.pattern = time$1(def));
1883
- $ZodStringFormat.init(inst, def);
1884
- });
1885
- const $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
1886
- def.pattern ?? (def.pattern = duration$1);
1887
- $ZodStringFormat.init(inst, def);
1888
- });
1889
- const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
1890
- def.pattern ?? (def.pattern = ipv4);
1891
- $ZodStringFormat.init(inst, def);
1892
- inst._zod.bag.format = `ipv4`;
1893
- });
1894
- const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
1895
- def.pattern ?? (def.pattern = ipv6);
1896
- $ZodStringFormat.init(inst, def);
1897
- inst._zod.bag.format = `ipv6`;
1898
- inst._zod.check = (payload) => {
1899
- try {
1900
- new URL(`http://[${payload.value}]`);
1901
- } catch {
1902
- payload.issues.push({
1903
- code: "invalid_format",
1904
- format: "ipv6",
1905
- input: payload.value,
1906
- inst,
1907
- continue: !def.abort
1908
- });
1909
- }
1910
- };
1911
- });
1912
- const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
1913
- def.pattern ?? (def.pattern = cidrv4);
1914
- $ZodStringFormat.init(inst, def);
1915
- });
1916
- const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
1917
- def.pattern ?? (def.pattern = cidrv6);
1918
- $ZodStringFormat.init(inst, def);
1919
- inst._zod.check = (payload) => {
1920
- const parts = payload.value.split("/");
1921
- try {
1922
- if (parts.length !== 2) throw new Error();
1923
- const [address, prefix] = parts;
1924
- if (!prefix) throw new Error();
1925
- const prefixNum = Number(prefix);
1926
- if (`${prefixNum}` !== prefix) throw new Error();
1927
- if (prefixNum < 0 || prefixNum > 128) throw new Error();
1928
- new URL(`http://[${address}]`);
1929
- } catch {
1930
- payload.issues.push({
1931
- code: "invalid_format",
1932
- format: "cidrv6",
1933
- input: payload.value,
1934
- inst,
1935
- continue: !def.abort
1936
- });
1937
- }
1938
- };
1939
- });
1940
- function isValidBase64(data) {
1941
- if (data === "") return true;
1942
- if (/\s/.test(data)) return false;
1943
- if (data.length % 4 !== 0) return false;
1944
- try {
1945
- atob(data);
1946
- return true;
1947
- } catch {
1948
- return false;
1949
- }
1950
- }
1951
- const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
1952
- def.pattern ?? (def.pattern = base64);
1953
- $ZodStringFormat.init(inst, def);
1954
- inst._zod.bag.contentEncoding = "base64";
1955
- inst._zod.check = (payload) => {
1956
- if (isValidBase64(payload.value)) return;
1957
- payload.issues.push({
1958
- code: "invalid_format",
1959
- format: "base64",
1960
- input: payload.value,
1961
- inst,
1962
- continue: !def.abort
1963
- });
1964
- };
1965
- });
1966
- function isValidBase64URL(data) {
1967
- if (!base64url.test(data)) return false;
1968
- const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1969
- return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
1970
- }
1971
- const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
1972
- def.pattern ?? (def.pattern = base64url);
1973
- $ZodStringFormat.init(inst, def);
1974
- inst._zod.bag.contentEncoding = "base64url";
1975
- inst._zod.check = (payload) => {
1976
- if (isValidBase64URL(payload.value)) return;
1977
- payload.issues.push({
1978
- code: "invalid_format",
1979
- format: "base64url",
1980
- input: payload.value,
1981
- inst,
1982
- continue: !def.abort
1983
- });
1984
- };
1985
- });
1986
- const $ZodE164 = /*@__PURE__*/ $constructor("$ZodE164", (inst, def) => {
1987
- def.pattern ?? (def.pattern = e164);
1988
- $ZodStringFormat.init(inst, def);
1989
- });
1990
- function isValidJWT(token, algorithm = null) {
1991
- try {
1992
- const tokensParts = token.split(".");
1993
- if (tokensParts.length !== 3) return false;
1994
- const [header] = tokensParts;
1995
- if (!header) return false;
1996
- const parsedHeader = JSON.parse(atob(header));
1997
- if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
1998
- if (!parsedHeader.alg) return false;
1999
- if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
2000
- return true;
2001
- } catch {
2002
- return false;
2003
- }
2004
- }
2005
- const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
2006
- $ZodStringFormat.init(inst, def);
2007
- inst._zod.check = (payload) => {
2008
- if (isValidJWT(payload.value, def.alg)) return;
2009
- payload.issues.push({
2010
- code: "invalid_format",
2011
- format: "jwt",
2012
- input: payload.value,
2013
- inst,
2014
- continue: !def.abort
2015
- });
2016
- };
2017
- });
2018
- const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
2019
- $ZodType.init(inst, def);
2020
- inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
2021
- inst._zod.parse = (payload, _ctx) => {
2022
- if (def.coerce) try {
2023
- payload.value = Number(payload.value);
2024
- } catch (_) {}
2025
- const input = payload.value;
2026
- if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
2027
- const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
2028
- payload.issues.push({
2029
- expected: "number",
2030
- code: "invalid_type",
2031
- input,
2032
- inst,
2033
- ...received ? { received } : {}
2034
- });
2035
- return payload;
2036
- };
2037
- });
2038
- const $ZodNumberFormat = /*@__PURE__*/ $constructor("$ZodNumberFormat", (inst, def) => {
2039
- $ZodCheckNumberFormat.init(inst, def);
2040
- $ZodNumber.init(inst, def);
2041
- });
2042
- const $ZodBoolean = /*@__PURE__*/ $constructor("$ZodBoolean", (inst, def) => {
2043
- $ZodType.init(inst, def);
2044
- inst._zod.pattern = boolean$1;
2045
- inst._zod.parse = (payload, _ctx) => {
2046
- if (def.coerce) try {
2047
- payload.value = Boolean(payload.value);
2048
- } catch (_) {}
2049
- const input = payload.value;
2050
- if (typeof input === "boolean") return payload;
2051
- payload.issues.push({
2052
- expected: "boolean",
2053
- code: "invalid_type",
2054
- input,
2055
- inst
2056
- });
2057
- return payload;
2058
- };
2059
- });
2060
- const $ZodUnknown = /*@__PURE__*/ $constructor("$ZodUnknown", (inst, def) => {
2061
- $ZodType.init(inst, def);
2062
- inst._zod.parse = (payload) => payload;
2063
- });
2064
- const $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (inst, def) => {
2065
- $ZodType.init(inst, def);
2066
- inst._zod.parse = (payload, _ctx) => {
2067
- payload.issues.push({
2068
- expected: "never",
2069
- code: "invalid_type",
2070
- input: payload.value,
2071
- inst
2072
- });
2073
- return payload;
2074
- };
2075
- });
2076
- function handleArrayResult(result, final, index) {
2077
- if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
2078
- final.value[index] = result.value;
2079
- }
2080
- const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
2081
- $ZodType.init(inst, def);
2082
- inst._zod.parse = (payload, ctx) => {
2083
- const input = payload.value;
2084
- if (!Array.isArray(input)) {
2085
- payload.issues.push({
2086
- expected: "array",
2087
- code: "invalid_type",
2088
- input,
2089
- inst
2090
- });
2091
- return payload;
2092
- }
2093
- payload.value = Array(input.length);
2094
- const proms = [];
2095
- for (let i = 0; i < input.length; i++) {
2096
- const item = input[i];
2097
- const result = def.element._zod.run({
2098
- value: item,
2099
- issues: []
2100
- }, ctx);
2101
- if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
2102
- else handleArrayResult(result, payload, i);
2103
- }
2104
- if (proms.length) return Promise.all(proms).then(() => payload);
2105
- return payload;
2106
- };
2107
- });
2108
- function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
2109
- const isPresent = key in input;
2110
- if (result.issues.length) {
2111
- if (isOptionalIn && isOptionalOut && !isPresent) return;
2112
- final.issues.push(...prefixIssues(key, result.issues));
2113
- }
2114
- if (!isPresent && !isOptionalIn) {
2115
- if (!result.issues.length) final.issues.push({
2116
- code: "invalid_type",
2117
- expected: "nonoptional",
2118
- input: void 0,
2119
- path: [key]
2120
- });
2121
- return;
2122
- }
2123
- if (result.value === void 0) {
2124
- if (isPresent) final.value[key] = void 0;
2125
- } else final.value[key] = result.value;
2126
- }
2127
- function normalizeDef(def) {
2128
- const keys = Object.keys(def.shape);
2129
- for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
2130
- const okeys = optionalKeys(def.shape);
2131
- return {
2132
- ...def,
2133
- keys,
2134
- keySet: new Set(keys),
2135
- numKeys: keys.length,
2136
- optionalKeys: new Set(okeys)
2137
- };
2138
- }
2139
- function handleCatchall(proms, input, payload, ctx, def, inst) {
2140
- const unrecognized = [];
2141
- const keySet = def.keySet;
2142
- const _catchall = def.catchall._zod;
2143
- const t = _catchall.def.type;
2144
- const isOptionalIn = _catchall.optin === "optional";
2145
- const isOptionalOut = _catchall.optout === "optional";
2146
- for (const key in input) {
2147
- if (key === "__proto__") continue;
2148
- if (keySet.has(key)) continue;
2149
- if (t === "never") {
2150
- unrecognized.push(key);
2151
- continue;
2152
- }
2153
- const r = _catchall.run({
2154
- value: input[key],
2155
- issues: []
2156
- }, ctx);
2157
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
2158
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
2159
- }
2160
- if (unrecognized.length) payload.issues.push({
2161
- code: "unrecognized_keys",
2162
- keys: unrecognized,
2163
- input,
2164
- inst
2165
- });
2166
- if (!proms.length) return payload;
2167
- return Promise.all(proms).then(() => {
2168
- return payload;
2169
- });
2170
- }
2171
- const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
2172
- $ZodType.init(inst, def);
2173
- if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
2174
- const sh = def.shape;
2175
- Object.defineProperty(def, "shape", { get: () => {
2176
- const newSh = { ...sh };
2177
- Object.defineProperty(def, "shape", { value: newSh });
2178
- return newSh;
2179
- } });
2180
- }
2181
- const _normalized = cached(() => normalizeDef(def));
2182
- defineLazy(inst._zod, "propValues", () => {
2183
- const shape = def.shape;
2184
- const propValues = {};
2185
- for (const key in shape) {
2186
- const field = shape[key]._zod;
2187
- if (field.values) {
2188
- propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
2189
- for (const v of field.values) propValues[key].add(v);
2190
- }
2191
- }
2192
- return propValues;
2193
- });
2194
- const isObject$1 = isObject;
2195
- const catchall = def.catchall;
2196
- let value;
2197
- inst._zod.parse = (payload, ctx) => {
2198
- value ?? (value = _normalized.value);
2199
- const input = payload.value;
2200
- if (!isObject$1(input)) {
2201
- payload.issues.push({
2202
- expected: "object",
2203
- code: "invalid_type",
2204
- input,
2205
- inst
2206
- });
2207
- return payload;
2208
- }
2209
- payload.value = {};
2210
- const proms = [];
2211
- const shape = value.shape;
2212
- for (const key of value.keys) {
2213
- const el = shape[key];
2214
- const isOptionalIn = el._zod.optin === "optional";
2215
- const isOptionalOut = el._zod.optout === "optional";
2216
- const r = el._zod.run({
2217
- value: input[key],
2218
- issues: []
2219
- }, ctx);
2220
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
2221
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
2222
- }
2223
- if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
2224
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
2225
- };
2226
- });
2227
- const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
2228
- $ZodObject.init(inst, def);
2229
- const superParse = inst._zod.parse;
2230
- const _normalized = cached(() => normalizeDef(def));
2231
- const generateFastpass = (shape) => {
2232
- const doc = new Doc([
2233
- "shape",
2234
- "payload",
2235
- "ctx"
2236
- ]);
2237
- const normalized = _normalized.value;
2238
- const parseStr = (key) => {
2239
- const k = esc(key);
2240
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
2241
- };
2242
- doc.write(`const input = payload.value;`);
2243
- const ids = Object.create(null);
2244
- let counter = 0;
2245
- for (const key of normalized.keys) ids[key] = `key_${counter++}`;
2246
- doc.write(`const newResult = {};`);
2247
- for (const key of normalized.keys) {
2248
- const id = ids[key];
2249
- const k = esc(key);
2250
- const schema = shape[key];
2251
- const isOptionalIn = schema?._zod?.optin === "optional";
2252
- const isOptionalOut = schema?._zod?.optout === "optional";
2253
- doc.write(`const ${id} = ${parseStr(key)};`);
2254
- if (isOptionalIn && isOptionalOut) doc.write(`
2255
- if (${id}.issues.length) {
2256
- if (${k} in input) {
2257
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2258
- ...iss,
2259
- path: iss.path ? [${k}, ...iss.path] : [${k}]
2260
- })));
2261
- }
2262
- }
2263
-
2264
- if (${id}.value === undefined) {
2265
- if (${k} in input) {
2266
- newResult[${k}] = undefined;
2267
- }
2268
- } else {
2269
- newResult[${k}] = ${id}.value;
2270
- }
2271
-
2272
- `);
2273
- else if (!isOptionalIn) doc.write(`
2274
- const ${id}_present = ${k} in input;
2275
- if (${id}.issues.length) {
2276
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2277
- ...iss,
2278
- path: iss.path ? [${k}, ...iss.path] : [${k}]
2279
- })));
2280
- }
2281
- if (!${id}_present && !${id}.issues.length) {
2282
- payload.issues.push({
2283
- code: "invalid_type",
2284
- expected: "nonoptional",
2285
- input: undefined,
2286
- path: [${k}]
2287
- });
2288
- }
2289
-
2290
- if (${id}_present) {
2291
- if (${id}.value === undefined) {
2292
- newResult[${k}] = undefined;
2293
- } else {
2294
- newResult[${k}] = ${id}.value;
2295
- }
2296
- }
2297
-
2298
- `);
2299
- else doc.write(`
2300
- if (${id}.issues.length) {
2301
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2302
- ...iss,
2303
- path: iss.path ? [${k}, ...iss.path] : [${k}]
2304
- })));
2305
- }
2306
-
2307
- if (${id}.value === undefined) {
2308
- if (${k} in input) {
2309
- newResult[${k}] = undefined;
2310
- }
2311
- } else {
2312
- newResult[${k}] = ${id}.value;
2313
- }
2314
-
2315
- `);
2316
- }
2317
- doc.write(`payload.value = newResult;`);
2318
- doc.write(`return payload;`);
2319
- const fn = doc.compile();
2320
- return (payload, ctx) => fn(shape, payload, ctx);
2321
- };
2322
- let fastpass;
2323
- const isObject$2 = isObject;
2324
- const jit = !globalConfig.jitless;
2325
- const fastEnabled = jit && allowsEval.value;
2326
- const catchall = def.catchall;
2327
- let value;
2328
- inst._zod.parse = (payload, ctx) => {
2329
- value ?? (value = _normalized.value);
2330
- const input = payload.value;
2331
- if (!isObject$2(input)) {
2332
- payload.issues.push({
2333
- expected: "object",
2334
- code: "invalid_type",
2335
- input,
2336
- inst
2337
- });
2338
- return payload;
2339
- }
2340
- if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
2341
- if (!fastpass) fastpass = generateFastpass(def.shape);
2342
- payload = fastpass(payload, ctx);
2343
- if (!catchall) return payload;
2344
- return handleCatchall([], input, payload, ctx, value, inst);
2345
- }
2346
- return superParse(payload, ctx);
2347
- };
2348
- });
2349
- function handleUnionResults(results, final, inst, ctx) {
2350
- for (const result of results) if (result.issues.length === 0) {
2351
- final.value = result.value;
2352
- return final;
2353
- }
2354
- const nonaborted = results.filter((r) => !aborted(r));
2355
- if (nonaborted.length === 1) {
2356
- final.value = nonaborted[0].value;
2357
- return nonaborted[0];
2358
- }
2359
- final.issues.push({
2360
- code: "invalid_union",
2361
- input: final.value,
2362
- inst,
2363
- errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
2364
- });
2365
- return final;
2366
- }
2367
- const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
2368
- $ZodType.init(inst, def);
2369
- defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
2370
- defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
2371
- defineLazy(inst._zod, "values", () => {
2372
- if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
2373
- });
2374
- defineLazy(inst._zod, "pattern", () => {
2375
- if (def.options.every((o) => o._zod.pattern)) {
2376
- const patterns = def.options.map((o) => o._zod.pattern);
2377
- return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
2378
- }
2379
- });
2380
- const first = def.options.length === 1 ? def.options[0]._zod.run : null;
2381
- inst._zod.parse = (payload, ctx) => {
2382
- if (first) return first(payload, ctx);
2383
- let async = false;
2384
- const results = [];
2385
- for (const option of def.options) {
2386
- const result = option._zod.run({
2387
- value: payload.value,
2388
- issues: []
2389
- }, ctx);
2390
- if (result instanceof Promise) {
2391
- results.push(result);
2392
- async = true;
2393
- } else {
2394
- if (result.issues.length === 0) return result;
2395
- results.push(result);
2396
- }
2397
- }
2398
- if (!async) return handleUnionResults(results, payload, inst, ctx);
2399
- return Promise.all(results).then((results) => {
2400
- return handleUnionResults(results, payload, inst, ctx);
2401
- });
2402
- };
2403
- });
2404
- const $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
2405
- def.inclusive = false;
2406
- $ZodUnion.init(inst, def);
2407
- const _super = inst._zod.parse;
2408
- defineLazy(inst._zod, "propValues", () => {
2409
- const propValues = {};
2410
- for (const option of def.options) {
2411
- const pv = option._zod.propValues;
2412
- if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
2413
- for (const [k, v] of Object.entries(pv)) {
2414
- if (!propValues[k]) propValues[k] = /* @__PURE__ */ new Set();
2415
- for (const val of v) propValues[k].add(val);
2416
- }
2417
- }
2418
- return propValues;
2419
- });
2420
- const disc = cached(() => {
2421
- const opts = def.options;
2422
- const map = /* @__PURE__ */ new Map();
2423
- for (const o of opts) {
2424
- const values = o._zod.propValues?.[def.discriminator];
2425
- if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
2426
- for (const v of values) {
2427
- if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
2428
- map.set(v, o);
2429
- }
2430
- }
2431
- return map;
2432
- });
2433
- inst._zod.parse = (payload, ctx) => {
2434
- const input = payload.value;
2435
- if (!isObject(input)) {
2436
- payload.issues.push({
2437
- code: "invalid_type",
2438
- expected: "object",
2439
- input,
2440
- inst
2441
- });
2442
- return payload;
2443
- }
2444
- const opt = disc.value.get(input?.[def.discriminator]);
2445
- if (opt) return opt._zod.run(payload, ctx);
2446
- if (def.unionFallback || ctx.direction === "backward") return _super(payload, ctx);
2447
- payload.issues.push({
2448
- code: "invalid_union",
2449
- errors: [],
2450
- note: "No matching discriminator",
2451
- discriminator: def.discriminator,
2452
- options: Array.from(disc.value.keys()),
2453
- input,
2454
- path: [def.discriminator],
2455
- inst
2456
- });
2457
- return payload;
2458
- };
2459
- });
2460
- const $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def) => {
2461
- $ZodType.init(inst, def);
2462
- inst._zod.parse = (payload, ctx) => {
2463
- const input = payload.value;
2464
- const left = def.left._zod.run({
2465
- value: input,
2466
- issues: []
2467
- }, ctx);
2468
- const right = def.right._zod.run({
2469
- value: input,
2470
- issues: []
2471
- }, ctx);
2472
- if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left, right]) => {
2473
- return handleIntersectionResults(payload, left, right);
2474
- });
2475
- return handleIntersectionResults(payload, left, right);
2476
- };
2477
- });
2478
- function mergeValues(a, b) {
2479
- if (a === b) return {
2480
- valid: true,
2481
- data: a
2482
- };
2483
- if (a instanceof Date && b instanceof Date && +a === +b) return {
2484
- valid: true,
2485
- data: a
2486
- };
2487
- if (isPlainObject(a) && isPlainObject(b)) {
2488
- const bKeys = Object.keys(b);
2489
- const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
2490
- const newObj = {
2491
- ...a,
2492
- ...b
2493
- };
2494
- for (const key of sharedKeys) {
2495
- const sharedValue = mergeValues(a[key], b[key]);
2496
- if (!sharedValue.valid) return {
2497
- valid: false,
2498
- mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
2499
- };
2500
- newObj[key] = sharedValue.data;
2501
- }
2502
- return {
2503
- valid: true,
2504
- data: newObj
2505
- };
2506
- }
2507
- if (Array.isArray(a) && Array.isArray(b)) {
2508
- if (a.length !== b.length) return {
2509
- valid: false,
2510
- mergeErrorPath: []
2511
- };
2512
- const newArray = [];
2513
- for (let index = 0; index < a.length; index++) {
2514
- const itemA = a[index];
2515
- const itemB = b[index];
2516
- const sharedValue = mergeValues(itemA, itemB);
2517
- if (!sharedValue.valid) return {
2518
- valid: false,
2519
- mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
2520
- };
2521
- newArray.push(sharedValue.data);
2522
- }
2523
- return {
2524
- valid: true,
2525
- data: newArray
2526
- };
2527
- }
2528
- return {
2529
- valid: false,
2530
- mergeErrorPath: []
2531
- };
2532
- }
2533
- function handleIntersectionResults(result, left, right) {
2534
- const unrecKeys = /* @__PURE__ */ new Map();
2535
- let unrecIssue;
2536
- for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
2537
- unrecIssue ?? (unrecIssue = iss);
2538
- for (const k of iss.keys) {
2539
- if (!unrecKeys.has(k)) unrecKeys.set(k, {});
2540
- unrecKeys.get(k).l = true;
2541
- }
2542
- } else result.issues.push(iss);
2543
- for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
2544
- if (!unrecKeys.has(k)) unrecKeys.set(k, {});
2545
- unrecKeys.get(k).r = true;
2546
- }
2547
- else result.issues.push(iss);
2548
- const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
2549
- if (bothKeys.length && unrecIssue) result.issues.push({
2550
- ...unrecIssue,
2551
- keys: bothKeys
2552
- });
2553
- if (aborted(result)) return result;
2554
- const merged = mergeValues(left.value, right.value);
2555
- if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
2556
- result.value = merged.data;
2557
- return result;
2558
- }
2559
- const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
2560
- $ZodType.init(inst, def);
2561
- inst._zod.parse = (payload, ctx) => {
2562
- const input = payload.value;
2563
- if (!isPlainObject(input)) {
2564
- payload.issues.push({
2565
- expected: "record",
2566
- code: "invalid_type",
2567
- input,
2568
- inst
2569
- });
2570
- return payload;
2571
- }
2572
- const proms = [];
2573
- const values = def.keyType._zod.values;
2574
- if (values) {
2575
- payload.value = {};
2576
- const recordKeys = /* @__PURE__ */ new Set();
2577
- for (const key of values) if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
2578
- recordKeys.add(typeof key === "number" ? key.toString() : key);
2579
- const keyResult = def.keyType._zod.run({
2580
- value: key,
2581
- issues: []
2582
- }, ctx);
2583
- if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
2584
- if (keyResult.issues.length) {
2585
- payload.issues.push({
2586
- code: "invalid_key",
2587
- origin: "record",
2588
- issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
2589
- input: key,
2590
- path: [key],
2591
- inst
2592
- });
2593
- continue;
2594
- }
2595
- const outKey = keyResult.value;
2596
- const result = def.valueType._zod.run({
2597
- value: input[key],
2598
- issues: []
2599
- }, ctx);
2600
- if (result instanceof Promise) proms.push(result.then((result) => {
2601
- if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
2602
- payload.value[outKey] = result.value;
2603
- }));
2604
- else {
2605
- if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
2606
- payload.value[outKey] = result.value;
2607
- }
2608
- }
2609
- let unrecognized;
2610
- for (const key in input) if (!recordKeys.has(key)) {
2611
- unrecognized = unrecognized ?? [];
2612
- unrecognized.push(key);
2613
- }
2614
- if (unrecognized && unrecognized.length > 0) payload.issues.push({
2615
- code: "unrecognized_keys",
2616
- input,
2617
- inst,
2618
- keys: unrecognized
2619
- });
2620
- } else {
2621
- payload.value = {};
2622
- for (const key of Reflect.ownKeys(input)) {
2623
- if (key === "__proto__") continue;
2624
- if (!Object.prototype.propertyIsEnumerable.call(input, key)) continue;
2625
- let keyResult = def.keyType._zod.run({
2626
- value: key,
2627
- issues: []
2628
- }, ctx);
2629
- if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
2630
- if (typeof key === "string" && number$1.test(key) && keyResult.issues.length) {
2631
- const retryResult = def.keyType._zod.run({
2632
- value: Number(key),
2633
- issues: []
2634
- }, ctx);
2635
- if (retryResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
2636
- if (retryResult.issues.length === 0) keyResult = retryResult;
2637
- }
2638
- if (keyResult.issues.length) {
2639
- if (def.mode === "loose") payload.value[key] = input[key];
2640
- else payload.issues.push({
2641
- code: "invalid_key",
2642
- origin: "record",
2643
- issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
2644
- input: key,
2645
- path: [key],
2646
- inst
2647
- });
2648
- continue;
2649
- }
2650
- const result = def.valueType._zod.run({
2651
- value: input[key],
2652
- issues: []
2653
- }, ctx);
2654
- if (result instanceof Promise) proms.push(result.then((result) => {
2655
- if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
2656
- payload.value[keyResult.value] = result.value;
2657
- }));
2658
- else {
2659
- if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
2660
- payload.value[keyResult.value] = result.value;
2661
- }
2662
- }
2663
- }
2664
- if (proms.length) return Promise.all(proms).then(() => payload);
2665
- return payload;
2666
- };
2667
- });
2668
- const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
2669
- $ZodType.init(inst, def);
2670
- const values = getEnumValues(def.entries);
2671
- const valuesSet = new Set(values);
2672
- inst._zod.values = valuesSet;
2673
- inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
2674
- inst._zod.parse = (payload, _ctx) => {
2675
- const input = payload.value;
2676
- if (valuesSet.has(input)) return payload;
2677
- payload.issues.push({
2678
- code: "invalid_value",
2679
- values,
2680
- input,
2681
- inst
2682
- });
2683
- return payload;
2684
- };
2685
- });
2686
- const $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
2687
- $ZodType.init(inst, def);
2688
- if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
2689
- const values = new Set(def.values);
2690
- inst._zod.values = values;
2691
- inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
2692
- inst._zod.parse = (payload, _ctx) => {
2693
- const input = payload.value;
2694
- if (values.has(input)) return payload;
2695
- payload.issues.push({
2696
- code: "invalid_value",
2697
- values: def.values,
2698
- input,
2699
- inst
2700
- });
2701
- return payload;
2702
- };
2703
- });
2704
- const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
2705
- $ZodType.init(inst, def);
2706
- inst._zod.optin = "optional";
2707
- inst._zod.parse = (payload, ctx) => {
2708
- if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
2709
- const _out = def.transform(payload.value, payload);
2710
- if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
2711
- payload.value = output;
2712
- payload.fallback = true;
2713
- return payload;
2714
- });
2715
- if (_out instanceof Promise) throw new $ZodAsyncError();
2716
- payload.value = _out;
2717
- payload.fallback = true;
2718
- return payload;
2719
- };
2720
- });
2721
- function handleOptionalResult(result, input) {
2722
- if (input === void 0 && (result.issues.length || result.fallback)) return {
2723
- issues: [],
2724
- value: void 0
2725
- };
2726
- return result;
2727
- }
2728
- const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
2729
- $ZodType.init(inst, def);
2730
- inst._zod.optin = "optional";
2731
- inst._zod.optout = "optional";
2732
- defineLazy(inst._zod, "values", () => {
2733
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
2734
- });
2735
- defineLazy(inst._zod, "pattern", () => {
2736
- const pattern = def.innerType._zod.pattern;
2737
- return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
2738
- });
2739
- inst._zod.parse = (payload, ctx) => {
2740
- if (def.innerType._zod.optin === "optional") {
2741
- const input = payload.value;
2742
- const result = def.innerType._zod.run(payload, ctx);
2743
- if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
2744
- return handleOptionalResult(result, input);
2745
- }
2746
- if (payload.value === void 0) return payload;
2747
- return def.innerType._zod.run(payload, ctx);
2748
- };
2749
- });
2750
- const $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
2751
- $ZodOptional.init(inst, def);
2752
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2753
- defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2754
- inst._zod.parse = (payload, ctx) => {
2755
- return def.innerType._zod.run(payload, ctx);
2756
- };
2757
- });
2758
- const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
2759
- $ZodType.init(inst, def);
2760
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2761
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2762
- defineLazy(inst._zod, "pattern", () => {
2763
- const pattern = def.innerType._zod.pattern;
2764
- return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
2765
- });
2766
- defineLazy(inst._zod, "values", () => {
2767
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
2768
- });
2769
- inst._zod.parse = (payload, ctx) => {
2770
- if (payload.value === null) return payload;
2771
- return def.innerType._zod.run(payload, ctx);
2772
- };
2773
- });
2774
- const $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
2775
- $ZodType.init(inst, def);
2776
- inst._zod.optin = "optional";
2777
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2778
- inst._zod.parse = (payload, ctx) => {
2779
- if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2780
- if (payload.value === void 0) {
2781
- payload.value = def.defaultValue;
2782
- /**
2783
- * $ZodDefault returns the default value immediately in forward direction.
2784
- * 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. */
2785
- return payload;
2786
- }
2787
- const result = def.innerType._zod.run(payload, ctx);
2788
- if (result instanceof Promise) return result.then((result) => handleDefaultResult(result, def));
2789
- return handleDefaultResult(result, def);
2790
- };
2791
- });
2792
- function handleDefaultResult(payload, def) {
2793
- if (payload.value === void 0) payload.value = def.defaultValue;
2794
- return payload;
2795
- }
2796
- const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
2797
- $ZodType.init(inst, def);
2798
- inst._zod.optin = "optional";
2799
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2800
- inst._zod.parse = (payload, ctx) => {
2801
- if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2802
- if (payload.value === void 0) payload.value = def.defaultValue;
2803
- return def.innerType._zod.run(payload, ctx);
2804
- };
2805
- });
2806
- const $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
2807
- $ZodType.init(inst, def);
2808
- defineLazy(inst._zod, "values", () => {
2809
- const v = def.innerType._zod.values;
2810
- return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
2811
- });
2812
- inst._zod.parse = (payload, ctx) => {
2813
- const result = def.innerType._zod.run(payload, ctx);
2814
- if (result instanceof Promise) return result.then((result) => handleNonOptionalResult(result, inst));
2815
- return handleNonOptionalResult(result, inst);
2816
- };
2817
- });
2818
- function handleNonOptionalResult(payload, inst) {
2819
- if (!payload.issues.length && payload.value === void 0) payload.issues.push({
2820
- code: "invalid_type",
2821
- expected: "nonoptional",
2822
- input: payload.value,
2823
- inst
2824
- });
2825
- return payload;
2826
- }
2827
- const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
2828
- $ZodType.init(inst, def);
2829
- inst._zod.optin = "optional";
2830
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2831
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2832
- inst._zod.parse = (payload, ctx) => {
2833
- if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2834
- const result = def.innerType._zod.run(payload, ctx);
2835
- if (result instanceof Promise) return result.then((result) => {
2836
- payload.value = result.value;
2837
- if (result.issues.length) {
2838
- payload.value = def.catchValue({
2839
- ...payload,
2840
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2841
- input: payload.value
2842
- });
2843
- payload.issues = [];
2844
- payload.fallback = true;
2845
- }
2846
- return payload;
2847
- });
2848
- payload.value = result.value;
2849
- if (result.issues.length) {
2850
- payload.value = def.catchValue({
2851
- ...payload,
2852
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2853
- input: payload.value
2854
- });
2855
- payload.issues = [];
2856
- payload.fallback = true;
2857
- }
2858
- return payload;
2859
- };
2860
- });
2861
- const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2862
- $ZodType.init(inst, def);
2863
- defineLazy(inst._zod, "values", () => def.in._zod.values);
2864
- defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2865
- defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2866
- defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2867
- inst._zod.parse = (payload, ctx) => {
2868
- if (ctx.direction === "backward") {
2869
- const right = def.out._zod.run(payload, ctx);
2870
- if (right instanceof Promise) return right.then((right) => handlePipeResult(right, def.in, ctx));
2871
- return handlePipeResult(right, def.in, ctx);
2872
- }
2873
- const left = def.in._zod.run(payload, ctx);
2874
- if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def.out, ctx));
2875
- return handlePipeResult(left, def.out, ctx);
2876
- };
2877
- });
2878
- function handlePipeResult(left, next, ctx) {
2879
- if (left.issues.length) {
2880
- left.aborted = true;
2881
- return left;
2882
- }
2883
- return next._zod.run({
2884
- value: left.value,
2885
- issues: left.issues,
2886
- fallback: left.fallback
2887
- }, ctx);
2888
- }
2889
- const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2890
- $ZodType.init(inst, def);
2891
- defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2892
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2893
- defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2894
- defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2895
- inst._zod.parse = (payload, ctx) => {
2896
- if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2897
- const result = def.innerType._zod.run(payload, ctx);
2898
- if (result instanceof Promise) return result.then(handleReadonlyResult);
2899
- return handleReadonlyResult(result);
2900
- };
2901
- });
2902
- function handleReadonlyResult(payload) {
2903
- payload.value = Object.freeze(payload.value);
2904
- return payload;
2905
- }
2906
- const $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
2907
- $ZodCheck.init(inst, def);
2908
- $ZodType.init(inst, def);
2909
- inst._zod.parse = (payload, _) => {
2910
- return payload;
2911
- };
2912
- inst._zod.check = (payload) => {
2913
- const input = payload.value;
2914
- const r = def.fn(input);
2915
- if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
2916
- handleRefineResult(r, payload, input, inst);
2917
- };
2918
- });
2919
- function handleRefineResult(result, payload, input, inst) {
2920
- if (!result) {
2921
- const _iss = {
2922
- code: "custom",
2923
- input,
2924
- inst,
2925
- path: [...inst._zod.def.path ?? []],
2926
- continue: !inst._zod.def.abort
2927
- };
2928
- if (inst._zod.def.params) _iss.params = inst._zod.def.params;
2929
- payload.issues.push(issue(_iss));
2930
- }
2931
- }
2932
- //#endregion
2933
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/registries.js
2934
- var _a;
2935
- var $ZodRegistry = class {
2936
- constructor() {
2937
- this._map = /* @__PURE__ */ new WeakMap();
2938
- this._idmap = /* @__PURE__ */ new Map();
2939
- }
2940
- add(schema, ..._meta) {
2941
- const meta = _meta[0];
2942
- this._map.set(schema, meta);
2943
- if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
2944
- return this;
2945
- }
2946
- clear() {
2947
- this._map = /* @__PURE__ */ new WeakMap();
2948
- this._idmap = /* @__PURE__ */ new Map();
2949
- return this;
2950
- }
2951
- remove(schema) {
2952
- const meta = this._map.get(schema);
2953
- if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
2954
- this._map.delete(schema);
2955
- return this;
2956
- }
2957
- get(schema) {
2958
- const p = schema._zod.parent;
2959
- if (p) {
2960
- const pm = { ...this.get(p) ?? {} };
2961
- delete pm.id;
2962
- const f = {
2963
- ...pm,
2964
- ...this._map.get(schema)
2965
- };
2966
- return Object.keys(f).length ? f : void 0;
2967
- }
2968
- return this._map.get(schema);
2969
- }
2970
- has(schema) {
2971
- return this._map.has(schema);
2972
- }
2973
- };
2974
- function registry() {
2975
- return new $ZodRegistry();
2976
- }
2977
- (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2978
- const globalRegistry = globalThis.__zod_globalRegistry;
2979
- //#endregion
2980
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/api.js
2981
- // @__NO_SIDE_EFFECTS__
2982
- function _string(Class, params) {
2983
- return new Class({
2984
- type: "string",
2985
- ...normalizeParams(params)
2986
- });
2987
- }
2988
- // @__NO_SIDE_EFFECTS__
2989
- function _email(Class, params) {
2990
- return new Class({
2991
- type: "string",
2992
- format: "email",
2993
- check: "string_format",
2994
- abort: false,
2995
- ...normalizeParams(params)
2996
- });
2997
- }
2998
- // @__NO_SIDE_EFFECTS__
2999
- function _guid(Class, params) {
3000
- return new Class({
3001
- type: "string",
3002
- format: "guid",
3003
- check: "string_format",
3004
- abort: false,
3005
- ...normalizeParams(params)
3006
- });
3007
- }
3008
- // @__NO_SIDE_EFFECTS__
3009
- function _uuid(Class, params) {
3010
- return new Class({
3011
- type: "string",
3012
- format: "uuid",
3013
- check: "string_format",
3014
- abort: false,
3015
- ...normalizeParams(params)
3016
- });
3017
- }
3018
- // @__NO_SIDE_EFFECTS__
3019
- function _uuidv4(Class, params) {
3020
- return new Class({
3021
- type: "string",
3022
- format: "uuid",
3023
- check: "string_format",
3024
- abort: false,
3025
- version: "v4",
3026
- ...normalizeParams(params)
3027
- });
3028
- }
3029
- // @__NO_SIDE_EFFECTS__
3030
- function _uuidv6(Class, params) {
3031
- return new Class({
3032
- type: "string",
3033
- format: "uuid",
3034
- check: "string_format",
3035
- abort: false,
3036
- version: "v6",
3037
- ...normalizeParams(params)
3038
- });
3039
- }
3040
- // @__NO_SIDE_EFFECTS__
3041
- function _uuidv7(Class, params) {
3042
- return new Class({
3043
- type: "string",
3044
- format: "uuid",
3045
- check: "string_format",
3046
- abort: false,
3047
- version: "v7",
3048
- ...normalizeParams(params)
3049
- });
3050
- }
3051
- // @__NO_SIDE_EFFECTS__
3052
- function _url(Class, params) {
3053
- return new Class({
3054
- type: "string",
3055
- format: "url",
3056
- check: "string_format",
3057
- abort: false,
3058
- ...normalizeParams(params)
3059
- });
3060
- }
3061
- // @__NO_SIDE_EFFECTS__
3062
- function _emoji(Class, params) {
3063
- return new Class({
3064
- type: "string",
3065
- format: "emoji",
3066
- check: "string_format",
3067
- abort: false,
3068
- ...normalizeParams(params)
3069
- });
3070
- }
3071
- // @__NO_SIDE_EFFECTS__
3072
- function _nanoid(Class, params) {
3073
- return new Class({
3074
- type: "string",
3075
- format: "nanoid",
3076
- check: "string_format",
3077
- abort: false,
3078
- ...normalizeParams(params)
3079
- });
3080
- }
3081
- /**
3082
- * @deprecated CUID v1 is deprecated by its authors due to information leakage
3083
- * (timestamps embedded in the id). Use {@link _cuid2} instead.
3084
- * See https://github.com/paralleldrive/cuid.
3085
- */
3086
- // @__NO_SIDE_EFFECTS__
3087
- function _cuid(Class, params) {
3088
- return new Class({
3089
- type: "string",
3090
- format: "cuid",
3091
- check: "string_format",
3092
- abort: false,
3093
- ...normalizeParams(params)
3094
- });
3095
- }
3096
- // @__NO_SIDE_EFFECTS__
3097
- function _cuid2(Class, params) {
3098
- return new Class({
3099
- type: "string",
3100
- format: "cuid2",
3101
- check: "string_format",
3102
- abort: false,
3103
- ...normalizeParams(params)
3104
- });
3105
- }
3106
- // @__NO_SIDE_EFFECTS__
3107
- function _ulid(Class, params) {
3108
- return new Class({
3109
- type: "string",
3110
- format: "ulid",
3111
- check: "string_format",
3112
- abort: false,
3113
- ...normalizeParams(params)
3114
- });
3115
- }
3116
- // @__NO_SIDE_EFFECTS__
3117
- function _xid(Class, params) {
3118
- return new Class({
3119
- type: "string",
3120
- format: "xid",
3121
- check: "string_format",
3122
- abort: false,
3123
- ...normalizeParams(params)
3124
- });
3125
- }
3126
- // @__NO_SIDE_EFFECTS__
3127
- function _ksuid(Class, params) {
3128
- return new Class({
3129
- type: "string",
3130
- format: "ksuid",
3131
- check: "string_format",
3132
- abort: false,
3133
- ...normalizeParams(params)
3134
- });
3135
- }
3136
- // @__NO_SIDE_EFFECTS__
3137
- function _ipv4(Class, params) {
3138
- return new Class({
3139
- type: "string",
3140
- format: "ipv4",
3141
- check: "string_format",
3142
- abort: false,
3143
- ...normalizeParams(params)
3144
- });
3145
- }
3146
- // @__NO_SIDE_EFFECTS__
3147
- function _ipv6(Class, params) {
3148
- return new Class({
3149
- type: "string",
3150
- format: "ipv6",
3151
- check: "string_format",
3152
- abort: false,
3153
- ...normalizeParams(params)
3154
- });
3155
- }
3156
- // @__NO_SIDE_EFFECTS__
3157
- function _cidrv4(Class, params) {
3158
- return new Class({
3159
- type: "string",
3160
- format: "cidrv4",
3161
- check: "string_format",
3162
- abort: false,
3163
- ...normalizeParams(params)
3164
- });
3165
- }
3166
- // @__NO_SIDE_EFFECTS__
3167
- function _cidrv6(Class, params) {
3168
- return new Class({
3169
- type: "string",
3170
- format: "cidrv6",
3171
- check: "string_format",
3172
- abort: false,
3173
- ...normalizeParams(params)
3174
- });
3175
- }
3176
- // @__NO_SIDE_EFFECTS__
3177
- function _base64(Class, params) {
3178
- return new Class({
3179
- type: "string",
3180
- format: "base64",
3181
- check: "string_format",
3182
- abort: false,
3183
- ...normalizeParams(params)
3184
- });
3185
- }
3186
- // @__NO_SIDE_EFFECTS__
3187
- function _base64url(Class, params) {
3188
- return new Class({
3189
- type: "string",
3190
- format: "base64url",
3191
- check: "string_format",
3192
- abort: false,
3193
- ...normalizeParams(params)
3194
- });
3195
- }
3196
- // @__NO_SIDE_EFFECTS__
3197
- function _e164(Class, params) {
3198
- return new Class({
3199
- type: "string",
3200
- format: "e164",
3201
- check: "string_format",
3202
- abort: false,
3203
- ...normalizeParams(params)
3204
- });
3205
- }
3206
- // @__NO_SIDE_EFFECTS__
3207
- function _jwt(Class, params) {
3208
- return new Class({
3209
- type: "string",
3210
- format: "jwt",
3211
- check: "string_format",
3212
- abort: false,
3213
- ...normalizeParams(params)
3214
- });
3215
- }
3216
- // @__NO_SIDE_EFFECTS__
3217
- function _isoDateTime(Class, params) {
3218
- return new Class({
3219
- type: "string",
3220
- format: "datetime",
3221
- check: "string_format",
3222
- offset: false,
3223
- local: false,
3224
- precision: null,
3225
- ...normalizeParams(params)
3226
- });
3227
- }
3228
- // @__NO_SIDE_EFFECTS__
3229
- function _isoDate(Class, params) {
3230
- return new Class({
3231
- type: "string",
3232
- format: "date",
3233
- check: "string_format",
3234
- ...normalizeParams(params)
3235
- });
3236
- }
3237
- // @__NO_SIDE_EFFECTS__
3238
- function _isoTime(Class, params) {
3239
- return new Class({
3240
- type: "string",
3241
- format: "time",
3242
- check: "string_format",
3243
- precision: null,
3244
- ...normalizeParams(params)
3245
- });
3246
- }
3247
- // @__NO_SIDE_EFFECTS__
3248
- function _isoDuration(Class, params) {
3249
- return new Class({
3250
- type: "string",
3251
- format: "duration",
3252
- check: "string_format",
3253
- ...normalizeParams(params)
3254
- });
3255
- }
3256
- // @__NO_SIDE_EFFECTS__
3257
- function _number(Class, params) {
3258
- return new Class({
3259
- type: "number",
3260
- checks: [],
3261
- ...normalizeParams(params)
3262
- });
3263
- }
3264
- // @__NO_SIDE_EFFECTS__
3265
- function _int(Class, params) {
3266
- return new Class({
3267
- type: "number",
3268
- check: "number_format",
3269
- abort: false,
3270
- format: "safeint",
3271
- ...normalizeParams(params)
3272
- });
3273
- }
3274
- // @__NO_SIDE_EFFECTS__
3275
- function _boolean(Class, params) {
3276
- return new Class({
3277
- type: "boolean",
3278
- ...normalizeParams(params)
3279
- });
3280
- }
3281
- // @__NO_SIDE_EFFECTS__
3282
- function _unknown(Class) {
3283
- return new Class({ type: "unknown" });
3284
- }
3285
- // @__NO_SIDE_EFFECTS__
3286
- function _never(Class, params) {
3287
- return new Class({
3288
- type: "never",
3289
- ...normalizeParams(params)
3290
- });
3291
- }
3292
- // @__NO_SIDE_EFFECTS__
3293
- function _lt(value, params) {
3294
- return new $ZodCheckLessThan({
3295
- check: "less_than",
3296
- ...normalizeParams(params),
3297
- value,
3298
- inclusive: false
3299
- });
3300
- }
3301
- // @__NO_SIDE_EFFECTS__
3302
- function _lte(value, params) {
3303
- return new $ZodCheckLessThan({
3304
- check: "less_than",
3305
- ...normalizeParams(params),
3306
- value,
3307
- inclusive: true
3308
- });
3309
- }
3310
- // @__NO_SIDE_EFFECTS__
3311
- function _gt(value, params) {
3312
- return new $ZodCheckGreaterThan({
3313
- check: "greater_than",
3314
- ...normalizeParams(params),
3315
- value,
3316
- inclusive: false
3317
- });
3318
- }
3319
- // @__NO_SIDE_EFFECTS__
3320
- function _gte(value, params) {
3321
- return new $ZodCheckGreaterThan({
3322
- check: "greater_than",
3323
- ...normalizeParams(params),
3324
- value,
3325
- inclusive: true
3326
- });
3327
- }
3328
- // @__NO_SIDE_EFFECTS__
3329
- function _multipleOf(value, params) {
3330
- return new $ZodCheckMultipleOf({
3331
- check: "multiple_of",
3332
- ...normalizeParams(params),
3333
- value
3334
- });
3335
- }
3336
- // @__NO_SIDE_EFFECTS__
3337
- function _maxLength(maximum, params) {
3338
- return new $ZodCheckMaxLength({
3339
- check: "max_length",
3340
- ...normalizeParams(params),
3341
- maximum
3342
- });
3343
- }
3344
- // @__NO_SIDE_EFFECTS__
3345
- function _minLength(minimum, params) {
3346
- return new $ZodCheckMinLength({
3347
- check: "min_length",
3348
- ...normalizeParams(params),
3349
- minimum
3350
- });
3351
- }
3352
- // @__NO_SIDE_EFFECTS__
3353
- function _length(length, params) {
3354
- return new $ZodCheckLengthEquals({
3355
- check: "length_equals",
3356
- ...normalizeParams(params),
3357
- length
3358
- });
3359
- }
3360
- // @__NO_SIDE_EFFECTS__
3361
- function _regex(pattern, params) {
3362
- return new $ZodCheckRegex({
3363
- check: "string_format",
3364
- format: "regex",
3365
- ...normalizeParams(params),
3366
- pattern
3367
- });
3368
- }
3369
- // @__NO_SIDE_EFFECTS__
3370
- function _lowercase(params) {
3371
- return new $ZodCheckLowerCase({
3372
- check: "string_format",
3373
- format: "lowercase",
3374
- ...normalizeParams(params)
3375
- });
3376
- }
3377
- // @__NO_SIDE_EFFECTS__
3378
- function _uppercase(params) {
3379
- return new $ZodCheckUpperCase({
3380
- check: "string_format",
3381
- format: "uppercase",
3382
- ...normalizeParams(params)
3383
- });
3384
- }
3385
- // @__NO_SIDE_EFFECTS__
3386
- function _includes(includes, params) {
3387
- return new $ZodCheckIncludes({
3388
- check: "string_format",
3389
- format: "includes",
3390
- ...normalizeParams(params),
3391
- includes
3392
- });
3393
- }
3394
- // @__NO_SIDE_EFFECTS__
3395
- function _startsWith(prefix, params) {
3396
- return new $ZodCheckStartsWith({
3397
- check: "string_format",
3398
- format: "starts_with",
3399
- ...normalizeParams(params),
3400
- prefix
3401
- });
3402
- }
3403
- // @__NO_SIDE_EFFECTS__
3404
- function _endsWith(suffix, params) {
3405
- return new $ZodCheckEndsWith({
3406
- check: "string_format",
3407
- format: "ends_with",
3408
- ...normalizeParams(params),
3409
- suffix
3410
- });
3411
- }
3412
- // @__NO_SIDE_EFFECTS__
3413
- function _overwrite(tx) {
3414
- return new $ZodCheckOverwrite({
3415
- check: "overwrite",
3416
- tx
3417
- });
3418
- }
3419
- // @__NO_SIDE_EFFECTS__
3420
- function _normalize(form) {
3421
- return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
3422
- }
3423
- // @__NO_SIDE_EFFECTS__
3424
- function _trim() {
3425
- return /* @__PURE__ */ _overwrite((input) => input.trim());
3426
- }
3427
- // @__NO_SIDE_EFFECTS__
3428
- function _toLowerCase() {
3429
- return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
3430
- }
3431
- // @__NO_SIDE_EFFECTS__
3432
- function _toUpperCase() {
3433
- return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
3434
- }
3435
- // @__NO_SIDE_EFFECTS__
3436
- function _slugify() {
3437
- return /* @__PURE__ */ _overwrite((input) => slugify(input));
3438
- }
3439
- // @__NO_SIDE_EFFECTS__
3440
- function _array(Class, element, params) {
3441
- return new Class({
3442
- type: "array",
3443
- element,
3444
- ...normalizeParams(params)
3445
- });
3446
- }
3447
- // @__NO_SIDE_EFFECTS__
3448
- function _refine(Class, fn, _params) {
3449
- return new Class({
3450
- type: "custom",
3451
- check: "custom",
3452
- fn,
3453
- ...normalizeParams(_params)
3454
- });
3455
- }
3456
- // @__NO_SIDE_EFFECTS__
3457
- function _superRefine(fn, params) {
3458
- const ch = /* @__PURE__ */ _check((payload) => {
3459
- payload.addIssue = (issue$2) => {
3460
- if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
3461
- else {
3462
- const _issue = issue$2;
3463
- if (_issue.fatal) _issue.continue = false;
3464
- _issue.code ?? (_issue.code = "custom");
3465
- _issue.input ?? (_issue.input = payload.value);
3466
- _issue.inst ?? (_issue.inst = ch);
3467
- _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
3468
- payload.issues.push(issue(_issue));
3469
- }
3470
- };
3471
- return fn(payload.value, payload);
3472
- }, params);
3473
- return ch;
3474
- }
3475
- // @__NO_SIDE_EFFECTS__
3476
- function _check(fn, params) {
3477
- const ch = new $ZodCheck({
3478
- check: "custom",
3479
- ...normalizeParams(params)
3480
- });
3481
- ch._zod.check = fn;
3482
- return ch;
3483
- }
3484
- //#endregion
3485
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/to-json-schema.js
3486
- function initializeContext(params) {
3487
- let target = params?.target ?? "draft-2020-12";
3488
- if (target === "draft-4") target = "draft-04";
3489
- if (target === "draft-7") target = "draft-07";
3490
- return {
3491
- processors: params.processors ?? {},
3492
- metadataRegistry: params?.metadata ?? globalRegistry,
3493
- target,
3494
- unrepresentable: params?.unrepresentable ?? "throw",
3495
- override: params?.override ?? (() => {}),
3496
- io: params?.io ?? "output",
3497
- counter: 0,
3498
- seen: /* @__PURE__ */ new Map(),
3499
- cycles: params?.cycles ?? "ref",
3500
- reused: params?.reused ?? "inline",
3501
- external: params?.external ?? void 0
3502
- };
3503
- }
3504
- function process$1(schema, ctx, _params = {
3505
- path: [],
3506
- schemaPath: []
3507
- }) {
3508
- var _a;
3509
- const def = schema._zod.def;
3510
- const seen = ctx.seen.get(schema);
3511
- if (seen) {
3512
- seen.count++;
3513
- if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
3514
- return seen.schema;
3515
- }
3516
- const result = {
3517
- schema: {},
3518
- count: 1,
3519
- cycle: void 0,
3520
- path: _params.path
3521
- };
3522
- ctx.seen.set(schema, result);
3523
- const overrideSchema = schema._zod.toJSONSchema?.();
3524
- if (overrideSchema) result.schema = overrideSchema;
3525
- else {
3526
- const params = {
3527
- ..._params,
3528
- schemaPath: [..._params.schemaPath, schema],
3529
- path: _params.path
3530
- };
3531
- if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
3532
- else {
3533
- const _json = result.schema;
3534
- const processor = ctx.processors[def.type];
3535
- if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
3536
- processor(schema, ctx, _json, params);
3537
- }
3538
- const parent = schema._zod.parent;
3539
- if (parent) {
3540
- if (!result.ref) result.ref = parent;
3541
- process$1(parent, ctx, params);
3542
- ctx.seen.get(parent).isParent = true;
3543
- }
3544
- }
3545
- const meta = ctx.metadataRegistry.get(schema);
3546
- if (meta) Object.assign(result.schema, meta);
3547
- if (ctx.io === "input" && isTransforming(schema)) {
3548
- delete result.schema.examples;
3549
- delete result.schema.default;
3550
- }
3551
- if (ctx.io === "input" && "_prefault" in result.schema) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
3552
- delete result.schema._prefault;
3553
- return ctx.seen.get(schema).schema;
3554
- }
3555
- function extractDefs(ctx, schema) {
3556
- const root = ctx.seen.get(schema);
3557
- if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
3558
- const idToSchema = /* @__PURE__ */ new Map();
3559
- for (const entry of ctx.seen.entries()) {
3560
- const id = ctx.metadataRegistry.get(entry[0])?.id;
3561
- if (id) {
3562
- const existing = idToSchema.get(id);
3563
- if (existing && existing !== entry[0]) throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
3564
- idToSchema.set(id, entry[0]);
3565
- }
3566
- }
3567
- const makeURI = (entry) => {
3568
- const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
3569
- if (ctx.external) {
3570
- const externalId = ctx.external.registry.get(entry[0])?.id;
3571
- const uriGenerator = ctx.external.uri ?? ((id) => id);
3572
- if (externalId) return { ref: uriGenerator(externalId) };
3573
- const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
3574
- entry[1].defId = id;
3575
- return {
3576
- defId: id,
3577
- ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
3578
- };
3579
- }
3580
- if (entry[1] === root) return { ref: "#" };
3581
- const defUriPrefix = `#/${defsSegment}/`;
3582
- const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
3583
- return {
3584
- defId,
3585
- ref: defUriPrefix + defId
3586
- };
3587
- };
3588
- const extractToDef = (entry) => {
3589
- if (entry[1].schema.$ref) return;
3590
- const seen = entry[1];
3591
- const { ref, defId } = makeURI(entry);
3592
- seen.def = { ...seen.schema };
3593
- if (defId) seen.defId = defId;
3594
- const schema = seen.schema;
3595
- for (const key in schema) delete schema[key];
3596
- schema.$ref = ref;
3597
- };
3598
- if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
3599
- const seen = entry[1];
3600
- if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
3601
-
3602
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
3603
- }
3604
- for (const entry of ctx.seen.entries()) {
3605
- const seen = entry[1];
3606
- if (schema === entry[0]) {
3607
- extractToDef(entry);
3608
- continue;
3609
- }
3610
- if (ctx.external) {
3611
- const ext = ctx.external.registry.get(entry[0])?.id;
3612
- if (schema !== entry[0] && ext) {
3613
- extractToDef(entry);
3614
- continue;
3615
- }
3616
- }
3617
- if (ctx.metadataRegistry.get(entry[0])?.id) {
3618
- extractToDef(entry);
3619
- continue;
3620
- }
3621
- if (seen.cycle) {
3622
- extractToDef(entry);
3623
- continue;
3624
- }
3625
- if (seen.count > 1) {
3626
- if (ctx.reused === "ref") {
3627
- extractToDef(entry);
3628
- continue;
3629
- }
3630
- }
3631
- }
3632
- }
3633
- function finalize(ctx, schema) {
3634
- const root = ctx.seen.get(schema);
3635
- if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
3636
- const flattenRef = (zodSchema) => {
3637
- const seen = ctx.seen.get(zodSchema);
3638
- if (seen.ref === null) return;
3639
- const schema = seen.def ?? seen.schema;
3640
- const _cached = { ...schema };
3641
- const ref = seen.ref;
3642
- seen.ref = null;
3643
- if (ref) {
3644
- flattenRef(ref);
3645
- const refSeen = ctx.seen.get(ref);
3646
- const refSchema = refSeen.schema;
3647
- if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
3648
- schema.allOf = schema.allOf ?? [];
3649
- schema.allOf.push(refSchema);
3650
- } else Object.assign(schema, refSchema);
3651
- Object.assign(schema, _cached);
3652
- if (zodSchema._zod.parent === ref) for (const key in schema) {
3653
- if (key === "$ref" || key === "allOf") continue;
3654
- if (!(key in _cached)) delete schema[key];
3655
- }
3656
- if (refSchema.$ref && refSeen.def) for (const key in schema) {
3657
- if (key === "$ref" || key === "allOf") continue;
3658
- if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
3659
- }
3660
- }
3661
- const parent = zodSchema._zod.parent;
3662
- if (parent && parent !== ref) {
3663
- flattenRef(parent);
3664
- const parentSeen = ctx.seen.get(parent);
3665
- if (parentSeen?.schema.$ref) {
3666
- schema.$ref = parentSeen.schema.$ref;
3667
- if (parentSeen.def) for (const key in schema) {
3668
- if (key === "$ref" || key === "allOf") continue;
3669
- if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) delete schema[key];
3670
- }
3671
- }
3672
- }
3673
- ctx.override({
3674
- zodSchema,
3675
- jsonSchema: schema,
3676
- path: seen.path ?? []
3677
- });
3678
- };
3679
- for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
3680
- const result = {};
3681
- if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
3682
- else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
3683
- else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
3684
- else if (ctx.target === "openapi-3.0") {}
3685
- if (ctx.external?.uri) {
3686
- const id = ctx.external.registry.get(schema)?.id;
3687
- if (!id) throw new Error("Schema is missing an `id` property");
3688
- result.$id = ctx.external.uri(id);
3689
- }
3690
- Object.assign(result, root.def ?? root.schema);
3691
- const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
3692
- if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
3693
- const defs = ctx.external?.defs ?? {};
3694
- for (const entry of ctx.seen.entries()) {
3695
- const seen = entry[1];
3696
- if (seen.def && seen.defId) {
3697
- if (seen.def.id === seen.defId) delete seen.def.id;
3698
- defs[seen.defId] = seen.def;
3699
- }
3700
- }
3701
- if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
3702
- else result.definitions = defs;
3703
- try {
3704
- const finalized = JSON.parse(JSON.stringify(result));
3705
- Object.defineProperty(finalized, "~standard", {
3706
- value: {
3707
- ...schema["~standard"],
3708
- jsonSchema: {
3709
- input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
3710
- output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
3711
- }
3712
- },
3713
- enumerable: false,
3714
- writable: false
3715
- });
3716
- return finalized;
3717
- } catch (_err) {
3718
- throw new Error("Error converting schema to JSON.");
3719
- }
3720
- }
3721
- function isTransforming(_schema, _ctx) {
3722
- const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
3723
- if (ctx.seen.has(_schema)) return false;
3724
- ctx.seen.add(_schema);
3725
- const def = _schema._zod.def;
3726
- if (def.type === "transform") return true;
3727
- if (def.type === "array") return isTransforming(def.element, ctx);
3728
- if (def.type === "set") return isTransforming(def.valueType, ctx);
3729
- if (def.type === "lazy") return isTransforming(def.getter(), ctx);
3730
- if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
3731
- if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
3732
- if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
3733
- if (def.type === "pipe") {
3734
- if (_schema._zod.traits.has("$ZodCodec")) return true;
3735
- return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
3736
- }
3737
- if (def.type === "object") {
3738
- for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
3739
- return false;
3740
- }
3741
- if (def.type === "union") {
3742
- for (const option of def.options) if (isTransforming(option, ctx)) return true;
3743
- return false;
3744
- }
3745
- if (def.type === "tuple") {
3746
- for (const item of def.items) if (isTransforming(item, ctx)) return true;
3747
- if (def.rest && isTransforming(def.rest, ctx)) return true;
3748
- return false;
3749
- }
3750
- return false;
3751
- }
3752
- /**
3753
- * Creates a toJSONSchema method for a schema instance.
3754
- * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
3755
- */
3756
- const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
3757
- const ctx = initializeContext({
3758
- ...params,
3759
- processors
3760
- });
3761
- process$1(schema, ctx);
3762
- extractDefs(ctx, schema);
3763
- return finalize(ctx, schema);
3764
- };
3765
- const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
3766
- const { libraryOptions, target } = params ?? {};
3767
- const ctx = initializeContext({
3768
- ...libraryOptions ?? {},
3769
- target,
3770
- io,
3771
- processors
3772
- });
3773
- process$1(schema, ctx);
3774
- extractDefs(ctx, schema);
3775
- return finalize(ctx, schema);
3776
- };
3777
- //#endregion
3778
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/json-schema-processors.js
3779
- const formatMap = {
3780
- guid: "uuid",
3781
- url: "uri",
3782
- datetime: "date-time",
3783
- json_string: "json-string",
3784
- regex: ""
3785
- };
3786
- const stringProcessor = (schema, ctx, _json, _params) => {
3787
- const json = _json;
3788
- json.type = "string";
3789
- const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
3790
- if (typeof minimum === "number") json.minLength = minimum;
3791
- if (typeof maximum === "number") json.maxLength = maximum;
3792
- if (format) {
3793
- json.format = formatMap[format] ?? format;
3794
- if (json.format === "") delete json.format;
3795
- if (format === "time") delete json.format;
3796
- }
3797
- if (contentEncoding) json.contentEncoding = contentEncoding;
3798
- if (patterns && patterns.size > 0) {
3799
- const regexes = [...patterns];
3800
- if (regexes.length === 1) json.pattern = regexes[0].source;
3801
- else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
3802
- ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
3803
- pattern: regex.source
3804
- }))];
3805
- }
3806
- };
3807
- const numberProcessor = (schema, ctx, _json, _params) => {
3808
- const json = _json;
3809
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
3810
- if (typeof format === "string" && format.includes("int")) json.type = "integer";
3811
- else json.type = "number";
3812
- const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
3813
- const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
3814
- const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
3815
- if (exMin) if (legacy) {
3816
- json.minimum = exclusiveMinimum;
3817
- json.exclusiveMinimum = true;
3818
- } else json.exclusiveMinimum = exclusiveMinimum;
3819
- else if (typeof minimum === "number") json.minimum = minimum;
3820
- if (exMax) if (legacy) {
3821
- json.maximum = exclusiveMaximum;
3822
- json.exclusiveMaximum = true;
3823
- } else json.exclusiveMaximum = exclusiveMaximum;
3824
- else if (typeof maximum === "number") json.maximum = maximum;
3825
- if (typeof multipleOf === "number") json.multipleOf = multipleOf;
3826
- };
3827
- const booleanProcessor = (_schema, _ctx, json, _params) => {
3828
- json.type = "boolean";
3829
- };
3830
- const neverProcessor = (_schema, _ctx, json, _params) => {
3831
- json.not = {};
3832
- };
3833
- const enumProcessor = (schema, _ctx, json, _params) => {
3834
- const def = schema._zod.def;
3835
- const values = getEnumValues(def.entries);
3836
- if (values.every((v) => typeof v === "number")) json.type = "number";
3837
- if (values.every((v) => typeof v === "string")) json.type = "string";
3838
- json.enum = values;
3839
- };
3840
- const literalProcessor = (schema, ctx, json, _params) => {
3841
- const def = schema._zod.def;
3842
- const vals = [];
3843
- for (const val of def.values) if (val === void 0) {
3844
- if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
3845
- } else if (typeof val === "bigint") if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
3846
- else vals.push(Number(val));
3847
- else vals.push(val);
3848
- if (vals.length === 0) {} else if (vals.length === 1) {
3849
- const val = vals[0];
3850
- json.type = val === null ? "null" : typeof val;
3851
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") json.enum = [val];
3852
- else json.const = val;
3853
- } else {
3854
- if (vals.every((v) => typeof v === "number")) json.type = "number";
3855
- if (vals.every((v) => typeof v === "string")) json.type = "string";
3856
- if (vals.every((v) => typeof v === "boolean")) json.type = "boolean";
3857
- if (vals.every((v) => v === null)) json.type = "null";
3858
- json.enum = vals;
3859
- }
3860
- };
3861
- const customProcessor = (_schema, ctx, _json, _params) => {
3862
- if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
3863
- };
3864
- const transformProcessor = (_schema, ctx, _json, _params) => {
3865
- if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
3866
- };
3867
- const arrayProcessor = (schema, ctx, _json, params) => {
3868
- const json = _json;
3869
- const def = schema._zod.def;
3870
- const { minimum, maximum } = schema._zod.bag;
3871
- if (typeof minimum === "number") json.minItems = minimum;
3872
- if (typeof maximum === "number") json.maxItems = maximum;
3873
- json.type = "array";
3874
- json.items = process$1(def.element, ctx, {
3875
- ...params,
3876
- path: [...params.path, "items"]
3877
- });
3878
- };
3879
- const objectProcessor = (schema, ctx, _json, params) => {
3880
- const json = _json;
3881
- const def = schema._zod.def;
3882
- json.type = "object";
3883
- json.properties = {};
3884
- const shape = def.shape;
3885
- for (const key in shape) json.properties[key] = process$1(shape[key], ctx, {
3886
- ...params,
3887
- path: [
3888
- ...params.path,
3889
- "properties",
3890
- key
3891
- ]
3892
- });
3893
- const allKeys = new Set(Object.keys(shape));
3894
- const requiredKeys = new Set([...allKeys].filter((key) => {
3895
- const v = def.shape[key]._zod;
3896
- if (ctx.io === "input") return v.optin === void 0;
3897
- else return v.optout === void 0;
3898
- }));
3899
- if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
3900
- if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
3901
- else if (!def.catchall) {
3902
- if (ctx.io === "output") json.additionalProperties = false;
3903
- } else if (def.catchall) json.additionalProperties = process$1(def.catchall, ctx, {
3904
- ...params,
3905
- path: [...params.path, "additionalProperties"]
3906
- });
3907
- };
3908
- const unionProcessor = (schema, ctx, json, params) => {
3909
- const def = schema._zod.def;
3910
- const isExclusive = def.inclusive === false;
3911
- const options = def.options.map((x, i) => process$1(x, ctx, {
3912
- ...params,
3913
- path: [
3914
- ...params.path,
3915
- isExclusive ? "oneOf" : "anyOf",
3916
- i
3917
- ]
3918
- }));
3919
- if (isExclusive) json.oneOf = options;
3920
- else json.anyOf = options;
3921
- };
3922
- const intersectionProcessor = (schema, ctx, json, params) => {
3923
- const def = schema._zod.def;
3924
- const a = process$1(def.left, ctx, {
3925
- ...params,
3926
- path: [
3927
- ...params.path,
3928
- "allOf",
3929
- 0
3930
- ]
3931
- });
3932
- const b = process$1(def.right, ctx, {
3933
- ...params,
3934
- path: [
3935
- ...params.path,
3936
- "allOf",
3937
- 1
3938
- ]
3939
- });
3940
- const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
3941
- json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
3942
- };
3943
- const recordProcessor = (schema, ctx, _json, params) => {
3944
- const json = _json;
3945
- const def = schema._zod.def;
3946
- json.type = "object";
3947
- const keyType = def.keyType;
3948
- const patterns = keyType._zod.bag?.patterns;
3949
- if (def.mode === "loose" && patterns && patterns.size > 0) {
3950
- const valueSchema = process$1(def.valueType, ctx, {
3951
- ...params,
3952
- path: [
3953
- ...params.path,
3954
- "patternProperties",
3955
- "*"
3956
- ]
3957
- });
3958
- json.patternProperties = {};
3959
- for (const pattern of patterns) json.patternProperties[pattern.source] = valueSchema;
3960
- } else {
3961
- if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") json.propertyNames = process$1(def.keyType, ctx, {
3962
- ...params,
3963
- path: [...params.path, "propertyNames"]
3964
- });
3965
- json.additionalProperties = process$1(def.valueType, ctx, {
3966
- ...params,
3967
- path: [...params.path, "additionalProperties"]
3968
- });
3969
- }
3970
- const keyValues = keyType._zod.values;
3971
- if (keyValues) {
3972
- const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
3973
- if (validKeyValues.length > 0) json.required = validKeyValues;
3974
- }
3975
- };
3976
- const nullableProcessor = (schema, ctx, json, params) => {
3977
- const def = schema._zod.def;
3978
- const inner = process$1(def.innerType, ctx, params);
3979
- const seen = ctx.seen.get(schema);
3980
- if (ctx.target === "openapi-3.0") {
3981
- seen.ref = def.innerType;
3982
- json.nullable = true;
3983
- } else json.anyOf = [inner, { type: "null" }];
3984
- };
3985
- const nonoptionalProcessor = (schema, ctx, _json, params) => {
3986
- const def = schema._zod.def;
3987
- process$1(def.innerType, ctx, params);
3988
- const seen = ctx.seen.get(schema);
3989
- seen.ref = def.innerType;
3990
- };
3991
- const defaultProcessor = (schema, ctx, json, params) => {
3992
- const def = schema._zod.def;
3993
- process$1(def.innerType, ctx, params);
3994
- const seen = ctx.seen.get(schema);
3995
- seen.ref = def.innerType;
3996
- json.default = JSON.parse(JSON.stringify(def.defaultValue));
3997
- };
3998
- const prefaultProcessor = (schema, ctx, json, params) => {
3999
- const def = schema._zod.def;
4000
- process$1(def.innerType, ctx, params);
4001
- const seen = ctx.seen.get(schema);
4002
- seen.ref = def.innerType;
4003
- if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
4004
- };
4005
- const catchProcessor = (schema, ctx, json, params) => {
4006
- const def = schema._zod.def;
4007
- process$1(def.innerType, ctx, params);
4008
- const seen = ctx.seen.get(schema);
4009
- seen.ref = def.innerType;
4010
- let catchValue;
4011
- try {
4012
- catchValue = def.catchValue(void 0);
4013
- } catch {
4014
- throw new Error("Dynamic catch values are not supported in JSON Schema");
4015
- }
4016
- json.default = catchValue;
4017
- };
4018
- const pipeProcessor = (schema, ctx, _json, params) => {
4019
- const def = schema._zod.def;
4020
- const inIsTransform = def.in._zod.traits.has("$ZodTransform");
4021
- const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
4022
- process$1(innerType, ctx, params);
4023
- const seen = ctx.seen.get(schema);
4024
- seen.ref = innerType;
4025
- };
4026
- const readonlyProcessor = (schema, ctx, json, params) => {
4027
- const def = schema._zod.def;
4028
- process$1(def.innerType, ctx, params);
4029
- const seen = ctx.seen.get(schema);
4030
- seen.ref = def.innerType;
4031
- json.readOnly = true;
4032
- };
4033
- const optionalProcessor = (schema, ctx, _json, params) => {
4034
- const def = schema._zod.def;
4035
- process$1(def.innerType, ctx, params);
4036
- const seen = ctx.seen.get(schema);
4037
- seen.ref = def.innerType;
4038
- };
4039
- //#endregion
4040
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/iso.js
4041
- const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
4042
- $ZodISODateTime.init(inst, def);
4043
- ZodStringFormat.init(inst, def);
4044
- });
4045
- function datetime(params) {
4046
- return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
4047
- }
4048
- const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
4049
- $ZodISODate.init(inst, def);
4050
- ZodStringFormat.init(inst, def);
4051
- });
4052
- function date(params) {
4053
- return /* @__PURE__ */ _isoDate(ZodISODate, params);
4054
- }
4055
- const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
4056
- $ZodISOTime.init(inst, def);
4057
- ZodStringFormat.init(inst, def);
4058
- });
4059
- function time(params) {
4060
- return /* @__PURE__ */ _isoTime(ZodISOTime, params);
4061
- }
4062
- const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
4063
- $ZodISODuration.init(inst, def);
4064
- ZodStringFormat.init(inst, def);
4065
- });
4066
- function duration(params) {
4067
- return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
4068
- }
4069
- //#endregion
4070
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/errors.js
4071
- const initializer = (inst, issues) => {
4072
- $ZodError.init(inst, issues);
4073
- inst.name = "ZodError";
4074
- Object.defineProperties(inst, {
4075
- format: { value: (mapper) => formatError(inst, mapper) },
4076
- flatten: { value: (mapper) => flattenError(inst, mapper) },
4077
- addIssue: { value: (issue) => {
4078
- inst.issues.push(issue);
4079
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
4080
- } },
4081
- addIssues: { value: (issues) => {
4082
- inst.issues.push(...issues);
4083
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
4084
- } },
4085
- isEmpty: { get() {
4086
- return inst.issues.length === 0;
4087
- } }
4088
- });
4089
- };
4090
- const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, { Parent: Error });
4091
- //#endregion
4092
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/parse.js
4093
- const parse = /* @__PURE__ */ _parse(ZodRealError);
4094
- const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
4095
- const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
4096
- const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
4097
- const encode = /* @__PURE__ */ _encode(ZodRealError);
4098
- const decode = /* @__PURE__ */ _decode(ZodRealError);
4099
- const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
4100
- const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
4101
- const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
4102
- const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
4103
- const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
4104
- const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
4105
- //#endregion
4106
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/schemas.js
4107
- const _installedGroups = /* @__PURE__ */ new WeakMap();
4108
- function _installLazyMethods(inst, group, methods) {
4109
- const proto = Object.getPrototypeOf(inst);
4110
- let installed = _installedGroups.get(proto);
4111
- if (!installed) {
4112
- installed = /* @__PURE__ */ new Set();
4113
- _installedGroups.set(proto, installed);
4114
- }
4115
- if (installed.has(group)) return;
4116
- installed.add(group);
4117
- for (const key in methods) {
4118
- const fn = methods[key];
4119
- Object.defineProperty(proto, key, {
4120
- configurable: true,
4121
- enumerable: false,
4122
- get() {
4123
- const bound = fn.bind(this);
4124
- Object.defineProperty(this, key, {
4125
- configurable: true,
4126
- writable: true,
4127
- enumerable: true,
4128
- value: bound
4129
- });
4130
- return bound;
4131
- },
4132
- set(v) {
4133
- Object.defineProperty(this, key, {
4134
- configurable: true,
4135
- writable: true,
4136
- enumerable: true,
4137
- value: v
4138
- });
4139
- }
4140
- });
4141
- }
4142
- }
4143
- const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
4144
- $ZodType.init(inst, def);
4145
- Object.assign(inst["~standard"], { jsonSchema: {
4146
- input: createStandardJSONSchemaMethod(inst, "input"),
4147
- output: createStandardJSONSchemaMethod(inst, "output")
4148
- } });
4149
- inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
4150
- inst.def = def;
4151
- inst.type = def.type;
4152
- Object.defineProperty(inst, "_def", { value: def });
4153
- inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
4154
- inst.safeParse = (data, params) => safeParse(inst, data, params);
4155
- inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
4156
- inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
4157
- inst.spa = inst.safeParseAsync;
4158
- inst.encode = (data, params) => encode(inst, data, params);
4159
- inst.decode = (data, params) => decode(inst, data, params);
4160
- inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
4161
- inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
4162
- inst.safeEncode = (data, params) => safeEncode(inst, data, params);
4163
- inst.safeDecode = (data, params) => safeDecode(inst, data, params);
4164
- inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
4165
- inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
4166
- _installLazyMethods(inst, "ZodType", {
4167
- check(...chks) {
4168
- const def = this.def;
4169
- return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
4170
- check: ch,
4171
- def: { check: "custom" },
4172
- onattach: []
4173
- } } : ch)] }), { parent: true });
4174
- },
4175
- with(...chks) {
4176
- return this.check(...chks);
4177
- },
4178
- clone(def, params) {
4179
- return clone(this, def, params);
4180
- },
4181
- brand() {
4182
- return this;
4183
- },
4184
- register(reg, meta) {
4185
- reg.add(this, meta);
4186
- return this;
4187
- },
4188
- refine(check, params) {
4189
- return this.check(refine(check, params));
4190
- },
4191
- superRefine(refinement, params) {
4192
- return this.check(superRefine(refinement, params));
4193
- },
4194
- overwrite(fn) {
4195
- return this.check(/* @__PURE__ */ _overwrite(fn));
4196
- },
4197
- optional() {
4198
- return optional(this);
4199
- },
4200
- exactOptional() {
4201
- return exactOptional(this);
4202
- },
4203
- nullable() {
4204
- return nullable(this);
4205
- },
4206
- nullish() {
4207
- return optional(nullable(this));
4208
- },
4209
- nonoptional(params) {
4210
- return nonoptional(this, params);
4211
- },
4212
- array() {
4213
- return array(this);
4214
- },
4215
- or(arg) {
4216
- return union([this, arg]);
4217
- },
4218
- and(arg) {
4219
- return intersection(this, arg);
4220
- },
4221
- transform(tx) {
4222
- return pipe(this, transform(tx));
4223
- },
4224
- default(d) {
4225
- return _default(this, d);
4226
- },
4227
- prefault(d) {
4228
- return prefault(this, d);
4229
- },
4230
- catch(params) {
4231
- return _catch(this, params);
4232
- },
4233
- pipe(target) {
4234
- return pipe(this, target);
4235
- },
4236
- readonly() {
4237
- return readonly(this);
4238
- },
4239
- describe(description) {
4240
- const cl = this.clone();
4241
- globalRegistry.add(cl, { description });
4242
- return cl;
4243
- },
4244
- meta(...args) {
4245
- if (args.length === 0) return globalRegistry.get(this);
4246
- const cl = this.clone();
4247
- globalRegistry.add(cl, args[0]);
4248
- return cl;
4249
- },
4250
- isOptional() {
4251
- return this.safeParse(void 0).success;
4252
- },
4253
- isNullable() {
4254
- return this.safeParse(null).success;
4255
- },
4256
- apply(fn) {
4257
- return fn(this);
4258
- }
4259
- });
4260
- Object.defineProperty(inst, "description", {
4261
- get() {
4262
- return globalRegistry.get(inst)?.description;
4263
- },
4264
- configurable: true
4265
- });
4266
- return inst;
4267
- });
4268
- /** @internal */
4269
- const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
4270
- $ZodString.init(inst, def);
4271
- ZodType.init(inst, def);
4272
- inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
4273
- const bag = inst._zod.bag;
4274
- inst.format = bag.format ?? null;
4275
- inst.minLength = bag.minimum ?? null;
4276
- inst.maxLength = bag.maximum ?? null;
4277
- _installLazyMethods(inst, "_ZodString", {
4278
- regex(...args) {
4279
- return this.check(/* @__PURE__ */ _regex(...args));
4280
- },
4281
- includes(...args) {
4282
- return this.check(/* @__PURE__ */ _includes(...args));
4283
- },
4284
- startsWith(...args) {
4285
- return this.check(/* @__PURE__ */ _startsWith(...args));
4286
- },
4287
- endsWith(...args) {
4288
- return this.check(/* @__PURE__ */ _endsWith(...args));
4289
- },
4290
- min(...args) {
4291
- return this.check(/* @__PURE__ */ _minLength(...args));
4292
- },
4293
- max(...args) {
4294
- return this.check(/* @__PURE__ */ _maxLength(...args));
4295
- },
4296
- length(...args) {
4297
- return this.check(/* @__PURE__ */ _length(...args));
4298
- },
4299
- nonempty(...args) {
4300
- return this.check(/* @__PURE__ */ _minLength(1, ...args));
4301
- },
4302
- lowercase(params) {
4303
- return this.check(/* @__PURE__ */ _lowercase(params));
4304
- },
4305
- uppercase(params) {
4306
- return this.check(/* @__PURE__ */ _uppercase(params));
4307
- },
4308
- trim() {
4309
- return this.check(/* @__PURE__ */ _trim());
4310
- },
4311
- normalize(...args) {
4312
- return this.check(/* @__PURE__ */ _normalize(...args));
4313
- },
4314
- toLowerCase() {
4315
- return this.check(/* @__PURE__ */ _toLowerCase());
4316
- },
4317
- toUpperCase() {
4318
- return this.check(/* @__PURE__ */ _toUpperCase());
4319
- },
4320
- slugify() {
4321
- return this.check(/* @__PURE__ */ _slugify());
4322
- }
4323
- });
4324
- });
4325
- const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
4326
- $ZodString.init(inst, def);
4327
- _ZodString.init(inst, def);
4328
- inst.email = (params) => inst.check(/* @__PURE__ */ _email(ZodEmail, params));
4329
- inst.url = (params) => inst.check(/* @__PURE__ */ _url(ZodURL, params));
4330
- inst.jwt = (params) => inst.check(/* @__PURE__ */ _jwt(ZodJWT, params));
4331
- inst.emoji = (params) => inst.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
4332
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
4333
- inst.uuid = (params) => inst.check(/* @__PURE__ */ _uuid(ZodUUID, params));
4334
- inst.uuidv4 = (params) => inst.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
4335
- inst.uuidv6 = (params) => inst.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
4336
- inst.uuidv7 = (params) => inst.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
4337
- inst.nanoid = (params) => inst.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
4338
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
4339
- inst.cuid = (params) => inst.check(/* @__PURE__ */ _cuid(ZodCUID, params));
4340
- inst.cuid2 = (params) => inst.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
4341
- inst.ulid = (params) => inst.check(/* @__PURE__ */ _ulid(ZodULID, params));
4342
- inst.base64 = (params) => inst.check(/* @__PURE__ */ _base64(ZodBase64, params));
4343
- inst.base64url = (params) => inst.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
4344
- inst.xid = (params) => inst.check(/* @__PURE__ */ _xid(ZodXID, params));
4345
- inst.ksuid = (params) => inst.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
4346
- inst.ipv4 = (params) => inst.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
4347
- inst.ipv6 = (params) => inst.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
4348
- inst.cidrv4 = (params) => inst.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
4349
- inst.cidrv6 = (params) => inst.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
4350
- inst.e164 = (params) => inst.check(/* @__PURE__ */ _e164(ZodE164, params));
4351
- inst.datetime = (params) => inst.check(datetime(params));
4352
- inst.date = (params) => inst.check(date(params));
4353
- inst.time = (params) => inst.check(time(params));
4354
- inst.duration = (params) => inst.check(duration(params));
4355
- });
4356
- function string(params) {
4357
- return /* @__PURE__ */ _string(ZodString, params);
4358
- }
4359
- const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def) => {
4360
- $ZodStringFormat.init(inst, def);
4361
- _ZodString.init(inst, def);
4362
- });
4363
- const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
4364
- $ZodEmail.init(inst, def);
4365
- ZodStringFormat.init(inst, def);
4366
- });
4367
- const ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def) => {
4368
- $ZodGUID.init(inst, def);
4369
- ZodStringFormat.init(inst, def);
4370
- });
4371
- const ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (inst, def) => {
4372
- $ZodUUID.init(inst, def);
4373
- ZodStringFormat.init(inst, def);
4374
- });
4375
- const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def) => {
4376
- $ZodURL.init(inst, def);
4377
- ZodStringFormat.init(inst, def);
4378
- });
4379
- const ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def) => {
4380
- $ZodEmoji.init(inst, def);
4381
- ZodStringFormat.init(inst, def);
4382
- });
4383
- const ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def) => {
4384
- $ZodNanoID.init(inst, def);
4385
- ZodStringFormat.init(inst, def);
4386
- });
4387
- /**
4388
- * @deprecated CUID v1 is deprecated by its authors due to information leakage
4389
- * (timestamps embedded in the id). Use {@link ZodCUID2} instead.
4390
- * See https://github.com/paralleldrive/cuid.
4391
- */
4392
- const ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def) => {
4393
- $ZodCUID.init(inst, def);
4394
- ZodStringFormat.init(inst, def);
4395
- });
4396
- const ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (inst, def) => {
4397
- $ZodCUID2.init(inst, def);
4398
- ZodStringFormat.init(inst, def);
4399
- });
4400
- const ZodULID = /*@__PURE__*/ $constructor("ZodULID", (inst, def) => {
4401
- $ZodULID.init(inst, def);
4402
- ZodStringFormat.init(inst, def);
4403
- });
4404
- const ZodXID = /*@__PURE__*/ $constructor("ZodXID", (inst, def) => {
4405
- $ZodXID.init(inst, def);
4406
- ZodStringFormat.init(inst, def);
4407
- });
4408
- const ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (inst, def) => {
4409
- $ZodKSUID.init(inst, def);
4410
- ZodStringFormat.init(inst, def);
4411
- });
4412
- const ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (inst, def) => {
4413
- $ZodIPv4.init(inst, def);
4414
- ZodStringFormat.init(inst, def);
4415
- });
4416
- const ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (inst, def) => {
4417
- $ZodIPv6.init(inst, def);
4418
- ZodStringFormat.init(inst, def);
4419
- });
4420
- const ZodCIDRv4 = /*@__PURE__*/ $constructor("ZodCIDRv4", (inst, def) => {
4421
- $ZodCIDRv4.init(inst, def);
4422
- ZodStringFormat.init(inst, def);
4423
- });
4424
- const ZodCIDRv6 = /*@__PURE__*/ $constructor("ZodCIDRv6", (inst, def) => {
4425
- $ZodCIDRv6.init(inst, def);
4426
- ZodStringFormat.init(inst, def);
4427
- });
4428
- const ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (inst, def) => {
4429
- $ZodBase64.init(inst, def);
4430
- ZodStringFormat.init(inst, def);
4431
- });
4432
- const ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (inst, def) => {
4433
- $ZodBase64URL.init(inst, def);
4434
- ZodStringFormat.init(inst, def);
4435
- });
4436
- const ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (inst, def) => {
4437
- $ZodE164.init(inst, def);
4438
- ZodStringFormat.init(inst, def);
4439
- });
4440
- const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
4441
- $ZodJWT.init(inst, def);
4442
- ZodStringFormat.init(inst, def);
4443
- });
4444
- const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
4445
- $ZodNumber.init(inst, def);
4446
- ZodType.init(inst, def);
4447
- inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
4448
- _installLazyMethods(inst, "ZodNumber", {
4449
- gt(value, params) {
4450
- return this.check(/* @__PURE__ */ _gt(value, params));
4451
- },
4452
- gte(value, params) {
4453
- return this.check(/* @__PURE__ */ _gte(value, params));
4454
- },
4455
- min(value, params) {
4456
- return this.check(/* @__PURE__ */ _gte(value, params));
4457
- },
4458
- lt(value, params) {
4459
- return this.check(/* @__PURE__ */ _lt(value, params));
4460
- },
4461
- lte(value, params) {
4462
- return this.check(/* @__PURE__ */ _lte(value, params));
4463
- },
4464
- max(value, params) {
4465
- return this.check(/* @__PURE__ */ _lte(value, params));
4466
- },
4467
- int(params) {
4468
- return this.check(int(params));
4469
- },
4470
- safe(params) {
4471
- return this.check(int(params));
4472
- },
4473
- positive(params) {
4474
- return this.check(/* @__PURE__ */ _gt(0, params));
4475
- },
4476
- nonnegative(params) {
4477
- return this.check(/* @__PURE__ */ _gte(0, params));
4478
- },
4479
- negative(params) {
4480
- return this.check(/* @__PURE__ */ _lt(0, params));
4481
- },
4482
- nonpositive(params) {
4483
- return this.check(/* @__PURE__ */ _lte(0, params));
4484
- },
4485
- multipleOf(value, params) {
4486
- return this.check(/* @__PURE__ */ _multipleOf(value, params));
4487
- },
4488
- step(value, params) {
4489
- return this.check(/* @__PURE__ */ _multipleOf(value, params));
4490
- },
4491
- finite() {
4492
- return this;
4493
- }
4494
- });
4495
- const bag = inst._zod.bag;
4496
- inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
4497
- inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
4498
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
4499
- inst.isFinite = true;
4500
- inst.format = bag.format ?? null;
4501
- });
4502
- function number(params) {
4503
- return /* @__PURE__ */ _number(ZodNumber, params);
4504
- }
4505
- const ZodNumberFormat = /*@__PURE__*/ $constructor("ZodNumberFormat", (inst, def) => {
4506
- $ZodNumberFormat.init(inst, def);
4507
- ZodNumber.init(inst, def);
4508
- });
4509
- function int(params) {
4510
- return /* @__PURE__ */ _int(ZodNumberFormat, params);
4511
- }
4512
- const ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (inst, def) => {
4513
- $ZodBoolean.init(inst, def);
4514
- ZodType.init(inst, def);
4515
- inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
4516
- });
4517
- function boolean(params) {
4518
- return /* @__PURE__ */ _boolean(ZodBoolean, params);
4519
- }
4520
- const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
4521
- $ZodUnknown.init(inst, def);
4522
- ZodType.init(inst, def);
4523
- inst._zod.processJSONSchema = (ctx, json, params) => void 0;
4524
- });
4525
- function unknown() {
4526
- return /* @__PURE__ */ _unknown(ZodUnknown);
4527
- }
4528
- const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
4529
- $ZodNever.init(inst, def);
4530
- ZodType.init(inst, def);
4531
- inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
4532
- });
4533
- function never(params) {
4534
- return /* @__PURE__ */ _never(ZodNever, params);
4535
- }
4536
- const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
4537
- $ZodArray.init(inst, def);
4538
- ZodType.init(inst, def);
4539
- inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
4540
- inst.element = def.element;
4541
- _installLazyMethods(inst, "ZodArray", {
4542
- min(n, params) {
4543
- return this.check(/* @__PURE__ */ _minLength(n, params));
4544
- },
4545
- nonempty(params) {
4546
- return this.check(/* @__PURE__ */ _minLength(1, params));
4547
- },
4548
- max(n, params) {
4549
- return this.check(/* @__PURE__ */ _maxLength(n, params));
4550
- },
4551
- length(n, params) {
4552
- return this.check(/* @__PURE__ */ _length(n, params));
4553
- },
4554
- unwrap() {
4555
- return this.element;
4556
- }
4557
- });
4558
- });
4559
- function array(element, params) {
4560
- return /* @__PURE__ */ _array(ZodArray, element, params);
4561
- }
4562
- const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
4563
- $ZodObjectJIT.init(inst, def);
4564
- ZodType.init(inst, def);
4565
- inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
4566
- defineLazy(inst, "shape", () => {
4567
- return def.shape;
4568
- });
4569
- _installLazyMethods(inst, "ZodObject", {
4570
- keyof() {
4571
- return _enum(Object.keys(this._zod.def.shape));
4572
- },
4573
- catchall(catchall) {
4574
- return this.clone({
4575
- ...this._zod.def,
4576
- catchall
4577
- });
4578
- },
4579
- passthrough() {
4580
- return this.clone({
4581
- ...this._zod.def,
4582
- catchall: unknown()
4583
- });
4584
- },
4585
- loose() {
4586
- return this.clone({
4587
- ...this._zod.def,
4588
- catchall: unknown()
4589
- });
4590
- },
4591
- strict() {
4592
- return this.clone({
4593
- ...this._zod.def,
4594
- catchall: never()
4595
- });
4596
- },
4597
- strip() {
4598
- return this.clone({
4599
- ...this._zod.def,
4600
- catchall: void 0
4601
- });
4602
- },
4603
- extend(incoming) {
4604
- return extend(this, incoming);
4605
- },
4606
- safeExtend(incoming) {
4607
- return safeExtend(this, incoming);
4608
- },
4609
- merge(other) {
4610
- return merge(this, other);
4611
- },
4612
- pick(mask) {
4613
- return pick(this, mask);
4614
- },
4615
- omit(mask) {
4616
- return omit(this, mask);
4617
- },
4618
- partial(...args) {
4619
- return partial(ZodOptional, this, args[0]);
4620
- },
4621
- required(...args) {
4622
- return required(ZodNonOptional, this, args[0]);
4623
- }
4624
- });
4625
- });
4626
- function object(shape, params) {
4627
- return new ZodObject({
4628
- type: "object",
4629
- shape: shape ?? {},
4630
- ...normalizeParams(params)
4631
- });
4632
- }
4633
- const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
4634
- $ZodUnion.init(inst, def);
4635
- ZodType.init(inst, def);
4636
- inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
4637
- inst.options = def.options;
4638
- });
4639
- function union(options, params) {
4640
- return new ZodUnion({
4641
- type: "union",
4642
- options,
4643
- ...normalizeParams(params)
4644
- });
4645
- }
4646
- const ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("ZodDiscriminatedUnion", (inst, def) => {
4647
- ZodUnion.init(inst, def);
4648
- $ZodDiscriminatedUnion.init(inst, def);
4649
- });
4650
- function discriminatedUnion(discriminator, options, params) {
4651
- return new ZodDiscriminatedUnion({
4652
- type: "union",
4653
- options,
4654
- discriminator,
4655
- ...normalizeParams(params)
4656
- });
4657
- }
4658
- const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
4659
- $ZodIntersection.init(inst, def);
4660
- ZodType.init(inst, def);
4661
- inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
4662
- });
4663
- function intersection(left, right) {
4664
- return new ZodIntersection({
4665
- type: "intersection",
4666
- left,
4667
- right
4668
- });
4669
- }
4670
- const ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
4671
- $ZodRecord.init(inst, def);
4672
- ZodType.init(inst, def);
4673
- inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
4674
- inst.keyType = def.keyType;
4675
- inst.valueType = def.valueType;
4676
- });
4677
- function record$1(keyType, valueType, params) {
4678
- if (!valueType || !valueType._zod) return new ZodRecord({
4679
- type: "record",
4680
- keyType: string(),
4681
- valueType: keyType,
4682
- ...normalizeParams(valueType)
4683
- });
4684
- return new ZodRecord({
4685
- type: "record",
4686
- keyType,
4687
- valueType,
4688
- ...normalizeParams(params)
4689
- });
4690
- }
4691
- const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
4692
- $ZodEnum.init(inst, def);
4693
- ZodType.init(inst, def);
4694
- inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
4695
- inst.enum = def.entries;
4696
- inst.options = Object.values(def.entries);
4697
- const keys = new Set(Object.keys(def.entries));
4698
- inst.extract = (values, params) => {
4699
- const newEntries = {};
4700
- for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
4701
- else throw new Error(`Key ${value} not found in enum`);
4702
- return new ZodEnum({
4703
- ...def,
4704
- checks: [],
4705
- ...normalizeParams(params),
4706
- entries: newEntries
4707
- });
4708
- };
4709
- inst.exclude = (values, params) => {
4710
- const newEntries = { ...def.entries };
4711
- for (const value of values) if (keys.has(value)) delete newEntries[value];
4712
- else throw new Error(`Key ${value} not found in enum`);
4713
- return new ZodEnum({
4714
- ...def,
4715
- checks: [],
4716
- ...normalizeParams(params),
4717
- entries: newEntries
4718
- });
4719
- };
4720
- });
4721
- function _enum(values, params) {
4722
- return new ZodEnum({
4723
- type: "enum",
4724
- entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
4725
- ...normalizeParams(params)
4726
- });
4727
- }
4728
- const ZodLiteral = /*@__PURE__*/ $constructor("ZodLiteral", (inst, def) => {
4729
- $ZodLiteral.init(inst, def);
4730
- ZodType.init(inst, def);
4731
- inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
4732
- inst.values = new Set(def.values);
4733
- Object.defineProperty(inst, "value", { get() {
4734
- if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
4735
- return def.values[0];
4736
- } });
4737
- });
4738
- function literal(value, params) {
4739
- return new ZodLiteral({
4740
- type: "literal",
4741
- values: Array.isArray(value) ? value : [value],
4742
- ...normalizeParams(params)
4743
- });
4744
- }
4745
- const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
4746
- $ZodTransform.init(inst, def);
4747
- ZodType.init(inst, def);
4748
- inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
4749
- inst._zod.parse = (payload, _ctx) => {
4750
- if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
4751
- payload.addIssue = (issue$1) => {
4752
- if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
4753
- else {
4754
- const _issue = issue$1;
4755
- if (_issue.fatal) _issue.continue = false;
4756
- _issue.code ?? (_issue.code = "custom");
4757
- _issue.input ?? (_issue.input = payload.value);
4758
- _issue.inst ?? (_issue.inst = inst);
4759
- payload.issues.push(issue(_issue));
4760
- }
4761
- };
4762
- const output = def.transform(payload.value, payload);
4763
- if (output instanceof Promise) return output.then((output) => {
4764
- payload.value = output;
4765
- payload.fallback = true;
4766
- return payload;
4767
- });
4768
- payload.value = output;
4769
- payload.fallback = true;
4770
- return payload;
4771
- };
4772
- });
4773
- function transform(fn) {
4774
- return new ZodTransform({
4775
- type: "transform",
4776
- transform: fn
4777
- });
4778
- }
4779
- const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
4780
- $ZodOptional.init(inst, def);
4781
- ZodType.init(inst, def);
4782
- inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4783
- inst.unwrap = () => inst._zod.def.innerType;
4784
- });
4785
- function optional(innerType) {
4786
- return new ZodOptional({
4787
- type: "optional",
4788
- innerType
4789
- });
4790
- }
4791
- const ZodExactOptional = /*@__PURE__*/ $constructor("ZodExactOptional", (inst, def) => {
4792
- $ZodExactOptional.init(inst, def);
4793
- ZodType.init(inst, def);
4794
- inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4795
- inst.unwrap = () => inst._zod.def.innerType;
4796
- });
4797
- function exactOptional(innerType) {
4798
- return new ZodExactOptional({
4799
- type: "optional",
4800
- innerType
4801
- });
4802
- }
4803
- const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
4804
- $ZodNullable.init(inst, def);
4805
- ZodType.init(inst, def);
4806
- inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
4807
- inst.unwrap = () => inst._zod.def.innerType;
4808
- });
4809
- function nullable(innerType) {
4810
- return new ZodNullable({
4811
- type: "nullable",
4812
- innerType
4813
- });
4814
- }
4815
- const ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def) => {
4816
- $ZodDefault.init(inst, def);
4817
- ZodType.init(inst, def);
4818
- inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
4819
- inst.unwrap = () => inst._zod.def.innerType;
4820
- inst.removeDefault = inst.unwrap;
4821
- });
4822
- function _default(innerType, defaultValue) {
4823
- return new ZodDefault({
4824
- type: "default",
4825
- innerType,
4826
- get defaultValue() {
4827
- return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
4828
- }
4829
- });
4830
- }
4831
- const ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (inst, def) => {
4832
- $ZodPrefault.init(inst, def);
4833
- ZodType.init(inst, def);
4834
- inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
4835
- inst.unwrap = () => inst._zod.def.innerType;
4836
- });
4837
- function prefault(innerType, defaultValue) {
4838
- return new ZodPrefault({
4839
- type: "prefault",
4840
- innerType,
4841
- get defaultValue() {
4842
- return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
4843
- }
4844
- });
4845
- }
4846
- const ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (inst, def) => {
4847
- $ZodNonOptional.init(inst, def);
4848
- ZodType.init(inst, def);
4849
- inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
4850
- inst.unwrap = () => inst._zod.def.innerType;
4851
- });
4852
- function nonoptional(innerType, params) {
4853
- return new ZodNonOptional({
4854
- type: "nonoptional",
4855
- innerType,
4856
- ...normalizeParams(params)
4857
- });
4858
- }
4859
- const ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def) => {
4860
- $ZodCatch.init(inst, def);
4861
- ZodType.init(inst, def);
4862
- inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
4863
- inst.unwrap = () => inst._zod.def.innerType;
4864
- inst.removeCatch = inst.unwrap;
4865
- });
4866
- function _catch(innerType, catchValue) {
4867
- return new ZodCatch({
4868
- type: "catch",
4869
- innerType,
4870
- catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
4871
- });
4872
- }
4873
- const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
4874
- $ZodPipe.init(inst, def);
4875
- ZodType.init(inst, def);
4876
- inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
4877
- inst.in = def.in;
4878
- inst.out = def.out;
4879
- });
4880
- function pipe(in_, out) {
4881
- return new ZodPipe({
4882
- type: "pipe",
4883
- in: in_,
4884
- out
4885
- });
4886
- }
4887
- const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
4888
- $ZodReadonly.init(inst, def);
4889
- ZodType.init(inst, def);
4890
- inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
4891
- inst.unwrap = () => inst._zod.def.innerType;
4892
- });
4893
- function readonly(innerType) {
4894
- return new ZodReadonly({
4895
- type: "readonly",
4896
- innerType
4897
- });
4898
- }
4899
- const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
4900
- $ZodCustom.init(inst, def);
4901
- ZodType.init(inst, def);
4902
- inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
4903
- });
4904
- function refine(fn, _params = {}) {
4905
- return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
4906
- }
4907
- function superRefine(fn, params) {
4908
- return /* @__PURE__ */ _superRefine(fn, params);
4909
- }
4910
- //#endregion
4911
643
  //#region lib/types/client/persistence.js
4912
644
  /** Validated current-layout snapshots; undo history belongs to the live window. */
4913
645
  /** Persistence namespace shared by scoped stores and startup discovery. */
4914
646
  const sidebarPersistence = "dsh.sidebar-right.v1";
4915
- const paneId = string().regex(/^(?:pane|float)[1-9][0-9]*$/u);
4916
- const splitId = string().regex(/^split[1-9][0-9]*$/u);
4917
- const tabId = string().regex(/^tab[1-9][0-9]*$/u);
4918
- const nodeId = union([paneId, splitId]);
4919
- const rectangle = object({
4920
- x: number(),
4921
- y: number(),
4922
- width: number().positive(),
4923
- height: number().positive()
647
+ const paneId = zod.z.string().regex(/^(?:pane|float)[1-9][0-9]*$/u);
648
+ const splitId = zod.z.string().regex(/^split[1-9][0-9]*$/u);
649
+ const tabId = zod.z.string().regex(/^tab[1-9][0-9]*$/u);
650
+ const nodeId = zod.z.union([paneId, splitId]);
651
+ const rectangle = zod.z.object({
652
+ x: zod.z.number(),
653
+ y: zod.z.number(),
654
+ width: zod.z.number().positive(),
655
+ height: zod.z.number().positive()
656
+ });
657
+ const node = zod.z.discriminatedUnion("kind", [zod.z.object({
658
+ kind: zod.z.literal("pane"),
659
+ id: paneId,
660
+ host: zod.z.enum(["dock", "float"]),
661
+ tabs: zod.z.array(tabId),
662
+ activeTabId: tabId.optional(),
663
+ rect: rectangle.optional()
664
+ }), zod.z.object({
665
+ kind: zod.z.literal("split"),
666
+ id: splitId,
667
+ axis: zod.z.enum(["row", "column"]),
668
+ children: zod.z.array(nodeId).min(2),
669
+ sizes: zod.z.array(zod.z.number().positive()).min(2)
670
+ })]);
671
+ const layout = zod.z.object({
672
+ nodes: zod.z.record(nodeId, node),
673
+ tabs: zod.z.record(tabId, zod.z.object({
674
+ id: tabId,
675
+ kind: zod.z.string().min(1),
676
+ contentId: zod.z.string().min(1),
677
+ title: zod.z.string()
678
+ })),
679
+ rootId: nodeId,
680
+ floats: zod.z.array(paneId),
681
+ activePaneId: paneId,
682
+ expanded: zod.z.boolean(),
683
+ mode: zod.z.enum(["push", "fullscreen"])
4924
684
  });
4925
- const surface = object({
4926
- layout: object({
4927
- nodes: record$1(nodeId, discriminatedUnion("kind", [object({
4928
- kind: literal("pane"),
4929
- id: paneId,
4930
- host: _enum(["dock", "float"]),
4931
- tabs: array(tabId),
4932
- activeTabId: tabId.optional(),
4933
- rect: rectangle.optional()
4934
- }), object({
4935
- kind: literal("split"),
4936
- id: splitId,
4937
- axis: _enum(["row", "column"]),
4938
- children: array(nodeId).min(2),
4939
- sizes: array(number().positive()).min(2)
4940
- })])),
4941
- tabs: record$1(tabId, object({
4942
- id: tabId,
4943
- kind: string().min(1),
4944
- contentId: string().min(1),
4945
- title: string()
4946
- })),
4947
- rootId: nodeId,
4948
- floats: array(paneId),
4949
- activePaneId: paneId,
4950
- expanded: boolean(),
4951
- mode: _enum(["push", "fullscreen"])
4952
- }),
4953
- minted: int().nonnegative()
685
+ const surface = zod.z.object({
686
+ layout,
687
+ minted: zod.z.int().nonnegative()
4954
688
  });
4955
- const envelope = object({ bySession: record$1(string(), unknown()) });
689
+ const envelope = zod.z.object({ bySession: zod.z.record(zod.z.string(), zod.z.unknown()) });
4956
690
  function validateReferences(value) {
4957
691
  const { layout, minted } = value;
4958
692
  const reject = () => {