import { AnyArray, ArrayElement, ElementType, Index, KeyedPathElement, NormalizeReadOnlyArray, Optional, Path, SafePath, Tuplify } from "./types.cjs";
import { AssignOp, CreateIfNotExistsMutation, CreateMutation, CreateOrReplaceMutation, DecOp, DeleteMutation, DiffMatchPatchOp, IncOp, InsertIfMissingOp, InsertOp, Mutation, NodePatch, NodePatchList, Operation, PatchMutation, PatchOptions, RelativePosition, RemoveOp, ReplaceOp, SanityDocumentBase, SetIfMissingOp, SetOp, Transaction, TruncateOp, UnassignOp, UnsetOp, UpsertOp } from "./types2.cjs";
import { Insert, InsertAfter, InsertBefore, InsertReplace, PatchMutationOperation, SanityCreateIfNotExistsMutation, SanityCreateMutation, SanityCreateOrReplaceMutation, SanityDecPatch, SanityDeleteMutation, SanityDiffMatchPatch, SanityIncPatch, SanityInsertPatch, SanityMutation, SanityPatch, SanitySetIfMissingPatch, SanitySetPatch, SanityUnsetPatch } from "./types3.cjs";
declare function decodeAll<Doc extends SanityDocumentBase>(sanityMutations: SanityMutation<Doc>[]): Mutation[];
declare function decode$1<Doc extends SanityDocumentBase>(encodedMutation: SanityMutation<Doc>): Mutation;
type Id = string;
type RevisionLock = string;
type CompactPath = string;
type ItemRef$1 = string | number;
type DeleteMutation$1 = ['delete', Id];
type CreateMutation$1<Doc> = ['create', Doc];
type CreateIfNotExistsMutation$1<Doc> = ['createIfNotExists', Doc];
type CreateOrReplaceMutation$1<Doc> = ['createOrReplace', Doc];
type UnsetMutation = ['patch', 'unset', Id, CompactPath, [], RevisionLock?];
type InsertMutation = ['patch', 'insert', Id, CompactPath, [RelativePosition, ItemRef$1, AnyArray], RevisionLock?];
type UpsertMutation = ['patch', 'upsert', Id, CompactPath, [RelativePosition, ItemRef$1, AnyArray], RevisionLock?];
type InsertIfMissingMutation = ['patch', 'insertIfMissing', Id, CompactPath, [RelativePosition, ItemRef$1, AnyArray], RevisionLock?];
type TruncateMutation = ['patch', 'truncate', Id, CompactPath, [startIndex: number, endIndex: number | undefined], RevisionLock?];
type IncMutation = ['patch', 'inc', Id, CompactPath, [number], RevisionLock?];
type DecMutation = ['patch', 'dec', Id, CompactPath, [number], RevisionLock?];
type AssignMutation = ['patch', 'assign', Id, CompactPath, [object], RevisionLock?];
type UnassignMutation = ['patch', 'assign', Id, CompactPath, [string[]], RevisionLock?];
type ReplaceMutation = ['patch', 'replace', Id, CompactPath, [ItemRef$1, AnyArray], RevisionLock?];
type RemoveMutation = ['patch', 'remove', Id, CompactPath, [ItemRef$1], RevisionLock?];
type SetMutation = ['patch', 'set', Id, CompactPath, any, RevisionLock?];
type SetIfMissingMutation = ['patch', 'setIfMissing', Id, CompactPath, [unknown], RevisionLock?];
type DiffMatchPatchMutation = ['patch', 'diffMatchPatch', Id, CompactPath, [string], RevisionLock?];
type CompactPatchMutation = UnsetMutation | InsertMutation | UpsertMutation | InsertIfMissingMutation | TruncateMutation | IncMutation | DecMutation | SetMutation | SetIfMissingMutation | DiffMatchPatchMutation | AssignMutation | UnassignMutation | ReplaceMutation | RemoveMutation;
type CompactMutation<Doc> = DeleteMutation$1 | CreateMutation$1<Doc> | CreateIfNotExistsMutation$1<Doc> | CreateOrReplaceMutation$1<Doc> | CompactPatchMutation;
declare function decode<Doc extends SanityDocumentBase>(mutations: CompactMutation<Doc>[]): Mutation[];
declare function encode$1<Doc extends SanityDocumentBase>(mutations: Mutation[]): CompactMutation<Doc>[];
declare namespace index_d_exports$2 {
  export { AssignMutation, CompactMutation, CompactPatchMutation, CompactPath, CreateIfNotExistsMutation$1 as CreateIfNotExistsMutation, CreateMutation$1 as CreateMutation, CreateOrReplaceMutation$1 as CreateOrReplaceMutation, DecMutation, DeleteMutation$1 as DeleteMutation, DiffMatchPatchMutation, Id, IncMutation, InsertIfMissingMutation, InsertMutation, ItemRef$1 as ItemRef, RemoveMutation, ReplaceMutation, RevisionLock, SetIfMissingMutation, SetMutation, TruncateMutation, UnassignMutation, UnsetMutation, UpsertMutation, decode, encode$1 as encode };
}
/**
 * @deprecated
 */
