@visulima/packem 1.0.0-alpha.35 → 1.0.0-alpha.36

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## @visulima/packem [1.0.0-alpha.36](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.35...@visulima/packem@1.0.0-alpha.36) (2024-06-02)
2
+
3
+
4
+ ### Features
5
+
6
+ * reduced complexity scope of builder ([958049a](https://github.com/visulima/packem/commit/958049a8d5fb1bc81b59a85f6373ba26b1ba0edc))
7
+
1
8
  ## @visulima/packem [1.0.0-alpha.35](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.34...@visulima/packem@1.0.0-alpha.35) (2024-06-02)
2
9
 
3
10
 
package/dist/cli.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var v=Object.defineProperty;var r=(n,e)=>v(n,"name",{value:e,configurable:!0});const k=require("@visulima/cerebro"),b=require("./create-bundler.cjs"),s=require("node:process"),h=require("@antfu/install-pkg"),i=require("@clack/prompts"),c=require("@visulima/fs"),j=require("@visulima/package/package-json"),l=require("@visulima/path"),w=r(n=>n&&typeof n=="object"&&"default"in n?n.default:n,"_interopDefaultCompat"),x=w(k),C="@visulima/packem",P="1.0.0-alpha.34";var S=Object.defineProperty,p=r((n,e)=>S(n,"name",{value:e,configurable:!0}),"n");const q=p(n=>{n.addCommand({description:"Demonstrate options required",execute:p(async({options:e})=>{let t="build";e.watch?t="watch":e.jit&&(t="jit");const a={};if(e.env)for(const o of e.env)a[o.key]=o.value;await b(e.dir,t,{cjsInterop:e.cjsInterop,configPath:e.config??void 0,debug:e.debug,minify:e.minify,replace:{...a},rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,...e.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:e.sourcemap,tsconfigPath:e.tsconfig??void 0})},"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},{description:"Watch for changes",name:"watch",type:Boolean},{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:p(e=>{const[t,a]=e.split("=");return{key:t,value:a}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{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 z=Object.defineProperty,g=r((n,e)=>z(n,"name",{value:e,configurable:!0}),"i");const B=g(n=>{n.addCommand({description:"Initialize packem configuration",execute:g(async({logger:e,options:t})=>{if(i.intro("Welcome to packem setup"),c.isAccessibleSync(l.join(t.dir,"packem.config.ts")))return e.info("Packem project already initialized, you can use `packem build` to build your project"),s.exit(0);if(i.isCancel(t.transformer))return i.cancel("Operation cancelled"),s.exit(0);if(t.transformer===void 0){const u=l.join(t.dir,"package.json");if(!c.isAccessibleSync(u))return e.error("No package.json found in the directory"),s.exit(1);const d=j.parsePackageJson(u),y=[...Object.keys(d.dependencies??{}),...Object.keys(d.devDependencies??{})];if(t.transformer=await i.select({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!y.includes(t.transformer)&&await i.confirm({message:"Do you want to install "+t.transformer+"?"})){const f=i.spinner();f.start("Installing "+t.transformer),await h.installPackage(t.transformer==="swc"?"@swc/core":t.transformer,{cwd:t.dir,dev:!0,silent:!0}),f.stop("")}}const a=`import { defineConfig } from "@visulima/packem/config";
2
+ "use strict";var v=Object.defineProperty;var r=(n,e)=>v(n,"name",{value:e,configurable:!0});const k=require("@visulima/cerebro"),b=require("./create-bundler.cjs"),s=require("node:process"),h=require("@antfu/install-pkg"),i=require("@clack/prompts"),c=require("@visulima/fs"),j=require("@visulima/package/package-json"),l=require("@visulima/path"),w=r(n=>n&&typeof n=="object"&&"default"in n?n.default:n,"_interopDefaultCompat"),x=w(k),C="@visulima/packem",P="1.0.0-alpha.35";var S=Object.defineProperty,p=r((n,e)=>S(n,"name",{value:e,configurable:!0}),"n");const q=p(n=>{n.addCommand({description:"Demonstrate options required",execute:p(async({options:e})=>{let t="build";e.watch?t="watch":e.jit&&(t="jit");const a={};if(e.env)for(const o of e.env)a[o.key]=o.value;await b(e.dir,t,{cjsInterop:e.cjsInterop,configPath:e.config??void 0,debug:e.debug,minify:e.minify,replace:{...a},rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,...e.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:e.sourcemap,tsconfigPath:e.tsconfig??void 0})},"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},{description:"Watch for changes",name:"watch",type:Boolean},{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:p(e=>{const[t,a]=e.split("=");return{key:t,value:a}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{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 z=Object.defineProperty,g=r((n,e)=>z(n,"name",{value:e,configurable:!0}),"i");const B=g(n=>{n.addCommand({description:"Initialize packem configuration",execute:g(async({logger:e,options:t})=>{if(i.intro("Welcome to packem setup"),c.isAccessibleSync(l.join(t.dir,"packem.config.ts")))return e.info("Packem project already initialized, you can use `packem build` to build your project"),s.exit(0);if(i.isCancel(t.transformer))return i.cancel("Operation cancelled"),s.exit(0);if(t.transformer===void 0){const u=l.join(t.dir,"package.json");if(!c.isAccessibleSync(u))return e.error("No package.json found in the directory"),s.exit(1);const d=j.parsePackageJson(u),y=[...Object.keys(d.dependencies??{}),...Object.keys(d.devDependencies??{})];if(t.transformer=await i.select({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!y.includes(t.transformer)&&await i.confirm({message:"Do you want to install "+t.transformer+"?"})){const f=i.spinner();f.start("Installing "+t.transformer),await h.installPackage(t.transformer==="swc"?"@swc/core":t.transformer,{cwd:t.dir,dev:!0,silent:!0}),f.stop("")}}const a=`import { defineConfig } from "@visulima/packem/config";
3
3
  import transformer from "@visulima/packem/transformer/${t.transformer}";
4
4
 
5
5
  export default defineConfig({
package/dist/cli.mjs CHANGED
@@ -7,10 +7,10 @@ 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 I="@visulima/packem",N="1.0.0-alpha.34";var O=Object.defineProperty,c=r((i,e)=>O(i,"name",{value:e,configurable:!0}),"n");const V=c(i=>{i.addCommand({description:"Demonstrate options required",execute:c(async({options:e})=>{let t="build";e.watch?t="watch":e.jit&&(t="jit");const n={};if(e.env)for(const o of e.env)n[o.key]=o.value;await b(e.dir,t,{cjsInterop:e.cjsInterop,configPath:e.config??void 0,debug:e.debug,minify:e.minify,replace:{...n},rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,...e.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:e.sourcemap,tsconfigPath:e.tsconfig??void 0})},"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},{description:"Watch for changes",name:"watch",type:Boolean},{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:c(e=>{const[t,n]=e.split("=");return{key:t,value:n}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{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 D=Object.defineProperty,g=r((i,e)=>D(i,"name",{value:e,configurable:!0}),"i");const E=g(i=>{i.addCommand({description:"Initialize packem configuration",execute:g(async({logger:e,options:t})=>{if(j("Welcome to packem setup"),u(s(t.dir,"packem.config.ts")))return e.info("Packem project already initialized, you can use `packem build` to build your project"),a(0);if(w(t.transformer))return C("Operation cancelled"),a(0);if(t.transformer===void 0){const p=s(t.dir,"package.json");if(!u(p))return e.error("No package.json found in the directory"),a(1);const l=B(p),y=[...Object.keys(l.dependencies??{}),...Object.keys(l.devDependencies??{})];if(t.transformer=await x({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!y.includes(t.transformer)&&await P({message:"Do you want to install "+t.transformer+"?"})){const d=f();d.start("Installing "+t.transformer),await h(t.transformer==="swc"?"@swc/core":t.transformer,{cwd:t.dir,dev:!0,silent:!0}),d.stop("")}}const n=`import { defineConfig } from "@visulima/packem/config";
10
+ const I="@visulima/packem",O="1.0.0-alpha.35";var N=Object.defineProperty,c=r((i,e)=>N(i,"name",{value:e,configurable:!0}),"n");const V=c(i=>{i.addCommand({description:"Demonstrate options required",execute:c(async({options:e})=>{let t="build";e.watch?t="watch":e.jit&&(t="jit");const n={};if(e.env)for(const o of e.env)n[o.key]=o.value;await b(e.dir,t,{cjsInterop:e.cjsInterop,configPath:e.config??void 0,debug:e.debug,minify:e.minify,replace:{...n},rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,...e.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:e.sourcemap,tsconfigPath:e.tsconfig??void 0})},"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},{description:"Watch for changes",name:"watch",type:Boolean},{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:c(e=>{const[t,n]=e.split("=");return{key:t,value:n}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{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 D=Object.defineProperty,g=r((i,e)=>D(i,"name",{value:e,configurable:!0}),"i");const E=g(i=>{i.addCommand({description:"Initialize packem configuration",execute:g(async({logger:e,options:t})=>{if(j("Welcome to packem setup"),u(s(t.dir,"packem.config.ts")))return e.info("Packem project already initialized, you can use `packem build` to build your project"),a(0);if(w(t.transformer))return C("Operation cancelled"),a(0);if(t.transformer===void 0){const p=s(t.dir,"package.json");if(!u(p))return e.error("No package.json found in the directory"),a(1);const l=B(p),y=[...Object.keys(l.dependencies??{}),...Object.keys(l.devDependencies??{})];if(t.transformer=await x({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!y.includes(t.transformer)&&await P({message:"Do you want to install "+t.transformer+"?"})){const d=f();d.start("Installing "+t.transformer),await h(t.transformer==="swc"?"@swc/core":t.transformer,{cwd:t.dir,dev:!0,silent:!0}),d.stop("")}}const n=`import { defineConfig } from "@visulima/packem/config";
11
11
  import transformer from "@visulima/packem/transformer/${t.transformer}";
12
12
 
13
13
  export default defineConfig({
14
14
  transformer
15
15
  });
16
- `,o=f();return o.start("Creating packem.config.ts"),z(s(t.dir,"packem.config.ts"),n),o.stop("Created packem.config.ts"),S("Now you can run `packem build` to build your project"),a(0)},"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"),m=new k("packem",{packageName:I,packageVersion:N});E(m);V(m);m.run();
16
+ `,o=f();return o.start("Creating packem.config.ts"),z(s(t.dir,"packem.config.ts"),n),o.stop("Created packem.config.ts"),S("Now you can run `packem build` to build your project"),a(0)},"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"),m=new k("packem",{packageName:I,packageVersion:O});E(m);V(m);m.run();
package/dist/config.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var i=(e,r)=>f(e,"name",{value:r,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var t=Object.defineProperty,n=i((e,r)=>t(e,"name",{value:r,configurable:!0}),"i");const o=n(e=>(Array.isArray(e)?e:[e]).filter(Boolean),"defineConfig"),a=n(e=>e,"definePreset");exports.defineConfig=o;exports.definePreset=a;
1
+ "use strict";var f=Object.defineProperty;var n=(e,i)=>f(e,"name",{value:i,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var r=Object.defineProperty,t=n((e,i)=>r(e,"name",{value:i,configurable:!0}),"i");const o=t(e=>e,"defineConfig"),d=t(e=>e,"definePreset");exports.defineConfig=o;exports.definePreset=d;
package/dist/config.d.cts CHANGED
@@ -21,7 +21,7 @@ import './shared/packem.DvWhOdt5.cjs';
21
21
  import 'sucrase';
22
22
  import './shared/packem.C44tLE3n.cjs';
23
23
 
24
- declare const defineConfig: (config: BuildConfig | BuildConfig[]) => BuildConfig[];
24
+ declare const defineConfig: (config: BuildConfig) => BuildConfig;
25
25
  declare const definePreset: (preset: BuildPreset) => BuildPreset;
26
26
 
27
27
  export { BuildConfig, BuildPreset, defineConfig, definePreset };
package/dist/config.d.mts CHANGED
@@ -21,7 +21,7 @@ import './shared/packem.DvWhOdt5.mjs';
21
21
  import 'sucrase';
22
22
  import './shared/packem.C44tLE3n.mjs';
23
23
 
24
- declare const defineConfig: (config: BuildConfig | BuildConfig[]) => BuildConfig[];
24
+ declare const defineConfig: (config: BuildConfig) => BuildConfig;
25
25
  declare const definePreset: (preset: BuildPreset) => BuildPreset;
26
26
 
27
27
  export { BuildConfig, BuildPreset, defineConfig, definePreset };
package/dist/config.d.ts CHANGED
@@ -21,7 +21,7 @@ import './shared/packem.DvWhOdt5.js';
21
21
  import 'sucrase';
22
22
  import './shared/packem.C44tLE3n.js';
23
23
 
24
- declare const defineConfig: (config: BuildConfig | BuildConfig[]) => BuildConfig[];
24
+ declare const defineConfig: (config: BuildConfig) => BuildConfig;
25
25
  declare const definePreset: (preset: BuildPreset) => BuildPreset;
26
26
 
27
27
  export { BuildConfig, BuildPreset, defineConfig, definePreset };
package/dist/config.mjs CHANGED
@@ -6,4 +6,4 @@ import __cjs_mod__ from "node:module";
6
6
  const __filename = __cjs_url__.fileURLToPath(import.meta.url);
7
7
  const __dirname = __cjs_path__.dirname(__filename);
8
8
  const require = __cjs_mod__.createRequire(import.meta.url);
9
- var f=Object.defineProperty;var i=(e,r)=>f(e,"name",{value:r,configurable:!0});var a=Object.defineProperty,n=i((e,r)=>a(e,"name",{value:r,configurable:!0}),"i");const t=n(e=>(Array.isArray(e)?e:[e]).filter(Boolean),"defineConfig"),d=n(e=>e,"definePreset");export{t as defineConfig,d as definePreset};
9
+ var r=Object.defineProperty;var i=(e,n)=>r(e,"name",{value:n,configurable:!0});var t=Object.defineProperty,f=i((e,n)=>t(e,"name",{value:n,configurable:!0}),"i");const a=f(e=>e,"defineConfig"),d=f(e=>e,"definePreset");export{a as defineConfig,d as definePreset};
@@ -1,36 +1,36 @@
1
- "use strict";var ot=Object.defineProperty;var f=(e,t)=>ot(e,"name",{value:t,configurable:!0});const J=require("node:fs/promises"),nt=require("node:module"),j=require("node:process"),g=require("@visulima/colorize"),v=require("@visulima/fs"),rt=require("@visulima/fs/error"),D=require("@visulima/humanizer"),G=require("@visulima/package"),st=require("@visulima/package/package-json"),it=require("@visulima/pail"),U=require("@visulima/pail/processor"),m=require("@visulima/path"),at=require("defu"),lt=require("hookable"),O=require("./shared/packem.NVRVuzg1.cjs"),be=require("node:url"),W=require("mlly"),ct=require("magic-string"),pt=require("jiti"),Z=require("node:fs"),B=require("rollup"),ut=require("@rollup/plugin-alias"),dt=require("@rollup/plugin-commonjs"),mt=require("@rollup/plugin-dynamic-import-vars"),$e=require("@rollup/plugin-node-resolve"),ft=require("@rollup/plugin-replace"),gt=require("@rollup/plugin-wasm"),ht=require("rollup-plugin-polyfill-node"),yt=require("rollup-plugin-visualizer"),je=require("semver"),vt=require("glob"),bt=require("glob-parent"),$t=require("@rollup/plugin-json"),T=require("@rollup/pluginutils"),jt=require("rollup-plugin-license"),wt=require("node:crypto"),kt=require("@babel/parser"),xt=require("fastest-levenshtein");var se=typeof document<"u"?document.currentScript:null;const x=f(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),ie=x(nt),P=x(ct),we=x(pt),ke=x(ut),Et=x(dt),Ot=x(mt),xe=x(ft),St=x(ht),_t=x(bt),Dt=x($t),Nt=x(jt);var Pt=Object.defineProperty,z=f((e,t)=>Pt(e,"name",{value:t,configurable:!0}),"i$b");const ee=/^#![^\n]*/,K=z(async e=>{await J.chmod(e,493).catch(()=>{})},"makeExecutable"),Ft=z((e,t=`#!/usr/bin/env node
2
- `)=>({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"&&ee.test(s.code)&&o.dir){const a=m.resolve(o.dir,n);await K(a)}}}),"shebangPlugin"),Mt=z(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ee,"")}}),"removeShebangPlugin"),Ct=z((e,t=`
3
- `)=>{const o=ee.exec(e);return o?o+t:""},"getShebang");var It=Object.defineProperty,Rt=f((e,t)=>It(e,"name",{value:t,configurable:!0}),"p$3");const te=Rt((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]=m.join(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 Tt=Object.defineProperty,At=f((e,t)=>Tt(e,"name",{value:t,configurable:!0}),"o$3");const qt=At((e,t)=>{const o=we(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 Lt=Object.defineProperty,Wt=f((e,t)=>Lt(e,"name",{value:t,configurable:!0}),"r$8");const A=Wt((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Bt=Object.defineProperty,Jt=f((e,t)=>Bt(e,"name",{value:t,configurable:!0}),"u$7");const zt=Jt(async e=>{const t=await W.resolvePath("jiti",{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:se&&se.src||new URL("create-bundler.cjs",document.baseURI).href}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...te(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const r of e.options.entries){const n=m.resolve(e.options.rootDir,e.options.outDir,r.name),s=m.normalize(qt(r.input,e.options.rootDir)||r.input),a=s.slice(0,Math.max(0,s.length-m.extname(s).length)),i=await v.readFile(s),l=Ct(i);e.options.emitCJS&&await v.writeFile(`${n}.cjs`,l+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(a)})} */`,`module.exports = _jiti(${JSON.stringify(s)})`].join(`
4
- `));let c=[];try{c=await W.resolveModuleExportNames(s,{extensions:O.DEFAULT_EXTENSIONS})}catch(p){A(e,`Cannot analyze ${s} for exports:${p}`);return}const u=c.includes("default")||c.length===0;await v.writeFile(`${n}.mjs`,l+[`import jiti from ${JSON.stringify(be.pathToFileURL(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,u?`
5
- export default _module;`:"",...c.filter(p=>p!=="default").map(p=>`export const ${p} = _module.${p};`)].join(`
6
- `)),await v.writeFile(`${n}.d.cts`,[`export * from ${JSON.stringify(a)};`,u?`export { default } from ${JSON.stringify(a)};`:""].join(`
7
- `)),await v.writeFile(`${n}.d.mts`,[`export * from ${JSON.stringify(s)};`,u?`export { default } from ${JSON.stringify(s)};`:""].join(`
8
- `)),l&&(await K(`${n}.cjs`),await K(`${n}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Ut=Object.defineProperty,Ht=f((e,t)=>Ut(e,"name",{value:t,configurable:!0}),"r$7");const Ee=Ht((e,t)=>we(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var Vt=Object.defineProperty,Oe=f((e,t)=>Vt(e,"name",{value:t,configurable:!0}),"t$4");const oe=Oe(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Se=Oe((e,t,o,r)=>{if(o){const a=oe(o);if(a)return a}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 Se(n,s,o,r)},"inferExportType");var Xt=Object.defineProperty,Gt=f((e,t)=>Xt(e,"name",{value:t,configurable:!0}),"o$2");const ne=Gt((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=oe(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",subKey:n,type:Se(n,r,s,t)}:ne(s,t,o,[...r,n]))},"extractExportFilenames");var Kt=Object.defineProperty,_e=f((e,t)=>Kt(e,"name",{value:t,configurable:!0}),"d$4");const ae=_e((e,t,o,r,n,s,a)=>{const i=e.find(l=>l.input===t)??e[e.push({input:t})-1];if(o&&(i.outDir=r),n.file.includes(".min.")&&(i.minify=!0),n.isExecutable)i.executable=!0,i.declaration=!1,i.cjs=s.type==="commonjs",i.esm=s.type==="module";else{/\.d\.[mc]?ts$/.test(n.file)&&!a&&(i.declaration=a),n.type==="cjs"&&(i.cjs=!0),n.type==="esm"&&(i.esm=!0);for(const l of O.RUNTIME_EXPORT_CONVENTIONS)if(n.file.includes(l)){i.runtime=l;break}n.key==="exports"&&n.subKey==="production"?i.environment="production":n.key==="exports"&&n.subKey==="development"&&(i.environment="development")}},"createOrUpdateEntry"),le=/(?:\.d\.[mc]?ts|\.\w+)$/,Yt=_e((e,t,o)=>{const r=[];t.sort((i,l)=>i.split("/").length-l.split("/").length);const n=ne(e.exports,e.type??"commonjs",o.options.declaration);if(e.bin){const i=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const l of i)n.push({file:l,isExecutable:!0,key:"bin"})}e.main&&n.push({file:e.main,key:"main",type:oe(e.main)??(e.type==="module"?"esm":"cjs")}),e.module&&n.push({file:e.module,key:"module",type:"esm"}),o.options.declaration!==!1&&(e.types||e.typings)&&n.push({file:e.types??e.typings,key:"types"});const s=e.type==="module";for(const i of n.filter(l=>!l.type)){const l=i.file.endsWith(".js");s&&l||i.file.endsWith(".mjs")?i.type="esm":(!s&&l||i.file.endsWith(".cjs"))&&(i.type="cjs")}const a=[];for(const i of n){const l=i.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const u=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir);if(i.file.includes("/*")&&i.key==="exports"){o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub.");const y=[],h=new RegExp("(?<=/|$)"+u.replace("*","(.*)")+(c?"":"\\.\\w+"));for(const b of t)h.test(b)&&y.push(b.replace(le,""));if(y.length===0){r.push(`Could not find entrypoints for \`${i.file}\``);continue}for(const b of y)ae(a,b,c,l,i,e,o.options.declaration);continue}const p=new RegExp("(?<=/|$)"+u+(c?"":"\\.\\w+")),d=t.find(y=>p.test(y))?.replace(le,"");if(!d){Z.existsSync(m.resolve(o.options.rootDir,i.file))||r.push(`Could not find entrypoint for \`${i.file}\``);continue}ae(a,d,c,l,i,e,o.options.declaration)}return{entries:a,warnings:r}},"inferEntries");var Qt=Object.defineProperty,Zt=f((e,t)=>Qt(e,"name",{value:t,configurable:!0}),"t$3");const eo=Zt((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 to=Object.defineProperty,oo=f((e,t)=>to(e,"name",{value:t,configurable:!0}),"n$8");const no={hooks:{"build:prepare":oo(function(e){if(e.options.entries.length>0)return;const t=m.join(e.options.rootDir,"src");if(!Z.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=v.collectSync(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=eo(r,e.options.declaration));const n=Yt(r,o,e);for(const s of n.warnings)A(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:",g.cyan(e.options.entries.map(s=>g.bold(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),g.gray([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var ro=Object.defineProperty,so=f((e,t)=>ro(e,"name",{value:t,configurable:!0}),"t$2");const io=so((e,t)=>(e==="auto"?e=no:typeof e=="string"&&(e=Ee(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var ao=Object.defineProperty,lo=f((e,t)=>ao(e,"name",{value:t,configurable:!0}),"a$a");const Y=lo((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var co=Object.defineProperty,po=f((e,t)=>co(e,"name",{value:t,configurable:!0}),"a$9");const H=po(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var uo=Object.defineProperty,mo=f((e,t)=>uo(e,"name",{value:t,configurable:!0}),"e$1");const Q=mo((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var fo=Object.defineProperty,De=f((e,t)=>fo(e,"name",{value:t,configurable:!0}),"s$a");const go=De((e,t,o)=>{const r=o??new Map;return(...n)=>{const s=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),a=r.get(s);if(a!==void 0)return a;const i=e(...n);return r.set(s,i),i}},"memoize"),ho=De(e=>{const t=new Map;return o=>go(e,o,t)},"memoizeByKey");var yo=Object.defineProperty,vo=f((e,t)=>yo(e,"name",{value:t,configurable:!0}),"m$5");const Ne=vo(({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 a=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(a===null||a.length<3)return null;const i=new P(r);i.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),i.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&i.append(`
9
- module.exports.default = `+a[2]+";");let l=i.toString();return l=l.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:l,map:i.generateMap({hires:!0})}}if(s.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)){if(o!=="commonjs"&&n.fileName.endsWith(".d.ts"))return null;const a=/export\s\{\s(.*)\s\}/i.exec(r);if(a===null||a.length<2)return null;const i=a[1].split(", "),l=[];let c="";for(const p of i)if(!p.includes("type"))if(p.includes("as")){const[d,y]=p.split(" as ");if(y==="default"&&(c=d,!e))continue;l.push(y+": typeof "+d+";")}else l.push(p+": typeof "+p+";");const u=new P(r);return u.replace(" "+c+" as default,",""),u.append(`
1
+ "use strict";var tt=Object.defineProperty;var f=(e,t)=>tt(e,"name",{value:t,configurable:!0});const B=require("node:fs/promises"),ot=require("node:module"),$=require("node:process"),g=require("@visulima/colorize"),h=require("@visulima/fs"),nt=require("@visulima/fs/error"),_=require("@visulima/humanizer"),X=require("@visulima/package"),rt=require("@visulima/package/package-json"),st=require("@visulima/pail"),z=require("@visulima/pail/processor"),d=require("@visulima/path"),it=require("defu"),at=require("hookable"),O=require("./shared/packem.NVRVuzg1.cjs"),ve=require("node:url"),L=require("mlly"),lt=require("magic-string"),ct=require("jiti"),Q=require("node:fs"),W=require("rollup"),pt=require("@rollup/plugin-alias"),ut=require("@rollup/plugin-commonjs"),dt=require("@rollup/plugin-dynamic-import-vars"),be=require("@rollup/plugin-node-resolve"),mt=require("@rollup/plugin-replace"),ft=require("@rollup/plugin-wasm"),gt=require("rollup-plugin-polyfill-node"),ht=require("rollup-plugin-visualizer"),$e=require("semver"),yt=require("glob"),vt=require("glob-parent"),bt=require("@rollup/plugin-json"),R=require("@rollup/pluginutils"),$t=require("rollup-plugin-license"),jt=require("node:crypto"),wt=require("@babel/parser"),kt=require("fastest-levenshtein");var se=typeof document<"u"?document.currentScript:null;const E=f(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),ie=E(ot),N=E(lt),je=E(ct),we=E(pt),xt=E(ut),Et=E(dt),ke=E(mt),Ot=E(gt),St=E(vt),_t=E(bt),Dt=E($t);var Nt=Object.defineProperty,J=f((e,t)=>Nt(e,"name",{value:t,configurable:!0}),"i$b");const Z=/^#![^\n]*/,G=J(async e=>{await B.chmod(e,493).catch(()=>{})},"makeExecutable"),Pt=J((e,t=`#!/usr/bin/env node
2
+ `)=>({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 N(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"&&Z.test(s.code)&&o.dir){const a=d.resolve(o.dir,n);await G(a)}}}),"shebangPlugin"),Ft=J(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(Z,"")}}),"removeShebangPlugin"),Mt=J((e,t=`
3
+ `)=>{const o=Z.exec(e);return o?o+t:""},"getShebang");var Ct=Object.defineProperty,It=f((e,t)=>Ct(e,"name",{value:t,configurable:!0}),"p$3");const ee=It((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]=d.join(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 Rt=Object.defineProperty,Tt=f((e,t)=>Rt(e,"name",{value:t,configurable:!0}),"o$3");const At=Tt((e,t)=>{const o=je(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 qt=Object.defineProperty,Lt=f((e,t)=>qt(e,"name",{value:t,configurable:!0}),"r$8");const T=Lt((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Wt=Object.defineProperty,Bt=f((e,t)=>Wt(e,"name",{value:t,configurable:!0}),"u$7");const Jt=Bt(async e=>{const t=await L.resolvePath("jiti",{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:se&&se.src||new URL("create-bundler.cjs",document.baseURI).href}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...ee(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const r of e.options.entries){const n=d.resolve(e.options.rootDir,e.options.outDir,r.name),s=d.normalize(At(r.input,e.options.rootDir)||r.input),a=s.slice(0,Math.max(0,s.length-d.extname(s).length)),i=await h.readFile(s),c=Mt(i);e.options.emitCJS&&await h.writeFile(`${n}.cjs`,c+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(a)})} */`,`module.exports = _jiti(${JSON.stringify(s)})`].join(`
4
+ `));let l=[];try{l=await L.resolveModuleExportNames(s,{extensions:O.DEFAULT_EXTENSIONS})}catch(m){T(e,`Cannot analyze ${s} for exports:${m}`);return}const p=l.includes("default")||l.length===0;await h.writeFile(`${n}.mjs`,c+[`import jiti from ${JSON.stringify(ve.pathToFileURL(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,p?`
5
+ export default _module;`:"",...l.filter(m=>m!=="default").map(m=>`export const ${m} = _module.${m};`)].join(`
6
+ `)),await h.writeFile(`${n}.d.cts`,[`export * from ${JSON.stringify(a)};`,p?`export { default } from ${JSON.stringify(a)};`:""].join(`
7
+ `)),await h.writeFile(`${n}.d.mts`,[`export * from ${JSON.stringify(s)};`,p?`export { default } from ${JSON.stringify(s)};`:""].join(`
8
+ `)),c&&(await G(`${n}.cjs`),await G(`${n}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var zt=Object.defineProperty,Ut=f((e,t)=>zt(e,"name",{value:t,configurable:!0}),"r$7");const xe=Ut((e,t)=>je(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var Ht=Object.defineProperty,Ee=f((e,t)=>Ht(e,"name",{value:t,configurable:!0}),"t$4");const te=Ee(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Oe=Ee((e,t,o,r)=>{if(o){const a=te(o);if(a)return a}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 Oe(n,s,o,r)},"inferExportType");var Vt=Object.defineProperty,Xt=f((e,t)=>Vt(e,"name",{value:t,configurable:!0}),"o$2");const oe=Xt((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=te(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",subKey:n,type:Oe(n,r,s,t)}:oe(s,t,o,[...r,n]))},"extractExportFilenames");var Gt=Object.defineProperty,Se=f((e,t)=>Gt(e,"name",{value:t,configurable:!0}),"d$4");const ae=Se((e,t,o,r,n,s,a)=>{const i=e.find(c=>c.input===t)??e[e.push({input:t})-1];if(o&&(i.outDir=r),n.file.includes(".min.")&&(i.minify=!0),n.isExecutable)i.executable=!0,i.declaration=!1,i.cjs=s.type==="commonjs",i.esm=s.type==="module";else{/\.d\.[mc]?ts$/.test(n.file)&&!a&&(i.declaration=a),n.type==="cjs"&&(i.cjs=!0),n.type==="esm"&&(i.esm=!0);for(const c of O.RUNTIME_EXPORT_CONVENTIONS)if(n.file.includes(c)){i.runtime=c;break}n.key==="exports"&&n.subKey==="production"?i.environment="production":n.key==="exports"&&n.subKey==="development"&&(i.environment="development")}},"createOrUpdateEntry"),le=/(?:\.d\.[mc]?ts|\.\w+)$/,Kt=Se((e,t,o)=>{const r=[];t.sort((i,c)=>i.split("/").length-c.split("/").length);const n=oe(e.exports,e.type??"commonjs",o.options.declaration);if(e.bin){const i=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const c of i)n.push({file:c,isExecutable:!0,key:"bin"})}e.main&&n.push({file:e.main,key:"main",type:te(e.main)??(e.type==="module"?"esm":"cjs")}),e.module&&n.push({file:e.module,key:"module",type:"esm"}),o.options.declaration!==!1&&(e.types||e.typings)&&n.push({file:e.types??e.typings,key:"types"});const s=e.type==="module";for(const i of n.filter(c=>!c.type)){const c=i.file.endsWith(".js");s&&c||i.file.endsWith(".mjs")?i.type="esm":(!s&&c||i.file.endsWith(".cjs"))&&(i.type="cjs")}const a=[];for(const i of n){const c=i.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),l=c.endsWith("/");if(l&&["./","/"].includes(c))continue;const p=c.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir);if(i.file.includes("/*")&&i.key==="exports"){o.logger.warn("Private subfolders are not supported, if you need this feature please open an issue on GitHub.");const y=[],w=new RegExp("(?<=/|$)"+p.replace("*","(.*)")+(l?"":"\\.\\w+"));for(const S of t)w.test(S)&&y.push(S.replace(le,""));if(y.length===0){r.push(`Could not find entrypoints for \`${i.file}\``);continue}for(const S of y)ae(a,S,l,c,i,e,o.options.declaration);continue}const m=new RegExp("(?<=/|$)"+p+(l?"":"\\.\\w+")),u=t.find(y=>m.test(y))?.replace(le,"");if(!u){Q.existsSync(d.resolve(o.options.rootDir,i.file))||r.push(`Could not find entrypoint for \`${i.file}\``);continue}ae(a,u,l,c,i,e,o.options.declaration)}return{entries:a,warnings:r}},"inferEntries");var Yt=Object.defineProperty,Qt=f((e,t)=>Yt(e,"name",{value:t,configurable:!0}),"t$3");const Zt=Qt((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 eo=Object.defineProperty,to=f((e,t)=>eo(e,"name",{value:t,configurable:!0}),"n$8");const oo={hooks:{"build:prepare":to(function(e){if(e.options.entries.length>0)return;const t=d.join(e.options.rootDir,"src");if(!Q.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=h.collectSync(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=Zt(r,e.options.declaration));const n=Kt(r,o,e);for(const s of n.warnings)T(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:",g.cyan(e.options.entries.map(s=>g.bold(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),g.gray([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var no=Object.defineProperty,ro=f((e,t)=>no(e,"name",{value:t,configurable:!0}),"t$2");const so=ro((e,t)=>(e==="auto"?e=oo:typeof e=="string"&&(e=xe(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var io=Object.defineProperty,ao=f((e,t)=>io(e,"name",{value:t,configurable:!0}),"a$a");const K=ao((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var lo=Object.defineProperty,co=f((e,t)=>lo(e,"name",{value:t,configurable:!0}),"a$9");const U=co(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var po=Object.defineProperty,uo=f((e,t)=>po(e,"name",{value:t,configurable:!0}),"e$1");const Y=uo((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var mo=Object.defineProperty,_e=f((e,t)=>mo(e,"name",{value:t,configurable:!0}),"s$a");const fo=_e((e,t,o)=>{const r=o??new Map;return(...n)=>{const s=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),a=r.get(s);if(a!==void 0)return a;const i=e(...n);return r.set(s,i),i}},"memoize"),go=_e(e=>{const t=new Map;return o=>fo(e,o,t)},"memoizeByKey");var ho=Object.defineProperty,yo=f((e,t)=>ho(e,"name",{value:t,configurable:!0}),"m$6");const De=yo(({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 a=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(a===null||a.length<3)return null;const i=new N(r);i.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),i.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&i.append(`
9
+ module.exports.default = `+a[2]+";");let c=i.toString();return c=c.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:c,map:i.generateMap({hires:!0})}}if(s.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)){if(o!=="commonjs"&&n.fileName.endsWith(".d.ts"))return null;const a=/export\s\{\s(.*)\s\}/i.exec(r);if(a===null||a.length<2)return null;const i=a[1].split(", "),c=[];let l="";for(const m of i)if(!m.includes("type"))if(m.includes("as")){const[u,y]=m.split(" as ");if(y==="default"&&(l=u,!e))continue;c.push(y+": typeof "+u+";")}else c.push(m+": typeof "+m+";");const p=new N(r);return p.replace(" "+l+" as default,",""),p.append(`
10
10
 
11
11
  declare const defaultExport: {
12
- `+(l.length>0?" ":"")+l.join(`
12
+ `+(c.length>0?" ":"")+c.join(`
13
13
  `)+`
14
- } & typeof `+c+`;
14
+ } & typeof `+l+`;
15
15
 
16
- export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:u.toString(),map:u.generateMap({hires:!0})}}return null}}),"cjsInterop");var bo=Object.defineProperty,$o=f((e,t)=>bo(e,"name",{value:t,configurable:!0}),"f$7");const jo=$o((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(a=>Array.isArray(a.src)?a.src.map(i=>({...a,src:i})):a).map(async a=>await vt.glob(a.src,{ignore:a.exclude}).then(i=>({dest:a.dest??"",parent:_t(a.src),src:i}))));for(const a of s)for(const i of a.src){let l;o.has(i)?l=o.get(i):(l={copied:[],dest:[],timestamp:0},o.set(i,l));const c=r.flatten?m.normalize(a.dest):m.join(a.dest,m.relative(a.parent,m.dirname(i)));l.dest.includes(c)||l.dest.push(c),this.addWatchFile(i)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([a,i])=>{let l;try{const c=await J.stat(a);if(!c.isFile())return;const u=c.mtime.getTime();u>i.timestamp&&(i.timestamp=u,i.copied=[]),l=await v.readFile(a,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${a}`,prefix:"plugin:copy"});return}for(const c of i.dest){if(r.copyOnce&&i.copied.includes(c))continue;const u=m.basename(a),p=m.join(c,u);try{this.emitFile({[r.exactFileNames?"fileName":"name"]:p,source:l,type:"asset"}),t.debug({message:`copied ${a} → ${p}`,prefix:"plugin:copy"}),i.copied.push(c)}catch(d){t.error({context:[d],message:`error copying file ${a} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var wo=Object.defineProperty,ko=f((e,t)=>wo(e,"name",{value:t,configurable:!0}),"n$4");const ce="export default ",Pe=ko(e=>{const t=Dt(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(ce)&&(n.code=n.code.replace(ce,"module.exports = ")),n}}},"JSONPlugin");class xo{static{f(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:f(()=>this.should_skip=!0,"skip"),remove:f(()=>this.should_remove=!0,"remove"),replace:f(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 Eo extends xo{static{f(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:f(()=>this.should_skip=!0,"skip"),remove:f(()=>this.should_remove=!0,"remove"),replace:f(r=>this.replacement=r,"replace")},this.enter=t,this.leave=o}visit(t,o,r,n){if(t){if(this.enter){const a=this.should_skip,i=this.should_remove,l=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,u=this.should_remove;if(this.should_skip=a,this.should_remove=i,this.replacement=l,c)return t;if(u)return null}let s;for(s in t){const a=t[s];if(a&&typeof a=="object")if(Array.isArray(a)){const i=a;for(let l=0;l<i.length;l+=1){const c=i[l];pe(c)&&(this.visit(c,t,s,l)||l--)}}else pe(a)&&this.visit(a,t,s,null)}if(this.leave){const a=this.replacement,i=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 l=this.should_remove;if(this.replacement=a,this.should_remove=i,l)return null}}return t}}function pe(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}f(pe,"isNode");function Fe(e,{enter:t,leave:o}){return new Eo(t,o).visit(e,null)}f(Fe,"walk");var Oo=Object.defineProperty,So=f((e,t)=>Oo(e,"name",{value:t,configurable:!0}),"u$5");const _o=So(({attributes:e,logger:t})=>{const o=T.createFilter([/\.[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(l){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${n}" and remove the jsx attribute.`}),t.warn(l),null}let a=!1;const i=new P(r);return Fe(s,{enter(l){if(l.type==="CallExpression"&&l.callee.type==="Identifier"&&l.callee.name==="jsx"){const c=l.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of c)for(const p of u.properties)p.type==="Property"&&p.key.type==="Literal"&&p.value.type==="Literal"&&e.includes(p.key.value)&&(i.overwrite(p.start-2,p.end,""),a=!0)}}}),a?{code:i.toString(),map:i.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Do=Object.defineProperty,re=f((e,t)=>Do(e,"name",{value:t,configurable:!0}),"p$1");const No=re(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),Po=re((e,t,o)=>{const r=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(r.test(e))return e.replace(r,`$1
16
+ 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 vo=Object.defineProperty,bo=f((e,t)=>vo(e,"name",{value:t,configurable:!0}),"f$6");const $o=bo((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(a=>Array.isArray(a.src)?a.src.map(i=>({...a,src:i})):a).map(async a=>await yt.glob(a.src,{ignore:a.exclude}).then(i=>({dest:a.dest??"",parent:St(a.src),src:i}))));for(const a of s)for(const i of a.src){let c;o.has(i)?c=o.get(i):(c={copied:[],dest:[],timestamp:0},o.set(i,c));const l=r.flatten?d.normalize(a.dest):d.join(a.dest,d.relative(a.parent,d.dirname(i)));c.dest.includes(l)||c.dest.push(l),this.addWatchFile(i)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([a,i])=>{let c;try{const l=await B.stat(a);if(!l.isFile())return;const p=l.mtime.getTime();p>i.timestamp&&(i.timestamp=p,i.copied=[]),c=await h.readFile(a,{buffer:!0})}catch(l){t.error({context:[l],message:`error reading file ${a}`,prefix:"plugin:copy"});return}for(const l of i.dest){if(r.copyOnce&&i.copied.includes(l))continue;const p=d.basename(a),m=d.join(l,p);try{this.emitFile({[r.exactFileNames?"fileName":"name"]:m,source:c,type:"asset"}),t.debug({message:`copied ${a} → ${m}`,prefix:"plugin:copy"}),i.copied.push(l)}catch(u){t.error({context:[u],message:`error copying file ${a} → ${m}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var jo=Object.defineProperty,wo=f((e,t)=>jo(e,"name",{value:t,configurable:!0}),"n$4");const ce="export default ",Ne=wo(e=>{const t=_t(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(ce)&&(n.code=n.code.replace(ce,"module.exports = ")),n}}},"JSONPlugin");class ko{static{f(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:f(()=>this.should_skip=!0,"skip"),remove:f(()=>this.should_remove=!0,"remove"),replace:f(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 xo extends ko{static{f(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:f(()=>this.should_skip=!0,"skip"),remove:f(()=>this.should_remove=!0,"remove"),replace:f(r=>this.replacement=r,"replace")},this.enter=t,this.leave=o}visit(t,o,r,n){if(t){if(this.enter){const a=this.should_skip,i=this.should_remove,c=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 l=this.should_skip,p=this.should_remove;if(this.should_skip=a,this.should_remove=i,this.replacement=c,l)return t;if(p)return null}let s;for(s in t){const a=t[s];if(a&&typeof a=="object")if(Array.isArray(a)){const i=a;for(let c=0;c<i.length;c+=1){const l=i[c];pe(l)&&(this.visit(l,t,s,c)||c--)}}else pe(a)&&this.visit(a,t,s,null)}if(this.leave){const a=this.replacement,i=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 c=this.should_remove;if(this.replacement=a,this.should_remove=i,c)return null}}return t}}function pe(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}f(pe,"isNode");function Pe(e,{enter:t,leave:o}){return new xo(t,o).visit(e,null)}f(Pe,"walk");var Eo=Object.defineProperty,Oo=f((e,t)=>Eo(e,"name",{value:t,configurable:!0}),"u$5");const So=Oo(({attributes:e,logger:t})=>{const o=R.createFilter([/\.[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(c){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${n}" and remove the jsx attribute.`}),t.warn(c),null}let a=!1;const i=new N(r);return Pe(s,{enter(c){if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="jsx"){const l=c.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of l)for(const m of p.properties)m.type==="Property"&&m.key.type==="Literal"&&m.value.type==="Literal"&&e.includes(m.key.value)&&(i.overwrite(m.start-2,m.end,""),a=!0)}}}),a?{code:i.toString(),map:i.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var _o=Object.defineProperty,ne=f((e,t)=>_o(e,"name",{value:t,configurable:!0}),"p$1");const Do=ne(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),No=ne((e,t,o)=>{const r=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(r.test(e))return e.replace(r,`$1
17
17
  ${o}
18
- $2`)},"replaceContentWithin"),Me=re(({licenseFilePath:e,licenseTemplate:t,logger:o,marker:r,mode:n,packageName:s})=>Nt({thirdParty(a){const i=new Set,l=a.sort(({name:u},{name:p})=>u>p?1:p>u?-1:0).map(({author:u,contributors:p,license:d,licenseText:y,maintainers:h,name:b,repository:E})=>{let F="## "+b+`
19
- `;d&&(F+=`License: ${d}
20
- `);const M=new Set;for(const S of[u,...h,...p]){const _=typeof S=="string"?S:S?.name;_&&M.add(_)}return M.size>0&&(F+=`By: ${[...M].join(", ")}
21
- `),E&&(F+=`Repository: ${typeof E=="string"?E:E.url}
22
- `),y&&(F+=`
18
+ $2`)},"replaceContentWithin"),Fe=ne(({licenseFilePath:e,licenseTemplate:t,logger:o,marker:r,mode:n,packageName:s})=>Dt({thirdParty(a){const i=new Set,c=a.sort(({name:p},{name:m})=>p>m?1:m>p?-1:0).map(({author:p,contributors:m,license:u,licenseText:y,maintainers:w,name:S,repository:P})=>{let k="## "+S+`
19
+ `;u&&(k+=`License: ${u}
20
+ `);const v=new Set;for(const F of[p,...w,...m]){const re=typeof F=="string"?F:F?.name;re&&v.add(re)}return v.size>0&&(k+=`By: ${[...v].join(", ")}
21
+ `),P&&(k+=`Repository: ${typeof P=="string"?P:P.url}
22
+ `),y&&(k+=`
23
23
  `+y.trim().replaceAll(/(\r\n|\r)/g,`
24
24
  `).split(`
25
- `).map(S=>`> ${S}`).join(`
25
+ `).map(F=>`> ${F}`).join(`
26
26
  `)+`
27
- `),d&&i.add(d),F}).join(`
27
+ `),u&&i.add(u),k}).join(`
28
28
  ---------------------------------------
29
29
 
30
- `);if(l===""){o.info({message:"No dependencies license information found.",prefix:"plugin:license:"+n});return}const c=t(No(i),l,s);try{const u=v.readFileSync(e),p=Po(u,r,c);if(!p){o.error({message:`Could not find the license marker: <!-- ${r} --> in ${e}`,prefix:"plugin:license:"+n});return}u!==p&&(v.writeFileSync(e,p),o.info({message:`${e} updated.`,prefix:"plugin:license:"+n}))}catch(u){o.error(u)}}}),"license");var Fo=Object.defineProperty,Mo=f((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"i$7");const Co=Mo(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=m.resolve(e.rootDir,e.outDir,"graph.json");v.writeJsonSync(o,t)},name:"packem:metafile"}),"metafilePlugin");var Io=Object.defineProperty,Ro=f((e,t)=>Io(e,"name",{value:t,configurable:!0}),"r$5");const C=Ro(e=>{const t=wt.createHash("md5");return t.update(e),t.digest("hex")},"getHash");var To=Object.defineProperty,Ce=f((e,t)=>To(e,"name",{value:t,configurable:!0}),"m$4");const R=Ce(e=>e.handler||e,"getHandler"),k=Ce((e,t)=>({...e,async buildEnd(o){e.buildEnd&&await R(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await R(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const r=m.join("load",C(o));if(t.has(r,e.name))return await t.get(r,e.name);const n=await R(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=m.join("resolveId",C(o),r?C(r):"",C(JSON.stringify(n)));if(t.has(s,e.name))return await t.get(s,e.name);const a=await R(e.resolveId).call(this,o,r,n);return t.set(s,a,e.name),a},async transform(o,r){if(!e.transform)return null;const n=m.join("transform",C(r),C(o));if(t.has(n,e.name))return await t.get(n,e.name);const s=await R(e.transform).call(this,o,r);return t.set(n,s,e.name),s}}),"cachingPlugin");var Ao=Object.defineProperty,qo=f((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"c$4");const Lo=/\.(?:m|c)?(?:j|t)sx?$/,Wo=/^use \w+$/,Bo=qo(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 a=n.moduleIds.map(c=>t[c]?t[c]:null).reduce((c,u)=>(u&&u.forEach(p=>{c.add(p)}),c),new Set),i=new P(r);a.size>0&&(e.debug({message:`directives for chunk "${n.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),i.prepend(`${[...a].map(c=>`'${c}';`).join(`
30
+ `);if(c===""){o.info({message:"No dependencies license information found.",prefix:"plugin:license:"+n});return}const l=t(Do(i),c,s);try{const p=h.readFileSync(e),m=No(p,r,l);if(!m){o.error({message:`Could not find the license marker: <!-- ${r} --> in ${e}`,prefix:"plugin:license:"+n});return}p!==m&&(h.writeFileSync(e,m),o.info({message:`${e} updated.`,prefix:"plugin:license:"+n}))}catch(p){o.error(p)}}}),"license");var Po=Object.defineProperty,Fo=f((e,t)=>Po(e,"name",{value:t,configurable:!0}),"i$7");const Mo=Fo(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=d.resolve(e.rootDir,e.outDir,"graph.json");h.writeJsonSync(o,t)},name:"packem:metafile"}),"metafilePlugin");var Co=Object.defineProperty,Io=f((e,t)=>Co(e,"name",{value:t,configurable:!0}),"r$5");const M=Io(e=>{const t=jt.createHash("md5");return t.update(e),t.digest("hex")},"getHash");var Ro=Object.defineProperty,Me=f((e,t)=>Ro(e,"name",{value:t,configurable:!0}),"m$5");const I=Me(e=>e.handler||e,"getHandler"),x=Me((e,t)=>({...e,async buildEnd(o){e.buildEnd&&await I(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await I(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const r=d.join("load",M(o));if(t.has(r,e.name))return await t.get(r,e.name);const n=await I(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=d.join("resolveId",M(o),r?M(r):"",M(JSON.stringify(n)));if(t.has(s,e.name))return await t.get(s,e.name);const a=await I(e.resolveId).call(this,o,r,n);return t.set(s,a,e.name),a},async transform(o,r){if(!e.transform)return null;const n=d.join("transform",M(r),M(o));if(t.has(n,e.name))return await t.get(n,e.name);const s=await I(e.transform).call(this,o,r);return t.set(n,s,e.name),s}}),"cachingPlugin");var To=Object.defineProperty,Ao=f((e,t)=>To(e,"name",{value:t,configurable:!0}),"c$4");const qo=/\.(?:m|c)?(?:j|t)sx?$/,Lo=/^use \w+$/,Wo=Ao(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 a=n.moduleIds.map(l=>t[l]?t[l]:null).reduce((l,p)=>(p&&p.forEach(m=>{l.add(m)}),l),new Set),i=new N(r);a.size>0&&(e.debug({message:`directives for chunk "${n.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),i.prepend(`${[...a].map(l=>`'${l}';`).join(`
31
31
  `)}
32
- `));let l=null;return n.facadeModuleId&&typeof o[n.facadeModuleId]=="string"&&(l=o[n.facadeModuleId]),l&&(e.debug({message:`shebang for chunk "${n.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),i.prepend(`${l}
33
- `)),a.size===0&&l===null?null:{code:i.toString(),map:s?i.generateMap({hires:!0}):null}},order:"post"},transform:{handler(r,n){const s=m.extname(n);if(!Lo.test(s))return null;let a=!1;const i=new P(r);if(r.startsWith("#")&&r[1]==="!"){let c=0;for(let u=2,p=r.length;u<p;u++){const d=r.codePointAt(u);if(d===10||d===13||d===8232||d===8233){c=u;break}}c&&(o[n]=r.slice(0,c),i.remove(0,c+1),a=!0,e.debug({message:`shebang for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}let l=null;try{l=this.parse(i.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(l.type!=="Program")return null;for(const c of l.body.filter(Boolean)){if(c.type!=="ExpressionStatement")break;let u=null;"directive"in c?u=c.directive:c.expression.type==="Literal"&&typeof c.expression.value=="string"&&Wo.test(c.expression.value)&&(u=c.expression.value),u!=="use strict"&&u&&(t[n]||=new Set,t[n].add(u),"start"in c&&typeof c.start=="number"&&"end"in c&&typeof c.end=="number"&&(i.remove(c.start,c.end),a=!0),e.debug({message:`directive "${u}" for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}return a?{code:i.toString(),map:i.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[n]??[]],shebang:o[n]??null}}}:null},order:"post"}}},"preserveDirectives");var Jo=Object.defineProperty,zo=f((e,t)=>Jo(e,"name",{value:t,configurable:!0}),"r$4");const Uo={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},Ho=zo((e={})=>{e={...e,...Uo};const t=T.createFilter(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 Vo=Object.defineProperty,Xo=f((e,t)=>Vo(e,"name",{value:t,configurable:!0}),"l$2");const V="\0__file_url__",Ie=Xo(()=>({async load(e){if(e.startsWith(V)){const t=be.fileURLToPath(e.slice(V.length));return await v.readFile(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${V}${e}`}}),"resolveFileUrl");var Go=Object.defineProperty,Re=f((e,t)=>Go(e,"name",{value:t,configurable:!0}),"i$3");const Ko=/__filename|__dirname|require\(|require\.resolve\(/,Te=`
32
+ `));let c=null;return n.facadeModuleId&&typeof o[n.facadeModuleId]=="string"&&(c=o[n.facadeModuleId]),c&&(e.debug({message:`shebang for chunk "${n.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),i.prepend(`${c}
33
+ `)),a.size===0&&c===null?null:{code:i.toString(),map:s?i.generateMap({hires:!0}):null}},order:"post"},transform:{handler(r,n){const s=d.extname(n);if(!qo.test(s))return null;let a=!1;const i=new N(r);if(r.startsWith("#")&&r[1]==="!"){let l=0;for(let p=2,m=r.length;p<m;p++){const u=r.codePointAt(p);if(u===10||u===13||u===8232||u===8233){l=p;break}}l&&(o[n]=r.slice(0,l),i.remove(0,l+1),a=!0,e.debug({message:`shebang for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}let c=null;try{c=this.parse(i.toString(),{allowReturnOutsideFunction:!0})}catch(l){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${n}" and extract the directives.`}),e.warn(l),null}if(c.type!=="Program")return null;for(const l of c.body.filter(Boolean)){if(l.type!=="ExpressionStatement")break;let p=null;"directive"in l?p=l.directive:l.expression.type==="Literal"&&typeof l.expression.value=="string"&&Lo.test(l.expression.value)&&(p=l.expression.value),p!=="use strict"&&p&&(t[n]||=new Set,t[n].add(p),"start"in l&&typeof l.start=="number"&&"end"in l&&typeof l.end=="number"&&(i.remove(l.start,l.end),a=!0),e.debug({message:`directive "${p}" for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}return a?{code:i.toString(),map:i.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[n]??[]],shebang:o[n]??null}}}:null},order:"post"}}},"preserveDirectives");var Bo=Object.defineProperty,Jo=f((e,t)=>Bo(e,"name",{value:t,configurable:!0}),"r$4");const zo={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},Uo=Jo((e={})=>{e={...e,...zo};const t=R.createFilter(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 Ho=Object.defineProperty,Vo=f((e,t)=>Ho(e,"name",{value:t,configurable:!0}),"l$2");const H="\0__file_url__",Ce=Vo(()=>({async load(e){if(e.startsWith(H)){const t=ve.fileURLToPath(e.slice(H.length));return await h.readFile(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${H}${e}`}}),"resolveFileUrl");var Xo=Object.defineProperty,Ie=f((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"i$3");const Go=/__filename|__dirname|require\(|require\.resolve\(/,Re=`
34
34
  // -- pack CommonJS Shims --
35
35
  import __cjs_url__ from "node:url";
36
36
  import __cjs_path__ from "node:path";
@@ -38,56 +38,56 @@ import __cjs_mod__ from "node:module";
38
38
  const __filename = __cjs_url__.fileURLToPath(import.meta.url);
39
39
  const __dirname = __cjs_path__.dirname(__filename);
40
40
  const require = __cjs_mod__.createRequire(import.meta.url);
41
- `,Ae=`
41
+ `,Te=`
42
42
  // -- pack CommonJS Shims Node 20.11 --
43
43
  import __cjs_mod__ from "node:module";
44
44
  const __filename = import.meta.filename;
45
45
  const __dirname = import.meta.dirname;
46
46
  const require = __cjs_mod__.createRequire(import.meta.url);
47
- `,Yo=Re((e,t)=>{if(j.env.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(Te)||e.includes(Ae)||!Ko.test(e)))return null;const o=W.findStaticImports(e).pop(),r=o?o.end:0,n=new P(e);return n.appendRight(r,t),{code:n.toString(),map:n.generateMap()}},"CJSToESM"),Qo=Re(e=>({name:"packem:cjs",renderChunk(t,o,r){if(r.format==="es"){let n=Te;if(e.engines?.node){const s=je.minVersion(e.engines.node);s&&s.major>=20&&s.minor>=11&&(n=Ae)}return Yo(t,n)}return null}}),"cjsPlugin");var Zo=Object.defineProperty,I=f((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"s$6");const en=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,tn=/MIT License|MIT license|BSD license/,on=/\n{2,}/g,nn=/\b(\w+)\$\d+\b/g,rn=/[-/\\^$*+?.()|[\]{}]/g,sn=I(e=>e.replaceAll(rn,"\\$&"),"escapeRegex"),an=I(e=>[...new Set(e)],"unique"),ln=I(e=>e.replaceAll(en,t=>tn.test(t)?"":t).replaceAll(on,`
47
+ `,Ko=Ie((e,t)=>{if($.env.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(Re)||e.includes(Te)||!Go.test(e)))return null;const o=L.findStaticImports(e).pop(),r=o?o.end:0,n=new N(e);return n.appendRight(r,t),{code:n.toString(),map:n.generateMap()}},"CJSToESM"),Yo=Ie(e=>({name:"packem:cjs",renderChunk(t,o,r){if(r.format==="es"){let n=Re;if(e.engines?.node){const s=$e.minVersion(e.engines.node);s&&s.major>=20&&s.minor>=11&&(n=Te)}return Ko(t,n)}return null}}),"cjsPlugin");var Qo=Object.defineProperty,C=f((e,t)=>Qo(e,"name",{value:t,configurable:!0}),"s$6");const Zo=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,en=/MIT License|MIT license|BSD license/,tn=/\n{2,}/g,on=/\b(\w+)\$\d+\b/g,nn=/[-/\\^$*+?.()|[\]{}]/g,rn=C(e=>e.replaceAll(nn,"\\$&"),"escapeRegex"),sn=C(e=>[...new Set(e)],"unique"),an=C(e=>e.replaceAll(Zo,t=>en.test(t)?"":t).replaceAll(tn,`
48
48
 
49
- `),"cleanUnnecessaryComments"),ue=new Map;function qe(e,t,{identifierReplacements:o},r){const n=W.findStaticImports(e);for(const a in o){const i=n.find(c=>c.specifier===a&&c.imports.includes("{"));if(!i){this.warn(`${t.fileName} does not import "${a}" for replacement`),process.exitCode=1;continue}const l=o[a];for(const c in l){i.imports.includes(c)||(this.warn(`${t.fileName} does not import "${c}" from "${a}" for replacement`),j.exit(1));const u=l[c],p=sn(c);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${p},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${p}\\b`,"g"),u)}}const s=an(Array.from(e.matchAll(nn),a=>a[0]));if(s.length>0){const a=s.map(l=>`
50
- - ${l}`).join(""),i=t.fileName.replace(/\.[^/.]+$/,"");ue.has(i)||r.warn({message:`${t.fileName} contains confusing identifier names${a}
49
+ `),"cleanUnnecessaryComments"),ue=new Map;function Ae(e,t,{identifierReplacements:o},r){const n=L.findStaticImports(e);for(const a in o){const i=n.find(l=>l.specifier===a&&l.imports.includes("{"));if(!i){this.warn(`${t.fileName} does not import "${a}" for replacement`),process.exitCode=1;continue}const c=o[a];for(const l in c){i.imports.includes(l)||(this.warn(`${t.fileName} does not import "${l}" from "${a}" for replacement`),$.exit(1));const p=c[l],m=rn(l);p.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${m},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${m}\\b`,"g"),p)}}const s=sn(Array.from(e.matchAll(on),a=>a[0]));if(s.length>0){const a=s.map(c=>`
50
+ - ${c}`).join(""),i=t.fileName.replace(/\.[^/.]+$/,"");ue.has(i)||r.warn({message:`${t.fileName} contains confusing identifier names${a}
51
51
 
52
- To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),ue.set(i,!0)}return e}f(qe,"v$1");I(qe,"replaceConfusingTypeNames");function Le(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}f(Le,"N");I(Le,"removeInternal");function We(e,t){if(e.includes("@internal")){const o=new P(e),r=kt.parse(e,{plugins:["typescript"],sourceType:"module"});Fe(r,{enter(n){Le(o,n)&&this.skip()}}),e=o.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),j.exit(1))}return e}f(We,"S");I(We,"stripInternalTypes");const cn=I((e,t)=>({name:"packem:patch-types",renderChunk(o,r){return o=qe.call(this,o,r,e,t),o=We.call(this,o,r),o=ln(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var pn=Object.defineProperty,Be=f((e,t)=>pn(e,"name",{value:t,configurable:!0}),"u$3");const Je=Be((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 a=m.resolve(m.dirname(r),n),i=[];if(s)for(const[l,c]of Object.entries(s)){const u=new RegExp(`^${[...l].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let p=0;for(const d of c){const y=[...T.normalizePath(m.resolve(a,d))].map(h=>h==="*"?`$${++p}`:h==="$"?"$$":h).join("");i.push({find:u,replacement:y})}}return t&&i.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...T.normalizePath(a)].map(l=>l==="$"?"$$":l).join("")}/$1`}),i},"getConfigAlias"),ze=Be((e,t)=>{const o=Je(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(r,n,s){if(!o||r.includes("\0"))return null;for(const{find:a,replacement:i}of o)if(a.test(r)){const l=r.replace(a,i),c=await this.resolve(l,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 un=Object.defineProperty,Ue=f((e,t)=>un(e,"name",{value:t,configurable:!0}),"u$2");const dn=Ue((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 a of n){if(a.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(a.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);s.push(m.resolve(e,a))}return s},"getRootDirectories"),He=Ue((e,t,o)=>{const r=dn(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,s,a){if(r===null||r.length===0)return null;if(n.startsWith("."))for(const i of r){const l=m.join(i,n),c=await this.resolve(l,s,{skipSelf:!0,...a});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 mn=Object.defineProperty,fn=f((e,t)=>mn(e,"name",{value:t,configurable:!0}),"r$3");const Ve=fn(()=>{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 gn=Object.defineProperty,hn=f((e,t)=>gn(e,"name",{value:t,configurable:!0}),"s$5");const yn=hn(e=>{const t=m.basename(e).split(".");if(t.length>=2){const[o,r]=t.slice(-2),n=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(O.DEFAULT_EXTENSIONS.includes(r)&&s&&s.length>0)return n+"-"+s}},"getCustomModuleLayer");var vn=Object.defineProperty,bn=f((e,t)=>vn(e,"name",{value:t,configurable:!0}),"i$2");const X=bn(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var $n=Object.defineProperty,de=f((e,t)=>$n(e,"name",{value:t,configurable:!0}),"c$2");const me=de((e,t)=>{const o=new Map;return de(function(r,n){const s=n.getModuleInfo(r);if(!s)return;const{isEntry:a}=s,i=s.meta,l=X(i);if(!a){const c=o.get(r);if(c)return c;const u=yn(r);if(u)return o.set(r,u),u}if(a){const c=n.getModuleIds();for(const u of c)n.getModuleInfo(u)&&X(i)===l&&(e.has(u)||e.set(u,new Set),e.get(u).add([r,l]))}if(l&&!a&&e.has(r)){const c=[...e.get(r)];if(c.some(([p])=>{if(t.some(d=>d.path===p)){const d=n.getModuleInfo(p);return X(d?d.meta:{})===l}return!1}))return;if(c.every(([,p])=>p===l))return o.has(r)?o.get(r):void 0;const u=`${m.basename(r,m.extname(r))}-${l}`;return o.set(r,u),u}},"splitChunks")},"createSplitChunks");var jn=Object.defineProperty,wn=f((e,t)=>jn(e,"name",{value:t,configurable:!0}),"n$2");const N=wn((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var kn=Object.defineProperty,xn=f((e,t)=>kn(e,"name",{value:t,configurable:!0}),"s$3");const En=process.platform==="win32",fe=xn((e,t)=>{const o=En?"\\":"/";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 On=Object.defineProperty,$=f((e,t)=>On(e,"name",{value:t,configurable:!0}),"p");const Sn=$((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"+j.versions.node.split(".")[0];if(t.pkg.engines?.node){const r=je.minVersion(t.pkg.engines.node);r&&(o="node"+r.major)}if(t.options.rollup.esbuild.target){const r=H(t.options.rollup.esbuild.target);r.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...H(o),...r])])}else t.options.rollup.esbuild.target=H(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"),Xe=$((e,t)=>e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message)?!0:e.code==="UNRESOLVED_IMPORT"?(t.logger.error(`Failed to resolve the module "${e.exporter}" imported by "${g.cyan(m.relative(m.resolve(),e.id))}"
52
+ To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),ue.set(i,!0)}return e}f(Ae,"v$1");C(Ae,"replaceConfusingTypeNames");function qe(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}f(qe,"N");C(qe,"removeInternal");function Le(e,t){if(e.includes("@internal")){const o=new N(e),r=wt.parse(e,{plugins:["typescript"],sourceType:"module"});Pe(r,{enter(n){qe(o,n)&&this.skip()}}),e=o.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),$.exit(1))}return e}f(Le,"S");C(Le,"stripInternalTypes");const ln=C((e,t)=>({name:"packem:patch-types",renderChunk(o,r){return o=Ae.call(this,o,r,e,t),o=Le.call(this,o,r),o=an(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var cn=Object.defineProperty,We=f((e,t)=>cn(e,"name",{value:t,configurable:!0}),"u$3");const Be=We((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 a=d.resolve(d.dirname(r),n),i=[];if(s)for(const[c,l]of Object.entries(s)){const p=new RegExp(`^${[...c].map(u=>u==="*"?"(.+)":u.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let m=0;for(const u of l){const y=[...R.normalizePath(d.resolve(a,u))].map(w=>w==="*"?`$${++m}`:w==="$"?"$$":w).join("");i.push({find:p,replacement:y})}}return t&&i.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...R.normalizePath(a)].map(c=>c==="$"?"$$":c).join("")}/$1`}),i},"getConfigAlias"),Je=We((e,t)=>{const o=Be(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(r,n,s){if(!o||r.includes("\0"))return null;for(const{find:a,replacement:i}of o)if(a.test(r)){const c=r.replace(a,i),l=await this.resolve(c,n,{skipSelf:!0,...s});if(l)return t.debug({message:`Resolved ${r} to ${l.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),l.id}return null}}},"resolveTsconfigPaths");var pn=Object.defineProperty,ze=f((e,t)=>pn(e,"name",{value:t,configurable:!0}),"u$2");const un=ze((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 a of n){if(a.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(a.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);s.push(d.resolve(e,a))}return s},"getRootDirectories"),Ue=ze((e,t,o)=>{const r=un(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,s,a){if(r===null||r.length===0)return null;if(n.startsWith("."))for(const i of r){const c=d.join(i,n),l=await this.resolve(c,s,{skipSelf:!0,...a});if(l)return t.debug({message:`Resolved ${n} to ${l.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),l.id}return null}}},"resolveTsconfigRootDirectories");var dn=Object.defineProperty,mn=f((e,t)=>dn(e,"name",{value:t,configurable:!0}),"r$3");const He=mn(()=>{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 fn=Object.defineProperty,gn=f((e,t)=>fn(e,"name",{value:t,configurable:!0}),"s$5");const hn=gn(e=>{const t=d.basename(e).split(".");if(t.length>=2){const[o,r]=t.slice(-2),n=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(O.DEFAULT_EXTENSIONS.includes(r)&&s&&s.length>0)return n+"-"+s}},"getCustomModuleLayer");var yn=Object.defineProperty,vn=f((e,t)=>yn(e,"name",{value:t,configurable:!0}),"i$2");const V=vn(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var bn=Object.defineProperty,de=f((e,t)=>bn(e,"name",{value:t,configurable:!0}),"c$2");const me=de((e,t)=>{const o=new Map;return de(function(r,n){const s=n.getModuleInfo(r);if(!s)return;const{isEntry:a}=s,i=s.meta,c=V(i);if(!a){const l=o.get(r);if(l)return l;const p=hn(r);if(p)return o.set(r,p),p}if(a){const l=n.getModuleIds();for(const p of l)n.getModuleInfo(p)&&V(i)===c&&(e.has(p)||e.set(p,new Set),e.get(p).add([r,c]))}if(c&&!a&&e.has(r)){const l=[...e.get(r)];if(l.some(([m])=>{if(t.some(u=>u.path===m)){const u=n.getModuleInfo(m);return V(u?u.meta:{})===c}return!1}))return;if(l.every(([,m])=>m===c))return o.has(r)?o.get(r):void 0;const p=`${d.basename(r,d.extname(r))}-${c}`;return o.set(r,p),p}},"splitChunks")},"createSplitChunks");var $n=Object.defineProperty,jn=f((e,t)=>$n(e,"name",{value:t,configurable:!0}),"n$2");const D=jn((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var wn=Object.defineProperty,kn=f((e,t)=>wn(e,"name",{value:t,configurable:!0}),"s$3");const xn=process.platform==="win32",fe=kn((e,t)=>{const o=xn?"\\":"/";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 En=Object.defineProperty,b=f((e,t)=>En(e,"name",{value:t,configurable:!0}),"p");const On=b((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"+$.versions.node.split(".")[0];if(t.pkg.engines?.node){const r=$e.minVersion(t.pkg.engines.node);r&&(o="node"+r.major)}if(t.options.rollup.esbuild.target){const r=U(t.options.rollup.esbuild.target);r.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...U(o),...r])])}else t.options.rollup.esbuild.target=U(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"),Ve=b((e,t)=>e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message)?!0:e.code==="UNRESOLVED_IMPORT"?(t.logger.error(`Failed to resolve the module "${e.exporter}" imported by "${g.cyan(d.relative(d.resolve(),e.id))}"
53
53
  Is the module installed? Note:
54
54
  ↳ to inline a module into your bundle, install it to "devDependencies".
55
- ↳ to depend on a module via import/require, install it to "dependencies".`),process.exitCode=1,!0):e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0,"sharedOnWarn"),ge=new Map,Ge=$((e,t,o)=>{const r=$(s=>{for(const[a,i]of Object.entries(t))if(s.startsWith(a))return s.replace(a,i)},"findAlias"),n=Je(e.tsconfig,!1);return{external(s){const a=r(s);a&&(s=a);const i=Q(s),l=Y(e.options.externals,i)||Y(e.options.externals,s);if(l)return!0;if(s.startsWith(".")||m.isAbsolute(s)||/src[/\\]/.test(s)||e.pkg.name&&s.startsWith(e.pkg.name))return!1;if(n){for(const{find:c}of n)if(c.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${c.source}`,prefix:o}),!1}return!l&&!ge.has(s)&&e.logger.info({message:'Inlined implicit external "'+g.cyan(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),ge.set(s,!0),l},input:Object.fromEntries(e.options.entries.map(s=>[s.name,m.resolve(e.options.rootDir,s.input)])),onLog:$((s,a)=>{let i=a.message;switch(a.stack&&(i=`${i}
56
- ${a.stack}`),s){case"info":{e.logger.info({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")});return}case"warn":{e.logger.warn({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")});return}case"debug":e.logger.debug({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")})}},"onLog"),onwarn(s,a){Xe(s,e)||s.code||a(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Ke=$(async(e,t)=>{const o=te(e,"build");let r;return e.options.rollup.resolve&&(r=k($e.nodeResolve({extensions:O.DEFAULT_EXTENSIONS,...e.options.rollup.resolve}),t)),{...Ge(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:$(n=>N(e,n,"cjs"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:$(n=>fe(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:me(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:$(n=>N(e,n,"mjs"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:$(n=>fe(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:me(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[k(Ie(),t),k(Ve(),t),e.tsconfig&&k(He(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&k(ze(e.tsconfig,e.logger),t),e.options.rollup.replace&&xe({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&ke({customResolver:r?.resolveId,...e.options.rollup.alias,entries:o}),r,e.options.rollup.polyfillNode&&St({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Pe({...e.options.rollup.json}),Bo(e.logger),Ft(e.options.entries.filter(n=>n.executable).map(n=>n.name).filter(Boolean)),e.options.rollup.wsam&&gt.wasm(e.options.rollup.wsam),e.options.transformer?.(Sn(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&Ne({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Ot(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&k(Et({extensions:O.DEFAULT_EXTENSIONS,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&Qo(e.pkg),e.options.rollup.raw&&Ho(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&_o({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Co({outDir:m.resolve(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&jo(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Me({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&&yt.visualizer({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"),_n=$(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=ho(_n),Ye=$(async(e,t)=>{const o=te(e,"types"),r={load(i){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(i)?null:""},name:"packem:ignore-files"},n=e.tsconfig?.config.compilerOptions;delete n?.lib;let s;e.options.rollup.resolve&&(s=k($e.nodeResolve({extensions:O.DEFAULT_EXTENSIONS,...e.options.rollup.resolve}),t));const a="dts-plugin:"+process.pid+e.tsconfig.path;return{...Ge(e,o,"dts"),onwarn(i,l){Xe(i,e)||i.code!=="EMPTY_BUNDLE"&&l(i)},output:[e.options.emitCJS&&{chunkFileNames:$(i=>N(e,i,"d.cts"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},{chunkFileNames:$(i=>N(e,i,"d.mts"),"chunkFileNames"),dir:m.resolve(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:$(i=>N(e,i,"d.ts"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[k(Ie(),t),k(Ve(),t),e.options.rollup.json&&Pe({...e.options.rollup.json}),r,e.tsconfig&&k(He(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&k(ze(e.tsconfig,e.logger),t),e.options.rollup.replace&&xe({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&ke({customResolver:s?.resolveId,...e.options.rollup.alias,entries:o}),s,await Dn(a)(e),e.options.cjsInterop&&e.options.emitCJS&&Ne({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&cn(e.options.rollup.patchTypes,e.logger),Mt(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Me({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 Nn=Object.defineProperty,Pn=f((e,t)=>Nn(e,"name",{value:t,configurable:!0}),"c$1");const Fn=Pn(async(e,t)=>{const o=await Ke(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 B.rollup(o);t.set(r,n.cache),await e.hooks.callHook("rollup:build",e,n);const s=o.output,a=new Map;for(const i of s){const{output:l}=await n.write(i),c=new Set,u=l.filter(d=>d.type==="chunk");for(const d of u){c.add(d.fileName);for(const y of d.imports)e.usedImports.add(y);d.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(d.code,"utf8"),chunks:d.imports.filter(y=>u.find(h=>h.fileName===y)),exports:d.exports,modules:Object.entries(d.modules).map(([y,h])=>({bytes:h.renderedLength,id:y})),path:d.fileName,type:"entry"})}const p=l.filter(d=>d.type==="asset");for(const d of p)a.has(d.fileName)||a.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(...a.values())},"build");var Mn=Object.defineProperty,q=f((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"r$1");const Cn=q(async(e,t)=>{const o=await Ye(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 B.rollup(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:q(s=>N(e,s,"d.cts"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await n.write({chunkFileNames:q(s=>N(e,s,"d.mts"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await n.write({chunkFileNames:q(s=>N(e,s,"d.ts"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var In=Object.defineProperty,Qe=f((e,t)=>In(e,"name",{value:t,configurable:!0}),"e");const he=Qe((e,t,o)=>{const r="watcher:"+t;e.on("change",(n,{event:s})=>{o.info({message:`${g.cyan(m.relative(".",n))} was ${s}d`,prefix:r})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:r})}),e.on("event",n=>{n.code==="END"&&o.success({message:"Rebuild "+t+" finished",prefix:r}),n.code==="ERROR"&&o.error({context:[n.error],message:"Rebuild "+t+" failed: "+n.error.message,prefix:r})})},"watchHandler"),Rn=Qe(async(e,t)=>{const o=await Ke(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get("rollup-watch");const r=B.watch(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 a of n)s+=g.gray(`
57
- └─ ${m.relative(process.cwd(),a)}`);if(e.logger.info(s),he(r,"bundle",e.logger),e.options.declaration){const a=await Ye(e,t);await e.hooks.callHook("rollup:dts:options",e,a);const i=B.watch(a);await e.hooks.callHook("rollup:watch",e,i),he(i,"types",e.logger)}},"watch");var Tn=Object.defineProperty,An=f((e,t)=>Tn(e,"name",{value:t,configurable:!0}),"i$1");const Ze=An(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var qn=Object.defineProperty,Ln=f((e,t)=>qn(e,"name",{value:t,configurable:!0}),"a$2");let Wn=class{static{f(this,"g")}static{Ln(this,"FileCache")}#n;#e;#r;#t=!0;#o=new Map;constructor(t,o,r){this.#n=t,this.#e=G.findCacheDirectorySync("visulima-packem",{cwd:t}),this.#r=o,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:v.isAccessibleSync(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(!v.isAccessibleSync(r))return;const n=v.readFileSync(r),s=JSON.parse(n);return this.#o.set(r,s),s}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)),v.writeFileSync(n,o,{overwrite:!0})}getFilePath(t,o){let r=t.replaceAll(m.toNamespacedPath(this.#n),"");return r=r.replaceAll(":","-"),m.join(this.#e,this.#r,o?.replaceAll(":","-")??"",m.toNamespacedPath(r))}};var Bn=Object.defineProperty,L=f((e,t)=>Bn(e,"name",{value:t,configurable:!0}),"l$1");const Jn=T.createFilter,zn=L((e,t)=>{const{sideEffects:o}=t;let r;if(typeof o=="boolean")r=L(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)r=L(()=>!1,"hasSideEffects");else{const n=o.map(s=>s.includes("/")?s:`**/${s}`);r=Jn(n,null,{resolve:e})}else r=L(()=>null,"hasSideEffects");return r},"getPackageSideEffect");var Un=Object.defineProperty,Hn=f((e,t)=>Un(e,"name",{value:t,configurable:!0}),"o");const Vn=Hn(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)!Y(e.options.externals,n)&&!n.startsWith("chunks/")&&!e.options.dependencies.includes(Q(n))&&!e.options.peerDependencies.includes(Q(n))&&r.add(n);o.size>0&&A(e,`Potential unused dependencies found: ${[...o].map(n=>g.cyan(n)).join(", ")}`),r.size>0&&A(e,`Potential implicit dependencies found: ${[...r].map(n=>g.cyan(n)).join(", ")}`)},"validateDependencies");var Xn=Object.defineProperty,et=f((e,t)=>Xn(e,"name",{value:t,configurable:!0}),"i");const Gn=et((e,t)=>xt.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),Kn=et((e,t)=>{const o=e.toLowerCase();return t.filter(r=>Gn(r.toLowerCase(),o))},"findAlternatives");var Yn=Object.defineProperty,ye=f((e,t)=>Yn(e,"name",{value:t,configurable:!0}),"n");const Qn=ye((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:"",...ne(e.exports,e.type??"commonjs",t.options.declaration).map(n=>n.file)].map(n=>n&&m.resolve(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("*")&&!Z.existsSync(n)&&r.push(n.replace(`${t.rootDir}/`,""));if(r.length>0){const n=ye(i=>m.relative(t.rootDir,m.resolve(t.options.outDir,i)),"rPath"),s=t.buildEntries.filter(i=>!i.chunk).map(i=>n(i.path));let a="Potential missing or wrong package.json files:";for(const i of r){const l=Kn(i,s);a+=`
58
- - `+g.cyan(i)+(l.length>0?g.grey` (did you mean ${l.map(c=>`"${c}"`).join(", ")}?)`:"")}A(t,a)}},"validatePackage");var Zn=Object.defineProperty,w=f((e,t)=>Zn(e,"name",{value:t,configurable:!0}),"f");const ve=w((e,t)=>{e.warnings.size>0&&(t&&e.logger.raw(`
55
+ ↳ to depend on a module via import/require, install it to "dependencies".`),process.exitCode=1,!0):e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0,"sharedOnWarn"),ge=new Map,Xe=b((e,t,o)=>{const r=b(s=>{for(const[a,i]of Object.entries(t))if(s.startsWith(a))return s.replace(a,i)},"findAlias"),n=Be(e.tsconfig,!1);return{external(s){const a=r(s);a&&(s=a);const i=Y(s),c=K(e.options.externals,i)||K(e.options.externals,s);if(c)return!0;if(s.startsWith(".")||d.isAbsolute(s)||/src[/\\]/.test(s)||e.pkg.name&&s.startsWith(e.pkg.name))return!1;if(n){for(const{find:l}of n)if(l.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${l.source}`,prefix:o}),!1}return!c&&!ge.has(s)&&e.logger.info({message:'Inlined implicit external "'+g.cyan(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),ge.set(s,!0),c},input:Object.fromEntries(e.options.entries.map(s=>[s.name,d.resolve(e.options.rootDir,s.input)])),onLog:b((s,a)=>{let i=a.message;switch(a.stack&&(i=`${i}
56
+ ${a.stack}`),s){case"info":{e.logger.info({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")});return}case"warn":{e.logger.warn({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")});return}case"debug":e.logger.debug({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")})}},"onLog"),onwarn(s,a){Ve(s,e)||s.code||a(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Ge=b(async(e,t)=>{const o=ee(e,"build");let r;return e.options.rollup.resolve&&(r=x(be.nodeResolve({extensions:O.DEFAULT_EXTENSIONS,...e.options.rollup.resolve}),t)),{...Xe(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:b(n=>D(e,n,"cjs"),"chunkFileNames"),dir:d.resolve(e.options.rootDir,e.options.outDir),entryFileNames:b(n=>fe(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:me(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:b(n=>D(e,n,"mjs"),"chunkFileNames"),dir:d.resolve(e.options.rootDir,e.options.outDir),entryFileNames:b(n=>fe(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:me(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[x(Ce(),t),x(He(),t),e.tsconfig&&x(Ue(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&x(Je(e.tsconfig,e.logger),t),e.options.rollup.replace&&ke({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&we({customResolver:r?.resolveId,...e.options.rollup.alias,entries:o}),r,e.options.rollup.polyfillNode&&Ot({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Ne({...e.options.rollup.json}),Wo(e.logger),Pt(e.options.entries.filter(n=>n.executable).map(n=>n.name).filter(Boolean)),e.options.rollup.wsam&&ft.wasm(e.options.rollup.wsam),e.options.transformer?.(On(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&De({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Et(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&x(xt({extensions:O.DEFAULT_EXTENSIONS,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&Yo(e.pkg),e.options.rollup.raw&&Uo(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&So({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Mo({outDir:d.resolve(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&$o(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Fe({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&&ht.visualizer({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"),Sn=b(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"),_n=go(Sn),Ke=b(async(e,t)=>{const o=ee(e,"types"),r={load(i){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(i)?null:""},name:"packem:ignore-files"},n=e.tsconfig?.config.compilerOptions;delete n?.lib;let s;e.options.rollup.resolve&&(s=x(be.nodeResolve({extensions:O.DEFAULT_EXTENSIONS,...e.options.rollup.resolve}),t));const a="dts-plugin:"+process.pid+e.tsconfig.path;return{...Xe(e,o,"dts"),onwarn(i,c){Ve(i,e)||i.code!=="EMPTY_BUNDLE"&&c(i)},output:[e.options.emitCJS&&{chunkFileNames:b(i=>D(e,i,"d.cts"),"chunkFileNames"),dir:d.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},{chunkFileNames:b(i=>D(e,i,"d.mts"),"chunkFileNames"),dir:d.resolve(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:b(i=>D(e,i,"d.ts"),"chunkFileNames"),dir:d.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[x(Ce(),t),x(He(),t),e.options.rollup.json&&Ne({...e.options.rollup.json}),r,e.tsconfig&&x(Ue(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&x(Je(e.tsconfig,e.logger),t),e.options.rollup.replace&&ke({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&we({customResolver:s?.resolveId,...e.options.rollup.alias,entries:o}),s,await _n(a)(e),e.options.cjsInterop&&e.options.emitCJS&&De({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&ln(e.options.rollup.patchTypes,e.logger),Ft(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Fe({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 Dn=Object.defineProperty,Nn=f((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"c$1");const Pn=Nn(async(e,t)=>{const o=await Ge(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 W.rollup(o);t.set(r,n.cache),await e.hooks.callHook("rollup:build",e,n);const s=o.output,a=new Map;for(const i of s){const{output:c}=await n.write(i),l=new Set,p=c.filter(u=>u.type==="chunk");for(const u of p){l.add(u.fileName);for(const y of u.imports)e.usedImports.add(y);u.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(u.code,"utf8"),chunks:u.imports.filter(y=>p.find(w=>w.fileName===y)),exports:u.exports,modules:Object.entries(u.modules).map(([y,w])=>({bytes:w.renderedLength,id:y})),path:u.fileName,type:"entry"})}const m=c.filter(u=>u.type==="asset");for(const u of m)a.has(u.fileName)||a.set(u.fileName,{bytes:Buffer.byteLength(u.source,"utf8"),path:u.fileName,type:"asset"});for(const u of l)e.usedImports.delete(u)}e.buildEntries.push(...a.values())},"build");var Fn=Object.defineProperty,A=f((e,t)=>Fn(e,"name",{value:t,configurable:!0}),"r$1");const Mn=A(async(e,t)=>{const o=await Ke(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 W.rollup(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:A(s=>D(e,s,"d.cts"),"chunkFileNames"),dir:d.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await n.write({chunkFileNames:A(s=>D(e,s,"d.mts"),"chunkFileNames"),dir:d.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await n.write({chunkFileNames:A(s=>D(e,s,"d.ts"),"chunkFileNames"),dir:d.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var Cn=Object.defineProperty,Ye=f((e,t)=>Cn(e,"name",{value:t,configurable:!0}),"e");const he=Ye((e,t,o)=>{const r="watcher:"+t;e.on("change",(n,{event:s})=>{o.info({message:`${g.cyan(d.relative(".",n))} was ${s}d`,prefix:r})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:r})}),e.on("event",n=>{n.code==="END"&&o.success({message:"Rebuild "+t+" finished",prefix:r}),n.code==="ERROR"&&o.error({context:[n.error],message:"Rebuild "+t+" failed: "+n.error.message,prefix:r})})},"watchHandler"),In=Ye(async(e,t)=>{const o=await Ge(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get("rollup-watch");const r=W.watch(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 a of n)s+=g.gray(`
57
+ └─ ${d.relative(process.cwd(),a)}`);if(e.logger.info(s),he(r,"bundle",e.logger),e.options.declaration){const a=await Ke(e,t);await e.hooks.callHook("rollup:dts:options",e,a);const i=W.watch(a);await e.hooks.callHook("rollup:watch",e,i),he(i,"types",e.logger)}},"watch");var Rn=Object.defineProperty,Tn=f((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"i$1");const Qe=Tn(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var An=Object.defineProperty,qn=f((e,t)=>An(e,"name",{value:t,configurable:!0}),"a$2");let Ln=class{static{f(this,"g")}static{qn(this,"FileCache")}#n;#e;#r;#t=!0;#o=new Map;constructor(t,o,r){this.#n=t,this.#e=X.findCacheDirectorySync("visulima-packem",{cwd:t}),this.#r=o,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:h.isAccessibleSync(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(!h.isAccessibleSync(r))return;const n=h.readFileSync(r),s=JSON.parse(n);return this.#o.set(r,s),s}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)),h.writeFileSync(n,o,{overwrite:!0})}getFilePath(t,o){let r=t.replaceAll(d.toNamespacedPath(this.#n),"");return r=r.replaceAll(":","-"),d.join(this.#e,this.#r,o?.replaceAll(":","-")??"",d.toNamespacedPath(r))}};var Wn=Object.defineProperty,q=f((e,t)=>Wn(e,"name",{value:t,configurable:!0}),"l$1");const Bn=R.createFilter,Jn=q((e,t)=>{const{sideEffects:o}=t;let r;if(typeof o=="boolean")r=q(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)r=q(()=>!1,"hasSideEffects");else{const n=o.map(s=>s.includes("/")?s:`**/${s}`);r=Bn(n,null,{resolve:e})}else r=q(()=>null,"hasSideEffects");return r},"getPackageSideEffect");var zn=Object.defineProperty,Un=f((e,t)=>zn(e,"name",{value:t,configurable:!0}),"o");const Hn=Un(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)!K(e.options.externals,n)&&!n.startsWith("chunks/")&&!e.options.dependencies.includes(Y(n))&&!e.options.peerDependencies.includes(Y(n))&&r.add(n);o.size>0&&T(e,`Potential unused dependencies found: ${[...o].map(n=>g.cyan(n)).join(", ")}`),r.size>0&&T(e,`Potential implicit dependencies found: ${[...r].map(n=>g.cyan(n)).join(", ")}`)},"validateDependencies");var Vn=Object.defineProperty,Ze=f((e,t)=>Vn(e,"name",{value:t,configurable:!0}),"i");const Xn=Ze((e,t)=>kt.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),Gn=Ze((e,t)=>{const o=e.toLowerCase();return t.filter(r=>Xn(r.toLowerCase(),o))},"findAlternatives");var Kn=Object.defineProperty,ye=f((e,t)=>Kn(e,"name",{value:t,configurable:!0}),"n");const Yn=ye((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:"",...oe(e.exports,e.type??"commonjs",t.options.declaration).map(n=>n.file)].map(n=>n&&d.resolve(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("*")&&!Q.existsSync(n)&&r.push(n.replace(`${t.rootDir}/`,""));if(r.length>0){const n=ye(i=>d.relative(t.rootDir,d.resolve(t.options.outDir,i)),"rPath"),s=t.buildEntries.filter(i=>!i.chunk).map(i=>n(i.path));let a="Potential missing or wrong package.json files:";for(const i of r){const c=Gn(i,s);a+=`
58
+ - `+g.cyan(i)+(c.length>0?g.grey` (did you mean ${c.map(l=>`"${l}"`).join(", ")}?)`:"")}T(t,a)}},"validatePackage");var Qn=Object.defineProperty,j=f((e,t)=>Qn(e,"name",{value:t,configurable:!0}),"m");const et=j((e,t)=>{e.warnings.size>0&&(t&&e.logger.raw(`
59
59
  `),e.logger.warn(`Build is done with some warnings:
60
60
 
61
61
  ${[...e.warnings].map(o=>`- ${o}`).join(`
62
- `)}`),e.options.failOnWarn&&(e.logger.error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`."),j.exit(1)))},"logErrors"),er=w(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"),tr=w((e,t,o,r,n,s,a,i)=>{const l=er(i?.config.compilerOptions?.jsx),c=at.defu(n,r,s,{alias:{},clean:!0,declaration:!0,dependencies:[],devDependencies:[],emitCJS:!0,emitESM:!0,entries:[],externals:[...ie.builtinModules,...ie.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,fileCache:!0,minify:j.env.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:i?.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:l,jsxDev:i?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:i?.config.compilerOptions?.jsxFactory,jsxFragment:i?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:i?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minifyWhitespace:j.env.NODE_ENV==="production",sourcesContent:!1,target:i?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:i?.config},json:{preferConst:!0},license:{dependenciesTemplate:w((u,p,d)=>`
62
+ `)}`),e.options.failOnWarn&&(e.logger.error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`."),$.exit(1)))},"logErrors"),Zn=j(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"),er=j((e,t,o,r,n,s,a,i)=>{const c=Zn(i?.config.compilerOptions?.jsx),l=it.defu(n,r,s,{alias:{},clean:!0,declaration:!0,dependencies:[],devDependencies:[],emitCJS:!0,emitESM:!0,entries:[],externals:[...ie.builtinModules,...ie.builtinModules.map(p=>`node:${p}`)],failOnWarn:!0,fileCache:!0,minify:$.env.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:i?.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:i?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:i?.config.compilerOptions?.jsxFactory,jsxFragment:i?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:i?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minifyWhitespace:$.env.NODE_ENV==="production",sourcesContent:!1,target:i?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:i?.config},json:{preferConst:!0},license:{dependenciesTemplate:j((p,m,u)=>`
63
63
  # Licenses of bundled dependencies
64
- The published ${d} artifact additionally contains code with the following licenses:
65
- ${u.join(", ")}
64
+ The published ${u} artifact additionally contains code with the following licenses:
65
+ ${p.join(", ")}
66
66
 
67
67
  # Bundled dependencies:
68
- `+p,"dependenciesTemplate"),dtsTemplate:w((u,p,d)=>`
68
+ `+m,"dependenciesTemplate"),dtsTemplate:j((p,m,u)=>`
69
69
  # Licenses of bundled types
70
- The published ${d} artifact additionally contains code with the following licenses:
71
- ${u.join(", ")}
70
+ The published ${u} artifact additionally contains code with the following licenses:
71
+ ${p.join(", ")}
72
72
 
73
73
  # Bundled types:
74
- `+p,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:O.EXCLUDE_REGEXP,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:i?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:j.env.NODE_ENV==="production",...i?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(i.config.compilerOptions.jsx)?{jsxFragmentPragma:i.config.compilerOptions.jsxFragmentFactory,jsxImportSource:i.config.compilerOptions.jsxImportSource,jsxPragma:i.config.compilerOptions.jsxFactory,jsxRuntime:l,transforms:["typescript","jsx",...i.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...i?.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:i?.config.compilerOptions?.experimentalDecorators,syntax:i?"typescript":"ecmascript",[i?"tsx":"jsx"]:!0},target:i?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:i?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:i?.config.compilerOptions?.experimentalDecorators,react:{development:j.env.NODE_ENV!=="production",pragma:i?.config.compilerOptions?.jsxFactory,pragmaFrag:i?.config.compilerOptions?.jsxFragmentFactory,runtime:l,throwIfNamespace:!0},treatConstEnumAsEnum:i?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:i?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:zn(t,a),preset:"recommended"},watch:{clearScreen:!0,exclude:O.EXCLUDE_REGEXP}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!c.transformerName){const u=new Set([...Object.keys(a.dependencies??{}),...Object.keys(a.devDependencies??{})]);if(u.has("esbuild"))c.transformerName="esbuild";else if(u.has("@swc/core"))c.transformerName="swc";else if(u.has("sucrase"))c.transformerName="sucrase";else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info('Using "'+g.cyan(c.transformerName)+'" as transformer.')}return c.rollup.resolve&&c.rollup.resolve.preferBuiltins===!0&&(c.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),i?.config.compilerOptions?.isolatedModules||e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
74
+ `+m,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:O.EXCLUDE_REGEXP,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:i?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:$.env.NODE_ENV==="production",...i?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(i.config.compilerOptions.jsx)?{jsxFragmentPragma:i.config.compilerOptions.jsxFragmentFactory,jsxImportSource:i.config.compilerOptions.jsxImportSource,jsxPragma:i.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...i.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...i?.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:i?.config.compilerOptions?.experimentalDecorators,syntax:i?"typescript":"ecmascript",[i?"tsx":"jsx"]:!0},target:i?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:i?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:i?.config.compilerOptions?.experimentalDecorators,react:{development:$.env.NODE_ENV!=="production",pragma:i?.config.compilerOptions?.jsxFactory,pragmaFrag:i?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:i?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:i?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:Jn(t,a),preset:"recommended"},watch:{clearScreen:!0,exclude:O.EXCLUDE_REGEXP}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!l.transformerName){const p=new Set([...Object.keys(a.dependencies??{}),...Object.keys(a.devDependencies??{})]);if(p.has("esbuild"))l.transformerName="esbuild";else if(p.has("@swc/core"))l.transformerName="swc";else if(p.has("sucrase"))l.transformerName="sucrase";else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info('Using "'+g.cyan(l.transformerName)+'" as transformer.')}return l.rollup.resolve&&l.rollup.resolve.preferBuiltins===!0&&(l.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),i?.config.compilerOptions?.isolatedModules||e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
75
75
  Because none of the third-party transpilers, 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.
76
- 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.`),c.dependencies=Object.keys(a.dependencies??{}),c.peerDependencies=Object.keys(a.peerDependencies??{}),c.devDependencies=Object.keys(a.devDependencies??{}),c.optionalDependencies=Object.keys(a.optionalDependencies??{}),c.externals.push(...c.dependencies,...c.peerDependencies,...c.optionalDependencies),c},"generateOptions"),or=w(e=>e.replace(/\.(?:js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension"),nr=w(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=m.isAbsolute(o.input)?m.relative(t,o.input):m.normalize(o.input);r.startsWith("./")&&(r=r.slice(2)),o.name=or(r.replace(/^src\//,""))}if(!o.input)throw new Error(`Missing entry input: ${Ze(o)}`);if(o.input=m.resolve(e.options.rootDir,o.input),!v.isAccessibleSync(o.input)){const r=new Set(await J.readdir(m.dirname(o.input)));let n=!1;for(const s of O.DEFAULT_EXTENSIONS)if(r.has(m.basename(o.input)+s)){n=!0;break}if(!n)throw new rt.NotFoundError("Your configured entry: "+g.cyan(o.input)+" does not exist.")}o.outDir=m.resolve(e.options.rootDir,o.outDir??e.options.outDir)}},"prepareEntries"),rr=w((e,t,o)=>{const r=w(s=>m.relative(t.rootDir,m.resolve(t.options.outDir,s)),"rPath");let n=!1;for(const s of t.buildEntries.filter(a=>!a.chunk)){let a=s.bytes??0;for(const l of s.chunks??[])a+=t.buildEntries.find(c=>c.path===l)?.bytes??0;let i=` ${g.bold(r(s.path))} (${["total size: "+g.cyan(D.formatBytes(a)),s.type!=="asset"&&s.bytes&&"chunk size: "+g.cyan(D.formatBytes(s.bytes))].filter(Boolean).join(", ")})`;if(i+=s.exports?.length?`
76
+ 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.`),l.dependencies=Object.keys(a.dependencies??{}),l.peerDependencies=Object.keys(a.peerDependencies??{}),l.devDependencies=Object.keys(a.devDependencies??{}),l.optionalDependencies=Object.keys(a.optionalDependencies??{}),l.externals.push(...l.dependencies,...l.peerDependencies,...l.optionalDependencies),l},"generateOptions"),tr=j(e=>e.replace(/\.(?:js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension"),or=j(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=d.isAbsolute(o.input)?d.relative(t,o.input):d.normalize(o.input);r.startsWith("./")&&(r=r.slice(2)),o.name=tr(r.replace(/^src\//,""))}if(!o.input)throw new Error(`Missing entry input: ${Qe(o)}`);if(o.input=d.resolve(e.options.rootDir,o.input),!h.isAccessibleSync(o.input)){const r=new Set(await B.readdir(d.dirname(o.input)));let n=!1;for(const s of O.DEFAULT_EXTENSIONS)if(r.has(d.basename(o.input)+s)){n=!0;break}if(!n)throw new nt.NotFoundError("Your configured entry: "+g.cyan(o.input)+" does not exist.")}o.outDir=d.resolve(e.options.rootDir,o.outDir??e.options.outDir)}},"prepareEntries"),nr=j((e,t,o)=>{const r=j(s=>d.relative(t.rootDir,d.resolve(t.options.outDir,s)),"rPath");let n=!1;for(const s of t.buildEntries.filter(a=>!a.chunk)){let a=s.bytes??0;for(const c of s.chunks??[])a+=t.buildEntries.find(l=>l.path===c)?.bytes??0;let i=` ${g.bold(r(s.path))} (${["total size: "+g.cyan(_.formatBytes(a)),s.type!=="asset"&&s.bytes&&"chunk size: "+g.cyan(_.formatBytes(s.bytes))].filter(Boolean).join(", ")})`;if(i+=s.exports?.length?`
77
77
  exports: `+g.gray(s.exports.join(", ")):"",s.chunks?.length&&(i+=`
78
- ${s.chunks.map(l=>{const c=t.buildEntries.find(u=>u.path===l)??{};return g.gray(" └─ "+r(l)+g.bold(c.bytes?" ("+D.formatBytes(c?.bytes)+")":""))}).join(`
79
- `)}`),s.modules&&s.modules.length>0){const l=s.modules.filter(c=>c.id.includes("node_modules")).sort((c,u)=>(u.bytes||0)-(c.bytes||0)).map(c=>g.gray(" 📦 "+r(c.id)+g.bold(c.bytes?" ("+D.formatBytes(c.bytes)+")":""))).join(`
80
- `);i+=l.length>0?`
78
+ ${s.chunks.map(c=>{const l=t.buildEntries.find(p=>p.path===c)??{};return g.gray(" └─ "+r(c)+g.bold(l.bytes?" ("+_.formatBytes(l?.bytes)+")":""))}).join(`
79
+ `)}`),s.modules&&s.modules.length>0){const c=s.modules.filter(l=>l.id.includes("node_modules")).sort((l,p)=>(p.bytes||0)-(l.bytes||0)).map(l=>g.gray(" 📦 "+r(l.id)+g.bold(l.bytes?" ("+_.formatBytes(l.bytes)+")":""))).join(`
80
+ `);i+=c.length>0?`
81
81
  inlined modules:
82
- `+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 u=t.buildEntries.find(p=>p.path.endsWith(l));if(u){let p;(t.options.declaration===!0||t.options.declaration==="compatible")&&!l.includes(".d.ts")&&(l=l.replace(c==="commonjs"?".d.c":".d.m",".d."),p=t.buildEntries.find(d=>d.path.endsWith(l))),i+=p&&c===o.type?`
82
+ `+c:""}if(t.options.declaration&&s.type==="entry"){let c=s.path.replace(/\.js$/,".d.ts"),l="commonjs";s.path.endsWith(".cjs")?c=s.path.replace(/\.cjs$/,".d.cts"):s.path.endsWith(".mjs")&&(l="module",c=s.path.replace(/\.mjs$/,".d.mts"));const p=t.buildEntries.find(m=>m.path.endsWith(c));if(p){let m;(t.options.declaration===!0||t.options.declaration==="compatible")&&!c.includes(".d.ts")&&(c=c.replace(l==="commonjs"?".d.c":".d.m",".d."),m=t.buildEntries.find(u=>u.path.endsWith(c))),i+=m&&l===o.type?`
83
83
  types:
84
- `+[u,p].map(d=>g.gray(" └─ ")+g.bold(r(d.path))+" (total size: "+g.cyan(D.formatBytes(d.bytes??0))+")").join(`
84
+ `+[p,m].map(u=>g.gray(" └─ ")+g.bold(r(u.path))+" (total size: "+g.cyan(_.formatBytes(u.bytes??0))+")").join(`
85
85
  `):`
86
- types: `+g.bold(r(u.path))+" (total size: "+g.cyan(D.formatBytes(u.bytes??0))+")"}}n=!0,i+=`
86
+ types: `+g.bold(r(p.path))+" (total size: "+g.cyan(_.formatBytes(p.bytes??0))+")"}}n=!0,i+=`
87
87
 
88
- `,e.raw(s.chunk?g.gray(i):i)}return n&&e.raw("Σ Total dist size (byte size):",g.cyan(D.formatBytes(t.buildEntries.reduce((s,a)=>s+(a.bytes??0),0))),`
89
- `),n},"showSizeInformation"),sr=w(async(e,t,o,r,n,s,a,i,l)=>{const c=io(n.preset??r.preset??"auto",t),u=tr(e,t,o,r,n,c,s,a);v.ensureDirSync(m.join(u.rootDir,u.outDir));const p={buildEntries:[],dependencyGraphMap:new Map,hooks:lt.createHooks(),logger:e,mode:o,options:u,pkg:s,rootDir:t,tsconfig:a,usedImports:new Set,warnings:new Set};if(c.hooks&&p.hooks.addHooks(c.hooks),r.hooks&&p.hooks.addHooks(r.hooks),n.hooks&&p.hooks.addHooks(n.hooks),i.isEnabled=p.options.fileCache,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");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."),await nr(p,t),await p.hooks.callHook("build:before",p);let d="Building";if(o==="watch"?d="Watching":o==="jit"&&(d="Stubbing"),p.logger.info(g.cyan(`${d} ${p.options.name}`)),p.logger.debug(`${g.bold("Root dir:")} ${p.options.rootDir}
88
+ `,e.raw(s.chunk?g.gray(i):i)}return n&&e.raw("Σ Total dist size (byte size):",g.cyan(_.formatBytes(t.buildEntries.reduce((s,a)=>s+(a.bytes??0),0))),`
89
+ `),n},"showSizeInformation"),rr=j(async(e,t,o,r,n,s,a)=>{const i=so(n.preset??r.preset??"auto",t),c=er(e,t,o,r,n,i,s,a);h.ensureDirSync(d.join(c.rootDir,c.outDir));const l={buildEntries:[],dependencyGraphMap:new Map,hooks:at.createHooks(),logger:e,mode:o,options:c,pkg:s,rootDir:t,tsconfig:a,usedImports:new Set,warnings:new Set};if(i.hooks&&l.hooks.addHooks(i.hooks),r.hooks&&l.hooks.addHooks(r.hooks),n.hooks&&l.hooks.addHooks(n.hooks),await l.hooks.callHook("build:prepare",l),!l.options.emitESM&&!l.options.emitCJS)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(l.options.declaration&&a===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");return l.options.emitESM===void 0&&l.logger.info("Emitting ESM bundles, is disabled."),l.options.emitCJS===void 0&&l.logger.info("Emitting CJS bundles, is disabled."),l.options.declaration||l.logger.info("Declaration files, are disabled."),l},"createContext"),sr=j(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||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(r=>o.startsWith(r))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${d.relative(e.options.rootDir,o)}\``),await h.emptyDir(o))},"cleanDistributionDirectories"),ir=j(async(e,t,o)=>{await e.hooks.callHook("build:before",e),await Promise.all([Pn(e,o),e.options.declaration&&Mn(e,o)]),e.logger.success(g.green(`Build succeeded for ${e.options.name}`));for await(const n of h.walk(d.join(e.options.rootDir,e.options.outDir))){let s=e.buildEntries.find(a=>d.join(e.options.rootDir,e.options.outDir,a.path)===n.path);if(s||(s={chunk:!0,path:n.path},e.buildEntries.push(s)),!s.bytes){const a=await B.stat(d.resolve(e.options.rootDir,e.options.outDir,n.path));s.bytes=a.size}}const r=nr(e.logger,e,t);Hn(e),Yn(t,e),await e.hooks.callHook("build:done",e),et(e,r)},"build"),ar=j(async(e,t,o={})=>{const{configPath:r,debug:n,tsconfigPath:s,...a}=o,i=[new z.MessageFormatterProcessor,new z.ErrorProcessor];n&&i.push(new z.CallerProcessor);const c=st.createPail({logLevel:n?"debug":"informational",processors:i,scope:"packem"});e=d.resolve($.cwd(),e),c.debug("Root directory:",e);const l=d.join(e,"package.json"),p=rt.parsePackageJson(l);c.debug("Using package.json found at",l);let m;if(s){const u=d.join(e,s);await h.isAccessible(u)||(c.error("tsconfig.json not found at",u),$.exit(1)),m={config:X.readTsConfig(u),path:u},c.info("Using tsconfig settings at",u)}else try{m=await X.findTSConfig(e),c.debug("Using tsconfig settings found at",m.path)}catch{c.info("No tsconfig.json or jsconfig.json found.")}try{const u=r??"./packem.config.ts";/\.(?:js|mjs|cjs|ts)$/.test(u)||(c.error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed."),$.exit(1));const y=xe(u,e);c.debug("Using packem config found at",d.join(e,u));const w=Date.now(),S=j(()=>_.duration(Math.floor(Date.now()-w)),"getDuration"),P=M(p.version+JSON.stringify({...p.dependencies,...p.devDependencies,eNode:p.engines?.node})),k=new Ln(e,P,c);k.cachePath&&!h.isAccessibleSync(d.join(k.cachePath,P))&&h.isAccessibleSync(k.cachePath)&&(c.info("Clearing file cache because the cache key has changed."),await h.emptyDir(k.cachePath));const v=await rr(c,e,t,a,y,p,m);if(k.isEnabled=v.options.fileCache,await or(v,e),v.logger.info(g.cyan((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+v.options.name)),v.logger.debug(`${g.bold("Root dir:")} ${v.options.rootDir}
90
90
  ${g.bold("Entries:")}
91
- ${p.options.entries.map(h=>` ${Ze(h)}`).join(`
92
- `)}`),p.options.clean)for(const h of new Set(p.options.entries.map(b=>b.outDir).filter(Boolean).sort()))h===p.options.rootDir||p.options.rootDir.startsWith(h.endsWith("/")?h:`${h}/`)||l.some(b=>h.startsWith(b))||(l.push(h),p.logger.info(`Cleaning dist directory: \`./${m.relative(p.options.rootDir,h)}\``),await v.emptyDir(h));if(p.options.stub){await zt(p),await p.hooks.callHook("build:done",p);return}if(o==="watch"){await Rn(p,i),ve(p,!1);return}await Promise.all([Fn(p,i),p.options.declaration&&Cn(p,i)]),p.logger.success(g.green(`Build succeeded for ${p.options.name}`));for await(const h of v.walk(m.join(p.options.rootDir,p.options.outDir))){let b=p.buildEntries.find(E=>m.join(p.options.rootDir,p.options.outDir,E.path)===h.path);if(b||(b={chunk:!0,path:h.path},p.buildEntries.push(b)),!b.bytes){const E=await J.stat(m.resolve(p.options.rootDir,p.options.outDir,h.path));b.bytes=E.size}}const y=rr(p.logger,p,s);Vn(p),Qn(s,p),await p.hooks.callHook("build:done",p),ve(p,y)},"build"),ir=w(async(e,t,o={})=>{const{configPath:r,debug:n,tsconfigPath:s,...a}=o,i=[new U.MessageFormatterProcessor,new U.ErrorProcessor];n&&i.push(new U.CallerProcessor);const l=it.createPail({logLevel:n?"debug":"informational",processors:i,scope:"packem"});e=m.resolve(j.cwd(),e),l.debug("Root directory:",e);const c=m.join(e,"package.json"),u=st.parsePackageJson(c);l.debug("Using package.json found at",c);let p;if(s){const d=m.join(e,s);await v.isAccessible(d)||(l.error("tsconfig.json not found at",d),j.exit(1)),p={config:G.readTsConfig(d),path:d},l.info("Using tsconfig settings at",d)}else try{p=await G.findTSConfig(e),l.debug("Using tsconfig settings found at",p.path)}catch{l.info("No tsconfig.json or jsconfig.json found.")}try{const d=r??"./packem.config.ts";/\.(?:js|mjs|cjs|ts)$/.test(d)||(l.error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed."),j.exit(1));const y=Ee(d,e);l.debug("Using packem config found at",m.join(e,d));const h=(Array.isArray(y)?y:[y]).filter(Boolean),b=Date.now(),E=w(()=>D.duration(Math.floor(Date.now()-b)),"getDuration"),F=[],M=[],S=C(u.version+JSON.stringify({...u.dependencies,...u.devDependencies,eNode:u.engines?.node})),_=new Wn(e,S,l);_.cachePath&&!v.isAccessibleSync(m.join(_.cachePath,S))&&v.isAccessibleSync(_.cachePath)&&(l.info("Clearing file cache because the cache key has changed."),await v.emptyDir(_.cachePath));for(const tt of h)M.push(sr(l,e,t,a,tt,u,p,_,F));await Promise.all(M),l.raw(`
93
- ⚡️ Build`+(M.length>1?"s":"")+" run in "+E()),l.restoreAll(),j.exit(0)}catch(d){l.error("An error occurred while building",d),j.exit(1)}},"createBundler");module.exports=ir;
91
+ ${v.options.entries.map(F=>` ${Qe(F)}`).join(`
92
+ `)}`),await sr(v),v.options.stub){await Jt(v),await v.hooks.callHook("build:done",v);return}if(t==="watch"){await In(v,k),et(v,!1);return}await ir(v,p,k),c.raw(`
93
+ ⚡️ Build run in `+S()),c.restoreAll(),$.exit(0)}catch(u){c.error("An error occurred while building",u),$.exit(1)}},"createBundler");module.exports=ar;
@@ -1,4 +1,4 @@
1
- var ht=Object.defineProperty;var d=(e,t)=>ht(e,"name",{value:t,configurable:!0});import{chmod as yt,stat as De,readdir as vt}from"node:fs/promises";import pe from"node:module";import{env as W,exit as I,versions as bt,cwd as $t}from"node:process";import{cyan as b,bold as E,gray as F,grey as jt,green as wt}from"@visulima/colorize";import{readFile as Z,writeFile as L,collectSync as kt,readFileSync as Se,writeFileSync as Ne,writeJsonSync as xt,isAccessibleSync as J,ensureDirSync as Ot,emptyDir as Pe,walk as Et,isAccessible as Dt}from"@visulima/fs";import{NotFoundError as St}from"@visulima/fs/error";import{formatBytes as M,duration as Nt}from"@visulima/humanizer";import{findCacheDirectorySync as Pt,readTsConfig as _t,findTSConfig as Mt}from"@visulima/package";import{parsePackageJson as Ct}from"@visulima/package/package-json";import{createPail as Ft}from"@visulima/pail";import{MessageFormatterProcessor as It,ErrorProcessor as Rt,CallerProcessor as Tt}from"@visulima/pail/processor";import{resolve as h,join as v,normalize as ee,extname as te,relative as N,dirname as oe,basename as H,isAbsolute as _e,toNamespacedPath as ue}from"@visulima/path";import{defu as At}from"defu";import{createHooks as Wt}from"hookable";import{a as T,R as Jt,E as me}from"./shared/packem.HRXF255z.mjs";import{pathToFileURL as Bt,fileURLToPath as Lt}from"node:url";import{resolvePath as zt,resolveModuleExportNames as Ut,findStaticImports as Me}from"mlly";import S from"magic-string";import Ce from"jiti";import{existsSync as re}from"node:fs";import{rollup as Fe,watch as de}from"rollup";import Ie from"@rollup/plugin-alias";import Ht from"@rollup/plugin-commonjs";import qt from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as Re}from"@rollup/plugin-node-resolve";import Te from"@rollup/plugin-replace";import{wasm as Vt}from"@rollup/plugin-wasm";import Gt from"rollup-plugin-polyfill-node";import{visualizer as Xt}from"rollup-plugin-visualizer";import{minVersion as Ae}from"semver";import{glob as Kt}from"glob";import Yt from"glob-parent";import Qt from"@rollup/plugin-json";import{createFilter as ne,normalizePath as fe}from"@rollup/pluginutils";import Zt from"rollup-plugin-license";import{createHash as eo}from"node:crypto";import{parse as to}from"@babel/parser";import{distance as oo}from"fastest-levenshtein";
1
+ var gt=Object.defineProperty;var m=(e,t)=>gt(e,"name",{value:t,configurable:!0});import{chmod as ht,stat as Ee,readdir as yt}from"node:fs/promises";import pe from"node:module";import{env as A,exit as F,versions as vt,cwd as bt}from"node:process";import{cyan as v,bold as O,gray as C,grey as $t,green as jt}from"@visulima/colorize";import{readFile as Q,writeFile as B,collectSync as wt,readFileSync as De,writeFileSync as Se,writeJsonSync as kt,isAccessibleSync as W,ensureDirSync as xt,emptyDir as Ne,walk as Ot,isAccessible as Et}from"@visulima/fs";import{NotFoundError as Dt}from"@visulima/fs/error";import{formatBytes as _,duration as St}from"@visulima/humanizer";import{findCacheDirectorySync as Nt,readTsConfig as Pt,findTSConfig as _t}from"@visulima/package";import{parsePackageJson as Mt}from"@visulima/package/package-json";import{createPail as Ct}from"@visulima/pail";import{MessageFormatterProcessor as Ft,ErrorProcessor as It,CallerProcessor as Rt}from"@visulima/pail/processor";import{resolve as f,join as y,normalize as Z,extname as ee,relative as S,dirname as te,basename as U,isAbsolute as Pe,toNamespacedPath as ue}from"@visulima/path";import{defu as Tt}from"defu";import{createHooks as At}from"hookable";import{a as R,R as Wt,E as de}from"./shared/packem.HRXF255z.mjs";import{pathToFileURL as Jt,fileURLToPath as Bt}from"node:url";import{resolvePath as Lt,resolveModuleExportNames as zt,findStaticImports as _e}from"mlly";import D from"magic-string";import Me from"jiti";import{existsSync as oe}from"node:fs";import{rollup as Ce,watch as me}from"rollup";import Fe from"@rollup/plugin-alias";import Ut from"@rollup/plugin-commonjs";import Ht from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as Ie}from"@rollup/plugin-node-resolve";import Re from"@rollup/plugin-replace";import{wasm as qt}from"@rollup/plugin-wasm";import Vt from"rollup-plugin-polyfill-node";import{visualizer as Gt}from"rollup-plugin-visualizer";import{minVersion as Te}from"semver";import{glob as Xt}from"glob";import Kt from"glob-parent";import Yt from"@rollup/plugin-json";import{createFilter as ne,normalizePath as fe}from"@rollup/pluginutils";import Qt from"rollup-plugin-license";import{createHash as Zt}from"node:crypto";import{parse as eo}from"@babel/parser";import{distance as to}from"fastest-levenshtein";
2
2
  // -- pack CommonJS Shims --
3
3
  import __cjs_url__ from "node:url";
4
4
  import __cjs_path__ from "node:path";
@@ -6,39 +6,39 @@ import __cjs_mod__ from "node:module";
6
6
  const __filename = __cjs_url__.fileURLToPath(import.meta.url);
7
7
  const __dirname = __cjs_path__.dirname(__filename);
8
8
  const require = __cjs_mod__.createRequire(import.meta.url);
9
- var ro=Object.defineProperty,q=d((e,t)=>ro(e,"name",{value:t,configurable:!0}),"i$b");const se=/^#![^\n]*/,K=q(async e=>{await yt(e,493).catch(()=>{})},"makeExecutable"),no=q((e,t=`#!/usr/bin/env node
10
- `)=>({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 S(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"&&se.test(s.code)&&o.dir){const a=h(o.dir,r);await K(a)}}}),"shebangPlugin"),so=q(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(se,"")}}),"removeShebangPlugin"),io=q((e,t=`
11
- `)=>{const o=se.exec(e);return o?o+t:""},"getShebang");var ao=Object.defineProperty,lo=d((e,t)=>ao(e,"name",{value:t,configurable:!0}),"p$3");const ie=lo((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]=v(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 co=Object.defineProperty,po=d((e,t)=>co(e,"name",{value:t,configurable:!0}),"o$3");const uo=po((e,t)=>{const o=Ce(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,fo=d((e,t)=>mo(e,"name",{value:t,configurable:!0}),"r$8");const B=fo((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var go=Object.defineProperty,ho=d((e,t)=>go(e,"name",{value:t,configurable:!0}),"u$7");const yo=ho(async e=>{const t=await zt("jiti",{url:import.meta.url}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...ie(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=ee(uo(n.input,e.options.rootDir)||n.input),a=s.slice(0,Math.max(0,s.length-te(s).length)),i=await Z(s),l=io(i);e.options.emitCJS&&await L(`${r}.cjs`,l+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(a)})} */`,`module.exports = _jiti(${JSON.stringify(s)})`].join(`
12
- `));let c=[];try{c=await Ut(s,{extensions:T})}catch(p){B(e,`Cannot analyze ${s} for exports:${p}`);return}const u=c.includes("default")||c.length===0;await L(`${r}.mjs`,l+[`import jiti from ${JSON.stringify(Bt(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,u?`
13
- export default _module;`:"",...c.filter(p=>p!=="default").map(p=>`export const ${p} = _module.${p};`)].join(`
14
- `)),await L(`${r}.d.cts`,[`export * from ${JSON.stringify(a)};`,u?`export { default } from ${JSON.stringify(a)};`:""].join(`
15
- `)),await L(`${r}.d.mts`,[`export * from ${JSON.stringify(s)};`,u?`export { default } from ${JSON.stringify(s)};`:""].join(`
16
- `)),l&&(await K(`${r}.cjs`),await K(`${r}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var vo=Object.defineProperty,bo=d((e,t)=>vo(e,"name",{value:t,configurable:!0}),"r$7");const We=bo((e,t)=>Ce(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var $o=Object.defineProperty,Je=d((e,t)=>$o(e,"name",{value:t,configurable:!0}),"t$4");const ae=Je(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Be=Je((e,t,o,n)=>{if(o){const a=ae(o);if(a)return a}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 Be(r,s,o,n)},"inferExportType");var jo=Object.defineProperty,wo=d((e,t)=>jo(e,"name",{value:t,configurable:!0}),"o$2");const le=wo((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const r=ae(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",subKey:r,type:Be(r,n,s,t)}:le(s,t,o,[...n,r]))},"extractExportFilenames");var ko=Object.defineProperty,Le=d((e,t)=>ko(e,"name",{value:t,configurable:!0}),"d$4");const ge=Le((e,t,o,n,r,s,a)=>{const i=e.find(l=>l.input===t)??e[e.push({input:t})-1];if(o&&(i.outDir=n),r.file.includes(".min.")&&(i.minify=!0),r.isExecutable)i.executable=!0,i.declaration=!1,i.cjs=s.type==="commonjs",i.esm=s.type==="module";else{/\.d\.[mc]?ts$/.test(r.file)&&!a&&(i.declaration=a),r.type==="cjs"&&(i.cjs=!0),r.type==="esm"&&(i.esm=!0);for(const l of Jt)if(r.file.includes(l)){i.runtime=l;break}r.key==="exports"&&r.subKey==="production"?i.environment="production":r.key==="exports"&&r.subKey==="development"&&(i.environment="development")}},"createOrUpdateEntry"),he=/(?:\.d\.[mc]?ts|\.\w+)$/,xo=Le((e,t,o)=>{const n=[];t.sort((i,l)=>i.split("/").length-l.split("/").length);const r=le(e.exports,e.type??"commonjs",o.options.declaration);if(e.bin){const i=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const l of i)r.push({file:l,isExecutable:!0,key:"bin"})}e.main&&r.push({file:e.main,key:"main",type:ae(e.main)??(e.type==="module"?"esm":"cjs")}),e.module&&r.push({file:e.module,key:"module",type:"esm"}),o.options.declaration!==!1&&(e.types||e.typings)&&r.push({file:e.types??e.typings,key:"types"});const s=e.type==="module";for(const i of r.filter(l=>!l.type)){const l=i.file.endsWith(".js");s&&l||i.file.endsWith(".mjs")?i.type="esm":(!s&&l||i.file.endsWith(".cjs"))&&(i.type="cjs")}const a=[];for(const i of r){const l=i.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const u=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir);if(i.file.includes("/*")&&i.key==="exports"){o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub.");const g=[],f=new RegExp("(?<=/|$)"+u.replace("*","(.*)")+(c?"":"\\.\\w+"));for(const y of t)f.test(y)&&g.push(y.replace(he,""));if(g.length===0){n.push(`Could not find entrypoints for \`${i.file}\``);continue}for(const y of g)ge(a,y,c,l,i,e,o.options.declaration);continue}const p=new RegExp("(?<=/|$)"+u+(c?"":"\\.\\w+")),m=t.find(g=>p.test(g))?.replace(he,"");if(!m){re(h(o.options.rootDir,i.file))||n.push(`Could not find entrypoint for \`${i.file}\``);continue}ge(a,m,c,l,i,e,o.options.declaration)}return{entries:a,warnings:n}},"inferEntries");var Oo=Object.defineProperty,Eo=d((e,t)=>Oo(e,"name",{value:t,configurable:!0}),"t$3");const Do=Eo((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 So=Object.defineProperty,No=d((e,t)=>So(e,"name",{value:t,configurable:!0}),"n$8");const Po={hooks:{"build:prepare":No(function(e){if(e.options.entries.length>0)return;const t=v(e.options.rootDir,"src");if(!re(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=kt(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=Do(n,e.options.declaration));const r=xo(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:",b(e.options.entries.map(s=>E(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),F([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var _o=Object.defineProperty,Mo=d((e,t)=>_o(e,"name",{value:t,configurable:!0}),"t$2");const Co=Mo((e,t)=>(e==="auto"?e=Po:typeof e=="string"&&(e=We(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var Fo=Object.defineProperty,Io=d((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"a$a");const Y=Io((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var Ro=Object.defineProperty,To=d((e,t)=>Ro(e,"name",{value:t,configurable:!0}),"a$9");const V=To(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var Ao=Object.defineProperty,Wo=d((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"e$1");const Q=Wo((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var Jo=Object.defineProperty,ze=d((e,t)=>Jo(e,"name",{value:t,configurable:!0}),"s$a");const Bo=ze((e,t,o)=>{const n=o??new Map;return(...r)=>{const s=t?typeof t=="function"?t(...r):t:JSON.stringify({args:r}),a=n.get(s);if(a!==void 0)return a;const i=e(...r);return n.set(s,i),i}},"memoize"),Lo=ze(e=>{const t=new Map;return o=>Bo(e,o,t)},"memoizeByKey");var zo=Object.defineProperty,Uo=d((e,t)=>zo(e,"name",{value:t,configurable:!0}),"m$5");const Ue=Uo(({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 a=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(a===null||a.length<3)return null;const i=new S(n);i.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),i.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&i.append(`
17
- module.exports.default = `+a[2]+";");let l=i.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:i.generateMap({hires:!0})}}if(s.format==="es"&&/\.d\.(?:ts|cts)$/.test(r.fileName)){if(o!=="commonjs"&&r.fileName.endsWith(".d.ts"))return null;const a=/export\s\{\s(.*)\s\}/i.exec(n);if(a===null||a.length<2)return null;const i=a[1].split(", "),l=[];let c="";for(const p of i)if(!p.includes("type"))if(p.includes("as")){const[m,g]=p.split(" as ");if(g==="default"&&(c=m,!e))continue;l.push(g+": typeof "+m+";")}else l.push(p+": typeof "+p+";");const u=new S(n);return u.replace(" "+c+" as default,",""),u.append(`
9
+ var oo=Object.defineProperty,H=m((e,t)=>oo(e,"name",{value:t,configurable:!0}),"i$b");const re=/^#![^\n]*/,X=H(async e=>{await ht(e,493).catch(()=>{})},"makeExecutable"),no=H((e,t=`#!/usr/bin/env node
10
+ `)=>({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 D(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"&&re.test(s.code)&&o.dir){const a=f(o.dir,n);await X(a)}}}),"shebangPlugin"),ro=H(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(re,"")}}),"removeShebangPlugin"),so=H((e,t=`
11
+ `)=>{const o=re.exec(e);return o?o+t:""},"getShebang");var io=Object.defineProperty,ao=m((e,t)=>io(e,"name",{value:t,configurable:!0}),"p$3");const se=ao((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]=y(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 lo=Object.defineProperty,co=m((e,t)=>lo(e,"name",{value:t,configurable:!0}),"o$3");const po=co((e,t)=>{const o=Me(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 uo=Object.defineProperty,mo=m((e,t)=>uo(e,"name",{value:t,configurable:!0}),"r$8");const J=mo((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var fo=Object.defineProperty,go=m((e,t)=>fo(e,"name",{value:t,configurable:!0}),"u$7");const ho=go(async e=>{const t=await Lt("jiti",{url:import.meta.url}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...se(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const r of e.options.entries){const n=f(e.options.rootDir,e.options.outDir,r.name),s=Z(po(r.input,e.options.rootDir)||r.input),a=s.slice(0,Math.max(0,s.length-ee(s).length)),i=await Q(s),c=so(i);e.options.emitCJS&&await B(`${n}.cjs`,c+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(a)})} */`,`module.exports = _jiti(${JSON.stringify(s)})`].join(`
12
+ `));let l=[];try{l=await zt(s,{extensions:R})}catch(d){J(e,`Cannot analyze ${s} for exports:${d}`);return}const p=l.includes("default")||l.length===0;await B(`${n}.mjs`,c+[`import jiti from ${JSON.stringify(Jt(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,p?`
13
+ export default _module;`:"",...l.filter(d=>d!=="default").map(d=>`export const ${d} = _module.${d};`)].join(`
14
+ `)),await B(`${n}.d.cts`,[`export * from ${JSON.stringify(a)};`,p?`export { default } from ${JSON.stringify(a)};`:""].join(`
15
+ `)),await B(`${n}.d.mts`,[`export * from ${JSON.stringify(s)};`,p?`export { default } from ${JSON.stringify(s)};`:""].join(`
16
+ `)),c&&(await X(`${n}.cjs`),await X(`${n}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var yo=Object.defineProperty,vo=m((e,t)=>yo(e,"name",{value:t,configurable:!0}),"r$7");const Ae=vo((e,t)=>Me(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var bo=Object.defineProperty,We=m((e,t)=>bo(e,"name",{value:t,configurable:!0}),"t$4");const ie=We(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Je=We((e,t,o,r)=>{if(o){const a=ie(o);if(a)return a}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 Je(n,s,o,r)},"inferExportType");var $o=Object.defineProperty,jo=m((e,t)=>$o(e,"name",{value:t,configurable:!0}),"o$2");const ae=jo((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=ie(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",subKey:n,type:Je(n,r,s,t)}:ae(s,t,o,[...r,n]))},"extractExportFilenames");var wo=Object.defineProperty,Be=m((e,t)=>wo(e,"name",{value:t,configurable:!0}),"d$4");const ge=Be((e,t,o,r,n,s,a)=>{const i=e.find(c=>c.input===t)??e[e.push({input:t})-1];if(o&&(i.outDir=r),n.file.includes(".min.")&&(i.minify=!0),n.isExecutable)i.executable=!0,i.declaration=!1,i.cjs=s.type==="commonjs",i.esm=s.type==="module";else{/\.d\.[mc]?ts$/.test(n.file)&&!a&&(i.declaration=a),n.type==="cjs"&&(i.cjs=!0),n.type==="esm"&&(i.esm=!0);for(const c of Wt)if(n.file.includes(c)){i.runtime=c;break}n.key==="exports"&&n.subKey==="production"?i.environment="production":n.key==="exports"&&n.subKey==="development"&&(i.environment="development")}},"createOrUpdateEntry"),he=/(?:\.d\.[mc]?ts|\.\w+)$/,ko=Be((e,t,o)=>{const r=[];t.sort((i,c)=>i.split("/").length-c.split("/").length);const n=ae(e.exports,e.type??"commonjs",o.options.declaration);if(e.bin){const i=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const c of i)n.push({file:c,isExecutable:!0,key:"bin"})}e.main&&n.push({file:e.main,key:"main",type:ie(e.main)??(e.type==="module"?"esm":"cjs")}),e.module&&n.push({file:e.module,key:"module",type:"esm"}),o.options.declaration!==!1&&(e.types||e.typings)&&n.push({file:e.types??e.typings,key:"types"});const s=e.type==="module";for(const i of n.filter(c=>!c.type)){const c=i.file.endsWith(".js");s&&c||i.file.endsWith(".mjs")?i.type="esm":(!s&&c||i.file.endsWith(".cjs"))&&(i.type="cjs")}const a=[];for(const i of n){const c=i.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),l=c.endsWith("/");if(l&&["./","/"].includes(c))continue;const p=c.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir);if(i.file.includes("/*")&&i.key==="exports"){o.logger.warn("Private subfolders are not supported, if you need this feature please open an issue on GitHub.");const g=[],j=new RegExp("(?<=/|$)"+p.replace("*","(.*)")+(l?"":"\\.\\w+"));for(const x of t)j.test(x)&&g.push(x.replace(he,""));if(g.length===0){r.push(`Could not find entrypoints for \`${i.file}\``);continue}for(const x of g)ge(a,x,l,c,i,e,o.options.declaration);continue}const d=new RegExp("(?<=/|$)"+p+(l?"":"\\.\\w+")),u=t.find(g=>d.test(g))?.replace(he,"");if(!u){oe(f(o.options.rootDir,i.file))||r.push(`Could not find entrypoint for \`${i.file}\``);continue}ge(a,u,l,c,i,e,o.options.declaration)}return{entries:a,warnings:r}},"inferEntries");var xo=Object.defineProperty,Oo=m((e,t)=>xo(e,"name",{value:t,configurable:!0}),"t$3");const Eo=Oo((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 Do=Object.defineProperty,So=m((e,t)=>Do(e,"name",{value:t,configurable:!0}),"n$8");const No={hooks:{"build:prepare":So(function(e){if(e.options.entries.length>0)return;const t=y(e.options.rootDir,"src");if(!oe(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=wt(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=Eo(r,e.options.declaration));const n=ko(r,o,e);for(const s of n.warnings)J(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=>O(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),C([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var Po=Object.defineProperty,_o=m((e,t)=>Po(e,"name",{value:t,configurable:!0}),"t$2");const Mo=_o((e,t)=>(e==="auto"?e=No:typeof e=="string"&&(e=Ae(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var Co=Object.defineProperty,Fo=m((e,t)=>Co(e,"name",{value:t,configurable:!0}),"a$a");const K=Fo((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var Io=Object.defineProperty,Ro=m((e,t)=>Io(e,"name",{value:t,configurable:!0}),"a$9");const q=Ro(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var To=Object.defineProperty,Ao=m((e,t)=>To(e,"name",{value:t,configurable:!0}),"e$1");const Y=Ao((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var Wo=Object.defineProperty,Le=m((e,t)=>Wo(e,"name",{value:t,configurable:!0}),"s$a");const Jo=Le((e,t,o)=>{const r=o??new Map;return(...n)=>{const s=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),a=r.get(s);if(a!==void 0)return a;const i=e(...n);return r.set(s,i),i}},"memoize"),Bo=Le(e=>{const t=new Map;return o=>Jo(e,o,t)},"memoizeByKey");var Lo=Object.defineProperty,zo=m((e,t)=>Lo(e,"name",{value:t,configurable:!0}),"m$6");const ze=zo(({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 a=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(a===null||a.length<3)return null;const i=new D(r);i.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),i.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&i.append(`
17
+ module.exports.default = `+a[2]+";");let c=i.toString();return c=c.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:c,map:i.generateMap({hires:!0})}}if(s.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)){if(o!=="commonjs"&&n.fileName.endsWith(".d.ts"))return null;const a=/export\s\{\s(.*)\s\}/i.exec(r);if(a===null||a.length<2)return null;const i=a[1].split(", "),c=[];let l="";for(const d of i)if(!d.includes("type"))if(d.includes("as")){const[u,g]=d.split(" as ");if(g==="default"&&(l=u,!e))continue;c.push(g+": typeof "+u+";")}else c.push(d+": typeof "+d+";");const p=new D(r);return p.replace(" "+l+" as default,",""),p.append(`
18
18
 
19
19
  declare const defaultExport: {
20
- `+(l.length>0?" ":"")+l.join(`
20
+ `+(c.length>0?" ":"")+c.join(`
21
21
  `)+`
22
- } & typeof `+c+`;
22
+ } & typeof `+l+`;
23
23
 
24
- export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:u.toString(),map:u.generateMap({hires:!0})}}return null}}),"cjsInterop");var Ho=Object.defineProperty,qo=d((e,t)=>Ho(e,"name",{value:t,configurable:!0}),"f$7");const Vo=qo((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(a=>Array.isArray(a.src)?a.src.map(i=>({...a,src:i})):a).map(async a=>await Kt(a.src,{ignore:a.exclude}).then(i=>({dest:a.dest??"",parent:Yt(a.src),src:i}))));for(const a of s)for(const i of a.src){let l;o.has(i)?l=o.get(i):(l={copied:[],dest:[],timestamp:0},o.set(i,l));const c=n.flatten?ee(a.dest):v(a.dest,N(a.parent,oe(i)));l.dest.includes(c)||l.dest.push(c),this.addWatchFile(i)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([a,i])=>{let l;try{const c=await De(a);if(!c.isFile())return;const u=c.mtime.getTime();u>i.timestamp&&(i.timestamp=u,i.copied=[]),l=await Z(a,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${a}`,prefix:"plugin:copy"});return}for(const c of i.dest){if(n.copyOnce&&i.copied.includes(c))continue;const u=H(a),p=v(c,u);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:p,source:l,type:"asset"}),t.debug({message:`copied ${a} → ${p}`,prefix:"plugin:copy"}),i.copied.push(c)}catch(m){t.error({context:[m],message:`error copying file ${a} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Go=Object.defineProperty,Xo=d((e,t)=>Go(e,"name",{value:t,configurable:!0}),"n$4");const ye="export default ",He=Xo(e=>{const t=Qt(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(ye)&&(r.code=r.code.replace(ye,"module.exports = ")),r}}},"JSONPlugin");class Ko{static{d(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:d(()=>this.should_skip=!0,"skip"),remove:d(()=>this.should_remove=!0,"remove"),replace:d(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 Yo extends Ko{static{d(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:d(()=>this.should_skip=!0,"skip"),remove:d(()=>this.should_remove=!0,"remove"),replace:d(n=>this.replacement=n,"replace")},this.enter=t,this.leave=o}visit(t,o,n,r){if(t){if(this.enter){const a=this.should_skip,i=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,u=this.should_remove;if(this.should_skip=a,this.should_remove=i,this.replacement=l,c)return t;if(u)return null}let s;for(s in t){const a=t[s];if(a&&typeof a=="object")if(Array.isArray(a)){const i=a;for(let l=0;l<i.length;l+=1){const c=i[l];ve(c)&&(this.visit(c,t,s,l)||l--)}}else ve(a)&&this.visit(a,t,s,null)}if(this.leave){const a=this.replacement,i=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=a,this.should_remove=i,l)return null}}return t}}function ve(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}d(ve,"isNode");function qe(e,{enter:t,leave:o}){return new Yo(t,o).visit(e,null)}d(qe,"walk");var Qo=Object.defineProperty,Zo=d((e,t)=>Qo(e,"name",{value:t,configurable:!0}),"u$5");const er=Zo(({attributes:e,logger:t})=>{const o=ne([/\.[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 a=!1;const i=new S(n);return qe(s,{enter(l){if(l.type==="CallExpression"&&l.callee.type==="Identifier"&&l.callee.name==="jsx"){const c=l.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of c)for(const p of u.properties)p.type==="Property"&&p.key.type==="Literal"&&p.value.type==="Literal"&&e.includes(p.key.value)&&(i.overwrite(p.start-2,p.end,""),a=!0)}}}),a?{code:i.toString(),map:i.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var tr=Object.defineProperty,ce=d((e,t)=>tr(e,"name",{value:t,configurable:!0}),"p$1");const or=ce(e=>{const t=[],o=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):o.push(n)}),[...o.sort(),...t.sort()]},"sortLicenses"),rr=ce((e,t,o)=>{const n=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(n.test(e))return e.replace(n,`$1
24
+ 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 Uo=Object.defineProperty,Ho=m((e,t)=>Uo(e,"name",{value:t,configurable:!0}),"f$6");const qo=Ho((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(a=>Array.isArray(a.src)?a.src.map(i=>({...a,src:i})):a).map(async a=>await Xt(a.src,{ignore:a.exclude}).then(i=>({dest:a.dest??"",parent:Kt(a.src),src:i}))));for(const a of s)for(const i of a.src){let c;o.has(i)?c=o.get(i):(c={copied:[],dest:[],timestamp:0},o.set(i,c));const l=r.flatten?Z(a.dest):y(a.dest,S(a.parent,te(i)));c.dest.includes(l)||c.dest.push(l),this.addWatchFile(i)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([a,i])=>{let c;try{const l=await Ee(a);if(!l.isFile())return;const p=l.mtime.getTime();p>i.timestamp&&(i.timestamp=p,i.copied=[]),c=await Q(a,{buffer:!0})}catch(l){t.error({context:[l],message:`error reading file ${a}`,prefix:"plugin:copy"});return}for(const l of i.dest){if(r.copyOnce&&i.copied.includes(l))continue;const p=U(a),d=y(l,p);try{this.emitFile({[r.exactFileNames?"fileName":"name"]:d,source:c,type:"asset"}),t.debug({message:`copied ${a} → ${d}`,prefix:"plugin:copy"}),i.copied.push(l)}catch(u){t.error({context:[u],message:`error copying file ${a} → ${d}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Vo=Object.defineProperty,Go=m((e,t)=>Vo(e,"name",{value:t,configurable:!0}),"n$4");const ye="export default ",Ue=Go(e=>{const t=Yt(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(ye)&&(n.code=n.code.replace(ye,"module.exports = ")),n}}},"JSONPlugin");class Xo{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 Ko extends Xo{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 a=this.should_skip,i=this.should_remove,c=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 l=this.should_skip,p=this.should_remove;if(this.should_skip=a,this.should_remove=i,this.replacement=c,l)return t;if(p)return null}let s;for(s in t){const a=t[s];if(a&&typeof a=="object")if(Array.isArray(a)){const i=a;for(let c=0;c<i.length;c+=1){const l=i[c];ve(l)&&(this.visit(l,t,s,c)||c--)}}else ve(a)&&this.visit(a,t,s,null)}if(this.leave){const a=this.replacement,i=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 c=this.should_remove;if(this.replacement=a,this.should_remove=i,c)return null}}return t}}function ve(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(ve,"isNode");function He(e,{enter:t,leave:o}){return new Ko(t,o).visit(e,null)}m(He,"walk");var Yo=Object.defineProperty,Qo=m((e,t)=>Yo(e,"name",{value:t,configurable:!0}),"u$5");const Zo=Qo(({attributes:e,logger:t})=>{const o=ne([/\.[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(c){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${n}" and remove the jsx attribute.`}),t.warn(c),null}let a=!1;const i=new D(r);return He(s,{enter(c){if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="jsx"){const l=c.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of l)for(const d of p.properties)d.type==="Property"&&d.key.type==="Literal"&&d.value.type==="Literal"&&e.includes(d.key.value)&&(i.overwrite(d.start-2,d.end,""),a=!0)}}}),a?{code:i.toString(),map:i.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var en=Object.defineProperty,le=m((e,t)=>en(e,"name",{value:t,configurable:!0}),"p$1");const tn=le(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),on=le((e,t,o)=>{const r=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(r.test(e))return e.replace(r,`$1
25
25
  ${o}
26
- $2`)},"replaceContentWithin"),Ve=ce(({licenseFilePath:e,licenseTemplate:t,logger:o,marker:n,mode:r,packageName:s})=>Zt({thirdParty(a){const i=new Set,l=a.sort(({name:u},{name:p})=>u>p?1:p>u?-1:0).map(({author:u,contributors:p,license:m,licenseText:g,maintainers:f,name:y,repository:k})=>{let P="## "+y+`
27
- `;m&&(P+=`License: ${m}
28
- `);const _=new Set;for(const x of[u,...f,...p]){const O=typeof x=="string"?x:x?.name;O&&_.add(O)}return _.size>0&&(P+=`By: ${[..._].join(", ")}
29
- `),k&&(P+=`Repository: ${typeof k=="string"?k:k.url}
30
- `),g&&(P+=`
26
+ $2`)},"replaceContentWithin"),qe=le(({licenseFilePath:e,licenseTemplate:t,logger:o,marker:r,mode:n,packageName:s})=>Qt({thirdParty(a){const i=new Set,c=a.sort(({name:p},{name:d})=>p>d?1:d>p?-1:0).map(({author:p,contributors:d,license:u,licenseText:g,maintainers:j,name:x,repository:N})=>{let w="## "+x+`
27
+ `;u&&(w+=`License: ${u}
28
+ `);const h=new Set;for(const P of[p,...j,...d]){const ce=typeof P=="string"?P:P?.name;ce&&h.add(ce)}return h.size>0&&(w+=`By: ${[...h].join(", ")}
29
+ `),N&&(w+=`Repository: ${typeof N=="string"?N:N.url}
30
+ `),g&&(w+=`
31
31
  `+g.trim().replaceAll(/(\r\n|\r)/g,`
32
32
  `).split(`
33
- `).map(x=>`> ${x}`).join(`
33
+ `).map(P=>`> ${P}`).join(`
34
34
  `)+`
35
- `),m&&i.add(m),P}).join(`
35
+ `),u&&i.add(u),w}).join(`
36
36
  ---------------------------------------
37
37
 
38
- `);if(l===""){o.info({message:"No dependencies license information found.",prefix:"plugin:license:"+r});return}const c=t(or(i),l,s);try{const u=Se(e),p=rr(u,n,c);if(!p){o.error({message:`Could not find the license marker: <!-- ${n} --> in ${e}`,prefix:"plugin:license:"+r});return}u!==p&&(Ne(e,p),o.info({message:`${e} updated.`,prefix:"plugin:license:"+r}))}catch(u){o.error(u)}}}),"license");var nr=Object.defineProperty,sr=d((e,t)=>nr(e,"name",{value:t,configurable:!0}),"i$7");const ir=sr(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");xt(o,t)},name:"packem:metafile"}),"metafilePlugin");var ar=Object.defineProperty,lr=d((e,t)=>ar(e,"name",{value:t,configurable:!0}),"r$5");const C=lr(e=>{const t=eo("md5");return t.update(e),t.digest("hex")},"getHash");var cr=Object.defineProperty,Ge=d((e,t)=>cr(e,"name",{value:t,configurable:!0}),"m$4");const A=Ge(e=>e.handler||e,"getHandler"),w=Ge((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=v("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=v("resolveId",C(o),n?C(n):"",C(JSON.stringify(r)));if(t.has(s,e.name))return await t.get(s,e.name);const a=await A(e.resolveId).call(this,o,n,r);return t.set(s,a,e.name),a},async transform(o,n){if(!e.transform)return null;const r=v("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 pr=Object.defineProperty,ur=d((e,t)=>pr(e,"name",{value:t,configurable:!0}),"c$4");const mr=/\.(?:m|c)?(?:j|t)sx?$/,dr=/^use \w+$/,fr=ur(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 a=r.moduleIds.map(c=>t[c]?t[c]:null).reduce((c,u)=>(u&&u.forEach(p=>{c.add(p)}),c),new Set),i=new S(n);a.size>0&&(e.debug({message:`directives for chunk "${r.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),i.prepend(`${[...a].map(c=>`'${c}';`).join(`
38
+ `);if(c===""){o.info({message:"No dependencies license information found.",prefix:"plugin:license:"+n});return}const l=t(tn(i),c,s);try{const p=De(e),d=on(p,r,l);if(!d){o.error({message:`Could not find the license marker: <!-- ${r} --> in ${e}`,prefix:"plugin:license:"+n});return}p!==d&&(Se(e,d),o.info({message:`${e} updated.`,prefix:"plugin:license:"+n}))}catch(p){o.error(p)}}}),"license");var nn=Object.defineProperty,rn=m((e,t)=>nn(e,"name",{value:t,configurable:!0}),"i$7");const sn=rn(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=f(e.rootDir,e.outDir,"graph.json");kt(o,t)},name:"packem:metafile"}),"metafilePlugin");var an=Object.defineProperty,ln=m((e,t)=>an(e,"name",{value:t,configurable:!0}),"r$5");const M=ln(e=>{const t=Zt("md5");return t.update(e),t.digest("hex")},"getHash");var cn=Object.defineProperty,Ve=m((e,t)=>cn(e,"name",{value:t,configurable:!0}),"m$5");const T=Ve(e=>e.handler||e,"getHandler"),k=Ve((e,t)=>({...e,async buildEnd(o){e.buildEnd&&await T(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await T(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const r=y("load",M(o));if(t.has(r,e.name))return await t.get(r,e.name);const n=await T(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=y("resolveId",M(o),r?M(r):"",M(JSON.stringify(n)));if(t.has(s,e.name))return await t.get(s,e.name);const a=await T(e.resolveId).call(this,o,r,n);return t.set(s,a,e.name),a},async transform(o,r){if(!e.transform)return null;const n=y("transform",M(r),M(o));if(t.has(n,e.name))return await t.get(n,e.name);const s=await T(e.transform).call(this,o,r);return t.set(n,s,e.name),s}}),"cachingPlugin");var pn=Object.defineProperty,un=m((e,t)=>pn(e,"name",{value:t,configurable:!0}),"c$4");const dn=/\.(?:m|c)?(?:j|t)sx?$/,mn=/^use \w+$/,fn=un(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 a=n.moduleIds.map(l=>t[l]?t[l]:null).reduce((l,p)=>(p&&p.forEach(d=>{l.add(d)}),l),new Set),i=new D(r);a.size>0&&(e.debug({message:`directives for chunk "${n.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),i.prepend(`${[...a].map(l=>`'${l}';`).join(`
39
39
  `)}
40
- `));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"}),i.prepend(`${l}
41
- `)),a.size===0&&l===null?null:{code:i.toString(),map:s?i.generateMap({hires:!0}):null}},order:"post"},transform:{handler(n,r){const s=te(r);if(!mr.test(s))return null;let a=!1;const i=new S(n);if(n.startsWith("#")&&n[1]==="!"){let c=0;for(let u=2,p=n.length;u<p;u++){const m=n.codePointAt(u);if(m===10||m===13||m===8232||m===8233){c=u;break}}c&&(o[r]=n.slice(0,c),i.remove(0,c+1),a=!0,e.debug({message:`shebang for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}let l=null;try{l=this.parse(i.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 u=null;"directive"in c?u=c.directive:c.expression.type==="Literal"&&typeof c.expression.value=="string"&&dr.test(c.expression.value)&&(u=c.expression.value),u!=="use strict"&&u&&(t[r]||=new Set,t[r].add(u),"start"in c&&typeof c.start=="number"&&"end"in c&&typeof c.end=="number"&&(i.remove(c.start,c.end),a=!0),e.debug({message:`directive "${u}" for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}return a?{code:i.toString(),map:i.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[r]??[]],shebang:o[r]??null}}}:null},order:"post"}}},"preserveDirectives");var gr=Object.defineProperty,hr=d((e,t)=>gr(e,"name",{value:t,configurable:!0}),"r$4");const yr={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},vr=hr((e={})=>{e={...e,...yr};const t=ne(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 br=Object.defineProperty,$r=d((e,t)=>br(e,"name",{value:t,configurable:!0}),"l$2");const G="\0__file_url__",Xe=$r(()=>({async load(e){if(e.startsWith(G)){const t=Lt(e.slice(G.length));return await Z(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${G}${e}`}}),"resolveFileUrl");var jr=Object.defineProperty,Ke=d((e,t)=>jr(e,"name",{value:t,configurable:!0}),"i$3");const wr=/__filename|__dirname|require\(|require\.resolve\(/,Ye=`
40
+ `));let c=null;return n.facadeModuleId&&typeof o[n.facadeModuleId]=="string"&&(c=o[n.facadeModuleId]),c&&(e.debug({message:`shebang for chunk "${n.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),i.prepend(`${c}
41
+ `)),a.size===0&&c===null?null:{code:i.toString(),map:s?i.generateMap({hires:!0}):null}},order:"post"},transform:{handler(r,n){const s=ee(n);if(!dn.test(s))return null;let a=!1;const i=new D(r);if(r.startsWith("#")&&r[1]==="!"){let l=0;for(let p=2,d=r.length;p<d;p++){const u=r.codePointAt(p);if(u===10||u===13||u===8232||u===8233){l=p;break}}l&&(o[n]=r.slice(0,l),i.remove(0,l+1),a=!0,e.debug({message:`shebang for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}let c=null;try{c=this.parse(i.toString(),{allowReturnOutsideFunction:!0})}catch(l){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${n}" and extract the directives.`}),e.warn(l),null}if(c.type!=="Program")return null;for(const l of c.body.filter(Boolean)){if(l.type!=="ExpressionStatement")break;let p=null;"directive"in l?p=l.directive:l.expression.type==="Literal"&&typeof l.expression.value=="string"&&mn.test(l.expression.value)&&(p=l.expression.value),p!=="use strict"&&p&&(t[n]||=new Set,t[n].add(p),"start"in l&&typeof l.start=="number"&&"end"in l&&typeof l.end=="number"&&(i.remove(l.start,l.end),a=!0),e.debug({message:`directive "${p}" for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}return a?{code:i.toString(),map:i.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[n]??[]],shebang:o[n]??null}}}:null},order:"post"}}},"preserveDirectives");var gn=Object.defineProperty,hn=m((e,t)=>gn(e,"name",{value:t,configurable:!0}),"r$4");const yn={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},vn=hn((e={})=>{e={...e,...yn};const t=ne(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 bn=Object.defineProperty,$n=m((e,t)=>bn(e,"name",{value:t,configurable:!0}),"l$2");const V="\0__file_url__",Ge=$n(()=>({async load(e){if(e.startsWith(V)){const t=Bt(e.slice(V.length));return await Q(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${V}${e}`}}),"resolveFileUrl");var jn=Object.defineProperty,Xe=m((e,t)=>jn(e,"name",{value:t,configurable:!0}),"i$3");const wn=/__filename|__dirname|require\(|require\.resolve\(/,Ke=`
42
42
  // -- pack CommonJS Shims --
43
43
  import __cjs_url__ from "node:url";
44
44
  import __cjs_path__ from "node:path";
@@ -46,56 +46,56 @@ import __cjs_mod__ from "node:module";
46
46
  const __filename = __cjs_url__.fileURLToPath(import.meta.url);
47
47
  const __dirname = __cjs_path__.dirname(__filename);
48
48
  const require = __cjs_mod__.createRequire(import.meta.url);
49
- `,Qe=`
49
+ `,Ye=`
50
50
  // -- pack CommonJS Shims Node 20.11 --
51
51
  import __cjs_mod__ from "node:module";
52
52
  const __filename = import.meta.filename;
53
53
  const __dirname = import.meta.dirname;
54
54
  const require = __cjs_mod__.createRequire(import.meta.url);
55
- `,kr=Ke((e,t)=>{if(W.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(Ye)||e.includes(Qe)||!wr.test(e)))return null;const o=Me(e).pop(),n=o?o.end:0,r=new S(e);return r.appendRight(n,t),{code:r.toString(),map:r.generateMap()}},"CJSToESM"),xr=Ke(e=>({name:"packem:cjs",renderChunk(t,o,n){if(n.format==="es"){let r=Ye;if(e.engines?.node){const s=Ae(e.engines.node);s&&s.major>=20&&s.minor>=11&&(r=Qe)}return kr(t,r)}return null}}),"cjsPlugin");var Or=Object.defineProperty,R=d((e,t)=>Or(e,"name",{value:t,configurable:!0}),"s$6");const Er=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Dr=/MIT License|MIT license|BSD license/,Sr=/\n{2,}/g,Nr=/\b(\w+)\$\d+\b/g,Pr=/[-/\\^$*+?.()|[\]{}]/g,_r=R(e=>e.replaceAll(Pr,"\\$&"),"escapeRegex"),Mr=R(e=>[...new Set(e)],"unique"),Cr=R(e=>e.replaceAll(Er,t=>Dr.test(t)?"":t).replaceAll(Sr,`
55
+ `,kn=Xe((e,t)=>{if(A.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(Ke)||e.includes(Ye)||!wn.test(e)))return null;const o=_e(e).pop(),r=o?o.end:0,n=new D(e);return n.appendRight(r,t),{code:n.toString(),map:n.generateMap()}},"CJSToESM"),xn=Xe(e=>({name:"packem:cjs",renderChunk(t,o,r){if(r.format==="es"){let n=Ke;if(e.engines?.node){const s=Te(e.engines.node);s&&s.major>=20&&s.minor>=11&&(n=Ye)}return kn(t,n)}return null}}),"cjsPlugin");var On=Object.defineProperty,I=m((e,t)=>On(e,"name",{value:t,configurable:!0}),"s$6");const En=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Dn=/MIT License|MIT license|BSD license/,Sn=/\n{2,}/g,Nn=/\b(\w+)\$\d+\b/g,Pn=/[-/\\^$*+?.()|[\]{}]/g,_n=I(e=>e.replaceAll(Pn,"\\$&"),"escapeRegex"),Mn=I(e=>[...new Set(e)],"unique"),Cn=I(e=>e.replaceAll(En,t=>Dn.test(t)?"":t).replaceAll(Sn,`
56
56
 
57
- `),"cleanUnnecessaryComments"),be=new Map;function Ze(e,t,{identifierReplacements:o},n){const r=Me(e);for(const a in o){const i=r.find(c=>c.specifier===a&&c.imports.includes("{"));if(!i){this.warn(`${t.fileName} does not import "${a}" for replacement`),process.exitCode=1;continue}const l=o[a];for(const c in l){i.imports.includes(c)||(this.warn(`${t.fileName} does not import "${c}" from "${a}" for replacement`),I(1));const u=l[c],p=_r(c);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${p},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${p}\\b`,"g"),u)}}const s=Mr(Array.from(e.matchAll(Nr),a=>a[0]));if(s.length>0){const a=s.map(l=>`
58
- - ${l}`).join(""),i=t.fileName.replace(/\.[^/.]+$/,"");be.has(i)||n.warn({message:`${t.fileName} contains confusing identifier names${a}
57
+ `),"cleanUnnecessaryComments"),be=new Map;function Qe(e,t,{identifierReplacements:o},r){const n=_e(e);for(const a in o){const i=n.find(l=>l.specifier===a&&l.imports.includes("{"));if(!i){this.warn(`${t.fileName} does not import "${a}" for replacement`),process.exitCode=1;continue}const c=o[a];for(const l in c){i.imports.includes(l)||(this.warn(`${t.fileName} does not import "${l}" from "${a}" for replacement`),F(1));const p=c[l],d=_n(l);p.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${d},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${d}\\b`,"g"),p)}}const s=Mn(Array.from(e.matchAll(Nn),a=>a[0]));if(s.length>0){const a=s.map(c=>`
58
+ - ${c}`).join(""),i=t.fileName.replace(/\.[^/.]+$/,"");be.has(i)||r.warn({message:`${t.fileName} contains confusing identifier names${a}
59
59
 
60
- To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),be.set(i,!0)}return e}d(Ze,"v$1");R(Ze,"replaceConfusingTypeNames");function et(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}d(et,"N");R(et,"removeInternal");function tt(e,t){if(e.includes("@internal")){const o=new S(e),n=to(e,{plugins:["typescript"],sourceType:"module"});qe(n,{enter(r){et(o,r)&&this.skip()}}),e=o.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),I(1))}return e}d(tt,"S");R(tt,"stripInternalTypes");const Fr=R((e,t)=>({name:"packem:patch-types",renderChunk(o,n){return o=Ze.call(this,o,n,e,t),o=tt.call(this,o,n),o=Cr(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var Ir=Object.defineProperty,ot=d((e,t)=>Ir(e,"name",{value:t,configurable:!0}),"u$3");const rt=ot((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 a=h(oe(n),r),i=[];if(s)for(const[l,c]of Object.entries(s)){const u=new RegExp(`^${[...l].map(m=>m==="*"?"(.+)":m.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let p=0;for(const m of c){const g=[...fe(h(a,m))].map(f=>f==="*"?`$${++p}`:f==="$"?"$$":f).join("");i.push({find:u,replacement:g})}}return t&&i.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...fe(a)].map(l=>l==="$"?"$$":l).join("")}/$1`}),i},"getConfigAlias"),nt=ot((e,t)=>{const o=rt(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,r,s){if(!o||n.includes("\0"))return null;for(const{find:a,replacement:i}of o)if(a.test(n)){const l=n.replace(a,i),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 Rr=Object.defineProperty,st=d((e,t)=>Rr(e,"name",{value:t,configurable:!0}),"u$2");const Tr=st((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 a of r){if(a.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(a.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);s.push(h(e,a))}return s},"getRootDirectories"),it=st((e,t,o)=>{const n=Tr(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(r,s,a){if(n===null||n.length===0)return null;if(r.startsWith("."))for(const i of n){const l=v(i,r),c=await this.resolve(l,s,{skipSelf:!0,...a});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 Ar=Object.defineProperty,Wr=d((e,t)=>Ar(e,"name",{value:t,configurable:!0}),"r$3");const at=Wr(()=>{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 Jr=Object.defineProperty,Br=d((e,t)=>Jr(e,"name",{value:t,configurable:!0}),"s$5");const Lr=Br(e=>{const t=H(e).split(".");if(t.length>=2){const[o,n]=t.slice(-2),r=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(T.includes(n)&&s&&s.length>0)return r+"-"+s}},"getCustomModuleLayer");var zr=Object.defineProperty,Ur=d((e,t)=>zr(e,"name",{value:t,configurable:!0}),"i$2");const X=Ur(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var Hr=Object.defineProperty,$e=d((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"c$2");const je=$e((e,t)=>{const o=new Map;return $e(function(n,r){const s=r.getModuleInfo(n);if(!s)return;const{isEntry:a}=s,i=s.meta,l=X(i);if(!a){const c=o.get(n);if(c)return c;const u=Lr(n);if(u)return o.set(n,u),u}if(a){const c=r.getModuleIds();for(const u of c)r.getModuleInfo(u)&&X(i)===l&&(e.has(u)||e.set(u,new Set),e.get(u).add([n,l]))}if(l&&!a&&e.has(n)){const c=[...e.get(n)];if(c.some(([p])=>{if(t.some(m=>m.path===p)){const m=r.getModuleInfo(p);return X(m?m.meta:{})===l}return!1}))return;if(c.every(([,p])=>p===l))return o.has(n)?o.get(n):void 0;const u=`${H(n,te(n))}-${l}`;return o.set(n,u),u}},"splitChunks")},"createSplitChunks");var qr=Object.defineProperty,Vr=d((e,t)=>qr(e,"name",{value:t,configurable:!0}),"n$2");const D=Vr((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var Gr=Object.defineProperty,Xr=d((e,t)=>Gr(e,"name",{value:t,configurable:!0}),"s$3");const Kr=process.platform==="win32",we=Xr((e,t)=>{const o=Kr?"\\":"/";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 Yr=Object.defineProperty,$=d((e,t)=>Yr(e,"name",{value:t,configurable:!0}),"p");const Qr=$((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"+bt.node.split(".")[0];if(t.pkg.engines?.node){const n=Ae(t.pkg.engines.node);n&&(o="node"+n.major)}if(t.options.rollup.esbuild.target){const n=V(t.options.rollup.esbuild.target);n.some(r=>r.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...V(o),...n])])}else t.options.rollup.esbuild.target=V(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"),lt=$((e,t)=>e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message)?!0:e.code==="UNRESOLVED_IMPORT"?(t.logger.error(`Failed to resolve the module "${e.exporter}" imported by "${b(N(h(),e.id))}"
60
+ To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),be.set(i,!0)}return e}m(Qe,"v$1");I(Qe,"replaceConfusingTypeNames");function Ze(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(Ze,"N");I(Ze,"removeInternal");function et(e,t){if(e.includes("@internal")){const o=new D(e),r=eo(e,{plugins:["typescript"],sourceType:"module"});He(r,{enter(n){Ze(o,n)&&this.skip()}}),e=o.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),F(1))}return e}m(et,"S");I(et,"stripInternalTypes");const Fn=I((e,t)=>({name:"packem:patch-types",renderChunk(o,r){return o=Qe.call(this,o,r,e,t),o=et.call(this,o,r),o=Cn(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var In=Object.defineProperty,tt=m((e,t)=>In(e,"name",{value:t,configurable:!0}),"u$3");const ot=tt((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 a=f(te(r),n),i=[];if(s)for(const[c,l]of Object.entries(s)){const p=new RegExp(`^${[...c].map(u=>u==="*"?"(.+)":u.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let d=0;for(const u of l){const g=[...fe(f(a,u))].map(j=>j==="*"?`$${++d}`:j==="$"?"$$":j).join("");i.push({find:p,replacement:g})}}return t&&i.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...fe(a)].map(c=>c==="$"?"$$":c).join("")}/$1`}),i},"getConfigAlias"),nt=tt((e,t)=>{const o=ot(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(r,n,s){if(!o||r.includes("\0"))return null;for(const{find:a,replacement:i}of o)if(a.test(r)){const c=r.replace(a,i),l=await this.resolve(c,n,{skipSelf:!0,...s});if(l)return t.debug({message:`Resolved ${r} to ${l.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),l.id}return null}}},"resolveTsconfigPaths");var Rn=Object.defineProperty,rt=m((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"u$2");const Tn=rt((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 a of n){if(a.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(a.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);s.push(f(e,a))}return s},"getRootDirectories"),st=rt((e,t,o)=>{const r=Tn(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,s,a){if(r===null||r.length===0)return null;if(n.startsWith("."))for(const i of r){const c=y(i,n),l=await this.resolve(c,s,{skipSelf:!0,...a});if(l)return t.debug({message:`Resolved ${n} to ${l.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),l.id}return null}}},"resolveTsconfigRootDirectories");var An=Object.defineProperty,Wn=m((e,t)=>An(e,"name",{value:t,configurable:!0}),"r$3");const it=Wn(()=>{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 Jn=Object.defineProperty,Bn=m((e,t)=>Jn(e,"name",{value:t,configurable:!0}),"s$5");const Ln=Bn(e=>{const t=U(e).split(".");if(t.length>=2){const[o,r]=t.slice(-2),n=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(R.includes(r)&&s&&s.length>0)return n+"-"+s}},"getCustomModuleLayer");var zn=Object.defineProperty,Un=m((e,t)=>zn(e,"name",{value:t,configurable:!0}),"i$2");const G=Un(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var Hn=Object.defineProperty,$e=m((e,t)=>Hn(e,"name",{value:t,configurable:!0}),"c$2");const je=$e((e,t)=>{const o=new Map;return $e(function(r,n){const s=n.getModuleInfo(r);if(!s)return;const{isEntry:a}=s,i=s.meta,c=G(i);if(!a){const l=o.get(r);if(l)return l;const p=Ln(r);if(p)return o.set(r,p),p}if(a){const l=n.getModuleIds();for(const p of l)n.getModuleInfo(p)&&G(i)===c&&(e.has(p)||e.set(p,new Set),e.get(p).add([r,c]))}if(c&&!a&&e.has(r)){const l=[...e.get(r)];if(l.some(([d])=>{if(t.some(u=>u.path===d)){const u=n.getModuleInfo(d);return G(u?u.meta:{})===c}return!1}))return;if(l.every(([,d])=>d===c))return o.has(r)?o.get(r):void 0;const p=`${U(r,ee(r))}-${c}`;return o.set(r,p),p}},"splitChunks")},"createSplitChunks");var qn=Object.defineProperty,Vn=m((e,t)=>qn(e,"name",{value:t,configurable:!0}),"n$2");const E=Vn((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var Gn=Object.defineProperty,Xn=m((e,t)=>Gn(e,"name",{value:t,configurable:!0}),"s$3");const Kn=process.platform==="win32",we=Xn((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 Yn=Object.defineProperty,b=m((e,t)=>Yn(e,"name",{value:t,configurable:!0}),"p");const Qn=b((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"+vt.node.split(".")[0];if(t.pkg.engines?.node){const r=Te(t.pkg.engines.node);r&&(o="node"+r.major)}if(t.options.rollup.esbuild.target){const r=q(t.options.rollup.esbuild.target);r.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...q(o),...r])])}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"),at=b((e,t)=>e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message)?!0:e.code==="UNRESOLVED_IMPORT"?(t.logger.error(`Failed to resolve the module "${e.exporter}" imported by "${v(S(f(),e.id))}"
61
61
  Is the module installed? Note:
62
62
  ↳ to inline a module into your bundle, install it to "devDependencies".
63
- ↳ to depend on a module via import/require, install it to "dependencies".`),process.exitCode=1,!0):e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0,"sharedOnWarn"),ke=new Map,ct=$((e,t,o)=>{const n=$(s=>{for(const[a,i]of Object.entries(t))if(s.startsWith(a))return s.replace(a,i)},"findAlias"),r=rt(e.tsconfig,!1);return{external(s){const a=n(s);a&&(s=a);const i=Q(s),l=Y(e.options.externals,i)||Y(e.options.externals,s);if(l)return!0;if(s.startsWith(".")||_e(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&&!ke.has(s)&&e.logger.info({message:'Inlined implicit external "'+b(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),ke.set(s,!0),l},input:Object.fromEntries(e.options.entries.map(s=>[s.name,h(e.options.rootDir,s.input)])),onLog:$((s,a)=>{let i=a.message;switch(a.stack&&(i=`${i}
64
- ${a.stack}`),s){case"info":{e.logger.info({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")});return}case"warn":{e.logger.warn({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")});return}case"debug":e.logger.debug({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")})}},"onLog"),onwarn(s,a){lt(s,e)||s.code||a(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),pt=$(async(e,t)=>{const o=ie(e,"build");let n;return e.options.rollup.resolve&&(n=w(Re({extensions:T,...e.options.rollup.resolve}),t)),{...ct(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:$(r=>D(e,r,"cjs"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:$(r=>we(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:je(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:$(r=>D(e,r,"mjs"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:$(r=>we(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:je(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[w(Xe(),t),w(at(),t),e.tsconfig&&w(it(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&w(nt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Te({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ie({customResolver:n?.resolveId,...e.options.rollup.alias,entries:o}),n,e.options.rollup.polyfillNode&&Gt({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&He({...e.options.rollup.json}),fr(e.logger),no(e.options.entries.filter(r=>r.executable).map(r=>r.name).filter(Boolean)),e.options.rollup.wsam&&Vt(e.options.rollup.wsam),e.options.transformer?.(Qr(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&Ue({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&qt(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&w(Ht({extensions:T,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&xr(e.pkg),e.options.rollup.raw&&vr(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&er({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&ir({outDir:h(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&Vo(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Ve({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&&Xt({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"),Zr=$(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"),en=Lo(Zr),ut=$(async(e,t)=>{const o=ie(e,"types"),n={load(i){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(i)?null:""},name:"packem:ignore-files"},r=e.tsconfig?.config.compilerOptions;delete r?.lib;let s;e.options.rollup.resolve&&(s=w(Re({extensions:T,...e.options.rollup.resolve}),t));const a="dts-plugin:"+process.pid+e.tsconfig.path;return{...ct(e,o,"dts"),onwarn(i,l){lt(i,e)||i.code!=="EMPTY_BUNDLE"&&l(i)},output:[e.options.emitCJS&&{chunkFileNames:$(i=>D(e,i,"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},{chunkFileNames:$(i=>D(e,i,"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:$(i=>D(e,i,"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:[w(Xe(),t),w(at(),t),e.options.rollup.json&&He({...e.options.rollup.json}),n,e.tsconfig&&w(it(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&w(nt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Te({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ie({customResolver:s?.resolveId,...e.options.rollup.alias,entries:o}),s,await en(a)(e),e.options.cjsInterop&&e.options.emitCJS&&Ue({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&Fr(e.options.rollup.patchTypes,e.logger),so(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Ve({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 tn=Object.defineProperty,on=d((e,t)=>tn(e,"name",{value:t,configurable:!0}),"c$1");const rn=on(async(e,t)=>{const o=await pt(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 Fe(o);t.set(n,r.cache),await e.hooks.callHook("rollup:build",e,r);const s=o.output,a=new Map;for(const i of s){const{output:l}=await r.write(i),c=new Set,u=l.filter(m=>m.type==="chunk");for(const m of u){c.add(m.fileName);for(const g of m.imports)e.usedImports.add(g);m.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(m.code,"utf8"),chunks:m.imports.filter(g=>u.find(f=>f.fileName===g)),exports:m.exports,modules:Object.entries(m.modules).map(([g,f])=>({bytes:f.renderedLength,id:g})),path:m.fileName,type:"entry"})}const p=l.filter(m=>m.type==="asset");for(const m of p)a.has(m.fileName)||a.set(m.fileName,{bytes:Buffer.byteLength(m.source,"utf8"),path:m.fileName,type:"asset"});for(const m of c)e.usedImports.delete(m)}e.buildEntries.push(...a.values())},"build");var nn=Object.defineProperty,z=d((e,t)=>nn(e,"name",{value:t,configurable:!0}),"r$1");const sn=z(async(e,t)=>{const o=await ut(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 Fe(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:z(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:z(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:z(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 an=Object.defineProperty,mt=d((e,t)=>an(e,"name",{value:t,configurable:!0}),"e");const xe=mt((e,t,o)=>{const n="watcher:"+t;e.on("change",(r,{event:s})=>{o.info({message:`${b(N(".",r))} was ${s}d`,prefix:n})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:n})}),e.on("event",r=>{r.code==="END"&&o.success({message:"Rebuild "+t+" finished",prefix:n}),r.code==="ERROR"&&o.error({context:[r.error],message:"Rebuild "+t+" failed: "+r.error.message,prefix:n})})},"watchHandler"),ln=mt(async(e,t)=>{const o=await pt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get("rollup-watch");const n=de(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 a of r)s+=F(`
65
- └─ ${N(process.cwd(),a)}`);if(e.logger.info(s),xe(n,"bundle",e.logger),e.options.declaration){const a=await ut(e,t);await e.hooks.callHook("rollup:dts:options",e,a);const i=de(a);await e.hooks.callHook("rollup:watch",e,i),xe(i,"types",e.logger)}},"watch");var cn=Object.defineProperty,pn=d((e,t)=>cn(e,"name",{value:t,configurable:!0}),"i$1");const dt=pn(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var un=Object.defineProperty,mn=d((e,t)=>un(e,"name",{value:t,configurable:!0}),"a$2");let dn=class{static{d(this,"g")}static{mn(this,"FileCache")}#r;#e;#n;#t=!0;#o=new Map;constructor(t,o,n){this.#r=t,this.#e=Pt("visulima-packem",{cwd:t}),this.#n=o,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:J(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(!J(n))return;const r=Se(n),s=JSON.parse(r);return this.#o.set(n,s),s}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)),Ne(r,o,{overwrite:!0})}getFilePath(t,o){let n=t.replaceAll(ue(this.#r),"");return n=n.replaceAll(":","-"),v(this.#e,this.#n,o?.replaceAll(":","-")??"",ue(n))}};var fn=Object.defineProperty,U=d((e,t)=>fn(e,"name",{value:t,configurable:!0}),"l$1");const gn=ne,hn=U((e,t)=>{const{sideEffects:o}=t;let n;if(typeof o=="boolean")n=U(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)n=U(()=>!1,"hasSideEffects");else{const r=o.map(s=>s.includes("/")?s:`**/${s}`);n=gn(r,null,{resolve:e})}else n=U(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var yn=Object.defineProperty,vn=d((e,t)=>yn(e,"name",{value:t,configurable:!0}),"o");const bn=vn(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)!Y(e.options.externals,r)&&!r.startsWith("chunks/")&&!e.options.dependencies.includes(Q(r))&&!e.options.peerDependencies.includes(Q(r))&&n.add(r);o.size>0&&B(e,`Potential unused dependencies found: ${[...o].map(r=>b(r)).join(", ")}`),n.size>0&&B(e,`Potential implicit dependencies found: ${[...n].map(r=>b(r)).join(", ")}`)},"validateDependencies");var $n=Object.defineProperty,ft=d((e,t)=>$n(e,"name",{value:t,configurable:!0}),"i");const jn=ft((e,t)=>oo(e,t)<=e.length/3||t.includes(e),"isSimilar"),wn=ft((e,t)=>{const o=e.toLowerCase();return t.filter(n=>jn(n.toLowerCase(),o))},"findAlternatives");var kn=Object.defineProperty,Oe=d((e,t)=>kn(e,"name",{value:t,configurable:!0}),"n");const xn=Oe((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:"",...le(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("*")&&!re(r)&&n.push(r.replace(`${t.rootDir}/`,""));if(n.length>0){const r=Oe(i=>N(t.rootDir,h(t.options.outDir,i)),"rPath"),s=t.buildEntries.filter(i=>!i.chunk).map(i=>r(i.path));let a="Potential missing or wrong package.json files:";for(const i of n){const l=wn(i,s);a+=`
66
- - `+b(i)+(l.length>0?jt` (did you mean ${l.map(c=>`"${c}"`).join(", ")}?)`:"")}B(t,a)}},"validatePackage");var On=Object.defineProperty,j=d((e,t)=>On(e,"name",{value:t,configurable:!0}),"f");const Ee=j((e,t)=>{e.warnings.size>0&&(t&&e.logger.raw(`
63
+ ↳ to depend on a module via import/require, install it to "dependencies".`),process.exitCode=1,!0):e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0,"sharedOnWarn"),ke=new Map,lt=b((e,t,o)=>{const r=b(s=>{for(const[a,i]of Object.entries(t))if(s.startsWith(a))return s.replace(a,i)},"findAlias"),n=ot(e.tsconfig,!1);return{external(s){const a=r(s);a&&(s=a);const i=Y(s),c=K(e.options.externals,i)||K(e.options.externals,s);if(c)return!0;if(s.startsWith(".")||Pe(s)||/src[/\\]/.test(s)||e.pkg.name&&s.startsWith(e.pkg.name))return!1;if(n){for(const{find:l}of n)if(l.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${l.source}`,prefix:o}),!1}return!c&&!ke.has(s)&&e.logger.info({message:'Inlined implicit external "'+v(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),ke.set(s,!0),c},input:Object.fromEntries(e.options.entries.map(s=>[s.name,f(e.options.rootDir,s.input)])),onLog:b((s,a)=>{let i=a.message;switch(a.stack&&(i=`${i}
64
+ ${a.stack}`),s){case"info":{e.logger.info({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")});return}case"warn":{e.logger.warn({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")});return}case"debug":e.logger.debug({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")})}},"onLog"),onwarn(s,a){at(s,e)||s.code||a(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),ct=b(async(e,t)=>{const o=se(e,"build");let r;return e.options.rollup.resolve&&(r=k(Ie({extensions:R,...e.options.rollup.resolve}),t)),{...lt(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:b(n=>E(e,n,"cjs"),"chunkFileNames"),dir:f(e.options.rootDir,e.options.outDir),entryFileNames:b(n=>we(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:je(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:b(n=>E(e,n,"mjs"),"chunkFileNames"),dir:f(e.options.rootDir,e.options.outDir),entryFileNames:b(n=>we(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:je(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[k(Ge(),t),k(it(),t),e.tsconfig&&k(st(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&k(nt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Re({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Fe({customResolver:r?.resolveId,...e.options.rollup.alias,entries:o}),r,e.options.rollup.polyfillNode&&Vt({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Ue({...e.options.rollup.json}),fn(e.logger),no(e.options.entries.filter(n=>n.executable).map(n=>n.name).filter(Boolean)),e.options.rollup.wsam&&qt(e.options.rollup.wsam),e.options.transformer?.(Qn(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&&Ht(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&k(Ut({extensions:R,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&xn(e.pkg),e.options.rollup.raw&&vn(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&Zo({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&sn({outDir:f(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&qo(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&qe({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&&Gt({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"),Zn=b(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"),er=Bo(Zn),pt=b(async(e,t)=>{const o=se(e,"types"),r={load(i){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(i)?null:""},name:"packem:ignore-files"},n=e.tsconfig?.config.compilerOptions;delete n?.lib;let s;e.options.rollup.resolve&&(s=k(Ie({extensions:R,...e.options.rollup.resolve}),t));const a="dts-plugin:"+process.pid+e.tsconfig.path;return{...lt(e,o,"dts"),onwarn(i,c){at(i,e)||i.code!=="EMPTY_BUNDLE"&&c(i)},output:[e.options.emitCJS&&{chunkFileNames:b(i=>E(e,i,"d.cts"),"chunkFileNames"),dir:f(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},{chunkFileNames:b(i=>E(e,i,"d.mts"),"chunkFileNames"),dir:f(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:b(i=>E(e,i,"d.ts"),"chunkFileNames"),dir:f(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[k(Ge(),t),k(it(),t),e.options.rollup.json&&Ue({...e.options.rollup.json}),r,e.tsconfig&&k(st(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&k(nt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Re({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Fe({customResolver:s?.resolveId,...e.options.rollup.alias,entries:o}),s,await er(a)(e),e.options.cjsInterop&&e.options.emitCJS&&ze({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&Fn(e.options.rollup.patchTypes,e.logger),ro(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&qe({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 tr=Object.defineProperty,or=m((e,t)=>tr(e,"name",{value:t,configurable:!0}),"c$1");const nr=or(async(e,t)=>{const o=await ct(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 Ce(o);t.set(r,n.cache),await e.hooks.callHook("rollup:build",e,n);const s=o.output,a=new Map;for(const i of s){const{output:c}=await n.write(i),l=new Set,p=c.filter(u=>u.type==="chunk");for(const u of p){l.add(u.fileName);for(const g of u.imports)e.usedImports.add(g);u.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(u.code,"utf8"),chunks:u.imports.filter(g=>p.find(j=>j.fileName===g)),exports:u.exports,modules:Object.entries(u.modules).map(([g,j])=>({bytes:j.renderedLength,id:g})),path:u.fileName,type:"entry"})}const d=c.filter(u=>u.type==="asset");for(const u of d)a.has(u.fileName)||a.set(u.fileName,{bytes:Buffer.byteLength(u.source,"utf8"),path:u.fileName,type:"asset"});for(const u of l)e.usedImports.delete(u)}e.buildEntries.push(...a.values())},"build");var rr=Object.defineProperty,L=m((e,t)=>rr(e,"name",{value:t,configurable:!0}),"r$1");const sr=L(async(e,t)=>{const o=await pt(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 Ce(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:L(s=>E(e,s,"d.cts"),"chunkFileNames"),dir:f(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await n.write({chunkFileNames:L(s=>E(e,s,"d.mts"),"chunkFileNames"),dir:f(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await n.write({chunkFileNames:L(s=>E(e,s,"d.ts"),"chunkFileNames"),dir:f(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var ir=Object.defineProperty,ut=m((e,t)=>ir(e,"name",{value:t,configurable:!0}),"e");const xe=ut((e,t,o)=>{const r="watcher:"+t;e.on("change",(n,{event:s})=>{o.info({message:`${v(S(".",n))} was ${s}d`,prefix:r})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:r})}),e.on("event",n=>{n.code==="END"&&o.success({message:"Rebuild "+t+" finished",prefix:r}),n.code==="ERROR"&&o.error({context:[n.error],message:"Rebuild "+t+" failed: "+n.error.message,prefix:r})})},"watchHandler"),ar=ut(async(e,t)=>{const o=await ct(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get("rollup-watch");const r=me(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 a of n)s+=C(`
65
+ └─ ${S(process.cwd(),a)}`);if(e.logger.info(s),xe(r,"bundle",e.logger),e.options.declaration){const a=await pt(e,t);await e.hooks.callHook("rollup:dts:options",e,a);const i=me(a);await e.hooks.callHook("rollup:watch",e,i),xe(i,"types",e.logger)}},"watch");var lr=Object.defineProperty,cr=m((e,t)=>lr(e,"name",{value:t,configurable:!0}),"i$1");const dt=cr(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var pr=Object.defineProperty,ur=m((e,t)=>pr(e,"name",{value:t,configurable:!0}),"a$2");let dr=class{static{m(this,"g")}static{ur(this,"FileCache")}#n;#e;#r;#t=!0;#o=new Map;constructor(t,o,r){this.#n=t,this.#e=Nt("visulima-packem",{cwd:t}),this.#r=o,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:W(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(!W(r))return;const n=De(r),s=JSON.parse(n);return this.#o.set(r,s),s}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)),Se(n,o,{overwrite:!0})}getFilePath(t,o){let r=t.replaceAll(ue(this.#n),"");return r=r.replaceAll(":","-"),y(this.#e,this.#r,o?.replaceAll(":","-")??"",ue(r))}};var mr=Object.defineProperty,z=m((e,t)=>mr(e,"name",{value:t,configurable:!0}),"l$1");const fr=ne,gr=z((e,t)=>{const{sideEffects:o}=t;let r;if(typeof o=="boolean")r=z(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)r=z(()=>!1,"hasSideEffects");else{const n=o.map(s=>s.includes("/")?s:`**/${s}`);r=fr(n,null,{resolve:e})}else r=z(()=>null,"hasSideEffects");return r},"getPackageSideEffect");var hr=Object.defineProperty,yr=m((e,t)=>hr(e,"name",{value:t,configurable:!0}),"o");const vr=yr(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)!K(e.options.externals,n)&&!n.startsWith("chunks/")&&!e.options.dependencies.includes(Y(n))&&!e.options.peerDependencies.includes(Y(n))&&r.add(n);o.size>0&&J(e,`Potential unused dependencies found: ${[...o].map(n=>v(n)).join(", ")}`),r.size>0&&J(e,`Potential implicit dependencies found: ${[...r].map(n=>v(n)).join(", ")}`)},"validateDependencies");var br=Object.defineProperty,mt=m((e,t)=>br(e,"name",{value:t,configurable:!0}),"i");const $r=mt((e,t)=>to(e,t)<=e.length/3||t.includes(e),"isSimilar"),jr=mt((e,t)=>{const o=e.toLowerCase();return t.filter(r=>$r(r.toLowerCase(),o))},"findAlternatives");var wr=Object.defineProperty,Oe=m((e,t)=>wr(e,"name",{value:t,configurable:!0}),"n");const kr=Oe((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:"",...ae(e.exports,e.type??"commonjs",t.options.declaration).map(n=>n.file)].map(n=>n&&f(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("*")&&!oe(n)&&r.push(n.replace(`${t.rootDir}/`,""));if(r.length>0){const n=Oe(i=>S(t.rootDir,f(t.options.outDir,i)),"rPath"),s=t.buildEntries.filter(i=>!i.chunk).map(i=>n(i.path));let a="Potential missing or wrong package.json files:";for(const i of r){const c=jr(i,s);a+=`
66
+ - `+v(i)+(c.length>0?$t` (did you mean ${c.map(l=>`"${l}"`).join(", ")}?)`:"")}J(t,a)}},"validatePackage");var xr=Object.defineProperty,$=m((e,t)=>xr(e,"name",{value:t,configurable:!0}),"m");const ft=$((e,t)=>{e.warnings.size>0&&(t&&e.logger.raw(`
67
67
  `),e.logger.warn(`Build is done with some warnings:
68
68
 
69
69
  ${[...e.warnings].map(o=>`- ${o}`).join(`
70
- `)}`),e.options.failOnWarn&&(e.logger.error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`."),I(1)))},"logErrors"),En=j(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"),Dn=j((e,t,o,n,r,s,a,i)=>{const l=En(i?.config.compilerOptions?.jsx),c=At(r,n,s,{alias:{},clean:!0,declaration:!0,dependencies:[],devDependencies:[],emitCJS:!0,emitESM:!0,entries:[],externals:[...pe.builtinModules,...pe.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,fileCache:!0,minify:W.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:i?.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:l,jsxDev:i?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:i?.config.compilerOptions?.jsxFactory,jsxFragment:i?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:i?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minifyWhitespace:W.NODE_ENV==="production",sourcesContent:!1,target:i?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:i?.config},json:{preferConst:!0},license:{dependenciesTemplate:j((u,p,m)=>`
70
+ `)}`),e.options.failOnWarn&&(e.logger.error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`."),F(1)))},"logErrors"),Or=$(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"),Er=$((e,t,o,r,n,s,a,i)=>{const c=Or(i?.config.compilerOptions?.jsx),l=Tt(n,r,s,{alias:{},clean:!0,declaration:!0,dependencies:[],devDependencies:[],emitCJS:!0,emitESM:!0,entries:[],externals:[...pe.builtinModules,...pe.builtinModules.map(p=>`node:${p}`)],failOnWarn:!0,fileCache:!0,minify:A.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:i?.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:i?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:i?.config.compilerOptions?.jsxFactory,jsxFragment:i?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:i?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minifyWhitespace:A.NODE_ENV==="production",sourcesContent:!1,target:i?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:i?.config},json:{preferConst:!0},license:{dependenciesTemplate:$((p,d,u)=>`
71
71
  # Licenses of bundled dependencies
72
- The published ${m} artifact additionally contains code with the following licenses:
73
- ${u.join(", ")}
72
+ The published ${u} artifact additionally contains code with the following licenses:
73
+ ${p.join(", ")}
74
74
 
75
75
  # Bundled dependencies:
76
- `+p,"dependenciesTemplate"),dtsTemplate:j((u,p,m)=>`
76
+ `+d,"dependenciesTemplate"),dtsTemplate:$((p,d,u)=>`
77
77
  # Licenses of bundled types
78
- The published ${m} artifact additionally contains code with the following licenses:
79
- ${u.join(", ")}
78
+ The published ${u} artifact additionally contains code with the following licenses:
79
+ ${p.join(", ")}
80
80
 
81
81
  # Bundled types:
82
- `+p,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:me,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:i?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:W.NODE_ENV==="production",...i?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(i.config.compilerOptions.jsx)?{jsxFragmentPragma:i.config.compilerOptions.jsxFragmentFactory,jsxImportSource:i.config.compilerOptions.jsxImportSource,jsxPragma:i.config.compilerOptions.jsxFactory,jsxRuntime:l,transforms:["typescript","jsx",...i.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...i?.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:i?.config.compilerOptions?.experimentalDecorators,syntax:i?"typescript":"ecmascript",[i?"tsx":"jsx"]:!0},target:i?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:i?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:i?.config.compilerOptions?.experimentalDecorators,react:{development:W.NODE_ENV!=="production",pragma:i?.config.compilerOptions?.jsxFactory,pragmaFrag:i?.config.compilerOptions?.jsxFragmentFactory,runtime:l,throwIfNamespace:!0},treatConstEnumAsEnum:i?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:i?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:hn(t,a),preset:"recommended"},watch:{clearScreen:!0,exclude:me}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!c.transformerName){const u=new Set([...Object.keys(a.dependencies??{}),...Object.keys(a.devDependencies??{})]);if(u.has("esbuild"))c.transformerName="esbuild";else if(u.has("@swc/core"))c.transformerName="swc";else if(u.has("sucrase"))c.transformerName="sucrase";else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info('Using "'+b(c.transformerName)+'" as transformer.')}return c.rollup.resolve&&c.rollup.resolve.preferBuiltins===!0&&(c.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),i?.config.compilerOptions?.isolatedModules||e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
82
+ `+d,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:de,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:i?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:A.NODE_ENV==="production",...i?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(i.config.compilerOptions.jsx)?{jsxFragmentPragma:i.config.compilerOptions.jsxFragmentFactory,jsxImportSource:i.config.compilerOptions.jsxImportSource,jsxPragma:i.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...i.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...i?.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:i?.config.compilerOptions?.experimentalDecorators,syntax:i?"typescript":"ecmascript",[i?"tsx":"jsx"]:!0},target:i?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:i?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:i?.config.compilerOptions?.experimentalDecorators,react:{development:A.NODE_ENV!=="production",pragma:i?.config.compilerOptions?.jsxFactory,pragmaFrag:i?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:i?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:i?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:gr(t,a),preset:"recommended"},watch:{clearScreen:!0,exclude:de}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!l.transformerName){const p=new Set([...Object.keys(a.dependencies??{}),...Object.keys(a.devDependencies??{})]);if(p.has("esbuild"))l.transformerName="esbuild";else if(p.has("@swc/core"))l.transformerName="swc";else if(p.has("sucrase"))l.transformerName="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(l.transformerName)+'" as transformer.')}return l.rollup.resolve&&l.rollup.resolve.preferBuiltins===!0&&(l.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),i?.config.compilerOptions?.isolatedModules||e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
83
83
  Because none of the third-party transpilers, 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.
84
- 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.`),c.dependencies=Object.keys(a.dependencies??{}),c.peerDependencies=Object.keys(a.peerDependencies??{}),c.devDependencies=Object.keys(a.devDependencies??{}),c.optionalDependencies=Object.keys(a.optionalDependencies??{}),c.externals.push(...c.dependencies,...c.peerDependencies,...c.optionalDependencies),c},"generateOptions"),Sn=j(e=>e.replace(/\.(?:js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension"),Nn=j(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=_e(o.input)?N(t,o.input):ee(o.input);n.startsWith("./")&&(n=n.slice(2)),o.name=Sn(n.replace(/^src\//,""))}if(!o.input)throw new Error(`Missing entry input: ${dt(o)}`);if(o.input=h(e.options.rootDir,o.input),!J(o.input)){const n=new Set(await vt(oe(o.input)));let r=!1;for(const s of T)if(n.has(H(o.input)+s)){r=!0;break}if(!r)throw new St("Your configured entry: "+b(o.input)+" does not exist.")}o.outDir=h(e.options.rootDir,o.outDir??e.options.outDir)}},"prepareEntries"),Pn=j((e,t,o)=>{const n=j(s=>N(t.rootDir,h(t.options.outDir,s)),"rPath");let r=!1;for(const s of t.buildEntries.filter(a=>!a.chunk)){let a=s.bytes??0;for(const l of s.chunks??[])a+=t.buildEntries.find(c=>c.path===l)?.bytes??0;let i=` ${E(n(s.path))} (${["total size: "+b(M(a)),s.type!=="asset"&&s.bytes&&"chunk size: "+b(M(s.bytes))].filter(Boolean).join(", ")})`;if(i+=s.exports?.length?`
85
- exports: `+F(s.exports.join(", ")):"",s.chunks?.length&&(i+=`
86
- ${s.chunks.map(l=>{const c=t.buildEntries.find(u=>u.path===l)??{};return F(" └─ "+n(l)+E(c.bytes?" ("+M(c?.bytes)+")":""))}).join(`
87
- `)}`),s.modules&&s.modules.length>0){const l=s.modules.filter(c=>c.id.includes("node_modules")).sort((c,u)=>(u.bytes||0)-(c.bytes||0)).map(c=>F(" 📦 "+n(c.id)+E(c.bytes?" ("+M(c.bytes)+")":""))).join(`
88
- `);i+=l.length>0?`
84
+ 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.`),l.dependencies=Object.keys(a.dependencies??{}),l.peerDependencies=Object.keys(a.peerDependencies??{}),l.devDependencies=Object.keys(a.devDependencies??{}),l.optionalDependencies=Object.keys(a.optionalDependencies??{}),l.externals.push(...l.dependencies,...l.peerDependencies,...l.optionalDependencies),l},"generateOptions"),Dr=$(e=>e.replace(/\.(?:js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension"),Sr=$(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=Pe(o.input)?S(t,o.input):Z(o.input);r.startsWith("./")&&(r=r.slice(2)),o.name=Dr(r.replace(/^src\//,""))}if(!o.input)throw new Error(`Missing entry input: ${dt(o)}`);if(o.input=f(e.options.rootDir,o.input),!W(o.input)){const r=new Set(await yt(te(o.input)));let n=!1;for(const s of R)if(r.has(U(o.input)+s)){n=!0;break}if(!n)throw new Dt("Your configured entry: "+v(o.input)+" does not exist.")}o.outDir=f(e.options.rootDir,o.outDir??e.options.outDir)}},"prepareEntries"),Nr=$((e,t,o)=>{const r=$(s=>S(t.rootDir,f(t.options.outDir,s)),"rPath");let n=!1;for(const s of t.buildEntries.filter(a=>!a.chunk)){let a=s.bytes??0;for(const c of s.chunks??[])a+=t.buildEntries.find(l=>l.path===c)?.bytes??0;let i=` ${O(r(s.path))} (${["total size: "+v(_(a)),s.type!=="asset"&&s.bytes&&"chunk size: "+v(_(s.bytes))].filter(Boolean).join(", ")})`;if(i+=s.exports?.length?`
85
+ exports: `+C(s.exports.join(", ")):"",s.chunks?.length&&(i+=`
86
+ ${s.chunks.map(c=>{const l=t.buildEntries.find(p=>p.path===c)??{};return C(" └─ "+r(c)+O(l.bytes?" ("+_(l?.bytes)+")":""))}).join(`
87
+ `)}`),s.modules&&s.modules.length>0){const c=s.modules.filter(l=>l.id.includes("node_modules")).sort((l,p)=>(p.bytes||0)-(l.bytes||0)).map(l=>C(" 📦 "+r(l.id)+O(l.bytes?" ("+_(l.bytes)+")":""))).join(`
88
+ `);i+=c.length>0?`
89
89
  inlined modules:
90
- `+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 u=t.buildEntries.find(p=>p.path.endsWith(l));if(u){let p;(t.options.declaration===!0||t.options.declaration==="compatible")&&!l.includes(".d.ts")&&(l=l.replace(c==="commonjs"?".d.c":".d.m",".d."),p=t.buildEntries.find(m=>m.path.endsWith(l))),i+=p&&c===o.type?`
90
+ `+c:""}if(t.options.declaration&&s.type==="entry"){let c=s.path.replace(/\.js$/,".d.ts"),l="commonjs";s.path.endsWith(".cjs")?c=s.path.replace(/\.cjs$/,".d.cts"):s.path.endsWith(".mjs")&&(l="module",c=s.path.replace(/\.mjs$/,".d.mts"));const p=t.buildEntries.find(d=>d.path.endsWith(c));if(p){let d;(t.options.declaration===!0||t.options.declaration==="compatible")&&!c.includes(".d.ts")&&(c=c.replace(l==="commonjs"?".d.c":".d.m",".d."),d=t.buildEntries.find(u=>u.path.endsWith(c))),i+=d&&l===o.type?`
91
91
  types:
92
- `+[u,p].map(m=>F(" └─ ")+E(n(m.path))+" (total size: "+b(M(m.bytes??0))+")").join(`
92
+ `+[p,d].map(u=>C(" └─ ")+O(r(u.path))+" (total size: "+v(_(u.bytes??0))+")").join(`
93
93
  `):`
94
- types: `+E(n(u.path))+" (total size: "+b(M(u.bytes??0))+")"}}r=!0,i+=`
94
+ types: `+O(r(p.path))+" (total size: "+v(_(p.bytes??0))+")"}}n=!0,i+=`
95
95
 
96
- `,e.raw(s.chunk?F(i):i)}return r&&e.raw("Σ Total dist size (byte size):",b(M(t.buildEntries.reduce((s,a)=>s+(a.bytes??0),0))),`
97
- `),r},"showSizeInformation"),_n=j(async(e,t,o,n,r,s,a,i,l)=>{const c=Co(r.preset??n.preset??"auto",t),u=Dn(e,t,o,n,r,c,s,a);Ot(v(u.rootDir,u.outDir));const p={buildEntries:[],dependencyGraphMap:new Map,hooks:Wt(),logger:e,mode:o,options:u,pkg:s,rootDir:t,tsconfig:a,usedImports:new Set,warnings:new Set};if(c.hooks&&p.hooks.addHooks(c.hooks),n.hooks&&p.hooks.addHooks(n.hooks),r.hooks&&p.hooks.addHooks(r.hooks),i.isEnabled=p.options.fileCache,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");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."),await Nn(p,t),await p.hooks.callHook("build:before",p);let m="Building";if(o==="watch"?m="Watching":o==="jit"&&(m="Stubbing"),p.logger.info(b(`${m} ${p.options.name}`)),p.logger.debug(`${E("Root dir:")} ${p.options.rootDir}
98
- ${E("Entries:")}
99
- ${p.options.entries.map(f=>` ${dt(f)}`).join(`
100
- `)}`),p.options.clean)for(const f of new Set(p.options.entries.map(y=>y.outDir).filter(Boolean).sort()))f===p.options.rootDir||p.options.rootDir.startsWith(f.endsWith("/")?f:`${f}/`)||l.some(y=>f.startsWith(y))||(l.push(f),p.logger.info(`Cleaning dist directory: \`./${N(p.options.rootDir,f)}\``),await Pe(f));if(p.options.stub){await yo(p),await p.hooks.callHook("build:done",p);return}if(o==="watch"){await ln(p,i),Ee(p,!1);return}await Promise.all([rn(p,i),p.options.declaration&&sn(p,i)]),p.logger.success(wt(`Build succeeded for ${p.options.name}`));for await(const f of Et(v(p.options.rootDir,p.options.outDir))){let y=p.buildEntries.find(k=>v(p.options.rootDir,p.options.outDir,k.path)===f.path);if(y||(y={chunk:!0,path:f.path},p.buildEntries.push(y)),!y.bytes){const k=await De(h(p.options.rootDir,p.options.outDir,f.path));y.bytes=k.size}}const g=Pn(p.logger,p,s);bn(p),xn(s,p),await p.hooks.callHook("build:done",p),Ee(p,g)},"build"),vs=j(async(e,t,o={})=>{const{configPath:n,debug:r,tsconfigPath:s,...a}=o,i=[new It,new Rt];r&&i.push(new Tt);const l=Ft({logLevel:r?"debug":"informational",processors:i,scope:"packem"});e=h($t(),e),l.debug("Root directory:",e);const c=v(e,"package.json"),u=Ct(c);l.debug("Using package.json found at",c);let p;if(s){const m=v(e,s);await Dt(m)||(l.error("tsconfig.json not found at",m),I(1)),p={config:_t(m),path:m},l.info("Using tsconfig settings at",m)}else try{p=await Mt(e),l.debug("Using tsconfig settings found at",p.path)}catch{l.info("No tsconfig.json or jsconfig.json found.")}try{const m=n??"./packem.config.ts";/\.(?:js|mjs|cjs|ts)$/.test(m)||(l.error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed."),I(1));const g=We(m,e);l.debug("Using packem config found at",v(e,m));const f=(Array.isArray(g)?g:[g]).filter(Boolean),y=Date.now(),k=j(()=>Nt(Math.floor(Date.now()-y)),"getDuration"),P=[],_=[],x=C(u.version+JSON.stringify({...u.dependencies,...u.devDependencies,eNode:u.engines?.node})),O=new dn(e,x,l);O.cachePath&&!J(v(O.cachePath,x))&&J(O.cachePath)&&(l.info("Clearing file cache because the cache key has changed."),await Pe(O.cachePath));for(const gt of f)_.push(_n(l,e,t,a,gt,u,p,O,P));await Promise.all(_),l.raw(`
101
- ⚡️ Build`+(_.length>1?"s":"")+" run in "+k()),l.restoreAll(),I(0)}catch(m){l.error("An error occurred while building",m),I(1)}},"createBundler");export{vs as default};
96
+ `,e.raw(s.chunk?C(i):i)}return n&&e.raw("Σ Total dist size (byte size):",v(_(t.buildEntries.reduce((s,a)=>s+(a.bytes??0),0))),`
97
+ `),n},"showSizeInformation"),Pr=$(async(e,t,o,r,n,s,a)=>{const i=Mo(n.preset??r.preset??"auto",t),c=Er(e,t,o,r,n,i,s,a);xt(y(c.rootDir,c.outDir));const l={buildEntries:[],dependencyGraphMap:new Map,hooks:At(),logger:e,mode:o,options:c,pkg:s,rootDir:t,tsconfig:a,usedImports:new Set,warnings:new Set};if(i.hooks&&l.hooks.addHooks(i.hooks),r.hooks&&l.hooks.addHooks(r.hooks),n.hooks&&l.hooks.addHooks(n.hooks),await l.hooks.callHook("build:prepare",l),!l.options.emitESM&&!l.options.emitCJS)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(l.options.declaration&&a===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");return l.options.emitESM===void 0&&l.logger.info("Emitting ESM bundles, is disabled."),l.options.emitCJS===void 0&&l.logger.info("Emitting CJS bundles, is disabled."),l.options.declaration||l.logger.info("Declaration files, are disabled."),l},"createContext"),_r=$(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||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(r=>o.startsWith(r))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${S(e.options.rootDir,o)}\``),await Ne(o))},"cleanDistributionDirectories"),Mr=$(async(e,t,o)=>{await e.hooks.callHook("build:before",e),await Promise.all([nr(e,o),e.options.declaration&&sr(e,o)]),e.logger.success(jt(`Build succeeded for ${e.options.name}`));for await(const n of Ot(y(e.options.rootDir,e.options.outDir))){let s=e.buildEntries.find(a=>y(e.options.rootDir,e.options.outDir,a.path)===n.path);if(s||(s={chunk:!0,path:n.path},e.buildEntries.push(s)),!s.bytes){const a=await Ee(f(e.options.rootDir,e.options.outDir,n.path));s.bytes=a.size}}const r=Nr(e.logger,e,t);vr(e),kr(t,e),await e.hooks.callHook("build:done",e),ft(e,r)},"build"),bs=$(async(e,t,o={})=>{const{configPath:r,debug:n,tsconfigPath:s,...a}=o,i=[new Ft,new It];n&&i.push(new Rt);const c=Ct({logLevel:n?"debug":"informational",processors:i,scope:"packem"});e=f(bt(),e),c.debug("Root directory:",e);const l=y(e,"package.json"),p=Mt(l);c.debug("Using package.json found at",l);let d;if(s){const u=y(e,s);await Et(u)||(c.error("tsconfig.json not found at",u),F(1)),d={config:Pt(u),path:u},c.info("Using tsconfig settings at",u)}else try{d=await _t(e),c.debug("Using tsconfig settings found at",d.path)}catch{c.info("No tsconfig.json or jsconfig.json found.")}try{const u=r??"./packem.config.ts";/\.(?:js|mjs|cjs|ts)$/.test(u)||(c.error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed."),F(1));const g=Ae(u,e);c.debug("Using packem config found at",y(e,u));const j=Date.now(),x=$(()=>St(Math.floor(Date.now()-j)),"getDuration"),N=M(p.version+JSON.stringify({...p.dependencies,...p.devDependencies,eNode:p.engines?.node})),w=new dr(e,N,c);w.cachePath&&!W(y(w.cachePath,N))&&W(w.cachePath)&&(c.info("Clearing file cache because the cache key has changed."),await Ne(w.cachePath));const h=await Pr(c,e,t,a,g,p,d);if(w.isEnabled=h.options.fileCache,await Sr(h,e),h.logger.info(v((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+h.options.name)),h.logger.debug(`${O("Root dir:")} ${h.options.rootDir}
98
+ ${O("Entries:")}
99
+ ${h.options.entries.map(P=>` ${dt(P)}`).join(`
100
+ `)}`),await _r(h),h.options.stub){await ho(h),await h.hooks.callHook("build:done",h);return}if(t==="watch"){await ar(h,w),ft(h,!1);return}await Mr(h,p,w),c.raw(`
101
+ ⚡️ Build run in `+x()),c.restoreAll(),F(0)}catch(u){c.error("An error occurred while building",u),F(1)}},"createBundler");export{bs as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/packem",
3
- "version": "1.0.0-alpha.35",
3
+ "version": "1.0.0-alpha.36",
4
4
  "description": "A fast and modern bundler for Node.js and TypeScript.",
5
5
  "keywords": [
6
6
  "anolilab",