@visulima/packem 1.0.0-alpha.50 → 1.0.0-alpha.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cli.mjs +46 -46
  3. package/dist/config.d.cts +2 -2
  4. package/dist/config.d.mts +2 -2
  5. package/dist/config.d.ts +2 -2
  6. package/dist/create-bundler.cjs +48 -48
  7. package/dist/create-bundler.d.cts +1 -1
  8. package/dist/create-bundler.d.mts +1 -1
  9. package/dist/create-bundler.d.ts +1 -1
  10. package/dist/create-bundler.mjs +46 -46
  11. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-plugin.cjs +1 -0
  12. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-plugin.d.cts +26 -0
  13. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-plugin.d.mts +26 -0
  14. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-plugin.d.ts +26 -0
  15. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-plugin.mjs +9 -0
  16. package/dist/rollup/plugins/swc/isolated-declarations-swc-plugin.cjs +1 -0
  17. package/dist/rollup/plugins/swc/isolated-declarations-swc-plugin.d.cts +26 -0
  18. package/dist/rollup/plugins/swc/isolated-declarations-swc-plugin.d.mts +26 -0
  19. package/dist/rollup/plugins/swc/isolated-declarations-swc-plugin.d.ts +26 -0
  20. package/dist/rollup/plugins/swc/isolated-declarations-swc-plugin.mjs +9 -0
  21. package/dist/shared/{packem.Dyuh0rNc.d.mts → packem.CXBj45xL.d.mts} +13 -1
  22. package/dist/shared/{packem.7EZm-4xL.d.ts → packem.EAyscW7M.d.ts} +13 -1
  23. package/dist/shared/{packem.CvCdTosN.d.cts → packem.zptSY3F2.d.cts} +13 -1
  24. package/package.json +30 -5
  25. /package/dist/rollup/plugins/swc/{index.cjs → swc-plugin.cjs} +0 -0
  26. /package/dist/rollup/plugins/swc/{index.d.cts → swc-plugin.d.cts} +0 -0
  27. /package/dist/rollup/plugins/swc/{index.d.mts → swc-plugin.d.mts} +0 -0
  28. /package/dist/rollup/plugins/swc/{index.d.ts → swc-plugin.d.ts} +0 -0
  29. /package/dist/rollup/plugins/swc/{index.mjs → swc-plugin.mjs} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## @visulima/packem [1.0.0-alpha.52](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.51...@visulima/packem@1.0.0-alpha.52) (2024-07-18)
