/*-------------------------------------------------------------------------- @sinclair/typebox/type The MIT License (MIT) Copyright (c) 2017-2026 Haydn Paterson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ---------------------------------------------------------------------------*/ import type { Evaluate } from '../helpers/index' import type { TOptional } from '../optional/index' import type { TReadonly } from '../readonly/index' import type { TArray } from '../array/index' import type { TAsyncIterator } from '../async-iterator/index' import type { TConstructor } from '../constructor/index' import type { TEnum } from '../enum/index' import type { TFunction } from '../function/index' import type { TIntersect } from '../intersect/index' import type { TImport } from '../module/index' import type { TIterator } from '../iterator/index' import type { TNot } from '../not/index' import type { TObject, TProperties } from '../object/index' import type { TPromise } from '../promise/index' import type { TRecursive } from '../recursive/index' import type { TRecord } from '../record/index' import type { TRef } from '../ref/index' import type { TTuple } from '../tuple/index' import type { TUnion } from '../union/index' import type { TUnsafe } from '../unsafe/index' import type { TSchema } from '../schema/index' import type { TTransform } from '../transform/index' import type { TNever } from '../never/index' // ------------------------------------------------------------------ // Import // ------------------------------------------------------------------ // prettier-ignore type TDecodeImport = ( Key extends keyof ModuleProperties ? TDecodeType extends infer Type extends TSchema ? Type extends TRef ? TDecodeImport : Type : TNever : TNever ) // ------------------------------------------------------------------ // Properties // ------------------------------------------------------------------ // prettier-ignore type TDecodeProperties = { [Key in keyof Properties]: TDecodeType } // ------------------------------------------------------------------ // Types // ------------------------------------------------------------------ // prettier-ignore type TDecodeTypes = ( Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TDecodeTypes]> : Result ) // ------------------------------------------------------------------ // Types // ------------------------------------------------------------------ // prettier-ignore export type TDecodeType = ( Type extends TOptional ? TOptional> : Type extends TReadonly ? TReadonly> : Type extends TTransform ? TUnsafe : Type extends TArray ? TArray> : Type extends TAsyncIterator ? TAsyncIterator> : Type extends TConstructor ? TConstructor, TDecodeType> : Type extends TEnum ? TEnum : // intercept for union. interior non decodable Type extends TFunction ? TFunction, TDecodeType> : Type extends TIntersect ? TIntersect> : Type extends TImport ? TDecodeImport : Type extends TIterator ? TIterator> : Type extends TNot ? TNot> : Type extends TObject ? TObject>> : Type extends TPromise ? TPromise> : Type extends TRecord ? TRecord> : Type extends TRecursive ? TRecursive> : Type extends TRef ? TRef : Type extends TTuple ? TTuple> : Type extends TUnion ? TUnion> : Type ) // ------------------------------------------------------------------ // Static // ------------------------------------------------------------------ export type StaticDecodeIsAny = boolean extends (Type extends TSchema ? true : false) ? true : false /** Creates an decoded static type from a TypeBox type */ // prettier-ignore export type StaticDecode extends true ? unknown : Static, Params> > = Result /** Creates an encoded static type from a TypeBox type */ export type StaticEncode> = Result /** Creates a static type from a TypeBox type */ export type Static = Result