@rilaykit/core 10.0.0 → 11.1.0

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/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import { StandardSchemaV1 } from '@standard-schema/spec';
1
2
  import * as React$1 from 'react';
2
3
  import React__default from 'react';
3
4
 
@@ -213,6 +214,7 @@ interface ValidationError {
213
214
  interface ValidationResult {
214
215
  readonly isValid: boolean;
215
216
  readonly errors: ValidationError[];
217
+ readonly value?: any;
216
218
  }
217
219
  interface ValidationContext {
218
220
  readonly fieldId?: string;
@@ -223,32 +225,46 @@ interface ValidationContext {
223
225
  readonly stepData?: Record<string, any>;
224
226
  readonly workflowData?: Record<string, any>;
225
227
  }
228
+ /** @internal - Use Standard Schema instead */
226
229
  type FieldValidator<T = any> = (value: T, context: ValidationContext) => ValidationResult | Promise<ValidationResult>;
230
+ /** @internal - Use Standard Schema instead */
227
231
  type FormValidator<T = Record<string, any>> = (formData: T, context: ValidationContext) => ValidationResult | Promise<ValidationResult>;
228
- type ValidationSchema<T = any> = {
229
- parse: (value: T) => T;
230
- safeParse: (value: T) => {
231
- success: boolean;
232
- data?: T;
233
- error?: any;
234
- };
235
- };
236
- interface ValidationAdapter<TSchema = any> {
237
- readonly name: string;
238
- readonly version?: string;
239
- createFieldValidator<T>(schema: TSchema): FieldValidator<T>;
240
- createFormValidator<T>(schema: TSchema): FormValidator<T>;
241
- }
242
- interface FieldValidationConfig {
243
- readonly validators?: FieldValidator[];
244
- readonly schema?: ValidationSchema;
232
+ type StandardSchema<Input = unknown, Output = Input> = StandardSchemaV1<Input, Output>;
233
+ type InferInput<T> = T extends StandardSchema<infer I, any> ? I : unknown;
234
+ type InferOutput<T> = T extends StandardSchema<any, infer O> ? O : unknown;
235
+ interface FieldValidationConfig<T = any> {
236
+ /**
237
+ * Validation rules using Standard Schema interface
238
+ * Accepts: single schema, array of schemas, or any Standard Schema compatible validation
239
+ *
240
+ * @example Single schema
241
+ * validate: z.string().email()
242
+ *
243
+ * @example Built-in validators
244
+ * validate: required()
245
+ *
246
+ * @example Multiple validations
247
+ * validate: [required(), email()]
248
+ *
249
+ * @example Mixed schemas + validators
250
+ * validate: [z.string(), required(), customValidator()]
251
+ */
252
+ readonly validate?: StandardSchema<T> | StandardSchema<T>[];
245
253
  readonly validateOnChange?: boolean;
246
254
  readonly validateOnBlur?: boolean;
247
255
  readonly debounceMs?: number;
248
256
  }
249
- interface FormValidationConfig {
250
- readonly validators?: FormValidator[];
251
- readonly schema?: ValidationSchema;
257
+ interface FormValidationConfig<T extends Record<string, any> = Record<string, any>> {
258
+ /**
259
+ * Form-level validation using Standard Schema interface
260
+ *
261
+ * @example Object schema
262
+ * validate: z.object({ email: z.string().email(), name: z.string() })
263
+ *
264
+ * @example Custom form validator
265
+ * validate: customFormValidator()
266
+ */
267
+ readonly validate?: StandardSchema<T> | StandardSchema<T>[];
252
268
  readonly validateOnSubmit?: boolean;
253
269
  readonly validateOnStepChange?: boolean;
254
270
  }
@@ -634,10 +650,10 @@ declare function configureObject<T>(target: T, updates: Partial<T>, allowedKeys?
634
650
  declare function resolveRendererChildren<TProps>(children: React.ReactNode | RendererChildrenFunction<TProps> | undefined, props: TProps): React.ReactNode;
635
651
 
636
652
  /**
637
- * @fileoverview Validation utilities
653
+ * @fileoverview Clean validation utilities for Standard Schema
638
654
  *
639
- * This module provides utility functions for working with validation results,
640
- * combining validators, and managing validation contexts.
655
+ * This module provides utility functions for working with validation results
656
+ * and managing validation contexts using Standard Schema exclusively.
641
657
  */
642
658
 
643
659
  /**
@@ -656,60 +672,30 @@ declare function resolveRendererChildren<TProps>(children: React.ReactNode | Ren
656
672
  */
657
673
  declare function createValidationResult(isValid: boolean, errors?: ValidationError[]): ValidationResult;
658
674
  /**
659
- * Combines multiple validation results into a single result
675
+ * Creates a successful validation result
660
676
  *
661
- * The combined result is valid only if all input results are valid.
662
- * All errors from all results are included in the combined result.
663
- *
664
- * @param results - Array of ValidationResult objects to combine
665
- * @returns A single ValidationResult combining all inputs
677
+ * @returns A successful ValidationResult with no errors
666
678
  *
667
679
  * @example
668
680
  * ```typescript
669
- * const combined = combineValidationResults([
670
- * emailValidator(value),
671
- * requiredValidator(value),
672
- * minLengthValidator(value)
673
- * ]);
681
+ * const success = createSuccessResult();
674
682
  * ```
675
683
  */
676
- declare function combineValidationResults(results: ValidationResult[]): ValidationResult;
684
+ declare function createSuccessResult(): ValidationResult;
677
685
  /**
678
- * Runs multiple synchronous validators and combines their results
686
+ * Creates a failed validation result with a single error
679
687
  *
680
- * @param validators - Array of validators to run
681
- * @param value - The value to validate
682
- * @param context - Validation context
683
- * @returns Combined validation result
684
- *
685
- * @example
686
- * ```typescript
687
- * const result = runValidators([
688
- * required,
689
- * email,
690
- * minLength(5)
691
- * ], emailValue, context);
692
- * ```
693
- */
694
- declare function runValidators<T>(validators: FieldValidator<T>[], value: T, context: ValidationContext): ValidationResult;
695
- /**
696
- * Runs multiple asynchronous validators and combines their results
697
- *
698
- * @param validators - Array of validators to run (can be sync or async)
699
- * @param value - The value to validate
700
- * @param context - Validation context
701
- * @returns Promise resolving to combined validation result
688
+ * @param message - The error message
689
+ * @param code - Optional error code
690
+ * @param path - Optional field path
691
+ * @returns A failed ValidationResult
702
692
  *
703
693
  * @example
704
694
  * ```typescript
705
- * const result = await runValidatorsAsync([
706
- * required,
707
- * email,
708
- * checkEmailUnique // async validator
709
- * ], emailValue, context);
695
+ * const error = createErrorResult('Email is invalid', 'INVALID_EMAIL');
710
696
  * ```
711
697
  */
712
- declare function runValidatorsAsync<T>(validators: FieldValidator<T>[], value: T, context: ValidationContext): Promise<ValidationResult>;
698
+ declare function createErrorResult(message: string, code?: string, path?: string): ValidationResult;
713
699
  /**
714
700
  * Creates a validation context object
715
701
  *
@@ -728,195 +714,120 @@ declare function runValidatorsAsync<T>(validators: FieldValidator<T>[], value: T
728
714
  declare function createValidationContext(options?: Partial<ValidationContext>): ValidationContext;
729
715
 
730
716
  /**
731
- * @fileoverview Built-in validators
732
- *
733
- * This module provides a comprehensive set of built-in validators for common
734
- * validation scenarios. These validators follow the FieldValidator interface
735
- * and can be used standalone or combined with other validators.
717
+ * Built-in validators implementing Standard Schema interface
718
+ * All RilayKit validators now implement Standard Schema for consistency
736
719
  */
737
720
 
738
721
  /**
739
- * Validates that a value is not empty, null, or undefined
740
- *
741
- * @param message - Custom error message (optional)
742
- * @returns A FieldValidator function
743
- *
744
- * @example
745
- * ```typescript
746
- * const nameValidator = required('Name is required');
747
- * ```
722
+ * Required field validator - Standard Schema implementation
748
723
  */
749
- declare function required(message?: string): FieldValidator;
724
+ declare function required(message?: string): StandardSchemaV1<any>;
750
725
  /**
751
- * Validates minimum string length
752
- *
753
- * @param min - Minimum length required
754
- * @param message - Custom error message (optional)
755
- * @returns A FieldValidator function
756
- *
757
- * @example
758
- * ```typescript
759
- * const passwordValidator = minLength(8, 'Password must be at least 8 characters');
760
- * ```
726
+ * Email validation - Standard Schema implementation
761
727
  */
762
- declare function minLength(min: number, message?: string): FieldValidator<string>;
728
+ declare function email(message?: string): StandardSchemaV1<string>;
763
729
  /**
764
- * Validates maximum string length
765
- *
766
- * @param max - Maximum length allowed
767
- * @param message - Custom error message (optional)
768
- * @returns A FieldValidator function
769
- *
770
- * @example
771
- * ```typescript
772
- * const bioValidator = maxLength(500, 'Bio must be under 500 characters');
773
- * ```
730
+ * URL validation - Standard Schema implementation
774
731
  */
775
- declare function maxLength(max: number, message?: string): FieldValidator<string>;
732
+ declare function url(message?: string): StandardSchemaV1<string>;
776
733
  /**
777
- * Validates that a string matches a regular expression pattern
778
- *
779
- * @param regex - The regular expression pattern
780
- * @param message - Custom error message (optional)
781
- * @returns A FieldValidator function
782
- *
783
- * @example
784
- * ```typescript
785
- * const phoneValidator = pattern(/^\d{3}-\d{3}-\d{4}$/, 'Invalid phone format');
786
- * ```
734
+ * Minimum length validation - Standard Schema implementation
787
735
  */
788
- declare function pattern(regex: RegExp, message?: string): FieldValidator<string>;
736
+ declare function minLength(min: number, message?: string): StandardSchemaV1<string>;
789
737
  /**
790
- * Email validation using a comprehensive regex pattern
791
- *
792
- * @param message - Custom error message (optional)
793
- * @returns A FieldValidator function
794
- *
795
- * @example
796
- * ```typescript
797
- * const emailValidator = email('Please enter a valid email address');
798
- * ```
738
+ * Maximum length validation - Standard Schema implementation
799
739
  */
800
- declare function email(message?: string): FieldValidator<string>;
740
+ declare function maxLength(max: number, message?: string): StandardSchemaV1<string>;
801
741
  /**
802
- * URL validation using a comprehensive regex pattern
803
- *
804
- * @param message - Custom error message (optional)
805
- * @returns A FieldValidator function
806
- *
807
- * @example
808
- * ```typescript
809
- * const websiteValidator = url('Please enter a valid URL');
810
- * ```
742
+ * Pattern validation - Standard Schema implementation
811
743
  */
812
- declare function url(message?: string): FieldValidator<string>;
744
+ declare function pattern(regex: RegExp, message?: string): StandardSchemaV1<string>;
813
745
  /**
814
- * Validates that a value is a valid number
815
- *
816
- * @param message - Custom error message (optional)
817
- * @returns A FieldValidator function
818
- *
819
- * @example
820
- * ```typescript
821
- * const ageValidator = number('Age must be a valid number');
822
- * ```
746
+ * Number validation - Standard Schema implementation
823
747
  */
824
- declare function number(message?: string): FieldValidator<string | number>;
748
+ declare function number(message?: string): StandardSchemaV1<number>;
825
749
  /**
826
- * Validates minimum numeric value
827
- *
828
- * @param minValue - Minimum value allowed
829
- * @param message - Custom error message (optional)
830
- * @returns A FieldValidator function
831
- *
832
- * @example
833
- * ```typescript
834
- * const ageValidator = min(18, 'Must be at least 18 years old');
835
- * ```
750
+ * Minimum value validation - Standard Schema implementation
836
751
  */
837
- declare function min(minValue: number, message?: string): FieldValidator<string | number>;
752
+ declare function min(minValue: number, message?: string): StandardSchemaV1<number>;
838
753
  /**
839
- * Validates maximum numeric value
840
- *
841
- * @param maxValue - Maximum value allowed
842
- * @param message - Custom error message (optional)
843
- * @returns A FieldValidator function
844
- *
845
- * @example
846
- * ```typescript
847
- * const scoreValidator = max(100, 'Score cannot exceed 100');
848
- * ```
754
+ * Maximum value validation - Standard Schema implementation
849
755
  */
850
- declare function max(maxValue: number, message?: string): FieldValidator<string | number>;
756
+ declare function max(maxValue: number, message?: string): StandardSchemaV1<number>;
851
757
  /**
852
- * Creates a custom validator from a validation function
853
- *
854
- * @param validateFn - Custom validation function
855
- * @param message - Error message for failed validation
856
- * @param code - Optional error code
857
- * @returns A FieldValidator function
858
- *
859
- * @example
860
- * ```typescript
861
- * const evenNumberValidator = custom(
862
- * (value) => Number(value) % 2 === 0,
863
- * 'Number must be even',
864
- * 'NOT_EVEN'
865
- * );
866
- * ```
758
+ * Custom validator - Standard Schema implementation
867
759
  */
868
- declare function custom<T>(validateFn: (value: T, context: ValidationContext) => boolean, message: string, code?: string): FieldValidator<T>;
760
+ declare function custom<T>(fn: (value: T) => boolean, message?: string): StandardSchemaV1<T>;
869
761
  /**
870
- * Creates a validator that checks if a value matches another field's value
871
- *
872
- * @param targetFieldId - ID of the field to match against
873
- * @param message - Custom error message (optional)
874
- * @returns A FieldValidator function
875
- *
876
- * @example
877
- * ```typescript
878
- * const confirmPasswordValidator = matchField('password', 'Passwords must match');
879
- * ```
762
+ * Async validator - Standard Schema implementation
880
763
  */
881
- declare function matchField(targetFieldId: string, message?: string): FieldValidator;
764
+ declare function async<T>(fn: (value: T) => Promise<boolean>, message?: string): StandardSchemaV1<T>;
882
765
  /**
883
- * Creates a validator that only validates when a condition is met
884
- *
885
- * @param condition - Function that determines if validation should run
886
- * @param validator - The validator to run conditionally
887
- * @returns A FieldValidator function
888
- *
889
- * @example
890
- * ```typescript
891
- * const conditionalValidator = validateWhen(
892
- * (value, context) => context.allFormData?.userType === 'premium',
893
- * required('Premium users must provide this field')
894
- * );
895
- * ```
766
+ * Utility to combine multiple Standard Schema validators
767
+ * This creates a new Standard Schema that runs all validations
896
768
  */
897
- declare function validateWhen<T>(condition: (value: T, context: ValidationContext) => boolean, validator: FieldValidator<T>): FieldValidator<T>;
769
+ declare function combine<T>(...schemas: StandardSchemaV1<T>[]): StandardSchemaV1<T>;
770
+
898
771
  /**
899
- * Creates an async custom validator from a validation function
900
- *
901
- * @param validateFn - Async custom validation function that returns a Promise<boolean>
902
- * @param message - Error message for failed validation
903
- * @param code - Optional error code
904
- * @returns A FieldValidator function that returns a Promise
905
- *
906
- * @example
907
- * ```typescript
908
- * const checkEmailUnique = customAsync(
909
- * async (email) => {
910
- * const response = await fetch(`/api/check-email?email=${email}`);
911
- * const data = await response.json();
912
- * return data.isUnique;
913
- * },
914
- * 'Email address is already taken',
915
- * 'EMAIL_NOT_UNIQUE'
916
- * );
917
- * ```
772
+ * Unified validation utilities for Standard Schema only
773
+ * These replace the old validator-based system with a clean Standard Schema approach
774
+ */
775
+
776
+ /**
777
+ * Checks if a value implements the Standard Schema interface
778
+ */
779
+ declare function isStandardSchema(value: any): value is StandardSchema;
780
+ /**
781
+ * Validates a value using a Standard Schema
782
+ */
783
+ declare function validateWithStandardSchema<T extends StandardSchema>(schema: T, value: unknown): Promise<ValidationResult>;
784
+ /**
785
+ * Utility to extract input type from Standard Schema at runtime (for debugging)
786
+ */
787
+ declare function getSchemaInfo(schema: StandardSchema): {
788
+ vendor: string;
789
+ version: number;
790
+ hasTypes: boolean;
791
+ };
792
+ /**
793
+ * Type guard to check if a schema has type information
794
+ */
795
+ declare function hasSchemaTypes<T extends StandardSchema>(schema: T): schema is T & {
796
+ '~standard': {
797
+ types: NonNullable<T['~standard']['types']>;
798
+ };
799
+ };
800
+ /**
801
+ * Validates a value using unified validation config
802
+ * Handles single schemas, arrays of schemas, and combines results
803
+ */
804
+ declare function validateWithUnifiedConfig<T>(config: FieldValidationConfig<T>, value: T, _context: ValidationContext): Promise<ValidationResult>;
805
+ /**
806
+ * Validates form data using unified validation config
807
+ */
808
+ declare function validateFormWithUnifiedConfig<T extends Record<string, any>>(config: FormValidationConfig<T>, formData: T, _context: ValidationContext): Promise<ValidationResult>;
809
+ /**
810
+ * Checks if a field validation config has any validation rules
811
+ */
812
+ declare function hasUnifiedValidation(config: FieldValidationConfig | FormValidationConfig): boolean;
813
+ /**
814
+ * Combines multiple Standard Schemas into a single schema
815
+ * This is useful for combining built-in validators with external schemas
816
+ */
817
+ declare function combineSchemas<T>(...schemas: StandardSchemaV1<T>[]): StandardSchemaV1<T>;
818
+ /**
819
+ * Utility to create a Standard Schema from any validation function
820
+ * This helps migrate existing validators to Standard Schema
821
+ */
822
+ declare function createStandardValidator<T>(validateFn: (value: T, context?: ValidationContext) => ValidationResult | Promise<ValidationResult>, vendor?: string): StandardSchemaV1<T>;
823
+ /**
824
+ * Type guard to check if value is a Standard Schema or array of Standard Schemas
825
+ */
826
+ declare function isValidationRule(value: any): value is StandardSchema | StandardSchema[];
827
+ /**
828
+ * Normalizes validation config to always return an array of Standard Schemas
918
829
  */
919
- declare function async<T>(validateFn: (value: T, context: ValidationContext) => Promise<boolean>, message: string, code?: string): FieldValidator<T>;
830
+ declare function normalizeValidationRules<T>(validate: StandardSchema<T> | StandardSchema<T>[] | undefined): StandardSchema<T>[];
920
831
 
921
832
  /**
922
833
  * Core monitoring system for Rilay
@@ -1043,4 +954,4 @@ declare class DevelopmentAdapter implements MonitoringAdapter {
1043
954
  private logErrorSummary;
1044
955
  }
1045
956
 
1046
- export { type ComponentConfig, type ComponentPerformanceMetrics, type ComponentRenderProps, type ComponentRenderer, type ComponentRendererBaseProps, ComponentRendererWrapper, type ComponentRendererWrapperProps, type ConditionBuilder as Condition, type ConditionBuilder, type ConditionConfig, type ConditionEvaluator, type ConditionOperator, type ConditionValue, type ConditionalBehavior, ConsoleAdapter, type ConsoleMonitoringAdapter, type CustomStepRenderer, DevelopmentAdapter, type EnhancedFormAnalytics, type EnhancedWorkflowAnalytics, type ErrorMonitoringEvent, type FieldRenderer, type FieldRendererProps, type FieldValidationConfig, type FieldValidator, type FormBodyRenderer, type FormBodyRendererProps, type FormComponentRendererProps, type FormConfiguration, type FormFieldConfig, type FormFieldRow, type FormPerformanceMetrics, type FormRenderConfig, type FormRowRenderer, type FormRowRendererProps, type FormSubmitButtonRenderer, type FormSubmitButtonRendererProps, type FormValidationConfig, type FormValidator, IdGenerator, LocalStorageAdapter, type LogicalOperator, type MonitoringAdapter, type MonitoringConfig, type MonitoringContext, type MonitoringEvent, type MonitoringEventType, type PerformanceMetrics, type PerformanceProfiler, type PerformanceThresholds, type PerformanceWarningEvent, RemoteAdapter, type RemoteMonitoringAdapter, type RendererChildrenFunction, type RilayInstance, type RilayLicenseConfig, RilayMonitor, type StepConditionalBehavior, type StepConfig, type StepDataHelper, type ValidationAdapter, type ValidationContext, type ValidationError, type ValidationResult, type ValidationSchema, type WorkflowAnalytics, type WorkflowComponentRendererBaseProps, type WorkflowConfig, type WorkflowContext, type WorkflowNextButtonRenderer, type WorkflowNextButtonRendererProps, type WorkflowPerformanceMetrics, type WorkflowPlugin, type WorkflowPreviousButtonRenderer, type WorkflowPreviousButtonRendererProps, type WorkflowRenderConfig, type WorkflowSkipButtonRenderer, type WorkflowSkipButtonRendererProps, type WorkflowStepperRenderer, type WorkflowStepperRendererProps, async, combineValidationResults, configureObject, createValidationContext, createValidationResult, custom, deepClone, destroyGlobalMonitoring, email, ensureUnique, evaluateCondition, getGlobalMonitor, initializeMonitoring, matchField, max, maxLength, mergeInto, min, minLength, normalizeToArray, number, pattern, required, resolveRendererChildren, ril, runValidators, runValidatorsAsync, url, validateRequired, validateWhen, when };
957
+ export { type ComponentConfig, type ComponentPerformanceMetrics, type ComponentRenderProps, type ComponentRenderer, type ComponentRendererBaseProps, ComponentRendererWrapper, type ComponentRendererWrapperProps, type ConditionBuilder as Condition, type ConditionBuilder, type ConditionConfig, type ConditionEvaluator, type ConditionOperator, type ConditionValue, type ConditionalBehavior, ConsoleAdapter, type ConsoleMonitoringAdapter, type CustomStepRenderer, DevelopmentAdapter, type EnhancedFormAnalytics, type EnhancedWorkflowAnalytics, type ErrorMonitoringEvent, type FieldRenderer, type FieldRendererProps, type FieldValidationConfig, type FieldValidator, type FormBodyRenderer, type FormBodyRendererProps, type FormComponentRendererProps, type FormConfiguration, type FormFieldConfig, type FormFieldRow, type FormPerformanceMetrics, type FormRenderConfig, type FormRowRenderer, type FormRowRendererProps, type FormSubmitButtonRenderer, type FormSubmitButtonRendererProps, type FormValidationConfig, type FormValidator, IdGenerator, type InferInput, type InferOutput, LocalStorageAdapter, type LogicalOperator, type MonitoringAdapter, type MonitoringConfig, type MonitoringContext, type MonitoringEvent, type MonitoringEventType, type PerformanceMetrics, type PerformanceProfiler, type PerformanceThresholds, type PerformanceWarningEvent, RemoteAdapter, type RemoteMonitoringAdapter, type RendererChildrenFunction, type RilayInstance, type RilayLicenseConfig, RilayMonitor, type StandardSchema, type StepConditionalBehavior, type StepConfig, type StepDataHelper, type ValidationContext, type ValidationError, type ValidationResult, type WorkflowAnalytics, type WorkflowComponentRendererBaseProps, type WorkflowConfig, type WorkflowContext, type WorkflowNextButtonRenderer, type WorkflowNextButtonRendererProps, type WorkflowPerformanceMetrics, type WorkflowPlugin, type WorkflowPreviousButtonRenderer, type WorkflowPreviousButtonRendererProps, type WorkflowRenderConfig, type WorkflowSkipButtonRenderer, type WorkflowSkipButtonRendererProps, type WorkflowStepperRenderer, type WorkflowStepperRendererProps, async, combine, combineSchemas, configureObject, createErrorResult, createStandardValidator, createSuccessResult, createValidationContext, createValidationResult, custom, deepClone, destroyGlobalMonitoring, email, ensureUnique, evaluateCondition, getGlobalMonitor, getSchemaInfo, hasSchemaTypes, hasUnifiedValidation, initializeMonitoring, isStandardSchema, isValidationRule, max, maxLength, mergeInto, min, minLength, normalizeToArray, normalizeValidationRules, number, pattern, required, resolveRendererChildren, ril, url, validateFormWithUnifiedConfig, validateRequired, validateWithStandardSchema, validateWithUnifiedConfig, when };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { StandardSchemaV1 } from '@standard-schema/spec';
1
2
  import * as React$1 from 'react';
2
3
  import React__default from 'react';
3
4
 
@@ -213,6 +214,7 @@ interface ValidationError {
213
214
  interface ValidationResult {
214
215
  readonly isValid: boolean;
215
216
  readonly errors: ValidationError[];
217
+ readonly value?: any;
216
218
  }
217
219
  interface ValidationContext {
218
220
  readonly fieldId?: string;
@@ -223,32 +225,46 @@ interface ValidationContext {
223
225
  readonly stepData?: Record<string, any>;
224
226
  readonly workflowData?: Record<string, any>;
225
227
  }
228
+ /** @internal - Use Standard Schema instead */
226
229
  type FieldValidator<T = any> = (value: T, context: ValidationContext) => ValidationResult | Promise<ValidationResult>;
230
+ /** @internal - Use Standard Schema instead */
227
231
  type FormValidator<T = Record<string, any>> = (formData: T, context: ValidationContext) => ValidationResult | Promise<ValidationResult>;
228
- type ValidationSchema<T = any> = {
229
- parse: (value: T) => T;
230
- safeParse: (value: T) => {
231
- success: boolean;
232
- data?: T;
233
- error?: any;
234
- };
235
- };
236
- interface ValidationAdapter<TSchema = any> {
237
- readonly name: string;
238
- readonly version?: string;
239
- createFieldValidator<T>(schema: TSchema): FieldValidator<T>;
240
- createFormValidator<T>(schema: TSchema): FormValidator<T>;
241
- }
242
- interface FieldValidationConfig {
243
- readonly validators?: FieldValidator[];
244
- readonly schema?: ValidationSchema;
232
+ type StandardSchema<Input = unknown, Output = Input> = StandardSchemaV1<Input, Output>;
233
+ type InferInput<T> = T extends StandardSchema<infer I, any> ? I : unknown;
234
+ type InferOutput<T> = T extends StandardSchema<any, infer O> ? O : unknown;
235
+ interface FieldValidationConfig<T = any> {
236
+ /**
237
+ * Validation rules using Standard Schema interface
238
+ * Accepts: single schema, array of schemas, or any Standard Schema compatible validation
239
+ *
240
+ * @example Single schema
241
+ * validate: z.string().email()
242
+ *
243
+ * @example Built-in validators
244
+ * validate: required()
245
+ *
246
+ * @example Multiple validations
247
+ * validate: [required(), email()]
248
+ *
249
+ * @example Mixed schemas + validators
250
+ * validate: [z.string(), required(), customValidator()]
251
+ */
252
+ readonly validate?: StandardSchema<T> | StandardSchema<T>[];
245
253
  readonly validateOnChange?: boolean;
246
254
  readonly validateOnBlur?: boolean;
247
255
  readonly debounceMs?: number;
248
256
  }
249
- interface FormValidationConfig {
250
- readonly validators?: FormValidator[];
251
- readonly schema?: ValidationSchema;
257
+ interface FormValidationConfig<T extends Record<string, any> = Record<string, any>> {
258
+ /**
259
+ * Form-level validation using Standard Schema interface
260
+ *
261
+ * @example Object schema
262
+ * validate: z.object({ email: z.string().email(), name: z.string() })
263
+ *
264
+ * @example Custom form validator
265
+ * validate: customFormValidator()
266
+ */
267
+ readonly validate?: StandardSchema<T> | StandardSchema<T>[];
252
268
  readonly validateOnSubmit?: boolean;
253
269
  readonly validateOnStepChange?: boolean;
254
270
  }
@@ -634,10 +650,10 @@ declare function configureObject<T>(target: T, updates: Partial<T>, allowedKeys?
634
650
  declare function resolveRendererChildren<TProps>(children: React.ReactNode | RendererChildrenFunction<TProps> | undefined, props: TProps): React.ReactNode;
635
651
 
636
652
  /**
637
- * @fileoverview Validation utilities
653
+ * @fileoverview Clean validation utilities for Standard Schema
638
654
  *
639
- * This module provides utility functions for working with validation results,
640
- * combining validators, and managing validation contexts.
655
+ * This module provides utility functions for working with validation results
656
+ * and managing validation contexts using Standard Schema exclusively.
641
657
  */
642
658
 
643
659
  /**
@@ -656,60 +672,30 @@ declare function resolveRendererChildren<TProps>(children: React.ReactNode | Ren
656
672
  */
657
673
  declare function createValidationResult(isValid: boolean, errors?: ValidationError[]): ValidationResult;
658
674
  /**
659
- * Combines multiple validation results into a single result
675
+ * Creates a successful validation result
660
676
  *
661
- * The combined result is valid only if all input results are valid.
662
- * All errors from all results are included in the combined result.
663
- *
664
- * @param results - Array of ValidationResult objects to combine
665
- * @returns A single ValidationResult combining all inputs
677
+ * @returns A successful ValidationResult with no errors
666
678
  *
667
679
  * @example
668
680
  * ```typescript
669
- * const combined = combineValidationResults([
670
- * emailValidator(value),
671
- * requiredValidator(value),
672
- * minLengthValidator(value)
673
- * ]);
681
+ * const success = createSuccessResult();
674
682
  * ```
675
683
  */
676
- declare function combineValidationResults(results: ValidationResult[]): ValidationResult;
684
+ declare function createSuccessResult(): ValidationResult;
677
685
  /**
678
- * Runs multiple synchronous validators and combines their results
686
+ * Creates a failed validation result with a single error
679
687
  *
680
- * @param validators - Array of validators to run
681
- * @param value - The value to validate
682
- * @param context - Validation context
683
- * @returns Combined validation result
684
- *
685
- * @example
686
- * ```typescript
687
- * const result = runValidators([
688
- * required,
689
- * email,
690
- * minLength(5)
691
- * ], emailValue, context);
692
- * ```
693
- */
694
- declare function runValidators<T>(validators: FieldValidator<T>[], value: T, context: ValidationContext): ValidationResult;
695
- /**
696
- * Runs multiple asynchronous validators and combines their results
697
- *
698
- * @param validators - Array of validators to run (can be sync or async)
699
- * @param value - The value to validate
700
- * @param context - Validation context
701
- * @returns Promise resolving to combined validation result
688
+ * @param message - The error message
689
+ * @param code - Optional error code
690
+ * @param path - Optional field path
691
+ * @returns A failed ValidationResult
702
692
  *
703
693
  * @example
704
694
  * ```typescript
705
- * const result = await runValidatorsAsync([
706
- * required,
707
- * email,
708
- * checkEmailUnique // async validator
709
- * ], emailValue, context);
695
+ * const error = createErrorResult('Email is invalid', 'INVALID_EMAIL');
710
696
  * ```
711
697
  */
712
- declare function runValidatorsAsync<T>(validators: FieldValidator<T>[], value: T, context: ValidationContext): Promise<ValidationResult>;
698
+ declare function createErrorResult(message: string, code?: string, path?: string): ValidationResult;
713
699
  /**
714
700
  * Creates a validation context object
715
701
  *
@@ -728,195 +714,120 @@ declare function runValidatorsAsync<T>(validators: FieldValidator<T>[], value: T
728
714
  declare function createValidationContext(options?: Partial<ValidationContext>): ValidationContext;
729
715
 
730
716
  /**
731
- * @fileoverview Built-in validators
732
- *
733
- * This module provides a comprehensive set of built-in validators for common
734
- * validation scenarios. These validators follow the FieldValidator interface
735
- * and can be used standalone or combined with other validators.
717
+ * Built-in validators implementing Standard Schema interface
718
+ * All RilayKit validators now implement Standard Schema for consistency
736
719
  */
737
720
 
738
721
  /**
739
- * Validates that a value is not empty, null, or undefined
740
- *
741
- * @param message - Custom error message (optional)
742
- * @returns A FieldValidator function
743
- *
744
- * @example
745
- * ```typescript
746
- * const nameValidator = required('Name is required');
747
- * ```
722
+ * Required field validator - Standard Schema implementation
748
723
  */
749
- declare function required(message?: string): FieldValidator;
724
+ declare function required(message?: string): StandardSchemaV1<any>;
750
725
  /**
751
- * Validates minimum string length
752
- *
753
- * @param min - Minimum length required
754
- * @param message - Custom error message (optional)
755
- * @returns A FieldValidator function
756
- *
757
- * @example
758
- * ```typescript
759
- * const passwordValidator = minLength(8, 'Password must be at least 8 characters');
760
- * ```
726
+ * Email validation - Standard Schema implementation
761
727
  */
762
- declare function minLength(min: number, message?: string): FieldValidator<string>;
728
+ declare function email(message?: string): StandardSchemaV1<string>;
763
729
  /**
764
- * Validates maximum string length
765
- *
766
- * @param max - Maximum length allowed
767
- * @param message - Custom error message (optional)
768
- * @returns A FieldValidator function
769
- *
770
- * @example
771
- * ```typescript
772
- * const bioValidator = maxLength(500, 'Bio must be under 500 characters');
773
- * ```
730
+ * URL validation - Standard Schema implementation
774
731
  */
775
- declare function maxLength(max: number, message?: string): FieldValidator<string>;
732
+ declare function url(message?: string): StandardSchemaV1<string>;
776
733
  /**
777
- * Validates that a string matches a regular expression pattern
778
- *
779
- * @param regex - The regular expression pattern
780
- * @param message - Custom error message (optional)
781
- * @returns A FieldValidator function
782
- *
783
- * @example
784
- * ```typescript
785
- * const phoneValidator = pattern(/^\d{3}-\d{3}-\d{4}$/, 'Invalid phone format');
786
- * ```
734
+ * Minimum length validation - Standard Schema implementation
787
735
  */
788
- declare function pattern(regex: RegExp, message?: string): FieldValidator<string>;
736
+ declare function minLength(min: number, message?: string): StandardSchemaV1<string>;
789
737
  /**
790
- * Email validation using a comprehensive regex pattern
791
- *
792
- * @param message - Custom error message (optional)
793
- * @returns A FieldValidator function
794
- *
795
- * @example
796
- * ```typescript
797
- * const emailValidator = email('Please enter a valid email address');
798
- * ```
738
+ * Maximum length validation - Standard Schema implementation
799
739
  */
800
- declare function email(message?: string): FieldValidator<string>;
740
+ declare function maxLength(max: number, message?: string): StandardSchemaV1<string>;
801
741
  /**
802
- * URL validation using a comprehensive regex pattern
803
- *
804
- * @param message - Custom error message (optional)
805
- * @returns A FieldValidator function
806
- *
807
- * @example
808
- * ```typescript
809
- * const websiteValidator = url('Please enter a valid URL');
810
- * ```
742
+ * Pattern validation - Standard Schema implementation
811
743
  */
812
- declare function url(message?: string): FieldValidator<string>;
744
+ declare function pattern(regex: RegExp, message?: string): StandardSchemaV1<string>;
813
745
  /**
814
- * Validates that a value is a valid number
815
- *
816
- * @param message - Custom error message (optional)
817
- * @returns A FieldValidator function
818
- *
819
- * @example
820
- * ```typescript
821
- * const ageValidator = number('Age must be a valid number');
822
- * ```
746
+ * Number validation - Standard Schema implementation
823
747
  */
824
- declare function number(message?: string): FieldValidator<string | number>;
748
+ declare function number(message?: string): StandardSchemaV1<number>;
825
749
  /**
826
- * Validates minimum numeric value
827
- *
828
- * @param minValue - Minimum value allowed
829
- * @param message - Custom error message (optional)
830
- * @returns A FieldValidator function
831
- *
832
- * @example
833
- * ```typescript
834
- * const ageValidator = min(18, 'Must be at least 18 years old');
835
- * ```
750
+ * Minimum value validation - Standard Schema implementation
836
751
  */
837
- declare function min(minValue: number, message?: string): FieldValidator<string | number>;
752
+ declare function min(minValue: number, message?: string): StandardSchemaV1<number>;
838
753
  /**
839
- * Validates maximum numeric value
840
- *
841
- * @param maxValue - Maximum value allowed
842
- * @param message - Custom error message (optional)
843
- * @returns A FieldValidator function
844
- *
845
- * @example
846
- * ```typescript
847
- * const scoreValidator = max(100, 'Score cannot exceed 100');
848
- * ```
754
+ * Maximum value validation - Standard Schema implementation
849
755
  */
850
- declare function max(maxValue: number, message?: string): FieldValidator<string | number>;
756
+ declare function max(maxValue: number, message?: string): StandardSchemaV1<number>;
851
757
  /**
852
- * Creates a custom validator from a validation function
853
- *
854
- * @param validateFn - Custom validation function
855
- * @param message - Error message for failed validation
856
- * @param code - Optional error code
857
- * @returns A FieldValidator function
858
- *
859
- * @example
860
- * ```typescript
861
- * const evenNumberValidator = custom(
862
- * (value) => Number(value) % 2 === 0,
863
- * 'Number must be even',
864
- * 'NOT_EVEN'
865
- * );
866
- * ```
758
+ * Custom validator - Standard Schema implementation
867
759
  */
868
- declare function custom<T>(validateFn: (value: T, context: ValidationContext) => boolean, message: string, code?: string): FieldValidator<T>;
760
+ declare function custom<T>(fn: (value: T) => boolean, message?: string): StandardSchemaV1<T>;
869
761
  /**
870
- * Creates a validator that checks if a value matches another field's value
871
- *
872
- * @param targetFieldId - ID of the field to match against
873
- * @param message - Custom error message (optional)
874
- * @returns A FieldValidator function
875
- *
876
- * @example
877
- * ```typescript
878
- * const confirmPasswordValidator = matchField('password', 'Passwords must match');
879
- * ```
762
+ * Async validator - Standard Schema implementation
880
763
  */
881
- declare function matchField(targetFieldId: string, message?: string): FieldValidator;
764
+ declare function async<T>(fn: (value: T) => Promise<boolean>, message?: string): StandardSchemaV1<T>;
882
765
  /**
883
- * Creates a validator that only validates when a condition is met
884
- *
885
- * @param condition - Function that determines if validation should run
886
- * @param validator - The validator to run conditionally
887
- * @returns A FieldValidator function
888
- *
889
- * @example
890
- * ```typescript
891
- * const conditionalValidator = validateWhen(
892
- * (value, context) => context.allFormData?.userType === 'premium',
893
- * required('Premium users must provide this field')
894
- * );
895
- * ```
766
+ * Utility to combine multiple Standard Schema validators
767
+ * This creates a new Standard Schema that runs all validations
896
768
  */
897
- declare function validateWhen<T>(condition: (value: T, context: ValidationContext) => boolean, validator: FieldValidator<T>): FieldValidator<T>;
769
+ declare function combine<T>(...schemas: StandardSchemaV1<T>[]): StandardSchemaV1<T>;
770
+
898
771
  /**
899
- * Creates an async custom validator from a validation function
900
- *
901
- * @param validateFn - Async custom validation function that returns a Promise<boolean>
902
- * @param message - Error message for failed validation
903
- * @param code - Optional error code
904
- * @returns A FieldValidator function that returns a Promise
905
- *
906
- * @example
907
- * ```typescript
908
- * const checkEmailUnique = customAsync(
909
- * async (email) => {
910
- * const response = await fetch(`/api/check-email?email=${email}`);
911
- * const data = await response.json();
912
- * return data.isUnique;
913
- * },
914
- * 'Email address is already taken',
915
- * 'EMAIL_NOT_UNIQUE'
916
- * );
917
- * ```
772
+ * Unified validation utilities for Standard Schema only
773
+ * These replace the old validator-based system with a clean Standard Schema approach
774
+ */
775
+
776
+ /**
777
+ * Checks if a value implements the Standard Schema interface
778
+ */
779
+ declare function isStandardSchema(value: any): value is StandardSchema;
780
+ /**
781
+ * Validates a value using a Standard Schema
782
+ */
783
+ declare function validateWithStandardSchema<T extends StandardSchema>(schema: T, value: unknown): Promise<ValidationResult>;
784
+ /**
785
+ * Utility to extract input type from Standard Schema at runtime (for debugging)
786
+ */
787
+ declare function getSchemaInfo(schema: StandardSchema): {
788
+ vendor: string;
789
+ version: number;
790
+ hasTypes: boolean;
791
+ };
792
+ /**
793
+ * Type guard to check if a schema has type information
794
+ */
795
+ declare function hasSchemaTypes<T extends StandardSchema>(schema: T): schema is T & {
796
+ '~standard': {
797
+ types: NonNullable<T['~standard']['types']>;
798
+ };
799
+ };
800
+ /**
801
+ * Validates a value using unified validation config
802
+ * Handles single schemas, arrays of schemas, and combines results
803
+ */
804
+ declare function validateWithUnifiedConfig<T>(config: FieldValidationConfig<T>, value: T, _context: ValidationContext): Promise<ValidationResult>;
805
+ /**
806
+ * Validates form data using unified validation config
807
+ */
808
+ declare function validateFormWithUnifiedConfig<T extends Record<string, any>>(config: FormValidationConfig<T>, formData: T, _context: ValidationContext): Promise<ValidationResult>;
809
+ /**
810
+ * Checks if a field validation config has any validation rules
811
+ */
812
+ declare function hasUnifiedValidation(config: FieldValidationConfig | FormValidationConfig): boolean;
813
+ /**
814
+ * Combines multiple Standard Schemas into a single schema
815
+ * This is useful for combining built-in validators with external schemas
816
+ */
817
+ declare function combineSchemas<T>(...schemas: StandardSchemaV1<T>[]): StandardSchemaV1<T>;
818
+ /**
819
+ * Utility to create a Standard Schema from any validation function
820
+ * This helps migrate existing validators to Standard Schema
821
+ */
822
+ declare function createStandardValidator<T>(validateFn: (value: T, context?: ValidationContext) => ValidationResult | Promise<ValidationResult>, vendor?: string): StandardSchemaV1<T>;
823
+ /**
824
+ * Type guard to check if value is a Standard Schema or array of Standard Schemas
825
+ */
826
+ declare function isValidationRule(value: any): value is StandardSchema | StandardSchema[];
827
+ /**
828
+ * Normalizes validation config to always return an array of Standard Schemas
918
829
  */
919
- declare function async<T>(validateFn: (value: T, context: ValidationContext) => Promise<boolean>, message: string, code?: string): FieldValidator<T>;
830
+ declare function normalizeValidationRules<T>(validate: StandardSchema<T> | StandardSchema<T>[] | undefined): StandardSchema<T>[];
920
831
 
921
832
  /**
922
833
  * Core monitoring system for Rilay
@@ -1043,4 +954,4 @@ declare class DevelopmentAdapter implements MonitoringAdapter {
1043
954
  private logErrorSummary;
1044
955
  }
1045
956
 
1046
- export { type ComponentConfig, type ComponentPerformanceMetrics, type ComponentRenderProps, type ComponentRenderer, type ComponentRendererBaseProps, ComponentRendererWrapper, type ComponentRendererWrapperProps, type ConditionBuilder as Condition, type ConditionBuilder, type ConditionConfig, type ConditionEvaluator, type ConditionOperator, type ConditionValue, type ConditionalBehavior, ConsoleAdapter, type ConsoleMonitoringAdapter, type CustomStepRenderer, DevelopmentAdapter, type EnhancedFormAnalytics, type EnhancedWorkflowAnalytics, type ErrorMonitoringEvent, type FieldRenderer, type FieldRendererProps, type FieldValidationConfig, type FieldValidator, type FormBodyRenderer, type FormBodyRendererProps, type FormComponentRendererProps, type FormConfiguration, type FormFieldConfig, type FormFieldRow, type FormPerformanceMetrics, type FormRenderConfig, type FormRowRenderer, type FormRowRendererProps, type FormSubmitButtonRenderer, type FormSubmitButtonRendererProps, type FormValidationConfig, type FormValidator, IdGenerator, LocalStorageAdapter, type LogicalOperator, type MonitoringAdapter, type MonitoringConfig, type MonitoringContext, type MonitoringEvent, type MonitoringEventType, type PerformanceMetrics, type PerformanceProfiler, type PerformanceThresholds, type PerformanceWarningEvent, RemoteAdapter, type RemoteMonitoringAdapter, type RendererChildrenFunction, type RilayInstance, type RilayLicenseConfig, RilayMonitor, type StepConditionalBehavior, type StepConfig, type StepDataHelper, type ValidationAdapter, type ValidationContext, type ValidationError, type ValidationResult, type ValidationSchema, type WorkflowAnalytics, type WorkflowComponentRendererBaseProps, type WorkflowConfig, type WorkflowContext, type WorkflowNextButtonRenderer, type WorkflowNextButtonRendererProps, type WorkflowPerformanceMetrics, type WorkflowPlugin, type WorkflowPreviousButtonRenderer, type WorkflowPreviousButtonRendererProps, type WorkflowRenderConfig, type WorkflowSkipButtonRenderer, type WorkflowSkipButtonRendererProps, type WorkflowStepperRenderer, type WorkflowStepperRendererProps, async, combineValidationResults, configureObject, createValidationContext, createValidationResult, custom, deepClone, destroyGlobalMonitoring, email, ensureUnique, evaluateCondition, getGlobalMonitor, initializeMonitoring, matchField, max, maxLength, mergeInto, min, minLength, normalizeToArray, number, pattern, required, resolveRendererChildren, ril, runValidators, runValidatorsAsync, url, validateRequired, validateWhen, when };
957
+ export { type ComponentConfig, type ComponentPerformanceMetrics, type ComponentRenderProps, type ComponentRenderer, type ComponentRendererBaseProps, ComponentRendererWrapper, type ComponentRendererWrapperProps, type ConditionBuilder as Condition, type ConditionBuilder, type ConditionConfig, type ConditionEvaluator, type ConditionOperator, type ConditionValue, type ConditionalBehavior, ConsoleAdapter, type ConsoleMonitoringAdapter, type CustomStepRenderer, DevelopmentAdapter, type EnhancedFormAnalytics, type EnhancedWorkflowAnalytics, type ErrorMonitoringEvent, type FieldRenderer, type FieldRendererProps, type FieldValidationConfig, type FieldValidator, type FormBodyRenderer, type FormBodyRendererProps, type FormComponentRendererProps, type FormConfiguration, type FormFieldConfig, type FormFieldRow, type FormPerformanceMetrics, type FormRenderConfig, type FormRowRenderer, type FormRowRendererProps, type FormSubmitButtonRenderer, type FormSubmitButtonRendererProps, type FormValidationConfig, type FormValidator, IdGenerator, type InferInput, type InferOutput, LocalStorageAdapter, type LogicalOperator, type MonitoringAdapter, type MonitoringConfig, type MonitoringContext, type MonitoringEvent, type MonitoringEventType, type PerformanceMetrics, type PerformanceProfiler, type PerformanceThresholds, type PerformanceWarningEvent, RemoteAdapter, type RemoteMonitoringAdapter, type RendererChildrenFunction, type RilayInstance, type RilayLicenseConfig, RilayMonitor, type StandardSchema, type StepConditionalBehavior, type StepConfig, type StepDataHelper, type ValidationContext, type ValidationError, type ValidationResult, type WorkflowAnalytics, type WorkflowComponentRendererBaseProps, type WorkflowConfig, type WorkflowContext, type WorkflowNextButtonRenderer, type WorkflowNextButtonRendererProps, type WorkflowPerformanceMetrics, type WorkflowPlugin, type WorkflowPreviousButtonRenderer, type WorkflowPreviousButtonRendererProps, type WorkflowRenderConfig, type WorkflowSkipButtonRenderer, type WorkflowSkipButtonRendererProps, type WorkflowStepperRenderer, type WorkflowStepperRendererProps, async, combine, combineSchemas, configureObject, createErrorResult, createStandardValidator, createSuccessResult, createValidationContext, createValidationResult, custom, deepClone, destroyGlobalMonitoring, email, ensureUnique, evaluateCondition, getGlobalMonitor, getSchemaInfo, hasSchemaTypes, hasUnifiedValidation, initializeMonitoring, isStandardSchema, isValidationRule, max, maxLength, mergeInto, min, minLength, normalizeToArray, normalizeValidationRules, number, pattern, required, resolveRendererChildren, ril, url, validateFormWithUnifiedConfig, validateRequired, validateWithStandardSchema, validateWithUnifiedConfig, when };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- 'use strict';function E(t,e){return typeof t=="function"?t(e):t}function re({children:t,renderAs:e,renderer:r,name:n,props:o}){if(e==="children"||e===true){if(typeof t!="function")throw new Error(`When renderAs="children" is used, children must be a function that returns React elements for ${n}`);return t(o)}if(!r)throw new Error(`No renderer provided for ${n}`);if(typeof r!="function")throw new Error(`Renderer must be a function for ${n}`);let s={...o,children:E(t,o)};return r(s)}function ne(t,e){return {...t,...e}}function P(t,e){let r=t.filter((n,o)=>t.indexOf(n)!==o);if(r.length>0)throw new Error(`Duplicate ${e} IDs: ${r.join(", ")}`)}function oe(t,e,r){if(t.filter(o=>e.some(i=>!o[i])).length>0)throw new Error(`Missing required fields in ${r}: ${e.join(", ")}`)}var V=class{constructor(){this.counters=new Map;}next(e){let r=this.counters.get(e)||0;return this.counters.set(e,r+1),`${e}-${r+1}`}reset(e){e?this.counters.delete(e):this.counters.clear();}};function ie(t){return Array.isArray(t)?t:[t]}function k(t){if(t===null||typeof t!="object")return t;if(t instanceof Date)return new Date(t.getTime());if(Array.isArray(t))return t.map(r=>k(r));let e={};for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=k(t[r]));return e}function se(t,e,r){let n={...t};for(let o in e)r&&!r.includes(o)||e[o]!==void 0&&(n[o]=e[o]);return n}var C=class extends Error{constructor(r,n,o){super(r);this.code=n;this.meta=o;this.name="RilayError";}},p=class extends C{constructor(e,r){super(e,"VALIDATION_ERROR",r),this.name="ValidationError";}};function m(t,e){let r={...t};for(let n in e){let o=e[n],i=r[n];o&&typeof o=="object"&&!Array.isArray(o)&&i&&typeof i=="object"&&!Array.isArray(i)?r[n]=m(i,o):r[n]=o;}return r}var v=class t{constructor(){this.components=new Map;this.formRenderConfig={};this.workflowRenderConfig={};}static create(){return new t}addComponent(e,r){let n={id:e,type:e,...r},o=new t;return o.components=new Map(this.components),o.formRenderConfig={...this.formRenderConfig},o.workflowRenderConfig={...this.workflowRenderConfig},o.components.set(e,n),o}configure(e){let r=["rowRenderer","bodyRenderer","submitButtonRenderer","fieldRenderer"],n=["stepperRenderer","nextButtonRenderer","previousButtonRenderer","skipButtonRenderer"],o={},i={};for(let[a,f]of Object.entries(e))r.includes(a)?o[a]=f:n.includes(a)&&(i[a]=f);let s=new t;return s.components=new Map(this.components),s.formRenderConfig=m(this.formRenderConfig,o),s.workflowRenderConfig=m(this.workflowRenderConfig,i),s}getFormRenderConfig(){return {...this.formRenderConfig}}getWorkflowRenderConfig(){return {...this.workflowRenderConfig}}getComponent(e){return this.components.get(e)}getAllComponents(){return Array.from(this.components.values())}hasComponent(e){return this.components.has(e)}removeComponent(e){let r=new t;return r.components=new Map(this.components),r.formRenderConfig={...this.formRenderConfig},r.workflowRenderConfig={...this.workflowRenderConfig},r.components.delete(e),r}clear(){let e=new t;return e.formRenderConfig={...this.formRenderConfig},e.workflowRenderConfig={...this.workflowRenderConfig},e}clone(){let e=new t;return e.components=new Map(this.components),e.formRenderConfig=m({},this.formRenderConfig),e.workflowRenderConfig=m({},this.workflowRenderConfig),e}getStats(){let e=Array.from(this.components.values());return {total:e.length,byType:e.reduce((r,n)=>(r[n.type]=(r[n.type]||0)+1,r),{}),hasCustomRenderers:{row:!!this.formRenderConfig.rowRenderer,body:!!this.formRenderConfig.bodyRenderer,submitButton:!!this.formRenderConfig.submitButtonRenderer,field:!!this.formRenderConfig.fieldRenderer,stepper:!!this.workflowRenderConfig.stepperRenderer,workflowNextButton:!!this.workflowRenderConfig.nextButtonRenderer,workflowPreviousButton:!!this.workflowRenderConfig.previousButtonRenderer,workflowSkipButton:!!this.workflowRenderConfig.skipButtonRenderer}}}validate(){let e=[],r=Array.from(this.components.values()),n=r.map(c=>c.id);try{P(n,"component");}catch(c){e.push(c instanceof Error?c.message:String(c));}let o=r.filter(c=>!c.renderer);o.length>0&&e.push(`Components without renderer: ${o.map(c=>c.id).join(", ")}`);let i=Object.keys(this.formRenderConfig),s=Object.keys(this.workflowRenderConfig),a=["rowRenderer","bodyRenderer","submitButtonRenderer","fieldRenderer"],f=["stepperRenderer","nextButtonRenderer","previousButtonRenderer","skipButtonRenderer"],l=i.filter(c=>!a.includes(c)),h=s.filter(c=>!f.includes(c));return l.length>0&&e.push(`Invalid form renderer keys: ${l.join(", ")}`),h.length>0&&e.push(`Invalid workflow renderer keys: ${h.join(", ")}`),e}async validateAsync(){let e=[],r=[],n=Array.from(this.components.values());try{let o=this.validate();e.push(...o);let i=n.map(async l=>l.renderer&&typeof l.renderer!="function"&&typeof l.renderer!="object"?`Component "${l.id}" has invalid renderer type: ${typeof l.renderer}`:((l.id.includes(" ")||l.id.includes("-"))&&r.push(`Component "${l.id}" uses non-standard naming (contains spaces or dashes)`),null)),a=(await Promise.all(i)).filter(l=>l!==null);e.push(...a),n.length>50&&r.push("Large number of components detected. Consider splitting configuration.");let f={isValid:e.length===0,errors:e,warnings:r.length>0?r:void 0};if(!f.isValid)throw new p("Ril configuration validation failed",{errors:e,warnings:r,componentCount:n.length});return f}catch(o){throw o instanceof p?o:new p("Unexpected error during async validation",{originalError:o instanceof Error?o.message:String(o)})}}};function y(t,e=[]){return {isValid:t,errors:[...e]}}function d(){return y(true,[])}function u(t,e,r){return y(false,[{message:t,code:e,path:r}])}function R(t){let e=[],r=true;for(let n of t)n.isValid||(r=false),e.push(...n.errors);return y(r,e)}function O(t,e,r){let n=t.map(o=>{let i=o(e,r);if(i instanceof Promise)throw new Error("Use runValidatorsAsync for async validators");return i});return R(n)}async function N(t,e,r){let n=await Promise.all(t.map(o=>o(e,r)));return R(n)}function $(t={}){return {fieldId:t.fieldId,formId:t.formId,stepId:t.stepId,workflowId:t.workflowId,allFormData:t.allFormData||{},stepData:t.stepData||{},workflowData:t.workflowData||{}}}function S(t="This field is required"){return e=>e==null||e===""||Array.isArray(e)&&e.length===0?u(t,"REQUIRED"):d()}function L(t,e){return r=>!r||r.length<t?u(e||`Must be at least ${t} characters long`,"MIN_LENGTH",`length.${t}`):d()}function D(t,e){return r=>r&&r.length>t?u(e||`Must be no more than ${t} characters long`,"MAX_LENGTH",`length.${t}`):d()}function W(t,e){return r=>r&&!t.test(r)?u(e||"Invalid format","PATTERN_MISMATCH",`pattern.${t.source}`):d()}function q(t="Please enter a valid email address"){let e=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;return r=>r&&!e.test(r)?u(t,"INVALID_EMAIL"):d()}function _(t="Please enter a valid URL"){let e=/^https?:\/\/(?:[-\w.])+(?:\:[0-9]+)?(?:\/(?:[\w/_.])*(?:\?(?:[\w&=%.])*)?(?:\#(?:[\w.])*)?)?$/;return r=>r&&!e.test(r)?u(t,"INVALID_URL"):d()}function U(t="Must be a valid number"){return e=>{let r=typeof e=="string"?Number.parseFloat(e):e;return Number.isNaN(r)||!Number.isFinite(r)?u(t,"INVALID_NUMBER"):d()}}function z(t,e){return r=>{let n=typeof r=="string"?Number.parseFloat(r):r;return !Number.isNaN(n)&&n<t?u(e||`Must be at least ${t}`,"MIN_VALUE",`min.${t}`):d()}}function K(t,e){return r=>{let n=typeof r=="string"?Number.parseFloat(r):r;return !Number.isNaN(n)&&n>t?u(e||`Must be no more than ${t}`,"MAX_VALUE",`max.${t}`):d()}}function j(t,e,r){return (n,o)=>t(n,o)?d():u(e,r||"CUSTOM_VALIDATION_FAILED")}function Q(t,e){return (r,n)=>{let o=n.allFormData?.[t];return r!==o?u(e||"Fields must match","FIELD_MISMATCH",`match.${t}`):d()}}function H(t,e){return (r,n)=>t(r,n)?e(r,n):d()}function Z(t,e,r){return async(n,o)=>{try{return await t(n,o)?d():u(e,r||"ASYNC_VALIDATION_FAILED")}catch(i){return u(i instanceof Error?i.message:"Async validation error","ASYNC_ERROR")}}}var J=0,M=()=>`event_${Date.now()}_${++J}`,G=()=>`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,w=class{constructor(e,r){this.adapters=[];this.eventBuffer=[];this.config={bufferSize:100,flushInterval:5e3,sampleRate:1,enablePerformanceTracking:true,enableErrorTracking:true,enableMemoryTracking:false,...e},this.context={sessionId:G(),environment:"production",userAgent:typeof window<"u"?window.navigator?.userAgent:void 0,url:typeof window<"u"?window.location?.href:void 0,...r},this.profiler=new T,this.config.enabled&&this.startFlushTimer();}addAdapter(e){this.adapters.push(e);}removeAdapter(e){this.adapters=this.adapters.filter(r=>r.name!==e);}track(e,r,n,o,i="low"){if(!this.config.enabled||Math.random()>(this.config.sampleRate||1))return;let s={id:M(),type:e,timestamp:Date.now(),source:r,data:{...n,context:this.context},metrics:o,severity:i};if(o&&this.config.performanceThresholds&&this.checkPerformanceThresholds(s,o),this.eventBuffer.push(s),this.config.onEvent)try{this.config.onEvent(s);}catch(a){console.error("Error in monitoring event callback:",a);}this.eventBuffer.length>=(this.config.bufferSize||100)&&this.flush();}trackError(e,r,n){this.track("error",r,{message:e.message,name:e.name,stack:e.stack,context:n},void 0,"high");}getProfiler(){return this.profiler}updateContext(e){this.context={...this.context,...e};}async flush(){if(this.eventBuffer.length===0)return;let e=[...this.eventBuffer];if(this.eventBuffer=[],this.config.onBatch)try{this.config.onBatch(e);}catch(r){console.error("Error in monitoring batch callback:",r);}await Promise.all(this.adapters.map(async r=>{try{await r.send(e);}catch(n){console.error(`Error sending events to adapter ${r.name}:`,n),this.config.onError&&this.config.onError(n);}}));}async destroy(){this.flushTimer&&clearInterval(this.flushTimer),await this.flush(),await Promise.all(this.adapters.map(async e=>{if(e.flush)try{await e.flush();}catch(r){console.error(`Error flushing adapter ${e.name}:`,r);}}));}startFlushTimer(){this.config.flushInterval&&this.config.flushInterval>0&&(this.flushTimer=setInterval(()=>{this.flush();},this.config.flushInterval));}checkPerformanceThresholds(e,r){let n=this.config.performanceThresholds;n.componentRenderTime&&e.type==="component_render"&&r.duration>n.componentRenderTime&&this.createPerformanceWarning("Component render time exceeded threshold",n.componentRenderTime,r.duration,"Consider memoizing component or optimizing render logic"),n.formValidationTime&&e.type==="form_validation"&&r.duration>n.formValidationTime&&this.createPerformanceWarning("Form validation time exceeded threshold",n.formValidationTime,r.duration,"Consider debouncing validation or optimizing validators"),n.workflowNavigationTime&&e.type==="workflow_navigation"&&r.duration>n.workflowNavigationTime&&this.createPerformanceWarning("Workflow navigation time exceeded threshold",n.workflowNavigationTime,r.duration,"Consider optimizing step transitions or condition evaluation"),n.memoryUsage&&r.memoryUsage&&r.memoryUsage>n.memoryUsage&&this.createPerformanceWarning("Memory usage exceeded threshold",n.memoryUsage,r.memoryUsage,"Check for memory leaks or optimize data structures"),n.reRenderCount&&r.reRenderCount&&r.reRenderCount>n.reRenderCount&&this.createPerformanceWarning("Component re-render count exceeded threshold",n.reRenderCount,r.reRenderCount,"Consider using React.memo or optimizing dependencies");}createPerformanceWarning(e,r,n,o){let i={id:M(),type:"performance_warning",timestamp:Date.now(),source:"rilay_monitor",data:{message:e,context:this.context},threshold:r,actualValue:n,recommendation:o,severity:"medium"};if(this.eventBuffer.push(i),this.config.onEvent)try{this.config.onEvent(i);}catch(s){console.error("Error in performance warning callback:",s);}}},T=class{constructor(){this.metrics=new Map;this.startTimes=new Map;}start(e,r={}){this.startTimes.set(e,performance.now()),this.metrics.set(e,{timestamp:Date.now(),duration:0,renderCount:r.renderCount||0,reRenderCount:r.reRenderCount||0,memoryUsage:this.getMemoryUsage()});}end(e){let r=this.startTimes.get(e);if(!r)return null;let n=performance.now()-r,o=this.metrics.get(e);if(!o)return null;let i={...o,duration:n,memoryUsage:this.getMemoryUsage()};return this.metrics.set(e,i),this.startTimes.delete(e),i}mark(e){typeof performance<"u"&&performance.mark&&performance.mark(e);}measure(e,r,n){if(typeof performance<"u"&&performance.measure){performance.measure(e,r,n);let o=performance.getEntriesByName(e,"measure");return o.length>0?o[o.length-1].duration:0}return 0}getMetrics(e){return this.metrics.get(e)||null}getAllMetrics(){let e={};return this.metrics.forEach((r,n)=>{e[n]=r;}),e}clear(e){e?(this.metrics.delete(e),this.startTimes.delete(e)):(this.metrics.clear(),this.startTimes.clear());}getMemoryUsage(){if(typeof performance<"u"&&performance.memory)return performance.memory.usedJSHeapSize}},g=null;function he(t,e){return g&&g.destroy(),g=new w(t,e),g}function ye(){return g}async function Ce(){g&&(await g.destroy(),g=null);}var b=class{constructor(e="info"){this.name="console";this.logLevel=e;}async send(e){for(let r of e)this.logEvent(r);}logEvent(e){let r={id:e.id,type:e.type,timestamp:new Date(e.timestamp).toISOString(),source:e.source,severity:e.severity,data:e.data,metrics:e.metrics};switch(e.severity){case "critical":case "high":this.shouldLog("error")&&console.error(`[Rilay Monitor] ${e.type}:`,r);break;case "medium":this.shouldLog("warn")&&console.warn(`[Rilay Monitor] ${e.type}:`,r);break;default:this.shouldLog("info")&&console.info(`[Rilay Monitor] ${e.type}:`,r);break}if(e.type==="performance_warning"&&this.shouldLog("warn")){let n=e;console.warn(`[Rilay Performance Warning] ${n.data.message}`,{threshold:n.threshold,actual:n.actualValue,recommendation:n.recommendation});}}shouldLog(e){let r=["debug","info","warn","error"],n=r.indexOf(this.logLevel);return r.indexOf(e)>=n}},A=class{constructor(e){this.name="remote";this.eventQueue=[];this.isProcessing=false;this.endpoint=e.endpoint,this.apiKey=e.apiKey,this.headers={"Content-Type":"application/json",...e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{},...e.headers},this.batchSize=e.batchSize||50,this.retryAttempts=e.retryAttempts||3;}async send(e){this.eventQueue.push(...e),this.isProcessing||await this.processQueue();}async flush(){await this.processQueue();}configure(e){e.headers&&Object.assign(this.headers,e.headers);}async processQueue(){if(!(this.isProcessing||this.eventQueue.length===0)){this.isProcessing=true;try{for(;this.eventQueue.length>0;){let e=this.eventQueue.splice(0,this.batchSize);await this.sendBatch(e);}}finally{this.isProcessing=false;}}}async sendBatch(e){let r={events:e,timestamp:Date.now(),source:"rilay-monitoring"},n=null;for(let o=1;o<=this.retryAttempts;o++)try{let i=await fetch(this.endpoint,{method:"POST",headers:this.headers,body:JSON.stringify(r)});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);return}catch(i){if(n=i,i instanceof Error&&i.message.includes("HTTP 4"))break;o<this.retryAttempts&&await this.delay(2**o*1e3);}throw console.error("Failed to send monitoring events to remote endpoint:",n),n}delay(e){return new Promise(r=>setTimeout(r,e))}},B=class{constructor(e=1e3){this.name="localStorage";this.storageKey="rilay_monitoring_events";this.maxEvents=e;}async send(e){try{let o=[...this.getStoredEvents(),...e].slice(-this.maxEvents);localStorage.setItem(this.storageKey,JSON.stringify(o));}catch(r){console.error("Failed to store monitoring events:",r);}}async flush(){}getStoredEvents(){try{let e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):[]}catch(e){return console.error("Failed to retrieve stored monitoring events:",e),[]}}clearStoredEvents(){localStorage.removeItem(this.storageKey);}getEventCount(){return this.getStoredEvents().length}},F=class{constructor(){this.name="development";this.console=new b("debug");}async send(e){await this.console.send(e),this.logPerformanceSummary(e),this.logErrorSummary(e);}logPerformanceSummary(e){let r=e.filter(s=>s.metrics);if(r.length===0)return;console.group("[Rilay Performance Summary]");let n=r.reduce((s,a)=>s+(a.metrics?.duration||0),0)/r.length,o=Math.max(...r.map(s=>s.metrics?.duration||0));console.info(`Average duration: ${n.toFixed(2)}ms`),console.info(`Max duration: ${o.toFixed(2)}ms`);let i={};for(let s of r)i[s.type]||(i[s.type]=[]),i[s.type].push(s);for(let[s,a]of Object.entries(i)){let f=a.reduce((l,h)=>l+(h.metrics?.duration||0),0)/a.length;console.info(`${s}: ${f.toFixed(2)}ms avg (${a.length} events)`);}console.groupEnd();}logErrorSummary(e){let r=e.filter(o=>o.type==="error");if(r.length===0)return;console.group("[Rilay Error Summary]"),console.error(`${r.length} errors detected`);let n={};for(let o of r)n[o.source]=(n[o.source]||0)+1;for(let[o,i]of Object.entries(n))console.error(`${o}: ${i} errors`);console.groupEnd();}};var x=class{constructor(e){this.field=e,this.operator="exists",this.conditions=[];}equals(e){return this.operator="equals",this.value=e,this}notEquals(e){return this.operator="notEquals",this.value=e,this}greaterThan(e){return this.operator="greaterThan",this.value=e,this}lessThan(e){return this.operator="lessThan",this.value=e,this}greaterThanOrEqual(e){return this.operator="greaterThanOrEqual",this.value=e,this}lessThanOrEqual(e){return this.operator="lessThanOrEqual",this.value=e,this}contains(e){return this.operator="contains",this.value=e,this}notContains(e){return this.operator="notContains",this.value=e,this}in(e){return this.operator="in",this.value=e,this}notIn(e){return this.operator="notIn",this.value=e,this}matches(e){return this.operator="matches",this.value=e instanceof RegExp?e.source:e,this}exists(){return this.operator="exists",this.value=void 0,this}notExists(){return this.operator="notExists",this.value=void 0,this}and(e){let r="build"in e?e.build():e,n={field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator};return this.field="",this.operator="exists",this.value=void 0,this.conditions=[n,r],this.logicalOperator="and",this}or(e){let r="build"in e?e.build():e,n={field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator};return this.field="",this.operator="exists",this.value=void 0,this.conditions=[n,r],this.logicalOperator="or",this}build(){return {field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator}}evaluate(e){return I(this,e)}};function we(t){return new x(t)}function I(t,e){if(t.conditions&&t.conditions.length>0){let n=t.conditions.map(o=>I(o,e));return t.logicalOperator==="or"?n.some(o=>o):n.every(o=>o)}let r=X(e,t.field);switch(t.operator){case "equals":return r===t.value;case "notEquals":return r!==t.value;case "greaterThan":return typeof r=="number"&&typeof t.value=="number"&&r>t.value;case "lessThan":return typeof r=="number"&&typeof t.value=="number"&&r<t.value;case "greaterThanOrEqual":return typeof r=="number"&&typeof t.value=="number"&&r>=t.value;case "lessThanOrEqual":return typeof r=="number"&&typeof t.value=="number"&&r<=t.value;case "contains":return typeof r=="string"&&typeof t.value=="string"||Array.isArray(r)?r.includes(t.value):false;case "notContains":return typeof r=="string"&&typeof t.value=="string"||Array.isArray(r)?!r.includes(t.value):false;case "in":return Array.isArray(t.value)&&t.value.includes(r);case "notIn":return Array.isArray(t.value)&&!t.value.includes(r);case "matches":return typeof r!="string"||typeof t.value!="string"?false:new RegExp(t.value).test(r);case "exists":return r!=null;case "notExists":return r==null;default:return false}}function X(t,e){let r=e.split("."),n=t;for(let o of r)if(n&&typeof n=="object"&&o in n)n=n[o];else return;return n}exports.ComponentRendererWrapper=re;exports.ConsoleAdapter=b;exports.DevelopmentAdapter=F;exports.IdGenerator=V;exports.LocalStorageAdapter=B;exports.RemoteAdapter=A;exports.RilayMonitor=w;exports.async=Z;exports.combineValidationResults=R;exports.configureObject=se;exports.createValidationContext=$;exports.createValidationResult=y;exports.custom=j;exports.deepClone=k;exports.destroyGlobalMonitoring=Ce;exports.email=q;exports.ensureUnique=P;exports.evaluateCondition=I;exports.getGlobalMonitor=ye;exports.initializeMonitoring=he;exports.matchField=Q;exports.max=K;exports.maxLength=D;exports.mergeInto=ne;exports.min=z;exports.minLength=L;exports.normalizeToArray=ie;exports.number=U;exports.pattern=W;exports.required=S;exports.resolveRendererChildren=E;exports.ril=v;exports.runValidators=O;exports.runValidatorsAsync=N;exports.url=_;exports.validateRequired=oe;exports.validateWhen=H;exports.when=we;
1
+ 'use strict';function x(n,e){return typeof n=="function"?n(e):n}function le({children:n,renderAs:e,renderer:r,name:t,props:o}){if(e==="children"||e===true){if(typeof n!="function")throw new Error(`When renderAs="children" is used, children must be a function that returns React elements for ${t}`);return n(o)}if(!r)throw new Error(`No renderer provided for ${t}`);if(typeof r!="function")throw new Error(`Renderer must be a function for ${t}`);let s={...o,children:x(n,o)};return r(s)}function ce(n,e){return {...n,...e}}function k(n,e){let r=n.filter((t,o)=>n.indexOf(t)!==o);if(r.length>0)throw new Error(`Duplicate ${e} IDs: ${r.join(", ")}`)}function fe(n,e,r){if(n.filter(o=>e.some(i=>!o[i])).length>0)throw new Error(`Missing required fields in ${r}: ${e.join(", ")}`)}var E=class{constructor(){this.counters=new Map;}next(e){let r=this.counters.get(e)||0;return this.counters.set(e,r+1),`${e}-${r+1}`}reset(e){e?this.counters.delete(e):this.counters.clear();}};function me(n){return Array.isArray(n)?n:[n]}function S(n){if(n===null||typeof n!="object")return n;if(n instanceof Date)return new Date(n.getTime());if(Array.isArray(n))return n.map(r=>S(r));let e={};for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=S(n[r]));return e}function pe(n,e,r){let t={...n};for(let o in e)r&&!r.includes(o)||e[o]!==void 0&&(t[o]=e[o]);return t}var h=class extends Error{constructor(r,t,o){super(r);this.code=t;this.meta=o;this.name="RilayError";}},p=class extends h{constructor(e,r){super(e,"VALIDATION_ERROR",r),this.name="ValidationError";}};function m(n,e){let r={...n};for(let t in e){let o=e[t],i=r[t];o&&typeof o=="object"&&!Array.isArray(o)&&i&&typeof i=="object"&&!Array.isArray(i)?r[t]=m(i,o):r[t]=o;}return r}var y=class n{constructor(){this.components=new Map;this.formRenderConfig={};this.workflowRenderConfig={};}static create(){return new n}addComponent(e,r){let t={id:e,type:e,...r},o=new n;return o.components=new Map(this.components),o.formRenderConfig={...this.formRenderConfig},o.workflowRenderConfig={...this.workflowRenderConfig},o.components.set(e,t),o}configure(e){let r=["rowRenderer","bodyRenderer","submitButtonRenderer","fieldRenderer"],t=["stepperRenderer","nextButtonRenderer","previousButtonRenderer","skipButtonRenderer"],o={},i={};for(let[a,u]of Object.entries(e))r.includes(a)?o[a]=u:t.includes(a)&&(i[a]=u);let s=new n;return s.components=new Map(this.components),s.formRenderConfig=m(this.formRenderConfig,o),s.workflowRenderConfig=m(this.workflowRenderConfig,i),s}getFormRenderConfig(){return {...this.formRenderConfig}}getWorkflowRenderConfig(){return {...this.workflowRenderConfig}}getComponent(e){return this.components.get(e)}getAllComponents(){return Array.from(this.components.values())}hasComponent(e){return this.components.has(e)}removeComponent(e){let r=new n;return r.components=new Map(this.components),r.formRenderConfig={...this.formRenderConfig},r.workflowRenderConfig={...this.workflowRenderConfig},r.components.delete(e),r}clear(){let e=new n;return e.formRenderConfig={...this.formRenderConfig},e.workflowRenderConfig={...this.workflowRenderConfig},e}clone(){let e=new n;return e.components=new Map(this.components),e.formRenderConfig=m({},this.formRenderConfig),e.workflowRenderConfig=m({},this.workflowRenderConfig),e}getStats(){let e=Array.from(this.components.values());return {total:e.length,byType:e.reduce((r,t)=>(r[t.type]=(r[t.type]||0)+1,r),{}),hasCustomRenderers:{row:!!this.formRenderConfig.rowRenderer,body:!!this.formRenderConfig.bodyRenderer,submitButton:!!this.formRenderConfig.submitButtonRenderer,field:!!this.formRenderConfig.fieldRenderer,stepper:!!this.workflowRenderConfig.stepperRenderer,workflowNextButton:!!this.workflowRenderConfig.nextButtonRenderer,workflowPreviousButton:!!this.workflowRenderConfig.previousButtonRenderer,workflowSkipButton:!!this.workflowRenderConfig.skipButtonRenderer}}}validate(){let e=[],r=Array.from(this.components.values()),t=r.map(l=>l.id);try{k(t,"component");}catch(l){e.push(l instanceof Error?l.message:String(l));}let o=r.filter(l=>!l.renderer);o.length>0&&e.push(`Components without renderer: ${o.map(l=>l.id).join(", ")}`);let i=Object.keys(this.formRenderConfig),s=Object.keys(this.workflowRenderConfig),a=["rowRenderer","bodyRenderer","submitButtonRenderer","fieldRenderer"],u=["stepperRenderer","nextButtonRenderer","previousButtonRenderer","skipButtonRenderer"],d=i.filter(l=>!a.includes(l)),g=s.filter(l=>!u.includes(l));return d.length>0&&e.push(`Invalid form renderer keys: ${d.join(", ")}`),g.length>0&&e.push(`Invalid workflow renderer keys: ${g.join(", ")}`),e}async validateAsync(){let e=[],r=[],t=Array.from(this.components.values());try{let o=this.validate();e.push(...o);let i=t.map(async d=>d.renderer&&typeof d.renderer!="function"&&typeof d.renderer!="object"?`Component "${d.id}" has invalid renderer type: ${typeof d.renderer}`:((d.id.includes(" ")||d.id.includes("-"))&&r.push(`Component "${d.id}" uses non-standard naming (contains spaces or dashes)`),null)),a=(await Promise.all(i)).filter(d=>d!==null);e.push(...a),t.length>50&&r.push("Large number of components detected. Consider splitting configuration.");let u={isValid:e.length===0,errors:e,warnings:r.length>0?r:void 0};if(!u.isValid)throw new p("Ril configuration validation failed",{errors:e,warnings:r,componentCount:t.length});return u}catch(o){throw o instanceof p?o:new p("Unexpected error during async validation",{originalError:o instanceof Error?o.message:String(o)})}}};function v(n,e=[]){return {isValid:n,errors:[...e]}}function I(){return v(true,[])}function O(n,e,r){return v(false,[{message:n,code:e,path:r}])}function N(n={}){return {fieldId:n.fieldId,formId:n.formId,stepId:n.stepId,workflowId:n.workflowId,allFormData:n.allFormData||{},stepData:n.stepData||{},workflowData:n.workflowData||{}}}function $(n="This field is required"){return {"~standard":{version:1,vendor:"rilaykit",validate:e=>e===""||e==null||Array.isArray(e)&&e.length===0||typeof e=="object"&&Object.keys(e).length===0?{issues:[{message:n,path:void 0}]}:{value:e}}}}function F(n="Please enter a valid email address"){let e=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return {"~standard":{version:1,vendor:"rilaykit",validate:r=>typeof r!="string"?{issues:[{message:"Email must be a string"}]}:e.test(r)?{value:r}:{issues:[{message:n}]},types:{input:"",output:""}}}}function W(n="Please enter a valid URL"){return {"~standard":{version:1,vendor:"rilaykit",validate:e=>{if(typeof e!="string")return {issues:[{message:"URL must be a string"}]};try{return new URL(e),{value:e}}catch{return {issues:[{message:n}]}}},types:{input:"",output:""}}}}function L(n,e){let r=`Must be at least ${n} characters long`;return {"~standard":{version:1,vendor:"rilaykit",validate:t=>typeof t!="string"?{issues:[{message:"Value must be a string"}]}:t.length>=n?{value:t}:{issues:[{message:e||r}]},types:{input:"",output:""}}}}function D(n,e){let r=`Must be no more than ${n} characters long`;return {"~standard":{version:1,vendor:"rilaykit",validate:t=>typeof t!="string"?{issues:[{message:"Value must be a string"}]}:t.length<=n?{value:t}:{issues:[{message:e||r}]},types:{input:"",output:""}}}}function q(n,e="Value does not match required pattern"){return {"~standard":{version:1,vendor:"rilaykit",validate:r=>typeof r!="string"?{issues:[{message:"Value must be a string"}]}:n.test(r)?{value:r}:{issues:[{message:e}]},types:{input:"",output:""}}}}function U(n="Must be a valid number"){return {"~standard":{version:1,vendor:"rilaykit",validate:e=>{let r=typeof e=="string"?Number(e):e;return typeof r!="number"||Number.isNaN(r)?{issues:[{message:n}]}:{value:r}},types:{input:0,output:0}}}}function K(n,e){let r=`Must be at least ${n}`;return {"~standard":{version:1,vendor:"rilaykit",validate:t=>{let o=typeof t=="string"?Number(t):t;return typeof o!="number"||Number.isNaN(o)?{issues:[{message:"Value must be a number"}]}:o>=n?{value:o}:{issues:[{message:e||r}]}},types:{input:0,output:0}}}}function z(n,e){let r=`Must be no more than ${n}`;return {"~standard":{version:1,vendor:"rilaykit",validate:t=>{let o=typeof t=="string"?Number(t):t;return typeof o!="number"||Number.isNaN(o)?{issues:[{message:"Value must be a number"}]}:o<=n?{value:o}:{issues:[{message:e||r}]}},types:{input:0,output:0}}}}function _(n,e="Validation failed"){return {"~standard":{version:1,vendor:"rilaykit",validate:r=>{try{return n(r)?{value:r}:{issues:[{message:e}]}}catch(t){return {issues:[{message:t instanceof Error?t.message:e}]}}}}}}function j(n,e="Async validation failed"){return {"~standard":{version:1,vendor:"rilaykit",validate:async r=>{try{return await n(r)?{value:r}:{issues:[{message:e}]}}catch(t){return {issues:[{message:t instanceof Error?t.message:e}]}}}}}}function Q(...n){return {"~standard":{version:1,vendor:"rilaykit",validate:async e=>{let r=[],t=e;for(let o of n){let i=o["~standard"].validate(e);i instanceof Promise&&(i=await i),i.issues?r.push(...i.issues):t=i.value;}return r.length>0?{issues:r}:{value:t}}}}}function c(n){return n!=null&&typeof n=="object"&&"~standard"in n&&n["~standard"]!==null&&typeof n["~standard"]=="object"&&n["~standard"].version===1&&typeof n["~standard"].vendor=="string"&&typeof n["~standard"].validate=="function"}async function C(n,e){if(!c(n))throw new Error("Invalid Standard Schema: missing ~standard property or invalid structure");try{let r=n["~standard"].validate(e);return r instanceof Promise&&(r=await r),r.issues?{isValid:!1,errors:r.issues.map(o=>({message:o.message,code:"VALIDATION_ERROR",path:H(o.path)}))}:{isValid:!0,errors:[],value:r.value}}catch(r){return {isValid:false,errors:[{message:r instanceof Error?r.message:"Validation failed",code:"VALIDATION_ERROR"}]}}}function H(n){if(!(!n||n.length===0))return n.map(e=>typeof e=="object"&&"key"in e?String(e.key):String(e)).join(".")}function J(n){if(!c(n))throw new Error("Invalid Standard Schema");return {vendor:n["~standard"].vendor,version:n["~standard"].version,hasTypes:!!n["~standard"].types}}function G(n){return c(n)&&!!n["~standard"].types}async function X(n,e,r){if(!n.validate)return {isValid:true,errors:[]};let t=Array.isArray(n.validate)?n.validate:[n.validate],o=[];for(let i of t){if(!c(i)){o.push({message:"Invalid validation rule: must implement Standard Schema interface",code:"INVALID_SCHEMA"});continue}try{let s=await C(i,e);s.isValid||o.push(...s.errors);}catch(s){o.push({message:s instanceof Error?s.message:"Validation error",code:"VALIDATION_ERROR"});}}return {isValid:o.length===0,errors:o}}async function Y(n,e,r){if(!n.validate)return {isValid:true,errors:[]};let t=Array.isArray(n.validate)?n.validate:[n.validate],o=[];for(let i of t){if(!c(i)){o.push({message:"Invalid validation rule: must implement Standard Schema interface",code:"INVALID_SCHEMA"});continue}try{let s=await C(i,e);s.isValid||o.push(...s.errors);}catch(s){o.push({message:s instanceof Error?s.message:"Form validation error",code:"FORM_VALIDATION_ERROR"});}}return {isValid:o.length===0,errors:o}}function Z(n){return !!n.validate}function ee(...n){return {"~standard":{version:1,vendor:"rilaykit-combined",validate:async e=>{let r=[],t=e;for(let o of n){let i=o["~standard"].validate(e);i instanceof Promise&&(i=await i),i.issues?r.push(...i.issues):t=i.value;}return r.length>0?{issues:r}:{value:t}}}}}function re(n,e="rilaykit"){return {"~standard":{version:1,vendor:e,validate:async r=>{try{let t=await n(r,{});return t.isValid?{value:r}:{issues:t.errors.map(i=>({message:i.message,path:i.path?[i.path]:void 0}))}}catch(t){return {issues:[{message:t instanceof Error?t.message:"Validation failed"}]}}}}}}function ne(n){return Array.isArray(n)?n.every(c):c(n)}function te(n){return n?Array.isArray(n)?n:[n]:[]}var oe=0,V=()=>`event_${Date.now()}_${++oe}`,ie=()=>`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,w=class{constructor(e,r){this.adapters=[];this.eventBuffer=[];this.config={bufferSize:100,flushInterval:5e3,sampleRate:1,enablePerformanceTracking:true,enableErrorTracking:true,enableMemoryTracking:false,...e},this.context={sessionId:ie(),environment:"production",userAgent:typeof window<"u"?window.navigator?.userAgent:void 0,url:typeof window<"u"?window.location?.href:void 0,...r},this.profiler=new R,this.config.enabled&&this.startFlushTimer();}addAdapter(e){this.adapters.push(e);}removeAdapter(e){this.adapters=this.adapters.filter(r=>r.name!==e);}track(e,r,t,o,i="low"){if(!this.config.enabled||Math.random()>(this.config.sampleRate||1))return;let s={id:V(),type:e,timestamp:Date.now(),source:r,data:{...t,context:this.context},metrics:o,severity:i};if(o&&this.config.performanceThresholds&&this.checkPerformanceThresholds(s,o),this.eventBuffer.push(s),this.config.onEvent)try{this.config.onEvent(s);}catch(a){console.error("Error in monitoring event callback:",a);}this.eventBuffer.length>=(this.config.bufferSize||100)&&this.flush();}trackError(e,r,t){this.track("error",r,{message:e.message,name:e.name,stack:e.stack,context:t},void 0,"high");}getProfiler(){return this.profiler}updateContext(e){this.context={...this.context,...e};}async flush(){if(this.eventBuffer.length===0)return;let e=[...this.eventBuffer];if(this.eventBuffer=[],this.config.onBatch)try{this.config.onBatch(e);}catch(r){console.error("Error in monitoring batch callback:",r);}await Promise.all(this.adapters.map(async r=>{try{await r.send(e);}catch(t){console.error(`Error sending events to adapter ${r.name}:`,t),this.config.onError&&this.config.onError(t);}}));}async destroy(){this.flushTimer&&clearInterval(this.flushTimer),await this.flush(),await Promise.all(this.adapters.map(async e=>{if(e.flush)try{await e.flush();}catch(r){console.error(`Error flushing adapter ${e.name}:`,r);}}));}startFlushTimer(){this.config.flushInterval&&this.config.flushInterval>0&&(this.flushTimer=setInterval(()=>{this.flush();},this.config.flushInterval));}checkPerformanceThresholds(e,r){let t=this.config.performanceThresholds;t.componentRenderTime&&e.type==="component_render"&&r.duration>t.componentRenderTime&&this.createPerformanceWarning("Component render time exceeded threshold",t.componentRenderTime,r.duration,"Consider memoizing component or optimizing render logic"),t.formValidationTime&&e.type==="form_validation"&&r.duration>t.formValidationTime&&this.createPerformanceWarning("Form validation time exceeded threshold",t.formValidationTime,r.duration,"Consider debouncing validation or optimizing validators"),t.workflowNavigationTime&&e.type==="workflow_navigation"&&r.duration>t.workflowNavigationTime&&this.createPerformanceWarning("Workflow navigation time exceeded threshold",t.workflowNavigationTime,r.duration,"Consider optimizing step transitions or condition evaluation"),t.memoryUsage&&r.memoryUsage&&r.memoryUsage>t.memoryUsage&&this.createPerformanceWarning("Memory usage exceeded threshold",t.memoryUsage,r.memoryUsage,"Check for memory leaks or optimize data structures"),t.reRenderCount&&r.reRenderCount&&r.reRenderCount>t.reRenderCount&&this.createPerformanceWarning("Component re-render count exceeded threshold",t.reRenderCount,r.reRenderCount,"Consider using React.memo or optimizing dependencies");}createPerformanceWarning(e,r,t,o){let i={id:V(),type:"performance_warning",timestamp:Date.now(),source:"rilay_monitor",data:{message:e,context:this.context},threshold:r,actualValue:t,recommendation:o,severity:"medium"};if(this.eventBuffer.push(i),this.config.onEvent)try{this.config.onEvent(i);}catch(s){console.error("Error in performance warning callback:",s);}}},R=class{constructor(){this.metrics=new Map;this.startTimes=new Map;}start(e,r={}){this.startTimes.set(e,performance.now()),this.metrics.set(e,{timestamp:Date.now(),duration:0,renderCount:r.renderCount||0,reRenderCount:r.reRenderCount||0,memoryUsage:this.getMemoryUsage()});}end(e){let r=this.startTimes.get(e);if(!r)return null;let t=performance.now()-r,o=this.metrics.get(e);if(!o)return null;let i={...o,duration:t,memoryUsage:this.getMemoryUsage()};return this.metrics.set(e,i),this.startTimes.delete(e),i}mark(e){typeof performance<"u"&&performance.mark&&performance.mark(e);}measure(e,r,t){if(typeof performance<"u"&&performance.measure){performance.measure(e,r,t);let o=performance.getEntriesByName(e,"measure");return o.length>0?o[o.length-1].duration:0}return 0}getMetrics(e){return this.metrics.get(e)||null}getAllMetrics(){let e={};return this.metrics.forEach((r,t)=>{e[t]=r;}),e}clear(e){e?(this.metrics.delete(e),this.startTimes.delete(e)):(this.metrics.clear(),this.startTimes.clear());}getMemoryUsage(){if(typeof performance<"u"&&performance.memory)return performance.memory.usedJSHeapSize}},f=null;function Se(n,e){return f&&f.destroy(),f=new w(n,e),f}function ke(){return f}async function Ve(){f&&(await f.destroy(),f=null);}var b=class{constructor(e="info"){this.name="console";this.logLevel=e;}async send(e){for(let r of e)this.logEvent(r);}logEvent(e){let r={id:e.id,type:e.type,timestamp:new Date(e.timestamp).toISOString(),source:e.source,severity:e.severity,data:e.data,metrics:e.metrics};switch(e.severity){case "critical":case "high":this.shouldLog("error")&&console.error(`[Rilay Monitor] ${e.type}:`,r);break;case "medium":this.shouldLog("warn")&&console.warn(`[Rilay Monitor] ${e.type}:`,r);break;default:this.shouldLog("info")&&console.info(`[Rilay Monitor] ${e.type}:`,r);break}if(e.type==="performance_warning"&&this.shouldLog("warn")){let t=e;console.warn(`[Rilay Performance Warning] ${t.data.message}`,{threshold:t.threshold,actual:t.actualValue,recommendation:t.recommendation});}}shouldLog(e){let r=["debug","info","warn","error"],t=r.indexOf(this.logLevel);return r.indexOf(e)>=t}},P=class{constructor(e){this.name="remote";this.eventQueue=[];this.isProcessing=false;this.endpoint=e.endpoint,this.apiKey=e.apiKey,this.headers={"Content-Type":"application/json",...e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{},...e.headers},this.batchSize=e.batchSize||50,this.retryAttempts=e.retryAttempts||3;}async send(e){this.eventQueue.push(...e),this.isProcessing||await this.processQueue();}async flush(){await this.processQueue();}configure(e){e.headers&&Object.assign(this.headers,e.headers);}async processQueue(){if(!(this.isProcessing||this.eventQueue.length===0)){this.isProcessing=true;try{for(;this.eventQueue.length>0;){let e=this.eventQueue.splice(0,this.batchSize);await this.sendBatch(e);}}finally{this.isProcessing=false;}}}async sendBatch(e){let r={events:e,timestamp:Date.now(),source:"rilay-monitoring"},t=null;for(let o=1;o<=this.retryAttempts;o++)try{let i=await fetch(this.endpoint,{method:"POST",headers:this.headers,body:JSON.stringify(r)});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);return}catch(i){if(t=i,i instanceof Error&&i.message.includes("HTTP 4"))break;o<this.retryAttempts&&await this.delay(2**o*1e3);}throw console.error("Failed to send monitoring events to remote endpoint:",t),t}delay(e){return new Promise(r=>setTimeout(r,e))}},M=class{constructor(e=1e3){this.name="localStorage";this.storageKey="rilay_monitoring_events";this.maxEvents=e;}async send(e){try{let o=[...this.getStoredEvents(),...e].slice(-this.maxEvents);localStorage.setItem(this.storageKey,JSON.stringify(o));}catch(r){console.error("Failed to store monitoring events:",r);}}async flush(){}getStoredEvents(){try{let e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):[]}catch(e){return console.error("Failed to retrieve stored monitoring events:",e),[]}}clearStoredEvents(){localStorage.removeItem(this.storageKey);}getEventCount(){return this.getStoredEvents().length}},B=class{constructor(){this.name="development";this.console=new b("debug");}async send(e){await this.console.send(e),this.logPerformanceSummary(e),this.logErrorSummary(e);}logPerformanceSummary(e){let r=e.filter(s=>s.metrics);if(r.length===0)return;console.group("[Rilay Performance Summary]");let t=r.reduce((s,a)=>s+(a.metrics?.duration||0),0)/r.length,o=Math.max(...r.map(s=>s.metrics?.duration||0));console.info(`Average duration: ${t.toFixed(2)}ms`),console.info(`Max duration: ${o.toFixed(2)}ms`);let i={};for(let s of r)i[s.type]||(i[s.type]=[]),i[s.type].push(s);for(let[s,a]of Object.entries(i)){let u=a.reduce((d,g)=>d+(g.metrics?.duration||0),0)/a.length;console.info(`${s}: ${u.toFixed(2)}ms avg (${a.length} events)`);}console.groupEnd();}logErrorSummary(e){let r=e.filter(o=>o.type==="error");if(r.length===0)return;console.group("[Rilay Error Summary]"),console.error(`${r.length} errors detected`);let t={};for(let o of r)t[o.source]=(t[o.source]||0)+1;for(let[o,i]of Object.entries(t))console.error(`${o}: ${i} errors`);console.groupEnd();}};var T=class{constructor(e){this.field=e,this.operator="exists",this.conditions=[];}equals(e){return this.operator="equals",this.value=e,this}notEquals(e){return this.operator="notEquals",this.value=e,this}greaterThan(e){return this.operator="greaterThan",this.value=e,this}lessThan(e){return this.operator="lessThan",this.value=e,this}greaterThanOrEqual(e){return this.operator="greaterThanOrEqual",this.value=e,this}lessThanOrEqual(e){return this.operator="lessThanOrEqual",this.value=e,this}contains(e){return this.operator="contains",this.value=e,this}notContains(e){return this.operator="notContains",this.value=e,this}in(e){return this.operator="in",this.value=e,this}notIn(e){return this.operator="notIn",this.value=e,this}matches(e){return this.operator="matches",this.value=e instanceof RegExp?e.source:e,this}exists(){return this.operator="exists",this.value=void 0,this}notExists(){return this.operator="notExists",this.value=void 0,this}and(e){let r="build"in e?e.build():e,t={field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator};return this.field="",this.operator="exists",this.value=void 0,this.conditions=[t,r],this.logicalOperator="and",this}or(e){let r="build"in e?e.build():e,t={field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator};return this.field="",this.operator="exists",this.value=void 0,this.conditions=[t,r],this.logicalOperator="or",this}build(){return {field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator}}evaluate(e){return A(this,e)}};function Be(n){return new T(n)}function A(n,e){if(n.conditions&&n.conditions.length>0){let t=n.conditions.map(o=>A(o,e));return n.logicalOperator==="or"?t.some(o=>o):t.every(o=>o)}let r=se(e,n.field);switch(n.operator){case "equals":return r===n.value;case "notEquals":return r!==n.value;case "greaterThan":return typeof r=="number"&&typeof n.value=="number"&&r>n.value;case "lessThan":return typeof r=="number"&&typeof n.value=="number"&&r<n.value;case "greaterThanOrEqual":return typeof r=="number"&&typeof n.value=="number"&&r>=n.value;case "lessThanOrEqual":return typeof r=="number"&&typeof n.value=="number"&&r<=n.value;case "contains":return typeof r=="string"&&typeof n.value=="string"||Array.isArray(r)?r.includes(n.value):false;case "notContains":return typeof r=="string"&&typeof n.value=="string"||Array.isArray(r)?!r.includes(n.value):false;case "in":return Array.isArray(n.value)&&n.value.includes(r);case "notIn":return Array.isArray(n.value)&&!n.value.includes(r);case "matches":return typeof r!="string"||typeof n.value!="string"?false:new RegExp(n.value).test(r);case "exists":return r!=null;case "notExists":return r==null;default:return false}}function se(n,e){let r=e.split("."),t=n;for(let o of r)if(t&&typeof t=="object"&&o in t)t=t[o];else return;return t}exports.ComponentRendererWrapper=le;exports.ConsoleAdapter=b;exports.DevelopmentAdapter=B;exports.IdGenerator=E;exports.LocalStorageAdapter=M;exports.RemoteAdapter=P;exports.RilayMonitor=w;exports.async=j;exports.combine=Q;exports.combineSchemas=ee;exports.configureObject=pe;exports.createErrorResult=O;exports.createStandardValidator=re;exports.createSuccessResult=I;exports.createValidationContext=N;exports.createValidationResult=v;exports.custom=_;exports.deepClone=S;exports.destroyGlobalMonitoring=Ve;exports.email=F;exports.ensureUnique=k;exports.evaluateCondition=A;exports.getGlobalMonitor=ke;exports.getSchemaInfo=J;exports.hasSchemaTypes=G;exports.hasUnifiedValidation=Z;exports.initializeMonitoring=Se;exports.isStandardSchema=c;exports.isValidationRule=ne;exports.max=z;exports.maxLength=D;exports.mergeInto=ce;exports.min=K;exports.minLength=L;exports.normalizeToArray=me;exports.normalizeValidationRules=te;exports.number=U;exports.pattern=q;exports.required=$;exports.resolveRendererChildren=x;exports.ril=y;exports.url=W;exports.validateFormWithUnifiedConfig=Y;exports.validateRequired=fe;exports.validateWithStandardSchema=C;exports.validateWithUnifiedConfig=X;exports.when=Be;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- function E(t,e){return typeof t=="function"?t(e):t}function re({children:t,renderAs:e,renderer:r,name:n,props:o}){if(e==="children"||e===true){if(typeof t!="function")throw new Error(`When renderAs="children" is used, children must be a function that returns React elements for ${n}`);return t(o)}if(!r)throw new Error(`No renderer provided for ${n}`);if(typeof r!="function")throw new Error(`Renderer must be a function for ${n}`);let s={...o,children:E(t,o)};return r(s)}function ne(t,e){return {...t,...e}}function P(t,e){let r=t.filter((n,o)=>t.indexOf(n)!==o);if(r.length>0)throw new Error(`Duplicate ${e} IDs: ${r.join(", ")}`)}function oe(t,e,r){if(t.filter(o=>e.some(i=>!o[i])).length>0)throw new Error(`Missing required fields in ${r}: ${e.join(", ")}`)}var V=class{constructor(){this.counters=new Map;}next(e){let r=this.counters.get(e)||0;return this.counters.set(e,r+1),`${e}-${r+1}`}reset(e){e?this.counters.delete(e):this.counters.clear();}};function ie(t){return Array.isArray(t)?t:[t]}function k(t){if(t===null||typeof t!="object")return t;if(t instanceof Date)return new Date(t.getTime());if(Array.isArray(t))return t.map(r=>k(r));let e={};for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=k(t[r]));return e}function se(t,e,r){let n={...t};for(let o in e)r&&!r.includes(o)||e[o]!==void 0&&(n[o]=e[o]);return n}var C=class extends Error{constructor(r,n,o){super(r);this.code=n;this.meta=o;this.name="RilayError";}},p=class extends C{constructor(e,r){super(e,"VALIDATION_ERROR",r),this.name="ValidationError";}};function m(t,e){let r={...t};for(let n in e){let o=e[n],i=r[n];o&&typeof o=="object"&&!Array.isArray(o)&&i&&typeof i=="object"&&!Array.isArray(i)?r[n]=m(i,o):r[n]=o;}return r}var v=class t{constructor(){this.components=new Map;this.formRenderConfig={};this.workflowRenderConfig={};}static create(){return new t}addComponent(e,r){let n={id:e,type:e,...r},o=new t;return o.components=new Map(this.components),o.formRenderConfig={...this.formRenderConfig},o.workflowRenderConfig={...this.workflowRenderConfig},o.components.set(e,n),o}configure(e){let r=["rowRenderer","bodyRenderer","submitButtonRenderer","fieldRenderer"],n=["stepperRenderer","nextButtonRenderer","previousButtonRenderer","skipButtonRenderer"],o={},i={};for(let[a,f]of Object.entries(e))r.includes(a)?o[a]=f:n.includes(a)&&(i[a]=f);let s=new t;return s.components=new Map(this.components),s.formRenderConfig=m(this.formRenderConfig,o),s.workflowRenderConfig=m(this.workflowRenderConfig,i),s}getFormRenderConfig(){return {...this.formRenderConfig}}getWorkflowRenderConfig(){return {...this.workflowRenderConfig}}getComponent(e){return this.components.get(e)}getAllComponents(){return Array.from(this.components.values())}hasComponent(e){return this.components.has(e)}removeComponent(e){let r=new t;return r.components=new Map(this.components),r.formRenderConfig={...this.formRenderConfig},r.workflowRenderConfig={...this.workflowRenderConfig},r.components.delete(e),r}clear(){let e=new t;return e.formRenderConfig={...this.formRenderConfig},e.workflowRenderConfig={...this.workflowRenderConfig},e}clone(){let e=new t;return e.components=new Map(this.components),e.formRenderConfig=m({},this.formRenderConfig),e.workflowRenderConfig=m({},this.workflowRenderConfig),e}getStats(){let e=Array.from(this.components.values());return {total:e.length,byType:e.reduce((r,n)=>(r[n.type]=(r[n.type]||0)+1,r),{}),hasCustomRenderers:{row:!!this.formRenderConfig.rowRenderer,body:!!this.formRenderConfig.bodyRenderer,submitButton:!!this.formRenderConfig.submitButtonRenderer,field:!!this.formRenderConfig.fieldRenderer,stepper:!!this.workflowRenderConfig.stepperRenderer,workflowNextButton:!!this.workflowRenderConfig.nextButtonRenderer,workflowPreviousButton:!!this.workflowRenderConfig.previousButtonRenderer,workflowSkipButton:!!this.workflowRenderConfig.skipButtonRenderer}}}validate(){let e=[],r=Array.from(this.components.values()),n=r.map(c=>c.id);try{P(n,"component");}catch(c){e.push(c instanceof Error?c.message:String(c));}let o=r.filter(c=>!c.renderer);o.length>0&&e.push(`Components without renderer: ${o.map(c=>c.id).join(", ")}`);let i=Object.keys(this.formRenderConfig),s=Object.keys(this.workflowRenderConfig),a=["rowRenderer","bodyRenderer","submitButtonRenderer","fieldRenderer"],f=["stepperRenderer","nextButtonRenderer","previousButtonRenderer","skipButtonRenderer"],l=i.filter(c=>!a.includes(c)),h=s.filter(c=>!f.includes(c));return l.length>0&&e.push(`Invalid form renderer keys: ${l.join(", ")}`),h.length>0&&e.push(`Invalid workflow renderer keys: ${h.join(", ")}`),e}async validateAsync(){let e=[],r=[],n=Array.from(this.components.values());try{let o=this.validate();e.push(...o);let i=n.map(async l=>l.renderer&&typeof l.renderer!="function"&&typeof l.renderer!="object"?`Component "${l.id}" has invalid renderer type: ${typeof l.renderer}`:((l.id.includes(" ")||l.id.includes("-"))&&r.push(`Component "${l.id}" uses non-standard naming (contains spaces or dashes)`),null)),a=(await Promise.all(i)).filter(l=>l!==null);e.push(...a),n.length>50&&r.push("Large number of components detected. Consider splitting configuration.");let f={isValid:e.length===0,errors:e,warnings:r.length>0?r:void 0};if(!f.isValid)throw new p("Ril configuration validation failed",{errors:e,warnings:r,componentCount:n.length});return f}catch(o){throw o instanceof p?o:new p("Unexpected error during async validation",{originalError:o instanceof Error?o.message:String(o)})}}};function y(t,e=[]){return {isValid:t,errors:[...e]}}function d(){return y(true,[])}function u(t,e,r){return y(false,[{message:t,code:e,path:r}])}function R(t){let e=[],r=true;for(let n of t)n.isValid||(r=false),e.push(...n.errors);return y(r,e)}function O(t,e,r){let n=t.map(o=>{let i=o(e,r);if(i instanceof Promise)throw new Error("Use runValidatorsAsync for async validators");return i});return R(n)}async function N(t,e,r){let n=await Promise.all(t.map(o=>o(e,r)));return R(n)}function $(t={}){return {fieldId:t.fieldId,formId:t.formId,stepId:t.stepId,workflowId:t.workflowId,allFormData:t.allFormData||{},stepData:t.stepData||{},workflowData:t.workflowData||{}}}function S(t="This field is required"){return e=>e==null||e===""||Array.isArray(e)&&e.length===0?u(t,"REQUIRED"):d()}function L(t,e){return r=>!r||r.length<t?u(e||`Must be at least ${t} characters long`,"MIN_LENGTH",`length.${t}`):d()}function D(t,e){return r=>r&&r.length>t?u(e||`Must be no more than ${t} characters long`,"MAX_LENGTH",`length.${t}`):d()}function W(t,e){return r=>r&&!t.test(r)?u(e||"Invalid format","PATTERN_MISMATCH",`pattern.${t.source}`):d()}function q(t="Please enter a valid email address"){let e=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;return r=>r&&!e.test(r)?u(t,"INVALID_EMAIL"):d()}function _(t="Please enter a valid URL"){let e=/^https?:\/\/(?:[-\w.])+(?:\:[0-9]+)?(?:\/(?:[\w/_.])*(?:\?(?:[\w&=%.])*)?(?:\#(?:[\w.])*)?)?$/;return r=>r&&!e.test(r)?u(t,"INVALID_URL"):d()}function U(t="Must be a valid number"){return e=>{let r=typeof e=="string"?Number.parseFloat(e):e;return Number.isNaN(r)||!Number.isFinite(r)?u(t,"INVALID_NUMBER"):d()}}function z(t,e){return r=>{let n=typeof r=="string"?Number.parseFloat(r):r;return !Number.isNaN(n)&&n<t?u(e||`Must be at least ${t}`,"MIN_VALUE",`min.${t}`):d()}}function K(t,e){return r=>{let n=typeof r=="string"?Number.parseFloat(r):r;return !Number.isNaN(n)&&n>t?u(e||`Must be no more than ${t}`,"MAX_VALUE",`max.${t}`):d()}}function j(t,e,r){return (n,o)=>t(n,o)?d():u(e,r||"CUSTOM_VALIDATION_FAILED")}function Q(t,e){return (r,n)=>{let o=n.allFormData?.[t];return r!==o?u(e||"Fields must match","FIELD_MISMATCH",`match.${t}`):d()}}function H(t,e){return (r,n)=>t(r,n)?e(r,n):d()}function Z(t,e,r){return async(n,o)=>{try{return await t(n,o)?d():u(e,r||"ASYNC_VALIDATION_FAILED")}catch(i){return u(i instanceof Error?i.message:"Async validation error","ASYNC_ERROR")}}}var J=0,M=()=>`event_${Date.now()}_${++J}`,G=()=>`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,w=class{constructor(e,r){this.adapters=[];this.eventBuffer=[];this.config={bufferSize:100,flushInterval:5e3,sampleRate:1,enablePerformanceTracking:true,enableErrorTracking:true,enableMemoryTracking:false,...e},this.context={sessionId:G(),environment:"production",userAgent:typeof window<"u"?window.navigator?.userAgent:void 0,url:typeof window<"u"?window.location?.href:void 0,...r},this.profiler=new T,this.config.enabled&&this.startFlushTimer();}addAdapter(e){this.adapters.push(e);}removeAdapter(e){this.adapters=this.adapters.filter(r=>r.name!==e);}track(e,r,n,o,i="low"){if(!this.config.enabled||Math.random()>(this.config.sampleRate||1))return;let s={id:M(),type:e,timestamp:Date.now(),source:r,data:{...n,context:this.context},metrics:o,severity:i};if(o&&this.config.performanceThresholds&&this.checkPerformanceThresholds(s,o),this.eventBuffer.push(s),this.config.onEvent)try{this.config.onEvent(s);}catch(a){console.error("Error in monitoring event callback:",a);}this.eventBuffer.length>=(this.config.bufferSize||100)&&this.flush();}trackError(e,r,n){this.track("error",r,{message:e.message,name:e.name,stack:e.stack,context:n},void 0,"high");}getProfiler(){return this.profiler}updateContext(e){this.context={...this.context,...e};}async flush(){if(this.eventBuffer.length===0)return;let e=[...this.eventBuffer];if(this.eventBuffer=[],this.config.onBatch)try{this.config.onBatch(e);}catch(r){console.error("Error in monitoring batch callback:",r);}await Promise.all(this.adapters.map(async r=>{try{await r.send(e);}catch(n){console.error(`Error sending events to adapter ${r.name}:`,n),this.config.onError&&this.config.onError(n);}}));}async destroy(){this.flushTimer&&clearInterval(this.flushTimer),await this.flush(),await Promise.all(this.adapters.map(async e=>{if(e.flush)try{await e.flush();}catch(r){console.error(`Error flushing adapter ${e.name}:`,r);}}));}startFlushTimer(){this.config.flushInterval&&this.config.flushInterval>0&&(this.flushTimer=setInterval(()=>{this.flush();},this.config.flushInterval));}checkPerformanceThresholds(e,r){let n=this.config.performanceThresholds;n.componentRenderTime&&e.type==="component_render"&&r.duration>n.componentRenderTime&&this.createPerformanceWarning("Component render time exceeded threshold",n.componentRenderTime,r.duration,"Consider memoizing component or optimizing render logic"),n.formValidationTime&&e.type==="form_validation"&&r.duration>n.formValidationTime&&this.createPerformanceWarning("Form validation time exceeded threshold",n.formValidationTime,r.duration,"Consider debouncing validation or optimizing validators"),n.workflowNavigationTime&&e.type==="workflow_navigation"&&r.duration>n.workflowNavigationTime&&this.createPerformanceWarning("Workflow navigation time exceeded threshold",n.workflowNavigationTime,r.duration,"Consider optimizing step transitions or condition evaluation"),n.memoryUsage&&r.memoryUsage&&r.memoryUsage>n.memoryUsage&&this.createPerformanceWarning("Memory usage exceeded threshold",n.memoryUsage,r.memoryUsage,"Check for memory leaks or optimize data structures"),n.reRenderCount&&r.reRenderCount&&r.reRenderCount>n.reRenderCount&&this.createPerformanceWarning("Component re-render count exceeded threshold",n.reRenderCount,r.reRenderCount,"Consider using React.memo or optimizing dependencies");}createPerformanceWarning(e,r,n,o){let i={id:M(),type:"performance_warning",timestamp:Date.now(),source:"rilay_monitor",data:{message:e,context:this.context},threshold:r,actualValue:n,recommendation:o,severity:"medium"};if(this.eventBuffer.push(i),this.config.onEvent)try{this.config.onEvent(i);}catch(s){console.error("Error in performance warning callback:",s);}}},T=class{constructor(){this.metrics=new Map;this.startTimes=new Map;}start(e,r={}){this.startTimes.set(e,performance.now()),this.metrics.set(e,{timestamp:Date.now(),duration:0,renderCount:r.renderCount||0,reRenderCount:r.reRenderCount||0,memoryUsage:this.getMemoryUsage()});}end(e){let r=this.startTimes.get(e);if(!r)return null;let n=performance.now()-r,o=this.metrics.get(e);if(!o)return null;let i={...o,duration:n,memoryUsage:this.getMemoryUsage()};return this.metrics.set(e,i),this.startTimes.delete(e),i}mark(e){typeof performance<"u"&&performance.mark&&performance.mark(e);}measure(e,r,n){if(typeof performance<"u"&&performance.measure){performance.measure(e,r,n);let o=performance.getEntriesByName(e,"measure");return o.length>0?o[o.length-1].duration:0}return 0}getMetrics(e){return this.metrics.get(e)||null}getAllMetrics(){let e={};return this.metrics.forEach((r,n)=>{e[n]=r;}),e}clear(e){e?(this.metrics.delete(e),this.startTimes.delete(e)):(this.metrics.clear(),this.startTimes.clear());}getMemoryUsage(){if(typeof performance<"u"&&performance.memory)return performance.memory.usedJSHeapSize}},g=null;function he(t,e){return g&&g.destroy(),g=new w(t,e),g}function ye(){return g}async function Ce(){g&&(await g.destroy(),g=null);}var b=class{constructor(e="info"){this.name="console";this.logLevel=e;}async send(e){for(let r of e)this.logEvent(r);}logEvent(e){let r={id:e.id,type:e.type,timestamp:new Date(e.timestamp).toISOString(),source:e.source,severity:e.severity,data:e.data,metrics:e.metrics};switch(e.severity){case "critical":case "high":this.shouldLog("error")&&console.error(`[Rilay Monitor] ${e.type}:`,r);break;case "medium":this.shouldLog("warn")&&console.warn(`[Rilay Monitor] ${e.type}:`,r);break;default:this.shouldLog("info")&&console.info(`[Rilay Monitor] ${e.type}:`,r);break}if(e.type==="performance_warning"&&this.shouldLog("warn")){let n=e;console.warn(`[Rilay Performance Warning] ${n.data.message}`,{threshold:n.threshold,actual:n.actualValue,recommendation:n.recommendation});}}shouldLog(e){let r=["debug","info","warn","error"],n=r.indexOf(this.logLevel);return r.indexOf(e)>=n}},A=class{constructor(e){this.name="remote";this.eventQueue=[];this.isProcessing=false;this.endpoint=e.endpoint,this.apiKey=e.apiKey,this.headers={"Content-Type":"application/json",...e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{},...e.headers},this.batchSize=e.batchSize||50,this.retryAttempts=e.retryAttempts||3;}async send(e){this.eventQueue.push(...e),this.isProcessing||await this.processQueue();}async flush(){await this.processQueue();}configure(e){e.headers&&Object.assign(this.headers,e.headers);}async processQueue(){if(!(this.isProcessing||this.eventQueue.length===0)){this.isProcessing=true;try{for(;this.eventQueue.length>0;){let e=this.eventQueue.splice(0,this.batchSize);await this.sendBatch(e);}}finally{this.isProcessing=false;}}}async sendBatch(e){let r={events:e,timestamp:Date.now(),source:"rilay-monitoring"},n=null;for(let o=1;o<=this.retryAttempts;o++)try{let i=await fetch(this.endpoint,{method:"POST",headers:this.headers,body:JSON.stringify(r)});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);return}catch(i){if(n=i,i instanceof Error&&i.message.includes("HTTP 4"))break;o<this.retryAttempts&&await this.delay(2**o*1e3);}throw console.error("Failed to send monitoring events to remote endpoint:",n),n}delay(e){return new Promise(r=>setTimeout(r,e))}},B=class{constructor(e=1e3){this.name="localStorage";this.storageKey="rilay_monitoring_events";this.maxEvents=e;}async send(e){try{let o=[...this.getStoredEvents(),...e].slice(-this.maxEvents);localStorage.setItem(this.storageKey,JSON.stringify(o));}catch(r){console.error("Failed to store monitoring events:",r);}}async flush(){}getStoredEvents(){try{let e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):[]}catch(e){return console.error("Failed to retrieve stored monitoring events:",e),[]}}clearStoredEvents(){localStorage.removeItem(this.storageKey);}getEventCount(){return this.getStoredEvents().length}},F=class{constructor(){this.name="development";this.console=new b("debug");}async send(e){await this.console.send(e),this.logPerformanceSummary(e),this.logErrorSummary(e);}logPerformanceSummary(e){let r=e.filter(s=>s.metrics);if(r.length===0)return;console.group("[Rilay Performance Summary]");let n=r.reduce((s,a)=>s+(a.metrics?.duration||0),0)/r.length,o=Math.max(...r.map(s=>s.metrics?.duration||0));console.info(`Average duration: ${n.toFixed(2)}ms`),console.info(`Max duration: ${o.toFixed(2)}ms`);let i={};for(let s of r)i[s.type]||(i[s.type]=[]),i[s.type].push(s);for(let[s,a]of Object.entries(i)){let f=a.reduce((l,h)=>l+(h.metrics?.duration||0),0)/a.length;console.info(`${s}: ${f.toFixed(2)}ms avg (${a.length} events)`);}console.groupEnd();}logErrorSummary(e){let r=e.filter(o=>o.type==="error");if(r.length===0)return;console.group("[Rilay Error Summary]"),console.error(`${r.length} errors detected`);let n={};for(let o of r)n[o.source]=(n[o.source]||0)+1;for(let[o,i]of Object.entries(n))console.error(`${o}: ${i} errors`);console.groupEnd();}};var x=class{constructor(e){this.field=e,this.operator="exists",this.conditions=[];}equals(e){return this.operator="equals",this.value=e,this}notEquals(e){return this.operator="notEquals",this.value=e,this}greaterThan(e){return this.operator="greaterThan",this.value=e,this}lessThan(e){return this.operator="lessThan",this.value=e,this}greaterThanOrEqual(e){return this.operator="greaterThanOrEqual",this.value=e,this}lessThanOrEqual(e){return this.operator="lessThanOrEqual",this.value=e,this}contains(e){return this.operator="contains",this.value=e,this}notContains(e){return this.operator="notContains",this.value=e,this}in(e){return this.operator="in",this.value=e,this}notIn(e){return this.operator="notIn",this.value=e,this}matches(e){return this.operator="matches",this.value=e instanceof RegExp?e.source:e,this}exists(){return this.operator="exists",this.value=void 0,this}notExists(){return this.operator="notExists",this.value=void 0,this}and(e){let r="build"in e?e.build():e,n={field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator};return this.field="",this.operator="exists",this.value=void 0,this.conditions=[n,r],this.logicalOperator="and",this}or(e){let r="build"in e?e.build():e,n={field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator};return this.field="",this.operator="exists",this.value=void 0,this.conditions=[n,r],this.logicalOperator="or",this}build(){return {field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator}}evaluate(e){return I(this,e)}};function we(t){return new x(t)}function I(t,e){if(t.conditions&&t.conditions.length>0){let n=t.conditions.map(o=>I(o,e));return t.logicalOperator==="or"?n.some(o=>o):n.every(o=>o)}let r=X(e,t.field);switch(t.operator){case "equals":return r===t.value;case "notEquals":return r!==t.value;case "greaterThan":return typeof r=="number"&&typeof t.value=="number"&&r>t.value;case "lessThan":return typeof r=="number"&&typeof t.value=="number"&&r<t.value;case "greaterThanOrEqual":return typeof r=="number"&&typeof t.value=="number"&&r>=t.value;case "lessThanOrEqual":return typeof r=="number"&&typeof t.value=="number"&&r<=t.value;case "contains":return typeof r=="string"&&typeof t.value=="string"||Array.isArray(r)?r.includes(t.value):false;case "notContains":return typeof r=="string"&&typeof t.value=="string"||Array.isArray(r)?!r.includes(t.value):false;case "in":return Array.isArray(t.value)&&t.value.includes(r);case "notIn":return Array.isArray(t.value)&&!t.value.includes(r);case "matches":return typeof r!="string"||typeof t.value!="string"?false:new RegExp(t.value).test(r);case "exists":return r!=null;case "notExists":return r==null;default:return false}}function X(t,e){let r=e.split("."),n=t;for(let o of r)if(n&&typeof n=="object"&&o in n)n=n[o];else return;return n}export{re as ComponentRendererWrapper,b as ConsoleAdapter,F as DevelopmentAdapter,V as IdGenerator,B as LocalStorageAdapter,A as RemoteAdapter,w as RilayMonitor,Z as async,R as combineValidationResults,se as configureObject,$ as createValidationContext,y as createValidationResult,j as custom,k as deepClone,Ce as destroyGlobalMonitoring,q as email,P as ensureUnique,I as evaluateCondition,ye as getGlobalMonitor,he as initializeMonitoring,Q as matchField,K as max,D as maxLength,ne as mergeInto,z as min,L as minLength,ie as normalizeToArray,U as number,W as pattern,S as required,E as resolveRendererChildren,v as ril,O as runValidators,N as runValidatorsAsync,_ as url,oe as validateRequired,H as validateWhen,we as when};
1
+ function x(n,e){return typeof n=="function"?n(e):n}function le({children:n,renderAs:e,renderer:r,name:t,props:o}){if(e==="children"||e===true){if(typeof n!="function")throw new Error(`When renderAs="children" is used, children must be a function that returns React elements for ${t}`);return n(o)}if(!r)throw new Error(`No renderer provided for ${t}`);if(typeof r!="function")throw new Error(`Renderer must be a function for ${t}`);let s={...o,children:x(n,o)};return r(s)}function ce(n,e){return {...n,...e}}function k(n,e){let r=n.filter((t,o)=>n.indexOf(t)!==o);if(r.length>0)throw new Error(`Duplicate ${e} IDs: ${r.join(", ")}`)}function fe(n,e,r){if(n.filter(o=>e.some(i=>!o[i])).length>0)throw new Error(`Missing required fields in ${r}: ${e.join(", ")}`)}var E=class{constructor(){this.counters=new Map;}next(e){let r=this.counters.get(e)||0;return this.counters.set(e,r+1),`${e}-${r+1}`}reset(e){e?this.counters.delete(e):this.counters.clear();}};function me(n){return Array.isArray(n)?n:[n]}function S(n){if(n===null||typeof n!="object")return n;if(n instanceof Date)return new Date(n.getTime());if(Array.isArray(n))return n.map(r=>S(r));let e={};for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=S(n[r]));return e}function pe(n,e,r){let t={...n};for(let o in e)r&&!r.includes(o)||e[o]!==void 0&&(t[o]=e[o]);return t}var h=class extends Error{constructor(r,t,o){super(r);this.code=t;this.meta=o;this.name="RilayError";}},p=class extends h{constructor(e,r){super(e,"VALIDATION_ERROR",r),this.name="ValidationError";}};function m(n,e){let r={...n};for(let t in e){let o=e[t],i=r[t];o&&typeof o=="object"&&!Array.isArray(o)&&i&&typeof i=="object"&&!Array.isArray(i)?r[t]=m(i,o):r[t]=o;}return r}var y=class n{constructor(){this.components=new Map;this.formRenderConfig={};this.workflowRenderConfig={};}static create(){return new n}addComponent(e,r){let t={id:e,type:e,...r},o=new n;return o.components=new Map(this.components),o.formRenderConfig={...this.formRenderConfig},o.workflowRenderConfig={...this.workflowRenderConfig},o.components.set(e,t),o}configure(e){let r=["rowRenderer","bodyRenderer","submitButtonRenderer","fieldRenderer"],t=["stepperRenderer","nextButtonRenderer","previousButtonRenderer","skipButtonRenderer"],o={},i={};for(let[a,u]of Object.entries(e))r.includes(a)?o[a]=u:t.includes(a)&&(i[a]=u);let s=new n;return s.components=new Map(this.components),s.formRenderConfig=m(this.formRenderConfig,o),s.workflowRenderConfig=m(this.workflowRenderConfig,i),s}getFormRenderConfig(){return {...this.formRenderConfig}}getWorkflowRenderConfig(){return {...this.workflowRenderConfig}}getComponent(e){return this.components.get(e)}getAllComponents(){return Array.from(this.components.values())}hasComponent(e){return this.components.has(e)}removeComponent(e){let r=new n;return r.components=new Map(this.components),r.formRenderConfig={...this.formRenderConfig},r.workflowRenderConfig={...this.workflowRenderConfig},r.components.delete(e),r}clear(){let e=new n;return e.formRenderConfig={...this.formRenderConfig},e.workflowRenderConfig={...this.workflowRenderConfig},e}clone(){let e=new n;return e.components=new Map(this.components),e.formRenderConfig=m({},this.formRenderConfig),e.workflowRenderConfig=m({},this.workflowRenderConfig),e}getStats(){let e=Array.from(this.components.values());return {total:e.length,byType:e.reduce((r,t)=>(r[t.type]=(r[t.type]||0)+1,r),{}),hasCustomRenderers:{row:!!this.formRenderConfig.rowRenderer,body:!!this.formRenderConfig.bodyRenderer,submitButton:!!this.formRenderConfig.submitButtonRenderer,field:!!this.formRenderConfig.fieldRenderer,stepper:!!this.workflowRenderConfig.stepperRenderer,workflowNextButton:!!this.workflowRenderConfig.nextButtonRenderer,workflowPreviousButton:!!this.workflowRenderConfig.previousButtonRenderer,workflowSkipButton:!!this.workflowRenderConfig.skipButtonRenderer}}}validate(){let e=[],r=Array.from(this.components.values()),t=r.map(l=>l.id);try{k(t,"component");}catch(l){e.push(l instanceof Error?l.message:String(l));}let o=r.filter(l=>!l.renderer);o.length>0&&e.push(`Components without renderer: ${o.map(l=>l.id).join(", ")}`);let i=Object.keys(this.formRenderConfig),s=Object.keys(this.workflowRenderConfig),a=["rowRenderer","bodyRenderer","submitButtonRenderer","fieldRenderer"],u=["stepperRenderer","nextButtonRenderer","previousButtonRenderer","skipButtonRenderer"],d=i.filter(l=>!a.includes(l)),g=s.filter(l=>!u.includes(l));return d.length>0&&e.push(`Invalid form renderer keys: ${d.join(", ")}`),g.length>0&&e.push(`Invalid workflow renderer keys: ${g.join(", ")}`),e}async validateAsync(){let e=[],r=[],t=Array.from(this.components.values());try{let o=this.validate();e.push(...o);let i=t.map(async d=>d.renderer&&typeof d.renderer!="function"&&typeof d.renderer!="object"?`Component "${d.id}" has invalid renderer type: ${typeof d.renderer}`:((d.id.includes(" ")||d.id.includes("-"))&&r.push(`Component "${d.id}" uses non-standard naming (contains spaces or dashes)`),null)),a=(await Promise.all(i)).filter(d=>d!==null);e.push(...a),t.length>50&&r.push("Large number of components detected. Consider splitting configuration.");let u={isValid:e.length===0,errors:e,warnings:r.length>0?r:void 0};if(!u.isValid)throw new p("Ril configuration validation failed",{errors:e,warnings:r,componentCount:t.length});return u}catch(o){throw o instanceof p?o:new p("Unexpected error during async validation",{originalError:o instanceof Error?o.message:String(o)})}}};function v(n,e=[]){return {isValid:n,errors:[...e]}}function I(){return v(true,[])}function O(n,e,r){return v(false,[{message:n,code:e,path:r}])}function N(n={}){return {fieldId:n.fieldId,formId:n.formId,stepId:n.stepId,workflowId:n.workflowId,allFormData:n.allFormData||{},stepData:n.stepData||{},workflowData:n.workflowData||{}}}function $(n="This field is required"){return {"~standard":{version:1,vendor:"rilaykit",validate:e=>e===""||e==null||Array.isArray(e)&&e.length===0||typeof e=="object"&&Object.keys(e).length===0?{issues:[{message:n,path:void 0}]}:{value:e}}}}function F(n="Please enter a valid email address"){let e=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return {"~standard":{version:1,vendor:"rilaykit",validate:r=>typeof r!="string"?{issues:[{message:"Email must be a string"}]}:e.test(r)?{value:r}:{issues:[{message:n}]},types:{input:"",output:""}}}}function W(n="Please enter a valid URL"){return {"~standard":{version:1,vendor:"rilaykit",validate:e=>{if(typeof e!="string")return {issues:[{message:"URL must be a string"}]};try{return new URL(e),{value:e}}catch{return {issues:[{message:n}]}}},types:{input:"",output:""}}}}function L(n,e){let r=`Must be at least ${n} characters long`;return {"~standard":{version:1,vendor:"rilaykit",validate:t=>typeof t!="string"?{issues:[{message:"Value must be a string"}]}:t.length>=n?{value:t}:{issues:[{message:e||r}]},types:{input:"",output:""}}}}function D(n,e){let r=`Must be no more than ${n} characters long`;return {"~standard":{version:1,vendor:"rilaykit",validate:t=>typeof t!="string"?{issues:[{message:"Value must be a string"}]}:t.length<=n?{value:t}:{issues:[{message:e||r}]},types:{input:"",output:""}}}}function q(n,e="Value does not match required pattern"){return {"~standard":{version:1,vendor:"rilaykit",validate:r=>typeof r!="string"?{issues:[{message:"Value must be a string"}]}:n.test(r)?{value:r}:{issues:[{message:e}]},types:{input:"",output:""}}}}function U(n="Must be a valid number"){return {"~standard":{version:1,vendor:"rilaykit",validate:e=>{let r=typeof e=="string"?Number(e):e;return typeof r!="number"||Number.isNaN(r)?{issues:[{message:n}]}:{value:r}},types:{input:0,output:0}}}}function K(n,e){let r=`Must be at least ${n}`;return {"~standard":{version:1,vendor:"rilaykit",validate:t=>{let o=typeof t=="string"?Number(t):t;return typeof o!="number"||Number.isNaN(o)?{issues:[{message:"Value must be a number"}]}:o>=n?{value:o}:{issues:[{message:e||r}]}},types:{input:0,output:0}}}}function z(n,e){let r=`Must be no more than ${n}`;return {"~standard":{version:1,vendor:"rilaykit",validate:t=>{let o=typeof t=="string"?Number(t):t;return typeof o!="number"||Number.isNaN(o)?{issues:[{message:"Value must be a number"}]}:o<=n?{value:o}:{issues:[{message:e||r}]}},types:{input:0,output:0}}}}function _(n,e="Validation failed"){return {"~standard":{version:1,vendor:"rilaykit",validate:r=>{try{return n(r)?{value:r}:{issues:[{message:e}]}}catch(t){return {issues:[{message:t instanceof Error?t.message:e}]}}}}}}function j(n,e="Async validation failed"){return {"~standard":{version:1,vendor:"rilaykit",validate:async r=>{try{return await n(r)?{value:r}:{issues:[{message:e}]}}catch(t){return {issues:[{message:t instanceof Error?t.message:e}]}}}}}}function Q(...n){return {"~standard":{version:1,vendor:"rilaykit",validate:async e=>{let r=[],t=e;for(let o of n){let i=o["~standard"].validate(e);i instanceof Promise&&(i=await i),i.issues?r.push(...i.issues):t=i.value;}return r.length>0?{issues:r}:{value:t}}}}}function c(n){return n!=null&&typeof n=="object"&&"~standard"in n&&n["~standard"]!==null&&typeof n["~standard"]=="object"&&n["~standard"].version===1&&typeof n["~standard"].vendor=="string"&&typeof n["~standard"].validate=="function"}async function C(n,e){if(!c(n))throw new Error("Invalid Standard Schema: missing ~standard property or invalid structure");try{let r=n["~standard"].validate(e);return r instanceof Promise&&(r=await r),r.issues?{isValid:!1,errors:r.issues.map(o=>({message:o.message,code:"VALIDATION_ERROR",path:H(o.path)}))}:{isValid:!0,errors:[],value:r.value}}catch(r){return {isValid:false,errors:[{message:r instanceof Error?r.message:"Validation failed",code:"VALIDATION_ERROR"}]}}}function H(n){if(!(!n||n.length===0))return n.map(e=>typeof e=="object"&&"key"in e?String(e.key):String(e)).join(".")}function J(n){if(!c(n))throw new Error("Invalid Standard Schema");return {vendor:n["~standard"].vendor,version:n["~standard"].version,hasTypes:!!n["~standard"].types}}function G(n){return c(n)&&!!n["~standard"].types}async function X(n,e,r){if(!n.validate)return {isValid:true,errors:[]};let t=Array.isArray(n.validate)?n.validate:[n.validate],o=[];for(let i of t){if(!c(i)){o.push({message:"Invalid validation rule: must implement Standard Schema interface",code:"INVALID_SCHEMA"});continue}try{let s=await C(i,e);s.isValid||o.push(...s.errors);}catch(s){o.push({message:s instanceof Error?s.message:"Validation error",code:"VALIDATION_ERROR"});}}return {isValid:o.length===0,errors:o}}async function Y(n,e,r){if(!n.validate)return {isValid:true,errors:[]};let t=Array.isArray(n.validate)?n.validate:[n.validate],o=[];for(let i of t){if(!c(i)){o.push({message:"Invalid validation rule: must implement Standard Schema interface",code:"INVALID_SCHEMA"});continue}try{let s=await C(i,e);s.isValid||o.push(...s.errors);}catch(s){o.push({message:s instanceof Error?s.message:"Form validation error",code:"FORM_VALIDATION_ERROR"});}}return {isValid:o.length===0,errors:o}}function Z(n){return !!n.validate}function ee(...n){return {"~standard":{version:1,vendor:"rilaykit-combined",validate:async e=>{let r=[],t=e;for(let o of n){let i=o["~standard"].validate(e);i instanceof Promise&&(i=await i),i.issues?r.push(...i.issues):t=i.value;}return r.length>0?{issues:r}:{value:t}}}}}function re(n,e="rilaykit"){return {"~standard":{version:1,vendor:e,validate:async r=>{try{let t=await n(r,{});return t.isValid?{value:r}:{issues:t.errors.map(i=>({message:i.message,path:i.path?[i.path]:void 0}))}}catch(t){return {issues:[{message:t instanceof Error?t.message:"Validation failed"}]}}}}}}function ne(n){return Array.isArray(n)?n.every(c):c(n)}function te(n){return n?Array.isArray(n)?n:[n]:[]}var oe=0,V=()=>`event_${Date.now()}_${++oe}`,ie=()=>`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,w=class{constructor(e,r){this.adapters=[];this.eventBuffer=[];this.config={bufferSize:100,flushInterval:5e3,sampleRate:1,enablePerformanceTracking:true,enableErrorTracking:true,enableMemoryTracking:false,...e},this.context={sessionId:ie(),environment:"production",userAgent:typeof window<"u"?window.navigator?.userAgent:void 0,url:typeof window<"u"?window.location?.href:void 0,...r},this.profiler=new R,this.config.enabled&&this.startFlushTimer();}addAdapter(e){this.adapters.push(e);}removeAdapter(e){this.adapters=this.adapters.filter(r=>r.name!==e);}track(e,r,t,o,i="low"){if(!this.config.enabled||Math.random()>(this.config.sampleRate||1))return;let s={id:V(),type:e,timestamp:Date.now(),source:r,data:{...t,context:this.context},metrics:o,severity:i};if(o&&this.config.performanceThresholds&&this.checkPerformanceThresholds(s,o),this.eventBuffer.push(s),this.config.onEvent)try{this.config.onEvent(s);}catch(a){console.error("Error in monitoring event callback:",a);}this.eventBuffer.length>=(this.config.bufferSize||100)&&this.flush();}trackError(e,r,t){this.track("error",r,{message:e.message,name:e.name,stack:e.stack,context:t},void 0,"high");}getProfiler(){return this.profiler}updateContext(e){this.context={...this.context,...e};}async flush(){if(this.eventBuffer.length===0)return;let e=[...this.eventBuffer];if(this.eventBuffer=[],this.config.onBatch)try{this.config.onBatch(e);}catch(r){console.error("Error in monitoring batch callback:",r);}await Promise.all(this.adapters.map(async r=>{try{await r.send(e);}catch(t){console.error(`Error sending events to adapter ${r.name}:`,t),this.config.onError&&this.config.onError(t);}}));}async destroy(){this.flushTimer&&clearInterval(this.flushTimer),await this.flush(),await Promise.all(this.adapters.map(async e=>{if(e.flush)try{await e.flush();}catch(r){console.error(`Error flushing adapter ${e.name}:`,r);}}));}startFlushTimer(){this.config.flushInterval&&this.config.flushInterval>0&&(this.flushTimer=setInterval(()=>{this.flush();},this.config.flushInterval));}checkPerformanceThresholds(e,r){let t=this.config.performanceThresholds;t.componentRenderTime&&e.type==="component_render"&&r.duration>t.componentRenderTime&&this.createPerformanceWarning("Component render time exceeded threshold",t.componentRenderTime,r.duration,"Consider memoizing component or optimizing render logic"),t.formValidationTime&&e.type==="form_validation"&&r.duration>t.formValidationTime&&this.createPerformanceWarning("Form validation time exceeded threshold",t.formValidationTime,r.duration,"Consider debouncing validation or optimizing validators"),t.workflowNavigationTime&&e.type==="workflow_navigation"&&r.duration>t.workflowNavigationTime&&this.createPerformanceWarning("Workflow navigation time exceeded threshold",t.workflowNavigationTime,r.duration,"Consider optimizing step transitions or condition evaluation"),t.memoryUsage&&r.memoryUsage&&r.memoryUsage>t.memoryUsage&&this.createPerformanceWarning("Memory usage exceeded threshold",t.memoryUsage,r.memoryUsage,"Check for memory leaks or optimize data structures"),t.reRenderCount&&r.reRenderCount&&r.reRenderCount>t.reRenderCount&&this.createPerformanceWarning("Component re-render count exceeded threshold",t.reRenderCount,r.reRenderCount,"Consider using React.memo or optimizing dependencies");}createPerformanceWarning(e,r,t,o){let i={id:V(),type:"performance_warning",timestamp:Date.now(),source:"rilay_monitor",data:{message:e,context:this.context},threshold:r,actualValue:t,recommendation:o,severity:"medium"};if(this.eventBuffer.push(i),this.config.onEvent)try{this.config.onEvent(i);}catch(s){console.error("Error in performance warning callback:",s);}}},R=class{constructor(){this.metrics=new Map;this.startTimes=new Map;}start(e,r={}){this.startTimes.set(e,performance.now()),this.metrics.set(e,{timestamp:Date.now(),duration:0,renderCount:r.renderCount||0,reRenderCount:r.reRenderCount||0,memoryUsage:this.getMemoryUsage()});}end(e){let r=this.startTimes.get(e);if(!r)return null;let t=performance.now()-r,o=this.metrics.get(e);if(!o)return null;let i={...o,duration:t,memoryUsage:this.getMemoryUsage()};return this.metrics.set(e,i),this.startTimes.delete(e),i}mark(e){typeof performance<"u"&&performance.mark&&performance.mark(e);}measure(e,r,t){if(typeof performance<"u"&&performance.measure){performance.measure(e,r,t);let o=performance.getEntriesByName(e,"measure");return o.length>0?o[o.length-1].duration:0}return 0}getMetrics(e){return this.metrics.get(e)||null}getAllMetrics(){let e={};return this.metrics.forEach((r,t)=>{e[t]=r;}),e}clear(e){e?(this.metrics.delete(e),this.startTimes.delete(e)):(this.metrics.clear(),this.startTimes.clear());}getMemoryUsage(){if(typeof performance<"u"&&performance.memory)return performance.memory.usedJSHeapSize}},f=null;function Se(n,e){return f&&f.destroy(),f=new w(n,e),f}function ke(){return f}async function Ve(){f&&(await f.destroy(),f=null);}var b=class{constructor(e="info"){this.name="console";this.logLevel=e;}async send(e){for(let r of e)this.logEvent(r);}logEvent(e){let r={id:e.id,type:e.type,timestamp:new Date(e.timestamp).toISOString(),source:e.source,severity:e.severity,data:e.data,metrics:e.metrics};switch(e.severity){case "critical":case "high":this.shouldLog("error")&&console.error(`[Rilay Monitor] ${e.type}:`,r);break;case "medium":this.shouldLog("warn")&&console.warn(`[Rilay Monitor] ${e.type}:`,r);break;default:this.shouldLog("info")&&console.info(`[Rilay Monitor] ${e.type}:`,r);break}if(e.type==="performance_warning"&&this.shouldLog("warn")){let t=e;console.warn(`[Rilay Performance Warning] ${t.data.message}`,{threshold:t.threshold,actual:t.actualValue,recommendation:t.recommendation});}}shouldLog(e){let r=["debug","info","warn","error"],t=r.indexOf(this.logLevel);return r.indexOf(e)>=t}},P=class{constructor(e){this.name="remote";this.eventQueue=[];this.isProcessing=false;this.endpoint=e.endpoint,this.apiKey=e.apiKey,this.headers={"Content-Type":"application/json",...e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{},...e.headers},this.batchSize=e.batchSize||50,this.retryAttempts=e.retryAttempts||3;}async send(e){this.eventQueue.push(...e),this.isProcessing||await this.processQueue();}async flush(){await this.processQueue();}configure(e){e.headers&&Object.assign(this.headers,e.headers);}async processQueue(){if(!(this.isProcessing||this.eventQueue.length===0)){this.isProcessing=true;try{for(;this.eventQueue.length>0;){let e=this.eventQueue.splice(0,this.batchSize);await this.sendBatch(e);}}finally{this.isProcessing=false;}}}async sendBatch(e){let r={events:e,timestamp:Date.now(),source:"rilay-monitoring"},t=null;for(let o=1;o<=this.retryAttempts;o++)try{let i=await fetch(this.endpoint,{method:"POST",headers:this.headers,body:JSON.stringify(r)});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);return}catch(i){if(t=i,i instanceof Error&&i.message.includes("HTTP 4"))break;o<this.retryAttempts&&await this.delay(2**o*1e3);}throw console.error("Failed to send monitoring events to remote endpoint:",t),t}delay(e){return new Promise(r=>setTimeout(r,e))}},M=class{constructor(e=1e3){this.name="localStorage";this.storageKey="rilay_monitoring_events";this.maxEvents=e;}async send(e){try{let o=[...this.getStoredEvents(),...e].slice(-this.maxEvents);localStorage.setItem(this.storageKey,JSON.stringify(o));}catch(r){console.error("Failed to store monitoring events:",r);}}async flush(){}getStoredEvents(){try{let e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):[]}catch(e){return console.error("Failed to retrieve stored monitoring events:",e),[]}}clearStoredEvents(){localStorage.removeItem(this.storageKey);}getEventCount(){return this.getStoredEvents().length}},B=class{constructor(){this.name="development";this.console=new b("debug");}async send(e){await this.console.send(e),this.logPerformanceSummary(e),this.logErrorSummary(e);}logPerformanceSummary(e){let r=e.filter(s=>s.metrics);if(r.length===0)return;console.group("[Rilay Performance Summary]");let t=r.reduce((s,a)=>s+(a.metrics?.duration||0),0)/r.length,o=Math.max(...r.map(s=>s.metrics?.duration||0));console.info(`Average duration: ${t.toFixed(2)}ms`),console.info(`Max duration: ${o.toFixed(2)}ms`);let i={};for(let s of r)i[s.type]||(i[s.type]=[]),i[s.type].push(s);for(let[s,a]of Object.entries(i)){let u=a.reduce((d,g)=>d+(g.metrics?.duration||0),0)/a.length;console.info(`${s}: ${u.toFixed(2)}ms avg (${a.length} events)`);}console.groupEnd();}logErrorSummary(e){let r=e.filter(o=>o.type==="error");if(r.length===0)return;console.group("[Rilay Error Summary]"),console.error(`${r.length} errors detected`);let t={};for(let o of r)t[o.source]=(t[o.source]||0)+1;for(let[o,i]of Object.entries(t))console.error(`${o}: ${i} errors`);console.groupEnd();}};var T=class{constructor(e){this.field=e,this.operator="exists",this.conditions=[];}equals(e){return this.operator="equals",this.value=e,this}notEquals(e){return this.operator="notEquals",this.value=e,this}greaterThan(e){return this.operator="greaterThan",this.value=e,this}lessThan(e){return this.operator="lessThan",this.value=e,this}greaterThanOrEqual(e){return this.operator="greaterThanOrEqual",this.value=e,this}lessThanOrEqual(e){return this.operator="lessThanOrEqual",this.value=e,this}contains(e){return this.operator="contains",this.value=e,this}notContains(e){return this.operator="notContains",this.value=e,this}in(e){return this.operator="in",this.value=e,this}notIn(e){return this.operator="notIn",this.value=e,this}matches(e){return this.operator="matches",this.value=e instanceof RegExp?e.source:e,this}exists(){return this.operator="exists",this.value=void 0,this}notExists(){return this.operator="notExists",this.value=void 0,this}and(e){let r="build"in e?e.build():e,t={field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator};return this.field="",this.operator="exists",this.value=void 0,this.conditions=[t,r],this.logicalOperator="and",this}or(e){let r="build"in e?e.build():e,t={field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator};return this.field="",this.operator="exists",this.value=void 0,this.conditions=[t,r],this.logicalOperator="or",this}build(){return {field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator}}evaluate(e){return A(this,e)}};function Be(n){return new T(n)}function A(n,e){if(n.conditions&&n.conditions.length>0){let t=n.conditions.map(o=>A(o,e));return n.logicalOperator==="or"?t.some(o=>o):t.every(o=>o)}let r=se(e,n.field);switch(n.operator){case "equals":return r===n.value;case "notEquals":return r!==n.value;case "greaterThan":return typeof r=="number"&&typeof n.value=="number"&&r>n.value;case "lessThan":return typeof r=="number"&&typeof n.value=="number"&&r<n.value;case "greaterThanOrEqual":return typeof r=="number"&&typeof n.value=="number"&&r>=n.value;case "lessThanOrEqual":return typeof r=="number"&&typeof n.value=="number"&&r<=n.value;case "contains":return typeof r=="string"&&typeof n.value=="string"||Array.isArray(r)?r.includes(n.value):false;case "notContains":return typeof r=="string"&&typeof n.value=="string"||Array.isArray(r)?!r.includes(n.value):false;case "in":return Array.isArray(n.value)&&n.value.includes(r);case "notIn":return Array.isArray(n.value)&&!n.value.includes(r);case "matches":return typeof r!="string"||typeof n.value!="string"?false:new RegExp(n.value).test(r);case "exists":return r!=null;case "notExists":return r==null;default:return false}}function se(n,e){let r=e.split("."),t=n;for(let o of r)if(t&&typeof t=="object"&&o in t)t=t[o];else return;return t}export{le as ComponentRendererWrapper,b as ConsoleAdapter,B as DevelopmentAdapter,E as IdGenerator,M as LocalStorageAdapter,P as RemoteAdapter,w as RilayMonitor,j as async,Q as combine,ee as combineSchemas,pe as configureObject,O as createErrorResult,re as createStandardValidator,I as createSuccessResult,N as createValidationContext,v as createValidationResult,_ as custom,S as deepClone,Ve as destroyGlobalMonitoring,F as email,k as ensureUnique,A as evaluateCondition,ke as getGlobalMonitor,J as getSchemaInfo,G as hasSchemaTypes,Z as hasUnifiedValidation,Se as initializeMonitoring,c as isStandardSchema,ne as isValidationRule,z as max,D as maxLength,ce as mergeInto,K as min,L as minLength,me as normalizeToArray,te as normalizeValidationRules,U as number,q as pattern,$ as required,x as resolveRendererChildren,y as ril,W as url,Y as validateFormWithUnifiedConfig,fe as validateRequired,C as validateWithStandardSchema,X as validateWithUnifiedConfig,Be as when};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rilaykit/core",
3
- "version": "10.0.0",
3
+ "version": "11.1.0",
4
4
  "description": "Core types, configurations, and utilities for the RilayKit form library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -44,6 +44,9 @@
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  },
47
+ "dependencies": {
48
+ "@standard-schema/spec": "^1.0.0"
49
+ },
47
50
  "scripts": {
48
51
  "build": "tsup",
49
52
  "dev": "tsup --watch",