@maroonedog/luq 0.1.1-alpha → 0.1.2-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/builder/context/field-context.d.ts +2 -2
- package/dist/core/builder/core/field-builder.d.ts +1 -1
- package/dist/core/builder/types/types.d.ts +4 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +2 -2
- package/dist/plugins/tupleBuilder.js +1 -1
- package/dist/plugins/tupleBuilder.mjs +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Optimized field context creation for V8 performance
|
|
3
3
|
* Removes Proxy usage and reduces object allocation
|
|
4
4
|
*/
|
|
5
|
-
import type { TypeName, ChainableFieldBuilder, FieldBuilderContext, TransformFunction } from "../plugins/plugin-types";
|
|
5
|
+
import type { TypeName, ChainableFieldBuilder, FieldBuilderContext, TransformFunction, TypeMapping } from "../plugins/plugin-types";
|
|
6
6
|
type OptimizedValidator<T = unknown> = (value: T, currentValue: T) => boolean;
|
|
7
7
|
interface ValidatorWithMeta<TValue = unknown> {
|
|
8
8
|
check: OptimizedValidator<TValue>;
|
|
@@ -23,7 +23,7 @@ interface ValidatorWithMeta<TValue = unknown> {
|
|
|
23
23
|
export declare function createOptimizedTypeBuilder<TObject extends object, TPlugins, TType extends TypeName>(type: TType, fieldPath: string, plugins: TPlugins, existingState?: {
|
|
24
24
|
validators: ValidatorWithMeta<unknown>[];
|
|
25
25
|
transforms: Array<TransformFunction<unknown, unknown>>;
|
|
26
|
-
}): ChainableFieldBuilder<TObject, TPlugins, TType,
|
|
26
|
+
}): ChainableFieldBuilder<TObject, TPlugins, TType, TypeMapping[TType]>;
|
|
27
27
|
/**
|
|
28
28
|
* Create type-safe field context without Proxy
|
|
29
29
|
*/
|
|
@@ -9,5 +9,5 @@ export type { FieldBuilderDefinition } from "../types/types";
|
|
|
9
9
|
/**
|
|
10
10
|
* Streamlined FieldBuilder implementation focused on core building logic
|
|
11
11
|
*/
|
|
12
|
-
export declare function createFieldBuilderImpl<TObject extends object, TMap = {}, TPlugins = {}, TDeclaredFields extends string = never>(plugins: TPlugins, chainableBuilder: any, fieldDefinitions?: Array<FieldBuilderDefinition
|
|
12
|
+
export declare function createFieldBuilderImpl<TObject extends object, TMap = {}, TPlugins = {}, TDeclaredFields extends string = never>(plugins: TPlugins, chainableBuilder: any, fieldDefinitions?: Array<FieldBuilderDefinition<TObject, TPlugins, any>>, isStrict?: boolean): FieldBuilder<TObject, TMap, TPlugins, TDeclaredFields>;
|
|
13
13
|
export declare const FieldBuilderImpl: any;
|
|
@@ -117,11 +117,12 @@ import type { FieldBuilderContext } from "../plugins/plugin-types";
|
|
|
117
117
|
/**
|
|
118
118
|
* Field definition for deferred building
|
|
119
119
|
*/
|
|
120
|
-
export interface FieldBuilderDefinition {
|
|
120
|
+
export interface FieldBuilderDefinition<TObject extends object = any, TPlugins = any, TFieldType = any> {
|
|
121
121
|
path: string;
|
|
122
|
-
builderFunction: (context: FieldBuilderContext<
|
|
122
|
+
builderFunction: (context: FieldBuilderContext<TObject, TPlugins, TFieldType>) => any;
|
|
123
123
|
inferredType?: string;
|
|
124
|
-
fieldOptions?: import("../types/field-options").FieldOptions<
|
|
124
|
+
fieldOptions?: import("../types/field-options").FieldOptions<TFieldType>;
|
|
125
|
+
fieldType?: TFieldType;
|
|
125
126
|
}
|
|
126
127
|
import type { FieldBuilder } from "../plugins/plugin-types";
|
|
127
128
|
import type { ComposablePlugin } from "../plugins/composable-plugin";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var le=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var tt=Object.prototype.hasOwnProperty;var rt=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},nt=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of et(t))!tt.call(e,r)&&r!==n&&le(e,r,{get:()=>t[r],enumerable:!(a=Xe(t,r))||a.enumerable});return e};var at=e=>nt(le({},"__esModule",{value:!0}),e);var Qt={};rt(Qt,{Builder:()=>oe,Result:()=>A,createPluginRegistry:()=>ze,getGlobalConfig:()=>Ze,globalConfig:()=>Q,plugin:()=>qe,pluginBuilderExtension:()=>Ye,pluginConfigurableTransform:()=>He,pluginPredefinedTransform:()=>Ge,resetGlobalConfig:()=>Je,setGlobalConfig:()=>Qe});module.exports=at(Qt);function Z(e){if(e!==void 0)return typeof e=="object"&&e!==null&&!Array.isArray(e)&&("default"in e||"description"in e||"deprecated"in e||"metadata"in e)?e:{default:e}}function K(e,t,n){if(!t||!("default"in t)||!(e===void 0||e===null&&t.applyDefaultToNull!==!1))return e;let r=t.default;return typeof r=="function"?r():r}function it(e,t){return{name:"LuqValidationException",message:e,errors:t,toString(){return`${this.name}: ${this.message}`}}}var st={isValid(){return!0},isError(){return!1},data(){return this._data},unwrap(){return this._data},unwrapOr(e){return this._data},unwrapOrElse(e){return this._data},map(e){return A.ok(e(this._data))},flatMap(e){return e(this._data)},tap(e){return e(this._data),this},tapError(e){return this},onSuccessPostProcess(e){return e(this._data),this},errors(){return[]},toPlainObject(){return{valid:!0,data:this._data,errors:[]}},get valid(){return!0},get value(){return this._data}},A={ok(e){let t=Object.create(st);return t._data=e,t},error(e){return ce({isValid:!1,data:void 0,errors:e})}};function ce(e){return{isValid(){return e.isValid},isError(){return!e.isValid},unwrap(){if(e.isValid)return e.data;throw it(`Validation failed with ${e.errors.length} error(s)`,e.errors)},unwrapOr(n){return e.isValid?e.data:n},unwrapOrElse(n){return e.isValid?e.data:n(e.errors)},map(n){return e.isValid?A.ok(n(e.data)):A.error(e.errors)},flatMap(n){return e.isValid?n(e.data):A.error(e.errors)},tap(n){return e.isValid&&n(e.data),ce(e)},tapError(n){return e.isValid||n(e.errors),ce(e)},data(){return e.isValid?e.data:void 0},toPlainObject(){return{valid:e.isValid,data:e.isValid?e.data:void 0,errors:e.isValid?[]:e.errors}},get valid(){return e.isValid},get errors(){return e.isValid?[]:e.errors}}}var Fe;(a=>{function e(r){let s=[],o=r.length;for(let i=0;i<o;i++){let c=r[i];if(c.isError())return A.error(c.errors);s.push(c.unwrap())}return A.ok(s)}a.all=e;function t(r){let s=[],o=r.length;for(let i=0;i<o;i++){let c=r[i];if(c.isValid())return c;s.push(...c.errors)}return A.error(s)}a.any=t;function n(r){let s=[],o=[],i=r.length;for(let c=0;c<i;c++){let l=r[c];l.isValid()?s.push(l.unwrap()):o.push(l.errors)}return{valid:s,invalid:o}}a.partition=n})(Fe||(Fe={}));var er=Object.freeze({valid:!0}),tr=Object.freeze({valid:!1});function Ve(e,t,n,a){let r=t.methodName,s=null,o=null;e[r]=function(...i){if(s||(s=t.createComposer(n,a)),s.add(i),e[r]=s[r],s){o=s.build();let c=e._executionPlan;if(!(c&&o&&typeof o.validate=="function")){if(o&&o._validators)for(let l of o._validators)c.addValidator(l.name,(h,g)=>{let b=l.check(h,h);return{valid:b,message:b?void 0:`Validation failed for ${l.name}`}})}}return e}}function ot(e){switch(e){case"string":return{check:t=>t==null?!0:typeof t=="string",name:"stringType",messageFactory:()=>"Expected string",inputType:"string",outputType:"string",metadata:{severity:"error",async:!1}};case"number":return{check:t=>t==null?!0:typeof t=="number"&&!isNaN(t),name:"numberType",messageFactory:()=>"Expected number",inputType:"number",outputType:"number",metadata:{severity:"error",async:!1}};case"boolean":return{check:t=>t==null?!0:typeof t=="boolean",name:"booleanType",messageFactory:()=>"Expected boolean",inputType:"boolean",outputType:"boolean",metadata:{severity:"error",async:!1}};case"array":return{check:t=>t==null?!0:Array.isArray(t),name:"arrayType",messageFactory:()=>"Expected array",inputType:"array",outputType:"array",metadata:{severity:"error",async:!1}};case"object":return{check:t=>t==null?!0:typeof t=="object"&&t!==null&&!Array.isArray(t),name:"objectType",messageFactory:()=>"Expected object",inputType:"object",outputType:"object",metadata:{severity:"error",async:!1}};case"date":return{check:t=>t==null?!0:t instanceof Date,name:"dateType",messageFactory:()=>"Expected Date",inputType:"date",outputType:"date",metadata:{severity:"error",async:!1}};case"null":return{check:t=>t===null,name:"nullType",messageFactory:()=>"Expected null",inputType:"null",outputType:"null",metadata:{severity:"error",async:!1}};case"any":return{check:()=>!0,name:"anyType",messageFactory:()=>"",inputType:"any",outputType:"any",metadata:{severity:"error",async:!1}};default:return null}}function S(e,t,n,a){let r=a?.validators?[...a.validators]:[];if(!a&&e!=="union"){let i=ot(e);i&&r.push(i)}let s=a?.transforms?[...a.transforms]:[],o={_type:e,_fieldPath:t,_validators:r,_transforms:s,build(){return e==="union"&&r.length===0&&r.push({check:()=>!1,name:"unionGuard",messageFactory:()=>"No union type guards defined",inputType:"union",outputType:"union",metadata:{severity:"error",async:!1}}),{_validators:r,_transforms:s}}};return lt(o,e,t,n,r,s),o.refineString=()=>S("string",t,n,{validators:r,transforms:s}),o.refineNumber=()=>S("number",t,n,{validators:r,transforms:s}),o.refineBoolean=()=>S("boolean",t,n,{validators:r,transforms:s}),o.refineArray=()=>S("array",t,n,{validators:r,transforms:s}),o.refineObject=()=>S("object",t,n,{validators:r,transforms:s}),o.refineTuple=()=>S("tuple",t,n,{validators:r,transforms:s}),o.refineUnion=()=>S("union",t,n,{validators:r,transforms:s}),o.refineDate=()=>S("date",t,n,{validators:r,transforms:s}),o.refineAny=()=>S("any",t,n,{validators:r,transforms:s}),o}function lt(e,t,n,a,r,s){let o=Object.entries(a),i=o.length;for(let c=0;c<i;c++){let[,l]=o[c];if(!l||typeof l!="object")continue;if(l.category?.startsWith("composable")){if(l.allowedTypes&&!l.allowedTypes.includes(t))continue;Ve(e,l,n,a);continue}if(typeof l.create!="function"||l.allowedTypes&&!l.allowedTypes.includes(t))continue;let{methodName:h,category:g="standard",name:b}=l,d=l.create();e[h]=function(...u){try{let f=d(...u);if(g==="transform"){let m=ct(f,u[0]);s.push(m)}else{let m=dt(f,n),y=ut(m,b||h,t,u,f);r.push(y)}}catch{}return e}}}function ct(e,t){return typeof e=="function"?t:e?.__isTransform?e.__transformFn:e?.__isCoerce?n=>e.coerce.coerceFn(n):e?.__isDefault?(n,a)=>e.default.applyDefault(n,a):e?.__isPreprocess?(n,a)=>e.preprocess.applyPreprocess(n,a):t||(n=>n)}function dt(e,t){return typeof e=="function"?(n,a)=>e(n,{path:t,allValues:a}).valid:e?.check?(n,a)=>e.check(n,a):()=>!1}function ut(e,t,n,a,r){let s={check:e,name:t,code:r?.code||t,pluginName:r?.pluginName||t,getErrorMessage:r?.getErrorMessage,messageFactory:a[a.length-1]?.messageFactory||r?.messageFactory||(()=>"Validation failed"),inputType:n,outputType:n,metadata:r?.metadata||{severity:"error",async:!1}};return r&&(r.shouldSkipAllValidation&&(s.shouldSkipAllValidation=r.shouldSkipAllValidation),r.shouldSkipValidation&&(s.shouldSkipValidation=r.shouldSkipValidation),r.shouldSkipFurtherValidation&&(s.shouldSkipFurtherValidation=r.shouldSkipFurtherValidation),r.skipForNull!==void 0&&(s.skipForNull=r.skipForNull),r.skipForUndefined!==void 0&&(s.skipForUndefined=r.skipForUndefined),r.__isRecursive&&(s.__isRecursive=r.__isRecursive),r.recursive&&(s.recursive=r.recursive)),s}function U(e,t){let n=S("string",e,t),a=S("number",e,t),r=S("boolean",e,t),s=S("array",e,t),o=S("object",e,t),i=S("union",e,t),c=S("tuple",e,t),l=S("date",e,t),h=S("any",e,t);return{string:n,number:a,boolean:r,date:l,array:s,tuple:c,union:i,object:o,any:h}}function J(e){let t=e.split(".");return{segments:t,isArrayElement:!1,arrayPath:void 0,elementKey:void 0,depth:t.length}}function z(e){let t=J(e),n;if(t.depth===1){let a=t.segments[0];n=r=>r?.[a]}else if(t.depth===2){let[a,r]=t.segments;n=s=>s?.[a]?.[r]}else if(t.depth===3){let[a,r,s]=t.segments;n=o=>o?.[a]?.[r]?.[s]}else n=a=>{let r=a;for(let s of t.segments){if(r==null)return;r=r[s]}return r};return n}function Pe(e){let t=J(e),n;if(t.depth===1){let a=t.segments[0];n=(r,s)=>{r!=null&&(r[a]=s)}}else if(t.depth===2){let[a,r]=t.segments;n=(s,o)=>{s!=null&&(s[a]||(s[a]={}),s[a][r]=o)}}else if(t.depth===3){let[a,r,s]=t.segments;n=(o,i)=>{o!=null&&(o[a]||(o[a]={}),o[a][r]||(o[a][r]={}),o[a][r][s]=i)}}else n=(a,r)=>{if(a==null)return;let s=a,o=t.segments;for(let i=0;i<o.length-1;i++){let c=o[i];s[c]||(s[c]={}),s=s[c]}s[o[o.length-1]]=r};return n}function ft(e,t){return z(t)(e)}function yt(e,t,n){Pe(t)(e,n)}function Ee(e){let t=J(e);return!t.isArrayElement||!t.arrayPath||!t.elementKey?null:{arrayPath:t.arrayPath,elementPath:t.elementKey,indexPattern:new RegExp(`${t.arrayPath.replace(/\./g,"\\.")}\\[(\\d+)\\]\\.${t.elementKey.replace(/\./g,"\\.")}`)}}function pt(e){let t=z(e);return n=>{let a=t(n);return Array.isArray(a)?a:[]}}function gt(e){let t=new Map;for(let n of e){let a=Ee(n);if(a){let{arrayPath:r,elementPath:s}=a;t.has(r)||t.set(r,{arrayPath:r,elementFields:[]}),t.get(r).elementFields.push(s)}}return t}function ht(e){return e.map(t=>({fieldName:t.split(".").pop()||t,path:t,accessor:z(t)}))}function mt(e){return!e||typeof e!="string"?!1:e.split(".").every(n=>n.length>0&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(n))}function Tt(e){return e.split(".").filter(t=>t.length>0).join(".")}function bt(e,t){let n=e.split("."),a=t.split(".");return n.length!==a.length?n.length-a.length:e.localeCompare(t)}function Ft(){}function Vt(){return{pathCacheSize:0,accessorCacheSize:0,setterCacheSize:0}}var Ae={parseFieldPath:J,createFieldAccessor:z,createFieldSetter:Pe,getNestedValue:ft,setNestedValue:yt,analyzeArrayField:Ee,createArrayAccessor:pt,groupArrayFields:gt,createBatchAccessors:ht,isValidFieldPath:mt,normalizeFieldPath:Tt,compareFieldPaths:bt,clearCache:Ft,getCacheStats:Vt};function Pt(e,t){let n=e.params||[];if(n.length>0){let a=n[0];if(typeof a=="number")return{expected:a,actual:typeof t=="string"?t.length:t};if(typeof a=="string")return{pattern:a,expected:a}}return{}}function X(e,t,n){let a=e.code||e.pluginName||"VALIDATION_ERROR",r="Validation failed";try{if(e.getErrorMessage)r=e.getErrorMessage(t,n.path,n.allValues,n.arrayContext);else if(e.messageFactory){let s={path:n.path,value:t,code:a,...Pt(e,t)};r=e.messageFactory(s)}}catch{r=`Validation failed for ${n.path}`}return{path:n.path,code:a,message:r}}function Et(e){if(typeof e=="function")return e;let t=e;if(t.apply&&typeof t.apply=="function")return t.apply;if(t.transformFn&&typeof t.transformFn=="function")return t.transformFn;throw new Error("Invalid transform function")}function Re(e,t){if(!t.includes("."))return e?.[t];let n=t.indexOf(".");if(n>0&&t.indexOf(".",n+1)===-1){let r=t.substring(0,n),s=t.substring(n+1);return e?.[r]?.[s]}return z(t)(e)}function ue(e){if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let r=e.length,s=new Array(r);for(let o=0;o<r;o++)s[o]=ue(e[o]);return s}let t={},n=Object.keys(e),a=n.length;for(let r=0;r<a;r++){let s=n[r];t[s]=ue(e[s])}return t}function fe(e,t,n,a={}){let{abortEarly:r=!0}=a,s=e.validators.length;if(s===0)return{valid:!0,errors:[]};if(s===1){let i=e.validators[0],c=i.check;if(typeof c!="function")throw new Error("Invalid validator: check function is not defined");try{return c(t,n.allValues,n.arrayContext)?{valid:!0,errors:[]}:{valid:!1,errors:[X(i,t,n)]}}catch{return{valid:!1,errors:[X(i,t,n)]}}}let o=[];for(let i=0;i<s;i++){let c=e.validators[i];if(c.metadata?.type==="conditional"&&c.metadata?.category==="skip"){let l=c.check;if(typeof l=="function")try{if(l(t,n.allValues,n.arrayContext))return{valid:!0,errors:[]}}catch{}}}for(let i=0;i<s;i++){let c=e.validators[i],l=c.check;if(typeof l!="function")throw new Error("Invalid validator: check function is not defined");let h=!1;try{h=l(t,n.allValues,n.arrayContext)}catch{h=!1}if(!h&&(o.push(X(c,t,n)),r))break}return{valid:o.length===0,errors:o}}function At(e,t,n={}){let{abortEarly:a=!1,abortEarlyOnEachField:r=!0}=n,s=[],o=e.length;for(let i=0;i<o;i++){let c=e[i],l=Re(t,c.path),h={originalValue:l,currentValue:l,allValues:t,path:c.path},g=fe(c,l,h,{abortEarly:r});if(!g.valid&&(s.push(...g.errors),a))break}return{valid:s.length===0,errors:s}}function Oe(e,t,n,a={}){let{abortEarly:r=!0}=a,s=fe(e,t,n,{abortEarly:r});if(!s.valid)return{valid:!1,errors:s.errors};let o=t;try{o=xe(e.transforms,t,n)}catch(i){return{valid:!1,errors:[{path:n.path,code:"TRANSFORM_ERROR",message:`Transform failed: ${i instanceof Error?i.message:"Unknown error"}`}]}}return{valid:!0,data:o,errors:[]}}function xe(e,t,n){let a=t,r=e.length;for(let s=0;s<r;s++)a=Et(e[s])(a,n);return a}function Ot(e,t,n,a=!0,r){let s=e.validators.length;if(s===0)return{valid:!0};if(s===1){let i=e.validators[0].check;if(typeof i!="function")return{valid:!1,errorIndices:[0]};try{return i(t,n,r)?{valid:!0}:{valid:!1,errorIndices:[0]}}catch{return{valid:!1,errorIndices:[0]}}}if(a){for(let i=0;i<s;i++){let c=e.validators[i].check;if(typeof c!="function")return{valid:!1,errorIndices:[i]};let l=!1;try{l=c(t,n,r)}catch{l=!1}if(!l)return{valid:!1,errorIndices:[i]}}return{valid:!0}}let o=[];for(let i=0;i<s;i++){let c=e.validators[i].check;if(typeof c!="function"){o.push(i);continue}let l=!1;try{l=c(t,n,r)}catch{l=!1}l||o.push(i)}return o.length===0?{valid:!0}:{valid:!1,errorIndices:o}}function Rt(e,t,n,a,r){let s={originalValue:n,currentValue:n,allValues:a,path:e.path,arrayContext:r};return t.filter(o=>o<e.validators.length).map(o=>{let i=e.validators[o];return X(i,n,s)})}function xt(){let e=new Map,t=r=>{let s=e.get(r);if(!s){if(!r.includes("."))s=(o,i)=>{o!=null&&(o[r]=i)};else{let o=r.split("."),i=o.length-1;s=(c,l)=>{let h=c;for(let g=0;g<i;g++){let b=o[g];h[b]||(h[b]={}),h=h[b]}h[o[i]]=l}}e.set(r,s)}return s},n=(r,s,o)=>{if(!s.includes(".")){r!=null&&(r[s]=o);return}t(s)(r,o)};return{validateField:fe,validateBatch:At,parseField:Oe,parseBatch:(r,s,o={})=>{let{abortEarly:i=!1,abortEarlyOnEachField:c=!0}=o,l=[],h=ue(s),g=r.length;for(let b=0;b<g;b++){let d=r[b],u=Re(s,d.path),f={originalValue:u,currentValue:u,allValues:s,path:d.path},m=Oe(d,u,f,{abortEarly:c});if(m.valid)m.data!==void 0&&n(h,d.path,m.data);else if(l.push(...m.errors),i)break}return{valid:l.length===0,data:l.length===0?h:void 0,errors:l}},applyTransforms:xe,validateHoisted:Ot,reconstructErrors:Rt}}var de=null;function ve(){return de||(de=xt()),de}var gr=ve();function ke(e,t){let n=e.length,a=!1,r=!1;for(let c of e)vt(c.builderFunction).some(h=>kt(h,t))&&(a=!0),Ae.parseFieldPath(c.path).isArrayElement&&(r=!0);let s,o,i;return r?(s="array_batch",o="Array fields detected - using batch processing",i=!0):a?(s="definition_order",o="Transforms detected - using definition order",i=!1):(s="fast_separated",o="No transforms or arrays - using fast separated execution",i=!0),{strategy:s,reason:o,canOptimize:i,hasTransforms:a,hasArrayFields:r,fieldCount:n}}function vt(e){let t=e.toString(),n=/\.(\w+)\(/g,a=[],r;for(;(r=n.exec(t))!==null;)a.push(r[1]);return a}function kt(e,t){return Object.values(t).find(a=>a?.methodName===e)?.category==="transform"||e==="transform"||e.startsWith("to")}function ye(e,t){let n=ke(e,t),a=new Map;for(let r of e)a.set(r.path,n);return a}function je(e){let t=[],n=[];return e.forEach((a,r)=>{a.strategy==="fast_separated"?t.push(r):n.push(r)}),{fastFields:t,slowFields:n}}var _=".",D="validate",k="parse";function G(e,t,n="fast_separated",a){let r=U(e.path,t),s=e.builderFunction(r);s&&typeof s.build=="function"&&(s=s.build());let o=s._validators||[],i=s._transforms||[],c=e.path,l=o.some(T=>T.shouldSkipAllValidation||T.shouldSkipValidation),h=i.length>0;if(!l&&!h&&o.length<=10&&n==="fast_separated")return jt(o,c);if(!l&&h&&o.length<=10&&i.length<=5&&n==="fast_separated")return Nt(o,i,c);let d=n==="definition_order"||l;return{validate:d?(T,p,P)=>{let E=P?.abortEarlyOnEachField!==!1,R=Ne(T,p,o,i,c,E,D);return{valid:R.valid,errors:R.errors}}:(T,p,P={})=>{let E=P.abortEarlyOnEachField!==!1;return we(T,p,o,i,c,E,D)},parse:d?(T,p,P)=>{let E=P?.abortEarlyOnEachField!==!1;return Ne(T,p,o,i,c,E,k)}:(T,p,P={})=>{let E=P.abortEarlyOnEachField!==!1;return we(T,p,o,i,c,E,k)},accessor:a}}function Ne(e,t,n,a,r,s,o=k){let i=[],c=e,l=n.some(b=>b.skipForNull===!0),h=n.some(b=>b.skipForUndefined===!0);if(e===null&&l||e===void 0&&h)return o===k?{valid:!0,data:e,errors:[]}:{valid:!0,data:void 0,errors:[]};let g=n.length;for(let b=0;b<g;b++){let d=n[b];if(d.shouldSkipAllValidation&&typeof d.shouldSkipAllValidation=="function"&&d.shouldSkipAllValidation(c,t))break;let u=d.check||d;if(typeof u=="function"&&!u(c,t)){let f={path:r,code:d.code||d.pluginName||"VALIDATION_ERROR",message:C(d,c,r,t)};if(s)return{valid:!1,data:void 0,errors:[f]};i.push(f)}}if(i.length>0)return{valid:!1,data:void 0,errors:i};if(o===k&&a.length>0){let b=[];for(let u=0;u<a.length;u++){let f=a[u];typeof f=="function"?b.push(f):f&&typeof f.apply=="function"&&b.push(f.apply)}let d=b.length;if(d===1)c=b[0](c);else if(d===2)c=b[0](c),c=b[1](c);else if(d>0)for(let u=0;u<d;u++)c=b[u](c)}return o===D?W:{valid:!0,data:c,errors:[]}}function we(e,t,n,a,r,s,o=k){let i=[],c=n.length,l=n.some(d=>d.skipForNull===!0),h=n.some(d=>d.skipForUndefined===!0);if(e===null&&l||e===void 0&&h)return o===k?{valid:!0,data:e,errors:[]}:{valid:!0,data:void 0,errors:[]};for(let d=0;d<c;d++){let u=n[d];if(u.shouldSkipAllValidation&&typeof u.shouldSkipAllValidation=="function"&&u.shouldSkipAllValidation(e,t))break;let f=u.check||u;if(typeof f=="function"&&!f(e,t)){if(s)return{valid:!1,data:void 0,errors:[{path:r,code:u.code||u.pluginName||"VALIDATION_ERROR",message:C(u,e,r,t)}]};i.push({path:r,code:u.code||u.pluginName||"VALIDATION_ERROR",message:C(u,e,r,t)})}}if(o===D)return i.length===0?W:{valid:!1,errors:i};if(i.length>0)return{valid:!1,data:void 0,errors:i};let g=e,b=a.length;if(b>0){let d=[];for(let f=0;f<b;f++){let m=a[f];typeof m=="function"?d.push(m):m&&typeof m.apply=="function"&&d.push(m.apply)}let u=d.length;if(u===1)g=d[0](g);else if(u===2)g=d[0](g),g=d[1](g);else if(u>0)for(let f=0;f<u;f++)g=d[f](g)}return{valid:!0,data:g,errors:[]}}function jt(e,t,n){let a=[],r=[],s=[],o=[],i=e.length;for(let b=0;b<i;b++){let d=e[b];a.push(d.check||d),r.push(d.code||d.pluginName||"VALIDATION_ERROR"),d.getErrorMessage&&typeof d.getErrorMessage=="function"||d.messageFactory?(s.push(""),o.push(!0)):(s.push(`Validation failed for ${t}`),o.push(!1))}let c=a.length,l={path:t,code:"",message:""},h;if(c===1){let b=a[0],d=r[0],u=s[0],f=o[0];h=(m,y,F)=>b(m,y)?W:(l.code=d,l.message=f?C(e[0],m,t,y):u,{valid:!1,errors:[{path:l.path,code:l.code,message:l.message}]})}else if(c===2){let b=a[0],d=a[1],u=r[0],f=r[1],m=s[0],y=s[1],F=o[0],V=o[1];h=(T,p,P)=>{if(!b(T,p)){if(P?.abortEarlyOnEachField!==!1)return l.code=u,l.message=F?C(e[0],T,t,p):m,{valid:!1,errors:[{path:l.path,code:l.code,message:l.message}]};let E=[{path:t,code:u,message:F?C(e[0],T,t,p):m}];return d(T,p)||E.push({path:t,code:f,message:V?C(e[1],T,t,p):y}),{valid:!1,errors:E}}return d(T,p)?W:(l.code=f,l.message=V?C(e[1],T,t,p):y,{valid:!1,errors:[{path:l.path,code:l.code,message:l.message}]})}}else h=(b,d,u)=>{for(let f=0;f<c;f++)if(!a[f](b,d)){if(u?.abortEarlyOnEachField!==!1)return l.code=r[f],l.message=o[f]?C(e[f],b,t,d):s[f],{valid:!1,errors:[{path:l.path,code:l.code,message:l.message}]};let m=[];m.push({path:t,code:r[f],message:o[f]?C(e[f],b,t,d):s[f]});for(let y=f+1;y<c;y++)a[y](b,d)||m.push({path:t,code:r[y],message:o[y]?C(e[y],b,t,d):s[y]});return{valid:!1,errors:m}}return W};return{validate:h,parse:(b,d,u={})=>{let f=h(b,d,u);return f.valid?{valid:!0,data:b,errors:[]}:{valid:!1,data:void 0,errors:f.errors}},accessor:n}}var W=Object.freeze({valid:!0,errors:[]});function C(e,t,n,a){if(e.getErrorMessage)try{return e.getErrorMessage(t,n,a)}catch{return`Validation failed for ${n}`}else if(e.messageFactory)try{let r={path:n,value:t,code:e.code||e.pluginName||"VALIDATION_ERROR"};return e.messageFactory(r)}catch{return`Validation failed for ${n}`}return`Validation failed for ${n}`}function Nt(e,t,n,a){let r=e.length,s=t.length,o=new Array(r),i=new Array(r);for(let d=0;d<r;d++){let u=e[d];o[d]=u.check||u,i[d]=u.code||u.pluginName||"VALIDATION_ERROR"}let c=new Array(s),l=0;for(let d=0;d<s;d++){let u=t[d];typeof u=="function"?c[l++]=u:u&&typeof u.apply=="function"&&(c[l++]=u.apply)}if(r===1&&l===1){let d=o[0],u=i[0],f=c[0],m=e[0],y={valid:!1,errors:[{path:n,code:u,message:""}]},F={valid:!1,data:void 0,errors:[{path:n,code:u,message:""}]},V={valid:!0,data:null,errors:[]};return{validate:(T,p,P)=>d(T,p)?W:(y.errors[0].message=C(m,T,n,p),y),parse:(T,p,P)=>d(T,p)?(V.data=f(T),V):(F.errors[0].message=C(m,T,n,p),F)}}if(r===2&&l===1){let d=o[0],u=o[1],f=i[0],m=i[1],y=c[0],F=e[0],V=e[1],T={valid:!1,errors:[{path:n,code:f,message:""}]},p={valid:!1,errors:[{path:n,code:m,message:""}]},P={valid:!1,data:void 0,errors:[{path:n,code:f,message:""}]},E={valid:!1,data:void 0,errors:[{path:n,code:m,message:""}]},R={valid:!0,data:null,errors:[]};return{validate:(x,O,v)=>d(x,O)?u(x,O)?W:(p.errors[0].message=C(V,x,n,O),p):(T.errors[0].message=C(F,x,n,O),T),parse:(x,O,v)=>d(x,O)?u(x,O)?(R.data=y(x),R):(E.errors[0].message=C(V,x,n,O),E):(P.errors[0].message=C(F,x,n,O),P)}}let h={path:n,code:"",message:""};return{validate:(d,u,f={})=>{for(let m=0;m<r;m++)if(!o[m](d,u)){if(f.abortEarlyOnEachField!==!1)return h.code=e[m].code||e[m].pluginName||"VALIDATION_ERROR",h.message=C(e[m],d,n,u),{valid:!1,errors:[{...h}]};let y=[];y.push({path:n,code:e[m].code||e[m].pluginName||"VALIDATION_ERROR",message:C(e[m],d,n,u)});for(let F=m+1;F<r;F++)o[F](d,u)||y.push({path:n,code:e[F].code||e[F].pluginName||"VALIDATION_ERROR",message:C(e[F],d,n,u)});return{valid:!1,errors:y}}return W},parse:(d,u,f={})=>{let m=e.some(V=>V.skipForNull===!0),y=e.some(V=>V.skipForUndefined===!0);if(d===null&&m||d===void 0&&y)return{valid:!0,data:d,errors:[]};for(let V=0;V<r;V++)if(!o[V](d,u)){if(f.abortEarlyOnEachField!==!1)return h.code=e[V].code||e[V].pluginName||"VALIDATION_ERROR",h.message=C(e[V],d,n,u),{valid:!1,data:void 0,errors:[{...h}]};let T=[];T.push({path:n,code:e[V].code||e[V].pluginName||"VALIDATION_ERROR",message:C(e[V],d,n,u)});for(let p=V+1;p<r;p++)o[p](d,u)||T.push({path:n,code:e[p].code||e[p].pluginName||"VALIDATION_ERROR",message:C(e[p],d,n,u)});return{valid:!1,data:void 0,errors:T}}let F=d;if(l===1)F=c[0](F);else if(l===2)F=c[0](F),F=c[1](F);else if(l>0)for(let V=0;V<l;V++)F=c[V](F);return{valid:!0,data:F,errors:[]}},accessor:a}}function ge(e){if(e.length===0)return t=>t;if(e.length===1){let t=e[0];return n=>n?.[t]}if(e.length===2){let[t,n]=e;return a=>a?.[t]?.[n]}if(e.length===3){let[t,n,a]=e;return r=>r?.[t]?.[n]?.[a]}if(e.length===4){let[t,n,a,r]=e;return s=>s?.[t]?.[n]?.[a]?.[r]}if(e.length===5){let[t,n,a,r,s]=e;return o=>o?.[t]?.[n]?.[a]?.[r]?.[s]}return t=>{let n=t,a=e.length;for(let r=0;r<a;r++){let s=e[r];if(n=n?.[s],n===void 0)return}return n}}function pe(e){return ge(e.split(_))}function he(e){let t=pe(e);return n=>t(n)!==void 0}function ee(e){let t=e.split(_);if(t.length===1){let n=t[0];return(a,r)=>{a[n]=r}}if(t.length===2){let[n,a]=t;return(r,s)=>{r[n]||(r[n]={}),r[n][a]=s}}if(t.length===3){let[n,a,r]=t;return(s,o)=>{s[n]||(s[n]={}),s[n][a]||(s[n][a]={}),s[n][a][r]=o}}return(n,a)=>{let r=n;for(let s=0;s<t.length-1;s++){let o=t[s];r[o]||(r[o]={}),r=r[o]}r[t[t.length-1]]=a}}function $(e){if(!e.includes(_))return a=>a[e];let t=e.split(_),n=t.length;if(n===2){let[a,r]=t;return s=>{let o=s[a];return Array.isArray(o)?o:o!=null&&typeof o=="object"?o[r]:void 0}}return a=>{let r=a;for(let s=0;s<n;s++){if(r==null||typeof r!="object")return;let o=t[s],i=r[o];if(Array.isArray(i)&&s<n-1){let c=t.slice(s+1).join(".");return{__isArrayElementField:!0,values:i.map(h=>{if(h==null||typeof h!="object")return;if(c.indexOf(".")===-1)return h[c];let g=h,b=t.slice(s+1),d=b.length;for(let u=0;u<d;u++){if(g==null||typeof g!="object")return;g=g[b[u]]}return g}),arrayPath:t.slice(0,s+1).join(".")}}r=i}return r}}function te(e){if(!e.includes("[*]"))return{hasArrayElements:!1,segments:e.split(_).map(s=>({name:s,isArrayElement:!1}))};let n=e.split(_),a=[];for(let s of n)if(s.endsWith("[*]")){let o=s.slice(0,-3);a.push({name:o,isArrayElement:!0})}else a.push({name:s,isArrayElement:!1});let r=a.findIndex(s=>s.isArrayElement);if(r!==-1){let s=a.slice(0,r+1).map(i=>i.name).join(_),o=a.slice(r+1).map(i=>i.name).join(_);return{hasArrayElements:!0,segments:a,baseArrayPath:s,elementPath:o||""}}return{hasArrayElements:!0,segments:a}}function me(e){let t=te(e);if(!t.hasArrayElements||!t.baseArrayPath)return()=>null;let n=pe(t.baseArrayPath),a=t.elementPath||"";return r=>{let s=n(r);if(!Array.isArray(s))return null;let o;if(a==="")o=s;else{let i=pe(a);o=s.map(c=>i(c))}return{elements:o,basePath:t.baseArrayPath,elementPath:a}}}function re(e){let t=e.match(/^(.+\[\*\])\[\*\]$/);if(t)return{isArrayElementPath:!0,arrayPath:t[1],elementField:""};if(e.match(/^(.+?)(\[\*\]\.(.+))?$/)&&e.includes("[*].")){let o=e.split(/\[\*\]\./);if(o.length>=2){let i=o[o.length-1];if(i.includes("[*]")){let c=i.replace(/\[\*\]$/,"");return{isArrayElementPath:!0,arrayPath:o.slice(0,-1).concat(c).join("."),elementField:""}}else return{isArrayElementPath:!0,arrayPath:o.slice(0,-1).join("."),elementField:i}}}let a=e.match(/^([^\[]+)\[\*\]\.(.+)$/);if(a)return{isArrayElementPath:!0,arrayPath:a[1],elementField:a[2]};let r=e.match(/^([^\[]+)\[\*\]$/);if(r)return{isArrayElementPath:!0,arrayPath:r[1],elementField:""};let s=e.match(/^([^\.]+)\.\*\.(.+)$/);return s?{isArrayElementPath:!0,arrayPath:s[1],elementField:s[2]}:{isArrayElementPath:!1}}function Ce(e){let t=[],n=new Set;for(let o of e){let i=re(o.path);if(i.isArrayElementPath&&i.arrayPath){if(n.add(i.arrayPath),i.elementField&&i.elementField.includes("[*]")){let c=`${i.arrayPath}.${i.elementField.split("[*]")[0]}`;n.add(c)}t.push({...o,originalPath:o.path})}else t.push(o)}for(let o of n)t.some(i=>i.path===o&&i.isArrayField)||t.push({path:o,isArrayField:!0});let a=new Set;for(let o of t)if(o.originalPath){let i=re(o.originalPath);if(i.isArrayElementPath&&i.elementField&&i.elementField.includes("[*]")){let c=i.elementField.split("[*]")[0],l=`${i.arrayPath}.${c}`;!a.has(l)&&!t.some(h=>h.path===l&&h.isArrayField)&&a.add(l)}}for(let o of a)t.push({path:o,isArrayField:!0});let r=t.filter(o=>o.isArrayField?o.path.includes("[*]")?!!o.path.match(/\[\*\]$/):!0:!1);r.sort((o,i)=>{let c=o.path.split(".").length,l=i.path.split(".").length;return c-l});let s=new Map;for(let o of r){let i=o.path,c=i.split(".").length-1,l;for(let f of s.keys())i.startsWith(f+".")?(!l||f.length>l.length)&&(l=f):i.startsWith(f+"[*]")&&f!==i&&(!l||f.length>l.length)&&(l=f);let h=t.filter(f=>{let m=f.originalPath||f.path,y=re(m);return y.isArrayElementPath&&y.arrayPath===i?!0:m.startsWith(i+".")});if(h.length===0)continue;let g=[],b=[];for(let f of h){let m=f.originalPath||f.path,y=re(m),F;y.isArrayElementPath&&y.arrayPath===i&&y.elementField!==void 0?F=y.elementField:F=m.substring(i.length+1),r.some(T=>T.path!==i&&T.path.startsWith(i+".")&&f.path.startsWith(T.path+"."))||g.push(F),f.isArrayField||b.push(f.originalPath||f.path)}let d=new Map;for(let f of g){let m=f.split(".");d.set(f,ge(m))}let u={arrayPath:i,elementFields:g,fullFieldPaths:b,validators:new Map,accessors:d,childArrays:new Map,depth:c,parentPath:l};s.set(i,u)}for(let[o,i]of s)if(i.parentPath){let c=s.get(i.parentPath);if(c){let l;o.startsWith(i.parentPath+".")?l=o.substring(i.parentPath.length+1):o.startsWith(i.parentPath+"[*]")?l=o.substring(i.parentPath.length):l=o.substring(i.parentPath.length+1),c.childArrays.set(l,i)}}return s}function Te(e,t){if(e.validators.size===0)for(let n of e.fullFieldPaths){let a=t.get(n);a&&e.validators.set(n,a)}return function(a,r,s,o=!0,i=D,c=""){let l=[],h=i===k?[...a]:void 0,g=!1;if(!Array.isArray(a))return{errors:l,transformedData:h};for(let b=0;b<a.length;b++){let d=a[b],u=i===k?typeof d=="object"&&d!==null?{...d}:d:void 0,f=!1,m=c?`${c}[${b}]`:`${e.arrayPath}[${b}]`;for(let y of e.elementFields){if(y===""){let O=null,v=`${e.arrayPath}[*]`;if(O=e.validators.get(v),!O)for(let M of e.fullFieldPaths){let q=e.validators.get(M);if(q){O=q;break}}if(!O)continue;let N=u||d,w=m,j;if(i===D)if(O.validate)j=O.validate(N,r,{abortEarlyOnEachField:g});else if(O.validateSlow)j=O.validateSlow(N,r,{abortEarlyOnEachField:g});else if(O.validateFast)j=O.validateFast(N,r);else continue;else if(i===k)if(O.parse)j=O.parse(N,r,{abortEarlyOnEachField:g});else if(O.parseSlow)j=O.parseSlow(N,r,{abortEarlyOnEachField:g});else if(O.parseFast)j=O.parseFast(N,r);else continue;else continue;if(j.valid)i===k&&j.data!==void 0&&h&&(h[b]=j.data);else{if(f=!0,j.errors&&j.errors.length>0)for(let M of j.errors)l.push({path:w,code:M.code||(i===k?"PARSE_ERROR":"VALIDATION_ERROR"),message:M.message||(i===k?"Parse failed":"Validation failed"),paths:()=>[w]});else l.push({path:w,code:i===k?"PARSE_ERROR":"VALIDATION_ERROR",message:i===k?"Parse failed":"Validation failed",paths:()=>[w]});if(g)break}continue}let F=`${e.arrayPath}.${y}`,V=`${e.arrayPath}[*].${y}`,T=`${e.arrayPath}.*.${y}`,p=e.validators.get(F);if(p||(p=e.validators.get(V)),p||(p=e.validators.get(T)),!p)for(let O of e.fullFieldPaths){let v=e.validators.get(O);if(v&&O.includes(y)){p=v;break}}if(!p)continue;let P=e.accessors.get(y),E=P?P(u||d):void 0,R=`${m}.${y}`,x;if(i===D)if(p.validate)x=p.validate(E,r,{abortEarlyOnEachField:g});else if(p.validateSlow)x=p.validateSlow(E,r,{abortEarlyOnEachField:g});else if(p.validateFast)x=p.validateFast(E,r);else continue;else if(i===k)if(p.parse)x=p.parse(E,r,{abortEarlyOnEachField:g});else if(p.parseSlow)x=p.parseSlow(E,r,{abortEarlyOnEachField:g});else if(p.parseFast)x=p.parseFast(E,r);else continue;else continue;if(x.valid)i===k&&x.data!==void 0&&u&&wt(u,y,x.data);else{if(f=!0,x.errors&&x.errors.length>0)for(let O of x.errors)l.push({path:R,code:O.code||(i===k?"PARSE_ERROR":"VALIDATION_ERROR"),message:O.message||(i===k?"Parse failed":"Validation failed"),paths:()=>[R]});else l.push({path:R,code:i===k?"PARSE_ERROR":"VALIDATION_ERROR",message:i===k?"Parse failed":"Validation failed",paths:()=>[R]});if(g)break}}for(let[y,F]of e.childArrays){let V,T;if(y.startsWith("[*]")?(V=u||d,T=m):(V=u?.[y]||d[y],T=`${m}.${y}`),Array.isArray(V)){let P=Te(F,t)(V,r,s,o,i,T);P.errors.length>0&&(l.push(...P.errors),f=!0),i===k&&P.transformedData&&u&&(u[y]=P.transformedData)}}if(i===k&&h&&u&&typeof u=="object"&&(h[b]=u),f&&s)return{errors:l,transformedData:h}}return{errors:l,transformedData:h}}}function wt(e,t,n){ee(t)(e,n)}function Ct(e){let t=Ce(e),n=new Map;for(let[a,r]of t)if(!r.parentPath){let s=Me(r,t),o={arrayPath:r.arrayPath,elementFields:r.elementFields,fullFieldPaths:s,validators:r.validators,accessors:r.accessors,_nestedInfo:r};n.set(a,o)}return n}function Me(e,t){let n=[];n.push(...e.fullFieldPaths);for(let[a,r]of e.childArrays){let s=Me(r,t);n.push(...s)}return n}function Ie(e){return Ct(e)}function ne(e,t){if(e._nestedInfo){for(let a of e.fullFieldPaths){let r=t.get(a);r&&e._nestedInfo.validators.set(a,r)}let n=Te(e._nestedInfo,t);return function(r,s,o,i=!0,c=D){let l=n(r,s,o,i,c);return{errors:l.errors,transformedData:l.transformedData}}}for(let n of e.fullFieldPaths){let a=t.get(n);a&&e.validators.set(n,a)}return function(a,r,s,o=!0,i=D){if(e.optimizedValidator&&(e.arrayStructure?.depth??0)>1){let g=e.optimizedValidator(a,r,{abortEarly:s,abortEarlyOnEachField:o,mode:i});return{errors:g.errors,transformedData:g.transformedData}}let l=[];if(!Array.isArray(a))return{errors:l};if(a.length===0)return{errors:l};let h=i===k?[...a]:void 0;for(let g=0;g<a.length;g++){let b=a[g],d=i===k?{...b}:void 0,u=!1;for(let f of e.elementFields){let m=`${e.arrayPath}.${f}`,y=e.validators.get(m);if(!y)continue;let F=e.accessors.get(f),V=F?F(d||b):void 0,T=`${e.arrayPath}[${g}].${f}`,p;if(i===D)p=y.validate(V,r,{abortEarlyOnEachField:!1});else if(i===k)p=y.parse(V,r,{abortEarlyOnEachField:!1});else continue;if(p.isValid())i===k&&p.data!==void 0&&d&&Mt(d,f,p.data);else if(u=!0,p.errors&&p.errors.length>0)for(let P of p.errors)l.push({path:T,code:P.code||(i===k?"PARSE_ERROR":"VALIDATION_ERROR"),message:P.message||(i===k?"Parse failed":"Validation failed"),paths:()=>[T]});else l.push({path:T,code:i===k?"PARSE_ERROR":"VALIDATION_ERROR",message:i===k?"Parse failed":"Validation failed",paths:()=>[T]})}if(i===k&&h&&d&&(h[g]=d),u&&s)return{errors:l,transformedData:h}}return{errors:l,transformedData:h}}}function Mt(e,t,n){ee(t)(e,n)}function Se(e){return Object.freeze(e.split(_))}function It(e){let t=e.length;switch(t){case 0:return y=>y;case 1:let n=e[0];return y=>y?.[n];case 2:let a=e[0],r=e[1];return y=>y?.[a]?.[r];case 3:let s=e[0],o=e[1],i=e[2];return y=>y?.[s]?.[o]?.[i];case 4:let c=e[0],l=e[1],h=e[2],g=e[3];return y=>y?.[c]?.[l]?.[h]?.[g];case 5:let b=e[0],d=e[1],u=e[2],f=e[3],m=e[4];return y=>y?.[b]?.[d]?.[u]?.[f]?.[m];default:return y=>{let F=y;for(let V=0;V<t;V++)if(F=F?.[e[V]],F===void 0)return;return F}}}function ae(e){let t=Se(e);return It(t)}function ie(e){let t=Se(e),n=t.length,a;switch(n){case 1:let r=t[0];a=(h,g)=>{h[r]=g};break;case 2:let s=t[0],o=t[1];a=(h,g)=>{h[s]||(h[s]={}),h[s][o]=g};break;case 3:let i=t[0],c=t[1],l=t[2];a=(h,g)=>{h[i]||(h[i]={}),h[i][c]||(h[i][c]={}),h[i][c][l]=g};break;default:a=(h,g)=>{let b=h;for(let d=0;d<n-1;d++){let u=t[d];b[u]||(b[u]={}),b=b[u]}b[t[n-1]]=g}}return a}function _e(e){let t=Array.from(e),n=t.length;if(n===0)return{validateRaw:()=>!0,parseRaw:a=>({valid:!0,data:a}),validate:a=>A.ok(a),parse:a=>A.ok(a)};if(n===1){let[a,r]=t[0],s=!a.includes("."),o=s?null:ae(a),i=s?null:ie(a);return{validateRaw:(c,l)=>{if(!c)return!1;let h=s?c[a]:o(c);return r.validate(h,c,l).valid},parseRaw:(c,l)=>{if(!c)return{valid:!1,error:"Value required"};let h=s?c[a]:o(c),g=r.parse(h,c,l);if(!g.valid)return{valid:!1,error:g.errors[0]};if(g.data!==void 0&&g.data!==h){let b={...c};return s?b[a]=g.data:i(b,g.data),{valid:!0,data:b}}return{valid:!0,data:c}},validate:(c,l)=>{if(!c)return A.error([{path:"",message:"Value required",code:"REQUIRED",paths:()=>[""]}]);let h=s?c[a]:o(c),g=r.validate(h,c,l);if(!g.valid){let b=g.errors.map(d=>({path:d.path,code:d.code,message:d.message,paths:()=>[d.path]}));return A.error(b)}return A.ok(c)},parse:function(c,l){let h=this.parseRaw(c,l);return h.valid?A.ok(h.data):A.error([h.error])}}}return n<=3?St(t):_t(t)}function St(e){let t=e.map(([n,a])=>({path:n,isSimple:!n.includes("."),accessor:n.includes(".")?ae(n):null,setter:n.includes(".")?ie(n):null,validator:a}));return t.sort((n,a)=>n.isSimple&&!a.isSimple?-1:!n.isSimple&&a.isSimple?1:0),{validateRaw:n=>{if(!n)return!1;if(t.length===2){let r=t[0],s=t[1],o=r.isSimple?n[r.path]:r.accessor(n);if(!r.validator.validate(o,n).valid)return!1;let i=s.isSimple?n[s.path]:s.accessor(n);return!!s.validator.validate(i,n).valid}else if(t.length===3){let r=t[0],s=t[1],o=t[2],i=r.isSimple?n[r.path]:r.accessor(n);if(!r.validator.validate(i,n).valid)return!1;let c=s.isSimple?n[s.path]:s.accessor(n);if(!s.validator.validate(c,n).valid)return!1;let l=o.isSimple?n[o.path]:o.accessor(n);return!!o.validator.validate(l,n).valid}let a=t.length;for(let r=0;r<a;r++){let s=t[r],o=s.isSimple?n[s.path]:s.accessor(n);if(!s.validator.validate(o,n).valid)return!1}return!0},parseRaw:n=>{if(!n)return{valid:!1,error:"Value required"};let a=!1,r=n;if(t.length===2){let s=t[0],o=t[1],i=s.isSimple?r[s.path]:s.accessor(r),c=s.validator.parse(i,r);if(!c.valid)return{valid:!1,error:c.errors[0]};c.data!==void 0&&c.data!==i&&(a||(r={...n},a=!0),s.isSimple?r[s.path]=c.data:s.setter(r,c.data));let l=o.isSimple?r[o.path]:o.accessor(r),h=o.validator.parse(l,r);if(!h.valid)return{valid:!1,error:h.errors[0]};h.data!==void 0&&h.data!==l&&(a||(r={...n},a=!0),o.isSimple?r[o.path]=h.data:o.setter(r,h.data))}else if(t.length===3){let s=t[0],o=t[1],i=t[2],c=s.isSimple?r[s.path]:s.accessor(r),l=s.validator.parse(c,r);if(!l.valid)return{valid:!1,error:l.errors[0]};l.data!==void 0&&l.data!==c&&(a||(r={...n},a=!0),s.isSimple?r[s.path]=l.data:s.setter(r,l.data));let h=o.isSimple?r[o.path]:o.accessor(r),g=o.validator.parse(h,r);if(!g.valid)return{valid:!1,error:g.errors[0]};g.data!==void 0&&g.data!==h&&(a||(r={...n},a=!0),o.isSimple?r[o.path]=g.data:o.setter(r,g.data));let b=i.isSimple?r[i.path]:i.accessor(r),d=i.validator.parse(b,r);if(!d.valid)return{valid:!1,error:d.errors[0]};d.data!==void 0&&d.data!==b&&(a||(r={...n},a=!0),i.isSimple?r[i.path]=d.data:i.setter(r,d.data))}else{let s=t.length;for(let o=0;o<s;o++){let i=t[o],c=i.isSimple?r[i.path]:i.accessor(r),l=i.validator.parse(c,r);if(!l.valid)return{valid:!1,error:l.errors[0]};l.data!==void 0&&l.data!==c&&(a||(r={...n},a=!0),i.isSimple?r[i.path]=l.data:i.setter(r,l.data))}}return{valid:!0,data:r}},validate:function(n){return this.validateRaw(n)?A.ok(n):A.error([{path:"",code:"VALIDATION_ERROR",message:"Validation failed",paths:()=>[""]}])},parse:function(n){let a=this.parseRaw(n);return a.valid?A.ok(a.data):A.error([a.error])}}}function _t(e){let t=e.map(([n,a])=>({path:n,isSimple:!n.includes("."),accessor:n.includes(".")?ae(n):null,setter:n.includes(".")?ie(n):null,validator:a}));return t.sort((n,a)=>n.isSimple&&!a.isSimple?-1:!n.isSimple&&a.isSimple?1:0),{validateRaw:n=>{if(!n)return!1;let a=t.length;for(let r=0;r<a;r++){let s=t[r],o=s.isSimple?n[s.path]:s.accessor(n);if(!s.validator.validate(o,n).valid)return!1}return!0},parseRaw:n=>{if(!n)return{valid:!1,error:"Value required"};let a=n,r=!1,s=t.length;for(let o=0;o<s;o++){let i=t[o],c=i.isSimple?a[i.path]:i.accessor(a),l=i.validator.parse(c,a);if(!l.valid)return{valid:!1,error:l.errors[0]};l.data!==void 0&&l.data!==c&&(r||(a={...n},r=!0),i.isSimple?a[i.path]=l.data:i.setter(a,l.data))}return{valid:!0,data:a}},validate:function(n){return this.validateRaw(n)?A.ok(n):A.error([{path:"",code:"VALIDATION_ERROR",message:"Validation failed",paths:()=>[""]}])},parse:function(n){let a=this.parseRaw(n);return a.valid?A.ok(a.data):A.error([a.error])}}}var Bt=[],tn=Object.freeze({valid:!0,value:null,errors:Bt});function Le(e){function t(n){if(n.length===0)return Dt(e);let a=n.map(p=>{let P=!1,E=!1;if(p.builderFunction)try{let R=U(p.path,e),x=p.builderFunction(R);x?._validators&&(P=x._validators.some(O=>O.name==="optional"),E=x._validators.some(O=>O.name==="required"))}catch{P=!1,E=!1}return{path:p.path,builderFunction:p.builderFunction||(()=>{throw new Error(`Field ${p.path} uses object definition form`)}),isOptional:P,hasRequired:E}}),r=ye(a,e),{fastFields:s,slowFields:o}=je(r),i=Ie(n),c=new Set,l=new Map,h=new Map;for(let[p,P]of i)if(P._nestedInfo){l.set(p,P);for(let E of P.fullFieldPaths)c.add(E);c.add(p)}else{h.set(p,P);for(let E of P.fullFieldPaths)c.add(E)}let g=s.filter(p=>!c.has(p)),b=o.filter(p=>!c.has(p)),d=be(b,n.filter(p=>!c.has(p.path)),e),u=be(g,n.filter(p=>!c.has(p.path)),e),f=new Map,m=n.map(p=>p.path),y=be(m,n,e);for(let[p,P]of y)f.set(p,P);let F=new Map,V=new Map,T=new Map;for(let p of a)p.isOptional&&F.set(p.path,!0),p.hasRequired&&V.set(p.path,!0);for(let p of n)p.metadata?.fieldOptions&&T.set(p.path,p.metadata.fieldOptions);for(let[p,P]of f)p.includes("[*]")&&(u.has(p)&&u.set(p,P),d.has(p)&&d.set(p,P));return $t(d,u,n,e,l,f,F,V,T)}return{buildOptimizedValidator:t}}function Dt(e){let t=se([],e);return{validate:()=>A.ok({}),parse:(n,a)=>A.ok(n),pick:n=>t.createPickedValidator(n)}}function be(e,t,n){let a=new Map,r=new Map,s=new Map;for(let o of e){let i=t.find(c=>c.path===o);if(i&&i.builderFunction){let c=$(o),l=U(o,n),h=i.builderFunction(l);if(h&&typeof h.build=="function"&&(h=h.build()),h._validators?.some?.(d=>d.__isRecursive===!0)){let d=h._validators.find(u=>u.__isRecursive===!0);if(d?.recursive){let u={targetFieldPath:d.recursive.targetFieldPath,maxDepth:d.recursive.maxDepth||10};o.includes("[*]")?s.set(o,u):r.set(o,u)}}let b=G({path:i.path,builderFunction:i.builderFunction||(()=>({}))},n,"fast_separated",c);a.set(o,b)}}for(let[o,i]of r){let c=a.get(o),l=null;if(i.targetFieldPath==="__Self")l=null;else if(i.targetFieldPath==="__Element")l=null;else{let g=t.find(b=>b.path===i.targetFieldPath);g&&g.builderFunction&&(l=a.get(i.targetFieldPath)||null)}let h=zt(c,l,o,i.targetFieldPath,i.maxDepth,t.filter(g=>g.builderFunction).map(g=>({path:g.path,builderFunction:g.builderFunction})),n,a);a.set(o,h)}for(let[o,i]of s){let c=a.get(o),h=te(o).baseArrayPath+"[*]";if(Array.from(a.keys()).filter(b=>b.startsWith(h)&&b!==o).length>0){let b=qt(c,o,i.targetFieldPath,i.maxDepth,t.filter(d=>d.builderFunction).map(d=>({path:d.path,builderFunction:d.builderFunction})),n,a);a.set(o,b)}}return a}function $t(e,t,n,a,r,s,o,i,c){let l=r.size>0,h=e.size>0,g=t.size+e.size,b=!l&&!h&&t.size<=10;if((process.env.LUQ_ULTRA_FAST==="true"||global.__LUQ_ULTRA_FAST__===!0)&&!l&&g<=50){let V=new Map([...t,...e]),T=_e(V),p=se(n.map(R=>({path:R.path,builderFunction:R.builderFunction||(()=>({})),fieldType:R.fieldType||"unknown"})),a);return{validate:(R,x)=>{if(R==null)return A.error([{path:"",message:"Value is required",code:"REQUIRED",paths:()=>[""]}]);let O=R;if(c&&c.size>0){let v={...O};for(let[N,w]of c){let j=I(v,N),M=K(j,w,{allValues:v});M!==j&&B(v,N,M)}O=v}return T.validate(O,x)},parse:(R,x)=>{if(R==null)return A.error([{path:"",message:"Value is required",code:"REQUIRED",paths:()=>[""]}]);let v={...R};if(c&&c.size>0)for(let[N,w]of c){let j=I(v,N),M=K(j,w,{allValues:v});M!==j&&B(v,N,M)}return T.parse(v,x)},pick:R=>p.createPickedValidator(R),validateRaw:T.validateRaw.bind(T),parseRaw:T.parseRaw.bind(T)}}if(b)return Lt(t,n.map(V=>({path:V.path,builderFunction:V.builderFunction||(()=>({}))})),a,c);let f=Kt(e,t,r,s,o,i,c),m=n.map(V=>({path:V.path,builderFunction:V.builderFunction||(()=>({})),fieldType:V.fieldType||"unknown"})),y={validate:(V,T)=>f.executeValidate(V,T),parse:(V,T)=>f.executeParse(V,T),pick:null},F=se(m,a,void 0,y);return y.pick=V=>F.createPickedValidator(V),y}function Lt(e,t,n,a){let r=Array.from(e),s=r.length,o=[];for(let g=0;g<s;g++){let[b,d]=r[g];o.push({path:b,accessor:d.accessor||$(b),validator:d})}let i=t.map(g=>({path:g.path,builderFunction:g.builderFunction||(()=>({})),fieldType:g.fieldType||"unknown"})),c=se(i,n),l=[],h=A.ok({});if(s===1){let{path:g,accessor:b,validator:d}=o[0];return{validate:(u,f)=>{if(u==null)return A.error([{path:"",message:"Value is required",code:"REQUIRED",paths:()=>[""]}]);let m=u;if(a&&a.size>0){let V={...m};for(let[T,p]of a){let P=I(V,T),E=K(P,p,{allValues:V});E!==P&&B(V,T,E)}m=V}let y=b(m),F=d.validate(y,m,f);if(!F.valid){let V=F.errors.map(T=>({path:T.path,code:T.code,message:T.message,paths:()=>[T.path]}));return A.error(V)}return A.ok(u)},parse:(u,f)=>{if(u==null)return A.error([{path:"",message:"Value is required",code:"REQUIRED",paths:()=>[""]}]);let m=u,y={...m};if(a&&a.size>0)for(let[T,p]of a){let P=I(y,T),E=K(P,p,{allValues:y});E!==P&&B(y,T,E)}let F=b(y),V=d.parse(F,m,f);if(!V.valid){let T=V.errors.map(p=>({path:p.path,code:p.code,message:p.message,paths:()=>[p.path]}));return A.error(T)}return V.data!==void 0&&V.data!==F?(B(y,g,V.data),A.ok(y)):A.ok(y)},pick:u=>c.createPickedValidator(u)}}return{validate:(g,b)=>{if(g==null)return A.error([{path:"",message:"Value is required",code:"REQUIRED",paths:()=>[""]}]);let d=g;if(a&&a.size>0){let m={...d};for(let[y,F]of a){let V=I(m,y),T=K(V,F,{allValues:m});T!==V&&B(m,y,T)}d=m}let u=b?.abortEarly!==!1,f=b?.abortEarlyOnEachField!==!1;l.length=0;for(let m=0;m<s;m++){let{path:y,accessor:F,validator:V}=o[m],T=F(d),p=V.validate(T,d,{abortEarlyOnEachField:f});if(!p.valid){let P=p.errors;for(let E=0;E<P.length;E++){let R=P[E];l.push({path:R.path,code:R.code,message:R.message,paths:()=>[R.path]})}if(u)return A.error(l.slice())}}return l.length>0?A.error(l.slice()):A.ok(g)},parse:(g,b)=>{if(g==null)return A.error([{path:"",message:"Value is required",code:"REQUIRED",paths:()=>[""]}]);let u={...g};if(a&&a.size>0)for(let[y,F]of a){let V=I(u,y),T=K(V,F,{allValues:u});T!==V&&B(u,y,T)}let f=b?.abortEarly!==!1,m=b?.abortEarlyOnEachField!==!1;l.length=0;for(let y=0;y<s;y++){let{path:F,accessor:V,validator:T}=o[y],p=V(u),P=T.parse(p,u,{abortEarlyOnEachField:m});if(P.valid)P.data!==void 0&&B(u,F,P.data);else{let E=P.errors;for(let R=0;R<E.length;R++){let x=E[R];l.push({path:x.path,code:x.code,message:x.message,paths:()=>[x.path]})}if(f)return A.error(l.slice())}}return l.length>0?A.error(l.slice()):A.ok(u)},pick:g=>c.createPickedValidator(g)}}function Kt(e,t,n,a,r,s,o){let i=new Map,c=new Map;for(let[g,b]of t)i.has(g)||(i.set(g,b.accessor||$(g)),c.set(g,he(g)));for(let[g,b]of e)i.has(g)||(i.set(g,b.accessor||$(g)),c.set(g,he(g)));function l(g,b){if(g==null)return A.error([{path:"",message:"Value is required",code:"REQUIRED",paths:()=>[""]}]);let d=[],u=g;if(o&&o.size>0){let y={...u};for(let[F,V]of o){let T=I(y,F),p=K(T,V,{allValues:y});p!==T&&B(y,F,p)}u=y}let f=b?.abortEarly!==!1,m=b?.abortEarlyOnEachField!==!1;for(let[y,F]of n){let V=i.get(y)||$(y);i.has(y)||i.set(y,V);let T=V(u),p=a.get(y);if(p){let P;if(p.validate?P=p.validate(T,u,{abortEarlyOnEachField:m}):p.validateSlow?P=p.validateSlow(T,u,{abortEarlyOnEachField:m}):p.validateFast&&(P=p.validateFast(T,u)),P&&!P.valid){if(P.errors&&P.errors.length>0?d.push(...P.errors):d.push({path:y,code:"VALIDATION_ERROR",message:"Array field validation failed",paths:()=>[y]}),f)return A.error(d);continue}}if(Array.isArray(T)){let E=ne(F,a)(T,u,f,m,D);if(E.errors.length>0&&(d.push(...E.errors),f))return A.error(d)}}for(let[y,F]of t){if(y.includes(".")&&!y.includes("[")&&!y.includes("*")){let V=y.split(".");if(V.length>1){let T=!1;for(let p=0;p<V.length-1;p++){let P=V.slice(0,p+1).join("."),E=I(u,P);if(Array.isArray(E)&&E.length===0){T=!0;break}}if(T)continue}}if(!y.includes("[")&&!y.includes("*")){let V=i.get(y),T=V?V(u):I(u,y),p=F.validate(T,u,{abortEarlyOnEachField:m});if(!p.valid){if(p.errors&&p.errors.length>0)for(let P=0;P<p.errors.length;P++)d.push(p.errors[P]);if(f)return A.error(d)}}else{if(y.includes("[*]")||y.includes(".*")){let E=De(y,F,u,u,f,m);if(E.length>0&&(d.push(...E),f))return A.error(d);continue}let T=i.get(y),p=T?T(u):I(u,y),P=F.validate(p,u,{abortEarlyOnEachField:m});if(!P.valid){if(P.errors&&P.errors.length>0)for(let E=0;E<P.errors.length;E++)d.push(P.errors[E]);if(f)return A.error(d)}}}for(let[y,F]of e){if(y.includes(".")&&!y.includes("[")&&!y.includes("*")){let v=y.split(".");if(v.length>1){let N=!1;for(let w=0;w<v.length-1;w++){let j=v.slice(0,w+1).join("."),M=I(u,j);if(Array.isArray(M)&&M.length===0){N=!0;break}}if(N)continue}}if(y.includes("[*]")||y.includes(".*")){let v=De(y,F,u,u,f,m);if(v.length>0&&(d.push(...v),f))return A.error(d);continue}let T=c.get(y),p=T?T(u):Be(u,y),P=r.get(y)||!1,E=s.get(y)||!1;if(!p&&P)continue;if(!p&&!P&&!E){if(d.push({path:y,code:"REQUIRED",message:`Field '${y}' is required`,paths:()=>[y]}),f)return A.error(d);continue}let R=i.get(y),x=R?R(u):I(u,y),O=F.validate(x,u,{abortEarlyOnEachField:m});if(!O.valid){if(O.errors&&O.errors.length>0)for(let v=0;v<O.errors.length;v++)d.push(O.errors[v]);if(f)return A.error(d)}}return d.length>0?A.error(d):A.ok(g)}function h(g,b){if(g==null)return A.error([{path:"",message:"Value is required",code:"REQUIRED",paths:()=>[""]}]);let d=[],f={...g};if(o&&o.size>0)for(let[F,V]of o){let T=I(f,F),p=K(T,V,{allValues:f});p!==T&&B(f,F,p)}let m=b?.abortEarly!==!1,y=b?.abortEarlyOnEachField!==!1;for(let[F,V]of n){let T=i.get(F)||$(F);i.has(F)||i.set(F,T);let p=T(f),P=a.get(F);if(P){let E;if(P.parse?E=P.parse(p,f,{abortEarlyOnEachField:y}):P.parseSlow?E=P.parseSlow(p,f,{abortEarlyOnEachField:y}):P.parseFast&&(E=P.parseFast(p,f)),E&&!E.valid){if(E.errors&&E.errors.length>0?d.push(...E.errors):d.push({path:F,code:"PARSE_ERROR",message:"Array field parsing failed",paths:()=>[F]}),m)return A.error(d);continue}else if(E&&E.data!==void 0){B(f,F,E.data);let R=T(f);if(Array.isArray(R)){let O=ne(V,a)(R,f,m,y,k);if(O.errors.length>0&&(d.push(...O.errors),m))return A.error(d);O.transformedData&&B(f,F,O.transformedData)}continue}}if(Array.isArray(p)){let R=ne(V,a)(p,f,m,y,k);if(R.errors.length>0&&(d.push(...R.errors),m))return A.error(d);R.transformedData&&B(f,F,R.transformedData)}}for(let[F,V]of t){let T=i.get(F),p=T?T(f):I(f,F),P=V.parse(p,f,{abortEarlyOnEachField:y});if(P.valid)P.data!==void 0&&B(f,F,P.data);else{if(P.errors&&P.errors.length>0)for(let E=0;E<P.errors.length;E++)d.push(P.errors[E]);if(m)return A.error(d)}}for(let[F,V]of e){let T=c.get(F),p=T?T(f):Be(f,F),P=r.get(F)||!1,E=s.get(F)||!1;if(!p&&P)continue;if(!p&&!P&&!E){if(d.push({path:F,code:"REQUIRED",message:`Field '${F}' is required`,paths:()=>[F]}),m)return A.error(d);continue}let R=i.get(F),x=R?R(f):I(f,F),O=V.parse(x,f,{abortEarlyOnEachField:y});if(O.valid)O.data!==void 0&&B(f,F,O.data);else{if(O.errors&&O.errors.length>0)for(let v=0;v<O.errors.length;v++)d.push(O.errors[v]);if(m)return A.error(d)}}return d.length>0?A.error(d):A.ok(f)}return{executeValidate:l,executeParse:h}}function I(e,t){return $(t)(e)}function Ut(e){if(e.includes(_)){let t=e.split(_),n=t.length-1;return a=>{let r=a;for(let o=0;o<n;o++){let i=t[o];if(!(i in r)||r[i]==null||typeof r[i]!="object")return!1;r=r[i]}return t[n]in r}}else return t=>e in t}function Be(e,t){return Ut(t)(e)}function Wt(e){if(e.includes(_)){let t=e.split(_),n=t.length-1;return(a,r)=>{let s=a;for(let o=0;o<n;o++){let i=t[o];(!(i in s)||typeof s[i]!="object")&&(s[i]={}),s=s[i]}s[t[n]]=r}}else return(t,n)=>{t[e]=n}}function B(e,t,n){Wt(t)(e,n)}function De(e,t,n,a,r,s){let o=[],i,c,l=e.match(/^([^\[]+)\[\*\]\.(.+)$/);if(l)i=l[1],c=l[2];else{let g=e.match(/^([^\.]+)\.\*\.(.+)$/);if(g)i=g[1],c=g[2];else{let b=e.match(/^([^\[]+)\[\*\]$/);if(b)i=b[1],c="";else return o}}let h=I(n,i);if(!Array.isArray(h))return o;if(c===""){for(let g=0;g<h.length;g++){let b=h[g],d=`${i}[${g}]`,u=t.validate(b,a,{abortEarlyOnEachField:s});if(!u.valid){if(u.errors&&u.errors.length>0)for(let f of u.errors)o.push({path:f.path?`${d}.${f.path}`:d,code:f.code||"VALIDATION_ERROR",message:f.message||"Validation failed",paths:()=>[f.path?`${d}.${f.path}`:d]});else o.push({path:d,code:"VALIDATION_ERROR",message:"Validation failed",paths:()=>[d]});if(r)break}}return o}if(h.length===0)return o;for(let g=0;g<h.length;g++){let b=h[g];if(!b||typeof b!="object")continue;let d=I(b,c),u=`${i}[${g}].${c}`,f=t.validate(d,a,{abortEarlyOnEachField:s});if(!f.valid){if(f.errors&&f.errors.length>0)for(let m of f.errors)o.push({path:m.path||u,code:m.code||"VALIDATION_ERROR",message:m.message||"Validation failed",paths:()=>[m.path||u]});else o.push({path:u,code:"VALIDATION_ERROR",message:"Validation failed",paths:()=>[u]});if(r)break}}return o}function zt(e,t,n,a,r,s,o,i){let c=(l,h,g,b,d,u)=>{if(g>r)return{valid:!0,errors:[]};if(l&&typeof l=="object"&&d.has(l))return{valid:!0,errors:[]};if(l&&typeof l=="object"&&d.add(l),l==null){let m=e.validate(l,h,u);return m.valid?{valid:!0,errors:[]}:{valid:!1,errors:m.errors.map(F=>({...F,path:b}))}}let f=e.validate(l,h,u);if(!f.valid)return{valid:!1,errors:f.errors.map(y=>({...y,path:b}))};if(a==="__Self"){if(l&&typeof l=="object"&&i){let m=[];for(let[y,F]of i){if(y===n)continue;if(y.includes("[*]")){let E=me(y)(l);if(E){let{elements:R,basePath:x,elementPath:O}=E;R.forEach((v,N)=>{let w=F.validate(v,h,u);if(!w.valid)for(let j of w.errors){let M=O?`${b}.${x}[${N}].${O}`:`${b}.${x}[${N}]`;m.push({...j,path:M})}})}continue}let T=$(y)(l),p=F.validate(T,h,u);if(!p.valid)for(let P of p.errors)m.push({...P,path:`${b}.${P.path}`})}for(let[y,F]of i){if(y===n)continue;if(y.includes("[*]")){let p=me(y)(l);if(p){let{elements:P,basePath:E,elementPath:R}=p;P.forEach((x,O)=>{if(x&&typeof x=="object"){let v=s.find(N=>N.path===y);if(v?.builderFunction){let N=U(y,o),w=v.builderFunction(N);if(w?.build&&(w=w.build()),w?._validators?.some?.(M=>M.__isRecursive===!0)){let M=R?`${b}.${E}[${O}].${R}`:`${b}.${E}[${O}]`,q=c(x,h,g+1,M,d,u);q.valid||m.push(...q.errors)}}}})}continue}let V=$(y)(l);if(V&&typeof V=="object"){let T=s.find(E=>E.path===y),p=null;if(T?.builderFunction){let E=U(y,o);p=T.builderFunction(E),p?.build&&(p=p.build())}if(p?._validators?.some?.(E=>E.__isRecursive===!0)){let E=c(V,h,g+1,`${b}.${y}`,d,u);E.valid||m.push(...E.errors)}}}if(m.length>0)return{valid:!1,errors:m}}}else if(a==="__Element"){if(Array.isArray(l)){let m=[];for(let y=0;y<l.length;y++){let F=l[y];if(F&&typeof F=="object"&&i)for(let[V,T]of i){if(V.includes("[*]"))continue;let P=$(V)(F),E=T.validate(P,h,u);if(!E.valid)for(let R of E.errors)m.push({...R,path:`${b}[${y}].${R.path}`})}}if(m.length>0)return{valid:!1,errors:m}}}else if(t&&l&&typeof l=="object"){let m=[],y=u?.abortEarlyOnEachField!==!1,F=a.split("."),V=F[F.length-1];if(Array.isArray(l))for(let T=0;T<l.length;T++){let p=l[T];if(p&&typeof p=="object"&&V in p){let P=p[V],E=`${b}[${T}].${V}`,R=c(P,h,g+1,E,d,u);if(!R.valid&&(m.push(...R.errors),y))return{valid:!1,errors:m}}}else if(V in l){let T=l[V],p=`${b}.${V}`,P=c(T,h,g+1,p,d,u);if(!P.valid&&(m.push(...P.errors),y))return{valid:!1,errors:m}}if(m.length>0)return{valid:!1,errors:m}}return l&&typeof l=="object"&&d.delete(l),{valid:!0,errors:[]}};return{validate:(l,h,g)=>c(l,h,0,n,new WeakSet,g),parse:(l,h,g)=>{let d=c(l,h,0,n,new WeakSet,g);return d.valid?{valid:!0,data:l,errors:[]}:{...d,data:void 0}},accessor:e.accessor}}function qt(e,t,n,a,r,s,o){let i=te(t);return{validate:(c,l,h)=>{if(c==null||!Array.isArray(c))return e.validate(c,l,h);let g=[],b=new WeakSet;return c.forEach((d,u)=>{if(d&&typeof d=="object"&&n==="__Self"&&o){for(let[f,m]of o)if(f.includes("[*]")){let y=i.baseArrayPath+"[*]";if(f.startsWith(y)){let F=f.slice(y.length),V,T,p;if(F==="")continue;if(F.startsWith("."))p=F.slice(1),V=$(p)(d),T=i.baseArrayPath?`${i.baseArrayPath}[${u}].${p}`:`[${u}].${p}`;else continue;let P=m.validate(V,l,h);if(!P.valid)for(let E of P.errors)g.push({...E,path:T})}continue}for(let[f,m]of o)if(f.includes("[*]")){let y=i.baseArrayPath+"[*]";if(f.startsWith(y)){let F=f.slice(y.length);if(F.startsWith(".")){let V=F.slice(1),T=$(V)(d);Array.isArray(T)&&T.forEach((p,P)=>{if(p&&typeof p=="object"){for(let[E,R]of o)if(E.includes("[*]")&&E.startsWith(y)){let x=E.slice(y.length);if(x.startsWith(".")&&x!=="."+V){let O=x.slice(1),v=$(O)(p),N=`${i.baseArrayPath}[${u}].${V}[${P}].${O}`,w=R.validate(v,l,h);if(!w.valid)for(let j of w.errors)g.push({...j,path:N})}}}})}}}}}),{valid:g.length===0,errors:g}},parse:(c,l,h)=>e.parse(c,l,h),accessor:e.accessor}}function $e(e,t){let n="^"+t.replace(/\[\*\]/g,"\\[\\d+\\]")+"$";return new RegExp(n).test(e)}function se(e,t,n,a){function r(s){let o=s,i=e.find(f=>f.path===o),c=e.filter(f=>!!(f.path===o||f.path.startsWith(o+"[*]")||f.path.startsWith(o+".*")||f.path.startsWith(o+".")));if(!i&&c.length===0)return{validate:()=>({valid:!0,value:void 0,errors:[]}),parse:()=>({valid:!0,value:void 0,errors:[]})};if(c.length>1){let f=new Set(c.map(m=>m.path));return{validate:(m,y,F)=>{if(a){let T={[o]:m},p=a.validate(T,F),P=p.valid?[]:(p.errors||[]).filter(E=>{for(let R of f)if($e(E.path,R))return!0;return!1});return{valid:P.length===0,value:P.length===0?m:null,errors:P}}let V=[];for(let T of c){let P=G(T,t).validate({[o]:m},{[o]:m},F);!P.valid&&P.errors&&V.push(...P.errors)}return{valid:V.length===0,value:V.length===0?m:null,errors:V}},parse:(m,y,F)=>{if(a){let T={[o]:m},p=a.parse(T,F);if(!p.valid){let R=(p.errors||[]).filter(x=>{for(let O of f)if($e(x.path,O))return!0;return!1});if(R.length>0)return{valid:!1,value:void 0,errors:R}}let P=p.valid?p.value:T;return{valid:!0,value:P&&P[o]!==void 0?P[o]:m,errors:[]}}let V=[];for(let T of c){let P=G(T,t).validate({[o]:m},{[o]:m},F);!P.valid&&P.errors&&V.push(...P.errors)}return{valid:V.length===0,value:V.length===0?m:null,errors:V}}}}if(!i)return{validate:()=>({valid:!0,value:void 0,errors:[]}),parse:()=>({valid:!0,value:void 0,errors:[]})};let l=U(i.path,t);if(!i.builderFunction)throw new Error(`Field definition for path '${i.path}' is missing builderFunction`);let h=i.builderFunction(l),g={path:i.path,builderFunction:i.builderFunction||(()=>{throw new Error(`Field ${i.path} uses object definition form`)})},d=ye([g],t).get(i.path),u;return u=G(i,t),{validate:(f,m,y)=>{let F={...m};B(F,s,f);let V=I(F,s),T=u.validate(V,F,y);return{valid:T.valid,value:T.valid?f??null:null,errors:T.errors||[]}},parse:(f,m,y)=>{let F={...m};B(F,s,f);let V=I(F,s),T=u.parse(V,F,y);return{valid:T.valid,value:T.valid?T.data!==void 0?T.data:f:null,errors:T.errors||[]}}}}return{createPickedValidator:r}}function H(e,t,n=[],a=!1){let r=[...n],s=a,o,i=u=>u.includes(_)?"nested":"scalar",c=(u,f,m)=>{let y=m!==void 0?Z(m):void 0,F={path:u,inferredType:i(u),builderFunction:f,fieldOptions:y};return H(e,t,[...r,F],s)},l=c,h=(u,f)=>{let m={path:u,inferredType:i(u),builderFunction:()=>f,fieldOptions:f.fieldOptions};return H(e,t,[...r,m],s)},g=()=>H(e,t,r,!0);return{field:c,v:l,useField:h,strict:g,strictOnEditor:g,build:()=>{o||(o=Le(e));let u=r.map(f=>{let m=U(f.path,e),y=f.builderFunction(m);return{path:f.path,builderFunction:f.builderFunction,rules:Array.isArray(y)?y:[y],metadata:{inferredType:f.inferredType,hasTransforms:!1,fieldOptions:f.fieldOptions},fieldType:f.inferredType||"unknown"}});return o.buildOptimizedValidator(u)}}}function Gt(){let e={},t={for(){return H(e,t,void 0,!1)},use(...n){if(n.length===0)return t;for(let a=0;a<n.length;a++){let r=n[a];if(!r)continue;if(typeof r!="object"||!r.name)throw console.error("Invalid plugin:",r),new Error(`Invalid plugin at index ${a}: plugin must be an object with a 'name' property`);let s=r.name;e[s]||(e[s]=r,r.category==="builder-extension"&&r.extendBuilder&&typeof r.extendBuilder=="function"&&(r.methodName&&r.impl&&(t[r.methodName]=r.impl),r.extendBuilder(t),r.methodName&&!t[r.methodName]&&console.warn(`BuilderExtensionPlugin ${r.name} did not add ${r.methodName} method`)))}return t}};return t}function Ht(){return Gt()}var oe=Ht;function Ke(e,t){let n={plugins:e?new Map(e):new Map,pluginsObject:t||{}},a={use(r){n.plugins.set(r.name,r);let s={...n.pluginsObject,[r.name]:r};return Ke(n.plugins,s)},createFieldRule(r,s){return We(a,n.pluginsObject,r,s)},toBuilder(){let r=oe(),s=Array.from(n.plugins.values()),o=s.length;for(let i=0;i<o;i++){let c=s[i];r=r.use(c)}return r},getPlugins(){let r={},s=Array.from(n.plugins.entries()),o=s.length;for(let i=0;i<o;i++){let[c,l]=s[i];r[c]=l}return r},for(){return Ue(n.plugins,n.pluginsObject,a)}};return a}function Ue(e,t,n){return{use:n.use,toBuilder:n.toBuilder,getPlugins:n.getPlugins,createFieldRule(r,s){return We(n,t,r,s)},for(){return Ue(e,t,n)}}}function We(e,t,n,a){let r={};a!==void 0&&(typeof a=="object"&&a!==null&&("name"in a||"description"in a||"fieldOptions"in a)?r=a:r={fieldOptions:Z(a)});let s=()=>{let i=`__standalone__${r?.name||Math.random()}`,c=U(i,t),h=n(c).build();return{validate:(g,b,d)=>{let u=g;r?.fieldOptions&&(u=K(g,r.fieldOptions,{allValues:b||{}}));let f=h._validators||[],m=h._transforms||[];for(let F of f)if(F.check&&!F.check(u,b||{})){let V=typeof F.messageFactory=="function"?F.messageFactory({path:i,value:u,context:b||{}}):"Validation failed";return{valid:!1,errors:[{path:i,message:V,code:F.name||"VALIDATION_ERROR",paths:()=>[i]}],data:u}}let y=u;for(let F of m)typeof F=="function"?y=F(y):F&&typeof F.transformFn=="function"&&(y=F.transformFn(y));return{valid:!0,data:y,errors:[]}},_executionPlan:h._executionPlan,_validators:h._validators,_transforms:h._transforms}};return{_phantomType:void 0,name:r?.name,description:r?.description,fieldOptions:r?.fieldOptions,_getInternalValidators:()=>{let i=s();return{validators:i._validators||[],transforms:i._transforms||[],executionPlan:i._executionPlan}},validate(i,c){try{let h=s().validate(i,{},c);return h.valid?A.ok(h.data):A.error(h.errors||[])}catch(l){return A.error([{path:"",message:l instanceof Error?l.message:"Validation failed",code:"FIELD_RULE_ERROR",paths:()=>[""]}])}},parse(i,c){try{let l=i;r?.fieldOptions&&(l=K(i,r.fieldOptions,{allValues:{}}));let h=s();if(h._executionPlan&&typeof h._executionPlan.execute=="function"){let g={originalValue:l,currentValue:l,allValues:{},path:r?.name||"field",reporter:{report:()=>{},getReports:()=>[]}},b=h._executionPlan.execute(l,g);return b.valid?A.ok(b.finalValue):A.error(b.errors||[])}else{let g=l;if(h._transforms)for(let u of h._transforms)typeof u=="function"&&(g=u(g));let b=h._validators||[],d=r?.name||"field";for(let u of b)if(u.check&&!u.check(g,{})){let f=typeof u.messageFactory=="function"?u.messageFactory({path:d,value:g,context:{}}):"Validation failed";return A.error([{path:d,message:f,code:u.name||"VALIDATION_ERROR",paths:()=>[d]}])}return A.ok(g)}}catch(l){return A.error([{path:"",message:l instanceof Error?l.message:"Parse failed",code:"FIELD_RULE_PARSE_ERROR",paths:()=>[""]}])}},getPluginRegistry(){return e}}}function ze(){return Ke()}var Yt=(e,t,n,a)=>{let s=(o=>(...i)=>{let c=o(...i);return c&&typeof c=="object"&&"check"in c?{...c,pluginName:a}:c})(n);switch(e){case"conditional":return(o,...i)=>s(o,...i);case"fieldReference":return(o,...i)=>s(o,...i);case"multiFieldReference":return s;case"transform":return o=>s(o);case"arrayElement":return(o,...i)=>s(o,...i);case"context":return o=>s(o);default:return s}};function qe(e){let{name:t,methodName:n,allowedTypes:a,category:r,impl:s}=e;return{name:t,methodName:n,allowedTypes:a,category:r,create:()=>Yt(r,n,s,t)}}function Ge(e){let{name:t,allowedTypes:n,impl:a}=e,r=()=>a();return{name:t,methodName:t,allowedTypes:n,category:"transform",create:()=>r}}function He(e){let{name:t,allowedTypes:n,impl:a}=e,r=(...s)=>a(...s);return{name:t,methodName:t,allowedTypes:n,category:"transform",create:()=>r}}function Ye(e){let{name:t,methodName:n,impl:a,extendBuilder:r}=e;return{name:t,methodName:n,category:"builder-extension",impl:a(),extendBuilder:r}}var Y={messageKeyPrefix:"",toBooleanTruthyValues:["true","1","yes","on"],numberFormat:{decimalSeparator:".",thousandSeparator:","},dateFormat:"YYYY-MM-DD",trimStrings:!1,caseSensitive:!0,customTransforms:{}},L={...Y},Q={setConfig(e){L={...L,...e,numberFormat:e.numberFormat?{...L.numberFormat,...e.numberFormat}:L.numberFormat}},getConfig(){return{...L}},get messageKeyPrefix(){return L.messageKeyPrefix||""},get toBooleanTruthyValues(){return[...L.toBooleanTruthyValues||[]]},get numberFormat(){return{...L.numberFormat}},get dateFormat(){return L.dateFormat||"YYYY-MM-DD"},get trimStrings(){return L.trimStrings||!1},get caseSensitive(){return L.caseSensitive!==!1},get customTransforms(){return{...L.customTransforms}},reset(){L={...Y,numberFormat:{...Y.numberFormat},toBooleanTruthyValues:[...Y.toBooleanTruthyValues],customTransforms:{...Y.customTransforms}}}};function Qe(e){Q.setConfig(e)}function Ze(){return Q.getConfig()}function Je(){Q.reset()}0&&(module.exports={Builder,Result,createPluginRegistry,getGlobalConfig,globalConfig,plugin,pluginBuilderExtension,pluginConfigurableTransform,pluginPredefinedTransform,resetGlobalConfig,setGlobalConfig});
|
|
1
|
+
"use strict";var le=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var tt=Object.prototype.hasOwnProperty;var rt=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},nt=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of et(t))!tt.call(e,r)&&r!==n&&le(e,r,{get:()=>t[r],enumerable:!(a=Xe(t,r))||a.enumerable});return e};var at=e=>nt(le({},"__esModule",{value:!0}),e);var Qt={};rt(Qt,{Builder:()=>oe,Result:()=>A,createPluginRegistry:()=>ze,getGlobalConfig:()=>Ze,globalConfig:()=>Q,plugin:()=>qe,pluginBuilderExtension:()=>Ye,pluginConfigurableTransform:()=>He,pluginPredefinedTransform:()=>Ge,resetGlobalConfig:()=>Je,setGlobalConfig:()=>Qe});module.exports=at(Qt);function Z(e){if(e!==void 0)return typeof e=="object"&&e!==null&&!Array.isArray(e)&&("default"in e||"description"in e||"deprecated"in e||"metadata"in e)?e:{default:e}}function K(e,t,n){if(!t||!("default"in t)||!(e===void 0||e===null&&t.applyDefaultToNull!==!1))return e;let r=t.default;return typeof r=="function"?r():r}function it(e,t){return{name:"LuqValidationException",message:e,errors:t,toString(){return`${this.name}: ${this.message}`}}}var st={isValid(){return!0},isError(){return!1},data(){return this._data},unwrap(){return this._data},unwrapOr(e){return this._data},unwrapOrElse(e){return this._data},map(e){return A.ok(e(this._data))},flatMap(e){return e(this._data)},tap(e){return e(this._data),this},tapError(e){return this},onSuccessPostProcess(e){return e(this._data),this},errors(){return[]},toPlainObject(){return{valid:!0,data:this._data,errors:[]}},get valid(){return!0},get value(){return this._data}},A={ok(e){let t=Object.create(st);return t._data=e,t},error(e){return ce({isValid:!1,data:void 0,errors:e})}};function ce(e){return{isValid(){return e.isValid},isError(){return!e.isValid},unwrap(){if(e.isValid)return e.data;throw it(`Validation failed with ${e.errors.length} error(s)`,e.errors)},unwrapOr(n){return e.isValid?e.data:n},unwrapOrElse(n){return e.isValid?e.data:n(e.errors)},map(n){return e.isValid?A.ok(n(e.data)):A.error(e.errors)},flatMap(n){return e.isValid?n(e.data):A.error(e.errors)},tap(n){return e.isValid&&n(e.data),ce(e)},tapError(n){return e.isValid||n(e.errors),ce(e)},data(){return e.isValid?e.data:void 0},toPlainObject(){return{valid:e.isValid,data:e.isValid?e.data:void 0,errors:e.isValid?[]:e.errors}},get valid(){return e.isValid},get errors(){return e.isValid?[]:e.errors}}}var Fe;(a=>{function e(r){let s=[],o=r.length;for(let i=0;i<o;i++){let c=r[i];if(c.isError())return A.error(c.errors);s.push(c.unwrap())}return A.ok(s)}a.all=e;function t(r){let s=[],o=r.length;for(let i=0;i<o;i++){let c=r[i];if(c.isValid())return c;s.push(...c.errors)}return A.error(s)}a.any=t;function n(r){let s=[],o=[],i=r.length;for(let c=0;c<i;c++){let l=r[c];l.isValid()?s.push(l.unwrap()):o.push(l.errors)}return{valid:s,invalid:o}}a.partition=n})(Fe||(Fe={}));var er=Object.freeze({valid:!0}),tr=Object.freeze({valid:!1});function Ve(e,t,n,a){let r=t.methodName,s=null,o=null;e[r]=function(...i){if(s||(s=t.createComposer(n,a)),s.add(i),e[r]=s[r],s){o=s.build();let c=e._executionPlan;if(!(c&&o&&typeof o.validate=="function")){if(o&&o._validators)for(let l of o._validators)c.addValidator(l.name,(h,g)=>{let b=l.check(h,h);return{valid:b,message:b?void 0:`Validation failed for ${l.name}`}})}}return e}}function ot(e){switch(e){case"string":return{check:t=>t==null?!0:typeof t=="string",name:"stringType",messageFactory:()=>"Expected string",inputType:"string",outputType:"string",metadata:{severity:"error",async:!1}};case"number":return{check:t=>t==null?!0:typeof t=="number"&&!isNaN(t),name:"numberType",messageFactory:()=>"Expected number",inputType:"number",outputType:"number",metadata:{severity:"error",async:!1}};case"boolean":return{check:t=>t==null?!0:typeof t=="boolean",name:"booleanType",messageFactory:()=>"Expected boolean",inputType:"boolean",outputType:"boolean",metadata:{severity:"error",async:!1}};case"array":return{check:t=>t==null?!0:Array.isArray(t),name:"arrayType",messageFactory:()=>"Expected array",inputType:"array",outputType:"array",metadata:{severity:"error",async:!1}};case"object":return{check:t=>t==null?!0:typeof t=="object"&&t!==null&&!Array.isArray(t),name:"objectType",messageFactory:()=>"Expected object",inputType:"object",outputType:"object",metadata:{severity:"error",async:!1}};case"date":return{check:t=>t==null?!0:t instanceof Date,name:"dateType",messageFactory:()=>"Expected Date",inputType:"date",outputType:"date",metadata:{severity:"error",async:!1}};case"null":return{check:t=>t===null,name:"nullType",messageFactory:()=>"Expected null",inputType:"null",outputType:"null",metadata:{severity:"error",async:!1}};case"any":return{check:()=>!0,name:"anyType",messageFactory:()=>"",inputType:"any",outputType:"any",metadata:{severity:"error",async:!1}};default:return null}}function S(e,t,n,a){let r=a?.validators?[...a.validators]:[];if(!a&&e!=="union"){let i=ot(e);i&&r.push(i)}let s=a?.transforms?[...a.transforms]:[],o={_type:e,_fieldPath:t,_validators:r,_transforms:s,build(){return e==="union"&&r.length===0&&r.push({check:()=>!1,name:"unionGuard",messageFactory:()=>"No union type guards defined",inputType:"union",outputType:"union",metadata:{severity:"error",async:!1}}),{_validators:r,_transforms:s}}};return lt(o,e,t,n,r,s),o.refineString=()=>S("string",t,n,{validators:r,transforms:s}),o.refineNumber=()=>S("number",t,n,{validators:r,transforms:s}),o.refineBoolean=()=>S("boolean",t,n,{validators:r,transforms:s}),o.refineArray=()=>S("array",t,n,{validators:r,transforms:s}),o.refineObject=()=>S("object",t,n,{validators:r,transforms:s}),o.refineTuple=()=>S("tuple",t,n,{validators:r,transforms:s}),o.refineUnion=()=>S("union",t,n,{validators:r,transforms:s}),o.refineDate=()=>S("date",t,n,{validators:r,transforms:s}),o.refineAny=()=>S("any",t,n,{validators:r,transforms:s}),o}function lt(e,t,n,a,r,s){let o=Object.entries(a),i=o.length;for(let c=0;c<i;c++){let[,l]=o[c];if(!l||typeof l!="object")continue;if(l.category?.startsWith("composable")){if(l.allowedTypes&&!l.allowedTypes.includes(t))continue;Ve(e,l,n,a);continue}if(typeof l.create!="function"||l.allowedTypes&&!l.allowedTypes.includes(t))continue;let{methodName:h,category:g="standard",name:b}=l,d=l.create();e[h]=function(...u){try{let f=d(...u);if(g==="transform"){let m=ct(f,u[0]);s.push(m)}else{let m=dt(f,n),y=ut(m,b||h,t,u,f);r.push(y)}}catch{}return e}}}function ct(e,t){return typeof e=="function"?t:e?.__isTransform?e.__transformFn:e?.__isCoerce?n=>e.coerce.coerceFn(n):e?.__isDefault?(n,a)=>e.default.applyDefault(n,a):e?.__isPreprocess?(n,a)=>e.preprocess.applyPreprocess(n,a):t||(n=>n)}function dt(e,t){return typeof e=="function"?(n,a)=>e(n,{path:t,allValues:a}).valid:e?.check?(n,a)=>e.check(n,a):()=>!1}function ut(e,t,n,a,r){let s={check:e,name:t,code:r?.code||t,pluginName:r?.pluginName||t,getErrorMessage:r?.getErrorMessage,messageFactory:a[a.length-1]?.messageFactory||r?.messageFactory||(()=>"Validation failed"),inputType:n,outputType:n,metadata:r?.metadata||{severity:"error",async:!1}};return r&&(r.shouldSkipAllValidation&&(s.shouldSkipAllValidation=r.shouldSkipAllValidation),r.shouldSkipValidation&&(s.shouldSkipValidation=r.shouldSkipValidation),r.shouldSkipFurtherValidation&&(s.shouldSkipFurtherValidation=r.shouldSkipFurtherValidation),r.skipForNull!==void 0&&(s.skipForNull=r.skipForNull),r.skipForUndefined!==void 0&&(s.skipForUndefined=r.skipForUndefined),r.__isRecursive&&(s.__isRecursive=r.__isRecursive),r.recursive&&(s.recursive=r.recursive)),s}function U(e,t){let n=S("string",e,t),a=S("number",e,t),r=S("boolean",e,t),s=S("array",e,t),o=S("object",e,t),i=S("union",e,t),c=S("tuple",e,t),l=S("date",e,t),h=S("any",e,t);return{string:n,number:a,boolean:r,date:l,array:s,tuple:c,union:i,object:o,any:h}}function J(e){let t=e.split(".");return{segments:t,isArrayElement:!1,arrayPath:void 0,elementKey:void 0,depth:t.length}}function z(e){let t=J(e),n;if(t.depth===1){let a=t.segments[0];n=r=>r?.[a]}else if(t.depth===2){let[a,r]=t.segments;n=s=>s?.[a]?.[r]}else if(t.depth===3){let[a,r,s]=t.segments;n=o=>o?.[a]?.[r]?.[s]}else n=a=>{let r=a;for(let s of t.segments){if(r==null)return;r=r[s]}return r};return n}function Pe(e){let t=J(e),n;if(t.depth===1){let a=t.segments[0];n=(r,s)=>{r!=null&&(r[a]=s)}}else if(t.depth===2){let[a,r]=t.segments;n=(s,o)=>{s!=null&&(s[a]||(s[a]={}),s[a][r]=o)}}else if(t.depth===3){let[a,r,s]=t.segments;n=(o,i)=>{o!=null&&(o[a]||(o[a]={}),o[a][r]||(o[a][r]={}),o[a][r][s]=i)}}else n=(a,r)=>{if(a==null)return;let s=a,o=t.segments;for(let i=0;i<o.length-1;i++){let c=o[i];s[c]||(s[c]={}),s=s[c]}s[o[o.length-1]]=r};return n}function ft(e,t){return z(t)(e)}function yt(e,t,n){Pe(t)(e,n)}function Ee(e){let t=J(e);return!t.isArrayElement||!t.arrayPath||!t.elementKey?null:{arrayPath:t.arrayPath,elementPath:t.elementKey,indexPattern:new RegExp(`${t.arrayPath.replace(/\./g,"\\.")}\\[(\\d+)\\]\\.${t.elementKey.replace(/\./g,"\\.")}`)}}function pt(e){let t=z(e);return n=>{let a=t(n);return Array.isArray(a)?a:[]}}function gt(e){let t=new Map;for(let n of e){let a=Ee(n);if(a){let{arrayPath:r,elementPath:s}=a;t.has(r)||t.set(r,{arrayPath:r,elementFields:[]}),t.get(r).elementFields.push(s)}}return t}function ht(e){return e.map(t=>({fieldName:t.split(".").pop()||t,path:t,accessor:z(t)}))}function mt(e){return!e||typeof e!="string"?!1:e.split(".").every(n=>n.length>0&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(n))}function Tt(e){return e.split(".").filter(t=>t.length>0).join(".")}function bt(e,t){let n=e.split("."),a=t.split(".");return n.length!==a.length?n.length-a.length:e.localeCompare(t)}function Ft(){}function Vt(){return{pathCacheSize:0,accessorCacheSize:0,setterCacheSize:0}}var Ae={parseFieldPath:J,createFieldAccessor:z,createFieldSetter:Pe,getNestedValue:ft,setNestedValue:yt,analyzeArrayField:Ee,createArrayAccessor:pt,groupArrayFields:gt,createBatchAccessors:ht,isValidFieldPath:mt,normalizeFieldPath:Tt,compareFieldPaths:bt,clearCache:Ft,getCacheStats:Vt};function Pt(e,t){let n=e.params||[];if(n.length>0){let a=n[0];if(typeof a=="number")return{expected:a,actual:typeof t=="string"?t.length:t};if(typeof a=="string")return{pattern:a,expected:a}}return{}}function X(e,t,n){let a=e.code||e.pluginName||"VALIDATION_ERROR",r="Validation failed";try{if(e.getErrorMessage)r=e.getErrorMessage(t,n.path,n.allValues,n.arrayContext);else if(e.messageFactory){let s={path:n.path,value:t,code:a,...Pt(e,t)};r=e.messageFactory(s)}}catch{r=`Validation failed for ${n.path}`}return{path:n.path,code:a,message:r}}function Et(e){if(typeof e=="function")return e;let t=e;if(t.apply&&typeof t.apply=="function")return t.apply;if(t.transformFn&&typeof t.transformFn=="function")return t.transformFn;throw new Error("Invalid transform function")}function Re(e,t){if(!t.includes("."))return e?.[t];let n=t.indexOf(".");if(n>0&&t.indexOf(".",n+1)===-1){let r=t.substring(0,n),s=t.substring(n+1);return e?.[r]?.[s]}return z(t)(e)}function ue(e){if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let r=e.length,s=new Array(r);for(let o=0;o<r;o++)s[o]=ue(e[o]);return s}let t={},n=Object.keys(e),a=n.length;for(let r=0;r<a;r++){let s=n[r];t[s]=ue(e[s])}return t}function fe(e,t,n,a={}){let{abortEarly:r=!0}=a,s=e.validators.length;if(s===0)return{valid:!0,errors:[]};if(s===1){let i=e.validators[0],c=i.check;if(typeof c!="function")throw new Error("Invalid validator: check function is not defined");try{return c(t,n.allValues,n.arrayContext)?{valid:!0,errors:[]}:{valid:!1,errors:[X(i,t,n)]}}catch{return{valid:!1,errors:[X(i,t,n)]}}}let o=[];for(let i=0;i<s;i++){let c=e.validators[i];if(c.metadata?.type==="conditional"&&c.metadata?.category==="skip"){let l=c.check;if(typeof l=="function")try{if(l(t,n.allValues,n.arrayContext))return{valid:!0,errors:[]}}catch{}}}for(let i=0;i<s;i++){let c=e.validators[i],l=c.check;if(typeof l!="function")throw new Error("Invalid validator: check function is not defined");let h=!1;try{h=l(t,n.allValues,n.arrayContext)}catch{h=!1}if(!h&&(o.push(X(c,t,n)),r))break}return{valid:o.length===0,errors:o}}function At(e,t,n={}){let{abortEarly:a=!1,abortEarlyOnEachField:r=!0}=n,s=[],o=e.length;for(let i=0;i<o;i++){let c=e[i],l=Re(t,c.path),h={originalValue:l,currentValue:l,allValues:t,path:c.path},g=fe(c,l,h,{abortEarly:r});if(!g.valid&&(s.push(...g.errors),a))break}return{valid:s.length===0,errors:s}}function Oe(e,t,n,a={}){let{abortEarly:r=!0}=a,s=fe(e,t,n,{abortEarly:r});if(!s.valid)return{valid:!1,errors:s.errors};let o=t;try{o=xe(e.transforms,t,n)}catch(i){return{valid:!1,errors:[{path:n.path,code:"TRANSFORM_ERROR",message:`Transform failed: ${i instanceof Error?i.message:"Unknown error"}`}]}}return{valid:!0,data:o,errors:[]}}function xe(e,t,n){let a=t,r=e.length;for(let s=0;s<r;s++)a=Et(e[s])(a,n);return a}function Ot(e,t,n,a=!0,r){let s=e.validators.length;if(s===0)return{valid:!0};if(s===1){let i=e.validators[0].check;if(typeof i!="function")return{valid:!1,errorIndices:[0]};try{return i(t,n,r)?{valid:!0}:{valid:!1,errorIndices:[0]}}catch{return{valid:!1,errorIndices:[0]}}}if(a){for(let i=0;i<s;i++){let c=e.validators[i].check;if(typeof c!="function")return{valid:!1,errorIndices:[i]};let l=!1;try{l=c(t,n,r)}catch{l=!1}if(!l)return{valid:!1,errorIndices:[i]}}return{valid:!0}}let o=[];for(let i=0;i<s;i++){let c=e.validators[i].check;if(typeof c!="function"){o.push(i);continue}let l=!1;try{l=c(t,n,r)}catch{l=!1}l||o.push(i)}return o.length===0?{valid:!0}:{valid:!1,errorIndices:o}}function Rt(e,t,n,a,r){let s={originalValue:n,currentValue:n,allValues:a,path:e.path,arrayContext:r};return t.filter(o=>o<e.validators.length).map(o=>{let i=e.validators[o];return X(i,n,s)})}function xt(){let e=new Map,t=r=>{let s=e.get(r);if(!s){if(!r.includes("."))s=(o,i)=>{o!=null&&(o[r]=i)};else{let o=r.split("."),i=o.length-1;s=(c,l)=>{let h=c;for(let g=0;g<i;g++){let b=o[g];h[b]||(h[b]={}),h=h[b]}h[o[i]]=l}}e.set(r,s)}return s},n=(r,s,o)=>{if(!s.includes(".")){r!=null&&(r[s]=o);return}t(s)(r,o)};return{validateField:fe,validateBatch:At,parseField:Oe,parseBatch:(r,s,o={})=>{let{abortEarly:i=!1,abortEarlyOnEachField:c=!0}=o,l=[],h=ue(s),g=r.length;for(let b=0;b<g;b++){let d=r[b],u=Re(s,d.path),f={originalValue:u,currentValue:u,allValues:s,path:d.path},m=Oe(d,u,f,{abortEarly:c});if(m.valid)m.data!==void 0&&n(h,d.path,m.data);else if(l.push(...m.errors),i)break}return{valid:l.length===0,data:l.length===0?h:void 0,errors:l}},applyTransforms:xe,validateHoisted:Ot,reconstructErrors:Rt}}var de=null;function ve(){return de||(de=xt()),de}var gr=ve();function ke(e,t){let n=e.length,a=!1,r=!1;for(let c of e)vt(c.builderFunction).some(h=>kt(h,t))&&(a=!0),Ae.parseFieldPath(c.path).isArrayElement&&(r=!0);let s,o,i;return r?(s="array_batch",o="Array fields detected - using batch processing",i=!0):a?(s="definition_order",o="Transforms detected - using definition order",i=!1):(s="fast_separated",o="No transforms or arrays - using fast separated execution",i=!0),{strategy:s,reason:o,canOptimize:i,hasTransforms:a,hasArrayFields:r,fieldCount:n}}function vt(e){let t=e.toString(),n=/\.(\w+)\(/g,a=[],r;for(;(r=n.exec(t))!==null;)a.push(r[1]);return a}function kt(e,t){return Object.values(t).find(a=>a?.methodName===e)?.category==="transform"||e==="transform"||e.startsWith("to")}function ye(e,t){let n=ke(e,t),a=new Map;for(let r of e)a.set(r.path,n);return a}function je(e){let t=[],n=[];return e.forEach((a,r)=>{a.strategy==="fast_separated"?t.push(r):n.push(r)}),{fastFields:t,slowFields:n}}var _=".",D="validate",k="parse";function G(e,t,n="fast_separated",a){let r=U(e.path,t),s=e.builderFunction(r);s&&typeof s.build=="function"&&(s=s.build());let o=s._validators||[],i=s._transforms||[],c=e.path,l=o.some(T=>T.shouldSkipAllValidation||T.shouldSkipValidation),h=i.length>0;if(!l&&!h&&o.length<=10&&n==="fast_separated")return jt(o,c);if(!l&&h&&o.length<=10&&i.length<=5&&n==="fast_separated")return Nt(o,i,c);let d=n==="definition_order"||l;return{validate:d?(T,p,P)=>{let E=P?.abortEarlyOnEachField!==!1,R=Ne(T,p,o,i,c,E,D);return{valid:R.valid,errors:R.errors}}:(T,p,P={})=>{let E=P.abortEarlyOnEachField!==!1;return we(T,p,o,i,c,E,D)},parse:d?(T,p,P)=>{let E=P?.abortEarlyOnEachField!==!1;return Ne(T,p,o,i,c,E,k)}:(T,p,P={})=>{let E=P.abortEarlyOnEachField!==!1;return we(T,p,o,i,c,E,k)},accessor:a}}function Ne(e,t,n,a,r,s,o=k){let i=[],c=e,l=n.some(b=>b.skipForNull===!0),h=n.some(b=>b.skipForUndefined===!0);if(e===null&&l||e===void 0&&h)return o===k?{valid:!0,data:e,errors:[]}:{valid:!0,data:void 0,errors:[]};let g=n.length;for(let b=0;b<g;b++){let d=n[b];if(d.shouldSkipAllValidation&&typeof d.shouldSkipAllValidation=="function"&&d.shouldSkipAllValidation(c,t))break;let u=d.check||d;if(typeof u=="function"&&!u(c,t)){let f={path:r,code:d.code||d.pluginName||"VALIDATION_ERROR",message:C(d,c,r,t)};if(s)return{valid:!1,data:void 0,errors:[f]};i.push(f)}}if(i.length>0)return{valid:!1,data:void 0,errors:i};if(o===k&&a.length>0){let b=[];for(let u=0;u<a.length;u++){let f=a[u];typeof f=="function"?b.push(f):f&&typeof f.apply=="function"&&b.push(f.apply)}let d=b.length;if(d===1)c=b[0](c);else if(d===2)c=b[0](c),c=b[1](c);else if(d>0)for(let u=0;u<d;u++)c=b[u](c)}return o===D?W:{valid:!0,data:c,errors:[]}}function we(e,t,n,a,r,s,o=k){let i=[],c=n.length,l=n.some(d=>d.skipForNull===!0),h=n.some(d=>d.skipForUndefined===!0);if(e===null&&l||e===void 0&&h)return o===k?{valid:!0,data:e,errors:[]}:{valid:!0,data:void 0,errors:[]};for(let d=0;d<c;d++){let u=n[d];if(u.shouldSkipAllValidation&&typeof u.shouldSkipAllValidation=="function"&&u.shouldSkipAllValidation(e,t))break;let f=u.check||u;if(typeof f=="function"&&!f(e,t)){if(s)return{valid:!1,data:void 0,errors:[{path:r,code:u.code||u.pluginName||"VALIDATION_ERROR",message:C(u,e,r,t)}]};i.push({path:r,code:u.code||u.pluginName||"VALIDATION_ERROR",message:C(u,e,r,t)})}}if(o===D)return i.length===0?W:{valid:!1,errors:i};if(i.length>0)return{valid:!1,data:void 0,errors:i};let g=e,b=a.length;if(b>0){let d=[];for(let f=0;f<b;f++){let m=a[f];typeof m=="function"?d.push(m):m&&typeof m.apply=="function"&&d.push(m.apply)}let u=d.length;if(u===1)g=d[0](g);else if(u===2)g=d[0](g),g=d[1](g);else if(u>0)for(let f=0;f<u;f++)g=d[f](g)}return{valid:!0,data:g,errors:[]}}function jt(e,t,n){let a=[],r=[],s=[],o=[],i=e.length;for(let b=0;b<i;b++){let d=e[b];a.push(d.check||d),r.push(d.code||d.pluginName||"VALIDATION_ERROR"),d.getErrorMessage&&typeof d.getErrorMessage=="function"||d.messageFactory?(s.push(""),o.push(!0)):(s.push(`Validation failed for ${t}`),o.push(!1))}let c=a.length,l={path:t,code:"",message:""},h;if(c===1){let b=a[0],d=r[0],u=s[0],f=o[0];h=(m,y,F)=>b(m,y)?W:(l.code=d,l.message=f?C(e[0],m,t,y):u,{valid:!1,errors:[{path:l.path,code:l.code,message:l.message}]})}else if(c===2){let b=a[0],d=a[1],u=r[0],f=r[1],m=s[0],y=s[1],F=o[0],V=o[1];h=(T,p,P)=>{if(!b(T,p)){if(P?.abortEarlyOnEachField!==!1)return l.code=u,l.message=F?C(e[0],T,t,p):m,{valid:!1,errors:[{path:l.path,code:l.code,message:l.message}]};let E=[{path:t,code:u,message:F?C(e[0],T,t,p):m}];return d(T,p)||E.push({path:t,code:f,message:V?C(e[1],T,t,p):y}),{valid:!1,errors:E}}return d(T,p)?W:(l.code=f,l.message=V?C(e[1],T,t,p):y,{valid:!1,errors:[{path:l.path,code:l.code,message:l.message}]})}}else h=(b,d,u)=>{for(let f=0;f<c;f++)if(!a[f](b,d)){if(u?.abortEarlyOnEachField!==!1)return l.code=r[f],l.message=o[f]?C(e[f],b,t,d):s[f],{valid:!1,errors:[{path:l.path,code:l.code,message:l.message}]};let m=[];m.push({path:t,code:r[f],message:o[f]?C(e[f],b,t,d):s[f]});for(let y=f+1;y<c;y++)a[y](b,d)||m.push({path:t,code:r[y],message:o[y]?C(e[y],b,t,d):s[y]});return{valid:!1,errors:m}}return W};return{validate:h,parse:(b,d,u={})=>{let f=h(b,d,u);return f.valid?{valid:!0,data:b,errors:[]}:{valid:!1,data:void 0,errors:f.errors}},accessor:n}}var W=Object.freeze({valid:!0,errors:[]});function C(e,t,n,a){if(e.getErrorMessage)try{return e.getErrorMessage(t,n,a)}catch{return`Validation failed for ${n}`}else if(e.messageFactory)try{let r={path:n,value:t,code:e.code||e.pluginName||"VALIDATION_ERROR"};return e.messageFactory(r)}catch{return`Validation failed for ${n}`}return`Validation failed for ${n}`}function Nt(e,t,n,a){let r=e.length,s=t.length,o=new Array(r),i=new Array(r);for(let d=0;d<r;d++){let u=e[d];o[d]=u.check||u,i[d]=u.code||u.pluginName||"VALIDATION_ERROR"}let c=new Array(s),l=0;for(let d=0;d<s;d++){let u=t[d];typeof u=="function"?c[l++]=u:u&&typeof u.apply=="function"&&(c[l++]=u.apply)}if(r===1&&l===1){let d=o[0],u=i[0],f=c[0],m=e[0],y={valid:!1,errors:[{path:n,code:u,message:""}]},F={valid:!1,data:void 0,errors:[{path:n,code:u,message:""}]},V={valid:!0,data:null,errors:[]};return{validate:(T,p,P)=>d(T,p)?W:(y.errors[0].message=C(m,T,n,p),y),parse:(T,p,P)=>d(T,p)?(V.data=f(T),V):(F.errors[0].message=C(m,T,n,p),F)}}if(r===2&&l===1){let d=o[0],u=o[1],f=i[0],m=i[1],y=c[0],F=e[0],V=e[1],T={valid:!1,errors:[{path:n,code:f,message:""}]},p={valid:!1,errors:[{path:n,code:m,message:""}]},P={valid:!1,data:void 0,errors:[{path:n,code:f,message:""}]},E={valid:!1,data:void 0,errors:[{path:n,code:m,message:""}]},R={valid:!0,data:null,errors:[]};return{validate:(x,O,v)=>d(x,O)?u(x,O)?W:(p.errors[0].message=C(V,x,n,O),p):(T.errors[0].message=C(F,x,n,O),T),parse:(x,O,v)=>d(x,O)?u(x,O)?(R.data=y(x),R):(E.errors[0].message=C(V,x,n,O),E):(P.errors[0].message=C(F,x,n,O),P)}}let h={path:n,code:"",message:""};return{validate:(d,u,f={})=>{for(let m=0;m<r;m++)if(!o[m](d,u)){if(f.abortEarlyOnEachField!==!1)return h.code=e[m].code||e[m].pluginName||"VALIDATION_ERROR",h.message=C(e[m],d,n,u),{valid:!1,errors:[{...h}]};let y=[];y.push({path:n,code:e[m].code||e[m].pluginName||"VALIDATION_ERROR",message:C(e[m],d,n,u)});for(let F=m+1;F<r;F++)o[F](d,u)||y.push({path:n,code:e[F].code||e[F].pluginName||"VALIDATION_ERROR",message:C(e[F],d,n,u)});return{valid:!1,errors:y}}return W},parse:(d,u,f={})=>{let m=e.some(V=>V.skipForNull===!0),y=e.some(V=>V.skipForUndefined===!0);if(d===null&&m||d===void 0&&y)return{valid:!0,data:d,errors:[]};for(let V=0;V<r;V++)if(!o[V](d,u)){if(f.abortEarlyOnEachField!==!1)return h.code=e[V].code||e[V].pluginName||"VALIDATION_ERROR",h.message=C(e[V],d,n,u),{valid:!1,data:void 0,errors:[{...h}]};let T=[];T.push({path:n,code:e[V].code||e[V].pluginName||"VALIDATION_ERROR",message:C(e[V],d,n,u)});for(let p=V+1;p<r;p++)o[p](d,u)||T.push({path:n,code:e[p].code||e[p].pluginName||"VALIDATION_ERROR",message:C(e[p],d,n,u)});return{valid:!1,data:void 0,errors:T}}let F=d;if(l===1)F=c[0](F);else if(l===2)F=c[0](F),F=c[1](F);else if(l>0)for(let V=0;V<l;V++)F=c[V](F);return{valid:!0,data:F,errors:[]}},accessor:a}}function ge(e){if(e.length===0)return t=>t;if(e.length===1){let t=e[0];return n=>n?.[t]}if(e.length===2){let[t,n]=e;return a=>a?.[t]?.[n]}if(e.length===3){let[t,n,a]=e;return r=>r?.[t]?.[n]?.[a]}if(e.length===4){let[t,n,a,r]=e;return s=>s?.[t]?.[n]?.[a]?.[r]}if(e.length===5){let[t,n,a,r,s]=e;return o=>o?.[t]?.[n]?.[a]?.[r]?.[s]}return t=>{let n=t,a=e.length;for(let r=0;r<a;r++){let s=e[r];if(n=n?.[s],n===void 0)return}return n}}function pe(e){return ge(e.split(_))}function he(e){let t=pe(e);return n=>t(n)!==void 0}function ee(e){let t=e.split(_);if(t.length===1){let n=t[0];return(a,r)=>{a[n]=r}}if(t.length===2){let[n,a]=t;return(r,s)=>{r[n]||(r[n]={}),r[n][a]=s}}if(t.length===3){let[n,a,r]=t;return(s,o)=>{s[n]||(s[n]={}),s[n][a]||(s[n][a]={}),s[n][a][r]=o}}return(n,a)=>{let r=n;for(let s=0;s<t.length-1;s++){let o=t[s];r[o]||(r[o]={}),r=r[o]}r[t[t.length-1]]=a}}function $(e){if(!e.includes(_))return a=>a[e];let t=e.split(_),n=t.length;if(n===2){let[a,r]=t;return s=>{let o=s[a];return Array.isArray(o)?o:o!=null&&typeof o=="object"?o[r]:void 0}}return a=>{let r=a;for(let s=0;s<n;s++){if(r==null||typeof r!="object")return;let o=t[s],i=r[o];if(Array.isArray(i)&&s<n-1){let c=t.slice(s+1).join(".");return{__isArrayElementField:!0,values:i.map(h=>{if(h==null||typeof h!="object")return;if(c.indexOf(".")===-1)return h[c];let g=h,b=t.slice(s+1),d=b.length;for(let u=0;u<d;u++){if(g==null||typeof g!="object")return;g=g[b[u]]}return g}),arrayPath:t.slice(0,s+1).join(".")}}r=i}return r}}function te(e){if(!e.includes("[*]"))return{hasArrayElements:!1,segments:e.split(_).map(s=>({name:s,isArrayElement:!1}))};let n=e.split(_),a=[];for(let s of n)if(s.endsWith("[*]")){let o=s.slice(0,-3);a.push({name:o,isArrayElement:!0})}else a.push({name:s,isArrayElement:!1});let r=a.findIndex(s=>s.isArrayElement);if(r!==-1){let s=a.slice(0,r+1).map(i=>i.name).join(_),o=a.slice(r+1).map(i=>i.name).join(_);return{hasArrayElements:!0,segments:a,baseArrayPath:s,elementPath:o||""}}return{hasArrayElements:!0,segments:a}}function me(e){let t=te(e);if(!t.hasArrayElements||!t.baseArrayPath)return()=>null;let n=pe(t.baseArrayPath),a=t.elementPath||"";return r=>{let s=n(r);if(!Array.isArray(s))return null;let o;if(a==="")o=s;else{let i=pe(a);o=s.map(c=>i(c))}return{elements:o,basePath:t.baseArrayPath,elementPath:a}}}function re(e){let t=e.match(/^(.+\[\*\])\[\*\]$/);if(t)return{isArrayElementPath:!0,arrayPath:t[1],elementField:""};if(e.match(/^(.+?)(\[\*\]\.(.+))?$/)&&e.includes("[*].")){let o=e.split(/\[\*\]\./);if(o.length>=2){let i=o[o.length-1];if(i.includes("[*]")){let c=i.replace(/\[\*\]$/,"");return{isArrayElementPath:!0,arrayPath:o.slice(0,-1).concat(c).join("."),elementField:""}}else return{isArrayElementPath:!0,arrayPath:o.slice(0,-1).join("."),elementField:i}}}let a=e.match(/^([^\[]+)\[\*\]\.(.+)$/);if(a)return{isArrayElementPath:!0,arrayPath:a[1],elementField:a[2]};let r=e.match(/^([^\[]+)\[\*\]$/);if(r)return{isArrayElementPath:!0,arrayPath:r[1],elementField:""};let s=e.match(/^([^\.]+)\.\*\.(.+)$/);return s?{isArrayElementPath:!0,arrayPath:s[1],elementField:s[2]}:{isArrayElementPath:!1}}function Ce(e){let t=[],n=new Set;for(let o of e){let i=re(o.path);if(i.isArrayElementPath&&i.arrayPath){if(n.add(i.arrayPath),i.elementField&&i.elementField.includes("[*]")){let c=`${i.arrayPath}.${i.elementField.split("[*]")[0]}`;n.add(c)}t.push({...o,originalPath:o.path})}else t.push(o)}for(let o of n)t.some(i=>i.path===o&&i.isArrayField)||t.push({path:o,isArrayField:!0});let a=new Set;for(let o of t)if(o.originalPath){let i=re(o.originalPath);if(i.isArrayElementPath&&i.elementField&&i.elementField.includes("[*]")){let c=i.elementField.split("[*]")[0],l=`${i.arrayPath}.${c}`;!a.has(l)&&!t.some(h=>h.path===l&&h.isArrayField)&&a.add(l)}}for(let o of a)t.push({path:o,isArrayField:!0});let r=t.filter(o=>o.isArrayField?o.path.includes("[*]")?!!o.path.match(/\[\*\]$/):!0:!1);r.sort((o,i)=>{let c=o.path.split(".").length,l=i.path.split(".").length;return c-l});let s=new Map;for(let o of r){let i=o.path,c=i.split(".").length-1,l;for(let f of s.keys())i.startsWith(f+".")?(!l||f.length>l.length)&&(l=f):i.startsWith(f+"[*]")&&f!==i&&(!l||f.length>l.length)&&(l=f);let h=t.filter(f=>{let m=f.originalPath||f.path,y=re(m);return y.isArrayElementPath&&y.arrayPath===i?!0:m.startsWith(i+".")});if(h.length===0)continue;let g=[],b=[];for(let f of h){let m=f.originalPath||f.path,y=re(m),F;y.isArrayElementPath&&y.arrayPath===i&&y.elementField!==void 0?F=y.elementField:F=m.substring(i.length+1),r.some(T=>T.path!==i&&T.path.startsWith(i+".")&&f.path.startsWith(T.path+"."))||g.push(F),f.isArrayField||b.push(f.originalPath||f.path)}let d=new Map;for(let f of g){let m=f.split(".");d.set(f,ge(m))}let u={arrayPath:i,elementFields:g,fullFieldPaths:b,validators:new Map,accessors:d,childArrays:new Map,depth:c,parentPath:l};s.set(i,u)}for(let[o,i]of s)if(i.parentPath){let c=s.get(i.parentPath);if(c){let l;o.startsWith(i.parentPath+".")?l=o.substring(i.parentPath.length+1):o.startsWith(i.parentPath+"[*]")?l=o.substring(i.parentPath.length):l=o.substring(i.parentPath.length+1),c.childArrays.set(l,i)}}return s}function Te(e,t){if(e.validators.size===0)for(let n of e.fullFieldPaths){let a=t.get(n);a&&e.validators.set(n,a)}return function(a,r,s,o=!0,i=D,c=""){let l=[],h=i===k?[...a]:void 0,g=!1;if(!Array.isArray(a))return{errors:l,transformedData:h};for(let b=0;b<a.length;b++){let d=a[b],u=i===k?typeof d=="object"&&d!==null?{...d}:d:void 0,f=!1,m=c?`${c}[${b}]`:`${e.arrayPath}[${b}]`;for(let y of e.elementFields){if(y===""){let O=null,v=`${e.arrayPath}[*]`;if(O=e.validators.get(v),!O)for(let M of e.fullFieldPaths){let q=e.validators.get(M);if(q){O=q;break}}if(!O)continue;let N=u||d,w=m,j;if(i===D)if(O.validate)j=O.validate(N,r,{abortEarlyOnEachField:g});else if(O.validateSlow)j=O.validateSlow(N,r,{abortEarlyOnEachField:g});else if(O.validateFast)j=O.validateFast(N,r);else continue;else if(i===k)if(O.parse)j=O.parse(N,r,{abortEarlyOnEachField:g});else if(O.parseSlow)j=O.parseSlow(N,r,{abortEarlyOnEachField:g});else if(O.parseFast)j=O.parseFast(N,r);else continue;else continue;if(j.valid)i===k&&j.data!==void 0&&h&&(h[b]=j.data);else{if(f=!0,j.errors&&j.errors.length>0)for(let M of j.errors)l.push({path:w,code:M.code||(i===k?"PARSE_ERROR":"VALIDATION_ERROR"),message:M.message||(i===k?"Parse failed":"Validation failed"),paths:()=>[w]});else l.push({path:w,code:i===k?"PARSE_ERROR":"VALIDATION_ERROR",message:i===k?"Parse failed":"Validation failed",paths:()=>[w]});if(g)break}continue}let F=`${e.arrayPath}.${y}`,V=`${e.arrayPath}[*].${y}`,T=`${e.arrayPath}.*.${y}`,p=e.validators.get(F);if(p||(p=e.validators.get(V)),p||(p=e.validators.get(T)),!p)for(let O of e.fullFieldPaths){let v=e.validators.get(O);if(v&&O.includes(y)){p=v;break}}if(!p)continue;let P=e.accessors.get(y),E=P?P(u||d):void 0,R=`${m}.${y}`,x;if(i===D)if(p.validate)x=p.validate(E,r,{abortEarlyOnEachField:g});else if(p.validateSlow)x=p.validateSlow(E,r,{abortEarlyOnEachField:g});else if(p.validateFast)x=p.validateFast(E,r);else continue;else if(i===k)if(p.parse)x=p.parse(E,r,{abortEarlyOnEachField:g});else if(p.parseSlow)x=p.parseSlow(E,r,{abortEarlyOnEachField:g});else if(p.parseFast)x=p.parseFast(E,r);else continue;else continue;if(x.valid)i===k&&x.data!==void 0&&u&&wt(u,y,x.data);else{if(f=!0,x.errors&&x.errors.length>0)for(let O of x.errors)l.push({path:R,code:O.code||(i===k?"PARSE_ERROR":"VALIDATION_ERROR"),message:O.message||(i===k?"Parse failed":"Validation failed"),paths:()=>[R]});else l.push({path:R,code:i===k?"PARSE_ERROR":"VALIDATION_ERROR",message:i===k?"Parse failed":"Validation failed",paths:()=>[R]});if(g)break}}for(let[y,F]of e.childArrays){let V,T;if(y.startsWith("[*]")?(V=u||d,T=m):(V=u?.[y]||d[y],T=`${m}.${y}`),Array.isArray(V)){let P=Te(F,t)(V,r,s,o,i,T);P.errors.length>0&&(l.push(...P.errors),f=!0),i===k&&P.transformedData&&u&&(u[y]=P.transformedData)}}if(i===k&&h&&u&&typeof u=="object"&&(h[b]=u),f&&s)return{errors:l,transformedData:h}}return{errors:l,transformedData:h}}}function wt(e,t,n){ee(t)(e,n)}function Ct(e){let t=Ce(e),n=new Map;for(let[a,r]of t)if(!r.parentPath){let s=Me(r,t),o={arrayPath:r.arrayPath,elementFields:r.elementFields,fullFieldPaths:s,validators:r.validators,accessors:r.accessors,_nestedInfo:r};n.set(a,o)}return n}function Me(e,t){let n=[];n.push(...e.fullFieldPaths);for(let[a,r]of e.childArrays){let s=Me(r,t);n.push(...s)}return n}function Ie(e){return Ct(e)}function ne(e,t){if(e._nestedInfo){for(let a of e.fullFieldPaths){let r=t.get(a);r&&e._nestedInfo.validators.set(a,r)}let n=Te(e._nestedInfo,t);return function(r,s,o,i=!0,c=D){let l=n(r,s,o,i,c);return{errors:l.errors,transformedData:l.transformedData}}}for(let n of e.fullFieldPaths){let a=t.get(n);a&&e.validators.set(n,a)}return function(a,r,s,o=!0,i=D){if(e.optimizedValidator&&(e.arrayStructure?.depth??0)>1){let g=e.optimizedValidator(a,r,{abortEarly:s,abortEarlyOnEachField:o,mode:i});return{errors:g.errors,transformedData:g.transformedData}}let l=[];if(!Array.isArray(a))return{errors:l};if(a.length===0)return{errors:l};let h=i===k?[...a]:void 0;for(let g=0;g<a.length;g++){let b=a[g],d=i===k?{...b}:void 0,u=!1;for(let f of e.elementFields){let m=`${e.arrayPath}.${f}`,y=e.validators.get(m);if(!y)continue;let F=e.accessors.get(f),V=F?F(d||b):void 0,T=`${e.arrayPath}[${g}].${f}`,p;if(i===D)p=y.validate(V,r,{abortEarlyOnEachField:!1});else if(i===k)p=y.parse(V,r,{abortEarlyOnEachField:!1});else continue;if(p.isValid())i===k&&p.data!==void 0&&d&&Mt(d,f,p.data);else if(u=!0,p.errors&&p.errors.length>0)for(let P of p.errors)l.push({path:T,code:P.code||(i===k?"PARSE_ERROR":"VALIDATION_ERROR"),message:P.message||(i===k?"Parse failed":"Validation failed"),paths:()=>[T]});else l.push({path:T,code:i===k?"PARSE_ERROR":"VALIDATION_ERROR",message:i===k?"Parse failed":"Validation failed",paths:()=>[T]})}if(i===k&&h&&d&&(h[g]=d),u&&s)return{errors:l,transformedData:h}}return{errors:l,transformedData:h}}}function Mt(e,t,n){ee(t)(e,n)}function Se(e){return Object.freeze(e.split(_))}function It(e){let t=e.length;switch(t){case 0:return y=>y;case 1:let n=e[0];return y=>y?.[n];case 2:let a=e[0],r=e[1];return y=>y?.[a]?.[r];case 3:let s=e[0],o=e[1],i=e[2];return y=>y?.[s]?.[o]?.[i];case 4:let c=e[0],l=e[1],h=e[2],g=e[3];return y=>y?.[c]?.[l]?.[h]?.[g];case 5:let b=e[0],d=e[1],u=e[2],f=e[3],m=e[4];return y=>y?.[b]?.[d]?.[u]?.[f]?.[m];default:return y=>{let F=y;for(let V=0;V<t;V++)if(F=F?.[e[V]],F===void 0)return;return F}}}function ae(e){let t=Se(e);return It(t)}function ie(e){let t=Se(e),n=t.length,a;switch(n){case 1:let r=t[0];a=(h,g)=>{h[r]=g};break;case 2:let s=t[0],o=t[1];a=(h,g)=>{h[s]||(h[s]={}),h[s][o]=g};break;case 3:let i=t[0],c=t[1],l=t[2];a=(h,g)=>{h[i]||(h[i]={}),h[i][c]||(h[i][c]={}),h[i][c][l]=g};break;default:a=(h,g)=>{let b=h;for(let d=0;d<n-1;d++){let u=t[d];b[u]||(b[u]={}),b=b[u]}b[t[n-1]]=g}}return a}function _e(e){let t=Array.from(e),n=t.length;if(n===0)return{validateRaw:()=>!0,parseRaw:a=>({valid:!0,data:a}),validate:a=>A.ok(a),parse:a=>A.ok(a)};if(n===1){let[a,r]=t[0],s=!a.includes("."),o=s?null:ae(a),i=s?null:ie(a);return{validateRaw:(c,l)=>{if(!c)return!1;let h=s?c[a]:o(c);return r.validate(h,c,l).valid},parseRaw:(c,l)=>{if(!c)return{valid:!1,error:"Value required"};let h=s?c[a]:o(c),g=r.parse(h,c,l);if(!g.valid)return{valid:!1,error:g.errors[0]};if(g.data!==void 0&&g.data!==h){let b={...c};return s?b[a]=g.data:i(b,g.data),{valid:!0,data:b}}return{valid:!0,data:c}},validate:(c,l)=>{if(!c)return A.error([{path:"",message:"Value required",code:"REQUIRED",paths:()=>[""]}]);let h=s?c[a]:o(c),g=r.validate(h,c,l);if(!g.valid){let b=g.errors.map(d=>({path:d.path,code:d.code,message:d.message,paths:()=>[d.path]}));return A.error(b)}return A.ok(c)},parse:function(c,l){let h=this.parseRaw(c,l);return h.valid?A.ok(h.data):A.error([h.error])}}}return n<=3?St(t):_t(t)}function St(e){let t=e.map(([n,a])=>({path:n,isSimple:!n.includes("."),accessor:n.includes(".")?ae(n):null,setter:n.includes(".")?ie(n):null,validator:a}));return t.sort((n,a)=>n.isSimple&&!a.isSimple?-1:!n.isSimple&&a.isSimple?1:0),{validateRaw:n=>{if(!n)return!1;if(t.length===2){let r=t[0],s=t[1],o=r.isSimple?n[r.path]:r.accessor(n);if(!r.validator.validate(o,n).valid)return!1;let i=s.isSimple?n[s.path]:s.accessor(n);return!!s.validator.validate(i,n).valid}else if(t.length===3){let r=t[0],s=t[1],o=t[2],i=r.isSimple?n[r.path]:r.accessor(n);if(!r.validator.validate(i,n).valid)return!1;let c=s.isSimple?n[s.path]:s.accessor(n);if(!s.validator.validate(c,n).valid)return!1;let l=o.isSimple?n[o.path]:o.accessor(n);return!!o.validator.validate(l,n).valid}let a=t.length;for(let r=0;r<a;r++){let s=t[r],o=s.isSimple?n[s.path]:s.accessor(n);if(!s.validator.validate(o,n).valid)return!1}return!0},parseRaw:n=>{if(!n)return{valid:!1,error:"Value required"};let a=!1,r=n;if(t.length===2){let s=t[0],o=t[1],i=s.isSimple?r[s.path]:s.accessor(r),c=s.validator.parse(i,r);if(!c.valid)return{valid:!1,error:c.errors[0]};c.data!==void 0&&c.data!==i&&(a||(r={...n},a=!0),s.isSimple?r[s.path]=c.data:s.setter(r,c.data));let l=o.isSimple?r[o.path]:o.accessor(r),h=o.validator.parse(l,r);if(!h.valid)return{valid:!1,error:h.errors[0]};h.data!==void 0&&h.data!==l&&(a||(r={...n},a=!0),o.isSimple?r[o.path]=h.data:o.setter(r,h.data))}else if(t.length===3){let s=t[0],o=t[1],i=t[2],c=s.isSimple?r[s.path]:s.accessor(r),l=s.validator.parse(c,r);if(!l.valid)return{valid:!1,error:l.errors[0]};l.data!==void 0&&l.data!==c&&(a||(r={...n},a=!0),s.isSimple?r[s.path]=l.data:s.setter(r,l.data));let h=o.isSimple?r[o.path]:o.accessor(r),g=o.validator.parse(h,r);if(!g.valid)return{valid:!1,error:g.errors[0]};g.data!==void 0&&g.data!==h&&(a||(r={...n},a=!0),o.isSimple?r[o.path]=g.data:o.setter(r,g.data));let b=i.isSimple?r[i.path]:i.accessor(r),d=i.validator.parse(b,r);if(!d.valid)return{valid:!1,error:d.errors[0]};d.data!==void 0&&d.data!==b&&(a||(r={...n},a=!0),i.isSimple?r[i.path]=d.data:i.setter(r,d.data))}else{let s=t.length;for(let o=0;o<s;o++){let i=t[o],c=i.isSimple?r[i.path]:i.accessor(r),l=i.validator.parse(c,r);if(!l.valid)return{valid:!1,error:l.errors[0]};l.data!==void 0&&l.data!==c&&(a||(r={...n},a=!0),i.isSimple?r[i.path]=l.data:i.setter(r,l.data))}}return{valid:!0,data:r}},validate:function(n){return this.validateRaw(n)?A.ok(n):A.error([{path:"",code:"VALIDATION_ERROR",message:"Validation failed",paths:()=>[""]}])},parse:function(n){let a=this.parseRaw(n);return a.valid?A.ok(a.data):A.error([a.error])}}}function _t(e){let t=e.map(([n,a])=>({path:n,isSimple:!n.includes("."),accessor:n.includes(".")?ae(n):null,setter:n.includes(".")?ie(n):null,validator:a}));return t.sort((n,a)=>n.isSimple&&!a.isSimple?-1:!n.isSimple&&a.isSimple?1:0),{validateRaw:n=>{if(!n)return!1;let a=t.length;for(let r=0;r<a;r++){let s=t[r],o=s.isSimple?n[s.path]:s.accessor(n);if(!s.validator.validate(o,n).valid)return!1}return!0},parseRaw:n=>{if(!n)return{valid:!1,error:"Value required"};let a=n,r=!1,s=t.length;for(let o=0;o<s;o++){let i=t[o],c=i.isSimple?a[i.path]:i.accessor(a),l=i.validator.parse(c,a);if(!l.valid)return{valid:!1,error:l.errors[0]};l.data!==void 0&&l.data!==c&&(r||(a={...n},r=!0),i.isSimple?a[i.path]=l.data:i.setter(a,l.data))}return{valid:!0,data:a}},validate:function(n){return this.validateRaw(n)?A.ok(n):A.error([{path:"",code:"VALIDATION_ERROR",message:"Validation failed",paths:()=>[""]}])},parse:function(n){let a=this.parseRaw(n);return a.valid?A.ok(a.data):A.error([a.error])}}}var Bt=[],tn=Object.freeze({valid:!0,value:null,errors:Bt});function Le(e){function t(n){if(n.length===0)return Dt(e);let a=n.map(p=>{let P=!1,E=!1;if(p.builderFunction)try{let R=U(p.path,e),x=p.builderFunction(R);x?._validators&&(P=x._validators.some(O=>O.name==="optional"),E=x._validators.some(O=>O.name==="required"))}catch{P=!1,E=!1}return{path:p.path,builderFunction:p.builderFunction||(()=>{throw new Error(`Field ${p.path} uses object definition form`)}),isOptional:P,hasRequired:E}}),r=ye(a,e),{fastFields:s,slowFields:o}=je(r),i=Ie(n),c=new Set,l=new Map,h=new Map;for(let[p,P]of i)if(P._nestedInfo){l.set(p,P);for(let E of P.fullFieldPaths)c.add(E);c.add(p)}else{h.set(p,P);for(let E of P.fullFieldPaths)c.add(E)}let g=s.filter(p=>!c.has(p)),b=o.filter(p=>!c.has(p)),d=be(b,n.filter(p=>!c.has(p.path)),e),u=be(g,n.filter(p=>!c.has(p.path)),e),f=new Map,m=n.map(p=>p.path),y=be(m,n,e);for(let[p,P]of y)f.set(p,P);let F=new Map,V=new Map,T=new Map;for(let p of a)p.isOptional&&F.set(p.path,!0),p.hasRequired&&V.set(p.path,!0);for(let p of n)p.metadata?.fieldOptions&&T.set(p.path,p.metadata.fieldOptions);for(let[p,P]of f)p.includes("[*]")&&(u.has(p)&&u.set(p,P),d.has(p)&&d.set(p,P));return $t(d,u,n,e,l,f,F,V,T)}return{buildOptimizedValidator:t}}function Dt(e){let t=se([],e);return{validate:()=>A.ok({}),parse:(n,a)=>A.ok(n),pick:n=>t.createPickedValidator(n)}}function be(e,t,n){let a=new Map,r=new Map,s=new Map;for(let o of e){let i=t.find(c=>c.path===o);if(i&&i.builderFunction){let c=$(o),l=U(o,n),h=i.builderFunction(l);if(h&&typeof h.build=="function"&&(h=h.build()),h._validators?.some?.(d=>d.__isRecursive===!0)){let d=h._validators.find(u=>u.__isRecursive===!0);if(d?.recursive){let u={targetFieldPath:d.recursive.targetFieldPath,maxDepth:d.recursive.maxDepth||10};o.includes("[*]")?s.set(o,u):r.set(o,u)}}let b=G({path:i.path,builderFunction:i.builderFunction||(()=>({}))},n,"fast_separated",c);a.set(o,b)}}for(let[o,i]of r){let c=a.get(o),l=null;if(i.targetFieldPath==="__Self")l=null;else if(i.targetFieldPath==="__Element")l=null;else{let g=t.find(b=>b.path===i.targetFieldPath);g&&g.builderFunction&&(l=a.get(i.targetFieldPath)||null)}let h=zt(c,l,o,i.targetFieldPath,i.maxDepth,t.filter(g=>g.builderFunction).map(g=>({path:g.path,builderFunction:g.builderFunction})),n,a);a.set(o,h)}for(let[o,i]of s){let c=a.get(o),h=te(o).baseArrayPath+"[*]";if(Array.from(a.keys()).filter(b=>b.startsWith(h)&&b!==o).length>0){let b=qt(c,o,i.targetFieldPath,i.maxDepth,t.filter(d=>d.builderFunction).map(d=>({path:d.path,builderFunction:d.builderFunction})),n,a);a.set(o,b)}}return a}function $t(e,t,n,a,r,s,o,i,c){let l=r.size>0,h=e.size>0,g=t.size+e.size,b=!l&&!h&&t.size<=10;if((process.env.LUQ_ULTRA_FAST==="true"||global.__LUQ_ULTRA_FAST__===!0)&&!l&&g<=50){let V=new Map([...t,...e]),T=_e(V),p=se(n.map(R=>({path:R.path,builderFunction:R.builderFunction||(()=>({})),fieldType:R.fieldType||"unknown"})),a);return{validate:(R,x)=>{if(R==null)return A.error([{path:"",message:"Value is required",code:"REQUIRED",paths:()=>[""]}]);let O=R;if(c&&c.size>0){let v={...O};for(let[N,w]of c){let j=I(v,N),M=K(j,w,{allValues:v});M!==j&&B(v,N,M)}O=v}return T.validate(O,x)},parse:(R,x)=>{if(R==null)return A.error([{path:"",message:"Value is required",code:"REQUIRED",paths:()=>[""]}]);let v={...R};if(c&&c.size>0)for(let[N,w]of c){let j=I(v,N),M=K(j,w,{allValues:v});M!==j&&B(v,N,M)}return T.parse(v,x)},pick:R=>p.createPickedValidator(R),validateRaw:T.validateRaw.bind(T),parseRaw:T.parseRaw.bind(T)}}if(b)return Lt(t,n.map(V=>({path:V.path,builderFunction:V.builderFunction||(()=>({}))})),a,c);let f=Kt(e,t,r,s,o,i,c),m=n.map(V=>({path:V.path,builderFunction:V.builderFunction||(()=>({})),fieldType:V.fieldType||"unknown"})),y={validate:(V,T)=>f.executeValidate(V,T),parse:(V,T)=>f.executeParse(V,T),pick:null},F=se(m,a,void 0,y);return y.pick=V=>F.createPickedValidator(V),y}function Lt(e,t,n,a){let r=Array.from(e),s=r.length,o=[];for(let g=0;g<s;g++){let[b,d]=r[g];o.push({path:b,accessor:d.accessor||$(b),validator:d})}let i=t.map(g=>({path:g.path,builderFunction:g.builderFunction||(()=>({})),fieldType:g.fieldType||"unknown"})),c=se(i,n),l=[],h=A.ok({});if(s===1){let{path:g,accessor:b,validator:d}=o[0];return{validate:(u,f)=>{if(u==null)return A.error([{path:"",message:"Value is required",code:"REQUIRED",paths:()=>[""]}]);let m=u;if(a&&a.size>0){let V={...m};for(let[T,p]of a){let P=I(V,T),E=K(P,p,{allValues:V});E!==P&&B(V,T,E)}m=V}let y=b(m),F=d.validate(y,m,f);if(!F.valid){let V=F.errors.map(T=>({path:T.path,code:T.code,message:T.message,paths:()=>[T.path]}));return A.error(V)}return A.ok(u)},parse:(u,f)=>{if(u==null)return A.error([{path:"",message:"Value is required",code:"REQUIRED",paths:()=>[""]}]);let m=u,y={...m};if(a&&a.size>0)for(let[T,p]of a){let P=I(y,T),E=K(P,p,{allValues:y});E!==P&&B(y,T,E)}let F=b(y),V=d.parse(F,m,f);if(!V.valid){let T=V.errors.map(p=>({path:p.path,code:p.code,message:p.message,paths:()=>[p.path]}));return A.error(T)}return V.data!==void 0&&V.data!==F?(B(y,g,V.data),A.ok(y)):A.ok(y)},pick:u=>c.createPickedValidator(u)}}return{validate:(g,b)=>{if(g==null)return A.error([{path:"",message:"Value is required",code:"REQUIRED",paths:()=>[""]}]);let d=g;if(a&&a.size>0){let m={...d};for(let[y,F]of a){let V=I(m,y),T=K(V,F,{allValues:m});T!==V&&B(m,y,T)}d=m}let u=b?.abortEarly!==!1,f=b?.abortEarlyOnEachField!==!1;l.length=0;for(let m=0;m<s;m++){let{path:y,accessor:F,validator:V}=o[m],T=F(d),p=V.validate(T,d,{abortEarlyOnEachField:f});if(!p.valid){let P=p.errors;for(let E=0;E<P.length;E++){let R=P[E];l.push({path:R.path,code:R.code,message:R.message,paths:()=>[R.path]})}if(u)return A.error(l.slice())}}return l.length>0?A.error(l.slice()):A.ok(g)},parse:(g,b)=>{if(g==null)return A.error([{path:"",message:"Value is required",code:"REQUIRED",paths:()=>[""]}]);let u={...g};if(a&&a.size>0)for(let[y,F]of a){let V=I(u,y),T=K(V,F,{allValues:u});T!==V&&B(u,y,T)}let f=b?.abortEarly!==!1,m=b?.abortEarlyOnEachField!==!1;l.length=0;for(let y=0;y<s;y++){let{path:F,accessor:V,validator:T}=o[y],p=V(u),P=T.parse(p,u,{abortEarlyOnEachField:m});if(P.valid)P.data!==void 0&&B(u,F,P.data);else{let E=P.errors;for(let R=0;R<E.length;R++){let x=E[R];l.push({path:x.path,code:x.code,message:x.message,paths:()=>[x.path]})}if(f)return A.error(l.slice())}}return l.length>0?A.error(l.slice()):A.ok(u)},pick:g=>c.createPickedValidator(g)}}function Kt(e,t,n,a,r,s,o){let i=new Map,c=new Map;for(let[g,b]of t)i.has(g)||(i.set(g,b.accessor||$(g)),c.set(g,he(g)));for(let[g,b]of e)i.has(g)||(i.set(g,b.accessor||$(g)),c.set(g,he(g)));function l(g,b){if(g==null)return A.error([{path:"",message:"Value is required",code:"REQUIRED",paths:()=>[""]}]);let d=[],u=g;if(o&&o.size>0){let y={...u};for(let[F,V]of o){let T=I(y,F),p=K(T,V,{allValues:y});p!==T&&B(y,F,p)}u=y}let f=b?.abortEarly!==!1,m=b?.abortEarlyOnEachField!==!1;for(let[y,F]of n){let V=i.get(y)||$(y);i.has(y)||i.set(y,V);let T=V(u),p=a.get(y);if(p){let P;if(p.validate?P=p.validate(T,u,{abortEarlyOnEachField:m}):p.validateSlow?P=p.validateSlow(T,u,{abortEarlyOnEachField:m}):p.validateFast&&(P=p.validateFast(T,u)),P&&!P.valid){if(P.errors&&P.errors.length>0?d.push(...P.errors):d.push({path:y,code:"VALIDATION_ERROR",message:"Array field validation failed",paths:()=>[y]}),f)return A.error(d);continue}}if(Array.isArray(T)){let E=ne(F,a)(T,u,f,m,D);if(E.errors.length>0&&(d.push(...E.errors),f))return A.error(d)}}for(let[y,F]of t){if(y.includes(".")&&!y.includes("[")&&!y.includes("*")){let V=y.split(".");if(V.length>1){let T=!1;for(let p=0;p<V.length-1;p++){let P=V.slice(0,p+1).join("."),E=I(u,P);if(Array.isArray(E)&&E.length===0){T=!0;break}}if(T)continue}}if(!y.includes("[")&&!y.includes("*")){let V=i.get(y),T=V?V(u):I(u,y),p=F.validate(T,u,{abortEarlyOnEachField:m});if(!p.valid){if(p.errors&&p.errors.length>0)for(let P=0;P<p.errors.length;P++)d.push(p.errors[P]);if(f)return A.error(d)}}else{if(y.includes("[*]")||y.includes(".*")){let E=De(y,F,u,u,f,m);if(E.length>0&&(d.push(...E),f))return A.error(d);continue}let T=i.get(y),p=T?T(u):I(u,y),P=F.validate(p,u,{abortEarlyOnEachField:m});if(!P.valid){if(P.errors&&P.errors.length>0)for(let E=0;E<P.errors.length;E++)d.push(P.errors[E]);if(f)return A.error(d)}}}for(let[y,F]of e){if(y.includes(".")&&!y.includes("[")&&!y.includes("*")){let v=y.split(".");if(v.length>1){let N=!1;for(let w=0;w<v.length-1;w++){let j=v.slice(0,w+1).join("."),M=I(u,j);if(Array.isArray(M)&&M.length===0){N=!0;break}}if(N)continue}}if(y.includes("[*]")||y.includes(".*")){let v=De(y,F,u,u,f,m);if(v.length>0&&(d.push(...v),f))return A.error(d);continue}let T=c.get(y),p=T?T(u):Be(u,y),P=r.get(y)||!1,E=s.get(y)||!1;if(!p&&P)continue;if(!p&&!P&&!E){if(d.push({path:y,code:"REQUIRED",message:`Field '${y}' is required`,paths:()=>[y]}),f)return A.error(d);continue}let R=i.get(y),x=R?R(u):I(u,y),O=F.validate(x,u,{abortEarlyOnEachField:m});if(!O.valid){if(O.errors&&O.errors.length>0)for(let v=0;v<O.errors.length;v++)d.push(O.errors[v]);if(f)return A.error(d)}}return d.length>0?A.error(d):A.ok(g)}function h(g,b){if(g==null)return A.error([{path:"",message:"Value is required",code:"REQUIRED",paths:()=>[""]}]);let d=[],f={...g};if(o&&o.size>0)for(let[F,V]of o){let T=I(f,F),p=K(T,V,{allValues:f});p!==T&&B(f,F,p)}let m=b?.abortEarly!==!1,y=b?.abortEarlyOnEachField!==!1;for(let[F,V]of n){let T=i.get(F)||$(F);i.has(F)||i.set(F,T);let p=T(f),P=a.get(F);if(P){let E;if(P.parse?E=P.parse(p,f,{abortEarlyOnEachField:y}):P.parseSlow?E=P.parseSlow(p,f,{abortEarlyOnEachField:y}):P.parseFast&&(E=P.parseFast(p,f)),E&&!E.valid){if(E.errors&&E.errors.length>0?d.push(...E.errors):d.push({path:F,code:"PARSE_ERROR",message:"Array field parsing failed",paths:()=>[F]}),m)return A.error(d);continue}else if(E&&E.data!==void 0){B(f,F,E.data);let R=T(f);if(Array.isArray(R)){let O=ne(V,a)(R,f,m,y,k);if(O.errors.length>0&&(d.push(...O.errors),m))return A.error(d);O.transformedData&&B(f,F,O.transformedData)}continue}}if(Array.isArray(p)){let R=ne(V,a)(p,f,m,y,k);if(R.errors.length>0&&(d.push(...R.errors),m))return A.error(d);R.transformedData&&B(f,F,R.transformedData)}}for(let[F,V]of t){let T=i.get(F),p=T?T(f):I(f,F),P=V.parse(p,f,{abortEarlyOnEachField:y});if(P.valid)P.data!==void 0&&B(f,F,P.data);else{if(P.errors&&P.errors.length>0)for(let E=0;E<P.errors.length;E++)d.push(P.errors[E]);if(m)return A.error(d)}}for(let[F,V]of e){let T=c.get(F),p=T?T(f):Be(f,F),P=r.get(F)||!1,E=s.get(F)||!1;if(!p&&P)continue;if(!p&&!P&&!E){if(d.push({path:F,code:"REQUIRED",message:`Field '${F}' is required`,paths:()=>[F]}),m)return A.error(d);continue}let R=i.get(F),x=R?R(f):I(f,F),O=V.parse(x,f,{abortEarlyOnEachField:y});if(O.valid)O.data!==void 0&&B(f,F,O.data);else{if(O.errors&&O.errors.length>0)for(let v=0;v<O.errors.length;v++)d.push(O.errors[v]);if(m)return A.error(d)}}return d.length>0?A.error(d):A.ok(f)}return{executeValidate:l,executeParse:h}}function I(e,t){return $(t)(e)}function Ut(e){if(e.includes(_)){let t=e.split(_),n=t.length-1;return a=>{let r=a;for(let o=0;o<n;o++){let i=t[o];if(!(i in r)||r[i]==null||typeof r[i]!="object")return!1;r=r[i]}return t[n]in r}}else return t=>e in t}function Be(e,t){return Ut(t)(e)}function Wt(e){if(e.includes(_)){let t=e.split(_),n=t.length-1;return(a,r)=>{let s=a;for(let o=0;o<n;o++){let i=t[o];(!(i in s)||typeof s[i]!="object")&&(s[i]={}),s=s[i]}s[t[n]]=r}}else return(t,n)=>{t[e]=n}}function B(e,t,n){Wt(t)(e,n)}function De(e,t,n,a,r,s){let o=[],i,c,l=e.match(/^([^\[]+)\[\*\]\.(.+)$/);if(l)i=l[1],c=l[2];else{let g=e.match(/^([^\.]+)\.\*\.(.+)$/);if(g)i=g[1],c=g[2];else{let b=e.match(/^([^\[]+)\[\*\]$/);if(b)i=b[1],c="";else return o}}let h=I(n,i);if(!Array.isArray(h))return o;if(c===""){for(let g=0;g<h.length;g++){let b=h[g],d=`${i}[${g}]`,u=t.validate(b,a,{abortEarlyOnEachField:s});if(!u.valid){if(u.errors&&u.errors.length>0)for(let f of u.errors)o.push({path:f.path?`${d}.${f.path}`:d,code:f.code||"VALIDATION_ERROR",message:f.message||"Validation failed",paths:()=>[f.path?`${d}.${f.path}`:d]});else o.push({path:d,code:"VALIDATION_ERROR",message:"Validation failed",paths:()=>[d]});if(r)break}}return o}if(h.length===0)return o;for(let g=0;g<h.length;g++){let b=h[g];if(!b||typeof b!="object")continue;let d=I(b,c),u=`${i}[${g}].${c}`,f=t.validate(d,a,{abortEarlyOnEachField:s});if(!f.valid){if(f.errors&&f.errors.length>0)for(let m of f.errors)o.push({path:m.path||u,code:m.code||"VALIDATION_ERROR",message:m.message||"Validation failed",paths:()=>[m.path||u]});else o.push({path:u,code:"VALIDATION_ERROR",message:"Validation failed",paths:()=>[u]});if(r)break}}return o}function zt(e,t,n,a,r,s,o,i){let c=(l,h,g,b,d,u)=>{if(g>r)return{valid:!0,errors:[]};if(l&&typeof l=="object"&&d.has(l))return{valid:!0,errors:[]};if(l&&typeof l=="object"&&d.add(l),l==null){let m=e.validate(l,h,u);return m.valid?{valid:!0,errors:[]}:{valid:!1,errors:m.errors.map(F=>({...F,path:b}))}}let f=e.validate(l,h,u);if(!f.valid)return{valid:!1,errors:f.errors.map(y=>({...y,path:b}))};if(a==="__Self"){if(l&&typeof l=="object"&&i){let m=[];for(let[y,F]of i){if(y===n)continue;if(y.includes("[*]")){let E=me(y)(l);if(E){let{elements:R,basePath:x,elementPath:O}=E;R.forEach((v,N)=>{let w=F.validate(v,h,u);if(!w.valid)for(let j of w.errors){let M=O?`${b}.${x}[${N}].${O}`:`${b}.${x}[${N}]`;m.push({...j,path:M})}})}continue}let T=$(y)(l),p=F.validate(T,h,u);if(!p.valid)for(let P of p.errors)m.push({...P,path:`${b}.${P.path}`})}for(let[y,F]of i){if(y===n)continue;if(y.includes("[*]")){let p=me(y)(l);if(p){let{elements:P,basePath:E,elementPath:R}=p;P.forEach((x,O)=>{if(x&&typeof x=="object"){let v=s.find(N=>N.path===y);if(v?.builderFunction){let N=U(y,o),w=v.builderFunction(N);if(w?.build&&(w=w.build()),w?._validators?.some?.(M=>M.__isRecursive===!0)){let M=R?`${b}.${E}[${O}].${R}`:`${b}.${E}[${O}]`,q=c(x,h,g+1,M,d,u);q.valid||m.push(...q.errors)}}}})}continue}let V=$(y)(l);if(V&&typeof V=="object"){let T=s.find(E=>E.path===y),p=null;if(T?.builderFunction){let E=U(y,o);p=T.builderFunction(E),p?.build&&(p=p.build())}if(p?._validators?.some?.(E=>E.__isRecursive===!0)){let E=c(V,h,g+1,`${b}.${y}`,d,u);E.valid||m.push(...E.errors)}}}if(m.length>0)return{valid:!1,errors:m}}}else if(a==="__Element"){if(Array.isArray(l)){let m=[];for(let y=0;y<l.length;y++){let F=l[y];if(F&&typeof F=="object"&&i)for(let[V,T]of i){if(V.includes("[*]"))continue;let P=$(V)(F),E=T.validate(P,h,u);if(!E.valid)for(let R of E.errors)m.push({...R,path:`${b}[${y}].${R.path}`})}}if(m.length>0)return{valid:!1,errors:m}}}else if(t&&l&&typeof l=="object"){let m=[],y=u?.abortEarlyOnEachField!==!1,F=a.split("."),V=F[F.length-1];if(Array.isArray(l))for(let T=0;T<l.length;T++){let p=l[T];if(p&&typeof p=="object"&&V in p){let P=p[V],E=`${b}[${T}].${V}`,R=c(P,h,g+1,E,d,u);if(!R.valid&&(m.push(...R.errors),y))return{valid:!1,errors:m}}}else if(V in l){let T=l[V],p=`${b}.${V}`,P=c(T,h,g+1,p,d,u);if(!P.valid&&(m.push(...P.errors),y))return{valid:!1,errors:m}}if(m.length>0)return{valid:!1,errors:m}}return l&&typeof l=="object"&&d.delete(l),{valid:!0,errors:[]}};return{validate:(l,h,g)=>c(l,h,0,n,new WeakSet,g),parse:(l,h,g)=>{let d=c(l,h,0,n,new WeakSet,g);return d.valid?{valid:!0,data:l,errors:[]}:{...d,data:void 0}},accessor:e.accessor}}function qt(e,t,n,a,r,s,o){let i=te(t);return{validate:(c,l,h)=>{if(c==null||!Array.isArray(c))return e.validate(c,l,h);let g=[],b=new WeakSet;return c.forEach((d,u)=>{if(d&&typeof d=="object"&&n==="__Self"&&o){for(let[f,m]of o)if(f.includes("[*]")){let y=i.baseArrayPath+"[*]";if(f.startsWith(y)){let F=f.slice(y.length),V,T,p;if(F==="")continue;if(F.startsWith("."))p=F.slice(1),V=$(p)(d),T=i.baseArrayPath?`${i.baseArrayPath}[${u}].${p}`:`[${u}].${p}`;else continue;let P=m.validate(V,l,h);if(!P.valid)for(let E of P.errors)g.push({...E,path:T})}continue}for(let[f,m]of o)if(f.includes("[*]")){let y=i.baseArrayPath+"[*]";if(f.startsWith(y)){let F=f.slice(y.length);if(F.startsWith(".")){let V=F.slice(1),T=$(V)(d);Array.isArray(T)&&T.forEach((p,P)=>{if(p&&typeof p=="object"){for(let[E,R]of o)if(E.includes("[*]")&&E.startsWith(y)){let x=E.slice(y.length);if(x.startsWith(".")&&x!=="."+V){let O=x.slice(1),v=$(O)(p),N=`${i.baseArrayPath}[${u}].${V}[${P}].${O}`,w=R.validate(v,l,h);if(!w.valid)for(let j of w.errors)g.push({...j,path:N})}}}})}}}}}),{valid:g.length===0,errors:g}},parse:(c,l,h)=>e.parse(c,l,h),accessor:e.accessor}}function $e(e,t){let n="^"+t.replace(/\[\*\]/g,"\\[\\d+\\]")+"$";return new RegExp(n).test(e)}function se(e,t,n,a){function r(s){let o=s,i=e.find(f=>f.path===o),c=e.filter(f=>!!(f.path===o||f.path.startsWith(o+"[*]")||f.path.startsWith(o+".*")||f.path.startsWith(o+".")));if(!i&&c.length===0)return{validate:()=>({valid:!0,value:void 0,errors:[]}),parse:()=>({valid:!0,value:void 0,errors:[]})};if(c.length>1){let f=new Set(c.map(m=>m.path));return{validate:(m,y,F)=>{if(a){let T={[o]:m},p=a.validate(T,F),P=p.valid?[]:(p.errors||[]).filter(E=>{for(let R of f)if($e(E.path,R))return!0;return!1});return{valid:P.length===0,value:P.length===0?m:null,errors:P}}let V=[];for(let T of c){let P=G(T,t).validate({[o]:m},{[o]:m},F);!P.valid&&P.errors&&V.push(...P.errors)}return{valid:V.length===0,value:V.length===0?m:null,errors:V}},parse:(m,y,F)=>{if(a){let T={[o]:m},p=a.parse(T,F);if(!p.valid){let R=(p.errors||[]).filter(x=>{for(let O of f)if($e(x.path,O))return!0;return!1});if(R.length>0)return{valid:!1,value:void 0,errors:R}}let P=p.valid?p.value:T;return{valid:!0,value:P&&P[o]!==void 0?P[o]:m,errors:[]}}let V=[];for(let T of c){let P=G(T,t).validate({[o]:m},{[o]:m},F);!P.valid&&P.errors&&V.push(...P.errors)}return{valid:V.length===0,value:V.length===0?m:null,errors:V}}}}if(!i)return{validate:()=>({valid:!0,value:void 0,errors:[]}),parse:()=>({valid:!0,value:void 0,errors:[]})};let l=U(i.path,t);if(!i.builderFunction)throw new Error(`Field definition for path '${i.path}' is missing builderFunction`);let h=i.builderFunction(l),g={path:i.path,builderFunction:i.builderFunction||(()=>{throw new Error(`Field ${i.path} uses object definition form`)})},d=ye([g],t).get(i.path),u;return u=G(i,t),{validate:(f,m,y)=>{let F={...m};B(F,s,f);let V=I(F,s),T=u.validate(V,F,y);return{valid:T.valid,value:T.valid?f??null:null,errors:T.errors||[]}},parse:(f,m,y)=>{let F={...m};B(F,s,f);let V=I(F,s),T=u.parse(V,F,y);return{valid:T.valid,value:T.valid?T.data!==void 0?T.data:f:null,errors:T.errors||[]}}}}return{createPickedValidator:r}}function H(e,t,n=[],a=!1){let r=[...n],s=a,o,i=u=>u.includes(_)?"nested":"scalar",c=(u,f,m)=>{let y=m!==void 0?Z(m):void 0,F={path:u,inferredType:i(u),builderFunction:f,fieldOptions:y,fieldType:{}};return H(e,t,[...r,F],s)},l=c,h=(u,f)=>{let m={path:u,inferredType:i(u),builderFunction:()=>f,fieldOptions:f.fieldOptions,fieldType:{}};return H(e,t,[...r,m],s)},g=()=>H(e,t,r,!0);return{field:c,v:l,useField:h,strict:g,strictOnEditor:g,build:()=>{o||(o=Le(e));let u=r.map(f=>{let m=U(f.path,e),y=f.builderFunction(m);return{path:f.path,builderFunction:f.builderFunction,rules:Array.isArray(y)?y:[y],metadata:{inferredType:f.inferredType,hasTransforms:!1,fieldOptions:f.fieldOptions},fieldType:f.inferredType||"unknown"}});return o.buildOptimizedValidator(u)}}}function Gt(){let e={},t={for(){return H(e,t,void 0,!1)},use(...n){if(n.length===0)return t;for(let a=0;a<n.length;a++){let r=n[a];if(!r)continue;if(typeof r!="object"||!r.name)throw console.error("Invalid plugin:",r),new Error(`Invalid plugin at index ${a}: plugin must be an object with a 'name' property`);let s=r.name;e[s]||(e[s]=r,r.category==="builder-extension"&&r.extendBuilder&&typeof r.extendBuilder=="function"&&(r.methodName&&r.impl&&(t[r.methodName]=r.impl),r.extendBuilder(t),r.methodName&&!t[r.methodName]&&console.warn(`BuilderExtensionPlugin ${r.name} did not add ${r.methodName} method`)))}return t}};return t}function Ht(){return Gt()}var oe=Ht;function Ke(e,t){let n={plugins:e?new Map(e):new Map,pluginsObject:t||{}},a={use(r){n.plugins.set(r.name,r);let s={...n.pluginsObject,[r.name]:r};return Ke(n.plugins,s)},createFieldRule(r,s){return We(a,n.pluginsObject,r,s)},toBuilder(){let r=oe(),s=Array.from(n.plugins.values()),o=s.length;for(let i=0;i<o;i++){let c=s[i];r=r.use(c)}return r},getPlugins(){let r={},s=Array.from(n.plugins.entries()),o=s.length;for(let i=0;i<o;i++){let[c,l]=s[i];r[c]=l}return r},for(){return Ue(n.plugins,n.pluginsObject,a)}};return a}function Ue(e,t,n){return{use:n.use,toBuilder:n.toBuilder,getPlugins:n.getPlugins,createFieldRule(r,s){return We(n,t,r,s)},for(){return Ue(e,t,n)}}}function We(e,t,n,a){let r={};a!==void 0&&(typeof a=="object"&&a!==null&&("name"in a||"description"in a||"fieldOptions"in a)?r=a:r={fieldOptions:Z(a)});let s=()=>{let i=`__standalone__${r?.name||Math.random()}`,c=U(i,t),h=n(c).build();return{validate:(g,b,d)=>{let u=g;r?.fieldOptions&&(u=K(g,r.fieldOptions,{allValues:b||{}}));let f=h._validators||[],m=h._transforms||[];for(let F of f)if(F.check&&!F.check(u,b||{})){let V=typeof F.messageFactory=="function"?F.messageFactory({path:i,value:u,context:b||{}}):"Validation failed";return{valid:!1,errors:[{path:i,message:V,code:F.name||"VALIDATION_ERROR",paths:()=>[i]}],data:u}}let y=u;for(let F of m)typeof F=="function"?y=F(y):F&&typeof F.transformFn=="function"&&(y=F.transformFn(y));return{valid:!0,data:y,errors:[]}},_executionPlan:h._executionPlan,_validators:h._validators,_transforms:h._transforms}};return{_phantomType:void 0,name:r?.name,description:r?.description,fieldOptions:r?.fieldOptions,_getInternalValidators:()=>{let i=s();return{validators:i._validators||[],transforms:i._transforms||[],executionPlan:i._executionPlan}},validate(i,c){try{let h=s().validate(i,{},c);return h.valid?A.ok(h.data):A.error(h.errors||[])}catch(l){return A.error([{path:"",message:l instanceof Error?l.message:"Validation failed",code:"FIELD_RULE_ERROR",paths:()=>[""]}])}},parse(i,c){try{let l=i;r?.fieldOptions&&(l=K(i,r.fieldOptions,{allValues:{}}));let h=s();if(h._executionPlan&&typeof h._executionPlan.execute=="function"){let g={originalValue:l,currentValue:l,allValues:{},path:r?.name||"field",reporter:{report:()=>{},getReports:()=>[]}},b=h._executionPlan.execute(l,g);return b.valid?A.ok(b.finalValue):A.error(b.errors||[])}else{let g=l;if(h._transforms)for(let u of h._transforms)typeof u=="function"&&(g=u(g));let b=h._validators||[],d=r?.name||"field";for(let u of b)if(u.check&&!u.check(g,{})){let f=typeof u.messageFactory=="function"?u.messageFactory({path:d,value:g,context:{}}):"Validation failed";return A.error([{path:d,message:f,code:u.name||"VALIDATION_ERROR",paths:()=>[d]}])}return A.ok(g)}}catch(l){return A.error([{path:"",message:l instanceof Error?l.message:"Parse failed",code:"FIELD_RULE_PARSE_ERROR",paths:()=>[""]}])}},getPluginRegistry(){return e}}}function ze(){return Ke()}var Yt=(e,t,n,a)=>{let s=(o=>(...i)=>{let c=o(...i);return c&&typeof c=="object"&&"check"in c?{...c,pluginName:a}:c})(n);switch(e){case"conditional":return(o,...i)=>s(o,...i);case"fieldReference":return(o,...i)=>s(o,...i);case"multiFieldReference":return s;case"transform":return o=>s(o);case"arrayElement":return(o,...i)=>s(o,...i);case"context":return o=>s(o);default:return s}};function qe(e){let{name:t,methodName:n,allowedTypes:a,category:r,impl:s}=e;return{name:t,methodName:n,allowedTypes:a,category:r,create:()=>Yt(r,n,s,t)}}function Ge(e){let{name:t,allowedTypes:n,impl:a}=e,r=()=>a();return{name:t,methodName:t,allowedTypes:n,category:"transform",create:()=>r}}function He(e){let{name:t,allowedTypes:n,impl:a}=e,r=(...s)=>a(...s);return{name:t,methodName:t,allowedTypes:n,category:"transform",create:()=>r}}function Ye(e){let{name:t,methodName:n,impl:a,extendBuilder:r}=e;return{name:t,methodName:n,category:"builder-extension",impl:a(),extendBuilder:r}}var Y={messageKeyPrefix:"",toBooleanTruthyValues:["true","1","yes","on"],numberFormat:{decimalSeparator:".",thousandSeparator:","},dateFormat:"YYYY-MM-DD",trimStrings:!1,caseSensitive:!0,customTransforms:{}},L={...Y},Q={setConfig(e){L={...L,...e,numberFormat:e.numberFormat?{...L.numberFormat,...e.numberFormat}:L.numberFormat}},getConfig(){return{...L}},get messageKeyPrefix(){return L.messageKeyPrefix||""},get toBooleanTruthyValues(){return[...L.toBooleanTruthyValues||[]]},get numberFormat(){return{...L.numberFormat}},get dateFormat(){return L.dateFormat||"YYYY-MM-DD"},get trimStrings(){return L.trimStrings||!1},get caseSensitive(){return L.caseSensitive!==!1},get customTransforms(){return{...L.customTransforms}},reset(){L={...Y,numberFormat:{...Y.numberFormat},toBooleanTruthyValues:[...Y.toBooleanTruthyValues],customTransforms:{...Y.customTransforms}}}};function Qe(e){Q.setConfig(e)}function Ze(){return Q.getConfig()}function Je(){Q.reset()}0&&(module.exports={Builder,Result,createPluginRegistry,getGlobalConfig,globalConfig,plugin,pluginBuilderExtension,pluginConfigurableTransform,pluginPredefinedTransform,resetGlobalConfig,setGlobalConfig});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|