"use strict";exports.id=6646,exports.ids=[6646],exports.modules={"./src/commands/worker-directory.ts"(r,e,o){o.r(e),o.d(e,{createInvalidWorkerDirectoryError:()=>a,findClosestCommonAncestor:()=>c,resolveWorkerDirectoryPaths:()=>i});var t=o("node:fs"),s=o("node:path"),n=o.n(s);function i(r){if(void 0===r||0===r.length){const r=process.cwd();return{isValid:!0,workspacePaths:[r],workerCwd:r}}const e=[];for(const o of r){const r=n().resolve(o);if(!(0,t.existsSync)(r))return{isValid:!1,workspacePath:r,reason:"does-not-exist"};if(!(0,t.statSync)(r).isDirectory())return{isValid:!1,workspacePath:r,reason:"not-directory"};e.includes(r)||e.push(r)}return{isValid:!0,workspacePaths:e,workerCwd:c(e)}}function c(r){if(0===r.length)throw new Error("Cannot compute common ancestor for an empty path list");if(1===r.length)return n().resolve(r[0]);const e=r.map((r=>n().resolve(r))),o=n().parse(e[0]).root;if(!e.every((r=>n().parse(r).root===o)))return e[0];const t=e[0].slice(o.length).split(n().sep).filter(Boolean);let s=t.length;for(const r of e.slice(1)){const e=r.slice(o.length).split(n().sep).filter(Boolean);let i=0;for(;i<s&&i<e.length&&t[i]===e[i];)i++;s=i}return 0===s?o:n().join(o,...t.slice(0,s))}function a(r,e){return"does-not-exist"===r?new Error(`Invalid worker directory: does not exist (${e})`):new Error(`Invalid worker directory: path is not a directory (${e})`)}}};