{"version":3,"file":"directory.mjs","names":["nodePath"],"sources":["../../../../../../../@warlock.js/fs/src/facade/directory.ts"],"sourcesContent":["import nodePath from \"node:path\";\nimport { dirs } from \"./dirs\";\nimport { File } from \"./file\";\nimport type { HashAlgorithm } from \"../hash\";\nimport type {\n  CopyOptions,\n  FileStats,\n  ListOptions,\n  MoveOptions,\n  WalkEntry,\n  WalkOptions,\n} from \"./options\";\n\n/**\n * A lazy, **immutable** handle to a directory path. The constructor does zero\n * IO; path helpers (`name`/`parent`/`file`/`dir`) are pure `node:path`.\n * `copy`/`move` return a NEW handle to the destination. `listFiles`/`listDirs`\n * return `File`/`Directory` handles (not bare strings).\n *\n * @example\n * const src = fs.dir(\"src\");\n * for (const f of await src.listFiles({ recursive: true })) {\n *   if (f.extension === \".ts\") { ... }\n * }\n */\nexport class Directory {\n  public constructor(public readonly path: string) {}\n\n  /** Basename of this directory (`\"users\"`). */\n  public get name(): string {\n    return nodePath.basename(this.path);\n  }\n\n  /** Handle to the parent directory (pure path — no IO). */\n  public parent(): Directory {\n    return new Directory(nodePath.dirname(this.path));\n  }\n\n  /** Handle to a child file (pure path — no IO). */\n  public file(...segments: string[]): File {\n    return new File(nodePath.join(this.path, ...segments));\n  }\n\n  /** Handle to a child directory (pure path — no IO). */\n  public dir(...segments: string[]): Directory {\n    return new Directory(nodePath.join(this.path, ...segments));\n  }\n\n  public ensure(): Promise<void> {\n    return dirs.ensure(this.path);\n  }\n\n  public remove(): Promise<void> {\n    return dirs.remove(this.path);\n  }\n\n  public empty(): Promise<void> {\n    return dirs.empty(this.path);\n  }\n\n  public exists(): Promise<boolean> {\n    return dirs.exists(this.path);\n  }\n\n  public isEmpty(): Promise<boolean> {\n    return dirs.isEmpty(this.path);\n  }\n\n  public count(): Promise<number> {\n    return dirs.count(this.path);\n  }\n\n  public async copy(to: string, options?: CopyOptions): Promise<Directory> {\n    await dirs.copy(this.path, to, options);\n    return new Directory(to);\n  }\n\n  public async move(to: string, options?: MoveOptions): Promise<Directory> {\n    await dirs.move(this.path, to, options);\n    return new Directory(to);\n  }\n\n  public stats(): Promise<FileStats> {\n    return dirs.stats(this.path);\n  }\n\n  public size(): Promise<number> {\n    return dirs.size(this.path);\n  }\n\n  public list(options?: ListOptions): Promise<string[]> {\n    return dirs.list(this.path, options);\n  }\n\n  public async listFiles(options?: ListOptions): Promise<File[]> {\n    return (await dirs.listFiles(this.path, options)).map((path) => new File(path));\n  }\n\n  public async listDirs(options?: ListOptions): Promise<Directory[]> {\n    return (await dirs.listDirs(this.path, options)).map((path) => new Directory(path));\n  }\n\n  public walk(options?: WalkOptions): AsyncIterable<WalkEntry> {\n    return dirs.walk(this.path, options);\n  }\n\n  public hash(algorithm?: HashAlgorithm): Promise<string> {\n    return dirs.hash(this.path, algorithm);\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyBA,IAAa,YAAb,MAAa,UAAU;CACc;CAAnC,AAAO,YAAY,AAAgB,MAAc;EAAd;CAAe;;CAGlD,IAAW,OAAe;EACxB,OAAOA,KAAS,SAAS,KAAK,IAAI;CACpC;;CAGA,AAAO,SAAoB;EACzB,OAAO,IAAI,UAAUA,KAAS,QAAQ,KAAK,IAAI,CAAC;CAClD;;CAGA,AAAO,KAAK,GAAG,UAA0B;EACvC,OAAO,IAAI,KAAKA,KAAS,KAAK,KAAK,MAAM,GAAG,QAAQ,CAAC;CACvD;;CAGA,AAAO,IAAI,GAAG,UAA+B;EAC3C,OAAO,IAAI,UAAUA,KAAS,KAAK,KAAK,MAAM,GAAG,QAAQ,CAAC;CAC5D;CAEA,AAAO,SAAwB;EAC7B,OAAO,KAAK,OAAO,KAAK,IAAI;CAC9B;CAEA,AAAO,SAAwB;EAC7B,OAAO,KAAK,OAAO,KAAK,IAAI;CAC9B;CAEA,AAAO,QAAuB;EAC5B,OAAO,KAAK,MAAM,KAAK,IAAI;CAC7B;CAEA,AAAO,SAA2B;EAChC,OAAO,KAAK,OAAO,KAAK,IAAI;CAC9B;CAEA,AAAO,UA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