import { IAction, IOperator } from "./types.js";
import { Devtools } from "./Devtools.js";
import { IFlushCallback, IMutation, IMutationTree, ITrackStateTree } from "proxy-state-tree";

//#region src/internalTypes.d.ts
type SubType<Base, Condition> = Pick<Base, { [Key in keyof Base]: Base[Key] extends Condition | undefined ? Key : never }[keyof Base]>;
type NestedPartial<T> = T extends Function ? T : Partial<{ [P in keyof T]: NestedPartial<T[P]> }>;
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
type Options = {
  delimiter?: string;
  name?: string;
  devEnv?: string;
  devtools?: string | boolean;
  logProxies?: boolean;
  hotReloading?: boolean;
  strict?: boolean;
  devtoolsLogLevel?: LogLevel;
};
type DefaultMode = {
  mode: Symbol;
};
type TestMode = {
  mode: Symbol;
  options: {
    effectsCallback: (effect: {
      effectId: number;
      name: string;
      method: string;
      args: any[];
    }) => {};
  };
};
type SSRMode = {
  mode: Symbol;
};
declare enum EventType {
  ACTION_START = "action:start",
  ACTION_END = "action:end",
  OPERATOR_START = "operator:start",
  OPERATOR_END = "operator:end",
  OPERATOR_ASYNC = "operator:async",
  MUTATIONS = "mutations",
  EFFECT = "effect",
  DERIVED = "derived",
  DERIVED_DIRTY = "derived:dirty",
  COMPONENT_ADD = "component:add",
  COMPONENT_UPDATE = "component:update",
  COMPONENT_REMOVE = "component:remove",
  GETTER = "getter",
}
type Execution = {
  actionId: number;
  executionId: number;
  actionName: string;
  operatorId: number;
  isRunning: boolean;
  parentExecution?: Execution;
  path: string[];
  namespacePath?: string[];
  emit(event: EventType, value: any): void;
  flush(isAsync?: boolean): {
    mutations: IMutation[];
    flushId: number;
  };
  getMutationTree(): IMutationTree<object, Devtools | undefined>;
  getTrackStateTree(): ITrackStateTree<object, Devtools | undefined>;
  onFlush(cb: IFlushCallback): () => IFlushCallback[];
  value?: any;
  error?: string;
};
interface Events {
  [EventType.ACTION_START]: Execution;
  [EventType.ACTION_END]: Execution;
  [EventType.OPERATOR_START]: Execution & {
    path: string[];
    type: string;
    name?: string;
  };
  [EventType.OPERATOR_END]: Execution & {
    path: string[];
    isAsync: boolean;
    result: any;
  };
  [EventType.OPERATOR_ASYNC]: Execution & {
    path: string[];
    type: string;
    name?: string;
  };
  [EventType.MUTATIONS]: Execution & {
    mutations: IMutation[];
  };
  [EventType.DERIVED]: {
    path: string;
    paths: string[];
    updateCount: number;
    value: any;
  };
  [EventType.DERIVED_DIRTY]: {
    derivedPath: string[];
    path: string;
    flushId: number;
  };
  [EventType.EFFECT]: Execution & {
    result: any;
    name: string;
    method: string;
    args: any[];
    isPending: boolean;
    error: string;
    effectId: number;
  };
  [EventType.GETTER]: {
    path: string;
    value: any;
  };
  [EventType.COMPONENT_ADD]: {
    componentId: number | string;
    componentInstanceId: number;
    name: string;
    paths: string[];
  };
  [EventType.COMPONENT_UPDATE]: {
    componentId: number | string;
    componentInstanceId: number;
    name: string;
    paths: string[];
    flushId?: number;
  };
  [EventType.COMPONENT_REMOVE]: {
    componentId: number | string;
    componentInstanceId: number;
    name: string;
  };
}
type NestedActions = {
  [key: string]: Function | NestedActions;
};
type ResolveAction<T> = T extends IOperator<void, infer R> ? () => Promise<R> : T extends IOperator<infer P | undefined, infer R> ? (payload?: P) => Promise<R> : T extends IOperator<infer P, infer R> ? (payload: P) => Promise<R> : T extends IAction<void, infer R> ? () => R : T extends IAction<infer P | undefined, infer R> ? (payload?: P) => R : T extends IAction<infer P, infer R> ? (payload: P) => R : T extends NestedActions ? { [K in keyof T]: ResolveAction<T[K]> } : never;
interface ContextFunction<P$1 extends any, R$1 extends any> {
  (context: {
    state: any;
    actions: any;
    effects: any;
    reaction: any;
    addMutationListener: any;
    addFlushListener: any;
  }, payload: P$1): R$1;
}
interface OperatorContextFunction<P$1 extends any, R$1 extends any> {
  (context: {
    state: any;
    actions: any;
    effects: any;
    reaction: any;
    addMutationListener: any;
    addFlushListener: any;
  }, payload: P$1 extends Promise<infer PP> ? PP : P$1): R$1;
}
//#endregion
export { ContextFunction, DefaultMode, EventType, Events, Execution, LogLevel, NestedPartial, OperatorContextFunction, Options, ResolveAction, SSRMode, SubType, TestMode };
//# sourceMappingURL=internalTypes.d.ts.map