"use strict";var w=Object.defineProperty;var n=(r,t)=>w(r,"name",{value:t,configurable:!0});var c=require("node:fs/promises"),u=require("node:path"),h=require("fs/promises"),g=require("path"),b=require("fs"),v=require("os");typeof Symbol.asyncDispose!="symbol"&&Object.defineProperty(Symbol,"asyncDispose",{configurable:!1,enumerable:!1,writable:!1,value:Symbol.for("asyncDispose")});class F{static{n(this,"FsFixture")}path;constructor(t){this.path=t}getPath(...t){return g.join(this.path,...t)}exists(t=""){return h.access(this.getPath(t)).then(()=>!0,()=>!1)}rm(t=""){return h.rm(this.getPath(t),{recursive:!0,force:!0})}writeFile(t,i){return h.writeFile(this.getPath(t),i)}writeJson(t,i){return this.writeFile(t,JSON.stringify(i,null,2))}readFile(t,i){return h.readFile(this.getPath(t),i)}async[Symbol.asyncDispose](){await this.rm()}}const d=b.realpathSync(v.tmpdir()),P=`fs-fixture-${Date.now()}`;let y=0;const j=n(()=>(y+=1,y),"getId");class p{static{n(this,"Symlink")}target;type;path;constructor(t,i){this.target=t,this.type=i}}const f=n((r,t,i)=>{const s=[];for(const o in r){if(!Object.hasOwn(r,o))continue;const e=u.join(t,o);let a=r[o];if(typeof a=="function"){const m=Object.assign(Object.create(i),{filePath:e}),l=a(m);if(l instanceof p){l.path=e,s.push(l);continue}else a=l}typeof a=="string"?s.push({path:e,content:a}):s.push(...f(a,e,i))}return s},"flattenFileTree"),D=n(async(r,t)=>{const i=t?.tempDir?u.resolve(t.tempDir):d,s=u.join(i,`${P}-${j()}/`);if(await c.mkdir(s,{recursive:!0}),r){if(typeof r=="string")await c.cp(r,s,{recursive:!0,filter:t?.templateFilter});else if(typeof r=="object"){const o={fixturePath:s,getPath:n((...e)=>u.join(s,...e),"getPath"),symlink:n((e,a)=>new p(e,a),"symlink")};await Promise.all(f(r,s,o).map(async e=>{await c.mkdir(u.dirname(e.path),{recursive:!0}),e instanceof p?await c.symlink(e.target,e.path,e.type):await c.writeFile(e.path,e.content)}))}}return new F(s)},"createFixture");exports.createFixture=D;