import { a as SchemaValidationResult, i as ProblemPathTypeSegment, l as Schema$1, n as ProblemPathPropertySegment, o as TypeWithProblems, r as ProblemPathSegment, s as _FIXME_, t as ProblemPath } from "./_chunks-dts/typedefs.js";
import { SetSynchronization, SynchronizationRequest, SynchronizationResult } from "@sanity/descriptors";
import { SanityDocumentLike, Schema, SchemaType, SchemaTypeDefinition, SchemaValidationProblem, SchemaValidationProblemGroup } from "@sanity/types";
import { ComponentType, ReactNode } from "react";
import { SchemaType as SchemaType$1 } from "groq-js";
/** The scheduler is capable of executing work in different ways. */
type Scheduler = {
  map<T, U>(arr: T[], fn: (val: T) => U): Promise<U[]>;
  forEach<T>(arr: T[], fn: (val: T) => void): Promise<void>;
  forEachIter<T>(iter: Iterable<T>, fn: (val: T) => void): Promise<void>;
};
type RegistryType = 'sanity.schema.registry';
declare class DescriptorConverter {
  cache: WeakMap<Schema, SetSynchronization<RegistryType>>;
  /**
   * Returns a synchronization object for a schema.
   *
   * This is automatically cached in a weak map.
   */
  get(schema: Schema, opts?: {
    /**
     * If present, this will use an idle scheduler which records duration into this array.
     * This option will be ignored if the `scheduler` option is passed in.
     **/
    pauseDurations?: number[]; /** An explicit scheduler to do the work. */
    scheduler?: Scheduler;
  }): Promise<SetSynchronization<RegistryType>>;
}
type SchemaSynchronizationRequest = SynchronizationRequest;
type SchemaSynchronizationResult = SynchronizationResult;
/**
 * Returns the next request that should be generated for synchronizing the
 * schema, based on the previous response from the /synchronize endpoint.
 *
 * @param response - The previous response, or `null` if it's the first request.
 * @returns The next request, or `null` if it's been fully synchronized.
 */
declare function processSchemaSynchronization(sync: SetSynchronization<RegistryType>, response: SchemaSynchronizationResult | null): SchemaSynchronizationRequest | null;
declare const isActionEnabled: (schemaType: SchemaType, action: string) => boolean;
declare const DEFAULT_MAX_FIELD_DEPTH = 5;
declare function resolveSearchConfigForBaseFieldPaths(type: any, maxDepth?: number): any;
/**
 * @internal
 */