type FormPatchPathKeyedSegment = {
  _key: string;
};
/**
 * @deprecated
 */
type FormPatchPathIndexTuple = [number | '', number | ''];
/**
 * @deprecated
 */
type FormPatchPathSegment = string | number | FormPatchPathKeyedSegment | FormPatchPathIndexTuple;
/**
 * @deprecated
 */
type FormPatchPath = FormPatchPathSegment[];
/**
 * A variant of the FormPath type that never contains index tupes
 */
type CompatPath = Exclude<ElementType<FormPatchPath>, FormPatchPathIndexTuple>[];
/**
 *
 * @internal
 * @deprecated
 */
type FormPatchJSONValue = number | string | boolean | {
  [key: string]: FormPatchJSONValue;
} | FormPatchJSONValue[];
/**
 *
 * @internal
 * @deprecated
 */
type FormPatchOrigin = 'remote' | 'local' | 'internal';
/**
 *
 * @internal
 * @deprecated
 */
interface FormSetPatch {
  path: FormPatchPath;
  type: 'set';
  value: FormPatchJSONValue;
}
/**
 *
 * @internal
 * @deprecated
 */
interface FormIncPatch {
  path: FormPatchPath;
  type: 'inc';
  value: FormPatchJSONValue;
}
/**
 *
 * @internal
 * @deprecated
 */
interface FormDecPatch {
  path: FormPatchPath;
  type: 'dec';
  value: FormPatchJSONValue;
}
/**
 *
 * @internal
 * @deprecated
 */
interface FormSetIfMissingPatch {
  path: FormPatchPath;
  type: 'setIfMissing';
  value: FormPatchJSONValue;
}
/**
 *
 * @internal
 * @deprecated
 */
interface FormUnsetPatch {
  path: FormPatchPath;
  type: 'unset';
}
/**
 *
 * @internal
 * @deprecated
 */
type FormInsertPatchPosition = 'before' | 'after';
/**
 *
 * @internal
 * @deprecated
 */
interface FormInsertPatch {
  path: FormPatchPath;
  type: 'insert';
  position: FormInsertPatchPosition;
  items: FormPatchJSONValue[];
}
/**
 *
 * @internal
 * @deprecated
 */
interface FormDiffMatchPatch {
  path: FormPatchPath;
  type: 'diffMatchPatch';
  value: string;
}
/**
 *
 * @internal
 * @deprecated
 */
type FormPatchLike = FormSetPatch | FormSetIfMissingPatch | FormUnsetPatch | FormInsertPatch | FormDiffMatchPatch;
/**
 * Convert a Sanity form patch (ie emitted from an input component) to a {@link NodePatch}
 * Note the lack of encodeMutation here. Sanity forms never emit *mutations*, only patches
 * @param patches - Array of {@link FormPatchLike}
 * @internal
 */
