import { a as Field } from '../_model-Bp0xf_rL.mjs';
import '@qundus/qstate';
import '@qundus/qstate/addons';

type IsZodObject<T> = {
    _def: {
        typeName: "ZodObject";
    };
    shape: Record<string, unknown>;
    _output: Record<string, unknown>;
};
type FlatObjectKeyValue$1<T, K = ""> = T extends IsZodObject<T> ? K extends `${infer U}.${infer V}` ? U extends keyof T["shape"] ? FlatObjectKeyValue$1<T["shape"][U], V> : never : K extends keyof T["shape"] ? T["shape"][K] : never : T;
type FlatObjectKeys$1<T extends Record<string, unknown>, Key = keyof T> = Key extends string ? T[Key] extends IsZodObject<T[Key]> ? `${Key}.${FlatObjectKeys$1<T[Key]["shape"]>}` : `${Key}` : never;
type FlatObject$1<T> = T extends IsZodObject<T> ? {
    [K in FlatObjectKeys$1<T["shape"]>]: ZodTypeName<FlatObjectKeyValue$1<T, K>>;
} : T;
type SchemaToSetups<Z> = FlatObject$1<Z> extends infer G ? {
    [K in keyof G]: ZodTypeNameToField<G[K]>;
} : never;
type ZodTypeNameToField<T> = T extends "boolean" | "nullable:boolean" ? Field.Setup<"checkbox"> : T extends "string" | "nullable:string" ? Field.Setup<"text"> : T extends "number" | "nullable:number" ? Field.Setup<"number"> : T extends "enum" | "nullable:enum" | "nativeEnum" | "nullable:nativeEnum" ? Field.Setup<"select" | "select.radio"> : T extends "date" | "nullable:date" ? Field.Setup<"date"> : T extends "file" ? Field.Setup<"file"> : Field.Setup;
type SchemaToFieldsExtenders<Z> = FlatObject$1<Z> extends infer G ? {
    [K in keyof G]?: Field.Type | Partial<Omit<Field.Setup, "options">>;
} : never;
/**
 * TODO: finished to merge field types of both SchemaToFields & SchemaToFieldsExtenders
 * to affect the last result of the object
 */
type Options<Z, E extends SchemaToFieldsExtenders<Z>> = {
    override?: E;
    verbose?: boolean;
    unknownsAsText?: boolean;
};
type ZodTypeName<T> = T extends {
    _def: {
        typeName: "ZodString";
    };
} ? "string" : T extends {
    _def: {
        typeName: "ZodNumber";
    };
} ? "number" : T extends {
    _def: {
        typeName: "ZodBoolean";
    };
} ? "boolean" : T extends {
    _def: {
        typeName: "ZodBigInt";
    };
} ? "bigint" : T extends {
    _def: {
        typeName: "ZodDate";
    };
} ? "date" : T extends {
    _def: {
        typeName: "ZodSymbol";
    };
} ? "symbol" : T extends {
    _def: {
        typeName: "ZodUndefined";
    };
} ? "undefined" : T extends {
    _def: {
        typeName: "ZodNull";
    };
} ? "null" : T extends {
    _def: {
        typeName: "ZodVoid";
    };
} ? "void" : T extends {
    _def: {
        typeName: "ZodAny";
    };
} ? "any" : T extends {
    _def: {
        typeName: "ZodUnknown";
    };
} ? "unknown" : T extends {
    _def: {
        typeName: "ZodNever";
    };
} ? "never" : T extends {
    _def: {
        typeName: "ZodNaN";
    };
} ? "nan" : T extends {
    _def: {
        typeName: "ZodLiteral";
        value: infer V;
    };
} ? `literal:${V & (string | number | boolean)}` : T extends {
    _def: {
        typeName: "ZodEnum";
    };
} ? "enum" : T extends {
    _def: {
        typeName: "ZodNativeEnum";
    };
} ? "nativeEnum" : T extends {
    _def: {
        typeName: "ZodArray";
        type: infer E;
    };
} ? `array:${ZodTypeName<E>}` : T extends {
    _def: {
        typeName: "ZodObject";
    };
} ? "object" : T extends {
    _def: {
        typeName: "ZodRecord";
    };
} ? "record" : T extends {
    _def: {
        typeName: "ZodUnion";
        options: infer O;
    };
} ? `union:${O extends any[] ? ZodTypeName<O[number]> : never}` : T extends {
    _def: {
        typeName: "ZodIntersection";
        left: infer L;
        right: infer R;
    };
} ? `intersection:${ZodTypeName<L> & ZodTypeName<R>}` : T extends {
    _def: {
        typeName: "ZodTuple";
        items: infer I;
    };
} ? `tuple:[${I extends any[] ? ZodTypeName<I[number]> : never}]` : T extends {
    _def: {
        typeName: "ZodOptional";
        innerType: infer I;
    };
} ? `optional:${ZodTypeName<I>}` : T extends {
    _def: {
        typeName: "ZodNullable";
        innerType: infer I;
    };
} ? `nullable:${ZodTypeName<I>}` : T extends {
    _def: {
        typeName: "ZodDefault";
        innerType: infer I;
    };
} ? `default:${ZodTypeName<I>}` : T extends {
    _def: {
        typeName: "ZodPromise";
        type: infer I;
    };
} ? `promise:${ZodTypeName<I>}` : "unknown";