declare function resolveSearchConfig(type: any, maxDepth?: number): any;
declare const ALL_FIELDS_GROUP_NAME = "all-fields";
declare function createSchemaFromManifestTypes(schemaDef: {
  name: string;
  types: unknown[];
}): Schema$1;
interface MediaLibraryConfig {
  enabled?: boolean;
  libraryId?: string;
  __internal?: {
    frontendHost?: string;
  };
}
declare const SANITY_WORKSPACE_SCHEMA_ID_PREFIX = "_.schemas";
declare const SANITY_WORKSPACE_SCHEMA_TYPE = "system.schema";
declare const CURRENT_WORKSPACE_SCHEMA_VERSION = "2025-05-01";
type ManifestSerializable = string | number | boolean | {
  [k: string]: ManifestSerializable;
} | ManifestSerializable[];
interface CreateManifest {
  version: number;
  createdAt: string;
  workspaces: ManifestWorkspaceFile[];
  studioVersion: string | null;
}
interface ManifestWorkspaceFile extends Omit<CreateWorkspaceManifest, 'schema' | 'tools'> {
  schema: string;
  tools: string;
}
interface CreateWorkspaceManifest {
  name: string;
  title?: string;
  subtitle?: string;
  basePath: string;
  dataset: string;
  projectId: string;
  mediaLibrary?: MediaLibraryConfig;
  schema: ManifestSchemaType[];
  tools: ManifestTool[];
  /**
   * returns undefined in the case of the icon not being able to be stringified
   */
  icon: string | undefined;
}
interface ManifestSchemaType {
  type: string;
  name: string;
  title?: string;
  deprecated?: {
    reason: string;
  };
  readOnly?: boolean | 'conditional';
  hidden?: boolean | 'conditional';
  validation?: ManifestValidationGroup[];
  fields?: ManifestField[];
  to?: ManifestReferenceMember[];
  of?: ManifestArrayMember[];
  preview?: {
    select: Record<string, string>;
  };
  fieldsets?: ManifestFieldset[];
  options?: Record<string, ManifestSerializable>;
  marks?: {
    annotations?: ManifestArrayMember[];
    decorators?: ManifestTitledValue[];
  };
  lists?: ManifestTitledValue[];
  styles?: ManifestTitledValue[];
}
interface ManifestFieldset {
  name: string;
  title?: string;
  [index: string]: ManifestSerializable | undefined;
}
interface ManifestTitledValue {
  value: string;
  title?: string;
}
type ManifestField = ManifestSchemaType & {
  fieldset?: string;
};
type ManifestArrayMember = Omit<ManifestSchemaType, 'name'> & {
  name?: string;
};
type ManifestReferenceMember = Omit<ManifestSchemaType, 'name'> & {
  name?: string;
};
interface ManifestValidationGroup {
  rules: ManifestValidationRule[];
  message?: string;
  level?: 'error' | 'warning' | 'info';
}
type ManifestValidationRule = {
  flag: string;
  constraint?: ManifestSerializable;
  [index: string]: ManifestSerializable | undefined;
};
interface ManifestTool {
  name: string;
  title: string;
  /**
   * returns undefined in the case of the icon not being able to be stringified
   */
  icon: string | undefined;
  type: string | null;
}
type DefaultWorkspaceSchemaId = `${typeof SANITY_WORKSPACE_SCHEMA_ID_PREFIX}.${string}`;
type PrefixedWorkspaceSchemaId = `${DefaultWorkspaceSchemaId}.${string}`;
type WorkspaceSchemaId = DefaultWorkspaceSchemaId | PrefixedWorkspaceSchemaId;
interface StoredWorkspaceSchema extends SanityDocumentLike {
  _type: typeof SANITY_WORKSPACE_SCHEMA_TYPE;
  _id: WorkspaceSchemaId;
  version: typeof CURRENT_WORKSPACE_SCHEMA_VERSION | undefined;
  tag?: string;
  workspace: {
    name: string;
    title?: string;
  };
  /**
   * The API expects JSON coming in, but will store a string to save on attribute paths.
   * Consumers must use JSON.parse on the value, put we deploy to the API using ManifestSchemaType[]
   */
  schema: string | ManifestSchemaType[];
}
interface ManifestWorkspaceInput {
  name: string;
  title?: string;
  subtitle?: string;
  basePath: string;
  projectId: string;
  dataset: string;
  icon?: ComponentType | ReactNode;
  mediaLibrary?: MediaLibraryConfig;
  schema: Schema;
  tools: ManifestToolInput[];
}
interface ManifestToolInput {
  title: string;
  name: string;
  icon?: ComponentType | ReactNode;
  __internalApplicationType?: string;
}
type IconResolver = (props: {
  icon?: ComponentType | ReactNode;
  title: string;
  subtitle?: string;
}) => string | undefined | Promise<string | undefined>;
declare function extractCreateWorkspaceManifest(workspace: ManifestWorkspaceInput, iconResolver?: IconResolver): Promise<CreateWorkspaceManifest>;
/**
 * Extracts all serializable properties from userland schema types,
 * so they best-effort can be used as definitions for Schema.compile
 . */
