import { i as ConfigStore, r as CliConfig } from "./cliConfig-BZgn8ge1.js";
import { t as ProjectRootResult } from "./recursivelyResolveProjectRoot-BE54uEP6.js";
import { z } from "zod/mini";
import { Workspace } from "sanity";
/**
 * Module-level cache for the resolved CLI auth token, shared between
 * `getCliTokenInfo` (reads/writes) and `setCliUserConfig` (invalidates).
 *
 * Extracted into its own module to avoid a circular dependency
 * between `cliUserConfig.ts` and `getCliToken.ts`.
 */
interface CliTokenInfo {
  source: string;
  token: string;
}
/**
 * Clear the in-process token cache so the next token resolution
 * re-reads from disk or the environment.
 *
 * Called automatically by `setCliUserConfig('authToken', ...)`.
 *
 * @internal
 */
declare function clearCliTokenCache(): void;
/**
 * Get the CLI authentication token selected for the current invocation.
 *
 * @returns A promise that resolves to a CLI token, or undefined if no token is found
 * @internal
 */
declare function getCliToken(): Promise<string | undefined>;
/**
 * Get the CLI authentication token and where it was resolved from.
 *
 * @returns A promise that resolves to the token and its source, or undefined if no token is found
 * @internal
 */
declare function getCliTokenInfo(): Promise<CliTokenInfo | undefined>;
/**
 * Set the config value for the given property.
 * Validates that the passed value adheres to the defined CLI config schema.
 *
 * @param prop - The property to set the value for
 * @param value - The value to set
 * @internal
 */
declare function setCliUserConfig(prop: 'authToken', value: string | undefined): void;
/**
 * Get the config value for the given property
 *
 * @param prop - The property to get the value for
 * @returns The value of the given property
 */
declare function getCliUserConfig(prop: 'authToken'): string | undefined;
/**
 * Get a key-value store backed by the CLI user configuration file
 * (`~/.config/sanity/config.json`).
 *
 * Each call to `get`, `set`, or `delete` performs a full synchronous
 * read-modify-write cycle. This is intentional: sync I/O prevents
 * intra-process race conditions that occurred with the previous async
 * (configstore-backed) implementation.
 *
 * Note: there is no file-level locking, so concurrent writes from
 * separate CLI processes could still conflict. In practice this is
 * unlikely since CLI config writes are rare and user-initiated.
 *
 * @returns A {@link ConfigStore} for the CLI config file
 * @public
 */
declare function getUserConfig(): ConfigStore;
/**
 * Get the CLI config for a project, given the root path.
 *
 * Results are cached in-memory keyed by rootPath for the lifetime of the
 * process. Since the CLI always runs from a single project root, the config
 * won't change during a command's execution, so caching avoids redundant
 * filesystem reads and jiti imports from the prerun hook, SanityCommand
 * helpers, and action files.
 *
 * If loading fails the cached promise is evicted so the next call retries.
 *
 * Long-lived processes that need to observe edits to `sanity.cli.(ts|js)`
 * (e.g. a dev-server watcher) should use {@link getCliConfigUncached}
 * instead — it bypasses both this in-memory cache and Node's module cache.
 *
 * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.
 * @returns The CLI config
 * @internal
 */
declare function getCliConfig(rootPath: string): Promise<CliConfig>;
/**
 * Read the CLI config for a project from disk, bypassing both the
 * `getCliConfig` in-memory cache and Node's module cache. Each call locates
 * `sanity.cli.(ts|js)`, drops any prior jiti compilation from `require.cache`,
 * re-imports, and re-validates.
 *
 * Use this when the config file is expected to change during the process's
 * lifetime — typically a dev-server watcher that needs the new values picked
 * up after each save. One-shot CLI invocations should prefer
 * {@link getCliConfig} so the prerun hook, SanityCommand helpers, and action
 * files share a single load.
 *
 * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.
 * @returns The freshly loaded CLI config
 * @internal
 */
