import fs from "node:fs";

//#region packages/fs-safe/dist/root-path.d.ts
type RootPathAliasPolicy = {
  allowFinalSymlinkForUnlink?: boolean;
  allowFinalHardlinkForUnlink?: boolean;
};
//#endregion
//#region packages/fs-safe/dist/path-policy.d.ts
type PathAliasPolicy = RootPathAliasPolicy;
//#endregion
//#region packages/fs-safe/dist/pinned-open.d.ts
type PinnedOpenSyncFailureReason = "path" | "validation" | "io";
type PinnedOpenSyncAllowedType = "file" | "directory";
//#endregion
//#region packages/fs-safe/dist/root-file.d.ts
type BoundaryReadFs = Pick<typeof fs, "closeSync" | "constants" | "fstatSync" | "lstatSync" | "openSync" | "readFileSync" | "realpathSync">;
type RootFileOpenFailureReason = PinnedOpenSyncFailureReason | "validation";
type RootFileOpenResult = {
  ok: true;
  path: string;
  fd: number;
  stat: fs.Stats;
  rootRealPath: string;
} | {
  ok: false;
  reason: RootFileOpenFailureReason;
  error?: unknown;
};
type RootFileOpenFailure = Extract<RootFileOpenResult, {
  ok: false;
}>;
type OpenRootFileSyncParams = {
  absolutePath: string;
  rootPath: string;
  boundaryLabel: string;
  rootRealPath?: string;
  maxBytes?: number;
  rejectHardlinks?: boolean;
  allowedType?: PinnedOpenSyncAllowedType;
  skipLexicalRootCheck?: boolean;
  ioFs?: BoundaryReadFs;
};
type OpenRootFileParams = OpenRootFileSyncParams & {
  aliasPolicy?: PathAliasPolicy;
};
//#endregion
//#region src/infra/boundary-file-read.d.ts
declare function canUseRootFileOpen(...args: any[]): any;
declare function matchRootFileOpenFailure(...args: any[]): any;
declare function openRootFile(...args: any[]): any;
declare function openRootFileSync(...args: any[]): any;
//#endregion
export { type OpenRootFileParams, type OpenRootFileSyncParams, type RootFileOpenFailure, type RootFileOpenFailureReason, type RootFileOpenResult, canUseRootFileOpen, matchRootFileOpenFailure, openRootFile, openRootFileSync };