@visulima/packem 2.0.0-alpha.86 → 2.0.0-alpha.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/dist/babel-runtime/packem_shared/transform-code-KNtowoK1.js +1 -0
- package/dist/babel-runtime/plugins/babel/worker.js +1 -1
- package/dist/builder/typedoc/index.js +2 -2
- package/dist/cli/index.js +39 -39
- package/dist/index.js +1 -1
- package/dist/packem_shared/{create-or-update-key-storage-CRDW-Kwa.js → create-or-update-key-storage-DHOKZmnD.js} +1 -1
- package/dist/packem_shared/default-BKj8akkL.js +1 -0
- package/dist/packem_shared/index-C47QUEeX.js +245 -0
- package/dist/packem_shared/{oxcTransformPlugin-Dwvbw2jE-BSBF_-9X.js → oxcTransformPlugin-Dwvbw2jE-DgTjbGep.js} +25 -25
- package/dist/rollup/plugins/oxc/oxc-transformer.js +1 -1
- package/package.json +7 -5
- package/dist/babel-runtime/packem_shared/transform-code-Cd2HSMcx.js +0 -1
- package/dist/packem_shared/default-nqaAQAPN.js +0 -1
- package/dist/packem_shared/index-1y8wS5GH.js +0 -244
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import{createRequire as _e,builtinModules as um}from"node:module";import{g as io,o as pm,a as Eu,P as Bi,b as fm,T as ao,N as ft,F as dt,u as Su,t as lo,c as Di,J as ku,S as dm,d as Ct,s as rt,i as ju,q as re,j as Ae,e as De,h as Rn,I as Li,k as Yt,m as di,l as Au,_ as mm,H as Cn,E as Ou,n as qt,K as hm,p as gm,f as ym,r as $m}from"./create-or-update-key-storage-DHOKZmnD.js";import ut,{env as bm,versions as Dn,platform as er}from"node:process";import{H as Z,_ as Se,B as Fr,w as G,v as Tt,P as X,E as wm,G as tr,V as Fe,Z as Ru,k as vm,W as Cu}from"./utils-Bsoe7qJG.js";import{installPackage as Tu,detectPackageManager as xm}from"@antfu/install-pkg";import{E as Ln,L as Nu,p as Em,i as Pu,s as Sm,P as Mu,f as km,M as jm,T as Nt,r as Oe,a as Xr,b as co,c as Fi,d as _u,e as Iu,g as Am,h as Wu,k as Om,S as Rm,l as Cm,m as Xt,n as mi,v as Tm,A as Nm,o as Zr,j as Pm}from"./oxcTransformPlugin-Dwvbw2jE-DgTjbGep.js";import{importTrace as Bu,replace as Du,alias as Lu,purePlugin as Mm,pureNewExpressionPlugin as Da,browserslistToEsbuild as La,polyfillNode as _m,chunkSplitter as Im,wasm as Wm,preserveDirectivesPlugin as Bm,dynamicImportVars as Dm,commonjs as Lm,jsxRemoveAttributes as Fm,visualizer as Hm,patchErrorWithTrace as qm}from"@visulima/packem-rollup";import{ENDING_REGEX as Jm,svgToCssDataUri as zm,svgToTinyDataUri as Um,memoizeByKey as Hi,arrayify as Gm,enhanceRollupError as Fu,FileCache as Vm}from"@visulima/packem-share";import{RUNTIME_EXPORT_CONVENTIONS as Hu,SPECIAL_EXPORT_CONVENTIONS as qu,DEFAULT_EXTENSIONS as uo,ENDING_REGEX as qi,PRODUCTION_ENV as Wr,DEVELOPMENT_ENV as Fa,EXCLUDE_REGEXP as kt,ALLOWED_TRANSFORM_EXTENSIONS_REGEX as Et,VALID_EXPORT_EXTENSIONS as Km}from"@visulima/packem-share/constants";import{getCacheHash as Ve,memoize as Ym,arrayify as hi,isFromNodeModules as Uo,isBareSpecifier as Tr,parseSpecifier as gi,isOutsideProject as Xm,getPackageName as Zm,replaceContentWithinMarker as Qm,svgEncoder as eh,sortUserPlugins as Ju,getDtsExtension as Ke,getChunkFilename as Br,getEntryFileNames as th,getOutputExtension as Pe,warn as Y}from"@visulima/packem-share/utils";import rh from"browserslist";import{createHooks as nh}from"hookable";import{createJiti as oh}from"jiti";import{x as Fn,exec as sh}from"tinyexec";import Ee from"magic-string";import{fileURLToPath as zu}from"node:url";import ih,{existsSync as Ji,createReadStream as zi,createWriteStream as ah,watch as Ha}from"node:fs";import{cpus as lh,tmpdir as Uu,homedir as ch}from"node:os";import{dirname as yi,join as Gu,resolve as uh,isAbsolute as ph}from"node:path";import{createFilter as Ze,normalizePath as Hr}from"@rollup/pluginutils";import fh from"workerpool";import{transformAsync as dh}from"@babel/core";import Vu,{stat as Qr,readFile as Hn,copyFile as mh,chmod as Ku,readdir as hh,rm as po,mkdtemp as Yu,mkdir as Xu,writeFile as Zu,rename as gh}from"node:fs/promises";import Qu from"mime";import*as yh from"rs-module-lexer";import{findStaticImports as fo,isNodeBuiltin as fn,parseNodeModulePath as qa,parseStaticImport as $h,findExports as bh,fileURLToPath as wh,resolveModuleExportNames as vh,resolvePath as ep,pathToFileURL as xh}from"mlly";import Eh from"rollup-plugin-license";import it from"typescript";import Sh from"clean-css";import{minify as kh}from"html-minifier-next";import{init as tp,parse as jh}from"cjs-module-lexer";import{parseSync as mo}from"oxc-parser";import Ah,{createHash as Oh,randomUUID as Rh}from"node:crypto";import{walk as Ch}from"estree-walker";import{cjsInteropPlugin as rp}from"@visulima/packem-rollup/plugin/cjs-interop";import{JsonPlugin as Th}from"@visulima/packem-rollup/plugin/json";import{confirm as Nh,isCancel as Ph,spinner as Mh}from"@clack/prompts";import Ja from"node:path/posix";import{readTsConfig as _h,findTsConfig as Ih}from"@visulima/tsconfig";import{createDefu as Wh}from"defu";import Bh from"child_process";import Dh from"node:child_process";import{promisify as Lh,debuglog as Fh}from"node:util";import{distance as Hh}from"fastest-levenshtein";import{createBrotliCompress as qh,constants as Jh,createGzip as zh}from"node:zlib";import{Buffer as Uh}from"node:buffer";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
2
|
+
const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
|
|
3
|
+
const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
|
|
4
|
+
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
5
|
+
var Gh=Object.defineProperty,ne=(e,t)=>Gh(e,"name",{value:t,configurable:!0});const Vh=_e(import.meta.url),Jt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ho=ne(e=>{if(typeof Jt<"u"&&Jt.versions&&Jt.versions.node){const[t,r]=Jt.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return Jt.getBuiltinModule(e)}return Vh(e)},"__cjs_getBuiltinModule"),{createRequire:Kh}=ho("node:module"),jt=Jt,{execFileSync:Yh}=ho("node:child_process"),Nr=ho("node:fs"),Xh=ho("node:tty"),wO={alert:7,critical:6,debug:1,emergency:8,error:5,informational:2,notice:3,trace:2,warning:4},Zh={alert:{color:"red",label:"alert",logLevel:"alert"},await:{color:"blue",label:"awaiting",logLevel:"informational"},complete:{color:"cyan",label:"complete",logLevel:"informational"},critical:{color:"redBright",label:"critical",logLevel:"critical"},debug:{color:"gray",label:"debug",logLevel:"debug"},emergency:{color:"redBright",label:"emergency",logLevel:"emergency"},error:{color:"red",label:"error",logLevel:"error"},info:{color:"blueBright",label:"info",logLevel:"informational"},log:{label:"",logLevel:"informational"},notice:{color:"magentaBright",label:"notice",logLevel:"notice"},pending:{color:"magenta",label:"pending",logLevel:"informational"},start:{color:"greenBright",label:"start",logLevel:"informational"},stop:{color:"red",label:"stop",logLevel:"informational"},success:{color:"green",label:"success",logLevel:"informational"},trace:{color:"cyanBright",label:"trace",logLevel:"trace"},wait:{color:"blue",label:"waiting",logLevel:"informational"},warn:{color:"yellow",label:"warning",logLevel:"warning"},warning:{color:"yellow",label:"warning",logLevel:"warning"},watch:{color:"yellowBright",label:"watching",logLevel:"informational"}},Qh=Symbol("EMPTY");var eg=Object.defineProperty,tg=ne((e,t)=>eg(e,"name",{value:t,configurable:!0}),"g$6");const rg=tg(e=>{const t=Object.keys(e).map(r=>e[r].label??"");return t.length===0?"":t.reduce((r,n)=>r.length>n.length?r:n,"")},"getLongestLabel");var ng=Object.defineProperty,np=ne((e,t)=>ng(e,"name",{value:t,configurable:!0}),"T$5"),og=Object.defineProperty,ie=np((e,t)=>og(e,"name",{value:t,configurable:!0}),"l"),sg=Object.defineProperty,ig=ie((e,t)=>sg(e,"name",{value:t,configurable:!0}),"L");const He=ig((e,t,r,n,o,s=", ")=>{const i=e.length;if(i===0)return"";let a=n;o!==void 0&&(a=o);const l=r.truncate;let u="",c="",p="";for(let f=0;f<i;f+=1){const d=f+1===e.length,m=f+2===e.length;p=`…(${String(e.length-f)})`;let h=e[f];r.truncate=l-u.length-(d?0:s.length);const y=c||a(h,t,r,n)+(d?"":s),$=u.length+y.length,g=$+p.length;if(d&&$>l&&u.length+p.length<=l||!d&&!m&&g>l)break;h=e[f+1];const w=m?"":s;if(d?c="":c=a(h,t,r,n)+w,!d&&m&&g>l&&$+c.length>l)break;if(u+=y,!d&&!m&&$+c.length>=l){p=`…(${String(e.length-f-1)})`;break}p=""}return`${u}${p}`},"inspectList");var ag=Object.defineProperty,go=ie((e,t)=>ag(e,"name",{value:t,configurable:!0}),"s$6");const lg=go(([e,t],r,n)=>(n.truncate-=3,t?`${n.stylize(String(e),"yellow")}=${n.stylize(`"${t}"`,"string")}`:n.stylize(String(e),"yellow")),"inspectAttribute"),cg=go((e,t,r)=>{switch(e.nodeType){case 1:return op(e,e,r,t);case 3:return t(e.data,t,r);default:return t(e,t,r)}},"inspectNode"),$i=go((e,t,r,n)=>He(e,e,t,r,cg,`
|
|
6
|
+
`),"inspectNodeCollection"),op=go((e,t,r,n)=>{const o=e.getAttributeNames(),s=e.tagName.toLowerCase(),i=r.stylize(`<${s}`,"special"),a=r.stylize(">","special"),l=r.stylize(`</${s}>`,"special");r.truncate-=s.length*2+5;let u="";o.length>0&&(u+=" ",u+=He(o.map(f=>[f,e.getAttribute(f)]),t,r,n,lg," ")),r.truncate-=u.length;const{truncate:c}=r;let p=$i(e.children,r,n,void 0);return p&&p.length>c&&(p=`…(${String(e.children.length)})`),`${i}${u}${a}${p}${l}`},"inspectHTMLElement");var ug=Object.defineProperty,pg=ie((e,t)=>ug(e,"name",{value:t,configurable:!0}),"n$4");const fg=pg((e,t,r)=>e.length===0?"Arguments []":(t.truncate-=13,`Arguments [ ${He(e,e,t,r)} ]`),"inspectArguments");var dg=Object.defineProperty,sp=ie((e,t)=>dg(e,"name",{value:t,configurable:!0}),"r$3");const mg=sp((e,t)=>{let r;if(e===" ")r=" ";else if(typeof e=="number"&&e>0)r=Array.from({length:e+1}).join(" ");else return;return{base:r,prev:`
|
|
7
|
+
${Array.from({length:t+1}).join(r)}`}},"getIndent"),yo=sp((e,t)=>{if(e.length===0)return"";const r=t.prev+t.base;return r+e.split(", ").join(`,${r}`)+t.prev},"indentedJoin");var hg=Object.defineProperty,ip=ie((e,t)=>hg(e,"name",{value:t,configurable:!0}),"i$5");const gg=/^[a-z_]\w*$/i,yg=/^"|"$/g,$g=ip((e,t)=>{if(gg.test(e))return e;const r=JSON.stringify(e);return t.quoteStyle==="double"?r.replaceAll('"',String.raw`\"`):r.replaceAll("'",String.raw`\'`).replaceAll(String.raw`\"`,'"').replaceAll(yg,"'")},"quoteComplexKey"),qr=ip(([e,t],r,n,o)=>{n.truncate-=2;let s;typeof e=="string"?s=$g(e,n):typeof e=="number"?s=String(e):s=`[${o(e,r,n)}]`,n.truncate-=s.length;const i=o(t,r,n);return`${s}: ${i}`},"inspectProperty");var bg=Object.defineProperty,ap=ie((e,t)=>bg(e,"name",{value:t,configurable:!0}),"p$4");const wg=ap(e=>{for(const t of e)if(Array.isArray(t)||typeof t=="object"&&t!==null)return!0;return!1},"multiLineValues"),vg=ap((e,t,r,n)=>{const o=Object.keys(e).slice(e.length);if(e.length===0&&o.length===0)return"[]";t.truncate-=4;let s=He(e,e,t,r);t.truncate-=s.length;let i="";o.length>0&&(i=He(o.map(l=>[l,e[l]]),e,t,r,qr));const a=n&&wg(e);return a&&(s=yo(s,n)),`[${a?"":" "}${s}${i?`, ${i}`:""}${a?"":" "}]`},"inspectArray");var xg=Object.defineProperty,Eg=ie((e,t)=>xg(e,"name",{value:t,configurable:!0}),"o$7");const za=/\d(?=(?:\d{3})+(?!\d))/g,Sg=/\d{3}/g,kg=/_$/,lp=Eg((e,t)=>{if(e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY||t.includes("e"))return t;if(typeof e=="number"){const r=e<0?-Math.floor(-e):Math.floor(e);if(r!==e){const n=String(r),o=t.slice(n.length+1);return`${n.replace(za,"$&_")}.${o.replace(Sg,"$&_").replace(kg,"")}`}}return t.replace(za,"$&_")},"addNumericSeparator");var jg=Object.defineProperty,cp=ie((e,t)=>jg(e,"name",{value:t,configurable:!0}),"i$4");const Ag=cp(e=>e>="\uD800"&&e<="\uDBFF","isHighSurrogate"),yt=cp((e,t,r="…")=>{e=String(e);const n=r.length,o=e.length;if(n>t&&o>n)return r;if(o>t&&o>n){let s=t-n;return s>0&&Ag(e[s-1])&&(s-=1),`${e.slice(0,s)}${r}`}return e},"truncate");var Og=Object.defineProperty,Rg=ie((e,t)=>Og(e,"name",{value:t,configurable:!0}),"e$4");const Ua=Rg((e,t)=>{let r=yt(e.toString(),t.truncate-1);return r!=="…"&&(r+="n"),t.stylize(t.numericSeparator?lp(e,r):r,"bigint")},"inspectBigInt");var Cg=Object.defineProperty,Tg=ie((e,t)=>Cg(e,"name",{value:t,configurable:!0}),"y");const Ng=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:void 0),Tn=Tg((e,t,r,n)=>{if("window"in globalThis&&e===globalThis)return"{ [object Window] }";if(e===globalThis||"global"in globalThis&&e===globalThis)return"{ [object globalThis] }";const o=Object.getOwnPropertyNames(e),s=Object.getOwnPropertySymbols(e),i=Ng(e)===Object.prototype||e.constructor===Object,a=e instanceof Object?"":"null prototype";let l;!i&&Symbol.toStringTag in e?l=e[Symbol.toStringTag]:l=a?"Object":"";const u=l||a?`[${[l,a].filter(Boolean).join(": ")}] `:"";if(o.length===0&&s.length===0)return`${u}{}`;t.truncate-=4;const c=He(o.map(d=>[d,e[d]]),e,t,r,qr),p=He(s.map(d=>[d,e[d]]),e,t,r,qr);let f="";return c&&p&&(f=", "),n?`${u}{${yo(c+f+p,n)}}`:`${u}{ ${c}${f}${p} }`},"inspectObject");var Pg=Object.defineProperty,Mg=ie((e,t)=>Pg(e,"name",{value:t,configurable:!0}),"s$3");const _g=Mg((e,t,r,n)=>{let o="";return o=o||e.constructor.name,(!o||o==="_class")&&(o="<Anonymous Class>"),t.truncate-=o.length,`${o} ${Tn(e,t,r,n)}`},"inspectClass");var Ig=Object.defineProperty,Wg=ie((e,t)=>Ig(e,"name",{value:t,configurable:!0}),"i$3");const Bg=Wg((e,t)=>{const r=e.toJSON();if(r===null)return"Invalid Date";const n=r.split("T"),o=n[0];return t.stylize(`${o}T${yt(n[1],t.truncate-o.length-1)}`,"date")},"inspectDate");var Dg=Object.defineProperty,Lg=ie((e,t)=>Dg(e,"name",{value:t,configurable:!0}),"c$4");const Fg=new Set(["column","columnNumber","description","fileName","line","lineNumber","message","name","number","stack"]),Hg=Lg((e,t,r)=>{const n=Object.getOwnPropertyNames(e).filter(a=>!Fg.has(a)),{name:o}=e;t.truncate-=o.length;let s="";typeof e.message=="string"?s=yt(e.message,t.truncate):n.unshift("message"),s=s?`: ${s}`:"",t.truncate-=s.length+5;const i=He(n.map(a=>[a,e[a]]),e,t,r,qr);return`${o}${s}${i?` { ${i} }`:""}`},"inspectObject");var qg=Object.defineProperty,Jg=ie((e,t)=>qg(e,"name",{value:t,configurable:!0}),"c$3");const Ga=Jg((e,t)=>{const r=e[Symbol.toStringTag]||"Function",n=e.toString();if(n.length<t.truncate-12)return t.stylize(`[${r}: ${n}]`,"special");const{name:o}=e;return o?t.stylize(`[${r} ${yt(o,t.truncate-11)}]`,"special"):t.stylize(`[${r}]`,"special")},"inspectFunction");var zg=Object.defineProperty,up=ie((e,t)=>zg(e,"name",{value:t,configurable:!0}),"p$3");const Ug=up(([e,t],r,n,o)=>(n.truncate-=4,e=o(e,r,n),n.truncate-=e.length,`${e} => ${o(t,r,n)}`),"inspectMapEntry"),Gg=up((e,t,r,n)=>{if(e.size<=0)return"Map (0) {}";t.truncate-=7;let o=He([...e.entries()],e,t,r,Ug);return n&&(o=yo(o,n)),`Map (${String(e.size)}) {${n?"":" "}${o}${n?"":" "}}`},"inspectMap");var Vg=Object.defineProperty,Kg=ie((e,t)=>Vg(e,"name",{value:t,configurable:!0}),"e$3");function rr(e,t){return Number.isNaN(e)?t.stylize("NaN","number"):e===Number.POSITIVE_INFINITY?t.stylize("Infinity","number"):e===Number.NEGATIVE_INFINITY?t.stylize("-Infinity","number"):e===0?t.stylize(1/e===Number.POSITIVE_INFINITY?"+0":"-0","number"):t.stylize(yt(t.numericSeparator?lp(e,e.toString()):e.toString(),t.truncate),"number")}ne(rr,"j$5");np(rr,"P");ie(rr,"u$3");Kg(rr,"inspectNumber");var Yg=Object.defineProperty,Xg=ie((e,t)=>Yg(e,"name",{value:t,configurable:!0}),"e$2");const Zg=Xg(()=>"Promise{…}","getPromiseValue");var Qg=Object.defineProperty,ey=ie((e,t)=>Qg(e,"name",{value:t,configurable:!0}),"p$1");const ty=ey((e,t)=>{const r=t.truncate-(2+e.flags.length);return t.stylize(`/${yt(e.source,r)}/${e.flags}`,"regexp")},"inspectRegExp");var ry=Object.defineProperty,ny=ie((e,t)=>ry(e,"name",{value:t,configurable:!0}),"i$1");const oy=ny((e,t,r,n)=>{if(e.size===0)return"Set (0) {}";t.truncate-=7;let o=He([...e],e,t,r);return n&&(o=yo(o,n)),`Set (${String(e.size)}) {${n?"":" "}${o}${n?"":" "}}`},"inspectSet");var sy=Object.defineProperty,iy=ie((e,t)=>sy(e,"name",{value:t,configurable:!0}),"l");const ay=iy((e,t)=>{const r=t.quoteStyle==="double"?'"':"'";return t.quoteStyle==="double"&&(e=e.replaceAll('"','"')),r+e+r},"wrapQuotes");var ly=Object.defineProperty,pp=ie((e,t)=>ly(e,"name",{value:t,configurable:!0}),"e$1");const Va=new RegExp(String.raw`['\0-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5`+String.raw`\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]`,"g"),cy={" ":String.raw`\t`,"\n":String.raw`\n`,"\f":String.raw`\f`,"\r":String.raw`\r`,"\b":String.raw`\b`,"'":String.raw`\'`,"\\":"\\\\"},uy=16,py=pp(e=>cy[e]||String.raw`\u${`0000${e.codePointAt(0).toString(uy)}`.slice(-4)}`,"escape"),Ka=pp((e,t)=>(Va.test(e)&&(e=e.replaceAll(Va,py)),t.stylize(ay(yt(e,t.truncate-2),t),"string")),"inspectString");var fy=Object.defineProperty,dy=ie((e,t)=>fy(e,"name",{value:t,configurable:!0}),"o");const Ya=dy(e=>"description"in Symbol.prototype?e.description?`Symbol(${e.description})`:"Symbol()":e.toString(),"inspectSymbol");var my=Object.defineProperty,fp=ie((e,t)=>my(e,"name",{value:t,configurable:!0}),"f");const hy=fp(e=>typeof Buffer=="function"&&e instanceof Buffer?"Buffer":e[Symbol.toStringTag],"getArrayName"),et=fp((e,t,r)=>{const n=hy(e);t.truncate-=n.length+4;const o=Object.keys(e).slice(e.length);if(e.length===0&&o.length===0)return`${n}[]`;let s="";for(let a=0;a<e.length;a++){const l=`${t.stylize(yt(e[a],t.truncate),"number")}${a===e.length-1?"":", "}`;if(t.truncate-=l.length,e[a]!==e.length&&t.truncate<=3){s+=`…(${String(e.length-e[a]+1)})`;break}s+=l}let i="";return o.length>0&&(i=He(o.map(a=>[a,e[a]]),e,t,r,qr)),`${n}[ ${s}${i?`, ${i}`:""} ]`},"inspectTypedArray");var gy=Object.defineProperty,xe=ie((e,t)=>gy(e,"name",{value:t,configurable:!0}),"r");const qn=new WeakMap,bi={},yy={Arguments:fg,Array:vg,ArrayBuffer:xe(()=>"","ArrayBuffer"),BigInt:Ua,bigint:Ua,Boolean:xe((e,t)=>t.stylize(String(e),"boolean"),"Boolean"),boolean:xe((e,t)=>t.stylize(String(e),"boolean"),"boolean"),DataView:xe(()=>"","DataView"),Date:Bg,Error:Hg,Float32Array:et,Float64Array:et,Function:Ga,function:Ga,Generator:xe(()=>"","Generator"),HTMLCollection:$i,Int8Array:et,Int16Array:et,Int32Array:et,Map:Gg,NodeList:$i,null:xe((e,t)=>t.stylize("null","null"),"null"),Number:rr,number:rr,Promise:Zg,RegExp:ty,Set:oy,String:Ka,string:Ka,Symbol:Ya,symbol:Ya,Uint8Array:et,Uint8ClampedArray:et,Uint16Array:et,Uint32Array:et,undefined:xe((e,t)=>t.stylize("undefined","undefined"),"undefined"),WeakMap:xe((e,t)=>t.stylize("WeakMap{…}","special"),"WeakMap"),WeakSet:xe((e,t)=>t.stylize("WeakSet{…}","special"),"WeakSet")},Xa=Symbol.for("nodejs.util.inspect.custom"),$y=xe((e,t,r,n)=>{if(!("window"in globalThis)&&typeof e[Xa]=="function")return e[Xa](n,t);if("inspect"in e&&typeof e.inspect=="function")return e.inspect(n,t);if("constructor"in e&&qn.has(e.constructor))return qn.get(e.constructor)?.(e,t)??"unknown";const o=bi[r];return o?o(e,t):""},"inspectCustom"),dp=xe((e,t,r,n)=>{if(n.includes(e))return"[Circular]";if(r>=t.depth&&t.depth>0&&typeof e=="object")return Array.isArray(e)?"[Array]":"[Object]";const o=xe((u,c,p)=>(c&&(n=[...n,c]),dp(u,p,r+1,n)),"inspect"),s=t.indent?mg(t.indent,r):void 0;let i=e===null?"null":typeof e;i==="object"&&(i=Object.prototype.toString.call(e).slice(8,-1));const a=yy[i];if(a!==void 0)return a(e,t,o,s);if(t.customInspect&&e){const u=$y(e,t,i,t.depth-r);if(u)return typeof u=="string"?u:o(u,e,t)}const l=e?Object.getPrototypeOf(e):!1;return l===Object.prototype||l===null?Tn(e,t,o,s):e&&typeof HTMLElement=="function"&&e instanceof HTMLElement?op(e,e,t,o):"constructor"in e?e.constructor!==Object?_g(e,t,o,s):Tn(e,t,o,s):e===Object(e)?Tn(e,t,o,s):t.stylize(String(e),i)},"internalInspect"),Za=xe((e,t={})=>{const r={breakLength:Number.POSITIVE_INFINITY,customInspect:!0,depth:5,indent:void 0,maxArrayLength:Number.POSITIVE_INFINITY,numericSeparator:!0,quoteStyle:"single",showHidden:!1,showProxy:!1,stylize:xe(n=>n,"stylize"),truncate:Number.POSITIVE_INFINITY,...t};if(r.indent!==void 0&&r.indent!==" "&&!(Number.parseInt(r.indent,10)===r.indent&&r.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `undefined`');return dp(e,r,0,[])},"inspect");xe((e,t)=>qn.has(e)?!1:(qn.set(e,t),!0),"registerConstructor");xe((e,t)=>e in bi?!1:(bi[e]=t,!0),"registerStringTag");var by=Object.defineProperty,wy=ne((e,t)=>by(e,"name",{value:t,configurable:!0}),"r$6");const vy=wy((e,t)=>(t.__write??t.write.bind(t)).call(t,e),"writeStream");var xy=Object.defineProperty,Ey=ne((e,t)=>xy(e,"name",{value:t,configurable:!0}),"A$4"),Sy=Object.defineProperty,Ui=Ey((e,t)=>Sy(e,"name",{value:t,configurable:!0}),"$"),ky=Object.defineProperty,jy=Ui((e,t)=>ky(e,"name",{value:t,configurable:!0}),"r$1");const Ay=jy(e=>e.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
8
|
+
`),"normalizeLF"),Oy=globalThis.process??Object.create(null),Qa={versions:{}},el=new Proxy(Oy,{get(e,t){if(t in e)return e[t];if(t in Qa)return Qa[t]}});var Ry=Object.defineProperty,Cy=Ui((e,t)=>Ry(e,"name",{value:t,configurable:!0}),"b");const Ty=Cy((e,t,r,n)=>{const o={column:0,line:-1,...e.start},s={...o,...e.end},i=o.line,a=o.column,l=s.line,u=s.column;let c=Math.max(i-(r+1),0),p=Math.min(t.length,l+n);i===-1&&(c=0),l===-1&&(p=t.length);const f=l-i,d={};if(f)for(let m=0;m<=f;m++){const h=m+i;if(!a)d[h]=!0;else if(m===0){const y=t[h-1]?.length;d[h]=[a,(y??0)-a+1]}else if(m===f)d[h]=[0,u];else{const y=t[h-m]?.length;d[h]=[0,y]}}else a===u?d[i]=a?[a,0]:!0:d[i]=[a,(u??0)-(a??0)];return{end:p,markerLines:d,start:c}},"getMarkerLines");var Ny=Object.defineProperty,dn=Ui((e,t)=>Ny(e,"name",{value:t,configurable:!0}),"t");const Py=el.platform==="win32"&&!el.env?.WT_SESSION?">":"❯",My=dn((e,t,r)=>{const n={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,tabWidth:4,...r,color:{gutter:dn(m=>m,"gutter"),marker:dn(m=>m,"marker"),message:dn(m=>m,"message"),...r?.color}},o=typeof t.start.column=="number";let s=Ay(e).split(`
|
|
9
|
+
`);typeof n.tabWidth=="number"&&(s=s.map(m=>m.replaceAll(" "," ".repeat(n.tabWidth))));const{end:i,markerLines:a,start:l}=Ty(t,s,n.linesAbove,n.linesBelow),u=String(i).length,{gutter:c,marker:p,message:f}=n.color;let d=s.slice(l,i).map((m,h)=>{const y=l+1+h,$=a[y],g=` ${String(y)}`.slice(-u),w=!a[y+1],b=` ${g}${n.showGutter?" |":""}`;if($){let v="";if(Array.isArray($)){const S=m.replaceAll(/[^\t]/g," ").slice(0,Math.max($[0]-1,0)),x=$[1]||1;v=[`
|
|
10
|
+
`,n.prefix+c(b.replaceAll(/\d/g," "))," ",S,p("^").repeat(x)].join(""),w&&n.message&&(v+=` ${f(n.message)}`)}return[n.prefix+p(Py),c(b),m.length>0?` ${m}`:"",v].join("")}return`${n.prefix} ${c(b)}${m.length>0?` ${m}`:""}`}).join(`
|
|
11
|
+
`);return n.message&&!o&&(d=`${n.prefix+" ".repeat(u+1)+n.message}
|
|
12
|
+
${d}`),d},"codeFrame");var _y=Object.defineProperty,Iy=ne((e,t)=>_y(e,"name",{value:t,configurable:!0}),"x$3"),Wy=Object.defineProperty,By=Iy((e,t)=>Wy(e,"name",{value:t,configurable:!0}),"x"),Dy=Object.defineProperty,ot=By((e,t)=>Dy(e,"name",{value:t,configurable:!0}),"u");const Pt=ot((e,...t)=>{process.env.DEBUG&&process.env.DEBUG==="true"&&console.debug(`error:parse-stacktrace: ${e}`,...t)},"debugLog"),Mt="<unknown>",Ly=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Fy=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,Hy=/(.*?):(\d+):(\d+)(?:\s<-\s.+:\d+:\d+)?/,qy=/eval\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*<anonymous>?:(\d+)?:(\d+)/,Jy=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,zy=/in\s(.*)\s\(at\s(.+)\)\sat/,Uy=/^(?:.*@)?(.*):(\d+):(\d+)$/,Gy=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Vy=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Ky=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,tl=/\(error: (.*)\)/,Yy=/at\s/,Xy=/^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/,Zy=/^\s+|\s+$/g,Qy=/\S*(?:Error: |AggregateError:)/,mp=/^Anonymous function$/,e$=/^\s*in\s.*/,t$=/^.*?\s*at\s.*/,r$=/^.*?\s*@.*|\[native code\]/,hp=ot((e,t)=>{const r=e.includes("safari-extension"),n=e.includes("safari-web-extension");return r||n?[e.includes("@")?e.split("@")[0]:Mt,r?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},"extractSafariExtensionDetails"),gp=ot((e,t)=>{const r=Hy.exec(t);r&&(e.file=r[1],e.line=+r[2],e.column=+r[3])},"parseMapped"),n$=ot(e=>{const t=zy.exec(e);if(t){Pt(`parse nested node error stack line: "${e}"`,`found: ${JSON.stringify(t)}`);const n=t[2].split(":");return{column:n[2]?+n[2]:void 0,file:n[0],line:n[1]?+n[1]:void 0,methodName:t[1]??Mt,raw:e,type:void 0}}const r=Jy.exec(e);if(r){Pt(`parse node error stack line: "${e}"`,`found: ${JSON.stringify(r)}`);const n={column:r[4]?+r[4]:void 0,file:r[2]?r[2].replace(Yy,""):void 0,line:r[3]?+r[3]:void 0,methodName:r[1]??Mt,raw:e,type:e.startsWith("internal")?"internal":void 0};return gp(n,`${r[2]}:${r[3]}:${r[4]}`),n}},"parseNode"),o$=ot(e=>{const t=Ly.exec(e);if(t){Pt(`parse chrome error stack line: "${e}"`,`found: ${JSON.stringify(t)}`);const r=t[2]?.startsWith("native"),n=t[2]?.startsWith("eval")||t[1]?.startsWith("eval");let o,s;if(n){const u=Fy.exec(e);if(u){const c=Xy.exec(u[1]);c?(t[2]=c[4]??c[1],t[3]=c[5]??c[2],t[4]=c[3]):u[2]&&(t[2]=u[1]),u[2]&&(o={column:u[4]?+u[4]:void 0,file:u[2],line:u[3]?+u[3]:void 0,methodName:"eval",raw:e,type:"eval"})}else{const c=qy.exec(e);c&&(s={column:c[4]?+c[4]:void 0,file:c[2],line:c[3]?+c[3]:void 0},o={column:c[6]?+c[6]:void 0,file:c[1],line:c[5]?+c[5]:void 0,methodName:"eval",raw:c[0],type:"eval"})}}const[i,a]=hp(t[1]?t[1].replace(mp,"<anonymous>"):Mt,t[2]),l={column:t[4]?+t[4]:void 0,evalOrigin:o,file:a,line:t[3]?+t[3]:void 0,methodName:i,raw:e,type:n?"eval":r?"native":void 0};return s?(l.column=s.column,l.file=s.file,l.line=s.line):gp(l,`${a}:${t[3]}:${t[4]}`),l}},"parseChromium"),s$=ot((e,t)=>{const r=Gy.exec(e);if(r){Pt(`parse gecko error stack line: "${e}"`,`found: ${JSON.stringify(r)}`);const n=r[3]?.includes(" > eval"),o=n&&r[3]&&Vy.exec(r[3]);let s;n&&o&&(r[3]=o[1],s={column:r[5]?+r[5]:void 0,file:r[3],line:r[4]?+r[4]:void 0,methodName:"eval",raw:e,type:"eval"},r[4]=o[2]);const[i,a]=hp(r[1]?r[1].replace(mp,"<anonymous>"):Mt,r[3]);let l;(t?.type==="safari"||!n&&t?.type==="firefox")&&t.column?l=t.column:!n&&r[5]&&(l=+r[5]);let u;return(t?.type==="safari"||!n&&t?.type==="firefox")&&t.line?u=t.line:r[4]&&(u=+r[4]),{column:l,evalOrigin:s,file:a,line:u,methodName:i,raw:e,type:n?"eval":a.includes("[native code]")?"native":void 0}}},"parseGecko"),i$=ot((e,t)=>{const r=Ky.exec(e);if(!(r&&r[2].includes(" > eval"))&&r)return Pt(`parse firefox error stack line: "${e}"`,`found: ${JSON.stringify(r)}`),{column:r[4]?+r[4]:t?.column??void 0,file:r[2],line:r[3]?+r[3]:t?.line??void 0,methodName:r[1]||Mt,raw:e,type:void 0}},"parseFirefox"),a$=ot(e=>{const t=Uy.exec(e);if(t)return Pt(`parse react android native error stack line: "${e}"`,`found: ${JSON.stringify(t)}`),{column:t[3]?+t[3]:void 0,file:t[1],line:t[2]?+t[2]:void 0,methodName:Mt,raw:e,type:void 0}},"parseReactAndroidNative"),yp=ot((e,{filter:t,frameLimit:r=50}={})=>{const n=e;let o=(typeof n.stacktrace=="string"?n.stacktrace:e.stack??"").split(`
|
|
13
|
+
`).map(s=>(tl.test(s)?s.replace(tl,"$1"):s).replaceAll(Zy,"")).filter(s=>!Qy.test(s)&&s!=="eval code");return t&&(o=o.filter(s=>t(s))),o=o.slice(0,r),o.reduce((s,i,a)=>{if(!i||i.length>1024)return s;let l;if(e$.test(i))l=n$(i);else if(t$.test(i))l=o$(i);else if(r$.test(i)){let u;if(a===0){const c=e,p=c.columnNumber,f=c.lineNumber,d=c.line,m=c.column;p||f?u={column:p,line:f,type:"firefox"}:(d||m)&&(u={column:m,line:d,type:"safari"})}l=i$(i,u)??s$(i,u)}else l=a$(i);return l?s.push(l):Pt(`parse error stack line: "${i}"`,"not parser found"),s},[])},"parseStacktrace");var l$=Object.defineProperty,c$=ne((e,t)=>l$(e,"name",{value:t,configurable:!0}),"p$6"),u$=Object.defineProperty,$p=c$((e,t)=>u$(e,"name",{value:t,configurable:!0}),"m");const p$=Kh(import.meta.url),zt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Gi=$p(e=>{if(typeof zt<"u"&&zt.versions&&zt.versions.node){const[t,r]=zt.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return zt.getBuiltinModule(e)}return p$(e)},"__cjs_getBuiltinModule"),{existsSync:f$,readFileSync:d$}=Gi("node:fs"),{relative:m$}=Gi("node:path"),{cwd:h$}=zt,{fileURLToPath:g$}=Gi("node:url");var y$=Object.defineProperty,he=$p((e,t)=>y$(e,"name",{value:t,configurable:!0}),"o");const ir=he((e,t,r)=>r===0?e:t===" "?e+" ".repeat(r):e+" ".repeat(t*r),"getPrefix"),$$=he((e,t)=>{const r=e.replace("async file:","file:");return m$(t,r.startsWith("file:")?g$(r):r)},"getRelativePath"),b$=he((e,t,r)=>{if(t)return r.title(e.message);const n=e.message?`: ${e.message}`:"";return r.title(e.name+n)},"getTitleText"),bp=he((e,{color:t,hideErrorTitle:r,indentation:n,prefix:o},s)=>`${ir(o,n,s)}${b$(e,r,t)}
|
|
14
|
+
`,"getMessage"),wp=he((e,{color:t,indentation:r,prefix:n},o)=>{if(e.hint===void 0)return;const s=ir(n,r,o);let i="";if(Array.isArray(e.hint))for(const a of e.hint)i+=`${s+a}
|
|
15
|
+
`;else i+=s+e.hint;return t.hint(i)},"getHint"),Vi=he((e,{color:t,cwd:r,displayShortPath:n,indentation:o,prefix:s},i=0)=>{const a=n?$$(e.file,r):e.file,{fileLine:l,method:u}=t;return`${ir(s,o,i)}at ${e.methodName?`${u(e.methodName)} `:""}${l(a)}:${l(e.line?.toString()??"")}`},"getMainFrame"),vp=he((e,{color:t,indentation:r,linesAbove:n,linesBelow:o,prefix:s,showGutter:i,showLineNumbers:a,tabWidth:l},u)=>{if(e.file===void 0)return;const c=e.file.replace("file://","");if(!f$(c))return;const p=d$(c,"utf8");return My(p,{start:{column:e.column,line:e.line}},{color:t,linesAbove:n,linesBelow:o,prefix:ir(s,r,u),showGutter:i,showLineNumbers:a,tabWidth:l})},"getCode"),xp=he((e,t,r)=>{if(e.errors.length===0)return;let n=`${ir(t.prefix,t.indentation,r)}Errors:
|
|
16
|
+
|
|
17
|
+
`,o=!0;for(const s of e.errors)o?o=!1:n+=`
|
|
18
|
+
|
|
19
|
+
`,n+=Sp(s,{...t,framesMaxLimit:1,hideErrorCodeView:t.hideErrorErrorsCodeView},r+1);return`
|
|
20
|
+
${n}`},"getErrors"),Ep=he((e,t,r)=>{let n=`${ir(t.prefix,t.indentation,r)}Caused by:
|
|
21
|
+
|
|
22
|
+
`;const o=e.cause;n+=bp(o,t,r);const s=yp(o).shift(),i=wp(o,t,r);if(i&&(n+=`${i}
|
|
23
|
+
`),s&&(n+=Vi(s,t,r),!t.hideErrorCauseCodeView)){const a=vp(s,t,r);a!==void 0&&(n+=`
|
|
24
|
+
${a}`)}if(o.cause)n+=`
|
|
25
|
+
${Ep(o,t,r+1)}`;else if(o instanceof AggregateError){const a=xp(o,t,r);a!==void 0&&(n+=`
|
|
26
|
+
${a}`)}return`
|
|
27
|
+
${n}`},"getCause"),w$=he((e,t)=>(e.length>0?`
|
|
28
|
+
`:"")+e.map(r=>Vi(r,t)).join(`
|
|
29
|
+
`),"getStacktrace"),Sp=he((e,t,r)=>{const n={cwd:h$(),displayShortPath:!1,filterStacktrace:void 0,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...t,color:{fileLine:he(i=>i,"fileLine"),gutter:he(i=>i,"gutter"),hint:he(i=>i,"hint"),marker:he(i=>i,"marker"),message:he(i=>i,"message"),method:he(i=>i,"method"),title:he(i=>i,"title"),...t.color}},o=yp(e,{filter:t.filterStacktrace,frameLimit:n.framesMaxLimit}),s=o.shift();return[t.hideMessage?void 0:bp(e,n,r),wp(e,n,r),s?Vi(s,n,r):void 0,s&&!n.hideErrorCodeView?vp(s,n,r):void 0,e instanceof AggregateError?xp(e,n,r):void 0,e.cause===void 0?void 0:Ep(e,n,r),o.length>0?w$(o,n):void 0].filter(Boolean).join(`
|
|
30
|
+
`).replaceAll("\\","/")},"internalRenderError"),Go=he((e,t={})=>{if(t.framesMaxLimit!==void 0&&t.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return Sp(e,t,0)},"renderError");var v$=Object.defineProperty,Ki=ne((e,t)=>v$(e,"name",{value:t,configurable:!0}),"s$3"),x$=Object.defineProperty,$o=Ki((e,t)=>x$(e,"name",{value:t,configurable:!0}),"l");const Yi=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],Xi=[12288,12288,65281,65376,65504,65510],Zi=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],Qi=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],bo=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var E$=Object.defineProperty,S$=$o((e,t)=>E$(e,"name",{value:t,configurable:!0}),"r$1");const en=S$((e,t)=>{let r=0,n=Math.floor(e.length/2)-1;for(;r<=n;){const o=Math.floor((r+n)/2),s=o*2;if(t<e[s])n=o-1;else if(t>e[s+1])r=o+1;else return!0}return!1},"isInRange");var k$=Object.defineProperty,It=$o((e,t)=>k$(e,"name",{value:t,configurable:!0}),"r");const j$=Yi[0],A$=Yi.at(-1),O$=Xi[0],R$=Xi.at(-1),C$=Zi[0],T$=Zi.at(-1),N$=Qi[0],P$=Qi.at(-1),M$=bo[0],_$=bo.at(-1),rl=19968,[I$,W$]=tn(bo);function tn(e){let t=e[0],r=e[1];for(let n=0;n<e.length;n+=2){const o=e[n],s=e[n+1];if(rl>=o&&rl<=s)return[o,s];s-o>r-t&&(t=o,r=s)}return[t,r]}ne(tn,"b$2");Ki(tn,"b");$o(tn,"N");It(tn,"findWideFastPathRange");const kp=It(e=>e<j$||e>A$?!1:en(Yi,e),"isAmbiguous"),jp=It(e=>e<O$||e>R$?!1:en(Xi,e),"isFullWidth"),B$=It(e=>e<C$||e>T$?!1:en(Zi,e),"isHalfWidth"),D$=It(e=>e<N$||e>P$?!1:en(Qi,e),"isNarrow"),Ap=It(e=>e>=I$&&e<=W$?!0:e<M$||e>_$?!1:en(bo,e),"isWide");function rn(e){return kp(e)?"ambiguous":jp(e)?"fullwidth":B$(e)?"halfwidth":D$(e)?"narrow":Ap(e)?"wide":"neutral"}ne(rn,"v$2");Ki(rn,"q");$o(rn,"getCategory");It(rn,"getCategory");var L$=Object.defineProperty,wo=ne((e,t)=>L$(e,"name",{value:t,configurable:!0}),"i$3"),F$=Object.defineProperty,vo=wo((e,t)=>F$(e,"name",{value:t,configurable:!0}),"a"),H$=Object.defineProperty,ea=vo((e,t)=>H$(e,"name",{value:t,configurable:!0}),"e");function ar(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}ne(ar,"s$2");wo(ar,"s");vo(ar,"r");ea(ar,"validate");function lr(e){return ar(e),rn(e)}ne(lr,"r$5");wo(lr,"p");vo(lr,"eastAsianWidthType");ea(lr,"eastAsianWidthType");function xo(e,{ambiguousAsWide:t=!1}={}){return ar(e),jp(e)||Ap(e)||t&&kp(e)?2:1}ne(xo,"o$5");wo(xo,"W");vo(xo,"eastAsianWidth");ea(xo,"eastAsianWidth");var q$=Object.defineProperty,J$=ne((e,t)=>q$(e,"name",{value:t,configurable:!0}),"p$3"),z$=Object.defineProperty,Op=J$((e,t)=>z$(e,"name",{value:t,configurable:!0}),"e"),U$=Object.defineProperty,G$=Op((e,t)=>U$(e,"name",{value:t,configurable:!0}),"E");const Rp=String.raw,nl=Rp`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,V$=G$(()=>new RegExp(Rp`\p{RI}{2}|(?)${nl}(?:\u200D${nl})*`,"gu"),"default");var K$=Object.defineProperty,Y$=Op((e,t)=>K$(e,"name",{value:t,configurable:!0}),"p");const cr=new Set(["\x1B",""]),Eo="\x07",Cp="[",ta="m",Jn="]8;;",X$=39,Z$=/[\u200B\uFEFF\u2060-\u2064]/g,Q$=new RegExp(`(?:\\${Cp}(?<code>\\d+)m|\\${Jn}(?<uri>.*)${Eo})`),e0=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),gr=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,mn=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,Nn=V$();Y$(e=>e.replace(Nn,""),"stripEmoji");var t0=Object.defineProperty,r0=ne((e,t)=>t0(e,"name",{value:t,configurable:!0}),"E"),n0=Object.defineProperty,o0=r0((e,t)=>n0(e,"name",{value:t,configurable:!0}),"A"),s0=Object.defineProperty,So=o0((e,t)=>s0(e,"name",{value:t,configurable:!0}),"d");const ol=new Map,hn=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Pn=So(e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other","getCharType"),i0=So((e,t)=>{const r=Math.floor(e/65536),n=e%65536;let o=ol.get(r);if(o||(o=new Map,ol.set(r,o)),o.has(n))return o.get(n);let s;if(Pn(e)==="latin")s=t.width.regular;else if(Pn(e)==="control")s=t.width.control;else if(Pn(e)==="wide")s=t.width.wide;else switch(lr(e)){case"ambiguous":{s=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{s=t.width.fullWidth;break}case"wide":{s=t.width.wide;break}default:s=t.width.regular}return o.set(n,s),s},"getCachedCharWidth"),a0=So(e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,"isCombiningCharacter"),wi=So((e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const r={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?wi(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},n=Math.max(0,r.truncation.limit-r.truncation.ellipsisWidth),{length:o}=e,s=o>1e4;let i=0,a=0,l=o,u=!1;const c=e.includes("\x1B")||e.includes("");for(;i<o;){if(c&&(e[i]==="\x1B"||e[i]==="")){if(e.startsWith("\x1B]8;;",i)){const y="\x1B]8;;\x07",$=y.length,g=e.indexOf("\x07",i+5);if(g!==-1){const w=e.indexOf(y,g+1);if(w!==-1){const b=w+$,v=e.slice(g+1,w).replace(gr,""),S=wi(v,{ambiguousIsNarrow:r.width.ambiguousIsNarrow,ansiWidth:r.width.ansi,controlWidth:r.width.control,countAnsiEscapeCodes:!1,ellipsis:r.truncation.ellipsis,ellipsisWidth:r.truncation.ellipsisWidth,emojiWidth:r.width.emoji,fullWidth:r.width.fullWidth,halfWidth:r.width.halfWidth,limit:Math.max(0,n-a),regularWidth:r.width.regular,tabWidth:r.width.tab,wideWidth:r.width.wide}),x=S.width;if(S.truncated)u=!0,l=Math.min(l,i);else if(a+x>n&&(l=Math.min(l,i),u=!0,a+x>r.truncation.limit))break;if(a+=x,i=b,u&&a>=r.truncation.limit)break;continue}}}if(gr.lastIndex=i,gr.test(e)){const y=gr.lastIndex-i,$=r.truncation.countAnsiEscapeCodes?y:r.width.ansi;if(a+$>n&&(l=Math.min(l,i),a+$>r.truncation.limit)){u=!0;break}a+=$,i=gr.lastIndex;continue}}const d=e.codePointAt(i);if(d===8203||d===65279||d>=8288&&d<=8292){i+=1;continue}if(d===9){if(a+r.width.tab>n&&(l=Math.min(l,i),a+r.width.tab>r.truncation.limit)){u=!0;break}a+=r.width.tab,i+=1;continue}if(hn.lastIndex=i,hn.test(e)){const y=(hn.lastIndex-i)*r.width.regular;if(a+y>n){const $=Math.floor((n-a)/r.width.regular);if(l=Math.min(l,i+$),a+y>r.truncation.limit){u=!0;break}}a+=y,i=hn.lastIndex;continue}if((d<=31||d>=127&&d<=159)&&(mn.lastIndex=i,mn.test(e))){const y=(mn.lastIndex-i)*r.width.control;if(a+y>n&&(l=Math.min(l,i+Math.floor((n-a)/r.width.control)),a+y>r.truncation.limit)){u=!0;break}a+=y,i=mn.lastIndex;continue}if(Nn.lastIndex=i,Nn.test(e)){if(a+r.width.emoji>n&&(l=Math.min(l,i),a+r.width.emoji>r.truncation.limit)){u=!0;break}a+=r.width.emoji,i=Nn.lastIndex;continue}const m=e.codePointAt(i)??0;if(a0(m)){i+=m>65535?2:1;continue}let h;if(s)h=i0(m,r);else switch(Pn(m)){case"control":{h=r.width.control;break}case"latin":{h=r.width.regular;break}case"wide":{h=r.width.wide;break}case"zero":{h=0;break}default:switch(lr(m)){case"ambiguous":{h=r.width.ambiguousIsNarrow?r.width.regular:r.width.wide;break}case"fullwidth":{h=r.width.fullWidth;break}case"wide":{h=r.width.wide;break}default:h=r.width.regular}}if(a+h>n&&(l=Math.min(l,i),a+h>r.truncation.limit)){u=!0;break}a+=h,i+=m>65535?2:1}let p=a,f=!1;return u&&r.truncation.limit>=r.truncation.ellipsisWidth&&(p=r.truncation.limit,f=!0),{ellipsed:f,index:u?l:o,truncated:u,width:p}},"getStringTruncatedWidth");var l0=Object.defineProperty,c0=ne((e,t)=>l0(e,"name",{value:t,configurable:!0}),"i$1"),u0=Object.defineProperty,p0=c0((e,t)=>u0(e,"name",{value:t,configurable:!0}),"e"),f0=Object.defineProperty,d0=p0((e,t)=>f0(e,"name",{value:t,configurable:!0}),"r");const Ne=d0((e,t={})=>wi(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,"getStringWidth");var m0=Object.defineProperty,Tp=ne((e,t)=>m0(e,"name",{value:t,configurable:!0}),"b"),h0=Object.defineProperty,Wt=Tp((e,t)=>h0(e,"name",{value:t,configurable:!0}),"d"),g0=Object.defineProperty,y0=Wt((e,t)=>g0(e,"name",{value:t,configurable:!0}),"a");const $0=/\x1B\[(\d+)m/;let Np=class{static{ne(this,"T")}static{Tp(this,"T")}static{Wt(this,"d")}static{y0(this,"AnsiStateTracker")}activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(t){const r=$0.exec(t);if(!r)return;const n=Number.parseInt(r[1],10);switch(n){case 0:{this.activeForeground=void 0,this.activeBackground=void 0,this.activeFormatting=[];break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}default:if(n>=30&&n<=37||n>=90&&n<=97)this.activeForeground=t;else if(n>=40&&n<=47||n>=100&&n<=107)this.activeBackground=t;else if([1,2,3,4,7,8,9].includes(n))this.activeFormatting.push(t);else if([22,23,24,27,28,29].includes(n)){const o={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[n];o&&(this.activeFormatting=this.activeFormatting.filter(s=>!s.includes(o)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const t=[];if(this.activeFormatting.length>0){const r={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].toReversed().forEach(n=>{const o=r[n];o&&t.push(o)})}return this.activeForeground&&t.push("\x1B[39m"),this.activeBackground&&t.push("\x1B[49m"),t.join("")}};var b0=Object.defineProperty,Pp=Wt((e,t)=>b0(e,"name",{value:t,configurable:!0}),"o");const Mp=Pp((e,t)=>{if(!cr.has(e[t]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const r=!0,n=e.slice(t+1,t+1+Jn.length).join("")===Jn;return{isInsideEscape:r,isInsideLinkEscape:n}},"checkEscapeSequence"),w0=Pp((e,t={})=>{const r=new Np;let n="",o=!1,s="",i="",a=!1;const l=[...e];for(let u=0;u<l.length;u++){const c=l[u];if(c&&cr.has(c)){if(n){const h=t.getWidth?.(n)??0,y={isEscapeSequence:!1,isGrapheme:!0,text:n,width:h};if(a&&(y.isHyperlink=!0,y.hyperlinkUrl=i),t.onSegment?.(y,r)===!1)return;n=""}o=!0,s=c;const d=Mp(l,u),{isInsideLinkEscape:m}=d;if(m){let h=u+1;for(i="";h<l.length;){const $=l[h];if($===Eo)break;i+=$,h+=1}i=i.slice(4);const y={hyperlinkUrl:i,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(t.onSegment?.(y,r)===!1)return;u=h,a=!0,o=!1,s="";continue}if(u+1<l.length&&l[u+1]==="\\"&&a){const h={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(t.onSegment?.(h,r)===!1)return;a=!1,i="",u+=1,o=!1,s="";continue}}if(o){if(s!==c&&(s+=c),c===ta){o=!1,r.processEscape(s);const d={isEscapeSequence:!0,isGrapheme:!1,text:s,width:0};if(t.onSegment?.(d,r)===!1)return;s=""}continue}n+=c;const p=t.getWidth?.(n)??0,f={isEscapeSequence:!1,isGrapheme:!0,text:n,width:p};if(a&&(f.isHyperlink=!0,f.hyperlinkUrl=i),t.onSegment?.(f,r)===!1)return;n=""}if(n){const u=t.getWidth?.(n)??0,c={isEscapeSequence:!1,isGrapheme:!0,text:n,width:u};a&&(c.isHyperlink=!0,c.hyperlinkUrl=i),t.onSegment?.(c,r)}if(s){const u={isEscapeSequence:!0,isGrapheme:!1,text:s,width:0};t.onSegment?.(u,r)}},"processAnsiString");var v0=Object.defineProperty,x0=Wt((e,t)=>v0(e,"name",{value:t,configurable:!0}),"t$1");const sl=x0(e=>`${cr.values().next().value}${Cp}${String(e)}${ta}`,"wrapAnsiCode");var E0=Object.defineProperty,S0=Wt((e,t)=>E0(e,"name",{value:t,configurable:!0}),"s");const il=S0(e=>`${cr.values().next().value}${Jn}${e}${Eo}`,"wrapAnsiHyperlink");var k0=Object.defineProperty,j0=Wt((e,t)=>k0(e,"name",{value:t,configurable:!0}),"l");const A0=j0(e=>{if(e.length===0)return"";if(e.length===1)return e[0];let t="",r,n;const o=e.join(`
|
|
31
|
+
`),s=[...o];let i=0;for(const[a,l]of s.entries()){if(t+=l,cr.has(l)){const c=Q$.exec(o.slice(i))?.groups??{};if(c.code!==void 0){const p=Number.parseFloat(c.code);r=p===X$?void 0:p}else c.uri!==void 0&&(n=c.uri.length===0?void 0:c.uri)}const u=e0.get(Number(r));s[a+1]===`
|
|
32
|
+
`?(n&&(t+=il("")),r&&u&&(t+=sl(u))):l===`
|
|
33
|
+
`&&(r&&u&&(t+=sl(r)),n&&(t+=il(n))),i+=l.length}return t},"preserveAnsi");var O0=Object.defineProperty,mt=Wt((e,t)=>O0(e,"name",{value:t,configurable:!0}),"f");const _p=/(?=\s)|(?<=\s)/,Ip=/^\s+$/,Vo=mt(e=>{if(!e.includes("\x1B"))return e;let t=e;return e.includes("\x1B[30m")&&(t+="\x1B[39m"),e.includes("\x1B[42m")&&(t+="\x1B[49m"),t},"resetAnsiAtLineBreak"),At=mt(e=>{const t=e.split(" ");let r=t.length;for(;r>0&&Ne(t[r-1])===0;)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},"stringVisibleTrimSpacesRight"),Wp=mt((e,t,r)=>{if(e.length===0)return[""];if(t<=0)return[e];const n=[],o=new Np;let s="",i=0,a=!1,l=!1,u="",c=0;for(;c<e.length;){const p=e[c];if(cr.has(p)){a=!0,u=p,s+=p,l=Mp([...e],c).isInsideLinkEscape,c+=1;continue}if(a){u+=p,s+=p,l?p===Eo&&(a=l=!1):p===ta&&(a=!1,o.processEscape(u)),c+=1;continue}const f=Ne(p),d=p===" ";if(f===0){s+=p,c+=1;continue}if(i+f>t&&(s&&n.push(s+o.getEndEscapesForAllActiveAttributes()),s=o.getStartEscapesForAllActiveAttributes(),i=Ne(s),d&&r)){for(;c<e.length&&e[c]===" ";)c+=1;continue}if(s+=p,i+=f,i===t&&c<e.length-1&&(n.push(s+o.getEndEscapesForAllActiveAttributes()),s=o.getStartEscapesForAllActiveAttributes(),i=Ne(s),c+1<e.length&&e[c+1]===" "&&r)){for(c+=1;c<e.length&&e[c]===" ";)c+=1;continue}c+=1}return s&&n.push(s+o.getEndEscapesForAllActiveAttributes()),r?n.map(p=>At(p)):n},"wrapWithBreakAtWidth"),R0=mt((e,t,r)=>{if(e.length===0)return[];const n=r?e.trim():e;if(n.length===0)return[];const o=[];let s="",i=0;return w0(n,{getWidth:Ne,onSegment:mt((a,l)=>{const u=a.text??"";if(a.isEscapeSequence)s+=u;else{const c=u===" ";if(a.width===0)return s+=u,!0;if(i+a.width>t&&(s&&o.push(s),s=l.getStartEscapesForAllActiveAttributes(),i=0,c))return r||o.push(l.getStartEscapesForAllActiveAttributes()+u),!0;s+=u,i+=a.width}return!0},"onSegment")}),s&&o.push(s),r?o.map(a=>At(a)):o},"wrapCharByChar"),C0=mt((e,t,r)=>{if(e.length===0)return[];const n=r?e.trim():e;if(n.length===0)return[];const o=n.split(_p),s=[];let i="",a=0,l=0;for(;l<o.length;){const u=o[l],c=Ip.test(u),p=Ne(u);if(u.length===0){l+=1;continue}if(r&&c&&a===0){l+=1;continue}if(a+p>t&&a>0){r?s.push(At(i)):s.push(i),i="",a=0;continue}i+=u,a+=p,l+=1}return i&&(r?s.push(At(i)):s.push(i)),s},"wrapWithWordBoundaries"),T0=mt((e,t,r)=>{if(e.length===0)return[];const n=r?e.trim():e;if(n.length===0)return[];const o=n.split(_p),s=[];let i="",a=0,l=0;for(;l<o.length;){const u=o[l],c=Ip.test(u),p=Ne(u);if(u.length===0){l+=1;continue}if(r&&c&&a===0){l+=1;continue}if(p>t){i&&s.push(Vo(r?At(i):i));const f=Wp(u,t,r);if(f.length>0){for(let d=0;d<f.length-1;d+=1)s.push(f[d]);i=f.at(-1),a=Ne(i)}else i="",a=0;l+=1;continue}if(a+p>t&&a>0&&(s.push(Vo(r?At(i):i)),i="",a=0,r&&c)){l+=1;continue}i+=u,a+=p,l+=1}return i&&s.push(Vo(r?At(i):i)),s},"wrapAndBreakWords"),Pr={BREAK_AT_CHARACTERS:"BREAK_AT_CHARACTERS",BREAK_WORDS:"BREAK_WORDS",PRESERVE_WORDS:"PRESERVE_WORDS",STRICT_WIDTH:"STRICT_WIDTH"},N0=mt((e,t={})=>{const{removeZeroWidthCharacters:r=!0,trim:n=!0,width:o=80,wrapMode:s=Pr.PRESERVE_WORDS}=t;if(n&&e.trim()==="")return"";let i=e.normalize("NFC").replaceAll(`\r
|
|
34
|
+
`,`
|
|
35
|
+
`);return r&&(i=i.replaceAll(Z$,"")),i.split(`
|
|
36
|
+
`).map(a=>{if(n&&a.trim()==="")return"";let l;switch(s){case Pr.BREAK_AT_CHARACTERS:{l=R0(a,o,n);break}case Pr.BREAK_WORDS:{l=T0(a,o,n);break}case Pr.STRICT_WIDTH:{l=Wp(a,o,n);break}default:l=C0(a,o,n)}return A0(l)}).join(`
|
|
37
|
+
`)},"wordWrap");var P0=Object.defineProperty,$t=ne((e,t)=>P0(e,"name",{value:t,configurable:!0}),"n$2");const Bp=80,Dp=24,vi=$t((e,t,{shell:r,env:n}={})=>Yh(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:r,env:n}).trim(),"exec"),Mn=$t((e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),"create"),Lp=$t((e,t)=>{const{columns:r,rows:n}=Mn(e,t);if(!(Number.isNaN(r)||Number.isNaN(n))&&!(r===Bp&&n===Dp))return{columns:r,rows:n}},"createIfNotDefault"),M0=$t(()=>{if(jt.platform!=="linux")return!0;try{const e=Nr.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const r=e.slice(t+2).trim().split(/\s+/),n=Number.parseInt(r[2],10),o=Number.parseInt(r[5],10);return Number.isNaN(n)||Number.isNaN(o)||o<=0?!1:n===o}catch{return!1}},"isForegroundProcess");function ra(){const{env:e,stdout:t,stderr:r}=jt;if(t?.columns&&t?.rows)return Mn(t.columns,t.rows);if(r?.columns&&r?.rows)return Mn(r.columns,r.rows);if(e.COLUMNS&&e.LINES)return Mn(e.COLUMNS,e.LINES);const n={columns:Bp,rows:Dp};return jt.platform==="win32"?Ko()??n:jt.platform==="darwin"?al()??Ko()??n:al()??Ko()??_0()??n}ne(ra,"O");$t(ra,"terminalSize");const al=$t(()=>{try{const e=jt.platform==="darwin"?Nr.constants.O_EVTONLY|Nr.constants.O_NONBLOCK:Nr.constants.O_NONBLOCK,{columns:t,rows:r}=Xh.WriteStream(Nr.openSync("/dev/tty",e));return{columns:t,rows:r}}catch{}},"devTty"),Ko=$t(()=>{try{const e=vi("tput",["cols"],{env:{TERM:"dumb",...jt.env}}),t=vi("tput",["lines"],{env:{TERM:"dumb",...jt.env}});if(e&&t)return Lp(e,t)}catch{}},"tput"),_0=$t(()=>{try{if(!M0())return;const e=vi("resize",["-u"]).match(/\d+/g);if(e.length===2)return Lp(e[0],e[1])}catch{}},"resize");var I0=Object.defineProperty,W0=ne((e,t)=>I0(e,"name",{value:t,configurable:!0}),"r$2");const B0=W0(e=>{const t=Object.keys(e).map(r=>e[r].badge??"");return t.length===0?"":t.reduce((r,n)=>r.length>n.length?r:n,"")},"getLongestBadge");var D0=Object.defineProperty,L0=ne((e,t)=>D0(e,"name",{value:t,configurable:!0}),"r$1");const{bold:F0,cyan:H0,green:ll,grey:q0,magenta:J0,red:z0,yellow:Yo}=io,U0={indent:2,quoteStyle:"single",stylize:L0((e,t)=>{const r={bigint:Yo,boolean:Yo,date:J0,null:F0,number:Yo,regexp:z0,special:H0,string:ll,symbol:ll,undefined:q0};return Object.hasOwn(r,t)?r[t](e):e},"stylize")};var G0=Object.defineProperty,V0=ne((e,t)=>G0(e,"name",{value:t,configurable:!0}),"o$1");const{bold:K0,underline:Y0}=io,X0=V0((e,t)=>{let r=t.uppercase.label?e.toUpperCase():e;return r=t.underline.label?Y0(r):r,t.bold.label&&(r=K0(r)),r},"formatLabel");var Z0=Object.defineProperty,Fp=ne((e,t)=>Z0(e,"name",{value:t,configurable:!0}),"o");const Q0=Fp(e=>[e.getHours(),e.getMinutes(),e.getSeconds()].map(t=>String(t).padStart(2,"0")).join(":"),"dateFormatter");class eb{static{ne(this,"AbstractPrettyReporter")}static{Fp(this,"AbstractPrettyReporter")}styles;loggerTypes;constructor(t){this.styles={bold:{label:!1},dateFormatter:Q0,underline:{label:!1,message:!1,prefix:!1,suffix:!1},uppercase:{label:!1},...t},this.loggerTypes=Zh}setLoggerTypes(t){this.loggerTypes=t}}var tb=Object.defineProperty,Hp=(e,t)=>tb(e,"name",{value:t,configurable:!0});_e(import.meta.url);const rb=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{stdout:nb,stderr:ob}=rb;var sb=Object.defineProperty,qp=Hp((e,t)=>sb(e,"name",{value:t,configurable:!0}),"b");const{bgGrey:ib,bold:cl,cyan:ab,green:lb,greenBright:cb,grey:vt,red:Xo,underline:ul,white:ub}=io,pb=/[\\/]pail[\\/]dist/,Zo=qp(e=>!pb.test(e),"pailFileFilter");let xO=class extends eb{static{Hp(this,"SimpleReporter")}static{qp(this,"SimpleReporter")}#e;#o;#t;#s=!1;#r;#n;constructor(t={}){const{error:r,inspect:n,...o}=t;super({uppercase:{label:!0,...o.uppercase},...o}),this.#r={...U0,indent:void 0,...n},this.#n={...r,color:{fileLine:lb,hint:ab,marker:Xo,message:Xo,method:cb,title:Xo}},this.#e=nb,this.#o=ob}setStdout(t){this.#e=t}setStderr(t){this.#o=t}setInteractiveManager(t){this.#t=t}setIsInteractive(t){this.#s=t}log(t){const r=this.formatMessage(t),n=t.type.level,o=["error","trace","warn"].includes(n)?"stderr":"stdout",s=o==="stderr"?this.#o:this.#e;this.#s&&this.#t!==void 0&&s.isTTY?this.#t.update(o,r.split(`
|
|
38
|
+
`),0):vy(`${r}
|
|
39
|
+
`,s)}formatMessage(t){const{columns:r}=ra();let n=r;typeof this.styles.messageLength=="number"&&(n=this.styles.messageLength);const{badge:o,context:s,date:i,error:a,file:l,groups:u,label:c,message:p,prefix:f,repeated:d,scope:m,suffix:h,traceError:y,type:$}=t,{color:g}=this.loggerTypes[$.name],w=g?io[g]:ub,b=u.map(()=>" ").join(""),v=[];if(u.length>0&&v.push(`${b+vt(`[${u.at(-1)??""}]`)} `),i&&v.push(`${vt(this.styles.dateFormatter(typeof i=="string"?new Date(i):i))} `),o)v.push(cl(w(o)));else{const j=B0(this.loggerTypes);j.length>0&&v.push(vt(" ".repeat(j.length)))}const S=rg(this.loggerTypes),x=Ne(S);if(c){const j=Ne(c),k=Math.max(0,x-j);v.push(`${cl(w(X0(c,this.styles)))} `," ".repeat(k))}else v.push(" ".repeat(x+1));d&&v.push(`${ib.white(`[${String(d)}x]`)} `),Array.isArray(m)&&m.length>0&&v.push(`${vt(`[${m.join(" > ")}]`)} `),f&&v.push(`${vt(`[${this.styles.underline.prefix?ul(f):f}]`)} `);const E=Ne(v.join(""));if(p!==Qh){const j=typeof p=="string"?p:Za(p,this.#r);v.push(b+N0(j,{trim:!1,width:n-3,wrapMode:Pr.STRICT_WIDTH}))}if(s){let j=!1;v.push(...s.map(k=>{if(k instanceof Error)return j=!0,`
|
|
40
|
+
|
|
41
|
+
${Go(k,{...this.#n,filterStacktrace:Zo,prefix:b})}`;if(typeof k=="object")return` ${Za(k,this.#r)}`;const R=(j?`
|
|
42
|
+
|
|
43
|
+
`:" ")+String(k);return j=!1,R}))}if(a&&v.push(Go(a,{...this.#n,filterStacktrace:Zo,prefix:b})),y&&v.push(`
|
|
44
|
+
|
|
45
|
+
${Go(y,{...this.#n,filterStacktrace:Zo,hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0,hideMessage:!0,prefix:b})}`),h&&v.push(` ${b}${vt(this.styles.underline.suffix?ul(h):h)}`),l){const j=(l.name??"")+(l.line?`:${String(l.line)}`:""),k=Math.max(0,E-Ne("Caller: "));v.push(`
|
|
46
|
+
`,vt("Caller: ")," ".repeat(k),j,`
|
|
47
|
+
`)}return v.join("")}};var SO="@visulima/packem",Jp="2.0.0-alpha.87";const kO={version:Jp};var fb=Object.defineProperty,zp=(e,t)=>fb(e,"name",{value:t,configurable:!0}),db=Object.defineProperty,mb=zp((e,t)=>db(e,"name",{value:t,configurable:!0}),"o");let jO=class extends Error{static{zp(this,"n")}static{mb(this,"DirectoryError")}constructor(t){super(`EISDIR: Illegal operation on a directory, ${t}`)}get code(){return"EISDIR"}set code(t){throw new Error("Cannot overwrite code EISDIR")}get name(){return"DirectoryError"}set name(t){throw new Error("Cannot overwrite name of DirectoryError")}};var hb=Object.defineProperty,Up=(e,t)=>hb(e,"name",{value:t,configurable:!0}),gb=Object.defineProperty,yb=Up((e,t)=>gb(e,"name",{value:t,configurable:!0}),"t");let OO=class extends Error{static{Up(this,"n")}static{yb(this,"NotEmptyError")}constructor(t){super(`ENOTEMPTY: Directory not empty, ${t}`)}get code(){return"ENOTEMPTY"}set code(t){throw new Error("Cannot overwrite code ENOTEMPTY")}get name(){return"NotEmptyError"}set name(t){throw new Error("Cannot overwrite name of NotEmptyError")}};var $b=Object.defineProperty,Gp=(e,t)=>$b(e,"name",{value:t,configurable:!0}),bb=Object.defineProperty,wb=Gp((e,t)=>bb(e,"name",{value:t,configurable:!0}),"o");let _t=class extends Error{static{Gp(this,"n")}static{wb(this,"NotFoundError")}constructor(t){super(`ENOENT: ${t}`)}get code(){return"ENOENT"}set code(t){throw new Error("Cannot overwrite code ENOENT")}get name(){return"NotFoundError"}set name(t){throw new Error("Cannot overwrite name of NotFoundError")}};var vb=Object.defineProperty,xb=(e,t)=>vb(e,"name",{value:t,configurable:!0}),Eb=Object.defineProperty,Sb=xb((e,t)=>Eb(e,"name",{value:t,configurable:!0}),"n");Sb((e,{whitespace:t=!0}={})=>e.replace(pm,r=>r.startsWith('"')||r[1]==="*"&&!r.endsWith("*/")?r:t?r.replaceAll(/\S/g," "):""),"stripJsonComments");var kb=Object.defineProperty,Vp=(e,t)=>kb(e,"name",{value:t,configurable:!0}),jb=Object.defineProperty,Ab=Vp((e,t)=>jb(e,"name",{value:t,configurable:!0}),"r");async function ko(e,t,r){const{buffer:n,compression:o,encoding:s="utf8",flag:i,...a}=r??{},l=await Eu(e,{buffer:n,compression:o,encoding:s,flag:i});return typeof t=="function"?Ln(l,t,a):Ln(l,a)}Vp(ko,"l");Ab(ko,"readYaml");var Ob=Object.defineProperty,Kp=(e,t)=>Ob(e,"name",{value:t,configurable:!0}),Rb=Object.defineProperty,Cb=Kp((e,t)=>Rb(e,"name",{value:t,configurable:!0}),"t");function jo(e,t,r){const{buffer:n,compression:o,encoding:s="utf8",flag:i,...a}=r??{},l=Bi(e,{buffer:n,compression:o,encoding:s,flag:i});return typeof t=="function"?Ln(l,t,a):Ln(l,a)}Kp(jo,"l");Cb(jo,"readYamlSync");var Tb=Object.defineProperty,Yp=(e,t)=>Tb(e,"name",{value:t,configurable:!0}),Nb=Object.defineProperty,Pb=Yp((e,t)=>Nb(e,"name",{value:t,configurable:!0}),"a");async function Xp(e,t,r,n){let o,s,i;typeof r=="object"&&r!==null&&!Array.isArray(r)&&typeof r!="function"?(o=r,s=o.replacer,i=o.space):typeof n=="object"?(o=n,s=r,i=o.space):(s=r,i=n);const a=Nu(t,s,i??o);await fm(e,a,o)}Yp(Xp,"c");Pb(Xp,"writeYaml");var Mb=Object.defineProperty,Zp=(e,t)=>Mb(e,"name",{value:t,configurable:!0}),_b=Object.defineProperty,Ib=Zp((e,t)=>_b(e,"name",{value:t,configurable:!0}),"a");function Qp(e,t,r,n){let o,s,i;typeof r=="object"&&r!==null&&!Array.isArray(r)&&typeof r!="function"?(o=r,s=o.replacer,i=o.space):typeof n=="object"?(o=n,s=r,i=o.space):(s=r,i=n);const a=Nu(t,s,i??o);ao(e,a,o)}Zp(Qp,"c");Ib(Qp,"writeYamlSync");var Wb=Object.defineProperty,Bb=(e,t)=>Wb(e,"name",{value:t,configurable:!0}),Db=Object.defineProperty,ur=Bb((e,t)=>Db(e,"name",{value:t,configurable:!0}),"c");const ef=ur((e,t,r)=>{const n=Z(e),o=Z(t),s=o===n?".":Se(n,o);return r.some(i=>{const a=i.startsWith("./")?i.slice(2):i,l=s.startsWith("./")?s.slice(2):s;if(a==="."&&l===".")return!0;if(a.endsWith("/**")){const u=a.slice(0,-3);return l===u||l.startsWith(`${u}/`)}if(a.endsWith("/*")){const u=a.slice(0,-2);return u===""?l!=="."&&!l.includes("/"):l.startsWith(`${u}/`)||l===u}return l===a||l.startsWith(`${a}/`)})},"isPackageInWorkspace"),tf=ur(async e=>{const t=await ft("pnpm-workspace.yaml",{cwd:Z(e),type:"file"});if(!t)return;const r=await ko(t),n=Array.isArray(r.packages)?r.packages:[];if(!ef(t,e,n))return;const o={};return r.catalog&&typeof r.catalog=="object"&&(o.catalog=r.catalog),r.catalogs&&typeof r.catalogs=="object"&&(o.catalogs=r.catalogs),Object.keys(o).length>0?o:void 0},"readPnpmCatalogs"),rf=ur(e=>{const t=dt("pnpm-workspace.yaml",{cwd:Z(e),type:"file"});if(!t)return;const r=jo(t),n=Array.isArray(r.packages)?r.packages:[];if(!ef(t,e,n))return;const o={};return r.catalog&&typeof r.catalog=="object"&&(o.catalog=r.catalog),r.catalogs&&typeof r.catalogs=="object"&&(o.catalogs=r.catalogs),Object.keys(o).length>0?o:void 0},"readPnpmCatalogsSync"),Lb=ur((e,t,r)=>{if(t==="catalog:")return r.catalog?.[e];if(t.startsWith("catalog:")){const n=t.slice(8);return r.catalogs?.[n]?.[e]}},"resolveCatalogReference"),Fb=ur((e,t)=>{for(const[r,n]of Object.entries(e)){if(typeof n!="string")continue;const o=Lb(r,n,t);o&&(e[r]=o)}},"resolveDependenciesCatalogReferences"),Ao=ur((e,t)=>{const r=["dependencies","devDependencies","peerDependencies","optionalDependencies"];for(const n of r){if(!e[n]||typeof e[n]!="object")continue;const o=e[n];Fb(o,t)}},"resolveCatalogReferences");var Hb=Object.defineProperty,ge=(e,t)=>Hb(e,"name",{value:t,configurable:!0});const qb=_e(import.meta.url),yr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,na=ge(e=>{if(typeof yr<"u"&&yr.versions&&yr.versions.node){const[t,r]=yr.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return yr.getBuiltinModule(e)}return qb(e)},"__cjs_getBuiltinModule"),{existsSync:nf}=na("node:fs"),{createInterface:Jb}=na("node:readline"),{styleText:Te}=na("node:util");var zb=Object.defineProperty,be=ge((e,t)=>zb(e,"name",{value:t,configurable:!0}),"f");const Ye=be(e=>{const t=typeof e;return e!==null&&(t==="object"||t==="function")},"isObject"),Ub=be(e=>{if(!Ye(e))return!1;for(const t in e)if(Object.hasOwn(e,t))return!1;return!0},"isEmptyObject"),of=new Set(["__proto__","prototype","constructor"]),sf=1e6,Gb=be(e=>e>="0"&&e<="9","isDigit");function pr(e){if(e==="0")return!0;if(/^[1-9]\d*$/.test(e)){const t=Number.parseInt(e,10);return t<=Number.MAX_SAFE_INTEGER&&t<=sf}return!1}ge(pr,"p$1");be(pr,"shouldCoerceToNumber");function Dr(e,t){return of.has(e)?!1:(e&&pr(e)?t.push(Number.parseInt(e,10)):t.push(e),!0)}ge(Dr,"y");be(Dr,"processSegment");function oa(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);const t=[];let r="",n="start",o=!1,s=0;for(const i of e){if(s++,o){r+=i,o=!1;continue}if(i==="\\"){if(n==="index")throw new Error(`Invalid character '${i}' in an index at position ${s}`);if(n==="indexEnd")throw new Error(`Invalid character '${i}' after an index at position ${s}`);o=!0,n=n==="start"?"property":n;continue}switch(i){case".":{if(n==="index")throw new Error(`Invalid character '${i}' in an index at position ${s}`);if(n==="indexEnd"){n="property";break}if(!Dr(r,t))return[];r="",n="property";break}case"[":{if(n==="index")throw new Error(`Invalid character '${i}' in an index at position ${s}`);if(n==="indexEnd"){n="index";break}if(n==="property"||n==="start"){if((r||n==="property")&&!Dr(r,t))return[];r=""}n="index";break}case"]":{if(n==="index"){if(r==="")r=(t.pop()||"")+"[]",n="property";else{const a=Number.parseInt(r,10);!Number.isNaN(a)&&Number.isFinite(a)&&a>=0&&a<=Number.MAX_SAFE_INTEGER&&a<=sf&&r===String(a)?t.push(a):t.push(r),r="",n="indexEnd"}break}if(n==="indexEnd")throw new Error(`Invalid character '${i}' after an index at position ${s}`);r+=i;break}default:{if(n==="index"&&!Gb(i))throw new Error(`Invalid character '${i}' in an index at position ${s}`);if(n==="indexEnd")throw new Error(`Invalid character '${i}' after an index at position ${s}`);n==="start"&&(n="property"),r+=i}}}switch(o&&(r+="\\"),n){case"property":{if(!Dr(r,t))return[];break}case"index":throw new Error("Index was not closed");case"start":{t.push("");break}}return t}ge(oa,"parsePath");be(oa,"parsePath");function fr(e){if(typeof e=="string")return oa(e);if(Array.isArray(e)){const t=[];for(const[r,n]of e.entries()){if(typeof n!="string"&&typeof n!="number")throw new TypeError(`Expected a string or number for path segment at index ${r}, got ${typeof n}`);if(typeof n=="number"&&!Number.isFinite(n))throw new TypeError(`Path segment at index ${r} must be a finite number, got ${n}`);if(of.has(n))return[];typeof n=="string"&&pr(n)?t.push(Number.parseInt(n,10)):t.push(n)}return t}return[]}ge(fr,"d");be(fr,"normalizePath");function nt(e,t,r){if(!Ye(e)||typeof t!="string"&&!Array.isArray(t))return r===void 0?e:r;const n=fr(t);if(n.length===0)return r;for(let o=0;o<n.length;o++){const s=n[o];if(e=e[s],e==null){if(o!==n.length-1)return r;break}}return e===void 0?r:e}ge(nt,"getProperty");be(nt,"getProperty");function sa(e,t,r){if(!Ye(e)||typeof t!="string"&&!Array.isArray(t))return e;const n=e,o=fr(t);if(o.length===0)return e;for(let s=0;s<o.length;s++){const i=o[s];if(s===o.length-1)e[i]=r;else if(!Ye(e[i])){const a=typeof o[s+1]=="number";e[i]=a?[]:{}}e=e[i]}return n}ge(sa,"setProperty");be(sa,"setProperty");function af(e,t){if(!Ye(e)||typeof t!="string"&&!Array.isArray(t))return!1;const r=fr(t);if(r.length===0)return!1;for(let n=0;n<r.length;n++){const o=r[n];if(n===r.length-1)return Object.hasOwn(e,o)?(delete e[o],!0):!1;if(e=e[o],!Ye(e))return!1}}ge(af,"deleteProperty");be(af,"deleteProperty");function Ot(e,t){if(!Ye(e)||typeof t!="string"&&!Array.isArray(t))return!1;const r=fr(t);if(r.length===0)return!1;for(const n of r){if(!Ye(e)||!(n in e))return!1;e=e[n]}return!0}ge(Ot,"hasProperty");be(Ot,"hasProperty");function zn(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return e.replaceAll(/[\\.[]/g,String.raw`\$&`)}ge(zn,"escapePath");be(zn,"escapePath");function ia(e){const t=Object.entries(e);return Array.isArray(e)?t.map(([r,n])=>[pr(r)?Number.parseInt(r,10):r,n]):t}ge(ia,"m$2");be(ia,"normalizeEntries");function aa(e,t={}){if(!Array.isArray(e))throw new TypeError(`Expected an array, got ${typeof e}`);const{preferDotForIndices:r=!1}=t,n=[];for(const[o,s]of e.entries()){if(typeof s!="string"&&typeof s!="number")throw new TypeError(`Expected a string or number for path segment at index ${o}, got ${typeof s}`);if(typeof s=="number")if(!Number.isInteger(s)||s<0){const i=zn(String(s));n.push(o===0?i:`.${i}`)}else r&&o>0?n.push(`.${s}`):n.push(`[${s}]`);else if(typeof s=="string")if(s==="")o===0||n.push(".");else if(pr(s)){const i=Number.parseInt(s,10);r&&o>0?n.push(`.${i}`):n.push(`[${i}]`)}else{const i=zn(s);n.push(o===0?i:`.${i}`)}}return n.join("")}ge(aa,"stringifyPath");be(aa,"stringifyPath");function*Oo(e,t=[],r=new Set){if(!Ye(e)||Ub(e)){t.length>0&&(yield aa(t));return}if(!r.has(e)){r.add(e);for(const[n,o]of ia(e))t.push(n),yield*Oo(o,t,r),t.pop();r.delete(e)}}ge(Oo,"x");be(Oo,"deepKeysIterator");function lf(e){return[...Oo(e)]}ge(lf,"deepKeys");be(lf,"deepKeys");function cf(e){const t={};if(!Ye(e))return t;for(const[r,n]of Object.entries(e))sa(t,r,n);return t}ge(cf,"unflatten");be(cf,"unflatten");var Vb=Object.defineProperty,Qo=ge((e,t)=>Vb(e,"name",{value:t,configurable:!0}),"i");const Kb=Qo(async e=>{const{default:t=!1,message:r,transformer:n}=e,o=Qo(i=>{const a=Te(["cyan","bold"],"?"),l=Te(["bold"],i),u=t?`${Te(["greenBright"],"Y")}${Te(["gray"],"/n")}`:`y/${Te(["yellowBright"],"N")}`;return`${a} ${l} ${Te(["gray"],`(${u})`)}`},"formatMessage"),s=Qo(i=>n?n(i):i?Te(["greenBright"],"Yes"):Te(["yellowBright"],"No"),"formatAnswer");return new Promise(i=>{const a=Jb({input:process.stdin,output:process.stdout}),l=o(r);a.question(l,u=>{a.close();const c=u.trim().toLowerCase();if(c===""){i(t);return}if(c==="y"||c==="yes"){console.log(`${Te(["greenBright"],"✓")} ${s(!0)}`),i(!0);return}if(c==="n"||c==="no"){console.log(`${Te(["yellowBright"],"✗")} ${s(!1)}`),i(!1);return}console.log(`${Te(["gray"],"→")} ${s(t)}`),i(t)}),a.on("SIGINT",()=>{a.close(),console.log(`
|
|
48
|
+
${Te(["gray"],"→")} ${s(t)}`),i(t)})})},"confirm"),Yb=typeof process.stdout<"u"&&!process.versions.deno&&!globalThis.window;var Xb=Object.defineProperty,$e=ge((e,t)=>Xb(e,"name",{value:t,configurable:!0}),"l");const uf=/, ([^,]*)$/,Un=new Map,pf=new Map;let Zb=class extends Error{static{ge(this,"M")}static{$e(this,"PackageJsonValidationError")}constructor(t){super(`The following warnings were encountered while normalizing package data:
|
|
49
|
+
- ${t.join(`
|
|
50
|
+
- `)}`),this.name="PackageJsonValidationError"}};const Ro=$e((e,t,r=[])=>{const n=[];if(Em(e,o=>{n.push(o)},t),t&&n.length>0){const o=n.filter(s=>!r.some(i=>i instanceof RegExp?i.test(s):i===s));if(o.length>0)throw new Zb(o)}return e},"normalizeInput"),Qb=$e(async e=>await ko(e),"parseYamlFile"),e1=$e(e=>jo(e),"parseYamlFileSync"),t1=$e(async e=>{const t=await Eu(e);return Pu.parse(t)},"parseJson5File"),r1=$e(e=>{const t=Bi(e);return Pu.parse(t)},"parseJson5FileSync"),ff=$e(async(e,t)=>t?.yaml!==!1&&(e.endsWith(".yaml")||e.endsWith(".yml"))?Qb(e):t?.json5!==!1&&e.endsWith(".json5")?t1(e):lo(e),"parsePackageFile"),df=$e((e,t)=>t?.yaml!==!1&&(e.endsWith(".yaml")||e.endsWith(".yml"))?e1(e):t?.json5!==!1&&e.endsWith(".json5")?r1(e):Di(e),"parsePackageFileSync");$e(async(e,t={})=>{const r={type:"file"};e&&(r.cwd=e);const n=["package.json"];t.yaml!==!1&&n.push("package.yaml","package.yml"),t.json5!==!1&&n.push("package.json5");let o;for(const l of n)if(o=await ft(l,r),o)break;if(!o)throw new _t(`No such file or directory, for ${n.join(", ").replace(uf," or $1")} found.`);const s=t.cache&&typeof t.cache!="boolean"?t.cache:pf;if(t.cache&&s.has(o))return s.get(o);const i=await ff(o,t);if(t.resolveCatalogs){const l=await tf(o);l&&Ao(i,l)}Ro(i,t.strict??!1,t.ignoreWarnings);const a={packageJson:i,path:o};return t.cache&&s.set(o,a),a},"findPackageJson");$e((e,t={})=>{const r={type:"file"};e&&(r.cwd=e);const n=["package.json"];t.yaml!==!1&&n.push("package.yaml","package.yml"),t.json5!==!1&&n.push("package.json5");let o;for(const l of n)if(o=dt(l,r),o)break;if(!o)throw new _t(`No such file or directory, for ${n.join(", ").replace(uf," or $1")} found.`);const s=t.cache&&typeof t.cache!="boolean"?t.cache:pf;if(t.cache&&s.has(o))return s.get(o);const i=df(o,t);if(t.resolveCatalogs){const l=rf(o);l&&Ao(i,l)}Ro(i,t.strict??!1,t.ignoreWarnings);const a={packageJson:i,path:o};return t.cache&&s.set(o,a),a},"findPackageJsonSync");$e(async(e,t={})=>{const{cwd:r,...n}=t,o=Fr(r??process.cwd());await ku(G(o,"package.json"),e,n)},"writePackageJson");$e((e,t={})=>{const{cwd:r,...n}=t,o=Fr(r??process.cwd());dm(G(o,"package.json"),e,n)},"writePackageJsonSync");const la=$e((e,t)=>{const r=typeof e=="object"&&!Array.isArray(e);if(!r&&typeof e!="string")throw new TypeError("`packageFile` should be either an `object` or a `string`.");let n,o=!1,s;if(r)n=structuredClone(e);else if(nf(e)){s=e;const a=t?.cache&&typeof t.cache!="boolean"?t.cache:Un;if(t?.cache&&a.has(s))return a.get(s);n=df(s,t),o=!0}else n=Su(e);if(t?.resolveCatalogs)if(o){const a=rf(e);a&&Ao(n,a)}else throw new Error("The 'resolveCatalogs' option can only be used on a file path.");Ro(n,t?.strict??!1,t?.ignoreWarnings);const i=n;return o&&t?.cache&&(typeof t.cache=="boolean"?Un:t.cache).set(s,i),i},"parsePackageJsonSync"),NO=$e(async(e,t)=>{const r=typeof e=="object"&&!Array.isArray(e);if(!r&&typeof e!="string")throw new TypeError("`packageFile` should be either an `object` or a `string`.");let n,o=!1,s;if(r)n=structuredClone(e);else if(nf(e)){s=e;const a=t?.cache&&typeof t.cache!="boolean"?t.cache:Un;if(t?.cache&&a.has(s))return a.get(s);n=await ff(s,t),o=!0}else n=Su(e);if(t?.resolveCatalogs)if(o){const a=await tf(e);a&&Ao(n,a)}else throw new Error("The 'resolveCatalogs' option can only be used on a file path.");Ro(n,t?.strict??!1,t?.ignoreWarnings);const i=n;return o&&t?.cache&&(typeof t.cache=="boolean"?Un:t.cache).set(s,i),i},"parsePackageJson");$e((e,t,r)=>nt(e,t,r),"getPackageJsonProperty");$e((e,t)=>Ot(e,t),"hasPackageJsonProperty");const mf=$e((e,t,r)=>{const n=nt(e,"dependencies",{}),o=nt(e,"devDependencies",{}),s=nt(e,"peerDependencies",{}),i={...n,...o,...r?.peerDeps===!1?{}:s};for(const a of t)if(Ot(i,a))return!0;return!1},"hasPackageJsonAnyDependency"),n1=$e(async(e,t,r="dependencies",n={})=>{const o=nt(e,"dependencies",{}),s=nt(e,"devDependencies",{}),i=nt(e,"peerDependencies",{}),a=[],l={deps:!0,devDeps:!0,peerDeps:!1,...n};for(const u of t)l.deps&&Ot(o,u)||l.devDeps&&Ot(s,u)||l.peerDeps&&Ot(i,u)||a.push(u);if(a.length!==0){if(process.env.CI||Yb&&!process.stdout.isTTY){const u=`Skipping package installation for [${t.join(", ")}] because the process is not interactive.`;if(n.throwOnWarn)throw new Error(u);n.logger?.warn?n.logger.warn(u):console.warn(u);return}if(typeof l.confirm?.message=="function"&&(l.confirm.message=l.confirm.message(a)),l.confirm?.message===void 0){const u=`${a.length===1?"Package is":"Packages are"} required for this config: ${a.join(", ")}. Do you want to install them?`;l.confirm===void 0?l.confirm={message:u}:l.confirm.message=u}await Kb(l.confirm)&&await Tu(a,{...l.installPackage,cwd:l.cwd?Fr(l.cwd):void 0,dev:r==="devDependencies"})}},"ensurePackages"),Gn=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"],o1=/\.(?:js|mjs|cjs|ts|cts|mts)$/,PO=async(e,t="")=>{if(t){const r=Tt(t)?t:G(e,t);if(!o1.test(r))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");if(!await Ct(r))throw new Error(`The packem config file "${t}" could not be found at "${r}".`);return r}for(const r of Gn){const n=G(e,r);if(await Ct(n))return n}throw new Error(`No packem config file found in "${e}". Expected one of: ${Gn.join(", ")}.`)},MO=async e=>{for(const t of Gn)if(await Ct(G(e,t)))return!0;return!1},s1={esbuild:"esbuild",oxc:"oxc-transform",sucrase:"sucrase",swc:"@swc/core"},pl=async(e,t)=>{const r=Array.isArray(e)?e:[e],n=await xm(t).catch(()=>{});let o;return n==="yarn"||n==="bun"?o=`${n} add -D`:n==="pnpm"?o="pnpm add -D":o="npm install -D",`${o} ${r.join(" ")}`},Vn=e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},xi=(e,t,r,n)=>{if(e==="module-sync")return"esm";if(n){const i=Vn(n);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return r;const[o,...s]=t;return xi(o,s,r,n)},i1=new Set(["browser","bun","default","deno","electron","import","module-sync","node","node-addons","require","types","workerd",...Hu,...qu]),ca=(e,t,r,n,o)=>{if(!e)return[];if(typeof e=="string"){const s=Vn(e);if(s&&s!==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:s??t}]}if(typeof e=="object"){const s=Object.entries(e).filter(([a])=>!a.endsWith(".json"));let i=[];for(const[a,l]of s){const u=a.replace("./",""),c=o.some(p=>u===p||u.startsWith(`${p}/`));if(typeof l=="string"){let p;Number.isInteger(+a)?p={exportKey:"*"}:a.startsWith("./")?p={exportKey:a.replace("./","")}:p={exportKey:a==="."?".":"*",subKey:a},i.push({...p,file:l,key:"exports",type:xi(a,n,t,l),...c&&{ignored:!0}})}else if(typeof l=="object"&&l!==null)for(const[p,f]of Object.entries(l)){if(r===!1&&p==="types")continue;const d=Number.isInteger(+a)?p:a;if(typeof f=="string")i.push({exportKey:d.replace("./",""),file:f,key:"exports",...i1.has(p)?{subKey:p}:{},type:xi(p,n,t,f),...c&&{ignored:!0}});else{const m=d.replace("./",""),h=c||o.some($=>m===$||m.startsWith(`${$}/`)),y=ca({[d]:f},t,r,[...n,p],o);h&&y.forEach($=>{$.ignored=!0}),i=[...i,...y]}}}return i}return[]},Ei=new Map,nr=/\.[^./]+$/,Ce=/\.d\.[mc]?ts$/,Si=/\.d\.mts$/,ki=/\.d\.cts$/,fl=/\.d\.[mc]ts$/,a1=/^\.\/dist\//,ji=/^dist\//,l1=/^\//,Mr=/^\.\//,c1=/\/$/,dl=/\.\w+$/,ml=/\*.*$/,u1=/\.(?:tsx?|cts|mts)$/,p1=/\.[cm]?tsx?$/,f1=/^(.+?)\.[^.]*$/,d1=/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,Re=e=>e===void 0||e==="node16",hf=(e,t)=>{const r=Ce.exec(e);if(r!==null)return r[0];if(t)for(const n of Object.values(t)){const o=n.startsWith(".")?n:`.${n}`;if(e.endsWith(o))return o}return tr(e)},m1=async e=>{try{return await Vu.readdir(e,{withFileTypes:!0})}catch(t){const{code:r}=t;if(r==="ENOENT")return[];throw t}},gf=async(e,t)=>{const r=await m1(e);return(await Promise.all(r.map(async n=>{const o=Ja.join(e,n.name);return n.isDirectory()?gf(o,t):n.isFile()?Ja.relative(t,o):[]}))).flat()},h1=async e=>{let t=Ei.get(e);return t||(t=gf(e,e),Ei.set(e,t)),t},hl=(e,t,r)=>{const n=e.replace(nr,"");if(t==="*"){const i=n.split("/").filter(Boolean);return i.length===0?void 0:r&&r>1?i:[i[0]]}const o=t.replaceAll(/[.+?^${}()|[\]\\]/g,String.raw`\$&`).replaceAll("*","(.*)"),s=new RegExp(`^${o}$`).exec(n);return s?s.slice(1):void 0},xt=(e,t)=>{let r=e;for(const n of t)r=r.replace("*",n);return r},g1=e=>e.endsWith(".d.mts")?"d.mts":e.endsWith(".d.cts")?"d.cts":"d.ts",y1=(e,t)=>e.key==="exports"&&e.subKey===Wr?Wr:e.key==="exports"&&e.subKey===Fa?Fa:t,$1=e=>{const t=e.replace(a1,"").replace(ji,"").replace(nr,"").split("/"),r=t.at(-1)??"",n=[".browser",".server",".development",".production",".node",".workerd"];for(const s of n)if(r.includes(s)){const i=r.replace(s,""),a=t.length>1?t.slice(0,-1).join("/"):"";return{baseName:a?`${a}/${i}`:i,pattern:s}}const o=r.split(".");if(o.length>2){const s=o.slice(0,-2).join("."),i=`.${o[o.length-2]}`,a=t.length>1?t.slice(0,-1).join("/"):"";return{baseName:a?`${a}/${s}`:s,pattern:i}}},b1=(e,t,r,n)=>{const o=`${t.replace(new RegExp(`^${n}/?`),"")}${r}`,s=o.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),i=new RegExp(String.raw`${s}\.([cm]?[tj]sx?|ts|js)$`),a=e.find(u=>{const c=u.replace(n,"").replace(l1,"");return i.test(c)});if(a)return a;const l=`${n}/${o}`;return e.find(u=>{const c=u.replace(nr,"");return c===l||c.endsWith(`/${o}`)})??void 0},at=(e,t,r,n,o,s,i,a)=>{const l=y1(o,s.environment);let{runtime:u}=s.options;const c=o.subKey==="browser"||typeof o.subKey=="string"&&o.subKey.includes("browser"),p=o.file.includes(".browser");if(c||p)u="browser";else{for(const b of Hu)if(o.file.includes(`.${b}.`)||o.subKey===b){u=b;break}(o.subKey==="node"||o.subKey==="workerd"||o.file.includes(".node")||o.file.includes(".workerd")||o.file.includes(".server"))&&(u="node")}const f=hf(o.file,s.options.outputExtensionMap),d=o.file.replace(f,""),m=s.options.outDir.replace(Mr,""),h=d.replace(new RegExp(`^(./)?${m}/`),""),y=t.replace(nr,"").split("/").pop()??"",$=h.split("/").pop()??"",g=!t.includes(h)&&y!==$;let w=e.find(b=>b.input===t&&b.environment===l&&b.runtime===u&&b.fileAlias===(g?h:void 0));if(w===void 0?w=e[e.push({environment:l,exportKey:new Set([o.exportKey].filter(Boolean)),fileAlias:g?h:void 0,input:t,runtime:u})-1]:w.exportKey&&o.exportKey&&w.exportKey.add(o.exportKey),i&&(w.isGlob=!0),r&&(w.outDir=n),o.isExecutable)w.executable=!0,w.declaration=!1,o.type==="cjs"?w.cjs=!0:o.type==="esm"&&(w.esm=!0);else{const b=Ce.test(o.file),v=a.filter(x=>x.exportKey===o.exportKey),S=v.length>0&&v.every(x=>Ce.test(x.file));if(b&&s.options.declaration!==!1){w.declaration=s.options.declaration;const x=g1(o.file);w.declarationExtensions??=new Set,w.declarationExtensions.add(x)}if(b||S){S&&s.options.declaration!==!1&&(w.declaration=s.options.declaration);const x=v.some(j=>Si.test(j.file)),E=v.some(j=>ki.test(j.file));if(x&&E?(Re(s.options.declaration)&&(s.options.declaration="compatible"),s.options.emitCJS=!0,s.options.emitESM=!0):E?(s.options.emitCJS=!0,Re(s.options.declaration)&&(s.options.declaration="compatible")):x&&(s.options.emitESM=!0,Re(s.options.declaration)&&(s.options.declaration="compatible")),S){const j=a.filter(P=>Ce.test(P.file)),k=j.some(P=>Si.test(P.file)),R=j.some(P=>ki.test(P.file));v.every(P=>!P.subKey||P.subKey==="types")?(R&&(w.cjs=!0),k&&(w.esm=!0)):(R&&(w.declarationCjs=!0),k&&(w.declarationEsm=!0))}}else o.type==="cjs"?w.cjs=!0:o.type==="esm"&&(w.esm=!0)}g&&!w.fileAlias&&(w.fileAlias=h)};let es=!1;const gl=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.")},w1=async(e,t,r)=>{const n=e.types||e.typings;Ei.clear(),es=!1;const o=[];t.sort((d,m)=>d.split("/").length-m.split("/").length);const s=e.type==="module"?"esm":"cjs",i=r.options.declaration??"node16",a=ca(e.exports,s,i,[],r.options.ignoreExportKeys??[]).filter(d=>!d.ignored),l=new Set;for(const d of a){const m=a.filter(h=>h.exportKey===d.exportKey);if(m.length>0&&m.every(h=>Ce.test(h.file))&&!l.has(d.exportKey)){l.add(d.exportKey);const h=m.some($=>$.file.endsWith(".d.mts")),y=m.some($=>$.file.endsWith(".d.cts"));h&&y?(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitCJS=!0,r.options.emitESM=!0):y?(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitCJS=!0):h&&(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitESM=!0)}}r.options.declaration??="node16";const u=a.some(d=>d.type==="esm"&&!Si.test(d.file)),c=a.some(d=>d.type==="cjs"&&!ki.test(d.file));u&&c?(r.options.emitESM=!0,r.options.emitCJS=!0):u?r.options.emitESM=!0:c?r.options.emitCJS=!0:s==="esm"?r.options.emitESM=!0:r.options.emitCJS=!0;const p=r.options.emitCJS&&r.options.emitESM;if(r.options.declaration==="node16"&&p&&(r.options.declaration="compatible"),e.bin){const d=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const m of d){const h=Vn(m);if(h&&h!==s)throw new Error(`Exported file "${m}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);a.push({file:m,isExecutable:!0,key:"bin",type:h??s})}}e.main&&a.push({file:e.main,key:"main",type:Vn(e.main)??s}),e.module&&a.push({file:e.module,key:"module",type:"esm"}),n&&(gl(r),Re(r.options.declaration)&&p&&(r.options.declaration="compatible"),a.push({file:n,key:"types"}));const f=[];if(!r.options.outputExtensionMap){const d=a.some(y=>!y.isExecutable&&!Ce.test(y.file)&&y.file.endsWith(".mjs")),m=a.some(y=>!y.isExecutable&&!Ce.test(y.file)&&y.file.endsWith(".cjs")),h=a.some(y=>!y.isExecutable&&!Ce.test(y.file)&&y.file.endsWith(".js"));d&&!m&&!h?r.options.outputExtensionMap={esm:"mjs"}:m&&!d&&!h&&(r.options.outputExtensionMap={cjs:"cjs"})}for(const d of a){const m=Ce.test(d.file),h=hf(d.file,r.options.outputExtensionMap),y=[...uo];if(r.options.outputExtensionMap)for(const k of Object.values(r.options.outputExtensionMap)){const R=k.startsWith(".")?k:`.${k}`;y.includes(R)||y.push(R)}if(!m&&h!==""&&!y.includes(h)||!m&&u1.test(d.file))continue;let $=d.type;if(!$&&m){if(d.file.endsWith(".d.mts"))$="esm";else if(d.file.endsWith(".d.cts"))$="cjs";else if(d.file.endsWith(".d.ts")){const k=a.some(P=>P.subKey==="import"&&P.file.endsWith(".d.mts")),R=a.some(P=>P.subKey==="require"&&P.file.endsWith(".d.cts"));k&&R?$=void 0:$=r.pkg.type==="module"?"esm":"cjs"}}if(Ce.test(d.file)||(r.options.emitCJS===void 0&&($==="cjs"||d.type==="cjs")&&(r.options.emitCJS=!0),r.options.emitESM===void 0&&($==="esm"||d.type==="esm")&&(r.options.emitESM=!0)),Re(r.options.declaration)){const k=r.options.emitCJS&&r.options.emitESM;r.options.declaration=k?"compatible":"node16"}let g=d.file;if(r.options.outputExtensionMap)for(const k of Object.values(r.options.outputExtensionMap)){const R=k.startsWith(".")?k:`.${k}`;if(d.file.endsWith(R)){g=d.file.slice(0,-R.length);break}}g===d.file&&(g=d.file.replace(d1,""));const w=g.endsWith("/");if(w&&["./","/"].includes(g))continue;const b=g.replace(new RegExp(`(./)?${r.options.outDir}`),r.options.sourceDir).replace("./",""),v=w?"":String.raw`(\.d\.[cm]?ts|(\.[cm]?[tj]sx?))$`,S="(?:^|/)";if((d.file.includes("/*")||g.includes("*"))&&d.key==="exports"){es||(r.logger?.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),es=!0);let k;d.exportKey?k=d.exportKey.startsWith("./")?d.exportKey.slice(2):d.exportKey:k=(d.file.startsWith("./")?d.file.slice(2):d.file).replace(ji,"");const R=d.file,P=dl.exec(R);if(R.includes("*")&&!P&&d.exportKey&&!d.subKey){const M=R.replace(ml,"").replace(Mr,""),_=k.replace(ml,"").replace(Mr,"");if(M!==_){const H=`package.json#exports["${d.exportKey==="."?".":`./${d.exportKey}`}"]`;o.push(`Wildcard pattern must include a file extension: ${R} at ${H}`);continue}}const z=r.options.sourceDir.replace(Mr,""),U=X(r.options.rootDir,z),J=[],N=await h1(U),O=R.split("*").length-1,F=k.split("*").length-1;for(const M of N){const _=hl(M,k,O);if(_){if(O>F&&O>1){if(_.length>=O){const B=_[0];if(_.every(D=>D===B)){const D=xt(R,_.slice(0,O));D.includes("*")||J.push({input:X(U,M),output:D})}continue}const V=M.replace(nr,"").split("/").filter(Boolean);if(V.length>=O){const B=Math.floor(V.length/O),D=[];for(let q=0;q<O;q+=1){const A=q*B,ae=q===O-1?V.length:(q+1)*B;D.push(V.slice(A,ae).join("/"))}const K=D[0];if(D.every(q=>q===K)){const q=xt(R,D);q.includes("*")||J.push({input:X(U,M),output:q})}}else if(V.length>0){const B=V[0];if(V.every(D=>D===B)){const D=Array.from({length:O}).fill(B),K=xt(R,D);K.includes("*")||J.push({input:X(U,M),output:K})}}continue}if(_.length<O)continue;if(F>0&&F<O&&O>1&&_.length>1){const V=_[0];if(!_.every(B=>B===V))continue}const H=xt(R,_);if(H.includes("*"))continue;J.push({input:X(U,M),output:H})}}if(J.length===0&&R.includes("*")){let M=(d.file.startsWith("./")?d.file.slice(2):d.file).replace(ji,"");M=M.replace(dl,"");for(const _ of N){const H=hl(_,M,O);if(H){if(O>1&&F<O){if(H.length>=O){const D=H[0];if(H.every(K=>K===D)){const K=xt(R,H);K.includes("*")||J.push({input:X(U,_),output:K});continue}}const V=_.replace(nr,""),B=M.split("*");if(B.length>=2){const D=B.map(A=>A.replaceAll(/[.+?^${}()|[\]\\]/g,String.raw`\$&`));let K=`${D[0]}(.+)`;for(let A=1;A<D.length;A+=1)K+=D[A],A<D.length-1&&(K+=String.raw`\1`);const q=new RegExp(`^${K}$`).exec(V);if(q){const A=q[1],ae=xt(R,Array.from({length:O}).fill(A));ae.includes("*")||J.push({input:X(U,_),output:ae})}}continue}if(H.length>=O){if(F>0&&F<O&&O>1&&H.length>1){const B=H[0];if(!H.every(D=>D===B))continue}const V=xt(R,H);V.includes("*")||J.push({input:X(U,_),output:V})}}}}if(J.length===0){a.length>1||o.push(`Could not find entrypoints matching pattern \`${k}\` for output \`${R}\``);continue}const I=a.filter(M=>M.exportKey===d.exportKey);if(I.length>0&&I.every(M=>Ce.test(M.file))){const M=I.some(D=>D.file.endsWith(".d.ts")),_=I.some(D=>D.file.endsWith(".d.mts")),H=I.some(D=>D.file.endsWith(".d.cts"));_&&H?(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitCJS=!0,r.options.emitESM=!0):H?(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitCJS=!0):_&&(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitESM=!0);const V=I.find(D=>D.file.endsWith(".d.ts")),B=V??I.find(D=>D.file.endsWith(".d.mts"))??I.find(D=>D.file.endsWith(".d.cts"))??d;if(!(B===d||V!==void 0&&d===V||V===void 0&&B===d))continue;for(const{input:D,output:K}of J){let q=K;if(K.endsWith(".d.mts")||K.endsWith(".d.cts"))q=K.replace(fl,".d.ts");else if(!K.endsWith(".d.ts")){const ae=K.replace(fl,".d.ts");M&&(q=ae)}const A={...B,file:q,subKey:"types",type:void 0};at(f,D,!1,g,A,r,!0,a)}}else for(const{input:M,output:_}of J){const H=Ce.test(_);let V=d.type;H||(_.endsWith(".mjs")?V="esm":_.endsWith(".cjs")?V="cjs":_.endsWith(".js")&&!V&&(V=r.pkg.type==="module"?"esm":"cjs"));const B={...d,file:_,...!H&&V&&{type:V}};at(f,M,!1,g,B,r,!0,a)}continue}const x=new RegExp(S+b.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)+v);let E=t.find(k=>x.test(k));if(E===void 0){const k=r.options.sourceDir.replace(Mr,""),R=X(r.options.rootDir,k),P=$1(d.file);if(P){const z=b1(t,P.baseName,P.pattern,R);if(z)E=z;else{const U=P.baseName,J=new RegExp(S+U.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)+v);E=t.find(N=>J.test(N))}}else{const z=b.replace(f1,"$1").replace(c1,"");if(qu.has(d.subKey)){const U=new RegExp(S+z.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)+v);E=t.find(J=>U.test(J))}}}if(E===void 0){rt(X(r.options.rootDir,d.file))||o.push(`Could not find entrypoint for \`${d.file}\``);continue}rt(E)&&p1.test(E)&&gl(r);const j=a.filter(k=>k.exportKey===d.exportKey);if(j.length>0&&j.every(k=>Ce.test(k.file))){const k=j.some(z=>z.file.endsWith(".d.mts")),R=j.some(z=>z.file.endsWith(".d.cts"));k&&R?(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitCJS=!0,r.options.emitESM=!0):R?(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitCJS=!0):k&&(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitESM=!0);const P={...d,subKey:"types",type:void 0};at(f,E,w,g,P,r,!1,a)}else{const k=wm(E.replace(qi,"")),R=`${k}.cts`,P=`${k}.mts`,z=rt(R),U=rt(P),J=d.file.endsWith(".d.mts")||d.file.endsWith(".mjs"),N=d.file.endsWith(".d.cts")||d.file.endsWith(".cjs");J&&U?at(f,P,w,g,{...d,type:"esm"},r,!1,a):N&&z?at(f,R,w,g,{...d,type:"cjs"},r,!1,a):z&&U?(at(f,R,w,g,{...d,type:"cjs"},r,!1,a),at(f,P,w,g,{...d,type:"esm"},r,!1,a)):at(f,E,w,g,d,r,!1,a)}}return{entries:f,warnings:o}},$r=e=>typeof e=="string"&&e!=="",v1=(e,t)=>{const{publishConfig:r}=e;return r&&(r.bin&&(typeof r.bin=="object"||typeof r.bin=="string")&&(e.bin=r.bin),$r(r.type)&&(e.type=r.type),$r(r.main)&&(e.main=r.main),$r(r.module)&&(e.module=r.module),t===void 0&&$r(r.types)?e.types=r.types:t===void 0&&$r(r.typings)&&(e.typings=r.typings),r.exports&&typeof r.exports=="object"&&(e.exports=r.exports)),e},yf=/.*\/dist\/.*/,yl=/\/$/,x1=/\.mjs$/,E1=/\.cjs$/,S1=/\.d\.[mc]?ts$/,k1=/(?<!\.d)\.js$/,j1=e=>{const t=[],r=new Set,n=o=>{if(typeof o=="string"){t.push(o);return}if(Array.isArray(o)){for(const s of o)n(s);return}if(o&&typeof o=="object")for(const[s,i]of Object.entries(o))s.startsWith(".")||r.add(s),n(i)};e.exports&&n(e.exports);for(const o of[e.main,e.module,e.types])typeof o=="string"&&t.push(o);return{conditions:r,files:t}},A1=(e,t,r)=>{if(e.options.emitESM!==void 0||e.options.emitCJS!==void 0)return;const n=e.pkg.type==="module"?"esm":"cjs",o=r.some(a=>k1.test(a));let s=r.some(a=>x1.test(a))||t.has("import")||t.has("module"),i=r.some(a=>E1.test(a))||t.has("require");(o||!s&&!i)&&n==="esm"?s=!0:(o||!s&&!i)&&(i=!0),e.options.emitESM=s,e.options.emitCJS=i},O1=(e,t,r)=>{if(e.options.declaration!==void 0)return;const n=!!e.pkg.types||t.has("types")||r.some(o=>S1.test(o));e.options.declaration=n?"node16":!1},R1=e=>{e.options.entries.length=0;const t=G(e.options.rootDir,e.options.sourceDir);if(!rt(t))throw new Error("No 'src' directory found. Please provide entries manually.");const r=ju(t,{extensions:[],includeDirs:!1,includeSymlinks:!1,skip:[kt,yf]}).filter(u=>Et.test(u)&&!u.endsWith(".d.ts")),{conditions:n,files:o}=j1(e.pkg);A1(e,n,o),O1(e,n,o);const s=e.options.emitESM??!1,i=e.options.emitCJS??!1;for(const u of r){const c=u.replace(`${t}/`,"").replace(Et,"").replaceAll("\\","/");e.options.entries.push({cjs:i,declaration:e.options.declaration,esm:s,input:u,name:c})}const a=[];s&&a.push("[esm]"),i&&a.push("[cjs]"),e.options.declaration&&a.push("[dts]");const l=e.options.entries.length;e.logger.info("Unbundle mode: preserving source structure for",re(`${String(l)} ${l===1?"entry":"entries"}`),De(a.join(" ")))},C1={hooks:{"build:prepare":async function(e){if(e.options.unbundle){R1(e);return}if(e.options.entries.length>0)return;const t=G(e.options.rootDir,e.options.sourceDir);if(!rt(t))throw new Error("No 'src' directory found. Please provide entries manually.");const r=ju(t,{extensions:[],includeDirs:!1,includeSymlinks:!1,skip:[kt,yf]});if(r.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");const n=e.logger;let o={...e.pkg};o.publishConfig&&(n.info(`Using publishConfig found in package.json, to override the default key-value pairs of "${Object.keys(o.publishConfig).join(", ")}".`),n.debug(o.publishConfig),o=v1(o,e.options.declaration));const s=await w1(o,r,e);for(const i of s.warnings)n.warn(i);if(e.options.entries.push(...s.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");n.info("Automatically detected entries:",re(e.options.entries.map(i=>i.fileAlias?`${Ae(i.fileAlias)} => ${Ae(i.input.replace(`${e.options.rootDir}/`,"").replace(yl,"/*"))}`:Ae(i.input.replace(`${e.options.rootDir}/`,"").replace(yl,"/*"))).join(", ")),De([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))}}},T1=_e(import.meta.url),Ut=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ua=e=>{if(typeof Ut<"u"&&Ut.versions&&Ut.versions.node){const[t,r]=Ut.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return Ut.getBuiltinModule(e)}return T1(e)},{existsSync:ts}=ua("node:fs"),{env:rs,cwd:N1}=Ut,{createRequire:nn}=ua("node:module"),P1=0,ns=2,M1=Symbol("findUpStop"),$f=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},$l=e=>{if(e.isFile())return"file";if(e.isDirectory())return"dir";if(e.isSymbolicLink())return"symlink"},_1=nn(import.meta.url),br=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I1=e=>{if(typeof br<"u"&&br.versions&&br.versions.node){const[t,r]=br.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return br.getBuiltinModule(e)}return _1(e)},{lstatSync:bl,mkdirSync:W1}=I1("node:fs"),B1=e=>{$f(e);try{const t=bl(e);if(!t.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String($l(t))}'`);return}catch(t){if(t.code!=="ENOENT")throw t}try{W1(e,{recursive:!0})}catch(t){if(t.code!=="EEXIST")throw t;const r=bl(e);if(!r.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String($l(r))}'`,{cause:t})}},D1=/^[A-Z]:\//i,on=(e="")=>e&&e.replaceAll("\\","/").replace(D1,t=>t.toUpperCase()),L1=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,F1=/^[A-Z]:$/i,H1=/.(\.[^./]+)$/,q1=/^[/\\]|^[a-z]:[/\\]/i,J1=/\/$/,z1=()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/",U1=(e,t)=>{let r="",n=0,o=-1,s=0,i;for(let a=0;a<=e.length;++a){if(a<e.length)i=e[a];else{if(i==="/")break;i="/"}if(i==="/"){if(!(o===a-1||s===1))if(s===2){if(r.length<2||n!==2||!r.endsWith(".")||r.at(-2)!=="."){if(r.length>2){const l=r.lastIndexOf("/");l===-1?(r="",n=0):(r=r.slice(0,l),n=r.length-1-r.lastIndexOf("/")),o=a,s=0;continue}else if(r.length>0){r="",n=0,o=a,s=0;continue}}t&&(r+=r.length>0?"/..":"..",n=2)}else r.length>0?r+=`/${e.slice(o+1,a)}`:r=e.slice(o+1,a),n=a-o-1;o=a,s=0}else i==="."&&s!==-1?++s:s=-1}return r},Kn=e=>L1.test(e),os=function(...e){e=e.map(n=>on(n));let t="",r=!1;for(let n=e.length-1;n>=-1&&!r;n--){const o=n>=0?e[n]:z1();!o||o.length===0||(t=`${o}/${t}`,r=Kn(o))}return t=U1(t,!r),r&&!Kn(t)?`/${t}`:t.length>0?t:"."},G1=function(e){return H1.exec(on(e))?.[1]??""},bf=e=>{const t=on(e).replace(J1,"").split("/").slice(0,-1);return t.length===1&&F1.test(t[0])&&(t[0]=`${t[0]}/`),t.join("/")||(Kn(e)?"/":".")},V1=(e,t)=>on(e).split("/").pop(),K1=function(e){const t=q1.exec(e)?.[0]?.replaceAll("\\","/")??"",r=V1(e),n=G1(r);return{base:r,dir:bf(e),ext:n,name:r.slice(0,r.length-n.length),root:t}},Y1=nn(import.meta.url),wr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,X1=e=>{if(typeof wr<"u"&&wr.versions&&wr.versions.node){const[t,r]=wr.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return wr.getBuiltinModule(e)}return Y1(e)},{fileURLToPath:Z1}=X1("node:url");function Q1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var wl,vl;function ew(){return vl||(vl=1,wl=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cr3","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),wl}var tw=ew();const rw=Q1(tw);new Set(rw);const Ai=e=>on(e instanceof URL?Z1(e):e),nw=nn(import.meta.url),vr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,wf=e=>{if(typeof vr<"u"&&vr.versions&&vr.versions.node){const[t,r]=vr.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return vr.getBuiltinModule(e)}return nw(e)};wf("node:fs/promises");wf("node:url");const ow=nn(import.meta.url),xr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,vf=e=>{if(typeof xr<"u"&&xr.versions&&xr.versions.node){const[t,r]=xr.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return xr.getBuiltinModule(e)}return ow(e)},{statSync:sw,lstatSync:iw}=vf("node:fs"),{fileURLToPath:aw}=vf("node:url"),lw=(e,t={})=>{const r=t.cwd?Ai(t.cwd):process.cwd();let n=os(r);const{root:o}=K1(n),s=Ai(t.stopAt??o),i=os(n,s),a=t.type??"file",l=function(c){return[e]};t.allowSymlinks??=!0;const u=t.allowSymlinks?sw:iw;for(;n&&n!==i&&n!==o;){for(let c of l()){if(c===M1)return;if(c===void 0)continue;Buffer.isBuffer(c)?c=c.toString():c instanceof URL&&(c=aw(c));const p=Kn(c)?c:os(n,c);try{const f=u(p);if(a==="file"&&f.isFile()||a==="directory"&&f.isDirectory())return p}catch{}}n=bf(n)}},cw=nn(import.meta.url),Er=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,uw=e=>{if(typeof Er<"u"&&Er.versions&&Er.versions.node){const[t,r]=Er.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return Er.getBuiltinModule(e)}return cw(e)};uw("node:fs/promises");const{accessSync:pw}=ua("node:fs");function ss(e,t=P1){$f(e),e=Ai(e);try{return pw(e,t),!0}catch{return!1}}let fw=class extends Error{constructor(t){super(`ENOENT: ${t}`)}get code(){return"ENOENT"}set code(t){throw new Error("Cannot overwrite code ENOENT")}get name(){return"NotFoundError"}set name(t){throw new Error("Cannot overwrite name of NotFoundError")}};const dw=/^[A-Z]:\//i,xf=(e="")=>e&&e.replaceAll("\\","/").replace(dw,t=>t.toUpperCase()),mw=/^[/\\]{2}/,hw=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,Ef=/^[A-Z]:$/i,gw=/\/$/,yw=(e,t)=>{let r="",n=0,o=-1,s=0,i;for(let a=0;a<=e.length;++a){if(a<e.length)i=e[a];else{if(i==="/")break;i="/"}if(i==="/"){if(!(o===a-1||s===1))if(s===2){if(r.length<2||n!==2||!r.endsWith(".")||r.at(-2)!=="."){if(r.length>2){const l=r.lastIndexOf("/");l===-1?(r="",n=0):(r=r.slice(0,l),n=r.length-1-r.lastIndexOf("/")),o=a,s=0;continue}else if(r.length>0){r="",n=0,o=a,s=0;continue}}t&&(r+=r.length>0?"/..":"..",n=2)}else r.length>0?r+=`/${e.slice(o+1,a)}`:r=e.slice(o+1,a),n=a-o-1;o=a,s=0}else i==="."&&s!==-1?++s:s=-1}return r},Oi=e=>hw.test(e),$w=function(e){if(e.length===0)return".";e=xf(e);const t=mw.exec(e),r=Oi(e),n=e.at(-1)==="/";return e=yw(e,!r),e.length===0?r?"/":n?"./":".":(n&&(e+="/"),Ef.test(e)&&(e+="/"),t?r?`//${e}`:`//./${e}`:r&&!Oi(e)?`/${e}`:e)},gn=(...e)=>{let t="";for(const r of e)if(r)if(t.length>0){const n=t.at(-1)==="/",o=r[0]==="/";n&&o?t+=r.slice(1):t+=n||o?r:`/${r}`}else t+=r;return $w(t)},bw=e=>{const t=xf(e).replace(gw,"").split("/").slice(0,-1);return t.length===1&&Ef.test(t[0])&&(t[0]=`${t[0]}/`),t.join("/")||(Oi(e)?"/":".")},xl=(e,t)=>(t?.create&&B1(e),e),ww=(e,t)=>{if(rs.CACHE_DIR&&!["0","1","false","true"].includes(rs.CACHE_DIR))return xl(gn(rs.CACHE_DIR,e),t);const r=lw("package.json",{cwd:t?.cwd??N1(),type:"file"});if(!r){if(t?.throwError)throw new fw("No such file or directory found.");return}const n=gn(bw(r),"node_modules"),o=gn(n,".cache"),s=gn(o,e);if(!(ts(s)&&!ss(s,ns))&&!(ts(o)&&!ss(o,ns))&&!(ts(n)&&!ss(n,ns)))return xl(s,t)},vw=ww,xw=/^(?<value>-?\d+(?:[.,]\d+)*) *(?<type>[a-z]+)?$/i,Ew=/^KIBI/,Sw=/^MIBI/,kw=/^GIBI/,jw=/^TEBI/,Aw=/^PEBI/,Ow=/^EXBI/,Rw=/^ZEBI/,Cw=/^YIBI/,Tw=/^(.)IB$/,Sf={iec:[{long:"Bytes",short:"B"},{long:"Kibibytes",short:"KiB"},{long:"Mebibytes",short:"MiB"},{long:"Gibibytes",short:"GiB"},{long:"Tebibytes",short:"TiB"},{long:"Pebibytes",short:"PiB"},{long:"Exbibytes",short:"EiB"},{long:"Zebibytes",short:"ZiB"},{long:"Yobibytes",short:"YiB"}],iec_octet:[{long:"Octets",short:"o"},{long:"Kibioctets",short:"Kio"},{long:"Mebioctets",short:"Mio"},{long:"Gibioctets",short:"Gio"},{long:"Tebioctets",short:"Tio"},{long:"Pebioctets",short:"Pio"},{long:"Exbioctets",short:"Eio"},{long:"Zebioctets",short:"Zio"},{long:"Yobioctets",short:"Yio"}],metric:[{long:"Bytes",short:"Bytes"},{long:"Kilobytes",short:"KB"},{long:"Megabytes",short:"MB"},{long:"Gigabytes",short:"GB"},{long:"Terabytes",short:"TB"},{long:"Petabytes",short:"PB"},{long:"Exabytes",short:"EB"},{long:"Zettabytes",short:"ZB"},{long:"Yottabytes",short:"YB"}],metric_octet:[{long:"Octets",short:"o"},{long:"Kilo-octets",short:"ko"},{long:"Mega-octets",short:"Mo"},{long:"Giga-octets",short:"Go"},{long:"Tera-octets",short:"To"},{long:"Peta-octets",short:"Po"},{long:"Exa-octets",short:"Eo"},{long:"Zetta-octets",short:"Zo"},{long:"Yotta-octets",short:"Yo"}]},Nw=(e,t)=>{const r=new Intl.NumberFormat(t).format(11111).replaceAll(new RegExp("\\p{Number}","gu"),""),n=new Intl.NumberFormat(t).format(1.1).replaceAll(new RegExp("\\p{Number}","gu"),"");return Number.parseFloat(e.replaceAll(new RegExp(`\\${r}`,"g"),"").replace(new RegExp(`\\${n}`),"."))},kf=e=>{switch(e){case 2:return 1024;case 10:return 1e3;default:throw new Error("Unsupported base.")}},Pw=(e,t)=>{const r={base:2,locale:"en-US",units:"metric",...t};if(typeof e!="string"||e.length===0)throw new TypeError("Value is not a string or is empty.");if(e.length>100)throw new TypeError("Value exceeds the maximum length of 100 characters.");const n=xw.exec(e)?.groups;if(!n)return Number.NaN;const o=Nw(n.value,r.locale),s=(n.type??"Bytes").toUpperCase().replace(Ew,"KILO").replace(Sw,"MEGA").replace(kw,"GIGA").replace(jw,"TERA").replace(Aw,"PETA").replace(Ow,"EXA").replace(Rw,"ZETTA").replace(Cw,"YOTTA").replace(Tw,"$1B"),i=Sf[r.units].findIndex(l=>l.short[0].toUpperCase()===s[0]),a=kf(r.base);return o*a**i},je=(e,t)=>{if(typeof e!="number"||!Number.isFinite(e))throw new TypeError("Bytesize is not a number.");const{base:r,decimals:n,locale:o,long:s,unit:i,units:a,...l}={base:2,decimals:0,locale:"en-US",long:!1,units:"metric",...t},u=kf(r),c=Math.abs(e),p=t?.space??!0?" ":"",f=Sf[a],d=f.findIndex(g=>g.short===i);if(e===0){const g=Math.min(0,Math.max(d,f.length-1));return"0"+p+f[g][s?"long":"short"]}const m=d===-1?Math.min(Math.floor(Math.log(c)/Math.log(u)),f.length-1):d,h=f[m][s?"long":"short"],y=e/u**m,$=n<0?void 0:n;return new Intl.NumberFormat(o,{maximumFractionDigits:$,minimumFractionDigits:$,...l}).format(y)+p+h},Mw=(e,t,r,n,o,s,i,a,l,u,c,p,f,d)=>{const m={d:n,h:o,m:s,mo:t,ms:a,s:i,w:r,y:e};return m.future=l,m.past=u,m.decimal=c,p!==void 0&&(m.unitMap=p),m.groupSeparator=f,m.placeholderSeparator=d,m},_w={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},Iw=Mw(e=>`year${e===1?"":"s"}`,e=>`month${e===1?"":"s"}`,e=>`week${e===1?"":"s"}`,e=>`day${e===1?"":"s"}`,e=>`hour${e===1?"":"s"}`,e=>`minute${e===1?"":"s"}`,e=>`second${e===1?"":"s"}`,e=>`millisecond${e===1?"":"s"}`,"in %s","%s ago",".",_w,",","_"),Ww=e=>{const t=["y","mo","w","d","h","m","s","ms","future","past"];for(const n of t)if(!Object.hasOwn(e,n))throw new TypeError(`Missing required property: ${n}`);if(typeof e.future!="string"||typeof e.past!="string")throw new TypeError("Properties future and past must be of type string");const r=["y","mo","w","d","h","m","s","ms"];for(const n of r)if(typeof e[n]!="string"&&typeof e[n]!="function")throw new TypeError(`Property ${n} must be of type string or function`);if(e.decimal&&typeof e.decimal!="string")throw new TypeError("Property decimal must be of type string");if(e.delimiter&&typeof e.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(e._digitReplacements&&!Array.isArray(e._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(e._numberFirst&&typeof e._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(e.unitMap&&typeof e.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(e.unitMap&&Object.values(e.unitMap).some(n=>typeof n!="string"))throw new TypeError("All values in unitMap must be of type string")},jf=(e,t)=>{t=t||-1;const r=new RegExp(String.raw`^-?\d+(?:.\d{0,${String(t)}})?`).exec(e.toString());return r===null?e:Number.parseFloat(r[0])},El=({unitCount:e,unitName:t},r,n)=>{let{spacer:o}=n;const{maxDecimalPoints:s}=n;let i=".";n.decimal!==void 0?i=n.decimal:r.decimal!==void 0&&(i=r.decimal);let a;"digitReplacements"in n?a=n.digitReplacements:"_digitReplacements"in r&&(a=r._digitReplacements);let l,u=e;s!==void 0&&(u=jf(e,s));const c=u.toString();if(!r._hideCountIf2||e!==2)if(a){l="";for(const d of c)l+=d==="."?i:a[d]}else l=c.replace(".",i);else l="";const p=r[t];let f=p;return typeof p=="function"&&(f=p(e)),r._hideCountIf2&&e===2&&(o=""),r._numberFirst?f+o+l:l+o+f},Bw=(e,t)=>{const{units:r}=t;if(r.length===0)return[];const{unitMeasures:n}=t,o=t.largest??Number.POSITIVE_INFINITY,s={};let i,a,l,u=e;for(a=0;a<r.length;a++){i=r[a];const p=n[i];l=a===r.length-1?u/p:Math.floor(u/p),s[i]=l,u-=l*p}if(t.round){let p=o;for(a=0;a<r.length;a++)if(i=r[a],l=s[i],l!==0&&(p--,p===0)){for(let f=a+1;f<r.length;f++){const d=r[f],m=s[d];s[i]=(s[i]??0)+m*n[d]/n[i],s[d]=0}break}for(a=r.length-1;a>=0;a--){if(i=r[a],l=s[i],l===0)continue;const f=Math.round(l);if(s[i]=f,a===0)break;const d=r[a-1],m=n[d],h=Math.floor(f*n[i]/m);if(h)s[d]=(s[d]??0)+h,s[i]=0;else break}}const c=[];for(a=0;a<r.length&&c.length<o;a++){if(i=r[a],l=s[i],l&&!t.round&&c.length===o-1){let p,f=0;for(p=a+1,r.length;p<r.length;p++){const d=r[p];f+=s[d]*(t.unitMeasures[d]/t.unitMeasures[i])}l+=f,t.maxDecimalPoints!==void 0&&(l=jf(l,t.maxDecimalPoints))}l&&c.push({unitCount:l,unitName:i})}return c},Dw=(e,t,r)=>{const{language:n,units:o}=t;if(e.length===0){const p=o.at(-1);return El({unitCount:0,unitName:p},n,t)}const{conjunction:s,serialComma:i}=t;let a=", ";t.delimiter!==void 0?a=t.delimiter:n.delimiter!==void 0&&(a=n.delimiter);let l="";t.timeAdverb&&r!==0&&(l=n.future??"",r<0&&(l=n.past??""));const u=e.map(p=>El(p,n,t));let c;return!s||e.length===1?c=u.join(a):e.length===2?c=u.join(s):c=u.slice(0,-1).join(a)+(i?",":"")+s+(u.at(-1)??""),l&&(c=l.replace("%s",c)),c},Sl=(e,t)=>{if(Number.isNaN(e))throw new TypeError("Expected a valid number");if(typeof e!="number")throw new TypeError("Expected a number for milliseconds input");const r={conjunction:"",language:Iw,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...t};Ww(r.language);const n=Math.abs(e),o=Bw(n,r);return Dw(o,r,e)};var Lw=Object.defineProperty,Af=(e,t)=>Lw(e,"name",{value:t,configurable:!0});const Fw=_e(import.meta.url),Sr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Of=Af(e=>{if(typeof Sr<"u"&&Sr.versions&&Sr.versions.node){const[t,r]=Sr.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return Sr.getBuiltinModule(e)}return Fw(e)},"__cjs_getBuiltinModule"),{execSync:Hw}=Of("node:child_process"),{existsSync:kl,readFileSync:qw}=Of("node:fs");var Jw=Object.defineProperty,Xe=Af((e,t)=>Jw(e,"name",{value:t,configurable:!0}),"r");const pa=["yarn.lock","package-lock.json","pnpm-lock.yaml","npm-shrinkwrap.json","bun.lockb"],Rf=Xe(e=>{let t;if(pa.forEach(n=>{!t&&kl(G(e,n))&&(t=G(e,n))}),t)return t;const r=G(e,"package.json");if(kl(r)&&la(qw(r,"utf8")).packageManager!==void 0)return r},"packageMangerFindUpMatcher"),Cf=Xe(e=>{if(!e)throw new _t("Could not find a package manager");if(e.endsWith("package.json")){const t=la(e);if(t.packageManager){const r=["npm","yarn","pnpm","bun"].find(n=>t.packageManager.startsWith(n));if(r)return{packageManager:r,path:Z(e)}}}if(e.endsWith("yarn.lock"))return{packageManager:"yarn",path:Z(e)};if(e.endsWith("package-lock.json")||e.endsWith("npm-shrinkwrap.json"))return{packageManager:"npm",path:Z(e)};if(e.endsWith("pnpm-lock.yaml"))return{packageManager:"pnpm",path:Z(e)};if(e.endsWith("bun.lockb"))return{packageManager:"bun",path:Z(e)};throw new _t("Could not find a package manager")},"resolvePackageManagerFromFile"),zw=Xe(async e=>{const t=await ft(pa,{type:"file",...e&&{cwd:e}});if(!t)throw new Error("Could not find lock file");return t},"findLockFile"),Uw=Xe(e=>{const t=dt(pa,{type:"file",...e&&{cwd:e}});if(!t)throw new Error("Could not find lock file");return t},"findLockFileSync"),Gw=Xe(async e=>{const t=await ft(Rf,{...e&&{cwd:e}});return Cf(t)},"findPackageManager"),Tf=Xe(e=>{const t=dt(Rf,{...e&&{cwd:e}});return Cf(t)},"findPackageManagerSync");Xe(e=>Hw(`${e} --version`).toString("utf8").trim(),"getPackageManagerVersion");Xe(()=>{if(!process.env.npm_config_user_agent)return;const e=process.env.npm_config_user_agent.split(" ")[0],t=e.lastIndexOf("/"),r=e.slice(0,Math.max(0,t));return{name:r==="npminstall"?"cnpm":r,version:e.slice(Math.max(0,t+1))}},"identifyInitiatingPackageManager");Xe((e,t,r)=>{const n=t.length===1?"":"s";if(r.packageManagers??=["npm","pnpm","yarn"],r.packageManagers.length===0)throw new Error("No package managers provided, please provide at least one package manager");if(t.length===0)throw new Error("No missing packages provided, please provide at least one missing package");let o=`
|
|
51
|
+
${r.preMessage??""}
|
|
52
|
+
${e} could not find the following package${n}
|
|
53
|
+
|
|
54
|
+
${t.join(`
|
|
55
|
+
`)}
|
|
56
|
+
|
|
57
|
+
To install the missing package${n}, please run the following command:
|
|
58
|
+
`;const s=Xe(a=>a.split("@").includes("@")?a:`${a}@latest`,"atLatest"),i=r.packageManagers.map(a=>{const l=t.map(u=>s(u)).join(" ");switch(a){case"bun":return` bun add ${l} -D`;case"npm":return` npm install ${l} --save-dev`;case"pnpm":return` pnpm add ${l} -D`;case"yarn":return` yarn add ${l} --dev`;default:throw new Error("Unknown package manager")}});return o+=i.join(`
|
|
59
|
+
|
|
60
|
+
or
|
|
61
|
+
|
|
62
|
+
`),r.postMessage&&(o+=r.postMessage),o},"generateMissingPackagesInstallMessage");var Vw=Object.defineProperty,Nf=(e,t)=>Vw(e,"name",{value:t,configurable:!0}),Kw=Object.defineProperty,Yw=Nf((e,t)=>Kw(e,"name",{value:t,configurable:!0}),"t");let IO=class extends Error{static{Nf(this,"s")}static{Yw(this,"PackageNotFoundError")}constructor(t,r){if(typeof t=="string"&&(t=[t]),t.length===0){super("Package was not found.");return}if(r===void 0)try{r=Tf().packageManager}catch{}r??="npm",super(`Package '${t.join(" ")}' was not found. Please install it using '${r} install ${t.join(" ")}'`)}get code(){return"PACKAGE_NOT_FOUND"}set code(t){throw new Error("Cannot overwrite code PACKAGE_NOT_FOUND")}get name(){return"PackageNotFoundError"}set name(t){throw new Error("Cannot overwrite name of PackageNotFoundError")}};var Xw=Object.defineProperty,Pf=(e,t)=>Xw(e,"name",{value:t,configurable:!0});const Zw=_e(import.meta.url),kr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Mf=Pf(e=>{if(typeof kr<"u"&&kr.versions&&kr.versions.node){const[t,r]=kr.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return kr.getBuiltinModule(e)}return Zw(e)},"__cjs_getBuiltinModule"),{readFileSync:Qw}=Mf("node:fs"),{readFile:ev}=Mf("node:fs/promises");var tv=Object.defineProperty,we=Pf((e,t)=>tv(e,"name",{value:t,configurable:!0}),"g");const rv={sha256:"sha256",sha384:"sha384",sha512:"sha512"},nv=1024,ov=/^[A-Z0-9+/]+={0,2}$/i,sv=/.*node_modules\/((?:@[^/]+\/)?[^/]+)$/,Jr=/^['"]/,zr=/['"]$/,iv=/^[a-z][a-zA-Z0-9]*:\s*$/m,av=/resolution:\s*\{[^}]*integrity:\s*([^,}\s]+)/,lv=/^["']?((?:@[^/@"']+\/)?[^@"'\n]+)@[^"'\n]+["']?:?[\t\v\f\r \u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*\n((?:[\t ][^\n]*\n?)+)/gm,cv=/^\s+version:?\s+"?([^"\n]+)"?/m,uv=/^\s+integrity[\s:]+"?([^"\s]+)"?/m,Co=we(e=>{if(e.length>nv)return;const t=e.indexOf("-");if(t<=0)return;const r=rv[e.slice(0,t).toLowerCase()];if(!r)return;const n=e.slice(t+1);if(ov.test(n))try{const o=Buffer.from(n,"base64");return o.length===0?void 0:{algorithm:r,hex:o.toString("hex")}}catch{return}},"decodeSriIntegrity"),To=we((e,t,r)=>{const n=`${r.name}@${r.version}`;t.has(n)||(t.add(n),e.push(r))},"pushUniqueEntry"),Me=we((e,t,r)=>{r&&Object.keys(r).length>0&&(e[t]={...r})},"copyDepMap"),Zt=we(e=>{if(!e)return;const t={};for(const[r,n]of Object.entries(e))t[r]=[n];return Object.keys(t).length>0?t:void 0},"liftDepMap"),pv=we(e=>{const t=[],r=new Set;let n;try{n=JSON.parse(e)}catch{return t}if(!n.packages)return t;for(const[o,s]of Object.entries(n.packages)){if(!o||!s.version)continue;const i=sv.exec(o);if(!i?.[1])continue;const a=s.name??i[1];if(a.startsWith("."))continue;const l={name:a,version:s.version};if(s.integrity){const u=Co(s.integrity);u&&(l.integrity=u)}Me(l,"dependencies",Zt(s.dependencies)),Me(l,"peerDependencies",Zt(s.peerDependencies)),Me(l,"optionalDependencies",Zt(s.optionalDependencies)),To(t,r,l)}return t},"parseNpmLockFile"),_f=we(e=>{let t=e.trim();t.startsWith("/")&&(t=t.slice(1)),t=t.replace(Jr,"").replace(zr,"");const r=t.indexOf("(");r>0&&(t=t.slice(0,r));const n=t.lastIndexOf("@");if(n<=0)return;const o=t.slice(0,n),s=t.slice(n+1);if(!(!o||!s||s.startsWith("link:")||s.startsWith("workspace:")||s.startsWith("file:")))return{name:o,version:s}},"splitPnpmPackageKey"),If=we((e,t)=>{const r=new RegExp(String.raw`^${t}:\s*$`,"m").exec(e);if(!r)return;const n=r.index+r[0].length,o=iv.exec(e.slice(n));return e.slice(n,o?n+o.index:e.length)},"sliceTopLevelSection"),fv=we(e=>{const t=new Map,r=If(e,"snapshots");if(!r)return t;const n=/^ {2}(['"]?[^\s:][^:\n]*?['"]?):\s*\n((?: {4}[^\n]*\n?)+)/gm;let o;for(;(o=n.exec(r)??void 0)!==void 0;){const s=_f(o[1]);if(!s)continue;const i=`${s.name}@${s.version}`,a=o[2],l=t.get(i)??{};for(const u of["dependencies","peerDependencies","optionalDependencies"]){const c=_n(a,u);if(!c)continue;const p=l[u]??{};for(const[f,d]of Object.entries(c)){const m=p[f]??[];for(const h of d)m.includes(h)||m.push(h);p[f]=m}l[u]=p}t.set(i,l)}return t},"parsePnpmSnapshotEdges"),dv=we(e=>{const t=[],r=new Set,n=If(e,"packages");if(!n)return t;const o=fv(e),s=/^ {2}(['"]?[^\s:][^:\n]*?['"]?):\s*\n((?: {4}[^\n]*\n?)+)/gm;let i;for(;(i=s.exec(n)??void 0)!==void 0;){const a=_f(i[1]);if(!a)continue;const l=i[2],u=av.exec(l),c={name:a.name,version:a.version};if(u?.[1]){const f=Co(u[1]);f&&(c.integrity=f)}const p=o.get(`${a.name}@${a.version}`);Me(c,"dependencies",p?.dependencies??_n(l,"dependencies")),Me(c,"peerDependencies",p?.peerDependencies??_n(l,"peerDependencies")),Me(c,"optionalDependencies",p?.optionalDependencies??_n(l,"optionalDependencies")),To(t,r,c)}return t},"parsePnpmLockFile"),_n=we((e,t)=>{const r=new RegExp(String.raw`^ {4}${t}:\s*\n((?: {6,}[^\n]*\n?)+)`,"m").exec(e);if(!r?.[1])return;const n={},o=/^ {6}([^\s:]+):\s*([^\n]+)/gm;let s;for(;(s=o.exec(r[1])??void 0)!==void 0;){const i=s[1].replace(Jr,"").replace(zr,"");let a=s[2].trim();a=a.replace(Jr,"").replace(zr,"");const l=a.indexOf("(");if(l>0&&(a=a.slice(0,l).trim()),!i||!a)continue;const u=n[i]??[];u.includes(a)||u.push(a),n[i]=u}return Object.keys(n).length>0?n:void 0},"extractPnpmDependencyMap"),mv=we(e=>{const t=[],r=new Set,n=lv;n.lastIndex=0;let o;for(;(o=n.exec(e)??void 0)!==void 0;){const s=o[1].replace(Jr,"").replace(zr,"");if(!s)continue;const i=o[2],a=cv.exec(i);if(!a?.[1])continue;const l={name:s,version:a[1].trim()},u=uv.exec(i);if(u?.[1]){const c=Co(u[1]);c&&(l.integrity=c)}Me(l,"dependencies",is(i,"dependencies")),Me(l,"peerDependencies",is(i,"peerDependencies")),Me(l,"optionalDependencies",is(i,"optionalDependencies")),To(t,r,l)}return t},"parseYarnLockFile"),is=we((e,t)=>{const r=new RegExp(String.raw`^ {2}${t}:\s*\n((?: {4,}[^\n]*\n?)+)`,"m").exec(e);if(!r?.[1])return;const n={},o=/^ {4}(['"]?[^\s:'"]+['"]?)\s*(?::\s*)?['"]([^'"\n]+)['"]/gm;let s;for(;(s=o.exec(r[1])??void 0)!==void 0;){const i=s[1].replace(Jr,"").replace(zr,""),a=s[2];if(i&&a){const l=n[i]??[];l.includes(a)||l.push(a),n[i]=l}}return Object.keys(n).length>0?n:void 0},"extractYarnDependencyMap"),hv=/,(?=\s*[}\]])/g,gv=we(e=>{const t=[],r=new Set;let n;try{n=JSON.parse(e.replaceAll(hv,""))}catch{return t}if(!n.packages)return t;for(const o of Object.values(n.packages)){const s=o[0];if(typeof s!="string")continue;const i=s.indexOf("@",1);if(i<=0)continue;const a=s.slice(0,i),l=s.slice(i+1);if(!a||!l||l.startsWith("workspace:")||l.startsWith("link:")||l.startsWith("file:"))continue;const u={name:a,version:l},c=o[3];if(typeof c=="string"&&c.length>0){const f=Co(c);f&&(u.integrity=f)}const p=o[2];if(p&&typeof p=="object"&&!Array.isArray(p)){const f=p;Me(u,"dependencies",Zt(f.dependencies)),Me(u,"peerDependencies",Zt(f.peerDependencies)),Me(u,"optionalDependencies",Zt(f.optionalDependencies))}To(t,r,u)}return t},"parseBunLockFile"),Wf=we(e=>{if(e.endsWith("pnpm-lock.yaml"))return"pnpm";if(e.endsWith("package-lock.json"))return"npm";if(e.endsWith("yarn.lock"))return"yarn";if(e.endsWith("bun.lock"))return"bun"},"inferLockFileType"),Bf=we((e,t)=>{switch(t){case"bun":return gv(e);case"npm":return pv(e);case"pnpm":return dv(e);case"yarn":return mv(e);default:return[]}},"parseLockFileContent"),Df=["pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lock"];we(async e=>{const t=await ft(Df,{type:"file",...e&&{cwd:e}});if(!t)throw new Error("Could not find a supported lock file (pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lock)");const r=Wf(t);if(!r)throw new Error(`Unsupported lock file: ${t}`);const n=await ev(t,"utf8");return{entries:Bf(n,r),path:t,type:r}},"parseLockFile");we(e=>{const t=dt(Df,{type:"file",...e&&{cwd:e}});if(!t)throw new Error("Could not find a supported lock file (pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lock)");const r=Wf(t);if(!r)throw new Error(`Unsupported lock file: ${t}`);return{entries:Bf(Qw(t,"utf8"),r),path:t,type:r}},"parseLockFileSync");var yv=Object.defineProperty,Lf=(e,t)=>yv(e,"name",{value:t,configurable:!0});const $v=_e(import.meta.url),jr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,bv=Lf(e=>{if(typeof jr<"u"&&jr.versions&&jr.versions.node){const[t,r]=jr.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return jr.getBuiltinModule(e)}return $v(e)},"__cjs_getBuiltinModule"),{existsSync:Yn,readFileSync:Ff}=bv("node:fs");var wv=Object.defineProperty,Hf=Lf((e,t)=>wv(e,"name",{value:t,configurable:!0}),"i");Hf(async e=>{const t=await ft(["lerna.json","turbo.json"],{type:"file",...e&&{cwd:e}});if(t?.endsWith("lerna.json")){const n=await lo(t);if(n&&typeof n=="object"&&!Array.isArray(n)){const o=n;if(o.useWorkspaces||o.packages)return{path:Z(t),strategy:"lerna"}}}const r=t?.endsWith("turbo.json");try{const{packageManager:n,path:o}=await Gw(e);if(["npm","yarn"].includes(n)){const s=G(o,"package.json");if(Yn(s)&&Ff(G(o,"package.json"),"utf8").includes("workspaces"))return{path:o,strategy:r?"turbo":n}}else if(n==="pnpm"){const s=G(o,"pnpm-workspace.yaml");if(Yn(s))return{path:o,strategy:r?"turbo":"pnpm"}}}catch(n){if(!(n instanceof _t))throw n}throw new Error(`No monorepo root could be found upwards from the directory ${e} using lerna, yarn, pnpm, or npm as indicators.`)},"findMonorepoRoot");Hf(e=>{const t=dt(["lerna.json","turbo.json"],{type:"file",...e&&{cwd:e}});if(t?.endsWith("lerna.json")){const n=Di(t);if(n.useWorkspaces||n.packages)return{path:Z(t),strategy:"lerna"}}const r=t?.endsWith("turbo.json");try{const{packageManager:n,path:o}=Tf(e);if(["npm","yarn"].includes(n)){const s=G(o,"package.json");if(Yn(s)&&Ff(G(o,"package.json"),"utf8").includes("workspaces"))return{path:o,strategy:r?"turbo":n}}else if(n==="pnpm"){const s=G(o,"pnpm-workspace.yaml");if(Yn(s))return{path:o,strategy:r?"turbo":"pnpm"}}}catch(n){if(!(n instanceof _t))throw n}throw new Error(`No monorepo root could be found upwards from the directory ${e} using lerna, yarn, pnpm, or npm as indicators.`)},"findMonorepoRootSync");var vv=Object.defineProperty,qf=(e,t)=>vv(e,"name",{value:t,configurable:!0});const xv=_e(import.meta.url),Ar=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ev=qf(e=>{if(typeof Ar<"u"&&Ar.versions&&Ar.versions.node){const[t,r]=Ar.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return Ar.getBuiltinModule(e)}return xv(e)},"__cjs_getBuiltinModule"),{existsSync:Sv}=Ev("node:fs");var kv=Object.defineProperty,fa=qf((e,t)=>kv(e,"name",{value:t,configurable:!0}),"r");const Jf=fa(e=>{if(Sv(G(e,"package.json"))){const t=Di(G(e,"package.json"));if(t.name&&t.private!==!0)return"package.json"}},"packageJsonMatcher");fa(async e=>{try{const n=await zw(e);return Z(n)}catch{}const t=await ft(".git/config",{...e&&{cwd:e},type:"file"});if(t)return Z(Z(t));const r=await ft(Jf,{...e&&{cwd:e},type:"file"});if(r)return Z(r);throw new Error("Could not find root directory")},"findPackageRoot");fa(e=>{try{const n=Uw(e);return Z(n)}catch{}const t=dt(".git/config",{...e&&{cwd:e},type:"file"});if(t)return Z(Z(t));const r=dt(Jf,{...e&&{cwd:e},type:"file"});if(r)return Z(r);throw new Error("Could not find root directory")},"findPackageRootSync");const Xn=async(e,t)=>{try{return t(await e())}catch{return}},zf="Rolldown is not installed. Please install '@rolldown/node' or 'rolldown' to use bundler: 'rolldown'.",Uf=async()=>{const e=await Xn(()=>import("@rolldown/node"),r=>typeof r.rolldown=="function"?r.rolldown:void 0);if(e)return e;const t=await Xn(()=>import("rolldown"),r=>typeof r.rolldown=="function"?r.rolldown:void 0);if(t)return t;throw new Error(zf)},jv=async()=>{const e=await Xn(()=>import("@rolldown/node"),r=>typeof r.watch=="function"?r.watch:void 0);if(e)return e;const t=await Xn(()=>import("rolldown"),r=>typeof r.watch=="function"?r.watch:void 0);if(t)return t;throw new Error(zf)};var Av=Object.defineProperty,Ov=(e,t)=>Av(e,"name",{value:t,configurable:!0}),Rv=Object.defineProperty,Bt=Ov((e,t)=>Rv(e,"name",{value:t,configurable:!0}),"u");const Gf="__packem_cache_wrapped",Ri="__packem_watch_files",lt=Bt(e=>typeof e=="function"?e:e.handler,"getHandler"),as=Bt(e=>{if(e&&typeof e=="object"&&"filter"in e)return e.filter},"getHookFilter"),jl=new Map,Cv=Bt(e=>{const t=JSON.stringify(e);let r=jl.get(t);return r===void 0&&(r=Ve(t),jl.set(t,r)),r},"hashResolveOptions"),Tv=Bt(e=>e!==null&&typeof e=="object"&&e[Gf]===!0,"isWrappedCacheValue"),Nv=Bt(e=>e!==null&&typeof e=="object"&&Array.isArray(e[Ri]),"isWatchFilesCacheValue"),yn=Bt(e=>Tv(e)?e.data:e,"unwrapCachedValue"),ke=Bt((e,t,r="")=>{if(!t.isEnabled)return e;const n=G(r,e.name),o={...e,async buildEnd(l){e.buildEnd&&await lt(e.buildEnd).call(this,l)},async buildStart(l){e.buildStart&&await lt(e.buildStart).call(this,l)},async load(l){if(!e.load)return;const u=l.includes("?")?l.split("?")[0]:l;let c="";try{if(u&&Sm(u)){const h=Mu(u);c=Ve(h)}}catch{}const p=G("load",Ve(l),c),f=await t.get(p,n);if(f!==void 0)return yn(f);const d=await lt(e.load).call(this,l);if(d==null)return d;const m=typeof d=="object"&&"code"in d?d:{data:d,[Gf]:!0};return t.set(p,m,n),d},name:`cached(${e.name})`,async resolveId(l,u,c){if(!e.resolveId)return;const p=G("resolveId",Ve(l),u?Ve(u):"",Cv(c)),f=await t.get(p,n);if(f!==void 0)return yn(f);const d=await lt(e.resolveId).call(this,l,u,c);return d==null||t.set(p,d,n),d},async transform(l,u){if(!e.transform)return;const c=G("transform",Ve(u),Ve(l)),p=await t.get(c,n);if(p!==void 0){const h=yn(p);if(Nv(h)){for(const y of h[Ri])this.addWatchFile(y);return yn(h.result)}return h}const f=[],d=Object.create(this);d.addWatchFile=h=>{f.push(h),this.addWatchFile(h)};const m=await lt(e.transform).call(d,l,u);return f.length>0?t.set(c,{[Ri]:f,result:m},n):m!=null&&t.set(c,m,n),m}},s=as(e.load),i=as(e.resolveId),a=as(e.transform);return s&&o.load&&(o.load={filter:s,handler:lt(o.load)}),i&&o.resolveId&&(o.resolveId={filter:i,handler:lt(o.resolveId)}),a&&o.transform&&(o.transform={filter:a,handler:lt(o.transform)}),o},"cachePlugin");var Pv=Object.defineProperty,Mv=(e,t)=>Pv(e,"name",{value:t,configurable:!0}),_v=Object.defineProperty,Iv=Mv((e,t)=>_v(e,"name",{value:t,configurable:!0}),"c");const Wv=Iv(()=>({name:"packem:fix-dynamic-import-extension",renderChunk(e,t,r){if(r.format==="es"||r.format==="cjs"){const n=new Ee(e),o=r.format==="es"?"mjs":"cjs",s=/(import\(.*?)(?<!\.d)(\.ts)(?=['"`]\))/g;let i=!1,a;for(;(a=s.exec(e))!==null;){const[,l,u]=a;if(l&&u){const c=a.index+l.length,p=c+u.length;n.overwrite(c,p,`.${o}`),i=!0}}if(i)return{code:n.toString(),map:r.sourcemap?n.generateMap({hires:!0}):void 0}}}}),"fixDynamicImportExtension");var Bv=Object.defineProperty,Dv=(e,t)=>Bv(e,"name",{value:t,configurable:!0}),Lv=Object.defineProperty,Fv=Dv((e,t)=>Lv(e,"name",{value:t,configurable:!0}),"i");const Hv=Fv(()=>({generateBundle(e,t){const r=[];for(const o of this.getModuleIds()){const s=this.getModuleInfo(o);if(s!==null&&!s.isExternal)for(const i of s.importedIds)r.push({source:o,target:i})}if(r.length===0)return;const n=Object.keys(t);this.emitFile({fileName:`metafile-${n[0].replace(Jm,"")}-${e.format??"unknown"}.json`,source:JSON.stringify(r,void 0,2),type:"asset"})},name:"packem:metafile"}),"metafilePlugin");var qv=Object.defineProperty,Jv=(e,t)=>qv(e,"name",{value:t,configurable:!0}),zv=Object.defineProperty,Uv=Jv((e,t)=>zv(e,"name",{value:t,configurable:!0}),"r");const Gv=/^file:\/\//,Vf=Uv(()=>({name:"packem:resolve-file-url",resolveId:{filter:{id:Gv},handler(e){if(e.startsWith("file://"))return zu(e)}}}),"resolveFileUrl");var Vv=Object.defineProperty,Kv=(e,t)=>Vv(e,"name",{value:t,configurable:!0}),Yv=Object.defineProperty,Xv=Kv((e,t)=>Yv(e,"name",{value:t,configurable:!0}),"s");const Zv=/^(\w+)-runtime$/,Qv=Xv(e=>{const t=Fe(e).split(".");if(t.length>=2){const[r,n]=t.slice(-2),o=t[0]??"",s=Zv.exec(r)?.[1];if(uo.includes(n)&&s&&s.length>0)return`${o}-${s}`}},"getCustomModuleLayer");var ex=Object.defineProperty,tx=(e,t)=>ex(e,"name",{value:t,configurable:!0}),rx=Object.defineProperty,nx=tx((e,t)=>rx(e,"name",{value:t,configurable:!0}),"t");const ox=/^use /,Lr=nx(e=>(e.preserveDirectives??{directives:[]}).directives.map(t=>t.replace(ox,"")).find(t=>t!=="strict"),"getModuleLayer");var sx=Object.defineProperty,ix=(e,t)=>sx(e,"name",{value:t,configurable:!0}),ax=Object.defineProperty,Zn=ix((e,t)=>ax(e,"name",{value:t,configurable:!0}),"p");const lx=/[\\/]node_modules[\\/]@swc[\\/]helper/,ls=Ym(e=>{let t=0;for(let r=0;r<e.length;r+=1)t=(t<<5)-t+e.codePointAt(r);return(t>>>0).toString(36).slice(0,3)}),Kf=Zn((e,t,r,n=new Set)=>{if(r.has(e))return r.get(e);if(n.has(e))return;n.add(e);const o=t(e);if(!o){r.set(e,void 0);return}const s=Lr(o.meta);if(s)return r.set(e,s),s;let i;for(const a of o.importers){const l=Kf(a,t,r,n);if(l){i=l;break}}return r.set(e,i),i},"getEffectiveModuleLayer"),cx=Zn((e,t,r)=>{const n=t(e);if(!n)return new Set;const o=new Set;for(const s of n.importers){const i=t(s);if(!i)continue;const a=Lr(i.meta);if(a)o.add(a);else{const l=Kf(s,t,r,new Set([e]));l&&o.add(l)}}return o},"getImporterLayers"),ux=Zn((e,t,r=!0)=>{const n=new Map,o=new Map;return Zn(function(s,i){if(lx.test(s))return"cc";const a=i.getModuleInfo(s);if(!a)return;const{isEntry:l}=a,u=a.meta;let c=Lr(u);if(c&&(c=ls(c)),!l){const p=n.get(s);if(p)return p;const f=Qv(s);if(f)return n.set(s,f),f}if(l&&c){const p=typeof i.getModuleIds=="function"?i.getModuleIds():(()=>{const f=new Set,d=[s];for(;d.length>0;){const m=d.pop();if(f.has(m))continue;f.add(m);const h=i.getModuleInfo(m);if(h)for(const y of h.importedIds)f.has(y)||d.push(y)}return f})();for(const f of p){const d=i.getModuleInfo(f);d&&Lr(d.meta)===c&&(e.has(f)||e.set(f,new Set),e.get(f).add([s,c]))}}if(r&&!c&&!l){const p=cx(s,i.getModuleInfo,o);if(p.size>1){if(n.has(s))return n.get(s);const f=Fe(s,tr(s)),d=[...p].toSorted((h,y)=>h.localeCompare(y)).join("-"),m=`${f}-${ls(d)}`;return n.set(s,m),m}}if(c&&!l&&e.has(s)){const p=[...e.get(s)];if(p.some(([h])=>{if(t.some(y=>y.path===h)){const y=i.getModuleInfo(h);return Lr(y?y.meta:{})===c}return!1}))return;if(p.every(([,h])=>h===c))return n.has(s)?n.get(s):void 0;const f=Fe(s,tr(s)),d=ls(c),m=`${f}-${d}`;return n.set(s,m),m}},"splitChunks")},"createSplitChunks");var px=Object.defineProperty,fx=(e,t)=>px(e,"name",{value:t,configurable:!0}),dx=Object.defineProperty,mx=fx((e,t)=>dx(e,"name",{value:t,configurable:!0}),"i");const No=mx((e,t)=>{let r={};return e.name&&(r[e.name]=t.rootDir),r={...r,...t.alias},t.rollup.alias&&t.rollup.alias.entries&&(Array.isArray(t.rollup.alias.entries)?Object.assign(r,Object.fromEntries(t.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(r,t.rollup.alias.entries)),r},"resolveAliases");var hx=Object.defineProperty,gx=(e,t)=>hx(e,"name",{value:t,configurable:!0}),yx=Object.defineProperty,da=gx((e,t)=>yx(e,"name",{value:t,configurable:!0}),"o");const $x=/\.tsx?$/,bx=/['"]use memo['"]/,Al="babel-options",wx="__packem_babel_missing_options__",vx=da(e=>e.find(t=>t==="babel-plugin-react-compiler"||Array.isArray(t)&&t[0]==="babel-plugin-react-compiler"),"getReactCompilerPlugin"),xx=da((e,t)=>{if(e.length===0)return;const r=vx(e);if(!(!r||!Array.isArray(r))&&r[1]?.compilationMode==="annotation"&&!bx.test(t)){const n=e.indexOf(r);n!==-1&&e.splice(n,1)}},"filterReactCompilerByAnnotation"),Ex=da(async(e,t,{filename:r,generatorOpts:n,sourceFileName:o,...s})=>{let i=[];s.plugins&&Array.isArray(s.plugins)&&(i=[...s.plugins]),i.length>0&&xx(i,e);const a=[];(t.endsWith(".jsx")||t.endsWith(".tsx"))&&a.push("jsx"),$x.test(t)&&a.push("typescript");const l=s.parserOpts?.plugins;l&&Array.isArray(l)&&a.unshift(...l);const u=[...new Set(a)],c=await dh(e,{...s,filename:t,generatorOpts:{...n,decoratorsBeforeExport:!0,importAttributesKeyword:"with"},parserOpts:{...s.parserOpts,allowAwaitOutsideFunction:!0,plugins:u.length>0?u:[],sourceType:"module"},plugins:i.length>0?i:[],sourceFileName:t});if(c?.code)return{code:c.code,map:c.map??void 0}},"transformCode");var Sx=Object.defineProperty,kx=(e,t)=>Sx(e,"name",{value:t,configurable:!0}),jx=Object.defineProperty,Ur=kx((e,t)=>jx(e,"name",{value:t,configurable:!0}),"s");const Ax=20,Ox=4,Rx=Gu("babel-runtime","plugins","babel","worker.js"),Cx=Ur(e=>{const t=Ur(r=>{if(r===null)return!0;if(Array.isArray(r))return r.every(n=>t(n));switch(typeof r){case"boolean":case"number":case"string":case"undefined":return!0;case"object":return Object.values(r).every(n=>t(n));default:return!1}},"isSerializable");for(const r of Object.keys(e))if(!t(e[r]))return r},"findNonSerializableOption"),Tx=Ur(()=>{let e;try{e=yi(zu(import.meta.url))}catch{return}for(let t=0;t<6;t+=1){const r=Gu(e,Rx);if(Ji(r))return r;const n=yi(e);if(n===e)break;e=n}},"resolveWorkerScript"),Nx=Ur(({exclude:e,generatorOpts:t,include:r,logger:n,parallel:o=!0,parallelThreshold:s=Ax,...i})=>{const a=Ze(r,e??kt),l={...i,generatorOpts:t};let u=0,c,p=o===!1||typeof o=="number"&&o<=0;const f=Ur(()=>{if(p)return;if(c)return c;if(u<s)return;const d=Cx(l);if(d!==void 0){p=!0,n?.warn(`[packem:babel] Parallel transforms disabled: the Babel option "${d}" is not serializable across a worker thread (e.g. a function plugin/preset or a function-form babel config). Falling back to in-process transforms.`);return}const m=Tx();if(!m){p=!0,n?.debug("[packem:babel] Parallel transforms disabled: the worker script was not found on disk (running from source, or the build did not copy it into dist/babel-runtime/). Falling back to in-process transforms.");return}const h=typeof o=="number"?Math.max(1,o):Math.max(1,Math.min(lh().length,Ox));return c=fh.pool(m,{maxWorkers:h,workerType:"thread"}),c},"ensurePool");return{async closeBundle(){this.meta.watchMode||(await c?.terminate(),c=void 0)},async closeWatcher(){await c?.terminate(),c=void 0},name:"packem:babel",async transform(d,m){if(!a(m))return;u+=1;const h=f();if(h)try{return await h.exec("transform",[d,m,Al])}catch($){if($ instanceof Error&&$.message.includes(wx))return await h.exec("transform",[d,m,Al,l]);throw $}const y=await Ex(d,m,l);if(y)return{code:y.code,map:y.map??void 0}}}},"babelTransformPlugin");var Px=Object.defineProperty,Mx=(e,t)=>Px(e,"name",{value:t,configurable:!0}),_x=Object.defineProperty,Ix=Mx((e,t)=>_x(e,"name",{value:t,configurable:!0}),"f");const Wx=Ix((e,t)=>{const r=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:o}=n;return Array.isArray(o)?o=o.map(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof o=="string"&&(o=[{src:o}]),{async buildStart(){const s=await Promise.all(o.flatMap(i=>Array.isArray(i.src)?i.src.map(a=>({...i,src:a})):[i]).map(async i=>await km(hi(i.src),{ignore:hi(i.exclude).filter(Boolean)}).then(a=>({dest:i.dest??"",parent:jm(i.src),src:a}))));for(const i of s)for(const a of i.src){let l;r.has(a)?l=r.get(a):(l={copied:[],dest:[],timestamp:0},r.set(a,l));const u=n.flatten?Ru(i.dest):G(i.dest,Se(i.parent,Z(a)));l.dest.includes(u)||l.dest.push(u),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all(Array.from(r,async([i,a])=>{let l;try{const u=await Qr(i);if(!u.isFile())return;const c=u.mtime.getTime();c>a.timestamp&&(a.timestamp=c,a.copied=[]),l=await Nt(i,{buffer:!0})}catch(u){t.error({context:[u],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const u of a.dest){if(n.copyOnce&&a.copied.includes(u))continue;const c=Fe(i),p=G(u,c);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:p,source:l,type:"asset"}),t.debug({message:`copied ${i} → ${p}`,prefix:"plugin:copy"}),a.copied.push(u)}catch(f){t.error({context:[f],message:`error copying file ${i} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Bx=Object.defineProperty,Dx=(e,t)=>Bx(e,"name",{value:t,configurable:!0}),Lx=Object.defineProperty,Fx=Dx((e,t)=>Lx(e,"name",{value:t,configurable:!0}),"l");const Hx=/\?data-uri/,qx=Fx((e={})=>{const t=Ze(e.include??[Hx],e.exclude);return{async load(r){if(!t(r)||!r.includes("?data-uri"))return;const n=new URL(r,"file://"),o=n.pathname,s=n.searchParams.get("encoding")??"tiny",i=n.searchParams.has("srcset")||e.srcset;this.addWatchFile(o);const a=Qu.getType(o)??"application/octet-stream";if(a==="image/svg+xml"){const p=await Nt(o,{buffer:!1}),f=s==="css"?zm(p):Um(p),d=i?f.replaceAll(" ","%20"):f;return`export default ${JSON.stringify(d)}`}const l=await Nt(o,{buffer:!0}),u=Buffer.from(l).toString("base64"),c=`${a.startsWith("text/")?`data:${a};charset=utf-8;base64,`:`data:${a};base64,`}${u}`;return`export default ${JSON.stringify(c)}`},name:"packem:data-uri"}},"dataUriPlugin");var Jx=Object.defineProperty,zx=(e,t)=>Jx(e,"name",{value:t,configurable:!0}),Ux=Object.defineProperty,ye=zx((e,t)=>Ux(e,"name",{value:t,configurable:!0}),"u");const Gx=/\.[mc]?tsx?(?:\?.*)?$/,Vx=/(?:\.[tj]sx?|\/index\.[tj]sx?)(?:\?.*)?$/,Kx=/^\s*export/,Yx=/^(?:import|export)\s+([\w$]+)/,Xx=/([\w$]+)\s*,\s*\{|\}\s*,\s*([\w$]+)/,cs=/[{,]\s*(type\s+)?([\w$]+)(?:\s+as\s+([\w$]+))?/gi,Zx=/default\s+([a-zA-Z_$][\w$]*)(?:[;\n]|$)/,Qx=/([\w$]+)\s*as\s*$/,e2=/^export\s+\*(?!\s+as)/,t2=/\bas\b/,r2={exports:[],facade:!1,imports:[]},Yf=ye(e=>Gx.test(e),"isSourceFile"),Xf=ye(e=>e.includes("/build/cache/vite/")||e.includes("/node_modules/"),"isIgnoredModule"),n2=ye((e,t)=>Xf(e)?!1:Vx.test(e)?!0:t.possibleBarrelFiles?t.possibleBarrelFiles.some(r=>typeof r=="string"?e.includes(r):r.test(e)):!1,"isPossibleBarrelSpecifier"),Zf=ye(e=>Kx.test(e)?"export":"import","getDeclarationKind"),{parseAsync:o2}=yh,Qf=ye(async(e,t,r)=>{try{const{output:n}=await o2({input:[{code:t,filename:e}]});return n[0]}catch(n){return r.debug({message:`Failed to parse ${e}:
|
|
63
|
+
${n instanceof Error?n.message:String(n)}`,prefix:"plugin:debarrel"}),r2}},"safeParse"),s2=ye(async(e,t,r,n)=>{const o=e.parseCache.get(t);if(o!==void 0)return o;const s=await Qf(t,r,n);return e.parseCache.set(t,s),s},"parsePotentialBarrelFile"),ed=ye((e,t)=>{const r=e.fileCache.get(t);if(r!==void 0)return r;const n=Vu.readFile(t,"utf8");return e.fileCache.set(t,n),n},"readFileCached"),td=ye(e=>{cs.lastIndex=0;const t=[];if(e.includes("*"))return t;if(!e.includes("{")){const o=Yx.exec(e);return o&&t.push({imported:"default",local:o[1]}),t}const r=Xx.exec(e);r&&t.push({imported:"default",local:r[1]??r[2]});let n=cs.exec(e);for(;n!==null;)!n[1]&&n[2]&&t.push({imported:n[2],local:n[3]}),n=cs.exec(e);return t},"getImportNames"),i2=ye((e,t,r)=>{let n=e.ln,o=t.find(s=>s.ss<e.s&&s.se>e.e&&s.d===-1);if(!o?.n){const s=n??Zx.exec(r.slice(e.s))?.[1];s&&(o=t.find(i=>{const a=td(r.slice(i.ss,i.s)).find(l=>l.local===s);return a&&(n=a.imported),a}))}if(o&&!n){const s=r.slice(o.ss,e.s);if(!s.includes("*")){const i=Qx.exec(s)?.[1];i&&(n=i)}}return{imp:o,localExportName:n}},"findMatchingImport"),Ol=new Map,a2=ye((e,t)=>{if(Zf(e)!=="import"||!t2.test(e))return;let r=Ol.get(t);return r||(r=new RegExp(String.raw`(\w+)\s+as\s+${t}(?!\w)`),Ol.set(t,r)),r.exec(e)?.[0]},"findAliasedImportName");let Gr;const l2=ye(async(e,t,r,n,o,s,i,a)=>{const{resolve:l}=e,u=i2(n,o,r),{imp:c,localExportName:p}=u;if(!c?.n)return{exportName:s,id:t,resolved:!0};if(c.d>-1)return{exportName:s,id:t,resolved:!0};const f=r.slice(c.ss,n.s),d=a2(f,s),m=(await l(c.n,t))?.id;return m?n2(m,i)?Gr(e,m,p??n.n,i,a):{aliasedImportName:d,exportName:p??s,id:m,resolved:!1}:{aliasedImportName:d,exportName:p,id:t,resolved:!1}},"resolveExportThroughBarrel"),c2=ye(async(e,t,r,n,o,s,i)=>{const a=n.filter(l=>e2.test(r.slice(l.ss,l.s)));if(a.length===1){const l=a[0]?.n,u=(l?await e.resolve(l,t):void 0)?.id;if(!u)return;const c=await Gr(e,u,o,s,i);if(c.resolved)return c}else if(a.length>1){const l=(await Promise.all(a.map(async u=>{const c=u.n;if(!c)return;const p=(await e.resolve(c,t))?.id;if(p)return Gr(e,p,o,s,i)}))).find(u=>u?.resolved);if(l)return l}},"resolveWildcardReExports");Gr=ye(async(e,t,r,n,o)=>{const s=await ed(e,t),{exports:i,imports:a}=await s2(e,t,s,o);for(const l of i)if(l.n===r)return await l2(e,t,s,l,a,r,n,o);return await c2(e,t,s,a,r,n,o)||{exportName:r,id:t,resolved:!1}},"resolveThroughBarrel");const u2=ye((e,t,r)=>{const{aliasedImportName:n,exportName:o}=e,s=t.local??t.imported;if(n)return`{${n}}`;if(o==="default"&&r!=="export")return s;const i=o??s;return`{${i!==s?`${i} as ${s}`:i}}`},"getDeclarationClause"),p2=ye(async(e,t,r,n,o)=>{const s=[],i=await ed(e,t),{imports:a}=await Qf(t,i,o);return await Promise.all(a.map(async l=>{if(!l.n||l.d!==-1)return;const u=i.slice(l.ss,l.s),c=td(u);if(c.length===0)return;const p=(await e.resolve(l.n,t))?.id;if(!p||!Yf(p)||Xf(p))return;const f=Zf(u);try{const d=await Promise.all(c.map(async m=>{const h=await Gr(e,p,m.imported,n,o),y=u2(h,m,f),$=JSON.stringify(h.id);return`${f} ${y} from ${$}`}));s.push([l.ss,l.se,d.join(";")])}catch(d){o.warn({context:{error:d},message:String(d),prefix:"plugin:debarrel"})}})),s},"getDebarrelModifications"),f2=ye((e,t,r,n)=>{if(r.length===0)return;const o=new Ee(t,{filename:e});for(const[s,i,a]of r)o.update(s,i,a);return{code:o.toString(),map:n?o.generateMap({file:e}):void 0}},"applyModifications"),d2=ye((e,t)=>{const r=new Map,n=new Map,o=ye(()=>{r.clear(),n.clear()},"purgeCaches"),s=e.include?Ze(e.include,[]):void 0;let i=!0;return{buildEnd:o,buildStart:o,async load(a){const l=r.get(a);if(l)return await l},name:"packem:debarrel",options(a){const{output:l}=a;let u;Array.isArray(l)?u=l[0]?.sourcemap:l&&(u=l.sourcemap),u===!1&&(i=!1)},async transform(a,l){if(l.includes("\0")||l.includes("?")||!Yf(l)||s&&!s(l))return;const u={fileCache:r,parseCache:n,resolve:this.resolve.bind(this)},c=await p2(u,l,a,e,t);return f2(l,a,c,i)},watchChange(a){r.delete(a),n.delete(a)}}},"debarrelPlugin");var us,Rl;function m2(){if(Rl)return us;Rl=1;const e=Oe();return us=(r,n,o,s,i)=>{typeof o=="string"&&(i=s,s=o,o=void 0);try{return new e(r instanceof e?r.version:r,o).inc(n,s,i).version}catch{return null}},us}var ps,Cl;function h2(){if(Cl)return ps;Cl=1;const e=Xr();return ps=(r,n)=>{const o=e(r,null,!0),s=e(n,null,!0),i=o.compare(s);if(i===0)return null;const a=i>0,l=a?o:s,u=a?s:o,c=!!l.prerelease.length;if(u.prerelease.length&&!c){if(!u.patch&&!u.minor)return"major";if(u.compareMain(l)===0)return u.minor&&!u.patch?"minor":"patch"}const p=c?"pre":"";return o.major!==s.major?p+"major":o.minor!==s.minor?p+"minor":o.patch!==s.patch?p+"patch":"prerelease"},ps}var fs,Tl;function g2(){if(Tl)return fs;Tl=1;const e=Oe();return fs=(r,n)=>new e(r,n).major,fs}var ds,Nl;function y2(){if(Nl)return ds;Nl=1;const e=Oe();return ds=(r,n)=>new e(r,n).minor,ds}var ms,Pl;function $2(){if(Pl)return ms;Pl=1;const e=Oe();return ms=(r,n)=>new e(r,n).patch,ms}var hs,Ml;function b2(){if(Ml)return hs;Ml=1;const e=Xr();return hs=(r,n)=>{const o=e(r,n);return o&&o.prerelease.length?o.prerelease:null},hs}var gs,_l;function qe(){if(_l)return gs;_l=1;const e=Oe();return gs=(r,n,o)=>new e(r,o).compare(new e(n,o)),gs}var ys,Il;function w2(){if(Il)return ys;Il=1;const e=qe();return ys=(r,n,o)=>e(n,r,o),ys}var $s,Wl;function v2(){if(Wl)return $s;Wl=1;const e=qe();return $s=(r,n)=>e(r,n,!0),$s}var bs,Bl;function ma(){if(Bl)return bs;Bl=1;const e=Oe();return bs=(r,n,o)=>{const s=new e(r,o),i=new e(n,o);return s.compare(i)||s.compareBuild(i)},bs}var ws,Dl;function x2(){if(Dl)return ws;Dl=1;const e=ma();return ws=(r,n)=>r.sort((o,s)=>e(o,s,n)),ws}var vs,Ll;function E2(){if(Ll)return vs;Ll=1;const e=ma();return vs=(r,n)=>r.sort((o,s)=>e(s,o,n)),vs}var xs,Fl;function Po(){if(Fl)return xs;Fl=1;const e=qe();return xs=(r,n,o)=>e(r,n,o)>0,xs}var Es,Hl;function ha(){if(Hl)return Es;Hl=1;const e=qe();return Es=(r,n,o)=>e(r,n,o)<0,Es}var Ss,ql;function rd(){if(ql)return Ss;ql=1;const e=qe();return Ss=(r,n,o)=>e(r,n,o)===0,Ss}var ks,Jl;function nd(){if(Jl)return ks;Jl=1;const e=qe();return ks=(r,n,o)=>e(r,n,o)!==0,ks}var js,zl;function ga(){if(zl)return js;zl=1;const e=qe();return js=(r,n,o)=>e(r,n,o)>=0,js}var As,Ul;function ya(){if(Ul)return As;Ul=1;const e=qe();return As=(r,n,o)=>e(r,n,o)<=0,As}var Os,Gl;function od(){if(Gl)return Os;Gl=1;const e=rd(),t=nd(),r=Po(),n=ga(),o=ha(),s=ya();return Os=(a,l,u,c)=>{switch(l){case"===":return typeof a=="object"&&(a=a.version),typeof u=="object"&&(u=u.version),a===u;case"!==":return typeof a=="object"&&(a=a.version),typeof u=="object"&&(u=u.version),a!==u;case"":case"=":case"==":return e(a,u,c);case"!=":return t(a,u,c);case">":return r(a,u,c);case">=":return n(a,u,c);case"<":return o(a,u,c);case"<=":return s(a,u,c);default:throw new TypeError(`Invalid operator: ${l}`)}},Os}var Rs,Vl;function S2(){if(Vl)return Rs;Vl=1;const e=Oe(),t=Xr(),{safeRe:r,t:n}=co();return Rs=(s,i)=>{if(s instanceof e)return s;if(typeof s=="number"&&(s=String(s)),typeof s!="string")return null;i=i||{};let a=null;if(!i.rtl)a=s.match(i.includePrerelease?r[n.COERCEFULL]:r[n.COERCE]);else{const d=i.includePrerelease?r[n.COERCERTLFULL]:r[n.COERCERTL];let m;for(;(m=d.exec(s))&&(!a||a.index+a[0].length!==s.length);)(!a||m.index+m[0].length!==a.index+a[0].length)&&(a=m),d.lastIndex=m.index+m[1].length+m[2].length;d.lastIndex=-1}if(a===null)return null;const l=a[2],u=a[3]||"0",c=a[4]||"0",p=i.includePrerelease&&a[5]?`-${a[5]}`:"",f=i.includePrerelease&&a[6]?`+${a[6]}`:"";return t(`${l}.${u}.${c}${p}${f}`,i)},Rs}var Cs,Kl;function k2(){if(Kl)return Cs;Kl=1;const e=Xr(),t=Fi(),r=Oe(),n=(a,l,u)=>{if(!t.RELEASE_TYPES.includes(l))return null;const c=o(a,u);return c&&s(c,l)},o=(a,l)=>{const u=a instanceof r?a.version:a;return e(u,l)},s=(a,l)=>{if(i(l))return a.version;switch(a.prerelease=[],l){case"major":a.minor=0,a.patch=0;break;case"minor":a.patch=0;break}return a.format()},i=a=>a.startsWith("pre");return Cs=n,Cs}var Ts,Yl;function j2(){if(Yl)return Ts;Yl=1;class e{constructor(){this.max=1e3,this.map=new Map}get(r){const n=this.map.get(r);if(n!==void 0)return this.map.delete(r),this.map.set(r,n),n}delete(r){return this.map.delete(r)}set(r,n){if(!this.delete(r)&&n!==void 0){if(this.map.size>=this.max){const o=this.map.keys().next().value;this.delete(o)}this.map.set(r,n)}return this}}return Ts=e,Ts}var Ns,Xl;function Je(){if(Xl)return Ns;Xl=1;const e=/\s+/g;class t{constructor(O,F){if(F=o(F),O instanceof t)return O.loose===!!F.loose&&O.includePrerelease===!!F.includePrerelease?O:new t(O.raw,F);if(O instanceof s)return this.raw=O.value,this.set=[[O]],this.formatted=void 0,this;if(this.options=F,this.loose=!!F.loose,this.includePrerelease=!!F.includePrerelease,this.raw=O.trim().replace(e," "),this.set=this.raw.split("||").map(I=>this.parseRange(I.trim())).filter(I=>I.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const I=this.set[0];if(this.set=this.set.filter(M=>!$(M[0])),this.set.length===0)this.set=[I];else if(this.set.length>1){for(const M of this.set)if(M.length===1&&g(M[0])){this.set=[M];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let O=0;O<this.set.length;O++){O>0&&(this.formatted+="||");const F=this.set[O];for(let I=0;I<F.length;I++)I>0&&(this.formatted+=" "),this.formatted+=F[I].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(O){O=O.replace(y,"");const F=((this.options.includePrerelease&&m)|(this.options.loose&&h))+":"+O,I=n.get(F);if(I)return I;const M=this.options.loose,_=M?l[c.HYPHENRANGELOOSE]:l[c.HYPHENRANGE];O=O.replace(_,U(this.options.includePrerelease)),i("hyphen replace",O),O=O.replace(l[c.COMPARATORTRIM],p),i("comparator trim",O),O=O.replace(l[c.TILDETRIM],f),i("tilde trim",O),O=O.replace(l[c.CARETTRIM],d),i("caret trim",O);let H=O.split(" ").map(K=>b(K,this.options)).join(" ").split(/\s+/).map(K=>z(K,this.options));M&&(H=H.filter(K=>(i("loose invalid filter",K,this.options),!!K.match(l[c.COMPARATORLOOSE])))),i("range list",H);const V=new Map,B=H.map(K=>new s(K,this.options));for(const K of B){if($(K))return[K];V.set(K.value,K)}V.size>1&&V.has("")&&V.delete("");const D=[...V.values()];return n.set(F,D),D}intersects(O,F){if(!(O instanceof t))throw new TypeError("a Range is required");return this.set.some(I=>w(I,F)&&O.set.some(M=>w(M,F)&&I.every(_=>M.every(H=>_.intersects(H,F)))))}test(O){if(!O)return!1;if(typeof O=="string")try{O=new a(O,this.options)}catch{return!1}for(let F=0;F<this.set.length;F++)if(J(this.set[F],O,this.options))return!0;return!1}}Ns=t;const r=j2(),n=new r,o=_u(),s=Mo(),i=Iu(),a=Oe(),{safeRe:l,src:u,t:c,comparatorTrimReplace:p,tildeTrimReplace:f,caretTrimReplace:d}=co(),{FLAG_INCLUDE_PRERELEASE:m,FLAG_LOOSE:h}=Fi(),y=new RegExp(u[c.BUILD],"g"),$=N=>N.value==="<0.0.0-0",g=N=>N.value==="",w=(N,O)=>{let F=!0;const I=N.slice();let M=I.pop();for(;F&&I.length;)F=I.every(_=>M.intersects(_,O)),M=I.pop();return F},b=(N,O)=>(N=N.replace(l[c.BUILD],""),i("comp",N,O),N=E(N,O),i("caret",N),N=S(N,O),i("tildes",N),N=k(N,O),i("xrange",N),N=P(N,O),i("stars",N),N),v=N=>!N||N.toLowerCase()==="x"||N==="*",S=(N,O)=>N.trim().split(/\s+/).map(F=>x(F,O)).join(" "),x=(N,O)=>{const F=O.loose?l[c.TILDELOOSE]:l[c.TILDE];return N.replace(F,(I,M,_,H,V)=>{i("tilde",N,I,M,_,H,V);let B;return v(M)?B="":v(_)?B=`>=${M}.0.0 <${+M+1}.0.0-0`:v(H)?B=`>=${M}.${_}.0 <${M}.${+_+1}.0-0`:V?(i("replaceTilde pr",V),B=`>=${M}.${_}.${H}-${V} <${M}.${+_+1}.0-0`):B=`>=${M}.${_}.${H} <${M}.${+_+1}.0-0`,i("tilde return",B),B})},E=(N,O)=>N.trim().split(/\s+/).map(F=>j(F,O)).join(" "),j=(N,O)=>{i("caret",N,O);const F=O.loose?l[c.CARETLOOSE]:l[c.CARET],I=O.includePrerelease?"-0":"";return N.replace(F,(M,_,H,V,B)=>{i("caret",N,M,_,H,V,B);let D;return v(_)?D="":v(H)?D=`>=${_}.0.0${I} <${+_+1}.0.0-0`:v(V)?_==="0"?D=`>=${_}.${H}.0${I} <${_}.${+H+1}.0-0`:D=`>=${_}.${H}.0${I} <${+_+1}.0.0-0`:B?(i("replaceCaret pr",B),_==="0"?H==="0"?D=`>=${_}.${H}.${V}-${B} <${_}.${H}.${+V+1}-0`:D=`>=${_}.${H}.${V}-${B} <${_}.${+H+1}.0-0`:D=`>=${_}.${H}.${V}-${B} <${+_+1}.0.0-0`):(i("no pr"),_==="0"?H==="0"?D=`>=${_}.${H}.${V}${I} <${_}.${H}.${+V+1}-0`:D=`>=${_}.${H}.${V}${I} <${_}.${+H+1}.0-0`:D=`>=${_}.${H}.${V} <${+_+1}.0.0-0`),i("caret return",D),D})},k=(N,O)=>(i("replaceXRanges",N,O),N.split(/\s+/).map(F=>R(F,O)).join(" ")),R=(N,O)=>{N=N.trim();const F=O.loose?l[c.XRANGELOOSE]:l[c.XRANGE];return N.replace(F,(I,M,_,H,V,B)=>{i("xRange",N,I,M,_,H,V,B);const D=v(_),K=D||v(H),q=K||v(V),A=q;return M==="="&&A&&(M=""),B=O.includePrerelease?"-0":"",D?M===">"||M==="<"?I="<0.0.0-0":I="*":M&&A?(K&&(H=0),V=0,M===">"?(M=">=",K?(_=+_+1,H=0,V=0):(H=+H+1,V=0)):M==="<="&&(M="<",K?_=+_+1:H=+H+1),M==="<"&&(B="-0"),I=`${M+_}.${H}.${V}${B}`):K?I=`>=${_}.0.0${B} <${+_+1}.0.0-0`:q&&(I=`>=${_}.${H}.0${B} <${_}.${+H+1}.0-0`),i("xRange return",I),I})},P=(N,O)=>(i("replaceStars",N,O),N.trim().replace(l[c.STAR],"")),z=(N,O)=>(i("replaceGTE0",N,O),N.trim().replace(l[O.includePrerelease?c.GTE0PRE:c.GTE0],"")),U=N=>(O,F,I,M,_,H,V,B,D,K,q,A)=>(v(I)?F="":v(M)?F=`>=${I}.0.0${N?"-0":""}`:v(_)?F=`>=${I}.${M}.0${N?"-0":""}`:H?F=`>=${F}`:F=`>=${F}${N?"-0":""}`,v(D)?B="":v(K)?B=`<${+D+1}.0.0-0`:v(q)?B=`<${D}.${+K+1}.0-0`:A?B=`<=${D}.${K}.${q}-${A}`:N?B=`<${D}.${K}.${+q+1}-0`:B=`<=${B}`,`${F} ${B}`.trim()),J=(N,O,F)=>{for(let I=0;I<N.length;I++)if(!N[I].test(O))return!1;if(O.prerelease.length&&!F.includePrerelease){for(let I=0;I<N.length;I++)if(i(N[I].semver),N[I].semver!==s.ANY&&N[I].semver.prerelease.length>0){const M=N[I].semver;if(M.major===O.major&&M.minor===O.minor&&M.patch===O.patch)return!0}return!1}return!0};return Ns}var Ps,Zl;function Mo(){if(Zl)return Ps;Zl=1;const e=Symbol("SemVer ANY");class t{static get ANY(){return e}constructor(c,p){if(p=r(p),c instanceof t){if(c.loose===!!p.loose)return c;c=c.value}c=c.trim().split(/\s+/).join(" "),i("comparator",c,p),this.options=p,this.loose=!!p.loose,this.parse(c),this.semver===e?this.value="":this.value=this.operator+this.semver.version,i("comp",this)}parse(c){const p=this.options.loose?n[o.COMPARATORLOOSE]:n[o.COMPARATOR],f=c.match(p);if(!f)throw new TypeError(`Invalid comparator: ${c}`);this.operator=f[1]!==void 0?f[1]:"",this.operator==="="&&(this.operator=""),f[2]?this.semver=new a(f[2],this.options.loose):this.semver=e}toString(){return this.value}test(c){if(i("Comparator.test",c,this.options.loose),this.semver===e||c===e)return!0;if(typeof c=="string")try{c=new a(c,this.options)}catch{return!1}return s(c,this.operator,this.semver,this.options)}intersects(c,p){if(!(c instanceof t))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new l(c.value,p).test(this.value):c.operator===""?c.value===""?!0:new l(this.value,p).test(c.semver):(p=r(p),p.includePrerelease&&(this.value==="<0.0.0-0"||c.value==="<0.0.0-0")||!p.includePrerelease&&(this.value.startsWith("<0.0.0")||c.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&c.operator.startsWith(">")||this.operator.startsWith("<")&&c.operator.startsWith("<")||this.semver.version===c.semver.version&&this.operator.includes("=")&&c.operator.includes("=")||s(this.semver,"<",c.semver,p)&&this.operator.startsWith(">")&&c.operator.startsWith("<")||s(this.semver,">",c.semver,p)&&this.operator.startsWith("<")&&c.operator.startsWith(">")))}}Ps=t;const r=_u(),{safeRe:n,t:o}=co(),s=od(),i=Iu(),a=Oe(),l=Je();return Ps}var Ms,Ql;function sn(){if(Ql)return Ms;Ql=1;const e=Je();return Ms=(r,n,o)=>{try{n=new e(n,o)}catch{return!1}return n.test(r)},Ms}var _s,ec;function A2(){if(ec)return _s;ec=1;const e=Je();return _s=(r,n)=>new e(r,n).set.map(o=>o.map(s=>s.value).join(" ").trim().split(" ")),_s}var Is,tc;function O2(){if(tc)return Is;tc=1;const e=Oe(),t=Je();return Is=(n,o,s)=>{let i=null,a=null,l=null;try{l=new t(o,s)}catch{return null}return n.forEach(u=>{l.test(u)&&(!i||a.compare(u)===-1)&&(i=u,a=new e(i,s))}),i},Is}var Ws,rc;function R2(){if(rc)return Ws;rc=1;const e=Oe(),t=Je();return Ws=(n,o,s)=>{let i=null,a=null,l=null;try{l=new t(o,s)}catch{return null}return n.forEach(u=>{l.test(u)&&(!i||a.compare(u)===1)&&(i=u,a=new e(i,s))}),i},Ws}var Bs,nc;function C2(){if(nc)return Bs;nc=1;const e=Oe(),t=Je(),r=Po();return Bs=(o,s)=>{o=new t(o,s);let i=new e("0.0.0");if(o.test(i)||(i=new e("0.0.0-0"),o.test(i)))return i;i=null;for(let a=0;a<o.set.length;++a){const l=o.set[a];let u=null;l.forEach(c=>{const p=new e(c.semver.version);switch(c.operator){case">":p.prerelease.length===0?p.patch++:p.prerelease.push(0),p.raw=p.format();case"":case">=":(!u||r(p,u))&&(u=p);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${c.operator}`)}}),u&&(!i||r(i,u))&&(i=u)}return i&&o.test(i)?i:null},Bs}var Ds,oc;function T2(){if(oc)return Ds;oc=1;const e=Je();return Ds=(r,n)=>{try{return new e(r,n).range||"*"}catch{return null}},Ds}var Ls,sc;function $a(){if(sc)return Ls;sc=1;const e=Oe(),t=Mo(),{ANY:r}=t,n=Je(),o=sn(),s=Po(),i=ha(),a=ya(),l=ga();return Ls=(c,p,f,d)=>{c=new e(c,d),p=new n(p,d);let m,h,y,$,g;switch(f){case">":m=s,h=a,y=i,$=">",g=">=";break;case"<":m=i,h=l,y=s,$="<",g="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(o(c,p,d))return!1;for(let w=0;w<p.set.length;++w){const b=p.set[w];let v=null,S=null;if(b.forEach(x=>{x.semver===r&&(x=new t(">=0.0.0")),v=v||x,S=S||x,m(x.semver,v.semver,d)?v=x:y(x.semver,S.semver,d)&&(S=x)}),v.operator===$||v.operator===g||(!S.operator||S.operator===$)&&h(c,S.semver)||S.operator===g&&y(c,S.semver))return!1}return!0},Ls}var Fs,ic;function N2(){if(ic)return Fs;ic=1;const e=$a();return Fs=(r,n,o)=>e(r,n,">",o),Fs}var Hs,ac;function P2(){if(ac)return Hs;ac=1;const e=$a();return Hs=(r,n,o)=>e(r,n,"<",o),Hs}var qs,lc;function M2(){if(lc)return qs;lc=1;const e=Je();return qs=(r,n,o)=>(r=new e(r,o),n=new e(n,o),r.intersects(n,o)),qs}var Js,cc;function _2(){if(cc)return Js;cc=1;const e=sn(),t=qe();return Js=(r,n,o)=>{const s=[];let i=null,a=null;const l=r.sort((f,d)=>t(f,d,o));for(const f of l)e(f,n,o)?(a=f,i||(i=f)):(a&&s.push([i,a]),a=null,i=null);i&&s.push([i,null]);const u=[];for(const[f,d]of s)f===d?u.push(f):!d&&f===l[0]?u.push("*"):d?f===l[0]?u.push(`<=${d}`):u.push(`${f} - ${d}`):u.push(`>=${f}`);const c=u.join(" || "),p=typeof n.raw=="string"?n.raw:String(n);return c.length<p.length?c:n},Js}var zs,uc;function I2(){if(uc)return zs;uc=1;const e=Je(),t=Mo(),{ANY:r}=t,n=sn(),o=qe(),s=(p,f,d={})=>{if(p===f)return!0;p=new e(p,d),f=new e(f,d);let m=!1;e:for(const h of p.set){for(const y of f.set){const $=l(h,y,d);if(m=m||$!==null,$)continue e}if(m)return!1}return!0},i=[new t(">=0.0.0-0")],a=[new t(">=0.0.0")],l=(p,f,d)=>{if(p===f)return!0;if(p.length===1&&p[0].semver===r){if(f.length===1&&f[0].semver===r)return!0;d.includePrerelease?p=i:p=a}if(f.length===1&&f[0].semver===r){if(d.includePrerelease)return!0;f=a}const m=new Set;let h,y;for(const E of p)E.operator===">"||E.operator===">="?h=u(h,E,d):E.operator==="<"||E.operator==="<="?y=c(y,E,d):m.add(E.semver);if(m.size>1)return null;let $;if(h&&y&&($=o(h.semver,y.semver,d),$>0||$===0&&(h.operator!==">="||y.operator!=="<=")))return null;for(const E of m){if(h&&!n(E,String(h),d)||y&&!n(E,String(y),d))return null;for(const j of f)if(!n(E,String(j),d))return!1;return!0}let g,w,b,v,S=y&&!d.includePrerelease&&y.semver.prerelease.length?y.semver:!1,x=h&&!d.includePrerelease&&h.semver.prerelease.length?h.semver:!1;S&&S.prerelease.length===1&&y.operator==="<"&&S.prerelease[0]===0&&(S=!1);for(const E of f){if(v=v||E.operator===">"||E.operator===">=",b=b||E.operator==="<"||E.operator==="<=",h){if(x&&E.semver.prerelease&&E.semver.prerelease.length&&E.semver.major===x.major&&E.semver.minor===x.minor&&E.semver.patch===x.patch&&(x=!1),E.operator===">"||E.operator===">="){if(g=u(h,E,d),g===E&&g!==h)return!1}else if(h.operator===">="&&!E.test(h.semver))return!1}if(y){if(S&&E.semver.prerelease&&E.semver.prerelease.length&&E.semver.major===S.major&&E.semver.minor===S.minor&&E.semver.patch===S.patch&&(S=!1),E.operator==="<"||E.operator==="<="){if(w=c(y,E,d),w===E&&w!==y)return!1}else if(y.operator==="<="&&!E.test(y.semver))return!1}if(!E.operator&&(y||h)&&$!==0)return!1}return!(h&&b&&!y&&$!==0||y&&v&&!h&&$!==0||x||S)},u=(p,f,d)=>{if(!p)return f;const m=o(p.semver,f.semver,d);return m>0?p:m<0||f.operator===">"&&p.operator===">="?f:p},c=(p,f,d)=>{if(!p)return f;const m=o(p.semver,f.semver,d);return m<0?p:m>0||f.operator==="<"&&p.operator==="<="?f:p};return zs=s,zs}var Us,pc;function W2(){if(pc)return Us;pc=1;const e=co(),t=Fi(),r=Oe(),n=Am(),o=Xr(),s=Wu(),i=Om(),a=m2(),l=h2(),u=g2(),c=y2(),p=$2(),f=b2(),d=qe(),m=w2(),h=v2(),y=ma(),$=x2(),g=E2(),w=Po(),b=ha(),v=rd(),S=nd(),x=ga(),E=ya(),j=od(),k=S2(),R=k2(),P=Mo(),z=Je(),U=sn(),J=A2(),N=O2(),O=R2(),F=C2(),I=T2(),M=$a(),_=N2(),H=P2(),V=M2(),B=_2(),D=I2();return Us={parse:o,valid:s,clean:i,inc:a,diff:l,major:u,minor:c,patch:p,prerelease:f,compare:d,rcompare:m,compareLoose:h,compareBuild:y,sort:$,rsort:g,gt:w,lt:b,eq:v,neq:S,gte:x,lte:E,cmp:j,coerce:k,truncate:R,Comparator:P,Range:z,satisfies:U,toComparators:J,maxSatisfying:N,minSatisfying:O,minVersion:F,validRange:I,outside:M,gtr:_,ltr:H,intersects:V,simplifyRange:B,subset:D,SemVer:r,re:e.re,src:e.src,tokens:e.t,SEMVER_SPEC_VERSION:t.SEMVER_SPEC_VERSION,RELEASE_TYPES:t.RELEASE_TYPES,compareIdentifiers:n.compareIdentifiers,rcompareIdentifiers:n.rcompareIdentifiers},Us}var Le=W2(),B2=Object.defineProperty,sd=(e,t)=>B2(e,"name",{value:t,configurable:!0}),D2=Object.defineProperty,id=sd((e,t)=>D2(e,"name",{value:t,configurable:!0}),"r");const Qn=/.*\/node_modules\/(?:@[^/]+\/)?[^/]+/,Ci=Hi(async e=>{const t=G(e,"package.json");try{const r=await Rm(t);return{directory:Z(t),name:r.name,version:r.version}}catch{return}})(),ad=id(async e=>{const t=Hr(e),r=Qn.exec(t);if(!r)return;const n=await Ci(r[0]);if(n)return n;const o=t.lastIndexOf("node_modules");if(o<=0)return;const s=Qn.exec(t.slice(0,o-1));if(s)return Ci(s[0])},"getPackageInfo"),L2=id(()=>{Ci.destroy()},"destroyPackageInfoCache");var F2=Object.defineProperty,ht=sd((e,t)=>F2(e,"name",{value:t,configurable:!0}),"d");const fc=Hi(async(e,t)=>{const r=Hr(e);if(Qn.test(r)){const n=await ad(r);if(n)return`${n.name}@${n.version}`}return r.replace(`${Hr(t)}/`,"")})(),H2=ht(e=>new Set([...e].toSorted((t,r)=>t.localeCompare(r))),"sortImporters"),q2=ht(e=>new Map([...e.entries()].toSorted((t,r)=>t[0].localeCompare(r[0])).map(([t,r])=>[t,H2(r)])),"sortDirectoryMap"),J2=ht(e=>new Map([...e.entries()].toSorted((t,r)=>Le.compare(t[0],r[0])).map(([t,r])=>[t,q2(r)])),"sortVersionMap"),z2=ht(e=>new Map([...e.entries()].toSorted((t,r)=>t[0].localeCompare(r[0])).map(([t,r])=>[t,J2(r)])),"sortPackagesInfo"),U2=ht((e,t,r,n,o)=>{let s=e.get(t);s||(s=new Map,e.set(t,s));let i=s.get(r);i||(i=new Map,s.set(r,i));let a=i.get(n);a||(a=new Set,i.set(n,a)),a.add(o)},"addImporter"),G2=ht((e,t,r,n)=>{const o=Math.max(0,...t.map(a=>a.length)),s=ht((a,l)=>a.filter(u=>u!==`${e}@${l}`).map(u=>Li(u)).join(", "),"colorizeImporters"),i=[`
|
|
64
|
+
${Rn(e)}:`];for(const a of t){const l=r.get(e)?.get(a);if(!l)continue;const u=Ae(Yt(a.padEnd(o," ")));if(l.size===1){const[c]=[...l.values()],p=c?[...c]:[];i.push(` - ${u} imported by ${s(p,a)}`);continue}i.push(` - ${u}`);for(const[c,p]of l){const f=Ae(re(c.replace(Hr(n),".")));i.push(` - ${f} imported by ${s([...p],a)}`)}}return i},"formatDuplicatedPackage"),V2=ht((e,t,{customErrorMessage:r,deep:n=!0,ignore:o={},throwErrorWhenDuplicated:s=!1}={})=>({async buildEnd(){const i=new Map;await Promise.all([...this.getModuleIds()].map(async f=>{const d=this.getModuleInfo(f);if(d===null||d.isExternal||d.isIncluded===!1)return;const m=await ad(f);if(!m)return;const{directory:h,name:y,version:$}=m;for(const g of[...d.importers,...d.dynamicImporters]){const w=Hr(g);!n&&Qn.test(w)||U2(i,y,$,h,await fc(w,t))}})),L2(),fc.destroy();const a=z2(i),l={},u=new Map;for(const[f,d]of a.entries()){const m=[...d.values()];if(m.length>1||m.length===1&&(m[0]?.size??0)>1){l[f]=[...d.keys()];for(const h of d.keys()){const y=o[f];if(!(y!==void 0&&(y.includes("*")||y.includes(h)))){const $=u.get(f)??[];$.push(h),u.set(f,$)}}}}if(u.size===0)return;const c=[`packages ${[...u.keys()].map(f=>Rn(f)).join(", ")} is bundled multiple times!`];for(const[f,d]of u)c.push(...G2(f,d,a,t));const p=r?r(a):c.join(`
|
|
65
|
+
`);s&&(e.error(p),e.info(`Fix this error by eliminating the duplicated dependencies or adjusting the ${Rn("ignore")} option.`),e.info(`You can copy the following duplicated dependencies as the value of the ${Rn("ignore")} option:`),e.info(`
|
|
66
|
+
${JSON.stringify(l,void 0,4)}
|
|
67
|
+
`),this.error("Duplicated dependencies detected.")),e.warn(p)},name:"packem:detect-duplicated"}),"detectDuplicatedPlugin");var K2=Object.defineProperty,Y2=(e,t)=>K2(e,"name",{value:t,configurable:!0}),X2=Object.defineProperty,_o=Y2((e,t)=>X2(e,"name",{value:t,configurable:!0}),"t");const Z2=/(?:^|[^.\w'"`])require(\.resolve)?\(\s*([\w'"`])/,Q2=_o((e,t)=>{if(bm.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return;let r=!1,n=!1,o=!1;if(e.includes("__filename")&&(r=!0),e.includes("__dirname")&&(n=!0),Z2.test(e)&&(o=!0),!r&&!n&&!o)return;const s=fo(e).pop(),i=s?s.end:0,a=new Ee(e);return a.appendRight(i,t(r,n,o)),{code:a.toString(),map:a.generateMap()}},"CJSToESM"),eE=_o((e,t,r)=>{let n="";return(e||t)&&(n+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
|
|
68
|
+
`),t&&(n+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
|
|
69
|
+
`),r&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
70
|
+
`),(e||t)&&(n+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
71
|
+
`),t&&(n+=`const __dirname = __cjs_path__.dirname(__filename);
|
|
72
|
+
`),r&&(n+=`const require = __cjs_mod__.createRequire(import.meta.url);
|
|
73
|
+
`),n},"generateCJSShim"),tE=_o((e,t,r)=>{let n="";return r&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
74
|
+
`),e&&(n+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
|
|
75
|
+
`),t&&(n+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
|
|
76
|
+
`),r&&(n+=`const require = __cjs_mod__.createRequire(import.meta.url);
|
|
77
|
+
`),n},"generateCJSShimNode20_11"),rE=_o((e,t)=>{const r=Ze(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(n,o,s){if(s.format==="es"&&r(o.fileName)){let i=eE;if(e.engines?.node){const a=Le.minVersion(e.engines.node);a&&(a.major>20||a.major===20&&a.minor>=11)&&(i=tE)}return Q2(n,i)}}}},"esmShimCjsSyntaxPlugin");var nE=Object.defineProperty,oE=(e,t)=>nE(e,"name",{value:t,configurable:!0}),sE=Object.defineProperty,Be=oE((e,t)=>sE(e,"name",{value:t,configurable:!0}),"c");const _r=/[.*+?^${}()|[\]\\]/g,iE=/.*/,aE=/^(?:\0|\.{1,2}\/)/,lE=/^node:/,cE=/^@visulima\/css-style-inject(?:\/.+)?$/,dc=Be((e,t,r)=>e.reduce((n,o,s)=>(o instanceof RegExp?n.push(o):typeof o=="string"&&o.length>0?n.push(new RegExp(`^${o.replaceAll(_r,String.raw`\$&`)}$`)):r.warn(`Ignoring wrong entry type #${String(s)} in '${t}' option: ${JSON.stringify(o)}`),n),[]),"getRegExps"),Ti=new Map,uE=Be((e,t)=>{Ti.has(e)||t.info({message:`Inlined implicit external "${re(e)}". If this is incorrect, add it to the "externals" option.`,prefix:"plugin:packem:externals"}),Ti.set(e,!0)},"logExternalMessage"),mc=new Set(["node:sqlite","node:test"]),pE=/[\\:]/,fE=Be(e=>e.length>0&&!pE.test(e),"isValidPackageName"),ba="@types/",hc=Be(e=>{if(e.startsWith("@")){const[t,r]=e.split("/");return`${t??""}/types/${r??""}`}return`${ba}${e}`},"getAtTypesPackageName"),dE=Be(e=>{if(e.startsWith("@")){const t=e.split("/");if(t[1]==="types")return`${t[0]??""}/${t.slice(2).join("/")}`}return e.replace(ba,"")},"getOriginalPackageName"),mE=["peerDependencies","dependencies","optionalDependencies"],ld=Be((e,t)=>{const r=ih.realpathSync.native(process.cwd()),{pkg:n}=e,o=new Set;for(const x of mE){const E=n[x];if(E)for(const j of Object.keys(E))j.startsWith(ba)?o.add(dE(j)):o.add(j)}const s=new Set(Object.keys(n.devDependencies??{})),i=new Set([...Object.keys(n.dependencies??{}),...Object.keys(n.devDependencies??{}),...Object.keys(n.peerDependencies??{}),...Object.keys(n.optionalDependencies??{})]),a=e.options.rollup.resolveExternals??{},l=new Set(dc([...e.options.externals??[]],"include",e.logger)),u=new Set(dc([...a.exclude??[]],"exclude",e.logger));if(t?.dtsResolve)if(t.dtsResolve===!0)u.add(iE);else for(const x of t.dtsResolve)typeof x=="string"?u.add(new RegExp(`^${x.replaceAll(_r,String.raw`\$&`)}(?:/.+)?$`)):u.add(x);const c=Be(x=>{const{dtsResolve:E}=t??{};return E?typeof E=="boolean"?E:E.some(j=>typeof j=="string"?x===j:j.test(x)):!1},"shouldResolveForDts"),p={...a.deps?n.dependencies??{}:void 0,...a.devDeps?n.devDependencies??{}:void 0,...a.peerDeps?n.peerDependencies??{}:void 0,...a.optDeps?n.optionalDependencies??{}:void 0},f=Object.keys(p);if(f.length>0){const x=f.map(E=>E.replaceAll(_r,String.raw`\$&`));l.add(new RegExp(`^(?:${x.join("|")})(?:/.+)?$`))}if(l.add(cE),n.peerDependenciesMeta)for(const[x,E]of Object.entries(n.peerDependenciesMeta))E&&typeof E=="object"&&"optional"in E&&l.add(new RegExp(`^${x.replaceAll(_r,String.raw`\$&`)}(?:/.+)?$`));const d=[...l],m=[...u],h=Be(x=>d.some(E=>E.test(x)),"isIncluded"),y=Be(x=>m.some(E=>E.test(x)),"isExcluded");let $=[];e.tsconfig&&($=Object.entries(e.tsconfig.config.compilerOptions?.paths??{}).map(([x])=>x.endsWith("*")?new RegExp(`^${x.replace("*","(.*)")}$`):new RegExp(`^${x}$`)));const g=No(n,e.options),w=e.options.sourceDir?new RegExp(String.raw`(?:^|/)${e.options.sourceDir.replaceAll(_r,String.raw`\$&`)}/`):void 0,b=new Set,v=new Set,S=new Map;return{buildStart(){Ti.clear()},name:"packem:externals",options:Be(x=>{x.external=(E,j)=>{const k=`${E}::${j??""}`;if(S.has(k))return S.get(k);const R=Fr(E),P=j?Fr(j):void 0;let z;if(Object.keys(g).length>0){const O=vm(R,g);O!==R&&(z=O)}let U="";z&&Tr(z)&&(U=qa(z).name??""),!U&&Tr(R)&&(U=qa(R).name??Zm(R));const J=U&&Tr(U)&&fE(U)?U:"";if(J&&!fn(J)){e.usedDependencies.add(J);const O=!P||!Uo(P,e.options.rootDir),F=i.has(J);O&&!F&&e.options.validation&&e.options.validation.dependencies&&e.options.validation.dependencies.hoisted!==!1&&!e.options.validation.dependencies.hoisted?.exclude.includes(J)&&e.hoistedDependencies.add(J)}const N=z?[R,z]:[R];for(const O of N){const F=n.name?O===n.name||O.startsWith(`${n.name}/`):!1;if(aE.test(O)||Tt(O)||(w?.test(O)??!1)||F)return S.set(k,!1),!1;if(fn(O)||mc.has(O)){let I=a.builtins;return I===void 0&&P&&(I=h(P)&&!y(P)),S.set(k,I),I}if(O[0]==="#"&&!O.startsWith("#/"))return S.set(k,!1),!1;if(h(O)&&!y(O))return S.set(k,!0),!0;if($.some(I=>I.test(O))||J&&c(J))return S.set(k,!1),!1}return e.implicitDependencies.add(R),uE(R,e.logger),S.set(k,!1),!1}},"options"),resolveId:{filter:{id:Be(x=>!x.startsWith("\0"),"id")},async handler(x,E,j){if(j.isEntry)return;if(x[0]==="#"&&!x.startsWith("#/")&&n.imports)return E&&!Uo(E,e.options.rootDir)?{external:!0,id:x}:void 0;if(mc.has(x))return{external:!0,id:x,moduleSideEffects:!1};if(fn(x)){const R=x.replace(lE,"");let P=R;return(a.builtinsPrefix==="add"||!fn(R))&&(P=`node:${R}`),{external:(a.builtins??h(x))&&!y(x),id:a.builtinsPrefix==="ignore"?x:P,moduleSideEffects:!1}}if(!Tr(x)||x.includes("?")||x.includes(" "))return;const[k]=gi(x);if(s.has(k)&&!o.has(k)){if(h(x)&&!y(x))return;if(t?.forTypes)return t.dtsResolve&&c(k)?void 0:{external:!0,id:x,moduleSideEffects:!1};const R=await this.resolve(x,E,{skipSelf:!0,...j});if(!R)throw new Error(`Could not resolve "${x}" even though it's declared in package.json. Try re-installing node_modules.`);if(t?.forTypes){const P=hc(k);o.has(P)&&!b.has(P)&&(b.add(P),e.logger.warn(`Recommendation: "${P}" is externalized but "${k}" is bundled (devDependencies). This may cause type mismatches for consumers. Consider moving "${k}" to dependencies or "${P}" to devDependencies.`))}return R}if(o.has(k)){if(t?.forTypes){const R=hc(k);s.has(R)&&!b.has(R)&&(b.add(R),e.logger.warn(`Recommendation: "${R}" is bundled (devDependencies) but "${k}" is externalized. Place "${R}" in dependencies/peerDependencies as well so users don't have missing types.`))}return}if(!s.has(k)&&E&&!Uo(E,r)&&!t?.skipUnlistedWarnings&&!v.has(k)&&(v.add(k),e.logger.warn(`"${k}" imported by "${E}" but not declared in package.json. Will be bundled to prevent failure at runtime.`)),t?.forTypes&&E&&Xm(E,r))return{external:!0,id:x,moduleSideEffects:!1}},order:"pre"}}},"externalsPlugin");var hE=Object.defineProperty,gE=(e,t)=>hE(e,"name",{value:t,configurable:!0}),yE=Object.defineProperty,gc=gE((e,t)=>yE(e,"name",{value:t,configurable:!0}),"p");const Gs="\0packem-import-attribute/",$E=/(import[\w$*{},\s]*?from\s*["'])([^"']+)(["'])\s*with\s*\{\s*type\s*:\s*["'](text|bytes)["']\s*\}/g,bE=/(\bimport\s*\(\s*["'])([^"']+)["']\s*,\s*\{\s*with\s*:\s*\{\s*type\s*:\s*["'](text|bytes)["']\s*\}\s*\}\s*\)/g,wE=/\.[mc]?[jt]sx?$/,vE=gc(()=>{const e=new Map;let t=0;const r=gc(n=>{const o=`${Gs}${String(t)}`;return t+=1,e.set(o,n),o},"allocateId");return{buildStart(){e.clear(),t=0},async load(n){const o=e.get(n);if(!o)return null;const{importer:s,source:i,type:a}=o;if(!i.startsWith("./")&&!i.startsWith("../")&&!i.startsWith("/"))return null;const l=i.startsWith("/")?i:uh(yi(s),i);if(this.addWatchFile(l),a==="text"){const u=await Hn(l,"utf8");return`export default ${JSON.stringify(u)}`}return`export default new Uint8Array([${(await Hn(l)).join(",")}])`},name:"packem:import-attributes",resolveId(n,o){return n.startsWith(Gs)&&e.has(n)?n:null},transform(n,o){const s=o.split("?")[0]??o;if(s.startsWith(Gs)||!wE.test(s)||!n.includes("with")||!n.includes("type")||!n.includes("text")&&!n.includes("bytes"))return null;const i=n.replaceAll($E,(a,l,u,c,p)=>{const f=r({importer:o,source:u,type:p});return`${l}${f}${c}`}).replaceAll(bE,(a,l,u,c)=>{const p=r({importer:o,source:u,type:c});return`${l}${p}")`});return i===n?null:{code:i,map:null}}}},"importAttributesPlugin");var xE=Object.defineProperty,cd=(e,t)=>xE(e,"name",{value:t,configurable:!0}),EE=Object.defineProperty,or=cd((e,t)=>EE(e,"name",{value:t,configurable:!0}),"a");const SE=or(e=>{const t=[],r=[];e.forEach(o=>{o.startsWith("(")?t.push(o):r.push(o)});const n=or((o,s)=>o.localeCompare(s),"byLocale");return[...r.toSorted(n),...t.toSorted(n)]},"sortLicenses"),kE=or((e,t,r)=>{const n=new Set;for(const o of[e,...t,...r]){const s=typeof o=="string"?o:o?.name;s&&n.add(s)}return[...n]},"collectAuthorNames");function wa(e){return e?`> ${e}`:">"}cd(wa,"P");or(wa,"prefixQuoteMarker");const jE=or((e,t,r)=>e.trim().replaceAll(/\r\n|\r/g,`
|
|
78
|
+
`).replaceAll(`<!-- ${t} -->`,"").replaceAll(r?`<!-- ${r} -->`:"","").replaceAll(`<!-- /${t} -->`,"").replaceAll(r?`<!-- /${r} -->`:"","").trim().split(`
|
|
79
|
+
`).map(n=>wa(n)).join(`
|
|
80
|
+
`),"formatLicenseBody"),ud=or(({dtsMarker:e,licenseFilePath:t,licenseTemplate:r,logger:n,marker:o,mode:s,packageName:i})=>Eh({thirdParty(a){const l=new Set,u=a.toSorted(({name:p},{name:f})=>{const d=p??"",m=f??"";return d.localeCompare(m)}).map(({author:p,contributors:f,license:d,licenseText:m,maintainers:h,name:y,repository:$})=>{let g=`## ${y??""}
|
|
81
|
+
`;d&&(g+=`License: ${d}
|
|
82
|
+
`);const w=kE(p,h,f);return w.length>0&&(g+=`By: ${w.join(", ")}
|
|
83
|
+
`),$&&(g+=`Repository: ${typeof $=="string"?$:$.url}
|
|
84
|
+
`),m&&(g+=`
|
|
85
|
+
${jE(m,o,e)}
|
|
86
|
+
`),d&&l.add(d),g}).join(`
|
|
87
|
+
---------------------------------------
|
|
88
|
+
|
|
89
|
+
`);if(u===""){n.info({message:"No dependencies license information found.",prefix:`plugin:license:${s}`});return}const c=r(SE(l),u,i);try{const p=Mu(t),f=Qm(p,o,c);if(!f){n.error({message:`Could not find the license marker: <!-- ${o} --><!-- /${o} --> in ${t}`,prefix:`plugin:license:${s}`});return}p!==f&&(Cm(t,f),n.info({message:`${t} updated.`,prefix:`plugin:license:${s}`}))}catch(p){n.error(p)}}}),"licensePlugin");var AE=Object.defineProperty,an=(e,t)=>AE(e,"name",{value:t,configurable:!0});let Dt;const Gt={getHeadTemplatePart(e){const t=e.getFullText(Dt),r=t.indexOf("`")+1,n=it.isTemplateHead(e)?-2:-1;return{end:e.end+n,start:e.pos+r,text:t.slice(r,t.length+n)}},getMiddleTailTemplatePart(e){const t=e.getText(Dt),r=it.isTemplateMiddle(e)?2:1;return{end:e.end-r,start:e.getStart(Dt)+1,text:t.slice(1,t.length-r)}},getRootNode(e,t=""){return it.createSourceFile(t,e,it.ScriptTarget.ESNext)},getTaggedTemplateTemplate(e){return e.template},getTagText(e){return e.tag.getText(Dt)},getTemplateParts(e){return it.isNoSubstitutionTemplateLiteral(e)?[Gt.getHeadTemplatePart(e)]:[Gt.getHeadTemplatePart(e.head),...e.templateSpans.map(t=>Gt.getMiddleTailTemplatePart(t.literal))]},isTaggedTemplate:it.isTaggedTemplateExpression,isTemplate:it.isTemplateLiteral,walkChildNodes(e,t){t(e),it.forEachChild(e,r=>{Gt.walkChildNodes(r,t)})},walkNodes(e,t){Dt=e,Gt.walkChildNodes(e,t),Dt=void 0}};var OE=Object.defineProperty,RE=an((e,t)=>OE(e,"name",{value:t,configurable:!0}),"i");const CE=RE((e,t={})=>{const r={...Gt,...t.strategy},n=[],o=[];return r.walkNodes(r.getRootNode(e,t.fileName),s=>{if(r.isTaggedTemplate(s)){const i=r.getTaggedTemplateTemplate(s);o.push(i),n.push({parts:r.getTemplateParts(i),tag:r.getTagText(s)})}else r.isTemplate(s)&&!o.includes(s)&&n.push({parts:r.getTemplateParts(s)})}),n},"parseLiterals");var TE=Object.defineProperty,va=an((e,t)=>TE(e,"name",{value:t,configurable:!0}),"c");const Qt={One:"1",Two:"2",Zero:"0"},NE=va(e=>{const t={[Qt.One]:{tidySelectors:!1,transform:void 0},[Qt.Two]:{tidySelectors:!1,transform:void 0},[Qt.Zero]:{}};if(e===void 0)return t;if(typeof e=="number"){const r=e.toString();return{...t,[r]:{...t[r]}}}return e},"optimizationLevelFrom"),PE=/(:[^()\s]+\(([^()]*)\))\s*\{/g,ME=/\s/g,_E=/\s/,yc=va((e,t)=>{let r=t;const n=[...e.matchAll(PE)];for(const o of n){const s=o[1],i=o[2];if(!s||!i||!_E.test(i))continue;const a=i.replaceAll(ME,""),l=s.replace(i,a),u=r.indexOf(l);if(u===-1)continue;const c=u+l.length;r=r.slice(0,Math.max(0,u))+s+r.slice(Math.max(0,c))}return r},"fixCleanCssTidySelectors"),IE={},WE={caseSensitive:!0,collapseWhitespace:!0,decodeEntities:!0,minifyCSS:IE,minifyJS:!0,removeAttributeQuotes:!1,removeComments:!0,removeEmptyAttributes:!0,removeScriptTypeAttributes:!0,removeStyleLinkTypeAttributes:!0,useShortDoctype:!0},$c=va((e={})=>{const t=NE(e.level),r=typeof e.level=="object"&&typeof e.level[1]?.transform=="function"?e.level[1].transform:!1;return t[Qt.One].transform=(n,o)=>o.startsWith("@TEMPLATE_EXPRESSION")&&!o.endsWith(";")?`${o};`:r?r(n,o):o,{...e,level:t}},"adjustMinifyCSSOptions"),BE={combineHTMLStrings(e,t){return e.map(r=>r.text).join(t)},getPlaceholder(e){let t="@TEMPLATE_EXPRESSION";for(;e.some(r=>r.text.includes(t+"();"));)t+="_";return t+"();"},minifyCSS(e,t={}){const r=$c(t),n=new Sh(r).minify(e);if(n.errors.length>0)throw new Error(n.errors.join(`
|
|
90
|
+
|
|
91
|
+
`));return r.level?.[Qt.One]?.tidySelectors&&(n.styles=yc(e,n.styles)),n.styles},async minifyHTML(e,t={}){let r;t.minifyCSS?r=t.minifyCSS!==!0&&typeof t.minifyCSS!="function"?{...t.minifyCSS}:{}:r=!1;let n=!1;r&&(n=$c(r));let o=await kh(e,{...t,minifyCSS:n});if(t.collapseWhitespace){const s=[...o.matchAll(/<svg/g)].toReversed();for(const i of s){const a=i.index,l=o.indexOf("</svg",a);if(l===-1)continue;const u=o.slice(0,Math.max(0,a));let c=o.slice(a,l);const p=o.slice(Math.max(0,l));c=c.replaceAll(/\r?\n/g,""),o=u+c+p}}return(n?n.level:void 0)?.[Qt.One]?.tidySelectors&&(o=yc(e,o)),o},splitHTMLByPlaceholder(e,t){const r=e.split(t);if(t.endsWith(";")){const n=t.slice(0,Math.max(0,t.length-1));for(let o=r.length-1;o>=0;o-=1){const s=r[o];s!==void 0&&r.splice(o,1,...s.split(n))}}return r}};var DE=Object.defineProperty,Io=an((e,t)=>DE(e,"name",{value:t,configurable:!0}),"f");const LE=Io((e,t)=>e.generateMap({file:`${t}.map`,hires:!0,source:t}),"defaultGenerateSourceMap"),FE=Io(e=>{const t=e.tag?.toLowerCase();return!!t&&(t.includes("html")||t.includes("svg"))},"defaultShouldMinify"),HE=Io(e=>!!e.tag&&e.tag.toLowerCase().includes("css"),"defaultShouldMinifyCSS"),qE={ensureHTMLPartsValid(e,t){if(e.length!==t.length)throw new Error("splitHTMLByPlaceholder() must return same number of strings as template parts")},ensurePlaceholderValid(e){if(typeof e!="string"||e.length===0)throw new Error("getPlaceholder() must return a non-empty string")}};async function xa(e,t={}){t.minifyOptions={...WE,...t.minifyOptions},t.MagicString??=Ee,t.parseLiterals??=CE,t.shouldMinify??=FE,t.shouldMinifyCSS??=HE,t.parseLiteralsOptions={fileName:t.fileName,...t.parseLiteralsOptions};const r=t.parseLiterals(e,t.parseLiteralsOptions),n=t.strategy??BE,{shouldMinify:o,shouldMinifyCSS:s}=t;let i;t.validate!==!1&&(i=t.validate??qE);const a=new t.MagicString(e);for(const c of r){const p=o(c),f=!!n.minifyCSS&&s(c);if(p||f){const d=n.getPlaceholder(c.parts);i&&i.ensurePlaceholderValid(d);const m=n.combineHTMLStrings(c.parts,d);let h;if(f){const $=t.minifyOptions?.minifyCSS;if(typeof $=="function"){const g=$(m);h=typeof g=="string"?g:await g}else if($===!1)h=m;else{const g=typeof $=="object"&&$!==null?$:void 0,w=n.minifyCSS;if(!w)throw new Error("Strategy does not implement minifyCSS but minifyCSS was requested");const b=w(m,g);h=typeof b=="string"?b:await b}}else{const $=n.minifyHTML(m,t.minifyOptions);h=typeof $=="string"?$:await $}const y=n.splitHTMLByPlaceholder(h,d);i&&i.ensureHTMLPartsValid(c.parts,y),c.parts.forEach(($,g)=>{$.start<$.end&&y[g]!==void 0&&a.overwrite($.start,$.end,y[g])})}}const l=a.toString();if(e===l)return;let u;return t.generateSourceMap!==!1&&(u=(t.generateSourceMap??LE)(a,t.fileName??"")),{code:l,map:u}}an(xa,"minifyHTMLLiterals");Io(xa,"minifyHTMLLiterals");var JE=Object.defineProperty,zE=an((e,t)=>JE(e,"name",{value:t,configurable:!0}),"o");const UE=zE(({exclude:e,failOnError:t=!1,include:r,logger:n,minifyHTMLLiterals:o,options:s})=>{o??=xa;const i=Ze(r,e),a=s??{};return{name:"packem:minify-html-literals",async transform(l,u){if(!(!l.includes("html`")&&!l.includes("css`"))&&i(u))try{return await o(l,{...a,fileName:u})}catch(c){const p=c instanceof Error?c.message:c;t?this.error(p):n.warn({message:p,prefix:"plugin:minify-html-literals"})}}}},"minifyHTMLLiteralsPlugin");var GE=Object.defineProperty,VE=(e,t)=>GE(e,"name",{value:t,configurable:!0}),KE=Object.defineProperty,bc=VE((e,t)=>KE(e,"name",{value:t,configurable:!0}),"f");const YE=/\.node$/,Vs="\0packem-natives/",XE=bc((e={})=>{const{nativesDirectory:t="natives"}=e,r=new Map;let n=0;return{buildStart(){r.clear(),n=0},generateBundle:bc(async o=>{if(r.size===0)return;let s;if(o.dir?s=o.dir:o.file&&(s=Z(o.file)),!s)throw new Error("Output directory not detected. Please ensure Rollup output options are configured.");const i=G(s,t);await mi(i);const a=new Set,l=[];for(const{outputName:u,sourcePath:c}of r.values())a.has(c)||(a.add(c),l.push(mh(c,G(i,u))));await Promise.all(l)},"generateBundle"),load(o){const s=r.get(o);if(!s)return;const{outputName:i}=s;return`export default require("${`./${t}/${i}`.replaceAll("\\","/")}");`},name:"native-modules",resolveId:{filter:{id:YE},async handler(o,s){if(o.startsWith(Vs))return;if(s?.startsWith(Vs))return{external:!0,id:o};const i=s?X(Z(s),o):X(o);if(!await Xt(i)){this.warn(`Native module not found: ${i}`);return}for(const[f,d]of r)if(d.sourcePath===i)return f;const a=Fe(i);let l=a,u=1;const c=new Set(Array.from(r.values(),f=>f.outputName));for(;c.has(l);){const f=tr(a);l=`${Fe(a,f)}_${String(u)}${f}`,u+=1}const p=`${Vs}${String(n)}`;return n+=1,r.set(p,{outputName:l,sourcePath:i}),p}}}},"nativeModulesPlugin");var ZE=Object.defineProperty,QE=(e,t)=>ZE(e,"name",{value:t,configurable:!0}),eS=Object.defineProperty,tS=QE((e,t)=>eS(e,"name",{value:t,configurable:!0}),"a");const rS=tS(e=>{const t=Ze(e.include,e.exclude);return{async load(r){if(r.includes("?raw")){const n=r.split("?")[0];try{const o=await Nt(n);return process.platform==="win32"?o.replaceAll(`\r
|
|
92
|
+
`,`
|
|
93
|
+
`):o}catch(o){this.error(`Failed to read file: ${n}: ${o instanceof Error?o.message:String(o)}`)}}return null},name:"packem:raw",transform(r,n){const o=n.includes("?raw"),s=o?n.split("?")[0]:n;if(t(s)||o){const i=process.platform==="win32"?r.replaceAll(`\r
|
|
94
|
+
`,`
|
|
95
|
+
`):r;return{code:`const data = ${JSON.stringify(i)};
|
|
96
|
+
export default data;`,map:null}}return null}}},"rawPlugin");var nS=Object.defineProperty,pd=(e,t)=>nS(e,"name",{value:t,configurable:!0}),oS=Object.defineProperty,fd=pd((e,t)=>oS(e,"name",{value:t,configurable:!0}),"a");let wc=!1;const dd=new Map,sS=fd(()=>{dd.clear()},"clearPureCjsCache"),iS=fd(async(e,t,r)=>{if(wc||(await tp(),wc=!0),e.startsWith("node:"))return!1;if(e.endsWith(".cjs"))return!0;if(e.endsWith(".js")||!e.includes("/")&&!e.startsWith(".")){let n;if(r)try{n=(await r(e,t))?.id}catch{}if(!n&&t&&!t.includes("!~{"))try{n=_e(t).resolve(e)}catch{}if(n){try{const{packageJson:o}=await Tm(n,{cache:dd});if(o.type==="module")return!1;if(o.type==="commonjs")return!0}catch{}try{const o=await Nt(n,{encoding:"utf8"});try{return jh(o,n),!0}catch{}}catch{}}}return!1},"isPureCJS");var aS=Object.defineProperty,dr=pd((e,t)=>aS(e,"name",{value:t,configurable:!0}),"d");const Ea="__cjs_require",lS='import { createRequire as __cjs_createRequire } from "node:module";',cS=`const ${Ea} = __cjs_createRequire(import.meta.url);`,uS='const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;',pS=`const __cjs_getBuiltinModule = (module) => {
|
|
97
|
+
// Check if we're in Node.js and version supports getBuiltinModule
|
|
98
|
+
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
99
|
+
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
100
|
+
// Node.js 20.16.0+ and 22.3.0+
|
|
101
|
+
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
102
|
+
return __cjs_getProcess.getBuiltinModule(module);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// Fallback to createRequire
|
|
106
|
+
return ${Ea}(module);
|
|
107
|
+
};`,$n={builtin:/const\s+__cjs_getBuiltinModule\s*=\s*\(module\)\s*=>\s*\{[\s\S]*?\};\s*/g,import:/import\s*\{\s*createRequire(?:\s+as\s+__cjs_createRequire)?\s*\}\s*from\s*["']node:module["'];?\s*/g,process:/const\s+__cjs_getProcess\s*=\s*typeof\s+globalThis[^;]*;\s*/g,require:/const\s+__cjs_require\s*=\s*(?:__cjs_)?createRequire(?:\$\w+)?\s*\([^)]*\);\s*/g},fS=[/node_modules/,/\.d\.[cm]?ts$/],dS=[/\.[cm]?[jt]sx?$/];let vc=!1;const mS=dr((e,t)=>t&&(um.includes(e)||e.startsWith("node:")),"isBuiltinModule"),hS=dr(async(e,t,r,n,o)=>t?!0:await r?.(e,n,o)??await iS(e,n,o),"shouldTransformImport"),gS=dr((e,t)=>t?e==="process"||e==="node:process"?{code:"__cjs_getProcess",needsBuiltin:!1,needsProcess:!0,needsRequire:!0}:{code:`__cjs_getBuiltinModule(${JSON.stringify(e)})`,needsBuiltin:!0,needsProcess:!0,needsRequire:!0}:{code:`${Ea}(${JSON.stringify(e)})`,needsBuiltin:!1,needsProcess:!1,needsRequire:!0},"generateRequireCode"),yS=dr(e=>{const t=new Ee(e),r={builtin:[...e.matchAll($n.builtin)],import:[...e.matchAll($n.import)],process:[...e.matchAll($n.process)],require:[...e.matchAll($n.require)]};return Object.values(r).forEach(n=>{if(n.length>1)for(let o=n.length-1;o>0;o-=1){const s=n[o];s&&t.remove(s.index,s.index+s[0].length)}}),t.toString()},"removeDuplicates"),$S=dr(e=>{if(Array.isArray(e.shouldTransform)){const{shouldTransform:t}=e;e.shouldTransform=r=>t.includes(r)}return{builtinNodeModules:!!e.builtinNodeModules,cwd:e.cwd??ut.cwd(),exclude:e.exclude??fS,include:e.include??dS,order:"order"in e?e.order:"pre",shouldTransform:e.shouldTransform}},"resolveOptions"),bS=dr((e,t)=>{if(ut.env.INTERNAL_PACKEM_BUILD)return{name:"require-cjs-transformer"};const{builtinNodeModules:r,cwd:n,exclude:o,include:s,order:i,shouldTransform:a}=$S(e),l=Ze(s,o);return{async buildStart(){sS(),vc||(await tp(),vc=!0)},name:"packem:plugin-require-cjs",renderChunk:{async handler(u,c,p){if(p.format!=="es"||!l(c.fileName))return;const f=mo(c.fileName,u,{astType:"js",lang:"js",sourceType:"module"}),d=new Ee(u);let m=!1,h=!1,y=!1;for(const g of f.program.body){if(g.type!=="ImportDeclaration"||g.importKind==="type")continue;const w=g.source.value,b=mS(w,r),v=this.resolve;if(!await hS(w,b,a,n,v))continue;const{code:S,needsBuiltin:x,needsProcess:E,needsRequire:j}=gS(w,b);if(m||=j,h||=E,y||=x,g.specifiers.length===0){b?d.remove(g.start,g.end):d.overwrite(g.start,g.end,`${S};`);continue}const k=[];let R,P;for(const U of g.specifiers)if(U.type==="ImportNamespaceSpecifier")R=U.local.name;else if(U.type==="ImportSpecifier"&&U.importKind!=="type"){const J=u.slice(U.imported.start,U.imported.end);k.push([J,U.local.name])}else U.type==="ImportDefaultSpecifier"&&(P=U.local.name);const z=[];if(R&&(P??=`_cjs_${R}_default`),P&&z.push(`const ${P} = ${S};`),R&&z.push(`const ${R} = { ...${P??""}, default: ${P??""} };`),k.length>0){const U=`const {
|
|
108
|
+
${k.map(([J,N])=>` ${J===N?N:`${J}: ${N}`}`).join(`,
|
|
109
|
+
`)}
|
|
110
|
+
} = ${P??S};`;z.push(U)}d.overwrite(g.start,g.end,z.join(`
|
|
111
|
+
`))}if(m||h||y){const g=[];m&&g.push(lS,cS),h&&g.push(uS),y&&g.push(pS);const w=`${g.join(`
|
|
112
|
+
|
|
113
|
+
`)}
|
|
114
|
+
|
|
115
|
+
`,b=d.toString();if(b[0]==="#"){const v=b.indexOf(`
|
|
116
|
+
`)+1;d.appendLeft(v,w)}else d.prepend(w)}const $=new Ee(yS(d.toString()));return{code:$.toString(),map:$.generateMap()}},order:i}}},"requireCJSTransformerPlugin");var wS=Object.defineProperty,vS=(e,t)=>wS(e,"name",{value:t,configurable:!0}),xS=Object.defineProperty,eo=vS((e,t)=>xS(e,"name",{value:t,configurable:!0}),"l");const xc=/\bfrom\s+['"`]([^'"`]+)['"`]/g,ES=/[/\\]node_modules[/\\]/,SS=/^\0/,kS=eo(async e=>{try{const n=await Qr(e);if(n.isFile())return e;if(n.isDirectory()){const o=G(e,"index.js");if(await Xt(o))return o;const s=G(e,"index.json");if(await Xt(s))return s}}catch{}const t=`${e}.js`;if(await Xt(t))return t;const r=`${e}.json`;if(await Xt(r))return r},"tryResolveImplicit"),jS=eo(async(e,t)=>{let r=e;const n=X("/");for(;r!==n&&r!==Z(r);){const o=G(r,"node_modules",t,"package.json");if(await Xt(o))return o;r=Z(r)}},"findPackageJson"),md=eo(e=>{const t=new Map,r=new Map,n=new Set;e.pkg.dependencies&&Object.keys(e.pkg.dependencies).forEach(s=>n.add(s)),e.pkg.peerDependencies&&Object.keys(e.pkg.peerDependencies).forEach(s=>n.add(s)),e.pkg.optionalDependencies&&Object.keys(e.pkg.optionalDependencies).forEach(s=>n.add(s));const o=eo(s=>n.has(s),"isExternalPackage");return{name:"packem:resolve-implicit-externals",transform:{filter:{id:{exclude:[SS,ES]}},async handler(s,i){if(i.includes("/node_modules/")||i.startsWith("\0"))return;const a=[];let l;for(xc.lastIndex=0;(l=xc.exec(s))!==null;){const f=l[1];if(!f||!Tr(f))continue;const[d,m]=gi(f);if(m&&d&&o(d)){const h=l.index+l[0].indexOf(f);a.push({importId:f,quoteEnd:h+f.length,quoteStart:h})}}if(a.length===0)return;const u=Z(i),c=(await Promise.all(a.map(async f=>{const[d,m]=gi(f.importId);if(!m)return;const h=`${d}:${m}:${u}`,y=r.get(h);if(y!==void 0)return y?{...f,resolvedId:y}:void 0;const $=await jS(u,d);if(!$){r.set(h,void 0);return}let g=t.get($);if(g===void 0)try{g=Nm($,{resolveCatalogs:!0}),t.set($,g)}catch{t.set($,void 0),r.set(h,void 0);return}if(g.exports){r.set(h,void 0);return}const w=Z($),b=G(w,m),v=await kS(b);if(!v){r.set(h,void 0);return}const S=Se(w,v),x=`${d}/${S}`;return r.set(h,x),{...f,resolvedId:x}}))).filter(f=>f!==void 0);if(c.length===0)return;const p=new Ee(s);for(const{quoteEnd:f,quoteStart:d,resolvedId:m}of c)p.overwrite(d,f,m),this.debug(`[resolve-implicit-externals] Rewriting ${s.slice(d,f)} -> ${m} in ${i}`);return{code:p.toString(),map:p.generateMap({hires:!0})}}}}},"resolveImplicitExternalsPlugin");var AS=Object.defineProperty,OS=(e,t)=>AS(e,"name",{value:t,configurable:!0}),RS=Object.defineProperty,Wo=OS((e,t)=>RS(e,"name",{value:t,configurable:!0}),"o");const to=/^#![^\n]*/,Ni=Wo(async e=>{await Ku(e,493).catch(()=>{})},"makeExecutable"),CS=Wo((e,t)=>({name:"packem:shebang",renderChunk:{handler(r,n,o){if(!n.isEntry||!n.facadeModuleId)return;const s=r.startsWith("#")&&r[1]==="!";if(s&&t.replace)return{code:r.replace(to,`${t.shebang}
|
|
117
|
+
`),map:void 0};if(!s&&e.includes(n.name)){const i=new Ee(r);return i.prepend(`${t.shebang}
|
|
118
|
+
`),{code:i.toString(),map:o.sourcemap?i.generateMap({hires:!0}):void 0}}},order:"post"},async writeBundle(r,n){for(const[o,s]of Object.entries(n))if(s.type==="chunk"&&to.test(s.code)&&r.dir){const i=X(r.dir,o);await Ni(i)}}}),"shebangPlugin"),TS=Wo(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(to,"")}}),"removeShebangPlugin"),NS=Wo((e,t=`
|
|
119
|
+
`)=>{const r=to.exec(e);return r?`${r[0]}${t}`:""},"getShebang");var PS=44,Ec="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",MS=new Uint8Array(64),hd=new Uint8Array(128);for(let e=0;e<Ec.length;e++){const t=Ec.charCodeAt(e);MS[e]=t,hd[t]=e}function Or(e,t){let r=0,n=0,o=0;do{const i=e.next();o=hd[i],r|=(o&31)<<n,n+=5}while(o&32);const s=r&1;return r>>>=1,s&&(r=-2147483648|-r),t+r}function Sc(e,t){return e.pos>=t?!1:e.peek()!==PS}typeof TextDecoder<"u"?new TextDecoder:typeof Buffer<"u";var _S=class{constructor(t){this.pos=0,this.buffer=t}next(){return this.buffer.charCodeAt(this.pos++)}peek(){return this.buffer.charCodeAt(this.pos)}indexOf(t){const{buffer:r,pos:n}=this,o=r.indexOf(t,n);return o===-1?r.length:o}};function IS(e){const{length:t}=e,r=new _S(e),n=[];let o=0,s=0,i=0,a=0,l=0;do{const u=r.indexOf(";"),c=[];let p=!0,f=0;for(o=0;r.pos<u;){let d;o=Or(r,o),o<f&&(p=!1),f=o,Sc(r,u)?(s=Or(r,s),i=Or(r,i),a=Or(r,a),Sc(r,u)?(l=Or(r,l),d=[o,s,i,a,l]):d=[o,s,i,a]):d=[o],c.push(d),r.pos++}p||WS(c),n.push(c),r.pos=u+1}while(r.pos<=t);return n}function WS(e){e.sort(BS)}function BS(e,t){return e[0]-t[0]}var In={exports:{}},DS=In.exports,kc;function LS(){return kc||(kc=1,(function(e,t){(function(r,n){e.exports=n()})(DS,(function(){const r=/^[\w+.-]+:\/\//,n=/^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/,o=/^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;function s(g){return r.test(g)}function i(g){return g.startsWith("//")}function a(g){return g.startsWith("/")}function l(g){return g.startsWith("file:")}function u(g){return/^[.?#]/.test(g)}function c(g){const w=n.exec(g);return f(w[1],w[2]||"",w[3],w[4]||"",w[5]||"/",w[6]||"",w[7]||"")}function p(g){const w=o.exec(g),b=w[2];return f("file:","",w[1]||"","",a(b)?b:"/"+b,w[3]||"",w[4]||"")}function f(g,w,b,v,S,x,E){return{scheme:g,user:w,host:b,port:v,path:S,query:x,hash:E,type:7}}function d(g){if(i(g)){const b=c("http:"+g);return b.scheme="",b.type=6,b}if(a(g)){const b=c("http://foo.com"+g);return b.scheme="",b.host="",b.type=5,b}if(l(g))return p(g);if(s(g))return c(g);const w=c("http://foo.com/"+g);return w.scheme="",w.host="",w.type=g?g.startsWith("?")?3:g.startsWith("#")?2:4:1,w}function m(g){if(g.endsWith("/.."))return g;const w=g.lastIndexOf("/");return g.slice(0,w+1)}function h(g,w){y(w,w.type),g.path==="/"?g.path=w.path:g.path=m(w.path)+g.path}function y(g,w){const b=w<=4,v=g.path.split("/");let S=1,x=0,E=!1;for(let k=1;k<v.length;k++){const R=v[k];if(!R){E=!0;continue}if(E=!1,R!=="."){if(R===".."){x?(E=!0,x--,S--):b&&(v[S++]=R);continue}v[S++]=R,x++}}let j="";for(let k=1;k<S;k++)j+="/"+v[k];(!j||E&&!j.endsWith("/.."))&&(j+="/"),g.path=j}function $(g,w){if(!g&&!w)return"";const b=d(g);let v=b.type;if(w&&v!==7){const x=d(w),E=x.type;switch(v){case 1:b.hash=x.hash;case 2:b.query=x.query;case 3:case 4:h(b,x);case 5:b.user=x.user,b.host=x.host,b.port=x.port;case 6:b.scheme=x.scheme}E>v&&(v=E)}y(b,v);const S=b.query+b.hash;switch(v){case 2:case 3:return S;case 4:{const x=b.path.slice(1);return x?u(w||g)&&!u(x)?"./"+x+S:x+S:S||"."}case 5:return b.path+S;default:return b.scheme+"//"+b.user+b.host+b.port+b.path+S}}return $}))})(In)),In.exports}var FS=LS();const HS=Zr(FS);function qS(e){if(!e)return"";const t=e.lastIndexOf("/");return e.slice(0,t+1)}function JS(e,t){const r=qS(e),n=t?t+"/":"";return o=>HS(n+(o||""),r)}var Vr=0,zS=1,US=2,GS=3,VS=4;function KS(e,t){const r=jc(e,0);if(r===e.length)return e;t||(e=e.slice());for(let n=r;n<e.length;n=jc(e,n+1))e[n]=XS(e[n],t);return e}function jc(e,t){for(let r=t;r<e.length;r++)if(!YS(e[r]))return r;return e.length}function YS(e){for(let t=1;t<e.length;t++)if(e[t][Vr]<e[t-1][Vr])return!1;return!0}function XS(e,t){return t||(e=e.slice()),e.sort(ZS)}function ZS(e,t){return e[Vr]-t[Vr]}function QS(){return{lastKey:-1,lastNeedle:-1,lastIndex:-1}}function Sa(e){return typeof e=="string"?JSON.parse(e):e}var ek=function(e,t){const r=Sa(e);if(!("sections"in r))return new ka(r,t);const n=[],o=[],s=[],i=[],a=[];gd(r,t,n,o,s,i,a,0,0,1/0,1/0);const l={version:3,file:r.file,names:i,sources:o,sourcesContent:s,mappings:n,ignoreList:a};return ok(l)};function gd(e,t,r,n,o,s,i,a,l,u,c){const{sections:p}=e;for(let f=0;f<p.length;f++){const{map:d,offset:m}=p[f];let h=u,y=c;if(f+1<p.length){const $=p[f+1].offset;h=Math.min(u,a+$.line),h===u?y=Math.min(c,l+$.column):h<u&&(y=l+$.column)}tk(d,t,r,n,o,s,i,a+m.line,l+m.column,h,y)}}function tk(e,t,r,n,o,s,i,a,l,u,c){const p=Sa(e);if("sections"in p)return gd(...arguments);const f=new ka(p,t),d=n.length,m=s.length,h=nk(f),{resolvedSources:y,sourcesContent:$,ignoreList:g}=f;if(Ks(n,y),Ks(s,f.names),$)Ks(o,$);else for(let w=0;w<y.length;w++)o.push(null);if(g)for(let w=0;w<g.length;w++)i.push(g[w]+d);for(let w=0;w<h.length;w++){const b=a+w;if(b>u)return;const v=rk(r,b),S=w===0?l:0,x=h[w];for(let E=0;E<x.length;E++){const j=x[E],k=S+j[Vr];if(b===u&&k>=c)return;if(j.length===1){v.push([k]);continue}const R=d+j[zS],P=j[US],z=j[GS];v.push(j.length===4?[k,R,P,z]:[k,R,P,z,m+j[VS]])}}}function Ks(e,t){for(let r=0;r<t.length;r++)e.push(t[r])}function rk(e,t){for(let r=e.length;r<=t;r++)e[r]=[];return e[t]}var ka=class{constructor(t,r){const n=typeof t=="string";if(!n&&t._decodedMemo)return t;const o=Sa(t),{version:s,file:i,names:a,sourceRoot:l,sources:u,sourcesContent:c}=o;this.version=s,this.file=i,this.names=a||[],this.sourceRoot=l,this.sources=u,this.sourcesContent=c,this.ignoreList=o.ignoreList||o.x_google_ignoreList||void 0;const p=JS(r,l);this.resolvedSources=u.map(p);const{mappings:f}=o;if(typeof f=="string")this._encoded=f,this._decoded=void 0;else if(Array.isArray(f))this._encoded=void 0,this._decoded=KS(f,n);else throw o.sections?new Error("TraceMap passed sectioned source map, please use FlattenMap export instead"):new Error(`invalid source map: ${JSON.stringify(o)}`);this._decodedMemo=QS(),this._bySources=void 0,this._bySourceMemos=void 0}};function nk(e){var t;return(t=e)._decoded||(t._decoded=IS(e._encoded))}function ok(e,t){const r=new ka(sk(e,[]),t);return r._decoded=e.mappings,r}function sk(e,t){return{version:e.version,file:e.file,names:e.names,sourceRoot:e.sourceRoot,sources:e.sources,sourcesContent:e.sourcesContent,mappings:t,ignoreList:e.ignoreList||e.x_google_ignoreList}}var ik=Object.defineProperty,yd=(e,t)=>ik(e,"name",{value:t,configurable:!0});const ak=_e(import.meta.url),Rr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$d=yd(e=>{if(typeof Rr<"u"&&Rr.versions&&Rr.versions.node){const[t,r]=Rr.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return Rr.getBuiltinModule(e)}return ak(e)},"__cjs_getBuiltinModule"),{readFileSync:Ac}=$d("node:fs"),{resolve:lk,toNamespacedPath:Ys,dirname:ck}=$d("node:path");var uk=Object.defineProperty,ln=yd((e,t)=>uk(e,"name",{value:t,configurable:!0}),"s");const pk=/^data:application\/json[^,]+base64,/,fk=/\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+)[ \t]*$|\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*\*\/[ \t]*$/,dk=/\r?\n/,bd=ln(e=>pk.test(e),"isInlineMap"),Xs=ln((e,t)=>{const r=e instanceof Error?e.message:String(e),n=`${t}:
|
|
120
|
+
${r}`;throw new Error(n)},"enhanceError"),mk=ln((e,t)=>{const r=e.split(dk);let n;for(let s=r.length-1;s>=0&&!n;s--)n=fk.exec(r[s])??void 0;if(!n)return;const o=n[1]??n[2];if(o)return bd(o)?o:lk(t,o)},"resolveSourceMapUrl"),hk=ln(e=>{const t=e.slice(e.indexOf(",")+1);return Buffer.from(t,"base64").toString()},"decodeInlineMap"),gk=ln(e=>{let t;try{t=Ac(e,{encoding:"utf8"})}catch(o){Xs(o,`Error reading sourcemap for file "${Ys(e)}"`)}const r=mk(t,ck(e));if(!r)return;let n;if(bd(r))n=hk(r);else try{n=Ac(r,{encoding:"utf8"})}catch(o){Xs(o,`Error reading sourcemap for file "${Ys(e)}"`)}try{return new ek(n,r)}catch(o){Xs(o,`Error parsing sourcemap for file "${Ys(e)}"`)}},"loadSourceMap");var yk=Object.defineProperty,$k=(e,t)=>yk(e,"name",{value:t,configurable:!0}),bk=Object.defineProperty,wk=$k((e,t)=>bk(e,"name",{value:t,configurable:!0}),"s");const vk=/\?[^?]*$/,xk=wk(({exclude:e,include:t}={})=>{const r=Ze(t,e);return{async load(n){if(!r(n))return;let o;try{o=await Nt(n,{buffer:!1}),this.addWatchFile(n)}catch(i){try{const a=n.replace(vk,"");o=await Nt(a,{buffer:!1}),this.addWatchFile(a)}catch{this.warn(`Failed reading file "${n}": ${i instanceof Error?i.message:String(i)}`);return}}if(!o.includes("sourceMappingURL"))return o;let s;try{const i=gk(n);if(i===void 0)return o;s=i}catch(i){return this.warn(`Failed resolving source map for "${n}": ${i instanceof Error?i.message:String(i)}`),{code:o}}return{code:o,map:s}},name:"packem:sourcemaps"}},"sourcemapsPlugin");var Ek=Object.defineProperty,Sk=(e,t)=>Ek(e,"name",{value:t,configurable:!0}),kk=Object.defineProperty,wd=Sk((e,t)=>kk(e,"name",{value:t,configurable:!0}),"g");const jk=wd(async(e,t)=>{await new Promise((r,n)=>{const o=zi(e);o.on("error",n);const s=ah(t);s.on("error",n),s.on("finish",()=>{r(void 0)}),o.pipe(s)})},"copy"),Ak=wd(({destDir:e,emitFiles:t,exclude:r,fileName:n,include:o,limit:s,publicPath:i,sourceDir:a})=>{const l=Ze(o,r),u={};return{async generateBundle(c){if(!t)return;const p=e??c.dir??Z(c.file??"");await mi(p),await Promise.all(Object.keys(u).map(async f=>{const d=u[f],m=G(p,Z(d));await mi(m),await jk(f,G(p,d))}))},async load(c){if(!l(c))return;this.addWatchFile(c);const[p,f]=await Promise.all([Qr(c),Hn(c)]);let d;if(s&&p.size>s||s===0){const m=Ah.createHash("sha1").update(f).digest("hex").slice(0,16),h=tr(c),y=Fe(c,h),$=a?Se(a,Z(c)):Fe(Z(c)),g=n.replaceAll("[hash]",m).replaceAll("[extname]",h).replaceAll("[dirname]",$===""?"":`${$}/`).replaceAll("[name]",y);d=G(i??"",g),u[c]=g}else{const m=Qu.getType(c);if(m===null)throw new Error(`Could not determine mimetype for ${c}`);d=m==="image/svg+xml"?eh(f):f.toString("base64"),d=`data:${m};base64,${d}`}return`export default ${JSON.stringify(d)}`},name:"packem:url"}},"urlPlugin");var Ok=Object.defineProperty,Bo=(e,t)=>Ok(e,"name",{value:t,configurable:!0}),Rk=Object.defineProperty,bt=Bo((e,t)=>Rk(e,"name",{value:t,configurable:!0}),"l");const Ck=/\s/,Tk=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Nk=/MIT License|MIT license|BSD license/,Pk=/\n{2,}/g,Mk=/\b(\w+)\$\d+\b/g,_k=/[-/\\^$*+?.()|[\]{}]/g,Ik=bt(e=>e.replaceAll(_k,String.raw`\$&`),"escapeRegex"),Wk=bt(e=>[...new Set(e)],"unique"),Bk=/\.[^/.]+$/;function ja(e){return Nk.test(e)?"":e}Bo(ja,"k");bt(ja,"stripLicenseComment");const Dk=bt(e=>e.replaceAll(Tk,ja).replaceAll(Pk,`
|
|
121
|
+
|
|
122
|
+
`),"cleanUnnecessaryComments"),Pi=new Map;function Aa(e,t,{identifierReplacements:r},n){const o=fo(e);let s=e;for(const a of Object.keys(r??{})){const l=o.find(c=>c.specifier===a&&c.imports.includes("{"));if(!l)throw new Error(`${t.fileName} does not import "${a}" for replacement`);const u=r?.[a]??{};for(const c of Object.keys(u)){if(!l.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${a}" for replacement`);const p=u[c],f=Ik(c);p.includes(".")&&(s=s.replace(new RegExp(String.raw`\b\w+\b as ${f},?\s?`),"")),s=s.replaceAll(new RegExp(String.raw`\b${f}\b`,"g"),p)}}const i=Wk(Array.from(s.matchAll(Mk),a=>a[0]));if(i.length>0){const a=i.map(u=>`
|
|
123
|
+
- ${u}`).join(""),l=t.fileName.replace(Bk,"");Pi.has(l)||n.warn({message:`${t.fileName} contains confusing identifier names${a}
|
|
124
|
+
|
|
125
|
+
To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Pi.set(l,!0)}return s}Bo(Aa,"O");bt(Aa,"replaceConfusingTypeNames");function Oa(e,t){if(!e.includes("@internal"))return e;const r=new Ee(e),n=mo(t.fileName,e,{lang:"dts",sourceType:"module"}),o=bt(a=>{let l=a,u=!0;for(;u;){for(u=!1;l<e.length&&Ck.test(e[l]);)l+=1;for(const c of n.comments)if(c.start===l){l=c.end,u=!0;break}}return l},"skipPastCommentsAndWhitespace"),s=[];for(const a of n.comments)a.type!=="Block"||!a.value.includes("@internal")||s.push({commentStart:a.start,nextStart:o(a.end)});s.length>0&&Ch(n.program,{enter(a){if(a.type==="Program")return;const{end:l,start:u}=a;if(typeof u!="number"||typeof l!="number")return;const c=s.findIndex(d=>d.nextStart===u);if(c===-1)return;const[{commentStart:p}]=s.splice(c,1),f=e[l]===","?l+1:l;r.remove(p,f),this.skip()}});const i=r.toString();if(i.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`);return i}Bo(Oa,"v");bt(Oa,"stripInternalTypes");const Lk=bt((e,t)=>({buildStart(){Pi.clear()},name:"packem:patch-types",renderChunk(r,n){return r=Aa.call(this,r,n,e,t),r=Oa.call(this,r,n),r=Dk(r),r}}),"patchTypescriptTypes");var Fk=Object.defineProperty,Hk=(e,t)=>Fk(e,"name",{value:t,configurable:!0}),qk=Object.defineProperty,Qe=Hk((e,t)=>qk(e,"name",{value:t,configurable:!0}),"o");const Jk=/^\./,zk=/\0/,Uk=42,Gk=Qe(e=>{let t=!1;for(let r=0;r<e.length;r++)if(e.codePointAt(r)===Uk){if(t)return!1;t=!0}return!0},"hasZeroOrOneAsteriskCharacter"),Vk=Qe(e=>{const t=e.indexOf("*");return t===-1?void 0:{prefix:e.slice(0,t),suffix:e.slice(t+1)}},"tryParsePattern"),Kk=Qe(({prefix:e,suffix:t},r)=>r.length>=e.length+t.length&&r.startsWith(e)&&r.endsWith(t),"isPatternMatch"),Yk=Qe((e,t,r)=>{let n,o=-1;for(const s of e){const i=t(s);Kk(i,r)&&i.prefix.length>o&&(o=i.prefix.length,n=s)}return n},"findBestPatternMatch"),Xk=Qe(e=>{const t=[],r=new Set;for(const n of e){if(!Gk(n))continue;const o=Vk(n);o?t.push(o):r.add(n)}return{exact:r,patterns:t}},"parsePathPatterns"),Zk=Qe((e,t)=>e.exact.has(t)?t:Yk(e.patterns,r=>r,t),"matchPatternOrExact"),Qk=Qe((e,t)=>t.substring(e.prefix.length,t.length-e.suffix.length),"matchedText"),ej=Qe(({prefix:e,suffix:t})=>`${e}*${t}`,"patternText"),tj=Qe((e,t,r)=>{let n=Z(t.path);t.config.compilerOptions?.baseUrl&&(n=X(e,t.config.compilerOptions.baseUrl)),r?.debug({message:`Resolved baseUrl to ${n}`,prefix:"plugin:resolve-tsconfig-paths"});const o=t.config.compilerOptions?.paths??{};return Object.keys(o).length===0&&r?.debug({message:"No paths found in tsconfig.json",prefix:"plugin:resolve-tsconfig-paths"}),{paths:o,resolvedBaseUrl:n}},"getTsconfigPaths"),vd=Qe((e,t,r,n)=>{const{paths:o,resolvedBaseUrl:s}=tj(e,t,r),i=Object.keys(o),a=Xk(i);return{name:"plugin:resolve-tsconfig-paths",resolveId:{filter:{id:{exclude:[Jk,zk]}},async handler(l,u,c){if(i.length===0)return;if(l.includes("\0")){r.debug({message:`Skipping resolution of ${l} as it is a virtual module`,prefix:"plugin:resolve-tsconfig-paths"});return}if(l.includes("node_modules")){r.debug({message:`Skipping request as it is inside node_modules ${l}`,prefix:"plugin:resolve-tsconfig-paths"});return}if(!n.resolveAbsolutePath&&Tt(l)){r.debug({message:`Skipping request as it is an absolute path ${l}`,prefix:"plugin:resolve-tsconfig-paths"});return}if(Cu(l)){r.debug({message:`Skipping request as it is a relative path ${l}`,prefix:"plugin:resolve-tsconfig-paths"});return}const p=Zk(a,l);if(!p){r.debug({message:`moduleName did not match any paths pattern ${l}`,prefix:"plugin:resolve-tsconfig-paths"});return}const f=typeof p=="string"?void 0:Qk(p,l),d=typeof p=="string"?p:ej(p);for(const m of o[d]){const h=f?m.replace("*",f):m;if(h.endsWith(".d.ts")||h.endsWith(".d.cts")||h.endsWith(".d.mts"))continue;const y=G(s,h);try{const $=await this.resolve(y,u,{skipSelf:!0,...c});if($)return $}catch($){r.debug({context:[$],message:`Failed to resolve ${y} from ${l}`,prefix:"plugin:resolve-tsconfig-paths"})}}}}}},"resolveTsconfigPathsPlugin");var rj=Object.defineProperty,nj=(e,t)=>rj(e,"name",{value:t,configurable:!0}),oj=Object.defineProperty,xd=nj((e,t)=>oj(e,"name",{value:t,configurable:!0}),"d");const sj=/^\./,ij=/^\.{1,2}\/?$/,aj=xd((e,t)=>{if(!t)return;const{config:r,path:n}=t;if(!r.compilerOptions)return;const{rootDirs:o}=r.compilerOptions;if(!o)return;const s=Z(n),i=Tt(s)?s:X(e,s),a=[];for(const l of o){if(ij.test(l))throw new Error(`Invalid rootDir value '${l}' in ${n}. Expected a directory path such as "./lib" or "src".`);a.push(Tt(l)?l:X(i,l))}return a},"getRootDirectories"),Ed=xd((e,t,r)=>{const n=aj(e,r);return{name:"packem:resolve-tsconfig-root-dirs",resolveId:{filter:{id:sj},async handler(o,s,i){if(!(n===void 0||n.length===0)&&o.startsWith("."))for(const a of n){const l=G(a,o),u=await this.resolve(l,s,{skipSelf:!0,...i});if(u)return t.debug({message:`Resolved ${o} to ${u.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),u.id}}}}},"resolveTsconfigRootDirectories");var lj=Object.defineProperty,cj=(e,t)=>lj(e,"name",{value:t,configurable:!0}),uj=Object.defineProperty,Ra=cj((e,t)=>uj(e,"name",{value:t,configurable:!0}),"l");const pj={".cjs":[".cts"],".js":[".ts",".tsx"],".jsx":[".tsx",".ts"],".mjs":[".mts"]},Oc=/\.(?:[mc]?js|jsx)$/,fj=Ra(e=>{const t=e[0];return!(t==="."||t==="/"||t==="#"||ph(e))},"isBareSpecifier"),Rc=Ra(async(e,t,r,n,o,s)=>{for(const i of t)try{const a=await e.resolve(r+i,n,o);if(a)return a}catch(a){if(!s)throw a}},"tryRewrites"),Sd=Ra(()=>({name:"packem:resolve-typescript-mjs-cjs",resolveId:{filter:{id:Oc},async handler(e,t,r){if(!t)return;const n=Oc.exec(e);if(!n)return;const o=n[0],s=pj[o];if(!s)return;const i=e.slice(0,-o.length),a={...r,skipSelf:!0};return!fj(e)&&!t.includes("/node_modules/")&&!e.includes("/node_modules/")?Rc(this,s,i,t,a,!1):await this.resolve(e,t,a)||Rc(this,s,i,t,a,!0)}}}),"resolveTypescriptMjsCts");var dj=Object.defineProperty,kd=(e,t)=>dj(e,"name",{value:t,configurable:!0}),mj=Object.defineProperty,gt=kd((e,t)=>mj(e,"name",{value:t,configurable:!0}),"h");const hj=/^export\s+default\s+(\w+);/m,gj=/export\s*\{([^}]*)\}/,yj=/\s*as\s+default\s*/,$j=/\s+\}$/,bn=/;$/,bj=/(?:\r?\n\s*){2,}/g,Zs=/^type\s+/,Cc=/\bas\s+default\b/,wj=gt((e,t,r)=>{const n=bh(e).find(l=>l.names?.includes("default")),o=hj.exec(e);if(o?.[1])return{defaultAlias:o[1],defaultExport:{code:o[0],end:o.index+o[0].length,names:["default"],specifier:void 0,start:o.index,type:"default"},exports:[]};if(!n)return;const s=gj.exec(n.code);if(!s?.length){r.warn?.(`A default export was indicated in ${t.fileName}, but its structure could not be parsed.`);return}let i;const a=[];for(const l of s[1].split(",").map(u=>u.trim())){if(l==="default"){i=l;continue}const u=yj.exec(l);u?i=l.replace(u[0],""):a.push(l)}if(!i){r.warn?.(`A default export was indicated in ${t.fileName}, but its alias could not be determined from the export statement.`);return}return{defaultAlias:i,defaultExport:n,exports:a}},"extractExports"),vj=gt((e,t,r)=>{if("declarations"in t&&t.declarations.length>0){const n=t.declarations[0];if(n?.id.type==="Identifier"){e.set(n.id.name,{declare:t.declare===!0,end:t.end,isVariable:!0,start:t.start});return}}if("id"in t&&t.id?.type==="Identifier"){const{name:n}=t.id;e.set(n,{declare:t.declare===!0,end:t.end,isClass:t.type==="ClassDeclaration",start:t.start});return}e.set(r(),{declare:t.declare===!0,end:t.end,start:t.start})},"prepareDeclaration"),Kr=gt((e,t,r,n)=>{const o=mo(r.fileName,e,{astType:"ts",lang:"ts",sourceType:"module"});let s,i=0;const a=gt(()=>(i+=1,`__unnamed_${String(i)}$$`),"generateUnnamed"),l=new Map,u=new Map,{program:c}=o;for(const m of c.body)if(m.type==="ExportNamedDeclaration")for(const h of m.specifiers)h.exported.type==="Identifier"&&(h.exported.name==="default"?h.local.type==="Identifier"&&(s={end:h.end,local:h.local.name,start:h.start}):u.set(h.exported.name,{type:h.exportKind==="type"}));else{if(m.type==="ImportDeclaration")continue;switch(m.type){case"ClassDeclaration":case"FunctionDeclaration":case"TSDeclareFunction":case"TSEnumDeclaration":case"TSInterfaceDeclaration":case"TSTypeAliasDeclaration":case"VariableDeclaration":{vj(l,m,a);break}case"TSImportEqualsDeclaration":case"TSModuleDeclaration":{l.set(a(),{declare:!1,end:m.end,start:m.start});break}}}const p=[];if(s)for(const[m,h]of u.entries())m!==s.local&&h.type&&p.push(m);if(!s){const m=[...u.values()].every(h=>h.type);return t.startsWith("export type")&&u.size>0&&m||n.warn?.(`Cannot infer default export from the file: ${r.fileName}`),t}if(!l.get(s.local))return n.warn?.(`Cannot infer default export from the file: ${r.fileName}. Declaration for '${s.local}' not found.`),t;const f=t,d=new Ee(`${f}
|
|
126
|
+
declare namespace ${s.local} {
|
|
127
|
+
`);for(const[m,h]of l.entries()){if(p.includes(m)&&m!==s.local)continue;const y=e.slice(h.start,h.end).replace($j," }");d.append(" "),h.declare?d.append(y.replace("declare","export").replaceAll(" "," ")):d.append(`export ${y}`.replaceAll(" "," ")),d.append(`
|
|
128
|
+
`)}return d.append(` import _default = ${s.local};
|
|
129
|
+
export { _default as default };
|
|
130
|
+
`),d.append(`}
|
|
131
|
+
export = ${s.local};
|
|
132
|
+
`),d.toString()},"createCjsNamespace"),Qs=gt((e,t,r)=>{const{defaultExport:n,exports:o}=t;if(r){const p=o.length===0?`export = ${r.defaultImport??""};`:`// @ts-ignore
|
|
133
|
+
export = ${r.defaultImport??""};
|
|
134
|
+
export { ${o.join(", ")} } from '${n.specifier??""}'`,f=e.replace(n.code.replace(bn,""),p.replace(bn,""));return f.endsWith(";")?f:`${f};`}const s=`import _default from '${n.specifier??""}';`,i=new Ee(e),a=fo(e),l=a.length>0?a.at(-1):void 0;l?.end!==void 0&&l.end>0?i.appendRight(l.end,`
|
|
135
|
+
${s}
|
|
136
|
+
`):i.prepend(`${s}
|
|
137
|
+
`);let u=i.toString();u=u.replaceAll(bj,`
|
|
138
|
+
`);let c;if(o.length===0)c=u.replace(n.code.replace(bn,""),"export = _default");else{const p=`// @ts-ignore
|
|
139
|
+
export = _default;
|
|
140
|
+
export { ${o.join(", ")} } from '${n.specifier??""}';`;c=u.replace(n.code.replace(bn,""),p)}return c.replaceAll(";;",";")},"handleDefaultCJSExportAsDefault"),xj=gt((e,t,r,n,o,s)=>{const{defaultAlias:i,defaultExport:a,exports:l}=r;if(s){if(s.namedImports?.[i]===i){if(l.length===0)return e.replace(a.code,`export = ${i}`);const d=`export { ${l.join(", ")} } from '${a.specifier??""}'`,m=new Ee(e).replace(a.code,d).toString();return Kr(e,m,t,o)}o.warn?.(`Cannot parse "${i}" named export from ${s.specifier} import at ${t.fileName}!.`);return}const u=`import { ${i} } from '${a.specifier??""}';
|
|
141
|
+
`;let c=e;const p=n.length>0?n.at(-1)?.end??0:0,f=new Ee(c);if(p>0?f.appendRight(p,`
|
|
142
|
+
${u}`):f.prepend(u),c=f.toString(),l.length>0){const d=`export { ${l.join(", ")} } from '${a.specifier??""}'`,m=new Ee(c).replace(a.code,d).toString();return Kr(e,m,t,o)}return new Ee(c).replace(a.code,`export = ${i}`).toString()},"handleDefaultNamedCJSExport"),Tc=gt((e,t,{defaultAlias:r,defaultExport:n,exports:o},s)=>{const i=o.filter(l=>Zs.test(l)),a=o.filter(l=>!Zs.test(l));if(i.length>0){let l="";return r&&(l+=`// @ts-ignore
|
|
143
|
+
${r};
|
|
144
|
+
`),l+=`export type { ${i.map(u=>u.replace(Zs,"").trim()).join(", ")} };
|
|
145
|
+
`,a.length>0&&(l+=`export { ${a.join(", ")} };
|
|
146
|
+
`),Kr(e,l.trim(),t,s)}if(r&&a.length>0&&i.length===0){let l=`// @ts-ignore
|
|
147
|
+
${r};
|
|
148
|
+
`;return l+=`export { ${a.join(", ")} };
|
|
149
|
+
`,Kr(e,l.trim(),t,s)}if(r&&a.length===0&&i.length===0){const l=new RegExp(String.raw`^export\\s+default\\s+${r};`,"m").exec(e);return l?`${e.slice(0,Math.max(0,l.index))}export = ${r};`:e.replace(n.code,`export = ${r};`).replace(";;",";")}},"handleNoSpecifierDefaultCJSExport"),Ej=/^export\s+default\s+from\s+['"]([^'"]+)['"];?$/m,Sj=gt((e,t,r)=>{const n=Ej.exec(e);if(n)return{code:`import _default from '${n[1]??""}';
|
|
150
|
+
export = _default;`,map:void 0};const o=wj(e,t,r);if(o){let l;if(o.defaultExport.specifier){const{specifier:u}=o.defaultExport,c=fo(e),p=c.filter($=>$.imports).map($=>$h($)),f=p.find($=>$.specifier===u),{defaultAlias:d,defaultExport:m,exports:h}=o,y=m.exports;if(d==="default"&&m.specifier&&h.length>0)l=Qs(e,o,f);else if(d==="default"&&m.specifier&&h.length===0&&y&&Cc.test(y))p.find($=>$.specifier===m.specifier)?.defaultImport?l=Qs(e,o,f):(r.warn?.(`Cannot parse default export name from ${m.specifier} import at ${t.fileName}!. The module might not have a default export, or it's aliased as 'default'.`),l=void 0);else if(d==="default"&&m.specifier&&h.length===0)l=Qs(e,o,f);else if(m.specifier&&d!=="default"){l=xj(e,t,o,c,r,f);const $=f&&o.defaultExport.specifier&&d!=="default"&&f.namedImports?.[d]!==d;if(!(l===void 0&&$)&&l===void 0&&!(d==="default"&&h.length===0&&y&&Cc.test(y))){const g=Tc(e,t,o,r);g&&(l=g)}}}else l=Tc(e,t,o,r);return l?{code:l,map:void 0}:void 0}const s=mo(t.fileName,e,{astType:"ts",lang:"ts",sourceType:"module"});let i=[],a=!1;if(s.program.body.length>0){const l=s.program.body.at(-1);l?.type==="ExportNamedDeclaration"&&!l.declaration&&l.specifiers.length>0&&l.specifiers.every(u=>u.exportKind==="type")&&(a=!0,i=l.specifiers.map(u=>u.local.type==="Identifier"?u.local.name:"").filter(Boolean))}if(a&&i.length>0){const l=`export type { ${i.join(", ")} };`,u=Kr(e,l,t,r);return u?{code:u,map:void 0}:void 0}},"fixDtsDefaultCJSExports");var kj=Object.defineProperty,Nc=kd((e,t)=>kj(e,"name",{value:t,configurable:!0}),"s");const jj=/\.d\.c?ts$/,Aj=Nc((e={})=>{const{matcher:t=Nc(r=>r.exports.length>0&&jj.test(r.fileName)&&r.isEntry,"matcher")}=e;return{name:"packem:fix-dts-default-cjs-exports-plugin",renderChunk(r,n){return t(n)?Sj(r,{fileName:n.fileName,imports:n.imports},{warn:this.warn}):void 0}}},"fixDtsDefaultCjsExportsPlugin"),Do=(e,t={},r={})=>({...t,...e,values:e.values?{...e.values}:{...r}}),Yr=e=>!!e?.endsWith(".d"),ce=e=>e.logger,Oj=/Circular dependency:[\s\S]*node_modules/,Rj=/\.mts$/,Cj=/\.(?:m|c)?(?:j|t)sx?$/,Tj=/^['|"](use (\w+))['|"]$/,Nj=/\.(?:[cm]?jsx?|[cm]?tsx?|json)$/,Pj=e=>e instanceof RegExp?e.source:e,Mj=e=>{if(typeof e=="boolean")return String(e);const t=[];for(const r of e)t.push(Pj(r));return t.toSorted((r,n)=>r.localeCompare(n)).join(",")},Pc=(e,t)=>t?r=>{if(!Yr(r.name))return`${r.name}.${e()}`}:r=>{if(!Yr(r.name))return Br(r,e())},Mc=(e,t)=>t?r=>{const{name:n}=r;if(!Yr(n))return`${n??"[name]"}.${e(r)}`}:r=>{const{name:n}=r;if(!Yr(n))return th(r,e(r))},jd=e=>{const t=`node${Dn.node.split(".")[0]}`;if(!e.pkg.engines?.node)return t;const r=Le.minVersion(e.pkg.engines.node);return r?`node${String(r.major)}`:t},Ad=(e,t,r)=>{const n=e.options.browserTargets&&e.options.browserTargets.length>0?e.options.browserTargets:e.options.resolvedBrowserTargets??e.options.browserTargets??[];if(t){const o=Gm(t);return e.options.runtime==="node"?[...new Set([r,...o])]:e.options.runtime==="browser"?[...new Set([...La(n),...o])]:o}return e.options.runtime==="node"?[r]:La(n)},_j=(e,t)=>{if(!e.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");const r=e.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3";r&&ce(e).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(" "));const n=r?"es5":Ad(e,e.options.rollup.esbuild.target,t);let o=e.options.rollup.esbuild.keepNames;return e.options.minify||(o=!1,ce(e).debug("Disabling keepNames because minify is disabled")),(r||e.tsconfig?.config.compilerOptions?.target==="es5")&&(o=!1,ce(e).debug("Disabling keepNames because target is set to es5")),{logger:ce(e),minify:e.options.minify,minifyWhitespace:e.options.minify,sourceMap:e.options.sourcemap,...e.options.rollup.esbuild,keepNames:o,target:n}},Ij=e=>{if(!e.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:e.options.minify,...e.options.rollup.swc,jsc:{minify:{compress:{directives:!1,passes:2},format:{comments:"some"},mangle:{topLevel:!0},sourceMap:e.options.sourcemap,toplevel:e.options.emitCJS??e.options.emitESM},...e.options.rollup.swc.jsc},sourceMaps:e.options.sourcemap}},Od=(e,t)=>{if(!e.options.rollup.oxc)throw new Error("No oxc options found in your configuration.");const{jsx:r}=e.options.rollup.oxc;let n;return typeof r=="string"?n=r:r?n={...r,refresh:!1}:n=void 0,e.options.rollup.oxc={...e.options.rollup.oxc,cwd:e.options.rootDir,jsx:n,sourcemap:e.options.sourcemap,typescript:e.tsconfig?.config?{allowDeclareFields:!0,allowNamespaces:!0,declaration:void 0,jsxPragma:e.tsconfig.config.compilerOptions?.jsxFactory,jsxPragmaFrag:e.tsconfig.config.compilerOptions?.jsxFragmentFactory,onlyRemoveTypeImports:!0,rewriteImportExtensions:!1}:void 0},e.options.rollup.oxc.target=Ad(e,e.options.rollup.oxc.target,t),e.options.rollup.oxc},Wj=(e,t,r)=>{if(r)return"js";if(t.facadeModuleId?.endsWith(".mts")){const n=t.facadeModuleId.replace(Rj,".cts");if(Ji(n))return"mjs"}return!e.options.emitCJS&&e.options.emitESM&&e.pkg.main?.endsWith(".cjs")?"mjs":Pe(e,"esm")},Bj=(e,t)=>{const r=jd(t);if(e==="esbuild")return _j(t,r);if(e==="swc")return Ij(t);if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return t.options.rollup.sucrase}if(e==="oxc")return Od(t,r);throw new Error("A Unknown transformer was provided")},Dj=e=>{const{browser:t,exportConditions:r}=e,n={...e};delete n.allowExportsFolderMapping,delete n.browser,delete n.exportConditions,delete n.preferBuiltins,delete n.unresolvedImportBehavior;const o=new Set(Array.isArray(n.conditionNames)?n.conditionNames:[]);return Array.isArray(r)&&(n.conditionNames=[...new Set([...r,...o])]),t&&(n.conditionNames=[...new Set(["browser",...n.conditionNames??[]])],n.aliasFields=[["browser"],...n.aliasFields??[]]),n},Rd=e=>{const{resolve:t}=e.options.rollup;if(t)return Pm(Dj(t),e.options.rootDir,ce(e),e.tsconfig?.path)},Cd=(e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&Oj.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT"){const{resolve:r}=t.options.rollup;if(r&&r.unresolvedImportBehavior==="warn")return!1;const n=new Error(`Failed to resolve the module "${e.exporter??""}" imported by "${re(Se(X(),e.id??""))}"
|
|
151
|
+
Is the module installed? Note:
|
|
152
|
+
↳ to inline a module into your bundle, install it to "devDependencies".
|
|
153
|
+
↳ to depend on a module via import/require, install it to "dependencies".`);throw n.id=e.id,n}return e.code==="MODULE_LEVEL_DIRECTIVE"?!0:e.code==="MIXED_EXPORTS"&&(t.options.cjsInterop??!1)},Lj=e=>{const t={};for(const r of e.options.entries){if(r.name===void 0)continue;const{name:n}=r,o=X(e.options.rootDir,r.input);if(t[n]!==void 0&&t[n]!==o)throw new Error(`Duplicate rollup input name "${n}" — one maps to "${t[n]}", another to "${o}". Each entry must have a unique name.`);t[n]=o}return t},Fj=e=>e.stack?`${e.message}
|
|
154
|
+
${e.stack}`:e.message,Hj=(e,t,r,n)=>{if(t==="dts"&&n.code==="EMPTY_BUNDLE")return;const o=Fj(n),s=t+(n.plugin?`:plugin:${n.plugin}`:"");switch(r){case"info":{ce(e).info({message:o,prefix:s});return}case"warn":{ce(e).warn({message:o,prefix:s});return}case"debug":ce(e).debug({message:o,prefix:s})}},Td=(e,t)=>({input:Lj(e),logLevel:e.options.debug?"debug":"info",onLog:(r,n)=>{Hj(e,t,r,n)},onwarn(r,n){Cd(r,e)||r.code||n(r)},preserveEntrySignatures:"strict",treeshake:{moduleSideEffects:!0,preset:"smallest"},watch:e.mode==="watch"?e.options.rollup.watch:!1}),qj=(e,t,r,n)=>{const o={...e.options.rollup.alias,entries:t};return!r&&n&&(o.customResolver=n),Lu(o)},Jj=e=>{if(!e.options.rollup.pure)return{pureNewExpressionPluginInstance:void 0,purePluginInstance:void 0,rolldownPurePluginInstance:void 0};const t=e.options.rollup.pure.functions??[],r=["Object.defineProperty","Object.assign","Object.create","Object.freeze","Object.seal","Object.setPrototypeOf","Object.getOwnPropertyDescriptor","Object.getOwnPropertyDescriptors","Object.getPrototypeOf","Object.hasOwnProperty","Object.isExtensible","Object.isFrozen","Object.isSealed","Symbol","Symbol.for","Symbol.keyFor","Symbol.iterator","Symbol.asyncIterator","Symbol.hasInstance","Symbol.isConcatSpreadable","Symbol.species","Symbol.toPrimitive","Symbol.toStringTag","Proxy","Reflect.apply","Reflect.construct","Reflect.defineProperty","Reflect.deleteProperty","Reflect.get","Reflect.getOwnPropertyDescriptor","Reflect.getPrototypeOf","Reflect.has","Reflect.isExtensible","Reflect.ownKeys","Reflect.preventExtensions","Reflect.set","Reflect.setPrototypeOf","WeakMap","WeakSet","WeakRef","Array.from","Array.of","Array.isArray","Number.isFinite","Number.isInteger","Number.isNaN","Number.isSafeInteger","Number.parseFloat","Number.parseInt","String.fromCharCode","String.fromCodePoint","String.raw","Date.now","Date.parse","Date.UTC","Math.abs","Math.acos","Math.acosh","Math.asin","Math.asinh","Math.atan","Math.atan2","Math.atanh","Math.cbrt","Math.ceil","Math.clz32","Math.cos","Math.cosh","Math.exp","Math.expm1","Math.floor","Math.fround","Math.hypot","Math.imul","Math.log","Math.log10","Math.log1p","Math.log2","Math.max","Math.min","Math.pow","Math.random","Math.round","Math.sign","Math.sin","Math.sinh","Math.sqrt","Math.tan","Math.tanh","Math.trunc","JSON.parse","JSON.stringify","require.resolve","Buffer.from","Buffer.alloc","Buffer.allocUnsafe","Buffer.isBuffer",...t],n=["Proxy","WeakMap","WeakSet","WeakRef",...t.filter(a=>typeof a=="string"&&!a.includes("."))],o=Mm({...e.options.rollup.pure,functions:r,sourcemap:e.options.sourcemap});o.transform.order="pre";const s=Da({constructors:n,sourcemap:e.options.sourcemap}),i=Da({constructors:n,functions:r,mode:"renderChunk",sourcemap:e.options.sourcemap});return{pureNewExpressionPluginInstance:s,purePluginInstance:o,rolldownPurePluginInstance:i}},zj=(e,t,r)=>{if(e.pkg.peerDependenciesMeta)for(const[n,o]of Object.entries(e.pkg.peerDependenciesMeta))o&&typeof o=="object"&&"optional"in o&&o.optional&&n in t&&r.push(n)},Uj=(e,t,r)=>{if(!e.options.rollup.resolveExternals?.devDeps)for(const n of Object.keys(e.pkg.devDependencies??{}))e.usedDependencies.has(n)&&!(n in t)&&r.push(n)},Gj=e=>{const t=new Set,r=[];for(const n of e)typeof n=="string"?t.has(n)||(t.add(n),r.push(n)):r.push(n);return r},Vj=e=>{const t=e.options.rollup.dts?.resolve;if(t===!1)return!1;if(t===!0)return!0;const r=Object.keys(e.pkg.optionalDependencies??{}),n=e.pkg.peerDependencies??{};return zj(e,n,r),Uj(e,n,r),r.length===0&&!t?!1:Gj([...r,...t??[]])},Kj=async(e,t)=>{const{dts:r}=await import("@visulima/rollup-plugin-dts"),n=e.options.rollup.dts??{};return r({...n,compilerOptions:{...n.compilerOptions,incremental:void 0,inlineSources:void 0,lib:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},emitDtsOnly:!0,resolve:t,tsconfig:e.tsconfig?.path})},Yj=Hi(Kj),Nd=async(e,t)=>{const r=No(e.pkg,e.options),n=Vj(e),o=Rd(e),s=Mj(n),i=e.options.entries.map(p=>p.name??"").filter(p=>p!=="").toSorted((p,f)=>p.localeCompare(f)).join(","),a=`dts-plugin:${String(process.pid)}${e.tsconfig?.path??""}:${s}:${i}`,[l,u,c]=Ju(e.options.rollup.plugins,"dts");return{...Td(e,"dts"),onwarn(p,f){Cd(p,e)||p.code!=="EMPTY_BUNDLE"&&p.code!=="CIRCULAR_DEPENDENCY"&&f(p)},output:[e.options.emitCJS&&{chunkFileNames:p=>Br(p,Ke(e,"cjs")),compact:e.options.minify,dir:X(e.options.rootDir,e.options.outDir),entryFileNames:`[name].${Ke(e,"cjs")}`,format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:p=>Br(p,Ke(e,"esm")),compact:e.options.minify,dir:X(e.options.rootDir,e.options.outDir),entryFileNames:`[name].${Ke(e,"esm")}`,format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.declaration==="compatible"&&{chunkFileNames:p=>Br(p,"d.mjs"),compact:e.options.minify,dir:X(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[Bu(),ke(Vf(),t),ke(Sd(),t),ld(e,{dtsResolve:n,forTypes:!0,skipUnlistedWarnings:!0}),{load(p){if(!Nj.test(p))return""},name:"packem:ignore-files"},e.tsconfig&&ke(Ed(e.options.rootDir,ce(e),e.tsconfig),t),e.tsconfig&&e.options.rollup.tsconfigPaths&&ke(vd(e.options.rootDir,e.tsconfig,ce(e),e.options.rollup.tsconfigPaths),t),md(e),e.options.rollup.replace&&Du(Do(e.options.rollup.replace,{sourcemap:e.options.sourcemap})),e.options.rollup.alias&&Lu({customResolver:o,...e.options.rollup.alias,entries:r}),...l,o,...u,...await Yj(a)(e,n),e.options.emitCJS&&Aj(),e.options.cjsInterop&&e.options.emitCJS&&rp({...e.options.rollup.cjsInterop,logger:ce(e)}),e.options.rollup.patchTypes&&ke(Lk(e.options.rollup.patchTypes,ce(e)),t),TS(),...c,e.options.rollup.license!==!1&&e.options.rollup.license?.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&ud({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:ce(e),marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},Pd=async(e,t,r)=>{const n=No(e.pkg,e.options),o=r==="rolldown",s=o?void 0:Rd(e),i=e.options.rollup.css&&e.options.rollup.css.loaders&&e.options.rollup.css.loaders.length>0?await import("@visulima/rollup-plugin-css"):void 0,a=!!(e.options.unbundle||e.options.rollup.output?.preserveModules),l=a?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output?.preserveModulesRoot??e.options.sourceDir}:{manualChunks:ux(e.dependencyGraphMap,e.buildEntries,!o&&!!e.options.rollup.preserveDirectives),preserveModules:!1},[u,c,p]=Ju(e.options.rollup.plugins,"build"),f=e.tsconfig?.config.compilerOptions?.esModuleInterop,{pureNewExpressionPluginInstance:d,purePluginInstance:m,rolldownPurePluginInstance:h}=Jj(e);return{...Td(e,"build"),output:[e.options.emitCJS&&{assetFileNames:"[name]-[hash][extname]",chunkFileNames:Pc(()=>Pe(e,"cjs"),a),compact:e.options.minify,dir:X(e.options.rootDir,e.options.outDir),entryFileNames:Mc(y=>Pe(e,"cjs"),a),esModule:f??"if-default-prop",exports:"auto",extend:!0,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,...l},e.options.emitESM&&{assetFileNames:"[name]-[hash][extname]",chunkFileNames:Pc(()=>Pe(e,"esm"),a),compact:e.options.minify,dir:X(e.options.rootDir,e.options.outDir),entryFileNames:Mc(y=>Wj(e,y,a),a),esModule:f??"if-default-prop",exports:"auto",extend:!0,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,...l}].filter(Boolean),plugins:[!o&&Bu(),vE(),ke(Vf(),t),ld(e),Sd(),e.tsconfig&&ke(Ed(e.options.rootDir,ce(e),e.tsconfig),t),e.tsconfig&&e.options.rollup.tsconfigPaths&&ke(vd(e.options.rootDir,e.tsconfig,ce(e),e.options.rollup.tsconfigPaths),t),md(e),e.options.rollup.replace&&Du(Do(e.options.rollup.replace,{sourcemap:e.options.sourcemap})),e.options.rollup.alias&&qj(e,n,o,s),...u,s,e.options.rollup.nativeModules&&XE(e.options.rollup.nativeModules),e.options.rollup.dataUri&&qx({...e.options.rollup.dataUri}),e.options.rollup.polyfillNode&&_m({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),!o&&e.options.rollup.json&&Th({...e.options.rollup.json}),e.options.rollup.debarrel&&d2(e.options.rollup.debarrel,ce(e)),Im(),e.options.rollup.wasm&&Wm(e.options.rollup.wasm),e.options.rollup.url&&Ak(e.options.rollup.url),i&&ke(i.rollupCssPlugin({dts:!!e.options.declaration,sourceMap:e.options.sourcemap,...e.options.rollup.css},e.options.runtime==="browser"&&(!e.options.browserTargets||e.options.browserTargets.length===0)?e.options.resolvedBrowserTargets??[]:e.options.browserTargets??[],e.options.rootDir,e.options.sourceDir,e.environment,e.options.sourcemap,e.options.debug,e.options.minify??!1,n),t),e.options.rollup.css&&e.options.rollup.css.loaders&&e.options.rollup.css.loaders.length>0&&(e.options.declaration||e.options.rollup.css.dts)&&i?.cssModulesTypesPlugin(e.options.rollup.css,e.options.rootDir),e.options.rollup.raw&&ke(rS(e.options.rollup.raw),t),e.options.sourcemap&&xk(e.options.rollup.sourcemap),...c,e.options.rollup.minifyHTMLLiterals&&e.options.minify&&UE({...e.options.rollup.minifyHTMLLiterals,logger:ce(e)}),e.options.rollup.requireCJS&&e.options.emitESM&&ke(bS({...e.options.rollup.requireCJS,cwd:e.options.rootDir},ce(e)),t),e.options.rollup.babel&&ke(Nx({include:e.options.rollup.babel.include??Cj,...e.options.rollup.babel,root:e.options.rootDir,sourceMaps:e.options.rollup.babel.sourceMaps??e.options.sourcemap}),t),!o&&d,!o&&m,o&&h,e.options.rollup.detectDuplicated!==!1&&V2(ce(e),e.options.rootDir,e.options.rollup.detectDuplicated),!o&&e.options.transformer&&ke(e.options.transformer(Bj(e.options.transformerName,e)),t),e.options.rollup.preserveDirectives&&Bm({directiveRegex:Tj,...e.options.rollup.preserveDirectives,logger:ce(e)}),e.options.rollup.shebang&&CS(e.options.entries.filter(y=>y.executable).map(y=>y.name).filter(Boolean),e.options.rollup.shebang),!o&&e.options.cjsInterop&&e.options.emitCJS&&rp({...e.options.rollup.cjsInterop,logger:ce(e)}),e.options.rollup.dynamicVars&&Wv(),!o&&e.options.rollup.dynamicVars&&Dm(e.options.rollup.dynamicVars),!o&&e.options.rollup.commonjs&&ke(Lm({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&&rE(e.pkg,e.options.rollup.shim),e.options.rollup.jsxRemoveAttributes&&(()=>{const y=Fm({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:ce(e),...o?{mode:"renderChunk"}:{}});return o?y:ke(y,t)})(),...p,e.options.rollup.metafile&&Hv(),e.options.rollup.copy&&Wx(e.options.rollup.copy,ce(e)),e.options.rollup.license!==!1&&e.options.rollup.license?.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&ud({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:ce(e),marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.analyze&&e.options.rollup.visualizer!==!1&&Hm({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),preserveEntrySignatures:"strict"}},Md=(e,t)=>Pd(e,t,"rollup"),Xj={".css":"js",".less":"js",".pcss":"js",".sass":"js",".scss":"js",".styl":"js",".stylus":"js"},Zj=e=>{if(!e.options.rollup.oxc)return{};const t=Od(e,jd(e));return{jsx:t.jsx,target:t.target,typescript:t.typescript}},_d=async(e,t)=>{const r=await Pd(e,t,"rolldown");return r.transform=Zj(e),r.moduleTypes={...Xj,...r.moduleTypes??{}},e.options.minify&&Array.isArray(r.output)&&(r.output=r.output.map(n=>({...n,minify:!0}))),r},Id=(e,t,r)=>{const n=e.filter(s=>s.type==="chunk"&&s.isEntry),o=new Set(n.map(s=>s.fileName));for(const s of n)t.buildEntries.push({chunks:(s.imports??[]).filter(i=>o.has(i)),dynamicImports:s.dynamicImports??[],exports:s.exports??[],modules:Object.entries(s.modules??{}).map(([i,a])=>({bytes:a.renderedLength,id:i})),path:s.fileName,size:{bytes:Buffer.byteLength(s.code??"","utf8")},type:"entry"});for(const s of e.filter(i=>i.type==="asset")){if(r.has(s.fileName))continue;const i=s.source??"",a=typeof i=="string"?Buffer.byteLength(i,"utf8"):i.byteLength;r.set(s.fileName,{path:s.fileName,size:{bytes:a},type:"asset"})}},Wd=async(e,t)=>{try{return t(await e())}catch{return}},Bd="Rollup is not installed. Please install 'rollup' to use bundler: 'rollup' or DTS generation with the rollup driver.",Ca=async()=>{const e=await Wd(()=>import("rollup"),t=>t.rollup);if(!e)throw new Error(Bd);return e},_c=async()=>{const e=await Wd(()=>import("rollup"),t=>t.watch);if(!e)throw new Error(Bd);return e},Ic="rollup-build.json",Lo="dependencies-cache.json",Dd=e=>e??"rollup",ro=e=>!!(e.options.validation&&e.options.validation.dependencies!==!1),Ld=(e,t,r)=>{const n=t.get(Lo,r);n&&(n.used?.forEach(o=>e.usedDependencies.add(o)),n.hoisted?.forEach(o=>e.hoistedDependencies.add(o)))},Fd=(e,t,r)=>{ro(e)&&t.set(Lo,{hoisted:[...e.hoistedDependencies],used:[...e.usedDependencies]},r)},Qj=async(e,t,r,n)=>{const o=ro(e)&&!!t.get(Lo,r),s=!ro(e)||o;let i=n;s&&(i={...n,cache:t.get(Ic,r)},o&&Ld(e,t,r));const a=await(await Ca())(i);try{s&&t.set(Ic,a.cache,r),Fd(e,t,r),await e.hooks.callHook("rollup:build",e,a);const l=new Map;for(const u of n.output){const{output:c}=await a.write(u);Id(c,e,l)}e.buildEntries.push(...l.values())}finally{await a.close()}},e9=async(e,t,r,n)=>{ro(e)&&t.get(Lo,r)&&Ld(e,t,r);const o=await(await Uf())(n);try{Fd(e,t,r),await e.hooks.callHook("rollup:build",e,o);const s=new Map;for(const i of n.output){const{output:a}=await o.write(i);Id(a,e,s)}e.buildEntries.push(...s.values())}finally{await o.close?.()}},t9=async(e,t,r,n)=>{const o=n==="rolldown",s=o?await _d(e,t):await Md(e,t);await e.hooks.callHook("rollup:options",e,s),Object.keys(s.input??{}).length!==0&&(await(o?e9(e,t,r,s):Qj(e,t,r,s)),await t.flush())},Wc=async e=>{try{return await(e==="rolldown"?Uf():Ca()),!0}catch{return!1}},Bc=(e,t)=>{const r=[G(t,"noop.js"),import.meta.url];for(const n of r)try{return _e(n).resolve(e),!0}catch{}return!1},Hd=async(e,t,r,n,o)=>{if(!(process.stdout.isTTY&&!process.env.CI)){const a=await pl(e,r);throw new Error(`${e} is required but is not installed. Run: ${a}`)}const s=await Nh({initialValue:!0,message:t});if(Ph(s)||!s){const a=await pl(e,r);throw new Error(`Cannot continue without ${e}. Run: ${a}`)}const i=Mh();i.start(`Installing ${e}`);try{await Tu([e],{cwd:r,dev:!0,silent:!0}),i.stop(`Installed ${e}`)}catch(a){throw i.stop(`Failed to install ${e}`),a}if(!await o())throw n.error(`Installed ${e} but it still cannot be loaded. Try restarting packem.`),new Error(`${e} was installed but is not loadable in the current process. Re-run packem to pick it up.`)},Dc=async(e,t,r)=>{await Wc(e)||await Hd(e,`${e} is required as the bundler but is not installed. Install it now?`,t,r,()=>Wc(e))},r9=async(e,t,r)=>{const n=s1[e];Bc(n,t)||await Hd(n,`${n} is required for transformer: "${e}" but is not installed. Install it now?`,t,r,()=>Promise.resolve(Bc(n,t)))},Fo=e=>{const t=G(e,"package.json");if(!rt(t))throw new Error(`package.json not found at ${t}`);const r=la(t,{resolveCatalogs:!0});return r.publishConfig&&Object.assign(r,r.publishConfig),{packageJson:r,packageJsonPath:t}},n9=async(e,t,r,n)=>{let o;if(n){const s=G(e,n);if(!await Ct(s))throw new Error(`tsconfig.json not found at ${s}`);o={config:_h(s),path:s},r.info("Using tsconfig settings at",s)}else if(mf(t,["typescript"]))try{o=await Ih(e),r.debug("Using tsconfig settings found at",o.path)}catch{r.info("No tsconfig.json or jsconfig.json found.")}return o},o9=/[.*+?^${}()|[\]\\]/g,qd=e=>e.replace(o9,"\\$&"),s9=/^\.\.?\//,i9=(e,t)=>{if(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);return}e.cjs!==void 0||e.esm!==void 0||e.declaration||(t.options.emitCJS!==void 0&&(e.cjs=t.options.emitCJS),t.options.emitESM!==void 0&&(e.esm=t.options.emitESM))},Lc=(e,t)=>{if(typeof e.name!="string"){let r=Tt(e.input)?Se(t.options.rootDir,e.input):Ru(e.input);r.startsWith("./")&&(r=r.slice(2)),e.name=r.replace(new RegExp(`^${qd(t.options.sourceDir)}/`),"").replace(qi,"")}if(!e.input)throw new Error(`Missing entry input: ${JSON.stringify(e)}`);Cu(e.input)&&(e.input=X(t.options.rootDir,e.input)),t.options.declaration&&e.declaration===void 0&&(e.declaration=t.options.declaration),i9(e,t),e.outDir=X(t.options.rootDir,e.outDir??t.options.outDir)},a9=e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:di(t)}:{...t,exportKey:t.exportKey??new Set,isGlob:di(t.input)})},l9=e=>{const t=["**/.git/**","**/node_modules/**","**/test-results/**"],{watch:r}=e.options.rollup;if(r){if(typeof r.exclude=="string")t.push(r.exclude);else if(Array.isArray(r.exclude))for(const n of r.exclude)typeof n=="string"&&t.push(n)}return t},c9=e=>{for(const t of e.options.entries.filter(r=>r.isGlob)){const r={...t};delete r.isGlob;const n=Au([r.input],{cwd:e.options.rootDir,dot:!1,ignore:l9(e),onlyFiles:!0});if(n.length===0)throw new _t(`No files found in the glob pattern: ${re(G(e.options.rootDir,r.input))}`);for(const o of n)e.options.entries.push({...r,input:X(e.options.rootDir,o)});e.options.entries.splice(e.options.entries.indexOf(t),1)}},u9=e=>{for(const t of e)if(t==="node"||t==="workerd"||t.includes("node")||t.includes("workerd"))return!0;return!1},p9=e=>e.includes(".server")||e.includes(".node")||e.includes(".workerd"),f9=e=>{const t=e.exportKey&&[...e.exportKey].some(n=>n.includes("browser")||n==="browser"),r=e.fileAlias?.includes(".browser")??!1;if(t||r)return"browser";if(e.exportKey&&u9(e.exportKey)||e.fileAlias&&p9(e.fileAlias))return"node"},d9=e=>{for(const t of e.options.entries){if(t.runtime)continue;const r=f9(t);r&&(t.runtime=r)}},m9=e=>{for(const t of e.options.entries)if(t.fileAlias){let r=t.fileAlias;for(;r.startsWith("./")||r.startsWith("../");)r=r.replace(s9,"");t.name=r}},Jd=e=>{a9(e),c9(e),d9(e),m9(e);for(const t of e.options.entries.filter(r=>!r.fileAlias))Lc(t,e);for(const t of e.options.entries.filter(r=>r.fileAlias))Lc(t,e),t.fileAlias=void 0},h9=/^[_$a-z\u00A0-\uFFFF][\w$\u00A0-\uFFFF]*$/iu,g9=(e,t)=>{const r=e.options.jiti.transformOptions?.babel?.plugins;return JSON.stringify({...e.options.jiti,alias:{...No(e.pkg,e.options),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},void 0,2).replace('"__$BABEL_PLUGINS"',Array.isArray(r)?`[${r.map((n,o)=>{if(Array.isArray(n)){const[s,...i]=n;return t.push(s),`[${[`plugin${String(o)}`,...i.map(a=>JSON.stringify(a))].join(", ")}]`}return t.push(n),`plugin${String(o)}`}).join(",")}]`:"[]")},y9=e=>e.filter(t=>t!=="default").map((t,r)=>{if(h9.test(t))return`export const ${t} = _module.${t};`;const n=`__packem_export_${String(r)}`,o=t.startsWith("'")&&t.endsWith("'")?`_module[${t}]`:`_module[${JSON.stringify(t)}]`;return`const ${n} = ${o};
|
|
155
|
+
export { ${n} as ${JSON.stringify(t)} };`}),zd=(e,t,r)=>{ao(e,`export * from "${t}";
|
|
156
|
+
${r?`export { default } from "${t}";`:""}`)},$9=async(e,t,r,n,o,s,i,a,l,u)=>{const c=t(Z(r),await ep("jiti",{conditions:["node","import"],url:import.meta.url})),p=Ke(e,"esm"),f=`${o}.${p}`;ao(`${r}.${Pe(e,"esm")}`,s+[`import { createJiti } from "${c}";`,...a.map((d,m)=>`import plugin${String(m)} from "${d}";`),"",`const jiti = createJiti(import.meta.url, ${i});`,"",`/** @type {import("${f}")} */`,`const _module = await jiti.import("${n}");`,...u?["export default _module?.default ?? _module;"]:[],...y9(l)].join(`
|
|
157
|
+
`)),e.options.declaration&&zd(`${r}.${p}`,f,u)},b9=async(e,t,r,n,o,s,i,a,l)=>{const u=t(Z(r),await ep("jiti",{conditions:["node","require"],url:import.meta.url})),c=Ke(e,"cjs"),p=`${o}.${c}`;ao(`${r}.${Pe(e,"cjs")}`,s+[`const { createJiti } = require("${u}");`,...a.map((f,d)=>`const plugin${String(d)} = require(${JSON.stringify(f)})`),"",`const jiti = createJiti(__filename, ${i});`,"",`/** @type {import("${p}")} */`,`module.exports = jiti("${n}")`].join(`
|
|
158
|
+
`)),e.options.declaration&&zd(`${r}.${c}`,p,l)},w9=async e=>{const t=[],r=g9(e,t);for(const n of e.options.entries){const o=X(e.options.rootDir,e.options.outDir,n.name),s=wh(e.jiti.esmResolve(n.input,{try:!0})??n.input),i=s.replace(qi,""),a=Bi(s),l=NS(a);let u;try{u=await vh(s,{extensions:uo})}catch(f){Y(e,`Cannot analyze ${s} for exports: ${String(f)}`);return}const c=u.includes("default")||u.length===0,p=e.options.jiti.absoluteJitiPath?(...f)=>xh(X(...f)):Se;e.options.emitESM&&await $9(e,p,o,s,i,l,r,t,u,c),e.options.emitCJS&&await b9(e,p,o,s,i,l,r,t,c),l&&(await Ni(`${o}.${Pe(e,"cjs")}`),await Ni(`${o}.${Pe(e,"esm")}`))}await e.hooks.callHook("rollup:done",e)},Ta=e=>e.logger,no="rollup-watch.json",Fc=({context:e,doOnSuccessCleanup:t,fileCache:r,mode:n,runBuilder:o,runOnsuccess:s,useCache:i,watcher:a})=>{const l=`watcher:${n}`,u=Ta(e);a.on("change",async(c,{event:p})=>{try{await t?.()}catch(f){u.error({context:[f],message:`onSuccess cleanup failed: ${f.message}`,prefix:l})}u.info({message:`${re(Se(".",c))} was ${p}d`,prefix:l})}),a.on("restart",()=>{u.info({message:"Rebuilding ...",prefix:l})}),a.on("event",async c=>{try{switch(c.code){case"BUNDLE_END":{await c.result.close(),i&&r.set(n==="bundle"?no:`dts-${no}`,c.result.cache),u.raw(`
|
|
159
|
+
⚡️ Build run in ${String(c.duration)}ms
|
|
160
|
+
|
|
161
|
+
`),await o?.(!0);break}case"BUNDLE_START":{u.info({message:re("build started..."),prefix:l});break}case"END":{u.success({message:"Rebuild finished",prefix:l}),await s?.();break}case"ERROR":{Fu(c.error),u.error({context:[c.error],message:`Rebuild failed: ${c.error.message}`,prefix:l});break}}}catch(p){u.error({context:[p],message:`Watch handler failed: ${p.message}`,prefix:l})}})},v9=(e,t)=>{const r=[];Array.isArray(t.input)?r.push(...t.input):typeof t.input=="string"?r.push(t.input):r.push(...Object.keys(t.input??{}));let n="Starting watcher for entries:";for(const o of r)n+=De(`
|
|
162
|
+
└─ ${Se(process.cwd(),o)}`);Ta(e).info(n)},x9=(e,t,r)=>{const n=[G(e.options.sourceDir,"**","*"),"package.json","packem.config.*","tsconfig.json","tsconfig.*.json"],{include:o}=r;Array.isArray(o)?n.push(...o):o!==void 0&&n.push(o);const s=t.chokidar??{},i=["**/.git/**","**/node_modules/**","**/test-results/**",...s.ignored??[]];return{...t,...r,chokidar:{cwd:e.options.rootDir,...s,ignored:i},include:n}},E9=(e,t)=>{const r=e.options.rollup.watch;return!r||typeof t!="object"||t.include!==void 0?t:x9(e,t,r)},S9=e=>{const t=["**/.git/**","**/node_modules/**","**/test-results/**"],r=e.options.rollup.watch,n={exclude:t};return r&&typeof r=="object"&&(r.include!==void 0&&(n.include=r.include),r.exclude!==void 0&&t.push(...Array.isArray(r.exclude)?r.exclude:[r.exclude])),n},k9=async(e,t,r,n,o)=>{let s=[];const i=e.options.bundler==="rolldown",a=async()=>{await Promise.all(s.map(m=>m.close())),s=[]},l=async()=>{let m,h,y;if(i){const $=await jv(),g=await _d(e,t);if(await e.hooks.callHook("rollup:options",e,g),Object.keys(g.input??{}).length===0)return;g.watch=S9(e),m=$(g),h=g,y=!1}else{const $=await _c(),g=await Md(e,t);if(await e.hooks.callHook("rollup:options",e,g),Object.keys(g.input??{}).length===0)return;g.cache=t.get(no),g.watch=E9(e,g.watch),m=$(g),h=g,y=!0}if(await e.hooks.callHook("rollup:watch",e,m),v9(e,h),Fc({context:e,doOnSuccessCleanup:o,fileCache:t,mode:"bundle",runBuilder:r,runOnsuccess:n,useCache:y,watcher:m}),s.push(m),e.options.declaration){const $=await _c(),g=await Nd(e,t);g.cache=t.get(`dts-${no}`),await e.hooks.callHook("rollup:dts:options",e,g);const w=$(g);await e.hooks.callHook("rollup:watch",e,w),Fc({context:e,fileCache:t,mode:"types",useCache:!0,watcher:w}),s.push(w)}};await l();const u=G(e.options.rootDir,"package.json"),c=Gn.map(m=>G(e.options.rootDir,m));let p;const f=async(m,h)=>{const y=Ta(e);if(h){y.info({message:`${Se(".",m)} changed. Restart packem to apply configuration changes (the watcher cannot reload packem.config.* in place).`,prefix:"watcher"});return}y.info(`${Se(".",m)} changed, restarting watchers...`);try{await a();const{packageJson:$}=Fo(e.options.rootDir);e.pkg=$,e.options.entries.length=0,e.buildEntries.length=0,await e.hooks.callHook("build:prepare",e),Jd(e),await l()}catch($){y.error({message:`Failed to restart watchers: ${$.message}`,prefix:"watcher"})}},d=(m,h)=>{clearTimeout(p),p=setTimeout(()=>{f(m,h).catch(()=>{})},100)};Ha(u,()=>{d(u,!1)});for(const m of c)if(rt(m)){Ha(m,()=>{d(m,!0)});break}},j9=async e=>{if(e.options.clean){const t=e.logger,r=[];for(const n of new Set(e.options.entries.map(o=>o.outDir).filter(Boolean).toSorted((o,s)=>o.localeCompare(s))))n===e.options.rootDir||n===e.options.sourceDir||e.options.rootDir.startsWith(n.endsWith("/")?n:`${n}/`)||r.some(o=>n.startsWith(o))||(r.push(n),t.info(`Cleaning dist directory: \`./${Se(e.options.rootDir,n)}\``),await mm(n))}},A9=()=>Wh((e,t,r)=>{if(t==="hooks"&&typeof r=="object"&&r!==null&&!Array.isArray(r)){const n=typeof e[t]=="object"&&e[t]!==null&&!Array.isArray(e[t])?e[t]:{};return e[t]={...n,...r},!0}return!1}),O9=Ze,R9=(e,t)=>{const{sideEffects:r}=t;let n;if(typeof r=="boolean")n=()=>r;else if(Array.isArray(r))if(r.length<=0)n=()=>!1;else{const o=r.map(s=>s.includes("/")?s:`**/${s}`);n=O9(o,void 0,{resolve:e})}else n=()=>{};return n};var ei,Hc;function C9(){if(Hc)return ei;Hc=1;var e=Bh,t=e.spawn,r=e.exec;ei=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 u={},c={};switch(u[i]=[],c[i]=1,process.platform){case"win32":r("taskkill /pid "+i+" /T /F",l);break;case"darwin":s(i,u,c,function(p){return t("pgrep",["-P",p])},function(){n(u,a,l)});break;default:s(i,u,c,function(p){return t("ps",["-o","pid","--no-headers","--ppid",p])},function(){n(u,a,l)});break}};function n(i,a,l){var u={};try{Object.keys(i).forEach(function(c){i[c].forEach(function(p){u[p]||(o(p,a),u[p]=1)}),u[c]||(o(c,a),u[c]=1)})}catch(c){if(l)return l(c);throw c}if(l)return l()}function o(i,a){try{process.kill(parseInt(i,10),a)}catch(l){if(l.code!=="ESRCH")throw l}}function s(i,a,l,u,c){var p=u(i),f="";p.stdout.on("data",function(h){var h=h.toString("ascii");f+=h});var d=function(m){if(delete l[i],m!=0){Object.keys(l).length==0&&c();return}f.match(/\d+/g).forEach(function(h){h=parseInt(h,10),a[i].push(h),a[h]=[],l[h]=1,s(h,a,l,u,c)})};p.on("close",d)}return ei}var T9=C9();const N9=Zr(T9),P9=e=>process.platform==="win32"&&"cmd"in e&&"code"in e&&typeof e.cmd=="string"&&e.cmd.startsWith("taskkill")&&e.code===128,M9=async({pid:e,signal:t})=>{await new Promise((r,n)=>{if(!Number.isInteger(e)||e<=0){n(new Error("Invalid process ID"));return}N9(e,t,o=>{if(o&&!P9(o)){n(o);return}r()})})},qc=(e,t)=>{if(e.warnings.size>0){const r=e.logger;if(t&&r.raw(`
|
|
163
|
+
`),r.warn(`Build is done with some warnings:
|
|
164
|
+
|
|
165
|
+
${Array.from(e.warnings,n=>`- ${n}`).join(`
|
|
166
|
+
`)}`),e.options.failOnWarn)throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")}},_9=async(e,t,r,n)=>{try{await po(G(e,t),{force:!0,recursive:!0})}catch(o){return r.error({message:`Failed to remove cache directory ${t}: ${o instanceof Error?o.message:String(o)}`,prefix:"file-cache"}),n}return n&&r.raw(`
|
|
167
|
+
`),r.info({message:`Removing ${t} file cache, the cache key is not used anymore.`,prefix:"file-cache"}),!1},I9=async(e,t,r)=>{if(!e)return;const n=G(e,"keystore.json");if(!await Ct(n))return;const o=await lo(n),s=(await hh(e,{withFileTypes:!0})).filter(a=>a.isDirectory());let i=r;for(const a of s)o[a.name]||(i=await _9(e,a.name,t,i))},Jc=(e,t)=>{for(const r of hi(e??[]))if(typeof r=="string"&&r.startsWith("node")){const n=Le.coerce(r.slice(4));n&&t.push(n.version)}},W9=e=>{if(e.options.runtime!=="node"||!e.options.emitCJS)return;const t=[],r=e.pkg.engines?.node,n=r?Le.minVersion(r):void 0;n&&t.push(n.version);const o=e.options.rollup;if(Jc(o.esbuild?.target,t),Jc(o.oxc?.target,t),t.length===0){const s=Le.coerce(Dn.node);s&&t.push(s.version)}t.some(s=>Le.satisfies(s,">=23.0.0 || >=22.12.0"))&&e.logger.warn(["We recommend using the ESM format instead of CommonJS.","The ESM format is compatible with modern platforms and runtimes, and most new libraries are now distributed only in ESM format.","Learn more at https://nodejs.org/en/learn/modules/publishing-a-package#how-did-we-get-here"].join(`
|
|
168
|
+
`))},B9=_e(import.meta.url),Vt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:pt,Na=e=>{if(typeof Vt<"u"&&Vt.versions&&Vt.versions.node){const[t,r]=Vt.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return Vt.getBuiltinModule(e)}return B9(e)},pt=Vt,{execFileSync:D9}=Na("node:child_process"),Ir=Na("node:fs"),L9=Na("node:tty"),Pa=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],Ma=[12288,12288,65281,65376,65504,65510],_a=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],Ia=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],Ho=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],cn=(e,t)=>{let r=0,n=Math.floor(e.length/2)-1;for(;r<=n;){const o=Math.floor((r+n)/2),s=o*2;if(t<e[s])n=o-1;else if(t>e[s+1])r=o+1;else return!0}return!1},F9=Pa[0],H9=Pa.at(-1),q9=Ma[0],J9=Ma.at(-1),z9=_a[0],U9=_a.at(-1),G9=Ia[0],V9=Ia.at(-1),K9=Ho[0],Y9=Ho.at(-1),zc=19968,[X9,Z9]=Q9(Ho);function Q9(e){let t=e[0],r=e[1];for(let n=0;n<e.length;n+=2){const o=e[n],s=e[n+1];if(zc>=o&&zc<=s)return[o,s];s-o>r-t&&(t=o,r=s)}return[t,r]}const e8=e=>e<F9||e>H9?!1:cn(Pa,e),t8=e=>e<q9||e>J9?!1:cn(Ma,e),r8=e=>e<z9||e>U9?!1:cn(_a,e),n8=e=>e<G9||e>V9?!1:cn(Ia,e),o8=e=>e>=X9&&e<=Z9?!0:e<K9||e>Y9?!1:cn(Ho,e);function s8(e){return e8(e)?"ambiguous":t8(e)?"fullwidth":r8(e)?"halfwidth":n8(e)?"narrow":o8(e)?"wide":"neutral"}function i8(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Ud(e){return i8(e),s8(e)}const Gd=String.raw,Uc=Gd`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,a8=()=>new RegExp(Gd`\p{RI}{2}|(?)${Uc}(?:\u200D${Uc})*`,"gu"),mr=new Set(["\x1B",""]),qo="\x07",Vd="[",Wa="m",oo="]8;;",l8=39,c8=/[\u200B\uFEFF\u2060-\u2064]/g,u8=new RegExp(`(?:\\${Vd}(?<code>\\d+)m|\\${oo}(?<uri>.*)${qo})`),p8=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),St=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,Gc=/\u001B\[(\d+(?:;\d+)*)?m[^\u001B]*(?:\u001B\[(?:\d+(?:;\d+)*)?m|$)/g,Vc=/\u001B\]8;[^\u0007\u001B]*(?:\u0007|\u001B\\)(.*?)\u001B\]8;;(?:\u0007|\u001B\\)/g,wn=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,ti=a8(),Kc=new Map,vn=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Wn=e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other",f8=(e,t)=>{const r=Math.floor(e/65536),n=e%65536;let o=Kc.get(r);if(o||(o=new Map,Kc.set(r,o)),o.has(n))return o.get(n);let s;if(Wn(e)==="latin")s=t.width.regular;else if(Wn(e)==="control")s=t.width.control;else if(Wn(e)==="wide")s=t.width.wide;else switch(Ud(e)){case"ambiguous":{s=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{s=t.width.fullWidth;break}case"wide":{s=t.width.wide;break}default:s=t.width.regular}return o.set(n,s),s},d8=e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,sr=(e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const r={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?sr(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},n=Math.max(0,r.truncation.limit-r.truncation.ellipsisWidth),{length:o}=e,s=o>1e4;let i=0,a=0,l=o,u=!1;const c=e.includes("\x1B")||e.includes("");for(;i<o;){if(c&&(e[i]==="\x1B"||e[i]==="")){if(e.startsWith("\x1B]8;;",i)){const y="\x1B]8;;\x07",$=y.length,g=e.indexOf("\x07",i+5);if(g!==-1){const w=e.indexOf(y,g+1);if(w!==-1){const b=w+$,v=e.slice(g+1,w).replace(St,""),S=sr(v,{ambiguousIsNarrow:r.width.ambiguousIsNarrow,ansiWidth:r.width.ansi,controlWidth:r.width.control,countAnsiEscapeCodes:!1,ellipsis:r.truncation.ellipsis,ellipsisWidth:r.truncation.ellipsisWidth,emojiWidth:r.width.emoji,fullWidth:r.width.fullWidth,halfWidth:r.width.halfWidth,limit:Math.max(0,n-a),regularWidth:r.width.regular,tabWidth:r.width.tab,wideWidth:r.width.wide}),x=S.width;if(S.truncated)u=!0,l=Math.min(l,i);else if(a+x>n&&(l=Math.min(l,i),u=!0,a+x>r.truncation.limit))break;if(a+=x,i=b,u&&a>=r.truncation.limit)break;continue}}}if(St.lastIndex=i,St.test(e)){const y=St.lastIndex-i,$=r.truncation.countAnsiEscapeCodes?y:r.width.ansi;if(a+$>n&&(l=Math.min(l,i),a+$>r.truncation.limit)){u=!0;break}a+=$,i=St.lastIndex;continue}}const d=e.codePointAt(i);if(d===8203||d===65279||d>=8288&&d<=8292){i+=1;continue}if(d===9){if(a+r.width.tab>n&&(l=Math.min(l,i),a+r.width.tab>r.truncation.limit)){u=!0;break}a+=r.width.tab,i+=1;continue}if(vn.lastIndex=i,vn.test(e)){const y=(vn.lastIndex-i)*r.width.regular;if(a+y>n){const $=Math.floor((n-a)/r.width.regular);if(l=Math.min(l,i+$),a+y>r.truncation.limit){u=!0;break}}a+=y,i=vn.lastIndex;continue}if((d<=31||d>=127&&d<=159)&&(wn.lastIndex=i,wn.test(e))){const y=(wn.lastIndex-i)*r.width.control;if(a+y>n&&(l=Math.min(l,i+Math.floor((n-a)/r.width.control)),a+y>r.truncation.limit)){u=!0;break}a+=y,i=wn.lastIndex;continue}if(ti.lastIndex=i,ti.test(e)){if(a+r.width.emoji>n&&(l=Math.min(l,i),a+r.width.emoji>r.truncation.limit)){u=!0;break}a+=r.width.emoji,i=ti.lastIndex;continue}const m=e.codePointAt(i)??0;if(d8(m)){i+=m>65535?2:1;continue}let h;if(s)h=f8(m,r);else switch(Wn(m)){case"control":{h=r.width.control;break}case"latin":{h=r.width.regular;break}case"wide":{h=r.width.wide;break}case"zero":{h=0;break}default:switch(Ud(m)){case"ambiguous":{h=r.width.ambiguousIsNarrow?r.width.regular:r.width.wide;break}case"fullwidth":{h=r.width.fullWidth;break}case"wide":{h=r.width.wide;break}default:h=r.width.regular}}if(a+h>n&&(l=Math.min(l,i),a+h>r.truncation.limit)){u=!0;break}a+=h,i+=m>65535?2:1}let p=a,f=!1;return u&&r.truncation.limit>=r.truncation.ellipsisWidth&&(p=r.truncation.limit,f=!0),{ellipsed:f,index:u?l:o,truncated:u,width:p}},fe=(e,t={})=>sr(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width;let m8=class{capacity;cache;keyOrder;constructor(t){this.capacity=t,this.cache=new Map,this.keyOrder=[]}get(t){if(this.cache.has(t))return this.keyOrder=this.keyOrder.filter(r=>r!==t),this.keyOrder.push(t),this.cache.get(t)}has(t){return this.cache.has(t)}set(t,r){if(this.cache.has(t))this.keyOrder=this.keyOrder.filter(n=>n!==t);else if(this.cache.size>=this.capacity){const n=this.keyOrder.shift();n!==void 0&&this.cache.delete(n)}this.cache.set(t,r),this.keyOrder.push(t)}delete(t){this.cache.delete(t),this.keyOrder=this.keyOrder.filter(r=>r!==t)}clear(){this.cache.clear(),this.keyOrder=[]}size(){return this.cache.size}};const Yc=new m8(100),h8=new Intl.Segmenter("en",{granularity:"grapheme"}),g8=/^[\u0000-\u007F]*$/,y8=new Set(["0","22","23","24","27","28","29","39","49"]),$8=new Set(["1","3","4","7","8","9"]),Xc=new Map([["22","1"],["23","3"],["24","4"],["27","7"],["28","8"],["29","9"]]),xn=e=>e>="30"&&e<="37"||e>="90"&&e<="97"||e.startsWith("38;"),En=e=>e>="40"&&e<="47"||e>="100"&&e<="107"||e.startsWith("48;"),b8=[{close:"\x1B[22m",open:"\x1B[1m"},{close:"\x1B[23m",open:"\x1B[3m"},{close:"\x1B[24m",open:"\x1B[4m"},{close:"\x1B[27m",open:"\x1B[7m"},{close:"\x1B[28m",open:"\x1B[8m"},{close:"\x1B[29m",open:"\x1B[9m"}],Zc=(e,t)=>{let r=-1;for(const n of t){const o=e.indexOf(n);o!==-1&&(r===-1||o<r)&&(r=o)}return r},w8=(e,t)=>{if(!e.includes("\x1B"))return[{after:"",before:"",content:e,visibleLength:fe(e,t.width)}];const r=Yc.get(e);if(r)return r;const n=[],o=[];let s=0,i;for(St.lastIndex=0;(i=St.exec(e))!==null;){const c=i[0];n.push(e.slice(s,i.index)),o.push(c),s=i.index+c.length}s<e.length&&n.push(e.slice(s));const a=[];for(const c of o){if(c==="\x1B[0m"||c==="\x1B]8;;\x07"){a.push(c);continue}if(c.startsWith("\x1B[")&&c.endsWith("m")){const p=c.slice(2,-1);if(y8.has(p)){a.push(c);continue}}}const l=new Set,u=[];for(const[c,p]of n.entries()){if(c>0&&o[c-1]){const m=o[c-1];if(m==="\x1B[0m")l.clear();else if(m==="\x1B]8;;\x07"){for(const h of l)if(h.startsWith("\x1B]8;;")&&!h.endsWith("\x1B]8;;\x07")){l.delete(h);break}}else if(m.startsWith("\x1B[")&&m.endsWith("m")){const h=m.slice(2,-1);if(h==="39"){for(const y of l)if(y.startsWith("\x1B[")&&y.endsWith("m")){const $=y.slice(2,-1);if(xn($)){l.delete(y);break}}}else if(h==="49"){for(const y of l)if(y.startsWith("\x1B[")&&y.endsWith("m")){const $=y.slice(2,-1);if(En($)){l.delete(y);break}}}else if(Xc.has(h)){const y=Xc.get(h);for(const $ of l)if($===`\x1B[${y}m`){l.delete($);break}}else{if(xn(h)){for(const y of l)if(y.startsWith("\x1B[")&&y.endsWith("m")){const $=y.slice(2,-1);if(xn($)){l.delete(y);break}}}else if(En(h)){for(const y of l)if(y.startsWith("\x1B[")&&y.endsWith("m")){const $=y.slice(2,-1);if(En($)){l.delete(y);break}}}else if($8.has(h)){const y=`\x1B[${h}m`;l.has(y)&&l.delete(y)}l.add(m)}}else if(m.startsWith("\x1B]8;;")&&!m.endsWith("\x1B]8;;\x07")){for(const h of l)if(h.startsWith("\x1B]8;;")&&!h.endsWith("\x1B]8;;\x07")){l.delete(h);break}l.add(m)}}if(p==="")continue;let f="";if(l.size>0)if(a.includes("\x1B[0m"))f="\x1B[0m";else{const m=[];let h=!1;for(const w of l)if(w.startsWith("\x1B]8;;")&&!w.endsWith("\x1B]8;;\x07")){h=!0;break}h&&a.includes("\x1B]8;;\x07")&&m.push("\x1B]8;;\x07");let y=!1,$=!1;for(const w of l)if(w.startsWith("\x1B[")&&w.endsWith("m")){const b=w.slice(2,-1);xn(b)?y=!0:En(b)&&($=!0)}if(y&&$){const w=Zc(e,["\x1B[3","\x1B[9","\x1B[38;"]),b=Zc(e,["\x1B[4","\x1B[10","\x1B[48;"]);w>=0&&b>=0?w>b?m.push("\x1B[39m","\x1B[49m"):m.push("\x1B[49m","\x1B[39m"):m.push("\x1B[39m","\x1B[49m")}else y&&m.push("\x1B[39m"),$&&m.push("\x1B[49m");y&&$&&e.includes("\x1B[39m")&&e.includes("\x1B[49m")&&(e.indexOf("\x1B[39m")<e.indexOf("\x1B[49m")?(m.length-=2,m.push("\x1B[39m","\x1B[49m")):e.indexOf("\x1B[49m")<e.indexOf("\x1B[39m")&&(m.length-=2,m.push("\x1B[49m","\x1B[39m")));const g=b8.filter(w=>l.has(w.open)).map(w=>({position:e.indexOf(w.open),style:w})).filter(w=>w.position>=0).toSorted((w,b)=>b.position-w.position);for(const w of g){const b=w;a.includes(b.style.close)&&m.push(b.style.close)}f=m.join("")}const d=[...l].join("");u.push({after:f,before:d,content:p,visibleLength:fe(p,{fullWidth:1,wideWidth:1})})}return Yc.set(e,u),u},v8=(e,t,r,n)=>{const o=[...n.segmenter.segment(e)],s=[];let i=0,a=!1;for(const l of o){const u=fe(l.segment,n.width),c=i,p=i+u;if(!a)if(c<t){i=p;continue}else a=!0;if(c>=r||p>r)break;s.push(l.segment),i=p}return s.join("")},ct=(e,t=0,r=Number.MAX_SAFE_INTEGER,n={})=>{const o={segmenter:h8,...n};if(t>=r||e==="")return"";const s=fe(e,o.width);if(t===0&&r>=s)return e;if(t<0||r<0)throw new RangeError("Negative indices aren't supported");if(!e.includes("\x1B"))return g8.test(e)?e.slice(t,r):v8(e,t,r,o);if(Gc.lastIndex=0,Vc.lastIndex=0,!Gc.test(e)&&!Vc.test(e))return e;const i=w8(e,o);if(i.length===0)return"";let a=0;const l=[];for(const[p,f]of i.entries()){const d=a,m=a+f.visibleLength;if(m>t&&d<r){const h=Math.max(0,t-d),y=Math.min(f.visibleLength,r-d);l.push({end:y,index:p,segment:f,start:h})}a=m}if(l.length===0)return"";const u=[],c=l[0].segment;u.push(c.before);for(let p=0;p<l.length;p++){const{end:f,segment:d,start:m}=l[p];if(m===0&&f===d.visibleLength)u.push(d.content);else{const h=[...o.segmenter.segment(d.content)];u.push(h.slice(m,f).map(y=>y.segment).join(""))}if(p<l.length-1){const h=l[p+1].segment,y=d.after,$=h.before;y!==$&&(y||$)&&u.push(y,$)}}return u.push(l.at(-1).segment.after),u.join("")},Qc="…",x8=3,Sn=(e,t,r=!1)=>{if(e.charAt(t)===" ")return t;const n=r?1:-1,o=Math.min(x8,r?e.length-t:t);for(let s=1;s<=o;s++){const i=t+s*n;if(e.charAt(i)===" ")return i}return t},kn=(e,t,r)=>sr(e,{...r,ellipsis:"",ellipsisWidth:0,limit:t}).index,jn=(e,t,r)=>fe(e.slice(0,t),r),eu=(e,t,r={})=>{if(typeof e!="string")throw new TypeError(`Expected \`input\` to be a string, got ${typeof e}`);if(typeof t!="number")throw new TypeError(`Expected \`limit\` to be a number, got ${typeof t}`);if(e===""||t<=0)return"";const n=e.normalize("NFC"),{ellipsis:o=Qc,position:s="end",preferTruncationOnSpace:i=!1}=r;let a=r.ellipsisWidth??o===Qc?1:void 0;a??=sr(o,{...r.width,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width;const{width:l}=sr(n,{...r.width,ellipsis:o,ellipsisWidth:a});if(l<=t)return n;switch(s){case"end":{if(i){const u=t-a,c=kn(n,u,r.width),p=Sn(n,c),f=jn(n,p,r.width);return ct(n,0,f,{width:r.width})+o}return ct(n,0,t-a,{width:r.width})+o}case"middle":{const u=Math.floor(t/2),c=Math.max(0,t-a),p=Math.min(u,c),f=Math.max(0,c-p);if(i){const d=kn(n,p,r.width),m=Sn(n,d),h=jn(n,m,r.width),y=l-f,$=kn(n,y,r.width),g=Sn(n,$,!0),w=jn(n,g,r.width);return ct(n,0,h,{width:r.width})+o+ct(n,w,l,{width:r.width}).trim()}return ct(n,0,p,{width:r.width})+o+ct(n,l-f,l,{width:r.width})}case"start":{if(i){const u=l-t+a,c=kn(n,u,r.width),p=Sn(n,c,!0),f=jn(n,p,r.width);return o+ct(n,f,l,{width:r.width}).trim()}return o+ct(n,l-t+a,l,{width:r.width})}default:throw new Error(`Invalid position: expected 'start', 'middle' or 'end', got '${s}'`)}},E8=/\x1B\[(\d+)m/;class Kd{activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(t){const r=E8.exec(t);if(!r)return;const n=Number.parseInt(r[1],10);switch(n){case 0:{this.activeForeground=void 0,this.activeBackground=void 0,this.activeFormatting=[];break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}default:if(n>=30&&n<=37||n>=90&&n<=97)this.activeForeground=t;else if(n>=40&&n<=47||n>=100&&n<=107)this.activeBackground=t;else if([1,2,3,4,7,8,9].includes(n))this.activeFormatting.push(t);else if([22,23,24,27,28,29].includes(n)){const o={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[n];o&&(this.activeFormatting=this.activeFormatting.filter(s=>!s.includes(o)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const t=[];if(this.activeFormatting.length>0){const r={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].toReversed().forEach(n=>{const o=r[n];o&&t.push(o)})}return this.activeForeground&&t.push("\x1B[39m"),this.activeBackground&&t.push("\x1B[49m"),t.join("")}}const Yd=(e,t)=>{if(!mr.has(e[t]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const r=!0,n=e.slice(t+1,t+1+oo.length).join("")===oo;return{isInsideEscape:r,isInsideLinkEscape:n}},S8=(e,t={})=>{const r=new Kd;let n="",o=!1,s="",i="",a=!1;const l=[...e];for(let u=0;u<l.length;u++){const c=l[u];if(c&&mr.has(c)){if(n){const h=t.getWidth?.(n)??0,y={isEscapeSequence:!1,isGrapheme:!0,text:n,width:h};if(a&&(y.isHyperlink=!0,y.hyperlinkUrl=i),t.onSegment?.(y,r)===!1)return;n=""}o=!0,s=c;const d=Yd(l,u),{isInsideLinkEscape:m}=d;if(m){let h=u+1;for(i="";h<l.length;){const $=l[h];if($===qo)break;i+=$,h+=1}i=i.slice(4);const y={hyperlinkUrl:i,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(t.onSegment?.(y,r)===!1)return;u=h,a=!0,o=!1,s="";continue}if(u+1<l.length&&l[u+1]==="\\"&&a){const h={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(t.onSegment?.(h,r)===!1)return;a=!1,i="",u+=1,o=!1,s="";continue}}if(o){if(s!==c&&(s+=c),c===Wa){o=!1,r.processEscape(s);const d={isEscapeSequence:!0,isGrapheme:!1,text:s,width:0};if(t.onSegment?.(d,r)===!1)return;s=""}continue}n+=c;const p=t.getWidth?.(n)??0,f={isEscapeSequence:!1,isGrapheme:!0,text:n,width:p};if(a&&(f.isHyperlink=!0,f.hyperlinkUrl=i),t.onSegment?.(f,r)===!1)return;n=""}if(n){const u=t.getWidth?.(n)??0,c={isEscapeSequence:!1,isGrapheme:!0,text:n,width:u};a&&(c.isHyperlink=!0,c.hyperlinkUrl=i),t.onSegment?.(c,r)}if(s){const u={isEscapeSequence:!0,isGrapheme:!1,text:s,width:0};t.onSegment?.(u,r)}},tu=e=>`${mr.values().next().value}${Vd}${String(e)}${Wa}`,ru=e=>`${mr.values().next().value}${oo}${e}${qo}`,k8=e=>{if(e.length===0)return"";if(e.length===1)return e[0];let t="",r,n;const o=e.join(`
|
|
169
|
+
`),s=[...o];let i=0;for(const[a,l]of s.entries()){if(t+=l,mr.has(l)){const c=u8.exec(o.slice(i))?.groups??{};if(c.code!==void 0){const p=Number.parseFloat(c.code);r=p===l8?void 0:p}else c.uri!==void 0&&(n=c.uri.length===0?void 0:c.uri)}const u=p8.get(Number(r));s[a+1]===`
|
|
170
|
+
`?(n&&(t+=ru("")),r&&u&&(t+=tu(u))):l===`
|
|
171
|
+
`&&(r&&u&&(t+=tu(r)),n&&(t+=ru(n))),i+=l.length}return t},Xd=/(?=\s)|(?<=\s)/,Zd=/^\s+$/,ri=e=>{if(!e.includes("\x1B"))return e;let t=e;return e.includes("\x1B[30m")&&(t+="\x1B[39m"),e.includes("\x1B[42m")&&(t+="\x1B[49m"),t},Rt=e=>{const t=e.split(" ");let r=t.length;for(;r>0&&fe(t[r-1])===0;)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Qd=(e,t,r)=>{if(e.length===0)return[""];if(t<=0)return[e];const n=[],o=new Kd;let s="",i=0,a=!1,l=!1,u="",c=0;for(;c<e.length;){const p=e[c];if(mr.has(p)){a=!0,u=p,s+=p,l=Yd([...e],c).isInsideLinkEscape,c+=1;continue}if(a){u+=p,s+=p,l?p===qo&&(a=l=!1):p===Wa&&(a=!1,o.processEscape(u)),c+=1;continue}const f=fe(p),d=p===" ";if(f===0){s+=p,c+=1;continue}if(i+f>t&&(s&&n.push(s+o.getEndEscapesForAllActiveAttributes()),s=o.getStartEscapesForAllActiveAttributes(),i=fe(s),d&&r)){for(;c<e.length&&e[c]===" ";)c+=1;continue}if(s+=p,i+=f,i===t&&c<e.length-1&&(n.push(s+o.getEndEscapesForAllActiveAttributes()),s=o.getStartEscapesForAllActiveAttributes(),i=fe(s),c+1<e.length&&e[c+1]===" "&&r)){for(c+=1;c<e.length&&e[c]===" ";)c+=1;continue}c+=1}return s&&n.push(s+o.getEndEscapesForAllActiveAttributes()),r?n.map(p=>Rt(p)):n},j8=(e,t,r)=>{if(e.length===0)return[];const n=r?e.trim():e;if(n.length===0)return[];const o=[];let s="",i=0;return S8(n,{getWidth:fe,onSegment:(a,l)=>{const u=a.text??"";if(a.isEscapeSequence)s+=u;else{const c=u===" ";if(a.width===0)return s+=u,!0;if(i+a.width>t&&(s&&o.push(s),s=l.getStartEscapesForAllActiveAttributes(),i=0,c))return r||o.push(l.getStartEscapesForAllActiveAttributes()+u),!0;s+=u,i+=a.width}return!0}}),s&&o.push(s),r?o.map(a=>Rt(a)):o},A8=(e,t,r)=>{if(e.length===0)return[];const n=r?e.trim():e;if(n.length===0)return[];const o=n.split(Xd),s=[];let i="",a=0,l=0;for(;l<o.length;){const u=o[l],c=Zd.test(u),p=fe(u);if(u.length===0){l+=1;continue}if(r&&c&&a===0){l+=1;continue}if(a+p>t&&a>0){r?s.push(Rt(i)):s.push(i),i="",a=0;continue}i+=u,a+=p,l+=1}return i&&(r?s.push(Rt(i)):s.push(i)),s},O8=(e,t,r)=>{if(e.length===0)return[];const n=r?e.trim():e;if(n.length===0)return[];const o=n.split(Xd),s=[];let i="",a=0,l=0;for(;l<o.length;){const u=o[l],c=Zd.test(u),p=fe(u);if(u.length===0){l+=1;continue}if(r&&c&&a===0){l+=1;continue}if(p>t){i&&s.push(ri(r?Rt(i):i));const f=Qd(u,t,r);if(f.length>0){for(let d=0;d<f.length-1;d+=1)s.push(f[d]);i=f.at(-1),a=fe(i)}else i="",a=0;l+=1;continue}if(a+p>t&&a>0&&(s.push(ri(r?Rt(i):i)),i="",a=0,r&&c)){l+=1;continue}i+=u,a+=p,l+=1}return i&&s.push(ri(r?Rt(i):i)),s},An={BREAK_AT_CHARACTERS:"BREAK_AT_CHARACTERS",BREAK_WORDS:"BREAK_WORDS",PRESERVE_WORDS:"PRESERVE_WORDS",STRICT_WIDTH:"STRICT_WIDTH"},R8=(e,t={})=>{const{removeZeroWidthCharacters:r=!0,trim:n=!0,width:o=80,wrapMode:s=An.PRESERVE_WORDS}=t;if(n&&e.trim()==="")return"";let i=e.normalize("NFC").replaceAll(`\r
|
|
172
|
+
`,`
|
|
173
|
+
`);return r&&(i=i.replaceAll(c8,"")),i.split(`
|
|
174
|
+
`).map(a=>{if(n&&a.trim()==="")return"";let l;switch(s){case An.BREAK_AT_CHARACTERS:{l=j8(a,o,n);break}case An.BREAK_WORDS:{l=O8(a,o,n);break}case An.STRICT_WIDTH:{l=Qd(a,o,n);break}default:l=A8(a,o,n)}return k8(l)}).join(`
|
|
175
|
+
`)},em=80,tm=24,Mi=(e,t,{shell:r,env:n}={})=>D9(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:r,env:n}).trim(),Bn=(e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),rm=(e,t)=>{const{columns:r,rows:n}=Bn(e,t);if(!(Number.isNaN(r)||Number.isNaN(n))&&!(r===em&&n===tm))return{columns:r,rows:n}},C8=()=>{if(pt.platform!=="linux")return!0;try{const e=Ir.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const r=e.slice(t+2).trim().split(/\s+/),n=Number.parseInt(r[2],10),o=Number.parseInt(r[5],10);return Number.isNaN(n)||Number.isNaN(o)||o<=0?!1:n===o}catch{return!1}};function T8(){const{env:e,stdout:t,stderr:r}=pt;if(t?.columns&&t?.rows)return Bn(t.columns,t.rows);if(r?.columns&&r?.rows)return Bn(r.columns,r.rows);if(e.COLUMNS&&e.LINES)return Bn(e.COLUMNS,e.LINES);const n={columns:em,rows:tm};return pt.platform==="win32"?ni()??n:pt.platform==="darwin"?nu()??ni()??n:nu()??ni()??N8()??n}const nu=()=>{try{const e=pt.platform==="darwin"?Ir.constants.O_EVTONLY|Ir.constants.O_NONBLOCK:Ir.constants.O_NONBLOCK,{columns:t,rows:r}=L9.WriteStream(Ir.openSync("/dev/tty",e));return{columns:t,rows:r}}catch{}},ni=()=>{try{const e=Mi("tput",["cols"],{env:{TERM:"dumb",...pt.env}}),t=Mi("tput",["lines"],{env:{TERM:"dumb",...pt.env}});if(e&&t)return rm(e,t)}catch{}},N8=()=>{try{if(!C8())return;const e=Mi("resize",["-u"]).match(/\d+/g);if(e.length===2)return rm(e[0],e[1])}catch{}},Lt=(e,t)=>{switch(t){case"bottom":return{body:e.bottomBody,join:e.bottomJoin,left:e.bottomLeft,right:e.bottomRight};case"middle":return{body:e.joinBody,join:e.joinJoin,left:e.joinLeft,right:e.joinRight};case"top":return{body:e.topBody,join:e.topJoin,left:e.topLeft,right:e.topRight};default:throw new Error(`Invalid borderType: ${String(t)}`)}},P8=e=>({join:e.bodyJoin,left:e.bodyLeft,right:e.bodyRight}),so=(e,t,r)=>{let n=0;for(let o=0;o<r;o+=1)n+=e[t+o]??0;return r>1&&(n+=r-1),n},_i=(e,t,r,n)=>{let o=t;for(;o>0&&e[o-1]?.[r]===n;)o-=1;let s=t;for(;s<e.length-1&&e[s+1]?.[r]===n;)s+=1;let i;const a=s-o+1;if(a===1)i=!0;else switch(n.vAlign){case"bottom":{i=t===s;break}case"middle":{const l=o+Math.floor(a/2);i=t===l;break}case"top":{i=t===o;break}default:i=t===o}return{firstRow:o,lastRow:s,showContent:i}},M8=(e,t,r,n,o)=>{if(e.length===0)return[];let s=e.length-1;for(let l=0;l<e.length;l+=1){const u=e[l];if(u){for(const[c,p]of u.entries())if(p&&o(e,l,c,p)===l){const f=_i(e,l,c,p);s=Math.max(s,f.lastRow)}}}const i=Array.from({length:s+1}).fill(1);for(let l=0;l<e.length;l+=1){const u=e[l];if(u)for(let c=0;c<r.columns;c+=1){const p=u[c];if(p&&o(e,l,c,p)===l&&(p.rowSpan??1)===1){const f=p.colSpan??1,d=so(t,c,f),m=n(p,d).length;i[l]=Math.max(i[l]??1,m)}}}const a=Array.from({length:i.length}).fill(!1);if(r.fixedRowHeights)for(let l=0;l<i.length;l+=1){let u;r.fixedRowHeights[l]!==void 0?u=r.fixedRowHeights[l]:r.fixedRowHeights.length===1&&r.fixedRowHeights[0]!==void 0&&(u=r.fixedRowHeights[0]),u!==void 0&&(i[l]=Math.max(1,u),a[l]=!0)}for(let l=0;l<e.length;l+=1){const u=e[l];if(u)for(let c=0;c<r.columns;c+=1){const p=u[c];if(p&&o(e,l,c,p)===l&&(p.rowSpan??1)>1){const f=p.colSpan??1,d=so(t,c,f),m=n(p,d).length-1,h=_i(e,l,c,p),{firstRow:y,lastRow:$}=h;let g=0,w=0;for(let v=y;v<=$&&v<i.length;v+=1)g+=i[v]??1,a[v]||(w+=1);const b=m-g;if(b>0)if(w>0){const v=Math.ceil(b/w);let S=0;for(let x=y;x<=$&&x<i.length;x+=1)if(!a[x]){const E=Math.min(v,b-S);if(i[x]=(i[x]??1)+E,S+=E,S>=b)break}}else console.warn(`[calculateRowHeights] Content of spanning cell exceeds fixed height allocated. Cell: ${JSON.stringify(p.content)}, Required: ${String(m)}, Allocated: ${String(g)} (fixed).`)}}}return i},Ft=(e,t,r,n)=>{let o=t;for(;o>0&&e[o-1]?.[r]===n;)o-=1;return o},Ii="__EMPTY__",ou=e=>{if(typeof e=="string")return{content:e};if(typeof e=="number"||typeof e=="bigint"||typeof e=="boolean")return{content:String(e)};if(e==null)return{content:Ii};if(typeof e=="object"&&"content"in e){let{content:t}=e;if(typeof t=="number"||typeof t=="bigint"||typeof t=="boolean")t=String(t);else if(t==null)t=Ii;else if(typeof t!="string")throw new TypeError(`Invalid item type in grid cell: expected string, number, null, undefined, or GridItem object, but received ${JSON.stringify(e)} (type: ${typeof e})`);return{...e,content:t}}throw new TypeError(`Invalid item type in grid cell: expected string, number, null, undefined, or GridItem object, but received ${JSON.stringify(e)} (type: ${typeof e})`)},_8=(e,t,r,n,o)=>{const s=fe(e),i=" ".repeat(Math.max(0,n)),a=" ".repeat(Math.max(0,o));if(s===0)return i+" ".repeat(Math.max(0,t))+a;const l=Math.max(0,t-s);switch(r){case"center":{const u=Math.floor(l/2),c=l-u;return i+" ".repeat(u)+e+" ".repeat(c)+a}case"right":return i+" ".repeat(l)+e+a;default:return i+e+" ".repeat(l)+a}},Cr=/\r?\n/,su=/\s+/,te=(e,t)=>!e||!t?e:typeof t=="function"?t(e):t.open+e+t.close;class Ba{#e;#o=[];#t;#s=new WeakMap;#r=new WeakMap;static createGridLayout(){return[]}constructor(t){const r={autoColumns:1,autoFlow:"row",autoRows:1,balancedWidths:!1,gap:0,paddingLeft:1,paddingRight:1,rows:0,showBorders:t.border!==void 0,truncate:!1,truncateOverflow:!0,wordWrap:!1};let n;Array.isArray(t.fixedRowHeights)?n=t.fixedRowHeights:typeof t.fixedRowHeights=="number"&&(n=[t.fixedRowHeights]),this.#e={...r,...t,columns:t.columns,fixedRowHeights:n,showBorders:t.border!==void 0||(t.showBorders??!1)};let{terminalWidth:o}=this.#e;if(o===void 0){const{columns:s}=T8();o=s}this.#t=o,this.#e.maxWidth&&(this.#e.maxWidth=Math.min(this.#e.maxWidth,this.#t))}addItem(t){return this.#o.push(ou(t)),this}addItems(t){return this.#o.push(...t.map(r=>ou(r))),this}setColumns(t){return this.#e.columns=t,this}setRows(t){return this.#e.rows=t,this}setBorder(t){return this.#e.border=t,this}setShowBorders(t){return this.#e.showBorders=t,this}setMaxWidth(t){return this.#e.maxWidth=t,this}toString(){const t=Ba.createGridLayout();if(this.placeItems(t),t.length===0||t[0]?.length===0)return"";let r=this.calculateColumnWidths(t);const n=this.calculateTotalGridWidth(r),o=typeof this.#e.maxWidth=="number"&&this.#e.maxWidth>0?Math.min(this.#e.maxWidth,this.#t):this.#t;return n>o&&(r=this.adjustColumnWidthsForTerminal(r,n)),this.renderGrid(t,r)}placeItems(t){let r=0,n=0;const o=this.#e.rows>0?this.#e.rows:Number.POSITIVE_INFINITY;for(let s=0;s<this.#o.length;s+=1){const i=this.#o[s];if(i.content===Ii&&!(i.rowSpan&&i.rowSpan>1)&&!(i.colSpan&&i.colSpan>1)){if(this.#e.autoFlow==="row")n+=1,n>=this.#e.columns&&(n=0,r+=1);else{r+=1;const m=t.length>0?t.length:o;r>=m&&m!==Number.POSITIVE_INFINITY?(r=0,n+=1):t.length===0&&m===Number.POSITIVE_INFINITY&&(n+=1)}continue}const a=i.colSpan??1,l=i.rowSpan??1;let u=!1,c=r,p=n,f=0;const d=(t.length+l+5)*this.#e.columns;for(;!u&&c<o&&f<d;){for(f+=1;c+l>t.length;)t.push(Array.from({length:this.#e.columns}).fill(void 0));if(this.canPlaceItem(t,c,p,a,l))if(this.placeItem(t,c,p,i),u=!0,this.#e.autoFlow==="row")n=p+a,r=c,n>=this.#e.columns&&(n=0,r+=1);else{r=c+l,n=p;const m=t.length>0?t.length:o;r>=m&&(r=0,n+=1)}else if(this.#e.autoFlow==="row")p+=1,p>=this.#e.columns&&(p=0,c+=1);else{for(c+=1;c+l>t.length;)t.push(Array.from({length:this.#e.columns}).fill(void 0));const m=t.length>0?t.length:o;if(c>=m&&(c=0,p+=1,p>=this.#e.columns))break}}if(!u)if(console.warn(`@visulima/tabular: Could not find position for item: ${JSON.stringify(i)} after ${String(f)} attempts. Grid might be too small or layout impossible.`),this.#e.autoFlow==="row")n+=1,n>=this.#e.columns&&(n=0,r+=1);else{r+=1;const m=t.length>0?t.length:o;r>=m&&(r=0,n+=1)}if(f>=d)break}if(this.#e.rows===0)for(;t.length>0&&t.at(-1)?.every(s=>s===void 0);)t.pop()}canPlaceItem(t,r,n,o,s,i=!1){if(n+o>this.#e.columns)return!1;for(let a=r;a<r+s;a+=1)if(a<t.length){if(!t[a])return console.warn(`Grid layout unexpectedly missing row ${String(a)} during canPlaceItem check.`),!1;for(let l=n;l<n+o;l+=1)if(t[a]?.[l]!==void 0)return!1}else if(!i)return!1;return!0}computeWrappedContentWidth(t,r,n,o){let s=t;if(o){if(s>20){let i=0;for(const a of r){const l=a.split(su);for(const u of l)i=Math.max(i,Math.min(fe(u),n))}s=Math.min(s,Math.max(i+4,12))}}else{let i=0;for(const a of r){const l=a.split(su);for(const u of l)i=Math.max(i,Math.min(fe(u),n))}s=Math.min(s,Math.max(i+12,20))}return s}placeItem(t,r,n,o){const s=o.rowSpan??1,i=o.colSpan??1;for(let a=r;a<r+s;a+=1){for(;a>=t.length;)t.push(Array.from({length:this.#e.columns}).fill(void 0));for(let l=n;l<n+i;l+=1)l<this.#e.columns&&(t[a]||(console.error(`Logic error: Row ${String(a)} not found in placeItem despite check.`),t[a]=Array.from({length:this.#e.columns}).fill(void 0)),t[a][l]=o)}}calculateTotalGridWidth(t){let r=0;const n=this.#e.showBorders?this.#e.border:void 0;n&&(r+=n.bodyLeft.width,r+=n.bodyRight.width);const o=t.length,s=this.#e.showBorders?n?.bodyJoin.width??0:0,i=this.#e.gap;for(let a=0;a<o;a+=1)r+=t[a]??0,a<o-1&&(r+=i,r+=s);return r}adjustColumnWidthsForTerminal(t,r){const n=typeof this.#e.maxWidth=="number"&&this.#e.maxWidth>0?Math.min(this.#e.maxWidth??0,this.#t):this.#t;if(r<=n)return t;let o=0;const s=t.length,i=this.#e.showBorders?this.#e.border:void 0;if(i&&(o+=i.bodyLeft.width,o+=i.bodyRight.width),s>1){o+=(s-1)*this.#e.gap;const p=i?.bodyJoin.width??0;o+=(s-1)*p}if(o>=n)return Array.from({length:s}).fill(1);const a=n-o,l=t.reduce((p,f)=>p+f,0);if(l===0){const p=Math.floor(a/s);return Array.from({length:s}).fill(p)}const u=t.map(p=>{const f=p/l;return Math.max(1,Math.floor(a*f))});let c=a-u.reduce((p,f)=>p+f,0);if(c>0){const p=u.map((f,d)=>{const m=l>0?(t[d]??0)/l:1/s;return{index:d,remainder:a*m%1}}).toSorted((f,d)=>d.remainder-f.remainder);for(const f of p){if(c<=0)break;const{index:d}=f;u[d]!==void 0&&(u[d]+=1,c-=1)}}return u}calculateBalancedColumnWidths(t){const r=this.calculateMinimumColumnWidthsWithGrowableInfo(t),n=r.widths,{growableColumns:o}=r,s=typeof this.#e.maxWidth=="number"&&this.#e.maxWidth>0?Math.min(this.#e.maxWidth,this.#t):this.#t,i=this.#e.showBorders?this.#e.border:void 0;let a=0;if(i&&(a+=i.bodyLeft.width,a+=i.bodyRight.width),this.#e.columns>1){a+=(this.#e.columns-1)*this.#e.gap;const c=i?.bodyJoin.width??0;a+=(this.#e.columns-1)*c}const l=Math.max(0,s-a);if(n.reduce((c,p)=>c+p,0)>0){const c=Math.floor(l/this.#e.columns),p=Array.from({length:this.#e.columns}).fill(c),f=c*this.#e.columns;let d=l-f;for(let $=0;$<p.length&&d>0;$+=1)p[$]=(p[$]??0)+1,d-=1;const m=[];let h=0;for(let $=0;$<this.#e.columns;$+=1){const g=p[$]??0,w=n[$]??0,b=Math.max(g,w);m.push(b),h+=b}if(h>l){const $=l/h,g=m.map(v=>Math.max(3,Math.floor(v*$))),w=g.reduce((v,S)=>v+S,0);let b=l-w;for(let v=0;v<g.length&&b>0;v+=1)g[v]=(g[v]??0)+1,b-=1;return g}let y=l-h;if(y>0){const $=o.length>0?o:m.map((g,w)=>w);for(;y>0&&$.length>0;)for(const g of $){if(y<=0)break;m[g]=(m[g]??0)+1,y-=1}}return m}const u=Math.floor(l/this.#e.columns);return Array.from({length:this.#e.columns}).fill(u)}calculateMinimumColumnWidthsWithGrowableInfo(t){const r=Array.from({length:this.#e.columns}).fill(0),n=[],o=this.#e.paddingLeft+this.#e.paddingRight,s=this.#e.gap+(this.#e.showBorders?this.#e.border?.bodyJoin.width??0:0);for(let i=0;i<this.#e.columns;i+=1)for(let a=0;a<t.length;a+=1){const l=t[a]?.[i];if(!l||Ft(t,a,i,l)!==a||i>0&&t[a]?.[i-1]===l)continue;const u=l.colSpan??1,c=l.maxWidth??Number.POSITIVE_INFINITY,p=String(l.content??"").split(Cr),f=this.#e.wordWrap&&l.wordWrap!==!1;let d=0;for(const m of p)d=Math.max(d,Math.min(fe(m),c));d=this.computeWrappedContentWidth(d,p,c,f),u===1&&(r[i]=Math.max(r[i]??0,d+o),f&&!n.includes(i)&&n.push(i))}for(let i=0;i<t.length;i+=1)for(let a=0;a<this.#e.columns;a+=1){const l=t[i]?.[a];if(!l||Ft(t,i,a,l)!==i||a>0&&t[i]?.[a-1]===l)continue;const u=l.colSpan??1;if(u>1){const c=l.maxWidth??Number.POSITIVE_INFINITY,p=String(l.content??"").split(Cr),f=this.#e.wordWrap&&l.wordWrap!==!1;let d=0;for(const $ of p)d=Math.max(d,Math.min(fe($),c));d=this.computeWrappedContentWidth(d,p,c,f);const m=(u-1)*s,h=d+o+m;let y=0;for(let $=a;$<a+u;$+=1)y+=r[$]??0;if(h>y){const $=h-y,g=Math.ceil($/u);for(let w=0;w<u&&a+w<this.#e.columns;w+=1)r[a+w]=Math.max(r[a+w]??0,g)}}}return{growableColumns:n,widths:r}}calculateColumnWidths(t){if(this.#e.fixedColumnWidths&&this.#e.fixedColumnWidths.length===this.#e.columns){const s=this.#e.fixedColumnWidths;if(!s.some(i=>i===void 0||!Number.isFinite(i)))return[...s];if(this.#e.balancedWidths){const i=Array.from({length:s.length}).fill(0),a=typeof this.#e.maxWidth=="number"&&this.#e.maxWidth>0?Math.min(this.#e.maxWidth,this.#t):this.#t,l=this.calculateTotalGridWidth(Array.from({length:i.length}).fill(0)),u=Math.max(0,a-l);let c=0;const p=[];for(const[m,h]of s.entries())typeof h=="number"&&Number.isFinite(h)?(i[m]=h,c+=h):p.push(m);let f=Math.max(0,u-c);const d=p.length>0?Math.floor(f/p.length):0;for(const m of p)i[m]=d;f-=d*p.length;for(const m of p){if(f<=0)break;i[m]+=1,f-=1}return i}}if(this.#e.balancedWidths)return this.calculateBalancedColumnWidths(t);const r=Array.from({length:this.#e.columns}).fill(0),n=this.#e.paddingLeft+this.#e.paddingRight,o=this.#e.gap+(this.#e.showBorders?this.#e.border?.bodyJoin.width??0:0);for(let s=0;s<this.#e.columns;s+=1)for(let i=0;i<t.length;i+=1){const a=t[i]?.[s];if(!a||Ft(t,i,s,a)!==i||s>0&&t[i]?.[s-1]===a)continue;const l=a.colSpan??1,u=a.maxWidth??Number.POSITIVE_INFINITY,c=String(a.content??"").split(Cr);let p=0;for(const f of c)p=Math.max(p,Math.min(fe(f),u));l===1&&(r[s]=Math.max(r[s]??0,p+n))}for(let s=0;s<t.length;s+=1)for(let i=0;i<this.#e.columns;i+=1){const a=t[s]?.[i];if(!a||Ft(t,s,i,a)!==s||i>0&&t[s]?.[i-1]===a)continue;const l=a.colSpan??1;if(l>1){const u=a.maxWidth??Number.POSITIVE_INFINITY,c=String(a.content??"").split(Cr),p=this.#e.wordWrap&&a.wordWrap!==!1;let f=0;for(const $ of c)f=Math.max(f,Math.min(fe($),u));f=this.computeWrappedContentWidth(f,c,u,p);let d=0;for(let $=i;$<i+l;$+=1)d+=r[$]??0;const m=l>1?(l-1)*o:0,h=f+n+m,y=d+m;if(h>y){const $=h-y,g=Math.floor($/l);let w=0;for(let b=0;b<l&&i+b<this.#e.columns;b+=1){const v=Math.min(g,$-w);if(r[i+b]=(r[i+b]??0)+v,w+=v,w>=$)break}}}}if(this.#e.maxWidth){const s=this.calculateTotalGridWidth(r);if(s>this.#e.maxWidth)return this.adjustColumnWidthsForTerminal(r,s)}return r}renderVisualRowContent(t,r,n,o,s){const i=t[r];if(!i)return"";const a=this.#e.borderColor??this.#e.foregroundColor??void 0,l=[],u=this.#e.showBorders&&this.#e.border?P8(this.#e.border):void 0,c=u&&u.left.width>0?u.left.char:"",p=u&&u.right.width>0?u.right.char:"",f=u&&u.join.width>0?u.join.char:"",d=" ".repeat(this.#e.gap);c&&l.push(te(te(c,a),this.#e.backgroundColor));let m=0;for(;m<this.#e.columns;){const h=i[m]??void 0;let y=1,$;if(h){const g=h.colSpan??1;y=g;const w=Ft(t,r,m,h),b=so(o,m,g),v=this.alignCellContent(h,b),S=v.length,x=this.getCachedCellVerticalPosition(t,r,m,h);x.firstRow!==w&&console.warn(`Mismatch between findFirstOccurrenceRow (${String(w)}) and determineCellVerticalPosition (${String(x.firstRow)})`);const E=s.slice(w,x.lastRow+1).reduce((J,N)=>J+N,0),j=x.lastRow-x.firstRow+1;let k=n,R=0;for(let J=w;J<r;J+=1)J<s.length&&(k+=s[J]??1),J<x.lastRow&&(R+=1);k+=R;const P=h.vAlign??"top";let z;switch(P){case"bottom":{let J=n;for(let O=w;O<r;O+=1)J+=s[O]??1;const N=E-S;z=J>=N?J-N:-1;break}case"middle":{const J=Math.round((E-S)/2);let N=n;for(let O=w;O<r;O+=1)N+=s[O]??1;z=N>=J&&N<J+S?N-J:-1;break}case"top":{z=k;break}default:z=k}const U=z>=0&&z<S;if($=" ".repeat(Math.max(0,b)),U){let J=!1;P==="middle"&&j%2===0&&z===0&&(J=!0),J||($=v[z]??$)}h.colSpan&&h.colSpan>1&&($+=d.repeat(h.colSpan)),h.foregroundColor?$=te($,h.foregroundColor):this.#e.foregroundColor&&($=te($,this.#e.foregroundColor)),h.backgroundColor?$=te($,h.backgroundColor):this.#e.backgroundColor&&($=te($,this.#e.backgroundColor))}else{const g=this.#e.paddingLeft+this.#e.paddingRight,w=Math.max(0,(o[m]??0)-g),b=" ".repeat(this.#e.paddingLeft+w+this.#e.paddingRight);$=te(te(n===0?b:" ".repeat(b.length),this.#e.foregroundColor),this.#e.backgroundColor)}l.push($),m+y<this.#e.columns&&(l.push(d),this.#e.showBorders&&f&&l.push(te(te(f,a),this.#e.backgroundColor)),this.#e.gap>0&&l.push(d)),m+=y}return p&&l.push(te(te(p,a),this.#e.backgroundColor)),l.join("")}alignCellContent(t,r){const n=this.#s.get(t);if(n?.has(r))return n.get(r);const{paddingLeft:o,paddingRight:s}=this.#e,i=o+s,a=r-i;if(a<=0){const p=[" ".repeat(i+this.#e.gap)];return n?n.set(r,p):this.#s.set(t,new Map([[r,p]])),p}let l;const u=String(t.content??"");if(l=u.includes(`
|
|
176
|
+
`)||u.includes("\r")?u.split(Cr):[u],this.#e.wordWrap&&t.wordWrap!==!1){const p=typeof this.#e.wordWrap=="object"?this.#e.wordWrap:{},f=typeof t.wordWrap=="object"?t.wordWrap:p;l=R8(u,{...f,width:a}).split(`
|
|
177
|
+
`)}if(this.#e.truncate&&t.truncate!==!1){const p=typeof this.#e.truncate=="object"?this.#e.truncate:{},f=typeof t.truncate=="object"?t.truncate:p;l=l.map(d=>eu(d,a,f))}else this.#e.truncateOverflow&&(l=l.map(p=>fe(p)>a?eu(p,a,{}):p));const c=l.map(p=>_8(p,a,t.hAlign??"left",o,s));return n?n.set(r,c):this.#s.set(t,new Map([[r,c]])),c}renderHorizontalBorder(t,r,n,o,s,i=-1){if(!this.#e.showBorders||!this.#e.border)return"";const a=this.#e.border,l=Lt(a,s),u=l.body.char,c=l.body.width,p=a.bodyJoin.char;if(s!=="middle"&&c===0)return"";let f=l.left.char,d=l.right.char;if(s==="middle"&&i!==-1){const $=t[n]?.[0]??void 0,g=t[i]?.[0]??void 0;$&&g&&$===g&&(f=p);const w=this.#e.columns-1,b=t[n]?.[w]??void 0,v=t[i]?.[w]??void 0;b&&v&&b===v&&(d=p)}const m=[],h=" ".repeat(this.#e.gap);f&&m.push(te(te(f,this.#e.borderColor),this.#e.backgroundColor));let y;for(let $=0;$<this.#e.columns;$+=1){const g=t[n]?.[$]??void 0,w=s==="middle"&&i!==-1?t[i]?.[$]??void 0:void 0;let b,v=!1;if(g&&($===0||t[n]?.[$-1]!==g)&&(b=g,v=!0),g&&!v)continue;if(!g){const E=o[$]??0;if(y=c>0?u.repeat(E):" ".repeat(E),m.push(te(te(y,this.#e.borderColor),this.#e.backgroundColor)),$<this.#e.columns-1){const j=this.determineJoinChar(s,t,n,i,$,$+1);m.push(h),j.width>0&&m.push(te(te(j.char,this.#e.borderColor),this.#e.backgroundColor))}continue}const S=b?.colSpan??1;if(s==="middle"&&s==="middle"&&w&&g===w&&b){const E=b.vAlign==="middle",{firstRow:j,lastRow:k}=this.getCachedCellVerticalPosition(t,n,$,b),R=k-j+1,P=R%2===0,z=j+Math.ceil(R/2)-1,U=so(o,$,S),J=this.alignCellContent(b,U),N=J.length;if(E&&P&&n===z)y=te(J[0]??"",this.#e.borderColor);else{let O=0;for(let I=j;I<=n;I+=1)O+=r[I]??1,I<n&&(O+=1);const F=O;if(F>=0&&F<N)y=te(J[F]??"",this.#e.foregroundColor);else{const I=o.slice($,$+S).reduce((M,_)=>M+_,0)+(S-1)*(this.#e.gap+this.#e.border.bodyJoin.width);y=te(" ".repeat(I),this.#e.borderColor)}}m.push(te(y,this.#e.backgroundColor))}else{const E=[];for(let j=$;j<$+S;j+=1){const k=o[j]??0,R=c>0?u:" ";if(E.push(R.repeat(k+this.#e.gap)),j<$+S-1){const P=this.determineJoinChar(s,t,n,i,j,j+1);P.width>0&&E.push(P.char)}}y=E.join(""),m.push(te(te(y,this.#e.borderColor),this.#e.backgroundColor))}const x=$+S-1;if(x<this.#e.columns-1){const E=this.determineJoinChar(s,t,n,i,x,x+1);E.width>0&&m.push(te(te(E.char,this.#e.borderColor),this.#e.backgroundColor))}$+=S-1}return d&&m.push(te(te(d,this.#e.borderColor),this.#e.backgroundColor)),m.join("")}determineJoinChar(t,r,n,o,s,i=-1){if(!this.#e.showBorders||!this.#e.border)return{char:" ",width:this.#e.gap};const a=this.#e.border;if(t!=="middle"){const v=Lt(a,t),S=r[n]?.[s]??void 0,x=i===-1?s+1:i,E=r[n]?.[x]??void 0,j=S!==void 0&&E!==void 0&&S===E?v.body:v.join,{char:k,width:R}=j;return{char:k,width:R>0?R:this.#e.gap}}if(o===-1||i===-1)return{char:" ",width:this.#e.gap};const l=a.bodyJoin,u=r[n]?.[s]??void 0,c=r[o]?.[s]??void 0,p=r[n]?.[i]??void 0,f=r[o]?.[i]??void 0,d=u!==void 0&&c!==void 0&&u===c,m=p!==void 0&&f!==void 0&&p===f,h=u!==void 0&&p!==void 0&&u===p,y=c!==void 0&&f!==void 0&&c===f;let $;const g=Lt(a,"middle");d&&m?$=h?{char:" ",width:l.width}:l:d?$=a.joinLeft:m?$=a.joinRight:h&&y?$=g.body:h?$=a.topJoin:y?$=a.bottomJoin:$=a.joinJoin;const{char:w,width:b}=$;return{char:w,width:b>0?b:this.#e.gap}}renderGrid(t,r){if(t.length===0)return"";const n=[],o=M8(t,r,this.#e,this.alignCellContent.bind(this),Ft),s=this.#e.showBorders&&this.#e.border?Lt(this.#e.border,"top"):void 0;s&&s.body.width>0&&n.push(this.renderHorizontalBorder(t,o,0,r,"top"));for(let a=0;a<t.length;a+=1){const l=o[a]??1;for(let c=0;c<l;c+=1)n.push(this.renderVisualRowContent(t,a,c,r,o));const u=this.#e.showBorders&&this.#e.border?Lt(this.#e.border,"middle"):void 0;if(a<t.length-1&&u&&u.body.width>0){const c=t[a],p=t[a+1];let f=!1;if(c&&p)for(let d=0;d<this.#e.columns;d+=1){const m=c[d],h=p[d];if(m!==h){f=!0;break}}f&&n.push(this.renderHorizontalBorder(t,o,a,r,"middle",a+1))}}const i=this.#e.showBorders&&this.#e.border?Lt(this.#e.border,"bottom"):void 0;return i&&i.body.width>0&&n.push(this.renderHorizontalBorder(t,o,t.length-1,r,"bottom")),n.join(`
|
|
178
|
+
`)}getCachedCellVerticalPosition(t,r,n,o){const s=this.#r.get(o);if(s)return s;const i=_i(t,r,n,o);return this.#r.set(o,i),i}}const I8={bodyJoin:{char:"│",width:1},bodyLeft:{char:"│",width:1},bodyRight:{char:"│",width:1},bottomBody:{char:"─",width:1},bottomJoin:{char:"┴",width:1},bottomLeft:{char:"└",width:1},bottomRight:{char:"┘",width:1},joinBody:{char:"─",width:1},joinJoin:{char:"┼",width:1},joinLeft:{char:"├",width:1},joinRight:{char:"┤",width:1},topBody:{char:"─",width:1},topJoin:{char:"┬",width:1},topLeft:{char:"┌",width:1},topRight:{char:"┐",width:1}},W8={bodyJoin:{char:"│",width:1},bodyLeft:{char:"│",width:1},bodyRight:{char:"│",width:1},bottomBody:{char:"─",width:1},bottomJoin:{char:"┴",width:1},bottomLeft:{char:"╰",width:1},bottomRight:{char:"╯",width:1},joinBody:{char:"─",width:1},joinJoin:{char:"┼",width:1},joinLeft:{char:"├",width:1},joinRight:{char:"┤",width:1},topBody:{char:"─",width:1},topJoin:{char:"┬",width:1},topLeft:{char:"╭",width:1},topRight:{char:"╮",width:1}},B8=e=>e.reduce((t,r)=>r===null?t+1:typeof r=="object"&&!Array.isArray(r)?(r.colSpan??=1,r.colSpan<=0?t+1:t+r.colSpan):t+1,0);let D8=class{#e;#o=[];#t=[];#s=[];#r=!0;#n=void 0;constructor(t={}){this.#e={...t,showFooter:t.showFooter??!0,showHeader:t.showHeader??!0,style:{border:I8,paddingLeft:1,paddingRight:1,...t.style}}}setHeaders(t){return t.length>0&&!Array.isArray(t[0])?this.#t=[t]:this.#t=t.map(r=>Array.isArray(r)?r:[r]),this.#r=!0,this.#n=void 0,this}setFooter(t){return t.length>0&&!Array.isArray(t[0])?this.#s=[t]:this.#s=t.map(r=>Array.isArray(r)?r:[r]),this.#r=!0,this.#n=void 0,this}addRow(t){if(!Array.isArray(t))throw new TypeError("Row must be an array");return this.#o.push(t),this.#r=!0,this.#n=void 0,this}addRows(...t){for(const r of t)this.addRow(r);return this.#r=!0,this.#n=void 0,this}toString(){if(!this.#r&&this.#n!==void 0)return this.#n;const t=this.#e.showHeader?this.#t:[],r=this.#e.showFooter?this.#s:[],n=[...t,...this.#o,...r];if(n.length===0)return this.#n="",this.#r=!1,"";let o=0;for(const p of n){const f=p;Array.isArray(f)?o=Math.max(o,B8(f)):console.error("Unexpected non-array element found while calculating columns:",f)}if(o===0)return this.#n="",this.#r=!1,"";let s;Array.isArray(this.#e.columnWidths)?s=this.#e.columnWidths.length>=o?this.#e.columnWidths.slice(0,o):[...this.#e.columnWidths,...Array.from({length:o-this.#e.columnWidths.length}).fill(void 0)]:typeof this.#e.columnWidths=="number"&&(s=Array.from({length:o}).fill(this.#e.columnWidths));let i;const a=n.length;if(Array.isArray(this.#e.rowHeights)?i=this.#e.rowHeights:typeof this.#e.rowHeights=="number"&&(i=Array.from({length:a}).fill(this.#e.rowHeights)),s&&Array.isArray(s)){const p=[...s];for(const f of n){const d=f;for(const[m,h]of d.entries()){let y={};if(typeof h=="object"&&h!==null&&!Array.isArray(h)){const{content:$,href:g,...w}=h;y=w}y.width!==void 0?p[m]=y.width:y.maxWidth!==void 0&&p[m]!==void 0&&(p[m]=Math.min(p[m],y.maxWidth))}}s=p}const l={autoFlow:"row",backgroundColor:this.#e.style?.backgroundColor,balancedWidths:this.#e.balancedWidths??!1,border:this.#e.style?.border,borderColor:this.#e.style?.borderColor,columns:o,fixedColumnWidths:s,fixedRowHeights:i,foregroundColor:this.#e.style?.foregroundColor,gap:this.#e.gap??0,maxWidth:this.#e.maxWidth,paddingLeft:this.#e.style?.paddingLeft,paddingRight:this.#e.style?.paddingRight,terminalWidth:this.#e.terminalWidth,truncate:this.#e.truncate??(s?.every(p=>typeof p=="number")||this.#e.maxWidth!==void 0&&!this.#e.balancedWidths),truncateOverflow:this.#e.truncateOverflow??!0,wordWrap:this.#e.wordWrap??!1},u=new Ba(l),c=[];for(const[p,f]of n.entries()){const d=f;if(!Array.isArray(d)){console.error("Skipping non-array row while creating GridItems:",d);continue}const m=this.#e.showHeader?this.#t.length:0,h=this.#o.length,y=this.#e.showHeader&&p<m,$=this.#e.showFooter&&p>=m+h,g=y&&d.length===1&&o>1,w=$&&d.length===1&&o>1;for(const b of d){let v=b,S={};if(typeof v=="object"&&v!==null&&!Array.isArray(v)){const{content:k,href:R,...P}=v;v=R?`\x1B]8;;${R}\x1B\\${String(k)}\x1B]8;;\x1B\\`:k,S=P}g&&(S.colSpan=o),w&&(S.colSpan=o);const x=this.#e.transformTabToSpace&&typeof v=="string"?v.replaceAll(" "," ".repeat(this.#e.transformTabToSpace)):v,{maxWidth:E,width:j}=S;c.push({backgroundColor:S.backgroundColor,colSpan:S.colSpan,content:x,foregroundColor:S.foregroundColor,hAlign:S.hAlign,maxWidth:E,rowSpan:S.rowSpan,truncate:S.truncate??(E===void 0?void 0:!0),vAlign:S.vAlign,width:j,wordWrap:S.wordWrap})}}return u.addItems(c),this.#n=u.toString(),this.#r=!1,this.#n}};const L8=e=>new D8(e),F8=e=>e.logger,H8=/\{\s*"name"/,q8=Lh(Dh.exec);class nm extends Error{}function J8(e){const t=new Map;return(...r)=>{const n=r.toString();if(t.has(n))return t.get(n);const o=e(...r);return t.set(n,o),o}}const z8={bundler:"bundler",node10:"node10","node16-cjs":"node16 (from CJS)","node16-esm":"node16 (from ESM)"},U8={"":"",1:"(CJS)",99:"(ESM)"},iu={CJSOnlyExportsDefault:Cn,CJSResolvesToESM:Yt,FallbackCondition:Yt,FalseCJS:qt,FalseESM:qt,FalseExportDefault:Cn,InternalResolutionError:qt,MissingExportEquals:Cn,NamedExports:Yt,NoResolution:qt,UnexpectedModuleSyntax:qt,UntypedResolution:Yt},G8={esmOnly:["node10","node16-cjs"],node16:["node10"],strict:[]},V8=e=>{if(e.startsWith("{"))return e;const t=H8.exec(e)?.index;if(t!==void 0)return e.slice(t);const r=e.indexOf("{");return r!==-1?e.slice(r):e},K8=e=>{const t=e.split(`
|
|
179
|
+
`);let r="[";for(const n of t)n&&(r+=`${n},`);return r.at(-1)===","&&(r=r.slice(0,-1)),r+="]",r},Y8=async(e,t)=>{switch(e){case"auto":{const{detect:r}=await import("package-manager-detector/detect"),n=await r({cwd:t});if(!n)return;if(n.name==="bun")throw new Error("Bun does not support --json on the pack command");return n.name}case"bun":throw new Error("Bun does not support --json on the pack command");case"pnpm":return"pnpm";case"yarn":return"yarn";default:return"npm"}},X8=(e,t,r)=>{const{allResolutionKinds:n,filterProblems:o,getResolutionOption:s,groupProblemsByKind:i,problemAffectsEntrypoint:a,problemAffectsResolutionKind:l,problemKindInfo:u}=r,c=n.filter(b=>!t.includes(b)),p=n.filter(b=>t.includes(b)),f=[...c,...p],d=Object.keys(e.entrypoints),m=d.map(b=>`"${b==="."?e.packageName:`${e.packageName}/${b.slice(2)}`}"`),h=d.map((b,v)=>{const S=e.problems.some(x=>a(x,b,e))?"redBright":"greenBright";return Ae[S](m[v])}),y=J8((b,v)=>{const S=t.includes(v)?"(ignored) ":"",x=i(o(e.problems,e,{entrypoint:b,resolutionKind:v})),E=e.entrypoints[b].resolutions[v],{resolution:j}=E,k=Object.keys(x);if(k.length>0)return k.map(U=>S+iu[U](u[U].shortDescription)).join(`
|
|
180
|
+
`);const R="OK (JSON)",P=e.programInfo[s(v)].moduleKinds?.[j?.fileName??""]?.detectedKind??"",z=E.isWildcard?"(wildcard)":`OK ${U8[P]}`;return S+(j?.isJson?R:z)}),$=L8({style:{border:W8}});$.setHeaders(["",...f.map(b=>z8[b])]),h.forEach((b,v)=>{const[S,x,E,j]=f.map(k=>d.map(R=>y(R,k)));$.addRow([b,S[v]??null,x[v]??null,E[v]??null,j[v]??null])});const g=i(e.problems),w=Object.entries(g).map(([b,v])=>{const S=u[b],x=v.some(j=>c.some(k=>l(j,k,e))),E=`${`${S.description}${S.details?` Use \`-f json\` to see ${S.details}.`:""}`} ${S.docsUrl}`;return`${x?"":"(ignored per resolution) "}${iu[b](E)}`});return`Are the types wrong problems found:
|
|
181
|
+
|
|
182
|
+
${$.toString()}
|
|
183
|
+
|
|
184
|
+
${w.join(`
|
|
185
|
+
|
|
186
|
+
`)}`},Z8=e=>{const t=JSON.parse(e),r=Array.isArray(t)?t[0]:t;if(!r?.filename)throw new Error(`Invalid npm pack output format: ${e}`);return r.filename},Q8=async(e,t,r)=>{let n=`--pack-destination "${t}"`;e==="yarn"?n=`--out "${G(t,"package.tgz")}"`:e==="bun"&&(n=` --destination "${t}"`);let o=" --ignore-scripts";e==="yarn"?o="":e==="pnpm"&&(o=" --config.ignore-scripts=true");let s=(await q8(`${e} pack --json ${n}${o}`,{cwd:r,encoding:"utf8"})).stdout.trim();e==="pnpm"?s=V8(s):e==="yarn"&&(s=K8(s));const i=Z8(s);return Tt(i)?i:G(t,Fe(i))},eA=(e,t,r,n,o,s)=>{if(t.types!==!1&&t.problems.length>0){const i=X8(t,r,s);if(n==="error")throw e.error({message:i,prefix:"attw"}),new nm("attw reported types problems; see the log above.");e.warn({message:i,prefix:"attw"});return}e.success({message:Li(`No Are the types wrong problems found ${Ou`(${Math.round(performance.now()-o).toString()}ms)`}`),prefix:"attw"})},tA=async(e,t)=>{if(!e.options?.validation)return;const{validation:r}=e.options;if(!r.attw)return;const n=F8(e),{packageJson:o}=Fo(e.options.rootDir);e.pkg=o,t&&n.raw(`
|
|
187
|
+
`),await n1(e.pkg,["@arethetypeswrong/core","package-manager-detector"],"devDependencies",{logger:{warn:v=>{n.warn({message:v,prefix:"attw"})}}});let{level:s="warn",pm:i="auto",profile:a="strict",...l}=r.attw===!0?{}:r.attw;const u=performance.now();n.debug({message:"Running attw check",prefix:"attw"});const c=await Yu(G(Uu(),"packem-attw-")),p=async()=>{await po(c,{force:!0,recursive:!0}).catch(()=>{})};let f;try{f=await import("@arethetypeswrong/core")}catch{n.error({message:`ATTW check requires ${Cn`@arethetypeswrong/core`} to be installed.`,prefix:"attw"}),await p();return}let d;try{d=await Y8(i,e.options.rootDir)}catch(v){throw await p(),v}if(d===void 0)throw await p(),new Error("Could not detect a package manager to run the attw check.");const{allResolutionKinds:m,getResolutionOption:h,groupProblemsByKind:y}=await import("@arethetypeswrong/core/utils"),{filterProblems:$,problemAffectsEntrypoint:g,problemAffectsResolutionKind:w,problemKindInfo:b}=await import("@arethetypeswrong/core/problems");try{const v=await Q8(d,c,e.options.rootDir),S=await Hn(v),x=f.createPackageFromTarballData(new Uint8Array(S)),E=await f.checkPackage(x,l),j=G8[a];eA(n,E,j,s,u,{allResolutionKinds:m,filterProblems:$,getResolutionOption:h,groupProblemsByKind:y,problemAffectsEntrypoint:g,problemAffectsResolutionKind:w,problemKindInfo:b})}catch(v){throw v instanceof nm||n.error({message:`ATTW check failed: ${v instanceof Error?v.message:String(v)}`,prefix:"attw"}),v}finally{await p()}},au=e=>Array.from(e,t=>Yt(t)).join(", "),rA=e=>{if(e.hoistedDependencies.size>0){const s=`These dependencies are shamefully hoisted: ${au(e.hoistedDependencies)}`;Y(e,s)}let t=Object.keys(e.pkg.dependencies??{}).filter(s=>!e.usedDependencies.has(s));const{validation:r}=e.options,n=r===!1||r===void 0?!1:r.dependencies,o=n===!1?!1:n.unused;if(o!==!1&&(t=t.filter(s=>!o.exclude.includes(s))),t.length>0){const s=`These dependencies are listed in package.json but not used: ${au(t)}`;Y(e,s)}},lu=">=18.0.0",nA=e=>{const t=e.options.validation,{pkg:r}=e;if(t.packageJson?.engines===!1)return;const n=process.version,o=r.engines?.node;if(!o){Y(e,`The 'engines.node' field is missing in your package.json. Consider adding "engines": { "node": "${lu}" } to specify Node.js version requirements.`);return}if(!Le.validRange(o)){Y(e,`Invalid Node.js version range "${o}" in engines.node field. Please use a valid semver range like "${lu}".`);return}if(!Le.satisfies(n,o))throw new Error(`Node.js version mismatch: Current version ${n} does not satisfy the required range "${o}" specified in package.json engines.node field.`)},oA=(e,t)=>Hh(e,t)<=e.length/3||t.includes(e),sA=(e,t)=>{const r=e.toLowerCase();return t.filter(n=>oA(n.toLowerCase(),r))},iA=/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,aA=(e,t)=>{const{options:r}=e;return ca(e.pkg.exports,t,r.declaration,[],r.ignoreExportKeys??[]).filter(n=>!n.ignored).map(n=>r.dtsOnly?n.subKey==="types"?n.file:void 0:n.file)},lA=(e,t)=>e.options.dtsOnly||!t?[""]:typeof e.pkg.bin=="string"?[e.pkg.bin]:typeof e.pkg.bin=="object"?Object.values(e.pkg.bin):[],cA=(e,t)=>{let r="Potential missing or wrong package.json files:";for(const n of e){const o=sA(n,t);r+=`
|
|
188
|
+
- ${re(n)}${o.length>0?hm` (did you mean ${o.map(s=>`"${s}"`).join(", ")}?)`:""}`}return r},uA=e=>{const{options:t}=e,r=t.validation,{packageJson:n}=r;if(!n?.exports)return;const o=lA(e,!!n.bin),s=e.pkg.type==="module"?"esm":"cjs",i=new Set([t.declaration&&n.types?e.pkg.types:"",t.declaration&&n.types?e.pkg.typings:"",...o,t.dtsOnly&&!n.main?"":e.pkg.main,t.dtsOnly&&!n.module?"":e.pkg.module,...aA(e,s)].filter(Boolean).map(c=>c&&X(t.rootDir,c.replace(iA,"")))),a=[];for(const c of i)c&&!c.includes("*")&&!Ji(c)&&a.push(c.replace(`${t.rootDir}/`,""));const l=c=>Se(t.rootDir,X(t.outDir,c)),u=e.buildEntries.filter(c=>!c.chunk).map(c=>l(c.path));if(a.length>0){const c=cA(a,u);Y(e,c)}},pA=(e,t)=>{const r=e.options.validation;if(r.packageJson?.exports===!1)return;const n=new Set(["default","import","module-sync","node","node-addons","require"]),o=new Set(["browser","bun","deno","development","edge-light","electron","production","react-native","react-server","types","workerd"]),s=r.packageJson?.extraConditions??[],i=new Set(s),a=new Set([...o,...i,...n]),l=(f,d)=>{if(f!==null){if(typeof f=="string"){if(!f.startsWith("./")){Y(e,`Invalid exports path "${f}" at ${d}. Export paths must start with "./"`);return}if(f.includes("../")){Y(e,`Invalid exports path "${f}" at ${d}. Export paths should not contain "../" for security reasons`);return}const m=r.packageJson?.allowedExportExtensions??[],h=[...Km,...m];if(di(f)){try{const y=f.startsWith("./")?X(e.options.rootDir,f.slice(2)):X(e.options.rootDir,f),$=Au([y],{cwd:e.options.rootDir,dot:!1,ignore:["**/node_modules/**","**/.git/**","**/dist/**"]});if($.length===0)return;const g=$.filter(w=>!h.some(b=>w.endsWith(b)));g.length>0&&Y(e,`Export path "${f}" at ${d} matches files with invalid extensions: ${g.join(", ")}. Valid extensions are: ${h.join(", ")}`)}catch(y){Y(e,`Could not validate glob pattern "${f}" at ${d}: ${y instanceof Error?y.message:"Unknown error"}`)}return}h.some(y=>f.endsWith(y))||Y(e,`Export path "${f}" at ${d} should have a valid file extension (${h.join(", ")})`);return}if(Array.isArray(f)){if(f.length===0){Y(e,`Empty fallback array at ${d}. Fallback arrays should contain at least one entry`);return}f.forEach((m,h)=>{l(m,`${d}[${String(h)}]`)});return}if(typeof f=="object"){const m=Object.keys(f);if(m.length===0){Y(e,`Empty conditions object at ${d}. Conditional exports should define at least one condition`);return}const h=m.filter($=>!a.has($));if(h.length>0){const $=s.length>0,g=[...n].join(", ");$?Y(e,`Unknown export conditions [${h.join(", ")}] at ${d}. Consider using standard conditions (${g}) or add custom conditions to 'validation.packageJson.extraConditions' in your packem config.`):Y(e,`Unknown export conditions [${h.join(", ")}] at ${d}. Consider using standard conditions (${g}) or add custom conditions using the 'extraConditions' option in your validation config.`)}const y=m.filter($=>n.has($));if(y.length>1){const $=["node-addons","node","import","require","module-sync","default"],g=y,w=$.filter(b=>g.includes(b));JSON.stringify(g)!==JSON.stringify(w)&&Y(e,`Incorrect condition order at ${d}. Standard conditions should be ordered: ${w.join(" > ")}`)}m.forEach($=>{l(f[$],`${d}.${$}`)});return}Y(e,`Invalid exports value type at ${d}. Expected string, array, object, or null`)}},u=(f,d)=>{f.startsWith(".")&&!f.startsWith("./")&&f!=="."&&Y(e,`Invalid subpath "${f}". Subpaths should start with "./" or be exactly "."`),f.includes("*")&&(f.match(/\*/g)??[]).length>1&&Y(e,`Invalid subpath pattern "${f}". Only one "*" wildcard is allowed per subpath`),l(d[f],`exports["${f}"]`)},c=(f,d,m)=>{const h=f.filter($=>$!=="."),y=e.pkg.bin!==void 0&&h.length<=1&&h.every($=>$==="./package.json");!d.includes(".")&&!y&&Y(e,'Missing main export ".". Subpaths exports should include a main export entry');for(const $ of d)u($,m)},p=f=>{const d=Object.keys(f);if(d.length===0){Y(e,"Empty exports object. Define at least one export entry");return}const m=d.filter(y=>y.startsWith(".")),h=d.filter(y=>!y.startsWith("."));if(m.length>0&&h.length>0){Y(e,'Mixed subpaths and conditions in exports object. Use either subpaths (keys starting with ".") or conditions, not both');return}m.length>0?c(m,d,f):l(f,"exports")};(f=>{if(typeof f=="string"){l(f,"exports");return}if(Array.isArray(f)){f.forEach((d,m)=>{l(d,`exports[${String(m)}]`)});return}if(typeof f=="object"&&f!==null){p(f);return}Y(e,"Invalid exports field type. Expected string, array, or object")})(t)},fA=({context:e,pkg:t,validation:r})=>{t.name===void 0&&r.packageJson?.name!==!1&&Y(e,"The 'name' field is missing in your package.json. Please provide a valid package name."),r.packageJson?.files!==!1&&Array.isArray(t.files)&&!t.files.includes("*")&&(t.files.length===0?Y(e,"The 'files' field in your package.json is empty. Please specify the files to be included in the package."):t.files.some(n=>n.includes(e.options.outDir))||Y(e,`The 'files' field in your package.json is missing the '${e.options.outDir}' directory. Ensure the output directory is included.`))},dA=({cjsJSExtension:e,context:t,esmJSExtension:r,pkg:n,validation:o})=>{o.packageJson?.main!==!1&&(n.main===void 0&&Y(t,"The 'main' field is missing in your package.json. This field should point to your main entry file."),n.main?.endsWith(`.${r}`)&&Y(t,`The 'main' field in your package.json should not use a '.${r}' extension for CommonJS modules.`)),o.packageJson?.module!==!1&&(n.module===void 0&&t.options.emitESM&&Y(t,"The 'module' field is missing in your package.json, but you are emitting ES modules."),n.module&&n.main&&n.module===n.main&&Y(t,`Conflict detected: The 'module' and 'main' fields both point to '${n.module}'. Please ensure they refer to different module types.`),t.options.emitESM&&n.module?.endsWith(`.${e}`)&&Y(t,`The 'module' field in your package.json should not use a '.${e}' extension for ES modules.`))},mA=({cjsJSExtension:e,context:t,pkg:r,validation:n})=>{n.packageJson?.main!==!1&&r.main===void 0&&Y(t,"The 'main' field is missing in your package.json. This field is needed when emitting CommonJS modules."),n.packageJson?.module!==!1&&(r.module===void 0&&Y(t,"The 'module' field is missing in your package.json. This field is necessary when emitting ES modules."),r.module?.endsWith(`.${e}`)&&Y(t,`The 'module' field should not use a '.${e}' extension for ES modules.`),r.module&&r.main&&r.module===r.main&&Y(t,`Conflict detected: The 'module' and 'main' fields both point to '${r.module}'. Please ensure they refer to different module types.`)),n.packageJson?.exports!==!1&&r.exports===void 0&&Y(t,"The 'exports' field is missing in your package.json. This field is required for defining explicit exports.")},hA=e=>{const{context:t,pkg:r,validation:n}=e;r.exports===void 0&&!t.options.emitCJS?n.packageJson?.exports!==!1&&Y(t,"The 'exports' field is missing in your package.json. Define module exports explicitly."):t.options.emitCJS&&mA(e)},gA=({cjsJSExtension:e,context:t,esmJSExtension:r,pkg:n,validation:o},s)=>{if(o.packageJson?.bin===!1)return;const i=s?r:e;if(e===r)return;const a=s?"CommonJS":"ES modules";if(typeof n.bin=="string"&&n.bin.endsWith(`.${i}`))Y(t,`The 'bin' field in your package.json should not use a .${i} extension for ${a} binaries.`);else if(typeof n.bin=="object")for(const[l,u]of Object.entries(n.bin))u?.endsWith(`.${i}`)&&Y(t,`The 'bin.${l}' field in your package.json should not use a .${i} extension for ${a} binaries.`)},yA=({cjsJSExtension:e,context:t,pkg:r,validation:n})=>{if(!t.options.declaration)return;let o=!0;r.type==="module"&&(o=!!r.main?.endsWith(`.${e}`));const s=r.types!==void 0||r.typings!==void 0;!s&&o&&n.packageJson?.types!==!1&&Y(t,"The 'types' field is missing in your package.json. This field should point to your type definitions file.");const i=r.type==="module"&&r.main!==void 0&&s;(t.options.declaration===!0||t.options.declaration==="compatible")&&o&&!i&&n.packageJson?.typesVersions!==!1&&(()=>{const a=r.typesVersions;return a===void 0||Object.keys(a).length===0})()&&Y(t,"No 'typesVersions' field found in your package.json. Consider adding this field, or change the declaration option to 'node16' or 'false'.")},$A=e=>{const t=e.options.validation,{pkg:r}=e,n=Pe(e,"cjs"),o=Pe(e,"esm"),s={cjsJSExtension:n,context:e,esmJSExtension:o,pkg:r,validation:t};fA(s);const i=r.type==="commonjs"||r.type===void 0,a=r.type==="module";i?dA(s):a&&hA(s),r.exports!==void 0&&pA(e,r.exports),gA(s,i),yA(s),t.packageJson?.sideEffects!==!1&&r.sideEffects===void 0&&Y(e,"The 'sideEffects' field is missing in your package.json. Consider adding this field to your package.json.")},bA=e=>{const{packageJson:t}=Fo(e.options.rootDir);e.pkg=t,rA(e),nA(e),$A(e),uA(e)},wA=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,vA=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","undefined","var","void","volatile","while","with","yield"]),xA=(e,t)=>{if(e.trim()==="")throw new Error(`Alias name "${e}" is invalid. Alias names should be non-empty strings.`);if(wA.test(e))throw new Error(`Alias name "${e}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(vA.has(e))throw new Error(`Alias name "${e}" is a reserved keyword and cannot be used.`);const r=X(t);if(!rt(r))throw new Error(`Target path "${r}" for alias "${e}" does not exist.`)},cu=e=>{if(Array.isArray(e))return;const t=e;for(const[r,n]of Object.entries(t))xA(r,n)};var oi={},si,uu;function Jo(){if(uu)return si;uu=1;const e="[^\\\\/]",t="(?=.)",r="[^/]",n="(?:\\/|$)",o="(?:^|\\/)",s=`\\.{1,2}${n}`,i="(?!\\.)",a=`(?!${o}${s})`,l=`(?!\\.{0,1}${n})`,u=`(?!${s})`,c="[^.\\/]",p=`${r}*?`,f="/",d={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:t,QMARK:r,END_ANCHOR:n,DOTS_SLASH:s,NO_DOT:i,NO_DOTS:a,NO_DOT_SLASH:l,NO_DOTS_SLASH:u,QMARK_NO_DOT:c,STAR:p,START_ANCHOR:o,SEP:f},m={...d,SLASH_LITERAL:"[\\\\/]",QMARK:e,STAR:`${e}*?`,DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},h={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};return si={DEFAULT_MAX_EXTGLOB_RECURSION:0,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:h,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(y){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${y.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(y){return y===!0?m:d}},si}var pu;function zo(){return pu||(pu=1,(function(e){const{REGEX_BACKSLASH:t,REGEX_REMOVE_BACKSLASH:r,REGEX_SPECIAL_CHARS:n,REGEX_SPECIAL_CHARS_GLOBAL:o}=Jo();e.isObject=s=>s!==null&&typeof s=="object"&&!Array.isArray(s),e.hasRegexChars=s=>n.test(s),e.isRegexChar=s=>s.length===1&&e.hasRegexChars(s),e.escapeRegex=s=>s.replace(o,"\\$1"),e.toPosixSlashes=s=>s.replace(t,"/"),e.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){const s=navigator.platform.toLowerCase();return s==="win32"||s==="windows"}return process.platform?process.platform==="win32":!1},e.removeBackslashes=s=>s.replace(r,i=>i==="\\"?"":i),e.escapeLast=(s,i,a)=>{const l=s.lastIndexOf(i,a);return l===-1?s:s[l-1]==="\\"?e.escapeLast(s,i,l-1):`${s.slice(0,l)}\\${s.slice(l)}`},e.removePrefix=(s,i={})=>{let a=s;return a.startsWith("./")&&(a=a.slice(2),i.prefix="./"),a},e.wrapOutput=(s,i={},a={})=>{const l=a.contains?"":"^",u=a.contains?"":"$";let c=`${l}(?:${s})${u}`;return i.negated===!0&&(c=`(?:^(?!${c}).*$)`),c},e.basename=(s,{windows:i}={})=>{const a=s.split(i?/[\\/]/:"/"),l=a[a.length-1];return l===""?a[a.length-2]:l}})(oi)),oi}var ii,fu;function EA(){if(fu)return ii;fu=1;const e=zo(),{CHAR_ASTERISK:t,CHAR_AT:r,CHAR_BACKWARD_SLASH:n,CHAR_COMMA:o,CHAR_DOT:s,CHAR_EXCLAMATION_MARK:i,CHAR_FORWARD_SLASH:a,CHAR_LEFT_CURLY_BRACE:l,CHAR_LEFT_PARENTHESES:u,CHAR_LEFT_SQUARE_BRACKET:c,CHAR_PLUS:p,CHAR_QUESTION_MARK:f,CHAR_RIGHT_CURLY_BRACE:d,CHAR_RIGHT_PARENTHESES:m,CHAR_RIGHT_SQUARE_BRACKET:h}=Jo(),y=w=>w===a||w===n,$=w=>{w.isPrefix!==!0&&(w.depth=w.isGlobstar?1/0:1)};return ii=(w,b)=>{const v=b||{},S=w.length-1,x=v.parts===!0||v.scanToEnd===!0,E=[],j=[],k=[];let R=w,P=-1,z=0,U=0,J=!1,N=!1,O=!1,F=!1,I=!1,M=!1,_=!1,H=!1,V=!1,B=!1,D=0,K,q,A={value:"",depth:0,isGlob:!1};const ae=()=>P>=S,ze=()=>R.charCodeAt(P+1),ve=()=>(K=q,R.charCodeAt(++P));for(;P<S;){q=ve();let de;if(q===n){_=A.backslashes=!0,q=ve(),q===l&&(M=!0);continue}if(M===!0||q===l){for(D++;ae()!==!0&&(q=ve());){if(q===n){_=A.backslashes=!0,ve();continue}if(q===l){D++;continue}if(M!==!0&&q===s&&(q=ve())===s){if(J=A.isBrace=!0,O=A.isGlob=!0,B=!0,x===!0)continue;break}if(M!==!0&&q===o){if(J=A.isBrace=!0,O=A.isGlob=!0,B=!0,x===!0)continue;break}if(q===d&&(D--,D===0)){M=!1,J=A.isBrace=!0,B=!0;break}}if(x===!0)continue;break}if(q===a){if(E.push(P),j.push(A),A={value:"",depth:0,isGlob:!1},B===!0)continue;if(K===s&&P===z+1){z+=2;continue}U=P+1;continue}if(v.noext!==!0&&(q===p||q===r||q===t||q===f||q===i)&&ze()===u){if(O=A.isGlob=!0,F=A.isExtglob=!0,B=!0,q===i&&P===z&&(V=!0),x===!0){for(;ae()!==!0&&(q=ve());){if(q===n){_=A.backslashes=!0,q=ve();continue}if(q===m){O=A.isGlob=!0,B=!0;break}}continue}break}if(q===t){if(K===t&&(I=A.isGlobstar=!0),O=A.isGlob=!0,B=!0,x===!0)continue;break}if(q===f){if(O=A.isGlob=!0,B=!0,x===!0)continue;break}if(q===c){for(;ae()!==!0&&(de=ve());){if(de===n){_=A.backslashes=!0,ve();continue}if(de===h){N=A.isBracket=!0,O=A.isGlob=!0,B=!0;break}}if(x===!0)continue;break}if(v.nonegate!==!0&&q===i&&P===z){H=A.negated=!0,z++;continue}if(v.noparen!==!0&&q===u){if(O=A.isGlob=!0,x===!0){for(;ae()!==!0&&(q=ve());){if(q===u){_=A.backslashes=!0,q=ve();continue}if(q===m){B=!0;break}}continue}break}if(O===!0){if(B=!0,x===!0)continue;break}}v.noext===!0&&(F=!1,O=!1);let C=R,T="",Ie="";z>0&&(T=R.slice(0,z),R=R.slice(z),U-=z),C&&O===!0&&U>0?(C=R.slice(0,U),Ie=R.slice(U)):O===!0?(C="",Ie=R):C=R,C&&C!==""&&C!=="/"&&C!==R&&y(C.charCodeAt(C.length-1))&&(C=C.slice(0,-1)),v.unescape===!0&&(Ie&&(Ie=e.removeBackslashes(Ie)),C&&_===!0&&(C=e.removeBackslashes(C)));const se={prefix:T,input:w,start:z,base:C,glob:Ie,isBrace:J,isBracket:N,isGlob:O,isExtglob:F,isGlobstar:I,negated:H,negatedExtglob:V};if(v.tokens===!0&&(se.maxDepth=0,y(q)||j.push(A),se.tokens=j),v.parts===!0||v.tokens===!0){let de;for(let pe=0;pe<E.length;pe++){const We=de?de+1:z,wt=E[pe],hr=w.slice(We,wt);v.tokens&&(pe===0&&z!==0?(j[pe].isPrefix=!0,j[pe].value=T):j[pe].value=hr,$(j[pe]),se.maxDepth+=j[pe].depth),(pe!==0||hr!=="")&&k.push(hr),de=wt}if(de&&de+1<w.length){const pe=w.slice(de+1);k.push(pe),v.tokens&&(j[j.length-1].value=pe,$(j[j.length-1]),se.maxDepth+=j[j.length-1].depth)}se.slashes=E,se.parts=k}return se},ii}var ai,du;function SA(){if(du)return ai;du=1;const e=Jo(),t=zo(),{MAX_LENGTH:r,POSIX_REGEX_SOURCE:n,REGEX_NON_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_BACKREF:s,REPLACEMENTS:i}=e,a=(g,w)=>typeof w.expandRange=="function"?w.expandRange(...g,w):(g.sort(),`[${g.join("-")}]`),l=(g,w)=>`Missing ${g}: "${w}" - use "\\\\${w}" to match literal characters`,u=g=>{const w=[];let b=0,v=0,S=0,x="",E=!1;for(const j of g){if(E===!0){x+=j,E=!1;continue}if(j==="\\"){x+=j,E=!0;continue}if(j==='"'){S=S===1?0:1,x+=j;continue}if(S===0){if(j==="[")b++;else if(j==="]"&&b>0)b--;else if(b===0){if(j==="(")v++;else if(j===")"&&v>0)v--;else if(j==="|"&&v===0){w.push(x),x="";continue}}}x+=j}return w.push(x),w},c=g=>{let w=!1;for(const b of g){if(w===!0){w=!1;continue}if(b==="\\"){w=!0;continue}if(/[?*+@!()[\]{}]/.test(b))return!1}return!0},p=g=>{let w=g.trim(),b=!0;for(;b===!0;)b=!1,/^@\([^\\()[\]{}|]+\)$/.test(w)&&(w=w.slice(2,-1),b=!0);if(c(w))return w.replace(/\\(.)/g,"$1")},f=g=>{const w=g.map(p).filter(Boolean);for(let b=0;b<w.length;b++)for(let v=b+1;v<w.length;v++){const S=w[b],x=w[v],E=S[0];if(!(!E||S!==E.repeat(S.length)||x!==E.repeat(x.length))&&(S===x||S.startsWith(x)||x.startsWith(S)))return!0}return!1},d=(g,w=!0)=>{if(g[0]!=="+"&&g[0]!=="*"||g[1]!=="(")return;let b=0,v=0,S=0,x=!1;for(let E=1;E<g.length;E++){const j=g[E];if(x===!0){x=!1;continue}if(j==="\\"){x=!0;continue}if(j==='"'){S=S===1?0:1;continue}if(S!==1){if(j==="["){b++;continue}if(j==="]"&&b>0){b--;continue}if(!(b>0)){if(j==="("){v++;continue}if(j===")"&&(v--,v===0))return w===!0&&E!==g.length-1?void 0:{type:g[0],body:g.slice(2,E),end:E}}}}},m=g=>{let w=0;const b=[];for(;w<g.length;){const v=d(g.slice(w),!1);if(!v||v.type!=="*")return;const S=u(v.body).map(E=>E.trim());if(S.length!==1)return;const x=p(S[0]);if(!x||x.length!==1)return;b.push(x),w+=v.end+1}return b.length<1?void 0:`${b.length===1?t.escapeRegex(b[0]):`[${b.map(v=>t.escapeRegex(v)).join("")}]`}*`},h=g=>{let w=0,b=g.trim(),v=d(b);for(;v;)w++,b=v.body.trim(),v=d(b);return w},y=(g,w)=>{if(w.maxExtglobRecursion===!1)return{risky:!1};const b=typeof w.maxExtglobRecursion=="number"?w.maxExtglobRecursion:e.DEFAULT_MAX_EXTGLOB_RECURSION,v=u(g).map(S=>S.trim());if(v.length>1&&(v.some(S=>S==="")||v.some(S=>/^[*?]+$/.test(S))||f(v)))return{risky:!0};for(const S of v){const x=m(S);if(x)return{risky:!0,safeOutput:x};if(h(S)>b)return{risky:!0}}return{risky:!1}},$=(g,w)=>{if(typeof g!="string")throw new TypeError("Expected a string");g=i[g]||g;const b={...w},v=typeof b.maxLength=="number"?Math.min(r,b.maxLength):r;let S=g.length;if(S>v)throw new SyntaxError(`Input length: ${S}, exceeds maximum allowed length: ${v}`);const x={type:"bos",value:"",output:b.prepend||""},E=[x],j=b.capture?"":"?:",k=e.globChars(b.windows),R=e.extglobChars(k),{DOT_LITERAL:P,PLUS_LITERAL:z,SLASH_LITERAL:U,ONE_CHAR:J,DOTS_SLASH:N,NO_DOT:O,NO_DOT_SLASH:F,NO_DOTS_SLASH:I,QMARK:M,QMARK_NO_DOT:_,STAR:H,START_ANCHOR:V}=k,B=L=>`(${j}(?:(?!${V}${L.dot?N:P}).)*?)`,D=b.dot?"":O,K=b.dot?M:_;let q=b.bash===!0?B(b):H;b.capture&&(q=`(${q})`),typeof b.noext=="boolean"&&(b.noextglob=b.noext);const A={input:g,index:-1,start:0,dot:b.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:E};g=t.removePrefix(g,A),S=g.length;const ae=[],ze=[],ve=[];let C=x,T;const Ie=()=>A.index===S-1,se=A.peek=(L=1)=>g[A.index+L],de=A.advance=()=>g[++A.index]||"",pe=()=>g.slice(A.index+1),We=(L="",le=0)=>{A.consumed+=L,A.index+=le},wt=L=>{A.output+=L.output!=null?L.output:L.value,We(L.value)},hr=()=>{let L=1;for(;se()==="!"&&(se(2)!=="("||se(3)==="?");)de(),A.start++,L++;return L%2===0?!1:(A.negated=!0,A.start++,!0)},un=L=>{A[L]++,ve.push(L)},st=L=>{A[L]--,ve.pop()},Q=L=>{if(C.type==="globstar"){const le=A.braces>0&&(L.type==="comma"||L.type==="brace"),W=L.extglob===!0||ae.length&&(L.type==="pipe"||L.type==="paren");L.type!=="slash"&&L.type!=="paren"&&!le&&!W&&(A.output=A.output.slice(0,-C.output.length),C.type="star",C.value="*",C.output=q,A.output+=C.output)}if(ae.length&&L.type!=="paren"&&(ae[ae.length-1].inner+=L.value),(L.value||L.output)&&wt(L),C&&C.type==="text"&&L.type==="text"){C.output=(C.output||C.value)+L.value,C.value+=L.value;return}L.prev=C,E.push(L),C=L},pn=(L,le)=>{const W={...R[le],conditions:1,inner:""};W.prev=C,W.parens=A.parens,W.output=A.output,W.startIndex=A.index,W.tokensIndex=E.length;const ee=(b.capture?"(":"")+W.open;un("parens"),Q({type:L,value:le,output:A.output?"":J}),Q({type:"paren",extglob:!0,value:de(),output:ee}),ae.push(W)},cm=L=>{const le=g.slice(L.startIndex,A.index+1),W=g.slice(L.startIndex+2,A.index),ee=y(W,b);if((L.type==="plus"||L.type==="star")&&ee.risky){const oe=ee.safeOutput?(L.output?"":J)+(b.capture?`(${ee.safeOutput})`:ee.safeOutput):void 0,Ue=E[L.tokensIndex];Ue.type="text",Ue.value=le,Ue.output=oe||t.escapeRegex(le);for(let Ge=L.tokensIndex+1;Ge<E.length;Ge++)E[Ge].value="",E[Ge].output="",delete E[Ge].suffix;A.output=L.output+Ue.output,A.backtrack=!0,Q({type:"paren",extglob:!0,value:T,output:""}),st("parens");return}let ue=L.close+(b.capture?")":""),me;if(L.type==="negate"){let oe=q;if(L.inner&&L.inner.length>1&&L.inner.includes("/")&&(oe=B(b)),(oe!==q||Ie()||/^\)+$/.test(pe()))&&(ue=L.close=`)$))${oe}`),L.inner.includes("*")&&(me=pe())&&/^\.[^\\/.]+$/.test(me)){const Ue=$(me,{...w,fastpaths:!1}).output;ue=L.close=`)${Ue})${oe})`}L.prev.type==="bos"&&(A.negatedExtglob=!0)}Q({type:"paren",extglob:!0,value:T,output:ue}),st("parens")};if(b.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(g)){let L=!1,le=g.replace(s,(W,ee,ue,me,oe,Ue)=>me==="\\"?(L=!0,W):me==="?"?ee?ee+me+(oe?M.repeat(oe.length):""):Ue===0?K+(oe?M.repeat(oe.length):""):M.repeat(ue.length):me==="."?P.repeat(ue.length):me==="*"?ee?ee+me+(oe?q:""):q:ee?W:`\\${W}`);return L===!0&&(b.unescape===!0?le=le.replace(/\\/g,""):le=le.replace(/\\+/g,W=>W.length%2===0?"\\\\":W?"\\":"")),le===g&&b.contains===!0?(A.output=g,A):(A.output=t.wrapOutput(le,A,w),A)}for(;!Ie();){if(T=de(),T==="\0")continue;if(T==="\\"){const W=se();if(W==="/"&&b.bash!==!0||W==="."||W===";")continue;if(!W){T+="\\",Q({type:"text",value:T});continue}const ee=/^\\+/.exec(pe());let ue=0;if(ee&&ee[0].length>2&&(ue=ee[0].length,A.index+=ue,ue%2!==0&&(T+="\\")),b.unescape===!0?T=de():T+=de(),A.brackets===0){Q({type:"text",value:T});continue}}if(A.brackets>0&&(T!=="]"||C.value==="["||C.value==="[^")){if(b.posix!==!1&&T===":"){const W=C.value.slice(1);if(W.includes("[")&&(C.posix=!0,W.includes(":"))){const ee=C.value.lastIndexOf("["),ue=C.value.slice(0,ee),me=C.value.slice(ee+2),oe=n[me];if(oe){C.value=ue+oe,A.backtrack=!0,de(),!x.output&&E.indexOf(C)===1&&(x.output=J);continue}}}(T==="["&&se()!==":"||T==="-"&&se()==="]")&&(T=`\\${T}`),T==="]"&&(C.value==="["||C.value==="[^")&&(T=`\\${T}`),b.posix===!0&&T==="!"&&C.value==="["&&(T="^"),C.value+=T,wt({value:T});continue}if(A.quotes===1&&T!=='"'){T=t.escapeRegex(T),C.value+=T,wt({value:T});continue}if(T==='"'){A.quotes=A.quotes===1?0:1,b.keepQuotes===!0&&Q({type:"text",value:T});continue}if(T==="("){un("parens"),Q({type:"paren",value:T});continue}if(T===")"){if(A.parens===0&&b.strictBrackets===!0)throw new SyntaxError(l("opening","("));const W=ae[ae.length-1];if(W&&A.parens===W.parens+1){cm(ae.pop());continue}Q({type:"paren",value:T,output:A.parens?")":"\\)"}),st("parens");continue}if(T==="["){if(b.nobracket===!0||!pe().includes("]")){if(b.nobracket!==!0&&b.strictBrackets===!0)throw new SyntaxError(l("closing","]"));T=`\\${T}`}else un("brackets");Q({type:"bracket",value:T});continue}if(T==="]"){if(b.nobracket===!0||C&&C.type==="bracket"&&C.value.length===1){Q({type:"text",value:T,output:`\\${T}`});continue}if(A.brackets===0){if(b.strictBrackets===!0)throw new SyntaxError(l("opening","["));Q({type:"text",value:T,output:`\\${T}`});continue}st("brackets");const W=C.value.slice(1);if(C.posix!==!0&&W[0]==="^"&&!W.includes("/")&&(T=`/${T}`),C.value+=T,wt({value:T}),b.literalBrackets===!1||t.hasRegexChars(W))continue;const ee=t.escapeRegex(C.value);if(A.output=A.output.slice(0,-C.value.length),b.literalBrackets===!0){A.output+=ee,C.value=ee;continue}C.value=`(${j}${ee}|${C.value})`,A.output+=C.value;continue}if(T==="{"&&b.nobrace!==!0){un("braces");const W={type:"brace",value:T,output:"(",outputIndex:A.output.length,tokensIndex:A.tokens.length};ze.push(W),Q(W);continue}if(T==="}"){const W=ze[ze.length-1];if(b.nobrace===!0||!W){Q({type:"text",value:T,output:T});continue}let ee=")";if(W.dots===!0){const ue=E.slice(),me=[];for(let oe=ue.length-1;oe>=0&&(E.pop(),ue[oe].type!=="brace");oe--)ue[oe].type!=="dots"&&me.unshift(ue[oe].value);ee=a(me,b),A.backtrack=!0}if(W.comma!==!0&&W.dots!==!0){const ue=A.output.slice(0,W.outputIndex),me=A.tokens.slice(W.tokensIndex);W.value=W.output="\\{",T=ee="\\}",A.output=ue;for(const oe of me)A.output+=oe.output||oe.value}Q({type:"brace",value:T,output:ee}),st("braces"),ze.pop();continue}if(T==="|"){ae.length>0&&ae[ae.length-1].conditions++,Q({type:"text",value:T});continue}if(T===","){let W=T;const ee=ze[ze.length-1];ee&&ve[ve.length-1]==="braces"&&(ee.comma=!0,W="|"),Q({type:"comma",value:T,output:W});continue}if(T==="/"){if(C.type==="dot"&&A.index===A.start+1){A.start=A.index+1,A.consumed="",A.output="",E.pop(),C=x;continue}Q({type:"slash",value:T,output:U});continue}if(T==="."){if(A.braces>0&&C.type==="dot"){C.value==="."&&(C.output=P);const W=ze[ze.length-1];C.type="dots",C.output+=T,C.value+=T,W.dots=!0;continue}if(A.braces+A.parens===0&&C.type!=="bos"&&C.type!=="slash"){Q({type:"text",value:T,output:P});continue}Q({type:"dot",value:T,output:P});continue}if(T==="?"){if(!(C&&C.value==="(")&&b.noextglob!==!0&&se()==="("&&se(2)!=="?"){pn("qmark",T);continue}if(C&&C.type==="paren"){const W=se();let ee=T;(C.value==="("&&!/[!=<:]/.test(W)||W==="<"&&!/<([!=]|\w+>)/.test(pe()))&&(ee=`\\${T}`),Q({type:"text",value:T,output:ee});continue}if(b.dot!==!0&&(C.type==="slash"||C.type==="bos")){Q({type:"qmark",value:T,output:_});continue}Q({type:"qmark",value:T,output:M});continue}if(T==="!"){if(b.noextglob!==!0&&se()==="("&&(se(2)!=="?"||!/[!=<:]/.test(se(3)))){pn("negate",T);continue}if(b.nonegate!==!0&&A.index===0){hr();continue}}if(T==="+"){if(b.noextglob!==!0&&se()==="("&&se(2)!=="?"){pn("plus",T);continue}if(C&&C.value==="("||b.regex===!1){Q({type:"plus",value:T,output:z});continue}if(C&&(C.type==="bracket"||C.type==="paren"||C.type==="brace")||A.parens>0){Q({type:"plus",value:T});continue}Q({type:"plus",value:z});continue}if(T==="@"){if(b.noextglob!==!0&&se()==="("&&se(2)!=="?"){Q({type:"at",extglob:!0,value:T,output:""});continue}Q({type:"text",value:T});continue}if(T!=="*"){(T==="$"||T==="^")&&(T=`\\${T}`);const W=o.exec(pe());W&&(T+=W[0],A.index+=W[0].length),Q({type:"text",value:T});continue}if(C&&(C.type==="globstar"||C.star===!0)){C.type="star",C.star=!0,C.value+=T,C.output=q,A.backtrack=!0,A.globstar=!0,We(T);continue}let L=pe();if(b.noextglob!==!0&&/^\([^?]/.test(L)){pn("star",T);continue}if(C.type==="star"){if(b.noglobstar===!0){We(T);continue}const W=C.prev,ee=W.prev,ue=W.type==="slash"||W.type==="bos",me=ee&&(ee.type==="star"||ee.type==="globstar");if(b.bash===!0&&(!ue||L[0]&&L[0]!=="/")){Q({type:"star",value:T,output:""});continue}const oe=A.braces>0&&(W.type==="comma"||W.type==="brace"),Ue=ae.length&&(W.type==="pipe"||W.type==="paren");if(!ue&&W.type!=="paren"&&!oe&&!Ue){Q({type:"star",value:T,output:""});continue}for(;L.slice(0,3)==="/**";){const Ge=g[A.index+4];if(Ge&&Ge!=="/")break;L=L.slice(3),We("/**",3)}if(W.type==="bos"&&Ie()){C.type="globstar",C.value+=T,C.output=B(b),A.output=C.output,A.globstar=!0,We(T);continue}if(W.type==="slash"&&W.prev.type!=="bos"&&!me&&Ie()){A.output=A.output.slice(0,-(W.output+C.output).length),W.output=`(?:${W.output}`,C.type="globstar",C.output=B(b)+(b.strictSlashes?")":"|$)"),C.value+=T,A.globstar=!0,A.output+=W.output+C.output,We(T);continue}if(W.type==="slash"&&W.prev.type!=="bos"&&L[0]==="/"){const Ge=L[1]!==void 0?"|$":"";A.output=A.output.slice(0,-(W.output+C.output).length),W.output=`(?:${W.output}`,C.type="globstar",C.output=`${B(b)}${U}|${U}${Ge})`,C.value+=T,A.output+=W.output+C.output,A.globstar=!0,We(T+de()),Q({type:"slash",value:"/",output:""});continue}if(W.type==="bos"&&L[0]==="/"){C.type="globstar",C.value+=T,C.output=`(?:^|${U}|${B(b)}${U})`,A.output=C.output,A.globstar=!0,We(T+de()),Q({type:"slash",value:"/",output:""});continue}A.output=A.output.slice(0,-C.output.length),C.type="globstar",C.output=B(b),C.value+=T,A.output+=C.output,A.globstar=!0,We(T);continue}const le={type:"star",value:T,output:q};if(b.bash===!0){le.output=".*?",(C.type==="bos"||C.type==="slash")&&(le.output=D+le.output),Q(le);continue}if(C&&(C.type==="bracket"||C.type==="paren")&&b.regex===!0){le.output=T,Q(le);continue}(A.index===A.start||C.type==="slash"||C.type==="dot")&&(C.type==="dot"?(A.output+=F,C.output+=F):b.dot===!0?(A.output+=I,C.output+=I):(A.output+=D,C.output+=D),se()!=="*"&&(A.output+=J,C.output+=J)),Q(le)}for(;A.brackets>0;){if(b.strictBrackets===!0)throw new SyntaxError(l("closing","]"));A.output=t.escapeLast(A.output,"["),st("brackets")}for(;A.parens>0;){if(b.strictBrackets===!0)throw new SyntaxError(l("closing",")"));A.output=t.escapeLast(A.output,"("),st("parens")}for(;A.braces>0;){if(b.strictBrackets===!0)throw new SyntaxError(l("closing","}"));A.output=t.escapeLast(A.output,"{"),st("braces")}if(b.strictSlashes!==!0&&(C.type==="star"||C.type==="bracket")&&Q({type:"maybe_slash",value:"",output:`${U}?`}),A.backtrack===!0){A.output="";for(const L of A.tokens)A.output+=L.output!=null?L.output:L.value,L.suffix&&(A.output+=L.suffix)}return A};return $.fastpaths=(g,w)=>{const b={...w},v=typeof b.maxLength=="number"?Math.min(r,b.maxLength):r,S=g.length;if(S>v)throw new SyntaxError(`Input length: ${S}, exceeds maximum allowed length: ${v}`);g=i[g]||g;const{DOT_LITERAL:x,SLASH_LITERAL:E,ONE_CHAR:j,DOTS_SLASH:k,NO_DOT:R,NO_DOTS:P,NO_DOTS_SLASH:z,STAR:U,START_ANCHOR:J}=e.globChars(b.windows),N=b.dot?P:R,O=b.dot?z:R,F=b.capture?"":"?:",I={negated:!1,prefix:""};let M=b.bash===!0?".*?":U;b.capture&&(M=`(${M})`);const _=D=>D.noglobstar===!0?M:`(${F}(?:(?!${J}${D.dot?k:x}).)*?)`,H=D=>{switch(D){case"*":return`${N}${j}${M}`;case".*":return`${x}${j}${M}`;case"*.*":return`${N}${M}${x}${j}${M}`;case"*/*":return`${N}${M}${E}${j}${O}${M}`;case"**":return N+_(b);case"**/*":return`(?:${N}${_(b)}${E})?${O}${j}${M}`;case"**/*.*":return`(?:${N}${_(b)}${E})?${O}${M}${x}${j}${M}`;case"**/.*":return`(?:${N}${_(b)}${E})?${x}${j}${M}`;default:{const K=/^(.*?)\.(\w+)$/.exec(D);if(!K)return;const q=H(K[1]);return q?q+x+K[2]:void 0}}},V=t.removePrefix(g,I);let B=H(V);return B&&b.strictSlashes!==!0&&(B+=`${E}?`),B},ai=$,ai}var li,mu;function kA(){if(mu)return li;mu=1;const e=EA(),t=SA(),r=zo(),n=Jo(),o=i=>i&&typeof i=="object"&&!Array.isArray(i),s=(i,a,l=!1)=>{if(Array.isArray(i)){const y=i.map($=>s($,a,l));return $=>{for(const g of y){const w=g($);if(w)return w}return!1}}const u=o(i)&&i.tokens&&i.input;if(i===""||typeof i!="string"&&!u)throw new TypeError("Expected pattern to be a non-empty string");const c=a||{},p=c.windows,f=u?s.compileRe(i,a):s.makeRe(i,a,!1,!0),d=f.state;delete f.state;let m=()=>!1;if(c.ignore){const y={...a,ignore:null,onMatch:null,onResult:null};m=s(c.ignore,y,l)}const h=(y,$=!1)=>{const{isMatch:g,match:w,output:b}=s.test(y,f,a,{glob:i,posix:p}),v={glob:i,state:d,regex:f,posix:p,input:y,output:b,match:w,isMatch:g};return typeof c.onResult=="function"&&c.onResult(v),g===!1?(v.isMatch=!1,$?v:!1):m(y)?(typeof c.onIgnore=="function"&&c.onIgnore(v),v.isMatch=!1,$?v:!1):(typeof c.onMatch=="function"&&c.onMatch(v),$?v:!0)};return l&&(h.state=d),h};return s.test=(i,a,l,{glob:u,posix:c}={})=>{if(typeof i!="string")throw new TypeError("Expected input to be a string");if(i==="")return{isMatch:!1,output:""};const p=l||{},f=p.format||(c?r.toPosixSlashes:null);let d=i===u,m=d&&f?f(i):i;return d===!1&&(m=f?f(i):i,d=m===u),(d===!1||p.capture===!0)&&(p.matchBase===!0||p.basename===!0?d=s.matchBase(i,a,l,c):d=a.exec(m)),{isMatch:!!d,match:d,output:m}},s.matchBase=(i,a,l)=>(a instanceof RegExp?a:s.makeRe(a,l)).test(r.basename(i)),s.isMatch=(i,a,l)=>s(a,l)(i),s.parse=(i,a)=>Array.isArray(i)?i.map(l=>s.parse(l,a)):t(i,{...a,fastpaths:!1}),s.scan=(i,a)=>e(i,a),s.compileRe=(i,a,l=!1,u=!1)=>{if(l===!0)return i.output;const c=a||{},p=c.contains?"":"^",f=c.contains?"":"$";let d=`${p}(?:${i.output})${f}`;i&&i.negated===!0&&(d=`^(?!${d}).*$`);const m=s.toRegex(d,a);return u===!0&&(m.state=i),m},s.makeRe=(i,a={},l=!1,u=!1)=>{if(!i||typeof i!="string")throw new TypeError("Expected a non-empty string");let c={negated:!1,fastpaths:!0};return a.fastpaths!==!1&&(i[0]==="."||i[0]==="*")&&(c.output=t.fastpaths(i,a)),c.output||(c=t(i,a)),s.compileRe(c,a,l,u)},s.toRegex=(i,a)=>{try{const l=a||{};return new RegExp(i,l.flags||(l.nocase?"i":""))}catch(l){if(a&&a.debug===!0)throw l;return/$^/}},s.constants=n,li=s,li}var ci,hu;function jA(){if(hu)return ci;hu=1;const e=kA(),t=zo();function r(n,o,s=!1){return o&&(o.windows===null||o.windows===void 0)&&(o={...o,windows:t.isWindows()}),e(n,o,s)}return Object.assign(r,e),ci=r,ci}var AA=jA();const OA=Zr(AA),RA=e=>e.logger,Wi="Validation: File Size",om=e=>typeof e=="string"?Pw(e):e,sm=(e,t,r,n,o)=>{if(r){o&&e.raw(`
|
|
189
|
+
`),e.warn({message:t,prefix:"validation:file-size"});return}Y(n,t)},CA=(e,t,r,n,o)=>{for(const[s,i]of Object.entries(r)){const a=om(i);if(!Number.isFinite(a)||a<=0){t.debug({message:`Invalid limit for ${s}: ${String(i)}`,prefix:Wi});continue}const l=e.buildEntries.find(u=>{const c=s.replace(new RegExp(`^.?/?${qd(e.options.outDir)}/?`),"");return u.path.endsWith(c)||OA(s)(u.path)});if(!l?.size?.bytes){t.debug({message:l?`Entry file has no size information: ${s}.`:`Entry file not found: ${s}, please check your configuration.`,prefix:Wi});continue}if(l.size.bytes>a){const u=`File size exceeds the limit: ${G(e.options.outDir,l.path)} (${je(l.size.bytes)} / ${je(a,{decimals:2})})`;sm(t,u,n,e,o)}}},TA=(e,t,r,n,o)=>{const s=e.buildEntries.reduce((a,l)=>{const u=l.size?.bytes;return a+(typeof u=="number"?u:0)},0),i=om(r);if(!Number.isFinite(i)||i<=0){t.debug({message:`Invalid total limit: ${String(r)}`,prefix:Wi});return}if(s>i){const a=`Total file size exceeds the limit: ${je(s)} / ${je(i,{decimals:2})}`;sm(t,a,n,e,o)}},NA=(e,t)=>{const r=e.options.validation,{allowFail:n=!1,limit:o,limits:s={}}=r.bundleLimit??{},i=RA(e);CA(e,i,s,n,t),o&&TA(e,i,o,n,t&&Object.keys(s).length===0)},gu="rollup-dts.json",PA=e=>{const t=new Set,r=[];for(const[n,o]of Object.entries(e))o.type==="chunk"&&o.isEntry&&(t.add(n),r.push(n));if(r.length!==0){for(;r.length>0;){const n=r.pop(),o=e[n];if(o.type==="chunk")for(const s of[...o.imports,...o.dynamicImports])Object.hasOwn(e,s)&&e[s].type==="chunk"&&!t.has(s)&&(t.add(s),r.push(s))}return t}},MA=e=>{const t=PA(e);if(t)for(const[r,n]of Object.entries(e))n.type==="chunk"&&!n.isEntry&&!t.has(r)&&delete e[r]},_A=e=>e.logger,yu="__packem_skip__/",$u=(e,t)=>{const r=new Set;if(t.options.emitCJS&&r.add(Ke(t,"cjs")),t.options.emitESM&&r.add(Ke(t,"esm")),(t.options.declaration===!0||t.options.declaration==="compatible")&&r.add("d.ts"),e.declarationExtensions)for(const n of e.declarationExtensions)r.add(n);return r},IA=async(e,t,r)=>{const n=await Nd(e,t);if(await e.hooks.callHook("rollup:dts:options",e,n),Object.keys(n.input??{}).length===0)return;const o=`${r}/${Ve(e.options.entries.map(i=>i.name??"").filter(Boolean).toSorted((i,a)=>i.localeCompare(a)).join(","))}`;n.cache=t.get(gu,o);const s=await(await Ca())(n);try{t.set(gu,s.cache,o),await e.hooks.callHook("rollup:dts:build",e,s),_A(e).info({message:"Building declaration files...",prefix:"dts"});const i=new Map;for(const c of e.options.entries)c.name&&i.set(c.name,c);const a=new Set;for(const c of e.options.entries)for(const p of $u(c,e))a.add(p);const l=X(e.options.rootDir,e.options.outDir),u={generateBundle(c,p){for(const f of Object.keys(p))f.startsWith(yu)&&delete p[f];MA(p)},name:"packem:filter-skip-chunks"};for(const c of a)await s.write({chunkFileNames:p=>Br(p,c),dir:l,entryFileNames:p=>{const f=p.name.endsWith(".d")?p.name.slice(0,-2):p.name,d=f?i.get(f):void 0;return d&&!$u(d,e).has(c)?`${yu}[name].${c}`:`[name].${c}`},plugins:[u]});await e.hooks.callHook("rollup:dts:done",e)}finally{await s.close(),await t.flush()}};var WA=sn();const im=Zr(WA),BA=Fh("packem:exe"),DA=/(?:^|,)packem:exe(?:,|$)/,LA=()=>{const e=process.env.NODE_DEBUG;return e?DA.test(e):!1},am=()=>{const e=((t,...r)=>{BA(t,...r)});return Object.defineProperty(e,"enabled",{get:LA}),e},FA=()=>{const e=ch();if(er==="darwin")return G(e,"Library/Caches/packem");if(er==="win32"){const r=process.env.LOCALAPPDATA;return r?G(r,"packem/Caches"):G(e,"AppData/Local/packem/Caches")}const t=process.env.XDG_CACHE_HOME;return t?G(t,"packem"):G(e,".cache/packem")},HA=e=>{const t=FA(),r=e.platform==="win"?"node.exe":"node";return G(t,"node",`v${e.nodeVersion}`,`${e.platform}-${e.arch}`,r)};var qA=Wu();const JA=Zr(qA),lm=e=>e==="win"?"zip":e==="linux"?"tar.xz":"tar.gz",zA=e=>{const{arch:t,nodeVersion:r,platform:n}=e,o=lm(n);return`https://nodejs.org/dist/v${r}/node-v${r}-${n}-${t}.${o}`},UA=e=>{const{arch:t,nodeVersion:r,platform:n}=e,o=`node-v${r}-${n}-${t}`;return n==="win"?`${o}/node.exe`:`${o}/bin/node`},bu="https://nodejs.org/dist/index.json",GA=/^v/,VA=async e=>{let t=e;if(t==="latest"||t==="latest-lts"){const n=await fetch(bu);if(!n.ok)throw new Error(`Failed to fetch Node.js releases: HTTP ${String(n.status)} from ${bu}`);const o=await n.json(),s=t==="latest";let i="";for(const a of o)if(s||a.lts!==!1){i=a.version;break}if(i==="")throw new Error(`No matching Node.js release found for "${t}".`);t=i.replace(GA,"")}const r=JA(t);if(!r)throw new Error(`Invalid Node.js version: ${t}. Please provide a valid version string (e.g., "25.7.0").`);if(!im(r,">=25.7.0"))throw new Error(`Node.js ${r} does not support SEA (Single Executable Applications). Required minimum version is 25.7.0. Please update the nodeVersion in your target configuration.`);return r},KA=e=>`-${e.platform}-${e.arch}`,tt=am(),YA=async(e,t)=>{const r=`https://nodejs.org/dist/v${e}/SHASUMS256.txt`;tt("Fetching checksums from: %s",r);const n=await fetch(r);if(!n.ok)throw new Error(`Failed to download Node.js checksums: HTTP ${String(n.status)} from ${r}`);const o=await n.text();for(const s of o.split(`
|
|
190
|
+
`)){const[i,a]=s.trim().split(/\s+/);if(a===t&&i)return i.toLowerCase()}throw new Error(`No checksum entry for "${t}" found in ${r}.`)},XA=async(e,t,r)=>{const n=UA(r),o=Z(t);if(tt("Extracting %s from archive to %s",n,o),r.platform==="win")await Fn("tar",["-xf",e,"-C",o,"--strip-components=1",n],{nodeOptions:{stdio:"inherit"},throwOnError:!0});else{const a=e.endsWith(".tar.xz")?"J":"z";await Fn("tar",[`-x${a}f`,e,"-C",o,"--strip-components=2",n],{nodeOptions:{stdio:"inherit"},throwOnError:!0})}const s=r.platform==="win"?"node.exe":"node",i=G(o,s);i!==t&&await gh(i,t)},ZA=async(e,t)=>{tt("Resolving Node.js binary for target: %O",e);const r={...e,nodeVersion:await VA(e.nodeVersion)},n=HA(r);if(tt("Cache path: %s",n),await Ct(n))return tt("Cache hit: %s",n),t.info(`Using cached Node.js ${r.nodeVersion} for ${r.platform}-${r.arch}`),n;const o=zA(r);tt("Cache miss, downloading from: %s",o),t.info(`Downloading Node.js ${r.nodeVersion} for ${r.platform}-${r.arch}...`),t.info(` ${o}`),await Xu(Z(n),{recursive:!0});const s=await fetch(o);if(!s.ok)throw new Error(`Failed to download Node.js binary: HTTP ${String(s.status)} from ${o}`);const i=lm(r.platform),a=Uh.from(await s.arrayBuffer()),l=Fe(o),u=await YA(r.nodeVersion,l),c=Oh("sha256").update(a).digest("hex");if(c!==u)throw new Error(`Checksum mismatch for ${l}: expected ${u}, got ${c}. The download may be corrupted or tampered with.`);tt("Checksum verified for %s",l);const p=`${n}.download.${Rh()}.${i}`;tt("Downloaded %d bytes, writing to: %s",a.length,p),await Zu(p,a);try{await XA(p,n,r),r.platform!=="win"&&await Ku(n,493),tt("Binary cached at: %s",n),t.info(`Cached Node.js binary at: ${n}`)}finally{await po(p,{force:!0})}return n},Kt=am(),QA=/\.d\.[mc]?ts$/,e3=e=>({buildEntries:e.buildEntries,logger:e.logger,options:e.options,packageType:e.pkg.type}),t3=e=>{const{logger:t,options:r}=e;if(Dn.bun||Dn.deno)throw new Error("The `exe` option is not supported in Bun and Deno environments.");if(!im(process.version,">=25.7.0"))throw new Error(`Node.js ${process.version} does not support \`exe\` option. Please upgrade to Node.js 25.7.0 or later.`);if(r.entries.length>1){const n=r.entries.map(o=>`- ${o.input}`).join(`
|
|
191
|
+
`);throw new Error(`The \`exe\` feature only supports a single entry point. Found ${String(r.entries.length)} entries:
|
|
192
|
+
${n}`)}r.declaration&&t.warn("Generating .d.ts files with the `exe` option is not recommended since they won't be included in the executable. Consider separating your library and executable targets if you need type declarations."),t.info("`exe` option is experimental and may change in future releases.")},r3=(e,t)=>e.endsWith(".cjs")?"commonjs":e.endsWith(".mjs")||t==="module"?"module":"commonjs",wu=er==="win32"?"win":er,vu=(e,t,r,n,o)=>{let s;return e.fileName?s=typeof e.fileName=="function"?e.fileName(t):e.fileName:s=Fe(r,tr(r)),o&&(s+=o),n==="win"&&(s+=".exe"),s},xu=async(e,t,r,n,o,s,i)=>{const{logger:a,options:l,packageType:u}=e,c=X(l.rootDir,t.outDir??"build");await Xu(c,{recursive:!0});const p=G(c,o);Kt("Building SEA executable: %s -> %s",n,p);const f=performance.now(),d=await Yu(G(Uu(),"packem-sea-"));try{const h={disableExperimentalSEAWarning:!0,...t.seaConfig,main:n,mainFormat:r3(r.path,u),output:p};i&&(h.executable=i);const y=G(d,"sea-config.json");await Zu(y,JSON.stringify(h)),Kt("Wrote sea-config.json: %O -> %s",h,y),Kt("Running: %s --build-sea %s",process.execPath,y),await Fn(process.execPath,["--build-sea",y],{nodeOptions:{stdio:["ignore","ignore","inherit"]},throwOnError:!0})}finally{Kt.enabled?Kt("Preserving temp directory for debugging: %s",d):await po(d,{force:!0,recursive:!0})}if(s==="darwin")try{await Fn("codesign",["--sign","-",p],{nodeOptions:{stdio:"inherit"},throwOnError:!0})}catch{const h=er==="darwin"?`You can sign it manually using:
|
|
193
|
+
codesign --sign - "${p}"`:`Automatic code signing is not supported on ${er}.`;a.warn(`Failed to code-sign the executable. ${h}`)}if(await Ct(p)){const h=await Qr(p),y=je(h.size,{decimals:2});a.info(`${Ae(Se(l.rootDir,p))} ${Ou(y)}`)}const m=Math.round(performance.now()-f);a.success(`Built executable: ${qt(Se(l.rootDir,p))} ${De(`(${String(m)}ms)`)}`)},n3=async e=>{const t=e3(e),{buildEntries:r,logger:n,options:o}=t,s=o.exe;if(!s)return;const i=typeof s=="object"?s:{};t3(t);const a=r.filter(p=>p.type==="entry"&&!QA.test(p.path));if(a.length===0)throw new Error("The `exe` feature requires a built entry, but no entry chunks were found.");if(a.length>1){const p=a.map(f=>`- ${f.path}`).join(`
|
|
194
|
+
`);throw new Error(`The \`exe\` feature only supports single-chunk outputs. Found ${String(a.length)} chunks:
|
|
195
|
+
${p}`)}const l=a[0],u=G(o.rootDir,o.outDir,l.path);Kt("Building executable with SEA for chunk: %s",l.path);const{targets:c}=i;if(c!==void 0&&c.length>0){i.seaConfig?.executable&&n.warn("`seaConfig.executable` is ignored when `targets` is specified.");for(const p of c){const f=await ZA(p,n),d=KA(p),m=vu(i,l,u,p.platform,d);await xu(t,i,l,u,m,p.platform,f)}}else{const p=vu(i,l,u,wu);await xu(t,i,l,u,p,wu)}},o3=async(e,t)=>{if(e.length===0)return[];const r=t<=0||!Number.isFinite(t)?1/0:t,n=Array.from({length:e.length});let o=0;const s=async()=>{for(;o<e.length;){const a=o;o+=1;const l=e[a];l&&(n[a]=await l())}},i=Array.from({length:Math.min(r,e.length)},()=>s());return await Promise.all(i),n},s3=async e=>await new Promise((t,r)=>{let n=0;const o=zi(e).pipe(qh({params:{[Jh.BROTLI_PARAM_QUALITY]:4}}));o.on("error",r),o.on("data",s=>{n+=s.length}),o.on("end",()=>{t(n)})}),ui=e=>e==null?"undefined":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"||typeof e=="symbol"?e.toString():JSON.stringify(e),pi=(e,t,r)=>{let n=e.get(t);return n===void 0&&(n=r(),e.set(t,n)),n},i3=(e,t,r,n)=>{{const o=new Map;for(const i of e){const a=pi(o,ui(i[t]),()=>new Map),l=pi(a,ui(i[r]),()=>new Map);pi(l,ui(i[n]),()=>[]).push(i)}const s={};for(const[i,a]of o){const l={};for(const[u,c]of a)l[u]=Object.fromEntries(c);s[i]=l}return s}},a3=async e=>await new Promise((t,r)=>{let n=0;const o=zi(e).pipe(zh({level:9}));o.on("error",r),o.on("data",s=>{n+=s.length}),o.on("end",()=>{t(n)})}),l3=2,c3=/\.js$/,u3=/\.d\.[m|c]ts$/,p3=(e,t,r)=>[`total size: ${re(je(t,{decimals:2}))}`,e.size?.brotli&&`brotli size: ${re(je(e.size.brotli,{decimals:2}))}`,e.size?.gzip&&`gzip size: ${re(je(e.size.gzip,{decimals:2}))}`,r!==0&&`chunk size: ${re(je(r,{decimals:2}))}`].filter(Boolean).join(", "),f3=(e,t,r,n)=>{const o=Pe(t,"cjs"),s=Pe(t,"esm"),i=Ke(t,"cjs"),a=Ke(t,"esm");let l=e.path.replace(c3,".d.ts"),u="commonjs";e.path.endsWith(`.${o}`)?l=e.path.replace(new RegExp(String.raw`\.${o}$`),`.${i}`):e.path.endsWith(`.${s}`)&&(u="module",l=e.path.replace(new RegExp(String.raw`\.${s}$`),`.${a}`));const c=t.buildEntries.find(f=>f.path.endsWith(l));if(!c)return"";n.push(c.path);let p;return!l.includes(".d.ts")&&(l=l.replace(u3,".d.ts"),p=t.buildEntries.find(f=>f.path.endsWith(l)),!p)?"":(p&&n.push(p.path),u==="commonjs"&&p?`
|
|
196
|
+
types:
|
|
197
|
+
${[c,p].map(f=>`${De(" └─ ")+Ae(r(f.path))} (total size: ${re(je(f.size?.bytes??0,{decimals:2}))})`).join(`
|
|
198
|
+
`)}`:`
|
|
199
|
+
types: ${Ae(r(c.path))} (total size: ${re(je(c.size?.bytes??0,{decimals:2}))})`)},d3=(e,t,r,n)=>{let o=e.size?.bytes??0,s=0;for(const a of e.chunks??[]){const l=t.buildEntries.find(u=>u.path.endsWith(a))?.size?.bytes??0;o+=l,s+=l}let i=` ${Ae(r(e.path))} (${p3(e,o,s)})`;if(i+=e.exports?.length?`
|
|
200
|
+
exports: ${De(e.exports.join(", "))}`:"",e.chunks?.length&&(i+=`
|
|
201
|
+
${e.chunks.map(a=>{const l=t.buildEntries.find(u=>u.path===a)?.bytes;return De(` └─ ${r(a)}${Ae(l?` (${je(l,{decimals:2})})`:"")}`)}).join(`
|
|
202
|
+
`)}`),e.dynamicImports&&e.dynamicImports.length>0&&(i+=`
|
|
203
|
+
dynamic imports:`,i+=`
|
|
204
|
+
${e.dynamicImports.map(a=>De(` └─ ${r(a)}`)).join(`
|
|
205
|
+
`)}`),e.modules&&e.modules.length>0){const a=e.modules.filter(l=>l.id.includes("node_modules")).toSorted((l,u)=>(u.bytes||0)-(l.bytes||0)).map(l=>De(` 📦 ${r(l.id)}${Ae(l.bytes?` (${je(l.bytes,{decimals:2})})`:"")}`)).join(`
|
|
206
|
+
`);i+=a.length>0?`
|
|
207
|
+
inlined modules:
|
|
208
|
+
${a}`:""}return t.options.declaration&&(i+=f3(e,t,r,n)),i+=`
|
|
209
|
+
|
|
210
|
+
`,e.chunk?De(i):i},m3=(e,t)=>{const r=i=>Se(t.options.rootDir,X(t.options.outDir,i));let n=!1;const o=[],s=t.buildEntries.filter(i=>i.type==="entry");if(s.length>0){e.raw(`Entries:
|
|
211
|
+
`);for(const i of s){const a=d3(i,t,r,o);n=!0,e.raw(a)}}if(t.buildEntries.filter(i=>i.type==="asset").length>0){let i="Assets:";for(const a of t.buildEntries.filter(l=>l.type==="asset"&&!o.includes(l.path)))i+=`${De(`
|
|
212
|
+
└─ `)+Ae(r(a.path))} (total size: ${re(je(a.size?.bytes??0,{decimals:2}))})`;i+=`
|
|
213
|
+
|
|
214
|
+
`,e.raw(i)}return n&&e.raw("Σ Total dist size (byte size):",re(je(t.buildEntries.reduce((i,a)=>i+(a.size?.bytes??0),0),{decimals:2})),`
|
|
215
|
+
`),n},h3=/\.d\.[mc]?ts$/,fi=e=>e.filter(t=>!h3.test(t.input)),g3=(e,t)=>{const r=[];return e!=="undefined"&&r.push(`${re(e)} environment`),t!=="undefined"&&r.push(`${re(t)} runtime`),r.length>0?`Preparing build for ${r.join(" with ")}`:""},y3=(e,t)=>{const r={};return e!=="undefined"&&(r[["process","env","NODE_ENV"].join(".")]=JSON.stringify(e)),r[["process","env","EdgeRuntime"].join(".")]=JSON.stringify(t==="edge-light"),Object.freeze(r)},$3=(e,t)=>{const r=[];return e!=="undefined"&&r.push(e),t!=="undefined"&&r.push(t),r.length>0?`${r.join("/")}/`:""},On=(e,t,r,n,o,s)=>({...e,options:{...e.options,emitCJS:t,emitESM:r,entries:n,minify:o,rollup:{...e.options.rollup,replace:e.options.rollup.replace?Do(e.options.rollup.replace,{},s):!1}}}),b3=async(e,t)=>{const r=e.logger,n=l=>{const u=l.name??l.fileAlias;if(!u)return"default";const c=[".browser",".server",".development",".node",".workerd"];for(const p of c)if(u.includes(p))return p.slice(1);return"default"},o=e.options.entries.map(l=>({...l,environment:l.environment??"undefined",runtime:l.runtime??"undefined",type:n(l)})),s=i3(o,"environment","runtime","type"),i=new Set,a=new Set;for(const[l,u]of Object.entries(s))for(const[c,p]of Object.entries(u))for(const[,f]of Object.entries(p)){const d={...e,environment:l==="undefined"?void 0:l,options:{...e.options,rollup:{...e.options.rollup,replace:e.options.rollup.replace?{...e.options.rollup.replace,values:{}}:e.options.rollup.replace}}};if(!e.options.dtsOnly&&(l!=="undefined"||c!=="undefined")){const k=g3(l,c);k&&r.info(k)}const m=c==="undefined"?void 0:c;d.options.runtime=m;try{await e.hooks.callHook("rollup:options",d,{})}catch(k){throw r.error(`Error calling rollup:options hook: ${String(k)}`),k}const h=d.options.rollup.replace,y=e.options.rollup.replace,$=h?y3(l,c):{};if(h){h.values??={};const k=y?Do(y).values:{};Object.assign(h.values,$,k)}else r.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");const g=h?h.values??$:$,w=$3(l,c);let b=d.options.minify??!1;l==="development"?b=!1:l==="production"&&(b=!0);const v=f.map(k=>{const{environment:R,runtime:P,...z}=k;return{...z,environment:R==="undefined"?void 0:R,runtime:P==="undefined"?void 0:P}}),S=[],x=[],E=[],j=[];for(const k of v){if(Yr(k.name)){k.declaration&&j.push(k);continue}k.cjs&&k.esm?S.push(k):k.cjs?E.push(k):k.esm?x.push(k):k.declaration&&j.push(k)}if(S.length>0){const k=On(d,!0,!0,fi(S),b,g);if(e.options.dtsOnly||i.add({context:k,fileCache:t,subDirectory:w}),e.options.declaration){const R=S.filter(P=>P.declaration);R.length>0&&a.add({context:{...k,options:{...k.options,entries:R}},fileCache:t,subDirectory:w})}}if(x.length>0){const k=On(d,!1,!0,fi(x),b,g);if(e.options.dtsOnly||i.add({context:k,fileCache:t,subDirectory:w}),e.options.declaration){const R=x.filter(P=>P.declaration);R.length>0&&a.add({context:{...k,options:{...k.options,entries:R}},fileCache:t,subDirectory:w})}}if(E.length>0){const k=On(d,!0,!1,fi(E),b,g);if(e.options.dtsOnly||i.add({context:k,fileCache:t,subDirectory:w}),e.options.declaration){const R=E.filter(P=>P.declaration);R.length>0&&a.add({context:{...k,options:{...k.options,entries:R}},fileCache:t,subDirectory:w})}}if(d.options.declaration&&j.length>0){const k=j.some(U=>U.declarationCjs),R=j.some(U=>U.declarationEsm),P=j.some(U=>U.declaration&&!U.declarationCjs&&!U.declarationEsm),z=On(d,k||P,R,j,b,g);a.add({context:z,fileCache:t,subDirectory:w})}}return{builders:i,typeBuilders:a}},w3=async(e,t)=>{const r=e.logger;await e.hooks.callHook("build:before",e);const{builders:n,typeBuilders:o}=await b3(e,t);if(n.size>0&&await Promise.all(Array.from(n,async({context:l,fileCache:u,subDirectory:c})=>t9(l,u,c,Dd(l.options.bundler)))),o.size>0){const l=e.options.dtsConcurrency??l3;await o3(Array.from(o,({context:u,fileCache:c,subDirectory:p})=>()=>IA(u,c,p)),l)}r.success(Li(e.options.name?`Build succeeded for ${e.options.name}`:"Build succeeded"));const s=new Set;e.buildEntries=e.buildEntries.filter(l=>s.has(l.path)?!1:(s.add(l.path),!0));const i=G(e.options.rootDir,e.options.outDir),a=[];for await(const l of gm(i,{includeDirs:!1,includeFiles:!0})){let u=e.buildEntries.find(f=>G(i,f.path)===l.path);u||(u={chunk:!0,path:l.path},e.buildEntries.push(u)),u.size??={};const c=X(i,l.path),p=u.size;a.push((async()=>{if(!p.bytes){const m=await Qr(c);p.bytes=m.size}const[f,d]=await Promise.all([p.brotli??s3(c),p.gzip??a3(c)]);p.brotli=f,p.gzip=d})())}return await Promise.all(a),e.options.exe&&await n3(e),await e.hooks.callHook("build:done",e),m3(r,e)},v3=e=>Object.fromEntries(Object.entries(e).map(([t,r])=>{if(!r)return[t,{}];const n=Object.fromEntries(Object.entries(r).map(([o,s])=>Array.isArray(s)?[o,[...new Set(s)]]:[o,[]]));return[t,n]})),x3=async(e,t,r,n,o,s)=>{const i=e;if(s!=="*"&&Le.valid(Le.coerce(s))===null)throw new Error("Invalid typeScriptVersion option. It must be a valid semver range.");i.info({message:"Declaration node10 compatibility mode is enabled.",prefix:"plugin:packem:node10-compatibility"});const a={};for(const c of t){if(c.exportKey===void 0||c.name===void 0)continue;const{name:p}=c;for(const f of c.exportKey)a[f]=f.includes("/*")?[`./${G(r,Z(p),"*.d.ts")}`]:[...a[f]??[],`./${G(r,`${p}.d.ts`)}`]}const l=G(n,"package.json"),u=await lo(l);o==="file"&&Object.keys(a).length>0?(await ku(l,{...u,typesVersions:v3({...u.typesVersions,[s]:a})},{detectIndent:!0}),i.info({message:'Your package.json "typesVersions" field has been updated.',prefix:"plugin:packem:node10-compatibility"})):Object.keys(a).length>0&&i.info({message:`Please add the following field into your package.json to enable node 10 compatibility:
|
|
216
|
+
|
|
217
|
+
${JSON.stringify({typesVersions:{"*":a}},void 0,4)}
|
|
218
|
+
`,prefix:"plugin:packem:node10-compatibility"})},Ht=e=>e??{},E3=/\.(md|txt|htm|html|data)$/,S3=/^@swc\/helpers(?:\/.*)?$/,k3=e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},j3=(e,t,r,n,o,s,i,a)=>{const l=k3(i?.config.compilerOptions?.jsx),u=a.split("."),c=A9()(C1,o,{alias:{},browserTargets:rh(),cjsInterop:!1,clean:!0,debug:n,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[],failOnWarn:!0,fileCache:!0,jiti:{alias:{},debug:n,interopDefault:!0},minify:r===Wr,name:(s.name??"").split("/").pop()??"default",outDir:i?.config.compilerOptions?.outDir??"dist",rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{extensions:[".mjs",".js",".json",".node",".cjs"],ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!0},css:{autoModules:!0,extensions:[".css",".pcss",".postcss",".sss"],namedExports:!0},dataUri:{srcset:!0},debarrel:{},detectDuplicated:{},dts:{compilerOptions:{baseUrl:i?.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}},dynamicVars:{errorWhenNoFilesFound:!0,exclude:kt,include:Et},esbuild:{charset:"utf8",jsx:l,jsxDev:i?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:i?.config.compilerOptions?.jsxFactory,jsxFragment:Ht(i?.config.compilerOptions).jsxFragmentFactory,jsxImportSource:Ht(i?.config.compilerOptions).jsxImportSource,jsxSideEffects:!0,keepNames:!1,sourcesContent:!1,supported:{"import-attributes":!0},target:i?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:i?.config},json:{preferConst:!1},license:{dependenciesTemplate:(d,m,h)=>`
|
|
219
|
+
# Licenses of bundled dependencies
|
|
220
|
+
The published ${h} artifact additionally contains code with the following licenses:
|
|
221
|
+
${d.length>0?`${d.join(", ")}
|
|
222
|
+
|
|
223
|
+
`:`
|
|
224
|
+
`}# Bundled dependencies:
|
|
225
|
+
${m}`,dtsTemplate:(d,m,h)=>`
|
|
226
|
+
# Licenses of bundled types
|
|
227
|
+
The published ${h} artifact additionally contains code with the following licenses:
|
|
228
|
+
${d.length>0?`${d.join(", ")}
|
|
229
|
+
|
|
230
|
+
`:`
|
|
231
|
+
`}# Bundled types:
|
|
232
|
+
${m}`},nativeModules:{},node10Compatibility:!1,output:{importAttributesKey:Number(u[0])>=22?"with":"assert"},oxc:{jsx:l==="preserve"?"preserve":{development:r!=="production",pragma:i?.config.compilerOptions?.jsxFactory,pragmaFrag:Ht(i?.config.compilerOptions).jsxFragmentFactory,pure:!0,runtime:l==="transform"||l==="automatic"?"automatic":"classic",useBuiltIns:!0,useSpread:!0}},patchTypes:{},polyfillNode:{},preserveDirectives:{include:Et},preserveDynamicImports:!0,pure:{},raw:{exclude:kt,include:[E3]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{aliasFields:[],builtinModules:!1,conditionNames:[r??"production","module-sync","import","require","default"],extensions:uo,mainFields:["module","main"]},resolveExternals:{builtins:!0,builtinsPrefix:"add",deps:!0,devDeps:!1,exclude:[],optDeps:!0,peerDeps:!0},shebang:{replace:!1,shebang:"#!/usr/bin/env node"},shim:{exclude:kt,include:Et},sourcemap:{},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:!i?.config.compilerOptions?.esModuleInterop,include:Et,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:r===Wr,...i?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(i.config.compilerOptions.jsx)?{jsxFragmentPragma:Ht(i.config.compilerOptions).jsxFragmentFactory,jsxImportSource:Ht(i.config.compilerOptions).jsxImportSource,jsxPragma:i.config.compilerOptions.jsxFactory,jsxRuntime:l,transforms:["typescript","jsx"]}:{transforms:["typescript"]}},swc:{include:Et,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!0,keepClassNames:!0,loose:!0,parser:{decorators:i?.config.compilerOptions?.experimentalDecorators,syntax:i?"typescript":"ecmascript",[i?"tsx":"jsx"]:!0},target:i?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:i?.config.compilerOptions?.emitDecoratorMetadata,decoratorVersion:"2022-03",legacyDecorator:i?.config.compilerOptions?.experimentalDecorators,react:{development:r!==Wr,pragma:i?.config.compilerOptions?.jsxFactory,pragmaFrag:Ht(i?.config.compilerOptions).jsxFragmentFactory,runtime:l,throwIfNamespace:!0},treatConstEnumAsEnum:i?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:i?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:R9(t,s),preset:"recommended",propertyReadSideEffects:!0},tsconfigPaths:{resolveAbsolutePath:!1},url:{emitFiles:!0,fileName:"[hash][extname]",include:["**/*.svg","**/*.png","**/*.jp(e)?g","**/*.gif","**/*.webp"],limit:14*1024},visualizer:{},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:kt}},rootDir:t,sourceDir:"src",sourcemap:!1,transformerName:void 0,typedoc:{excludePrivate:!0,format:"inline",githubPages:!1,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:s.name??"unknown",pretty:!0,readme:"none",showConfig:n,tsconfig:i?.path},validation:{dependencies:{hoisted:{exclude:[]},unused:{exclude:[]}},packageJson:{bin:!0,dependencies:!0,exports:!0,files:!0,main:!0,module:!0,name:!0,types:!0,typesVersions:!0}}});c.runtime===void 0&&(e.warn(`No runtime specified, defaulting to 'node'. Add 'runtime: "node"' (or 'runtime: "browser"') to your packem config or pass --runtime to silence this warning.`),c.runtime="node");const p=new Map([...Object.entries(s.dependencies??{}),...Object.entries(s.devDependencies??{})]),f=c.bundler==="rolldown";if(f&&o.transformer!==void 0)throw new Error('The `transformer` option is not supported when `bundler: "rolldown"`. Rolldown uses its own oxc-based transform — remove `transformer` from your packem config.');if(!f){if(c.transformer?.NAME===void 0)throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");c.transformerName=c.transformer.NAME,c.transformerName==="swc"&&(c.externals=[...c.externals,S3])}if(e.info({message:`Using ${re("node ")}${a}`,prefix:"system"}),e.info({message:f?`Using ${re("rolldown")} with ${re(c.runtime)} build runtime`:`Using ${re("rollup")} with ${re(c.runtime)} build runtime`,prefix:"bundler"}),!f&&c.transformerName){let d=c.transformerName;c.transformerName==="oxc"?d="oxc-transform":c.transformerName==="swc"&&(d="@swc/core");const m=p.get(d)??"0.0.0";e.info({message:`Using ${re(c.transformerName)} ${m}`,prefix:"transformer"})}if(c.rollup.resolve&&(c.rollup.resolve.preferBuiltins=c.runtime==="node",c.rollup.resolve.preferBuiltins&&(c.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true"))),c.resolvedBrowserTargets??=c.browserTargets??[],c.runtime==="node"&&(c.browserTargets=[]),c.runtime==="browser"&&(c.rollup.resolve&&c.rollup.resolve.browser===void 0&&(c.rollup.resolve.browser=!0),c.browserTargets&&c.browserTargets.length>0&&e.debug(`Using browser targets: ${c.browserTargets.join(", ")}`)),cu(c.alias),c.rollup.alias!==!1&&c.rollup.alias?.entries&&cu(c.rollup.alias.entries),c.outputExtensionMap){let d;for(const[m,h]of Object.entries(c.outputExtensionMap)){if(!["cjs","esm"].includes(m))throw new Error(`Invalid output extension map: ${m} must be "cjs" or "esm"`);if(typeof h!="string")throw new TypeError(`Invalid output extension map: ${m} must be a string`);if(h.startsWith("."))throw new Error(`Invalid output extension map: ${m} must not start with a dot. Example: "cjs": "c.js", "esm": "m.js"`);if(d===void 0)d=h;else if(d===h)throw new Error(`Invalid output extension map: ${m} must be different from the other key`)}}return i?.config.compilerOptions?.declarationMap&&(c.sourcemap=!0,e.info("Enabling sourcemap because declarationMap is enabled in tsconfig.json")),c},A3=async(e,t,r,n,o,s,i,a,l)=>{const u=s.hooks,c=j3(e,t,n,o,s,i,a,l);$m(G(c.rootDir,c.outDir));const p={buildEntries:[],dependencyGraphMap:new Map,environment:n,hoistedDependencies:new Set,hooks:nh(),implicitDependencies:new Set,jiti:oh(c.rootDir,c.jiti),logger:e,mode:r,options:c,pkg:i,tsconfig:a,usedDependencies:new Set,warnings:new Set};u&&p.hooks.addHooks(u),await p.hooks.callHook("build:prepare",p),p.options.emitESM===void 0&&e.info("Emitting of ESM bundles is disabled."),p.options.emitCJS===void 0&&e.info("Emitting of CJS bundles is disabled."),p.options.minify&&e.info("Minification is enabled, the output will be minified"),W9(p);const f=mf(i,["typescript"]);if(p.options.declaration&&p.tsconfig===void 0&&f)throw new Error("Cannot build declaration files without a tsconfig.json");return f?p.options.declaration===!1&&e.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(p.options.declaration=!1,e.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),p.options.declaration&&e.info(`Using typescript version: ${re(i.devDependencies?.typescript??i.dependencies?.typescript??"unknown")}`),p.options.declaration&&(i.dependencies?.typescript||i.devDependencies?.typescript)&&!p.tsconfig?.config.compilerOptions?.isolatedModules&&e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
|
|
233
|
+
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.
|
|
234
|
+
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.`),Jd(p),p},O3=e=>{switch(e){case"build":return"Building";case"jit":return"Stubbing";case"watch":return"Watching";default:throw new Error(`Unknown mode: ${String(e)}`)}},HO=async(e,t,r,n,o,s,i)=>{const a=ut.version.slice(1);n.wrapAll(),e=X(ut.cwd(),e),n.debug("Root directory:",e);const{packageJson:l,packageJsonPath:u}=Fo(e);n.debug("Using package.json found at",u);const c=await n9(e,l,n,i),p=vw("@visulima/packem",{cwd:e});let f=!1,d,m,h;const y=Ve(JSON.stringify({packemVersion:Jp,version:l.version,...l.dependencies,...l.devDependencies,...l.peerDependencies,...l.peerDependenciesMeta,browser:l.browser,eNode:l.engines?.node,exports:l.exports,main:l.main,module:l.module,nodeVersion:a,type:l.type,types:l.types}))+Ve(JSON.stringify(s));p&&ym(y,p,n);const $=new Vm(e,p,y,n);try{const g=await A3(n,e,t,r,o,s,l,c,a);$.isEnabled=g.options.fileCache??!0;const w=Dd(g.options.bundler);await Dc(w,e,n),w==="rolldown"&&g.options.declaration&&await Dc("rollup",e,n),g.options.transformerName&&await r9(g.options.transformerName,e,n),n.info(re(`${O3(t)} ${g.options.name}`)),n.debug({context:g.options.entries,message:`${Ae("Root dir:")} ${g.options.rootDir}
|
|
235
|
+
${Ae("Entries:")}`});const b=async j=>{for(const[k,R]of Object.entries(g.options.builder??{})){n.raw(`
|
|
236
|
+
`),await g.hooks.callHook("builder:before",k,g);const P=Date.now(),z=()=>Sl(Math.floor(Date.now()-P));await R(g,p,$,f),await g.hooks.callHook("builder:done",k,g),n.raw(`
|
|
237
|
+
⚡️ ${k} run in ${z()}`),j&&n.raw(`
|
|
238
|
+
|
|
239
|
+
`)}},v=async()=>{if(d?.pid!==void 0)await M9({pid:d.pid,signal:s.killSignal??"SIGTERM"});else if(m!==void 0)try{typeof m=="function"&&await m()}catch(j){throw new Error(`onSuccess function cleanup failed: ${j instanceof Error?j.message:String(j)}`,{cause:j})}d=void 0,m=void 0},S=async()=>{if(typeof g.options.onSuccess=="function")try{m=await g.options.onSuccess()}catch(j){throw new Error(`onSuccess function failed: ${j instanceof Error?j.message:String(j)}`,{cause:j})}else if(typeof g.options.onSuccess=="string"){const j=g.options.onSuccessTimeout??3e4,k=d=sh(g.options.onSuccess,[],{nodeOptions:{shell:!0,stdio:"inherit",timeout:j}});await k;const{exitCode:R}=k;if(typeof R=="number"&&R!==0)throw new Error(`onSuccess script failed with exit code ${String(R)}. Check the output above for details.`)}},x=Date.now(),E=()=>Sl(Math.floor(Date.now()-x));if(t==="watch"){if(g.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem config.");g.options.bundler==="rolldown"&&g.options.declaration&&n.info({message:"Declaration (DTS) watching runs through rollup; the bundle watcher is rolldown.",prefix:"bundler"}),await k9(g,$,b,S,v),qc(g,!1);return}if(await j9(g),t==="jit")await w9(g),await g.hooks.callHook("build:done",g);else{if(f=await w3(g,$),g.options.emitCJS&&g.options.declaration==="compatible"){f&&n.raw(`
|
|
240
|
+
`);let j="console",k="*";g.options.node10Compatibility&&(j=g.options.node10Compatibility.writeToPackageJson?"file":"console",k=g.options.node10Compatibility.typeScriptVersion??"*"),await x3(n,g.options.entries,g.options.outDir,g.options.rootDir,j,k)}await g.hooks.callHook("validate:before",g),typeof g.options.validation=="object"&&(g.options.validation.packageJson&&bA(g),g.options.validation.attw&&await tA(g,f),g.options.validation.bundleLimit&&NA(g,f)),await g.hooks.callHook("validate:done",g),qc(g,f)}n.raw(`
|
|
241
|
+
⚡️ Build run in ${E()}
|
|
242
|
+
`),h=()=>{v().catch(j=>{n.raw(`
|
|
243
|
+
onSuccess cleanup failed: ${j instanceof Error?j.message:String(j)}
|
|
244
|
+
`)})},ut.once("SIGINT",h),ut.once("SIGTERM",h),await b(),await S()}catch(g){throw n.raw(`
|
|
245
|
+
`),qm(g),Fu(g),g}finally{h&&(ut.off("SIGINT",h),ut.off("SIGTERM",h)),n.restoreAll(),await I9(p,n,f)}};export{Ne as A,C1 as B,Qh as J,X0 as K,ra as M,NO as S,HO as T,eb as X,wO as Y,rg as Z,B0 as a,Pr as b,Go as c,xO as d,PO as e,pl as f,s1 as g,Za as h,A9 as i,kO as j,N0 as k,SO as l,MO as m,Zh as n,U0 as q,Jp as v,vy as y};
|