import { Empty, Eq, ProvableInstance, Update } from './core.js'; import { Precondition } from './preconditions.js'; import { Bool } from '../../provable/bool.js'; import { Field } from '../../provable/field.js'; import { Provable } from '../../provable/provable.js'; import { Unconstrained } from '../../provable/types/unconstrained.js'; export { StateValues, GenericStatePreconditions, StatePreconditions, StateDefinition, StateUpdates, StateLayout, GenericStateUpdates, StateMask, StateReader, State, }; type CustomStateLayout = { [name: string]: Provable & Empty; }; type StateLayout = 'GenericState' | CustomStateLayout; declare const CustomStateLayout: { project(Layout: StateIn, f: (key: keyof StateIn, value: StateIn[keyof StateIn]) => StateOut[keyof StateIn]): StateOut; }; type StateDefinition = State extends 'GenericState' ? 'GenericState' : { Layout: State; } & Provable<{ [name in keyof State]: ProvableInstance; }>; declare const StateDefinition: { split2(definition: StateDefinition, value1: State extends 'GenericState' ? Generic1 : Custom1, value2: State extends 'GenericState' ? Generic2 : Custom2, generic: (x1: Generic1, x2: Generic2) => void, custom: (layout: CustomStateLayout, x1: Custom1, x2: Custom2) => void): void; map(definition: StateDefinition, value: State_1 extends "GenericState" ? GenericIn : CustomIn, generic: (x: GenericIn) => GenericOut, custom: (layout: CustomStateLayout, x: CustomIn) => CustomOut): State_1 extends "GenericState" ? GenericOut : CustomOut; map2(definition: StateDefinition, value1: State_2 extends "GenericState" ? GenericIn1 : CustomIn1, value2: State_2 extends "GenericState" ? GenericIn2 : CustomIn2, generic: (x1: GenericIn1, x2: GenericIn2) => GenericOut_1, custom: (layout: CustomStateLayout, x1: CustomIn1, x2: CustomIn2) => CustomOut_1): State_2 extends "GenericState" ? GenericOut_1 : CustomOut_1; project(definition: StateDefinition, generic: () => Generic, custom: (layout: CustomStateLayout) => Custom): State_3 extends "GenericState" ? Generic : Custom; convert(definition: StateDefinition, value: State_4 extends "GenericState" ? Generic_1 : Custom_1, generic: (x: Generic_1) => Out, custom: (layout: CustomStateLayout, x: Custom_1) => Out): Out; }; declare function State(Layout: State): StateDefinition; type StatePreconditions = State extends 'GenericState' ? GenericStatePreconditions : { [name in keyof State]: Precondition.Equals & Eq>>; }; declare const StatePreconditions: { empty(State: StateDefinition): StatePreconditions; toGeneric(State: StateDefinition, statePreconditions: StatePreconditions): StatePreconditions<'GenericState'>; fromGeneric(statePreconditions: StatePreconditions<'GenericState'>, State: StateDefinition): StatePreconditions; toFieldPreconditions(State: StateDefinition, preconditions: StatePreconditions): Precondition.Equals[]; }; type StateUpdates = State extends 'GenericState' ? GenericStateUpdates : { [name in keyof State]?: ProvableInstance | Update>; }; declare const StateUpdates: { empty(State: StateDefinition): StateUpdates; anyValuesAreSet(stateUpdates: StateUpdates): Bool; toGeneric(State: StateDefinition, stateUpdates: StateUpdates): StateUpdates<'GenericState'>; fromGeneric(stateUpdates: StateUpdates<'GenericState'>, State: StateDefinition): StateUpdates; toFieldUpdates(State: StateDefinition, updates: StateUpdates): Update[]; }; type StateValues = State extends 'GenericState' ? GenericStateValues : { [name in keyof State]: ProvableInstance; }; declare const StateValues: { empty(State: StateDefinition): StateValues; toGeneric(State: StateDefinition, stateValues: StateValues): StateValues<'GenericState'>; fromGeneric(stateValues: StateValues<'GenericState'>, State: StateDefinition): StateValues; checkPreconditions(State: StateDefinition, stateValues: StateValues, statePreconditions: StatePreconditions): void; applyUpdates(State: StateDefinition, stateValues: StateValues, stateUpdates: StateUpdates): StateValues; }; type StateMask = State extends 'GenericState' ? GenericStateMask : { [name in keyof State]?: ProvableInstance; }; declare const StateMask: { create(State: StateDefinition): StateMask; }; type StateReader = State extends 'GenericState' ? GenericStateReader : { [name in keyof State]: State[name] extends Provable ? () => U : never; }; declare const StateReader: { create(State: StateDefinition, stateValues: Unconstrained>, stateMask: Unconstrained>): StateReader; }; declare class StateFieldsArray { private fieldElements; constructor(fieldElements: T[], empty: () => T); get fields(): T[]; } declare class GenericStateValues extends StateFieldsArray { constructor(values: Field[]); get values(): Field[]; get(index: number): Field; map(f: (x: Field, i: number) => Field): GenericStateValues; static empty(): GenericStateValues; } declare class GenericStatePreconditions extends StateFieldsArray> { constructor(preconditions: Precondition.Equals[]); get preconditions(): Precondition.Equals[]; static empty(): GenericStatePreconditions; } declare class GenericStateUpdates extends StateFieldsArray> { constructor(updates: Update[]); get updates(): Update[]; static empty(): GenericStateUpdates; } declare class GenericStateMask extends StateFieldsArray { constructor(); set(index: number, value: Field): void; static empty(): GenericStateMask; } declare class GenericStateReader { private values; private mask; constructor(values: Unconstrained, mask: Unconstrained); read(index: number): Field; }