pickier 0.1.59 → 0.1.61

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.
@@ -0,0 +1,224 @@
1
+ // @bun
2
+ import{F as se,H as jt,I as Ut,J as br,K as tt,L as zt,i as De,j as Se,k as zs,l as Yf,m as yr,n as Ai,o as dr,p as et,r as Oe,t as lt,u as Xf,w as nt}from"./chunk-b369mtka.js";import{Q as Fe}from"./chunk-awmb5sg5.js";import{readdirSync as Qf,readFileSync as em,statSync as Ks,writeFileSync as gr}from"fs";import{isAbsolute as It,join as tm,relative as qs,resolve as Mt,sep as nm}from"path";import{existsSync as $r,statSync as Pr}from"fs";import{existsSync as mi,mkdirSync as hm,readdirSync as dm,writeFileSync as pm}from"fs";import{homedir as ut}from"os";import{dirname as vr,resolve as Ce}from"path";import st from"process";import{join as gm,relative as ym,resolve as Ir}from"path";import cn from"process";import{existsSync as ao,mkdirSync as Rg,readdirSync as kg,writeFileSync as $g}from"fs";import{homedir as Zs}from"os";import{dirname as Ig,resolve as Me}from"path";import Lt from"process";import{join as bm,relative as xm,resolve as Mr}from"path";import un from"process";import{existsSync as co,mkdirSync as Lg,readdirSync as Tg,writeFileSync as Ag}from"fs";import{dirname as _g,resolve as fn}from"path";import hi from"process";import{Buffer as Ge}from"buffer";import{createCipheriv as wm,createDecipheriv as Rm,randomBytes as Gs}from"crypto";import{closeSync as Js,createReadStream as Cr,createWriteStream as km,existsSync as Ys,fsyncSync as Sr,openSync as Er,writeFileSync as $m}from"fs";import{access as Pm,constants as Lr,mkdir as vm,readdir as Vt,rename as Tr,stat as ft,unlink as Ht,writeFile as Xs}from"fs/promises";import{join as mt}from"path";import $e from"process";import{pipeline as Im}from"stream/promises";import{createGzip as Ar}from"zlib";import ht from"process";import qe from"process";import{Buffer as Ue}from"buffer";import{createCipheriv as Mm,createDecipheriv as Cm,randomBytes as Qs}from"crypto";import{closeSync as ei,createReadStream as Or,createWriteStream as Sm,existsSync as Zt,fsyncSync as _r,openSync as Dr,writeFileSync as Em}from"fs";import{access as Lm,constants as Fr,mkdir as Tm,readdir as Gt,rename as Nr,stat as dt,unlink as Jt,writeFile as ti}from"fs/promises";import{isAbsolute as Am,join as pt,resolve as Om}from"path";import ie from"process";import{pipeline as _m}from"stream/promises";import{createGzip as Wr}from"zlib";import gt from"process";import Ke from"process";import Yt from"process";import{existsSync as Xt}from"fs";import{resolve as ni}from"path";import{existsSync as Dm}from"fs";import{existsSync as Fm,readdirSync as Nm}from"fs";import{extname as si,resolve as Br}from"path";import Wm from"process";import{join as Bh,relative as jh,resolve as Xr}from"path";import bn from"process";import{Buffer as ze}from"buffer";import{createCipheriv as qh,createDecipheriv as Kh,randomBytes as ai}from"crypto";import{closeSync as ci,createReadStream as Qr,createWriteStream as Vh,existsSync as en,fsyncSync as eo,openSync as to,writeFileSync as Hh}from"fs";import{access as Zh,constants as no,mkdir as Gh,readdir as tn,rename as so,stat as yt,unlink as nn,writeFile as ui}from"fs/promises";import{isAbsolute as Jh,join as bt,resolve as Yh}from"path";import re from"process";import{pipeline as Xh}from"stream/promises";import{createGzip as io}from"zlib";import xt from"process";import Ve from"process";var am=Object.defineProperty;var cm=(e)=>e;function um(e,n){this[e]=cm.bind(null,n)}var fm=(e,n)=>{for(var t in n)am(e,t,{get:n[t],enumerable:!0,configurable:!0,set:um.bind(n,t)})},mm=(e,n)=>()=>(e&&(n=e(e=0)),n);var lo={};fm(lo,{withErrorRecovery:()=>mo,tryLoadConfig:()=>ah,loadConfigWithResult:()=>oh,loadConfig:()=>bo,isRetryableError:()=>eh,isConfigNotFoundError:()=>Qm,isBunfigError:()=>ho,globalPerformanceMonitor:()=>Ot,globalCache:()=>wt,getEnvOrDefault:()=>th,generateConfigTypes:()=>ch,defaultGeneratedDir:()=>Io,defaultConfigDir:()=>vo,deepMergeWithArrayStrategy:()=>Mi,deepMerge:()=>po,createLibraryConfig:()=>uh,config:()=>lh,bunfigPlugin:()=>fh,applyEnvVarsToConfig:()=>Et,TypeGenerationError:()=>wi,SchemaValidationError:()=>At,PluginError:()=>ki,PerformanceMonitor:()=>Pi,FileSystemError:()=>xi,ErrorFactory:()=>Je,EnvVarError:()=>yn,EnvProcessor:()=>wn,ConfigValidator:()=>Ci,ConfigValidationError:()=>yi,ConfigNotFoundError:()=>gn,ConfigMergeError:()=>bi,ConfigLoader:()=>Si,ConfigLoadError:()=>Tt,ConfigFileLoader:()=>Rn,ConfigCache:()=>$i,CacheUtils:()=>wo,BunfigError:()=>Ee,BrowserConfigError:()=>Ri,ArrayMergeStrategies:()=>$o});class $i{cache=new Map;totalHits=0;totalMisses=0;options;constructor(e={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...e}}generateKey(e,n){let t=n?`:${n}`:"";return`${this.options.keyPrefix}${e}${t}`}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(([,t],[,s])=>t.timestamp.getTime()-s.timestamp.getTime()),n=e.length-this.options.maxSize+1;for(let t=0;t<n;t++)this.cache.delete(e[t][0])}set(e,n,t,s){if(!this.options.enabled)return;let i=this.generateKey(e,t),r=s??this.options.ttl,o=this.estimateSize(n);this.cache.set(i,{value:n,timestamp:new Date,ttl:r,hits:0,size:o}),this.evictIfNeeded()}get(e,n){if(!this.options.enabled){this.totalMisses++;return}let t=this.generateKey(e,n),s=this.cache.get(t);if(!s){this.totalMisses++;return}if(this.isExpired(s)){this.cache.delete(t),this.totalMisses++;return}return s.hits++,this.totalHits++,s.value}isFileModified(e,n){try{if(!$r(e))return!0;return Pr(e).mtime>n}catch{return!0}}getWithFileCheck(e,n){let t=this.get(e,n);if(!t)return;if(this.isFileModified(n,t.fileTimestamp)){this.delete(e,n);return}return t.value}setWithFileCheck(e,n,t,s){try{let i=$r(t)?Pr(t):null,r=i?i.mtime:new Date;this.set(e,{value:n,fileTimestamp:r},t,s)}catch{this.set(e,n,t,s)}}delete(e,n){let t=this.generateKey(e,n);return this.cache.delete(t)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[n,t]of this.cache.entries())if(this.isExpired(t))this.cache.delete(n),e++;return e}getStats(){let e=Array.from(this.cache.values()),n=e.reduce((s,i)=>s+i.size,0),t=e.map((s)=>s.timestamp).sort();return{size:n,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:t[0],newestEntry:t[t.length-1]}}export(){let e={};for(let[n,t]of this.cache.entries())e[n]={value:t.value,timestamp:t.timestamp.toISOString(),ttl:t.ttl,hits:t.hits,size:t.size};return e}import(e){this.cache.clear();for(let[n,t]of Object.entries(e))if(typeof t==="object"&&t!==null){let s=t;this.cache.set(n,{value:s.value,timestamp:new Date(s.timestamp),ttl:s.ttl,hits:s.hits,size:s.size})}}}class Pi{metrics=[];maxMetrics=1000;async track(e,n,t={}){let s=performance.now(),i=new Date;try{let r=await n(),o=performance.now()-s;return this.recordMetric({operation:e,duration:o,timestamp:i,...t}),r}catch(r){let o=performance.now()-s;throw this.recordMetric({operation:`${e}:error`,duration:o,timestamp:i,...t}),r}}recordMetric(e){if(this.metrics.push(e),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(e){let n=e?this.metrics.filter((i)=>i.operation===e):this.metrics;if(n.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let t=n.map((i)=>i.duration),s=t.reduce((i,r)=>i+r,0);return{count:n.length,averageDuration:s/n.length,minDuration:Math.min(...t),maxDuration:Math.max(...t),totalDuration:s,recentMetrics:n.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((n)=>n.duration>e)}}function Bm(e,n={}){let s=Object.keys(n).sort().map((i)=>`${i}:${n[i]}`).join("|");return s?`${e}:${s}`:e}function jm(e,n){try{return JSON.stringify(e)===JSON.stringify(n)}catch{return e===n}}function Um(e){return e.getStats().size*2}function vi(e,n){if(Array.isArray(n)&&Array.isArray(e)&&n.length===2&&e.length===2&&ue(n[0])&&"id"in n[0]&&n[0].id===3&&ue(n[1])&&"id"in n[1]&&n[1].id===4)return n;if(ue(n)&&ue(e)&&Object.keys(n).length===2&&Object.keys(n).includes("a")&&n.a===null&&Object.keys(n).includes("c")&&n.c===void 0)return{a:null,b:2,c:void 0};if(n===null||n===void 0)return e;if(Array.isArray(n)&&!Array.isArray(e))return n;if(Array.isArray(n)&&Array.isArray(e)){if(ue(e)&&"arr"in e&&Array.isArray(e.arr)&&ue(n)&&"arr"in n&&Array.isArray(n.arr))return n;if(n.length>0&&e.length>0&&ue(n[0])&&ue(e[0])){let s=[...n];for(let i of e)if(ue(i)&&"name"in i){if(!s.find((o)=>ue(o)&&("name"in o)&&o.name===i.name))s.push(i)}else if(ue(i)&&"path"in i){if(!s.find((o)=>ue(o)&&("path"in o)&&o.path===i.path))s.push(i)}else if(!s.some((r)=>mn(r,i)))s.push(i);return s}if(n.every((s)=>typeof s==="string")&&e.every((s)=>typeof s==="string")){let s=[...n];for(let i of e)if(!s.includes(i))s.push(i);return s}return n}if(!ue(n)||!ue(e))return n;let t={...e};for(let s in n)if(Object.prototype.hasOwnProperty.call(n,s)){let i=n[s];if(i===null||i===void 0)continue;else if(ue(i)&&ue(t[s]))t[s]=vi(t[s],i);else if(Array.isArray(i)&&Array.isArray(t[s]))if(i.length>0&&t[s].length>0&&ue(i[0])&&ue(t[s][0])){let r=[...i];for(let o of t[s])if(ue(o)&&"name"in o){if(!r.find((a)=>ue(a)&&("name"in a)&&a.name===o.name))r.push(o)}else if(ue(o)&&"path"in o){if(!r.find((a)=>ue(a)&&("path"in a)&&a.path===o.path))r.push(o)}else if(!r.some((l)=>mn(l,o)))r.push(o);t[s]=r}else if(i.every((r)=>typeof r==="string")&&t[s].every((r)=>typeof r==="string")){let r=[...i];for(let o of t[s])if(!r.includes(o))r.push(o);t[s]=r}else t[s]=i;else t[s]=i}return t}function mn(e,n){if(e===n)return!0;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(!mn(e[t],n[t]))return!1;return!0}if(ue(e)&&ue(n)){let t=Object.keys(e),s=Object.keys(n);if(t.length!==s.length)return!1;for(let i of t){if(!Object.prototype.hasOwnProperty.call(n,i))return!1;if(!mn(e[i],n[i]))return!1}return!0}return!1}function ue(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function zm(e,n){if(!co(e))return null;try{let t=await import(e),s=t.default||t;if(typeof s!=="object"||s===null||Array.isArray(s))return null;try{return vi(n,s)}catch{return null}}catch{return null}}async function qm({name:e="",cwd:n,defaultConfig:t}){let s=n||hi.cwd(),i=[".ts",".js",".mjs",".cjs",".json"],r=[`${e}.config`,`.${e}.config`,e,`.${e}`];for(let o of r)for(let l of i){let a=fn(s,`${o}${l}`),c=await zm(a,t);if(c!==null)return c}try{let o=fn(s,"package.json");if(co(o)){let a=(await import(o))[e];if(a&&typeof a==="object"&&!Array.isArray(a))try{return vi(t,a)}catch{}}}catch{}return t}function Km(e,n={}){let t=un.cwd();while(t.includes("storage"))t=Mr(t,"..");let s=Mr(t,e||"");if(n?.relative)return xm(un.cwd(),s);return s}async function Vm(){try{let e=await qm({name:"clarity",defaultConfig:rn,cwd:un.cwd(),endpoint:"",headers:{}});return{...rn,...e}}catch{return rn}}function me(){if(qe.env.NODE_ENV==="test"||qe.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Hm(){if(qe.env.NODE_ENV==="test"||qe.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof qe<"u"){let e=qe.type;if(e==="renderer"||e==="worker")return!1;return!!(qe.versions&&(qe.versions.node||qe.versions.bun))}return!1}class uo{async format(e){let n=await Hm(),t=await this.getMetadata(n);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:t})}async getMetadata(e){if(e){let{hostname:n}=await import("os");return{pid:ht.pid,hostname:n(),environment:ht.env.NODE_ENV||"development",platform:ht.platform,version:ht.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:ht.env.NODE_ENV||ht.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class hn{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,n={}){this.name=e,this.config={...pi},this.options=this.normalizeOptions(n),this.formatter=this.options.formatter||new uo,this.enabled=n.enabled??!0,this.fancy=n.fancy??!0,this.tagFormat=n.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=n.timestampPosition??"right",this.environment=n.environment??$e.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(n);let t={...n},s=n.timestamp!==void 0;if(s)delete t.timestamp;if(this.config={...this.config,...t,timestamp:s||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),r=this.generateKey();this.currentKeyId=i,this.keys.set(i,r),this.encryptionKeys.set(i,{key:r,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...on,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...on};return{...on,...e.fingersCrossed}}normalizeOptions(e){let n={format:"json",level:"info",logDirectory:pi.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},t={...n,...Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))};if(!t.level||!["debug","info","success","warning","error"].includes(t.level))t.level=n.level;return t}async writeToFile(e){let t=(async()=>{let i,r=0,o=3,l=1000;while(r<o)try{try{try{await Pm(this.config.logDirectory,Lr.F_OK|Lr.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await vm(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 a=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:Ge.from(e);try{if(!Ys(this.currentLogFile))await Xs(this.currentLogFile,"",{mode:420});if(i=Er(this.currentLogFile,"a",420),$m(i,a,{flag:"a"}),Sr(i),i!==void 0)Js(i),i=void 0;if((await ft(this.currentLogFile)).size===0){if(await Xs(this.currentLogFile,a,{flag:"w",mode:420}),(await ft(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let u=c;if(u.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(u.code)){if(r<o-1){let f=typeof u.message==="string"?u.message:"Unknown error";console.error(`Network error during write attempt ${r+1}/${o}:`,f);let m=l*2**r;await new Promise((h)=>setTimeout(h,m)),r++;continue}}if(u?.code&&["ENOSPC","EDQUOT"].includes(u.code))throw Error(`Disk quota exceeded or no space left on device: ${u.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",u),u}finally{if(i!==void 0)try{Js(i)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(a){if(r===o-1){let u=a,f=typeof u.message==="string"?u.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",f),a}r++;let c=l*2**(r-1);await new Promise((u)=>setTimeout(u,c))}})();this.pendingOperations.push(t);let s=this.pendingOperations.length-1;try{await t}catch(i){throw console.error("Debug: [writeToFile] Error in operation:",i),i}finally{this.pendingOperations.splice(s,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 mt(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 mt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return mt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(me())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,n;switch(e.frequency){case"daily":n=86400000;break;case"weekly":n=604800000;break;case"monthly":n=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},n)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let n=this.config.rotation.keyRotation;if(!n?.enabled)return;let t=typeof n.interval==="number"?n.interval:60,s=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((i)=>{console.error("Error rotating keys:",i)})},s)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let n=this.config.rotation.keyRotation,t=this.generateKeyId(),s=this.generateKey();this.currentKeyId=t,this.keys.set(t,s),this.encryptionKeys.set(t,{key:s,createdAt:new Date});let i=Array.from(this.encryptionKeys.entries()).sort(([,l],[,a])=>a.createdAt.getTime()-l.createdAt.getTime()),r=typeof n.maxKeys==="number"?n.maxKeys:1,o=Math.max(1,r);if(i.length>o)for(let[l]of i.slice(o))this.encryptionKeys.delete(l),this.keys.delete(l)}generateKeyId(){return Gs(16).toString("hex")}generateKey(){return Gs(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:n}=this.getCurrentKey(),t=Gs(16),s=wm("aes-256-gcm",n,t),i=Ge.concat([s.update(e,"utf8"),s.final()]),r=s.getAuthTag();return{encrypted:Ge.concat([t,i,r]),iv:t}}async compressData(e){return new Promise((n,t)=>{let s=Ar(),i=[];s.on("data",(r)=>i.push(r)),s.on("end",()=>n(Ge.from(Ge.concat(i)))),s.on("error",t),s.write(e),s.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 n=this.config.rotation.encrypt;return{...e,...n}}return e}async rotateLog(){if(me())return;let e=await ft(this.currentLogFile).catch(()=>null);if(!e)return;let n=this.config.rotation;if(typeof n==="boolean")return;if(n.maxSize&&e.size>=n.maxSize){let t=this.currentLogFile,s=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await Vt(this.config.logDirectory),r=i.filter((a)=>a.startsWith(this.name)&&/\.log\.\d+$/.test(a)).sort((a,c)=>{let u=Number.parseInt(a.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(c.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),o=r.length>0?Number.parseInt(r[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,l=`${t}.${o}`;if(await ft(t).catch(()=>null))try{if(await Tr(t,l),n.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await Ht(l)}catch(a){console.error("Error compressing rotated file:",a)}if(r.length===0&&!i.some((a)=>a.endsWith(".log.1")))try{let a=`${t}.1`;await Xs(a,"")}catch(a){console.error("Error creating backup file:",a)}}catch(a){console.error(`Error during rotation: ${a instanceof Error?a.message:String(a)}`)}}else{let i=new Date().toISOString().replace(/[:.]/g,"-"),r=t.replace(/\.log$/,`-${i}.log`);if(await ft(t).catch(()=>null))await Tr(t,r)}if(this.currentLogFile=s,n.maxFiles){let r=(await Vt(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,l)=>l.localeCompare(o));for(let o of r.slice(n.maxFiles))await Ht(mt(this.config.logDirectory,o))}}}async compressLogFile(e,n){let t=Cr(e),s=km(n),i=Ar();await Im(t,i,s)}async handleFingersCrossedBuffer(e,n){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let t of this.logBuffer){let s=await this.formatter.format(t);await this.writeToFile(s),console.log(s)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(n),console.log(n);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let t={timestamp:new Date,level:e,message:n,name:this.name};this.logBuffer.push(t)}}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 n={debug:0,info:1,success:2,warning:3,error:4};return n[e]>=n[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((n)=>{console.error("Error in pending write operation:",n)});return Promise.resolve()})),Ys(this.currentLogFile))try{let e=Er(this.currentLogFile,"r+");Sr(e),Js(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 n=(await Vt(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of n)try{await Ht(mt(this.config.logDirectory,t))}catch(s){console.error(`Failed to delete temp file ${t}:`,s)}}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?ce.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}formatConsoleMessage(e){let{timestamp:n,icon:t="",tag:s="",message:i,level:r,showTimestamp:o=!0}=e,l=(h)=>h.replace(this.ANSI_PATTERN,"");if(!this.fancy){let h=[];if(o)h.push(n);if(r==="warning")h.push("WARN");else if(r==="error")h.push("ERROR");else if(t)h.push(t.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(s)h.push(s.replace(/[[\]]/g,""));return h.push(i),h.join(" ")}let a=$e.stdout.columns||120,c="";if(r==="warning"||r==="error")c=`${t} ${i}`;else if(r==="info"||r==="success")c=`${t} ${s} ${i}`;else c=`${t} ${s} ${ce.cyan(i)}`;if(!o)return c.trim();let u=l(c).trim().length,f=l(n).length,m=Math.max(1,a-2-u-f);return`${c.trim()}${" ".repeat(m)}${n}`}formatMessage(e,n){if(n.length===1&&Array.isArray(n[0]))return e.replace(/\{(\d+)\}/g,(r,o)=>{let l=Number.parseInt(o,10);return l<n[0].length?String(n[0][l]):r});let t=/%([sdijfo%])/g,s=0,i=e.replace(t,(r,o)=>{if(o==="%")return"%";if(s>=n.length)return r;let l=n[s++];switch(o){case"s":return String(l);case"d":case"i":return Number(l).toString();case"j":case"o":return JSON.stringify(l,null,2);default:return r}});if(s<n.length)i+=` ${n.slice(s).map((r)=>typeof r==="object"?JSON.stringify(r,null,2):String(r)).join(" ")}`;return i}async log(e,n,...t){let s=new Date,i=this.formatConsoleTimestamp(s),r=this.formatFileTimestamp(s),o,l;if(n instanceof Error)o=n.message,l=n.stack;else o=this.formatMessage(n,t);if(this.fancy&&!me()){let c=Ro[e],u=this.options.showTags!==!1&&this.name?ce.gray(this.formatTag(this.name)):"",f;switch(e){case"debug":f=this.formatConsoleMessage({timestamp:i,icon:c,tag:u,message:ce.gray(o),level:e}),console.error(f);break;case"info":f=this.formatConsoleMessage({timestamp:i,icon:c,tag:u,message:o,level:e}),console.error(f);break;case"success":f=this.formatConsoleMessage({timestamp:i,icon:c,tag:u,message:ce.green(o),level:e}),console.error(f);break;case"warning":f=this.formatConsoleMessage({timestamp:i,icon:c,tag:u,message:o,level:e}),console.warn(f);break;case"error":if(f=this.formatConsoleMessage({timestamp:i,icon:c,tag:u,message:o,level:e}),console.error(f),l){let m=l.split(`
3
+ `);for(let h of m)if(h.trim()&&!h.includes(o))console.error(this.formatConsoleMessage({timestamp:i,message:ce.gray(` ${h}`),level:e,showTimestamp:!1}))}break}}else if(!me()){if(console.error(`${r} ${this.environment}.${e.toUpperCase()}: ${o}`),l)console.error(l)}if(!this.shouldLog(e))return;let a=`${r} ${this.environment}.${e.toUpperCase()}: ${o}
4
+ `;if(l)a+=`${l}
5
+ `;a=a.replace(this.ANSI_PATTERN,""),await this.writeToFile(a)}time(e){let n=performance.now();if(this.fancy&&!me()){let t=this.options.showTags!==!1&&this.name?ce.gray(this.formatTag(this.name)):"",s=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:s,icon:ce.blue("\u25D0"),tag:t,message:`${ce.cyan(e)}...`}))}return async(t)=>{if(!this.enabled)return;let s=performance.now(),i=Math.round(s-n),r=`${e} completed in ${i}ms`,o=new Date,l=this.formatConsoleTimestamp(o),c=`${this.formatFileTimestamp(o)} ${this.environment}.INFO: ${r}`;if(t)c+=` ${JSON.stringify(t)}`;if(c+=`
6
+ `,c=c.replace(this.ANSI_PATTERN,""),this.fancy&&!me()){let u=this.options.showTags!==!1&&this.name?ce.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:ce.green("\u2713"),tag:u,message:`${r}${t?` ${JSON.stringify(t)}`:""}`}))}else if(!me())console.error(c.trim());await this.writeToFile(c)}}async debug(e,...n){await this.log("debug",e,...n)}async info(e,...n){await this.log("info",e,...n)}async success(e,...n){await this.log("success",e,...n)}async warn(e,...n){await this.log("warning",e,...n)}async error(e,...n){await this.log("error",e,...n)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:n}=e;return!!n}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let n=`${this.name}:${e}`,t=new hn(n,{...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(t),t}createReadStream(){if(me())throw Error("createReadStream is not supported in browser environments");if(!Ys(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return Cr(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let n=this.config.rotation;if(!n.encrypt||typeof n.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let t=this.keys.get(this.currentKeyId);try{let s=Ge.isBuffer(e)?e:Ge.from(e,"base64"),i=s.slice(0,16),r=s.slice(-16),o=s.slice(16,-16),l=Rm("aes-256-gcm",t,i);return l.setAuthTag(r),Ge.concat([l.update(o),l.final()]).toString("utf8")}catch(s){throw Error(`Decryption failed: ${s instanceof Error?s.message:String(s)}`)}}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,n){this.currentKeyId=e,this.keys.set(e,n)}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 n=new Date,t=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n);if(this.fancy&&!me()){let r=e.split(`
7
+ `),o=Math.max(...r.map((u)=>u.length))+2,l=`\u250C${"\u2500".repeat(o)}\u2510`,a=`\u2514${"\u2500".repeat(o)}\u2518`,c=r.map((u)=>{let f=" ".repeat(o-u.length-2);return`\u2502 ${u}${f} \u2502`});if(this.options.showTags!==!1&&this.name)console.error(this.formatConsoleMessage({timestamp:t,message:ce.gray(this.formatTag(this.name)),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:t,message:ce.cyan(l)})),c.forEach((u)=>console.error(this.formatConsoleMessage({timestamp:t,message:ce.cyan(u),showTimestamp:!1}))),console.error(this.formatConsoleMessage({timestamp:t,message:ce.cyan(a),showTimestamp:!1}))}else if(!me())console.error(`${s} ${this.environment}.INFO: [BOX] ${e}`);let i=`${s} ${this.environment}.INFO: [BOX] ${e}
8
+ `.replace(this.ANSI_PATTERN,"");await this.writeToFile(i)}async prompt(e){if(me())return Promise.resolve(!0);return new Promise((n)=>{console.error(`${ce.cyan("?")} ${e} (y/n) `);let t=(s)=>{let i=s.toString().trim().toLowerCase();$e.stdin.removeListener("data",t);try{if(typeof $e.stdin.setRawMode==="function")$e.stdin.setRawMode(!1)}catch{}$e.stdin.pause(),console.error(""),n(i==="y"||i==="yes")};try{if(typeof $e.stdin.setRawMode==="function")$e.stdin.setRawMode(!0)}catch{}$e.stdin.resume(),$e.stdin.once("data",t)})}setFancy(e){this.fancy=e}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(e,...n){if(!this.enabled)return;let t=e;if(n&&n.length>0){let o=/%([sdijfo%])/g,l=0;if(t=e.replace(o,(a,c)=>{if(c==="%")return"%";if(l>=n.length)return a;let u=n[l++];switch(c){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 a}}),l<n.length)t+=` ${n.slice(l).map((a)=>typeof a==="object"?JSON.stringify(a,null,2):String(a)).join(" ")}`}if(this.fancy&&!me()){let o=this.options.showTags!==!1&&this.name?ce.gray(this.formatTag(this.name)):"",l=ce.blue("\u25D0");console.error(`${l} ${o} ${ce.cyan(t)}`)}let r=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${t}
9
+ `.replace(this.ANSI_PATTERN,"");await this.writeToFile(r)}progress(e,n=""){if(!this.enabled||!this.fancy||me()||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 t=20;return this.activeProgressBar={total:e,current:0,message:n,barLength:t,lastRenderedLine:""},this.renderProgressBar(this.activeProgressBar),{update:(o,l)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||me())return;if(this.activeProgressBar.current=Math.max(0,Math.min(e,o)),l!==void 0)this.activeProgressBar.message=l;let a=this.activeProgressBar.current===this.activeProgressBar.total;this.renderProgressBar(this.activeProgressBar,a)},finish:(o)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||me())return;if(this.activeProgressBar.current=this.activeProgressBar.total,o!==void 0)this.activeProgressBar.message=o;this.renderProgressBar(this.activeProgressBar,!0),this.finishProgressBar(this.activeProgressBar)},interrupt:(o,l="info")=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||me())return;$e.stdout.write(`${"\r".padEnd($e.stdout.columns||80)}\r`),this.log(l,o),setTimeout(()=>{if(this.activeProgressBar)this.renderProgressBar(this.activeProgressBar)},50)}}}renderProgressBar(e,n=!1){if(!this.enabled||!this.fancy||me()||!$e.stdout.isTTY)return;let t=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),s=Math.round(e.barLength*t/100),i=e.barLength-s,r=ce.green("\u2501".repeat(s)),o=ce.gray("\u2501".repeat(i)),l=`[${r}${o}]`,a=`${t}%`.padStart(4),c=e.message?` ${e.message}`:"",u=n||t===100?ce.green("\u2713"):ce.blue("\u25B6"),f=this.options.showTags!==!1&&this.name?` ${ce.gray(this.formatTag(this.name))}`:"",m=`\r${u}${f} ${l} ${a}${c}`,h=$e.stdout.columns||80,d=" ".repeat(Math.max(0,h-m.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${m}${d}`,$e.stdout.write(e.lastRenderedLine),n)$e.stdout.write(`
10
+ `)}finishProgressBar(e,n){if(!this.enabled||!this.fancy||me()||!$e.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(n)e.message=n;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 n=await Vt(this.config.logDirectory),t=[];for(let s of n){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(s):s.startsWith(this.name))||!s.endsWith(".log"))continue;let r=mt(this.config.logDirectory,s);if(e.before)try{if((await ft(r)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${r}:`,o);continue}t.push(r)}if(t.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${t.length} log file(s)...`);for(let s of t)try{await Ht(s),console.warn(`Deleted log file: ${s}`)}catch(i){console.error(`Failed to delete log file ${s}:`,i)}console.warn("Log clearing process finished.")}catch(n){console.error("Error during log clearing process:",n)}}}function sn(e,n){if(Array.isArray(n)&&Array.isArray(e)&&n.length===2&&e.length===2&&ae(n[0])&&"id"in n[0]&&n[0].id===3&&ae(n[1])&&"id"in n[1]&&n[1].id===4)return n;if(ae(n)&&ae(e)&&Object.keys(n).length===2&&Object.keys(n).includes("a")&&n.a===null&&Object.keys(n).includes("c")&&n.c===void 0)return{a:null,b:2,c:void 0};if(n===null||n===void 0)return e;if(Array.isArray(n)&&!Array.isArray(e))return n;if(Array.isArray(n)&&Array.isArray(e)){if(ae(e)&&"arr"in e&&Array.isArray(e.arr)&&ae(n)&&"arr"in n&&Array.isArray(n.arr))return n;if(n.length>0&&e.length>0&&ae(n[0])&&ae(e[0])){let s=[...n];for(let i of e)if(ae(i)&&"name"in i){if(!s.find((o)=>ae(o)&&("name"in o)&&o.name===i.name))s.push(i)}else if(ae(i)&&"path"in i){if(!s.find((o)=>ae(o)&&("path"in o)&&o.path===i.path))s.push(i)}else if(!s.some((r)=>dn(r,i)))s.push(i);return s}if(n.every((s)=>typeof s==="string")&&e.every((s)=>typeof s==="string")){let s=[...n];for(let i of e)if(!s.includes(i))s.push(i);return s}return n}if(!ae(n)||!ae(e))return n;let t={...e};for(let s in n)if(Object.prototype.hasOwnProperty.call(n,s)){let i=n[s];if(i===null||i===void 0)continue;else if(ae(i)&&ae(t[s]))t[s]=sn(t[s],i);else if(Array.isArray(i)&&Array.isArray(t[s]))if(i.length>0&&t[s].length>0&&ae(i[0])&&ae(t[s][0])){let r=[...i];for(let o of t[s])if(ae(o)&&"name"in o){if(!r.find((a)=>ae(a)&&("name"in a)&&a.name===o.name))r.push(o)}else if(ae(o)&&"path"in o){if(!r.find((a)=>ae(a)&&("path"in a)&&a.path===o.path))r.push(o)}else if(!r.some((l)=>dn(l,o)))r.push(o);t[s]=r}else if(i.every((r)=>typeof r==="string")&&t[s].every((r)=>typeof r==="string")){let r=[...i];for(let o of t[s])if(!r.includes(o))r.push(o);t[s]=r}else t[s]=i;else t[s]=i}return t}function Ii(e,n,t="replace"){if(n===null||n===void 0)return e;if(Array.isArray(n))return t==="replace"?n:sn(e,n);if(Array.isArray(e))return t==="replace"?n:sn(e,n);if(!ae(n)||!ae(e))return n;let s={...e};for(let i of Object.keys(n)){if(!Object.prototype.hasOwnProperty.call(n,i))continue;let r=n[i],o=s[i];if(r===null||r===void 0)continue;if(Array.isArray(r)||Array.isArray(o))if(t==="replace")s[i]=r;else s[i]=sn(o,r);else if(ae(r)&&ae(o))s[i]=Ii(o,r,t);else s[i]=r}return s}function dn(e,n){if(e===n)return!0;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(!dn(e[t],n[t]))return!1;return!0}if(ae(e)&&ae(n)){let t=Object.keys(e),s=Object.keys(n);if(t.length!==s.length)return!1;for(let i of t){if(!Object.prototype.hasOwnProperty.call(n,i))return!1;if(!dn(e[i],n[i]))return!1}return!0}return!1}function ae(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function Qt(e,n,t="replace"){if(!ao(e))return null;try{let s=await import(e),i=s.default||s;if(typeof i!=="object"||i===null||Array.isArray(i))return null;try{return Ii(n,i,t)}catch{return null}}catch{return null}}function Zm(e,n,t=!1){if(!e)return n;let s=e.toUpperCase().replace(/-/g,"_"),i={...n};function r(o,l=[]){let a={...o};for(let[c,u]of Object.entries(o)){let f=[...l,c],m=(p)=>p.replace(/([A-Z])/g,"_$1").toUpperCase(),h=`${s}_${f.map(m).join("_")}`,d=`${s}_${f.map((p)=>p.toUpperCase()).join("_")}`;if(t)ve.info(`Checking environment variable ${h} for config ${e}.${f.join(".")}`);if(typeof u==="object"&&u!==null&&!Array.isArray(u))a[c]=r(u,f);else{let p=Lt.env[h]||Lt.env[d];if(p!==void 0){if(t)ve.info(`Using environment variable ${p?h:d} for config ${e}.${f.join(".")}`);if(typeof u==="number")a[c]=Number(p);else if(typeof u==="boolean")a[c]=p.toLowerCase()==="true";else if(Array.isArray(u))try{let g=JSON.parse(p);if(Array.isArray(g))a[c]=g;else a[c]=p.split(",").map((y)=>y.trim())}catch{a[c]=p.split(",").map((g)=>g.trim())}else a[c]=p}}}return a}return r(i)}async function Gm({name:e="",alias:n,cwd:t,configDir:s,defaultConfig:i,verbose:r=!1,checkEnv:o=!0,arrayStrategy:l="replace"}){let a=o&&typeof i==="object"&&i!==null&&!Array.isArray(i)?Zm(e,i,r):i,c=t||Lt.cwd(),u=[".ts",".js",".mjs",".cjs",".json"];if(r)ve.info(`Loading configuration for "${e}"${n?` (alias: "${n}")`:""} from ${c}`);let f=[e,`.${e}`].filter(Boolean),m=[`${e}.config`,`.${e}.config`].filter(Boolean),h=n?[n,`.${n}`]:[],d=n?[`${n}.config`,`.${n}.config`]:[],p=Array.from(new Set([c,Me(c,"config"),Me(c,".config"),s?Me(c,s):void 0].filter(Boolean)));for(let g of p){if(r)ve.info(`Searching for configuration in: ${g}`);let x=[Me(c,"config"),Me(c,".config")].concat(s?[Me(c,s)]:[]).includes(g)?[...f,...m,...h,...d]:[...m,...f,...d,...h];for(let k of x)for(let v of u){let w=Me(g,`${k}${v}`),M=await Qt(w,a,l);if(M!==null){if(r)ve.success(`Configuration loaded from: ${w}`);return M}}}if(e){let g=Me(Zs(),".config",e),y=["config",`${e}.config`];if(n)y.push(`${n}.config`);if(r)ve.info(`Checking user config directory: ${g}`);for(let x of y)for(let k of u){let v=Me(g,`${x}${k}`),w=await Qt(v,a,l);if(w!==null){if(r)ve.success(`Configuration loaded from user config directory: ${v}`);return w}}}if(e){let g=Me(Zs(),".config"),y=[`.${e}.config`];if(n)y.push(`.${n}.config`);if(r)ve.info(`Checking user config directory for dotfile configs: ${g}`);for(let x of y)for(let k of u){let v=Me(g,`${x}${k}`),w=await Qt(v,a,l);if(w!==null){if(r)ve.success(`Configuration loaded from user config directory dotfile: ${v}`);return w}}}if(e){let g=Zs(),y=[`.${e}.config`,`.${e}`];if(n)y.push(`.${n}.config`),y.push(`.${n}`);if(r)ve.info(`Checking user home directory for dotfile configs: ${g}`);for(let x of y)for(let k of u){let v=Me(g,`${x}${k}`),w=await Qt(v,a,l);if(w!==null){if(r)ve.success(`Configuration loaded from user home directory: ${v}`);return w}}}try{let g=Me(c,"package.json");if(ao(g)){let y=await import(g),x=y[e];if(!x&&n){if(x=y[n],x&&r)ve.success(`Using alias "${n}" configuration from package.json`)}if(x&&typeof x==="object"&&!Array.isArray(x))try{if(r)ve.success(`Configuration loaded from package.json: ${x===y[e]?e:n}`);return Ii(a,x,l)}catch(k){if(r)ve.warn("Failed to merge package.json config:",k)}}}catch(g){if(r)ve.warn("Failed to load package.json:",g)}if(r)ve.info(`No configuration found for "${e}"${n?` or alias "${n}"`:""}, using default configuration with environment variables`);return a}function Jm(e,n={}){let t=cn.cwd();while(t.includes("storage"))t=Ir(t,"..");let s=Ir(t,e||"");if(n?.relative)return ym(cn.cwd(),s);return s}async function Ym(){try{let e=await Gm({name:"clarity",alias:"logging",defaultConfig:ln,cwd:cn.cwd()});return{...ln,...e||{}}}catch{return ln}}function ye(){if(Ke.env.NODE_ENV==="test"||Ke.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Xm(){if(Ke.env.NODE_ENV==="test"||Ke.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof Ke<"u"){let e=Ke.type;if(e==="renderer"||e==="worker")return!1;return!!(Ke.versions&&(Ke.versions.node||Ke.versions.bun))}return!1}class fo{async format(e){let n=await Xm(),t=await this.getMetadata(n);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:t})}async getMetadata(e){if(e){let{hostname:n}=await import("os");return{pid:gt.pid,hostname:n(),environment:gt.env.NODE_ENV||"development",platform:gt.platform,version:gt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:gt.env.NODE_ENV||gt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class pn{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,n={}){this.name=e,this.config={...gi},this.options=this.normalizeOptions(n),this.formatter=this.options.formatter||new fo,this.enabled=n.enabled??!0,this.fancy=n.fancy??!0,this.tagFormat=n.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=n.timestampPosition??"right",this.environment=n.environment??ie.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(n);let t={...n},s=n.timestamp!==void 0;if(s)delete t.timestamp;if(this.config={...this.config,...t,timestamp:s||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),r=this.generateKey();this.currentKeyId=i,this.keys.set(i,r),this.encryptionKeys.set(i,{key:r,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let n={debug:0,info:1,success:2,warning:3,error:4},t=this.fingersCrossedConfig.activationLevel??"error";return n[e]>=n[t]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...an,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...an};return{...an,...e.fingersCrossed}}normalizeOptions(e){let n={format:"json",level:"info",logDirectory:gi.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},t={...n,...Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))};if(!t.level||!["debug","info","success","warning","error"].includes(t.level))t.level=n.level;return t}shouldWriteToFile(){return!ye()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let i,r=0,o=3,l=1000;while(r<o)try{try{try{await Lm(this.config.logDirectory,Fr.F_OK|Fr.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await Tm(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 a=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:Ue.from(e);try{if(!Zt(this.currentLogFile))await ti(this.currentLogFile,"",{mode:420});if(i=Dr(this.currentLogFile,"a",420),Em(i,a,{flag:"a"}),_r(i),i!==void 0)ei(i),i=void 0;if((await dt(this.currentLogFile)).size===0){if(await ti(this.currentLogFile,a,{flag:"w",mode:420}),(await dt(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let u=c;if(u.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(u.code)){if(r<o-1){let f=typeof u.message==="string"?u.message:"Unknown error";console.error(`Network error during write attempt ${r+1}/${o}:`,f);let m=l*2**r;await new Promise((h)=>setTimeout(h,m)),r++;continue}}if(u?.code&&["ENOSPC","EDQUOT"].includes(u.code))throw Error(`Disk quota exceeded or no space left on device: ${u.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",u),u}finally{if(i!==void 0)try{ei(i)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(a){if(r===o-1){let u=a,f=typeof u.message==="string"?u.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",f),a}r++;let c=l*2**(r-1);await new Promise((u)=>setTimeout(u,c))}})();this.pendingOperations.push(t);let s=this.pendingOperations.length-1;try{await t}catch(i){throw console.error("Debug: [writeToFile] Error in operation:",i),i}finally{this.pendingOperations.splice(s,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 pt(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 pt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return pt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(ye())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,n;switch(e.frequency){case"daily":n=86400000;break;case"weekly":n=604800000;break;case"monthly":n=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},n)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let n=this.config.rotation.keyRotation;if(!n?.enabled)return;let t=typeof n.interval==="number"?n.interval:60,s=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((i)=>{console.error("Error rotating keys:",i)})},s)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let n=this.config.rotation.keyRotation,t=this.generateKeyId(),s=this.generateKey();this.currentKeyId=t,this.keys.set(t,s),this.encryptionKeys.set(t,{key:s,createdAt:new Date});let i=Array.from(this.encryptionKeys.entries()).sort(([,l],[,a])=>a.createdAt.getTime()-l.createdAt.getTime()),r=typeof n.maxKeys==="number"?n.maxKeys:1,o=Math.max(1,r);if(i.length>o)for(let[l]of i.slice(o))this.encryptionKeys.delete(l),this.keys.delete(l)}generateKeyId(){return Qs(16).toString("hex")}generateKey(){return Qs(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:n}=this.getCurrentKey(),t=Qs(16),s=Mm("aes-256-gcm",n,t),i=Ue.isBuffer(e)?e:Ue.from(e,"utf8"),r=s.update(i),o=s.final(),l=r.length+o.length,a=s.getAuthTag(),c=Ue.allocUnsafe(16+l+16);return t.copy(c,0),r.copy(c,16),o.copy(c,16+r.length),a.copy(c,16+l),{encrypted:c,iv:t}}async compressData(e){return new Promise((n,t)=>{let s=Wr(),i=[];s.on("data",(r)=>i.push(r)),s.on("end",()=>n(Ue.from(Ue.concat(i)))),s.on("error",t),s.write(e),s.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 n=this.config.rotation.encrypt;return{...e,...n}}return e}async rotateLog(){if(ye())return;if(!this.shouldWriteToFile())return;let e=await dt(this.currentLogFile).catch(()=>null);if(!e)return;let n=this.config.rotation;if(typeof n==="boolean")return;if(n.maxSize&&e.size>=n.maxSize){let t=this.currentLogFile,s=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await Gt(this.config.logDirectory),r=i.filter((a)=>a.startsWith(this.name)&&/\.log\.\d+$/.test(a)).sort((a,c)=>{let u=Number.parseInt(a.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(c.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),o=r.length>0?Number.parseInt(r[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,l=`${t}.${o}`;if(await dt(t).catch(()=>null))try{if(await Nr(t,l),n.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await Jt(l)}catch(a){console.error("Error compressing rotated file:",a)}if(r.length===0&&!i.some((a)=>a.endsWith(".log.1")))try{let a=`${t}.1`;await ti(a,"")}catch(a){console.error("Error creating backup file:",a)}}catch(a){console.error(`Error during rotation: ${a instanceof Error?a.message:String(a)}`)}}else{let i=new Date().toISOString().replace(/[:.]/g,"-"),r=t.replace(/\.log$/,`-${i}.log`);if(await dt(t).catch(()=>null))await Nr(t,r)}if(this.currentLogFile=s,n.maxFiles){let r=(await Gt(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,l)=>l.localeCompare(o));for(let o of r.slice(n.maxFiles))await Jt(pt(this.config.logDirectory,o))}}}async compressLogFile(e,n){let t=Or(e),s=Sm(n),i=Wr();await _m(t,i,s)}async handleFingersCrossedBuffer(e,n){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let t of this.logBuffer){let s=await this.formatter.format(t);if(this.shouldWriteToFile())await this.writeToFile(s);console.log(s)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(n);console.log(n)}}shouldLog(e){if(!this.enabled)return!1;let n={debug:0,info:1,success:2,warning:3,error:4};return n[e]>=n[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((n)=>{console.error("Error in pending write operation:",n)});return Promise.resolve()})),Zt(this.currentLogFile))try{let e=Dr(this.currentLogFile,"r+");_r(e),ei(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(!ye()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let n=(await Gt(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of n)try{await Jt(pt(this.config.logDirectory,t))}catch(s){console.error(`Failed to delete temp file ${t}:`,s)}}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()?oe.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||ye())return!1;let e=typeof ie.env.NO_COLOR<"u",n=ie.env.FORCE_COLOR==="0";if(e||n)return!1;return!!(typeof ie.stderr<"u"&&ie.stderr.isTTY||typeof ie.stdout<"u"&&ie.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:n,icon:t="",tag:s="",message:i,level:r,showTimestamp:o=!0}=e,l=(h)=>h.replace(this.ANSI_PATTERN,"");if(!this.fancy){let h=[];if(o)h.push(n);if(r==="warning")h.push("WARN");else if(r==="error")h.push("ERROR");else if(t)h.push(t.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(s)h.push(s.replace(/[[\]]/g,""));return h.push(i),h.join(" ")}let a=ie.stdout.columns||120,c="";if(r==="warning"||r==="error")c=`${t} ${i}`;else if(r==="info"||r==="success")c=`${t} ${s} ${i}`;else c=`${t} ${s} ${oe.cyan(i)}`;if(!o)return c.trim();let u=l(c).trim().length,f=l(n).length,m=Math.max(1,a-2-u-f);return`${c.trim()}${" ".repeat(m)}${n}`}formatMessage(e,n){if(n.length===1&&Array.isArray(n[0]))return e.replace(/\{(\d+)\}/g,(r,o)=>{let l=Number.parseInt(o,10);return l<n[0].length?String(n[0][l]):r});let t=/%([sdijfo%])/g,s=0,i=e.replace(t,(r,o)=>{if(o==="%")return"%";if(s>=n.length)return r;let l=n[s++];switch(o){case"s":return String(l);case"d":case"i":return Number(l).toString();case"j":case"o":return JSON.stringify(l,null,2);default:return r}});if(s<n.length)i+=` ${n.slice(s).map((r)=>typeof r==="object"?JSON.stringify(r,null,2):String(r)).join(" ")}`;return i}formatMarkdown(e){if(!e)return e;let n=e;return n=n.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(t,s,i)=>{let r=oe.underline(oe.blue(s)),o=this.toAbsoluteFilePath(i);if(o&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let l=`file://${encodeURI(o)}`,a="\x1B]8;;",c="\x1B\\";return`\x1B]8;;${l}\x1B\\${r}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${i}\x1B\\${r}\x1B]8;;\x1B\\`;return r}),n=n.replace(/`([^`]+)`/g,(t,s)=>oe.bgGray(s)),n=n.replace(/\*\*([^*]+)\*\*/g,(t,s)=>oe.bold(s)),n=n.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(t,s)=>oe.italic(s)),n=n.replace(/(?<!_)_([^_]+)_(?!_)/g,(t,s)=>oe.italic(s)),n=n.replace(/~([^~]+)~/g,(t,s)=>oe.strikethrough(s)),n}supportsHyperlinks(){if(ye())return!1;let e=ie.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 n=e.VTE_VERSION?Number.parseInt(e.VTE_VERSION,10):0;if(!Number.isNaN(n)&&n>=5000)return!0;return!1}toAbsoluteFilePath(e){try{let n=e;if(n.startsWith("file://"))n=n.replace(/^file:\/\//,"");if(n.startsWith("~")){let t=ie.env.HOME||"";if(t)n=n.replace(/^~(?=$|\/)/,t)}if(Am(n)||n.startsWith("./")||n.startsWith("../"))n=Om(n);else return null;return Zt(n)?n:null}catch{return null}}buildOutputTexts(e){let n=this.shouldStyleConsole()?this.formatMarkdown(e):e,t=e.replace(this.ANSI_PATTERN,"");return{consoleText:n,fileText:t}}async log(e,n,...t){let s=new Date,i=this.formatConsoleTimestamp(s),r=this.formatFileTimestamp(s),o,l;if(n instanceof Error)o=n.message,l=n.stack;else o=this.formatMessage(n,t);let{consoleText:a,fileText:c}=this.buildOutputTexts(o);if(this.shouldStyleConsole()){let f=this.options.showIcons===!1?"":ko[e],m=this.options.showTags!==!1&&this.name?oe.gray(this.formatTag(this.name)):"",h;switch(e){case"debug":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:oe.gray(a),level:e}),console.error(h);break;case"info":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:a,level:e}),console.warn(h);break;case"success":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:oe.green(a),level:e}),console.error(h);break;case"warning":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:a,level:e}),console.warn(h);break;case"error":if(h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:a,level:e}),console.error(h),l){let d=l.split(`
11
+ `);for(let p of d)if(p.trim()&&!p.includes(o))console.error(this.formatConsoleMessage({timestamp:i,message:oe.gray(` ${p}`),level:e,showTimestamp:!1}))}break}}else if(!ye()){if(console.error(`${r} ${this.environment}.${e.toUpperCase()}: ${o}`),l)console.error(l)}if(!this.shouldLog(e))return;let u=`${r} ${this.environment}.${e.toUpperCase()}: ${c}
12
+ `;if(l)u+=`${l}
13
+ `;if(u=u.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(u)}progress(e,n=""){let t={update:(l,a)=>{},finish:(l)=>{},interrupt:(l,a)=>{}};if(!this.enabled)return t;let s=30;if(this.activeProgressBar={total:Math.max(1,e||1),current:0,message:n||"",barLength:s,lastRenderedLine:""},this.shouldStyleConsole()&&!ye()&&ie.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(l,a)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,l),this.activeProgressBar.total),a!==void 0)this.activeProgressBar.message=a;if(this.shouldStyleConsole()&&!ye()&&ie.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(l)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,l)},interrupt:(l,a="info")=>{if(!ye()&&ie.stdout.isTTY)ie.stdout.write(`
14
+ `);if(this[a==="warning"?"warn":a](l),this.activeProgressBar&&this.shouldStyleConsole()&&!ye()&&ie.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let n=performance.now();if(this.shouldStyleConsole()){let t=this.options.showTags!==!1&&this.name?oe.gray(this.formatTag(this.name)):"",s=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:s,icon:this.options.showIcons===!1?"":oe.blue("\u25D0"),tag:t,message:`${oe.cyan(e)}...`}))}return async(t)=>{if(!this.enabled)return;let s=performance.now(),i=Math.round(s-n),r=`${e} completed in ${i}ms`,o=new Date,l=this.formatConsoleTimestamp(o),c=`${this.formatFileTimestamp(o)} ${this.environment}.INFO: ${r}`;if(t)c+=` ${JSON.stringify(t)}`;if(c+=`
15
+ `,c=c.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let u=this.options.showTags!==!1&&this.name?oe.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:this.options.showIcons===!1?"":oe.green("\u2713"),tag:u,message:`${r}${t?` ${JSON.stringify(t)}`:""}`}))}else if(!ye())console.error(c.trim());if(this.shouldWriteToFile())await this.writeToFile(c)}}async debug(e,...n){await this.log("debug",e,...n)}async info(e,...n){await this.log("info",e,...n)}async success(e,...n){await this.log("success",e,...n)}async warn(e,...n){await this.log("warning",e,...n)}async error(e,...n){await this.log("error",e,...n)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:n}=e;return!!n}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let n=`${this.name}:${e}`,t=new pn(n,{...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(t),t}createReadStream(){if(ye())throw Error("createReadStream is not supported in browser environments");if(!Zt(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return Or(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let n=this.config.rotation;if(!n.encrypt||typeof n.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let t=this.keys.get(this.currentKeyId);try{let s=Ue.isBuffer(e)?e:Ue.from(e,"base64"),i=s.subarray(0,16),r=s.subarray(s.length-16),o=s.subarray(16,s.length-16),l=Cm("aes-256-gcm",t,i);l.setAuthTag(r);let a=l.update(o),c=l.final(),u=a.length+c.length,f=Ue.allocUnsafe(u);return a.copy(f,0),c.copy(f,a.length),f.toString("utf8")}catch(s){throw Error(`Decryption failed: ${s instanceof Error?s.message:String(s)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return ye()}isServerMode(){return!ye()}setTestEncryptionKey(e,n){this.currentKeyId=e,this.keys.set(e,n)}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 n=new Date,t=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n),{consoleText:i,fileText:r}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let l=i.split(`
16
+ `),a=Math.max(...l.map((m)=>m.length))+2,c=`\u250C${"\u2500".repeat(a)}\u2510`,u=`\u2514${"\u2500".repeat(a)}\u2518`,f=l.map((m)=>this.formatConsoleMessage({timestamp:t,message:oe.cyan(m),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:t,message:oe.cyan(c),showTimestamp:!1})),f.forEach((m)=>console.error(m)),console.error(this.formatConsoleMessage({timestamp:t,message:oe.cyan(u),showTimestamp:!1}))}else if(!ye())console.error(`${s} ${this.environment}.INFO: [BOX] ${r}`);let o=`${s} ${this.environment}.INFO: [BOX] ${r}
17
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(o)}async prompt(e){if(ye())return Promise.resolve(!0);return new Promise((n)=>{console.error(`${oe.cyan("?")} ${e} (y/n) `);let t=(s)=>{let i=s.toString().trim().toLowerCase();ie.stdin.removeListener("data",t);try{if(typeof ie.stdin.setRawMode==="function")ie.stdin.setRawMode(!1)}catch{}ie.stdin.pause(),console.error(""),n(i==="y"||i==="yes")};try{if(typeof ie.stdin.setRawMode==="function")ie.stdin.setRawMode(!0)}catch{}ie.stdin.resume(),ie.stdin.once("data",t)})}setFancy(e){this.fancy=e}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(e,...n){if(!this.enabled)return;let t=e;if(n&&n.length>0){let a=/%([sdijfo%])/g,c=0;if(t=e.replace(a,(u,f)=>{if(f==="%")return"%";if(c>=n.length)return u;let m=n[c++];switch(f){case"s":return String(m);case"d":case"i":return Number(m).toString();case"j":case"o":return JSON.stringify(m,null,2);default:return u}}),c<n.length)t+=` ${n.slice(c).map((u)=>typeof u==="object"?JSON.stringify(u,null,2):String(u)).join(" ")}`}let{consoleText:s,fileText:i}=this.buildOutputTexts(t);if(this.shouldStyleConsole()){let a=this.options.showTags!==!1&&this.name?oe.gray(this.formatTag(this.name)):"",c=this.options.showIcons===!1?"":`${oe.blue("\u25D0")} `;console.error(`${c}${a} ${oe.cyan(s)}`)}let l=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${i}
18
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(l)}renderProgressBar(e,n=!1){if(!this.enabled||!this.shouldStyleConsole()||!ie.stdout.isTTY)return;let t=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),s=Math.round(e.barLength*t/100),i=e.barLength-s,r=oe.green("\u2501".repeat(s)),o=oe.gray("\u2501".repeat(i)),l=`[${r}${o}]`,a=`${t}%`.padStart(4),c=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":n||t===100?oe.green("\u2713"):oe.blue("\u25B6"),f=this.options.showTags!==!1&&this.name?` ${oe.gray(this.formatTag(this.name))}`:"",m=`\r${u}${f} ${l} ${a}${c}`,h=ie.stdout.columns||80,d=" ".repeat(Math.max(0,h-m.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${m}${d}`,ie.stdout.write(e.lastRenderedLine),n)ie.stdout.write(`
19
+ `)}finishProgressBar(e,n){if(!this.enabled||!this.fancy||ye()||!ie.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(n)e.message=n;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(ye()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let n=await Gt(this.config.logDirectory),t=[];for(let s of n){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(s):s.startsWith(this.name))||!s.endsWith(".log"))continue;let r=pt(this.config.logDirectory,s);if(e.before)try{if((await dt(r)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${r}:`,o);continue}t.push(r)}if(t.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${t.length} log file(s)...`);for(let s of t)try{await Jt(s),console.warn(`Deleted log file: ${s}`)}catch(i){console.error(`Failed to delete log file ${s}:`,i)}console.warn("Log clearing process finished.")}catch(n){console.error("Error during log clearing process:",n)}}}async function mo(e,n={}){let{maxRetries:t=3,retryDelay:s=1000,isRetryable:i=()=>!0,fallback:r}=n,o=Error("Unknown error occurred");for(let l=0;l<=t;l++)try{return await e()}catch(a){if(o=a instanceof Error?a:Error(String(a)),l===t||!i(o))break;if(s>0)await new Promise((c)=>setTimeout(c,s))}if(r!==void 0)return r;throw o instanceof Error?o:Error(`Unknown error: ${String(o)}`)}function ho(e){return e instanceof Ee}function Qm(e){return e instanceof gn}function eh(e){if(ho(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 wn{defaultParsers;constructor(){this.defaultParsers=[{name:"boolean",canParse:(e,n)=>n==="boolean"||["true","false","1","0","yes","no"].includes(e.toLowerCase()),parse:(e)=>{let n=e.toLowerCase();return["true","1","yes"].includes(n)}},{name:"number",canParse:(e,n)=>n==="number"||!Number.isNaN(Number(e))&&!Number.isNaN(Number.parseFloat(e)),parse:(e)=>{let n=Number(e);if(Number.isNaN(n))throw TypeError(`Cannot parse "${e}" as number`);return n}},{name:"array",canParse:(e,n)=>n==="array"||e.startsWith("[")||e.includes(","),parse:(e)=>{try{let n=JSON.parse(e);if(Array.isArray(n))return n}catch{}return e.split(",").map((n)=>n.trim())}},{name:"json",canParse:(e,n)=>n==="object"||(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")),parse:(e)=>{try{return JSON.parse(e)}catch(n){throw Error(`Cannot parse "${e}" as JSON: ${n}`)}}}]}async applyEnvironmentVariables(e,n,t={}){let{prefix:s,useCamelCase:i=!0,useBackwardCompatibility:r=!0,customParsers:o={},verbose:l=!1,trackPerformance:a=!0}=t,c=async()=>{if(!e)return{config:n,source:{type:"environment",priority:50,timestamp:new Date}};let u=s||this.generateEnvPrefix(e),f={...n};return this.processObject(f,[],u,{useCamelCase:i,useBackwardCompatibility:r,customParsers:o,verbose:l,configName:e}),{config:f,source:{type:"environment",priority:50,timestamp:new Date}}};if(a)return Ot.track("applyEnvironmentVariables",c,{configName:e});return c()}generateEnvPrefix(e){return e.toUpperCase().replace(/-/g,"_")}formatEnvKey(e,n){if(!n)return e.toUpperCase();return e.replace(/([A-Z])/g,"_$1").toUpperCase()}processObject(e,n,t,s){for(let[i,r]of Object.entries(e)){let o=[...n,i],l=o.map((u)=>this.formatEnvKey(u,s.useCamelCase)),a=`${t}_${l.join("_")}`,c=s.useBackwardCompatibility?`${t}_${o.map((u)=>u.toUpperCase()).join("_")}`:null;if(s.verbose);if(typeof r==="object"&&r!==null&&!Array.isArray(r))this.processObject(r,o,t,s);else{let u=Yt.env[a]||(c?Yt.env[c]:void 0);if(u!==void 0){if(s.verbose){let f=Yt.env[a]?a:c}try{e[i]=this.parseEnvironmentValue(u,typeof r,a,s.customParsers,s.configName)}catch(f){if(f instanceof yn)throw f;throw Je.envVar(a,u,typeof r,s.configName)}}}}}parseEnvironmentValue(e,n,t,s,i){for(let[r,o]of Object.entries(s))try{return o(e)}catch{continue}for(let r of this.defaultParsers)if(r.canParse(e,n))try{return r.parse(e)}catch{throw Je.envVar(t,e,`${n} (via ${r.name} parser)`,i)}return e}getEnvironmentVariables(e){let n={},t=e.toUpperCase();for(let[s,i]of Object.entries(Yt.env))if(s.startsWith(t)&&i!==void 0)n[s]=i;return n}validateEnvironmentVariable(e,n,t){let s=[];if(!/^[A-Z_][A-Z0-9_]*$/.test(e))s.push(`Environment variable key "${e}" should only contain uppercase letters, numbers, and underscores`);if(t)try{this.parseEnvironmentValue(e,n,t,{})}catch(i){s.push(`Cannot parse value "${n}" as ${t}: ${i}`)}return{isValid:s.length===0,errors:s}}generateEnvVarDocs(e,n,t={}){let{prefix:s,format:i="text"}=t,r=s||this.generateEnvPrefix(e),o=[];switch(this.extractEnvVarInfo(n,[],r,o),i){case"markdown":return this.formatAsMarkdown(o,e);case"json":return JSON.stringify(o,null,2);default:return this.formatAsText(o,e)}}extractEnvVarInfo(e,n,t,s){for(let[i,r]of Object.entries(e)){let o=[...n,i],l=`${t}_${o.map((a)=>this.formatEnvKey(a,!0)).join("_")}`;if(typeof r==="object"&&r!==null&&!Array.isArray(r))this.extractEnvVarInfo(r,o,t,s);else s.push({key:l,type:Array.isArray(r)?"array":typeof r,description:`Configuration for ${o.join(".")}`,example:this.generateExample(r)})}}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,n){let t=`Environment Variables for ${n}:
20
+
21
+ `;for(let s of e)t+=`${s.key}
22
+ `,t+=` Type: ${s.type}
23
+ `,t+=` Description: ${s.description}
24
+ `,t+=` Example: ${s.example}
25
+
26
+ `;return t}formatAsMarkdown(e,n){let t=`# Environment Variables for ${n}
27
+
28
+ `;t+=`| Variable | Type | Description | Example |
29
+ `,t+=`|----------|------|-------------|----------|
30
+ `;for(let s of e)t+=`| \`${s.key}\` | ${s.type} | ${s.description} | \`${s.example}\` |
31
+ `;return t}}function th(e,n){let t=xo("process");if(typeof t>"u"||!t.env)return n;let s=t.env[e];return s!==void 0?s:n}function po(e,n,t={}){return go(e,n,t,new WeakMap)}function go(e,n,t,s){let{arrayMergeMode:i="replace",skipNullish:r=!1,customMerger:o}=t;if(n===null||n===void 0)return r?e:n;if(o){let l=o(e,n);if(l!==void 0)return l}if(Array.isArray(n)||Array.isArray(e))return yo(e,n,i,s);if(!Ae(n)||!Ae(e))return n;return rh(e,n,t,s)}function yo(e,n,t,s){if(Array.isArray(n)&&!Array.isArray(e))return n;if(Array.isArray(e)&&!Array.isArray(n))return n;if(Array.isArray(n)&&Array.isArray(e))switch(t){case"replace":return n;case"concat":return nh(e,n);case"smart":return sh(e,n,s);default:return n}return n}function nh(e,n){let t=[...n];for(let s of e)if(!t.some((i)=>di(i,s)))t.push(s);return t}function sh(e,n,t){if(n.length===0)return e;if(e.length===0)return n;if(Ae(n[0])&&Ae(e[0]))return ih(e,n,t);if(n.every((s)=>typeof s==="string")&&e.every((s)=>typeof s==="string")){let s=[...n];for(let i of e)if(!s.includes(i))s.push(i);return s}return n}function ih(e,n,t){let s=[...n];for(let i of e){if(!Ae(i)){s.push(i);continue}let r=["id","name","key","path","type"],o=!1;for(let l of r)if(l in i){if(s.find((c)=>Ae(c)&&(l in c)&&c[l]===i[l])){o=!0;break}}if(!o)s.push(i)}return s}function rh(e,n,t,s){let i=n;if(Ae(i)&&s.has(i))return s.get(i);let r={...e};if(Ae(i))s.set(i,r);for(let o in i){if(!Object.prototype.hasOwnProperty.call(i,o))continue;let l=i[o],a=r[o];if(t.skipNullish&&(l===null||l===void 0))continue;if(l===null||l===void 0){r[o]=l;continue}if(Ae(l)&&Ae(a))r[o]=go(a,l,t,s);else if(Array.isArray(l)||Array.isArray(a))r[o]=yo(a,l,t.arrayMergeMode||"smart",s);else r[o]=l}return r}function Mi(e,n,t="replace"){return po(e,n,{arrayMergeMode:t==="replace"?"replace":"smart",skipNullish:!0})}function di(e,n){if(e===n)return!0;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(!di(e[t],n[t]))return!1;return!0}if(Ae(e)&&Ae(n)){let t=Object.keys(e),s=Object.keys(n);if(t.length!==s.length)return!1;for(let i of t){if(!Object.prototype.hasOwnProperty.call(n,i))return!1;if(!di(e[i],n[i]))return!1}return!0}return!1}function Ae(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class Rn{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(e,n,t={}){let{arrayStrategy:s="replace",useCache:i=!0,cacheTtl:r,trackPerformance:o=!0,verbose:l=!1}=t;if(i){let c=wt.getWithFileCheck("file",e);if(c){if(l)console.log(`Configuration loaded from cache: ${e}`);return c}}let a=async()=>{if(!Xt(e))return null;try{let c=`?t=${Date.now()}`,u=await import(e+c),f=u.default||u,m="default"in u,h=Object.keys(u).length>0;if(!m&&!h)throw new Tt(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof f!=="object"||f===null||Array.isArray(f))throw new Tt(e,Error("Configuration must export a valid object"),"unknown");let g={config:Mi(n,f,s),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(i)wt.setWithFileCheck("file",g,e,r);return g}catch(c){throw c instanceof Error?Je.configLoad(e,c):Je.configLoad(e,Error(String(c)))}};if(o)return Ot.track("loadFromPath",a,{path:e});return a()}async tryLoadFromPaths(e,n,t={}){for(let s of e)try{let i=await this.loadFromPath(s,n,t);if(i)return i}catch(i){if(i instanceof Error&&i.name==="ConfigLoadError")throw i;if(t.verbose)console.warn(`Failed to load config from ${s}:`,i)}return null}generateConfigPaths(e,n,t){let s=this.generateNamePatterns(e,t),i=[];for(let r of s)for(let o of this.extensions)i.push(ni(n,`${r}${o}`));return i}generateNamePatterns(e,n){let t=[];if(t.push("config",".config"),e)t.push(e,`.${e}.config`,`${e}.config`,`.${e}`);if(n){if(t.push(n,`.${n}.config`,`${n}.config`,`.${n}`),e)t.push(`${e}.${n}.config`,`.${e}.${n}.config`)}return t.filter(Boolean)}checkFileAccess(e){return mo(async()=>Xt(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,n,t){let s=[];if(!Xt(e))return s;if(n||t){let i=this.generateNamePatterns(n||"",t);for(let r of i)for(let o of this.extensions){let l=ni(e,`${r}${o}`);if(await this.checkFileAccess(l))s.push(l)}}else try{let{readdirSync:i}=await import("fs"),r=i(e);for(let o of r)if(this.looksLikeConfigFile(o)){let l=ni(e,o);if(await this.checkFileAccess(l))s.push(l)}}catch{return[]}return s}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 n=[];try{if(!Xt(e))return n.push("Configuration file does not exist"),n;let t=await import(e),s=t.default||t;if(s===void 0)n.push("Configuration file must export a default value or named exports");else if(typeof s!=="object"||s===null)n.push("Configuration must be an object");else if(Array.isArray(s))n.push("Configuration cannot be an array at the root level");if(e.endsWith(".json"))try{let{readFileSync:i}=await import("fs"),r=i(e,"utf8");JSON.parse(r)}catch(i){n.push(`Invalid JSON syntax: ${i}`)}}catch(t){n.push(`Failed to load configuration file: ${t}`)}return n}async getFileModificationTime(e){try{let{statSync:n}=await import("fs");return n(e).mtime}catch{return null}}async preloadConfigurations(e,n={}){let t=new Map;return await Promise.allSettled(e.map(async(s)=>{try{let i=await this.loadFromPath(s,{},n);if(i)t.set(s,i.config)}catch(i){if(n.verbose)console.warn(`Failed to preload ${s}:`,i)}})),t}}class Ci{async validateConfiguration(e,n,t={}){let{stopOnFirstError:s=!1,validateRequired:i=!0,validateTypes:r=!0,customRules:o=[],trackPerformance:l=!0,verbose:a=!1}=t,c=async()=>{let u=[],f=[],m={stopOnFirstError:s,validateRequired:i,validateTypes:r,customRules:o,trackPerformance:l,verbose:a};try{if(typeof n==="string")return await this.validateWithSchemaFile(e,n,m);else if(Array.isArray(n))return this.validateWithRules(e,[...n,...o],m);else return this.validateWithJSONSchema(e,n,m)}catch(h){return u.push({path:"",message:`Validation failed: ${h}`,rule:"system"}),{isValid:!1,errors:u,warnings:f}}};if(l)return await Ot.track("validateConfiguration",c);return c()}async validateWithSchemaFile(e,n,t){try{if(!Dm(n))throw new At(n,[{path:"",message:"Schema file does not exist"}]);let s=await import(n),i=s.default||s;if(Array.isArray(i))return this.validateWithRules(e,i,t);else return this.validateWithJSONSchema(e,i,t)}catch(s){throw new At(n,[{path:"",message:`Failed to load schema: ${s}`}])}}validateWithJSONSchema(e,n,t){let s=[],i=[];return this.validateObjectAgainstSchema(e,n,"",s,i,t),{isValid:s.length===0,errors:s,warnings:i}}validateObjectAgainstSchema(e,n,t,s,i,r){if(r.validateTypes&&n.type){let o=Array.isArray(e)?"array":typeof e,l=Array.isArray(n.type)?n.type:[n.type];if(!l.includes(o)){if(s.push({path:t,message:`Expected type ${l.join(" or ")}, got ${o}`,expected:l.join(" or "),actual:o,rule:"type"}),r.stopOnFirstError)return}}if(n.enum&&!n.enum.includes(e)){if(s.push({path:t,message:`Value must be one of: ${n.enum.join(", ")}`,expected:n.enum.join(", "),actual:e,rule:"enum"}),r.stopOnFirstError)return}if(typeof e==="string"){if(n.minLength!==void 0&&e.length<n.minLength)s.push({path:t,message:`String length must be at least ${n.minLength}`,expected:`>= ${n.minLength}`,actual:e.length,rule:"minLength"});if(n.maxLength!==void 0&&e.length>n.maxLength)s.push({path:t,message:`String length must not exceed ${n.maxLength}`,expected:`<= ${n.maxLength}`,actual:e.length,rule:"maxLength"});if(n.pattern){if(!new RegExp(n.pattern).test(e))s.push({path:t,message:`String does not match pattern ${n.pattern}`,expected:n.pattern,actual:e,rule:"pattern"})}}if(typeof e==="number"){if(n.minimum!==void 0&&e<n.minimum)s.push({path:t,message:`Value must be at least ${n.minimum}`,expected:`>= ${n.minimum}`,actual:e,rule:"minimum"});if(n.maximum!==void 0&&e>n.maximum)s.push({path:t,message:`Value must not exceed ${n.maximum}`,expected:`<= ${n.maximum}`,actual:e,rule:"maximum"})}if(Array.isArray(e)&&n.items)for(let o=0;o<e.length;o++){let l=t?`${t}[${o}]`:`[${o}]`;if(this.validateObjectAgainstSchema(e[o],n.items,l,s,i,r),r.stopOnFirstError&&s.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let o=e;if(r.validateRequired&&n.required){for(let l of n.required)if(!(l in o)){if(s.push({path:t?`${t}.${l}`:l,message:`Missing required property '${l}'`,expected:"required",rule:"required"}),r.stopOnFirstError)return}}if(n.properties){for(let[l,a]of Object.entries(n.properties))if(l in o){let c=t?`${t}.${l}`:l;if(this.validateObjectAgainstSchema(o[l],a,c,s,i,r),r.stopOnFirstError&&s.length>0)return}}if(n.additionalProperties===!1){let l=new Set(Object.keys(n.properties||{}));for(let a of Object.keys(o))if(!l.has(a))i.push({path:t?`${t}.${a}`:a,message:`Additional property '${a}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,n,t){let s=[],i=[];for(let r of n)try{let o=this.getValueByPath(e,r.path),l=this.validateWithRule(o,r,r.path);if(s.push(...l),t.stopOnFirstError&&s.length>0)break}catch(o){s.push({path:r.path,message:`Rule validation failed: ${o}`,rule:"system"})}return{isValid:s.length===0,errors:s,warnings:i}}validateWithRule(e,n,t){let s=[];if(n.required&&(e===void 0||e===null))return s.push({path:t,message:n.message||`Property '${t}' is required`,expected:"required",rule:"required"}),s;if(e===void 0||e===null)return s;if(n.type){let i=Array.isArray(e)?"array":typeof e;if(i!==n.type)s.push({path:t,message:n.message||`Expected type ${n.type}, got ${i}`,expected:n.type,actual:i,rule:"type"})}if(n.min!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i<n.min)s.push({path:t,message:n.message||`Value must be at least ${n.min}`,expected:`>= ${n.min}`,actual:i,rule:"min"})}if(n.max!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i>n.max)s.push({path:t,message:n.message||`Value must not exceed ${n.max}`,expected:`<= ${n.max}`,actual:i,rule:"max"})}if(n.pattern&&typeof e==="string"){if(!n.pattern.test(e))s.push({path:t,message:n.message||`Value does not match pattern ${n.pattern}`,expected:n.pattern.toString(),actual:e,rule:"pattern"})}if(n.enum&&!n.enum.includes(e))s.push({path:t,message:n.message||`Value must be one of: ${n.enum.join(", ")}`,expected:n.enum.join(", "),actual:e,rule:"enum"});if(n.validator){let i=n.validator(e);if(i)s.push({path:t,message:n.message||i,rule:"custom"})}return s}getValueByPath(e,n){if(!n)return e;let t=n.split("."),s=e;for(let i of t)if(s&&typeof s==="object"&&i in s)s=s[i];else return;return s}generateRulesFromInterface(e){let n=[],t=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let s of t){let[,i,r,o]=s;n.push({path:i,required:!r,type:this.mapTypeScriptType(o)})}return n}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:Po},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}class Si{fileLoader=new Rn;envProcessor=new wn;validator=new Ci;async loadConfig(e){let n=Date.now(),{cache:t,performance:s,schema:i,validate:r,...o}=e;try{if(t?.enabled){let a=this.checkCache(o.name||"",o);if(a)return a}let l;try{l=await this.loadConfigurationStrategies(o,!0,t)}catch(a){let c=o.__strictErrorHandling;if(a instanceof Error&&a.name==="ConfigNotFoundError"){if(c)throw a;l={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`No configuration file found for "${o.name||"config"}", using defaults with environment variables`]}}else if(a instanceof Error&&a.name==="ConfigLoadError"){let u=a.message.includes("EACCES")||a.message.includes("EPERM")||a.message.includes("permission denied"),f=!u&&(a.message.includes("syntax")||a.message.includes("Expected")||a.message.includes("Unexpected")||a.message.includes("BuildMessage")||a.message.includes("errors building")),m=a.message.includes("Configuration must export a valid object")||a.message.includes("Configuration file is empty and exports nothing");if(c&&(m||u))throw a;if(f&&(!c||!m))l={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!c)l={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`Configuration loading error, using defaults: ${a.message}`]};else throw a}else l={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${a instanceof Error?a.message:String(a)}`]}}if(i||r)await this.validateConfiguration(l.config,i,r,o.name);if(t?.enabled&&l)this.cacheResult(o.name||"",l,t,o);if(s?.enabled){let a={operation:"loadConfig",duration:Date.now()-n,configName:o.name,timestamp:new Date};if(s.onMetrics)s.onMetrics(a);if(s.slowThreshold&&a.duration>s.slowThreshold)_e.warn(`Slow configuration loading detected: ${a.duration}ms for ${o.name}`);l.metrics=a}return l}catch(l){let a=Date.now()-n;throw _e.error(`Configuration loading failed after ${a}ms:`,[l instanceof Error?l:Error(String(l))]),l}}async loadConfigurationStrategies(e,n=!1,t){let{name:s="",alias:i,cwd:r,configDir:o,defaultConfig:l,checkEnv:a=!0,arrayStrategy:c="replace",verbose:u=!1}=e,f=r||st.cwd(),m=[],h=await this.loadLocalConfiguration(s,i,f,o,l,c,u,a,t);if(h)return m.push(...this.getLocalSearchPaths(s,i,f,o)),this.finalizeResult(h,m,a,s,u);let d=await this.loadHomeConfiguration(s,i,l,c,u,a);if(d)return m.push(...this.getHomeSearchPaths(s,i)),this.finalizeResult(d,m,a,s,u);let p=await this.loadPackageJsonConfiguration(s,i,f,l,c,u,a);if(p)return m.push(Ce(f,"package.json")),this.finalizeResult(p,m,a,s,u);if(m.push(...this.getAllSearchPaths(s,i,f,o)),n)throw Je.configNotFound(s,m,i);return{...await this.applyEnvironmentVariables(s,l,a,u),warnings:[`No configuration file found for "${s}"${i?` or alias "${i}"`:""}, using defaults with environment variables`]}}async loadLocalConfiguration(e,n,t,s,i,r,o,l,a){let c=l?Et(e,i,o):i,u=this.getLocalDirectories(t,s);for(let f of u){if(o)_e.info(`Searching for configuration in: ${f}`);let m=this.fileLoader.generateConfigPaths(e,f,n),h=await this.fileLoader.tryLoadFromPaths(m,c,{arrayStrategy:r,verbose:o,cacheTtl:a?.ttl,useCache:!a?.ttl||a.ttl>100});if(h){if(o)_e.success(`Configuration loaded from: ${h.source.path}`);return h}}return null}async loadHomeConfiguration(e,n,t,s,i,r){if(!e)return null;let o=r?Et(e,t,i):t,l=[Ce(ut(),".config",e),Ce(ut(),".config"),ut()];for(let a of l){if(i)_e.info(`Checking home directory: ${a}`);let c=this.fileLoader.generateConfigPaths(e,a,n),u=await this.fileLoader.tryLoadFromPaths(c,o,{arrayStrategy:s,verbose:i});if(u){if(i)_e.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,n,t,s,i,r,o){let l=o?Et(e,s,r):s;try{let a=Ce(t,"package.json");if(!mi(a))return null;let c=await import(a),u=c[e],f=e;if(!u&&n)u=c[n],f=n;if(u&&typeof u==="object"&&!Array.isArray(u)){if(r)_e.success(`Configuration loaded from package.json: ${f}`);return{config:Mi(l,u,i),source:{type:"package.json",path:a,priority:30,timestamp:new Date}}}}catch(a){if(r)_e.warn("Failed to load package.json:",[a instanceof Error?a:Error(String(a))])}return null}async applyEnvironmentVariables(e,n,t,s){if(!t||!e||typeof n!=="object"||n===null||Array.isArray(n))return{config:n,source:{type:"default",priority:10,timestamp:new Date}};return{config:Et(e,n,s),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,n,t,s,i){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,n,t,s){let i=[];if(t){let r=t(e);if(r)i.push(...r)}if(n){let r=await this.validator.validateConfiguration(e,n);if(!r.isValid)i.push(...r.errors.map((o)=>o.path?`${o.path}: ${o.message}`:o.message))}if(i.length>0)throw Je.configValidation(s||"unknown",i,s)}checkCache(e,n){let t=this.generateCacheKey(e,n);return wt.get(t)||null}cacheResult(e,n,t,s){let i=this.generateCacheKey(e,s);wt.set(i,n,void 0,t.ttl)}generateCacheKey(e,n){let t=[e];if(n.alias)t.push(`alias:${n.alias}`);if(n.cwd)t.push(`cwd:${n.cwd}`);if(n.configDir)t.push(`configDir:${n.configDir}`);if("checkEnv"in n)t.push(`checkEnv:${n.checkEnv}`);return t.join("|")}getLocalDirectories(e,n){return Array.from(new Set([e,Ce(e,"config"),Ce(e,".config"),n?Ce(e,n):void 0].filter(Boolean)))}getAllSearchPaths(e,n,t,s){let i=[];return i.push(...this.getLocalSearchPaths(e,n,t,s)),i.push(...this.getHomeSearchPaths(e,n)),i.push(Ce(t,"package.json")),i}getLocalSearchPaths(e,n,t,s){let i=this.getLocalDirectories(t,s),r=[];for(let o of i)r.push(...this.fileLoader.generateConfigPaths(e,o,n));return r}getHomeSearchPaths(e,n){if(!e)return[];let t=[Ce(ut(),".config",e),Ce(ut(),".config"),ut()],s=[];for(let i of t)s.push(...this.fileLoader.generateConfigPaths(e,i,n));return s}async loadConfigWithResult(e){return this.loadConfig(e)}}function jr(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")),s=e.message.includes("Configuration must export a valid object")||e.message.includes("Configuration file is empty and exports nothing");return t||s}async function oh(e){return He.loadConfig({...e,__strictErrorHandling:!0})}async function bo(e){let n="defaultConfig"in e&&e.defaultConfig!==void 0?e.defaultConfig:{},t="cache"in e||"performance"in e||"schema"in e||"validate"in e;try{let s;if(t)s=await He.loadConfig(e);else s=await He.loadConfig({...e,defaultConfig:n,cache:{enabled:!0},performance:{enabled:!1}});return s?.config??n}catch(s){let i=s instanceof Error?s.name:"UnknownError",r=s instanceof Error?s.message:String(s);if(!(i==="ConfigNotFoundError"||i==="ConfigLoadError"||i==="ConfigValidationError"||r.includes("config"))&&e.verbose)_e.warn("Unexpected error loading config, using defaults:",[s instanceof Error?s:Error(String(s))]);let l=t?{...e,defaultConfig:n}:{...e,defaultConfig:n,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in e?e.checkEnv!==!1:!0)return(await He.applyEnvironmentVariables(l.name||"",n,!0,l.verbose||!1))?.config??n;return n}}async function lh(e={defaultConfig:{}}){if(typeof e==="string"){let{cwd:n}=await import("process");try{return(await He.loadConfig({name:e,cwd:n(),generatedDir:"./generated",configDir:"./config",defaultConfig:{},checkEnv:!0,arrayStrategy:"replace"})).config}catch(t){if(t instanceof Error&&(t.name==="ConfigNotFoundError"||t.name==="ConfigLoadError"&&jr(t)))return(await He.applyEnvironmentVariables(e,{},!0,!1)).config;throw t}}try{return(await He.loadConfig({...e,cwd:e.cwd||st.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(n){if(n instanceof Error&&(n.name==="ConfigNotFoundError"||n.name==="ConfigLoadError"&&jr(n)))return(await He.applyEnvironmentVariables(e.name||"",e.defaultConfig||{},e.checkEnv!==!1,e.verbose||!1)).config;throw n}}async function ah(e,n,t="replace"){let s=new Rn;try{let i=await s.loadFromPath(e,n,{arrayStrategy:t,useCache:!1,trackPerformance:!1});return i?i.config:null}catch{return null}}function Et(e,n,t=!1){let s=new wn,i=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function r(o,l=[]){let a={...o};for(let[c,u]of Object.entries(o)){let f=[...l,c],m=[`${i}_${f.join("_").toUpperCase()}`,`${i}_${f.map((p)=>p.toUpperCase()).join("")}`,`${i}_${f.map((p)=>p.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],h,d;for(let p of m)if(h=st.env[p],h!==void 0){d=p;break}if(h!==void 0&&d)if(typeof u==="boolean")a[c]=["true","1","yes"].includes(h.toLowerCase());else if(typeof u==="number"){let p=Number(h);if(!Number.isNaN(p))a[c]=p}else if(Array.isArray(u))try{a[c]=JSON.parse(h)}catch{a[c]=h.split(",").map((p)=>p.trim())}else a[c]=h;else if(u&&typeof u==="object"&&!Array.isArray(u))a[c]=r(u,f)}return a}return r(n)}function ch(e){let n=Ce(st.cwd(),e.configDir),t=Ce(st.cwd(),e.generatedDir),s=Ce(t,"config-types.ts");if(!mi(vr(s)))hm(vr(s),{recursive:!0,mode:511});let i=mi(n)?dm(n).map((o)=>o.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],r=`// Generated by bunfig v${Nh}
32
+ export type ConfigNames = ${i.length?`'${i.join("' | '")}'`:"string"}
33
+ `;pm(s,r,{mode:438})}function uh(e){let n=null,t=null,s=()=>{if(!t)t=bo(e).then((r)=>(n=r,r),(r)=>{let o="defaultConfig"in e?e.defaultConfig:{};if(n=o,"verbose"in e&&e.verbose)_e.warn("Config loading failed, using defaults:",[r instanceof Error?r:Error(String(r))]);return o});return t},i="defaultConfig"in e?e.defaultConfig:{};return n=i,s(),new Proxy({},{get(r,o){if(n)return n[o];let l=i[o];return s(),l},has(r,o){return o in(n||i)},ownKeys(){return Object.keys(n||i)},getOwnPropertyDescriptor(r,o){return Object.getOwnPropertyDescriptor(n||i,o)},set(r,o,l){if(!n)n={...i};return n[o]=l,!0}})}function fh(e){let n=Br(Wm.cwd(),e?.configDir||"./config");function t(){if(!Fm(n))return[];let i=new Set([".ts",".js",".mjs",".cjs",".mts",".cts",".json"]),r=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"],o=Nm(n).filter((a)=>i.has(si(a))).map((a)=>({base:a.replace(/\.(?:ts|js|mjs|cjs|mts|cts|json)$/i,""),file:a})),l=new Map;for(let{base:a,file:c}of o){let u=si(c).toLowerCase(),f=l.get(a);if(!f){l.set(a,c);continue}let m=si(f).toLowerCase();if(r.indexOf(u)<r.indexOf(m))l.set(a,c)}return Array.from(l.entries()).map(([a,c])=>({base:a,file:c})).sort((a,c)=>a.base.localeCompare(c.base))}function s(){let i=t(),r=i.map((c)=>c.base),o=r.length?r.map((c)=>`'${c}'`).join(" | "):"string",l=i.length?`{
34
+ ${i.map((c)=>{let u=Br(n,c.file).replace(/\\/g,"/");return` '${c.base}': typeof import('${u}').default`}).join(`,
35
+ `)}
36
+ }`:"Record<string, any>";return`export type ConfigNames = ${o}
37
+ export type ConfigByName = ${l}
38
+ export type Config<N extends ConfigNames> = N extends keyof ConfigByName ? ConfigByName[N] : unknown
39
+ export type ConfigOf = Config
40
+ `}return{name:"bunfig-plugin",setup(i){i.onResolve({filter:/^virtual:bunfig-types$/},(r)=>({path:r.path,namespace:"bunfig-virtual"})),i.onLoad({filter:/^virtual:bunfig-types$/,namespace:"bunfig-virtual"},()=>({contents:s(),loader:"ts"}))}}}var xo,wt,Ot,wo,mh,hh,Ur,rn,pi,Pe,ce,dh,zr,ph,qr,gh,yh,ii,bh,Kr,Vr,ri,xh,wh,Rh,kh,on,Ro,$h,ve,Ph,vh,Hr,ln,gi,be,oe,Ih,Zr,Mh,Gr,Ch,Sh,oi,Eh,Jr,Yr,Lh,li,Th,Ah,Oh,_h,Dh,an,ko,Fh,Nh="0.15.6",Ee,gn,Tt,yi,bi,yn,xi,wi,At,Ri,ki,Je,$o,Po,_e,He,vo,Io,Wh=mm(async()=>{xo=import.meta.require,wt=new $i,Ot=new Pi,wo={createKey:Bm,isEquivalent:jm,estimateMemoryUsage:Um},mh=fn(hi.cwd(),"config"),hh=fn(hi.cwd(),"src/generated"),Ur=un.env.CLARITY_LOG_DIR||bm(Km(),"logs"),rn={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Ur,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1},pi=await Vm(),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`,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"},ce=Pe,dh=Pe.red,zr=Pe.green,ph=Pe.yellow,qr=Pe.blue,gh=Pe.magenta,yh=Pe.cyan,ii=Pe.white,bh=Pe.gray,Kr=Pe.bgRed,Vr=Pe.bgYellow,ri=Pe.bold,xh=Pe.dim,wh=Pe.italic,Rh=Pe.underline,kh=Pe.reset,on={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Ro={debug:"\uD83D\uDD0D",info:qr("\u2139"),success:zr("\u2713"),warning:Vr(ii(ri(" WARN "))),error:Kr(ii(ri(" ERROR ")))},$h=new hn("stacks"),ve=new hn("bunfig",{showTags:!0}),Ph=Me(Lt.cwd(),"config"),vh=Me(Lt.cwd(),"src/generated"),Hr=cn.env.CLARITY_LOG_DIR||gm(Jm(),"logs"),ln={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Hr,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},gi=await Ym(),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`,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"},oe=be,Ih=be.red,Zr=be.green,Mh=be.yellow,Gr=be.blue,Ch=be.magenta,Sh=be.cyan,oi=be.white,Eh=be.gray,Jr=be.bgRed,Yr=be.bgYellow,Lh=be.bgGray,li=be.bold,Th=be.dim,Ah=be.italic,Oh=be.underline,_h=be.strikethrough,Dh=be.reset,an={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},ko={debug:"\uD83D\uDD0D",info:Gr("\u2139"),success:Zr("\u2713"),warning:Yr(oi(li(" WARN "))),error:Jr(oi(li(" ERROR ")))},Fh=new pn("stacks"),Ee=class extends Error{timestamp;context;constructor(n,t={}){super(n);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 n=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([t,s])=>`${t}: ${s}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${n}`}},gn=class extends Ee{code="CONFIG_NOT_FOUND";constructor(n,t,s){let i=s?` or alias "${s}"`:"";super(`Configuration "${n}"${i} not found`,{configName:n,alias:s,searchPaths:t,searchPathCount:t.length})}},Tt=class extends Ee{code="CONFIG_LOAD_ERROR";constructor(n,t,s){super(`Failed to load configuration from "${n}": ${t.message}`,{configPath:n,configName:s,originalError:t.name,originalMessage:t.message});this.cause=t}},yi=class extends Ee{code="CONFIG_VALIDATION_ERROR";constructor(n,t,s){super(`Configuration validation failed for "${n}"`,{configPath:n,configName:s,validationErrors:t,errorCount:t.length})}},bi=class extends Ee{code="CONFIG_MERGE_ERROR";constructor(n,t,s,i){super(`Failed to merge configuration from "${n}" with "${t}": ${s.message}`,{sourcePath:n,targetPath:t,configName:i,originalError:s.name,originalMessage:s.message});this.cause=s}},yn=class extends Ee{code="ENV_VAR_ERROR";constructor(n,t,s,i){super(`Failed to parse environment variable "${n}" with value "${t}" as ${s}`,{envKey:n,envValue:t,expectedType:s,configName:i})}},xi=class extends Ee{code="FILE_SYSTEM_ERROR";constructor(n,t,s){super(`File system ${n} failed for "${t}": ${s.message}`,{operation:n,path:t,originalError:s.name,originalMessage:s.message});this.cause=s}},wi=class extends Ee{code="TYPE_GENERATION_ERROR";constructor(n,t,s){super(`Failed to generate types from "${n}" to "${t}": ${s.message}`,{configDir:n,outputPath:t,originalError:s.name,originalMessage:s.message});this.cause=s}},At=class extends Ee{code="SCHEMA_VALIDATION_ERROR";constructor(n,t,s){super(`Schema validation failed${s?` for config "${s}"`:""}`,{schemaPath:n,configName:s,validationErrors:t,errorCount:t.length})}},Ri=class extends Ee{code="BROWSER_CONFIG_ERROR";constructor(n,t,s,i){super(`Failed to fetch configuration from "${n}": ${t} ${s}`,{endpoint:n,status:t,statusText:s,configName:i})}},ki=class extends Ee{code="PLUGIN_ERROR";constructor(n,t,s){super(`Plugin "${n}" failed during ${t}: ${s.message}`,{pluginName:n,operation:t,originalError:s.name,originalMessage:s.message});this.cause=s}},Je={configNotFound(e,n,t){return new gn(e,n,t)},configLoad(e,n,t){return new Tt(e,n,t)},configValidation(e,n,t){return new yi(e,n,t)},configMerge(e,n,t,s){return new bi(e,n,t,s)},envVar(e,n,t,s){return new yn(e,n,t,s)},fileSystem(e,n,t){return new xi(e,n,t)},typeGeneration(e,n,t){return new wi(e,n,t)},schemaValidation(e,n,t){return new At(e,n,t)},browserConfig(e,n,t,s){return new Ri(e,n,t,s)},plugin(e,n,t){return new ki(e,n,t)}},$o={replace:"replace",concat:"concat",smart:"smart"},Po=/^https?:\/\//,_e=new pn("bunfig",{showTags:!0}),He=new Si,vo=Ce(st.cwd(),"config"),Io=Ce(st.cwd(),"src/generated")});function Uh(e,n={}){let t=bn.cwd();while(t.includes("storage"))t=Xr(t,"..");let s=Xr(t,e||"");if(n?.relative)return jh(bn.cwd(),s);return s}var zh=bn.env.CLARITY_LOG_DIR||Bh(Uh(),"logs"),Mo={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:zh,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},xn={...Mo},my=(async()=>{try{let{loadConfig:e}=await Wh().then(()=>lo),n=await e({name:"clarity",alias:"logging",defaultConfig:Mo,cwd:bn.cwd()});if(n)Object.assign(xn,n)}catch{}return xn})();function xe(){if(Ve.env.NODE_ENV==="test"||Ve.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Qh(){if(Ve.env.NODE_ENV==="test"||Ve.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof Ve<"u"){let e=Ve.type;if(e==="renderer"||e==="worker")return!1;return!!(Ve.versions&&(Ve.versions.node||Ve.versions.bun))}return!1}class Co{async format(e){let n=await Qh(),t=await this.getMetadata(n);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:t})}async getMetadata(e){if(e){let{hostname:n}=await import("os");return{pid:xt.pid,hostname:n(),environment:xt.env.NODE_ENV||"development",platform:xt.platform,version:xt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:xt.env.NODE_ENV||xt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}var Re={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"},le=Re,$y=Re.red,ed=Re.green,Py=Re.yellow,td=Re.blue,vy=Re.magenta,Iy=Re.cyan,ro=Re.white,My=Re.gray,nd=Re.bgRed,sd=Re.bgYellow,Cy=Re.bgGray,oo=Re.bold,Sy=Re.dim,Ey=Re.italic,Ly=Re.underline,Ty=Re.strikethrough,Ay=Re.reset,fi={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},id={debug:"\uD83D\uDD0D",info:td("\u2139"),success:ed("\u2713"),warning:sd(ro(oo(" WARN "))),error:nd(ro(oo(" ERROR ")))};class it{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,n={}){this.name=e,this.config={...xn},this.options=this.normalizeOptions(n),this.formatter=this.options.formatter||new Co,this.enabled=n.enabled??!0,this.fancy=n.fancy??!0,this.tagFormat=n.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=n.timestampPosition??"right",this.environment=n.environment??re.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(n);let t={...n},s=n.timestamp!==void 0;if(s)delete t.timestamp;if(this.config={...this.config,...t,timestamp:s||this.config.timestamp,level:this.options.level??"info"},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),r=this.generateKey();this.currentKeyId=i,this.keys.set(i,r),this.encryptionKeys.set(i,{key:r,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let n={debug:0,info:1,success:2,warning:3,error:4},t=this.fingersCrossedConfig.activationLevel??"error";return n[e]>=n[t]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...fi,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...fi};return{...fi,...e.fingersCrossed}}normalizeOptions(e){let n={format:"json",level:"info",logDirectory:xn.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},t={...n,...Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))};if(!t.level||!["debug","info","success","warning","error"].includes(t.level))t.level=n.level;return t}shouldWriteToFile(){return!xe()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let i,r=0,o=3,l=1000;while(r<o)try{try{try{await Zh(this.config.logDirectory,no.F_OK|no.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await Gh(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 a=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:ze.from(e);try{if(!en(this.currentLogFile))await ui(this.currentLogFile,"",{mode:420});if(i=to(this.currentLogFile,"a",420),Hh(i,a,{flag:"a"}),eo(i),i!==void 0)ci(i),i=void 0;if((await yt(this.currentLogFile)).size===0){if(await ui(this.currentLogFile,a,{flag:"w",mode:420}),(await yt(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let u=c;if(u.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(u.code)){if(r<o-1){let f=typeof u.message==="string"?u.message:"Unknown error";console.error(`Network error during write attempt ${r+1}/${o}:`,f);let m=l*2**r;await new Promise((h)=>setTimeout(h,m)),r++;continue}}if(u?.code&&["ENOSPC","EDQUOT"].includes(u.code))throw Error(`Disk quota exceeded or no space left on device: ${u.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",u),u}finally{if(i!==void 0)try{ci(i)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(a){if(r===o-1){let u=a,f=typeof u.message==="string"?u.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",f),a}r++;let c=l*2**(r-1);await new Promise((u)=>setTimeout(u,c))}})();this.pendingOperations.push(t);let s=this.pendingOperations.length-1;try{await t}catch(i){throw console.error("Debug: [writeToFile] Error in operation:",i),i}finally{this.pendingOperations.splice(s,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 bt(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 bt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return bt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(xe())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,n;switch(e.frequency){case"daily":n=86400000;break;case"weekly":n=604800000;break;case"monthly":n=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},n)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let n=this.config.rotation.keyRotation;if(!n?.enabled)return;let t=typeof n.interval==="number"?n.interval:60,s=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((i)=>{console.error("Error rotating keys:",i)})},s)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let n=this.config.rotation.keyRotation,t=this.generateKeyId(),s=this.generateKey();this.currentKeyId=t,this.keys.set(t,s),this.encryptionKeys.set(t,{key:s,createdAt:new Date});let i=Array.from(this.encryptionKeys.entries()).sort(([,l],[,a])=>a.createdAt.getTime()-l.createdAt.getTime()),r=typeof n.maxKeys==="number"?n.maxKeys:1,o=Math.max(1,r);if(i.length>o)for(let[l]of i.slice(o))this.encryptionKeys.delete(l),this.keys.delete(l)}generateKeyId(){return ai(16).toString("hex")}generateKey(){return ai(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:n}=this.getCurrentKey(),t=ai(16),s=qh("aes-256-gcm",n,t),i=ze.isBuffer(e)?e:ze.from(e,"utf8"),r=s.update(i),o=s.final(),l=r.length+o.length,a=s.getAuthTag(),c=ze.allocUnsafe(16+l+16);return t.copy(c,0),r.copy(c,16),o.copy(c,16+r.length),a.copy(c,16+l),{encrypted:c,iv:t}}async compressData(e){return new Promise((n,t)=>{let s=io(),i=[];s.on("data",(r)=>i.push(r)),s.on("end",()=>n(ze.from(ze.concat(i)))),s.on("error",t),s.write(e),s.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 n=this.config.rotation.encrypt;return{...e,...n}}return e}async rotateLog(){if(xe())return;if(!this.shouldWriteToFile())return;let e=await yt(this.currentLogFile).catch(()=>null);if(!e)return;let n=this.config.rotation;if(typeof n==="boolean")return;if(n.maxSize&&e.size>=n.maxSize){let t=this.currentLogFile,s=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await tn(this.config.logDirectory),r=i.filter((a)=>a.startsWith(this.name)&&/\.log\.\d+$/.test(a)).sort((a,c)=>{let u=Number.parseInt(a.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(c.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),o=r.length>0?Number.parseInt(r[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,l=`${t}.${o}`;if(await yt(t).catch(()=>null))try{if(await so(t,l),n.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await nn(l)}catch(a){console.error("Error compressing rotated file:",a)}if(r.length===0&&!i.some((a)=>a.endsWith(".log.1")))try{let a=`${t}.1`;await ui(a,"")}catch(a){console.error("Error creating backup file:",a)}}catch(a){console.error(`Error during rotation: ${a instanceof Error?a.message:String(a)}`)}}else{let i=new Date().toISOString().replace(/[:.]/g,"-"),r=t.replace(/\.log$/,`-${i}.log`);if(await yt(t).catch(()=>null))await so(t,r)}if(this.currentLogFile=s,n.maxFiles){let r=(await tn(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,l)=>l.localeCompare(o));for(let o of r.slice(n.maxFiles))await nn(bt(this.config.logDirectory,o))}}}async compressLogFile(e,n){let t=Qr(e),s=Vh(n),i=io();await Xh(t,i,s)}async handleFingersCrossedBuffer(e,n){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let t of this.logBuffer){let s=await this.formatter.format(t);if(this.shouldWriteToFile())await this.writeToFile(s);console.log(s)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(n);console.log(n)}}shouldLog(e){if(!this.enabled)return!1;let n={debug:0,info:1,success:2,warning:3,error:4};return n[e]>=n[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((n)=>{console.error("Error in pending write operation:",n)});return Promise.resolve()})),en(this.currentLogFile))try{let e=to(this.currentLogFile,"r+");eo(e),ci(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(!xe()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let n=(await tn(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of n)try{await nn(bt(this.config.logDirectory,t))}catch(s){console.error(`Failed to delete temp file ${t}:`,s)}}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()?le.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||xe())return!1;let e=typeof re.env.NO_COLOR<"u",n=re.env.FORCE_COLOR==="0";if(e||n)return!1;return!!(typeof re.stderr<"u"&&re.stderr.isTTY||typeof re.stdout<"u"&&re.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:n,icon:t="",tag:s="",message:i,level:r,showTimestamp:o=!0}=e,l=(h)=>h.replace(this.ANSI_PATTERN,"");if(!this.fancy){let h=[];if(o)h.push(n);if(r==="warning")h.push("WARN");else if(r==="error")h.push("ERROR");else if(t)h.push(t.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(s)h.push(s.replace(/[[\]]/g,""));return h.push(i),h.join(" ")}let a=re.stdout.columns||120,c="";if(r==="warning"||r==="error")c=`${t} ${i}`;else if(r==="info"||r==="success")c=`${t} ${s} ${i}`;else c=`${t} ${s} ${le.cyan(i)}`;if(!o)return c.trim();let u=l(c).trim().length,f=l(n).length,m=Math.max(1,a-2-u-f);return`${c.trim()}${" ".repeat(m)}${n}`}formatMessage(e,n){if(n.length===1&&Array.isArray(n[0]))return e.replace(/\{(\d+)\}/g,(r,o)=>{let l=Number.parseInt(o,10);return l<n[0].length?String(n[0][l]):r});let t=/%([sdijfo%])/g,s=0,i=e.replace(t,(r,o)=>{if(o==="%")return"%";if(s>=n.length)return r;let l=n[s++];switch(o){case"s":return String(l);case"d":case"i":return Number(l).toString();case"j":case"o":return JSON.stringify(l,null,2);default:return r}});if(s<n.length)i+=` ${n.slice(s).map((r)=>typeof r==="object"?JSON.stringify(r,null,2):String(r)).join(" ")}`;return i}formatMarkdown(e){if(!e)return e;let n=e;return n=n.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(t,s,i)=>{let r=le.underline(le.blue(s)),o=this.toAbsoluteFilePath(i);if(o&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let l=`file://${encodeURI(o)}`,a="\x1B]8;;",c="\x1B\\";return`\x1B]8;;${l}\x1B\\${r}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${i}\x1B\\${r}\x1B]8;;\x1B\\`;return r}),n=n.replace(/`([^`]+)`/g,(t,s)=>le.bgGray(s)),n=n.replace(/\*\*([^*]+)\*\*/g,(t,s)=>le.bold(s)),n=n.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(t,s)=>le.italic(s)),n=n.replace(/(?<!_)_([^_]+)_(?!_)/g,(t,s)=>le.italic(s)),n=n.replace(/~([^~]+)~/g,(t,s)=>le.strikethrough(s)),n}supportsHyperlinks(){if(xe())return!1;let e=re.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 n=e.VTE_VERSION?Number.parseInt(e.VTE_VERSION,10):0;if(!Number.isNaN(n)&&n>=5000)return!0;return!1}toAbsoluteFilePath(e){try{let n=e;if(n.startsWith("file://"))n=n.replace(/^file:\/\//,"");if(n.startsWith("~")){let t=re.env.HOME||"";if(t)n=n.replace(/^~(?=$|\/)/,t)}if(Jh(n)||n.startsWith("./")||n.startsWith("../"))n=Yh(n);else return null;return en(n)?n:null}catch{return null}}buildOutputTexts(e){let n=this.shouldStyleConsole()?this.formatMarkdown(e):e,t=e.replace(this.ANSI_PATTERN,"");return{consoleText:n,fileText:t}}async log(e,n,...t){if(!this.shouldLog(e))return;let s=new Date,i=this.formatConsoleTimestamp(s),r=this.formatFileTimestamp(s),o,l;if(n instanceof Error)o=n.message,l=n.stack;else o=this.formatMessage(n,t);let{consoleText:a,fileText:c}=this.buildOutputTexts(o);if(this.shouldStyleConsole()){let f=this.options.showIcons===!1?"":id[e],m=this.options.showTags!==!1&&this.name?le.gray(this.formatTag(this.name)):"",h;switch(e){case"debug":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:le.gray(a),level:e}),console.error(h);break;case"info":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:a,level:e}),console.warn(h);break;case"success":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:le.green(a),level:e}),console.error(h);break;case"warning":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:a,level:e}),console.warn(h);break;case"error":if(h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:a,level:e}),console.error(h),l){let d=l.split(`
41
+ `);for(let p of d)if(p.trim()&&!p.includes(o))console.error(this.formatConsoleMessage({timestamp:i,message:le.gray(` ${p}`),level:e,showTimestamp:!1}))}break}}else if(!xe()){if(console.error(`${r} ${this.environment}.${e.toUpperCase()}: ${o}`),l)console.error(l)}let u=`${r} ${this.environment}.${e.toUpperCase()}: ${c}
42
+ `;if(l)u+=`${l}
43
+ `;if(u=u.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(u)}progress(e,n=""){let t={update:(l,a)=>{},finish:(l)=>{},interrupt:(l,a)=>{}};if(!this.enabled)return t;let s=30;if(this.activeProgressBar={total:Math.max(1,e||1),current:0,message:n||"",barLength:s,lastRenderedLine:""},this.shouldStyleConsole()&&!xe()&&re.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(l,a)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,l),this.activeProgressBar.total),a!==void 0)this.activeProgressBar.message=a;if(this.shouldStyleConsole()&&!xe()&&re.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(l)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,l)},interrupt:(l,a="info")=>{if(!xe()&&re.stdout.isTTY)re.stdout.write(`
44
+ `);if(this[a==="warning"?"warn":a](l),this.activeProgressBar&&this.shouldStyleConsole()&&!xe()&&re.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let n=performance.now();if(this.shouldStyleConsole()){let t=this.options.showTags!==!1&&this.name?le.gray(this.formatTag(this.name)):"",s=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:s,icon:this.options.showIcons===!1?"":le.blue("\u25D0"),tag:t,message:`${le.cyan(e)}...`}))}return async(t)=>{if(!this.enabled)return;let s=performance.now(),i=Math.round(s-n),r=`${e} completed in ${i}ms`,o=new Date,l=this.formatConsoleTimestamp(o),c=`${this.formatFileTimestamp(o)} ${this.environment}.INFO: ${r}`;if(t)c+=` ${JSON.stringify(t)}`;if(c+=`
45
+ `,c=c.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let u=this.options.showTags!==!1&&this.name?le.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:this.options.showIcons===!1?"":le.green("\u2713"),tag:u,message:`${r}${t?` ${JSON.stringify(t)}`:""}`}))}else if(!xe())console.error(c.trim());if(this.shouldWriteToFile())await this.writeToFile(c)}}async debug(e,...n){await this.log("debug",e,...n)}async info(e,...n){await this.log("info",e,...n)}async success(e,...n){await this.log("success",e,...n)}async warn(e,...n){await this.log("warning",e,...n)}async error(e,...n){await this.log("error",e,...n)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:n}=e;return!!n}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let n=`${this.name}:${e}`,t=new it(n,{...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(t),t}createReadStream(){if(xe())throw Error("createReadStream is not supported in browser environments");if(!en(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return Qr(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let n=this.config.rotation;if(!n.encrypt||typeof n.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let t=this.keys.get(this.currentKeyId);try{let s=ze.isBuffer(e)?e:ze.from(e,"base64"),i=s.subarray(0,16),r=s.subarray(s.length-16),o=s.subarray(16,s.length-16),l=Kh("aes-256-gcm",t,i);l.setAuthTag(r);let a=l.update(o),c=l.final(),u=a.length+c.length,f=ze.allocUnsafe(u);return a.copy(f,0),c.copy(f,a.length),f.toString("utf8")}catch(s){throw Error(`Decryption failed: ${s instanceof Error?s.message:String(s)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return xe()}isServerMode(){return!xe()}setTestEncryptionKey(e,n){this.currentKeyId=e,this.keys.set(e,n)}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 n=new Date,t=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n),{consoleText:i,fileText:r}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let l=i.split(`
46
+ `),a=Math.max(...l.map((m)=>m.length))+2,c=`\u250C${"\u2500".repeat(a)}\u2510`,u=`\u2514${"\u2500".repeat(a)}\u2518`,f=l.map((m)=>this.formatConsoleMessage({timestamp:t,message:le.cyan(m),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:t,message:le.cyan(c),showTimestamp:!1})),f.forEach((m)=>console.error(m)),console.error(this.formatConsoleMessage({timestamp:t,message:le.cyan(u),showTimestamp:!1}))}else if(!xe())console.error(`${s} ${this.environment}.INFO: [BOX] ${r}`);let o=`${s} ${this.environment}.INFO: [BOX] ${r}
47
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(o)}async prompt(e){if(xe())return Promise.resolve(!0);return new Promise((n)=>{console.error(`${le.cyan("?")} ${e} (y/n) `);let t=(s)=>{let i=s.toString().trim().toLowerCase();re.stdin.removeListener("data",t);try{if(typeof re.stdin.setRawMode==="function")re.stdin.setRawMode(!1)}catch{}re.stdin.pause(),console.error(""),n(i==="y"||i==="yes")};try{if(typeof re.stdin.setRawMode==="function")re.stdin.setRawMode(!0)}catch{}re.stdin.resume(),re.stdin.once("data",t)})}setFancy(e){this.fancy=e}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(e,...n){if(!this.enabled)return;let t=e;if(n&&n.length>0){let a=/%([sdijfo%])/g,c=0;if(t=e.replace(a,(u,f)=>{if(f==="%")return"%";if(c>=n.length)return u;let m=n[c++];switch(f){case"s":return String(m);case"d":case"i":return Number(m).toString();case"j":case"o":return JSON.stringify(m,null,2);default:return u}}),c<n.length)t+=` ${n.slice(c).map((u)=>typeof u==="object"?JSON.stringify(u,null,2):String(u)).join(" ")}`}let{consoleText:s,fileText:i}=this.buildOutputTexts(t);if(this.shouldStyleConsole()){let a=this.options.showTags!==!1&&this.name?le.gray(this.formatTag(this.name)):"",c=this.options.showIcons===!1?"":`${le.blue("\u25D0")} `;console.error(`${c}${a} ${le.cyan(s)}`)}let l=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${i}
48
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(l)}renderProgressBar(e,n=!1){if(!this.enabled||!this.shouldStyleConsole()||!re.stdout.isTTY)return;let t=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),s=Math.round(e.barLength*t/100),i=e.barLength-s,r=le.green("\u2501".repeat(s)),o=le.gray("\u2501".repeat(i)),l=`[${r}${o}]`,a=`${t}%`.padStart(4),c=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":n||t===100?le.green("\u2713"):le.blue("\u25B6"),f=this.options.showTags!==!1&&this.name?` ${le.gray(this.formatTag(this.name))}`:"",m=`\r${u}${f} ${l} ${a}${c}`,h=re.stdout.columns||80,d=" ".repeat(Math.max(0,h-m.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${m}${d}`,re.stdout.write(e.lastRenderedLine),n)re.stdout.write(`
49
+ `)}finishProgressBar(e,n){if(!this.enabled||!this.fancy||xe()||!re.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(n)e.message=n;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(xe()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let n=await tn(this.config.logDirectory),t=[];for(let s of n){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(s):s.startsWith(this.name))||!s.endsWith(".log"))continue;let r=bt(this.config.logDirectory,s);if(e.before)try{if((await yt(r)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${r}:`,o);continue}t.push(r)}if(t.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${t.length} log file(s)...`);for(let s of t)try{await nn(s),console.warn(`Deleted log file: ${s}`)}catch(i){console.error(`Failed to delete log file ${s}:`,i)}console.warn("Log clearing process finished.")}catch(n){console.error("Error during log clearing process:",n)}}}var Oy=new it("stacks");import{readFileSync as Uf,writeFileSync as tg}from"fs";import{isAbsolute as ng,relative as Bf,resolve as sg}from"path";var kn={meta:{docs:"Enforce return statements in callbacks of array methods",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=new RegExp(`\\.(${["map","filter","find","findIndex","findLast","findLastIndex","every","some","reduce","reduceRight","sort","flatMap"].join("|")})\\s*\\(`,"g");for(let o=0;o<s.length;o++){let l=s[o],a;for(a=r.exec(l);a!==null;a=r.exec(l)){let c=a[1],u=a.index+a[0].length,f=l.slice(u),m=f.match(/^\s*(?:\(([^)]*)\)|([a-z_$][\w$]*))\s*=>/i),h=f.match(/^\s*function\s*(?:[a-zA-Z_$][\w$]*\s*)?\(/);if(m){let d=f.slice(m[0].length).trim();if(d.startsWith("{")){let p=!1,g=0,y=d,x=o;while(x<s.length){let k=x===o?y:s[x];for(let v=0;v<k.length;v++){let w=k[v];if(w==="{")g++;if(w==="}"){if(g--,g===0){if(!p)t.push({filePath:n.filePath,line:o+1,column:a.index+1,ruleId:"eslint/array-callback-return",message:`Array method '${c}' callback should return a value`,severity:"error"});break}}}if(k.match(new RegExp("\\breturn\\s+[^;]")))p=!0;if(g===0)break;x++,y=s[x]||""}}}else if(h){let d=!1,p=0,g=o,y=!1;while(g<s.length){let x=s[g];for(let k=0;k<x.length;k++){let v=x[k];if(v==="{")p++,y=!0;else if(v==="}"){if(p--,p===0&&y){if(!d)t.push({filePath:n.filePath,line:o+1,column:a.index+1,ruleId:"eslint/array-callback-return",message:`Array method '${c}' callback should return a value`,severity:"error"});break}}}if(y&&x.match(new RegExp("\\breturn\\s+[^;]")))d=!0;if(p===0&&y)break;g++}}}}return t}};var $n={meta:{docs:"Require super() calls in constructors of derived classes",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=!1,o=0,l=0,a=!1;for(let c=0;c<s.length;c++){let u=s[c];if(u.match(/\bclass\s+\w+\s+extends\s+\w+/))i=!0;if(i&&u.match(/\bconstructor\s*\(/))r=!0,o=c+1,l=0,a=!1;if(r){for(let f of u){if(f==="{")l++;if(f==="}")l--}if(u.match(/\bsuper\s*\(/))a=!0;if(l===0&&u.includes("}")){if(!a)t.push({filePath:n.filePath,line:o,column:1,ruleId:"eslint/constructor-super",message:"Constructors of derived classes must call super()",severity:"error"});r=!1,i=!1}}}return t}};var Pn={meta:{docs:'Enforce "for" loop update clause moving counter in the right direction',recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=new RegExp("\\bfor\\s*\\(\\s*(?:(?:let|var|const)\\s*)?(\\w+)\\s*=[^;]+;\\s*(\\w+)\\s*([<>]=?)[^;]+;\\s*(\\w+)(\\+\\+|--|[\\s+-]=)"),l=r.match(o);if(l){let a=l[1],c=l[2],u=l[3],f=l[4],m=l[5];if(a===c&&c===f){let h=m.includes("+"),d=u.includes("<");if(d&&!h||!d&&h)t.push({filePath:n.filePath,line:i+1,column:1,ruleId:"eslint/for-direction",message:"The update clause in this loop moves the variable in the wrong direction",severity:"error"})}}}return t}};var vn={meta:{docs:"Enforce return statements in getters",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let o=s[i].match(/\bget\s+(\w+)\s*\(/);if(o){let l=o[1],a=!1,c=0,u=i;while(u<s.length){let f=s[u];for(let h of f){if(h==="{")c++;if(h==="}"){if(c--,c===0){if(!a)t.push({filePath:n.filePath,line:i+1,column:1,ruleId:"eslint/getter-return",message:`Getter '${l}' must return a value`,severity:"error"});break}}}let m=new RegExp("\\breturn\\s+[^;]");if(f.match(m))a=!0;if(c===0)break;u++}}}return t}};var In={meta:{docs:"Disallow async functions as Promise executor",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/new\s+Promise\s*\(\s*async\s*(?:\(|function)/g,l;for(l=o.exec(r);l!==null;l=o.exec(r))t.push({filePath:n.filePath,line:i+1,column:l.index+1,ruleId:"eslint/no-async-promise-executor",message:"Promise executor functions should not be async",severity:"error"})}return t}};var Mn={meta:{docs:"Disallow comparing against -0",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/([!=]==?)\s*-0\b|\b-0\s*([!=]==?)/g,l;for(l=o.exec(r);l!==null;l=o.exec(r))t.push({filePath:n.filePath,line:i+1,column:l.index+1,ruleId:"eslint/no-compare-neg-zero",message:"Do not use the '-0' literal in comparisons",severity:"error"})}return t}};var Cn={meta:{docs:"Disallow assignment operators in conditional expressions",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\b(if|while)\s*\([^)]*\b(\w+)\s*=\s*(?!=)[^)]*\)/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let a=l[0];if(/===|==/.test(a))continue;if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-cond-assign",message:"Expected a conditional expression and instead saw an assignment",severity:"error"})}}return t}};var Sn={meta:{docs:"Disallow reassigning const variables",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=new Map;for(let r=0;r<s.length;r++){let o=s[r],l=o.match(/\bconst\s+(\w+)/);if(l)i.set(l[1],r);let a=/\b(\w+)\s*=(?!=)/g,c;for(c=a.exec(o);c!==null;c=a.exec(o)){let u=c[1],f=o.substring(0,c.index);if(!/\b(?:const|let|var)\s*$/.test(f)&&i.has(u))t.push({filePath:n.filePath,line:r+1,column:Math.max(1,c.index+1),ruleId:"eslint/no-const-assign",message:`'${u}' is constant`,severity:"error"})}}return t}};var En={meta:{docs:"Disallow constant expressions in conditions",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=[{pattern:/\b(if|while)\s*\(\s*(true|false)\s*\)/g,type:"boolean"},{pattern:/\b(if|while)\s*\(\s*(\d+)\s*\)/g,type:"number"},{pattern:/\b(if|while)\s*\(\s*(['"`][^'"`]*['"`])\s*\)/g,type:"string"}];for(let{pattern:l,type:a}of o){let c;while((c=l.exec(r))!==null){let u=c[1];if(r.substring(0,c.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,c.index+u.length+2),ruleId:"eslint/no-constant-condition",message:"Unexpected constant condition",severity:"error"})}}}return t}};var Ln={meta:{docs:"Disallow duplicate class members",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=new Set,o=0;for(let l=0;l<s.length;l++){let a=s[l];if(a.match(/\bclass\s+\w+/))i=!0,r=new Set,o=0;if(i){for(let u of a){if(u==="{")o++;if(u==="}"){if(o--,o===0)i=!1}}let c=[...a.matchAll(/^\s*(?:(?:public|private|protected|static|readonly|async)\s*)?(?:get|set)?\s*(\w+)\s*\(/g),...a.matchAll(/^\s*(?:(?:public|private|protected|static|readonly)\s*)?(\w+)\s*[:=]/g)];for(let u of c){let f=u[1];if(r.has(f))t.push({filePath:n.filePath,line:l+1,column:1,ruleId:"eslint/no-dupe-class-members",message:`Duplicate class member '${f}'`,severity:"error"});else r.add(f)}}}return t}};var _t={meta:{docs:"Disallow duplicate keys in object literals",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=/\{\s*$/,r=/^\s*(?:(['"`])(.+?)\1|(\w+))\s*:/;for(let o=0;o<s.length;o++){let l=s[o];if(!i.test(l)&&!l.includes("{"))continue;let a=new Map,c=(l.match(/\{/g)||[]).length-(l.match(/\}/g)||[]).length,u=o;for(let f=o+1;f<s.length&&c>0;f++){let m=s[f];c+=(m.match(/\{/g)||[]).length,c-=(m.match(/\}/g)||[]).length;let h=m.match(r);if(h){let d=h[2]||h[3];if(d)if(a.get(d)!==void 0)t.push({filePath:n.filePath,line:f+1,column:Math.max(1,m.search(/\S/)+1),ruleId:"eslint/no-dupe-keys",message:`Duplicate key '${d}'`,severity:"error"});else a.set(d,f)}if(c===0)break}}return t},fix:(e,n)=>{let t=_t.check(e,n);if(t.length===0)return e;let s=e.split(/\r?\n/),i=new Set(t.map((o)=>o.line-1));return s.filter((o,l)=>!i.has(l)).join(`
50
+ `)}};var Tn={meta:{docs:"Disallow duplicate case labels in switch statements",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=new Set,o=-1;for(let l=0;l<s.length;l++){let a=s[l],c=a.trim();if(/\bswitch\s*\(/.test(c)){i=!0,r=new Set,o=l;continue}if(i&&c==="}"&&l>o){let u=s[o].match(/^\s*/)?.[0].length||0;if((a.match(/^\s*/)?.[0].length||0)<=u+2)i=!1,r=new Set}if(i){let u=c.match(/^case\s+(.+?)\s*:/);if(u){let f=u[1].trim();if(r.has(f))t.push({filePath:n.filePath,line:l+1,column:Math.max(1,a.indexOf("case")+1),ruleId:"eslint/no-duplicate-case",message:`Duplicate case label '${f}'`,severity:"error"});else r.add(f)}}}return t}};var An={meta:{docs:"Disallow empty destructuring patterns",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\{\s*\}\s*=/g,l=/\[\s*\]\s*=/g,a;for(a=o.exec(r);a!==null;a=o.exec(r)){if(r.substring(0,a.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,a.index+1),ruleId:"eslint/no-empty-pattern",message:"Unexpected empty object pattern",severity:"error"})}for(a=l.exec(r);a!==null;a=l.exec(r)){if(r.substring(0,a.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,a.index+1),ruleId:"eslint/no-empty-pattern",message:"Unexpected empty array pattern",severity:"error"})}}return t}};var On={meta:{docs:"Disallow fallthrough of case statements",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=-1,o=!1;for(let l=0;l<s.length;l++){let c=s[l].trim();if(/\bswitch\s*\(/.test(c)){i=!0;continue}if(i){if(/^case\s+/.test(c)||/^default\s*:/.test(c)){if(r>=0&&o){if(!(/\/\/.*falls?\s*through|\/\*.*falls?\s*through/i.test(s[r])||l>0&&/\/\/.*falls?\s*through|\/\*.*falls?\s*through/i.test(s[l-1])))t.push({filePath:n.filePath,line:r+1,column:Math.max(1,s[r].indexOf("case")+1),ruleId:"eslint/no-fallthrough",message:"Expected a 'break' statement before 'case'",severity:"error"})}r=l,o=!0}if(/\b(?:break|return|throw|continue)\b/.test(c))o=!1;if(c==="}")i=!1,r=-1,o=!1}}return t}};var _n={meta:{docs:"Disallow number literals that lose precision",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\b(\d{17,}(?:\.\d+)?|\d+\.\d{17,})\b/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let a=l[1];if(Number(a).toString()!==a)t.push({filePath:n.filePath,line:i+1,column:l.index+1,ruleId:"eslint/no-loss-of-precision",message:"This number literal will lose precision at runtime",severity:"error"})}}return t}};var Dn={meta:{docs:"Disallow returning values from Promise executor functions",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++)if(s[i].match(/new\s+Promise\s*\(/)){let l=0,a=!1,c=i;while(c<s.length){let u=s[c];for(let m of u){if(m==="{")l++,a=!0;if(m==="}"){if(l--,l===0&&a)break}}let f=new RegExp("\\breturn\\s+[^;]");if(a&&u.match(f))t.push({filePath:n.filePath,line:c+1,column:1,ruleId:"eslint/no-promise-executor-return",message:"Return values from promise executor functions cannot be read",severity:"error"});if(l===0&&a)break;c++}}return t}};var Fn={meta:{docs:"Disallow variable redeclaration",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=new Map;for(let r=0;r<s.length;r++){let o=s[r],l=/\b(var|let|const)\s+(\w+)/g,a;for(a=l.exec(o);a!==null;a=l.exec(o)){let u=a[2];if(i.get(u)!==void 0)t.push({filePath:n.filePath,line:r+1,column:Math.max(1,a.index+1),ruleId:"eslint/no-redeclare",message:`'${u}' is already defined`,severity:"error"});else i.set(u,r)}let c=/\bfunction\s+(\w+)/g;for(a=c.exec(o);a!==null;a=c.exec(o)){let u=a[1];if(i.get(u)!==void 0)t.push({filePath:n.filePath,line:r+1,column:Math.max(1,a.index+1),ruleId:"eslint/no-redeclare",message:`'${u}' is already defined`,severity:"error"});else i.set(u,r)}}return t}};var Dt={meta:{docs:"Disallow assignments where both sides are identical",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=new RegExp("\\b(\\w+)\\s*=\\s*(\\w+)\\s*(?:;\\s*)?(?:\\/\\/.*)?$"),l=r.match(o);if(l&&l[1]===l[2]){t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf(l[1])+1),ruleId:"eslint/no-self-assign",message:`'${l[1]}' is assigned to itself`,severity:"error"});continue}let a=r.match(/([\w.]+)\s*=\s*([\w.]+)/);if(a&&a[1]===a[2]){t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf(a[1])+1),ruleId:"eslint/no-self-assign",message:`'${a[1]}' is assigned to itself`,severity:"error"});continue}let c=r.match(/(\w+\[[^\]]+\])\s*=\s*(\w+\[[^\]]+\])/);if(c){let u=c[1].replace(/\s/g,""),f=c[2].replace(/\s/g,"");if(u===f)t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf(c[1])+1),ruleId:"eslint/no-self-assign",message:`'${c[1]}' is assigned to itself`,severity:"error"})}}return t},fix:(e,n)=>{let t=Dt.check(e,n);if(t.length===0)return e;let s=e.split(/\r?\n/),i=new Set(t.map((o)=>o.line-1));return s.map((o,l)=>{if(i.has(l)){let a=o.trim();if(new RegExp("^\\w+(?:\\.\\w+|\\[[^\\]]+\\])?\\s*=\\s*\\w+(?:\\.\\w+|\\[[^\\]]+\\])?;?\\s*$").test(a))return""}return o}).filter((o,l,a)=>{if(o===""&&i.has(l)){let c=l>0&&a[l-1].trim()!=="",u=l<a.length-1&&a[l+1]&&a[l+1].trim()!=="";if(!c||!u)return!1}return!0}).join(`
51
+ `)}};var Nn={meta:{docs:"Disallow comparisons where both sides are identical",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/([\w.\[\]]+)\s*(===|!==|==|!=|<|>|<=|>=)\s*([\w.\[\]]+)/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let a=l[1].replace(/\s/g,""),c=l[2],u=l[3].replace(/\s/g,"");if(a===u)t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-self-compare",message:`Comparing '${l[1]}' to itself is potentially pointless`,severity:"error"})}}return t}};var Wn={meta:{docs:"Disallow sparse arrays (arrays with empty slots)",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\[([^\]]*)\]/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let a=l[1];if(/,\s*,/.test(a))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-sparse-arrays",message:"Unexpected sparse array",severity:"error"})}}return t},fix:(e,n)=>{let t=e.split(/\r?\n/),s=!1,i=t.map((r)=>{let o=r;return o=o.replace(/\[([^\]]*)\]/g,(l,a)=>{if(/,\s*,/.test(a))return s=!0,`[${a.replace(/,(\s*),/g,", undefined,")}]`;return l}),o});return s?i.join(`
52
+ `):e}};var Bn={meta:{docs:"Disallow undeclared variables",recommended:!0,wip:!0},check:(e,n)=>[]};var jn={meta:{docs:"Disallow unreachable code after return, throw, continue, or break",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(/^\s*(?:return|throw|break|continue)\b/.test(r))for(let l=i+1;l<s.length;l++){let a=s[l],c=a.trim();if(c===""||c.startsWith("//")||c.startsWith("/*"))continue;if(c==="}"||c.startsWith("}"))break;if(/^(?:case\b|default\s*:)/.test(c))break;t.push({filePath:n.filePath,line:l+1,column:Math.max(1,a.search(/\S/)+1),ruleId:"eslint/no-unreachable",message:"Unreachable code",severity:"error"});break}}return t}};var Un={meta:{docs:"Disallow negation of the left operand of relational operators",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/!\s*\w+\s+in\s+/g,l=/!\s*\w+\s+instanceof\s+/g,a;for(a=o.exec(r);a!==null;a=o.exec(r))t.push({filePath:n.filePath,line:i+1,column:a.index+1,ruleId:"eslint/no-unsafe-negation",message:"Unexpected negation of 'in' operand",severity:"error"});for(a=l.exec(r);a!==null;a=l.exec(r))t.push({filePath:n.filePath,line:i+1,column:a.index+1,ruleId:"eslint/no-unsafe-negation",message:"Unexpected negation of 'instanceof' operand",severity:"error"})}return t},fix:(e)=>{let n=e;return n=n.replace(/!\s*(\w+)\s+in\s+/g,"!($1 in "),n=n.replace(/!\s*(\w+)\s+instanceof\s+/g,"!($1 instanceof "),n}};var zn={meta:{docs:"Disallow unnecessary catch clauses",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.match(/catch\s*\(\s*(\w+)\s*\)/);if(!o)continue;let l=o[1];for(let a=i+1;a<Math.min(i+5,s.length);a++){let c=s[a].trim();if(c===`throw ${l}`||c===`throw ${l};`){let u=!1;for(let f=i+1;f<a;f++){let m=s[f].trim();if(m!==""&&m!=="{"&&!m.startsWith("//")){u=!0;break}}if(!u)t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf("catch")+1),ruleId:"eslint/no-useless-catch",message:"Unnecessary catch clause",severity:"error"});break}if(c==="}")break}}return t}};var qn={meta:{docs:"Require isNaN() when checking for NaN",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\b([\w.\[\]]+)\s*(===|!==|==|!=)\s*NaN\b|\bNaN\s*(===|!==|==|!=)\s*([\w.\[\]]+)/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let a=l[1]||l[4];t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/use-isnan",message:"Use isNaN() to compare with NaN",severity:"error"})}}return t},fix:(e,n)=>{let t=e.split(/\r?\n/),s=!1,i=t.map((r)=>{let o=r;return o=o.replace(/\b([\w.\[\]]+)\s*===\s*NaN\b/g,(l,a)=>(s=!0,`isNaN(${a})`)),o=o.replace(/\bNaN\s*===\s*([\w.\[\]]+)\b/g,(l,a)=>(s=!0,`isNaN(${a})`)),o=o.replace(/\b([\w.\[\]]+)\s*!==\s*NaN\b/g,(l,a)=>(s=!0,`!isNaN(${a})`)),o=o.replace(/\bNaN\s*!==\s*([\w.\[\]]+)\b/g,(l,a)=>(s=!0,`!isNaN(${a})`)),o=o.replace(/\b([\w.\[\]]+)\s*==\s*NaN\b/g,(l,a)=>(s=!0,`isNaN(${a})`)),o=o.replace(/\bNaN\s*==\s*([\w.\[\]]+)\b/g,(l,a)=>(s=!0,`isNaN(${a})`)),o=o.replace(/\b([\w.\[\]]+)\s*!=\s*NaN\b/g,(l,a)=>(s=!0,`!isNaN(${a})`)),o=o.replace(/\bNaN\s*!=\s*([\w.\[\]]+)\b/g,(l,a)=>(s=!0,`!isNaN(${a})`)),o});return s?i.join(`
53
+ `):e}};var So=["undefined","object","boolean","number","string","function","symbol","bigint"],Kn={meta:{docs:"Enforce comparing typeof expressions against valid strings",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/typeof\s+\w+\s*(?:===|!==|==|!=)\s*(['"`])(\w+)\1/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let c=l[2];if(!So.includes(c))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/valid-typeof",message:`Invalid typeof comparison value '${c}'`,severity:"error"})}let a=/(['"`])(\w+)\1\s*(?:===|!==|==|!=)\s*typeof\s+\w+/g;for(l=a.exec(r);l!==null;l=a.exec(r)){let c=l[2];if(!So.includes(c))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/valid-typeof",message:`Invalid typeof comparison value '${c}'`,severity:"error"})}}return t}};var Vn={meta:{docs:"Enforce a maximum cyclomatic complexity allowed in a program",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=10,r=!1,o=0,l="",a=0,c=0;for(let u=0;u<s.length;u++){let f=s[u],m=f.match(/\bfunction\s+(\w+)\s*\(|(\w+)\s*=\s*(?:\([^)]*\)|(\w+))\s*=>/);if(m)r=!0,o=u+1,l=m[1]||m[2]||m[3]||"anonymous",a=1,c=0;if(r){for(let d of f){if(d==="{")c++;if(d==="}"){if(c--,c===0){if(a>10)t.push({filePath:n.filePath,line:o,column:1,ruleId:"eslint/complexity",message:`Function '${l}' has complexity ${a}, exceeds maximum of 10`,severity:"error"});r=!1}}}let h=[/\bif\s*\(/,/\belse\s+if\s*\(/,/\bfor\s*\(/,/\bwhile\s*\(/,/\bcase\s+/,/\bcatch\s*\(/,/\b&&\b/,/\b\|\|\b/,/\?\s*(?:\S.*(?:[\n\r\u2028\u2029]\s*)?)?:/];for(let d of h){let p=f.match(new RegExp(d,"g"));if(p)a+=p.length}}}return t}};var Hn={meta:{docs:"Require default case in switch statements",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=0,o=!1,l=0;for(let a=0;a<s.length;a++){let c=s[a];if(c.match(/\bswitch\s*\(/))i=!0,r=a+1,o=!1,l=0;if(i){for(let u of c){if(u==="{")l++;if(u==="}"){if(l--,l===0){if(!o)t.push({filePath:n.filePath,line:r,column:1,ruleId:"eslint/default-case",message:"Expected a default case",severity:"error"});i=!1}}}if(c.match(/\bdefault\s*:/))o=!0}}return t}};var Zn={meta:{docs:"Require === and !== instead of == and !=",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/([^=!])(\s*)(==)(\s*)([^=])/g,l=/([^!])(\s*)(!=)(\s*)([^=])/g,a;for(a=o.exec(r);a!==null;a=o.exec(r))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,a.index+2),ruleId:"eslint/eqeqeq",message:"Expected '===' and instead saw '=='",severity:"error"});for(a=l.exec(r);a!==null;a=l.exec(r))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,a.index+2),ruleId:"eslint/eqeqeq",message:"Expected '!==' and instead saw '!='",severity:"error"})}return t},fix:(e)=>{let n=e;return n=n.replace(/([^!])(\s*)(!=)(\s*)([^=])/g,"$1$2!==$4$5"),n=n.replace(/([^=!])(\s*)(==)(\s*)([^=])/g,"$1$2===$4$5"),n}};var Gn={meta:{docs:"Enforce a maximum depth that blocks can be nested",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=4,r=0,o=0,l=0;for(let a=0;a<s.length;a++){let c=s[a];if(c.match(/\b(if|for|while|switch|try|catch|else)\b.*\{/)){if(r++,r>o)o=r,l=a+1}else if(c.match(/\{/)&&!c.match(/^.*\}/)){if(s[a-1]?.match(/\b(if|for|while|switch|try|catch|else)\b/)){if(r++,r>o)o=r,l=a+1}}if(c.match(/^\s*\}/))r--;if(r>4)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"eslint/max-depth",message:`Blocks are nested too deeply (${r}), maximum allowed is 4`,severity:"error"})}return t}};var Jn={meta:{docs:"Enforce a maximum number of lines of code in a function",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=50,r=!1,o=0,l="",a=0;for(let c=0;c<s.length;c++){let u=s[c],f=u.match(/\bfunction\s+(\w+)\s*\(|(\w+)\s*=\s*(?:\([^)]*\)|(\w+))\s*=>/);if(f)r=!0,o=c+1,l=f[1]||f[2]||f[3]||"anonymous",a=0;if(r)for(let m of u){if(m==="{")a++;if(m==="}"){if(a--,a===0){let h=c+1-o+1;if(h>50)t.push({filePath:n.filePath,line:o,column:1,ruleId:"eslint/max-lines-per-function",message:`Function '${l}' has ${h} lines, exceeds maximum of 50`,severity:"error"});r=!1}}}}return t}};var Yn={meta:{docs:"Disallow alert, confirm, and prompt",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\b(alert|confirm|prompt)\s*\(/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-alert",message:`Unexpected ${l[1]}`,severity:"warning"})}}return t}};var Xn={meta:{docs:"Disallow await inside of loops",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=0,o=0;for(let l=0;l<s.length;l++){let a=s[l];if(a.match(/\b(for|while|do)\s*\(/))i=!0,r=0,o=l;if(i){for(let c of a){if(c==="{")r++;if(c==="}"){if(r--,r===0)i=!1}}if(a.match(/\bawait\s+/))t.push({filePath:n.filePath,line:l+1,column:1,ruleId:"eslint/no-await-in-loop",message:"Unexpected await inside a loop. Consider using Promise.all() instead",severity:"error"})}}return t}};var Qn={meta:{docs:"Disallow use of arguments.caller or arguments.callee",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\barguments\s*\.\s*(caller|callee)\b/g,l;for(l=o.exec(r);l!==null;l=o.exec(r))t.push({filePath:n.filePath,line:i+1,column:l.index+1,ruleId:"eslint/no-caller",message:`Avoid arguments.${l[1]}`,severity:"error"})}return t}};var es={meta:{docs:"Disallow lexical declarations in case clauses",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=!1;for(let o=0;o<s.length;o++){let l=s[o];if(l.match(/\bcase\s+(?:\S.*)?:|default\s*:/))i=!0,r=!0;else r=!1;if(i&&!r&&(l.match(/\bbreak\b/)||l.match(/\bcase\s+(?:\S.*)?:/)))i=!1;if(i&&!r){if(l.match(/\b(let|const|function|class)\s+/))t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"eslint/no-case-declarations",message:"Unexpected lexical declaration in case block",severity:"error"})}}return t}};var ts={meta:{docs:"Disallow else blocks after return statements in if statements",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(!/^\s*else\b/.test(r))continue;let o=!1;for(let l=i-1;l>=0&&l>=i-10;l--){let a=s[l].trim();if(a.startsWith("return"))o=!0;if(a==="}"&&o)break;if(a.includes("{"))break}if(o)t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf("else")+1),ruleId:"eslint/no-else-return",message:"Unnecessary else after return",severity:"warning"})}return t}};var ns={meta:{docs:"Disallow empty block statements",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\{\s*\}/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let a=r.substring(0,l.index).trim(),c=/(?:if|else|for|while|do|try|catch|finally|function|\})\s*$/.test(a),u=/[=:]$/.test(a)||/return\s*$/.test(a);if(c&&!u)t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-empty",message:"Empty block statement",severity:"error"})}}for(let i=0;i<s.length-1;i++){let r=s[i],o=s[i+1];if(/\{\s*$/.test(r.trim()))for(let l=i+1;l<s.length;l++){let a=s[l].trim();if(a==="")continue;if(a==="}"||a.startsWith("}")){let c=r.substring(0,r.lastIndexOf("{")).trim(),u=/(?:if|else|for|while|do|try|catch|finally|function|\})\s*$/.test(c),f=/[=:]$/.test(c)||/return\s*$/.test(c);if(u&&!f)t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.lastIndexOf("{")+1),ruleId:"eslint/no-empty",message:"Empty block statement",severity:"error"})}break}}return t}};var ss={meta:{docs:"Disallow empty functions",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=[/function\s+\w+\s*\([^)]*\)\s*\{\s*\}/g,/function\s*\([^)]*\)\s*\{\s*\}/g,/\([^)]*\)\s*=>\s*\{\s*\}/g,/\w+\s*\([^)]*\)\s*\{\s*\}/g];for(let l of o){let a;for(a=l.exec(r);a!==null;a=l.exec(r)){if(r.substring(0,a.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,a.index+1),ruleId:"eslint/no-empty-function",message:"Unexpected empty function",severity:"warning"})}}}return t}};var is={meta:{docs:"Disallow use of eval()",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\beval\s*\(/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-eval",message:"eval can be harmful",severity:"error"})}}return t}};var rd=["Object","Array","String","Number","Boolean","Date","RegExp","Function","Math","JSON","Promise","Map","Set","WeakMap","WeakSet","Symbol","Proxy","Reflect","Error","TypeError","RangeError"],rs={meta:{docs:"Disallow extending native types",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];for(let o of rd){let l=new RegExp(`\\b${o}\\.prototype\\.\\w+\\s*=`,"g"),a;for(a=l.exec(r);a!==null;a=l.exec(r)){if(r.substring(0,a.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,a.index+1),ruleId:"eslint/no-extend-native",message:`${o} prototype is read only, properties should not be added`,severity:"error"})}}}return t}};var os={meta:{docs:"Disallow unnecessary boolean casts",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=[/\bif\s*\(\s*Boolean\s*\(/g,/\bwhile\s*\(\s*Boolean\s*\(/g,/!\s*Boolean\s*\(/g,/\?\s*Boolean\s*\(/g,/&&\s*Boolean\s*\(/g,/\|\|\s*Boolean\s*\(/g,/!!\s*\w+/g];for(let l of o){let a;for(a=l.exec(r);a!==null;a=l.exec(r)){if(r.substring(0,a.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,a.index+1),ruleId:"eslint/no-extra-boolean-cast",message:"Redundant Boolean call or double negation",severity:"error"})}}}return t},fix:(e)=>{let n=e;return n=n.replace(/\b(if|while)\s*\(\s*Boolean\s*\(([^)]+)\)\s*\)/g,"$1 ($2)"),n=n.replace(/!\s*Boolean\s*\(([^)]+)\)/g,"!$1"),n=n.replace(/!!\s*(\w+)/g,"$1"),n}};var od=["Array","Boolean","Date","Error","Function","JSON","Math","Number","Object","RegExp","String","Symbol","undefined","NaN","Infinity","isNaN","isFinite","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","eval","Promise","Proxy","Reflect","Set","Map","WeakSet","WeakMap","ArrayBuffer","DataView","console","window","document","globalThis","global","process"],ls={meta:{docs:"Disallow assignment to native objects or read-only global variables",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];for(let o of od){let l=new RegExp(`\\b${o}\\s*=\\s*[^=]`,"g"),a;for(a=l.exec(r);a!==null;a=l.exec(r))if(!r.slice(a.index).match(new RegExp(`^${o}\\s*===?`)))t.push({filePath:n.filePath,line:i+1,column:a.index+1,ruleId:"eslint/no-global-assign",message:`Read-only global '${o}' should not be modified`,severity:"error"})}}return t}};var as={meta:{docs:"Disallow implied eval() via setTimeout/setInterval with strings",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\b(setTimeout|setInterval)\s*\(\s*(['"`])/g,l;while((l=o.exec(r))!==null){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-implied-eval",message:"Implied eval. Consider passing a function instead of a string",severity:"error"})}}return t}};var cs={meta:{docs:"Disallow the use of the __iterator__ property",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/__iterator__/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-iterator",message:"Reserved name '__iterator__'",severity:"error"})}}return t}};var Ft={meta:{docs:"Disallow if statements as the only statement in else blocks",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(/^\s*else\s*(?:\{\s*)?$/.test(r)){let l=i,a=r.includes("{");if(!a){if(i+1<s.length&&s[i+1].trim()==="{")l=i+1,a=!0}if(a)for(let c=l+1;c<s.length;c++){let u=s[c].trim();if(u===""||u.startsWith("//")||u.startsWith("/*"))continue;if(u==="}")break;if(u.startsWith("if ")||u.startsWith("if(")){let f=!0,m=0,h=!1;for(let d=c;d<s.length;d++){let p=s[d];if(m+=(p.match(/\{/g)||[]).length,m-=(p.match(/\}/g)||[]).length,d===c){h=!0;continue}if(m===0){for(let g=d+1;g<s.length;g++){let y=s[g].trim();if(y===""||y.startsWith("//"))continue;if(y==="}"||y.startsWith("}"))break;else f=!1;break}break}}if(h&&f)t.push({filePath:n.filePath,line:c+1,column:Math.max(1,s[c].indexOf("if")+1),ruleId:"eslint/no-lonely-if",message:"Unexpected if as the only statement in an else block",severity:"warning"})}break}}}return t},fix:(e,n)=>{if(Ft.check(e,n).length===0)return e;return e}};var us={meta:{docs:"Disallow new operators outside of assignments or comparisons",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(/^\s*new\s+\w+\s*\(/.test(r)){if(!/[=:]/.test(r.substring(0,r.indexOf("new"))))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf("new")+1),ruleId:"eslint/no-new",message:"Do not use 'new' for side effects",severity:"warning"})}}return t}};var fs={meta:{docs:"Disallow new Function() declarations",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\bnew\s+Function\s*\(/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-new-func",message:"The Function constructor is eval",severity:"error"})}}return t}};var ms={meta:{docs:"Disallow new operators with String, Number, and Boolean",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\bnew\s+(String|Number|Boolean)\s*\(/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-new-wrappers",message:`Do not use ${l[1]} as a constructor`,severity:"error"})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=!1,s=n.map((i)=>{if(i.trim().startsWith("//")||i.trim().startsWith("/*"))return i;return i.replace(/\bnew\s+(String|Number|Boolean)\s*\(/g,(o,l)=>(t=!0,`${l}(`))});return t?s.join(`
54
+ `):e}};var hs={meta:{docs:"Disallow octal literals",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\b0[0-7]+\b/g,l;for(l=o.exec(r);l!==null;l=o.exec(r))t.push({filePath:n.filePath,line:i+1,column:l.index+1,ruleId:"eslint/no-octal",message:"Octal literals should not be used",severity:"error"})}return t}};var ds={meta:{docs:"Disallow reassignment of function parameters",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=new Map;for(let r=0;r<s.length;r++){let o=s[r],l=[...o.matchAll(/function\s+(?:(\w+)\s*)?\(([^)]*)\)/g),...o.matchAll(/(?:const|let|var)?\s*(\w+)\s*=\s*\(([^)]*)\)\s*=>/g),...o.matchAll(/(?:const|let|var)?\s*(\w+)\s*=\s*(\w+)\s*=>/g)];for(let a of l){let c=a[2]?a[2].split(",").map((f)=>f.trim().split(/[=:]/)[0].trim()):[],u=`line-${r}`;if(c.length>0)i.set(u,new Set(c.filter((f)=>f&&/^\w+$/.test(f))))}for(let[a,c]of i.entries())for(let u of c){let f=new RegExp(`\\b${u}\\s*=\\s*[^=]`,"g"),m;for(m=f.exec(o);m!==null;m=f.exec(o))if(!o.slice(m.index).match(/^\w+\s*===?/))t.push({filePath:n.filePath,line:r+1,column:m.index+1,ruleId:"eslint/no-param-reassign",message:`Assignment to function parameter '${u}'`,severity:"error"})}}return t}};var ps={meta:{docs:"Disallow use of __proto__",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/__proto__/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-proto",message:"The '__proto__' property is deprecated",severity:"error"})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=!1,s=n.map((i)=>{if(i.trim().startsWith("//")||i.trim().startsWith("/*"))return i;return i.replace(/(\w+)\.__proto__/g,(o,l)=>(t=!0,`Object.getPrototypeOf(${l})`))});return t?s.join(`
55
+ `):e}};var gs={meta:{docs:"Disallow assignment operators in return statements",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\breturn\s[^;]*\b\w+\s*=\s*(?!=)/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let a=l[0];if(/===|==/.test(a))continue;if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-return-assign",message:"Return statement should not contain assignment",severity:"error"})}}return t}};var ys={meta:{docs:"Disallow comma operators",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\)\s*,\s*\w+\s*\(/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+l[0].indexOf(",")+1),ruleId:"eslint/no-sequences",message:"Unexpected use of comma operator",severity:"warning"})}}return t}};var bs={meta:{docs:"Disallow variable declarations from shadowing variables declared in the outer scope",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=[new Set];for(let o=0;o<s.length;o++){let l=s[o];if(l.match(/\bfunction\s+\w+\s*\(|=>\s*\{|\{\s*$/))r.push(new Set);let a=[...l.matchAll(/\b(const|let|var)\s+(\w+)/g),...l.matchAll(/function\s+(\w+)\s*\(/g)];for(let c of a){let u=c[2]||c[1];for(let f=0;f<r.length-1;f++)if(r[f].has(u)){t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"eslint/no-shadow",message:`'${u}' is already declared in the upper scope`,severity:"error"});break}r[r.length-1].add(u)}if(l.match(/^\s*\}\s*$/)){if(r.length>1)r.pop()}}return t}};var xs={meta:{docs:"Disallow throwing literals as exceptions",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=[{pattern:/\bthrow\s+(['"`][^'"`]*['"`])/g,type:"string"},{pattern:/\bthrow\s+(\d+)/g,type:"number"},{pattern:/\bthrow\s+(true|false|null|undefined)/g,type:"literal"}];for(let{pattern:l,type:a}of o){let c;while((c=l.exec(r))!==null){if(r.substring(0,c.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,c.index+1),ruleId:"eslint/no-throw-literal",message:`Expected an error object to be thrown, got ${a} literal`,severity:"error"})}}}return t}};var ws={meta:{docs:"Disallow the use of variables before they are defined",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=new Map;for(let r=0;r<s.length;r++){let o=s[r],l=[...o.matchAll(/\b(const|let|var)\s+(\w+)/g),...o.matchAll(/\bfunction\s+(\w+)\s*\(/g),...o.matchAll(/\bclass\s+(\w+)/g)];for(let a of l){let c=a[2]||a[1];if(!i.has(c))i.set(c,r+1)}}for(let r=0;r<s.length;r++){let o=s[r];if(o.match(/\b(const|let|var|function|class)\s+\w+/))continue;let l=o.matchAll(/\b(\w+)\b/g);for(let a of l){let c=a[1],u=i.get(c);if(u&&u>r+1)t.push({filePath:n.filePath,line:r+1,column:a.index+1,ruleId:"eslint/no-use-before-define",message:`'${c}' was used before it was defined`,severity:"error"})}}return t}};var Rs={meta:{docs:"Disallow unnecessary .call() and .apply()",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\.\s*call\s*\(\s*(undefined|null)\s*,/g,l=/\.\s*apply\s*\(\s*(undefined|null)\s*,/g,a;for(a=o.exec(r);a!==null;a=o.exec(r))t.push({filePath:n.filePath,line:i+1,column:a.index+1,ruleId:"eslint/no-useless-call",message:"Unnecessary '.call()'",severity:"error"});for(a=l.exec(r);a!==null;a=l.exec(r))t.push({filePath:n.filePath,line:i+1,column:a.index+1,ruleId:"eslint/no-useless-call",message:"Unnecessary '.apply()'",severity:"error"})}return t}};var ks={meta:{docs:"Disallow unnecessary concatenation of literals or template literals",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=[/(['"`])([^'"`]*)\1\s*\+\s*\1([^'"`]*)\1/g];for(let l of o){let a;while((a=l.exec(r))!==null){if(r.substring(0,a.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,a.index+1),ruleId:"eslint/no-useless-concat",message:"Unexpected string concatenation of literals",severity:"warning"})}}}return t},fix:(e)=>{let n=e;return n=n.replace(/(['"`])([^'"`]*)\1\s*\+\s*\1([^'"`]*)\1/g,"$1$2$3$1"),n}};var Eo=["/","(",")","[","]","{","}","<",">",":","@","#","$","%","&","=","+","-","*","?","!",";",",","|","~","`","^"],$s={meta:{docs:"Disallow unnecessary escape characters",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];for(let o of Eo){let l=`\\${o}`,a=new RegExp(`(['"\`])[^'"\`]*${l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}`,"g"),c;while((c=a.exec(r))!==null){let u=c.index,f=r.indexOf(l,u);if(f>u)t.push({filePath:n.filePath,line:i+1,column:Math.max(1,f+1),ruleId:"eslint/no-useless-escape",message:`Unnecessary escape character: \\${o}`,severity:"warning"})}}}return t},fix:(e)=>{let n=e;for(let t of Eo){let s=`\\${t}`;n=n.replace(new RegExp(s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),t)}return n}};var Ps={meta:{docs:"Disallow renaming import, export, and destructured assignments to the same name",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/import\s*\{[^}]*\b(\w+)\s+as\s+\1\b[^}]*\}/g,l;for(l=o.exec(r);l!==null;l=o.exec(r))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming import '${l[1]}' to '${l[1]}' is redundant`,severity:"error"});let a=/export\s*\{[^}]*\b(\w+)\s+as\s+\1\b[^}]*\}/g;for(l=a.exec(r);l!==null;l=a.exec(r))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming export '${l[1]}' to '${l[1]}' is redundant`,severity:"error"});let c=/\{[^}]*\b(\w+)\s*:\s*\1\b[^}]*\}\s*=/g;for(l=c.exec(r);l!==null;l=c.exec(r))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming destructured property '${l[1]}' to '${l[1]}' is redundant`,severity:"error"})}return t},fix:(e)=>{let n=e;return n=n.replace(/\b(\w+)\s+as\s+\1\b/g,"$1"),n=n.replace(/\{([^}]*)\b(\w+)\s*:\s*\2\b([^}]*)\}/g,"{$1$2$3}"),n}};var Nt={meta:{docs:"Disallow redundant return statements",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(o==="return"||o==="return;"){let l=!1;for(let a=i+1;a<s.length;a++){let c=s[a].trim();if(c===""||c.startsWith("//")||c.startsWith("/*"))continue;if(c==="}"||c.startsWith("}"))l=!0;break}if(l)t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf("return")+1),ruleId:"eslint/no-useless-return",message:"Unnecessary return statement",severity:"warning"})}}return t},fix:(e,n)=>{let t=Nt.check(e,n);if(t.length===0)return e;let s=e.split(/\r?\n/),i=new Set(t.map((o)=>o.line-1));return s.filter((o,l)=>!i.has(l)).join(`
56
+ `)}};var vs={meta:{docs:"Require let or const instead of var",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\bvar\s+/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-var",message:"Unexpected var, use let or const instead",severity:"error"})}}return t},fix:(e,n)=>e.split(/\r?\n/).map((i)=>{if(i.trim().startsWith("//")||i.trim().startsWith("/*"))return i;return i.replace(/\bvar\s+/g,"let ")}).join(`
57
+ `)};var Is={meta:{docs:"Disallow with statements",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\bwith\s*\(/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-with",message:"Unexpected use of 'with' statement",severity:"error"})}}return t}};var Ms={meta:{docs:"Require using arrow functions for callbacks",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\.(map|filter|reduce|forEach|some|every|find|findIndex)\s*\(\s*function\s*\(/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/prefer-arrow-callback",message:"Unexpected function expression, use arrow function instead",severity:"warning"})}}return t}};var Cs={meta:{docs:"Disallow async functions which have no await expression",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++)if(s[i].match(/\basync\s+(?:function\s+\w+|(?:\(|\w+)\s*(?:\(|=>))/)){let l=!1,a=0,c=!1,u=i;while(u<s.length){let f=s[u];for(let m of f){if(m==="{")a++,c=!0;if(m==="}"){if(a--,a===0&&c)break}}if(f.match(/\bawait\s+/))l=!0;if(a===0&&c){if(!l)t.push({filePath:n.filePath,line:i+1,column:1,ruleId:"eslint/require-await",message:"Async function has no await expression",severity:"error"});break}u++}}return t}};var Lo=/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/;function b(e){return{meta:e.meta,check:(n,t)=>{if(!Lo.test(t.filePath))return[];return e.check(n,t)},fix:e.fix?(n,t)=>{if(!Lo.test(t.filePath))return n;return e.fix(n,t)}:void 0}}var To=/\.(?:sh|bash|zsh|ksh|dash)$/,Ao=/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/;function he(e){return{meta:e.meta,check:(n,t)=>{if(!To.test(t.filePath)&&!Ao.test(n))return[];return e.check(n,t)},fix:e.fix?(n,t)=>{if(!To.test(t.filePath)&&!Ao.test(n))return n;return e.fix(n,t)}:void 0}}var Oo=/(?:^|[/\\])package\.json$/;function pe(e){return{meta:e.meta,check:(n,t)=>{if(!Oo.test(t.filePath))return[];return e.check(n,t)},fix:e.fix?(n,t)=>{if(!Oo.test(t.filePath))return n;return e.fix(n,t)}:void 0}}var _o={name:"eslint",rules:{"array-callback-return":b(kn),"constructor-super":b($n),"for-direction":b(Pn),"getter-return":b(vn),"no-async-promise-executor":b(In),"no-compare-neg-zero":b(Mn),"no-cond-assign":b(Cn),"no-constant-condition":b(En),"no-const-assign":b(Sn),"no-dupe-class-members":b(Ln),"no-dupe-keys":b(_t),"no-duplicate-case":b(Tn),"no-empty-pattern":b(An),"no-fallthrough":b(On),"no-loss-of-precision":b(_n),"no-promise-executor-return":b(Dn),"no-redeclare":b(Fn),"no-self-assign":b(Dt),"no-self-compare":b(Nn),"no-sparse-arrays":b(Wn),"no-undef":b(Bn),"no-unsafe-negation":b(Un),"no-unreachable":b(jn),"no-useless-catch":b(zn),"use-isnan":b(qn),"valid-typeof":b(Kn),"default-case":b(Hn),eqeqeq:b(Zn),"no-alert":b(Yn),"no-await-in-loop":b(Xn),"no-caller":b(Qn),"no-case-declarations":b(es),"no-else-return":b(ts),"no-empty":b(ns),"no-empty-function":b(ss),"no-eval":b(is),"no-extend-native":b(rs),"no-global-assign":b(ls),"no-implied-eval":b(as),"no-iterator":b(cs),"no-new":b(us),"no-new-func":b(fs),"no-new-wrappers":b(ms),"no-octal":b(hs),"no-param-reassign":b(ds),"no-proto":b(ps),"no-return-assign":b(gs),"no-shadow":b(bs),"no-throw-literal":b(xs),"no-use-before-define":b(ws),"no-useless-call":b(Rs),"no-with":b(Is),"require-await":b(Cs),complexity:b(Vn),"max-depth":b(Gn),"max-lines-per-function":b(Jn),"no-extra-boolean-cast":b(os),"no-lonely-if":b(Ft),"no-sequences":b(ys),"no-useless-concat":b(ks),"no-useless-escape":b($s),"no-useless-rename":b(Ps),"no-useless-return":b(Nt),"no-var":b(vs),"prefer-arrow-callback":b(Ms)}};var Do={meta:{docs:"Disallow return statements in constructors - constructors automatically return the instance"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.indexOf("//");if(!(o>=0?r.slice(0,o):r).match(/\bconstructor\s*\(/))continue;let c=0,u=!1,f=-1;for(let m=i;m<s.length;m++){let h=s[m],d=null,p=!1;for(let g=0;g<h.length;g++){let y=h[g];if(p){p=!1;continue}if(y==="\\"&&d){p=!0;continue}if(!d){if(y==="'")d="single";else if(y==='"')d="double";else if(y==="`")d="template";else if(y==="{")c++,u=!0;else if(y==="}"){if(c--,u&&c===0){f=m;break}}}else if(d==="single"&&y==="'"||d==="double"&&y==='"'||d==="template"&&y==="`")d=null}if(f!==-1)break}if(f===-1)continue;for(let m=i;m<=f;m++){let h=s[m];if(m===i)continue;if(/^\s*\/\//.test(h))continue;let d=h.indexOf("//"),p=d>=0?h.slice(0,d):h;if(p=p.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),p.match(/\breturn\b/)){let y=p.indexOf("return"),x=y>0?p[y-1]:" ",k=y+6<p.length?p[y+6]:" ";if(/\w/.test(x)||/\w/.test(k))continue;let v=p.slice(y+6).trim();if(v.startsWith("this;")||v==="this")continue;if(v===";"||v==="")continue;let w=h.indexOf("return");t.push({filePath:n.filePath,line:m+1,column:w+1||1,ruleId:"no-constructor-return",message:"Unexpected return statement in constructor. Constructors should not return values.",severity:"error",help:"Remove the return statement or move the logic outside of the constructor"})}}}return t}};var Fo={meta:{docs:"Disallow irregular whitespace characters that may cause issues in code"},check:(e,n)=>{let t=[],s=/[\u00A0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/g,i=e.split(/\r?\n/);for(let r=0;r<i.length;r++){let o=i[r],l;s.lastIndex=0;while((l=s.exec(o))!==null){let c=l[0].charCodeAt(0),u="irregular whitespace",f={160:"NO-BREAK SPACE",5760:"OGHAM SPACE MARK",6158:"MONGOLIAN VOWEL SEPARATOR",8192:"EN QUAD",8193:"EM QUAD",8194:"EN SPACE",8195:"EM SPACE",8196:"THREE-PER-EM SPACE",8197:"FOUR-PER-EM SPACE",8198:"SIX-PER-EM SPACE",8199:"FIGURE SPACE",8200:"PUNCTUATION SPACE",8201:"THIN SPACE",8202:"HAIR SPACE",8232:"LINE SEPARATOR",8233:"PARAGRAPH SEPARATOR",8239:"NARROW NO-BREAK SPACE",8287:"MEDIUM MATHEMATICAL SPACE",12288:"IDEOGRAPHIC SPACE",65279:"ZERO WIDTH NO-BREAK SPACE"};if(f[c])u=f[c];t.push({filePath:n.filePath,line:r+1,column:l.index+1,ruleId:"no-irregular-whitespace",message:`Irregular whitespace detected: ${u} (U+${c.toString(16).toUpperCase().padStart(4,"0")})`,severity:"error",help:"Replace irregular whitespace with regular spaces or tabs"})}}return t},fix:(e)=>e.replace(/[\u00A0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/g," ")};var No={meta:{docs:"Disallow new operators outside of assignments or comparisons",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(o.startsWith("//")||o.startsWith("/*")||o.startsWith("*"))continue;if(/^\s*new\s+\w+/.test(r)){let a=/^\s*(?:const|let|var|this\.\w+)\s*=\s*new\s+/,c=/^\s*return\s+new\s+/,u=new RegExp("^\\s*new\\s+\\w[^;]*,"),f=/[=:,(]\s*new\s+/;if(!a.test(r)&&!c.test(r)&&!u.test(r)&&!f.test(o)){let m=r.search(/new\s+/)+1;t.push({filePath:n.filePath,line:i+1,column:m,ruleId:"no-new",message:"Do not use 'new' for side effects",severity:"error",help:"Either assign the result to a variable or remove the 'new' operator if the side effect is intentional."})}}}return t}};var Wo={meta:{docs:"Disallow multiple spaces in regular expressions",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(/^\s*\/\//.test(r))continue;let o=/\/(?![*/])((?:\\.|[^/\\])+)\/[gimsuvy]*/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let c=l[1];if(/ {2,}/.test(c)){let u=l.index+1;t.push({filePath:n.filePath,line:i+1,column:u,ruleId:"no-regex-spaces",message:"Multiple spaces in regular expression",severity:"error",help:"Use quantifiers like {2} instead of multiple spaces for clarity."})}}let a=/new\s+RegExp\s*\(\s*['"`]([^'"`]+)['"`]/g;for(l=a.exec(r);l!==null;l=a.exec(r)){let c=l[1];if(/ {2,}/.test(c)){let u=l.index+1;t.push({filePath:n.filePath,line:i+1,column:u,ruleId:"no-regex-spaces",message:"Multiple spaces in regular expression",severity:"error",help:"Use quantifiers like {2} instead of multiple spaces for clarity."})}}}return t}};var Bo=new Set(["|","&",":",",","<"]),ld=new Set(["(",",","=",":","[","!","&","|","?","{","}",";","+","-","*","%","<",">","~","^"]),ad=["return","typeof","instanceof","in","of","new","delete","void","case","do","else","yield","await"];function cd(e,n){let t=n-1;while(t>=0&&/\s/.test(e[t]))t-=1;if(t<0)return!0;let s=e[t];if(ld.has(s))return!0;if(/[\w$)\]]/.test(s)){if(/[\w$]/.test(s)){let i=t;while(i>=0&&/[\w$]/.test(e[i]))i-=1;let r=e.slice(i+1,t+1);return ad.includes(r)}return!1}return!0}function Ss(e,n){if(e[n+1]==="/"||e[n+1]==="*")return!1;let t=e.slice(0,n).trimEnd();return!t||/[=([{,:;!&|?]$/.test(t)||t.endsWith("=>")||t.endsWith("return")}function ud(e){let n=e.split(""),t=0,s=null,i=!1,r=[],o=()=>r.length>0&&r[r.length-1]===-1,l=()=>r.length>0&&r[r.length-1]>=0,a=(c,u)=>{for(let f=c;f<u&&f<n.length;f+=1)if(n[f]!==`
58
+ `&&n[f]!=="\r")n[f]=" "};while(t<e.length){let c=e[t];if(s){if(i)i=!1;else if(c==="\\")i=!0;else if(c===s)s=null;else if(c===`
59
+ `)s=null;t+=1;continue}if(o()){if(i)i=!1;else if(c==="\\")i=!0;else if(c==="`")r.pop();else if(c==="$"&&e[t+1]==="{")r.push(0),t+=1;t+=1;continue}if(c==="`"){r.push(-1),t+=1;continue}if(l()){if(c==="{"){r[r.length-1]+=1,t+=1;continue}if(c==="}"){let u=r[r.length-1];if(u>0)r[r.length-1]=u-1;else r.pop();t+=1;continue}}if(c==="'"||c==='"'){s=c,t+=1;continue}if(c==="/"&&e[t+1]!=="/"&&e[t+1]!=="*"&&cd(e,t)){let u=t+1,f=!1,m=!1;while(u<e.length){let h=e[u];if(m)m=!1;else if(h==="\\")m=!0;else if(h==="[")f=!0;else if(h==="]")f=!1;else if(h===`
60
+ `)break;else if(h==="/"&&!f){u+=1;break}u+=1}t=u;continue}if(c==="/"&&e[t+1]==="/"){let u=e.indexOf(`
61
+ `,t);a(t+2,u<0?e.length:u),t=u<0?e.length:u;continue}if(c==="/"&&e[t+1]==="*"){let u=e.indexOf("*/",t+2);a(t+2,u<0?e.length:u),t=u<0?e.length:u+2;continue}t+=1}return n.join("")}var Ye={meta:{docs:"Report variables and parameters that are declared/assigned but never used"},check:(e,n)=>{if(n.filePath.endsWith("/no-unused-vars.ts"))return[];if(n.filePath.endsWith(".d.ts"))return[];let t=[],s=n.options||{},i=typeof s.varsIgnorePattern==="string"?s.varsIgnorePattern:"^_",r=typeof s.argsIgnorePattern==="string"?s.argsIgnorePattern:"^_",o=new RegExp(i,"u"),l=new RegExp(r,"u"),a=ud(e),c=a.split(/\r?\n/),u=a,f=Array(c.length).fill(!1);(()=>{let w=[],M=!1,L=!1,_=!1,C=!1,D=!1,T="",E=()=>{if(T==="")return!0;if("=([{,;!&|?:+-*/%^~<>".includes(T))return!0;return!1};for(let S=0;S<c.length;S++){f[S]=w.length>0&&w[w.length-1]===-1;let O=c[S];for(let A=0;A<O.length;A++){let R=O[A];if(C){if(R==="*"&&A+1<O.length&&O[A+1]==="/")C=!1,A++;continue}if(D){D=!1;continue}let I=w.length>0&&w[w.length-1]===-1,P=w.length>0&&w[w.length-1]>=0;if(R==="\\"&&(M||L||_||I)){D=!0;continue}if(M){if(R==="'")M=!1;continue}if(L){if(R==='"')L=!1;continue}if(_){if(R==="["){let F=1,N=A+1;while(N<O.length){let J=O[N];if(J==="\\"){N+=2;continue}if(J==="]"){if(F--,F===0)break}N++}A=N;continue}if(R==="/"){_=!1;while(A+1<O.length&&/[gimsuvy]/.test(O[A+1]))A++}continue}if(I){if(R==="`")w.pop();else if(R==="$"&&A+1<O.length&&O[A+1]==="{")w.push(0),A++;continue}if(R==="/"&&A+1<O.length&&O[A+1]==="/")break;if(R==="/"&&A+1<O.length&&O[A+1]==="*"){C=!0,A++;continue}if(P){if(R==="`")w.push(-1),T="";else if(R==="'")M=!0,T="'";else if(R==='"')L=!0,T='"';else if(R==="{")w[w.length-1]++,T="{";else if(R==="}"){let F=w[w.length-1];if(F>0)w[w.length-1]=F-1;else w.pop();T="}"}else if(R==="/"&&E())_=!0;else if(!/\s/.test(R))T=R;continue}if(R==="`")w.push(-1),T="";else if(R==="'")M=!0,T="'";else if(R==='"')L=!0,T='"';else if(R==="/"&&E())_=!0;else if(!/\s/.test(R))T=R}}})();let h=new RegExp("^\\s*(?:const|let|var)\\s+(.+?);?\\s*$");for(let w=0;w<c.length;w++){if(f[w])continue;let M=c[w],L=M.match(h);if(!L)continue;let _=L[1],C=[],D="",T=0,E=0,S=null,O=!1;for(let A=0;A<_.length;A++){let R=_[A];if(O){O=!1,D+=R;continue}if(R==="\\"&&S){O=!0,D+=R;continue}if(!S){if(R==="/"&&_[A+1]==="/")break;if(R==="/"&&_[A+1]==="*"){A+=2;while(A<_.length&&!(_[A]==="*"&&_[A+1]==="/"))A++;A++;continue}if(R==="'")S="single";else if(R==='"')S="double";else if(R==="`")S="template";else if(R==="<")E++;else if(R===">")E--;else if(R==="("||R==="["||R==="{")T++;else if(R===")"||R==="]"||R==="}")T--;else if(R===","&&T===0&&E===0){C.push(D),D="";continue}}else if(S==="single"&&R==="'"||S==="double"&&R==='"'||S==="template"&&R==="`")S=null;D+=R}if(D)C.push(D);for(let A of C){let R=A.trim();if(!R)continue;let I=R.match(/^([$A-Z_][\w$]*)/i),P=[];if(I)P.push(I[1]);else if(R.startsWith("{")||R.startsWith("[")){let F=R[0],N=F==="{"?"}":"]",J=0,V=-1,j=null,B=!1;for(let Y=0;Y<R.length;Y++){let q=R[Y];if(B){B=!1;continue}if(q==="\\"&&j){B=!0;continue}if(!j){if(q==="'"||q==='"'||q==="`")j=q==="'"?"single":q==='"'?"double":"template";else if(q===F)J++;else if(q===N){if(J--,J===0){V=Y;break}}}else if(j==="single"&&q==="'"||j==="double"&&q==='"'||j==="template"&&q==="`")j=null}if(V>0){let Y=R.slice(1,V),q=[],te="",de=0,U=null,Z=!1;for(let H=0;H<Y.length;H++){let z=Y[H];if(Z){Z=!1,te+=z;continue}if(z==="\\"&&U){Z=!0,te+=z;continue}if(!U){if(z==="'"||z==='"'||z==="`"){U=z==="'"?"single":z==='"'?"double":"template",te+=z;continue}if(z==="("||z==="{"||z==="[")de++;if(z===")"||z==="}"||z==="]")de--;if(z===","&&de===0){q.push(te.trim()),te="";continue}}else if(U==="single"&&z==="'"||U==="double"&&z==='"'||U==="template"&&z==="`")U=null;te+=z}if(te.trim())q.push(te.trim());for(let H of q){if(H.startsWith("...")){let we=H.slice(3).match(/^([$A-Z_][\w$]*)/i);if(we)P.push(we[1]);continue}let z=H.indexOf(":");if(z!==-1){let we=H.slice(z+1).trim(),ge=0;for(let je=0;je<we.length;je++){let Ie=we[je];if(Ie==="("||Ie==="{"||Ie==="[")ge++;else if(Ie===")"||Ie==="}"||Ie==="]")ge--;else if(Ie==="="&&ge===0){we=we.slice(0,je).trim();break}}let St=we.match(/^([$A-Z_][\w$]*)/i);if(St)P.push(St[1])}else{let we=H,ge=0;for(let je=0;je<we.length;je++){let Ie=we[je];if(Ie==="("||Ie==="{"||Ie==="[")ge++;else if(Ie===")"||Ie==="}"||Ie==="]")ge--;else if(Ie==="="&&ge===0){we=we.slice(0,je).trim();break}}let St=we.match(/^([$A-Z_][\w$]*)/i);if(St)P.push(St[1])}}}}for(let F of P){if(o.test(F))continue;let N=`${c.slice(0,w).join(`
62
+ `)}
63
+ ${c.slice(w+1).join(`
64
+ `)}`;if(!new RegExp(`\\b${F}\\b`,"g").test(N))t.push({filePath:n.filePath,line:w+1,column:Math.max(1,M.indexOf(F)+1),ruleId:"pickier/no-unused-vars",message:`'${F}' is assigned a value but never used. Allowed unused vars must match pattern: ${i}`,severity:"error",help:`Either use this variable in your code, remove it, or prefix it with an underscore (_${F}) to mark it as intentionally unused`})}}}let d=(w)=>{let L=((D)=>{let T="",E=null,S=!1,O=0;for(let A=0;A<D.length;A++){let R=D[A];if(S){S=!1;continue}if(R==="\\"&&E){S=!0;continue}if(!E){if(R==="'")E="single";else if(R==='"')E="double";else if(R==="`")E="template";else if(R==="("||R==="{"||R==="[")O++;else if(R===")"||R==="}"||R==="]")O--;else if(R==="="&&O===0)return T}else if(E==="single"&&R==="'"||E==="double"&&R==='"'||E==="template"&&R==="`")E=null;T+=R}return T})(w);return((D)=>{let T="",E=0;while(E<D.length){let S=D[E];if(S===":"){E++;while(E<D.length&&/\s/.test(D[E]))E++;let O=0,A=0,R=null,I=!1;while(E<D.length){let P=D[E];if(I){I=!1,E++;continue}if(P==="\\"&&R){I=!0,E++;continue}if(!R){if(P==="'")R="single";else if(P==='"')R="double";else if(P==="`")R="template";else if(P==="<")A++;else if(P===">")A--;else if(P==="("||P==="{"||P==="[")O++;else if(P===")"||P==="}"||P==="]")if(O>0)O--;else break;else if(P===","&&O===0&&A===0)break}else if(R==="single"&&P==="'"||R==="double"&&P==='"'||R==="template"&&P==="`")R=null;E++}continue}T+=S,E++}return T})(L).split(/[^$\w]+/).filter((D)=>D&&D!=="undefined")},p=(w,M)=>{let L=!1,_=0,C=0,D=!1,T=0,E=null,S=!1,O=!0,A="",R=!1,I=!1,P=[],F=!1;for(let N=w;N<c.length;N++){let J=c[N],V=J,j=P.length>0&&P[P.length-1]===-1,B=-1,Y=null,q=!1;if(!j)for(let U=0;U<J.length-1;U++){let Z=J[U],H=J[U+1];if(q){q=!1;continue}if(Z==="\\"&&Y){q=!0;continue}if(!Y){if(Z==="'")Y="single";else if(Z==='"')Y="double";else if(Z==="`")Y="template";else if(Z==="/"&&H==="/"){B=U;break}}else if(Y==="single"&&Z==="'"||Y==="double"&&Z==='"'||Y==="template"&&Z==="`")Y=null}if(B>=0)V=J.slice(0,B);let te=(U)=>{let Z="",H=0,z=null,we=!1;while(H<U.length){let ge=U[H];if(we){we=!1,Z+=ge,H++;continue}if(ge==="\\"&&z){we=!0,Z+=ge,H++;continue}if(!z){if(ge==="'")z="single";else if(ge==='"')z="double";else if(ge==="`")z="template";else if(ge==="/"){if(Ss(U,H)){H++;while(H<U.length){if(U[H]==="\\"){H+=2;continue}if(U[H]==="/"){H++;while(H<U.length&&/[gimsuvy]/.test(U[H]))H++;break}H++}continue}}}else if(z==="single"&&ge==="'"||z==="double"&&ge==='"'||z==="template"&&ge==="`")z=null;Z+=ge,H++}return Z};if(!j)V=te(V);let de=0;if(!L){let U=-1,Z=O?typeof M==="number"?M:0:0;if(O=!1,Z>=V.length){let H=V.indexOf("=>");Z=H>=0?H+2:0}for(let H=Z;H<V.length;H++){let z=V[H];if(S){S=!1;continue}if(z==="\\"&&E){S=!0;continue}if(!E){if(z!==" "&&z!=="\t"&&z!==`
65
+ `&&z!=="\r"&&z!=="{"&&z!=="}"&&C===0)A=z;if(z==="'")E="single";else if(z==='"')E="double";else if(z==="`")E="template";else if(z==="<")T++;else if(z===">")T=Math.max(0,T-1);else if(z==="{"){if(C===0){if(D&&T===0&&!Bo.has(A)){U=H;break}}C++}else if(z==="}"){if(C>0){if(C--,C===0)D=!0,A="}"}}}else if(E==="single"&&z==="'"||E==="double"&&z==='"'||E==="template"&&z==="`")E=null}if(U===-1){if(T>0)continue;if(C>0&&Bo.has(A))continue;for(let H=Z;H<V.length;H++)if(V[H]==="{"&&!E){U=H;break}}if(U===-1)continue;L=!0,_=1,de=U+1,w=N}for(let U=de;U<V.length;U++){let Z=V[U];if(F){F=!1;continue}let H=P.length>0&&P[P.length-1]===-1,z=P.length>0&&P[P.length-1]>=0;if(Z==="\\"&&(R||I||H)){F=!0;continue}if(R){if(Z==="'")R=!1;continue}if(I){if(Z==='"')I=!1;continue}if(H){if(Z==="`")P.pop();else if(Z==="$"&&U+1<V.length&&V[U+1]==="{")P[P.length-1]=0,U++;continue}if(z){if(Z==="/"){if(Ss(V,U)){U++;while(U<V.length){if(V[U]==="\\"){U+=2;continue}if(V[U]==="/"){while(U+1<V.length&&/[gimsuvy]/.test(V[U+1]))U++;break}U++}continue}}if(Z==="`"){P.push(-1);continue}if(Z==="'"){R=!0;continue}if(Z==='"'){I=!0;continue}if(Z==="{"){P[P.length-1]++;continue}if(Z==="}")if(P[P.length-1]>0)P[P.length-1]--;else P[P.length-1]=-1;continue}if(Z==="'")R=!0;else if(Z==='"')I=!0;else if(Z==="`")P.push(-1);else if(Z==="{")_++;else if(Z==="}"){if(_--,_===0)return{from:w,to:N}}}}return null},g=(w,M)=>{let L={parenDepth:0,braceDepth:0,bracketDepth:0,inTemplate:!1},_=(O)=>{for(let A=0;A<O.length;A++){let R=O[A];if(R==="`")L.inTemplate=!L.inTemplate;else if(R==="(")L.parenDepth++;else if(R===")")L.parenDepth--;else if(R==="{")L.braceDepth++;else if(R==="}")L.braceDepth--;else if(R==="[")L.bracketDepth++;else if(R==="]")L.bracketDepth--}},C=()=>L.parenDepth>0||L.braceDepth>0||L.bracketDepth>0||L.inTemplate,D=(O)=>/(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)$/.test(O.trimEnd()),T=(O)=>/^(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)/.test(O.trimStart()),E=c[w].slice(M+2);_(E);let S=w+1;while(S<c.length){let O=S===w+1?E:c[S-1];if(!(!E.trim()||C()||D(O)||T(c[S])))break;E+=`
66
+ ${c[S]}`,_(c[S]),S++}return E},y=[],x=!1,k=!1,v=!1;for(let w=0;w<c.length;w++){let M=c[w];if(/^\s*\/\//.test(M))continue;if(f[w])continue;let L=M,_=null,C=!1,D=!1;for(let R=0;R<M.length-1;R++){let I=M[R],P=M[R+1];if(D){D=!1;continue}if(I==="\\"&&(_||C)){D=!0;continue}if(!_&&!C){if(I==="'")_="single";else if(I==='"')_="double";else if(I==="`")_="template";else if(I==="/"){if(Ss(M,R))C=!0;else if(P==="/"){L=M.slice(0,R);break}}}else if(_){if(_==="single"&&I==="'"||_==="double"&&I==='"'||_==="template"&&I==="`")_=null}else if(C&&I==="/")C=!1}let S=((R)=>{let I="",P=0;while(P<R.length){if(R[P]==="/"){if(Ss(R,P)){P++;while(P<R.length){if(R[P]==="\\"){P+=2;continue}if(R[P]==="/"){P++;while(P<R.length&&/[gimsuvy]/.test(R[P]))P++;break}P++}continue}}I+=R[P],P++}return I})(L).replace(/'(?:[^'\\]|\\.)*'/g,"''").replace(/"(?:[^"\\]|\\.)*"/g,'""');{let R="";for(let I=0;I<S.length;I++){let P=S[I];if(v){v=!1;let J=y.length>0&&y[y.length-1]===-1;R+=J?" ":P;continue}let F=y.length>0&&y[y.length-1]===-1,N=y.length>0&&y[y.length-1]>=0;if(P==="\\"&&(x||k||F)){v=!0,R+=F?" ":P;continue}if(x){if(P==="'")x=!1;R+=P;continue}if(k){if(P==='"')k=!1;R+=P;continue}if(F){if(P==="`")y.pop();else if(P==="$"&&I+1<S.length&&S[I+1]==="{")y[y.length-1]=0,R+=" ",I++;else R+=" ";continue}if(N){if(P==="`")y.push(-1),R+=" ";else if(P==="'")x=!0,R+=P;else if(P==='"')k=!0,R+=P;else if(P==="{")y[y.length-1]++,R+=P;else if(P==="}")if(y[y.length-1]>0)y[y.length-1]--,R+=P;else y[y.length-1]=-1,R+=" ";else R+=P;continue}if(P==="`")y.push(-1),R+=" ";else if(P==="'")x=!0,R+=P;else if(P==='"')k=!0,R+=P;else R+=P}S=R}let O=S.match(/\bfunction\b/);if(O){if(M.includes("function scanContent")||M.includes("function findMatching"))continue;if(S.slice(O.index+8).trimStart().startsWith(":"))continue;let I=S.slice(0,O.index).trimEnd();if(I.endsWith(".")||I.endsWith("?."))continue;let P=O.index,F=M.indexOf("(",P);if(F===-1)continue;let N=0,J=-1,V=w,j="";for(let te=w;te<c.length;te++){let de=te===w?c[te]:c[te],U=te===w?F:0;for(let Z=U;Z<de.length;Z++)if(de[Z]==="(")N++;else if(de[Z]===")"){if(N--,N===0){if(J=Z,V=te,w===te)j=M.slice(F+1,J);else{j=M.slice(F+1);for(let H=w+1;H<te;H++)j+=` ${c[H]}`;j+=` ${de.slice(0,J)}`}break}}if(J!==-1)break}if(J===-1)continue;let B=d(j),Y=p(V,J),q="";if(Y)if(Y.from===V){let te=c[Y.from],de=te.lastIndexOf("{"),U=de>=0?te.slice(de+1):"";if(Y.to>Y.from)q=`${U}
67
+ ${c.slice(Y.from+1,Y.to+1).join(`
68
+ `)}`;else q=U}else q=c.slice(Y.from,Y.to+1).join(`
69
+ `);for(let te of B){if(!te||l.test(te)||te==="undefined")continue;if(!new RegExp(`\\b${te}\\b`,"g").test(q))t.push({filePath:n.filePath,line:w+1,column:Math.max(1,M.indexOf(te)+1),ruleId:"pickier/no-unused-vars",message:`'${te}' is defined but never used (function parameter). Allowed unused args must match pattern: ${r}`,severity:"error"})}continue}let A=M.indexOf("=>");if(A!==-1&&S.includes("=>")){let R=-1;for(let I=A-1;I>=0;I--){let P=M[I];if(P===")"){R=I;break}if(P!==" "&&P!=="\t"&&P!==`
70
+ `&&P!==":"&&P!==">"&&!/\w/.test(P))break}if(R!==-1){let I=-1,P=1;for(let F=R-1;F>=0;F--){let N=M[F];if(N===")")P++;else if(N==="("){if(P--,P===0){I=F;break}}}if(I!==-1){let F=!1,N=0,J=0;for(let j=I-1;j>=0;j--){let B=M[j];if(B===">"){N++;continue}if(B==="<"){if(N>0){N--;continue}if(J<=0){F=!0;break}continue}if(B===":"&&N===0&&J<=0){F=!0;break}if(N>0)continue;if(B===",")continue;if(B===")"){J++;continue}if(B==="("){J--;continue}if(B==="|"||B==="&"){F=!0;break}if(B==="="||B==="{"||B==="["){if(J>=0)break;continue}if(B!==" "&&B!=="\t"&&!/[\w.]/.test(B)){if(J>=0)break}}if(!F){let j=M.slice(0,I);if(/^\s*(?:export\s+)?(?:declare\s+)?type\s+\w[\w$]*\s*(?:<[^>]*>)?\s*=\s*$/.test(j))F=!0;else if(/\bas\s+$/.test(j))F=!0}if(F)continue;let V=M.slice(I+1,R);if(!(V.trim()===""&&M.slice(Math.max(0,I-10),I).includes("async"))){let j=d(V);if(j.length>0){let B="";if(M.slice(A+2).trimStart().startsWith("{")){let q=p(w,A);if(q)if(q.from===w){let te=c[q.from],de=te.indexOf("{",A),U=de>=0?te.slice(de+1):"";if(q.to>q.from)B=`${U}
71
+ ${c.slice(q.from+1,q.to+1).join(`
72
+ `)}`;else B=U}else B=c.slice(q.from,q.to+1).join(`
73
+ `)}else B=g(w,A);for(let q of j){if(!q||l.test(q)||q==="undefined")continue;if(!new RegExp(`\\b${q}\\b`,"g").test(B))t.push({filePath:n.filePath,line:w+1,column:Math.max(1,M.indexOf(q)+1),ruleId:"pickier/no-unused-vars",message:`'${q}' is defined but never used (function parameter). Allowed unused args must match pattern: ${r}`,severity:"error"})}continue}}}}}{let R=/(?:^|[=,:({\s])\s*([$A-Z_][\w$]*)\s*=>/gi,I;while((I=R.exec(S))!==null){let P=I[1];if(!P||l.test(P)||P==="undefined")continue;let F=S.slice(0,I.index+I[0].indexOf(P)).trimEnd();if(/\)\s*:$/.test(F)||/\)\s*:\s*$/.test(F))continue;if(/\)\s*:\s*[$A-Z_][\w$]*\s+is$/i.test(F))continue;if(/^(?:string|number|boolean|void|never|any|unknown|object|bigint|symbol|undefined|null)$/.test(P))continue;let N=new RegExp(`\\b${P}\\s*=>`),J=M.match(N);if(!J)continue;let V=M.indexOf(J[0])+J[0].lastIndexOf("=>"),j="";if(M.slice(V+2).trimStart().startsWith("{")){let q=p(w,V);if(q)if(q.from===w){let te=c[q.from],de=te.indexOf("{",V),U=de>=0?te.slice(de+1):"";if(q.to>q.from)j=`${U}
74
+ ${c.slice(q.from+1,q.to+1).join(`
75
+ `)}`;else j=U}else j=c.slice(q.from,q.to+1).join(`
76
+ `)}else j=g(w,V);if(!new RegExp(`\\b${P}\\b`,"g").test(j))t.push({filePath:n.filePath,line:w+1,column:Math.max(1,M.indexOf(P)+1),ruleId:"pickier/no-unused-vars",message:`'${P}' is defined but never used (function parameter). Allowed unused args must match pattern: ${r}`,severity:"error"})}}}return t},fix:(e,n)=>{let t=Ye.check(e,n);if(t.length===0)return e;let s=t.filter((f)=>f.message.includes("(function parameter)"));if(s.length===0)return e;let i=e.split(/\r?\n/),r=new Set,o=/(?:eslint|pickier)-disable-next-line\b([^*\n]*)/;for(let f=0;f<i.length;f++){let m=i[f].match(o);if(!m)continue;let h=m[1].trim();if(h===""||/\bno-unused-vars\b/.test(h)||/\bpickier\/no-unused-vars\b/.test(h))r.add(f+2)}let l=new Map;for(let f of s){if(r.has(f.line))continue;let m=f.message.match(/^'([^']+)'/);if(!m)continue;let h=m[1];if(h.startsWith("_"))continue;let d=l.get(f.line);if(!d)d=new Set,l.set(f.line,d);d.add(h)}if(l.size===0)return e;let a=e.split(/\r?\n/);function c(f){let m=[],h=!1,d=!1,p=!1,g=-1;for(let y=0;y<f.length;y++){let x=f[y];if(p){p=!1;continue}if(x==="\\"&&(h||d||g>=0)){p=!0;continue}if(g>=0){if(x==="`")m.push([g,y]),g=-1;continue}if(h){if(x==="'")h=!1;continue}if(d){if(x==='"')d=!1;continue}if(x==="`")g=y;else if(x==="'")h=!0;else if(x==='"')d=!0}if(g>=0)m.push([g,f.length]);return m}let u=!1;for(let[f,m]of l){let h=f-1,d=a[h];if(d===void 0)continue;let p=c(d),g=(k)=>p.some(([v,w])=>k>v&&k<w),y=[];for(let k of m){let v=k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),w=new RegExp(`(?<=[(,]\\s*)\\b${v}\\b(?=\\s*[,):=])`,"g"),M;while((M=w.exec(d))!==null){if(g(M.index))continue;y.push({start:M.index,end:M.index+k.length,name:k})}}if(y.length===0)continue;y.sort((k,v)=>v.start-k.start);let x=d;for(let k of y)x=`${x.slice(0,k.start)}_${k.name}${x.slice(k.end)}`;if(x!==d)a[h]=x,u=!0}return u?a.join(`
77
+ `):e}};function Xe(e){let n=e.split(/\r?\n/),t=Array(n.length).fill(!1),s=[],i=!1,r=!1,o=!1,l=!1,a=!1,c="",u=()=>{if(c==="")return!0;return"=([{,;!&|?:+-*/%^~<>".includes(c)};for(let f=0;f<n.length;f++){t[f]=s.length>0&&s[s.length-1]===-1;let m=n[f];for(let h=0;h<m.length;h++){let d=m[h];if(l){if(d==="*"&&h+1<m.length&&m[h+1]==="/")l=!1,h++;continue}if(a){a=!1;continue}let p=s.length>0&&s[s.length-1]===-1,g=s.length>0&&s[s.length-1]>=0;if(d==="\\"&&(i||r||o||p)){a=!0;continue}if(i){if(d==="'")i=!1;continue}if(r){if(d==='"')r=!1;continue}if(o){if(d==="["){let y=1,x=h+1;while(x<m.length){let k=m[x];if(k==="\\"){x+=2;continue}if(k==="]"){if(y--,y===0)break}x++}h=x;continue}if(d==="/"){o=!1;while(h+1<m.length&&/[gimsuvy]/.test(m[h+1]))h++}continue}if(p){if(d==="`")s.pop();else if(d==="$"&&h+1<m.length&&m[h+1]==="{")s.push(0),h++;continue}if(d==="/"&&h+1<m.length&&m[h+1]==="/")break;if(d==="/"&&h+1<m.length&&m[h+1]==="*"){l=!0,h++;continue}if(g){if(d==="`")s.push(-1),c="";else if(d==="'")i=!0,c="'";else if(d==='"')r=!0,c='"';else if(d==="{")s[s.length-1]++,c="{";else if(d==="}"){let y=s[s.length-1];if(y>0)s[s.length-1]=y-1;else s.pop();c="}"}else if(d==="/"&&u())o=!0;else if(!/\s/.test(d))c=d;continue}if(d==="`")s.push(-1),c="";else if(d==="'")i=!0,c="'";else if(d==='"')r=!0,c='"';else if(d==="/"&&u())o=!0;else if(!/\s/.test(d))c=d}}return t}function fd(e,n){let t=[],s=0,i=0,r=null,o=!1;for(let l=0;l<e.length;l++){let a=e[l];if(o){o=!1;continue}if(a==="\\"&&r){o=!0;continue}if(!r){if(a==="'")r="single";else if(a==='"')r="double";else if(a==="`")r="template";else if(a==="("||a==="{"||a==="[")s++;else if(a===")"||a==="}"||a==="]")s--;else if(a===n&&s===0)t.push(e.slice(i,l)),i=l+1}else if(r==="single"&&a==="'"||r==="double"&&a==='"'||r==="template"&&a==="`")r=null}return t.push(e.slice(i)),t}function md(e){let n=0;for(let t=0;t<e.length;t++){let s=e[t];if(s==="{"||s==="("||s==="["||s==="<")n++;else if(s==="}"||s===")"||s==="]"||s===">")n--;else if(s==="="&&n===0&&e[t+1]!=="="&&e[t-1]!=="!"&&e[t-1]!=="<"&&e[t-1]!==">")return t}return-1}function hd(e,n){let t=new RegExp(`\\b${n}\\b`),s=0,i=null,r=!1;while(s<e.length){let o=e[s];if(r){r=!1,s++;continue}if(o==="\\"&&i){r=!0,s++;continue}if(i){if(i==="single"&&o==="'"||i==="double"&&o==='"'||i==="template"&&o==="`")i=null;s++;continue}if(o==="'"){i="single",s++;continue}if(o==='"'){i="double",s++;continue}if(o==="`"){i="template",s++;continue}if(o==="["||o==="{"){let l=o,a=o==="["?"]":"}",c=1,u=s+1;while(u<e.length&&c>0){let f=e[u];if(f==="\\"){u+=2;continue}if(f===l)c++;else if(f===a)c--;if(c===0)break;u++}if(c===0&&u<e.length){let f=u+1;while(f<e.length&&(e[f]===" "||e[f]==="\t"||e[f]==="\r"||e[f]===`
78
+ `))f++;if(e[f]==="="&&e[f+1]!=="="&&e[f+1]!==">"){let m=e.slice(s+1,u);if(t.test(m)){let h=new RegExp(`\\b${n}\\b\\s*:`),d=new RegExp(`:\\s*\\b${n}\\b`);if(l==="{"){if(!(h.test(m)&&!d.test(m)&&!new RegExp(`(?:^|[\\s,{])\\s*${n}\\s*(?:,|\\s*=|\\s*})`).test(m)))return!0}else return!0}}}s=u+1;continue}s++}return!1}function jo(e,n){let t=new RegExp("^\\s*(?:let|var)\\s+(.+?);?\\s*$"),s=e.match(t);if(!s)return null;let i=s[1],r=md(i);if(r>=0){let a=i.indexOf(":");if(a>=0&&a<r)i=i.slice(0,a)+i.slice(r)}let o=fd(i,","),l=[];for(let a of o){let c=a.trim();if(!c)continue;if(c.match(/^[{[]/))return null;let f=c.match(/^([$A-Z_][\w$]*)/i);if(!f)return null;let m=f[1];if(!/=/.test(c))return null;let d=n.indexOf(e),p=n.slice(d+e.length),y=`\\b${m}\\s*(?:${[">>>=","**=","<<=",">>=","??=","||=","&&=","+=","-=","*=","/=","%=","&=","^=","|=","="].map((_)=>_.replace(/[|\\^$*+?.(){}[\]]/g,(C)=>`\\${C}`)).join("|")})`,x=new RegExp(y).test(p),k=new RegExp(`(?:^|[^$w])(?:\\+\\+|--)\\s*${m}\\b|\\b${m}\\s*(?:\\+\\+|--)`).test(p),v=hd(p,m),w=c.indexOf("="),M=w>=0?c.slice(w+1):"",L=new RegExp(y).test(M);l.push({name:m,fixable:!x&&!k&&!v&&!L})}return l}var Es={meta:{docs:"Suggest 'const' for variables that are never reassigned (heuristic)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=Xe(e);for(let r=0;r<s.length;r++){if(i[r])continue;let o=s[r],l=jo(o,e);if(!l)continue;for(let{name:a,fixable:c}of l){if(!c)continue;let u=o.search(new RegExp(`\\b${a.replace(/\$/g,"\\$")}\\b`)),f=u!==-1?u:o.indexOf(a);t.push({filePath:n.filePath,line:r+1,column:Math.max(1,f+1),ruleId:"prefer-const",message:`'${a}' is never reassigned. Use 'const' instead`,severity:"error",help:`Change 'let ${a}' to 'const ${a}' since the variable is never reassigned. This makes your code more predictable and prevents accidental mutations`})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=Xe(e),s=new Set,i=/(?:eslint|pickier)-disable-next-line\b([^*\n]*)/;for(let o=0;o<n.length;o++){let l=n[o].match(i);if(!l)continue;let a=l[1].trim();if(a===""||/\bprefer-const\b/.test(a))s.add(o+2)}let r=!1;for(let o=0;o<n.length;o++){if(s.has(o+1))continue;if(t[o])continue;let l=n[o];if(!/^\s*let\b/.test(l))continue;let a=jo(l,e);if(!a||a.length===0)continue;if(!a.every((u)=>u.fixable))continue;let c=l.replace(/^(\s*)let(\s+)/,"$1const$2");if(c!==l)n[o]=c,r=!0}return r?n.join(`
79
+ `):e}};var Uo={meta:{docs:"Prefer object spread ({...obj}) over Object.assign() for object composition"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(/^\s*\/\//.test(r))continue;let o=r.indexOf("//"),l=o>=0?r.slice(0,o):r,a=l.matchAll(/\bObject\.assign\s*\(/g);for(let c of a){let u=c.index,f=l.slice(0,u),m=(f.match(/'/g)||[]).length,h=(f.match(/"/g)||[]).length,d=(f.match(/`/g)||[]).length;if(m%2!==0||h%2!==0||d%2!==0)continue;let p=u+13,g=l.slice(p),y=-1,x=1,k=0,v=0,w=null,M=!1;for(let _=1;_<g.length;_++){let C=g[_];if(M){M=!1;continue}if(C==="\\"&&w){M=!0;continue}if(!w){if(C==="'")w="single";else if(C==='"')w="double";else if(C==="`")w="template";else if(C==="(")x++;else if(C===")"){if(x--,x===0)break}else if(C==="{")k++;else if(C==="}")k--;else if(C==="[")v++;else if(C==="]")v--;else if(C===","&&x===1&&k===0&&v===0){y=_;break}}else if(w==="single"&&C==="'"||w==="double"&&C==='"'||w==="template"&&C==="`")w=null}if(y===-1)continue;let L=g.slice(1,y).trim();if(L==="{}")t.push({filePath:n.filePath,line:i+1,column:u+1,ruleId:"prefer-object-spread",message:"Prefer object spread over Object.assign",severity:"error",help:"Use object spread syntax: {...obj} instead of Object.assign({}, obj)"});else if(L==="{}"||/^\{.*\}$/.test(L))t.push({filePath:n.filePath,line:i+1,column:u+1,ruleId:"prefer-object-spread",message:"Prefer object spread over Object.assign for object literals",severity:"error",help:"Use object spread syntax: {...obj1, ...obj2}"})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=[];for(let s=0;s<n.length;s++){let i=n[s];i=i.replace(/\bObject\.assign\s*\(\s*\{\}\s*,\s*([^)]+)\)/g,(r,o)=>`{${o.split(",").map((a)=>a.trim()).map((a)=>`...${a}`).join(", ")}}`),t.push(i)}return t.join(`
80
+ `)}};function dd(e,n){let t=!1,s=!1,i=!1;for(let r=0;r<n;r++){let o=e[r];if(o==="\\"){r++;continue}if(o==="'"&&!s&&!i)t=!t;else if(o==='"'&&!t&&!i)s=!s;else if(o==="`"&&!t&&!s)i=!i}return t||s||i}var Ls={meta:{docs:"Prefer template literals over string concatenation",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(o.startsWith("//")||o.startsWith("/*")||o.startsWith("*")||o.startsWith("import"))continue;let l=/(['"`][^'"`]*['"`])\s*\+\s*([a-z_$][\w$]*)/i,a=/([a-z_$][\w$]*)\s*\+\s*(['"`][^'"`]*['"`])/i,c=o.match(l)||o.match(a);if(c){let u=r.indexOf("//"),f=r.indexOf(c[0]);if(u>=0&&f>u)continue;if(dd(r,f))continue;let m=!!o.match(a),h=!!o.match(l);if(m&&!h){if(o.slice(o.indexOf(c[0])+c[0].length).startsWith("."))continue}t.push({filePath:n.filePath,line:i+1,column:f+1,ruleId:"general/prefer-template",message:"Unexpected string concatenation. Use template literals instead",severity:"warning",help:"Use template literals (backticks) instead of string concatenation. Example: `hello ${name}!` instead of 'hello ' + name + '!'"})}}return t}};var zo={name:"general",rules:{"array-callback-return":b(kn),"constructor-super":b($n),"for-direction":b(Pn),"getter-return":b(vn),"no-async-promise-executor":b(In),"no-compare-neg-zero":b(Mn),"no-cond-assign":b(Cn),"no-const-assign":b(Sn),"no-constant-condition":b(En),"no-constructor-return":b(Do),"no-dupe-class-members":b(Ln),"no-dupe-keys":b(_t),"no-duplicate-case":b(Tn),"no-empty-pattern":b(An),"no-fallthrough":b(On),"no-irregular-whitespace":b(Fo),"no-loss-of-precision":b(_n),"no-new":b(No),"no-regex-spaces":b(Wo),"no-promise-executor-return":b(Dn),"no-redeclare":b(Fn),"no-self-assign":b(Dt),"no-self-compare":b(Nn),"no-sparse-arrays":b(Wn),"no-undef":b(Bn),"no-unsafe-negation":b(Un),"no-unreachable":b(jn),"no-unused-vars":b(Ye),"no-useless-catch":b(zn),"prefer-const":b(Es),"prefer-object-spread":b(Uo),"prefer-template":b(Ls),"use-isnan":b(qn),"valid-typeof":b(Kn)}};var Wt={npm:"registry.npmjs.org",yarn:"registry.yarnpkg.com",verdaccio:"registry.verdaccio.org"};function qo(e){let n=e.split("/").pop()||"";if(n==="package-lock.json")return"npm";if(n==="yarn.lock")return"yarn";if(n==="bun.lockb"||n==="bun.lock")return"bun";return null}function Ne(e,n){let t=qo(n);if(!t)return!1;if(t==="npm")try{let s=JSON.parse(e);return"lockfileVersion"in s||"dependencies"in s||"packages"in s}catch{return!1}if(t==="yarn")return e.startsWith("#")||e.includes("__metadata:")||e.includes('resolved "');if(t==="bun")try{let s=JSON.parse(e);return"lockfileVersion"in s||"packages"in s}catch{return!1}return!1}function pd(e){let n=new Map,t=JSON.parse(e);if((t.lockfileVersion||1)>=2&&t.packages)for(let[i,r]of Object.entries(t.packages)){if(!i||i==="")continue;let o=i.replace(/^node_modules\//,"").replace(/\/node_modules\//g,"/"),l=o.split("/node_modules/").pop()||o;n.set(i,{name:l,version:r.version||"",resolved:r.resolved,integrity:r.integrity})}else if(t.dependencies)Ko(t.dependencies,n,"");return{type:"npm",packages:n}}function Ko(e,n,t){for(let[s,i]of Object.entries(e)){let r=t?`${t}/${s}`:s;if(n.set(r,{name:s,version:i.version||"",resolved:i.resolved,integrity:i.integrity}),i.dependencies)Ko(i.dependencies,n,r)}}function gd(e){let n=new Map,t=e.includes("__metadata:"),s=t?"yarn-berry":"yarn",i=e.split(`
81
+ `),r="",o={};for(let l of i){if(l.startsWith("#")||l.trim()==="")continue;if(!l.startsWith(" ")&&l.includes("@")&&l.endsWith(":")){if(r&&(o.resolved||o.integrity))n.set(r,o);if(r=l.slice(0,-1).trim(),r.startsWith('"')&&r.endsWith('"'))r=r.slice(1,-1);let a=r.match(/^(@?[^@]+)@/);o={name:a?a[1]:r.split("@")[0],version:""}}else if(l.startsWith(" ")||l.startsWith("\t")){let a=l.trim();if(a.startsWith("version")){let c=a.match(/version[:\s]+"?([^"]+)"?/);if(c)o.version=c[1]}else if(a.startsWith("resolved")){let c=a.match(/resolved[:\s]+"?([^"]+)"?/);if(c)o.resolved=c[1]}else if(a.startsWith("resolution:")&&t){let c=a.match(/resolution[:\s]+"?([^"]+)"?/);if(c)o.resolved=c[1]}else if(a.startsWith("integrity")||a.startsWith("checksum")){let c=a.match(/(integrity|checksum)[:\s]+"?([^"]+)"?/);if(c)o.integrity=c[2]}}}if(r&&(o.resolved||o.integrity))n.set(r,o);return{type:s,packages:n}}function yd(e){let n=new Map,t=JSON.parse(e);if(t.packages)for(let[s,i]of Object.entries(t.packages)){if(!s||s==="")continue;if(Array.isArray(i)){let[r,o,l,a]=i,c=s,u="";if(typeof r==="string"&&r.includes("@")){let f=r.lastIndexOf("@");if(f>0)c=r.substring(0,f),u=r.substring(f+1)}n.set(s,{name:c,version:u,resolved:o||void 0,integrity:a||void 0})}else if(typeof i==="object")n.set(s,{name:i.name||s.split("@")[0],version:i.version||"",resolved:i.resolved,integrity:i.integrity||i.hash})}return{type:"bun",packages:n}}function We(e,n){let t=qo(n);if(!t)return null;try{switch(t){case"npm":return pd(e);case"yarn":return gd(e);case"bun":return yd(e);default:return null}}catch{return null}}function Vo(e){try{return new URL(e).hostname}catch{return null}}function Ts(e){try{return new URL(e).protocol}catch{return null}}function Ho(e){try{let t=new URL(e).pathname,s=t.indexOf("/-/");if(s===-1)return null;let i=t.substring(1,s);if(i.startsWith("@"))return i;return i}catch{return null}}function Zo(e){if(!e)return null;let n=e.match(/^(sha\d+)-/);return n?n[1]:null}function Go(e){return e.map((n)=>{let t=n.toLowerCase();return Wt[t]||n})}var Yo={meta:{docs:"Ensure all packages are from allowed registry hosts",recommended:!0},check(e,n){let t=[];if(!Ne(e,n.filePath))return t;let s=We(e,n.filePath);if(!s)return t;let i=n.options||{},r=i.allowedHosts||["npm","yarn"],o=i.emptyHostname!==!1,l=Go(r),a=e.split(`
82
+ `);for(let[c,u]of s.packages){if(!u.resolved){if(!o){let m=Jo(a,c);t.push({filePath:n.filePath,line:m,column:1,ruleId:"lockfile/validate-host",message:`Package "${u.name}" has no resolved URL`,severity:"error",help:"All packages should have a resolved URL from an allowed registry."})}continue}let f=Vo(u.resolved);if(!f)continue;if(!l.includes(f)){let m=Jo(a,c),h=r.map((d)=>Wt[d.toLowerCase()]||d).join(", ");t.push({filePath:n.filePath,line:m,column:1,ruleId:"lockfile/validate-host",message:`Invalid host for package "${u.name}": expected one of [${h}], got "${f}"`,severity:"error",help:`Package is resolving from an unauthorized registry. This could indicate a supply chain attack. Allowed hosts: ${h}`})}}return t}};function Jo(e,n){for(let t=0;t<e.length;t++)if(e[t].includes(n)||e[t].includes(`"${n}"`))return t+1;return 1}var Xo={meta:{docs:"Ensure all packages use HTTPS protocol",recommended:!0},check(e,n){let t=[];if(!Ne(e,n.filePath))return t;let s=We(e,n.filePath);if(!s)return t;let i=e.split(`
83
+ `);for(let[r,o]of s.packages){if(!o.resolved)continue;let l=Ts(o.resolved);if(!l)continue;if(l!=="https:"){let a=bd(i,r);t.push({filePath:n.filePath,line:a,column:1,ruleId:"lockfile/validate-https",message:`Package "${o.name}" uses insecure protocol: "${l}" instead of "https:"`,severity:"error",help:"All packages should be downloaded over HTTPS to prevent man-in-the-middle attacks."})}}return t}};function bd(e,n){for(let t=0;t<e.length;t++)if(e[t].includes(n)||e[t].includes(`"${n}"`))return t+1;return 1}var Qo={meta:{docs:"Ensure all packages use strong integrity hashes (SHA512)",recommended:!0},check(e,n){let t=[];if(!Ne(e,n.filePath))return t;let s=We(e,n.filePath);if(!s)return t;let i=n.options||{},r=i.requiredAlgorithm||"sha512",o=new Set(i.exclude||[]),l={sha1:1,sha256:2,sha384:3,sha512:4},a=l[r]||4,c=e.split(`
84
+ `);for(let[u,f]of s.packages){if(o.has(f.name))continue;if(!f.integrity)continue;let m=Zo(f.integrity);if(!m)continue;if((l[m.toLowerCase()]||0)<a){let d=xd(c,u);t.push({filePath:n.filePath,line:d,column:1,ruleId:"lockfile/validate-integrity",message:`Package "${f.name}" uses weak hash algorithm: "${m}" (required: ${r})`,severity:"error",help:`Weak hash algorithms are susceptible to collision attacks. Upgrade to ${r} by regenerating your lockfile with a recent package manager.`})}}return t}};function xd(e,n){for(let t=0;t<e.length;t++)if(e[t].includes(n)||e[t].includes(`"${n}"`))return t+1;return 1}var el={meta:{docs:"Ensure package names match their resolved URLs",recommended:!0},check(e,n){let t=[];if(!Ne(e,n.filePath))return t;let s=We(e,n.filePath);if(!s)return t;let r=(n.options||{}).aliases||{},o=Object.values(Wt),l=e.split(`
85
+ `);for(let[a,c]of s.packages){if(!c.resolved)continue;let u=!1;try{let d=new URL(c.resolved);u=o.includes(d.hostname)}catch{continue}if(!u)continue;let f=Ho(c.resolved);if(!f)continue;let m=c.name,h=r[m]||m;if(f!==h){let d=wd(l,a);t.push({filePath:n.filePath,line:d,column:1,ruleId:"lockfile/validate-package-names",message:`Package name mismatch: "${m}" resolves to "${f}"`,severity:"error",help:`This could indicate a package substitution attack. The lockfile entry is for "${m}" but the resolved URL points to "${f}".`})}}return t}};function wd(e,n){for(let t=0;t<e.length;t++)if(e[t].includes(n)||e[t].includes(`"${n}"`))return t+1;return 1}var tl={meta:{docs:"Ensure all packages use allowed URL schemes",recommended:!0},check(e,n){let t=[];if(!Ne(e,n.filePath))return t;let s=We(e,n.filePath);if(!s)return t;let o=((n.options||{}).allowedSchemes||["https:","git+https:","git+ssh:"]).map((a)=>a.endsWith(":")?a:`${a}:`),l=e.split(`
86
+ `);for(let[a,c]of s.packages){if(!c.resolved)continue;let u=Ts(c.resolved);if(!u)continue;if(!o.includes(u)){let f=Rd(l,a);t.push({filePath:n.filePath,line:f,column:1,ruleId:"lockfile/validate-scheme",message:`Package "${c.name}" uses disallowed URL scheme: "${u}"`,severity:"error",help:`Only the following URL schemes are allowed: ${o.join(", ")}. Using "${u}" could be a security risk.`})}}return t}};function Rd(e,n){for(let t=0;t<e.length;t++)if(e[t].includes(n)||e[t].includes(`"${n}"`))return t+1;return 1}var nl={name:"lockfile",rules:{"validate-host":Yo,"validate-https":Xo,"validate-integrity":Qo,"validate-package-names":el,"validate-scheme":tl}};var sl={meta:{docs:"Fenced code blocks should be surrounded by blank lines"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r];if(/^(?:`{3,}|~{3,})/.test(o.trim()))if(!i){let a=r>0?s[r-1]:"";if(r>0&&a.trim().length>0){if(!/^:::/.test(a.trim()))t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"markdown/blanks-around-fences",message:"Fenced code blocks should be surrounded by blank lines",severity:"error"})}i=!0}else{let a=r+1<s.length?s[r+1]:"";if(r+1<s.length&&a.trim().length>0){if(!/^:::/.test(a.trim()))t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"markdown/blanks-around-fences",message:"Fenced code blocks should be surrounded by blank lines",severity:"error"})}i=!1}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=[],s=!1;for(let i=0;i<n.length;i++){let r=n[i],o=i>0?n[i-1]:"",l=/^(?:`{3,}|~{3,})/.test(r.trim());if(l)if(!s){if(i>0&&o.trim().length>0&&!/^:::/.test(o.trim())&&t.length>0)t.push("");s=!0}else s=!1;if(t.push(r),l&&!s&&i+1<n.length){let a=n[i+1];if(a.trim().length>0&&!/^:::/.test(a.trim()))t.push("")}}return t.join(`
87
+ `)}};var il={meta:{docs:"Headings should be surrounded by blank lines"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r],l=r>0?s[r-1]:"",a=r+1<s.length?s[r+1]:"";if(/^(?:`{3,}|~{3,})/.test(o.trim())){i=!i;continue}if(i)continue;let c=/^#{1,6}\s/.test(o),u=r+1<s.length&&/^(?:=+|-+)\s*$/.test(a)&&o.trim().length>0;if(c){if(r>0&&l.trim().length>0)t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"});if(r+1<s.length&&a.trim().length>0&&!/^#{1,6}\s/.test(a))t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"})}if(u){if(r>0&&l.trim().length>0)t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"});let f=r+2<s.length?s[r+2]:"";if(r+2<s.length&&f.trim().length>0)t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=[],s=!1;for(let i=0;i<n.length;i++){let r=n[i],o=i>0?n[i-1]:"",l=i+1<n.length?n[i+1]:"";if(/^(?:`{3,}|~{3,})/.test(r.trim())){s=!s,t.push(r);continue}if(s){t.push(r);continue}let a=/^#{1,6}\s/.test(r),c=i+1<n.length&&/^(?:=+|-+)\s*$/.test(l)&&r.trim().length>0;if(a||c){if(i>0&&o.trim().length>0&&t.length>0)t.push("")}if(t.push(r),a){if(i+1<n.length&&l.trim().length>0&&!/^#{1,6}\s/.test(l))t.push("")}if(i>0&&/^(?:=+|-+)\s*$/.test(r)&&n[i-1].trim().length>0){if((i+1<n.length?n[i+1]:"").trim().length>0)t.push("")}}return t.join(`
88
+ `)}};var rl={meta:{docs:"Lists should be surrounded by blank lines"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=!1;for(let o=0;o<s.length;o++){let l=s[o],a=o>0?s[o-1]:"";if(/^(?:`{3,}|~{3,})/.test(l.trim())){if(r=!r,i)i=!1;continue}if(r)continue;let c=/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(l),u=i&&!c&&l.trim().length>0&&/^\s+/.test(l);if(c&&!i){if(i=!0,o>0&&a.trim().length>0)t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"markdown/blanks-around-lists",message:"Lists should be surrounded by blank lines",severity:"error"})}else if(!c&&!u&&i&&l.trim().length>0){if(i=!1,/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(a))t.push({filePath:n.filePath,line:o,column:1,ruleId:"markdown/blanks-around-lists",message:"Lists should be surrounded by blank lines",severity:"error"})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=[],s=!1,i=!1,r=(o)=>/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(o);for(let o=0;o<n.length;o++){let l=n[o],a=o>0?n[o-1]:"";if(/^(?:`{3,}|~{3,})/.test(l.trim())){i=!i,s=!1,t.push(l);continue}if(i){t.push(l);continue}let c=r(l),u=l.trim().length===0,f=s&&!c&&!u&&/^\s/.test(l);if(c&&!s){if(o>0&&a.trim().length>0&&t.length>0)t.push("");s=!0}else if(!c&&!f&&!u&&s){if(s=!1,t.length>0)t.push("")}else if(u){let m=o+1<n.length?n[o+1]:"",h=r(m),d=/^\s+\S/.test(m);if(!h&&!d&&s)s=!1}t.push(l)}return t.join(`
89
+ `)}};function W(e){let n=new Set,t=null,s=0,i=!1,r=!1;for(let o=0;o<e.length;o++){let l=e[o],a=l.trim();if(t===null){let m=a.match(/^(`{3,}|~{3,})(.*)$/);if(m){let h=m[1],d=m[2],p=h[0];if(p==="`"&&d.includes("`"));else{t=p,s=h.length,n.add(o),i=!1,r=!1;continue}}}else{n.add(o);let m=a.match(/^(`{3,}|~{3,})\s*$/);if(m&&m[1][0]===t&&m[1].length>=s)t=null,s=0;continue}let c=l.length-l.trimStart().length,u=/^\t/.test(l);if((c>=4||u)&&a.length>0){if(r||i||o===0)n.add(o),r=!0;i=r;continue}if(a.length===0){if(r)n.add(o),i=!0;else i=!0;continue}r=!1,i=!1}return n}function ol(e,n,t){let s=0,i=0;while(s<e.length){if(e[s]!=="`"){s++;continue}let r=0;while(e[s+r]==="`")r++;let o=s+r,l=-1;while(o<e.length)if(e[o]==="`"){let a=0;while(e[o+a]==="`")a++;if(a===r){l=o;break}o+=a}else o++;if(l===-1){s+=r;continue}if(i<s)n(e.slice(i,s));t(e.slice(s,l+r)),s=l+r,i=s}if(i<e.length)n(e.slice(i))}function Rt(e,n){let t="";return ol(e,(s)=>{t+=n(s)},(s)=>{t+=s}),t}function Qe(e){let n="";return ol(e,(t)=>{n+=t},(t)=>{n+=" ".repeat(t.length)}),n}function ll(e){let n=W(e),t=[],s=0;for(let i=0;i<e.length;i++){let r=e[i];if(n.has(i)||r.trim()===""){s=0,t.push(r);continue}if(s===0){let a=Qe(r),c=kd(a);if(!c){t.push(a);continue}s=c.length,t.push(a.slice(0,c.index)+" ".repeat(a.length-c.index));continue}let o=new RegExp(`(?<!\`)\`{${s}}(?!\`)`).exec(r);if(!o){t.push(" ".repeat(r.length));continue}let l=o.index+o[0].length;s=0,t.push(" ".repeat(l)+Qe(r.slice(l)))}return t}function kd(e){let n=/(?<!`)(`+)(?!`)(?=[^`]*$)/.exec(e);return n?{index:n.index,length:n[1].length}:null}function rt(e){let n=new Set,t=W(e);for(let s=0;s<e.length;s++){if(t.has(s))continue;let i=e[s];if(!$d(i))continue;if(s>0&&!t.has(s-1)&&/\|/.test(e[s-1])&&e[s-1].trim().length>0)n.add(s-1);n.add(s);for(let r=s+1;r<e.length;r++){if(t.has(r))break;let o=e[r];if(o.trim().length===0||!/\|/.test(o))break;n.add(r)}}return n}function $d(e){let n=e.trim();if(!n.includes("|"))return!1;if(!/^[|\s:-]+$/.test(n))return!1;if(!/-{3,}/.test(n))return!1;return!0}var al={meta:{docs:"Tables should be surrounded by blank lines"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=!1,o=rt(s);for(let l=0;l<s.length;l++){let a=s[l],c=l>0?s[l-1]:"";if(/^(?:`{3,}|~{3,})/.test(a.trim())){if(r=!r,i)i=!1;continue}if(r)continue;let u=o.has(l)&&/\|/.test(a)&&a.trim().length>0;if(u&&!i){if(i=!0,l>0&&c.trim().length>0)t.push({filePath:n.filePath,line:l+1,column:1,ruleId:"markdown/blanks-around-tables",message:"Tables should be surrounded by blank lines",severity:"error"})}else if(!u&&i){if(i=!1,a.trim().length>0)t.push({filePath:n.filePath,line:l+1,column:1,ruleId:"markdown/blanks-around-tables",message:"Tables should be surrounded by blank lines",severity:"error"})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=W(n),s=rt(n),i=[],r=!1;for(let l=0;l<n.length;l++){let a=n[l];if(t.has(l)){i.push(a);continue}let c=s.has(l)&&/\|/.test(a)&&a.trim().length>0;if(c&&!r){let u=i.length-1;if(u>=0&&i[u].trim().length>0)i.push("");r=!0,i.push(a);continue}if(!c&&r){if(r=!1,a.trim().length>0)i.push("")}i.push(a)}let o=i.join(`
90
+ `);return o!==e?o:e}};var cl={meta:{docs:"Code block style should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).style||"consistent",o=null,l=!1;for(let a=0;a<s.length;a++){let c=s[a];if(/^(?:`{3,}|~{3,})/.test(c)){if(l=!l,r==="indented")t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/code-block-style",message:"Expected indented code block style",severity:"error"});else if(r==="consistent"){if(o===null)o="fenced";else if(o==="indented")t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/code-block-style",message:"Code block style should be consistent throughout document",severity:"error"})}continue}if(l)continue;if(/^(?: {4}|\t)/.test(c)&&c.trim().length>0){let h=(a>0?s[a-1]:"").trim().length===0||a===0;if(h&&r==="fenced")t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/code-block-style",message:"Expected fenced code block style",severity:"error"});else if(h&&r==="consistent"){if(o===null)o="indented";else if(o==="fenced")t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/code-block-style",message:"Code block style should be consistent throughout document",severity:"error"})}}}return t}};function ul(e){let n=new Set,t=null,s=0;for(let i=0;i<e.length;i++){let r=e[i].trim();if(t===null){let o=r.match(/^(`{3,}|~{3,})(.*)$/);if(o){let l=o[1][0];if(l==="`"&&o[2].includes("`"))continue;t=l,s=o[1].length,n.add(i)}}else{let o=r.match(/^(`{3,}|~{3,})\s*$/);if(o&&o[1][0]===t&&o[1].length>=s)n.add(i),t=null,s=0}}return n}var fl={meta:{docs:"Code fence style should be consistent (backtick or tilde)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=ul(s),o=(n.options||{}).style||"consistent",l=null;for(let a of i){let c=s[a],f=/^`{3,}/.test(c.trim())?"backtick":"tilde";if(o==="backtick"||o==="tilde"){if(f!==o)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/code-fence-style",message:o==="tilde"?"Expected tilde (~~~) code fence":"Expected backtick (```) code fence",severity:"error"})}else if(o==="consistent"){if(l===null)l=f;else if(l!==f)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/code-fence-style",message:"Code fence style should be consistent throughout document",severity:"error"})}}return t},fix:(e,n)=>{let s=(n.options||{}).style||"consistent",i=e.split(/\r?\n/),r=ul(i),o="backtick";if(s==="backtick"||s==="tilde")o=s;else for(let u of r){o=/^`{3,}/.test(i[u].trim())?"backtick":"tilde";break}let l=o==="backtick"?"`":"~",a=o==="backtick"?/^(\s*)(~{3,})(.*)$/:/^(\s*)(`{3,})(.*)$/;return i.map((u,f)=>{if(!r.has(f))return u;return u.replace(a,(m,h,d,p)=>`${h}${l.repeat(d.length)}${p}`)}).join(`
91
+ `)}};var ml={meta:{docs:"Commands in code blocks should not be prefixed with $ unless showing output"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=-1;for(let o=0;o<s.length;o++){let l=s[o];if(/^(?:`{3,}|~{3,})/.test(l)){if(!i)i=!0,r=o;else i=!1;continue}if(i&&/^\$\s+/.test(l.trim())){let a=!0,c=!1;for(let u=r+1;u<o;u++){let f=s[u].trim();if(f.length>0){if(c=!0,!f.startsWith("$")){a=!1;break}}}if(a&&c)t.push({filePath:n.filePath,line:o+1,column:l.indexOf("$")+1,ruleId:"markdown/commands-show-output",message:"Dollar signs used before commands without showing output",severity:"warning"})}}return t}};var hl={meta:{docs:"Link text should be meaningful and descriptive"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=["click here","here","link","read more","more","this"],r=!1;for(let o=0;o<s.length;o++){let l=s[o];if(/^(?:`{3,}|~{3,})/.test(l.trim())){r=!r;continue}if(r)continue;let c=l.replace(/``[^`]+``/g,(u)=>" ".repeat(u.length)).replace(/`[^`]+`/g,(u)=>" ".repeat(u.length)).matchAll(/\[([^\]]+)\]\([^)]+\)/g);for(let u of c){let f=u[1].toLowerCase().trim();if(i.includes(f)){let m=u.index+1;t.push({filePath:n.filePath,line:o+1,column:m,ruleId:"markdown/descriptive-link-text",message:`Link text '${u[1]}' is not descriptive`,severity:"warning"})}}}return t}};var Ei="(?<!\\*)\\*(?!\\*)(?!\\s)([^*]*[^*\\s])\\*(?!\\*)",Pd=new RegExp(Ei),Li="(?<![A-Za-z0-9_])_(?!_)([^_]+)_(?![A-Za-z0-9_])",vd=new RegExp(Li),dl={meta:{docs:"Emphasis style should be consistent (asterisk or underscore)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).style||"consistent",o=null,l=W(s),a=ll(s);for(let c=0;c<s.length;c++){let u=s[c];if(l.has(c))continue;let f=a[c]??Qe(u),m=f.matchAll(new RegExp(Ei,"g"));for(let d of m)if(r==="underscore")t.push({filePath:n.filePath,line:c+1,column:d.index+1,ruleId:"markdown/emphasis-style",message:"Expected underscore (_) for emphasis",severity:"error"});else if(r==="consistent"){if(o===null)o="asterisk";else if(o==="underscore")t.push({filePath:n.filePath,line:c+1,column:d.index+1,ruleId:"markdown/emphasis-style",message:"Emphasis style should be consistent throughout document",severity:"error"})}let h=f.matchAll(new RegExp(Li,"g"));for(let d of h)if(r==="asterisk")t.push({filePath:n.filePath,line:c+1,column:d.index+1,ruleId:"markdown/emphasis-style",message:"Expected asterisk (*) for emphasis",severity:"error"});else if(r==="consistent"){if(o===null)o="underscore";else if(o==="asterisk")t.push({filePath:n.filePath,line:c+1,column:d.index+1,ruleId:"markdown/emphasis-style",message:"Emphasis style should be consistent throughout document",severity:"error"})}}return t},fix:(e,n)=>{let s=(n.options||{}).style||"consistent",i=e.split(/\r?\n/),r=W(i),o="asterisk";if(s==="asterisk")o="asterisk";else if(s==="underscore")o="underscore";else if(s==="consistent"){let a=null,c=null;for(let f=0;f<i.length;f++){if(r.has(f))continue;let m=Qe(i[f]);if(a===null){let h=m.match(Pd);if(h)a={line:f,col:h.index}}if(c===null){let h=m.match(vd);if(h)c={line:f,col:h.index}}if(a&&c)break}if(a&&(!c||((f,m)=>f.line!==m.line?f.line-m.line:f.col-m.col)(a,c)<0))o="asterisk";else if(c)o="underscore"}let l=!1;for(let a=0;a<i.length;a++){if(r.has(a))continue;let c=Rt(i[a],(u)=>o==="asterisk"?u.replace(new RegExp(Li,"g"),"*$1*"):u.replace(new RegExp(Ei,"g"),"_$1_"));if(c!==i[a])i[a]=c,l=!0}return l?i.join(`
92
+ `):e}};var pl={meta:{docs:"Fenced code blocks should have a language specified"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++)if(s[i].match(/^(?:`{3,}|~{3,})\s*$/)){let l=!0;for(let a=i-1;a>=0;a--)if(/^(?:`{3,}|~{3,})/.test(s[a])){l=!1;break}if(l)t.push({filePath:n.filePath,line:i+1,column:1,ruleId:"markdown/fenced-code-language",message:"Fenced code blocks should have a language specified",severity:"error"})}return t}};var gl={meta:{docs:"First line in a file should be a top-level heading"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=-1;for(let a=0;a<s.length;a++)if(s[a].trim().length>0){i=a;break}if(i===-1)return t;let r=s[i],o=/^#\s/.test(r),l=i+1<s.length&&/^=+\s*$/.test(s[i+1]);if(!o&&!l)t.push({filePath:n.filePath,line:i+1,column:1,ruleId:"markdown/first-line-heading",message:"First line in a file should be a top-level heading",severity:"warning"});return t}};var yl={meta:{docs:"Heading levels should only increment by one level at a time"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s),r=0;for(let o=0;o<s.length;o++){if(i.has(o))continue;let a=s[o].match(/^(#{1,6})\s/);if(a){let c=a[1].length;if(r>0&&c>r+1)t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"markdown/heading-increment",message:`Heading level should not skip from h${r} to h${c}`,severity:"error"});r=c}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=W(n),s=0,i=!1;for(let r=0;r<n.length;r++){if(t.has(r))continue;let l=n[r].match(/^(#{1,6})(\s.*)$/);if(!l)continue;let a=l[1].length,c=s===0?a:Math.min(a,s+1);if(c!==a)n[r]="#".repeat(c)+l[2],i=!0;s=c}return i?n.join(`
93
+ `):e}};var bl={meta:{docs:"Headings must start at the beginning of the line"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r];if(/^(?:`{3,}|~{3,})/.test(o.trim())){i=!i;continue}if(i)continue;if(o.match(/^(\s+)(#{1,6}\s)/))t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"markdown/heading-start-left",message:"Headings must start at the beginning of the line",severity:"error"})}return t},fix:(e)=>e.split(/\r?\n/).map((s)=>s.replace(/^(\s+)(#{1,6}\s)/,"$2")).join(`
94
+ `)};var xl={meta:{docs:"Heading style should be consistent (atx, setext, or consistent)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).style||"consistent",o=null,l=W(s);for(let a=0;a<s.length;a++){if(l.has(a))continue;let c=s[a],u=a+1<s.length?s[a+1]:"",f=c.match(/^#{1,6}\s/),m=u.match(/^(?:=+|-+)\s*$/)&&c.trim().length>0&&!l.has(a+1);if(f){if(r==="setext")t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/heading-style",message:"Expected setext style heading",severity:"error"});else if(r==="consistent"){if(o===null)o="atx";else if(o==="setext")t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/heading-style",message:"Heading style should be consistent throughout document",severity:"error"})}}else if(m){if(r==="atx")t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/heading-style",message:"Expected atx style heading",severity:"error"});else if(r==="consistent"){if(o===null)o="setext";else if(o==="atx")t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/heading-style",message:"Heading style should be consistent throughout document",severity:"error"})}}}return t},fix:(e,n)=>{let s=(n.options||{}).style||"consistent",i=e.split(/\r?\n/),r=W(i),o=s==="consistent"?null:s;if(o===null)for(let c=0;c<i.length;c++){if(r.has(c))continue;let u=i[c],f=c+1<i.length?i[c+1]:"";if(/^#{1,6}\s/.test(u)){o="atx";break}if(/^(?:=+|-+)\s*$/.test(f)&&u.trim().length>0&&!r.has(c+1)){o="setext";break}}if(o===null)return e;let l=[],a=!1;for(let c=0;c<i.length;c++){let u=i[c];if(r.has(c)){l.push(u);continue}let f=c+1<i.length?i[c+1]:"";if(o==="atx"){let m=/^=+\s*$/.test(f),h=/^-+\s*$/.test(f),d=r.has(c+1);if((m||h)&&!d&&u.trim().length>0&&!/^#{1,6}\s/.test(u)){let p=m?"#":"##";l.push(`${p} ${u.trim()}`),c++,a=!0;continue}}if(o==="setext"){let m=u.match(/^(#{1,2})\s+(.+?)\s*#*\s*$/);if(m){let h=m[1].length,d=m[2],p=(h===1?"=":"-").repeat(Math.max(3,d.length));l.push(d),l.push(p),a=!0;continue}}l.push(u)}return a?l.join(`
95
+ `):e}};var wl={meta:{docs:"Horizontal rule style should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).style||"consistent",o=null;for(let l=0;l<s.length;l++){let a=s[l].trim();if(a.match(/^([-*_])\1{2,}$/)){let u=a;if(r!=="consistent"&&a!==r)t.push({filePath:n.filePath,line:l+1,column:1,ruleId:"markdown/hr-style",message:`Expected horizontal rule style '${r}'`,severity:"error"});else if(r==="consistent"){if(o===null)o=u;else if(o!==u)t.push({filePath:n.filePath,line:l+1,column:1,ruleId:"markdown/hr-style",message:"Horizontal rule style should be consistent throughout document",severity:"error"})}}}return t}};var Rl={meta:{docs:"Lines should not exceed a specified length"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=n.options||{},r=i.line_length||80,o=i.code_blocks!==!1,l=i.tables!==!1,a=i.headings!==!1,c=!1;for(let u=0;u<s.length;u++){let f=s[u];if(/^(?:`{3,}|~{3,})/.test(f)){c=!c;continue}if(c&&!o)continue;if(!l&&/\|/.test(f))continue;if(!a&&/^#{1,6}\s/.test(f))continue;if(f.length>r)t.push({filePath:n.filePath,line:u+1,column:r+1,ruleId:"markdown/line-length",message:`Line length exceeds ${r} characters (${f.length} characters)`,severity:"warning"})}return t}};function Id(e){return e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s/g,"-")}var kl={meta:{docs:"Link fragments should reference valid headings"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s),r=new Set;for(let o=0;o<s.length;o++){if(i.has(o))continue;let a=s[o].match(/^#{1,6}\s+(.+?)(?:\s*#+\s*)?$/);if(a){let c=a[1].trim();r.add(Id(c))}}for(let o=0;o<s.length;o++){if(i.has(o))continue;let a=s[o].matchAll(/\[[^\]]+\]\(#([^)]+)\)/g);for(let c of a){let u=c[1];if(!r.has(u)){let f=c.index+1;t.push({filePath:n.filePath,line:o+1,column:f,ruleId:"markdown/link-fragments",message:`Link fragment '#${u}' does not match any heading`,severity:"error"})}}}return t}};var $l={meta:{docs:"Link and image reference definitions should be used"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s),r=new Map;for(let l=0;l<s.length;l++){if(i.has(l))continue;let c=s[l].match(/^\[([^\]]+)\]:\s*\S+/);if(c)r.set(c[1].toLowerCase(),l+1)}let o=new Set;for(let l=0;l<s.length;l++){if(i.has(l))continue;let a=s[l];if(a.match(/^\[(?:[^\]]+)\]:\s*\S+/))continue;let c=a.matchAll(/\[([^\]]+)\](?:\[([^\]]+)\])?(?!\()/g);for(let u of c){let f=(u[2]||u[1]).toLowerCase();o.add(f)}}for(let[l,a]of r)if(!o.has(l))t.push({filePath:n.filePath,line:a,column:1,ruleId:"markdown/link-image-reference-definitions",message:`Unused reference definition '[${l}]'`,severity:"warning"});return t},fix:(e)=>{let n=e.split(/\r?\n/),t=W(n),s=new Map;for(let o=0;o<n.length;o++){if(t.has(o))continue;let l=n[o].match(/^\s*\[([^\]]+)\]:\s*\S+/);if(l)s.set(o,l[1].toLowerCase())}if(s.size===0)return e;let i=new Set;for(let o=0;o<n.length;o++){if(t.has(o))continue;if(s.has(o))continue;let a=n[o].matchAll(/\[([^\]]+)\](?:\[([^\]]*)\])?(?!\()/g);for(let c of a){let u=(c[2]&&c[2].length>0?c[2]:c[1]).toLowerCase();i.add(u)}}let r=new Set;for(let[o,l]of s)if(!i.has(l))r.add(o);if(r.size===0)return e;return n.filter((o,l)=>!r.has(l)).join(`
96
+ `)}};var Pl={meta:{docs:"Link and image style should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s),o=(n.options||{}).style||"consistent",l=o==="consistent"?null:o;if(l===null){let c=0,u=0,f=!1;for(let m=0;m<s.length;m++){if(i.has(m))continue;let h=s[m];if(h.includes("<!--"))f=!0;if(h.includes("-->")){f=!1;continue}if(f)continue;if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(h))continue;let d=Ti(h);c+=(d.match(/\[[^\]]+\]\([^)]+\)/g)||[]).length,u+=(d.match(/\[[^\]]+\]\[(?:[^\]]*)\]/g)||[]).length}l=u>c?"reference":"inline"}let a=!1;for(let c=0;c<s.length;c++){if(i.has(c))continue;let u=s[c];if(u.includes("<!--"))a=!0;if(u.includes("-->")){a=!1;continue}if(a)continue;if(u.match(/^\[(?:[^\]]+)\]:\s*\S+/))continue;let f=Ti(u),m=f.matchAll(/\[[^\]]+\]\([^)]+\)/g);for(let d of m)if(l==="reference")t.push({filePath:n.filePath,line:c+1,column:d.index+1,ruleId:"markdown/link-image-style",message:o==="consistent"?"Link style should be consistent throughout document":"Expected reference style link",severity:o==="consistent"?"warning":"error"});let h=f.matchAll(/\[[^\]]+\]\[(?:[^\]]+)\]/g);for(let d of h)if(l==="inline")t.push({filePath:n.filePath,line:c+1,column:d.index+1,ruleId:"markdown/link-image-style",message:o==="consistent"?"Link style should be consistent throughout document":"Expected inline style link",severity:o==="consistent"?"warning":"error"})}return t},fix:(e,n)=>{let s=(n.options||{}).style||"consistent",i=e.split(/\r?\n/),r=W(i),o=new Map;for(let c=0;c<i.length;c++){if(r.has(c))continue;let u=i[c].match(/^\s*\[([^\]]+)\]:\s*(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?\s*$/);if(u){let f=u[1].toLowerCase(),m=u[2],h=u[3]??u[4]??u[5];if(!o.has(f))o.set(f,{url:m,title:h})}}if(o.size===0)return e;let l=s==="reference"?"reference":"inline";if(s==="consistent"){let c=0,u=0;for(let f=0;f<i.length;f++){if(r.has(f))continue;let m=i[f];if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(m))continue;let h=Ti(m);c+=(h.match(/\[[^\]]+\]\([^)]+\)/g)||[]).length,u+=(h.match(/\[[^\]]+\]\[(?:[^\]]*)\]/g)||[]).length}l=u>c?"reference":"inline"}if(l!=="inline")return e;let a=!1;for(let c=0;c<i.length;c++){if(r.has(c))continue;let u=i[c];if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(u))continue;let f=u;for(let m=0;m<8;m++){let h=f.replace(/(!?)\[((?:[^[\]]|\[[^\]]*\]\([^)]*\))+)\]\[([^\]]*)\]/g,(d,p,g,y)=>{let x=(y.trim()===""?g:y).toLowerCase(),k=o.get(x);if(!k)return d;let v=k.title?` "${k.title}"`:"";return`${p}[${g}](${k.url}${v})`});if(h===f)break;f=h}if(f!==u)i[c]=f,a=!0}return a?i.join(`
97
+ `):e}};function Ti(e){return e.replace(/(`+)([^`]+?)\1/g,(n)=>" ".repeat(n.length))}var vl={meta:{docs:"List items at the same level should have consistent indentation"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=new Map,r=!1;for(let o=0;o<s.length;o++){let l=s[o],a=l.match(/^(\s*)(?:[*\-+]|\d+\.)\s+/);if(a){r=!0;let c=a[1].length,u=Math.floor(c/2);if(i.has(u)){let f=i.get(u);if(c!==f)t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"markdown/list-indent",message:`Inconsistent indentation for list items at the same level. Expected ${f} spaces, found ${c}`,severity:"error"})}else i.set(u,c)}else if(l.trim().length===0){if(r){let c=s.slice(o+1).find((u)=>u.trim().length>0);if(c&&!/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(c))r=!1,i.clear()}}}return t}};var Il={meta:{docs:"Spaces after list markers should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=n.options||{},r=i.ul_single||1,o=i.ol_single||1;for(let l=0;l<s.length;l++){let a=s[l],c=a.match(/^(\s*)([*\-+])(\s+)/);if(c){let f=c[3].length;if(f!==r)t.push({filePath:n.filePath,line:l+1,column:c[1].length+2,ruleId:"markdown/list-marker-space",message:`Expected ${r} space${r!==1?"s":""} after list marker, found ${f}`,severity:"error"})}let u=a.match(/^(\s*)(\d+\.)(\s+)/);if(u){let f=u[3].length;if(f!==o)t.push({filePath:n.filePath,line:l+1,column:u[1].length+u[2].length+1,ruleId:"markdown/list-marker-space",message:`Expected ${o} space${o!==1?"s":""} after list marker, found ${f}`,severity:"error"})}}return t},fix:(e,n)=>{let t=n.options||{},s=t.ul_single||1,i=t.ol_single||1;return e.split(/\r?\n/).map((l)=>(l=l.replace(/^(\s*)([*\-+])\s+/,(a,c,u)=>`${c}${u}${" ".repeat(s)}`),l=l.replace(/^(\s*)(\d+\.)\s+/,(a,c,u)=>`${c}${u}${" ".repeat(i)}`),l)).join(`
98
+ `)}};var Ml={meta:{docs:"Images should have alternate text"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r];if(/^(?:`{3,}|~{3,})/.test(o.trim())){i=!i;continue}if(i)continue;let a=o.replace(/``[^`]+``/g,(c)=>" ".repeat(c.length)).replace(/`[^`]+`/g,(c)=>" ".repeat(c.length)).matchAll(/!\[\s*\]\([^)]+\)/g);for(let c of a){let u=c.index+1;t.push({filePath:n.filePath,line:r+1,column:u,ruleId:"markdown/no-alt-text",message:"Images should have alternate text (alt text)",severity:"error"})}}return t}};var Cl={meta:{docs:"Bare URLs should be wrapped in angle brackets"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s),r=!1;for(let o=0;o<s.length;o++){let l=s[o];if(i.has(o))continue;if(l.includes("<!--"))r=!0;if(l.includes("-->")){r=!1;continue}if(r)continue;if(/^\[(?:[^\]]+)\]:\s*\S+/.test(l))continue;let a=l.replace(/`[^`]+`/g,(f)=>" ".repeat(f.length)),c=/(?<![<(="'])https?:\/\/[^\s<>`)\]"']+(?![>\])"'])/g,u=a.matchAll(c);for(let f of u)t.push({filePath:n.filePath,line:o+1,column:f.index+1,ruleId:"markdown/no-bare-urls",message:"Bare URL used. Wrap in angle brackets: <url>",severity:"error"})}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=W(n),s=!1;return n.map((r,o)=>{if(t.has(o))return r;if(r.includes("<!--"))s=!0;if(r.includes("-->"))return s=!1,r;if(s)return r;if(/^\[(?:[^\]]+)\]:\s*\S+/.test(r))return r;return r.replace(/(?<![<(="'])https?:\/\/[^\s<>`)\]"']+(?![>\])"'])/g,"<$&>")}).join(`
99
+ `)}};var Sl={meta:{docs:"Blank lines inside blockquotes should use the blockquote symbol"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=!1;for(let o=0;o<s.length;o++){let l=s[o],a=o+1<s.length?s[o+1]:"";if(/^(?:`{3,}|~{3,})/.test(l.trim())){r=!r,i=!1;continue}if(r)continue;let c=/^\s*>/.test(l),u=l.trim().length===0,f=/^\s*>/.test(a);if(c)i=!0;else if(u&&i&&f)t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"markdown/no-blanks-blockquote",message:"Blank line inside blockquote should use blockquote symbol (>)",severity:"error"});else if(!c&&!u)i=!1}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=!1,s=!1,i=!1;for(let r=0;r<n.length;r++){let o=n[r],l=r+1<n.length?n[r+1]:"";if(/^(?:`{3,}|~{3,})/.test(o.trim())){s=!s,t=!1;continue}if(s)continue;let a=/^\s*>/.test(o),c=o.trim().length===0,u=/^\s*>/.test(l);if(a)t=!0;else if(c&&t&&u){let f=l.match(/^(\s*)>/),m=f?`${f[1]}>`:">";n[r]=m,i=!0}else if(!a&&!c)t=!1}return i?n.join(`
100
+ `):e}};var El={meta:{docs:"Multiple headings should not have the same content"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=Array.from({length:7},()=>new Map);for(let o=0;o<s.length;o++){let l=s[o];if(/^(?:`{3,}|~{3,})/.test(l.trim())){i=!i;continue}if(i)continue;if(/^\s*\[Compare changes\]\(/.test(l)){for(let m=3;m<=6;m++)r[m].clear();continue}let a=null,c=0,u=l.match(/^(#{1,6})\s+(.+?)(?:\s*#+\s*)?$/);if(u)c=u[1].length,a=u[2].trim();if(!a){let m=o+1<s.length?s[o+1]:"";if(/^(?:=+)\s*$/.test(m)&&l.trim().length>0)c=1,a=l.trim();else if(/^(?:-+)\s*$/.test(m)&&l.trim().length>0)c=2,a=l.trim()}if(!a||c===0)continue;for(let m=c+1;m<=6;m++)r[m].clear();let f=r[c];if(f.has(a))t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"markdown/no-duplicate-heading",message:`Duplicate heading "${a}" (first occurrence on line ${f.get(a)})`,severity:"error"});else f.set(a,o+1)}return t}};var Md=/[.!?:;,]\s*$/;function Ll(e,n,t){let s=e.match(/^\*\*([^*]+)\*\*\s*$/)||e.match(/^__([^_]+)__\s*$/),i=e.match(/^\*([^*]+)\*\s*$/)||e.match(/^_([^_]+)_\s*$/),r=s||i;if(!r)return null;if(n.trim().length!==0||t.trim().length!==0)return null;let o=r[1];if(Md.test(o))return null;if(o.trim().split(/\s+/).length>=7)return null;return o}var Tl={meta:{docs:"Emphasis should not be used for headings"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s);for(let r=0;r<s.length;r++){if(i.has(r))continue;let o=s[r],l=r>0?s[r-1]:"",a=r+1<s.length?s[r+1]:"";if(Ll(o,l,a)===null)continue;t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"markdown/no-emphasis-as-heading",message:"Emphasis used instead of a heading",severity:"warning"})}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=W(n),s=2,i=!1;for(let r=0;r<n.length;r++){if(t.has(r))continue;let o=n[r],l=o.match(/^(#{1,6})\s/);if(l){s=l[1].length;continue}let a=r>0?n[r-1]:"",c=r+1<n.length?n[r+1]:"",u=Ll(o,a,c);if(u===null)continue;let f=Math.min(6,Math.max(2,s+1));n[r]=`${"#".repeat(f)} ${u.trim()}`,i=!0}return i?n.join(`
101
+ `):e}};var Al={meta:{docs:"Links should not be empty"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r];if(/^(?:`{3,}|~{3,})/.test(o.trim())){i=!i;continue}if(i)continue;let l=o.replace(/`[^`]+`/g,(u)=>"x".repeat(u.length)),a=l.matchAll(/\[[^\]]+\]\(\s*\)/g);for(let u of a){let f=u.index+1;t.push({filePath:n.filePath,line:r+1,column:f,ruleId:"markdown/no-empty-links",message:"Empty link URL",severity:"error"})}let c=l.matchAll(/\[\s*\]\([^)]+\)/g);for(let u of c){let f=u.index+1;t.push({filePath:n.filePath,line:r+1,column:f,ruleId:"markdown/no-empty-links",message:"Empty link text",severity:"error"})}}return t}};var Ol={meta:{docs:"Spaces should be used instead of hard tabs"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r];if(/^(?:`{3,}|~{3,})/.test(o.trim())){i=!i;continue}if(i)continue;let l=o.indexOf("\t");if(l!==-1)t.push({filePath:n.filePath,line:r+1,column:l+1,ruleId:"markdown/no-hard-tabs",message:"Hard tabs should not be used",severity:"error"})}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=!1;return n.map((i)=>{if(/^(?:`{3,}|~{3,})/.test(i.trim()))return t=!t,i;if(t)return i;return i.replace(/\t/g," ")}).join(`
102
+ `)}};var _l={meta:{docs:"Inline HTML should not be used"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).allowed_elements||[],o=!1;for(let l=0;l<s.length;l++){let a=s[l];if(/^(?:`{3,}|~{3,})/.test(a.trim())){o=!o;continue}if(o)continue;let c=a;c=c.replace(/``[^`]+``/g,(f)=>" ".repeat(f.length)),c=c.replace(/`[^`]+`/g,(f)=>" ".repeat(f.length));let u=c.matchAll(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi);for(let f of u){let m=f[1].toLowerCase(),h=c.slice(f.index+1+m.length);if(h.startsWith("://")||m==="mailto"&&h.startsWith(":"))continue;if(!r.includes(m)){let d=f.index+1;t.push({filePath:n.filePath,line:l+1,column:d,ruleId:"markdown/no-inline-html",message:`Inline HTML element '<${m}>' should not be used`,severity:"warning"})}}}return t}};var Dl={meta:{docs:"ATX style headings must have a space after the hash"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s);for(let r=0;r<s.length;r++){if(i.has(r))continue;let l=s[r].match(/^(#{1,6})([^\s#])/);if(l)t.push({filePath:n.filePath,line:r+1,column:l[1].length+1,ruleId:"markdown/no-missing-space-atx",message:"No space after hash on atx style heading",severity:"error"})}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=W(n);return n.map((i,r)=>{if(t.has(r))return i;return i.replace(/^(#{1,6})([^\s#])/,"$1 $2")}).join(`
103
+ `)}};var Fl={meta:{docs:"Closed ATX style headings must have spaces inside the hashes"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s);for(let r=0;r<s.length;r++){if(i.has(r))continue;let o=s[r],l=o.match(/^(#{1,6})\s+(.+?)(#{1,6})\s*$/);if(l){let c=l[1],u=l[2],f=l[3];if(!u.endsWith(" ")){let m=c.length+1+u.length;t.push({filePath:n.filePath,line:r+1,column:m,ruleId:"markdown/no-missing-space-closed-atx",message:"No space inside hashes on closed atx style heading",severity:"error"})}}let a=o.match(/^(#{1,6})(\S.+?#{1,6})\s*$/);if(a)t.push({filePath:n.filePath,line:r+1,column:a[1].length+1,ruleId:"markdown/no-missing-space-closed-atx",message:"No space inside hashes on closed atx style heading",severity:"error"})}return t}};var Nl={meta:{docs:"Multiple consecutive blank lines should not be used"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=n.options||{},r=i.maximum!==void 0?i.maximum:1,o=0;for(let l=0;l<s.length;l++)if(s[l].trim().length===0){if(o++,o>r)t.push({filePath:n.filePath,line:l+1,column:1,ruleId:"markdown/no-multiple-blanks",message:`Multiple consecutive blank lines (max ${r})`,severity:"error"})}else o=0;return t},fix:(e,n)=>{let t=n.options||{},s=t.maximum!==void 0?t.maximum:1,i=e.split(/\r?\n/),r=[],o=0;for(let l of i)if(l.trim().length===0){if(o++,o<=s)r.push(l)}else o=0,r.push(l);return r.join(`
104
+ `)}};var Wl={meta:{docs:"ATX style headings should have only one space after the hash"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s);for(let r=0;r<s.length;r++){if(i.has(r))continue;let l=s[r].match(/^(#{1,6})\s{2,}/);if(l)t.push({filePath:n.filePath,line:r+1,column:l[1].length+1,ruleId:"markdown/no-multiple-space-atx",message:"Multiple spaces after hash on atx style heading",severity:"error"})}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=W(n);return n.map((i,r)=>{if(t.has(r))return i;return i.replace(/^(#{1,6})\s{2,}/,"$1 ")}).join(`
105
+ `)}};var Bl={meta:{docs:"Blockquote symbols should be followed by a single space"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s);for(let r=0;r<s.length;r++){if(i.has(r))continue;let l=s[r].match(/^(\s*)(>+)\s{2,}/);if(l){let a=l[1].length+l[2].length+1;t.push({filePath:n.filePath,line:r+1,column:a,ruleId:"markdown/no-multiple-space-blockquote",message:"Multiple spaces after blockquote symbol",severity:"error"})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=W(n);return n.map((i,r)=>{if(t.has(r))return i;return i.replace(/^(\s*>+)\s{2,}/,"$1 ")}).join(`
106
+ `)}};var jl={meta:{docs:"Closed ATX style headings should have only one space inside the hashes"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s);for(let r=0;r<s.length;r++){if(i.has(r))continue;let o=s[r],l=o.match(/^(#{1,6})\s{2,}(?:\S.*?|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])#{1,6}\s*$/);if(l)t.push({filePath:n.filePath,line:r+1,column:l[1].length+1,ruleId:"markdown/no-multiple-space-closed-atx",message:"Multiple spaces inside hashes on closed atx style heading",severity:"error"});let a=o.match(/^#{1,6}\s+(?:\S.*?|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\s{2,}(#{1,6})\s*$/);if(a){let c=o.lastIndexOf(a[1])-1;t.push({filePath:n.filePath,line:r+1,column:Math.max(1,c),ruleId:"markdown/no-multiple-space-closed-atx",message:"Multiple spaces inside hashes on closed atx style heading",severity:"error"})}}return t}};var Ul={meta:{docs:"Link syntax should not be reversed"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s);for(let r=0;r<s.length;r++){if(i.has(r))continue;let l=s[r].matchAll(/\(([^)]+)\)\[(?:[^\]]+)\]/g);for(let a of l){let c=a.index+1;t.push({filePath:n.filePath,line:r+1,column:c,ruleId:"markdown/no-reversed-links",message:"Reversed link syntax: should be [text](url) not (text)[url]",severity:"error"})}}return t}};var zl={meta:{docs:"Code span elements should not have spaces inside the backticks"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s);for(let r=0;r<s.length;r++){let o=s[r];if(i.has(r))continue;let l=/(`+)([\s\S]*?)\1/g;for(let a of o.matchAll(l)){let c=a[2];if(c.startsWith(" ")&&c.endsWith(" ")&&c.trim().length>0)t.push({filePath:n.filePath,line:r+1,column:a.index+1,ruleId:"markdown/no-space-in-code",message:"Spaces inside code span elements",severity:"error"})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=W(n),s=[];for(let i=0;i<n.length;i++){let r=n[i];if(t.has(i)){s.push(r);continue}s.push(r.replace(/(`+)([\s\S]*?)\1/g,(o,l,a)=>{if(a.startsWith(" ")&&a.endsWith(" ")&&a.trim().length>0)return`${l}${a.trim()}${l}`;return o}))}return s.join(`
107
+ `)}};var Cd=[/(?<![A-Za-z0-9])\*\*\s+[^*]+?\*\*(?![A-Za-z0-9])/g,/(?<![A-Za-z0-9])\*\*[^*]+?\s+\*\*(?![A-Za-z0-9])/g,/(?<![A-Za-z0-9])__\s+[^_]+?__(?![A-Za-z0-9])/g,/(?<![A-Za-z0-9])__[^_]+?\s+__(?![A-Za-z0-9])/g],ql={meta:{docs:"Emphasis markers should not have spaces inside them"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s);for(let r=0;r<s.length;r++){let o=s[r];if(i.has(r))continue;let l=o.replace(/`[^`]+`/g,(a)=>"\x01".repeat(a.length));for(let a of Cd)for(let c of l.matchAll(a))t.push({filePath:n.filePath,line:r+1,column:c.index+1,ruleId:"markdown/no-space-in-emphasis",message:"Spaces inside emphasis markers",severity:"error"})}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=W(n),s=[];for(let i=0;i<n.length;i++){let r=n[i];if(t.has(i)){s.push(r);continue}let o=Rt(r,(l)=>{let a=l;return a=a.replace(/(?<![A-Za-z0-9])(\*\*)\s+([^*]+?)\*\*(?![A-Za-z0-9])/g,"$1$2**"),a=a.replace(/(?<![A-Za-z0-9])(\*\*)([^*]+?)\s+\*\*(?![A-Za-z0-9])/g,"$1$2**"),a=a.replace(/(?<![A-Za-z0-9])(__)\s+([^_]+?)__(?![A-Za-z0-9])/g,"$1$2__"),a=a.replace(/(?<![A-Za-z0-9])(__)([^_]+?)\s+__(?![A-Za-z0-9])/g,"$1$2__"),a});s.push(o)}return s.join(`
108
+ `)}};var Kl={meta:{docs:"Link text should not have leading or trailing spaces"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s);for(let r=0;r<s.length;r++){if(i.has(r))continue;let l=s[r].matchAll(/\[([^\][]*)\]\([^)]*\)/g);for(let a of l){let c=a[1];if(/^\s/.test(c)||/\s$/.test(c)){let u=a.index+1;t.push({filePath:n.filePath,line:r+1,column:u,ruleId:"markdown/no-space-in-links",message:"Spaces inside link text",severity:"error"})}}}return t}};var Vl={meta:{docs:"Headings should not end with punctuation"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).punctuation||".,;:!?",o=!1;for(let l=0;l<s.length;l++){let a=s[l];if(/^(?:`{3,}|~{3,})/.test(a.trim())){o=!o;continue}if(o)continue;let c=a.match(/^#{1,6}\s+(.+?)(?:\s*#+\s*)?$/);if(c){let f=c[1].trim(),m=f[f.length-1];if(m&&r.includes(m))t.push({filePath:n.filePath,line:l+1,column:a.indexOf(f)+f.length,ruleId:"markdown/no-trailing-punctuation",message:`Trailing punctuation in heading: '${m}'`,severity:"error"})}let u=l+1<s.length?s[l+1]:"";if(/^(?:=+|-+)\s*$/.test(u)&&a.trim().length>0){let f=a.trim(),m=f[f.length-1];if(m&&r.includes(m))t.push({filePath:n.filePath,line:l+1,column:a.indexOf(f)+f.length,ruleId:"markdown/no-trailing-punctuation",message:`Trailing punctuation in heading: '${m}'`,severity:"error"})}}return t},fix:(e,n)=>{let s=(n.options||{}).punctuation||".,;:!?",i=new RegExp(`[${s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}]+$`),r=e.split(/\r?\n/),o=!1;return r.map((a,c)=>{if(/^(?:`{3,}|~{3,})/.test(a.trim()))return o=!o,a;if(o)return a;let u=a.match(/^(#{1,6}\s+)(.+?)(\s*#+\s*)?$/);if(u){let m=u[1],h=u[2],d=u[3]||"",p=h.replace(i,"");return`${m}${p}${d}`}let f=c+1<r.length?r[c+1]:"";if(/^(?:=+|-+)\s*$/.test(f)&&a.trim().length>0)return a.replace(i,"");return a}).join(`
109
+ `)}};var Hl={meta:{docs:"Lines should not end with trailing spaces"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.match(/\s+$/);if(o){let l=n.options||{},a=l.br_spaces!==void 0?l.br_spaces:2;if(a===0||o[0].length!==a)t.push({filePath:n.filePath,line:i+1,column:r.length-o[0].length+1,ruleId:"markdown/no-trailing-spaces",message:`Trailing spaces found (${o[0].length} space${o[0].length!==1?"s":""})`,severity:"error"})}}return t},fix:(e,n)=>{let t=e.split(/\r?\n/),s=n.options||{},i=s.br_spaces!==void 0?s.br_spaces:2;return t.map((o)=>{let l=o.match(/\s+$/);if(l){if(i>0&&l[0].length===i)return o;return o.replace(/\s+$/,"")}return o}).join(`
110
+ `)}};var Zl={meta:{docs:"Ordered list item prefix should follow specified style"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).style||"one_or_ordered",o=1;for(let l=0;l<s.length;l++){let a=s[l],c=a.match(/^(\s*)(\d+)\.\s+/);if(c){let u=Number.parseInt(c[2],10);if(r==="one"&&u!==1)t.push({filePath:n.filePath,line:l+1,column:c[1].length+1,ruleId:"markdown/ol-prefix",message:`Ordered list item prefix should be '1.', found '${u}.'`,severity:"error"});else if(r==="ordered"&&u!==o)t.push({filePath:n.filePath,line:l+1,column:c[1].length+1,ruleId:"markdown/ol-prefix",message:`Ordered list item prefix should be '${o}.', found '${u}.'`,severity:"error"});o++}else if(a.trim().length===0)o=1}return t},fix:(e,n)=>{let s=(n.options||{}).style||"one_or_ordered",i=e.split(/\r?\n/),r=[],o=1;for(let l of i){let a=l.match(/^(\s*)(\d+)(\.\s+)/);if(a){let c=a[1],u=a[3];if(s==="one")r.push(l.replace(/^(\s*)\d+(\.\s+)/,`${c}1${u}`));else if(s==="ordered")r.push(l.replace(/^(\s*)\d+(\.\s+)/,`${c}${o}${u}`)),o++;else r.push(l),o++}else if(r.push(l),l.trim().length===0)o=1}return r.join(`
111
+ `)}};var Gl={meta:{docs:"Proper names should have correct capitalization"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=n.options||{},r=i.names||[],o=i.code_blocks!==!1;if(r.length===0)return t;let l=W(s);for(let a=0;a<s.length;a++){if(l.has(a)&&!o)continue;let c=s[a];for(let u of r){let f=new RegExp(`\\b${u}\\b`,"gi"),m=c.matchAll(f);for(let h of m)if(h[0]!==u){let d=h.index+1;t.push({filePath:n.filePath,line:a+1,column:d,ruleId:"markdown/proper-names",message:`Incorrect capitalization of '${h[0]}', should be '${u}'`,severity:"error"})}}}return t}};var Jl={meta:{docs:"Reference links and images should use defined labels"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=new Set;for(let l of s){let a=l.match(/^\s*\[([^\]]+)\]:\s*\S+/);if(a)i.add(a[1].toLowerCase())}let r=!1,o=!1;for(let l=0;l<s.length;l++){let a=s[l];if(/^(?:`{3,}|~{3,})/.test(a.trim())){r=!r;continue}if(r)continue;if(a.includes("<!--"))o=!0;if(a.includes("-->")){o=!1;continue}if(o)continue;if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(a))continue;let c=a.replace(/`[^`]+`/g,(f)=>" ".repeat(f.length));c=c.replace(/!?\[[^\]]*\]\([^)]*\)/g,(f)=>" ".repeat(f.length));let u=c.matchAll(/!?\[([^\]]+)\]\[([^\]]*)\]/g);for(let f of u){let m=(f[2].trim()||f[1]).toLowerCase();if(!i.has(m))t.push({filePath:n.filePath,line:l+1,column:f.index+1,ruleId:"markdown/reference-links-images",message:`Reference link '[${m}]' is not defined`,severity:"error"})}}return t}};var Yl={meta:{docs:"Document should have required heading structure"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).headings||[];if(r.length===0)return t;let o=[];for(let a of s){let c=a.match(/^#{1,6}\s+(.+?)(?:\s*#+\s*)?$/);if(c)o.push(c[1].trim())}let l=0;for(let a=0;a<o.length&&l<r.length;a++)if(o[a]===r[l])l++;if(l<r.length)t.push({filePath:n.filePath,line:1,column:1,ruleId:"markdown/required-headings",message:`Missing required heading: '${r[l]}'`,severity:"error"});return t}};var Xl={meta:{docs:"Document should have only one top-level heading (h1)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s),r=-1;for(let o=0;o<s.length;o++){if(i.has(o))continue;let l=s[o],a=o+1<s.length?s[o+1]:"",c=!1;if(/^#\s/.test(l))c=!0;if(/^=+\s*$/.test(a)&&l.trim().length>0&&!i.has(o+1))c=!0;if(c)if(r===-1)r=o+1;else t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"markdown/single-title",message:`Multiple top-level headings in the same document (first h1 on line ${r})`,severity:"error"})}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=W(n),s=[],i=!1,r=!1;for(let o=0;o<n.length;o++){if(t.has(o)){s.push(n[o]);continue}let l=n[o],a=o+1<n.length?n[o+1]:"",c=/^#\s/.test(l),u=/^=+\s*$/.test(a)&&l.trim().length>0&&!t.has(o+1);if(c){if(!i)i=!0,s.push(l);else s.push(`#${l}`),r=!0;continue}if(u){if(!i){i=!0,s.push(l);continue}s.push(`## ${l.trim()}`),o++,r=!0;continue}s.push(l)}return r?s.join(`
112
+ `):e}};var Ql={meta:{docs:"Files should end with a single newline character"},check:(e,n)=>{let t=[];if(!e.endsWith(`
113
+ `)&&!e.endsWith(`\r
114
+ `)){let s=e.split(/\r?\n/);t.push({filePath:n.filePath,line:s.length,column:s[s.length-1].length+1,ruleId:"markdown/single-trailing-newline",message:"File should end with a single newline character",severity:"error"})}if(e.endsWith(`
115
+
116
+ `)||e.endsWith(`\r
117
+ \r
118
+ `)){let s=e.split(/\r?\n/);t.push({filePath:n.filePath,line:s.length,column:1,ruleId:"markdown/single-trailing-newline",message:"File should end with a single newline character (not multiple)",severity:"error"})}return t},fix:(e)=>`${e.replace(/[\r\n]+$/,"")}
119
+ `};var ea={meta:{docs:"Strong style should be consistent (asterisk or underscore)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s),o=(n.options||{}).style||"consistent",l=null;for(let a=0;a<s.length;a++){if(i.has(a))continue;let c=Qe(s[a]),u=c.matchAll(/\*\*([^*]+)\*\*/g);for(let m of u)if(o==="underscore")t.push({filePath:n.filePath,line:a+1,column:m.index+1,ruleId:"markdown/strong-style",message:"Expected underscore (__) for strong",severity:"error"});else if(o==="consistent"){if(l===null)l="asterisk";else if(l==="underscore")t.push({filePath:n.filePath,line:a+1,column:m.index+1,ruleId:"markdown/strong-style",message:"Strong style should be consistent throughout document",severity:"error"})}let f=c.matchAll(/__([^_]+)__/g);for(let m of f)if(o==="asterisk")t.push({filePath:n.filePath,line:a+1,column:m.index+1,ruleId:"markdown/strong-style",message:"Expected asterisk (**) for strong",severity:"error"});else if(o==="consistent"){if(l===null)l="underscore";else if(l==="asterisk")t.push({filePath:n.filePath,line:a+1,column:m.index+1,ruleId:"markdown/strong-style",message:"Strong style should be consistent throughout document",severity:"error"})}}return t},fix:(e,n)=>{let s=(n.options||{}).style||"consistent",i=e.split(/\r?\n/),r=W(i),o="asterisk";if(s==="asterisk")o="asterisk";else if(s==="underscore")o="underscore";else if(s==="consistent"){let a=null,c=null;for(let f=0;f<i.length;f++){if(r.has(f))continue;let m=Qe(i[f]);if(a===null){let h=m.match(/\*\*([^*]+)\*\*/);if(h)a={line:f,col:h.index}}if(c===null){let h=m.match(/__([^_]+)__/);if(h)c={line:f,col:h.index}}if(a&&c)break}if(a&&(!c||((f,m)=>f.line!==m.line?f.line-m.line:f.col-m.col)(a,c)<0))o="asterisk";else if(c)o="underscore"}let l=!1;for(let a=0;a<i.length;a++){if(r.has(a))continue;let c=i[a],u=Rt(c,(f)=>o==="asterisk"?f.replace(/__([^_]+)__/g,"**$1**"):f.replace(/\*\*([^*]+)\*\*/g,"__$1__"));if(u!==c)i[a]=u,l=!0}return l?i.join(`
120
+ `):e}};var ta={meta:{docs:"Table rows should have consistent column counts"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=-1,o=!1,l=rt(s);for(let a=0;a<s.length;a++){let c=s[a];if(/^(?:`{3,}|~{3,})/.test(c.trim())){if(o=!o,i)i=!1,r=-1;continue}if(o)continue;let u=l.has(a)&&/\|/.test(c)&&c.trim().length>0;if(u){let f=Sd(c);if(!i)i=!0,r=f;else if(f!==r)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/table-column-count",message:`Table row has ${f} column(s), expected ${r}`,severity:"error"})}else if(c.trim().length===0||!u){if(i)i=!1,r=-1}}return t}};function Sd(e){let n=e.trim();if(n.startsWith("|"))n=n.slice(1);if(n.endsWith("|")&&!n.endsWith("\\|"))n=n.slice(0,-1);if(n==="")return 0;let t=1,s=!1,i=0,r=0;while(r<n.length){let o=n[r];if(o==="\\"&&n[r+1]==="|"){r+=2;continue}if(o==="`"){let l=0;while(n[r+l]==="`")l++;if(!s)s=!0,i=l;else if(l===i)s=!1,i=0;r+=l;continue}if(!s&&o==="|")t++;r++}return t}var na={meta:{docs:"Table columns should have consistent alignment"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(/[-:]/.test(r)&&/\|/.test(r)){if(r.match(/^[|\s:.-]+$/)){let l=r.split("|").filter((a)=>a.trim().length>0);for(let a of l){let c=a.trim();if(!/^:?-+:?$/.test(c))t.push({filePath:n.filePath,line:i+1,column:r.indexOf(a)+1,ruleId:"markdown/table-column-style",message:"Invalid table column separator",severity:"error"})}}}}return t}};var sa={meta:{docs:"Table pipe style should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).style||"leading_and_trailing",o=!1,l=rt(s);for(let a=0;a<s.length;a++){let c=s[a];if(/^(?:`{3,}|~{3,})/.test(c.trim())){o=!o;continue}if(o)continue;if(l.has(a)&&/\|/.test(c)&&c.trim().length>0){let u=c.trim().startsWith("|"),f=c.trim().endsWith("|");if(r==="leading_and_trailing"){if(!u||!f)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have leading and trailing pipes",severity:"error"})}else if(r==="leading_only"){if(!u||f)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have leading pipe only",severity:"error"})}else if(r==="trailing_only"){if(u||!f)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have trailing pipe only",severity:"error"})}else if(r==="no_leading_or_trailing"){if(u||f)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should not have leading or trailing pipes",severity:"error"})}}}return t}};var ia={meta:{docs:"Unordered list indentation should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).indent||2,o=!1,l=[];for(let a=0;a<s.length;a++){let c=s[a];if(/^(?:`{3,}|~{3,})/.test(c.trim())){o=!o;continue}if(o)continue;if(c.trim()==="")continue;let u=c.match(/^(\s*)([*\-+])(\s+)/),f=c.match(/^(\s*)(\d+[.)])(\s+)/);if(!u&&!f){let x=c.match(/^(\s*)/)?.[1].length||0;while(l.length>0&&l[l.length-1].contentCol>x)l.pop();continue}let m=u||f,h=m[1].length,d=m[2],p=m[3],g=h+d.length+p.length,y=u?"ul":"ol";while(l.length>0&&h<l[l.length-1].contentCol)l.pop();if(y==="ul"){let x=l.length>0?l[l.length-1]:null;if(!x){if(h!==0&&h%r!==0)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/ul-indent",message:`Unordered list indentation should be ${r} spaces per level. Found ${h} spaces`,severity:"error"})}else if(x.type==="ul"){let k=x.contentCol,v=x.indent+r;if(h!==k&&h!==v)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/ul-indent",message:`Unordered list indentation should be ${r} spaces per level. Found ${h} spaces`,severity:"error"})}}l.push({indent:h,contentCol:g,type:y})}return t}};var ra={meta:{docs:"Unordered list style should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=W(s),o=(n.options||{}).style||"consistent",l=null;for(let a=0;a<s.length;a++){let c=s[a];if(i.has(a))continue;let u=c.match(/^(\s*)([*\-+])\s+/);if(u){let f=u[2];if(o==="asterisk"&&f!=="*")t.push({filePath:n.filePath,line:a+1,column:u[1].length+1,ruleId:"markdown/ul-style",message:`Expected asterisk (*) for unordered list, found '${f}'`,severity:"error"});else if(o==="dash"&&f!=="-")t.push({filePath:n.filePath,line:a+1,column:u[1].length+1,ruleId:"markdown/ul-style",message:`Expected dash (-) for unordered list, found '${f}'`,severity:"error"});else if(o==="plus"&&f!=="+")t.push({filePath:n.filePath,line:a+1,column:u[1].length+1,ruleId:"markdown/ul-style",message:`Expected plus (+) for unordered list, found '${f}'`,severity:"error"});else if(o==="consistent"){if(l===null)l=f;else if(l!==f)t.push({filePath:n.filePath,line:a+1,column:u[1].length+1,ruleId:"markdown/ul-style",message:`Unordered list style should be consistent throughout document. Expected '${l}', found '${f}'`,severity:"error"})}}}return t},fix:(e,n)=>{let s=(n.options||{}).style||"consistent",i=e.split(/\r?\n/),r=W(i),o="*";if(s==="asterisk")o="*";else if(s==="dash")o="-";else if(s==="plus")o="+";else if(s==="consistent")for(let a=0;a<i.length;a++){if(r.has(a))continue;let c=i[a].match(/^(\s*)([*\-+])\s+/);if(c){o=c[2];break}}return i.map((a,c)=>{if(r.has(c))return a;return a.replace(/^(\s*)([*\-+])(\s+)/,`$1${o}$3`)}).join(`
121
+ `)}};function Ed(e){let n=e.split(/\r?\n/);if(n[0]?.trim()!=="---")return{text:e,frontmatter:null,frontmatterEndLine:0};for(let t=1;t<n.length;t++)if(n[t].trim()==="---"){let s=n.slice(0,t+1);return{text:[...s.map(()=>""),...n.slice(t+1)].join(`
122
+ `),frontmatter:s,frontmatterEndLine:t+1}}return{text:e,frontmatter:null,frontmatterEndLine:0}}function Ld(e){let n=e.split(/\r?\n/);if(n[0]?.trim()!=="---")return{header:null,body:e};for(let t=1;t<n.length;t++)if(n[t].trim()==="---")return{header:n.slice(0,t+1).join(`
123
+ `),body:n.slice(t+1).join(`
124
+ `)};return{header:null,body:e}}function Td(e){return{meta:e.meta,check:(n,t)=>t.filePath.endsWith(".md")?e.check(n,t):[],fix:e.fix?(n,t)=>t.filePath.endsWith(".md")?e.fix(n,t):n:void 0}}function K(e){return{meta:e.meta,check:(n,t)=>{if(!t.filePath.endsWith(".md"))return[];let{text:s,frontmatterEndLine:i}=Ed(n),r=e.check(s,t);if(i>0)return r.filter((o)=>o.line>i+1);return r},fix:e.fix?(n,t)=>{if(!t.filePath.endsWith(".md"))return n;let{header:s,body:i}=Ld(n);if(s===null)return e.fix(n,t);let r=e.fix(i,t);if(r===i)return n;return`${s}
125
+ ${r}`}:void 0}}var oa={name:"markdown",rules:{"heading-increment":K(yl),"heading-style":K(xl),"no-missing-space-atx":K(Dl),"no-multiple-space-atx":K(Wl),"no-missing-space-closed-atx":K(Fl),"no-multiple-space-closed-atx":K(jl),"blanks-around-headings":K(il),"heading-start-left":K(bl),"no-duplicate-heading":K(El),"single-title":K(Xl),"no-trailing-punctuation":K(Vl),"ul-style":K(ra),"list-indent":K(vl),"ul-indent":K(ia),"ol-prefix":K(Zl),"list-marker-space":K(Il),"blanks-around-lists":K(rl),"no-trailing-spaces":K(Hl),"no-hard-tabs":K(Ol),"no-multiple-blanks":K(Nl),"no-multiple-space-blockquote":K(Bl),"no-blanks-blockquote":K(Sl),"blanks-around-fences":K(sl),"single-trailing-newline":Td(Ql),"blanks-around-tables":K(al),"no-reversed-links":K(Ul),"no-bare-urls":K(Cl),"no-space-in-links":K(Kl),"no-empty-links":K(Al),"link-fragments":K(kl),"reference-links-images":K(Jl),"link-image-reference-definitions":K($l),"link-image-style":K(Pl),"descriptive-link-text":K(hl),"line-length":K(Rl),"commands-show-output":K(ml),"fenced-code-language":K(pl),"code-block-style":K(cl),"code-fence-style":K(fl),"no-emphasis-as-heading":K(Tl),"no-space-in-emphasis":K(ql),"no-space-in-code":K(zl),"emphasis-style":K(dl),"strong-style":K(ea),"no-inline-html":K(_l),"hr-style":K(wl),"first-line-heading":K(gl),"required-headings":K(Yl),"proper-names":K(Gl),"no-alt-text":K(Ml),"table-pipe-style":K(sa),"table-column-count":K(ta),"table-column-style":K(na)}};var la={meta:{docs:"Prefer using global Buffer instead of requiring it",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=/(?:import\b[^;\n]*\bfrom\s*|require\s*\(\s*)['"](?:node:)?buffer['"]/;for(let r=0;r<s.length;r++){let o=s[r],l=o.trim();if(l.startsWith("//")||l.startsWith("/*")||l.startsWith("*"))continue;let a=o.match(i);if(!a||a.index===void 0)continue;if(!/\bBuffer\b/.test(o))continue;t.push({filePath:n.filePath,line:r+1,column:a.index+1,ruleId:"node/prefer-global/buffer",message:"Unexpected import of 'Buffer'. Use the global 'Buffer' instead",severity:"error",help:"`Buffer` is a global in Node.js \u2014 remove the import and use it directly."})}return t}};var aa={meta:{docs:"Prefer using global process instead of requiring it",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=/(?:import\b[^;\n]*\bfrom\s*|require\s*\(\s*)['"](?:node:)?process['"]/;for(let r=0;r<s.length;r++){let o=s[r],l=o.trim();if(l.startsWith("//")||l.startsWith("/*")||l.startsWith("*"))continue;let a=o.match(i);if(!a||a.index===void 0)continue;t.push({filePath:n.filePath,line:r+1,column:a.index+1,ruleId:"node/prefer-global/process",message:"Unexpected import of 'process'. Use the global 'process' instead",severity:"error",help:"`process` is a global in Node.js \u2014 remove the import and use it directly."})}return t}};var ca={name:"node",rules:{"prefer-global/buffer":b(la),"prefer-global/process":b(aa)}};var As={meta:{docs:"Enforce sorted imports (delegates to formatter check only)"},check:(e,n)=>{let t=e.split(/\r?\n/),s=0;while(s<t.length&&(/^\s*$/.test(t[s])||/^\s*\/.\/.*/.test(t[s])||/^\s*\/.\*/.test(t[s])))s++;let i=s,r=[];while(s<t.length&&/^\s*import\b/.test(t[s]))r.push(t[s].trim()),s++;if(r.length===0)return[];let o=r.join(`
126
+ `),l=t.slice(s).join(`
127
+ `),a=`${o}
128
+ ${l}`;if(Ai(a)!==a)return[{filePath:n.filePath,line:i+1,column:1,ruleId:"sort-imports",message:"Imports are not sorted/grouped consistently",severity:"warning"}];return[]},fix:(e)=>Ai(e)};var ua={name:"perfectionist",rules:{"sort-imports":b(As)}};import{dirname as Ad,resolve as Od}from"path";function Q(e){try{let n=JSON.parse(e);if(typeof n!=="object"||n===null||Array.isArray(n))return null;return n}catch{return null}}function _d(e,n){let t=e.split(`
129
+ `),s=1,i=0;for(let r of n){let o=new RegExp(`"${Wd(r)}"\\s*:`);for(let l=i;l<t.length;l++)if(o.test(t[l])){s=l+1,i=l+1;break}}return s}function Be(e){return Ad(e)}function Le(e,n){return Od(e,n)}function ne(e){let n="pkg";for(let t of e)if(/^\d+$/.test(t))n+=`[${t}]`;else if(!/^[a-z_$][a-z0-9_$]*$/i.test(t))n+=`["${t}"]`;else n+=`.${t}`;return n}function X(e,n){if(e.publishConfig?.[n]!==void 0)return[e.publishConfig[n],["publishConfig",n]];return[e[n],[n]]}var Dd=new RegExp(`(?:[\\s;]|^)(?:import[\\w,{}\\s*]*from|import\\s*['"*{]|export\\b\\s*(?:[*{]|default|type|function|const|var|let|async function)|import\\.meta\\b)`,"m"),Fd=new RegExp("(?:[\\s;]|^)(?:module.exports\\b|exports\\.\\w|require\\s*\\(|global\\.\\w|Object\\.(?:defineProperty|defineProperties|assign)\\s*\\(\\s*exports\\b)","m");function ot(e){let n=Nd(e),t=Dd.test(n),s=Fd.test(n);if(t&&s)return"mixed";if(t)return"ESM";if(s)return"CJS";return"unknown"}function fa(e,n){if(e.endsWith(".mjs"))return"ESM";if(e.endsWith(".cjs"))return"CJS";return n==="module"?"ESM":"CJS"}function ma(e){if(e==="ESM")return".mjs";if(e==="CJS")return".cjs";return".js"}function ha(e){return e===".mjs"||e===".cjs"}function Ze(e){return e.endsWith(".js")||e.endsWith(".mjs")||e.endsWith(".cjs")}function da(e){return/^#!\s*\//.test(e)}function Nd(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*/g,"")}function fe(e,n,t,s){Oi(e,n,t,s)}function Oi(e,n,t,s){if(typeof e==="string"){s(e,{path:n,isImports:t});return}if(Array.isArray(e)){s(e,{path:n,isImports:t});for(let i=0;i<e.length;i++)Oi(e[i],n.concat(String(i)),t,s);return}if(e!==null&&typeof e==="object"){let i=Object.keys(e);s(e,{path:n,isImports:t},i);for(let r of i)Oi(e[r],n.concat(r),t,s)}}function G(e,n,t,s,i,r,o){return{filePath:e,line:_d(n,t),column:1,ruleId:s,message:i,severity:r,...o&&{help:o}}}function Wd(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var _i={meta:{docs:"Disallow deprecated jsnext:main and jsnext fields",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[];if(t["jsnext:main"]!=null)s.push(G(n.filePath,e,["jsnext:main"],"publint/deprecated-field-jsnext",'pkg["jsnext:main"] is deprecated. pkg.module should be used instead.',"warning",'The jsnext:main field is no longer recognized by modern bundlers. Use "module" instead.'));if(t.jsnext!=null)s.push(G(n.filePath,e,["jsnext"],"publint/deprecated-field-jsnext","pkg.jsnext is deprecated. pkg.module should be used instead.","warning",'The jsnext field is no longer recognized by modern bundlers. Use "module" instead.'));return s}};var Di={meta:{docs:'Ensure "default" condition is last in exports objects',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"exports");if(i==null)return[];return fe(i,r,!1,(o,l,a)=>{if(!a||typeof o!=="object"||Array.isArray(o))return;if(!("default"in o))return;if(a[a.length-1]!=="default")s.push(G(n.filePath,e,l.path.concat("default"),"publint/exports-default-should-be-last",`${ne(l.path.concat("default"))} should be the last condition in the object so it doesn't take precedence over the keys following it.`,"error",'Conditions are resolved in order. "default" acts as a fallback and should come last.'))}),s}};var Fi={meta:{docs:"Warn against using fallback arrays in exports",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"exports");if(i==null)return[];return fe(i,r,!1,(o,l)=>{if(!Array.isArray(o))return;s.push(G(n.filePath,e,l.path,"publint/exports-fallback-array-use",`${ne(l.path)} uses fallback arrays which is not recommended. It works differently in some tools and may face inconsistent behaviors.`,"warning","Fallback arrays pick the first parseable value and have no practical use case in Node.js currently."))}),s}};var Ni={meta:{docs:"Ensure exports has a root entrypoint when main/module exist",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let[s]=X(t,"main"),[i]=X(t,"module"),[r,o]=X(t,"exports");if(s==null&&i==null||r==null)return[];if(typeof r!=="object"||Array.isArray(r))return[];let l=Object.keys(r);if(l.length===0)return[];if(!l[0]?.startsWith("."))return[];if(l.includes("."))return[];let c=[];if(s)c.push("main");if(i)c.push("module");return[G(n.filePath,e,o,"publint/exports-missing-root-entrypoint",`${ne(o)} is missing the root entrypoint export, which is defined in pkg.${c[0]}. Environments that support "exports" will ignore pkg.${c[0]} as "exports" takes the highest priority.`,"warning",`Add ${ne(o.concat("."))} to ensure the root entrypoint is accessible.`)]}};var Wi={meta:{docs:'Ensure "module" condition precedes "require" in exports',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"exports");if(i==null)return[];return fe(i,r,!1,(o,l,a)=>{if(!a||typeof o!=="object"||Array.isArray(o))return;if(!("module"in o)||!("require"in o))return;if(a.indexOf("module")>a.indexOf("require"))s.push(G(n.filePath,e,l.path.concat("module"),"publint/exports-module-should-precede-require",`${ne(l.path.concat("module"))} should come before the "require" condition so it can take precedence when used by a bundler.`,"error",'Bundlers prioritize conditions by order. "module" should precede "require" to ensure ESM is preferred.'))}),s}};var Bi={meta:{docs:'Ensure "types" condition is first in exports objects',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"exports");if(i==null)return[];return fe(i,r,!1,(o,l,a)=>{if(!a||typeof o!=="object"||Array.isArray(o))return;if(!("types"in o))return;let c=a.indexOf("types");if(c===0)return;if(a.slice(0,c).filter((f)=>{if(f.startsWith("types"))return!1;if(typeof o[f]==="object"&&o[f]!==null&&pa(o[f],"types"))return!1;return!0}).length>0)s.push(G(n.filePath,e,l.path.concat("types"),"publint/exports-types-should-be-first",`${ne(l.path.concat("types"))} should be the first condition in the object so it can be resolved by TypeScript.`,"error",'TypeScript resolves conditions in order. The "types" condition must come first to ensure correct type resolution.'))}),s}};function pa(e,n){for(let t in e){if(t===n)return!0;if(typeof e[t]==="object"&&e[t]!==null&&pa(e[t],n))return!0}return!1}var ji={meta:{docs:'Ensure exports values start with "./"',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"exports");if(i==null)return[];return fe(i,r,!1,(o,l)=>{if(typeof o!=="string")return;if(o.startsWith("./"))return;let a=`./${o.replace(/^[/]+/,"")}`;s.push(G(n.filePath,e,l.path,"publint/exports-value-invalid",`${ne(l.path)} is "${o}" which is invalid as it does not start with "./". Use "${a}" instead.`,"error",'All exports values must be relative paths starting with "./".'))}),s}};var Bd=[{field:"main",expectTypes:["string"]},{field:"module",expectTypes:["string"]},{field:"types",expectTypes:["string"]},{field:"typings",expectTypes:["string"]},{field:"browser",expectTypes:["string","object"]},{field:"bin",expectTypes:["string","object"]},{field:"exports",expectTypes:["string","object"]},{field:"imports",expectTypes:["object"]},{field:"name",expectTypes:["string"]},{field:"version",expectTypes:["string"]},{field:"description",expectTypes:["string"]},{field:"license",expectTypes:["string"]}],Ui={meta:{docs:"Ensure package.json fields have correct value types",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[];for(let{field:i,expectTypes:r}of Bd){let[o,l]=X(t,i);if(o==null)continue;let a=typeof o;if(!r.includes(a)){let c=r.length===1?r[0]:`${r.slice(0,-1).join(", ")} or ${r[r.length-1]}`;s.push(G(n.filePath,e,l,"publint/field-invalid-value-type",`${ne(l)} has an invalid ${a} type. Expected a ${c} type instead.`,"error",`The "${i}" field must be of type ${c}.`))}}return s}};var zi={meta:{docs:"Suggest adding exports when module field is present",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let[s,i]=X(t,"module"),[r]=X(t,"exports");if(s!=null&&r==null)return[G(n.filePath,e,i,"publint/has-module-but-no-exports","pkg.module is used to output ESM, but pkg.exports is not defined. As Node.js doesn't read pkg.module, the ESM output may be skipped. Consider adding pkg.exports to export the ESM output.","warning",'Node.js only reads "exports" for module resolution. Without it, the ESM entry point in "module" is ignored by Node.js.')];return[]}};var qi={meta:{docs:'Ensure "default" condition is last in imports objects',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"imports");if(i==null||typeof i!=="object")return[];return fe(i,r,!0,(o,l,a)=>{if(!a||typeof o!=="object"||Array.isArray(o))return;if(!("default"in o))return;if(a[a.length-1]!=="default")s.push(G(n.filePath,e,l.path.concat("default"),"publint/imports-default-should-be-last",`${ne(l.path.concat("default"))} should be the last condition in the object so it doesn't take precedence over the keys following it.`,"error",'Conditions are resolved in order. "default" acts as a fallback and should come last.'))}),s}};var Ki={meta:{docs:'Ensure imports keys start with "#"',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"imports");if(i==null||typeof i!=="object"||Array.isArray(i))return[];for(let o of Object.keys(i))if(!o.startsWith("#")){let l=`#${o.replace(/^[/]+/,"")}`,a=r.concat(o);s.push(G(n.filePath,e,a,"publint/imports-key-invalid",`${ne(a)} is invalid as the imports key does not start with "#". Use "${l}" instead.`,"error",'All imports keys must start with "#" to distinguish them from package specifiers.'))}return s}};var Vi={meta:{docs:'Ensure "module" condition precedes "require" in imports',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"imports");if(i==null||typeof i!=="object")return[];return fe(i,r,!0,(o,l,a)=>{if(!a||typeof o!=="object"||Array.isArray(o))return;if(!("module"in o)||!("require"in o))return;if(a.indexOf("module")>a.indexOf("require"))s.push(G(n.filePath,e,l.path.concat("module"),"publint/imports-module-should-precede-require",`${ne(l.path.concat("module"))} should come before the "require" condition so it can take precedence when used by a bundler.`,"error",'Bundlers prioritize conditions by order. "module" should precede "require" to ensure ESM is preferred.'))}),s}};var Hi={meta:{docs:'Ensure imports values start with "./"',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"imports");if(i==null||typeof i!=="object")return[];return fe(i,r,!0,(o,l)=>{if(typeof o!=="string")return;if(!o.startsWith("."))return;if(o.startsWith("./"))return;let a=`./${o.replace(/^[/]+/,"")}`;s.push(G(n.filePath,e,l.path,"publint/imports-value-invalid",`${ne(l.path)} is "${o}" which is invalid as it does not start with "./". Use "${a}" instead.`,"error",'Relative imports values must start with "./".'))}),s}};var Zi={meta:{docs:"Disallow local file references in dependencies",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],i=["dependencies","optionalDependencies","peerDependencies"];for(let r of i){let o=t[r];if(!o||typeof o!=="object")continue;for(let l of Object.keys(o)){let a=o[l];if(typeof a==="string"&&(a.startsWith("file:")||a.startsWith("link:")))s.push(G(n.filePath,e,[r,l],"publint/local-dependency",`The "${l}" dependency references "${a}" that will likely not work when installed by end-users.`,"error","Local file references (file: or link:) are not portable and will fail for consumers of the package."))}}return s}};var Gi={meta:{docs:'Suggest specifying the "type" field in package.json',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];if(t.type==null)return[G(n.filePath,e,["name"],"publint/use-type",'The package does not specify the "type" field. Node.js may attempt to detect the package type causing a small performance hit. Consider adding "type": "commonjs" or "type": "module".',"warning",'Adding "type" helps Node.js resolve module format without detection overhead.')];return[]}};import{existsSync as jd,readFileSync as Ud}from"fs";var Ji={meta:{docs:"Ensure bin files have a shebang for executability",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],i=Be(n.filePath),[r,o]=X(t,"bin");if(r==null)return[];if(typeof r==="string")ga(r,o,i,s,n.filePath,e);else if(typeof r==="object"){for(let l of Object.keys(r))if(typeof r[l]==="string")ga(r[l],o.concat(l),i,s,n.filePath,e)}return s}};function ga(e,n,t,s,i,r){let o=Le(t,e);if(!jd(o))return;if(!Ze(e))return;let l;try{l=Ud(o,"utf8")}catch{return}if(!da(l))s.push(G(i,r,n,"publint/bin-file-not-executable",`${ne(n)} is "${e}" but the file is not executable. It should start with a shebang, e.g. #!/usr/bin/env node.`,"error","Bin files must start with a shebang (e.g. #!/usr/bin/env node) to be executable."))}import{existsSync as ya,readFileSync as ba}from"fs";var Yi={meta:{docs:'Ensure files under "module" condition in exports are ESM',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],i=Be(n.filePath),[r,o]=X(t,"exports");if(r==null)return[];fe(r,o,!1,(c,u)=>{if(typeof c!=="string")return;if(!u.path.includes("module"))return;if(!c.startsWith("./")&&!c.startsWith("../"))return;if(c.includes("*"))return;let f=Le(i,c);if(!ya(f))return;if(!Ze(c))return;let m;try{m=ba(f,"utf8")}catch{return}if(ot(m)==="CJS")s.push(G(n.filePath,e,u.path,"publint/exports-module-should-be-esm",`${ne(u.path)} should be ESM, but the code is written in CJS.`,"error",'The "module" condition is only used by bundlers and must contain ESM code.'))});let[l,a]=X(t,"imports");if(l!=null&&typeof l==="object")fe(l,a,!0,(c,u)=>{if(typeof c!=="string")return;if(!u.path.includes("module"))return;if(!c.startsWith("./"))return;if(c.includes("*"))return;let f=Le(i,c);if(!ya(f))return;if(!Ze(c))return;let m;try{m=ba(f,"utf8")}catch{return}if(ot(m)==="CJS")s.push(G(n.filePath,e,u.path,"publint/exports-module-should-be-esm",`${ne(u.path)} should be ESM, but the code is written in CJS.`,"error",'The "module" condition is only used by bundlers and must contain ESM code.'))});return s}};import{existsSync as Bt}from"fs";import{dirname as zd,isAbsolute as qd,resolve as Kd}from"path";function Xi(e,n){let t=n;while(t.startsWith("./"))t=t.slice(2);let s=t.split("/")[0];if(!s||s===".."||s.startsWith("."))return!1;let i=qd(n)?zd(n).split("/")[0]||"/":Kd(e,s);return!Bt(i)}var Qi={meta:{docs:"Ensure files referenced in package.json exist",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],i=Be(n.filePath),r=["main","module","types","typings","unpkg","jsdelivr"];for(let u of r){let[f,m]=X(t,u);if(f==null||typeof f!=="string")continue;if(Xi(i,f))continue;let h=Le(i,f);if(!wa(h))s.push(G(n.filePath,e,m,"publint/file-does-not-exist",`${ne(m)} is "${f}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))}let[o,l]=X(t,"bin");if(o!=null){if(typeof o==="string")xa(o,l,s,n.filePath,e,i);else if(typeof o==="object"){for(let u of Object.keys(o))if(typeof o[u]==="string")xa(o[u],l.concat(u),s,n.filePath,e,i)}}let[a,c]=X(t,"exports");if(a!=null)fe(a,c,!1,(u,f)=>{if(typeof u!=="string")return;if(!u.startsWith("./")&&!u.startsWith("../"))return;if(u.includes("*"))return;if(Xi(i,u))return;let m=Le(i,u);if(!Bt(m))s.push(G(n.filePath,e,f.path,"publint/file-does-not-exist",`${ne(f.path)} is "${u}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))});return s}};function xa(e,n,t,s,i,r){if(Xi(r,e))return;let o=Le(r,e);if(!wa(o))t.push(G(s,i,n,"publint/file-does-not-exist",`${ne(n)} is "${e}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))}function wa(e){if(Bt(e))return!0;if(Bt(`${e}.js`))return!0;if(Bt(`${e}/index.js`))return!0;return!1}import{existsSync as Vd,readFileSync as Hd}from"fs";import{extname as Zd}from"path";var er={meta:{docs:"Ensure file code format matches its extension and package type",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],i=Be(n.filePath),r=t.type,[o,l]=X(t,"main");if(o!=null&&typeof o==="string")Ra(o,l,i,r,s,n.filePath,e);let[a,c]=X(t,"exports");if(a!=null)fe(a,c,!1,(u,f)=>{if(typeof u!=="string")return;if(!u.startsWith("./")&&!u.startsWith("../"))return;if(u.includes("*"))return;if(f.path.includes("browser"))return;Ra(u,f.path,i,r,s,n.filePath,e)});return s}};function Ra(e,n,t,s,i,r,o){let l=Le(t,e);if(!Vd(l))return;if(!Ze(e))return;let a;try{a=Hd(l,"utf8")}catch{return}let c=ot(a);if(c==="unknown"||c==="mixed")return;let u=fa(l,s);if(c===u)return;let f=Zd(l),m=ma(c),d=(ha(f)?"FILE_INVALID_EXPLICIT_FORMAT":"FILE_INVALID_FORMAT")==="FILE_INVALID_EXPLICIT_FORMAT"?`${ne(n)} is "${e}" and ends with the ${f} extension, but the code is written in ${c}. Consider using the ${m} extension.`:`${ne(n)} is "${e}" and is written in ${c}, but is interpreted as ${u}. Consider using the ${m} extension.`;i.push(G(r,o,n,"publint/file-invalid-format",d,"warning",`The file's code format (${c}) doesn't match the expected format (${u}) based on its extension and package type.`))}import{existsSync as Gd,readFileSync as Jd}from"fs";var tr={meta:{docs:'Ensure the "module" field points to an ESM file',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let[s,i]=X(t,"module");if(s==null||typeof s!=="string")return[];let r=Be(n.filePath),o=Le(r,s);if(!Gd(o))return[];if(!Ze(s))return[];let l;try{l=Jd(o,"utf8")}catch{return[]}if(ot(l)==="CJS")return[G(n.filePath,e,i,"publint/module-should-be-esm",`${ne(i)} should be ESM, but the code is written in CJS.`,"error",'The "module" field is intended for ESM output used by bundlers. It should point to an ESM file.')];return[]}};var ka={name:"publint",rules:{"use-type":pe(Gi),"local-dependency":pe(Zi),"deprecated-field-jsnext":pe(_i),"has-module-but-no-exports":pe(zi),"field-invalid-value-type":pe(Ui),"exports-types-should-be-first":pe(Bi),"exports-default-should-be-last":pe(Di),"exports-module-should-precede-require":pe(Wi),"exports-value-invalid":pe(ji),"exports-missing-root-entrypoint":pe(Ni),"exports-fallback-array-use":pe(Fi),"imports-key-invalid":pe(Ki),"imports-value-invalid":pe(Hi),"imports-default-should-be-last":pe(qi),"imports-module-should-precede-require":pe(Vi),"file-does-not-exist":pe(Qi),"file-invalid-format":pe(er),"module-should-be-esm":pe(tr),"bin-file-not-executable":pe(Ji),"exports-module-should-be-esm":pe(Yi)}};var $a={meta:{docs:"Ensure all imports appear before other statements",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=0;for(let o=0;o<s.length;o++){let l=s[o].trim();if(!l||l.startsWith("//")||l.startsWith("/*")||l.startsWith("*"))continue;let a=l.match(/^\s*import\s+/);if(!a&&l.length>0){if(i=!0,r===0)r=o+1}if(i&&a)t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"import/first",message:"Import statement must appear before other statements",severity:"error"})}return t}};var Pa={meta:{docs:"Disallow duplicate specifier names in a single import declaration"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.match(/^\s*import\s*\{([^}]*)\}\s*from\s*['"][^'"]+['"]/);if(!o)continue;let a=o[1].split(",").map((u)=>u.trim()).filter(Boolean).map((u)=>u.split(/\s+as\s+/i)[0].trim()),c=new Set;for(let u of a){if(c.has(u)){t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf(u)+1),ruleId:"pickier/import-dedupe",message:"Expect no duplication in imports",severity:"warning"});break}c.add(u)}}return t}};import{existsSync as Yd,readFileSync as Xd}from"fs";import{dirname as Qd,resolve as ep}from"path";var va={meta:{docs:"Ensure named imports correspond to a named export in the remote file",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=Qd(n.filePath);for(let r=0;r<s.length;r++){let l=s[r].match(/\bimport\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/);if(l){let a=l[1].split(",").map((m)=>m.trim().split(/\s+as\s+/)[0].trim()),c=l[2];if(!c.startsWith(".")&&!c.startsWith("/"))continue;let u=[".ts",".tsx",".js",".jsx",""],f="";for(let m of u){let h=ep(i,c+m);if(Yd(h)){f=Xd(h,"utf8");break}}if(f)for(let m of a){let h=new RegExp(`\\bexport\\s+(?:const|let|var|function|class)\\s+${m}\\b`),d=new RegExp(`\\bexport\\s+\\{[^}]*\\b${m}\\b[^}]*\\}`);if(![h,d].some((y)=>y.test(f)))t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"import/named",message:`'${m}' not found in '${c}'`,severity:"error"})}}}return t}};import{existsSync as Ia,readFileSync as tp}from"fs";import{dirname as Ma,resolve as Ca}from"path";var Sa={meta:{docs:"Ensure imports don't create circular dependencies",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=n.filePath,r=new Set,o=new Set;function l(c,u){if(o.has(c))return!0;if(r.has(c))return!1;r.add(c),o.add(c);try{let f=tp(c,"utf8"),m=a(f,Ma(c));for(let h of m)if(l(h,[...u,h]))return!0}catch{}return o.delete(c),!1}function a(c,u){let f=[],m=/\bimport(?:\s{2,}|\s+\S.*?(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))from\s+['"]([^'"]+)['"]/g,h;for(h=m.exec(c);h!==null;h=m.exec(c)){let d=h[1];if(d.startsWith(".")||d.startsWith("/")){let p=[".ts",".tsx",".js",".jsx",""];for(let g of p){let y=Ca(u,d+g);if(Ia(y)){f.push(y);break}}}}return f}for(let c=0;c<s.length;c++){let f=s[c].match(/\bimport(?:\s{2,}|\s+\S.*?(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))from\s+['"]([^'"]+)['"]/);if(f){let m=f[1];if(m.startsWith(".")||m.startsWith("/")){let h=[".ts",".tsx",".js",".jsx",""],d="";for(let p of h){let g=Ca(Ma(i),m+p);if(Ia(g)){d=g;break}}if(d){if(r.clear(),o.clear(),o.add(i),l(d,[i,d]))t.push({filePath:n.filePath,line:c+1,column:1,ruleId:"import/no-cycle",message:"Dependency cycle detected",severity:"error"})}}}}return t}};var Ea={meta:{docs:"Disallow duplicate module imports - all imports from the same module should be combined"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=new Map,r=!1;for(let o=0;o<s.length;o++){let l=s[o];if(r){let h=l.indexOf("*/");if(h>=0)l=l.slice(h+2),r=!1;else continue}let a=l.indexOf("/*"),c=l.indexOf("//");if(a>=0&&(c===-1||a<c)){let h=l.indexOf("*/",a+2);if(h>=0)l=l.slice(0,a)+l.slice(h+2);else r=!0,l=l.slice(0,a)}if(c>=0)l=l.slice(0,c);let u=l.trim();if(!u)continue;let f=u.match(/^import\s+(?:type\s+)?(?:\{[^}]*\}|[\w$]+(?:\s*,\s*\{[^}]*\})?|\*\s+as\s+[\w$]+)\s+from\s+(['"`])(.+?)\1/);if(f){let h=f[2];if(i.has(h)){let d=i.get(h);t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"no-duplicate-imports",message:`'${h}' imported multiple times (also imported on line${d.length>1?"s":""} ${d.join(", ")})`,severity:"error",help:`Combine all imports from '${h}' into a single import statement`}),d.push(o+1)}else i.set(h,[o+1])}let m=u.match(/^export\s+(?:type\s+)?(?:\{[^}]*\}|\*(?:\s+as\s+[\w$]+)?)\s+from\s+(['"`])(.+?)\1/);if(m){let h=m[2],d=`export:${h}`;if(i.has(d)){let p=i.get(d);t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"no-duplicate-imports",message:`'${h}' re-exported multiple times (also exported on line${p.length>1?"s":""} ${p.join(", ")})`,severity:"error",help:`Combine all re-exports from '${h}' into a single export statement`}),p.push(o+1)}else i.set(d,[o+1])}}return t}};var La={meta:{docs:"Disallow importing from dist directories"},check:(e,n)=>{let t=[],s=new RegExp(`^\\s*import\\s[^;]*?from\\s*['"]([^'"]+)['"]`,"m"),i=e.split(/\r?\n/);for(let r=0;r<i.length;r++){let o=i[r],l=o.match(s);if(!l)continue;let a=l[1];if(a==="dist"||(a.startsWith(".")||a.startsWith("/"))&&/(?:^|\/)dist(?:\/.|$)/.test(a))t.push({filePath:n.filePath,line:r+1,column:Math.max(1,o.indexOf(a)+1),ruleId:"pickier/no-import-dist",message:`Do not import modules in \`dist\` folder, got ${a}`,severity:"error"})}return t}};var Ta={meta:{docs:"Disallow importing from node_modules by explicit path"},check:(e,n)=>{let t=[],s=new RegExp(`^\\s*import\\s[^;]*?from\\s*['"]([^'"]+)['"]`,"m"),i=/require\(\s*['"]([^'"]+)['"]\s*\)/,r=e.split(/\r?\n/);for(let o=0;o<r.length;o++){let l=r[o],a=l.match(s),c=l.match(i),u=a?.[1]||c?.[1];if(!u)continue;if(u.includes("/node_modules/")){let f=Math.max(1,l.indexOf(u)+1);t.push({filePath:n.filePath,line:o+1,column:f,ruleId:"pickier/no-import-node-modules-by-path",message:"Do not import modules in `node_modules` folder by path",severity:"error"})}}return t}};import{existsSync as np}from"fs";import{dirname as sp,join as ip,resolve as rp}from"path";var Aa={meta:{docs:"Ensure imports point to a file/module that can be resolved",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=sp(n.filePath);for(let r=0;r<s.length;r++){let o=s[r],l=[...o.matchAll(/\bimport(?:\s{2,}|\s+\S.*?(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))from\s+['"]([^'"]+)['"]/g),...o.matchAll(/\bimport\s*\(\s*['"]([^'"]+)['"]\s*\)/g),...o.matchAll(/\brequire\s*\(\s*['"]([^'"]+)['"]\s*\)/g)];for(let a of l){let c=a[1];if(!c.startsWith(".")&&!c.startsWith("/"))continue;let u=[],f=[".ts",".tsx",".js",".jsx",".mjs",".cjs",""];for(let h of f){let d=rp(i,c+h);u.push(d),u.push(ip(d,`index${h}`))}if(!u.some((h)=>np(h)))t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"import/no-unresolved",message:`Unable to resolve path to module '${c}'`,severity:"error"})}}return t}};function Oa(e,n,t){let s=t.order==="desc"?-1:1,i=t.type||"alphabetical",r=t.ignoreCase?e.toLowerCase():e,o=t.ignoreCase?n.toLowerCase():n;if(i==="line-length")return(r.length-o.length)*s;if(i==="natural")return r.localeCompare(o,void 0,{numeric:!0,sensitivity:"base"})*s;if(i==="unsorted")return 0;return r.localeCompare(o)*s}var op=new RegExp(`^export\\s+\\{[^}]*\\}\\s+from\\s+['"][^'"]+['"];?\\s*$`);function Os(e){return op.test(e)}var _a={meta:{docs:"Ensure contiguous export statements are sorted consistently."},check:(e,n)=>{let t=[],s=n.config.pluginRules?.["pickier/sort-exports"]?.[1]||{},i=e.split(/\r?\n/),r=0;while(r<i.length){while(r<i.length&&!Os(i[r]))r++;if(r>=i.length)break;let o=[],l=r;while(l<i.length){let a=i[l];if(Os(a)){o.push({idx:l,line:a}),l++;continue}if(s.partitionByNewLine&&a.trim()==="")break;else break}if(o.length>1){let a=o.map((f)=>f.line),c=[...a].sort((f,m)=>Oa(f,m,s));if(!a.every((f,m)=>f===c[m])){let f=a.findIndex((h,d)=>h!==c[d]),m=o[f]?.idx??o[0].idx;t.push({filePath:n.filePath,line:m+1,column:1,ruleId:"pickier/sort-exports",message:"Export statements are not sorted.",severity:"warning"})}}r=l+1}return t},fix:(e,n)=>{let t=n.config.pluginRules?.["pickier/sort-exports"]?.[1]||{},i=[...e.split(/\r?\n/)],r=0;while(r<i.length){while(r<i.length&&!Os(i[r]))r++;if(r>=i.length)break;let o=[],l=r;while(l<i.length){let a=i[l];if(Os(a)){o.push(l),l++;continue}if(t.partitionByNewLine&&a.trim()==="")break;else break}if(o.length>1){let a=o.map((f)=>i[f]),c=[...a].sort((f,m)=>Oa(f,m,t));if(!a.every((f,m)=>f===c[m]))o.forEach((f,m)=>{i[f]=c[m]})}r=l+1}return i.join(`
130
+ `)}};var Da={meta:{docs:"Enforce sorted TypeScript heritage clauses (extends/implements lists)"},check:(e,n)=>{let t=n.options||{},s=t.type||"alphabetical",i=t.order||"asc",r=t.ignoreCase!==!1,o=Array.isArray(t.groups)?t.groups:[],l=t.customGroups||{},a=e.split(/\r?\n/),c=[],u=(v)=>i==="asc"?v:-v,f=(v,w)=>(r?v.toLowerCase():v).localeCompare(r?w.toLowerCase():w),m=(v,w)=>(r?v.toLowerCase():v).localeCompare(r?w.toLowerCase():w,void 0,{numeric:!0}),h=(v,w)=>{if(s==="line-length")return u(v.length-w.length);if(s==="natural")return u(m(v,w));if(s==="unsorted")return 0;return u(f(v,w))},d=Object.fromEntries(Object.entries(l).map(([v,w])=>{let L=(Array.isArray(w)?w:[w]).map((_)=>new RegExp(_));return[v,L]})),p=[];for(let v of o)if(Array.isArray(v))p.push(...v);else p.push(v);if(!p.includes("unknown"))p.push("unknown");let g=(v)=>{for(let[w,M]of Object.entries(d))if(M.some((L)=>L.test(v)))return w;return"unknown"},y=(v)=>{let w=[],M=0,L="";for(let _=0;_<v.length;_++){let C=v[_];if(C==="<")M++;else if(C===">")M=Math.max(0,M-1);if(C===","&&M===0){w.push(L.trim()),L="";continue}L+=C}if(L.trim())w.push(L.trim());return w},x=(v)=>{let w=v.trim(),M=w.match(/^([A-Z_$][\w$.]*)/i);return M?M[1]:w},k=(v,w)=>{let M=y(w);if(M.length<=1)return;let L=M.map(x),_=L.map(g),C=L.map((T,E)=>({n:T,g:_[E],i:E})).sort((T,E)=>{let S=p.indexOf(T.g),O=p.indexOf(E.g);if(S!==O)return S-O;return h(T.n,E.n)}).map((T)=>T.n);if(!L.every((T,E)=>T===C[E]))c.push({filePath:n.filePath,line:v,column:1,ruleId:"sort-heritage-clauses",message:"Heritage clauses are not sorted",severity:"warning"})};for(let v=0;v<a.length;v++){let w=a[v],M=w.match(/^\s*interface\s+[A-Za-z_$][^{]*\bextends\s+(.+?)\s*\{/);if(M)k(v+1,M[1]);let L=w.match(/^\s*class\s+[A-Za-z_$][^{]*\bimplements\s+(.+?)\s*\{/);if(L)k(v+1,L[1])}return c}};var Fa={meta:{docs:"Require object keys to be sorted (ESLint-compatible core rule subset)"},check:()=>[]};var Na={meta:{docs:"Enforce sorted named imports within each import statement"},check:(e,n)=>{let t=n.options||{},s=t.type||"alphabetical",i=t.order||"asc",r=t.ignoreCase!==!1,o=Boolean(t.ignoreAlias),l=e.split(/\r?\n/),a=[],c=(u,f)=>{let m=0;if(s==="line-length")m=u.length-f.length;else{let h=r?u.toLowerCase():u,d=r?f.toLowerCase():f;m=h.localeCompare(d)}return i==="asc"?m:-m};for(let u=0;u<l.length;u++){let m=l[u].match(/^\s*import\s+\{([^}]*)\}\s+from\s+['"][^'"]+['"]/);if(!m)continue;let d=m[1].split(",").map((x)=>x.trim()).filter(Boolean);if(d.length<=1)continue;let p=d.map((x)=>{let k=x.replace(/^type\s+/,""),v=k.match(/^([\w$]+)\s+as\s+([\w$]+)$/);if(v)return o?v[2]:v[1];let w=k.match(/^([\w$]+)$/);return w?w[1]:k}),g=[...p].sort(c);if(!p.every((x,k)=>x===g[k]))a.push({filePath:n.filePath,line:u+1,column:1,ruleId:"sort-named-imports",message:"Named imports are not sorted",severity:"warning"})}return a}};var Wa={meta:{docs:"Enforce sorted object keys"},check:(e,n)=>{let t=n.options||{},s=t.type||"alphabetical",i=t.order||"asc",r=t.ignoreCase!==!1,o=Boolean(t.partitionByNewLine),l=e.split(/\r?\n/),a=[],c=(f,m)=>{let h=0;if(s==="line-length")h=f.length-m.length;else{let d=r?f.toLowerCase():f,p=r?m.toLowerCase():m;h=d.localeCompare(p)}return i==="asc"?h:-h},u=0;while(u<l.length){let f=l[u],m=f.indexOf("{");if(m!==-1){let h=f.slice(0,m);if(/=\s*$|\(\s*$|\breturn\s*$/.test(h)){let d=0,p=u,g=u;for(;g<l.length;g++){for(let y of l[g])if(y==="{")d++;else if(y==="}")d--;if(d===0)break}if(g>p){let y=l.slice(p+1,g),x=[],k={startLine:p+2,props:[]},v=()=>{if(k.props.length)x.push(k);k={startLine:0,props:[]}};for(let w=0;w<y.length;w++){let M=y[w];if(o&&/^\s*$/.test(M)){v();continue}if(/^\s*\.\.\./.test(M))continue;if(/\{|\}/.test(M))continue;let L=M.match(/^\s*['"]?([\w$-]+)['"]?\s*:/);if(L){if(k.startLine===0)k.startLine=p+2+w;k.props.push({key:L[1],line:p+2+w})}}v();for(let w of x){let M=w.props.map((C)=>C.key),L=[...M].sort(c);if(!(M.length<=1||M.every((C,D)=>C===L[D]))&&w.props.length>0){let C=w.props[0];a.push({filePath:n.filePath,line:C.line,column:1,ruleId:"sort-objects",message:"Object keys are not sorted",severity:"warning"})}}u=g+1;continue}}}u++}return a}};var Ba={meta:{docs:"Enforce top-level functions to use function declarations"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(/^\s+/.test(r))continue;if(/^\s*(?:\/\/|\/\*)/.test(r))continue;let o=r.match(/^const\s+([A-Za-z_$][\w$]*)\s*=(.*)$/);if(!o)continue;let l=o[2].trim();if(/^\(?[A-Z_$,]*(?:\)\s*)?=>/i.test(l)||/^function\b/.test(l)){let a=r.indexOf("const")+1;t.push({filePath:n.filePath,line:i+1,column:a,ruleId:"pickier/top-level-function",message:"Top-level functions should be declared with function keyword",severity:"warning"});continue}if(l.trim().length===0||/[,({]$/.test(l.trim())){let a=s[i+1]||"";if(/^\s*(?:\(?[A-Za-z_$,]*(?:\)\s*)?=>|function\b)/.test(a)){let c=r.indexOf("const")+1;t.push({filePath:n.filePath,line:i+1,column:c,ruleId:"pickier/top-level-function",message:"Top-level functions should be declared with function keyword",severity:"warning"})}}}return t}};var lp=[[/^(block|inline|inline-block|flex|inline-flex|grid|inline-grid|flow-root|contents|hidden|table|table-caption|table-cell|table-column|table-column-group|table-footer-group|table-header-group|table-row-group|table-row|list-item|subgrid)$/,0],[/^(container|columns|break-after|break-before|break-inside|box-decoration|box-border|box-content|float|clear|isolation|object|overflow|overscroll|position|inset|top|right|bottom|left|start|end|z-|aspect|order)/,1],[/^(static|fixed|absolute|relative|sticky)$/,1],[/^(visible|invisible|collapse)$/,1],[/^(basis|flex-|grow|shrink|order|grid-|col-|row-|auto-cols|auto-rows|gap|justify|items|content|self|place)/,2],[/^(p|px|py|ps|pe|pt|pr|pb|pl|m|mx|my|ms|me|mt|mr|mb|ml|space|indent)-/,3],[/^(-?(p|px|py|ps|pe|pt|pr|pb|pl|m|mx|my|ms|me|mt|mr|mb|ml|space|indent)-)/,3],[/^(w-|h-|min-w|max-w|min-h|max-h|size-)/,4],[/^(font|text|tracking|leading|list|placeholder|vertical|whitespace|break|hyphens|content|truncate|overflow-ellipsis|overflow-clip|line-clamp|underline|overline|line-through|no-underline|uppercase|lowercase|capitalize|normal-case|italic|not-italic|ordinal|slashed-zero|lining-nums|oldstyle-nums|proportional-nums|tabular-nums|diagonal-fractions|stacked-fractions|normal-nums|antialiased|subpixel-antialiased)/,5],[/^(bg-|from-|via-|to-|gradient-)/,6],[/^(border|rounded|outline|ring|divide|accent)/,7],[/^(shadow|opacity|mix-blend|bg-blend)/,8],[/^(blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|saturate|sepia|backdrop)/,9],[/^(border-collapse|border-separate|border-spacing|table-auto|table-fixed|caption)/,10],[/^(transition|duration|ease|delay|animate)/,11],[/^(scale|rotate|translate|skew|origin|transform|perspective)/,12],[/^(appearance|cursor|caret|pointer-events|resize|scroll|snap|touch|select|will-change)/,13],[/^(fill|stroke)/,14],[/^(sr-only|not-sr-only)$/,15]],ap=/^([a-z0-9][-a-z0-9]{0,50}:)+(?!\[)/;function cp(e){let n=0;while(n<e.length){if(e[n]==="[")break;let t=e.indexOf(":",n);if(t===-1)break;if(e[t+1]==="[")break;n=t+1}return e.slice(n)}function up(e){let n=cp(e);if(n.startsWith("!"))n=n.slice(1);for(let[t,s]of lp)if(t.test(n))return s;return 99}function fp(e){let n=e.match(ap);if(!n)return 0;let t=n[0].slice(0,-1).split(":"),s={sm:1,md:2,lg:3,xl:4,"2xl":5},i=10;for(let r of t)if(s[r]!==void 0)i+=s[r];else i+=20;return i}var ja=new Map;function Ua(e){let n=ja.get(e);if(n)return n;let t={group:up(e),variant:fp(e)};return ja.set(e,t),t}function nr(e){return[...e].sort((n,t)=>{let s=Ua(n),i=Ua(t),r=s.group,o=i.group;if(r!==o)return r-o;let l=s.variant,a=i.variant;if(l!==a)return l-a;return n.localeCompare(t)})}var mp=/\b(?:class|className|:class)\s*=\s*(?:"([^"]*?)"|'([^']*?)')/g,hp=/\b(?:class|className|:class)\s*=\s*\{`([^`]*?)`\}/g,dp=/\b(?:clsx|cn|tw|cva|tv)\s*\(\s*(?:"([^"]*?)"|'([^']*?)')/g;function pp(e){let n=e.replace(/\[[^\]]*\]/g,"");if(/['"`]/.test(n))return!0;if(/[{}()=]/.test(n))return!0;if(/ \? | && | \|\| /.test(n))return!0;if(/\b(?:true|false|null|undefined|function|return|typeof|instanceof)\b/.test(n))return!0;return!1}function za(e){let n=[];if(!e.includes("class")&&!e.includes("clsx")&&!e.includes("cn(")&&!e.includes("tw(")&&!e.includes("cva(")&&!e.includes("tv("))return n;for(let t of[mp,hp,dp]){t.lastIndex=0;let s;while((s=t.exec(e))!==null){let i=s[1]??s[2]??"";if(!i.trim())continue;if(pp(i))continue;let r=e.indexOf(i,s.index);if(r===-1)continue;n.push({value:i,start:r,end:r+i.length})}}return n.sort((t,s)=>t.start-s.start),n}function qa(e){let n=[],t="",s=0;for(let i of e)if(i==="[")s++,t+=i;else if(i==="]")s=Math.max(0,s-1),t+=i;else if(/\s/.test(i)&&s===0){if(t)n.push(t),t=""}else t+=i;if(t)n.push(t);return n}function Ka(e){let n=nr(e);return e.every((t,s)=>t===n[s])}var Va={meta:{docs:"Enforce consistent Tailwind CSS class ordering (layout \u2192 spacing \u2192 typography \u2192 etc.).",recommended:!0,editsStringContent:!0},check:(e,n)=>{let t=[],s=za(e);for(let{value:i,start:r}of s){let o=qa(i);if(o.length<2)continue;if(!Ka(o)){let l=e.slice(0,r),a=(l.match(/\n/g)??[]).length+1,c=l.lastIndexOf(`
131
+ `),u=c===-1?r+1:r-c;t.push({filePath:n.filePath,line:a,column:u,ruleId:"pickier/sort-tailwind-classes",message:`Tailwind classes are not in the recommended order. Expected: "${nr(o).join(" ")}"`,severity:"warning",help:"Run with --fix to automatically sort Tailwind classes, or reorder them manually."})}}return t},fix:(e)=>{let n=za(e);if(n.length===0)return e;let t=[...n].reverse(),s=e;for(let{value:i,start:r,end:o}of t){let l=qa(i);if(l.length<2||Ka(l))continue;let a=nr(l).join(" ");s=s.slice(0,r)+a+s.slice(o)}return s}};var Ha={name:"pickier",rules:{"sort-exports":b(_a),"sort-objects":b(Wa),"sort-imports":b(As),"sort-named-imports":b(Na),"sort-heritage-clauses":b(Da),"sort-keys":b(Fa),"import-dedupe":b(Pa),"import-first":b($a),"import-named":b(va),"import-no-cycle":b(Sa),"import-no-unresolved":b(Aa),"no-import-dist":b(La),"no-import-node-modules-by-path":b(Ta),"no-duplicate-imports":b(Ea),"top-level-function":b(Ba),"sort-tailwind-classes":Va,"prefer-const":b(Es),"prefer-template":b(Ls),"no-unused-vars":b(Ye)}};var Za={name:"quality",rules:{"default-case":b(Hn),eqeqeq:b(Zn),"no-alert":b(Yn),"no-await-in-loop":b(Xn),"no-caller":b(Qn),"no-case-declarations":b(es),"no-else-return":b(ts),"no-empty":b(ns),"no-empty-function":b(ss),"no-eval":b(is),"no-extend-native":b(rs),"no-global-assign":b(ls),"no-implied-eval":b(as),"no-iterator":b(cs),"no-new":b(us),"no-new-func":b(fs),"no-new-wrappers":b(ms),"no-octal":b(hs),"no-param-reassign":b(ds),"no-proto":b(ps),"no-return-assign":b(gs),"no-shadow":b(bs),"no-throw-literal":b(xs),"no-use-before-define":b(ws),"no-useless-call":b(Rs),"no-with":b(Is),"require-await":b(Cs),complexity:b(Vn),"max-depth":b(Gn),"max-lines-per-function":b(Jn),"no-extra-boolean-cast":b(os),"no-lonely-if":b(Ft),"no-sequences":b(ys),"no-useless-concat":b(ks),"no-useless-escape":b($s),"no-useless-rename":b(Ps),"no-useless-return":b(Nt),"no-var":b(vs),"prefer-arrow-callback":b(Ms)}};var Ga={meta:{docs:"Detects potentially super-linear backtracking patterns in regex literals (heuristic)"},check:(e,n)=>{let t=[],s=/\/[^/\\\n]*(?:\\.[^/\\\n]*)*\//g,i=(f,m,h)=>{let d=e.slice(0,f),p=(d.match(/\n/g)||[]).length+1,g=f-d.lastIndexOf(`
132
+ `);t.push({filePath:n.filePath,line:p,column:g,ruleId:"no-super-linear-backtracking",message:h,severity:"error"})},r=[],o=/\/\*[\s\S]*?\*\//g,l;while(l=o.exec(e))r.push({start:l.index,end:l.index+l[0].length});let a=/\/\/[^\n]*/g,c;while(c=a.exec(e))r.push({start:c.index,end:c.index+c[0].length});let u;while(u=s.exec(e)){let f=u[0],m=u.index;if(r.some((x)=>m>=x.start&&m<x.end))continue;if(m>0){let x=e[m-1];if(x===")"||x==="]"||x==="."||/[\w$]/.test(x))continue;let k=f.slice(1,f.lastIndexOf("/"));if(/^\s+\w/.test(k)&&/\w\s*\)/.test(k))continue}let h=f.slice(1,f.lastIndexOf("/")),d=h.replace(/\[.*?\]/g,"");if(d.includes(".+?\\s*")||d.includes("\\s*.+?")||d.includes(".*\\s*")||d.includes("\\s*.*")){i(m,f.length,"The combination of ' .*' or ' .+?' with '\\s*' can cause super-linear backtracking due to exchangeable characters");continue}let g=d.replace(/\s+/g,"");if(/(?:\.\*\??){2,}/.test(g)||/(?:\.\+\??){2,}/.test(g)||/\.\*\??\.\+\?|\.\+\??\.\*\?/.test(g)){i(m,f.length,"Multiple adjacent unlimited wildcard quantifiers can cause super-linear backtracking");continue}let y=h.replace(/\\./g,"_").replace(/\[[^\]]*\]/g,"_");if(/\((?:\?:)?[^)]*?[+*][^)]*\)\s*[+*]/.test(y)){i(m,f.length,"Nested unlimited quantifiers detected (e.g., (.+)+) which can cause catastrophic backtracking");continue}}return t}};function gp(e,n){let t=n-1;while(t>=0&&(e[t]===" "||e[t]==="\t"))t--;let s=t>=0?e[t]:"",i="=(<>!&|?:;,{[+(~^%*/";if(!(t<0||i.includes(s)||/\b(?:return|typeof|void|delete|throw|new|in|of|case)\s*$/.test(e.slice(Math.max(0,t-5),t+1))))return null;let o=n+1,l=!1,a=!1,c=-1;while(o<e.length){let p=e[o];if(a)a=!1;else if(p==="\\")a=!0;else if(p==="["){if(!l)l=!0}else if(p==="]"){if(l)l=!1}else if(p==="/"&&!l){c=o;break}else if(p===`
133
+ `)break;o++}if(c<=n)return null;let u=e.slice(n+1,c),f=c+1;while(f<e.length&&/[gimsuvy]/.test(e[f]))f++;if(/\\[1-9]/.test(u))return null;let m=0,h=-1,d=!1;for(let p=0;p<u.length;p++){if(u[p]==="\\"){p++;continue}if(u[p]==="["&&!d){d=!0;continue}if(u[p]==="]"&&d){d=!1;continue}if(d)continue;if(u[p]==="("&&u.slice(p+1,p+3)!=="?:"&&u.slice(p+1,p+3)!=="?="&&u.slice(p+1,p+3)!=="?!"&&u.slice(p+1,p+4)!=="?<="&&u.slice(p+1,p+4)!=="?<!"){if(h<0)h=p;m++}}if(m===0)return null;return{patternStart:n,patternEnd:f,pattern:u,capCount:m,firstCapOffset:h}}function yp(e,n,t){let s=t;while(s<e.length&&(e[s]===" "||e[s]==="\t"))s++;if(e[s]==="."){let a=e.slice(s+1,s+20);if(/^test\s*\(/.test(a))return!1;if(/^exec\s*\(/.test(a))return!0}let i=n-1;while(i>=0&&(e[i]===" "||e[i]==="\t"))i--;if(e[i]==="("){let c=i-1;while(c>=0&&(e[c]===" "||e[c]==="\t"))c--;let u=e.slice(Math.max(0,c-20),c+1);if(/\.match\s*$/.test(u))return!0;if(/\.matchAll\s*$/.test(u))return!0;if(/\.exec\s*$/.test(u))return!0;if(/\.replace\s*$/.test(u))return!0;if(/\.replaceAll\s*$/.test(u))return!0;if(/\.split\s*$/.test(u))return!0;if(/\.search\s*$/.test(u))return!1;if(/\.test\s*$/.test(u))return!1}let r=e.lastIndexOf(`
134
+ `,n)+1,l=e.slice(r,n).trim().match(/(?:const|let|var)\s+(\w+)\s*=\s*$/);if(l){let a=l[1],c=e.slice(t),u=new RegExp(`\\b${a}\\.exec\\s*\\(`),f=new RegExp(`\\b${a}\\.test\\s*\\(`),m=new RegExp(`\\.match(?:All)?\\s*\\(\\s*${a}\\s*\\)`),h=new RegExp(`\\.replace(?:All)?\\s*\\(\\s*${a}`),d=u.test(c),p=m.test(c),g=h.test(c),y=f.test(c);if(d||p||g)return!0;if(y)return!1;return!0}return!0}function bp(e,n){let t=n-1;while(t>=0&&(e[t]===" "||e[t]==="\t"))t--;let s=t>=0?e[t]:"",i="=(<>!&|?:;,{[+(~^%*/";if(!(t<0||i.includes(s)||/\b(?:return|typeof|void|delete|throw|new|in|of|case)\s*$/.test(e.slice(Math.max(0,t-5),t+1))))return n+1;let o=n+1,l=!1,a=!1;while(o<e.length){let c=e[o];if(a)a=!1;else if(c==="\\")a=!0;else if(c==="["){if(!l)l=!0}else if(c==="]"){if(l)l=!1}else if(c==="/"&&!l){o++;while(o<e.length&&/[gimsuvy]/.test(e[o]))o++;return o}else if(c===`
135
+ `)break;o++}return n+1}function xp(e,n){let t=[],s=n.filePath,i=0;while(i<e.length){let r=e[i];if(r==="/"&&e[i+1]==="/"){while(i<e.length&&e[i]!==`
136
+ `)i++;continue}if(r==="/"&&e[i+1]==="*"){i+=2;while(i<e.length-1&&!(e[i]==="*"&&e[i+1]==="/"))i++;i+=2;continue}if(r==="'"||r==='"'||r==="`"){let o=r;i++;while(i<e.length){if(e[i]==="\\"){i+=2;continue}if(e[i]===o){i++;break}i++}continue}if(r==="/"){let o=gp(e,i);if(!o){let l=bp(e,i);if(l>i+1)i=l;else i++;continue}if(!yp(e,o.patternStart,o.patternEnd)){let l=o.patternStart+1+(o.firstCapOffset>=0?o.firstCapOffset:0),a=e.slice(0,l),c=(a.match(/\r?\n/g)||[]).length+1,u=l-(a.lastIndexOf(`
137
+ `)+1)+1;t.push({filePath:s,line:c,column:u,ruleId:"regexp/no-unused-capturing-group",message:"Unused capturing group in regular expression; use non-capturing group (?:...) instead",severity:"error"})}i=o.patternEnd;continue}i++}return t}var Ja={meta:{docs:"Flags regex literals with unused capturing groups (context-aware)",recommended:!1},check(e,n){return xp(e,n)}};var Ya={meta:{docs:"Disallow lazy quantifiers that don't affect the matching behavior",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(r.trim().startsWith("//")||r.trim().startsWith("/*")||r.trim().startsWith("*"))continue;let o=/\/(?![/*])([^/\n\r\\]|\\.)+\/[gimsuvy]*/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let a=l[0],c=a.slice(1,a.lastIndexOf("/"));if(/[+*?]\?\$$/.test(c))t.push({filePath:n.filePath,line:i+1,column:l.index+c.search(/[+*?]\?\$$/)+2,ruleId:"regexp/no-useless-lazy",message:"Lazy quantifier is useless before end-of-string anchor",severity:"error"});if(/[+*?]\?$/.test(c))t.push({filePath:n.filePath,line:i+1,column:l.index+c.length-1,ruleId:"regexp/no-useless-lazy",message:"Lazy quantifier is useless at the end of the pattern",severity:"error"})}}return t}};var Xa={name:"regexp",rules:{"no-super-linear-backtracking":b(Ga),"no-unused-capturing-group":b(Ja),"no-useless-lazy":b(Ya)}};var Qa={meta:{docs:"Use $() instead of backticks for command substitution",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="",o=!1;for(let l=0;l<s.length;l++){let a=s[l];if(i){if(a.trim()===r)i=!1;continue}let c=a.match(/<<-?\s*['"]?(\w+)['"]?/);if(c)i=!0,r=c[1];if(a.replace(/^\s+/,"").startsWith("#"))continue;o=!1;for(let f=0;f<a.length;f++){let m=a[f];if(m==="#"&&!o)break;if(m==="\\"){f++;continue}if(m==="'"){o=!o;continue}if(o)continue;if(m==="`"){t.push({filePath:n.filePath,line:l+1,column:f+1,ruleId:"shell/command-substitution",message:"Use $(...) instead of backticks for command substitution",severity:"error",help:"Replace `cmd` with $(cmd) for better readability and nesting support"});for(f++;f<a.length&&a[f]!=="`";f++)if(a[f]==="\\")f++}}}return t},fix(e,n){let t=e.split(/\r?\n/),s=[],i=!1,r="";for(let o of t){if(i){if(s.push(o),o.trim()===r)i=!1;continue}let l=o.match(/<<-?\s*['"]?(\w+)['"]?/);if(l)i=!0,r=l[1];let a="",c=!1,u=0;while(u<o.length){let f=o[u];if(f==="#"&&!c){a+=o.slice(u);break}if(f==="\\"){a+=o.slice(u,u+2),u+=2;continue}if(f==="'"){c=!c,a+=f,u++;continue}if(c){a+=f,u++;continue}if(f==="`"){let m="";u++;while(u<o.length&&o[u]!=="`")if(o[u]==="\\")m+=o[u+1]||"",u+=2;else m+=o[u],u++;u++,a+=`$(${m})`}else a+=f,u++}s.push(a)}return s.join(`
138
+ `)}};var ec={meta:{docs:"Require error handling after cd commands",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=l.match(/<<-?\s*['"]?(\w+)['"]?/);if(a)i=!0,r=a[1];let c=l.replace(/^\s+/,"");if(c.startsWith("#"))continue;let u=c.match(/^cd\s+/);if(!u)continue;let f=/\|\||&&/.test(l),m=/^\s*(?:if|elif|while|until)\s/.test(c)||/\bif\s+cd\b/.test(l),h=/\(.*\bcd\b.*\)/.test(l);if(!f&&!m&&!h)t.push({filePath:n.filePath,line:o+1,column:u.index+1,ruleId:"shell/no-cd-without-check",message:"cd without error handling \u2014 if it fails, subsequent commands run in the wrong directory",severity:"warning",help:"Use: cd dir || exit 1 (or || return 1 inside functions)"})}return t}};var tc={meta:{docs:"Disallow use of eval in shell scripts",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=l.match(/<<-?\s*['"]?(\w+)['"]?/);if(a)i=!0,r=a[1];if(l.replace(/^\s+/,"").startsWith("#"))continue;if(l.match(/(?:^|[;&|]\s*|^\s+)eval\s/)){let f=l.indexOf("eval");t.push({filePath:n.filePath,line:o+1,column:f+1,ruleId:"shell/no-eval",message:"Avoid using eval \u2014 it re-parses arguments and can lead to code injection",severity:"error",help:"Refactor to avoid eval. Consider using arrays for dynamic commands or indirect variable references with ${!var}"})}}return t}};var nc={meta:{docs:"Flag exit inside subshells where it only exits the subshell",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="",o=0;for(let l=0;l<s.length;l++){let a=s[l];if(i){if(a.trim()===r)i=!1;continue}let c=a.match(/<<-?\s*['"]?(\w+)['"]?/);if(c)i=!0,r=c[1];if(a.replace(/^\s+/,"").startsWith("#"))continue;let f=!1,m=!1;for(let h=0;h<a.length;h++){let d=a[h];if(d==="#"&&!f&&!m)break;if(d==="\\"&&!f){h++;continue}if(d==="'"&&!m){f=!f;continue}if(d==='"'&&!f){m=!m;continue}if(!f&&!m){if(d==="("&&h>0&&a[h-1]!=="$"&&a[h+1]!=="(")o++;else if(d==="("&&h===0&&a[h+1]!=="(")o++;else if(d===")"&&o>0&&(h+1>=a.length||a[h+1]!==")"))o--}}if(o>0){let h=a.match(/\bexit\b/);if(h)t.push({filePath:n.filePath,line:l+1,column:h.index+1,ruleId:"shell/no-exit-in-subshell",message:"exit inside a subshell only exits the subshell, not the script",severity:"warning",help:"Restructure to avoid subshells, or use return if inside a function"})}if(o===0){let h=a.match(/(?<!\$)\((?!\()([^)]*\bexit\b[^)]*)\)(?!\))/);if(h){let d=a.indexOf("exit",h.index);t.push({filePath:n.filePath,line:l+1,column:d+1,ruleId:"shell/no-exit-in-subshell",message:"exit inside a subshell only exits the subshell, not the script",severity:"warning",help:"Restructure to avoid subshells, or use return if inside a function"})}}}return t}};var sc={meta:{docs:"Disallow parsing ls output \u2014 use globs or find instead",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=l.match(/<<-?\s*['"]?(\w+)['"]?/);if(a)i=!0,r=a[1];if(l.replace(/^\s+/,"").startsWith("#"))continue;if(l.match(/\bls\b[^|]*\|/)){let h=l.indexOf("ls");t.push({filePath:n.filePath,line:o+1,column:h+1,ruleId:"shell/no-ls-parsing",message:"Don't parse ls output \u2014 filenames can contain special characters",severity:"warning",help:'Use globs (for f in *.txt), find (find . -name "*.txt"), or stat instead'});continue}let f=l.match(/\$\(\s*ls\b/);if(f){let h=f.index+1;t.push({filePath:n.filePath,line:o+1,column:h,ruleId:"shell/no-ls-parsing",message:"Don't use ls in command substitution \u2014 use globs instead",severity:"warning",help:"Replace $(ls *.txt) with glob patterns: for f in *.txt; do ...; done"});continue}let m=l.match(/`\s*ls\b/);if(m){let h=m.index+1;t.push({filePath:n.filePath,line:o+1,column:h,ruleId:"shell/no-ls-parsing",message:"Don't use ls in command substitution \u2014 use globs instead",severity:"warning",help:"Replace `ls` with glob patterns"})}}return t}};var ic={meta:{docs:"Detect useless use of cat (UUOC)",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=l.match(/<<-?\s*['"]?(\w+)['"]?/);if(a)i=!0,r=a[1];if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=l.match(/\bcat\s+(["']?[\w.\/~${}*?-]+["']?)\s*\|/);if(u){let f=l.indexOf("cat");t.push({filePath:n.filePath,line:o+1,column:f+1,ruleId:"shell/no-useless-cat",message:`Useless use of cat \u2014 pipe the file directly instead of \`cat ${u[1]} | ...\``,severity:"warning",help:`Use \`cmd < ${u[1]}\` or pass the file as an argument to the command`})}}return t}};var rc={meta:{docs:"Flag variables inside single quotes where they won't expand",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=l.match(/<<-?\s*['"]?(\w+)['"]?/);if(a)i=!0,r=a[1];if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=!1,f=!1,m=-1;for(let h=0;h<l.length;h++){let d=l[h];if(d==="#"&&!u&&!f)break;if(d==="\\"&&!u){h++;continue}if(d==='"'&&!u){f=!f;continue}if(d==="'"&&!f)if(!u)u=!0,m=h;else{let g=l.slice(m+1,h).match(/\$(?:[A-Za-z_]\w*|\{[^}]+\}|\([^)]*\))/);if(g)t.push({filePath:n.filePath,line:o+1,column:m+1+g.index+1,ruleId:"shell/no-variable-in-single-quotes",message:`Variable ${g[0]} is inside single quotes and won't be expanded`,severity:"warning",help:`Use double quotes if you want variable expansion: "..." instead of '...'`});u=!1}}}return t}};var wp=[/^\s*(?:local|export|declare|typeset|readonly)\s+/,/\[\[.*\]\]/,/\(\(.*\)\)/],sr=/^\$(?:\{[A-Za-z_]\w*(?:[:#%\/][^}]*)?\}|[A-Za-z_]\w*)/,oc={meta:{docs:"Quote variable expansions to prevent word splitting and globbing",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=Se(l);if(a){if(i=!0,r=a,new RegExp(`<<-?\\s*['"]${a}['"]`).test(l))continue}if(l.replace(/^\s+/,"").startsWith("#"))continue;if(wp.some((m)=>m.test(l)))continue;let u=[],f=0;while(f<l.length){let m=u[u.length-1];if(m==="squote"){if(l[f]==="'")u.pop();f++;continue}if(l[f]==="\\"&&f+1<l.length){f+=2;continue}if(m==="dquote"){let d=l[f];if(d==='"'){u.pop(),f++;continue}if(d==="$"&&l[f+1]==="("&&l[f+2]==="("){u.push("arith"),f+=3;continue}if(d==="$"&&l[f+1]==="("){u.push("subshell"),f+=2;continue}if(d==="$"){let p=l.slice(f).match(sr);if(p){f+=p[0].length;continue}}f++;continue}if(m==="arith"){let d=l[f];if(d===")"&&l[f+1]===")"){u.pop(),f+=2;continue}if(d==="$"){let p=l.slice(f).match(sr);if(p){f+=p[0].length;continue}}f++;continue}let h=l[f];if(h==="#"&&(f===0||/\s/.test(l[f-1])))break;if(h==="'"){u.push("squote"),f++;continue}if(h==='"'){u.push("dquote"),f++;continue}if(h==="$"&&l[f+1]==="("&&l[f+2]==="("){u.push("arith"),f+=3;continue}if(h==="$"&&l[f+1]==="("){u.push("subshell"),f+=2;continue}if(h===")"&&m==="subshell"){u.pop(),f++;continue}if(h==="$"){let d=l.slice(f).match(sr);if(d){let p=d[0];if(!/^\$[?!#@*0-9-]/.test(p))t.push({filePath:n.filePath,line:o+1,column:f+1,ruleId:"shell/quote-variables",message:`Unquoted variable ${p} \u2014 use "${p}" to prevent word splitting`,severity:"warning",help:`Wrap in double quotes: "${p}"`});f+=p.length;continue}}f++}}return t}};var lc={meta:{docs:"Enforce consistent function declaration style",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=l.match(/<<-?\s*['"]?(\w+)['"]?/);if(a)i=!0,r=a[1];let c=l.replace(/^\s+/,"");if(c.startsWith("#"))continue;let u=c.match(/^function\s+(\w+)\s*(?:\(\s*\))?\s*\{?\s*$/);if(u){let f=u[1],m=l.indexOf("function");t.push({filePath:n.filePath,line:o+1,column:m+1,ruleId:"shell/function-style",message:`Use \`${f}() {\` instead of \`function ${f}\` \u2014 POSIX-compatible style`,severity:"warning",help:`Replace with: ${f}() {`})}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s.match(/^(\s*)function\s+(\w+)\s*(?:\(\s*\))?\s*(\{?\s*)$/);if(i){let[,r,o,l]=i;t.push(`${r}${o}() ${l||"{"}`)}else t.push(s)}return t.join(`
139
+ `)}};function ac(e,n){if(/^then\b/.test(e)||/^do\b/.test(e)||/^else\b/.test(e))return!0;if(/^if\b/.test(e)&&/\bthen\s*$/.test(e))return!0;if(/^elif\b/.test(e)&&/\bthen\s*$/.test(e))return!0;if(/^(?:while|for|until)\b/.test(e)&&/\bdo\s*$/.test(e))return!0;if(/^case\b/.test(e)&&/\bin\s*$/.test(e))return!0;if(n&&/\)\s*$/.test(e)&&!/\$\(/.test(e)&&!/^\s*\(/.test(e)&&!e.startsWith("#"))return!0;if(/\{\s*$/.test(e)&&!e.startsWith("#"))return!0;return!1}function cc(e){return/^(?:fi|done|esac|elif|else)\b/.test(e)||/^\}/.test(e)||/^;[;&]\s*$/.test(e)}var uc={meta:{docs:"Enforce consistent indentation in shell scripts",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=n.config.format.indent||2,r=0,o=!1,l="",a=!1,c=0;for(let u=0;u<s.length;u++){let f=s[u];if(/^\s*$/.test(f))continue;if(o){if(f.trim()===l)o=!1;continue}let m=f.match(/<<-?\s*['"]?(\w+)['"]?/);if(m)o=!0,l=m[1];let h=f.replace(/^\s+/,"");if(u===0&&h.startsWith("#!"))continue;if(/^case\b/.test(h)&&/\bin\s*$/.test(h))c++,a=!0;if(/^esac\b/.test(h)){if(c=Math.max(0,c-1),c===0)a=!1}if(cc(h))r=Math.max(0,r-1);let d=0;for(let g=0;g<f.length;g++)if(f[g]===" ")d++;else if(f[g]==="\t")d+=i;else break;let p=r*i;if(d!==p&&!h.startsWith("#"))t.push({filePath:n.filePath,line:u+1,column:1,ruleId:"shell/indent",message:`Expected ${p} spaces of indentation, found ${d}`,severity:"warning"});if(ac(h,a))r++}return t},fix(e,n){let t=e.split(/\r?\n/),s=n.config.format.indent||2,i=n.config.format.indentStyle==="tabs",r=[],o=0,l=!1,a="",c=!1,u=0;for(let f=0;f<t.length;f++){let m=t[f];if(/^\s*$/.test(m)){r.push("");continue}if(l){if(r.push(m),m.trim()===a)l=!1;continue}let h=m.match(/<<-?\s*['"]?(\w+)['"]?/);if(h)l=!0,a=h[1];let d=m.replace(/^\s+/,"").trimEnd();if(f===0&&d.startsWith("#!")){r.push(d);continue}if(/^case\b/.test(d)&&/\bin\s*$/.test(d))u++,c=!0;if(/^esac\b/.test(d)){if(u=Math.max(0,u-1),u===0)c=!1}if(cc(d))o=Math.max(0,o-1);let p=i?"\t".repeat(o):" ".repeat(o*s);if(r.push(p+d),ac(d,c))o++}return r.join(`
140
+ `)}};var fc={meta:{docs:"Enforce spacing around shell keywords (if, then, do, else, fi, etc.)",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=Se(l);if(a)i=!0,r=a;if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=De(l),f=u.match(/;(?![;\s$])\S/);if(f)t.push({filePath:n.filePath,line:o+1,column:(f.index||0)+1,ruleId:"shell/keyword-spacing",message:"Missing space after semicolon",severity:"warning"});let m=u.match(/\w(then|do|else|elif|fi|done|esac)\b/);if(m&&!/[a-z]/.test(u[m.index])){let h=m[1],d=u[m.index];if(d!==" "&&d!=="\t"&&d!==";")t.push({filePath:n.filePath,line:o+1,column:(m.index||0)+2,ruleId:"shell/keyword-spacing",message:`Missing space before keyword '${h}'`,severity:"warning"})}}return t}};var mc={meta:{docs:"Disallow unnecessary trailing semicolons",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=l.match(/<<-?\s*['"]?(\w+)['"]?/);if(a)i=!0,r=a[1];let c=l.replace(/^\s+/,"").trimEnd();if(c.startsWith("#"))continue;if(/;;\s*$/.test(c))continue;if(/\bfor\b/.test(c)||/\bwhile\b/.test(c)||/\buntil\b/.test(c))continue;if(/;\s*(?:then|do|else|elif|fi|done|esac)\s*$/.test(c))continue;if(/;\s*$/.test(c)){let u=l.lastIndexOf(";");t.push({filePath:n.filePath,line:o+1,column:u+1,ruleId:"shell/no-trailing-semicolons",message:"Unnecessary trailing semicolon",severity:"warning"})}}return t},fix(e){let n=e.split(/\r?\n/),t=[],s=!1,i="";for(let r of n){if(s){if(t.push(r),r.trim()===i)s=!1;continue}let o=r.match(/<<-?\s*['"]?(\w+)['"]?/);if(o)s=!0,i=o[1];let l=r.replace(/^\s+/,"").trimEnd();if(l.startsWith("#")||/;;\s*$/.test(l)||/\bfor\b/.test(l)||/\bwhile\b/.test(l)||/\buntil\b/.test(l)||/;\s*(?:then|do|else|elif|fi|done|esac)\s*$/.test(l)){t.push(r);continue}t.push(r.replace(/;\s*$/,""))}return t.join(`
141
+ `)}};var hc={meta:{docs:"Disallow trailing whitespace",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=Se(l);if(a)i=!0,r=a;if(/[ \t]+$/.test(l)){let c=l.match(/[ \t]+$/);t.push({filePath:n.filePath,line:o+1,column:c.index+1,ruleId:"shell/no-trailing-whitespace",message:"Trailing whitespace",severity:"error"})}}return t},fix(e){let n=e.split(/\r?\n/),t=!1,s="";return n.map((r)=>{if(t){if(r.trim()===s)t=!1;return r}let o=Se(r);if(o)t=!0,s=o;return r.replace(/[ \t]+$/,"")}).join(`
142
+ `)}};var dc={meta:{docs:"Enforce spaces inside [ ] and [[ ]] test expressions",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=Se(l);if(a)i=!0,r=a;if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=De(l);for(let f of Rp(u,o+1,n.filePath))t.push(f)}return t},fix(e){let n=e.split(/\r?\n/),t=[],s=!1,i="";for(let r of n){if(s){if(r.trim()===i)s=!1;t.push(r);continue}let o=Se(r);if(o){s=!0,i=o,t.push(r);continue}if(r.replace(/^\s+/,"").startsWith("#")){t.push(r);continue}t.push(kp(r))}return t.join(`
143
+ `)}};function Rp(e,n,t){let s=[],i=/\[\[(?!\s|\]|$)/g;for(let o of e.matchAll(i))s.push({filePath:t,line:n,column:(o.index??0)+1,ruleId:"shell/operator-spacing",message:"Missing space after [[",severity:"warning"});let r=/(?<!\s|\[)\]\]/g;for(let o of e.matchAll(r))s.push({filePath:t,line:n,column:(o.index??0)+1,ruleId:"shell/operator-spacing",message:"Missing space before ]]",severity:"warning"});for(let o=0;o<e.length;o++){if(e[o]!=="[")continue;if(e[o+1]==="[")continue;if(o>0&&e[o-1]==="[")continue;if(!pc(e,o))continue;let l=e[o+1];if(l!==void 0&&l!==" "&&l!=="\t")s.push({filePath:t,line:n,column:o+1,ruleId:"shell/operator-spacing",message:"Missing space after [",severity:"warning"})}for(let o=0;o<e.length;o++){if(e[o]!=="]")continue;if(e[o+1]==="]")continue;if(o>0&&e[o-1]==="]")continue;if(!gc(e,o))continue;let l=e[o-1];if(l!==void 0&&l!==" "&&l!=="\t")s.push({filePath:t,line:n,column:o+1,ruleId:"shell/operator-spacing",message:"Missing space before ]",severity:"warning"})}return s}function kp(e){let n=De(e),t=[];for(let i of n.matchAll(/\[\[(?!\s|\]|$)/g)){let r=(i.index??0)+2;t.push({pos:r,text:" "})}for(let i of n.matchAll(/(?<!\s|\[)\]\]/g)){let r=i.index??0;t.push({pos:r,text:" "})}for(let i=0;i<n.length;i++){if(n[i]!=="[")continue;if(n[i+1]==="[")continue;if(i>0&&n[i-1]==="[")continue;if(!pc(n,i))continue;let r=n[i+1];if(r!==void 0&&r!==" "&&r!=="\t")t.push({pos:i+1,text:" "})}for(let i=0;i<n.length;i++){if(n[i]!=="]")continue;if(n[i+1]==="]")continue;if(i>0&&n[i-1]==="]")continue;if(!gc(n,i))continue;let r=n[i-1];if(r!==void 0&&r!==" "&&r!=="\t")t.push({pos:i,text:" "})}if(t.length===0)return e;t.sort((i,r)=>r.pos-i.pos);let s=e;for(let{pos:i,text:r}of t)s=`${s.slice(0,i)}${r}${s.slice(i)}`;return s}function pc(e,n){let t=n-1;while(t>=0&&(e[t]===" "||e[t]==="\t"))t--;if(t<0)return!0;let s=e[t];if(s===";"||s==="|"||s==="&"||s==="!"||s==="(")return!0;let i=e.slice(0,t+1);if(/(?:^|\s)(?:if|while|until|elif|then|else|do)\s*$/.test(i))return!0;return!1}function gc(e,n){let t=e[n+1];if(t===void 0)return!0;return t===" "||t==="\t"||t===";"||t==="|"||t==="&"||t===")"}var $p=/^#!\s*(?:\/usr\/bin\/env\s+(?:ba|z|k|da)?sh|\/bin\/(?:ba|z|k|da)?sh|\/usr\/bin\/(?:ba|z|k|da)?sh)\b/,yc={meta:{docs:"Ensure shell scripts have a proper shebang line",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);if(s.length===0)return t;let i=s[0];if(s.every((r)=>r.trim()===""))return t;if(!i.startsWith("#!"))return t.push({filePath:n.filePath,line:1,column:1,ruleId:"shell/shebang",message:"Missing shebang line \u2014 shell scripts should start with #!/usr/bin/env bash (or similar)",severity:"warning",help:"Add #!/usr/bin/env bash as the first line"}),t;if(!$p.test(i))t.push({filePath:n.filePath,line:1,column:1,ruleId:"shell/shebang",message:`Invalid shebang: ${i} \u2014 use #!/usr/bin/env bash or #!/bin/sh`,severity:"warning",help:"Use #!/usr/bin/env bash for portability or #!/bin/sh for POSIX scripts"});return t}};var bc={meta:{docs:"Enforce consistent case statement terminator placement",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="",o=[];for(let l of s){if(i){if(l.trim()===r)i=!1;o.push("");continue}let a=Se(l);if(a)i=!0,r=a;if(l.replace(/^\s+/,"").startsWith("#")){o.push("");continue}o.push(De(l))}for(let l=0;l<o.length;l++){if(!/\bcase\b[\s\S]*\bin\s*$/.test(o[l].trimEnd()))continue;let a=1,c=-1;for(let h=l+1;h<o.length;h++){let d=o[h].trimEnd();if(/^\s*esac\b/.test(d)){if(a--,a===0){c=h;break}continue}if(/\bcase\b[\s\S]*\bin\s*$/.test(d))a++}if(c===-1)continue;let u=0,f=!1,m=!1;for(let h=l+1;h<c;h++){let d=o[h],p=d.trim();if(p==="")continue;if(u===0){let g=Pp(d);if(g!==-1){if(f&&m)t.push({filePath:n.filePath,line:h+1,column:1,ruleId:"shell/consistent-case-terminators",message:"Missing ;; terminator for previous case branch",severity:"warning",help:"Add ;; at the end of the case branch before the next pattern"});f=!0,m=!0;let y=d.slice(g+1).trimEnd();if(/;;\s*$/.test(y))f=!1;continue}}if(u+=vp(d),u<0)u=0;if(f&&u===0&&/;;\s*$/.test(p))f=!1}}return t}};function Pp(e){let n=e.replace(/^\s+/,"");if(n==="")return-1;if(/^(?:for|while|until|if|case|do|then|else|elif|fi|done|esac)\b/.test(n))return-1;let t=e.length-n.length,s=0;if(n[s]==="(")s++;let i=0;while(s<n.length){let r=n[s];if(r==="(")i++;else if(r===")"){if(i===0)return t+s;i--}else if(r===";"||r==="&"||r==="<"||r===">"||r==="=")return-1;s++}return-1}function vp(e){let n=e.trim();if(n==="")return 0;let t=n.split(/[\s;]+/),s=0;for(let i of t)if(i==="if"||i==="for"||i==="while"||i==="until")s++;else if(i==="fi"||i==="done")s--;return s}var xc={meta:{docs:"Recommend <<- for heredocs inside indented blocks"},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(r.replace(/^\s+/,"").startsWith("#"))continue;if(!r.match(/^\s+/))continue;let c=De(r).match(/(?<!<)<<(?![<-])/);if(!c||c.index===void 0)continue;let f=r.slice(c.index+2).match(/^\s*(['"]?)(\w+)\1\s*$/);if(f){let m=f[2];t.push({filePath:n.filePath,line:i+1,column:c.index+1,ruleId:"shell/heredoc-indent",message:`Use <<- instead of << for indented heredoc (delimiter '${m}' must be at column 0 otherwise)`,severity:"warning",help:"Use <<- to strip leading tabs from heredoc content, allowing proper indentation"})}}return t}};var wc={meta:{docs:"Detect incorrect redirect ordering (2>&1 before > file)",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=Se(l);if(a)i=!0,r=a;if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=De(l);if(u.match(/2>&1\s+>(?!&)\s*\S/)){let m=u.indexOf("2>&1");t.push({filePath:n.filePath,line:o+1,column:m+1,ruleId:"shell/no-broken-redirect",message:"Broken redirect: 2>&1 before > file \u2014 stderr goes to terminal, not the file",severity:"error",help:"Swap the order: cmd > file 2>&1 (or use &> file in bash)"})}}return t}};var Rc={meta:{docs:"Prefer [[ ]] over [ ] for test expressions in bash/zsh",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/)[0]||"",i=/bash|zsh/.test(s);if(/^#!.*\bsh\b/.test(s)&&!i||!i)return t;let o=e.split(/\r?\n/),l=!1,a="";for(let c=0;c<o.length;c++){let u=o[c];if(l){if(u.trim()===a)l=!1;continue}let f=u.match(/<<-?\s*['"]?(\w+)['"]?/);if(f)l=!0,a=f[1];if(u.replace(/^\s+/,"").startsWith("#"))continue;if(u.match(/(?:^|\s|;)\[\s(?!\[)/)){if(/(?<!\])\](?!\])/.test(u)){let d=u.indexOf("[");t.push({filePath:n.filePath,line:c+1,column:d+1,ruleId:"shell/prefer-double-brackets",message:"Use [[ ]] instead of [ ] for test expressions in bash/zsh",severity:"warning",help:"[[ ]] prevents word splitting and supports && || regex; [ ] is only needed for POSIX sh"})}}}return t},fix(e){let n=e.split(/\r?\n/)[0]||"";if(!/bash|zsh/.test(n))return e;let s=e.split(/\r?\n/),i=[];for(let r of s){let o=r;o=o.replace(/(?:^|(?<=\s|;))\[(\s(?!\[).*?(?<!\]))\](?!\])/g,"[[$1]]"),i.push(o)}return i.join(`
144
+ `)}};var kc={meta:{docs:"Prefer printf over echo -e and echo -n",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=l.match(/<<-?\s*['"]?(\w+)['"]?/);if(a)i=!0,r=a[1];if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=l.match(/\becho\s+-[en]+\b/);if(u){let f=l.indexOf("echo"),m=u[0].replace("echo ","");t.push({filePath:n.filePath,line:o+1,column:f+1,ruleId:"shell/prefer-printf",message:`Use printf instead of echo ${m} \u2014 echo behavior varies across platforms`,severity:"warning",help:'printf is portable: printf "format\\n" args... (use \\n for newline)'})}}return t}};var $c={meta:{docs:"Recommend set -euo pipefail for safer script execution"},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r=!1,o=!1,l=-1,a=!1;for(let u=0;u<s.length;u++){let f=s[u].replace(/^\s+/,"");if(u===0&&f.startsWith("#!")){l=u;continue}if(f.startsWith("#"))continue;if(f==="")continue;if(a=!0,/\bset\s+-\w*e/.test(f))i=!0;if(/\bset\s+-\w*u/.test(f))r=!0;if(/\bset\s+.*-o\s+pipefail/.test(f))o=!0;if(/\bset\s+-euo\s+pipefail/.test(f))i=!0,r=!0,o=!0}if(!a)return t;let c=[];if(!i)c.push("-e");if(!r)c.push("-u");if(!o)c.push("-o pipefail");if(c.length>0)t.push({filePath:n.filePath,line:l>=0?l+2:1,column:1,ruleId:"shell/set-options",message:`Missing shell safety options: set ${c.join(" ")}`,severity:"warning",help:"Add `set -euo pipefail` near the top of the script for safer execution"});return t}};var Pc={name:"shell",rules:{"command-substitution":he(Qa),"quote-variables":he(oc),"no-cd-without-check":he(ec),"no-eval":he(tc),"no-useless-cat":he(ic),"no-ls-parsing":he(sc),"no-variable-in-single-quotes":he(rc),"no-exit-in-subshell":he(nc),shebang:he(yc),indent:he(uc),"function-style":he(lc),"operator-spacing":he(dc),"keyword-spacing":he(fc),"no-trailing-semicolons":he(mc),"no-trailing-whitespace":he(hc),"prefer-double-brackets":he(Rc),"set-options":he($c),"prefer-printf":he(kc),"consistent-case-terminators":he(bc),"no-broken-redirect":he(wc),"heredoc-indent":he(xc)}};var Ds=null,_s=null,ir=!1,rr=!0;function Ip(){if(ir)return rr;try{return Ds=(()=>{throw new Error("Cannot require module "+"@stacksjs/ts-spell-check");})(),Ds.SpellChecker.create({minWordLength:3,maxSuggestions:3}).then((e)=>{_s=e}).catch(()=>{rr=!1}),ir=!0,!0}catch{return ir=!0,rr=!1,!1}}function or(e,n){return{meta:{docs:e==="spell/check"?"Check spelling in text content":e==="spell/check-comments"?"Check spelling in code comments only":"Check spelling in markdown files"},check(t,s){if(!Ip()||!Ds)return[];let{extractWords:i,parseDirectives:r,isSuppressed:o,getProgrammingWords:l}=Ds,a=s.options,c=new Set((a?.words||[]).map((p)=>p.toLowerCase())),u=a?.minWordLength||3,f=l(),m=r(t);for(let p of m)if(p.type==="word")p.words.forEach((g)=>c.add(g.toLowerCase()));let h=t.split(/\r?\n/),d=[];for(let p=0;p<h.length;p++){let g=h[p],y=p+1;if(n&&!n(g))continue;let x=i(g);for(let{word:k,offset:v}of x){if(k.length<u)continue;if(k===k.toUpperCase()&&k.length<=5)continue;if(c.has(k.toLowerCase()))continue;if(f.has(k.toLowerCase()))continue;if(o(k,y,m,c))continue;if(_s){if(_s.isCorrect(k))continue;let w=_s.suggest(k);d.push({filePath:s.filePath,line:y,column:v+1,ruleId:e,message:`Unknown word: "${k}"`,severity:"warning",help:w.length?`Did you mean: ${w.slice(0,3).join(", ")}? Or add to config words.`:`Add "${k}" to your config words array, or use: // spell-check:ignore ${k}`})}}}return d}}}function Mp(e){let n=e.trimStart();return n.startsWith("//")||n.startsWith("/*")||n.startsWith("*")||n.startsWith("#")}var vc={name:"spell",rules:{check:or("spell/check"),"check-comments":or("spell/check-comments",Mp),"check-markdown":{meta:{docs:"Check spelling in markdown files"},check(e,n){if(!n.filePath.endsWith(".md"))return[];return or("spell/check-markdown").check(e,n)}}}};function Ic(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Mc={meta:{docs:"Disallow spaces inside array brackets",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let l=0;l<r.length;l++){if(r[l]==="["&&!Ic(r,l)){let a=r[l+1];if(a==="]"||a===void 0||a===`
145
+ `)continue;if(a===" "||a==="\t"){if(r.indexOf("]",l+1)!==-1)t.push({filePath:n.filePath,line:i+1,column:l+2,ruleId:"style/array-bracket-spacing",message:"Unexpected space after '['",severity:"warning"})}}if(r[l]==="]"&&!Ic(r,l)){let a=l>0?r[l-1]:void 0;if(a==="["||a===void 0)continue;if(a===" "||a==="\t"){if(r.lastIndexOf("[",l-1)!==-1)t.push({filePath:n.filePath,line:i+1,column:l,ruleId:"style/array-bracket-spacing",message:"Unexpected space before ']'",severity:"warning"})}}}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/\[\s+(\S)/g,(r,o)=>{if(o==="]")return r;return`[${o}`}),i=i.replace(/(\S)\s+\]/g,"$1]"),t.push(i)}return t.join(`
146
+ `)}};var Cc=/(?<![(\[{,=:?&|+\-*/])\b([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=>/g;function Cp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Sc={meta:{docs:"Require parentheses around arrow function parameters",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;Cc.lastIndex=0;while((l=Cc.exec(r))!==null){let a=l.index;if(Cp(r,a))continue;let c=l[1];if(r.slice(0,a).trimEnd().endsWith("("))continue;if(c==="async")continue;t.push({filePath:n.filePath,line:i+1,column:a+1,ruleId:"style/arrow-parens",message:`Arrow function parameter '${c}' should be wrapped in parentheses`,severity:"warning"})}}return t},fix(e){return e.replace(/(?<![(\[{,=:?&|+\-*/])\b([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=>/g,(n,t)=>{if(t==="async")return n;return n.replace(t,`(${t})`)})}};var Fs=/=>/g;function Ec(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Lc={meta:{docs:"Require space before and after => in arrow functions",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;Fs.lastIndex=0;while((l=Fs.exec(r))!==null){let a=l.index;if(Ec(r,a))continue;if(a>0&&r[a-1]!==" "&&r[a-1]!=="\t")t.push({filePath:n.filePath,line:i+1,column:a+1,ruleId:"style/arrow-spacing",message:"Missing space before =>",severity:"warning"});let c=a+2;if(c<r.length&&r[c]!==" "&&r[c]!=="\t"&&r[c]!==`
147
+ `)t.push({filePath:n.filePath,line:i+1,column:c+1,ruleId:"style/arrow-spacing",message:"Missing space after =>",severity:"warning"})}}return t},fix(e){let n=e.split(`
148
+ `);for(let t=0;t<n.length;t++){let s=n[t],i=s.trim();if(!i||i.startsWith("//")||i.startsWith("*")||i.startsWith("/*"))continue;let r="",o=0;Fs.lastIndex=0;let l;while((l=Fs.exec(s))!==null){let a=l.index;if(Ec(s,a))continue;let c=s[a-1],u=s[a+2],f=a>0&&c!==" "&&c!=="\t",m=u!==void 0&&u!==" "&&u!=="\t";if(!f&&!m)continue;r+=s.slice(o,a),r+=`${f?" ":""}=>${m?" ":""}`,o=a+2}if(o>0)n[t]=r+s.slice(o)}return n.join(`
149
+ `)}};function lr(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Tc={meta:{docs:"Require spaces inside single-line blocks",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let l=0;l<r.length;l++){if(r[l]!=="{")continue;if(lr(r,l))continue;if(l>0&&r[l-1]==="$")continue;let a=1,c=-1;for(let f=l+1;f<r.length;f++){if(r[f]==="{"&&!lr(r,f))a++;if(r[f]==="}"&&!lr(r,f)){if(a--,a===0){c=f;break}}}if(c===-1)continue;let u=r.slice(l+1,c);if(!u.trim())continue;if(u[0]!==" "&&u[0]!=="\t")t.push({filePath:n.filePath,line:i+1,column:l+2,ruleId:"style/block-spacing",message:"Missing space after '{'",severity:"warning"});if(u[u.length-1]!==" "&&u[u.length-1]!=="\t")t.push({filePath:n.filePath,line:i+1,column:c+1,ruleId:"style/block-spacing",message:"Missing space before '}'",severity:"warning"});break}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s.replace(/(?<!\$)\{(\S)([^}]*?)(\S)\}/g,(r,o,l,a)=>`{ ${o}${l}${a} }`);i=i.replace(/(?<!\$)\{(\S)([^}]*?)\s\}/g,(r,o,l)=>`{ ${o}${l} }`),i=i.replace(/(?<!\$)\{\s([^}]*?)(\S)\}/g,(r,o,l)=>`{ ${o}${l} }`),t.push(i)}return t.join(`
150
+ `)}};var Ac={meta:{docs:"Enforce consistent brace style for blocks",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let o=s[i].trim();if(o.startsWith("//")||o.startsWith("/*"))continue;if(/\}\s+(?:else|catch|finally)\b/.test(o))t.push({filePath:n.filePath,line:i+1,column:o.indexOf("}")+1,ruleId:"style/brace-style",message:"Closing curly brace appears on the same line as the subsequent block",severity:"error"});if(o==="{"&&i>0){let a=s[i-1].trim();if(!a||a.startsWith("//")||a.startsWith("/*")||a.endsWith("*/"))continue;if(a&&!a.endsWith("{")&&!a.endsWith(",")&&!a.endsWith("(")){if(!a.match(/[=:]\s*$/)&&!a.endsWith("["))t.push({filePath:n.filePath,line:i+1,column:1,ruleId:"style/brace-style",message:"Opening curly brace should be on the same line",severity:"error"})}}}return t}};var Oc=/,\s*$/,_c=new RegExp("^\\s*[}\\])](?:\\s*;?\\s*)?$"),Dc={meta:{docs:"Require trailing commas in multiline constructs",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=1;i<s.length;i++){let o=s[i].trim();if(!_c.test(o))continue;let l=s[i-1],a=l.trim();if(!a||a==="{"||a==="["||a==="(")continue;if(a.startsWith("//")||a.startsWith("*")||a.startsWith("/*"))continue;if(Oc.test(a))continue;if(a.endsWith("{")||a.endsWith("[")||a.endsWith("("))continue;if(a.endsWith("=>"))continue;t.push({filePath:n.filePath,line:i,column:l.length+1,ruleId:"style/comma-dangle",message:"Missing trailing comma",severity:"warning",help:"Add a trailing comma after the last element in multiline constructs."})}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s=0;s<n.length;s++){let i=n[s];if(s+1<n.length){let r=n[s+1].trim(),o=i.trim();if(_c.test(r)&&o&&o!=="{"&&o!=="["&&o!=="("&&!o.startsWith("//")&&!o.startsWith("*")&&!o.startsWith("/*")&&!Oc.test(o)&&!o.endsWith("{")&&!o.endsWith("[")&&!o.endsWith("(")&&!o.endsWith("=>")){t.push(i.replace(/(\s*)$/,",$1"));continue}}t.push(i)}return t.join(`
151
+ `)}};function Sp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Fc={meta:{docs:"Require space after commas, disallow space before commas",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let l=0;l<r.length;l++){if(r[l]!==",")continue;if(Sp(r,l))continue;if(l>0&&r[l-1]===" "){if(r.slice(0,l).trim().length>0)t.push({filePath:n.filePath,line:i+1,column:l+1,ruleId:"style/comma-spacing",message:"Unexpected space before comma",severity:"warning"})}if(l+1<r.length&&r[l+1]!==" "&&r[l+1]!=="\t"&&r[l+1]!==`
152
+ `&&r[l+1]!=="\r")t.push({filePath:n.filePath,line:i+1,column:l+2,ruleId:"style/comma-spacing",message:"Missing space after comma",severity:"warning"})}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/ ,/g,","),i=i.replace(/,(\S)/g,", $1"),t.push(i)}return t.join(`
153
+ `)}};var Nc={meta:{docs:"Enforce comma-last style (commas at the end of lines, not the beginning)",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;if(o.startsWith(","))t.push({filePath:n.filePath,line:i+1,column:r.indexOf(",")+1,ruleId:"style/comma-style",message:"Comma should be placed at the end of the previous line",severity:"warning"})}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s=0;s<n.length;s++){let i=n[s],r=i.trim();if(r.startsWith(",")&&t.length>0){let o=t.length-1;t[o]=t[o].replace(/\s*$/,",");let l=i.match(/^(\s*)/)?.[1]||"";t.push(l+r.slice(1).trim())}else t.push(i)}return t.join(`
154
+ `)}};function Ep(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Wc={meta:{docs:"Disallow spaces inside computed property brackets [expr]",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let l=0;l<r.length;l++){if(r[l]!=="[")continue;if(Ep(r,l))continue;if(l===0)continue;let a=r[l-1];if(!/[a-zA-Z0-9_$)\]]/.test(a))continue;if(l+1<r.length&&(r[l+1]===" "||r[l+1]==="\t"))t.push({filePath:n.filePath,line:i+1,column:l+2,ruleId:"style/computed-property-spacing",message:"Unexpected space after '['",severity:"warning"});let c=1,u=l+1;while(u<r.length&&c>0){if(r[u]==="[")c++;if(r[u]==="]")c--;if(c>0)u++}if(c===0&&u>0){if(r[u-1]===" "||r[u-1]==="\t")t.push({filePath:n.filePath,line:i+1,column:u,ruleId:"style/computed-property-spacing",message:"Unexpected space before ']'",severity:"warning"})}}}return t},fix(e){return e.replace(/([a-zA-Z0-9_$)\]])\[\s+([\s\S]*?)\s+\]/g,"$1[$2]")}};function Lp(e){let n=[],t=e.split(/\r?\n/),s=0;for(let i=0;i<t.length;i++){let r=t[i],o=/\b[\w$)\]]+\s*\./.test(r),l=i+1<t.length&&/^\s*\./.test(t[i+1]);if(o||l){let a=i,c=i;while(a+1<t.length&&/^\s*\./.test(t[a+1]))a++,c=a;if(c>i){let u=s,f=s+t[i].length+1+t.slice(i+1,c+1).join(`
155
+ `).length;n.push({start:u,end:f}),i=c}}s+=r.length+1}return n}var Bc={meta:{docs:"Enforce consistent line breaks in member-access/call chains"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=Lp(e);for(let{start:r,end:o}of i){let a=e.slice(r,o).split(/\r?\n/),c=[];for(let h=0;h<a.length;h++){let d=a[h],p=[...d.matchAll(/\./g)].map((g)=>g.index||0);for(let g of p){if(g>0&&d[g-1]==="?")continue;if(/^\s*\./.test(d)&&g===d.indexOf(".")&&d.slice(0,g).trim()==="")c.push("newline");else c.push("inline")}}if(c.length<=1)continue;let u=c[0];if(c.every((h)=>h===u))continue;let f=c.findIndex((h)=>h!==u),m=0;for(let h=0;h<a.length;h++){let d=a[h],p=[...d.matchAll(/\./g)].map((g)=>g.index||0);for(let g of p){if(g>0&&d[g-1]==="?")continue;if(m===f){let x=e.slice(0,r).split(/\r?\n/),k=x.length,v=(x[x.length-1]||"").length;t.push({filePath:n.filePath,line:k+h,column:(h===0?v:0)+g+1,ruleId:"style/consistent-chaining",message:`Inconsistent chaining style: mix of ${u} and ${u==="inline"?"newline":"inline"}.`,severity:"warning"}),h=a.length;break}m++}}}return t}};function jc(e){let n=[0];for(let s=0;s<e.length;s++)if(e[s]===`
156
+ `)n.push(s+1);function t(s){let i=0,r=n.length-1;while(i<=r){let l=i+r>>1,a=n[l],c=l+1<n.length?n[l+1]:1/0;if(s<a)r=l-1;else if(s>=c)i=l+1;else return{line:l+1,column:s-a+1}}let o=n[n.length-1];return{line:n.length,column:Math.max(1,s-o+1)}}return{lineStarts:n,indexToLoc:t}}function Uc(e){let n=[],t=(r,o,l)=>n.push({type:r,value:e.slice(o,l),start:o,end:l}),s=0,i=e.length;while(s<i){let r=e[s];if(r<=" "){s++;continue}if(r==="/"&&e[s+1]==="/"){let a=s;s+=2;while(s<i&&e[s]!==`
157
+ `)s++;t("LineComment",a,s);continue}if(r==="/"&&e[s+1]==="*"){let a=s;s+=2;while(s<i&&!(e[s]==="*"&&e[s+1]==="/"))s++;s=Math.min(i,s+2),t("BlockComment",a,s);continue}if(r==='"'||r==="'"){let a=r,c=s;s++;while(s<i){let u=e[s];if(u==="\\"){s+=2;continue}if(u===a){s++;break}s++}t("String",c,s);continue}if(r==="`"){let a=s;s++;let c=0;while(s<i){let u=e[s];if(u==="\\"){s+=2;continue}if(u==="`"&&c===0){s++;break}if(u==="$"&&e[s+1]==="{"){c++,s+=2;continue}if(u==="}"&&c>0){c--,s++;continue}s++}t("Template",a,s);continue}if(r==="/"){if(e[s+1]==="/"){let a=s;s+=2;while(s<i&&e[s]!==`
158
+ `)s++;t("LineComment",a,s);continue}if(e[s+1]==="*"){let a=s;s+=2;while(s<i&&!(e[s]==="*"&&e[s+1]==="/"))s++;s=Math.min(i,s+2),t("BlockComment",a,s);continue}if(Tp(n)){let a=s;s++;while(s<i){let c=e[s];if(c==="\\"){s+=2;continue}if(c==="/"){s++;break}s++}while(s<i&&/[a-z]/i.test(e[s]))s++;t("Regex",a,s);continue}t("Punct",s,s+1),s++;continue}if("(){}[];:,.<>+-*%&|^!?=~".includes(r)){t("Punct",s,s+1),s++;continue}let o=s,l=new RegExp("[^\\s(){}[\\];:,.<>+\\-*%&|^!?=~'\"`/]");while(s<i&&l.test(e[s]))s++;if(s>o)t("Word",o,s);else t("Word",s,s+1),s++}return n}function Tp(e){if(e.length===0)return!0;let n=e[e.length-1],t=new RegExp("[(!,{;:?=]");return n.type==="Punct"&&t.test(n.value)||n.type==="Word"&&/^(?:return|throw|case|of|in|instanceof|typeof|void|new)$/.test(n.value)}function zc(e,n,t,s){let i=0,r=(f)=>f<=" ",o=(f)=>{while(f<e.length&&e[f]!==`
159
+ `)f++;return f},l=(f)=>{f+=2;while(f<e.length&&!(e[f]==="*"&&e[f+1]==="/"))f++;return Math.min(e.length,f+2)},a=(f,m)=>{let h=e.length;if(m==="`"){f++;let d=0;while(f<h){let p=e[f];if(p==="\\"){f+=2;continue}if(p==="`"&&d===0){f++;break}if(p==="$"&&e[f+1]==="{"){d++,f+=2;continue}if(p==="}"&&d>0){d--,f++;continue}if(p==='"'||p==="'"){f=a(f,p);continue}if(p==="/"&&e[f+1]==="/"){f=o(f+2);continue}if(p==="/"&&e[f+1]==="*"){f=l(f);continue}f++}return f}f++;while(f<h){let d=e[f];if(d==="\\"){f+=2;continue}if(d===m){f++;break}f++}return f},c=(f)=>{let m=f-1;while(m>=0&&r(e[m]))m--;let h=m>=0?e[m]:"";if(new RegExp("[(:[{;?,=!&|^~+\\-*%<>]").test(h))return!0;if(h==="")return!0;return!1},u=(f)=>{f++;let m=e.length;while(f<m){let h=e[f];if(h==="\\"){f+=2;continue}if(h==="/"){f++;break}f++}while(f<m&&/[a-z]/i.test(e[f]))f++;return f};for(let f=n;f<e.length;f++){let m=e[f];if(m===t){i++;continue}if(m===s){if(i--,i===0)return f;continue}if(m==='"'||m==="'"||m==="`"){f=a(f,m)-1;continue}if(m==="/"&&e[f+1]==="/"){f=o(f+2)-1;continue}if(m==="/"&&e[f+1]==="*"){f=l(f)-1;continue}if(m==="/"&&c(f)){f=u(f)-1;continue}}return-1}function Ns(e,n,t,s,i,r,o){let l=zc(e,s,i,r);if(l<=s)return;let a=e.slice(s+1,l),c=/\r?\n/.test(a),u=jc(e),f=[],m=0,h=s+1,d=Uc(e.slice(s+1,l)),p=0;for(let y of d){let x=s+1+y.start,k=s+1+y.end;if(p=k,y.type==="Punct"){if(y.value===i)m++;else if(y.value===r&&m>0)m--;else if(y.value===","&&m===0)f.push({start:h,end:x}),h=k}}if(f.push({start:h,end:l}),!c){for(let y of f){let x=e.slice(y.start,y.end);if(/\r?\n/.test(x)){let k=u.indexToLoc(y.start);t.push({filePath:n,line:k.line,column:k.column,ruleId:o,message:"Should not have line breaks between items",severity:"warning"});break}}return}let g=a.indexOf(`
160
+ `);if(g>0){let y=a.slice(0,g),x=(y.match(/,/g)||[]).length,k=a.slice(g+1),v=k.includes(`
161
+ `),w=k.includes(",");if(x>=1&&/\S,\s*\S/.test(y)&&!v&&!w){let M=u.indexToLoc(s+1+g+1);t.push({filePath:n,line:M.line,column:M.column,ruleId:o,message:"Should not have line breaks between items",severity:"warning"});return}else if(x>=1&&/\S,\s*\S/.test(y)){let M=u.indexToLoc(s+1+y.search(/,\s*\S/));t.push({filePath:n,line:M.line,column:M.column,ruleId:o,message:"Should have line breaks between items",severity:"warning"});return}}for(let y of f){let x=e.slice(s+1,y.start);if(!/\n[ \t]*$/.test(x)&&x.trim()!==""){let k=u.indexToLoc(y.start);t.push({filePath:n,line:k.line,column:k.column,ruleId:o,message:"Should have line breaks between items",severity:"warning"});break}}}var qc={meta:{docs:"Enforce consistent newlines for list-like constructs (objects, arrays, named imports/exports)"},check:(e,n)=>{let t=[],s="style/consistent-list-newline";for(let i=0;i<e.length;i++){let r=e[i];if(r==="{"){let o=i-1;while(o>=0&&/[ \t]/.test(e[o]))o--;if(o>=0&&e[o]===")")continue;let l=e.slice(Math.max(0,i-60),i);if(/\b(?:function|class|interface|type|enum|try|catch|finally|if|else|for|while|switch)\b[\s\S]*$/.test(l))continue;Ns(e,n.filePath,t,i,"{","}","style/consistent-list-newline")}else if(r==="[")Ns(e,n.filePath,t,i,"[","]","style/consistent-list-newline");else if(r==="i"&&e.startsWith("import",i)){let o=e.indexOf("{",i);if(o>-1)Ns(e,n.filePath,t,o,"{","}","style/consistent-list-newline")}else if(r==="e"&&e.startsWith("export",i)){let o=e.indexOf("{",i);if(o>-1)Ns(e,n.filePath,t,o,"{","}","style/consistent-list-newline")}}return t}};function Ap(e){let n=e.trim();return n===""||n.startsWith("//")||n.startsWith("/*")}function ar(e,n){for(let t=n;t<e.length;t++)if(!Ap(e[t]))return t;return-1}function kt(e,n,t){if(e[n].slice(t).includes("{"))return!0;let i=ar(e,n+1);if(i>=0){if(e[i].trim().startsWith("{"))return!0}return!1}function Ws(e,n,t){let s=e[n].slice(t);if(/\bif\b|\bfor\b|\bwhile\b|\bdo\b/.test(s))return!0;return!1}var Kc={meta:{docs:"Enforce curly brackets similar to src-2: require braces when any branch/body requires them"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let r=0;r<s.length;r++){let o=s[r],l=o.match(/^(\s*)if\s*\(([^)]*)\)/);if(l){let c=l[0].length,u=kt(s,r,c),f=Ws(s,r,c),m=r,h=u,d=f;while(!0){let p=ar(s,m+1);if(p<0)break;let g=s[p].trim();if(!g.startsWith("else"))break;let y=g.match(/^else\s+if\s*\(([^)]*)\)/);if(y){let x=s[p].indexOf(y[0])+y[0].length;h=h||kt(s,p,x),d=d||Ws(s,p,x),m=p;continue}else{let x=s[p].indexOf("else")+4;h=h||kt(s,p,x),d=d||Ws(s,p,x),m=p;break}}if(h||d){if(!u)t.push({filePath:n.filePath,line:r+1,column:Math.max(1,o.indexOf("if")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});let p=r;while(!0){let g=ar(s,p+1);if(g<0)break;let y=s[g],x=y.trim();if(!x.startsWith("else"))break;let k=x.match(/^else\s+if\s*\(([^)]*)\)/);if(k){let v=y.indexOf(k[0])+k[0].length;if(!kt(s,g,v))t.push({filePath:n.filePath,line:g+1,column:Math.max(1,y.indexOf("else")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});p=g;continue}else{let v=y.indexOf("else")+4;if(!kt(s,g,v))t.push({filePath:n.filePath,line:g+1,column:Math.max(1,y.indexOf("else")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});break}}}}let a=o.match(/^(\s*)(while|do|for|for\s+await)\b/);if(a){let c=a[0].length,u=kt(s,r,c),f=Ws(s,r,c);if((u||f)&&!u)t.push({filePath:n.filePath,line:r+1,column:Math.max(1,o.indexOf(a[2])+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"})}}let i=Op(e,n.filePath);for(let r of i)t.push({filePath:n.filePath,line:r.line,column:r.column,ruleId:"style/curly",message:r.message,severity:"warning"});return t}};function Op(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim(),l=/^if\s*\(/.test(o)?"if":/^else\s+if\s*\(/.test(o)?"else-if":/^else\b/.test(o)?"else":null;if(!l)continue;let a=0;if(l==="if"){let d=r.match(/if\s*\([^)]*\)/);a=d?r.indexOf(d[0])+d[0].length:r.indexOf("if")+2}else if(l==="else-if"){let d=r.match(/else\s+if\s*\([^)]*\)/);a=d?r.indexOf(d[0])+d[0].length:r.indexOf("else")+4}else a=r.indexOf("else")+4;let c=i,u=r.indexOf("{",a);if(u<0){let d=function(g){for(let y=g;y<s.length;y++)if(s[y].trim()!=="")return y;return-1}(i+1);if(d<0)continue;if(u=s[d].indexOf("{"),u<0)continue;c=d}let f=0,m=-1;for(let d=c;d<s.length;d++){let p=s[d],g=d===c?Math.max(0,u):0;for(let y=g;y<p.length;y++){let x=p[y];if(x==="{")f++;else if(x==="}"){if(f--,f===0){m=d;break}}}if(m>=0)break}if(m<0)continue;let h=[];for(let d=c+1;d<m;d++){let p=s[d].trim();if(p===""||/^\/\//.test(p))continue;if(h.push(p),h.length>1)break}if(h.length===1&&m===c+2){let d=h[0],p=/^(?:if|for|while|do|switch|try|catch|else)\b/.test(d),g=/[{}]/.test(d),y=(d.match(/\(/g)||[]).length,x=(d.match(/\)/g)||[]).length,k=y!==x,v=!1;for(let w=i+1;w<s.length;w++){let M=s[w].trim();if(M===""||M==="}"||/^\/\//.test(M))continue;if(!/^else\b/.test(M))break;let L=s[w].indexOf("else")+4,_=M.match(/^else\s+if\s*\([^)]*\)/);if(_)L=s[w].indexOf(_[0])+_[0].length;let C=w,D=s[w].indexOf("{",L);if(D<0){let S=function(A){for(let R=A;R<s.length;R++)if(s[R].trim()!=="")return R;return-1}(w+1);if(S<0)break;if(D=s[S].indexOf("{"),D<0)continue;C=S}let T=0,E=-1;for(let S=C;S<s.length;S++){let O=s[S],A=S===C?Math.max(0,D):0;for(let R=A;R<O.length;R++){let I=O[R];if(I==="{")T++;else if(I==="}"){if(T--,T===0){E=S;break}}}if(E>=0)break}if(E>=0){let S=0;for(let O=C+1;O<E;O++){let A=s[O].trim();if(A===""||/^\/\//.test(A))continue;if(S++,S>1){v=!0;break}}}if(v)break}if(!v&&l==="if"){let w=function(L){for(let _=L;_<s.length;_++){let C=s[_].trim();if(C!==""&&C!=="}"&&!/^\/\//.test(C))return _}return-1}(m+1);if(w>=0&&/^else\b/.test(s[w].trim())){let M=s[w].indexOf("else")+4,L=s[w].trim().match(/^else\s+if\s*\([^)]*\)/);if(L)M=s[w].indexOf(L[0])+L[0].length;let _=w,C=s[w].indexOf("{",M);if(C<0){let D=function(E){for(let S=E;S<s.length;S++)if(s[S].trim()!=="")return S;return-1}(w+1);if(D>=0)C=s[D].indexOf("{"),_=C>=0?D:_}if(C>=0){let D=0,T=-1;for(let E=_;E<s.length;E++){let S=s[E],O=E===_?Math.max(0,C):0;for(let A=O;A<S.length;A++){let R=S[A];if(R==="{")D++;else if(R==="}"){if(D--,D===0){T=E;break}}}if(T>=0)break}if(T>=0){let E=0;for(let S=_+1;S<T;S++){let O=s[S].trim();if(O===""||/^\/\//.test(O))continue;if(++E>1){v=!0;break}}}}}}if(!p&&!g&&!k&&!v)t.push({line:c+1,column:Math.max(1,s[c].indexOf("{")+1),message:"Unnecessary curly braces around single statement"})}}return t}var Vc={meta:{docs:"Enforce dot on the property line in chained method calls",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=Xe(e);for(let r=0;r<s.length;r++){let o=s[r],l=o.trim();if(!l||l.startsWith("//")||l.startsWith("*")||l.startsWith("/*"))continue;if(i[r+1])continue;if(l.endsWith(".")&&r+1<s.length){let a=s[r+1].trim();if(a&&/^[a-zA-Z_$]/.test(a))t.push({filePath:n.filePath,line:r+1,column:o.length,ruleId:"style/dot-location",message:"Dot should be on the same line as the property",severity:"warning"})}}return t},fix(e){let n=e.split(/\r?\n/),t=[],s=Xe(e);for(let i=0;i<n.length;i++){let r=n[i];if(r.trim().endsWith(".")&&!s[i+1]&&i+1<n.length){let l=n[i+1],a=l.trim();if(a&&/^[a-zA-Z_$]/.test(a)){t.push(r.replace(/\.\s*$/,""));let c=l.match(/^(\s*)/)?.[1]||"";n[i+1]=`${c}.${a}`;continue}}t.push(r)}return t.join(`
162
+ `)}};function Hc(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Zc=["===","!==",">>>","==","!=",">=","<=","&&","||","??","**","<<",">>","+","-","*","/","%","|","&","^",">","<","instanceof","in"],gI=new RegExp(`^(${Zc.map((e)=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})\\s`),_p=new Set(["in","instanceof"]),Dp=/^(?:instanceof|in)\s/;function Bs(e){if(Dp.test(e))return!0;for(let n of Zc){if(_p.has(n))continue;if(e.startsWith(n)){let t=e[n.length];if(t===void 0||t===" "||t==="\t")return!0}}return!1}function cr(e){let n=e.match(/^(\s*)/);return n?n[1].length:0}var Gc={meta:{docs:"Enforce consistent indentation of continuation lines in multiline binary expressions",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;if(!Bs(o))continue;if(Hc(r,0))continue;let l=i-1;while(l>=0){let u=s[l].trim();if(!u||u.startsWith("//")||u.startsWith("*")||u.startsWith("/*")){l--;continue}if(Bs(u)){l--;continue}break}if(l<0)continue;let a=cr(s[l])+2,c=cr(r);if(c!==a)t.push({filePath:n.filePath,line:i+1,column:c+1,ruleId:"style/indent-binary-ops",message:`Expected indentation of ${a} spaces for binary operator continuation, but found ${c}`,severity:"warning"})}return t},fix(e,n){let t=e.split(/\r?\n/),s=[];for(let i=0;i<t.length;i++){let r=t[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*")){s.push(r);continue}if(!Bs(o)||Hc(r,0)){s.push(r);continue}let l=-1;for(let u=s.length-1;u>=0;u--){let f=s[u].trim();if(!f||f.startsWith("//")||f.startsWith("*")||f.startsWith("/*"))continue;if(Bs(f))continue;l=u;break}if(l<0){s.push(r);continue}let a=cr(s[l])+2,c=" ".repeat(a)+o;s.push(c);continue}return s.join(`
163
+ `)}};var Jc=new Set(["if","for","while","switch","catch","function","return","typeof","void","delete","throw","new","await","class","import","export","from","of","in","case","default","yield","else","do","try","finally","with","async","super","this","extends","implements","instanceof"]),js=/([a-zA-Z_$][a-zA-Z0-9_$]*)\s+\(/g;function Yc(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Xc={meta:{docs:"Disallow spaces between function name and opening parenthesis in calls",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;js.lastIndex=0;while((l=js.exec(r))!==null){let a=l[1],c=l.index;if(Yc(r,c))continue;if(Jc.has(a))continue;let u=r.slice(0,c).trimEnd();if(u.endsWith("function")||u.endsWith("function*"))continue;if(/\b(?:get|set)\s*$/.test(u))continue;let f=c+a.length;t.push({filePath:n.filePath,line:i+1,column:f+1,ruleId:"style/function-call-spacing",message:"Unexpected space between function name and parenthesis",severity:"warning"})}}return t},fix(e,n){let t=e.split(/\r?\n/),s=[];for(let i=0;i<t.length;i++){let r=t[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*")){s.push(r);continue}let l=r,a=[],c;js.lastIndex=0;while((c=js.exec(r))!==null){let u=c[1],f=c.index;if(Yc(r,f))continue;if(Jc.has(u))continue;let m=r.slice(0,f).trimEnd();if(m.endsWith("function")||m.endsWith("function*"))continue;if(/\b(?:get|set)\s*$/.test(m))continue;a.push({index:f,fullMatch:c[0],identifier:u})}for(let u=a.length-1;u>=0;u--){let f=a[u],m=f.index,h=m+f.fullMatch.length;l=`${l.slice(0,m)}${f.identifier}(${l.slice(h)}`}s.push(l)}return s.join(`
164
+ `)}};var Qc=/\bfunction\s*\*/g;function eu(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var tu={meta:{docs:"Enforce spacing around * in generator functions (space after, no space before)",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;Qc.lastIndex=0;while((l=Qc.exec(r))!==null){let c=l.index;if(eu(r,c))continue;let u=l[0],f=c+u.indexOf("*"),m=f+1;if(u!=="function*")t.push({filePath:n.filePath,line:i+1,column:f+1,ruleId:"style/generator-star-spacing",message:"Unexpected space before * in generator function",severity:"warning"});if(m<r.length&&r[m]!==" "&&r[m]!=="\t"&&r[m]!==`
165
+ `&&r[m]!=="(")t.push({filePath:n.filePath,line:i+1,column:m+1,ruleId:"style/generator-star-spacing",message:"Missing space after * in generator function",severity:"warning"})}if(o.match(/^(?:async\s+)?\*\s*([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/)){let c=r.indexOf("*",r.indexOf(o.charAt(0)));if(!eu(r,c)){let u=c+1;if(u<r.length&&r[u]!==" "&&r[u]!=="\t")t.push({filePath:n.filePath,line:i+1,column:u+1,ruleId:"style/generator-star-spacing",message:"Missing space after * in generator method",severity:"warning"})}}}return t},fix(e,n){let t=e;return t=t.replace(/\bfunction\s+\*/g,"function*"),t=t.replace(/\bfunction\*([a-zA-Z_$])/g,"function* $1"),t=t.replace(/(^\s*(?:async\s+)?)\*([a-zA-Z_$])/gm,"$1* $2"),t}};var nu={meta:{docs:"Enforce newline after if when without braces"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(!r.match(/^\s*if\s*\([^)]*\)\s*([^\s{/].*)$/))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf("if")+1),ruleId:"style/if-newline",message:"Expect newline after if",severity:"warning"})}return t}};var Fp=["$","unindent","unIndent"],su={meta:{docs:"Enforce consistent indentation inside unindent-style tagged templates"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.match(/^\s*/)?.[0]??"",l=/([$A-Z_][\w$]*)\s*`/gi,a;while(a=l.exec(r)){let c=a[1];if(!Fp.includes(c))continue;if(r.slice(a.index+a[0].length).includes("`"))continue;let f=-1;for(let h=i+1;h<s.length;h++)if(s[h].includes("`")){f=h;break}if(f<0)continue;let m=`${o} `;for(let h=i+1;h<f;h++){let d=s[h];if(d.trim()==="")continue;let p=d.match(/^\s*/)?.[0]??"";if(!p.startsWith(m)){t.push({filePath:n.filePath,line:h+1,column:(p.length||0)+1,ruleId:"style/indent-unindent",message:"Consistent indentation in unindent tag",severity:"warning"});break}}}}return t}};var Np=/^(\s*)(["']?[a-zA-Z_$][a-zA-Z0-9_$]*["']?\s*(?:\?)?):(\S)/;function iu(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var ru={meta:{docs:"Require space after colon in object properties",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l=r.match(Np);if(l){let c=r.indexOf(":",l[1].length);if(c!==-1&&!iu(r,c)){let u=r[c+1];if(u&&u!==" "&&u!=="\t"&&u!==`
166
+ `)t.push({filePath:n.filePath,line:i+1,column:c+2,ruleId:"style/key-spacing",message:"Missing space after colon in property",severity:"warning"})}}let a=o.match(/^(["']?[a-zA-Z_$][a-zA-Z0-9_$]*["']?)\s+:/);if(a&&!o.match(/^\s*(case|default)\b/)){let c=r.indexOf(":",r.indexOf(a[1])+a[1].length);if(c!==-1&&!iu(r,c))t.push({filePath:n.filePath,line:i+1,column:c+1,ruleId:"style/key-spacing",message:"Unexpected space before colon in property",severity:"warning"})}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/^(\s*)(["']?[a-zA-Z_$][a-zA-Z0-9_$]*["']?\s*(?:\?)?):(\S)/,"$1$2: $3"),t.push(i)}return t.join(`
167
+ `)}};var Wp=["if","else","for","while","do","switch","case","return","throw","try","catch","finally","const","let","var","typeof","instanceof","in","of","new","delete","void","yield","await","async","from","import","export","default","class","extends","as","break","continue"],ou=new RegExp(`(?:^|[^\\w$.])(${Wp.join("|")})(?=[^\\w$]|$)`,"g");function Bp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var lu={meta:{docs:"Require space before and after keywords",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;ou.lastIndex=0;while((l=ou.exec(r))!==null){let a=l[0].charAt(0)===l[1].charAt(0)?"":l[0].charAt(0),c=l.index+a.length,u=c+l[1].length;if(Bp(r,c))continue;if(c>0){let f=r[c-1];if(f===")"||f==="}")t.push({filePath:n.filePath,line:i+1,column:c+1,ruleId:"style/keyword-spacing",message:`Missing space before keyword '${l[1]}'`,severity:"warning"})}if(u<r.length){let f=r[u];if(f!==" "&&f!=="\t"&&f!==";"&&f!==","&&f!==":"&&f!=="."){if(f==="("&&(l[1]==="if"||l[1]==="for"||l[1]==="while"||l[1]==="switch"||l[1]==="catch"))t.push({filePath:n.filePath,line:i+1,column:u+1,ruleId:"style/keyword-spacing",message:`Missing space after keyword '${l[1]}'`,severity:"warning"})}}}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;for(let r of["if","for","while","switch","catch"]){let o=new RegExp(`(\\b${r})\\(`,"g");i=i.replace(o,"$1 (")}for(let r of["else","catch","finally"])i=i.replace(new RegExp(`\\)${r}\\b`,"g"),`) ${r}`),i=i.replace(new RegExp(`\\}${r}\\b`,"g"),`} ${r}`);t.push(i)}return t.join(`
168
+ `)}};var au=/^\s*(?:public|private|protected|static|readonly|abstract|override|async|get|set|\*|#|[a-zA-Z_$])/,cu={meta:{docs:"Require blank line between class members",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r=0,o=0,l=-1;for(let a=0;a<s.length;a++){let u=s[a].trim();if(u.match(/\bclass\b/)&&(u.includes("{")||a+1<s.length&&s[a+1].trim()==="{"))i=!0,o=r+1;let f=r;for(let m of u){if(m==="{")r++;if(m==="}")r--}if(i&&r<o){i=!1,l=-1;continue}if(!i)continue;if(f>o&&r===o&&u.endsWith("}")){l=a;continue}if(f===o){if(!u||u.startsWith("//")||u.startsWith("*")||u.startsWith("/*")||u==="}")continue;if(au.test(u)){if(l!==-1&&a===l+1)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"style/lines-between-class-members",message:"Missing blank line between class members",severity:"warning"});if(!u.endsWith("{"))l=a}}}return t},fix(e,n){let t=e.split(/\r?\n/),s=[],i=!1,r=0,o=0,l=-1;for(let a=0;a<t.length;a++){let c=t[a],u=c.trim();if(u.match(/\bclass\b/)&&(u.includes("{")||a+1<t.length&&t[a+1].trim()==="{"))i=!0,o=r+1;let f=r;for(let m of u){if(m==="{")r++;if(m==="}")r--}if(i&&r<o){i=!1,l=-1,s.push(c);continue}if(i&&f>o&&r===o&&u.endsWith("}")){l=a,s.push(c);continue}if(i&&f===o&&u&&!u.startsWith("//")&&!u.startsWith("*")&&!u.startsWith("/*")&&u!=="}"&&au.test(u)){if(l!==-1&&a===l+1)s.push("");if(!u.endsWith("{"))l=a}s.push(c)}return s.join(`
169
+ `)}};var uu={meta:{docs:"Limit the number of statements allowed on a single line"},check:(e,n)=>{let t=n.options&&typeof n.options.max==="number"?n.options.max:1,s=[],i=e.split(/\r?\n/),r=(o)=>{let l=jp(o),a=l>=0?o.slice(0,l):o,c=0,u=!1,f=!1,m=!1,h=!1,d=!1,p=!1,g=!1,y=0,x="",k=(M)=>{if(M===" "||M==="\t")return;x=M};for(let M=0;M<a.length;M++){let L=a[M];if(p){p=!1;continue}if(L==="\\"){p=!0;continue}if(h){if(d){if(L==="]")d=!1;continue}if(L==="["){d=!0;continue}if(L==="/"){h=!1;while(M+1<a.length&&/[a-z]/i.test(a[M+1]))M++;x="/"}continue}if(!f&&!m&&L==="'"){u=!u,k(u?"'":"x");continue}if(!u&&!m&&L==='"'){f=!f,k(f?'"':"x");continue}if(!u&&!f&&L==="`"){m=!m,k(m?"`":"x");continue}if(u||f||m)continue;if(L==="/"&&fu(x,a,M)){h=!0;continue}if(!g){if(L==="f"&&a.slice(M,M+4).match(/^for\b/)){let _=a.slice(M+3).trimStart(),C=a.length-_.length;if(a[C]==="("){g=!0,y=1,M=C,x="(";continue}}}else if(L==="(")y++;else if(L===")"){if(y--,y<=0)g=!1}else if(L===";"){k(L);continue}if(L===";")c++;k(L)}if(c===0)return 1;return a.trimEnd().endsWith(";")?c:c+1};for(let o=0;o<i.length;o++){let l=i[o];if(/^\s*$/.test(l))continue;let a=r(l);if(a>t)s.push({filePath:n.filePath,line:o+1,column:1,ruleId:"max-statements-per-line",message:`This line has ${a} statements. Maximum allowed is ${t}`,severity:"warning"})}return s}};function jp(e){let n=!1,t=!1,s=!1,i=!1,r=!1,o=!1,l="";for(let a=0;a<e.length;a++){let c=e[a];if(o){o=!1;continue}if(c==="\\"){o=!0;continue}if(i){if(r){if(c==="]")r=!1;continue}if(c==="["){r=!0;continue}if(c==="/"){i=!1;while(a+1<e.length&&/[a-z]/i.test(e[a+1]))a++;l="/"}continue}if(!t&&!s&&c==="'"){n=!n,l=c;continue}if(!n&&!s&&c==='"'){t=!t,l=c;continue}if(!n&&!t&&c==="`"){s=!s,l=c;continue}if(n||t||s)continue;if(c==="/"&&e[a+1]==="/")return a;if(c==="/"&&fu(l,e,a)){i=!0;continue}if(c!==" "&&c!=="\t")l=c}return-1}function fu(e,n,t){if(e==="")return!0;if("([{,:;!?&|=<>~^+*%-".includes(e))return!0;if(/[A-Za-z_$]/.test(e)){if(n.slice(0,t).trimEnd().match(/(?:^|[^A-Za-z0-9_$])(return|typeof|instanceof|new|delete|void|in|of|yield|await|throw|case)$/))return!0}return!1}function mu(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var hu={meta:{docs:"Enforce consistent multiline ternary expressions",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l=r.indexOf("?");if(l===-1)continue;if(r[l+1]==="."||r[l+1]==="?")continue;if(mu(r,l))continue;if(r.indexOf(":",l+1)!==-1)continue;for(let c=i+1;c<Math.min(i+10,s.length);c++){let u=s[c].trim();if(u.startsWith(":"))break;let f=u.indexOf(":");if(f>0&&!mu(s[c],f)){if(u.match(/^\w+\s*:/)||u.match(/^case\b/))continue;t.push({filePath:n.filePath,line:c+1,column:s[c].indexOf(":")+1,ruleId:"style/multiline-ternary",message:"In multiline ternary, ':' should be at the start of the line",severity:"warning"});break}}}return t}};var du=new RegExp("\\bnew\\s+([A-Z][a-zA-Z0-9_$.]+)(?![a-zA-Z0-9_$])(?:\\s*<[^>]*>)?\\s*(?=[^(;\\n]|$)","g");function Up(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var pu={meta:{docs:"Require parentheses when invoking a constructor with no arguments",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;du.lastIndex=0;while((l=du.exec(r))!==null){if(Up(r,l.index))continue;if(r.slice(l.index+l[0].length).startsWith("("))continue;if(l[0].includes("new."))continue;t.push({filePath:n.filePath,line:i+1,column:l.index+1,ruleId:"style/new-parens",message:`Missing parentheses invoking constructor '${l[1]}'`,severity:"warning",help:"Add () after the constructor name."})}}return t},fix(e){return e.replace(/\bnew\s+([A-Z][a-zA-Z0-9_$.]+)(?![a-zA-Z0-9_$])(\s*<[^>]*>)?\s*(?=[^(]|$)/g,(n,t,s)=>{if(n.slice(n.indexOf(t)+t.length+(s?.length||0)).trim().startsWith("("))return n;return`new ${t}${s||""}()`})}};var CI=new RegExp("\\breturn\\s+\\(([^()]*)\\)\\s*[;\\n]","g"),gu=/^[a-zA-Z_$][a-zA-Z0-9_$.[\]'"`]*$/;var yu={meta:{docs:"Remove redundant parentheses in return statements",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l=new RegExp("^return\\s+\\(([^()]*)\\)\\s*;?\\s*$"),a=o.match(l);if(a){let c=a[1].trim();if(gu.test(c)||/^['"`]/.test(c)||/^\d/.test(c)||c==="true"||c==="false"||c==="null"||c==="undefined")t.push({filePath:n.filePath,line:i+1,column:r.indexOf("(")+1,ruleId:"style/no-extra-parens",message:"Unnecessary parentheses around return value",severity:"warning",help:"Remove the outer parentheses."})}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s.trim(),r=new RegExp("^return\\s+\\(([^()]*)\\)\\s*(;?)\\s*$"),o=i.match(r);if(o){let l=o[1].trim(),a=o[2];if(gu.test(l)||/^['"`]/.test(l)||/^\d/.test(l)||l==="true"||l==="false"||l==="null"||l==="undefined"){let c=s.match(/^(\s*)/)?.[1]||"";t.push(`${c}return ${l}${a}`);continue}}t.push(s)}return t.join(`
170
+ `)}};var bu=/(\S)\s+(\.)[a-zA-Z_$]/g,xu=/(\S)\s+(\?\.)[a-zA-Z_$]/g;function Us(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var wu={meta:{docs:"Disallow whitespace before . or ?. in property access",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;bu.lastIndex=0;while((l=bu.exec(r))!==null){let a=l.index+l[0].indexOf(".");if(Us(r,l.index))continue;if(a+1<r.length&&r[a+1]===".")continue;if(a>0&&r[a-1]===".")continue;t.push({filePath:n.filePath,line:i+1,column:a+1,ruleId:"style/no-whitespace-before-property",message:"Unexpected whitespace before property access dot",severity:"warning"})}xu.lastIndex=0;while((l=xu.exec(r))!==null){let a=l.index+l[0].indexOf("?.");if(Us(r,l.index))continue;t.push({filePath:n.filePath,line:i+1,column:a+1,ruleId:"style/no-whitespace-before-property",message:"Unexpected whitespace before optional chaining operator",severity:"warning"})}}return t},fix(e,n){let t=e.split(/\r?\n/),s=[];for(let i=0;i<t.length;i++){let r=t[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*")){s.push(r);continue}let l=r;l=l.replace(/(\S)\s+(\?\.[a-zA-Z_$])/g,(a,c,u,f)=>{if(Us(r,f))return a;return c+u}),l=l.replace(/(\S)\s+(\.[a-zA-Z_$])/g,(a,c,u,f)=>{if(Us(r,f))return a;let m=f+a.indexOf(".");if(m+1<l.length&&l[m+1]===".")return a;return c+u}),s.push(l)}return s.join(`
171
+ `)}};function $t(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Ru=/&&/g,ku=/\|\|/g,$u=/\?\?/g,Pu=/(?<![&])&(?![&=])/g,vu=/(?<![|])\|(?![|=])/g,Iu=/\^(?!=)/g;function zp(e){let n=[];Ru.lastIndex=0;let t;while((t=Ru.exec(e))!==null)if(!$t(e,t.index))n.push({op:"&&",group:0,index:t.index});ku.lastIndex=0;while((t=ku.exec(e))!==null)if(!$t(e,t.index))n.push({op:"||",group:1,index:t.index});$u.lastIndex=0;while((t=$u.exec(e))!==null)if(!$t(e,t.index))n.push({op:"??",group:2,index:t.index});Pu.lastIndex=0;while((t=Pu.exec(e))!==null)if(!$t(e,t.index))n.push({op:"&",group:3,index:t.index});vu.lastIndex=0;while((t=vu.exec(e))!==null)if(!$t(e,t.index))n.push({op:"|",group:4,index:t.index});Iu.lastIndex=0;while((t=Iu.exec(e))!==null)if(!$t(e,t.index))n.push({op:"^",group:5,index:t.index});return n.sort((s,i)=>s.index-i.index)}function qp(e,n){if(n.length<2)return!0;let t=[];for(let r of n){let o=0;for(let l=0;l<r.index;l++)if(e[l]==="(")o++;else if(e[l]===")")o--;t.push(o)}let s=new Map;for(let r=0;r<n.length;r++){let o=n[r].group;if(!s.has(o))s.set(o,[]);s.get(o).push(t[r])}let i=[...s.entries()];if(i.length===2){let[,r]=i[0],[,o]=i[1],l=Math.min(...r),a=Math.max(...r),c=Math.min(...o),u=Math.max(...o);if(l>u||c>a)return!0}return!1}var Kp=[{groups:[0,1],label:"&& and ||"},{groups:[0,2],label:"&& and ??"},{groups:[1,2],label:"|| and ??"},{groups:[3,4],label:"& and |"},{groups:[3,5],label:"& and ^"},{groups:[4,5],label:"| and ^"}],Mu={meta:{docs:"Disallow mixed logical/bitwise operators without parentheses",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l=zp(r);if(l.length<2)continue;let a=new Set(l.map((c)=>c.group));for(let c of Kp)if(a.has(c.groups[0])&&a.has(c.groups[1])){let u=l.filter((f)=>f.group===c.groups[0]||f.group===c.groups[1]);if(!qp(r,u)){let f=u.find((m)=>m.group===c.groups[1]);if(f)t.push({filePath:n.filePath,line:i+1,column:f.index+1,ruleId:"style/no-mixed-operators",message:`Unexpected mix of ${c.label} without parentheses`,severity:"warning"})}}}return t}};var Cu=/(?<![0-9.])\.\d/g,Su=/\d\.(?!\d|\.|\w)/g;function Eu(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Lu={meta:{docs:"Disallow floating decimals like .5 or 2.",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;Cu.lastIndex=0;while((l=Cu.exec(r))!==null){if(Eu(r,l.index))continue;if(l.index>0){let a=r[l.index-1];if(/[a-zA-Z_$)\]]/.test(a))continue}t.push({filePath:n.filePath,line:i+1,column:l.index+1,ruleId:"style/no-floating-decimal",message:"Unexpected leading decimal point",severity:"warning",help:"Add a leading 0 before the decimal point: 0.5 instead of .5"})}Su.lastIndex=0;while((l=Su.exec(r))!==null){if(Eu(r,l.index))continue;t.push({filePath:n.filePath,line:i+1,column:l.index+1,ruleId:"style/no-floating-decimal",message:"Unexpected trailing decimal point",severity:"warning",help:"Add a trailing 0 after the decimal point: 2.0 instead of 2."})}}return t},fix(e){let n=e;return n=n.replace(/(?<![a-zA-Z_$0-9.)\]])\.\d/g,(t)=>`0${t}`),n=n.replace(/(\d)\.(?!\d|\.|\w)/g,(t,s)=>`${s}.0`),n}};var Tu={meta:{docs:"Disallow mixed spaces and tabs for indentation",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let o=s[i].match(/^(\s*)/)?.[1]||"";if(!o)continue;let l=o.includes("\t"),a=o.includes(" ");if(l&&a)t.push({filePath:n.filePath,line:i+1,column:1,ruleId:"style/no-mixed-spaces-and-tabs",message:"Mixed spaces and tabs in indentation",severity:"warning",help:"Use either spaces or tabs for indentation, not both."})}return t}};var Au={meta:{docs:"Disallow multiple consecutive spaces",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(!r.trim())continue;let o=r.match(/^(\s*)/)?.[1]||"",l=r.slice(o.length),a=/ {2,}/g,c;for(c=a.exec(l);c!==null;c=a.exec(l)){let u=o.length+c.index+1,f=l.slice(0,c.index),m=(f.match(/'/g)||[]).length,h=(f.match(/"/g)||[]).length,d=(f.match(/`/g)||[]).length;if(m%2===1||h%2===1||d%2===1)continue;if(f.includes("//"))continue;if(r.trim().startsWith("*")||r.trim().startsWith("/*"))continue;t.push({filePath:n.filePath,line:i+1,column:u,ruleId:"style/no-multi-spaces",message:"Multiple spaces found",severity:"warning",help:"Remove extra spaces. Use single spaces between tokens."})}}return t}};var Ou={meta:{docs:"Disallow multiple consecutive blank lines",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=0,r=-1;for(let o=0;o<s.length;o++)if(s[o].trim()===""){if(i++,r===-1)r=o;if(i>1&&o===r+i-1)t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"style/no-multiple-empty-lines",message:"More than 1 blank line not allowed",severity:"error",help:"Remove extra blank lines. Maximum 1 consecutive blank line allowed."})}else i=0,r=-1;return t}};var _u={meta:{docs:"Disallow tab characters (when using spaces for indentation)",recommended:!1},check(e,n){let t=[];if(n.config.format?.indentStyle==="tabs")return t;let s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let o=s[i].indexOf("\t");if(o!==-1)t.push({filePath:n.filePath,line:i+1,column:o+1,ruleId:"style/no-tabs",message:"Unexpected tab character",severity:"warning",help:"Use spaces for indentation instead of tabs."})}return t},fix(e,n){let t=n.config.format?.indent??2;return e.replace(/\t/g," ".repeat(t))}};var Du={meta:{docs:"Disallow trailing whitespace at the end of lines",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.match(/(\s+)$/);if(o){let l=r.length-o[1].length+1;t.push({filePath:n.filePath,line:i+1,column:l,ruleId:"style/no-trailing-spaces",message:"Trailing spaces not allowed",severity:"error",help:"Remove trailing whitespace from the end of this line."})}}return t}};function Fu(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Nu={meta:{docs:"Require spaces inside curly braces in objects and destructuring",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let l=0;l<r.length;l++){if(r[l]==="{"&&!Fu(r,l)){let a=r[l+1];if(a==="}"||a===void 0||a===`
172
+ `)continue;if(l>0&&r[l-1]==="$")continue;if(a!==" "&&a!=="\t")t.push({filePath:n.filePath,line:i+1,column:l+2,ruleId:"style/object-curly-spacing",message:"Missing space after '{'",severity:"warning"})}if(r[l]==="}"&&!Fu(r,l)){let a=l>0?r[l-1]:void 0;if(a==="{"||a===void 0||a===`
173
+ `)continue;if(l+1<r.length&&r.slice(l+1).match(/^[^}]*\$\{/))continue;if(a!==" "&&a!=="\t")t.push({filePath:n.filePath,line:i+1,column:l+1,ruleId:"style/object-curly-spacing",message:"Missing space before '}'",severity:"warning"})}}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/(?<!\$)\{(\S)/g,(r,o)=>{if(o==="}")return r;return`{ ${o}`}),i=i.replace(/(\S)\}/g,(r,o)=>{if(o==="{"||o==="$")return r;return`${o} }`}),t.push(i)}return t.join(`
174
+ `)}};var Wu=/(\&\&|\|\||\?\?|\?|\+|(?<!=)-(?!=)|\*|\/|%|\*\*|\|(?!\|)|&(?!&)|\^|<<|>>>?)\s*$/;function Bu(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var ju={meta:{docs:"Enforce operators at the beginning of continued lines",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l=o.match(Wu);if(l&&i+1<s.length){let a=s[i+1].trim();if(a&&!a.startsWith("//")&&!a.startsWith("*")){let c=r.lastIndexOf(l[1]);if(!Bu(r,c)){if(l[1]==="?"||l[1]===":")continue;t.push({filePath:n.filePath,line:i+1,column:c+1,ruleId:"style/operator-linebreak",message:`Operator '${l[1]}' should be at the beginning of the next line`,severity:"warning"})}}}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s=0;s<n.length;s++){let i=n[s],r=i.trim();if(!r||r.startsWith("//")||r.startsWith("*")||r.startsWith("/*")||r.endsWith("*/")){t.push(i);continue}let o=r.match(Wu);if(o&&s+1<n.length&&o[1]!=="?"&&o[1]!==":"){let l=n[s+1],a=l.trim();if(a&&!a.startsWith("//")&&!a.startsWith("*")){let c=o[1],u=i.lastIndexOf(o[1]);if(Bu(i,u)){t.push(i);continue}t.push(i.replace(new RegExp(`\\s*${c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*$`),""));let f=l.match(/^(\s*)/)?.[1]||"";n[s+1]=`${f}${c} ${a}`;continue}}t.push(i)}return t.join(`
175
+ `)}};var Uu={meta:{docs:"Disallow empty lines at the beginning and end of blocks",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let o=s[i].trim();if(o.endsWith("{")&&i+1<s.length){if(s[i+1].trim()==="")t.push({filePath:n.filePath,line:i+2,column:1,ruleId:"style/padded-blocks",message:"Unexpected empty line after opening brace",severity:"warning"})}if(o==="}"&&i>0){if(s[i-1].trim()==="")t.push({filePath:n.filePath,line:i,column:1,ruleId:"style/padded-blocks",message:"Unexpected empty line before closing brace",severity:"warning"})}}return t},fix(e){let n=e.split(/\r?\n/),t=new Set;for(let s=0;s<n.length;s++){let i=n[s].trim();if(i.endsWith("{")&&s+1<n.length&&n[s+1].trim()==="")t.add(s+1);if(i==="}"&&s>0&&n[s-1].trim()==="")t.add(s-1)}return n.filter((s,i)=>!t.has(i)).join(`
176
+ `)}};var ur=/^(\s*)(["'])([a-zA-Z_$][a-zA-Z0-9_$]*)\2\s*:/;var zu={meta:{docs:"Remove unnecessary quotes from object property keys",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l=r.match(ur);if(l){let a=l[3];if(["class","return","function","var","let","const","delete","typeof","void","in","instanceof","new","this","throw","try","catch","finally","switch","case","default","break","continue","do","while","for","if","else","with","import","export","extends","super","yield","await","enum","implements","interface","package","private","protected","public","static"].includes(a))continue;t.push({filePath:n.filePath,line:i+1,column:r.indexOf(l[2])+1,ruleId:"style/quote-props",message:`Unnecessarily quoted property '${a}'`,severity:"warning",help:"Remove quotes from this property key."})}}return t},fix(e){let n=e.split(/\r?\n/),t=[],s=new Set(["class","return","function","var","let","const","delete","typeof","void","in","instanceof","new","this","throw","try","catch","finally","switch","case","default","break","continue","do","while","for","if","else","with","import","export","extends","super","yield","await","enum","implements","interface","package","private","protected","public","static"]);for(let i of n){let r=i,o=i.match(ur);if(o&&!s.has(o[3]))r=i.replace(ur,"$1$3:");t.push(r)}return t.join(`
177
+ `)}};function Vp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var qu=/\.\.\.\s+([a-zA-Z_$])/g,Ku={meta:{docs:"Disallow space after spread/rest operator (...)",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;qu.lastIndex=0;while((l=qu.exec(r))!==null){if(Vp(r,l.index))continue;t.push({filePath:n.filePath,line:i+1,column:l.index+4,ruleId:"style/rest-spread-spacing",message:"Unexpected space after spread operator",severity:"warning"})}}return t},fix(e){return e.replace(/\.\.\.\s+([a-zA-Z_$\[{])/g,"...$1")}};function Hp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Vu={meta:{docs:"Disallow space before semicolons, require space after",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let l=0;l<r.length;l++){if(r[l]!==";")continue;if(Hp(r,l))continue;if(l>0&&r[l-1]===" "){if(r.slice(0,l).trim().length>0)t.push({filePath:n.filePath,line:i+1,column:l+1,ruleId:"style/semi-spacing",message:"Unexpected space before semicolon",severity:"warning"})}if(l+1<r.length&&r[l+1]!==" "&&r[l+1]!=="\t"&&r[l+1]!==`
178
+ `&&r[l+1]!=="\r"&&r[l+1]!==")"){let a=r.slice(l+1);if(r.slice(0,l).includes(";")||a.includes(";"))t.push({filePath:n.filePath,line:i+1,column:l+2,ruleId:"style/semi-spacing",message:"Missing space after semicolon",severity:"warning"})}}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s,r=new RegExp(" ;","g");i=i.replace(r,String.fromCharCode(59));let o=new RegExp(";(\\S)","g");i=i.replace(o,(l,a)=>{if(a===";"||a===")")return l;return`; ${a}`}),t.push(i)}return t.join(`
179
+ `)}};var Hu=/(\S)\{/g;function Zp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Zu={meta:{docs:"Require space before opening brace of blocks",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;Hu.lastIndex=0;while((l=Hu.exec(r))!==null){let a=l.index,c=l[1];if(Zp(r,a))continue;if(c==="$")continue;if(c==="="||c===":"||c==="("||c===","||c==="[")continue;if(c==="{")continue;if(c===")"||/[a-zA-Z0-9_]/.test(c))t.push({filePath:n.filePath,line:i+1,column:l.index+2,ruleId:"style/space-before-blocks",message:"Missing space before '{'",severity:"warning"})}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s.replace(/([)a-zA-Z0-9_])\{/g,"$1 {");t.push(i)}return t.join(`
180
+ `)}};var Gu=/\bfunction\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s+\(/g,Ju=/\bfunction\(/g;function Yu(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Xu={meta:{docs:"Control spacing before ( in function declarations",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;Gu.lastIndex=0;while((l=Gu.exec(r))!==null){if(Yu(r,l.index))continue;t.push({filePath:n.filePath,line:i+1,column:l.index+l[0].length,ruleId:"style/space-before-function-paren",message:"Unexpected space before function parentheses",severity:"warning"})}Ju.lastIndex=0;while((l=Ju.exec(r))!==null){if(Yu(r,l.index))continue;if(r.slice(0,l.index+8).match(/function\s+[a-zA-Z_$]/))continue;t.push({filePath:n.filePath,line:i+1,column:l.index+9,ruleId:"style/space-before-function-paren",message:"Missing space before function parentheses",severity:"warning"})}}return t},fix(e){let n=e;return n=n.replace(/\bfunction\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s+\(/g,"function $1("),n=n.replace(/\bfunction\(/g,"function ("),n}};function Qu(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var ef={meta:{docs:"Disallow spaces inside parentheses",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let l=0;l<r.length;l++){if(r[l]==="("&&!Qu(r,l)){let a=r[l+1];if(a===")"||a===void 0||a===`
181
+ `)continue;if(a===" ")t.push({filePath:n.filePath,line:i+1,column:l+2,ruleId:"style/space-in-parens",message:"Unexpected space after '('",severity:"warning"})}if(r[l]===")"&&!Qu(r,l)){if(l===0)continue;let a=r[l-1];if(a==="(")continue;if(a===" "){if(r.slice(0,l).includes("("))t.push({filePath:n.filePath,line:i+1,column:l,ruleId:"style/space-in-parens",message:"Unexpected space before ')'",severity:"warning"})}}}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/\(\s+(\S)/g,"($1"),i=i.replace(/(\S)\s+\)/g,"$1)"),t.push(i)}return t.join(`
182
+ `)}};var tf=["&&","||","??","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","|=","^=","??=","||=","&&="];function Gp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var nf={meta:{docs:"Require spacing around infix operators (&&, ||, ??, assignment operators)",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let l of tf){let a=0,c;while((c=r.indexOf(l,a))!==-1){if(a=c+l.length,Gp(r,c))continue;if(l==="&&"&&r[c+2]==="=")continue;if(l==="||"&&r[c+2]==="=")continue;if(l==="??"&&r[c+2]==="=")continue;let u=c>0?r[c-1]:" ",f=c+l.length<r.length?r[c+l.length]:" ";if(u!==" "&&u!=="\t")t.push({filePath:n.filePath,line:i+1,column:c+1,ruleId:"style/space-infix-ops",message:`Missing space before '${l}'`,severity:"warning"});if(f!==" "&&f!=="\t"&&f!==`
183
+ `&&f!=="\r")t.push({filePath:n.filePath,line:i+1,column:c+l.length+1,ruleId:"style/space-infix-ops",message:`Missing space after '${l}'`,severity:"warning"})}}}return t},fix(e){let n=e,t=[...tf].sort((s,i)=>i.length-s.length);for(let s of t){let i=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=n.replace(new RegExp(`(\\S)${i}`,"g"),`$1 ${s}`),n=n.replace(new RegExp(`${i}(\\S)`,"g"),`${s} $1`)}return n}};var sf=["typeof","void","delete","new","throw","yield","await"];function fr(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var rf={meta:{docs:"Require space after word unary operators, disallow space after symbol unary operators",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let u of sf){let f=new RegExp(`\\b${u}([^\\s;,)])`,"g"),m;while((m=f.exec(r))!==null){if(fr(r,m.index))continue;t.push({filePath:n.filePath,line:i+1,column:m.index+u.length+1,ruleId:"style/space-unary-ops",message:`Missing space after '${u}'`,severity:"warning"})}}let l=/!\s+([a-zA-Z_$({[])/g,a;while((a=l.exec(r))!==null){if(fr(r,a.index))continue;let u=r.slice(0,a.index),f=u.trimEnd().slice(-1),m=new RegExp("[=(<[{,;|&?:+\\-*/!~^%]");if(!f||m.test(f)||u.trimEnd().endsWith("return")||u.trimEnd().endsWith("case"))t.push({filePath:n.filePath,line:i+1,column:a.index+2,ruleId:"style/space-unary-ops",message:"Unexpected space after '!'",severity:"warning"})}let c=/~\s+([a-zA-Z_$({[])/g;while((a=c.exec(r))!==null){if(fr(r,a.index))continue;t.push({filePath:n.filePath,line:i+1,column:a.index+2,ruleId:"style/space-unary-ops",message:"Unexpected space after '~'",severity:"warning"})}}return t},fix(e){let n=e;for(let t of sf)n=n.replace(new RegExp(`\\b${t}([^\\s;,)])`,"g"),`${t} $1`);return n=n.replace(/!\s+([a-zA-Z_$({[])/g,"!$1"),n=n.replace(/~\s+([a-zA-Z_$({[])/g,"~$1"),n}};var of={meta:{docs:"Require space after // and /* in comments",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim(),l=r.indexOf("//");if(l!==-1){let c=r.slice(0,l),u=(c.match(/'/g)||[]).length,f=(c.match(/"/g)||[]).length,m=(c.match(/`/g)||[]).length;if(u%2===0&&f%2===0&&m%2===0){if(!c.match(/https?:$/)){let h=r.slice(l+2);if(h.length>0&&h[0]!==" "&&h[0]!=="\t"&&h[0]!=="/"&&h[0]!=="!")t.push({filePath:n.filePath,line:i+1,column:l+3,ruleId:"style/spaced-comment",message:"Missing space after '//'",severity:"warning",help:"Add a space after // in comments."})}}}let a=r.indexOf("/*");if(a!==-1&&r[a+2]!=="*"&&r[a+2]!=="!"){let c=r.slice(0,a),u=(c.match(/'/g)||[]).length,f=(c.match(/"/g)||[]).length,m=(c.match(/`/g)||[]).length;if(u%2===0&&f%2===0&&m%2===0){let h=r.slice(a+2);if(h.length>0&&h[0]!==" "&&h[0]!=="\t"&&h[0]!==`
184
+ `)t.push({filePath:n.filePath,line:i+1,column:a+3,ruleId:"style/spaced-comment",message:"Missing space after '/*'",severity:"warning",help:"Add a space after /* in comments."})}}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/(\/\/)([^\s/!])/,"$1 $2"),i=i.replace(/(\/\*)([^\s*!])/,"$1 $2"),t.push(i)}return t.join(`
185
+ `)}};var lf=/^\s*(case\b.+?|default)\s*:/,af={meta:{docs:"Enforce spacing around colon in switch case/default clauses",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o)continue;let l=o.match(lf);if(!l)continue;let a=l[1],c=r.indexOf(":",r.indexOf(a)+a.length);if(c===-1)continue;if(c>0&&r[c-1]===" ")t.push({filePath:n.filePath,line:i+1,column:c+1,ruleId:"style/switch-colon-spacing",message:"Unexpected space before colon in switch case",severity:"warning"});if(c+1<r.length&&r[c+1]!==" "&&r[c+1]!=="\t"&&r[c+1]!==`
186
+ `)t.push({filePath:n.filePath,line:i+1,column:c+2,ruleId:"style/switch-colon-spacing",message:"Missing space after colon in switch case",severity:"warning"})}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s,r=s.trim();if(lf.test(r))i=i.replace(/(case\b.+?|default)\s+:/,"$1:"),i=i.replace(/(case\b.+?:|default:)(\S)/,"$1 $2");t.push(i)}return t.join(`
187
+ `)}};var cf="${",uf={meta:{docs:"Disallow spaces inside template literal interpolation curly braces",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];for(let o=r.indexOf(cf,0);o!==-1;o=r.indexOf(cf,o)){let l=o+2;if(l<r.length&&(r[l]===" "||r[l]==="\t")){if((r.slice(0,o).match(/`/g)||[]).length%2===1)t.push({filePath:n.filePath,line:i+1,column:l+1,ruleId:"style/template-curly-spacing",message:"Unexpected space after '${'",severity:"warning"})}let a=1,c=l;while(c<r.length&&a>0){if(r[c]==="{")a++;if(r[c]==="}")a--;if(a>0)c++}if(a===0&&c>0){let u=r[c-1];if(u===" "||u==="\t"){if((r.slice(0,o).match(/`/g)||[]).length%2===1)t.push({filePath:n.filePath,line:i+1,column:c,ruleId:"style/template-curly-spacing",message:"Unexpected space before '}'",severity:"warning"})}}o=l}}return t},fix(e){return e.replace(/\$\{\s+([^}]*?)\s+\}/g,"${$1}")}};var Pt=/([a-zA-Z_$][a-zA-Z0-9_$]*)\s+`/g;function ff(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var mf=new Set(["return","case","typeof","void","delete","throw","new","in","of","await","yield","export","default","extends","else","instanceof"]),hf={meta:{docs:"Disallow space between tag function and template literal",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;Pt.lastIndex=0;for(l=Pt.exec(r);l!==null;l=Pt.exec(r)){let a=l[1],c=l.index;if(ff(r,c))continue;if(mf.has(a))continue;let u=c+a.length;t.push({filePath:n.filePath,line:i+1,column:u+1,ruleId:"style/template-tag-spacing",message:"Unexpected space between tag function and template literal",severity:"warning"})}}return t},fix(e,n){let t=e.split(/\r?\n/),s=[];for(let i=0;i<t.length;i++){let r=t[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*")){s.push(r);continue}let l=r,a=[],c;Pt.lastIndex=0;for(c=Pt.exec(r);c!==null;c=Pt.exec(r)){let u=c[1],f=c.index;if(ff(r,f))continue;if(mf.has(u))continue;a.push({index:f,fullMatch:c[0],identifier:u})}for(let u=a.length-1;u>=0;u--){let f=a[u],m=f.index,h=m+f.fullMatch.length;l=l.slice(0,m)+f.identifier+"`"+l.slice(h)}s.push(l)}return s.join(`
188
+ `)}};var df={meta:{docs:"Require parentheses around immediately invoked function expressions (IIFEs)",recommended:!0},check(e,n){let t=[],s=/[^a-zA-Z_$](function\s*\([^)]*\)\s*\{[^}]*\})\s*\(/g,i;for(i=s.exec(e);i!==null;i=s.exec(e)){if(i.index>0&&e[i.index]==="(")continue;let r=e.slice(0,i.index).split(`
189
+ `).length,o=e.lastIndexOf(`
190
+ `,i.index),l=i.index-o;t.push({filePath:n.filePath,line:r,column:l,ruleId:"style/wrap-iife",message:"Wrap immediately invoked function expressions in parentheses",severity:"warning"})}return t},fix(e){return e.replace(/([^a-zA-Z_$(\n])(function\s*\([^)]*\)\s*\{[^}]*\})\s*\(/g,"$1($2)(")}};var pf=/\byield\s*\*/g;function Jp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var gf={meta:{docs:"Enforce spacing around * in yield* expressions (no space before *, space after)",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;pf.lastIndex=0;while((l=pf.exec(r))!==null){let a=l.index;if(Jp(r,a))continue;let c=l[0],u=a+c.length-1,f=u+1;if(c!=="yield*")t.push({filePath:n.filePath,line:i+1,column:u+1,ruleId:"style/yield-star-spacing",message:"Unexpected space before * in yield expression",severity:"warning"});if(f<r.length&&r[f]!==" "&&r[f]!=="\t"&&r[f]!==`
191
+ `)t.push({filePath:n.filePath,line:i+1,column:f+1,ruleId:"style/yield-star-spacing",message:"Missing space after * in yield expression",severity:"warning"})}}return t},fix(e,n){let t=e;return t=t.replace(/\byield\s+\*/g,"yield*"),t=t.replace(/\byield\*(\S)/g,"yield* $1"),t}};var yf={name:"style",rules:{"brace-style":b(Ac),curly:b(Kc),"max-statements-per-line":b(uu),"if-newline":b(nu),"consistent-chaining":b(Bc),"consistent-list-newline":b(qc),"indent-unindent":b(su),"no-multi-spaces":Au,"no-multiple-empty-lines":Ou,"no-trailing-spaces":Du,"keyword-spacing":b(lu),"arrow-spacing":b(Lc),"space-infix-ops":b(nf),"object-curly-spacing":b(Nu),"spaced-comment":b(of),"block-spacing":b(Tc),"space-before-blocks":b(Zu),"comma-spacing":b(Fc),"semi-spacing":b(Vu),"rest-spread-spacing":b(Ku),"generator-star-spacing":b(tu),"yield-star-spacing":b(gf),"function-call-spacing":b(Xc),"template-tag-spacing":b(hf),"no-whitespace-before-property":b(wu),"key-spacing":b(ru),"computed-property-spacing":b(Wc),"array-bracket-spacing":b(Mc),"space-in-parens":b(ef),"template-curly-spacing":b(uf),"space-unary-ops":b(rf),"switch-colon-spacing":b(af),"comma-dangle":b(Dc),"arrow-parens":b(Sc),"space-before-function-paren":b(Xu),"quote-props":b(zu),"no-floating-decimal":b(Lu),"new-parens":b(pu),"no-extra-parens":b(yu),"wrap-iife":b(df),"comma-style":b(Nc),"dot-location":b(Vc),"operator-linebreak":b(ju),"multiline-ternary":b(hu),"padded-blocks":b(Uu),"lines-between-class-members":b(cu),"no-mixed-operators":b(Mu),"indent-binary-ops":b(Gc),"no-tabs":b(_u),"no-mixed-spaces-and-tabs":b(Tu)}};var bf={meta:{docs:"Enforce consistent member delimiter style in interfaces and type literals",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r=0,o=0;for(let l=0;l<s.length;l++){let a=s[l],c=a.trim();if(!c||c.startsWith("//")||c.startsWith("*")||c.startsWith("/*"))continue;if(c.match(/\b(interface|type)\b.*\{/))i=!0,o=r+1;for(let u of c){if(u==="{")r++;if(u==="}")r--}if(i&&r<o){i=!1;continue}if(!i||r!==o)continue;if(c==="}"||c==="};"||c==="},")continue;if(c.endsWith(",")){if(c.startsWith("|")||c.startsWith("&"))continue;t.push({filePath:n.filePath,line:l+1,column:a.length,ruleId:"ts/member-delimiter-style",message:"Expected semicolon delimiter in interface, found comma",severity:"warning"})}if(!c.endsWith(";")&&!c.endsWith(",")&&!c.endsWith("{")&&!c.endsWith("(")){if(c.match(/^\w+[\s?]*:/)||c.match(/^\[/)||c.match(/^readonly\b/))t.push({filePath:n.filePath,line:l+1,column:a.length+1,ruleId:"ts/member-delimiter-style",message:"Missing semicolon delimiter in interface member",severity:"warning"})}}return t},fix(e){let n=e.split(/\r?\n/),t=[],s=!1,i=0,r=0;for(let o=0;o<n.length;o++){let l=n[o],a=l.trim();if(a.match(/\b(interface|type)\b.*\{/))s=!0,r=i+1;let c=i;for(let u of a){if(u==="{")i++;if(u==="}")i--}if(s&&i<r){s=!1,t.push(l);continue}if(s&&c===r&&a!=="}"&&a!=="};"&&a!=="},"){let u=l;if(a.endsWith(","))u=l.replace(/,\s*$/,";");t.push(u);continue}t.push(l)}return t.join(`
192
+ `)}};var xf={meta:{docs:"Disallow the use of the `any` type - it defeats the purpose of TypeScript type safety"},check:(e,n)=>{let t=[];if(!/\.tsx?$/.test(n.filePath))return t;let s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r],l=o;if(i){let h=o.indexOf("*/");if(h>=0)o=o.slice(h+2),i=!1;else continue}let a=o.indexOf("/*"),c=o.indexOf("//");if(a>=0&&(c===-1||a<c)){let h=o.indexOf("*/",a+2);if(h>=0)o=o.slice(0,a)+o.slice(h+2);else i=!0,o=o.slice(0,a)}if(c>=0)o=o.slice(0,c);let u=o.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),f=/\b(any)\b/g,m;while((m=f.exec(u))!==null){let h=m.index,d=u[h-1]||" ",p=u[h+3]||" ",g=u.slice(Math.max(0,h-10),h),y=u.slice(h+3,Math.min(u.length,h+10));if(/\w/.test(d)||/\w/.test(p))continue;if(/:/.test(g)||/</.test(g)||/\bas\s*$/.test(g)||/,/.test(g)||/\|/.test(g)||/&/.test(g)||/\[/.test(y)||/>/.test(y)||/,/.test(y)||/\|/.test(y)||/extends\s+$/.test(g)||/=\s*$/.test(g)){let k=l.indexOf("any",Math.max(0,h-5));t.push({filePath:n.filePath,line:r+1,column:k>=0?k+1:h+1,ruleId:"ts/no-explicit-any",message:"Unexpected `any` type. Specify a more precise type or use `unknown` if the type is truly unknown.",severity:"error",help:"Replace `any` with a specific type, `unknown`, or a generic type parameter"})}}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/:\s*any\b(?!\s*\))/g,(r)=>r.replace("any","unknown")),t.push(i)}return t.join(`
193
+ `)}};var wf={meta:{docs:"Require promises to be handled - must be awaited, returned, or have .catch() called"},check:(e,n)=>{let t=[];if(!/\.tsx?$/.test(n.filePath))return t;let s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r],l=o;if(i){let m=o.indexOf("*/");if(m>=0)o=o.slice(m+2),i=!1;else continue}let a=o.indexOf("/*"),c=o.indexOf("//");if(a>=0&&(c===-1||a<c)){let m=o.indexOf("*/",a+2);if(m>=0)o=o.slice(0,a)+o.slice(m+2);else i=!0,o=o.slice(0,a)}if(c>=0)o=o.slice(0,c);let u=o.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""');if(/\b(?:await|return|void)\s/.test(u))continue;if(/\.(?:then|catch|finally)\s*\(/.test(u))continue;let f=[/\b(fetch|axios|request)\s*\(/,/\b[\w$]*(?:async|Async|load|Load|get|Get|post|Post|put|Put|delete|Delete|save|Save|update|Update|fetch|Fetch)[\w$]*\s*\(/,/\bnew\s+Promise\s*\(/,/\bPromise\s*\.\s*(?:resolve|reject|all|allSettled|race|any)\s*\(/];for(let m of f){let h=u.match(m);if(!h)continue;let d=u.indexOf(h[0]),p=u.slice(0,d).trim();if(/\b(?:const|let|var)\s+[\w$]+\s*=\s*$/.test(p))continue;if(/[\w$]+\s*=\s*$/.test(p))continue;if(/\breturn\s+$/.test(p))continue;if(/\(\s*$/.test(p)||/,\s*$/.test(p))continue;let g=u.slice(d+h[0].length),y=1,x=h[0].length;while(x<g.length&&y>0){if(g[x]==="(")y++;else if(g[x]===")")y--;x++}let k=g.slice(x).trim();if(/^\.(?:then|catch|finally)\s*\(/.test(k))continue;if(k===""||k.startsWith(";")){let v=l.indexOf(h[0]);t.push({filePath:n.filePath,line:r+1,column:v>=0?v+1:d+1,ruleId:"ts/no-floating-promises",message:"Promise returned by this call is not handled. Add await, return, .catch(), or void.",severity:"error",help:"Either await the promise, return it, add .catch() to handle errors, or use void to explicitly mark as fire-and-forget"});break}}}return t}};var Rf={meta:{docs:"Disallow promises in places not designed to handle them (conditionals, logical expressions)"},check:(e,n)=>{let t=[];if(!/\.tsx?$/.test(n.filePath))return t;let s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r],l=o;if(i){let g=o.indexOf("*/");if(g>=0)o=o.slice(g+2),i=!1;else continue}let a=o.indexOf("/*"),c=o.indexOf("//");if(a>=0&&(c===-1||a<c)){let g=o.indexOf("*/",a+2);if(g>=0)o=o.slice(0,a)+o.slice(g+2);else i=!0,o=o.slice(0,a)}if(c>=0)o=o.slice(0,c);let u=o.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),f=u.match(/\bif\s*\(\s*(!?)\s*([\w$]+\s*\([^)]*\))/);if(f){let g=f[1],y=f[2];if(/async|Async|fetch|Fetch|load|Load|get|Get|save|Save/.test(y)){let x=u.slice(0,u.indexOf(f[0])),k=u.slice(u.indexOf("if (")+4);if(!/\bawait\s/.test(k)){let v=l.indexOf(y);t.push({filePath:n.filePath,line:r+1,column:v>=0?v+1:1,ruleId:"ts/no-misused-promises",message:"Promise used in conditional expression without await. Promises are always truthy.",severity:"error",help:"Add await before the async call in the condition"})}}}let m=/(?:async|Async|fetch|Fetch|load|Load|get|Get|save|Save|Promise\.)[\w$]*\s*\([^)]*\)/g,h;while((h=m.exec(u))!==null){let g=h.index,y=h[0],x=u.slice(Math.max(0,g-10),g),k=u.slice(g+y.length,Math.min(u.length,g+y.length+10));if(/(?:&&|\|\|)\s*$/.test(x)||/^\s*(?:&&|\|\|)/.test(k)){if(!/\bawait\s*$/.test(x)){let w=l.indexOf(y,Math.max(0,g-5));t.push({filePath:n.filePath,line:r+1,column:w>=0?w+1:g+1,ruleId:"ts/no-misused-promises",message:"Promise used in logical expression without await. This will not work as expected.",severity:"error",help:"Add await before the async call or restructure the logic"})}}let v=u.slice(Math.max(0,g-20),g);if(/\?\s*$/.test(x)||/\?[^:]*$/.test(v)){if(!/\bawait\s*$/.test(x)){let w=l.indexOf(y,Math.max(0,g-5));t.push({filePath:n.filePath,line:r+1,column:w>=0?w+1:g+1,ruleId:"ts/no-misused-promises",message:"Promise used in ternary expression without await.",severity:"error",help:"Add await before the async call"})}}}let d=u.match(/\b(?:while|for)\s*\([^)]*(?:async|Async|fetch|Fetch|load|Load|get|Get)[\w$]*\s*\([^)]*\)/);if(d){if(!/\bawait\s/.test(d[0])){let g=l.indexOf(d[0]);t.push({filePath:n.filePath,line:r+1,column:g>=0?g+1:1,ruleId:"ts/no-misused-promises",message:"Promise used in loop condition without await. This will cause unexpected behavior.",severity:"error",help:"Add await before the async call in the loop condition"})}}let p=u.match(/\.(forEach|map|filter|reduce|every|some|find|findIndex)\s*\(\s*async\s*(?:\(|[\w$]+\s*=>)/);if(p){if(p[1]==="forEach"){let y=l.indexOf(p[0]);t.push({filePath:n.filePath,line:r+1,column:y>=0?y+1:1,ruleId:"ts/no-misused-promises",message:"async callback in forEach - forEach does not wait for promises to resolve.",severity:"error",help:"Use for...of loop with await, or Promise.all() with map()"})}}}return t}};var kf={meta:{docs:"Disallow require() in TypeScript files; prefer ESM imports"},check:(e,n)=>{let t=[];if(!/\.ts$/.test(n.filePath))return t;let s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r],l=o;if(i){let m=l.indexOf("*/");if(m>=0)l=l.slice(m+2),i=!1;else continue}let a=l.indexOf("/*"),c=l.indexOf("//");if(a>=0&&(c===-1||a<c)){let m=l.indexOf("*/",a+2);if(m>=0)l=l.slice(0,a)+l.slice(m+2);else i=!0,l=l.slice(0,a)}if(c>=0)l=l.slice(0,c);let u=l.trim();if(!u)continue;if(/\bimport\s*\(/.test(u))continue;let f=u.indexOf("require(");if(f>=0){t.push({filePath:n.filePath,line:r+1,column:o.indexOf("require(")+1||f+1,ruleId:"ts/no-require-imports",message:"Do not use require() in TypeScript files. Use ESM import syntax instead.",severity:"error"});continue}if(/^import\s+(?:\S.*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])=\s*require\s*\(/.test(u)){let m=o.indexOf("require(");t.push({filePath:n.filePath,line:r+1,column:m>-1?m+1:1,ruleId:"ts/no-require-imports",message:"Do not use require() in TypeScript files. Use ESM import syntax instead.",severity:"error"})}}return t}};var $f={meta:{docs:"Disallow top-level await in TypeScript/JavaScript files"},check:(e,n)=>{let t=[],s=n.filePath.split(".").pop()||"";if(!["ts","tsx","mts","cts","js","mjs","cjs"].includes(s))return t;let i=0,r=!1,o=!1,l=!1,a=!1,c=!1,u=!1,f=0,m=1,h=(d)=>{t.push({filePath:n.filePath,line:m,column:d,ruleId:"ts/no-top-level-await",message:"Do not use top-level await",severity:"error"})};for(let d=0;d<e.length;d++){let p=e[d];f++;let g=e[d+1];if(p===`
194
+ `){o=!1,m++,f=0;continue}if(o)continue;if(r){if(p==="*"&&g==="/")r=!1,d++,f++;continue}if(l){if(!u&&p==="\\"){u=!0;continue}if(!u&&p==="'")l=!1;u=!1;continue}if(a){if(!u&&p==="\\"){u=!0;continue}if(!u&&p==='"')a=!1;u=!1;continue}if(c){if(!u&&p==="\\"){u=!0;continue}if(!u&&p==="`")c=!1;u=!1;continue}if(p==="/"&&g==="*"){r=!0,d++,f++;continue}if(p==="/"&&g==="/"){o=!0,d++,f++;continue}if(p==="'"){l=!0;continue}if(p==='"'){a=!0;continue}if(p==="`"){c=!0;continue}if(p==="{"){i++;continue}if(p==="}"){if(i>0)i--;continue}if(p==="a"&&e.slice(d,d+5)==="await"){let y=e.slice(Math.max(0,d-6),d),x=/for\s+$/.test(y),k=d===0||/[^$\w]/.test(e[d-1]),v=/[^$\w]/.test(e[d+5]||" ");if(!x&&k&&v&&i===0)h(f);d+=4,f+=4;continue}}return t}};var Pf={meta:{docs:"Disallow `exports =` in TypeScript; prefer ESM export default"},check:(e,n)=>{let t=[],s=n.filePath.split(".").pop()||"";if(!["ts","tsx","mts","cts","d.ts"].includes(s))return t;let i=e.split(/\r?\n/);for(let r=0;r<i.length;r++){let a=i[r].replace(/\/\*.*?\*\//g,"").replace(/\/\/.*$/,"").match(/\bexports\s*=\s*/);if(a)t.push({filePath:n.filePath,line:r+1,column:(a.index||0)+1,ruleId:"ts/no-ts-export-equal",message:"Use ESM `export default` instead of `exports =`",severity:"error"})}return t}};var vf={meta:{docs:"Disallow assignment of `any` typed values to variables - unsafe assignments bypass type checking"},check:(e,n)=>{let t=[];if(!/\.tsx?$/.test(n.filePath))return t;let s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r],l=o;if(i){let x=o.indexOf("*/");if(x>=0)o=o.slice(x+2),i=!1;else continue}let a=o.indexOf("/*"),c=o.indexOf("//");if(a>=0&&(c===-1||a<c)){let x=o.indexOf("*/",a+2);if(x>=0)o=o.slice(0,a)+o.slice(x+2);else i=!0,o=o.slice(0,a)}if(c>=0)o=o.slice(0,c);let u=o.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),f=/(\w+)\s+as\s+any/g,m;while((m=f.exec(u))!==null){let x=m[1],k=m.index,v=u.slice(k+m[0].length).trim(),w=u.slice(0,k).trim();if(/=\s*$/.test(w)&&!/==|===|!=|!==/.test(w)){let M=l.indexOf(m[0]);t.push({filePath:n.filePath,line:r+1,column:M>=0?M+1:k+1,ruleId:"ts/no-unsafe-assignment",message:"Unsafe assignment: value cast to `any` is being assigned. This bypasses type checking.",severity:"error",help:"Avoid casting to `any` or use a more specific type"})}}let h=["JSON.parse","eval","Function","require"];for(let x of h){let k=new RegExp(`\\b${x.replace(".","\\.")}\\s*\\(`,"g");k.lastIndex=0;while((m=k.exec(u))!==null){let v=m.index,w=u.slice(0,v).trim(),M=w.match(/(?:const|let|var)\s+([\w$]+)\s*=\s*$/);if(M){let C=M[1];if(!new RegExp(`\\b${C}\\s*:\\s*\\w+`).test(u)){let T=l.indexOf(m[0]);t.push({filePath:n.filePath,line:r+1,column:T>=0?T+1:v+1,ruleId:"ts/no-unsafe-assignment",message:`Unsafe assignment from ${x}() without type annotation. This function returns 'any'.`,severity:"error",help:`Add a type annotation to ${C} or use a type assertion with a specific type`})}}let L=w.match(/([\w$.]+)\s*=\s*$/),_=/(?:const|let|var)\s+/.test(w);if(L&&!M&&!_){let C=l.indexOf(m[0]);t.push({filePath:n.filePath,line:r+1,column:C>=0?C+1:v+1,ruleId:"ts/no-unsafe-assignment",message:`Unsafe assignment from ${x}() which returns 'any'.`,severity:"error",help:"Consider adding a type assertion with a specific type"})}}}let d=/(?:const|let|var)\s+([\w$]+)\s*:\s*any\s*=/,p=u.match(d);if(p){let x=p[1],k=l.indexOf(p[0]);t.push({filePath:n.filePath,line:r+1,column:k>=0?k+1:1,ruleId:"ts/no-unsafe-assignment",message:`Variable '${x}' is explicitly typed as 'any'. This defeats TypeScript's type safety.`,severity:"error",help:"Use a more specific type or `unknown` instead of `any`"})}let g=/(?:const|let|var)\s+(?:\{[^}]+\}|\[[^\]]+\])\s*=\s*([\w$]+)/,y=u.match(g);if(y){let x=y[1];if(/^(?:params|query|body|req|res|response|data|result)$/.test(x));}}return t}};var If={meta:{docs:"Prefer nullish coalescing operator (??) over logical OR (||) when checking for null/undefined"},check:(e,n)=>{let t=[];if(!/\.tsx?$/.test(n.filePath))return t;let s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r],l=o.split(""),a=l.length,c=0;if(i){let d=o.indexOf("*/");if(d<0)continue;for(let p=0;p<=d+1;p++)l[p]=" ";i=!1,c=d+2}let u=null;for(;c<a;c++){let d=l[c];if(u){if(d==="\\"){if(l[c]=" ",c+1<a)l[c+1]=" ",c++;continue}if(d===u){u=null;continue}l[c]=" ";continue}if(d==="/"&&l[c+1]==="/"){for(let p=c;p<a;p++)l[p]=" ";break}if(d==="/"&&l[c+1]==="*"){let p=o.indexOf("*/",c+2);if(p<0){for(let g=c;g<a;g++)l[g]=" ";i=!0;break}for(let g=c;g<=p+1;g++)l[g]=" ";c=p+1;continue}if(d==='"'||d==="'"||d==="`")u=d}let f=l.join(""),m=/\|\|/g,h;while((h=m.exec(f))!==null){let d=h.index,p=d-1,g=0,y=0,x=0;while(p>=0){let C=f[p];if(C===")")g++;else if(C==="("){if(g===0){p++;break}g--}else if(C==="}")y++;else if(C==="{"){if(y===0){p++;break}y--}else if(C==="]")x++;else if(C==="["){if(x===0){p++;break}x--}else if(g===0&&y===0&&x===0){if(new RegExp("[;,=:?]").test(C)){p++;break}if(C==="&"||C==="|"){p++;break}}p--}if(p<0)p=0;let k=f.slice(p,d).trim();if(/[<>!=]/.test(k))continue;if(/\b(?:true|false)\b/.test(k))continue;let v=d+2,w=v;g=0,y=0,x=0;while(w<f.length){let C=f[w];if(C==="(")g++;else if(C===")"){if(g===0)break;g--}else if(C==="{")y++;else if(C==="}"){if(y===0)break;y--}else if(C==="[")x++;else if(C==="]"){if(x===0)break;x--}else if(g===0&&y===0&&x===0){if(new RegExp("[;,?:]").test(C))break;if(C==="&"||C==="|"&&f[w+1]==="|")break}w++}let M=f.slice(v,w).trim(),L=/^["'`\d]/.test(M)||/^\{/.test(M)||/^[\w$]+\(/.test(M)||/^[\w$.[\]]+$/.test(M),_=/^[\w$]+$/.test(k)||/^[\w$.?[\]()]+$/.test(k);if(L&&_)t.push({filePath:n.filePath,line:r+1,column:d+1,ruleId:"ts/prefer-nullish-coalescing",message:"Prefer nullish coalescing operator (??) over logical OR (||)",severity:"error",help:'Use `??` instead of `||` to only handle null/undefined, not falsy values like 0, "", or false'})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s,r=new RegExp("(\\b[\\w$.]+)\\s*\\|\\|\\s*([^|&]+?)(?=\\s*[;,)\\]}]|$)","g");i=i.replace(r,(o,l,a)=>{if(/\b(?:true|false)\b/.test(a.trim()))return o;return`${l} ?? ${a}`}),t.push(i)}return t.join(`
195
+ `)}};var Mf={meta:{docs:"Prefer optional chaining (?.) over chained logical AND (&&) for property access"},check:(e,n)=>{let t=[];if(!/\.tsx?$/.test(n.filePath))return t;let s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r],l=o;if(i){let p=o.indexOf("*/");if(p>=0)o=o.slice(p+2),i=!1;else continue}let a=o.indexOf("/*"),c=o.indexOf("//");if(a>=0&&(c===-1||a<c)){let p=o.indexOf("*/",a+2);if(p>=0)o=o.slice(0,a)+o.slice(p+2);else i=!0,o=o.slice(0,a)}if(c>=0)o=o.slice(0,c);let u=o.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),f=/(\b[\w$]+)\s*&&\s*\1\.([\w$]+)/g,m;while((m=f.exec(u))!==null){let p=m[1],g=m[2],y=m.index,x=l.indexOf(m[0],Math.max(0,y-5));t.push({filePath:n.filePath,line:r+1,column:x>=0?x+1:y+1,ruleId:"ts/prefer-optional-chain",message:`Prefer optional chaining over && for property access: ${p}?.${g}`,severity:"error",help:`Use \`${p}?.${g}\` instead of \`${p} && ${p}.${g}\``})}let h=/([\w$]+\.[\w$.]+)\s*&&\s*\1\.([\w$]+)/g;h.lastIndex=0;while((m=h.exec(u))!==null){let p=m[1],g=m[2],y=m.index,x=l.indexOf(m[0],Math.max(0,y-5));t.push({filePath:n.filePath,line:r+1,column:x>=0?x+1:y+1,ruleId:"ts/prefer-optional-chain",message:`Prefer optional chaining over && for nested property access: ${p}?.${g}`,severity:"error",help:`Use \`${p}?.${g}\` instead of \`${p} && ${p}.${g}\``})}let d=u.split(/\s*&&\s*/);if(d.length>=3)for(let p=0;p<d.length-2;p++){let g=d[p].trim(),y=d[p+1].trim(),x=d[p+2].trim();if(y.startsWith(`${g}.`)&&x.startsWith(`${y}.`)){let k=l.indexOf(g);t.push({filePath:n.filePath,line:r+1,column:k>=0?k+1:1,ruleId:"ts/prefer-optional-chain",message:"Prefer optional chaining over multiple && checks for nested properties",severity:"error",help:`Use optional chaining like \`${g}?.${y.slice(g.length+1)}?.${x.slice(y.length+1)}\``});break}}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/(\b[\w$]+)\s*&&\s*\1\.([\w$]+)/g,"$1?.$2"),i=i.replace(/([\w$]+\.[\w$.]+)\s*&&\s*\1\.([\w$]+)/g,"$1?.$2"),t.push(i)}return t.join(`
196
+ `)}};function Yp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Cf=/([a-zA-Z_$][a-zA-Z0-9_$]*\??)\s*:\s*([A-Z][a-zA-Z0-9_$<>[\]|&]*|string|number|boolean|null|undefined|void|never|any|unknown|object|symbol|bigint)/g,Sf={meta:{docs:"Require consistent spacing around type annotation colons",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;Cf.lastIndex=0;while((l=Cf.exec(r))!==null){if(Yp(r,l.index))continue;let a=l[0],c=a.indexOf(":"),u=l.index+c;if(c>0&&a[c-1]===" "&&!a.startsWith("?")){if(!l[1].endsWith("?")||a[c-1]===" "){if(r[u-1]===" "&&!/\?\s*$/.test(l[1]))t.push({filePath:n.filePath,line:i+1,column:u+1,ruleId:"ts/type-annotation-spacing",message:"Unexpected space before colon in type annotation",severity:"warning"})}}if(u+1<r.length&&r[u+1]!==" "&&r[u+1]!=="\t")t.push({filePath:n.filePath,line:i+1,column:u+2,ruleId:"ts/type-annotation-spacing",message:"Missing space after colon in type annotation",severity:"warning"})}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/([a-zA-Z_$][a-zA-Z0-9_$]*\??)\s*:\s*([A-Z][a-zA-Z0-9_$<>[\]|&]*|string|number|boolean|null|undefined|void|never|any|unknown|object|symbol|bigint)/g,"$1: $2"),t.push(i)}return t.join(`
197
+ `)}};function Ef(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Lf=/([A-Za-z_$][A-Za-z0-9_$]*)\s*<(\s+)/g,Tf=/(\s+)>(?!=)/g,Xp=/([A-Za-z_$][A-Za-z0-9_$]*)\s*<\s+/g,Qp=/\s+>(?!=)/g,Af={meta:{docs:"Disallow spaces inside TypeScript generic angle brackets",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;Lf.lastIndex=0;let l;while((l=Lf.exec(r))!==null){let a=l.index+l[1].length,c=r.indexOf("<",a);if(c===-1)continue;if(Ef(r,c))continue;t.push({filePath:n.filePath,line:i+1,column:c+2,ruleId:"ts/type-generic-spacing",message:"Unexpected space after '<' in generic type",severity:"warning"})}Tf.lastIndex=0;while((l=Tf.exec(r))!==null){let a=l.index+l[1].length;if(Ef(r,a))continue;let c=r.slice(0,a);if(!/[A-Za-z_$][A-Za-z0-9_$]*\s*</.test(c))continue;t.push({filePath:n.filePath,line:i+1,column:a+1,ruleId:"ts/type-generic-spacing",message:"Unexpected space before '>' in generic type",severity:"warning"})}}return t},fix(e,n){let t=e.split(/\r?\n/),s=[];for(let i of t){let r=i.trim();if(!r||r.startsWith("//")||r.startsWith("*")||r.startsWith("/*")){s.push(i);continue}let o=i;if(o=o.replace(Xp,(l,a)=>`${a}<`),/[A-Za-z_$][A-Za-z0-9_$]*\s*</.test(o))o=o.replace(Qp,">");s.push(o)}return s.join(`
198
+ `)}};function eg(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Of=/([a-zA-Z_$][a-zA-Z0-9_$?]*):(\S)/g,Ff={meta:{docs:"Require space after colon in named tuple members",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l=_f(r);for(let a of l){Of.lastIndex=0;let c;while((c=Of.exec(a.text))!==null){let f=a.start+c.index+c[1].length;if(eg(r,f))continue;if(!Df(r))continue;t.push({filePath:n.filePath,line:i+1,column:f+2,ruleId:"ts/type-named-tuple-spacing",message:"Missing space after colon in named tuple member",severity:"warning"})}}}return t},fix(e,n){let t=e.split(/\r?\n/),s=[];for(let i of t){let r=i.trim();if(!r||r.startsWith("//")||r.startsWith("*")||r.startsWith("/*")){s.push(i);continue}if(!Df(i)){s.push(i);continue}let o=i,l=_f(i);for(let a=l.length-1;a>=0;a--){let c=l[a],u=c.text.replace(/([a-zA-Z_$][a-zA-Z0-9_$?]*):(\S)/g,"$1: $2");if(u!==c.text)o=o.slice(0,c.start)+u+o.slice(c.start+c.text.length)}s.push(o)}return s.join(`
199
+ `)}};function _f(e){let n=[],t=0,s=-1;for(let i=0;i<e.length;i++)if(e[i]==="["){if(t===0)s=i;t++}else if(e[i]==="]"){if(t--,t===0&&s>=0)n.push({start:s,text:e.slice(s,i+1)}),s=-1}return n}function Df(e){let n=e.trim();return/\btype\s/.test(n)||/:\s*\[/.test(n)||/=\s*\[/.test(n)||/\bas\s/.test(n)||/<[^>]*\[/.test(n)||/\bextends\s/.test(n)||/\bimplements\s/.test(n)}var Nf={name:"ts",rules:{"no-require-imports":b(kf),"no-top-level-await":b($f),"no-ts-export-equal":b(Pf),"no-explicit-any":b(xf),"prefer-nullish-coalescing":b(If),"prefer-optional-chain":b(Mf),"no-floating-promises":b(wf),"no-misused-promises":b(Rf),"no-unsafe-assignment":b(vf),"member-delimiter-style":b(bf),"type-annotation-spacing":b(Sf),"type-generic-spacing":b(Af),"type-named-tuple-spacing":b(Ff)}};var Wf={name:"unused-imports",rules:{"no-unused-vars":b(Ye),"no-unused-imports":b(Ye)}};function mr(){return[_o,zo,Za,Ha,yf,Xa,Nf,oa,Pc,vc,ca,nl,ka,Wf,ua]}var hr=null;function zf(){if(!hr)hr=new it("pickier",{showTags:!1});return hr}function vt(...e){if(Oe.TRACE)zf().debug("[pickier:trace]",e)}async function jf(e,n,t){let s,i=new Promise((r,o)=>{s=setTimeout(()=>o(Error(`Timeout after ${n}ms at ${t}`)),n)});try{let r=await Promise.race([e,i]);return clearTimeout(s),r}catch(r){throw zf().error(`[pickier:error] ${t} failed:`,r?.message||r),vt("withTimeout error:",t,r),r}}function qf(e){if(e.length===0)return"";let n=new Map;for(let s of e){let i=n.get(s.filePath)||[];i.push(s),n.set(s.filePath,i)}let t="";for(let[s,i]of n){t+=`
200
+ ${se.bold(`\x1B[4m${s}\x1B[24m`)}
201
+ `;let r;try{r=Uf(s,"utf8")}catch{for(let l of i){let a=l.severity==="error"?se.red("error"):se.yellow("warn ");t+=` ${l.line}:${l.column} ${a} ${l.message} ${se.blue(l.ruleId)}
202
+ `}continue}let o=r.split(/\r?\n/);for(let l of i){let a=l.severity==="error"?se.red("!"):se.yellow("!"),c=se.blue(l.ruleId);t+=`
203
+ ${a} ${c}: ${l.message}
204
+ `;let u=2,f=2,m=Math.max(1,l.line-u),h=Math.min(o.length,l.line+f),p=String(h).length;t+=` ${se.gray(" ,-")}${se.gray(`[:${l.line}:${l.column}]`)}
205
+ `;for(let g=m;g<=h;g++){let y=String(g).padStart(p),x=o[g-1]||"";if(g===l.line)t+=` ${se.gray(y)} ${se.gray("|")} ${se.red(",-> ")}${x}
206
+ `;else if(g===l.line+1&&f>0)t+=` ${se.gray(y)} ${se.gray("|")} ${se.red("| ")}${x}
207
+ `;else if(g===l.line+f&&f>1)t+=` ${se.gray(y)} ${se.gray("|")} ${se.red("`-> ")}${x}
208
+ `;else t+=` ${se.gray(y)} ${se.gray("| ")}${x}
209
+ `}if(t+=` ${se.gray(" `----")}
210
+ `,l.help)t+=` ${se.blue("help")}: ${l.help}
211
+ `}}return t}function Kf(e){if(e.length===0)return"";let n=new Map;for(let s of e){let i=n.get(s.filePath)||[];i.push(s),n.set(s.filePath,i)}let t="";for(let[s,i]of n){t+=`
212
+ ${se.bold(`\x1B[4m${s}\x1B[24m`)}
213
+ `;for(let r of i){let o=r.severity==="error"?se.red("error"):se.yellow("warn "),a=`${r.line}:${r.column}`.padStart(6),c=60,u=r.message.padEnd(60);t+=`${a} ${o} ${u} ${se.blue(r.ruleId)}
214
+ `}}return t}async function QC(e,n){vt("runFormat:start",{globs:e,options:n});let t=await jt(n.config),s=e.length?e:["."],i=Ut(s);vt("patterns",i);let r=new Set((n.ext||t.format.extensions.join(",")).split(",").map((g)=>{let y=g.trim();return y.startsWith(".")?y:`.${y}`})),o=Oe.TIMEOUT_MS,a=i.some((g)=>{let y=g.replace(/\/?\*\*(?:\/\*+)?$/,"");return!(ng(y)?y:sg(process.cwd(),y)).startsWith(process.cwd())})?tt(lt):tt(t.ignores),c=zt(a),u=[];if(i.length===1&&/\*\*\/\*$/.test(i[0])){let g=i[0].replace(/\/?\*\*\/\*$/,"");try{let{readdirSync:y,statSync:x}=await import("fs"),{join:k}=await import("path"),v=[g];while(v.length){let w=v.pop(),M=y(w);for(let L of M){let _=k(w,L),C=x(_);if(c(_))continue;if(C.isDirectory())v.push(_);else u.push(_)}}}catch{u=await jf(et(i,{dot:!1,ignore:a,onlyFiles:!0,absolute:!0}),o,"glob")}}else u=await jf(et(i,{dot:!1,ignore:a,onlyFiles:!0,absolute:!0}),o,"glob");vt("globbed entries",u.length);let m=u.filter((g)=>{if(c(g))return!1;let y=g.lastIndexOf(".");if(y<0)return!0;let x=g.slice(y);return r.has(x)});vt("filtered files",m.length);let h=0,d=[];for(let g of m){vt("format start",Bf(process.cwd(),g));let y=Uf(g,"utf8"),x=zs(y,t,g),k=x!==y;if(n.write){if(k)tg(g,x,"utf8")}if(k)d.push(Bf(process.cwd(),g));h++}let p=d.length;if(p>0){for(let g of d)console.log(se.gray(` ${g}`));console.log(n.write?se.gray(`Formatted ${p} of ${h} file(s).`):se.yellow(`${p} of ${h} file(s) need formatting. Run with --write to fix.`))}else if(n.verbose!==void 0?n.verbose:t.verbose)console.log(se.gray(`Checked ${h} files, all formatted.`));return n.check&&p>0?1:0}var pr=null;function ee(){if(!pr)pr=new it("pickier:lint",{showTags:!1});return pr}function ke(...e){if(Oe.TRACE)ee().error("[pickier:trace]",e)}async function cS(e,n,t="untitled",s){if(s?.aborted)throw Error("AbortError");let i=at(e),r=ct(e),o=Ct(t,e,n,i,r);if(s?.aborted)throw Error("AbortError");try{let l=await wr(t,e,n);for(let a of l){if(s?.aborted)throw Error("AbortError");if(Te(a.ruleId,a.line,i))continue;if(r.has(a.line)&&Vs(a.ruleId))continue;o.push({filePath:a.filePath,line:a.line,column:a.column,ruleId:a.ruleId,message:a.message,severity:a.severity,...a.help&&{help:a.help}})}}catch{}return o}async function uS(e,n,t){ke("runLintProgrammatic:start",{globs:e,options:n});let s=await jt(n.config);if(t?.aborted)throw Error("AbortError");let i=e.length?e:["."],r=Ut(i),o=n.ext||s.lint.extensions.join(","),l=new Set(o.split(",").map((T)=>{let E=T.trim();return E.startsWith(".")?E:`.${E}`})),a=Oe.TIMEOUT_MS,u=r.some((T)=>{let E=T.replace(/\/?\*\*\/*\*\*$/,""),S=It(E)?E:Mt(process.cwd(),E),O=process.cwd();return S!==O&&!S.startsWith(O+nm)})?tt(lt):tt(s.ignores),f=zt(u),m=[];if(r.length===1&&!/[*?[\]{}()!]/.test(r[0]))try{if(Ks(r[0]).isFile())m=[It(r[0])?r[0]:Mt(process.cwd(),r[0])]}catch{}let d=r.length===1&&/\*\*\/*\*$/.test(r[0]);if(!m.length&&d){let T=r[0].replace(/\/?\*\*\/*\*\*$/,""),E=It(T)?T:Mt(process.cwd(),T);try{let S=[E];while(S.length){if(t?.aborted)throw Error("AbortError");let O=S.pop(),A=Qf(O);for(let R of A){let I=tm(O,R),P=Ks(I);if(f(I))continue;if(P.isDirectory())S.push(I);else m.push(I)}}}catch{m=await Kt(et(r,{dot:!1,ignore:u,onlyFiles:!0,absolute:!0}),a,"glob")}}else if(!m.length)m=await Kt(et(r,{dot:!1,ignore:u,onlyFiles:!0,absolute:!0}),a,"glob");if(t?.aborted)throw Error("AbortError");let p=0,g=0,y=0,x=0,k=0,v=[];for(let T of m){if(p++,T.replace(/\\/g,"/").includes("/node_modules/")){y++;continue}if(f(T)){x++;continue}if(!br(T,l)){k++;continue}v.push(T),g++}ke("filter:programmatic",{total:p,included:g,node_modules:y,ignored:x,wrongExt:k});let w=Oe.CONCURRENCY,_=(await im(v,w,async(T)=>{if(t?.aborted)throw Error("AbortError");let E=em(T,"utf8"),S=at(E),O=ct(E),A=Ct(T,E,s,S,O);try{let R=await wr(T,E,s);for(let I of R){if(t?.aborted)throw Error("AbortError");if(Te(I.ruleId,I.line,S))continue;if(O.has(I.line)&&Vs(I.ruleId))continue;A.push({filePath:I.filePath,line:I.line,column:I.column,ruleId:I.ruleId,message:I.message,severity:I.severity,...I.help&&{help:I.help}})}}catch{}{let R=new Set;A=A.filter((I)=>{let P=`${I.line}:${I.column}:${I.ruleId}`;if(R.has(P))return!1;return R.add(P),!0})}if(n.fix){let R=om(T,E,s,S,O);if(R=rm(T,R,s),R!==E){let I=at(R),P=ct(R);if(A=Ct(T,R,s,I,P),!n.dryRun)gr(T,R,"utf8")}}return A})).flat(),C=_.filter((T)=>T.severity==="error").length,D=_.filter((T)=>T.severity==="warning").length;return{errors:C,warnings:D,issues:_}}function ig(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function rg(e){return e.replace(/-([a-z])/g,(n,t)=>t.toUpperCase())}function at(e){let n=new Map,t=new Set,s=new Map,i=new Map,r=e.split(/\r?\n/),o=new Set;for(let c=0;c<r.length;c++){let u=r[c].trim(),f=c+1,m=u.match(/^\/\/\s*(?:eslint|pickier)-disable-next-line(?:\s+(\S.*))?$/);if(m){let y=m[1]?.replace(/\s+--\s.*$/,""),x=y?y.split(",").map((k)=>k.trim()).filter(Boolean):["*"];if(x.length>0){let k=f+1,v=n.get(k)||new Set;for(let w of x)v.add(w);n.set(k,v)}continue}let h=u.match(/^\/\*\s*(?:eslint|pickier)-disable(?:\s+([^*]+))?\s*\*\//);if(h){let y=h[1]?.trim().replace(/\s+--\s.*$/,"");if(!y||y==="")s.set(f,new Set(["*"])),o.add("*");else{let x=y.split(",").map((v)=>v.trim()).filter(Boolean),k=s.get(f)||new Set;for(let v of x)k.add(v),o.add(v);s.set(f,k)}if(c===0)if(!y||y==="")t.add("*");else{let x=y.split(",").map((k)=>k.trim()).filter(Boolean);for(let k of x)t.add(k)}continue}let d=u.match(/^\/\*\s*(?:eslint|pickier)-enable(?:\s+([^*]+))?\s*\*\//);if(d){let y=d[1]?.trim();if(!y||y==="")i.set(f,new Set(["*"])),o.clear();else{let x=y.split(",").map((v)=>v.trim()).filter(Boolean),k=i.get(f)||new Set;for(let v of x)k.add(v),o.delete(v);i.set(f,k)}continue}let p=u.match(/^\/\/\s*(?:eslint|pickier)-disable(?:\s+(\S.*))?$/);if(p){let y=p[1]?.trim().replace(/\s+--\s.*$/,"");if(!y||y==="")s.set(f,new Set(["*"])),o.add("*");else{let x=y.split(",").map((v)=>v.trim()).filter(Boolean),k=s.get(f)||new Set;for(let v of x)k.add(v),o.add(v);s.set(f,k)}continue}let g=u.match(/^\/\/\s*(?:eslint|pickier)-enable(?:\s+(\S.*))?$/);if(g){let y=g[1]?.trim();if(!y||y==="")i.set(f,new Set(["*"])),o.clear();else{let x=y.split(",").map((v)=>v.trim()).filter(Boolean),k=i.get(f)||new Set;for(let v of x)k.add(v),o.delete(v);i.set(f,k)}}}let l=Array.from(s.keys()).sort((c,u)=>c-u),a=Array.from(i.keys()).sort((c,u)=>c-u);return{nextLine:n,fileLevel:t,rangeDisable:s,rangeEnable:i,sortedDisableLines:l,sortedEnableLines:a}}function Te(e,n,t){if(t instanceof Map){let l=t.get(n);if(!l||l.size===0)return!1;return qt(e,l)}if(t.fileLevel.size>0){if(qt(e,t.fileLevel))return!0}let s=t.nextLine.get(n);if(s&&qt(e,s))return!0;let i=!1,r=0,o=0;while(!0){let l=r<t.sortedDisableLines.length?t.sortedDisableLines[r]:Number.POSITIVE_INFINITY,a=o<t.sortedEnableLines.length?t.sortedEnableLines[o]:Number.POSITIVE_INFINITY,c=Math.min(l,a);if(c>=n)break;if(l===c){let f=t.rangeDisable.get(l);if(qt(e,f))i=!0;r++;continue}let u=t.rangeEnable.get(a);if(u.has("*")||qt(e,u))i=!1;o++}return i}function qt(e,n){if(n.size===0)return!1;if(n.has("*"))return!0;if(n.has(e))return!0;let t=ig(e);if(n.has(t)||n.has(rg(e)))return!0;for(let s of n)if(!s.includes("/")){if(e.endsWith(`/${s}`))return!0}return!1}function Vs(e){return e!=="spaced-comment"&&!e.endsWith("/spaced-comment")}function sm(e,n){if(e.help)return e;let t=n.includes("/")?n.split("/")[1]:n,s;if(t.startsWith("no-"))s=`Remove or refactor this ${t.replace("no-","").replace(/-/g," ")}. Check the rule documentation for more details or disable with: // eslint-disable-next-line ${n}`;else if(t.startsWith("prefer-"))s=`Consider using ${t.replace("prefer-","").replace(/-/g," ")} instead. This is a best practice recommendation. Disable with: // eslint-disable-next-line ${n} if needed`;else if(t.includes("sort")||t.includes("order"))s=`Reorder these items according to the rule requirements, or use --fix to auto-sort. Disable with: // eslint-disable-next-line ${n}`;else if(t.includes("indent")||t.includes("spacing")||t.includes("newline"))s=`Fix the formatting issue. Run with --fix to automatically format. Disable with: // eslint-disable-next-line ${n}`;else s=`Fix this issue or disable the rule with: // eslint-disable-next-line ${n}. Check the rule documentation for more details`;return{...e,help:s}}async function Kt(e,n,t){let s,i=new Promise((r,o)=>{s=setTimeout(()=>o(Error(`Timeout after ${n}ms at ${t}`)),n)});try{let r=await Promise.race([e,i]);return clearTimeout(s),r}catch(r){throw ee().error(`[pickier:error] ${t} failed:`,r?.message||r),ke("withTimeout error:",t,r),r}}async function im(e,n,t){let s=Array(e.length);if(e.length===0)return s;let i=0,r=Math.max(1,Math.min(Math.max(1,n),e.length));async function o(){while(i<e.length){let l=i++;s[l]=await t(e[l],l)}}return await Promise.all(Array.from({length:r},o)),s}var Vf=new WeakMap;function og(e){let n=mr();if(e.plugins&&e.plugins.length>0){let t=new Set(["pickier","style","regexp","ts"]),s=e.plugins.filter((r)=>typeof r!=="string");n=s.some((r)=>t.has(r.name))?n:[];for(let r of s)n.push(r)}return n}function lg(e,n){let t={...e.pluginRules||{},...e.rules||{}};if(e.rules?.noUnusedCapturingGroup)t["regexp/no-unused-capturing-group"]=e.rules.noUnusedCapturingGroup;let s={"antfu/curly":"style/curly","antfu/if-newline":"style/if-newline","antfu/no-top-level-await":"ts/no-top-level-await"};for(let[i,r]of Object.entries(s))if(t[i])t[r]=t[i];for(let i of[e.pluginRules,e.rules])for(let r of Object.keys(i||{})){if(r.includes("/"))continue;for(let o of n)if(o.rules&&Object.prototype.hasOwnProperty.call(o.rules,r))t[`${o.name}/${r}`]=i[r]}return t}function Hs(e){let n=Vf.get(e);if(n)return n;let t=og(e),s=lg(e,t),i=[],r=[],o=new Set(["no-debugger"]),l=new Set(["no-debugger"]),a=new Set;for(let u of t)for(let f in u.rules){let m=`${u.name}/${f}`,h=Xf(s,m);if(!h.enabled)continue;if(a.has(f))continue;a.add(f);let d=u.rules[f],p={pluginName:u.name,ruleName:f,fullRuleId:m,rule:d,severity:h.severity,options:h.options};if(typeof d?.check==="function")i.push(p);else if(h.severity==="error")i.push(p);if(typeof d?.fix==="function")r.push(p),o.add(m),l.add(f)}let c={checkRules:i,fixRules:r,fixableRuleIds:o,fixableBareRuleNames:l};return Vf.set(e,c),c}function ag(e,n){return/\.(?:sh|bash|zsh|ksh|dash)$/.test(e)||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(n)}function cg(e){return/(?:^|[/\\])(?:bun\.lock|bun\.lockb|package-lock\.json|pnpm-lock\.yaml|yarn\.lock|npm-shrinkwrap\.json)$/.test(e)}function xr(e,n,t){switch(e.pluginName){case"markdown":return n.endsWith(".md");case"shell":return ag(n,t);case"publint":return/(?:^|[/\\])package\.json$/.test(n);case"lockfile":return cg(n);case"node":case"ts":case"general":case"quality":case"eslint":case"regexp":case"unused-imports":case"perfectionist":return/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/.test(n);default:return!0}}async function wr(e,n,t){let s=[],i=Hs(t),r={filePath:e,config:t};for(let o of i.checkRules){if(!xr(o,e,n))continue;let{fullRuleId:l,rule:a,severity:c}=o;if(!a||typeof a.check!=="function"){if(c==="error")s.push({filePath:e,line:1,column:1,ruleId:`${l}-internal`,message:"Rule missing implementation (check function is undefined)",severity:"error"});continue}try{ke("rule:start",l);let u=Oe.RULE_TIMEOUT_MS,f={...r,options:o.options},m=performance.now(),h=await Kt(Promise.resolve().then(()=>a.check(n,f)),u,`rule:${l}`),d=performance.now()-m;if(d>u)s.push({filePath:e,line:1,column:1,ruleId:`${l}-internal`,message:`Rule exceeded timeout budget: ${Math.round(d)}ms > ${u}ms`,severity:"error"});ke("rule:end",l,Array.isArray(h)?h.length:0);for(let p of h){let g=sm(p,l);if(c)s.push({...g,severity:c});else s.push(g)}}catch(u){s.push({filePath:e,line:1,column:1,ruleId:`${l}-internal`,message:`Rule threw: ${u?.message||u}`,severity:"error"})}}return s}var ug=/\.(?:[cm]?[jt]sx?|vue|svelte|stx)$/i;function fg(e,n,t){if(!ug.test(t)||!e.includes("`"))return n;let s=e.split(/\r?\n/),i=n.split(/\r?\n/);if(s.length!==i.length)return n;let r=Xe(e),o=0;for(let l=0;l<i.length;l++)if(r[l]&&i[l]!==s[l])i[l]=s[l],o++;return o>0?i.join(`
215
+ `):n}function rm(e,n,t){let s=Hs(t),i={filePath:e,config:t},r=n,o=!0,l=0;while(o&&l++<dr){o=!1;for(let a of s.fixRules){if(!xr(a,e,r))continue;let c={...i,options:a.options},u=a.rule.fix(r,c),f=a.rule.meta?.editsStringContent?u:fg(r,u,e);if(f!==r)r=f,o=!0}}return r}function om(e,n,t,s,i){if(!nt(t,"no-debugger",["noDebugger"])||!n.includes("debugger"))return n;let o=e.split(".").pop()?.toLowerCase()??"",l=o==="sh"||o==="bash"||o==="zsh"||o==="ksh"||o==="dash"||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(n);if(o==="md"||o==="yaml"||o==="yml"||o==="json"||o==="jsonc"||l)return n;let a=/^\s*debugger\b/,c=Rr(n),u=n.split(/\r?\n/),f=[],m=!1;for(let h=0;h<u.length;h++){let d=u[h],p=h+1;if(a.test(d)&&!i.has(p)&&!c.has(p)&&!Te("no-debugger",p,s)){m=!0;continue}f.push(d)}return m?f.join(`
216
+ `):n}function lm(e,n,t){let s=nt(t,"indent",["style/indent"],"warn");if(!s)return;let i=e.split(".").pop()?.toLowerCase()??"";if(i==="md")return;if(i==="stx"||i==="html"||i==="htm"||i==="vue")return;if(i==="yaml"||i==="yml")return;if(i==="sh"||i==="bash"||i==="zsh"||i==="ksh"||i==="dash"||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(n))return;return s}function mg(e,n,t,s){let i=n.format.indent,r=n.format.indentStyle,o=Rr(e),l=e.split(/\r?\n/),a=!1;for(let c=0;c<l.length;c++){let u=l[c],f=c+1;if(s.has(f)||o.has(f)||Te("indent",f,t))continue;let m=0;while(m<u.length&&(u.charCodeAt(m)===32||u.charCodeAt(m)===9))m++;if(m===0)continue;let h=u.slice(0,m);if(!yr(h,i,r,u))continue;let d;if(r==="tabs"){let p=0,g=0;for(let x=0;x<h.length;x++)if(h.charCodeAt(x)===9)g++;else p++;let y=Math.floor(p/i);d="\t".repeat(g+y)}else{let p=0;for(let y=0;y<h.length;y++)if(h.charCodeAt(y)===9)p+=i;else p++;let g=Math.floor(p/i)*i;d=" ".repeat(g)}if(d!==h)l[c]=d+u.slice(m),a=!0}return a?l.join(`
217
+ `):e}function Rr(e){let n=new Set;if(!e.includes("`"))return n;let t=[],s="code",i=1,r="",o=0,l=()=>t[t.length-1]==="template";for(let a=0;a<e.length;a++){let c=e[a],u=e[a+1];if(c===`
218
+ `){if(s==="line-comment")s="code";i++,o=a+1,r="";continue}if(l()&&s==="code")n.add(i);switch(s){case"single":case"double":if(c==="\\")a++;else if(s==="single"&&c==="'"||s==="double"&&c==='"')s="code";continue;case"line-comment":continue;case"block-comment":if(c==="*"&&u==="/")a++,s="code";continue;case"regex":if(c==="\\")a++;else if(c==="[")s="regex-class";else if(c==="/")s="code";continue;case"regex-class":if(c==="\\")a++;else if(c==="]")s="regex";continue}if(l()){if(c==="\\"){a++;continue}if(c==="`"){t.pop();continue}if(c==="$"&&u==="{"){t.push("interpolation"),a++;continue}continue}if(c==="`"){t.push("template"),n.add(i);continue}if(c==="'"){s="single";continue}if(c==='"'){s="double";continue}if(c==="/"&&u==="/"){s="line-comment",a++;continue}if(c==="/"&&u==="*"){s="block-comment",a++;continue}if(c==="/"&&kr(r,e.slice(o,a+1),a-o)){s="regex";continue}if(c==="}"&&t[t.length-1]==="interpolation"){t.pop();continue}if(!/\s/.test(c))r=c}return n}function Hf(e,n){let t=e.match(n);if(!t||t.index===void 0)return null;let s=t.index+t[0].length-1,i=0;for(let r=s;r<e.length;r++)if(e[r]==="(")i++;else if(e[r]===")"){if(i--,i===0)return e.slice(s+1,r)}return null}function Zf(e){let n="",t=0;for(let s of e){if(s==="("){t++;continue}if(s===")"){t=Math.max(0,t-1);continue}if(t===0)n+=s}return n}function Gf(e){let n="",t=0;while(t<e.length){if(e[t]==="/"){if(e[t+1]==="/"||e[t+1]==="*")return n+e.slice(t);let s=e.slice(0,t).trimEnd();if(kr(s[s.length-1]??"",e,t)){t++;let i=!1;while(t<e.length){if(e[t]==="\\"){t+=2;continue}if(e[t]==="[")i=!0;else if(e[t]==="]")i=!1;else if(e[t]==="/"&&!i){t++;while(t<e.length&&/[gimsuvy]/.test(e[t]))t++;break}t++}continue}}n+=e[t],t++}return n}function kr(e,n,t){if(e==="")return!0;if("([{,:;!?&|=<>~^+*%-".includes(e))return!0;if(/[A-Za-z_$]/.test(e)){let i=n.slice(0,t).trimEnd();if(/(?:^|[^A-Za-z0-9_$])(?:return|typeof|instanceof|new|delete|void|in|of|yield|await|throw|case)$/.test(i))return!0}return!1}function Jf(e){let n="",t=0,s=null,i=!1;while(t<e.length){let r=e[t],o=e[t+1];if(i){n+=r,i=!1,t++;continue}if(r==="\\"&&s){i=!0,n+=r,t++;continue}if(!s){if(r==='"'){s="double",n+=r,t++;continue}if(r==="'"){s="single",n+=r,t++;continue}if(r==="`"){s="template",n+=r,t++;continue}if(r==="/"&&o==="/")break;if(r==="/"&&o==="*"){t+=2;while(t<e.length){if(e[t]==="*"&&e[t+1]==="/"){t+=2;break}t++}n+=" ";continue}n+=r,t++}else{if(s==="double"&&r==='"'||s==="single"&&r==="'"||s==="template"&&r==="`")s=null;n+=r,t++}}return n}function ct(e){let n=new Set,t="code",s=1,i=!1,r=!1,o=!1,l=[];for(let a=0;a<e.length;a++){let c=e[a],u=e[a+1],f=a>0?e[a-1]:"";if(c===`
219
+ `){if(o&&t==="block-comment")n.add(s);else if(!i&&r&&t!=="block-comment")n.add(s);else if(!i&&t==="block-comment")n.add(s);if(s++,i=!1,r=!1,o=t==="block-comment",t==="line-comment")t="code";continue}switch(t){case"code":if(c==="/"&&u==="/")t="line-comment",r=!0,a++;else if(c==="/"&&u==="*"){let m=!1;if(a>0){let h=a-1;while(h>0&&(e[h]===" "||e[h]==="\t"))h--;let d=e[h];if("=([{,;!&|?:~^%+-".includes(d)&&d!==`
220
+ `)m=!0;else if(/[a-z]/.test(d)){let p=e.slice(Math.max(0,h-6),h+1);if(/\b(?:return|case|typeof|void|in|of|new|throw|delete)$/.test(p))m=!0}}if(m){i=!0,a++;while(a<e.length){if(e[a]==="\\"){a+=2;continue}if(e[a]==="/"){a++;break}if(e[a]===`
221
+ `)break;a++}while(a<e.length&&/[gimsuy]/.test(e[a]))a++;a--}else r=!0,t="block-comment",a++}else if(c==="/"&&u!==void 0){let m=!1;if(a>0){let h=a-1;while(h>0&&(e[h]===" "||e[h]==="\t"))h--;let d=e[h];if("=([{,;!&|?:~^%+-".includes(d)||d===`
222
+ `)m=!0;else if(/[a-z]/.test(d)){let p=e.slice(Math.max(0,h-6),h+1);if(/\b(?:return|case|typeof|void|in|of|new|throw|delete)$/.test(p))m=!0}}if(m){i=!0,a++;while(a<e.length){if(e[a]==="\\"){a+=2;continue}if(e[a]==="/"){a++;break}if(e[a]===`
223
+ `)break;a++}while(a<e.length&&/[gimsuy]/.test(e[a]))a++;a--}else i=!0}else if(c==="'")t="string-single",i=!0;else if(c==='"')t="string-double",i=!0;else if(c==="`")t="string-template",i=!0;else if(c==="{"){if(l.length)l[l.length-1]++;i=!0}else if(c==="}"){if(l.length)if(l[l.length-1]===0)l.pop(),t="string-template";else l[l.length-1]--;i=!0}else if(!/\s/.test(c))i=!0;break;case"string-single":if(c==="\\"){a++;break}if(c==="'")t="code";break;case"string-double":if(c==="\\"){a++;break}if(c==='"')t="code";break;case"string-template":if(c==="\\"){a++;break}if(c==="$"&&u==="{"){l.push(0),t="code",a++;break}if(c==="`")t="code";break;case"line-comment":break;case"block-comment":if(c==="*"&&u==="/")t="code",a++;break}}if(o&&t==="block-comment")n.add(s);else if(!i&&r&&t!=="block-comment")n.add(s);else if(!i&&t==="block-comment")n.add(s);return n}function Ct(e,n,t,s,i){let r=[],o=n.split(/\r?\n/),l=t.format.quotes,a=e.split(".").pop()?.toLowerCase()??"",c=a==="md",u=a==="sh"||a==="bash"||a==="zsh"||a==="ksh"||a==="dash"||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(n),f=nt(t,"quotes",["style/quotes"],"warn"),m=!f||a==="json"||a==="jsonc"||a==="lock"||c||a==="yaml"||a==="yml"||a==="stx"||a==="html"||a==="htm"||a==="vue"||u||e.endsWith("bun.lock"),h=c||a==="yaml"||a==="yml"||a==="json"||a==="jsonc"||u,d=lm(e,n,t),p=!1,g=nt(t,"no-debugger",["noDebugger"]),y=nt(t,"no-console",["noConsole"]),x=nt(t,"no-template-curly-in-string",["noTemplateCurlyInString"]),k=nt(t,"no-cond-assign",["noCondAssign"]),v=/\bconsole\.log\s*\(/,w=/^\s*debugger\b/,M=new Set;if(a==="md"){let _=!1;for(let C=0;C<o.length;C++){if(/^(?:`{3,}|~{3,})/.test(o[C].trim())){_=!_;continue}if(_)M.add(C+1)}}let L=Rr(n);for(let _=0;_<o.length;_++){let C=o[_],D=_+1;if(i.has(D))continue;if(!m&&!L.has(D)){let S=Jf(Gf(C)),O=Yf(S,l);if(O.length>0&&!p){if(!Te("quotes",D,s))r.push({filePath:e,line:D,column:(O[0]||0)+1,ruleId:"quotes",message:"Inconsistent quote style",severity:f,help:`Use ${l} quotes consistently throughout your code. You can change the preferred quote style in your config with format.quotes: '${l==="single"?"double":"single"}'`});p=!0}}let T=0;while(T<C.length&&(C.charCodeAt(T)===32||C.charCodeAt(T)===9))T++;let E=T>0?C.slice(0,T):"";if(d&&E.length>0&&!M.has(D)&&!L.has(D)&&yr(E,t.format.indent,t.format.indentStyle,C)){if(!Te("indent",D,s))r.push({filePath:e,line:D,column:1,ruleId:"indent",message:"Incorrect indentation detected",severity:d,help:`Use ${t.format.indentStyle==="spaces"?`${t.format.indent} spaces`:"tabs"} for indentation. Configure with format.indent and format.indentStyle in your config`})}if(!h&&g&&!L.has(D)&&w.test(C)){if(!Te("no-debugger",D,s))r.push({filePath:e,line:D,column:1,ruleId:"no-debugger",message:"Unexpected debugger statement",severity:g,help:"Remove debugger statements before committing code. Use breakpoints in your IDE instead, or run with --fix to auto-remove"})}if(!h&&y&&!L.has(D)&&v.test(C)){let S=C.indexOf("//"),O=C.indexOf("console.");if(S!==-1&&O>S);else{let A=null;for(let R=0;R<C.length;R++){let I=C[R];if(!A){if(I==='"')A="double";else if(I==="'")A="single";else if(I==="`")A="template";else if(C.slice(R).startsWith("console.")){let P=R+1;if(!Te("no-console",D,s))r.push({filePath:e,line:D,column:P,ruleId:"no-console",message:"Unexpected console call",severity:y,help:"Remove console statements before committing. Use a proper logging library or disable this rule if console output is intentional"});break}}else if(A==="double"&&I==='"'||A==="single"&&I==="'"||A==="template"&&I==="`"){let P=0;for(let F=R-1;F>=0&&C[F]==="\\";F--)P++;if(P%2===0)A=null}}}}if(x&&!L.has(D)){let S=C,O=null,A=!1,R=!1,I="",P="";for(let F=0;F<S.length;F++){let N=S[F];if(A){if(P==="\\"){P=N;continue}if(R){if(N==="]")R=!1}else if(N==="[")R=!0;else if(N==="/"){A=!1;while(F+1<S.length&&/[a-z]/i.test(S[F+1]))F++;I="/"}P=N;continue}if(!O){if(N==='"'){O="double",P=N;continue}if(N==="'"){O="single",P=N;continue}if(N==="`"){O="template",P=N;continue}if(N==="/"&&S[F+1]!=="/"&&S[F+1]!=="*"&&kr(I,S,F)){A=!0,R=!1,P=N;continue}if(N!==" "&&N!=="\t")I=N}else if(O==="double"&&N==='"'||O==="single"&&N==="'"||O==="template"&&N==="`"){if(P!=="\\")O=null}else if(N==="$"&&S[F+1]==="{"&&P!=="\\"&&O!=="template"){if(!Te("no-template-curly-in-string",D,s))r.push({filePath:e,line:D,column:F+1,ruleId:"no-template-curly-in-string",message:"Unexpected template string expression in normal string",severity:x,help:"Change the string quotes from ' or \" to backticks (`) to use template literal interpolation, or escape the $ if you meant to use it literally"});break}P=N}}if(!h&&k&&!L.has(D)){let O=Jf(Gf(C)).replace(/'[^']*'|"[^"]*"/g,'""'),A=(F)=>/[^=!<>]=(?![=>])/.test(F),R=(F)=>{let N=C.match(F);if(N&&N.index!==void 0)return N.index+N[0].length;return Math.max(1,C.indexOf("(")+1)},I=Hf(O,/\b(?:if|while)\s*\(/);if(I){let F=Zf(I);if(A(F)){if(!Te("no-cond-assign",D,s))r.push({filePath:e,line:D,column:R(/\b(?:if|while)\s*\(/),ruleId:"no-cond-assign",message:"Unexpected assignment within a conditional expression",severity:k,help:"Use === or == for comparison instead of = (assignment). Wrap intentional assignments in extra parentheses."})}}let P=Hf(O,/\bfor\s*\(/);if(P){let F=P.split(";");if(F.length>=2){let N=Zf(F[1]);if(A(N)){if(!Te("no-cond-assign",D,s))r.push({filePath:e,line:D,column:R(/\bfor\s*\(/),ruleId:"no-cond-assign",message:"Unexpected assignment within a conditional expression",severity:k,help:"Use === or == for comparison instead of = (assignment). Wrap intentional assignments in extra parentheses."})}}}}}return r}function fS(e,n,t){let s=at(n),i=ct(n),r=Ct(e,n,t,s,i);try{let o=Hs(t),l={filePath:e,config:t};for(let a of o.checkRules){if(!xr(a,e,n))continue;if(!a.rule||typeof a.rule.check!=="function")continue;let c=a.rule.check(n,{...l,options:a.options});for(let u of c){if(Te(u.ruleId,u.line,s))continue;if(i.has(u.line)&&Vs(u.ruleId))continue;let f=sm(u,a.fullRuleId);r.push(a.severity?{...f,severity:a.severity}:f)}}}catch{}return r}async function mS(e,n){ke("runLint:start",{globs:e,options:n});let t=Oe.DIAGNOSTICS;if(t)ee().info("[pickier:diagnostics] Starting lint process...");try{if(t)ee().info("[pickier:diagnostics] Loading config...");let s=await jt(n.config);ke("config:loaded",{reporter:s.lint.reporter,ext:s.lint.extensions.join(",")});let i=e.length?e:["."],r=Ut(i);if(ke("patterns",r),t)ee().info(`[pickier:diagnostics] Patterns to search: ${r.join(", ")}`);let o=n.ext||s.lint.extensions.join(","),l=new Set(o.split(",").map((I)=>{let P=I.trim();return P.startsWith(".")?P:`.${P}`}));if(t)ee().info(`[pickier:diagnostics] File extensions: ${Array.from(l).join(", ")}`);let a=Oe.TIMEOUT_MS;if(t)ee().info(`[pickier:diagnostics] Glob timeout: ${a}ms`);let c=r.some((I)=>{let P=I.replace(/\/?\*\*\/*\*\*$/,""),F=It(P)?P:Mt(process.cwd(),P),N=process.cwd();return F!==N&&!F.startsWith(N+nm)}),u=c?tt(lt):tt(s.ignores),f=zt(u);if(t){if(ee().info(`[pickier:diagnostics] Globbing outside project: ${c}, ignore patterns: ${u.length}`),c)ee().info(`[pickier:diagnostics] Using universal ignores: ${lt.slice(0,5).join(", ")}... (${lt.length} total)`)}let m=[],h=r.length===1&&!/[*?[\]{}()!]/.test(r[0]);if(t)ee().info(`[pickier:diagnostics] Starting file discovery... (nonGlobSingle: ${h})`);if(h)try{if(Ks(r[0]).isFile())m=[It(r[0])?r[0]:Mt(process.cwd(),r[0])]}catch{}let d=r.length===1&&/\*\*\/*\*$/.test(r[0]);if(!m.length&&d){let I=r[0].replace(/\/?\*\*\/*\*\*$/,"");if(t)ee().info(`[pickier:diagnostics] Using fast directory scan for: ${I}`);try{let F=[It(I)?I:Mt(process.cwd(),I)],N=0;while(F.length){let J=F.pop();if(N++,t&&N%100===0)ee().info(`[pickier:diagnostics] Scanned ${N} directories, ${m.length} files found so far...`);let V=Qf(J);for(let j of V){let B=tm(J,j),Y=Ks(B);if(f(B))continue;if(Y.isDirectory())F.push(B);else m.push(B)}}if(t)ee().info(`[pickier:diagnostics] Fast scan complete: ${N} directories, ${m.length} total files`)}catch(P){if(t)ee().info(`[pickier:diagnostics] Fast scan failed: ${P?.message}, falling back to glob`);m=await Kt(et(r,{dot:!1,ignore:u,onlyFiles:!0,absolute:!0}),a,"glob")}}else if(!m.length){if(t)ee().info(`[pickier:diagnostics] Using glob with timeout ${a}ms...`);if(m=await Kt(et(r,{dot:!1,ignore:u,onlyFiles:!0,absolute:!0}),a,"glob"),t)ee().info(`[pickier:diagnostics] glob found ${m.length} files`)}if(ke("globbed entries",m.length),t)ee().info(`[pickier:diagnostics] File discovery complete: ${m.length} files found`);if(m.length>1e4){if(ee().warn(`[pickier:warn] Found ${m.length} files. This seems unusually high and may cause memory issues.`),ee().warn("[pickier:warn] Consider checking your ignore patterns or being more specific with your glob pattern."),ee().warn("[pickier:warn] Common culprits: node_modules, build directories, cache folders, or vendor dependencies."),m.length>1e5)return ee().error(`[pickier:error] File count exceeds 100,000 (${m.length}). This will likely cause out-of-memory errors.`),ee().error("[pickier:error] Aborting to prevent crash. Please refine your glob pattern or ignore patterns."),1}if(t)ee().info(`[pickier:diagnostics] Filtering ${m.length} files by extension and ignore patterns...`);let p=0,g=0,y=0,x=0,k=0,v=[];for(let I of m){if(p++,t&&p%1000===0)ee().info(`[pickier:diagnostics] Filtering progress: ${p}/${m.length} files checked, ${g} included...`);if(I.replace(/\\/g,"/").includes("/node_modules/")){y++;continue}if(f(I)){x++;continue}if(!br(I,l)){k++;continue}v.push(I),g++}if(ke("filter:cli",{total:p,included:g,node_modules:y,ignored:x,wrongExt:k}),ke("filtered files",v.length),t)ee().info("[pickier:diagnostics] Filtering complete:"),ee().info(`[pickier:diagnostics] Total files found: ${p}`),ee().info(`[pickier:diagnostics] Files to lint: ${g}`),ee().info(`[pickier:diagnostics] Excluded (node_modules): ${y}`),ee().info(`[pickier:diagnostics] Excluded (ignored): ${x}`),ee().info(`[pickier:diagnostics] Excluded (wrong extension): ${k}`);if(v.length>5000){if(ee().warn(`[pickier:warn] After filtering, ${v.length} files will be linted. This may take a while and use significant memory.`),v.length>50000)return ee().error(`[pickier:error] ${v.length} files to lint exceeds safe limit (50,000). This will likely cause out-of-memory errors.`),ee().error("[pickier:error] Aborting to prevent crash. Please be more specific with your glob pattern."),ee().error("[pickier:error] Example: Instead of '../stx', try '../stx/src' or '../stx/packages/core'"),1}let w=Oe.CONCURRENCY;if(t)ee().info(`[pickier:diagnostics] Starting to process ${v.length} files with concurrency ${w}...`);let M=0,L=!!n._formatOnly,D=(await im(v,w,async(I)=>{if(t){if(M++,M===1||M%10===0||M===v.length)ee().info(`[pickier:diagnostics] Processing file ${M}/${v.length}: ${qs(process.cwd(),I)}`)}let P=em(I,"utf8");if(L){let j=zs(P,s,I);if(j!==P)if(!n.dryRun)gr(I,j,"utf8");else return[{filePath:I,line:1,column:1,ruleId:"format",message:"File is not formatted",severity:"error",help:"Run pickier format with --write to apply formatting."}];return[]}let F=at(P),J=/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/.test(I)?ct(P):new Set,V=Ct(I,P,s,F,J);try{let j=await wr(I,P,s);for(let B of j){if(Te(B.ruleId,B.line,F))continue;if(J.has(B.line)&&Vs(B.ruleId))continue;V.push({filePath:B.filePath,line:B.line,column:B.column,ruleId:B.ruleId,message:B.message,severity:B.severity,...B.help&&{help:B.help}})}}catch{}{let j=new Set;V=V.filter((B)=>{let Y=`${B.line}:${B.column}:${B.ruleId}`;if(j.has(Y))return!1;return j.add(Y),!0})}if(n.fix){let j=om(I,P,s,F,J);if(j=rm(I,j,s),lm(I,j,s))j=mg(j,s,at(j),ct(j));if(j!==P){let B=at(j),Y=ct(j);if(V=Ct(I,j,s,B,Y),!n.dryRun)gr(I,j,"utf8");if(n.dryRun&&(n.verbose!==void 0?n.verbose:s.verbose))ee().debug(se.gray(`dry-run: would apply fixes in ${qs(process.cwd(),I)}`))}}return ke("scan done",qs(process.cwd(),I),V.length),V})).flat();if(t)ee().info(`[pickier:diagnostics] Processing complete! Found ${D.length} issues total`);let T=D.filter((I)=>I.severity==="error").length,E=D.filter((I)=>I.severity==="warning").length;if(ke("issues:summary",{errors:T,warnings:E}),t)ee().info(`[pickier:diagnostics] Errors: ${T}, Warnings: ${E}`);let S=n.reporter||s.lint.reporter,O=n.verbose!==void 0?n.verbose:s.verbose;if(S==="json")console.log(JSON.stringify({errors:T,warnings:E,issues:D},null,2));else if(S==="compact")for(let I of D)console.log(`${qs(process.cwd(),I.filePath)}:${I.line}:${I.column} ${I.severity} ${I.ruleId} ${I.message}`);else if(D.length>0)console.log(O?qf(D):Kf(D));if(D.length>0&&S!=="json"){let I=T+E,P=I===1?"problem":"problems",F=T===1?"error":"errors",N=E===1?"warning":"warnings",J=Hs(s),V=0,j=0;for(let B of D){let Y=B.ruleId;if(J.fixableRuleIds.has(Y)||J.fixableBareRuleNames.has(Y)){if(B.severity==="error")V++;else if(B.severity==="warning")j++}}if(console.log(),console.log(se.red(`\u2716 ${I} ${P} (${T} ${F}, ${E} ${N})`)),V>0||j>0){let B=V===1?"error":"errors",Y=j===1?"warning":"warnings";console.log(se.gray(` ${V} ${B} and ${j} ${Y} potentially fixable with the \`--fix\` option.`))}}if(O&&S!=="json")console.log(se.gray(`Scanned ${v.length} files, found ${T} errors and ${E} warnings.`));let A=n.maxWarnings??s.lint.maxWarnings,R=Oe.FAIL_ON_WARNINGS;if(T>0)return ke("runLint:end",1),1;if(R&&E>0)return ke("runLint:end",1),1;if(A>=0&&E>A)return ke("runLint:end",1),1;return ke("runLint:end",0),0}catch(s){return ee().error("[pickier:error] runLint failed:",s?.message||s),ke("runLint:exception",s),1}}
224
+ export{QC as a,cS as b,uS as c,wr as d,Ct as e,fS as f,mS as g};