declare function extractManifestSchemaTypes(schema: Schema): ManifestSchemaType[];
declare const validForNamesChars = "a-zA-Z0-9_-";
declare const validForNamesPattern: RegExp;
declare function getWorkspaceSchemaId(args: {
  workspaceName: string;
  tag?: string;
}): {
  safeBaseId: DefaultWorkspaceSchemaId;
  safeTaggedId: WorkspaceSchemaId;
  idWarning: string | undefined;
};
interface ParsedWorkspaceSchemaId {
  schemaId: string;
  workspace: string;
}
declare function parseWorkspaceSchemaId(id: string, errors: string[]): ParsedWorkspaceSchemaId | undefined;
declare function createStoredWorkspaceSchemaPayload(args: {
  workspace: {
    name: string;
    title?: string;
  };
  schema: ManifestSchemaType[];
  tag?: string;
}): Omit<StoredWorkspaceSchema, '_id' | '_type'>;
declare const builtinTypes: ({
  name: string;
  title: string;
  type: string;
  fieldsets: {
    name: string;
    title: string;
    description: string;
  }[];
  fields: ({
    name: string;
    type: string;
    title: string;
    readOnly: boolean;
    fieldset?: undefined;
    validation?: undefined;
    hidden?: undefined;
  } | {
    name: string;
    type: string;
    title: string;
    readOnly?: undefined;
    fieldset?: undefined;
    validation?: undefined;
    hidden?: undefined;
  } | {
    name: string;
    type: string;
    title: string;
    readOnly: boolean;
    fieldset: string;
    validation: (Rule: import("@sanity/types").Rule) => import("@sanity/types").Rule;
    hidden?: undefined;
  } | {
    name: string;
    type: string;
    readOnly: boolean;
    hidden: boolean;
    fieldset: string;
    title?: undefined;
    validation?: undefined;
  } | {
    name: string;
    type: string;
    title: string;
    readOnly: boolean;
    fieldset: string;
    validation?: undefined;
    hidden?: undefined;
  })[];
  preview: {
    select: {
      title: string;
      path: string;
      mimeType: string;
      size: string;
    };
    prepare(doc: Record<string, any>): {
      title: any;
      subtitle: string;
    };
  };
  orderings: {
    title: string;
    name: string;
    by: {
      field: string;
      direction: string;
    }[];
  }[];
} | {
  title: string;
  name: string;
  type: string;
  fields: {
    name: string;
    type: string;
    title: string;
  }[];
} | {
  name: string;
  title: string;
  type: string;
  fieldsets: {
    name: string;
    title: string;
    description: string;
  }[];
  fields: ({
    name: string;
    type: string;
    title: string;
    readOnly: boolean;
    fieldset?: undefined;
    validation?: undefined;
    hidden?: undefined;
  } | {
    name: string;
    type: string;
    title: string;
    readOnly?: undefined;
    fieldset?: undefined;
    validation?: undefined;
    hidden?: undefined;
  } | {
    name: string;
    type: string;
    title: string;
    readOnly: boolean;
    fieldset: string;
    validation: (Rule: import("@sanity/types").Rule) => import("@sanity/types").Rule;
    hidden?: undefined;
  } | {
    name: string;
    type: string;
    readOnly: boolean;
    hidden: boolean;
    fieldset: string;
    title?: undefined;
    validation?: undefined;
  } | {
    name: string;
    type: string;
    title: string;
    readOnly: boolean;
    fieldset: string;
    validation?: undefined;
    hidden?: undefined;
  })[];
  preview: {
    select: {
      id: string;
      title: string;
      mimeType: string;
      size: string;
      media: string;
    };
    prepare(doc: Partial<import("@sanity/types").SanityDocument>): {
      title: {};
      media: {
        asset: {
          _ref: unknown;
        };
        media?: {} | undefined;
      };
      subtitle: string;
    };
  };
  orderings: {
    title: string;
    name: string;
    by: {
      field: string;
      direction: string;
    }[];
  }[];
} | {
  name: string;
  title: string;
  type: string;
  fields: {
    name: string;
    type: string;
    validation: (Rule: import("@sanity/types").Rule) => import("@sanity/types").Rule;
  }[];
} | {
  name: string;
  title: string;
  type: string;
  fieldsets: {
    name: string;
    title: string;
    options: {
      collapsable: boolean;
    };
  }[];
  fields: ({
    title?: undefined;
    readOnly?: undefined;
    fieldset?: undefined;
    name: string;
    type: string;
  } | {
    readOnly?: undefined;
    name: string;
    title: string;
    type: string;
    fieldset: string;
  } | {
    fieldset?: undefined;
    name: string;
    title: string;
    type: string;
    readOnly: boolean;
  })[];
})[];
interface ExtractSchemaOptions {
  enforceRequiredFields?: boolean;
}
/**
 * Extracts a GROQ-compatible schema from a Sanity schema definition. The extraction happens in three passes:
 *
 * 1. **Dependency analysis & hoisting detection** (`sortByDependencies`): Walks the entire schema to sort
 *    types topologically and identifies inline object fields that are used multiple times (candidates
 *    for "hoisting").
 *
 * 2. **Hoisted type creation**: For any repeated inline fields, we create top-level named type definitions
 *    first, so they exist before being referenced.
 *
 * 3. **Main type conversion**: Processes each schema type in dependency order. When a field was marked for
 *    hoisting, we emit an `inline` reference to the hoisted type instead of duplicating the structure.
 */