declare function getCliConfigUncached(rootPath: string): Promise<CliConfig>;
/**
 * Get the CLI config for a project synchronously, given the root path.
 *
 * This loads the CLI config in the main thread using Jiti for TypeScript support.
 * Note: This is a synchronous operation and does not use worker threads like the async version.
 *
 * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.
 * @returns The CLI config
 * @internal
 */
declare function getCliConfigSync(rootPath: string): CliConfig;
/**
 * Resolve project root directory and type.
 *
 * Project root is:
 * - `studio` - A pre-blueprints Sanity studio root (containing `sanity.config.(ts|js)`)
 * - `app` - A Sanity app root (containing `sanity.cli.(ts|js)`)
 *
 * If a Sanity Studio v2/v1 root is found (containing `sanity.json` with `root: true`),
 * an error is thrown, as v2/v1 is no longer supported.
 *
 * @internal
 */
declare function findProjectRoot(cwd: string): Promise<ProjectRootResult>;
/**
 * Resolve project root directory and type synchronously.
 *
 * Project root is:
 * - `studio` - A pre-blueprints Sanity studio root (containing `sanity.config.(ts|js)`)
 * - `app` - A Sanity app root (containing `sanity.cli.(ts|js)`)
 *
 * If a Sanity Studio v2/v1 root is found (containing `sanity.json` with `root: true`),
 * an error is thrown, as v2/v1 is no longer supported.
 *
 * @param cwd - Current working directory to start searching from
 * @returns Project root result
 * @internal
 */
declare function findProjectRootSync(cwd: string): ProjectRootResult;
declare const rawConfigSchema: z.ZodMiniUnion<readonly [z.ZodMiniArray<z.ZodMiniObject<{
  basePath: z.ZodMiniOptional<z.ZodMiniString<string>>;
  name: z.ZodMiniOptional<z.ZodMiniString<string>>;
  plugins: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnknown>>;
  schema: z.ZodMiniOptional<z.ZodMiniObject<{
    name: z.ZodMiniOptional<z.ZodMiniString<string>>;
    types: z.ZodMiniArray<z.ZodMiniObject<{}, z.core.$loose>>;
  }, z.core.$loose>>;
  title: z.ZodMiniOptional<z.ZodMiniString<string>>;
  unstable_sources: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
    dataset: z.ZodMiniString<string>;
    projectId: z.ZodMiniString<string>;
    schema: z.ZodMiniObject<{
      _original: z.ZodMiniObject<{
        name: z.ZodMiniOptional<z.ZodMiniString<string>>;
        types: z.ZodMiniArray<z.ZodMiniObject<{}, z.core.$loose>>;
      }, z.core.$loose>;
    }, z.core.$loose>;
  }, z.core.$loose>>>;
  dataset: z.ZodMiniString<string>;
  projectId: z.ZodMiniString<string>;
}, z.core.$loose>>, z.ZodMiniObject<{
  basePath: z.ZodMiniOptional<z.ZodMiniString<string>>;
  name: z.ZodMiniOptional<z.ZodMiniString<string>>;
  plugins: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnknown>>;
  schema: z.ZodMiniOptional<z.ZodMiniObject<{
    name: z.ZodMiniOptional<z.ZodMiniString<string>>;
    types: z.ZodMiniArray<z.ZodMiniObject<{}, z.core.$loose>>;
  }, z.core.$loose>>;
  title: z.ZodMiniOptional<z.ZodMiniString<string>>;
  unstable_sources: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
    dataset: z.ZodMiniString<string>;
    projectId: z.ZodMiniString<string>;
    schema: z.ZodMiniObject<{
      _original: z.ZodMiniObject<{
        name: z.ZodMiniOptional<z.ZodMiniString<string>>;
        types: z.ZodMiniArray<z.ZodMiniObject<{}, z.core.$loose>>;
      }, z.core.$loose>;
    }, z.core.$loose>;
  }, z.core.$loose>>>;
  dataset: z.ZodMiniString<string>;
  projectId: z.ZodMiniString<string>;
}, z.core.$loose>]>;
declare const resolvedConfigSchema: z.ZodMiniArray<z.ZodMiniObject<{
  basePath: z.ZodMiniString<string>;
  name: z.ZodMiniString<string>;
  plugins: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnknown>>;
  title: z.ZodMiniString<string>;
  unstable_sources: z.ZodMiniArray<z.ZodMiniObject<{
    dataset: z.ZodMiniString<string>;
    projectId: z.ZodMiniString<string>;
    schema: z.ZodMiniObject<{
      _original: z.ZodMiniObject<{
        name: z.ZodMiniOptional<z.ZodMiniString<string>>;
        types: z.ZodMiniArray<z.ZodMiniObject<{}, z.core.$loose>>;
      }, z.core.$loose>;
    }, z.core.$loose>;
  }, z.core.$loose>>;
  dataset: z.ZodMiniString<string>;
  projectId: z.ZodMiniString<string>;
  schema: z.ZodMiniObject<{
    _original: z.ZodMiniObject<{
      name: z.ZodMiniOptional<z.ZodMiniString<string>>;
      types: z.ZodMiniArray<z.ZodMiniObject<{}, z.core.$loose>>;
    }, z.core.$loose>;
  }, z.core.$loose>;
}, z.core.$loose>>;
type RawStudioConfig = z.infer<typeof rawConfigSchema>;
type ResolvedStudioConfig = z.infer<typeof resolvedConfigSchema>;
/**
 * Get the studio config for a project, given the root path.
 *
 * @param rootPath - The root path for the project
 * @returns The studio config (some properties may be missing)
 * @public
 */
