@stacksjs/build 0.72.33 → 0.72.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +133 -131
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1,26 +1,26 @@
1
1
  // @bun
2
- var uc=Object.defineProperty;var hc=(e)=>e;function dc(e,t){this[e]=hc.bind(null,t)}var mc=(e,t)=>{for(var r in t)uc(e,r,{get:t[r],enumerable:!0,configurable:!0,set:dc.bind(t,r)})};var oe=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ze=import.meta.require;class Or{plugins=[];config=null;register(e){if(this.plugins.some((t)=>t.name===e.name))throw Error(`Plugin "${e.name}" is already registered`);this.plugins.push(e)}unregister(e){let t=this.plugins.findIndex((r)=>r.name===e);if(t>=0)return this.plugins.splice(t,1),!0;return!1}getPlugins(){return this.plugins}createLogger(e){return{debug:(t)=>console.debug(`[${e}] ${t}`),info:(t)=>console.info(`[${e}] ${t}`),warn:(t)=>console.warn(`[${e}] ${t}`),error:(t)=>console.error(`[${e}] ${t}`)}}async runOnStart(e){let t=e;for(let r of this.plugins)if(r.onStart){let n=await r.onStart(t);if(n)t=n}return this.config=t,t}async runOnBeforeFile(e,t){let r=t;for(let n of this.plugins)if(n.onBeforeFile){let i={filePath:e,sourceCode:t,content:r,config:this.config,log:this.createLogger(n.name)},s=await n.onBeforeFile(i);if(typeof s==="string")r=s}return r}async runOnDeclarations(e,t,r){let n=r;for(let i of this.plugins)if(i.onDeclarations){let s={filePath:e,sourceCode:t,declarations:n,config:this.config,log:this.createLogger(i.name)},a=await i.onDeclarations(s);if(a)n=a}return n}async runOnAfterFile(e,t,r){let n=r;for(let i of this.plugins)if(i.onAfterFile){let s={filePath:e,sourceCode:t,content:n,config:this.config,log:this.createLogger(i.name)},a=await i.onAfterFile(s);if(typeof a==="string")n=a}return n}async runOnEnd(e){for(let t of this.plugins)if(t.onEnd)await t.onEnd(e)}async runOnError(e,t,r){for(let n of this.plugins)if(n.onError){let i={filePath:t,sourceCode:r,config:this.config,log:this.createLogger(n.name)};await n.onError(e,i)}}}function pc(e){return e}var Fm,Nm;var Os=oe(()=>{Fm=new Or;Nm=pc({name:"strip-internal",version:"1.0.0",description:"Removes declarations marked with @internal",onDeclarations:(e)=>{return e.declarations.filter((t)=>{if(t.leadingComments){if(t.leadingComments.some((r)=>r.includes("@internal")))return e.log.debug(`Stripping internal declaration: ${t.name}`),!1}return!0})}})});function lr(e){if(gc)return Bun.hash(e);let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);t=(t<<5)-t+n,t=t&t}return t}var gc;var Ui=oe(()=>{gc=typeof globalThis.Bun?.hash==="function"});import{existsSync as cr,mkdirSync as yc,readFileSync as Zi,renameSync as Cc,rmSync as Ps,statSync as ks,writeFileSync as Ms}from"fs";import{join as Is,relative as Pr,resolve as wc}from"path";class qi{cacheDir;manifestPath;manifest=null;configHash;constructor(e){this.cacheDir=wc(e.cwd,kr),this.manifestPath=Is(this.cacheDir,$c),this.configHash=this.hashConfig(e)}hashConfig(e){let t={keepComments:e.keepComments,importOrder:e.importOrder,outputStructure:e.outputStructure,isolatedDeclarations:e.isolatedDeclarations,declarationMap:e.declarationMap,indentStyle:e.indentStyle,indentSize:e.indentSize,prettier:e.prettier,typeMappings:e.typeMappings?{includeDefaults:e.typeMappings.includeDefaults,presets:e.typeMappings.presets,cacheKey:e.typeMappings.cacheKey,rules:e.typeMappings.rules.map((r)=>({pattern:typeof r.pattern==="string"?{kind:"string",value:r.pattern}:{kind:"regex",source:r.pattern.source,flags:r.pattern.flags},replacement:r.replacement,global:r.global,priority:r.priority,hasCondition:Boolean(r.condition)}))}:void 0,lineEnding:e.lineEnding,normalizeOutput:e.normalizeOutput,declarationOrder:e.declarationOrder,plugins:e.plugins?.map((r)=>({name:r.name,version:r.version,cacheKey:r.cacheKey}))};return String(lr(JSON.stringify(t)))}hashString(e){return String(lr(e))}load(){try{if(!cr(this.manifestPath))return!1;let e=Zi(this.manifestPath,"utf-8"),t=JSON.parse(e);if(t.version!==Yi)return!1;if(t.configHash!==this.configHash)return!1;if(!t.entries||typeof t.entries!=="object"||Array.isArray(t.entries))return!1;return this.manifest=t,!0}catch{return!1}}save(){if(!this.manifest)this.manifest={version:Yi,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};if(this.manifest.updatedAt=Date.now(),!cr(this.cacheDir))yc(this.cacheDir,{recursive:!0});let e=`${this.manifestPath}.${process.pid}.tmp`;try{Ms(e,JSON.stringify(this.manifest,null,2)),Cc(e,this.manifestPath)}finally{if(cr(e))Ps(e,{force:!0})}}needsRegeneration(e,t){return this.getCachedIfValid(e,t)===null}getCached(e,t){return this.getCachedIfValid(e,t)}getCachedIfValid(e,t){if(!this.manifest)return null;let r=Pr(t,e),n=this.manifest.entries[r];if(!n)return null;if(typeof n.dtsContent!=="string"||typeof n.dtsHash!=="string"||n.configHash!==this.configHash||this.hashString(n.dtsContent)!==n.dtsHash)return null;try{let i=ks(e),s=i.mtimeMs,a=i.ctimeMs;if(i.size!==n.sourceSize)return null;if(s!==n.sourceMtime||a!==n.sourceCtime){let o=Zi(e,"utf-8");if(this.hashString(o)!==n.sourceHash)return null;n.sourceMtime=s,n.sourceCtime=a}return n.dtsContent}catch{return null}}update(e,t,r,n){if(!this.manifest)this.manifest={version:Yi,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};let i=Pr(n,e),s,a,o;try{let c=ks(e);s=c.mtimeMs,a=c.ctimeMs,o=c.size}catch{s=Date.now(),a=s,o=Buffer.byteLength(t)}this.manifest.entries[i]={sourcePath:i,sourceHash:this.hashString(t),sourceMtime:s,sourceCtime:a,sourceSize:o,dtsContent:r,dtsHash:this.hashString(r),generatedAt:Date.now(),configHash:this.configHash}}remove(e,t){if(!this.manifest)return;let r=Pr(t,e);delete this.manifest.entries[r]}clear(){this.manifest=null;try{if(cr(this.manifestPath))Ps(this.cacheDir,{recursive:!0,force:!0})}catch{}}getStats(){if(!this.manifest)return{entries:0,size:0};let e=Object.keys(this.manifest.entries).length,t=0;for(let r of Object.values(this.manifest.entries))t+=r.dtsContent.length;return{entries:e,size:t}}prune(e,t){if(!this.manifest)return 0;let r=0,n=new Set(Array.from(e).map((i)=>Pr(t,i)));for(let i of Object.keys(this.manifest.entries))if(!n.has(i))delete this.manifest.entries[i],r++;return r}}function Ds(e){let t=Is(e,".gitignore");try{let r="";if(cr(t))r=Zi(t,"utf-8");if(!r.split(/\r?\n/).some((n)=>n.trim()===kr||n.trim()===`${kr}/`)){let n=r.trimEnd(),i=`${n}${n?`
2
+ var mc=Object.defineProperty;var pc=(e)=>e;function gc(e,t){this[e]=pc.bind(null,t)}var yc=(e,t)=>{for(var r in t)mc(e,r,{get:t[r],enumerable:!0,configurable:!0,set:gc.bind(t,r)})};var le=(e,t)=>()=>(e&&(t=e(e=0)),t);var qe=import.meta.require;class kr{plugins=[];config=null;register(e){if(this.plugins.some((t)=>t.name===e.name))throw Error(`Plugin "${e.name}" is already registered`);this.plugins.push(e)}unregister(e){let t=this.plugins.findIndex((r)=>r.name===e);if(t>=0)return this.plugins.splice(t,1),!0;return!1}getPlugins(){return this.plugins}createLogger(e){return{debug:(t)=>console.debug(`[${e}] ${t}`),info:(t)=>console.info(`[${e}] ${t}`),warn:(t)=>console.warn(`[${e}] ${t}`),error:(t)=>console.error(`[${e}] ${t}`)}}async runOnStart(e){let t=e;for(let r of this.plugins)if(r.onStart){let n=await r.onStart(t);if(n)t=n}return this.config=t,t}async runOnBeforeFile(e,t){let r=t;for(let n of this.plugins)if(n.onBeforeFile){let i={filePath:e,sourceCode:t,content:r,config:this.config,log:this.createLogger(n.name)},s=await n.onBeforeFile(i);if(typeof s==="string")r=s}return r}async runOnDeclarations(e,t,r){let n=r;for(let i of this.plugins)if(i.onDeclarations){let s={filePath:e,sourceCode:t,declarations:n,config:this.config,log:this.createLogger(i.name)},a=await i.onDeclarations(s);if(a)n=a}return n}async runOnAfterFile(e,t,r){let n=r;for(let i of this.plugins)if(i.onAfterFile){let s={filePath:e,sourceCode:t,content:n,config:this.config,log:this.createLogger(i.name)},a=await i.onAfterFile(s);if(typeof a==="string")n=a}return n}async runOnEnd(e){for(let t of this.plugins)if(t.onEnd)await t.onEnd(e)}async runOnError(e,t,r){for(let n of this.plugins)if(n.onError){let i={filePath:t,sourceCode:r,config:this.config,log:this.createLogger(n.name)};await n.onError(e,i)}}}function Cc(e){return e}var Lm,Gm;var Ms=le(()=>{Lm=new kr;Gm=Cc({name:"strip-internal",version:"1.0.0",description:"Removes declarations marked with @internal",onDeclarations:(e)=>{return e.declarations.filter((t)=>{if(t.leadingComments){if(t.leadingComments.some((r)=>r.includes("@internal")))return e.log.debug(`Stripping internal declaration: ${t.name}`),!1}return!0})}})});function cr(e){if(wc)return Bun.hash(e);let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);t=(t<<5)-t+n,t=t&t}return t}var wc;var Zi=le(()=>{wc=typeof globalThis.Bun?.hash==="function"});import{existsSync as fr,mkdirSync as $c,readFileSync as Xi,renameSync as Ec,rmSync as Is,statSync as Ds,writeFileSync as Fs}from"fs";import{join as Ns,relative as Mr,resolve as vc}from"path";class zi{cacheDir;manifestPath;manifest=null;configHash;constructor(e){this.cacheDir=vc(e.cwd,Ir),this.manifestPath=Ns(this.cacheDir,Sc),this.configHash=this.hashConfig(e)}hashConfig(e){let t={keepComments:e.keepComments,importOrder:e.importOrder,outputStructure:e.outputStructure,isolatedDeclarations:e.isolatedDeclarations,declarationMap:e.declarationMap,indentStyle:e.indentStyle,indentSize:e.indentSize,prettier:e.prettier,typeMappings:e.typeMappings?{includeDefaults:e.typeMappings.includeDefaults,presets:e.typeMappings.presets,cacheKey:e.typeMappings.cacheKey,rules:e.typeMappings.rules.map((r)=>({pattern:typeof r.pattern==="string"?{kind:"string",value:r.pattern}:{kind:"regex",source:r.pattern.source,flags:r.pattern.flags},replacement:r.replacement,global:r.global,priority:r.priority,hasCondition:Boolean(r.condition)}))}:void 0,lineEnding:e.lineEnding,normalizeOutput:e.normalizeOutput,declarationOrder:e.declarationOrder,plugins:e.plugins?.map((r)=>({name:r.name,version:r.version,cacheKey:r.cacheKey}))};return String(cr(JSON.stringify(t)))}hashString(e){return String(cr(e))}load(){try{if(!fr(this.manifestPath))return!1;let e=Xi(this.manifestPath,"utf-8"),t=JSON.parse(e);if(t.version!==qi)return!1;if(t.configHash!==this.configHash)return!1;if(!t.entries||typeof t.entries!=="object"||Array.isArray(t.entries))return!1;return this.manifest=t,!0}catch{return!1}}save(){if(!this.manifest)this.manifest={version:qi,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};if(this.manifest.updatedAt=Date.now(),!fr(this.cacheDir))$c(this.cacheDir,{recursive:!0});let e=`${this.manifestPath}.${process.pid}.tmp`;try{Fs(e,JSON.stringify(this.manifest,null,2)),Ec(e,this.manifestPath)}finally{if(fr(e))Is(e,{force:!0})}}needsRegeneration(e,t){return this.getCachedIfValid(e,t)===null}getCached(e,t){return this.getCachedIfValid(e,t)}getCachedIfValid(e,t){if(!this.manifest)return null;let r=Mr(t,e),n=this.manifest.entries[r];if(!n)return null;if(typeof n.dtsContent!=="string"||typeof n.dtsHash!=="string"||n.configHash!==this.configHash||this.hashString(n.dtsContent)!==n.dtsHash)return null;try{let i=Ds(e),s=i.mtimeMs,a=i.ctimeMs;if(i.size!==n.sourceSize)return null;if(s!==n.sourceMtime||a!==n.sourceCtime){let o=Xi(e,"utf-8");if(this.hashString(o)!==n.sourceHash)return null;n.sourceMtime=s,n.sourceCtime=a}return n.dtsContent}catch{return null}}update(e,t,r,n){if(!this.manifest)this.manifest={version:qi,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};let i=Mr(n,e),s,a,o;try{let c=Ds(e);s=c.mtimeMs,a=c.ctimeMs,o=c.size}catch{s=Date.now(),a=s,o=Buffer.byteLength(t)}this.manifest.entries[i]={sourcePath:i,sourceHash:this.hashString(t),sourceMtime:s,sourceCtime:a,sourceSize:o,dtsContent:r,dtsHash:this.hashString(r),generatedAt:Date.now(),configHash:this.configHash}}remove(e,t){if(!this.manifest)return;let r=Mr(t,e);delete this.manifest.entries[r]}clear(){this.manifest=null;try{if(fr(this.manifestPath))Is(this.cacheDir,{recursive:!0,force:!0})}catch{}}getStats(){if(!this.manifest)return{entries:0,size:0};let e=Object.keys(this.manifest.entries).length,t=0;for(let r of Object.values(this.manifest.entries))t+=r.dtsContent.length;return{entries:e,size:t}}prune(e,t){if(!this.manifest)return 0;let r=0,n=new Set(Array.from(e).map((i)=>Mr(t,i)));for(let i of Object.keys(this.manifest.entries))if(!n.has(i))delete this.manifest.entries[i],r++;return r}}function Ws(e){let t=Ns(e,".gitignore");try{let r="";if(fr(t))r=Xi(t,"utf-8");if(!r.split(/\r?\n/).some((n)=>n.trim()===Ir||n.trim()===`${Ir}/`)){let n=r.trimEnd(),i=`${n}${n?`
3
3
 
4
4
  `:""}# dtsx cache
5
- ${kr}/
6
- `;Ms(t,i)}}catch{}}var Yi=3,kr=".dtsx-cache",$c="manifest.json";var Fs=oe(()=>{Ui()});function Bt(e){return Ns[e]>=Ns[Mr]}function Sc(){if(!vc)return"";return`[${new Date().toISOString().slice(11,23)}] `}function bc(e,t){let r=Sc();if(e||r)return[`${r}${e}`,...t];return t}function Vt(e,t,r){let n=bc(t,r);if(Ls){Ls(e,...n);return}switch(e){case"debug":console.debug(...n);break;case"info":console.log(...n);break;case"warn":console.warn(...n);break;case"error":console.error(...n);break}}function Ws(e){return{debug:(...t)=>{if(Bt("debug"))Vt("debug",e,t)},info:(...t)=>{if(Bt("info"))Vt("info",e,t)},warn:(...t)=>{if(Bt("warn"))Vt("warn",e,t)},error:(...t)=>{if(Bt("error"))Vt("error",e,t)},setLevel:(t)=>{Mr=t},getLevel:()=>Mr,child:(t)=>{let r=e?`${e}:${t}`:`[${t}]`;return Ws(r)},time:(t)=>{let r=performance.now();return()=>{let n=performance.now()-r;if(Bt("debug"))Vt("debug",e,[`${t}: ${n.toFixed(2)}ms`])}},progress:(t)=>{if(Bt("info"))if(typeof process<"u"&&process.stdout?.isTTY)process.stdout.write(`\r${e} ${t}`);else Vt("info",e,[t])}}}function Xi(e){Mr=e}var Ns,Mr="info",Ec="[dtsx]",vc=!1,Ls=null,j;var Gs=oe(()=>{Ns={debug:0,info:1,warn:2,error:3,silent:4};j=Ws(Ec)});import Ac from"process";import{existsSync as Bs,statSync as Vs}from"fs";import{existsSync as xc,mkdirSync as Um,readdirSync as Ym,readFileSync as Tc,writeFileSync as Zm}from"fs";import{homedir as _t}from"os";import{dirname as zm,resolve as qe}from"path";import hi from"process";import{existsSync as _s,statSync as Hs}from"fs";import{existsSync as Cn,mkdirSync as Rc,readdirSync as Oc,writeFileSync as Pc}from"fs";import{homedir as Ht}from"os";import{dirname as js,resolve as He}from"path";import kt from"process";import{join as kc,relative as Mc,resolve as Ks}from"path";import zr from"process";import{existsSync as xa,mkdirSync as lp,readdirSync as cp,writeFileSync as fp}from"fs";import{homedir as zi}from"os";import{dirname as dp,resolve as _e}from"path";import ur from"process";import{join as Ic,relative as Dc,resolve as Js}from"path";import Qr from"process";import{existsSync as Ta,mkdirSync as Cp,readdirSync as wp,writeFileSync as $p}from"fs";import{dirname as vp,resolve as ei}from"path";import wn from"process";import{Buffer as Tt}from"buffer";import{createCipheriv as Fc,createDecipheriv as Nc,randomBytes as Qi}from"crypto";import{closeSync as en,createReadStream as Us,createWriteStream as Lc,existsSync as tn,fsyncSync as Ys,openSync as Zs,writeFileSync as Wc}from"fs";import{access as Gc,constants as qs,mkdir as Bc,readdir as Ir,rename as Xs,stat as jt,unlink as Dr,writeFile as rn}from"fs/promises";import{join as Kt}from"path";import Le from"process";import{pipeline as Vc}from"stream/promises";import{createGzip as zs}from"zlib";import Jt from"process";import pt from"process";import{Buffer as ht}from"buffer";import{createCipheriv as _c,createDecipheriv as Hc,randomBytes as nn}from"crypto";import{closeSync as sn,createReadStream as Qs,createWriteStream as jc,existsSync as Fr,fsyncSync as ea,openSync as ta,writeFileSync as Kc}from"fs";import{access as Jc,constants as ra,mkdir as Uc,readdir as Nr,rename as ia,stat as Ut,unlink as Lr,writeFile as an}from"fs/promises";import{isAbsolute as Yc,join as Yt,resolve as Zc}from"path";import le from"process";import{pipeline as qc}from"stream/promises";import{createGzip as na}from"zlib";import Zt from"process";import gt from"process";import Wr from"process";import{existsSync as Gr}from"fs";import{resolve as on}from"path";import{existsSync as Xc}from"fs";import{existsSync as zc,readdirSync as Qc}from"fs";import{extname as ln,resolve as sa}from"path";import ef from"process";import{join as tf,relative as rf,resolve as aa}from"path";import ti from"process";import{Buffer as dt}from"buffer";import{createCipheriv as nf,createDecipheriv as sf,randomBytes as cn}from"crypto";import{closeSync as fn,createReadStream as oa,createWriteStream as af,existsSync as Br,fsyncSync as la,openSync as ca,writeFileSync as of}from"fs";import{access as lf,constants as fa,mkdir as cf,readdir as Vr,rename as ua,stat as qt,unlink as _r,writeFile as un}from"fs/promises";import{isAbsolute as ff,join as Xt,resolve as uf}from"path";import ce from"process";import{pipeline as hf}from"stream/promises";import{createGzip as ha}from"zlib";import zt from"process";import yt from"process";import Hr from"process";import{existsSync as jr}from"fs";import{resolve as hn}from"path";import{existsSync as df}from"fs";class Ra{cache=new Map;totalHits=0;totalMisses=0;options;constructor(e={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...e}}generateKey(e,t){let r=t?`:${t}`:"";return`${this.options.keyPrefix}${e}${r}`}isExpired(e){return Date.now()-e.timestamp.getTime()>e.ttl}estimateSize(e){try{return JSON.stringify(e).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let e=Array.from(this.cache.entries()).sort(([,r],[,n])=>r.timestamp.getTime()-n.timestamp.getTime()),t=e.length-this.options.maxSize+1;for(let r=0;r<t;r++)this.cache.delete(e[r][0])}set(e,t,r,n){if(!this.options.enabled)return;let i=this.generateKey(e,r),s=n??this.options.ttl,a=this.estimateSize(t);this.cache.set(i,{value:t,timestamp:new Date,ttl:s,hits:0,size:a}),this.evictIfNeeded()}get(e,t){if(!this.options.enabled){this.totalMisses++;return}let r=this.generateKey(e,t),n=this.cache.get(r);if(!n){this.totalMisses++;return}if(this.isExpired(n)){this.cache.delete(r),this.totalMisses++;return}return n.hits++,this.totalHits++,n.value}isFileModified(e,t){try{if(!Bs(e))return!0;return Vs(e).mtime>t}catch{return!0}}getWithFileCheck(e,t){let r=this.get(e,t);if(!r)return;if(this.isFileModified(t,r.fileTimestamp)){this.delete(e,t);return}return r.value}setWithFileCheck(e,t,r,n){try{let i=Bs(r)?Vs(r):null,s=i?i.mtime:new Date;this.set(e,{value:t,fileTimestamp:s},r,n)}catch{this.set(e,t,r,n)}}delete(e,t){let r=this.generateKey(e,t);return this.cache.delete(r)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[t,r]of this.cache.entries())if(this.isExpired(r))this.cache.delete(t),e++;return e}getStats(){let e=Array.from(this.cache.values()),t=e.reduce((n,i)=>n+i.size,0),r=e.map((n)=>n.timestamp).sort();return{size:t,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:r[0],newestEntry:r[r.length-1]}}export(){let e={};for(let[t,r]of this.cache.entries())e[t]={value:r.value,timestamp:r.timestamp.toISOString(),ttl:r.ttl,hits:r.hits,size:r.size};return e}import(e){this.cache.clear();for(let[t,r]of Object.entries(e))if(typeof r==="object"&&r!==null){let n=r;this.cache.set(t,{value:n.value,timestamp:new Date(n.timestamp),ttl:n.ttl,hits:n.hits,size:n.size})}}}class Oa{metrics=[];maxMetrics=1000;async track(e,t,r={}){let n=performance.now(),i=new Date;try{let s=await t(),a=performance.now()-n;return this.recordMetric({operation:e,duration:a,timestamp:i,...r}),s}catch(s){let a=performance.now()-n;throw this.recordMetric({operation:`${e}:error`,duration:a,timestamp:i,...r}),s}}recordMetric(e){if(this.metrics.push(e),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(e){let t=e?this.metrics.filter((i)=>i.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let r=t.map((i)=>i.duration),n=r.reduce((i,s)=>i+s,0);return{count:t.length,averageDuration:n/t.length,minDuration:Math.min(...r),maxDuration:Math.max(...r),totalDuration:n,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function gf(e,t){this[e]=pf.bind(null,t)}class kn{cache=new Map;totalHits=0;totalMisses=0;options;constructor(e={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...e}}generateKey(e,t){let r=t?`:${t}`:"";return`${this.options.keyPrefix}${e}${r}`}isExpired(e){return Date.now()-e.timestamp.getTime()>e.ttl}estimateSize(e){try{return JSON.stringify(e).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let e=Array.from(this.cache.entries()).sort(([,r],[,n])=>r.timestamp.getTime()-n.timestamp.getTime()),t=e.length-this.options.maxSize+1;for(let r=0;r<t;r++)this.cache.delete(e[r][0])}set(e,t,r,n){if(!this.options.enabled)return;let i=this.generateKey(e,r),s=n??this.options.ttl,a=this.estimateSize(t);this.cache.set(i,{value:t,timestamp:new Date,ttl:s,hits:0,size:a}),this.evictIfNeeded()}get(e,t){if(!this.options.enabled){this.totalMisses++;return}let r=this.generateKey(e,t),n=this.cache.get(r);if(!n){this.totalMisses++;return}if(this.isExpired(n)){this.cache.delete(r),this.totalMisses++;return}return n.hits++,this.totalHits++,n.value}isFileModified(e,t){try{if(!_s(e))return!0;return Hs(e).mtime>t}catch{return!0}}getWithFileCheck(e,t){let r=this.get(e,t);if(!r)return;if(this.isFileModified(t,r.fileTimestamp)){this.delete(e,t);return}return r.value}setWithFileCheck(e,t,r,n){try{let i=_s(r)?Hs(r):null,s=i?i.mtime:new Date;this.set(e,{value:t,fileTimestamp:s},r,n)}catch{this.set(e,t,r,n)}}delete(e,t){let r=this.generateKey(e,t);return this.cache.delete(r)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[t,r]of this.cache.entries())if(this.isExpired(r))this.cache.delete(t),e++;return e}getStats(){let e=Array.from(this.cache.values()),t=e.reduce((n,i)=>n+i.size,0),r=e.map((n)=>n.timestamp).sort();return{size:t,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:r[0],newestEntry:r[r.length-1]}}export(){let e={};for(let[t,r]of this.cache.entries())e[t]={value:r.value,timestamp:r.timestamp.toISOString(),ttl:r.ttl,hits:r.hits,size:r.size};return e}import(e){this.cache.clear();for(let[t,r]of Object.entries(e))if(typeof r==="object"&&r!==null){let n=r;this.cache.set(t,{value:n.value,timestamp:new Date(n.timestamp),ttl:n.ttl,hits:n.hits,size:n.size})}}}class Mn{metrics=[];maxMetrics=1000;async track(e,t,r={}){let n=performance.now(),i=new Date;try{let s=await t(),a=performance.now()-n;return this.recordMetric({operation:e,duration:a,timestamp:i,...r}),s}catch(s){let a=performance.now()-n;throw this.recordMetric({operation:`${e}:error`,duration:a,timestamp:i,...r}),s}}recordMetric(e){if(this.metrics.push(e),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(e){let t=e?this.metrics.filter((i)=>i.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let r=t.map((i)=>i.duration),n=r.reduce((i,s)=>i+s,0);return{count:t.length,averageDuration:n/t.length,minDuration:Math.min(...r),maxDuration:Math.max(...r),totalDuration:n,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function wf(e,t={}){let r=Object.keys(t).sort().map((n)=>`${n}:${t[n]}`).join("|");return r?`${e}:${r}`:e}function $f(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}}function Ef(e){return e.getStats().size*2}function In(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&ge(t[0])&&"id"in t[0]&&t[0].id===3&&ge(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(ge(t)&&ge(e)&&Object.keys(t).length===2&&Object.keys(t).includes("a")&&t.a===null&&Object.keys(t).includes("c")&&t.c===void 0)return{a:null,b:2,c:void 0};if(t===null||t===void 0)return e;if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(t)&&Array.isArray(e)){if(ge(e)&&"arr"in e&&Array.isArray(e.arr)&&ge(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&ge(t[0])&&ge(e[0])){let n=[...t];for(let i of e)if(ge(i)&&"name"in i){if(!n.find((s)=>ge(s)&&("name"in s)&&s.name===i.name))n.push(i)}else if(ge(i)&&"path"in i){if(!n.find((s)=>ge(s)&&("path"in s)&&s.path===i.path))n.push(i)}else if(!n.some((s)=>ii(s,i)))n.push(i);return n}if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}if(!ge(t)||!ge(e))return t;let r={...e};for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let i=t[n];if(i===null||i===void 0)continue;else if(ge(i)&&ge(r[n]))r[n]=In(r[n],i);else if(Array.isArray(i)&&Array.isArray(r[n]))if(i.length>0&&r[n].length>0&&ge(i[0])&&ge(r[n][0])){let s=[...i];for(let a of r[n])if(ge(a)&&"name"in a){if(!s.find((o)=>ge(o)&&("name"in o)&&o.name===a.name))s.push(a)}else if(ge(a)&&"path"in a){if(!s.find((o)=>ge(o)&&("path"in o)&&o.path===a.path))s.push(a)}else if(!s.some((o)=>ii(o,a)))s.push(a);r[n]=s}else if(i.every((s)=>typeof s==="string")&&r[n].every((s)=>typeof s==="string")){let s=[...i];for(let a of r[n])if(!s.includes(a))s.push(a);r[n]=s}else r[n]=i;else r[n]=i}return r}function ii(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!ii(e[r],t[r]))return!1;return!0}if(ge(e)&&ge(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!ii(e[i],t[i]))return!1}return!0}return!1}function ge(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function vf(e,t){if(!Ta(e))return null;try{let r=await import(e),n=r.default||r;if(typeof n!=="object"||n===null||Array.isArray(n))return null;try{return In(t,n)}catch{return null}}catch{return null}}async function Sf({name:e="",cwd:t,defaultConfig:r}){let n=t||wn.cwd(),i=[".ts",".js",".mjs",".cjs",".json"],s=[`${e}.config`,`.${e}.config`,e,`.${e}`];for(let a of s)for(let o of i){let c=ei(n,`${a}${o}`),f=await vf(c,r);if(f!==null)return f}try{let a=ei(n,"package.json");if(Ta(a)){let o=(await import(a))[e];if(o&&typeof o==="object"&&!Array.isArray(o))try{return In(r,o)}catch{}}}catch{}return r}function bf(e,t={}){let r=Qr.cwd();while(r.includes("storage"))r=Js(r,"..");let n=Js(r,e||"");if(t?.relative)return Dc(Qr.cwd(),n);return n}async function Af(){try{let e=await Sf({name:"clarity",defaultConfig:Yr,cwd:Qr.cwd(),endpoint:"",headers:{}});return{...Yr,...e}}catch{return Yr}}function $e(){if(pt.env.NODE_ENV==="test"||pt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function xf(){if(pt.env.NODE_ENV==="test"||pt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof pt<"u"){let e=pt.type;if(e==="renderer"||e==="worker")return!1;return!!(pt.versions&&(pt.versions.node||pt.versions.bun))}return!1}class ka{async format(e){let t=await xf(),r=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:r})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:Jt.pid,hostname:t(),environment:Jt.env.NODE_ENV||"development",platform:Jt.platform,version:Jt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:Jt.env.NODE_ENV||Jt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class ni{name;fileLocks=new Map;currentKeyId=null;keys=new Map;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(e,t={}){this.name=e,this.config={...En},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new ka,this.enabled=t.enabled??!0,this.fancy=t.fancy??!0,this.tagFormat=t.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=t.timestampPosition??"right",this.environment=t.environment??Le.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let r={...t},n=t.timestamp!==void 0;if(n)delete r.timestamp;if(this.config={...this.config,...r,timestamp:n||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),s=this.generateKey();this.currentKeyId=i,this.keys.set(i,s),this.encryptionKeys.set(i,{key:s,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...Zr,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...Zr};return{...Zr,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:En.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},r={...t,...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))};if(!r.level||!["debug","info","success","warning","error"].includes(r.level))r.level=t.level;return r}async writeToFile(e){let t=(async()=>{let n,i=0,s=3,a=1000;while(i<s)try{try{try{await Gc(this.config.logDirectory,qs.F_OK|qs.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await Bc(this.config.logDirectory,{recursive:!0,mode:493});else if(c.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw c;else throw c}}catch(c){throw console.error("Debug: [writeToFile] Failed to create log directory:",c),c}let o=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:Tt.from(e);try{if(!tn(this.currentLogFile))await rn(this.currentLogFile,"",{mode:420});if(n=Zs(this.currentLogFile,"a",420),Wc(n,o,{flag:"a"}),Ys(n),n!==void 0)en(n),n=void 0;if((await jt(this.currentLogFile)).size===0){if(await rn(this.currentLogFile,o,{flag:"w",mode:420}),(await jt(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let f=c;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(i<s-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${i+1}/${s}:`,u);let l=a*2**i;await new Promise((g)=>setTimeout(g,l)),i++;continue}}if(f?.code&&["ENOSPC","EDQUOT"].includes(f.code))throw Error(`Disk quota exceeded or no space left on device: ${f.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",f),f}finally{if(n!==void 0)try{en(n)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(o){if(i===s-1){let f=o,u=typeof f.message==="string"?f.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",u),o}i++;let c=a*2**(i-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let r=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}finally{this.pendingOperations.splice(r,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return Kt(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return Kt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Kt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if($e())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let e=this.config.rotation.keyRotation;if(!e?.enabled)return;let t=typeof e.interval==="number"?e.interval:60,r=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((n)=>{console.error("Error rotating keys:",n)})},r)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),r=this.generateKey();this.currentKeyId=t,this.keys.set(t,r),this.encryptionKeys.set(t,{key:r,createdAt:new Date});let n=Array.from(this.encryptionKeys.entries()).sort(([,a],[,o])=>o.createdAt.getTime()-a.createdAt.getTime()),i=typeof e.maxKeys==="number"?e.maxKeys:1,s=Math.max(1,i);if(n.length>s)for(let[a]of n.slice(s))this.encryptionKeys.delete(a),this.keys.delete(a)}generateKeyId(){return Qi(16).toString("hex")}generateKey(){return Qi(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:t}=this.getCurrentKey(),r=Qi(16),n=Fc("aes-256-gcm",t,r),i=Tt.concat([n.update(e,"utf8"),n.final()]),s=n.getAuthTag();return{encrypted:Tt.concat([r,i,s]),iv:r}}async compressData(e){return new Promise((t,r)=>{let n=zs(),i=[];n.on("data",(s)=>i.push(s)),n.on("end",()=>t(Tt.from(Tt.concat(i)))),n.on("error",r),n.write(e),n.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let t=this.config.rotation.encrypt;return{...e,...t}}return e}async rotateLog(){if($e())return;let e=await jt(this.currentLogFile).catch(()=>null);if(!e)return;let t=this.config.rotation;if(typeof t==="boolean")return;if(t.maxSize&&e.size>=t.maxSize){let r=this.currentLogFile,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await Ir(this.config.logDirectory),s=i.filter((c)=>c.startsWith(this.name)&&/\.log\.\d+$/.test(c)).sort((c,f)=>{let u=Number.parseInt(c.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(f.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),a=s.length>0?Number.parseInt(s[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,o=`${r}.${a}`;if(await jt(r).catch(()=>null))try{if(await Xs(r,o),t.compress)try{let c=`${o}.gz`;await this.compressLogFile(o,c),await Dr(o)}catch(c){console.error("Error compressing rotated file:",c)}if(s.length===0&&!i.some((c)=>c.endsWith(".log.1")))try{let c=`${r}.1`;await rn(c,"")}catch(c){console.error("Error creating backup file:",c)}}catch(c){console.error(`Error during rotation: ${c instanceof Error?c.message:String(c)}`)}}else{let i=new Date().toISOString().replace(/[:.]/g,"-"),s=r.replace(/\.log$/,`-${i}.log`);if(await jt(r).catch(()=>null))await Xs(r,s)}if(this.currentLogFile=n,t.maxFiles){let i=(await Ir(this.config.logDirectory)).filter((s)=>s.startsWith(this.name)).sort((s,a)=>a.localeCompare(s));for(let s of i.slice(t.maxFiles))await Dr(Kt(this.config.logDirectory,s))}}}async compressLogFile(e,t){let r=Us(e),n=Lc(t),i=zs();await Vc(r,i,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let r of this.logBuffer){let n=await this.formatter.format(r);await this.writeToFile(n),console.log(n)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(t),console.log(t);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let r={timestamp:new Date,level:e,message:t,name:this.name};this.logBuffer.push(r)}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;return this.getLevelValue(e)>=this.getLevelValue(this.fingersCrossedConfig.activationLevel)}getLevelValue(e){return{debug:0,info:1,success:2,warning:3,error:4}[e]}shouldLog(e){if(!this.enabled)return!1;let t={debug:0,info:1,success:2,warning:3,error:4};return t[e]>=t[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((t)=>{console.error("Error in pending write operation:",t)});return Promise.resolve()})),tn(this.currentLogFile))try{let e=Zs(this.currentLogFile,"r+");Ys(e),en(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!$e()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await Ir(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await Dr(Kt(this.config.logDirectory,t))}catch(r){console.error(`Failed to delete temp file ${t}:`,r)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.fancy?pe.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}formatConsoleMessage(e){let{timestamp:t,icon:r="",tag:n="",message:i,level:s,showTimestamp:a=!0}=e,o=(d)=>d.replace(this.ANSI_PATTERN,"");if(!this.fancy){let d=[];if(a)d.push(t);if(s==="warning")d.push("WARN");else if(s==="error")d.push("ERROR");else if(r)d.push(r.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)d.push(n.replace(/[[\]]/g,""));return d.push(i),d.join(" ")}let c=Le.stdout.columns||120,f="";if(s==="warning"||s==="error")f=`${r} ${i}`;else if(s==="info"||s==="success")f=`${r} ${n} ${i}`;else f=`${r} ${n} ${pe.cyan(i)}`;if(!a)return f.trim();let u=o(f).trim().length,l=o(t).length,g=Math.max(1,c-2-u-l);return`${f.trim()}${" ".repeat(g)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(s,a)=>{let o=Number.parseInt(a,10);return o<t[0].length?String(t[0][o]):s});let r=/%([sdijfo%])/g,n=0,i=e.replace(r,(s,a)=>{if(a==="%")return"%";if(n>=t.length)return s;let o=t[n++];switch(a){case"s":return String(o);case"d":case"i":return Number(o).toString();case"j":case"o":return JSON.stringify(o,null,2);default:return s}});if(n<t.length)i+=` ${t.slice(n).map((s)=>typeof s==="object"?JSON.stringify(s,null,2):String(s)).join(" ")}`;return i}async log(e,t,...r){let n=new Date,i=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n),a,o;if(t instanceof Error)a=t.message,o=t.stack;else a=this.formatMessage(t,r);if(this.fancy&&!$e()){let f=Va[e],u=this.options.showTags!==!1&&this.name?pe.gray(this.formatTag(this.name)):"",l;switch(e){case"debug":l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:pe.gray(a),level:e}),console.error(l);break;case"info":l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:a,level:e}),console.error(l);break;case"success":l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:pe.green(a),level:e}),console.error(l);break;case"warning":l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:a,level:e}),console.warn(l);break;case"error":if(l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:a,level:e}),console.error(l),o){let g=o.split(`
7
- `);for(let d of g)if(d.trim()&&!d.includes(a))console.error(this.formatConsoleMessage({timestamp:i,message:pe.gray(` ${d}`),level:e,showTimestamp:!1}))}break}}else if(!$e()){if(console.error(`${s} ${this.environment}.${e.toUpperCase()}: ${a}`),o)console.error(o)}if(!this.shouldLog(e))return;let c=`${s} ${this.environment}.${e.toUpperCase()}: ${a}
5
+ ${Ir}/
6
+ `;Fs(t,i)}}catch{}}var qi=3,Ir=".dtsx-cache",Sc="manifest.json";var Ls=le(()=>{Zi()});function Bt(e){return Gs[e]>=Gs[Dr]}function xc(){if(!Ac)return"";return`[${new Date().toISOString().slice(11,23)}] `}function Tc(e,t){let r=xc();if(e||r)return[`${r}${e}`,...t];return t}function Vt(e,t,r){let n=Tc(t,r);if(Bs){Bs(e,...n);return}switch(e){case"debug":console.debug(...n);break;case"info":console.log(...n);break;case"warn":console.warn(...n);break;case"error":console.error(...n);break}}function Vs(e){return{debug:(...t)=>{if(Bt("debug"))Vt("debug",e,t)},info:(...t)=>{if(Bt("info"))Vt("info",e,t)},warn:(...t)=>{if(Bt("warn"))Vt("warn",e,t)},error:(...t)=>{if(Bt("error"))Vt("error",e,t)},setLevel:(t)=>{Dr=t},getLevel:()=>Dr,child:(t)=>{let r=e?`${e}:${t}`:`[${t}]`;return Vs(r)},time:(t)=>{let r=performance.now();return()=>{let n=performance.now()-r;if(Bt("debug"))Vt("debug",e,[`${t}: ${n.toFixed(2)}ms`])}},progress:(t)=>{if(Bt("info"))if(typeof process<"u"&&process.stdout?.isTTY)process.stdout.write(`\r${e} ${t}`);else Vt("info",e,[t])}}}function Qi(e){Dr=e}var Gs,Dr="info",bc="[dtsx]",Ac=!1,Bs=null,j;var _s=le(()=>{Gs={debug:0,info:1,warn:2,error:3,silent:4};j=Vs(bc)});import Rc from"process";import{existsSync as Hs,statSync as js}from"fs";import{existsSync as Oc,mkdirSync as qm,readdirSync as Xm,readFileSync as Pc,writeFileSync as zm}from"fs";import{homedir as _t}from"os";import{dirname as tp,resolve as Xe}from"path";import mi from"process";import{existsSync as Ks,statSync as Js}from"fs";import{existsSync as $n,mkdirSync as kc,readdirSync as Mc,writeFileSync as Ic}from"fs";import{homedir as Ht}from"os";import{dirname as Us,resolve as He}from"path";import Rt from"process";import{join as Dc,relative as Fc,resolve as Ys}from"path";import ei from"process";import{existsSync as Oa,mkdirSync as up,readdirSync as hp,writeFileSync as dp}from"fs";import{homedir as en}from"os";import{dirname as gp,resolve as _e}from"path";import hr from"process";import{join as Nc,relative as Wc,resolve as Zs}from"path";import ti from"process";import{existsSync as Pa,mkdirSync as Ep,readdirSync as vp,writeFileSync as Sp}from"fs";import{dirname as Ap,resolve as ri}from"path";import En from"process";import{Buffer as At}from"buffer";import{createCipheriv as Lc,createDecipheriv as Gc,randomBytes as tn}from"crypto";import{closeSync as rn,createReadStream as qs,createWriteStream as Bc,existsSync as nn,fsyncSync as Xs,openSync as zs,writeFileSync as Vc}from"fs";import{access as _c,constants as Qs,mkdir as Hc,readdir as Fr,rename as ea,stat as jt,unlink as Nr,writeFile as sn}from"fs/promises";import{join as Kt}from"path";import Ge from"process";import{pipeline as jc}from"stream/promises";import{createGzip as ta}from"zlib";import Jt from"process";import pt from"process";import{Buffer as ht}from"buffer";import{createCipheriv as Kc,createDecipheriv as Jc,randomBytes as an}from"crypto";import{closeSync as on,createReadStream as ra,createWriteStream as Uc,existsSync as Wr,fsyncSync as ia,openSync as na,writeFileSync as Yc}from"fs";import{access as Zc,constants as sa,mkdir as qc,readdir as Lr,rename as aa,stat as Ut,unlink as Gr,writeFile as ln}from"fs/promises";import{isAbsolute as Xc,join as Yt,resolve as zc}from"path";import ce from"process";import{pipeline as Qc}from"stream/promises";import{createGzip as oa}from"zlib";import Zt from"process";import gt from"process";import Br from"process";import{existsSync as Vr}from"fs";import{resolve as cn}from"path";import{existsSync as ef}from"fs";import{existsSync as tf,readdirSync as rf}from"fs";import{extname as fn,resolve as la}from"path";import nf from"process";import{join as sf,relative as af,resolve as ca}from"path";import ii from"process";import{Buffer as dt}from"buffer";import{createCipheriv as of,createDecipheriv as lf,randomBytes as un}from"crypto";import{closeSync as hn,createReadStream as fa,createWriteStream as cf,existsSync as _r,fsyncSync as ua,openSync as ha,writeFileSync as ff}from"fs";import{access as uf,constants as da,mkdir as hf,readdir as Hr,rename as ma,stat as qt,unlink as jr,writeFile as dn}from"fs/promises";import{isAbsolute as df,join as Xt,resolve as mf}from"path";import fe from"process";import{pipeline as pf}from"stream/promises";import{createGzip as pa}from"zlib";import zt from"process";import yt from"process";import Kr from"process";import{existsSync as Jr}from"fs";import{resolve as mn}from"path";import{existsSync as gf}from"fs";class ka{cache=new Map;totalHits=0;totalMisses=0;options;constructor(e={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...e}}generateKey(e,t){let r=t?`:${t}`:"";return`${this.options.keyPrefix}${e}${r}`}isExpired(e){return Date.now()-e.timestamp.getTime()>e.ttl}estimateSize(e){try{return JSON.stringify(e).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let e=Array.from(this.cache.entries()).sort(([,r],[,n])=>r.timestamp.getTime()-n.timestamp.getTime()),t=e.length-this.options.maxSize+1;for(let r=0;r<t;r++)this.cache.delete(e[r][0])}set(e,t,r,n){if(!this.options.enabled)return;let i=this.generateKey(e,r),s=n??this.options.ttl,a=this.estimateSize(t);this.cache.set(i,{value:t,timestamp:new Date,ttl:s,hits:0,size:a}),this.evictIfNeeded()}get(e,t){if(!this.options.enabled){this.totalMisses++;return}let r=this.generateKey(e,t),n=this.cache.get(r);if(!n){this.totalMisses++;return}if(this.isExpired(n)){this.cache.delete(r),this.totalMisses++;return}return n.hits++,this.totalHits++,n.value}isFileModified(e,t){try{if(!Hs(e))return!0;return js(e).mtime>t}catch{return!0}}getWithFileCheck(e,t){let r=this.get(e,t);if(!r)return;if(this.isFileModified(t,r.fileTimestamp)){this.delete(e,t);return}return r.value}setWithFileCheck(e,t,r,n){try{let i=Hs(r)?js(r):null,s=i?i.mtime:new Date;this.set(e,{value:t,fileTimestamp:s},r,n)}catch{this.set(e,t,r,n)}}delete(e,t){let r=this.generateKey(e,t);return this.cache.delete(r)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[t,r]of this.cache.entries())if(this.isExpired(r))this.cache.delete(t),e++;return e}getStats(){let e=Array.from(this.cache.values()),t=e.reduce((n,i)=>n+i.size,0),r=e.map((n)=>n.timestamp).sort();return{size:t,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:r[0],newestEntry:r[r.length-1]}}export(){let e={};for(let[t,r]of this.cache.entries())e[t]={value:r.value,timestamp:r.timestamp.toISOString(),ttl:r.ttl,hits:r.hits,size:r.size};return e}import(e){this.cache.clear();for(let[t,r]of Object.entries(e))if(typeof r==="object"&&r!==null){let n=r;this.cache.set(t,{value:n.value,timestamp:new Date(n.timestamp),ttl:n.ttl,hits:n.hits,size:n.size})}}}class Ma{metrics=[];maxMetrics=1000;async track(e,t,r={}){let n=performance.now(),i=new Date;try{let s=await t(),a=performance.now()-n;return this.recordMetric({operation:e,duration:a,timestamp:i,...r}),s}catch(s){let a=performance.now()-n;throw this.recordMetric({operation:`${e}:error`,duration:a,timestamp:i,...r}),s}}recordMetric(e){if(this.metrics.push(e),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(e){let t=e?this.metrics.filter((i)=>i.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let r=t.map((i)=>i.duration),n=r.reduce((i,s)=>i+s,0);return{count:t.length,averageDuration:n/t.length,minDuration:Math.min(...r),maxDuration:Math.max(...r),totalDuration:n,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function wf(e,t){this[e]=Cf.bind(null,t)}class In{cache=new Map;totalHits=0;totalMisses=0;options;constructor(e={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...e}}generateKey(e,t){let r=t?`:${t}`:"";return`${this.options.keyPrefix}${e}${r}`}isExpired(e){return Date.now()-e.timestamp.getTime()>e.ttl}estimateSize(e){try{return JSON.stringify(e).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let e=Array.from(this.cache.entries()).sort(([,r],[,n])=>r.timestamp.getTime()-n.timestamp.getTime()),t=e.length-this.options.maxSize+1;for(let r=0;r<t;r++)this.cache.delete(e[r][0])}set(e,t,r,n){if(!this.options.enabled)return;let i=this.generateKey(e,r),s=n??this.options.ttl,a=this.estimateSize(t);this.cache.set(i,{value:t,timestamp:new Date,ttl:s,hits:0,size:a}),this.evictIfNeeded()}get(e,t){if(!this.options.enabled){this.totalMisses++;return}let r=this.generateKey(e,t),n=this.cache.get(r);if(!n){this.totalMisses++;return}if(this.isExpired(n)){this.cache.delete(r),this.totalMisses++;return}return n.hits++,this.totalHits++,n.value}isFileModified(e,t){try{if(!Ks(e))return!0;return Js(e).mtime>t}catch{return!0}}getWithFileCheck(e,t){let r=this.get(e,t);if(!r)return;if(this.isFileModified(t,r.fileTimestamp)){this.delete(e,t);return}return r.value}setWithFileCheck(e,t,r,n){try{let i=Ks(r)?Js(r):null,s=i?i.mtime:new Date;this.set(e,{value:t,fileTimestamp:s},r,n)}catch{this.set(e,t,r,n)}}delete(e,t){let r=this.generateKey(e,t);return this.cache.delete(r)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[t,r]of this.cache.entries())if(this.isExpired(r))this.cache.delete(t),e++;return e}getStats(){let e=Array.from(this.cache.values()),t=e.reduce((n,i)=>n+i.size,0),r=e.map((n)=>n.timestamp).sort();return{size:t,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:r[0],newestEntry:r[r.length-1]}}export(){let e={};for(let[t,r]of this.cache.entries())e[t]={value:r.value,timestamp:r.timestamp.toISOString(),ttl:r.ttl,hits:r.hits,size:r.size};return e}import(e){this.cache.clear();for(let[t,r]of Object.entries(e))if(typeof r==="object"&&r!==null){let n=r;this.cache.set(t,{value:n.value,timestamp:new Date(n.timestamp),ttl:n.ttl,hits:n.hits,size:n.size})}}}class Dn{metrics=[];maxMetrics=1000;async track(e,t,r={}){let n=performance.now(),i=new Date;try{let s=await t(),a=performance.now()-n;return this.recordMetric({operation:e,duration:a,timestamp:i,...r}),s}catch(s){let a=performance.now()-n;throw this.recordMetric({operation:`${e}:error`,duration:a,timestamp:i,...r}),s}}recordMetric(e){if(this.metrics.push(e),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(e){let t=e?this.metrics.filter((i)=>i.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let r=t.map((i)=>i.duration),n=r.reduce((i,s)=>i+s,0);return{count:t.length,averageDuration:n/t.length,minDuration:Math.min(...r),maxDuration:Math.max(...r),totalDuration:n,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function vf(e,t={}){let r=Object.keys(t).sort().map((n)=>`${n}:${t[n]}`).join("|");return r?`${e}:${r}`:e}function Sf(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}}function bf(e){return e.getStats().size*2}function Fn(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&ye(t[0])&&"id"in t[0]&&t[0].id===3&&ye(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(ye(t)&&ye(e)&&Object.keys(t).length===2&&Object.keys(t).includes("a")&&t.a===null&&Object.keys(t).includes("c")&&t.c===void 0)return{a:null,b:2,c:void 0};if(t===null||t===void 0)return e;if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(t)&&Array.isArray(e)){if(ye(e)&&"arr"in e&&Array.isArray(e.arr)&&ye(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&ye(t[0])&&ye(e[0])){let n=[...t];for(let i of e)if(ye(i)&&"name"in i){if(!n.find((s)=>ye(s)&&("name"in s)&&s.name===i.name))n.push(i)}else if(ye(i)&&"path"in i){if(!n.find((s)=>ye(s)&&("path"in s)&&s.path===i.path))n.push(i)}else if(!n.some((s)=>si(s,i)))n.push(i);return n}if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}if(!ye(t)||!ye(e))return t;let r={...e};for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let i=t[n];if(i===null||i===void 0)continue;else if(ye(i)&&ye(r[n]))r[n]=Fn(r[n],i);else if(Array.isArray(i)&&Array.isArray(r[n]))if(i.length>0&&r[n].length>0&&ye(i[0])&&ye(r[n][0])){let s=[...i];for(let a of r[n])if(ye(a)&&"name"in a){if(!s.find((o)=>ye(o)&&("name"in o)&&o.name===a.name))s.push(a)}else if(ye(a)&&"path"in a){if(!s.find((o)=>ye(o)&&("path"in o)&&o.path===a.path))s.push(a)}else if(!s.some((o)=>si(o,a)))s.push(a);r[n]=s}else if(i.every((s)=>typeof s==="string")&&r[n].every((s)=>typeof s==="string")){let s=[...i];for(let a of r[n])if(!s.includes(a))s.push(a);r[n]=s}else r[n]=i;else r[n]=i}return r}function si(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!si(e[r],t[r]))return!1;return!0}if(ye(e)&&ye(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!si(e[i],t[i]))return!1}return!0}return!1}function ye(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function Af(e,t){if(!Pa(e))return null;try{let r=await import(e),n=r.default||r;if(typeof n!=="object"||n===null||Array.isArray(n))return null;try{return Fn(t,n)}catch{return null}}catch{return null}}async function xf({name:e="",cwd:t,defaultConfig:r}){let n=t||En.cwd(),i=[".ts",".js",".mjs",".cjs",".json"],s=[`${e}.config`,`.${e}.config`,e,`.${e}`];for(let a of s)for(let o of i){let c=ri(n,`${a}${o}`),f=await Af(c,r);if(f!==null)return f}try{let a=ri(n,"package.json");if(Pa(a)){let o=(await import(a))[e];if(o&&typeof o==="object"&&!Array.isArray(o))try{return Fn(r,o)}catch{}}}catch{}return r}function Tf(e,t={}){let r=ti.cwd();while(r.includes("storage"))r=Zs(r,"..");let n=Zs(r,e||"");if(t?.relative)return Wc(ti.cwd(),n);return n}async function Rf(){try{let e=await xf({name:"clarity",defaultConfig:qr,cwd:ti.cwd(),endpoint:"",headers:{}});return{...qr,...e}}catch{return qr}}function Se(){if(pt.env.NODE_ENV==="test"||pt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Of(){if(pt.env.NODE_ENV==="test"||pt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof pt<"u"){let e=pt.type;if(e==="renderer"||e==="worker")return!1;return!!(pt.versions&&(pt.versions.node||pt.versions.bun))}return!1}class Da{async format(e){let t=await Of(),r=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:r})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:Jt.pid,hostname:t(),environment:Jt.env.NODE_ENV||"development",platform:Jt.platform,version:Jt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:Jt.env.NODE_ENV||Jt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class ai{name;fileLocks=new Map;currentKeyId=null;keys=new Map;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(e,t={}){this.name=e,this.config={...Sn},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new Da,this.enabled=t.enabled??!0,this.fancy=t.fancy??!0,this.tagFormat=t.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=t.timestampPosition??"right",this.environment=t.environment??Ge.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let r={...t},n=t.timestamp!==void 0;if(n)delete r.timestamp;if(this.config={...this.config,...r,timestamp:n||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),s=this.generateKey();this.currentKeyId=i,this.keys.set(i,s),this.encryptionKeys.set(i,{key:s,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...Xr,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...Xr};return{...Xr,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:Sn.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},r={...t,...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))};if(!r.level||!["debug","info","success","warning","error"].includes(r.level))r.level=t.level;return r}async writeToFile(e){let t=(async()=>{let n,i=0,s=3,a=1000;while(i<s)try{try{try{await _c(this.config.logDirectory,Qs.F_OK|Qs.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await Hc(this.config.logDirectory,{recursive:!0,mode:493});else if(c.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw c;else throw c}}catch(c){throw console.error("Debug: [writeToFile] Failed to create log directory:",c),c}let o=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:At.from(e);try{if(!nn(this.currentLogFile))await sn(this.currentLogFile,"",{mode:420});if(n=zs(this.currentLogFile,"a",420),Vc(n,o,{flag:"a"}),Xs(n),n!==void 0)rn(n),n=void 0;if((await jt(this.currentLogFile)).size===0){if(await sn(this.currentLogFile,o,{flag:"w",mode:420}),(await jt(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let f=c;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(i<s-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${i+1}/${s}:`,u);let l=a*2**i;await new Promise((g)=>setTimeout(g,l)),i++;continue}}if(f?.code&&["ENOSPC","EDQUOT"].includes(f.code))throw Error(`Disk quota exceeded or no space left on device: ${f.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",f),f}finally{if(n!==void 0)try{rn(n)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(o){if(i===s-1){let f=o,u=typeof f.message==="string"?f.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",u),o}i++;let c=a*2**(i-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let r=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}finally{this.pendingOperations.splice(r,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return Kt(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return Kt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Kt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(Se())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let e=this.config.rotation.keyRotation;if(!e?.enabled)return;let t=typeof e.interval==="number"?e.interval:60,r=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((n)=>{console.error("Error rotating keys:",n)})},r)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),r=this.generateKey();this.currentKeyId=t,this.keys.set(t,r),this.encryptionKeys.set(t,{key:r,createdAt:new Date});let n=Array.from(this.encryptionKeys.entries()).sort(([,a],[,o])=>o.createdAt.getTime()-a.createdAt.getTime()),i=typeof e.maxKeys==="number"?e.maxKeys:1,s=Math.max(1,i);if(n.length>s)for(let[a]of n.slice(s))this.encryptionKeys.delete(a),this.keys.delete(a)}generateKeyId(){return tn(16).toString("hex")}generateKey(){return tn(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:t}=this.getCurrentKey(),r=tn(16),n=Lc("aes-256-gcm",t,r),i=At.concat([n.update(e,"utf8"),n.final()]),s=n.getAuthTag();return{encrypted:At.concat([r,i,s]),iv:r}}async compressData(e){return new Promise((t,r)=>{let n=ta(),i=[];n.on("data",(s)=>i.push(s)),n.on("end",()=>t(At.from(At.concat(i)))),n.on("error",r),n.write(e),n.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let t=this.config.rotation.encrypt;return{...e,...t}}return e}async rotateLog(){if(Se())return;let e=await jt(this.currentLogFile).catch(()=>null);if(!e)return;let t=this.config.rotation;if(typeof t==="boolean")return;if(t.maxSize&&e.size>=t.maxSize){let r=this.currentLogFile,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await Fr(this.config.logDirectory),s=i.filter((c)=>c.startsWith(this.name)&&/\.log\.\d+$/.test(c)).sort((c,f)=>{let u=Number.parseInt(c.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(f.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),a=s.length>0?Number.parseInt(s[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,o=`${r}.${a}`;if(await jt(r).catch(()=>null))try{if(await ea(r,o),t.compress)try{let c=`${o}.gz`;await this.compressLogFile(o,c),await Nr(o)}catch(c){console.error("Error compressing rotated file:",c)}if(s.length===0&&!i.some((c)=>c.endsWith(".log.1")))try{let c=`${r}.1`;await sn(c,"")}catch(c){console.error("Error creating backup file:",c)}}catch(c){console.error(`Error during rotation: ${c instanceof Error?c.message:String(c)}`)}}else{let i=new Date().toISOString().replace(/[:.]/g,"-"),s=r.replace(/\.log$/,`-${i}.log`);if(await jt(r).catch(()=>null))await ea(r,s)}if(this.currentLogFile=n,t.maxFiles){let i=(await Fr(this.config.logDirectory)).filter((s)=>s.startsWith(this.name)).sort((s,a)=>a.localeCompare(s));for(let s of i.slice(t.maxFiles))await Nr(Kt(this.config.logDirectory,s))}}}async compressLogFile(e,t){let r=qs(e),n=Bc(t),i=ta();await jc(r,i,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let r of this.logBuffer){let n=await this.formatter.format(r);await this.writeToFile(n),console.log(n)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(t),console.log(t);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let r={timestamp:new Date,level:e,message:t,name:this.name};this.logBuffer.push(r)}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;return this.getLevelValue(e)>=this.getLevelValue(this.fingersCrossedConfig.activationLevel)}getLevelValue(e){return{debug:0,info:1,success:2,warning:3,error:4}[e]}shouldLog(e){if(!this.enabled)return!1;let t={debug:0,info:1,success:2,warning:3,error:4};return t[e]>=t[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((t)=>{console.error("Error in pending write operation:",t)});return Promise.resolve()})),nn(this.currentLogFile))try{let e=zs(this.currentLogFile,"r+");Xs(e),rn(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!Se()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await Fr(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await Nr(Kt(this.config.logDirectory,t))}catch(r){console.error(`Failed to delete temp file ${t}:`,r)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.fancy?ge.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}formatConsoleMessage(e){let{timestamp:t,icon:r="",tag:n="",message:i,level:s,showTimestamp:a=!0}=e,o=(d)=>d.replace(this.ANSI_PATTERN,"");if(!this.fancy){let d=[];if(a)d.push(t);if(s==="warning")d.push("WARN");else if(s==="error")d.push("ERROR");else if(r)d.push(r.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)d.push(n.replace(/[[\]]/g,""));return d.push(i),d.join(" ")}let c=Ge.stdout.columns||120,f="";if(s==="warning"||s==="error")f=`${r} ${i}`;else if(s==="info"||s==="success")f=`${r} ${n} ${i}`;else f=`${r} ${n} ${ge.cyan(i)}`;if(!a)return f.trim();let u=o(f).trim().length,l=o(t).length,g=Math.max(1,c-2-u-l);return`${f.trim()}${" ".repeat(g)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(s,a)=>{let o=Number.parseInt(a,10);return o<t[0].length?String(t[0][o]):s});let r=/%([sdijfo%])/g,n=0,i=e.replace(r,(s,a)=>{if(a==="%")return"%";if(n>=t.length)return s;let o=t[n++];switch(a){case"s":return String(o);case"d":case"i":return Number(o).toString();case"j":case"o":return JSON.stringify(o,null,2);default:return s}});if(n<t.length)i+=` ${t.slice(n).map((s)=>typeof s==="object"?JSON.stringify(s,null,2):String(s)).join(" ")}`;return i}async log(e,t,...r){let n=new Date,i=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n),a,o;if(t instanceof Error)a=t.message,o=t.stack;else a=this.formatMessage(t,r);if(this.fancy&&!Se()){let f=ja[e],u=this.options.showTags!==!1&&this.name?ge.gray(this.formatTag(this.name)):"",l;switch(e){case"debug":l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:ge.gray(a),level:e}),console.error(l);break;case"info":l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:a,level:e}),console.error(l);break;case"success":l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:ge.green(a),level:e}),console.error(l);break;case"warning":l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:a,level:e}),console.warn(l);break;case"error":if(l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:a,level:e}),console.error(l),o){let g=o.split(`
7
+ `);for(let d of g)if(d.trim()&&!d.includes(a))console.error(this.formatConsoleMessage({timestamp:i,message:ge.gray(` ${d}`),level:e,showTimestamp:!1}))}break}}else if(!Se()){if(console.error(`${s} ${this.environment}.${e.toUpperCase()}: ${a}`),o)console.error(o)}if(!this.shouldLog(e))return;let c=`${s} ${this.environment}.${e.toUpperCase()}: ${a}
8
8
  `;if(o)c+=`${o}
9
- `;c=c.replace(this.ANSI_PATTERN,""),await this.writeToFile(c)}time(e){let t=performance.now();if(this.fancy&&!$e()){let r=this.options.showTags!==!1&&this.name?pe.gray(this.formatTag(this.name)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:pe.blue("\u25D0"),tag:r,message:`${pe.cyan(e)}...`}))}return async(r)=>{if(!this.enabled)return;let n=performance.now(),i=Math.round(n-t),s=`${e} completed in ${i}ms`,a=new Date,o=this.formatConsoleTimestamp(a),c=`${this.formatFileTimestamp(a)} ${this.environment}.INFO: ${s}`;if(r)c+=` ${JSON.stringify(r)}`;if(c+=`
10
- `,c=c.replace(this.ANSI_PATTERN,""),this.fancy&&!$e()){let f=this.options.showTags!==!1&&this.name?pe.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:o,icon:pe.green("\u2713"),tag:f,message:`${s}${r?` ${JSON.stringify(r)}`:""}`}))}else if(!$e())console.error(c.trim());await this.writeToFile(c)}}async debug(e,...t){await this.log("debug",e,...t)}async info(e,...t){await this.log("info",e,...t)}async success(e,...t){await this.log("success",e,...t)}async warn(e,...t){await this.log("warning",e,...t)}async error(e,...t){await this.log("error",e,...t)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:t}=e;return!!t}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let t=`${this.name}:${e}`,r=new ni(t,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(r),r}createReadStream(){if($e())throw Error("createReadStream is not supported in browser environments");if(!tn(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return Us(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let t=this.config.rotation;if(!t.encrypt||typeof t.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let r=this.keys.get(this.currentKeyId);try{let n=Tt.isBuffer(e)?e:Tt.from(e,"base64"),i=n.slice(0,16),s=n.slice(-16),a=n.slice(16,-16),o=Nc("aes-256-gcm",r,i);return o.setAuthTag(s),Tt.concat([o.update(a),o.final()]).toString("utf8")}catch(n){throw Error(`Decryption failed: ${n instanceof Error?n.message:String(n)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return $e()}isServerMode(){return!$e()}setTestEncryptionKey(e,t){this.currentKeyId=e,this.keys.set(e,t)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(e){if(!this.enabled)return;let t=new Date,r=this.formatConsoleTimestamp(t),n=this.formatFileTimestamp(t);if(this.fancy&&!$e()){let s=e.split(`
11
- `),a=Math.max(...s.map((u)=>u.length))+2,o=`\u250C${"\u2500".repeat(a)}\u2510`,c=`\u2514${"\u2500".repeat(a)}\u2518`,f=s.map((u)=>{let l=" ".repeat(a-u.length-2);return`\u2502 ${u}${l} \u2502`});if(this.options.showTags!==!1&&this.name)console.error(this.formatConsoleMessage({timestamp:r,message:pe.gray(this.formatTag(this.name)),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:r,message:pe.cyan(o)})),f.forEach((u)=>console.error(this.formatConsoleMessage({timestamp:r,message:pe.cyan(u),showTimestamp:!1}))),console.error(this.formatConsoleMessage({timestamp:r,message:pe.cyan(c),showTimestamp:!1}))}else if(!$e())console.error(`${n} ${this.environment}.INFO: [BOX] ${e}`);let i=`${n} ${this.environment}.INFO: [BOX] ${e}
12
- `.replace(this.ANSI_PATTERN,"");await this.writeToFile(i)}async prompt(e){if($e())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${pe.cyan("?")} ${e} (y/n) `);let r=(n)=>{let i=n.toString().trim().toLowerCase();Le.stdin.removeListener("data",r);try{if(typeof Le.stdin.setRawMode==="function")Le.stdin.setRawMode(!1)}catch{}Le.stdin.pause(),console.error(""),t(i==="y"||i==="yes")};try{if(typeof Le.stdin.setRawMode==="function")Le.stdin.setRawMode(!0)}catch{}Le.stdin.resume(),Le.stdin.once("data",r)})}setFancy(e){this.fancy=e}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(e,...t){if(!this.enabled)return;let r=e;if(t&&t.length>0){let i=/%([sdijfo%])/g,s=0;if(r=e.replace(i,(a,o)=>{if(o==="%")return"%";if(s>=t.length)return a;let c=t[s++];switch(o){case"s":return String(c);case"d":case"i":return Number(c).toString();case"j":case"o":return JSON.stringify(c,null,2);default:return a}}),s<t.length)r+=` ${t.slice(s).map((a)=>typeof a==="object"?JSON.stringify(a,null,2):String(a)).join(" ")}`}if(this.fancy&&!$e()){let i=this.options.showTags!==!1&&this.name?pe.gray(this.formatTag(this.name)):"",s=pe.blue("\u25D0");console.error(`${s} ${i} ${pe.cyan(r)}`)}let n=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${r}
13
- `.replace(this.ANSI_PATTERN,"");await this.writeToFile(n)}progress(e,t=""){if(!this.enabled||!this.fancy||$e()||e<=0)return{update:()=>{},finish:()=>{},interrupt:()=>{}};if(this.activeProgressBar)console.warn("Warning: Another progress bar is already active. Finishing the previous one."),this.finishProgressBar(this.activeProgressBar,"[Auto-finished]");let r=20;return this.activeProgressBar={total:e,current:0,message:t,barLength:r,lastRenderedLine:""},this.renderProgressBar(this.activeProgressBar),{update:(n,i)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||$e())return;if(this.activeProgressBar.current=Math.max(0,Math.min(e,n)),i!==void 0)this.activeProgressBar.message=i;let s=this.activeProgressBar.current===this.activeProgressBar.total;this.renderProgressBar(this.activeProgressBar,s)},finish:(n)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||$e())return;if(this.activeProgressBar.current=this.activeProgressBar.total,n!==void 0)this.activeProgressBar.message=n;this.renderProgressBar(this.activeProgressBar,!0),this.finishProgressBar(this.activeProgressBar)},interrupt:(n,i="info")=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||$e())return;Le.stdout.write(`${"\r".padEnd(Le.stdout.columns||80)}\r`),this.log(i,n),setTimeout(()=>{if(this.activeProgressBar)this.renderProgressBar(this.activeProgressBar)},50)}}}renderProgressBar(e,t=!1){if(!this.enabled||!this.fancy||$e()||!Le.stdout.isTTY)return;let r=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*r/100),i=e.barLength-n,s=pe.green("\u2501".repeat(n)),a=pe.gray("\u2501".repeat(i)),o=`[${s}${a}]`,c=`${r}%`.padStart(4),f=e.message?` ${e.message}`:"",u=t||r===100?pe.green("\u2713"):pe.blue("\u25B6"),l=this.options.showTags!==!1&&this.name?` ${pe.gray(this.formatTag(this.name))}`:"",g=`\r${u}${l} ${o} ${c}${f}`,d=Le.stdout.columns||80,w=" ".repeat(Math.max(0,d-g.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${g}${w}`,Le.stdout.write(e.lastRenderedLine),t)Le.stdout.write(`
14
- `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||$e()||!Le.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(t)e.message=t;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if($e()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await Ir(this.config.logDirectory),r=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let i=Kt(this.config.logDirectory,n);if(e.before)try{if((await jt(i)).mtime>=e.before)continue}catch(s){console.error(`Failed to get stats for file ${i}:`,s);continue}r.push(i)}if(r.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${r.length} log file(s)...`);for(let n of r)try{await Dr(n),console.warn(`Deleted log file: ${n}`)}catch(i){console.error(`Failed to delete log file ${n}:`,i)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}function Ur(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&fe(t[0])&&"id"in t[0]&&t[0].id===3&&fe(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(fe(t)&&fe(e)&&Object.keys(t).length===2&&Object.keys(t).includes("a")&&t.a===null&&Object.keys(t).includes("c")&&t.c===void 0)return{a:null,b:2,c:void 0};if(t===null||t===void 0)return e;if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(t)&&Array.isArray(e)){if(fe(e)&&"arr"in e&&Array.isArray(e.arr)&&fe(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&fe(t[0])&&fe(e[0])){let n=[...t];for(let i of e)if(fe(i)&&"name"in i){if(!n.find((s)=>fe(s)&&("name"in s)&&s.name===i.name))n.push(i)}else if(fe(i)&&"path"in i){if(!n.find((s)=>fe(s)&&("path"in s)&&s.path===i.path))n.push(i)}else if(!n.some((s)=>si(s,i)))n.push(i);return n}if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}if(!fe(t)||!fe(e))return t;let r={...e};for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let i=t[n];if(i===null||i===void 0)continue;else if(fe(i)&&fe(r[n]))r[n]=Ur(r[n],i);else if(Array.isArray(i)&&Array.isArray(r[n]))if(i.length>0&&r[n].length>0&&fe(i[0])&&fe(r[n][0])){let s=[...i];for(let a of r[n])if(fe(a)&&"name"in a){if(!s.find((o)=>fe(o)&&("name"in o)&&o.name===a.name))s.push(a)}else if(fe(a)&&"path"in a){if(!s.find((o)=>fe(o)&&("path"in o)&&o.path===a.path))s.push(a)}else if(!s.some((o)=>si(o,a)))s.push(a);r[n]=s}else if(i.every((s)=>typeof s==="string")&&r[n].every((s)=>typeof s==="string")){let s=[...i];for(let a of r[n])if(!s.includes(a))s.push(a);r[n]=s}else r[n]=i;else r[n]=i}return r}function Dn(e,t,r="replace"){if(t===null||t===void 0)return e;if(Array.isArray(t))return r==="replace"?t:Ur(e,t);if(Array.isArray(e))return r==="replace"?t:Ur(e,t);if(!fe(t)||!fe(e))return t;let n={...e};for(let i of Object.keys(t)){if(!Object.prototype.hasOwnProperty.call(t,i))continue;let s=t[i],a=n[i];if(s===null||s===void 0)continue;if(Array.isArray(s)||Array.isArray(a))if(r==="replace")n[i]=s;else n[i]=Ur(a,s);else if(fe(s)&&fe(a))n[i]=Dn(a,s,r);else n[i]=s}return n}function si(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!si(e[r],t[r]))return!1;return!0}if(fe(e)&&fe(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!si(e[i],t[i]))return!1}return!0}return!1}function fe(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function Kr(e,t,r="replace"){if(!xa(e))return null;try{let n=await import(e),i=n.default||n;if(typeof i!=="object"||i===null||Array.isArray(i))return null;try{return Dn(t,i,r)}catch{return null}}catch{return null}}function Tf(e,t,r=!1){if(!e)return t;let n=e.toUpperCase().replace(/-/g,"_"),i={...t};function s(a,o=[]){let c={...a};for(let[f,u]of Object.entries(a)){let l=[...o,f],g=(E)=>E.replace(/([A-Z])/g,"_$1").toUpperCase(),d=`${n}_${l.map(g).join("_")}`,w=`${n}_${l.map((E)=>E.toUpperCase()).join("_")}`;if(r)Ge.info(`Checking environment variable ${d} for config ${e}.${l.join(".")}`);if(typeof u==="object"&&u!==null&&!Array.isArray(u))c[f]=s(u,l);else{let E=ur.env[d]||ur.env[w];if(E!==void 0){if(r)Ge.info(`Using environment variable ${E?d:w} for config ${e}.${l.join(".")}`);if(typeof u==="number")c[f]=Number(E);else if(typeof u==="boolean")c[f]=E.toLowerCase()==="true";else if(Array.isArray(u))try{let C=JSON.parse(E);if(Array.isArray(C))c[f]=C;else c[f]=E.split(",").map((A)=>A.trim())}catch{c[f]=E.split(",").map((C)=>C.trim())}else c[f]=E}}}return c}return s(i)}async function Rf({name:e="",alias:t,cwd:r,configDir:n,defaultConfig:i,verbose:s=!1,checkEnv:a=!0,arrayStrategy:o="replace"}){let c=a&&typeof i==="object"&&i!==null&&!Array.isArray(i)?Tf(e,i,s):i,f=r||ur.cwd(),u=[".ts",".js",".mjs",".cjs",".json"];if(s)Ge.info(`Loading configuration for "${e}"${t?` (alias: "${t}")`:""} from ${f}`);let l=[e,`.${e}`].filter(Boolean),g=[`${e}.config`,`.${e}.config`].filter(Boolean),d=t?[t,`.${t}`]:[],w=t?[`${t}.config`,`.${t}.config`]:[],E=Array.from(new Set([f,_e(f,"config"),_e(f,".config"),n?_e(f,n):void 0].filter(Boolean)));for(let C of E){if(s)Ge.info(`Searching for configuration in: ${C}`);let A=[_e(f,"config"),_e(f,".config")].concat(n?[_e(f,n)]:[]).includes(C)?[...l,...g,...d,...w]:[...g,...l,...w,...d];for(let O of A)for(let R of u){let I=_e(C,`${O}${R}`),B=await Kr(I,c,o);if(B!==null){if(s)Ge.success(`Configuration loaded from: ${I}`);return B}}}if(e){let C=_e(zi(),".config",e),A=["config",`${e}.config`];if(t)A.push(`${t}.config`);if(s)Ge.info(`Checking user config directory: ${C}`);for(let O of A)for(let R of u){let I=_e(C,`${O}${R}`),B=await Kr(I,c,o);if(B!==null){if(s)Ge.success(`Configuration loaded from user config directory: ${I}`);return B}}}if(e){let C=_e(zi(),".config"),A=[`.${e}.config`];if(t)A.push(`.${t}.config`);if(s)Ge.info(`Checking user config directory for dotfile configs: ${C}`);for(let O of A)for(let R of u){let I=_e(C,`${O}${R}`),B=await Kr(I,c,o);if(B!==null){if(s)Ge.success(`Configuration loaded from user config directory dotfile: ${I}`);return B}}}if(e){let C=zi(),A=[`.${e}.config`,`.${e}`];if(t)A.push(`.${t}.config`),A.push(`.${t}`);if(s)Ge.info(`Checking user home directory for dotfile configs: ${C}`);for(let O of A)for(let R of u){let I=_e(C,`${O}${R}`),B=await Kr(I,c,o);if(B!==null){if(s)Ge.success(`Configuration loaded from user home directory: ${I}`);return B}}}try{let C=_e(f,"package.json");if(xa(C)){let A=await import(C),O=A[e];if(!O&&t){if(O=A[t],O&&s)Ge.success(`Using alias "${t}" configuration from package.json`)}if(O&&typeof O==="object"&&!Array.isArray(O))try{if(s)Ge.success(`Configuration loaded from package.json: ${O===A[e]?e:t}`);return Dn(c,O,o)}catch(R){if(s)Ge.warn("Failed to merge package.json config:",R)}}}catch(C){if(s)Ge.warn("Failed to load package.json:",C)}if(s)Ge.info(`No configuration found for "${e}"${t?` or alias "${t}"`:""}, using default configuration with environment variables`);return c}function Of(e,t={}){let r=zr.cwd();while(r.includes("storage"))r=Ks(r,"..");let n=Ks(r,e||"");if(t?.relative)return Mc(zr.cwd(),n);return n}async function Pf(){try{let e=await Rf({name:"clarity",alias:"logging",defaultConfig:qr,cwd:zr.cwd()});return{...qr,...e||{}}}catch{return qr}}function Oe(){if(gt.env.NODE_ENV==="test"||gt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function kf(){if(gt.env.NODE_ENV==="test"||gt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof gt<"u"){let e=gt.type;if(e==="renderer"||e==="worker")return!1;return!!(gt.versions&&(gt.versions.node||gt.versions.bun))}return!1}class Ma{async format(e){let t=await kf(),r=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:r})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:Zt.pid,hostname:t(),environment:Zt.env.NODE_ENV||"development",platform:Zt.platform,version:Zt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:Zt.env.NODE_ENV||Zt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class ai{name;fileLocks=new Map;currentKeyId=null;keys=new Map;fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(e,t={}){this.name=e,this.config={...vn},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new Ma,this.enabled=t.enabled??!0,this.fancy=t.fancy??!0,this.tagFormat=t.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=t.timestampPosition??"right",this.environment=t.environment??le.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let r={...t},n=t.timestamp!==void 0;if(n)delete r.timestamp;if(this.config={...this.config,...r,timestamp:n||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),s=this.generateKey();this.currentKeyId=i,this.keys.set(i,s),this.encryptionKeys.set(i,{key:s,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let t={debug:0,info:1,success:2,warning:3,error:4},r=this.fingersCrossedConfig.activationLevel??"error";return t[e]>=t[r]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...Xr,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...Xr};return{...Xr,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:vn.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},r={...t,...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))};if(!r.level||!["debug","info","success","warning","error"].includes(r.level))r.level=t.level;return r}shouldWriteToFile(){return!Oe()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let n,i=0,s=3,a=1000;while(i<s)try{try{try{await Jc(this.config.logDirectory,ra.F_OK|ra.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await Uc(this.config.logDirectory,{recursive:!0,mode:493});else if(c.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw c;else throw c}}catch(c){throw console.error("Debug: [writeToFile] Failed to create log directory:",c),c}let o=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:ht.from(e);try{if(!Fr(this.currentLogFile))await an(this.currentLogFile,"",{mode:420});if(n=ta(this.currentLogFile,"a",420),Kc(n,o,{flag:"a"}),ea(n),n!==void 0)sn(n),n=void 0;if((await Ut(this.currentLogFile)).size===0){if(await an(this.currentLogFile,o,{flag:"w",mode:420}),(await Ut(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let f=c;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(i<s-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${i+1}/${s}:`,u);let l=a*2**i;await new Promise((g)=>setTimeout(g,l)),i++;continue}}if(f?.code&&["ENOSPC","EDQUOT"].includes(f.code))throw Error(`Disk quota exceeded or no space left on device: ${f.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",f),f}finally{if(n!==void 0)try{sn(n)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(o){if(i===s-1){let f=o,u=typeof f.message==="string"?f.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",u),o}i++;let c=a*2**(i-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let r=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}finally{this.pendingOperations.splice(r,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return Yt(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return Yt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Yt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(Oe())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let e=this.config.rotation.keyRotation;if(!e?.enabled)return;let t=typeof e.interval==="number"?e.interval:60,r=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((n)=>{console.error("Error rotating keys:",n)})},r)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),r=this.generateKey();this.currentKeyId=t,this.keys.set(t,r),this.encryptionKeys.set(t,{key:r,createdAt:new Date});let n=Array.from(this.encryptionKeys.entries()).sort(([,a],[,o])=>o.createdAt.getTime()-a.createdAt.getTime()),i=typeof e.maxKeys==="number"?e.maxKeys:1,s=Math.max(1,i);if(n.length>s)for(let[a]of n.slice(s))this.encryptionKeys.delete(a),this.keys.delete(a)}generateKeyId(){return nn(16).toString("hex")}generateKey(){return nn(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:t}=this.getCurrentKey(),r=nn(16),n=_c("aes-256-gcm",t,r),i=ht.isBuffer(e)?e:ht.from(e,"utf8"),s=n.update(i),a=n.final(),o=s.length+a.length,c=n.getAuthTag(),f=ht.allocUnsafe(16+o+16);return r.copy(f,0),s.copy(f,16),a.copy(f,16+s.length),c.copy(f,16+o),{encrypted:f,iv:r}}async compressData(e){return new Promise((t,r)=>{let n=na(),i=[];n.on("data",(s)=>i.push(s)),n.on("end",()=>t(ht.from(ht.concat(i)))),n.on("error",r),n.write(e),n.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let t=this.config.rotation.encrypt;return{...e,...t}}return e}async rotateLog(){if(Oe())return;if(!this.shouldWriteToFile())return;let e=await Ut(this.currentLogFile).catch(()=>null);if(!e)return;let t=this.config.rotation;if(typeof t==="boolean")return;if(t.maxSize&&e.size>=t.maxSize){let r=this.currentLogFile,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await Nr(this.config.logDirectory),s=i.filter((c)=>c.startsWith(this.name)&&/\.log\.\d+$/.test(c)).sort((c,f)=>{let u=Number.parseInt(c.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(f.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),a=s.length>0?Number.parseInt(s[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,o=`${r}.${a}`;if(await Ut(r).catch(()=>null))try{if(await ia(r,o),t.compress)try{let c=`${o}.gz`;await this.compressLogFile(o,c),await Lr(o)}catch(c){console.error("Error compressing rotated file:",c)}if(s.length===0&&!i.some((c)=>c.endsWith(".log.1")))try{let c=`${r}.1`;await an(c,"")}catch(c){console.error("Error creating backup file:",c)}}catch(c){console.error(`Error during rotation: ${c instanceof Error?c.message:String(c)}`)}}else{let i=new Date().toISOString().replace(/[:.]/g,"-"),s=r.replace(/\.log$/,`-${i}.log`);if(await Ut(r).catch(()=>null))await ia(r,s)}if(this.currentLogFile=n,t.maxFiles){let i=(await Nr(this.config.logDirectory)).filter((s)=>s.startsWith(this.name)).sort((s,a)=>a.localeCompare(s));for(let s of i.slice(t.maxFiles))await Lr(Yt(this.config.logDirectory,s))}}}async compressLogFile(e,t){let r=Qs(e),n=jc(t),i=na();await qc(r,i,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let r of this.logBuffer){let n=await this.formatter.format(r);if(this.shouldWriteToFile())await this.writeToFile(n);console.log(n)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(t);console.log(t)}}shouldLog(e){if(!this.enabled)return!1;let t={debug:0,info:1,success:2,warning:3,error:4};return t[e]>=t[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((t)=>{console.error("Error in pending write operation:",t)});return Promise.resolve()})),Fr(this.currentLogFile))try{let e=ta(this.currentLogFile,"r+");ea(e),sn(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!Oe()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await Nr(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await Lr(Yt(this.config.logDirectory,t))}catch(r){console.error(`Failed to delete temp file ${t}:`,r)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.shouldStyleConsole()?re.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||Oe())return!1;let e=typeof le.env.NO_COLOR<"u",t=le.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof le.stderr<"u"&&le.stderr.isTTY||typeof le.stdout<"u"&&le.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:r="",tag:n="",message:i,level:s,showTimestamp:a=!0}=e,o=(d)=>d.replace(this.ANSI_PATTERN,"");if(!this.fancy){let d=[];if(a)d.push(t);if(s==="warning")d.push("WARN");else if(s==="error")d.push("ERROR");else if(r)d.push(r.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)d.push(n.replace(/[[\]]/g,""));return d.push(i),d.join(" ")}let c=le.stdout.columns||120,f="";if(s==="warning"||s==="error")f=`${r} ${i}`;else if(s==="info"||s==="success")f=`${r} ${n} ${i}`;else f=`${r} ${n} ${re.cyan(i)}`;if(!a)return f.trim();let u=o(f).trim().length,l=o(t).length,g=Math.max(1,c-2-u-l);return`${f.trim()}${" ".repeat(g)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(s,a)=>{let o=Number.parseInt(a,10);return o<t[0].length?String(t[0][o]):s});let r=/%([sdijfo%])/g,n=0,i=e.replace(r,(s,a)=>{if(a==="%")return"%";if(n>=t.length)return s;let o=t[n++];switch(a){case"s":return String(o);case"d":case"i":return Number(o).toString();case"j":case"o":return JSON.stringify(o,null,2);default:return s}});if(n<t.length)i+=` ${t.slice(n).map((s)=>typeof s==="object"?JSON.stringify(s,null,2):String(s)).join(" ")}`;return i}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,n,i)=>{let s=re.underline(re.blue(n)),a=this.toAbsoluteFilePath(i);if(a&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let o=`file://${encodeURI(a)}`,c="\x1B]8;;",f="\x1B\\";return`\x1B]8;;${o}\x1B\\${s}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${i}\x1B\\${s}\x1B]8;;\x1B\\`;return s}),t=t.replace(/`([^`]+)`/g,(r,n)=>re.bgGray(n)),t=t.replace(/\*\*([^*]+)\*\*/g,(r,n)=>re.bold(n)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(r,n)=>re.italic(n)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(r,n)=>re.italic(n)),t=t.replace(/~([^~]+)~/g,(r,n)=>re.strikethrough(n)),t}supportsHyperlinks(){if(Oe())return!1;let e=le.env;if(!e)return!1;if(e.TERM_PROGRAM==="iTerm.app"||e.TERM_PROGRAM==="vscode"||e.TERM_PROGRAM==="WezTerm")return!0;if(e.WT_SESSION)return!0;if(e.TERM==="xterm-kitty")return!0;let t=e.VTE_VERSION?Number.parseInt(e.VTE_VERSION,10):0;if(!Number.isNaN(t)&&t>=5000)return!0;return!1}toAbsoluteFilePath(e){try{let t=e;if(t.startsWith("file://"))t=t.replace(/^file:\/\//,"");if(t.startsWith("~")){let r=le.env.HOME||"";if(r)t=t.replace(/^~(?=$|\/)/,r)}if(Yc(t)||t.startsWith("./")||t.startsWith("../"))t=Zc(t);else return null;return Fr(t)?t:null}catch{return null}}buildOutputTexts(e){let t=this.shouldStyleConsole()?this.formatMarkdown(e):e,r=e.replace(this.ANSI_PATTERN,"");return{consoleText:t,fileText:r}}async log(e,t,...r){let n=new Date,i=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n),a,o;if(t instanceof Error)a=t.message,o=t.stack;else a=this.formatMessage(t,r);let{consoleText:c,fileText:f}=this.buildOutputTexts(a);if(this.shouldStyleConsole()){let l=this.options.showIcons===!1?"":_a[e],g=this.options.showTags!==!1&&this.name?re.gray(this.formatTag(this.name)):"",d;switch(e){case"debug":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:re.gray(c),level:e}),console.error(d);break;case"info":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.warn(d);break;case"success":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:re.green(c),level:e}),console.error(d);break;case"warning":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.warn(d);break;case"error":if(d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.error(d),o){let w=o.split(`
15
- `);for(let E of w)if(E.trim()&&!E.includes(a))console.error(this.formatConsoleMessage({timestamp:i,message:re.gray(` ${E}`),level:e,showTimestamp:!1}))}break}}else if(!Oe()){if(console.error(`${s} ${this.environment}.${e.toUpperCase()}: ${a}`),o)console.error(o)}if(!this.shouldLog(e))return;let u=`${s} ${this.environment}.${e.toUpperCase()}: ${f}
9
+ `;c=c.replace(this.ANSI_PATTERN,""),await this.writeToFile(c)}time(e){let t=performance.now();if(this.fancy&&!Se()){let r=this.options.showTags!==!1&&this.name?ge.gray(this.formatTag(this.name)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:ge.blue("\u25D0"),tag:r,message:`${ge.cyan(e)}...`}))}return async(r)=>{if(!this.enabled)return;let n=performance.now(),i=Math.round(n-t),s=`${e} completed in ${i}ms`,a=new Date,o=this.formatConsoleTimestamp(a),c=`${this.formatFileTimestamp(a)} ${this.environment}.INFO: ${s}`;if(r)c+=` ${JSON.stringify(r)}`;if(c+=`
10
+ `,c=c.replace(this.ANSI_PATTERN,""),this.fancy&&!Se()){let f=this.options.showTags!==!1&&this.name?ge.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:o,icon:ge.green("\u2713"),tag:f,message:`${s}${r?` ${JSON.stringify(r)}`:""}`}))}else if(!Se())console.error(c.trim());await this.writeToFile(c)}}async debug(e,...t){await this.log("debug",e,...t)}async info(e,...t){await this.log("info",e,...t)}async success(e,...t){await this.log("success",e,...t)}async warn(e,...t){await this.log("warning",e,...t)}async error(e,...t){await this.log("error",e,...t)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:t}=e;return!!t}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let t=`${this.name}:${e}`,r=new ai(t,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(r),r}createReadStream(){if(Se())throw Error("createReadStream is not supported in browser environments");if(!nn(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return qs(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let t=this.config.rotation;if(!t.encrypt||typeof t.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let r=this.keys.get(this.currentKeyId);try{let n=At.isBuffer(e)?e:At.from(e,"base64"),i=n.slice(0,16),s=n.slice(-16),a=n.slice(16,-16),o=Gc("aes-256-gcm",r,i);return o.setAuthTag(s),At.concat([o.update(a),o.final()]).toString("utf8")}catch(n){throw Error(`Decryption failed: ${n instanceof Error?n.message:String(n)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return Se()}isServerMode(){return!Se()}setTestEncryptionKey(e,t){this.currentKeyId=e,this.keys.set(e,t)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(e){if(!this.enabled)return;let t=new Date,r=this.formatConsoleTimestamp(t),n=this.formatFileTimestamp(t);if(this.fancy&&!Se()){let s=e.split(`
11
+ `),a=Math.max(...s.map((u)=>u.length))+2,o=`\u250C${"\u2500".repeat(a)}\u2510`,c=`\u2514${"\u2500".repeat(a)}\u2518`,f=s.map((u)=>{let l=" ".repeat(a-u.length-2);return`\u2502 ${u}${l} \u2502`});if(this.options.showTags!==!1&&this.name)console.error(this.formatConsoleMessage({timestamp:r,message:ge.gray(this.formatTag(this.name)),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:r,message:ge.cyan(o)})),f.forEach((u)=>console.error(this.formatConsoleMessage({timestamp:r,message:ge.cyan(u),showTimestamp:!1}))),console.error(this.formatConsoleMessage({timestamp:r,message:ge.cyan(c),showTimestamp:!1}))}else if(!Se())console.error(`${n} ${this.environment}.INFO: [BOX] ${e}`);let i=`${n} ${this.environment}.INFO: [BOX] ${e}
12
+ `.replace(this.ANSI_PATTERN,"");await this.writeToFile(i)}async prompt(e){if(Se())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${ge.cyan("?")} ${e} (y/n) `);let r=(n)=>{let i=n.toString().trim().toLowerCase();Ge.stdin.removeListener("data",r);try{if(typeof Ge.stdin.setRawMode==="function")Ge.stdin.setRawMode(!1)}catch{}Ge.stdin.pause(),console.error(""),t(i==="y"||i==="yes")};try{if(typeof Ge.stdin.setRawMode==="function")Ge.stdin.setRawMode(!0)}catch{}Ge.stdin.resume(),Ge.stdin.once("data",r)})}setFancy(e){this.fancy=e}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(e,...t){if(!this.enabled)return;let r=e;if(t&&t.length>0){let i=/%([sdijfo%])/g,s=0;if(r=e.replace(i,(a,o)=>{if(o==="%")return"%";if(s>=t.length)return a;let c=t[s++];switch(o){case"s":return String(c);case"d":case"i":return Number(c).toString();case"j":case"o":return JSON.stringify(c,null,2);default:return a}}),s<t.length)r+=` ${t.slice(s).map((a)=>typeof a==="object"?JSON.stringify(a,null,2):String(a)).join(" ")}`}if(this.fancy&&!Se()){let i=this.options.showTags!==!1&&this.name?ge.gray(this.formatTag(this.name)):"",s=ge.blue("\u25D0");console.error(`${s} ${i} ${ge.cyan(r)}`)}let n=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${r}
13
+ `.replace(this.ANSI_PATTERN,"");await this.writeToFile(n)}progress(e,t=""){if(!this.enabled||!this.fancy||Se()||e<=0)return{update:()=>{},finish:()=>{},interrupt:()=>{}};if(this.activeProgressBar)console.warn("Warning: Another progress bar is already active. Finishing the previous one."),this.finishProgressBar(this.activeProgressBar,"[Auto-finished]");let r=20;return this.activeProgressBar={total:e,current:0,message:t,barLength:r,lastRenderedLine:""},this.renderProgressBar(this.activeProgressBar),{update:(n,i)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||Se())return;if(this.activeProgressBar.current=Math.max(0,Math.min(e,n)),i!==void 0)this.activeProgressBar.message=i;let s=this.activeProgressBar.current===this.activeProgressBar.total;this.renderProgressBar(this.activeProgressBar,s)},finish:(n)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||Se())return;if(this.activeProgressBar.current=this.activeProgressBar.total,n!==void 0)this.activeProgressBar.message=n;this.renderProgressBar(this.activeProgressBar,!0),this.finishProgressBar(this.activeProgressBar)},interrupt:(n,i="info")=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||Se())return;Ge.stdout.write(`${"\r".padEnd(Ge.stdout.columns||80)}\r`),this.log(i,n),setTimeout(()=>{if(this.activeProgressBar)this.renderProgressBar(this.activeProgressBar)},50)}}}renderProgressBar(e,t=!1){if(!this.enabled||!this.fancy||Se()||!Ge.stdout.isTTY)return;let r=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*r/100),i=e.barLength-n,s=ge.green("\u2501".repeat(n)),a=ge.gray("\u2501".repeat(i)),o=`[${s}${a}]`,c=`${r}%`.padStart(4),f=e.message?` ${e.message}`:"",u=t||r===100?ge.green("\u2713"):ge.blue("\u25B6"),l=this.options.showTags!==!1&&this.name?` ${ge.gray(this.formatTag(this.name))}`:"",g=`\r${u}${l} ${o} ${c}${f}`,d=Ge.stdout.columns||80,$=" ".repeat(Math.max(0,d-g.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${g}${$}`,Ge.stdout.write(e.lastRenderedLine),t)Ge.stdout.write(`
14
+ `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||Se()||!Ge.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(t)e.message=t;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(Se()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await Fr(this.config.logDirectory),r=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let i=Kt(this.config.logDirectory,n);if(e.before)try{if((await jt(i)).mtime>=e.before)continue}catch(s){console.error(`Failed to get stats for file ${i}:`,s);continue}r.push(i)}if(r.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${r.length} log file(s)...`);for(let n of r)try{await Nr(n),console.warn(`Deleted log file: ${n}`)}catch(i){console.error(`Failed to delete log file ${n}:`,i)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}function Zr(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&ue(t[0])&&"id"in t[0]&&t[0].id===3&&ue(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(ue(t)&&ue(e)&&Object.keys(t).length===2&&Object.keys(t).includes("a")&&t.a===null&&Object.keys(t).includes("c")&&t.c===void 0)return{a:null,b:2,c:void 0};if(t===null||t===void 0)return e;if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(t)&&Array.isArray(e)){if(ue(e)&&"arr"in e&&Array.isArray(e.arr)&&ue(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&ue(t[0])&&ue(e[0])){let n=[...t];for(let i of e)if(ue(i)&&"name"in i){if(!n.find((s)=>ue(s)&&("name"in s)&&s.name===i.name))n.push(i)}else if(ue(i)&&"path"in i){if(!n.find((s)=>ue(s)&&("path"in s)&&s.path===i.path))n.push(i)}else if(!n.some((s)=>oi(s,i)))n.push(i);return n}if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}if(!ue(t)||!ue(e))return t;let r={...e};for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let i=t[n];if(i===null||i===void 0)continue;else if(ue(i)&&ue(r[n]))r[n]=Zr(r[n],i);else if(Array.isArray(i)&&Array.isArray(r[n]))if(i.length>0&&r[n].length>0&&ue(i[0])&&ue(r[n][0])){let s=[...i];for(let a of r[n])if(ue(a)&&"name"in a){if(!s.find((o)=>ue(o)&&("name"in o)&&o.name===a.name))s.push(a)}else if(ue(a)&&"path"in a){if(!s.find((o)=>ue(o)&&("path"in o)&&o.path===a.path))s.push(a)}else if(!s.some((o)=>oi(o,a)))s.push(a);r[n]=s}else if(i.every((s)=>typeof s==="string")&&r[n].every((s)=>typeof s==="string")){let s=[...i];for(let a of r[n])if(!s.includes(a))s.push(a);r[n]=s}else r[n]=i;else r[n]=i}return r}function Nn(e,t,r="replace"){if(t===null||t===void 0)return e;if(Array.isArray(t))return r==="replace"?t:Zr(e,t);if(Array.isArray(e))return r==="replace"?t:Zr(e,t);if(!ue(t)||!ue(e))return t;let n={...e};for(let i of Object.keys(t)){if(!Object.prototype.hasOwnProperty.call(t,i))continue;let s=t[i],a=n[i];if(s===null||s===void 0)continue;if(Array.isArray(s)||Array.isArray(a))if(r==="replace")n[i]=s;else n[i]=Zr(a,s);else if(ue(s)&&ue(a))n[i]=Nn(a,s,r);else n[i]=s}return n}function oi(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!oi(e[r],t[r]))return!1;return!0}if(ue(e)&&ue(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!oi(e[i],t[i]))return!1}return!0}return!1}function ue(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function Ur(e,t,r="replace"){if(!Oa(e))return null;try{let n=await import(e),i=n.default||n;if(typeof i!=="object"||i===null||Array.isArray(i))return null;try{return Nn(t,i,r)}catch{return null}}catch{return null}}function Pf(e,t,r=!1){if(!e)return t;let n=e.toUpperCase().replace(/-/g,"_"),i={...t};function s(a,o=[]){let c={...a};for(let[f,u]of Object.entries(a)){let l=[...o,f],g=(v)=>v.replace(/([A-Z])/g,"_$1").toUpperCase(),d=`${n}_${l.map(g).join("_")}`,$=`${n}_${l.map((v)=>v.toUpperCase()).join("_")}`;if(r)Ve.info(`Checking environment variable ${d} for config ${e}.${l.join(".")}`);if(typeof u==="object"&&u!==null&&!Array.isArray(u))c[f]=s(u,l);else{let v=hr.env[d]||hr.env[$];if(v!==void 0){if(r)Ve.info(`Using environment variable ${v?d:$} for config ${e}.${l.join(".")}`);if(typeof u==="number")c[f]=Number(v);else if(typeof u==="boolean")c[f]=v.toLowerCase()==="true";else if(Array.isArray(u))try{let C=JSON.parse(v);if(Array.isArray(C))c[f]=C;else c[f]=v.split(",").map((x)=>x.trim())}catch{c[f]=v.split(",").map((C)=>C.trim())}else c[f]=v}}}return c}return s(i)}async function kf({name:e="",alias:t,cwd:r,configDir:n,defaultConfig:i,verbose:s=!1,checkEnv:a=!0,arrayStrategy:o="replace"}){let c=a&&typeof i==="object"&&i!==null&&!Array.isArray(i)?Pf(e,i,s):i,f=r||hr.cwd(),u=[".ts",".js",".mjs",".cjs",".json"];if(s)Ve.info(`Loading configuration for "${e}"${t?` (alias: "${t}")`:""} from ${f}`);let l=[e,`.${e}`].filter(Boolean),g=[`${e}.config`,`.${e}.config`].filter(Boolean),d=t?[t,`.${t}`]:[],$=t?[`${t}.config`,`.${t}.config`]:[],v=Array.from(new Set([f,_e(f,"config"),_e(f,".config"),n?_e(f,n):void 0].filter(Boolean)));for(let C of v){if(s)Ve.info(`Searching for configuration in: ${C}`);let x=[_e(f,"config"),_e(f,".config")].concat(n?[_e(f,n)]:[]).includes(C)?[...l,...g,...d,...$]:[...g,...l,...$,...d];for(let P of x)for(let R of u){let I=_e(C,`${P}${R}`),B=await Ur(I,c,o);if(B!==null){if(s)Ve.success(`Configuration loaded from: ${I}`);return B}}}if(e){let C=_e(en(),".config",e),x=["config",`${e}.config`];if(t)x.push(`${t}.config`);if(s)Ve.info(`Checking user config directory: ${C}`);for(let P of x)for(let R of u){let I=_e(C,`${P}${R}`),B=await Ur(I,c,o);if(B!==null){if(s)Ve.success(`Configuration loaded from user config directory: ${I}`);return B}}}if(e){let C=_e(en(),".config"),x=[`.${e}.config`];if(t)x.push(`.${t}.config`);if(s)Ve.info(`Checking user config directory for dotfile configs: ${C}`);for(let P of x)for(let R of u){let I=_e(C,`${P}${R}`),B=await Ur(I,c,o);if(B!==null){if(s)Ve.success(`Configuration loaded from user config directory dotfile: ${I}`);return B}}}if(e){let C=en(),x=[`.${e}.config`,`.${e}`];if(t)x.push(`.${t}.config`),x.push(`.${t}`);if(s)Ve.info(`Checking user home directory for dotfile configs: ${C}`);for(let P of x)for(let R of u){let I=_e(C,`${P}${R}`),B=await Ur(I,c,o);if(B!==null){if(s)Ve.success(`Configuration loaded from user home directory: ${I}`);return B}}}try{let C=_e(f,"package.json");if(Oa(C)){let x=await import(C),P=x[e];if(!P&&t){if(P=x[t],P&&s)Ve.success(`Using alias "${t}" configuration from package.json`)}if(P&&typeof P==="object"&&!Array.isArray(P))try{if(s)Ve.success(`Configuration loaded from package.json: ${P===x[e]?e:t}`);return Nn(c,P,o)}catch(R){if(s)Ve.warn("Failed to merge package.json config:",R)}}}catch(C){if(s)Ve.warn("Failed to load package.json:",C)}if(s)Ve.info(`No configuration found for "${e}"${t?` or alias "${t}"`:""}, using default configuration with environment variables`);return c}function Mf(e,t={}){let r=ei.cwd();while(r.includes("storage"))r=Ys(r,"..");let n=Ys(r,e||"");if(t?.relative)return Fc(ei.cwd(),n);return n}async function If(){try{let e=await kf({name:"clarity",alias:"logging",defaultConfig:zr,cwd:ei.cwd()});return{...zr,...e||{}}}catch{return zr}}function Me(){if(gt.env.NODE_ENV==="test"||gt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Df(){if(gt.env.NODE_ENV==="test"||gt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof gt<"u"){let e=gt.type;if(e==="renderer"||e==="worker")return!1;return!!(gt.versions&&(gt.versions.node||gt.versions.bun))}return!1}class Fa{async format(e){let t=await Df(),r=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:r})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:Zt.pid,hostname:t(),environment:Zt.env.NODE_ENV||"development",platform:Zt.platform,version:Zt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:Zt.env.NODE_ENV||Zt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class li{name;fileLocks=new Map;currentKeyId=null;keys=new Map;fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(e,t={}){this.name=e,this.config={...bn},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new Fa,this.enabled=t.enabled??!0,this.fancy=t.fancy??!0,this.tagFormat=t.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=t.timestampPosition??"right",this.environment=t.environment??ce.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let r={...t},n=t.timestamp!==void 0;if(n)delete r.timestamp;if(this.config={...this.config,...r,timestamp:n||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),s=this.generateKey();this.currentKeyId=i,this.keys.set(i,s),this.encryptionKeys.set(i,{key:s,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let t={debug:0,info:1,success:2,warning:3,error:4},r=this.fingersCrossedConfig.activationLevel??"error";return t[e]>=t[r]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...Qr,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...Qr};return{...Qr,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:bn.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},r={...t,...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))};if(!r.level||!["debug","info","success","warning","error"].includes(r.level))r.level=t.level;return r}shouldWriteToFile(){return!Me()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let n,i=0,s=3,a=1000;while(i<s)try{try{try{await Zc(this.config.logDirectory,sa.F_OK|sa.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await qc(this.config.logDirectory,{recursive:!0,mode:493});else if(c.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw c;else throw c}}catch(c){throw console.error("Debug: [writeToFile] Failed to create log directory:",c),c}let o=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:ht.from(e);try{if(!Wr(this.currentLogFile))await ln(this.currentLogFile,"",{mode:420});if(n=na(this.currentLogFile,"a",420),Yc(n,o,{flag:"a"}),ia(n),n!==void 0)on(n),n=void 0;if((await Ut(this.currentLogFile)).size===0){if(await ln(this.currentLogFile,o,{flag:"w",mode:420}),(await Ut(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let f=c;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(i<s-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${i+1}/${s}:`,u);let l=a*2**i;await new Promise((g)=>setTimeout(g,l)),i++;continue}}if(f?.code&&["ENOSPC","EDQUOT"].includes(f.code))throw Error(`Disk quota exceeded or no space left on device: ${f.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",f),f}finally{if(n!==void 0)try{on(n)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(o){if(i===s-1){let f=o,u=typeof f.message==="string"?f.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",u),o}i++;let c=a*2**(i-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let r=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}finally{this.pendingOperations.splice(r,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return Yt(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return Yt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Yt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(Me())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let e=this.config.rotation.keyRotation;if(!e?.enabled)return;let t=typeof e.interval==="number"?e.interval:60,r=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((n)=>{console.error("Error rotating keys:",n)})},r)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),r=this.generateKey();this.currentKeyId=t,this.keys.set(t,r),this.encryptionKeys.set(t,{key:r,createdAt:new Date});let n=Array.from(this.encryptionKeys.entries()).sort(([,a],[,o])=>o.createdAt.getTime()-a.createdAt.getTime()),i=typeof e.maxKeys==="number"?e.maxKeys:1,s=Math.max(1,i);if(n.length>s)for(let[a]of n.slice(s))this.encryptionKeys.delete(a),this.keys.delete(a)}generateKeyId(){return an(16).toString("hex")}generateKey(){return an(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:t}=this.getCurrentKey(),r=an(16),n=Kc("aes-256-gcm",t,r),i=ht.isBuffer(e)?e:ht.from(e,"utf8"),s=n.update(i),a=n.final(),o=s.length+a.length,c=n.getAuthTag(),f=ht.allocUnsafe(16+o+16);return r.copy(f,0),s.copy(f,16),a.copy(f,16+s.length),c.copy(f,16+o),{encrypted:f,iv:r}}async compressData(e){return new Promise((t,r)=>{let n=oa(),i=[];n.on("data",(s)=>i.push(s)),n.on("end",()=>t(ht.from(ht.concat(i)))),n.on("error",r),n.write(e),n.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let t=this.config.rotation.encrypt;return{...e,...t}}return e}async rotateLog(){if(Me())return;if(!this.shouldWriteToFile())return;let e=await Ut(this.currentLogFile).catch(()=>null);if(!e)return;let t=this.config.rotation;if(typeof t==="boolean")return;if(t.maxSize&&e.size>=t.maxSize){let r=this.currentLogFile,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await Lr(this.config.logDirectory),s=i.filter((c)=>c.startsWith(this.name)&&/\.log\.\d+$/.test(c)).sort((c,f)=>{let u=Number.parseInt(c.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(f.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),a=s.length>0?Number.parseInt(s[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,o=`${r}.${a}`;if(await Ut(r).catch(()=>null))try{if(await aa(r,o),t.compress)try{let c=`${o}.gz`;await this.compressLogFile(o,c),await Gr(o)}catch(c){console.error("Error compressing rotated file:",c)}if(s.length===0&&!i.some((c)=>c.endsWith(".log.1")))try{let c=`${r}.1`;await ln(c,"")}catch(c){console.error("Error creating backup file:",c)}}catch(c){console.error(`Error during rotation: ${c instanceof Error?c.message:String(c)}`)}}else{let i=new Date().toISOString().replace(/[:.]/g,"-"),s=r.replace(/\.log$/,`-${i}.log`);if(await Ut(r).catch(()=>null))await aa(r,s)}if(this.currentLogFile=n,t.maxFiles){let i=(await Lr(this.config.logDirectory)).filter((s)=>s.startsWith(this.name)).sort((s,a)=>a.localeCompare(s));for(let s of i.slice(t.maxFiles))await Gr(Yt(this.config.logDirectory,s))}}}async compressLogFile(e,t){let r=ra(e),n=Uc(t),i=oa();await Qc(r,i,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let r of this.logBuffer){let n=await this.formatter.format(r);if(this.shouldWriteToFile())await this.writeToFile(n);console.log(n)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(t);console.log(t)}}shouldLog(e){if(!this.enabled)return!1;let t={debug:0,info:1,success:2,warning:3,error:4};return t[e]>=t[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((t)=>{console.error("Error in pending write operation:",t)});return Promise.resolve()})),Wr(this.currentLogFile))try{let e=na(this.currentLogFile,"r+");ia(e),on(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!Me()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await Lr(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await Gr(Yt(this.config.logDirectory,t))}catch(r){console.error(`Failed to delete temp file ${t}:`,r)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.shouldStyleConsole()?ee.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||Me())return!1;let e=typeof ce.env.NO_COLOR<"u",t=ce.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof ce.stderr<"u"&&ce.stderr.isTTY||typeof ce.stdout<"u"&&ce.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:r="",tag:n="",message:i,level:s,showTimestamp:a=!0}=e,o=(d)=>d.replace(this.ANSI_PATTERN,"");if(!this.fancy){let d=[];if(a)d.push(t);if(s==="warning")d.push("WARN");else if(s==="error")d.push("ERROR");else if(r)d.push(r.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)d.push(n.replace(/[[\]]/g,""));return d.push(i),d.join(" ")}let c=ce.stdout.columns||120,f="";if(s==="warning"||s==="error")f=`${r} ${i}`;else if(s==="info"||s==="success")f=`${r} ${n} ${i}`;else f=`${r} ${n} ${ee.cyan(i)}`;if(!a)return f.trim();let u=o(f).trim().length,l=o(t).length,g=Math.max(1,c-2-u-l);return`${f.trim()}${" ".repeat(g)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(s,a)=>{let o=Number.parseInt(a,10);return o<t[0].length?String(t[0][o]):s});let r=/%([sdijfo%])/g,n=0,i=e.replace(r,(s,a)=>{if(a==="%")return"%";if(n>=t.length)return s;let o=t[n++];switch(a){case"s":return String(o);case"d":case"i":return Number(o).toString();case"j":case"o":return JSON.stringify(o,null,2);default:return s}});if(n<t.length)i+=` ${t.slice(n).map((s)=>typeof s==="object"?JSON.stringify(s,null,2):String(s)).join(" ")}`;return i}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,n,i)=>{let s=ee.underline(ee.blue(n)),a=this.toAbsoluteFilePath(i);if(a&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let o=`file://${encodeURI(a)}`,c="\x1B]8;;",f="\x1B\\";return`\x1B]8;;${o}\x1B\\${s}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${i}\x1B\\${s}\x1B]8;;\x1B\\`;return s}),t=t.replace(/`([^`]+)`/g,(r,n)=>ee.bgGray(n)),t=t.replace(/\*\*([^*]+)\*\*/g,(r,n)=>ee.bold(n)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(r,n)=>ee.italic(n)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(r,n)=>ee.italic(n)),t=t.replace(/~([^~]+)~/g,(r,n)=>ee.strikethrough(n)),t}supportsHyperlinks(){if(Me())return!1;let e=ce.env;if(!e)return!1;if(e.TERM_PROGRAM==="iTerm.app"||e.TERM_PROGRAM==="vscode"||e.TERM_PROGRAM==="WezTerm")return!0;if(e.WT_SESSION)return!0;if(e.TERM==="xterm-kitty")return!0;let t=e.VTE_VERSION?Number.parseInt(e.VTE_VERSION,10):0;if(!Number.isNaN(t)&&t>=5000)return!0;return!1}toAbsoluteFilePath(e){try{let t=e;if(t.startsWith("file://"))t=t.replace(/^file:\/\//,"");if(t.startsWith("~")){let r=ce.env.HOME||"";if(r)t=t.replace(/^~(?=$|\/)/,r)}if(Xc(t)||t.startsWith("./")||t.startsWith("../"))t=zc(t);else return null;return Wr(t)?t:null}catch{return null}}buildOutputTexts(e){let t=this.shouldStyleConsole()?this.formatMarkdown(e):e,r=e.replace(this.ANSI_PATTERN,"");return{consoleText:t,fileText:r}}async log(e,t,...r){let n=new Date,i=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n),a,o;if(t instanceof Error)a=t.message,o=t.stack;else a=this.formatMessage(t,r);let{consoleText:c,fileText:f}=this.buildOutputTexts(a);if(this.shouldStyleConsole()){let l=this.options.showIcons===!1?"":Ka[e],g=this.options.showTags!==!1&&this.name?ee.gray(this.formatTag(this.name)):"",d;switch(e){case"debug":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:ee.gray(c),level:e}),console.error(d);break;case"info":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.warn(d);break;case"success":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:ee.green(c),level:e}),console.error(d);break;case"warning":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.warn(d);break;case"error":if(d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.error(d),o){let $=o.split(`
15
+ `);for(let v of $)if(v.trim()&&!v.includes(a))console.error(this.formatConsoleMessage({timestamp:i,message:ee.gray(` ${v}`),level:e,showTimestamp:!1}))}break}}else if(!Me()){if(console.error(`${s} ${this.environment}.${e.toUpperCase()}: ${a}`),o)console.error(o)}if(!this.shouldLog(e))return;let u=`${s} ${this.environment}.${e.toUpperCase()}: ${f}
16
16
  `;if(o)u+=`${o}
17
- `;if(u=u.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(u)}progress(e,t=""){let r={update:(i,s)=>{},finish:(i)=>{},interrupt:(i,s)=>{}};if(!this.enabled)return r;let n=30;if(this.activeProgressBar={total:Math.max(1,e||1),current:0,message:t||"",barLength:n,lastRenderedLine:""},this.shouldStyleConsole()&&!Oe()&&le.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(i,s)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,i),this.activeProgressBar.total),s!==void 0)this.activeProgressBar.message=s;if(this.shouldStyleConsole()&&!Oe()&&le.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(i)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,i)},interrupt:(i,s="info")=>{if(!Oe()&&le.stdout.isTTY)le.stdout.write(`
18
- `);if(this[s==="warning"?"warn":s](i),this.activeProgressBar&&this.shouldStyleConsole()&&!Oe()&&le.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let t=performance.now();if(this.shouldStyleConsole()){let r=this.options.showTags!==!1&&this.name?re.gray(this.formatTag(this.name)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:this.options.showIcons===!1?"":re.blue("\u25D0"),tag:r,message:`${re.cyan(e)}...`}))}return async(r)=>{if(!this.enabled)return;let n=performance.now(),i=Math.round(n-t),s=`${e} completed in ${i}ms`,a=new Date,o=this.formatConsoleTimestamp(a),c=`${this.formatFileTimestamp(a)} ${this.environment}.INFO: ${s}`;if(r)c+=` ${JSON.stringify(r)}`;if(c+=`
19
- `,c=c.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let f=this.options.showTags!==!1&&this.name?re.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:o,icon:this.options.showIcons===!1?"":re.green("\u2713"),tag:f,message:`${s}${r?` ${JSON.stringify(r)}`:""}`}))}else if(!Oe())console.error(c.trim());if(this.shouldWriteToFile())await this.writeToFile(c)}}async debug(e,...t){await this.log("debug",e,...t)}async info(e,...t){await this.log("info",e,...t)}async success(e,...t){await this.log("success",e,...t)}async warn(e,...t){await this.log("warning",e,...t)}async error(e,...t){await this.log("error",e,...t)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:t}=e;return!!t}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let t=`${this.name}:${e}`,r=new ai(t,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(r),r}createReadStream(){if(Oe())throw Error("createReadStream is not supported in browser environments");if(!Fr(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return Qs(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let t=this.config.rotation;if(!t.encrypt||typeof t.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let r=this.keys.get(this.currentKeyId);try{let n=ht.isBuffer(e)?e:ht.from(e,"base64"),i=n.subarray(0,16),s=n.subarray(n.length-16),a=n.subarray(16,n.length-16),o=Hc("aes-256-gcm",r,i);o.setAuthTag(s);let c=o.update(a),f=o.final(),u=c.length+f.length,l=ht.allocUnsafe(u);return c.copy(l,0),f.copy(l,c.length),l.toString("utf8")}catch(n){throw Error(`Decryption failed: ${n instanceof Error?n.message:String(n)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return Oe()}isServerMode(){return!Oe()}setTestEncryptionKey(e,t){this.currentKeyId=e,this.keys.set(e,t)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(e){if(!this.enabled)return;let t=new Date,r=this.formatConsoleTimestamp(t),n=this.formatFileTimestamp(t),{consoleText:i,fileText:s}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let o=i.split(`
20
- `),c=Math.max(...o.map((g)=>g.length))+2,f=`\u250C${"\u2500".repeat(c)}\u2510`,u=`\u2514${"\u2500".repeat(c)}\u2518`,l=o.map((g)=>{return this.formatConsoleMessage({timestamp:r,message:re.cyan(g),showTimestamp:!1})});console.error(this.formatConsoleMessage({timestamp:r,message:re.cyan(f),showTimestamp:!1})),l.forEach((g)=>console.error(g)),console.error(this.formatConsoleMessage({timestamp:r,message:re.cyan(u),showTimestamp:!1}))}else if(!Oe())console.error(`${n} ${this.environment}.INFO: [BOX] ${s}`);let a=`${n} ${this.environment}.INFO: [BOX] ${s}
21
- `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(a)}async prompt(e){if(Oe())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${re.cyan("?")} ${e} (y/n) `);let r=(n)=>{let i=n.toString().trim().toLowerCase();le.stdin.removeListener("data",r);try{if(typeof le.stdin.setRawMode==="function")le.stdin.setRawMode(!1)}catch{}le.stdin.pause(),console.error(""),t(i==="y"||i==="yes")};try{if(typeof le.stdin.setRawMode==="function")le.stdin.setRawMode(!0)}catch{}le.stdin.resume(),le.stdin.once("data",r)})}setFancy(e){this.fancy=e}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(e,...t){if(!this.enabled)return;let r=e;if(t&&t.length>0){let a=/%([sdijfo%])/g,o=0;if(r=e.replace(a,(c,f)=>{if(f==="%")return"%";if(o>=t.length)return c;let u=t[o++];switch(f){case"s":return String(u);case"d":case"i":return Number(u).toString();case"j":case"o":return JSON.stringify(u,null,2);default:return c}}),o<t.length)r+=` ${t.slice(o).map((c)=>typeof c==="object"?JSON.stringify(c,null,2):String(c)).join(" ")}`}let{consoleText:n,fileText:i}=this.buildOutputTexts(r);if(this.shouldStyleConsole()){let a=this.options.showTags!==!1&&this.name?re.gray(this.formatTag(this.name)):"",o=this.options.showIcons===!1?"":`${re.blue("\u25D0")} `;console.error(`${o}${a} ${re.cyan(n)}`)}let s=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${i}
22
- `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(s)}renderProgressBar(e,t=!1){if(!this.enabled||!this.shouldStyleConsole()||!le.stdout.isTTY)return;let r=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*r/100),i=e.barLength-n,s=re.green("\u2501".repeat(n)),a=re.gray("\u2501".repeat(i)),o=`[${s}${a}]`,c=`${r}%`.padStart(4),f=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":t||r===100?re.green("\u2713"):re.blue("\u25B6"),l=this.options.showTags!==!1&&this.name?` ${re.gray(this.formatTag(this.name))}`:"",g=`\r${u}${l} ${o} ${c}${f}`,d=le.stdout.columns||80,w=" ".repeat(Math.max(0,d-g.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${g}${w}`,le.stdout.write(e.lastRenderedLine),t)le.stdout.write(`
23
- `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||Oe()||!le.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(t)e.message=t;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(Oe()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await Nr(this.config.logDirectory),r=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let i=Yt(this.config.logDirectory,n);if(e.before)try{if((await Ut(i)).mtime>=e.before)continue}catch(s){console.error(`Failed to get stats for file ${i}:`,s);continue}r.push(i)}if(r.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${r.length} log file(s)...`);for(let n of r)try{await Lr(n),console.warn(`Deleted log file: ${n}`)}catch(i){console.error(`Failed to delete log file ${n}:`,i)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}async function Ia(e,t={}){let{maxRetries:r=3,retryDelay:n=1000,isRetryable:i=()=>!0,fallback:s}=t,a=Error("Unknown error occurred");for(let o=0;o<=r;o++)try{return await e()}catch(c){if(a=c instanceof Error?c:Error(String(c)),o===r||!i(a))break;if(n>0)await new Promise((f)=>setTimeout(f,n))}if(s!==void 0)return s;throw a instanceof Error?a:Error(`Unknown error: ${String(a)}`)}function Da(e){return e instanceof Ue}function Mf(e){return e instanceof oi}function If(e){if(Da(e))return e.code==="FILE_SYSTEM_ERROR"||e.code==="BROWSER_CONFIG_ERROR";return["ENOENT","EACCES","EMFILE","ENFILE","EBUSY","network","timeout","connection"].some((t)=>e.message.toLowerCase().includes(t.toLowerCase()))}class di{defaultParsers;constructor(){this.defaultParsers=[{name:"boolean",canParse:(e,t)=>t==="boolean"||["true","false","1","0","yes","no"].includes(e.toLowerCase()),parse:(e)=>{let t=e.toLowerCase();return["true","1","yes"].includes(t)}},{name:"number",canParse:(e,t)=>t==="number"||!Number.isNaN(Number(e))&&!Number.isNaN(Number.parseFloat(e)),parse:(e)=>{let t=Number(e);if(Number.isNaN(t))throw TypeError(`Cannot parse "${e}" as number`);return t}},{name:"array",canParse:(e,t)=>t==="array"||e.startsWith("[")||e.includes(","),parse:(e)=>{try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return e.split(",").map((t)=>t.trim())}},{name:"json",canParse:(e,t)=>t==="object"||(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")),parse:(e)=>{try{return JSON.parse(e)}catch(t){throw Error(`Cannot parse "${e}" as JSON: ${t}`)}}}]}async applyEnvironmentVariables(e,t,r={}){let{prefix:n,useCamelCase:i=!0,useBackwardCompatibility:s=!0,customParsers:a={},verbose:o=!1,trackPerformance:c=!0}=r,f=async()=>{if(!e)return{config:t,source:{type:"environment",priority:50,timestamp:new Date}};let u=n||this.generateEnvPrefix(e),l={...t};return this.processObject(l,[],u,{useCamelCase:i,useBackwardCompatibility:s,customParsers:a,verbose:o,configName:e}),{config:l,source:{type:"environment",priority:50,timestamp:new Date}}};if(c)return mr.track("applyEnvironmentVariables",f,{configName:e});return f()}generateEnvPrefix(e){return e.toUpperCase().replace(/-/g,"_")}formatEnvKey(e,t){if(!t)return e.toUpperCase();return e.replace(/([A-Z])/g,"_$1").toUpperCase()}processObject(e,t,r,n){for(let[i,s]of Object.entries(e)){let a=[...t,i],o=a.map((u)=>this.formatEnvKey(u,n.useCamelCase)),c=`${r}_${o.join("_")}`,f=n.useBackwardCompatibility?`${r}_${a.map((u)=>u.toUpperCase()).join("_")}`:null;if(n.verbose);if(typeof s==="object"&&s!==null&&!Array.isArray(s))this.processObject(s,a,r,n);else{let u=Wr.env[c]||(f?Wr.env[f]:void 0);if(u!==void 0){if(n.verbose){let l=Wr.env[c]?c:f}try{e[i]=this.parseEnvironmentValue(u,typeof s,c,n.customParsers,n.configName)}catch(l){if(l instanceof li)throw l;throw Rt.envVar(c,u,typeof s,n.configName)}}}}}parseEnvironmentValue(e,t,r,n,i){for(let[s,a]of Object.entries(n))try{return a(e)}catch{continue}for(let s of this.defaultParsers)if(s.canParse(e,t))try{return s.parse(e)}catch{throw Rt.envVar(r,e,`${t} (via ${s.name} parser)`,i)}return e}getEnvironmentVariables(e){let t={},r=e.toUpperCase();for(let[n,i]of Object.entries(Wr.env))if(n.startsWith(r)&&i!==void 0)t[n]=i;return t}validateEnvironmentVariable(e,t,r){let n=[];if(!/^[A-Z_][A-Z0-9_]*$/.test(e))n.push(`Environment variable key "${e}" should only contain uppercase letters, numbers, and underscores`);if(r)try{this.parseEnvironmentValue(e,t,r,{})}catch(i){n.push(`Cannot parse value "${t}" as ${r}: ${i}`)}return{isValid:n.length===0,errors:n}}generateEnvVarDocs(e,t,r={}){let{prefix:n,format:i="text"}=r,s=n||this.generateEnvPrefix(e),a=[];switch(this.extractEnvVarInfo(t,[],s,a),i){case"markdown":return this.formatAsMarkdown(a,e);case"json":return JSON.stringify(a,null,2);default:return this.formatAsText(a,e)}}extractEnvVarInfo(e,t,r,n){for(let[i,s]of Object.entries(e)){let a=[...t,i],o=`${r}_${a.map((c)=>this.formatEnvKey(c,!0)).join("_")}`;if(typeof s==="object"&&s!==null&&!Array.isArray(s))this.extractEnvVarInfo(s,a,r,n);else n.push({key:o,type:Array.isArray(s)?"array":typeof s,description:`Configuration for ${a.join(".")}`,example:this.generateExample(s)})}}generateExample(e){if(Array.isArray(e))return JSON.stringify(e);if(typeof e==="object"&&e!==null)return JSON.stringify(e);return String(e)}formatAsText(e,t){let r=`Environment Variables for ${t}:
17
+ `;if(u=u.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(u)}progress(e,t=""){let r={update:(i,s)=>{},finish:(i)=>{},interrupt:(i,s)=>{}};if(!this.enabled)return r;let n=30;if(this.activeProgressBar={total:Math.max(1,e||1),current:0,message:t||"",barLength:n,lastRenderedLine:""},this.shouldStyleConsole()&&!Me()&&ce.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(i,s)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,i),this.activeProgressBar.total),s!==void 0)this.activeProgressBar.message=s;if(this.shouldStyleConsole()&&!Me()&&ce.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(i)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,i)},interrupt:(i,s="info")=>{if(!Me()&&ce.stdout.isTTY)ce.stdout.write(`
18
+ `);if(this[s==="warning"?"warn":s](i),this.activeProgressBar&&this.shouldStyleConsole()&&!Me()&&ce.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let t=performance.now();if(this.shouldStyleConsole()){let r=this.options.showTags!==!1&&this.name?ee.gray(this.formatTag(this.name)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:this.options.showIcons===!1?"":ee.blue("\u25D0"),tag:r,message:`${ee.cyan(e)}...`}))}return async(r)=>{if(!this.enabled)return;let n=performance.now(),i=Math.round(n-t),s=`${e} completed in ${i}ms`,a=new Date,o=this.formatConsoleTimestamp(a),c=`${this.formatFileTimestamp(a)} ${this.environment}.INFO: ${s}`;if(r)c+=` ${JSON.stringify(r)}`;if(c+=`
19
+ `,c=c.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let f=this.options.showTags!==!1&&this.name?ee.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:o,icon:this.options.showIcons===!1?"":ee.green("\u2713"),tag:f,message:`${s}${r?` ${JSON.stringify(r)}`:""}`}))}else if(!Me())console.error(c.trim());if(this.shouldWriteToFile())await this.writeToFile(c)}}async debug(e,...t){await this.log("debug",e,...t)}async info(e,...t){await this.log("info",e,...t)}async success(e,...t){await this.log("success",e,...t)}async warn(e,...t){await this.log("warning",e,...t)}async error(e,...t){await this.log("error",e,...t)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:t}=e;return!!t}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let t=`${this.name}:${e}`,r=new li(t,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(r),r}createReadStream(){if(Me())throw Error("createReadStream is not supported in browser environments");if(!Wr(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return ra(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let t=this.config.rotation;if(!t.encrypt||typeof t.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let r=this.keys.get(this.currentKeyId);try{let n=ht.isBuffer(e)?e:ht.from(e,"base64"),i=n.subarray(0,16),s=n.subarray(n.length-16),a=n.subarray(16,n.length-16),o=Jc("aes-256-gcm",r,i);o.setAuthTag(s);let c=o.update(a),f=o.final(),u=c.length+f.length,l=ht.allocUnsafe(u);return c.copy(l,0),f.copy(l,c.length),l.toString("utf8")}catch(n){throw Error(`Decryption failed: ${n instanceof Error?n.message:String(n)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return Me()}isServerMode(){return!Me()}setTestEncryptionKey(e,t){this.currentKeyId=e,this.keys.set(e,t)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(e){if(!this.enabled)return;let t=new Date,r=this.formatConsoleTimestamp(t),n=this.formatFileTimestamp(t),{consoleText:i,fileText:s}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let o=i.split(`
20
+ `),c=Math.max(...o.map((g)=>g.length))+2,f=`\u250C${"\u2500".repeat(c)}\u2510`,u=`\u2514${"\u2500".repeat(c)}\u2518`,l=o.map((g)=>{return this.formatConsoleMessage({timestamp:r,message:ee.cyan(g),showTimestamp:!1})});console.error(this.formatConsoleMessage({timestamp:r,message:ee.cyan(f),showTimestamp:!1})),l.forEach((g)=>console.error(g)),console.error(this.formatConsoleMessage({timestamp:r,message:ee.cyan(u),showTimestamp:!1}))}else if(!Me())console.error(`${n} ${this.environment}.INFO: [BOX] ${s}`);let a=`${n} ${this.environment}.INFO: [BOX] ${s}
21
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(a)}async prompt(e){if(Me())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${ee.cyan("?")} ${e} (y/n) `);let r=(n)=>{let i=n.toString().trim().toLowerCase();ce.stdin.removeListener("data",r);try{if(typeof ce.stdin.setRawMode==="function")ce.stdin.setRawMode(!1)}catch{}ce.stdin.pause(),console.error(""),t(i==="y"||i==="yes")};try{if(typeof ce.stdin.setRawMode==="function")ce.stdin.setRawMode(!0)}catch{}ce.stdin.resume(),ce.stdin.once("data",r)})}setFancy(e){this.fancy=e}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(e,...t){if(!this.enabled)return;let r=e;if(t&&t.length>0){let a=/%([sdijfo%])/g,o=0;if(r=e.replace(a,(c,f)=>{if(f==="%")return"%";if(o>=t.length)return c;let u=t[o++];switch(f){case"s":return String(u);case"d":case"i":return Number(u).toString();case"j":case"o":return JSON.stringify(u,null,2);default:return c}}),o<t.length)r+=` ${t.slice(o).map((c)=>typeof c==="object"?JSON.stringify(c,null,2):String(c)).join(" ")}`}let{consoleText:n,fileText:i}=this.buildOutputTexts(r);if(this.shouldStyleConsole()){let a=this.options.showTags!==!1&&this.name?ee.gray(this.formatTag(this.name)):"",o=this.options.showIcons===!1?"":`${ee.blue("\u25D0")} `;console.error(`${o}${a} ${ee.cyan(n)}`)}let s=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${i}
22
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(s)}renderProgressBar(e,t=!1){if(!this.enabled||!this.shouldStyleConsole()||!ce.stdout.isTTY)return;let r=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*r/100),i=e.barLength-n,s=ee.green("\u2501".repeat(n)),a=ee.gray("\u2501".repeat(i)),o=`[${s}${a}]`,c=`${r}%`.padStart(4),f=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":t||r===100?ee.green("\u2713"):ee.blue("\u25B6"),l=this.options.showTags!==!1&&this.name?` ${ee.gray(this.formatTag(this.name))}`:"",g=`\r${u}${l} ${o} ${c}${f}`,d=ce.stdout.columns||80,$=" ".repeat(Math.max(0,d-g.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${g}${$}`,ce.stdout.write(e.lastRenderedLine),t)ce.stdout.write(`
23
+ `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||Me()||!ce.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(t)e.message=t;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(Me()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await Lr(this.config.logDirectory),r=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let i=Yt(this.config.logDirectory,n);if(e.before)try{if((await Ut(i)).mtime>=e.before)continue}catch(s){console.error(`Failed to get stats for file ${i}:`,s);continue}r.push(i)}if(r.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${r.length} log file(s)...`);for(let n of r)try{await Gr(n),console.warn(`Deleted log file: ${n}`)}catch(i){console.error(`Failed to delete log file ${n}:`,i)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}async function Na(e,t={}){let{maxRetries:r=3,retryDelay:n=1000,isRetryable:i=()=>!0,fallback:s}=t,a=Error("Unknown error occurred");for(let o=0;o<=r;o++)try{return await e()}catch(c){if(a=c instanceof Error?c:Error(String(c)),o===r||!i(a))break;if(n>0)await new Promise((f)=>setTimeout(f,n))}if(s!==void 0)return s;throw a instanceof Error?a:Error(`Unknown error: ${String(a)}`)}function Wa(e){return e instanceof Ye}function Ff(e){return e instanceof ci}function Nf(e){if(Wa(e))return e.code==="FILE_SYSTEM_ERROR"||e.code==="BROWSER_CONFIG_ERROR";return["ENOENT","EACCES","EMFILE","ENFILE","EBUSY","network","timeout","connection"].some((t)=>e.message.toLowerCase().includes(t.toLowerCase()))}class pi{defaultParsers;constructor(){this.defaultParsers=[{name:"boolean",canParse:(e,t)=>t==="boolean"||["true","false","1","0","yes","no"].includes(e.toLowerCase()),parse:(e)=>{let t=e.toLowerCase();return["true","1","yes"].includes(t)}},{name:"number",canParse:(e,t)=>t==="number"||!Number.isNaN(Number(e))&&!Number.isNaN(Number.parseFloat(e)),parse:(e)=>{let t=Number(e);if(Number.isNaN(t))throw TypeError(`Cannot parse "${e}" as number`);return t}},{name:"array",canParse:(e,t)=>t==="array"||e.startsWith("[")||e.includes(","),parse:(e)=>{try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return e.split(",").map((t)=>t.trim())}},{name:"json",canParse:(e,t)=>t==="object"||(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")),parse:(e)=>{try{return JSON.parse(e)}catch(t){throw Error(`Cannot parse "${e}" as JSON: ${t}`)}}}]}async applyEnvironmentVariables(e,t,r={}){let{prefix:n,useCamelCase:i=!0,useBackwardCompatibility:s=!0,customParsers:a={},verbose:o=!1,trackPerformance:c=!0}=r,f=async()=>{if(!e)return{config:t,source:{type:"environment",priority:50,timestamp:new Date}};let u=n||this.generateEnvPrefix(e),l={...t};return this.processObject(l,[],u,{useCamelCase:i,useBackwardCompatibility:s,customParsers:a,verbose:o,configName:e}),{config:l,source:{type:"environment",priority:50,timestamp:new Date}}};if(c)return pr.track("applyEnvironmentVariables",f,{configName:e});return f()}generateEnvPrefix(e){return e.toUpperCase().replace(/-/g,"_")}formatEnvKey(e,t){if(!t)return e.toUpperCase();return e.replace(/([A-Z])/g,"_$1").toUpperCase()}processObject(e,t,r,n){for(let[i,s]of Object.entries(e)){let a=[...t,i],o=a.map((u)=>this.formatEnvKey(u,n.useCamelCase)),c=`${r}_${o.join("_")}`,f=n.useBackwardCompatibility?`${r}_${a.map((u)=>u.toUpperCase()).join("_")}`:null;if(n.verbose);if(typeof s==="object"&&s!==null&&!Array.isArray(s))this.processObject(s,a,r,n);else{let u=Br.env[c]||(f?Br.env[f]:void 0);if(u!==void 0){if(n.verbose){let l=Br.env[c]?c:f}try{e[i]=this.parseEnvironmentValue(u,typeof s,c,n.customParsers,n.configName)}catch(l){if(l instanceof fi)throw l;throw xt.envVar(c,u,typeof s,n.configName)}}}}}parseEnvironmentValue(e,t,r,n,i){for(let[s,a]of Object.entries(n))try{return a(e)}catch{continue}for(let s of this.defaultParsers)if(s.canParse(e,t))try{return s.parse(e)}catch{throw xt.envVar(r,e,`${t} (via ${s.name} parser)`,i)}return e}getEnvironmentVariables(e){let t={},r=e.toUpperCase();for(let[n,i]of Object.entries(Br.env))if(n.startsWith(r)&&i!==void 0)t[n]=i;return t}validateEnvironmentVariable(e,t,r){let n=[];if(!/^[A-Z_][A-Z0-9_]*$/.test(e))n.push(`Environment variable key "${e}" should only contain uppercase letters, numbers, and underscores`);if(r)try{this.parseEnvironmentValue(e,t,r,{})}catch(i){n.push(`Cannot parse value "${t}" as ${r}: ${i}`)}return{isValid:n.length===0,errors:n}}generateEnvVarDocs(e,t,r={}){let{prefix:n,format:i="text"}=r,s=n||this.generateEnvPrefix(e),a=[];switch(this.extractEnvVarInfo(t,[],s,a),i){case"markdown":return this.formatAsMarkdown(a,e);case"json":return JSON.stringify(a,null,2);default:return this.formatAsText(a,e)}}extractEnvVarInfo(e,t,r,n){for(let[i,s]of Object.entries(e)){let a=[...t,i],o=`${r}_${a.map((c)=>this.formatEnvKey(c,!0)).join("_")}`;if(typeof s==="object"&&s!==null&&!Array.isArray(s))this.extractEnvVarInfo(s,a,r,n);else n.push({key:o,type:Array.isArray(s)?"array":typeof s,description:`Configuration for ${a.join(".")}`,example:this.generateExample(s)})}}generateExample(e){if(Array.isArray(e))return JSON.stringify(e);if(typeof e==="object"&&e!==null)return JSON.stringify(e);return String(e)}formatAsText(e,t){let r=`Environment Variables for ${t}:
24
24
 
25
25
  `;for(let n of e)r+=`${n.key}
26
26
  `,r+=` Type: ${n.type}
@@ -32,25 +32,25 @@ ${kr}/
32
32
  `;r+=`| Variable | Type | Description | Example |
33
33
  `,r+=`|----------|------|-------------|----------|
34
34
  `;for(let n of e)r+=`| \`${n.key}\` | ${n.type} | ${n.description} | \`${n.example}\` |
35
- `;return r}}function Df(e,t){let r=Ga("process");if(typeof r>"u"||!r.env)return t;let n=r.env[e];return n!==void 0?n:t}function Fa(e,t,r={}){return Na(e,t,r,new WeakMap)}function Na(e,t,r,n){let{arrayMergeMode:i="replace",skipNullish:s=!1,customMerger:a}=r;if(t===null||t===void 0)return s?e:t;if(a){let o=a(e,t);if(o!==void 0)return o}if(Array.isArray(t)||Array.isArray(e))return La(e,t,i,n);if(!Xe(t)||!Xe(e))return t;return Wf(e,t,r,n)}function La(e,t,r,n){if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(e)&&!Array.isArray(t))return t;if(Array.isArray(t)&&Array.isArray(e))switch(r){case"replace":return t;case"concat":return Ff(e,t);case"smart":return Nf(e,t,n);default:return t}return t}function Ff(e,t){let r=[...t];for(let n of e)if(!r.some((i)=>$n(i,n)))r.push(n);return r}function Nf(e,t,r){if(t.length===0)return e;if(e.length===0)return t;if(Xe(t[0])&&Xe(e[0]))return Lf(e,t,r);if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}function Lf(e,t,r){let n=[...t];for(let i of e){if(!Xe(i)){n.push(i);continue}let s=["id","name","key","path","type"],a=!1;for(let o of s)if(o in i){if(n.find((c)=>Xe(c)&&(o in c)&&c[o]===i[o])){a=!0;break}}if(!a)n.push(i)}return n}function Wf(e,t,r,n){let i=t;if(Xe(i)&&n.has(i))return n.get(i);let s={...e};if(Xe(i))n.set(i,s);for(let a in i){if(!Object.prototype.hasOwnProperty.call(i,a))continue;let o=i[a],c=s[a];if(r.skipNullish&&(o===null||o===void 0))continue;if(o===null||o===void 0){s[a]=o;continue}if(Xe(o)&&Xe(c))s[a]=Na(c,o,r,n);else if(Array.isArray(o)||Array.isArray(c))s[a]=La(c,o,r.arrayMergeMode||"smart",n);else s[a]=o}return s}function Fn(e,t,r="replace"){return Fa(e,t,{arrayMergeMode:r==="replace"?"replace":"smart",skipNullish:!0})}function $n(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!$n(e[r],t[r]))return!1;return!0}if(Xe(e)&&Xe(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!$n(e[i],t[i]))return!1}return!0}return!1}function Xe(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class mi{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(e,t,r={}){let{arrayStrategy:n="replace",useCache:i=!0,cacheTtl:s,trackPerformance:a=!0,verbose:o=!1}=r;if(i){let f=Qt.getWithFileCheck("file",e);if(f){if(o)console.log(`Configuration loaded from cache: ${e}`);return f}}let c=async()=>{if(!Gr(e))return null;try{let f=`?t=${Date.now()}`,u=await import(e+f),l=u.default||u,g="default"in u,d=Object.keys(u).length>0;if(!g&&!d)throw new hr(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof l!=="object"||l===null||Array.isArray(l))throw new hr(e,Error("Configuration must export a valid object"),"unknown");let w={config:Fn(t,l,n),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(i)Qt.setWithFileCheck("file",w,e,s);return w}catch(f){throw f instanceof Error?Rt.configLoad(e,f):Rt.configLoad(e,Error(String(f)))}};if(a)return mr.track("loadFromPath",c,{path:e});return c()}async tryLoadFromPaths(e,t,r={}){for(let n of e)try{let i=await this.loadFromPath(n,t,r);if(i)return i}catch(i){if(i instanceof Error&&i.name==="ConfigLoadError")throw i;if(r.verbose)console.warn(`Failed to load config from ${n}:`,i)}return null}generateConfigPaths(e,t,r){let n=this.generateNamePatterns(e,r),i=[];for(let s of n)for(let a of this.extensions)i.push(on(t,`${s}${a}`));return i}generateNamePatterns(e,t){let r=[];if(r.push("config",".config"),e)r.push(e,`.${e}.config`,`${e}.config`,`.${e}`);if(t){if(r.push(t,`.${t}.config`,`${t}.config`,`.${t}`),e)r.push(`${e}.${t}.config`,`.${e}.${t}.config`)}return r.filter(Boolean)}checkFileAccess(e){return Ia(async()=>{return Gr(e)},{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,r){let n=[];if(!Gr(e))return n;if(t||r){let i=this.generateNamePatterns(t||"",r);for(let s of i)for(let a of this.extensions){let o=on(e,`${s}${a}`);if(await this.checkFileAccess(o))n.push(o)}}else try{let{readdirSync:i}=await import("fs"),s=i(e);for(let a of s)if(this.looksLikeConfigFile(a)){let o=on(e,a);if(await this.checkFileAccess(o))n.push(o)}}catch{return[]}return n}looksLikeConfigFile(e){return[/\.config\.(ts|js|mjs|cjs|json|mts|cts)$/,/^\..*\.(ts|js|mjs|cjs|json|mts|cts)$/,/config\.(ts|js|mjs|cjs|json|mts|cts)$/].some((t)=>t.test(e))}async validateConfigFile(e){let t=[];try{if(!Gr(e))return t.push("Configuration file does not exist"),t;let r=await import(e),n=r.default||r;if(n===void 0)t.push("Configuration file must export a default value or named exports");else if(typeof n!=="object"||n===null)t.push("Configuration must be an object");else if(Array.isArray(n))t.push("Configuration cannot be an array at the root level");if(e.endsWith(".json"))try{let{readFileSync:i}=await import("fs"),s=i(e,"utf8");JSON.parse(s)}catch(i){t.push(`Invalid JSON syntax: ${i}`)}}catch(r){t.push(`Failed to load configuration file: ${r}`)}return t}async getFileModificationTime(e){try{let{statSync:t}=await import("fs");return t(e).mtime}catch{return null}}async preloadConfigurations(e,t={}){let r=new Map;return await Promise.allSettled(e.map(async(n)=>{try{let i=await this.loadFromPath(n,{},t);if(i)r.set(n,i.config)}catch(i){if(t.verbose)console.warn(`Failed to preload ${n}:`,i)}})),r}}class Nn{async validateConfiguration(e,t,r={}){let{stopOnFirstError:n=!1,validateRequired:i=!0,validateTypes:s=!0,customRules:a=[],trackPerformance:o=!0,verbose:c=!1}=r,f=async()=>{let u=[],l=[],g={stopOnFirstError:n,validateRequired:i,validateTypes:s,customRules:a,trackPerformance:o,verbose:c};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,g);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...a],g);else return this.validateWithJSONSchema(e,t,g)}catch(d){return u.push({path:"",message:`Validation failed: ${d}`,rule:"system"}),{isValid:!1,errors:u,warnings:l}}};if(o)return await mr.track("validateConfiguration",f);return f()}async validateWithSchemaFile(e,t,r){try{if(!Xc(t))throw new dr(t,[{path:"",message:"Schema file does not exist"}]);let n=await import(t),i=n.default||n;if(Array.isArray(i))return this.validateWithRules(e,i,r);else return this.validateWithJSONSchema(e,i,r)}catch(n){throw new dr(t,[{path:"",message:`Failed to load schema: ${n}`}])}}validateWithJSONSchema(e,t,r){let n=[],i=[];return this.validateObjectAgainstSchema(e,t,"",n,i,r),{isValid:n.length===0,errors:n,warnings:i}}validateObjectAgainstSchema(e,t,r,n,i,s){if(s.validateTypes&&t.type){let a=Array.isArray(e)?"array":typeof e,o=Array.isArray(t.type)?t.type:[t.type];if(!o.includes(a)){if(n.push({path:r,message:`Expected type ${o.join(" or ")}, got ${a}`,expected:o.join(" or "),actual:a,rule:"type"}),s.stopOnFirstError)return}}if(t.enum&&!t.enum.includes(e)){if(n.push({path:r,message:`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"}),s.stopOnFirstError)return}if(typeof e==="string"){if(t.minLength!==void 0&&e.length<t.minLength)n.push({path:r,message:`String length must be at least ${t.minLength}`,expected:`>= ${t.minLength}`,actual:e.length,rule:"minLength"});if(t.maxLength!==void 0&&e.length>t.maxLength)n.push({path:r,message:`String length must not exceed ${t.maxLength}`,expected:`<= ${t.maxLength}`,actual:e.length,rule:"maxLength"});if(t.pattern){if(!new RegExp(t.pattern).test(e))n.push({path:r,message:`String does not match pattern ${t.pattern}`,expected:t.pattern,actual:e,rule:"pattern"})}}if(typeof e==="number"){if(t.minimum!==void 0&&e<t.minimum)n.push({path:r,message:`Value must be at least ${t.minimum}`,expected:`>= ${t.minimum}`,actual:e,rule:"minimum"});if(t.maximum!==void 0&&e>t.maximum)n.push({path:r,message:`Value must not exceed ${t.maximum}`,expected:`<= ${t.maximum}`,actual:e,rule:"maximum"})}if(Array.isArray(e)&&t.items)for(let a=0;a<e.length;a++){let o=r?`${r}[${a}]`:`[${a}]`;if(this.validateObjectAgainstSchema(e[a],t.items,o,n,i,s),s.stopOnFirstError&&n.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let a=e;if(s.validateRequired&&t.required){for(let o of t.required)if(!(o in a)){if(n.push({path:r?`${r}.${o}`:o,message:`Missing required property '${o}'`,expected:"required",rule:"required"}),s.stopOnFirstError)return}}if(t.properties){for(let[o,c]of Object.entries(t.properties))if(o in a){let f=r?`${r}.${o}`:o;if(this.validateObjectAgainstSchema(a[o],c,f,n,i,s),s.stopOnFirstError&&n.length>0)return}}if(t.additionalProperties===!1){let o=new Set(Object.keys(t.properties||{}));for(let c of Object.keys(a))if(!o.has(c))i.push({path:r?`${r}.${c}`:c,message:`Additional property '${c}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,r){let n=[],i=[];for(let s of t)try{let a=this.getValueByPath(e,s.path),o=this.validateWithRule(a,s,s.path);if(n.push(...o),r.stopOnFirstError&&n.length>0)break}catch(a){n.push({path:s.path,message:`Rule validation failed: ${a}`,rule:"system"})}return{isValid:n.length===0,errors:n,warnings:i}}validateWithRule(e,t,r){let n=[];if(t.required&&(e===void 0||e===null))return n.push({path:r,message:t.message||`Property '${r}' is required`,expected:"required",rule:"required"}),n;if(e===void 0||e===null)return n;if(t.type){let i=Array.isArray(e)?"array":typeof e;if(i!==t.type)n.push({path:r,message:t.message||`Expected type ${t.type}, got ${i}`,expected:t.type,actual:i,rule:"type"})}if(t.min!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i<t.min)n.push({path:r,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:i,rule:"min"})}if(t.max!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i>t.max)n.push({path:r,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:i,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))n.push({path:r,message:t.message||`Value does not match pattern ${t.pattern}`,expected:t.pattern.toString(),actual:e,rule:"pattern"})}if(t.enum&&!t.enum.includes(e))n.push({path:r,message:t.message||`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"});if(t.validator){let i=t.validator(e);if(i)n.push({path:r,message:t.message||i,rule:"custom"})}return n}getValueByPath(e,t){if(!t)return e;let r=t.split("."),n=e;for(let i of r)if(n&&typeof n==="object"&&i in n)n=n[i];else return;return n}generateRulesFromInterface(e){let t=[],r=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let n of r){let[,i,s,a]=n;t.push({path:i,required:!s,type:this.mapTypeScriptType(a)})}return t}mapTypeScriptType(e){switch(e.toLowerCase()){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"object";default:return"object"}}static createCommonRules(){return{server:[{path:"port",required:!0,type:"number",min:1,max:65535},{path:"host",required:!0,type:"string",min:1},{path:"ssl",type:"boolean"}],database:[{path:"url",required:!0,type:"string",min:1},{path:"pool",type:"number",min:1,max:100},{path:"timeout",type:"number",min:0}],api:[{path:"baseUrl",required:!0,type:"string",pattern:ja},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}class Ln{fileLoader=new mi;envProcessor=new di;validator=new Nn;async loadConfig(e){let t=Date.now(),{cache:r,performance:n,schema:i,validate:s,...a}=e;try{if(r?.enabled){let c=this.checkCache(a.name||"",a);if(c)return c}let o;try{o=await this.loadConfigurationStrategies(a,!0,r)}catch(c){let f=a.__strictErrorHandling;if(c instanceof Error&&c.name==="ConfigNotFoundError"){if(f)throw c;o={...await this.applyEnvironmentVariables(a.name||"",a.defaultConfig,a.checkEnv!==!1,a.verbose||!1),warnings:[`No configuration file found for "${a.name||"config"}", using defaults with environment variables`]}}else if(c instanceof Error&&c.name==="ConfigLoadError"){let u=c.message.includes("EACCES")||c.message.includes("EPERM")||c.message.includes("permission denied"),l=!u&&(c.message.includes("syntax")||c.message.includes("Expected")||c.message.includes("Unexpected")||c.message.includes("BuildMessage")||c.message.includes("errors building")),g=c.message.includes("Configuration must export a valid object")||c.message.includes("Configuration file is empty and exports nothing");if(f&&(g||u))throw c;if(l&&(!f||!g))o={...await this.applyEnvironmentVariables(a.name||"",a.defaultConfig,a.checkEnv!==!1,a.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!f)o={...await this.applyEnvironmentVariables(a.name||"",a.defaultConfig,a.checkEnv!==!1,a.verbose||!1),warnings:[`Configuration loading error, using defaults: ${c.message}`]};else throw c}else o={...await this.applyEnvironmentVariables(a.name||"",a.defaultConfig,a.checkEnv!==!1,a.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${c instanceof Error?c.message:String(c)}`]}}if(i||s)await this.validateConfiguration(o.config,i,s,a.name);if(r?.enabled&&o)this.cacheResult(a.name||"",o,r,a);if(n?.enabled){let c={operation:"loadConfig",duration:Date.now()-t,configName:a.name,timestamp:new Date};if(n.onMetrics)n.onMetrics(c);if(n.slowThreshold&&c.duration>n.slowThreshold)st.warn(`Slow configuration loading detected: ${c.duration}ms for ${a.name}`);o.metrics=c}return o}catch(o){let c=Date.now()-t;throw st.error(`Configuration loading failed after ${c}ms:`,[o instanceof Error?o:Error(String(o))]),o}}async loadConfigurationStrategies(e,t=!1,r){let{name:n="",alias:i,cwd:s,configDir:a,defaultConfig:o,checkEnv:c=!0,arrayStrategy:f="replace",verbose:u=!1}=e,l=s||kt.cwd(),g=[],d=await this.loadLocalConfiguration(n,i,l,a,o,f,u,c,r);if(d)return g.push(...this.getLocalSearchPaths(n,i,l,a)),this.finalizeResult(d,g,c,n,u);let w=await this.loadHomeConfiguration(n,i,o,f,u,c);if(w)return g.push(...this.getHomeSearchPaths(n,i)),this.finalizeResult(w,g,c,n,u);let E=await this.loadPackageJsonConfiguration(n,i,l,o,f,u,c);if(E)return g.push(He(l,"package.json")),this.finalizeResult(E,g,c,n,u);if(g.push(...this.getAllSearchPaths(n,i,l,a)),t)throw Rt.configNotFound(n,g,i);return{...await this.applyEnvironmentVariables(n,o,c,u),warnings:[`No configuration file found for "${n}"${i?` or alias "${i}"`:""}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,r,n,i,s,a,o,c){let f=o?fr(e,i,a):i,u=this.getLocalDirectories(r,n);for(let l of u){if(a)st.info(`Searching for configuration in: ${l}`);let g=this.fileLoader.generateConfigPaths(e,l,t),d=await this.fileLoader.tryLoadFromPaths(g,f,{arrayStrategy:s,verbose:a,cacheTtl:c?.ttl,useCache:!c?.ttl||c.ttl>100});if(d){if(a)st.success(`Configuration loaded from: ${d.source.path}`);return d}}return null}async loadHomeConfiguration(e,t,r,n,i,s){if(!e)return null;let a=s?fr(e,r,i):r,o=[He(Ht(),".config",e),He(Ht(),".config"),Ht()];for(let c of o){if(i)st.info(`Checking home directory: ${c}`);let f=this.fileLoader.generateConfigPaths(e,c,t),u=await this.fileLoader.tryLoadFromPaths(f,a,{arrayStrategy:n,verbose:i});if(u){if(i)st.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,t,r,n,i,s,a){let o=a?fr(e,n,s):n;try{let c=He(r,"package.json");if(!Cn(c))return null;let f=await import(c),u=f[e],l=e;if(!u&&t)u=f[t],l=t;if(u&&typeof u==="object"&&!Array.isArray(u)){if(s)st.success(`Configuration loaded from package.json: ${l}`);return{config:Fn(o,u,i),source:{type:"package.json",path:c,priority:30,timestamp:new Date}}}}catch(c){if(s)st.warn("Failed to load package.json:",[c instanceof Error?c:Error(String(c))])}return null}async applyEnvironmentVariables(e,t,r,n){if(!r||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:fr(e,t,n),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,r,n,i){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,r,n){let i=[];if(r){let s=r(e);if(s)i.push(...s)}if(t){let s=await this.validator.validateConfiguration(e,t);if(!s.isValid)i.push(...s.errors.map((a)=>a.path?`${a.path}: ${a.message}`:a.message))}if(i.length>0)throw Rt.configValidation(n||"unknown",i,n)}checkCache(e,t){let r=this.generateCacheKey(e,t);return Qt.get(r)||null}cacheResult(e,t,r,n){let i=this.generateCacheKey(e,n);Qt.set(i,t,void 0,r.ttl)}generateCacheKey(e,t){let r=[e];if(t.alias)r.push(`alias:${t.alias}`);if(t.cwd)r.push(`cwd:${t.cwd}`);if(t.configDir)r.push(`configDir:${t.configDir}`);if("checkEnv"in t)r.push(`checkEnv:${t.checkEnv}`);return r.join("|")}getLocalDirectories(e,t){return Array.from(new Set([e,He(e,"config"),He(e,".config"),t?He(e,t):void 0].filter(Boolean)))}getAllSearchPaths(e,t,r,n){let i=[];return i.push(...this.getLocalSearchPaths(e,t,r,n)),i.push(...this.getHomeSearchPaths(e,t)),i.push(He(r,"package.json")),i}getLocalSearchPaths(e,t,r,n){let i=this.getLocalDirectories(r,n),s=[];for(let a of i)s.push(...this.fileLoader.generateConfigPaths(e,a,t));return s}getHomeSearchPaths(e,t){if(!e)return[];let r=[He(Ht(),".config",e),He(Ht(),".config"),Ht()],n=[];for(let i of r)n.push(...this.fileLoader.generateConfigPaths(e,i,t));return n}async loadConfigWithResult(e){return this.loadConfig(e)}}function da(e){let t=!(e.message.includes("EACCES")||e.message.includes("EPERM")||e.message.includes("permission denied"))&&(e.message.includes("syntax")||e.message.includes("Expected")||e.message.includes("Unexpected")||e.message.includes("BuildMessage")),r=e.message.includes("Configuration must export a valid object")||e.message.includes("Configuration file is empty and exports nothing");return t||r}async function Gf(e){return Ct.loadConfig({...e,__strictErrorHandling:!0})}async function Wa(e){let t="defaultConfig"in e&&e.defaultConfig!==void 0?e.defaultConfig:{},r="cache"in e||"performance"in e||"schema"in e||"validate"in e;try{let n;if(r)n=await Ct.loadConfig(e);else n=await Ct.loadConfig({...e,defaultConfig:t,cache:{enabled:!0},performance:{enabled:!1}});return n?.config??t}catch(n){let i=n instanceof Error?n.name:"UnknownError",s=n instanceof Error?n.message:String(n);if(!(i==="ConfigNotFoundError"||i==="ConfigLoadError"||i==="ConfigValidationError"||s.includes("config"))&&e.verbose)st.warn("Unexpected error loading config, using defaults:",[n instanceof Error?n:Error(String(n))]);let a=r?{...e,defaultConfig:t}:{...e,defaultConfig:t,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in e?e.checkEnv!==!1:!0)return(await Ct.applyEnvironmentVariables(a.name||"",t,!0,a.verbose||!1))?.config??t;return t}}async function Bf(e={defaultConfig:{}}){if(typeof e==="string"){let{cwd:t}=await import("process");try{return(await Ct.loadConfig({name:e,cwd:t(),generatedDir:"./generated",configDir:"./config",defaultConfig:{},checkEnv:!0,arrayStrategy:"replace"})).config}catch(r){if(r instanceof Error&&(r.name==="ConfigNotFoundError"||r.name==="ConfigLoadError"&&da(r)))return(await Ct.applyEnvironmentVariables(e,{},!0,!1)).config;throw r}}try{return(await Ct.loadConfig({...e,cwd:e.cwd||kt.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(t){if(t instanceof Error&&(t.name==="ConfigNotFoundError"||t.name==="ConfigLoadError"&&da(t)))return(await Ct.applyEnvironmentVariables(e.name||"",e.defaultConfig||{},e.checkEnv!==!1,e.verbose||!1)).config;throw t}}async function Vf(e,t,r="replace"){let n=new mi;try{let i=await n.loadFromPath(e,t,{arrayStrategy:r,useCache:!1,trackPerformance:!1});return i?i.config:null}catch{return null}}function fr(e,t,r=!1){let n=new di,i=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function s(a,o=[]){let c={...a};for(let[f,u]of Object.entries(a)){let l=[...o,f],g=[`${i}_${l.join("_").toUpperCase()}`,`${i}_${l.map((E)=>E.toUpperCase()).join("")}`,`${i}_${l.map((E)=>E.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],d,w;for(let E of g)if(d=kt.env[E],d!==void 0){w=E;break}if(d!==void 0&&w)if(typeof u==="boolean")c[f]=["true","1","yes"].includes(d.toLowerCase());else if(typeof u==="number"){let E=Number(d);if(!Number.isNaN(E))c[f]=E}else if(Array.isArray(u))try{c[f]=JSON.parse(d)}catch{c[f]=d.split(",").map((E)=>E.trim())}else c[f]=d;else if(u&&typeof u==="object"&&!Array.isArray(u))c[f]=s(u,l)}return c}return s(t)}function _f(e){let t=He(kt.cwd(),e.configDir),r=He(kt.cwd(),e.generatedDir),n=He(r,"config-types.ts");if(!Cn(js(n)))Rc(js(n),{recursive:!0,mode:511});let i=Cn(t)?Oc(t).map((a)=>a.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],s=`// Generated by bunfig v${yu}
35
+ `;return r}}function Wf(e,t){let r=_a("process");if(typeof r>"u"||!r.env)return t;let n=r.env[e];return n!==void 0?n:t}function La(e,t,r={}){return Ga(e,t,r,new WeakMap)}function Ga(e,t,r,n){let{arrayMergeMode:i="replace",skipNullish:s=!1,customMerger:a}=r;if(t===null||t===void 0)return s?e:t;if(a){let o=a(e,t);if(o!==void 0)return o}if(Array.isArray(t)||Array.isArray(e))return Ba(e,t,i,n);if(!ze(t)||!ze(e))return t;return Vf(e,t,r,n)}function Ba(e,t,r,n){if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(e)&&!Array.isArray(t))return t;if(Array.isArray(t)&&Array.isArray(e))switch(r){case"replace":return t;case"concat":return Lf(e,t);case"smart":return Gf(e,t,n);default:return t}return t}function Lf(e,t){let r=[...t];for(let n of e)if(!r.some((i)=>vn(i,n)))r.push(n);return r}function Gf(e,t,r){if(t.length===0)return e;if(e.length===0)return t;if(ze(t[0])&&ze(e[0]))return Bf(e,t,r);if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}function Bf(e,t,r){let n=[...t];for(let i of e){if(!ze(i)){n.push(i);continue}let s=["id","name","key","path","type"],a=!1;for(let o of s)if(o in i){if(n.find((c)=>ze(c)&&(o in c)&&c[o]===i[o])){a=!0;break}}if(!a)n.push(i)}return n}function Vf(e,t,r,n){let i=t;if(ze(i)&&n.has(i))return n.get(i);let s={...e};if(ze(i))n.set(i,s);for(let a in i){if(!Object.prototype.hasOwnProperty.call(i,a))continue;let o=i[a],c=s[a];if(r.skipNullish&&(o===null||o===void 0))continue;if(o===null||o===void 0){s[a]=o;continue}if(ze(o)&&ze(c))s[a]=Ga(c,o,r,n);else if(Array.isArray(o)||Array.isArray(c))s[a]=Ba(c,o,r.arrayMergeMode||"smart",n);else s[a]=o}return s}function Wn(e,t,r="replace"){return La(e,t,{arrayMergeMode:r==="replace"?"replace":"smart",skipNullish:!0})}function vn(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!vn(e[r],t[r]))return!1;return!0}if(ze(e)&&ze(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!vn(e[i],t[i]))return!1}return!0}return!1}function ze(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class gi{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(e,t,r={}){let{arrayStrategy:n="replace",useCache:i=!0,cacheTtl:s,trackPerformance:a=!0,verbose:o=!1}=r;if(i){let f=Qt.getWithFileCheck("file",e);if(f){if(o)console.log(`Configuration loaded from cache: ${e}`);return f}}let c=async()=>{if(!Vr(e))return null;try{let f=`?t=${Date.now()}`,u=await import(e+f),l=u.default||u,g="default"in u,d=Object.keys(u).length>0;if(!g&&!d)throw new dr(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof l!=="object"||l===null||Array.isArray(l))throw new dr(e,Error("Configuration must export a valid object"),"unknown");let $={config:Wn(t,l,n),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(i)Qt.setWithFileCheck("file",$,e,s);return $}catch(f){throw f instanceof Error?xt.configLoad(e,f):xt.configLoad(e,Error(String(f)))}};if(a)return pr.track("loadFromPath",c,{path:e});return c()}async tryLoadFromPaths(e,t,r={}){for(let n of e)try{let i=await this.loadFromPath(n,t,r);if(i)return i}catch(i){if(i instanceof Error&&i.name==="ConfigLoadError")throw i;if(r.verbose)console.warn(`Failed to load config from ${n}:`,i)}return null}generateConfigPaths(e,t,r){let n=this.generateNamePatterns(e,r),i=[];for(let s of n)for(let a of this.extensions)i.push(cn(t,`${s}${a}`));return i}generateNamePatterns(e,t){let r=[];if(r.push("config",".config"),e)r.push(e,`.${e}.config`,`${e}.config`,`.${e}`);if(t){if(r.push(t,`.${t}.config`,`${t}.config`,`.${t}`),e)r.push(`${e}.${t}.config`,`.${e}.${t}.config`)}return r.filter(Boolean)}checkFileAccess(e){return Na(async()=>{return Vr(e)},{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,r){let n=[];if(!Vr(e))return n;if(t||r){let i=this.generateNamePatterns(t||"",r);for(let s of i)for(let a of this.extensions){let o=cn(e,`${s}${a}`);if(await this.checkFileAccess(o))n.push(o)}}else try{let{readdirSync:i}=await import("fs"),s=i(e);for(let a of s)if(this.looksLikeConfigFile(a)){let o=cn(e,a);if(await this.checkFileAccess(o))n.push(o)}}catch{return[]}return n}looksLikeConfigFile(e){return[/\.config\.(ts|js|mjs|cjs|json|mts|cts)$/,/^\..*\.(ts|js|mjs|cjs|json|mts|cts)$/,/config\.(ts|js|mjs|cjs|json|mts|cts)$/].some((t)=>t.test(e))}async validateConfigFile(e){let t=[];try{if(!Vr(e))return t.push("Configuration file does not exist"),t;let r=await import(e),n=r.default||r;if(n===void 0)t.push("Configuration file must export a default value or named exports");else if(typeof n!=="object"||n===null)t.push("Configuration must be an object");else if(Array.isArray(n))t.push("Configuration cannot be an array at the root level");if(e.endsWith(".json"))try{let{readFileSync:i}=await import("fs"),s=i(e,"utf8");JSON.parse(s)}catch(i){t.push(`Invalid JSON syntax: ${i}`)}}catch(r){t.push(`Failed to load configuration file: ${r}`)}return t}async getFileModificationTime(e){try{let{statSync:t}=await import("fs");return t(e).mtime}catch{return null}}async preloadConfigurations(e,t={}){let r=new Map;return await Promise.allSettled(e.map(async(n)=>{try{let i=await this.loadFromPath(n,{},t);if(i)r.set(n,i.config)}catch(i){if(t.verbose)console.warn(`Failed to preload ${n}:`,i)}})),r}}class Ln{async validateConfiguration(e,t,r={}){let{stopOnFirstError:n=!1,validateRequired:i=!0,validateTypes:s=!0,customRules:a=[],trackPerformance:o=!0,verbose:c=!1}=r,f=async()=>{let u=[],l=[],g={stopOnFirstError:n,validateRequired:i,validateTypes:s,customRules:a,trackPerformance:o,verbose:c};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,g);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...a],g);else return this.validateWithJSONSchema(e,t,g)}catch(d){return u.push({path:"",message:`Validation failed: ${d}`,rule:"system"}),{isValid:!1,errors:u,warnings:l}}};if(o)return await pr.track("validateConfiguration",f);return f()}async validateWithSchemaFile(e,t,r){try{if(!ef(t))throw new mr(t,[{path:"",message:"Schema file does not exist"}]);let n=await import(t),i=n.default||n;if(Array.isArray(i))return this.validateWithRules(e,i,r);else return this.validateWithJSONSchema(e,i,r)}catch(n){throw new mr(t,[{path:"",message:`Failed to load schema: ${n}`}])}}validateWithJSONSchema(e,t,r){let n=[],i=[];return this.validateObjectAgainstSchema(e,t,"",n,i,r),{isValid:n.length===0,errors:n,warnings:i}}validateObjectAgainstSchema(e,t,r,n,i,s){if(s.validateTypes&&t.type){let a=Array.isArray(e)?"array":typeof e,o=Array.isArray(t.type)?t.type:[t.type];if(!o.includes(a)){if(n.push({path:r,message:`Expected type ${o.join(" or ")}, got ${a}`,expected:o.join(" or "),actual:a,rule:"type"}),s.stopOnFirstError)return}}if(t.enum&&!t.enum.includes(e)){if(n.push({path:r,message:`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"}),s.stopOnFirstError)return}if(typeof e==="string"){if(t.minLength!==void 0&&e.length<t.minLength)n.push({path:r,message:`String length must be at least ${t.minLength}`,expected:`>= ${t.minLength}`,actual:e.length,rule:"minLength"});if(t.maxLength!==void 0&&e.length>t.maxLength)n.push({path:r,message:`String length must not exceed ${t.maxLength}`,expected:`<= ${t.maxLength}`,actual:e.length,rule:"maxLength"});if(t.pattern){if(!new RegExp(t.pattern).test(e))n.push({path:r,message:`String does not match pattern ${t.pattern}`,expected:t.pattern,actual:e,rule:"pattern"})}}if(typeof e==="number"){if(t.minimum!==void 0&&e<t.minimum)n.push({path:r,message:`Value must be at least ${t.minimum}`,expected:`>= ${t.minimum}`,actual:e,rule:"minimum"});if(t.maximum!==void 0&&e>t.maximum)n.push({path:r,message:`Value must not exceed ${t.maximum}`,expected:`<= ${t.maximum}`,actual:e,rule:"maximum"})}if(Array.isArray(e)&&t.items)for(let a=0;a<e.length;a++){let o=r?`${r}[${a}]`:`[${a}]`;if(this.validateObjectAgainstSchema(e[a],t.items,o,n,i,s),s.stopOnFirstError&&n.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let a=e;if(s.validateRequired&&t.required){for(let o of t.required)if(!(o in a)){if(n.push({path:r?`${r}.${o}`:o,message:`Missing required property '${o}'`,expected:"required",rule:"required"}),s.stopOnFirstError)return}}if(t.properties){for(let[o,c]of Object.entries(t.properties))if(o in a){let f=r?`${r}.${o}`:o;if(this.validateObjectAgainstSchema(a[o],c,f,n,i,s),s.stopOnFirstError&&n.length>0)return}}if(t.additionalProperties===!1){let o=new Set(Object.keys(t.properties||{}));for(let c of Object.keys(a))if(!o.has(c))i.push({path:r?`${r}.${c}`:c,message:`Additional property '${c}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,r){let n=[],i=[];for(let s of t)try{let a=this.getValueByPath(e,s.path),o=this.validateWithRule(a,s,s.path);if(n.push(...o),r.stopOnFirstError&&n.length>0)break}catch(a){n.push({path:s.path,message:`Rule validation failed: ${a}`,rule:"system"})}return{isValid:n.length===0,errors:n,warnings:i}}validateWithRule(e,t,r){let n=[];if(t.required&&(e===void 0||e===null))return n.push({path:r,message:t.message||`Property '${r}' is required`,expected:"required",rule:"required"}),n;if(e===void 0||e===null)return n;if(t.type){let i=Array.isArray(e)?"array":typeof e;if(i!==t.type)n.push({path:r,message:t.message||`Expected type ${t.type}, got ${i}`,expected:t.type,actual:i,rule:"type"})}if(t.min!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i<t.min)n.push({path:r,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:i,rule:"min"})}if(t.max!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i>t.max)n.push({path:r,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:i,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))n.push({path:r,message:t.message||`Value does not match pattern ${t.pattern}`,expected:t.pattern.toString(),actual:e,rule:"pattern"})}if(t.enum&&!t.enum.includes(e))n.push({path:r,message:t.message||`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"});if(t.validator){let i=t.validator(e);if(i)n.push({path:r,message:t.message||i,rule:"custom"})}return n}getValueByPath(e,t){if(!t)return e;let r=t.split("."),n=e;for(let i of r)if(n&&typeof n==="object"&&i in n)n=n[i];else return;return n}generateRulesFromInterface(e){let t=[],r=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let n of r){let[,i,s,a]=n;t.push({path:i,required:!s,type:this.mapTypeScriptType(a)})}return t}mapTypeScriptType(e){switch(e.toLowerCase()){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"object";default:return"object"}}static createCommonRules(){return{server:[{path:"port",required:!0,type:"number",min:1,max:65535},{path:"host",required:!0,type:"string",min:1},{path:"ssl",type:"boolean"}],database:[{path:"url",required:!0,type:"string",min:1},{path:"pool",type:"number",min:1,max:100},{path:"timeout",type:"number",min:0}],api:[{path:"baseUrl",required:!0,type:"string",pattern:Ua},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}class Gn{fileLoader=new gi;envProcessor=new pi;validator=new Ln;async loadConfig(e){let t=Date.now(),{cache:r,performance:n,schema:i,validate:s,...a}=e;try{if(r?.enabled){let c=this.checkCache(a.name||"",a);if(c)return c}let o;try{o=await this.loadConfigurationStrategies(a,!0,r)}catch(c){let f=a.__strictErrorHandling;if(c instanceof Error&&c.name==="ConfigNotFoundError"){if(f)throw c;o={...await this.applyEnvironmentVariables(a.name||"",a.defaultConfig,a.checkEnv!==!1,a.verbose||!1),warnings:[`No configuration file found for "${a.name||"config"}", using defaults with environment variables`]}}else if(c instanceof Error&&c.name==="ConfigLoadError"){let u=c.message.includes("EACCES")||c.message.includes("EPERM")||c.message.includes("permission denied"),l=!u&&(c.message.includes("syntax")||c.message.includes("Expected")||c.message.includes("Unexpected")||c.message.includes("BuildMessage")||c.message.includes("errors building")),g=c.message.includes("Configuration must export a valid object")||c.message.includes("Configuration file is empty and exports nothing");if(f&&(g||u))throw c;if(l&&(!f||!g))o={...await this.applyEnvironmentVariables(a.name||"",a.defaultConfig,a.checkEnv!==!1,a.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!f)o={...await this.applyEnvironmentVariables(a.name||"",a.defaultConfig,a.checkEnv!==!1,a.verbose||!1),warnings:[`Configuration loading error, using defaults: ${c.message}`]};else throw c}else o={...await this.applyEnvironmentVariables(a.name||"",a.defaultConfig,a.checkEnv!==!1,a.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${c instanceof Error?c.message:String(c)}`]}}if(i||s)await this.validateConfiguration(o.config,i,s,a.name);if(r?.enabled&&o)this.cacheResult(a.name||"",o,r,a);if(n?.enabled){let c={operation:"loadConfig",duration:Date.now()-t,configName:a.name,timestamp:new Date};if(n.onMetrics)n.onMetrics(c);if(n.slowThreshold&&c.duration>n.slowThreshold)at.warn(`Slow configuration loading detected: ${c.duration}ms for ${a.name}`);o.metrics=c}return o}catch(o){let c=Date.now()-t;throw at.error(`Configuration loading failed after ${c}ms:`,[o instanceof Error?o:Error(String(o))]),o}}async loadConfigurationStrategies(e,t=!1,r){let{name:n="",alias:i,cwd:s,configDir:a,defaultConfig:o,checkEnv:c=!0,arrayStrategy:f="replace",verbose:u=!1}=e,l=s||Rt.cwd(),g=[],d=await this.loadLocalConfiguration(n,i,l,a,o,f,u,c,r);if(d)return g.push(...this.getLocalSearchPaths(n,i,l,a)),this.finalizeResult(d,g,c,n,u);let $=await this.loadHomeConfiguration(n,i,o,f,u,c);if($)return g.push(...this.getHomeSearchPaths(n,i)),this.finalizeResult($,g,c,n,u);let v=await this.loadPackageJsonConfiguration(n,i,l,o,f,u,c);if(v)return g.push(He(l,"package.json")),this.finalizeResult(v,g,c,n,u);if(g.push(...this.getAllSearchPaths(n,i,l,a)),t)throw xt.configNotFound(n,g,i);return{...await this.applyEnvironmentVariables(n,o,c,u),warnings:[`No configuration file found for "${n}"${i?` or alias "${i}"`:""}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,r,n,i,s,a,o,c){let f=o?ur(e,i,a):i,u=this.getLocalDirectories(r,n);for(let l of u){if(a)at.info(`Searching for configuration in: ${l}`);let g=this.fileLoader.generateConfigPaths(e,l,t),d=await this.fileLoader.tryLoadFromPaths(g,f,{arrayStrategy:s,verbose:a,cacheTtl:c?.ttl,useCache:!c?.ttl||c.ttl>100});if(d){if(a)at.success(`Configuration loaded from: ${d.source.path}`);return d}}return null}async loadHomeConfiguration(e,t,r,n,i,s){if(!e)return null;let a=s?ur(e,r,i):r,o=[He(Ht(),".config",e),He(Ht(),".config"),Ht()];for(let c of o){if(i)at.info(`Checking home directory: ${c}`);let f=this.fileLoader.generateConfigPaths(e,c,t),u=await this.fileLoader.tryLoadFromPaths(f,a,{arrayStrategy:n,verbose:i});if(u){if(i)at.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,t,r,n,i,s,a){let o=a?ur(e,n,s):n;try{let c=He(r,"package.json");if(!$n(c))return null;let f=await import(c),u=f[e],l=e;if(!u&&t)u=f[t],l=t;if(u&&typeof u==="object"&&!Array.isArray(u)){if(s)at.success(`Configuration loaded from package.json: ${l}`);return{config:Wn(o,u,i),source:{type:"package.json",path:c,priority:30,timestamp:new Date}}}}catch(c){if(s)at.warn("Failed to load package.json:",[c instanceof Error?c:Error(String(c))])}return null}async applyEnvironmentVariables(e,t,r,n){if(!r||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:ur(e,t,n),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,r,n,i){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,r,n){let i=[];if(r){let s=r(e);if(s)i.push(...s)}if(t){let s=await this.validator.validateConfiguration(e,t);if(!s.isValid)i.push(...s.errors.map((a)=>a.path?`${a.path}: ${a.message}`:a.message))}if(i.length>0)throw xt.configValidation(n||"unknown",i,n)}checkCache(e,t){let r=this.generateCacheKey(e,t);return Qt.get(r)||null}cacheResult(e,t,r,n){let i=this.generateCacheKey(e,n);Qt.set(i,t,void 0,r.ttl)}generateCacheKey(e,t){let r=[e];if(t.alias)r.push(`alias:${t.alias}`);if(t.cwd)r.push(`cwd:${t.cwd}`);if(t.configDir)r.push(`configDir:${t.configDir}`);if("checkEnv"in t)r.push(`checkEnv:${t.checkEnv}`);return r.join("|")}getLocalDirectories(e,t){return Array.from(new Set([e,He(e,"config"),He(e,".config"),t?He(e,t):void 0].filter(Boolean)))}getAllSearchPaths(e,t,r,n){let i=[];return i.push(...this.getLocalSearchPaths(e,t,r,n)),i.push(...this.getHomeSearchPaths(e,t)),i.push(He(r,"package.json")),i}getLocalSearchPaths(e,t,r,n){let i=this.getLocalDirectories(r,n),s=[];for(let a of i)s.push(...this.fileLoader.generateConfigPaths(e,a,t));return s}getHomeSearchPaths(e,t){if(!e)return[];let r=[He(Ht(),".config",e),He(Ht(),".config"),Ht()],n=[];for(let i of r)n.push(...this.fileLoader.generateConfigPaths(e,i,t));return n}async loadConfigWithResult(e){return this.loadConfig(e)}}function ga(e){let t=!(e.message.includes("EACCES")||e.message.includes("EPERM")||e.message.includes("permission denied"))&&(e.message.includes("syntax")||e.message.includes("Expected")||e.message.includes("Unexpected")||e.message.includes("BuildMessage")),r=e.message.includes("Configuration must export a valid object")||e.message.includes("Configuration file is empty and exports nothing");return t||r}async function _f(e){return Ct.loadConfig({...e,__strictErrorHandling:!0})}async function Va(e){let t="defaultConfig"in e&&e.defaultConfig!==void 0?e.defaultConfig:{},r="cache"in e||"performance"in e||"schema"in e||"validate"in e;try{let n;if(r)n=await Ct.loadConfig(e);else n=await Ct.loadConfig({...e,defaultConfig:t,cache:{enabled:!0},performance:{enabled:!1}});return n?.config??t}catch(n){let i=n instanceof Error?n.name:"UnknownError",s=n instanceof Error?n.message:String(n);if(!(i==="ConfigNotFoundError"||i==="ConfigLoadError"||i==="ConfigValidationError"||s.includes("config"))&&e.verbose)at.warn("Unexpected error loading config, using defaults:",[n instanceof Error?n:Error(String(n))]);let a=r?{...e,defaultConfig:t}:{...e,defaultConfig:t,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in e?e.checkEnv!==!1:!0)return(await Ct.applyEnvironmentVariables(a.name||"",t,!0,a.verbose||!1))?.config??t;return t}}async function Hf(e={defaultConfig:{}}){if(typeof e==="string"){let{cwd:t}=await import("process");try{return(await Ct.loadConfig({name:e,cwd:t(),generatedDir:"./generated",configDir:"./config",defaultConfig:{},checkEnv:!0,arrayStrategy:"replace"})).config}catch(r){if(r instanceof Error&&(r.name==="ConfigNotFoundError"||r.name==="ConfigLoadError"&&ga(r)))return(await Ct.applyEnvironmentVariables(e,{},!0,!1)).config;throw r}}try{return(await Ct.loadConfig({...e,cwd:e.cwd||Rt.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(t){if(t instanceof Error&&(t.name==="ConfigNotFoundError"||t.name==="ConfigLoadError"&&ga(t)))return(await Ct.applyEnvironmentVariables(e.name||"",e.defaultConfig||{},e.checkEnv!==!1,e.verbose||!1)).config;throw t}}async function jf(e,t,r="replace"){let n=new gi;try{let i=await n.loadFromPath(e,t,{arrayStrategy:r,useCache:!1,trackPerformance:!1});return i?i.config:null}catch{return null}}function ur(e,t,r=!1){let n=new pi,i=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function s(a,o=[]){let c={...a};for(let[f,u]of Object.entries(a)){let l=[...o,f],g=[`${i}_${l.join("_").toUpperCase()}`,`${i}_${l.map((v)=>v.toUpperCase()).join("")}`,`${i}_${l.map((v)=>v.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],d,$;for(let v of g)if(d=Rt.env[v],d!==void 0){$=v;break}if(d!==void 0&&$)if(typeof u==="boolean")c[f]=["true","1","yes"].includes(d.toLowerCase());else if(typeof u==="number"){let v=Number(d);if(!Number.isNaN(v))c[f]=v}else if(Array.isArray(u))try{c[f]=JSON.parse(d)}catch{c[f]=d.split(",").map((v)=>v.trim())}else c[f]=d;else if(u&&typeof u==="object"&&!Array.isArray(u))c[f]=s(u,l)}return c}return s(t)}function Kf(e){let t=He(Rt.cwd(),e.configDir),r=He(Rt.cwd(),e.generatedDir),n=He(r,"config-types.ts");if(!$n(Us(n)))kc(Us(n),{recursive:!0,mode:511});let i=$n(t)?Mc(t).map((a)=>a.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],s=`// Generated by bunfig v${$u}
36
36
  export type ConfigNames = ${i.length?`'${i.join("' | '")}'`:"string"}
37
- `;Pc(n,s,{mode:438})}function Hf(e){let t=null,r=null,n=()=>{if(!r)r=Wa(e).then((s)=>{return t=s,s},(s)=>{let a="defaultConfig"in e?e.defaultConfig:{};if(t=a,"verbose"in e&&e.verbose)st.warn("Config loading failed, using defaults:",[s instanceof Error?s:Error(String(s))]);return a});return r},i="defaultConfig"in e?e.defaultConfig:{};return t=i,n(),new Proxy({},{get(s,a){if(t)return t[a];let o=i[a];return n(),o},has(s,a){return a in(t||i)},ownKeys(){return Object.keys(t||i)},getOwnPropertyDescriptor(s,a){return Object.getOwnPropertyDescriptor(t||i,a)},set(s,a,o){if(!t)t={...i};return t[a]=o,!0}})}function jf(e){let t=sa(ef.cwd(),e?.configDir||"./config");function r(){if(!zc(t))return[];let i=new Set([".ts",".js",".mjs",".cjs",".mts",".cts",".json"]),s=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"],a=Qc(t).filter((c)=>i.has(ln(c))).map((c)=>({base:c.replace(/\.(?:ts|js|mjs|cjs|mts|cts|json)$/i,""),file:c})),o=new Map;for(let{base:c,file:f}of a){let u=ln(f).toLowerCase(),l=o.get(c);if(!l){o.set(c,f);continue}let g=ln(l).toLowerCase();if(s.indexOf(u)<s.indexOf(g))o.set(c,f)}return Array.from(o.entries()).map(([c,f])=>({base:c,file:f})).sort((c,f)=>c.base.localeCompare(f.base))}function n(){let i=r(),s=i.map((c)=>c.base),a=s.length?s.map((c)=>`'${c}'`).join(" | "):"string",o=i.length?`{
38
- ${i.map((c)=>{let f=sa(t,c.file).replace(/\\/g,"/");return` '${c.base}': typeof import('${f}').default`}).join(`,
37
+ `;Ic(n,s,{mode:438})}function Jf(e){let t=null,r=null,n=()=>{if(!r)r=Va(e).then((s)=>{return t=s,s},(s)=>{let a="defaultConfig"in e?e.defaultConfig:{};if(t=a,"verbose"in e&&e.verbose)at.warn("Config loading failed, using defaults:",[s instanceof Error?s:Error(String(s))]);return a});return r},i="defaultConfig"in e?e.defaultConfig:{};return t=i,n(),new Proxy({},{get(s,a){if(t)return t[a];let o=i[a];return n(),o},has(s,a){return a in(t||i)},ownKeys(){return Object.keys(t||i)},getOwnPropertyDescriptor(s,a){return Object.getOwnPropertyDescriptor(t||i,a)},set(s,a,o){if(!t)t={...i};return t[a]=o,!0}})}function Uf(e){let t=la(nf.cwd(),e?.configDir||"./config");function r(){if(!tf(t))return[];let i=new Set([".ts",".js",".mjs",".cjs",".mts",".cts",".json"]),s=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"],a=rf(t).filter((c)=>i.has(fn(c))).map((c)=>({base:c.replace(/\.(?:ts|js|mjs|cjs|mts|cts|json)$/i,""),file:c})),o=new Map;for(let{base:c,file:f}of a){let u=fn(f).toLowerCase(),l=o.get(c);if(!l){o.set(c,f);continue}let g=fn(l).toLowerCase();if(s.indexOf(u)<s.indexOf(g))o.set(c,f)}return Array.from(o.entries()).map(([c,f])=>({base:c,file:f})).sort((c,f)=>c.base.localeCompare(f.base))}function n(){let i=r(),s=i.map((c)=>c.base),a=s.length?s.map((c)=>`'${c}'`).join(" | "):"string",o=i.length?`{
38
+ ${i.map((c)=>{let f=la(t,c.file).replace(/\\/g,"/");return` '${c.base}': typeof import('${f}').default`}).join(`,
39
39
  `)}
40
40
  }`:"Record<string, any>";return`export type ConfigNames = ${a}
41
41
  export type ConfigByName = ${o}
42
42
  export type Config<N extends ConfigNames> = N extends keyof ConfigByName ? ConfigByName[N] : unknown
43
43
  export type ConfigOf = Config
44
- `}return{name:"bunfig-plugin",setup(i){i.onResolve({filter:/^virtual:bunfig-types$/},(s)=>{return{path:s.path,namespace:"bunfig-virtual"}}),i.onLoad({filter:/^virtual:bunfig-types$/,namespace:"bunfig-virtual"},()=>{return{contents:n(),loader:"ts"}})}}}function wu(e,t={}){let r=ti.cwd();while(r.includes("storage"))r=aa(r,"..");let n=aa(r,e||"");if(t?.relative)return rf(ti.cwd(),n);return n}function ke(){if(yt.env.NODE_ENV==="test"||yt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Eu(){if(yt.env.NODE_ENV==="test"||yt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof yt<"u"){let e=yt.type;if(e==="renderer"||e==="worker")return!1;return!!(yt.versions&&(yt.versions.node||yt.versions.bun))}return!1}class Ya{async format(e){let t=await Eu(),r=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:r})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:zt.pid,hostname:t(),environment:zt.env.NODE_ENV||"development",platform:zt.platform,version:zt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:zt.env.NODE_ENV||zt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class pi{name;fileLocks=new Map;currentKeyId=null;keys=new Map;fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(e,t={}){this.name=e,this.config={...ci},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new Ya,this.enabled=t.enabled??!0,this.fancy=t.fancy??!0,this.tagFormat=t.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=t.timestampPosition??"right",this.environment=t.environment??ce.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let r={...t},n=t.timestamp!==void 0;if(n)delete r.timestamp;if(this.config={...this.config,...r,timestamp:n||this.config.timestamp,level:this.options.level??"info"},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),s=this.generateKey();this.currentKeyId=i,this.keys.set(i,s),this.encryptionKeys.set(i,{key:s,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let t={debug:0,info:1,success:2,warning:3,error:4},r=this.fingersCrossedConfig.activationLevel??"error";return t[e]>=t[r]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...yn,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...yn};return{...yn,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:ci.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},r={...t,...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))};if(!r.level||!["debug","info","success","warning","error"].includes(r.level))r.level=t.level;return r}shouldWriteToFile(){return!ke()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let n,i=0,s=3,a=1000;while(i<s)try{try{try{await lf(this.config.logDirectory,fa.F_OK|fa.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await cf(this.config.logDirectory,{recursive:!0,mode:493});else if(c.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw c;else throw c}}catch(c){throw console.error("Debug: [writeToFile] Failed to create log directory:",c),c}let o=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:dt.from(e);try{if(!Br(this.currentLogFile))await un(this.currentLogFile,"",{mode:420});if(n=ca(this.currentLogFile,"a",420),of(n,o,{flag:"a"}),la(n),n!==void 0)fn(n),n=void 0;if((await qt(this.currentLogFile)).size===0){if(await un(this.currentLogFile,o,{flag:"w",mode:420}),(await qt(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let f=c;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(i<s-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${i+1}/${s}:`,u);let l=a*2**i;await new Promise((g)=>setTimeout(g,l)),i++;continue}}if(f?.code&&["ENOSPC","EDQUOT"].includes(f.code))throw Error(`Disk quota exceeded or no space left on device: ${f.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",f),f}finally{if(n!==void 0)try{fn(n)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(o){if(i===s-1){let f=o,u=typeof f.message==="string"?f.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",u),o}i++;let c=a*2**(i-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let r=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}finally{this.pendingOperations.splice(r,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return Xt(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return Xt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Xt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(ke())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let e=this.config.rotation.keyRotation;if(!e?.enabled)return;let t=typeof e.interval==="number"?e.interval:60,r=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((n)=>{console.error("Error rotating keys:",n)})},r)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),r=this.generateKey();this.currentKeyId=t,this.keys.set(t,r),this.encryptionKeys.set(t,{key:r,createdAt:new Date});let n=Array.from(this.encryptionKeys.entries()).sort(([,a],[,o])=>o.createdAt.getTime()-a.createdAt.getTime()),i=typeof e.maxKeys==="number"?e.maxKeys:1,s=Math.max(1,i);if(n.length>s)for(let[a]of n.slice(s))this.encryptionKeys.delete(a),this.keys.delete(a)}generateKeyId(){return cn(16).toString("hex")}generateKey(){return cn(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:t}=this.getCurrentKey(),r=cn(16),n=nf("aes-256-gcm",t,r),i=dt.isBuffer(e)?e:dt.from(e,"utf8"),s=n.update(i),a=n.final(),o=s.length+a.length,c=n.getAuthTag(),f=dt.allocUnsafe(16+o+16);return r.copy(f,0),s.copy(f,16),a.copy(f,16+s.length),c.copy(f,16+o),{encrypted:f,iv:r}}async compressData(e){return new Promise((t,r)=>{let n=ha(),i=[];n.on("data",(s)=>i.push(s)),n.on("end",()=>t(dt.from(dt.concat(i)))),n.on("error",r),n.write(e),n.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let t=this.config.rotation.encrypt;return{...e,...t}}return e}async rotateLog(){if(ke())return;if(!this.shouldWriteToFile())return;let e=await qt(this.currentLogFile).catch(()=>null);if(!e)return;let t=this.config.rotation;if(typeof t==="boolean")return;if(t.maxSize&&e.size>=t.maxSize){let r=this.currentLogFile,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await Vr(this.config.logDirectory),s=i.filter((c)=>c.startsWith(this.name)&&/\.log\.\d+$/.test(c)).sort((c,f)=>{let u=Number.parseInt(c.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(f.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),a=s.length>0?Number.parseInt(s[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,o=`${r}.${a}`;if(await qt(r).catch(()=>null))try{if(await ua(r,o),t.compress)try{let c=`${o}.gz`;await this.compressLogFile(o,c),await _r(o)}catch(c){console.error("Error compressing rotated file:",c)}if(s.length===0&&!i.some((c)=>c.endsWith(".log.1")))try{let c=`${r}.1`;await un(c,"")}catch(c){console.error("Error creating backup file:",c)}}catch(c){console.error(`Error during rotation: ${c instanceof Error?c.message:String(c)}`)}}else{let i=new Date().toISOString().replace(/[:.]/g,"-"),s=r.replace(/\.log$/,`-${i}.log`);if(await qt(r).catch(()=>null))await ua(r,s)}if(this.currentLogFile=n,t.maxFiles){let i=(await Vr(this.config.logDirectory)).filter((s)=>s.startsWith(this.name)).sort((s,a)=>a.localeCompare(s));for(let s of i.slice(t.maxFiles))await _r(Xt(this.config.logDirectory,s))}}}async compressLogFile(e,t){let r=oa(e),n=af(t),i=ha();await hf(r,i,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let r of this.logBuffer){let n=await this.formatter.format(r);if(this.shouldWriteToFile())await this.writeToFile(n);console.log(n)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(t);console.log(t)}}shouldLog(e){if(!this.enabled)return!1;let t={debug:0,info:1,success:2,warning:3,error:4};return t[e]>=t[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((t)=>{console.error("Error in pending write operation:",t)});return Promise.resolve()})),Br(this.currentLogFile))try{let e=ca(this.currentLogFile,"r+");la(e),fn(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!ke()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await Vr(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await _r(Xt(this.config.logDirectory,t))}catch(r){console.error(`Failed to delete temp file ${t}:`,r)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.shouldStyleConsole()?ie.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||ke())return!1;let e=typeof ce.env.NO_COLOR<"u",t=ce.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof ce.stderr<"u"&&ce.stderr.isTTY||typeof ce.stdout<"u"&&ce.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:r="",tag:n="",message:i,level:s,showTimestamp:a=!0}=e,o=(d)=>d.replace(this.ANSI_PATTERN,"");if(!this.fancy){let d=[];if(a)d.push(t);if(s==="warning")d.push("WARN");else if(s==="error")d.push("ERROR");else if(r)d.push(r.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)d.push(n.replace(/[[\]]/g,""));return d.push(i),d.join(" ")}let c=ce.stdout.columns||120,f="";if(s==="warning"||s==="error")f=`${r} ${i}`;else if(s==="info"||s==="success")f=`${r} ${n} ${i}`;else f=`${r} ${n} ${ie.cyan(i)}`;if(!a)return f.trim();let u=o(f).trim().length,l=o(t).length,g=Math.max(1,c-2-u-l);return`${f.trim()}${" ".repeat(g)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(s,a)=>{let o=Number.parseInt(a,10);return o<t[0].length?String(t[0][o]):s});let r=/%([sdijfo%])/g,n=0,i=e.replace(r,(s,a)=>{if(a==="%")return"%";if(n>=t.length)return s;let o=t[n++];switch(a){case"s":return String(o);case"d":case"i":return Number(o).toString();case"j":case"o":return JSON.stringify(o,null,2);default:return s}});if(n<t.length)i+=` ${t.slice(n).map((s)=>typeof s==="object"?JSON.stringify(s,null,2):String(s)).join(" ")}`;return i}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,n,i)=>{let s=ie.underline(ie.blue(n)),a=this.toAbsoluteFilePath(i);if(a&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let o=`file://${encodeURI(a)}`,c="\x1B]8;;",f="\x1B\\";return`\x1B]8;;${o}\x1B\\${s}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${i}\x1B\\${s}\x1B]8;;\x1B\\`;return s}),t=t.replace(/`([^`]+)`/g,(r,n)=>ie.bgGray(n)),t=t.replace(/\*\*([^*]+)\*\*/g,(r,n)=>ie.bold(n)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(r,n)=>ie.italic(n)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(r,n)=>ie.italic(n)),t=t.replace(/~([^~]+)~/g,(r,n)=>ie.strikethrough(n)),t}supportsHyperlinks(){if(ke())return!1;let e=ce.env;if(!e)return!1;if(e.TERM_PROGRAM==="iTerm.app"||e.TERM_PROGRAM==="vscode"||e.TERM_PROGRAM==="WezTerm")return!0;if(e.WT_SESSION)return!0;if(e.TERM==="xterm-kitty")return!0;let t=e.VTE_VERSION?Number.parseInt(e.VTE_VERSION,10):0;if(!Number.isNaN(t)&&t>=5000)return!0;return!1}toAbsoluteFilePath(e){try{let t=e;if(t.startsWith("file://"))t=t.replace(/^file:\/\//,"");if(t.startsWith("~")){let r=ce.env.HOME||"";if(r)t=t.replace(/^~(?=$|\/)/,r)}if(ff(t)||t.startsWith("./")||t.startsWith("../"))t=uf(t);else return null;return Br(t)?t:null}catch{return null}}buildOutputTexts(e){let t=this.shouldStyleConsole()?this.formatMarkdown(e):e,r=e.replace(this.ANSI_PATTERN,"");return{consoleText:t,fileText:r}}async log(e,t,...r){if(!this.shouldLog(e))return;let n=new Date,i=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n),a,o;if(t instanceof Error)a=t.message,o=t.stack;else a=this.formatMessage(t,r);let{consoleText:c,fileText:f}=this.buildOutputTexts(a);if(this.shouldStyleConsole()){let l=this.options.showIcons===!1?"":xu[e],g=this.options.showTags!==!1&&this.name?ie.gray(this.formatTag(this.name)):"",d;switch(e){case"debug":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:ie.gray(c),level:e}),console.error(d);break;case"info":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.warn(d);break;case"success":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:ie.green(c),level:e}),console.error(d);break;case"warning":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.warn(d);break;case"error":if(d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.error(d),o){let w=o.split(`
45
- `);for(let E of w)if(E.trim()&&!E.includes(a))console.error(this.formatConsoleMessage({timestamp:i,message:ie.gray(` ${E}`),level:e,showTimestamp:!1}))}break}}else if(!ke()){if(console.error(`${s} ${this.environment}.${e.toUpperCase()}: ${a}`),o)console.error(o)}let u=`${s} ${this.environment}.${e.toUpperCase()}: ${f}
44
+ `}return{name:"bunfig-plugin",setup(i){i.onResolve({filter:/^virtual:bunfig-types$/},(s)=>{return{path:s.path,namespace:"bunfig-virtual"}}),i.onLoad({filter:/^virtual:bunfig-types$/,namespace:"bunfig-virtual"},()=>{return{contents:n(),loader:"ts"}})}}}function vu(e,t={}){let r=ii.cwd();while(r.includes("storage"))r=ca(r,"..");let n=ca(r,e||"");if(t?.relative)return af(ii.cwd(),n);return n}function De(){if(yt.env.NODE_ENV==="test"||yt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function bu(){if(yt.env.NODE_ENV==="test"||yt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof yt<"u"){let e=yt.type;if(e==="renderer"||e==="worker")return!1;return!!(yt.versions&&(yt.versions.node||yt.versions.bun))}return!1}class Xa{async format(e){let t=await bu(),r=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:r})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:zt.pid,hostname:t(),environment:zt.env.NODE_ENV||"development",platform:zt.platform,version:zt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:zt.env.NODE_ENV||zt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class yi{name;fileLocks=new Map;currentKeyId=null;keys=new Map;fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(e,t={}){this.name=e,this.config={...ui},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new Xa,this.enabled=t.enabled??!0,this.fancy=t.fancy??!0,this.tagFormat=t.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=t.timestampPosition??"right",this.environment=t.environment??fe.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let r={...t},n=t.timestamp!==void 0;if(n)delete r.timestamp;if(this.config={...this.config,...r,timestamp:n||this.config.timestamp,level:this.options.level??"info"},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),s=this.generateKey();this.currentKeyId=i,this.keys.set(i,s),this.encryptionKeys.set(i,{key:s,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let t={debug:0,info:1,success:2,warning:3,error:4},r=this.fingersCrossedConfig.activationLevel??"error";return t[e]>=t[r]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...wn,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...wn};return{...wn,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:ui.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},r={...t,...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))};if(!r.level||!["debug","info","success","warning","error"].includes(r.level))r.level=t.level;return r}shouldWriteToFile(){return!De()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let n,i=0,s=3,a=1000;while(i<s)try{try{try{await uf(this.config.logDirectory,da.F_OK|da.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await hf(this.config.logDirectory,{recursive:!0,mode:493});else if(c.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw c;else throw c}}catch(c){throw console.error("Debug: [writeToFile] Failed to create log directory:",c),c}let o=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:dt.from(e);try{if(!_r(this.currentLogFile))await dn(this.currentLogFile,"",{mode:420});if(n=ha(this.currentLogFile,"a",420),ff(n,o,{flag:"a"}),ua(n),n!==void 0)hn(n),n=void 0;if((await qt(this.currentLogFile)).size===0){if(await dn(this.currentLogFile,o,{flag:"w",mode:420}),(await qt(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let f=c;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(i<s-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${i+1}/${s}:`,u);let l=a*2**i;await new Promise((g)=>setTimeout(g,l)),i++;continue}}if(f?.code&&["ENOSPC","EDQUOT"].includes(f.code))throw Error(`Disk quota exceeded or no space left on device: ${f.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",f),f}finally{if(n!==void 0)try{hn(n)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(o){if(i===s-1){let f=o,u=typeof f.message==="string"?f.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",u),o}i++;let c=a*2**(i-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let r=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}finally{this.pendingOperations.splice(r,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return Xt(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return Xt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Xt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(De())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let e=this.config.rotation.keyRotation;if(!e?.enabled)return;let t=typeof e.interval==="number"?e.interval:60,r=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((n)=>{console.error("Error rotating keys:",n)})},r)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),r=this.generateKey();this.currentKeyId=t,this.keys.set(t,r),this.encryptionKeys.set(t,{key:r,createdAt:new Date});let n=Array.from(this.encryptionKeys.entries()).sort(([,a],[,o])=>o.createdAt.getTime()-a.createdAt.getTime()),i=typeof e.maxKeys==="number"?e.maxKeys:1,s=Math.max(1,i);if(n.length>s)for(let[a]of n.slice(s))this.encryptionKeys.delete(a),this.keys.delete(a)}generateKeyId(){return un(16).toString("hex")}generateKey(){return un(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:t}=this.getCurrentKey(),r=un(16),n=of("aes-256-gcm",t,r),i=dt.isBuffer(e)?e:dt.from(e,"utf8"),s=n.update(i),a=n.final(),o=s.length+a.length,c=n.getAuthTag(),f=dt.allocUnsafe(16+o+16);return r.copy(f,0),s.copy(f,16),a.copy(f,16+s.length),c.copy(f,16+o),{encrypted:f,iv:r}}async compressData(e){return new Promise((t,r)=>{let n=pa(),i=[];n.on("data",(s)=>i.push(s)),n.on("end",()=>t(dt.from(dt.concat(i)))),n.on("error",r),n.write(e),n.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let t=this.config.rotation.encrypt;return{...e,...t}}return e}async rotateLog(){if(De())return;if(!this.shouldWriteToFile())return;let e=await qt(this.currentLogFile).catch(()=>null);if(!e)return;let t=this.config.rotation;if(typeof t==="boolean")return;if(t.maxSize&&e.size>=t.maxSize){let r=this.currentLogFile,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await Hr(this.config.logDirectory),s=i.filter((c)=>c.startsWith(this.name)&&/\.log\.\d+$/.test(c)).sort((c,f)=>{let u=Number.parseInt(c.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(f.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),a=s.length>0?Number.parseInt(s[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,o=`${r}.${a}`;if(await qt(r).catch(()=>null))try{if(await ma(r,o),t.compress)try{let c=`${o}.gz`;await this.compressLogFile(o,c),await jr(o)}catch(c){console.error("Error compressing rotated file:",c)}if(s.length===0&&!i.some((c)=>c.endsWith(".log.1")))try{let c=`${r}.1`;await dn(c,"")}catch(c){console.error("Error creating backup file:",c)}}catch(c){console.error(`Error during rotation: ${c instanceof Error?c.message:String(c)}`)}}else{let i=new Date().toISOString().replace(/[:.]/g,"-"),s=r.replace(/\.log$/,`-${i}.log`);if(await qt(r).catch(()=>null))await ma(r,s)}if(this.currentLogFile=n,t.maxFiles){let i=(await Hr(this.config.logDirectory)).filter((s)=>s.startsWith(this.name)).sort((s,a)=>a.localeCompare(s));for(let s of i.slice(t.maxFiles))await jr(Xt(this.config.logDirectory,s))}}}async compressLogFile(e,t){let r=fa(e),n=cf(t),i=pa();await pf(r,i,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let r of this.logBuffer){let n=await this.formatter.format(r);if(this.shouldWriteToFile())await this.writeToFile(n);console.log(n)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(t);console.log(t)}}shouldLog(e){if(!this.enabled)return!1;let t={debug:0,info:1,success:2,warning:3,error:4};return t[e]>=t[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((t)=>{console.error("Error in pending write operation:",t)});return Promise.resolve()})),_r(this.currentLogFile))try{let e=ha(this.currentLogFile,"r+");ua(e),hn(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!De()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await Hr(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await jr(Xt(this.config.logDirectory,t))}catch(r){console.error(`Failed to delete temp file ${t}:`,r)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.shouldStyleConsole()?re.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||De())return!1;let e=typeof fe.env.NO_COLOR<"u",t=fe.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof fe.stderr<"u"&&fe.stderr.isTTY||typeof fe.stdout<"u"&&fe.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:r="",tag:n="",message:i,level:s,showTimestamp:a=!0}=e,o=(d)=>d.replace(this.ANSI_PATTERN,"");if(!this.fancy){let d=[];if(a)d.push(t);if(s==="warning")d.push("WARN");else if(s==="error")d.push("ERROR");else if(r)d.push(r.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)d.push(n.replace(/[[\]]/g,""));return d.push(i),d.join(" ")}let c=fe.stdout.columns||120,f="";if(s==="warning"||s==="error")f=`${r} ${i}`;else if(s==="info"||s==="success")f=`${r} ${n} ${i}`;else f=`${r} ${n} ${re.cyan(i)}`;if(!a)return f.trim();let u=o(f).trim().length,l=o(t).length,g=Math.max(1,c-2-u-l);return`${f.trim()}${" ".repeat(g)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(s,a)=>{let o=Number.parseInt(a,10);return o<t[0].length?String(t[0][o]):s});let r=/%([sdijfo%])/g,n=0,i=e.replace(r,(s,a)=>{if(a==="%")return"%";if(n>=t.length)return s;let o=t[n++];switch(a){case"s":return String(o);case"d":case"i":return Number(o).toString();case"j":case"o":return JSON.stringify(o,null,2);default:return s}});if(n<t.length)i+=` ${t.slice(n).map((s)=>typeof s==="object"?JSON.stringify(s,null,2):String(s)).join(" ")}`;return i}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,n,i)=>{let s=re.underline(re.blue(n)),a=this.toAbsoluteFilePath(i);if(a&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let o=`file://${encodeURI(a)}`,c="\x1B]8;;",f="\x1B\\";return`\x1B]8;;${o}\x1B\\${s}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${i}\x1B\\${s}\x1B]8;;\x1B\\`;return s}),t=t.replace(/`([^`]+)`/g,(r,n)=>re.bgGray(n)),t=t.replace(/\*\*([^*]+)\*\*/g,(r,n)=>re.bold(n)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(r,n)=>re.italic(n)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(r,n)=>re.italic(n)),t=t.replace(/~([^~]+)~/g,(r,n)=>re.strikethrough(n)),t}supportsHyperlinks(){if(De())return!1;let e=fe.env;if(!e)return!1;if(e.TERM_PROGRAM==="iTerm.app"||e.TERM_PROGRAM==="vscode"||e.TERM_PROGRAM==="WezTerm")return!0;if(e.WT_SESSION)return!0;if(e.TERM==="xterm-kitty")return!0;let t=e.VTE_VERSION?Number.parseInt(e.VTE_VERSION,10):0;if(!Number.isNaN(t)&&t>=5000)return!0;return!1}toAbsoluteFilePath(e){try{let t=e;if(t.startsWith("file://"))t=t.replace(/^file:\/\//,"");if(t.startsWith("~")){let r=fe.env.HOME||"";if(r)t=t.replace(/^~(?=$|\/)/,r)}if(df(t)||t.startsWith("./")||t.startsWith("../"))t=mf(t);else return null;return _r(t)?t:null}catch{return null}}buildOutputTexts(e){let t=this.shouldStyleConsole()?this.formatMarkdown(e):e,r=e.replace(this.ANSI_PATTERN,"");return{consoleText:t,fileText:r}}async log(e,t,...r){if(!this.shouldLog(e))return;let n=new Date,i=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n),a,o;if(t instanceof Error)a=t.message,o=t.stack;else a=this.formatMessage(t,r);let{consoleText:c,fileText:f}=this.buildOutputTexts(a);if(this.shouldStyleConsole()){let l=this.options.showIcons===!1?"":Ou[e],g=this.options.showTags!==!1&&this.name?re.gray(this.formatTag(this.name)):"",d;switch(e){case"debug":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:re.gray(c),level:e}),console.error(d);break;case"info":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.warn(d);break;case"success":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:re.green(c),level:e}),console.error(d);break;case"warning":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.warn(d);break;case"error":if(d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.error(d),o){let $=o.split(`
45
+ `);for(let v of $)if(v.trim()&&!v.includes(a))console.error(this.formatConsoleMessage({timestamp:i,message:re.gray(` ${v}`),level:e,showTimestamp:!1}))}break}}else if(!De()){if(console.error(`${s} ${this.environment}.${e.toUpperCase()}: ${a}`),o)console.error(o)}let u=`${s} ${this.environment}.${e.toUpperCase()}: ${f}
46
46
  `;if(o)u+=`${o}
47
- `;if(u=u.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(u)}progress(e,t=""){let r={update:(i,s)=>{},finish:(i)=>{},interrupt:(i,s)=>{}};if(!this.enabled)return r;let n=30;if(this.activeProgressBar={total:Math.max(1,e||1),current:0,message:t||"",barLength:n,lastRenderedLine:""},this.shouldStyleConsole()&&!ke()&&ce.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(i,s)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,i),this.activeProgressBar.total),s!==void 0)this.activeProgressBar.message=s;if(this.shouldStyleConsole()&&!ke()&&ce.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(i)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,i)},interrupt:(i,s="info")=>{if(!ke()&&ce.stdout.isTTY)ce.stdout.write(`
48
- `);if(this[s==="warning"?"warn":s](i),this.activeProgressBar&&this.shouldStyleConsole()&&!ke()&&ce.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let t=performance.now();if(this.shouldStyleConsole()){let r=this.options.showTags!==!1&&this.name?ie.gray(this.formatTag(this.name)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:this.options.showIcons===!1?"":ie.blue("\u25D0"),tag:r,message:`${ie.cyan(e)}...`}))}return async(r)=>{if(!this.enabled)return;let n=performance.now(),i=Math.round(n-t),s=`${e} completed in ${i}ms`,a=new Date,o=this.formatConsoleTimestamp(a),c=`${this.formatFileTimestamp(a)} ${this.environment}.INFO: ${s}`;if(r)c+=` ${JSON.stringify(r)}`;if(c+=`
49
- `,c=c.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let f=this.options.showTags!==!1&&this.name?ie.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:o,icon:this.options.showIcons===!1?"":ie.green("\u2713"),tag:f,message:`${s}${r?` ${JSON.stringify(r)}`:""}`}))}else if(!ke())console.error(c.trim());if(this.shouldWriteToFile())await this.writeToFile(c)}}async debug(e,...t){await this.log("debug",e,...t)}async info(e,...t){await this.log("info",e,...t)}async success(e,...t){await this.log("success",e,...t)}async warn(e,...t){await this.log("warning",e,...t)}async error(e,...t){await this.log("error",e,...t)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:t}=e;return!!t}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let t=`${this.name}:${e}`,r=new pi(t,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(r),r}createReadStream(){if(ke())throw Error("createReadStream is not supported in browser environments");if(!Br(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return oa(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let t=this.config.rotation;if(!t.encrypt||typeof t.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let r=this.keys.get(this.currentKeyId);try{let n=dt.isBuffer(e)?e:dt.from(e,"base64"),i=n.subarray(0,16),s=n.subarray(n.length-16),a=n.subarray(16,n.length-16),o=sf("aes-256-gcm",r,i);o.setAuthTag(s);let c=o.update(a),f=o.final(),u=c.length+f.length,l=dt.allocUnsafe(u);return c.copy(l,0),f.copy(l,c.length),l.toString("utf8")}catch(n){throw Error(`Decryption failed: ${n instanceof Error?n.message:String(n)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return ke()}isServerMode(){return!ke()}setTestEncryptionKey(e,t){this.currentKeyId=e,this.keys.set(e,t)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(e){if(!this.enabled)return;let t=new Date,r=this.formatConsoleTimestamp(t),n=this.formatFileTimestamp(t),{consoleText:i,fileText:s}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let o=i.split(`
50
- `),c=Math.max(...o.map((g)=>g.length))+2,f=`\u250C${"\u2500".repeat(c)}\u2510`,u=`\u2514${"\u2500".repeat(c)}\u2518`,l=o.map((g)=>{return this.formatConsoleMessage({timestamp:r,message:ie.cyan(g),showTimestamp:!1})});console.error(this.formatConsoleMessage({timestamp:r,message:ie.cyan(f),showTimestamp:!1})),l.forEach((g)=>console.error(g)),console.error(this.formatConsoleMessage({timestamp:r,message:ie.cyan(u),showTimestamp:!1}))}else if(!ke())console.error(`${n} ${this.environment}.INFO: [BOX] ${s}`);let a=`${n} ${this.environment}.INFO: [BOX] ${s}
51
- `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(a)}async prompt(e){if(ke())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${ie.cyan("?")} ${e} (y/n) `);let r=(n)=>{let i=n.toString().trim().toLowerCase();ce.stdin.removeListener("data",r);try{if(typeof ce.stdin.setRawMode==="function")ce.stdin.setRawMode(!1)}catch{}ce.stdin.pause(),console.error(""),t(i==="y"||i==="yes")};try{if(typeof ce.stdin.setRawMode==="function")ce.stdin.setRawMode(!0)}catch{}ce.stdin.resume(),ce.stdin.once("data",r)})}setFancy(e){this.fancy=e}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(e,...t){if(!this.enabled)return;let r=e;if(t&&t.length>0){let a=/%([sdijfo%])/g,o=0;if(r=e.replace(a,(c,f)=>{if(f==="%")return"%";if(o>=t.length)return c;let u=t[o++];switch(f){case"s":return String(u);case"d":case"i":return Number(u).toString();case"j":case"o":return JSON.stringify(u,null,2);default:return c}}),o<t.length)r+=` ${t.slice(o).map((c)=>typeof c==="object"?JSON.stringify(c,null,2):String(c)).join(" ")}`}let{consoleText:n,fileText:i}=this.buildOutputTexts(r);if(this.shouldStyleConsole()){let a=this.options.showTags!==!1&&this.name?ie.gray(this.formatTag(this.name)):"",o=this.options.showIcons===!1?"":`${ie.blue("\u25D0")} `;console.error(`${o}${a} ${ie.cyan(n)}`)}let s=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${i}
52
- `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(s)}renderProgressBar(e,t=!1){if(!this.enabled||!this.shouldStyleConsole()||!ce.stdout.isTTY)return;let r=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*r/100),i=e.barLength-n,s=ie.green("\u2501".repeat(n)),a=ie.gray("\u2501".repeat(i)),o=`[${s}${a}]`,c=`${r}%`.padStart(4),f=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":t||r===100?ie.green("\u2713"):ie.blue("\u25B6"),l=this.options.showTags!==!1&&this.name?` ${ie.gray(this.formatTag(this.name))}`:"",g=`\r${u}${l} ${o} ${c}${f}`,d=ce.stdout.columns||80,w=" ".repeat(Math.max(0,d-g.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${g}${w}`,ce.stdout.write(e.lastRenderedLine),t)ce.stdout.write(`
53
- `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||ke()||!ce.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(t)e.message=t;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(ke()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await Vr(this.config.logDirectory),r=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let i=Xt(this.config.logDirectory,n);if(e.before)try{if((await qt(i)).mtime>=e.before)continue}catch(s){console.error(`Failed to get stats for file ${i}:`,s);continue}r.push(i)}if(r.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${r.length} log file(s)...`);for(let n of r)try{await _r(n),console.warn(`Deleted log file: ${n}`)}catch(i){console.error(`Failed to delete log file ${n}:`,i)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}async function Tu(e,t={}){let{maxRetries:r=3,retryDelay:n=1000,isRetryable:i=()=>!0,fallback:s}=t,a=Error("Unknown error occurred");for(let o=0;o<=r;o++)try{return await e()}catch(c){if(a=c instanceof Error?c:Error(String(c)),o===r||!i(a))break;if(n>0)await new Promise((f)=>setTimeout(f,n))}if(s!==void 0)return s;throw a instanceof Error?a:Error(`Unknown error: ${String(a)}`)}class Gn{defaultParsers;constructor(){this.defaultParsers=[{name:"boolean",canParse:(e,t)=>t==="boolean"||["true","false","1","0","yes","no"].includes(e.toLowerCase()),parse:(e)=>{let t=e.toLowerCase();return["true","1","yes"].includes(t)}},{name:"number",canParse:(e,t)=>t==="number"||!Number.isNaN(Number(e))&&!Number.isNaN(Number.parseFloat(e)),parse:(e)=>{let t=Number(e);if(Number.isNaN(t))throw TypeError(`Cannot parse "${e}" as number`);return t}},{name:"array",canParse:(e,t)=>t==="array"||e.startsWith("[")||e.includes(","),parse:(e)=>{try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return e.split(",").map((t)=>t.trim())}},{name:"json",canParse:(e,t)=>t==="object"||(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")),parse:(e)=>{try{return JSON.parse(e)}catch(t){throw Error(`Cannot parse "${e}" as JSON: ${t}`)}}}]}async applyEnvironmentVariables(e,t,r={}){let{prefix:n,useCamelCase:i=!0,useBackwardCompatibility:s=!0,customParsers:a={},verbose:o=!1,trackPerformance:c=!0}=r,f=async()=>{if(!e)return{config:t,source:{type:"environment",priority:50,timestamp:new Date}};let u=n||this.generateEnvPrefix(e),l={...t};return this.processObject(l,[],u,{useCamelCase:i,useBackwardCompatibility:s,customParsers:a,verbose:o,configName:e}),{config:l,source:{type:"environment",priority:50,timestamp:new Date}}};if(c)return Pn.track("applyEnvironmentVariables",f,{configName:e});return f()}generateEnvPrefix(e){return e.toUpperCase().replace(/-/g,"_")}formatEnvKey(e,t){if(!t)return e.toUpperCase();return e.replace(/([A-Z])/g,"_$1").toUpperCase()}processObject(e,t,r,n){for(let[i,s]of Object.entries(e)){let a=[...t,i],o=a.map((u)=>this.formatEnvKey(u,n.useCamelCase)),c=`${r}_${o.join("_")}`,f=n.useBackwardCompatibility?`${r}_${a.map((u)=>u.toUpperCase()).join("_")}`:null;if(n.verbose);if(typeof s==="object"&&s!==null&&!Array.isArray(s))this.processObject(s,a,r,n);else{let u=Hr.env[c]||(f?Hr.env[f]:void 0);if(u!==void 0){if(n.verbose){let l=Hr.env[c]?c:f}try{e[i]=this.parseEnvironmentValue(u,typeof s,c,n.customParsers,n.configName)}catch(l){if(l instanceof Wn)throw l;throw er.envVar(c,u,typeof s,n.configName)}}}}}parseEnvironmentValue(e,t,r,n,i){for(let[s,a]of Object.entries(n))try{return a(e)}catch{continue}for(let s of this.defaultParsers)if(s.canParse(e,t))try{return s.parse(e)}catch{throw er.envVar(r,e,`${t} (via ${s.name} parser)`,i)}return e}getEnvironmentVariables(e){let t={},r=e.toUpperCase();for(let[n,i]of Object.entries(Hr.env))if(n.startsWith(r)&&i!==void 0)t[n]=i;return t}validateEnvironmentVariable(e,t,r){let n=[];if(!/^[A-Z_][A-Z0-9_]*$/.test(e))n.push(`Environment variable key "${e}" should only contain uppercase letters, numbers, and underscores`);if(r)try{this.parseEnvironmentValue(e,t,r,{})}catch(i){n.push(`Cannot parse value "${t}" as ${r}: ${i}`)}return{isValid:n.length===0,errors:n}}generateEnvVarDocs(e,t,r={}){let{prefix:n,format:i="text"}=r,s=n||this.generateEnvPrefix(e),a=[];switch(this.extractEnvVarInfo(t,[],s,a),i){case"markdown":return this.formatAsMarkdown(a,e);case"json":return JSON.stringify(a,null,2);default:return this.formatAsText(a,e)}}extractEnvVarInfo(e,t,r,n){for(let[i,s]of Object.entries(e)){let a=[...t,i],o=`${r}_${a.map((c)=>this.formatEnvKey(c,!0)).join("_")}`;if(typeof s==="object"&&s!==null&&!Array.isArray(s))this.extractEnvVarInfo(s,a,r,n);else n.push({key:o,type:Array.isArray(s)?"array":typeof s,description:`Configuration for ${a.join(".")}`,example:this.generateExample(s)})}}generateExample(e){if(Array.isArray(e))return JSON.stringify(e);if(typeof e==="object"&&e!==null)return JSON.stringify(e);return String(e)}formatAsText(e,t){let r=`Environment Variables for ${t}:
47
+ `;if(u=u.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(u)}progress(e,t=""){let r={update:(i,s)=>{},finish:(i)=>{},interrupt:(i,s)=>{}};if(!this.enabled)return r;let n=30;if(this.activeProgressBar={total:Math.max(1,e||1),current:0,message:t||"",barLength:n,lastRenderedLine:""},this.shouldStyleConsole()&&!De()&&fe.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(i,s)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,i),this.activeProgressBar.total),s!==void 0)this.activeProgressBar.message=s;if(this.shouldStyleConsole()&&!De()&&fe.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(i)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,i)},interrupt:(i,s="info")=>{if(!De()&&fe.stdout.isTTY)fe.stdout.write(`
48
+ `);if(this[s==="warning"?"warn":s](i),this.activeProgressBar&&this.shouldStyleConsole()&&!De()&&fe.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let t=performance.now();if(this.shouldStyleConsole()){let r=this.options.showTags!==!1&&this.name?re.gray(this.formatTag(this.name)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:this.options.showIcons===!1?"":re.blue("\u25D0"),tag:r,message:`${re.cyan(e)}...`}))}return async(r)=>{if(!this.enabled)return;let n=performance.now(),i=Math.round(n-t),s=`${e} completed in ${i}ms`,a=new Date,o=this.formatConsoleTimestamp(a),c=`${this.formatFileTimestamp(a)} ${this.environment}.INFO: ${s}`;if(r)c+=` ${JSON.stringify(r)}`;if(c+=`
49
+ `,c=c.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let f=this.options.showTags!==!1&&this.name?re.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:o,icon:this.options.showIcons===!1?"":re.green("\u2713"),tag:f,message:`${s}${r?` ${JSON.stringify(r)}`:""}`}))}else if(!De())console.error(c.trim());if(this.shouldWriteToFile())await this.writeToFile(c)}}async debug(e,...t){await this.log("debug",e,...t)}async info(e,...t){await this.log("info",e,...t)}async success(e,...t){await this.log("success",e,...t)}async warn(e,...t){await this.log("warning",e,...t)}async error(e,...t){await this.log("error",e,...t)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:t}=e;return!!t}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let t=`${this.name}:${e}`,r=new yi(t,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(r),r}createReadStream(){if(De())throw Error("createReadStream is not supported in browser environments");if(!_r(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return fa(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let t=this.config.rotation;if(!t.encrypt||typeof t.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let r=this.keys.get(this.currentKeyId);try{let n=dt.isBuffer(e)?e:dt.from(e,"base64"),i=n.subarray(0,16),s=n.subarray(n.length-16),a=n.subarray(16,n.length-16),o=lf("aes-256-gcm",r,i);o.setAuthTag(s);let c=o.update(a),f=o.final(),u=c.length+f.length,l=dt.allocUnsafe(u);return c.copy(l,0),f.copy(l,c.length),l.toString("utf8")}catch(n){throw Error(`Decryption failed: ${n instanceof Error?n.message:String(n)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return De()}isServerMode(){return!De()}setTestEncryptionKey(e,t){this.currentKeyId=e,this.keys.set(e,t)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(e){if(!this.enabled)return;let t=new Date,r=this.formatConsoleTimestamp(t),n=this.formatFileTimestamp(t),{consoleText:i,fileText:s}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let o=i.split(`
50
+ `),c=Math.max(...o.map((g)=>g.length))+2,f=`\u250C${"\u2500".repeat(c)}\u2510`,u=`\u2514${"\u2500".repeat(c)}\u2518`,l=o.map((g)=>{return this.formatConsoleMessage({timestamp:r,message:re.cyan(g),showTimestamp:!1})});console.error(this.formatConsoleMessage({timestamp:r,message:re.cyan(f),showTimestamp:!1})),l.forEach((g)=>console.error(g)),console.error(this.formatConsoleMessage({timestamp:r,message:re.cyan(u),showTimestamp:!1}))}else if(!De())console.error(`${n} ${this.environment}.INFO: [BOX] ${s}`);let a=`${n} ${this.environment}.INFO: [BOX] ${s}
51
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(a)}async prompt(e){if(De())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${re.cyan("?")} ${e} (y/n) `);let r=(n)=>{let i=n.toString().trim().toLowerCase();fe.stdin.removeListener("data",r);try{if(typeof fe.stdin.setRawMode==="function")fe.stdin.setRawMode(!1)}catch{}fe.stdin.pause(),console.error(""),t(i==="y"||i==="yes")};try{if(typeof fe.stdin.setRawMode==="function")fe.stdin.setRawMode(!0)}catch{}fe.stdin.resume(),fe.stdin.once("data",r)})}setFancy(e){this.fancy=e}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(e,...t){if(!this.enabled)return;let r=e;if(t&&t.length>0){let a=/%([sdijfo%])/g,o=0;if(r=e.replace(a,(c,f)=>{if(f==="%")return"%";if(o>=t.length)return c;let u=t[o++];switch(f){case"s":return String(u);case"d":case"i":return Number(u).toString();case"j":case"o":return JSON.stringify(u,null,2);default:return c}}),o<t.length)r+=` ${t.slice(o).map((c)=>typeof c==="object"?JSON.stringify(c,null,2):String(c)).join(" ")}`}let{consoleText:n,fileText:i}=this.buildOutputTexts(r);if(this.shouldStyleConsole()){let a=this.options.showTags!==!1&&this.name?re.gray(this.formatTag(this.name)):"",o=this.options.showIcons===!1?"":`${re.blue("\u25D0")} `;console.error(`${o}${a} ${re.cyan(n)}`)}let s=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${i}
52
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(s)}renderProgressBar(e,t=!1){if(!this.enabled||!this.shouldStyleConsole()||!fe.stdout.isTTY)return;let r=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*r/100),i=e.barLength-n,s=re.green("\u2501".repeat(n)),a=re.gray("\u2501".repeat(i)),o=`[${s}${a}]`,c=`${r}%`.padStart(4),f=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":t||r===100?re.green("\u2713"):re.blue("\u25B6"),l=this.options.showTags!==!1&&this.name?` ${re.gray(this.formatTag(this.name))}`:"",g=`\r${u}${l} ${o} ${c}${f}`,d=fe.stdout.columns||80,$=" ".repeat(Math.max(0,d-g.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${g}${$}`,fe.stdout.write(e.lastRenderedLine),t)fe.stdout.write(`
53
+ `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||De()||!fe.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(t)e.message=t;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(De()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await Hr(this.config.logDirectory),r=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let i=Xt(this.config.logDirectory,n);if(e.before)try{if((await qt(i)).mtime>=e.before)continue}catch(s){console.error(`Failed to get stats for file ${i}:`,s);continue}r.push(i)}if(r.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${r.length} log file(s)...`);for(let n of r)try{await jr(n),console.warn(`Deleted log file: ${n}`)}catch(i){console.error(`Failed to delete log file ${n}:`,i)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}async function Pu(e,t={}){let{maxRetries:r=3,retryDelay:n=1000,isRetryable:i=()=>!0,fallback:s}=t,a=Error("Unknown error occurred");for(let o=0;o<=r;o++)try{return await e()}catch(c){if(a=c instanceof Error?c:Error(String(c)),o===r||!i(a))break;if(n>0)await new Promise((f)=>setTimeout(f,n))}if(s!==void 0)return s;throw a instanceof Error?a:Error(`Unknown error: ${String(a)}`)}class Vn{defaultParsers;constructor(){this.defaultParsers=[{name:"boolean",canParse:(e,t)=>t==="boolean"||["true","false","1","0","yes","no"].includes(e.toLowerCase()),parse:(e)=>{let t=e.toLowerCase();return["true","1","yes"].includes(t)}},{name:"number",canParse:(e,t)=>t==="number"||!Number.isNaN(Number(e))&&!Number.isNaN(Number.parseFloat(e)),parse:(e)=>{let t=Number(e);if(Number.isNaN(t))throw TypeError(`Cannot parse "${e}" as number`);return t}},{name:"array",canParse:(e,t)=>t==="array"||e.startsWith("[")||e.includes(","),parse:(e)=>{try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return e.split(",").map((t)=>t.trim())}},{name:"json",canParse:(e,t)=>t==="object"||(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")),parse:(e)=>{try{return JSON.parse(e)}catch(t){throw Error(`Cannot parse "${e}" as JSON: ${t}`)}}}]}async applyEnvironmentVariables(e,t,r={}){let{prefix:n,useCamelCase:i=!0,useBackwardCompatibility:s=!0,customParsers:a={},verbose:o=!1,trackPerformance:c=!0}=r,f=async()=>{if(!e)return{config:t,source:{type:"environment",priority:50,timestamp:new Date}};let u=n||this.generateEnvPrefix(e),l={...t};return this.processObject(l,[],u,{useCamelCase:i,useBackwardCompatibility:s,customParsers:a,verbose:o,configName:e}),{config:l,source:{type:"environment",priority:50,timestamp:new Date}}};if(c)return Mn.track("applyEnvironmentVariables",f,{configName:e});return f()}generateEnvPrefix(e){return e.toUpperCase().replace(/-/g,"_")}formatEnvKey(e,t){if(!t)return e.toUpperCase();return e.replace(/([A-Z])/g,"_$1").toUpperCase()}processObject(e,t,r,n){for(let[i,s]of Object.entries(e)){let a=[...t,i],o=a.map((u)=>this.formatEnvKey(u,n.useCamelCase)),c=`${r}_${o.join("_")}`,f=n.useBackwardCompatibility?`${r}_${a.map((u)=>u.toUpperCase()).join("_")}`:null;if(n.verbose);if(typeof s==="object"&&s!==null&&!Array.isArray(s))this.processObject(s,a,r,n);else{let u=Kr.env[c]||(f?Kr.env[f]:void 0);if(u!==void 0){if(n.verbose){let l=Kr.env[c]?c:f}try{e[i]=this.parseEnvironmentValue(u,typeof s,c,n.customParsers,n.configName)}catch(l){if(l instanceof Bn)throw l;throw er.envVar(c,u,typeof s,n.configName)}}}}}parseEnvironmentValue(e,t,r,n,i){for(let[s,a]of Object.entries(n))try{return a(e)}catch{continue}for(let s of this.defaultParsers)if(s.canParse(e,t))try{return s.parse(e)}catch{throw er.envVar(r,e,`${t} (via ${s.name} parser)`,i)}return e}getEnvironmentVariables(e){let t={},r=e.toUpperCase();for(let[n,i]of Object.entries(Kr.env))if(n.startsWith(r)&&i!==void 0)t[n]=i;return t}validateEnvironmentVariable(e,t,r){let n=[];if(!/^[A-Z_][A-Z0-9_]*$/.test(e))n.push(`Environment variable key "${e}" should only contain uppercase letters, numbers, and underscores`);if(r)try{this.parseEnvironmentValue(e,t,r,{})}catch(i){n.push(`Cannot parse value "${t}" as ${r}: ${i}`)}return{isValid:n.length===0,errors:n}}generateEnvVarDocs(e,t,r={}){let{prefix:n,format:i="text"}=r,s=n||this.generateEnvPrefix(e),a=[];switch(this.extractEnvVarInfo(t,[],s,a),i){case"markdown":return this.formatAsMarkdown(a,e);case"json":return JSON.stringify(a,null,2);default:return this.formatAsText(a,e)}}extractEnvVarInfo(e,t,r,n){for(let[i,s]of Object.entries(e)){let a=[...t,i],o=`${r}_${a.map((c)=>this.formatEnvKey(c,!0)).join("_")}`;if(typeof s==="object"&&s!==null&&!Array.isArray(s))this.extractEnvVarInfo(s,a,r,n);else n.push({key:o,type:Array.isArray(s)?"array":typeof s,description:`Configuration for ${a.join(".")}`,example:this.generateExample(s)})}}generateExample(e){if(Array.isArray(e))return JSON.stringify(e);if(typeof e==="object"&&e!==null)return JSON.stringify(e);return String(e)}formatAsText(e,t){let r=`Environment Variables for ${t}:
54
54
 
55
55
  `;for(let n of e)r+=`${n.key}
56
56
  `,r+=` Type: ${n.type}
@@ -62,139 +62,141 @@ export type ConfigOf = Config
62
62
  `;r+=`| Variable | Type | Description | Example |
63
63
  `,r+=`|----------|------|-------------|----------|
64
64
  `;for(let n of e)r+=`| \`${n.key}\` | ${n.type} | ${n.description} | \`${n.example}\` |
65
- `;return r}}function Ru(e,t,r={}){return ro(e,t,r,new WeakMap)}function ro(e,t,r,n){let{arrayMergeMode:i="replace",skipNullish:s=!1,customMerger:a}=r;if(t===null||t===void 0)return s?e:t;if(a){let o=a(e,t);if(o!==void 0)return o}if(Array.isArray(t)||Array.isArray(e))return io(e,t,i,n);if(!ze(t)||!ze(e))return t;return Mu(e,t,r,n)}function io(e,t,r,n){if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(e)&&!Array.isArray(t))return t;if(Array.isArray(t)&&Array.isArray(e))switch(r){case"replace":return t;case"concat":return Ou(e,t);case"smart":return Pu(e,t,n);default:return t}return t}function Ou(e,t){let r=[...t];for(let n of e)if(!r.some((i)=>On(i,n)))r.push(n);return r}function Pu(e,t,r){if(t.length===0)return e;if(e.length===0)return t;if(ze(t[0])&&ze(e[0]))return ku(e,t,r);if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}function ku(e,t,r){let n=[...t];for(let i of e){if(!ze(i)){n.push(i);continue}let s=["id","name","key","path","type"],a=!1;for(let o of s)if(o in i){if(n.find((c)=>ze(c)&&(o in c)&&c[o]===i[o])){a=!0;break}}if(!a)n.push(i)}return n}function Mu(e,t,r,n){let i=t;if(ze(i)&&n.has(i))return n.get(i);let s={...e};if(ze(i))n.set(i,s);for(let a in i){if(!Object.prototype.hasOwnProperty.call(i,a))continue;let o=i[a],c=s[a];if(r.skipNullish&&(o===null||o===void 0))continue;if(o===null||o===void 0){s[a]=o;continue}if(ze(o)&&ze(c))s[a]=ro(c,o,r,n);else if(Array.isArray(o)||Array.isArray(c))s[a]=io(c,o,r.arrayMergeMode||"smart",n);else s[a]=o}return s}function no(e,t,r="replace"){return Ru(e,t,{arrayMergeMode:r==="replace"?"replace":"smart",skipNullish:!0})}function On(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!On(e[r],t[r]))return!1;return!0}if(ze(e)&&ze(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!On(e[i],t[i]))return!1}return!0}return!1}function ze(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class so{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(e,t,r={}){let{arrayStrategy:n="replace",useCache:i=!0,cacheTtl:s,trackPerformance:a=!0,verbose:o=!1}=r;if(i){let f=ri.getWithFileCheck("file",e);if(f){if(o)console.log(`Configuration loaded from cache: ${e}`);return f}}let c=async()=>{if(!jr(e))return null;try{let f=`?t=${Date.now()}`,u=await import(e+f),l=u.default||u,g="default"in u,d=Object.keys(u).length>0;if(!g&&!d)throw new fi(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof l!=="object"||l===null||Array.isArray(l))throw new fi(e,Error("Configuration must export a valid object"),"unknown");let w={config:no(t,l,n),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(i)ri.setWithFileCheck("file",w,e,s);return w}catch(f){throw f instanceof Error?er.configLoad(e,f):er.configLoad(e,Error(String(f)))}};if(a)return Pn.track("loadFromPath",c,{path:e});return c()}async tryLoadFromPaths(e,t,r={}){for(let n of e)try{let i=await this.loadFromPath(n,t,r);if(i)return i}catch(i){if(i instanceof Error&&i.name==="ConfigLoadError")throw i;if(r.verbose)console.warn(`Failed to load config from ${n}:`,i)}return null}generateConfigPaths(e,t,r){let n=this.generateNamePatterns(e,r),i=[];for(let s of n)for(let a of this.extensions)i.push(hn(t,`${s}${a}`));return i}generateNamePatterns(e,t){let r=[];if(r.push("config",".config"),e)r.push(e,`.${e}.config`,`${e}.config`,`.${e}`);let n=t===void 0?[]:Array.isArray(t)?t:[t];for(let s of n){if(!s)continue;if(r.push(s,`.${s}.config`,`${s}.config`,`.${s}`),e)r.push(`${e}.${s}.config`,`.${e}.${s}.config`)}let i=new Set;return r.filter((s)=>{if(!s||i.has(s))return!1;return i.add(s),!0})}checkFileAccess(e){return Tu(async()=>{return jr(e)},{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,r){let n=[];if(!jr(e))return n;if(t||r){let i=this.generateNamePatterns(t||"",r);for(let s of i)for(let a of this.extensions){let o=hn(e,`${s}${a}`);if(await this.checkFileAccess(o))n.push(o)}}else try{let{readdirSync:i}=await import("fs"),s=i(e);for(let a of s)if(this.looksLikeConfigFile(a)){let o=hn(e,a);if(await this.checkFileAccess(o))n.push(o)}}catch{return[]}return n}looksLikeConfigFile(e){return[/\.config\.(ts|js|mjs|cjs|json|mts|cts)$/,/^\..*\.(ts|js|mjs|cjs|json|mts|cts)$/,/config\.(ts|js|mjs|cjs|json|mts|cts)$/].some((t)=>t.test(e))}async validateConfigFile(e){let t=[];try{if(!jr(e))return t.push("Configuration file does not exist"),t;let r=await import(e),n=r.default||r;if(n===void 0)t.push("Configuration file must export a default value or named exports");else if(typeof n!=="object"||n===null)t.push("Configuration must be an object");else if(Array.isArray(n))t.push("Configuration cannot be an array at the root level");if(e.endsWith(".json"))try{let{readFileSync:i}=await import("fs"),s=i(e,"utf8");JSON.parse(s)}catch(i){t.push(`Invalid JSON syntax: ${i}`)}}catch(r){t.push(`Failed to load configuration file: ${r}`)}return t}async getFileModificationTime(e){try{let{statSync:t}=await import("fs");return t(e).mtime}catch{return null}}async preloadConfigurations(e,t={}){let r=new Map;return await Promise.allSettled(e.map(async(n)=>{try{let i=await this.loadFromPath(n,{},t);if(i)r.set(n,i.config)}catch(i){if(t.verbose)console.warn(`Failed to preload ${n}:`,i)}})),r}}class ao{async validateConfiguration(e,t,r={}){let{stopOnFirstError:n=!1,validateRequired:i=!0,validateTypes:s=!0,customRules:a=[],trackPerformance:o=!0,verbose:c=!1}=r,f=async()=>{let u=[],l=[],g={stopOnFirstError:n,validateRequired:i,validateTypes:s,customRules:a,trackPerformance:o,verbose:c};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,g);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...a],g);else return this.validateWithJSONSchema(e,t,g)}catch(d){return u.push({path:"",message:`Validation failed: ${d}`,rule:"system"}),{isValid:!1,errors:u,warnings:l}}};if(o)return await Pn.track("validateConfiguration",f);return f()}async validateWithSchemaFile(e,t,r){try{if(!df(t))throw new ui(t,[{path:"",message:"Schema file does not exist"}]);let n=await import(t),i=n.default||n;if(Array.isArray(i))return this.validateWithRules(e,i,r);else return this.validateWithJSONSchema(e,i,r)}catch(n){throw new ui(t,[{path:"",message:`Failed to load schema: ${n}`}])}}validateWithJSONSchema(e,t,r){let n=[],i=[];return this.validateObjectAgainstSchema(e,t,"",n,i,r),{isValid:n.length===0,errors:n,warnings:i}}validateObjectAgainstSchema(e,t,r,n,i,s){if(s.validateTypes&&t.type){let a=Array.isArray(e)?"array":typeof e,o=Array.isArray(t.type)?t.type:[t.type];if(!o.includes(a)){if(n.push({path:r,message:`Expected type ${o.join(" or ")}, got ${a}`,expected:o.join(" or "),actual:a,rule:"type"}),s.stopOnFirstError)return}}if(t.enum&&!t.enum.includes(e)){if(n.push({path:r,message:`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"}),s.stopOnFirstError)return}if(typeof e==="string"){if(t.minLength!==void 0&&e.length<t.minLength)n.push({path:r,message:`String length must be at least ${t.minLength}`,expected:`>= ${t.minLength}`,actual:e.length,rule:"minLength"});if(t.maxLength!==void 0&&e.length>t.maxLength)n.push({path:r,message:`String length must not exceed ${t.maxLength}`,expected:`<= ${t.maxLength}`,actual:e.length,rule:"maxLength"});if(t.pattern){if(!new RegExp(t.pattern).test(e))n.push({path:r,message:`String does not match pattern ${t.pattern}`,expected:t.pattern,actual:e,rule:"pattern"})}}if(typeof e==="number"){if(t.minimum!==void 0&&e<t.minimum)n.push({path:r,message:`Value must be at least ${t.minimum}`,expected:`>= ${t.minimum}`,actual:e,rule:"minimum"});if(t.maximum!==void 0&&e>t.maximum)n.push({path:r,message:`Value must not exceed ${t.maximum}`,expected:`<= ${t.maximum}`,actual:e,rule:"maximum"})}if(Array.isArray(e)&&t.items)for(let a=0;a<e.length;a++){let o=r?`${r}[${a}]`:`[${a}]`;if(this.validateObjectAgainstSchema(e[a],t.items,o,n,i,s),s.stopOnFirstError&&n.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let a=e;if(s.validateRequired&&t.required){for(let o of t.required)if(!(o in a)){if(n.push({path:r?`${r}.${o}`:o,message:`Missing required property '${o}'`,expected:"required",rule:"required"}),s.stopOnFirstError)return}}if(t.properties){for(let[o,c]of Object.entries(t.properties))if(o in a){let f=r?`${r}.${o}`:o;if(this.validateObjectAgainstSchema(a[o],c,f,n,i,s),s.stopOnFirstError&&n.length>0)return}}if(t.additionalProperties===!1){let o=new Set(Object.keys(t.properties||{}));for(let c of Object.keys(a))if(!o.has(c))i.push({path:r?`${r}.${c}`:c,message:`Additional property '${c}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,r){let n=[],i=[];for(let s of t)try{let a=this.getValueByPath(e,s.path),o=this.validateWithRule(a,s,s.path);if(n.push(...o),r.stopOnFirstError&&n.length>0)break}catch(a){n.push({path:s.path,message:`Rule validation failed: ${a}`,rule:"system"})}return{isValid:n.length===0,errors:n,warnings:i}}validateWithRule(e,t,r){let n=[];if(t.required&&(e===void 0||e===null))return n.push({path:r,message:t.message||`Property '${r}' is required`,expected:"required",rule:"required"}),n;if(e===void 0||e===null)return n;if(t.type){let i=Array.isArray(e)?"array":typeof e;if(i!==t.type)n.push({path:r,message:t.message||`Expected type ${t.type}, got ${i}`,expected:t.type,actual:i,rule:"type"})}if(t.min!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i<t.min)n.push({path:r,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:i,rule:"min"})}if(t.max!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i>t.max)n.push({path:r,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:i,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))n.push({path:r,message:t.message||`Value does not match pattern ${t.pattern}`,expected:t.pattern.toString(),actual:e,rule:"pattern"})}if(t.enum&&!t.enum.includes(e))n.push({path:r,message:t.message||`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"});if(t.validator){let i=t.validator(e);if(i)n.push({path:r,message:t.message||i,rule:"custom"})}return n}getValueByPath(e,t){if(!t)return e;let r=t.split("."),n=e;for(let i of r)if(n&&typeof n==="object"&&i in n)n=n[i];else return;return n}generateRulesFromInterface(e){let t=[],r=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let n of r){let[,i,s,a]=n;t.push({path:i,required:!s,type:this.mapTypeScriptType(a)})}return t}mapTypeScriptType(e){switch(e.toLowerCase()){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"object";default:return"object"}}static createCommonRules(){return{server:[{path:"port",required:!0,type:"number",min:1,max:65535},{path:"host",required:!0,type:"string",min:1},{path:"ssl",type:"boolean"}],database:[{path:"url",required:!0,type:"string",min:1},{path:"pool",type:"number",min:1,max:100},{path:"timeout",type:"number",min:0}],api:[{path:"baseUrl",required:!0,type:"string",pattern:Iu},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}function Du(e){if(!e)return"";let t=Array.isArray(e)?e.filter(Boolean):[e];if(t.length===0)return"";if(t.length===1)return` or alias "${t[0]}"`;return` or aliases ${t.map((r)=>`"${r}"`).join(", ")}`}class oo{fileLoader=new so;envProcessor=new Gn;validator=new ao;async loadConfig(e){let t=Date.now(),{cache:r,performance:n,schema:i,validate:s,...a}=e;try{if(r?.enabled){let c=this.checkCache(a.name||"",a);if(c)return c}let o;try{o=await this.loadConfigurationStrategies(a,!0,r)}catch(c){let f=a.__strictErrorHandling;if(c instanceof Error&&c.name==="ConfigNotFoundError"){if(f)throw c;o={...await this.applyEnvironmentVariables(a.name||"",a.defaultConfig,a.checkEnv!==!1,a.verbose||!1),warnings:[`No configuration file found for "${a.name||"config"}", using defaults with environment variables`]}}else if(c instanceof Error&&c.name==="ConfigLoadError"){let u=c.message.includes("EACCES")||c.message.includes("EPERM")||c.message.includes("permission denied"),l=!u&&(c.message.includes("syntax")||c.message.includes("Expected")||c.message.includes("Unexpected")||c.message.includes("BuildMessage")||c.message.includes("errors building")),g=c.message.includes("Configuration must export a valid object")||c.message.includes("Configuration file is empty and exports nothing");if(f&&(g||u))throw c;if(l&&(!f||!g))o={...await this.applyEnvironmentVariables(a.name||"",a.defaultConfig,a.checkEnv!==!1,a.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!f)o={...await this.applyEnvironmentVariables(a.name||"",a.defaultConfig,a.checkEnv!==!1,a.verbose||!1),warnings:[`Configuration loading error, using defaults: ${c.message}`]};else throw c}else o={...await this.applyEnvironmentVariables(a.name||"",a.defaultConfig,a.checkEnv!==!1,a.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${c instanceof Error?c.message:String(c)}`]}}if(i||s)await this.validateConfiguration(o.config,i,s,a.name);if(r?.enabled&&o)this.cacheResult(a.name||"",o,r,a);if(n?.enabled){let c={operation:"loadConfig",duration:Date.now()-t,configName:a.name,timestamp:new Date};if(n.onMetrics)n.onMetrics(c);if(n.slowThreshold&&c.duration>n.slowThreshold)mt.warn(`Slow configuration loading detected: ${c.duration}ms for ${a.name}`);o.metrics=c}return o}catch(o){if(o instanceof Error&&o.name==="ConfigNotFoundError")throw o;let c=Date.now()-t;throw mt.error(`Configuration loading failed after ${c}ms:`,[o instanceof Error?o:Error(String(o))]),o}}async loadConfigurationStrategies(e,t=!1,r){let{name:n="",alias:i,cwd:s,configDir:a,defaultConfig:o,checkEnv:c=!0,arrayStrategy:f="replace",verbose:u=!1}=e,l=s||hi.cwd(),g=[],d=await this.loadLocalConfiguration(n,i,l,a,o,f,u,c,r);if(d)return g.push(...this.getLocalSearchPaths(n,i,l,a)),this.finalizeResult(d,g,c,n,u);let w=await this.loadHomeConfiguration(n,i,o,f,u,c);if(w)return g.push(...this.getHomeSearchPaths(n,i)),this.finalizeResult(w,g,c,n,u);let E=await this.loadPackageJsonConfiguration(n,i,l,o,f,u,c);if(E)return g.push(qe(l,"package.json")),this.finalizeResult(E,g,c,n,u);if(g.push(...this.getAllSearchPaths(n,i,l,a)),t)throw er.configNotFound(n,g,i);return{...await this.applyEnvironmentVariables(n,o,c,u),warnings:[`No configuration file found for "${n}"${Du(i)}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,r,n,i,s,a,o,c){let f=o?Jr(e,i,a):i,u=this.getLocalDirectories(r,n);for(let l of u){if(a)mt.info(`Searching for configuration in: ${l}`);let g=this.fileLoader.generateConfigPaths(e,l,t),d=await this.fileLoader.tryLoadFromPaths(g,f,{arrayStrategy:s,verbose:a,cacheTtl:c?.ttl,useCache:!c?.ttl||c.ttl>100});if(d){if(a)mt.success(`Configuration loaded from: ${d.source.path}`);return d}}return null}async loadHomeConfiguration(e,t,r,n,i,s){if(!e)return null;let a=s?Jr(e,r,i):r,o=[qe(_t(),".config",e),qe(_t(),".config"),_t()];for(let c of o){if(i)mt.info(`Checking home directory: ${c}`);let f=this.fileLoader.generateConfigPaths(e,c,t),u=await this.fileLoader.tryLoadFromPaths(f,a,{arrayStrategy:n,verbose:i});if(u){if(i)mt.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,t,r,n,i,s,a){let o=a?Jr(e,n,s):n;try{let c=qe(r,"package.json");if(!xc(c))return null;let f={};try{f=JSON.parse(Tc(c,"utf8"))}catch(g){if(s)mt.warn("Failed to parse package.json:",[g instanceof Error?g:Error(String(g))]);return null}let u=f[e],l=e;if(!u&&t){let g=Array.isArray(t)?t:[t];for(let d of g){if(!d)continue;if(f[d]){u=f[d],l=d;break}}}if(u&&typeof u==="object"&&!Array.isArray(u)){if(s)mt.success(`Configuration loaded from package.json: ${l}`);return{config:no(o,u,i),source:{type:"package.json",path:c,priority:30,timestamp:new Date}}}}catch(c){if(s)mt.warn("Failed to load package.json:",[c instanceof Error?c:Error(String(c))])}return null}async applyEnvironmentVariables(e,t,r,n){if(!r||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:Jr(e,t,n),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,r,n,i){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,r,n){let i=[];if(r){let s=r(e);if(s)i.push(...s)}if(t){let s=await this.validator.validateConfiguration(e,t);if(!s.isValid)i.push(...s.errors.map((a)=>a.path?`${a.path}: ${a.message}`:a.message))}if(i.length>0)throw er.configValidation(n||"unknown",i,n)}checkCache(e,t){let r=this.generateCacheKey(e,t);return ri.get(r)||null}cacheResult(e,t,r,n){let i=this.generateCacheKey(e,n);ri.set(i,t,void 0,r.ttl)}generateCacheKey(e,t){let r=[e];if(t.alias){let n=Array.isArray(t.alias)?t.alias.join(","):t.alias;r.push(`alias:${n}`)}if(t.cwd)r.push(`cwd:${t.cwd}`);if(t.configDir)r.push(`configDir:${t.configDir}`);if("checkEnv"in t)r.push(`checkEnv:${t.checkEnv}`);return r.join("|")}getLocalDirectories(e,t){return Array.from(new Set([e,qe(e,"config"),qe(e,".config"),t?qe(e,t):void 0].filter(Boolean)))}getAllSearchPaths(e,t,r,n){let i=[];return i.push(...this.getLocalSearchPaths(e,t,r,n)),i.push(...this.getHomeSearchPaths(e,t)),i.push(qe(r,"package.json")),i}getLocalSearchPaths(e,t,r,n){let i=this.getLocalDirectories(r,n),s=[];for(let a of i)s.push(...this.fileLoader.generateConfigPaths(e,a,t));return s}getHomeSearchPaths(e,t){if(!e)return[];let r=[qe(_t(),".config",e),qe(_t(),".config"),_t()],n=[];for(let i of r)n.push(...this.fileLoader.generateConfigPaths(e,i,t));return n}async loadConfigWithResult(e){return this.loadConfig(e)}}function Jr(e,t,r=!1){let n=new Gn,i=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function s(a,o=[]){let c={...a};for(let[f,u]of Object.entries(a)){let l=[...o,f],g=[`${i}_${l.join("_").toUpperCase()}`,`${i}_${l.map((E)=>E.toUpperCase()).join("")}`,`${i}_${l.map((E)=>E.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],d,w;for(let E of g)if(d=hi.env[E],d!==void 0){w=E;break}if(d!==void 0&&w)if(typeof u==="boolean")c[f]=["true","1","yes"].includes(d.toLowerCase());else if(typeof u==="number"){let E=Number(d);if(!Number.isNaN(E))c[f]=E}else if(Array.isArray(u))try{c[f]=JSON.parse(d)}catch{c[f]=d.split(",").map((E)=>E.trim())}else c[f]=d;else if(u&&typeof u==="object"&&!Array.isArray(u))c[f]=s(u,l)}return c}return s(t)}var ri,Pn,mf,pf=(e)=>e,yf=(e,t)=>{for(var r in t)mf(e,r,{get:t[r],enumerable:!0,configurable:!0,set:gf.bind(t,r)})},Cf=(e,t)=>()=>(e&&(t=e(e=0)),t),Pa,Ga,Qt,mr,Ba,Kf,Jf,ma,Yr,En,We,pe,Uf,pa,Yf,ga,Zf,qf,dn,Xf,ya,Ca,mn,zf,Qf,eu,tu,Zr,Va,ru,Ge,iu,nu,wa,qr,vn,Pe,re,su,$a,au,Ea,ou,lu,pn,cu,va,Sa,fu,gn,uu,hu,du,mu,pu,Xr,_a,gu,yu="0.15.6",Ue,oi,hr,Sn,bn,li,An,xn,dr,Tn,Rn,Rt,Ha,ja,st,Ct,Ka,Ja,Cu,$u,Ua,ci,dg,Fe,ie,mg,vu,pg,Su,gg,yg,ba,Cg,bu,Au,wg,Aa,$g,Eg,vg,Sg,bg,yn,xu,Ag,at,Za,fi,qa,Xa,Wn,za,Qa,ui,eo,to,er,Iu,mt,xg,Tg,Rg,Fu,lo;var co=oe(()=>{ri=new Ra,Pn=new Oa,mf=Object.defineProperty;Pa={};yf(Pa,{withErrorRecovery:()=>Ia,tryLoadConfig:()=>Vf,loadConfigWithResult:()=>Gf,loadConfig:()=>Wa,isRetryableError:()=>If,isConfigNotFoundError:()=>Mf,isBunfigError:()=>Da,globalPerformanceMonitor:()=>mr,globalCache:()=>Qt,getEnvOrDefault:()=>Df,generateConfigTypes:()=>_f,defaultGeneratedDir:()=>Ja,defaultConfigDir:()=>Ka,deepMergeWithArrayStrategy:()=>Fn,deepMerge:()=>Fa,createLibraryConfig:()=>Hf,config:()=>Bf,bunfigPlugin:()=>jf,applyEnvVarsToConfig:()=>fr,TypeGenerationError:()=>xn,SchemaValidationError:()=>dr,PluginError:()=>Rn,PerformanceMonitor:()=>Mn,FileSystemError:()=>An,ErrorFactory:()=>Rt,EnvVarError:()=>li,EnvProcessor:()=>di,ConfigValidator:()=>Nn,ConfigValidationError:()=>Sn,ConfigNotFoundError:()=>oi,ConfigMergeError:()=>bn,ConfigLoader:()=>Ln,ConfigLoadError:()=>hr,ConfigFileLoader:()=>mi,ConfigCache:()=>kn,CacheUtils:()=>Ba,BunfigError:()=>Ue,BrowserConfigError:()=>Tn,ArrayMergeStrategies:()=>Ha});Cu=Cf(async()=>{Ga=import.meta.require,Qt=new kn,mr=new Mn,Ba={createKey:wf,isEquivalent:$f,estimateMemoryUsage:Ef},Kf=ei(wn.cwd(),"config"),Jf=ei(wn.cwd(),"src/generated"),ma=Qr.env.CLARITY_LOG_DIR||Ic(bf(),"logs"),Yr={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:ma,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1},En=await Af(),We={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,reset:"\x1B[0m"},pe=We,Uf=We.red,pa=We.green,Yf=We.yellow,ga=We.blue,Zf=We.magenta,qf=We.cyan,dn=We.white,Xf=We.gray,ya=We.bgRed,Ca=We.bgYellow,mn=We.bold,zf=We.dim,Qf=We.italic,eu=We.underline,tu=We.reset,Zr={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Va={debug:"\uD83D\uDD0D",info:ga("\u2139"),success:pa("\u2713"),warning:Ca(dn(mn(" WARN "))),error:ya(dn(mn(" ERROR ")))},ru=new ni("stacks"),Ge=new ni("bunfig",{showTags:!0}),iu=_e(ur.cwd(),"config"),nu=_e(ur.cwd(),"src/generated"),wa=zr.env.CLARITY_LOG_DIR||kc(Of(),"logs"),qr={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:wa,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},vn=await Pf(),Pe={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bgGray:(e)=>`\x1B[100m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,strikethrough:(e)=>`\x1B[9m${e}\x1B[0m`,reset:"\x1B[0m"},re=Pe,su=Pe.red,$a=Pe.green,au=Pe.yellow,Ea=Pe.blue,ou=Pe.magenta,lu=Pe.cyan,pn=Pe.white,cu=Pe.gray,va=Pe.bgRed,Sa=Pe.bgYellow,fu=Pe.bgGray,gn=Pe.bold,uu=Pe.dim,hu=Pe.italic,du=Pe.underline,mu=Pe.strikethrough,pu=Pe.reset,Xr={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},_a={debug:"\uD83D\uDD0D",info:Ea("\u2139"),success:$a("\u2713"),warning:Sa(pn(gn(" WARN "))),error:va(pn(gn(" ERROR ")))},gu=new ai("stacks"),Ue=class extends Error{timestamp;context;constructor(e,t={}){super(e);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}toString(){let e=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([t,r])=>`${t}: ${r}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${e}`}},oi=class extends Ue{code="CONFIG_NOT_FOUND";constructor(e,t,r){let n=r?` or alias "${r}"`:"";super(`Configuration "${e}"${n} not found`,{configName:e,alias:r,searchPaths:t,searchPathCount:t.length})}},hr=class extends Ue{code="CONFIG_LOAD_ERROR";constructor(e,t,r){super(`Failed to load configuration from "${e}": ${t.message}`,{configPath:e,configName:r,originalError:t.name,originalMessage:t.message});this.cause=t}},Sn=class extends Ue{code="CONFIG_VALIDATION_ERROR";constructor(e,t,r){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:r,validationErrors:t,errorCount:t.length})}},bn=class extends Ue{code="CONFIG_MERGE_ERROR";constructor(e,t,r,n){super(`Failed to merge configuration from "${e}" with "${t}": ${r.message}`,{sourcePath:e,targetPath:t,configName:n,originalError:r.name,originalMessage:r.message});this.cause=r}},li=class extends Ue{code="ENV_VAR_ERROR";constructor(e,t,r,n){super(`Failed to parse environment variable "${e}" with value "${t}" as ${r}`,{envKey:e,envValue:t,expectedType:r,configName:n})}},An=class extends Ue{code="FILE_SYSTEM_ERROR";constructor(e,t,r){super(`File system ${e} failed for "${t}": ${r.message}`,{operation:e,path:t,originalError:r.name,originalMessage:r.message});this.cause=r}},xn=class extends Ue{code="TYPE_GENERATION_ERROR";constructor(e,t,r){super(`Failed to generate types from "${e}" to "${t}": ${r.message}`,{configDir:e,outputPath:t,originalError:r.name,originalMessage:r.message});this.cause=r}},dr=class extends Ue{code="SCHEMA_VALIDATION_ERROR";constructor(e,t,r){super(`Schema validation failed${r?` for config "${r}"`:""}`,{schemaPath:e,configName:r,validationErrors:t,errorCount:t.length})}},Tn=class extends Ue{code="BROWSER_CONFIG_ERROR";constructor(e,t,r,n){super(`Failed to fetch configuration from "${e}": ${t} ${r}`,{endpoint:e,status:t,statusText:r,configName:n})}},Rn=class extends Ue{code="PLUGIN_ERROR";constructor(e,t,r){super(`Plugin "${e}" failed during ${t}: ${r.message}`,{pluginName:e,operation:t,originalError:r.name,originalMessage:r.message});this.cause=r}},Rt={configNotFound(e,t,r){return new oi(e,t,r)},configLoad(e,t,r){return new hr(e,t,r)},configValidation(e,t,r){return new Sn(e,t,r)},configMerge(e,t,r,n){return new bn(e,t,r,n)},envVar(e,t,r,n){return new li(e,t,r,n)},fileSystem(e,t,r){return new An(e,t,r)},typeGeneration(e,t,r){return new xn(e,t,r)},schemaValidation(e,t,r){return new dr(e,t,r)},browserConfig(e,t,r,n){return new Tn(e,t,r,n)},plugin(e,t,r){return new Rn(e,t,r)}},Ha={replace:"replace",concat:"concat",smart:"smart"},ja=/^https?:\/\//,st=new ai("bunfig",{showTags:!0}),Ct=new Ln,Ka=He(kt.cwd(),"config"),Ja=He(kt.cwd(),"src/generated")});$u=ti.env.CLARITY_LOG_DIR||tf(wu(),"logs"),Ua={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:$u,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},ci={...Ua},dg=(async()=>{try{let{loadConfig:e}=await Cu().then(()=>Pa),t=await e({name:"clarity",alias:"logging",defaultConfig:Ua,cwd:ti.cwd()});if(t)Object.assign(ci,t)}catch{}return ci})();Fe={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bgGray:(e)=>`\x1B[100m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,strikethrough:(e)=>`\x1B[9m${e}\x1B[0m`,reset:"\x1B[0m"},ie=Fe,mg=Fe.red,vu=Fe.green,pg=Fe.yellow,Su=Fe.blue,gg=Fe.magenta,yg=Fe.cyan,ba=Fe.white,Cg=Fe.gray,bu=Fe.bgRed,Au=Fe.bgYellow,wg=Fe.bgGray,Aa=Fe.bold,$g=Fe.dim,Eg=Fe.italic,vg=Fe.underline,Sg=Fe.strikethrough,bg=Fe.reset,yn={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},xu={debug:"\uD83D\uDD0D",info:Su("\u2139"),success:vu("\u2713"),warning:Au(ba(Aa(" WARN "))),error:bu(ba(Aa(" ERROR ")))};Ag=new pi("stacks");at=class at extends Error{timestamp;context;constructor(e,t={}){super(e);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}toString(){let e=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([t,r])=>`${t}: ${r}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${e}`}};Za=class Za extends at{code="CONFIG_NOT_FOUND";constructor(e,t,r){let n=r===void 0?[]:Array.isArray(r)?r.filter(Boolean):[r],i="";if(n.length===1)i=` or alias "${n[0]}"`;else if(n.length>1)i=` or aliases ${n.map((s)=>`"${s}"`).join(", ")}`;super(`Configuration "${e}"${i} not found`,{configName:e,alias:r,searchPaths:t,searchPathCount:t.length})}};fi=class fi extends at{code="CONFIG_LOAD_ERROR";constructor(e,t,r){super(`Failed to load configuration from "${e}": ${t.message}`,{configPath:e,configName:r,originalError:t.name,originalMessage:t.message});this.cause=t}};qa=class qa extends at{code="CONFIG_VALIDATION_ERROR";constructor(e,t,r){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:r,validationErrors:t,errorCount:t.length})}};Xa=class Xa extends at{code="CONFIG_MERGE_ERROR";constructor(e,t,r,n){super(`Failed to merge configuration from "${e}" with "${t}": ${r.message}`,{sourcePath:e,targetPath:t,configName:n,originalError:r.name,originalMessage:r.message});this.cause=r}};Wn=class Wn extends at{code="ENV_VAR_ERROR";constructor(e,t,r,n){super(`Failed to parse environment variable "${e}" with value "${t}" as ${r}`,{envKey:e,envValue:t,expectedType:r,configName:n})}};za=class za extends at{code="FILE_SYSTEM_ERROR";constructor(e,t,r){super(`File system ${e} failed for "${t}": ${r.message}`,{operation:e,path:t,originalError:r.name,originalMessage:r.message});this.cause=r}};Qa=class Qa extends at{code="TYPE_GENERATION_ERROR";constructor(e,t,r){super(`Failed to generate types from "${e}" to "${t}": ${r.message}`,{configDir:e,outputPath:t,originalError:r.name,originalMessage:r.message});this.cause=r}};ui=class ui extends at{code="SCHEMA_VALIDATION_ERROR";constructor(e,t,r){super(`Schema validation failed${r?` for config "${r}"`:""}`,{schemaPath:e,configName:r,validationErrors:t,errorCount:t.length})}};eo=class eo extends at{code="BROWSER_CONFIG_ERROR";constructor(e,t,r,n){super(`Failed to fetch configuration from "${e}": ${t} ${r}`,{endpoint:e,status:t,statusText:r,configName:n})}};to=class to extends at{code="PLUGIN_ERROR";constructor(e,t,r){super(`Plugin "${e}" failed during ${t}: ${r.message}`,{pluginName:e,operation:t,originalError:r.name,originalMessage:r.message});this.cause=r}};er={configNotFound(e,t,r){return new Za(e,t,r)},configLoad(e,t,r){return new fi(e,t,r)},configValidation(e,t,r){return new qa(e,t,r)},configMerge(e,t,r,n){return new Xa(e,t,r,n)},envVar(e,t,r,n){return new Wn(e,t,r,n)},fileSystem(e,t,r){return new za(e,t,r)},typeGeneration(e,t,r){return new Qa(e,t,r)},schemaValidation(e,t,r){return new ui(e,t,r)},browserConfig(e,t,r,n){return new eo(e,t,r,n)},plugin(e,t,r){return new to(e,t,r)}};Iu=/^https?:\/\//;mt=new pi("bunfig",{showTags:!0});xg=new oo;Tg=qe(hi.cwd(),"config"),Rg=qe(hi.cwd(),"src/generated"),Fu={cwd:Ac.cwd(),root:"./src",entrypoints:["**/*.{ts,tsx,mts,cts,vue,stx}"],outdir:"./dist",keepComments:!0,clean:!0,tsconfigPath:"./tsconfig.json",outputStructure:"mirror",verbose:!1,importOrder:["bun"],declarationMap:!1},lo=Fu});var fo;var uo=oe(()=>{fo=new Set(["ANGLE_instanced_arrays","ARIAMixin","AacBitstreamFormat","AacEncoderConfig","AbortController","AbortSignal","AbortSignalEventMap","AbstractRange","AbstractWorker","AbstractWorkerEventMap","ActiveXObject","AddEventListenerOptions","AddressErrors","AddressType","AddressValue","AesCbcParams","AesCtrParams","AesDerivedKeyParams","AesGcmParams","AesKeyAlgorithm","AesKeyGenParams","AggregateError","AggregateErrorConstructor","Algorithm","AlgorithmIdentifier","AlignSetting","AllAcceptedCredentialsOptions","AllowSharedBufferSource","AlphaOption","AnalyserNode","AnalyserOptions","Animatable","Animation","AnimationEffect","AnimationEvent","AnimationEventInit","AnimationEventMap","AnimationFrameProvider","AnimationPlayState","AnimationPlaybackEvent","AnimationPlaybackEventInit","AnimationReplaceState","AnimationTimeline","AppendMode","Array","ArrayBuffer","ArrayBufferConstructor","ArrayBufferLike","ArrayBufferTypes","ArrayBufferView","ArrayConstructor","ArrayIterator","ArrayLike","AssignedNodesOptions","AsyncDisposable","AsyncDisposableStack","AsyncDisposableStackConstructor","AsyncGenerator","AsyncGeneratorFunction","AsyncGeneratorFunctionConstructor","AsyncIterable","AsyncIterableIterator","AsyncIterator","AsyncIteratorObject","Atomics","AttestationConveyancePreference","Attr","Audio","AudioBuffer","AudioBufferOptions","AudioBufferSourceNode","AudioBufferSourceOptions","AudioConfiguration","AudioContext","AudioContextLatencyCategory","AudioContextOptions","AudioContextState","AudioData","AudioDataCopyToOptions","AudioDataInit","AudioDataOutputCallback","AudioDecoder","AudioDecoderConfig","AudioDecoderEventMap","AudioDecoderInit","AudioDecoderSupport","AudioDestinationNode","AudioEncoder","AudioEncoderConfig","AudioEncoderEventMap","AudioEncoderInit","AudioEncoderSupport","AudioListener","AudioNode","AudioNodeOptions","AudioParam","AudioParamMap","AudioProcessingEvent","AudioProcessingEventInit","AudioSampleFormat","AudioScheduledSourceNode","AudioScheduledSourceNodeEventMap","AudioTimestamp","AudioWorklet","AudioWorkletNode","AudioWorkletNodeEventMap","AudioWorkletNodeOptions","AuthenticationExtensionsClientInputs","AuthenticationExtensionsClientInputsJSON","AuthenticationExtensionsClientOutputs","AuthenticationExtensionsClientOutputsJSON","AuthenticationExtensionsLargeBlobInputs","AuthenticationExtensionsLargeBlobInputsJSON","AuthenticationExtensionsLargeBlobOutputs","AuthenticationExtensionsLargeBlobOutputsJSON","AuthenticationExtensionsPRFInputs","AuthenticationExtensionsPRFInputsJSON","AuthenticationExtensionsPRFOutputs","AuthenticationExtensionsPRFOutputsJSON","AuthenticationExtensionsPRFValues","AuthenticationExtensionsPRFValuesJSON","AuthenticationResponseJSON","AuthenticatorAssertionResponse","AuthenticatorAssertionResponseJSON","AuthenticatorAttachment","AuthenticatorAttestationResponse","AuthenticatorAttestationResponseJSON","AuthenticatorResponse","AuthenticatorSelectionCriteria","AuthenticatorTransport","AutoFill","AutoFillAddressKind","AutoFillBase","AutoFillContactField","AutoFillContactKind","AutoFillCredentialField","AutoFillField","AutoFillNormalField","AutoFillSection","AutoKeyword","AutomationRate","AvcBitstreamFormat","AvcEncoderConfig","Awaited","BarProp","Base64URLString","BaseAudioContext","BaseAudioContextEventMap","BeforeUnloadEvent","BigInt","BigInt64Array","BigInt64ArrayConstructor","BigIntConstructor","BigIntToLocaleStringOptions","BigInteger","BigUint64Array","BigUint64ArrayConstructor","BinaryType","BiquadFilterNode","BiquadFilterOptions","BiquadFilterType","BitrateMode","Blob","BlobCallback","BlobEvent","BlobEventInit","BlobPart","BlobPropertyBag","Body","BodyInit","Boolean","BooleanConstructor","BroadcastChannel","BroadcastChannelEventMap","Buffer","BufferEncoding","BufferSource","BuiltinIteratorReturn","Bun","BunFile","ByteLengthQueuingStrategy","CDATASection","COSEAlgorithmIdentifier","CSS","CSSAnimation","CSSConditionRule","CSSContainerRule","CSSCounterStyleRule","CSSFontFaceRule","CSSFontFeatureValuesRule","CSSFontPaletteValuesRule","CSSGroupingRule","CSSImageValue","CSSImportRule","CSSKeyframeRule","CSSKeyframesRule","CSSKeywordValue","CSSKeywordish","CSSLayerBlockRule","CSSLayerStatementRule","CSSMathClamp","CSSMathInvert","CSSMathMax","CSSMathMin","CSSMathNegate","CSSMathOperator","CSSMathProduct","CSSMathSum","CSSMathValue","CSSMatrixComponent","CSSMatrixComponentOptions","CSSMediaRule","CSSNamespaceRule","CSSNestedDeclarations","CSSNumberish","CSSNumericArray","CSSNumericBaseType","CSSNumericType","CSSNumericValue","CSSPageDescriptors","CSSPageRule","CSSPerspective","CSSPerspectiveValue","CSSPositionTryDescriptors","CSSPositionTryRule","CSSPropertyRule","CSSRotate","CSSRule","CSSRuleList","CSSScale","CSSScopeRule","CSSSkew","CSSSkewX","CSSSkewY","CSSStartingStyleRule","CSSStyleDeclaration","CSSStyleDeclarationBase","CSSStyleProperties","CSSStyleRule","CSSStyleSheet","CSSStyleSheetInit","CSSStyleValue","CSSSupportsRule","CSSTransformComponent","CSSTransformValue","CSSTransition","CSSTranslate","CSSUnitValue","CSSUnparsedSegment","CSSUnparsedValue","CSSVariableReferenceValue","CSSViewTransitionRule","Cache","CacheQueryOptions","CacheStorage","CalendarLike","CallableFunction","CanPlayTypeResult","CanvasCaptureMediaStreamTrack","CanvasCompositing","CanvasDirection","CanvasDrawImage","CanvasDrawPath","CanvasFillRule","CanvasFillStrokeStyles","CanvasFilters","CanvasFontKerning","CanvasFontStretch","CanvasFontVariantCaps","CanvasGradient","CanvasImageData","CanvasImageSmoothing","CanvasImageSource","CanvasLineCap","CanvasLineJoin","CanvasPath","CanvasPathDrawingStyles","CanvasPattern","CanvasRect","CanvasRenderingContext2D","CanvasRenderingContext2DSettings","CanvasSettings","CanvasShadowStyles","CanvasState","CanvasText","CanvasTextAlign","CanvasTextBaseline","CanvasTextDrawingStyles","CanvasTextRendering","CanvasTransform","CanvasUserInterface","Capitalize","CaretPosition","CaretPositionFromPointOptions","ChannelCountMode","ChannelInterpretation","ChannelMergerNode","ChannelMergerOptions","ChannelSplitterNode","ChannelSplitterOptions","CharacterData","CheckVisibilityOptions","ChildNode","ClassAccessorDecoratorContext","ClassAccessorDecoratorResult","ClassAccessorDecoratorTarget","ClassDecorator","ClassDecoratorContext","ClassFieldDecoratorContext","ClassGetterDecoratorContext","ClassMemberDecoratorContext","ClassMethodDecoratorContext","ClassSetterDecoratorContext","Client","ClientQueryOptions","ClientRect","ClientTypes","Clients","Clipboard","ClipboardEvent","ClipboardEventInit","ClipboardItem","ClipboardItemData","ClipboardItemOptions","ClipboardItems","CloseEvent","CloseEventInit","CodecState","Collator","CollatorConstructor","CollatorOptions","ColorGamut","ColorSpaceConversion","CommandEvent","CommandEventInit","Comment","CompileError","CompositeOperation","CompositeOperationOrAuto","CompositionEvent","CompositionEventInit","CompressionFormat","CompressionStream","ComputedEffectTiming","ComputedKeyframe","ConcatArray","Console","ConstantSourceNode","ConstantSourceOptions","ConstrainBoolean","ConstrainBooleanOrDOMString","ConstrainBooleanOrDOMStringParameters","ConstrainBooleanParameters","ConstrainDOMString","ConstrainDOMStringParameters","ConstrainDouble","ConstrainDoubleRange","ConstrainULong","ConstrainULongRange","ConstructorParameters","ContentVisibilityAutoStateChangeEvent","ContentVisibilityAutoStateChangeEventInit","ConvolverNode","ConvolverOptions","CookieChangeEvent","CookieChangeEventInit","CookieInit","CookieList","CookieListItem","CookieSameSite","CookieStore","CookieStoreDeleteOptions","CookieStoreEventMap","CookieStoreGetOptions","CookieStoreManager","CountQueuingStrategy","Credential","CredentialCreationOptions","CredentialMediationRequirement","CredentialPropertiesOutput","CredentialRequestOptions","CredentialsContainer","Crypto","CryptoKey","CryptoKeyPair","CurrentUserDetailsOptions","CustomElementConstructor","CustomElementRegistry","CustomEvent","CustomEventInit","CustomStateSet","DOMException","DOMHighResTimeStamp","DOMImplementation","DOMMatrix","DOMMatrix2DInit","DOMMatrixInit","DOMMatrixReadOnly","DOMParser","DOMParserSupportedType","DOMPoint","DOMPointInit","DOMPointReadOnly","DOMQuad","DOMQuadInit","DOMRect","DOMRectInit","DOMRectList","DOMRectReadOnly","DOMStringList","DOMStringMap","DOMTokenList","DataTransfer","DataTransferItem","DataTransferItemList","DataView","DataViewConstructor","Date","DateConstructor","DateLikeObject","DateTimeFormat","DateTimeFormatConstructor","DateTimeFormatOptions","DateTimeFormatPart","DateTimeFormatPartTypes","DateTimeFormatPartTypesRegistry","DateTimeLikeObject","DateTimeRangeFormatPart","DateUnit","DecodeErrorCallback","DecodeSuccessCallback","DecompressionStream","DecoratorContext","DecoratorMetadata","DecoratorMetadataObject","DedicatedWorkerGlobalScope","DedicatedWorkerGlobalScopeEventMap","DelayNode","DelayOptions","DeviceMotionEvent","DeviceMotionEventAcceleration","DeviceMotionEventAccelerationInit","DeviceMotionEventInit","DeviceMotionEventRotationRate","DeviceMotionEventRotationRateInit","DeviceOrientationEvent","DeviceOrientationEventInit","DigitalCredential","DirectionSetting","Dirent","DisambiguationOptions","DisplayCaptureSurfaceType","DisplayMediaStreamOptions","DisplayNames","DisplayNamesFallback","DisplayNamesLanguageDisplay","DisplayNamesOptions","DisplayNamesType","Disposable","DisposableStack","DisposableStackConstructor","DistanceModelType","Document","DocumentEventMap","DocumentFragment","DocumentOrShadowRoot","DocumentReadyState","DocumentTimeline","DocumentTimelineOptions","DocumentType","DocumentVisibilityState","DoubleRange","DragEvent","DragEventInit","Duration","DurationConstructor","DurationFormat","DurationFormatDisplayOption","DurationFormatLocaleMatcher","DurationFormatOptions","DurationFormatPart","DurationFormatStyle","DurationFormatUnit","DurationFormatUnitSingular","DurationLike","DurationLikeObject","DurationRelativeToOptions","DurationRoundingOptions","DurationToStringOptions","DurationTotalOptions","DynamicsCompressorNode","DynamicsCompressorOptions","EXT_blend_minmax","EXT_color_buffer_float","EXT_color_buffer_half_float","EXT_float_blend","EXT_frag_depth","EXT_sRGB","EXT_shader_texture_lod","EXT_texture_compression_bptc","EXT_texture_compression_rgtc","EXT_texture_filter_anisotropic","EXT_texture_norm16","EcKeyAlgorithm","EcKeyGenParams","EcKeyImportParams","EcdhKeyDeriveParams","EcdsaParams","EffectTiming","Element","ElementCSSInlineStyle","ElementContentEditable","ElementCreationOptions","ElementDefinitionOptions","ElementEventMap","ElementInternals","ElementTagNameMap","EncodedAudioChunk","EncodedAudioChunkInit","EncodedAudioChunkMetadata","EncodedAudioChunkOutputCallback","EncodedAudioChunkType","EncodedVideoChunk","EncodedVideoChunkInit","EncodedVideoChunkMetadata","EncodedVideoChunkOutputCallback","EncodedVideoChunkType","EndOfStreamError","EndingType","Enumerator","EnumeratorConstructor","EpochTimeStamp","Error","ErrorCallback","ErrorConstructor","ErrorEvent","ErrorEventInit","ErrorOptions","EvalError","EvalErrorConstructor","Event","EventCounts","EventInit","EventListener","EventListenerObject","EventListenerOptions","EventListenerOrEventListenerObject","EventModifierInit","EventSource","EventSourceEventMap","EventSourceInit","EventTarget","Exception","ExceptionOptions","Exclude","ExportValue","Exports","ExtendableCookieChangeEvent","ExtendableCookieChangeEventInit","ExtendableEvent","ExtendableEventInit","ExtendableMessageEvent","ExtendableMessageEventInit","External","Extract","FetchEvent","FetchEventInit","File","FileCallback","FileList","FilePropertyBag","FileReader","FileReaderEventMap","FileReaderSync","FileSink","FileSystem","FileSystemCreateWritableOptions","FileSystemDirectoryEntry","FileSystemDirectoryHandle","FileSystemDirectoryHandleAsyncIterator","FileSystemDirectoryReader","FileSystemEntriesCallback","FileSystemEntry","FileSystemEntryCallback","FileSystemFileEntry","FileSystemFileHandle","FileSystemFlags","FileSystemGetDirectoryOptions","FileSystemGetFileOptions","FileSystemHandle","FileSystemHandleKind","FileSystemReadWriteOptions","FileSystemRemoveOptions","FileSystemSyncAccessHandle","FileSystemWritableFileStream","FileSystemWriteChunkType","FillLightMode","FillMode","FinalizationRegistry","FinalizationRegistryConstructor","FlatArray","Float16Array","Float16ArrayConstructor","Float32Array","Float32ArrayConstructor","Float32List","Float64Array","Float64ArrayConstructor","FocusEvent","FocusEventInit","FocusOptions","FontDisplay","FontFace","FontFaceDescriptors","FontFaceLoadStatus","FontFaceSet","FontFaceSetEventMap","FontFaceSetLoadEvent","FontFaceSetLoadEventInit","FontFaceSetLoadStatus","FontFaceSource","FormData","FormDataEntryValue","FormDataEvent","FormDataEventInit","FormDataIterator","FormattableTemporalObject","FragmentDirective","FrameRequestCallback","FrameType","FullscreenNavigationUI","FullscreenOptions","Function","FunctionConstructor","FunctionStringCallback","GLbitfield","GLboolean","GLclampf","GLenum","GLfloat","GLint","GLint64","GLintptr","GLsizei","GLsizeiptr","GLuint","GLuint64","GPU","GPUAdapter","GPUAdapterInfo","GPUAddressMode","GPUAutoLayoutMode","GPUBindGroup","GPUBindGroupDescriptor","GPUBindGroupEntry","GPUBindGroupLayout","GPUBindGroupLayoutDescriptor","GPUBindGroupLayoutEntry","GPUBindingCommandsMixin","GPUBindingResource","GPUBlendComponent","GPUBlendFactor","GPUBlendOperation","GPUBlendState","GPUBuffer","GPUBufferBinding","GPUBufferBindingLayout","GPUBufferBindingType","GPUBufferDescriptor","GPUBufferDynamicOffset","GPUBufferMapState","GPUBufferUsageFlags","GPUCanvasAlphaMode","GPUCanvasConfiguration","GPUCanvasContext","GPUCanvasToneMapping","GPUCanvasToneMappingMode","GPUColor","GPUColorDict","GPUColorTargetState","GPUColorWriteFlags","GPUCommandBuffer","GPUCommandBufferDescriptor","GPUCommandEncoder","GPUCommandEncoderDescriptor","GPUCompareFunction","GPUCompilationInfo","GPUCompilationMessage","GPUCompilationMessageType","GPUComputePassDescriptor","GPUComputePassEncoder","GPUComputePassTimestampWrites","GPUComputePipeline","GPUComputePipelineDescriptor","GPUCopyExternalImageDestInfo","GPUCopyExternalImageSource","GPUCopyExternalImageSourceInfo","GPUCullMode","GPUDebugCommandsMixin","GPUDepthBias","GPUDepthStencilState","GPUDevice","GPUDeviceDescriptor","GPUDeviceEventMap","GPUDeviceLostInfo","GPUDeviceLostReason","GPUError","GPUErrorFilter","GPUExtent3D","GPUExtent3DDict","GPUExternalTexture","GPUExternalTextureBindingLayout","GPUExternalTextureDescriptor","GPUFeatureName","GPUFilterMode","GPUFlagsConstant","GPUFragmentState","GPUFrontFace","GPUIndex32","GPUIndexFormat","GPUIntegerCoordinate","GPUIntegerCoordinateOut","GPUInternalError","GPULoadOp","GPUMapModeFlags","GPUMipmapFilterMode","GPUMultisampleState","GPUObjectBase","GPUObjectDescriptorBase","GPUOrigin2D","GPUOrigin2DDict","GPUOrigin3D","GPUOrigin3DDict","GPUOutOfMemoryError","GPUPipelineBase","GPUPipelineConstantValue","GPUPipelineDescriptorBase","GPUPipelineError","GPUPipelineErrorInit","GPUPipelineErrorReason","GPUPipelineLayout","GPUPipelineLayoutDescriptor","GPUPowerPreference","GPUPrimitiveState","GPUPrimitiveTopology","GPUProgrammableStage","GPUQuerySet","GPUQuerySetDescriptor","GPUQueryType","GPUQueue","GPUQueueDescriptor","GPURenderBundle","GPURenderBundleDescriptor","GPURenderBundleEncoder","GPURenderBundleEncoderDescriptor","GPURenderCommandsMixin","GPURenderPassColorAttachment","GPURenderPassDepthStencilAttachment","GPURenderPassDescriptor","GPURenderPassEncoder","GPURenderPassLayout","GPURenderPassTimestampWrites","GPURenderPipeline","GPURenderPipelineDescriptor","GPURequestAdapterOptions","GPUSampleMask","GPUSampler","GPUSamplerBindingLayout","GPUSamplerBindingType","GPUSamplerDescriptor","GPUShaderModule","GPUShaderModuleDescriptor","GPUShaderStageFlags","GPUSignedOffset32","GPUSize32","GPUSize32Out","GPUSize64","GPUSize64Out","GPUStencilFaceState","GPUStencilOperation","GPUStencilValue","GPUStorageTextureAccess","GPUStorageTextureBindingLayout","GPUStoreOp","GPUSupportedFeatures","GPUSupportedLimits","GPUTexelCopyBufferInfo","GPUTexelCopyBufferLayout","GPUTexelCopyTextureInfo","GPUTexture","GPUTextureAspect","GPUTextureBindingLayout","GPUTextureDescriptor","GPUTextureDimension","GPUTextureFormat","GPUTextureSampleType","GPUTextureUsageFlags","GPUTextureView","GPUTextureViewDescriptor","GPUTextureViewDimension","GPUUncapturedErrorEvent","GPUUncapturedErrorEventInit","GPUValidationError","GPUVertexAttribute","GPUVertexBufferLayout","GPUVertexFormat","GPUVertexState","GPUVertexStepMode","GainNode","GainOptions","Gamepad","GamepadButton","GamepadEffectParameters","GamepadEvent","GamepadEventInit","GamepadHapticActuator","GamepadHapticEffectType","GamepadHapticsResult","GamepadMappingType","Generator","GeneratorFunction","GeneratorFunctionConstructor","GenericTransformStream","Geolocation","GeolocationCoordinates","GeolocationPosition","GeolocationPositionError","GetAnimationsOptions","GetComposedRangesOptions","GetHTMLOptions","GetNotificationOptions","GetRootNodeOptions","Global","GlobalCompositeOperation","GlobalDescriptor","GlobalEventHandlers","GlobalEventHandlersEventMap","HTMLAllCollection","HTMLAnchorElement","HTMLAreaElement","HTMLAudioElement","HTMLBRElement","HTMLBaseElement","HTMLBodyElement","HTMLBodyElementEventMap","HTMLButtonElement","HTMLCanvasElement","HTMLCollection","HTMLCollectionBase","HTMLCollectionOf","HTMLDListElement","HTMLDataElement","HTMLDataListElement","HTMLDetailsElement","HTMLDialogElement","HTMLDirectoryElement","HTMLDivElement","HTMLDocument","HTMLElement","HTMLElementDeprecatedTagNameMap","HTMLElementEventMap","HTMLElementTagNameMap","HTMLEmbedElement","HTMLFieldSetElement","HTMLFontElement","HTMLFormControlsCollection","HTMLFormElement","HTMLFrameElement","HTMLFrameSetElement","HTMLFrameSetElementEventMap","HTMLHRElement","HTMLHeadElement","HTMLHeadingElement","HTMLHtmlElement","HTMLHyperlinkElementUtils","HTMLIFrameElement","HTMLImageElement","HTMLInputElement","HTMLLIElement","HTMLLabelElement","HTMLLegendElement","HTMLLinkElement","HTMLMapElement","HTMLMarqueeElement","HTMLMediaElement","HTMLMediaElementEventMap","HTMLMenuElement","HTMLMetaElement","HTMLMeterElement","HTMLModElement","HTMLOListElement","HTMLObjectElement","HTMLOptGroupElement","HTMLOptionElement","HTMLOptionsCollection","HTMLOrSVGElement","HTMLOrSVGImageElement","HTMLOrSVGScriptElement","HTMLOutputElement","HTMLParagraphElement","HTMLParamElement","HTMLPictureElement","HTMLPreElement","HTMLProgressElement","HTMLQuoteElement","HTMLScriptElement","HTMLSelectElement","HTMLSlotElement","HTMLSourceElement","HTMLSpanElement","HTMLStyleElement","HTMLTableCaptionElement","HTMLTableCellElement","HTMLTableColElement","HTMLTableDataCellElement","HTMLTableElement","HTMLTableHeaderCellElement","HTMLTableRowElement","HTMLTableSectionElement","HTMLTemplateElement","HTMLTextAreaElement","HTMLTimeElement","HTMLTitleElement","HTMLTrackElement","HTMLUListElement","HTMLUnknownElement","HTMLVideoElement","HTMLVideoElementEventMap","HardwareAcceleration","HashAlgorithmIdentifier","HashChangeEvent","HashChangeEventInit","HdrMetadataType","Headers","HeadersInit","HeadersIterator","Highlight","HighlightRegistry","HighlightType","History","HkdfParams","HmacImportParams","HmacKeyAlgorithm","HmacKeyGenParams","IArguments","IDBCursor","IDBCursorDirection","IDBCursorWithValue","IDBDatabase","IDBDatabaseEventMap","IDBDatabaseInfo","IDBFactory","IDBIndex","IDBIndexParameters","IDBKeyRange","IDBObjectStore","IDBObjectStoreParameters","IDBOpenDBRequest","IDBOpenDBRequestEventMap","IDBRequest","IDBRequestEventMap","IDBRequestReadyState","IDBTransaction","IDBTransactionDurability","IDBTransactionEventMap","IDBTransactionMode","IDBTransactionOptions","IDBValidKey","IDBVersionChangeEvent","IDBVersionChangeEventInit","IIRFilterNode","IIRFilterOptions","ITextWriter","IdleDeadline","IdleRequestCallback","IdleRequestOptions","Image","ImageBitmap","ImageBitmapOptions","ImageBitmapRenderingContext","ImageBitmapRenderingContextSettings","ImageBitmapSource","ImageBufferSource","ImageCapture","ImageData","ImageDataArray","ImageDataPixelFormat","ImageDataSettings","ImageDecodeOptions","ImageDecodeResult","ImageDecoder","ImageDecoderInit","ImageEncodeOptions","ImageOrientation","ImageSmoothingQuality","ImageTrack","ImageTrackList","Immediate","ImportAssertions","ImportAttributes","ImportCallOptions","ImportExportKind","ImportMeta","ImportNodeOptions","ImportValue","Imports","Infinity","InputDeviceInfo","InputEvent","InputEventInit","InsertPosition","Instance","InstanceType","Instant","InstantConstructor","InstantLike","InstantToStringOptions","Int16Array","Int16ArrayConstructor","Int32Array","Int32ArrayConstructor","Int32List","Int8Array","Int8ArrayConstructor","IntersectionObserver","IntersectionObserverCallback","IntersectionObserverEntry","IntersectionObserverInit","Intl","Iterable","IterableIterator","IterationCompositeOperation","Iterator","IteratorConstructor","IteratorObject","IteratorObjectConstructor","IteratorResult","IteratorReturnResult","IteratorYieldResult","JSON","JsonWebKey","KHR_parallel_shader_compile","KeyAlgorithm","KeyFormat","KeySystemTrackConfiguration","KeyType","KeyUsage","KeyboardEvent","KeyboardEventInit","Keyframe","KeyframeAnimationOptions","KeyframeEffect","KeyframeEffectOptions","LDMLPluralRule","LargestContentfulPaint","LatencyMode","LineAlignSetting","LineAndPositionSetting","LinkError","LinkStyle","ListFormat","ListFormatLocaleMatcher","ListFormatOptions","ListFormatStyle","ListFormatType","Locale","LocaleCollationCaseFirst","LocaleHourCycleKey","LocaleOptions","LocalesArgument","Location","Lock","LockGrantedCallback","LockInfo","LockManager","LockManagerSnapshot","LockMode","LockOptions","LoginStatus","Lowercase","MIDIAccess","MIDIAccessEventMap","MIDIConnectionEvent","MIDIConnectionEventInit","MIDIInput","MIDIInputEventMap","MIDIInputMap","MIDIMessageEvent","MIDIMessageEventInit","MIDIOptions","MIDIOutput","MIDIOutputMap","MIDIPort","MIDIPortConnectionState","MIDIPortDeviceState","MIDIPortEventMap","MIDIPortType","Map","MapConstructor","MapIterator","Math","MathMLElement","MathMLElementEventMap","MathMLElementTagNameMap","MediaCapabilities","MediaCapabilitiesDecodingInfo","MediaCapabilitiesEncodingInfo","MediaCapabilitiesInfo","MediaCapabilitiesKeySystemConfiguration","MediaConfiguration","MediaDecodingConfiguration","MediaDecodingType","MediaDeviceInfo","MediaDeviceKind","MediaDevices","MediaDevicesEventMap","MediaElementAudioSourceNode","MediaElementAudioSourceOptions","MediaEncodingConfiguration","MediaEncodingType","MediaEncryptedEvent","MediaEncryptedEventInit","MediaError","MediaImage","MediaKeyMessageEvent","MediaKeyMessageEventInit","MediaKeyMessageType","MediaKeySession","MediaKeySessionClosedReason","MediaKeySessionEventMap","MediaKeySessionType","MediaKeyStatus","MediaKeyStatusMap","MediaKeyStatusMapIterator","MediaKeySystemAccess","MediaKeySystemConfiguration","MediaKeySystemMediaCapability","MediaKeys","MediaKeysPolicy","MediaKeysRequirement","MediaList","MediaMetadata","MediaMetadataInit","MediaPositionState","MediaProvider","MediaQueryList","MediaQueryListEvent","MediaQueryListEventInit","MediaQueryListEventMap","MediaRecorder","MediaRecorderEventMap","MediaRecorderOptions","MediaSession","MediaSessionAction","MediaSessionActionDetails","MediaSessionActionHandler","MediaSessionPlaybackState","MediaSettingsRange","MediaSource","MediaSourceEventMap","MediaSourceHandle","MediaStream","MediaStreamAudioDestinationNode","MediaStreamAudioSourceNode","MediaStreamAudioSourceOptions","MediaStreamConstraints","MediaStreamEventMap","MediaStreamTrack","MediaStreamTrackEvent","MediaStreamTrackEventInit","MediaStreamTrackEventMap","MediaStreamTrackProcessor","MediaStreamTrackProcessorInit","MediaStreamTrackState","MediaTrackCapabilities","MediaTrackConstraintSet","MediaTrackConstraints","MediaTrackSettings","MediaTrackSupportedConstraints","Memory","MemoryDescriptor","MessageChannel","MessageEvent","MessageEventInit","MessageEventSource","MessageEventTarget","MessageEventTargetEventMap","MessagePort","MessagePortEventMap","MethodDecorator","MimeType","MimeTypeArray","Module","ModuleExportDescriptor","ModuleImportDescriptor","ModuleImports","MouseEvent","MouseEventInit","MultiCacheQueryOptions","MutationCallback","MutationObserver","MutationObserverInit","MutationRecord","MutationRecordType","NaN","NamedCurve","NamedNodeMap","NavigateEvent","NavigateEventInit","Navigation","NavigationActivation","NavigationCurrentEntryChangeEvent","NavigationCurrentEntryChangeEventInit","NavigationDestination","NavigationEventMap","NavigationFocusReset","NavigationHistoryBehavior","NavigationHistoryEntry","NavigationHistoryEntryEventMap","NavigationInterceptHandler","NavigationInterceptOptions","NavigationNavigateOptions","NavigationOptions","NavigationPrecommitController","NavigationPrecommitHandler","NavigationPreloadManager","NavigationPreloadState","NavigationReloadOptions","NavigationResult","NavigationScrollBehavior","NavigationTimingType","NavigationTransition","NavigationType","NavigationUpdateCurrentEntryOptions","Navigator","NavigatorAutomationInformation","NavigatorBadge","NavigatorConcurrentHardware","NavigatorContentUtils","NavigatorCookies","NavigatorGPU","NavigatorID","NavigatorLanguage","NavigatorLocks","NavigatorLogin","NavigatorOnLine","NavigatorPlugins","NavigatorStorage","NewableFunction","NoInfer","Node","NodeFilter","NodeIterator","NodeJS","NodeList","NodeListOf","NodeModule","NodeRequire","NonDocumentTypeChildNode","NonElementParentNode","NonNullable","Notification","NotificationDirection","NotificationEvent","NotificationEventInit","NotificationEventMap","NotificationOptions","NotificationPermission","NotificationPermissionCallback","Now","Number","NumberConstructor","NumberFormat","NumberFormatConstructor","NumberFormatOptions","NumberFormatOptionsCurrencyDisplay","NumberFormatOptionsCurrencyDisplayRegistry","NumberFormatOptionsSignDisplay","NumberFormatOptionsSignDisplayRegistry","NumberFormatOptionsStyle","NumberFormatOptionsStyleRegistry","NumberFormatOptionsUseGrouping","NumberFormatOptionsUseGroupingRegistry","NumberFormatPart","NumberFormatPartTypeRegistry","NumberFormatPartTypes","NumberFormatRangePartTypeRegistry","NumberFormatRangePartTypes","NumberRangeFormatPart","OES_draw_buffers_indexed","OES_element_index_uint","OES_fbo_render_mipmap","OES_standard_derivatives","OES_texture_float","OES_texture_float_linear","OES_texture_half_float","OES_texture_half_float_linear","OES_vertex_array_object","OVR_multiview2","Object","ObjectConstructor","OfflineAudioCompletionEvent","OfflineAudioCompletionEventInit","OfflineAudioContext","OfflineAudioContextEventMap","OfflineAudioContextOptions","OffscreenCanvas","OffscreenCanvasEventMap","OffscreenCanvasRenderingContext2D","OffscreenRenderingContext","OffscreenRenderingContextId","Omit","OmitThisParameter","OnBeforeUnloadEventHandler","OnBeforeUnloadEventHandlerNonNull","OnErrorEventHandler","OnErrorEventHandlerNonNull","Option","OptionalEffectTiming","OptionalPostfixToken","OptionalPrefixToken","OpusBitstreamFormat","OpusEncoderConfig","OrientationLockType","OrientationType","OscillatorNode","OscillatorOptions","OscillatorType","OverSampleType","OverconstrainedError","OverflowOptions","PageRevealEvent","PageRevealEventInit","PageSwapEvent","PageSwapEventInit","PageTransitionEvent","PageTransitionEventInit","PaintTimingMixin","PannerNode","PannerOptions","PanningModelType","ParameterDecorator","Parameters","ParentNode","Partial","PartialTemporalLike","Path2D","PayerErrors","PaymentAddress","PaymentComplete","PaymentCurrencyAmount","PaymentDetailsBase","PaymentDetailsInit","PaymentDetailsModifier","PaymentDetailsUpdate","PaymentItem","PaymentMethodChangeEvent","PaymentMethodChangeEventInit","PaymentMethodData","PaymentOptions","PaymentRequest","PaymentRequestEventMap","PaymentRequestUpdateEvent","PaymentRequestUpdateEventInit","PaymentResponse","PaymentResponseEventMap","PaymentShippingOption","PaymentShippingType","PaymentValidationErrors","Pbkdf2Params","Performance","PerformanceEntry","PerformanceEntryList","PerformanceEventMap","PerformanceEventTiming","PerformanceMark","PerformanceMarkOptions","PerformanceMeasure","PerformanceMeasureOptions","PerformanceNavigation","PerformanceNavigationTiming","PerformanceObserver","PerformanceObserverCallback","PerformanceObserverEntryList","PerformanceObserverInit","PerformancePaintTiming","PerformanceResourceTiming","PerformanceServerTiming","PerformanceTiming","PeriodicWave","PeriodicWaveConstraints","PeriodicWaveOptions","PermissionDescriptor","PermissionName","PermissionState","PermissionStatus","PermissionStatusEventMap","Permissions","PhotoCapabilities","PhotoSettings","Pick","PictureInPictureEvent","PictureInPictureEventInit","PictureInPictureWindow","PictureInPictureWindowEventMap","PlainDate","PlainDateConstructor","PlainDateLike","PlainDateTime","PlainDateTimeConstructor","PlainDateTimeLike","PlainDateTimeToStringOptions","PlainDateToStringOptions","PlainDateToZonedDateTimeOptions","PlainMonthDay","PlainMonthDayConstructor","PlainMonthDayLike","PlainMonthDayToPlainDateOptions","PlainTime","PlainTimeConstructor","PlainTimeLike","PlainTimeToStringOptions","PlainYearMonth","PlainYearMonthConstructor","PlainYearMonthLike","PlainYearMonthToPlainDateOptions","PlaneLayout","PlaybackDirection","Plugin","PluginArray","PluralRuleType","PluralRules","PluralRulesConstructor","PluralRulesOptions","PluralizeUnit","PointerEvent","PointerEventInit","PointerLockOptions","PopStateEvent","PopStateEventInit","PopoverTargetAttributes","PositionAlignSetting","PositionCallback","PositionErrorCallback","PositionOptions","PredefinedColorSpace","PremultiplyAlpha","PresentationStyle","ProcessingInstruction","ProgressEvent","ProgressEventInit","Promise","PromiseConstructor","PromiseConstructorLike","PromiseFulfilledResult","PromiseLike","PromiseRejectedResult","PromiseRejectionEvent","PromiseRejectionEventInit","PromiseSettledResult","PromiseWithResolvers","PropertyDecorator","PropertyDefinition","PropertyDescriptor","PropertyDescriptorMap","PropertyIndexedKeyframes","PropertyKey","Proxy","ProxyConstructor","ProxyHandler","PublicKeyCredential","PublicKeyCredentialClientCapabilities","PublicKeyCredentialCreationOptions","PublicKeyCredentialCreationOptionsJSON","PublicKeyCredentialDescriptor","PublicKeyCredentialDescriptorJSON","PublicKeyCredentialEntity","PublicKeyCredentialParameters","PublicKeyCredentialRequestOptions","PublicKeyCredentialRequestOptionsJSON","PublicKeyCredentialRpEntity","PublicKeyCredentialType","PublicKeyCredentialUserEntity","PublicKeyCredentialUserEntityJSON","PushEncryptionKeyName","PushEvent","PushEventInit","PushManager","PushManagerAttribute","PushMessageData","PushMessageDataInit","PushSubscription","PushSubscriptionChangeEvent","PushSubscriptionChangeEventInit","PushSubscriptionJSON","PushSubscriptionOptions","PushSubscriptionOptionsInit","QueuingStrategy","QueuingStrategyInit","QueuingStrategySize","RTCAnswerOptions","RTCBundlePolicy","RTCCertificate","RTCCertificateExpiration","RTCConfiguration","RTCDTMFSender","RTCDTMFSenderEventMap","RTCDTMFToneChangeEvent","RTCDTMFToneChangeEventInit","RTCDataChannel","RTCDataChannelEvent","RTCDataChannelEventInit","RTCDataChannelEventMap","RTCDataChannelInit","RTCDataChannelState","RTCDegradationPreference","RTCDtlsFingerprint","RTCDtlsRole","RTCDtlsTransport","RTCDtlsTransportEventMap","RTCDtlsTransportState","RTCEncodedAudioFrame","RTCEncodedAudioFrameMetadata","RTCEncodedFrameMetadata","RTCEncodedVideoFrame","RTCEncodedVideoFrameMetadata","RTCError","RTCErrorDetailType","RTCErrorEvent","RTCErrorEventInit","RTCErrorInit","RTCIceCandidate","RTCIceCandidateInit","RTCIceCandidatePair","RTCIceCandidatePairStats","RTCIceCandidateType","RTCIceComponent","RTCIceConnectionState","RTCIceGathererState","RTCIceGatheringState","RTCIceProtocol","RTCIceRole","RTCIceServer","RTCIceTcpCandidateType","RTCIceTransport","RTCIceTransportEventMap","RTCIceTransportPolicy","RTCIceTransportState","RTCInboundRtpStreamStats","RTCLocalIceCandidateInit","RTCLocalSessionDescriptionInit","RTCOfferAnswerOptions","RTCOfferOptions","RTCOutboundRtpStreamStats","RTCPeerConnection","RTCPeerConnectionErrorCallback","RTCPeerConnectionEventMap","RTCPeerConnectionIceErrorEvent","RTCPeerConnectionIceErrorEventInit","RTCPeerConnectionIceEvent","RTCPeerConnectionIceEventInit","RTCPeerConnectionState","RTCPriorityType","RTCQualityLimitationReason","RTCReceivedRtpStreamStats","RTCRtcpMuxPolicy","RTCRtcpParameters","RTCRtpCapabilities","RTCRtpCodec","RTCRtpCodecParameters","RTCRtpCodingParameters","RTCRtpContributingSource","RTCRtpEncodingParameters","RTCRtpHeaderExtensionCapability","RTCRtpHeaderExtensionParameters","RTCRtpParameters","RTCRtpReceiveParameters","RTCRtpReceiver","RTCRtpReceiverTransform","RTCRtpScriptTransform","RTCRtpScriptTransformer","RTCRtpSendParameters","RTCRtpSender","RTCRtpSenderTransform","RTCRtpStreamStats","RTCRtpSynchronizationSource","RTCRtpTransceiver","RTCRtpTransceiverDirection","RTCRtpTransceiverInit","RTCSctpTransport","RTCSctpTransportEventMap","RTCSctpTransportState","RTCSdpType","RTCSentRtpStreamStats","RTCSessionDescription","RTCSessionDescriptionCallback","RTCSessionDescriptionInit","RTCSetParameterOptions","RTCSignalingState","RTCStats","RTCStatsIceCandidatePairState","RTCStatsReport","RTCStatsType","RTCTrackEvent","RTCTrackEventInit","RTCTransformEvent","RTCTransportStats","RadioNodeList","Range","RangeError","RangeErrorConstructor","ReadableByteStreamController","ReadableStream","ReadableStreamAsyncIterator","ReadableStreamBYOBReader","ReadableStreamBYOBReaderReadOptions","ReadableStreamBYOBRequest","ReadableStreamController","ReadableStreamDefaultController","ReadableStreamDefaultReader","ReadableStreamGenericReader","ReadableStreamGetReaderOptions","ReadableStreamIteratorOptions","ReadableStreamReadDoneResult","ReadableStreamReadResult","ReadableStreamReadValueResult","ReadableStreamReader","ReadableStreamReaderMode","ReadableStreamType","ReadableWritablePair","Readonly","ReadonlyArray","ReadonlyMap","ReadonlySet","ReadonlySetLike","ReadyState","Record","RecordingState","RedEyeReduction","ReferenceError","ReferenceErrorConstructor","ReferrerPolicy","Reflect","RegExp","RegExpConstructor","RegExpExecArray","RegExpIndicesArray","RegExpMatchArray","RegExpStringIterator","RegistrationOptions","RegistrationResponseJSON","RelativeTimeFormat","RelativeTimeFormatLocaleMatcher","RelativeTimeFormatNumeric","RelativeTimeFormatOptions","RelativeTimeFormatPart","RelativeTimeFormatStyle","RelativeTimeFormatUnit","RelativeTimeFormatUnitSingular","RemotePlayback","RemotePlaybackAvailabilityCallback","RemotePlaybackEventMap","RemotePlaybackState","RenderingContext","Report","ReportBody","ReportList","ReportingObserver","ReportingObserverCallback","ReportingObserverOptions","Request","RequestCache","RequestCredentials","RequestDestination","RequestInfo","RequestInit","RequestMode","RequestPriority","RequestRedirect","Required","ResidentKeyRequirement","ResizeObserver","ResizeObserverBoxOptions","ResizeObserverCallback","ResizeObserverEntry","ResizeObserverOptions","ResizeObserverSize","ResizeQuality","ResolvedCollatorOptions","ResolvedDateTimeFormatOptions","ResolvedDisplayNamesOptions","ResolvedDurationFormatOptions","ResolvedListFormatOptions","ResolvedNumberFormatOptions","ResolvedNumberFormatOptionsUseGrouping","ResolvedPluralRulesOptions","ResolvedRelativeTimeFormatOptions","ResolvedSegmenterOptions","Response","ResponseInit","ResponseType","ReturnType","RoundingOptions","RoundingOptionsWithLargestUnit","RsaHashedImportParams","RsaHashedKeyAlgorithm","RsaHashedKeyGenParams","RsaKeyAlgorithm","RsaKeyGenParams","RsaOaepParams","RsaOtherPrimesInfo","RsaPssParams","RuntimeError","SVGAElement","SVGAngle","SVGAnimateElement","SVGAnimateMotionElement","SVGAnimateTransformElement","SVGAnimatedAngle","SVGAnimatedBoolean","SVGAnimatedEnumeration","SVGAnimatedInteger","SVGAnimatedLength","SVGAnimatedLengthList","SVGAnimatedNumber","SVGAnimatedNumberList","SVGAnimatedPoints","SVGAnimatedPreserveAspectRatio","SVGAnimatedRect","SVGAnimatedString","SVGAnimatedTransformList","SVGAnimationElement","SVGBoundingBoxOptions","SVGCircleElement","SVGClipPathElement","SVGComponentTransferFunctionElement","SVGDefsElement","SVGDescElement","SVGElement","SVGElementEventMap","SVGElementTagNameMap","SVGEllipseElement","SVGFEBlendElement","SVGFEColorMatrixElement","SVGFEComponentTransferElement","SVGFECompositeElement","SVGFEConvolveMatrixElement","SVGFEDiffuseLightingElement","SVGFEDisplacementMapElement","SVGFEDistantLightElement","SVGFEDropShadowElement","SVGFEFloodElement","SVGFEFuncAElement","SVGFEFuncBElement","SVGFEFuncGElement","SVGFEFuncRElement","SVGFEGaussianBlurElement","SVGFEImageElement","SVGFEMergeElement","SVGFEMergeNodeElement","SVGFEMorphologyElement","SVGFEOffsetElement","SVGFEPointLightElement","SVGFESpecularLightingElement","SVGFESpotLightElement","SVGFETileElement","SVGFETurbulenceElement","SVGFilterElement","SVGFilterPrimitiveStandardAttributes","SVGFitToViewBox","SVGForeignObjectElement","SVGGElement","SVGGeometryElement","SVGGradientElement","SVGGraphicsElement","SVGImageElement","SVGLength","SVGLengthList","SVGLineElement","SVGLinearGradientElement","SVGMPathElement","SVGMarkerElement","SVGMaskElement","SVGMatrix","SVGMetadataElement","SVGNumber","SVGNumberList","SVGPathElement","SVGPatternElement","SVGPoint","SVGPointList","SVGPolygonElement","SVGPolylineElement","SVGPreserveAspectRatio","SVGRadialGradientElement","SVGRect","SVGRectElement","SVGSVGElement","SVGSVGElementEventMap","SVGScriptElement","SVGSetElement","SVGStopElement","SVGStringList","SVGStyleElement","SVGSwitchElement","SVGSymbolElement","SVGTSpanElement","SVGTests","SVGTextContentElement","SVGTextElement","SVGTextPathElement","SVGTextPositioningElement","SVGTitleElement","SVGTransform","SVGTransformList","SVGURIReference","SVGUnitTypes","SVGUseElement","SVGViewElement","Sanitizer","SanitizerAttribute","SanitizerAttributeNamespace","SanitizerConfig","SanitizerElement","SanitizerElementNamespace","SanitizerElementNamespaceWithAttributes","SanitizerElementWithAttributes","SanitizerPresets","Scheduler","SchedulerPostTaskCallback","SchedulerPostTaskOptions","Screen","ScreenOrientation","ScreenOrientationEventMap","ScriptProcessorNode","ScriptProcessorNodeEventMap","ScrollAxis","ScrollBehavior","ScrollIntoViewOptions","ScrollLogicalPosition","ScrollOptions","ScrollRestoration","ScrollSetting","ScrollTimeline","ScrollTimelineOptions","ScrollToOptions","SecurityPolicyViolationEvent","SecurityPolicyViolationEventDisposition","SecurityPolicyViolationEventInit","SegmentData","SegmentIterator","Segmenter","SegmenterOptions","Segments","Selection","SelectionDirection","SelectionMode","Server","ServerWebSocket","ServiceWorker","ServiceWorkerContainer","ServiceWorkerContainerEventMap","ServiceWorkerEventMap","ServiceWorkerGlobalScope","ServiceWorkerGlobalScopeEventMap","ServiceWorkerRegistration","ServiceWorkerRegistrationEventMap","ServiceWorkerState","ServiceWorkerUpdateViaCache","Set","SetConstructor","SetIterator","ShadowRoot","ShadowRootEventMap","ShadowRootInit","ShadowRootMode","ShareData","SharedArrayBuffer","SharedArrayBufferConstructor","SharedWorker","SharedWorkerGlobalScope","SharedWorkerGlobalScopeEventMap","ShellPromise","ShowPopoverOptions","SlotAssignmentMode","Slottable","Socket","SocketHandler","SourceBuffer","SourceBufferEventMap","SourceBufferList","SourceBufferListEventMap","SpeechRecognitionAlternative","SpeechRecognitionErrorCode","SpeechRecognitionErrorEvent","SpeechRecognitionErrorEventInit","SpeechRecognitionEvent","SpeechRecognitionEventInit","SpeechRecognitionResult","SpeechRecognitionResultList","SpeechSynthesis","SpeechSynthesisErrorCode","SpeechSynthesisErrorEvent","SpeechSynthesisErrorEventInit","SpeechSynthesisEvent","SpeechSynthesisEventInit","SpeechSynthesisEventMap","SpeechSynthesisUtterance","SpeechSynthesisUtteranceEventMap","SpeechSynthesisVoice","StartViewTransitionOptions","StaticRange","StaticRangeInit","Stats","StereoPannerNode","StereoPannerOptions","Storage","StorageEstimate","StorageEvent","StorageEventInit","StorageManager","StreamPipeOptions","String","StringConstructor","StringIterator","StringNumericLiteral","StructuredSerializeOptions","StylePropertyMap","StylePropertyMapReadOnly","StylePropertyMapReadOnlyIterator","StyleSheet","StyleSheetList","SubmitEvent","SubmitEventInit","Subprocess","SubtleCrypto","SuppressedError","SuppressedErrorConstructor","SvcOutputMetadata","Symbol","SymbolConstructor","SyntaxError","SyntaxErrorConstructor","TCPSocket","Table","TableDescriptor","TableKind","Tag","TagType","TaskController","TaskControllerInit","TaskPriority","TaskPriorityChangeEvent","TaskPriorityChangeEventInit","TaskSignal","TaskSignalAnyInit","TaskSignalEventMap","TemplateStringsArray","Temporal","TexImageSource","Text","TextDecodeOptions","TextDecoder","TextDecoderCommon","TextDecoderOptions","TextDecoderStream","TextEncoder","TextEncoderCommon","TextEncoderEncodeIntoResult","TextEncoderStream","TextEvent","TextInfo","TextMetrics","TextStreamBase","TextStreamReader","TextStreamWriter","TextTrack","TextTrackCue","TextTrackCueEventMap","TextTrackCueList","TextTrackEventMap","TextTrackKind","TextTrackList","TextTrackListEventMap","TextTrackMode","ThisParameterType","ThisType","TimeLikeObject","TimeRanges","TimeUnit","TimeZoneLike","TimelineRangeOffset","Timeout","Timer","TimerHandler","ToStringRoundingOptions","ToStringRoundingOptionsWithFractionalSeconds","ToggleEvent","ToggleEventInit","TogglePopoverOptions","Touch","TouchEvent","TouchEventInit","TouchInit","TouchList","TouchType","TrackEvent","TrackEventInit","TransferFunction","Transferable","TransformStream","TransformStreamDefaultController","Transformer","TransformerFlushCallback","TransformerStartCallback","TransformerTransformCallback","TransitionEvent","TransitionEventInit","TransitionOptions","TreeWalker","TypeError","TypeErrorConstructor","TypedArray","TypedPropertyDescriptor","UIEvent","UIEventInit","ULongRange","URIError","URIErrorConstructor","URL","URLPattern","URLPatternComponentResult","URLPatternInit","URLPatternInput","URLPatternOptions","URLPatternResult","URLSearchParams","URLSearchParamsIterator","Uint16Array","Uint16ArrayConstructor","Uint32Array","Uint32ArrayConstructor","Uint32List","Uint8Array","Uint8ArrayConstructor","Uint8ClampedArray","Uint8ClampedArrayConstructor","Uncapitalize","UnderlyingByteSource","UnderlyingDefaultSource","UnderlyingSink","UnderlyingSinkAbortCallback","UnderlyingSinkCloseCallback","UnderlyingSinkStartCallback","UnderlyingSinkWriteCallback","UnderlyingSource","UnderlyingSourceCancelCallback","UnderlyingSourcePullCallback","UnderlyingSourceStartCallback","UnicodeBCP47LocaleIdentifier","UnknownCredentialOptions","Uppercase","UserActivation","UserVerificationRequirement","VBArray","VBArrayConstructor","VTTCue","VTTRegion","ValidityState","ValidityStateFlags","ValueType","ValueTypeMap","VibratePattern","VideoColorPrimaries","VideoColorSpace","VideoColorSpaceInit","VideoConfiguration","VideoDecoder","VideoDecoderConfig","VideoDecoderEventMap","VideoDecoderInit","VideoDecoderSupport","VideoEncoder","VideoEncoderBitrateMode","VideoEncoderConfig","VideoEncoderEncodeOptions","VideoEncoderEncodeOptionsForAvc","VideoEncoderEventMap","VideoEncoderInit","VideoEncoderSupport","VideoFacingModeEnum","VideoFrame","VideoFrameBufferInit","VideoFrameCallbackMetadata","VideoFrameCopyToOptions","VideoFrameInit","VideoFrameOutputCallback","VideoFrameRequestCallback","VideoMatrixCoefficients","VideoPixelFormat","VideoPlaybackQuality","VideoTransferCharacteristics","ViewTimeline","ViewTimelineOptions","ViewTransition","ViewTransitionTypeSet","ViewTransitionUpdateCallback","VisualViewport","VisualViewportEventMap","VoidFunction","WEBGL_color_buffer_float","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb","WEBGL_debug_renderer_info","WEBGL_debug_shaders","WEBGL_depth_texture","WEBGL_draw_buffers","WEBGL_lose_context","WEBGL_multi_draw","WGSLLanguageFeatures","WSH","WScript","WakeLock","WakeLockSentinel","WakeLockSentinelEventMap","WakeLockType","WaveShaperNode","WaveShaperOptions","WeakKey","WeakKeyTypes","WeakMap","WeakMapConstructor","WeakRef","WeakRefConstructor","WeakSet","WeakSetConstructor","WebAssembly","WebAssemblyCompileOptions","WebAssemblyInstantiatedSource","WebCodecsErrorCallback","WebGL2RenderingContext","WebGL2RenderingContextBase","WebGL2RenderingContextOverloads","WebGLActiveInfo","WebGLBuffer","WebGLContextAttributes","WebGLContextEvent","WebGLContextEventInit","WebGLFramebuffer","WebGLPowerPreference","WebGLProgram","WebGLQuery","WebGLRenderbuffer","WebGLRenderingContext","WebGLRenderingContextBase","WebGLRenderingContextOverloads","WebGLSampler","WebGLShader","WebGLShaderPrecisionFormat","WebGLSync","WebGLTexture","WebGLTransformFeedback","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES","WebKitCSSMatrix","WebSocket","WebSocketEventMap","WebSocketHandler","WebTransport","WebTransportBidirectionalStream","WebTransportCloseInfo","WebTransportCongestionControl","WebTransportDatagramDuplexStream","WebTransportError","WebTransportErrorOptions","WebTransportErrorSource","WebTransportHash","WebTransportOptions","WebTransportSendOptions","WebTransportSendStreamOptions","WeekInfo","WheelEvent","WheelEventInit","Window","WindowClient","WindowEventHandlers","WindowEventHandlersEventMap","WindowEventMap","WindowLocalStorage","WindowOrWorkerGlobalScope","WindowPostMessageOptions","WindowProxy","WindowSessionStorage","WithImplicitCoercion","Worker","WorkerEventMap","WorkerGlobalScope","WorkerGlobalScopeEventMap","WorkerLocation","WorkerNavigator","WorkerOptions","WorkerType","Worklet","WorkletOptions","WritableStream","WritableStreamDefaultController","WritableStreamDefaultWriter","WriteCommandType","WriteParams","XMLDocument","XMLHttpRequest","XMLHttpRequestBodyInit","XMLHttpRequestEventMap","XMLHttpRequestEventTarget","XMLHttpRequestEventTargetEventMap","XMLHttpRequestResponseType","XMLHttpRequestUpload","XMLSerializer","XPathEvaluator","XPathEvaluatorBase","XPathExpression","XPathNSResolver","XPathResult","XSLTProcessor","YearMonthLikeObject","ZonedDateTime","ZonedDateTimeConstructor","ZonedDateTimeFromOptions","ZonedDateTimeLike","ZonedDateTimeLikeObject","ZonedDateTimeToStringOptions","global","globalThis","process","structuredClone"])});function ho(e,t={strings:!0}){let r="",n=0;while(n<e.length){let i=e.slice(n,n+2);if(i==="//"){let a=e.indexOf(`
65
+ `;return r}}function ku(e,t,r={}){return so(e,t,r,new WeakMap)}function so(e,t,r,n){let{arrayMergeMode:i="replace",skipNullish:s=!1,customMerger:a}=r;if(t===null||t===void 0)return s?e:t;if(a){let o=a(e,t);if(o!==void 0)return o}if(Array.isArray(t)||Array.isArray(e))return ao(e,t,i,n);if(!Qe(t)||!Qe(e))return t;return Fu(e,t,r,n)}function ao(e,t,r,n){if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(e)&&!Array.isArray(t))return t;if(Array.isArray(t)&&Array.isArray(e))switch(r){case"replace":return t;case"concat":return Mu(e,t);case"smart":return Iu(e,t,n);default:return t}return t}function Mu(e,t){let r=[...t];for(let n of e)if(!r.some((i)=>kn(i,n)))r.push(n);return r}function Iu(e,t,r){if(t.length===0)return e;if(e.length===0)return t;if(Qe(t[0])&&Qe(e[0]))return Du(e,t,r);if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}function Du(e,t,r){let n=[...t];for(let i of e){if(!Qe(i)){n.push(i);continue}let s=["id","name","key","path","type"],a=!1;for(let o of s)if(o in i){if(n.find((c)=>Qe(c)&&(o in c)&&c[o]===i[o])){a=!0;break}}if(!a)n.push(i)}return n}function Fu(e,t,r,n){let i=t;if(Qe(i)&&n.has(i))return n.get(i);let s={...e};if(Qe(i))n.set(i,s);for(let a in i){if(!Object.prototype.hasOwnProperty.call(i,a))continue;let o=i[a],c=s[a];if(r.skipNullish&&(o===null||o===void 0))continue;if(o===null||o===void 0){s[a]=o;continue}if(Qe(o)&&Qe(c))s[a]=so(c,o,r,n);else if(Array.isArray(o)||Array.isArray(c))s[a]=ao(c,o,r.arrayMergeMode||"smart",n);else s[a]=o}return s}function oo(e,t,r="replace"){return ku(e,t,{arrayMergeMode:r==="replace"?"replace":"smart",skipNullish:!0})}function kn(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!kn(e[r],t[r]))return!1;return!0}if(Qe(e)&&Qe(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!kn(e[i],t[i]))return!1}return!0}return!1}function Qe(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class lo{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(e,t,r={}){let{arrayStrategy:n="replace",useCache:i=!0,cacheTtl:s,trackPerformance:a=!0,verbose:o=!1}=r;if(i){let f=ni.getWithFileCheck("file",e);if(f){if(o)console.log(`Configuration loaded from cache: ${e}`);return f}}let c=async()=>{if(!Jr(e))return null;try{let f=`?t=${Date.now()}`,u=await import(e+f),l=u.default||u,g="default"in u,d=Object.keys(u).length>0;if(!g&&!d)throw new hi(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof l!=="object"||l===null||Array.isArray(l))throw new hi(e,Error("Configuration must export a valid object"),"unknown");let $={config:oo(t,l,n),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(i)ni.setWithFileCheck("file",$,e,s);return $}catch(f){throw f instanceof Error?er.configLoad(e,f):er.configLoad(e,Error(String(f)))}};if(a)return Mn.track("loadFromPath",c,{path:e});return c()}async tryLoadFromPaths(e,t,r={}){for(let n of e)try{let i=await this.loadFromPath(n,t,r);if(i)return i}catch(i){if(i instanceof Error&&i.name==="ConfigLoadError")throw i;if(r.verbose)console.warn(`Failed to load config from ${n}:`,i)}return null}generateConfigPaths(e,t,r){let n=this.generateNamePatterns(e,r),i=[];for(let s of n)for(let a of this.extensions)i.push(mn(t,`${s}${a}`));return i}generateNamePatterns(e,t){let r=[];if(r.push("config",".config"),e)r.push(e,`.${e}.config`,`${e}.config`,`.${e}`);let n=t===void 0?[]:Array.isArray(t)?t:[t];for(let s of n){if(!s)continue;if(r.push(s,`.${s}.config`,`${s}.config`,`.${s}`),e)r.push(`${e}.${s}.config`,`.${e}.${s}.config`)}let i=new Set;return r.filter((s)=>{if(!s||i.has(s))return!1;return i.add(s),!0})}checkFileAccess(e){return Pu(async()=>{return Jr(e)},{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,r){let n=[];if(!Jr(e))return n;if(t||r){let i=this.generateNamePatterns(t||"",r);for(let s of i)for(let a of this.extensions){let o=mn(e,`${s}${a}`);if(await this.checkFileAccess(o))n.push(o)}}else try{let{readdirSync:i}=await import("fs"),s=i(e);for(let a of s)if(this.looksLikeConfigFile(a)){let o=mn(e,a);if(await this.checkFileAccess(o))n.push(o)}}catch{return[]}return n}looksLikeConfigFile(e){return[/\.config\.(ts|js|mjs|cjs|json|mts|cts)$/,/^\..*\.(ts|js|mjs|cjs|json|mts|cts)$/,/config\.(ts|js|mjs|cjs|json|mts|cts)$/].some((t)=>t.test(e))}async validateConfigFile(e){let t=[];try{if(!Jr(e))return t.push("Configuration file does not exist"),t;let r=await import(e),n=r.default||r;if(n===void 0)t.push("Configuration file must export a default value or named exports");else if(typeof n!=="object"||n===null)t.push("Configuration must be an object");else if(Array.isArray(n))t.push("Configuration cannot be an array at the root level");if(e.endsWith(".json"))try{let{readFileSync:i}=await import("fs"),s=i(e,"utf8");JSON.parse(s)}catch(i){t.push(`Invalid JSON syntax: ${i}`)}}catch(r){t.push(`Failed to load configuration file: ${r}`)}return t}async getFileModificationTime(e){try{let{statSync:t}=await import("fs");return t(e).mtime}catch{return null}}async preloadConfigurations(e,t={}){let r=new Map;return await Promise.allSettled(e.map(async(n)=>{try{let i=await this.loadFromPath(n,{},t);if(i)r.set(n,i.config)}catch(i){if(t.verbose)console.warn(`Failed to preload ${n}:`,i)}})),r}}class co{async validateConfiguration(e,t,r={}){let{stopOnFirstError:n=!1,validateRequired:i=!0,validateTypes:s=!0,customRules:a=[],trackPerformance:o=!0,verbose:c=!1}=r,f=async()=>{let u=[],l=[],g={stopOnFirstError:n,validateRequired:i,validateTypes:s,customRules:a,trackPerformance:o,verbose:c};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,g);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...a],g);else return this.validateWithJSONSchema(e,t,g)}catch(d){return u.push({path:"",message:`Validation failed: ${d}`,rule:"system"}),{isValid:!1,errors:u,warnings:l}}};if(o)return await Mn.track("validateConfiguration",f);return f()}async validateWithSchemaFile(e,t,r){try{if(!gf(t))throw new di(t,[{path:"",message:"Schema file does not exist"}]);let n=await import(t),i=n.default||n;if(Array.isArray(i))return this.validateWithRules(e,i,r);else return this.validateWithJSONSchema(e,i,r)}catch(n){throw new di(t,[{path:"",message:`Failed to load schema: ${n}`}])}}validateWithJSONSchema(e,t,r){let n=[],i=[];return this.validateObjectAgainstSchema(e,t,"",n,i,r),{isValid:n.length===0,errors:n,warnings:i}}validateObjectAgainstSchema(e,t,r,n,i,s){if(s.validateTypes&&t.type){let a=Array.isArray(e)?"array":typeof e,o=Array.isArray(t.type)?t.type:[t.type];if(!o.includes(a)){if(n.push({path:r,message:`Expected type ${o.join(" or ")}, got ${a}`,expected:o.join(" or "),actual:a,rule:"type"}),s.stopOnFirstError)return}}if(t.enum&&!t.enum.includes(e)){if(n.push({path:r,message:`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"}),s.stopOnFirstError)return}if(typeof e==="string"){if(t.minLength!==void 0&&e.length<t.minLength)n.push({path:r,message:`String length must be at least ${t.minLength}`,expected:`>= ${t.minLength}`,actual:e.length,rule:"minLength"});if(t.maxLength!==void 0&&e.length>t.maxLength)n.push({path:r,message:`String length must not exceed ${t.maxLength}`,expected:`<= ${t.maxLength}`,actual:e.length,rule:"maxLength"});if(t.pattern){if(!new RegExp(t.pattern).test(e))n.push({path:r,message:`String does not match pattern ${t.pattern}`,expected:t.pattern,actual:e,rule:"pattern"})}}if(typeof e==="number"){if(t.minimum!==void 0&&e<t.minimum)n.push({path:r,message:`Value must be at least ${t.minimum}`,expected:`>= ${t.minimum}`,actual:e,rule:"minimum"});if(t.maximum!==void 0&&e>t.maximum)n.push({path:r,message:`Value must not exceed ${t.maximum}`,expected:`<= ${t.maximum}`,actual:e,rule:"maximum"})}if(Array.isArray(e)&&t.items)for(let a=0;a<e.length;a++){let o=r?`${r}[${a}]`:`[${a}]`;if(this.validateObjectAgainstSchema(e[a],t.items,o,n,i,s),s.stopOnFirstError&&n.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let a=e;if(s.validateRequired&&t.required){for(let o of t.required)if(!(o in a)){if(n.push({path:r?`${r}.${o}`:o,message:`Missing required property '${o}'`,expected:"required",rule:"required"}),s.stopOnFirstError)return}}if(t.properties){for(let[o,c]of Object.entries(t.properties))if(o in a){let f=r?`${r}.${o}`:o;if(this.validateObjectAgainstSchema(a[o],c,f,n,i,s),s.stopOnFirstError&&n.length>0)return}}if(t.additionalProperties===!1){let o=new Set(Object.keys(t.properties||{}));for(let c of Object.keys(a))if(!o.has(c))i.push({path:r?`${r}.${c}`:c,message:`Additional property '${c}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,r){let n=[],i=[];for(let s of t)try{let a=this.getValueByPath(e,s.path),o=this.validateWithRule(a,s,s.path);if(n.push(...o),r.stopOnFirstError&&n.length>0)break}catch(a){n.push({path:s.path,message:`Rule validation failed: ${a}`,rule:"system"})}return{isValid:n.length===0,errors:n,warnings:i}}validateWithRule(e,t,r){let n=[];if(t.required&&(e===void 0||e===null))return n.push({path:r,message:t.message||`Property '${r}' is required`,expected:"required",rule:"required"}),n;if(e===void 0||e===null)return n;if(t.type){let i=Array.isArray(e)?"array":typeof e;if(i!==t.type)n.push({path:r,message:t.message||`Expected type ${t.type}, got ${i}`,expected:t.type,actual:i,rule:"type"})}if(t.min!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i<t.min)n.push({path:r,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:i,rule:"min"})}if(t.max!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i>t.max)n.push({path:r,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:i,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))n.push({path:r,message:t.message||`Value does not match pattern ${t.pattern}`,expected:t.pattern.toString(),actual:e,rule:"pattern"})}if(t.enum&&!t.enum.includes(e))n.push({path:r,message:t.message||`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"});if(t.validator){let i=t.validator(e);if(i)n.push({path:r,message:t.message||i,rule:"custom"})}return n}getValueByPath(e,t){if(!t)return e;let r=t.split("."),n=e;for(let i of r)if(n&&typeof n==="object"&&i in n)n=n[i];else return;return n}generateRulesFromInterface(e){let t=[],r=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let n of r){let[,i,s,a]=n;t.push({path:i,required:!s,type:this.mapTypeScriptType(a)})}return t}mapTypeScriptType(e){switch(e.toLowerCase()){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"object";default:return"object"}}static createCommonRules(){return{server:[{path:"port",required:!0,type:"number",min:1,max:65535},{path:"host",required:!0,type:"string",min:1},{path:"ssl",type:"boolean"}],database:[{path:"url",required:!0,type:"string",min:1},{path:"pool",type:"number",min:1,max:100},{path:"timeout",type:"number",min:0}],api:[{path:"baseUrl",required:!0,type:"string",pattern:Nu},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}function Wu(e){if(!e)return"";let t=Array.isArray(e)?e.filter(Boolean):[e];if(t.length===0)return"";if(t.length===1)return` or alias "${t[0]}"`;return` or aliases ${t.map((r)=>`"${r}"`).join(", ")}`}class fo{fileLoader=new lo;envProcessor=new Vn;validator=new co;async loadConfig(e){let t=Date.now(),{cache:r,performance:n,schema:i,validate:s,...a}=e;try{if(r?.enabled){let c=this.checkCache(a.name||"",a);if(c)return c}let o;try{o=await this.loadConfigurationStrategies(a,!0,r)}catch(c){let f=a.__strictErrorHandling;if(c instanceof Error&&c.name==="ConfigNotFoundError"){if(f)throw c;o={...await this.applyEnvironmentVariables(a.name||"",a.defaultConfig,a.checkEnv!==!1,a.verbose||!1),warnings:[`No configuration file found for "${a.name||"config"}", using defaults with environment variables`]}}else if(c instanceof Error&&c.name==="ConfigLoadError"){let u=c.message.includes("EACCES")||c.message.includes("EPERM")||c.message.includes("permission denied"),l=!u&&(c.message.includes("syntax")||c.message.includes("Expected")||c.message.includes("Unexpected")||c.message.includes("BuildMessage")||c.message.includes("errors building")),g=c.message.includes("Configuration must export a valid object")||c.message.includes("Configuration file is empty and exports nothing");if(f&&(g||u))throw c;if(l&&(!f||!g))o={...await this.applyEnvironmentVariables(a.name||"",a.defaultConfig,a.checkEnv!==!1,a.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!f)o={...await this.applyEnvironmentVariables(a.name||"",a.defaultConfig,a.checkEnv!==!1,a.verbose||!1),warnings:[`Configuration loading error, using defaults: ${c.message}`]};else throw c}else o={...await this.applyEnvironmentVariables(a.name||"",a.defaultConfig,a.checkEnv!==!1,a.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${c instanceof Error?c.message:String(c)}`]}}if(i||s)await this.validateConfiguration(o.config,i,s,a.name);if(r?.enabled&&o)this.cacheResult(a.name||"",o,r,a);if(n?.enabled){let c={operation:"loadConfig",duration:Date.now()-t,configName:a.name,timestamp:new Date};if(n.onMetrics)n.onMetrics(c);if(n.slowThreshold&&c.duration>n.slowThreshold)mt.warn(`Slow configuration loading detected: ${c.duration}ms for ${a.name}`);o.metrics=c}return o}catch(o){if(o instanceof Error&&o.name==="ConfigNotFoundError")throw o;let c=Date.now()-t;throw mt.error(`Configuration loading failed after ${c}ms:`,[o instanceof Error?o:Error(String(o))]),o}}async loadConfigurationStrategies(e,t=!1,r){let{name:n="",alias:i,cwd:s,configDir:a,defaultConfig:o,checkEnv:c=!0,arrayStrategy:f="replace",verbose:u=!1}=e,l=s||mi.cwd(),g=[],d=await this.loadLocalConfiguration(n,i,l,a,o,f,u,c,r);if(d)return g.push(...this.getLocalSearchPaths(n,i,l,a)),this.finalizeResult(d,g,c,n,u);let $=await this.loadHomeConfiguration(n,i,o,f,u,c);if($)return g.push(...this.getHomeSearchPaths(n,i)),this.finalizeResult($,g,c,n,u);let v=await this.loadPackageJsonConfiguration(n,i,l,o,f,u,c);if(v)return g.push(Xe(l,"package.json")),this.finalizeResult(v,g,c,n,u);if(g.push(...this.getAllSearchPaths(n,i,l,a)),t)throw er.configNotFound(n,g,i);return{...await this.applyEnvironmentVariables(n,o,c,u),warnings:[`No configuration file found for "${n}"${Wu(i)}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,r,n,i,s,a,o,c){let f=o?Yr(e,i,a):i,u=this.getLocalDirectories(r,n);for(let l of u){if(a)mt.info(`Searching for configuration in: ${l}`);let g=this.fileLoader.generateConfigPaths(e,l,t),d=await this.fileLoader.tryLoadFromPaths(g,f,{arrayStrategy:s,verbose:a,cacheTtl:c?.ttl,useCache:!c?.ttl||c.ttl>100});if(d){if(a)mt.success(`Configuration loaded from: ${d.source.path}`);return d}}return null}async loadHomeConfiguration(e,t,r,n,i,s){if(!e)return null;let a=s?Yr(e,r,i):r,o=[Xe(_t(),".config",e),Xe(_t(),".config"),_t()];for(let c of o){if(i)mt.info(`Checking home directory: ${c}`);let f=this.fileLoader.generateConfigPaths(e,c,t),u=await this.fileLoader.tryLoadFromPaths(f,a,{arrayStrategy:n,verbose:i});if(u){if(i)mt.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,t,r,n,i,s,a){let o=a?Yr(e,n,s):n;try{let c=Xe(r,"package.json");if(!Oc(c))return null;let f={};try{f=JSON.parse(Pc(c,"utf8"))}catch(g){if(s)mt.warn("Failed to parse package.json:",[g instanceof Error?g:Error(String(g))]);return null}let u=f[e],l=e;if(!u&&t){let g=Array.isArray(t)?t:[t];for(let d of g){if(!d)continue;if(f[d]){u=f[d],l=d;break}}}if(u&&typeof u==="object"&&!Array.isArray(u)){if(s)mt.success(`Configuration loaded from package.json: ${l}`);return{config:oo(o,u,i),source:{type:"package.json",path:c,priority:30,timestamp:new Date}}}}catch(c){if(s)mt.warn("Failed to load package.json:",[c instanceof Error?c:Error(String(c))])}return null}async applyEnvironmentVariables(e,t,r,n){if(!r||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:Yr(e,t,n),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,r,n,i){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,r,n){let i=[];if(r){let s=r(e);if(s)i.push(...s)}if(t){let s=await this.validator.validateConfiguration(e,t);if(!s.isValid)i.push(...s.errors.map((a)=>a.path?`${a.path}: ${a.message}`:a.message))}if(i.length>0)throw er.configValidation(n||"unknown",i,n)}checkCache(e,t){let r=this.generateCacheKey(e,t);return ni.get(r)||null}cacheResult(e,t,r,n){let i=this.generateCacheKey(e,n);ni.set(i,t,void 0,r.ttl)}generateCacheKey(e,t){let r=[e];if(t.alias){let n=Array.isArray(t.alias)?t.alias.join(","):t.alias;r.push(`alias:${n}`)}if(t.cwd)r.push(`cwd:${t.cwd}`);if(t.configDir)r.push(`configDir:${t.configDir}`);if("checkEnv"in t)r.push(`checkEnv:${t.checkEnv}`);return r.join("|")}getLocalDirectories(e,t){return Array.from(new Set([e,Xe(e,"config"),Xe(e,".config"),t?Xe(e,t):void 0].filter(Boolean)))}getAllSearchPaths(e,t,r,n){let i=[];return i.push(...this.getLocalSearchPaths(e,t,r,n)),i.push(...this.getHomeSearchPaths(e,t)),i.push(Xe(r,"package.json")),i}getLocalSearchPaths(e,t,r,n){let i=this.getLocalDirectories(r,n),s=[];for(let a of i)s.push(...this.fileLoader.generateConfigPaths(e,a,t));return s}getHomeSearchPaths(e,t){if(!e)return[];let r=[Xe(_t(),".config",e),Xe(_t(),".config"),_t()],n=[];for(let i of r)n.push(...this.fileLoader.generateConfigPaths(e,i,t));return n}async loadConfigWithResult(e){return this.loadConfig(e)}}function Yr(e,t,r=!1){let n=new Vn,i=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function s(a,o=[]){let c={...a};for(let[f,u]of Object.entries(a)){let l=[...o,f],g=[`${i}_${l.join("_").toUpperCase()}`,`${i}_${l.map((v)=>v.toUpperCase()).join("")}`,`${i}_${l.map((v)=>v.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],d,$;for(let v of g)if(d=mi.env[v],d!==void 0){$=v;break}if(d!==void 0&&$)if(typeof u==="boolean")c[f]=["true","1","yes"].includes(d.toLowerCase());else if(typeof u==="number"){let v=Number(d);if(!Number.isNaN(v))c[f]=v}else if(Array.isArray(u))try{c[f]=JSON.parse(d)}catch{c[f]=d.split(",").map((v)=>v.trim())}else c[f]=d;else if(u&&typeof u==="object"&&!Array.isArray(u))c[f]=s(u,l)}return c}return s(t)}var ni,Mn,yf,Cf=(e)=>e,$f=(e,t)=>{for(var r in t)yf(e,r,{get:t[r],enumerable:!0,configurable:!0,set:wf.bind(t,r)})},Ef=(e,t)=>()=>(e&&(t=e(e=0)),t),Ia,_a,Qt,pr,Ha,Yf,Zf,ya,qr,Sn,Be,ge,qf,Ca,Xf,wa,zf,Qf,pn,eu,$a,Ea,gn,tu,ru,iu,nu,Xr,ja,su,Ve,au,ou,va,zr,bn,Ie,ee,lu,Sa,cu,ba,fu,uu,yn,hu,Aa,xa,du,Cn,mu,pu,gu,yu,Cu,Qr,Ka,wu,$u="0.15.6",Ye,ci,dr,An,xn,fi,Tn,Rn,mr,On,Pn,xt,Ja,Ua,at,Ct,Ya,Za,Eu,Su,qa,ui,gg,We,re,yg,Au,Cg,xu,wg,$g,Ta,Eg,Tu,Ru,vg,Ra,Sg,bg,Ag,xg,Tg,wn,Ou,Rg,ot,za,hi,Qa,eo,Bn,to,ro,di,io,no,er,Nu,mt,Og,Pg,kg,Lu,uo;var ho=le(()=>{ni=new ka,Mn=new Ma,yf=Object.defineProperty;Ia={};$f(Ia,{withErrorRecovery:()=>Na,tryLoadConfig:()=>jf,loadConfigWithResult:()=>_f,loadConfig:()=>Va,isRetryableError:()=>Nf,isConfigNotFoundError:()=>Ff,isBunfigError:()=>Wa,globalPerformanceMonitor:()=>pr,globalCache:()=>Qt,getEnvOrDefault:()=>Wf,generateConfigTypes:()=>Kf,defaultGeneratedDir:()=>Za,defaultConfigDir:()=>Ya,deepMergeWithArrayStrategy:()=>Wn,deepMerge:()=>La,createLibraryConfig:()=>Jf,config:()=>Hf,bunfigPlugin:()=>Uf,applyEnvVarsToConfig:()=>ur,TypeGenerationError:()=>Rn,SchemaValidationError:()=>mr,PluginError:()=>Pn,PerformanceMonitor:()=>Dn,FileSystemError:()=>Tn,ErrorFactory:()=>xt,EnvVarError:()=>fi,EnvProcessor:()=>pi,ConfigValidator:()=>Ln,ConfigValidationError:()=>An,ConfigNotFoundError:()=>ci,ConfigMergeError:()=>xn,ConfigLoader:()=>Gn,ConfigLoadError:()=>dr,ConfigFileLoader:()=>gi,ConfigCache:()=>In,CacheUtils:()=>Ha,BunfigError:()=>Ye,BrowserConfigError:()=>On,ArrayMergeStrategies:()=>Ja});Eu=Ef(async()=>{_a=import.meta.require,Qt=new In,pr=new Dn,Ha={createKey:vf,isEquivalent:Sf,estimateMemoryUsage:bf},Yf=ri(En.cwd(),"config"),Zf=ri(En.cwd(),"src/generated"),ya=ti.env.CLARITY_LOG_DIR||Nc(Tf(),"logs"),qr={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:ya,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1},Sn=await Rf(),Be={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,reset:"\x1B[0m"},ge=Be,qf=Be.red,Ca=Be.green,Xf=Be.yellow,wa=Be.blue,zf=Be.magenta,Qf=Be.cyan,pn=Be.white,eu=Be.gray,$a=Be.bgRed,Ea=Be.bgYellow,gn=Be.bold,tu=Be.dim,ru=Be.italic,iu=Be.underline,nu=Be.reset,Xr={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},ja={debug:"\uD83D\uDD0D",info:wa("\u2139"),success:Ca("\u2713"),warning:Ea(pn(gn(" WARN "))),error:$a(pn(gn(" ERROR ")))},su=new ai("stacks"),Ve=new ai("bunfig",{showTags:!0}),au=_e(hr.cwd(),"config"),ou=_e(hr.cwd(),"src/generated"),va=ei.env.CLARITY_LOG_DIR||Dc(Mf(),"logs"),zr={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:va,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},bn=await If(),Ie={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bgGray:(e)=>`\x1B[100m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,strikethrough:(e)=>`\x1B[9m${e}\x1B[0m`,reset:"\x1B[0m"},ee=Ie,lu=Ie.red,Sa=Ie.green,cu=Ie.yellow,ba=Ie.blue,fu=Ie.magenta,uu=Ie.cyan,yn=Ie.white,hu=Ie.gray,Aa=Ie.bgRed,xa=Ie.bgYellow,du=Ie.bgGray,Cn=Ie.bold,mu=Ie.dim,pu=Ie.italic,gu=Ie.underline,yu=Ie.strikethrough,Cu=Ie.reset,Qr={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Ka={debug:"\uD83D\uDD0D",info:ba("\u2139"),success:Sa("\u2713"),warning:xa(yn(Cn(" WARN "))),error:Aa(yn(Cn(" ERROR ")))},wu=new li("stacks"),Ye=class extends Error{timestamp;context;constructor(e,t={}){super(e);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}toString(){let e=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([t,r])=>`${t}: ${r}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${e}`}},ci=class extends Ye{code="CONFIG_NOT_FOUND";constructor(e,t,r){let n=r?` or alias "${r}"`:"";super(`Configuration "${e}"${n} not found`,{configName:e,alias:r,searchPaths:t,searchPathCount:t.length})}},dr=class extends Ye{code="CONFIG_LOAD_ERROR";constructor(e,t,r){super(`Failed to load configuration from "${e}": ${t.message}`,{configPath:e,configName:r,originalError:t.name,originalMessage:t.message});this.cause=t}},An=class extends Ye{code="CONFIG_VALIDATION_ERROR";constructor(e,t,r){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:r,validationErrors:t,errorCount:t.length})}},xn=class extends Ye{code="CONFIG_MERGE_ERROR";constructor(e,t,r,n){super(`Failed to merge configuration from "${e}" with "${t}": ${r.message}`,{sourcePath:e,targetPath:t,configName:n,originalError:r.name,originalMessage:r.message});this.cause=r}},fi=class extends Ye{code="ENV_VAR_ERROR";constructor(e,t,r,n){super(`Failed to parse environment variable "${e}" with value "${t}" as ${r}`,{envKey:e,envValue:t,expectedType:r,configName:n})}},Tn=class extends Ye{code="FILE_SYSTEM_ERROR";constructor(e,t,r){super(`File system ${e} failed for "${t}": ${r.message}`,{operation:e,path:t,originalError:r.name,originalMessage:r.message});this.cause=r}},Rn=class extends Ye{code="TYPE_GENERATION_ERROR";constructor(e,t,r){super(`Failed to generate types from "${e}" to "${t}": ${r.message}`,{configDir:e,outputPath:t,originalError:r.name,originalMessage:r.message});this.cause=r}},mr=class extends Ye{code="SCHEMA_VALIDATION_ERROR";constructor(e,t,r){super(`Schema validation failed${r?` for config "${r}"`:""}`,{schemaPath:e,configName:r,validationErrors:t,errorCount:t.length})}},On=class extends Ye{code="BROWSER_CONFIG_ERROR";constructor(e,t,r,n){super(`Failed to fetch configuration from "${e}": ${t} ${r}`,{endpoint:e,status:t,statusText:r,configName:n})}},Pn=class extends Ye{code="PLUGIN_ERROR";constructor(e,t,r){super(`Plugin "${e}" failed during ${t}: ${r.message}`,{pluginName:e,operation:t,originalError:r.name,originalMessage:r.message});this.cause=r}},xt={configNotFound(e,t,r){return new ci(e,t,r)},configLoad(e,t,r){return new dr(e,t,r)},configValidation(e,t,r){return new An(e,t,r)},configMerge(e,t,r,n){return new xn(e,t,r,n)},envVar(e,t,r,n){return new fi(e,t,r,n)},fileSystem(e,t,r){return new Tn(e,t,r)},typeGeneration(e,t,r){return new Rn(e,t,r)},schemaValidation(e,t,r){return new mr(e,t,r)},browserConfig(e,t,r,n){return new On(e,t,r,n)},plugin(e,t,r){return new Pn(e,t,r)}},Ja={replace:"replace",concat:"concat",smart:"smart"},Ua=/^https?:\/\//,at=new li("bunfig",{showTags:!0}),Ct=new Gn,Ya=He(Rt.cwd(),"config"),Za=He(Rt.cwd(),"src/generated")});Su=ii.env.CLARITY_LOG_DIR||sf(vu(),"logs"),qa={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Su,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},ui={...qa},gg=(async()=>{try{let{loadConfig:e}=await Eu().then(()=>Ia),t=await e({name:"clarity",alias:"logging",defaultConfig:qa,cwd:ii.cwd()});if(t)Object.assign(ui,t)}catch{}return ui})();We={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bgGray:(e)=>`\x1B[100m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,strikethrough:(e)=>`\x1B[9m${e}\x1B[0m`,reset:"\x1B[0m"},re=We,yg=We.red,Au=We.green,Cg=We.yellow,xu=We.blue,wg=We.magenta,$g=We.cyan,Ta=We.white,Eg=We.gray,Tu=We.bgRed,Ru=We.bgYellow,vg=We.bgGray,Ra=We.bold,Sg=We.dim,bg=We.italic,Ag=We.underline,xg=We.strikethrough,Tg=We.reset,wn={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Ou={debug:"\uD83D\uDD0D",info:xu("\u2139"),success:Au("\u2713"),warning:Ru(Ta(Ra(" WARN "))),error:Tu(Ta(Ra(" ERROR ")))};Rg=new yi("stacks");ot=class ot extends Error{timestamp;context;constructor(e,t={}){super(e);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}toString(){let e=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([t,r])=>`${t}: ${r}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${e}`}};za=class za extends ot{code="CONFIG_NOT_FOUND";constructor(e,t,r){let n=r===void 0?[]:Array.isArray(r)?r.filter(Boolean):[r],i="";if(n.length===1)i=` or alias "${n[0]}"`;else if(n.length>1)i=` or aliases ${n.map((s)=>`"${s}"`).join(", ")}`;super(`Configuration "${e}"${i} not found`,{configName:e,alias:r,searchPaths:t,searchPathCount:t.length})}};hi=class hi extends ot{code="CONFIG_LOAD_ERROR";constructor(e,t,r){super(`Failed to load configuration from "${e}": ${t.message}`,{configPath:e,configName:r,originalError:t.name,originalMessage:t.message});this.cause=t}};Qa=class Qa extends ot{code="CONFIG_VALIDATION_ERROR";constructor(e,t,r){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:r,validationErrors:t,errorCount:t.length})}};eo=class eo extends ot{code="CONFIG_MERGE_ERROR";constructor(e,t,r,n){super(`Failed to merge configuration from "${e}" with "${t}": ${r.message}`,{sourcePath:e,targetPath:t,configName:n,originalError:r.name,originalMessage:r.message});this.cause=r}};Bn=class Bn extends ot{code="ENV_VAR_ERROR";constructor(e,t,r,n){super(`Failed to parse environment variable "${e}" with value "${t}" as ${r}`,{envKey:e,envValue:t,expectedType:r,configName:n})}};to=class to extends ot{code="FILE_SYSTEM_ERROR";constructor(e,t,r){super(`File system ${e} failed for "${t}": ${r.message}`,{operation:e,path:t,originalError:r.name,originalMessage:r.message});this.cause=r}};ro=class ro extends ot{code="TYPE_GENERATION_ERROR";constructor(e,t,r){super(`Failed to generate types from "${e}" to "${t}": ${r.message}`,{configDir:e,outputPath:t,originalError:r.name,originalMessage:r.message});this.cause=r}};di=class di extends ot{code="SCHEMA_VALIDATION_ERROR";constructor(e,t,r){super(`Schema validation failed${r?` for config "${r}"`:""}`,{schemaPath:e,configName:r,validationErrors:t,errorCount:t.length})}};io=class io extends ot{code="BROWSER_CONFIG_ERROR";constructor(e,t,r,n){super(`Failed to fetch configuration from "${e}": ${t} ${r}`,{endpoint:e,status:t,statusText:r,configName:n})}};no=class no extends ot{code="PLUGIN_ERROR";constructor(e,t,r){super(`Plugin "${e}" failed during ${t}: ${r.message}`,{pluginName:e,operation:t,originalError:r.name,originalMessage:r.message});this.cause=r}};er={configNotFound(e,t,r){return new za(e,t,r)},configLoad(e,t,r){return new hi(e,t,r)},configValidation(e,t,r){return new Qa(e,t,r)},configMerge(e,t,r,n){return new eo(e,t,r,n)},envVar(e,t,r,n){return new Bn(e,t,r,n)},fileSystem(e,t,r){return new to(e,t,r)},typeGeneration(e,t,r){return new ro(e,t,r)},schemaValidation(e,t,r){return new di(e,t,r)},browserConfig(e,t,r,n){return new io(e,t,r,n)},plugin(e,t,r){return new no(e,t,r)}};Nu=/^https?:\/\//;mt=new yi("bunfig",{showTags:!0});Og=new fo;Pg=Xe(mi.cwd(),"config"),kg=Xe(mi.cwd(),"src/generated"),Lu={cwd:Rc.cwd(),root:"./src",entrypoints:["**/*.{ts,tsx,mts,cts,vue,stx}"],outdir:"./dist",keepComments:!0,clean:!0,tsconfigPath:"./tsconfig.json",outputStructure:"mirror",verbose:!1,importOrder:["bun"],declarationMap:!1},uo=Lu});var mo;var po=le(()=>{mo=new Set(["ANGLE_instanced_arrays","ARIAMixin","AacBitstreamFormat","AacEncoderConfig","AbortController","AbortSignal","AbortSignalEventMap","AbstractRange","AbstractWorker","AbstractWorkerEventMap","ActiveXObject","AddEventListenerOptions","AddressErrors","AddressType","AddressValue","AesCbcParams","AesCtrParams","AesDerivedKeyParams","AesGcmParams","AesKeyAlgorithm","AesKeyGenParams","AggregateError","AggregateErrorConstructor","Algorithm","AlgorithmIdentifier","AlignSetting","AllAcceptedCredentialsOptions","AllowSharedBufferSource","AlphaOption","AnalyserNode","AnalyserOptions","Animatable","Animation","AnimationEffect","AnimationEvent","AnimationEventInit","AnimationEventMap","AnimationFrameProvider","AnimationPlayState","AnimationPlaybackEvent","AnimationPlaybackEventInit","AnimationReplaceState","AnimationTimeline","AppendMode","Array","ArrayBuffer","ArrayBufferConstructor","ArrayBufferLike","ArrayBufferTypes","ArrayBufferView","ArrayConstructor","ArrayIterator","ArrayLike","AssignedNodesOptions","AsyncDisposable","AsyncDisposableStack","AsyncDisposableStackConstructor","AsyncGenerator","AsyncGeneratorFunction","AsyncGeneratorFunctionConstructor","AsyncIterable","AsyncIterableIterator","AsyncIterator","AsyncIteratorObject","Atomics","AttestationConveyancePreference","Attr","Audio","AudioBuffer","AudioBufferOptions","AudioBufferSourceNode","AudioBufferSourceOptions","AudioConfiguration","AudioContext","AudioContextLatencyCategory","AudioContextOptions","AudioContextState","AudioData","AudioDataCopyToOptions","AudioDataInit","AudioDataOutputCallback","AudioDecoder","AudioDecoderConfig","AudioDecoderEventMap","AudioDecoderInit","AudioDecoderSupport","AudioDestinationNode","AudioEncoder","AudioEncoderConfig","AudioEncoderEventMap","AudioEncoderInit","AudioEncoderSupport","AudioListener","AudioNode","AudioNodeOptions","AudioParam","AudioParamMap","AudioProcessingEvent","AudioProcessingEventInit","AudioSampleFormat","AudioScheduledSourceNode","AudioScheduledSourceNodeEventMap","AudioTimestamp","AudioWorklet","AudioWorkletNode","AudioWorkletNodeEventMap","AudioWorkletNodeOptions","AuthenticationExtensionsClientInputs","AuthenticationExtensionsClientInputsJSON","AuthenticationExtensionsClientOutputs","AuthenticationExtensionsClientOutputsJSON","AuthenticationExtensionsLargeBlobInputs","AuthenticationExtensionsLargeBlobInputsJSON","AuthenticationExtensionsLargeBlobOutputs","AuthenticationExtensionsLargeBlobOutputsJSON","AuthenticationExtensionsPRFInputs","AuthenticationExtensionsPRFInputsJSON","AuthenticationExtensionsPRFOutputs","AuthenticationExtensionsPRFOutputsJSON","AuthenticationExtensionsPRFValues","AuthenticationExtensionsPRFValuesJSON","AuthenticationResponseJSON","AuthenticatorAssertionResponse","AuthenticatorAssertionResponseJSON","AuthenticatorAttachment","AuthenticatorAttestationResponse","AuthenticatorAttestationResponseJSON","AuthenticatorResponse","AuthenticatorSelectionCriteria","AuthenticatorTransport","AutoFill","AutoFillAddressKind","AutoFillBase","AutoFillContactField","AutoFillContactKind","AutoFillCredentialField","AutoFillField","AutoFillNormalField","AutoFillSection","AutoKeyword","AutomationRate","AvcBitstreamFormat","AvcEncoderConfig","Awaited","BarProp","Base64URLString","BaseAudioContext","BaseAudioContextEventMap","BeforeUnloadEvent","BigInt","BigInt64Array","BigInt64ArrayConstructor","BigIntConstructor","BigIntToLocaleStringOptions","BigInteger","BigUint64Array","BigUint64ArrayConstructor","BinaryType","BiquadFilterNode","BiquadFilterOptions","BiquadFilterType","BitrateMode","Blob","BlobCallback","BlobEvent","BlobEventInit","BlobPart","BlobPropertyBag","Body","BodyInit","Boolean","BooleanConstructor","BroadcastChannel","BroadcastChannelEventMap","Buffer","BufferEncoding","BufferSource","BuiltinIteratorReturn","Bun","BunFile","ByteLengthQueuingStrategy","CDATASection","COSEAlgorithmIdentifier","CSS","CSSAnimation","CSSConditionRule","CSSContainerRule","CSSCounterStyleRule","CSSFontFaceRule","CSSFontFeatureValuesRule","CSSFontPaletteValuesRule","CSSGroupingRule","CSSImageValue","CSSImportRule","CSSKeyframeRule","CSSKeyframesRule","CSSKeywordValue","CSSKeywordish","CSSLayerBlockRule","CSSLayerStatementRule","CSSMathClamp","CSSMathInvert","CSSMathMax","CSSMathMin","CSSMathNegate","CSSMathOperator","CSSMathProduct","CSSMathSum","CSSMathValue","CSSMatrixComponent","CSSMatrixComponentOptions","CSSMediaRule","CSSNamespaceRule","CSSNestedDeclarations","CSSNumberish","CSSNumericArray","CSSNumericBaseType","CSSNumericType","CSSNumericValue","CSSPageDescriptors","CSSPageRule","CSSPerspective","CSSPerspectiveValue","CSSPositionTryDescriptors","CSSPositionTryRule","CSSPropertyRule","CSSRotate","CSSRule","CSSRuleList","CSSScale","CSSScopeRule","CSSSkew","CSSSkewX","CSSSkewY","CSSStartingStyleRule","CSSStyleDeclaration","CSSStyleDeclarationBase","CSSStyleProperties","CSSStyleRule","CSSStyleSheet","CSSStyleSheetInit","CSSStyleValue","CSSSupportsRule","CSSTransformComponent","CSSTransformValue","CSSTransition","CSSTranslate","CSSUnitValue","CSSUnparsedSegment","CSSUnparsedValue","CSSVariableReferenceValue","CSSViewTransitionRule","Cache","CacheQueryOptions","CacheStorage","CalendarLike","CallableFunction","CanPlayTypeResult","CanvasCaptureMediaStreamTrack","CanvasCompositing","CanvasDirection","CanvasDrawImage","CanvasDrawPath","CanvasFillRule","CanvasFillStrokeStyles","CanvasFilters","CanvasFontKerning","CanvasFontStretch","CanvasFontVariantCaps","CanvasGradient","CanvasImageData","CanvasImageSmoothing","CanvasImageSource","CanvasLineCap","CanvasLineJoin","CanvasPath","CanvasPathDrawingStyles","CanvasPattern","CanvasRect","CanvasRenderingContext2D","CanvasRenderingContext2DSettings","CanvasSettings","CanvasShadowStyles","CanvasState","CanvasText","CanvasTextAlign","CanvasTextBaseline","CanvasTextDrawingStyles","CanvasTextRendering","CanvasTransform","CanvasUserInterface","Capitalize","CaretPosition","CaretPositionFromPointOptions","ChannelCountMode","ChannelInterpretation","ChannelMergerNode","ChannelMergerOptions","ChannelSplitterNode","ChannelSplitterOptions","CharacterData","CheckVisibilityOptions","ChildNode","ClassAccessorDecoratorContext","ClassAccessorDecoratorResult","ClassAccessorDecoratorTarget","ClassDecorator","ClassDecoratorContext","ClassFieldDecoratorContext","ClassGetterDecoratorContext","ClassMemberDecoratorContext","ClassMethodDecoratorContext","ClassSetterDecoratorContext","Client","ClientQueryOptions","ClientRect","ClientTypes","Clients","Clipboard","ClipboardEvent","ClipboardEventInit","ClipboardItem","ClipboardItemData","ClipboardItemOptions","ClipboardItems","CloseEvent","CloseEventInit","CodecState","Collator","CollatorConstructor","CollatorOptions","ColorGamut","ColorSpaceConversion","CommandEvent","CommandEventInit","Comment","CompileError","CompositeOperation","CompositeOperationOrAuto","CompositionEvent","CompositionEventInit","CompressionFormat","CompressionStream","ComputedEffectTiming","ComputedKeyframe","ConcatArray","Console","ConstantSourceNode","ConstantSourceOptions","ConstrainBoolean","ConstrainBooleanOrDOMString","ConstrainBooleanOrDOMStringParameters","ConstrainBooleanParameters","ConstrainDOMString","ConstrainDOMStringParameters","ConstrainDouble","ConstrainDoubleRange","ConstrainULong","ConstrainULongRange","ConstructorParameters","ContentVisibilityAutoStateChangeEvent","ContentVisibilityAutoStateChangeEventInit","ConvolverNode","ConvolverOptions","CookieChangeEvent","CookieChangeEventInit","CookieInit","CookieList","CookieListItem","CookieSameSite","CookieStore","CookieStoreDeleteOptions","CookieStoreEventMap","CookieStoreGetOptions","CookieStoreManager","CountQueuingStrategy","Credential","CredentialCreationOptions","CredentialMediationRequirement","CredentialPropertiesOutput","CredentialRequestOptions","CredentialsContainer","Crypto","CryptoKey","CryptoKeyPair","CurrentUserDetailsOptions","CustomElementConstructor","CustomElementRegistry","CustomEvent","CustomEventInit","CustomStateSet","DOMException","DOMHighResTimeStamp","DOMImplementation","DOMMatrix","DOMMatrix2DInit","DOMMatrixInit","DOMMatrixReadOnly","DOMParser","DOMParserSupportedType","DOMPoint","DOMPointInit","DOMPointReadOnly","DOMQuad","DOMQuadInit","DOMRect","DOMRectInit","DOMRectList","DOMRectReadOnly","DOMStringList","DOMStringMap","DOMTokenList","DataTransfer","DataTransferItem","DataTransferItemList","DataView","DataViewConstructor","Date","DateConstructor","DateLikeObject","DateTimeFormat","DateTimeFormatConstructor","DateTimeFormatOptions","DateTimeFormatPart","DateTimeFormatPartTypes","DateTimeFormatPartTypesRegistry","DateTimeLikeObject","DateTimeRangeFormatPart","DateUnit","DecodeErrorCallback","DecodeSuccessCallback","DecompressionStream","DecoratorContext","DecoratorMetadata","DecoratorMetadataObject","DedicatedWorkerGlobalScope","DedicatedWorkerGlobalScopeEventMap","DelayNode","DelayOptions","DeviceMotionEvent","DeviceMotionEventAcceleration","DeviceMotionEventAccelerationInit","DeviceMotionEventInit","DeviceMotionEventRotationRate","DeviceMotionEventRotationRateInit","DeviceOrientationEvent","DeviceOrientationEventInit","DigitalCredential","DirectionSetting","Dirent","DisambiguationOptions","DisplayCaptureSurfaceType","DisplayMediaStreamOptions","DisplayNames","DisplayNamesFallback","DisplayNamesLanguageDisplay","DisplayNamesOptions","DisplayNamesType","Disposable","DisposableStack","DisposableStackConstructor","DistanceModelType","Document","DocumentEventMap","DocumentFragment","DocumentOrShadowRoot","DocumentReadyState","DocumentTimeline","DocumentTimelineOptions","DocumentType","DocumentVisibilityState","DoubleRange","DragEvent","DragEventInit","Duration","DurationConstructor","DurationFormat","DurationFormatDisplayOption","DurationFormatLocaleMatcher","DurationFormatOptions","DurationFormatPart","DurationFormatStyle","DurationFormatUnit","DurationFormatUnitSingular","DurationLike","DurationLikeObject","DurationRelativeToOptions","DurationRoundingOptions","DurationToStringOptions","DurationTotalOptions","DynamicsCompressorNode","DynamicsCompressorOptions","EXT_blend_minmax","EXT_color_buffer_float","EXT_color_buffer_half_float","EXT_float_blend","EXT_frag_depth","EXT_sRGB","EXT_shader_texture_lod","EXT_texture_compression_bptc","EXT_texture_compression_rgtc","EXT_texture_filter_anisotropic","EXT_texture_norm16","EcKeyAlgorithm","EcKeyGenParams","EcKeyImportParams","EcdhKeyDeriveParams","EcdsaParams","EffectTiming","Element","ElementCSSInlineStyle","ElementContentEditable","ElementCreationOptions","ElementDefinitionOptions","ElementEventMap","ElementInternals","ElementTagNameMap","EncodedAudioChunk","EncodedAudioChunkInit","EncodedAudioChunkMetadata","EncodedAudioChunkOutputCallback","EncodedAudioChunkType","EncodedVideoChunk","EncodedVideoChunkInit","EncodedVideoChunkMetadata","EncodedVideoChunkOutputCallback","EncodedVideoChunkType","EndOfStreamError","EndingType","Enumerator","EnumeratorConstructor","EpochTimeStamp","Error","ErrorCallback","ErrorConstructor","ErrorEvent","ErrorEventInit","ErrorOptions","EvalError","EvalErrorConstructor","Event","EventCounts","EventInit","EventListener","EventListenerObject","EventListenerOptions","EventListenerOrEventListenerObject","EventModifierInit","EventSource","EventSourceEventMap","EventSourceInit","EventTarget","Exception","ExceptionOptions","Exclude","ExportValue","Exports","ExtendableCookieChangeEvent","ExtendableCookieChangeEventInit","ExtendableEvent","ExtendableEventInit","ExtendableMessageEvent","ExtendableMessageEventInit","External","Extract","FetchEvent","FetchEventInit","File","FileCallback","FileList","FilePropertyBag","FileReader","FileReaderEventMap","FileReaderSync","FileSink","FileSystem","FileSystemCreateWritableOptions","FileSystemDirectoryEntry","FileSystemDirectoryHandle","FileSystemDirectoryHandleAsyncIterator","FileSystemDirectoryReader","FileSystemEntriesCallback","FileSystemEntry","FileSystemEntryCallback","FileSystemFileEntry","FileSystemFileHandle","FileSystemFlags","FileSystemGetDirectoryOptions","FileSystemGetFileOptions","FileSystemHandle","FileSystemHandleKind","FileSystemReadWriteOptions","FileSystemRemoveOptions","FileSystemSyncAccessHandle","FileSystemWritableFileStream","FileSystemWriteChunkType","FillLightMode","FillMode","FinalizationRegistry","FinalizationRegistryConstructor","FlatArray","Float16Array","Float16ArrayConstructor","Float32Array","Float32ArrayConstructor","Float32List","Float64Array","Float64ArrayConstructor","FocusEvent","FocusEventInit","FocusOptions","FontDisplay","FontFace","FontFaceDescriptors","FontFaceLoadStatus","FontFaceSet","FontFaceSetEventMap","FontFaceSetLoadEvent","FontFaceSetLoadEventInit","FontFaceSetLoadStatus","FontFaceSource","FormData","FormDataEntryValue","FormDataEvent","FormDataEventInit","FormDataIterator","FormattableTemporalObject","FragmentDirective","FrameRequestCallback","FrameType","FullscreenNavigationUI","FullscreenOptions","Function","FunctionConstructor","FunctionStringCallback","GLbitfield","GLboolean","GLclampf","GLenum","GLfloat","GLint","GLint64","GLintptr","GLsizei","GLsizeiptr","GLuint","GLuint64","GPU","GPUAdapter","GPUAdapterInfo","GPUAddressMode","GPUAutoLayoutMode","GPUBindGroup","GPUBindGroupDescriptor","GPUBindGroupEntry","GPUBindGroupLayout","GPUBindGroupLayoutDescriptor","GPUBindGroupLayoutEntry","GPUBindingCommandsMixin","GPUBindingResource","GPUBlendComponent","GPUBlendFactor","GPUBlendOperation","GPUBlendState","GPUBuffer","GPUBufferBinding","GPUBufferBindingLayout","GPUBufferBindingType","GPUBufferDescriptor","GPUBufferDynamicOffset","GPUBufferMapState","GPUBufferUsageFlags","GPUCanvasAlphaMode","GPUCanvasConfiguration","GPUCanvasContext","GPUCanvasToneMapping","GPUCanvasToneMappingMode","GPUColor","GPUColorDict","GPUColorTargetState","GPUColorWriteFlags","GPUCommandBuffer","GPUCommandBufferDescriptor","GPUCommandEncoder","GPUCommandEncoderDescriptor","GPUCompareFunction","GPUCompilationInfo","GPUCompilationMessage","GPUCompilationMessageType","GPUComputePassDescriptor","GPUComputePassEncoder","GPUComputePassTimestampWrites","GPUComputePipeline","GPUComputePipelineDescriptor","GPUCopyExternalImageDestInfo","GPUCopyExternalImageSource","GPUCopyExternalImageSourceInfo","GPUCullMode","GPUDebugCommandsMixin","GPUDepthBias","GPUDepthStencilState","GPUDevice","GPUDeviceDescriptor","GPUDeviceEventMap","GPUDeviceLostInfo","GPUDeviceLostReason","GPUError","GPUErrorFilter","GPUExtent3D","GPUExtent3DDict","GPUExternalTexture","GPUExternalTextureBindingLayout","GPUExternalTextureDescriptor","GPUFeatureName","GPUFilterMode","GPUFlagsConstant","GPUFragmentState","GPUFrontFace","GPUIndex32","GPUIndexFormat","GPUIntegerCoordinate","GPUIntegerCoordinateOut","GPUInternalError","GPULoadOp","GPUMapModeFlags","GPUMipmapFilterMode","GPUMultisampleState","GPUObjectBase","GPUObjectDescriptorBase","GPUOrigin2D","GPUOrigin2DDict","GPUOrigin3D","GPUOrigin3DDict","GPUOutOfMemoryError","GPUPipelineBase","GPUPipelineConstantValue","GPUPipelineDescriptorBase","GPUPipelineError","GPUPipelineErrorInit","GPUPipelineErrorReason","GPUPipelineLayout","GPUPipelineLayoutDescriptor","GPUPowerPreference","GPUPrimitiveState","GPUPrimitiveTopology","GPUProgrammableStage","GPUQuerySet","GPUQuerySetDescriptor","GPUQueryType","GPUQueue","GPUQueueDescriptor","GPURenderBundle","GPURenderBundleDescriptor","GPURenderBundleEncoder","GPURenderBundleEncoderDescriptor","GPURenderCommandsMixin","GPURenderPassColorAttachment","GPURenderPassDepthStencilAttachment","GPURenderPassDescriptor","GPURenderPassEncoder","GPURenderPassLayout","GPURenderPassTimestampWrites","GPURenderPipeline","GPURenderPipelineDescriptor","GPURequestAdapterOptions","GPUSampleMask","GPUSampler","GPUSamplerBindingLayout","GPUSamplerBindingType","GPUSamplerDescriptor","GPUShaderModule","GPUShaderModuleDescriptor","GPUShaderStageFlags","GPUSignedOffset32","GPUSize32","GPUSize32Out","GPUSize64","GPUSize64Out","GPUStencilFaceState","GPUStencilOperation","GPUStencilValue","GPUStorageTextureAccess","GPUStorageTextureBindingLayout","GPUStoreOp","GPUSupportedFeatures","GPUSupportedLimits","GPUTexelCopyBufferInfo","GPUTexelCopyBufferLayout","GPUTexelCopyTextureInfo","GPUTexture","GPUTextureAspect","GPUTextureBindingLayout","GPUTextureDescriptor","GPUTextureDimension","GPUTextureFormat","GPUTextureSampleType","GPUTextureUsageFlags","GPUTextureView","GPUTextureViewDescriptor","GPUTextureViewDimension","GPUUncapturedErrorEvent","GPUUncapturedErrorEventInit","GPUValidationError","GPUVertexAttribute","GPUVertexBufferLayout","GPUVertexFormat","GPUVertexState","GPUVertexStepMode","GainNode","GainOptions","Gamepad","GamepadButton","GamepadEffectParameters","GamepadEvent","GamepadEventInit","GamepadHapticActuator","GamepadHapticEffectType","GamepadHapticsResult","GamepadMappingType","Generator","GeneratorFunction","GeneratorFunctionConstructor","GenericTransformStream","Geolocation","GeolocationCoordinates","GeolocationPosition","GeolocationPositionError","GetAnimationsOptions","GetComposedRangesOptions","GetHTMLOptions","GetNotificationOptions","GetRootNodeOptions","Global","GlobalCompositeOperation","GlobalDescriptor","GlobalEventHandlers","GlobalEventHandlersEventMap","HTMLAllCollection","HTMLAnchorElement","HTMLAreaElement","HTMLAudioElement","HTMLBRElement","HTMLBaseElement","HTMLBodyElement","HTMLBodyElementEventMap","HTMLButtonElement","HTMLCanvasElement","HTMLCollection","HTMLCollectionBase","HTMLCollectionOf","HTMLDListElement","HTMLDataElement","HTMLDataListElement","HTMLDetailsElement","HTMLDialogElement","HTMLDirectoryElement","HTMLDivElement","HTMLDocument","HTMLElement","HTMLElementDeprecatedTagNameMap","HTMLElementEventMap","HTMLElementTagNameMap","HTMLEmbedElement","HTMLFieldSetElement","HTMLFontElement","HTMLFormControlsCollection","HTMLFormElement","HTMLFrameElement","HTMLFrameSetElement","HTMLFrameSetElementEventMap","HTMLHRElement","HTMLHeadElement","HTMLHeadingElement","HTMLHtmlElement","HTMLHyperlinkElementUtils","HTMLIFrameElement","HTMLImageElement","HTMLInputElement","HTMLLIElement","HTMLLabelElement","HTMLLegendElement","HTMLLinkElement","HTMLMapElement","HTMLMarqueeElement","HTMLMediaElement","HTMLMediaElementEventMap","HTMLMenuElement","HTMLMetaElement","HTMLMeterElement","HTMLModElement","HTMLOListElement","HTMLObjectElement","HTMLOptGroupElement","HTMLOptionElement","HTMLOptionsCollection","HTMLOrSVGElement","HTMLOrSVGImageElement","HTMLOrSVGScriptElement","HTMLOutputElement","HTMLParagraphElement","HTMLParamElement","HTMLPictureElement","HTMLPreElement","HTMLProgressElement","HTMLQuoteElement","HTMLScriptElement","HTMLSelectElement","HTMLSlotElement","HTMLSourceElement","HTMLSpanElement","HTMLStyleElement","HTMLTableCaptionElement","HTMLTableCellElement","HTMLTableColElement","HTMLTableDataCellElement","HTMLTableElement","HTMLTableHeaderCellElement","HTMLTableRowElement","HTMLTableSectionElement","HTMLTemplateElement","HTMLTextAreaElement","HTMLTimeElement","HTMLTitleElement","HTMLTrackElement","HTMLUListElement","HTMLUnknownElement","HTMLVideoElement","HTMLVideoElementEventMap","HardwareAcceleration","HashAlgorithmIdentifier","HashChangeEvent","HashChangeEventInit","HdrMetadataType","Headers","HeadersInit","HeadersIterator","Highlight","HighlightRegistry","HighlightType","History","HkdfParams","HmacImportParams","HmacKeyAlgorithm","HmacKeyGenParams","IArguments","IDBCursor","IDBCursorDirection","IDBCursorWithValue","IDBDatabase","IDBDatabaseEventMap","IDBDatabaseInfo","IDBFactory","IDBIndex","IDBIndexParameters","IDBKeyRange","IDBObjectStore","IDBObjectStoreParameters","IDBOpenDBRequest","IDBOpenDBRequestEventMap","IDBRequest","IDBRequestEventMap","IDBRequestReadyState","IDBTransaction","IDBTransactionDurability","IDBTransactionEventMap","IDBTransactionMode","IDBTransactionOptions","IDBValidKey","IDBVersionChangeEvent","IDBVersionChangeEventInit","IIRFilterNode","IIRFilterOptions","ITextWriter","IdleDeadline","IdleRequestCallback","IdleRequestOptions","Image","ImageBitmap","ImageBitmapOptions","ImageBitmapRenderingContext","ImageBitmapRenderingContextSettings","ImageBitmapSource","ImageBufferSource","ImageCapture","ImageData","ImageDataArray","ImageDataPixelFormat","ImageDataSettings","ImageDecodeOptions","ImageDecodeResult","ImageDecoder","ImageDecoderInit","ImageEncodeOptions","ImageOrientation","ImageSmoothingQuality","ImageTrack","ImageTrackList","Immediate","ImportAssertions","ImportAttributes","ImportCallOptions","ImportExportKind","ImportMeta","ImportNodeOptions","ImportValue","Imports","Infinity","InputDeviceInfo","InputEvent","InputEventInit","InsertPosition","Instance","InstanceType","Instant","InstantConstructor","InstantLike","InstantToStringOptions","Int16Array","Int16ArrayConstructor","Int32Array","Int32ArrayConstructor","Int32List","Int8Array","Int8ArrayConstructor","IntersectionObserver","IntersectionObserverCallback","IntersectionObserverEntry","IntersectionObserverInit","Intl","Iterable","IterableIterator","IterationCompositeOperation","Iterator","IteratorConstructor","IteratorObject","IteratorObjectConstructor","IteratorResult","IteratorReturnResult","IteratorYieldResult","JSON","JsonWebKey","KHR_parallel_shader_compile","KeyAlgorithm","KeyFormat","KeySystemTrackConfiguration","KeyType","KeyUsage","KeyboardEvent","KeyboardEventInit","Keyframe","KeyframeAnimationOptions","KeyframeEffect","KeyframeEffectOptions","LDMLPluralRule","LargestContentfulPaint","LatencyMode","LineAlignSetting","LineAndPositionSetting","LinkError","LinkStyle","ListFormat","ListFormatLocaleMatcher","ListFormatOptions","ListFormatStyle","ListFormatType","Locale","LocaleCollationCaseFirst","LocaleHourCycleKey","LocaleOptions","LocalesArgument","Location","Lock","LockGrantedCallback","LockInfo","LockManager","LockManagerSnapshot","LockMode","LockOptions","LoginStatus","Lowercase","MIDIAccess","MIDIAccessEventMap","MIDIConnectionEvent","MIDIConnectionEventInit","MIDIInput","MIDIInputEventMap","MIDIInputMap","MIDIMessageEvent","MIDIMessageEventInit","MIDIOptions","MIDIOutput","MIDIOutputMap","MIDIPort","MIDIPortConnectionState","MIDIPortDeviceState","MIDIPortEventMap","MIDIPortType","Map","MapConstructor","MapIterator","Math","MathMLElement","MathMLElementEventMap","MathMLElementTagNameMap","MediaCapabilities","MediaCapabilitiesDecodingInfo","MediaCapabilitiesEncodingInfo","MediaCapabilitiesInfo","MediaCapabilitiesKeySystemConfiguration","MediaConfiguration","MediaDecodingConfiguration","MediaDecodingType","MediaDeviceInfo","MediaDeviceKind","MediaDevices","MediaDevicesEventMap","MediaElementAudioSourceNode","MediaElementAudioSourceOptions","MediaEncodingConfiguration","MediaEncodingType","MediaEncryptedEvent","MediaEncryptedEventInit","MediaError","MediaImage","MediaKeyMessageEvent","MediaKeyMessageEventInit","MediaKeyMessageType","MediaKeySession","MediaKeySessionClosedReason","MediaKeySessionEventMap","MediaKeySessionType","MediaKeyStatus","MediaKeyStatusMap","MediaKeyStatusMapIterator","MediaKeySystemAccess","MediaKeySystemConfiguration","MediaKeySystemMediaCapability","MediaKeys","MediaKeysPolicy","MediaKeysRequirement","MediaList","MediaMetadata","MediaMetadataInit","MediaPositionState","MediaProvider","MediaQueryList","MediaQueryListEvent","MediaQueryListEventInit","MediaQueryListEventMap","MediaRecorder","MediaRecorderEventMap","MediaRecorderOptions","MediaSession","MediaSessionAction","MediaSessionActionDetails","MediaSessionActionHandler","MediaSessionPlaybackState","MediaSettingsRange","MediaSource","MediaSourceEventMap","MediaSourceHandle","MediaStream","MediaStreamAudioDestinationNode","MediaStreamAudioSourceNode","MediaStreamAudioSourceOptions","MediaStreamConstraints","MediaStreamEventMap","MediaStreamTrack","MediaStreamTrackEvent","MediaStreamTrackEventInit","MediaStreamTrackEventMap","MediaStreamTrackProcessor","MediaStreamTrackProcessorInit","MediaStreamTrackState","MediaTrackCapabilities","MediaTrackConstraintSet","MediaTrackConstraints","MediaTrackSettings","MediaTrackSupportedConstraints","Memory","MemoryDescriptor","MessageChannel","MessageEvent","MessageEventInit","MessageEventSource","MessageEventTarget","MessageEventTargetEventMap","MessagePort","MessagePortEventMap","MethodDecorator","MimeType","MimeTypeArray","Module","ModuleExportDescriptor","ModuleImportDescriptor","ModuleImports","MouseEvent","MouseEventInit","MultiCacheQueryOptions","MutationCallback","MutationObserver","MutationObserverInit","MutationRecord","MutationRecordType","NaN","NamedCurve","NamedNodeMap","NavigateEvent","NavigateEventInit","Navigation","NavigationActivation","NavigationCurrentEntryChangeEvent","NavigationCurrentEntryChangeEventInit","NavigationDestination","NavigationEventMap","NavigationFocusReset","NavigationHistoryBehavior","NavigationHistoryEntry","NavigationHistoryEntryEventMap","NavigationInterceptHandler","NavigationInterceptOptions","NavigationNavigateOptions","NavigationOptions","NavigationPrecommitController","NavigationPrecommitHandler","NavigationPreloadManager","NavigationPreloadState","NavigationReloadOptions","NavigationResult","NavigationScrollBehavior","NavigationTimingType","NavigationTransition","NavigationType","NavigationUpdateCurrentEntryOptions","Navigator","NavigatorAutomationInformation","NavigatorBadge","NavigatorConcurrentHardware","NavigatorContentUtils","NavigatorCookies","NavigatorGPU","NavigatorID","NavigatorLanguage","NavigatorLocks","NavigatorLogin","NavigatorOnLine","NavigatorPlugins","NavigatorStorage","NewableFunction","NoInfer","Node","NodeFilter","NodeIterator","NodeJS","NodeList","NodeListOf","NodeModule","NodeRequire","NonDocumentTypeChildNode","NonElementParentNode","NonNullable","Notification","NotificationDirection","NotificationEvent","NotificationEventInit","NotificationEventMap","NotificationOptions","NotificationPermission","NotificationPermissionCallback","Now","Number","NumberConstructor","NumberFormat","NumberFormatConstructor","NumberFormatOptions","NumberFormatOptionsCurrencyDisplay","NumberFormatOptionsCurrencyDisplayRegistry","NumberFormatOptionsSignDisplay","NumberFormatOptionsSignDisplayRegistry","NumberFormatOptionsStyle","NumberFormatOptionsStyleRegistry","NumberFormatOptionsUseGrouping","NumberFormatOptionsUseGroupingRegistry","NumberFormatPart","NumberFormatPartTypeRegistry","NumberFormatPartTypes","NumberFormatRangePartTypeRegistry","NumberFormatRangePartTypes","NumberRangeFormatPart","OES_draw_buffers_indexed","OES_element_index_uint","OES_fbo_render_mipmap","OES_standard_derivatives","OES_texture_float","OES_texture_float_linear","OES_texture_half_float","OES_texture_half_float_linear","OES_vertex_array_object","OVR_multiview2","Object","ObjectConstructor","OfflineAudioCompletionEvent","OfflineAudioCompletionEventInit","OfflineAudioContext","OfflineAudioContextEventMap","OfflineAudioContextOptions","OffscreenCanvas","OffscreenCanvasEventMap","OffscreenCanvasRenderingContext2D","OffscreenRenderingContext","OffscreenRenderingContextId","Omit","OmitThisParameter","OnBeforeUnloadEventHandler","OnBeforeUnloadEventHandlerNonNull","OnErrorEventHandler","OnErrorEventHandlerNonNull","Option","OptionalEffectTiming","OptionalPostfixToken","OptionalPrefixToken","OpusBitstreamFormat","OpusEncoderConfig","OrientationLockType","OrientationType","OscillatorNode","OscillatorOptions","OscillatorType","OverSampleType","OverconstrainedError","OverflowOptions","PageRevealEvent","PageRevealEventInit","PageSwapEvent","PageSwapEventInit","PageTransitionEvent","PageTransitionEventInit","PaintTimingMixin","PannerNode","PannerOptions","PanningModelType","ParameterDecorator","Parameters","ParentNode","Partial","PartialTemporalLike","Path2D","PayerErrors","PaymentAddress","PaymentComplete","PaymentCurrencyAmount","PaymentDetailsBase","PaymentDetailsInit","PaymentDetailsModifier","PaymentDetailsUpdate","PaymentItem","PaymentMethodChangeEvent","PaymentMethodChangeEventInit","PaymentMethodData","PaymentOptions","PaymentRequest","PaymentRequestEventMap","PaymentRequestUpdateEvent","PaymentRequestUpdateEventInit","PaymentResponse","PaymentResponseEventMap","PaymentShippingOption","PaymentShippingType","PaymentValidationErrors","Pbkdf2Params","Performance","PerformanceEntry","PerformanceEntryList","PerformanceEventMap","PerformanceEventTiming","PerformanceMark","PerformanceMarkOptions","PerformanceMeasure","PerformanceMeasureOptions","PerformanceNavigation","PerformanceNavigationTiming","PerformanceObserver","PerformanceObserverCallback","PerformanceObserverEntryList","PerformanceObserverInit","PerformancePaintTiming","PerformanceResourceTiming","PerformanceServerTiming","PerformanceTiming","PeriodicWave","PeriodicWaveConstraints","PeriodicWaveOptions","PermissionDescriptor","PermissionName","PermissionState","PermissionStatus","PermissionStatusEventMap","Permissions","PhotoCapabilities","PhotoSettings","Pick","PictureInPictureEvent","PictureInPictureEventInit","PictureInPictureWindow","PictureInPictureWindowEventMap","PlainDate","PlainDateConstructor","PlainDateLike","PlainDateTime","PlainDateTimeConstructor","PlainDateTimeLike","PlainDateTimeToStringOptions","PlainDateToStringOptions","PlainDateToZonedDateTimeOptions","PlainMonthDay","PlainMonthDayConstructor","PlainMonthDayLike","PlainMonthDayToPlainDateOptions","PlainTime","PlainTimeConstructor","PlainTimeLike","PlainTimeToStringOptions","PlainYearMonth","PlainYearMonthConstructor","PlainYearMonthLike","PlainYearMonthToPlainDateOptions","PlaneLayout","PlaybackDirection","Plugin","PluginArray","PluralRuleType","PluralRules","PluralRulesConstructor","PluralRulesOptions","PluralizeUnit","PointerEvent","PointerEventInit","PointerLockOptions","PopStateEvent","PopStateEventInit","PopoverTargetAttributes","PositionAlignSetting","PositionCallback","PositionErrorCallback","PositionOptions","PredefinedColorSpace","PremultiplyAlpha","PresentationStyle","ProcessingInstruction","ProgressEvent","ProgressEventInit","Promise","PromiseConstructor","PromiseConstructorLike","PromiseFulfilledResult","PromiseLike","PromiseRejectedResult","PromiseRejectionEvent","PromiseRejectionEventInit","PromiseSettledResult","PromiseWithResolvers","PropertyDecorator","PropertyDefinition","PropertyDescriptor","PropertyDescriptorMap","PropertyIndexedKeyframes","PropertyKey","Proxy","ProxyConstructor","ProxyHandler","PublicKeyCredential","PublicKeyCredentialClientCapabilities","PublicKeyCredentialCreationOptions","PublicKeyCredentialCreationOptionsJSON","PublicKeyCredentialDescriptor","PublicKeyCredentialDescriptorJSON","PublicKeyCredentialEntity","PublicKeyCredentialParameters","PublicKeyCredentialRequestOptions","PublicKeyCredentialRequestOptionsJSON","PublicKeyCredentialRpEntity","PublicKeyCredentialType","PublicKeyCredentialUserEntity","PublicKeyCredentialUserEntityJSON","PushEncryptionKeyName","PushEvent","PushEventInit","PushManager","PushManagerAttribute","PushMessageData","PushMessageDataInit","PushSubscription","PushSubscriptionChangeEvent","PushSubscriptionChangeEventInit","PushSubscriptionJSON","PushSubscriptionOptions","PushSubscriptionOptionsInit","QueuingStrategy","QueuingStrategyInit","QueuingStrategySize","RTCAnswerOptions","RTCBundlePolicy","RTCCertificate","RTCCertificateExpiration","RTCConfiguration","RTCDTMFSender","RTCDTMFSenderEventMap","RTCDTMFToneChangeEvent","RTCDTMFToneChangeEventInit","RTCDataChannel","RTCDataChannelEvent","RTCDataChannelEventInit","RTCDataChannelEventMap","RTCDataChannelInit","RTCDataChannelState","RTCDegradationPreference","RTCDtlsFingerprint","RTCDtlsRole","RTCDtlsTransport","RTCDtlsTransportEventMap","RTCDtlsTransportState","RTCEncodedAudioFrame","RTCEncodedAudioFrameMetadata","RTCEncodedFrameMetadata","RTCEncodedVideoFrame","RTCEncodedVideoFrameMetadata","RTCError","RTCErrorDetailType","RTCErrorEvent","RTCErrorEventInit","RTCErrorInit","RTCIceCandidate","RTCIceCandidateInit","RTCIceCandidatePair","RTCIceCandidatePairStats","RTCIceCandidateType","RTCIceComponent","RTCIceConnectionState","RTCIceGathererState","RTCIceGatheringState","RTCIceProtocol","RTCIceRole","RTCIceServer","RTCIceTcpCandidateType","RTCIceTransport","RTCIceTransportEventMap","RTCIceTransportPolicy","RTCIceTransportState","RTCInboundRtpStreamStats","RTCLocalIceCandidateInit","RTCLocalSessionDescriptionInit","RTCOfferAnswerOptions","RTCOfferOptions","RTCOutboundRtpStreamStats","RTCPeerConnection","RTCPeerConnectionErrorCallback","RTCPeerConnectionEventMap","RTCPeerConnectionIceErrorEvent","RTCPeerConnectionIceErrorEventInit","RTCPeerConnectionIceEvent","RTCPeerConnectionIceEventInit","RTCPeerConnectionState","RTCPriorityType","RTCQualityLimitationReason","RTCReceivedRtpStreamStats","RTCRtcpMuxPolicy","RTCRtcpParameters","RTCRtpCapabilities","RTCRtpCodec","RTCRtpCodecParameters","RTCRtpCodingParameters","RTCRtpContributingSource","RTCRtpEncodingParameters","RTCRtpHeaderExtensionCapability","RTCRtpHeaderExtensionParameters","RTCRtpParameters","RTCRtpReceiveParameters","RTCRtpReceiver","RTCRtpReceiverTransform","RTCRtpScriptTransform","RTCRtpScriptTransformer","RTCRtpSendParameters","RTCRtpSender","RTCRtpSenderTransform","RTCRtpStreamStats","RTCRtpSynchronizationSource","RTCRtpTransceiver","RTCRtpTransceiverDirection","RTCRtpTransceiverInit","RTCSctpTransport","RTCSctpTransportEventMap","RTCSctpTransportState","RTCSdpType","RTCSentRtpStreamStats","RTCSessionDescription","RTCSessionDescriptionCallback","RTCSessionDescriptionInit","RTCSetParameterOptions","RTCSignalingState","RTCStats","RTCStatsIceCandidatePairState","RTCStatsReport","RTCStatsType","RTCTrackEvent","RTCTrackEventInit","RTCTransformEvent","RTCTransportStats","RadioNodeList","Range","RangeError","RangeErrorConstructor","ReadableByteStreamController","ReadableStream","ReadableStreamAsyncIterator","ReadableStreamBYOBReader","ReadableStreamBYOBReaderReadOptions","ReadableStreamBYOBRequest","ReadableStreamController","ReadableStreamDefaultController","ReadableStreamDefaultReader","ReadableStreamGenericReader","ReadableStreamGetReaderOptions","ReadableStreamIteratorOptions","ReadableStreamReadDoneResult","ReadableStreamReadResult","ReadableStreamReadValueResult","ReadableStreamReader","ReadableStreamReaderMode","ReadableStreamType","ReadableWritablePair","Readonly","ReadonlyArray","ReadonlyMap","ReadonlySet","ReadonlySetLike","ReadyState","Record","RecordingState","RedEyeReduction","ReferenceError","ReferenceErrorConstructor","ReferrerPolicy","Reflect","RegExp","RegExpConstructor","RegExpExecArray","RegExpIndicesArray","RegExpMatchArray","RegExpStringIterator","RegistrationOptions","RegistrationResponseJSON","RelativeTimeFormat","RelativeTimeFormatLocaleMatcher","RelativeTimeFormatNumeric","RelativeTimeFormatOptions","RelativeTimeFormatPart","RelativeTimeFormatStyle","RelativeTimeFormatUnit","RelativeTimeFormatUnitSingular","RemotePlayback","RemotePlaybackAvailabilityCallback","RemotePlaybackEventMap","RemotePlaybackState","RenderingContext","Report","ReportBody","ReportList","ReportingObserver","ReportingObserverCallback","ReportingObserverOptions","Request","RequestCache","RequestCredentials","RequestDestination","RequestInfo","RequestInit","RequestMode","RequestPriority","RequestRedirect","Required","ResidentKeyRequirement","ResizeObserver","ResizeObserverBoxOptions","ResizeObserverCallback","ResizeObserverEntry","ResizeObserverOptions","ResizeObserverSize","ResizeQuality","ResolvedCollatorOptions","ResolvedDateTimeFormatOptions","ResolvedDisplayNamesOptions","ResolvedDurationFormatOptions","ResolvedListFormatOptions","ResolvedNumberFormatOptions","ResolvedNumberFormatOptionsUseGrouping","ResolvedPluralRulesOptions","ResolvedRelativeTimeFormatOptions","ResolvedSegmenterOptions","Response","ResponseInit","ResponseType","ReturnType","RoundingOptions","RoundingOptionsWithLargestUnit","RsaHashedImportParams","RsaHashedKeyAlgorithm","RsaHashedKeyGenParams","RsaKeyAlgorithm","RsaKeyGenParams","RsaOaepParams","RsaOtherPrimesInfo","RsaPssParams","RuntimeError","SVGAElement","SVGAngle","SVGAnimateElement","SVGAnimateMotionElement","SVGAnimateTransformElement","SVGAnimatedAngle","SVGAnimatedBoolean","SVGAnimatedEnumeration","SVGAnimatedInteger","SVGAnimatedLength","SVGAnimatedLengthList","SVGAnimatedNumber","SVGAnimatedNumberList","SVGAnimatedPoints","SVGAnimatedPreserveAspectRatio","SVGAnimatedRect","SVGAnimatedString","SVGAnimatedTransformList","SVGAnimationElement","SVGBoundingBoxOptions","SVGCircleElement","SVGClipPathElement","SVGComponentTransferFunctionElement","SVGDefsElement","SVGDescElement","SVGElement","SVGElementEventMap","SVGElementTagNameMap","SVGEllipseElement","SVGFEBlendElement","SVGFEColorMatrixElement","SVGFEComponentTransferElement","SVGFECompositeElement","SVGFEConvolveMatrixElement","SVGFEDiffuseLightingElement","SVGFEDisplacementMapElement","SVGFEDistantLightElement","SVGFEDropShadowElement","SVGFEFloodElement","SVGFEFuncAElement","SVGFEFuncBElement","SVGFEFuncGElement","SVGFEFuncRElement","SVGFEGaussianBlurElement","SVGFEImageElement","SVGFEMergeElement","SVGFEMergeNodeElement","SVGFEMorphologyElement","SVGFEOffsetElement","SVGFEPointLightElement","SVGFESpecularLightingElement","SVGFESpotLightElement","SVGFETileElement","SVGFETurbulenceElement","SVGFilterElement","SVGFilterPrimitiveStandardAttributes","SVGFitToViewBox","SVGForeignObjectElement","SVGGElement","SVGGeometryElement","SVGGradientElement","SVGGraphicsElement","SVGImageElement","SVGLength","SVGLengthList","SVGLineElement","SVGLinearGradientElement","SVGMPathElement","SVGMarkerElement","SVGMaskElement","SVGMatrix","SVGMetadataElement","SVGNumber","SVGNumberList","SVGPathElement","SVGPatternElement","SVGPoint","SVGPointList","SVGPolygonElement","SVGPolylineElement","SVGPreserveAspectRatio","SVGRadialGradientElement","SVGRect","SVGRectElement","SVGSVGElement","SVGSVGElementEventMap","SVGScriptElement","SVGSetElement","SVGStopElement","SVGStringList","SVGStyleElement","SVGSwitchElement","SVGSymbolElement","SVGTSpanElement","SVGTests","SVGTextContentElement","SVGTextElement","SVGTextPathElement","SVGTextPositioningElement","SVGTitleElement","SVGTransform","SVGTransformList","SVGURIReference","SVGUnitTypes","SVGUseElement","SVGViewElement","Sanitizer","SanitizerAttribute","SanitizerAttributeNamespace","SanitizerConfig","SanitizerElement","SanitizerElementNamespace","SanitizerElementNamespaceWithAttributes","SanitizerElementWithAttributes","SanitizerPresets","Scheduler","SchedulerPostTaskCallback","SchedulerPostTaskOptions","Screen","ScreenOrientation","ScreenOrientationEventMap","ScriptProcessorNode","ScriptProcessorNodeEventMap","ScrollAxis","ScrollBehavior","ScrollIntoViewOptions","ScrollLogicalPosition","ScrollOptions","ScrollRestoration","ScrollSetting","ScrollTimeline","ScrollTimelineOptions","ScrollToOptions","SecurityPolicyViolationEvent","SecurityPolicyViolationEventDisposition","SecurityPolicyViolationEventInit","SegmentData","SegmentIterator","Segmenter","SegmenterOptions","Segments","Selection","SelectionDirection","SelectionMode","Server","ServerWebSocket","ServiceWorker","ServiceWorkerContainer","ServiceWorkerContainerEventMap","ServiceWorkerEventMap","ServiceWorkerGlobalScope","ServiceWorkerGlobalScopeEventMap","ServiceWorkerRegistration","ServiceWorkerRegistrationEventMap","ServiceWorkerState","ServiceWorkerUpdateViaCache","Set","SetConstructor","SetIterator","ShadowRoot","ShadowRootEventMap","ShadowRootInit","ShadowRootMode","ShareData","SharedArrayBuffer","SharedArrayBufferConstructor","SharedWorker","SharedWorkerGlobalScope","SharedWorkerGlobalScopeEventMap","ShellPromise","ShowPopoverOptions","SlotAssignmentMode","Slottable","Socket","SocketHandler","SourceBuffer","SourceBufferEventMap","SourceBufferList","SourceBufferListEventMap","SpeechRecognitionAlternative","SpeechRecognitionErrorCode","SpeechRecognitionErrorEvent","SpeechRecognitionErrorEventInit","SpeechRecognitionEvent","SpeechRecognitionEventInit","SpeechRecognitionResult","SpeechRecognitionResultList","SpeechSynthesis","SpeechSynthesisErrorCode","SpeechSynthesisErrorEvent","SpeechSynthesisErrorEventInit","SpeechSynthesisEvent","SpeechSynthesisEventInit","SpeechSynthesisEventMap","SpeechSynthesisUtterance","SpeechSynthesisUtteranceEventMap","SpeechSynthesisVoice","StartViewTransitionOptions","StaticRange","StaticRangeInit","Stats","StereoPannerNode","StereoPannerOptions","Storage","StorageEstimate","StorageEvent","StorageEventInit","StorageManager","StreamPipeOptions","String","StringConstructor","StringIterator","StringNumericLiteral","StructuredSerializeOptions","StylePropertyMap","StylePropertyMapReadOnly","StylePropertyMapReadOnlyIterator","StyleSheet","StyleSheetList","SubmitEvent","SubmitEventInit","Subprocess","SubtleCrypto","SuppressedError","SuppressedErrorConstructor","SvcOutputMetadata","Symbol","SymbolConstructor","SyntaxError","SyntaxErrorConstructor","TCPSocket","Table","TableDescriptor","TableKind","Tag","TagType","TaskController","TaskControllerInit","TaskPriority","TaskPriorityChangeEvent","TaskPriorityChangeEventInit","TaskSignal","TaskSignalAnyInit","TaskSignalEventMap","TemplateStringsArray","Temporal","TexImageSource","Text","TextDecodeOptions","TextDecoder","TextDecoderCommon","TextDecoderOptions","TextDecoderStream","TextEncoder","TextEncoderCommon","TextEncoderEncodeIntoResult","TextEncoderStream","TextEvent","TextInfo","TextMetrics","TextStreamBase","TextStreamReader","TextStreamWriter","TextTrack","TextTrackCue","TextTrackCueEventMap","TextTrackCueList","TextTrackEventMap","TextTrackKind","TextTrackList","TextTrackListEventMap","TextTrackMode","ThisParameterType","ThisType","TimeLikeObject","TimeRanges","TimeUnit","TimeZoneLike","TimelineRangeOffset","Timeout","Timer","TimerHandler","ToStringRoundingOptions","ToStringRoundingOptionsWithFractionalSeconds","ToggleEvent","ToggleEventInit","TogglePopoverOptions","Touch","TouchEvent","TouchEventInit","TouchInit","TouchList","TouchType","TrackEvent","TrackEventInit","TransferFunction","Transferable","TransformStream","TransformStreamDefaultController","Transformer","TransformerFlushCallback","TransformerStartCallback","TransformerTransformCallback","TransitionEvent","TransitionEventInit","TransitionOptions","TreeWalker","TypeError","TypeErrorConstructor","TypedArray","TypedPropertyDescriptor","UIEvent","UIEventInit","ULongRange","URIError","URIErrorConstructor","URL","URLPattern","URLPatternComponentResult","URLPatternInit","URLPatternInput","URLPatternOptions","URLPatternResult","URLSearchParams","URLSearchParamsIterator","Uint16Array","Uint16ArrayConstructor","Uint32Array","Uint32ArrayConstructor","Uint32List","Uint8Array","Uint8ArrayConstructor","Uint8ClampedArray","Uint8ClampedArrayConstructor","Uncapitalize","UnderlyingByteSource","UnderlyingDefaultSource","UnderlyingSink","UnderlyingSinkAbortCallback","UnderlyingSinkCloseCallback","UnderlyingSinkStartCallback","UnderlyingSinkWriteCallback","UnderlyingSource","UnderlyingSourceCancelCallback","UnderlyingSourcePullCallback","UnderlyingSourceStartCallback","UnicodeBCP47LocaleIdentifier","UnknownCredentialOptions","Uppercase","UserActivation","UserVerificationRequirement","VBArray","VBArrayConstructor","VTTCue","VTTRegion","ValidityState","ValidityStateFlags","ValueType","ValueTypeMap","VibratePattern","VideoColorPrimaries","VideoColorSpace","VideoColorSpaceInit","VideoConfiguration","VideoDecoder","VideoDecoderConfig","VideoDecoderEventMap","VideoDecoderInit","VideoDecoderSupport","VideoEncoder","VideoEncoderBitrateMode","VideoEncoderConfig","VideoEncoderEncodeOptions","VideoEncoderEncodeOptionsForAvc","VideoEncoderEventMap","VideoEncoderInit","VideoEncoderSupport","VideoFacingModeEnum","VideoFrame","VideoFrameBufferInit","VideoFrameCallbackMetadata","VideoFrameCopyToOptions","VideoFrameInit","VideoFrameOutputCallback","VideoFrameRequestCallback","VideoMatrixCoefficients","VideoPixelFormat","VideoPlaybackQuality","VideoTransferCharacteristics","ViewTimeline","ViewTimelineOptions","ViewTransition","ViewTransitionTypeSet","ViewTransitionUpdateCallback","VisualViewport","VisualViewportEventMap","VoidFunction","WEBGL_color_buffer_float","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb","WEBGL_debug_renderer_info","WEBGL_debug_shaders","WEBGL_depth_texture","WEBGL_draw_buffers","WEBGL_lose_context","WEBGL_multi_draw","WGSLLanguageFeatures","WSH","WScript","WakeLock","WakeLockSentinel","WakeLockSentinelEventMap","WakeLockType","WaveShaperNode","WaveShaperOptions","WeakKey","WeakKeyTypes","WeakMap","WeakMapConstructor","WeakRef","WeakRefConstructor","WeakSet","WeakSetConstructor","WebAssembly","WebAssemblyCompileOptions","WebAssemblyInstantiatedSource","WebCodecsErrorCallback","WebGL2RenderingContext","WebGL2RenderingContextBase","WebGL2RenderingContextOverloads","WebGLActiveInfo","WebGLBuffer","WebGLContextAttributes","WebGLContextEvent","WebGLContextEventInit","WebGLFramebuffer","WebGLPowerPreference","WebGLProgram","WebGLQuery","WebGLRenderbuffer","WebGLRenderingContext","WebGLRenderingContextBase","WebGLRenderingContextOverloads","WebGLSampler","WebGLShader","WebGLShaderPrecisionFormat","WebGLSync","WebGLTexture","WebGLTransformFeedback","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES","WebKitCSSMatrix","WebSocket","WebSocketEventMap","WebSocketHandler","WebTransport","WebTransportBidirectionalStream","WebTransportCloseInfo","WebTransportCongestionControl","WebTransportDatagramDuplexStream","WebTransportError","WebTransportErrorOptions","WebTransportErrorSource","WebTransportHash","WebTransportOptions","WebTransportSendOptions","WebTransportSendStreamOptions","WeekInfo","WheelEvent","WheelEventInit","Window","WindowClient","WindowEventHandlers","WindowEventHandlersEventMap","WindowEventMap","WindowLocalStorage","WindowOrWorkerGlobalScope","WindowPostMessageOptions","WindowProxy","WindowSessionStorage","WithImplicitCoercion","Worker","WorkerEventMap","WorkerGlobalScope","WorkerGlobalScopeEventMap","WorkerLocation","WorkerNavigator","WorkerOptions","WorkerType","Worklet","WorkletOptions","WritableStream","WritableStreamDefaultController","WritableStreamDefaultWriter","WriteCommandType","WriteParams","XMLDocument","XMLHttpRequest","XMLHttpRequestBodyInit","XMLHttpRequestEventMap","XMLHttpRequestEventTarget","XMLHttpRequestEventTargetEventMap","XMLHttpRequestResponseType","XMLHttpRequestUpload","XMLSerializer","XPathEvaluator","XPathEvaluatorBase","XPathExpression","XPathNSResolver","XPathResult","XSLTProcessor","YearMonthLikeObject","ZonedDateTime","ZonedDateTimeConstructor","ZonedDateTimeFromOptions","ZonedDateTimeLike","ZonedDateTimeLikeObject","ZonedDateTimeToStringOptions","global","globalThis","process","structuredClone"])});function go(e,t={strings:!0}){let r="",n=0;while(n<e.length){let i=e.slice(n,n+2);if(i==="//"){let a=e.indexOf(`
66
66
  `,n),o=a===-1?e.length:a;r+=" ".repeat(o-n),n=o;continue}if(i==="/*"){let a=e.indexOf("*/",n+2),o=a===-1?e.length:a+2;for(let c=n;c<o;c++)r+=e[c]===`
67
67
  `?`
68
68
  `:" ";n=o;continue}let s=e[n];if(t.strings&&(s==='"'||s==="'"||s==="`")){let a=s;r+=" ",n++;while(n<e.length){if(e[n]==="\\"){r+=" ",n+=2;continue}if(e[n]===a){r+=" ",n++;break}r+=e[n]===`
69
69
  `?`
70
- `:" ",n++}continue}r+=s,n++}return r}function Lu(e){let t=new Set,r=[/\b(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:type|interface|class|enum|namespace|module)\s+([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?(?:declare\s+)?(?:async\s+)?function\s*\*?\s*([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?declare\s+(?:const|let|var)\s+([A-Za-z_$][\w$]*)/g];for(let n of r)for(let i of e.matchAll(n))t.add(i[1]);return t}function Wu(e){let t=new Set;for(let r of e.matchAll(/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"`]/g)){let n=r[1],i=/\*\s*as\s+([A-Za-z_$][\w$]*)/.exec(n);if(i)t.add(i[1]);let s=n.split("{")[0].replace(/\*\s*as\s+[A-Za-z_$][\w$]*/,"");for(let o of s.split(",")){let c=o.trim();if(/^[A-Za-z_$][\w$]*$/.test(c))t.add(c)}let a=/\{([\s\S]*?)\}/.exec(n);if(a)for(let o of a[1].split(",")){let c=o.trim().replace(/^type\s+/,"");if(!c)continue;let f=/\bas\s+([A-Za-z_$][\w$]*)$/.exec(c);t.add(f?f[1]:c.split(/\s+/)[0])}}for(let r of e.matchAll(/\bimport\s*\(\s*['"`][^'"`]*['"`]\s*\)\s*\.\s*([A-Za-z_$][\w$]*)/g))t.add(r[1]);return t}function Gu(e){let t=new Set,r=(i)=>{for(let s of i.split(",")){let a=s.trim().split(/\s+|=/)[0]?.trim();if(a&&/^[A-Za-z_$][\w$]*$/.test(a))t.add(a)}},n=/\b(?:type|interface|class|function)\s+[A-Za-z_$][\w$]*\s*<([^<>]*(?:<[^<>]*>[^<>]*)*)>/g;for(let i of e.matchAll(n))r(i[1]);for(let i of e.matchAll(/(?:\b[A-Za-z_$][\w$]*)?\s*<([^<>()]*)>\s*\(/g))r(i[1]);for(let i of e.matchAll(/\binfer\s+([A-Za-z_$][\w$]*)/g))t.add(i[1]);for(let i of e.matchAll(/\[\s*([A-Za-z_$][\w$]*)\s+in\b/g))t.add(i[1]);return t}function Bu(e){let t=new Map,r=(i)=>{let s=1;for(let a=0;a<i&&a<e.length;a++)if(e.charCodeAt(a)===10)s++;return s},n=(i,s,a)=>{for(let o of i.matchAll(/\b([A-Z][\w$]*)\b/g)){let c=o[1];if(t.has(c))continue;let f=i.slice(o.index+c.length);if(/^\s*\??:/.test(f))continue;t.set(c,{line:r(s),context:a.trim().slice(0,120)})}};for(let i of e.matchAll(/\btype\s+[A-Za-z_$][\w$]*\s*(?:<[^=]*?>)?\s*=([^;]*)/g))n(i[1],i.index+i[0].indexOf("="),i[0]);for(let i of e.matchAll(/\b(?:extends|implements)\s+([^{;]*)/g))n(i[1],i.index,i[0]);for(let i of e.matchAll(/:\s*([^;,){}\n=]+)/g))n(i[1],i.index,i[0]);for(let i of e.matchAll(/<([^<>()]*)>/g))n(i[1],i.index,i[0]);return t}function mo(e){let t=ho(e),r=ho(e,{strings:!1}),n=new Set([...Lu(t),...Wu(r),...Gu(t),...fo,...Nu]),i=[];for(let[s,a]of Bu(t)){if(n.has(s))continue;if(new RegExp(`[\\w$]\\s*\\.\\s*${s}\\b`).test(t))continue;i.push({name:s,line:a.line,context:a.context})}return i.sort((s,a)=>s.line-a.line||s.name.localeCompare(a.name))}var Nu;var po=oe(()=>{uo();Nu=new Set(["This","True","False","Null","Undefined","Void","Never","Any","Unknown","Object","Infinity","NaN"])});function tr(e,t){let r=1,n=1;for(let i=0;i<t;i++)if(e.charCodeAt(i)===10)r++,n=1;else n++;return{line:r,column:n}}function go(e){let t=[],r=[],n=[],i={")":"(","]":"[","}":"{"},s=0,a=0,o=-1;for(let f=0;f<e.length;f++){let u=e.charCodeAt(f),l=e.charCodeAt(f+1);if(o!==-1){if(u===42&&l===47)r.push({start:o,end:f+2}),o=-1,f++;continue}if(s){if(u===92)f++;else if(u===s)r.push({start:a,end:f+1}),s=0;continue}if(u===47&&l===42){o=f,f++;continue}if(u===47&&l===47){let d=f;while(f<e.length&&e.charCodeAt(f)!==10)f++;r.push({start:d,end:f});continue}if(u===39||u===34||u===96){s=u,a=f;continue}let g=e[f];if(g==="("||g==="["||g==="{")n.push({char:g,offset:f});else if(i[g]){let d=n.pop();if(!d||d.char!==i[g])t.push({...tr(e,f),message:`Unexpected closing delimiter ${g}`,code:"DTSX1004"})}}if(s)t.push({...tr(e,a),message:"Unterminated string literal",code:"DTSX1002"});if(o!==-1)t.push({...tr(e,o),message:"Unterminated block comment",code:"DTSX1003"});for(let f of n)t.push({...tr(e,f.offset),message:`Unclosed delimiter ${f.char}`,code:"DTSX1001"});let c=[[/\b(?:interface|class|enum)\s*(?=[{=])/g,"Declaration name expected"],[/\bfunction\s*(?=\()/g,"Function name expected"],[/\(\s*:/g,"Parameter name expected"]];for(let[f,u]of c)for(let l of e.matchAll(f)){if(r.some((g)=>l.index>=g.start&&l.index<g.end))continue;t.push({...tr(e,l.index),message:u,code:"DTSX1005"})}for(let f of e.matchAll(/\btype\s*(?=[{=])/g)){if(r.some((l)=>f.index>=l.start&&f.index<l.end))continue;let u=e.slice(0,f.index).trimEnd();if(u.endsWith("import")||u.endsWith("export"))continue;t.push({...tr(e,f.index),message:"Declaration name expected",code:"DTSX1005"})}return t.sort((f,u)=>f.line-u.line||f.column-u.column)}var yo=()=>{};import{readFile as Vu,stat as Jg,writeFile as _u}from"fs/promises";async function Co(e,t){if(gi)return globalThis.Bun.write(e,t);let r=typeof t==="string"?t:t instanceof ArrayBuffer?Buffer.from(t):t;return await _u(e,r),typeof t==="string"?Buffer.byteLength(t):t.byteLength}async function wt(e){if(gi)return globalThis.Bun.file(e).text();return Vu(e,"utf-8")}var gi,Ug;var yi=oe(()=>{gi=typeof globalThis.Bun<"u",Ug=!gi&&typeof process<"u"&&!!process.versions?.node});import{statSync as Hu}from"fs";import{readFile as ju,readdir as ey}from"fs/promises";import{createRequire as Ku}from"module";import{dirname as Ju,isAbsolute as wo,join as Uu,resolve as $o}from"path";import Yu from"process";function Vn(){return`${String.fromCharCode(47,47,35)} sourceMappingURL=`}async function pr(e,t,r="lf"){let n=t.replace(/\r\n/g,`
70
+ `:" ",n++}continue}r+=s,n++}return r}function Bu(e){let t=new Set,r=[/\b(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:type|interface|class|enum|namespace|module)\s+([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?(?:declare\s+)?(?:async\s+)?function\s*\*?\s*([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?declare\s+(?:const|let|var)\s+([A-Za-z_$][\w$]*)/g];for(let n of r)for(let i of e.matchAll(n))t.add(i[1]);return t}function Vu(e){let t=new Set;for(let r of e.matchAll(/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"`]/g)){let n=r[1],i=/\*\s*as\s+([A-Za-z_$][\w$]*)/.exec(n);if(i)t.add(i[1]);let s=n.split("{")[0].replace(/\*\s*as\s+[A-Za-z_$][\w$]*/,"");for(let o of s.split(",")){let c=o.trim();if(/^[A-Za-z_$][\w$]*$/.test(c))t.add(c)}let a=/\{([\s\S]*?)\}/.exec(n);if(a)for(let o of a[1].split(",")){let c=o.trim().replace(/^type\s+/,"");if(!c)continue;let f=/\bas\s+([A-Za-z_$][\w$]*)$/.exec(c);t.add(f?f[1]:c.split(/\s+/)[0])}}for(let r of e.matchAll(/\bimport\s*\(\s*['"`][^'"`]*['"`]\s*\)\s*\.\s*([A-Za-z_$][\w$]*)/g))t.add(r[1]);return t}function _u(e){let t=new Set,r=(i)=>{for(let s of i.split(",")){let a=s.trim().split(/\s+|=/)[0]?.trim();if(a&&/^[A-Za-z_$][\w$]*$/.test(a))t.add(a)}},n=/\b(?:type|interface|class|function)\s+[A-Za-z_$][\w$]*\s*<([^<>]*(?:<[^<>]*>[^<>]*)*)>/g;for(let i of e.matchAll(n))r(i[1]);for(let i of e.matchAll(/(?:\b[A-Za-z_$][\w$]*)?\s*<([^<>()]*)>\s*\(/g))r(i[1]);for(let i of e.matchAll(/\binfer\s+([A-Za-z_$][\w$]*)/g))t.add(i[1]);for(let i of e.matchAll(/\[\s*([A-Za-z_$][\w$]*)\s+in\b/g))t.add(i[1]);return t}function Hu(e){let t=new Map,r=(i)=>{let s=1;for(let a=0;a<i&&a<e.length;a++)if(e.charCodeAt(a)===10)s++;return s},n=(i,s,a)=>{for(let o of i.matchAll(/\b([A-Z][\w$]*)\b/g)){let c=o[1];if(t.has(c))continue;let f=i.slice(o.index+c.length);if(/^\s*\??:/.test(f))continue;t.set(c,{line:r(s),context:a.trim().slice(0,120)})}};for(let i of e.matchAll(/\btype\s+[A-Za-z_$][\w$]*\s*(?:<[^=]*?>)?\s*=([^;]*)/g))n(i[1],i.index+i[0].indexOf("="),i[0]);for(let i of e.matchAll(/\b(?:extends|implements)\s+([^{;]*)/g))n(i[1],i.index,i[0]);for(let i of e.matchAll(/:\s*([^;,){}\n=]+)/g))n(i[1],i.index,i[0]);for(let i of e.matchAll(/<([^<>()]*)>/g))n(i[1],i.index,i[0]);return t}function yo(e){let t=go(e),r=go(e,{strings:!1}),n=new Set([...Bu(t),...Vu(r),..._u(t),...mo,...Gu]),i=[];for(let[s,a]of Hu(t)){if(n.has(s))continue;if(new RegExp(`[\\w$]\\s*\\.\\s*${s}\\b`).test(t))continue;i.push({name:s,line:a.line,context:a.context})}return i.sort((s,a)=>s.line-a.line||s.name.localeCompare(a.name))}var Gu;var Co=le(()=>{po();Gu=new Set(["This","True","False","Null","Undefined","Void","Never","Any","Unknown","Object","Infinity","NaN"])});function tr(e,t){let r=1,n=1;for(let i=0;i<t;i++)if(e.charCodeAt(i)===10)r++,n=1;else n++;return{line:r,column:n}}function wo(e){let t=[],r=[],n=[],i={")":"(","]":"[","}":"{"},s=0,a=0,o=-1;for(let f=0;f<e.length;f++){let u=e.charCodeAt(f),l=e.charCodeAt(f+1);if(o!==-1){if(u===42&&l===47)r.push({start:o,end:f+2}),o=-1,f++;continue}if(s){if(u===92)f++;else if(u===s)r.push({start:a,end:f+1}),s=0;continue}if(u===47&&l===42){o=f,f++;continue}if(u===47&&l===47){let d=f;while(f<e.length&&e.charCodeAt(f)!==10)f++;r.push({start:d,end:f});continue}if(u===39||u===34||u===96){s=u,a=f;continue}let g=e[f];if(g==="("||g==="["||g==="{")n.push({char:g,offset:f});else if(i[g]){let d=n.pop();if(!d||d.char!==i[g])t.push({...tr(e,f),message:`Unexpected closing delimiter ${g}`,code:"DTSX1004"})}}if(s)t.push({...tr(e,a),message:"Unterminated string literal",code:"DTSX1002"});if(o!==-1)t.push({...tr(e,o),message:"Unterminated block comment",code:"DTSX1003"});for(let f of n)t.push({...tr(e,f.offset),message:`Unclosed delimiter ${f.char}`,code:"DTSX1001"});let c=[[/\b(?:interface|class|enum)\s*(?=[{=])/g,"Declaration name expected"],[/\bfunction\s*(?=\()/g,"Function name expected"],[/\(\s*:/g,"Parameter name expected"]];for(let[f,u]of c)for(let l of e.matchAll(f)){if(r.some((g)=>l.index>=g.start&&l.index<g.end))continue;t.push({...tr(e,l.index),message:u,code:"DTSX1005"})}for(let f of e.matchAll(/\btype\s*(?=[{=])/g)){if(r.some((l)=>f.index>=l.start&&f.index<l.end))continue;let u=e.slice(0,f.index).trimEnd();if(u.endsWith("import")||u.endsWith("export"))continue;t.push({...tr(e,f.index),message:"Declaration name expected",code:"DTSX1005"})}return t.sort((f,u)=>f.line-u.line||f.column-u.column)}var $o=()=>{};import{readFile as ju,stat as Zg,writeFile as Ku}from"fs/promises";async function Eo(e,t){if(Ci)return globalThis.Bun.write(e,t);let r=typeof t==="string"?t:t instanceof ArrayBuffer?Buffer.from(t):t;return await Ku(e,r),typeof t==="string"?Buffer.byteLength(t):t.byteLength}async function wt(e){if(Ci)return globalThis.Bun.file(e).text();return ju(e,"utf-8")}var Ci,qg;var wi=le(()=>{Ci=typeof globalThis.Bun<"u",qg=!Ci&&typeof process<"u"&&!!process.versions?.node});import{statSync as Ju}from"fs";import{readFile as Uu,readdir as iy}from"fs/promises";import{createRequire as Yu}from"module";import{dirname as Zu,isAbsolute as vo,join as qu,resolve as So}from"path";import Xu from"process";function Hn(){return`${String.fromCharCode(47,47,35)} sourceMappingURL=`}async function gr(e,t,r="lf"){let n=t.replace(/\r\n/g,`
71
71
  `);if(!n.endsWith(`
72
72
  `))n+=`
73
73
  `;if(r==="crlf")n=n.replace(/\n/g,`\r
74
- `);await Co(e,n)}function Zu(e){let t="",r=0,n=0;while(r<e.length){let i=e.charCodeAt(r);if(n){if(t+=e[r],i===92&&r+1<e.length){t+=e[r+1],r+=2;continue}if(i===n)n=0;r++;continue}if(i===34){n=i,t+=e[r++];continue}if(i===47&&e.charCodeAt(r+1)===47){r+=2;while(r<e.length&&e.charCodeAt(r)!==10)r++;continue}if(i===47&&e.charCodeAt(r+1)===42){r+=2;while(r+1<e.length&&!(e.charCodeAt(r)===42&&e.charCodeAt(r+1)===47)){if(e.charCodeAt(r)===10)t+=`
75
- `;r++}r=Math.min(r+2,e.length);continue}if(i===44){let s=r+1;while(s<e.length){while(s<e.length&&e.charCodeAt(s)<=32)s++;if(e.charCodeAt(s)===47&&e.charCodeAt(s+1)===47){s+=2;while(s<e.length&&e.charCodeAt(s)!==10)s++;continue}if(e.charCodeAt(s)===47&&e.charCodeAt(s+1)===42){s+=2;while(s+1<e.length&&!(e.charCodeAt(s)===42&&e.charCodeAt(s+1)===47))s++;s=Math.min(s+2,e.length);continue}break}let a=e.charCodeAt(s);if(a===93||a===125){r++;continue}}t+=e[r++]}return t}function Bn(e){let t=[e];if(!e.endsWith(".json"))t.push(`${e}.json`);t.push(Uu(e,"tsconfig.json"));for(let r of t)try{if(Hu(r).isFile())return r}catch{}return null}function qu(e,t){if(wo(e)||e.startsWith("."))return Bn($o(Ju(t),e));let r=Ku(t);for(let n of[e,`${e}/tsconfig.json`])try{let i=Bn(r.resolve(n));if(i)return i}catch{}return null}async function Eo(e,t){let r=Bn(e);if(!r||t.has(r))return;t.add(r);let n=await ju(r,"utf8"),i=JSON.parse(Zu(n)),s=typeof i.extends==="string"?[i.extends]:i.extends??[],a;for(let o of s){let c=qu(o,r);if(!c)continue;let f=await Eo(c,t);if(f!==void 0)a=f}return i.compilerOptions?.isolatedDeclarations??a}async function vo(e){try{let t=e?.cwd||Yu.cwd(),r=e?.tsconfigPath||"tsconfig.json",n=wo(r)?r:$o(t,r);return await Eo(n,new Set)??!1}catch{return!1}}function So(e,t){let r={isValid:!0,errors:[]};for(let n of go(e))r.errors.push({line:n.line,column:n.column,message:n.message,code:n.code});for(let n of mo(e))r.errors.push({line:n.line,column:1,message:`'${n.name}' is used but never declared or imported here, so it resolves to an error type for anything consuming this file. It is most likely an ambient global in the source project \u2014 import it explicitly. Referenced by: ${n.context}`,code:"dangling-type-reference"});return r.isValid=r.errors.length===0,r}function bo(e,t,r){if(e===t)return"";let n=e.split(`
74
+ `);await Eo(e,n)}function zu(e){let t="",r=0,n=0;while(r<e.length){let i=e.charCodeAt(r);if(n){if(t+=e[r],i===92&&r+1<e.length){t+=e[r+1],r+=2;continue}if(i===n)n=0;r++;continue}if(i===34){n=i,t+=e[r++];continue}if(i===47&&e.charCodeAt(r+1)===47){r+=2;while(r<e.length&&e.charCodeAt(r)!==10)r++;continue}if(i===47&&e.charCodeAt(r+1)===42){r+=2;while(r+1<e.length&&!(e.charCodeAt(r)===42&&e.charCodeAt(r+1)===47)){if(e.charCodeAt(r)===10)t+=`
75
+ `;r++}r=Math.min(r+2,e.length);continue}if(i===44){let s=r+1;while(s<e.length){while(s<e.length&&e.charCodeAt(s)<=32)s++;if(e.charCodeAt(s)===47&&e.charCodeAt(s+1)===47){s+=2;while(s<e.length&&e.charCodeAt(s)!==10)s++;continue}if(e.charCodeAt(s)===47&&e.charCodeAt(s+1)===42){s+=2;while(s+1<e.length&&!(e.charCodeAt(s)===42&&e.charCodeAt(s+1)===47))s++;s=Math.min(s+2,e.length);continue}break}let a=e.charCodeAt(s);if(a===93||a===125){r++;continue}}t+=e[r++]}return t}function _n(e){let t=[e];if(!e.endsWith(".json"))t.push(`${e}.json`);t.push(qu(e,"tsconfig.json"));for(let r of t)try{if(Ju(r).isFile())return r}catch{}return null}function Qu(e,t){if(vo(e)||e.startsWith("."))return _n(So(Zu(t),e));let r=Yu(t);for(let n of[e,`${e}/tsconfig.json`])try{let i=_n(r.resolve(n));if(i)return i}catch{}return null}async function bo(e,t){let r=_n(e);if(!r||t.has(r))return;t.add(r);let n=await Uu(r,"utf8"),i=JSON.parse(zu(n)),s=typeof i.extends==="string"?[i.extends]:i.extends??[],a;for(let o of s){let c=Qu(o,r);if(!c)continue;let f=await bo(c,t);if(f!==void 0)a=f}return i.compilerOptions?.isolatedDeclarations??a}async function Ao(e){try{let t=e?.cwd||Xu.cwd(),r=e?.tsconfigPath||"tsconfig.json",n=vo(r)?r:So(t,r);return await bo(n,new Set)??!1}catch{return!1}}function xo(e,t){let r={isValid:!0,errors:[]};for(let n of wo(e))r.errors.push({line:n.line,column:n.column,message:n.message,code:n.code});for(let n of yo(e))r.errors.push({line:n.line,column:1,message:`'${n.name}' is used but never declared or imported here, so it resolves to an error type for anything consuming this file. It is most likely an ambient global in the source project \u2014 import it explicitly. Referenced by: ${n.context}`,code:"dangling-type-reference"});return r.isValid=r.errors.length===0,r}function To(e,t,r){if(e===t)return"";let n=e.split(`
76
76
  `),i=t.split(`
77
77
  `),s=new Map,a=new Map;for(let u=0;u<n.length;u++)s.set(n[u],(s.get(n[u])??0)+1);for(let u=0;u<i.length;u++)a.set(i[u],(a.get(i[u])??0)+1);let o=[],c=[];for(let[u,l]of s){let g=l-(a.get(u)??0);for(let d=0;d<g;d++)o.push(u)}for(let[u,l]of a){let g=l-(s.get(u)??0);for(let d=0;d<g;d++)c.push(u)}if(o.length===0&&c.length===0)return"";let f=[`--- ${r}`,`+++ ${r}`];for(let u=0;u<o.length;u++)f.push(`- ${o[u]}`);for(let u=0;u<c.length;u++)f.push(`+ ${c[u]}`);return f.join(`
78
- `)}function Ao(e,t,r,n){let i=e.split(`
79
- `),s=[];function a(l){let g="",d=l<0?-l<<1|1:l<<1;do{let w=d&31;if(d>>>=5,d>0)w|=32;g+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[w]}while(d>0);return g}let o=0,c=0,f=0,u=n.split(`
80
- `).length;for(let l=0;l<i.length;l++){if(i[l].trim()===""){s.push("");continue}o=0;let g=Math.min(l,u-1),d=[],w=0-o,E=0,C=g-c,A=0-f;d.push(a(w)+a(E)+a(C)+a(A)),o=0,c=g,f=0,s.push(d.join(","))}return{version:3,file:t,sourceRoot:"",sources:[r],sourcesContent:[n],mappings:s.join(";")}}function xo(e,t){return`${e}
81
- ${Vn()}${t}
82
- `}var To=oe(()=>{po();yo();yi()});function Ro(e,t){let r=Number.isFinite(t)?Math.max(1,Math.floor(t)):1;if(e===void 0||!Number.isFinite(e))return r;return Math.max(1,Math.floor(e))}var Oo=()=>{};function Xu(e){if(e.indexOf("/*")===-1)return e.trim();let t=[],r=0,n=0,i=e.length;while(n<i)if(e.charCodeAt(n)===47&&n+1<i&&e.charCodeAt(n+1)===42){if(n>r)t.push(e.substring(r,n));n+=2;while(n<i-1){if(e.charCodeAt(n)===42&&e.charCodeAt(n+1)===47){n+=2;break}n++}r=n}else n++;if(r<i)t.push(e.substring(r));return t.join("").trim()}function Jn(){Ei=!0,je=null}function Un(){Ei=!1;let e=je;return je=null,e}function Yn(e){let t=e.length;if(t===0)return!1;let r=0;if(e.charCodeAt(r)===45)r++;if(r>=t)return!1;let n=r;while(r<t&&e.charCodeAt(r)>=48&&e.charCodeAt(r)<=57)r++;if(r===n)return!1;if(r<t&&e.charCodeAt(r)===46){r++;let i=r;while(r<t&&e.charCodeAt(r)>=48&&e.charCodeAt(r)<=57)r++;if(r===i)return!1}return r===t}function zu(e){for(let t=0,r=e.length-1;t<r;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return!0}function _n(e,t){let r=0,n=0;while((n=e.indexOf(t,n))!==-1)r++,n+=t.length;return r}function Po(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===36||e===95||e===46||e===58||e===45}function Ci(e){let t=e.trim();if(t.length<3||t.charCodeAt(0)!==60)return!1;if(t.startsWith("<>"))return t.endsWith("</>");let r=t.charCodeAt(1);if(!(r>=65&&r<=90||r>=97&&r<=122||r===36||r===95))return!1;let n=2;while(n<t.length&&Po(t.charCodeAt(n)))n++;let i=t.slice(1,n),s=t.charCodeAt(n);if(s>32&&s!==62&&s!==47)return!1;if(t.endsWith("/>"))return!0;let a=t.lastIndexOf("</");if(a===-1)return!1;let o=a+2;while(o<t.length&&Po(t.charCodeAt(o)))o++;return t.slice(a+2,o)===i&&t.charCodeAt(o)===62&&o===t.length-1}function gr(e){let t=e.length,r=!1;for(let a=1;a<t;a++)if(e.charCodeAt(a)<=32&&e.charCodeAt(a-1)<=32){r=!0;break}if(!r)for(let a=0;a<t;a++){let o=e.charCodeAt(a);if(o===10||o===13||o===9){r=!0;break}}if(!r)return e;let n=[],i=-1,s=!1;for(let a=0;a<t;a++)if(e.charCodeAt(a)<=32){if(!s){if(i>=0)n.push(e.substring(i,a));n.push(" "),s=!0,i=-1}}else{if(s||i<0)i=a;s=!1}if(i>=0)n.push(e.substring(i));return n.join("")}function Ae(e,t=!1,r=!1,n=0){if(!e||typeof e!=="string")return"unknown";if(n>=20)return"unknown";let i=e.trim();if(Ci(i))return"JSX.Element";if(i.startsWith("BigInt("))return"bigint";if(i.startsWith("Symbol.for("))return"symbol";if(i.includes(".raw`")||i.includes("String.raw`"))return"string";if(i.startsWith("`")&&i.endsWith("`")){if(!t||i.includes("${")||i.includes(`
83
- `)||i.includes("\r"))return"string";return i}if(i.charCodeAt(0)===39||i.charCodeAt(0)===34){let a=Qu(i);if(a!==null){if(a==="string"||!t)return"string";return a}}if(Yn(i)){if(!t)return"number";return i}if(i==="true"||i==="false"){if(!t)return"boolean";return i}if(i==="null")return"null";if(i==="undefined")return"undefined";if(i.startsWith("[")&&i.endsWith("]"))return Hn(i,t,n+1);if(i.startsWith("{")&&i.endsWith("}"))return hh(i,t,n+1);if(i.startsWith("class ")||i.startsWith("class{"))return fh(i);if(i.startsWith("new "))return ch(i);if(i.endsWith("as const")){let a=i.slice(0,-8).trim();if(a.startsWith("[")&&a.endsWith("]")){let o=a.slice(1,-1).trim();if(!o)return"readonly []";let c=wi(o),f=[];for(let u=0;u<c.length;u++)f.push(Ae(c[u].trim(),!0,!1,n+1));return`readonly [${f.join(", ")}]`}return Ae(a,!0,r,n+1)}if($i(i)!==-1||i.startsWith("function")||i.startsWith("async"))return _o(i,r,n,t);if(i.startsWith("`")&&i.endsWith("`"))return lh(i,t);if(i.startsWith("Promise."))return Wo(i,t,n);if(i.startsWith("await "))return"unknown";if(i.charCodeAt(i.length-1)===110&&i.length>1&&zu(i)){if(t)return i;return"bigint"}if(i.startsWith("Symbol(")||i==="Symbol.for")return"symbol";let s=Go(i);if(s!==null)return s;if(nh(i))return"boolean";if(ih(i))return"number";return"unknown"}function ko(e){let t=e.charCodeAt(0);if(t!==39&&t!==34)return!1;return It(e,0,t)===e.length}function Qu(e){if(ko(e))return e;let t=eh(e);if(t.length<2)return null;let r=!1,n=!0,i="";for(let s of t){let a=s.trim();if(ko(a))r=!0,i+=th(a);else n=!1}if(n)return rh(i);if(r)return"string";return null}function eh(e){let t=[],r=0,n=0,i=0;while(i<e.length){let s=e.charCodeAt(i);if(s===39||s===34||s===96){i=It(e,i,s);continue}if(s===40||s===91||s===123)r++;else if(s===41||s===93||s===125)r--;else if(s===43&&r===0)t.push(e.slice(n,i)),n=i+1;i++}return t.push(e.slice(n)),t}function th(e){return e.slice(1,-1).replace(/\\(.)/g,(t,r)=>{if(r==="n")return`
84
- `;if(r==="t")return"\t";if(r==="r")return"\r";if(r==="0")return"\x00";return r})}function rh(e){return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function ih(e){if(e==="")return!1;let t=!1,r=!1;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);if(i>=48&&i<=57){t=!0;continue}if(i===43||i===45||i===42||i===47||i===37){r=!0;continue}if(i===46||i===40||i===41||i<=32)continue;return!1}return t&&r}function nh(e){let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===34||n===39||n===96){r=It(e,r,n)-1;continue}if(n===40||n===91||n===123){t++;continue}if(n===41||n===93||n===125){t--;continue}if(t!==0)continue;if(e.startsWith("===",r)||e.startsWith("!==",r)||e.startsWith("==",r)||e.startsWith("!=",r)||e.startsWith(">=",r)||e.startsWith("<=",r))return!0;if((n===62||n===60)&&e.charCodeAt(r-1)!==61&&e.charCodeAt(r+1)!==61)return!0}return!1}function sh(e,t=!1,r=0){return Ae(e,t,!0,r)}function yr(e,t=!1,r=""){let n=No(r),i=[],s=!1,a=0;while(a<e.length){let c=e.charCodeAt(a);if(c===34||c===39||c===96){a=It(e,a,c);continue}if(c===47&&e.charCodeAt(a+1)===47){a+=2;while(a<e.length&&e.charCodeAt(a)!==10&&e.charCodeAt(a)!==13)a++;continue}if(c===47&&e.charCodeAt(a+1)===42){let f=e.indexOf("*/",a+2);a=f===-1?e.length:f+2;continue}if(e.startsWith("function",a)&&Mo(e,a,8)||e.startsWith("class",a)&&Mo(e,a,5)){let f=oh(e,a);if(f!==-1){a=Io(e,f);continue}}if(c===61&&e.charCodeAt(a+1)===62){let f=a+2;while(f<e.length&&e.charCodeAt(f)<=32)f++;if(e.charCodeAt(f)===123){a=Io(e,f);continue}}if(e.startsWith("return",a)&&(a===0||!$t(e.charCodeAt(a-1)))&&!$t(e.charCodeAt(a+6))){a+=6;let f=!1;while(a<e.length&&e.charCodeAt(a)<=32){let C=e.charCodeAt(a);if(C===10||C===13)f=!0;a++}if(f||a>=e.length||e.charCodeAt(a)===59||e.charCodeAt(a)===125){s=!0;continue}let u=a,l=0,g=0,d=0;while(a<e.length){let C=e.charCodeAt(a);if(C===34||C===39||C===96){a=It(e,a,C);continue}if(C===47&&e.charCodeAt(a+1)===47)break;if(C===47&&e.charCodeAt(a+1)===42){let A=e.indexOf("*/",a+2);a=A===-1?e.length:A+2;continue}if(C===40)l++;else if(C===41)l--;else if(C===91)g++;else if(C===93)g--;else if(C===123)d++;else if(C===125){if(d===0&&l===0&&g===0)break;d--}else if(C===59&&l===0&&g===0&&d===0)break;else if((C===10||C===13)&&l===0&&g===0&&d===0){let A=a+1;while(A<e.length&&e.charCodeAt(A)<=32)A++;if(e.startsWith("return",A)&&!$t(e.charCodeAt(A+6)))break}a++}let w=e.slice(u,a).trim(),E=Mt(w,n);if(!i.includes(E))i.push(E);continue}a++}if(s&&!i.includes("undefined"))i.push("undefined");let o=i.includes("unknown")?"unknown":i.length===0?"void":i.join(" | ");return t&&!o.startsWith("Promise<")?`Promise<${o}>`:o}function No(e){let t=new Map,r=e.startsWith("(")&&e.endsWith(")")?e.slice(1,-1):e,n=0,i=0,s=0;for(let a=0;a<=r.length;a++){let o=r.charCodeAt(a);if(o===40||o===91||o===123)i++;else if(o===41||o===93||o===125)i--;else if(o===60)s++;else if(o===62&&r.charCodeAt(a-1)!==61&&s>0)s--;if(a!==r.length&&(o!==44||i!==0||s!==0))continue;let c=r.slice(n,a).trim(),f=c.indexOf(":");if(f!==-1){let u=c.slice(0,f).trim().replace(/^\.\.\./,"").replace(/\?$/,""),l=c.slice(f+1).trim(),g=l.indexOf("=");if(g!==-1)l=l.slice(0,g).trim();if(Cr(u)&&l)t.set(u,l)}n=a+1}return t}function Mt(e,t){let r=e.trim();while(Lo(r))r=r.slice(1,-1).trim();if(Ci(r))return"JSX.Element";if(r.startsWith("await ")){let s=Mt(r.slice(6),t);return s.startsWith("Promise<")&&s.endsWith(">")?s.slice(8,-1):s}if(t.has(r))return t.get(r);if(r.startsWith("!"))return"boolean";if(r.startsWith("fetch("))return"Promise<Response>";let n=ah(r);if(n){let s=Mt(n.whenTrue,t),a=Mt(n.whenFalse,t);return s===a?s:`${s} | ${a}`}if(["===","!==","==","!=",">=","<="].some((s)=>r.includes(s))||r.includes(" > ")||r.includes(" < "))return"boolean";let i=0;for(let s=r.length-1;s>=0;s--){let a=r.charCodeAt(s);if(a===41||a===93||a===125)i++;else if(a===40||a===91||a===123)i--;else if(i===0&&(a===43||a===45||a===42||a===47||a===37)){let o=Mt(r.slice(0,s),t),c=Mt(r.slice(s+1),t);if(a===43&&(o==="string"||c==="string"))return"string";if(o==="number"&&c==="number")return"number";break}}return Ae(r,!1).replace(/\btypeof\s+[$A-Z_a-z][$\w]*/g,(s)=>{let a=s.slice(7);return t.get(a)??"unknown"})}function Lo(e){if(!e.startsWith("(")||!e.endsWith(")"))return!1;let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===40)t++;else if(n===41&&--t===0)return r===e.length-1}return!1}function ah(e){let t=0,r=-1;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);if(i===40||i===91||i===123)t++;else if(i===41||i===93||i===125)t--;else if(i===63&&t===0&&e.charCodeAt(n+1)!==63)r=n;else if(i===58&&t===0&&r!==-1)return{whenTrue:e.slice(r+1,n),whenFalse:e.slice(n+1)}}return null}function Mo(e,t,r){return(t===0||!$t(e.charCodeAt(t-1)))&&!$t(e.charCodeAt(t+r))}function oh(e,t){for(let r=t;r<e.length;r++){let n=e.charCodeAt(r);if(n===34||n===39||n===96){r=It(e,r,n)-1;continue}if(n===123)return r;if(n===59)return-1}return-1}function Io(e,t){let r=1,n=t+1;while(n<e.length&&r>0){let i=e.charCodeAt(n);if(i===34||i===39||i===96){n=It(e,n,i);continue}if(i===47&&e.charCodeAt(n+1)===47){n+=2;while(n<e.length&&e.charCodeAt(n)!==10&&e.charCodeAt(n)!==13)n++;continue}if(i===47&&e.charCodeAt(n+1)===42){let s=e.indexOf("*/",n+2);n=s===-1?e.length:s+2;continue}if(i===123)r++;else if(i===125)r--;n++}return n}function It(e,t,r){let n=t+1;while(n<e.length){let i=e.charCodeAt(n);if(i===92){n+=2;continue}if(n++,i===r)break}return n}function lh(e,t){if(e.includes(".raw`")||e.includes("String.raw`"))return"string";if(!t||e.includes("${")||e.includes(`
85
- `)||e.includes("\r"))return"string";return e}function ch(e){let t=4;while(t<e.length&&e.charCodeAt(t)<=32)t++;let r=t,n=e.charCodeAt(t);if(n<65||n>90)return"unknown";while(t<e.length&&($t(e.charCodeAt(t))||e.charCodeAt(t)===46))t++;if(t===r)return"unknown";let i=e.slice(r,t);{let s=e.slice(t),a=s;if(s.startsWith("<")){let c=0,f=-1;for(let u=0;u<s.length;u++)if(s[u]==="<")c++;else if(s[u]===">"){if(c--,c===0){f=u;break}}if(f!==-1){let u=s.slice(0,f+1);a=s.slice(f+1);let l=a.indexOf("(");if(l!==-1){let g=0,d=-1;for(let w=l;w<a.length;w++)if(a[w]==="(")g++;else if(a[w]===")"){if(g--,g===0){d=w;break}}if(d!==-1){if(a.slice(d+1).trimStart().startsWith("."))return"unknown"}}return`${i}${u}`}}let o=a.indexOf("(");if(o!==-1){let c=0,f=-1;for(let u=o;u<a.length;u++)if(a[u]==="(")c++;else if(a[u]===")"){if(c--,c===0){f=u;break}}if(f!==-1){if(a.slice(f+1).trimStart().startsWith("."))return"unknown"}}switch(i){case"Date":return"Date";case"Map":return"Map<any, any>";case"Set":return"Set<any>";case"WeakMap":return"WeakMap<any, any>";case"WeakSet":return"WeakSet<any>";case"RegExp":return"RegExp";case"Error":return"Error";case"Array":return"any[]";case"Object":return"object";case"Function":return"Function";case"Promise":return"Promise<any>";default:return i}}return"unknown"}function fh(e){return"{ new (...args: any[]): any }"}function Wo(e,t,r=0){if(e.startsWith("Promise.resolve(")){let n=e.indexOf(")",16);if(n!==-1){let i=e.slice(16,n).trim();if(i)return`Promise<${Ae(i,t,!1,r+1)}>`}return"Promise<unknown>"}if(e.startsWith("Promise.reject("))return"Promise<never>";if(e.startsWith("Promise.all(")){let n=e.indexOf("[",12),i=e.lastIndexOf("]");if(n!==-1&&i>n){let s=e.slice(n+1,i).trim(),a=wi(s),o=[];for(let c=0;c<a.length;c++){let f=a[c].trim();if(f.startsWith("Promise.resolve(")){let u=Wo(f,t,r+1),l=u.indexOf("<"),g=u.lastIndexOf(">");o.push(l!==-1&&g>l?u.slice(l+1,g):"unknown")}else o.push(Ae(f,t,!1,r+1))}return`Promise<[${o.join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function Hn(e,t,r=0){let n=e.slice(1,-1).trim();if(!n)return"never[]";if(r>=20)return"unknown[]";let i=wi(n),s=!1;for(let g=0;g<i.length;g++){let d=i[g],w=d.length;while(w>0&&d.charCodeAt(w-1)<=32)w--;if(w>=8&&d.slice(w-8,w)==="as const"){s=!0;break}}if(s){let g=[];for(let d=0;d<i.length;d++){let w=i[d].trim();if(w.endsWith("as const")){let E=w.slice(0,-8).trim();if(E.startsWith("[")&&E.endsWith("]")){let C=E.slice(1,-1).trim(),A=wi(C),O=[];for(let R=0;R<A.length;R++)O.push(Ae(A[R].trim(),!0,!1,r+1));g.push(`readonly [${O.join(", ")}]`)}else g.push(Ae(E,!0,!1,r+1))}else if(w.startsWith("[")&&w.endsWith("]"))g.push(Hn(w,!0,r+1));else g.push(Ae(w,!0,!1,r+1))}return`readonly [
78
+ `)}function Ro(e,t,r,n){let i=e.split(`
79
+ `),s=[];function a(l){let g="",d=l<0?-l<<1|1:l<<1;do{let $=d&31;if(d>>>=5,d>0)$|=32;g+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[$]}while(d>0);return g}let o=0,c=0,f=0,u=n.split(`
80
+ `).length;for(let l=0;l<i.length;l++){if(i[l].trim()===""){s.push("");continue}o=0;let g=Math.min(l,u-1),d=[],$=0-o,v=0,C=g-c,x=0-f;d.push(a($)+a(v)+a(C)+a(x)),o=0,c=g,f=0,s.push(d.join(","))}return{version:3,file:t,sourceRoot:"",sources:[r],sourcesContent:[n],mappings:s.join(";")}}function Oo(e,t){return`${e}
81
+ ${Hn()}${t}
82
+ `}var Po=le(()=>{Co();$o();wi()});function ko(e,t){let r=Number.isFinite(t)?Math.max(1,Math.floor(t)):1;if(e===void 0||!Number.isFinite(e))return r;return Math.max(1,Math.floor(e))}var Mo=()=>{};function eh(e){if(e.indexOf("/*")===-1)return e.trim();let t=[],r=0,n=0,i=e.length;while(n<i)if(e.charCodeAt(n)===47&&n+1<i&&e.charCodeAt(n+1)===42){if(n>r)t.push(e.substring(r,n));n+=2;while(n<i-1){if(e.charCodeAt(n)===42&&e.charCodeAt(n+1)===47){n+=2;break}n++}r=n}else n++;if(r<i)t.push(e.substring(r));return t.join("").trim()}function Yn(){Si=!0,je=null}function Zn(){Si=!1;let e=je;return je=null,e}function qn(e){let t=e.length;if(t===0)return!1;let r=0;if(e.charCodeAt(r)===45)r++;if(r>=t)return!1;let n=r;while(r<t&&e.charCodeAt(r)>=48&&e.charCodeAt(r)<=57)r++;if(r===n)return!1;if(r<t&&e.charCodeAt(r)===46){r++;let i=r;while(r<t&&e.charCodeAt(r)>=48&&e.charCodeAt(r)<=57)r++;if(r===i)return!1}return r===t}function th(e){for(let t=0,r=e.length-1;t<r;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return!0}function jn(e,t){let r=0,n=0;while((n=e.indexOf(t,n))!==-1)r++,n+=t.length;return r}function Io(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===36||e===95||e===46||e===58||e===45}function $i(e){let t=e.trim();if(t.length<3||t.charCodeAt(0)!==60)return!1;if(t.startsWith("<>"))return t.endsWith("</>");let r=t.charCodeAt(1);if(!(r>=65&&r<=90||r>=97&&r<=122||r===36||r===95))return!1;let n=2;while(n<t.length&&Io(t.charCodeAt(n)))n++;let i=t.slice(1,n),s=t.charCodeAt(n);if(s>32&&s!==62&&s!==47)return!1;if(t.endsWith("/>"))return!0;let a=t.lastIndexOf("</");if(a===-1)return!1;let o=a+2;while(o<t.length&&Io(t.charCodeAt(o)))o++;return t.slice(a+2,o)===i&&t.charCodeAt(o)===62&&o===t.length-1}function yr(e){let t=e.length,r=!1;for(let a=1;a<t;a++)if(e.charCodeAt(a)<=32&&e.charCodeAt(a-1)<=32){r=!0;break}if(!r)for(let a=0;a<t;a++){let o=e.charCodeAt(a);if(o===10||o===13||o===9){r=!0;break}}if(!r)return e;let n=[],i=-1,s=!1;for(let a=0;a<t;a++)if(e.charCodeAt(a)<=32){if(!s){if(i>=0)n.push(e.substring(i,a));n.push(" "),s=!0,i=-1}}else{if(s||i<0)i=a;s=!1}if(i>=0)n.push(e.substring(i));return n.join("")}function xe(e,t=!1,r=!1,n=0){if(!e||typeof e!=="string")return"unknown";if(n>=20)return"unknown";let i=e.trim();if($i(i))return"JSX.Element";if(i.startsWith("BigInt("))return"bigint";if(i.startsWith("Symbol.for("))return"symbol";if(i.includes(".raw`")||i.includes("String.raw`"))return"string";if(i.startsWith("`")&&i.endsWith("`")){if(!t||i.includes("${")||i.includes(`
83
+ `)||i.includes("\r"))return"string";return i}if(i.charCodeAt(0)===39||i.charCodeAt(0)===34){let a=rh(i);if(a!==null){if(a==="string"||!t)return"string";return a}}if(qn(i)){if(!t)return"number";return i}if(i==="true"||i==="false"){if(!t)return"boolean";return i}if(i==="null")return"null";if(i==="undefined")return"undefined";if(i.startsWith("[")&&i.endsWith("]"))return Kn(i,t,n+1);if(i.startsWith("{")&&i.endsWith("}"))return ph(i,t,n+1);if(i.startsWith("class ")||i.startsWith("class{"))return dh(i);if(i.startsWith("new "))return hh(i);if(i.endsWith("as const")){let a=i.slice(0,-8).trim();if(a.startsWith("[")&&a.endsWith("]")){let o=a.slice(1,-1).trim();if(!o)return"readonly []";let c=Ei(o),f=[];for(let u=0;u<c.length;u++)f.push(xe(c[u].trim(),!0,!1,n+1));return`readonly [${f.join(", ")}]`}return xe(a,!0,r,n+1)}if(vi(i)!==-1||i.startsWith("function")||i.startsWith("async"))return Ko(i,r,n,t);if(i.startsWith("`")&&i.endsWith("`"))return uh(i,t);if(i.startsWith("Promise."))return Vo(i,t,n);if(i.startsWith("await "))return"unknown";if(i.charCodeAt(i.length-1)===110&&i.length>1&&th(i)){if(t)return i;return"bigint"}if(i.startsWith("Symbol(")||i==="Symbol.for")return"symbol";let s=_o(i);if(s!==null)return s;if(oh(i))return"boolean";if(ah(i))return"number";return"unknown"}function Do(e){let t=e.charCodeAt(0);if(t!==39&&t!==34)return!1;return Pt(e,0,t)===e.length}function rh(e){if(Do(e))return e;let t=ih(e);if(t.length<2)return null;let r=!1,n=!0,i="";for(let s of t){let a=s.trim();if(Do(a))r=!0,i+=nh(a);else n=!1}if(n)return sh(i);if(r)return"string";return null}function ih(e){let t=[],r=0,n=0,i=0;while(i<e.length){let s=e.charCodeAt(i);if(s===39||s===34||s===96){i=Pt(e,i,s);continue}if(s===40||s===91||s===123)r++;else if(s===41||s===93||s===125)r--;else if(s===43&&r===0)t.push(e.slice(n,i)),n=i+1;i++}return t.push(e.slice(n)),t}function nh(e){return e.slice(1,-1).replace(/\\(.)/g,(t,r)=>{if(r==="n")return`
84
+ `;if(r==="t")return"\t";if(r==="r")return"\r";if(r==="0")return"\x00";return r})}function sh(e){return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function ah(e){if(e==="")return!1;let t=!1,r=!1;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);if(i>=48&&i<=57){t=!0;continue}if(i===43||i===45||i===42||i===47||i===37){r=!0;continue}if(i===46||i===40||i===41||i<=32)continue;return!1}return t&&r}function oh(e){let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===34||n===39||n===96){r=Pt(e,r,n)-1;continue}if(n===40||n===91||n===123){t++;continue}if(n===41||n===93||n===125){t--;continue}if(t!==0)continue;if(e.startsWith("===",r)||e.startsWith("!==",r)||e.startsWith("==",r)||e.startsWith("!=",r)||e.startsWith(">=",r)||e.startsWith("<=",r))return!0;if((n===62||n===60)&&e.charCodeAt(r-1)!==61&&e.charCodeAt(r+1)!==61)return!0}return!1}function lh(e,t=!1,r=0){return xe(e,t,!0,r)}function Cr(e,t=!1,r=""){let n=Go(r),i=[],s=!1,a=0;while(a<e.length){let c=e.charCodeAt(a);if(c===34||c===39||c===96){a=Pt(e,a,c);continue}if(c===47&&e.charCodeAt(a+1)===47){a+=2;while(a<e.length&&e.charCodeAt(a)!==10&&e.charCodeAt(a)!==13)a++;continue}if(c===47&&e.charCodeAt(a+1)===42){let f=e.indexOf("*/",a+2);a=f===-1?e.length:f+2;continue}if(e.startsWith("function",a)&&Fo(e,a,8)||e.startsWith("class",a)&&Fo(e,a,5)){let f=fh(e,a);if(f!==-1){a=No(e,f);continue}}if(c===61&&e.charCodeAt(a+1)===62){let f=a+2;while(f<e.length&&e.charCodeAt(f)<=32)f++;if(e.charCodeAt(f)===123){a=No(e,f);continue}}if(e.startsWith("return",a)&&(a===0||!$t(e.charCodeAt(a-1)))&&!$t(e.charCodeAt(a+6))){a+=6;let f=!1;while(a<e.length&&e.charCodeAt(a)<=32){let C=e.charCodeAt(a);if(C===10||C===13)f=!0;a++}if(f||a>=e.length||e.charCodeAt(a)===59||e.charCodeAt(a)===125){s=!0;continue}let u=a,l=0,g=0,d=0;while(a<e.length){let C=e.charCodeAt(a);if(C===34||C===39||C===96){a=Pt(e,a,C);continue}if(C===47&&e.charCodeAt(a+1)===47)break;if(C===47&&e.charCodeAt(a+1)===42){let x=e.indexOf("*/",a+2);a=x===-1?e.length:x+2;continue}if(C===40)l++;else if(C===41)l--;else if(C===91)g++;else if(C===93)g--;else if(C===123)d++;else if(C===125){if(d===0&&l===0&&g===0)break;d--}else if(C===59&&l===0&&g===0&&d===0)break;else if((C===10||C===13)&&l===0&&g===0&&d===0){let x=a+1;while(x<e.length&&e.charCodeAt(x)<=32)x++;if(e.startsWith("return",x)&&!$t(e.charCodeAt(x+6)))break}a++}let $=e.slice(u,a).trim(),v=Ot($,n);if(!i.includes(v))i.push(v);continue}a++}if(s&&!i.includes("undefined"))i.push("undefined");let o=i.includes("unknown")?"unknown":i.length===0?"void":i.join(" | ");return t&&!o.startsWith("Promise<")?`Promise<${o}>`:o}function Go(e){let t=new Map,r=e.startsWith("(")&&e.endsWith(")")?e.slice(1,-1):e,n=0,i=0,s=0;for(let a=0;a<=r.length;a++){let o=r.charCodeAt(a);if(o===40||o===91||o===123)i++;else if(o===41||o===93||o===125)i--;else if(o===60)s++;else if(o===62&&r.charCodeAt(a-1)!==61&&s>0)s--;if(a!==r.length&&(o!==44||i!==0||s!==0))continue;let c=r.slice(n,a).trim(),f=c.indexOf(":");if(f!==-1){let u=c.slice(0,f).trim().replace(/^\.\.\./,"").replace(/\?$/,""),l=c.slice(f+1).trim(),g=l.indexOf("=");if(g!==-1)l=l.slice(0,g).trim();if(wr(u)&&l)t.set(u,l)}n=a+1}return t}function Ot(e,t){let r=e.trim();while(Bo(r))r=r.slice(1,-1).trim();if($i(r))return"JSX.Element";if(r.startsWith("await ")){let s=Ot(r.slice(6),t);return s.startsWith("Promise<")&&s.endsWith(">")?s.slice(8,-1):s}if(t.has(r))return t.get(r);if(r.startsWith("!"))return"boolean";if(r.startsWith("fetch("))return"Promise<Response>";let n=ch(r);if(n){let s=Ot(n.whenTrue,t),a=Ot(n.whenFalse,t);return s===a?s:`${s} | ${a}`}if(["===","!==","==","!=",">=","<="].some((s)=>r.includes(s))||r.includes(" > ")||r.includes(" < "))return"boolean";let i=0;for(let s=r.length-1;s>=0;s--){let a=r.charCodeAt(s);if(a===41||a===93||a===125)i++;else if(a===40||a===91||a===123)i--;else if(i===0&&(a===43||a===45||a===42||a===47||a===37)){let o=Ot(r.slice(0,s),t),c=Ot(r.slice(s+1),t);if(a===43&&(o==="string"||c==="string"))return"string";if(o==="number"&&c==="number")return"number";break}}return xe(r,!1).replace(/\btypeof\s+[$A-Z_a-z][$\w]*/g,(s)=>{let a=s.slice(7);return t.get(a)??"unknown"})}function Bo(e){if(!e.startsWith("(")||!e.endsWith(")"))return!1;let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===40)t++;else if(n===41&&--t===0)return r===e.length-1}return!1}function ch(e){let t=0,r=-1;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);if(i===40||i===91||i===123)t++;else if(i===41||i===93||i===125)t--;else if(i===63&&t===0&&e.charCodeAt(n+1)!==63)r=n;else if(i===58&&t===0&&r!==-1)return{whenTrue:e.slice(r+1,n),whenFalse:e.slice(n+1)}}return null}function Fo(e,t,r){return(t===0||!$t(e.charCodeAt(t-1)))&&!$t(e.charCodeAt(t+r))}function fh(e,t){for(let r=t;r<e.length;r++){let n=e.charCodeAt(r);if(n===34||n===39||n===96){r=Pt(e,r,n)-1;continue}if(n===123)return r;if(n===59)return-1}return-1}function No(e,t){let r=1,n=t+1;while(n<e.length&&r>0){let i=e.charCodeAt(n);if(i===34||i===39||i===96){n=Pt(e,n,i);continue}if(i===47&&e.charCodeAt(n+1)===47){n+=2;while(n<e.length&&e.charCodeAt(n)!==10&&e.charCodeAt(n)!==13)n++;continue}if(i===47&&e.charCodeAt(n+1)===42){let s=e.indexOf("*/",n+2);n=s===-1?e.length:s+2;continue}if(i===123)r++;else if(i===125)r--;n++}return n}function Pt(e,t,r){let n=t+1;while(n<e.length){let i=e.charCodeAt(n);if(i===92){n+=2;continue}if(n++,i===r)break}return n}function uh(e,t){if(e.includes(".raw`")||e.includes("String.raw`"))return"string";if(!t||e.includes("${")||e.includes(`
85
+ `)||e.includes("\r"))return"string";return e}function hh(e){let t=4;while(t<e.length&&e.charCodeAt(t)<=32)t++;let r=t,n=e.charCodeAt(t);if(n<65||n>90)return"unknown";while(t<e.length&&($t(e.charCodeAt(t))||e.charCodeAt(t)===46))t++;if(t===r)return"unknown";let i=e.slice(r,t);{let s=e.slice(t),a=s;if(s.startsWith("<")){let c=0,f=-1;for(let u=0;u<s.length;u++)if(s[u]==="<")c++;else if(s[u]===">"){if(c--,c===0){f=u;break}}if(f!==-1){let u=s.slice(0,f+1);a=s.slice(f+1);let l=a.indexOf("(");if(l!==-1){let g=0,d=-1;for(let $=l;$<a.length;$++)if(a[$]==="(")g++;else if(a[$]===")"){if(g--,g===0){d=$;break}}if(d!==-1){if(a.slice(d+1).trimStart().startsWith("."))return"unknown"}}return`${i}${u}`}}let o=a.indexOf("(");if(o!==-1){let c=0,f=-1;for(let u=o;u<a.length;u++)if(a[u]==="(")c++;else if(a[u]===")"){if(c--,c===0){f=u;break}}if(f!==-1){if(a.slice(f+1).trimStart().startsWith("."))return"unknown"}}switch(i){case"Date":return"Date";case"Map":return"Map<any, any>";case"Set":return"Set<any>";case"WeakMap":return"WeakMap<any, any>";case"WeakSet":return"WeakSet<any>";case"RegExp":return"RegExp";case"Error":return"Error";case"Array":return"any[]";case"Object":return"object";case"Function":return"Function";case"Promise":return"Promise<any>";default:return i}}return"unknown"}function dh(e){return"{ new (...args: any[]): any }"}function Vo(e,t,r=0){if(e.startsWith("Promise.resolve(")){let n=e.indexOf(")",16);if(n!==-1){let i=e.slice(16,n).trim();if(i)return`Promise<${xe(i,t,!1,r+1)}>`}return"Promise<unknown>"}if(e.startsWith("Promise.reject("))return"Promise<never>";if(e.startsWith("Promise.all(")){let n=e.indexOf("[",12),i=e.lastIndexOf("]");if(n!==-1&&i>n){let s=e.slice(n+1,i).trim(),a=Ei(s),o=[];for(let c=0;c<a.length;c++){let f=a[c].trim();if(f.startsWith("Promise.resolve(")){let u=Vo(f,t,r+1),l=u.indexOf("<"),g=u.lastIndexOf(">");o.push(l!==-1&&g>l?u.slice(l+1,g):"unknown")}else o.push(xe(f,t,!1,r+1))}return`Promise<[${o.join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function Kn(e,t,r=0){let n=e.slice(1,-1).trim();if(!n)return"never[]";if(r>=20)return"unknown[]";let i=Ei(n),s=!1;for(let g=0;g<i.length;g++){let d=i[g],$=d.length;while($>0&&d.charCodeAt($-1)<=32)$--;if($>=8&&d.slice($-8,$)==="as const"){s=!0;break}}if(s){let g=[];for(let d=0;d<i.length;d++){let $=i[d].trim();if($.endsWith("as const")){let v=$.slice(0,-8).trim();if(v.startsWith("[")&&v.endsWith("]")){let C=v.slice(1,-1).trim(),x=Ei(C),P=[];for(let R=0;R<x.length;R++)P.push(xe(x[R].trim(),!0,!1,r+1));g.push(`readonly [${P.join(", ")}]`)}else g.push(xe(v,!0,!1,r+1))}else if($.startsWith("[")&&$.endsWith("]"))g.push(Kn($,!0,r+1));else g.push(xe($,!0,!1,r+1))}return`readonly [
86
86
  ${g.join(` |
87
87
  `)}
88
- ]`}let a=Ei&&!t,o=[],c=[];for(let g of i){let d=g.trim(),w=je;if(je=null,d.startsWith("...")){let E=d.slice(3).trim(),C=Ae(E,!1,!1,r+1);if(C.endsWith("[]"))o.push(C.slice(0,-2));else if(C.startsWith("readonly [")&&C.endsWith("]"))o.push(C.slice(10,-1));else if(wr(E))o.push(`(typeof ${E})[number]`);else o.push("unknown")}else if(d.startsWith("[")&&d.endsWith("]"))o.push(Hn(d,t,r+1));else o.push(sh(d,t,r+1));if(a)c.push(je);je=w}if(a)if(Kn(e))je=gr(e);else{let g=[];for(let d=0;d<i.length;d++){let w=i[d].trim();if(w.endsWith("as const"))continue;if(jn(w)||w==="null"||w==="undefined")g.push(w);else if(w.startsWith("[")&&Kn(w))g.push(gr(w));else if(w.startsWith("{")){if(c[d])g.push(c[d])}else{let E=Ae(w,!1,!1,0);if(E!=="unknown")g.push(E)}}if(g.length>0)je=`[${g.join(", ")}]`}if(t)return`readonly [${o.join(", ")}]`;let f=new Set,u=[],l=!0;for(let g of o){if(!f.has(g))f.add(g),u.push(g);if(l){if(!(Yn(g)||g==="true"||g==="false"||g.charCodeAt(0)===34&&g.charCodeAt(g.length-1)===34||g.charCodeAt(0)===39&&g.charCodeAt(g.length-1)===39))l=!1}}if(l&&o.length<=10)return`readonly [${o.join(", ")}]`;if(u.length===1)return`${u[0]}[]`;return`(${u.join(" | ")})[]`}function wi(e){let t=[],r=0,n=0,i=!1,s=0;for(let o=0;o<e.length;o++){let c=e.charCodeAt(o);if(!i&&(c===34||c===39||c===96))i=!0,s=c;else if(i&&c===s&&(o===0||e.charCodeAt(o-1)!==92))i=!1;if(!i){if(c===91||c===123||c===40)n++;else if(c===93||c===125||c===41)n--;else if(c===44&&n===0){let f=e.substring(r,o).trim();if(f)t.push(f);r=o+1;continue}}}let a=e.substring(r).trim();if(a)t.push(a);return t}function jn(e){if(Yn(e))return!0;if(e==="true"||e==="false")return!0;if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return!0;return!1}function uh(e){return e==="number"||e==="string"||e==="boolean"}function Kn(e){let t=!1,r=0,n=e.length;for(let i=0;i<n;i++){let s=e.charCodeAt(i);if(t){if(s===92){i++;continue}if(s===r)t=!1;continue}if(s===34||s===39||s===96){t=!0,r=s;continue}if(s===61&&i+1<n&&e.charCodeAt(i+1)===62)return!1;if(s>=97&&s<=122){let a=i;while(i<n&&(e.charCodeAt(i)>=97&&e.charCodeAt(i)<=122||e.charCodeAt(i)>=65&&e.charCodeAt(i)<=90||e.charCodeAt(i)>=48&&e.charCodeAt(i)<=57||e.charCodeAt(i)===95||e.charCodeAt(i)===36))i++;let o=e.slice(a,i);if(o==="new"||o==="async"||o==="await"||o==="function"||o==="yield"||o==="console"||o==="process")return!1;let c=i;while(c<n&&e.charCodeAt(c)<=32)c++;if(c<n&&e.charCodeAt(c)===40)return!1;i--}}return!0}function hh(e,t,r=0){let n=e.slice(1,-1).trim();if(!n)return"{}";if(r>=20)return"Record<string, unknown>";let i=Ch(n),s=[],a=[],o=Ei&&!t,c=[];for(let[l,g]of i){let{comments:d,key:w}=yh(l),E=d?`${d}
89
- `:"",C=w,A=!1;if(w==="..."){let D=g.trim(),H=wr(D)?`typeof ${D}`:Ae(D,t,!1,r+1);if(H!=="unknown")a.push(H);if(o&&(wr(D)||D.startsWith("{")))c.push(`...${gr(D)}`);continue}let O=je;je=null;let R,I=g.trim();if(I===w&&Cr(I))R=`typeof ${I}`;else if(Eh(I)){A=!0;let D=vh(w);if(D){C=D.name;let H="";if(I.startsWith("async "))H="async ";if(I.charCodeAt(H.length)===42)H+="*";R=Do(D.name,H+D.typeParams+I.slice(H.length))}else R=Do(w,I)}else if(R=Ae(g,t,!1,r+1),R.includes("=>")||R.includes("function")||R.includes("async"))R=mh(R);let B=je;je=O;let L=g.trim(),T=wh(w);if(T){let D=$h(T.kind,T.name,R);if(D){s.push(`${E}${D}`);continue}}if(!t&&uh(R)&&jn(L))s.push(`${E}/** @defaultValue ${L} */
90
- ${C}: ${R}`);else s.push(`${E}${C}: ${R}`);if(o){let D=Xu(C);if(L.endsWith("as const"));else if(jn(L))c.push(`${D}: ${L}`);else if(L.startsWith("[")&&Kn(L))c.push(`${D}: ${gr(L)}`);else if(L.startsWith("{")){if(B)c.push(`${D}: ${B}`)}else if(A)c.push(`${D}: ${gr(R)}`);else if(!L.startsWith("[")&&(L.includes("=>")||L.startsWith("function")||L.startsWith("async"))){let H=_o(L,!1,0,!0);c.push(`${D}: ${H}`)}}}if(o&&c.length>0){let l=r>0?(r-1)/2:0,g=`{ ${c.join(", ")} }`;if(g.length<=80)je=g;else{let d=" ".repeat((l+1)*2),w=" ".repeat(l*2);je=`{
88
+ ]`}let a=Si&&!t,o=[],c=[];for(let g of i){let d=g.trim(),$=je;if(je=null,d.startsWith("...")){let v=d.slice(3).trim(),C=xe(v,!1,!1,r+1);if(C.endsWith("[]"))o.push(C.slice(0,-2));else if(C.startsWith("readonly [")&&C.endsWith("]"))o.push(C.slice(10,-1));else if($r(v))o.push(`(typeof ${v})[number]`);else o.push("unknown")}else if(d.startsWith("[")&&d.endsWith("]"))o.push(Kn(d,t,r+1));else o.push(lh(d,t,r+1));if(a)c.push(je);je=$}if(a)if(Un(e))je=yr(e);else{let g=[];for(let d=0;d<i.length;d++){let $=i[d].trim();if($.endsWith("as const"))continue;if(Jn($)||$==="null"||$==="undefined")g.push($);else if($.startsWith("[")&&Un($))g.push(yr($));else if($.startsWith("{")){if(c[d])g.push(c[d])}else{let v=xe($,!1,!1,0);if(v!=="unknown")g.push(v)}}if(g.length>0)je=`[${g.join(", ")}]`}if(t)return`readonly [${o.join(", ")}]`;let f=new Set,u=[],l=!0;for(let g of o){if(!f.has(g))f.add(g),u.push(g);if(l){if(!(qn(g)||g==="true"||g==="false"||g.charCodeAt(0)===34&&g.charCodeAt(g.length-1)===34||g.charCodeAt(0)===39&&g.charCodeAt(g.length-1)===39))l=!1}}if(l&&o.length<=10)return`readonly [${o.join(", ")}]`;if(u.length===1)return`${u[0]}[]`;return`(${u.join(" | ")})[]`}function Ei(e){let t=[],r=0,n=0,i=!1,s=0;for(let o=0;o<e.length;o++){let c=e.charCodeAt(o);if(!i&&(c===34||c===39||c===96))i=!0,s=c;else if(i&&c===s&&(o===0||e.charCodeAt(o-1)!==92))i=!1;if(!i){if(c===91||c===123||c===40)n++;else if(c===93||c===125||c===41)n--;else if(c===44&&n===0){let f=e.substring(r,o).trim();if(f)t.push(f);r=o+1;continue}}}let a=e.substring(r).trim();if(a)t.push(a);return t}function Jn(e){if(qn(e))return!0;if(e==="true"||e==="false")return!0;if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return!0;return!1}function mh(e){return e==="number"||e==="string"||e==="boolean"}function Un(e){let t=!1,r=0,n=e.length;for(let i=0;i<n;i++){let s=e.charCodeAt(i);if(t){if(s===92){i++;continue}if(s===r)t=!1;continue}if(s===34||s===39||s===96){t=!0,r=s;continue}if(s===61&&i+1<n&&e.charCodeAt(i+1)===62)return!1;if(s>=97&&s<=122){let a=i;while(i<n&&(e.charCodeAt(i)>=97&&e.charCodeAt(i)<=122||e.charCodeAt(i)>=65&&e.charCodeAt(i)<=90||e.charCodeAt(i)>=48&&e.charCodeAt(i)<=57||e.charCodeAt(i)===95||e.charCodeAt(i)===36))i++;let o=e.slice(a,i);if(o==="new"||o==="async"||o==="await"||o==="function"||o==="yield"||o==="console"||o==="process")return!1;let c=i;while(c<n&&e.charCodeAt(c)<=32)c++;if(c<n&&e.charCodeAt(c)===40)return!1;i--}}return!0}function ph(e,t,r=0){let n=e.slice(1,-1).trim();if(!n)return"{}";if(r>=20)return"Record<string, unknown>";let i=Eh(n),s=[],a=[],o=Si&&!t,c=[];for(let[l,g]of i){let{comments:d,key:$}=$h(l),v=d?`${d}
89
+ `:"",C=$,x=!1;if($==="..."){let D=g.trim(),H=$r(D)?`typeof ${D}`:xe(D,t,!1,r+1);if(H!=="unknown")a.push(H);if(o&&($r(D)||D.startsWith("{")))c.push(`...${yr(D)}`);continue}let P=je;je=null;let R,I=g.trim();if(I===$&&wr(I))R=`typeof ${I}`;else if(bh(I)){x=!0;let D=Ah($);if(D){C=D.name;let H="";if(I.startsWith("async "))H="async ";if(I.charCodeAt(H.length)===42)H+="*";R=Wo(D.name,H+D.typeParams+I.slice(H.length))}else R=Wo($,I)}else if(R=xe(g,t,!1,r+1),R.includes("=>")||R.includes("function")||R.includes("async"))R=yh(R);let B=je;je=P;let W=g.trim(),T=vh($);if(T){let D=Sh(T.kind,T.name,R);if(D){s.push(`${v}${D}`);continue}}if(!t&&mh(R)&&Jn(W))s.push(`${v}/** @defaultValue ${W} */
90
+ ${C}: ${R}`);else s.push(`${v}${C}: ${R}`);if(o){let D=eh(C);if(W.endsWith("as const"));else if(Jn(W))c.push(`${D}: ${W}`);else if(W.startsWith("[")&&Un(W))c.push(`${D}: ${yr(W)}`);else if(W.startsWith("{")){if(B)c.push(`${D}: ${B}`)}else if(x)c.push(`${D}: ${yr(R)}`);else if(!W.startsWith("[")&&(W.includes("=>")||W.startsWith("function")||W.startsWith("async"))){let H=Ko(W,!1,0,!0);c.push(`${D}: ${H}`)}}}if(o&&c.length>0){let l=r>0?(r-1)/2:0,g=`{ ${c.join(", ")} }`;if(g.length<=80)je=g;else{let d=" ".repeat((l+1)*2),$=" ".repeat(l*2);je=`{
91
91
  ${d}${c.join(`,
92
92
  ${d}`)}
93
- ${w}}`}}let f=s.length>0?`{
93
+ ${$}}`}}let f=s.length>0?`{
94
94
  ${s.join(`;
95
95
  `)}
96
- }`:"{}";if(a.length===0)return f;let u=a[0];for(let l=1;l<a.length;l++)u=`Omit<${u}, keyof ${a[l]}> & ${a[l]}`;return s.length>0?`Omit<${u}, keyof ${f}> & ${f}`:u}function Cr(e){if(!e)return!1;let t=e.charCodeAt(0);if(!(t>=65&&t<=90||t>=97&&t<=122||t===95||t===36||t>127))return!1;for(let r=1;r<e.length;r++)if(!$t(e.charCodeAt(r)))return!1;return!0}function wr(e){let t=e.split(".");return t.length>0&&t.every(Cr)}function dh(e){let t=!1,r="";for(let n=0;n<e.length;n++){let i=e[n];if(t){if(i==="\\")n++;else if(i===r)t=!1;continue}if(i==='"'||i==="'"||i==="`"){t=!0,r=i;continue}if(i==="(")return n;if(i==="<"){let s=Qe(e,n,"<",">");if(s!==-1)n=s}}return-1}function Go(e){if(e.length<3||!e.endsWith(")"))return null;let t=dh(e);if(t===-1||Qe(e,t,"(",")")!==e.length-1)return null;let r=e.slice(0,t).trim(),n=!1;if(r.endsWith("?."))n=!0,r=r.slice(0,-2).trim();let i=r,s=!1,a=r.indexOf("<");if(a!==-1){if(Qe(r,a,"<",">")!==r.length-1)return null;i=r.slice(0,a).trim(),s=!0}if(!wr(i))return null;let o=e.slice(t+1,-1).trim(),c=$i(o)!==-1||o.startsWith("function")||o.startsWith("async function"),f=wr(o),u=!c&&o.endsWith(")")&&Go(o)!==null;if(!s&&!n&&!c&&!f&&!u)return null;let l=`ReturnType<typeof ${r}>`;return n?`${l} | undefined`:l}function mh(e){let t=e.split(`
97
- `).map((f)=>Bo(f)).join(`
98
- `),r=t.indexOf("async");if(r!==-1){let f=r>0?t.charCodeAt(r-1):32,u=r+5<t.length?t.charCodeAt(r+5):32;if(!$t(f)&&!$t(u))t=(t.slice(0,r)+t.slice(r+5)).trim()}let n=t.indexOf("(");if(n!==-1){let f=Qe(t,n,"(",")");if(f!==-1){let u=t.slice(n,f+1),l=rr(u);t=t.slice(0,n)+l+t.slice(f+1)}}let i=t.length,s="",a=[],o=!1,c=!1;for(let f=0;f<i;f++){let u=t.charCodeAt(f);if(u===123||u===40)a.push(u);else if(u===125||u===41)a.pop();if(u<=32){if(o=!0,u===10||u===13)c=!0;continue}if(o&&s.length>0){let l=(a.length>0?a[a.length-1]:0)===123;if(c&&l){let g=s.charCodeAt(s.length-1),d=g===59||g===44||g===123||u===125,w=s.length>=2&&s.charCodeAt(s.length-1)===47&&s.charCodeAt(s.length-2)===42;if(!d&&!w)s+="; ";else s+=" "}else s+=" "}o=!1,c=!1,s+=t[f]}return s.trim()}function $t(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95||e===36}function rr(e){let t=e.trim(),r,n=!1;if(t.startsWith("(")&&t.endsWith(")"))r=t.slice(1,-1),n=!0;else r=t;let i=r.trim();if(!i)return n?"()":"";let s=!1;{let w=0;for(let E=0;E<i.length;E++){let C=i.charCodeAt(E);if(C===40||C===60||C===91||C===123)w++;else if(C===41||C===62||C===93||C===125)w--;else if(w===0&&C===61){let A=E>0?i.charCodeAt(E-1):0,O=E+1<i.length?i.charCodeAt(E+1):0;if(A!==61&&A!==33&&A!==60&&A!==62&&O!==61&&O!==62){s=!0;break}}}}if(!s)return t;let a=[],o=[],c=0,f=0,u=!1,l=0;for(let w=0;w<=i.length;w++){if(w===i.length){a.push(i.slice(c));break}let E=i.charCodeAt(w);if(u){if(E===92){w++;continue}if(E===l)u=!1;continue}if(E===47&&w+1<i.length){let C=i.charCodeAt(w+1);if(C===42){w+=2;while(w+1<i.length&&!(i.charCodeAt(w)===42&&i.charCodeAt(w+1)===47))w++;w++;continue}if(C===47){while(w<i.length&&i.charCodeAt(w)!==10)w++;continue}}if(E===39||E===34||E===96){u=!0,l=E;continue}if(E===40||E===60||E===91||E===123)f++;else if(E===41||E===62||E===93||E===125)f--;else if(E===44&&f===0){a.push(i.slice(c,w));let C=",",A=w+1;while(A<i.length&&i.charCodeAt(A)<=32)C+=i[A],A++;o.push(C),c=A}}let g=[];for(let w of a){let E=w.trim();if(!E){g.push(w);continue}if(E.startsWith("//"))continue;let C=Bo(E),A=w.slice(0,w.length-w.trimStart().length);g.push(A+ph(C))}let d=g[0]||"";for(let w=1;w<g.length;w++)d+=(o[w-1]||", ")+g[w];return n?`(${d})`:d}function Bo(e){let t=!1,r=0;for(let n=0;n<e.length-1;n++){let i=e.charCodeAt(n);if(t){if(i===92){n++;continue}if(i===r)t=!1;continue}if(i===39||i===34||i===96){t=!0,r=i;continue}if(i===47&&e.charCodeAt(n+1)===47)return e.slice(0,n).trimEnd()}return e}function ph(e){if(e.startsWith("..."))return e;let t=-1,r=-1,n=0,i=!1,s=0;for(let o=0;o<e.length;o++){let c=e.charCodeAt(o);if(i){if(c===92){o++;continue}if(c===s)i=!1;continue}if(c===47&&o+1<e.length){let f=e.charCodeAt(o+1);if(f===42){o+=2;while(o+1<e.length&&!(e.charCodeAt(o)===42&&e.charCodeAt(o+1)===47))o++;o++;continue}if(f===47){while(o<e.length&&e.charCodeAt(o)!==10)o++;continue}}if(c===39||c===34||c===96){i=!0,s=c;continue}if(c===40||c===60||c===91||c===123)n++;else if(c===41||c===62||c===93||c===125)n--;else if(n===0){if(c===58&&t===-1)t=o;else if(c===61&&r===-1&&(o===0||e.charCodeAt(o-1)!==61)&&(o+1>=e.length||e.charCodeAt(o+1)!==61&&e.charCodeAt(o+1)!==62))r=o}}let a=r!==-1;if(t!==-1&&(r===-1||t<r)){let o=e.slice(0,t).trim(),c=r!==-1?e.slice(t+1,r).trim():e.slice(t+1).trim(),f=a&&!o.endsWith("?")?"?":"";return`${o}${f}: ${c}`}else if(r!==-1){let o=e.slice(0,r).trim(),c=!o.endsWith("?")?"?":"",f=e.slice(r+1).trim(),u="unknown";if(f==="true"||f==="false")u="boolean";else if(/^-?\d+(\.\d+)?$/.test(f))u="number";else if(f.startsWith("'")&&f.endsWith("'")||f.startsWith('"')&&f.endsWith('"'))u="string";else if(f.startsWith("["))u="unknown[]";else if(f.startsWith("{"))u="Record<string, unknown>";return`${o}${c}: ${u}`}return e}function gh(e){let t=0,r=e.length;while(t<r){while(t<r&&(e.charCodeAt(t)===32||e.charCodeAt(t)===9||e.charCodeAt(t)===10||e.charCodeAt(t)===13))t++;if(t+1<r&&e.charCodeAt(t)===47&&e.charCodeAt(t+1)===42){t+=2;while(t+1<r&&!(e.charCodeAt(t)===42&&e.charCodeAt(t+1)===47))t++;t+=2;continue}break}return t}function yh(e){let t=[],r=0,n=e.length;while(r<n){while(r<n&&e.charCodeAt(r)<=32)r++;if(r+1>=n||e.charCodeAt(r)!==47||e.charCodeAt(r+1)!==42)break;let i=r;r+=2;while(r+1<n&&!(e.charCodeAt(r)===42&&e.charCodeAt(r+1)===47))r++;r=Math.min(r+2,n),t.push(e.slice(i,r).trim())}return{comments:t.join(`
99
- `),key:e.slice(r).trim()}}function Ch(e){let t=[],r="",n="",i=0,s=!1,a="",o=!0,c=!1,f=0,u=!1,l=!1,g=0,d=!1,w=!1;for(let E=0;E<e.length;E++){let C=e.charCodeAt(E),A=E>0?e.charCodeAt(E-1):0,O=E<e.length-1?e.charCodeAt(E+1):0;if(!s&&!c&&C===47&&O===47){E+=2;while(E<e.length&&e.charCodeAt(E)!==10)E++;continue}if(!s&&!c&&C===47&&O===42){c=!0,f=1,r+="/*",E++;continue}else if(c&&C===42&&O===47){if(f--,r+="*/",E++,f===0)c=!1;continue}else if(c&&C===47&&O===42){f++,r+="/*",E++;continue}let R=e[E];if(!s&&(C===34||C===39||C===96))s=!0,a=R,r+=R;else if(s&&R===a&&A!==92)s=!1,r+=R;else if(!s&&!c)if(C===40&&i===0&&o&&g===0){n=r.trim();let I=gh(n),B=I>0?n.slice(0,I):"",L=n.slice(I),T="";if(L.startsWith("async ")||L.startsWith("async\t")||L.startsWith(`async
100
- `))L=L.slice(6).trimStart(),T="async ";if(L.startsWith("*"))L=L.slice(1).trimStart(),T+="*";n=B+L,r=T+R,o=!1,d=!0,w=!1,i=1}else if(C===123||C===91||C===40){if(i++,r+=R,w&&C===123)w=!1}else if(C===125||C===93||C===41){if(i--,r+=R,C===41&&i===0&&!o&&!d)u=!0;if(d){if(C===41&&i===0&&!w)w=!0;else if(C===125&&i===0)d=!1,w=!1}}else if(C===58&&i===0&&o&&g===0)n=r.trim(),r="",o=!1;else if(C===58&&i===0&&u)l=!0,r+=R;else if(C===60&&l)g++,r+=R;else if(C===60&&o&&i===0)g++,r+=R;else if(C===62&&g>0&&A!==61)g--,r+=R;else if(C===61&&O===62&&l&&g===0)l=!1,u=!1,r+=R;else if(C===44&&i===0&&g===0&&!w){if(n&&r.trim()){let I=r.trim();t.push([n,I])}else if(o&&r.trim()){let I=r.trim();if(Cr(I))t.push([I,I]);else if(I.startsWith("...")&&I.length>3)t.push(["...",I.slice(3).trim()])}r="",n="",o=!0,u=!1,l=!1,g=0}else r+=R;else r+=R}if(n&&r.trim()){let E=r.trim();t.push([n,E])}else if(o&&r.trim()){let E=r.trim();if(Cr(E))t.push([E,E]);else if(E.startsWith("...")&&E.length>3)t.push(["...",E.slice(3).trim()])}return t}function wh(e){let t=e.trim();if(t.startsWith("get ")&&t.length>4){let r=t.slice(4).trim();if(r)return{kind:"get",name:r}}if(t.startsWith("set ")&&t.length>4){let r=t.slice(4).trim();if(r)return{kind:"set",name:r}}return null}function $h(e,t,r){let n=r.trim();if(n.charCodeAt(0)!==40)return null;let i=Qe(n,0,"(",")");if(i===-1)return null;let s=n.slice(1,i).trim(),a=n.slice(i+1).trimStart();if(!a.startsWith("=>"))return null;let o=a.slice(2).trim();if(e==="get")return`get ${t}(): ${o||"unknown"}`;return`set ${t}(${s})`}function Eh(e){let t=e;if(t.startsWith("async ")||t.startsWith("async\t"))t=t.slice(5).trimStart();if(t.startsWith("*"))t=t.slice(1).trimStart();if(!t.startsWith("("))return!1;let r=0;for(let n=0;n<t.length;n++){let i=t.charCodeAt(n);if(i===40)r++;else if(i===41){if(r--,r===0){let s=t.slice(n+1).trimStart();if(s.startsWith("{"))return!0;if(s.startsWith(":")){let a=Vo(s,1);if(a?.kind==="arrow")return!1;if(a?.kind==="body")return!0}return!1}}}return!1}function vh(e){let t=e.trimEnd();if(!t.endsWith(">"))return null;let r=0,n=-1;for(let s=t.length-1;s>=0;s--){let a=t.charCodeAt(s);if(a===62){if(s>0&&t.charCodeAt(s-1)===61)continue;r++}else if(a===60){if(r--,r===0){n=s;break}}}if(n===-1)return null;let i=t.slice(0,n).trimEnd();if(!i)return null;return{name:i,typeParams:t.slice(n)}}function Do(e,t){let r=t.trimStart(),n=!1,i=!1;if(r.startsWith("async ")||r.startsWith("async\t"))n=!0,r=r.slice(5).trimStart();if(r.startsWith("*"))i=!0,r=r.slice(1).trimStart();let s="";if(r.charCodeAt(0)===60){let g=0,d=-1;for(let w=0;w<r.length;w++)if(r.charCodeAt(w)===60)g++;else if(r.charCodeAt(w)===62&&!(w>0&&r.charCodeAt(w-1)===61)){if(g--,g===0){d=w;break}}if(d!==-1)s=r.slice(0,d+1),r=r.slice(d+1).trimStart()}let a=r.indexOf("("),o=Qe(r,a,"(",")");if(a===-1||o===-1)return"() => unknown";let c=r.slice(a,o+1),f="unknown",u=r.slice(o+1).trimStart();if(u.charCodeAt(0)===58){let g=u.slice(1),d=Vo(g,0);if(d)f=g.slice(0,d.index).trim();else f=g.trim()}if(f==="unknown"){if(n&&i)f="AsyncGenerator<unknown, void, unknown>";else if(i)f="Generator<unknown, void, unknown>";else if(n)f="Promise<void>"}else if(n&&!f.startsWith("Promise<")&&!f.startsWith("AsyncGenerator<"))f=`Promise<${f}>`;let l=rr(c);return`${s}${l} => ${f}`}function Vo(e,t){let r=0,n=0,i=0,s=0,a=!1,o=0;for(let c=t;c<e.length;c++){let f=e.charCodeAt(c);if(a){if(f===92)c++;else if(f===o)a=!1;continue}if(f===34||f===39||f===96){a=!0,o=f;continue}if(f===40)r++;else if(f===41&&r>0)r--;else if(f===91)n++;else if(f===93&&n>0)n--;else if(f===60)i++;else if(f===62&&i>0&&e.charCodeAt(c-1)!==61)i--;else if(f===125&&s>0)s--;else if(f===123){let u=r>0||n>0||i>0||s>0,l=e.slice(t,c).trimEnd(),g=l.charCodeAt(l.length-1),d=l.length===0||g===38||g===124||g===40||g===44||g===58||g===61||g===91;if(u||d)s++;else return{index:c,kind:"body"}}else if(f===61&&c+1<e.length&&e.charCodeAt(c+1)===62&&r===0&&n===0&&i===0&&s===0)return{index:c,kind:"arrow"}}return null}function Qe(e,t,r,n){let i=0;for(let s=t;s<e.length;s++)if(e[s]===r)i++;else if(e[s]===n){if(n===">"&&s>0&&e[s-1]==="=")continue;if(i--,i===0)return s}return-1}function $i(e){let t=0,r=0,n=!1,i="";for(let s=0;s<e.length-1;s++){let a=e[s],o=e[s+1],c=s>0?e[s-1]:"";if(!n&&(a==='"'||a==="'"||a==="`"))n=!0,i=a;else if(n&&a===i&&c!=="\\")n=!1;if(!n){if(a==="<"){let f=Qe(e,s,"<",">");if(f!==-1){s=f;continue}}if(a==="(")t++;else if(a===")")t--;else if(a==="[")r++;else if(a==="]")r--;if(a==="="&&o===">"&&t===0&&r===0)return s}}return-1}function _o(e,t=!1,r=0,n=!0){let i=e.trim();if(i.length>200&&_n(i,"=>")>2&&_n(i,"<")>5&&!i.startsWith("function"))return t?"((...args: any[]) => any)":"(...args: any[]) => any";if(i.startsWith("async ")&&i.includes("=>")){let a=i.slice(5).trim(),o=$i(a);if(o===-1)return t?"(() => Promise<unknown>)":"() => Promise<unknown>";let c=a.substring(0,o).trim(),f=a.substring(o+2).trim(),u=Fo(c),l=u.params,g=u.returnType;if(l=rr(l),l==="()"||l==="")l="()";else if(!l.startsWith("("))l=`(${l})`;let d=g;if(d);else if(f.startsWith("{"))d=yr(f.slice(1,f.endsWith("}")?-1:void 0),!0,l);else d=Ae(f,n,!1,r+1);let w=`${l} => ${g||d.startsWith("Promise<")?d:`Promise<${d}>`}`;return t?`(${w})`:w}if(i.includes("=>")){let a="",o=i;if(i.startsWith("<")){let C=Qe(i,0,"<",">");if(C!==-1)a=i.substring(0,C+1),o=i.substring(C+1).trim()}let c=$i(o);if(c===-1)return t?"(() => unknown)":"() => unknown";let f=o.substring(0,c).trim(),u=o.substring(c+2).trim(),l=Fo(f),g=l.params,d=l.returnType;if(g=rr(g),g==="()"||g==="")g="()";else if(!g.startsWith("("))g=`(${g})`;let w="unknown";if(d)w=d;else if(u.startsWith("{"))w=yr(u.slice(1,u.endsWith("}")?-1:void 0),!1,g);else if(Ci(u)||Lo(u)&&Ci(u.slice(1,-1).trim()))w="JSX.Element";else if(u.includes("=>")){let C=u.trimStart(),A=C.indexOf("("),O=A!==-1?Qe(C,A,"(",")"):-1,R=O!==-1?C.indexOf("=>",O):-1;if(A===0&&O!==-1&&R!==-1){let I=C.substring(A+1,O).trim(),B=rr(I);if(a.includes("T")&&B.includes("T"))w=`(${B}) => T`;else w=`(${B}) => any`}else w="any"}else if(t)w="unknown";else w=Mt(u,No(g));let E=`${a}${g} => ${w}`;return t?`(${E})`:E}if(i.startsWith("function")){let a=8,o=i.length;while(a<o&&i.charCodeAt(a)<=32)a++;let c=!1;if(a<o&&i.charCodeAt(a)===42){c=!0,a++;while(a<o&&i.charCodeAt(a)<=32)a++}let f="";if(a<o&&i.charCodeAt(a)===60){let g=a,d=1;a++;while(a<o&&d>0){let w=i.charCodeAt(a);if(w===60)d++;else if(w===62&&i.charCodeAt(a-1)!==61)d--;a++}f=i.substring(g,a);while(a<o&&i.charCodeAt(a)<=32)a++}let u=i.indexOf("(",a);if(u!==-1){let g=1,d=u+1;while(d<o&&g>0){let A=i.charCodeAt(d);if(A===40)g++;else if(A===41)g--;d++}let w=i.substring(u+1,d-1).trim(),E=w?`(${w})`:"()";if(c){let A=i.substring(d).trim(),O=A.indexOf("Generator<");if(O!==-1){let I=O+10,B=A.indexOf(">",I);if(B!==-1){let L=A.substring(I,B),T=`${f}${E} => Generator<${L}>`;return t?`(${T})`:T}}let R=`${f}${E} => Generator<any, any, any>`;return t?`(${R})`:R}let C=`${f}${E} => unknown`;return t?`(${C})`:C}let l="(...args: any[]) => unknown";return t?`(${l})`:l}if(i.includes("=>")&&i.includes("(")&&i.includes(")")){if(i.length>100||_n(i,"=>")>2){let a="";if(i.charCodeAt(0)===60){let l=Qe(i,0,"<",">");if(l!==-1)a=i.substring(0,l+1)}let o=i.indexOf("("),c=o!==-1?Qe(i,o,"(",")"):-1,f=o!==-1&&c!==-1?i.substring(o,c+1):"(...args: any[])";f=rr(f);let u=`${a}${f} => any`;return t?`(${u})`:u}return t?`(${i})`:i}let s="() => unknown";return t?`(${s})`:s}function Fo(e){let t=e.trim();if(!t.startsWith("("))return{params:t,returnType:""};let r=Qe(t,0,"(",")");if(r===-1)return{params:t,returnType:""};let n=t.slice(r+1).trim();return{params:t.slice(0,r+1),returnType:n.startsWith(":")?n.slice(1).trim():""}}function Ho(e){let t=e.trim();if(t==="any"||t==="object"||t==="unknown")return!0;if(t.startsWith("Record<")&&t.endsWith(">"))return!0;if(t.startsWith("Array<")&&t.endsWith(">"))return!0;if(/^\{\s*\[[^\]]*\]:\s*(any|string|number|unknown)\s*\}$/.test(t))return!0;return!1}function jo(e){let t=e.lastIndexOf(" satisfies ");if(t===-1)return null;let r=e.slice(t+11).trim();if(r.endsWith(";"))r=r.slice(0,-1).trim();return r||null}var Ei=!1,je=null;var Zn=()=>{};function Me(e){return e===Te||e===Re||e===Ce||e===Se}function Dt(e){return e>=65&&e<=90||e>=97&&e<=122||e===bh||e===Uo||e>127}function Ke(e){return Dt(e)||e>=48&&e<=57}function Ah(e){let t=!0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===ct){if(t)return!1;t=!0}else if(t){if(!Dt(n))return!1;t=!1}else if(!Ke(n))return!1}return e.length>0&&!t}function bi(e,t,r){let n=t+1;while(n<e.length){let i=e.charCodeAt(n);if(i===Je){n+=2;continue}if(n++,i===r)break}return n}function xh(e){if(e==="any"||e==="object"||e==="unknown")return!0;if(e.startsWith("Record<")||e.startsWith("Array<"))return!0;return e.charCodeAt(0)===_&&e.includes("[")&&e.includes("]:")}function Yo(e,t,r=!0){return qo(e,t,r,!0)}function Zo(e,t,r=!0){return qo(e,t,r,!1)}function qo(e,t,r,n){let i=e,s=r,a=n,o=i.length,c=[],f=new Map,u=new Set,l=0;if(l<o&&i.charCodeAt(l)===65279)l++;function g(m,h){if(m<h){let p=i.charCodeAt(m),y=i.charCodeAt(h-1);if(p!==Te&&p!==Re&&p!==Ce&&p!==Se&&y!==Te&&y!==Re&&y!==Ce&&y!==Se)return i.slice(m,h)}while(m<h&&Me(i.charCodeAt(m)))m++;while(h>m&&Me(i.charCodeAt(h-1)))h--;return i.slice(m,h)}function d(){if(l>=o)return;let m=i.charCodeAt(l);if(m!==Te&&m!==Re&&m!==Ce&&m!==Se&&m!==Y)return;while(l<o){let h=i.charCodeAt(l);if(h===Te||h===Re||h===Ce||h===Se){l++;continue}if(h===Y&&l+1<o){let p=i.charCodeAt(l+1);if(p===Y){let y=i.indexOf(`
101
- `,l+2);l=y===-1?o:y+1;continue}if(p===ve){let y=i.indexOf("*/",l+2);l=y===-1?o:y+2;continue}}break}}function w(m){let h=m.length,p=0,y=h;for(let $=0;$<h;$++){let v=m.charCodeAt($);if(p){if(v===Je){$++;continue}if(v===p)p=0;continue}if(v===ne||v===ae||v===xe){p=v;continue}if(v===Y&&$+1<h){let x=m.charCodeAt($+1);if(x===Y){y=$;while(y>0&&(m.charCodeAt(y-1)===Te||m.charCodeAt(y-1)===Re))y--;return m.slice(0,y)}if(x===ve){let P=m.indexOf("*/",$+2);if(P!==-1){m=`${m.slice(0,$)} ${m.slice(P+2)}`,$--;continue}}}}y=h;while(y>0&&(m.charCodeAt(y-1)===Te||m.charCodeAt(y-1)===Re||m.charCodeAt(y-1)===Se))y--;return y<h?m.slice(0,y):m}function E(m){l++;let h=m===ne?"'":'"';while(l<o){let p=i.indexOf(h,l);if(p===-1){l=o;return}let y=0,$=p-1;while($>=0&&i.charCodeAt($)===Je)y++,$--;if(y%2===0){l=p+1;return}l=p+1}}function C(){l++;let m=[];while(l<o){let h=i.charCodeAt(l);if(m.length===0){if(h===Je){l+=2;continue}if(h===xe){l++;return}if(h===Uo&&l+1<o&&i.charCodeAt(l+1)===_){l+=2,m.push(0);continue}l++;continue}if(h===ne||h===ae){E(h);continue}if(h===xe){C();continue}if(h===Y&&l+1<o){let p=i.charCodeAt(l+1);if(p===Y){let y=i.indexOf(`
102
- `,l+2);l=y===-1?o:y+1;continue}if(p===ve){let y=i.indexOf("*/",l+2);l=y===-1?o:y+2;continue}if(I()){B();continue}l++;continue}if(h===_){m[m.length-1]++,l++;continue}if(h===J){let p=m[m.length-1];if(p===0){m.pop(),l++;continue}m[m.length-1]=p-1,l++;continue}l++}}function A(){let m=i.charCodeAt(l);if(m===ne||m===ae)return E(m),!0;if(m===xe)return C(),!0;if(m===Y&&l+1<o){let h=i.charCodeAt(l+1);if(h===Y){let p=i.indexOf(`
103
- `,l+2);return l=p===-1?o:p+1,!0}if(h===ve){let p=i.indexOf("*/",l+2);return l=p===-1?o:p+2,!0}if(I())return B(),!0}return!1}function O(m){let h=m;for(;;){while(h>=0&&(i.charCodeAt(h)===Te||i.charCodeAt(h)===Re||i.charCodeAt(h)===Ce||i.charCodeAt(h)===Se))h--;if(h<0)return-1;if(i.charCodeAt(h)===Y&&h>0&&i.charCodeAt(h-1)===ve){let $=i.lastIndexOf("/*",h-2);if($===-1)return-1;h=$-1;continue}let p=i.lastIndexOf(`
104
- `,h)+1,y=R(p,h);if(y!==-1){h=y-1;continue}return h}}function R(m,h){let p=0;for(let y=m;y<=h;y++){let $=i.charCodeAt(y);if(p){if($===Je){y++;continue}if($===p)p=0;continue}if($===ne||$===ae||$===xe){p=$;continue}if($===Y&&y+1<=h&&i.charCodeAt(y+1)===Y)return y}return-1}function I(){let m=O(l-1);if(m<0)return!0;let h=i.charCodeAt(m);if(h===we||h===te||h===he||h===33||h===38||h===124||h===vi||h===et||h===tt||h===Z||h===_||h===J||h===94||h===126||h===43||h===45||h===ve||h===37||h===de||h===ue)return!0;if(Ke(h)){let p=m;while(p>=0&&Ke(i.charCodeAt(p)))p--;let y=i.slice(p+1,m+1);if(y==="return"||y==="typeof"||y==="void"||y==="delete"||y==="throw"||y==="new"||y==="in"||y==="of"||y==="case"||y==="instanceof"||y==="yield"||y==="await")return!0}return!1}function B(){l++;let m=!1;while(l<o){let h=i.charCodeAt(l);if(h===Je){l+=2;continue}if(m){if(h===Ee)m=!1;l++;continue}if(h===he){m=!0,l++;continue}if(h===Y){l++;break}if(h===Ce||h===Se)break;l++}while(l<o&&Ke(i.charCodeAt(l)))l++}function L(){let m=l;while(l<o&&Ke(i.charCodeAt(l)))l++;return i.slice(m,l)}function T(m){if(l+m.length>o)return!1;for(let h=0;h<m.length;h++)if(i.charCodeAt(l+h)!==m.charCodeAt(h))return!1;if(l+m.length<o&&Ke(i.charCodeAt(l+m.length)))return!1;return!0}function D(m){let h=l+m;while(h<o){let p=i.charCodeAt(h);if(p===Te||p===Re||p===Ce||p===Se){h++;continue}return p!==ct&&p!==we}return!1}function H(){if(l>=o)return!1;switch(i.charCodeAt(l)){case 101:return T("export")||T("enum");case 105:return T("import")||T("interface");case 102:return T("function");case 99:return T("class")||T("const");case 116:return T("type");case 108:return T("let");case 118:return T("var");case 100:return T("declare")||T("default");case 109:return T("module");case 110:return T("namespace");case 97:return T("abstract")||T("async");default:return!1}}function U(){let m=i.charCodeAt(l);if(m!==Ce&&m!==Se)return!1;let h=l;if(l++,m===Se&&l<o&&i.charCodeAt(l)===Ce)l++;while(l<o){let y=i.charCodeAt(l);if(y===Te||y===Re||y===Se||y===Ce){l++;continue}if(y===Y&&l+1<o){let $=i.charCodeAt(l+1);if($===Y){let v=i.indexOf(`
105
- `,l+2);l=v===-1?o:v+1;continue}if($===ve){let v=i.indexOf("*/",l+2);l=v===-1?o:v+2;continue}}break}let p=l>=o||H()||i.charCodeAt(l)===J;return l=h,p}function Q(){let m=i.charCodeAt(l);if(m!==Ce&&m!==Se)return!1;let h=l;if(l++,m===Se&&l<o&&i.charCodeAt(l)===Ce)l++;while(l<o){let y=i.charCodeAt(l);if(y===Te||y===Re||y===Se||y===Ce){l++;continue}if(y===Y&&l+1<o&&i.charCodeAt(l+1)===Y){let $=i.indexOf(`
106
- `,l+2);l=$===-1?o:$+1;continue}break}if(l>=o)return l=h,!0;let p=i.charCodeAt(l);if(p===124||p===38||p===ct||p===vi||p===et)return l=h,!1;if(T("extends")||T("keyof")||T("typeof")||T("infer")||T("is")||T("as")||T("in"))return l=h,!1;return l=h,!0}let K=/[{}'"`\/]/g,q=/[()'"`\/]/g,me=/[[\]'"`\/]/g,z=/[<>'"`\/]/g;function X(m,h){let p=1;l++;let y=m===_?K:m===te?q:m===he?me:z;y.lastIndex=l;let $;while(($=y.exec(i))!==null){let v=$.index,x=i.charCodeAt(v);if(x===ne||x===ae){l=v,E(x),y.lastIndex=l;continue}if(x===xe){l=v,C(),y.lastIndex=l;continue}if(x===Y){if(l=v,A()){y.lastIndex=l;continue}y.lastIndex=v+1;continue}if(x===m)p++;else if(x===h){if(h===ue&&v>0&&i.charCodeAt(v-1)===we){y.lastIndex=v+1;continue}if(p--,p===0)return l=v+1,l}y.lastIndex=v+1}return l=o,l}function ee(){return l>0&&i.charCodeAt(l-1)===we}function vt(){return l+1<o&&i.charCodeAt(l+1)===ue}let De=/[<{};'"`\/\n\r()[\]]/g;function se(){let m=0,h=0,p=0,y=0,$=i.charCodeAt(l)===_;De.lastIndex=l;let v;while((v=De.exec(i))!==null){let x=v.index,P=i.charCodeAt(x);if(P===ne||P===ae){l=x,E(P),De.lastIndex=l;continue}if(P===xe){l=x,C(),De.lastIndex=l;continue}if(P===Y){if(x>0&&i.charCodeAt(x-1)===de){De.lastIndex=x+1;continue}if(l=x,A()){De.lastIndex=l;continue}De.lastIndex=x+1;continue}if(P===de){let b=Ss(x);if(b!==null)y=Math.max(0,y+b);De.lastIndex=x+1;continue}if(P===te){h++,De.lastIndex=x+1;continue}if(P===ye){h--,De.lastIndex=x+1;continue}if(P===he){p++,De.lastIndex=x+1;continue}if(P===Ee){p--,De.lastIndex=x+1;continue}if(P===_){m++,De.lastIndex=x+1;continue}if(P===J){let b=m>0;if(b)m--;if((!b||$)&&m===0&&h===0&&p===0&&y===0){l=x+1;return}De.lastIndex=x+1;continue}if(P===Z&&m===0&&h===0&&p===0&&y===0){l=x+1;return}if((P===Ce||P===Se)&&m===0&&h===0&&p===0&&y===0){if(l=x,U())return}De.lastIndex=x+1}l=o}function Pt(){l++;while(l<o&&(i.charCodeAt(l)===Te||i.charCodeAt(l)===Re))l++;let m=i.indexOf(`
107
- `,l),h=m===-1?o:m,p=i.indexOf(";",l);if(p!==-1&&p<h){let y=p-1;while(y>=l&&(i.charCodeAt(y)===Te||i.charCodeAt(y)===Re))y--;let $=i.charCodeAt(l),v=i.charCodeAt(y);if($===_&&v===J||$===he&&v===Ee||$===ne&&v===ne||$===ae&&v===ae||$===xe&&v===xe){l=p+1;return}}se()}function Be(){X(_,J);while(l<o&&Me(i.charCodeAt(l)))l++;if(T("from")){l+=4;while(l<o&&Me(i.charCodeAt(l)))l++;if(l<o){let m=i.charCodeAt(l);if(m===ne||m===ae)E(m)}}while(l<o&&(i.charCodeAt(l)===Te||i.charCodeAt(l)===Re))l++;if(l<o&&i.charCodeAt(l)===Z)l++}function ot(){l++;while(l<o&&Me(i.charCodeAt(l)))l++;if(T("as")){l+=2;while(l<o&&Me(i.charCodeAt(l)))l++;L();while(l<o&&Me(i.charCodeAt(l)))l++}if(T("from")){l+=4;while(l<o&&Me(i.charCodeAt(l)))l++;if(l<o){let m=i.charCodeAt(l);if(m===ne||m===ae)E(m)}}while(l<o&&(i.charCodeAt(l)===Te||i.charCodeAt(l)===Re))l++;if(l<o&&i.charCodeAt(l)===Z)l++}function ut(m){let h=m.indexOf("from ");if(h===-1)return;let p=h+5;while(p<m.length&&(m.charCodeAt(p)===32||m.charCodeAt(p)===9))p++;if(p>=m.length)return;let y=m.charCodeAt(p);if(y!==39&&y!==34)return;let $=m.indexOf(m[p],p+1);if($===-1)return;return m.slice(p+1,$)}function Ve(m){if(!s)return;let h=m-1;while(h>=0&&Me(i.charCodeAt(h)))h--;if(h<0)return;let p=[],y=!1;while(h>=0){if(h>=1&&i.charCodeAt(h)===Y&&i.charCodeAt(h-1)===ve){let x=i.lastIndexOf("/*",h-2);if(x>=0){p.push(i.slice(x,h+1)),y=!0,h=x-1;while(h>=0&&Me(i.charCodeAt(h)))h--;continue}break}let $=h;while($>0&&i.charCodeAt($-1)!==Ce)$--;let v=g($,h+1);if(v.startsWith("//")){if(y)break;let x=[v];h=$-1;while(h>=0&&(i.charCodeAt(h)===Ce||i.charCodeAt(h)===Se))h--;while(h>=0){let P=h;while(P>0&&i.charCodeAt(P-1)!==Ce)P--;let b=g(P,h+1);if(b.startsWith("//")){x.push(b),h=P-1;while(h>=0&&(i.charCodeAt(h)===Ce||i.charCodeAt(h)===Se))h--}else if(b===""){h=P-1;while(h>=0&&(i.charCodeAt(h)===Ce||i.charCodeAt(h)===Se))h--}else break}x.reverse(),p.push(x.join(`
108
- `));continue}break}if(p.length===0)return;return p.reverse(),p}function rc(m){let h=m,p=!1;while(l<o){let b=i.charCodeAt(l);if(b===Z){l++;break}if(b===ne||b===ae){E(b),p=!0;while(l<o&&(i.charCodeAt(l)===Te||i.charCodeAt(l)===Re))l++;if(l<o&&i.charCodeAt(l)===Z)l++;break}if(b===Ce&&p)break;l++}let y=g(h,l),$=y.charCodeAt(7)===116&&(y.startsWith("import type ")||y.startsWith("import type{")),v=!1;{let b=6;while(b<y.length&&(y.charCodeAt(b)===Te||y.charCodeAt(b)===Re))b++;if(b<y.length&&y.charCodeAt(b)===116&&y.startsWith("type",b)){b+=4;while(b<y.length&&(y.charCodeAt(b)===Te||y.charCodeAt(b)===Re))b++}if(b<y.length){let S=y.charCodeAt(b);v=S===ne||S===ae}}let x="";{let b=y.indexOf("from ");if(b!==-1){let S=b+5;while(S<y.length&&(y.charCodeAt(S)===Te||y.charCodeAt(S)===Re))S++;if(S<y.length){let k=y.charCodeAt(S);if(k===ne||k===ae){let N=y.indexOf(String.fromCharCode(k),S+1);if(N!==-1)x=y.slice(S+1,N)}}}else if(v){let S=6;while(S<y.length&&y.charCodeAt(S)!==ne&&y.charCodeAt(S)!==ae)S++;if(S<y.length){let k=y.charCodeAt(S),N=y.indexOf(String.fromCharCode(k),S+1);if(N!==-1)x=y.slice(S+1,N)}}}let P=Ve(h);return{kind:"import",name:"",text:y,isExported:!1,isTypeOnly:$,isSideEffect:v,source:x,leadingComments:P,start:h,end:l}}function Wi(){let m=l;return X(_,J),i.slice(m,l)}function ws(m){let h=m.indexOf("(");if(h===-1)return m;let p=m.slice(h);if(p.indexOf("=")===-1)return m;let y=!1;for(let b=0;b<p.length;b++)if(p.charCodeAt(b)===61){let S=b>0?p.charCodeAt(b-1):0,k=b+1<p.length?p.charCodeAt(b+1):0;if(S!==61&&S!==33&&S!==60&&S!==62&&k!==61&&k!==62){y=!0;break}}if(!y)return m;let $=0,v=-1;for(let b=h;b<m.length;b++){let S=m.charCodeAt(b);if(S===40)$++;else if(S===41){if($--,$===0){v=b;break}}}if(v===-1)return m;let x=m.slice(h,v+1),P=Nt(x);return m.slice(0,h)+P+m.slice(v+1)}function $s(m){let h=m.indexOf("//")!==-1||m.indexOf("/*")!==-1,p=m.split(`
109
- `),y=[],$=[],v=[],x=!1,P=1/0;for(let k=0;k<p.length;k++){let N=p[k];if(h){if(x){if(N.includes("*/"))x=!1;continue}let G=N.trim();if(G.length===0)continue;let W=G.charCodeAt(0);if(W===Y){let be=G.charCodeAt(1);if(be===Y)continue;if(be===ve){if(!G.includes("*/"))x=!0;continue}}if(W===ve)continue;let M=w(N);if(M.charCodeAt(M.length-1)===Z)M=M.slice(0,-1);M=ws(M);let F=M.trim();if(!F)continue;y.push(M),$.push(F);let V=0;while(V<M.length&&Me(M.charCodeAt(V)))V++;if(F!=="{"&&F!=="}"){if(V<P)P=V}v.push(V)}else{let G=N.length;while(G>0&&(N.charCodeAt(G-1)===Te||N.charCodeAt(G-1)===Re||N.charCodeAt(G-1)===Se))G--;if(G===0)continue;let W=G<N.length?N.slice(0,G):N;if(W.charCodeAt(W.length-1)===Z)W=W.slice(0,-1);W=ws(W);let M=W.trim();if(!M)continue;y.push(W),$.push(M);let F=0;while(F<W.length&&Me(W.charCodeAt(F)))F++;if(M!=="{"&&M!=="}"){if(F<P)P=F}v.push(F)}}if(y.length===0)return"{}";if(P===1/0||P<=2)return y.join(`
110
- `);let b=P-2,S=Array(y.length);for(let k=0;k<y.length;k++){let N=$[k];if(N==="{"){S[k]=N;continue}let G=v[k];if(G>P)S[k]=y[k];else if(G===P&&(N.charCodeAt(0)===J||N.charCodeAt(0)===Ee||N.charCodeAt(0)===ye))S[k]=y[k];else{let W=Math.max(0,G-b);S[k]=" ".repeat(W)+N}}return S.join(`
111
- `)}function lt(){if(l>=o||i.charCodeAt(l)!==de)return"";let m=l;X(de,ue);let h=i.slice(m,l);if(h.includes(`
112
- `)){let p="",y=!1;for(let $=0;$<h.length;$++){let v=h.charCodeAt($);if(v===32||v===9||v===10||v===13){if(!y&&p.length>0)p+=" ",y=!0}else p+=h[$],y=!1}if(p.charCodeAt(1)===32)p=`<${p.slice(2)}`;if(p.charCodeAt(p.length-2)===32)p=`${p.slice(0,-2)}>`;return p}return h}function St(){if(l>=o||i.charCodeAt(l)!==te)return"()";let m=l;return X(te,ye),i.slice(m,l)}function Nt(m){let h=m.slice(1,-1).trim();if(!h)return"()";if(m.indexOf(`
113
- `)===-1&&h.indexOf(":")!==-1&&h.indexOf("{")===-1&&h.indexOf("[")===-1&&h.indexOf("=")===-1&&h.indexOf("@")===-1&&h.indexOf("...")===-1){let b=0,S=0,k=0;for(let N=0;N<h.length;N++){let G=h.charCodeAt(N);if(G===te||G===de||G===_)k++;else if(G===ye||G===ue||G===J)k--;else if(k===0){if(G===et)b++;else if(G===tt)S++}}if(b>=S+1){let N=!1;for(let G=0;G<qn.length;G++){let W=qn[G],M=h.indexOf(W);if(M!==-1){let F=M+W.length;if((M===0||!Ke(h.charCodeAt(M-1)))&&(F>=h.length||!Ke(h.charCodeAt(F)))){N=!0;break}}}if(!N)return m}}let p=[],y=0,$=0,v=!1,x=0;for(let b=0;b<=h.length;b++){if(b===h.length){p.push(h.slice(y).trim());break}let S=h.charCodeAt(b);if(v){if(S===Je){b++;continue}if(S===x)v=!1;continue}if(S===Y&&b+1<h.length){let k=h.charCodeAt(b+1);if(k===ve){b+=2;while(b+1<h.length&&!(h.charCodeAt(b)===ve&&h.charCodeAt(b+1)===Y))b++;b++;continue}if(k===Y){while(b<h.length&&h.charCodeAt(b)!==10)b++;continue}}if(S===ne||S===ae||S===xe){v=!0,x=S;continue}if(S===te||S===_||S===he||S===de)$++;else if(S===ye||S===J||S===Ee||S===ue&&!(b>0&&h.charCodeAt(b-1)===we))$--;else if(S===tt&&$===0)p.push(h.slice(y,b).trim()),y=b+1}let P=[];for(let b of p){if(!b)continue;let S=b.trim();if(S.startsWith("//")||S.startsWith("/*"))continue;let k=b;{let N=!1,G=0,W=0,M=0;for(let F=0;F<k.length-1;F++){let V=k.charCodeAt(F);if(V===Ce){M=F+1;continue}if(N){if(V===Je){F++;continue}if(V===G)N=!1;continue}if(V===ne||V===ae||V===xe){N=!0,G=V;continue}if(V===_||V===he||V===te||V===de){W++;continue}if(V===J||V===Ee||V===ye||V===ue){if(W>0)W--;continue}if(V===Y&&k.charCodeAt(F+1)===Y){if(W===0){k=k.slice(0,F).trimEnd();break}let be=k.indexOf(`
114
- `,F);if(be===-1){k=k.slice(0,M).trimEnd();break}let xt=k.slice(0,M),fc=k.slice(be+1);k=`${xt}${fc}`,F=M-1}}}if(!k.trim())continue;P.push(Es(k))}return`(${P.join(", ")})`}function ic(m){if(!m.startsWith("{")&&!m.startsWith("["))return m;let h="",p=0,y=0,$=!1,v=0;while(p<m.length){let x=m.charCodeAt(p);if($){if(x===Je&&p+1<m.length){h+=m[p]+m[p+1],p+=2;continue}if(x===v)$=!1;h+=m[p],p++;continue}if(x===Y&&p+1<m.length){let P=m.charCodeAt(p+1);if(P===ve){let b=p;p+=2;while(p+1<m.length&&!(m.charCodeAt(p)===ve&&m.charCodeAt(p+1)===Y))p++;p=Math.min(p+2,m.length),h+=m.slice(b,p);continue}if(P===Y){let b=p;while(p<m.length&&m.charCodeAt(p)!==10)p++;h+=m.slice(b,p);continue}}if(x===ne||x===ae||x===xe){$=!0,v=x,h+=m[p],p++;continue}if(x===_||x===he||x===te)y++;else if(x===J||x===Ee||x===ye)y--;if(y>=1&&x===we&&(p+1>=m.length||m.charCodeAt(p+1)!==we&&m.charCodeAt(p+1)!==ue)){while(h.length>0&&(h[h.length-1]===" "||h[h.length-1]==="\t"||h[h.length-1]===`
115
- `))h=h.slice(0,-1);p++;let P=0;while(p<m.length){let b=m.charCodeAt(p);if(b===ne||b===ae||b===xe){let S=b;p++;while(p<m.length){if(m.charCodeAt(p)===Je){p+=2;continue}if(m.charCodeAt(p)===S){p++;break}p++}continue}if(b===_||b===he||b===te)P++;else if(b===J||b===Ee||b===ye){if(P===0)break;P--}else if(b===tt&&P===0)break;p++}continue}if(y===1&&x===ct&&p+2<m.length&&m.charCodeAt(p+1)===ct&&m.charCodeAt(p+2)===ct){p+=3;continue}h+=m[p],p++}return h}function Es(m){let h=m.trim(),p=h.startsWith("...");if(p)h=h.slice(3).trim();while(h.startsWith("@")){let M=1;while(M<h.length&&Ke(h.charCodeAt(M)))M++;if(M<h.length&&h.charCodeAt(M)===te){let F=1;M++;while(M<h.length&&F>0){if(h.charCodeAt(M)===te)F++;else if(h.charCodeAt(M)===ye)F--;M++}}h=h.slice(M).trim()}let y=!0;while(y){y=!1;for(let M of qn)if(h.startsWith(M)&&h.length>M.length&&!Ke(h.charCodeAt(M.length))){let F=h.slice(M.length).trim();if(F.charCodeAt(0)===et||F.charCodeAt(0)===vi&&F.length>1&&F.charCodeAt(1)===et)break;h=F,y=!0;break}}let $=-1,v=-1,x=0,P=!1,b=0;for(let M=0;M<h.length;M++){let F=h.charCodeAt(M);if(P){if(F===Je){M++;continue}if(F===b)P=!1;continue}if(F===Y&&M+1<h.length){let V=h.charCodeAt(M+1);if(V===ve){M+=2;while(M+1<h.length&&!(h.charCodeAt(M)===ve&&h.charCodeAt(M+1)===Y))M++;M++;continue}if(V===Y){while(M<h.length&&h.charCodeAt(M)!==10)M++;continue}}if(F===ne||F===ae||F===xe){P=!0,b=F;continue}if(F===te||F===_||F===he||F===de)x++;else if(F===ye||F===J||F===Ee||F===ue&&!(M>0&&h.charCodeAt(M-1)===we))x--;else if(x===0){if(F===et&&$===-1)$=M;else if(F===we&&v===-1&&(M===0||h.charCodeAt(M-1)!==we)&&(M+1>=h.length||h.charCodeAt(M+1)!==we&&h.charCodeAt(M+1)!==ue))v=M}}let S,k,N=v!==-1;if($!==-1&&(v===-1||$<v))if(S=h.slice(0,$).trim(),v!==-1)k=h.slice($+1,v).trim();else k=h.slice($+1).trim();else if(v!==-1)S=h.slice(0,v).trim(),k=Gi(h.slice(v+1).trim());else S=h,k="unknown";if(S=ic(S),(S.startsWith("{")||S.startsWith("["))&&S.includes(`
116
- `)){let M=S.replace(/\s*\n\s*/g," ").replace(/\s+/g," ");if(M.length<=40)S=M;else S=S.split(`
96
+ }`:"{}";if(a.length===0)return f;let u=a[0];for(let l=1;l<a.length;l++)u=`Omit<${u}, keyof ${a[l]}> & ${a[l]}`;return s.length>0?`Omit<${u}, keyof ${f}> & ${f}`:u}function wr(e){if(!e)return!1;let t=e.charCodeAt(0);if(!(t>=65&&t<=90||t>=97&&t<=122||t===95||t===36||t>127))return!1;for(let r=1;r<e.length;r++)if(!$t(e.charCodeAt(r)))return!1;return!0}function $r(e){let t=e.split(".");return t.length>0&&t.every(wr)}function gh(e){let t=!1,r="";for(let n=0;n<e.length;n++){let i=e[n];if(t){if(i==="\\")n++;else if(i===r)t=!1;continue}if(i==='"'||i==="'"||i==="`"){t=!0,r=i;continue}if(i==="(")return n;if(i==="<"){let s=et(e,n,"<",">");if(s!==-1)n=s}}return-1}function _o(e){if(e.length<3||!e.endsWith(")"))return null;let t=gh(e);if(t===-1||et(e,t,"(",")")!==e.length-1)return null;let r=e.slice(0,t).trim(),n=!1;if(r.endsWith("?."))n=!0,r=r.slice(0,-2).trim();let i=r,s=!1,a=r.indexOf("<");if(a!==-1){if(et(r,a,"<",">")!==r.length-1)return null;i=r.slice(0,a).trim(),s=!0}if(!$r(i))return null;let o=e.slice(t+1,-1).trim(),c=vi(o)!==-1||o.startsWith("function")||o.startsWith("async function"),f=$r(o),u=!c&&o.endsWith(")")&&_o(o)!==null;if(!s&&!n&&!c&&!f&&!u)return null;let l=`ReturnType<typeof ${r}>`;return n?`${l} | undefined`:l}function yh(e){let t=e.split(`
97
+ `).map((f)=>Ho(f)).join(`
98
+ `),r=t.indexOf("async");if(r!==-1){let f=r>0?t.charCodeAt(r-1):32,u=r+5<t.length?t.charCodeAt(r+5):32;if(!$t(f)&&!$t(u))t=(t.slice(0,r)+t.slice(r+5)).trim()}let n=t.indexOf("(");if(n!==-1){let f=et(t,n,"(",")");if(f!==-1){let u=t.slice(n,f+1),l=rr(u);t=t.slice(0,n)+l+t.slice(f+1)}}let i=t.length,s="",a=[],o=!1,c=!1;for(let f=0;f<i;f++){let u=t.charCodeAt(f);if(u===123||u===40)a.push(u);else if(u===125||u===41)a.pop();if(u<=32){if(o=!0,u===10||u===13)c=!0;continue}if(o&&s.length>0){let l=(a.length>0?a[a.length-1]:0)===123;if(c&&l){let g=s.charCodeAt(s.length-1),d=g===59||g===44||g===123||u===125,$=s.length>=2&&s.charCodeAt(s.length-1)===47&&s.charCodeAt(s.length-2)===42;if(!d&&!$)s+="; ";else s+=" "}else s+=" "}o=!1,c=!1,s+=t[f]}return s.trim()}function $t(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95||e===36}function rr(e){let t=e.trim(),r,n=!1;if(t.startsWith("(")&&t.endsWith(")"))r=t.slice(1,-1),n=!0;else r=t;let i=r.trim();if(!i)return n?"()":"";let s=!1;{let $=0;for(let v=0;v<i.length;v++){let C=i.charCodeAt(v);if(C===40||C===60||C===91||C===123)$++;else if(C===41||C===62||C===93||C===125)$--;else if($===0&&C===61){let x=v>0?i.charCodeAt(v-1):0,P=v+1<i.length?i.charCodeAt(v+1):0;if(x!==61&&x!==33&&x!==60&&x!==62&&P!==61&&P!==62){s=!0;break}}}}if(!s)return t;let a=[],o=[],c=0,f=0,u=!1,l=0;for(let $=0;$<=i.length;$++){if($===i.length){a.push(i.slice(c));break}let v=i.charCodeAt($);if(u){if(v===92){$++;continue}if(v===l)u=!1;continue}if(v===47&&$+1<i.length){let C=i.charCodeAt($+1);if(C===42){$+=2;while($+1<i.length&&!(i.charCodeAt($)===42&&i.charCodeAt($+1)===47))$++;$++;continue}if(C===47){while($<i.length&&i.charCodeAt($)!==10)$++;continue}}if(v===39||v===34||v===96){u=!0,l=v;continue}if(v===40||v===60||v===91||v===123)f++;else if(v===41||v===62||v===93||v===125)f--;else if(v===44&&f===0){a.push(i.slice(c,$));let C=",",x=$+1;while(x<i.length&&i.charCodeAt(x)<=32)C+=i[x],x++;o.push(C),c=x}}let g=[];for(let $ of a){let v=$.trim();if(!v){g.push($);continue}if(v.startsWith("//"))continue;let C=Ho(v),x=$.slice(0,$.length-$.trimStart().length);g.push(x+Ch(C))}let d=g[0]||"";for(let $=1;$<g.length;$++)d+=(o[$-1]||", ")+g[$];return n?`(${d})`:d}function Ho(e){let t=!1,r=0;for(let n=0;n<e.length-1;n++){let i=e.charCodeAt(n);if(t){if(i===92){n++;continue}if(i===r)t=!1;continue}if(i===39||i===34||i===96){t=!0,r=i;continue}if(i===47&&e.charCodeAt(n+1)===47)return e.slice(0,n).trimEnd()}return e}function Ch(e){if(e.startsWith("..."))return e;let t=-1,r=-1,n=0,i=!1,s=0;for(let o=0;o<e.length;o++){let c=e.charCodeAt(o);if(i){if(c===92){o++;continue}if(c===s)i=!1;continue}if(c===47&&o+1<e.length){let f=e.charCodeAt(o+1);if(f===42){o+=2;while(o+1<e.length&&!(e.charCodeAt(o)===42&&e.charCodeAt(o+1)===47))o++;o++;continue}if(f===47){while(o<e.length&&e.charCodeAt(o)!==10)o++;continue}}if(c===39||c===34||c===96){i=!0,s=c;continue}if(c===40||c===60||c===91||c===123)n++;else if(c===41||c===62||c===93||c===125)n--;else if(n===0){if(c===58&&t===-1)t=o;else if(c===61&&r===-1&&(o===0||e.charCodeAt(o-1)!==61)&&(o+1>=e.length||e.charCodeAt(o+1)!==61&&e.charCodeAt(o+1)!==62))r=o}}let a=r!==-1;if(t!==-1&&(r===-1||t<r)){let o=e.slice(0,t).trim(),c=r!==-1?e.slice(t+1,r).trim():e.slice(t+1).trim(),f=a&&!o.endsWith("?")?"?":"";return`${o}${f}: ${c}`}else if(r!==-1){let o=e.slice(0,r).trim(),c=!o.endsWith("?")?"?":"",f=e.slice(r+1).trim(),u="unknown";if(f==="true"||f==="false")u="boolean";else if(/^-?\d+(\.\d+)?$/.test(f))u="number";else if(f.startsWith("'")&&f.endsWith("'")||f.startsWith('"')&&f.endsWith('"'))u="string";else if(f.startsWith("["))u="unknown[]";else if(f.startsWith("{"))u="Record<string, unknown>";return`${o}${c}: ${u}`}return e}function wh(e){let t=0,r=e.length;while(t<r){while(t<r&&(e.charCodeAt(t)===32||e.charCodeAt(t)===9||e.charCodeAt(t)===10||e.charCodeAt(t)===13))t++;if(t+1<r&&e.charCodeAt(t)===47&&e.charCodeAt(t+1)===42){t+=2;while(t+1<r&&!(e.charCodeAt(t)===42&&e.charCodeAt(t+1)===47))t++;t+=2;continue}break}return t}function $h(e){let t=[],r=0,n=e.length;while(r<n){while(r<n&&e.charCodeAt(r)<=32)r++;if(r+1>=n||e.charCodeAt(r)!==47||e.charCodeAt(r+1)!==42)break;let i=r;r+=2;while(r+1<n&&!(e.charCodeAt(r)===42&&e.charCodeAt(r+1)===47))r++;r=Math.min(r+2,n),t.push(e.slice(i,r).trim())}return{comments:t.join(`
99
+ `),key:e.slice(r).trim()}}function Eh(e){let t=[],r="",n="",i=0,s=!1,a="",o=!0,c=!1,f=0,u=!1,l=!1,g=0,d=!1,$=!1;for(let v=0;v<e.length;v++){let C=e.charCodeAt(v),x=v>0?e.charCodeAt(v-1):0,P=v<e.length-1?e.charCodeAt(v+1):0;if(!s&&!c&&C===47&&P===47){v+=2;while(v<e.length&&e.charCodeAt(v)!==10)v++;continue}if(!s&&!c&&C===47&&P===42){c=!0,f=1,r+="/*",v++;continue}else if(c&&C===42&&P===47){if(f--,r+="*/",v++,f===0)c=!1;continue}else if(c&&C===47&&P===42){f++,r+="/*",v++;continue}let R=e[v];if(!s&&(C===34||C===39||C===96))s=!0,a=R,r+=R;else if(s&&R===a&&x!==92)s=!1,r+=R;else if(!s&&!c)if(C===40&&i===0&&o&&g===0){n=r.trim();let I=wh(n),B=I>0?n.slice(0,I):"",W=n.slice(I),T="";if(W.startsWith("async ")||W.startsWith("async\t")||W.startsWith(`async
100
+ `))W=W.slice(6).trimStart(),T="async ";if(W.startsWith("*"))W=W.slice(1).trimStart(),T+="*";n=B+W,r=T+R,o=!1,d=!0,$=!1,i=1}else if(C===123||C===91||C===40){if(i++,r+=R,$&&C===123)$=!1}else if(C===125||C===93||C===41){if(i--,r+=R,C===41&&i===0&&!o&&!d)u=!0;if(d){if(C===41&&i===0&&!$)$=!0;else if(C===125&&i===0)d=!1,$=!1}}else if(C===58&&i===0&&o&&g===0)n=r.trim(),r="",o=!1;else if(C===58&&i===0&&u)l=!0,r+=R;else if(C===60&&l)g++,r+=R;else if(C===60&&o&&i===0)g++,r+=R;else if(C===62&&g>0&&x!==61)g--,r+=R;else if(C===61&&P===62&&l&&g===0)l=!1,u=!1,r+=R;else if(C===44&&i===0&&g===0&&!$){if(n&&r.trim()){let I=r.trim();t.push([n,I])}else if(o&&r.trim()){let I=r.trim();if(wr(I))t.push([I,I]);else if(I.startsWith("...")&&I.length>3)t.push(["...",I.slice(3).trim()])}r="",n="",o=!0,u=!1,l=!1,g=0}else r+=R;else r+=R}if(n&&r.trim()){let v=r.trim();t.push([n,v])}else if(o&&r.trim()){let v=r.trim();if(wr(v))t.push([v,v]);else if(v.startsWith("...")&&v.length>3)t.push(["...",v.slice(3).trim()])}return t}function vh(e){let t=e.trim();if(t.startsWith("get ")&&t.length>4){let r=t.slice(4).trim();if(r)return{kind:"get",name:r}}if(t.startsWith("set ")&&t.length>4){let r=t.slice(4).trim();if(r)return{kind:"set",name:r}}return null}function Sh(e,t,r){let n=r.trim();if(n.charCodeAt(0)!==40)return null;let i=et(n,0,"(",")");if(i===-1)return null;let s=n.slice(1,i).trim(),a=n.slice(i+1).trimStart();if(!a.startsWith("=>"))return null;let o=a.slice(2).trim();if(e==="get")return`get ${t}(): ${o||"unknown"}`;return`set ${t}(${s})`}function bh(e){let t=e;if(t.startsWith("async ")||t.startsWith("async\t"))t=t.slice(5).trimStart();if(t.startsWith("*"))t=t.slice(1).trimStart();if(!t.startsWith("("))return!1;let r=0;for(let n=0;n<t.length;n++){let i=t.charCodeAt(n);if(i===40)r++;else if(i===41){if(r--,r===0){let s=t.slice(n+1).trimStart();if(s.startsWith("{"))return!0;if(s.startsWith(":")){let a=jo(s,1);if(a?.kind==="arrow")return!1;if(a?.kind==="body")return!0}return!1}}}return!1}function Ah(e){let t=e.trimEnd();if(!t.endsWith(">"))return null;let r=0,n=-1;for(let s=t.length-1;s>=0;s--){let a=t.charCodeAt(s);if(a===62){if(s>0&&t.charCodeAt(s-1)===61)continue;r++}else if(a===60){if(r--,r===0){n=s;break}}}if(n===-1)return null;let i=t.slice(0,n).trimEnd();if(!i)return null;return{name:i,typeParams:t.slice(n)}}function Wo(e,t){let r=t.trimStart(),n=!1,i=!1;if(r.startsWith("async ")||r.startsWith("async\t"))n=!0,r=r.slice(5).trimStart();if(r.startsWith("*"))i=!0,r=r.slice(1).trimStart();let s="";if(r.charCodeAt(0)===60){let g=0,d=-1;for(let $=0;$<r.length;$++)if(r.charCodeAt($)===60)g++;else if(r.charCodeAt($)===62&&!($>0&&r.charCodeAt($-1)===61)){if(g--,g===0){d=$;break}}if(d!==-1)s=r.slice(0,d+1),r=r.slice(d+1).trimStart()}let a=r.indexOf("("),o=et(r,a,"(",")");if(a===-1||o===-1)return"() => unknown";let c=r.slice(a,o+1),f="unknown",u=r.slice(o+1).trimStart();if(u.charCodeAt(0)===58){let g=u.slice(1),d=jo(g,0);if(d)f=g.slice(0,d.index).trim();else f=g.trim()}if(f==="unknown"){if(n&&i)f="AsyncGenerator<unknown, void, unknown>";else if(i)f="Generator<unknown, void, unknown>";else if(n)f="Promise<void>"}else if(n&&!f.startsWith("Promise<")&&!f.startsWith("AsyncGenerator<"))f=`Promise<${f}>`;let l=rr(c);return`${s}${l} => ${f}`}function jo(e,t){let r=0,n=0,i=0,s=0,a=!1,o=0;for(let c=t;c<e.length;c++){let f=e.charCodeAt(c);if(a){if(f===92)c++;else if(f===o)a=!1;continue}if(f===34||f===39||f===96){a=!0,o=f;continue}if(f===40)r++;else if(f===41&&r>0)r--;else if(f===91)n++;else if(f===93&&n>0)n--;else if(f===60)i++;else if(f===62&&i>0&&e.charCodeAt(c-1)!==61)i--;else if(f===125&&s>0)s--;else if(f===123){let u=r>0||n>0||i>0||s>0,l=e.slice(t,c).trimEnd(),g=l.charCodeAt(l.length-1),d=l.length===0||g===38||g===124||g===40||g===44||g===58||g===61||g===91;if(u||d)s++;else return{index:c,kind:"body"}}else if(f===61&&c+1<e.length&&e.charCodeAt(c+1)===62&&r===0&&n===0&&i===0&&s===0)return{index:c,kind:"arrow"}}return null}function et(e,t,r,n){let i=0;for(let s=t;s<e.length;s++)if(e[s]===r)i++;else if(e[s]===n){if(n===">"&&s>0&&e[s-1]==="=")continue;if(i--,i===0)return s}return-1}function vi(e){let t=0,r=0,n=!1,i="";for(let s=0;s<e.length-1;s++){let a=e[s],o=e[s+1],c=s>0?e[s-1]:"";if(!n&&(a==='"'||a==="'"||a==="`"))n=!0,i=a;else if(n&&a===i&&c!=="\\")n=!1;if(!n){if(a==="<"){let f=et(e,s,"<",">");if(f!==-1){s=f;continue}}if(a==="(")t++;else if(a===")")t--;else if(a==="[")r++;else if(a==="]")r--;if(a==="="&&o===">"&&t===0&&r===0)return s}}return-1}function Ko(e,t=!1,r=0,n=!0){let i=e.trim();if(i.length>200&&jn(i,"=>")>2&&jn(i,"<")>5&&!i.startsWith("function"))return t?"((...args: any[]) => any)":"(...args: any[]) => any";if(i.startsWith("async ")&&i.includes("=>")){let a=i.slice(5).trim(),o=vi(a);if(o===-1)return t?"(() => Promise<unknown>)":"() => Promise<unknown>";let c=a.substring(0,o).trim(),f=a.substring(o+2).trim(),u=Lo(c),l=u.params,g=u.returnType;if(l=rr(l),l==="()"||l==="")l="()";else if(!l.startsWith("("))l=`(${l})`;let d=g;if(d);else if(f.startsWith("{"))d=Cr(f.slice(1,f.endsWith("}")?-1:void 0),!0,l);else d=xe(f,n,!1,r+1);let $=`${l} => ${g||d.startsWith("Promise<")?d:`Promise<${d}>`}`;return t?`(${$})`:$}if(i.includes("=>")){let a="",o=i;if(i.startsWith("<")){let C=et(i,0,"<",">");if(C!==-1)a=i.substring(0,C+1),o=i.substring(C+1).trim()}let c=vi(o);if(c===-1)return t?"(() => unknown)":"() => unknown";let f=o.substring(0,c).trim(),u=o.substring(c+2).trim(),l=Lo(f),g=l.params,d=l.returnType;if(g=rr(g),g==="()"||g==="")g="()";else if(!g.startsWith("("))g=`(${g})`;let $="unknown";if(d)$=d;else if(u.startsWith("{"))$=Cr(u.slice(1,u.endsWith("}")?-1:void 0),!1,g);else if($i(u)||Bo(u)&&$i(u.slice(1,-1).trim()))$="JSX.Element";else if(u.includes("=>")){let C=u.trimStart(),x=C.indexOf("("),P=x!==-1?et(C,x,"(",")"):-1,R=P!==-1?C.indexOf("=>",P):-1;if(x===0&&P!==-1&&R!==-1){let I=C.substring(x+1,P).trim(),B=rr(I);if(a.includes("T")&&B.includes("T"))$=`(${B}) => T`;else $=`(${B}) => any`}else $="any"}else if(t)$="unknown";else $=Ot(u,Go(g));let v=`${a}${g} => ${$}`;return t?`(${v})`:v}if(i.startsWith("function")){let a=8,o=i.length;while(a<o&&i.charCodeAt(a)<=32)a++;let c=!1;if(a<o&&i.charCodeAt(a)===42){c=!0,a++;while(a<o&&i.charCodeAt(a)<=32)a++}let f="";if(a<o&&i.charCodeAt(a)===60){let g=a,d=1;a++;while(a<o&&d>0){let $=i.charCodeAt(a);if($===60)d++;else if($===62&&i.charCodeAt(a-1)!==61)d--;a++}f=i.substring(g,a);while(a<o&&i.charCodeAt(a)<=32)a++}let u=i.indexOf("(",a);if(u!==-1){let g=1,d=u+1;while(d<o&&g>0){let x=i.charCodeAt(d);if(x===40)g++;else if(x===41)g--;d++}let $=i.substring(u+1,d-1).trim(),v=$?`(${$})`:"()";if(c){let x=i.substring(d).trim(),P=x.indexOf("Generator<");if(P!==-1){let I=P+10,B=x.indexOf(">",I);if(B!==-1){let W=x.substring(I,B),T=`${f}${v} => Generator<${W}>`;return t?`(${T})`:T}}let R=`${f}${v} => Generator<any, any, any>`;return t?`(${R})`:R}let C=`${f}${v} => unknown`;return t?`(${C})`:C}let l="(...args: any[]) => unknown";return t?`(${l})`:l}if(i.includes("=>")&&i.includes("(")&&i.includes(")")){if(i.length>100||jn(i,"=>")>2){let a="";if(i.charCodeAt(0)===60){let l=et(i,0,"<",">");if(l!==-1)a=i.substring(0,l+1)}let o=i.indexOf("("),c=o!==-1?et(i,o,"(",")"):-1,f=o!==-1&&c!==-1?i.substring(o,c+1):"(...args: any[])";f=rr(f);let u=`${a}${f} => any`;return t?`(${u})`:u}return t?`(${i})`:i}let s="() => unknown";return t?`(${s})`:s}function Lo(e){let t=e.trim();if(!t.startsWith("("))return{params:t,returnType:""};let r=et(t,0,"(",")");if(r===-1)return{params:t,returnType:""};let n=t.slice(r+1).trim();return{params:t.slice(0,r+1),returnType:n.startsWith(":")?n.slice(1).trim():""}}function Jo(e){let t=e.trim();if(t==="any"||t==="object"||t==="unknown")return!0;if(t.startsWith("Record<")&&t.endsWith(">"))return!0;if(t.startsWith("Array<")&&t.endsWith(">"))return!0;if(/^\{\s*\[[^\]]*\]:\s*(any|string|number|unknown)\s*\}$/.test(t))return!0;return!1}function Uo(e){let t=e.lastIndexOf(" satisfies ");if(t===-1)return null;let r=e.slice(t+11).trim();if(r.endsWith(";"))r=r.slice(0,-1).trim();return r||null}var Si=!1,je=null;var Xn=()=>{};function Fe(e){return e===Ee||e===ve||e===ne||e===pe}function kt(e){return e>=65&&e<=90||e>=97&&e<=122||e===Th||e===qo||e>127}function Ke(e){return kt(e)||e>=48&&e<=57}function Rh(e){let t=!0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===ct){if(t)return!1;t=!0}else if(t){if(!kt(n))return!1;t=!1}else if(!Ke(n))return!1}return e.length>0&&!t}function xi(e,t,r){let n=t+1;while(n<e.length){let i=e.charCodeAt(n);if(i===Je){n+=2;continue}if(n++,i===r)break}return n}function Oh(e){if(e==="any"||e==="object"||e==="unknown")return!0;if(e.startsWith("Record<")||e.startsWith("Array<"))return!0;return e.charCodeAt(0)===_&&e.includes("[")&&e.includes("]:")}function Xo(e,t,r=!0){return Qo(e,t,r,!0)}function zo(e,t,r=!0){return Qo(e,t,r,!1)}function Qo(e,t,r,n){let i=e,s=r,a=n,o=i.length,c=[],f=new Map,u=new Set,l=0;if(l<o&&i.charCodeAt(l)===65279)l++;function g(p,h){if(p<h){let m=i.charCodeAt(p),y=i.charCodeAt(h-1);if(m!==Ee&&m!==ve&&m!==ne&&m!==pe&&y!==Ee&&y!==ve&&y!==ne&&y!==pe)return i.slice(p,h)}while(p<h&&Fe(i.charCodeAt(p)))p++;while(h>p&&Fe(i.charCodeAt(h-1)))h--;return i.slice(p,h)}function d(){if(l>=o)return;let p=i.charCodeAt(l);if(p!==Ee&&p!==ve&&p!==ne&&p!==pe&&p!==J)return;while(l<o){let h=i.charCodeAt(l);if(h===Ee||h===ve||h===ne||h===pe){l++;continue}if(h===J&&l+1<o){let m=i.charCodeAt(l+1);if(m===J){let y=i.indexOf(`
101
+ `,l+2);l=y===-1?o:y+1;continue}if(m===we){let y=i.indexOf("*/",l+2);l=y===-1?o:y+2;continue}}break}}function $(p){let h=p.length,m=0,y=h;for(let w=0;w<h;w++){let E=p.charCodeAt(w);if(m){if(E===Je){w++;continue}if(E===m)m=0;continue}if(E===ie||E===oe||E===Te){m=E;continue}if(E===J&&w+1<h){let A=p.charCodeAt(w+1);if(A===J){y=w;while(y>0&&(p.charCodeAt(y-1)===Ee||p.charCodeAt(y-1)===ve))y--;return p.slice(0,y)}if(A===we){let O=p.indexOf("*/",w+2);if(O!==-1){p=`${p.slice(0,w)} ${p.slice(O+2)}`,w--;continue}}}}y=h;while(y>0&&(p.charCodeAt(y-1)===Ee||p.charCodeAt(y-1)===ve||p.charCodeAt(y-1)===pe))y--;return y<h?p.slice(0,y):p}function v(p){l++;let h=p===ie?"'":'"';while(l<o){let m=i.indexOf(h,l);if(m===-1){l=o;return}let y=0,w=m-1;while(w>=0&&i.charCodeAt(w)===Je)y++,w--;if(y%2===0){l=m+1;return}l=m+1}}function C(){l++;let p=[];while(l<o){let h=i.charCodeAt(l);if(p.length===0){if(h===Je){l+=2;continue}if(h===Te){l++;return}if(h===qo&&l+1<o&&i.charCodeAt(l+1)===_){l+=2,p.push(0);continue}l++;continue}if(h===ie||h===oe){v(h);continue}if(h===Te){C();continue}if(h===J&&l+1<o){let m=i.charCodeAt(l+1);if(m===J){let y=i.indexOf(`
102
+ `,l+2);l=y===-1?o:y+1;continue}if(m===we){let y=i.indexOf("*/",l+2);l=y===-1?o:y+2;continue}if(I()){B();continue}l++;continue}if(h===_){p[p.length-1]++,l++;continue}if(h===U){let m=p[p.length-1];if(m===0){p.pop(),l++;continue}p[p.length-1]=m-1,l++;continue}l++}}function x(){let p=i.charCodeAt(l);if(p===ie||p===oe)return v(p),!0;if(p===Te)return C(),!0;if(p===J&&l+1<o){let h=i.charCodeAt(l+1);if(h===J){let m=i.indexOf(`
103
+ `,l+2);return l=m===-1?o:m+1,!0}if(h===we){let m=i.indexOf("*/",l+2);return l=m===-1?o:m+2,!0}if(I())return B(),!0}return!1}function P(p){let h=p;for(;;){while(h>=0&&(i.charCodeAt(h)===Ee||i.charCodeAt(h)===ve||i.charCodeAt(h)===ne||i.charCodeAt(h)===pe))h--;if(h<0)return-1;if(i.charCodeAt(h)===J&&h>0&&i.charCodeAt(h-1)===we){let w=i.lastIndexOf("/*",h-2);if(w===-1)return-1;h=w-1;continue}let m=i.lastIndexOf(`
104
+ `,h)+1,y=R(m,h);if(y!==-1){h=y-1;continue}return h}}function R(p,h){let m=0;for(let y=p;y<=h;y++){let w=i.charCodeAt(y);if(m){if(w===Je){y++;continue}if(w===m)m=0;continue}if(w===ie||w===oe||w===Te){m=w;continue}if(w===J&&y+1<=h&&i.charCodeAt(y+1)===J)return y}return-1}function I(){let p=P(l-1);if(p<0)return!0;let h=i.charCodeAt(p);if(h===$e||h===Q||h===de||h===33||h===38||h===124||h===bi||h===tt||h===rt||h===Z||h===_||h===U||h===94||h===126||h===43||h===45||h===we||h===37||h===me||h===he)return!0;if(Ke(h)){let m=p;while(m>=0&&Ke(i.charCodeAt(m)))m--;let y=i.slice(m+1,p+1);if(y==="return"||y==="typeof"||y==="void"||y==="delete"||y==="throw"||y==="new"||y==="in"||y==="of"||y==="case"||y==="instanceof"||y==="yield"||y==="await")return!0}return!1}function B(){l++;let p=!1;while(l<o){let h=i.charCodeAt(l);if(h===Je){l+=2;continue}if(p){if(h===be)p=!1;l++;continue}if(h===de){p=!0,l++;continue}if(h===J){l++;break}if(h===ne||h===pe)break;l++}while(l<o&&Ke(i.charCodeAt(l)))l++}function W(){let p=l;while(l<o&&Ke(i.charCodeAt(l)))l++;return i.slice(p,l)}function T(p){if(l+p.length>o)return!1;for(let h=0;h<p.length;h++)if(i.charCodeAt(l+h)!==p.charCodeAt(h))return!1;if(l+p.length<o&&Ke(i.charCodeAt(l+p.length)))return!1;return!0}function D(p){let h=l+p;while(h<o){let m=i.charCodeAt(h);if(m===Ee||m===ve||m===ne||m===pe){h++;continue}return m!==ct&&m!==$e}return!1}function H(){if(l>=o)return!1;switch(i.charCodeAt(l)){case 101:return T("export")||T("enum");case 105:return T("import")||T("interface");case 102:return T("function");case 99:return T("class")||T("const");case 116:return T("type");case 108:return T("let");case 118:return T("var");case 100:return T("declare")||T("default");case 109:return T("module");case 110:return T("namespace");case 97:return T("abstract")||T("async");default:return!1}}function Y(){let p=i.charCodeAt(l);if(p!==ne&&p!==pe)return!1;let h=l;if(l++,p===pe&&l<o&&i.charCodeAt(l)===ne)l++;while(l<o){let y=i.charCodeAt(l);if(y===Ee||y===ve||y===pe||y===ne){l++;continue}if(y===J&&l+1<o){let w=i.charCodeAt(l+1);if(w===J){let E=i.indexOf(`
105
+ `,l+2);l=E===-1?o:E+1;continue}if(w===we){let E=i.indexOf("*/",l+2);l=E===-1?o:E+2;continue}}break}let m=l>=o||H()||i.charCodeAt(l)===U;return l=h,m}function se(p){let h=p-1;while(h>=0){let S=i.charCodeAt(h);if(S===Ee||S===ve||S===pe||S===ne){h--;continue}break}if(h<0)return!0;let m=i[h];if("+-*/%=<>&|^!~?:,.([{".includes(m))return!0;let y=h;while(y>0&&i.charCodeAt(y-1)!==ne)y--;let w=i.slice(y,h+1),E=w.lastIndexOf("<");if(E!==-1&&/^<[A-Za-z]/.test(w.slice(E))&&!w.slice(E).includes(">"))return!0;let A=h;while(A>=0&&/[a-z]/i.test(i[A]))A--;let O=i.slice(A+1,h+1);return["as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","return","yield","void"].includes(O)}function K(){let p=i.charCodeAt(l);if(p!==ne&&p!==pe)return!1;if(se(l))return!1;let h=l;l++;while(l<o){let E=i.charCodeAt(l);if(E===Ee||E===ve||E===pe||E===ne){l++;continue}if(E===J&&l+1<o){let A=i.charCodeAt(l+1);if(A===J){let O=i.indexOf(`
106
+ `,l+2);l=O===-1?o:O+1;continue}if(A===we){let O=i.indexOf("*/",l+2);l=O===-1?o:O+2;continue}}break}let m=l<o?i[l]:"",y=i.slice(l,l+2),w=m==="."||m==="?"||m===":"||m===")"||m==="]"||m==="}"||m===","||m==="+"||m==="-"||m==="*"||m==="/"||m==="%"||m==="<"||m===">"||m==="="||m==="&"||m==="|"||m==="^"||m==="`"||y==="=>"||T("as")||T("satisfies")||T("instanceof")||T("in");return l=h,!w}function q(){let p=i.charCodeAt(l);if(p!==ne&&p!==pe)return!1;if(se(l))return!1;let h=l;l++;while(l<o){let w=i.charCodeAt(l);if(w===Ee||w===ve||w===pe||w===ne){l++;continue}if(w===J&&l+1<o){let E=i.charCodeAt(l+1);if(E===J){let A=i.indexOf(`
107
+ `,l+2);l=A===-1?o:A+1;continue}if(E===we){let A=i.indexOf("*/",l+2);l=A===-1?o:A+2;continue}}break}let m=l<o?i[l]:"",y=m==="|"||m==="&"||m==="["||m==="."||m==="?"||m===":"||m===">"||m===")"||m===","||T("extends");return l=h,!y}function te(){let p=i.charCodeAt(l);if(p!==ne&&p!==pe)return!1;let h=l;if(l++,p===pe&&l<o&&i.charCodeAt(l)===ne)l++;while(l<o){let y=i.charCodeAt(l);if(y===Ee||y===ve||y===pe||y===ne){l++;continue}if(y===J&&l+1<o&&i.charCodeAt(l+1)===J){let w=i.indexOf(`
108
+ `,l+2);l=w===-1?o:w+1;continue}break}if(l>=o)return l=h,!0;let m=i.charCodeAt(l);if(m===124||m===38||m===ct||m===bi||m===tt)return l=h,!1;if(T("extends")||T("keyof")||T("typeof")||T("infer")||T("is")||T("as")||T("in"))return l=h,!1;return l=h,!0}let X=/[{}'"`\/]/g,Re=/[()'"`\/]/g,Oe=/[[\]'"`\/]/g,It=/[<>'"`\/]/g;function Pe(p,h){let m=1;l++;let y=p===_?X:p===Q?Re:p===de?Oe:It;y.lastIndex=l;let w;while((w=y.exec(i))!==null){let E=w.index,A=i.charCodeAt(E);if(A===ie||A===oe){l=E,v(A),y.lastIndex=l;continue}if(A===Te){l=E,C(),y.lastIndex=l;continue}if(A===J){if(l=E,x()){y.lastIndex=l;continue}y.lastIndex=E+1;continue}if(A===p)m++;else if(A===h){if(h===he&&E>0&&i.charCodeAt(E-1)===$e){y.lastIndex=E+1;continue}if(m--,m===0)return l=E+1,l}y.lastIndex=E+1}return l=o,l}function ke(){return l>0&&i.charCodeAt(l-1)===$e}function ut(){return l+1<o&&i.charCodeAt(l+1)===he}let ae=/[<{};'"`\/\n\r()[\]]/g;function z(){let p=0,h=0,m=0,y=0,w=i.charCodeAt(l)===_;ae.lastIndex=l;let E;while((E=ae.exec(i))!==null){let A=E.index,O=i.charCodeAt(A);if(O===ie||O===oe){l=A,v(O),ae.lastIndex=l;continue}if(O===Te){l=A,C(),ae.lastIndex=l;continue}if(O===J){if(A>0&&i.charCodeAt(A-1)===me){ae.lastIndex=A+1;continue}if(l=A,x()){ae.lastIndex=l;continue}ae.lastIndex=A+1;continue}if(O===me){let S=xs(A);if(S!==null)y=Math.max(0,y+S);ae.lastIndex=A+1;continue}if(O===Q){h++,ae.lastIndex=A+1;continue}if(O===Ce){h--,ae.lastIndex=A+1;continue}if(O===de){m++,ae.lastIndex=A+1;continue}if(O===be){m--,ae.lastIndex=A+1;continue}if(O===_){p++,ae.lastIndex=A+1;continue}if(O===U){let S=p>0;if(S)p--;if((!S||w)&&p===0&&h===0&&m===0&&y===0){l=A+1;return}ae.lastIndex=A+1;continue}if(O===Z&&p===0&&h===0&&m===0&&y===0){l=A+1;return}if((O===ne||O===pe)&&p===0&&h===0&&m===0&&y===0){if(l=A,Y())return}ae.lastIndex=A+1}l=o}function Dt(){l++;while(l<o&&(i.charCodeAt(l)===Ee||i.charCodeAt(l)===ve))l++;let p=i.indexOf(`
109
+ `,l),h=p===-1?o:p,m=i.indexOf(";",l);if(m!==-1&&m<h){let y=m-1;while(y>=l&&(i.charCodeAt(y)===Ee||i.charCodeAt(y)===ve))y--;let w=i.charCodeAt(l),E=i.charCodeAt(y);if(w===_&&E===U||w===de&&E===be||w===ie&&E===ie||w===oe&&E===oe||w===Te&&E===Te){l=m+1;return}}z()}function or(){Pe(_,U);while(l<o&&Fe(i.charCodeAt(l)))l++;if(T("from")){l+=4;while(l<o&&Fe(i.charCodeAt(l)))l++;if(l<o){let p=i.charCodeAt(l);if(p===ie||p===oe)v(p)}}while(l<o&&(i.charCodeAt(l)===Ee||i.charCodeAt(l)===ve))l++;if(l<o&&i.charCodeAt(l)===Z)l++}function Es(){l++;while(l<o&&Fe(i.charCodeAt(l)))l++;if(T("as")){l+=2;while(l<o&&Fe(i.charCodeAt(l)))l++;W();while(l<o&&Fe(i.charCodeAt(l)))l++}if(T("from")){l+=4;while(l<o&&Fe(i.charCodeAt(l)))l++;if(l<o){let p=i.charCodeAt(l);if(p===ie||p===oe)v(p)}}while(l<o&&(i.charCodeAt(l)===Ee||i.charCodeAt(l)===ve))l++;if(l<o&&i.charCodeAt(l)===Z)l++}function Or(p){let h=p.indexOf("from ");if(h===-1)return;let m=h+5;while(m<p.length&&(p.charCodeAt(m)===32||p.charCodeAt(m)===9))m++;if(m>=p.length)return;let y=p.charCodeAt(m);if(y!==39&&y!==34)return;let w=p.indexOf(p[m],m+1);if(w===-1)return;return p.slice(m+1,w)}function Ue(p){if(!s)return;let h=p-1;while(h>=0&&Fe(i.charCodeAt(h)))h--;if(h<0)return;let m=[],y=!1;while(h>=0){if(h>=1&&i.charCodeAt(h)===J&&i.charCodeAt(h-1)===we){let A=i.lastIndexOf("/*",h-2);if(A>=0){m.push(i.slice(A,h+1)),y=!0,h=A-1;while(h>=0&&Fe(i.charCodeAt(h)))h--;continue}break}let w=h;while(w>0&&i.charCodeAt(w-1)!==ne)w--;let E=g(w,h+1);if(E.startsWith("//")){if(y)break;let A=[E];h=w-1;while(h>=0&&(i.charCodeAt(h)===ne||i.charCodeAt(h)===pe))h--;while(h>=0){let O=h;while(O>0&&i.charCodeAt(O-1)!==ne)O--;let S=g(O,h+1);if(S.startsWith("//")){A.push(S),h=O-1;while(h>=0&&(i.charCodeAt(h)===ne||i.charCodeAt(h)===pe))h--}else if(S===""){h=O-1;while(h>=0&&(i.charCodeAt(h)===ne||i.charCodeAt(h)===pe))h--}else break}A.reverse(),m.push(A.join(`
110
+ `));continue}break}if(m.length===0)return;return m.reverse(),m}function sc(p){let h=p,m=!1;while(l<o){let S=i.charCodeAt(l);if(S===Z){l++;break}if(S===ie||S===oe){v(S),m=!0;while(l<o&&(i.charCodeAt(l)===Ee||i.charCodeAt(l)===ve))l++;if(l<o&&i.charCodeAt(l)===Z)l++;break}if(S===ne&&m)break;l++}let y=g(h,l),w=y.charCodeAt(7)===116&&(y.startsWith("import type ")||y.startsWith("import type{")),E=!1;{let S=6;while(S<y.length&&(y.charCodeAt(S)===Ee||y.charCodeAt(S)===ve))S++;if(S<y.length&&y.charCodeAt(S)===116&&y.startsWith("type",S)){S+=4;while(S<y.length&&(y.charCodeAt(S)===Ee||y.charCodeAt(S)===ve))S++}if(S<y.length){let b=y.charCodeAt(S);E=b===ie||b===oe}}let A="";{let S=y.indexOf("from ");if(S!==-1){let b=S+5;while(b<y.length&&(y.charCodeAt(b)===Ee||y.charCodeAt(b)===ve))b++;if(b<y.length){let k=y.charCodeAt(b);if(k===ie||k===oe){let N=y.indexOf(String.fromCharCode(k),b+1);if(N!==-1)A=y.slice(b+1,N)}}}else if(E){let b=6;while(b<y.length&&y.charCodeAt(b)!==ie&&y.charCodeAt(b)!==oe)b++;if(b<y.length){let k=y.charCodeAt(b),N=y.indexOf(String.fromCharCode(k),b+1);if(N!==-1)A=y.slice(b+1,N)}}}let O=Ue(h);return{kind:"import",name:"",text:y,isExported:!1,isTypeOnly:w,isSideEffect:E,source:A,leadingComments:O,start:h,end:l}}function Bi(){let p=l;return Pe(_,U),i.slice(p,l)}function vs(p){let h=p.indexOf("(");if(h===-1)return p;let m=p.slice(h);if(m.indexOf("=")===-1)return p;let y=!1;for(let S=0;S<m.length;S++)if(m.charCodeAt(S)===61){let b=S>0?m.charCodeAt(S-1):0,k=S+1<m.length?m.charCodeAt(S+1):0;if(b!==61&&b!==33&&b!==60&&b!==62&&k!==61&&k!==62){y=!0;break}}if(!y)return p;let w=0,E=-1;for(let S=h;S<p.length;S++){let b=p.charCodeAt(S);if(b===40)w++;else if(b===41){if(w--,w===0){E=S;break}}}if(E===-1)return p;let A=p.slice(h,E+1),O=Ft(A);return p.slice(0,h)+O+p.slice(E+1)}function Ss(p){let h=p.indexOf("//")!==-1||p.indexOf("/*")!==-1,m=p.split(`
111
+ `),y=[],w=[],E=[],A=!1,O=1/0;for(let k=0;k<m.length;k++){let N=m[k];if(h){if(A){if(N.includes("*/"))A=!1;continue}let G=N.trim();if(G.length===0)continue;let L=G.charCodeAt(0);if(L===J){let Ae=G.charCodeAt(1);if(Ae===J)continue;if(Ae===we){if(!G.includes("*/"))A=!0;continue}}if(L===we)continue;let M=$(N);if(M.charCodeAt(M.length-1)===Z)M=M.slice(0,-1);M=vs(M);let F=M.trim();if(!F)continue;y.push(M),w.push(F);let V=0;while(V<M.length&&Fe(M.charCodeAt(V)))V++;if(F!=="{"&&F!=="}"){if(V<O)O=V}E.push(V)}else{let G=N.length;while(G>0&&(N.charCodeAt(G-1)===Ee||N.charCodeAt(G-1)===ve||N.charCodeAt(G-1)===pe))G--;if(G===0)continue;let L=G<N.length?N.slice(0,G):N;if(L.charCodeAt(L.length-1)===Z)L=L.slice(0,-1);L=vs(L);let M=L.trim();if(!M)continue;y.push(L),w.push(M);let F=0;while(F<L.length&&Fe(L.charCodeAt(F)))F++;if(M!=="{"&&M!=="}"){if(F<O)O=F}E.push(F)}}if(y.length===0)return"{}";if(O===1/0||O<=2)return y.join(`
112
+ `);let S=O-2,b=Array(y.length);for(let k=0;k<y.length;k++){let N=w[k];if(N==="{"){b[k]=N;continue}let G=E[k];if(G>O)b[k]=y[k];else if(G===O&&(N.charCodeAt(0)===U||N.charCodeAt(0)===be||N.charCodeAt(0)===Ce))b[k]=y[k];else{let L=Math.max(0,G-S);b[k]=" ".repeat(L)+N}}return b.join(`
113
+ `)}function lt(){if(l>=o||i.charCodeAt(l)!==me)return"";let p=l;Pe(me,he);let h=i.slice(p,l);if(h.includes(`
114
+ `)){let m="",y=!1;for(let w=0;w<h.length;w++){let E=h.charCodeAt(w);if(E===32||E===9||E===10||E===13){if(!y&&m.length>0)m+=" ",y=!0}else m+=h[w],y=!1}if(m.charCodeAt(1)===32)m=`<${m.slice(2)}`;if(m.charCodeAt(m.length-2)===32)m=`${m.slice(0,-2)}>`;return m}return h}function vt(){if(l>=o||i.charCodeAt(l)!==Q)return"()";let p=l;return Pe(Q,Ce),i.slice(p,l)}function Ft(p){let h=p.slice(1,-1).trim();if(!h)return"()";if(p.indexOf(`
115
+ `)===-1&&h.indexOf(":")!==-1&&h.indexOf("{")===-1&&h.indexOf("[")===-1&&h.indexOf("=")===-1&&h.indexOf("@")===-1&&h.indexOf("...")===-1){let S=0,b=0,k=0;for(let N=0;N<h.length;N++){let G=h.charCodeAt(N);if(G===Q||G===me||G===_)k++;else if(G===Ce||G===he||G===U)k--;else if(k===0){if(G===tt)S++;else if(G===rt)b++}}if(S>=b+1){let N=!1;for(let G=0;G<zn.length;G++){let L=zn[G],M=h.indexOf(L);if(M!==-1){let F=M+L.length;if((M===0||!Ke(h.charCodeAt(M-1)))&&(F>=h.length||!Ke(h.charCodeAt(F)))){N=!0;break}}}if(!N)return p}}let m=[],y=0,w=0,E=!1,A=0;for(let S=0;S<=h.length;S++){if(S===h.length){m.push(h.slice(y).trim());break}let b=h.charCodeAt(S);if(E){if(b===Je){S++;continue}if(b===A)E=!1;continue}if(b===J&&S+1<h.length){let k=h.charCodeAt(S+1);if(k===we){S+=2;while(S+1<h.length&&!(h.charCodeAt(S)===we&&h.charCodeAt(S+1)===J))S++;S++;continue}if(k===J){while(S<h.length&&h.charCodeAt(S)!==10)S++;continue}}if(b===ie||b===oe||b===Te){E=!0,A=b;continue}if(b===Q||b===_||b===de||b===me)w++;else if(b===Ce||b===U||b===be||b===he&&!(S>0&&h.charCodeAt(S-1)===$e))w--;else if(b===rt&&w===0)m.push(h.slice(y,S).trim()),y=S+1}let O=[];for(let S of m){if(!S)continue;let b=S.trim();if(b.startsWith("//")||b.startsWith("/*"))continue;let k=S;{let N=!1,G=0,L=0,M=0;for(let F=0;F<k.length-1;F++){let V=k.charCodeAt(F);if(V===ne){M=F+1;continue}if(N){if(V===Je){F++;continue}if(V===G)N=!1;continue}if(V===ie||V===oe||V===Te){N=!0,G=V;continue}if(V===_||V===de||V===Q||V===me){L++;continue}if(V===U||V===be||V===Ce||V===he){if(L>0)L--;continue}if(V===J&&k.charCodeAt(F+1)===J){if(L===0){k=k.slice(0,F).trimEnd();break}let Ae=k.indexOf(`
116
+ `,F);if(Ae===-1){k=k.slice(0,M).trimEnd();break}let Gt=k.slice(0,M),dc=k.slice(Ae+1);k=`${Gt}${dc}`,F=M-1}}}if(!k.trim())continue;O.push(bs(k))}return`(${O.join(", ")})`}function ac(p){if(!p.startsWith("{")&&!p.startsWith("["))return p;let h="",m=0,y=0,w=!1,E=0;while(m<p.length){let A=p.charCodeAt(m);if(w){if(A===Je&&m+1<p.length){h+=p[m]+p[m+1],m+=2;continue}if(A===E)w=!1;h+=p[m],m++;continue}if(A===J&&m+1<p.length){let O=p.charCodeAt(m+1);if(O===we){let S=m;m+=2;while(m+1<p.length&&!(p.charCodeAt(m)===we&&p.charCodeAt(m+1)===J))m++;m=Math.min(m+2,p.length),h+=p.slice(S,m);continue}if(O===J){let S=m;while(m<p.length&&p.charCodeAt(m)!==10)m++;h+=p.slice(S,m);continue}}if(A===ie||A===oe||A===Te){w=!0,E=A,h+=p[m],m++;continue}if(A===_||A===de||A===Q)y++;else if(A===U||A===be||A===Ce)y--;if(y>=1&&A===$e&&(m+1>=p.length||p.charCodeAt(m+1)!==$e&&p.charCodeAt(m+1)!==he)){while(h.length>0&&(h[h.length-1]===" "||h[h.length-1]==="\t"||h[h.length-1]===`
117
+ `))h=h.slice(0,-1);m++;let O=0;while(m<p.length){let S=p.charCodeAt(m);if(S===ie||S===oe||S===Te){let b=S;m++;while(m<p.length){if(p.charCodeAt(m)===Je){m+=2;continue}if(p.charCodeAt(m)===b){m++;break}m++}continue}if(S===_||S===de||S===Q)O++;else if(S===U||S===be||S===Ce){if(O===0)break;O--}else if(S===rt&&O===0)break;m++}continue}if(y===1&&A===ct&&m+2<p.length&&p.charCodeAt(m+1)===ct&&p.charCodeAt(m+2)===ct){m+=3;continue}h+=p[m],m++}return h}function bs(p){let h=p.trim(),m=h.startsWith("...");if(m)h=h.slice(3).trim();while(h.startsWith("@")){let M=1;while(M<h.length&&Ke(h.charCodeAt(M)))M++;if(M<h.length&&h.charCodeAt(M)===Q){let F=1;M++;while(M<h.length&&F>0){if(h.charCodeAt(M)===Q)F++;else if(h.charCodeAt(M)===Ce)F--;M++}}h=h.slice(M).trim()}let y=!0;while(y){y=!1;for(let M of zn)if(h.startsWith(M)&&h.length>M.length&&!Ke(h.charCodeAt(M.length))){let F=h.slice(M.length).trim();if(F.charCodeAt(0)===tt||F.charCodeAt(0)===bi&&F.length>1&&F.charCodeAt(1)===tt)break;h=F,y=!0;break}}let w=-1,E=-1,A=0,O=!1,S=0;for(let M=0;M<h.length;M++){let F=h.charCodeAt(M);if(O){if(F===Je){M++;continue}if(F===S)O=!1;continue}if(F===J&&M+1<h.length){let V=h.charCodeAt(M+1);if(V===we){M+=2;while(M+1<h.length&&!(h.charCodeAt(M)===we&&h.charCodeAt(M+1)===J))M++;M++;continue}if(V===J){while(M<h.length&&h.charCodeAt(M)!==10)M++;continue}}if(F===ie||F===oe||F===Te){O=!0,S=F;continue}if(F===Q||F===_||F===de||F===me)A++;else if(F===Ce||F===U||F===be||F===he&&!(M>0&&h.charCodeAt(M-1)===$e))A--;else if(A===0){if(F===tt&&w===-1)w=M;else if(F===$e&&E===-1&&(M===0||h.charCodeAt(M-1)!==$e)&&(M+1>=h.length||h.charCodeAt(M+1)!==$e&&h.charCodeAt(M+1)!==he))E=M}}let b,k,N=E!==-1;if(w!==-1&&(E===-1||w<E))if(b=h.slice(0,w).trim(),E!==-1)k=h.slice(w+1,E).trim();else k=h.slice(w+1).trim();else if(E!==-1)b=h.slice(0,E).trim(),k=Vi(h.slice(E+1).trim());else b=h,k="unknown";if(b=ac(b),(b.startsWith("{")||b.startsWith("["))&&b.includes(`
118
+ `)){let M=b.replace(/\s*\n\s*/g," ").replace(/\s+/g," ");if(M.length<=40)b=M;else b=b.split(`
117
119
  `).map((F)=>{let V=F.trim();if(!V)return"";if(V==="{"||V==="}"||V==="["||V==="]"||V.startsWith("}")||V.startsWith("]"))return V;return` ${V}`}).join(`
118
- `)}let G=S.endsWith("?")||N;if(S.endsWith("?"))S=S.slice(0,-1).trim();let W=G&&!p?"?":"";if(p)return`...${S}: ${k}`;return`${S}${W}: ${k}`}function vs(m){let h=0;if(h<m.length&&m.charCodeAt(h)===45)h++;if(h>=m.length)return!1;let p=m.charCodeAt(h);if(p<48||p>57)return!1;while(h<m.length&&m.charCodeAt(h)>=48&&m.charCodeAt(h)<=57)h++;if(h<m.length&&m.charCodeAt(h)===46){if(h++,h>=m.length||m.charCodeAt(h)<48||m.charCodeAt(h)>57)return!1;while(h<m.length&&m.charCodeAt(h)>=48&&m.charCodeAt(h)<=57)h++}return h===m.length}function Gi(m){let h=m.trim();if(h==="true"||h==="false")return"boolean";if(vs(h))return"number";if(h.startsWith("'")&&h.endsWith("'")||h.startsWith('"')&&h.endsWith('"'))return"string";if(h.startsWith("["))return"unknown[]";if(h.startsWith("{"))return"Record<string, unknown>";return"unknown"}function Bi(m){let h=m.trim();if(h.endsWith("as const"))h=h.slice(0,-8).trim();if(h==="true"||h==="false")return h;if(vs(h))return h;let p=nc(h);if(p!==null)return p;return"unknown"}function nc(m){if(m==="")return null;if(m.charCodeAt(0)===ne||m.charCodeAt(0)===ae){if(bi(m,0,m.charCodeAt(0))===m.length)return m}let h=sc(m,"+");if(h.length>1){let p=!1,y=!0,$=[];for(let v of h){let x=v.trim(),P=x.charCodeAt(0);if((P===ne||P===ae)&&bi(x,0,P)===x.length)p=!0,$.push(ac(x));else y=!1}if(y)return oc($.join(""));if(p)return"string";return null}if(/^[\d\s()+*/%.\-]+$/.test(m)&&/\d/.test(m)&&/[+*/%\-\s]/.test(m))return"number";return null}function sc(m,h){let p=[],y=0,$="",v=0;while(v<m.length){let x=m.charCodeAt(v);if(x===ne||x===ae||x===xe){let P=bi(m,v,x);$+=m.slice(v,P),v=P;continue}if(x===Y&&(m.charCodeAt(v+1)===Y||m.charCodeAt(v+1)===42)){if(m.charCodeAt(v+1)===Y){let S=m.indexOf(`
119
- `,v+2),k=S===-1?m.length:S;$+=m.slice(v,k),v=k;continue}let P=m.indexOf("*/",v+2),b=P===-1?m.length:P+2;$+=m.slice(v,b),v=b;continue}if(x===te||x===he||x===_)y++;else if(x===ye||x===Ee||x===J)y--;if(m[v]===h&&y===0){p.push($),$="",v++;continue}$+=m[v],v++}return p.push($),p}function ac(m){return m.slice(1,-1).replace(/\\(.)/g,(h,p)=>{if(p==="n")return`
120
- `;if(p==="t")return"\t";if(p==="r")return"\r";if(p==="0")return"\x00";return p})}function oc(m){return`'${m.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function Rr(m){if(m.endsWith("as const"))return null;let h=0,p=-1;for(let y=0;y<m.length;y++){let $=m.charCodeAt(y);if($===ne||$===ae||$===xe)y=bi(m,y,$)-1;else if($===123||$===91||$===40)h++;else if($===125||$===93||$===41)h--;else if(h===0&&$===32&&y+4<=m.length&&m.substring(y,y+4)===" as ")p=y}if(p===-1)return null;return m.slice(p+4).trim()||null}function or(){if(d(),l<o&&i.charCodeAt(l)===et){l++,d();let m=l,h=0;while(l<o){if(A())continue;let p=i.charCodeAt(l);if(p===te||p===he||p===de)h++;else if(p===ye||p===Ee||p===ue&&!ee())h--;else if(p===_)if(h>0)h++;else{let y=g(m,l),$=(v)=>{let x=y.length-v.length;return x>=0&&y.endsWith(v)&&(x===0||!Ke(y.charCodeAt(x-1)))};if(y.length===0||y.endsWith("|")||y.endsWith("&")||$("is")||$("extends"))h++;else break}else if(p===J){if(h===0)break;h--}else if(h===0&&p===Z)break;if(h===0&&Q())break;l++}return g(m,l)}return""}function bt(m,h,p,y){l+=8,d();let $=l<o&&i.charCodeAt(l)===ve;if($)l++,d();let v=L();if(!v&&!y)return null;d();let x=lt();d();let P=St();d();let b=or(),S=b.length>0;if(!b)if(p&&$)b="AsyncGenerator<unknown, void, unknown>";else if($)b="Generator<unknown, void, unknown>";else if(p)b="Promise<void>";else b="void";d();let k=!1;if(l<o&&i.charCodeAt(l)===_){k=!0;let M=l+1;if(X(_,J),!a&&!S&&!$)b=yr(i.slice(M,l-1),p,P)}else if(l<o&&i.charCodeAt(l)===Z)l++;let N=Nt(P),G=`${h?y?"export default function ":"export declare function ":"declare function "}${v||(y?"":"default")}${x}${N}: ${b};`,W=Ve(m);if(k)u.add(c.length);return{kind:"function",name:v||"default",text:G,isExported:h,isDefault:y,isAsync:p,isGenerator:$,returnType:b,generics:x||void 0,leadingComments:W,start:m,end:l}}function Lt(m,h,p){l+=h.length,d();let y=[];do{if(d(),l>=o)break;let $=i.charCodeAt(l);if($===_||$===he)return se(),y;let v=L();if(!v)return se(),y;d();let x,P,b=!1;if(l<o&&i.charCodeAt(l)===et){l++,d();let N=l,G=0;while(l<o){if(A())continue;let W=i.charCodeAt(l);if(W===te||W===_||W===he||W===de)G++;else if(W===ye||W===J||W===Ee||W===ue&&!ee())G--;else if(G===0&&(W===Z||W===tt))break;else if(G===0&&W===we&&!vt())break;if(G===0&&U())break;l++}x=g(N,l)}if(l<o&&i.charCodeAt(l)===we)if(a&&x&&(!s||!xh(x)))Pt();else{l++,d();let N=l,G=0,W=0,M=0;while(l<o){if(A())continue;let F=i.charCodeAt(l);if(F===te||F===_||F===he)G++;else if(F===ye||F===J||F===Ee)G--;else if(F===de&&G===0){let V=Ss(l);if(V!==null)M=Math.max(0,M+V);else if(l+1>=o||i.charCodeAt(l+1)!==we)W++}else if(F===ue&&G===0&&M===0&&!ee()){if(W>0&&(l+1>=o||i.charCodeAt(l+1)!==we))W--}else if(G===0&&W===0&&M===0&&(F===Z||F===tt))break;if(G===0&&W===0&&M===0&&U())break;l++}if(P=g(N,l),P.endsWith(" as const")||P==="const"){if(b=!0,!x){let F=P.endsWith(" as const")?P.slice(0,-9).trim():P,V=Bi(F);x=V!=="unknown"?V:void 0}}else if(!x){let F=Rr(P);if(F)x=F}}if(l<o){let N=i.charCodeAt(l);if(N===tt){l++;continue}if(N===Z)l++}let S=Ve(m),k=`${p?"export ":""}declare ${h} ${v}: ${x||"unknown"};`;y.push({kind:"variable",name:v,text:k,isExported:p,typeAnnotation:x,value:P,modifiers:b?[h,"const assertion"]:[h],leadingComments:S,start:m,end:l});break}while(l<o);return y}function Ss(m){if(i.charCodeAt(m)!==de||m+1>=o)return null;let h=i.charCodeAt(m+1);if(h===ue)return 1;if(h===Y)return-1;if(!Dt(h))return null;let p=m+2;while(p<o){let S=i.charCodeAt(p);if(!Ke(S)&&S!==ct&&S!==58&&S!==45)break;p++}let y=i.slice(m+1,p),$=i.charCodeAt(p);if($>32&&$!==ue&&$!==Y)return null;let v=0,x=0,P=p;for(;P<o;P++){let S=i.charCodeAt(P);if(x!==0){if(S===Je)P++;else if(S===x)x=0;continue}if(S===ne||S===ae||S===xe)x=S;else if(S===_)v++;else if(S===J&&v>0)v--;else if(S===ue&&v===0)break}if(P>=o)return null;let b=P-1;while(b>m&&i.charCodeAt(b)<=32)b--;if(i.charCodeAt(b)===Y)return 0;return i.indexOf(`</${y}`,P+1)===-1?null:1}function Vi(m,h){l+=9,d();let p=L();d();let y=lt();d();let $="";if(T("extends")){l+=7,d();let S=l,k=0;while(l<o){if(A())continue;let N=i.charCodeAt(l);if(N===de)k++;else if(N===ue&&!ee())k--;else if(N===_&&k===0)break;l++}$=g(S,l)}d();let v=l<o&&i.charCodeAt(l)===_?Wi():"{}",x=$s(v),P=`${h?"export ":""}declare interface ${p}${y}${$?` extends ${$}`:""} ${x}`,b=Ve(m);return{kind:"interface",name:p,text:P,isExported:h,extends:$||void 0,generics:y||void 0,leadingComments:b,start:m,end:l}}function _i(m,h){l+=4,d();let p=L();d();let y=lt();if(d(),l<o&&i.charCodeAt(l)===we)l++;d();let $=l,v=0;while(l<o){if(A())continue;let S=i.charCodeAt(l);if(S===te||S===_||S===he||S===de)v++;else if(S===ye||S===J||S===Ee||S===ue&&!ee())v--;else if(v===0&&S===Z)break;if(v===0&&U())break;l++}let x=g($,l);if(l<o&&i.charCodeAt(l)===Z)l++;let P=`${h?"export ":""}type ${p}${y} = ${x}`,b=Ve(m);return{kind:"type",name:p,text:P,isExported:h,generics:y||void 0,leadingComments:b,start:m,end:l}}function Wt(m,h,p){l+=4,d();let y=L();d();let $=l;if(l<o&&i.charCodeAt(l)===_)X(_,J);let v=g(m,l),x=Ve(m);return{kind:"enum",name:y,text:v,isExported:h,modifiers:p?["const"]:void 0,leadingComments:x,start:m,end:l}}function At(m,h,p,y=!1){l+=5,d();let $=L()||"AnonymousClass";d();let v=lt();d();let x="";if(T("extends")){l+=7,d();let N=l,G=0;while(l<o){if(A())continue;let W=i.charCodeAt(l);if(W===de)G++;else if(W===ue&&!ee())G--;else if(G===0&&(W===_||T("implements")))break;l++}x=g(N,l)}let P;if(T("implements")){l+=10,d();let N=l,G=0;while(l<o){if(A())continue;let M=i.charCodeAt(l);if(M===de)G++;else if(M===ue&&!ee())G--;else if(G===0&&M===_)break;l++}let W=g(N,l);if(W)P=W.split(",").map((M)=>M.trim())}d();let b=Hi(),S=`${h?y?"export default ":"export declare ":"declare "}${p?"abstract ":""}class ${$}${v}${x?` extends ${x}`:""}${P&&P.length>0?` implements ${P.join(", ")}`:""} ${b}`,k=Ve(m);return{kind:"class",name:$,text:S,isExported:h,isDefault:y,extends:x||void 0,implements:P,generics:v||void 0,modifiers:p?["abstract"]:void 0,leadingComments:k,start:m,end:l}}function Hi(){if(l>=o||i.charCodeAt(l)!==_)return"{}";l++;let m=[];while(l<o){if(d(),l>=o)break;if(i.charCodeAt(l)===J){l++;break}if(i.charCodeAt(l)===Z){l++;continue}if(T("static")&&bs("static")===_){l+=6,d(),X(_,J);continue}let h=!1,p=!1,y=!1,$=!1,v=!1,x=!1,P=!1,b=!1,S=!0;while(S){if(d(),T("private")){h=!0,l+=7;continue}if(T("protected")){p=!0,l+=9;continue}if(T("public")){l+=6;continue}if(T("static")){y=!0,l+=6;continue}if(T("abstract")){$=!0,l+=8;continue}if(T("readonly")){v=!0,l+=8;continue}if(T("override")){x=!0,l+=8;continue}if(T("accessor")){P=!0,l+=8;continue}if(T("async")){b=!0,l+=5;continue}if(T("declare")){l+=7;continue}break}if(d(),l>=o||i.charCodeAt(l)===J)break;if(i.charCodeAt(l)===Si)h=!0;if(h){Ki();continue}let k=" ";if(p)k+="protected ";if(y)k+="static ";if($)k+="abstract ";if(v)k+="readonly ";if(T("constructor")){l+=11,d();let N=St();if(d(),lc(N,m),l<o&&i.charCodeAt(l)===_)X(_,J);else if(l<o&&i.charCodeAt(l)===Z)l++;let G=Nt(N);m.push(` constructor${G};`)}else if(T("get"))if(l+=3,d(),l<o&&(Dt(i.charCodeAt(l))||i.charCodeAt(l)===he||i.charCodeAt(l)===Si)){let N=ji();if(N.startsWith("#")){if(d(),l<o&&i.charCodeAt(l)===te)St();if(d(),or(),d(),l<o&&i.charCodeAt(l)===_)X(_,J);else if(l<o&&i.charCodeAt(l)===Z)l++;continue}d(),St(),d();let G=or()||"unknown";if(d(),l<o&&i.charCodeAt(l)===_)X(_,J);else if(l<o&&i.charCodeAt(l)===Z)l++;m.push(`${k}get ${N}(): ${G};`)}else As("get",k,y,v,b,m);else if(T("set"))if(l+=3,d(),l<o&&(Dt(i.charCodeAt(l))||i.charCodeAt(l)===he||i.charCodeAt(l)===Si)){let N=ji();if(N.startsWith("#")){if(d(),l<o&&i.charCodeAt(l)===te)St();if(d(),l<o&&i.charCodeAt(l)===_)X(_,J);else if(l<o&&i.charCodeAt(l)===Z)l++;continue}d();let G=St();if(d(),l<o&&i.charCodeAt(l)===_)X(_,J);else if(l<o&&i.charCodeAt(l)===Z)l++;let W=Nt(G);m.push(`${k}set ${N}${W};`)}else As("set",k,y,v,b,m);else{let N=i.charCodeAt(l)===ve;if(N)l++,d();let G=ji();if(!G){Ki();continue}xs(G,k,y,v,N,$,b,m)}}return`{
121
- ${m.join(`
120
+ `)}let G=b.endsWith("?")||N;if(b.endsWith("?"))b=b.slice(0,-1).trim();let L=G&&!m?"?":"";if(m)return`...${b}: ${k}`;return`${b}${L}: ${k}`}function As(p){let h=0;if(h<p.length&&p.charCodeAt(h)===45)h++;if(h>=p.length)return!1;let m=p.charCodeAt(h);if(m<48||m>57)return!1;while(h<p.length&&p.charCodeAt(h)>=48&&p.charCodeAt(h)<=57)h++;if(h<p.length&&p.charCodeAt(h)===46){if(h++,h>=p.length||p.charCodeAt(h)<48||p.charCodeAt(h)>57)return!1;while(h<p.length&&p.charCodeAt(h)>=48&&p.charCodeAt(h)<=57)h++}return h===p.length}function Vi(p){let h=p.trim();if(h==="true"||h==="false")return"boolean";if(As(h))return"number";if(h.startsWith("'")&&h.endsWith("'")||h.startsWith('"')&&h.endsWith('"'))return"string";if(h.startsWith("["))return"unknown[]";if(h.startsWith("{"))return"Record<string, unknown>";return"unknown"}function _i(p){let h=p.trim();if(h.endsWith("as const"))h=h.slice(0,-8).trim();if(h==="true"||h==="false")return h;if(As(h))return h;let m=oc(h);if(m!==null)return m;return"unknown"}function oc(p){if(p==="")return null;if(p.charCodeAt(0)===ie||p.charCodeAt(0)===oe){if(xi(p,0,p.charCodeAt(0))===p.length)return p}let h=lc(p,"+");if(h.length>1){let m=!1,y=!0,w=[];for(let E of h){let A=E.trim(),O=A.charCodeAt(0);if((O===ie||O===oe)&&xi(A,0,O)===A.length)m=!0,w.push(cc(A));else y=!1}if(y)return fc(w.join(""));if(m)return"string";return null}if(/^[\d\s()+*/%.\-]+$/.test(p)&&/\d/.test(p)&&/[+*/%\-\s]/.test(p))return"number";return null}function lc(p,h){let m=[],y=0,w="",E=0;while(E<p.length){let A=p.charCodeAt(E);if(A===ie||A===oe||A===Te){let O=xi(p,E,A);w+=p.slice(E,O),E=O;continue}if(A===J&&(p.charCodeAt(E+1)===J||p.charCodeAt(E+1)===42)){if(p.charCodeAt(E+1)===J){let b=p.indexOf(`
121
+ `,E+2),k=b===-1?p.length:b;w+=p.slice(E,k),E=k;continue}let O=p.indexOf("*/",E+2),S=O===-1?p.length:O+2;w+=p.slice(E,S),E=S;continue}if(A===Q||A===de||A===_)y++;else if(A===Ce||A===be||A===U)y--;if(p[E]===h&&y===0){m.push(w),w="",E++;continue}w+=p[E],E++}return m.push(w),m}function cc(p){return p.slice(1,-1).replace(/\\(.)/g,(h,m)=>{if(m==="n")return`
122
+ `;if(m==="t")return"\t";if(m==="r")return"\r";if(m==="0")return"\x00";return m})}function fc(p){return`'${p.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function Pr(p){if(p.endsWith("as const"))return null;let h=0,m=-1;for(let y=0;y<p.length;y++){let w=p.charCodeAt(y);if(w===ie||w===oe||w===Te)y=xi(p,y,w)-1;else if(w===123||w===91||w===40)h++;else if(w===125||w===93||w===41)h--;else if(h===0&&w===32&&y+4<=p.length&&p.substring(y,y+4)===" as ")m=y}if(m===-1)return null;return p.slice(m+4).trim()||null}function lr(){if(d(),l<o&&i.charCodeAt(l)===tt){l++,d();let p=l,h=0;while(l<o){if(x())continue;let m=i.charCodeAt(l);if(m===Q||m===de||m===me)h++;else if(m===Ce||m===be||m===he&&!ke())h--;else if(m===_)if(h>0)h++;else{let y=g(p,l),w=(E)=>{let A=y.length-E.length;return A>=0&&y.endsWith(E)&&(A===0||!Ke(y.charCodeAt(A-1)))};if(y.length===0||y.endsWith("|")||y.endsWith("&")||w("is")||w("extends"))h++;else break}else if(m===U){if(h===0)break;h--}else if(h===0&&m===Z)break;if(h===0&&te())break;l++}return g(p,l)}return""}function St(p,h,m,y){l+=8,d();let w=l<o&&i.charCodeAt(l)===we;if(w)l++,d();let E=W();if(!E&&!y)return null;d();let A=lt();d();let O=vt();d();let S=lr(),b=S.length>0;if(!S)if(m&&w)S="AsyncGenerator<unknown, void, unknown>";else if(w)S="Generator<unknown, void, unknown>";else if(m)S="Promise<void>";else S="void";d();let k=!1;if(l<o&&i.charCodeAt(l)===_){k=!0;let M=l+1;if(Pe(_,U),!a&&!b&&!w)S=Cr(i.slice(M,l-1),m,O)}else if(l<o&&i.charCodeAt(l)===Z)l++;let N=Ft(O),G=`${h?y?"export default function ":"export declare function ":"declare function "}${E||(y?"":"default")}${A}${N}: ${S};`,L=Ue(p);if(k)u.add(c.length);return{kind:"function",name:E||"default",text:G,isExported:h,isDefault:y,isAsync:m,isGenerator:w,returnType:S,generics:A||void 0,leadingComments:L,start:p,end:l}}function Nt(p,h,m){l+=h.length,d();let y=[];do{if(d(),l>=o)break;let w=i.charCodeAt(l);if(w===_||w===de)return z(),y;let E=W();if(!E)return z(),y;d();let A,O,S=!1;if(l<o&&i.charCodeAt(l)===tt){l++,d();let N=l,G=0;while(l<o){if(x())continue;let L=i.charCodeAt(l);if(L===Q||L===_||L===de||L===me)G++;else if(L===Ce||L===U||L===be||L===he&&!ke())G--;else if(G===0&&(L===Z||L===rt))break;else if(G===0&&L===$e&&!ut())break;if(G===0&&(Y()||q()))break;l++}A=g(N,l)}if(l<o&&i.charCodeAt(l)===$e)if(a&&A&&(!s||!Oh(A)))Dt();else{l++,d();let N=l,G=0,L=0,M=0;while(l<o){if(x())continue;let F=i.charCodeAt(l);if(F===Q||F===_||F===de)G++;else if(F===Ce||F===U||F===be)G--;else if(F===me&&G===0){let V=xs(l);if(V!==null)M=Math.max(0,M+V);else if(l+1>=o||i.charCodeAt(l+1)!==$e)L++}else if(F===he&&G===0&&M===0&&!ke()){if(L>0&&(l+1>=o||i.charCodeAt(l+1)!==$e))L--}else if(G===0&&L===0&&M===0&&(F===Z||F===rt))break;if(G===0&&L===0&&M===0&&(Y()||K()))break;l++}if(O=g(N,l),O.endsWith(" as const")||O==="const"){if(S=!0,!A){let F=O.endsWith(" as const")?O.slice(0,-9).trim():O,V=_i(F);A=V!=="unknown"?V:void 0}}else if(!A){let F=Pr(O);if(F)A=F}}if(l<o){let N=i.charCodeAt(l);if(N===rt){l++;continue}if(N===Z)l++}let b=Ue(p),k=`${m?"export ":""}declare ${h} ${E}: ${A||"unknown"};`;y.push({kind:"variable",name:E,text:k,isExported:m,typeAnnotation:A,value:O,modifiers:S?[h,"const assertion"]:[h],leadingComments:b,start:p,end:l});break}while(l<o);return y}function xs(p){if(i.charCodeAt(p)!==me||p+1>=o)return null;let h=i.charCodeAt(p+1);if(h===he)return 1;if(h===J)return-1;if(!kt(h))return null;let m=p+2;while(m<o){let b=i.charCodeAt(m);if(!Ke(b)&&b!==ct&&b!==58&&b!==45)break;m++}let y=i.slice(p+1,m),w=i.charCodeAt(m);if(w>32&&w!==he&&w!==J)return null;let E=0,A=0,O=m;for(;O<o;O++){let b=i.charCodeAt(O);if(A!==0){if(b===Je)O++;else if(b===A)A=0;continue}if(b===ie||b===oe||b===Te)A=b;else if(b===_)E++;else if(b===U&&E>0)E--;else if(b===he&&E===0)break}if(O>=o)return null;let S=O-1;while(S>p&&i.charCodeAt(S)<=32)S--;if(i.charCodeAt(S)===J)return 0;return i.indexOf(`</${y}`,O+1)===-1?null:1}function Hi(p,h){l+=9,d();let m=W();d();let y=lt();d();let w="";if(T("extends")){l+=7,d();let b=l,k=0;while(l<o){if(x())continue;let N=i.charCodeAt(l);if(N===me)k++;else if(N===he&&!ke())k--;else if(N===_&&k===0)break;l++}w=g(b,l)}d();let E=l<o&&i.charCodeAt(l)===_?Bi():"{}",A=Ss(E),O=`${h?"export ":""}declare interface ${m}${y}${w?` extends ${w}`:""} ${A}`,S=Ue(p);return{kind:"interface",name:m,text:O,isExported:h,extends:w||void 0,generics:y||void 0,leadingComments:S,start:p,end:l}}function ji(p,h){l+=4,d();let m=W();d();let y=lt();if(d(),l<o&&i.charCodeAt(l)===$e)l++;d();let w=l,E=0;while(l<o){if(x())continue;let b=i.charCodeAt(l);if(b===Q||b===_||b===de||b===me)E++;else if(b===Ce||b===U||b===be||b===he&&!ke())E--;else if(E===0&&b===Z)break;if(E===0&&Y())break;l++}let A=g(w,l);if(l<o&&i.charCodeAt(l)===Z)l++;let O=`${h?"export ":""}type ${m}${y} = ${A}`,S=Ue(p);return{kind:"type",name:m,text:O,isExported:h,generics:y||void 0,leadingComments:S,start:p,end:l}}function Wt(p,h,m){l+=4,d();let y=W();d();let w=l;if(l<o&&i.charCodeAt(l)===_)Pe(_,U);let E=g(p,l),A=Ue(p);return{kind:"enum",name:y,text:E,isExported:h,modifiers:m?["const"]:void 0,leadingComments:A,start:p,end:l}}function bt(p,h,m,y=!1){l+=5,d();let w=W()||"AnonymousClass";d();let E=lt();d();let A="";if(T("extends")){l+=7,d();let N=l,G=0;while(l<o){if(x())continue;let L=i.charCodeAt(l);if(L===me)G++;else if(L===he&&!ke())G--;else if(G===0&&(L===_||T("implements")))break;l++}A=g(N,l)}let O;if(T("implements")){l+=10,d();let N=l,G=0;while(l<o){if(x())continue;let M=i.charCodeAt(l);if(M===me)G++;else if(M===he&&!ke())G--;else if(G===0&&M===_)break;l++}let L=g(N,l);if(L)O=L.split(",").map((M)=>M.trim())}d();let S=Ki(),b=`${h?y?"export default ":"export declare ":"declare "}${m?"abstract ":""}class ${w}${E}${A?` extends ${A}`:""}${O&&O.length>0?` implements ${O.join(", ")}`:""} ${S}`,k=Ue(p);return{kind:"class",name:w,text:b,isExported:h,isDefault:y,extends:A||void 0,implements:O,generics:E||void 0,modifiers:m?["abstract"]:void 0,leadingComments:k,start:p,end:l}}function Ki(){if(l>=o||i.charCodeAt(l)!==_)return"{}";l++;let p=[];while(l<o){if(d(),l>=o)break;if(i.charCodeAt(l)===U){l++;break}if(i.charCodeAt(l)===Z){l++;continue}if(T("static")&&Ts("static")===_){l+=6,d(),Pe(_,U);continue}let h=!1,m=!1,y=!1,w=!1,E=!1,A=!1,O=!1,S=!1,b=!0;while(b){if(d(),T("private")){h=!0,l+=7;continue}if(T("protected")){m=!0,l+=9;continue}if(T("public")){l+=6;continue}if(T("static")){y=!0,l+=6;continue}if(T("abstract")){w=!0,l+=8;continue}if(T("readonly")){E=!0,l+=8;continue}if(T("override")){A=!0,l+=8;continue}if(T("accessor")){O=!0,l+=8;continue}if(T("async")){S=!0,l+=5;continue}if(T("declare")){l+=7;continue}break}if(d(),l>=o||i.charCodeAt(l)===U)break;if(i.charCodeAt(l)===Ai)h=!0;if(h){Ui();continue}let k=" ";if(m)k+="protected ";if(y)k+="static ";if(w)k+="abstract ";if(E)k+="readonly ";if(T("constructor")){l+=11,d();let N=vt();if(d(),uc(N,p),l<o&&i.charCodeAt(l)===_)Pe(_,U);else if(l<o&&i.charCodeAt(l)===Z)l++;let G=Ft(N);p.push(` constructor${G};`)}else if(T("get"))if(l+=3,d(),l<o&&(kt(i.charCodeAt(l))||i.charCodeAt(l)===de||i.charCodeAt(l)===Ai)){let N=Ji();if(N.startsWith("#")){if(d(),l<o&&i.charCodeAt(l)===Q)vt();if(d(),lr(),d(),l<o&&i.charCodeAt(l)===_)Pe(_,U);else if(l<o&&i.charCodeAt(l)===Z)l++;continue}d(),vt(),d();let G=lr()||"unknown";if(d(),l<o&&i.charCodeAt(l)===_)Pe(_,U);else if(l<o&&i.charCodeAt(l)===Z)l++;p.push(`${k}get ${N}(): ${G};`)}else Rs("get",k,y,E,S,p);else if(T("set"))if(l+=3,d(),l<o&&(kt(i.charCodeAt(l))||i.charCodeAt(l)===de||i.charCodeAt(l)===Ai)){let N=Ji();if(N.startsWith("#")){if(d(),l<o&&i.charCodeAt(l)===Q)vt();if(d(),l<o&&i.charCodeAt(l)===_)Pe(_,U);else if(l<o&&i.charCodeAt(l)===Z)l++;continue}d();let G=vt();if(d(),l<o&&i.charCodeAt(l)===_)Pe(_,U);else if(l<o&&i.charCodeAt(l)===Z)l++;let L=Ft(G);p.push(`${k}set ${N}${L};`)}else Rs("set",k,y,E,S,p);else{let N=i.charCodeAt(l)===we;if(N)l++,d();let G=Ji();if(!G){Ui();continue}Os(G,k,y,E,N,w,S,p)}}return`{
123
+ ${p.join(`
122
124
  `)}
123
- }`}function ji(){if(l>=o)return"";let m=i.charCodeAt(l);if(m===he){let h=l;return X(he,Ee),i.slice(h,l)}if(m===Si)return l++,`#${L()}`;return L()}function bs(m){let h=l+m.length;while(h<o&&Me(i.charCodeAt(h)))h++;return h<o?i.charCodeAt(h):0}function Ki(){let m=0;while(l<o){if(A())continue;let h=i.charCodeAt(l);if(h===_||h===te)m++;else if(h===J||h===ye){if(m===0)return;m--}else if(h===Z&&m===0){l++;return}if(m===0&&Q())return;l++}}function As(m,h,p,y,$,v){xs(m,h,p,y,!1,!1,$,v)}function xs(m,h,p,y,$,v,x,P){if(d(),l>=o)return;let b=i.charCodeAt(l),S=!1;if(b===vi)S=!0,l++,d();if(l<o&&i.charCodeAt(l)===33)l++,d();let k=l<o?i.charCodeAt(l):0;if(k===te||k===de){let N=k===de?lt():"";d();let G=St();d();let W=or(),M=W.length>0;if(!W)if(x&&$)W="AsyncGenerator<unknown, void, unknown>";else if($)W="Generator<unknown, void, unknown>";else if(x)W="Promise<void>";else W="void";if(d(),l<o&&i.charCodeAt(l)===_){let xt=l+1;if(X(_,J),!a&&!M&&!$)W=yr(i.slice(xt,l-1),x,G)}else if(l<o&&i.charCodeAt(l)===Z)l++;let F=Nt(G),V=S?"?":"",be=$?"*":"";P.push(`${h}${be}${m}${V}${N}${F}: ${W};`)}else if(k===et||k===we||k===Z||k===J||k===Ce||k===Se){let N="";if(k===et){l++,d();let M=l,F=0;while(l<o){if(A())continue;let V=i.charCodeAt(l);if(V===te||V===_||V===he||V===de)F++;else if(V===ye||V===J||V===Ee||V===ue&&!ee()){if(F===0)break;F--}else if(F===0&&(V===Z||V===tt))break;else if(F===0&&V===we&&!vt())break;if(F===0&&Q())break;l++}N=g(M,l)}let G="";if(l<o&&i.charCodeAt(l)===we)if(a&&N){l++;let M=0;while(l<o){if(A())continue;let F=i.charCodeAt(l);if(F===te||F===_||F===he)M++;else if(F===ye||F===J||F===Ee){if(M===0&&F===J)break;M--}else if(M===0&&F===Z)break;if(M===0&&Q())break;l++}}else{l++,d();let M=l,F=0;while(l<o){if(A())continue;let V=i.charCodeAt(l);if(V===te||V===_||V===he)F++;else if(V===ye||V===J||V===Ee){if(F===0&&V===J)break;F--}else if(F===0&&V===Z)break;if(F===0&&Q())break;l++}G=g(M,l)}if(l<o&&i.charCodeAt(l)===Z)l++;if(!N)if(G){let M=Rr(G);if(M)N=M;else N=G.endsWith("as const")||p&&y?Bi(G):Gi(G)}else N="unknown";let W=S?"?":"";P.push(`${h}${m}${W}: ${N};`)}else Ki()}function lc(m,h){let p=m.slice(1,-1).trim();if(!p)return;let y=[],$=0,v=0,x=!1,P=0;for(let b=0;b<=p.length;b++){if(b===p.length){y.push(p.slice($).trim());break}let S=p.charCodeAt(b);if(x){if(S===Je){b++;continue}if(S===P)x=!1;continue}if(S===ne||S===ae||S===xe){x=!0,P=S;continue}if(S===te||S===_||S===he||S===de)v++;else if(S===ye||S===J||S===Ee||S===ue&&!(b>0&&p.charCodeAt(b-1)===we))v--;else if(S===tt&&v===0)y.push(p.slice($,b).trim()),$=b+1}for(let b of y){let S=b.startsWith("public ")||b.startsWith("public\t"),k=b.startsWith("protected ")||b.startsWith("protected\t"),N=b.startsWith("private ")||b.startsWith("private\t"),G=b.includes("readonly ");if(!S&&!k&&!N&&!G)continue;if(N)continue;let W=b,M=[];if(S){let be=6;while(be<W.length&&Me(W.charCodeAt(be)))be++;W=W.slice(be),M.push("public")}if(k){let be=9;while(be<W.length&&Me(W.charCodeAt(be)))be++;W=W.slice(be),M.push("protected")}if(G){let be=W.indexOf("readonly ");if(be!==-1){let xt=be+8;while(xt<W.length&&Me(W.charCodeAt(xt)))xt++;W=W.slice(0,be)+W.slice(xt)}M.push("readonly")}let F=M.length>0?`${M.join(" ")} `:"",V=Es(W);h.push(` ${F}${V};`)}}function Ji(m=" "){if(l>=o||i.charCodeAt(l)!==_)return"{}";l++;let h=[];while(l<o){if(d(),l>=o)break;if(i.charCodeAt(l)===J){l++;break}if(i.charCodeAt(l)===Z){l++;continue}let p=!1;if(T("export"))p=!0,l+=6,d();if(T("declare"))l+=7,d();let y=p?"export ":"";if(T("function")||T("async")&&cc("async","function")){let $=!1;if(T("async"))$=!0,l+=5,d();if(l+=8,d(),l<o&&i.charCodeAt(l)===ve)l++,d();let v=L();d();let x=lt();d();let P=St();d();let b=or();if(!b)b=$?"Promise<void>":"void";if(d(),l<o&&i.charCodeAt(l)===_)X(_,J);else if(l<o&&i.charCodeAt(l)===Z)l++;let S=Nt(P);h.push(`${m}${y}function ${v}${x}${S}: ${b};`)}else if(T("const")||T("let")||T("var")){let $=T("const")?"const":T("let")?"let":"var";l+=$.length,d();let v=L();if(!v){se();continue}d();let x="";if(l<o&&i.charCodeAt(l)===et){l++,d();let b=l,S=0;while(l<o){if(A())continue;let k=i.charCodeAt(l);if(k===te||k===_||k===he||k===de)S++;else if(k===ye||k===J||k===Ee||k===ue&&!ee())S--;else if(S===0&&(k===Z||k===tt))break;else if(S===0&&k===we&&!vt())break;if(S===0&&U())break;l++}x=g(b,l)}let P="";if(l<o&&i.charCodeAt(l)===we){l++,d();let b=l,S=0;while(l<o){if(A())continue;let k=i.charCodeAt(l);if(k===te||k===_||k===he||k===de)S++;else if(k===ye||k===J||k===Ee||k===ue&&!ee())S--;else if(S===0&&(k===Z||k===tt))break;if(S===0&&U())break;l++}P=g(b,l)}if(l<o&&i.charCodeAt(l)===Z)l++;if(!x&&P){let b=Rr(P);if(b)x=b;else if($==="const")x=Bi(P);else x=Gi(P)}if(!x)x="unknown";h.push(`${m}${y}${$} ${v}: ${x};`)}else if(T("interface")){l+=9,d();let $=L();d();let v=lt();d();let x="";if(T("extends")){l+=7,d();let b=l,S=0;while(l<o){if(A())continue;let k=i.charCodeAt(l);if(k===de)S++;else if(k===ue&&!ee())S--;else if(k===_&&S===0)break;l++}x=g(b,l)}let P=$s(Wi());h.push(`${m}${y}interface ${$}${v}${x?` extends ${x}`:""} ${P}`)}else if(T("type")){l+=4,d();let $=L();d();let v=lt();if(d(),l<o&&i.charCodeAt(l)===we){l++,d();let x=l,P=0;while(l<o){if(A())continue;let S=i.charCodeAt(l);if(S===te||S===_||S===he||S===de)P++;else if(S===ye||S===J||S===Ee||S===ue&&!ee())P--;else if(P===0&&S===Z)break;if(P===0&&U())break;l++}let b=g(x,l);if(l<o&&i.charCodeAt(l)===Z)l++;h.push(`${m}${y}type ${$}${v} = ${b}`)}}else if(T("class")){l+=5,d();let $=L();d();let v=lt();d();let x=l,P=0;while(l<o){if(A())continue;let N=i.charCodeAt(l);if(N===de)P++;else if(N===ue&&!ee())P--;else if(N===_&&P===0)break;l++}let b=g(x,l),S=b?` ${b}`:"",k=Hi();h.push(`${m}${y}class ${$}${v}${S} ${k}`)}else if(T("enum")){l+=4,d();let $=L();d();let v=Wi();h.push(`${m}${y}enum ${$} ${v}`)}else if(T("namespace")||T("module")){let $=T("namespace")?"namespace":"module";l+=$.length,d();let v=L();d();let x=Ji(m);h.push(`${m}${y}${$} ${v} ${x}`)}else if(T("abstract"))if(l+=8,d(),T("class")){l+=5,d();let $=L();d();let v=lt();d();let x=l,P=0;while(l<o){if(A())continue;let N=i.charCodeAt(l);if(N===de)P++;else if(N===ue&&!ee())P--;else if(N===_&&P===0)break;l++}let b=g(x,l),S=b?` ${b}`:"",k=Hi();h.push(`${m}${y}abstract class ${$}${v}${S} ${k}`)}else se();else if(p&&T("default")){l+=7,d();let $=l;se();let v=g($,l);if(v.charCodeAt(v.length-1)===Z)v=v.slice(0,-1);if(v)h.push(`${m}export default ${v};`)}else if(!p&&(i.charCodeAt(l)===ne||i.charCodeAt(l)===ae||i.charCodeAt(l)===xe))se();else se()}if(h.length===0)return"{}";return`{
125
+ }`}function Ji(){if(l>=o)return"";let p=i.charCodeAt(l);if(p===de){let h=l;return Pe(de,be),i.slice(h,l)}if(p===Ai)return l++,`#${W()}`;return W()}function Ts(p){let h=l+p.length;while(h<o&&Fe(i.charCodeAt(h)))h++;return h<o?i.charCodeAt(h):0}function Ui(){let p=0;while(l<o){if(x())continue;let h=i.charCodeAt(l);if(h===_||h===Q)p++;else if(h===U||h===Ce){if(p===0)return;p--}else if(h===Z&&p===0){l++;return}if(p===0&&te())return;l++}}function Rs(p,h,m,y,w,E){Os(p,h,m,y,!1,!1,w,E)}function Os(p,h,m,y,w,E,A,O){if(d(),l>=o)return;let S=i.charCodeAt(l),b=!1;if(S===bi)b=!0,l++,d();if(l<o&&i.charCodeAt(l)===33)l++,d();let k=l<o?i.charCodeAt(l):0;if(k===Q||k===me){let N=k===me?lt():"";d();let G=vt();d();let L=lr(),M=L.length>0;if(!L)if(A&&w)L="AsyncGenerator<unknown, void, unknown>";else if(w)L="Generator<unknown, void, unknown>";else if(A)L="Promise<void>";else L="void";if(d(),l<o&&i.charCodeAt(l)===_){let Ae=l+1;if(Pe(_,U),!a&&!M&&!w)L=Cr(i.slice(Ae,l-1),A,G)}else if(l<o&&i.charCodeAt(l)===Z)l++;let F=Ft(G),V=b?"?":"";O.push(`${h}${p}${V}${N}${F}: ${L};`)}else if(k===tt||k===$e||k===Z||k===U||k===ne||k===pe){let N="";if(k===tt){l++,d();let M=l,F=0;while(l<o){if(x())continue;let V=i.charCodeAt(l);if(V===Q||V===_||V===de||V===me)F++;else if(V===Ce||V===U||V===be||V===he&&!ke()){if(F===0)break;F--}else if(F===0&&(V===Z||V===rt))break;else if(F===0&&V===$e&&!ut())break;if(F===0&&te())break;l++}N=g(M,l)}let G="";if(l<o&&i.charCodeAt(l)===$e)if(a&&N){l++;let M=0;while(l<o){if(x())continue;let F=i.charCodeAt(l);if(F===Q||F===_||F===de)M++;else if(F===Ce||F===U||F===be){if(M===0&&F===U)break;M--}else if(M===0&&F===Z)break;if(M===0&&te())break;l++}}else{l++,d();let M=l,F=0;while(l<o){if(x())continue;let V=i.charCodeAt(l);if(V===Q||V===_||V===de)F++;else if(V===Ce||V===U||V===be){if(F===0&&V===U)break;F--}else if(F===0&&V===Z)break;if(F===0&&te())break;l++}G=g(M,l)}if(l<o&&i.charCodeAt(l)===Z)l++;if(!N)if(G){let M=Pr(G);if(M)N=M;else N=G.endsWith("as const")||m&&y?_i(G):Vi(G)}else N="unknown";let L=b?"?":"";O.push(`${h}${p}${L}: ${N};`)}else Ui()}function uc(p,h){let m=p.slice(1,-1).trim();if(!m)return;let y=[],w=0,E=0,A=!1,O=0;for(let S=0;S<=m.length;S++){if(S===m.length){y.push(m.slice(w).trim());break}let b=m.charCodeAt(S);if(A){if(b===Je){S++;continue}if(b===O)A=!1;continue}if(b===ie||b===oe||b===Te){A=!0,O=b;continue}if(b===Q||b===_||b===de||b===me)E++;else if(b===Ce||b===U||b===be||b===he&&!(S>0&&m.charCodeAt(S-1)===$e))E--;else if(b===rt&&E===0)y.push(m.slice(w,S).trim()),w=S+1}for(let S of y){let b=S.startsWith("public ")||S.startsWith("public\t"),k=S.startsWith("protected ")||S.startsWith("protected\t"),N=S.startsWith("private ")||S.startsWith("private\t"),G=S.includes("readonly ");if(!b&&!k&&!N&&!G)continue;if(N)continue;let L=S,M=[];if(b){let Ae=6;while(Ae<L.length&&Fe(L.charCodeAt(Ae)))Ae++;L=L.slice(Ae),M.push("public")}if(k){let Ae=9;while(Ae<L.length&&Fe(L.charCodeAt(Ae)))Ae++;L=L.slice(Ae),M.push("protected")}if(G){let Ae=L.indexOf("readonly ");if(Ae!==-1){let Gt=Ae+8;while(Gt<L.length&&Fe(L.charCodeAt(Gt)))Gt++;L=L.slice(0,Ae)+L.slice(Gt)}M.push("readonly")}let F=M.length>0?`${M.join(" ")} `:"",V=bs(L);h.push(` ${F}${V};`)}}function Yi(p=" "){if(l>=o||i.charCodeAt(l)!==_)return"{}";l++;let h=[];while(l<o){if(d(),l>=o)break;if(i.charCodeAt(l)===U){l++;break}if(i.charCodeAt(l)===Z){l++;continue}let m=!1;if(T("export"))m=!0,l+=6,d();if(T("declare"))l+=7,d();let y=m?"export ":"";if(T("function")||T("async")&&hc("async","function")){let w=!1;if(T("async"))w=!0,l+=5,d();if(l+=8,d(),l<o&&i.charCodeAt(l)===we)l++,d();let E=W();d();let A=lt();d();let O=vt();d();let S=lr();if(!S)S=w?"Promise<void>":"void";if(d(),l<o&&i.charCodeAt(l)===_)Pe(_,U);else if(l<o&&i.charCodeAt(l)===Z)l++;let b=Ft(O);h.push(`${p}${y}function ${E}${A}${b}: ${S};`)}else if(T("const")||T("let")||T("var")){let w=T("const")?"const":T("let")?"let":"var";l+=w.length,d();let E=W();if(!E){z();continue}d();let A="";if(l<o&&i.charCodeAt(l)===tt){l++,d();let S=l,b=0;while(l<o){if(x())continue;let k=i.charCodeAt(l);if(k===Q||k===_||k===de||k===me)b++;else if(k===Ce||k===U||k===be||k===he&&!ke())b--;else if(b===0&&(k===Z||k===rt))break;else if(b===0&&k===$e&&!ut())break;if(b===0&&Y())break;l++}A=g(S,l)}let O="";if(l<o&&i.charCodeAt(l)===$e){l++,d();let S=l,b=0;while(l<o){if(x())continue;let k=i.charCodeAt(l);if(k===Q||k===_||k===de||k===me)b++;else if(k===Ce||k===U||k===be||k===he&&!ke())b--;else if(b===0&&(k===Z||k===rt))break;if(b===0&&Y())break;l++}O=g(S,l)}if(l<o&&i.charCodeAt(l)===Z)l++;if(!A&&O){let S=Pr(O);if(S)A=S;else if(w==="const")A=_i(O);else A=Vi(O)}if(!A)A="unknown";h.push(`${p}${y}${w} ${E}: ${A};`)}else if(T("interface")){l+=9,d();let w=W();d();let E=lt();d();let A="";if(T("extends")){l+=7,d();let S=l,b=0;while(l<o){if(x())continue;let k=i.charCodeAt(l);if(k===me)b++;else if(k===he&&!ke())b--;else if(k===_&&b===0)break;l++}A=g(S,l)}let O=Ss(Bi());h.push(`${p}${y}interface ${w}${E}${A?` extends ${A}`:""} ${O}`)}else if(T("type")){l+=4,d();let w=W();d();let E=lt();if(d(),l<o&&i.charCodeAt(l)===$e){l++,d();let A=l,O=0;while(l<o){if(x())continue;let b=i.charCodeAt(l);if(b===Q||b===_||b===de||b===me)O++;else if(b===Ce||b===U||b===be||b===he&&!ke())O--;else if(O===0&&b===Z)break;if(O===0&&Y())break;l++}let S=g(A,l);if(l<o&&i.charCodeAt(l)===Z)l++;h.push(`${p}${y}type ${w}${E} = ${S}`)}}else if(T("class")){l+=5,d();let w=W();d();let E=lt();d();let A=l,O=0;while(l<o){if(x())continue;let N=i.charCodeAt(l);if(N===me)O++;else if(N===he&&!ke())O--;else if(N===_&&O===0)break;l++}let S=g(A,l),b=S?` ${S}`:"",k=Ki();h.push(`${p}${y}class ${w}${E}${b} ${k}`)}else if(T("enum")){l+=4,d();let w=W();d();let E=Bi();h.push(`${p}${y}enum ${w} ${E}`)}else if(T("namespace")||T("module")){let w=T("namespace")?"namespace":"module";l+=w.length,d();let E=W();d();let A=Yi(p);h.push(`${p}${y}${w} ${E} ${A}`)}else if(T("abstract"))if(l+=8,d(),T("class")){l+=5,d();let w=W();d();let E=lt();d();let A=l,O=0;while(l<o){if(x())continue;let N=i.charCodeAt(l);if(N===me)O++;else if(N===he&&!ke())O--;else if(N===_&&O===0)break;l++}let S=g(A,l),b=S?` ${S}`:"",k=Ki();h.push(`${p}${y}abstract class ${w}${E}${b} ${k}`)}else z();else if(m&&T("default")){l+=7,d();let w=l;z();let E=g(w,l);if(E.charCodeAt(E.length-1)===Z)E=E.slice(0,-1);if(E)h.push(`${p}export default ${E};`)}else if(!m&&(i.charCodeAt(l)===ie||i.charCodeAt(l)===oe||i.charCodeAt(l)===Te))z();else z()}if(h.length===0)return"{}";return`{
124
126
  ${h.join(`
125
127
  `)}
126
- }`}function cc(m,h){let p=l+m.length;while(p<o&&Me(i.charCodeAt(p)))p++;for(let y=0;y<h.length;y++)if(p+y>=o||i.charCodeAt(p+y)!==h.charCodeAt(y))return!1;return p+h.length>=o||!Ke(i.charCodeAt(p+h.length))}function Gt(m,h,p){l+=p.length,d();let y="",$=i.charCodeAt(l);if($===ne||$===ae){let S=l;E($),y=i.slice(S,l)}else{y=L();while(l<o&&i.charCodeAt(l)===ct)l++,y+=`.${L()}`}d();let v=l<o&&i.charCodeAt(l)===_?Ji():"{}",x=`${h?"export ":""}declare ${p} ${y} ${v}`,P=Ve(m),b=y.startsWith("'")||y.startsWith('"');return{kind:"module",name:y,text:x,isExported:h,source:b?y.slice(1,-1):void 0,leadingComments:P,start:m,end:l}}function Ts(m,h){se();let p=g(h,l);if(p.charCodeAt(p.length-1)===Z)p=p.slice(0,-1).trimEnd();if(!p)return;let y=Dt(p.charCodeAt(0));for(let S=1;y&&S<p.length;S++)y=Ke(p.charCodeAt(S));let $=Ve(m);if(y){c.push({kind:"export",name:"default",text:`export default ${p};`,isExported:!0,isTypeOnly:!1,leadingComments:$,start:m,end:l});return}let v="__dtsx_default_export__",x=1;while(i.includes(v))v=`__dtsx_default_export_${x++}__`;let P=Rr(p)||Ae(p,!1),b=P==="unknown"&&Ah(p)?`typeof ${p}`:P;c.push({kind:"variable",name:v,text:`declare const ${v}: ${b};`,isExported:!1,typeAnnotation:b,modifiers:["const"],start:m,end:l}),c.push({kind:"export",name:"default",text:`export default ${v};`,isExported:!0,isTypeOnly:!1,leadingComments:$,start:m,end:l})}while(l<o){if(d(),l>=o)break;let m=l,h=i.charCodeAt(l);if(h===105&&T("import"))c.push(rc(m));else if(h===101&&T("export")){l+=6,d();let p=i.charCodeAt(l);if(p===100&&T("default")){l+=7,d();let y=l,$=i.charCodeAt(l);if($===102&&T("function")){let v=bt(m,!0,!1,!0);if(v)c.push(v)}else if($===97&&T("async")&&bs("async")!==Z)if(l+=5,d(),T("function")){let v=bt(m,!0,!0,!0);if(v)c.push(v)}else Ts(m,y);else if($===99&&T("class")){let v=At(m,!0,!1,!0);c.push(v)}else if($===97&&T("abstract")){if(l+=8,d(),T("class")){let v=At(m,!0,!0,!0);c.push(v)}}else Ts(m,y)}else if(p===116&&T("type")){let y=l;if(l+=4,d(),l<o&&i.charCodeAt(l)===_){Be();let $=g(m,l),v=Ve(m);c.push({kind:"export",name:"",text:$,isExported:!0,isTypeOnly:!0,source:ut($),leadingComments:v,start:m,end:l})}else if(l<o&&i.charCodeAt(l)===ve){ot();let $=g(m,l);c.push({kind:"export",name:"",text:$,isExported:!0,isTypeOnly:!0,source:ut($),start:m,end:l})}else{l=y;let $=_i(m,!0);c.push($)}}else if(p===105&&T("interface")){let y=Vi(m,!0);c.push(y)}else if(p===102&&T("function")){let y=bt(m,!0,!1,!1);if(y)c.push(y)}else if(p===97&&T("async"))if(l+=5,d(),T("function")){let y=bt(m,!0,!0,!1);if(y)c.push(y)}else se();else if(p===99)if(T("class")){let y=At(m,!0,!1);c.push(y)}else if(T("const")){let y=l;if(l+=5,d(),T("enum")){l=y+5,d();let $=Wt(m,!0,!0);c.push($)}else{l=y;let $=Lt(m,"const",!0);for(let v=0;v<$.length;v++)c.push($[v])}}else se();else if(p===97&&T("abstract")){if(l+=8,d(),T("class")){let y=At(m,!0,!0);c.push(y)}}else if(p===108&&T("let")){let y=Lt(m,"let",!0);for(let $=0;$<y.length;$++)c.push(y[$])}else if(p===118&&T("var")){let y=Lt(m,"var",!0);for(let $=0;$<y.length;$++)c.push(y[$])}else if(p===101&&T("enum")){let y=Wt(m,!0,!1);c.push(y)}else if(p===100&&T("declare"))l+=7,d(),Rs(m,!0);else if(p===110&&T("namespace")&&D(9)){let y=Gt(m,!0,"namespace");c.push(y)}else if(p===109&&T("module")&&D(6)){let y=Gt(m,!0,"module");c.push(y)}else if(p===_){Be();let y=g(m,l),$=y.includes("export type"),v=Ve(m);c.push({kind:"export",name:"",text:y,isExported:!0,isTypeOnly:$,source:ut(y),leadingComments:v,start:m,end:l})}else if(p===ve){ot();let y=g(m,l),$=Ve(m);c.push({kind:"export",name:"",text:y,isExported:!0,isTypeOnly:!1,source:ut(y),leadingComments:$,start:m,end:l})}else{se();let y=g(m,l);if(y)c.push({kind:"export",name:"",text:y,isExported:!0,start:m,end:l})}}else if(h===100&&T("declare"))l+=7,d(),Rs(m,!1);else if(h===105&&T("interface")){let p=Vi(m,!1);f.set(p.name,p)}else if(h===116&&T("type")){let p=_i(m,!1);f.set(p.name,p),c.push(p)}else if(h===102&&T("function")){let p=bt(m,!1,!1,!1);if(p)f.set(p.name,p);else se()}else if(h===97)if(T("async")){let p=l;if(l+=5,d(),T("function")){let y=bt(m,!1,!0,!1);if(y)f.set(y.name,y);else l=p,se()}else l=p,se()}else if(T("abstract"))if(l+=8,d(),T("class")){let p=At(m,!1,!1);f.set(p.name,p),c.push(p)}else se();else l++,se();else if(h===99)if(T("class")){let p=At(m,!1,!1);f.set(p.name,p),c.push(p)}else if(T("const")){let p=l;if(l+=5,d(),T("enum")){l=p+5,d();let y=Wt(m,!1,!0);f.set(y.name,y),c.push(y)}else{l=p;let y=Lt(m,"const",!1);for(let $=0;$<y.length;$++)f.set(y[$].name,y[$])}}else l++,se();else if(h===101&&T("enum")){let p=Wt(m,!1,!1);f.set(p.name,p),c.push(p)}else if(h===108&&T("let"))se();else if(h===118&&T("var"))se();else if(h===109&&T("module")&&D(6)){let p=Gt(m,!1,"module");c.push(p)}else if(h===110&&T("namespace")&&D(9)){let p=Gt(m,!1,"namespace");c.push(p)}else{let p=i.charCodeAt(l);if(p===Z)l++;else if(p===ne||p===ae){if(E(p),l<o&&i.charCodeAt(l)===Z)l++}else if(p===xe){if(C(),l<o&&i.charCodeAt(l)===Z)l++}else if(p===Sh){if(l++,L(),d(),l<o&&i.charCodeAt(l)===ct)l++,L(),d();if(l<o&&i.charCodeAt(l)===te)X(te,ye)}else l++,se()}}if(f.size>0)Th(c,f);if(u.size>0){let m=new Map;for(let p of c)if(p.kind==="function")m.set(p.name,(m.get(p.name)||0)+1);let h=new Set;for(let[p,y]of m)if(y>1)h.add(p);if(h.size>0){let p=new Set;for(let y of h)for(let $=c.length-1;$>=0;$--)if(c[$].kind==="function"&&c[$].name===y&&u.has($)){p.add($);break}if(p.size>0){let y=[...p].sort(($,v)=>v-$);for(let $ of y)c.splice($,1)}}}return c;function Rs(m,h){if(T("function")){let p=bt(m,h,!1,!1);if(p)c.push(p)}else if(T("async")){if(l+=5,d(),T("function")){let p=bt(m,h,!0,!1);if(p)c.push(p)}}else if(T("class")){let p=At(m,h,!1);c.push(p)}else if(T("abstract")){if(l+=8,d(),T("class")){let p=At(m,h,!0);c.push(p)}}else if(T("interface")){let p=Vi(m,h);c.push(p)}else if(T("type")){let p=_i(m,h);c.push(p)}else if(T("enum")){let p=Wt(m,h,!1);c.push(p)}else if(T("const")){let p=l;if(l+=5,d(),T("enum")){l=p+5,d();let y=Wt(m,h,!0);c.push(y)}else if(h){l=p;let y=Lt(m,"const",!0);for(let $=0;$<y.length;$++)c.push(y[$])}else se()}else if(T("let")||T("var"))if(h){let p=T("let")?"let":"var",y=Lt(m,p,!0);for(let $=0;$<y.length;$++)c.push(y[$])}else se();else if(T("module")){let p=Gt(m,h,"module");c.push(p)}else if(T("namespace")){let p=Gt(m,h,"namespace");c.push(p)}else if(T("global")){l+=6,d();let p=`declare global ${l<o&&i.charCodeAt(l)===_?Ji():"{}"}`,y=Ve(m);c.push({kind:"module",name:"global",text:p,isExported:!1,leadingComments:y,start:m,end:l})}else se()}}function Ko(e,t){let r=0,n=e.length;while(r<n){let i=e.charCodeAt(r);if(i>=65&&i<=90||i>=97&&i<=122||i===95||i===36||i>127){let s=r;r++;while(r<n){let a=e.charCodeAt(r);if(a>=65&&a<=90||a>=97&&a<=122||a>=48&&a<=57||a===95||a===36||a>127)r++;else break}t.add(e.substring(s,r))}else r++}}function Jo(e,t){let r=0;while(r<e.length){let n=e.charCodeAt(r);if(n===ne||n===ae||n===xe){let u=n;r++;while(r<e.length)if(e.charCodeAt(r)===Je)r+=2;else if(e.charCodeAt(r++)===u)break;continue}if(n===Y&&e.charCodeAt(r+1)===Y){r+=2;while(r<e.length&&e.charCodeAt(r)!==Ce&&e.charCodeAt(r)!==Se)r++;continue}if(n===Y&&e.charCodeAt(r+1)===ve){let u=e.indexOf("*/",r+2);r=u===-1?e.length:u+2;continue}if(!Dt(n)){r++;continue}let i=r++;while(r<e.length&&Ke(e.charCodeAt(r)))r++;let s=i-1,a=r;while(s>=0&&Me(e.charCodeAt(s)))s--;while(a<e.length&&Me(e.charCodeAt(a)))a++;let o=s>=0?e.charCodeAt(s):0,c=a<e.length?e.charCodeAt(a):0,f=i>=3&&e.slice(i-3,i)==="...";if(c===et||o===ct&&!f)continue;if(c===te&&(o===_||o===tt))continue;t.add(e.slice(i,r))}}function Th(e,t){let r=new Set,n=new Set;for(let a of e)n.add(a.name);let i=new Set,s=[];for(let a=0;a<e.length;a++){let o=e[a];if(o.kind!=="import"){if(s.push(o.text),Ko(o.text,i),typeof o.value==="string")Jo(o.value,i)}}for(;;){let a=[];for(let[f,u]of t){if(r.has(f))continue;if(i.has(f)){if(!n.has(f))a.push(u),n.add(f);r.add(f)}}if(a.length===0)break;a.sort((f,u)=>(f.start??1/0)-(u.start??1/0));let o=[],c=0;for(let f=0;f<e.length;f++){let u=e[f].start??1/0;while(c<a.length&&(a[c].start??1/0)<=u)o.push(a[c++]);o.push(e[f])}while(c<a.length)o.push(a[c++]);e.length=0;for(let f=0;f<o.length;f++)e.push(o[f]);for(let f of a)if(f.kind!=="import"){if(s.push(f.text),Ko(f.text,i),typeof f.value==="string")Jo(f.value,i)}}}var Te=32,Re=9,Ce=10,Se=13,Y=47,ve=42,ne=39,ae=34,xe=96,Je=92,_=123,J=125,te=40,ye=41,he=91,Ee=93,de=60,ue=62,Z=59,et=58,we=61,tt=44,ct=46,vi=63,Si=35,Sh=64,Uo=36,bh=95,qn;var Xo=oe(()=>{Zn();qn=["public","protected","private","readonly","override"]});function Qo(e){return e.endsWith(".vue")}function Rh(e){let t={script:null,scriptSetup:null},r=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,n;while((n=r.exec(e))!==null){let i=n[1]||"",s=/lang\s*=\s*["']([^"']+)["']/i.exec(i)?.[1]?.toLowerCase()??"js",a={content:n[2]??"",attrs:i,setup:/\bsetup\b/.test(i),lang:s};if(a.setup)t.scriptSetup=a;else t.script=a}return t}function Ye(e,t){let r=e[t];t++;while(t<e.length){let n=e[t];if(n==="\\"){t+=2;continue}if(n===r)return t+1;t++}return t}function rt(e,t){t++;let r=0;while(t<e.length){let n=e[t];if(n==="\\"){t+=2;continue}if(n==="`"&&r===0)return t+1;if(n==="$"&&e[t+1]==="{"){r++,t+=2;continue}if(n==="}"){if(r>0)r--;t++;continue}t++}return t}function ft(e,t){if(e[t+1]==="/"){let r=e.indexOf(`
127
- `,t+2);return r===-1?e.length:r+1}if(e[t+1]==="*"){let r=e.indexOf("*/",t+2);return r===-1?e.length:r+2}return t+1}function zn(e,t){let r=e[t];if(r==='"'||r==="'")return Ye(e,t);if(r==="`")return rt(e,t);if(r==="/"&&(e[t+1]==="/"||e[t+1]==="*"))return ft(e,t);return t}function Qn(e){let t=e.split(""),r=0;while(r<e.length){let n=zn(e,r);if(n>r){for(let i=r;i<n;i++)if(t[i]!==`
128
- `&&t[i]!=="\r")t[i]=" ";r=n;continue}r++}return t.join("")}function Ne(e,t,r,n){let i=0,s=t;while(s<e.length){let a=e[s];if(a==='"'||a==="'"){s=Ye(e,s);continue}if(a==="`"){s=rt(e,s);continue}if(a==="/"&&(e[s+1]==="/"||e[s+1]==="*")){s=ft(e,s);continue}if(a===r)i++;else if(a===n){if(i--,i===0)return s}s++}return-1}function es(e,t){let r=0,n=t;while(n<e.length){let i=e[n];if(i==='"'||i==="'"){n=Ye(e,n);continue}if(i==="`"){n=rt(e,n);continue}if(i==="/"&&(e[n+1]==="/"||e[n+1]==="*")){n=ft(e,n);continue}if(i==="="&&e[n+1]===">"){n+=2;continue}if(i==="<")r++;else if(i===">"){if(r--,r===0)return n}n++}return-1}function ir(e,t=","){let r=[],n=0,i="",s=0;while(s<e.length){let a=e[s];if(a==='"'||a==="'"){let o=Ye(e,s);i+=e.slice(s,o),s=o;continue}if(a==="`"){let o=rt(e,s);i+=e.slice(s,o),s=o;continue}if(a==="/"&&(e[s+1]==="/"||e[s+1]==="*")){s=ft(e,s);continue}if(a==="{"||a==="["||a==="("||a==="<")n++;else if(a==="}"||a==="]"||a===")"||a===">")n--;if(a===t&&n===0){r.push(i),i="",s++;continue}i+=a,s++}if(i.trim()!=="")r.push(i);return r}function vr(e){let t=e.trim();if(!t.startsWith("{"))return[];let r=Ne(t,0,"{","}");if(r===-1)return[];let n=t.slice(1,r),i=[];for(let s of ir(n)){let a=-1,o=0;for(let u=0;u<s.length;u++){let l=s[u];if(l==='"'||l==="'"){u=Ye(s,u)-1;continue}if(l==="`"){u=rt(s,u)-1;continue}if(l==="{"||l==="["||l==="("||l==="<")o++;else if(l==="}"||l==="]"||l===")"||l===">")o--;else if(l===":"&&o===0){a=u;break}}if(a!==-1){i.push({key:$r(s.slice(0,a).trim()),value:s.slice(a+1).trim(),isMethod:!1});continue}let c=/^([A-Za-z_$][\w$]*|['"][^'"]+['"])\s*\(/.exec(s.trim());if(c){i.push({key:$r(c[1]),value:s.trim(),isMethod:!0});continue}let f=s.trim();if(f)i.push({key:$r(f),value:"",isMethod:!1})}return i}function $r(e){if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);return e}function Er(e){return/^[A-Za-z_$][\w$]*$/.test(e)?e:JSON.stringify(e)}function Sr(e,t){let r=new RegExp(`\\b${t}\\b`,"g"),n;while((n=r.exec(e))!==null){let i=n.index+n[0].length;while(i<e.length&&/\s/.test(e[i]))i++;let s=null;if(e[i]==="<"){let c=es(e,i);if(c===-1)return null;s=e.slice(i+1,c).trim(),i=c+1;while(i<e.length&&/\s/.test(e[i]))i++}if(e[i]!=="(")continue;let a=Ne(e,i,"(",")");if(a===-1)return null;let o=ir(e.slice(i+1,a));return{generic:s,arg:o.length>0?o[0].trim():null}}return null}function Oh(e,t){let r=el(e,t);if(!r)return null;return r.kind==="interface"?e.slice(r.bodyStart,r.end):e.slice(r.bodyStart,r.end).trim()}function el(e,t){let r=new RegExp(`\\binterface\\s+${t}\\b[^{]*\\{`,"m").exec(e);if(r){let i=r.index+r[0].length-1,s=Ne(e,i,"{","}");if(s!==-1)return{kind:"interface",start:r.index,end:s+1,bodyStart:i}}let n=new RegExp(`\\btype\\s+${t}\\b[^=]*=`,"m").exec(e);if(n){let i=n.index+n[0].length,s=0,a=i;while(i<e.length){let o=e[i];if(o==='"'||o==="'"){i=Ye(e,i);continue}if(o==="`"){i=rt(e,i);continue}if(o==="{"||o==="["||o==="("||o==="<")s++;else if(o==="}"||o==="]"||o===")"||o===">")s--;else if((o===";"||o===`
129
- `)&&s===0)break;i++}return{kind:"type",start:n.index,end:i,bodyStart:a}}return null}function Ph(e){let t=e.search(/\bas\s+PropType\s*</);if(t===-1)return null;let r=e.indexOf("<",t),n=es(e,r);if(n===-1)return null;if(e.slice(n+1).trim()!=="")return null;return e.slice(r+1,n).trim()}function Xn(e){let t=e.trim(),r=Ph(t);if(r!==null)return{type:r,optional:!0};if(t==="null")return{type:"unknown",optional:!0};if(t.startsWith("[")){let n=Ne(t,0,"[","]");if(n!==-1){let i=ir(t.slice(1,n)).map((s)=>Xn(s).type).filter((s)=>s!=="unknown");return{type:i.length>0?[...new Set(i)].join(" | "):"unknown",optional:!0}}}if(t.startsWith("{")){let n=vr(t),i=n.find((c)=>c.key==="type"),s=n.find((c)=>c.key==="required"),a=i?Xn(i.value).type:"unknown",o=!(s&&s.value.trim()==="true");return{type:a,optional:o}}if(zo[t])return{type:zo[t],optional:!0};if(/^[A-Za-z_$][\w$.]*$/.test(t))return{type:t,optional:!0};return{type:"unknown",optional:!0}}function Ri(e){let t=e.trim();if(t.startsWith("{")){let r=vr(t);if(r.length===0)return"{}";return`{ ${r.map((n)=>{if(n.isMethod||n.value==="")return`${Er(n.key)}?: unknown`;let i=Xn(n.value);return`${Er(n.key)}${i.optional?"?":""}: ${i.type}`}).join(", ")} }`}if(t.startsWith("[")){let r=Ne(t,0,"[","]");if(r===-1)return null;let n=ir(t.slice(1,r)).map((i)=>$r(i.trim())).filter((i)=>i!=="");if(n.length===0)return"{}";return`{ ${n.map((i)=>`${Er(i)}?: unknown`).join(", ")} }`}return null}function kh(e){let t=e.trim();if(!t.startsWith("["))return null;let r=Ne(t,0,"[","]");if(r===-1)return null;let n=ir(t.slice(1,r)).map((i)=>i.trim());if(n.length===0)return"{}";if(!n.every((i)=>i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"')))return"string[]";return`[${n.map((i)=>JSON.stringify($r(i))).join(", ")}]`}function Mh(e){let t=e.trim();if(!t.startsWith("{"))return null;let r=vr(t);if(r.length===0)return"{}";return`{ ${r.map((n)=>`${JSON.stringify(n.key)}: (...args: any[]) => void`).join(", ")} }`}function tl(e){return kh(e)??Mh(e)}function Ih(e){let t=[],r=0,n="",i=0;while(i<e.length){let s=e[i];if(s==='"'||s==="'"){let a=Ye(e,i);n+=e.slice(i,a),i=a;continue}if(s==="`"){let a=rt(e,i);n+=e.slice(i,a),i=a;continue}if(s==="/"&&(e[i+1]==="/"||e[i+1]==="*")){let a=ft(e,i);n+=e.slice(i,a),i=a;continue}if(s==="="&&e[i+1]===">"){n+="=>",i+=2;continue}if(s==="{"||s==="["||s==="("||s==="<")r++;else if(s==="}"||s==="]"||s===")"||s===">")r--;if((s===";"||s===","||s===`
130
- `)&&r===0){if(n.trim()!=="")t.push(n.trim());n="",i++;continue}n+=s,i++}if(n.trim()!=="")t.push(n.trim());return t}function Dh(e){let t=e.trim();if(!t.startsWith("{"))return null;let r=Ne(t,0,"{","}");if(r===-1||t.slice(r+1).trim()!=="")return null;let n=Ih(t.slice(1,r));if(n.length===0)return"{}";let i=[];for(let s of n){let a=/^\(\s*\w+\s*:\s*/.exec(s);if(!a)return null;let o=a[0].length,c=s[o];if(c!=="'"&&c!=='"'&&c!=="`")return null;let f=Ye(s,o),u=s.slice(o+1,f-1),l=Ne(s,s.indexOf("(",0),"(",")");if(l===-1)return null;let g=s.slice(o,l),d=ir(g).slice(1),w=s.slice(l+1).trim();if(w.startsWith(":"))w=w.slice(1).trim();if(w==="")w="void";i.push(`${JSON.stringify(u)}: (${d.map((E)=>E.trim()).join(", ")}) => ${w}`)}return`{ ${i.join(", ")} }`}function ts(e){let t=e;for(let r of["defineProps","defineEmits","defineExpose","defineSlots","defineOptions"])t=Fh(t,r);return t}function Fh(e,t){let r=new RegExp(`\\b${t}\\b`,"g"),n=[],i=e,s;while((s=r.exec(e))!==null){let a=e.lastIndexOf(`
131
- `,s.index)+1,o=e.slice(a,s.index),c=/^\s*(?:(?:const|let|var)\s+[A-Za-z_$][\w$]*\s*(?::[^=]+)?=\s*)?(withDefaults\s*\(\s*)?$/.exec(o);if(!c)continue;let f=s.index+s[0].length;while(f<e.length&&/\s/.test(e[f]))f++;if(e[f]==="<"){let g=es(e,f);if(g===-1)continue;f=g+1;while(f<e.length&&/\s/.test(e[f]))f++}if(e[f]!=="(")continue;let u=Ne(e,f,"(",")");if(u===-1)continue;if(c[1]){let g=a+o.length-c[1].length,d=e.indexOf("(",g);if(d!==-1){let w=Ne(e,d,"(",")");if(w!==-1)u=w}}let l=u+1;while(l<e.length&&e[l]!==`
128
+ }`}function hc(p,h){let m=l+p.length;while(m<o&&Fe(i.charCodeAt(m)))m++;for(let y=0;y<h.length;y++)if(m+y>=o||i.charCodeAt(m+y)!==h.charCodeAt(y))return!1;return m+h.length>=o||!Ke(i.charCodeAt(m+h.length))}function Lt(p,h,m){l+=m.length,d();let y="",w=i.charCodeAt(l);if(w===ie||w===oe){let b=l;v(w),y=i.slice(b,l)}else{y=W();while(l<o&&i.charCodeAt(l)===ct)l++,y+=`.${W()}`}d();let E=l<o&&i.charCodeAt(l)===_?Yi():"{}",A=`${h?"export ":""}declare ${m} ${y} ${E}`,O=Ue(p),S=y.startsWith("'")||y.startsWith('"');return{kind:"module",name:y,text:A,isExported:h,source:S?y.slice(1,-1):void 0,leadingComments:O,start:p,end:l}}function Ps(p,h){z();let m=g(h,l);if(m.charCodeAt(m.length-1)===Z)m=m.slice(0,-1).trimEnd();if(!m)return;let y=kt(m.charCodeAt(0));for(let b=1;y&&b<m.length;b++)y=Ke(m.charCodeAt(b));let w=Ue(p);if(y){c.push({kind:"export",name:"default",text:`export default ${m};`,isExported:!0,isTypeOnly:!1,leadingComments:w,start:p,end:l});return}let E="__dtsx_default_export__",A=1;while(i.includes(E))E=`__dtsx_default_export_${A++}__`;let O=Pr(m)||xe(m,!1),S=O==="unknown"&&Rh(m)?`typeof ${m}`:O;c.push({kind:"variable",name:E,text:`declare const ${E}: ${S};`,isExported:!1,typeAnnotation:S,modifiers:["const"],start:p,end:l}),c.push({kind:"export",name:"default",text:`export default ${E};`,isExported:!0,isTypeOnly:!1,leadingComments:w,start:p,end:l})}while(l<o){if(d(),l>=o)break;let p=l,h=i.charCodeAt(l);if(h===105&&T("import"))c.push(sc(p));else if(h===101&&T("export")){l+=6,d();let m=i.charCodeAt(l);if(m===100&&T("default")){l+=7,d();let y=l,w=i.charCodeAt(l);if(w===102&&T("function")){let E=St(p,!0,!1,!0);if(E)c.push(E)}else if(w===97&&T("async")&&Ts("async")!==Z)if(l+=5,d(),T("function")){let E=St(p,!0,!0,!0);if(E)c.push(E)}else Ps(p,y);else if(w===99&&T("class")){let E=bt(p,!0,!1,!0);c.push(E)}else if(w===97&&T("abstract")){if(l+=8,d(),T("class")){let E=bt(p,!0,!0,!0);c.push(E)}}else Ps(p,y)}else if(m===116&&T("type")){let y=l;if(l+=4,d(),l<o&&i.charCodeAt(l)===_){or();let w=g(p,l),E=Ue(p);c.push({kind:"export",name:"",text:w,isExported:!0,isTypeOnly:!0,source:Or(w),leadingComments:E,start:p,end:l})}else if(l<o&&i.charCodeAt(l)===we){Es();let w=g(p,l);c.push({kind:"export",name:"",text:w,isExported:!0,isTypeOnly:!0,source:Or(w),start:p,end:l})}else{l=y;let w=ji(p,!0);c.push(w)}}else if(m===105&&T("interface")){let y=Hi(p,!0);c.push(y)}else if(m===102&&T("function")){let y=St(p,!0,!1,!1);if(y)c.push(y)}else if(m===97&&T("async"))if(l+=5,d(),T("function")){let y=St(p,!0,!0,!1);if(y)c.push(y)}else z();else if(m===99)if(T("class")){let y=bt(p,!0,!1);c.push(y)}else if(T("const")){let y=l;if(l+=5,d(),T("enum")){l=y+5,d();let w=Wt(p,!0,!0);c.push(w)}else{l=y;let w=Nt(p,"const",!0);for(let E=0;E<w.length;E++)c.push(w[E])}}else z();else if(m===97&&T("abstract")){if(l+=8,d(),T("class")){let y=bt(p,!0,!0);c.push(y)}}else if(m===108&&T("let")){let y=Nt(p,"let",!0);for(let w=0;w<y.length;w++)c.push(y[w])}else if(m===118&&T("var")){let y=Nt(p,"var",!0);for(let w=0;w<y.length;w++)c.push(y[w])}else if(m===101&&T("enum")){let y=Wt(p,!0,!1);c.push(y)}else if(m===100&&T("declare"))l+=7,d(),ks(p,!0);else if(m===110&&T("namespace")&&D(9)){let y=Lt(p,!0,"namespace");c.push(y)}else if(m===109&&T("module")&&D(6)){let y=Lt(p,!0,"module");c.push(y)}else if(m===_){or();let y=g(p,l),w=y.includes("export type"),E=Ue(p);c.push({kind:"export",name:"",text:y,isExported:!0,isTypeOnly:w,source:Or(y),leadingComments:E,start:p,end:l})}else if(m===we){Es();let y=g(p,l),w=Ue(p);c.push({kind:"export",name:"",text:y,isExported:!0,isTypeOnly:!1,source:Or(y),leadingComments:w,start:p,end:l})}else{z();let y=g(p,l);if(y)c.push({kind:"export",name:"",text:y,isExported:!0,start:p,end:l})}}else if(h===100&&T("declare"))l+=7,d(),ks(p,!1);else if(h===105&&T("interface")){let m=Hi(p,!1);f.set(m.name,m)}else if(h===116&&T("type")){let m=ji(p,!1);f.set(m.name,m),c.push(m)}else if(h===102&&T("function")){let m=St(p,!1,!1,!1);if(m)f.set(m.name,m);else z()}else if(h===97)if(T("async")){let m=l;if(l+=5,d(),T("function")){let y=St(p,!1,!0,!1);if(y)f.set(y.name,y);else l=m,z()}else l=m,z()}else if(T("abstract"))if(l+=8,d(),T("class")){let m=bt(p,!1,!1);f.set(m.name,m),c.push(m)}else z();else l++,z();else if(h===99)if(T("class")){let m=bt(p,!1,!1);f.set(m.name,m),c.push(m)}else if(T("const")){let m=l;if(l+=5,d(),T("enum")){l=m+5,d();let y=Wt(p,!1,!0);f.set(y.name,y),c.push(y)}else{l=m;let y=Nt(p,"const",!1);for(let w=0;w<y.length;w++)f.set(y[w].name,y[w])}}else l++,z();else if(h===101&&T("enum")){let m=Wt(p,!1,!1);f.set(m.name,m),c.push(m)}else if(h===108&&T("let"))z();else if(h===118&&T("var"))z();else if(h===109&&T("module")&&D(6)){let m=Lt(p,!1,"module");c.push(m)}else if(h===110&&T("namespace")&&D(9)){let m=Lt(p,!1,"namespace");c.push(m)}else{let m=i.charCodeAt(l);if(m===Z)l++;else if(m===ie||m===oe){if(v(m),l<o&&i.charCodeAt(l)===Z)l++}else if(m===Te){if(C(),l<o&&i.charCodeAt(l)===Z)l++}else if(m===xh){if(l++,W(),d(),l<o&&i.charCodeAt(l)===ct)l++,W(),d();if(l<o&&i.charCodeAt(l)===Q)Pe(Q,Ce)}else l++,z()}}if(f.size>0)Ph(c,f);if(u.size>0){let p=new Map;for(let m of c)if(m.kind==="function")p.set(m.name,(p.get(m.name)||0)+1);let h=new Set;for(let[m,y]of p)if(y>1)h.add(m);if(h.size>0){let m=new Set;for(let y of h)for(let w=c.length-1;w>=0;w--)if(c[w].kind==="function"&&c[w].name===y&&u.has(w)){m.add(w);break}if(m.size>0){let y=[...m].sort((w,E)=>E-w);for(let w of y)c.splice(w,1)}}}return c;function ks(p,h){if(T("function")){let m=St(p,h,!1,!1);if(m)c.push(m)}else if(T("async")){if(l+=5,d(),T("function")){let m=St(p,h,!0,!1);if(m)c.push(m)}}else if(T("class")){let m=bt(p,h,!1);c.push(m)}else if(T("abstract")){if(l+=8,d(),T("class")){let m=bt(p,h,!0);c.push(m)}}else if(T("interface")){let m=Hi(p,h);c.push(m)}else if(T("type")){let m=ji(p,h);c.push(m)}else if(T("enum")){let m=Wt(p,h,!1);c.push(m)}else if(T("const")){let m=l;if(l+=5,d(),T("enum")){l=m+5,d();let y=Wt(p,h,!0);c.push(y)}else if(h){l=m;let y=Nt(p,"const",!0);for(let w=0;w<y.length;w++)c.push(y[w])}else z()}else if(T("let")||T("var"))if(h){let m=T("let")?"let":"var",y=Nt(p,m,!0);for(let w=0;w<y.length;w++)c.push(y[w])}else z();else if(T("module")){let m=Lt(p,h,"module");c.push(m)}else if(T("namespace")){let m=Lt(p,h,"namespace");c.push(m)}else if(T("global")){l+=6,d();let m=`declare global ${l<o&&i.charCodeAt(l)===_?Yi():"{}"}`,y=Ue(p);c.push({kind:"module",name:"global",text:m,isExported:!1,leadingComments:y,start:p,end:l})}else z()}}function Yo(e,t){let r=0,n=e.length;while(r<n){let i=e.charCodeAt(r);if(i>=65&&i<=90||i>=97&&i<=122||i===95||i===36||i>127){let s=r;r++;while(r<n){let a=e.charCodeAt(r);if(a>=65&&a<=90||a>=97&&a<=122||a>=48&&a<=57||a===95||a===36||a>127)r++;else break}t.add(e.substring(s,r))}else r++}}function Zo(e,t){let r=0;while(r<e.length){let n=e.charCodeAt(r);if(n===ie||n===oe||n===Te){let u=n;r++;while(r<e.length)if(e.charCodeAt(r)===Je)r+=2;else if(e.charCodeAt(r++)===u)break;continue}if(n===J&&e.charCodeAt(r+1)===J){r+=2;while(r<e.length&&e.charCodeAt(r)!==ne&&e.charCodeAt(r)!==pe)r++;continue}if(n===J&&e.charCodeAt(r+1)===we){let u=e.indexOf("*/",r+2);r=u===-1?e.length:u+2;continue}if(!kt(n)){r++;continue}let i=r++;while(r<e.length&&Ke(e.charCodeAt(r)))r++;let s=i-1,a=r;while(s>=0&&Fe(e.charCodeAt(s)))s--;while(a<e.length&&Fe(e.charCodeAt(a)))a++;let o=s>=0?e.charCodeAt(s):0,c=a<e.length?e.charCodeAt(a):0,f=i>=3&&e.slice(i-3,i)==="...";if(c===tt||o===ct&&!f)continue;if(c===Q&&(o===_||o===rt))continue;t.add(e.slice(i,r))}}function Ph(e,t){let r=new Set,n=new Set;for(let a of e)n.add(a.name);let i=new Set,s=[];for(let a=0;a<e.length;a++){let o=e[a];if(o.kind!=="import"){if(s.push(o.text),Yo(o.text,i),typeof o.value==="string")Zo(o.value,i)}}for(;;){let a=[];for(let[f,u]of t){if(r.has(f))continue;if(i.has(f)){if(!n.has(f))a.push(u),n.add(f);r.add(f)}}if(a.length===0)break;a.sort((f,u)=>(f.start??1/0)-(u.start??1/0));let o=[],c=0;for(let f=0;f<e.length;f++){let u=e[f].start??1/0;while(c<a.length&&(a[c].start??1/0)<=u)o.push(a[c++]);o.push(e[f])}while(c<a.length)o.push(a[c++]);e.length=0;for(let f=0;f<o.length;f++)e.push(o[f]);for(let f of a)if(f.kind!=="import"){if(s.push(f.text),Yo(f.text,i),typeof f.value==="string")Zo(f.value,i)}}}var Ee=32,ve=9,ne=10,pe=13,J=47,we=42,ie=39,oe=34,Te=96,Je=92,_=123,U=125,Q=40,Ce=41,de=91,be=93,me=60,he=62,Z=59,tt=58,$e=61,rt=44,ct=46,bi=63,Ai=35,xh=64,qo=36,Th=95,zn;var el=le(()=>{Xn();zn=["public","protected","private","readonly","override"]});function rl(e){return e.endsWith(".vue")}function kh(e){let t={script:null,scriptSetup:null},r=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,n;while((n=r.exec(e))!==null){let i=n[1]||"",s=/lang\s*=\s*["']([^"']+)["']/i.exec(i)?.[1]?.toLowerCase()??"js",a={content:n[2]??"",attrs:i,setup:/\bsetup\b/.test(i),lang:s};if(a.setup)t.scriptSetup=a;else t.script=a}return t}function Ze(e,t){let r=e[t];t++;while(t<e.length){let n=e[t];if(n==="\\"){t+=2;continue}if(n===r)return t+1;t++}return t}function it(e,t){t++;let r=0;while(t<e.length){let n=e[t];if(n==="\\"){t+=2;continue}if(n==="`"&&r===0)return t+1;if(n==="$"&&e[t+1]==="{"){r++,t+=2;continue}if(n==="}"){if(r>0)r--;t++;continue}t++}return t}function ft(e,t){if(e[t+1]==="/"){let r=e.indexOf(`
129
+ `,t+2);return r===-1?e.length:r+1}if(e[t+1]==="*"){let r=e.indexOf("*/",t+2);return r===-1?e.length:r+2}return t+1}function es(e,t){let r=e[t];if(r==='"'||r==="'")return Ze(e,t);if(r==="`")return it(e,t);if(r==="/"&&(e[t+1]==="/"||e[t+1]==="*"))return ft(e,t);return t}function ts(e){let t=e.split(""),r=0;while(r<e.length){let n=es(e,r);if(n>r){for(let i=r;i<n;i++)if(t[i]!==`
130
+ `&&t[i]!=="\r")t[i]=" ";r=n;continue}r++}return t.join("")}function Le(e,t,r,n){let i=0,s=t;while(s<e.length){let a=e[s];if(a==='"'||a==="'"){s=Ze(e,s);continue}if(a==="`"){s=it(e,s);continue}if(a==="/"&&(e[s+1]==="/"||e[s+1]==="*")){s=ft(e,s);continue}if(a===r)i++;else if(a===n){if(i--,i===0)return s}s++}return-1}function rs(e,t){let r=0,n=t;while(n<e.length){let i=e[n];if(i==='"'||i==="'"){n=Ze(e,n);continue}if(i==="`"){n=it(e,n);continue}if(i==="/"&&(e[n+1]==="/"||e[n+1]==="*")){n=ft(e,n);continue}if(i==="="&&e[n+1]===">"){n+=2;continue}if(i==="<")r++;else if(i===">"){if(r--,r===0)return n}n++}return-1}function ir(e,t=","){let r=[],n=0,i="",s=0;while(s<e.length){let a=e[s];if(a==='"'||a==="'"){let o=Ze(e,s);i+=e.slice(s,o),s=o;continue}if(a==="`"){let o=it(e,s);i+=e.slice(s,o),s=o;continue}if(a==="/"&&(e[s+1]==="/"||e[s+1]==="*")){s=ft(e,s);continue}if(a==="{"||a==="["||a==="("||a==="<")n++;else if(a==="}"||a==="]"||a===")"||a===">")n--;if(a===t&&n===0){r.push(i),i="",s++;continue}i+=a,s++}if(i.trim()!=="")r.push(i);return r}function Sr(e){let t=e.trim();if(!t.startsWith("{"))return[];let r=Le(t,0,"{","}");if(r===-1)return[];let n=t.slice(1,r),i=[];for(let s of ir(n)){let a=-1,o=0;for(let u=0;u<s.length;u++){let l=s[u];if(l==='"'||l==="'"){u=Ze(s,u)-1;continue}if(l==="`"){u=it(s,u)-1;continue}if(l==="{"||l==="["||l==="("||l==="<")o++;else if(l==="}"||l==="]"||l===")"||l===">")o--;else if(l===":"&&o===0){a=u;break}}if(a!==-1){i.push({key:Er(s.slice(0,a).trim()),value:s.slice(a+1).trim(),isMethod:!1});continue}let c=/^([A-Za-z_$][\w$]*|['"][^'"]+['"])\s*\(/.exec(s.trim());if(c){i.push({key:Er(c[1]),value:s.trim(),isMethod:!0});continue}let f=s.trim();if(f)i.push({key:Er(f),value:"",isMethod:!1})}return i}function Er(e){if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);return e}function vr(e){return/^[A-Za-z_$][\w$]*$/.test(e)?e:JSON.stringify(e)}function br(e,t){let r=new RegExp(`\\b${t}\\b`,"g"),n;while((n=r.exec(e))!==null){let i=n.index+n[0].length;while(i<e.length&&/\s/.test(e[i]))i++;let s=null;if(e[i]==="<"){let c=rs(e,i);if(c===-1)return null;s=e.slice(i+1,c).trim(),i=c+1;while(i<e.length&&/\s/.test(e[i]))i++}if(e[i]!=="(")continue;let a=Le(e,i,"(",")");if(a===-1)return null;let o=ir(e.slice(i+1,a));return{generic:s,arg:o.length>0?o[0].trim():null}}return null}function Mh(e,t){let r=il(e,t);if(!r)return null;return r.kind==="interface"?e.slice(r.bodyStart,r.end):e.slice(r.bodyStart,r.end).trim()}function il(e,t){let r=new RegExp(`\\binterface\\s+${t}\\b[^{]*\\{`,"m").exec(e);if(r){let i=r.index+r[0].length-1,s=Le(e,i,"{","}");if(s!==-1)return{kind:"interface",start:r.index,end:s+1,bodyStart:i}}let n=new RegExp(`\\btype\\s+${t}\\b[^=]*=`,"m").exec(e);if(n){let i=n.index+n[0].length,s=0,a=i;while(i<e.length){let o=e[i];if(o==='"'||o==="'"){i=Ze(e,i);continue}if(o==="`"){i=it(e,i);continue}if(o==="{"||o==="["||o==="("||o==="<")s++;else if(o==="}"||o==="]"||o===")"||o===">")s--;else if((o===";"||o===`
131
+ `)&&s===0)break;i++}return{kind:"type",start:n.index,end:i,bodyStart:a}}return null}function Ih(e){let t=e.search(/\bas\s+PropType\s*</);if(t===-1)return null;let r=e.indexOf("<",t),n=rs(e,r);if(n===-1)return null;if(e.slice(n+1).trim()!=="")return null;return e.slice(r+1,n).trim()}function Qn(e){let t=e.trim(),r=Ih(t);if(r!==null)return{type:r,optional:!0};if(t==="null")return{type:"unknown",optional:!0};if(t.startsWith("[")){let n=Le(t,0,"[","]");if(n!==-1){let i=ir(t.slice(1,n)).map((s)=>Qn(s).type).filter((s)=>s!=="unknown");return{type:i.length>0?[...new Set(i)].join(" | "):"unknown",optional:!0}}}if(t.startsWith("{")){let n=Sr(t),i=n.find((c)=>c.key==="type"),s=n.find((c)=>c.key==="required"),a=i?Qn(i.value).type:"unknown",o=!(s&&s.value.trim()==="true");return{type:a,optional:o}}if(tl[t])return{type:tl[t],optional:!0};if(/^[A-Za-z_$][\w$.]*$/.test(t))return{type:t,optional:!0};return{type:"unknown",optional:!0}}function Pi(e){let t=e.trim();if(t.startsWith("{")){let r=Sr(t);if(r.length===0)return"{}";return`{ ${r.map((n)=>{if(n.isMethod||n.value==="")return`${vr(n.key)}?: unknown`;let i=Qn(n.value);return`${vr(n.key)}${i.optional?"?":""}: ${i.type}`}).join(", ")} }`}if(t.startsWith("[")){let r=Le(t,0,"[","]");if(r===-1)return null;let n=ir(t.slice(1,r)).map((i)=>Er(i.trim())).filter((i)=>i!=="");if(n.length===0)return"{}";return`{ ${n.map((i)=>`${vr(i)}?: unknown`).join(", ")} }`}return null}function Dh(e){let t=e.trim();if(!t.startsWith("["))return null;let r=Le(t,0,"[","]");if(r===-1)return null;let n=ir(t.slice(1,r)).map((i)=>i.trim());if(n.length===0)return"{}";if(!n.every((i)=>i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"')))return"string[]";return`[${n.map((i)=>JSON.stringify(Er(i))).join(", ")}]`}function Fh(e){let t=e.trim();if(!t.startsWith("{"))return null;let r=Sr(t);if(r.length===0)return"{}";return`{ ${r.map((n)=>`${JSON.stringify(n.key)}: (...args: any[]) => void`).join(", ")} }`}function nl(e){return Dh(e)??Fh(e)}function Nh(e){let t=[],r=0,n="",i=0;while(i<e.length){let s=e[i];if(s==='"'||s==="'"){let a=Ze(e,i);n+=e.slice(i,a),i=a;continue}if(s==="`"){let a=it(e,i);n+=e.slice(i,a),i=a;continue}if(s==="/"&&(e[i+1]==="/"||e[i+1]==="*")){let a=ft(e,i);n+=e.slice(i,a),i=a;continue}if(s==="="&&e[i+1]===">"){n+="=>",i+=2;continue}if(s==="{"||s==="["||s==="("||s==="<")r++;else if(s==="}"||s==="]"||s===")"||s===">")r--;if((s===";"||s===","||s===`
132
+ `)&&r===0){if(n.trim()!=="")t.push(n.trim());n="",i++;continue}n+=s,i++}if(n.trim()!=="")t.push(n.trim());return t}function Wh(e){let t=e.trim();if(!t.startsWith("{"))return null;let r=Le(t,0,"{","}");if(r===-1||t.slice(r+1).trim()!=="")return null;let n=Nh(t.slice(1,r));if(n.length===0)return"{}";let i=[];for(let s of n){let a=/^\(\s*\w+\s*:\s*/.exec(s);if(!a)return null;let o=a[0].length,c=s[o];if(c!=="'"&&c!=='"'&&c!=="`")return null;let f=Ze(s,o),u=s.slice(o+1,f-1),l=Le(s,s.indexOf("(",0),"(",")");if(l===-1)return null;let g=s.slice(o,l),d=ir(g).slice(1),$=s.slice(l+1).trim();if($.startsWith(":"))$=$.slice(1).trim();if($==="")$="void";i.push(`${JSON.stringify(u)}: (${d.map((v)=>v.trim()).join(", ")}) => ${$}`)}return`{ ${i.join(", ")} }`}function is(e){let t=e;for(let r of["defineProps","defineEmits","defineExpose","defineSlots","defineOptions"])t=Lh(t,r);return t}function Lh(e,t){let r=new RegExp(`\\b${t}\\b`,"g"),n=[],i=e,s;while((s=r.exec(e))!==null){let a=e.lastIndexOf(`
133
+ `,s.index)+1,o=e.slice(a,s.index),c=/^\s*(?:(?:const|let|var)\s+[A-Za-z_$][\w$]*\s*(?::[^=]+)?=\s*)?(withDefaults\s*\(\s*)?$/.exec(o);if(!c)continue;let f=s.index+s[0].length;while(f<e.length&&/\s/.test(e[f]))f++;if(e[f]==="<"){let g=rs(e,f);if(g===-1)continue;f=g+1;while(f<e.length&&/\s/.test(e[f]))f++}if(e[f]!=="(")continue;let u=Le(e,f,"(",")");if(u===-1)continue;if(c[1]){let g=a+o.length-c[1].length,d=e.indexOf("(",g);if(d!==-1){let $=Le(e,d,"(",")");if($!==-1)u=$}}let l=u+1;while(l<e.length&&e[l]!==`
132
134
  `&&/\s|;/.test(e[l]))l++;if(e[l]===`
133
- `)l++;n.push([a,l])}for(let a=n.length-1;a>=0;a--)i=i.slice(0,n[a][0])+i.slice(n[a][1]);return i}function rs(e){let t=Nh(e);if(t!==-1){let r=/^export\s+default\b/.exec(e.slice(t))?.[0];if(!r)return{options:null,script:e,passthrough:!1};let n=t+r.length;while(n<e.length&&/\s/.test(e[n]))n++;let i=-1,s=-1,a=-1;if(e[n]==="{")i=n,s=Ne(e,n,"{","}"),a=s;else if(e.startsWith("defineComponent",n)){let f=e.indexOf("(",n);if(f!==-1){let u=f+1;while(u<e.length&&/\s/.test(e[u]))u++;if(e[u]==="{")i=u,s=Ne(e,u,"{","}"),a=Ne(e,f,"(",")")}}if(i===-1||s===-1||a===-1)return{options:null,script:e,passthrough:!0};let o=a+1;if(e[o]===";")o++;let c=(e.slice(0,t)+e.slice(o)).trim();return{options:e.slice(i,s+1),script:c,passthrough:!1}}return{options:null,script:e,passthrough:!1}}function Nh(e){let t=0,r=0;while(r<e.length){let n=e[r];if(n==='"'||n==="'"){r=Ye(e,r);continue}if(n==="`"){r=rt(e,r);continue}if(n==="/"&&(e[r+1]==="/"||e[r+1]==="*")){r=ft(e,r);continue}if(n==="{"||n==="["||n==="(")t++;else if(n==="}"||n==="]"||n===")")t=Math.max(0,t-1);else if(t===0&&e.startsWith("export",r)){let i=r===0?"":e[r-1],s=e[r+6]??"";if(!/[\w$]/.test(i)&&!/[\w$]/.test(s)){if(/^export\s+default\b/.exec(e.slice(r)))return r}}r++}return-1}function Ai(e,t){let r=vr(e).find((n)=>n.key===t);return r&&r.value!==""?r.value:null}function xi(e,t){let r=Wh(e),n=e;for(let i=r.length-1;i>=0;i--){let s=r[i],a=n.slice(0,s.start)+n.slice(s.end);if(Lh(a,s.name))continue;if(new RegExp(`\\btypeof\\s+${s.name}\\b`).test(t))continue;n=a}return n}function Lh(e,t){let r=0;while(r<e.length){let n=e[r];if(n==='"'||n==="'"){r=Ye(e,r);continue}if(n==="`"){r=rt(e,r);continue}if(n==="/"&&(e[r+1]==="/"||e[r+1]==="*")){r=ft(e,r);continue}if(/[A-Za-z_$]/.test(n)){let i=r+1;while(i<e.length&&/[\w$]/.test(e[i]))i++;if(e.slice(r,i)===t)return!0;r=i;continue}r++}return!1}function Wh(e){let t=[],r=Gh(e),n=/^[ \t]*(const|let|var|(?:async[ \t]+)?function)[ \t]+([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=?/gm,i;while((i=n.exec(e))!==null){let s=e.lastIndexOf(`
134
- `,i.index)+1;if(!r.has(s))continue;if(/\bexport\b/.test(e.slice(s,i.index)))continue;let a=i[1],o=i[2],c=i.index+i[0].length,f=-1;if(a.endsWith("function")){let u=e.indexOf("(",c);if(u===-1)continue;let l=Ne(e,u,"(",")");if(l===-1)continue;c=l+1;while(c<e.length&&/\s/.test(e[c]))c++;if(e[c]===":")while(c<e.length&&e[c]!=="{"&&e[c]!==`
135
+ `)l++;n.push([a,l])}for(let a=n.length-1;a>=0;a--)i=i.slice(0,n[a][0])+i.slice(n[a][1]);return i}function ns(e){let t=Gh(e);if(t!==-1){let r=/^export\s+default\b/.exec(e.slice(t))?.[0];if(!r)return{options:null,script:e,passthrough:!1};let n=t+r.length;while(n<e.length&&/\s/.test(e[n]))n++;let i=-1,s=-1,a=-1;if(e[n]==="{")i=n,s=Le(e,n,"{","}"),a=s;else if(e.startsWith("defineComponent",n)){let f=e.indexOf("(",n);if(f!==-1){let u=f+1;while(u<e.length&&/\s/.test(e[u]))u++;if(e[u]==="{")i=u,s=Le(e,u,"{","}"),a=Le(e,f,"(",")")}}if(i===-1||s===-1||a===-1)return{options:null,script:e,passthrough:!0};let o=a+1;if(e[o]===";")o++;let c=(e.slice(0,t)+e.slice(o)).trim();return{options:e.slice(i,s+1),script:c,passthrough:!1}}return{options:null,script:e,passthrough:!1}}function Gh(e){let t=0,r=0;while(r<e.length){let n=e[r];if(n==='"'||n==="'"){r=Ze(e,r);continue}if(n==="`"){r=it(e,r);continue}if(n==="/"&&(e[r+1]==="/"||e[r+1]==="*")){r=ft(e,r);continue}if(n==="{"||n==="["||n==="(")t++;else if(n==="}"||n==="]"||n===")")t=Math.max(0,t-1);else if(t===0&&e.startsWith("export",r)){let i=r===0?"":e[r-1],s=e[r+6]??"";if(!/[\w$]/.test(i)&&!/[\w$]/.test(s)){if(/^export\s+default\b/.exec(e.slice(r)))return r}}r++}return-1}function Ti(e,t){let r=Sr(e).find((n)=>n.key===t);return r&&r.value!==""?r.value:null}function Ri(e,t){let r=Vh(e),n=e;for(let i=r.length-1;i>=0;i--){let s=r[i],a=n.slice(0,s.start)+n.slice(s.end);if(Bh(a,s.name))continue;if(new RegExp(`\\btypeof\\s+${s.name}\\b`).test(t))continue;n=a}return n}function Bh(e,t){let r=0;while(r<e.length){let n=e[r];if(n==='"'||n==="'"){r=Ze(e,r);continue}if(n==="`"){r=it(e,r);continue}if(n==="/"&&(e[r+1]==="/"||e[r+1]==="*")){r=ft(e,r);continue}if(/[A-Za-z_$]/.test(n)){let i=r+1;while(i<e.length&&/[\w$]/.test(e[i]))i++;if(e.slice(r,i)===t)return!0;r=i;continue}r++}return!1}function Vh(e){let t=[],r=_h(e),n=/^[ \t]*(const|let|var|(?:async[ \t]+)?function)[ \t]+([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=?/gm,i;while((i=n.exec(e))!==null){let s=e.lastIndexOf(`
136
+ `,i.index)+1;if(!r.has(s))continue;if(/\bexport\b/.test(e.slice(s,i.index)))continue;let a=i[1],o=i[2],c=i.index+i[0].length,f=-1;if(a.endsWith("function")){let u=e.indexOf("(",c);if(u===-1)continue;let l=Le(e,u,"(",")");if(l===-1)continue;c=l+1;while(c<e.length&&/\s/.test(e[c]))c++;if(e[c]===":")while(c<e.length&&e[c]!=="{"&&e[c]!==`
135
137
  `)c++;while(c<e.length&&/\s/.test(e[c])&&e[c]!==`
136
- `)c++;if(e[c]!=="{")continue;let g=Ne(e,c,"{","}");if(g===-1)continue;f=g+1}else{let u=0;while(c<e.length){let l=e[c];if(l==='"'||l==="'"){c=Ye(e,c);continue}if(l==="`"){c=rt(e,c);continue}if(l==="/"&&(e[c+1]==="/"||e[c+1]==="*")){c=ft(e,c);continue}if(l==="{"||l==="["||l==="(")u++;else if(l==="}"||l==="]"||l===")")u--;else if(l===";"&&u===0){f=c+1;break}else if(l===`
138
+ `)c++;if(e[c]!=="{")continue;let g=Le(e,c,"{","}");if(g===-1)continue;f=g+1}else{let u=0;while(c<e.length){let l=e[c];if(l==='"'||l==="'"){c=Ze(e,c);continue}if(l==="`"){c=it(e,c);continue}if(l==="/"&&(e[c+1]==="/"||e[c+1]==="*")){c=ft(e,c);continue}if(l==="{"||l==="["||l==="(")u++;else if(l==="}"||l==="]"||l===")")u--;else if(l===";"&&u===0){f=c+1;break}else if(l===`
137
139
  `&&u===0){f=c;break}c++}if(f===-1)f=e.length}if(e[f]===`
138
- `)f++;t.push({name:o,start:i.index,end:f})}return t}function Gh(e){let t=new Set([0]),r=0,n=0;while(n<e.length){let i=e[n];if(i==='"'||i==="'"){n=Ye(e,n);continue}if(i==="`"){n=rt(e,n);continue}if(i==="/"&&(e[n+1]==="/"||e[n+1]==="*")){n=ft(e,n);continue}if(i==="{"||i==="["||i==="(")r++;else if(i==="}"||i==="]"||i===")")r=Math.max(0,r-1);if(i===`
139
- `&&r===0)t.add(n+1);n++}return t}function Ti(e,t,r){let n=e.indexOf(r);if(n===-1)return e;let i=e.lastIndexOf(`
140
- `,n)+1;if(/\bexport\b/.test(e.slice(i,n)))return e;let s=e.slice(0,n)+e.slice(n+r.length);if(new RegExp(`\\b${t}\\b`).test(s))return e;return s}function is(e){let t="",r=0,n=()=>{for(let s=t.length-1;s>=0;s--)if(!/\s/.test(t[s]))return t[s];return""},i=(s)=>{for(let a=s;a<e.length;a++)if(!/\s/.test(e[a]))return e[a];return""};while(r<e.length){let s=e[r];if(s==='"'||s==="'"){let a=Ye(e,r);t+=e.slice(r,a),r=a;continue}if(s==="`"){let a=rt(e,r);t+=e.slice(r,a),r=a;continue}if(s==="/"&&e[r+1]==="*"){let a=ft(e,r);t+=e.slice(r,a).replace(/\s*\n\s*/g," "),r=a;continue}if(s==="/"&&e[r+1]==="/"){let a=r+2;while(a<e.length&&e[a]!==`
140
+ `)f++;t.push({name:o,start:i.index,end:f})}return t}function _h(e){let t=new Set([0]),r=0,n=0;while(n<e.length){let i=e[n];if(i==='"'||i==="'"){n=Ze(e,n);continue}if(i==="`"){n=it(e,n);continue}if(i==="/"&&(e[n+1]==="/"||e[n+1]==="*")){n=ft(e,n);continue}if(i==="{"||i==="["||i==="(")r++;else if(i==="}"||i==="]"||i===")")r=Math.max(0,r-1);if(i===`
141
+ `&&r===0)t.add(n+1);n++}return t}function Oi(e,t,r){let n=e.indexOf(r);if(n===-1)return e;let i=e.lastIndexOf(`
142
+ `,n)+1;if(/\bexport\b/.test(e.slice(i,n)))return e;let s=e.slice(0,n)+e.slice(n+r.length);if(new RegExp(`\\b${t}\\b`).test(s))return e;return s}function ss(e){let t="",r=0,n=()=>{for(let s=t.length-1;s>=0;s--)if(!/\s/.test(t[s]))return t[s];return""},i=(s)=>{for(let a=s;a<e.length;a++)if(!/\s/.test(e[a]))return e[a];return""};while(r<e.length){let s=e[r];if(s==='"'||s==="'"){let a=Ze(e,r);t+=e.slice(r,a),r=a;continue}if(s==="`"){let a=it(e,r);t+=e.slice(r,a),r=a;continue}if(s==="/"&&e[r+1]==="*"){let a=ft(e,r);t+=e.slice(r,a).replace(/\s*\n\s*/g," "),r=a;continue}if(s==="/"&&e[r+1]==="/"){let a=r+2;while(a<e.length&&e[a]!==`
141
143
  `)a++;let o=e.slice(r+2,a).trim();if(o!==""&&!o.includes("*/"))t+=`/* ${o} */`;r=a;continue}if(s===`
142
- `){let a=n(),o=i(r+1);if(a===""||o===""){r++;continue}let c=Bh(t);if(!c&&("{;,(<:=[".includes(a)||"}),]>;|&".includes(o))){if(!t.endsWith(" ")&&!t.endsWith(";"))t+=" "}else if(c){if(!t.endsWith(" "))t+=" "}else{if(t.endsWith(" "))t=t.slice(0,-1);t+="; "}r++;while(r<e.length&&(e[r]===" "||e[r]==="\t"))r++;continue}t+=s,r++}return t}function Bh(e){let t=e.length-1;while(t>=0&&/\s/.test(e[t]))t--;if(t<1||e[t]!=="/"||e[t-1]!=="*")return!1;let r=e.lastIndexOf("/*",t);if(r===-1)return!1;for(let n=r-1;n>=0;n--){let i=e[n];if(/\s/.test(i))continue;return"{;,(<:".includes(i)}return!0}function Oi(e,t){let r=[e,t].filter((n)=>n!==null);for(let n of r){let i=Sr(n,"defineProps");if(!i)continue;if(i.generic){let s=i.generic;if(s.startsWith("{"))return{type:s};if(/^[A-Za-z_$][\w$]*$/.test(s)){for(let a of r){let o=el(a,s);if(!o)continue;let c=Oh(a,s);if(c===null)continue;return{type:c,inlinedLocal:{name:s,declText:a.slice(o.start,o.end)}}}return{type:s}}return{type:s}}if(i.arg){let s=Ri(i.arg);if(s!==null)return{type:s}}}return null}function ns(e,t){let r=[e,t].filter((n)=>n!==null);for(let n of r){let i=Sr(n,"defineEmits");if(!i)continue;if(i.generic)return Dh(i.generic)??i.generic;if(i.arg){let s=tl(i.arg);if(s!==null)return s}}return null}function ss(e,t){let r=[e,t].filter((n)=>n!==null);for(let n of r){let i=Sr(n,"defineExpose");if(!i||!i.arg||!i.arg.startsWith("{"))continue;let s=vr(i.arg);if(s.length===0)return null;return`{ ${s.map((a)=>{if(a.value===""&&/^[A-Za-z_$][\w$]*$/.test(a.key))return`${Er(a.key)}: typeof ${a.key}`;let o=a.isMethod||/=>|^\s*function\b/.test(a.value);return`${Er(a.key)}: ${o?"(...args: any[]) => any":"unknown"}`}).join(", ")} }`}return null}function rl(e){let t=Rh(e),r="",n=null,i=null;if(t.script){let C=rs(t.script.content);if(C.passthrough)return t.scriptSetup?`${t.script.content}
143
- ${t.scriptSetup.content}`:t.script.content;if(r=C.script,C.options){let A=Ai(C.options,"props");if(A)n=Ri(A);let O=Ai(C.options,"emits");if(O)i=tl(O)}}let s=t.scriptSetup?.content??null,a=s!==null?ts(s):null,o=Oi(s,s!==null?null:r),c=o?.type??n??"{}",f=ns(s,null)??i,u=ss(s,null),l=o?.inlinedLocal;if(l){if(r=Ti(r,l.name,l.declText),a!==null)a=Ti(a,l.name,l.declText)}let g=[c,u??"{}"];if(f)g.push("{}","{}","{}","{}","{}",f);let d=is(`DefineComponent<${g.join(", ")}>`),w=[],E=xi(r,d);if(E.trim()!=="")w.push(E);if(a&&a.trim()!==""){let C=xi(a,d);if(C.trim()!=="")w.push(C)}return w.push("import type { DefineComponent } from 'vue'"),w.push(`type __DtsxComponentType = ${d}`),w.push("const __dtsx_component__: __DtsxComponentType = null as unknown as __DtsxComponentType"),w.push("export default __dtsx_component__"),w.join(`
144
- `)}var zo;var as=oe(()=>{zo={String:"string",Number:"number",Boolean:"boolean",Array:"unknown[]",Object:"Record<string, unknown>",Function:"(...args: any[]) => any",Symbol:"symbol",Promise:"Promise<unknown>",Date:"Date",BigInt:"bigint"}});function nl(e){return e.endsWith(".stx")}function Vh(e){let t=[],r=/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi,n;while((n=r.exec(e))!==null){let i=n[1]??"",s=/\blang\s*=\s*["']([^"']+)["']/i.exec(i)?.[1]?.toLowerCase()??(/\b(?:type\s*=\s*["'](?:text\/)?typescript["']|typescript)\b/i.test(i)?"ts":"js"),a=/\bserver\b/i.test(i)?"server":/\bclient\b/i.test(i)?"client":"universal";t.push({content:n[2]??"",kind:"script",attrs:i,context:a,lang:s,start:n.index})}return t}function _h(e){let t=[],r=/^[ \t]*@ts[ \t]*(?:\r?\n|$)/gm,n;while((n=r.exec(e))!==null){let i=r.lastIndex,s=/^[ \t]*@endts[ \t]*(?:\r?\n|$)/gm;s.lastIndex=i;let a=s.exec(e),o=a?.index??e.length;if(t.push({content:e.slice(i,o),kind:"ts",attrs:"",context:"universal",lang:"ts",start:n.index}),!a)break;r.lastIndex=s.lastIndex}return t}function Hh(e){return[...Vh(e),..._h(e)].sort((t,r)=>t.start-r.start)}function jh(e){if(e.kind==="ts"||e.context!=="universal"||e.lang==="ts")return!0;return/\b(?:defineProps|defineEmits|defineExpose|defineSlots)\b|\bexport\s|\b(?:interface|type)\s+[A-Za-z_$]/.test(e.content)}function Kh(e){let t=/(?:\$?props)\s+as\s+/g,r;while((r=t.exec(e))!==null){let n=t.lastIndex;while(n<e.length&&/\s/.test(e[n]))n++;if(e[n]==="{"){let a=Ne(e,n,"{","}");if(a!==-1)return e.slice(n,a+1).trim();continue}let i=/^[A-Za-z_$][\w$]*/.exec(e.slice(n))?.[0];if(!i)continue;let s=n+i.length;while(s<e.length&&/\s/.test(e[s]))s++;if(e[s]==="<"){let a=Ne(e,s,"<",">");if(a!==-1)s=a+1}return e.slice(n,s).trim()}return null}function Jh(e){return/\b(?:const|let|var)\s+\$?props\s*:\s*([^=;\n]+)/.exec(e)?.[1]?.trim()??null}function Uh(e){let t=/^\s*(?:\|\||\?\?)\s*([^;\n]+)/.exec(e)?.[1]?.trim();if(/^['"`]/.test(t??""))return"string";if(/^(?:true|false)\b/.test(t??""))return"boolean";if(/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)\b/.test(t??""))return"number";if(/^\[/.test(t??""))return"unknown[]";if(/^\{/.test(t??""))return"Record<string, unknown>";if(/^\s*(?:===?|!==?)\s*(?:true|false)\b/.test(e))return"boolean";return"unknown"}function Yh(e,t){if(!e||e==="unknown")return t;if(t==="unknown"||e===t)return e;return[...new Set([...e.split(" | "),...t.split(" | ")])].join(" | ")}function Zh(e){let t=Qn(e),r=new Map,n=/\$props(?:\.([A-Za-z_$][\w$]*)|\[\s*(['"])([^'"\n]+)\2\s*\])/g,i;while((i=n.exec(e))!==null){if(t.slice(i.index,i.index+6)!=="$props")continue;let s=i[1]??i[3],a=Uh(e.slice(n.lastIndex));r.set(s,Yh(r.get(s),a))}if(r.size===0)return null;return{type:`{ ${[...r].map(([s,a])=>{return`${/^[A-Za-z_$][\w$]*$/.test(s)?s:JSON.stringify(s)}?: ${a}`}).join(", ")} }`}}function qh(e){let t=Oi(e,null);if(t)return t;let r=Kh(e)??Jh(e);if(!r)return Zh(e);if(/^[A-Za-z_$][\w$]*$/.test(r)){let n=r.replace(/[$]/g,"\\$&");if(new RegExp(`\\bexport\\s+(?:declare\\s+)?(?:interface|type)\\s+${n}\\b`).test(e))return{type:r}}return Oi(`${e}
145
- defineProps<${r}>()`,null)}function Xh(e){return ts(e)}function il(e){let t=Qn(e).trimStart();if(t==="")return!0;return/^(?:import\b|export\b|declare\b|interface\b|type\b|(?:export\s+)?namespace\b|(?:export\s+)?module\b|(?:abstract\s+)?class\b|const\b|let\b|var\b|(?:async\s+)?function\b)/.test(t)}function zh(e){let t=[],r=0,n=0,i=0;while(i<e.length){let a=e[i],o=zn(e,i);if(o>i){i=o;continue}if(a==="{"||a==="["||a==="(")n++;else if(a==="}"||a==="]"||a===")")n=Math.max(0,n-1);if((a===";"||a===`
146
- `)&&n===0){let c=i+1;if(!il(e.slice(r,c)))t.push([r,c]);r=c}i++}if(r<e.length&&!il(e.slice(r)))t.push([r,e.length]);let s=e;for(let a=t.length-1;a>=0;a--)s=s.slice(0,t[a][0])+s.slice(t[a][1]);return s}function sl(e){let t=Hh(e).filter(jh).map((E)=>E.content).join(`
147
- `),r=null,n=rs(t);if(n.passthrough)return t;if(t=n.script,n.options){let E=Ai(n.options,"props");if(E)r=Ri(E)}let i=t,s=Xh(t),a=qh(i),o=a?.type??r??"{}",c=ns(i,null),f=ss(i,null),u=Sr(i,"defineSlots")?.generic??null,l=a?.inlinedLocal;if(l)s=Ti(s,l.name,l.declText);let g=`DefineComponent<${o}>`,d=[];if(c)d.push(`readonly __stxEmits?: ${c}`);if(u)d.push(`readonly __stxSlots?: ${u}`);if(f)d.push(`readonly __stxExposed?: ${f}`);if(d.length>0)g+=` & { ${d.join(", ")} }`;g=is(g),s=zh(xi(s,g));let w=["import type { DefineComponent } from '@stacksjs/stx'",`type __DtsxStxComponentType = ${g}`,"const __dtsx_component__: __DtsxStxComponentType = null as unknown as __DtsxStxComponentType","export default __dtsx_component__"];if(s.trim()!=="")w.push(s);return w.join(`
148
- `)}var al=oe(()=>{as()});function ll(e,t,r=!0,n=!1){if(Qo(t))e=rl(e);else if(nl(t))e=sl(e);let i=lr(e),s=`${t}:${r?1:0}:${n?1:0}`,a=nr.get(s);if(a&&a.contentHash===i)return a.lastAccess=++ol,a.declarations;let o=n?Yo(e,t,r):Zo(e,t,r);if(nr.set(s,{declarations:o,contentHash:i,lastAccess:++ol}),nr.size>Qh){let c=Math.max(1,Math.ceil(nr.size*0.1)),f=[];for(let[u,l]of nr)f.push([u,l.lastAccess]);f.sort((u,l)=>u[1]-l[1]);for(let u=0;u<c&&u<f.length;u++)nr.delete(f[u][0])}return o}var Qh=100,ol=0,nr;var cl=oe(()=>{Xo();Ui();al();as();nr=new Map});function Pi(e,t,r=!0,n=!1){return ll(e,t,r,n)}var os=oe(()=>{cl()});import{dirname as vy,relative as ed,resolve as Sy}from"path";async function fl(e,t,r){let n=new Map,i=[],s=new Set,a=0,o=0,c=0,f=[];for(let O of e){let R=t.get(O);if(!R)continue;f.push({file:O,decls:Pi(R,O,r.keepComments)})}for(let{file:O,decls:R}of f){a+=R.length;for(let I of R)if(I.kind==="import"){o++;let B=I.source||"";if(B.startsWith("."))continue;if(!n.has(B))n.set(B,{source:B,specifiers:new Map,isTypeOnly:I.isTypeOnly||!1,isSideEffect:I.isSideEffect||!1});let L=n.get(B);if(I.specifiers)for(let T of I.specifiers){let D=T.alias||T.name;if(!L.specifiers.has(D))L.specifiers.set(D,{name:T.name,alias:T.alias,isType:T.isType||!1})}if(!I.isTypeOnly)L.isTypeOnly=!1}else if(I.isExported||I.kind==="export"){if(c++,I.kind==="export"&&I.source&&(I.source.startsWith(".")||I.source.startsWith("/")))continue;if(I.name&&s.has(I.name))continue;if(I.name)s.add(I.name);i.push({declaration:I,file:O})}}let u=[];u.push("/**"),u.push(" * Bundled TypeScript declarations"),u.push(` * Generated from ${e.length} source files`),u.push(" */"),u.push("");let l=r.importOrder||["bun"],g=Array.from(n.values()),d=Array(g.length);for(let O=0;O<g.length;O++){let R=g[O].source,I=l.length;for(let B=0;B<l.length;B++)if(R.startsWith(l[B])){I=B;break}d[O]=I}let w=g.map((O,R)=>R);w.sort((O,R)=>{let I=d[O],B=d[R];if(I!==B)return I-B;return g[O].source.localeCompare(g[R].source)});let E=w.map((O)=>g[O]);for(let O of E)if(O.isSideEffect)u.push(`import '${O.source}';`);else if(O.specifiers.size>0){let R=Array.from(O.specifiers.values()).map((B)=>{let L=B.isType?"type ":"";return B.alias?`${L}${B.name} as ${B.alias}`:`${L}${B.name}`}),I=O.isTypeOnly?"type ":"";u.push(`import ${I}{ ${R.join(", ")} } from '${O.source}';`)}if(E.length>0)u.push("");let C=new Map;for(let{declaration:O,file:R}of i){if(!C.has(R))C.set(R,[]);C.get(R).push(O)}for(let[O,R]of C){let I=ed(r.cwd,O);u.push(`// From: ${I}`);for(let B of R){if(r.keepComments&&B.leadingComments)for(let L of B.leadingComments)u.push(L);u.push(ul(B))}u.push("")}let A=u.join(`
149
- `);return{content:A,files:e,declarationCount:a,importCount:o,exportCount:c,size:Buffer.byteLength(A,"utf8"),warnings:[]}}function ul(e){if(e.text){let r=e.text.trim();if(e.isExported&&!r.startsWith("export"))r=`export ${r}`;if(!r.endsWith(";")&&!r.endsWith("}"))r+=";";return r}let t=[];if(e.isExported)t.push("export");if(e.isDefault)t.push("default");switch(e.kind){case"function":if(t.push("declare function"),t.push(e.name),e.generics)t.push(e.generics);if(t.push(`(${td(e.parameters)})`),e.returnType)t.push(`: ${e.returnType}`);break;case"variable":if(t.push("declare const"),t.push(e.name),e.typeAnnotation)t.push(`: ${e.typeAnnotation}`);break;case"interface":if(t.push("interface"),t.push(e.name),e.generics)t.push(e.generics);if(e.extends)t.push(`extends ${e.extends}`);if(t.push("{"),e.members)for(let r of e.members)t.push(` ${r.name}${r.typeAnnotation?`: ${r.typeAnnotation}`:""};`);t.push("}");break;case"type":if(t.push("type"),t.push(e.name),e.generics)t.push(e.generics);t.push("="),t.push(e.typeAnnotation||"unknown");break;case"class":if(t.push("declare class"),t.push(e.name),e.generics)t.push(e.generics);if(e.extends)t.push(`extends ${e.extends}`);if(e.implements&&e.implements.length>0)t.push(`implements ${e.implements.join(", ")}`);if(t.push("{"),e.members)for(let r of e.members)t.push(` ${ul(r)}`);t.push("}");break;case"enum":if(t.push("declare enum"),t.push(e.name),t.push("{"),e.members){let r=e.members.map((n)=>n.value!==void 0?`${n.name} = ${n.value}`:n.name);t.push(` ${r.join(`,
150
- `)}`)}t.push("}");break;default:return e.text||""}return t.join(" ")}function td(e){if(!e||e.length===0)return"";return e.map((t)=>{let r="";if(t.rest)r+="...";if(r+=t.name,t.optional)r+="?";if(t.type)r+=`: ${t.type}`;if(t.defaultValue)r+=` = ${t.defaultValue}`;return r}).join(", ")}var hl=oe(()=>{os()});async function rd(){if(ki!==null)return ki;try{return Ot=await import("prettier"),ki=!0,!0}catch{return ki=!1,!1}}async function id(e,t){if(!Ot)return null;try{if(t&&Ot.resolveConfig){let r=await Ot.resolveConfig(t);if(r)return r}if(e&&Ot.resolveConfig){let r=await Ot.resolveConfig(e);if(r)return r}return null}catch{return null}}async function nd(e,t){if(!Ot)throw Error("Prettier is not available");let r={...t,parser:t.parser||"typescript"};return Ot.format(e,r)}function sd(e,t={}){let{indentSize:r=2,useTabs:n=!1,maxLineWidth:i=100,trailingNewline:s=!0,normalizeWhitespace:a=!0,sortImports:o=!0,groupImports:c=!0}=t,f=e,u=n?"\t":" ".repeat(r);if(f.indexOf(`\r
144
+ `){let a=n(),o=i(r+1);if(a===""||o===""){r++;continue}let c=Hh(t);if(!c&&("{;,(<:=[".includes(a)||"}),]>;|&".includes(o))){if(!t.endsWith(" ")&&!t.endsWith(";"))t+=" "}else if(c){if(!t.endsWith(" "))t+=" "}else{if(t.endsWith(" "))t=t.slice(0,-1);t+="; "}r++;while(r<e.length&&(e[r]===" "||e[r]==="\t"))r++;continue}t+=s,r++}return t}function Hh(e){let t=e.length-1;while(t>=0&&/\s/.test(e[t]))t--;if(t<1||e[t]!=="/"||e[t-1]!=="*")return!1;let r=e.lastIndexOf("/*",t);if(r===-1)return!1;for(let n=r-1;n>=0;n--){let i=e[n];if(/\s/.test(i))continue;return"{;,(<:".includes(i)}return!0}function ki(e,t){let r=[e,t].filter((n)=>n!==null);for(let n of r){let i=br(n,"defineProps");if(!i)continue;if(i.generic){let s=i.generic;if(s.startsWith("{"))return{type:s};if(/^[A-Za-z_$][\w$]*$/.test(s)){for(let a of r){let o=il(a,s);if(!o)continue;let c=Mh(a,s);if(c===null)continue;return{type:c,inlinedLocal:{name:s,declText:a.slice(o.start,o.end)}}}return{type:s}}return{type:s}}if(i.arg){let s=Pi(i.arg);if(s!==null)return{type:s}}}return null}function as(e,t){let r=[e,t].filter((n)=>n!==null);for(let n of r){let i=br(n,"defineEmits");if(!i)continue;if(i.generic)return Wh(i.generic)??i.generic;if(i.arg){let s=nl(i.arg);if(s!==null)return s}}return null}function os(e,t){let r=[e,t].filter((n)=>n!==null);for(let n of r){let i=br(n,"defineExpose");if(!i||!i.arg||!i.arg.startsWith("{"))continue;let s=Sr(i.arg);if(s.length===0)return null;return`{ ${s.map((a)=>{if(a.value===""&&/^[A-Za-z_$][\w$]*$/.test(a.key))return`${vr(a.key)}: typeof ${a.key}`;let o=a.isMethod||/=>|^\s*function\b/.test(a.value);return`${vr(a.key)}: ${o?"(...args: any[]) => any":"unknown"}`}).join(", ")} }`}return null}function sl(e){let t=kh(e),r="",n=null,i=null;if(t.script){let C=ns(t.script.content);if(C.passthrough)return t.scriptSetup?`${t.script.content}
145
+ ${t.scriptSetup.content}`:t.script.content;if(r=C.script,C.options){let x=Ti(C.options,"props");if(x)n=Pi(x);let P=Ti(C.options,"emits");if(P)i=nl(P)}}let s=t.scriptSetup?.content??null,a=s!==null?is(s):null,o=ki(s,s!==null?null:r),c=o?.type??n??"{}",f=as(s,null)??i,u=os(s,null),l=o?.inlinedLocal;if(l){if(r=Oi(r,l.name,l.declText),a!==null)a=Oi(a,l.name,l.declText)}let g=[c,u??"{}"];if(f)g.push("{}","{}","{}","{}","{}",f);let d=ss(`DefineComponent<${g.join(", ")}>`),$=[],v=Ri(r,d);if(v.trim()!=="")$.push(v);if(a&&a.trim()!==""){let C=Ri(a,d);if(C.trim()!=="")$.push(C)}return $.push("import type { DefineComponent } from 'vue'"),$.push(`type __DtsxComponentType = ${d}`),$.push("const __dtsx_component__: __DtsxComponentType = null as unknown as __DtsxComponentType"),$.push("export default __dtsx_component__"),$.join(`
146
+ `)}var tl;var ls=le(()=>{tl={String:"string",Number:"number",Boolean:"boolean",Array:"unknown[]",Object:"Record<string, unknown>",Function:"(...args: any[]) => any",Symbol:"symbol",Promise:"Promise<unknown>",Date:"Date",BigInt:"bigint"}});function ol(e){return e.endsWith(".stx")}function jh(e){let t=[],r=/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi,n;while((n=r.exec(e))!==null){let i=n[1]??"",s=/\blang\s*=\s*["']([^"']+)["']/i.exec(i)?.[1]?.toLowerCase()??(/\b(?:type\s*=\s*["'](?:text\/)?typescript["']|typescript)\b/i.test(i)?"ts":"js"),a=/\bserver\b/i.test(i)?"server":/\bclient\b/i.test(i)?"client":"universal";t.push({content:n[2]??"",kind:"script",attrs:i,context:a,lang:s,start:n.index})}return t}function Kh(e){let t=[],r=/^[ \t]*@ts[ \t]*(?:\r?\n|$)/gm,n;while((n=r.exec(e))!==null){let i=r.lastIndex,s=/^[ \t]*@endts[ \t]*(?:\r?\n|$)/gm;s.lastIndex=i;let a=s.exec(e),o=a?.index??e.length;if(t.push({content:e.slice(i,o),kind:"ts",attrs:"",context:"universal",lang:"ts",start:n.index}),!a)break;r.lastIndex=s.lastIndex}return t}function Jh(e){return[...jh(e),...Kh(e)].sort((t,r)=>t.start-r.start)}function Uh(e){if(e.kind==="ts"||e.context!=="universal"||e.lang==="ts")return!0;return/\b(?:defineProps|defineEmits|defineExpose|defineSlots)\b|\bexport\s|\b(?:interface|type)\s+[A-Za-z_$]/.test(e.content)}function Yh(e){let t=/(?:\$?props)\s+as\s+/g,r;while((r=t.exec(e))!==null){let n=t.lastIndex;while(n<e.length&&/\s/.test(e[n]))n++;if(e[n]==="{"){let a=Le(e,n,"{","}");if(a!==-1)return e.slice(n,a+1).trim();continue}let i=/^[A-Za-z_$][\w$]*/.exec(e.slice(n))?.[0];if(!i)continue;let s=n+i.length;while(s<e.length&&/\s/.test(e[s]))s++;if(e[s]==="<"){let a=Le(e,s,"<",">");if(a!==-1)s=a+1}return e.slice(n,s).trim()}return null}function Zh(e){return/\b(?:const|let|var)\s+\$?props\s*:\s*([^=;\n]+)/.exec(e)?.[1]?.trim()??null}function qh(e){let t=/^\s*(?:\|\||\?\?)\s*([^;\n]+)/.exec(e)?.[1]?.trim();if(/^['"`]/.test(t??""))return"string";if(/^(?:true|false)\b/.test(t??""))return"boolean";if(/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)\b/.test(t??""))return"number";if(/^\[/.test(t??""))return"unknown[]";if(/^\{/.test(t??""))return"Record<string, unknown>";if(/^\s*(?:===?|!==?)\s*(?:true|false)\b/.test(e))return"boolean";return"unknown"}function Xh(e,t){if(!e||e==="unknown")return t;if(t==="unknown"||e===t)return e;return[...new Set([...e.split(" | "),...t.split(" | ")])].join(" | ")}function zh(e){let t=ts(e),r=new Map,n=/\$props(?:\.([A-Za-z_$][\w$]*)|\[\s*(['"])([^'"\n]+)\2\s*\])/g,i;while((i=n.exec(e))!==null){if(t.slice(i.index,i.index+6)!=="$props")continue;let s=i[1]??i[3],a=qh(e.slice(n.lastIndex));r.set(s,Xh(r.get(s),a))}if(r.size===0)return null;return{type:`{ ${[...r].map(([s,a])=>{return`${/^[A-Za-z_$][\w$]*$/.test(s)?s:JSON.stringify(s)}?: ${a}`}).join(", ")} }`}}function Qh(e){let t=ki(e,null);if(t)return t;let r=Yh(e)??Zh(e);if(!r)return zh(e);if(/^[A-Za-z_$][\w$]*$/.test(r)){let n=r.replace(/[$]/g,"\\$&");if(new RegExp(`\\bexport\\s+(?:declare\\s+)?(?:interface|type)\\s+${n}\\b`).test(e))return{type:r}}return ki(`${e}
147
+ defineProps<${r}>()`,null)}function ed(e){return is(e)}function al(e){let t=ts(e).trimStart();if(t==="")return!0;return/^(?:import\b|export\b|declare\b|interface\b|type\b|(?:export\s+)?namespace\b|(?:export\s+)?module\b|(?:abstract\s+)?class\b|const\b|let\b|var\b|(?:async\s+)?function\b)/.test(t)}function td(e){let t=[],r=0,n=0,i=0;while(i<e.length){let a=e[i],o=es(e,i);if(o>i){i=o;continue}if(a==="{"||a==="["||a==="(")n++;else if(a==="}"||a==="]"||a===")")n=Math.max(0,n-1);if((a===";"||a===`
148
+ `)&&n===0){let c=i+1;if(!al(e.slice(r,c)))t.push([r,c]);r=c}i++}if(r<e.length&&!al(e.slice(r)))t.push([r,e.length]);let s=e;for(let a=t.length-1;a>=0;a--)s=s.slice(0,t[a][0])+s.slice(t[a][1]);return s}function ll(e){let t=Jh(e).filter(Uh).map((v)=>v.content).join(`
149
+ `),r=null,n=ns(t);if(n.passthrough)return t;if(t=n.script,n.options){let v=Ti(n.options,"props");if(v)r=Pi(v)}let i=t,s=ed(t),a=Qh(i),o=a?.type??r??"{}",c=as(i,null),f=os(i,null),u=br(i,"defineSlots")?.generic??null,l=a?.inlinedLocal;if(l)s=Oi(s,l.name,l.declText);let g=`DefineComponent<${o}>`,d=[];if(c)d.push(`readonly __stxEmits?: ${c}`);if(u)d.push(`readonly __stxSlots?: ${u}`);if(f)d.push(`readonly __stxExposed?: ${f}`);if(d.length>0)g+=` & { ${d.join(", ")} }`;g=ss(g),s=td(Ri(s,g));let $=["import type { DefineComponent } from '@stacksjs/stx'",`type __DtsxStxComponentType = ${g}`,"const __dtsx_component__: __DtsxStxComponentType = null as unknown as __DtsxStxComponentType","export default __dtsx_component__"];if(s.trim()!=="")$.push(s);return $.join(`
150
+ `)}var cl=le(()=>{ls()});function ul(e,t,r=!0,n=!1){if(rl(t))e=sl(e);else if(ol(t))e=ll(e);let i=cr(e),s=`${t}:${r?1:0}:${n?1:0}`,a=nr.get(s);if(a&&a.contentHash===i)return a.lastAccess=++fl,a.declarations;let o=n?Xo(e,t,r):zo(e,t,r);if(nr.set(s,{declarations:o,contentHash:i,lastAccess:++fl}),nr.size>rd){let c=Math.max(1,Math.ceil(nr.size*0.1)),f=[];for(let[u,l]of nr)f.push([u,l.lastAccess]);f.sort((u,l)=>u[1]-l[1]);for(let u=0;u<c&&u<f.length;u++)nr.delete(f[u][0])}return o}var rd=100,fl=0,nr;var hl=le(()=>{el();Zi();cl();ls();nr=new Map});function Mi(e,t,r=!0,n=!1){return ul(e,t,r,n)}var cs=le(()=>{hl()});import{dirname as Ay,relative as id,resolve as xy}from"path";async function dl(e,t,r){let n=new Map,i=[],s=new Set,a=0,o=0,c=0,f=[];for(let P of e){let R=t.get(P);if(!R)continue;f.push({file:P,decls:Mi(R,P,r.keepComments)})}for(let{file:P,decls:R}of f){a+=R.length;for(let I of R)if(I.kind==="import"){o++;let B=I.source||"";if(B.startsWith("."))continue;if(!n.has(B))n.set(B,{source:B,specifiers:new Map,isTypeOnly:I.isTypeOnly||!1,isSideEffect:I.isSideEffect||!1});let W=n.get(B);if(I.specifiers)for(let T of I.specifiers){let D=T.alias||T.name;if(!W.specifiers.has(D))W.specifiers.set(D,{name:T.name,alias:T.alias,isType:T.isType||!1})}if(!I.isTypeOnly)W.isTypeOnly=!1}else if(I.isExported||I.kind==="export"){if(c++,I.kind==="export"&&I.source&&(I.source.startsWith(".")||I.source.startsWith("/")))continue;if(I.name&&s.has(I.name))continue;if(I.name)s.add(I.name);i.push({declaration:I,file:P})}}let u=[];u.push("/**"),u.push(" * Bundled TypeScript declarations"),u.push(` * Generated from ${e.length} source files`),u.push(" */"),u.push("");let l=r.importOrder||["bun"],g=Array.from(n.values()),d=Array(g.length);for(let P=0;P<g.length;P++){let R=g[P].source,I=l.length;for(let B=0;B<l.length;B++)if(R.startsWith(l[B])){I=B;break}d[P]=I}let $=g.map((P,R)=>R);$.sort((P,R)=>{let I=d[P],B=d[R];if(I!==B)return I-B;return g[P].source.localeCompare(g[R].source)});let v=$.map((P)=>g[P]);for(let P of v)if(P.isSideEffect)u.push(`import '${P.source}';`);else if(P.specifiers.size>0){let R=Array.from(P.specifiers.values()).map((B)=>{let W=B.isType?"type ":"";return B.alias?`${W}${B.name} as ${B.alias}`:`${W}${B.name}`}),I=P.isTypeOnly?"type ":"";u.push(`import ${I}{ ${R.join(", ")} } from '${P.source}';`)}if(v.length>0)u.push("");let C=new Map;for(let{declaration:P,file:R}of i){if(!C.has(R))C.set(R,[]);C.get(R).push(P)}for(let[P,R]of C){let I=id(r.cwd,P);u.push(`// From: ${I}`);for(let B of R){if(r.keepComments&&B.leadingComments)for(let W of B.leadingComments)u.push(W);u.push(ml(B))}u.push("")}let x=u.join(`
151
+ `);return{content:x,files:e,declarationCount:a,importCount:o,exportCount:c,size:Buffer.byteLength(x,"utf8"),warnings:[]}}function ml(e){if(e.text){let r=e.text.trim();if(e.isExported&&!r.startsWith("export"))r=`export ${r}`;if(!r.endsWith(";")&&!r.endsWith("}"))r+=";";return r}let t=[];if(e.isExported)t.push("export");if(e.isDefault)t.push("default");switch(e.kind){case"function":if(t.push("declare function"),t.push(e.name),e.generics)t.push(e.generics);if(t.push(`(${nd(e.parameters)})`),e.returnType)t.push(`: ${e.returnType}`);break;case"variable":if(t.push("declare const"),t.push(e.name),e.typeAnnotation)t.push(`: ${e.typeAnnotation}`);break;case"interface":if(t.push("interface"),t.push(e.name),e.generics)t.push(e.generics);if(e.extends)t.push(`extends ${e.extends}`);if(t.push("{"),e.members)for(let r of e.members)t.push(` ${r.name}${r.typeAnnotation?`: ${r.typeAnnotation}`:""};`);t.push("}");break;case"type":if(t.push("type"),t.push(e.name),e.generics)t.push(e.generics);t.push("="),t.push(e.typeAnnotation||"unknown");break;case"class":if(t.push("declare class"),t.push(e.name),e.generics)t.push(e.generics);if(e.extends)t.push(`extends ${e.extends}`);if(e.implements&&e.implements.length>0)t.push(`implements ${e.implements.join(", ")}`);if(t.push("{"),e.members)for(let r of e.members)t.push(` ${ml(r)}`);t.push("}");break;case"enum":if(t.push("declare enum"),t.push(e.name),t.push("{"),e.members){let r=e.members.map((n)=>n.value!==void 0?`${n.name} = ${n.value}`:n.name);t.push(` ${r.join(`,
152
+ `)}`)}t.push("}");break;default:return e.text||""}return t.join(" ")}function nd(e){if(!e||e.length===0)return"";return e.map((t)=>{let r="";if(t.rest)r+="...";if(r+=t.name,t.optional)r+="?";if(t.type)r+=`: ${t.type}`;if(t.defaultValue)r+=` = ${t.defaultValue}`;return r}).join(", ")}var pl=le(()=>{cs()});async function sd(){if(Ii!==null)return Ii;try{return Tt=await import("prettier"),Ii=!0,!0}catch{return Ii=!1,!1}}async function ad(e,t){if(!Tt)return null;try{if(t&&Tt.resolveConfig){let r=await Tt.resolveConfig(t);if(r)return r}if(e&&Tt.resolveConfig){let r=await Tt.resolveConfig(e);if(r)return r}return null}catch{return null}}async function od(e,t){if(!Tt)throw Error("Prettier is not available");let r={...t,parser:t.parser||"typescript"};return Tt.format(e,r)}function ld(e,t={}){let{indentSize:r=2,useTabs:n=!1,maxLineWidth:i=100,trailingNewline:s=!0,normalizeWhitespace:a=!0,sortImports:o=!0,groupImports:c=!0}=t,f=e,u=n?"\t":" ".repeat(r);if(f.indexOf(`\r
151
153
  `)!==-1)f=f.replace(/\r\n/g,`
152
154
  `);if(a){if(/[ \t]\n/.test(f)||/[ \t]$/.test(f))f=f.replace(/[ \t]+$/gm,"");if(f.indexOf(`
153
155
 
154
156
 
155
157
  `)!==-1)f=f.replace(/\n{3,}/g,`
156
158
 
157
- `);f=ad(f,u)}if(o||c)f=od(f,{sort:o,group:c});if(i>0)f=cd(f,i,u);if(s&&!f.endsWith(`
159
+ `);f=cd(f,u)}if(o||c)f=fd(f,{sort:o,group:c});if(i>0)f=hd(f,i,u);if(s&&!f.endsWith(`
158
160
  `))f+=`
159
- `;return f}function ad(e,t){let r=e.split(`
161
+ `;return f}function cd(e,t){let r=e.split(`
160
162
  `),n=[];for(let i of r){let s=i.match(/^(\s*)(.*)$/);if(!s){n.push(i);continue}let[,a,o]=s;if(!o){n.push("");continue}let c=a.replace(/\t/g," ").length,f=Math.floor(c/2);n.push(t.repeat(f)+o)}return n.join(`
161
- `)}function od(e,t){let r=e.split(`
162
- `),n=[],i=[],s=!1,a=0;for(let c=0;c<r.length;c++){let f=r[c],u=f.match(/^(import\s+(?:type\s+)?.*from\s+['"])([^'"]+)(['"].*)$/);if(u){s=!0,a=c;let l=u[1];n.push({line:f,source:u[2],isType:l.startsWith("import type ")||l.startsWith("import type\t")})}else if(s&&f.trim()==="")continue;else{if(s)s=!1;i.push(f)}}if(n.length===0)return e;if(t.sort)n.sort((c,f)=>{if(c.isType!==f.isType)return c.isType?1:-1;return ld(c.source,f.source)});let o;if(t.group){let c=[],f=[],u=[],l=[],g=[];for(let d=0;d<n.length;d++){let w=n[d],E=w.source;if(E.charCodeAt(0)===46)g.push(w);else if(E.startsWith("node:"))c.push(w);else if(E.charCodeAt(0)===64)l.push(w);else if(E.includes("/"))u.push(w);else f.push(w)}o=[...c.map((d)=>d.line),...c.length>0&&f.length>0?[""]:[],...f.map((d)=>d.line),...(c.length>0||f.length>0)&&u.length>0?[""]:[],...u.map((d)=>d.line),...l.length>0&&(c.length>0||f.length>0||u.length>0)?[""]:[],...l.map((d)=>d.line),...g.length>0?[""]:[],...g.map((d)=>d.line)]}else o=n.map((c)=>c.line);return[...o,"",...i].join(`
163
- `)}function ld(e,t){let r=e.startsWith("node:"),n=t.startsWith("node:");if(r!==n)return r?-1:1;let i=e.startsWith("."),s=t.startsWith(".");if(i!==s)return i?1:-1;return e.localeCompare(t)}function cd(e,t,r){let n=e.split(`
164
- `),i=[];for(let s of n){if(s.length<=t){i.push(s);continue}if(s.trimStart().startsWith("import ")){i.push(s);continue}let a=s.match(/^(\s*)/)?.[1]||"",o=a+r;if(s.includes("{")&&s.includes("}")){let c=fd(s,t,a,o);i.push(...c);continue}if(s.includes(" | ")){let c=ud(s,t,a,o);i.push(...c);continue}i.push(s)}return i.join(`
165
- `)}function fd(e,t,r,n){let i=e.match(/^(\s*)(.*?)(\{)(.+)(\}.*)$/);if(!i)return[e];let[,,s,a,o,c]=i,f=o.split(/;\s*|,\s*/).filter((u)=>u.trim());if(f.length<=1)return[e];return[`${r}${s}${a}`,...f.map((u)=>`${n}${u.trim()};`),`${r}${c.trim()}`]}function ud(e,t,r,n){let i=e.match(/^(\s*)(.*?=\s*)(.+)$/);if(!i)return[e];let[,,s,a]=i,o=a.split(/\s*\|\s*/).filter((c)=>c.trim());if(o.length<=2)return[e];return[`${r}${s}`,...o.map((c,f)=>`${n}${f>0?"| ":" "}${c.trim()}`)]}async function dl(e,t={},r){let n=[];if(t.usePrettier!==!1){if(await rd())try{let i={...await id(t.prettierConfigPath,r),...t.prettierOptions,parser:"typescript"};return{content:await nd(e,i),usedPrettier:!0}}catch(i){n.push(`Prettier formatting failed: ${i}. Using built-in formatter.`)}else if(t.usePrettier===!0)n.push("Prettier requested but not available. Using built-in formatter.")}return{content:sd(e,t.builtIn),usedPrettier:!1,warnings:n.length>0?n:void 0}}var ki=null,Ot=null;var ml=()=>{};function pl(e,t,r){let n={file:t,message:"Unknown error",code:br.UNKNOWN_ERROR};if(e instanceof Error){n.message=e.message,n.stack=e.stack;let i=e.message.match(/\((\d+),(\d+)\)/);if(i)n.location={line:Number.parseInt(i[1],10),column:Number.parseInt(i[2],10)};if(e.message.includes("Cannot find")||e.message.includes("not found"))n.code=br.FILE_NOT_FOUND,n.suggestion="Check that the file path is correct and the file exists.";else if(e.message.includes("syntax")||e.message.includes("Unexpected token"))n.code=br.SYNTAX_ERROR,n.suggestion="Check for syntax errors in your TypeScript code.";else if(e.message.includes("type")&&e.message.includes("cannot"))n.code=br.TYPE_INFERENCE_ERROR,n.suggestion="Add explicit type annotations to help with type inference.";else if(e.message.includes("parse")||e.message.includes("Parse"))n.code=br.PARSE_ERROR,n.suggestion="The file contains invalid TypeScript syntax."}else if(typeof e==="string")n.message=e;return n}function gl(e,t){let r=[],n=e.file;if(e.location)n+=`:${e.location.line}:${e.location.column}`;if(e.code)n+=` [${e.code}]`;if(r.push(n),r.push(` Error: ${e.message}`),t&&e.location){r.push("");let i=t.split(`
163
+ `)}function fd(e,t){let r=e.split(`
164
+ `),n=[],i=[],s=!1,a=0;for(let c=0;c<r.length;c++){let f=r[c],u=f.match(/^(import\s+(?:type\s+)?.*from\s+['"])([^'"]+)(['"].*)$/);if(u){s=!0,a=c;let l=u[1];n.push({line:f,source:u[2],isType:l.startsWith("import type ")||l.startsWith("import type\t")})}else if(s&&f.trim()==="")continue;else{if(s)s=!1;i.push(f)}}if(n.length===0)return e;if(t.sort)n.sort((c,f)=>{if(c.isType!==f.isType)return c.isType?1:-1;return ud(c.source,f.source)});let o;if(t.group){let c=[],f=[],u=[],l=[],g=[];for(let d=0;d<n.length;d++){let $=n[d],v=$.source;if(v.charCodeAt(0)===46)g.push($);else if(v.startsWith("node:"))c.push($);else if(v.charCodeAt(0)===64)l.push($);else if(v.includes("/"))u.push($);else f.push($)}o=[...c.map((d)=>d.line),...c.length>0&&f.length>0?[""]:[],...f.map((d)=>d.line),...(c.length>0||f.length>0)&&u.length>0?[""]:[],...u.map((d)=>d.line),...l.length>0&&(c.length>0||f.length>0||u.length>0)?[""]:[],...l.map((d)=>d.line),...g.length>0?[""]:[],...g.map((d)=>d.line)]}else o=n.map((c)=>c.line);return[...o,"",...i].join(`
165
+ `)}function ud(e,t){let r=e.startsWith("node:"),n=t.startsWith("node:");if(r!==n)return r?-1:1;let i=e.startsWith("."),s=t.startsWith(".");if(i!==s)return i?1:-1;return e.localeCompare(t)}function hd(e,t,r){let n=e.split(`
166
+ `),i=[];for(let s of n){if(s.length<=t){i.push(s);continue}if(s.trimStart().startsWith("import ")){i.push(s);continue}let a=s.match(/^(\s*)/)?.[1]||"",o=a+r;if(s.includes("{")&&s.includes("}")){let c=dd(s,t,a,o);i.push(...c);continue}if(s.includes(" | ")){let c=md(s,t,a,o);i.push(...c);continue}i.push(s)}return i.join(`
167
+ `)}function dd(e,t,r,n){let i=e.match(/^(\s*)(.*?)(\{)(.+)(\}.*)$/);if(!i)return[e];let[,,s,a,o,c]=i,f=o.split(/;\s*|,\s*/).filter((u)=>u.trim());if(f.length<=1)return[e];return[`${r}${s}${a}`,...f.map((u)=>`${n}${u.trim()};`),`${r}${c.trim()}`]}function md(e,t,r,n){let i=e.match(/^(\s*)(.*?=\s*)(.+)$/);if(!i)return[e];let[,,s,a]=i,o=a.split(/\s*\|\s*/).filter((c)=>c.trim());if(o.length<=2)return[e];return[`${r}${s}`,...o.map((c,f)=>`${n}${f>0?"| ":" "}${c.trim()}`)]}async function gl(e,t={},r){let n=[];if(t.usePrettier!==!1){if(await sd())try{let i={...await ad(t.prettierConfigPath,r),...t.prettierOptions,parser:"typescript"};return{content:await od(e,i),usedPrettier:!0}}catch(i){n.push(`Prettier formatting failed: ${i}. Using built-in formatter.`)}else if(t.usePrettier===!0)n.push("Prettier requested but not available. Using built-in formatter.")}return{content:ld(e,t.builtIn),usedPrettier:!1,warnings:n.length>0?n:void 0}}var Ii=null,Tt=null;var yl=()=>{};function Cl(e,t,r){let n={file:t,message:"Unknown error",code:Ar.UNKNOWN_ERROR};if(e instanceof Error){n.message=e.message,n.stack=e.stack;let i=e.message.match(/\((\d+),(\d+)\)/);if(i)n.location={line:Number.parseInt(i[1],10),column:Number.parseInt(i[2],10)};if(e.message.includes("Cannot find")||e.message.includes("not found"))n.code=Ar.FILE_NOT_FOUND,n.suggestion="Check that the file path is correct and the file exists.";else if(e.message.includes("syntax")||e.message.includes("Unexpected token"))n.code=Ar.SYNTAX_ERROR,n.suggestion="Check for syntax errors in your TypeScript code.";else if(e.message.includes("type")&&e.message.includes("cannot"))n.code=Ar.TYPE_INFERENCE_ERROR,n.suggestion="Add explicit type annotations to help with type inference.";else if(e.message.includes("parse")||e.message.includes("Parse"))n.code=Ar.PARSE_ERROR,n.suggestion="The file contains invalid TypeScript syntax."}else if(typeof e==="string")n.message=e;return n}function wl(e,t){let r=[],n=e.file;if(e.location)n+=`:${e.location.line}:${e.location.column}`;if(e.code)n+=` [${e.code}]`;if(r.push(n),r.push(` Error: ${e.message}`),t&&e.location){r.push("");let i=t.split(`
166
168
  `),s=e.location.line-1;if(s>=0&&s<i.length){let a=Math.max(0,s-1),o=Math.min(i.length-1,s+1);for(let c=a;c<=o;c++){let f=(c+1).toString().padStart(4," "),u=c===s?">":" ";if(r.push(` ${u} ${f} | ${i[c]}`),c===s&&e.location.column>0){let l=" ".repeat(10+e.location.column-1);r.push(` ${l}^`)}}}}if(e.suggestion)r.push(""),r.push(` Suggestion: ${e.suggestion}`);return r.join(`
167
- `)}var br;var yl=oe(()=>{br={PARSE_ERROR:"PARSE_ERROR",SYNTAX_ERROR:"SYNTAX_ERROR",FILE_NOT_FOUND:"FILE_NOT_FOUND",FILE_READ_ERROR:"FILE_READ_ERROR",FILE_WRITE_ERROR:"FILE_WRITE_ERROR",TYPE_INFERENCE_ERROR:"TYPE_INFERENCE_ERROR",UNRESOLVED_TYPE:"UNRESOLVED_TYPE",EXTRACTION_ERROR:"EXTRACTION_ERROR",PROCESSING_ERROR:"PROCESSING_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_DECLARATION:"INVALID_DECLARATION",CONFIG_ERROR:"CONFIG_ERROR",INVALID_ENTRYPOINT:"INVALID_ENTRYPOINT",CIRCULAR_DEPENDENCY:"CIRCULAR_DEPENDENCY",TIMEOUT_ERROR:"TIMEOUT_ERROR",NOT_SUPPORTED:"NOT_SUPPORTED",UNKNOWN_ERROR:"UNKNOWN_ERROR"}});function $l(e,t={}){let{lineEnding:r="lf",trailingNewline:n=!0,maxBlankLines:i=1,trimTrailingWhitespace:s=!0,normalizeIndentation:a=!0,indent:o={style:"spaces",size:2},declarationOrder:c,importGrouping:f,preserveComments:u=!0,insertFinalNewline:l=!0}=t,g=e;if(g=md(g,r),f?.enabled!==!1)g=wd(g,f||{});if(c)g=$d(g,c);if(s)g=pd(g);if(g=gd(g,i),a)g=Cd(g,o);if(n||l)g=yd(g);return g}function md(e,t){let r=e;if(e.indexOf("\r")!==-1){if(e.indexOf(`\r
169
+ `)}var Ar;var $l=le(()=>{Ar={PARSE_ERROR:"PARSE_ERROR",SYNTAX_ERROR:"SYNTAX_ERROR",FILE_NOT_FOUND:"FILE_NOT_FOUND",FILE_READ_ERROR:"FILE_READ_ERROR",FILE_WRITE_ERROR:"FILE_WRITE_ERROR",TYPE_INFERENCE_ERROR:"TYPE_INFERENCE_ERROR",UNRESOLVED_TYPE:"UNRESOLVED_TYPE",EXTRACTION_ERROR:"EXTRACTION_ERROR",PROCESSING_ERROR:"PROCESSING_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_DECLARATION:"INVALID_DECLARATION",CONFIG_ERROR:"CONFIG_ERROR",INVALID_ENTRYPOINT:"INVALID_ENTRYPOINT",CIRCULAR_DEPENDENCY:"CIRCULAR_DEPENDENCY",TIMEOUT_ERROR:"TIMEOUT_ERROR",NOT_SUPPORTED:"NOT_SUPPORTED",UNKNOWN_ERROR:"UNKNOWN_ERROR"}});function Sl(e,t={}){let{lineEnding:r="lf",trailingNewline:n=!0,maxBlankLines:i=1,trimTrailingWhitespace:s=!0,normalizeIndentation:a=!0,indent:o={style:"spaces",size:2},declarationOrder:c,importGrouping:f,preserveComments:u=!0,insertFinalNewline:l=!0}=t,g=e;if(g=yd(g,r),f?.enabled!==!1)g=vd(g,f||{});if(c)g=Sd(g,c);if(s)g=Cd(g);if(g=wd(g,i),a)g=Ed(g,o);if(n||l)g=$d(g);return g}function yd(e,t){let r=e;if(e.indexOf("\r")!==-1){if(e.indexOf(`\r
168
170
  `)!==-1)r=r.replace(/\r\n/g,`
169
171
  `);if(r.indexOf("\r")!==-1)r=r.replace(/\r/g,`
170
172
  `)}if(t==="crlf")r=r.replace(/\n/g,`\r
171
- `);return r}function pd(e){return e.split(`
173
+ `);return r}function Cd(e){return e.split(`
172
174
  `).map((t)=>t.replace(/[\t ]+$/,"")).join(`
173
- `)}function gd(e,t){let r=new RegExp(`\\n{${t+2},}`,"g");return e.replace(r,`
174
- `.repeat(t+1))}function yd(e){return`${e.replace(/\s+$/,"")}
175
- `}function Cd(e,t){let{style:r="spaces",size:n=2}=t,i=r==="tabs"?"\t":" ".repeat(n),s=e.split(`
175
+ `)}function wd(e,t){let r=new RegExp(`\\n{${t+2},}`,"g");return e.replace(r,`
176
+ `.repeat(t+1))}function $d(e){return`${e.replace(/\s+$/,"")}
177
+ `}function Ed(e,t){let{style:r="spaces",size:n=2}=t,i=r==="tabs"?"\t":" ".repeat(n),s=e.split(`
176
178
  `),a=[];for(let o of s){let c=o.match(/^([\t ]*)(.*)$/);if(!c){a.push(o);continue}let[,f,u]=c;if(!u){a.push("");continue}let l=f.replace(/\t/g," "),g=Math.floor(l.length/2);a.push(i.repeat(g)+u)}return a.join(`
177
- `)}function wd(e,t){let{groups:r=dd,separateGroups:n=!0,alphabetize:i=!0}=t,s=e.split(`
178
- `),a=[],o=[],c=-1;for(let w=0;w<s.length;w++){let E=s[w],C=Cl(E);if(C)a.push({line:E,source:C.source,group:C.group,isType:C.isType}),c=w;else if(a.length>0&&E.trim()==="")continue;else if(a.length>0||E.trim()!==""){if(a.length===0||w>c+1)o.push(E)}}if(a.length===0)return e;let f=new Map;for(let w of r)f.set(w,[]);for(let w of a)(f.get(w.group)||f.get("external")||[]).push(w);if(i)for(let[,w]of f)w.sort((E,C)=>{if(E.isType!==C.isType)return E.isType?1:-1;return E.source.localeCompare(C.source)});let u=[],l=null;for(let w of r){let E=f.get(w)||[];if(E.length===0)continue;if(n&&l!==null)u.push("");for(let C of E)u.push(C.line);l=w}let g=s.slice(0,s.findIndex((w)=>Cl(w)!==null)),d=o;while(d.length>0&&d[0].trim()==="")d.shift();return[...g,...u,"",...d].join(`
179
- `)}function Cl(e){let t=e.trim(),r=t.match(/^import\s+(type\s+)?.*from\s+['"]([^'"]+)['"]/);if(!r){let s=t.match(/^import\s+['"]([^'"]+)['"]/);if(s)return{source:s[1],group:wl(s[1]),isType:!1};return null}let n=!!r[1],i=r[2];return{source:i,group:n?"type":wl(i),isType:n}}function wl(e){if(e.startsWith("node:"))return"builtin";let t=["assert","buffer","child_process","cluster","crypto","dgram","dns","events","fs","http","https","net","os","path","querystring","readline","stream","url","util","zlib"];if(t.includes(e)||t.includes(e.split("/")[0]))return"builtin";if(e==="."||e==="./index"||e==="./index.js"||e==="./index.ts")return"index";if(e.startsWith("./"))return"sibling";if(e.startsWith("../"))return"parent";if(e.startsWith("@/")||e.startsWith("~/")||e.startsWith("#"))return"internal";if(e.startsWith("@"))return"scoped";return"external"}function $d(e,t){let{kinds:r=hd,alphabetize:n=!1,groupExports:i=!0}=t,s=e.split(`
180
- `),a=[],o=[],c=[],f=null,u=0,l=!0,g=!1,d=[];for(let C=0;C<s.length;C++){let A=s[C],O=A.trim(),R=u,I=O.startsWith("///"),B=R===0&&!I&&(O.startsWith("//")||O.startsWith("/*"));if(g||B){if(d.push(A),!g&&O.startsWith("/*")&&!O.includes("*/"))g=!0;else if(g&&O.includes("*/"))g=!1;continue}if(R===0&&d.length>0&&O===""){d.push(A);continue}u+=(A.match(/\{/g)||[]).length,u-=(A.match(/\}/g)||[]).length;let L=Ed(O);if(l&&L&&L.kind!=="import"&&!O.startsWith("//")&&!O.startsWith("/*"))l=!1;if(l){if(d.length>0){if(L?.kind==="import"||!L)o.push(...d),d.length=0}o.push(A);continue}if(L&&u<=1){if(f)a.push(f);f={lines:d.length>0?[...d,A]:[A],kind:L.kind,name:L.name,isExport:L.isExport},d.length=0}else if(f)f.lines.push(A);else{if(O==="")continue;c.push(A)}}if(f)a.push(f);if(d.length>0)c.push(...d);a.sort((C,A)=>{if(i&&C.isExport!==A.isExport)return C.isExport?-1:1;let O=r.indexOf(C.kind),R=r.indexOf(A.kind),I=O>=0?O:r.length,B=R>=0?R:r.length;if(I!==B)return I-B;if(n)return C.name.localeCompare(A.name);return 0});let w=[...o],E=null;for(let C of a){if(E!==null&&C.kind!==E)w.push("");w.push(...C.lines),E=C.kind}if(c.length>0)w.push(""),w.push(...c);return w.join(`
181
- `)}function Ed(e){let t=e.startsWith("export "),r=t?e.slice(7):e;if(e.startsWith("import "))return{kind:"import",name:e.match(/from\s+['"]([^'"]+)['"]/)?.[1]||"",isExport:!1};if(r.startsWith("type ")||r.startsWith("declare type "))return{kind:"type",name:r.match(/type\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("interface ")||r.startsWith("declare interface "))return{kind:"interface",name:r.match(/interface\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("class ")||r.startsWith("abstract class ")||r.startsWith("declare class ")||r.startsWith("declare abstract class "))return{kind:"class",name:r.match(/class\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("enum ")||r.startsWith("const enum ")||r.startsWith("declare enum ")||r.startsWith("declare const enum "))return{kind:"enum",name:r.match(/enum\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("function ")||r.startsWith("async function ")||r.startsWith("declare function ")||r.startsWith("declare async function "))return{kind:"function",name:r.match(/function\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("const ")||r.startsWith("let ")||r.startsWith("var ")||r.startsWith("declare const ")||r.startsWith("declare let ")||r.startsWith("declare var "))return{kind:"variable",name:r.match(/(?:const|let|var)\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("namespace ")||r.startsWith("declare namespace "))return{kind:"namespace",name:r.match(/namespace\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("module ")||r.startsWith("declare module "))return{kind:"module",name:r.match(/module\s+['"]?(\w+)['"]?/)?.[1]||"",isExport:t};if(e.startsWith("export {")||e.startsWith("export *")||e.startsWith("export type {"))return{kind:"export",name:"",isExport:!0};return null}var hd,dd;var El=oe(()=>{hd=["import","type","interface","enum","class","function","variable","export","module","namespace","unknown"],dd=["builtin","external","scoped","internal","parent","sibling","index","type"]});function xd(e){switch(e){case"strict":return Sd;case"readonly":return bd;case"simplified":return Ad;case"nullable":return[{pattern:/^(.+)\s*\|\s*undefined$/,replacement:"$1 | undefined",priority:5}];case"branded":return[{pattern:/^string$/,replacement:"string",condition:(t)=>t.declarationKind==="variable"&&(t.declarationName?.includes("path")??!1),priority:5}];default:return[]}}class Sl{rules;compiled=[];cache=new Map;constructor(e={rules:[]}){if(this.rules=[],e.includeDefaults!==!1)this.rules.push(...vd);if(e.presets)for(let t of e.presets)this.rules.push(...xd(t));this.rules.push(...e.rules),this.rules.sort((t,r)=>(r.priority||0)-(t.priority||0)),this.recompile()}recompile(){let e=Array(this.rules.length);for(let t=0;t<this.rules.length;t++){let r=this.rules[t],n=typeof r.pattern==="string"?new RegExp(r.pattern.replace(Td,"\\$&"),r.global?"g":""):r.pattern;e[t]={rule:r,regex:n}}this.compiled=e}map(e,t={}){let r=!t.declarationName&&!t.declarationKind&&!t.filePath&&!t.isReturnType&&!t.isParameterType&&!t.isPropertyType?e:`${e}\x00${t.declarationName??""}\x00${t.declarationKind??""}\x00${t.filePath??""}\x00${t.isReturnType?"r":""}${t.isParameterType?"p":""}${t.isPropertyType?"P":""}`,n=this.cache.get(r);if(n!==void 0)return n;let i=e,s=null;for(let a=0;a<this.compiled.length;a++){let{rule:o,regex:c}=this.compiled[a];if(o.condition){if(!s)s={type:e,...t};if(!o.condition(s))continue}if(c.lastIndex=0,c.test(i)){if(c.lastIndex=0,i=i.replace(c,o.replacement),c.lastIndex=0,!o.global)break}}if(this.cache.size>=vl){let a=Math.ceil(vl*0.1),o=0;for(let c of this.cache.keys()){if(o++>=a)break;this.cache.delete(c)}}return this.cache.set(r,i),i}mapAll(e,t={}){return e.map((r)=>this.map(r,{...t,type:r}))}addRule(e){this.rules.push(e),this.rules.sort((t,r)=>(r.priority||0)-(t.priority||0)),this.recompile(),this.cache.clear()}removeRules(e){let t=this.rules.length;return this.rules=this.rules.filter((r)=>{let n=typeof r.pattern==="string"?r.pattern:r.pattern.source;if(e instanceof RegExp)e.lastIndex=0;return typeof e==="string"?n!==e:!e.test(n)}),this.recompile(),this.cache.clear(),t-this.rules.length}clearCache(){this.cache.clear()}getRules(){return this.rules}}function Mi(e={rules:[]}){return new Sl(e)}function bl(e,t,r={}){return e.replace(/:\s*([^;,)\]}]+)/g,(n,i)=>{return`: ${t.map(i.trim(),r)}`})}var vd,Sd,bd,Ad,Td,vl=2048,Ry,Oy;var Al=oe(()=>{vd=[{pattern:/^Promise<void>$/,replacement:"Promise<void>",priority:-1},{pattern:/^Record<string,\s*any>$/,replacement:"Record<string, unknown>",priority:0},{pattern:/^Array<([^<>]+)>$/,replacement:"$1[]",priority:0}],Sd=[{pattern:/\bany\b/,replacement:"unknown",global:!0,priority:10},{pattern:/^object$/,replacement:"Record<string, unknown>",priority:10},{pattern:/^Function$/,replacement:"(...args: unknown[]) => unknown",priority:10}],bd=[{pattern:/^(\w+)\[\]$/,replacement:"readonly $1[]",priority:5},{pattern:/^Array<(.+)>$/,replacement:"ReadonlyArray<$1>",priority:5},{pattern:/^Map<(.+),\s*(.+)>$/,replacement:"ReadonlyMap<$1, $2>",priority:5},{pattern:/^Set<(.+)>$/,replacement:"ReadonlySet<$1>",priority:5}],Ad=[{pattern:/^Partial<Partial<(.+)>>$/,replacement:"Partial<$1>",priority:5},{pattern:/^Required<Required<(.+)>>$/,replacement:"Required<$1>",priority:5},{pattern:/^Pick<Omit<(.+),\s*(.+)>,\s*(.+)>$/,replacement:"Pick<$1, $3>",priority:5}];Td=/[.*+?^${}()|[\]\\]/g;Ry=Mi({rules:[]}),Oy=Mi({rules:[],presets:["strict"]})});function Et(e,t=!0){if(!t||!e||e.length===0)return"";if(e.length===1){let n=e[0];if(n.length>0&&n.charCodeAt(0)>32&&n.charCodeAt(n.length-1)>32)return`${n}
179
+ `)}function vd(e,t){let{groups:r=gd,separateGroups:n=!0,alphabetize:i=!0}=t,s=e.split(`
180
+ `),a=[],o=[],c=-1;for(let $=0;$<s.length;$++){let v=s[$],C=El(v);if(C)a.push({line:v,source:C.source,group:C.group,isType:C.isType}),c=$;else if(a.length>0&&v.trim()==="")continue;else if(a.length>0||v.trim()!==""){if(a.length===0||$>c+1)o.push(v)}}if(a.length===0)return e;let f=new Map;for(let $ of r)f.set($,[]);for(let $ of a)(f.get($.group)||f.get("external")||[]).push($);if(i)for(let[,$]of f)$.sort((v,C)=>{if(v.isType!==C.isType)return v.isType?1:-1;return v.source.localeCompare(C.source)});let u=[],l=null;for(let $ of r){let v=f.get($)||[];if(v.length===0)continue;if(n&&l!==null)u.push("");for(let C of v)u.push(C.line);l=$}let g=s.slice(0,s.findIndex(($)=>El($)!==null)),d=o;while(d.length>0&&d[0].trim()==="")d.shift();return[...g,...u,"",...d].join(`
181
+ `)}function El(e){let t=e.trim(),r=t.match(/^import\s+(type\s+)?.*from\s+['"]([^'"]+)['"]/);if(!r){let s=t.match(/^import\s+['"]([^'"]+)['"]/);if(s)return{source:s[1],group:vl(s[1]),isType:!1};return null}let n=!!r[1],i=r[2];return{source:i,group:n?"type":vl(i),isType:n}}function vl(e){if(e.startsWith("node:"))return"builtin";let t=["assert","buffer","child_process","cluster","crypto","dgram","dns","events","fs","http","https","net","os","path","querystring","readline","stream","url","util","zlib"];if(t.includes(e)||t.includes(e.split("/")[0]))return"builtin";if(e==="."||e==="./index"||e==="./index.js"||e==="./index.ts")return"index";if(e.startsWith("./"))return"sibling";if(e.startsWith("../"))return"parent";if(e.startsWith("@/")||e.startsWith("~/")||e.startsWith("#"))return"internal";if(e.startsWith("@"))return"scoped";return"external"}function Sd(e,t){let{kinds:r=pd,alphabetize:n=!1,groupExports:i=!0}=t,s=e.split(`
182
+ `),a=[],o=[],c=[],f=null,u=0,l=!0,g=!1,d=[];for(let C=0;C<s.length;C++){let x=s[C],P=x.trim(),R=u,I=P.startsWith("///"),B=R===0&&!I&&(P.startsWith("//")||P.startsWith("/*"));if(g||B){if(d.push(x),!g&&P.startsWith("/*")&&!P.includes("*/"))g=!0;else if(g&&P.includes("*/"))g=!1;continue}if(R===0&&d.length>0&&P===""){d.push(x);continue}u+=(x.match(/\{/g)||[]).length,u-=(x.match(/\}/g)||[]).length;let W=bd(P);if(l&&W&&W.kind!=="import"&&!P.startsWith("//")&&!P.startsWith("/*"))l=!1;if(l){if(d.length>0){if(W?.kind==="import"||!W)o.push(...d),d.length=0}o.push(x);continue}if(W&&u<=1){if(f)a.push(f);f={lines:d.length>0?[...d,x]:[x],kind:W.kind,name:W.name,isExport:W.isExport},d.length=0}else if(f)f.lines.push(x);else{if(P==="")continue;c.push(x)}}if(f)a.push(f);if(d.length>0)c.push(...d);a.sort((C,x)=>{if(i&&C.isExport!==x.isExport)return C.isExport?-1:1;let P=r.indexOf(C.kind),R=r.indexOf(x.kind),I=P>=0?P:r.length,B=R>=0?R:r.length;if(I!==B)return I-B;if(n)return C.name.localeCompare(x.name);return 0});let $=[...o],v=null;for(let C of a){if(v!==null&&C.kind!==v)$.push("");$.push(...C.lines),v=C.kind}if(c.length>0)$.push(""),$.push(...c);return $.join(`
183
+ `)}function bd(e){let t=e.startsWith("export "),r=t?e.slice(7):e;if(e.startsWith("import "))return{kind:"import",name:e.match(/from\s+['"]([^'"]+)['"]/)?.[1]||"",isExport:!1};if(r.startsWith("type ")||r.startsWith("declare type "))return{kind:"type",name:r.match(/type\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("interface ")||r.startsWith("declare interface "))return{kind:"interface",name:r.match(/interface\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("class ")||r.startsWith("abstract class ")||r.startsWith("declare class ")||r.startsWith("declare abstract class "))return{kind:"class",name:r.match(/class\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("enum ")||r.startsWith("const enum ")||r.startsWith("declare enum ")||r.startsWith("declare const enum "))return{kind:"enum",name:r.match(/enum\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("function ")||r.startsWith("async function ")||r.startsWith("declare function ")||r.startsWith("declare async function "))return{kind:"function",name:r.match(/function\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("const ")||r.startsWith("let ")||r.startsWith("var ")||r.startsWith("declare const ")||r.startsWith("declare let ")||r.startsWith("declare var "))return{kind:"variable",name:r.match(/(?:const|let|var)\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("namespace ")||r.startsWith("declare namespace "))return{kind:"namespace",name:r.match(/namespace\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("module ")||r.startsWith("declare module "))return{kind:"module",name:r.match(/module\s+['"]?(\w+)['"]?/)?.[1]||"",isExport:t};if(e.startsWith("export {")||e.startsWith("export *")||e.startsWith("export type {"))return{kind:"export",name:"",isExport:!0};return null}var pd,gd;var bl=le(()=>{pd=["import","type","interface","enum","class","function","variable","export","module","namespace","unknown"],gd=["builtin","external","scoped","internal","parent","sibling","index","type"]});function Od(e){switch(e){case"strict":return xd;case"readonly":return Td;case"simplified":return Rd;case"nullable":return[{pattern:/^(.+)\s*\|\s*undefined$/,replacement:"$1 | undefined",priority:5}];case"branded":return[{pattern:/^string$/,replacement:"string",condition:(t)=>t.declarationKind==="variable"&&(t.declarationName?.includes("path")??!1),priority:5}];default:return[]}}class xl{rules;compiled=[];cache=new Map;constructor(e={rules:[]}){if(this.rules=[],e.includeDefaults!==!1)this.rules.push(...Ad);if(e.presets)for(let t of e.presets)this.rules.push(...Od(t));this.rules.push(...e.rules),this.rules.sort((t,r)=>(r.priority||0)-(t.priority||0)),this.recompile()}recompile(){let e=Array(this.rules.length);for(let t=0;t<this.rules.length;t++){let r=this.rules[t],n=typeof r.pattern==="string"?new RegExp(r.pattern.replace(Pd,"\\$&"),r.global?"g":""):r.pattern;e[t]={rule:r,regex:n}}this.compiled=e}map(e,t={}){let r=!t.declarationName&&!t.declarationKind&&!t.filePath&&!t.isReturnType&&!t.isParameterType&&!t.isPropertyType?e:`${e}\x00${t.declarationName??""}\x00${t.declarationKind??""}\x00${t.filePath??""}\x00${t.isReturnType?"r":""}${t.isParameterType?"p":""}${t.isPropertyType?"P":""}`,n=this.cache.get(r);if(n!==void 0)return n;let i=e,s=null;for(let a=0;a<this.compiled.length;a++){let{rule:o,regex:c}=this.compiled[a];if(o.condition){if(!s)s={type:e,...t};if(!o.condition(s))continue}if(c.lastIndex=0,c.test(i)){if(c.lastIndex=0,i=i.replace(c,o.replacement),c.lastIndex=0,!o.global)break}}if(this.cache.size>=Al){let a=Math.ceil(Al*0.1),o=0;for(let c of this.cache.keys()){if(o++>=a)break;this.cache.delete(c)}}return this.cache.set(r,i),i}mapAll(e,t={}){return e.map((r)=>this.map(r,{...t,type:r}))}addRule(e){this.rules.push(e),this.rules.sort((t,r)=>(r.priority||0)-(t.priority||0)),this.recompile(),this.cache.clear()}removeRules(e){let t=this.rules.length;return this.rules=this.rules.filter((r)=>{let n=typeof r.pattern==="string"?r.pattern:r.pattern.source;if(e instanceof RegExp)e.lastIndex=0;return typeof e==="string"?n!==e:!e.test(n)}),this.recompile(),this.cache.clear(),t-this.rules.length}clearCache(){this.cache.clear()}getRules(){return this.rules}}function Di(e={rules:[]}){return new xl(e)}function Tl(e,t,r={}){return e.replace(/:\s*([^;,)\]}]+)/g,(n,i)=>{return`: ${t.map(i.trim(),r)}`})}var Ad,xd,Td,Rd,Pd,Al=2048,ky,My;var Rl=le(()=>{Ad=[{pattern:/^Promise<void>$/,replacement:"Promise<void>",priority:-1},{pattern:/^Record<string,\s*any>$/,replacement:"Record<string, unknown>",priority:0},{pattern:/^Array<([^<>]+)>$/,replacement:"$1[]",priority:0}],xd=[{pattern:/\bany\b/,replacement:"unknown",global:!0,priority:10},{pattern:/^object$/,replacement:"Record<string, unknown>",priority:10},{pattern:/^Function$/,replacement:"(...args: unknown[]) => unknown",priority:10}],Td=[{pattern:/^(\w+)\[\]$/,replacement:"readonly $1[]",priority:5},{pattern:/^Array<(.+)>$/,replacement:"ReadonlyArray<$1>",priority:5},{pattern:/^Map<(.+),\s*(.+)>$/,replacement:"ReadonlyMap<$1, $2>",priority:5},{pattern:/^Set<(.+)>$/,replacement:"ReadonlySet<$1>",priority:5}],Rd=[{pattern:/^Partial<Partial<(.+)>>$/,replacement:"Partial<$1>",priority:5},{pattern:/^Required<Required<(.+)>>$/,replacement:"Required<$1>",priority:5},{pattern:/^Pick<Omit<(.+),\s*(.+)>,\s*(.+)>$/,replacement:"Pick<$1, $3>",priority:5}];Pd=/[.*+?^${}()|[\]\\]/g;ky=Di({rules:[]}),My=Di({rules:[],presets:["strict"]})});function Et(e,t=!0){if(!t||!e||e.length===0)return"";if(e.length===1){let n=e[0];if(n.length>0&&n.charCodeAt(0)>32&&n.charCodeAt(n.length-1)>32)return`${n}
182
184
  `;return`${n.trim()}
183
185
  `}let r="";for(let n=0;n<e.length;n++){if(n>0)r+=`
184
186
  `;r+=e[n].trim()}return`${r}
185
- `}var xl=()=>{};function kd(e){let t=[],r=0;for(let n=0;n<=e.length;n++)if(n===e.length||e[n]===`
186
- `){let i=r,s=n;while(i<s&&(e[i]===" "||e[i]==="\t"||e[i]==="\r"))i++;while(s>i&&(e[s-1]===" "||e[s-1]==="\t"||e[s-1]==="\r"))s--;let a=e.slice(i,s);if(r=n+1,a.startsWith("///")){if(a.indexOf("<")===-1)continue;if(Rd.test(a)||Od.test(a)||Pd.test(a))t.push(a)}else if(a===""||a.startsWith("//"))continue;else break}return t}function Md(e){if(e.includes(`
187
+ `}var Ol=()=>{};function Dd(e){let t=[],r=0;for(let n=0;n<=e.length;n++)if(n===e.length||e[n]===`
188
+ `){let i=r,s=n;while(i<s&&(e[i]===" "||e[i]==="\t"||e[i]==="\r"))i++;while(s>i&&(e[s-1]===" "||e[s-1]==="\t"||e[s-1]==="\r"))s--;let a=e.slice(i,s);if(r=n+1,a.startsWith("///")){if(a.indexOf("<")===-1)continue;if(kd.test(a)||Md.test(a)||Id.test(a))t.push(a)}else if(a===""||a.startsWith("//"))continue;else break}return t}function Fd(e){if(e.includes(`
187
189
  `))return`/**
188
190
  * ${e}
189
191
  */
190
192
  `;return`/** ${e} */
191
- `}function Id(e){let t=e.indexOf("{");if(t===-1)return-1;let r=e.indexOf("<");if(r===-1||r>t)return t;let n=0,i=!1,s="";for(let a=0;a<e.length;a++){let o=e[a],c=a>0?e[a-1]:"";if(!i&&(o==='"'||o==="'"||o==="`"))i=!0,s=o;else if(i&&o===s&&c!=="\\")i=!1;if(!i){if(o==="<")n++;else if(o===">")n--;else if(o==="{"&&n===0)return a}}return-1}function Dd(e,t=!0){return Et(e.leadingComments,t)+e.text}function Tl(e,t=!0){let r=Et(e.leadingComments,t);if(e.typeAnnotation&&!e.value)return r+e.text;let n="";if(e.isExported)n+="export ";n+="declare ";let i=e.modifiers?.[0]||"const";n+=`${i} `,n+=e.name;let{typeAnnotation:s,value:a}=e;if(a&&a.includes(" satisfies ")){let c=jo(a);if(c)s=c}else if(!s&&a&&a.trim().endsWith("as const"))s=Ae(a,!0);else if(!s&&a&&i==="const"){let c=a.trim(),f=c.startsWith("{")||c.startsWith("[");if(f)Jn();s=Ae(a,!f)}else if(!s&&a)s=Ae(a,i==="const");if(!s)s="unknown";let o="";if(t&&a&&!e.typeAnnotation&&!a.trim().endsWith("as const")){let c=a.trim();if(i!=="const"){if((s==="string"||s==="number"||s==="boolean")&&c.length>0)o=`@defaultValue ${c}`}else if(c.startsWith("{")||c.startsWith("[")){let f=Un();if(f)if(f.includes(`
193
+ `}function Nd(e){let t=e.indexOf("{");if(t===-1)return-1;let r=e.indexOf("<");if(r===-1||r>t)return t;let n=0,i=!1,s="";for(let a=0;a<e.length;a++){let o=e[a],c=a>0?e[a-1]:"";if(!i&&(o==='"'||o==="'"||o==="`"))i=!0,s=o;else if(i&&o===s&&c!=="\\")i=!1;if(!i){if(o==="<")n++;else if(o===">")n--;else if(o==="{"&&n===0)return a}}return-1}function Wd(e,t=!0){return Et(e.leadingComments,t)+e.text}function Pl(e,t=!0){let r=Et(e.leadingComments,t);if(e.typeAnnotation&&!e.value)return r+e.text;let n="";if(e.isExported)n+="export ";n+="declare ";let i=e.modifiers?.[0]||"const";n+=`${i} `,n+=e.name;let{typeAnnotation:s,value:a}=e;if(a&&a.includes(" satisfies ")){let c=Uo(a);if(c)s=c}else if(!s&&a&&a.trim().endsWith("as const"))s=xe(a,!0);else if(!s&&a&&i==="const"){let c=a.trim(),f=c.startsWith("{")||c.startsWith("[");if(f)Yn();s=xe(a,!f)}else if(!s&&a)s=xe(a,i==="const");if(!s)s="unknown";let o="";if(t&&a&&!e.typeAnnotation&&!a.trim().endsWith("as const")){let c=a.trim();if(i!=="const"){if((s==="string"||s==="number"||s==="boolean")&&c.length>0)o=`@defaultValue ${c}`}else if(c.startsWith("{")||c.startsWith("[")){let f=Zn();if(f)if(f.includes(`
192
194
  `))o=`@defaultValue
193
195
  * \`\`\`ts
194
196
  ${f.split(`
195
197
  `).map((u)=>` * ${u}`).join(`
196
198
  `)}
197
- * \`\`\``;else o=`@defaultValue \`${f}\``}}else if(t&&a&&e.typeAnnotation&&Ho(e.typeAnnotation)){Jn();let c=a.trim(),f=c.endsWith("as const")?c.slice(0,-8).trim():c;Ae(f,!1);let u=Un();if(u)if(u.includes(`
199
+ * \`\`\``;else o=`@defaultValue \`${f}\``}}else if(t&&a&&e.typeAnnotation&&Jo(e.typeAnnotation)){Yn();let c=a.trim(),f=c.endsWith("as const")?c.slice(0,-8).trim():c;xe(f,!1);let u=Zn();if(u)if(u.includes(`
198
200
  `))o=`@defaultValue
199
201
  * \`\`\`ts
200
202
  ${u.split(`
@@ -209,22 +211,22 @@ ${u.split(`
209
211
  * ${c.replace(/^\/\/\s*/,"")}
210
212
  * ${o}
211
213
  */
212
- ${n}`}if(o)return`${Md(o)}${n}`;return r+n}function Fd(e,t=!0){let r=Et(e.leadingComments,t),n=e.text;if(n.startsWith("export declare interface")||n.startsWith("declare interface"))return r+n;let i="";if(e.isExported)i+="export ";if(i+="declare interface ",i+=e.name,e.generics)i+=e.generics;if(e.extends)i+=` extends ${e.extends}`;let s=Id(e.text);if(s!==-1)i+=` ${e.text.slice(s)}`;else i+=" {}";return r+i}function Nd(e,t=!0){let r=Et(e.leadingComments,t);if(e.text.includes("{")&&e.text.includes("}")&&e.text.includes("from"))return r+e.text;let n="";if(e.isExported)n+="export ";if(!e.isExported&&!e.text.includes(" from "))n+="declare ";let i=e.text.indexOf("type ");if(i!==-1){let a=e.text.slice(i),o=a.length;while(o>0&&(a.charCodeAt(o-1)===59||a.charCodeAt(o-1)===32||a.charCodeAt(o-1)===10||a.charCodeAt(o-1)===13))o--;if(o<a.length)a=a.slice(0,o);n+=a}else{if(n+=`type ${e.name}`,e.generics)n+=e.generics;n+=" = any"}let s=n.trimEnd();if(!s.endsWith(";")&&!s.endsWith("}"))n+=";";return r+n}function Ld(e,t=!0){return Et(e.leadingComments,t)+e.text}function Wd(e,t=!0){let r=Et(e.leadingComments,t),n="";if(e.isExported)n+="export ";if(n+="declare ",e.modifiers?.includes("const"))n+="const ";n+="enum ",n+=e.name;let i=e.text.indexOf("{");if(i!==-1)n+=` ${e.text.slice(i)}`;else n+=" {}";return r+n}function Gd(e,t=!0){let r=Et(e.leadingComments,t);if(e.text.startsWith("declare global"))return r+e.text;if(e.source||(e.name.startsWith('"')||e.name.startsWith("'")||e.name.startsWith("`"))){let s="declare module ";s+=e.name;let a=e.text.indexOf("{");if(a!==-1)s+=` ${e.text.slice(a)}`;else s+=" {}";return r+s}let n="";if(e.isExported)n+="export ";if(!e.modifiers?.includes("declare"))n+="declare ";n+="namespace ",n+=e.name;let i=e.text.indexOf("{");if(i!==-1)n+=` ${e.text.slice(i)}`;else n+=" {}";return r+n}function Bd(e){let t=Ft.get(e);if(t)return Ft.delete(e),Ft.set(e,t),t;return null}function Rl(e,t){if(Ft.set(e,t),Ft.size>200){let r=0;for(let n of Ft.keys()){if(r++>=20)break;Ft.delete(n)}}}function Vd(e){let t=e.indexOf(" from ");if(t===-1)return null;let r=e.slice(t+6).trim(),n=r[0];if(n!=='"'&&n!=="'")return null;let i=r.indexOf(n,1);if(i===-1)return null;let s=r.slice(1,i),a=e.slice(0,t).trim(),o=a.startsWith("import type ");if(a.startsWith("import "))a=a.slice(7).trim();if(a.startsWith("type "))a=a.slice(5).trim();let c=null,f=[],u=!1,l=a.indexOf("{"),g=a.lastIndexOf("}");if(l!==-1&&g!==-1){let d=a.slice(0,l).trim();if(d.endsWith(","))c=d.slice(0,-1).trim()||null;let w=a.slice(l+1,g),E=0;for(let C=0;C<=w.length;C++)if(C===w.length||w.charCodeAt(C)===44){let A=E,O=C;while(A<O&&(w.charCodeAt(A)===32||w.charCodeAt(A)===9||w.charCodeAt(A)===10))A++;while(O>A&&(w.charCodeAt(O-1)===32||w.charCodeAt(O-1)===9||w.charCodeAt(O-1)===10))O--;if(A<O)f.push(w.slice(A,O));E=C+1}}else{let d=a.trim();if(d.startsWith("* as "))c=d.slice(5).trim()||null,u=!0;else c=d||null}return{defaultName:c,namedItems:f,source:s,isTypeOnly:o,isNamespace:u}}function _d(e){let t=Bd(e);if(t)return t;let r=[],n=e.indexOf(" from ");if(n===-1)return Rl(e,r),r;let i=e.slice(0,n).trim();if(i.startsWith("import "))i=i.slice(7).trim();if(i.startsWith("type "))i=i.slice(5).trim();let s=i.indexOf("{"),a=i.lastIndexOf("}");if(s!==-1&&a!==-1){let o=i.slice(0,s).trim();if(o.endsWith(",")){let f=o.slice(0,-1).trim();if(f)r.push(f)}else if(o&&!o.includes(","))r.push(o);let c=i.slice(s+1,a).split(",");for(let f=0;f<c.length;f++){let u=c[f].trim();if(!u)continue;if(u.startsWith("type "))u=u.slice(5).trim();let l=u.indexOf(" as ");if(l!==-1)u=u.slice(l+4).trim();if(u)r.push(u)}}else{let o=i.trim();if(o.startsWith("* as ")){let c=o.slice(5).trim();if(c)r.push(c)}else if(o)r.push(o)}return Rl(e,r),r}function Ol(e,t){throw Error(t||`Unexpected value: ${e}`)}function Hd(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===36||e>127}function Pl(e){let t=new Set,r=0,n=e.length;while(r<n){let i=e.charCodeAt(r);if(i>=65&&i<=90||i>=97&&i<=122||i===95||i===36||i>127){let s=r;r++;while(r<n&&Hd(e.charCodeAt(r)))r++;t.add(e.substring(s,r))}else r++}return t}function Dl(e,t,r=!0,n=["bun"]){let i="",s=t.sourceCode;if(s){let D=0;while(D<s.length&&(s.charCodeAt(D)===32||s.charCodeAt(D)===9||s.charCodeAt(D)===10||s.charCodeAt(D)===13))D++;if(D<s.length-2&&s.charCodeAt(D)===47&&s.charCodeAt(D+1)===47&&s.charCodeAt(D+2)===47){let H=kd(s);if(H.length>0)for(let U=0;U<H.length;U++){if(i)i+=`
213
- `;i+=H[U]}}}let a=[],o=[],c=[],f=[],u=[],l=[],g=[],d=[],w=[];for(let D of e){let H=D.kind;switch(H){case"import":a.push(D);break;case"function":o.push(D);break;case"variable":c.push(D);break;case"interface":f.push(D);break;case"type":u.push(D);break;case"class":l.push(D);break;case"enum":g.push(D);break;case"module":d.push(D);break;case"export":w.push(D);break;case"namespace":d.push(D);break;case"unknown":break;default:Ol(H,`Unhandled declaration kind: ${H}`)}}let E=new Set,C=[],A=[],O=[],R=new Set;for(let D of w){let H=Et(D.leadingComments,r);if(D.text.startsWith("export default")){let U=D.text.endsWith(";")?D.text:`${D.text};`;O.push(H+U)}else{let U=D.text.trim();if(!U.endsWith(";"))U+=";";let Q=U.match(jd);if(Q){let q=Q[1],me=0;for(let z=0;z<=q.length;z++)if(z===q.length||q.charCodeAt(z)===44){let X=me,ee=z;while(X<ee&&q.charCodeAt(X)<=32)X++;while(ee>X&&q.charCodeAt(ee-1)<=32)ee--;if(X<ee)E.add(q.slice(X,ee));me=z+1}}let K=H+U;if(!R.has(K))if(R.add(K),K.includes("export type"))C.push(K);else A.push(K)}}let I=new Map;if(a.length>0)for(let D of a){let H=_d(D.text);for(let U of H)I.set(U,D)}let B=new Set;if(f.length>0){let D=[];for(let H of o)if(H.isExported)D.push(H.text);for(let H of l)D.push(H.text);for(let H of u)D.push(H.text);if(D.length>0){let H=Pl(D.join(`
214
- `));for(let U of f)if(H.has(U.name))B.add(U.name)}}let L=[];if(a.length>0){let D=new Set,H=[];for(let K of o)if(K.isExported)H.push(K.text);for(let K of c)if(H.push(K.text),K.typeAnnotation)H.push(K.typeAnnotation);else if(K.isExported&&K.value)H.push(Tl(K,!1));for(let K of f)if(K.isExported||B.has(K.name))H.push(K.text);for(let K of u)H.push(K.text);for(let K of l)H.push(K.text);for(let K of g)H.push(K.text);for(let K of d)H.push(K.text);for(let K of w)H.push(K.text);let U=H.join(`
215
- `);if(U&&I.size>0){let K=Pl(U);for(let q of I.keys())if(K.has(q))D.add(q)}for(let K of E)if(I.has(K))D.add(K);for(let K of a){if(K.isSideEffect){let Be=K.text.trim(),ot=Be.endsWith(";")?Be:`${Be};`;L.push(ot);continue}let q=Vd(K.text);if(!q)continue;let{defaultName:me,namedItems:z,source:X,isTypeOnly:ee,isNamespace:vt}=q,De=me?D.has(me):!1,se="",Pt=0;for(let Be=0;Be<z.length;Be++){let ot=z[Be],ut=ot.charCodeAt(0)===116&&ot.startsWith("type ")?ot.slice(5).trim():ot.trim(),Ve=ut.indexOf(" as ");if(Ve!==-1)ut=ut.slice(Ve+4).trim();if(D.has(ut)){if(Pt>0)se+=", ";se+=ot,Pt++}}if(De||Pt>0){let Be=ee?"import type ":"import ";if(De&&me)if(vt)Be+=`* as ${me}`;else Be+=Pt>0?`${me}, { ${se} }`:me;else if(Pt>0)Be+=`{ ${se} }`;Be+=` from '${X}';`,L.push(Be)}}let Q=n.length;if(L.length>1){if(kl!==n)kl=n,Ml=n.map((z)=>`from '${z}`),Il=n.map((z)=>`from "${z}`);let K=Ml,q=Il,me=new Map;for(let z of L){let X=Q;for(let ee=0;ee<n.length;ee++)if(z.includes(K[ee])||z.includes(q[ee])){X=ee;break}me.set(z,X)}L.sort((z,X)=>{let ee=me.get(z),vt=me.get(X);return ee!==vt?ee-vt:z.localeCompare(X)})}}for(let D=0;D<L.length;D++){if(i)i+=`
216
- `;i+=L[D]}for(let D=0;D<C.length;D++){if(i)i+=`
217
- `;i+=C[D]}let T=[o,c,f,u,l,g,d];for(let D=0;D<T.length;D++){let H=T[D];for(let U=0;U<H.length;U++){let Q=H[U],K="",q=Q.kind;switch(q){case"function":K=Dd(Q,r);break;case"variable":K=Tl(Q,r);break;case"interface":K=Fd(Q,r);break;case"type":K=Nd(Q,r);break;case"class":K=Ld(Q,r);break;case"enum":K=Wd(Q,r);break;case"module":case"namespace":K=Gd(Q,r);break;case"import":case"export":case"unknown":break;default:Ol(q,`Unhandled declaration kind in processor: ${q}`)}if(K){if(i)i+=`
218
- `;i+=K}}}for(let D=0;D<A.length;D++){if(i)i+=`
219
- `;i+=A[D]}for(let D=0;D<O.length;D++){if(i)i+=`
220
- `;i+=O[D]}if(!i&&(a.length>0||w.length>0))return"export {};";return i}var Rd,Od,Pd,Ft,jd,kl=null,Ml,Il;var Fl=oe(()=>{xl();Zn();Rd=/^\/\/\/\s*<reference\s+(?:path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/,Od=/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/,Pd=/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/;Ft=new Map;jd=/export\s+(?:type\s+)?\{\s*([^}]+)\s*\}/,Ml=[],Il=[]});import{existsSync as Kd,statSync as Jd}from"fs";import{dirname as Ud,extname as Yd,isAbsolute as ls,resolve as Zd}from"path";function Ii(e){try{return Jd(e).isFile()}catch{return!1}}function Di(e,t){let r=e.replace(/[?#].*$/,"");if(!(r.startsWith("./")||r.startsWith("../")||r==="."||r==="..")&&!ls(r))return{resolved:null,isRelative:!1};let n=Ud(t),i=ls(r)?r:Zd(n,r);if(Ii(i))return{resolved:i,isRelative:!0};let s=Yd(i),a=qd[s];if(a){let o=i.slice(0,-s.length);for(let c of a){let f=o+c;if(Ii(f))return{resolved:f,isRelative:!0}}}for(let o of Nl){let c=i+o;if(Ii(c))return{resolved:c,isRelative:!0}}if(Kd(i))for(let o of Nl){let c=`${i}/index${o}`;if(Ii(c))return{resolved:c,isRelative:!0}}return{resolved:null,isRelative:!0}}function Xd(e){let t=e.length,r="",n=0;while(n<t){let i=e.charCodeAt(n);if(i===34||i===39||i===96){let s=i;r+=e[n++];while(n<t){let a=e.charCodeAt(n),o=e[n++];if(r+=s===96&&a!==s?a===10||a===13?o:" ":o,a===92&&n<t){let c=e[n++];r+=s===96?c===`
221
- `||c==="\r"?c:" ":c;continue}if(a===s)break}continue}if(i===47&&n+1<t){let s=e.charCodeAt(n+1);if(s===47){n+=2;while(n<t&&e.charCodeAt(n)!==10)n++;continue}if(s===42){n+=2;while(n+1<t&&!(e.charCodeAt(n)===42&&e.charCodeAt(n+1)===47))n++;n+=2;continue}}r+=e[n++]}return r}function cs(e,t={}){let r=[],n=Xd(e);Ll.lastIndex=0;let i;while((i=Ll.exec(n))!==null){let s=!!i[1],a=i[3],o=i[0],c;if(o.includes("* as "))c="export-star-as";else if(o.includes("*"))c="export-star";else c="export-named";r.push({specifier:a,kind:c,isTypeOnly:s})}if(t.includeImports){Wl.lastIndex=0;while((i=Wl.exec(n))!==null)r.push({specifier:i[3],kind:"import",isTypeOnly:!!i[1]})}return r}async function fs(e,t={}){let r=new Set,n=new Map,i=[],s=[];for(let a of e)if(!r.has(a))r.add(a),s.push(a);while(s.length>0){let a=s.shift(),o;try{o=await wt(a)}catch{continue}let c=cs(o,t);n.set(a,c);for(let f of c){if(!(f.specifier.startsWith(".")||ls(f.specifier)))continue;let u=Di(f.specifier,a);if(u.resolved){if(!r.has(u.resolved))r.add(u.resolved),s.push(u.resolved)}else i.push({from:a,specifier:f.specifier,isTypeOnly:f.isTypeOnly})}}return{reachable:r,reExports:n,unresolved:i}}var Nl,qd,Ll,Wl;var Gl=oe(()=>{yi();Nl=[".ts",".tsx",".mts",".cts",".vue",".stx",".js",".jsx",".mjs",".cjs",".d.ts",".d.mts",".d.cts"],qd={".js":[".ts",".tsx",".d.ts"],".jsx":[".tsx",".ts",".d.ts"],".mjs":[".mts",".d.mts"],".cjs":[".cts",".d.cts"]};Ll=/(?:^|[\n;{}])\s*export\s+(type\s+)?(?:\*(?:\s+as\s+\w+)?|\{[^}]*\})\s+from\s+(['"])([^'"]+)\2/g,Wl=/(?:^|[\n;{}])\s*import\s+(type\s+)?(?:[^'";\n]+\s+from\s+)?(['"])([^'"]+)\2/g});import{mkdir as us,readdir as zd,realpath as Qd,rm as em}from"fs/promises";import{availableParallelism as tm}from"os";import{basename as Hl,dirname as xr,extname as rm,isAbsolute as ms,parse as im,relative as Ie,resolve as it}from"path";async function Bl(e,t,r,n,i){let s=Hl(e)||"output.d.ts",a=Ie(xr(e),t),o=`${s}.map`,c=r.lastIndexOf(`
222
- ${Vn()}`),f=c===-1?r:r.slice(0,c),u=Ao(f,s,a,n),l=`${e}.map`;return await pr(l,JSON.stringify(u)),j.debug(` Generated source map: ${Ie(i,l)}`),o}async function Ni(e){let t=Date.now(),r={...lo,...e};if(r.logLevel)Xi(r.logLevel);else if(r.verbose)Xi("debug");let n=new Or;if(r.plugins&&r.plugins.length>0){for(let C of r.plugins)n.register(C),j.debug(`Registered plugin: ${C.name}`);r=await n.runOnStart(r)}if(await sm(r),r.isolatedDeclarations===void 0)r.isolatedDeclarations=await vo(r);let i=r.typeMappings?Mi(r.typeMappings):void 0,s=null;if(r.incremental){if(s=new qi(r),r.clearCache){if(j.debug("Clearing build cache..."),!r.dryRun)s.clear()}else if(s.load()){let C=s.getStats();j.debug(`Loaded build cache with ${C.entries} entries`)}else j.debug("No existing build cache found, starting fresh");if(!r.dryRun)Ds(r.cwd)}let a={generationMode:r.isolatedDeclarations?"isolated":"semantic",filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},o=0;if(j.debug("Starting DTS generation..."),j.debug(`Using ${a.generationMode} declaration generation path`),j.debug("Config:",r),r.clean&&!r.dryRun)await om(r);let c=await lm(r),f=c.slice(),u=null;if(r.autoIncludeReExports!==!1&&f.length>0){u=await fs(f,{includeImports:!0});let C=it(r.cwd,r.root),A=r.exclude||[],O=[];for(let R of u.reachable){if(f.includes(R))continue;if(!ds(R))continue;if(R.endsWith(".d.ts"))continue;if(R.includes("node_modules"))continue;if(!Fi(R,C)){j.warn(`Skipping auto-included source outside root: ${Ie(r.cwd,R)}`);continue}if(hs(R,A,C))continue;O.push(R)}if(O.length>0)f=[...f,...O],j.debug(`Auto-included ${O.length} file(s) reached via relative re-exports`)}if(cm(f,r),s&&!r.dryRun){let C=s.prune(new Set(f),r.cwd);if(C>0)j.debug(`Pruned ${C} deleted files from cache`)}if(j.debug(`Found ${f.length} TypeScript files`),r.progress&&f.length>0){let C=r.parallel?"parallel":"sequential";j.info(`Processing ${f.length} files (${C})...`)}let l=async(C,A)=>{let O;try{let R=Tr(C,r),I=async(q)=>{if(!r.diff)return;try{let me=await wt(R),z=bo(me,q,Ie(r.cwd,R));if(z)j.info(`
223
- ${z}`);else j.debug(`[no changes] ${R}`)}catch{j.info(`[new file] ${Ie(r.cwd,R)}`)}},B=(q)=>{if(!r.validate)return 0;let me=So(q,R);if(me.isValid)return j.debug(`[validation] ${R} - OK`),0;j.warn(`[validation] ${Ie(r.cwd,R)} has ${me.errors.length} error(s):`);for(let z of me.errors){let X=` Line ${z.line}:${z.column}`;if(z.code)X+=` [${z.code}]`;if(X+=` - ${z.message}`,j.warn(X),z.suggestion)j.warn(` Suggestion: ${z.suggestion}`)}return me.errors.length},L=(q)=>{j.info(`[dry-run] Would generate: ${R}`),j.debug("--- Content preview ---"),j.debug(q.slice(0,500)+(q.length>500?`
224
- ...`:"")),j.debug("--- End preview ---")};if(s){let q=s.getCachedIfValid(C,r.cwd);if(q){await I(q);let me=B(q);if(r.dryRun)L(q);else{if(await us(xr(R),{recursive:!0}),r.declarationMap)O=A??await wt(C),await Bl(R,C,q,O,r.cwd);await pr(R,q,r.lineEnding)}return j.debug(`[cached] ${Ie(r.cwd,R)}`),{success:!0,file:C,declarationCount:0,importCount:0,exportCount:0,cached:!0,validationErrorCount:me}}}O=A??await wt(C);let{content:T,declarationCount:D,importCount:H,exportCount:U}=await hm(C,O,r,n,i),Q=T;if(r.prettier||r.indentStyle||r.indentSize){let q=await dl(Q,{usePrettier:r.prettier,builtIn:{indentSize:r.indentSize||2,useTabs:r.indentStyle==="tabs",normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}},R);Q=q.content;for(let me of q.warnings??[])j.warn(`[format] ${me}`)}if(r.declarationMap){let q=`${Hl(R)||"output.d.ts"}.map`;Q=xo(Q,q)}await I(Q);let K=B(Q);if(r.dryRun)L(Q);else{if(await us(xr(R),{recursive:!0}),r.declarationMap&&O)await Bl(R,C,Q,O,r.cwd);if(await pr(R,Q,r.lineEnding),s&&O)s.update(C,O,Q,r.cwd);j.debug(`Generated: ${R}`)}return{success:!0,file:C,declarationCount:D,importCount:H,exportCount:U,validationErrorCount:K}}catch(R){let I=pl(R,C,O);if(r.plugins&&r.plugins.length>0)await n.runOnError(R instanceof Error?R:Error(String(R)),C,O||"");return{success:!1,file:C,declarationCount:0,importCount:0,exportCount:0,dtsError:I,validationErrorCount:0}}},g=r.parallel||r.parallel!==!1&&f.length>=10,d=Ro(r.concurrency,tm?.()??8),w=new Map;if(g&&f.length>1){let C=f.map(async(A)=>{try{let O=await wt(A);return{file:A,source:O}}catch{return{file:A,source:null}}});for(let A of await Promise.all(C))if(A.source!==null)w.set(A.file,A.source)}let E=(C)=>{if(a.filesProcessed++,C.success){if(C.cached)o++;else a.filesGenerated++,a.declarationsFound+=C.declarationCount,a.importsProcessed+=C.importCount,a.exportsProcessed+=C.exportCount;if(r.validate){if(a.filesValidated++,C.validationErrorCount)a.validationErrors+=C.validationErrorCount}}else if(a.filesFailed++,C.dtsError){a.errors.push(C.dtsError);let A=gl(C.dtsError);if(r.continueOnError)j.warn(A);else throw j.error(A),Error(C.dtsError.message)}};if(g)for(let C=0;C<f.length;C+=d){let A=f.slice(C,C+d),O=await Promise.all(A.map((R)=>l(R,w.get(R))));for(let R of O)E(R);if(r.progress){let R=Math.round(a.filesProcessed/f.length*100);j.info(`[${a.filesProcessed}/${f.length}] ${R}%`)}}else for(let C of f){let A=await l(C);if(E(A),r.progress){let O=Math.round(a.filesProcessed/f.length*100),R=A.cached?"[cached]":"";j.info(`[${a.filesProcessed}/${f.length}] ${O}% - ${Ie(r.cwd,C)} ${R}`)}}if(s&&!r.dryRun)s.save(),j.debug("Saved build cache");if(!r.bundle){let C=[];if(u)for(let A of u.unresolved)C.push({from:A.from,specifier:A.specifier,reason:"missing"});if(r.autoIncludeReExports===!1&&f.length>0){let A=new Set(f);for(let O of f){let R;try{R=await wt(O)}catch{continue}for(let I of cs(R)){if(!I.specifier.startsWith("."))continue;let B=Di(I.specifier,O);if(!B.resolved)C.push({from:O,specifier:I.specifier,reason:"missing"});else if(!/\.d\.(?:ts|mts|cts)$/.test(B.resolved)&&!A.has(B.resolved))C.push({from:O,specifier:I.specifier,reason:"not-emitted"})}}}if(C.length>0){let A=[];A.push(`Found ${C.length} re-export(s) pointing at siblings that won't be in the output:`);for(let R of C){let I=Ie(r.cwd,R.from);if(R.reason==="missing")A.push(` ${I} \u2192 '${R.specifier}' (path not found on disk)`);else A.push(` ${I} \u2192 '${R.specifier}' (resolved but not in entrypoints; set autoIncludeReExports: true or add to entrypoints)`)}let O=A.join(`
225
- `);if(r.failOnUnresolvedReExport)throw Error(O);j.warn(O),j.warn('Generated .d.ts files reference modules that were not emitted \u2014 consumers will see "has no exported member" errors.')}}if(r.bundle&&(a.filesGenerated>0||o>0)&&c.length>0)try{j.debug("Bundling declarations...");let C=new Map,A=async(R)=>{let I=C.get(R);if(I!==void 0)return I;return I=await wt(R),C.set(R,I),I};for(let R of f)await A(R);let O=c.length===1&&!!r.bundleOutput;for(let R of c){let I=await fs([R],{includeImports:!0}),B=new Set;for(let U of I.reachable){if(U.endsWith(".d.ts"))continue;if(U.includes("node_modules"))continue;B.add(U)}let L=f.filter((U)=>B.has(U));if(!L.includes(R))L.push(R);let T=new Map;for(let U of L){let Q=C.get(U)??await A(U);T.set(U,Q)}let D=await fl(L,T,r),H=O?it(r.cwd,r.outdir,r.bundleOutput):Tr(R,r);if(r.dryRun)j.info(`[dry-run] Would bundle ${D.files.length} files to: ${Ie(r.cwd,H)}`);else await us(xr(H),{recursive:!0}),await pr(H,D.content,r.lineEnding),j.info(`Bundled ${D.files.length} files to: ${Ie(r.cwd,H)}`);if(O)break}}catch(C){let A=C instanceof Error?C.message:String(C);j.error(`Bundle failed: ${A}`)}if(a.durationMs=Date.now()-t,r.stats)if(r.outputFormat==="json")console.log(JSON.stringify(a,null,2));else{if(j.info(`
214
+ ${n}`}if(o)return`${Fd(o)}${n}`;return r+n}function Ld(e,t=!0){let r=Et(e.leadingComments,t),n=e.text;if(n.startsWith("export declare interface")||n.startsWith("declare interface"))return r+n;let i="";if(e.isExported)i+="export ";if(i+="declare interface ",i+=e.name,e.generics)i+=e.generics;if(e.extends)i+=` extends ${e.extends}`;let s=Nd(e.text);if(s!==-1)i+=` ${e.text.slice(s)}`;else i+=" {}";return r+i}function Gd(e,t=!0){let r=Et(e.leadingComments,t);if(e.text.includes("{")&&e.text.includes("}")&&e.text.includes("from"))return r+e.text;let n="";if(e.isExported)n+="export ";if(!e.isExported&&!e.text.includes(" from "))n+="declare ";let i=e.text.indexOf("type ");if(i!==-1){let a=e.text.slice(i),o=a.length;while(o>0&&(a.charCodeAt(o-1)===59||a.charCodeAt(o-1)===32||a.charCodeAt(o-1)===10||a.charCodeAt(o-1)===13))o--;if(o<a.length)a=a.slice(0,o);n+=a}else{if(n+=`type ${e.name}`,e.generics)n+=e.generics;n+=" = any"}let s=n.trimEnd();if(!s.endsWith(";")&&!s.endsWith("}"))n+=";";return r+n}function Bd(e,t=!0){return Et(e.leadingComments,t)+e.text}function Vd(e,t=!0){let r=Et(e.leadingComments,t),n="";if(e.isExported)n+="export ";if(n+="declare ",e.modifiers?.includes("const"))n+="const ";n+="enum ",n+=e.name;let i=e.text.indexOf("{");if(i!==-1)n+=` ${e.text.slice(i)}`;else n+=" {}";return r+n}function _d(e,t=!0){let r=Et(e.leadingComments,t);if(e.text.startsWith("declare global"))return r+e.text;if(e.source||(e.name.startsWith('"')||e.name.startsWith("'")||e.name.startsWith("`"))){let s="declare module ";s+=e.name;let a=e.text.indexOf("{");if(a!==-1)s+=` ${e.text.slice(a)}`;else s+=" {}";return r+s}let n="";if(e.isExported)n+="export ";if(!e.modifiers?.includes("declare"))n+="declare ";n+="namespace ",n+=e.name;let i=e.text.indexOf("{");if(i!==-1)n+=` ${e.text.slice(i)}`;else n+=" {}";return r+n}function Hd(e){let t=Mt.get(e);if(t)return Mt.delete(e),Mt.set(e,t),t;return null}function kl(e,t){if(Mt.set(e,t),Mt.size>200){let r=0;for(let n of Mt.keys()){if(r++>=20)break;Mt.delete(n)}}}function jd(e){let t=e.indexOf(" from ");if(t===-1)return null;let r=e.slice(t+6).trim(),n=r[0];if(n!=='"'&&n!=="'")return null;let i=r.indexOf(n,1);if(i===-1)return null;let s=r.slice(1,i),a=e.slice(0,t).trim(),o=a.startsWith("import type ");if(a.startsWith("import "))a=a.slice(7).trim();if(a.startsWith("type "))a=a.slice(5).trim();let c=null,f=[],u=!1,l=a.indexOf("{"),g=a.lastIndexOf("}");if(l!==-1&&g!==-1){let d=a.slice(0,l).trim();if(d.endsWith(","))c=d.slice(0,-1).trim()||null;let $=a.slice(l+1,g),v=0;for(let C=0;C<=$.length;C++)if(C===$.length||$.charCodeAt(C)===44){let x=v,P=C;while(x<P&&($.charCodeAt(x)===32||$.charCodeAt(x)===9||$.charCodeAt(x)===10))x++;while(P>x&&($.charCodeAt(P-1)===32||$.charCodeAt(P-1)===9||$.charCodeAt(P-1)===10))P--;if(x<P)f.push($.slice(x,P));v=C+1}}else{let d=a.trim();if(d.startsWith("* as "))c=d.slice(5).trim()||null,u=!0;else c=d||null}return{defaultName:c,namedItems:f,source:s,isTypeOnly:o,isNamespace:u}}function Kd(e){let t=Hd(e);if(t)return t;let r=[],n=e.indexOf(" from ");if(n===-1)return kl(e,r),r;let i=e.slice(0,n).trim();if(i.startsWith("import "))i=i.slice(7).trim();if(i.startsWith("type "))i=i.slice(5).trim();let s=i.indexOf("{"),a=i.lastIndexOf("}");if(s!==-1&&a!==-1){let o=i.slice(0,s).trim();if(o.endsWith(",")){let f=o.slice(0,-1).trim();if(f)r.push(f)}else if(o&&!o.includes(","))r.push(o);let c=i.slice(s+1,a).split(",");for(let f=0;f<c.length;f++){let u=c[f].trim();if(!u)continue;if(u.startsWith("type "))u=u.slice(5).trim();let l=u.indexOf(" as ");if(l!==-1)u=u.slice(l+4).trim();if(u)r.push(u)}}else{let o=i.trim();if(o.startsWith("* as ")){let c=o.slice(5).trim();if(c)r.push(c)}else if(o)r.push(o)}return kl(e,r),r}function Ml(e,t){throw Error(t||`Unexpected value: ${e}`)}function Jd(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===36||e>127}function Il(e){let t=new Set,r=0,n=e.length;while(r<n){let i=e.charCodeAt(r);if(i>=65&&i<=90||i>=97&&i<=122||i===95||i===36||i>127){let s=r;r++;while(r<n&&Jd(e.charCodeAt(r)))r++;t.add(e.substring(s,r))}else r++}return t}function Wl(e,t,r=!0,n=["bun"]){let i="",s=t.sourceCode;if(s){let D=0;while(D<s.length&&(s.charCodeAt(D)===32||s.charCodeAt(D)===9||s.charCodeAt(D)===10||s.charCodeAt(D)===13))D++;if(D<s.length-2&&s.charCodeAt(D)===47&&s.charCodeAt(D+1)===47&&s.charCodeAt(D+2)===47){let H=Dd(s);if(H.length>0)for(let Y=0;Y<H.length;Y++){if(i)i+=`
215
+ `;i+=H[Y]}}}let a=[],o=[],c=[],f=[],u=[],l=[],g=[],d=[],$=[];for(let D of e){let H=D.kind;switch(H){case"import":a.push(D);break;case"function":o.push(D);break;case"variable":c.push(D);break;case"interface":f.push(D);break;case"type":u.push(D);break;case"class":l.push(D);break;case"enum":g.push(D);break;case"module":d.push(D);break;case"export":$.push(D);break;case"namespace":d.push(D);break;case"unknown":break;default:Ml(H,`Unhandled declaration kind: ${H}`)}}let v=new Set,C=[],x=[],P=[],R=new Set;for(let D of $){let H=Et(D.leadingComments,r);if(D.text.startsWith("export default")){let Y=D.text.endsWith(";")?D.text:`${D.text};`;P.push(H+Y)}else{let Y=D.text.trim();if(!Y.endsWith(";"))Y+=";";let se=Y.match(Ud);if(se){let q=se[1],te=0;for(let X=0;X<=q.length;X++)if(X===q.length||q.charCodeAt(X)===44){let Re=te,Oe=X;while(Re<Oe&&q.charCodeAt(Re)<=32)Re++;while(Oe>Re&&q.charCodeAt(Oe-1)<=32)Oe--;if(Re<Oe)v.add(q.slice(Re,Oe));te=X+1}}let K=H+Y;if(!R.has(K))if(R.add(K),K.includes("export type"))C.push(K);else x.push(K)}}let I=new Map;if(a.length>0)for(let D of a){let H=Kd(D.text);for(let Y of H)I.set(Y,D)}let B=new Set;if(f.length>0){let D=[];for(let H of o)if(H.isExported)D.push(H.text);for(let H of l)D.push(H.text);for(let H of u)D.push(H.text);if(D.length>0){let H=Il(D.join(`
216
+ `));for(let Y of f)if(H.has(Y.name))B.add(Y.name)}}let W=[];if(a.length>0){let D=new Set,H=[];for(let K of o)if(K.isExported)H.push(K.text);for(let K of c)if(H.push(K.text),K.typeAnnotation)H.push(K.typeAnnotation);else if(K.isExported&&K.value)H.push(Pl(K,!1));for(let K of f)if(K.isExported||B.has(K.name))H.push(K.text);for(let K of u)H.push(K.text);for(let K of l)H.push(K.text);for(let K of g)H.push(K.text);for(let K of d)H.push(K.text);for(let K of $)H.push(K.text);let Y=H.join(`
217
+ `);if(Y&&I.size>0){let K=Il(Y);for(let q of I.keys())if(K.has(q))D.add(q)}for(let K of v)if(I.has(K))D.add(K);for(let K of a){if(K.isSideEffect){let ae=K.text.trim(),z=ae.endsWith(";")?ae:`${ae};`;W.push(z);continue}let q=jd(K.text);if(!q)continue;let{defaultName:te,namedItems:X,source:Re,isTypeOnly:Oe,isNamespace:It}=q,Pe=te?D.has(te):!1,ke="",ut=0;for(let ae=0;ae<X.length;ae++){let z=X[ae],Dt=z.charCodeAt(0)===116&&z.startsWith("type ")?z.slice(5).trim():z.trim(),or=Dt.indexOf(" as ");if(or!==-1)Dt=Dt.slice(or+4).trim();if(D.has(Dt)){if(ut>0)ke+=", ";ke+=z,ut++}}if(Pe||ut>0){let ae=Oe?"import type ":"import ";if(Pe&&te)if(It)ae+=`* as ${te}`;else ae+=ut>0?`${te}, { ${ke} }`:te;else if(ut>0)ae+=`{ ${ke} }`;ae+=` from '${Re}';`,W.push(ae)}}let se=n.length;if(W.length>1){if(Dl!==n)Dl=n,Fl=n.map((X)=>`from '${X}`),Nl=n.map((X)=>`from "${X}`);let K=Fl,q=Nl,te=new Map;for(let X of W){let Re=se;for(let Oe=0;Oe<n.length;Oe++)if(X.includes(K[Oe])||X.includes(q[Oe])){Re=Oe;break}te.set(X,Re)}W.sort((X,Re)=>{let Oe=te.get(X),It=te.get(Re);return Oe!==It?Oe-It:X.localeCompare(Re)})}}for(let D=0;D<W.length;D++){if(i)i+=`
218
+ `;i+=W[D]}for(let D=0;D<C.length;D++){if(i)i+=`
219
+ `;i+=C[D]}let T=[o,c,f,u,l,g,d];for(let D=0;D<T.length;D++){let H=T[D];for(let Y=0;Y<H.length;Y++){let se=H[Y],K="",q=se.kind;switch(q){case"function":K=Wd(se,r);break;case"variable":K=Pl(se,r);break;case"interface":K=Ld(se,r);break;case"type":K=Gd(se,r);break;case"class":K=Bd(se,r);break;case"enum":K=Vd(se,r);break;case"module":case"namespace":K=_d(se,r);break;case"import":case"export":case"unknown":break;default:Ml(q,`Unhandled declaration kind in processor: ${q}`)}if(K){if(i)i+=`
220
+ `;i+=K}}}for(let D=0;D<x.length;D++){if(i)i+=`
221
+ `;i+=x[D]}for(let D=0;D<P.length;D++){if(i)i+=`
222
+ `;i+=P[D]}if(!i&&(a.length>0||$.length>0))return"export {};";return i}var kd,Md,Id,Mt,Ud,Dl=null,Fl,Nl;var Ll=le(()=>{Ol();Xn();kd=/^\/\/\/\s*<reference\s+(?:path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/,Md=/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/,Id=/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/;Mt=new Map;Ud=/export\s+(?:type\s+)?\{\s*([^}]+)\s*\}/,Fl=[],Nl=[]});import{existsSync as Yd,statSync as Zd}from"fs";import{dirname as qd,extname as Xd,isAbsolute as fs,resolve as zd}from"path";function Fi(e){try{return Zd(e).isFile()}catch{return!1}}function Ni(e,t){let r=e.replace(/[?#].*$/,"");if(!(r.startsWith("./")||r.startsWith("../")||r==="."||r==="..")&&!fs(r))return{resolved:null,isRelative:!1};let n=qd(t),i=fs(r)?r:zd(n,r);if(Fi(i))return{resolved:i,isRelative:!0};let s=Xd(i),a=Qd[s];if(a){let o=i.slice(0,-s.length);for(let c of a){let f=o+c;if(Fi(f))return{resolved:f,isRelative:!0}}}for(let o of Gl){let c=i+o;if(Fi(c))return{resolved:c,isRelative:!0}}if(Yd(i))for(let o of Gl){let c=`${i}/index${o}`;if(Fi(c))return{resolved:c,isRelative:!0}}return{resolved:null,isRelative:!0}}function em(e){let t=e.length,r="",n=0;while(n<t){let i=e.charCodeAt(n);if(i===34||i===39||i===96){let s=i;r+=e[n++];while(n<t){let a=e.charCodeAt(n),o=e[n++];if(r+=s===96&&a!==s?a===10||a===13?o:" ":o,a===92&&n<t){let c=e[n++];r+=s===96?c===`
223
+ `||c==="\r"?c:" ":c;continue}if(a===s)break}continue}if(i===47&&n+1<t){let s=e.charCodeAt(n+1);if(s===47){n+=2;while(n<t&&e.charCodeAt(n)!==10)n++;continue}if(s===42){n+=2;while(n+1<t&&!(e.charCodeAt(n)===42&&e.charCodeAt(n+1)===47))n++;n+=2;continue}}r+=e[n++]}return r}function us(e,t={}){let r=[],n=em(e);Bl.lastIndex=0;let i;while((i=Bl.exec(n))!==null){let s=!!i[1],a=i[3],o=i[0],c;if(o.includes("* as "))c="export-star-as";else if(o.includes("*"))c="export-star";else c="export-named";r.push({specifier:a,kind:c,isTypeOnly:s})}if(t.includeImports){Vl.lastIndex=0;while((i=Vl.exec(n))!==null)r.push({specifier:i[3],kind:"import",isTypeOnly:!!i[1]})}return r}async function hs(e,t={}){let r=new Set,n=new Map,i=[],s=[];for(let a of e)if(!r.has(a))r.add(a),s.push(a);while(s.length>0){let a=s.shift(),o;try{o=await wt(a)}catch{continue}let c=us(o,t);n.set(a,c);for(let f of c){if(!(f.specifier.startsWith(".")||fs(f.specifier)))continue;let u=Ni(f.specifier,a);if(u.resolved){if(!r.has(u.resolved))r.add(u.resolved),s.push(u.resolved)}else i.push({from:a,specifier:f.specifier,isTypeOnly:f.isTypeOnly})}}return{reachable:r,reExports:n,unresolved:i}}var Gl,Qd,Bl,Vl;var _l=le(()=>{wi();Gl=[".ts",".tsx",".mts",".cts",".vue",".stx",".js",".jsx",".mjs",".cjs",".d.ts",".d.mts",".d.cts"],Qd={".js":[".ts",".tsx",".d.ts"],".jsx":[".tsx",".ts",".d.ts"],".mjs":[".mts",".d.mts"],".cjs":[".cts",".d.cts"]};Bl=/(?:^|[\n;{}])\s*export\s+(type\s+)?(?:\*(?:\s+as\s+\w+)?|\{[^}]*\})\s+from\s+(['"])([^'"]+)\2/g,Vl=/(?:^|[\n;{}])\s*import\s+(type\s+)?(?:[^'";\n]+\s+from\s+)?(['"])([^'"]+)\2/g});import{mkdir as ds,readdir as tm,realpath as rm,rm as im}from"fs/promises";import{availableParallelism as nm}from"os";import{basename as Jl,dirname as Tr,extname as sm,isAbsolute as gs,parse as am,relative as Ne,resolve as nt}from"path";async function Hl(e,t,r,n,i){let s=Jl(e)||"output.d.ts",a=Ne(Tr(e),t),o=`${s}.map`,c=r.lastIndexOf(`
224
+ ${Hn()}`),f=c===-1?r:r.slice(0,c),u=Ro(f,s,a,n),l=`${e}.map`;return await gr(l,JSON.stringify(u)),j.debug(` Generated source map: ${Ne(i,l)}`),o}async function Li(e){let t=Date.now(),r={...uo,...e};if(r.logLevel)Qi(r.logLevel);else if(r.verbose)Qi("debug");let n=new kr;if(r.plugins&&r.plugins.length>0){for(let C of r.plugins)n.register(C),j.debug(`Registered plugin: ${C.name}`);r=await n.runOnStart(r)}if(await lm(r),r.isolatedDeclarations===void 0)r.isolatedDeclarations=await Ao(r);let i=r.typeMappings?Di(r.typeMappings):void 0,s=null;if(r.incremental){if(s=new zi(r),r.clearCache){if(j.debug("Clearing build cache..."),!r.dryRun)s.clear()}else if(s.load()){let C=s.getStats();j.debug(`Loaded build cache with ${C.entries} entries`)}else j.debug("No existing build cache found, starting fresh");if(!r.dryRun)Ws(r.cwd)}let a={generationMode:r.isolatedDeclarations?"isolated":"semantic",filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},o=0;if(j.debug("Starting DTS generation..."),j.debug(`Using ${a.generationMode} declaration generation path`),j.debug("Config:",r),r.clean&&!r.dryRun)await fm(r);let c=await um(r),f=c.slice(),u=null;if(r.autoIncludeReExports!==!1&&f.length>0){u=await hs(f,{includeImports:!0});let C=nt(r.cwd,r.root),x=r.exclude||[],P=[];for(let R of u.reachable){if(f.includes(R))continue;if(!ps(R))continue;if(R.endsWith(".d.ts"))continue;if(R.includes("node_modules"))continue;if(!Wi(R,C)){j.warn(`Skipping auto-included source outside root: ${Ne(r.cwd,R)}`);continue}if(ms(R,x,C))continue;P.push(R)}if(P.length>0)f=[...f,...P],j.debug(`Auto-included ${P.length} file(s) reached via relative re-exports`)}if(hm(f,r),s&&!r.dryRun){let C=s.prune(new Set(f),r.cwd);if(C>0)j.debug(`Pruned ${C} deleted files from cache`)}if(j.debug(`Found ${f.length} TypeScript files`),r.progress&&f.length>0){let C=r.parallel?"parallel":"sequential";j.info(`Processing ${f.length} files (${C})...`)}let l=async(C,x)=>{let P;try{let R=Rr(C,r),I=async(q)=>{if(!r.diff)return;try{let te=await wt(R),X=To(te,q,Ne(r.cwd,R));if(X)j.info(`
225
+ ${X}`);else j.debug(`[no changes] ${R}`)}catch{j.info(`[new file] ${Ne(r.cwd,R)}`)}},B=(q)=>{if(!r.validate)return 0;let te=xo(q,R);if(te.isValid)return j.debug(`[validation] ${R} - OK`),0;j.warn(`[validation] ${Ne(r.cwd,R)} has ${te.errors.length} error(s):`);for(let X of te.errors){let Re=` Line ${X.line}:${X.column}`;if(X.code)Re+=` [${X.code}]`;if(Re+=` - ${X.message}`,j.warn(Re),X.suggestion)j.warn(` Suggestion: ${X.suggestion}`)}return te.errors.length},W=(q)=>{j.info(`[dry-run] Would generate: ${R}`),j.debug("--- Content preview ---"),j.debug(q.slice(0,500)+(q.length>500?`
226
+ ...`:"")),j.debug("--- End preview ---")};if(s){let q=s.getCachedIfValid(C,r.cwd);if(q){await I(q);let te=B(q);if(r.dryRun)W(q);else{if(await ds(Tr(R),{recursive:!0}),r.declarationMap)P=x??await wt(C),await Hl(R,C,q,P,r.cwd);await gr(R,q,r.lineEnding)}return j.debug(`[cached] ${Ne(r.cwd,R)}`),{success:!0,file:C,declarationCount:0,importCount:0,exportCount:0,cached:!0,validationErrorCount:te}}}P=x??await wt(C);let{content:T,declarationCount:D,importCount:H,exportCount:Y}=await pm(C,P,r,n,i),se=T;if(r.prettier||r.indentStyle||r.indentSize){let q=await gl(se,{usePrettier:r.prettier,builtIn:{indentSize:r.indentSize||2,useTabs:r.indentStyle==="tabs",normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}},R);se=q.content;for(let te of q.warnings??[])j.warn(`[format] ${te}`)}if(r.declarationMap){let q=`${Jl(R)||"output.d.ts"}.map`;se=Oo(se,q)}await I(se);let K=B(se);if(r.dryRun)W(se);else{if(await ds(Tr(R),{recursive:!0}),r.declarationMap&&P)await Hl(R,C,se,P,r.cwd);if(await gr(R,se,r.lineEnding),s&&P)s.update(C,P,se,r.cwd);j.debug(`Generated: ${R}`)}return{success:!0,file:C,declarationCount:D,importCount:H,exportCount:Y,validationErrorCount:K}}catch(R){let I=Cl(R,C,P);if(r.plugins&&r.plugins.length>0)await n.runOnError(R instanceof Error?R:Error(String(R)),C,P||"");return{success:!1,file:C,declarationCount:0,importCount:0,exportCount:0,dtsError:I,validationErrorCount:0}}},g=r.parallel||r.parallel!==!1&&f.length>=10,d=ko(r.concurrency,nm?.()??8),$=new Map;if(g&&f.length>1){let C=f.map(async(x)=>{try{let P=await wt(x);return{file:x,source:P}}catch{return{file:x,source:null}}});for(let x of await Promise.all(C))if(x.source!==null)$.set(x.file,x.source)}let v=(C)=>{if(a.filesProcessed++,C.success){if(C.cached)o++;else a.filesGenerated++,a.declarationsFound+=C.declarationCount,a.importsProcessed+=C.importCount,a.exportsProcessed+=C.exportCount;if(r.validate){if(a.filesValidated++,C.validationErrorCount)a.validationErrors+=C.validationErrorCount}}else if(a.filesFailed++,C.dtsError){a.errors.push(C.dtsError);let x=wl(C.dtsError);if(r.continueOnError)j.warn(x);else throw j.error(x),Error(C.dtsError.message)}};if(g)for(let C=0;C<f.length;C+=d){let x=f.slice(C,C+d),P=await Promise.all(x.map((R)=>l(R,$.get(R))));for(let R of P)v(R);if(r.progress){let R=Math.round(a.filesProcessed/f.length*100);j.info(`[${a.filesProcessed}/${f.length}] ${R}%`)}}else for(let C of f){let x=await l(C);if(v(x),r.progress){let P=Math.round(a.filesProcessed/f.length*100),R=x.cached?"[cached]":"";j.info(`[${a.filesProcessed}/${f.length}] ${P}% - ${Ne(r.cwd,C)} ${R}`)}}if(s&&!r.dryRun)s.save(),j.debug("Saved build cache");if(!r.bundle){let C=[];if(u)for(let x of u.unresolved)C.push({from:x.from,specifier:x.specifier,reason:"missing"});if(r.autoIncludeReExports===!1&&f.length>0){let x=new Set(f);for(let P of f){let R;try{R=await wt(P)}catch{continue}for(let I of us(R)){if(!I.specifier.startsWith("."))continue;let B=Ni(I.specifier,P);if(!B.resolved)C.push({from:P,specifier:I.specifier,reason:"missing"});else if(!/\.d\.(?:ts|mts|cts)$/.test(B.resolved)&&!x.has(B.resolved))C.push({from:P,specifier:I.specifier,reason:"not-emitted"})}}}if(C.length>0){let x=[];x.push(`Found ${C.length} re-export(s) pointing at siblings that won't be in the output:`);for(let R of C){let I=Ne(r.cwd,R.from);if(R.reason==="missing")x.push(` ${I} \u2192 '${R.specifier}' (path not found on disk)`);else x.push(` ${I} \u2192 '${R.specifier}' (resolved but not in entrypoints; set autoIncludeReExports: true or add to entrypoints)`)}let P=x.join(`
227
+ `);if(r.failOnUnresolvedReExport)throw Error(P);j.warn(P),j.warn('Generated .d.ts files reference modules that were not emitted \u2014 consumers will see "has no exported member" errors.')}}if(r.bundle&&(a.filesGenerated>0||o>0)&&c.length>0)try{j.debug("Bundling declarations...");let C=new Map,x=async(R)=>{let I=C.get(R);if(I!==void 0)return I;return I=await wt(R),C.set(R,I),I};for(let R of f)await x(R);let P=c.length===1&&!!r.bundleOutput;for(let R of c){let I=await hs([R],{includeImports:!0}),B=new Set;for(let Y of I.reachable){if(Y.endsWith(".d.ts"))continue;if(Y.includes("node_modules"))continue;B.add(Y)}let W=f.filter((Y)=>B.has(Y));if(!W.includes(R))W.push(R);let T=new Map;for(let Y of W){let se=C.get(Y)??await x(Y);T.set(Y,se)}let D=await dl(W,T,r),H=P?nt(r.cwd,r.outdir,r.bundleOutput):Rr(R,r);if(r.dryRun)j.info(`[dry-run] Would bundle ${D.files.length} files to: ${Ne(r.cwd,H)}`);else await ds(Tr(H),{recursive:!0}),await gr(H,D.content,r.lineEnding),j.info(`Bundled ${D.files.length} files to: ${Ne(r.cwd,H)}`);if(P)break}}catch(C){let x=C instanceof Error?C.message:String(C);j.error(`Bundle failed: ${x}`)}if(a.durationMs=Date.now()-t,r.stats)if(r.outputFormat==="json")console.log(JSON.stringify(a,null,2));else{if(j.info(`
226
228
  --- Generation Statistics ---`),j.info(`Files processed: ${a.filesProcessed}`),j.info(`Files generated: ${a.filesGenerated}`),o>0)j.info(`Files cached: ${o}`);if(a.filesFailed>0)j.info(`Files failed: ${a.filesFailed}`);if(j.info(`Declarations found: ${a.declarationsFound}`),j.info(`Imports processed: ${a.importsProcessed}`),j.info(`Exports processed: ${a.exportsProcessed}`),a.filesValidated>0){if(j.info(`Files validated: ${a.filesValidated}`),a.validationErrors>0)j.info(`Validation errors: ${a.validationErrors}`)}if(j.info(`Duration: ${a.durationMs}ms`),a.errors.length>0){j.info(`
227
- Errors:`);for(let C of a.errors){let A=` - ${C.file}`;if(C.location)A+=`:${C.location.line}:${C.location.column}`;if(C.code)A+=` [${C.code}]`;if(A+=`: ${C.message}`,j.info(A),C.suggestion)j.info(` Suggestion: ${C.suggestion}`)}}j.info(`-----------------------------
228
- `)}if(r.plugins&&r.plugins.length>0)await n.runOnEnd(a);return j.debug("DTS generation complete!"),a}async function Vl(e){try{return await Qd(e)}catch{return it(e)}}async function sm(e){let t=it(e.cwd,e.outdir);if(e.bundle&&e.bundleOutput){if(ms(e.bundleOutput))throw Error("bundleOutput must be relative to outdir");let i=it(t,e.bundleOutput);if(!Fi(i,t))throw Error("bundleOutput must stay within outdir")}if(!e.clean||e.dryRun)return;if(t===im(t).root)throw Error("Refusing to clean declarations from the filesystem root");let[r,n]=await Promise.all([Vl(t),Vl(it(e.cwd,e.root))]);if(Fi(n,r))throw Error("Refusing to clean an outdir that contains the source root")}function am(e){let t=Ar.get(e);if(!t){if(t=new _l(e),Ar.set(e,t),Ar.size>nm){let r=Ar.keys().next().value;if(r!==void 0)Ar.delete(r)}}return t}async function om(e){let t=it(e.cwd,e.outdir);async function r(n){let i;try{i=await zd(n,{withFileTypes:!0})}catch{return}await Promise.all(i.map(async(s)=>{let a=it(n,s.name);if(s.isDirectory()){await r(a);return}if(s.name.endsWith(".d.ts")||s.name.endsWith(".d.mts")||s.name.endsWith(".d.cts")||s.name.endsWith(".d.ts.map")||s.name.endsWith(".d.mts.map")||s.name.endsWith(".d.cts.map"))await em(a,{force:!0})}))}await r(t)}function hs(e,t,r){if(!t||t.length===0)return!1;let n=Ie(r,e);for(let i of t){let s=am(i);if(s.match(n)||s.match(e))return!0}return!1}async function lm(e){let t=[],r=it(e.cwd,e.root),n=e.exclude||[],i=[...e.entrypoints,...e.include??[]];for(let s of i)if(ms(s)&&ds(s)){if(!s.includes("node_modules")){if(!Fi(s,r)&&e.outputStructure!=="flat")j.warn(`Skipping entrypoint outside root: ${Ie(e.cwd,s)}`);else if(!hs(s,n,r))t.push(s)}}else{let a=new _l(s);for await(let o of a.scan({cwd:r,absolute:!0,onlyFiles:!0}))if(ds(o)&&!o.includes("node_modules")){if(!hs(o,n,r))t.push(o)}}return[...new Set(t)].sort()}function Fi(e,t){let r=Ie(t,e);return r!==".."&&!r.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!ms(r)}function cm(e,t){let r=new Map;for(let n of e){let i=Tr(n,t),s=r.get(i);if(s&&s!==n)throw Error(`Output path collision: ${Ie(t.cwd,s)} and ${Ie(t.cwd,n)} both emit ${Ie(t.cwd,i)}`);r.set(i,n)}}function ds(e){return/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/.test(e)&&!/\.d\.(?:ts|mts|cts)$/.test(e)}function Tr(e,t){let r=it(t.cwd,t.root),n=Ie(r,e).replace(/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/,(i)=>{if(i===".mts"||i===".mjs")return".d.mts";if(i===".cts"||i===".cjs")return".d.cts";return".d.ts"});if(t.outputStructure==="mirror")return it(t.cwd,t.outdir,n);else{let i=n.split("/").pop();return it(t.cwd,t.outdir,i)}}function fm(e,t,r=""){let n=Ie(xr(e),t).replace(/\\/g,"/");if(n=n.replace(/\.d\.mts$/,"").replace(/\.d\.cts$/,"").replace(/\.d\.ts$/,""),r)n+=r;if(!n.startsWith("."))n=`./${n}`;return n}function um(e,t,r){let n=Tr(t,r),i=(s)=>{let a=Di(s,t);if(!a.isRelative||!a.resolved)return s;if(/\.d\.(?:ts|mts|cts)$/.test(a.resolved))return s;let o=s.match(/[?#].*$/)?.[0]??"",c=o?s.slice(0,-o.length):s,f=rm(c),u=/^(?:\.js|\.jsx|\.mjs|\.cjs)$/.test(f)?f:"";return fm(n,Tr(a.resolved,r),u)+o};return e.replace(/\b(from\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(s,a,o,c)=>{return`${a}${o}${i(c)}${o}`}).replace(/\b(import\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(s,a,o,c)=>{return`${a}${o}${i(c)}${o}`}).replace(/\b(import\s*\(\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(s,a,o,c)=>{return`${a}${o}${i(c)}${o}`})}async function hm(e,t,r,n,i){let s=t;if(n)s=await n.runOnBeforeFile(e,t);let a=Pi(s,e,r.keepComments,r.isolatedDeclarations??!1);if(n)a=await n.runOnDeclarations(e,s,a);let o=0,c=0;for(let u=0;u<a.length;u++){let l=a[u];if(l.kind==="import")o++;if(l.kind==="export"||l.isExported)c++}let f=Dl(a,{filePath:e,sourceCode:s,declarations:a},r.keepComments,r.importOrder);if(f=um(f,e,r),i)f=bl(f,i,{filePath:e});if(r.normalizeOutput===!0||r.declarationOrder)f=$l(f,{lineEnding:"lf",declarationOrder:r.declarationOrder,indent:{style:r.indentStyle??"spaces",size:r.indentSize??2}});if(n)f=await n.runOnAfterFile(e,s,f);return{content:f,declarationCount:a.length,importCount:o,exportCount:c}}var _l,nm=50,Ar;var jl=oe(()=>{Os();Fs();To();hl();ml();co();yl();El();Al();Gs();os();Oo();Fl();Gl();yi();({Glob:_l}=globalThis.Bun);Ar=new Map});var Kl=oe(()=>{jl()});var zl={};mc(zl,{dtsWatch:()=>Sm,dtsCheck:()=>bm,dts:()=>gs,default:()=>xm,clearCache:()=>Am,PluginErrorCodes:()=>$m,DtsxPluginError:()=>ar});import{createHash as mm}from"crypto";import{existsSync as pm,readFileSync as gm,writeFileSync as ym}from"fs";import{dirname as Cm,join as wm,relative as Jl,resolve as sr,sep as Li}from"path";import Yl from"process";class Zl{listeners=new Map;on(e,t){let r=this.listeners.get(e)||[];r.push(t),this.listeners.set(e,r)}async emit(e,t){let r={type:e,timestamp:Date.now(),data:t},n=this.listeners.get(e)||[];for(let i of n)await i(r)}}class ps{manifest;cacheDir;manifestPath;constructor(e,t){this.cacheDir=e,this.manifestPath=wm(e,"manifest.json"),this.manifest=this.loadManifest(t)}loadManifest(e){try{if(pm(this.manifestPath)){let t=JSON.parse(gm(this.manifestPath,"utf-8"));if(t.configHash===e&&t.version==="1.0")return t}}catch{}return{version:"1.0",configHash:e,entries:{}}}save(){try{let{mkdirSync:e}=dm("fs");e(this.cacheDir,{recursive:!0}),ym(this.manifestPath,JSON.stringify(this.manifest,null,2))}catch{}}getEntry(e){return this.manifest.entries[e]}setEntry(e,t){this.manifest.entries[e]=t}isValid(e,t){return this.getEntry(e)?.hash===t}clear(){this.manifest.entries={},this.save()}}function Em(e){let t={root:e.root,outdir:e.outdir,entrypoints:e.entrypoints,clean:e.clean,tsconfigPath:e.tsconfigPath};return mm("md5").update(JSON.stringify(t)).digest("hex")}function gs(e={}){let{onSuccess:t,onError:r,failOnError:n=!0,incremental:i=!1,cacheDir:s=".dtsx-cache",on:a,timeout:o=60000,continueOnError:c=!1,verbose:f=!1,...u}=e,l=new Zl;if(a){for(let[g,d]of Object.entries(a))if(d)l.on(g,d)}return{name:"bun-plugin-dtsx",async setup(g){let d=Date.now(),w=null,E=0;try{let C=Xl(u,g),A=Em(C);if(C.clean){let B=sr(C.cwd??Yl.cwd(),C.outdir??"./dist");if(Ul.has(B))C.clean=!1;else Ul.add(B)}if(i)w=new ps(sr(s),A);if(await l.emit("start",{type:"start",files:C.entrypoints||[],config:C}),f){if(console.log("[bun-plugin-dtsx] Starting declaration generation..."),i)console.log("[bun-plugin-dtsx] Incremental mode enabled")}let R=await(async()=>{return new Promise((B,L)=>{let T=setTimeout(()=>{L(new ar(`Generation timed out after ${o}ms`,"TIMEOUT_ERROR",{timeout:o}))},o);Ni(C).then((D)=>{clearTimeout(T),B(D)}).catch((D)=>{clearTimeout(T),L(D)})})})(),I=Date.now()-d;if(w)w.save();if(await l.emit("complete",{type:"complete",stats:R,duration:I,fromCache:E}),f){if(console.log(`[bun-plugin-dtsx] Generation complete in ${I}ms`),E>0)console.log(`[bun-plugin-dtsx] ${E} files served from cache`)}if(t)await t(R)}catch(C){let A=ql(C);if(await l.emit("error",{type:"error",error:A}),r)await r(A);else{if(console.error("[bun-plugin-dtsx] Error generating declarations:"),console.error(` Code: ${A.code}`),console.error(` Message: ${A.message}`),A.context)console.error(` Context: ${JSON.stringify(A.context)}`);if(f&&A.stack)console.error(` Stack: ${A.stack}`)}if(n&&!c)throw A}}}}function ql(e){if(e instanceof ar)return e;if(e instanceof Error){let t="GENERATION_ERROR";if(e.message.includes("config")||e.message.includes("Config"))t="CONFIG_ERROR";else if(e.message.includes("file")||e.message.includes("File")||e.message.includes("ENOENT"))t="FILE_ERROR";return new ar(e.message,t,{originalError:e.name},e)}return new ar(String(e),"GENERATION_ERROR")}function vm(e){let t=e.map((n)=>Cm(n).split(Li)),r=t[0];for(let n of t.slice(1)){let i=0;while(i<r.length&&i<n.length&&r[i]===n[i])i++;r=r.slice(0,i)}return r.join(Li)||Li}function Xl(e,t){let r=e.cwd||Yl.cwd(),n=t?.config?.entrypoints,i=e.outdir||e.build?.config.outdir||t?.config.outdir||"./dist",s=e.root||e.build?.config.root||t?.config.root;if(!s&&n?.length){let o=vm(n.map((c)=>sr(r,c)));s=Jl(r,o)||"."}s=s||"./src";let a=e.entrypoints;if(!a)if(n?.length){let o=sr(r,s),c=[];for(let f of n){let u=sr(r,f);if(u===o||u.startsWith(o+Li))c.push(Jl(o,u));else console.warn(`[bun-plugin-dtsx] Skipping entrypoint outside root "${s}": ${f}`)}a=c.length?c:["index.ts"]}else a=["index.ts"];return{...e,cwd:r,root:s,entrypoints:a,outdir:i,clean:e.clean??!0,tsconfigPath:e.tsconfigPath}}function Sm(e={}){return gs({...e,incremental:!0,verbose:e.verbose??!0})}function bm(e){return{name:"bun-plugin-dtsx-check",async setup(t){let r=Xl({...e,outdir:""},t);try{await Ni({...r,clean:!1})}catch(n){let i=ql(n);if(e.onError)await e.onError(i);if(e.failOnError!==!1)throw i}}}}function Am(e=".dtsx-cache"){new ps(sr(e),"").clear()}var dm,$m,ar,Ul,xm;var Ql=oe(()=>{Kl();dm=import.meta.require,$m={CONFIG_ERROR:"CONFIG_ERROR",GENERATION_ERROR:"GENERATION_ERROR",FILE_ERROR:"FILE_ERROR",CACHE_ERROR:"CACHE_ERROR",TIMEOUT_ERROR:"TIMEOUT_ERROR"};ar=class ar extends Error{code;context;cause;constructor(e,t,r,n){super(e);if(this.name="DtsxPluginError",this.code=t,this.context=r,this.cause=n,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}};Ul=new Set;xm=gs});import{mkdir as Tm,stat as Rm}from"fs/promises";import{bold as ys,dim as Cs,green as Om,italic as ec,log as Pm}from"@stacksjs/cli";import{path as nt}from"@stacksjs/path";import{glob as tc}from"@stacksjs/storage";async function km(e){let t=await tc([nt.resolve(e,"dist","**/*.d.ts")],{absolute:!0}),r=new Bun.Transpiler({loader:"ts",target:"bun"});for(let n of t){let i=await Bun.file(n).text();try{r.transformSync(i)}catch(s){throw Error(`Invalid declaration generated at ${n}: ${s instanceof Error?s.message:String(s)}`)}}}async function Mm(e){let t=nt.resolve(e,"dist","index.js");if(!await Bun.file(t).exists())return;let r=Bun.spawnSync({cmd:[process.execPath,"-e",`await import(${JSON.stringify(t)})`],stdout:"ignore",stderr:"pipe",env:{...process.env,NODE_ENV:"test"}});if(r.exitCode===0)return;let n=new TextDecoder().decode(r.stderr??new Uint8Array);if(/needs to refer to a top-level declared variable|does not provide an export named|Export named .* not found/i.test(n))throw Error(`Built package at ${t} cannot be imported: ${n.trim().split(`
229
+ Errors:`);for(let C of a.errors){let x=` - ${C.file}`;if(C.location)x+=`:${C.location.line}:${C.location.column}`;if(C.code)x+=` [${C.code}]`;if(x+=`: ${C.message}`,j.info(x),C.suggestion)j.info(` Suggestion: ${C.suggestion}`)}}j.info(`-----------------------------
230
+ `)}if(r.plugins&&r.plugins.length>0)await n.runOnEnd(a);return j.debug("DTS generation complete!"),a}async function jl(e){try{return await rm(e)}catch{return nt(e)}}async function lm(e){let t=nt(e.cwd,e.outdir);if(e.bundle&&e.bundleOutput){if(gs(e.bundleOutput))throw Error("bundleOutput must be relative to outdir");let i=nt(t,e.bundleOutput);if(!Wi(i,t))throw Error("bundleOutput must stay within outdir")}if(!e.clean||e.dryRun)return;if(t===am(t).root)throw Error("Refusing to clean declarations from the filesystem root");let[r,n]=await Promise.all([jl(t),jl(nt(e.cwd,e.root))]);if(Wi(n,r))throw Error("Refusing to clean an outdir that contains the source root")}function cm(e){let t=xr.get(e);if(!t){if(t=new Kl(e),xr.set(e,t),xr.size>om){let r=xr.keys().next().value;if(r!==void 0)xr.delete(r)}}return t}async function fm(e){let t=nt(e.cwd,e.outdir);async function r(n){let i;try{i=await tm(n,{withFileTypes:!0})}catch{return}await Promise.all(i.map(async(s)=>{let a=nt(n,s.name);if(s.isDirectory()){await r(a);return}if(s.name.endsWith(".d.ts")||s.name.endsWith(".d.mts")||s.name.endsWith(".d.cts")||s.name.endsWith(".d.ts.map")||s.name.endsWith(".d.mts.map")||s.name.endsWith(".d.cts.map"))await im(a,{force:!0})}))}await r(t)}function ms(e,t,r){if(!t||t.length===0)return!1;let n=Ne(r,e);for(let i of t){let s=cm(i);if(s.match(n)||s.match(e))return!0}return!1}async function um(e){let t=[],r=nt(e.cwd,e.root),n=e.exclude||[],i=[...e.entrypoints,...e.include??[]];for(let s of i)if(gs(s)&&ps(s)){if(!s.includes("node_modules")){if(!Wi(s,r)&&e.outputStructure!=="flat")j.warn(`Skipping entrypoint outside root: ${Ne(e.cwd,s)}`);else if(!ms(s,n,r))t.push(s)}}else{let a=new Kl(s);for await(let o of a.scan({cwd:r,absolute:!0,onlyFiles:!0}))if(ps(o)&&!o.includes("node_modules")){if(!ms(o,n,r))t.push(o)}}return[...new Set(t)].sort()}function Wi(e,t){let r=Ne(t,e);return r!==".."&&!r.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!gs(r)}function hm(e,t){let r=new Map;for(let n of e){let i=Rr(n,t),s=r.get(i);if(s&&s!==n)throw Error(`Output path collision: ${Ne(t.cwd,s)} and ${Ne(t.cwd,n)} both emit ${Ne(t.cwd,i)}`);r.set(i,n)}}function ps(e){return/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/.test(e)&&!/\.d\.(?:ts|mts|cts)$/.test(e)}function Rr(e,t){let r=nt(t.cwd,t.root),n=Ne(r,e).replace(/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/,(i)=>{if(i===".mts"||i===".mjs")return".d.mts";if(i===".cts"||i===".cjs")return".d.cts";return".d.ts"});if(t.outputStructure==="mirror")return nt(t.cwd,t.outdir,n);else{let i=n.split("/").pop();return nt(t.cwd,t.outdir,i)}}function dm(e,t,r=""){let n=Ne(Tr(e),t).replace(/\\/g,"/");if(n=n.replace(/\.d\.mts$/,"").replace(/\.d\.cts$/,"").replace(/\.d\.ts$/,""),r)n+=r;if(!n.startsWith("."))n=`./${n}`;return n}function mm(e,t,r){let n=Rr(t,r),i=(s)=>{let a=Ni(s,t);if(!a.isRelative||!a.resolved)return s;if(/\.d\.(?:ts|mts|cts)$/.test(a.resolved))return s;let o=s.match(/[?#].*$/)?.[0]??"",c=o?s.slice(0,-o.length):s,f=sm(c),u=/^(?:\.js|\.jsx|\.mjs|\.cjs)$/.test(f)?f:"";return dm(n,Rr(a.resolved,r),u)+o};return e.replace(/\b(from\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(s,a,o,c)=>{return`${a}${o}${i(c)}${o}`}).replace(/\b(import\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(s,a,o,c)=>{return`${a}${o}${i(c)}${o}`}).replace(/\b(import\s*\(\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(s,a,o,c)=>{return`${a}${o}${i(c)}${o}`})}async function pm(e,t,r,n,i){let s=t;if(n)s=await n.runOnBeforeFile(e,t);let a=Mi(s,e,r.keepComments,r.isolatedDeclarations??!1);if(n)a=await n.runOnDeclarations(e,s,a);let o=0,c=0;for(let u=0;u<a.length;u++){let l=a[u];if(l.kind==="import")o++;if(l.kind==="export"||l.isExported)c++}let f=Wl(a,{filePath:e,sourceCode:s,declarations:a},r.keepComments,r.importOrder);if(f=mm(f,e,r),i)f=Tl(f,i,{filePath:e});if(r.normalizeOutput===!0||r.declarationOrder)f=Sl(f,{lineEnding:"lf",declarationOrder:r.declarationOrder,indent:{style:r.indentStyle??"spaces",size:r.indentSize??2}});if(n)f=await n.runOnAfterFile(e,s,f);return{content:f,declarationCount:a.length,importCount:o,exportCount:c}}var Kl,om=50,xr;var Ul=le(()=>{Ms();Ls();Po();pl();yl();ho();$l();bl();Rl();_s();cs();Mo();Ll();_l();wi();({Glob:Kl}=globalThis.Bun);xr=new Map});var Yl=le(()=>{Ul()});var tc={};yc(tc,{dtsWatch:()=>xm,dtsCheck:()=>Tm,dts:()=>Cs,default:()=>Om,clearCache:()=>Rm,PluginErrorCodes:()=>Sm,DtsxPluginError:()=>ar});import{createHash as ym}from"crypto";import{existsSync as Cm,readFileSync as wm,writeFileSync as $m}from"fs";import{dirname as Em,join as vm,relative as Zl,resolve as sr,sep as Gi}from"path";import Xl from"process";class zl{listeners=new Map;on(e,t){let r=this.listeners.get(e)||[];r.push(t),this.listeners.set(e,r)}async emit(e,t){let r={type:e,timestamp:Date.now(),data:t},n=this.listeners.get(e)||[];for(let i of n)await i(r)}}class ys{manifest;cacheDir;manifestPath;constructor(e,t){this.cacheDir=e,this.manifestPath=vm(e,"manifest.json"),this.manifest=this.loadManifest(t)}loadManifest(e){try{if(Cm(this.manifestPath)){let t=JSON.parse(wm(this.manifestPath,"utf-8"));if(t.configHash===e&&t.version==="1.0")return t}}catch{}return{version:"1.0",configHash:e,entries:{}}}save(){try{let{mkdirSync:e}=gm("fs");e(this.cacheDir,{recursive:!0}),$m(this.manifestPath,JSON.stringify(this.manifest,null,2))}catch{}}getEntry(e){return this.manifest.entries[e]}setEntry(e,t){this.manifest.entries[e]=t}isValid(e,t){return this.getEntry(e)?.hash===t}clear(){this.manifest.entries={},this.save()}}function bm(e){let t={root:e.root,outdir:e.outdir,entrypoints:e.entrypoints,clean:e.clean,tsconfigPath:e.tsconfigPath};return ym("md5").update(JSON.stringify(t)).digest("hex")}function Cs(e={}){let{onSuccess:t,onError:r,failOnError:n=!0,incremental:i=!1,cacheDir:s=".dtsx-cache",on:a,timeout:o=60000,continueOnError:c=!1,verbose:f=!1,...u}=e,l=new zl;if(a){for(let[g,d]of Object.entries(a))if(d)l.on(g,d)}return{name:"bun-plugin-dtsx",async setup(g){let d=Date.now(),$=null,v=0;try{let C=ec(u,g),x=bm(C);if(C.clean){let B=sr(C.cwd??Xl.cwd(),C.outdir??"./dist");if(ql.has(B))C.clean=!1;else ql.add(B)}if(i)$=new ys(sr(s),x);if(await l.emit("start",{type:"start",files:C.entrypoints||[],config:C}),f){if(console.log("[bun-plugin-dtsx] Starting declaration generation..."),i)console.log("[bun-plugin-dtsx] Incremental mode enabled")}let R=await(async()=>{return new Promise((B,W)=>{let T=setTimeout(()=>{W(new ar(`Generation timed out after ${o}ms`,"TIMEOUT_ERROR",{timeout:o}))},o);Li(C).then((D)=>{clearTimeout(T),B(D)}).catch((D)=>{clearTimeout(T),W(D)})})})(),I=Date.now()-d;if($)$.save();if(await l.emit("complete",{type:"complete",stats:R,duration:I,fromCache:v}),f){if(console.log(`[bun-plugin-dtsx] Generation complete in ${I}ms`),v>0)console.log(`[bun-plugin-dtsx] ${v} files served from cache`)}if(t)await t(R)}catch(C){let x=Ql(C);if(await l.emit("error",{type:"error",error:x}),r)await r(x);else{if(console.error("[bun-plugin-dtsx] Error generating declarations:"),console.error(` Code: ${x.code}`),console.error(` Message: ${x.message}`),x.context)console.error(` Context: ${JSON.stringify(x.context)}`);if(f&&x.stack)console.error(` Stack: ${x.stack}`)}if(n&&!c)throw x}}}}function Ql(e){if(e instanceof ar)return e;if(e instanceof Error){let t="GENERATION_ERROR";if(e.message.includes("config")||e.message.includes("Config"))t="CONFIG_ERROR";else if(e.message.includes("file")||e.message.includes("File")||e.message.includes("ENOENT"))t="FILE_ERROR";return new ar(e.message,t,{originalError:e.name},e)}return new ar(String(e),"GENERATION_ERROR")}function Am(e){let t=e.map((n)=>Em(n).split(Gi)),r=t[0];for(let n of t.slice(1)){let i=0;while(i<r.length&&i<n.length&&r[i]===n[i])i++;r=r.slice(0,i)}return r.join(Gi)||Gi}function ec(e,t){let r=e.cwd||Xl.cwd(),n=t?.config?.entrypoints,i=e.outdir||e.build?.config.outdir||t?.config.outdir||"./dist",s=e.root||e.build?.config.root||t?.config.root;if(!s&&n?.length){let o=Am(n.map((c)=>sr(r,c)));s=Zl(r,o)||"."}s=s||"./src";let a=e.entrypoints;if(!a)if(n?.length){let o=sr(r,s),c=[];for(let f of n){let u=sr(r,f);if(u===o||u.startsWith(o+Gi))c.push(Zl(o,u));else console.warn(`[bun-plugin-dtsx] Skipping entrypoint outside root "${s}": ${f}`)}a=c.length?c:["index.ts"]}else a=["index.ts"];return{...e,cwd:r,root:s,entrypoints:a,outdir:i,clean:e.clean??!0,tsconfigPath:e.tsconfigPath}}function xm(e={}){return Cs({...e,incremental:!0,verbose:e.verbose??!0})}function Tm(e){return{name:"bun-plugin-dtsx-check",async setup(t){let r=ec({...e,outdir:""},t);try{await Li({...r,clean:!1})}catch(n){let i=Ql(n);if(e.onError)await e.onError(i);if(e.failOnError!==!1)throw i}}}}function Rm(e=".dtsx-cache"){new ys(sr(e),"").clear()}var gm,Sm,ar,ql,Om;var rc=le(()=>{Yl();gm=import.meta.require,Sm={CONFIG_ERROR:"CONFIG_ERROR",GENERATION_ERROR:"GENERATION_ERROR",FILE_ERROR:"FILE_ERROR",CACHE_ERROR:"CACHE_ERROR",TIMEOUT_ERROR:"TIMEOUT_ERROR"};ar=class ar extends Error{code;context;cause;constructor(e,t,r,n){super(e);if(this.name="DtsxPluginError",this.code=t,this.context=r,this.cause=n,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}};ql=new Set;Om=Cs});import{mkdir as Pm,stat as km}from"fs/promises";import{bold as ws,dim as $s,green as Mm,italic as ic,log as Im}from"@stacksjs/cli";import{path as st}from"@stacksjs/path";import{glob as nc}from"@stacksjs/storage";async function Dm(e){let t=await nc([st.resolve(e,"dist","**/*.d.ts")],{absolute:!0}),r=new Bun.Transpiler({loader:"ts",target:"bun"});for(let n of t){let i=await Bun.file(n).text();try{r.transformSync(i)}catch(s){throw Error(`Invalid declaration generated at ${n}: ${s instanceof Error?s.message:String(s)}`)}}}async function Fm(e){let t=st.resolve(e,"dist","index.js");if(!await Bun.file(t).exists())return;let r=Bun.spawnSync({cmd:[process.execPath,"-e",`await import(${JSON.stringify(t)})`],stdout:"ignore",stderr:"pipe",env:{...process.env,NODE_ENV:"test"}});if(r.exitCode===0)return;let n=new TextDecoder().decode(r.stderr??new Uint8Array);if(/needs to refer to a top-level declared variable|does not provide an export named|Export named .* not found/i.test(n))throw Error(`Built package at ${t} cannot be imported: ${n.trim().split(`
229
231
  `)[0]}
230
- This is the minified-barrel failure. Build with \`transpilePackage\` instead of a minifying \`Bun.build\`.`)}async function b0(e){let r=Date.now()-e.startTime,n=e.pkgName??`@stacksjs/${nt.basename(e.dir)}`;if(e.result.errors&&e.result.errors.length>0)throw console.error("Build errors:",e.result.errors),Error(`Build failed with errors: ${JSON.stringify(e.result.errors)}`);else if(e.result.success!==void 0&&!e.result.success){let s=e.result.logs?.[0]||"Unknown build error";throw console.log(s),Error(`Build failed: ${s}`)}await km(e.dir),await Mm(e.dir);let i=await tc([nt.resolve(e.dir,"dist","**/*")],{absolute:!0});for(let s of i){let a=await Rm(s),o;if(a.size<1048576)o=`${(a.size/1024).toFixed(2)}kb`;else o=`${(a.size/1024/1024).toFixed(2)}mb`;let c=nt.relative(e.dir,s).replace("dist/","");console.log(`${ys(Cs(`[${o}]`))} ${Cs("dist/")}${c}`)}console.log(`${ys(Cs(`[${r}ms]`))} Built ${ec(ys(Om(n)))}`)}async function A0(e){let t=e.pkgName??`@stacksjs/${nt.basename(e.dir)}`;if(e.styled===!1)console.log(`Building ${t}...`);else Pm.info(`Building ${ec(t)}...`);return{startTime:Date.now()}}async function x0(e){let{dts:t}=await Promise.resolve().then(() => (Ql(),zl)),r=nt.resolve(e.dir,"src"),n=nt.resolve(e.dir,"dist"),i=(await Array.fromAsync(new Bun.Glob("**/*.ts").scan({cwd:r}))).filter((a)=>!a.endsWith(".d.ts")).filter((a)=>!a.endsWith(".test.ts")&&!a.endsWith(".spec.ts"));await Bun.build({entrypoints:i.map((a)=>nt.resolve(r,a)),outdir:n,root:r,target:"bun",format:"esm",splitting:!1,external:e.external??Im(),plugins:[t({root:r,outdir:n})]});let s=new Bun.Transpiler({loader:"ts",target:"bun",minifyWhitespace:!0});for(let a of i){let o=s.transformSync(await Bun.file(nt.resolve(r,a)).text());o=o.replace(/(['"])(\.\.?\/[^'"]+?)\.tsx?\1/g,"$1$2.js$1");let c=nt.resolve(n,a.replace(/\.ts$/,".js"));await Tm(nt.dirname(c),{recursive:!0}),await Bun.write(c,o)}}function Im(e=[]){let t=[];try{let r=Ze("fs"),n=JSON.parse(r.readFileSync(`${process.cwd()}/package.json`,"utf8"));t=[...Object.keys(n.dependencies??{}),...Object.keys(n.peerDependencies??{}),...Object.keys(n.optionalDependencies??{})]}catch{}return["@stacksjs/*",...t,...t.map((r)=>`${r}/*`),"bun-queue","ioredis","localtunnels","localtunnels/*","@craft-native/ts","ts-md","meilisearch","algoliasearch","@opensearch-project/opensearch","*.yaml","*.yml",...e]}export{Mm as validateRuntimeExports,km as validateDeclarations,x0 as transpilePackage,b0 as outro,A0 as intro,Im as frameworkExternal};
232
+ This is the minified-barrel failure. Build with \`transpilePackage\` instead of a minifying \`Bun.build\`.`)}async function T0(e){let r=Date.now()-e.startTime,n=e.pkgName??`@stacksjs/${st.basename(e.dir)}`;if(e.result.errors&&e.result.errors.length>0)throw console.error("Build errors:",e.result.errors),Error(`Build failed with errors: ${JSON.stringify(e.result.errors)}`);else if(e.result.success!==void 0&&!e.result.success){let s=e.result.logs?.[0]||"Unknown build error";throw console.log(s),Error(`Build failed: ${s}`)}await Dm(e.dir),await Fm(e.dir);let i=await nc([st.resolve(e.dir,"dist","**/*")],{absolute:!0});for(let s of i){let a=await km(s),o;if(a.size<1048576)o=`${(a.size/1024).toFixed(2)}kb`;else o=`${(a.size/1024/1024).toFixed(2)}mb`;let c=st.relative(e.dir,s).replace("dist/","");console.log(`${ws($s(`[${o}]`))} ${$s("dist/")}${c}`)}console.log(`${ws($s(`[${r}ms]`))} Built ${ic(ws(Mm(n)))}`)}async function R0(e){let t=e.pkgName??`@stacksjs/${st.basename(e.dir)}`;if(e.styled===!1)console.log(`Building ${t}...`);else Im.info(`Building ${ic(t)}...`);return{startTime:Date.now()}}async function O0(e){let{dts:t}=await Promise.resolve().then(() => (rc(),tc)),r=st.resolve(e.dir,"src"),n=st.resolve(e.dir,"dist"),i=(await Array.fromAsync(new Bun.Glob("**/*.ts").scan({cwd:r}))).filter((a)=>!a.endsWith(".d.ts")).filter((a)=>!a.endsWith(".test.ts")&&!a.endsWith(".spec.ts"));await Bun.build({entrypoints:i.map((a)=>st.resolve(r,a)),outdir:n,root:r,target:"bun",format:"esm",splitting:!1,external:e.external??Nm(),plugins:[t({root:r,outdir:n})]});let s=new Bun.Transpiler({loader:"ts",target:"bun",minifyWhitespace:!0});for(let a of i){let o=s.transformSync(await Bun.file(st.resolve(r,a)).text());o=o.replace(/(['"])(\.\.?\/[^'"]+?)\.tsx?\1/g,"$1$2.js$1");let c=st.resolve(n,a.replace(/\.ts$/,".js"));await Pm(st.dirname(c),{recursive:!0}),await Bun.write(c,o)}}function Nm(e=[]){let t=[];try{let r=qe("fs"),n=JSON.parse(r.readFileSync(`${process.cwd()}/package.json`,"utf8"));t=[...Object.keys(n.dependencies??{}),...Object.keys(n.peerDependencies??{}),...Object.keys(n.optionalDependencies??{})]}catch{}return["@stacksjs/*",...t,...t.map((r)=>`${r}/*`),"bun-queue","ioredis","localtunnels","localtunnels/*","@craft-native/ts","ts-md","meilisearch","algoliasearch","@opensearch-project/opensearch","*.yaml","*.yml",...e]}export{Fm as validateRuntimeExports,Dm as validateDeclarations,O0 as transpilePackage,T0 as outro,R0 as intro,Nm as frameworkExternal};