declare function encodePatches(patches: FormPatchLike[]): NodePatch[];
declare namespace index_d_exports$3 {
  export { CompatPath, FormDecPatch, FormDiffMatchPatch, FormIncPatch, FormInsertPatch, FormInsertPatchPosition, FormPatchJSONValue, FormPatchLike, FormPatchOrigin, FormPatchPath, FormPatchPathIndexTuple, FormPatchPathKeyedSegment, FormPatchPathSegment, FormSetIfMissingPatch, FormSetPatch, FormUnsetPatch, encodePatches };
}
declare namespace compact_d_exports {
  export { ItemRef, format };
}
type ItemRef = string | number;
declare function format<Doc extends SanityDocumentBase>(mutations: Mutation[]): string;
declare function autoKeys<Item>(generateKey: (item: Item) => string): {
  insert: <Pos extends RelativePosition, Ref extends Index | KeyedPathElement>(position: Pos, referenceItem: Ref, items: Item[]) => InsertOp<(Item & {
    _key: string;
  })[], Pos, Ref>;
  upsert: <Pos extends RelativePosition, ReferenceItem extends KeyedPathElement>(items: Item[], position: Pos, referenceItem: ReferenceItem) => UpsertOp<Arrify<Item & {
    _key: string;
  }>, Pos, ReferenceItem>;
  replace: <Pos extends RelativePosition, ReferenceItem extends Index | KeyedPathElement>(items: Item[], position: Pos, referenceItem: ReferenceItem) => ReplaceOp<(Item & {
    _key: string;
  })[], ReferenceItem>;
  insertBefore: <Ref extends Index | KeyedPathElement>(ref: Ref, items: Item[]) => InsertOp<(Item & {
    _key: string;
  })[], "before", Ref>;
  prepend: (items: Item[]) => InsertOp<(Item & {
    _key: string;
  })[], "before", 0>;
  insertAfter: <Ref extends Index | KeyedPathElement>(ref: Ref, items: Item[]) => InsertOp<(Item & {
    _key: string;
  })[], "after", Ref>;
  append: (items: Item[]) => InsertOp<(Item & {
    _key: string;
  })[], "after", -1>;
};
declare function create<Doc extends Optional<SanityDocumentBase, '_id'>>(document: Doc): CreateMutation<Doc>;
declare function patch<P extends NodePatchList | NodePatch>(id: string, patches: P, options?: PatchOptions): PatchMutation<NormalizeReadOnlyArray<Tuplify<P>>>;
declare function at<const P extends Path, O extends Operation>(path: P, operation: O): NodePatch<NormalizeReadOnlyArray<P>, O>;
declare function at<const P extends string, O extends Operation>(path: P, operation: O): NodePatch<SafePath<P>, O>;
declare function createIfNotExists<Doc extends SanityDocumentBase>(document: Doc): CreateIfNotExistsMutation<Doc>;
declare function createOrReplace<Doc extends SanityDocumentBase>(document: Doc): CreateOrReplaceMutation<Doc>;
declare function delete_(id: string): DeleteMutation;
declare const del: typeof delete_;
declare const destroy: typeof delete_;
type Arrify<T> = (T extends (infer E)[] ? E : T)[];
declare const set: <const T>(value: T) => SetOp<T>;
declare const assign: <const T extends { [K in string]: unknown }>(value: T) => AssignOp<T>;
declare const unassign: <const K extends readonly string[]>(keys: K) => UnassignOp<K>;
declare const setIfMissing: <const T>(value: T) => SetIfMissingOp<T>;
declare const unset: () => UnsetOp;
declare const inc: <const N extends number = 1>(amount?: N) => IncOp<N>;
declare const dec: <const N extends number = 1>(amount?: N) => DecOp<N>;
declare const diffMatchPatch: (value: string) => DiffMatchPatchOp;
declare function insert<const Items extends AnyArray<unknown>, const Pos extends RelativePosition, const ReferenceItem extends Index | KeyedPathElement>(items: Items | ArrayElement<Items>, position: Pos, indexOrReferenceItem: ReferenceItem): InsertOp<NormalizeReadOnlyArray<Items>, Pos, ReferenceItem>;
declare function append<const Items extends AnyArray<unknown>>(items: Items | ArrayElement<Items>): InsertOp<NormalizeReadOnlyArray<Items>, "after", -1>;
declare function prepend<const Items extends AnyArray<unknown>>(items: Items | ArrayElement<Items>): InsertOp<NormalizeReadOnlyArray<Items>, "before", 0>;
declare function insertBefore<const Items extends AnyArray<unknown>, const ReferenceItem extends Index | KeyedPathElement>(items: Items | ArrayElement<Items>, indexOrReferenceItem: ReferenceItem): InsertOp<NormalizeReadOnlyArray<Items>, "before", ReferenceItem>;
declare const insertAfter: <const Items extends AnyArray<unknown>, const ReferenceItem extends Index | KeyedPathElement>(items: Items | ArrayElement<Items>, indexOrReferenceItem: ReferenceItem) => InsertOp<NormalizeReadOnlyArray<Items>, "after", ReferenceItem>;
declare function truncate(startIndex: number, endIndex?: number): TruncateOp;
declare function replace<Items extends any[], ReferenceItem extends Index | KeyedPathElement>(items: Items | ArrayElement<Items>, referenceItem: ReferenceItem): ReplaceOp<Items, ReferenceItem>;
declare function remove<ReferenceItem extends Index | KeyedPathElement>(referenceItem: ReferenceItem): RemoveOp<ReferenceItem>;
declare function upsert<const Item extends {
  _key: string;
}, const Pos extends RelativePosition, const ReferenceItem extends Index | KeyedPathElement>(items: Item | Item[], position: Pos, referenceItem: ReferenceItem): UpsertOp<Arrify<Item>, Pos, ReferenceItem>;
declare function insertIfMissing<const Item extends {
  _key: string;
}, const Pos extends RelativePosition, const ReferenceItem extends Index | KeyedPathElement>(items: Item | Item[], position: Pos, referenceItem: ReferenceItem): InsertIfMissingOp<Arrify<Item>, Pos, ReferenceItem>;
declare function encode(mutation: Mutation): SanityMutation[] | SanityMutation;
declare function encodeAll(mutations: Mutation[]): SanityMutation[];
declare function encodeTransaction(transaction: Transaction): {
  transactionId: string | undefined;
  mutations: SanityMutation[];
};
declare function encodeMutation(mutation: Mutation): SanityMutation[] | SanityMutation;
declare function encodePatch(patch: NodePatch): {
  unset: string[];
  insert?: undefined;
  diffMatchPatch?: undefined;
  inc?: undefined;
  dec?: undefined;
  set?: undefined;
} | {
  insert: {
    [x: string]: string | readonly any[];
    items: AnyArray;
    replace?: undefined;
  };
  unset?: undefined;
  diffMatchPatch?: undefined;
  inc?: undefined;
  dec?: undefined;
  set?: undefined;
} | {
  diffMatchPatch: {
    [x: string]: string;
  };
  unset?: undefined;
  insert?: undefined;
  inc?: undefined;
  dec?: undefined;
  set?: undefined;
} | {
  inc: {
    [x: string]: number;
  };
  unset?: undefined;
  insert?: undefined;
  diffMatchPatch?: undefined;
  dec?: undefined;
  set?: undefined;
} | {
  dec: {
    [x: string]: number;
  };
  unset?: undefined;
  insert?: undefined;
  diffMatchPatch?: undefined;
  inc?: undefined;
  set?: undefined;
} | {
  [x: string]: {
    [x: string]: unknown;
  };
  unset?: undefined;
  insert?: undefined;
  diffMatchPatch?: undefined;
  inc?: undefined;
  dec?: undefined;
  set?: undefined;
} | {
  unset: string[];
  insert: {
    [x: string]: string | readonly any[];
    items: AnyArray;
    replace?: undefined;
  };
  diffMatchPatch?: undefined;
  inc?: undefined;
  dec?: undefined;
  set?: undefined;
} | {
  set: {
    [k: string]: never;
  };
  unset?: undefined;
  insert?: undefined;
  diffMatchPatch?: undefined;
  inc?: undefined;
  dec?: undefined;
} | {
  insert: {
    replace: string;
    items: AnyArray;
  };
  unset?: undefined;
  diffMatchPatch?: undefined;
  inc?: undefined;
  dec?: undefined;
  set?: undefined;
};
declare namespace index_d_exports {
  export { Insert, InsertAfter, InsertBefore, InsertReplace, Mutation, PatchMutationOperation, SanityCreateIfNotExistsMutation, SanityCreateMutation, SanityCreateOrReplaceMutation, SanityDecPatch, SanityDeleteMutation, SanityDiffMatchPatch, SanityDocumentBase, SanityIncPatch, SanityInsertPatch, SanityMutation, SanityPatch, SanitySetIfMissingPatch, SanitySetPatch, SanityUnsetPatch, decode$1 as decode, decodeAll, encode, encodeAll, encodeMutation, encodePatch, encodeTransaction };
}
export { type Arrify, append, assign, at, autoKeys, compact_d_exports, create, createIfNotExists, createOrReplace, dec, del, delete_, destroy, diffMatchPatch, inc, index_d_exports, index_d_exports$3 as index_d_exports$1, index_d_exports$2, insert, insertAfter, insertBefore, insertIfMissing, patch, prepend, remove, replace, set, setIfMissing, truncate, unassign, unset, upsert };
//# sourceMappingURL=index.d.cts.map