declare function extractSchema(schemaDef: Schema, extractOptions?: ExtractSchemaOptions): SchemaType$1;
/**
 * @internal
 */
declare function groupProblems(types: SchemaTypeDefinition[]): SchemaValidationProblemGroup[];
/**
 * Ensure that the provided value is a valid Media Library asset aspect that can be safely deployed.
 *
 * @internal
 */
declare function validateMediaLibraryAssetAspect(maybeAspect: unknown): [isValidMediaLibraryAspect: boolean, validationErrors: SchemaValidationProblem[][]];
declare function validateBlockType(typeDef: any, visitorContext: any): {
  marks: any;
  styles: any;
  name: any;
  of: any;
  _problems: SchemaValidationResult[];
};
declare const typeVisitors: {
  array: (typeDef: any, visitorContext: any) => any;
  object: (typeDef: any, visitorContext: any) => any;
  slug: (typeDef: any, visitorContext: any) => any;
  file: (typeDef: any, visitorContext: any) => any;
  image: (typeDef: any, visitorContext: any) => any;
  block: typeof validateBlockType;
  document: (typeDefinition: any, visitorContext: any) => any;
  reference: (typeDef: any, visitorContext: any) => any;
  crossDatasetReference: (typeDef: any, visitorContext: any) => any;
  globalDocumentReference: (typeDef: any, visitorContext: any) => any;
};
interface Options {
  transformTypeVisitors?: (visitors: typeof typeVisitors) => Partial<typeof typeVisitors>;
  transformCommonVisitors?: (visitors: any[]) => any[];
}
/**
 * @internal
 */
declare function validateSchema(schemaTypes: _FIXME_, {
  transformTypeVisitors,
  transformCommonVisitors
}?: Options): {
  get(typeName: string): any;
  has(typeName: string): boolean;
  getTypeNames(): string[];
  getTypes(): any[];
  toJSON(): any[];
};
declare class ValidationError extends Error {
  problems: SchemaValidationProblemGroup[];
  constructor(problems: SchemaValidationProblemGroup[]);
}
export { ALL_FIELDS_GROUP_NAME, type CreateManifest, type CreateWorkspaceManifest, DEFAULT_MAX_FIELD_DEPTH, type DefaultWorkspaceSchemaId, DescriptorConverter, type _FIXME_ as FIXME, type IconResolver, type ManifestSchemaType, type ManifestWorkspaceFile, type ParsedWorkspaceSchemaId, type SchemaValidationResult as Problem, type SchemaValidationResult as ValidationResult, type ProblemPath, type ProblemPathPropertySegment, type ProblemPathSegment, type ProblemPathTypeSegment, SchemaSynchronizationRequest, SchemaSynchronizationResult, type StoredWorkspaceSchema, type TypeWithProblems, ValidationError, type WorkspaceSchemaId, builtinTypes, createSchemaFromManifestTypes, createStoredWorkspaceSchemaPayload, extractCreateWorkspaceManifest, extractManifestSchemaTypes, extractSchema, getWorkspaceSchemaId, groupProblems, isActionEnabled, parseWorkspaceSchemaId, processSchemaSynchronization, resolveSearchConfig, resolveSearchConfigForBaseFieldPaths, validForNamesChars, validForNamesPattern, validateMediaLibraryAssetAspect, validateSchema };