import{createRequire as e}from"node:module";import{existsSync as t}from"node:fs";import{dirname as n,join as r}from"node:path";import{fileURLToPath as i}from"node:url";const a=e(import.meta.url),o=import.meta.dirname??n(i(import.meta.url)),s=new Map;function c(e){let i=s.get(e);if(i!==void 0)return i;let c=r(o,`..`,`..`,e);if(t(r(c,`package.json`)))return s.set(e,c),c;try{let t=n(a.resolve(`@aikit/${e}/package.json`));return s.set(e,t),t}catch{}let l=o;for(let i=0;i<6;i++){let i=r(l,`packages`,e);if(t(r(i,`package.json`)))return s.set(e,i),i;let a=n(l);if(a===l)break;l=a}return s.set(e,null),null}function l(e,n=`dist`){let i=c(e);if(!i)return null;let a=r(i,n);return t(a)?a:null}function u(e,n){let i=c(e);if(!i)return null;for(let e of n){let n=r(i,e);if(t(n))return n}return null}export{u as n,c as r,l as t};