@visulima/packem
Version:
A fast and modern bundler for Node.js and TypeScript.
77 lines (76 loc) • 189 kB
JavaScript
#!/usr/bin/env node
var Eo=Object.defineProperty;var g=(e,t)=>Eo(e,"name",{value:t,configurable:!0});import So from"@visulima/cerebro";import{SimpleReporter as Oo}from"@visulima/pail/reporter";import Te,{cwd as wt,env as Po,versions as Do,exit as Co}from"node:process";import{installPackage as mt}from"@antfu/install-pkg";import{spinner as ft,select as Q,multiselect as hi,confirm as U,intro as No,log as Nt,cancel as Mo,outro as _o}from"@clack/prompts";import{isAccessible as He,readFile as De,writeFile as xi,isAccessibleSync as R,readFileSync as Ye,writeFileSync as le,ensureDir as Mt,emptyDir as Io,readJsonSync as To,writeJsonSync as yi,readJson as bi,walk as zo,writeJson as Ao,ensureDirSync as Fo,collectSync as Ro}from"@visulima/fs";import{join as $,resolve as S,isAbsolute as Ce,relative as z,normalize as K,dirname as _,basename as G,parse as at,toNamespacedPath as ge,sep as _t,extname as Ne}from"@visulima/path";import Z from"magic-string";import{defu as wi}from"defu";import{createJiti as ki}from"jiti";import{cyan as P,yellow as Lo,gray as te,grey as Jo,bold as V,green as Bo}from"@visulima/colorize";import{findCacheDirSync as qo}from"@visulima/find-cache-dir";import{parseBytes as It,formatBytes as A,duration as Tt}from"@visulima/humanizer";import{hasPackageJsonAnyDependency as ji}from"@visulima/package";import Wo from"browserslist";import{createHooks as Uo}from"hookable";import{watch as zt,rollup as $i,VERSION as Vo}from"rollup";import{exec as Ko}from"tinyexec";import{parsePackageJson as Ei,findPackageJson as Go}from"@visulima/package/package-json";import{readTsConfig as Ho,findTsConfig as Yo}from"@visulima/tsconfig";import{NotFoundError as Xo}from"@visulima/fs/error";import{isRelative as kt,resolveAlias as Qo}from"@visulima/path/utils";import{isDynamicPattern as At,globSync as Zo,glob as en}from"tinyglobby";import{fileURLToPath as tn,resolveModuleExportNames as on,resolvePath as Ft,interopDefault as nn,loadModule as an,findStaticImports as Si}from"mlly";import{chmod as sn,stat as jt,readFile as rn,readdir as ln,rm as pn}from"node:fs/promises";import cn,{createHash as dn}from"node:crypto";import Oi from"@rollup/plugin-alias";import un from"@rollup/plugin-commonjs";import mn from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as Pi}from"@rollup/plugin-node-resolve";import Di from"@rollup/plugin-replace";import{wasm as fn}from"@rollup/plugin-wasm";import gn from"rollup-plugin-polyfill-node";import{visualizer as vn}from"rollup-plugin-visualizer";import{minVersion as Ci,valid as hn,coerce as xn}from"semver";import Je from"node:assert/strict";import{extractAssignedNames as yn,createFilter as H}from"@rollup/pluginutils";import bn from"glob-parent";import{SourceMapConsumer as wn,SourceMapGenerator as kn}from"source-map-js";import{fileURLToPath as Ni}from"node:url";import{ResolverFactory as Mi}from"oxc-resolver";import{parseAsync as jn}from"oxc-parser";import $n from"@rollup/plugin-json";import En from"rollup-plugin-license";import{readdirSync as Sn,createReadStream as $t,createWriteStream as On,existsSync as Pn}from"node:fs";import Rt,{isBuiltin as st}from"node:module";import{loadSourceMap as Dn}from"@visulima/source-map";import{parse as Cn}from"@babel/parser";import Nn from"child_process";import{distance as Mn}from"fastest-levenshtein";import _n from"picomatch";import{createBrotliCompress as In,constants as Tn,createGzip as zn}from"node:zlib";import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
const __dirname = __cjs_path__.dirname(__filename);
const require = __cjs_mod__.createRequire(import.meta.url);
const An="@visulima/packem",Fn="1.19.0";var Rn=Object.defineProperty,Ln=g((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"t$e");const _i=Ln(async(e,t="")=>{let i=t;if(!i){const o=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const n of o)if(await He($(e,n))){i="./"+n;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(i))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");return i},"findPackemFile"),Ii={less:["less"],lightningcss:["lightningcss"],"node-sass":["node-sass"],postcss:["postcss","postcss-load-config","postcss-modules-extract-imports","postcss-modules-local-by-default","postcss-modules-scope","postcss-modules-values","postcss-value-parser","icss-utils"],sass:["sass"],"sass-embedded":["sass-embedded"],stylus:["stylus"]};var Jn=Object.defineProperty,Lt=g((e,t)=>Jn(e,"name",{value:t,configurable:!0}),"g$8");const Bn=["typedoc","typedoc-plugin-markdown","typedoc-plugin-rename-defaults"],qn=Lt(e=>{e.addCommand({argument:{description:"Add a packem feature to your project",name:"feature",required:!0},description:"Add a optional packem feature to your project",execute:Lt(async({argument:t,logger:i,options:o})=>{const n=ft(),s=S(wt(),o.dir??".");let a;try{a=await _i(s,o.config)}catch{i.error("Could not find a packem config file, please run `packem init` first.");return}const l=await De(a,{buffer:!1});let c="cjs";l.includes("import")&&(c="esm");const r=new Z(l),p=" transformer,";let u=" transformer";if(l.includes(" transformer,")&&(u=" transformer,"),t.includes("typedoc")){if(l.includes("typedoc: typedocBuilder")||l.includes("@visulima/packem/builder/typedoc")){i.warn("Typedoc has already been added to the packem config.");return}c==="cjs"?r.prepend(`const typedocBuilder = require("@visulima/packem/builder/typedoc");
`):r.prepend(`import typedocBuilder from "@visulima/packem/builder/typedoc";
`),l.includes("builder: {")?r.replace("builder: {",`builder: {
typedoc: typedocBuilder,
`):r.replace(u,p+`
builder: {
typedoc: typedocBuilder,
},`),i.info("Adding typedoc dependencies..."),n.start("Installing packages"),await mt(Bn,{cwd:s,dev:!0,silent:!0}),n.stop("Installed packages"),i.success(`
Typedoc added!`)}if(t.includes("css")){if(l.includes("css: {")||l.includes("@visulima/packem/css")){i.warn("Css loaders have already been added to the packem config.");return}const d=[],f=await Q({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{hint:"experimental",label:"Lightning CSS",value:"lightningcss"}]});d.push(f);let h=await hi({message:"Pick extra loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(h.includes("sass")){const w=await Q({message:"Pick a sass loader",options:[{hint:"recommended",label:"Sass embedded",value:"sass-embedded"},{label:"Sass",value:"sass"},{hint:"legacy",label:"Node Sass",value:"node-sass"}]});w!=="sass"&&(h=h.filter(y=>y!=="sass"),h.push(w))}d.push(...h);const v=[];for(const w of d)v.push(...Ii[w]);d.push("sourceMap");for(let w of d)(w==="sass-embedded"||w==="node-sass")&&(w="sass"),c==="cjs"?r.prepend(`const ${w}Loader = require("@visulima/packem/css/loader/${w.toLowerCase()}");
`):r.prepend(`import ${w}Loader from "@visulima/packem/css/loader/${w.toLowerCase()}";
`);const x=await U({initialValue:!1,message:"Do you want to minify your css?"});let m;x&&(m=await Q({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]}),d.includes("lightningcss")||v.push(m),c==="cjs"?r.prepend(`const ${m}Minifier = require("@visulima/packem/css/minifier/${m.toLowerCase()}");
`):r.prepend(`import ${m}Minifier from "@visulima/packem/css/minifier/${m.toLowerCase()}";
`));const b=d.map(w=>((w==="sass-embedded"||w==="node-sass")&&(w="sass"),`${w}Loader`)).join(", ");l.includes("rollup: {")?r.replace("rollup: {",`rollup: {
css: {${m?`
minifier: ${m}Minifier,`:""}
loaders: [${b}],
},
`):r.replace(u,p+`
rollup: {
css: {${m?`
minifier: ${m}Minifier,`:""}
loaders: [${b}],
},
},`),n.start("Installing packages"),await mt(v,{cwd:s,dev:!0,silent:!0}),n.stop("Installed packages"),i.success(`
CSS loaders added!`)}await xi(a,r.toString(),{overwrite:!0})},"execute"),name:"add",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{description:"Use a custom config file",name:"config",type:String}]})},"createAddCommand"),Xe=[".mjs",".js",".json",".node",".cjs",".ts",".cts",".mts",".tsx",".ctsx",".mtsx",".jsx"],oe="production",Be="development",Et=new Set(["react-server","react-native","edge-light"]),qe=new Set([Be,oe,...Et]),ye=/node_modules/,ae=/(?:\.d\.[mc]?tsx?|\.\w+)$/,Wn="packem_chunks",Un="packem_shared",be=/\.(?:m|c)?(?:j|t)sx?$/;var Vn=Object.defineProperty,Kn=g((e,t)=>Vn(e,"name",{value:t,configurable:!0}),"e$b");const Ti=Kn(e=>{const t=$(e,"package.json");if(!R(t))throw new Error("package.json not found at "+t);return{packageJson:Ei(t),packageJsonPath:t}},"loadPackageJson");var Gn=Object.defineProperty,Hn=g((e,t)=>Gn(e,"name",{value:t,configurable:!0}),"a$u");const Yn=Hn(async(e,t,i,o)=>{let n;if(o){const s=$(e,o);if(!await He(s))throw new Error("tsconfig.json not found at "+s);n={config:Ho(s),path:s},i.info("Using tsconfig settings at",s)}else if(ji(t,["typescript"]))try{n=await Yo(e),i.debug("Using tsconfig settings found at",n.path)}catch{i.info("No tsconfig.json or jsconfig.json found.")}return n},"loadTsconfig");var Xn=Object.defineProperty,zi=g((e,t)=>Xn(e,"name",{value:t,configurable:!0}),"r$i");const Jt=zi(async(e,t)=>{if(typeof e.name!="string"){let i=Ce(e.input)?z(t.options.rootDir,e.input):K(e.input);i.startsWith("./")&&(i=i.slice(2)),e.name=i.replace(new RegExp(`^${t.options.sourceDir}/`),"").replace(ae,"")}if(!e.input)throw new Error(`Missing entry input: ${JSON.stringify(e)}`);kt(e.input)&&(e.input=S(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=S(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),Qn=zi(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:At(t)}:{...t,exportKey:t.exportKey??new Set,isGlob:At(t.input)});for(const t of e.options.entries.filter(i=>i.isGlob)){const{isGlob:i,...o}=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 a of e.options.rollup.watch.exclude)typeof a=="string"&&n.push(a)}const s=Zo([o.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: "+P($(e.options.rootDir,o.input)));for(const a of s)e.options.entries.push({...o,input:S(e.options.rootDir,a)});e.options.entries.splice(e.options.entries.indexOf(t),1)}for(const t of e.options.entries.filter(i=>i.fileAlias===void 0))await Jt(t,e);for(const t of e.options.entries.filter(i=>i.fileAlias!==void 0))t.name=t.fileAlias,t.fileAlias=void 0,await Jt(t,e)},"prepareEntries");var Zn=Object.defineProperty,Qe=g((e,t)=>Zn(e,"name",{value:t,configurable:!0}),"i$j");const We=/^#![^\n]*/,gt=Qe(async e=>{await sn(e,493).catch(()=>{})},"makeExecutable"),ea=Qe((e,t)=>({name:"packem:shebang",renderChunk:{handler(i,o,n){if(!o.isEntry||!o.facadeModuleId)return null;const s=i.startsWith("#")&&i[1]==="!";if(s&&t.replace)return i.replace(We,t.shebang+`
`);if(s)return null;if(e.includes(o.name)){const a=new Z(i);return a.prepend(t.shebang+`
`),{code:a.toString(),map:n.sourcemap?a.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(i,o){for(const[n,s]of Object.entries(o))if(s.type==="chunk"&&We.test(s.code)&&i.dir){const a=S(i.dir,n);await gt(a)}}}),"shebangPlugin"),ta=Qe(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(We,"")}}),"removeShebangPlugin"),ia=Qe((e,t=`
`)=>{const i=We.exec(e);return i?i+t:""},"getShebang");var oa=Object.defineProperty,na=g((e,t)=>oa(e,"name",{value:t,configurable:!0}),"i$i");const Ze=na((e,t)=>{let i={};return e.name&&(i[e.name]=t.rootDir),i={...i,...t.alias},t.rollup.alias&&(Array.isArray(t.rollup.alias.entries)?Object.assign(i,Object.fromEntries(t.rollup.alias.entries.map(o=>[o.find,o.replacement]))):Object.assign(i,t.rollup.alias.entries??t.rollup.alias)),i},"resolveAliases");var aa=Object.defineProperty,sa=g((e,t)=>aa(e,"name",{value:t,configurable:!0}),"r$h");const C=sa((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var ra=Object.defineProperty,la=g((e,t)=>ra(e,"name",{value:t,configurable:!0}),"j$4");const pa=la(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,i=[],o=JSON.stringify({...e.options.jiti,alias:{...Ze(e.pkg,e.options),...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[a,...l]=n;return i.push(a),"["+["plugin"+s,...l.map(c=>JSON.stringify(c))].join(", ")+"]"}return i.push(n),"plugin"+s}).join(",")+"]":"[]");for(const n of e.options.entries){const s=S(e.options.rootDir,e.options.outDir,n.name),a=tn(e.jiti.esmResolve(n.input,{try:!0})??n.input),l=a.replace(ae,""),c=Ye(a),r=ia(c);let p=[];try{p=await on(a,{extensions:Xe})}catch(d){C(e,`Cannot analyze ${a} for exports: ${d.toString()}`);return}const u=p.includes("default")||p.length===0;if(e.options.emitESM){const d=z(_(s),await Ft("jiti",{conditions:["node","import"],url:import.meta.url})),f=l+".d.mts";le(`${s}.mjs`,r+['import { createJiti } from "'+d+'";',...i.map((h,v)=>"import plugin"+v+' from "'+h+'";'),"","const jiti = createJiti(import.meta.url, "+o+");","",'/** @type {import("'+f+'")} */','const _module = await jiti.import("'+a+'");',u?`
export default _module?.default ?? _module;`:"",...p.filter(h=>h!=="default").map(h=>`export const ${h} = _module.${h};`)].join(`
`)),e.options.declaration&&le(`${s}.d.mts`,'export * from "'+f+`";
`+(u?'export { default } from "'+f+'";':""))}if(e.options.emitCJS){const d=z(_(s),await Ft("jiti",{conditions:["node","require"],url:import.meta.url})),f=l+".d.cts";le(`${s}.cjs`,r+['const { createJiti } = require("'+d+'");',...i.map((h,v)=>"const plugin"+v+" = require("+JSON.stringify(h)+")"),"","const jiti = createJiti(__filename, "+o+");","",'/** @type {import("'+f+'")} */','module.exports = jiti("'+a+'")'].join(`
`)),e.options.declaration&&le(s+".d.cts",'export * from "'+f+`";
`+(u?'export { default } from "'+f+'";':""))}r&&(await gt(`${s}.cjs`),await gt(`${s}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var ca=Object.defineProperty,da=g((e,t)=>ca(e,"name",{value:t,configurable:!0}),"t$b");const ie=da(e=>dn("sha256").update(e).digest("hex"),"getHash");var ua=Object.defineProperty,St=g((e,t)=>ua(e,"name",{value:t,configurable:!0}),"i$f");const ma=St(e=>{const{message:t,name:i="Error",stack:o}=e;if(!o)return;const n=`${i}: ${t}
`;return o.startsWith(n)?o.slice(n.length):o},"extractStack"),fa=St(e=>`
${e.replaceAll(/^\n|\n$/g,"")}
`,"normalizeCodeFrame"),Ai=St(e=>{const t=ma(e);let i=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(i+=`
file: ${P(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(i+=`
`+Lo(fa(e.frame))),e.message=i,t!==void 0&&(e.stack=`${e.message}
${t}`)},"enhanceRollupError");var ga=Object.defineProperty,va=g((e,t)=>ga(e,"name",{value:t,configurable:!0}),"a$r");const Ue=va(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var ha=Object.defineProperty,Fi=g((e,t)=>ha(e,"name",{value:t,configurable:!0}),"s$h");const xa=Fi((e,t,i)=>{const o=i??new Map;return(...n)=>{const s=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),a=o.get(s);if(a!==void 0)return a;const l=e(...n);return o.set(s,l),l}},"memoize"),ya=Fi(e=>{const t=new Map;return i=>xa(e,i,t)},"memoizeByKey");var ba=Object.defineProperty,Me=g((e,t)=>ba(e,"name",{value:t,configurable:!0}),"r$g");const wa=Me(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;Je(t,"Expected class/function to have a name"),yield t.name;break}case"VariableDeclaration":{for(const t of e.declaration.declarations)for(const i of yn(t.id))yield i;break}}},"exportName"),ka=Me(function*(e){if(e.declaration)for(const t of wa(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"),ja=Me(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),$a=Me(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),Ea=Me(function*(e,t){Je(t.code!=null,`Module ${t.id} doesn't have associated code`);const i=e.parse(t.code);for(const o of i.body)switch(o.type){case"ExportAllDeclaration":{yield*ja(o);break}case"ExportDefaultDeclaration":{yield*$a();break}case"ExportNamedDeclaration":{yield*ka(o);break}}},"parseExports");var Sa=Object.defineProperty,_e=g((e,t)=>Sa(e,"name",{value:t,configurable:!0}),"n$e");const Ri=_e(async function(e,t,i){const o=await e.resolve(t,i.id);if(Je(o,`Rollup can't resolve ${t} from ${i.id}`),o.external)return null;const n=await e.load(o);return Je(n,`Rollup doesn't have a module for id ${o.id}`),n},"getImportedModule"),Oa=_e(async function*(e,t,i){const o=await Ri(e,t.source,i);o&&(yield*Ot(e,o))},"gatherBarrelReExports"),Pa=_e(async function*(e,t,i){const o=await Ri(e,t.source,i);if(!o)return;const n=new Map(t.bindings.map(s=>[s.importedName,s]));for await(const s of Ot(e,o)){const a=n.get(s.exportedName);a&&(yield{...s,exportedName:a.exportedName})}},"gatherNamedReExports"),Da=_e(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),Ot=_e(async function*(e,t){for(const i of Ea(e,t))i.from==="self"?yield*Da(t,i):i.type==="barrel"?yield*Oa(e,i,t):yield*Pa(e,i,t)},"gatherExports");var Ca=Object.defineProperty,Na=g((e,t)=>Ca(e,"name",{value:t,configurable:!0}),"r$f");const Ma=Na(()=>({moduleParsed:{async handler(e){if(e.isEntry)for await(const t of Ot(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 _a=Object.defineProperty,Ia=g((e,t)=>_a(e,"name",{value:t,configurable:!0}),"r$e");const Ta=Ia((e,t)=>{const i=e,o=[];let n;for(;(n=i.exec(t))!==null;)n.index===i.lastIndex&&i.lastIndex++,n.forEach(s=>{o.push(s)});return o.filter(Boolean)},"getRegexMatches");var za=Object.defineProperty,Aa=g((e,t)=>za(e,"name",{value:t,configurable:!0}),"a$q");const Li=Aa(e=>{const t=Ta(/export\s(\{\s(.*)\s\}|default\s.*);/g,e);if(t.length===0)return null;const i=t.at(-1).split(", ");let o="";for(const n of i)if(!n.includes("type")&&(n.includes("default ")&&(o=n.split("default ")[1]),n.includes("as"))){const[s,a]=n.split(" as ");a==="default"&&(o=s)}if(o!==""){const n=new Z(e);return n.replace(new RegExp(`(,s)?${o} as default(,)?`),""),n.replace(new RegExp(`export default ${o};
?`),""),n.append(`
export = `+o+";"),{code:n.toString().replace(/export\s\{\s\s\};/,""),map:n.generateMap({hires:!0})}}return null},"patchCjsDefaultExport");var Fa=Object.defineProperty,Bt=g((e,t)=>Fa(e,"name",{value:t,configurable:!0}),"i$d");const Ji=Bt(({addDefaultProperty:e=!1,logger:t,type:i})=>({name:"packem:cjs-interop",renderChunk:Bt(async(o,n,s)=>{if(n.type!=="chunk"||!n.isEntry)return null;if(s.format==="cjs"&&s.exports==="auto"){const a=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(o);if(a===null||a.length<3)return null;const l=new Z(o);l.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),l.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&l.append(`
module.exports.default = `+a[2]+";");let c=l.toString();return c=c.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:c,map:l.generateMap({hires:!0})}}return s.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)?i!=="commonjs"&&n.fileName.endsWith(".d.mts")?null:Li(o):null},"renderChunk")}),"cjsInteropPlugin");var Ra=Object.defineProperty,La=g((e,t)=>Ra(e,"name",{value:t,configurable:!0}),"f$h");const Ja=La((e,t)=>{const i=new Map,o={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:n}=o;return Array.isArray(n)?n=n.map(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof n=="string"&&(n=[{src:n}]),{async buildStart(){const s=await Promise.all(n.flatMap(a=>Array.isArray(a.src)?a.src.map(l=>({...a,src:l})):a).map(async a=>await en(Ue(a.src),{ignore:Ue(a.exclude).filter(Boolean)}).then(l=>({dest:a.dest??"",parent:bn(a.src),src:l}))));for(const a of s)for(const l of a.src){let c;i.has(l)?c=i.get(l):(c={copied:[],dest:[],timestamp:0},i.set(l,c));const r=o.flatten?K(a.dest):$(a.dest,z(a.parent,_(l)));c.dest.includes(r)||c.dest.push(r),this.addWatchFile(l)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...i].map(async([a,l])=>{let c;try{const r=await jt(a);if(!r.isFile())return;const p=r.mtime.getTime();p>l.timestamp&&(l.timestamp=p,l.copied=[]),c=await De(a,{buffer:!0})}catch(r){t.error({context:[r],message:`error reading file ${a}`,prefix:"plugin:copy"});return}for(const r of l.dest){if(o.copyOnce&&l.copied.includes(r))continue;const p=G(a),u=$(r,p);try{this.emitFile({[o.exactFileNames?"fileName":"name"]:u,source:c,type:"asset"}),t.debug({message:`copied ${a} → ${u}`,prefix:"plugin:copy"}),l.copied.push(r)}catch(d){t.error({context:[d],message:`error copying file ${a} → ${u}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");function Bi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}g(Bi,"getDefaultExportFromCjs");var rt={exports:{}},qt;function Ba(){return qt||(qt=1,function(e){var t=Object.defineProperty,i=g((p,u)=>t(p,"name",{value:u,configurable:!0}),"c"),o=Object.prototype.hasOwnProperty,n="~";function s(){}g(s,"Events"),i(s,"Events"),Object.create&&(s.prototype=Object.create(null),new s().__proto__||(n=!1));function a(p,u,d){this.fn=p,this.context=u,this.once=d||!1}g(a,"EE"),i(a,"EE");function l(p,u,d,f,h){if(typeof d!="function")throw new TypeError("The listener must be a function");var v=new a(d,f||p,h),x=n?n+u:u;return p._events[x]?p._events[x].fn?p._events[x]=[p._events[x],v]:p._events[x].push(v):(p._events[x]=v,p._eventsCount++),p}g(l,"addListener"),i(l,"addListener");function c(p,u){--p._eventsCount===0?p._events=new s:delete p._events[u]}g(c,"clearEvent"),i(c,"clearEvent");function r(){this._events=new s,this._eventsCount=0}g(r,"EventEmitter"),i(r,"EventEmitter"),r.prototype.eventNames=i(function(){var p=[],u,d;if(this._eventsCount===0)return p;for(d in u=this._events)o.call(u,d)&&p.push(n?d.slice(1):d);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(u)):p},"eventNames"),r.prototype.listeners=i(function(p){var u=n?n+p:p,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var f=0,h=d.length,v=new Array(h);f<h;f++)v[f]=d[f].fn;return v},"listeners"),r.prototype.listenerCount=i(function(p){var u=n?n+p:p,d=this._events[u];return d?d.fn?1:d.length:0},"listenerCount"),r.prototype.emit=i(function(p,u,d,f,h,v){var x=n?n+p:p;if(!this._events[x])return!1;var m=this._events[x],b=arguments.length,w,y;if(m.fn){switch(m.once&&this.removeListener(p,m.fn,void 0,!0),b){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,u),!0;case 3:return m.fn.call(m.context,u,d),!0;case 4:return m.fn.call(m.context,u,d,f),!0;case 5:return m.fn.call(m.context,u,d,f,h),!0;case 6:return m.fn.call(m.context,u,d,f,h,v),!0}for(y=1,w=new Array(b-1);y<b;y++)w[y-1]=arguments[y];m.fn.apply(m.context,w)}else{var k=m.length,j;for(y=0;y<k;y++)switch(m[y].once&&this.removeListener(p,m[y].fn,void 0,!0),b){case 1:m[y].fn.call(m[y].context);break;case 2:m[y].fn.call(m[y].context,u);break;case 3:m[y].fn.call(m[y].context,u,d);break;case 4:m[y].fn.call(m[y].context,u,d,f);break;default:if(!w)for(j=1,w=new Array(b-1);j<b;j++)w[j-1]=arguments[j];m[y].fn.apply(m[y].context,w)}}return!0},"emit"),r.prototype.on=i(function(p,u,d){return l(this,p,u,d,!1)},"on"),r.prototype.once=i(function(p,u,d){return l(this,p,u,d,!0)},"once"),r.prototype.removeListener=i(function(p,u,d,f){var h=n?n+p:p;if(!this._events[h])return this;if(!u)return c(this,h),this;var v=this._events[h];if(v.fn)v.fn===u&&(!f||v.once)&&(!d||v.context===d)&&c(this,h);else{for(var x=0,m=[],b=v.length;x<b;x++)(v[x].fn!==u||f&&!v[x].once||d&&v[x].context!==d)&&m.push(v[x]);m.length?this._events[h]=m.length===1?m[0]:m:c(this,h)}return this},"removeListener"),r.prototype.removeAllListeners=i(function(p){var u;return p?(u=n?n+p:p,this._events[u]&&c(this,u)):(this._events=new s,this._eventsCount=0),this},"removeAllListeners"),r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prefixed=n,r.EventEmitter=r,e.exports=r}(rt)),rt.exports}g(Ba,"requireEventemitter3");var qa=Ba();const Wa=Bi(qa);var Ua=Object.defineProperty,ve=g((e,t)=>Ua(e,"name",{value:t,configurable:!0}),"o$8");class qi extends Error{static{g(this,"TimeoutError")}static{ve(this,"TimeoutError")}constructor(t){super(t),this.name="TimeoutError"}}class Va extends Error{static{g(this,"AbortError")}static{ve(this,"AbortError")}constructor(t){super(),this.name="AbortError",this.message=t}}const Wt=ve(e=>globalThis.DOMException===void 0?new Va(e):new DOMException(e),"getDOMException"),Ut=ve(e=>{const t=e.reason===void 0?Wt("This operation was aborted."):e.reason;return t instanceof Error?t:Wt(t)},"getAbortedReason");function Wi(e,t){const{milliseconds:i,fallback:o,message:n,customTimers:s={setTimeout,clearTimeout}}=t;let a;const l=new Promise((c,r)=>{if(typeof i!="number"||Math.sign(i)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${i}\``);if(t.signal){const{signal:u}=t;u.aborted&&r(Ut(u));const d=ve(()=>{r(Ut(u))},"abortHandler");u.addEventListener("abort",d,{once:!0}),e.finally(()=>{u.removeEventListener("abort",d)})}if(i===Number.POSITIVE_INFINITY){e.then(c,r);return}const p=new qi;a=s.setTimeout.call(void 0,()=>{if(o){try{c(o())}catch(u){r(u)}return}typeof e.cancel=="function"&&e.cancel(),n===!1?c():n instanceof Error?r(n):(p.message=n??`Promise timed out after ${i} milliseconds`,r(p))},i),(async()=>{try{c(await e)}catch(u){r(u)}})()}).finally(()=>{l.clear()});return l.clear=()=>{s.clearTimeout.call(void 0,a),a=void 0},l}g(Wi,"T$1");ve(Wi,"pTimeout");var Ka=Object.defineProperty,Ga=g((e,t)=>Ka(e,"name",{value:t,configurable:!0}),"i$c");function Ui(e,t,i){let o=0,n=e.length;for(;n>0;){const s=Math.trunc(n/2);let a=o+s;i(e[a],t)<=0?(o=++a,n-=s+1):n=s}return o}g(Ui,"r$d");Ga(Ui,"lowerBound");var Ha=Object.defineProperty,Ya=g((e,t)=>Ha(e,"name",{value:t,configurable:!0}),"n$c");let Xa=class{static{g(this,"y")}static{Ya(this,"PriorityQueue")}#e=[];enqueue(t,i){i={priority:0,...i};const o={priority:i.priority,id:i.id,run:t};if(this.size===0||this.#e[this.size-1].priority>=i.priority){this.#e.push(o);return}const n=Ui(this.#e,o,(s,a)=>a.priority-s.priority);this.#e.splice(n,0,o)}setPriority(t,i){const o=this.#e.findIndex(s=>s.id===t);if(o===-1)throw new ReferenceError(`No promise function with the id "${t}" exists in the queue.`);const[n]=this.#e.splice(o,1);this.enqueue(n.run,{priority:i,id:t})}dequeue(){return this.#e.shift()?.run}filter(t){return this.#e.filter(i=>i.priority===t.priority).map(i=>i.run)}get size(){return this.#e.length}};var Qa=Object.defineProperty,Vt=g((e,t)=>Qa(e,"name",{value:t,configurable:!0}),"n$b");let Za=class extends Wa{static{g(this,"d")}static{Vt(this,"PQueue")}#e;#i;#a=0;#r;#s;#f=0;#o;#p;#t;#g;#n=0;#c;#l;#v;#y=1n;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Xa,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#e=t.carryoverConcurrencyCount,this.#i=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#r=t.intervalCap,this.#s=t.interval,this.#t=new t.queueClass,this.#g=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#v=t.throwOnTimeout===!0,this.#l=t.autoStart===!1}get#b(){return this.#i||this.#a<this.#r}get#w(){return this.#n<this.#c}#k(){this.#n--,this.#d(),this.emit("next")}#j(){this.#x(),this.#h(),this.#p=void 0}get#$(){const t=Date.now();if(this.#o===void 0){const i=this.#f-t;if(i<0)this.#a=this.#e?this.#n:0;else return this.#p===void 0&&(this.#p=setTimeout(()=>{this.#j()},i)),!0}return!1}#d(){if(this.#t.size===0)return this.#o&&clearInterval(this.#o),this.#o=void 0,this.emit("empty"),this.#n===0&&this.emit("idle"),!1;if(!this.#l){const t=!this.#$;if(this.#b&&this.#w){const i=this.#t.dequeue();return i?(this.emit("active"),i(),t&&this.#h(),!0):!1}}return!1}#h(){this.#i||this.#o!==void 0||(this.#o=setInterval(()=>{this.#x()},this.#s),this.#f=Date.now()+this.#s)}#x(){this.#a===0&&this.#n===0&&this.#o&&(clearInterval(this.#o),this.#o=void 0),this.#a=this.#e?this.#n:0,this.#u()}#u(){for(;this.#d(););}get concurrency(){return this.#c}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#c=t,this.#u()}async#E(t){return new Promise((i,o)=>{t.addEventListener("abort",()=>{o(t.reason)},{once:!0})})}setPriority(t,i){this.#t.setPriority(t,i)}async add(t,i={}){return i.id??=(this.#y++).toString(),i={timeout:this.timeout,throwOnTimeout:this.#v,...i},new Promise((o,n)=>{this.#t.enqueue(async()=>{this.#n++,this.#a++;try{i.signal?.throwIfAborted();let s=t({signal:i.signal});i.timeout&&(s=Wi(Promise.resolve(s),{milliseconds:i.timeout})),i.signal&&(s=Promise.race([s,this.#E(i.signal)]));const a=await s;o(a),this.emit("completed",a)}catch(s){if(s instanceof qi&&!i.throwOnTimeout){o();return}n(s),this.emit("error",s)}finally{this.#k()}},i),this.emit("add"),this.#d()})}async addAll(t,i){return Promise.all(t.map(async o=>this.add(o,i)))}start(){return this.#l?(this.#l=!1,this.#u(),this):this}pause(){this.#l=!0}clear(){this.#t=new this.#g}async onEmpty(){this.#t.size!==0&&await this.#m("empty")}async onSizeLessThan(t){this.#t.size<t||await this.#m("next",()=>this.#t.size<t)}async onIdle(){this.#n===0&&this.#t.size===0||await this.#m("idle")}async#m(t,i){return new Promise(o=>{const n=Vt(()=>{i&&!i()||(this.off(t,n),o())},"listener");this.on(t,n)})}get size(){return this.#t.size}sizeBy(t){return this.#t.filter(t).length}get pending(){return this.#n}get isPaused(){return this.#l}};var es=Object.defineProperty,ts=g((e,t)=>es(e,"name",{value:t,configurable:!0}),"r$c");const Kt=ts((e,t)=>{if(!t)return!1;if(typeof t=="function")return t(e);if(typeof t.test=="function")return t.test(e);throw new Error("Invalid condition type")},"matchFile");var is=Object.defineProperty,os=g((e,t)=>is(e,"name",{value:t,configurable:!0}),"a$p");const ns=4,as=process.env.UV_THREADPOOL_SIZE?Number.parseInt(process.env.UV_THREADPOOL_SIZE,10):ns;let ss=class{static{g(this,"f")}static{os(this,"LoaderManager")}test;loaders=new Map;options;workQueue;logger;constructor({extensions:t,loaders:i,logger:o,options:n}){this.test=s=>t.some(a=>s.toLowerCase().endsWith(a)),i.length>0&&this.add(...i),this.options=n,this.logger=o}add(...t){for(const i of t)this.loaders.has(i.name)||this.loaders.set(i.name,i)}isSupported(t){if(this.test(t))return!0;for(const[,i]of this.loaders)if(Kt(t,i.test))return!0;return!1}async process(t,i){this.workQueue||(this.workQueue=new Za({concurrency:as-1}));for await(const[o,n]of this.loaders){const s={...i,options:this.options[o]??{}};if(n.alwaysProcess||Kt(s.id,n.test)){this.logger.debug(`Processing ${o} loader for ${s.id}`);const a=await this.workQueue.add(n.process.bind(s,t));a&&(t=a)}}return t}};const rs=/data:[^\n\r;]+(?:;charset=[^\n\r;]+)?;base64,([\d+/A-Za-z]+={0,2})/;var ls=Object.defineProperty,et=g((e,t)=>ls(e,"name",{value:t,configurable:!0}),"i$b");const Vi=/(?:\n|\r\n)?\/\*[#*@]+\s*sourceMappingURL\s*=\s*(\S+)\s*\*+\//g,Ki=/(?:\n|\r\n)?\/\/[#@]+\s*sourceMappingURL\s*=\s*(\S+)\s*?$/gm;let ps=class{static{g(this,"S")}static{et(this,"MapModifier")}map;constructor(t){if(typeof t=="string")try{this.map=JSON.parse(t)}catch{}else this.map=t}modify(t){return this.map?(t(this.map),this):this}modifySources(t){return this.map?(this.map.sources&&(this.map.sources=this.map.sources.map(i=>t(i))),this):this}resolve(t=process.cwd()){return this.modifySources(i=>i==="<no source>"?i:S(t,i))}relative(t=process.cwd()){return this.modifySources(i=>i==="<no source>"?i:Ce(i)?z(t,i):K(i))}toObject(){return this.map}toString(){return this.map?JSON.stringify(this.map):this.map}toConsumer(){return this.map?new wn(this.map):this.map}toCommentData(){const t=this.toString();return t?`
/*# sourceMappingURL=data:application/json;base64,${Buffer.from(t).toString("base64")} */`:""}toCommentFile(t){return this.map?`
/*# sourceMappingURL=${t} */`:""}};et(async(e,t)=>{const[,i]=Vi.exec(e)??Ki.exec(e)??[];if(!i)return;const[,o]=rs.exec(i)??[];if(o)return Buffer.from(o,"base64").toString();if(!t)throw new Error("Extracted map detected, but no ID is provided");const n=S(_(t),i);if(R(n))return Ye(n)},"getMap");et(e=>e.replaceAll(Vi,"").replaceAll(Ki,""),"stripMap");const vt=et(e=>new ps(e),"mm");var cs=Object.defineProperty,ds=g((e,t)=>cs(e,"name",{value:t,configurable:!0}),"u$e");const us=ds(async e=>{const t=new kn({file:""}),i=[];let o=0;for await(const{css:n,map:s}of e){i.push(n);const a=vt(s),l=a.toObject();if(!l)continue;const c=a.toConsumer();if(c){if(c.eachMapping(r=>{t.addMapping({generated:{column:r.generatedColumn,line:o+r.generatedLine},name:r.name,original:{column:r.originalColumn,line:r.originalLine},source:r.source})}),l.sourcesContent)for(const r of l.sources)t.setSourceContent(r,c.sourceContentFor(r,!0));o+=n.split(`
`).length}}return{css:i.join(`
`),map:t}},"concat");var ms=Object.defineProperty,fs=g((e,t)=>ms(e,"name",{value:t,configurable:!0}),"s$e");const Gi=fs(e=>e.map((t,i,o)=>{const n=`\`${t}\``;switch(i){case o.length-1:return`or ${n}`;case o.length-2:return n;default:return`${n},`}}).join(" "),"default");var gs=Object.defineProperty,vs=g((e,t)=>gs(e,"name",{value:t,configurable:!0}),"l$e");const hs=_(Ni(import.meta.url)),Gt=vs((e,t)=>{const i={baseDirs:[hs],caller:"Resolver",extensions:[".mjs",".js",".cjs",".json"],symlinks:!0,...t},o=new Mi({extensions:i.extensions,symlinks:i.symlinks});for(const n of i.baseDirs)for(const s of e)try{const{error:a,path:l}=o.sync(n,s);if(l)return l;a&&console.debug(a,{context:[{basedir:n,caller:t.caller,extensions:t.extensions,id:s}]})}catch(a){console.debug(a.message,{context:[{basedir:n,caller:t.caller,error:a,extensions:t.extensions,id:s}]})}throw new Error(`${i.caller} could not resolve ${Gi(e)}`)},"resolve");var xs=Object.defineProperty,ys=g((e,t)=>xs(e,"name",{value:t,configurable:!0}),"o$5");const se={},bs=[".js",".mjs",".cjs",".json"],ws=ys(async(e,t)=>{if(se[e])return se[e];if(se[e]===null)return;const i={baseDirs:[t],caller:"Module loader",extensions:bs,symlinks:!1};try{se[e]=require(Gt([e,`./${e}`],i))}catch(n){if(n.code==="ERR_REQUIRE_ESM")try{se[e]=nn(await an(Gt([e,`./${e}`],i)))}catch{}else{se[e]=null;return}}const o=se[e];return o?.default??o},"default");var ks=Object.defineProperty,he=g((e,t)=>ks(e,"name",{value:t,configurable:!0}),"r$b");const Hi=["inject","extract","emit"],js=Gi(Hi),$s=he(e=>{const t=Array.isArray(e)?e:[e];if(t[0]&&!Hi.includes(t[0]))throw new Error(`Incorrect mode provided, allowed modes are ${js}`);return{emit:t[0]==="emit",extract:t[0]==="extract"&&(t[1]??!0),inject:(!t[0]||t[0]==="inject")&&(t[1]??!0)}},"inferModeOption"),ht=he((e,t)=>typeof e=="boolean"?e&&{}:typeof e=="object"?e:t,"inferOption"),Es=he(e=>{const t=Array.isArray(e)?e:[e];return t[0]?{content:!0,...t[1],inline:t[0]==="inline"}:!1},"inferSourceMapOption"),Ht=he((e,t)=>{const i=ht(e,{});return t&&typeof i=="object"&&!i.alias&&(i.alias=t),i},"inferHandlerOption"),fe=he(async(e,t,i)=>{if(typeof e!="string")return e;const o=await ws(e,i);if(!o)throw new Error(`Unable to load PostCSS ${t} \`${e}\``);return o},"ensurePCSSOption"),Ss=he(async(e,t)=>{if(e===void 0)return[];if(e.length===0)return[];const i=[];for await(const o of e.filter(Boolean)){if(!Array.isArray(o)){i.push(await fe(o,"plugin",t));continue}const[n,s]=o;s?i.push((await fe(n,"plugin",t))(s)):i.push(await fe(n,"plugin",t))}return i},"ensurePCSSPlugins");var Os=Object.defineProperty,$e=g((e,t)=>Os(e,"name",{value:t,configurable:!0}),"b$3");const Ps=$e(async(e,t)=>e.sort((i,o)=>t.indexOf(i.name)-t.indexOf(o.name)),"sortByNameOrder"),Ds=$e(async(e,t,i,o,n,s,a,l,c,r)=>{const p={...r,...e.alias},u=H(e.include,e.exclude),d=Es(e.sourceMap),f={...$s(e.mode),autoModules:e.autoModules??!1,dts:e.dts,extensions:e.extensions,namedExports:e.namedExports};typeof f.inject=="object"&&f.inject.treeshakeable&&(f.namedExports=!1,t.info({message:"Disabling named exports due to `inject.treeshakeable` option",prefix:"css"}));let h=!1;if(e.loaders)for(const b of e.loaders)b.name==="postcss"&&(h=!0);else e.loaders=[];h&&(f.postcss={...e.postcss,config:ht(e.postcss?.config,{}),import:Ht(e.postcss?.import,p),modules:ht(e.postcss?.modules,void 0),to:e.postcss?.to,url:Ht(e.postcss?.url,p)},e.postcss?.parser&&(f.postcss.parser=await fe(e.postcss.parser,"parser",o)),e.postcss?.syntax&&(f.postcss.syntax=await fe(e.postcss.syntax,"syntax",o)),e.postcss?.stringifier&&(f.postcss.stringifier=await fe(e.postcss.stringifier,"stringifier",o)),e.postcss?.plugins&&(f.postcss.plugins=await Ss(e.postcss.plugins,o)));const v=new ss({extensions:f.extensions,loaders:await Ps(e.loaders,["sourcemap","stylus","less","sass","postcss"]),logger:t,options:{...e,...f,alias:p}});let x=[];const m=$e((b,w)=>{const y=[];for(const k of Object.keys(b)){const j=new Set;let E=[k];do{const N=[];for(const M of E){if(j.has(M))continue;if(v.isSupported(M)){u(M)&&N.push(M);continue}j.add(M);const Y=w(M);Y&&N.push(...Y.importedIds)}E=N}while(E.some(N=>!v.isSupported(N)));y.push(...E)}return y},"traverseImportedModules");return{augmentChunkHash(b){if(x.length===0)return null;const w=m(b.modules,this.getModuleInfo),y=x.filter(k=>w.includes(k.id)).sort((k,j)=>w.lastIndexOf(k.id)-w.lastIndexOf(j.id)).map(k=>`${G(k.id)}:${k.css}`);return y.length===0?null:y.join(":")},async generateBundle(b,w){if(x.length===0||!(b.dir||b.file))return;const y=Object.values(w),k=b.dir??_(b.file),j=y.filter(D=>D.type==="chunk"),E=j.filter(D=>!D.facadeModuleId),N=b.preserveModules?j:j.filter(D=>D.isEntry||D.isDynamicEntry),M=[],Y=$e(async(D,I)=>{const O=typeof f.extract=="string"?K(f.extract).replace(/^\.[/\\]/,""):K(`${D}.css`);Ce(O)&&this.error(["Extraction path must be relative to the output directory,",`which is ${z(o,k)}`].join(`
`)),kt(O)&&this.error(["Extraction path must be nested inside output directory,",`which is ${z(o,k)}`].join(`
`));const q=x.filter(W=>I.includes(W.id)).sort((W,de)=>I.lastIndexOf(W.id)-I.lastIndexOf(de.id)),Ie=await us(q);return{css:Ie.css,map:vt(Ie.map.toString()).relative(_(S(k,O))).toString(),name:O}},"getExtractedData"),X=$e(D=>{if(b.file)return at(b.file).name;if(b.preserveModules){const{dir:I,name:O}=at(D.fileName);return I?$(I,O):O}return D.name},"getName"),ce=[];if(typeof f.extract=="string"){t.debug({message:`Extracting to ${f.extract}`,prefix:"css"});const D=[];for(const O of E){const q=m(O.modules,this.getModuleInfo);ce.push(...q),D.push(...q)}for(const O of N)D.push(...m(O.modules,this.getModuleInfo).filter(q=>!ce.includes(q)));const I=X(j[0]);M.push([I,D])}else{t.debug({message:"Extracting to individual files",prefix:"css"});for(const D of E){const I=m(D.modules,this.getModuleInfo);if(I.length===0)continue;ce.push(...I);const O=X(D);M.push([O,I])}for(const D of N){const I=m(D.modules,this.getModuleInfo).filter(q=>!ce.includes(q));if(I.length===0)continue;const O=X(D);M.push([O,I])}}for await(const[D,I]of M){const O=await Y(D,I);if(typeof e.onExtract=="function"&&!e.onExtract(O))continue;if(c&&e.minifier){t.info({message:`Minifying ${O.name} with ${e.minifier.name}`,prefix:"css"});const{css:W,map:de}=await e.minifier.handler.bind({browserTargets:i,warn:this.warn.bind(this)})(O,d,e[e.minifier.name]??{});O.css=W,O.map=de}const q={fileName:O.name,name:O.name,names:[O.name],originalFileName:O.name,originalFileNames:[O.name],source:O.css,type:"asset"},Ie=this.emitFile(q);if(O.map&&d){const W=this.getFileName(Ie),de=typeof b.assetFileNames=="string"?K(_(b.assetFileNames)):typeof b.assetFileNames=="function"?K(_(b.assetFileNames(q))):"assets",xe=vt(O.map).modify(T=>(T.file=G(W),T)).modifySources(T=>{if(T==="<no source>"||de.length<=1)return T;T=`../${T}`;for(const nt of de)nt==="/"&&(T=`../${T}`);return T});if(d.inline)xe.modify(T=>d.transform?.(T,K($(k,W)))),w[W].source+=xe.toCommentData();else{const T=`${W}.map`;xe.modify($o=>d.transform?.($o,K($(k,T)))),this.emitFile({fileName:T,source:xe.toString(),type:"asset"});const{base:nt}=at(T);w[W].source+=xe.toCommentFile(nt)}}}},name:"packem:css",async transform(b,w){if(!u(w)||!v.isSupported(w)||b.replaceAll(/\s/g,"")==="")return null;typeof e.onImport=="function"&&e.onImport(b,w);const y={alias:p,assets:new Map,autoModules:f.autoModules,browserTargets:i,cwd:o,debug:l,deps:new Set,dts:f.dts,emit:f.emit,environment:s,extensions:f.extensions,extract:f.extract,id:w,inject:f.inject,logger:t,namedExports:f.namedExports,options:{},plugin:this,sourceDir:n,sourceMap:d,useSourcemap:a,warn:this.warn.bind(this)},k=await v.process({code:b},y);for(const j of y.deps)this.addWatchFile(j);for(const[j,E]of y.assets)this.emitFile({fileName:j,source:E,type:"asset"});if(k.extracted){const{id:j}=k.extracted;x=x.filter(E=>E.id!==j),x.push(k.extracted)}return{code:k.code,map:d&&k.map?k.map:{mappings:""},meta:{styles:k.meta},moduleSideEffects:k.extracted?!0:null}}}},"default");var Cs=Object.defineProperty,Ns=g((e,t)=>Cs(e,"name",{value:t,configurable:!0}),"t$a");const Ms=/\.module\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/,lt=Ns((e,t)=>e===void 0?!0:typeof e=="function"?e(t):e instanceof RegExp?e.test(t):e&&Ms.test(t),"ensureAutoModules");var _s=Object.defineProperty,Is=g((e,t)=>_s(e,"name",{value:t,configurable:!0}),"u$b");const Ts=`
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
/**
* Generated by packem
* @see https://npmjs.com/@visulima/packem
*/
`.trim(),zs=Is((e,t,i)=>{let o;return e.postcss&&typeof e.postcss.modules=="boolean"?o=e.postcss.modules:e.lightningcss&&typeof e.lightningcss.modules=="boolean"&&(o=e.lightningcss.modules),{async transform(n,s){let a=o;if(e.postcss&&typeof e.postcss.modules=="object"?a=lt(e.postcss.modules.include,s):e.lightningcss&&typeof e.lightningcss.modules=="object"&&(a=lt(e.lightningcss.modules.include,s)),e.autoModules&&a===void 0&&(a=lt(e.autoModules,s)),!a)return null;const{types:l}=this.getModuleInfo(s)?.meta.styles??{};return l===void 0||await He(s)&&(await xi(s+".d.ts",`${Ts}
${l}`),i.info({message:`Generated types for ${K(s).replace(t+"/","")}`,prefix:"dts:css-modules"}),this.addWatchFile(s+".d.ts")),null}}},"cssModulesTypes");var As=Object.defineProperty,Fs=g((e,t)=>As(e,"name",{value:t,configurable:!0}),"r$a");const Rs=new Set(["es","chrome","edge","firefox","ios","node","safari","opera","ie"]),Ls=["android 4"],Js={android:"chrome",ios_saf:"ios"},Bs=" ",ze=Fs(e=>{let t=e.filter(i=>!Ls.some(o=>i.startsWith(o))).map(i=>i.split(Bs)).map(([i,o])=>[Js[i]||i,o]).map(([i,o])=>[i,o.includes("-")?o.slice(0,o.indexOf("-")):o]).map(([i,o])=>[i,o.endsWith(".0")?o.slice(0,-2):o]).filter(([,i])=>/^\d+(\.\d+)*$/.test(i)).filter(([i])=>Rs.has(i));return t=Object.entries(Object.fromEntries(t)),t.map(([i,o])=>`${i}${o}`)},"browserslistToEsbuild");var qs=Object.defineProperty,tt=g((e,t)=>qs(e,"name",{value:t,configurable:!0}),"t$9");const Ws=/(?:^|[^.\w'"`])require(\.resolve)?\(\s*([\w'"`])/,Us=tt((e,t)=>{if(Po.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 i=!1,o=!1,n=!1;if(e.includes("__filename")&&(i=!0),e.includes("__dirname")&&(o=!0),Ws.test(e)&&(n=!0),!i&&!o&&!n)return null;const s=Si(e).pop(),a=s?s.end:0,l=new Z(e);return l.appendRight(a,t(i,o,n)),{code:l.toString(),map:l.generateMap()}},"CJSToESM"),Vs=tt((e,t,i)=>{let o="";return(e||t)&&(o+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
`),t&&(o+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
`),i&&(o+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
`),(e||t)&&(o+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url);
`),t&&(o+=`const __dirname = __cjs_path__.dirname(__filename);
`),i&&(o+=`const require = __cjs_mod__.createRequire(import.meta.url);
`),o},"generateCJSShim"),Ks=tt((e,t,i)=>{let o="";return i&&(o+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
`),e&&(o+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
`),t&&(o+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
`),i&&(o+=`const require = __cjs_mod__.createRequire(import.meta.url);
`),o},"generateCJSShimNode20_11"),Gs=tt((e,t)=>{const i=H(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(o,n,s){if(s.format==="es"&&i(n.fileName)){let a=Vs;if(e.engines?.node){const l=Ci(e.engines.node);l&&l.major>=20&&l.minor>=11&&(a=Ks)}return Us(o,a)}return null}}},"esmShimCjsSyntaxPlugin");var Hs=Object.defineProperty,Ys=g((e,t)=>Hs(e,"name",{value:t,configurable:!0}),"m$c");const Xs=Ys(()=>({name:"packem:fix-dynamic-import-extension",renderChunk(e,t,i){return i.format==="es"||i.format==="cjs"?{code:e.replaceAll(/(import\(.*)(\.ts)(['´"`]\))/g,"$1."+(i.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var Qs=Object.defineProperty,Zs=g((e,t)=>Qs(e,"name",{value:t,configurable:!0}),"e$8");const Yt=/^([\w-]+):/,Xt=Zs(e=>{if(!e||typeof e!="string")throw new Error("Invalid key: Key must be a non-empty string.");const t=[],i=Yt.exec(e);i&&(t.push(i[1]),e=e.replace(Yt,""));const o=e.split("/");for(const n of o)(n.includes("*")||n)&&t.push(n);return t},"splitTsconfigPathKey");var er=Object.defineProperty,tr=g((e,t)=>er(e,"name",{value:t,configurable:!0}),"h$2");const ir=tr((e,t)=>{const i=e.replace(/^\.\//,""),o=t.replace(/^\.\//,"");if(o.startsWith(i))return e+o.slice(i.length);if(e.endsWith(t))return e;const n=Xt(e),s=Xt(t);let a=n.length-1,l=s.length-1;for(;a>=0&&l>=0&&n[a]===s[l];)a--,l--;let c=n.slice(0,a).join("/");const r=s.slice(l).join("/");return(!c.startsWith(".")||c==="")&&(c="./"+c),c+(r?"/"+r:"")},"extendString");var or=Object.defineProperty,nr=g((e,t)=>or(e,"name",{value:t,configurable:!0}),"s$d");const ar=nr((...e)=>{if(e.length===0)return"";if(e.length===1)return _(e[0]);e=e.map(n=>ge(n).split(_t).join("/"));const[t,...i]=e;let o=t.split("/");for(const n of i){const s=n.split("/",o.length);let a=0;for(const l of s)if(l===o[a])a+=1;else{o=o.slice(0,a);break}o=o.slice(0,a)}return(o.length<=1&&o[0]===""?`/${o[0]}`:o.join("/")).split("/").join(_t)},"lowestCommonAncestor");var sr=Object.defineProperty,Pe=g((e,t)=>sr(e,"name",{value:t,configurable:!0}),"d$a");const Qt=Pe((e,t)=>`${e}
//# sourceMappingURL=${G(t)}.map
`,"appendMapUrl"),Zt=Pe((e,t,i)=>JSON.stringify({file:G(i),mappings:e,names:[],sourceRoot:"",sources:[z(_(i),t)],version:3}),"generateDtsMap"),rr=Pe((e,t,i,o,n,s,a,l)=>{const c=H(s.include,s.exclude);let r=Object.create(null);const p=Pe((f,h)=>{r[f.replace(ae,"")]={...h,ext:Ne(f)}},"addOutput");let u=[];l?.config.compilerOptions&&(u=Object.entries(l.config.compilerOptions.paths??{}).map(([f])=>f.endsWith("*")?new RegExp(`^${f.replace("*","(.*)")}$`):new RegExp(`^${f}$`)));async function d(f,h){if(!c(h))return;let v;try{v=(await jn(h,f)).program}catch(y){n.debug({message:y.message,prefix:"packem:isolated-declarations"})}if(v){const y=v.body.filter(k=>(k.type==="ImportDeclaration"||k.type==="ExportAllDeclaration"||k.type==="ExportNamedDeclaration")&&!!k.source);for await(const k of y){if(G(k.source.value).includes("."))continue;const j=await this.resolve(k.source.value,h);if(!(!j||j.external)&&(j.id.endsWith(".ts")||j.id.endsWith(".cts")||j.id.endsWith(".mts")||j.id.endsWith(".tsx")||j.id.endsWith(".ctsx")||j.id.endsWith(".mtsx"))){const E=j.id.replace(e+"/","");let N=k.source.value;u.some(M=>M.test(k.source.value))&&!k.source.value.startsWith(".")&&(N="./"+k.source.value),f=f.replaceAll('from "'+k.source.value+'"','from "'+ir(N,E)+'"')}}}const{errors:x,map:m,sourceText:b}=await t(h,f,a,l?.config?.compilerOptions);if(x.length>0){if(s.ignoreErrors){this.warn(x[0]);return}return this.error(x[0])}if(p(h,{map:m,source:b}),!v)r