declare function getStudioConfig(rootPath: string, options: {
  resolvePlugins: true;
}): Promise<ResolvedStudioConfig>;
declare function getStudioConfig(rootPath: string, options: {
  resolvePlugins: false;
}): Promise<RawStudioConfig>;
/**
 * Resolves the workspaces from the studio config.
 *
 * NOTE: This function should only be called from a worker thread.
 *
 * @param configPath - The path to the studio config
 * @returns The workspaces
 * @internal
 */
declare function getStudioWorkspaces(configPath: string): Promise<Workspace[]>;
/**
 * Checks if the given value conforms to a minimum studio config shape.
 *
 * @param value - The value to check
 * @returns Whether the value is a studio config
 * @internal
 */
declare function isStudioConfig(value: unknown): boolean;
/**
 * @internal
 */
interface PathResult {
  exists: boolean;
  path: string;
}
/**
 * Finds the path for a given set of files.
 *
 * @param basePath - The base path to search for files.
 * @param files - The files to search for.
 * @internal
 */
declare function findPathForFiles(basePath: string, files: string[]): Promise<PathResult[]>;
/**
 * Resolves to a string containing the found config path, otherwise throws an error.
 * Also throws if Sanity v2 studio root is found.
 *
 * @param basePath - The base path to start searching from
 * @returns A promise that resolves to a string containing the found config path
 * @throws On multiple config files found, if v2 studio root found, or no config found
 * @internal
 */
declare function findStudioConfigPath(basePath: string): Promise<string>;
/**
 * Tries to find the studio config path, returning `undefined` if not found.
 *
 * @param basePath - The base path to start searching from
 * @returns A promise that resolves to a string containing the found config path, or `undefined` if not found
 * @throws On errors other than config not found
 * @internal
 */
declare function tryFindStudioConfigPath(basePath: string): Promise<string | undefined>;
export { CliTokenInfo as _, getStudioWorkspaces as a, findProjectRoot as c, getCliConfigUncached as d, getCliToken as f, setCliUserConfig as g, getUserConfig as h, isStudioConfig as i, getCliConfigSync as l, getCliUserConfig as m, tryFindStudioConfigPath as n, getStudioConfig as o, getCliTokenInfo as p, findPathForFiles as r, findProjectRootSync as s, findStudioConfigPath as t, getCliConfig as u, clearCliTokenCache as v };
//# sourceMappingURL=findStudioConfigPath-B35la6W9.d.ts.map