/// <reference types="@applicaster/applicaster-types" />

declare module "@applicaster/quick-brick-core";

declare type CacheAssetsArgs = {
  layout: ZappLayout;
  pluginConfigurations: ZappPluginConfiguration[];
  cellStyles: ZappCellStyles;
};

// This is a workaround to allow recursive types
// doing type SomeType = { prop: SomeType[] } will not work
// creating an interface to extend this type allows
// the use of the interface as a recursive type
interface AnyRecordI extends AnyRecord {}
interface AnyArrayI extends AnyArray {}

type AnyArray = (string | number | boolean | AnyArrayI | AnyRecord)[];

type AnyRecord = Record<string, string | number | AnyArray | AnyRecordI>;

type AnyValue = void | string | number | boolean | AnyArray | AnyRecord;

declare type ReducerAction<
  T extends string = string,
  P extends AnyValue = AnyValue,
  M extends AnyRecord = AnyRecord,
> = {
  type: T;
  payload?: P;
  meta?: M;
};

declare type Reducer<S extends AnyRecord, A extends AnyRecord> = (
  state: S,
  actions: A
) => S;

declare type NavigationReducerActionTypes =
  | "PUSH"
  | "REPLACE"
  | "POP"
  | "REPLACE_TOP"
  | "SET_NAV_BAR_VISIBILITY"
  | "SET_NAV_BAR_TITLE"
  | "SET_NAV_BAR_SUMMARY"
  | "SET_BOTTOM_BAR_VISIBILITY"
  | "SET_LOCATION"
  | "OPEN_VIDEO_MODAL"
  | "CLOSE_VIDEO_MODAL"
  | "MINIMISE_VIDEO_MODAL"
  | "MAXIMISE_VIDEO_MODAL"
  | "FULLSCREEN_VIDEO_MODAL"
  | "SET_VIDEO_MODAL_ITEM"
  | "";

declare type NavigationStackReducerState = {
  mainStack: NavigationScreenState[];
  modal: Nullable<NavigationScreenState>;
};

declare type LocationReducerState = {
  key: string;
  pathname: string;
  state: Nullable<NavigationScreenData>;
};

declare type NavigationOptionsReducerState = {
  navBar: {
    visible: boolean;
    title: string;
    summary: string;
  };
  videoModal: QuickBrickVideoModalState;
};

declare type NavigationReducerState = {
  stack: NavigationStackReducerState;
  location: LocationReducerState;
  options: NavigationOptionsReducerState;
};

declare type NavigationReducer = (
  state: NavigationReducerState,
  action: ReducerAction
) => NavigationReducerState;
