@visulima/packem 1.2.2 → 1.3.0

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/dist/packem.mjs CHANGED
@@ -1,114 +1,114 @@
1
- var Xt=Object.defineProperty;var m=(e,t)=>Xt(e,"name",{value:t,configurable:!0});import{readdirSync as Ye,existsSync as Xe}from"node:fs";import{stat as Qe,chmod as Qt,rm as Zt}from"node:fs/promises";import Ee from"node:module";import{env as eo,versions as to,cwd as oo}from"node:process";import{cyan as k,bold as N,gray as M,green as no,yellow as ro,grey as io}from"@visulima/colorize";import{findCacheDirSync as so}from"@visulima/find-cache-dir";import{readFile as Ze,readFileSync as be,writeFileSync as B,writeJsonSync as et,readJsonSync as tt,walk as ao,isAccessibleSync as C,collectSync as lo,isAccessible as ot,ensureDirSync as co,emptyDir as po}from"@visulima/fs";import{formatBytes as _,duration as Se}from"@visulima/humanizer";import{normalize as nt,join as w,relative as D,dirname as L,basename as ae,toNamespacedPath as ee,resolve as $,extname as rt,isAbsolute as it}from"@visulima/path";import{readTsConfig as uo,findTsConfig as mo}from"@visulima/tsconfig";import{defu as fo}from"defu";import{createHooks as go}from"hookable";import{createJiti as st}from"jiti";import{rollup as at,watch as Oe,VERSION as ho}from"rollup";import lt from"@rollup/plugin-alias";import yo from"@rollup/plugin-commonjs";import vo from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as ct}from"@rollup/plugin-node-resolve";import pt from"@rollup/plugin-replace";import{wasm as bo}from"@rollup/plugin-wasm";import wo from"rollup-plugin-polyfill-node";import{visualizer as $o}from"rollup-plugin-visualizer";import{minVersion as ut,valid as jo,coerce as ko}from"semver";import{E as R,D as we,C as xo,S as Eo,R as dt,a as te,P as K,b as De,c as J,A as U}from"./packem_shared/constants-CWqse9ko.mjs";import oe from"node:assert/strict";import{extractAssignedNames as So,createFilter as W,normalizePath as Ne}from"@rollup/pluginutils";import I from"magic-string";import Oo from"glob-parent";import{glob as Do,isDynamicPattern as Pe,globSync as No}from"tinyglobby";import{findStaticImports as mt,fileURLToPath as Po,resolveModuleExportNames as Co,resolvePath as Ce}from"mlly";import{parseAsync as _o}from"oxc-parser";import Mo from"@rollup/plugin-json";import To from"rollup-plugin-license";import{g as Ao,d as Io}from"./packem_shared/create-or-update-key-storage-BxGi6kMH.mjs";import{createHash as Ro}from"node:crypto";import{fileURLToPath as Fo}from"node:url";import{parse as Jo}from"@babel/parser";import{parsePackageJson as Bo}from"@visulima/package/package-json";import{NotFoundError as Lo}from"@visulima/fs/error";import{isRelative as Wo}from"@visulima/path/utils";import{distance as Uo}from"fastest-levenshtein";import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
1
+ var io=Object.defineProperty;var f=(e,t)=>io(e,"name",{value:t,configurable:!0});import{readdirSync as rt,existsSync as nt}from"node:fs";import{stat as it,chmod as so,rm as ao}from"node:fs/promises";import Ce from"node:module";import me,{env as lo,versions as co}from"node:process";import{cyan as x,bold as C,gray as M,green as po,yellow as uo,grey as fo}from"@visulima/colorize";import{findCacheDirSync as mo}from"@visulima/find-cache-dir";import{readFile as st,readFileSync as ke,writeFileSync as L,writeJsonSync as at,readJsonSync as lt,walk as go,isAccessibleSync as T,collectSync as ho,isAccessible as ct,ensureDirSync as yo,emptyDir as vo}from"@visulima/fs";import{formatBytes as I,duration as _e}from"@visulima/humanizer";import{normalize as pt,join as w,relative as N,dirname as K,basename as le,toNamespacedPath as te,resolve as $,extname as ut,isAbsolute as dt}from"@visulima/path";import{readTsConfig as bo,findTsConfig as wo}from"@visulima/tsconfig";import{defu as $o}from"defu";import{createHooks as jo}from"hookable";import{createJiti as ft}from"jiti";import{rollup as mt,watch as Te,VERSION as ko}from"rollup";import{exec as xo}from"tinyexec";import gt from"@rollup/plugin-alias";import Eo from"@rollup/plugin-commonjs";import So from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as ht}from"@rollup/plugin-node-resolve";import yt from"@rollup/plugin-replace";import{wasm as Oo}from"@rollup/plugin-wasm";import Do from"rollup-plugin-polyfill-node";import{visualizer as No}from"rollup-plugin-visualizer";import{minVersion as vt,valid as Po,coerce as Co}from"semver";import{E as J,D as xe,C as _o,S as To,R as bt,a as oe,P as H,b as Ie,c as W,A as z}from"./packem_shared/constants-CWqse9ko.mjs";import re from"node:assert/strict";import{extractAssignedNames as Io,createFilter as U,normalizePath as Me}from"@rollup/pluginutils";import F from"magic-string";import Mo from"glob-parent";import{glob as Ao,isDynamicPattern as Ae,globSync as Ro}from"tinyglobby";import{findStaticImports as wt,fileURLToPath as Fo,resolveModuleExportNames as Jo,resolvePath as Re}from"mlly";import{parseAsync as Bo}from"oxc-parser";import Wo from"@rollup/plugin-json";import Lo from"rollup-plugin-license";import{g as Ko,d as Uo}from"./packem_shared/create-or-update-key-storage-BxGi6kMH.mjs";import{createHash as zo}from"node:crypto";import{fileURLToPath as Vo}from"node:url";import{parse as Ho}from"@babel/parser";import qo from"child_process";import{parsePackageJson as Go}from"@visulima/package/package-json";import{NotFoundError as Xo}from"@visulima/fs/error";import{isRelative as Yo}from"@visulima/path/utils";import{distance as Qo}from"fastest-levenshtein";import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
2
2
  import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
3
3
  import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
4
4
  const __filename = __cjs_url__.fileURLToPath(import.meta.url);
5
5
  const __dirname = __cjs_path__.dirname(__filename);
6
6
  const require = __cjs_mod__.createRequire(import.meta.url);