2
+
3
+ ### Features
4
+
5
+ * added isolated declarations transformer, added check for peerDependenciesMeta ([8f7ba0d](https://github.com/visulima/packem/commit/8f7ba0d8a52afa6dad9a67ee5cee82096748600c))
6
+
7
+ ## @visulima/packem [1.0.0-alpha.51](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.50...@visulima/packem@1.0.0-alpha.51) (2024-07-17)
8
+
9
+ ### Bug Fixes
10
+
11
+ * stop delete on source folder, added decorator to swc, removed custom error ([449f93c](https://github.com/visulima/packem/commit/449f93ccd2e3174a7161dc96976bfe537817586b))
12
+
1
13
  ## @visulima/packem [1.0.0-alpha.50](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.49...@visulima/packem@1.0.0-alpha.50) (2024-07-17)
2
14
 
3
15
  ### Bug Fixes
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- var Et=Object.defineProperty;var m=(e,t)=>Et(e,"name",{value:t,configurable:!0});import Ot from"@visulima/cerebro";import{SimpleReporter as St}from"@visulima/pail/reporter";import{env as E,versions as Dt,cwd as Nt,exit as Pt}from"node:process";import{chmod as _t,stat as Fe,readdir as Ct}from"node:fs/promises";import ye from"node:module";import{cyan as v,bold as S,gray as M,yellow as Mt,grey as It,green as Ft}from"@visulima/colorize";import{readFile as oe,writeFile as J,isAccessibleSync as O,collectSync as Rt,readFileSync as Re,writeFileSync as re,writeJsonSync as Tt,ensureDirSync as At,emptyDir as Te,walk as Bt,isAccessible as Jt}from"@visulima/fs";import{NotFoundError as Wt}from"@visulima/fs/error";import{formatBytes as _,duration as Lt}from"@visulima/humanizer";import{parsePackageJson as Ae}from"@visulima/package/package-json";import{resolve as h,join as b,normalize as ne,extname as se,relative as P,dirname as ie,basename as V,isAbsolute as Be,toNamespacedPath as ve}from"@visulima/path";import{readTsConfig as zt,findTsConfig as Ut}from"@visulima/tsconfig";import{defu as Vt}from"defu";import{createHooks as Ht}from"hookable";import{rollup as Je,watch as be,VERSION as qt}from"rollup";import{DEFAULTS as Gt,nodeResolve as We}from"@rollup/plugin-node-resolve";import{pathToFileURL as Yt,fileURLToPath as Kt}from"node:url";import{resolvePath as Xt,resolveModuleExportNames as Zt,findStaticImports as Le}from"mlly";import N from"magic-string";import ze from"jiti";import{existsSync as ae,rmSync as Qt}from"node:fs";import Ue from"@rollup/plugin-alias";import eo from"@rollup/plugin-commonjs";import to from"@rollup/plugin-dynamic-import-vars";import Ve from"@rollup/plugin-replace";import{wasm as oo}from"@rollup/plugin-wasm";import ro from"rollup-plugin-polyfill-node";import{visualizer as no}from"rollup-plugin-visualizer";import{minVersion as He}from"semver";import{glob as so}from"glob";import io from"glob-parent";import ao from"@rollup/plugin-json";import{createFilter as le,normalizePath as $e}from"@rollup/pluginutils";import lo from"rollup-plugin-license";import{createHash as co}from"node:crypto";import{parse as po}from"@babel/parser";import{findCacheDirSync as uo}from"@visulima/find-cache-dir";import{distance as mo}from"fastest-levenshtein";import{installPackage as fo}from"@antfu/install-pkg";import{intro as go,isCancel as ho,cancel as yo,select as vo,confirm as bo,spinner as we,outro as $o}from"@clack/prompts";
2
+ var Dt=Object.defineProperty;var m=(e,t)=>Dt(e,"name",{value:t,configurable:!0});import St from"@visulima/cerebro";import{SimpleReporter as Nt}from"@visulima/pail/reporter";import{env as E,versions as Pt,cwd as _t,exit as Ct}from"node:process";import{chmod as Mt,stat as Te,readdir as It}from"node:fs/promises";import be from"node:module";import{cyan as v,bold as S,gray as M,yellow as Ft,grey as Rt,green as Tt}from"@visulima/colorize";import{readFile as ie,writeFile as J,isAccessibleSync as O,collectSync as At,readFileSync as Ae,writeFileSync as ae,writeJsonSync as Bt,ensureDirSync as Jt,emptyDir as Be,walk as Wt,isAccessible as Lt}from"@visulima/fs";import{NotFoundError as zt}from"@visulima/fs/error";import{formatBytes as _,duration as Ut}from"@visulima/humanizer";import{parsePackageJson as Je}from"@visulima/package/package-json";import{resolve as h,join as b,normalize as le,extname as ce,relative as D,dirname as H,basename as q,sep as W,isAbsolute as We,toNamespacedPath as $e}from"@visulima/path";import{readTsConfig as Vt,findTsConfig as Ht}from"@visulima/tsconfig";import{defu as qt}from"defu";import{createHooks as Gt}from"hookable";import{rollup as Le,watch as we,VERSION as Yt}from"rollup";import{DEFAULTS as Kt,nodeResolve as ze}from"@rollup/plugin-node-resolve";import{pathToFileURL as Xt,fileURLToPath as Zt}from"node:url";import{resolvePath as Qt,resolveModuleExportNames as eo,findStaticImports as Ue}from"mlly";import P from"magic-string";import Ve from"jiti";import{existsSync as pe,rmSync as to}from"node:fs";import He from"@rollup/plugin-alias";import oo from"@rollup/plugin-commonjs";import ro from"@rollup/plugin-dynamic-import-vars";import qe from"@rollup/plugin-replace";import{wasm as no}from"@rollup/plugin-wasm";import so from"rollup-plugin-polyfill-node";import{visualizer as io}from"rollup-plugin-visualizer";import{minVersion as Ge}from"semver";import{glob as ao}from"glob";import lo from"glob-parent";import{createFilter as G,normalizePath as je}from"@rollup/pluginutils";import co from"@rollup/plugin-json";import po from"rollup-plugin-license";import{createHash as uo}from"node:crypto";import{parse as mo}from"@babel/parser";import{findCacheDirSync as fo}from"@visulima/find-cache-dir";import{distance as go}from"fastest-levenshtein";import{installPackage as ho}from"@antfu/install-pkg";import{intro as yo,isCancel as vo,cancel as bo,select as $o,confirm as wo,spinner as ke,outro as jo}from"@clack/prompts";
3
3
  // -- pack CommonJS Shims --
4
4
  import __cjs_url__ from "node:url";
5
5
  import __cjs_path__ from "node:path";
@@ -7,39 +7,39 @@ import __cjs_mod__ from "node:module";
7
7
  const __filename = __cjs_url__.fileURLToPath(import.meta.url);
8
8
  const __dirname = __cjs_path__.dirname(__filename);
9
9
  const require = __cjs_mod__.createRequire(import.meta.url);
10
- const wo="@visulima/packem",jo="1.0.0-alpha.49",F=[...Gt.extensions,".cjs",".ts",".cts",".mts",".tsx",".jsx"],ko=["development","production"],qe=["react-server","react-native","edge-light"];[...ko,...qe];const je=/node_modules/;var xo=Object.defineProperty,H=m((e,t)=>xo(e,"name",{value:t,configurable:!0}),"i$d");const ce=/^#![^\n]*/,Q=H(async e=>{await _t(e,493).catch(()=>{})},"makeExecutable"),Eo=H((e,t=`#!/usr/bin/env node
11
- `)=>({name:"packem:shebang",renderChunk:{handler(o,n,r){if(!n.isEntry||!n.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(n.name)){const s=new N(o);return s.prepend(t),{code:s.toString(),map:r.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,n){for(const[r,s]of Object.entries(n))if(s.type==="chunk"&&ce.test(s.code)&&o.dir){const i=h(o.dir,r);await Q(i)}}}),"shebangPlugin"),Oo=H(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ce,"")}}),"removeShebangPlugin"),So=H((e,t=`
12
- `)=>{const o=ce.exec(e);return o?o+t:""},"getShebang");var Do=Object.defineProperty,No=m((e,t)=>Do(e,"name",{value:t,configurable:!0}),"p$4");const pe=No((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:n}=e.pkg;for(const r in n){if(r.startsWith("#"))continue;const s=n[r];typeof s=="string"&&(o[r]=b(e.rootDir,s))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(o,e.options.rollup.alias.entries??e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(o),prefix:t}),o},"resolveAliases");var Po=Object.defineProperty,_o=m((e,t)=>Po(e,"name",{value:t,configurable:!0}),"o$3");const Co=_o((e,t)=>{const o=ze(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(n){if(n.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:n});return e}},"tryResolve");var Mo=Object.defineProperty,Io=m((e,t)=>Mo(e,"name",{value:t,configurable:!0}),"r$b");const B=Io((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Fo=Object.defineProperty,Ro=m((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"u$9");const To=Ro(async e=>{const t=await Xt("jiti",{url:import.meta.url}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...pe(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const n of e.options.entries){const r=h(e.options.rootDir,e.options.outDir,n.name),s=ne(Co(n.input,e.options.rootDir)||n.input),i=s.slice(0,Math.max(0,s.length-se(s).length)),a=await oe(s),l=So(a);e.options.emitCJS&&await J(`${r}.cjs`,l+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`module.exports = _jiti(${JSON.stringify(s)})`].join(`
13
- `));let c=[];try{c=await Zt(s,{extensions:F})}catch(u){B(e,`Cannot analyze ${s} for exports: ${u.toString()}`);return}const p=c.includes("default")||c.length===0;await J(`${r}.mjs`,l+[`import jiti from ${JSON.stringify(Yt(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,p?`
10
+ const ko="@visulima/packem",xo="1.0.0-alpha.51",F=[...Kt.extensions,".cjs",".ts",".cts",".mts",".tsx",".jsx"],Eo=["development","production"],Ye=["react-server","react-native","edge-light"];[...Eo,...Ye];const xe=/node_modules/;var Oo=Object.defineProperty,Y=m((e,t)=>Oo(e,"name",{value:t,configurable:!0}),"i$d");const ue=/^#![^\n]*/,oe=Y(async e=>{await Mt(e,493).catch(()=>{})},"makeExecutable"),Do=Y((e,t=`#!/usr/bin/env node
11
+ `)=>({name:"packem:shebang",renderChunk:{handler(o,r,n){if(!r.isEntry||!r.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(r.name)){const s=new P(o);return s.prepend(t),{code:s.toString(),map:n.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,r){for(const[n,s]of Object.entries(r))if(s.type==="chunk"&&ue.test(s.code)&&o.dir){const i=h(o.dir,n);await oe(i)}}}),"shebangPlugin"),So=Y(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ue,"")}}),"removeShebangPlugin"),No=Y((e,t=`
12
+ `)=>{const o=ue.exec(e);return o?o+t:""},"getShebang");var Po=Object.defineProperty,_o=m((e,t)=>Po(e,"name",{value:t,configurable:!0}),"p$5");const de=_o((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:r}=e.pkg;for(const n in r){if(n.startsWith("#"))continue;const s=r[n];typeof s=="string"&&(o[n]=b(e.rootDir,s))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(r=>[r.find,r.replacement]))):Object.assign(o,e.options.rollup.alias.entries??e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(o),prefix:t}),o},"resolveAliases");var Co=Object.defineProperty,Mo=m((e,t)=>Co(e,"name",{value:t,configurable:!0}),"o$3");const Io=Mo((e,t)=>{const o=Ve(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(r){if(r.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:r});return e}},"tryResolve");var Fo=Object.defineProperty,Ro=m((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"r$b");const B=Ro((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var To=Object.defineProperty,Ao=m((e,t)=>To(e,"name",{value:t,configurable:!0}),"u$9");const Bo=Ao(async e=>{const t=await Qt("jiti",{url:import.meta.url}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...de(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const r of e.options.entries){const n=h(e.options.rootDir,e.options.outDir,r.name),s=le(Io(r.input,e.options.rootDir)||r.input),i=s.slice(0,Math.max(0,s.length-ce(s).length)),l=await ie(s),a=No(l);e.options.emitCJS&&await J(`${n}.cjs`,a+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`module.exports = _jiti(${JSON.stringify(s)})`].join(`
13
+ `));let c=[];try{c=await eo(s,{extensions:F})}catch(u){B(e,`Cannot analyze ${s} for exports: ${u.toString()}`);return}const p=c.includes("default")||c.length===0;await J(`${n}.mjs`,a+[`import jiti from ${JSON.stringify(Xt(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,p?`
14
14
  export default _module;`:"",...c.filter(u=>u!=="default").map(u=>`export const ${u} = _module.${u};`)].join(`
15
- `)),await J(`${r}.d.cts`,[`export * from ${JSON.stringify(i)};`,p?`export { default } from ${JSON.stringify(i)};`:""].join(`
16
- `)),await J(`${r}.d.mts`,[`export * from ${JSON.stringify(s)};`,p?`export { default } from ${JSON.stringify(s)};`:""].join(`
17
- `)),l&&(await Q(`${r}.cjs`),await Q(`${r}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Ao=Object.defineProperty,Bo=m((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"r$a");const Ge=Bo((e,t)=>ze(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var Jo=Object.defineProperty,Ye=m((e,t)=>Jo(e,"name",{value:t,configurable:!0}),"t$5");const U=Ye(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Ke=Ye((e,t,o,n)=>{if(o){const i=U(o);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return n==="commonjs"?"cjs":"esm";const[r,...s]=t;return Ke(r,s,o,n)},"inferExportType");var Wo=Object.defineProperty,Lo=m((e,t)=>Wo(e,"name",{value:t,configurable:!0}),"n$a");const ue=Lo((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const r=U(e),s=t==="module"?"esm":"cjs";if(r&&r!==s)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t}".`);return[{file:e,key:"exports",type:r??s}]}return Object.entries(e).filter(([r])=>!r.endsWith(".json")).flatMap(([r,s])=>r==="types"&&o===!1?[]:typeof s=="string"?{file:s,key:"exports",...["browser","default","deno","development","import","node","node-addons","production","require","types"].includes(r)?{subKey:r}:{},type:Ke(r,n,s,t)}:ue(s,t,o,[...n,r]))},"extractExportFilenames");var zo=Object.defineProperty,de=m((e,t)=>zo(e,"name",{value:t,configurable:!0}),"y$2");const Uo=de(e=>{if(e.key==="exports"&&e.subKey==="production")return"production";if(e.key==="exports"&&e.subKey==="development")return"development";if(E.NODE_ENV){if(!E.NODE_ENV.includes("production")&&!E.NODE_ENV.includes("development"))throw new Error(`Invalid NODE_ENV value: ${E.NODE_ENV}, must be either "production" or "development".`);return E.NODE_ENV}return"production"},"getEnvironment"),W=de((e,t,o,n,r,s)=>{const i=e.find(a=>a.input===t)??e[e.push({input:t})-1];if(o&&(i.outDir=n),r.isExecutable)i.executable=!0,i.declaration=!1,r.type==="cjs"&&(i.cjs=!0),r.type==="esm"&&(i.esm=!0);else{/\.d\.[mc]?ts$/.test(r.file)&&s!==!1&&(i.declaration=s),r.type==="cjs"&&(i.cjs=!0),r.type==="esm"&&(i.esm=!0);for(const a of qe)if(r.file.includes("."+a+".")){i.runtime=a;break}}i.runtime===void 0&&(i.runtime="node"),i.environment=Uo(r)},"createOrUpdateEntry"),ke=/(?:\.d\.[mc]?ts|\.\w+)$/;let xe=!1;const Vo=de((e,t,o)=>{const n=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const r=e.type==="module"?"esm":"cjs",s=ue(e.exports,e.type??"commonjs",o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=U(l);if(c&&c!==r)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type}".`);s.push({file:l,isExecutable:!0,key:"bin",type:c??r})}}e.main&&s.push({file:e.main,key:"main",type:U(e.main)??r}),e.module&&s.push({file:e.module,key:"module",type:"esm"}),o.options.declaration!==!1&&(e.types||e.typings)&&s.push({file:e.types??e.typings,key:"types"});const i=[];for(const a of s){const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const p=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./","");if(a.file.includes("/*")&&a.key==="exports"){xe||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),xe=!0);const g=[],f=new RegExp("(?<=/|$)"+p.replace("*","(.*)")+(c?"":"\\.\\w+"));for(const $ of t)f.test($)&&g.push($.replace(ke,""));if(g.length===0){n.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const $ of g)W(i,$,c,l,a,o.options.declaration);continue}const u=new RegExp("(?<=/|$)"+p+(c?"":"\\.\\w+")),d=t.find(g=>u.test(g))?.replace(ke,"");if(!d){ae(h(o.options.rootDir,a.file))||n.push(`Could not find entrypoint for \`${a.file}\``);continue}O(d+".cts")&&O(d+".mts")?(W(i,d+".cts",c,l,{...a,type:"cjs"},o.options.declaration),W(i,d+".mts",c,l,{...a,type:"esm"},o.options.declaration)):W(i,d,c,l,a,o.options.declaration)}return{entries:i,warnings:n}},"inferEntries");var Ho=Object.defineProperty,qo=m((e,t)=>Ho(e,"name",{value:t,configurable:!0}),"t$4");const Go=qo((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var Yo=Object.defineProperty,Ko=m((e,t)=>Yo(e,"name",{value:t,configurable:!0}),"n$8");const Xo={hooks:{"build:prepare":Ko(function(e){if(e.options.entries.length>0)return;const t=b(e.options.rootDir,"src");if(!ae(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=Rt(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};n.publishConfig&&(n=Go(n,e.options.declaration));const r=Vo(n,o,e);for(const s of r.warnings)B(e,s);if(e.options.entries.push(...r.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",v(e.options.entries.map(s=>S(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),M([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var Zo=Object.defineProperty,Qo=m((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"t$3");const er=Qo((e,t)=>(e==="auto"?e=Xo:typeof e=="string"&&(e=Ge(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var tr=Object.defineProperty,or=m((e,t)=>tr(e,"name",{value:t,configurable:!0}),"a$c");const ee=or((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var rr=Object.defineProperty,nr=m((e,t)=>rr(e,"name",{value:t,configurable:!0}),"a$b");const q=nr(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var sr=Object.defineProperty,ir=m((e,t)=>sr(e,"name",{value:t,configurable:!0}),"a$a");const te=ir((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var ar=Object.defineProperty,Xe=m((e,t)=>ar(e,"name",{value:t,configurable:!0}),"s$a");const lr=Xe((e,t,o)=>{const n=o??new Map;return(...r)=>{const s=t?typeof t=="function"?t(...r):t:JSON.stringify({args:r}),i=n.get(s);if(i!==void 0)return i;const a=e(...r);return n.set(s,a),a}},"memoize"),cr=Xe(e=>{const t=new Map;return o=>lr(e,o,t)},"memoizeByKey");var pr=Object.defineProperty,ur=m((e,t)=>pr(e,"name",{value:t,configurable:!0}),"m$5");const Ze=ur(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(n,r,s){if(r.type!=="chunk"||!r.isEntry)return null;if(s.format==="cjs"&&s.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(i===null||i.length<3)return null;const a=new N(n);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
18
- module.exports.default = `+i[2]+";");let l=a.toString();return l=l.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:l,map:a.generateMap({hires:!0})}}if(s.format==="es"&&/\.d\.(?:ts|cts)$/.test(r.fileName)){if(o!=="commonjs"&&r.fileName.endsWith(".d.ts"))return null;const i=/export\s\{\s(.*)\s\}/i.exec(n);if(i===null||i.length<2)return null;const a=i[1].split(", "),l=[];let c="";for(const u of a)if(!u.includes("type"))if(u.includes("as")){const[d,g]=u.split(" as ");if(g==="default"&&(c=d,!e))continue;l.push(g+": typeof "+d+";")}else l.push(u+": typeof "+u+";");const p=new N(n);return p.replace(" "+c+" as default,",""),p.append(`
15
+ `)),await J(`${n}.d.cts`,[`export * from ${JSON.stringify(i)};`,p?`export { default } from ${JSON.stringify(i)};`:""].join(`
16
+ `)),await J(`${n}.d.mts`,[`export * from ${JSON.stringify(s)};`,p?`export { default } from ${JSON.stringify(s)};`:""].join(`
17
+ `)),a&&(await oe(`${n}.cjs`),await oe(`${n}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Jo=Object.defineProperty,Wo=m((e,t)=>Jo(e,"name",{value:t,configurable:!0}),"r$a");const Ke=Wo((e,t)=>Ve(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var Lo=Object.defineProperty,Xe=m((e,t)=>Lo(e,"name",{value:t,configurable:!0}),"t$5");const V=Xe(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Ze=Xe((e,t,o,r)=>{if(o){const i=V(o);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return r==="commonjs"?"cjs":"esm";const[n,...s]=t;return Ze(n,s,o,r)},"inferExportType");var zo=Object.defineProperty,Uo=m((e,t)=>zo(e,"name",{value:t,configurable:!0}),"n$a");const me=Uo((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=V(e),s=t==="module"?"esm":"cjs";if(n&&n!==s)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t}".`);return[{file:e,key:"exports",type:n??s}]}return Object.entries(e).filter(([n])=>!n.endsWith(".json")).flatMap(([n,s])=>n==="types"&&o===!1?[]:typeof s=="string"?{file:s,key:"exports",...["browser","default","deno","development","import","node","node-addons","production","require","types"].includes(n)?{subKey:n}:{},type:Ze(n,r,s,t)}:me(s,t,o,[...r,n]))},"extractExportFilenames");var Vo=Object.defineProperty,fe=m((e,t)=>Vo(e,"name",{value:t,configurable:!0}),"y$2");const Ho=fe(e=>{if(e.key==="exports"&&e.subKey==="production")return"production";if(e.key==="exports"&&e.subKey==="development")return"development";if(E.NODE_ENV){if(!E.NODE_ENV.includes("production")&&!E.NODE_ENV.includes("development"))throw new Error(`Invalid NODE_ENV value: ${E.NODE_ENV}, must be either "production" or "development".`);return E.NODE_ENV}return"production"},"getEnvironment"),L=fe((e,t,o,r,n,s)=>{const i=e.find(l=>l.input===t)??e[e.push({input:t})-1];if(o&&(i.outDir=r),n.isExecutable)i.executable=!0,i.declaration=!1,n.type==="cjs"&&(i.cjs=!0),n.type==="esm"&&(i.esm=!0);else{/\.d\.[mc]?ts$/.test(n.file)&&s!==!1&&(i.declaration=s),n.type==="cjs"&&(i.cjs=!0),n.type==="esm"&&(i.esm=!0);for(const l of Ye)if(n.file.includes("."+l+".")){i.runtime=l;break}}i.runtime===void 0&&(i.runtime="node"),i.environment=Ho(n)},"createOrUpdateEntry"),Ee=/(?:\.d\.[mc]?ts|\.\w+)$/;let Oe=!1;const qo=fe((e,t,o)=>{const r=[];t.sort((l,a)=>l.split("/").length-a.split("/").length);const n=e.type==="module"?"esm":"cjs",s=me(e.exports,e.type??"commonjs",o.options.declaration);if(e.bin){const l=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const a of l){const c=V(a);if(c&&c!==n)throw new Error(`Exported file "${a}" has an extension that does not match the package.json type "${e.type}".`);s.push({file:a,isExecutable:!0,key:"bin",type:c??n})}}e.main&&s.push({file:e.main,key:"main",type:V(e.main)??n}),e.module&&s.push({file:e.module,key:"module",type:"esm"}),o.options.declaration!==!1&&(e.types||e.typings)&&s.push({file:e.types??e.typings,key:"types"});const i=[];for(const l of s){const a=l.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=a.endsWith("/");if(c&&["./","/"].includes(a))continue;const p=a.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./","");if(l.file.includes("/*")&&l.key==="exports"){Oe||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Oe=!0);const g=[],f=new RegExp("(?<=/|$)"+p.replace("*","(.*)")+(c?"":"\\.\\w+"));for(const $ of t)f.test($)&&g.push($.replace(Ee,""));if(g.length===0){r.push(`Could not find entrypoint for \`${l.file}\``);continue}for(const $ of g)L(i,$,c,a,l,o.options.declaration);continue}const u=new RegExp("(?<=/|$)"+p+(c?"":"\\.\\w+")),d=t.find(g=>u.test(g))?.replace(Ee,"");if(!d){pe(h(o.options.rootDir,l.file))||r.push(`Could not find entrypoint for \`${l.file}\``);continue}O(d+".cts")&&O(d+".mts")?(L(i,d+".cts",c,a,{...l,type:"cjs"},o.options.declaration),L(i,d+".mts",c,a,{...l,type:"esm"},o.options.declaration)):L(i,d,c,a,l,o.options.declaration)}return{entries:i,warnings:r}},"inferEntries");var Go=Object.defineProperty,Yo=m((e,t)=>Go(e,"name",{value:t,configurable:!0}),"t$4");const Ko=Yo((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var Xo=Object.defineProperty,Zo=m((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"n$8");const Qo={hooks:{"build:prepare":Zo(function(e){if(e.options.entries.length>0)return;const t=b(e.options.rootDir,"src");if(!pe(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=At(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let r={...e.pkg};r.publishConfig&&(r=Ko(r,e.options.declaration));const n=qo(r,o,e);for(const s of n.warnings)B(e,s);if(e.options.entries.push(...n.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",v(e.options.entries.map(s=>S(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),M([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var er=Object.defineProperty,tr=m((e,t)=>er(e,"name",{value:t,configurable:!0}),"t$3");const or=tr((e,t)=>(e==="auto"?e=Qo:typeof e=="string"&&(e=Ke(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var rr=Object.defineProperty,nr=m((e,t)=>rr(e,"name",{value:t,configurable:!0}),"a$c");const re=nr((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var sr=Object.defineProperty,ir=m((e,t)=>sr(e,"name",{value:t,configurable:!0}),"a$b");const K=ir(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var ar=Object.defineProperty,lr=m((e,t)=>ar(e,"name",{value:t,configurable:!0}),"a$a");const ne=lr((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var cr=Object.defineProperty,Qe=m((e,t)=>cr(e,"name",{value:t,configurable:!0}),"s$a");const pr=Qe((e,t,o)=>{const r=o??new Map;return(...n)=>{const s=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),i=r.get(s);if(i!==void 0)return i;const l=e(...n);return r.set(s,l),l}},"memoize"),ur=Qe(e=>{const t=new Map;return o=>pr(e,o,t)},"memoizeByKey");var dr=Object.defineProperty,mr=m((e,t)=>dr(e,"name",{value:t,configurable:!0}),"m$5");const et=mr(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(r,n,s){if(n.type!=="chunk"||!n.isEntry)return null;if(s.format==="cjs"&&s.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(i===null||i.length<3)return null;const l=new P(r);l.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),l.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&l.append(`
18
+ module.exports.default = `+i[2]+";");let a=l.toString();return a=a.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:a,map:l.generateMap({hires:!0})}}if(s.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)){if(o!=="commonjs"&&n.fileName.endsWith(".d.ts"))return null;const i=/export\s\{\s(.*)\s\}/i.exec(r);if(i===null||i.length<2)return null;const l=i[1].split(", "),a=[];let c="";for(const u of l)if(!u.includes("type"))if(u.includes("as")){const[d,g]=u.split(" as ");if(g==="default"&&(c=d,!e))continue;a.push(g+": typeof "+d+";")}else a.push(u+": typeof "+u+";");const p=new P(r);return p.replace(" "+c+" as default,",""),p.append(`
19
19
 
20
20
  declare const defaultExport: {
21
- `+(l.length>0?" ":"")+l.join(`
21
+ `+(a.length>0?" ":"")+a.join(`
22
22
  `)+`
23
23
  } & typeof `+c+`;
24
24
 
25
- export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:p.toString(),map:p.generateMap({hires:!0})}}return null}}),"cjsInterop");var dr=Object.defineProperty,mr=m((e,t)=>dr(e,"name",{value:t,configurable:!0}),"f$6");const fr=mr((e,t)=>{const o=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:r}=n;return Array.isArray(r)?r=r.map(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof r=="string"&&(r=[{src:r}]),{async buildStart(){const s=await Promise.all(r.flatMap(i=>Array.isArray(i.src)?i.src.map(a=>({...i,src:a})):i).map(async i=>await so(i.src,{ignore:i.exclude}).then(a=>({dest:i.dest??"",parent:io(i.src),src:a}))));for(const i of s)for(const a of i.src){let l;o.has(a)?l=o.get(a):(l={copied:[],dest:[],timestamp:0},o.set(a,l));const c=n.flatten?ne(i.dest):b(i.dest,P(i.parent,ie(a)));l.dest.includes(c)||l.dest.push(c),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,a])=>{let l;try{const c=await Fe(i);if(!c.isFile())return;const p=c.mtime.getTime();p>a.timestamp&&(a.timestamp=p,a.copied=[]),l=await oe(i,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const c of a.dest){if(n.copyOnce&&a.copied.includes(c))continue;const p=V(i),u=b(c,p);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:u,source:l,type:"asset"}),t.debug({message:`copied ${i} → ${u}`,prefix:"plugin:copy"}),a.copied.push(c)}catch(d){t.error({context:[d],message:`error copying file ${i} → ${u}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var gr=Object.defineProperty,hr=m((e,t)=>gr(e,"name",{value:t,configurable:!0}),"n$4");const Ee="export default ",Qe=hr(e=>{const t=ao(e);return{...t,name:"packem:json",transform(o,n){const r=t.transform?.call(this,o,n);return r&&typeof r!="string"&&"code"in r&&r.code?.startsWith(Ee)&&(r.code=r.code.replace(Ee,"module.exports = ")),r}}},"JSONPlugin");class yr{static{m(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(t=>this.replacement=t,"replace")}}replace(t,o,n,r){t&&o&&(n!=null?t[o][n]=r:t[o]=r)}remove(t,o,n){t&&o&&(n!=null?t[o].splice(n,1):delete t[o])}}class vr extends yr{static{m(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(n=>this.replacement=n,"replace")},this.enter=t,this.leave=o}visit(t,o,n,r){if(t){if(this.enter){const i=this.should_skip,a=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const c=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=a,this.replacement=l,c)return t;if(p)return null}let s;for(s in t){const i=t[s];if(i&&typeof i=="object")if(Array.isArray(i)){const a=i;for(let l=0;l<a.length;l+=1){const c=a[l];Oe(c)&&(this.visit(c,t,s,l)||l--)}}else Oe(i)&&this.visit(i,t,s,null)}if(this.leave){const i=this.replacement,a=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const l=this.should_remove;if(this.replacement=i,this.should_remove=a,l)return null}}return t}}function Oe(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(Oe,"isNode");function et(e,{enter:t,leave:o}){return new vr(t,o).visit(e,null)}m(et,"walk");var br=Object.defineProperty,$r=m((e,t)=>br(e,"name",{value:t,configurable:!0}),"u$7");const wr=$r(({attributes:e,logger:t})=>{const o=le([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(n,r){if(!o(r))return null;let s=null;try{s=this.parse(n,{allowReturnOutsideFunction:!0})}catch(l){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${r}" and remove the jsx attribute.`}),t.warn(l),null}let i=!1;const a=new N(n);return et(s,{enter(l){if(l.type==="CallExpression"&&l.callee.type==="Identifier"&&l.callee.name==="jsx"){const c=l.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of c)for(const u of p.properties)u.type==="Property"&&u.key.type==="Literal"&&u.value.type==="Literal"&&e.includes(u.key.value)&&(a.overwrite(u.start-2,u.end,""),i=!0)}}}),i?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var jr=Object.defineProperty,me=m((e,t)=>jr(e,"name",{value:t,configurable:!0}),"p$2");const kr=me(e=>{const t=[],o=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):o.push(n)}),[...o.sort(),...t.sort()]},"sortLicenses"),xr=me((e,t,o)=>{const n=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(n.test(e))return e.replace(n,`$1
25
+ export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:p.toString(),map:p.generateMap({hires:!0})}}return null}}),"cjsInterop");var fr=Object.defineProperty,gr=m((e,t)=>fr(e,"name",{value:t,configurable:!0}),"f$6");const hr=gr((e,t)=>{const o=new Map,r={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:n}=r;return Array.isArray(n)?n=n.map(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof n=="string"&&(n=[{src:n}]),{async buildStart(){const s=await Promise.all(n.flatMap(i=>Array.isArray(i.src)?i.src.map(l=>({...i,src:l})):i).map(async i=>await ao(i.src,{ignore:i.exclude}).then(l=>({dest:i.dest??"",parent:lo(i.src),src:l}))));for(const i of s)for(const l of i.src){let a;o.has(l)?a=o.get(l):(a={copied:[],dest:[],timestamp:0},o.set(l,a));const c=r.flatten?le(i.dest):b(i.dest,D(i.parent,H(l)));a.dest.includes(c)||a.dest.push(c),this.addWatchFile(l)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,l])=>{let a;try{const c=await Te(i);if(!c.isFile())return;const p=c.mtime.getTime();p>l.timestamp&&(l.timestamp=p,l.copied=[]),a=await ie(i,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const c of l.dest){if(r.copyOnce&&l.copied.includes(c))continue;const p=q(i),u=b(c,p);try{this.emitFile({[r.exactFileNames?"fileName":"name"]:u,source:a,type:"asset"}),t.debug({message:`copied ${i} → ${u}`,prefix:"plugin:copy"}),l.copied.push(c)}catch(d){t.error({context:[d],message:`error copying file ${i} → ${u}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var yr=Object.defineProperty,se=m((e,t)=>yr(e,"name",{value:t,configurable:!0}),"l$5");const vr=se((...e)=>{if(e.length===0)return"";if(e.length===1)return H(e[0]);const[t,...o]=e;let r=t.split(W);for(const n of o){const s=n.split(W,r.length);let i=0;for(const l of s)if(l===r[i])i+=1;else{r=r.slice(0,i);break}r=r.slice(0,i)}return r.length<=1&&r[0]===""?W+r[0]:r.join(W)},"lowestCommonAncestor"),br=se((e,t={})=>{const o=G(t.include,t.exclude),r={},n=se((s,i)=>{r[s.replace(/\..?[jt]s$/,"")]=i},"addOutput");return{name:"packem:isolated-declarations",renderStart(s,i){let l="",{input:a}=i;if(a=typeof a=="string"?[a]:a,Array.isArray(a)&&(l=vr(...a)),typeof s.entryFileNames!="string")return this.error("entryFileNames must be a string");const c=s.entryFileNames.replace(/\.(.)?[jt]s$/,(p,u)=>`.d.${u||""}ts`);for(const[p,u]of Object.entries(r))this.emitFile({fileName:c.replace("[name]",D(l,p)),source:u,type:"asset"})},async transform(s,i){if(!o(s))return;const l=await e(s,i),{errors:a,sourceText:c}=l;a.length>0?t.ignoreErrors?this.warn(a[0]):this.error(a[0]):n(s,c)}}},"isolatedDeclarationsPlugin");var $r=Object.defineProperty,wr=m((e,t)=>$r(e,"name",{value:t,configurable:!0}),"n$4");const De="export default ",tt=wr(e=>{const t=co(e);return{...t,name:"packem:json",transform(o,r){const n=t.transform?.call(this,o,r);return n&&typeof n!="string"&&"code"in n&&n.code?.startsWith(De)&&(n.code=n.code.replace(De,"module.exports = ")),n}}},"JSONPlugin");class jr{static{m(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(t=>this.replacement=t,"replace")}}replace(t,o,r,n){t&&o&&(r!=null?t[o][r]=n:t[o]=n)}remove(t,o,r){t&&o&&(r!=null?t[o].splice(r,1):delete t[o])}}class kr extends jr{static{m(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(r=>this.replacement=r,"replace")},this.enter=t,this.leave=o}visit(t,o,r,n){if(t){if(this.enter){const i=this.should_skip,l=this.should_remove,a=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,r,n),this.replacement&&(t=this.replacement,this.replace(o,r,n,t)),this.should_remove&&this.remove(o,r,n);const c=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=l,this.replacement=a,c)return t;if(p)return null}let s;for(s in t){const i=t[s];if(i&&typeof i=="object")if(Array.isArray(i)){const l=i;for(let a=0;a<l.length;a+=1){const c=l[a];Se(c)&&(this.visit(c,t,s,a)||a--)}}else Se(i)&&this.visit(i,t,s,null)}if(this.leave){const i=this.replacement,l=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,r,n),this.replacement&&(t=this.replacement,this.replace(o,r,n,t)),this.should_remove&&this.remove(o,r,n);const a=this.should_remove;if(this.replacement=i,this.should_remove=l,a)return null}}return t}}function Se(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(Se,"isNode");function ot(e,{enter:t,leave:o}){return new kr(t,o).visit(e,null)}m(ot,"walk");var xr=Object.defineProperty,Er=m((e,t)=>xr(e,"name",{value:t,configurable:!0}),"u$7");const Or=Er(({attributes:e,logger:t})=>{const o=G([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(r,n){if(!o(n))return null;let s=null;try{s=this.parse(r,{allowReturnOutsideFunction:!0})}catch(a){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${n}" and remove the jsx attribute.`}),t.warn(a),null}let i=!1;const l=new P(r);return ot(s,{enter(a){if(a.type==="CallExpression"&&a.callee.type==="Identifier"&&a.callee.name==="jsx"){const c=a.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of c)for(const u of p.properties)u.type==="Property"&&u.key.type==="Literal"&&u.value.type==="Literal"&&e.includes(u.key.value)&&(l.overwrite(u.start-2,u.end,""),i=!0)}}}),i?{code:l.toString(),map:l.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Dr=Object.defineProperty,ge=m((e,t)=>Dr(e,"name",{value:t,configurable:!0}),"p$2");const Sr=ge(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),Nr=ge((e,t,o)=>{const r=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(r.test(e))return e.replace(r,`$1
26
26
  ${o}
27
- $2`)},"replaceContentWithin"),tt=me(({licenseFilePath:e,licenseTemplate:t,logger:o,marker:n,mode:r,packageName:s})=>lo({thirdParty(i){const a=new Set,l=i.sort(({name:p},{name:u})=>(p||0)>(u||0)?1:(u||0)>(p||0)?-1:0).map(({author:p,contributors:u,license:d,licenseText:g,maintainers:f,name:$,repository:w})=>{let y="## "+$+`
27
+ $2`)},"replaceContentWithin"),rt=ge(({licenseFilePath:e,licenseTemplate:t,logger:o,marker:r,mode:n,packageName:s})=>po({thirdParty(i){const l=new Set,a=i.sort(({name:p},{name:u})=>(p||0)>(u||0)?1:(u||0)>(p||0)?-1:0).map(({author:p,contributors:u,license:d,licenseText:g,maintainers:f,name:$,repository:w})=>{let y="## "+$+`
28
28
  `;d&&(y+=`License: ${d}
29
- `);const R=new Set;for(const T of[p,...f,...u]){const he=typeof T=="string"?T:T?.name;he&&R.add(he)}return R.size>0&&(y+=`By: ${[...R].join(", ")}
29
+ `);const R=new Set;for(const T of[p,...f,...u]){const ve=typeof T=="string"?T:T?.name;ve&&R.add(ve)}return R.size>0&&(y+=`By: ${[...R].join(", ")}
30
30
  `),w&&(y+=`Repository: ${typeof w=="string"?w:w.url}
31
31
  `),g&&(y+=`
32
32
  `+g.trim().replaceAll(/\r\n|\r/g,`
33
33
  `).split(`
34
34
  `).map(T=>`> ${T}`).join(`
35
35
  `)+`
36
- `),d&&a.add(d),y}).join(`
36
+ `),d&&l.add(d),y}).join(`
37
37
  ---------------------------------------
38
38
 
39
- `);if(l===""){o.info({message:"No dependencies license information found.",prefix:"plugin:license:"+r});return}const c=t(kr(a),l,s);try{const p=Re(e),u=xr(p,n,c);if(!u){o.error({message:`Could not find the license marker: <!-- ${n} --> in ${e}`,prefix:"plugin:license:"+r});return}p!==u&&(re(e,u),o.info({message:`${e} updated.`,prefix:"plugin:license:"+r}))}catch(p){o.error(p)}}}),"license");var Er=Object.defineProperty,Or=m((e,t)=>Er(e,"name",{value:t,configurable:!0}),"i$9");const Sr=Or(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const r=this.getModuleInfo(n);if(r!=null&&!r.isExternal)for(const s of r.importedIds)t.push({source:n,target:s})}if(Array.isArray(t)&&t.length===0)return;const o=h(e.rootDir,e.outDir,"graph.json");Tt(o,t)},name:"packem:metafile"}),"metafilePlugin");var Dr=Object.defineProperty,Nr=m((e,t)=>Dr(e,"name",{value:t,configurable:!0}),"r$7");const C=Nr(e=>{const t=co("md5");return t.update(e),t.digest("hex")},"getHash");var Pr=Object.defineProperty,ot=m((e,t)=>Pr(e,"name",{value:t,configurable:!0}),"m$4");const A=ot(e=>e.handler||e,"getHandler"),x=ot((e,t)=>({...e,async buildEnd(o){e.buildEnd&&await A(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await A(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const n=b("load",C(o));if(t.has(n,e.name))return await t.get(n,e.name);const r=await A(e.load).call(this,o);return t.set(n,r,e.name),r},name:`cached(${e.name})`,async resolveId(o,n,r){if(!e.resolveId)return null;const s=b("resolveId",C(o),n?C(n):"",C(JSON.stringify(r)));if(t.has(s,e.name))return await t.get(s,e.name);const i=await A(e.resolveId).call(this,o,n,r);return t.set(s,i,e.name),i},async transform(o,n){if(!e.transform)return null;const r=b("transform",C(n),C(o));if(t.has(r,e.name))return await t.get(r,e.name);const s=await A(e.transform).call(this,o,n);return t.set(r,s,e.name),s}}),"cachingPlugin");var _r=Object.defineProperty,Cr=m((e,t)=>_r(e,"name",{value:t,configurable:!0}),"c$6");const Mr=/\.(?:m|c)?(?:j|t)sx?$/,Ir=/^use \w+$/,Fr=Cr(e=>{const t={},o={};return{name:"packem:preserve-directives",onLog(n,r){return r.code==="MODULE_LEVEL_DIRECTIVE"&&n==="warn"?!1:null},renderChunk:{handler(n,r,{sourcemap:s}){const i=r.moduleIds.map(c=>t[c]?t[c]:null).reduce((c,p)=>(p&&p.forEach(u=>{c.add(u)}),c),new Set),a=new N(n);i.size>0&&(e.debug({message:`directives for chunk "${r.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${[...i].map(c=>`'${c}';`).join(`
39
+ `);if(a===""){o.info({message:"No dependencies license information found.",prefix:"plugin:license:"+n});return}const c=t(Sr(l),a,s);try{const p=Ae(e),u=Nr(p,r,c);if(!u){o.error({message:`Could not find the license marker: <!-- ${r} --> in ${e}`,prefix:"plugin:license:"+n});return}p!==u&&(ae(e,u),o.info({message:`${e} updated.`,prefix:"plugin:license:"+n}))}catch(p){o.error(p)}}}),"license");var Pr=Object.defineProperty,_r=m((e,t)=>Pr(e,"name",{value:t,configurable:!0}),"i$9");const Cr=_r(e=>({async buildEnd(){const t=[];for(const r of this.getModuleIds()){const n=this.getModuleInfo(r);if(n!=null&&!n.isExternal)for(const s of n.importedIds)t.push({source:r,target:s})}if(Array.isArray(t)&&t.length===0)return;const o=h(e.rootDir,e.outDir,"graph.json");Bt(o,t)},name:"packem:metafile"}),"metafilePlugin");var Mr=Object.defineProperty,Ir=m((e,t)=>Mr(e,"name",{value:t,configurable:!0}),"r$7");const C=Ir(e=>{const t=uo("md5");return t.update(e),t.digest("hex")},"getHash");var Fr=Object.defineProperty,nt=m((e,t)=>Fr(e,"name",{value:t,configurable:!0}),"m$4");const A=nt(e=>e.handler||e,"getHandler"),x=nt((e,t)=>({...e,async buildEnd(o){e.buildEnd&&await A(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await A(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const r=b("load",C(o));if(t.has(r,e.name))return await t.get(r,e.name);const n=await A(e.load).call(this,o);return t.set(r,n,e.name),n},name:`cached(${e.name})`,async resolveId(o,r,n){if(!e.resolveId)return null;const s=b("resolveId",C(o),r?C(r):"",C(JSON.stringify(n)));if(t.has(s,e.name))return await t.get(s,e.name);const i=await A(e.resolveId).call(this,o,r,n);return t.set(s,i,e.name),i},async transform(o,r){if(!e.transform)return null;const n=b("transform",C(r),C(o));if(t.has(n,e.name))return await t.get(n,e.name);const s=await A(e.transform).call(this,o,r);return t.set(n,s,e.name),s}}),"cachingPlugin");var Rr=Object.defineProperty,Tr=m((e,t)=>Rr(e,"name",{value:t,configurable:!0}),"c$6");const Ar=/\.(?:m|c)?(?:j|t)sx?$/,Br=/^use \w+$/,Jr=Tr(e=>{const t={},o={};return{name:"packem:preserve-directives",onLog(r,n){return n.code==="MODULE_LEVEL_DIRECTIVE"&&r==="warn"?!1:null},renderChunk:{handler(r,n,{sourcemap:s}){const i=n.moduleIds.map(c=>t[c]?t[c]:null).reduce((c,p)=>(p&&p.forEach(u=>{c.add(u)}),c),new Set),l=new P(r);i.size>0&&(e.debug({message:`directives for chunk "${n.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),l.prepend(`${[...i].map(c=>`'${c}';`).join(`
40
40
  `)}
41
- `));let l=null;return r.facadeModuleId&&typeof o[r.facadeModuleId]=="string"&&(l=o[r.facadeModuleId]),l&&(e.debug({message:`shebang for chunk "${r.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${l}
42
- `)),i.size===0&&l===null?null:{code:a.toString(),map:s?a.generateMap({hires:!0}):null}},order:"post"},transform:{handler(n,r){const s=se(r);if(!Mr.test(s))return null;let i=!1;const a=new N(n);if(n.startsWith("#")&&n[1]==="!"){let c=0;for(let p=2,u=n.length;p<u;p++){const d=n.codePointAt(p);if(d===10||d===13||d===8232||d===8233){c=p;break}}c&&(o[r]=n.slice(0,c),a.remove(0,c+1),i=!0,e.debug({message:`shebang for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}let l=null;try{l=this.parse(a.toString(),{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${r}" and extract the directives.`}),e.warn(c),null}if(l.type!=="Program")return null;for(const c of l.body.filter(Boolean)){if(c.type!=="ExpressionStatement")break;let p=null;"directive"in c?p=c.directive:c.expression.type==="Literal"&&typeof c.expression.value=="string"&&Ir.test(c.expression.value)&&(p=c.expression.value),p!=="use strict"&&p&&(t[r]||=new Set,t[r].add(p),"start"in c&&typeof c.start=="number"&&"end"in c&&typeof c.end=="number"&&(a.remove(c.start,c.end),i=!0),e.debug({message:`directive "${p}" for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}return i?{code:a.toString(),map:a.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[r]??[]],shebang:o[r]??null}}}:null},order:"post"}}},"preserveDirectives");var Rr=Object.defineProperty,Tr=m((e,t)=>Rr(e,"name",{value:t,configurable:!0}),"r$6");const Ar={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},Br=Tr((e={})=>{e={...e,...Ar};const t=le(e.include,e.exclude);return{name:"packem:raw",transform(o,n){return t(n)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var Jr=Object.defineProperty,Wr=m((e,t)=>Jr(e,"name",{value:t,configurable:!0}),"l$3");const G="\0__file_url__",rt=Wr(()=>({async load(e){if(e.startsWith(G)){const t=Kt(e.slice(G.length));return await oe(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${G}${e}`}}),"resolveFileUrl");var Lr=Object.defineProperty,nt=m((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"i$5");const zr=/__filename|__dirname|require\(|require\.resolve\(/,st=`
41
+ `));let a=null;return n.facadeModuleId&&typeof o[n.facadeModuleId]=="string"&&(a=o[n.facadeModuleId]),a&&(e.debug({message:`shebang for chunk "${n.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),l.prepend(`${a}
42
+ `)),i.size===0&&a===null?null:{code:l.toString(),map:s?l.generateMap({hires:!0}):null}},order:"post"},transform:{handler(r,n){const s=ce(n);if(!Ar.test(s))return null;let i=!1;const l=new P(r);if(r.startsWith("#")&&r[1]==="!"){let c=0;for(let p=2,u=r.length;p<u;p++){const d=r.codePointAt(p);if(d===10||d===13||d===8232||d===8233){c=p;break}}c&&(o[n]=r.slice(0,c),l.remove(0,c+1),i=!0,e.debug({message:`shebang for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}let a=null;try{a=this.parse(l.toString(),{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${n}" and extract the directives.`}),e.warn(c),null}if(a.type!=="Program")return null;for(const c of a.body.filter(Boolean)){if(c.type!=="ExpressionStatement")break;let p=null;"directive"in c?p=c.directive:c.expression.type==="Literal"&&typeof c.expression.value=="string"&&Br.test(c.expression.value)&&(p=c.expression.value),p!=="use strict"&&p&&(t[n]||=new Set,t[n].add(p),"start"in c&&typeof c.start=="number"&&"end"in c&&typeof c.end=="number"&&(l.remove(c.start,c.end),i=!0),e.debug({message:`directive "${p}" for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}return i?{code:l.toString(),map:l.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[n]??[]],shebang:o[n]??null}}}:null},order:"post"}}},"preserveDirectives");var Wr=Object.defineProperty,Lr=m((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"r$6");const zr={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},Ur=Lr((e={})=>{e={...e,...zr};const t=G(e.include,e.exclude);return{name:"packem:raw",transform(o,r){return t(r)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var Vr=Object.defineProperty,Hr=m((e,t)=>Vr(e,"name",{value:t,configurable:!0}),"l$3");const X="\0__file_url__",st=Hr(()=>({async load(e){if(e.startsWith(X)){const t=Zt(e.slice(X.length));return await ie(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${X}${e}`}}),"resolveFileUrl");var qr=Object.defineProperty,it=m((e,t)=>qr(e,"name",{value:t,configurable:!0}),"i$5");const Gr=/__filename|__dirname|require\(|require\.resolve\(/,at=`
43
43
  // -- pack CommonJS Shims --
44
44
  import __cjs_url__ from "node:url";
45
45
  import __cjs_path__ from "node:path";
@@ -47,34 +47,34 @@ import __cjs_mod__ from "node:module";
47
47
  const __filename = __cjs_url__.fileURLToPath(import.meta.url);
48
48
  const __dirname = __cjs_path__.dirname(__filename);
49
49
  const require = __cjs_mod__.createRequire(import.meta.url);
50
- `,it=`
50
+ `,lt=`
51
51
  // -- pack CommonJS Shims Node 20.11 --
52
52
  import __cjs_mod__ from "node:module";
53
53
  const __filename = import.meta.filename;
54
54
  const __dirname = import.meta.dirname;
55
55
  const require = __cjs_mod__.createRequire(import.meta.url);
56
- `,Ur=nt((e,t)=>{if(E.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(st)||e.includes(it)||!zr.test(e)))return null;const o=Le(e).pop(),n=o?o.end:0,r=new N(e);return r.appendRight(n,t),{code:r.toString(),map:r.generateMap()}},"CJSToESM"),Vr=nt(e=>({name:"packem:cjs",renderChunk(t,o,n){if(n.format==="es"){let r=st;if(e.engines?.node){const s=He(e.engines.node);s&&s.major>=20&&s.minor>=11&&(r=it)}return Ur(t,r)}return null}}),"cjsPlugin");var Hr=Object.defineProperty,I=m((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"r$5");const qr=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Gr=/MIT License|MIT license|BSD license/,Yr=/\n{2,}/g,Kr=/\b(\w+)\$\d+\b/g,Xr=/[-/\\^$*+?.()|[\]{}]/g,Zr=I(e=>e.replaceAll(Xr,"\\$&"),"escapeRegex"),Qr=I(e=>[...new Set(e)],"unique"),en=I(e=>e.replaceAll(qr,t=>Gr.test(t)?"":t).replaceAll(Yr,`
56
+ `,Yr=it((e,t)=>{if(E.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(at)||e.includes(lt)||!Gr.test(e)))return null;const o=Ue(e).pop(),r=o?o.end:0,n=new P(e);return n.appendRight(r,t),{code:n.toString(),map:n.generateMap()}},"CJSToESM"),Kr=it(e=>({name:"packem:cjs",renderChunk(t,o,r){if(r.format==="es"){let n=at;if(e.engines?.node){const s=Ge(e.engines.node);s&&s.major>=20&&s.minor>=11&&(n=lt)}return Yr(t,n)}return null}}),"cjsPlugin");var Xr=Object.defineProperty,I=m((e,t)=>Xr(e,"name",{value:t,configurable:!0}),"r$5");const Zr=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Qr=/MIT License|MIT license|BSD license/,en=/\n{2,}/g,tn=/\b(\w+)\$\d+\b/g,on=/[-/\\^$*+?.()|[\]{}]/g,rn=I(e=>e.replaceAll(on,"\\$&"),"escapeRegex"),nn=I(e=>[...new Set(e)],"unique"),sn=I(e=>e.replaceAll(Zr,t=>Qr.test(t)?"":t).replaceAll(en,`
57
57
 
58
- `),"cleanUnnecessaryComments"),Se=new Map;function at(e,t,{identifierReplacements:o},n){const r=Le(e);for(const i in o){const a=r.find(c=>c.specifier===i&&c.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const l=o[i];for(const c in l){if(!a.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${i}" for replacement`);const p=l[c],u=Zr(c);p.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${u},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${u}\\b`,"g"),p)}}const s=Qr(Array.from(e.matchAll(Kr),i=>i[0]));if(s.length>0){const i=s.map(l=>`
59
- - ${l}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");Se.has(a)||n.warn({message:`${t.fileName} contains confusing identifier names${i}
58
+ `),"cleanUnnecessaryComments"),Ne=new Map;function ct(e,t,{identifierReplacements:o},r){const n=Ue(e);for(const i in o){const l=n.find(c=>c.specifier===i&&c.imports.includes("{"));if(!l){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const a=o[i];for(const c in a){if(!l.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${i}" for replacement`);const p=a[c],u=rn(c);p.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${u},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${u}\\b`,"g"),p)}}const s=nn(Array.from(e.matchAll(tn),i=>i[0]));if(s.length>0){const i=s.map(a=>`
59
+ - ${a}`).join(""),l=t.fileName.replace(/\.[^/.]+$/,"");Ne.has(l)||r.warn({message:`${t.fileName} contains confusing identifier names${i}
60
60
 
61
- To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Se.set(a,!0)}return e}m(at,"I");I(at,"replaceConfusingTypeNames");function lt(e,t){if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1}m(lt,"N");I(lt,"removeInternal");function ct(e,t){if(e.includes("@internal")){const o=new N(e),n=po(e,{plugins:["typescript"],sourceType:"module"});if(et(n,{enter(r){lt(o,r)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}m(ct,"S");I(ct,"stripInternalTypes");const tn=I((e,t)=>({name:"packem:patch-types",renderChunk(o,n){return o=at.call(this,o,n,e,t),o=ct.call(this,o,n),o=en(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var on=Object.defineProperty,pt=m((e,t)=>on(e,"name",{value:t,configurable:!0}),"u$5");const ut=pt((e,t=!0)=>{if(!e)return null;const{config:o,path:n}=e;if(!o.compilerOptions)return null;const{baseUrl:r,paths:s}=o.compilerOptions;if(!r)return null;const i=h(ie(n),r),a=[];if(s)for(const[l,c]of Object.entries(s)){const p=new RegExp(`^${[...l].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let u=0;for(const d of c){const g=[...$e(h(i,d))].map(f=>f==="*"?"$"+(++u+""):f==="$"?"$$":f).join("");a.push({find:p,replacement:g})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...$e(i)].map(l=>l==="$"?"$$":l).join("")}/$1`}),a},"getConfigAlias"),dt=pt((e,t)=>{const o=ut(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,r,s){if(!o||n.includes("\0"))return null;for(const{find:i,replacement:a}of o)if(i.test(n)){const l=n.replace(i,a),c=await this.resolve(l,r,{skipSelf:!0,...s});if(c)return t.debug({message:`Resolved ${n} to ${c.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),c.id}return null}}},"resolveTsconfigPaths");var rn=Object.defineProperty,mt=m((e,t)=>rn(e,"name",{value:t,configurable:!0}),"u$4");const nn=mt((e,t)=>{if(!t)return null;const{config:o,path:n}=t;if(!o.compilerOptions)return null;const{rootDirs:r}=o.compilerOptions;if(!r)return null;const s=[];for(const i of r){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);s.push(h(e,i))}return s},"getRootDirectories"),ft=mt((e,t,o)=>{const n=nn(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(r,s,i){if(n===null||n.length===0)return null;if(r.startsWith("."))for(const a of n){const l=b(a,r),c=await this.resolve(l,s,{skipSelf:!0,...i});if(c)return t.debug({message:`Resolved ${r} to ${c.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),c.id}return null}}},"resolveTsconfigRootDirectories");var sn=Object.defineProperty,an=m((e,t)=>sn(e,"name",{value:t,configurable:!0}),"r$4");const gt=an(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,n){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,n):null}}},"resolveTypescriptMjsCts");var ln=Object.defineProperty,cn=m((e,t)=>ln(e,"name",{value:t,configurable:!0}),"s$6");const pn=cn(e=>{const t=V(e).split(".");if(t.length>=2){const[o,n]=t.slice(-2),r=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(F.includes(n)&&s&&s.length>0)return r+"-"+s}},"getCustomModuleLayer");var un=Object.defineProperty,dn=m((e,t)=>un(e,"name",{value:t,configurable:!0}),"i$4");const Y=dn(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var mn=Object.defineProperty,De=m((e,t)=>mn(e,"name",{value:t,configurable:!0}),"c$4");const Ne=De((e,t)=>{const o=new Map;return De(function(n,r){const s=r.getModuleInfo(n);if(!s)return;const{isEntry:i}=s,a=s.meta,l=Y(a);if(!i){const c=o.get(n);if(c)return c;const p=pn(n);if(p)return o.set(n,p),p}if(i){const c=r.getModuleIds();for(const p of c)r.getModuleInfo(p)&&Y(a)===l&&(e.has(p)||e.set(p,new Set),e.get(p).add([n,l]))}if(l&&!i&&e.has(n)){const c=[...e.get(n)];if(c.some(([u])=>{if(t.some(d=>d.path===u)){const d=r.getModuleInfo(u);return Y(d?d.meta:{})===l}return!1}))return;if(c.every(([,u])=>u===l))return o.has(n)?o.get(n):void 0;const p=`${V(n,se(n))}-${l}`;return o.set(n,p),p}},"splitChunks")},"createSplitChunks");var fn=Object.defineProperty,gn=m((e,t)=>fn(e,"name",{value:t,configurable:!0}),"n$2");const D=gn((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var hn=Object.defineProperty,yn=m((e,t)=>hn(e,"name",{value:t,configurable:!0}),"s$4");const vn=process.platform==="win32",Pe=yn((e,t)=>{const o=vn?"\\":"/";return e.name?.includes("node_modules"+o+".pnpm")?(e.name.replace("node_modules"+o+".pnpm","external")+"."+t).replace("node_modules"+o,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var bn=Object.defineProperty,j=m((e,t)=>bn(e,"name",{value:t,configurable:!0}),"p$1");const $n=j((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let o="node"+Dt.node.split(".")[0];if(t.pkg.engines?.node){const n=He(t.pkg.engines.node);n&&(o="node"+n.major)}if(t.options.rollup.esbuild.target){const n=q(t.options.rollup.esbuild.target);n.some(r=>r.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...q(o),...n])])}else t.options.rollup.esbuild.target=q(o);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{minify:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild,logger:t.logger}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),ht=j((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${v(P(h(),e.id))}"
61
+ To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Ne.set(l,!0)}return e}m(ct,"I");I(ct,"replaceConfusingTypeNames");function pt(e,t){if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1}m(pt,"N");I(pt,"removeInternal");function ut(e,t){if(e.includes("@internal")){const o=new P(e),r=mo(e,{plugins:["typescript"],sourceType:"module"});if(ot(r,{enter(n){pt(o,n)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}m(ut,"S");I(ut,"stripInternalTypes");const an=I((e,t)=>({name:"packem:patch-types",renderChunk(o,r){return o=ct.call(this,o,r,e,t),o=ut.call(this,o,r),o=sn(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var ln=Object.defineProperty,dt=m((e,t)=>ln(e,"name",{value:t,configurable:!0}),"u$5");const mt=dt((e,t=!0)=>{if(!e)return null;const{config:o,path:r}=e;if(!o.compilerOptions)return null;const{baseUrl:n,paths:s}=o.compilerOptions;if(!n)return null;const i=h(H(r),n),l=[];if(s)for(const[a,c]of Object.entries(s)){const p=new RegExp(`^${[...a].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let u=0;for(const d of c){const g=[...je(h(i,d))].map(f=>f==="*"?"$"+(++u+""):f==="$"?"$$":f).join("");l.push({find:p,replacement:g})}}return t&&l.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...je(i)].map(a=>a==="$"?"$$":a).join("")}/$1`}),l},"getConfigAlias"),ft=dt((e,t)=>{const o=mt(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(r,n,s){if(!o||r.includes("\0"))return null;for(const{find:i,replacement:l}of o)if(i.test(r)){const a=r.replace(i,l),c=await this.resolve(a,n,{skipSelf:!0,...s});if(c)return t.debug({message:`Resolved ${r} to ${c.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),c.id}return null}}},"resolveTsconfigPaths");var cn=Object.defineProperty,gt=m((e,t)=>cn(e,"name",{value:t,configurable:!0}),"u$4");const pn=gt((e,t)=>{if(!t)return null;const{config:o,path:r}=t;if(!o.compilerOptions)return null;const{rootDirs:n}=o.compilerOptions;if(!n)return null;const s=[];for(const i of n){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);s.push(h(e,i))}return s},"getRootDirectories"),ht=gt((e,t,o)=>{const r=pn(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,s,i){if(r===null||r.length===0)return null;if(n.startsWith("."))for(const l of r){const a=b(l,n),c=await this.resolve(a,s,{skipSelf:!0,...i});if(c)return t.debug({message:`Resolved ${n} to ${c.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),c.id}return null}}},"resolveTsconfigRootDirectories");var un=Object.defineProperty,dn=m((e,t)=>un(e,"name",{value:t,configurable:!0}),"r$4");const yt=dn(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,r){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,r):null}}},"resolveTypescriptMjsCts");var mn=Object.defineProperty,fn=m((e,t)=>mn(e,"name",{value:t,configurable:!0}),"s$6");const gn=fn(e=>{const t=q(e).split(".");if(t.length>=2){const[o,r]=t.slice(-2),n=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(F.includes(r)&&s&&s.length>0)return n+"-"+s}},"getCustomModuleLayer");var hn=Object.defineProperty,yn=m((e,t)=>hn(e,"name",{value:t,configurable:!0}),"i$4");const Z=yn(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var vn=Object.defineProperty,Pe=m((e,t)=>vn(e,"name",{value:t,configurable:!0}),"c$4");const _e=Pe((e,t)=>{const o=new Map;return Pe(function(r,n){const s=n.getModuleInfo(r);if(!s)return;const{isEntry:i}=s,l=s.meta,a=Z(l);if(!i){const c=o.get(r);if(c)return c;const p=gn(r);if(p)return o.set(r,p),p}if(i){const c=n.getModuleIds();for(const p of c)n.getModuleInfo(p)&&Z(l)===a&&(e.has(p)||e.set(p,new Set),e.get(p).add([r,a]))}if(a&&!i&&e.has(r)){const c=[...e.get(r)];if(c.some(([u])=>{if(t.some(d=>d.path===u)){const d=n.getModuleInfo(u);return Z(d?d.meta:{})===a}return!1}))return;if(c.every(([,u])=>u===a))return o.has(r)?o.get(r):void 0;const p=`${q(r,ce(r))}-${a}`;return o.set(r,p),p}},"splitChunks")},"createSplitChunks");var bn=Object.defineProperty,$n=m((e,t)=>bn(e,"name",{value:t,configurable:!0}),"n$2");const N=$n((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var wn=Object.defineProperty,jn=m((e,t)=>wn(e,"name",{value:t,configurable:!0}),"s$4");const kn=process.platform==="win32",Ce=jn((e,t)=>{const o=kn?"\\":"/";return e.name?.includes("node_modules"+o+".pnpm")?(e.name.replace("node_modules"+o+".pnpm","external")+"."+t).replace("node_modules"+o,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var xn=Object.defineProperty,j=m((e,t)=>xn(e,"name",{value:t,configurable:!0}),"p$1");const En=j((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let o="node"+Pt.node.split(".")[0];if(t.pkg.engines?.node){const r=Ge(t.pkg.engines.node);r&&(o="node"+r.major)}if(t.options.rollup.esbuild.target){const r=K(t.options.rollup.esbuild.target);r.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...K(o),...r])])}else t.options.rollup.esbuild.target=K(o);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{minify:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild,logger:t.logger}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),vt=j((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${v(D(h(),e.id))}"
62
62
  Is the module installed? Note:
63
63
  ↳ to inline a module into your bundle, install it to "devDependencies".
64
- ↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),_e=new Map,yt=j((e,t,o)=>{const n=j(s=>{for(const[i,a]of Object.entries(t))if(s.startsWith(i))return s.replace(i,a)},"findAlias"),r=ut(e.tsconfig,!1);return{external(s){const i=n(s);i&&(s=i);const a=te(s),l=ee(e.options.externals,a)||ee(e.options.externals,s);if(l)return!0;if(s.startsWith(".")||Be(s)||/src[/\\]/.test(s)||e.pkg.name&&s.startsWith(e.pkg.name))return!1;if(r){for(const{find:c}of r)if(c.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${c.source}`,prefix:o}),!1}return!l&&!_e.has(s)&&e.logger.info({message:'Inlined implicit external "'+v(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),_e.set(s,!0),l},input:Object.fromEntries(e.options.entries.map(s=>[s.name,h(e.options.rootDir,s.input)])),logLevel:e.options.debug?"debug":"info",onLog:j((s,i)=>{let a=i.message;switch(i.stack&&(a=`${a}
65
- ${i.stack}`),s){case"info":{e.logger.info({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(s,i){ht(s,e)||s.code||i(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),vt=j(async(e,t)=>{const o=pe(e,"build");let n;return e.options.rollup.resolve&&(n=x(We({extensions:F,...e.options.rollup.resolve}),t)),{...yt(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:j(r=>D(e,r,"cjs"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:j(r=>Pe(r,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Ne(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:j(r=>D(e,r,"mjs"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:j(r=>Pe(r,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Ne(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[x(rt(),t),x(gt(),t),e.tsconfig&&x(ft(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&x(dt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ve({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ue({customResolver:n?.resolveId,...e.options.rollup.alias,entries:o}),n,e.options.rollup.polyfillNode&&ro({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Qe({...e.options.rollup.json}),Fr(e.logger),Eo(e.options.entries.filter(r=>r.executable).map(r=>r.name).filter(Boolean)),e.options.rollup.wsam&&oo(e.options.rollup.wsam),e.options.transformer?.($n(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&Ze({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&to(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&x(eo({extensions:F,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&Vr(e.pkg),e.options.rollup.raw&&Br(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&wr({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Sr({outDir:h(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&fr(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&tt({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&no({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),wn=j(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),jn=cr(wn),bt=j(async(e,t)=>{const o=pe(e,"types"),n={load(a){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(a)?null:""},name:"packem:ignore-files"},r=e.tsconfig?.config.compilerOptions;delete r?.lib;let s;e.options.rollup.resolve&&(s=x(We({extensions:F,...e.options.rollup.resolve}),t));const i="dts-plugin:"+process.pid+e.tsconfig.path;return{...yt(e,o,"dts"),onwarn(a,l){ht(a,e)||a.code!=="EMPTY_BUNDLE"&&l(a)},output:[e.options.emitCJS&&{chunkFileNames:j(a=>D(e,a,"d.cts"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:j(a=>D(e,a,"d.mts"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},(e.options.declaration===!0||e.options.declaration==="compatible")&&{chunkFileNames:j(a=>D(e,a,"d.ts"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[x(rt(),t),x(gt(),t),e.options.rollup.json&&Qe({...e.options.rollup.json}),n,e.tsconfig&&x(ft(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&x(dt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ve({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ue({customResolver:s?.resolveId,...e.options.rollup.alias,entries:o}),s,await jn(i)(e),e.options.cjsInterop&&e.options.emitCJS&&Ze({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&tn(e.options.rollup.patchTypes,e.logger),Oo(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&tt({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var kn=Object.defineProperty,xn=m((e,t)=>kn(e,"name",{value:t,configurable:!0}),"c$3");const K=xn(async(e,t)=>{const o=await vt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-build.json";o.cache=t.get(n);const r=await Je(o);t.set(n,r.cache),await e.hooks.callHook("rollup:build",e,r);const s=o.output,i=new Map;for(const a of s){const{output:l}=await r.write(a),c=new Set,p=l.filter(d=>d.type==="chunk");for(const d of p){c.add(d.fileName);for(const g of d.imports)e.usedImports.add(g);d.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(d.code,"utf8"),chunks:d.imports.filter(g=>p.find(f=>f.fileName===g)),exports:d.exports,modules:Object.entries(d.modules).map(([g,f])=>({bytes:f.renderedLength,id:g})),path:d.fileName,type:"entry"})}const u=l.filter(d=>d.type==="asset");for(const d of u)i.has(d.fileName)||i.set(d.fileName,{bytes:Buffer.byteLength(d.source,"utf8"),path:d.fileName,type:"asset"});for(const d of c)e.usedImports.delete(d)}e.buildEntries.push(...i.values())},"build");var En=Object.defineProperty,L=m((e,t)=>En(e,"name",{value:t,configurable:!0}),"r$2");const X=L(async(e,t)=>{const o=await bt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-dts.json";o.cache=t.get(n);const r=await Je(o);t.set(n,r.cache),await e.hooks.callHook("rollup:dts:build",e,r),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await r.write({chunkFileNames:L(s=>D(e,s,"d.cts"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await r.write({chunkFileNames:L(s=>D(e,s,"d.mts"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await r.write({chunkFileNames:L(s=>D(e,s,"d.ts"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var On=Object.defineProperty,fe=m((e,t)=>On(e,"name",{value:t,configurable:!0}),"i$2");const Sn=fe(e=>{const{message:t,name:o="Error",stack:n}=e;if(!n)return n;const r=`${o}: ${t}
66
- `;return n.startsWith(r)?n.slice(r.length):n},"extractStack"),Dn=fe(e=>`
64
+ ↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),Me=new Map,bt=j((e,t,o)=>{const r=j(s=>{for(const[i,l]of Object.entries(t))if(s.startsWith(i))return s.replace(i,l)},"findAlias"),n=mt(e.tsconfig,!1);return{external(s){const i=r(s);i&&(s=i);const l=ne(s),a=re(e.options.externals,l)||re(e.options.externals,s);if(a)return!0;const{pkg:c}=e,p=c.peerDependencies;if(p&&s in p&&!c.dependencies?.[s]&&!c.peerDependencies?.[s]&&!c.peerDependenciesMeta?.[s]?.optional)return!0;if(s.startsWith(".")||We(s)||/src[/\\]/.test(s)||c.name&&s.startsWith(c.name))return!1;if(n){for(const{find:u}of n)if(u.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${u.source}`,prefix:o}),!1}return!a&&!Me.has(s)&&e.logger.info({message:'Inlined implicit external "'+v(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),Me.set(s,!0),a},input:Object.fromEntries(e.options.entries.map(s=>[s.name,h(e.options.rootDir,s.input)])),logLevel:e.options.debug?"debug":"info",onLog:j((s,i)=>{let l=i.message;switch(i.stack&&(l=`${l}
65
+ ${i.stack}`),s){case"info":{e.logger.info({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(s,i){vt(s,e)||s.code||i(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),$t=j(async(e,t)=>{const o=de(e,"build");let r;return e.options.rollup.resolve&&(r=x(ze({extensions:F,...e.options.rollup.resolve}),t)),{...bt(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:j(n=>N(e,n,"cjs"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:j(n=>Ce(n,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:_e(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:j(n=>N(e,n,"mjs"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:j(n=>Ce(n,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:_e(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[x(st(),t),x(yt(),t),e.tsconfig&&x(ht(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&x(ft(e.tsconfig,e.logger),t),e.options.rollup.replace&&qe({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&He({customResolver:r?.resolveId,...e.options.rollup.alias,entries:o}),r,e.options.rollup.polyfillNode&&so({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&tt({...e.options.rollup.json}),Jr(e.logger),Do(e.options.entries.filter(n=>n.executable).map(n=>n.name).filter(Boolean)),e.options.rollup.wsam&&no(e.options.rollup.wsam),e.options.transformer?.(En(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&et({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&ro(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&x(oo({extensions:F,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&Kr(e.pkg),e.options.rollup.raw&&Ur(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&Or({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Cr({outDir:h(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&hr(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&rt({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&io({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),On=j(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),Dn=ur(On),wt=j(async(e,t)=>{const o=de(e,"types"),r={load(l){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(l)?null:""},name:"packem:ignore-files"},n=e.tsconfig?.config.compilerOptions;delete n?.lib;let s;e.options.rollup.resolve&&(s=x(ze({extensions:F,...e.options.rollup.resolve}),t));const i="dts-plugin:"+process.pid+e.tsconfig.path;return{...bt(e,o,"dts"),onwarn(l,a){vt(l,e)||l.code!=="EMPTY_BUNDLE"&&a(l)},output:[e.options.emitCJS&&{chunkFileNames:j(l=>N(e,l,"d.cts"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:j(l=>N(e,l,"d.mts"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},(e.options.declaration===!0||e.options.declaration==="compatible")&&{chunkFileNames:j(l=>N(e,l,"d.ts"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[x(st(),t),x(yt(),t),e.options.rollup.json&&tt({...e.options.rollup.json}),r,e.tsconfig&&x(ht(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&x(ft(e.tsconfig,e.logger),t),e.options.rollup.replace&&qe({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&He({customResolver:s?.resolveId,...e.options.rollup.alias,entries:o}),s,e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer?br(e.options.isolatedDeclarationTransformer,e.options.rollup.isolatedDeclarations):await Dn(i)(e),e.options.cjsInterop&&e.options.emitCJS&&et({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&an(e.options.rollup.patchTypes,e.logger),So(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&rt({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var Sn=Object.defineProperty,Nn=m((e,t)=>Sn(e,"name",{value:t,configurable:!0}),"c$3");const Q=Nn(async(e,t)=>{const o=await $t(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;const r="rollup-build.json";o.cache=t.get(r);const n=await Le(o);t.set(r,n.cache),await e.hooks.callHook("rollup:build",e,n);const s=o.output,i=new Map;for(const l of s){const{output:a}=await n.write(l),c=new Set,p=a.filter(d=>d.type==="chunk");for(const d of p){c.add(d.fileName);for(const g of d.imports)e.usedImports.add(g);d.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(d.code,"utf8"),chunks:d.imports.filter(g=>p.find(f=>f.fileName===g)),exports:d.exports,modules:Object.entries(d.modules).map(([g,f])=>({bytes:f.renderedLength,id:g})),path:d.fileName,type:"entry"})}const u=a.filter(d=>d.type==="asset");for(const d of u)i.has(d.fileName)||i.set(d.fileName,{bytes:Buffer.byteLength(d.source,"utf8"),path:d.fileName,type:"asset"});for(const d of c)e.usedImports.delete(d)}e.buildEntries.push(...i.values())},"build");var Pn=Object.defineProperty,z=m((e,t)=>Pn(e,"name",{value:t,configurable:!0}),"r$2");const ee=z(async(e,t)=>{const o=await wt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,o),Object.keys(o.input).length===0)return;const r="rollup-dts.json";o.cache=t.get(r);const n=await Le(o);t.set(r,n.cache),await e.hooks.callHook("rollup:dts:build",e,n),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await n.write({chunkFileNames:z(s=>N(e,s,"d.cts"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await n.write({chunkFileNames:z(s=>N(e,s,"d.mts"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await n.write({chunkFileNames:z(s=>N(e,s,"d.ts"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var _n=Object.defineProperty,he=m((e,t)=>_n(e,"name",{value:t,configurable:!0}),"i$2");const Cn=he(e=>{const{message:t,name:o="Error",stack:r}=e;if(!r)return r;const n=`${o}: ${t}
66
+ `;return r.startsWith(n)?r.slice(n.length):r},"extractStack"),Mn=he(e=>`
67
67
  ${e.replaceAll(/^\n|\n$/g,"")}
68
- `,"normalizeCodeFrame"),$t=fe(e=>{const t=Sn(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
68
+ `,"normalizeCodeFrame"),jt=he(e=>{const t=Cn(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
69
69
  file: ${v(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
70
- `+Mt(Dn(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
71
- ${t}`)},"enhanceRollupError");var Nn=Object.defineProperty,wt=m((e,t)=>Nn(e,"name",{value:t,configurable:!0}),"l$2");const Ce=wt((e,t,o)=>{const n="watcher:"+t;e.on("change",(r,{event:s})=>{o.info({message:`${v(P(".",r))} was ${s}d`,prefix:n})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:n})}),e.on("event",async r=>{switch(r.code){case"END":{o.success({message:"Rebuild "+t+" finished",prefix:n});break}case"BUNDLE_START":{o.info({message:v("build started..."),prefix:n});break}case"BUNDLE_END":{await r.result.close(),o.info({message:v(`built in ${r.duration+""}ms.`),prefix:n});break}case"ERROR":{$t(r.error),o.error({context:[r.error],message:"Rebuild "+t+" failed: "+r.error.message,prefix:n});break}}})},"watchHandler"),Pn=wt(async(e,t)=>{const o=await vt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get("rollup-watch"),typeof o.watch=="object"&&o.watch.include===void 0&&(o.watch.include=[b(e.options.sourceDir,"**")],o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar});const n=be(o);await e.hooks.callHook("rollup:watch",e,n);const r=[...Array.isArray(o.input)?o.input:typeof o.input=="string"?[o.input]:Object.keys(o.input??{})];let s="Starting watchers for entries:";for(const i of r)s+=M(`
72
- └─ ${P(process.cwd(),i)}`);if(e.logger.info(s),Ce(n,"bundle",e.logger),e.options.declaration){const i=await bt(e,t);await e.hooks.callHook("rollup:dts:options",e,i);const a=be(i);await e.hooks.callHook("rollup:watch",e,a),Ce(a,"types",e.logger)}},"watch");var _n=Object.defineProperty,Cn=m((e,t)=>_n(e,"name",{value:t,configurable:!0}),"i$1");const jt=Cn(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var Mn=Object.defineProperty,In=m((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"a$3");class Fn{static{m(this,"p")}static{In(this,"FileCache")}#r;#e;#n;#t=!0;#o=new Map;#s;constructor(t,o,n){this.#r=t,this.#e=uo("@visulima/packem",{cwd:t}),this.#n=o,this.#s=n,this.#e===void 0?n.debug("Could not create cache directory."):n.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#t=t}get cachePath(){return this.#e}has(t,o){return!this.#t||this.#e===void 0?!1:O(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const n=this.getFilePath(t,o);if(this.#o.has(n))return this.#o.get(n);if(!O(n))return;const r=Re(n);try{const s=JSON.parse(r);return this.#o.set(n,s),s}catch{this.#s.warn(`Could not parse cache file: ${n}, deleting the broken cache file.`),this.#o.delete(n),Qt(n,{force:!0});return}}set(t,o,n){if(!this.#t||this.#e===void 0||o===void 0)return;const r=this.getFilePath(t,n);typeof o=="object"&&(o=JSON.stringify(o)),re(r,o,{overwrite:!0})}getFilePath(t,o){let n=t.replaceAll(ve(this.#r),"");return n=n.replaceAll(":","-"),b(this.#e,this.#n,o?.replaceAll(":","-")??"",ve(n))}}var Rn=Object.defineProperty,z=m((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"l$1");const Tn=le,An=z((e,t)=>{const{sideEffects:o}=t;let n;if(typeof o=="boolean")n=z(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)n=z(()=>!1,"hasSideEffects");else{const r=o.map(s=>s.includes("/")?s:`**/${s}`);n=Tn(r,null,{resolve:e})}else n=z(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var Bn=Object.defineProperty,Jn=m((e,t)=>Bn(e,"name",{value:t,configurable:!0}),"y");const Wn=Jn((e,t,o)=>e.reduce((n,r)=>{const s=r[t],i=r[o];return n[s]||(n[s]={}),n[s][i]||(n[s][i]=[]),n[s][i].push(r),n},{}),"groupByKeys");var Ln=Object.defineProperty,zn=m((e,t)=>Ln(e,"name",{value:t,configurable:!0}),"o");const Un=zn(e=>{const t=new Set,o=new Set(Object.keys(e.pkg.dependencies??{})),n=new Set;for(const r of e.usedImports)o.delete(r),t.add(r);if(Array.isArray(e.options.dependencies))for(const r of e.options.dependencies)o.delete(r);for(const r of t)!ee(e.options.externals,r)&&!r.startsWith("chunks/")&&!e.options.dependencies.includes(te(r))&&!e.options.peerDependencies.includes(te(r))&&n.add(r);o.size>0&&B(e,`Potential unused dependencies found: ${[...o].map(r=>v(r)).join(", ")}`),n.size>0&&B(e,`Potential implicit dependencies found: ${[...n].map(r=>v(r)).join(", ")}`)},"validateDependencies");var Vn=Object.defineProperty,kt=m((e,t)=>Vn(e,"name",{value:t,configurable:!0}),"i");const Hn=kt((e,t)=>mo(e,t)<=e.length/3||t.includes(e),"isSimilar"),qn=kt((e,t)=>{const o=e.toLowerCase();return t.filter(n=>Hn(n.toLowerCase(),o))},"findAlternatives");var Gn=Object.defineProperty,Me=m((e,t)=>Gn(e,"name",{value:t,configurable:!0}),"n");const Yn=Me((e,t)=>{const o=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin??{}),e.main,e.module,t.options.declaration?e.types:"",t.options.declaration?e.typings:"",...ue(e.exports,e.type??"commonjs",t.options.declaration).map(r=>r.file)].map(r=>r&&h(t.rootDir,r.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const r of o)r&&!r.includes("*")&&!ae(r)&&n.push(r.replace(`${t.rootDir}/`,""));if(n.length>0){const r=Me(a=>P(t.rootDir,h(t.options.outDir,a)),"rPath"),s=t.buildEntries.filter(a=>!a.chunk).map(a=>r(a.path));let i="Potential missing or wrong package.json files:";for(const a of n){const l=qn(a,s);i+=`
73
- - `+v(a)+(l.length>0?It` (did you mean ${l.map(c=>`"${c}"`).join(", ")}?)`:"")}B(t,i)}},"validatePackage");var Kn=Object.defineProperty,k=m((e,t)=>Kn(e,"name",{value:t,configurable:!0}),"h$1");const xt=k((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
70
+ `+Ft(Mn(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
71
+ ${t}`)},"enhanceRollupError");var In=Object.defineProperty,kt=m((e,t)=>In(e,"name",{value:t,configurable:!0}),"l$2");const Ie=kt((e,t,o)=>{const r="watcher:"+t;e.on("change",(n,{event:s})=>{o.info({message:`${v(D(".",n))} was ${s}d`,prefix:r})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:r})}),e.on("event",async n=>{switch(n.code){case"END":{o.success({message:"Rebuild "+t+" finished",prefix:r});break}case"BUNDLE_START":{o.info({message:v("build started..."),prefix:r});break}case"BUNDLE_END":{await n.result.close(),o.info({message:v(`built in ${n.duration+""}ms.`),prefix:r});break}case"ERROR":{jt(n.error),o.error({context:[n.error],message:"Rebuild "+t+" failed: "+n.error.message,prefix:r});break}}})},"watchHandler"),Fn=kt(async(e,t)=>{const o=await $t(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get("rollup-watch"),typeof o.watch=="object"&&o.watch.include===void 0&&(o.watch.include=[b(e.options.sourceDir,"**")],o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar});const r=we(o);await e.hooks.callHook("rollup:watch",e,r);const n=[...Array.isArray(o.input)?o.input:typeof o.input=="string"?[o.input]:Object.keys(o.input??{})];let s="Starting watchers for entries:";for(const i of n)s+=M(`
72
+ └─ ${D(process.cwd(),i)}`);if(e.logger.info(s),Ie(r,"bundle",e.logger),e.options.declaration){const i=await wt(e,t);await e.hooks.callHook("rollup:dts:options",e,i);const l=we(i);await e.hooks.callHook("rollup:watch",e,l),Ie(l,"types",e.logger)}},"watch");var Rn=Object.defineProperty,Tn=m((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"i$1");const xt=Tn(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var An=Object.defineProperty,Bn=m((e,t)=>An(e,"name",{value:t,configurable:!0}),"a$3");class Jn{static{m(this,"p")}static{Bn(this,"FileCache")}#r;#e;#n;#t=!0;#o=new Map;#s;constructor(t,o,r){this.#r=t,this.#e=fo("@visulima/packem",{cwd:t}),this.#n=o,this.#s=r,this.#e===void 0?r.debug("Could not create cache directory."):r.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#t=t}get cachePath(){return this.#e}has(t,o){return!this.#t||this.#e===void 0?!1:O(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const r=this.getFilePath(t,o);if(this.#o.has(r))return this.#o.get(r);if(!O(r))return;const n=Ae(r);try{const s=JSON.parse(n);return this.#o.set(r,s),s}catch{this.#s.warn(`Could not parse cache file: ${r}, deleting the broken cache file.`),this.#o.delete(r),to(r,{force:!0});return}}set(t,o,r){if(!this.#t||this.#e===void 0||o===void 0)return;const n=this.getFilePath(t,r);typeof o=="object"&&(o=JSON.stringify(o)),ae(n,o,{overwrite:!0})}getFilePath(t,o){let r=t.replaceAll($e(this.#r),"");return r=r.replaceAll(":","-"),b(this.#e,this.#n,o?.replaceAll(":","-")??"",$e(r))}}var Wn=Object.defineProperty,U=m((e,t)=>Wn(e,"name",{value:t,configurable:!0}),"l$1");const Ln=G,zn=U((e,t)=>{const{sideEffects:o}=t;let r;if(typeof o=="boolean")r=U(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)r=U(()=>!1,"hasSideEffects");else{const n=o.map(s=>s.includes("/")?s:`**/${s}`);r=Ln(n,null,{resolve:e})}else r=U(()=>null,"hasSideEffects");return r},"getPackageSideEffect");var Un=Object.defineProperty,Vn=m((e,t)=>Un(e,"name",{value:t,configurable:!0}),"y");const Hn=Vn((e,t,o)=>e.reduce((r,n)=>{const s=n[t],i=n[o];return r[s]||(r[s]={}),r[s][i]||(r[s][i]=[]),r[s][i].push(n),r},{}),"groupByKeys");var qn=Object.defineProperty,Gn=m((e,t)=>qn(e,"name",{value:t,configurable:!0}),"o");const Yn=Gn(e=>{const t=new Set,o=new Set(Object.keys(e.pkg.dependencies??{})),r=new Set;for(const n of e.usedImports)o.delete(n),t.add(n);if(Array.isArray(e.options.dependencies))for(const n of e.options.dependencies)o.delete(n);for(const n of t)!re(e.options.externals,n)&&!n.startsWith("chunks/")&&!e.options.dependencies.includes(ne(n))&&!e.options.peerDependencies.includes(ne(n))&&r.add(n);o.size>0&&B(e,`Potential unused dependencies found: ${[...o].map(n=>v(n)).join(", ")}`),r.size>0&&B(e,`Potential implicit dependencies found: ${[...r].map(n=>v(n)).join(", ")}`)},"validateDependencies");var Kn=Object.defineProperty,Et=m((e,t)=>Kn(e,"name",{value:t,configurable:!0}),"i");const Xn=Et((e,t)=>go(e,t)<=e.length/3||t.includes(e),"isSimilar"),Zn=Et((e,t)=>{const o=e.toLowerCase();return t.filter(r=>Xn(r.toLowerCase(),o))},"findAlternatives");var Qn=Object.defineProperty,Fe=m((e,t)=>Qn(e,"name",{value:t,configurable:!0}),"n");const es=Fe((e,t)=>{const o=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin??{}),e.main,e.module,t.options.declaration?e.types:"",t.options.declaration?e.typings:"",...me(e.exports,e.type??"commonjs",t.options.declaration).map(n=>n.file)].map(n=>n&&h(t.rootDir,n.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),r=[];for(const n of o)n&&!n.includes("*")&&!pe(n)&&r.push(n.replace(`${t.rootDir}/`,""));if(r.length>0){const n=Fe(l=>D(t.rootDir,h(t.options.outDir,l)),"rPath"),s=t.buildEntries.filter(l=>!l.chunk).map(l=>n(l.path));let i="Potential missing or wrong package.json files:";for(const l of r){const a=Zn(l,s);i+=`
73
+ - `+v(l)+(a.length>0?Rt` (did you mean ${a.map(c=>`"${c}"`).join(", ")}?)`:"")}B(t,i)}},"validatePackage");var ts=Object.defineProperty,k=m((e,t)=>ts(e,"name",{value:t,configurable:!0}),"h$1");const Ot=k((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
74
74
  `),e.logger.warn(`Build is done with some warnings:
75
75
 
76
76
  ${[...e.warnings].map(o=>`- ${o}`).join(`
77
- `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logErrors"),Xn=k(e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},"resolveTsconfigJsxToJsxRuntime"),Zn=k((e,t,o,n,r,s,i,a,l)=>{const c=Xn(l?.config.compilerOptions?.jsx),p=Vt(s,r,i,{alias:{},clean:!0,debug:n,declaration:!0,dependencies:[],devDependencies:[],emitCJS:!0,emitESM:!0,entries:[],externals:[...ye.builtinModules,...ye.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,fileCache:!0,minify:E.NODE_ENV==="production",name:(a.name??"").split("/").pop()??"default",optionalDependencies:[],outDir:"dist",peerDependencies:[],replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:l?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",include:/\.[jt]sx?$/,jsx:c,jsxDev:l?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:l?.config.compilerOptions?.jsxFactory,jsxFragment:l?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:l?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minifyWhitespace:E.NODE_ENV==="production",sourcesContent:!1,target:l?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:l?.config},json:{preferConst:!0},license:{dependenciesTemplate:k((u,d,g)=>`
77
+ `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logErrors"),os=k(e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},"resolveTsconfigJsxToJsxRuntime"),rs=k((e,t,o,r,n,s,i,l,a)=>{const c=os(a?.config.compilerOptions?.jsx),p=qt(s,n,i,{alias:{},clean:!0,debug:r,declaration:!0,dependencies:[],devDependencies:[],emitCJS:!0,emitESM:!0,entries:[],externals:[...be.builtinModules,...be.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,fileCache:!0,minify:E.NODE_ENV==="production",name:(l.name??"").split("/").pop()??"default",optionalDependencies:[],outDir:"dist",peerDependencies:[],replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:a?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",include:/\.[jt]sx?$/,jsx:c,jsxDev:a?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:a?.config.compilerOptions?.jsxFactory,jsxFragment:a?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:a?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minifyWhitespace:E.NODE_ENV==="production",sourcesContent:!1,target:a?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:a?.config},isolatedDeclarations:{},json:{preferConst:!0},license:{dependenciesTemplate:k((u,d,g)=>`
78
78
  # Licenses of bundled dependencies
79
79
  The published ${g} artifact additionally contains code with the following licenses:
80
80
  ${u.join(", ")}
@@ -86,30 +86,30 @@ The published ${g} artifact additionally contains code with the following licens
86
86
  ${u.join(", ")}
87
87
 
88
88
  # Bundled types:
89
- `+d,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:je,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:l?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:E.NODE_ENV==="production",...l?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(l.config.compilerOptions.jsx)?{jsxFragmentPragma:l.config.compilerOptions.jsxFragmentFactory,jsxImportSource:l.config.compilerOptions.jsxImportSource,jsxPragma:l.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...l.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...l?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:/\.[jt]sx?$/,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:l?.config.compilerOptions?.experimentalDecorators,syntax:l?"typescript":"ecmascript",[l?"tsx":"jsx"]:!0},target:l?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:l?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:l?.config.compilerOptions?.experimentalDecorators,react:{development:E.NODE_ENV!=="production",pragma:l?.config.compilerOptions?.jsxFactory,pragmaFrag:l?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:l?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:l?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:An(t,a),preset:"recommended"},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:je}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!p.transformerName){const u=new Map([...Object.entries(a.dependencies??{}),...Object.entries(a.devDependencies??{})]);let d="0.0.0";if(u.has("esbuild"))p.transformerName="esbuild",d=u.get("esbuild");else if(u.has("@swc/core"))p.transformerName="swc",d=u.get("@swc/core");else if(u.has("sucrase"))p.transformerName="sucrase",d=u.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+v("rollup ")+qt),e.info({message:"Using "+v(p.transformerName)+" "+d,prefix:"transformer"})}return p.rollup.resolve&&p.rollup.resolve.preferBuiltins===!0&&(p.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),l?.config.compilerOptions?.isolatedModules||e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
89
+ `+d,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:xe,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:a?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:E.NODE_ENV==="production",...a?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(a.config.compilerOptions.jsx)?{jsxFragmentPragma:a.config.compilerOptions.jsxFragmentFactory,jsxImportSource:a.config.compilerOptions.jsxImportSource,jsxPragma:a.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...a.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...a?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:/\.[jt]sx?$/,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:a?.config.compilerOptions?.experimentalDecorators,syntax:a?"typescript":"ecmascript",[a?"tsx":"jsx"]:!0},target:a?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:a?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:a?.config.compilerOptions?.experimentalDecorators,react:{development:E.NODE_ENV!=="production",pragma:a?.config.compilerOptions?.jsxFactory,pragmaFrag:a?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:a?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:a?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"},transform:{decoratorVersion:"2022-03"}},treeshake:{moduleSideEffects:zn(t,l),preset:"recommended"},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:xe}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!p.transformerName){const u=new Map([...Object.entries(l.dependencies??{}),...Object.entries(l.devDependencies??{})]);let d="0.0.0";if(u.has("esbuild"))p.transformerName="esbuild",d=u.get("esbuild");else if(u.has("@swc/core"))p.transformerName="swc",d=u.get("@swc/core");else if(u.has("sucrase"))p.transformerName="sucrase",d=u.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+v("rollup ")+Yt),e.info({message:"Using "+v(p.transformerName)+" "+d,prefix:"transformer"})}return p.rollup.resolve&&p.rollup.resolve.preferBuiltins===!0&&(p.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),a?.config.compilerOptions?.isolatedModules||e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
90
90
  Because none of the third-party transpiler, packem uses under the hood is type-aware, some techniques or features often used in TypeScript are not properly checked and can cause mis-compilation or even runtime errors.
91
- To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),p.dependencies=Object.keys(a.dependencies??{}),p.peerDependencies=Object.keys(a.peerDependencies??{}),p.devDependencies=Object.keys(a.devDependencies??{}),p.optionalDependencies=Object.keys(a.optionalDependencies??{}),p.externals.push(...p.dependencies,...p.peerDependencies,...p.optionalDependencies),p},"generateOptions"),Qn=k(e=>e.replace(/\.(?:js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension"),es=k(async(e,t)=>{e.options.entries=e.options.entries.map(o=>typeof o=="string"?{input:o}:o);for await(const o of e.options.entries){if(typeof o.name!="string"){let n=Be(o.input)?P(t,o.input):ne(o.input);n.startsWith("./")&&(n=n.slice(2)),o.name=Qn(n.replace(/^src\//,""))}if(!o.input)throw new Error(`Missing entry input: ${jt(o)}`);if(o.input=h(e.options.rootDir,o.input),!O(o.input)){const n=new Set(await Ct(ie(o.input)));let r=!1;for(const s of F)if(n.has(V(o.input)+s)){r=!0;break}if(!r)throw new Wt("Your configured entry: "+v(o.input)+" does not exist.")}o.outDir=h(e.options.rootDir,o.outDir??e.options.outDir)}},"prepareEntries"),ts=k((e,t,o)=>{const n=k(s=>P(t.rootDir,h(t.options.outDir,s)),"rPath");let r=!1;for(const s of t.buildEntries.filter(i=>!i.chunk)){let i=s.bytes??0;for(const l of s.chunks??[])i+=t.buildEntries.find(c=>c.path===l)?.bytes??0;let a=` ${S(n(s.path))} (${["total size: "+v(_(i)),s.type!=="asset"&&s.bytes&&"chunk size: "+v(_(s.bytes))].filter(Boolean).join(", ")})`;if(a+=s.exports?.length?`
92
- exports: `+M(s.exports.join(", ")):"",s.chunks?.length&&(a+=`
93
- ${s.chunks.map(l=>{const c=t.buildEntries.find(p=>p.path===l)??{};return M(" └─ "+n(l)+S(c.bytes?" ("+_(c?.bytes)+")":""))}).join(`
94
- `)}`),s.modules&&s.modules.length>0){const l=s.modules.filter(c=>c.id.includes("node_modules")).sort((c,p)=>(p.bytes||0)-(c.bytes||0)).map(c=>M(" 📦 "+n(c.id)+S(c.bytes?" ("+_(c.bytes)+")":""))).join(`
95
- `);a+=l.length>0?`
91
+ To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),p.dependencies=Object.keys(l.dependencies??{}),p.peerDependencies=Object.keys(l.peerDependencies??{}),p.devDependencies=Object.keys(l.devDependencies??{}),p.optionalDependencies=Object.keys(l.optionalDependencies??{}),p.externals.push(...p.dependencies,...p.peerDependencies,...p.optionalDependencies),p},"generateOptions"),ns=k(e=>e.replace(/\.(?:js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension"),ss=k(async(e,t)=>{e.options.entries=e.options.entries.map(o=>typeof o=="string"?{input:o}:o);for await(const o of e.options.entries){if(typeof o.name!="string"){let r=We(o.input)?D(t,o.input):le(o.input);r.startsWith("./")&&(r=r.slice(2)),o.name=ns(r.replace(/^src\//,""))}if(!o.input)throw new Error(`Missing entry input: ${xt(o)}`);if(o.input=h(e.options.rootDir,o.input),!O(o.input)){const r=new Set(await It(H(o.input)));let n=!1;for(const s of F)if(r.has(q(o.input)+s)){n=!0;break}if(!n)throw new zt("Your configured entry: "+v(o.input)+" does not exist.")}o.outDir=h(e.options.rootDir,o.outDir??e.options.outDir)}},"prepareEntries"),is=k((e,t,o)=>{const r=k(s=>D(t.rootDir,h(t.options.outDir,s)),"rPath");let n=!1;for(const s of t.buildEntries.filter(i=>!i.chunk)){let i=s.bytes??0;for(const a of s.chunks??[])i+=t.buildEntries.find(c=>c.path===a)?.bytes??0;let l=` ${S(r(s.path))} (${["total size: "+v(_(i)),s.type!=="asset"&&s.bytes&&"chunk size: "+v(_(s.bytes))].filter(Boolean).join(", ")})`;if(l+=s.exports?.length?`
92
+ exports: `+M(s.exports.join(", ")):"",s.chunks?.length&&(l+=`
93
+ ${s.chunks.map(a=>{const c=t.buildEntries.find(p=>p.path===a)??{};return M(" └─ "+r(a)+S(c.bytes?" ("+_(c?.bytes)+")":""))}).join(`
94
+ `)}`),s.modules&&s.modules.length>0){const a=s.modules.filter(c=>c.id.includes("node_modules")).sort((c,p)=>(p.bytes||0)-(c.bytes||0)).map(c=>M(" 📦 "+r(c.id)+S(c.bytes?" ("+_(c.bytes)+")":""))).join(`
95
+ `);l+=a.length>0?`
96
96
  inlined modules:
97
- `+l:""}if(t.options.declaration&&s.type==="entry"){let l=s.path.replace(/\.js$/,".d.ts"),c="commonjs";s.path.endsWith(".cjs")?l=s.path.replace(/\.cjs$/,".d.cts"):s.path.endsWith(".mjs")&&(c="module",l=s.path.replace(/\.mjs$/,".d.mts"));const p=t.buildEntries.find(u=>u.path.endsWith(l));if(p){let u;(t.options.declaration===!0||t.options.declaration==="compatible")&&!l.includes(".d.ts")&&(l=l.replace(c==="commonjs"?".d.c":".d.m",".d."),u=t.buildEntries.find(d=>d.path.endsWith(l))),a+=u&&c===o.type?`
97
+ `+a:""}if(t.options.declaration&&s.type==="entry"){let a=s.path.replace(/\.js$/,".d.ts"),c="commonjs";s.path.endsWith(".cjs")?a=s.path.replace(/\.cjs$/,".d.cts"):s.path.endsWith(".mjs")&&(c="module",a=s.path.replace(/\.mjs$/,".d.mts"));const p=t.buildEntries.find(u=>u.path.endsWith(a));if(p){let u;(t.options.declaration===!0||t.options.declaration==="compatible")&&!a.includes(".d.ts")&&(a=a.replace(c==="commonjs"?".d.c":".d.m",".d."),u=t.buildEntries.find(d=>d.path.endsWith(a))),l+=u&&c===o.type?`
98
98
  types:
99
- `+[p,u].map(d=>M(" └─ ")+S(n(d.path))+" (total size: "+v(_(d.bytes??0))+")").join(`
99
+ `+[p,u].map(d=>M(" └─ ")+S(r(d.path))+" (total size: "+v(_(d.bytes??0))+")").join(`
100
100
  `):`
101
- types: `+S(n(p.path))+" (total size: "+v(_(p.bytes??0))+")"}}r=!0,a+=`
101
+ types: `+S(r(p.path))+" (total size: "+v(_(p.bytes??0))+")"}}n=!0,l+=`
102
102
 
103
- `,e.raw(s.chunk?M(a):a)}return r&&e.raw("Σ Total dist size (byte size):",v(_(t.buildEntries.reduce((s,i)=>s+(i.bytes??0),0))),`
104
- `),r},"showSizeInformation"),os=k(async(e,t,o,n,r,s,i,a)=>{const l=er(s.preset??r.preset??"auto",t),c=Zn(e,t,o,n,r,s,l,i,a);At(b(c.rootDir,c.outDir));const p={buildEntries:[],dependencyGraphMap:new Map,hooks:Ht(),logger:e,mode:o,options:c,pkg:i,rootDir:t,tsconfig:a,usedImports:new Set,warnings:new Set};if(l.hooks&&p.hooks.addHooks(l.hooks),r.hooks&&p.hooks.addHooks(r.hooks),s.hooks&&p.hooks.addHooks(s.hooks),await p.hooks.callHook("build:prepare",p),!p.options.emitESM&&!p.options.emitCJS)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(p.options.declaration&&a===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");return p.options.emitESM===void 0&&p.logger.info("Emitting ESM bundles, is disabled."),p.options.emitCJS===void 0&&p.logger.info("Emitting CJS bundles, is disabled."),p.options.declaration||p.logger.info("Declaration files, are disabled."),p},"createContext"),rs=k(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(n=>n.outDir).filter(Boolean).sort()))o===e.options.rootDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(n=>o.startsWith(n))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${P(e.options.rootDir,o)}\``),await Te(o))},"cleanDistributionDirectories"),ns=k(async(e,t,o)=>{await e.hooks.callHook("build:before",e);const n=Wn(e.options.entries,"environment","runtime"),r=[];for(const[i,a]of Object.entries(n))for(const[l,c]of Object.entries(a)){e.logger.info("Preparing build for "+v(i)+" environment with "+v(l)+" runtime"),e.options.rollup.replace?(e.options.rollup.replace.values={...e.options.rollup.replace.values,production:i},l==="edge-light"&&(e.options.rollup.replace.values.EdgeRuntime="edge-runtime")):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");const p=[],u=[],d=[];for(const f of c)f.cjs&&f.esm?p.push(f):f.cjs?d.push(f):f.esm&&u.push(f);const g=i!=="development"&&e.options.minify;if(p.length>0){const f={...e,options:{...e.options,emitCJS:!0,emitESM:!0,entries:p,minify:g}};r.push(K(f,o));const $=f.options.entries.filter(w=>w.declaration);e.options.declaration&&$.length>0&&r.push(X({...f,options:{...f.options,entries:$}},o))}if(u.length>0){const f={...e,options:{...e.options,emitCJS:!1,emitESM:!0,entries:u,minify:g}};r.push(K(f,o));const $=f.options.entries.filter(w=>w.declaration);e.options.declaration&&$.length>0&&r.push(X({...f,options:{...f.options,entries:$}},o))}if(d.length>0){const f={...e,options:{...e.options,emitCJS:!1,emitESM:!1,entries:d,minify:g}};r.push(K(f,o));const $=f.options.entries.filter(w=>w.declaration);e.options.declaration&&$.length>0&&r.push(X({...f,options:{...f.options,entries:$}},o))}}await Promise.all(r),e.logger.success(Ft(`Build succeeded for ${e.options.name}`));for await(const i of Bt(b(e.options.rootDir,e.options.outDir))){let a=e.buildEntries.find(l=>b(e.options.rootDir,e.options.outDir,l.path)===i.path);if(a||(a={chunk:!0,path:i.path},e.buildEntries.push(a)),!a.bytes){const l=await Fe(h(e.options.rootDir,e.options.outDir,i.path));a.bytes=l.size}}const s=ts(e.logger,e,t);Un(e),Yn(t,e),await e.hooks.callHook("build:done",e),xt(e,s)},"build"),ss=k(async(e,t,o,n={})=>{const{configPath:r,debug:s,tsconfigPath:i,...a}=n;o.wrapAll(),e=h(Nt(),e),o.debug("Root directory:",e);const l=b(e,"package.json"),c=Ae(l);o.debug("Using package.json found at",l);let p;if(i){const u=b(e,i);if(!await Jt(u))throw new Error("tsconfig.json not found at "+u);p={config:zt(u),path:u},o.info("Using tsconfig settings at",u)}else try{p=await Ut(e),o.debug("Using tsconfig settings found at",p.path)}catch{o.info("No tsconfig.json or jsconfig.json found.")}try{const u=r??"./packem.config.ts";if(!/\.(?:js|mjs|cjs|ts)$/.test(u))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed.");const d=Ge(u,e);o.debug("Using packem config found at",b(e,u));const g=Date.now(),f=k(()=>Lt(Math.floor(Date.now()-g)),"getDuration"),$=C(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types})),w=new Fn(e,$,o);w.cachePath&&!O(b(w.cachePath,$))&&O(w.cachePath)&&(o.info("Clearing file cache because the cache key has changed."),await Te(w.cachePath));const y=await os(o,e,t,s??!1,a,d,c,p);if(w.isEnabled=y.options.fileCache,await es(y,e),y.logger.info(v((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+y.options.name)),y.logger.debug(`${S("Root dir:")} ${y.options.rootDir}
103
+ `,e.raw(s.chunk?M(l):l)}return n&&e.raw("Σ Total dist size (byte size):",v(_(t.buildEntries.reduce((s,i)=>s+(i.bytes??0),0))),`
104
+ `),n},"showSizeInformation"),as=k(async(e,t,o,r,n,s,i,l)=>{const a=or(s.preset??n.preset??"auto",t),c=rs(e,t,o,r,n,s,a,i,l);Jt(b(c.rootDir,c.outDir));const p={buildEntries:[],dependencyGraphMap:new Map,hooks:Gt(),logger:e,mode:o,options:c,pkg:i,rootDir:t,tsconfig:l,usedImports:new Set,warnings:new Set};if(a.hooks&&p.hooks.addHooks(a.hooks),n.hooks&&p.hooks.addHooks(n.hooks),s.hooks&&p.hooks.addHooks(s.hooks),await p.hooks.callHook("build:prepare",p),!p.options.emitESM&&!p.options.emitCJS)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(p.options.declaration&&l===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");return p.options.emitESM===void 0&&p.logger.info("Emitting ESM bundles, is disabled."),p.options.emitCJS===void 0&&p.logger.info("Emitting CJS bundles, is disabled."),p.options.declaration||p.logger.info("Declaration files, are disabled."),p},"createContext"),ls=k(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(r=>r.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(r=>o.startsWith(r))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${D(e.options.rootDir,o)}\``),await Be(o))},"cleanDistributionDirectories"),cs=k(async(e,t,o)=>{await e.hooks.callHook("build:before",e);const r=Hn(e.options.entries,"environment","runtime"),n=[];for(const[i,l]of Object.entries(r))for(const[a,c]of Object.entries(l)){e.logger.info("Preparing build for "+v(i)+" environment with "+v(a)+" runtime"),e.options.rollup.replace?(e.options.rollup.replace.values={...e.options.rollup.replace.values,production:i},a==="edge-light"&&(e.options.rollup.replace.values.EdgeRuntime="edge-runtime")):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");const p=[],u=[],d=[];for(const f of c)f.cjs&&f.esm?p.push(f):f.cjs?d.push(f):f.esm&&u.push(f);const g=i!=="development"&&e.options.minify;if(p.length>0){const f={...e,options:{...e.options,emitCJS:!0,emitESM:!0,entries:p,minify:g}};n.push(Q(f,o));const $=f.options.entries.filter(w=>w.declaration);e.options.declaration&&$.length>0&&n.push(ee({...f,options:{...f.options,entries:$}},o))}if(u.length>0){const f={...e,options:{...e.options,emitCJS:!1,emitESM:!0,entries:u,minify:g}};n.push(Q(f,o));const $=f.options.entries.filter(w=>w.declaration);e.options.declaration&&$.length>0&&n.push(ee({...f,options:{...f.options,entries:$}},o))}if(d.length>0){const f={...e,options:{...e.options,emitCJS:!1,emitESM:!1,entries:d,minify:g}};n.push(Q(f,o));const $=f.options.entries.filter(w=>w.declaration);e.options.declaration&&$.length>0&&n.push(ee({...f,options:{...f.options,entries:$}},o))}}await Promise.all(n),e.logger.success(Tt(`Build succeeded for ${e.options.name}`));for await(const i of Wt(b(e.options.rootDir,e.options.outDir))){let l=e.buildEntries.find(a=>b(e.options.rootDir,e.options.outDir,a.path)===i.path);if(l||(l={chunk:!0,path:i.path},e.buildEntries.push(l)),!l.bytes){const a=await Te(h(e.options.rootDir,e.options.outDir,i.path));l.bytes=a.size}}const s=is(e.logger,e,t);Yn(e),es(t,e),await e.hooks.callHook("build:done",e),Ot(e,s)},"build"),ps=k(async(e,t,o,r={})=>{const{configPath:n,debug:s,tsconfigPath:i,...l}=r;o.wrapAll(),e=h(_t(),e),o.debug("Root directory:",e);const a=b(e,"package.json"),c=Je(a);o.debug("Using package.json found at",a);let p;if(i){const u=b(e,i);if(!await Lt(u))throw new Error("tsconfig.json not found at "+u);p={config:Vt(u),path:u},o.info("Using tsconfig settings at",u)}else try{p=await Ht(e),o.debug("Using tsconfig settings found at",p.path)}catch{o.info("No tsconfig.json or jsconfig.json found.")}try{const u=n??"./packem.config.ts";if(!/\.(?:js|mjs|cjs|ts)$/.test(u))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed.");const d=Ke(u,e);o.debug("Using packem config found at",b(e,u));const g=Date.now(),f=k(()=>Ut(Math.floor(Date.now()-g)),"getDuration"),$=C(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types})),w=new Jn(e,$,o);w.cachePath&&!O(b(w.cachePath,$))&&O(w.cachePath)&&(o.info("Clearing file cache because the cache key has changed."),await Be(w.cachePath));const y=await as(o,e,t,s??!1,l,d,c,p);if(w.isEnabled=y.options.fileCache,await ss(y,e),y.logger.info(v((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+y.options.name)),y.logger.debug(`${S("Root dir:")} ${y.options.rootDir}
105
105
  ${S("Entries:")}
106
- ${y.options.entries.map(R=>` ${jt(R)}`).join(`
107
- `)}`),await rs(y),y.options.stub){await To(y),await y.hooks.callHook("build:done",y);return}if(t==="watch"){if(y.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Pn(y,w),xt(y,!1);return}await ns(y,c,w),o.raw(`
106
+ ${y.options.entries.map(R=>` ${xt(R)}`).join(`
107
+ `)}`),await ls(y),y.options.stub){await Bo(y),await y.hooks.callHook("build:done",y);return}if(t==="watch"){if(y.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Fn(y,w),Ot(y,!1);return}await cs(y,c,w),o.raw(`
108
108
  ⚡️ Build run in `+f()),o.restoreAll()}catch(u){throw o.raw(`
109
- `),$t(u),new Error("An error occurred while building",{cause:u})}},"createBundler");var is=Object.defineProperty,Z=m((e,t)=>is(e,"name",{value:t,configurable:!0}),"a");const as=Z(e=>{e.addCommand({description:"Demonstrate options required",execute:Z(async({logger:t,options:o})=>{let n="build";o.watch?n="watch":o.jit&&(n="jit");const r={};if(o.env)for(const s of o.env)r[s.key]=s.value;try{await ss(o.dir,n,t,{cjsInterop:o.cjsInterop,configPath:o.config??void 0,debug:o.debug,minify:o.minify,replace:{...r},rollup:{esbuild:{target:o.target},license:{path:o.license},metafile:o.metafile,...o.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:o.sourcemap,tsconfigPath:o.tsconfig??void 0})}catch(s){t.error(s),Pt(1)}},"execute"),name:"build",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{conflicts:"jit",description:"Watch for changes",name:"watch",type:Boolean},{conflicts:"watch",description:"Stub the package for JIT compilation",name:"jit",type:Boolean},{description:"Compile-time environment variables (eg. --env.NODE_ENV=production)",multiple:!0,name:"env",type:Z(t=>{const[o,n]=t.split("=");return{key:o,value:n}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean}]})},"createBuildCommand");var ls=Object.defineProperty,Ie=m((e,t)=>ls(e,"name",{value:t,configurable:!0}),"t");const cs=Ie(e=>{e.addCommand({description:"Initialize packem configuration",execute:Ie(async({logger:t,options:o})=>{if(go("Welcome to packem setup"),O(b(o.dir,"packem.config.ts"))){t.info("Packem project already initialized, you can use `packem build` to build your project");return}if(ho(o.transformer)){yo("Operation cancelled");return}if(o.transformer===void 0){const s=b(o.dir,"package.json");if(!O(s))throw new Error("No package.json found in the directory");const i=Ae(s),a=[...Object.keys(i.dependencies??{}),...Object.keys(i.devDependencies??{})];if(o.transformer=await vo({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!a.includes(o.transformer)&&await bo({message:"Do you want to install "+o.transformer+"?"})){const l=we();l.start("Installing "+o.transformer),await fo(o.transformer==="swc"?"@swc/core":o.transformer,{cwd:o.dir,dev:!0,silent:!0}),l.stop("")}}const n=`import { defineConfig } from "@visulima/packem/config";
109
+ `),jt(u),u}},"createBundler");var us=Object.defineProperty,te=m((e,t)=>us(e,"name",{value:t,configurable:!0}),"a");const ds=te(e=>{e.addCommand({description:"Demonstrate options required",execute:te(async({logger:t,options:o})=>{let r="build";o.watch?r="watch":o.jit&&(r="jit");const n={};if(o.env)for(const s of o.env)n[s.key]=s.value;try{await ps(o.dir,r,t,{cjsInterop:o.cjsInterop,configPath:o.config??void 0,debug:o.debug,minify:o.minify,replace:{...n},rollup:{esbuild:{target:o.target},license:{path:o.license},metafile:o.metafile,...o.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:o.sourcemap,tsconfigPath:o.tsconfig??void 0})}catch(s){t.error(s),Ct(1)}},"execute"),name:"build",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{conflicts:"jit",description:"Watch for changes",name:"watch",type:Boolean},{conflicts:"watch",description:"Stub the package for JIT compilation",name:"jit",type:Boolean},{description:"Compile-time environment variables (eg. --env.NODE_ENV=production)",multiple:!0,name:"env",type:te(t=>{const[o,r]=t.split("=");return{key:o,value:r}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean}]})},"createBuildCommand");var ms=Object.defineProperty,Re=m((e,t)=>ms(e,"name",{value:t,configurable:!0}),"t");const fs=Re(e=>{e.addCommand({description:"Initialize packem configuration",execute:Re(async({logger:t,options:o})=>{if(yo("Welcome to packem setup"),O(b(o.dir,"packem.config.ts"))){t.info("Packem project already initialized, you can use `packem build` to build your project");return}if(vo(o.transformer)){bo("Operation cancelled");return}if(o.transformer===void 0){const s=b(o.dir,"package.json");if(!O(s))throw new Error("No package.json found in the directory");const i=Je(s),l=[...Object.keys(i.dependencies??{}),...Object.keys(i.devDependencies??{})];if(o.transformer=await $o({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!l.includes(o.transformer)&&await wo({message:"Do you want to install "+o.transformer+"?"})){const a=ke();a.start("Installing "+o.transformer),await ho(o.transformer==="swc"?"@swc/core":o.transformer,{cwd:o.dir,dev:!0,silent:!0}),a.stop("")}}const r=`import { defineConfig } from "@visulima/packem/config";
110
110
  import transformer from "@visulima/packem/transformer/${o.transformer}";
111
111
 
112
112
  export default defineConfig({
113
113
  transformer
114
114
  });
115
- `,r=we();r.start("Creating packem.config.ts"),re(b(o.dir,"packem.config.ts"),n),r.stop("Created packem.config.ts"),$o("Now you can run `packem build` to build your project")},"execute"),name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer to use for packem",name:"transformer",type:String}]})},"createInitCommand"),ge=new Ot("packem",{logger:{reporters:[new St({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:wo,packageVersion:jo});cs(ge);as(ge);ge.run({shouldExitProcess:!1});
115
+ `,n=ke();n.start("Creating packem.config.ts"),ae(b(o.dir,"packem.config.ts"),r),n.stop("Created packem.config.ts"),jo("Now you can run `packem build` to build your project")},"execute"),name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer to use for packem",name:"transformer",type:String}]})},"createInitCommand"),ye=new St("packem",{logger:{reporters:[new Nt({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:ko,packageVersion:xo});fs(ye);ds(ye);ye.run({shouldExitProcess:!1});