declare function schemaToSetups<Z, E extends SchemaToFieldsExtenders<Z>>(zod: Z, _options?: Options<Z, E>): SchemaToSetups<Z>;

type index$1_IsZodObject<T> = IsZodObject<T>;
type index$1_Options<Z, E extends SchemaToFieldsExtenders<Z>> = Options<Z, E>;
type index$1_SchemaToFieldsExtenders<Z> = SchemaToFieldsExtenders<Z>;
type index$1_SchemaToSetups<Z> = SchemaToSetups<Z>;
type index$1_ZodTypeNameToField<T> = ZodTypeNameToField<T>;
declare const index$1_schemaToSetups: typeof schemaToSetups;
declare namespace index$1 {
  export { type FlatObject$1 as FlatObject, type FlatObjectKeyValue$1 as FlatObjectKeyValue, type FlatObjectKeys$1 as FlatObjectKeys, type index$1_IsZodObject as IsZodObject, type index$1_Options as Options, type index$1_SchemaToFieldsExtenders as SchemaToFieldsExtenders, type index$1_SchemaToSetups as SchemaToSetups, type index$1_ZodTypeNameToField as ZodTypeNameToField, index$1_schemaToSetups as schemaToSetups };
}

type NestedObject = {
    [key: string]: NestedObject | unknown;
};
type FlatObjectKeyValue<T, K = keyof T> = T extends NestedObject ? K extends `${infer U}.${infer V}` ? U extends keyof T ? FlatObjectKeyValue<T[U], V> : never : K extends keyof T ? T[K] : never : T;
type FlatObjectKeys<T extends NestedObject, Key = keyof T> = Key extends string ? T[Key] extends NestedObject ? `${Key}.${FlatObjectKeys<T[Key]>}` : `${Key}` : never;
type FlatObject<T extends NestedObject> = {
    [K in FlatObjectKeys<T>]: FlatObjectKeyValue<T, K>;
};
type _UnflatObject<T> = T extends Record<string, unknown> ? {
    [K in keyof T as K extends `${infer Prefix}.${string}` ? Prefix : K]: K extends `${infer Prefix}.${string}` ? _UnflatObject<{
        [P in keyof T as P extends `${Prefix}.${infer Suffix}` ? Suffix : never]: T[P];
    }> : T[K];
} : T;
type UnflatObject<T> = _UnflatObject<T> extends infer G ? G : never;

declare function flattenObject<T extends NestedObject>(obj: T): FlatObject<T>;

declare function unflatten<T extends FlatObject<Record<string, unknown>>>(flat: T): UnflatObject<T>;

type index_FlatObject<T extends NestedObject> = FlatObject<T>;
type index_NestedObject = NestedObject;
type index_UnflatObject<T> = UnflatObject<T>;
type index__UnflatObject<T> = _UnflatObject<T>;
declare const index_unflatten: typeof unflatten;
declare namespace index {
  export { type index_FlatObject as FlatObject, type index_NestedObject as NestedObject, type index_UnflatObject as UnflatObject, type index__UnflatObject as _UnflatObject, flattenObject as flatten, index_unflatten as unflatten };
}

export { index as cObj, index$1 as cZod };
