{"version":3,"file":"@vee-validate-BsJ4aUeu.js","sources":["../../node_modules/@vee-validate/zod/dist/vee-validate-zod.mjs"],"sourcesContent":["/**\n * vee-validate v4.15.0\n * (c) 2024 Abdelrahman Awad\n * @license MIT\n */\nimport { ZodObject, ZodDefault, ZodFirstPartyTypeKind } from 'zod';\nimport { isNotNestedPath, cleanupNonNestedPath } from 'vee-validate';\n\nconst isObject = (obj) => obj !== null && !!obj && typeof obj === 'object' && !Array.isArray(obj);\nfunction isIndex(value) {\n return Number(value) >= 0;\n}\nfunction isObjectLike(value) {\n return typeof value === 'object' && value !== null;\n}\nfunction getTag(value) {\n if (value == null) {\n return value === undefined ? '[object Undefined]' : '[object Null]';\n }\n return Object.prototype.toString.call(value);\n}\n// Reference: https://github.com/lodash/lodash/blob/master/isPlainObject.js\nfunction isPlainObject(value) {\n if (!isObjectLike(value) || getTag(value) !== '[object Object]') {\n return false;\n }\n if (Object.getPrototypeOf(value) === null) {\n return true;\n }\n let proto = value;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n return Object.getPrototypeOf(value) === proto;\n}\nfunction merge(target, source) {\n Object.keys(source).forEach(key => {\n if (isPlainObject(source[key]) && isPlainObject(target[key])) {\n if (!target[key]) {\n target[key] = {};\n }\n merge(target[key], source[key]);\n return;\n }\n target[key] = source[key];\n });\n return target;\n}\n/**\n * Constructs a path with dot paths for arrays to use brackets to be compatible with vee-validate path syntax\n */\nfunction normalizeFormPath(path) {\n const pathArr = path.split('.');\n if (!pathArr.length) {\n return '';\n }\n let fullPath = String(pathArr[0]);\n for (let i = 1; i < pathArr.length; i++) {\n if (isIndex(pathArr[i])) {\n fullPath += `[${pathArr[i]}]`;\n continue;\n }\n fullPath += `.${pathArr[i]}`;\n }\n return fullPath;\n}\n\n/**\n * Transforms a Zod object schema to Yup's schema\n */\nfunction toTypedSchema(zodSchema, opts) {\n const schema = {\n __type: 'VVTypedSchema',\n async parse(value) {\n const result = await zodSchema.safeParseAsync(value, opts);\n if (result.success) {\n return {\n value: result.data,\n errors: [],\n };\n }\n const errors = {};\n processIssues(result.error.issues, errors);\n return {\n errors: Object.values(errors),\n };\n },\n cast(values) {\n try {\n return zodSchema.parse(values);\n }\n catch (_a) {\n // Zod does not support \"casting\" or not validating a value, so next best thing is getting the defaults and merging them with the provided values.\n const defaults = getDefaults(zodSchema);\n if (isObject(defaults) && isObject(values)) {\n return merge(defaults, values);\n }\n return values;\n }\n },\n describe(path) {\n try {\n if (!path) {\n return {\n required: !zodSchema.isOptional(),\n exists: true,\n };\n }\n const description = getSchemaForPath(path, zodSchema);\n if (!description) {\n return {\n required: false,\n exists: false,\n };\n }\n return {\n required: !description.isOptional(),\n exists: true,\n };\n }\n catch (_a) {\n if ((process.env.NODE_ENV !== 'production')) {\n // eslint-disable-next-line no-console\n console.warn(`Failed to describe path ${path} on the schema, returning a default description.`);\n }\n return {\n required: false,\n exists: false,\n };\n }\n },\n };\n return schema;\n}\nfunction processIssues(issues, errors) {\n issues.forEach(issue => {\n const path = normalizeFormPath(issue.path.join('.'));\n if (issue.code === 'invalid_union') {\n processIssues(issue.unionErrors.flatMap(ue => ue.issues), errors);\n if (!path) {\n return;\n }\n }\n if (!errors[path]) {\n errors[path] = { errors: [], path };\n }\n errors[path].errors.push(issue.message);\n });\n}\n// Zod does not support extracting default values so the next best thing is manually extracting them.\n// https://github.com/colinhacks/zod/issues/1944#issuecomment-1406566175\nfunction getDefaults(schema) {\n if (!(schema instanceof ZodObject)) {\n return undefined;\n }\n return Object.fromEntries(Object.entries(schema.shape).map(([key, value]) => {\n if (value instanceof ZodDefault) {\n return [key, value._def.defaultValue()];\n }\n if (value instanceof ZodObject) {\n return [key, getDefaults(value)];\n }\n return [key, undefined];\n }));\n}\n/**\n * @deprecated use toTypedSchema instead.\n */\nconst toFieldValidator = toTypedSchema;\n/**\n * @deprecated use toTypedSchema instead.\n */\nconst toFormValidator = toTypedSchema;\nfunction getSchemaForPath(path, schema) {\n if (!isObjectSchema(schema)) {\n return null;\n }\n if (isNotNestedPath(path)) {\n return schema.shape[cleanupNonNestedPath(path)];\n }\n const paths = (path || '').split(/\\.|\\[(\\d+)\\]/).filter(Boolean);\n let currentSchema = schema;\n for (let i = 0; i <= paths.length; i++) {\n const p = paths[i];\n if (!p || !currentSchema) {\n return currentSchema;\n }\n if (isObjectSchema(currentSchema)) {\n currentSchema = currentSchema.shape[p] || null;\n continue;\n }\n if (isIndex(p) && isArraySchema(currentSchema)) {\n currentSchema = currentSchema._def.type;\n }\n }\n return null;\n}\nfunction getDefType(schema) {\n return schema._def.typeName;\n}\nfunction isArraySchema(schema) {\n return getDefType(schema) === ZodFirstPartyTypeKind.ZodArray;\n}\nfunction isObjectSchema(schema) {\n return getDefType(schema) === ZodFirstPartyTypeKind.ZodObject;\n}\n\nexport { toFieldValidator, toFormValidator, toTypedSchema };\n"],"names":["isObject","obj","isIndex","value","isObjectLike","getTag","isPlainObject","proto","merge","target","source","key","normalizeFormPath","path","pathArr","fullPath","i","toTypedSchema","zodSchema","opts","result","errors","processIssues","values","defaults","getDefaults","description","getSchemaForPath","issues","issue","ue","schema","ZodObject","ZodDefault","isObjectSchema","isNotNestedPath","cleanupNonNestedPath","paths","currentSchema","p","isArraySchema","getDefType","ZodFirstPartyTypeKind"],"mappings":"mbAAA;AAAA;AAAA;AAAA;AAAA,IAQA,MAAMA,EAAYC,GAAQA,IAAQ,MAAQ,CAAC,CAACA,GAAO,OAAOA,GAAQ,UAAY,CAAC,MAAM,QAAQA,CAAG,EAChG,SAASC,EAAQC,EAAO,CACb,OAAA,OAAOA,CAAK,GAAK,CAC5B,CACA,SAASC,EAAaD,EAAO,CAClB,OAAA,OAAOA,GAAU,UAAYA,IAAU,IAClD,CACA,SAASE,EAAOF,EAAO,CACnB,OAAIA,GAAS,KACFA,IAAU,OAAY,qBAAuB,gBAEjD,OAAO,UAAU,SAAS,KAAKA,CAAK,CAC/C,CAEA,SAASG,EAAcH,EAAO,CAC1B,GAAI,CAAC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