7
- var zo=Object.defineProperty,Ko=m((e,t)=>zo(e,"name",{value:t,configurable:!0}),"a$g");const he=Ko((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var Vo=Object.defineProperty,Ho=m((e,t)=>Vo(e,"name",{value:t,configurable:!0}),"a$f");const V=Ho(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var qo=Object.defineProperty,Go=m((e,t)=>qo(e,"name",{value:t,configurable:!0}),"a$e");const ft=Go((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var Yo=Object.defineProperty,gt=m((e,t)=>Yo(e,"name",{value:t,configurable:!0}),"s$e");const Xo=gt((e,t,o)=>{const n=o??new Map;return(...r)=>{const s=t?typeof t=="function"?t(...r):t:JSON.stringify({args:r}),i=n.get(s);if(i!==void 0)return i;const a=e(...r);return n.set(s,a),a}},"memoize"),Qo=gt(e=>{const t=new Map;return o=>Xo(e,o,t)},"memoizeByKey");var Zo=Object.defineProperty,H=m((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"r$d");const en=H(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;oe(t,"Expected class/function to have a name"),yield t.name;break}case"VariableDeclaration":{for(const t of e.declaration.declarations)for(const o of So(t.id))yield o;break}}},"exportName"),tn=H(function*(e){if(e.declaration)for(const t of en(e))yield{exportedName:t,from:"self",type:"named"};else if(e.source)yield{bindings:e.specifiers.map(t=>({exportedName:t.exported.name,importedName:t.local.name})),from:"other",source:e.source.value,type:"named"};else for(const t of e.specifiers)yield{exportedName:t.exported.name,from:"self",type:"named"}},"parseExportNamed"),on=H(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),nn=H(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),rn=H(function*(e,t){oe(t.code!=null,`Module ${t.id} doesn't have associated code`);const o=e.parse(t.code);for(const n of o.body)switch(n.type){case"ExportAllDeclaration":{yield*on(n);break}case"ExportDefaultDeclaration":{yield*nn();break}case"ExportNamedDeclaration":{yield*tn(n);break}}},"parseExports");var sn=Object.defineProperty,q=m((e,t)=>sn(e,"name",{value:t,configurable:!0}),"n$b");const ht=q(async function(e,t,o){const n=await e.resolve(t,o.id);if(oe(n,`Rollup can't resolve ${t} from ${o.id}`),n.external)return null;const r=await e.load(n);return oe(r,`Rollup doesn't have a module for id ${n.id}`),r},"getImportedModule"),an=q(async function*(e,t,o){const n=await ht(e,t.source,o);n&&(yield*$e(e,n))},"gatherBarrelReExports"),ln=q(async function*(e,t,o){const n=await ht(e,t.source,o);if(!n)return;const r=new Map(t.bindings.map(s=>[s.importedName,s]));for await(const s of $e(e,n)){const i=r.get(s.exportedName);i&&(yield{...s,exportedName:i.exportedName})}},"gatherNamedReExports"),cn=q(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),$e=q(async function*(e,t){for(const o of rn(e,t))o.from==="self"?yield*cn(t,o):o.type==="barrel"?yield*an(e,o,t):yield*ln(e,o,t)},"gatherExports");var pn=Object.defineProperty,un=m((e,t)=>pn(e,"name",{value:t,configurable:!0}),"r$c");const dn=un(()=>({moduleParsed:{async handler(e){if(e.isEntry)for await(const t of $e(this,e))t.id!==e.id&&this.emitFile({id:t.id,name:t.exportedName,preserveSignature:"exports-only",type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");var mn=Object.defineProperty,fn=m((e,t)=>mn(e,"name",{value:t,configurable:!0}),"r$b");const gn=fn((e,t)=>{const o=e,n=[];let r;for(;(r=o.exec(t))!==null;)r.index===o.lastIndex&&o.lastIndex++,r.forEach(s=>{n.push(s)});return n.filter(Boolean)},"getRegexMatches");var hn=Object.defineProperty,yn=m((e,t)=>hn(e,"name",{value:t,configurable:!0}),"a$d");const yt=yn(e=>{const t=gn(/export\s(\{\s(.*)\s\}|default\s.*);/g,e);if(t.length===0)return null;const o=t.at(-1).split(", ");let n="";for(const r of o)if(!r.includes("type")&&(r.includes("default ")&&(n=r.split("default ")[1]),r.includes("as"))){const[s,i]=r.split(" as ");i==="default"&&(n=s)}if(n!==""){const r=new I(e);return r.replace(new RegExp(`(,s)?${n} as default(,)?`),""),r.replace(new RegExp(`export default ${n};
8
- ?`),""),r.append(`
7
+ var Zo=Object.defineProperty,er=f((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"a$h");const we=er((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var tr=Object.defineProperty,or=f((e,t)=>tr(e,"name",{value:t,configurable:!0}),"a$g");const q=or(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var rr=Object.defineProperty,nr=f((e,t)=>rr(e,"name",{value:t,configurable:!0}),"a$f");const $t=nr((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var ir=Object.defineProperty,jt=f((e,t)=>ir(e,"name",{value:t,configurable:!0}),"s$e");const sr=jt((e,t,o)=>{const r=o??new Map;return(...n)=>{const s=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),i=r.get(s);if(i!==void 0)return i;const a=e(...n);return r.set(s,a),a}},"memoize"),ar=jt(e=>{const t=new Map;return o=>sr(e,o,t)},"memoizeByKey");var lr=Object.defineProperty,G=f((e,t)=>lr(e,"name",{value:t,configurable:!0}),"r$d");const cr=G(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;re(t,"Expected class/function to have a name"),yield t.name;break}case"VariableDeclaration":{for(const t of e.declaration.declarations)for(const o of Io(t.id))yield o;break}}},"exportName"),pr=G(function*(e){if(e.declaration)for(const t of cr(e))yield{exportedName:t,from:"self",type:"named"};else if(e.source)yield{bindings:e.specifiers.map(t=>({exportedName:t.exported.name,importedName:t.local.name})),from:"other",source:e.source.value,type:"named"};else for(const t of e.specifiers)yield{exportedName:t.exported.name,from:"self",type:"named"}},"parseExportNamed"),ur=G(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),dr=G(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),fr=G(function*(e,t){re(t.code!=null,`Module ${t.id} doesn't have associated code`);const o=e.parse(t.code);for(const r of o.body)switch(r.type){case"ExportAllDeclaration":{yield*ur(r);break}case"ExportDefaultDeclaration":{yield*dr();break}case"ExportNamedDeclaration":{yield*pr(r);break}}},"parseExports");var mr=Object.defineProperty,X=f((e,t)=>mr(e,"name",{value:t,configurable:!0}),"n$b");const kt=X(async function(e,t,o){const r=await e.resolve(t,o.id);if(re(r,`Rollup can't resolve ${t} from ${o.id}`),r.external)return null;const n=await e.load(r);return re(n,`Rollup doesn't have a module for id ${r.id}`),n},"getImportedModule"),gr=X(async function*(e,t,o){const r=await kt(e,t.source,o);r&&(yield*Ee(e,r))},"gatherBarrelReExports"),hr=X(async function*(e,t,o){const r=await kt(e,t.source,o);if(!r)return;const n=new Map(t.bindings.map(s=>[s.importedName,s]));for await(const s of Ee(e,r)){const i=n.get(s.exportedName);i&&(yield{...s,exportedName:i.exportedName})}},"gatherNamedReExports"),yr=X(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),Ee=X(async function*(e,t){for(const o of fr(e,t))o.from==="self"?yield*yr(t,o):o.type==="barrel"?yield*gr(e,o,t):yield*hr(e,o,t)},"gatherExports");var vr=Object.defineProperty,br=f((e,t)=>vr(e,"name",{value:t,configurable:!0}),"r$c");const wr=br(()=>({moduleParsed:{async handler(e){if(e.isEntry)for await(const t of Ee(this,e))t.id!==e.id&&this.emitFile({id:t.id,name:t.exportedName,preserveSignature:"exports-only",type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");var $r=Object.defineProperty,jr=f((e,t)=>$r(e,"name",{value:t,configurable:!0}),"r$b");const kr=jr((e,t)=>{const o=e,r=[];let n;for(;(n=o.exec(t))!==null;)n.index===o.lastIndex&&o.lastIndex++,n.forEach(s=>{r.push(s)});return r.filter(Boolean)},"getRegexMatches");var xr=Object.defineProperty,Er=f((e,t)=>xr(e,"name",{value:t,configurable:!0}),"a$e");const xt=Er(e=>{const t=kr(/export\s(\{\s(.*)\s\}|default\s.*);/g,e);if(t.length===0)return null;const o=t.at(-1).split(", ");let r="";for(const n of o)if(!n.includes("type")&&(n.includes("default ")&&(r=n.split("default ")[1]),n.includes("as"))){const[s,i]=n.split(" as ");i==="default"&&(r=s)}if(r!==""){const n=new F(e);return n.replace(new RegExp(`(,s)?${r} as default(,)?`),""),n.replace(new RegExp(`export default ${r};
8
+ ?`),""),n.append(`
9
9
 
10
- export = `+n+";"),{code:r.toString().replace(/export\s\{\s\s\};/,""),map:r.generateMap({hires:!0})}}return null},"patchCjsDefaultExport");var vn=Object.defineProperty,_e=m((e,t)=>vn(e,"name",{value:t,configurable:!0}),"i$9");const vt=_e(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk:_e(async(n,r,s)=>{if(r.type!=="chunk"||!r.isEntry)return null;if(s.format==="cjs"&&s.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(i===null||i.length<3)return null;const a=new I(n);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
11
- module.exports.default = `+i[2]+";");let l=a.toString();return l=l.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:l,map:a.generateMap({hires:!0})}}return s.format==="es"&&/\.d\.(?:ts|cts)$/.test(r.fileName)?o!=="commonjs"&&r.fileName.endsWith(".d.mts")?null:yt(n):null},"renderChunk")}),"cjsInteropPlugin");var bn=Object.defineProperty,wn=m((e,t)=>bn(e,"name",{value:t,configurable:!0}),"f$a");const $n=wn((e,t)=>{const o=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:r}=n;return Array.isArray(r)?r=r.map(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof r=="string"&&(r=[{src:r}]),{async buildStart(){const s=await Promise.all(r.flatMap(i=>Array.isArray(i.src)?i.src.map(a=>({...i,src:a})):i).map(async i=>await Do(V(i.src),{ignore:V(i.exclude).filter(Boolean)}).then(a=>({dest:i.dest??"",parent:Oo(i.src),src:a}))));for(const i of s)for(const a of i.src){let l;o.has(a)?l=o.get(a):(l={copied:[],dest:[],timestamp:0},o.set(a,l));const c=n.flatten?nt(i.dest):w(i.dest,D(i.parent,L(a)));l.dest.includes(c)||l.dest.push(c),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,a])=>{let l;try{const c=await Qe(i);if(!c.isFile())return;const u=c.mtime.getTime();u>a.timestamp&&(a.timestamp=u,a.copied=[]),l=await Ze(i,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const c of a.dest){if(n.copyOnce&&a.copied.includes(c))continue;const u=ae(i),p=w(c,u);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:p,source:l,type:"asset"}),t.debug({message:`copied ${i} → ${p}`,prefix:"plugin:copy"}),a.copied.push(c)}catch(d){t.error({context:[d],message:`error copying file ${i} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var jn=Object.defineProperty,le=m((e,t)=>jn(e,"name",{value:t,configurable:!0}),"t$9");const kn=/\Wrequire(?:\.resolve)?\(/,xn=le((e,t)=>{if(eo.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return null;let o=!1,n=!1,r=!1;if(e.includes("__filename")&&(o=!0),e.includes("__dirname")&&(n=!0),kn.test(e)&&(r=!0),!o&&!n&&!r)return null;const s=mt(e).pop(),i=s?s.end:0,a=new I(e);return a.appendRight(i,t(o,n,r)),{code:a.toString(),map:a.generateMap()}},"CJSToESM"),En=le((e,t,o)=>{let n="";return(e||t)&&(n+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
12
- `),t&&(n+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
13
- `),o&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
14
- `),(e||t)&&(n+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url);
15
- `),t&&(n+=`const __dirname = __cjs_path__.dirname(__filename);
16
- `),o&&(n+=`const require = __cjs_mod__.createRequire(import.meta.url);
17
- `),n},"generateCJSShim"),Sn=le((e,t,o)=>{let n="";return o&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
18
- `),e&&(n+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
19
- `),t&&(n+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
20
- `),o&&(n+=`const require = __cjs_mod__.createRequire(import.meta.url);
21
- `),n},"generateCJSShimNode20_11"),On=le((e,t)=>{const o=W(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(n,r,s){if(s.format==="es"&&o(r.fileName)){let i=En;if(e.engines?.node){const a=ut(e.engines.node);a&&a.major>=20&&a.minor>=11&&(i=Sn)}return xn(n,i)}return null}}},"esmShimCjsSyntaxPlugin");var Dn=Object.defineProperty,Nn=m((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"m$9");const Pn=Nn(()=>({name:"packem:fix-dynamic-import-extension",renderChunk(e,t,o){return o.format==="es"||o.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(o.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var Cn=Object.defineProperty,_n=m((e,t)=>Cn(e,"name",{value:t,configurable:!0}),"a$c");const Mn=_n((e,t)=>{const o=e.replace(/^\.\//,""),n=t.replace(/^\.\//,"");if(n.startsWith(o))return e+n.slice(o.length);if(e.endsWith(t))return e;const r=e.split("/"),s=t.split("/");let i=r.length-1,a=s.length-1;for(;i>=0&&a>=0&&r[i]===s[a];)i--,a--;const l=r.slice(0,i).join("/"),c=s.slice(a).join("/");return l+(c?"/"+c:"")},"extendString");var Tn=Object.defineProperty,An=m((e,t)=>Tn(e,"name",{value:t,configurable:!0}),"s$b");const In=An((...e)=>{if(e.length===0)return"";if(e.length===1)return L(e[0]);e=e.map(r=>ee(r));const[t,...o]=e;let n=t.split("/");for(const r of o){const s=r.split("/",n.length);let i=0;for(const a of s)if(a===n[i])i+=1;else{n=n.slice(0,i);break}n=n.slice(0,i)}return n.length<=1&&n[0]===""?`/${n[0]}`:n.join("/")},"lowestCommonAncestor");var Rn=Object.defineProperty,de=m((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"m$7");const Fn=de((e,t,o,n,r={})=>{const s=W(r.include,r.exclude),i={},a=de((c,u)=>{i[c.replace(R,"")]=u},"addOutput");async function l(c,u){if(!s(u))return;let p;try{const f=await _o(c,{sourceFilename:u});p=JSON.parse(f.program)}catch{}if(p){const f=p.body.filter(y=>y.type==="ImportDeclaration"||y.type==="ExportAllDeclaration"||y.type==="ExportNamedDeclaration");for(const y of f){if(!y.source||ae(y.source.value).includes("."))continue;const b=await this.resolve(y.source.value,u);if(!(!b||b.external)&&(b.id.endsWith(".ts")||b.id.endsWith(".cts")||b.id.endsWith(".mts")||b.id.endsWith(".tsx")||b.id.endsWith(".ctsx")||b.id.endsWith(".mtsx"))){const x=b.id.replace(e+"/","");c=c.replaceAll('from "'+y.source.value+'"','from "'+Mn(y.source.value,x)+'"')}}}const{errors:d,sourceText:g}=await t(u,c);if(d.length>0){if(r.ignoreErrors){this.warn(d[0]);return}return this.error(d[0])}if(a(u,g),!p)return;const h=p.body.filter(f=>f.type==="ImportDeclaration"?f.importKind==="type"?!0:f.specifiers?.every(y=>y.type==="ImportSpecifier"&&y.importKind==="type"):f.type==="ExportNamedDeclaration"||f.type==="ExportAllDeclaration"?f.exportKind==="type"?!0:f.type==="ExportNamedDeclaration"&&f.specifiers?.every(y=>y.type==="ExportSpecifier"&&y.exportKind==="type"):!1);for await(const f of h){if(!f.source)continue;const y=await this.resolve(f.source.value,u);if(!y)return;const b=y.id;if(s(b)&&!i[b.replace(R,"")])try{const x=await Ze(b);await l.call(this,x,b)}catch{}}}return m(l,"h"),de(l,"transform"),{name:"packem:isolated-declarations",async renderStart(c,{input:u}){const p=In(...Array.isArray(u)?u:Object.values(u));typeof c.entryFileNames=="function"&&(c.entryFileNames=c.entryFileNames({name:c.name}));const d=c.entryFileNames.replace(/\.(.)?[jt]sx?$/,(g,h)=>`.d.${h||""}ts`);for await(let[g,h]of Object.entries(i)){if(n&&c.format==="cjs"){const y=yt(h);y!==null&&(h=y.code)}const f=h.includes("from '")?"'":'"';(o===!0||o==="compatible")&&c.format==="cjs"&&this.emitFile({fileName:d.replace("[name]",D(p,g)).replace(".cts",".ts"),source:h.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(y,b,x,v)=>b+f+(v||x)+".d.ts"+f+";"),type:"asset"}),this.emitFile({fileName:d.replace("[name]",D(p,g)),source:h.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(y,b,x,v)=>b+f+(v||x)+(c.format==="cjs"?".d.cts":".d.mts")+f+";"),type:"asset"})}},transform:l}},"isolatedDeclarationsPlugin");var Jn=Object.defineProperty,Bn=m((e,t)=>Jn(e,"name",{value:t,configurable:!0}),"n$9");const Me="export default ",bt=Bn(e=>{const t=Mo(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(Me)&&(r.code=r.code.replace(Me,"module.exports = ")),r}}},"JSONPlugin");class Ln{static{m(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(t=>this.replacement=t,"replace")}}replace(t,o,n,r){t&&o&&(n!=null?t[o][n]=r:t[o]=r)}remove(t,o,n){t&&o&&(n!=null?t[o].splice(n,1):delete t[o])}}class Wn extends Ln{static{m(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(n=>this.replacement=n,"replace")},this.enter=t,this.leave=o}visit(t,o,n,r){if(t){if(this.enter){const i=this.should_skip,a=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const c=this.should_skip,u=this.should_remove;if(this.should_skip=i,this.should_remove=a,this.replacement=l,c)return t;if(u)return null}let s;for(s in t){const i=t[s];if(i&&typeof i=="object")if(Array.isArray(i)){const a=i;for(let l=0;l<a.length;l+=1){const c=a[l];Te(c)&&(this.visit(c,t,s,l)||l--)}}else Te(i)&&this.visit(i,t,s,null)}if(this.leave){const i=this.replacement,a=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const l=this.should_remove;if(this.replacement=i,this.should_remove=a,l)return null}}return t}}function Te(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(Te,"isNode");function wt(e,{enter:t,leave:o}){return new Wn(t,o).visit(e,null)}m(wt,"walk");var Un=Object.defineProperty,zn=m((e,t)=>Un(e,"name",{value:t,configurable:!0}),"u$8");const Kn=zn(({attributes:e,logger:t})=>{const o=W([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(n,r){if(!o(r))return null;let s=null;try{s=this.parse(n,{allowReturnOutsideFunction:!0})}catch(l){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${r}" and remove the jsx attribute.`}),t.warn(l),null}let i=!1;const a=new I(n);return wt(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)&&(a.overwrite(p.start-2,p.end,""),i=!0)}}}),i?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Vn=Object.defineProperty,$t=m((e,t)=>Vn(e,"name",{value:t,configurable:!0}),"d$a");const Hn=$t(e=>{const t=[],o=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):o.push(n)}),[...o.sort(),...t.sort()]},"sortLicenses"),jt=$t(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:n,marker:r,mode:s,packageName:i})=>To({thirdParty(a){const l=new Set,c=a.sort(({name:p},{name:d})=>(p||0)>(d||0)?1:(d||0)>(p||0)?-1:0).map(({author:p,contributors:d,license:g,licenseText:h,maintainers:f,name:y,repository:b})=>{let x="## "+y+`
22
- `;g&&(x+=`License: ${g}
23
- `);const v=new Set;for(const P of[p,...f,...d]){const G=typeof P=="string"?P:P?.name;G&&v.add(G)}return v.size>0&&(x+=`By: ${[...v].join(", ")}
24
- `),b&&(x+=`Repository: ${typeof b=="string"?b:b.url}
25
- `),h&&(x+=`
10
+ export = `+r+";"),{code:n.toString().replace(/export\s\{\s\s\};/,""),map:n.generateMap({hires:!0})}}return null},"patchCjsDefaultExport");var Sr=Object.defineProperty,Fe=f((e,t)=>Sr(e,"name",{value:t,configurable:!0}),"i$9");const Et=Fe(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk:Fe(async(r,n,s)=>{if(n.type!=="chunk"||!n.isEntry)return null;if(s.format==="cjs"&&s.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(i===null||i.length<3)return null;const a=new F(r);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
11
+ module.exports.default = `+i[2]+";");let l=a.toString();return l=l.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:l,map:a.generateMap({hires:!0})}}return s.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)?o!=="commonjs"&&n.fileName.endsWith(".d.mts")?null:xt(r):null},"renderChunk")}),"cjsInteropPlugin");var Or=Object.defineProperty,Dr=f((e,t)=>Or(e,"name",{value:t,configurable:!0}),"f$b");const Nr=Dr((e,t)=>{const o=new Map,r={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:n}=r;return Array.isArray(n)?n=n.map(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof n=="string"&&(n=[{src:n}]),{async buildStart(){const s=await Promise.all(n.flatMap(i=>Array.isArray(i.src)?i.src.map(a=>({...i,src:a})):i).map(async i=>await Ao(q(i.src),{ignore:q(i.exclude).filter(Boolean)}).then(a=>({dest:i.dest??"",parent:Mo(i.src),src:a}))));for(const i of s)for(const a of i.src){let l;o.has(a)?l=o.get(a):(l={copied:[],dest:[],timestamp:0},o.set(a,l));const c=r.flatten?pt(i.dest):w(i.dest,N(i.parent,K(a)));l.dest.includes(c)||l.dest.push(c),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,a])=>{let l;try{const c=await it(i);if(!c.isFile())return;const p=c.mtime.getTime();p>a.timestamp&&(a.timestamp=p,a.copied=[]),l=await st(i,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const c of a.dest){if(r.copyOnce&&a.copied.includes(c))continue;const p=le(i),u=w(c,p);try{this.emitFile({[r.exactFileNames?"fileName":"name"]:u,source:l,type:"asset"}),t.debug({message:`copied ${i} → ${u}`,prefix:"plugin:copy"}),a.copied.push(c)}catch(d){t.error({context:[d],message:`error copying file ${i} → ${u}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Pr=Object.defineProperty,ce=f((e,t)=>Pr(e,"name",{value:t,configurable:!0}),"t$9");const Cr=/\Wrequire(?:\.resolve)?\(/,_r=ce((e,t)=>{if(lo.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return null;let o=!1,r=!1,n=!1;if(e.includes("__filename")&&(o=!0),e.includes("__dirname")&&(r=!0),Cr.test(e)&&(n=!0),!o&&!r&&!n)return null;const s=wt(e).pop(),i=s?s.end:0,a=new F(e);return a.appendRight(i,t(o,r,n)),{code:a.toString(),map:a.generateMap()}},"CJSToESM"),Tr=ce((e,t,o)=>{let r="";return(e||t)&&(r+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
12
+ `),t&&(r+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
13
+ `),o&&(r+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
14
+ `),(e||t)&&(r+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url);
15
+ `),t&&(r+=`const __dirname = __cjs_path__.dirname(__filename);
16
+ `),o&&(r+=`const require = __cjs_mod__.createRequire(import.meta.url);
17
+ `),r},"generateCJSShim"),Ir=ce((e,t,o)=>{let r="";return o&&(r+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
18
+ `),e&&(r+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
19
+ `),t&&(r+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
20
+ `),o&&(r+=`const require = __cjs_mod__.createRequire(import.meta.url);
21
+ `),r},"generateCJSShimNode20_11"),Mr=ce((e,t)=>{const o=U(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(r,n,s){if(s.format==="es"&&o(n.fileName)){let i=Tr;if(e.engines?.node){const a=vt(e.engines.node);a&&a.major>=20&&a.minor>=11&&(i=Ir)}return _r(r,i)}return null}}},"esmShimCjsSyntaxPlugin");var Ar=Object.defineProperty,Rr=f((e,t)=>Ar(e,"name",{value:t,configurable:!0}),"m$a");const Fr=Rr(()=>({name:"packem:fix-dynamic-import-extension",renderChunk(e,t,o){return o.format==="es"||o.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(o.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var Jr=Object.defineProperty,Br=f((e,t)=>Jr(e,"name",{value:t,configurable:!0}),"a$d");const Wr=Br((e,t)=>{const o=e.replace(/^\.\//,""),r=t.replace(/^\.\//,"");if(r.startsWith(o))return e+r.slice(o.length);if(e.endsWith(t))return e;const n=e.split("/"),s=t.split("/");let i=n.length-1,a=s.length-1;for(;i>=0&&a>=0&&n[i]===s[a];)i--,a--;const l=n.slice(0,i).join("/"),c=s.slice(a).join("/");return l+(c?"/"+c:"")},"extendString");var Lr=Object.defineProperty,Kr=f((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"s$b");const Ur=Kr((...e)=>{if(e.length===0)return"";if(e.length===1)return K(e[0]);e=e.map(n=>te(n));const[t,...o]=e;let r=t.split("/");for(const n of o){const s=n.split("/",r.length);let i=0;for(const a of s)if(a===r[i])i+=1;else{r=r.slice(0,i);break}r=r.slice(0,i)}return r.length<=1&&r[0]===""?`/${r[0]}`:r.join("/")},"lowestCommonAncestor");var zr=Object.defineProperty,ge=f((e,t)=>zr(e,"name",{value:t,configurable:!0}),"m$8");const Vr=ge((e,t,o,r,n={})=>{const s=U(n.include,n.exclude),i={},a=ge((c,p)=>{i[c.replace(J,"")]=p},"addOutput");async function l(c,p){if(!s(p))return;let u;try{const m=await Bo(c,{sourceFilename:p});u=JSON.parse(m.program)}catch{}if(u){const m=u.body.filter(y=>y.type==="ImportDeclaration"||y.type==="ExportAllDeclaration"||y.type==="ExportNamedDeclaration");for(const y of m){if(!y.source||le(y.source.value).includes("."))continue;const b=await this.resolve(y.source.value,p);if(!(!b||b.external)&&(b.id.endsWith(".ts")||b.id.endsWith(".cts")||b.id.endsWith(".mts")||b.id.endsWith(".tsx")||b.id.endsWith(".ctsx")||b.id.endsWith(".mtsx"))){const k=b.id.replace(e+"/","");c=c.replaceAll('from "'+y.source.value+'"','from "'+Wr(y.source.value,k)+'"')}}}const{errors:d,sourceText:g}=await t(p,c);if(d.length>0){if(n.ignoreErrors){this.warn(d[0]);return}return this.error(d[0])}if(a(p,g),!u)return;const h=u.body.filter(m=>m.type==="ImportDeclaration"?m.importKind==="type"?!0:m.specifiers?.every(y=>y.type==="ImportSpecifier"&&y.importKind==="type"):m.type==="ExportNamedDeclaration"||m.type==="ExportAllDeclaration"?m.exportKind==="type"?!0:m.type==="ExportNamedDeclaration"&&m.specifiers?.every(y=>y.type==="ExportSpecifier"&&y.exportKind==="type"):!1);for await(const m of h){if(!m.source)continue;const y=await this.resolve(m.source.value,p);if(!y)return;const b=y.id;if(s(b)&&!i[b.replace(J,"")])try{const k=await st(b);await l.call(this,k,b)}catch{}}}return f(l,"h"),ge(l,"transform"),{name:"packem:isolated-declarations",async renderStart(c,{input:p}){const u=Ur(...Array.isArray(p)?p:Object.values(p));typeof c.entryFileNames=="function"&&(c.entryFileNames=c.entryFileNames({name:c.name}));const d=c.entryFileNames.replace(/\.(.)?[jt]sx?$/,(g,h)=>`.d.${h||""}ts`);for await(let[g,h]of Object.entries(i)){if(r&&c.format==="cjs"){const y=xt(h);y!==null&&(h=y.code)}const m=h.includes("from '")?"'":'"';(o===!0||o==="compatible")&&c.format==="cjs"&&this.emitFile({fileName:d.replace("[name]",N(u,g)).replace(".cts",".ts"),source:h.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(y,b,k,E)=>b+m+(E||k)+".d.ts"+m+";"),type:"asset"}),this.emitFile({fileName:d.replace("[name]",N(u,g)),source:h.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(y,b,k,E)=>b+m+(E||k)+(c.format==="cjs"?".d.cts":".d.mts")+m+";"),type:"asset"})}},transform:l}},"isolatedDeclarationsPlugin");var Hr=Object.defineProperty,qr=f((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"n$9");const Je="export default ",St=qr(e=>{const t=Wo(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(Je)&&(n.code=n.code.replace(Je,"module.exports = ")),n}}},"JSONPlugin");class Gr{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 Xr extends Gr{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 i=this.should_skip,a=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,r,n),this.replacement&&(t=this.replacement,this.replace(o,r,n,t)),this.should_remove&&this.remove(o,r,n);const c=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=a,this.replacement=l,c)return t;if(p)return null}let s;for(s in t){const i=t[s];if(i&&typeof i=="object")if(Array.isArray(i)){const a=i;for(let l=0;l<a.length;l+=1){const c=a[l];Be(c)&&(this.visit(c,t,s,l)||l--)}}else Be(i)&&this.visit(i,t,s,null)}if(this.leave){const i=this.replacement,a=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,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=i,this.should_remove=a,l)return null}}return t}}function Be(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}f(Be,"isNode");function Ot(e,{enter:t,leave:o}){return new Xr(t,o).visit(e,null)}f(Ot,"walk");var Yr=Object.defineProperty,Qr=f((e,t)=>Yr(e,"name",{value:t,configurable:!0}),"u$9");const Zr=Qr(({attributes:e,logger:t})=>{const o=U([/\.[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 i=!1;const a=new F(r);return Ot(s,{enter(l){if(l.type==="CallExpression"&&l.callee.type==="Identifier"&&l.callee.name==="jsx"){const c=l.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of c)for(const u of p.properties)u.type==="Property"&&u.key.type==="Literal"&&u.value.type==="Literal"&&e.includes(u.key.value)&&(a.overwrite(u.start-2,u.end,""),i=!0)}}}),i?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var en=Object.defineProperty,Dt=f((e,t)=>en(e,"name",{value:t,configurable:!0}),"d$a");const tn=Dt(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),Nt=Dt(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:r,marker:n,mode:s,packageName:i})=>Lo({thirdParty(a){const l=new Set,c=a.sort(({name:u},{name:d})=>(u||0)>(d||0)?1:(d||0)>(u||0)?-1:0).map(({author:u,contributors:d,license:g,licenseText:h,maintainers:m,name:y,repository:b})=>{let k="## "+y+`
22
+ `;g&&(k+=`License: ${g}
23
+ `);const E=new Set;for(const P of[u,...m,...d]){const v=typeof P=="string"?P:P?.name;v&&E.add(v)}return E.size>0&&(k+=`By: ${[...E].join(", ")}
24
+ `),b&&(k+=`Repository: ${typeof b=="string"?b:b.url}
25
+ `),h&&(k+=`
26
26
  `+h.trim().replaceAll(/\r\n|\r/g,`
27
- `).replaceAll(`<!-- ${r} -->`,"").replaceAll(e?`<!-- ${e} -->`:"","").replaceAll(`<!-- /${r} -->`,"").replaceAll(e?`<!-- /${e} -->`:"","").trim().split(`
27
+ `).replaceAll(`<!-- ${n} -->`,"").replaceAll(e?`<!-- ${e} -->`:"","").replaceAll(`<!-- /${n} -->`,"").replaceAll(e?`<!-- /${e} -->`:"","").trim().split(`
28
28
  `).map(P=>P?`> ${P}`:">").join(`
29
29
  `)+`
30
- `),g&&l.add(g),x}).join(`
30
+ `),g&&l.add(g),k}).join(`
31
31
  ---------------------------------------
32
32
 
33
- `);if(c===""){n.info({message:"No dependencies license information found.",prefix:"plugin:license:"+s});return}const u=o(Hn(l),c,i);try{const p=be(t),d=Ao(p,r,u);if(!d){n.error({message:`Could not find the license marker: <!-- ${r} --><!-- /${r} --> in ${t}`,prefix:"plugin:license:"+s});return}p!==d&&(B(t,d),n.info({message:`${t} updated.`,prefix:"plugin:license:"+s}))}catch(p){n.error(p)}}}),"license");var qn=Object.defineProperty,Gn=m((e,t)=>qn(e,"name",{value:t,configurable:!0}),"i$7");const Yn=Gn(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=$(e.rootDir,e.outDir,"graph.json");et(o,t)},name:"packem:metafile"}),"metafilePlugin");var Xn=Object.defineProperty,Qn=m((e,t)=>Xn(e,"name",{value:t,configurable:!0}),"g$5");let Ae=!1;const Zn=Qn((e,t,o,n,r,s)=>{if(s!=="*"&&jo(ko(s))===null)throw new Error("Invalid typeScriptVersion option. It must be a valid semver range.");return{name:"packem:node10-compatibility",writeBundle(){Ae||(e.info({message:"Declaration node10 compatibility mode is enabled.",prefix:"plugin:node10-compatibility"}),Ae=!0);const i={};for(const c of t)for(const u of c.exportKey)u.includes("/*")?i[u]=["./"+w(o,L(c.name),"*.d.ts")]:i[u]=[...i[u]??[],"./"+w(o,c.name+".d.ts")];const a=w(n,"package.json"),l=tt(a);r==="file"&&Object.keys(i).length>0?(et(a,{...l,typesVersions:{...l.typesVersions,[s]:i}},{detectIndent:!0}),e.info({message:'Your package.json "typesVersions" field has been updated.',prefix:"plugin:node10-compatibility"})):Object.keys(i).length>0&&e.info({message:`Please add the following field into your package.json to enable node 10 compatibility:
33
+ `);if(c===""){r.info({message:"No dependencies license information found.",prefix:"plugin:license:"+s});return}const p=o(tn(l),c,i);try{const u=ke(t),d=Ko(u,n,p);if(!d){r.error({message:`Could not find the license marker: <!-- ${n} --><!-- /${n} --> in ${t}`,prefix:"plugin:license:"+s});return}u!==d&&(L(t,d),r.info({message:`${t} updated.`,prefix:"plugin:license:"+s}))}catch(u){r.error(u)}}}),"license");var on=Object.defineProperty,rn=f((e,t)=>on(e,"name",{value:t,configurable:!0}),"i$7");const nn=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=$(e.rootDir,e.outDir,"graph.json");at(o,t)},name:"packem:metafile"}),"metafilePlugin");var sn=Object.defineProperty,an=f((e,t)=>sn(e,"name",{value:t,configurable:!0}),"g$5");let We=!1;const ln=an((e,t,o,r,n,s)=>{if(s!=="*"&&Po(Co(s))===null)throw new Error("Invalid typeScriptVersion option. It must be a valid semver range.");return{name:"packem:node10-compatibility",writeBundle(){We||(e.info({message:"Declaration node10 compatibility mode is enabled.",prefix:"plugin:node10-compatibility"}),We=!0);const i={};for(const c of t)for(const p of c.exportKey)p.includes("/*")?i[p]=["./"+w(o,K(c.name),"*.d.ts")]:i[p]=[...i[p]??[],"./"+w(o,c.name+".d.ts")];const a=w(r,"package.json"),l=lt(a);n==="file"&&Object.keys(i).length>0?(at(a,{...l,typesVersions:{...l.typesVersions,[s]:i}},{detectIndent:!0}),e.info({message:'Your package.json "typesVersions" field has been updated.',prefix:"plugin:node10-compatibility"})):Object.keys(i).length>0&&e.info({message:`Please add the following field into your package.json to enable node 10 compatibility:
34
34
 
35
35
  ${JSON.stringify({typesVersions:{"*":i}},null,4)}
36
- `,prefix:"plugin:node10-compatibility"})}}},"node10CompatibilityPlugin");var er=Object.defineProperty,tr=m((e,t)=>er(e,"name",{value:t,configurable:!0}),"r$9");const T=tr(e=>{const t=Ro("md5");return t.update(e),t.digest("hex")},"getHash");var or=Object.defineProperty,kt=m((e,t)=>or(e,"name",{value:t,configurable:!0}),"d$9");const z=kt(e=>e.handler||e,"getHandler"),E=kt((e,t,o="")=>({...e,async buildEnd(n){e.buildEnd&&await z(e.buildEnd).call(this,n)},async buildStart(n){e.buildStart&&await z(e.buildStart).call(this,n)},async load(n){if(!e.load)return null;const r=w(o,e.name),s=w("load",T(n));if(t.has(s,r))return await t.get(s,r);const i=await z(e.load).call(this,n);return t.set(s,i,r),i},name:`cached(${e.name})`,async resolveId(n,r,s){if(!e.resolveId)return null;const i=w(o,e.name),a=w("resolveId",T(n),r?T(r):"",T(JSON.stringify(s)));if(t.has(a,i))return await t.get(a,i);const l=await z(e.resolveId).call(this,n,r,s);return t.set(a,l,i),l},async transform(n,r){if(!e.transform)return null;const s=w(o,e.name),i=w("transform",T(r),T(n));if(t.has(i,s))return await t.get(i,s);const a=await z(e.transform).call(this,n,r);return t.set(i,a,s),a}}),"cachingPlugin");var nr=Object.defineProperty,rr=m((e,t)=>nr(e,"name",{value:t,configurable:!0}),"n$8");const ir=rr(()=>({name:"packem:prepend-directive",transform:{handler(e,t){const o=this.getModuleInfo(t);if(o?.meta.preserveDirectives){const n=o.meta.preserveDirectives.directives[0];if(n)return`'${n.value}';
37
- `+e}return null},order:"post"}}),"prependDirectivePlugin");var sr=Object.defineProperty,ar=m((e,t)=>sr(e,"name",{value:t,configurable:!0}),"c$8");const lr=ar(({directiveRegex:e,exclude:t=[],include:o=[],logger:n})=>{const r={},s={},i=W(o,t);return{name:"packem:preserve-directives",onLog(a,l){return l.code==="MODULE_LEVEL_DIRECTIVE"&&a==="warn"?!1:null},renderChunk:{handler(a,l,{sourcemap:c}){const u=l.moduleIds.map(g=>r[g]?r[g]:null).reduce((g,h)=>(h&&h.forEach(f=>{g.add(f)}),g),new Set),p=new I(a);u.size>0&&(n.debug({message:`directives for chunk "${l.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),p.prepend(`${[...u].map(g=>`'${g}';`).join(`
36
+ `,prefix:"plugin:node10-compatibility"})}}},"node10CompatibilityPlugin");var cn=Object.defineProperty,pn=f((e,t)=>cn(e,"name",{value:t,configurable:!0}),"r$9");const A=pn(e=>{const t=zo("md5");return t.update(e),t.digest("hex")},"getHash");var un=Object.defineProperty,Pt=f((e,t)=>un(e,"name",{value:t,configurable:!0}),"d$9");const V=Pt(e=>e.handler||e,"getHandler"),S=Pt((e,t,o="")=>({...e,async buildEnd(r){e.buildEnd&&await V(e.buildEnd).call(this,r)},async buildStart(r){e.buildStart&&await V(e.buildStart).call(this,r)},async load(r){if(!e.load)return null;const n=w(o,e.name),s=w("load",A(r));if(t.has(s,n))return await t.get(s,n);const i=await V(e.load).call(this,r);return t.set(s,i,n),i},name:`cached(${e.name})`,async resolveId(r,n,s){if(!e.resolveId)return null;const i=w(o,e.name),a=w("resolveId",A(r),n?A(n):"",A(JSON.stringify(s)));if(t.has(a,i))return await t.get(a,i);const l=await V(e.resolveId).call(this,r,n,s);return t.set(a,l,i),l},async transform(r,n){if(!e.transform)return null;const s=w(o,e.name),i=w("transform",A(n),A(r));if(t.has(i,s))return await t.get(i,s);const a=await V(e.transform).call(this,r,n);return t.set(i,a,s),a}}),"cachingPlugin");var dn=Object.defineProperty,fn=f((e,t)=>dn(e,"name",{value:t,configurable:!0}),"n$8");const mn=fn(()=>({name:"packem:prepend-directive",transform:{handler(e,t){const o=this.getModuleInfo(t);if(o?.meta.preserveDirectives){const r=o.meta.preserveDirectives.directives[0];if(r)return`'${r.value}';
37
+ `+e}return null},order:"post"}}),"prependDirectivePlugin");var gn=Object.defineProperty,hn=f((e,t)=>gn(e,"name",{value:t,configurable:!0}),"c$9");const yn=hn(({directiveRegex:e,exclude:t=[],include:o=[],logger:r})=>{const n={},s={},i=U(o,t);return{name:"packem:preserve-directives",onLog(a,l){return l.code==="MODULE_LEVEL_DIRECTIVE"&&a==="warn"?!1:null},renderChunk:{handler(a,l,{sourcemap:c}){const p=l.moduleIds.map(g=>n[g]?n[g]:null).reduce((g,h)=>(h&&h.forEach(m=>{g.add(m)}),g),new Set),u=new F(a);p.size>0&&(r.debug({message:`directives for chunk "${l.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),u.prepend(`${[...p].map(g=>`'${g}';`).join(`
38
38
  `)}
39
- `));let d;return l.facadeModuleId&&typeof s[l.facadeModuleId]=="string"&&(d=s[l.facadeModuleId]),d&&(n.debug({message:`shebang for chunk "${l.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),p.prepend(`${d}
40
- `)),u.size===0&&d===void 0?null:{code:p.toString(),map:c?p.generateMap({hires:!0}):null}},order:"post"},transform(a,l){if(!i(l))return null;let c=!1;const u=new I(a);if(a.startsWith("#")&&a[1]==="!"){let d=0;for(let g=2,h=a.length;g<h;g++){const f=a.codePointAt(g);if(f===10||f===13||f===8232||f===8233){d=g;break}}d&&(s[l]=a.slice(0,d),u.remove(0,d+1),c=!0,n.debug({message:`shebang for module "${l}" is preserved.`,prefix:"plugin:preserve-directives"}))}let p=null;try{p=this.parse(u.toString(),{allowReturnOutsideFunction:!0})}catch(d){return this.warn({code:"PARSE_ERROR",message:`failed to parse "${l}" and extract the directives.`}),n.warn(d),null}if(p.type!=="Program")return null;for(const d of p.body.filter(Boolean)){if(d.type!=="ExpressionStatement")break;let g=null;"directive"in d?g=d.directive:d.expression.type==="Literal"&&typeof d.expression.value=="string"&&e.test(d.expression.value)&&(g=d.expression.value),g!=="use strict"&&g&&(r[l]||=new Set,r[l].add(g),"start"in d&&typeof d.start=="number"&&"end"in d&&typeof d.end=="number"&&(u.remove(d.start,d.end),c=!0),n.debug({message:`directive "${g}" for module "${l}" is preserved.`,prefix:"plugin:preserve-directives"}))}return c?{code:u.toString(),map:u.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...r[l]??[]],shebang:s[l]??null}}}:null}}},"preserveDirectives");var cr=Object.defineProperty,pr=m((e,t)=>cr(e,"name",{value:t,configurable:!0}),"n$7");const ur=pr(e=>{const t=W(e.include,e.exclude);return{async load(o){return o.includes("?raw")?await this.load({id:o.replace(/\?raw$/,"")}):null},name:"packem:raw",transform(o,n){return!t(n)&&!n.includes("?raw")?null:(n.includes("?raw")||(o=`export default ${JSON.stringify(o)}`),{code:o,map:{mappings:""}})}}},"rawPlugin");var dr=Object.defineProperty,mr=m((e,t)=>dr(e,"name",{value:t,configurable:!0}),"r$8");const xt=mr(()=>({name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return Fo(e)}}),"resolveFileUrl");var fr=Object.defineProperty,ce=m((e,t)=>fr(e,"name",{value:t,configurable:!0}),"i$5");const ne=/^#![^\n]*/,ye=ce(async e=>{await Qt(e,493).catch(()=>{})},"makeExecutable"),gr=ce((e,t)=>({name:"packem:shebang",renderChunk:{handler(o,n,r){if(!n.isEntry||!n.facadeModuleId)return null;const s=o.startsWith("#")&&o[1]==="!";if(s&&t.replace)return o.replace(ne,t.shebang+`
41
- `);if(s)return null;if(e.includes(n.name)){const i=new I(o);return i.prepend(t.shebang+`
42
- `),{code:i.toString(),map:r.sourcemap?i.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"&&ne.test(s.code)&&o.dir){const i=$(o.dir,r);await ye(i)}}}),"shebangPlugin"),hr=ce(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ne,"")}}),"removeShebangPlugin"),yr=ce((e,t=`
43
- `)=>{const o=ne.exec(e);return o?o+t:""},"getShebang");var vr=Object.defineProperty,F=m((e,t)=>vr(e,"name",{value:t,configurable:!0}),"r$7");const br=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,wr=/MIT License|MIT license|BSD license/,$r=/\n{2,}/g,jr=/\b(\w+)\$\d+\b/g,kr=/[-/\\^$*+?.()|[\]{}]/g,xr=F(e=>e.replaceAll(kr,"\\$&"),"escapeRegex"),Er=F(e=>[...new Set(e)],"unique"),Sr=F(e=>e.replaceAll(br,t=>wr.test(t)?"":t).replaceAll($r,`
39
+ `));let d;return l.facadeModuleId&&typeof s[l.facadeModuleId]=="string"&&(d=s[l.facadeModuleId]),d&&(r.debug({message:`shebang for chunk "${l.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),u.prepend(`${d}
40
+ `)),p.size===0&&d===void 0?null:{code:u.toString(),map:c?u.generateMap({hires:!0}):null}},order:"post"},transform(a,l){if(!i(l))return null;let c=!1;const p=new F(a);if(a.startsWith("#")&&a[1]==="!"){let d=0;for(let g=2,h=a.length;g<h;g++){const m=a.codePointAt(g);if(m===10||m===13||m===8232||m===8233){d=g;break}}d&&(s[l]=a.slice(0,d),p.remove(0,d+1),c=!0,r.debug({message:`shebang for module "${l}" is preserved.`,prefix:"plugin:preserve-directives"}))}let u=null;try{u=this.parse(p.toString(),{allowReturnOutsideFunction:!0})}catch(d){return this.warn({code:"PARSE_ERROR",message:`failed to parse "${l}" and extract the directives.`}),r.warn(d),null}if(u.type!=="Program")return null;for(const d of u.body.filter(Boolean)){if(d.type!=="ExpressionStatement")break;let g=null;"directive"in d?g=d.directive:d.expression.type==="Literal"&&typeof d.expression.value=="string"&&e.test(d.expression.value)&&(g=d.expression.value),g!=="use strict"&&g&&(n[l]||=new Set,n[l].add(g),"start"in d&&typeof d.start=="number"&&"end"in d&&typeof d.end=="number"&&(p.remove(d.start,d.end),c=!0),r.debug({message:`directive "${g}" for module "${l}" is preserved.`,prefix:"plugin:preserve-directives"}))}return c?{code:p.toString(),map:p.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...n[l]??[]],shebang:s[l]??null}}}:null}}},"preserveDirectives");var vn=Object.defineProperty,bn=f((e,t)=>vn(e,"name",{value:t,configurable:!0}),"n$7");const wn=bn(e=>{const t=U(e.include,e.exclude);return{async load(o){return o.includes("?raw")?await this.load({id:o.replace(/\?raw$/,"")}):null},name:"packem:raw",transform(o,r){return!t(r)&&!r.includes("?raw")?null:(r.includes("?raw")||(o=`export default ${JSON.stringify(o)}`),{code:o,map:{mappings:""}})}}},"rawPlugin");var $n=Object.defineProperty,jn=f((e,t)=>$n(e,"name",{value:t,configurable:!0}),"r$8");const Ct=jn(()=>({name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return Vo(e)}}),"resolveFileUrl");var kn=Object.defineProperty,pe=f((e,t)=>kn(e,"name",{value:t,configurable:!0}),"i$5");const ne=/^#![^\n]*/,$e=pe(async e=>{await so(e,493).catch(()=>{})},"makeExecutable"),xn=pe((e,t)=>({name:"packem:shebang",renderChunk:{handler(o,r,n){if(!r.isEntry||!r.facadeModuleId)return null;const s=o.startsWith("#")&&o[1]==="!";if(s&&t.replace)return o.replace(ne,t.shebang+`
41
+ `);if(s)return null;if(e.includes(r.name)){const i=new F(o);return i.prepend(t.shebang+`
42
+ `),{code:i.toString(),map:n.sourcemap?i.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"&&ne.test(s.code)&&o.dir){const i=$(o.dir,n);await $e(i)}}}),"shebangPlugin"),En=pe(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ne,"")}}),"removeShebangPlugin"),Sn=pe((e,t=`
43
+ `)=>{const o=ne.exec(e);return o?o+t:""},"getShebang");var On=Object.defineProperty,B=f((e,t)=>On(e,"name",{value:t,configurable:!0}),"r$7");const Dn=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Nn=/MIT License|MIT license|BSD license/,Pn=/\n{2,}/g,Cn=/\b(\w+)\$\d+\b/g,_n=/[-/\\^$*+?.()|[\]{}]/g,Tn=B(e=>e.replaceAll(_n,"\\$&"),"escapeRegex"),In=B(e=>[...new Set(e)],"unique"),Mn=B(e=>e.replaceAll(Dn,t=>Nn.test(t)?"":t).replaceAll(Pn,`
44
44
 
45
- `),"cleanUnnecessaryComments"),Ie=new Map;function Et(e,t,{identifierReplacements:o},n){const r=mt(e);for(const i in o){const a=r.find(c=>c.specifier===i&&c.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const l=o[i];for(const c in l){if(!a.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${i}" for replacement`);const u=l[c],p=xr(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=Er(Array.from(e.matchAll(jr),i=>i[0]));if(s.length>0){const i=s.map(l=>`
46
- - ${l}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");Ie.has(a)||n.warn({message:`${t.fileName} contains confusing identifier names${i}
45
+ `),"cleanUnnecessaryComments"),Le=new Map;function _t(e,t,{identifierReplacements:o},r){const n=wt(e);for(const i in o){const a=n.find(c=>c.specifier===i&&c.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const l=o[i];for(const c in l){if(!a.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${i}" for replacement`);const p=l[c],u=Tn(c);p.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${u},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${u}\\b`,"g"),p)}}const s=In(Array.from(e.matchAll(Cn),i=>i[0]));if(s.length>0){const i=s.map(l=>`
46
+ - ${l}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");Le.has(a)||r.warn({message:`${t.fileName} contains confusing identifier names${i}
47
47
 
48
- To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Ie.set(a,!0)}return e}m(Et,"I");F(Et,"replaceConfusingTypeNames");const Or=F((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},"removeInternal");function St(e,t){if(e.includes("@internal")){const o=new I(e),n=Jo(e,{plugins:["typescript"],sourceType:"module"});if(wt(n,{enter(r){Or(o,r)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}m(St,"S$1");F(St,"stripInternalTypes");const Dr=F((e,t)=>({name:"packem:patch-types",renderChunk(o,n){return o=Et.call(this,o,n,e,t),o=St.call(this,o,n),o=Sr(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var Nr=Object.defineProperty,Ot=m((e,t)=>Nr(e,"name",{value:t,configurable:!0}),"m$6");const Dt=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 i=$(L(n),r),a=[];if(s)for(const[l,c]of Object.entries(s)){let u;l==="@"||l==="~"||l==="#"?u=new RegExp(`^${l}/(.+)$`):u=new RegExp(`^${[...l].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let p=0;for(const d of c){const g=[...Ne($(i,d))].map(h=>h==="*"?"$"+(++p+""):h==="$"?"$$":h).join("");a.push({find:u,replacement:g})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...Ne(i)].map(l=>l==="$"?"$$":l).join("")}/$1`}),a},"getConfigAlias"),Nt=Ot((e,t)=>{const o=Dt(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,r,s){if(!o||n.includes("\0"))return null;for(const{find:i,replacement:a}of o)if(i.test(n)){const l=n.replace(i,a),c=await this.resolve(l,r,{skipSelf:!0,...s});if(c)return t.debug({message:`Resolved ${n} to ${c.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),c.id}return null}}},"resolveTsconfigPaths");var Pr=Object.defineProperty,Pt=m((e,t)=>Pr(e,"name",{value:t,configurable:!0}),"u$5");const Cr=Pt((e,t)=>{if(!t)return null;const{config:o,path:n}=t;if(!o.compilerOptions)return null;const{rootDirs:r}=o.compilerOptions;if(!r)return null;const s=[];for(const i of r){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);s.push($(e,i))}return s},"getRootDirectories"),Ct=Pt((e,t,o)=>{const n=Cr(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(r,s,i){if(n===null||n.length===0)return null;if(r.startsWith("."))for(const a of n){const l=w(a,r),c=await this.resolve(l,s,{skipSelf:!0,...i});if(c)return t.debug({message:`Resolved ${r} to ${c.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),c.id}return null}}},"resolveTsconfigRootDirectories");var _r=Object.defineProperty,Mr=m((e,t)=>_r(e,"name",{value:t,configurable:!0}),"r$6");const _t=Mr(()=>{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 Tr=Object.defineProperty,Mt=m((e,t)=>Tr(e,"name",{value:t,configurable:!0}),"u$4");const Re=Mt((e,t,o,n)=>{const r=e.findIndex(i=>typeof i=="object"?i.name===o:!1);if(r===-1)throw new Error(`Plugin with name "${o}" was not found, try one of: ${e.map(i=>{if(typeof i=="object")return i.name}).filter(Boolean).join(", ")}`);const s=n?r+1:r;return e.splice(s,0,t),e},"appendPlugin"),Tt=Mt((e,t)=>{if(!t)return e;for(const{after:o=void 0,before:n=void 0,plugin:r}of t)e=o?Re(e,r,o,!0):Re(e,r,n,!1);return e},"appendPlugins");var Ar=Object.defineProperty,Ir=m((e,t)=>Ar(e,"name",{value:t,configurable:!0}),"s$7");const Rr=Ir(e=>{const t=ae(e).split(".");if(t.length>=2){const[o,n]=t.slice(-2),r=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(we.includes(n)&&s&&s.length>0)return r+"-"+s}},"getCustomModuleLayer");var Fr=Object.defineProperty,Jr=m((e,t)=>Fr(e,"name",{value:t,configurable:!0}),"i$4");const me=Jr(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var Br=Object.defineProperty,Fe=m((e,t)=>Br(e,"name",{value:t,configurable:!0}),"d$7");const Lr=Fe((e,t)=>{const o=new Map;return Fe(function(n,r){const s=r.getModuleInfo(n);if(!s)return;const{isEntry:i}=s,a=s.meta,l=me(a);if(!i){const c=o.get(n);if(c)return c;const u=Rr(n);if(u)return o.set(n,u),u}if(i){const c=r.getModuleIds();for(const u of c)r.getModuleInfo(u)&&me(a)===l&&(e.has(u)||e.set(u,new Set),e.get(u).add([n,l]))}if(l&&!i&&e.has(n)){const c=[...e.get(n)];if(c.some(([p])=>{if(t.some(d=>d.path===p)){const d=r.getModuleInfo(p);return me(d?d.meta:{})===l}return!1}))return;if(c.every(([,p])=>p===l))return o.has(n)?o.get(n):void 0;const u=ae(n,rt(n))+"-"+l;return o.set(n,u),u}},"splitChunks")},"createSplitChunks");var Wr=Object.defineProperty,Ur=m((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"n$5");const A=Ur((e,t)=>e.isDynamicEntry?`${xo}/[name].${t}`:`${Eo}/${e.name}-[hash].${t}`,"getChunkFilename");var zr=Object.defineProperty,Kr=m((e,t)=>zr(e,"name",{value:t,configurable:!0}),"o$4");const Vr=process.platform==="win32",Je=Kr((e,t)=>{const o=Vr?"\\":"/";for(let n of Array.isArray(e.names)?e.names:[]){if(n.includes("node_modules"+o+".pnpm"))return n=n.replace("node_modules"+o+".pnpm","external")+"."+t,n.replace("node_modules"+o,"");if(n.includes("node_modules"))return n.replace("node_modules","external")+"."+t}return"[name]."+t},"getEntryFileNames");var Hr=Object.defineProperty,qr=m((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"p$2");const je=qr((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]=w(e.options.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 Gr=Object.defineProperty,S=m((e,t)=>Gr(e,"name",{value:t,configurable:!0}),"p$1");const Yr=S((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"+to.node.split(".")[0];if(t.pkg.engines?.node){const n=ut(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")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}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=S((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${k(D($(),e.id))}"
48
+ To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Le.set(a,!0)}return e}f(_t,"I");B(_t,"replaceConfusingTypeNames");const An=B((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},"removeInternal");function Tt(e,t){if(e.includes("@internal")){const o=new F(e),r=Ho(e,{plugins:["typescript"],sourceType:"module"});if(Ot(r,{enter(n){An(o,n)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}f(Tt,"S$1");B(Tt,"stripInternalTypes");const Rn=B((e,t)=>({name:"packem:patch-types",renderChunk(o,r){return o=_t.call(this,o,r,e,t),o=Tt.call(this,o,r),o=Mn(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var Fn=Object.defineProperty,It=f((e,t)=>Fn(e,"name",{value:t,configurable:!0}),"m$7");const Mt=It((e,t=!0)=>{if(!e)return null;const{config:o,path:r}=e;if(!o.compilerOptions)return null;const{baseUrl:n,paths:s}=o.compilerOptions;if(!n)return null;const i=$(K(r),n),a=[];if(s)for(const[l,c]of Object.entries(s)){let p;l==="@"||l==="~"||l==="#"?p=new RegExp(`^${l}/(.+)$`):p=new RegExp(`^${[...l].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let u=0;for(const d of c){const g=[...Me($(i,d))].map(h=>h==="*"?"$"+(++u+""):h==="$"?"$$":h).join("");a.push({find:p,replacement:g})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...Me(i)].map(l=>l==="$"?"$$":l).join("")}/$1`}),a},"getConfigAlias"),At=It((e,t)=>{const o=Mt(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(r,n,s){if(!o||r.includes("\0"))return null;for(const{find:i,replacement:a}of o)if(i.test(r)){const l=r.replace(i,a),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 Jn=Object.defineProperty,Rt=f((e,t)=>Jn(e,"name",{value:t,configurable:!0}),"u$6");const Bn=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 i of n){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);s.push($(e,i))}return s},"getRootDirectories"),Ft=Rt((e,t,o)=>{const r=Bn(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,s,i){if(r===null||r.length===0)return null;if(n.startsWith("."))for(const a of r){const l=w(a,n),c=await this.resolve(l,s,{skipSelf:!0,...i});if(c)return t.debug({message:`Resolved ${n} to ${c.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),c.id}return null}}},"resolveTsconfigRootDirectories");var Wn=Object.defineProperty,Ln=f((e,t)=>Wn(e,"name",{value:t,configurable:!0}),"r$6");const Jt=Ln(()=>{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 Kn=Object.defineProperty,Bt=f((e,t)=>Kn(e,"name",{value:t,configurable:!0}),"u$5");const Ke=Bt((e,t,o,r)=>{const n=e.findIndex(i=>typeof i=="object"?i.name===o:!1);if(n===-1)throw new Error(`Plugin with name "${o}" was not found, try one of: ${e.map(i=>{if(typeof i=="object")return i.name}).filter(Boolean).join(", ")}`);const s=r?n+1:n;return e.splice(s,0,t),e},"appendPlugin"),Wt=Bt((e,t)=>{if(!t)return e;for(const{after:o=void 0,before:r=void 0,plugin:n}of t)e=o?Ke(e,n,o,!0):Ke(e,n,r,!1);return e},"appendPlugins");var Un=Object.defineProperty,zn=f((e,t)=>Un(e,"name",{value:t,configurable:!0}),"s$7");const Vn=zn(e=>{const t=le(e).split(".");if(t.length>=2){const[o,r]=t.slice(-2),n=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(xe.includes(r)&&s&&s.length>0)return n+"-"+s}},"getCustomModuleLayer");var Hn=Object.defineProperty,qn=f((e,t)=>Hn(e,"name",{value:t,configurable:!0}),"i$4");const he=qn(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var Gn=Object.defineProperty,Ue=f((e,t)=>Gn(e,"name",{value:t,configurable:!0}),"d$7");const Xn=Ue((e,t)=>{const o=new Map;return Ue(function(r,n){const s=n.getModuleInfo(r);if(!s)return;const{isEntry:i}=s,a=s.meta,l=he(a);if(!i){const c=o.get(r);if(c)return c;const p=Vn(r);if(p)return o.set(r,p),p}if(i){const c=n.getModuleIds();for(const p of c)n.getModuleInfo(p)&&he(a)===l&&(e.has(p)||e.set(p,new Set),e.get(p).add([r,l]))}if(l&&!i&&e.has(r)){const c=[...e.get(r)];if(c.some(([u])=>{if(t.some(d=>d.path===u)){const d=n.getModuleInfo(u);return he(d?d.meta:{})===l}return!1}))return;if(c.every(([,u])=>u===l))return o.has(r)?o.get(r):void 0;const p=le(r,ut(r))+"-"+l;return o.set(r,p),p}},"splitChunks")},"createSplitChunks");var Yn=Object.defineProperty,Qn=f((e,t)=>Yn(e,"name",{value:t,configurable:!0}),"n$5");const R=Qn((e,t)=>e.isDynamicEntry?`${_o}/[name].${t}`:`${To}/${e.name}-[hash].${t}`,"getChunkFilename");var Zn=Object.defineProperty,ei=f((e,t)=>Zn(e,"name",{value:t,configurable:!0}),"o$4");const ti=process.platform==="win32",ze=ei((e,t)=>{const o=ti?"\\":"/";for(let r of Array.isArray(e.names)?e.names:[]){if(r.includes("node_modules"+o+".pnpm"))return r=r.replace("node_modules"+o+".pnpm","external")+"."+t,r.replace("node_modules"+o,"");if(r.includes("node_modules"))return r.replace("node_modules","external")+"."+t}return"[name]."+t},"getEntryFileNames");var oi=Object.defineProperty,ri=f((e,t)=>oi(e,"name",{value:t,configurable:!0}),"p$1");const Se=ri((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]=w(e.options.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 ni=Object.defineProperty,O=f((e,t)=>ni(e,"name",{value:t,configurable:!0}),"p");const ii=O((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"+co.node.split(".")[0];if(t.pkg.engines?.node){const r=vt(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")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}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=O((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${x(N($(),e.id))}"
49
49
  Is the module installed? Note:
50
50
  ↳ to inline a module into your bundle, install it to "devDependencies".
51
- ↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MODULE_LEVEL_DIRECTIVE"?!0:e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),Be=new Map,fe=new Map,It=S((e,t,o)=>{const n=S(s=>{for(const[i,a]of Object.entries(t))if(s.startsWith(i))return s.replace(i,a)},"findAlias"),r=Dt(e.tsconfig,!1);return{external(s){const i=n(s);i&&(s=i);const a=ft(s);if(he(e.options.externals,a)||he(e.options.externals,s))return!0;const{pkg:l}=e;if(s.startsWith(".")||it(s)||/src[/\\]/.test(s)||l.name&&s.startsWith(l.name))return!1;if(l.imports)for(const[c,u]of Object.entries(l.imports)){if(c===s)return!1;if(c.includes("*")){let p;fe.has(c)?p=fe.get(c):(p=Ye(w(e.options.rootDir,u.replace("/*","")),{withFileTypes:!0}).filter(d=>d.isFile()).map(d=>d.name),fe.set(c,p));for(const d of p)if(d.replace(R,"")===s.replace(R,"").replace("#",""))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 Be.has(s)||e.logger.info({message:'Inlined implicit external "'+k(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),Be.set(s,!0),!1},input:Object.fromEntries(e.options.entries.map(s=>[s.name,$(e.options.rootDir,s.input)])),logLevel:e.options.debug?"debug":"info",onLog:S((s,i)=>{let a=i.message;switch(i.stack&&(a=`${a}
52
- ${i.stack}`),s){case"info":{e.logger.info({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(s,i){At(s,e)||s.code||i(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Rt=S(async(e,t)=>{const o=je(e,"build");let n;e.options.rollup.resolve&&(n=E(ct({...e.options.rollup.resolve}),t));const r=e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Lr(e.dependencyGraphMap,e.buildEntries),preserveModules:!1};return{...It(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:S(s=>A(s,"cjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:S(s=>Je(s,"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,...r},e.options.emitESM&&{chunkFileNames:S(s=>A(s,"mjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:S(s=>Je(s,"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,...r}].filter(Boolean),plugins:Tt([E(xt(),t),E(_t(),t),e.tsconfig&&E(Ct(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&E(Nt(e.tsconfig,e.logger),t),e.options.rollup.replace&&pt({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&lt({customResolver:n,...e.options.rollup.alias,entries:o}),n,e.options.rollup.polyfillNode&&wo({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&bt({...e.options.rollup.json}),dn(),e.options.rollup.wasm&&bo(e.options.rollup.wasm),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&Fn(w(e.options.rootDir,e.options.sourceDir),e.options.isolatedDeclarationTransformer,e.options.declaration,!!e.options.rollup.cjsInterop,e.options.rollup.isolatedDeclarations),e.options.rollup.raw&&E(ur(e.options.rollup.raw),t),e.options.transformer(Yr(e.options.transformerName,e)),E(lr({directiveRegex:/^['|"](use (\w+))['|"]$/,...e.options.rollup.preserveDirectives,logger:e.logger}),t),e.options.rollup.shebang&&gr(e.options.entries.filter(s=>s.executable).map(s=>s.name).filter(Boolean),e.options.rollup.shebang),e.options.cjsInterop&&e.options.emitCJS&&vt({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Pn(),e.options.rollup.dynamicVars&&vo(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&E(yo({sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{name:"packem:preserve-dynamic-imports",renderDynamicImport(){return{left:"import(",right:")"}}},e.options.cjsInterop&&e.options.rollup.shim&&On(e.pkg,e.options.rollup.shim),e.options.rollup.jsxRemoveAttributes&&E(Kn({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),t),e.options.rollup.metafile&&Yn({outDir:$(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&$n(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&jt({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",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}),ir(),e.options.emitCJS&&e.mode==="build"&&e.options.declaration==="compatible"&&e.options.rollup.node10Compatibility&&Zn(e.logger,e.options.entries,e.options.outDir,e.options.rootDir,e.options.rollup.node10Compatibility.writeToPackageJson?"file":"console",e.options.rollup.node10Compatibility.typeScriptVersion??"*"),e.options.analyze&&e.options.rollup.visualizer!==!1&&$o({brotliSize:!0,gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,...e.options.rollup.visualizer,filename:"packem-bundle-analyze.html",title:"Packem Visualizer"})].filter(Boolean),e.options.rollup.plugins)}},"getRollupOptions"),Xr=S(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"),Qr=Qo(Xr),Ft=S(async(e,t)=>{const o=je(e,"types"),n={load(a){return/\.(?:js|cjs|mjs|jsx|ts|tsx|ctsx|mtsx|mts|json)$/.test(a)?null:""},name:"packem:ignore-files"},r=e.tsconfig?.config.compilerOptions;delete r?.lib;let s;e.options.rollup.resolve&&(s=E(ct({...e.options.rollup.resolve}),t));const i="dts-plugin:"+process.pid+e.tsconfig.path;return{...It(e,o,"dts"),onwarn(a,l){At(a,e)||a.code!=="EMPTY_BUNDLE"&&l(a)},output:[e.options.emitCJS&&{chunkFileNames:S(a=>A(a,"d.cts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:S(a=>A(a,"d.mts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.declaration==="compatible"&&{chunkFileNames:S(a=>A(a,"d.ts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:Tt([E(xt(),t),E(_t(),t),e.options.rollup.json&&bt({...e.options.rollup.json}),n,e.tsconfig&&E(Ct(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&E(Nt(e.tsconfig,e.logger),t),e.options.rollup.replace&&pt({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&lt({customResolver:s,...e.options.rollup.alias,entries:o}),s,await Qr(i)(e),e.options.cjsInterop&&e.options.emitCJS&&vt({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&E(Dr(e.options.rollup.patchTypes,e.logger),t),hr(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&jt({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean),e.options.rollup.plugins)}},"getRollupDtsOptions");var Zr=Object.defineProperty,ei=m((e,t)=>Zr(e,"name",{value:t,configurable:!0}),"f$5");const Le="rollup-build.json",ge=ei(async(e,t,o)=>{const n=await Rt(e,t);if(await e.hooks.callHook("rollup:options",e,n),Object.keys(n.input).length===0)return;(!e.options.rollup.isolatedDeclarations||!e.options.isolatedDeclarationTransformer)&&(n.cache=t.get(Le,o));const r=await at(n);t.set(Le,r.cache,o),await e.hooks.callHook("rollup:build",e,r);const s=new Map;for(const i of n.output){const{output:a}=await r.write(i),l=new Set,c=a.filter(p=>p.type==="chunk");for(const p of c){l.add(p.fileName);for(const d of p.imports)e.usedImports.add(d);p.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(p.code,"utf8"),chunks:p.imports.filter(d=>c.find(g=>g.fileName===d)),exports:p.exports,modules:Object.entries(p.modules).map(([d,g])=>({bytes:g.renderedLength,id:d})),path:p.fileName,type:"entry"})}const u=a.filter(p=>p.type==="asset");for(const p of u)s.has(p.fileName)||s.set(p.fileName,{bytes:Buffer.byteLength(p.source,"utf8"),path:p.fileName,type:"asset"});for(const p of l)e.usedImports.delete(p)}e.buildEntries.push(...s.values())},"build");var ti=Object.defineProperty,Y=m((e,t)=>ti(e,"name",{value:t,configurable:!0}),"a$6");const We="rollup-dts.json",X=Y(async(e,t,o)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.info({message:"Using isolated declaration transformer to generate declaration files...",prefix:"dts"});return}const n=await Ft(e,t);if(await e.hooks.callHook("rollup:dts:options",e,n),Object.keys(n.input).length===0)return;n.cache=t.get(We,o);const r=await at(n);t.set(We,r.cache,o),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:Y(s=>A(s,"d.cts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await r.write({chunkFileNames:Y(s=>A(s,"d.mts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration==="compatible"&&await r.write({chunkFileNames:Y(s=>A(s,"d.mjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var oi=Object.defineProperty,ni=m((e,t)=>oi(e,"name",{value:t,configurable:!0}),"y$2");const ri=ni((e,t,o)=>e.reduce((n,r)=>{const s=r[t],i=r[o];return n[s]||(n[s]={}),n[s][i]||(n[s][i]=[]),n[s][i].push(r),n},{}),"groupByKeys");var ii=Object.defineProperty,re=m((e,t)=>ii(e,"name",{value:t,configurable:!0}),"j$1");const si=re((e,t)=>{const o=re(i=>D(t.options.rootDir,$(t.options.outDir,i)),"rPath");let n=!1;const r=[],s=t.buildEntries.filter(i=>i.type==="entry");if(s.length>0){e.raw(`Entries:
53
- `);for(const i of s){let a=i.bytes??0;for(const c of i.chunks??[])a+=t.buildEntries.find(u=>u.path===c)?.bytes??0;let l=` ${N(o(i.path))} (${["total size: "+k(_(a)),i.bytes&&"chunk size: "+k(_(i.bytes))].filter(Boolean).join(", ")})`;if(l+=i.exports?.length?`
51
+ ↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MODULE_LEVEL_DIRECTIVE"?!0:e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),Ve=new Map,ye=new Map,Kt=O((e,t,o)=>{const r=O(s=>{for(const[i,a]of Object.entries(t))if(s.startsWith(i))return s.replace(i,a)},"findAlias"),n=Mt(e.tsconfig,!1);return{external(s){const i=r(s);i&&(s=i);const a=$t(s);if(we(e.options.externals,a)||we(e.options.externals,s))return!0;const{pkg:l}=e;if(s.startsWith(".")||dt(s)||/src[/\\]/.test(s)||l.name&&s.startsWith(l.name))return!1;if(l.imports)for(const[c,p]of Object.entries(l.imports)){if(c===s)return!1;if(c.includes("*")){let u;ye.has(c)?u=ye.get(c):(u=rt(w(e.options.rootDir,p.replace("/*","")),{withFileTypes:!0}).filter(d=>d.isFile()).map(d=>d.name),ye.set(c,u));for(const d of u)if(d.replace(J,"")===s.replace(J,"").replace("#",""))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 Ve.has(s)||e.logger.info({message:'Inlined implicit external "'+x(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),Ve.set(s,!0),!1},input:Object.fromEntries(e.options.entries.map(s=>[s.name,$(e.options.rootDir,s.input)])),logLevel:e.options.debug?"debug":"info",onLog:O((s,i)=>{let a=i.message;switch(i.stack&&(a=`${a}
52
+ ${i.stack}`),s){case"info":{e.logger.info({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(s,i){Lt(s,e)||s.code||i(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Ut=O(async(e,t)=>{const o=Se(e,"build");let r;e.options.rollup.resolve&&(r=S(ht({...e.options.rollup.resolve}),t));const n=e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Xn(e.dependencyGraphMap,e.buildEntries),preserveModules:!1};return{...Kt(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:O(s=>R(s,"cjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:O(s=>ze(s,"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,...n},e.options.emitESM&&{chunkFileNames:O(s=>R(s,"mjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:O(s=>ze(s,"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,...n}].filter(Boolean),plugins:Wt([S(Ct(),t),S(Jt(),t),e.tsconfig&&S(Ft(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&S(At(e.tsconfig,e.logger),t),e.options.rollup.replace&&yt({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&gt({customResolver:r,...e.options.rollup.alias,entries:o}),r,e.options.rollup.polyfillNode&&Do({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&St({...e.options.rollup.json}),wr(),e.options.rollup.wasm&&Oo(e.options.rollup.wasm),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&Vr(w(e.options.rootDir,e.options.sourceDir),e.options.isolatedDeclarationTransformer,e.options.declaration,!!e.options.rollup.cjsInterop,e.options.rollup.isolatedDeclarations),e.options.rollup.raw&&S(wn(e.options.rollup.raw),t),e.options.transformer(ii(e.options.transformerName,e)),S(yn({directiveRegex:/^['|"](use (\w+))['|"]$/,...e.options.rollup.preserveDirectives,logger:e.logger}),t),e.options.rollup.shebang&&xn(e.options.entries.filter(s=>s.executable).map(s=>s.name).filter(Boolean),e.options.rollup.shebang),e.options.cjsInterop&&e.options.emitCJS&&Et({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Fr(),e.options.rollup.dynamicVars&&So(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&S(Eo({sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{name:"packem:preserve-dynamic-imports",renderDynamicImport(){return{left:"import(",right:")"}}},e.options.cjsInterop&&e.options.rollup.shim&&Mr(e.pkg,e.options.rollup.shim),e.options.rollup.jsxRemoveAttributes&&S(Zr({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),t),e.options.rollup.metafile&&nn({outDir:$(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&Nr(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Nt({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",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}),mn(),e.options.emitCJS&&e.mode==="build"&&e.options.declaration==="compatible"&&e.options.rollup.node10Compatibility&&ln(e.logger,e.options.entries,e.options.outDir,e.options.rootDir,e.options.rollup.node10Compatibility.writeToPackageJson?"file":"console",e.options.rollup.node10Compatibility.typeScriptVersion??"*"),e.options.analyze&&e.options.rollup.visualizer!==!1&&No({brotliSize:!0,gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,...e.options.rollup.visualizer,filename:"packem-bundle-analyze.html",title:"Packem Visualizer"})].filter(Boolean),e.options.rollup.plugins)}},"getRollupOptions"),si=O(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"),ai=ar(si),zt=O(async(e,t)=>{const o=Se(e,"types"),r={load(a){return/\.(?:js|cjs|mjs|jsx|ts|tsx|ctsx|mtsx|mts|json)$/.test(a)?null:""},name:"packem:ignore-files"},n=e.tsconfig?.config.compilerOptions;delete n?.lib;let s;e.options.rollup.resolve&&(s=S(ht({...e.options.rollup.resolve}),t));const i="dts-plugin:"+process.pid+e.tsconfig.path;return{...Kt(e,o,"dts"),onwarn(a,l){Lt(a,e)||a.code!=="EMPTY_BUNDLE"&&l(a)},output:[e.options.emitCJS&&{chunkFileNames:O(a=>R(a,"d.cts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:O(a=>R(a,"d.mts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.declaration==="compatible"&&{chunkFileNames:O(a=>R(a,"d.ts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:Wt([S(Ct(),t),S(Jt(),t),e.options.rollup.json&&St({...e.options.rollup.json}),r,e.tsconfig&&S(Ft(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&S(At(e.tsconfig,e.logger),t),e.options.rollup.replace&&yt({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&gt({customResolver:s,...e.options.rollup.alias,entries:o}),s,await ai(i)(e),e.options.cjsInterop&&e.options.emitCJS&&Et({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&S(Rn(e.options.rollup.patchTypes,e.logger),t),En(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Nt({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean),e.options.rollup.plugins)}},"getRollupDtsOptions");var li=Object.defineProperty,ci=f((e,t)=>li(e,"name",{value:t,configurable:!0}),"f$6");const He="rollup-build.json",ve=ci(async(e,t,o)=>{const r=await Ut(e,t);if(await e.hooks.callHook("rollup:options",e,r),Object.keys(r.input).length===0)return;(!e.options.rollup.isolatedDeclarations||!e.options.isolatedDeclarationTransformer)&&(r.cache=t.get(He,o));const n=await mt(r);t.set(He,n.cache,o),await e.hooks.callHook("rollup:build",e,n);const s=new Map;for(const i of r.output){const{output:a}=await n.write(i),l=new Set,c=a.filter(u=>u.type==="chunk");for(const u of c){l.add(u.fileName);for(const d of u.imports)e.usedImports.add(d);u.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(u.code,"utf8"),chunks:u.imports.filter(d=>c.find(g=>g.fileName===d)),exports:u.exports,modules:Object.entries(u.modules).map(([d,g])=>({bytes:g.renderedLength,id:d})),path:u.fileName,type:"entry"})}const p=a.filter(u=>u.type==="asset");for(const u of p)s.has(u.fileName)||s.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(...s.values())},"build");var pi=Object.defineProperty,Y=f((e,t)=>pi(e,"name",{value:t,configurable:!0}),"a$7");const qe="rollup-dts.json",Q=Y(async(e,t,o)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.info({message:"Using isolated declaration transformer to generate declaration files...",prefix:"dts"});return}const r=await zt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,r),Object.keys(r.input).length===0)return;r.cache=t.get(qe,o);const n=await mt(r);t.set(qe,n.cache,o),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:Y(s=>R(s,"d.cts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await n.write({chunkFileNames:Y(s=>R(s,"d.mts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration==="compatible"&&await n.write({chunkFileNames:Y(s=>R(s,"d.mjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var ui=Object.defineProperty,di=f((e,t)=>ui(e,"name",{value:t,configurable:!0}),"y$2");const fi=di((e,t,o)=>e.reduce((r,n)=>{const s=n[t],i=n[o];return r[s]||(r[s]={}),r[s][i]||(r[s][i]=[]),r[s][i].push(n),r},{}),"groupByKeys");var mi=Object.defineProperty,ie=f((e,t)=>mi(e,"name",{value:t,configurable:!0}),"j$1");const gi=ie((e,t)=>{const o=ie(i=>N(t.options.rootDir,$(t.options.outDir,i)),"rPath");let r=!1;const n=[],s=t.buildEntries.filter(i=>i.type==="entry");if(s.length>0){e.raw(`Entries:
53
+ `);for(const i of s){let a=i.bytes??0;for(const c of i.chunks??[])a+=t.buildEntries.find(p=>p.path===c)?.bytes??0;let l=` ${C(o(i.path))} (${["total size: "+x(I(a)),i.bytes&&"chunk size: "+x(I(i.bytes))].filter(Boolean).join(", ")})`;if(l+=i.exports?.length?`
54
54
  exports: `+M(i.exports.join(", ")):"",i.chunks?.length&&(l+=`
55
- ${i.chunks.map(c=>{const u=t.buildEntries.find(p=>p.path===c)??{};return M(" └─ "+o(c)+N(u.bytes?" ("+_(u?.bytes)+")":""))}).join(`
56
- `)}`),i.modules&&i.modules.length>0){const c=i.modules.filter(u=>u.id.includes("node_modules")).sort((u,p)=>(p.bytes||0)-(u.bytes||0)).map(u=>M(" 📦 "+o(u.id)+N(u.bytes?" ("+_(u.bytes)+")":""))).join(`
55
+ ${i.chunks.map(c=>{const p=t.buildEntries.find(u=>u.path===c)??{};return M(" └─ "+o(c)+C(p.bytes?" ("+I(p?.bytes)+")":""))}).join(`
56
+ `)}`),i.modules&&i.modules.length>0){const c=i.modules.filter(p=>p.id.includes("node_modules")).sort((p,u)=>(u.bytes||0)-(p.bytes||0)).map(p=>M(" 📦 "+o(p.id)+C(p.bytes?" ("+I(p.bytes)+")":""))).join(`
57
57
  `);l+=c.length>0?`
58
58
  inlined modules:
59
- `+c:""}if(t.options.declaration){let c=i.path.replace(/\.js$/,".d.ts"),u="commonjs";i.path.endsWith(".cjs")?c=i.path.replace(/\.cjs$/,".d.cts"):i.path.endsWith(".mjs")&&(u="module",c=i.path.replace(/\.mjs$/,".d.mts"));const p=t.buildEntries.find(d=>d.path.endsWith(c));if(p){r.push(p.path);let d;c.includes(".d.ts")||(c=c.replace(".d.c",".d."),d=t.buildEntries.find(g=>g.path.endsWith(c))),d&&(r.push(d.path),l+=u==="commonjs"?`
59
+ `+c:""}if(t.options.declaration){let c=i.path.replace(/\.js$/,".d.ts"),p="commonjs";i.path.endsWith(".cjs")?c=i.path.replace(/\.cjs$/,".d.cts"):i.path.endsWith(".mjs")&&(p="module",c=i.path.replace(/\.mjs$/,".d.mts"));const u=t.buildEntries.find(d=>d.path.endsWith(c));if(u){n.push(u.path);let d;c.includes(".d.ts")||(c=c.replace(".d.c",".d."),d=t.buildEntries.find(g=>g.path.endsWith(c))),d&&(n.push(d.path),l+=p==="commonjs"?`
60
60
  types:
61
- `+[p,d].map(g=>M(" └─ ")+N(o(g.path))+" (total size: "+k(_(g.bytes??0))+")").join(`
61
+ `+[u,d].map(g=>M(" └─ ")+C(o(g.path))+" (total size: "+x(I(g.bytes??0))+")").join(`
62
62
  `):`
63
- types: `+N(o(p.path))+" (total size: "+k(_(p.bytes??0))+")")}}n=!0,l+=`
63
+ types: `+C(o(u.path))+" (total size: "+x(I(u.bytes??0))+")")}}r=!0,l+=`
64
64
 
65
- `,e.raw(i.chunk?M(l):l)}}if(t.buildEntries.filter(i=>i.type==="asset").length>0){let i="Assets:";for(const a of t.buildEntries.filter(l=>l.type==="asset"))r.includes(a.path)||(i+=M(`
66
- └─ `)+N(o(a.path))+" (total size: "+k(_(a.bytes??0))+")");i+=`
65
+ `,e.raw(i.chunk?M(l):l)}}if(t.buildEntries.filter(i=>i.type==="asset").length>0){let i="Assets:";for(const a of t.buildEntries.filter(l=>l.type==="asset"))n.includes(a.path)||(i+=M(`
66
+ └─ `)+C(o(a.path))+" (total size: "+x(I(a.bytes??0))+")");i+=`
67
67
 
68
- `,e.raw(i)}return n&&e.raw("Σ Total dist size (byte size):",k(_(t.buildEntries.reduce((i,a)=>i+(a.bytes??0),0))),`
69
- `),n},"showSizeInformation"),ai=re((e,t)=>{const o=ri(e.options.entries,"environment","runtime"),n=[];for(const[r,s]of Object.entries(o))for(const[i,a]of Object.entries(s)){const l={...e};!e.options.dtsOnly&&(r!=="undefined"||i!=="undefined")&&e.logger.info("Preparing build for "+(r==="undefined"?"":k(r)+" environment"+(i==="undefined"?"":" with "))+(i==="undefined"?"":k(i)+" runtime")),l.options.rollup.replace?(l.options.rollup.replace.values===void 0&&(l.options.rollup.replace.values={}),r!=="undefined"&&(l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(r)}),l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","EdgeRuntime"].join(".")]:JSON.stringify(i==="edge-light")}):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";r!=="undefined"&&(c+=r+"/"),i!=="undefined"&&(c+=i+"/");let u=!1;l.options.minify!==void 0&&(u=l.options.minify),r==="development"?u=!1:r==="production"&&(u=!0);const p=[],d=[],g=[],h=[];for(const f of a)f.cjs&&f.esm?p.push(f):f.cjs?g.push(f):f.esm?d.push(f):f.declaration&&h.push(f);if(p.length>0){const f={...l,options:{...l.options,emitCJS:!0,emitESM:!0,entries:p,minify:u}};if(e.options.dtsOnly||n.push(ge(f,t,c)),e.options.declaration){const y=f.options.entries.filter(b=>b.declaration);y.length>0&&n.push(X({...f,options:{...f.options,entries:y}},t,c))}}if(d.length>0){const f={...l,options:{...l.options,emitCJS:!1,emitESM:!0,entries:d,minify:u}};if(e.options.dtsOnly||n.push(ge(f,t,c)),e.options.declaration){const y=f.options.entries.filter(b=>b.declaration);y.length>0&&n.push(X({...f,options:{...f.options,entries:y}},t,c))}}if(g.length>0){const f={...l,options:{...l.options,emitCJS:!0,emitESM:!1,entries:g,minify:u}};if(e.options.dtsOnly||n.push(ge(f,t,c)),e.options.declaration){const y=f.options.entries.filter(b=>b.declaration);y.length>0&&n.push(X({...f,options:{...f.options,entries:y}},t,c))}}if(l.options.declaration&&h.length>0){const f={...l,options:{...l.options,emitCJS:!1,emitESM:!1,entries:h,minify:u}};n.push(X(f,t,c))}}return n.filter(Boolean)},"prepareRollupConfig"),li=re(async(e,t)=>{await e.hooks.callHook("build:before",e),await Promise.all(ai(e,t)),e.logger.success(no(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const o of ao(w(e.options.rootDir,e.options.outDir))){let n=e.buildEntries.find(r=>w(e.options.rootDir,e.options.outDir,r.path)===o.path);if(n||(n={chunk:!0,path:o.path},e.buildEntries.push(n)),!n.bytes){const r=await Qe($(e.options.rootDir,e.options.outDir,o.path));n.bytes=r.size}}return await e.hooks.callHook("build:done",e),si(e.logger,e)},"build");var ci=Object.defineProperty,pi=m((e,t)=>ci(e,"name",{value:t,configurable:!0}),"r$4");const j=pi((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var ui=Object.defineProperty,Jt=m((e,t)=>ui(e,"name",{value:t,configurable:!0}),"t$4");const ie=Jt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),ve=Jt((e,t,o,n)=>{if(e==="module-sync")return"esm";if(n){const i=ie(n);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[r,...s]=t;return ve(r,s,o,n)},"inferExportType");var di=Object.defineProperty,mi=m((e,t)=>di(e,"name",{value:t,configurable:!0}),"y$1");const fi=new Set(["electron","import","require","node","node-addons","default","types","deno","browser","module-sync","bun","workerd",...dt,...te]),ke=mi((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const r=ie(e);if(r&&r!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:r??t}]}if(typeof e=="object"){const r=Object.entries(e).filter(([i])=>!i.endsWith(".json"));let s=[];for(const[i,a]of r)if(typeof a=="string"){let l={};Number.isInteger(+i)?l={exportKey:"*"}:i.startsWith("./")?l={exportKey:i.replace("./","")}:l={exportKey:i==="."?".":"*",subKey:i},s.push({...l,file:a,key:"exports",type:ve(i,n,t,a)})}else if(typeof a=="object"&&a!==null)for(const[l,c]of Object.entries(a)){if(o===!1&&l==="types")continue;const u=Number.isInteger(+i)?l:i;typeof c=="string"?s.push({exportKey:u.replace("./",""),file:c,key:"exports",...fi.has(l)?{subKey:l}:{},type:ve(l,n,t,c)}):s=[...s,...ke({[u]:c},t,o,[...n,l])]}return s}return[]},"extractExportFilenames");var gi=Object.defineProperty,pe=m((e,t)=>gi(e,"name",{value:t,configurable:!0}),"c$3");const hi=pe((e,t)=>e.key==="exports"&&e.subKey===K?K:e.key==="exports"&&e.subKey===De?De:t,"getEnvironment"),Q=pe((e,t,o,n,r,s,i)=>{const a=hi(r,s.environment);let l="node";for(const p of dt)if(r.file.includes("."+p+".")||r.subKey===p){l=p;break}let c=e.find(p=>p.input===t&&p.environment===a&&p.runtime===l);c===void 0?c=e[e.push({environment:a,exportKey:new Set([r.exportKey].filter(Boolean)),input:t,runtime:l})-1]:c.exportKey&&r.exportKey&&c.exportKey.add(r.exportKey),i&&(c.isGlob=!0),o&&(c.outDir=n),r.isExecutable?(c.executable=!0,c.declaration=!1,r.type==="cjs"?c.cjs=!0:r.type==="esm"&&(c.esm=!0)):(/\.d\.[mc]?ts$/.test(r.file)&&s.options.declaration!==!1&&(c.declaration=s.options.declaration),r.type==="cjs"?c.cjs=!0:r.type==="esm"&&(c.esm=!0));const u=r.file.replace(rt(r.file),"").replace(new RegExp(`^./${s.options.outDir.replace(/^\.\//,"")}/`),"");te.has(r.subKey)&&!t.includes(u)&&(c.fileAlias=u)},"createOrUpdateEntry");let Ue=!1;const ze=pe(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),yi=pe((e,t,o)=>{const n=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const r=e.type==="module"?"esm":"cjs";r==="esm"&&(o.options.emitESM=!0),r==="cjs"&&(o.options.emitCJS=!0);const s=ke(e.exports,r,o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=ie(l);if(c&&c!==r)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);s.push({file:l,isExecutable:!0,key:"bin",type:c??r})}}e.main&&s.push({file:e.main,key:"main",type:ie(e.main)??r}),e.module&&s.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(ze(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),s.push({file:e.types??e.typings,key:"types"}));const i=[];for(const a of s){o.options.declaration===void 0&&(a.key==="types"||a.subKey==="types")&&(o.options.declaration=a.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&a.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&a.type==="esm"&&(o.options.emitESM=!0);const l=a.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).replace("./",""),p="(?<=/|$)",d=c?"":"\\.\\w+$";if(a.file.includes("/*")&&a.key==="exports"){Ue||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Ue=!0);const y=[],b=new RegExp(p+u.replace("*","(.*)")+d),x=new RegExp(p+u.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+d);for(const v of t)(b.test(v)||te.has(a.subKey)&&x.test(v))&&y.push(v);if(y.length===0){n.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const v of y)Q(i,v,c,l,a,o,!0);continue}const g=new RegExp(p+u+d);let h=t.find(y=>g.test(y));if(te.has(a.subKey)&&h===void 0){const y=new RegExp(p+u.replace(/(.*)\.[^.]*$/,"$1")+d);h=t.find(b=>y.test(b))}if(h===void 0){C($(o.options.rootDir,a.file))||n.push(`Could not find entrypoint for \`${a.file}\``);continue}(h.endsWith(".ts")||h.endsWith(".cts")||h.endsWith(".mts"))&&C(h)&&ze(o);const f=ee(h.replace(R,""));C(f+".cts")&&C(f+".mts")?(Q(i,f+".cts",c,l,{...a,type:"cjs"},o,!1),Q(i,f+".mts",c,l,{...a,type:"esm"},o,!1)):Q(i,h,c,l,a,o,!1)}return{entries:i,warnings:n}},"inferEntries");var vi=Object.defineProperty,bi=m((e,t)=>vi(e,"name",{value:t,configurable:!0}),"o$3");const wi=bi((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 $i=Object.defineProperty,ji=m((e,t)=>$i(e,"name",{value:t,configurable:!0}),"t$3");const ki={hooks:{"build:prepare":ji(function(e){if(e.options.entries.length>0)return;const t=w(e.options.rootDir,e.options.sourceDir);if(!Xe(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=lo(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&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(n.publishConfig).join(", ")+'".'),e.logger.debug(n.publishConfig),n=wi(n,e.options.declaration));const r=yi(n,o,e);for(const s of r.warnings)j(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:",k(e.options.entries.map(s=>s.fileAlias?N(s.fileAlias)+" => "+N(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):N(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),M([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var xi=Object.defineProperty,Ei=m((e,t)=>xi(e,"name",{value:t,configurable:!0}),"t$2");const Si=Ei(async(e,t)=>{if(e==="auto")e=ki;else{if(e==="none")return{};typeof e=="string"&&(e=await t.import(e)||{})}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Oi=Object.defineProperty,Di=m((e,t)=>Oi(e,"name",{value:t,configurable:!0}),"j");const Ni=Di(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,o=[],n=JSON.stringify({...e.options.jiti,alias:{...je(e,"jit"),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},null,2).replace('"__$BABEL_PLUGINS"',Array.isArray(t)?"["+t.map((r,s)=>{if(Array.isArray(r)){const[i,...a]=r;return o.push(i),"["+["plugin"+s,...a.map(l=>JSON.stringify(l))].join(", ")+"]"}return o.push(r),"plugin"+s}).join(",")+"]":"[]");for(const r of e.options.entries){const s=$(e.options.rootDir,e.options.outDir,r.name),i=Po(e.jiti.esmResolve(r.input,{try:!0})??r.input),a=i.replace(R,""),l=be(i),c=yr(l);let u=[];try{u=await Co(i,{extensions:we})}catch(d){j(e,`Cannot analyze ${i} for exports: ${d.toString()}`);return}const p=u.includes("default")||u.length===0;if(e.options.emitESM){const d=D(L(s),await Ce("jiti",{conditions:["node","import"],url:import.meta.url})),g=a+".d.mts";B(`${s}.mjs`,c+['import { createJiti } from "'+d+'";',...o.map((h,f)=>"import plugin"+f+' from "'+h+'";'),"","const jiti = createJiti(import.meta.url, "+n+");","",'/** @type {import("'+g+'")} */','const _module = await jiti.import("'+i+'");',p?`
70
- export default _module;`:"",...u.filter(h=>h!=="default").map(h=>`export const ${h} = _module.${h};`)].join(`
71
- `)),e.options.declaration&&B(`${s}.d.mts`,'export * from "'+g+`";
72
- `+(p?'export { default } from "'+g+'";':""))}if(e.options.emitCJS){const d=D(L(s),await Ce("jiti",{conditions:["node","require"],url:import.meta.url})),g=a+".d.cts";B(`${s}.cjs`,c+['const { createJiti } = require("'+d+'");',...o.map((h,f)=>"const plugin"+f+" = require("+JSON.stringify(h)+")"),"","const jiti = createJiti(__filename, "+n+");","",'/** @type {import("'+g+'")} */','module.exports = jiti("'+i+'")'].join(`
73
- `)),e.options.declaration&&B(s+".d.cts",'export * from "'+g+`";
74
- `+(p?'export { default } from "'+g+'";':""))}c&&(await ye(`${s}.cjs`),await ye(`${s}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Pi=Object.defineProperty,xe=m((e,t)=>Pi(e,"name",{value:t,configurable:!0}),"i$2");const Ci=xe(e=>{const{message:t,name:o="Error",stack:n}=e;if(!n)return n;const r=`${o}: ${t}
75
- `;return n.startsWith(r)?n.slice(r.length):n},"extractStack"),_i=xe(e=>`
68
+ `,e.raw(i)}return r&&e.raw("Σ Total dist size (byte size):",x(I(t.buildEntries.reduce((i,a)=>i+(a.bytes??0),0))),`
69
+ `),r},"showSizeInformation"),hi=ie((e,t)=>{const o=fi(e.options.entries,"environment","runtime"),r=[];for(const[n,s]of Object.entries(o))for(const[i,a]of Object.entries(s)){const l={...e};!e.options.dtsOnly&&(n!=="undefined"||i!=="undefined")&&e.logger.info("Preparing build for "+(n==="undefined"?"":x(n)+" environment"+(i==="undefined"?"":" with "))+(i==="undefined"?"":x(i)+" runtime")),l.options.rollup.replace?(l.options.rollup.replace.values===void 0&&(l.options.rollup.replace.values={}),n!=="undefined"&&(l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(n)}),l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","EdgeRuntime"].join(".")]:JSON.stringify(i==="edge-light")}):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";n!=="undefined"&&(c+=n+"/"),i!=="undefined"&&(c+=i+"/");let p=!1;l.options.minify!==void 0&&(p=l.options.minify),n==="development"?p=!1:n==="production"&&(p=!0);const u=[],d=[],g=[],h=[];for(const m of a)m.cjs&&m.esm?u.push(m):m.cjs?g.push(m):m.esm?d.push(m):m.declaration&&h.push(m);if(u.length>0){const m={...l,options:{...l.options,emitCJS:!0,emitESM:!0,entries:u,minify:p}};if(e.options.dtsOnly||r.push(ve(m,t,c)),e.options.declaration){const y=m.options.entries.filter(b=>b.declaration);y.length>0&&r.push(Q({...m,options:{...m.options,entries:y}},t,c))}}if(d.length>0){const m={...l,options:{...l.options,emitCJS:!1,emitESM:!0,entries:d,minify:p}};if(e.options.dtsOnly||r.push(ve(m,t,c)),e.options.declaration){const y=m.options.entries.filter(b=>b.declaration);y.length>0&&r.push(Q({...m,options:{...m.options,entries:y}},t,c))}}if(g.length>0){const m={...l,options:{...l.options,emitCJS:!0,emitESM:!1,entries:g,minify:p}};if(e.options.dtsOnly||r.push(ve(m,t,c)),e.options.declaration){const y=m.options.entries.filter(b=>b.declaration);y.length>0&&r.push(Q({...m,options:{...m.options,entries:y}},t,c))}}if(l.options.declaration&&h.length>0){const m={...l,options:{...l.options,emitCJS:!1,emitESM:!1,entries:h,minify:p}};r.push(Q(m,t,c))}}return r.filter(Boolean)},"prepareRollupConfig"),yi=ie(async(e,t)=>{await e.hooks.callHook("build:before",e),await Promise.all(hi(e,t)),e.logger.success(po(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const o of go(w(e.options.rootDir,e.options.outDir))){let r=e.buildEntries.find(n=>w(e.options.rootDir,e.options.outDir,n.path)===o.path);if(r||(r={chunk:!0,path:o.path},e.buildEntries.push(r)),!r.bytes){const n=await it($(e.options.rootDir,e.options.outDir,o.path));r.bytes=n.size}}return await e.hooks.callHook("build:done",e),gi(e.logger,e)},"build");var vi=Object.defineProperty,bi=f((e,t)=>vi(e,"name",{value:t,configurable:!0}),"r$4");const j=bi((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var wi=Object.defineProperty,Vt=f((e,t)=>wi(e,"name",{value:t,configurable:!0}),"t$4");const se=Vt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),je=Vt((e,t,o,r)=>{if(e==="module-sync")return"esm";if(r){const i=se(r);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[n,...s]=t;return je(n,s,o,r)},"inferExportType");var $i=Object.defineProperty,ji=f((e,t)=>$i(e,"name",{value:t,configurable:!0}),"y$1");const ki=new Set(["electron","import","require","node","node-addons","default","types","deno","browser","module-sync","bun","workerd",...bt,...oe]),Oe=ji((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=se(e);if(n&&n!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:n??t}]}if(typeof e=="object"){const n=Object.entries(e).filter(([i])=>!i.endsWith(".json"));let s=[];for(const[i,a]of n)if(typeof a=="string"){let l={};Number.isInteger(+i)?l={exportKey:"*"}:i.startsWith("./")?l={exportKey:i.replace("./","")}:l={exportKey:i==="."?".":"*",subKey:i},s.push({...l,file:a,key:"exports",type:je(i,r,t,a)})}else if(typeof a=="object"&&a!==null)for(const[l,c]of Object.entries(a)){if(o===!1&&l==="types")continue;const p=Number.isInteger(+i)?l:i;typeof c=="string"?s.push({exportKey:p.replace("./",""),file:c,key:"exports",...ki.has(l)?{subKey:l}:{},type:je(l,r,t,c)}):s=[...s,...Oe({[p]:c},t,o,[...r,l])]}return s}return[]},"extractExportFilenames");var xi=Object.defineProperty,ue=f((e,t)=>xi(e,"name",{value:t,configurable:!0}),"c$4");const Ei=ue((e,t)=>e.key==="exports"&&e.subKey===H?H:e.key==="exports"&&e.subKey===Ie?Ie:t,"getEnvironment"),Z=ue((e,t,o,r,n,s,i)=>{const a=Ei(n,s.environment);let l="node";for(const u of bt)if(n.file.includes("."+u+".")||n.subKey===u){l=u;break}let c=e.find(u=>u.input===t&&u.environment===a&&u.runtime===l);c===void 0?c=e[e.push({environment:a,exportKey:new Set([n.exportKey].filter(Boolean)),input:t,runtime:l})-1]:c.exportKey&&n.exportKey&&c.exportKey.add(n.exportKey),i&&(c.isGlob=!0),o&&(c.outDir=r),n.isExecutable?(c.executable=!0,c.declaration=!1,n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0)):(/\.d\.[mc]?ts$/.test(n.file)&&s.options.declaration!==!1&&(c.declaration=s.options.declaration),n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0));const p=n.file.replace(ut(n.file),"").replace(new RegExp(`^./${s.options.outDir.replace(/^\.\//,"")}/`),"");oe.has(n.subKey)&&!t.includes(p)&&(c.fileAlias=p)},"createOrUpdateEntry");let Ge=!1;const Xe=ue(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),Si=ue((e,t,o)=>{const r=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const n=e.type==="module"?"esm":"cjs";n==="esm"&&(o.options.emitESM=!0),n==="cjs"&&(o.options.emitCJS=!0);const s=Oe(e.exports,n,o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=se(l);if(c&&c!==n)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);s.push({file:l,isExecutable:!0,key:"bin",type:c??n})}}e.main&&s.push({file:e.main,key:"main",type:se(e.main)??n}),e.module&&s.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(Xe(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),s.push({file:e.types??e.typings,key:"types"}));const i=[];for(const a of s){o.options.declaration===void 0&&(a.key==="types"||a.subKey==="types")&&(o.options.declaration=a.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&a.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&a.type==="esm"&&(o.options.emitESM=!0);const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const p=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),u="(?<=/|$)",d=c?"":"\\.\\w+$";if(a.file.includes("/*")&&a.key==="exports"){Ge||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Ge=!0);const y=[],b=new RegExp(u+p.replace("*","(.*)")+d),k=new RegExp(u+p.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+d);for(const E of t)(b.test(E)||oe.has(a.subKey)&&k.test(E))&&y.push(E);if(y.length===0){r.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const E of y)Z(i,E,c,l,a,o,!0);continue}const g=new RegExp(u+p+d);let h=t.find(y=>g.test(y));if(oe.has(a.subKey)&&h===void 0){const y=new RegExp(u+p.replace(/(.*)\.[^.]*$/,"$1")+d);h=t.find(b=>y.test(b))}if(h===void 0){T($(o.options.rootDir,a.file))||r.push(`Could not find entrypoint for \`${a.file}\``);continue}(h.endsWith(".ts")||h.endsWith(".cts")||h.endsWith(".mts"))&&T(h)&&Xe(o);const m=te(h.replace(J,""));T(m+".cts")&&T(m+".mts")?(Z(i,m+".cts",c,l,{...a,type:"cjs"},o,!1),Z(i,m+".mts",c,l,{...a,type:"esm"},o,!1)):Z(i,h,c,l,a,o,!1)}return{entries:i,warnings:r}},"inferEntries");var Oi=Object.defineProperty,Di=f((e,t)=>Oi(e,"name",{value:t,configurable:!0}),"o$3");const Ni=Di((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 Pi=Object.defineProperty,Ci=f((e,t)=>Pi(e,"name",{value:t,configurable:!0}),"t$3");const _i={hooks:{"build:prepare":Ci(function(e){if(e.options.entries.length>0)return;const t=w(e.options.rootDir,e.options.sourceDir);if(!nt(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=ho(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&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(r.publishConfig).join(", ")+'".'),e.logger.debug(r.publishConfig),r=Ni(r,e.options.declaration));const n=Si(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:",x(e.options.entries.map(s=>s.fileAlias?C(s.fileAlias)+" => "+C(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):C(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),M([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var Ti=Object.defineProperty,Ii=f((e,t)=>Ti(e,"name",{value:t,configurable:!0}),"t$2");const Mi=Ii(async(e,t)=>{if(e==="auto")e=_i;else{if(e==="none")return{};typeof e=="string"&&(e=await t.import(e)||{})}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Ai=Object.defineProperty,Ri=f((e,t)=>Ai(e,"name",{value:t,configurable:!0}),"j");const Fi=Ri(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,o=[],r=JSON.stringify({...e.options.jiti,alias:{...Se(e,"jit"),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},null,2).replace('"__$BABEL_PLUGINS"',Array.isArray(t)?"["+t.map((n,s)=>{if(Array.isArray(n)){const[i,...a]=n;return o.push(i),"["+["plugin"+s,...a.map(l=>JSON.stringify(l))].join(", ")+"]"}return o.push(n),"plugin"+s}).join(",")+"]":"[]");for(const n of e.options.entries){const s=$(e.options.rootDir,e.options.outDir,n.name),i=Fo(e.jiti.esmResolve(n.input,{try:!0})??n.input),a=i.replace(J,""),l=ke(i),c=Sn(l);let p=[];try{p=await Jo(i,{extensions:xe})}catch(d){j(e,`Cannot analyze ${i} for exports: ${d.toString()}`);return}const u=p.includes("default")||p.length===0;if(e.options.emitESM){const d=N(K(s),await Re("jiti",{conditions:["node","import"],url:import.meta.url})),g=a+".d.mts";L(`${s}.mjs`,c+['import { createJiti } from "'+d+'";',...o.map((h,m)=>"import plugin"+m+' from "'+h+'";'),"","const jiti = createJiti(import.meta.url, "+r+");","",'/** @type {import("'+g+'")} */','const _module = await jiti.import("'+i+'");',u?`
70
+ export default _module;`:"",...p.filter(h=>h!=="default").map(h=>`export const ${h} = _module.${h};`)].join(`
71
+ `)),e.options.declaration&&L(`${s}.d.mts`,'export * from "'+g+`";
72
+ `+(u?'export { default } from "'+g+'";':""))}if(e.options.emitCJS){const d=N(K(s),await Re("jiti",{conditions:["node","require"],url:import.meta.url})),g=a+".d.cts";L(`${s}.cjs`,c+['const { createJiti } = require("'+d+'");',...o.map((h,m)=>"const plugin"+m+" = require("+JSON.stringify(h)+")"),"","const jiti = createJiti(__filename, "+r+");","",'/** @type {import("'+g+'")} */','module.exports = jiti("'+i+'")'].join(`
73
+ `)),e.options.declaration&&L(s+".d.cts",'export * from "'+g+`";
74
+ `+(u?'export { default } from "'+g+'";':""))}c&&(await $e(`${s}.cjs`),await $e(`${s}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Ji=Object.defineProperty,De=f((e,t)=>Ji(e,"name",{value:t,configurable:!0}),"i$2");const Bi=De(e=>{const{message:t,name:o="Error",stack:r}=e;if(!r)return r;const n=`${o}: ${t}
75
+ `;return r.startsWith(n)?r.slice(n.length):r},"extractStack"),Wi=De(e=>`
76
76
  ${e.replaceAll(/^\n|\n$/g,"")}
77
- `,"normalizeCodeFrame"),Bt=xe(e=>{const t=Ci(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
78
- file: ${k(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
79
- `+ro(_i(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
80
- ${t}`)},"enhanceRollupError");var Mi=Object.defineProperty,Lt=m((e,t)=>Mi(e,"name",{value:t,configurable:!0}),"n$1");const se="rollup-watch.json",Ke=Lt(({context:e,fileCache:t,mode:o,runBuilder:n,watcher:r})=>{const s="watcher:"+o;r.on("change",(i,{event:a})=>{e.logger.info({message:`${k(D(".",i))} was ${a}d`,prefix:s})}),r.on("restart",()=>{e.logger.info({message:"Rebuilding ...",prefix:s})}),r.on("event",async i=>{switch(i.code){case"END":{e.logger.success({message:"Rebuild finished",prefix:s});break}case"BUNDLE_START":{e.logger.info({message:k("build started..."),prefix:s});break}case"BUNDLE_END":{await i.result.close(),t.set(o==="bundle"?se:"dts-"+se,i.result.cache),e.logger.raw(`
81
- ⚡️ Build run in `+i.duration+`ms
77
+ `,"normalizeCodeFrame"),Ht=De(e=>{const t=Bi(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
78
+ file: ${x(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
79
+ `+uo(Wi(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
80
+ ${t}`)},"enhanceRollupError");var Li=Object.defineProperty,qt=f((e,t)=>Li(e,"name",{value:t,configurable:!0}),"u$3");const ae="rollup-watch.json",Ye=qt(({context:e,doOnSuccessCleanup:t,fileCache:o,mode:r,runBuilder:n,runOnsuccess:s,watcher:i})=>{const a="watcher:"+r;i.on("change",async(l,{event:c})=>{await t?.(),e.logger.info({message:`${x(N(".",l))} was ${c}d`,prefix:a})}),i.on("restart",()=>{e.logger.info({message:"Rebuilding ...",prefix:a})}),i.on("event",async l=>{switch(l.code){case"END":{e.logger.success({message:"Rebuild finished",prefix:a}),await s?.();break}case"BUNDLE_START":{e.logger.info({message:x("build started..."),prefix:a});break}case"BUNDLE_END":{await l.result.close(),o.set(r==="bundle"?ae:"dts-"+ae,l.result.cache),e.logger.raw(`
81
+ ⚡️ Build run in `+l.duration+`ms
82
82
 
83
- `),n&&await n(!0);break}case"ERROR":{Bt(i.error),e.logger.error({context:[i.error],message:"Rebuild failed: "+i.error.message,prefix:s});break}}})},"watchHandler"),Ti=Lt(async(e,t,o)=>{const n=await Rt(e,t);if(await e.hooks.callHook("rollup:options",e,n),Object.keys(n.input).length===0)return;(!e.options.rollup.isolatedDeclarations||!e.options.isolatedDeclarationTransformer)&&(n.cache=t.get(se)),e.options.rollup.watch&&typeof n.watch=="object"&&n.watch.include===void 0&&(n.watch={...n.watch,...e.options.rollup.watch},n.watch.include=[w(e.options.sourceDir,"**","*"),"package.json"],Array.isArray(e.options.rollup.watch.include)?n.watch.include=[...n.watch.include,...e.options.rollup.watch.include]:e.options.rollup.watch.include&&n.watch.include.push(e.options.rollup.watch.include),n.watch.chokidar={cwd:e.options.rootDir,...n.watch.chokidar,ignored:["**/.git/**","**/node_modules/**","**/test-results/**",...n.watch.chokidar?.ignored??[]]});const r=Oe(n);await e.hooks.callHook("rollup:watch",e,r);const s=[...Array.isArray(n.input)?n.input:typeof n.input=="string"?[n.input]:Object.keys(n.input??{})];let i="Starting watcher for entries:";for(const a of s)i+=M(`
84
- └─ ${D(process.cwd(),a)}`);if(e.logger.info(i),Ke({context:e,fileCache:t,mode:"bundle",runBuilder:o,watcher:r}),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer)e.logger.info({message:"Using isolated declaration transformer to generate declaration files...",prefix:"dts"});else if(e.options.declaration){const a=await Ft(e,t);a.cache=t.get("dts-"+se),await e.hooks.callHook("rollup:dts:options",e,a);const l=Oe(a);await e.hooks.callHook("rollup:watch",e,l),Ke({context:e,fileCache:t,mode:"types",watcher:l})}},"watch");var Ai=Object.defineProperty,Wt=m((e,t)=>Ai(e,"name",{value:t,configurable:!0}),"s$4");const Ii=Wt(e=>{try{JSON.parse(e)}catch{return!1}return!0},"isJson");let Ri=class{static{m(this,"g")}static{Wt(this,"FileCache")}#n;#e;#r;#t=!0;#o=new Map;constructor(t,o,n,r){this.#n=t,this.#r=n,o===void 0?r.debug({message:"Could not create cache directory.",prefix:"file-cache"}):(this.#e=o,r.debug({message:"Cache path is: "+this.#e,prefix:"file-cache"}))}set isEnabled(t){this.#t=t}has(t,o){return!this.#t||this.#e===void 0?!1:C(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(!C(n))return;const r=be(n);if(Ii(r)){const s=JSON.parse(r);return this.#o.set(n,s),s}return this.#o.set(n,r),r}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)),B(r,o,{overwrite:!0})}getFilePath(t,o){let n=t.replaceAll(ee(this.#n),"");return n=n.replaceAll(":","-"),w(this.#e,this.#r,o?.replaceAll(":","-")??"",ee(n))}};var Fi=Object.defineProperty,Ji=m((e,t)=>Fi(e,"name",{value:t,configurable:!0}),"t$1");const Bi=Ji(async(e,t="")=>{let o=t;if(!o){const n=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for await(const r of n)if(await ot(w(e,r))){o="./"+r;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(o))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");return o},"findPackemFile");var Li=Object.defineProperty,Z=m((e,t)=>Li(e,"name",{value:t,configurable:!0}),"l$3");const Wi=W,Ui=Z((e,t)=>{const{sideEffects:o}=t;let n;if(typeof o=="boolean")n=Z(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)n=Z(()=>!1,"hasSideEffects");else{const r=o.map(s=>s.includes("/")?s:`**/${s}`);n=Wi(r,null,{resolve:e})}else n=Z(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var zi=Object.defineProperty,Ki=m((e,t)=>zi(e,"name",{value:t,configurable:!0}),"n");const Ut=Ki(e=>{const t=w(e,"package.json");if(!C(t))throw new Error("package.json not found at "+t);return{packageJson:Bo(t),packageJsonPath:t}},"loadPackageJson");var Vi=Object.defineProperty,Hi=m((e,t)=>Vi(e,"name",{value:t,configurable:!0}),"r$2");const Ve=Hi((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
83
+ `),await n?.(!0);break}case"ERROR":{Ht(l.error),e.logger.error({context:[l.error],message:"Rebuild failed: "+l.error.message,prefix:a});break}}})},"watchHandler"),Ki=qt(async(e,t,o,r,n)=>{const s=await Ut(e,t);if(await e.hooks.callHook("rollup:options",e,s),Object.keys(s.input).length===0)return;(!e.options.rollup.isolatedDeclarations||!e.options.isolatedDeclarationTransformer)&&(s.cache=t.get(ae)),e.options.rollup.watch&&typeof s.watch=="object"&&s.watch.include===void 0&&(s.watch={...s.watch,...e.options.rollup.watch},s.watch.include=[w(e.options.sourceDir,"**","*"),"package.json","packem.config.*"],Array.isArray(e.options.rollup.watch.include)?s.watch.include=[...s.watch.include,...e.options.rollup.watch.include]:e.options.rollup.watch.include&&s.watch.include.push(e.options.rollup.watch.include),s.watch.chokidar={cwd:e.options.rootDir,...s.watch.chokidar,ignored:["**/.git/**","**/node_modules/**","**/test-results/**",...s.watch.chokidar?.ignored??[]]});const i=Te(s);await e.hooks.callHook("rollup:watch",e,i);const a=[...Array.isArray(s.input)?s.input:typeof s.input=="string"?[s.input]:Object.keys(s.input??{})];let l="Starting watcher for entries:";for(const c of a)l+=M(`
84
+ └─ ${N(process.cwd(),c)}`);if(e.logger.info(l),Ye({context:e,doOnSuccessCleanup:n,fileCache:t,mode:"bundle",runBuilder:o,runOnsuccess:r,watcher:i}),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer)e.logger.info({message:"Using isolated declaration transformer to generate declaration files...",prefix:"dts"});else if(e.options.declaration){const c=await zt(e,t);c.cache=t.get("dts-"+ae),await e.hooks.callHook("rollup:dts:options",e,c);const p=Te(c);await e.hooks.callHook("rollup:watch",e,p),Ye({context:e,fileCache:t,mode:"types",watcher:p})}},"watch");var Ui=Object.defineProperty,Gt=f((e,t)=>Ui(e,"name",{value:t,configurable:!0}),"s$4");const zi=Gt(e=>{try{JSON.parse(e)}catch{return!1}return!0},"isJson");let Vi=class{static{f(this,"g")}static{Gt(this,"FileCache")}#r;#e;#n;#t=!0;#o=new Map;constructor(t,o,r,n){this.#r=t,this.#n=r,o===void 0?n.debug({message:"Could not create cache directory.",prefix:"file-cache"}):(this.#e=o,n.debug({message:"Cache path is: "+this.#e,prefix:"file-cache"}))}set isEnabled(t){this.#t=t}has(t,o){return!this.#t||this.#e===void 0?!1:T(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(!T(r))return;const n=ke(r);if(zi(n)){const s=JSON.parse(n);return this.#o.set(r,s),s}return this.#o.set(r,n),n}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)),L(n,o,{overwrite:!0})}getFilePath(t,o){let r=t.replaceAll(te(this.#r),"");return r=r.replaceAll(":","-"),w(this.#e,this.#n,o?.replaceAll(":","-")??"",te(r))}};var Hi=Object.defineProperty,qi=f((e,t)=>Hi(e,"name",{value:t,configurable:!0}),"t$1");const Gi=qi(async(e,t="")=>{let o=t;if(!o){const r=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const n of r)if(await ct(w(e,n))){o="./"+n;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(o))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");return o},"findPackemFile");var Xi=Object.defineProperty,ee=f((e,t)=>Xi(e,"name",{value:t,configurable:!0}),"l$4");const Yi=U,Qi=ee((e,t)=>{const{sideEffects:o}=t;let r;if(typeof o=="boolean")r=ee(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)r=ee(()=>!1,"hasSideEffects");else{const n=o.map(s=>s.includes("/")?s:`**/${s}`);r=Yi(n,null,{resolve:e})}else r=ee(()=>null,"hasSideEffects");return r},"getPackageSideEffect");function Zi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}f(Zi,"getDefaultExportFromCjs");var be,Qe;function es(){if(Qe)return be;Qe=1;var e=qo,t=e.spawn,o=e.exec;be=f(function(i,a,l){if(typeof a=="function"&&l===void 0&&(l=a,a=void 0),i=parseInt(i),Number.isNaN(i)){if(l)return l(new Error("pid must be a number"));throw new Error("pid must be a number")}var c={},p={};switch(c[i]=[],p[i]=1,process.platform){case"win32":o("taskkill /pid "+i+" /T /F",l);break;case"darwin":s(i,c,p,function(u){return t("pgrep",["-P",u])},function(){r(c,a,l)});break;default:s(i,c,p,function(u){return t("ps",["-o","pid","--no-headers","--ppid",u])},function(){r(c,a,l)});break}},"treeKill");function r(i,a,l){var c={};try{Object.keys(i).forEach(function(p){i[p].forEach(function(u){c[u]||(n(u,a),c[u]=1)}),c[p]||(n(p,a),c[p]=1)})}catch(p){if(l)return l(p);throw p}if(l)return l()}f(r,"killAll");function n(i,a){try{process.kill(parseInt(i,10),a)}catch(l){if(l.code!=="ESRCH")throw l}}f(n,"killPid");function s(i,a,l,c,p){var u=c(i),d="";u.stdout.on("data",function(m){var m=m.toString("ascii");d+=m});var g=f(function(h){if(delete l[i],h!=0){Object.keys(l).length==0&&p();return}d.match(/\d+/g).forEach(function(m){m=parseInt(m,10),a[i].push(m),a[m]=[],l[m]=1,s(m,a,l,c,p)})},"onClose");u.on("close",g)}return f(s,"buildProcessTree"),be}f(es,"requireTreeKill");var ts=es();const os=Zi(ts);var rs=Object.defineProperty,Xt=f((e,t)=>rs(e,"name",{value:t,configurable:!0}),"l$3");const ns=Xt(e=>process.platform==="win32"&&"cmd"in e&&"code"in e&&typeof e.cmd=="string"&&e.cmd.startsWith("taskkill")&&e.code===128,"isTaskKillCmdProcessNotFoundError"),is=Xt(async({pid:e,signal:t})=>await new Promise((o,r)=>{if(!Number.isInteger(e)||e<=0){r(new Error("Invalid process ID"));return}os(e,t,n=>{if(n&&!ns(n)){r(n);return}o()})}),"killProcess");var ss=Object.defineProperty,as=f((e,t)=>ss(e,"name",{value:t,configurable:!0}),"n");const Yt=as(e=>{const t=w(e,"package.json");if(!T(t))throw new Error("package.json not found at "+t);return{packageJson:Go(t),packageJsonPath:t}},"loadPackageJson");var ls=Object.defineProperty,cs=f((e,t)=>ls(e,"name",{value:t,configurable:!0}),"r$2");const Ze=cs((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
85
85
  `),e.logger.warn(`Build is done with some warnings:
86
86
 
87
87
  ${[...e.warnings].map(o=>`- ${o}`).join(`
88
- `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logBuildErrors");var qi=Object.defineProperty,zt=m((e,t)=>qi(e,"name",{value:t,configurable:!0}),"r$1");const He=zt(async(e,t)=>{if(typeof e.name!="string"){let o=it(e.input)?D(t.options.rootDir,e.input):nt(e.input);o.startsWith("./")&&(o=o.slice(2)),e.name=o.replace(new RegExp(`^${t.options.sourceDir}/`),"").replace(R,"")}if(!e.input)throw new Error(`Missing entry input: ${JSON.stringify(e)}`);Wo(e.input)&&(e.input=$(t.options.rootDir,e.input)),t.options.declaration&&e.declaration===void 0&&(e.declaration=t.options.declaration),e.executable&&(e.cjs===void 0||e.esm===void 0)?t.pkg.type==="commonjs"&&e.cjs===void 0&&t.options.emitCJS!==void 0?(e.cjs=t.options.emitCJS,e.esm=!1):t.pkg.type==="module"&&e.esm===void 0&&t.options.emitESM!==void 0&&(e.esm=t.options.emitESM,e.cjs=!1):e.cjs===void 0&&e.esm===void 0&&(t.options.emitCJS!==void 0&&(e.cjs=t.options.emitCJS),t.options.emitESM!==void 0&&(e.esm=t.options.emitESM)),e.outDir=$(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),Gi=zt(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:Pe(t)}:{...t,exportKey:t.exportKey??new Set,isGlob:Pe(t.input)});for(const t of e.options.entries.filter(o=>o.isGlob)){const{isGlob:o,...n}=t,r=["**/.git/**","**/node_modules/**","**/test-results/**"];if(e.options.rollup.watch){if(typeof e.options.rollup.watch.exclude=="string")r.push(e.options.rollup.watch.exclude);else if(Array.isArray(e.options.rollup.watch.exclude))for(const i of e.options.rollup.watch.exclude)typeof i=="string"&&r.push(i)}const s=No([n.input],{cwd:e.options.rootDir,dot:!1,ignore:r,onlyFiles:!0});if(s.length===0)throw new Lo("No files found in the glob pattern: "+k(w(e.options.rootDir,n.input)));for(const i of s)e.options.entries.push({...n,input:$(e.options.rootDir,i)});e.options.entries.splice(e.options.entries.indexOf(t),1)}for await(const t of e.options.entries.filter(o=>o.fileAlias===void 0))await He(t,e);for await(const t of e.options.entries.filter(o=>o.fileAlias!==void 0))t.name=t.fileAlias,t.fileAlias=void 0,await He(t,e)},"prepareEntries");var Yi=Object.defineProperty,Xi=m((e,t)=>Yi(e,"name",{value:t,configurable:!0}),"o");const Qi=Xi(e=>{if(e.options.validation?.packageJson?.dependencies===!1)return;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(e.pkg?.dependencies)for(const r of Object.keys(e.pkg?.dependencies))o.delete(r);for(const r of t){const s=ft(r);!he(e.options.externals,r)&&!r.startsWith("chunks/")&&e.pkg?.dependencies?.[s]===void 0&&e.pkg?.peerDependencies?.[s]===void 0&&n.add(r)}o.size>0&&j(e,`Potential unused dependencies found: ${[...o].map(r=>k(r)).join(", ")}`),n.size>0&&j(e,`Potential implicit dependencies found: ${[...n].map(r=>k(r)).join(", ")}`)},"validateDependencies");var Zi=Object.defineProperty,Kt=m((e,t)=>Zi(e,"name",{value:t,configurable:!0}),"i$1");const es=Kt((e,t)=>Uo(e,t)<=e.length/3||t.includes(e),"isSimilar"),ts=Kt((e,t)=>{const o=e.toLowerCase();return t.filter(n=>es(n.toLowerCase(),o))},"findAlternatives");var os=Object.defineProperty,qe=m((e,t)=>os(e,"name",{value:t,configurable:!0}),"r");const ns=qe(e=>{const{options:t}=e;if(t.validation?.packageJson?.exports===!1)return;const o=t.validation?.packageJson,n=new Set([t.declaration&&o?.types?e.pkg.types:"",t.declaration&&o?.types?e.pkg.typings:"",...t.dtsOnly||o?.bin===!1?[""]:typeof e.pkg.bin=="string"?[e.pkg.bin]:Object.values(e.pkg.bin??{}),t.dtsOnly&&o?.main===!1?"":e.pkg.main,t.dtsOnly&&o?.module===!1?"":e.pkg.module,...o?.exports===!1?[]:ke(e.pkg.exports,e.pkg.type==="module"?"esm":"cjs",t.declaration).map(a=>t.dtsOnly?a.subKey==="types"?a.file:void 0:a.file)].filter(Boolean).map(a=>a&&$(t.rootDir,a.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),r=[];for(const a of n)a&&!a.includes("*")&&!Xe(a)&&r.push(a.replace(`${t.rootDir}/`,""));const s=qe(a=>D(t.rootDir,$(t.outDir,a)),"rPath"),i=e.buildEntries.filter(a=>!a.chunk).map(a=>s(a.path));if(r.length>0){let a="Potential missing or wrong package.json files:";for(const l of r){const c=ts(l,i);a+=`
89
- - `+k(l)+(c.length>0?io` (did you mean ${c.map(u=>`"${u}"`).join(", ")}?)`:"")}j(e,a)}},"validatePackageEntries");var rs=Object.defineProperty,is=m((e,t)=>rs(e,"name",{value:t,configurable:!0}),"l$1");const ss=is(e=>{const{options:{validation:t},pkg:o}=e;o.name===void 0&&t?.packageJson?.name!==!1&&j(e,"The 'name' field is missing in your package.json. Please provide a valid package name."),t?.packageJson?.files!==!1&&(o.files===void 0?j(e,"The 'files' field is missing in your package.json. Add the files to be included in the package."):o.files.length===0?j(e,"The 'files' field in your package.json is empty. Please specify the files to be included in the package."):o.files.some(s=>s.includes(e.options.outDir))||j(e,`The 'files' field in your package.json is missing the '${e.options.outDir}' directory. Ensure the output directory is included.`));const n=o.type==="commonjs"||o.type===void 0,r=o.type==="module";if(n?(t?.packageJson?.main!==!1&&(o.main===void 0&&j(e,"The 'main' field is missing in your package.json. This field should point to your main entry file."),o.main?.includes(".mjs")&&j(e,"The 'main' field in your package.json should not use a '.mjs' extension for CommonJS modules.")),t?.packageJson?.module!==!1&&(o.module===void 0&&e.options.emitESM&&j(e,"The 'module' field is missing in your package.json, but you are emitting ES modules."),o.module&&o.main&&o.module===o.main&&j(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`),e.options.emitESM&&o.module?.includes(".cjs")&&j(e,"The 'module' field in your package.json should not use a '.cjs' extension for ES modules."))):r&&(o.exports===void 0&&!e.options.emitCJS?t?.packageJson?.exports!==!1&&j(e,"The 'exports' field is missing in your package.json. Define module exports explicitly."):e.options.emitCJS&&(t?.packageJson?.main!==!1&&o.main===void 0&&j(e,"The 'main' field is missing in your package.json. This field is needed when emitting CommonJS modules."),t?.packageJson?.module!==!1&&(o.module===void 0&&j(e,"The 'module' field is missing in your package.json. This field is necessary when emitting ES modules."),o.module?.includes(".cjs")&&j(e,"The 'module' field should not use a '.cjs' extension for ES modules."),o.module&&o.main&&o.module===o.main&&j(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`)),t?.packageJson?.exports!==!1&&o.exports===void 0&&j(e,"The 'exports' field is missing in your package.json. This field is required for defining explicit exports."))),o.exports,t?.packageJson?.bin!==!1){if(typeof o.bin=="string"&&o.bin.includes(n?".mjs":".cjs"))j(e,`The 'bin' field in your package.json should not use a ${n?".mjs":".cjs"} extension for ${n?"CommonJS":"ES modules"} binaries.`);else if(typeof o.bin=="object")for(const[s,i]of Object.entries(o.bin))i&&i.includes(n?".mjs":".cjs")&&j(e,`The 'bin.${s}' field in your package.json should not use a ${n?".mjs":".cjs"} extension for ${n?"CommonJS":"ES modules"} binaries.`)}if(e.options.declaration){let s=!0;o.type==="module"&&(s=!!o.main?.endsWith(".cjs")),o.types===void 0&&o.typings===void 0&&s&&t?.packageJson?.types!==!1&&j(e,"The 'types' field is missing in your package.json. This field should point to your type definitions file."),(e.options.declaration===!0||e.options.declaration==="compatible")&&s&&t?.packageJson?.typesVersions!==!1&&(o.typesVersions===void 0||Object.keys(o.typesVersions).length===0)&&j(e,"No 'typesVersions' field found in your package.json. Consider adding this field, or change the declaration option to 'node16' or 'false'.")}},"validatePackageFields");var as=Object.defineProperty,ls=m((e,t)=>as(e,"name",{value:t,configurable:!0}),"i");const cs=ls(e=>{const{packageJson:t}=Ut(e.options.rootDir);e.pkg=t,Qi(e),ss(e),ns(e)},"validator");var ps=Object.defineProperty,us=m((e,t)=>ps(e,"name",{value:t,configurable:!0}),"a");const ds=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,ms=new Set(["abstract","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]),Ge=us(e=>{if(!Array.isArray(e)&&e!==null)for(const[t,o]of Object.entries(e)){if(typeof t!="string"||t.trim()==="")throw new Error(`Alias name "${t}" is invalid. Alias names should be non-empty strings.`);if(ds.test(t))throw new Error(`Alias name "${t}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(ms.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const n=$(o);if(!C(n))throw new Error(`Target path "${n}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var fs=Object.defineProperty,O=m((e,t)=>fs(e,"name",{value:t,configurable:!0}),"u");const gs=O(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"),hs=O((e,t,o,n,r,s,i,a,l)=>{const c=gs(l?.config.compilerOptions?.jsx),u=fo(s,r,i,{alias:{},cjsInterop:!1,clean:!0,debug:n,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[...Ee.builtinModules,...Ee.builtinModules.map(p=>`node:${p}`)],failOnWarn:!0,fileCache:!0,jiti:{alias:{},debug:n,interopDefault:!0},minify:o===K,name:(a.name??"").split("/").pop()??"default",outDir:l?.config.compilerOptions?.outDir??"dist",rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{extensions:[".mjs",".js",".json",".node",".cjs"],ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:l?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,moduleResolution:100,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",exclude:J,jsx:c,jsxDev:l?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:l?.config.compilerOptions?.jsxFactory,jsxFragment:l?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:l?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:l?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:l?.config},isolatedDeclarations:{exclude:J,ignoreErrors:!1,include:U},json:{preferConst:!0},license:{dependenciesTemplate:O((p,d,g)=>`
88
+ `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logBuildErrors");var ps=Object.defineProperty,Qt=f((e,t)=>ps(e,"name",{value:t,configurable:!0}),"r$1");const et=Qt(async(e,t)=>{if(typeof e.name!="string"){let o=dt(e.input)?N(t.options.rootDir,e.input):pt(e.input);o.startsWith("./")&&(o=o.slice(2)),e.name=o.replace(new RegExp(`^${t.options.sourceDir}/`),"").replace(J,"")}if(!e.input)throw new Error(`Missing entry input: ${JSON.stringify(e)}`);Yo(e.input)&&(e.input=$(t.options.rootDir,e.input)),t.options.declaration&&e.declaration===void 0&&(e.declaration=t.options.declaration),e.executable&&(e.cjs===void 0||e.esm===void 0)?t.pkg.type==="commonjs"&&e.cjs===void 0&&t.options.emitCJS!==void 0?(e.cjs=t.options.emitCJS,e.esm=!1):t.pkg.type==="module"&&e.esm===void 0&&t.options.emitESM!==void 0&&(e.esm=t.options.emitESM,e.cjs=!1):e.cjs===void 0&&e.esm===void 0&&(t.options.emitCJS!==void 0&&(e.cjs=t.options.emitCJS),t.options.emitESM!==void 0&&(e.esm=t.options.emitESM)),e.outDir=$(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),us=Qt(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:Ae(t)}:{...t,exportKey:t.exportKey??new Set,isGlob:Ae(t.input)});for(const t of e.options.entries.filter(o=>o.isGlob)){const{isGlob:o,...r}=t,n=["**/.git/**","**/node_modules/**","**/test-results/**"];if(e.options.rollup.watch){if(typeof e.options.rollup.watch.exclude=="string")n.push(e.options.rollup.watch.exclude);else if(Array.isArray(e.options.rollup.watch.exclude))for(const i of e.options.rollup.watch.exclude)typeof i=="string"&&n.push(i)}const s=Ro([r.input],{cwd:e.options.rootDir,dot:!1,ignore:n,onlyFiles:!0});if(s.length===0)throw new Xo("No files found in the glob pattern: "+x(w(e.options.rootDir,r.input)));for(const i of s)e.options.entries.push({...r,input:$(e.options.rootDir,i)});e.options.entries.splice(e.options.entries.indexOf(t),1)}for(const t of e.options.entries.filter(o=>o.fileAlias===void 0))await et(t,e);for(const t of e.options.entries.filter(o=>o.fileAlias!==void 0))t.name=t.fileAlias,t.fileAlias=void 0,await et(t,e)},"prepareEntries");var ds=Object.defineProperty,fs=f((e,t)=>ds(e,"name",{value:t,configurable:!0}),"o");const ms=fs(e=>{if(e.options.validation?.packageJson?.dependencies===!1)return;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(e.pkg?.dependencies)for(const n of Object.keys(e.pkg?.dependencies))o.delete(n);for(const n of t){const s=$t(n);!we(e.options.externals,n)&&!n.startsWith("chunks/")&&e.pkg?.dependencies?.[s]===void 0&&e.pkg?.peerDependencies?.[s]===void 0&&r.add(n)}o.size>0&&j(e,`Potential unused dependencies found: ${[...o].map(n=>x(n)).join(", ")}`),r.size>0&&j(e,`Potential implicit dependencies found: ${[...r].map(n=>x(n)).join(", ")}`)},"validateDependencies");var gs=Object.defineProperty,Zt=f((e,t)=>gs(e,"name",{value:t,configurable:!0}),"i$1");const hs=Zt((e,t)=>Qo(e,t)<=e.length/3||t.includes(e),"isSimilar"),ys=Zt((e,t)=>{const o=e.toLowerCase();return t.filter(r=>hs(r.toLowerCase(),o))},"findAlternatives");var vs=Object.defineProperty,tt=f((e,t)=>vs(e,"name",{value:t,configurable:!0}),"r");const bs=tt(e=>{const{options:t}=e;if(t.validation?.packageJson?.exports===!1)return;const o=t.validation?.packageJson,r=new Set([t.declaration&&o?.types?e.pkg.types:"",t.declaration&&o?.types?e.pkg.typings:"",...t.dtsOnly||o?.bin===!1?[""]:typeof e.pkg.bin=="string"?[e.pkg.bin]:Object.values(e.pkg.bin??{}),t.dtsOnly&&o?.main===!1?"":e.pkg.main,t.dtsOnly&&o?.module===!1?"":e.pkg.module,...o?.exports===!1?[]:Oe(e.pkg.exports,e.pkg.type==="module"?"esm":"cjs",t.declaration).map(a=>t.dtsOnly?a.subKey==="types"?a.file:void 0:a.file)].filter(Boolean).map(a=>a&&$(t.rootDir,a.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const a of r)a&&!a.includes("*")&&!nt(a)&&n.push(a.replace(`${t.rootDir}/`,""));const s=tt(a=>N(t.rootDir,$(t.outDir,a)),"rPath"),i=e.buildEntries.filter(a=>!a.chunk).map(a=>s(a.path));if(n.length>0){let a="Potential missing or wrong package.json files:";for(const l of n){const c=ys(l,i);a+=`
89
+ - `+x(l)+(c.length>0?fo` (did you mean ${c.map(p=>`"${p}"`).join(", ")}?)`:"")}j(e,a)}},"validatePackageEntries");var ws=Object.defineProperty,$s=f((e,t)=>ws(e,"name",{value:t,configurable:!0}),"l$1");const js=$s(e=>{const{options:{validation:t},pkg:o}=e;o.name===void 0&&t?.packageJson?.name!==!1&&j(e,"The 'name' field is missing in your package.json. Please provide a valid package name."),t?.packageJson?.files!==!1&&(o.files===void 0?j(e,"The 'files' field is missing in your package.json. Add the files to be included in the package."):o.files.length===0?j(e,"The 'files' field in your package.json is empty. Please specify the files to be included in the package."):o.files.some(s=>s.includes(e.options.outDir))||j(e,`The 'files' field in your package.json is missing the '${e.options.outDir}' directory. Ensure the output directory is included.`));const r=o.type==="commonjs"||o.type===void 0,n=o.type==="module";if(r?(t?.packageJson?.main!==!1&&(o.main===void 0&&j(e,"The 'main' field is missing in your package.json. This field should point to your main entry file."),o.main?.includes(".mjs")&&j(e,"The 'main' field in your package.json should not use a '.mjs' extension for CommonJS modules.")),t?.packageJson?.module!==!1&&(o.module===void 0&&e.options.emitESM&&j(e,"The 'module' field is missing in your package.json, but you are emitting ES modules."),o.module&&o.main&&o.module===o.main&&j(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`),e.options.emitESM&&o.module?.includes(".cjs")&&j(e,"The 'module' field in your package.json should not use a '.cjs' extension for ES modules."))):n&&(o.exports===void 0&&!e.options.emitCJS?t?.packageJson?.exports!==!1&&j(e,"The 'exports' field is missing in your package.json. Define module exports explicitly."):e.options.emitCJS&&(t?.packageJson?.main!==!1&&o.main===void 0&&j(e,"The 'main' field is missing in your package.json. This field is needed when emitting CommonJS modules."),t?.packageJson?.module!==!1&&(o.module===void 0&&j(e,"The 'module' field is missing in your package.json. This field is necessary when emitting ES modules."),o.module?.includes(".cjs")&&j(e,"The 'module' field should not use a '.cjs' extension for ES modules."),o.module&&o.main&&o.module===o.main&&j(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`)),t?.packageJson?.exports!==!1&&o.exports===void 0&&j(e,"The 'exports' field is missing in your package.json. This field is required for defining explicit exports."))),o.exports,t?.packageJson?.bin!==!1){if(typeof o.bin=="string"&&o.bin.includes(r?".mjs":".cjs"))j(e,`The 'bin' field in your package.json should not use a ${r?".mjs":".cjs"} extension for ${r?"CommonJS":"ES modules"} binaries.`);else if(typeof o.bin=="object")for(const[s,i]of Object.entries(o.bin))i&&i.includes(r?".mjs":".cjs")&&j(e,`The 'bin.${s}' field in your package.json should not use a ${r?".mjs":".cjs"} extension for ${r?"CommonJS":"ES modules"} binaries.`)}if(e.options.declaration){let s=!0;o.type==="module"&&(s=!!o.main?.endsWith(".cjs")),o.types===void 0&&o.typings===void 0&&s&&t?.packageJson?.types!==!1&&j(e,"The 'types' field is missing in your package.json. This field should point to your type definitions file."),(e.options.declaration===!0||e.options.declaration==="compatible")&&s&&t?.packageJson?.typesVersions!==!1&&(o.typesVersions===void 0||Object.keys(o.typesVersions).length===0)&&j(e,"No 'typesVersions' field found in your package.json. Consider adding this field, or change the declaration option to 'node16' or 'false'.")}},"validatePackageFields");var ks=Object.defineProperty,xs=f((e,t)=>ks(e,"name",{value:t,configurable:!0}),"i");const Es=xs(e=>{const{packageJson:t}=Yt(e.options.rootDir);e.pkg=t,ms(e),js(e),bs(e)},"validator");var Ss=Object.defineProperty,Os=f((e,t)=>Ss(e,"name",{value:t,configurable:!0}),"a");const Ds=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,Ns=new Set(["abstract","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]),ot=Os(e=>{if(!Array.isArray(e)&&e!==null)for(const[t,o]of Object.entries(e)){if(typeof t!="string"||t.trim()==="")throw new Error(`Alias name "${t}" is invalid. Alias names should be non-empty strings.`);if(Ds.test(t))throw new Error(`Alias name "${t}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(Ns.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const r=$(o);if(!T(r))throw new Error(`Target path "${r}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var Ps=Object.defineProperty,D=f((e,t)=>Ps(e,"name",{value:t,configurable:!0}),"u");const Cs=D(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"),_s=D((e,t,o,r,n,s,i,a,l)=>{const c=Cs(l?.config.compilerOptions?.jsx),p=$o(s,n,i,{alias:{},cjsInterop:!1,clean:!0,debug:r,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[...Ce.builtinModules,...Ce.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,fileCache:!0,jiti:{alias:{},debug:r,interopDefault:!0},minify:o===H,name:(a.name??"").split("/").pop()??"default",outDir:l?.config.compilerOptions?.outDir??"dist",rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{extensions:[".mjs",".js",".json",".node",".cjs"],ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:l?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,moduleResolution:100,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",exclude:W,jsx:c,jsxDev:l?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:l?.config.compilerOptions?.jsxFactory,jsxFragment:l?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:l?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:l?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:l?.config},isolatedDeclarations:{exclude:W,ignoreErrors:!1,include:z},json:{preferConst:!0},license:{dependenciesTemplate:D((u,d,g)=>`
90
90
  # Licenses of bundled dependencies
91
91
  The published ${g} artifact additionally contains code with the following licenses:
92
- `+(p.length>0?`${p.join(", ")}
92
+ `+(u.length>0?`${u.join(", ")}
93
93
 
94
94
  `:`
95
95
  `)+`# Bundled dependencies:
96
- `+d,"dependenciesTemplate"),dtsTemplate:O((p,d,g)=>`
96
+ `+d,"dependenciesTemplate"),dtsTemplate:D((u,d,g)=>`
97
97
  # Licenses of bundled types
98
98
  The published ${g} artifact additionally contains code with the following licenses:
99
- `+(p.length>0?`${p.join(", ")}
99
+ `+(u.length>0?`${u.join(", ")}
100
100
 
101
101
  `:`
102
102
  `)+`# Bundled types:
103
- `+d,"dtsTemplate")},node10Compatibility:{},patchTypes:{},polyfillNode:{},preserveDirectives:{exclude:J,include:U},preserveDynamicImports:!0,raw:{exclude:J,include:[/\.(md|txt|css|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,exportConditions:["module-sync"],extensions:we,preferBuiltins:!1},shebang:{replace:!1,shebang:"#!/usr/bin/env node"},shim:{exclude:J,include:U},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:l?.config.compilerOptions?.esModuleInterop===!1,include:U,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:o===K,...l?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(l.config.compilerOptions.jsx)?{jsxFragmentPragma:l.config.compilerOptions.jsxFragmentFactory,jsxImportSource:l.config.compilerOptions.jsxImportSource,jsxPragma:l.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...l.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...l?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:U,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:l?.config.compilerOptions?.experimentalDecorators,syntax:l?"typescript":"ecmascript",[l?"tsx":"jsx"]:!0},target:l?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:l?.config.compilerOptions?.emitDecoratorMetadata,decoratorVersion:"2022-03",legacyDecorator:l?.config.compilerOptions?.experimentalDecorators,react:{development:o!==K,pragma:l?.config.compilerOptions?.jsxFactory,pragmaFrag:l?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:l?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:l?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:Ui(t,a),preset:"recommended",propertyReadSideEffects:!0},visualizer:{},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:J}},rootDir:t,sourceDir:"src",sourcemap:!1,transformerName:void 0,typedoc:{excludePrivate:!0,groupOrder:["Classes","Constructors","Accessors","Methods","Functions","Namespaces","Variables","Enumerations","Interfaces","Type Aliases","*"],kindSortOrder:["Project","Module","Class","Interface","Function","Namespace","Variable","Enum","EnumMember","TypeAlias","Reference","Constructor","Property","Accessor","Method","Parameter","TypeParameter","TypeLiteral","CallSignature","ConstructorSignature","IndexSignature","GetSignature","SetSignature"],marker:"TYPEDOC",name:a.name??"unknown",pretty:!0,readme:"none",showConfig:n,tsconfig:l?.path}});if(!u.transformerName){const p=new Map([...Object.entries(a.dependencies??{}),...Object.entries(a.devDependencies??{})]);let d="0.0.0";if(p.has("esbuild"))u.transformerName="esbuild",d=p.get("esbuild");else if(p.has("@swc/core"))u.transformerName="swc",d=p.get("@swc/core");else if(p.has("sucrase"))u.transformerName="sucrase",d=p.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+k("rollup ")+ho),e.info({message:"Using "+k(u.transformerName)+" "+d,prefix:"transformer"})}return u.rollup.resolve&&u.rollup.resolve.preferBuiltins===!0&&(u.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),a.dependencies&&u.externals.push(...Object.keys(a.dependencies)),a.peerDependencies&&u.externals.push(...Object.keys(a.peerDependencies)),a.optionalDependencies&&u.externals.push(...Object.keys(a.optionalDependencies)),Ge(u.alias),u.rollup.alias&&u.rollup.alias.entries&&Ge(u.rollup.alias.entries),u},"generateOptions"),ys=O(async(e,t,o,n,r,s,i,a,l,c)=>{const u=await Si(i.preset??s.preset??"auto",c),p=hs(e,t,n,r,s,i,u,a,l);co(w(p.rootDir,p.outDir));const d={buildEntries:[],dependencyGraphMap:new Map,environment:n,hooks:go(),jiti:st(p.rootDir,p.jiti),logger:e,mode:o,options:p,pkg:a,tsconfig:l,usedImports:new Set,warnings:new Set};u.hooks&&d.hooks.addHooks(u.hooks),s.hooks&&d.hooks.addHooks(s.hooks),i.hooks&&d.hooks.addHooks(i.hooks),await d.hooks.callHook("build:prepare",d),d.options.emitESM===void 0&&d.logger.info("Emitting of ESM bundles, is disabled."),d.options.emitCJS===void 0&&d.logger.info("Emitting of CJS bundles, is disabled."),d.options.minify&&d.logger.info("Minification is enabled, the output will be minified");const g=a.dependencies?.typescript!==void 0||a.devDependencies?.typescript!==void 0;if(d.options.declaration&&d.tsconfig===void 0&&g)throw new Error("Cannot build declaration files without a tsconfig.json");return g?d.options.declaration===!1&&d.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(d.options.declaration=!1,d.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),d.options.declaration&&d.logger.info("Using typescript version: "+k(a.devDependencies?.typescript??a.dependencies?.typescript??"unknown")),d.options.declaration&&(a.dependencies?.typescript||a.devDependencies?.typescript)&&!d.tsconfig?.config.compilerOptions?.isolatedModules&&d.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
103
+ `+d,"dtsTemplate")},node10Compatibility:{},patchTypes:{},polyfillNode:{},preserveDirectives:{exclude:W,include:z},preserveDynamicImports:!0,raw:{exclude:W,include:[/\.(md|txt|css|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,exportConditions:["module-sync"],extensions:xe,preferBuiltins:!1},shebang:{replace:!1,shebang:"#!/usr/bin/env node"},shim:{exclude:W,include:z},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:l?.config.compilerOptions?.esModuleInterop===!1,include:z,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:o===H,...l?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(l.config.compilerOptions.jsx)?{jsxFragmentPragma:l.config.compilerOptions.jsxFragmentFactory,jsxImportSource:l.config.compilerOptions.jsxImportSource,jsxPragma:l.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...l.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...l?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:z,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:l?.config.compilerOptions?.experimentalDecorators,syntax:l?"typescript":"ecmascript",[l?"tsx":"jsx"]:!0},target:l?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:l?.config.compilerOptions?.emitDecoratorMetadata,decoratorVersion:"2022-03",legacyDecorator:l?.config.compilerOptions?.experimentalDecorators,react:{development:o!==H,pragma:l?.config.compilerOptions?.jsxFactory,pragmaFrag:l?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:l?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:l?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:Qi(t,a),preset:"recommended",propertyReadSideEffects:!0},visualizer:{},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:W}},rootDir:t,sourceDir:"src",sourcemap:!1,transformerName:void 0,typedoc:{excludePrivate:!0,groupOrder:["Classes","Constructors","Accessors","Methods","Functions","Namespaces","Variables","Enumerations","Interfaces","Type Aliases","*"],kindSortOrder:["Project","Module","Class","Interface","Function","Namespace","Variable","Enum","EnumMember","TypeAlias","Reference","Constructor","Property","Accessor","Method","Parameter","TypeParameter","TypeLiteral","CallSignature","ConstructorSignature","IndexSignature","GetSignature","SetSignature"],marker:"TYPEDOC",name:a.name??"unknown",pretty:!0,readme:"none",showConfig:r,tsconfig:l?.path}});if(!p.transformerName){const u=new Map([...Object.entries(a.dependencies??{}),...Object.entries(a.devDependencies??{})]);let d="0.0.0";if(u.has("esbuild"))p.transformerName="esbuild",d=u.get("esbuild");else if(u.has("@swc/core"))p.transformerName="swc",d=u.get("@swc/core");else if(u.has("sucrase"))p.transformerName="sucrase",d=u.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+x("rollup ")+ko),e.info({message:"Using "+x(p.transformerName)+" "+d,prefix:"transformer"})}return p.rollup.resolve&&p.rollup.resolve.preferBuiltins===!0&&(p.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),a.dependencies&&p.externals.push(...Object.keys(a.dependencies)),a.peerDependencies&&p.externals.push(...Object.keys(a.peerDependencies)),a.optionalDependencies&&p.externals.push(...Object.keys(a.optionalDependencies)),ot(p.alias),p.rollup.alias&&p.rollup.alias.entries&&ot(p.rollup.alias.entries),p},"generateOptions"),Ts=D(async(e,t,o,r,n,s,i,a,l,c)=>{const p=await Mi(i.preset??s.preset??"auto",c),u=_s(e,t,r,n,s,i,p,a,l);yo(w(u.rootDir,u.outDir));const d={buildEntries:[],dependencyGraphMap:new Map,environment:r,hooks:jo(),jiti:ft(u.rootDir,u.jiti),logger:e,mode:o,options:u,pkg:a,tsconfig:l,usedImports:new Set,warnings:new Set};p.hooks&&d.hooks.addHooks(p.hooks),s.hooks&&d.hooks.addHooks(s.hooks),i.hooks&&d.hooks.addHooks(i.hooks),await d.hooks.callHook("build:prepare",d),d.options.emitESM===void 0&&d.logger.info("Emitting of ESM bundles, is disabled."),d.options.emitCJS===void 0&&d.logger.info("Emitting of CJS bundles, is disabled."),d.options.minify&&d.logger.info("Minification is enabled, the output will be minified");const g=a.dependencies?.typescript!==void 0||a.devDependencies?.typescript!==void 0;if(d.options.declaration&&d.tsconfig===void 0&&g)throw new Error("Cannot build declaration files without a tsconfig.json");return g?d.options.declaration===!1&&d.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(d.options.declaration=!1,d.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),d.options.declaration&&d.logger.info("Using typescript version: "+x(a.devDependencies?.typescript??a.dependencies?.typescript??"unknown")),d.options.declaration&&(a.dependencies?.typescript||a.devDependencies?.typescript)&&!d.tsconfig?.config.compilerOptions?.isolatedModules&&d.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
104
104
  Because none of the third-party transpiler, packem uses under the hood is type-aware, some techniques or features often used in TypeScript are not properly checked and can cause mis-compilation or even runtime errors.
105
- 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.`),await Gi(d),d},"createContext"),vs=O(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(n=>n.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(n=>o.startsWith(n))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${D(e.options.rootDir,o)}\``),await po(o))},"cleanDistributionDirectories"),bs=O(async(e,t,o)=>{if(e&&C(w(e,"keystore1.json"))){const n=tt(w(e,"keystore.json")),r=Ye(e,{withFileTypes:!0}).filter(i=>i.isDirectory());let s=o;for await(const i of r)n[i.name]||(await Zt(w(e,i.name),{force:!0,recursive:!0}),s&&t.raw(`
105
+ 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.`),await us(d),d},"createContext"),Is=D(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(r=>r.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(r=>o.startsWith(r))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${N(e.options.rootDir,o)}\``),await vo(o))},"cleanDistributionDirectories"),Ms=D(async(e,t,o)=>{if(e&&T(w(e,"keystore1.json"))){const r=lt(w(e,"keystore.json")),n=rt(e,{withFileTypes:!0}).filter(i=>i.isDirectory());let s=o;for(const i of n)r[i.name]||(await ao(w(e,i.name),{force:!0,recursive:!0}),s&&t.raw(`
106
106
 
107
- `),t.info({message:"Removing "+i.name+" file cache, the cache key is not used anymore.",prefix:"file-cache"}),s=!1)}},"removeOldCacheFolders"),ws=O(e=>{switch(e){case"jit":return"Stubbing";case"watch":return"Watching";case"tsdoc":return"Generating TSDoc";default:return"Building"}},"getMode"),pa=O(async(e,t,o,n,r={})=>{const{configPath:s,debug:i,tsconfigPath:a,...l}=r;n.wrapAll(),e=$(oo(),e),n.debug("Root directory:",e);const{packageJson:c,packageJsonPath:u}=Ut(e);n.debug("Using package.json found at",u);let p;if(a){const h=w(e,a);if(!await ot(h))throw new Error("tsconfig.json not found at "+h);p={config:uo(h),path:h},n.info("Using tsconfig settings at",h)}else if(c.dependencies?.typescript||c.devDependencies?.typescript)try{p=await mo(e),n.debug("Using tsconfig settings found at",p.path)}catch{n.info("No tsconfig.json or jsconfig.json found.")}const d=so("@visulima/packem",{cwd:e});let g=!1;try{const h=await Bi(e,s??""),f=st(e,{debug:i});let y=await f.import(h,{default:!0,try:!0})||{};typeof y=="function"&&(y=await y(o,t)),n.debug("Using packem config found at",w(e,h));const b=T(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,...c.peerDependencies,...c.peerDependenciesMeta,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types}))+T(JSON.stringify(y));d&&Io(b,d,n);const x=new Ri(e,d,b,n),v=await ys(n,e,t,o,i??!1,l,y,c,p,f);x.isEnabled=v.options.fileCache,v.logger.info(k(ws(t)+" "+v.options.name)),v.logger.debug({context:v.options.entries,message:`${N("Root dir:")} ${v.options.rootDir}
108
- ${N("Entries:")}}`}),await vs(v);const P=O(async Ht=>{for await(const[ue,qt]of Object.entries(v.options.builder??{})){v.logger.raw(`
109
- `),await v.hooks.callHook("builder:before",ue,v);const Gt=Date.now(),Yt=O(()=>Se(Math.floor(Date.now()-Gt)),"getBuilderDuration");await qt(v,d,x,g),await v.hooks.callHook("builder:done",ue,v),v.logger.raw(`
110
- ⚡️ `+ue+" run in "+Yt()),Ht&&v.logger.raw(`
107
+ `),t.info({message:"Removing "+i.name+" file cache, the cache key is not used anymore.",prefix:"file-cache"}),s=!1)}},"removeOldCacheFolders"),As=D(e=>{switch(e){case"jit":return"Stubbing";case"watch":return"Watching";case"tsdoc":return"Generating TSDoc";default:return"Building"}},"getMode"),Da=D(async(e,t,o,r,n={})=>{const{configPath:s,debug:i,tsconfigPath:a,...l}=n;r.wrapAll(),e=$(me.cwd(),e),r.debug("Root directory:",e);const{packageJson:c,packageJsonPath:p}=Yt(e);r.debug("Using package.json found at",p);let u;if(a){const y=w(e,a);if(!await ct(y))throw new Error("tsconfig.json not found at "+y);u={config:bo(y),path:y},r.info("Using tsconfig settings at",y)}else if(c.dependencies?.typescript||c.devDependencies?.typescript)try{u=await wo(e),r.debug("Using tsconfig settings found at",u.path)}catch{r.info("No tsconfig.json or jsconfig.json found.")}const d=mo("@visulima/packem",{cwd:e});let g=!1,h,m;try{const y=await Gi(e,s??""),b=ft(e,{debug:i});let k=await b.import(y,{default:!0,try:!0})||{};typeof k=="function"&&(k=await k(o,t)),r.debug("Using packem config found at",w(e,y));const E=A(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,...c.peerDependencies,...c.peerDependenciesMeta,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types}))+A(JSON.stringify(k));d&&Uo(E,d,r);const P=new Vi(e,d,E,r),v=await Ts(r,e,t,o,i??!1,l,k,c,u,b);P.isEnabled=v.options.fileCache,v.logger.info(x(As(t)+" "+v.options.name)),v.logger.debug({context:v.options.entries,message:`${C("Root dir:")} ${v.options.rootDir}
108
+ ${C("Entries:")}}`}),await Is(v);const Ne=D(async _=>{for await(const[fe,oo]of Object.entries(v.options.builder??{})){v.logger.raw(`
109
+ `),await v.hooks.callHook("builder:before",fe,v);const ro=Date.now(),no=D(()=>_e(Math.floor(Date.now()-ro)),"getBuilderDuration");await oo(v,d,P,g),await v.hooks.callHook("builder:done",fe,v),v.logger.raw(`
110
+ ⚡️ `+fe+" run in "+no()),_&&v.logger.raw(`
111
111
 
112
- `)}},"runBuilder"),G=Date.now(),Vt=O(()=>Se(Math.floor(Date.now()-G)),"getDuration");if(t==="watch"){if(v.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Ti(v,x,P),Ve(v,!1);return}t==="jit"?(await Ni(v),await v.hooks.callHook("build:done",v)):(g=await li(v,x),await v.hooks.callHook("validate:before",v),cs(v),await v.hooks.callHook("validate:done",v),Ve(v,g)),v.logger.raw(`
113
- ⚡️ Build run in `+Vt()),await P()}catch(h){throw n.raw(`
114
- `),Bt(h),h}finally{n.restoreAll(),await bs(d,n,g)}},"packem");export{pa as default};
112
+ `)}},"runBuilder"),de=D(async()=>{if(h!==void 0)await is({pid:h.pid,signal:l.killSignal??k.killSignal??"SIGTERM"});else if(m!==void 0)try{await m()}catch(_){throw new Error("onSuccess function cleanup failed: "+_.message,{cause:_})}h=void 0,m=void 0},"doOnSuccessCleanup"),Pe=D(async()=>{if(typeof v.options.onSuccess=="function")try{m=await v.options.onSuccess()}catch(_){throw new Error("onSuccess function failed: "+_.message,{cause:_})}else if(typeof v.options.onSuccess=="string"){const _=v.options.onSuccessTimeout??3e4;if(h=xo(v.options.onSuccess,[],{nodeOptions:{shell:!0,stdio:"inherit",timeout:_}}),await h,h.exitCode&&h.exitCode!==0)throw new Error("onSuccess script failed with exit code "+h.exitCode+". Check the output above for details.")}},"runOnsuccess"),eo=Date.now(),to=D(()=>_e(Math.floor(Date.now()-eo)),"getDuration");if(t==="watch"){if(v.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Ki(v,P,Ne,Pe,de),Ze(v,!1);return}t==="jit"?(await Fi(v),await v.hooks.callHook("build:done",v)):(g=await yi(v,P),await v.hooks.callHook("validate:before",v),Es(v),await v.hooks.callHook("validate:done",v),Ze(v,g)),v.logger.raw(`
113
+ ⚡️ Build run in `+to()),await Ne(),await Pe(),me.on("SIGINT",async()=>{await de()}),me.on("SIGTERM",async()=>{await de()})}catch(y){throw r.raw(`
114
+ `),Ht(y),y}finally{r.restoreAll(),await Ms(d,r,g)}},"packem");export{Da as default};