pickier 0.1.63 → 0.1.65

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.
@@ -1,22 +1,22 @@
1
1
  // @bun
2
- import{F as se,H as Ut,I as zt,J as xr,K as nt,L as qt,i as Fe,j as Ee,k as qs,l as Xf,m as br,n as Oi,o as pr,p as tt,r as _e,t as at,u as Qf,w as st}from"./chunk-b369mtka.js";import{Q as Ne}from"./chunk-awmb5sg5.js";import{readdirSync as em,readFileSync as tm,statSync as Vs,writeFileSync as yr}from"fs";import{isAbsolute as Mt,join as nm,relative as Ks,resolve as Ct,sep as sm}from"path";import{existsSync as Pr,statSync as vr}from"fs";import{existsSync as hi,mkdirSync as dm,readdirSync as pm,writeFileSync as gm}from"fs";import{homedir as ft}from"os";import{dirname as Ir,resolve as Se}from"path";import it from"process";import{join as ym,relative as bm,resolve as Mr}from"path";import un from"process";import{existsSync as co,mkdirSync as kg,readdirSync as $g,writeFileSync as Pg}from"fs";import{homedir as Gs}from"os";import{dirname as Mg,resolve as Ce}from"path";import Tt from"process";import{join as xm,relative as wm,resolve as Cr}from"path";import fn from"process";import{existsSync as uo,mkdirSync as Tg,readdirSync as Ag,writeFileSync as Og}from"fs";import{dirname as Dg,resolve as mn}from"path";import di from"process";import{Buffer as Je}from"buffer";import{createCipheriv as Rm,createDecipheriv as km,randomBytes as Js}from"crypto";import{closeSync as Ys,createReadStream as Sr,createWriteStream as $m,existsSync as Xs,fsyncSync as Er,openSync as Lr,writeFileSync as Pm}from"fs";import{access as vm,constants as Tr,mkdir as Im,readdir as Ht,rename as Ar,stat as mt,unlink as Zt,writeFile as Qs}from"fs/promises";import{join as ht}from"path";import Pe from"process";import{pipeline as Mm}from"stream/promises";import{createGzip as Or}from"zlib";import dt from"process";import Ke from"process";import{Buffer as ze}from"buffer";import{createCipheriv as Cm,createDecipheriv as Sm,randomBytes as ei}from"crypto";import{closeSync as ti,createReadStream as _r,createWriteStream as Em,existsSync as Gt,fsyncSync as Dr,openSync as Fr,writeFileSync as Lm}from"fs";import{access as Tm,constants as Nr,mkdir as Am,readdir as Jt,rename as Wr,stat as pt,unlink as Yt,writeFile as ni}from"fs/promises";import{isAbsolute as Om,join as gt,resolve as _m}from"path";import ie from"process";import{pipeline as Dm}from"stream/promises";import{createGzip as Br}from"zlib";import yt from"process";import Ve from"process";import Xt from"process";import{existsSync as Qt}from"fs";import{resolve as si}from"path";import{existsSync as Fm}from"fs";import{existsSync as Nm,readdirSync as Wm}from"fs";import{extname as ii,resolve as jr}from"path";import Bm from"process";import{join as jh,relative as Uh,resolve as Qr}from"path";import xn from"process";import{Buffer as qe}from"buffer";import{createCipheriv as Kh,createDecipheriv as Vh,randomBytes as ci}from"crypto";import{closeSync as ui,createReadStream as eo,createWriteStream as Hh,existsSync as tn,fsyncSync as to,openSync as no,writeFileSync as Zh}from"fs";import{access as Gh,constants as so,mkdir as Jh,readdir as nn,rename as io,stat as bt,unlink as sn,writeFile as fi}from"fs/promises";import{isAbsolute as Yh,join as xt,resolve as Xh}from"path";import re from"process";import{pipeline as Qh}from"stream/promises";import{createGzip as ro}from"zlib";import wt from"process";import He from"process";var cm=Object.defineProperty;var um=(e)=>e;function fm(e,n){this[e]=um.bind(null,n)}var mm=(e,n)=>{for(var t in n)cm(e,t,{get:n[t],enumerable:!0,configurable:!0,set:fm.bind(n,t)})},hm=(e,n)=>()=>(e&&(n=e(e=0)),n);var ao={};mm(ao,{withErrorRecovery:()=>ho,tryLoadConfig:()=>ch,loadConfigWithResult:()=>lh,loadConfig:()=>xo,isRetryableError:()=>th,isConfigNotFoundError:()=>eh,isBunfigError:()=>po,globalPerformanceMonitor:()=>_t,globalCache:()=>Rt,getEnvOrDefault:()=>nh,generateConfigTypes:()=>uh,defaultGeneratedDir:()=>Mo,defaultConfigDir:()=>Io,deepMergeWithArrayStrategy:()=>Ci,deepMerge:()=>go,createLibraryConfig:()=>fh,config:()=>ah,bunfigPlugin:()=>mh,applyEnvVarsToConfig:()=>Lt,TypeGenerationError:()=>Ri,SchemaValidationError:()=>Ot,PluginError:()=>$i,PerformanceMonitor:()=>vi,FileSystemError:()=>wi,ErrorFactory:()=>Ye,EnvVarError:()=>bn,EnvProcessor:()=>Rn,ConfigValidator:()=>Si,ConfigValidationError:()=>bi,ConfigNotFoundError:()=>yn,ConfigMergeError:()=>xi,ConfigLoader:()=>Ei,ConfigLoadError:()=>At,ConfigFileLoader:()=>kn,ConfigCache:()=>Pi,CacheUtils:()=>Ro,BunfigError:()=>Le,BrowserConfigError:()=>ki,ArrayMergeStrategies:()=>Po});class Pi{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(!Pr(e))return!0;return vr(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=Pr(t)?vr(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 vi{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 jm(e,n={}){let s=Object.keys(n).sort().map((i)=>`${i}:${n[i]}`).join("|");return s?`${e}:${s}`:e}function Um(e,n){try{return JSON.stringify(e)===JSON.stringify(n)}catch{return e===n}}function zm(e){return e.getStats().size*2}function Ii(e,n){if(Array.isArray(n)&&Array.isArray(e)&&n.length===2&&e.length===2&&fe(n[0])&&"id"in n[0]&&n[0].id===3&&fe(n[1])&&"id"in n[1]&&n[1].id===4)return n;if(fe(n)&&fe(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(fe(e)&&"arr"in e&&Array.isArray(e.arr)&&fe(n)&&"arr"in n&&Array.isArray(n.arr))return n;if(n.length>0&&e.length>0&&fe(n[0])&&fe(e[0])){let s=[...n];for(let i of e)if(fe(i)&&"name"in i){if(!s.find((o)=>fe(o)&&("name"in o)&&o.name===i.name))s.push(i)}else if(fe(i)&&"path"in i){if(!s.find((o)=>fe(o)&&("path"in o)&&o.path===i.path))s.push(i)}else if(!s.some((r)=>hn(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(!fe(n)||!fe(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(fe(i)&&fe(t[s]))t[s]=Ii(t[s],i);else if(Array.isArray(i)&&Array.isArray(t[s]))if(i.length>0&&t[s].length>0&&fe(i[0])&&fe(t[s][0])){let r=[...i];for(let o of t[s])if(fe(o)&&"name"in o){if(!r.find((a)=>fe(a)&&("name"in a)&&a.name===o.name))r.push(o)}else if(fe(o)&&"path"in o){if(!r.find((a)=>fe(a)&&("path"in a)&&a.path===o.path))r.push(o)}else if(!r.some((l)=>hn(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 hn(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(!hn(e[t],n[t]))return!1;return!0}if(fe(e)&&fe(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(!hn(e[i],n[i]))return!1}return!0}return!1}function fe(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function qm(e,n){if(!uo(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 Ii(n,s)}catch{return null}}catch{return null}}async function Km({name:e="",cwd:n,defaultConfig:t}){let s=n||di.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=mn(s,`${o}${l}`),c=await qm(a,t);if(c!==null)return c}try{let o=mn(s,"package.json");if(uo(o)){let a=(await import(o))[e];if(a&&typeof a==="object"&&!Array.isArray(a))try{return Ii(t,a)}catch{}}}catch{}return t}function Vm(e,n={}){let t=fn.cwd();while(t.includes("storage"))t=Cr(t,"..");let s=Cr(t,e||"");if(n?.relative)return wm(fn.cwd(),s);return s}async function Hm(){try{let e=await Km({name:"clarity",defaultConfig:on,cwd:fn.cwd(),endpoint:"",headers:{}});return{...on,...e}}catch{return on}}function he(){if(Ke.env.NODE_ENV==="test"||Ke.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Zm(){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 Zm(),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:dt.pid,hostname:n(),environment:dt.env.NODE_ENV||"development",platform:dt.platform,version:dt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:dt.env.NODE_ENV||dt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class dn{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={...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??Pe.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{...ln,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...ln};return{...ln,...e.fingersCrossed}}normalizeOptions(e){let n={format:"json",level:"info",logDirectory:gi.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 vm(this.config.logDirectory,Tr.F_OK|Tr.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await Im(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:Je.from(e);try{if(!Xs(this.currentLogFile))await Qs(this.currentLogFile,"",{mode:420});if(i=Lr(this.currentLogFile,"a",420),Pm(i,a,{flag:"a"}),Er(i),i!==void 0)Ys(i),i=void 0;if((await mt(this.currentLogFile)).size===0){if(await Qs(this.currentLogFile,a,{flag:"w",mode:420}),(await mt(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{Ys(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 ht(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 ht(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return ht(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(he())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 Js(16).toString("hex")}generateKey(){return Js(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=Js(16),s=Rm("aes-256-gcm",n,t),i=Je.concat([s.update(e,"utf8"),s.final()]),r=s.getAuthTag();return{encrypted:Je.concat([t,i,r]),iv:t}}async compressData(e){return new Promise((n,t)=>{let s=Or(),i=[];s.on("data",(r)=>i.push(r)),s.on("end",()=>n(Je.from(Je.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(he())return;let e=await mt(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 Ht(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 mt(t).catch(()=>null))try{if(await Ar(t,l),n.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await Zt(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 Qs(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 mt(t).catch(()=>null))await Ar(t,r)}if(this.currentLogFile=s,n.maxFiles){let r=(await Ht(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,l)=>l.localeCompare(o));for(let o of r.slice(n.maxFiles))await Zt(ht(this.config.logDirectory,o))}}}async compressLogFile(e,n){let t=Sr(e),s=$m(n),i=Or();await Mm(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()})),Xs(this.currentLogFile))try{let e=Lr(this.currentLogFile,"r+");Er(e),Ys(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(!he()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let n=(await Ht(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of n)try{await Zt(ht(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?ue.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=Pe.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} ${ue.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&&!he()){let c=ko[e],u=this.options.showTags!==!1&&this.name?ue.gray(this.formatTag(this.name)):"",f;switch(e){case"debug":f=this.formatConsoleMessage({timestamp:i,icon:c,tag:u,message:ue.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:ue.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(`
2
+ import{F as se,H as Ut,I as zt,J as wr,K as nt,L as qt,i as Fe,j as Ee,k as qs,l as tm,m as xr,n as _i,o as gr,p as tt,r as _e,t as at,u as nm,w as st}from"./chunk-vdbbvx8x.js";import{Q as Ne}from"./chunk-awmb5sg5.js";import{readdirSync as sm,readFileSync as im,statSync as Vs,writeFileSync as br}from"fs";import{isAbsolute as Mt,join as rm,relative as Ks,resolve as Ct,sep as om}from"path";import{existsSync as vr,statSync as Ir}from"fs";import{existsSync as hi,mkdirSync as ym,readdirSync as bm,writeFileSync as xm}from"fs";import{homedir as ft}from"os";import{dirname as Mr,resolve as Se}from"path";import it from"process";import{join as wm,relative as Rm,resolve as Cr}from"path";import un from"process";import{existsSync as uo,mkdirSync as vg,readdirSync as Ig,writeFileSync as Mg}from"fs";import{homedir as Gs}from"os";import{dirname as Eg,resolve as Ce}from"path";import Tt from"process";import{join as km,relative as $m,resolve as Sr}from"path";import fn from"process";import{existsSync as fo,mkdirSync as _g,readdirSync as Dg,writeFileSync as Fg}from"fs";import{dirname as Wg,resolve as mn}from"path";import di from"process";import{Buffer as Je}from"buffer";import{createCipheriv as Pm,createDecipheriv as vm,randomBytes as Js}from"crypto";import{closeSync as Ys,createReadStream as Er,createWriteStream as Im,existsSync as Xs,fsyncSync as Lr,openSync as Tr,writeFileSync as Mm}from"fs";import{access as Cm,constants as Ar,mkdir as Sm,readdir as Ht,rename as Or,stat as mt,unlink as Zt,writeFile as Qs}from"fs/promises";import{join as ht}from"path";import Pe from"process";import{pipeline as Em}from"stream/promises";import{createGzip as _r}from"zlib";import dt from"process";import Ke from"process";import{Buffer as ze}from"buffer";import{createCipheriv as Lm,createDecipheriv as Tm,randomBytes as ei}from"crypto";import{closeSync as ti,createReadStream as Dr,createWriteStream as Am,existsSync as Gt,fsyncSync as Fr,openSync as Nr,writeFileSync as Om}from"fs";import{access as _m,constants as Wr,mkdir as Dm,readdir as Jt,rename as Br,stat as pt,unlink as Yt,writeFile as ni}from"fs/promises";import{isAbsolute as Fm,join as gt,resolve as Nm}from"path";import ie from"process";import{pipeline as Wm}from"stream/promises";import{createGzip as jr}from"zlib";import yt from"process";import Ve from"process";import Xt from"process";import{existsSync as Qt}from"fs";import{resolve as si}from"path";import{existsSync as Bm}from"fs";import{existsSync as jm,readdirSync as Um}from"fs";import{extname as ii,resolve as Ur}from"path";import zm from"process";import{join as qh,relative as Kh,resolve as eo}from"path";import xn from"process";import{Buffer as qe}from"buffer";import{createCipheriv as Zh,createDecipheriv as Gh,randomBytes as ci}from"crypto";import{closeSync as ui,createReadStream as to,createWriteStream as Jh,existsSync as tn,fsyncSync as no,openSync as so,writeFileSync as Yh}from"fs";import{access as Xh,constants as io,mkdir as Qh,readdir as nn,rename as ro,stat as bt,unlink as sn,writeFile as fi}from"fs/promises";import{isAbsolute as ed,join as xt,resolve as td}from"path";import re from"process";import{pipeline as nd}from"stream/promises";import{createGzip as oo}from"zlib";import wt from"process";import He from"process";var mm=Object.defineProperty;var hm=(e)=>e;function dm(e,n){this[e]=hm.bind(null,n)}var pm=(e,n)=>{for(var t in n)mm(e,t,{get:n[t],enumerable:!0,configurable:!0,set:dm.bind(n,t)})},gm=(e,n)=>()=>(e&&(n=e(e=0)),n);var co={};pm(co,{withErrorRecovery:()=>po,tryLoadConfig:()=>mh,loadConfigWithResult:()=>uh,loadConfig:()=>wo,isRetryableError:()=>ih,isConfigNotFoundError:()=>sh,isBunfigError:()=>go,globalPerformanceMonitor:()=>_t,globalCache:()=>Rt,getEnvOrDefault:()=>rh,generateConfigTypes:()=>hh,defaultGeneratedDir:()=>Co,defaultConfigDir:()=>Mo,deepMergeWithArrayStrategy:()=>Ci,deepMerge:()=>yo,createLibraryConfig:()=>dh,config:()=>fh,bunfigPlugin:()=>ph,applyEnvVarsToConfig:()=>Lt,TypeGenerationError:()=>Ri,SchemaValidationError:()=>Ot,PluginError:()=>$i,PerformanceMonitor:()=>vi,FileSystemError:()=>wi,ErrorFactory:()=>Ye,EnvVarError:()=>bn,EnvProcessor:()=>Rn,ConfigValidator:()=>Si,ConfigValidationError:()=>bi,ConfigNotFoundError:()=>yn,ConfigMergeError:()=>xi,ConfigLoader:()=>Ei,ConfigLoadError:()=>At,ConfigFileLoader:()=>kn,ConfigCache:()=>Pi,CacheUtils:()=>ko,BunfigError:()=>Le,BrowserConfigError:()=>ki,ArrayMergeStrategies:()=>vo});class Pi{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(!vr(e))return!0;return Ir(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=vr(t)?Ir(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 vi{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 qm(e,n={}){let s=Object.keys(n).sort().map((i)=>`${i}:${n[i]}`).join("|");return s?`${e}:${s}`:e}function Km(e,n){try{return JSON.stringify(e)===JSON.stringify(n)}catch{return e===n}}function Vm(e){return e.getStats().size*2}function Ii(e,n){if(Array.isArray(n)&&Array.isArray(e)&&n.length===2&&e.length===2&&fe(n[0])&&"id"in n[0]&&n[0].id===3&&fe(n[1])&&"id"in n[1]&&n[1].id===4)return n;if(fe(n)&&fe(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(fe(e)&&"arr"in e&&Array.isArray(e.arr)&&fe(n)&&"arr"in n&&Array.isArray(n.arr))return n;if(n.length>0&&e.length>0&&fe(n[0])&&fe(e[0])){let s=[...n];for(let i of e)if(fe(i)&&"name"in i){if(!s.find((o)=>fe(o)&&("name"in o)&&o.name===i.name))s.push(i)}else if(fe(i)&&"path"in i){if(!s.find((o)=>fe(o)&&("path"in o)&&o.path===i.path))s.push(i)}else if(!s.some((r)=>hn(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(!fe(n)||!fe(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(fe(i)&&fe(t[s]))t[s]=Ii(t[s],i);else if(Array.isArray(i)&&Array.isArray(t[s]))if(i.length>0&&t[s].length>0&&fe(i[0])&&fe(t[s][0])){let r=[...i];for(let o of t[s])if(fe(o)&&"name"in o){if(!r.find((a)=>fe(a)&&("name"in a)&&a.name===o.name))r.push(o)}else if(fe(o)&&"path"in o){if(!r.find((a)=>fe(a)&&("path"in a)&&a.path===o.path))r.push(o)}else if(!r.some((l)=>hn(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 hn(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(!hn(e[t],n[t]))return!1;return!0}if(fe(e)&&fe(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(!hn(e[i],n[i]))return!1}return!0}return!1}function fe(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function Hm(e,n){if(!fo(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 Ii(n,s)}catch{return null}}catch{return null}}async function Zm({name:e="",cwd:n,defaultConfig:t}){let s=n||di.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=mn(s,`${o}${l}`),c=await Hm(a,t);if(c!==null)return c}try{let o=mn(s,"package.json");if(fo(o)){let a=(await import(o))[e];if(a&&typeof a==="object"&&!Array.isArray(a))try{return Ii(t,a)}catch{}}}catch{}return t}function Gm(e,n={}){let t=fn.cwd();while(t.includes("storage"))t=Sr(t,"..");let s=Sr(t,e||"");if(n?.relative)return $m(fn.cwd(),s);return s}async function Jm(){try{let e=await Zm({name:"clarity",defaultConfig:on,cwd:fn.cwd(),endpoint:"",headers:{}});return{...on,...e}}catch{return on}}function he(){if(Ke.env.NODE_ENV==="test"||Ke.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Ym(){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 mo{async format(e){let n=await Ym(),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:dt.pid,hostname:n(),environment:dt.env.NODE_ENV||"development",platform:dt.platform,version:dt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:dt.env.NODE_ENV||dt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class dn{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={...gi},this.options=this.normalizeOptions(n),this.formatter=this.options.formatter||new mo,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??Pe.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{...ln,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...ln};return{...ln,...e.fingersCrossed}}normalizeOptions(e){let n={format:"json",level:"info",logDirectory:gi.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 Cm(this.config.logDirectory,Ar.F_OK|Ar.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await Sm(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:Je.from(e);try{if(!Xs(this.currentLogFile))await Qs(this.currentLogFile,"",{mode:420});if(i=Tr(this.currentLogFile,"a",420),Mm(i,a,{flag:"a"}),Lr(i),i!==void 0)Ys(i),i=void 0;if((await mt(this.currentLogFile)).size===0){if(await Qs(this.currentLogFile,a,{flag:"w",mode:420}),(await mt(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{Ys(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 ht(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 ht(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return ht(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(he())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 Js(16).toString("hex")}generateKey(){return Js(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=Js(16),s=Pm("aes-256-gcm",n,t),i=Je.concat([s.update(e,"utf8"),s.final()]),r=s.getAuthTag();return{encrypted:Je.concat([t,i,r]),iv:t}}async compressData(e){return new Promise((n,t)=>{let s=_r(),i=[];s.on("data",(r)=>i.push(r)),s.on("end",()=>n(Je.from(Je.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(he())return;let e=await mt(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 Ht(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 mt(t).catch(()=>null))try{if(await Or(t,l),n.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await Zt(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 Qs(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 mt(t).catch(()=>null))await Or(t,r)}if(this.currentLogFile=s,n.maxFiles){let r=(await Ht(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,l)=>l.localeCompare(o));for(let o of r.slice(n.maxFiles))await Zt(ht(this.config.logDirectory,o))}}}async compressLogFile(e,n){let t=Er(e),s=Im(n),i=_r();await Em(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()})),Xs(this.currentLogFile))try{let e=Tr(this.currentLogFile,"r+");Lr(e),Ys(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(!he()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let n=(await Ht(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of n)try{await Zt(ht(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?ue.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=Pe.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} ${ue.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&&!he()){let c=$o[e],u=this.options.showTags!==!1&&this.name?ue.gray(this.formatTag(this.name)):"",f;switch(e){case"debug":f=this.formatConsoleMessage({timestamp:i,icon:c,tag:u,message:ue.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:ue.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
3
  `);for(let h of m)if(h.trim()&&!h.includes(o))console.error(this.formatConsoleMessage({timestamp:i,message:ue.gray(` ${h}`),level:e,showTimestamp:!1}))}break}}else if(!he()){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
4
  `;if(l)a+=`${l}
5
5
  `;a=a.replace(this.ANSI_PATTERN,""),await this.writeToFile(a)}time(e){let n=performance.now();if(this.fancy&&!he()){let t=this.options.showTags!==!1&&this.name?ue.gray(this.formatTag(this.name)):"",s=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:s,icon:ue.blue("\u25D0"),tag:t,message:`${ue.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&&!he()){let u=this.options.showTags!==!1&&this.name?ue.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:ue.green("\u2713"),tag:u,message:`${r}${t?` ${JSON.stringify(t)}`:""}`}))}else if(!he())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 dn(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(he())throw Error("createReadStream is not supported in browser environments");if(!Xs(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return Sr(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=Je.isBuffer(e)?e:Je.from(e,"base64"),i=s.slice(0,16),r=s.slice(-16),o=s.slice(16,-16),l=km("aes-256-gcm",t,i);return l.setAuthTag(r),Je.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 he()}isServerMode(){return!he()}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&&!he()){let r=e.split(`
6
+ `,c=c.replace(this.ANSI_PATTERN,""),this.fancy&&!he()){let u=this.options.showTags!==!1&&this.name?ue.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:ue.green("\u2713"),tag:u,message:`${r}${t?` ${JSON.stringify(t)}`:""}`}))}else if(!he())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 dn(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(he())throw Error("createReadStream is not supported in browser environments");if(!Xs(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return Er(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=Je.isBuffer(e)?e:Je.from(e,"base64"),i=s.slice(0,16),r=s.slice(-16),o=s.slice(16,-16),l=vm("aes-256-gcm",t,i);return l.setAuthTag(r),Je.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 he()}isServerMode(){return!he()}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&&!he()){let r=e.split(`
7
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:ue.gray(this.formatTag(this.name)),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:t,message:ue.cyan(l)})),c.forEach((u)=>console.error(this.formatConsoleMessage({timestamp:t,message:ue.cyan(u),showTimestamp:!1}))),console.error(this.formatConsoleMessage({timestamp:t,message:ue.cyan(a),showTimestamp:!1}))}else if(!he())console.error(`${s} ${this.environment}.INFO: [BOX] ${e}`);let i=`${s} ${this.environment}.INFO: [BOX] ${e}
8
8
  `.replace(this.ANSI_PATTERN,"");await this.writeToFile(i)}async prompt(e){if(he())return Promise.resolve(!0);return new Promise((n)=>{console.error(`${ue.cyan("?")} ${e} (y/n) `);let t=(s)=>{let i=s.toString().trim().toLowerCase();Pe.stdin.removeListener("data",t);try{if(typeof Pe.stdin.setRawMode==="function")Pe.stdin.setRawMode(!1)}catch{}Pe.stdin.pause(),console.error(""),n(i==="y"||i==="yes")};try{if(typeof Pe.stdin.setRawMode==="function")Pe.stdin.setRawMode(!0)}catch{}Pe.stdin.resume(),Pe.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&&!he()){let o=this.options.showTags!==!1&&this.name?ue.gray(this.formatTag(this.name)):"",l=ue.blue("\u25D0");console.error(`${l} ${o} ${ue.cyan(t)}`)}let r=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${t}
9
9
  `.replace(this.ANSI_PATTERN,"");await this.writeToFile(r)}progress(e,n=""){if(!this.enabled||!this.fancy||he()||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||he())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||he())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||he())return;Pe.stdout.write(`${"\r".padEnd(Pe.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||he()||!Pe.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=ue.green("\u2501".repeat(s)),o=ue.gray("\u2501".repeat(i)),l=`[${r}${o}]`,a=`${t}%`.padStart(4),c=e.message?` ${e.message}`:"",u=n||t===100?ue.green("\u2713"):ue.blue("\u25B6"),f=this.options.showTags!==!1&&this.name?` ${ue.gray(this.formatTag(this.name))}`:"",m=`\r${u}${f} ${l} ${a}${c}`,h=Pe.stdout.columns||80,d=" ".repeat(Math.max(0,h-m.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${m}${d}`,Pe.stdout.write(e.lastRenderedLine),n)Pe.stdout.write(`
10
- `)}finishProgressBar(e,n){if(!this.enabled||!this.fancy||he()||!Pe.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(he()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let n=await Ht(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=ht(this.config.logDirectory,s);if(e.before)try{if((await mt(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 Zt(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 rn(e,n){if(Array.isArray(n)&&Array.isArray(e)&&n.length===2&&e.length===2&&ce(n[0])&&"id"in n[0]&&n[0].id===3&&ce(n[1])&&"id"in n[1]&&n[1].id===4)return n;if(ce(n)&&ce(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(ce(e)&&"arr"in e&&Array.isArray(e.arr)&&ce(n)&&"arr"in n&&Array.isArray(n.arr))return n;if(n.length>0&&e.length>0&&ce(n[0])&&ce(e[0])){let s=[...n];for(let i of e)if(ce(i)&&"name"in i){if(!s.find((o)=>ce(o)&&("name"in o)&&o.name===i.name))s.push(i)}else if(ce(i)&&"path"in i){if(!s.find((o)=>ce(o)&&("path"in o)&&o.path===i.path))s.push(i)}else if(!s.some((r)=>pn(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(!ce(n)||!ce(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(ce(i)&&ce(t[s]))t[s]=rn(t[s],i);else if(Array.isArray(i)&&Array.isArray(t[s]))if(i.length>0&&t[s].length>0&&ce(i[0])&&ce(t[s][0])){let r=[...i];for(let o of t[s])if(ce(o)&&"name"in o){if(!r.find((a)=>ce(a)&&("name"in a)&&a.name===o.name))r.push(o)}else if(ce(o)&&"path"in o){if(!r.find((a)=>ce(a)&&("path"in a)&&a.path===o.path))r.push(o)}else if(!r.some((l)=>pn(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 Mi(e,n,t="replace"){if(n===null||n===void 0)return e;if(Array.isArray(n))return t==="replace"?n:rn(e,n);if(Array.isArray(e))return t==="replace"?n:rn(e,n);if(!ce(n)||!ce(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]=rn(o,r);else if(ce(r)&&ce(o))s[i]=Mi(o,r,t);else s[i]=r}return s}function pn(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(!pn(e[t],n[t]))return!1;return!0}if(ce(e)&&ce(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(!pn(e[i],n[i]))return!1}return!0}return!1}function ce(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function en(e,n,t="replace"){if(!co(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 Mi(n,i,t)}catch{return null}}catch{return null}}function Gm(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)Ie.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=Tt.env[h]||Tt.env[d];if(p!==void 0){if(t)Ie.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 Jm({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)?Gm(e,i,r):i,c=t||Tt.cwd(),u=[".ts",".js",".mjs",".cjs",".json"];if(r)Ie.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,Ce(c,"config"),Ce(c,".config"),s?Ce(c,s):void 0].filter(Boolean)));for(let g of p){if(r)Ie.info(`Searching for configuration in: ${g}`);let x=[Ce(c,"config"),Ce(c,".config")].concat(s?[Ce(c,s)]:[]).includes(g)?[...f,...m,...h,...d]:[...m,...f,...d,...h];for(let R of x)for(let k of u){let M=Ce(g,`${R}${k}`),P=await en(M,a,l);if(P!==null){if(r)Ie.success(`Configuration loaded from: ${M}`);return P}}}if(e){let g=Ce(Gs(),".config",e),y=["config",`${e}.config`];if(n)y.push(`${n}.config`);if(r)Ie.info(`Checking user config directory: ${g}`);for(let x of y)for(let R of u){let k=Ce(g,`${x}${R}`),M=await en(k,a,l);if(M!==null){if(r)Ie.success(`Configuration loaded from user config directory: ${k}`);return M}}}if(e){let g=Ce(Gs(),".config"),y=[`.${e}.config`];if(n)y.push(`.${n}.config`);if(r)Ie.info(`Checking user config directory for dotfile configs: ${g}`);for(let x of y)for(let R of u){let k=Ce(g,`${x}${R}`),M=await en(k,a,l);if(M!==null){if(r)Ie.success(`Configuration loaded from user config directory dotfile: ${k}`);return M}}}if(e){let g=Gs(),y=[`.${e}.config`,`.${e}`];if(n)y.push(`.${n}.config`),y.push(`.${n}`);if(r)Ie.info(`Checking user home directory for dotfile configs: ${g}`);for(let x of y)for(let R of u){let k=Ce(g,`${x}${R}`),M=await en(k,a,l);if(M!==null){if(r)Ie.success(`Configuration loaded from user home directory: ${k}`);return M}}}try{let g=Ce(c,"package.json");if(co(g)){let y=await import(g),x=y[e];if(!x&&n){if(x=y[n],x&&r)Ie.success(`Using alias "${n}" configuration from package.json`)}if(x&&typeof x==="object"&&!Array.isArray(x))try{if(r)Ie.success(`Configuration loaded from package.json: ${x===y[e]?e:n}`);return Mi(a,x,l)}catch(R){if(r)Ie.warn("Failed to merge package.json config:",R)}}}catch(g){if(r)Ie.warn("Failed to load package.json:",g)}if(r)Ie.info(`No configuration found for "${e}"${n?` or alias "${n}"`:""}, using default configuration with environment variables`);return a}function Ym(e,n={}){let t=un.cwd();while(t.includes("storage"))t=Mr(t,"..");let s=Mr(t,e||"");if(n?.relative)return bm(un.cwd(),s);return s}async function Xm(){try{let e=await Jm({name:"clarity",alias:"logging",defaultConfig:an,cwd:un.cwd()});return{...an,...e||{}}}catch{return an}}function be(){if(Ve.env.NODE_ENV==="test"||Ve.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Qm(){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 mo{async format(e){let n=await Qm(),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:yt.pid,hostname:n(),environment:yt.env.NODE_ENV||"development",platform:yt.platform,version:yt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:yt.env.NODE_ENV||yt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class gn{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={...yi},this.options=this.normalizeOptions(n),this.formatter=this.options.formatter||new mo,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{...cn,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...cn};return{...cn,...e.fingersCrossed}}normalizeOptions(e){let n={format:"json",level:"info",logDirectory:yi.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!be()&&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 Tm(this.config.logDirectory,Nr.F_OK|Nr.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await Am(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(!Gt(this.currentLogFile))await ni(this.currentLogFile,"",{mode:420});if(i=Fr(this.currentLogFile,"a",420),Lm(i,a,{flag:"a"}),Dr(i),i!==void 0)ti(i),i=void 0;if((await pt(this.currentLogFile)).size===0){if(await ni(this.currentLogFile,a,{flag:"w",mode:420}),(await pt(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{ti(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 gt(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 gt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return gt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(be())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 ei(16).toString("hex")}generateKey(){return ei(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=ei(16),s=Cm("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=Br(),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(be())return;if(!this.shouldWriteToFile())return;let e=await pt(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 Jt(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 pt(t).catch(()=>null))try{if(await Wr(t,l),n.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await Yt(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 ni(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 pt(t).catch(()=>null))await Wr(t,r)}if(this.currentLogFile=s,n.maxFiles){let r=(await Jt(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,l)=>l.localeCompare(o));for(let o of r.slice(n.maxFiles))await Yt(gt(this.config.logDirectory,o))}}}async compressLogFile(e,n){let t=_r(e),s=Em(n),i=Br();await Dm(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()})),Gt(this.currentLogFile))try{let e=Fr(this.currentLogFile,"r+");Dr(e),ti(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(!be()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let n=(await Jt(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of n)try{await Yt(gt(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||be())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(be())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(Om(n)||n.startsWith("./")||n.startsWith("../"))n=_m(n);else return null;return Gt(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?"":$o[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(`
10
+ `)}finishProgressBar(e,n){if(!this.enabled||!this.fancy||he()||!Pe.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(he()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let n=await Ht(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=ht(this.config.logDirectory,s);if(e.before)try{if((await mt(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 Zt(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 rn(e,n){if(Array.isArray(n)&&Array.isArray(e)&&n.length===2&&e.length===2&&ce(n[0])&&"id"in n[0]&&n[0].id===3&&ce(n[1])&&"id"in n[1]&&n[1].id===4)return n;if(ce(n)&&ce(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(ce(e)&&"arr"in e&&Array.isArray(e.arr)&&ce(n)&&"arr"in n&&Array.isArray(n.arr))return n;if(n.length>0&&e.length>0&&ce(n[0])&&ce(e[0])){let s=[...n];for(let i of e)if(ce(i)&&"name"in i){if(!s.find((o)=>ce(o)&&("name"in o)&&o.name===i.name))s.push(i)}else if(ce(i)&&"path"in i){if(!s.find((o)=>ce(o)&&("path"in o)&&o.path===i.path))s.push(i)}else if(!s.some((r)=>pn(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(!ce(n)||!ce(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(ce(i)&&ce(t[s]))t[s]=rn(t[s],i);else if(Array.isArray(i)&&Array.isArray(t[s]))if(i.length>0&&t[s].length>0&&ce(i[0])&&ce(t[s][0])){let r=[...i];for(let o of t[s])if(ce(o)&&"name"in o){if(!r.find((a)=>ce(a)&&("name"in a)&&a.name===o.name))r.push(o)}else if(ce(o)&&"path"in o){if(!r.find((a)=>ce(a)&&("path"in a)&&a.path===o.path))r.push(o)}else if(!r.some((l)=>pn(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 Mi(e,n,t="replace"){if(n===null||n===void 0)return e;if(Array.isArray(n))return t==="replace"?n:rn(e,n);if(Array.isArray(e))return t==="replace"?n:rn(e,n);if(!ce(n)||!ce(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]=rn(o,r);else if(ce(r)&&ce(o))s[i]=Mi(o,r,t);else s[i]=r}return s}function pn(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(!pn(e[t],n[t]))return!1;return!0}if(ce(e)&&ce(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(!pn(e[i],n[i]))return!1}return!0}return!1}function ce(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function en(e,n,t="replace"){if(!uo(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 Mi(n,i,t)}catch{return null}}catch{return null}}function Xm(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)Ie.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=Tt.env[h]||Tt.env[d];if(p!==void 0){if(t)Ie.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 Qm({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)?Xm(e,i,r):i,c=t||Tt.cwd(),u=[".ts",".js",".mjs",".cjs",".json"];if(r)Ie.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,Ce(c,"config"),Ce(c,".config"),s?Ce(c,s):void 0].filter(Boolean)));for(let g of p){if(r)Ie.info(`Searching for configuration in: ${g}`);let x=[Ce(c,"config"),Ce(c,".config")].concat(s?[Ce(c,s)]:[]).includes(g)?[...f,...m,...h,...d]:[...m,...f,...d,...h];for(let R of x)for(let k of u){let M=Ce(g,`${R}${k}`),P=await en(M,a,l);if(P!==null){if(r)Ie.success(`Configuration loaded from: ${M}`);return P}}}if(e){let g=Ce(Gs(),".config",e),y=["config",`${e}.config`];if(n)y.push(`${n}.config`);if(r)Ie.info(`Checking user config directory: ${g}`);for(let x of y)for(let R of u){let k=Ce(g,`${x}${R}`),M=await en(k,a,l);if(M!==null){if(r)Ie.success(`Configuration loaded from user config directory: ${k}`);return M}}}if(e){let g=Ce(Gs(),".config"),y=[`.${e}.config`];if(n)y.push(`.${n}.config`);if(r)Ie.info(`Checking user config directory for dotfile configs: ${g}`);for(let x of y)for(let R of u){let k=Ce(g,`${x}${R}`),M=await en(k,a,l);if(M!==null){if(r)Ie.success(`Configuration loaded from user config directory dotfile: ${k}`);return M}}}if(e){let g=Gs(),y=[`.${e}.config`,`.${e}`];if(n)y.push(`.${n}.config`),y.push(`.${n}`);if(r)Ie.info(`Checking user home directory for dotfile configs: ${g}`);for(let x of y)for(let R of u){let k=Ce(g,`${x}${R}`),M=await en(k,a,l);if(M!==null){if(r)Ie.success(`Configuration loaded from user home directory: ${k}`);return M}}}try{let g=Ce(c,"package.json");if(uo(g)){let y=await import(g),x=y[e];if(!x&&n){if(x=y[n],x&&r)Ie.success(`Using alias "${n}" configuration from package.json`)}if(x&&typeof x==="object"&&!Array.isArray(x))try{if(r)Ie.success(`Configuration loaded from package.json: ${x===y[e]?e:n}`);return Mi(a,x,l)}catch(R){if(r)Ie.warn("Failed to merge package.json config:",R)}}}catch(g){if(r)Ie.warn("Failed to load package.json:",g)}if(r)Ie.info(`No configuration found for "${e}"${n?` or alias "${n}"`:""}, using default configuration with environment variables`);return a}function eh(e,n={}){let t=un.cwd();while(t.includes("storage"))t=Cr(t,"..");let s=Cr(t,e||"");if(n?.relative)return Rm(un.cwd(),s);return s}async function th(){try{let e=await Qm({name:"clarity",alias:"logging",defaultConfig:an,cwd:un.cwd()});return{...an,...e||{}}}catch{return an}}function be(){if(Ve.env.NODE_ENV==="test"||Ve.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function nh(){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 ho{async format(e){let n=await nh(),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:yt.pid,hostname:n(),environment:yt.env.NODE_ENV||"development",platform:yt.platform,version:yt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:yt.env.NODE_ENV||yt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class gn{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={...yi},this.options=this.normalizeOptions(n),this.formatter=this.options.formatter||new ho,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{...cn,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...cn};return{...cn,...e.fingersCrossed}}normalizeOptions(e){let n={format:"json",level:"info",logDirectory:yi.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!be()&&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 _m(this.config.logDirectory,Wr.F_OK|Wr.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await Dm(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(!Gt(this.currentLogFile))await ni(this.currentLogFile,"",{mode:420});if(i=Nr(this.currentLogFile,"a",420),Om(i,a,{flag:"a"}),Fr(i),i!==void 0)ti(i),i=void 0;if((await pt(this.currentLogFile)).size===0){if(await ni(this.currentLogFile,a,{flag:"w",mode:420}),(await pt(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{ti(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 gt(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 gt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return gt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(be())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 ei(16).toString("hex")}generateKey(){return ei(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=ei(16),s=Lm("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=jr(),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(be())return;if(!this.shouldWriteToFile())return;let e=await pt(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 Jt(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 pt(t).catch(()=>null))try{if(await Br(t,l),n.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await Yt(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 ni(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 pt(t).catch(()=>null))await Br(t,r)}if(this.currentLogFile=s,n.maxFiles){let r=(await Jt(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,l)=>l.localeCompare(o));for(let o of r.slice(n.maxFiles))await Yt(gt(this.config.logDirectory,o))}}}async compressLogFile(e,n){let t=Dr(e),s=Am(n),i=jr();await Wm(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()})),Gt(this.currentLogFile))try{let e=Nr(this.currentLogFile,"r+");Fr(e),ti(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(!be()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let n=(await Jt(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of n)try{await Yt(gt(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||be())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(be())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(Fm(n)||n.startsWith("./")||n.startsWith("../"))n=Nm(n);else return null;return Gt(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?"":Po[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
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(!be()){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
12
  `;if(l)u+=`${l}
13
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()&&!be()&&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()&&!be()&&ie.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(l)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,l)},interrupt:(l,a="info")=>{if(!be()&&ie.stdout.isTTY)ie.stdout.write(`
14
14
  `);if(this[a==="warning"?"warn":a](l),this.activeProgressBar&&this.shouldStyleConsole()&&!be()&&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(!be())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 gn(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(be())throw Error("createReadStream is not supported in browser environments");if(!Gt(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return _r(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=Sm("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 be()}isServerMode(){return!be()}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(`
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(!be())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 gn(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(be())throw Error("createReadStream is not supported in browser environments");if(!Gt(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return Dr(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=Tm("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 be()}isServerMode(){return!be()}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
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(!be())console.error(`${s} ${this.environment}.INFO: [BOX] ${r}`);let o=`${s} ${this.environment}.INFO: [BOX] ${r}
17
17
  `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(o)}async prompt(e){if(be())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
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||be()||!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(be()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let n=await Jt(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=gt(this.config.logDirectory,s);if(e.before)try{if((await pt(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 Yt(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 ho(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 po(e){return e instanceof Le}function eh(e){return e instanceof yn}function th(e){if(po(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 Rn{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 _t.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=Xt.env[a]||(c?Xt.env[c]:void 0);if(u!==void 0){if(s.verbose){let f=Xt.env[a]?a:c}try{e[i]=this.parseEnvironmentValue(u,typeof r,a,s.customParsers,s.configName)}catch(f){if(f instanceof bn)throw f;throw Ye.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 Ye.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(Xt.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}:
19
+ `)}finishProgressBar(e,n){if(!this.enabled||!this.fancy||be()||!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(be()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let n=await Jt(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=gt(this.config.logDirectory,s);if(e.before)try{if((await pt(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 Yt(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 po(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 go(e){return e instanceof Le}function sh(e){return e instanceof yn}function ih(e){if(go(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 Rn{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 _t.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=Xt.env[a]||(c?Xt.env[c]:void 0);if(u!==void 0){if(s.verbose){let f=Xt.env[a]?a:c}try{e[i]=this.parseEnvironmentValue(u,typeof r,a,s.customParsers,s.configName)}catch(f){if(f instanceof bn)throw f;throw Ye.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 Ye.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(Xt.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
20
 
21
21
  `;for(let s of e)t+=`${s.key}
22
22
  `,t+=` Type: ${s.type}
@@ -28,41 +28,41 @@ import{F as se,H as Ut,I as zt,J as xr,K as nt,L as qt,i as Fe,j as Ee,k as qs,l
28
28
  `;t+=`| Variable | Type | Description | Example |
29
29
  `,t+=`|----------|------|-------------|----------|
30
30
  `;for(let s of e)t+=`| \`${s.key}\` | ${s.type} | ${s.description} | \`${s.example}\` |
31
- `;return t}}function nh(e,n){let t=wo("process");if(typeof t>"u"||!t.env)return n;let s=t.env[e];return s!==void 0?s:n}function go(e,n,t={}){return yo(e,n,t,new WeakMap)}function yo(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 bo(e,n,i,s);if(!Oe(n)||!Oe(e))return n;return oh(e,n,t,s)}function bo(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 sh(e,n);case"smart":return ih(e,n,s);default:return n}return n}function sh(e,n){let t=[...n];for(let s of e)if(!t.some((i)=>pi(i,s)))t.push(s);return t}function ih(e,n,t){if(n.length===0)return e;if(e.length===0)return n;if(Oe(n[0])&&Oe(e[0]))return rh(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 rh(e,n,t){let s=[...n];for(let i of e){if(!Oe(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)=>Oe(c)&&(l in c)&&c[l]===i[l])){o=!0;break}}if(!o)s.push(i)}return s}function oh(e,n,t,s){let i=n;if(Oe(i)&&s.has(i))return s.get(i);let r={...e};if(Oe(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(Oe(l)&&Oe(a))r[o]=yo(a,l,t,s);else if(Array.isArray(l)||Array.isArray(a))r[o]=bo(a,l,t.arrayMergeMode||"smart",s);else r[o]=l}return r}function Ci(e,n,t="replace"){return go(e,n,{arrayMergeMode:t==="replace"?"replace":"smart",skipNullish:!0})}function pi(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(!pi(e[t],n[t]))return!1;return!0}if(Oe(e)&&Oe(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(!pi(e[i],n[i]))return!1}return!0}return!1}function Oe(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class kn{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=Rt.getWithFileCheck("file",e);if(c){if(l)console.log(`Configuration loaded from cache: ${e}`);return c}}let a=async()=>{if(!Qt(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 At(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof f!=="object"||f===null||Array.isArray(f))throw new At(e,Error("Configuration must export a valid object"),"unknown");let g={config:Ci(n,f,s),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(i)Rt.setWithFileCheck("file",g,e,r);return g}catch(c){throw c instanceof Error?Ye.configLoad(e,c):Ye.configLoad(e,Error(String(c)))}};if(o)return _t.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(si(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 ho(async()=>Qt(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,n,t){let s=[];if(!Qt(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=si(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=si(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(!Qt(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 Si{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 _t.track("validateConfiguration",c);return c()}async validateWithSchemaFile(e,n,t){try{if(!Fm(n))throw new Ot(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 Ot(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:vo},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}class Ei{fileLoader=new kn;envProcessor=new Rn;validator=new Si;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)De.warn(`Slow configuration loading detected: ${a.duration}ms for ${o.name}`);l.metrics=a}return l}catch(l){let a=Date.now()-n;throw De.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||it.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(Se(f,"package.json")),this.finalizeResult(p,m,a,s,u);if(m.push(...this.getAllSearchPaths(s,i,f,o)),n)throw Ye.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?Lt(e,i,o):i,u=this.getLocalDirectories(t,s);for(let f of u){if(o)De.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)De.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?Lt(e,t,i):t,l=[Se(ft(),".config",e),Se(ft(),".config"),ft()];for(let a of l){if(i)De.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)De.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?Lt(e,s,r):s;try{let a=Se(t,"package.json");if(!hi(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)De.success(`Configuration loaded from package.json: ${f}`);return{config:Ci(l,u,i),source:{type:"package.json",path:a,priority:30,timestamp:new Date}}}}catch(a){if(r)De.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:Lt(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 Ye.configValidation(s||"unknown",i,s)}checkCache(e,n){let t=this.generateCacheKey(e,n);return Rt.get(t)||null}cacheResult(e,n,t,s){let i=this.generateCacheKey(e,s);Rt.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,Se(e,"config"),Se(e,".config"),n?Se(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(Se(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=[Se(ft(),".config",e),Se(ft(),".config"),ft()],s=[];for(let i of t)s.push(...this.fileLoader.generateConfigPaths(e,i,n));return s}async loadConfigWithResult(e){return this.loadConfig(e)}}function Ur(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 lh(e){return Ze.loadConfig({...e,__strictErrorHandling:!0})}async function xo(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 Ze.loadConfig(e);else s=await Ze.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)De.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 Ze.applyEnvironmentVariables(l.name||"",n,!0,l.verbose||!1))?.config??n;return n}}async function ah(e={defaultConfig:{}}){if(typeof e==="string"){let{cwd:n}=await import("process");try{return(await Ze.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"&&Ur(t)))return(await Ze.applyEnvironmentVariables(e,{},!0,!1)).config;throw t}}try{return(await Ze.loadConfig({...e,cwd:e.cwd||it.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(n){if(n instanceof Error&&(n.name==="ConfigNotFoundError"||n.name==="ConfigLoadError"&&Ur(n)))return(await Ze.applyEnvironmentVariables(e.name||"",e.defaultConfig||{},e.checkEnv!==!1,e.verbose||!1)).config;throw n}}async function ch(e,n,t="replace"){let s=new kn;try{let i=await s.loadFromPath(e,n,{arrayStrategy:t,useCache:!1,trackPerformance:!1});return i?i.config:null}catch{return null}}function Lt(e,n,t=!1){let s=new Rn,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=it.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 uh(e){let n=Se(it.cwd(),e.configDir),t=Se(it.cwd(),e.generatedDir),s=Se(t,"config-types.ts");if(!hi(Ir(s)))dm(Ir(s),{recursive:!0,mode:511});let i=hi(n)?pm(n).map((o)=>o.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],r=`// Generated by bunfig v${Wh}
31
+ `;return t}}function rh(e,n){let t=Ro("process");if(typeof t>"u"||!t.env)return n;let s=t.env[e];return s!==void 0?s:n}function yo(e,n,t={}){return bo(e,n,t,new WeakMap)}function bo(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 xo(e,n,i,s);if(!Oe(n)||!Oe(e))return n;return ch(e,n,t,s)}function xo(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 oh(e,n);case"smart":return lh(e,n,s);default:return n}return n}function oh(e,n){let t=[...n];for(let s of e)if(!t.some((i)=>pi(i,s)))t.push(s);return t}function lh(e,n,t){if(n.length===0)return e;if(e.length===0)return n;if(Oe(n[0])&&Oe(e[0]))return ah(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 ah(e,n,t){let s=[...n];for(let i of e){if(!Oe(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)=>Oe(c)&&(l in c)&&c[l]===i[l])){o=!0;break}}if(!o)s.push(i)}return s}function ch(e,n,t,s){let i=n;if(Oe(i)&&s.has(i))return s.get(i);let r={...e};if(Oe(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(Oe(l)&&Oe(a))r[o]=bo(a,l,t,s);else if(Array.isArray(l)||Array.isArray(a))r[o]=xo(a,l,t.arrayMergeMode||"smart",s);else r[o]=l}return r}function Ci(e,n,t="replace"){return yo(e,n,{arrayMergeMode:t==="replace"?"replace":"smart",skipNullish:!0})}function pi(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(!pi(e[t],n[t]))return!1;return!0}if(Oe(e)&&Oe(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(!pi(e[i],n[i]))return!1}return!0}return!1}function Oe(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class kn{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=Rt.getWithFileCheck("file",e);if(c){if(l)console.log(`Configuration loaded from cache: ${e}`);return c}}let a=async()=>{if(!Qt(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 At(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof f!=="object"||f===null||Array.isArray(f))throw new At(e,Error("Configuration must export a valid object"),"unknown");let g={config:Ci(n,f,s),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(i)Rt.setWithFileCheck("file",g,e,r);return g}catch(c){throw c instanceof Error?Ye.configLoad(e,c):Ye.configLoad(e,Error(String(c)))}};if(o)return _t.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(si(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 po(async()=>Qt(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,n,t){let s=[];if(!Qt(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=si(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=si(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(!Qt(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 Si{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 _t.track("validateConfiguration",c);return c()}async validateWithSchemaFile(e,n,t){try{if(!Bm(n))throw new Ot(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 Ot(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:Io},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}class Ei{fileLoader=new kn;envProcessor=new Rn;validator=new Si;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)De.warn(`Slow configuration loading detected: ${a.duration}ms for ${o.name}`);l.metrics=a}return l}catch(l){let a=Date.now()-n;throw De.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||it.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(Se(f,"package.json")),this.finalizeResult(p,m,a,s,u);if(m.push(...this.getAllSearchPaths(s,i,f,o)),n)throw Ye.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?Lt(e,i,o):i,u=this.getLocalDirectories(t,s);for(let f of u){if(o)De.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)De.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?Lt(e,t,i):t,l=[Se(ft(),".config",e),Se(ft(),".config"),ft()];for(let a of l){if(i)De.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)De.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?Lt(e,s,r):s;try{let a=Se(t,"package.json");if(!hi(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)De.success(`Configuration loaded from package.json: ${f}`);return{config:Ci(l,u,i),source:{type:"package.json",path:a,priority:30,timestamp:new Date}}}}catch(a){if(r)De.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:Lt(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 Ye.configValidation(s||"unknown",i,s)}checkCache(e,n){let t=this.generateCacheKey(e,n);return Rt.get(t)||null}cacheResult(e,n,t,s){let i=this.generateCacheKey(e,s);Rt.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,Se(e,"config"),Se(e,".config"),n?Se(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(Se(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=[Se(ft(),".config",e),Se(ft(),".config"),ft()],s=[];for(let i of t)s.push(...this.fileLoader.generateConfigPaths(e,i,n));return s}async loadConfigWithResult(e){return this.loadConfig(e)}}function zr(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 uh(e){return Ze.loadConfig({...e,__strictErrorHandling:!0})}async function wo(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 Ze.loadConfig(e);else s=await Ze.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)De.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 Ze.applyEnvironmentVariables(l.name||"",n,!0,l.verbose||!1))?.config??n;return n}}async function fh(e={defaultConfig:{}}){if(typeof e==="string"){let{cwd:n}=await import("process");try{return(await Ze.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"&&zr(t)))return(await Ze.applyEnvironmentVariables(e,{},!0,!1)).config;throw t}}try{return(await Ze.loadConfig({...e,cwd:e.cwd||it.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(n){if(n instanceof Error&&(n.name==="ConfigNotFoundError"||n.name==="ConfigLoadError"&&zr(n)))return(await Ze.applyEnvironmentVariables(e.name||"",e.defaultConfig||{},e.checkEnv!==!1,e.verbose||!1)).config;throw n}}async function mh(e,n,t="replace"){let s=new kn;try{let i=await s.loadFromPath(e,n,{arrayStrategy:t,useCache:!1,trackPerformance:!1});return i?i.config:null}catch{return null}}function Lt(e,n,t=!1){let s=new Rn,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=it.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 hh(e){let n=Se(it.cwd(),e.configDir),t=Se(it.cwd(),e.generatedDir),s=Se(t,"config-types.ts");if(!hi(Mr(s)))ym(Mr(s),{recursive:!0,mode:511});let i=hi(n)?bm(n).map((o)=>o.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],r=`// Generated by bunfig v${Uh}
32
32
  export type ConfigNames = ${i.length?`'${i.join("' | '")}'`:"string"}
33
- `;gm(s,r,{mode:438})}function fh(e){let n=null,t=null,s=()=>{if(!t)t=xo(e).then((r)=>(n=r,r),(r)=>{let o="defaultConfig"in e?e.defaultConfig:{};if(n=o,"verbose"in e&&e.verbose)De.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 mh(e){let n=jr(Bm.cwd(),e?.configDir||"./config");function t(){if(!Nm(n))return[];let i=new Set([".ts",".js",".mjs",".cjs",".mts",".cts",".json"]),r=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"],o=Wm(n).filter((a)=>i.has(ii(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=ii(c).toLowerCase(),f=l.get(a);if(!f){l.set(a,c);continue}let m=ii(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=jr(n,c.file).replace(/\\/g,"/");return` '${c.base}': typeof import('${u}').default`}).join(`,
33
+ `;xm(s,r,{mode:438})}function dh(e){let n=null,t=null,s=()=>{if(!t)t=wo(e).then((r)=>(n=r,r),(r)=>{let o="defaultConfig"in e?e.defaultConfig:{};if(n=o,"verbose"in e&&e.verbose)De.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 ph(e){let n=Ur(zm.cwd(),e?.configDir||"./config");function t(){if(!jm(n))return[];let i=new Set([".ts",".js",".mjs",".cjs",".mts",".cts",".json"]),r=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"],o=Um(n).filter((a)=>i.has(ii(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=ii(c).toLowerCase(),f=l.get(a);if(!f){l.set(a,c);continue}let m=ii(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=Ur(n,c.file).replace(/\\/g,"/");return` '${c.base}': typeof import('${u}').default`}).join(`,
35
35
  `)}
36
36
  }`:"Record<string, any>";return`export type ConfigNames = ${o}
37
37
  export type ConfigByName = ${l}
38
38
  export type Config<N extends ConfigNames> = N extends keyof ConfigByName ? ConfigByName[N] : unknown
39
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 wo,Rt,_t,Ro,hh,dh,zr,on,gi,ve,ue,ph,qr,gh,Kr,yh,bh,ri,xh,Vr,Hr,oi,wh,Rh,kh,$h,ln,ko,Ph,Ie,vh,Ih,Zr,an,yi,xe,oe,Mh,Gr,Ch,Jr,Sh,Eh,li,Lh,Yr,Xr,Th,ai,Ah,Oh,_h,Dh,Fh,cn,$o,Nh,Wh="0.15.6",Le,yn,At,bi,xi,bn,wi,Ri,Ot,ki,$i,Ye,Po,vo,De,Ze,Io,Mo,Bh=hm(async()=>{wo=import.meta.require,Rt=new Pi,_t=new vi,Ro={createKey:jm,isEquivalent:Um,estimateMemoryUsage:zm},hh=mn(di.cwd(),"config"),dh=mn(di.cwd(),"src/generated"),zr=fn.env.CLARITY_LOG_DIR||xm(Vm(),"logs"),on={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:zr,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1},gi=await Hm(),ve={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"},ue=ve,ph=ve.red,qr=ve.green,gh=ve.yellow,Kr=ve.blue,yh=ve.magenta,bh=ve.cyan,ri=ve.white,xh=ve.gray,Vr=ve.bgRed,Hr=ve.bgYellow,oi=ve.bold,wh=ve.dim,Rh=ve.italic,kh=ve.underline,$h=ve.reset,ln={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},ko={debug:"\uD83D\uDD0D",info:Kr("\u2139"),success:qr("\u2713"),warning:Hr(ri(oi(" WARN "))),error:Vr(ri(oi(" ERROR ")))},Ph=new dn("stacks"),Ie=new dn("bunfig",{showTags:!0}),vh=Ce(Tt.cwd(),"config"),Ih=Ce(Tt.cwd(),"src/generated"),Zr=un.env.CLARITY_LOG_DIR||ym(Ym(),"logs"),an={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Zr,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},yi=await Xm(),xe={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=xe,Mh=xe.red,Gr=xe.green,Ch=xe.yellow,Jr=xe.blue,Sh=xe.magenta,Eh=xe.cyan,li=xe.white,Lh=xe.gray,Yr=xe.bgRed,Xr=xe.bgYellow,Th=xe.bgGray,ai=xe.bold,Ah=xe.dim,Oh=xe.italic,_h=xe.underline,Dh=xe.strikethrough,Fh=xe.reset,cn={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},$o={debug:"\uD83D\uDD0D",info:Jr("\u2139"),success:Gr("\u2713"),warning:Xr(li(ai(" WARN "))),error:Yr(li(ai(" ERROR ")))},Nh=new gn("stacks"),Le=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}`}},yn=class extends Le{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})}},At=class extends Le{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}},bi=class extends Le{code="CONFIG_VALIDATION_ERROR";constructor(n,t,s){super(`Configuration validation failed for "${n}"`,{configPath:n,configName:s,validationErrors:t,errorCount:t.length})}},xi=class extends Le{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}},bn=class extends Le{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})}},wi=class extends Le{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}},Ri=class extends Le{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}},Ot=class extends Le{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})}},ki=class extends Le{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})}},$i=class extends Le{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}},Ye={configNotFound(e,n,t){return new yn(e,n,t)},configLoad(e,n,t){return new At(e,n,t)},configValidation(e,n,t){return new bi(e,n,t)},configMerge(e,n,t,s){return new xi(e,n,t,s)},envVar(e,n,t,s){return new bn(e,n,t,s)},fileSystem(e,n,t){return new wi(e,n,t)},typeGeneration(e,n,t){return new Ri(e,n,t)},schemaValidation(e,n,t){return new Ot(e,n,t)},browserConfig(e,n,t,s){return new ki(e,n,t,s)},plugin(e,n,t){return new $i(e,n,t)}},Po={replace:"replace",concat:"concat",smart:"smart"},vo=/^https?:\/\//,De=new gn("bunfig",{showTags:!0}),Ze=new Ei,Io=Se(it.cwd(),"config"),Mo=Se(it.cwd(),"src/generated")});function zh(e,n={}){let t=xn.cwd();while(t.includes("storage"))t=Qr(t,"..");let s=Qr(t,e||"");if(n?.relative)return Uh(xn.cwd(),s);return s}var qh=xn.env.CLARITY_LOG_DIR||jh(zh(),"logs"),Co={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:qh,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},wn={...Co},hy=(async()=>{try{let{loadConfig:e}=await Bh().then(()=>ao),n=await e({name:"clarity",alias:"logging",defaultConfig:Co,cwd:xn.cwd()});if(n)Object.assign(wn,n)}catch{}return wn})();function we(){if(He.env.NODE_ENV==="test"||He.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function ed(){if(He.env.NODE_ENV==="test"||He.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof He<"u"){let e=He.type;if(e==="renderer"||e==="worker")return!1;return!!(He.versions&&(He.versions.node||He.versions.bun))}return!1}class So{async format(e){let n=await ed(),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:wt.pid,hostname:n(),environment:wt.env.NODE_ENV||"development",platform:wt.platform,version:wt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:wt.env.NODE_ENV||wt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}var ke={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"},ae=ke,Py=ke.red,td=ke.green,vy=ke.yellow,nd=ke.blue,Iy=ke.magenta,My=ke.cyan,oo=ke.white,Cy=ke.gray,sd=ke.bgRed,id=ke.bgYellow,Sy=ke.bgGray,lo=ke.bold,Ey=ke.dim,Ly=ke.italic,Ty=ke.underline,Ay=ke.strikethrough,Oy=ke.reset,mi={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},rd={debug:"\uD83D\uDD0D",info:nd("\u2139"),success:td("\u2713"),warning:id(oo(lo(" WARN "))),error:sd(oo(lo(" ERROR ")))};class rt{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={...wn},this.options=this.normalizeOptions(n),this.formatter=this.options.formatter||new So,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{...mi,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...mi};return{...mi,...e.fingersCrossed}}normalizeOptions(e){let n={format:"json",level:"info",logDirectory:wn.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!we()&&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 Gh(this.config.logDirectory,so.F_OK|so.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await Jh(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:qe.from(e);try{if(!tn(this.currentLogFile))await fi(this.currentLogFile,"",{mode:420});if(i=no(this.currentLogFile,"a",420),Zh(i,a,{flag:"a"}),to(i),i!==void 0)ui(i),i=void 0;if((await bt(this.currentLogFile)).size===0){if(await fi(this.currentLogFile,a,{flag:"w",mode:420}),(await bt(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{ui(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 xt(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return xt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return xt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(we())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 ci(16).toString("hex")}generateKey(){return ci(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=ci(16),s=Kh("aes-256-gcm",n,t),i=qe.isBuffer(e)?e:qe.from(e,"utf8"),r=s.update(i),o=s.final(),l=r.length+o.length,a=s.getAuthTag(),c=qe.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=ro(),i=[];s.on("data",(r)=>i.push(r)),s.on("end",()=>n(qe.from(qe.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(we())return;if(!this.shouldWriteToFile())return;let e=await bt(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 nn(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 bt(t).catch(()=>null))try{if(await io(t,l),n.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await sn(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 fi(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 bt(t).catch(()=>null))await io(t,r)}if(this.currentLogFile=s,n.maxFiles){let r=(await nn(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,l)=>l.localeCompare(o));for(let o of r.slice(n.maxFiles))await sn(xt(this.config.logDirectory,o))}}}async compressLogFile(e,n){let t=eo(e),s=Hh(n),i=ro();await Qh(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()})),tn(this.currentLogFile))try{let e=no(this.currentLogFile,"r+");to(e),ui(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(!we()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let n=(await nn(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of n)try{await sn(xt(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()?ae.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||we())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} ${ae.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=ae.underline(ae.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)=>ae.bgGray(s)),n=n.replace(/\*\*([^*]+)\*\*/g,(t,s)=>ae.bold(s)),n=n.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(t,s)=>ae.italic(s)),n=n.replace(/(?<!_)_([^_]+)_(?!_)/g,(t,s)=>ae.italic(s)),n=n.replace(/~([^~]+)~/g,(t,s)=>ae.strikethrough(s)),n}supportsHyperlinks(){if(we())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(Yh(n)||n.startsWith("./")||n.startsWith("../"))n=Xh(n);else return null;return tn(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?"":rd[e],m=this.options.showTags!==!1&&this.name?ae.gray(this.formatTag(this.name)):"",h;switch(e){case"debug":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:ae.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:ae.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(`
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 Ro,Rt,_t,ko,gh,yh,qr,on,gi,ve,ue,bh,Kr,xh,Vr,wh,Rh,ri,kh,Hr,Zr,oi,$h,Ph,vh,Ih,ln,$o,Mh,Ie,Ch,Sh,Gr,an,yi,xe,oe,Eh,Jr,Lh,Yr,Th,Ah,li,Oh,Xr,Qr,_h,ai,Dh,Fh,Nh,Wh,Bh,cn,Po,jh,Uh="0.15.6",Le,yn,At,bi,xi,bn,wi,Ri,Ot,ki,$i,Ye,vo,Io,De,Ze,Mo,Co,zh=gm(async()=>{Ro=import.meta.require,Rt=new Pi,_t=new vi,ko={createKey:qm,isEquivalent:Km,estimateMemoryUsage:Vm},gh=mn(di.cwd(),"config"),yh=mn(di.cwd(),"src/generated"),qr=fn.env.CLARITY_LOG_DIR||km(Gm(),"logs"),on={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:qr,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1},gi=await Jm(),ve={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"},ue=ve,bh=ve.red,Kr=ve.green,xh=ve.yellow,Vr=ve.blue,wh=ve.magenta,Rh=ve.cyan,ri=ve.white,kh=ve.gray,Hr=ve.bgRed,Zr=ve.bgYellow,oi=ve.bold,$h=ve.dim,Ph=ve.italic,vh=ve.underline,Ih=ve.reset,ln={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},$o={debug:"\uD83D\uDD0D",info:Vr("\u2139"),success:Kr("\u2713"),warning:Zr(ri(oi(" WARN "))),error:Hr(ri(oi(" ERROR ")))},Mh=new dn("stacks"),Ie=new dn("bunfig",{showTags:!0}),Ch=Ce(Tt.cwd(),"config"),Sh=Ce(Tt.cwd(),"src/generated"),Gr=un.env.CLARITY_LOG_DIR||wm(eh(),"logs"),an={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Gr,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},yi=await th(),xe={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=xe,Eh=xe.red,Jr=xe.green,Lh=xe.yellow,Yr=xe.blue,Th=xe.magenta,Ah=xe.cyan,li=xe.white,Oh=xe.gray,Xr=xe.bgRed,Qr=xe.bgYellow,_h=xe.bgGray,ai=xe.bold,Dh=xe.dim,Fh=xe.italic,Nh=xe.underline,Wh=xe.strikethrough,Bh=xe.reset,cn={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Po={debug:"\uD83D\uDD0D",info:Yr("\u2139"),success:Jr("\u2713"),warning:Qr(li(ai(" WARN "))),error:Xr(li(ai(" ERROR ")))},jh=new gn("stacks"),Le=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}`}},yn=class extends Le{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})}},At=class extends Le{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}},bi=class extends Le{code="CONFIG_VALIDATION_ERROR";constructor(n,t,s){super(`Configuration validation failed for "${n}"`,{configPath:n,configName:s,validationErrors:t,errorCount:t.length})}},xi=class extends Le{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}},bn=class extends Le{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})}},wi=class extends Le{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}},Ri=class extends Le{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}},Ot=class extends Le{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})}},ki=class extends Le{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})}},$i=class extends Le{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}},Ye={configNotFound(e,n,t){return new yn(e,n,t)},configLoad(e,n,t){return new At(e,n,t)},configValidation(e,n,t){return new bi(e,n,t)},configMerge(e,n,t,s){return new xi(e,n,t,s)},envVar(e,n,t,s){return new bn(e,n,t,s)},fileSystem(e,n,t){return new wi(e,n,t)},typeGeneration(e,n,t){return new Ri(e,n,t)},schemaValidation(e,n,t){return new Ot(e,n,t)},browserConfig(e,n,t,s){return new ki(e,n,t,s)},plugin(e,n,t){return new $i(e,n,t)}},vo={replace:"replace",concat:"concat",smart:"smart"},Io=/^https?:\/\//,De=new gn("bunfig",{showTags:!0}),Ze=new Ei,Mo=Se(it.cwd(),"config"),Co=Se(it.cwd(),"src/generated")});function Vh(e,n={}){let t=xn.cwd();while(t.includes("storage"))t=eo(t,"..");let s=eo(t,e||"");if(n?.relative)return Kh(xn.cwd(),s);return s}var Hh=xn.env.CLARITY_LOG_DIR||qh(Vh(),"logs"),So={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Hh,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},wn={...So},gy=(async()=>{try{let{loadConfig:e}=await zh().then(()=>co),n=await e({name:"clarity",alias:"logging",defaultConfig:So,cwd:xn.cwd()});if(n)Object.assign(wn,n)}catch{}return wn})();function we(){if(He.env.NODE_ENV==="test"||He.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function sd(){if(He.env.NODE_ENV==="test"||He.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof He<"u"){let e=He.type;if(e==="renderer"||e==="worker")return!1;return!!(He.versions&&(He.versions.node||He.versions.bun))}return!1}class Eo{async format(e){let n=await sd(),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:wt.pid,hostname:n(),environment:wt.env.NODE_ENV||"development",platform:wt.platform,version:wt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:wt.env.NODE_ENV||wt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}var ke={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"},ae=ke,My=ke.red,id=ke.green,Cy=ke.yellow,rd=ke.blue,Sy=ke.magenta,Ey=ke.cyan,lo=ke.white,Ly=ke.gray,od=ke.bgRed,ld=ke.bgYellow,Ty=ke.bgGray,ao=ke.bold,Ay=ke.dim,Oy=ke.italic,_y=ke.underline,Dy=ke.strikethrough,Fy=ke.reset,mi={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},ad={debug:"\uD83D\uDD0D",info:rd("\u2139"),success:id("\u2713"),warning:ld(lo(ao(" WARN "))),error:od(lo(ao(" ERROR ")))};class rt{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={...wn},this.options=this.normalizeOptions(n),this.formatter=this.options.formatter||new Eo,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{...mi,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...mi};return{...mi,...e.fingersCrossed}}normalizeOptions(e){let n={format:"json",level:"info",logDirectory:wn.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!we()&&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 Xh(this.config.logDirectory,io.F_OK|io.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await Qh(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:qe.from(e);try{if(!tn(this.currentLogFile))await fi(this.currentLogFile,"",{mode:420});if(i=so(this.currentLogFile,"a",420),Yh(i,a,{flag:"a"}),no(i),i!==void 0)ui(i),i=void 0;if((await bt(this.currentLogFile)).size===0){if(await fi(this.currentLogFile,a,{flag:"w",mode:420}),(await bt(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{ui(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 xt(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return xt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return xt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(we())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 ci(16).toString("hex")}generateKey(){return ci(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=ci(16),s=Zh("aes-256-gcm",n,t),i=qe.isBuffer(e)?e:qe.from(e,"utf8"),r=s.update(i),o=s.final(),l=r.length+o.length,a=s.getAuthTag(),c=qe.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=oo(),i=[];s.on("data",(r)=>i.push(r)),s.on("end",()=>n(qe.from(qe.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(we())return;if(!this.shouldWriteToFile())return;let e=await bt(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 nn(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 bt(t).catch(()=>null))try{if(await ro(t,l),n.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await sn(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 fi(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 bt(t).catch(()=>null))await ro(t,r)}if(this.currentLogFile=s,n.maxFiles){let r=(await nn(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,l)=>l.localeCompare(o));for(let o of r.slice(n.maxFiles))await sn(xt(this.config.logDirectory,o))}}}async compressLogFile(e,n){let t=to(e),s=Jh(n),i=oo();await nd(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()})),tn(this.currentLogFile))try{let e=so(this.currentLogFile,"r+");no(e),ui(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(!we()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let n=(await nn(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of n)try{await sn(xt(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()?ae.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||we())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} ${ae.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=ae.underline(ae.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)=>ae.bgGray(s)),n=n.replace(/\*\*([^*]+)\*\*/g,(t,s)=>ae.bold(s)),n=n.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(t,s)=>ae.italic(s)),n=n.replace(/(?<!_)_([^_]+)_(?!_)/g,(t,s)=>ae.italic(s)),n=n.replace(/~([^~]+)~/g,(t,s)=>ae.strikethrough(s)),n}supportsHyperlinks(){if(we())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(ed(n)||n.startsWith("./")||n.startsWith("../"))n=td(n);else return null;return tn(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?"":ad[e],m=this.options.showTags!==!1&&this.name?ae.gray(this.formatTag(this.name)):"",h;switch(e){case"debug":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:ae.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:ae.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
41
  `);for(let p of d)if(p.trim()&&!p.includes(o))console.error(this.formatConsoleMessage({timestamp:i,message:ae.gray(` ${p}`),level:e,showTimestamp:!1}))}break}}else if(!we()){if(console.error(`${r} ${this.environment}.${e.toUpperCase()}: ${o}`),l)console.error(l)}let u=`${r} ${this.environment}.${e.toUpperCase()}: ${c}
42
42
  `;if(l)u+=`${l}
43
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()&&!we()&&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()&&!we()&&re.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(l)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,l)},interrupt:(l,a="info")=>{if(!we()&&re.stdout.isTTY)re.stdout.write(`
44
44
  `);if(this[a==="warning"?"warn":a](l),this.activeProgressBar&&this.shouldStyleConsole()&&!we()&&re.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let n=performance.now();if(this.shouldStyleConsole()){let t=this.options.showTags!==!1&&this.name?ae.gray(this.formatTag(this.name)):"",s=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:s,icon:this.options.showIcons===!1?"":ae.blue("\u25D0"),tag:t,message:`${ae.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?ae.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:this.options.showIcons===!1?"":ae.green("\u2713"),tag:u,message:`${r}${t?` ${JSON.stringify(t)}`:""}`}))}else if(!we())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 rt(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(we())throw Error("createReadStream is not supported in browser environments");if(!tn(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return eo(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=qe.isBuffer(e)?e:qe.from(e,"base64"),i=s.subarray(0,16),r=s.subarray(s.length-16),o=s.subarray(16,s.length-16),l=Vh("aes-256-gcm",t,i);l.setAuthTag(r);let a=l.update(o),c=l.final(),u=a.length+c.length,f=qe.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 we()}isServerMode(){return!we()}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(`
45
+ `,c=c.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let u=this.options.showTags!==!1&&this.name?ae.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:this.options.showIcons===!1?"":ae.green("\u2713"),tag:u,message:`${r}${t?` ${JSON.stringify(t)}`:""}`}))}else if(!we())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 rt(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(we())throw Error("createReadStream is not supported in browser environments");if(!tn(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return to(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=qe.isBuffer(e)?e:qe.from(e,"base64"),i=s.subarray(0,16),r=s.subarray(s.length-16),o=s.subarray(16,s.length-16),l=Gh("aes-256-gcm",t,i);l.setAuthTag(r);let a=l.update(o),c=l.final(),u=a.length+c.length,f=qe.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 we()}isServerMode(){return!we()}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
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:ae.cyan(m),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:t,message:ae.cyan(c),showTimestamp:!1})),f.forEach((m)=>console.error(m)),console.error(this.formatConsoleMessage({timestamp:t,message:ae.cyan(u),showTimestamp:!1}))}else if(!we())console.error(`${s} ${this.environment}.INFO: [BOX] ${r}`);let o=`${s} ${this.environment}.INFO: [BOX] ${r}
47
47
  `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(o)}async prompt(e){if(we())return Promise.resolve(!0);return new Promise((n)=>{console.error(`${ae.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?ae.gray(this.formatTag(this.name)):"",c=this.options.showIcons===!1?"":`${ae.blue("\u25D0")} `;console.error(`${c}${a} ${ae.cyan(s)}`)}let l=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${i}
48
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=ae.green("\u2501".repeat(s)),o=ae.gray("\u2501".repeat(i)),l=`[${r}${o}]`,a=`${t}%`.padStart(4),c=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":n||t===100?ae.green("\u2713"):ae.blue("\u25B6"),f=this.options.showTags!==!1&&this.name?` ${ae.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||we()||!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(we()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let n=await nn(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=xt(this.config.logDirectory,s);if(e.before)try{if((await bt(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 sn(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 _y=new rt("stacks");import{readFileSync as zf,writeFileSync as ng}from"fs";import{isAbsolute as sg,relative as jf,resolve as ig}from"path";var $n={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 R=x===o?y:s[x];for(let k=0;k<R.length;k++){let M=R[k];if(M==="{")g++;if(M==="}"){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(R.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 R=0;R<x.length;R++){let k=x[R];if(k==="{")p++,y=!0;else if(k==="}"){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 Pn={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 vn={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 In={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 Mn={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 Cn={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 Sn={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 En={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 Ln={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 Tn={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 Dt={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=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.filter((o,l)=>!i.has(l)).join(`
49
+ `)}finishProgressBar(e,n){if(!this.enabled||!this.fancy||we()||!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(we()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let n=await nn(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=xt(this.config.logDirectory,s);if(e.before)try{if((await bt(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 sn(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 Ny=new rt("stacks");import{readFileSync as Vf,writeFileSync as rg}from"fs";import{isAbsolute as og,relative as qf,resolve as lg}from"path";var $n={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 R=x===o?y:s[x];for(let k=0;k<R.length;k++){let M=R[k];if(M==="{")g++;if(M==="}"){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(R.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 R=0;R<x.length;R++){let k=x[R];if(k==="{")p++,y=!0;else if(k==="}"){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 Pn={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 vn={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 In={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 Mn={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 Cn={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 Sn={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 En={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 Ln={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 Tn={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 Dt={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=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.filter((o,l)=>!i.has(l)).join(`
50
50
  `)}};var An={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 On={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 _n={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 Dn={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 Fn={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 Nn={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 Ft={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=Ft.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
51
  `)}};var Wn={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 Bn={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
52
  `):e}};var jn={meta:{docs:"Disallow undeclared variables",recommended:!0,wip:!0},check:(e,n)=>[]};var Un={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 zn={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 qn={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 Kn={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 Eo=["undefined","object","boolean","number","string","function","symbol","bigint"],Vn={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(!Eo.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(!Eo.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 Hn={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 Zn={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 Gn={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 Jn={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 Yn={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 Xn={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 Qn={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 es={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 ts={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 ns={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 ss={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 is={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 rs={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 od=["Object","Array","String","Number","Boolean","Date","RegExp","Function","Math","JSON","Promise","Map","Set","WeakMap","WeakSet","Symbol","Proxy","Reflect","Error","TypeError","RangeError"],os={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 od){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 ls={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 ld=["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"],as={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 ld){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 cs={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 us={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 Nt={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(Nt.check(e,n).length===0)return e;return e}};var fs={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 ms={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 hs={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(`
53
+ `):e}};var Lo=["undefined","object","boolean","number","string","function","symbol","bigint"],Vn={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(!Lo.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(!Lo.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 Hn={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 Zn={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 Gn={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 Jn={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 Yn={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 Xn={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 Qn={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 es={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 ts={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 ns={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 ss={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 is={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 rs={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 cd=["Object","Array","String","Number","Boolean","Date","RegExp","Function","Math","JSON","Promise","Map","Set","WeakMap","WeakSet","Symbol","Proxy","Reflect","Error","TypeError","RangeError"],os={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 cd){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 ls={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 ud=["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"],as={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 ud){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 cs={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 us={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 Nt={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(Nt.check(e,n).length===0)return e;return e}};var fs={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 ms={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 hs={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
54
  `):e}};var ds={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 ps={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 gs={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 ys={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 bs={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 xs={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 ws={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 Rs={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 ks={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 $s={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 Lo=["/","(",")","[","]","{","}","<",">",":","@","#","$","%","&","=","+","-","*","?","!",";",",","|","~","`","^"],Ps={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 Lo){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 Lo){let s=`\\${t}`;n=n.replace(new RegExp(s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),t)}return n}};var vs={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 Wt={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=Wt.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(`
55
+ `):e}};var ys={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 bs={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 xs={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 ws={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 Rs={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 ks={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 $s={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 To=["/","(",")","[","]","{","}","<",">",":","@","#","$","%","&","=","+","-","*","?","!",";",",","|","~","`","^"],Ps={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 To){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 To){let s=`\\${t}`;n=n.replace(new RegExp(s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),t)}return n}};var vs={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 Wt={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=Wt.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
56
  `)}};var Is={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 Ms={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 Cs={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 Ss={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 To=/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/;function b(e){return{meta:e.meta,check:(n,t)=>{if(!To.test(t.filePath))return[];return e.check(n,t)},fix:e.fix?(n,t)=>{if(!To.test(t.filePath))return n;return e.fix(n,t)}:void 0}}var Ao=/\.(?:sh|bash|zsh|ksh|dash)$/,Oo=/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/;function de(e){return{meta:e.meta,check:(n,t)=>{if(!Ao.test(t.filePath)&&!Oo.test(n))return[];return e.check(n,t)},fix:e.fix?(n,t)=>{if(!Ao.test(t.filePath)&&!Oo.test(n))return n;return e.fix(n,t)}:void 0}}var _o=/(?:^|[/\\])package\.json$/;function ge(e){return{meta:e.meta,check:(n,t)=>{if(!_o.test(t.filePath))return[];return e.check(n,t)},fix:e.fix?(n,t)=>{if(!_o.test(t.filePath))return n;return e.fix(n,t)}:void 0}}var Do={name:"eslint",rules:{"array-callback-return":b($n),"constructor-super":b(Pn),"for-direction":b(vn),"getter-return":b(In),"no-async-promise-executor":b(Mn),"no-compare-neg-zero":b(Cn),"no-cond-assign":b(Sn),"no-constant-condition":b(Ln),"no-const-assign":b(En),"no-dupe-class-members":b(Tn),"no-dupe-keys":b(Dt),"no-duplicate-case":b(An),"no-empty-pattern":b(On),"no-fallthrough":b(_n),"no-loss-of-precision":b(Dn),"no-promise-executor-return":b(Fn),"no-redeclare":b(Nn),"no-self-assign":b(Ft),"no-self-compare":b(Wn),"no-sparse-arrays":b(Bn),"no-undef":b(jn),"no-unsafe-negation":b(zn),"no-unreachable":b(Un),"no-useless-catch":b(qn),"use-isnan":b(Kn),"valid-typeof":b(Vn),"default-case":b(Zn),eqeqeq:b(Gn),"no-alert":b(Xn),"no-await-in-loop":b(Qn),"no-caller":b(es),"no-case-declarations":b(ts),"no-else-return":b(ns),"no-empty":b(ss),"no-empty-function":b(is),"no-eval":b(rs),"no-extend-native":b(os),"no-global-assign":b(as),"no-implied-eval":b(cs),"no-iterator":b(us),"no-new":b(fs),"no-new-func":b(ms),"no-new-wrappers":b(hs),"no-octal":b(ds),"no-param-reassign":b(ps),"no-proto":b(gs),"no-return-assign":b(ys),"no-shadow":b(xs),"no-throw-literal":b(ws),"no-use-before-define":b(Rs),"no-useless-call":b(ks),"no-with":b(Ms),"require-await":b(Ss),complexity:b(Hn),"max-depth":b(Jn),"max-lines-per-function":b(Yn),"no-extra-boolean-cast":b(ls),"no-lonely-if":b(Nt),"no-sequences":b(bs),"no-useless-concat":b($s),"no-useless-escape":b(Ps),"no-useless-rename":b(vs),"no-useless-return":b(Wt),"no-var":b(Is),"prefer-arrow-callback":b(Cs)}};var Fo={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]:" ",R=y+6<p.length?p[y+6]:" ";if(/\w/.test(x)||/\w/.test(R))continue;let k=p.slice(y+6).trim();if(k.startsWith("this;")||k==="this")continue;if(k===";"||k==="")continue;let M=h.indexOf("return");t.push({filePath:n.filePath,line:m+1,column:M+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 No={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 Wo={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 Bo={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 jo=new Set(["|","&",":",",","<"]),ad=new Set(["(",",","=",":","[","!","&","|","?","{","}",";","+","-","*","%","<",">","~","^"]),cd=["return","typeof","instanceof","in","of","new","delete","void","case","do","else","yield","await"];function ud(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(ad.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 cd.includes(r)}return!1}return!0}function Es(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 fd(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]!==`
57
+ `)};var Ms={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 Cs={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 Ss={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 Ao=/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/;function b(e){return{meta:e.meta,check:(n,t)=>{if(!Ao.test(t.filePath))return[];return e.check(n,t)},fix:e.fix?(n,t)=>{if(!Ao.test(t.filePath))return n;return e.fix(n,t)}:void 0}}var Oo=/\.(?:sh|bash|zsh|ksh|dash)$/,_o=/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/;function de(e){return{meta:e.meta,check:(n,t)=>{if(!Oo.test(t.filePath)&&!_o.test(n))return[];return e.check(n,t)},fix:e.fix?(n,t)=>{if(!Oo.test(t.filePath)&&!_o.test(n))return n;return e.fix(n,t)}:void 0}}var Do=/(?:^|[/\\])package\.json$/;function ge(e){return{meta:e.meta,check:(n,t)=>{if(!Do.test(t.filePath))return[];return e.check(n,t)},fix:e.fix?(n,t)=>{if(!Do.test(t.filePath))return n;return e.fix(n,t)}:void 0}}var Fo={name:"eslint",rules:{"array-callback-return":b($n),"constructor-super":b(Pn),"for-direction":b(vn),"getter-return":b(In),"no-async-promise-executor":b(Mn),"no-compare-neg-zero":b(Cn),"no-cond-assign":b(Sn),"no-constant-condition":b(Ln),"no-const-assign":b(En),"no-dupe-class-members":b(Tn),"no-dupe-keys":b(Dt),"no-duplicate-case":b(An),"no-empty-pattern":b(On),"no-fallthrough":b(_n),"no-loss-of-precision":b(Dn),"no-promise-executor-return":b(Fn),"no-redeclare":b(Nn),"no-self-assign":b(Ft),"no-self-compare":b(Wn),"no-sparse-arrays":b(Bn),"no-undef":b(jn),"no-unsafe-negation":b(zn),"no-unreachable":b(Un),"no-useless-catch":b(qn),"use-isnan":b(Kn),"valid-typeof":b(Vn),"default-case":b(Zn),eqeqeq:b(Gn),"no-alert":b(Xn),"no-await-in-loop":b(Qn),"no-caller":b(es),"no-case-declarations":b(ts),"no-else-return":b(ns),"no-empty":b(ss),"no-empty-function":b(is),"no-eval":b(rs),"no-extend-native":b(os),"no-global-assign":b(as),"no-implied-eval":b(cs),"no-iterator":b(us),"no-new":b(fs),"no-new-func":b(ms),"no-new-wrappers":b(hs),"no-octal":b(ds),"no-param-reassign":b(ps),"no-proto":b(gs),"no-return-assign":b(ys),"no-shadow":b(xs),"no-throw-literal":b(ws),"no-use-before-define":b(Rs),"no-useless-call":b(ks),"no-with":b(Ms),"require-await":b(Ss),complexity:b(Hn),"max-depth":b(Jn),"max-lines-per-function":b(Yn),"no-extra-boolean-cast":b(ls),"no-lonely-if":b(Nt),"no-sequences":b(bs),"no-useless-concat":b($s),"no-useless-escape":b(Ps),"no-useless-rename":b(vs),"no-useless-return":b(Wt),"no-var":b(Is),"prefer-arrow-callback":b(Cs)}};var No={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]:" ",R=y+6<p.length?p[y+6]:" ";if(/\w/.test(x)||/\w/.test(R))continue;let k=p.slice(y+6).trim();if(k.startsWith("this;")||k==="this")continue;if(k===";"||k==="")continue;let M=h.indexOf("return");t.push({filePath:n.filePath,line:m+1,column:M+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 Wo={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 Bo={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 jo={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 Uo=new Set(["|","&",":",",","<"]),fd=new Set(["(",",","=",":","[","!","&","|","?","{","}",";","+","-","*","%","<",">","~","^"]),md=["return","typeof","instanceof","in","of","new","delete","void","case","do","else","yield","await"];function hd(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(fd.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 md.includes(r)}return!1}return!0}function Es(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 Li(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
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]!=="*"&&ud(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===`
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]!=="*"&&hd(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
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 Xe={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=fd(e),c=a.split(/\r?\n/),u=a,f=Array(c.length).fill(!1);(()=>{let P=[],C=!1,O=!1,I=!1,N=!1,T=!1,_="",S=()=>{if(_==="")return!0;if("=([{,;!&|?:+-*/%^~<>".includes(_))return!0;return!1};for(let A=0;A<c.length;A++){f[A]=P.length>0&&P[P.length-1]===-1;let F=c[A];for(let L=0;L<F.length;L++){let w=F[L];if(N){if(w==="*"&&L+1<F.length&&F[L+1]==="/")N=!1,L++;continue}if(T){T=!1;continue}let E=P.length>0&&P[P.length-1]===-1,v=P.length>0&&P[P.length-1]>=0;if(w==="\\"&&(C||O||I||E)){T=!0;continue}if(C){if(w==="'")C=!1;continue}if(O){if(w==='"')O=!1;continue}if(I){if(w==="["){let D=1,Y=L+1;while(Y<F.length){let V=F[Y];if(V==="\\"){Y+=2;continue}if(V==="]"){if(D--,D===0)break}Y++}L=Y;continue}if(w==="/"){I=!1;while(L+1<F.length&&/[gimsuvy]/.test(F[L+1]))L++}continue}if(E){if(w==="`")P.pop();else if(w==="$"&&L+1<F.length&&F[L+1]==="{")P.push(0),L++;continue}if(w==="/"&&L+1<F.length&&F[L+1]==="/")break;if(w==="/"&&L+1<F.length&&F[L+1]==="*"){N=!0,L++;continue}if(v){if(w==="`")P.push(-1),_="";else if(w==="'")C=!0,_="'";else if(w==='"')O=!0,_='"';else if(w==="{")P[P.length-1]++,_="{";else if(w==="}"){let D=P[P.length-1];if(D>0)P[P.length-1]=D-1;else P.pop();_="}"}else if(w==="/"&&S())I=!0;else if(!/\s/.test(w))_=w;continue}if(w==="`")P.push(-1),_="";else if(w==="'")C=!0,_="'";else if(w==='"')O=!0,_='"';else if(w==="/"&&S())I=!0;else if(!/\s/.test(w))_=w}}})();let h=new RegExp("^\\s*(?:const|let|var)\\s+(.+?);?\\s*$");for(let P=0;P<c.length;P++){if(f[P])continue;let C=c[P],O=C.match(h);if(!O)continue;let I=O[1],N=[],T="",_=0,S=0,A=null,F=!1;for(let L=0;L<I.length;L++){let w=I[L];if(F){F=!1,T+=w;continue}if(w==="\\"&&A){F=!0,T+=w;continue}if(!A){if(w==="/"&&I[L+1]==="/")break;if(w==="/"&&I[L+1]==="*"){L+=2;while(L<I.length&&!(I[L]==="*"&&I[L+1]==="/"))L++;L++;continue}if(w==="'")A="single";else if(w==='"')A="double";else if(w==="`")A="template";else if(w==="<")S++;else if(w===">")S--;else if(w==="("||w==="["||w==="{")_++;else if(w===")"||w==="]"||w==="}")_--;else if(w===","&&_===0&&S===0){N.push(T),T="";continue}}else if(A==="single"&&w==="'"||A==="double"&&w==='"'||A==="template"&&w==="`")A=null;T+=w}if(T)N.push(T);for(let L of N){let w=L.trim();if(!w)continue;let E=w.match(/^([$A-Z_][\w$]*)/i),v=[];if(E)v.push(E[1]);else if(w.startsWith("{")||w.startsWith("[")){let D=w[0],Y=D==="{"?"}":"]",V=0,W=-1,B=null,J=!1;for(let le=0;le<w.length;le++){let K=w[le];if(J){J=!1;continue}if(K==="\\"&&B){J=!0;continue}if(!B){if(K==="'"||K==='"'||K==="`")B=K==="'"?"single":K==='"'?"double":"template";else if(K===D)V++;else if(K===Y){if(V--,V===0){W=le;break}}}else if(B==="single"&&K==="'"||B==="double"&&K==='"'||B==="template"&&K==="`")B=null}if(W>0){let le=w.slice(1,W),K=[],te="",pe=0,U=null,Z=!1;for(let H=0;H<le.length;H++){let z=le[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==="[")pe++;if(z===")"||z==="}"||z==="]")pe--;if(z===","&&pe===0){K.push(te.trim()),te="";continue}}else if(U==="single"&&z==="'"||U==="double"&&z==='"'||U==="template"&&z==="`")U=null;te+=z}if(te.trim())K.push(te.trim());for(let H of K){if(H.startsWith("...")){let Re=H.slice(3).match(/^([$A-Z_][\w$]*)/i);if(Re)v.push(Re[1]);continue}let z=H.indexOf(":");if(z!==-1){let Re=H.slice(z+1).trim(),ye=0;for(let Ue=0;Ue<Re.length;Ue++){let Me=Re[Ue];if(Me==="("||Me==="{"||Me==="[")ye++;else if(Me===")"||Me==="}"||Me==="]")ye--;else if(Me==="="&&ye===0){Re=Re.slice(0,Ue).trim();break}}let Et=Re.match(/^([$A-Z_][\w$]*)/i);if(Et)v.push(Et[1])}else{let Re=H,ye=0;for(let Ue=0;Ue<Re.length;Ue++){let Me=Re[Ue];if(Me==="("||Me==="{"||Me==="[")ye++;else if(Me===")"||Me==="}"||Me==="]")ye--;else if(Me==="="&&ye===0){Re=Re.slice(0,Ue).trim();break}}let Et=Re.match(/^([$A-Z_][\w$]*)/i);if(Et)v.push(Et[1])}}}}for(let D of v){if(o.test(D))continue;let Y=`${c.slice(0,P).join(`
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 Xe={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=Li(e),c=a.split(/\r?\n/),u=a,f=Array(c.length).fill(!1);(()=>{let P=[],C=!1,O=!1,I=!1,N=!1,T=!1,_="",S=()=>{if(_==="")return!0;if("=([{,;!&|?:+-*/%^~<>".includes(_))return!0;return!1};for(let A=0;A<c.length;A++){f[A]=P.length>0&&P[P.length-1]===-1;let F=c[A];for(let L=0;L<F.length;L++){let w=F[L];if(N){if(w==="*"&&L+1<F.length&&F[L+1]==="/")N=!1,L++;continue}if(T){T=!1;continue}let E=P.length>0&&P[P.length-1]===-1,v=P.length>0&&P[P.length-1]>=0;if(w==="\\"&&(C||O||I||E)){T=!0;continue}if(C){if(w==="'")C=!1;continue}if(O){if(w==='"')O=!1;continue}if(I){if(w==="["){let D=1,Y=L+1;while(Y<F.length){let V=F[Y];if(V==="\\"){Y+=2;continue}if(V==="]"){if(D--,D===0)break}Y++}L=Y;continue}if(w==="/"){I=!1;while(L+1<F.length&&/[gimsuvy]/.test(F[L+1]))L++}continue}if(E){if(w==="`")P.pop();else if(w==="$"&&L+1<F.length&&F[L+1]==="{")P.push(0),L++;continue}if(w==="/"&&L+1<F.length&&F[L+1]==="/")break;if(w==="/"&&L+1<F.length&&F[L+1]==="*"){N=!0,L++;continue}if(v){if(w==="`")P.push(-1),_="";else if(w==="'")C=!0,_="'";else if(w==='"')O=!0,_='"';else if(w==="{")P[P.length-1]++,_="{";else if(w==="}"){let D=P[P.length-1];if(D>0)P[P.length-1]=D-1;else P.pop();_="}"}else if(w==="/"&&S())I=!0;else if(!/\s/.test(w))_=w;continue}if(w==="`")P.push(-1),_="";else if(w==="'")C=!0,_="'";else if(w==='"')O=!0,_='"';else if(w==="/"&&S())I=!0;else if(!/\s/.test(w))_=w}}})();let h=new RegExp("^\\s*(?:const|let|var)\\s+(.+?);?\\s*$");for(let P=0;P<c.length;P++){if(f[P])continue;let C=c[P],O=C.match(h);if(!O)continue;let I=O[1],N=[],T="",_=0,S=0,A=null,F=!1;for(let L=0;L<I.length;L++){let w=I[L];if(F){F=!1,T+=w;continue}if(w==="\\"&&A){F=!0,T+=w;continue}if(!A){if(w==="/"&&I[L+1]==="/")break;if(w==="/"&&I[L+1]==="*"){L+=2;while(L<I.length&&!(I[L]==="*"&&I[L+1]==="/"))L++;L++;continue}if(w==="'")A="single";else if(w==='"')A="double";else if(w==="`")A="template";else if(w==="<")S++;else if(w===">")S--;else if(w==="("||w==="["||w==="{")_++;else if(w===")"||w==="]"||w==="}")_--;else if(w===","&&_===0&&S===0){N.push(T),T="";continue}}else if(A==="single"&&w==="'"||A==="double"&&w==='"'||A==="template"&&w==="`")A=null;T+=w}if(T)N.push(T);for(let L of N){let w=L.trim();if(!w)continue;let E=w.match(/^([$A-Z_][\w$]*)/i),v=[];if(E)v.push(E[1]);else if(w.startsWith("{")||w.startsWith("[")){let D=w[0],Y=D==="{"?"}":"]",V=0,W=-1,B=null,J=!1;for(let le=0;le<w.length;le++){let K=w[le];if(J){J=!1;continue}if(K==="\\"&&B){J=!0;continue}if(!B){if(K==="'"||K==='"'||K==="`")B=K==="'"?"single":K==='"'?"double":"template";else if(K===D)V++;else if(K===Y){if(V--,V===0){W=le;break}}}else if(B==="single"&&K==="'"||B==="double"&&K==='"'||B==="template"&&K==="`")B=null}if(W>0){let le=w.slice(1,W),K=[],te="",pe=0,U=null,Z=!1;for(let H=0;H<le.length;H++){let z=le[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==="[")pe++;if(z===")"||z==="}"||z==="]")pe--;if(z===","&&pe===0){K.push(te.trim()),te="";continue}}else if(U==="single"&&z==="'"||U==="double"&&z==='"'||U==="template"&&z==="`")U=null;te+=z}if(te.trim())K.push(te.trim());for(let H of K){if(H.startsWith("...")){let Re=H.slice(3).match(/^([$A-Z_][\w$]*)/i);if(Re)v.push(Re[1]);continue}let z=H.indexOf(":");if(z!==-1){let Re=H.slice(z+1).trim(),ye=0;for(let Ue=0;Ue<Re.length;Ue++){let Me=Re[Ue];if(Me==="("||Me==="{"||Me==="[")ye++;else if(Me===")"||Me==="}"||Me==="]")ye--;else if(Me==="="&&ye===0){Re=Re.slice(0,Ue).trim();break}}let Et=Re.match(/^([$A-Z_][\w$]*)/i);if(Et)v.push(Et[1])}else{let Re=H,ye=0;for(let Ue=0;Ue<Re.length;Ue++){let Me=Re[Ue];if(Me==="("||Me==="{"||Me==="[")ye++;else if(Me===")"||Me==="}"||Me==="]")ye--;else if(Me==="="&&ye===0){Re=Re.slice(0,Ue).trim();break}}let Et=Re.match(/^([$A-Z_][\w$]*)/i);if(Et)v.push(Et[1])}}}}for(let D of v){if(o.test(D))continue;let Y=`${c.slice(0,P).join(`
62
62
  `)}
63
63
  ${c.slice(P+1).join(`
64
64
  `)}`;if(!new RegExp(`\\b${D}\\b`,"g").test(Y))t.push({filePath:n.filePath,line:P+1,column:Math.max(1,C.indexOf(D)+1),ruleId:"pickier/no-unused-vars",message:`'${D}' 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 (_${D}) to mark it as intentionally unused`})}}}let d=(P)=>{let O=((T)=>{let _="",S=null,A=!1,F=0;for(let L=0;L<T.length;L++){let w=T[L];if(A){A=!1;continue}if(w==="\\"&&S){A=!0;continue}if(!S){if(w==="'")S="single";else if(w==='"')S="double";else if(w==="`")S="template";else if(w==="("||w==="{"||w==="[")F++;else if(w===")"||w==="}"||w==="]")F--;else if(w==="="&&F===0)return _}else if(S==="single"&&w==="'"||S==="double"&&w==='"'||S==="template"&&w==="`")S=null;_+=w}return _})(P);return((T)=>{let _="",S=0;while(S<T.length){let A=T[S];if(A===":"){S++;while(S<T.length&&/\s/.test(T[S]))S++;let F=0,L=0,w=null,E=!1;while(S<T.length){let v=T[S];if(E){E=!1,S++;continue}if(v==="\\"&&w){E=!0,S++;continue}if(!w){if(v==="'")w="single";else if(v==='"')w="double";else if(v==="`")w="template";else if(v==="<")L++;else if(v===">")L--;else if(v==="("||v==="{"||v==="[")F++;else if(v===")"||v==="}"||v==="]")if(F>0)F--;else break;else if(v===","&&F===0&&L===0)break}else if(w==="single"&&v==="'"||w==="double"&&v==='"'||w==="template"&&v==="`")w=null;S++}continue}_+=A,S++}return _})(O).split(/[^$\w]+/).filter((T)=>T&&T!=="undefined")},p=(P,C)=>{let O=/^\s*(?:export\s+)?(?:default\s+)?(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function\b|class\b|const\b|let\b|var\b|interface\b|type\b)/;for(let I=P;I<c.length;I++){let T=(I===P?c[I].slice(C+1):c[I]).replace(/\/\/.*$/,"");if(I!==P&&O.test(T))return!0;if(T.includes("{"))return!1;if(T.includes(";"))return!0}return!0},g=(P,C)=>{let O=!1,I=0,N=0,T=!1,_=0,S=null,A=!1,F=!0,L="",w=!1,E=!1,v=[],D=!1;for(let Y=P;Y<c.length;Y++){let V=c[Y],W=V,B=v.length>0&&v[v.length-1]===-1,J=-1,le=null,K=!1;if(!B)for(let U=0;U<V.length-1;U++){let Z=V[U],H=V[U+1];if(K){K=!1;continue}if(Z==="\\"&&le){K=!0;continue}if(!le){if(Z==="'")le="single";else if(Z==='"')le="double";else if(Z==="`")le="template";else if(Z==="/"&&H==="/"){J=U;break}}else if(le==="single"&&Z==="'"||le==="double"&&Z==='"'||le==="template"&&Z==="`")le=null}if(J>=0)W=V.slice(0,J);let te=(U)=>{let Z="",H=0,z=null,Re=!1;while(H<U.length){let ye=U[H];if(Re){Re=!1,Z+=ye,H++;continue}if(ye==="\\"&&z){Re=!0,Z+=ye,H++;continue}if(!z){if(ye==="'")z="single";else if(ye==='"')z="double";else if(ye==="`")z="template";else if(ye==="/"){if(Es(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"&&ye==="'"||z==="double"&&ye==='"'||z==="template"&&ye==="`")z=null;Z+=ye,H++}return Z};if(!B)W=te(W);let pe=0;if(!O){let U=-1,Z=F?typeof C==="number"?C:0:0;if(F=!1,Z>=W.length){let H=W.indexOf("=>");Z=H>=0?H+2:0}for(let H=Z;H<W.length;H++){let z=W[H];if(A){A=!1;continue}if(z==="\\"&&S){A=!0;continue}if(!S){if(z!==" "&&z!=="\t"&&z!==`
65
- `&&z!=="\r"&&z!=="{"&&z!=="}"&&N===0)L=z;if(z==="'")S="single";else if(z==='"')S="double";else if(z==="`")S="template";else if(z==="<")_++;else if(z===">")_=Math.max(0,_-1);else if(z==="{"){if(N===0){if(T&&_===0&&!jo.has(L)){U=H;break}}N++}else if(z==="}"){if(N>0){if(N--,N===0)T=!0,L="}"}}}else if(S==="single"&&z==="'"||S==="double"&&z==='"'||S==="template"&&z==="`")S=null}if(U===-1){if(_>0)continue;if(N>0&&jo.has(L))continue;for(let H=Z;H<W.length;H++)if(W[H]==="{"&&!S){U=H;break}}if(U===-1)continue;O=!0,I=1,pe=U+1,P=Y}for(let U=pe;U<W.length;U++){let Z=W[U];if(D){D=!1;continue}let H=v.length>0&&v[v.length-1]===-1,z=v.length>0&&v[v.length-1]>=0;if(Z==="\\"&&(w||E||H)){D=!0;continue}if(w){if(Z==="'")w=!1;continue}if(E){if(Z==='"')E=!1;continue}if(H){if(Z==="`")v.pop();else if(Z==="$"&&U+1<W.length&&W[U+1]==="{")v[v.length-1]=0,U++;continue}if(z){if(Z==="/"){if(Es(W,U)){U++;while(U<W.length){if(W[U]==="\\"){U+=2;continue}if(W[U]==="/"){while(U+1<W.length&&/[gimsuvy]/.test(W[U+1]))U++;break}U++}continue}}if(Z==="`"){v.push(-1);continue}if(Z==="'"){w=!0;continue}if(Z==='"'){E=!0;continue}if(Z==="{"){v[v.length-1]++;continue}if(Z==="}")if(v[v.length-1]>0)v[v.length-1]--;else v[v.length-1]=-1;continue}if(Z==="'")w=!0;else if(Z==='"')E=!0;else if(Z==="`")v.push(-1);else if(Z==="{")I++;else if(Z==="}"){if(I--,I===0)return{from:P,to:Y}}}}return null},y=(P,C)=>{let O={parenDepth:0,braceDepth:0,bracketDepth:0,inTemplate:!1},I=(F)=>{for(let L=0;L<F.length;L++){let w=F[L];if(w==="`")O.inTemplate=!O.inTemplate;else if(w==="(")O.parenDepth++;else if(w===")")O.parenDepth--;else if(w==="{")O.braceDepth++;else if(w==="}")O.braceDepth--;else if(w==="[")O.bracketDepth++;else if(w==="]")O.bracketDepth--}},N=()=>O.parenDepth>0||O.braceDepth>0||O.bracketDepth>0||O.inTemplate,T=(F)=>/(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)$/.test(F.trimEnd()),_=(F)=>/^(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)/.test(F.trimStart()),S=c[P].slice(C+2);I(S);let A=P+1;while(A<c.length){let F=A===P+1?S:c[A-1];if(!(!S.trim()||N()||T(F)||_(c[A])))break;S+=`
65
+ `&&z!=="\r"&&z!=="{"&&z!=="}"&&N===0)L=z;if(z==="'")S="single";else if(z==='"')S="double";else if(z==="`")S="template";else if(z==="<")_++;else if(z===">")_=Math.max(0,_-1);else if(z==="{"){if(N===0){if(T&&_===0&&!Uo.has(L)){U=H;break}}N++}else if(z==="}"){if(N>0){if(N--,N===0)T=!0,L="}"}}}else if(S==="single"&&z==="'"||S==="double"&&z==='"'||S==="template"&&z==="`")S=null}if(U===-1){if(_>0)continue;if(N>0&&Uo.has(L))continue;for(let H=Z;H<W.length;H++)if(W[H]==="{"&&!S){U=H;break}}if(U===-1)continue;O=!0,I=1,pe=U+1,P=Y}for(let U=pe;U<W.length;U++){let Z=W[U];if(D){D=!1;continue}let H=v.length>0&&v[v.length-1]===-1,z=v.length>0&&v[v.length-1]>=0;if(Z==="\\"&&(w||E||H)){D=!0;continue}if(w){if(Z==="'")w=!1;continue}if(E){if(Z==='"')E=!1;continue}if(H){if(Z==="`")v.pop();else if(Z==="$"&&U+1<W.length&&W[U+1]==="{")v[v.length-1]=0,U++;continue}if(z){if(Z==="/"){if(Es(W,U)){U++;while(U<W.length){if(W[U]==="\\"){U+=2;continue}if(W[U]==="/"){while(U+1<W.length&&/[gimsuvy]/.test(W[U+1]))U++;break}U++}continue}}if(Z==="`"){v.push(-1);continue}if(Z==="'"){w=!0;continue}if(Z==='"'){E=!0;continue}if(Z==="{"){v[v.length-1]++;continue}if(Z==="}")if(v[v.length-1]>0)v[v.length-1]--;else v[v.length-1]=-1;continue}if(Z==="'")w=!0;else if(Z==='"')E=!0;else if(Z==="`")v.push(-1);else if(Z==="{")I++;else if(Z==="}"){if(I--,I===0)return{from:P,to:Y}}}}return null},y=(P,C)=>{let O={parenDepth:0,braceDepth:0,bracketDepth:0,inTemplate:!1},I=(F)=>{for(let L=0;L<F.length;L++){let w=F[L];if(w==="`")O.inTemplate=!O.inTemplate;else if(w==="(")O.parenDepth++;else if(w===")")O.parenDepth--;else if(w==="{")O.braceDepth++;else if(w==="}")O.braceDepth--;else if(w==="[")O.bracketDepth++;else if(w==="]")O.bracketDepth--}},N=()=>O.parenDepth>0||O.braceDepth>0||O.bracketDepth>0||O.inTemplate,T=(F)=>/(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)$/.test(F.trimEnd()),_=(F)=>/^(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)/.test(F.trimStart()),S=c[P].slice(C+2);I(S);let A=P+1;while(A<c.length){let F=A===P+1?S:c[A-1];if(!(!S.trim()||N()||T(F)||_(c[A])))break;S+=`
66
66
  ${c[A]}`,I(c[A]),A++}return S},x=[],R=!1,k=!1,M=!1;for(let P=0;P<c.length;P++){let C=c[P];if(/^\s*\/\//.test(C))continue;if(f[P])continue;let O=C,I=null,N=!1,T=!1;for(let w=0;w<C.length-1;w++){let E=C[w],v=C[w+1];if(T){T=!1;continue}if(E==="\\"&&(I||N)){T=!0;continue}if(!I&&!N){if(E==="'")I="single";else if(E==='"')I="double";else if(E==="`")I="template";else if(E==="/"){if(Es(C,w))N=!0;else if(v==="/"){O=C.slice(0,w);break}}}else if(I){if(I==="single"&&E==="'"||I==="double"&&E==='"'||I==="template"&&E==="`")I=null}else if(N&&E==="/")N=!1}let A=((w)=>{let E="",v=0;while(v<w.length){if(w[v]==="/"){if(Es(w,v)){v++;while(v<w.length){if(w[v]==="\\"){v+=2;continue}if(w[v]==="/"){v++;while(v<w.length&&/[gimsuvy]/.test(w[v]))v++;break}v++}continue}}E+=w[v],v++}return E})(O).replace(/'(?:[^'\\]|\\.)*'/g,"''").replace(/"(?:[^"\\]|\\.)*"/g,'""');{let w="";for(let E=0;E<A.length;E++){let v=A[E];if(M){M=!1;let V=x.length>0&&x[x.length-1]===-1;w+=V?" ":v;continue}let D=x.length>0&&x[x.length-1]===-1,Y=x.length>0&&x[x.length-1]>=0;if(v==="\\"&&(R||k||D)){M=!0,w+=D?" ":v;continue}if(R){if(v==="'")R=!1;w+=v;continue}if(k){if(v==='"')k=!1;w+=v;continue}if(D){if(v==="`")x.pop();else if(v==="$"&&E+1<A.length&&A[E+1]==="{")x[x.length-1]=0,w+=" ",E++;else w+=" ";continue}if(Y){if(v==="`")x.push(-1),w+=" ";else if(v==="'")R=!0,w+=v;else if(v==='"')k=!0,w+=v;else if(v==="{")x[x.length-1]++,w+=v;else if(v==="}")if(x[x.length-1]>0)x[x.length-1]--,w+=v;else x[x.length-1]=-1,w+=" ";else w+=v;continue}if(v==="`")x.push(-1),w+=" ";else if(v==="'")R=!0,w+=v;else if(v==='"')k=!0,w+=v;else w+=v}A=w}let F=A.match(/\bfunction\b/);if(F){if(C.includes("function scanContent")||C.includes("function findMatching"))continue;if(A.slice(F.index+8).trimStart().startsWith(":"))continue;let E=A.slice(0,F.index).trimEnd();if(E.endsWith(".")||E.endsWith("?."))continue;let v=F.index,D=C.indexOf("(",v);if(D===-1)continue;let Y=0,V=-1,W=P,B="";for(let te=P;te<c.length;te++){let pe=te===P?c[te]:c[te],U=te===P?D:0;for(let Z=U;Z<pe.length;Z++)if(pe[Z]==="(")Y++;else if(pe[Z]===")"){if(Y--,Y===0){if(V=Z,W=te,P===te)B=C.slice(D+1,V);else{B=C.slice(D+1);for(let H=P+1;H<te;H++)B+=` ${c[H]}`;B+=` ${pe.slice(0,V)}`}break}}if(V!==-1)break}if(V===-1)continue;if(p(W,V))continue;let J=d(B),le=g(W,V),K="";if(le)if(le.from===W){let te=c[le.from],pe=te.lastIndexOf("{"),U=pe>=0?te.slice(pe+1):"";if(le.to>le.from)K=`${U}
67
67
  ${c.slice(le.from+1,le.to+1).join(`
68
68
  `)}`;else K=U}else K=c.slice(le.from,le.to+1).join(`
@@ -74,131 +74,133 @@ ${c.slice(K.from+1,K.to+1).join(`
74
74
  ${c.slice(K.from+1,K.to+1).join(`
75
75
  `)}`;else B=U}else B=c.slice(K.from,K.to+1).join(`
76
76
  `)}else B=y(P,W);if(!new RegExp(`\\b${v}\\b`,"g").test(B))t.push({filePath:n.filePath,line:P+1,column:Math.max(1,C.indexOf(v)+1),ruleId:"pickier/no-unused-vars",message:`'${v}' is defined but never used (function parameter). Allowed unused args must match pattern: ${r}`,severity:"error"})}}}return t},fix:(e,n)=>{let t=Xe.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=(R)=>p.some(([k,M])=>R>k&&R<M),y=[];for(let R of m){let k=R.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),M=new RegExp(`(?<=[(,]\\s*)\\b${k}\\b(?=\\s*[,):=])`,"g"),P;while((P=M.exec(d))!==null){if(g(P.index))continue;y.push({start:P.index,end:P.index+R.length,name:R})}}if(y.length===0)continue;y.sort((R,k)=>k.start-R.start);let x=d;for(let R of y)x=`${x.slice(0,R.start)}_${R.name}${x.slice(R.end)}`;if(x!==d)a[h]=x,u=!0}return u?a.join(`
77
- `):e}};function Qe(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 R=m[x];if(R==="\\"){x+=2;continue}if(R==="]"){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 md(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 hd(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 dd(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 Uo(e,n){let t=new RegExp("^\\s*(?:let|var)\\s+(.+?);?\\s*$"),s=e.match(t);if(!s)return null;let i=s[1],r=hd(i);if(r>=0){let a=i.indexOf(":");if(a>=0&&a<r)i=i.slice(0,a)+i.slice(r)}let o=md(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((O)=>O.replace(/[|\\^$*+?.(){}[\]]/g,(I)=>`\\${I}`)).join("|")})`,x=new RegExp(y).test(p),R=new RegExp(`(?:^|[^$w])(?:\\+\\+|--)\\s*${m}\\b|\\b${m}\\s*(?:\\+\\+|--)`).test(p),k=dd(p,m),M=c.indexOf("="),P=M>=0?c.slice(M+1):"",C=new RegExp(y).test(P);l.push({name:m,fixable:!x&&!R&&!k&&!C})}return l}var Ls={meta:{docs:"Suggest 'const' for variables that are never reassigned (heuristic)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=Qe(e);for(let r=0;r<s.length;r++){if(i[r])continue;let o=s[r],l=Uo(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=Qe(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=Uo(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 zo={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,R=0,k=0,M=null,P=!1;for(let O=1;O<g.length;O++){let I=g[O];if(P){P=!1;continue}if(I==="\\"&&M){P=!0;continue}if(!M){if(I==="'")M="single";else if(I==='"')M="double";else if(I==="`")M="template";else if(I==="(")x++;else if(I===")"){if(x--,x===0)break}else if(I==="{")R++;else if(I==="}")R--;else if(I==="[")k++;else if(I==="]")k--;else if(I===","&&x===1&&R===0&&k===0){y=O;break}}else if(M==="single"&&I==="'"||M==="double"&&I==='"'||M==="template"&&I==="`")M=null}if(y===-1)continue;let C=g.slice(1,y).trim();if(C==="{}")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(C==="{}"||/^\{.*\}$/.test(C))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 pd(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 Ts={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(pd(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 qo={name:"general",rules:{"array-callback-return":b($n),"constructor-super":b(Pn),"for-direction":b(vn),"getter-return":b(In),"no-async-promise-executor":b(Mn),"no-compare-neg-zero":b(Cn),"no-cond-assign":b(Sn),"no-const-assign":b(En),"no-constant-condition":b(Ln),"no-constructor-return":b(Fo),"no-dupe-class-members":b(Tn),"no-dupe-keys":b(Dt),"no-duplicate-case":b(An),"no-empty-pattern":b(On),"no-fallthrough":b(_n),"no-irregular-whitespace":b(No),"no-loss-of-precision":b(Dn),"no-new":b(Wo),"no-regex-spaces":b(Bo),"no-promise-executor-return":b(Fn),"no-redeclare":b(Nn),"no-self-assign":b(Ft),"no-self-compare":b(Wn),"no-sparse-arrays":b(Bn),"no-undef":b(jn),"no-unsafe-negation":b(zn),"no-unreachable":b(Un),"no-unused-vars":b(Xe),"no-useless-catch":b(qn),"prefer-const":b(Ls),"prefer-object-spread":b(zo),"prefer-template":b(Ts),"use-isnan":b(Kn),"valid-typeof":b(Vn)}};var Bt={npm:"registry.npmjs.org",yarn:"registry.yarnpkg.com",verdaccio:"registry.verdaccio.org"};function Ko(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 We(e,n){let t=Ko(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 gd(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)Vo(t.dependencies,n,"");return{type:"npm",packages:n}}function Vo(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)Vo(i.dependencies,n,r)}}function yd(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 bd(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 Be(e,n){let t=Ko(n);if(!t)return null;try{switch(t){case"npm":return gd(e);case"yarn":return yd(e);case"bun":return bd(e);default:return null}}catch{return null}}function Ho(e){try{return new URL(e).hostname}catch{return null}}function As(e){try{return new URL(e).protocol}catch{return null}}function Zo(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 Go(e){if(!e)return null;let n=e.match(/^(sha\d+)-/);return n?n[1]:null}function Jo(e){return e.map((n)=>{let t=n.toLowerCase();return Bt[t]||n})}var Xo={meta:{docs:"Ensure all packages are from allowed registry hosts",recommended:!0},check(e,n){let t=[];if(!We(e,n.filePath))return t;let s=Be(e,n.filePath);if(!s)return t;let i=n.options||{},r=i.allowedHosts||["npm","yarn"],o=i.emptyHostname!==!1,l=Jo(r),a=e.split(`
82
- `);for(let[c,u]of s.packages){if(!u.resolved){if(!o){let m=Yo(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=Ho(u.resolved);if(!f)continue;if(!l.includes(f)){let m=Yo(a,c),h=r.map((d)=>Bt[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 Yo(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 HTTPS protocol",recommended:!0},check(e,n){let t=[];if(!We(e,n.filePath))return t;let s=Be(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=As(o.resolved);if(!l)continue;if(l!=="https:"){let a=xd(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 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 all packages use strong integrity hashes (SHA512)",recommended:!0},check(e,n){let t=[];if(!We(e,n.filePath))return t;let s=Be(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=Go(f.integrity);if(!m)continue;if((l[m.toLowerCase()]||0)<a){let d=wd(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 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 package names match their resolved URLs",recommended:!0},check(e,n){let t=[];if(!We(e,n.filePath))return t;let s=Be(e,n.filePath);if(!s)return t;let r=(n.options||{}).aliases||{},o=Object.values(Bt),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=Zo(c.resolved);if(!f)continue;let m=c.name,h=r[m]||m;if(f!==h){let d=Rd(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 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={meta:{docs:"Ensure all packages use allowed URL schemes",recommended:!0},check(e,n){let t=[];if(!We(e,n.filePath))return t;let s=Be(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=As(c.resolved);if(!u)continue;if(!o.includes(u)){let f=kd(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 kd(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 sl={name:"lockfile",rules:{"validate-host":Xo,"validate-https":Qo,"validate-integrity":el,"validate-package-names":tl,"validate-scheme":nl}};var il={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 rl={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 ol={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 j(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 ll(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 kt(e,n){let t="";return ll(e,(s)=>{t+=n(s)},(s)=>{t+=s}),t}function et(e){let n="";return ll(e,(t)=>{n+=t},(t)=>{n+=" ".repeat(t.length)}),n}function al(e){let n=j(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=et(r),c=$d(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)+et(r.slice(l)))}return t}function $d(e){let n=/(?<!`)(`+)(?!`)(?=[^`]*$)/.exec(e);return n?{index:n.index,length:n[1].length}:null}function ot(e){let n=new Set,t=j(e);for(let s=0;s<e.length;s++){if(t.has(s))continue;let i=e[s];if(!Pd(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 Pd(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 cl={meta:{docs:"Tables should be surrounded by blank lines"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=!1,o=ot(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=j(n),s=ot(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 ul={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 fl(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 ml={meta:{docs:"Code fence style should be consistent (backtick or tilde)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=fl(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=fl(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 hl={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 dl={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 Li="(?<!\\*)\\*(?!\\*)(?!\\s)([^*]*[^*\\s])\\*(?!\\*)",vd=new RegExp(Li),Ti="(?<![A-Za-z0-9_])_(?!_)([^_]+)_(?![A-Za-z0-9_])",Id=new RegExp(Ti),pl={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=j(s),a=al(s);for(let c=0;c<s.length;c++){let u=s[c];if(l.has(c))continue;let f=a[c]??et(u),m=f.matchAll(new RegExp(Li,"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(Ti,"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=j(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=et(i[f]);if(a===null){let h=m.match(vd);if(h)a={line:f,col:h.index}}if(c===null){let h=m.match(Id);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=kt(i[a],(u)=>o==="asterisk"?u.replace(new RegExp(Ti,"g"),"*$1*"):u.replace(new RegExp(Li,"g"),"_$1_"));if(c!==i[a])i[a]=c,l=!0}return l?i.join(`
92
- `):e}};var gl={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 yl={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 bl={meta:{docs:"Heading levels should only increment by one level at a time"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(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 xl={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 wl={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=j(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=j(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 Rl={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 kl={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 Md(e){return e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s/g,"-")}var $l={meta:{docs:"Link fragments should reference valid headings"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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(Md(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 Pl={meta:{docs:"Link and image reference definitions should be used"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(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 vl={meta:{docs:"Link and image style should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=Ai(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=Ai(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=j(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=Ai(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(),R=o.get(x);if(!R)return d;let k=R.title?` "${R.title}"`:"";return`${p}[${g}](${R.url}${k})`});if(h===f)break;f=h}if(f!==u)i[c]=f,a=!0}return a?i.join(`
97
- `):e}};function Ai(e){return e.replace(/(`+)([^`]+?)\1/g,(n)=>" ".repeat(n.length))}var Il={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 Ml={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 Cl={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 Sl={meta:{docs:"Bare URLs should be wrapped in angle brackets"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(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 El={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 Ll={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 Cd=/[.!?:;,]\s*$/;function Tl(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(Cd.test(o))return null;if(o.trim().split(/\s+/).length>=7)return null;return o}var Al={meta:{docs:"Emphasis should not be used for headings"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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(Tl(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=j(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=Tl(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 Ol={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 _l={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 Dl={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 Fl={meta:{docs:"ATX style headings must have a space after the hash"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(n);return n.map((i,r)=>{if(t.has(r))return i;return i.replace(/^(#{1,6})([^\s#])/,"$1 $2")}).join(`
103
- `)}};var Nl={meta:{docs:"Closed ATX style headings must have spaces inside the hashes"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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 Wl={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 Bl={meta:{docs:"ATX style headings should have only one space after the hash"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(n);return n.map((i,r)=>{if(t.has(r))return i;return i.replace(/^(#{1,6})\s{2,}/,"$1 ")}).join(`
105
- `)}};var jl={meta:{docs:"Blockquote symbols should be followed by a single space"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(n);return n.map((i,r)=>{if(t.has(r))return i;return i.replace(/^(\s*>+)\s{2,}/,"$1 ")}).join(`
106
- `)}};var Ul={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=j(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 zl={meta:{docs:"Link syntax should not be reversed"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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 ql={meta:{docs:"Code span elements should not have spaces inside the backticks"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(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 Sd=[/(?<![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],Kl={meta:{docs:"Emphasis markers should not have spaces inside them"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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 Sd)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=j(n),s=[];for(let i=0;i<n.length;i++){let r=n[i];if(t.has(i)){s.push(r);continue}let o=kt(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 Vl={meta:{docs:"Link text should not have leading or trailing spaces"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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 Hl={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 Zl={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 Gl={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 Jl={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=j(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 Yl={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 Xl={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 Ql={meta:{docs:"Document should have only one top-level heading (h1)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(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 ea={meta:{docs:"Files should end with a single newline character"},check:(e,n)=>{let t=[];if(!e.endsWith(`
77
+ `):e}};function Qe(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 R=m[x];if(R==="\\"){x+=2;continue}if(R==="]"){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 dd(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 pd(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 gd(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 zo(e,n){let t=new RegExp("^\\s*(?:let|var)\\s+(.+?);?\\s*$"),s=e.match(t);if(!s)return null;let i=s[1],r=pd(i);if(r>=0){let a=i.indexOf(":");if(a>=0&&a<r)i=i.slice(0,a)+i.slice(r)}let o=dd(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((O)=>O.replace(/[|\\^$*+?.(){}[\]]/g,(I)=>`\\${I}`)).join("|")})`,x=new RegExp(y).test(p),R=new RegExp(`(?:^|[^$w])(?:\\+\\+|--)\\s*${m}\\b|\\b${m}\\s*(?:\\+\\+|--)`).test(p),k=gd(p,m),M=c.indexOf("="),P=M>=0?c.slice(M+1):"",C=new RegExp(y).test(P);l.push({name:m,fixable:!x&&!R&&!k&&!C})}return l}var Ls={meta:{docs:"Suggest 'const' for variables that are never reassigned (heuristic)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=Qe(e);for(let r=0;r<s.length;r++){if(i[r])continue;let o=s[r],l=zo(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=Qe(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=zo(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 qo={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,R=0,k=0,M=null,P=!1;for(let O=1;O<g.length;O++){let I=g[O];if(P){P=!1;continue}if(I==="\\"&&M){P=!0;continue}if(!M){if(I==="'")M="single";else if(I==='"')M="double";else if(I==="`")M="template";else if(I==="(")x++;else if(I===")"){if(x--,x===0)break}else if(I==="{")R++;else if(I==="}")R--;else if(I==="[")k++;else if(I==="]")k--;else if(I===","&&x===1&&R===0&&k===0){y=O;break}}else if(M==="single"&&I==="'"||M==="double"&&I==='"'||M==="template"&&I==="`")M=null}if(y===-1)continue;let C=g.slice(1,y).trim();if(C==="{}")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(C==="{}"||/^\{.*\}$/.test(C))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 yd(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 Ts={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(yd(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 Ko={name:"general",rules:{"array-callback-return":b($n),"constructor-super":b(Pn),"for-direction":b(vn),"getter-return":b(In),"no-async-promise-executor":b(Mn),"no-compare-neg-zero":b(Cn),"no-cond-assign":b(Sn),"no-const-assign":b(En),"no-constant-condition":b(Ln),"no-constructor-return":b(No),"no-dupe-class-members":b(Tn),"no-dupe-keys":b(Dt),"no-duplicate-case":b(An),"no-empty-pattern":b(On),"no-fallthrough":b(_n),"no-irregular-whitespace":b(Wo),"no-loss-of-precision":b(Dn),"no-new":b(Bo),"no-regex-spaces":b(jo),"no-promise-executor-return":b(Fn),"no-redeclare":b(Nn),"no-self-assign":b(Ft),"no-self-compare":b(Wn),"no-sparse-arrays":b(Bn),"no-undef":b(jn),"no-unsafe-negation":b(zn),"no-unreachable":b(Un),"no-unused-vars":b(Xe),"no-useless-catch":b(qn),"prefer-const":b(Ls),"prefer-object-spread":b(qo),"prefer-template":b(Ts),"use-isnan":b(Kn),"valid-typeof":b(Vn)}};var Bt={npm:"registry.npmjs.org",yarn:"registry.yarnpkg.com",verdaccio:"registry.verdaccio.org"};function Vo(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 We(e,n){let t=Vo(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 bd(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)Ho(t.dependencies,n,"");return{type:"npm",packages:n}}function Ho(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)Ho(i.dependencies,n,r)}}function xd(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 wd(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 Be(e,n){let t=Vo(n);if(!t)return null;try{switch(t){case"npm":return bd(e);case"yarn":return xd(e);case"bun":return wd(e);default:return null}}catch{return null}}function Zo(e){try{return new URL(e).hostname}catch{return null}}function As(e){try{return new URL(e).protocol}catch{return null}}function Go(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 Jo(e){if(!e)return null;let n=e.match(/^(sha\d+)-/);return n?n[1]:null}function Yo(e){return e.map((n)=>{let t=n.toLowerCase();return Bt[t]||n})}var Qo={meta:{docs:"Ensure all packages are from allowed registry hosts",recommended:!0},check(e,n){let t=[];if(!We(e,n.filePath))return t;let s=Be(e,n.filePath);if(!s)return t;let i=n.options||{},r=i.allowedHosts||["npm","yarn"],o=i.emptyHostname!==!1,l=Yo(r),a=e.split(`
82
+ `);for(let[c,u]of s.packages){if(!u.resolved){if(!o){let m=Xo(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=Zo(u.resolved);if(!f)continue;if(!l.includes(f)){let m=Xo(a,c),h=r.map((d)=>Bt[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 Xo(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 all packages use HTTPS protocol",recommended:!0},check(e,n){let t=[];if(!We(e,n.filePath))return t;let s=Be(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=As(o.resolved);if(!l)continue;if(l!=="https:"){let a=Rd(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 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 tl={meta:{docs:"Ensure all packages use strong integrity hashes (SHA512)",recommended:!0},check(e,n){let t=[];if(!We(e,n.filePath))return t;let s=Be(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=Jo(f.integrity);if(!m)continue;if((l[m.toLowerCase()]||0)<a){let d=kd(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 kd(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={meta:{docs:"Ensure package names match their resolved URLs",recommended:!0},check(e,n){let t=[];if(!We(e,n.filePath))return t;let s=Be(e,n.filePath);if(!s)return t;let r=(n.options||{}).aliases||{},o=Object.values(Bt),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=Go(c.resolved);if(!f)continue;let m=c.name,h=r[m]||m;if(f!==h){let d=$d(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 $d(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 sl={meta:{docs:"Ensure all packages use allowed URL schemes",recommended:!0},check(e,n){let t=[];if(!We(e,n.filePath))return t;let s=Be(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=As(c.resolved);if(!u)continue;if(!o.includes(u)){let f=Pd(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 Pd(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 il={name:"lockfile",rules:{"validate-host":Qo,"validate-https":el,"validate-integrity":tl,"validate-package-names":nl,"validate-scheme":sl}};var rl={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 ol={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 ll={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 j(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 al(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 kt(e,n){let t="";return al(e,(s)=>{t+=n(s)},(s)=>{t+=s}),t}function et(e){let n="";return al(e,(t)=>{n+=t},(t)=>{n+=" ".repeat(t.length)}),n}function cl(e){let n=j(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=et(r),c=vd(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)+et(r.slice(l)))}return t}function vd(e){let n=/(?<!`)(`+)(?!`)(?=[^`]*$)/.exec(e);return n?{index:n.index,length:n[1].length}:null}function ot(e){let n=new Set,t=j(e);for(let s=0;s<e.length;s++){if(t.has(s))continue;let i=e[s];if(!Id(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 Id(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 ul={meta:{docs:"Tables should be surrounded by blank lines"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=!1,o=ot(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=j(n),s=ot(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 fl={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 ml(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 hl={meta:{docs:"Code fence style should be consistent (backtick or tilde)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=ml(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=ml(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 dl={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 pl={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 Ti="(?<!\\*)\\*(?!\\*)(?!\\s)([^*]*[^*\\s])\\*(?!\\*)",Md=new RegExp(Ti),Ai="(?<![A-Za-z0-9_])_(?!_)([^_]+)_(?![A-Za-z0-9_])",Cd=new RegExp(Ai),gl={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=j(s),a=cl(s);for(let c=0;c<s.length;c++){let u=s[c];if(l.has(c))continue;let f=a[c]??et(u),m=f.matchAll(new RegExp(Ti,"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(Ai,"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=j(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=et(i[f]);if(a===null){let h=m.match(Md);if(h)a={line:f,col:h.index}}if(c===null){let h=m.match(Cd);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=kt(i[a],(u)=>o==="asterisk"?u.replace(new RegExp(Ai,"g"),"*$1*"):u.replace(new RegExp(Ti,"g"),"_$1_"));if(c!==i[a])i[a]=c,l=!0}return l?i.join(`
92
+ `):e}};var yl={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 bl={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 xl={meta:{docs:"Heading levels should only increment by one level at a time"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(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 wl={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 Rl={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=j(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=j(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 kl={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 $l={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 Sd(e){return e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s/g,"-")}var Pl={meta:{docs:"Link fragments should reference valid headings"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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(Sd(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 vl={meta:{docs:"Link and image reference definitions should be used"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(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 Il={meta:{docs:"Link and image style should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=Oi(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=Oi(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=j(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=Oi(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(),R=o.get(x);if(!R)return d;let k=R.title?` "${R.title}"`:"";return`${p}[${g}](${R.url}${k})`});if(h===f)break;f=h}if(f!==u)i[c]=f,a=!0}return a?i.join(`
97
+ `):e}};function Oi(e){return e.replace(/(`+)([^`]+?)\1/g,(n)=>" ".repeat(n.length))}var Ml={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 Cl={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 Sl={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 El={meta:{docs:"Bare URLs should be wrapped in angle brackets"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(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 Ll={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 Tl={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 Ed=/[.!?:;,]\s*$/;function Al(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(Ed.test(o))return null;if(o.trim().split(/\s+/).length>=7)return null;return o}var Ol={meta:{docs:"Emphasis should not be used for headings"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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(Al(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=j(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=Al(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 _l={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 Dl={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 Fl={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 Nl={meta:{docs:"ATX style headings must have a space after the hash"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(n);return n.map((i,r)=>{if(t.has(r))return i;return i.replace(/^(#{1,6})([^\s#])/,"$1 $2")}).join(`
103
+ `)}};var Wl={meta:{docs:"Closed ATX style headings must have spaces inside the hashes"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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 Bl={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 jl={meta:{docs:"ATX style headings should have only one space after the hash"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(n);return n.map((i,r)=>{if(t.has(r))return i;return i.replace(/^(#{1,6})\s{2,}/,"$1 ")}).join(`
105
+ `)}};var Ul={meta:{docs:"Blockquote symbols should be followed by a single space"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(n);return n.map((i,r)=>{if(t.has(r))return i;return i.replace(/^(\s*>+)\s{2,}/,"$1 ")}).join(`
106
+ `)}};var zl={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=j(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 ql={meta:{docs:"Link syntax should not be reversed"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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 Kl={meta:{docs:"Code span elements should not have spaces inside the backticks"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(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 Ld=[/(?<![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],Vl={meta:{docs:"Emphasis markers should not have spaces inside them"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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 Ld)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=j(n),s=[];for(let i=0;i<n.length;i++){let r=n[i];if(t.has(i)){s.push(r);continue}let o=kt(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 Hl={meta:{docs:"Link text should not have leading or trailing spaces"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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 Zl={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 Gl={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 Jl={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 Yl={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=j(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 Xl={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 Ql={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 ea={meta:{docs:"Document should have only one top-level heading (h1)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(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 ta={meta:{docs:"Files should end with a single newline character"},check:(e,n)=>{let t=[];if(!e.endsWith(`
113
113
  `)&&!e.endsWith(`\r
114
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
115
 
116
116
  `)||e.endsWith(`\r
117
117
  \r
118
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 ta={meta:{docs:"Strong style should be consistent (asterisk or underscore)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s),o=(n.options||{}).style||"consistent",l=null;for(let a=0;a<s.length;a++){if(i.has(a))continue;let c=et(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=j(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=et(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=kt(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 na={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=ot(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=Ed(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 Ed(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 sa={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 ia={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=ot(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 ra={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 R=x.contentCol,k=x.indent+r;if(h!==R&&h!==k)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 oa={meta:{docs:"Unordered list style should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(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 Ld(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 Td(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(`
119
+ `};var na={meta:{docs:"Strong style should be consistent (asterisk or underscore)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s),o=(n.options||{}).style||"consistent",l=null;for(let a=0;a<s.length;a++){if(i.has(a))continue;let c=et(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=j(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=et(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=kt(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 sa={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=ot(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=Td(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 Td(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 ia={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 ra={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=ot(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 oa={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 R=x.contentCol,k=x.indent+r;if(h!==R&&h!==k)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 la={meta:{docs:"Unordered list style should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(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=j(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 Ad(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 Od(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
123
  `),body:n.slice(t+1).join(`
124
- `)};return{header:null,body:e}}function Ad(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 q(e){return{meta:e.meta,check:(n,t)=>{if(!t.filePath.endsWith(".md"))return[];let{text:s,frontmatterEndLine:i}=Ld(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}=Td(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 la={name:"markdown",rules:{"heading-increment":q(bl),"heading-style":q(wl),"no-missing-space-atx":q(Fl),"no-multiple-space-atx":q(Bl),"no-missing-space-closed-atx":q(Nl),"no-multiple-space-closed-atx":q(Ul),"blanks-around-headings":q(rl),"heading-start-left":q(xl),"no-duplicate-heading":q(Ll),"single-title":q(Ql),"no-trailing-punctuation":q(Hl),"ul-style":q(oa),"list-indent":q(Il),"ul-indent":q(ra),"ol-prefix":q(Gl),"list-marker-space":q(Ml),"blanks-around-lists":q(ol),"no-trailing-spaces":q(Zl),"no-hard-tabs":q(_l),"no-multiple-blanks":q(Wl),"no-multiple-space-blockquote":q(jl),"no-blanks-blockquote":q(El),"blanks-around-fences":q(il),"single-trailing-newline":Ad(ea),"blanks-around-tables":q(cl),"no-reversed-links":q(zl),"no-bare-urls":q(Sl),"no-space-in-links":q(Vl),"no-empty-links":q(Ol),"link-fragments":q($l),"reference-links-images":q(Yl),"link-image-reference-definitions":q(Pl),"link-image-style":q(vl),"descriptive-link-text":q(dl),"line-length":q(kl),"commands-show-output":q(hl),"fenced-code-language":q(gl),"code-block-style":q(ul),"code-fence-style":q(ml),"no-emphasis-as-heading":q(Al),"no-space-in-emphasis":q(Kl),"no-space-in-code":q(ql),"emphasis-style":q(pl),"strong-style":q(ta),"no-inline-html":q(Dl),"hr-style":q(Rl),"first-line-heading":q(yl),"required-headings":q(Xl),"proper-names":q(Jl),"no-alt-text":q(Cl),"table-pipe-style":q(ia),"table-column-count":q(na),"table-column-style":q(sa)}};var aa={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 ca={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 ua={name:"node",rules:{"prefer-global/buffer":b(aa),"prefer-global/process":b(ca)}};var Os={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(`
124
+ `)};return{header:null,body:e}}function _d(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 q(e){return{meta:e.meta,check:(n,t)=>{if(!t.filePath.endsWith(".md"))return[];let{text:s,frontmatterEndLine:i}=Ad(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}=Od(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 aa={name:"markdown",rules:{"heading-increment":q(xl),"heading-style":q(Rl),"no-missing-space-atx":q(Nl),"no-multiple-space-atx":q(jl),"no-missing-space-closed-atx":q(Wl),"no-multiple-space-closed-atx":q(zl),"blanks-around-headings":q(ol),"heading-start-left":q(wl),"no-duplicate-heading":q(Tl),"single-title":q(ea),"no-trailing-punctuation":q(Zl),"ul-style":q(la),"list-indent":q(Ml),"ul-indent":q(oa),"ol-prefix":q(Jl),"list-marker-space":q(Cl),"blanks-around-lists":q(ll),"no-trailing-spaces":q(Gl),"no-hard-tabs":q(Dl),"no-multiple-blanks":q(Bl),"no-multiple-space-blockquote":q(Ul),"no-blanks-blockquote":q(Ll),"blanks-around-fences":q(rl),"single-trailing-newline":_d(ta),"blanks-around-tables":q(ul),"no-reversed-links":q(ql),"no-bare-urls":q(El),"no-space-in-links":q(Hl),"no-empty-links":q(_l),"link-fragments":q(Pl),"reference-links-images":q(Xl),"link-image-reference-definitions":q(vl),"link-image-style":q(Il),"descriptive-link-text":q(pl),"line-length":q($l),"commands-show-output":q(dl),"fenced-code-language":q(yl),"code-block-style":q(fl),"code-fence-style":q(hl),"no-emphasis-as-heading":q(Ol),"no-space-in-emphasis":q(Vl),"no-space-in-code":q(Kl),"emphasis-style":q(gl),"strong-style":q(na),"no-inline-html":q(Fl),"hr-style":q(kl),"first-line-heading":q(bl),"required-headings":q(Ql),"proper-names":q(Yl),"no-alt-text":q(Sl),"table-pipe-style":q(ra),"table-column-count":q(sa),"table-column-style":q(ia)}};var ca={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 ua={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 fa={name:"node",rules:{"prefer-global/buffer":b(ca),"prefer-global/process":b(ua)}};var Os={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
126
  `),l=t.slice(s).join(`
127
127
  `),a=`${o}
128
- ${l}`;if(Oi(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)=>Oi(e)};var fa={name:"perfectionist",rules:{"sort-imports":b(Os)}};import{dirname as Od,resolve as _d}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 Dd(e,n){let t=e.split(`
129
- `),s=1,i=0;for(let r of n){let o=new RegExp(`"${Bd(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 je(e){return Od(e)}function Te(e,n){return _d(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 Fd=new RegExp(`(?:[\\s;]|^)(?:import[\\w,{}\\s*]*from|import\\s*['"*{]|export\\b\\s*(?:[*{]|default|type|function|const|var|let|async function)|import\\.meta\\b)`,"m"),Nd=new RegExp("(?:[\\s;]|^)(?:module.exports\\b|exports\\.\\w|require\\s*\\(|global\\.\\w|Object\\.(?:defineProperty|defineProperties|assign)\\s*\\(\\s*exports\\b)","m");function lt(e){let n=Wd(e),t=Fd.test(n),s=Nd.test(n);if(t&&s)return"mixed";if(t)return"ESM";if(s)return"CJS";return"unknown"}function ma(e,n){if(e.endsWith(".mjs"))return"ESM";if(e.endsWith(".cjs"))return"CJS";return n==="module"?"ESM":"CJS"}function ha(e){if(e==="ESM")return".mjs";if(e==="CJS")return".cjs";return".js"}function da(e){return e===".mjs"||e===".cjs"}function Ge(e){return e.endsWith(".js")||e.endsWith(".mjs")||e.endsWith(".cjs")}function pa(e){return/^#!\s*\//.test(e)}function Wd(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*/g,"")}function me(e,n,t,s){_i(e,n,t,s)}function _i(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++)_i(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)_i(e[r],n.concat(r),t,s)}}function G(e,n,t,s,i,r,o){return{filePath:e,line:Dd(n,t),column:1,ruleId:s,message:i,severity:r,...o&&{help:o}}}function Bd(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Di={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 Fi={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 me(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 Ni={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 me(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 Wi={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 Bi={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 me(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 ji={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 me(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&&ga(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 ga(e,n){for(let t in e){if(t===n)return!0;if(typeof e[t]==="object"&&e[t]!==null&&ga(e[t],n))return!0}return!1}var Ui={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 me(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 jd=[{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"]}],zi={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 jd){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 qi={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 Ki={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 me(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 Vi={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 Hi={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 me(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 Zi={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 me(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 Gi={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 Ji={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 Ud,readFileSync as zd}from"fs";var Yi={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=je(n.filePath),[r,o]=X(t,"bin");if(r==null)return[];if(typeof r==="string")ya(r,o,i,s,n.filePath,e);else if(typeof r==="object"){for(let l of Object.keys(r))if(typeof r[l]==="string")ya(r[l],o.concat(l),i,s,n.filePath,e)}return s}};function ya(e,n,t,s,i,r){let o=Te(t,e);if(!Ud(o))return;if(!Ge(e))return;let l;try{l=zd(o,"utf8")}catch{return}if(!pa(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 ba,readFileSync as xa}from"fs";var Xi={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=je(n.filePath),[r,o]=X(t,"exports");if(r==null)return[];me(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=Te(i,c);if(!ba(f))return;if(!Ge(c))return;let m;try{m=xa(f,"utf8")}catch{return}if(lt(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")me(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=Te(i,c);if(!ba(f))return;if(!Ge(c))return;let m;try{m=xa(f,"utf8")}catch{return}if(lt(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 jt}from"fs";import{dirname as qd,isAbsolute as Kd,resolve as Vd}from"path";function Qi(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=Kd(n)?qd(n).split("/")[0]||"/":Vd(e,s);return!jt(i)}var er={meta:{docs:"Ensure files referenced in package.json exist",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],i=je(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(Qi(i,f))continue;let h=Te(i,f);if(!Ra(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")wa(o,l,s,n.filePath,e,i);else if(typeof o==="object"){for(let u of Object.keys(o))if(typeof o[u]==="string")wa(o[u],l.concat(u),s,n.filePath,e,i)}}let[a,c]=X(t,"exports");if(a!=null)me(a,c,!1,(u,f)=>{if(typeof u!=="string")return;if(!u.startsWith("./")&&!u.startsWith("../"))return;if(u.includes("*"))return;if(Qi(i,u))return;let m=Te(i,u);if(!jt(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 wa(e,n,t,s,i,r){if(Qi(r,e))return;let o=Te(r,e);if(!Ra(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 Ra(e){if(jt(e))return!0;if(jt(`${e}.js`))return!0;if(jt(`${e}/index.js`))return!0;return!1}import{existsSync as Hd,readFileSync as Zd}from"fs";import{extname as Gd}from"path";var tr={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=je(n.filePath),r=t.type,[o,l]=X(t,"main");if(o!=null&&typeof o==="string")ka(o,l,i,r,s,n.filePath,e);let[a,c]=X(t,"exports");if(a!=null)me(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;ka(u,f.path,i,r,s,n.filePath,e)});return s}};function ka(e,n,t,s,i,r,o){let l=Te(t,e);if(!Hd(l))return;if(!Ge(e))return;let a;try{a=Zd(l,"utf8")}catch{return}let c=lt(a);if(c==="unknown"||c==="mixed")return;let u=ma(l,s);if(c===u)return;let f=Gd(l),m=ha(c),d=(da(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 Jd,readFileSync as Yd}from"fs";var nr={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=je(n.filePath),o=Te(r,s);if(!Jd(o))return[];if(!Ge(s))return[];let l;try{l=Yd(o,"utf8")}catch{return[]}if(lt(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 $a={name:"publint",rules:{"use-type":ge(Ji),"local-dependency":ge(Gi),"deprecated-field-jsnext":ge(Di),"has-module-but-no-exports":ge(qi),"field-invalid-value-type":ge(zi),"exports-types-should-be-first":ge(ji),"exports-default-should-be-last":ge(Fi),"exports-module-should-precede-require":ge(Bi),"exports-value-invalid":ge(Ui),"exports-missing-root-entrypoint":ge(Wi),"exports-fallback-array-use":ge(Ni),"imports-key-invalid":ge(Vi),"imports-value-invalid":ge(Zi),"imports-default-should-be-last":ge(Ki),"imports-module-should-precede-require":ge(Hi),"file-does-not-exist":ge(er),"file-invalid-format":ge(tr),"module-should-be-esm":ge(nr),"bin-file-not-executable":ge(Yi),"exports-module-should-be-esm":ge(Xi)}};var Pa={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 va={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 Xd,readFileSync as Qd}from"fs";import{dirname as ep,resolve as tp}from"path";var Ia={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=ep(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=tp(i,c+m);if(Xd(h)){f=Qd(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 Ma,readFileSync as np}from"fs";import{dirname as Ca,resolve as Sa}from"path";var Ea={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=np(c,"utf8"),m=a(f,Ca(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=Sa(u,d+g);if(Ma(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=Sa(Ca(i),m+p);if(Ma(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 La={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 Ta={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 Aa={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 sp}from"fs";import{dirname as ip,join as rp,resolve as op}from"path";var Oa={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=ip(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=op(i,c+h);u.push(d),u.push(rp(d,`index${h}`))}if(!u.some((h)=>sp(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 _a(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 lp=new RegExp(`^export\\s+\\{[^}]*\\}\\s+from\\s+['"][^'"]+['"];?\\s*$`);function _s(e){return lp.test(e)}var Da={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&&!_s(i[r]))r++;if(r>=i.length)break;let o=[],l=r;while(l<i.length){let a=i[l];if(_s(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)=>_a(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&&!_s(i[r]))r++;if(r>=i.length)break;let o=[],l=r;while(l<i.length){let a=i[l];if(_s(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)=>_a(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 Fa={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=(k)=>i==="asc"?k:-k,f=(k,M)=>(r?k.toLowerCase():k).localeCompare(r?M.toLowerCase():M),m=(k,M)=>(r?k.toLowerCase():k).localeCompare(r?M.toLowerCase():M,void 0,{numeric:!0}),h=(k,M)=>{if(s==="line-length")return u(k.length-M.length);if(s==="natural")return u(m(k,M));if(s==="unsorted")return 0;return u(f(k,M))},d=Object.fromEntries(Object.entries(l).map(([k,M])=>{let C=(Array.isArray(M)?M:[M]).map((O)=>new RegExp(O));return[k,C]})),p=[];for(let k of o)if(Array.isArray(k))p.push(...k);else p.push(k);if(!p.includes("unknown"))p.push("unknown");let g=(k)=>{for(let[M,P]of Object.entries(d))if(P.some((C)=>C.test(k)))return M;return"unknown"},y=(k)=>{let M=[],P=0,C="";for(let O=0;O<k.length;O++){let I=k[O];if(I==="<")P++;else if(I===">")P=Math.max(0,P-1);if(I===","&&P===0){M.push(C.trim()),C="";continue}C+=I}if(C.trim())M.push(C.trim());return M},x=(k)=>{let M=k.trim(),P=M.match(/^([A-Z_$][\w$.]*)/i);return P?P[1]:M},R=(k,M)=>{let P=y(M);if(P.length<=1)return;let C=P.map(x),O=C.map(g),I=C.map((T,_)=>({n:T,g:O[_],i:_})).sort((T,_)=>{let S=p.indexOf(T.g),A=p.indexOf(_.g);if(S!==A)return S-A;return h(T.n,_.n)}).map((T)=>T.n);if(!C.every((T,_)=>T===I[_]))c.push({filePath:n.filePath,line:k,column:1,ruleId:"sort-heritage-clauses",message:"Heritage clauses are not sorted",severity:"warning"})};for(let k=0;k<a.length;k++){let M=a[k],P=M.match(/^\s*interface\s+[A-Za-z_$][^{]*\bextends\s+(.+?)\s*\{/);if(P)R(k+1,P[1]);let C=M.match(/^\s*class\s+[A-Za-z_$][^{]*\bimplements\s+(.+?)\s*\{/);if(C)R(k+1,C[1])}return c}};var Na={meta:{docs:"Require object keys to be sorted (ESLint-compatible core rule subset)"},check:()=>[]};var Wa={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 R=x.replace(/^type\s+/,""),k=R.match(/^([\w$]+)\s+as\s+([\w$]+)$/);if(k)return o?k[2]:k[1];let M=R.match(/^([\w$]+)$/);return M?M[1]:R}),g=[...p].sort(c);if(!p.every((x,R)=>x===g[R]))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 Ba={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=[],R={startLine:p+2,props:[]},k=()=>{if(R.props.length)x.push(R);R={startLine:0,props:[]}};for(let M=0;M<y.length;M++){let P=y[M];if(o&&/^\s*$/.test(P)){k();continue}if(/^\s*\.\.\./.test(P))continue;if(/\{|\}/.test(P))continue;let C=P.match(/^\s*['"]?([\w$-]+)['"]?\s*:/);if(C){if(R.startLine===0)R.startLine=p+2+M;R.props.push({key:C[1],line:p+2+M})}}k();for(let M of x){let P=M.props.map((I)=>I.key),C=[...P].sort(c);if(!(P.length<=1||P.every((I,N)=>I===C[N]))&&M.props.length>0){let I=M.props[0];a.push({filePath:n.filePath,line:I.line,column:1,ruleId:"sort-objects",message:"Object keys are not sorted",severity:"warning"})}}u=g+1;continue}}}u++}return a}};var ja={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 ap=[[/^(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]],cp=/^([a-z0-9][-a-z0-9]{0,50}:)+(?!\[)/;function up(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 fp(e){let n=up(e);if(n.startsWith("!"))n=n.slice(1);for(let[t,s]of ap)if(t.test(n))return s;return 99}function mp(e){let n=e.match(cp);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 Ua=new Map;function za(e){let n=Ua.get(e);if(n)return n;let t={group:fp(e),variant:mp(e)};return Ua.set(e,t),t}function sr(e){return[...e].sort((n,t)=>{let s=za(n),i=za(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 hp=/\b(?:class|className|:class)\s*=\s*(?:"([^"]*?)"|'([^']*?)')/g,dp=/\b(?:class|className|:class)\s*=\s*\{`([^`]*?)`\}/g,pp=/\b(?:clsx|cn|tw|cva|tv)\s*\(\s*(?:"([^"]*?)"|'([^']*?)')/g;function gp(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 qa(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[hp,dp,pp]){t.lastIndex=0;let s;while((s=t.exec(e))!==null){let i=s[1]??s[2]??"";if(!i.trim())continue;if(gp(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 Ka(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 Va(e){let n=sr(e);return e.every((t,s)=>t===n[s])}var Ha={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=qa(e);for(let{value:i,start:r}of s){let o=Ka(i);if(o.length<2)continue;if(!Va(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: "${sr(o).join(" ")}"`,severity:"warning",help:"Run with --fix to automatically sort Tailwind classes, or reorder them manually."})}}return t},fix:(e)=>{let n=qa(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=Ka(i);if(l.length<2||Va(l))continue;let a=sr(l).join(" ");s=s.slice(0,r)+a+s.slice(o)}return s}};var Za={name:"pickier",rules:{"sort-exports":b(Da),"sort-objects":b(Ba),"sort-imports":b(Os),"sort-named-imports":b(Wa),"sort-heritage-clauses":b(Fa),"sort-keys":b(Na),"import-dedupe":b(va),"import-first":b(Pa),"import-named":b(Ia),"import-no-cycle":b(Ea),"import-no-unresolved":b(Oa),"no-import-dist":b(Ta),"no-import-node-modules-by-path":b(Aa),"no-duplicate-imports":b(La),"top-level-function":b(ja),"sort-tailwind-classes":Ha,"prefer-const":b(Ls),"prefer-template":b(Ts),"no-unused-vars":b(Xe)}};var Ga={name:"quality",rules:{"default-case":b(Zn),eqeqeq:b(Gn),"no-alert":b(Xn),"no-await-in-loop":b(Qn),"no-caller":b(es),"no-case-declarations":b(ts),"no-else-return":b(ns),"no-empty":b(ss),"no-empty-function":b(is),"no-eval":b(rs),"no-extend-native":b(os),"no-global-assign":b(as),"no-implied-eval":b(cs),"no-iterator":b(us),"no-new":b(fs),"no-new-func":b(ms),"no-new-wrappers":b(hs),"no-octal":b(ds),"no-param-reassign":b(ps),"no-proto":b(gs),"no-return-assign":b(ys),"no-shadow":b(xs),"no-throw-literal":b(ws),"no-use-before-define":b(Rs),"no-useless-call":b(ks),"no-with":b(Ms),"require-await":b(Ss),complexity:b(Hn),"max-depth":b(Jn),"max-lines-per-function":b(Yn),"no-extra-boolean-cast":b(ls),"no-lonely-if":b(Nt),"no-sequences":b(bs),"no-useless-concat":b($s),"no-useless-escape":b(Ps),"no-useless-rename":b(vs),"no-useless-return":b(Wt),"no-var":b(Is),"prefer-arrow-callback":b(Cs)}};var Ja={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 R=f.slice(1,f.lastIndexOf("/"));if(/^\s+\w/.test(R)&&/\w\s*\)/.test(R))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 yp(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 bp(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 xp(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 wp(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=yp(e,i);if(!o){let l=xp(e,i);if(l>i+1)i=l;else i++;continue}if(!bp(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 Ya={meta:{docs:"Flags regex literals with unused capturing groups (context-aware)",recommended:!1},check(e,n){return wp(e,n)}};var Xa={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 Qa={name:"regexp",rules:{"no-super-linear-backtracking":b(Ja),"no-unused-capturing-group":b(Ya),"no-useless-lazy":b(Xa)}};var ec={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 tc={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 nc={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 sc={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 ic={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 rc={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 oc={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 Rp=[/^\s*(?:local|export|declare|typeset|readonly)\s+/,/\[\[.*\]\]/,/\(\(.*\)\)/],ir=/^\$(?:\{[A-Za-z_]\w*(?:[:#%\/][^}]*)?\}|[A-Za-z_]\w*)/,lc={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=Ee(l);if(a){if(i=!0,r=a,new RegExp(`<<-?\\s*['"]${a}['"]`).test(l))continue}if(l.replace(/^\s+/,"").startsWith("#"))continue;if(Rp.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(ir);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(ir);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(ir);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 ac={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 cc(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 uc(e){return/^(?:fi|done|esac|elif|else)\b/.test(e)||/^\}/.test(e)||/^;[;&]\s*$/.test(e)}var fc={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(uc(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(cc(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(uc(d))o=Math.max(0,o-1);let p=i?"\t".repeat(o):" ".repeat(o*s);if(r.push(p+d),cc(d,c))o++}return r.join(`
140
- `)}};var mc={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=Ee(l);if(a)i=!0,r=a;if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=Fe(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 hc={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 dc={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=Ee(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=Ee(r);if(o)t=!0,s=o;return r.replace(/[ \t]+$/,"")}).join(`
142
- `)}};var pc={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=Ee(l);if(a)i=!0,r=a;if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=Fe(l);for(let f of kp(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=Ee(r);if(o){s=!0,i=o,t.push(r);continue}if(r.replace(/^\s+/,"").startsWith("#")){t.push(r);continue}t.push($p(r))}return t.join(`
143
- `)}};function kp(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(!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 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(!yc(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 $p(e){let n=Fe(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(!gc(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(!yc(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 gc(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 yc(e,n){let t=e[n+1];if(t===void 0)return!0;return t===" "||t==="\t"||t===";"||t==="|"||t==="&"||t===")"}var Pp=/^#!\s*(?:\/usr\/bin\/env\s+(?:ba|z|k|da)?sh|\/bin\/(?:ba|z|k|da)?sh|\/usr\/bin\/(?:ba|z|k|da)?sh)\b/,bc={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(!Pp.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 xc={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=Ee(l);if(a)i=!0,r=a;if(l.replace(/^\s+/,"").startsWith("#")){o.push("");continue}o.push(Fe(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=vp(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+=Ip(d),u<0)u=0;if(f&&u===0&&/;;\s*$/.test(p))f=!1}}return t}};function vp(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 Ip(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 wc={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=Fe(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 Rc={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=Ee(l);if(a)i=!0,r=a;if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=Fe(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 kc={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 $c={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 Pc={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 vc={name:"shell",rules:{"command-substitution":de(ec),"quote-variables":de(lc),"no-cd-without-check":de(tc),"no-eval":de(nc),"no-useless-cat":de(rc),"no-ls-parsing":de(ic),"no-variable-in-single-quotes":de(oc),"no-exit-in-subshell":de(sc),shebang:de(bc),indent:de(fc),"function-style":de(ac),"operator-spacing":de(pc),"keyword-spacing":de(mc),"no-trailing-semicolons":de(hc),"no-trailing-whitespace":de(dc),"prefer-double-brackets":de(kc),"set-options":de(Pc),"prefer-printf":de($c),"consistent-case-terminators":de(xc),"no-broken-redirect":de(Rc),"heredoc-indent":de(wc)}};var Fs=null,Ds=null,rr=!1,or=!0;function Mp(){if(rr)return or;try{return Fs=(()=>{throw new Error("Cannot require module "+"@stacksjs/ts-spell-check");})(),Fs.SpellChecker.create({minWordLength:3,maxSuggestions:3}).then((e)=>{Ds=e}).catch(()=>{or=!1}),rr=!0,!0}catch{return rr=!0,or=!1,!1}}function lr(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(!Mp()||!Fs)return[];let{extractWords:i,parseDirectives:r,isSuppressed:o,getProgrammingWords:l}=Fs,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:R,offset:k}of x){if(R.length<u)continue;if(R===R.toUpperCase()&&R.length<=5)continue;if(c.has(R.toLowerCase()))continue;if(f.has(R.toLowerCase()))continue;if(o(R,y,m,c))continue;if(Ds){if(Ds.isCorrect(R))continue;let M=Ds.suggest(R);d.push({filePath:s.filePath,line:y,column:k+1,ruleId:e,message:`Unknown word: "${R}"`,severity:"warning",help:M.length?`Did you mean: ${M.slice(0,3).join(", ")}? Or add to config words.`:`Add "${R}" to your config words array, or use: // spell-check:ignore ${R}`})}}}return d}}}function Cp(e){let n=e.trimStart();return n.startsWith("//")||n.startsWith("/*")||n.startsWith("*")||n.startsWith("#")}var Ic={name:"spell",rules:{check:lr("spell/check"),"check-comments":lr("spell/check-comments",Cp),"check-markdown":{meta:{docs:"Check spelling in markdown files"},check(e,n){if(!n.filePath.endsWith(".md"))return[];return lr("spell/check-markdown").check(e,n)}}}};function Mc(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 Cc={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]==="["&&!Mc(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]==="]"&&!Mc(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 Sc=/(?<![(\[{,=:?&|+\-*/])\b([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=>/g;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 Ec={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;Sc.lastIndex=0;while((l=Sc.exec(r))!==null){let a=l.index;if(Sp(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 Ns=/=>/g;function Lc(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 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;Ns.lastIndex=0;while((l=Ns.exec(r))!==null){let a=l.index;if(Lc(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]!==`
128
+ ${l}`;if(_i(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)=>_i(e)};var ma={name:"perfectionist",rules:{"sort-imports":b(Os)}};import{dirname as Dd,resolve as Fd}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 Nd(e,n){let t=e.split(`
129
+ `),s=1,i=0;for(let r of n){let o=new RegExp(`"${Ud(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 je(e){return Dd(e)}function Te(e,n){return Fd(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 Wd=new RegExp(`(?:[\\s;]|^)(?:import[\\w,{}\\s*]*from|import\\s*['"*{]|export\\b\\s*(?:[*{]|default|type|function|const|var|let|async function)|import\\.meta\\b)`,"m"),Bd=new RegExp("(?:[\\s;]|^)(?:module.exports\\b|exports\\.\\w|require\\s*\\(|global\\.\\w|Object\\.(?:defineProperty|defineProperties|assign)\\s*\\(\\s*exports\\b)","m");function lt(e){let n=jd(e),t=Wd.test(n),s=Bd.test(n);if(t&&s)return"mixed";if(t)return"ESM";if(s)return"CJS";return"unknown"}function ha(e,n){if(e.endsWith(".mjs"))return"ESM";if(e.endsWith(".cjs"))return"CJS";return n==="module"?"ESM":"CJS"}function da(e){if(e==="ESM")return".mjs";if(e==="CJS")return".cjs";return".js"}function pa(e){return e===".mjs"||e===".cjs"}function Ge(e){return e.endsWith(".js")||e.endsWith(".mjs")||e.endsWith(".cjs")}function ga(e){return/^#!\s*\//.test(e)}function jd(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*/g,"")}function me(e,n,t,s){Di(e,n,t,s)}function Di(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++)Di(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)Di(e[r],n.concat(r),t,s)}}function G(e,n,t,s,i,r,o){return{filePath:e,line:Nd(n,t),column:1,ruleId:s,message:i,severity:r,...o&&{help:o}}}function Ud(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Fi={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 Ni={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 me(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 Wi={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 me(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 Bi={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 ji={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 me(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 Ui={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 me(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&&ya(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 ya(e,n){for(let t in e){if(t===n)return!0;if(typeof e[t]==="object"&&e[t]!==null&&ya(e[t],n))return!0}return!1}var zi={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 me(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 zd=[{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"]}],qi={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 zd){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 Ki={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 Vi={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 me(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 Hi={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 Zi={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 me(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 Gi={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 me(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 Ji={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 Yi={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 qd,readFileSync as Kd}from"fs";var Xi={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=je(n.filePath),[r,o]=X(t,"bin");if(r==null)return[];if(typeof r==="string")ba(r,o,i,s,n.filePath,e);else if(typeof r==="object"){for(let l of Object.keys(r))if(typeof r[l]==="string")ba(r[l],o.concat(l),i,s,n.filePath,e)}return s}};function ba(e,n,t,s,i,r){let o=Te(t,e);if(!qd(o))return;if(!Ge(e))return;let l;try{l=Kd(o,"utf8")}catch{return}if(!ga(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 xa,readFileSync as wa}from"fs";var Qi={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=je(n.filePath),[r,o]=X(t,"exports");if(r==null)return[];me(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=Te(i,c);if(!xa(f))return;if(!Ge(c))return;let m;try{m=wa(f,"utf8")}catch{return}if(lt(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")me(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=Te(i,c);if(!xa(f))return;if(!Ge(c))return;let m;try{m=wa(f,"utf8")}catch{return}if(lt(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 jt}from"fs";import{dirname as Vd,isAbsolute as Hd,resolve as Zd}from"path";function er(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=Hd(n)?Vd(n).split("/")[0]||"/":Zd(e,s);return!jt(i)}var tr={meta:{docs:"Ensure files referenced in package.json exist",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],i=je(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(er(i,f))continue;let h=Te(i,f);if(!ka(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")Ra(o,l,s,n.filePath,e,i);else if(typeof o==="object"){for(let u of Object.keys(o))if(typeof o[u]==="string")Ra(o[u],l.concat(u),s,n.filePath,e,i)}}let[a,c]=X(t,"exports");if(a!=null)me(a,c,!1,(u,f)=>{if(typeof u!=="string")return;if(!u.startsWith("./")&&!u.startsWith("../"))return;if(u.includes("*"))return;if(er(i,u))return;let m=Te(i,u);if(!jt(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 Ra(e,n,t,s,i,r){if(er(r,e))return;let o=Te(r,e);if(!ka(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 ka(e){if(jt(e))return!0;if(jt(`${e}.js`))return!0;if(jt(`${e}/index.js`))return!0;return!1}import{existsSync as Gd,readFileSync as Jd}from"fs";import{extname as Yd}from"path";var nr={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=je(n.filePath),r=t.type,[o,l]=X(t,"main");if(o!=null&&typeof o==="string")$a(o,l,i,r,s,n.filePath,e);let[a,c]=X(t,"exports");if(a!=null)me(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;$a(u,f.path,i,r,s,n.filePath,e)});return s}};function $a(e,n,t,s,i,r,o){let l=Te(t,e);if(!Gd(l))return;if(!Ge(e))return;let a;try{a=Jd(l,"utf8")}catch{return}let c=lt(a);if(c==="unknown"||c==="mixed")return;let u=ha(l,s);if(c===u)return;let f=Yd(l),m=da(c),d=(pa(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 Xd,readFileSync as Qd}from"fs";var sr={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=je(n.filePath),o=Te(r,s);if(!Xd(o))return[];if(!Ge(s))return[];let l;try{l=Qd(o,"utf8")}catch{return[]}if(lt(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 Pa={name:"publint",rules:{"use-type":ge(Yi),"local-dependency":ge(Ji),"deprecated-field-jsnext":ge(Fi),"has-module-but-no-exports":ge(Ki),"field-invalid-value-type":ge(qi),"exports-types-should-be-first":ge(Ui),"exports-default-should-be-last":ge(Ni),"exports-module-should-precede-require":ge(ji),"exports-value-invalid":ge(zi),"exports-missing-root-entrypoint":ge(Bi),"exports-fallback-array-use":ge(Wi),"imports-key-invalid":ge(Hi),"imports-value-invalid":ge(Gi),"imports-default-should-be-last":ge(Vi),"imports-module-should-precede-require":ge(Zi),"file-does-not-exist":ge(tr),"file-invalid-format":ge(nr),"module-should-be-esm":ge(sr),"bin-file-not-executable":ge(Xi),"exports-module-should-be-esm":ge(Qi)}};var va={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 Ia={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}};function Ma(e){let n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`(?<![\\w$])${n}(?![\\w$])`)}function ep(e,n,t){let s=[],i=/^\s*import\s+type\b/.test(e),r=e.replace(/^\s*import\s+/,"").replace(/\s+from\s+['"][^'"]+['"].*$/s,"");if(/^['"]/.test(r))return s;let o=(c,u)=>{let f=c.trim();if(!f||f==="type")return;if(!/^[A-Z_$][\w$]*$/i.test(f))return;for(let m=n;m<t.length;m++){let h=t[m].search(Ma(f));if(h!==-1){s.push({name:f,line:m+1,column:h,typeOnly:u});return}if(/\bfrom\b/.test(t[m]))break}s.push({name:f,line:n+1,column:0,typeOnly:u})},l=r.match(/\{([\s\S]*)\}/);if(l)for(let c of l[1].split(",")){let u=c.trim();if(!u)continue;let f=/^type\s+/.test(u),h=u.replace(/^type\s+/,"").split(/\s+as\s+/);o(h[h.length-1],i||f)}let a=l?r.slice(0,r.indexOf("{")):r;for(let c of a.split(",")){let u=c.trim().replace(/^type\s+/,"");if(!u)continue;let f=u.match(/^\*\s+as\s+(\w+)$/);o(f?f[1]:u,i)}return s}var Ca={meta:{docs:"Disallow imports that nothing in the file uses"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=[],r=new Set;for(let a=0;a<s.length;a++){if(!/^\s*import(?![\w$])\s*(?![(.])/.test(s[a]))continue;let c=s[a],u=a,f=Math.min(s.length-1,a+40);while(u<f&&!/\bfrom\s*['"][^'"]*['"]/.test(c)&&!/^\s*import\s*['"]/.test(c))u++,c+=`
130
+ ${s[u]}`;if(!/\bfrom\s*['"][^'"]*['"]/.test(c)&&!/^\s*import\s*['"]/.test(c))continue;for(let m=a;m<=u;m++)r.add(m);i.push(...ep(c,a,s)),a=u}if(i.length===0)return t;let o=s.map((a,c)=>r.has(c)?"":a).join(`
131
+ `),l=Li(o);for(let a of i){if(Ma(a.name).test(l))continue;t.push({filePath:n.filePath,line:a.line,column:a.column+1,ruleId:"pickier/no-unused-imports",message:a.typeOnly?`'${a.name}' is imported as a type but never used`:`'${a.name}' is imported but never used`,severity:"error"})}return t}};import{existsSync as tp,readFileSync as np}from"fs";import{dirname as sp,resolve as ip}from"path";var Sa={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=sp(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=ip(i,c+m);if(tp(h)){f=np(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 Ea,readFileSync as rp}from"fs";import{dirname as La,resolve as Ta}from"path";var Aa={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=rp(c,"utf8"),m=a(f,La(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=Ta(u,d+g);if(Ea(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=Ta(La(i),m+p);if(Ea(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 Oa={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 _a={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 Da={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 op}from"fs";import{dirname as lp,join as ap,resolve as cp}from"path";var Fa={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=lp(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=cp(i,c+h);u.push(d),u.push(ap(d,`index${h}`))}if(!u.some((h)=>op(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 Na(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 up=new RegExp(`^export\\s+\\{[^}]*\\}\\s+from\\s+['"][^'"]+['"];?\\s*$`);function _s(e){return up.test(e)}var Wa={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&&!_s(i[r]))r++;if(r>=i.length)break;let o=[],l=r;while(l<i.length){let a=i[l];if(_s(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)=>Na(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&&!_s(i[r]))r++;if(r>=i.length)break;let o=[],l=r;while(l<i.length){let a=i[l];if(_s(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)=>Na(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(`
132
+ `)}};var Ba={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=(k)=>i==="asc"?k:-k,f=(k,M)=>(r?k.toLowerCase():k).localeCompare(r?M.toLowerCase():M),m=(k,M)=>(r?k.toLowerCase():k).localeCompare(r?M.toLowerCase():M,void 0,{numeric:!0}),h=(k,M)=>{if(s==="line-length")return u(k.length-M.length);if(s==="natural")return u(m(k,M));if(s==="unsorted")return 0;return u(f(k,M))},d=Object.fromEntries(Object.entries(l).map(([k,M])=>{let C=(Array.isArray(M)?M:[M]).map((O)=>new RegExp(O));return[k,C]})),p=[];for(let k of o)if(Array.isArray(k))p.push(...k);else p.push(k);if(!p.includes("unknown"))p.push("unknown");let g=(k)=>{for(let[M,P]of Object.entries(d))if(P.some((C)=>C.test(k)))return M;return"unknown"},y=(k)=>{let M=[],P=0,C="";for(let O=0;O<k.length;O++){let I=k[O];if(I==="<")P++;else if(I===">")P=Math.max(0,P-1);if(I===","&&P===0){M.push(C.trim()),C="";continue}C+=I}if(C.trim())M.push(C.trim());return M},x=(k)=>{let M=k.trim(),P=M.match(/^([A-Z_$][\w$.]*)/i);return P?P[1]:M},R=(k,M)=>{let P=y(M);if(P.length<=1)return;let C=P.map(x),O=C.map(g),I=C.map((T,_)=>({n:T,g:O[_],i:_})).sort((T,_)=>{let S=p.indexOf(T.g),A=p.indexOf(_.g);if(S!==A)return S-A;return h(T.n,_.n)}).map((T)=>T.n);if(!C.every((T,_)=>T===I[_]))c.push({filePath:n.filePath,line:k,column:1,ruleId:"sort-heritage-clauses",message:"Heritage clauses are not sorted",severity:"warning"})};for(let k=0;k<a.length;k++){let M=a[k],P=M.match(/^\s*interface\s+[A-Za-z_$][^{]*\bextends\s+(.+?)\s*\{/);if(P)R(k+1,P[1]);let C=M.match(/^\s*class\s+[A-Za-z_$][^{]*\bimplements\s+(.+?)\s*\{/);if(C)R(k+1,C[1])}return c}};var ja={meta:{docs:"Require object keys to be sorted (ESLint-compatible core rule subset)"},check:()=>[]};var Ua={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 R=x.replace(/^type\s+/,""),k=R.match(/^([\w$]+)\s+as\s+([\w$]+)$/);if(k)return o?k[2]:k[1];let M=R.match(/^([\w$]+)$/);return M?M[1]:R}),g=[...p].sort(c);if(!p.every((x,R)=>x===g[R]))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 za={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=[],R={startLine:p+2,props:[]},k=()=>{if(R.props.length)x.push(R);R={startLine:0,props:[]}};for(let M=0;M<y.length;M++){let P=y[M];if(o&&/^\s*$/.test(P)){k();continue}if(/^\s*\.\.\./.test(P))continue;if(/\{|\}/.test(P))continue;let C=P.match(/^\s*['"]?([\w$-]+)['"]?\s*:/);if(C){if(R.startLine===0)R.startLine=p+2+M;R.props.push({key:C[1],line:p+2+M})}}k();for(let M of x){let P=M.props.map((I)=>I.key),C=[...P].sort(c);if(!(P.length<=1||P.every((I,N)=>I===C[N]))&&M.props.length>0){let I=M.props[0];a.push({filePath:n.filePath,line:I.line,column:1,ruleId:"sort-objects",message:"Object keys are not sorted",severity:"warning"})}}u=g+1;continue}}}u++}return a}};var qa={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 fp=[[/^(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]],mp=/^([a-z0-9][-a-z0-9]{0,50}:)+(?!\[)/;function hp(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 dp(e){let n=hp(e);if(n.startsWith("!"))n=n.slice(1);for(let[t,s]of fp)if(t.test(n))return s;return 99}function pp(e){let n=e.match(mp);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 Ka=new Map;function Va(e){let n=Ka.get(e);if(n)return n;let t={group:dp(e),variant:pp(e)};return Ka.set(e,t),t}function ir(e){return[...e].sort((n,t)=>{let s=Va(n),i=Va(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 gp=/\b(?:class|className|:class)\s*=\s*(?:"([^"]*?)"|'([^']*?)')/g,yp=/\b(?:class|className|:class)\s*=\s*\{`([^`]*?)`\}/g,bp=/\b(?:clsx|cn|tw|cva|tv)\s*\(\s*(?:"([^"]*?)"|'([^']*?)')/g;function xp(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 Ha(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[gp,yp,bp]){t.lastIndex=0;let s;while((s=t.exec(e))!==null){let i=s[1]??s[2]??"";if(!i.trim())continue;if(xp(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 Za(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 Ga(e){let n=ir(e);return e.every((t,s)=>t===n[s])}var Ja={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=Ha(e);for(let{value:i,start:r}of s){let o=Za(i);if(o.length<2)continue;if(!Ga(o)){let l=e.slice(0,r),a=(l.match(/\n/g)??[]).length+1,c=l.lastIndexOf(`
133
+ `),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: "${ir(o).join(" ")}"`,severity:"warning",help:"Run with --fix to automatically sort Tailwind classes, or reorder them manually."})}}return t},fix:(e)=>{let n=Ha(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=Za(i);if(l.length<2||Ga(l))continue;let a=ir(l).join(" ");s=s.slice(0,r)+a+s.slice(o)}return s}};var Ya={name:"pickier",rules:{"sort-exports":b(Wa),"sort-objects":b(za),"sort-imports":b(Os),"sort-named-imports":b(Ua),"sort-heritage-clauses":b(Ba),"sort-keys":b(ja),"import-dedupe":b(Ia),"no-unused-imports":b(Ca),"import-first":b(va),"import-named":b(Sa),"import-no-cycle":b(Aa),"import-no-unresolved":b(Fa),"no-import-dist":b(_a),"no-import-node-modules-by-path":b(Da),"no-duplicate-imports":b(Oa),"top-level-function":b(qa),"sort-tailwind-classes":Ja,"prefer-const":b(Ls),"prefer-template":b(Ts),"no-unused-vars":b(Xe)}};var Xa={name:"quality",rules:{"default-case":b(Zn),eqeqeq:b(Gn),"no-alert":b(Xn),"no-await-in-loop":b(Qn),"no-caller":b(es),"no-case-declarations":b(ts),"no-else-return":b(ns),"no-empty":b(ss),"no-empty-function":b(is),"no-eval":b(rs),"no-extend-native":b(os),"no-global-assign":b(as),"no-implied-eval":b(cs),"no-iterator":b(us),"no-new":b(fs),"no-new-func":b(ms),"no-new-wrappers":b(hs),"no-octal":b(ds),"no-param-reassign":b(ps),"no-proto":b(gs),"no-return-assign":b(ys),"no-shadow":b(xs),"no-throw-literal":b(ws),"no-use-before-define":b(Rs),"no-useless-call":b(ks),"no-with":b(Ms),"require-await":b(Ss),complexity:b(Hn),"max-depth":b(Jn),"max-lines-per-function":b(Yn),"no-extra-boolean-cast":b(ls),"no-lonely-if":b(Nt),"no-sequences":b(bs),"no-useless-concat":b($s),"no-useless-escape":b(Ps),"no-useless-rename":b(vs),"no-useless-return":b(Wt),"no-var":b(Is),"prefer-arrow-callback":b(Cs)}};var Qa={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(`
134
+ `);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 R=f.slice(1,f.lastIndexOf("/"));if(/^\s+\w/.test(R)&&/\w\s*\)/.test(R))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 wp(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===`
135
+ `)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 Rp(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(`
136
+ `,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 kp(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===`
137
+ `)break;o++}return n+1}function $p(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]!==`
138
+ `)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=wp(e,i);if(!o){let l=kp(e,i);if(l>i+1)i=l;else i++;continue}if(!Rp(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(`
139
+ `)+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 ec={meta:{docs:"Flags regex literals with unused capturing groups (context-aware)",recommended:!1},check(e,n){return $p(e,n)}};var tc={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 nc={name:"regexp",rules:{"no-super-linear-backtracking":b(Qa),"no-unused-capturing-group":b(ec),"no-useless-lazy":b(tc)}};var sc={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(`
140
+ `)}};var ic={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 rc={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 oc={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 lc={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 ac={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 cc={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 Pp=[/^\s*(?:local|export|declare|typeset|readonly)\s+/,/\[\[.*\]\]/,/\(\(.*\)\)/],rr=/^\$(?:\{[A-Za-z_]\w*(?:[:#%\/][^}]*)?\}|[A-Za-z_]\w*)/,uc={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=Ee(l);if(a){if(i=!0,r=a,new RegExp(`<<-?\\s*['"]${a}['"]`).test(l))continue}if(l.replace(/^\s+/,"").startsWith("#"))continue;if(Pp.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(rr);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(rr);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(rr);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 fc={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(`
141
+ `)}};function mc(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 hc(e){return/^(?:fi|done|esac|elif|else)\b/.test(e)||/^\}/.test(e)||/^;[;&]\s*$/.test(e)}var dc={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(hc(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(mc(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(hc(d))o=Math.max(0,o-1);let p=i?"\t".repeat(o):" ".repeat(o*s);if(r.push(p+d),mc(d,c))o++}return r.join(`
142
+ `)}};var pc={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=Ee(l);if(a)i=!0,r=a;if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=Fe(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 gc={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(`
143
+ `)}};var yc={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=Ee(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=Ee(r);if(o)t=!0,s=o;return r.replace(/[ \t]+$/,"")}).join(`
144
+ `)}};var bc={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=Ee(l);if(a)i=!0,r=a;if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=Fe(l);for(let f of vp(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=Ee(r);if(o){s=!0,i=o,t.push(r);continue}if(r.replace(/^\s+/,"").startsWith("#")){t.push(r);continue}t.push(Ip(r))}return t.join(`
145
+ `)}};function vp(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(!xc(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(!wc(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 Ip(e){let n=Fe(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(!xc(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(!wc(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 xc(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 wc(e,n){let t=e[n+1];if(t===void 0)return!0;return t===" "||t==="\t"||t===";"||t==="|"||t==="&"||t===")"}var Mp=/^#!\s*(?:\/usr\/bin\/env\s+(?:ba|z|k|da)?sh|\/bin\/(?:ba|z|k|da)?sh|\/usr\/bin\/(?:ba|z|k|da)?sh)\b/,Rc={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(!Mp.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 kc={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=Ee(l);if(a)i=!0,r=a;if(l.replace(/^\s+/,"").startsWith("#")){o.push("");continue}o.push(Fe(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=Cp(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+=Sp(d),u<0)u=0;if(f&&u===0&&/;;\s*$/.test(p))f=!1}}return t}};function Cp(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 Sp(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 $c={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=Fe(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 Pc={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=Ee(l);if(a)i=!0,r=a;if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=Fe(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 vc={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(`
146
+ `)}};var Ic={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 Mc={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 Cc={name:"shell",rules:{"command-substitution":de(sc),"quote-variables":de(uc),"no-cd-without-check":de(ic),"no-eval":de(rc),"no-useless-cat":de(ac),"no-ls-parsing":de(lc),"no-variable-in-single-quotes":de(cc),"no-exit-in-subshell":de(oc),shebang:de(Rc),indent:de(dc),"function-style":de(fc),"operator-spacing":de(bc),"keyword-spacing":de(pc),"no-trailing-semicolons":de(gc),"no-trailing-whitespace":de(yc),"prefer-double-brackets":de(vc),"set-options":de(Mc),"prefer-printf":de(Ic),"consistent-case-terminators":de(kc),"no-broken-redirect":de(Pc),"heredoc-indent":de($c)}};var Fs=null,Ds=null,or=!1,lr=!0;function Ep(){if(or)return lr;try{return Fs=(()=>{throw new Error("Cannot require module "+"@stacksjs/ts-spell-check");})(),Fs.SpellChecker.create({minWordLength:3,maxSuggestions:3}).then((e)=>{Ds=e}).catch(()=>{lr=!1}),or=!0,!0}catch{return or=!0,lr=!1,!1}}function ar(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(!Ep()||!Fs)return[];let{extractWords:i,parseDirectives:r,isSuppressed:o,getProgrammingWords:l}=Fs,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:R,offset:k}of x){if(R.length<u)continue;if(R===R.toUpperCase()&&R.length<=5)continue;if(c.has(R.toLowerCase()))continue;if(f.has(R.toLowerCase()))continue;if(o(R,y,m,c))continue;if(Ds){if(Ds.isCorrect(R))continue;let M=Ds.suggest(R);d.push({filePath:s.filePath,line:y,column:k+1,ruleId:e,message:`Unknown word: "${R}"`,severity:"warning",help:M.length?`Did you mean: ${M.slice(0,3).join(", ")}? Or add to config words.`:`Add "${R}" to your config words array, or use: // spell-check:ignore ${R}`})}}}return d}}}function Lp(e){let n=e.trimStart();return n.startsWith("//")||n.startsWith("/*")||n.startsWith("*")||n.startsWith("#")}var Sc={name:"spell",rules:{check:ar("spell/check"),"check-comments":ar("spell/check-comments",Lp),"check-markdown":{meta:{docs:"Check spelling in markdown files"},check(e,n){if(!n.filePath.endsWith(".md"))return[];return ar("spell/check-markdown").check(e,n)}}}};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:"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]==="["&&!Ec(r,l)){let a=r[l+1];if(a==="]"||a===void 0||a===`
147
+ `)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]==="]"&&!Ec(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(`
148
+ `)}};var Tc=/(?<![(\[{,=:?&|+\-*/])\b([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=>/g;function Tp(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 Ac={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;Tc.lastIndex=0;while((l=Tc.exec(r))!==null){let a=l.index;if(Tp(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 Ns=/=>/g;function Oc(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 _c={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;Ns.lastIndex=0;while((l=Ns.exec(r))!==null){let a=l.index;if(Oc(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
149
  `)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;Ns.lastIndex=0;let l;while((l=Ns.exec(s))!==null){let a=l.index;if(Lc(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 ar(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 Ac={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(ar(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]==="{"&&!ar(r,f))a++;if(r[f]==="}"&&!ar(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 Oc={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 _c=/,\s*$/,Dc=new RegExp("^\\s*[}\\])](?:\\s*;?\\s*)?$"),Fc={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(!Dc.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(_c.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(Dc.test(r)&&o&&o!=="{"&&o!=="["&&o!=="("&&!o.startsWith("//")&&!o.startsWith("*")&&!o.startsWith("/*")&&!_c.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 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 Nc={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(Ep(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]!==`
150
+ `);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;Ns.lastIndex=0;let l;while((l=Ns.exec(s))!==null){let a=l.index;if(Oc(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(`
151
+ `)}};function cr(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 Dc={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(cr(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]==="{"&&!cr(r,f))a++;if(r[f]==="}"&&!cr(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(`
152
+ `)}};var Fc={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 Nc=/,\s*$/,Wc=new RegExp("^\\s*[}\\])](?:\\s*;?\\s*)?$"),Bc={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(!Wc.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(Nc.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(Wc.test(r)&&o&&o!=="{"&&o!=="["&&o!=="("&&!o.startsWith("//")&&!o.startsWith("*")&&!o.startsWith("/*")&&!Nc.test(o)&&!o.endsWith("{")&&!o.endsWith("[")&&!o.endsWith("(")&&!o.endsWith("=>")){t.push(i.replace(/(\s*)$/,",$1"));continue}}t.push(i)}return t.join(`
153
+ `)}};function Ap(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 jc={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(Ap(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
154
  `&&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 Wc={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 Lp(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 Bc={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(Lp(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 Tp(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 jc={meta:{docs:"Enforce consistent line breaks in member-access/call chains"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=Tp(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/),R=x.length,k=(x[x.length-1]||"").length;t.push({filePath:n.filePath,line:R+h,column:(h===0?k: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 Uc(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 zc(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]!==`
155
+ `)}};var Uc={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(`
156
+ `)}};function Op(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={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(Op(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 _p(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(`
157
+ `).length;n.push({start:u,end:f}),i=c}}s+=r.length+1}return n}var qc={meta:{docs:"Enforce consistent line breaks in member-access/call chains"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=_p(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/),R=x.length,k=(x[x.length-1]||"").length;t.push({filePath:n.filePath,line:R+h,column:(h===0?k: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 Kc(e){let n=[0];for(let s=0;s<e.length;s++)if(e[s]===`
158
+ `)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 Vc(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
159
  `)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(Ap(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 Ap(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 qc(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 Ws(e,n,t,s,i,r,o){let l=qc(e,s,i,r);if(l<=s)return;let a=e.slice(s+1,l),c=/\r?\n/.test(a),u=Uc(e),f=[],m=0,h=s+1,d=zc(e.slice(s+1,l)),p=0;for(let y of d){let x=s+1+y.start,R=s+1+y.end;if(p=R,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=R}}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 R=u.indexToLoc(y.start);t.push({filePath:n,line:R.line,column:R.column,ruleId:o,message:"Should not have line breaks between items",severity:"warning"});break}}return}let g=a.indexOf(`
160
+ `)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(Dp(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 Dp(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 Hc(e,n,t,s){let i=0,r=(f)=>f<=" ",o=(f)=>{while(f<e.length&&e[f]!==`
161
+ `)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 Ws(e,n,t,s,i,r,o){let l=Hc(e,s,i,r);if(l<=s)return;let a=e.slice(s+1,l),c=/\r?\n/.test(a),u=Kc(e),f=[],m=0,h=s+1,d=Vc(e.slice(s+1,l)),p=0;for(let y of d){let x=s+1+y.start,R=s+1+y.end;if(p=R,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=R}}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 R=u.indexToLoc(y.start);t.push({filePath:n,line:R.line,column:R.column,ruleId:o,message:"Should not have line breaks between items",severity:"warning"});break}}return}let g=a.indexOf(`
160
162
  `);if(g>0){let y=a.slice(0,g),x=(y.match(/,/g)||[]).length,R=a.slice(g+1),k=R.includes(`
161
- `),M=R.includes(",");if(x>=1&&/\S,\s*\S/.test(y)&&!k&&!M){let P=u.indexToLoc(s+1+g+1);t.push({filePath:n,line:P.line,column:P.column,ruleId:o,message:"Should not have line breaks between items",severity:"warning"});return}else if(x>=1&&/\S,\s*\S/.test(y)){let P=u.indexToLoc(s+1+y.search(/,\s*\S/));t.push({filePath:n,line:P.line,column:P.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 R=u.indexToLoc(y.start);t.push({filePath:n,line:R.line,column:R.column,ruleId:o,message:"Should have line breaks between items",severity:"warning"});break}}}var Kc={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;Ws(e,n.filePath,t,i,"{","}","style/consistent-list-newline")}else if(r==="[")Ws(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)Ws(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)Ws(e,n.filePath,t,o,"{","}","style/consistent-list-newline")}}return t}};function Op(e){let n=e.trim();return n===""||n.startsWith("//")||n.startsWith("/*")}function cr(e,n){for(let t=n;t<e.length;t++)if(!Op(e[t]))return t;return-1}function $t(e,n,t){if(e[n].slice(t).includes("{"))return!0;let i=cr(e,n+1);if(i>=0){if(e[i].trim().startsWith("{"))return!0}return!1}function Bs(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 Vc={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=$t(s,r,c),f=Bs(s,r,c),m=r,h=u,d=f;while(!0){let p=cr(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||$t(s,p,x),d=d||Bs(s,p,x),m=p;continue}else{let x=s[p].indexOf("else")+4;h=h||$t(s,p,x),d=d||Bs(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=cr(s,p+1);if(g<0)break;let y=s[g],x=y.trim();if(!x.startsWith("else"))break;let R=x.match(/^else\s+if\s*\(([^)]*)\)/);if(R){let k=y.indexOf(R[0])+R[0].length;if(!$t(s,g,k))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 k=y.indexOf("else")+4;if(!$t(s,g,k))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=$t(s,r,c),f=Bs(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=_p(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 _p(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,R=y!==x,k=!1;for(let M=i+1;M<s.length;M++){let P=s[M].trim();if(P===""||P==="}"||/^\/\//.test(P))continue;if(!/^else\b/.test(P))break;let C=s[M].indexOf("else")+4,O=P.match(/^else\s+if\s*\([^)]*\)/);if(O)C=s[M].indexOf(O[0])+O[0].length;let I=M,N=s[M].indexOf("{",C);if(N<0){let S=function(F){for(let L=F;L<s.length;L++)if(s[L].trim()!=="")return L;return-1}(M+1);if(S<0)break;if(N=s[S].indexOf("{"),N<0)continue;I=S}let T=0,_=-1;for(let S=I;S<s.length;S++){let A=s[S],F=S===I?Math.max(0,N):0;for(let L=F;L<A.length;L++){let w=A[L];if(w==="{")T++;else if(w==="}"){if(T--,T===0){_=S;break}}}if(_>=0)break}if(_>=0){let S=0;for(let A=I+1;A<_;A++){let F=s[A].trim();if(F===""||/^\/\//.test(F))continue;if(S++,S>1){k=!0;break}}}if(k)break}if(!k&&l==="if"){let M=function(C){for(let O=C;O<s.length;O++){let I=s[O].trim();if(I!==""&&I!=="}"&&!/^\/\//.test(I))return O}return-1}(m+1);if(M>=0&&/^else\b/.test(s[M].trim())){let P=s[M].indexOf("else")+4,C=s[M].trim().match(/^else\s+if\s*\([^)]*\)/);if(C)P=s[M].indexOf(C[0])+C[0].length;let O=M,I=s[M].indexOf("{",P);if(I<0){let N=function(_){for(let S=_;S<s.length;S++)if(s[S].trim()!=="")return S;return-1}(M+1);if(N>=0)I=s[N].indexOf("{"),O=I>=0?N:O}if(I>=0){let N=0,T=-1;for(let _=O;_<s.length;_++){let S=s[_],A=_===O?Math.max(0,I):0;for(let F=A;F<S.length;F++){let L=S[F];if(L==="{")N++;else if(L==="}"){if(N--,N===0){T=_;break}}}if(T>=0)break}if(T>=0){let _=0;for(let S=O+1;S<T;S++){let A=s[S].trim();if(A===""||/^\/\//.test(A))continue;if(++_>1){k=!0;break}}}}}}if(!p&&!g&&!R&&!k)t.push({line:c+1,column:Math.max(1,s[c].indexOf("{")+1),message:"Unnecessary curly braces around single statement"})}}return t}var Hc={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=Qe(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=Qe(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 Zc(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 Gc=["===","!==",">>>","==","!=",">=","<=","&&","||","??","**","<<",">>","+","-","*","/","%","|","&","^",">","<","instanceof","in"],yI=new RegExp(`^(${Gc.map((e)=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})\\s`),Dp=new Set(["in","instanceof"]),Fp=/^(?:instanceof|in)\s/;function js(e){if(Fp.test(e))return!0;for(let n of Gc){if(Dp.has(n))continue;if(e.startsWith(n)){let t=e[n.length];if(t===void 0||t===" "||t==="\t")return!0}}return!1}function ur(e){let n=e.match(/^(\s*)/);return n?n[1].length:0}var Jc={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(!js(o))continue;if(Zc(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(js(u)){l--;continue}break}if(l<0)continue;let a=ur(s[l])+2,c=ur(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(!js(o)||Zc(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(js(f))continue;l=u;break}if(l<0){s.push(r);continue}let a=ur(s[l])+2,c=" ".repeat(a)+o;s.push(c);continue}return s.join(`
163
- `)}};var Yc=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"]),Us=/([a-zA-Z_$][a-zA-Z0-9_$]*)\s+\(/g;function Xc(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 Qc={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;Us.lastIndex=0;while((l=Us.exec(r))!==null){let a=l[1],c=l.index;if(Xc(r,c))continue;if(Yc.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;Us.lastIndex=0;while((c=Us.exec(r))!==null){let u=c[1],f=c.index;if(Xc(r,f))continue;if(Yc.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 eu=/\bfunction\s*\*/g;function tu(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:"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;eu.lastIndex=0;while((l=eu.exec(r))!==null){let c=l.index;if(tu(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(!tu(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 su={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 Np=["$","unindent","unIndent"],iu={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(!Np.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 Wp=/^(\s*)(["']?[a-zA-Z_$][a-zA-Z0-9_$]*["']?\s*(?:\?)?):(\S)/;function ru(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 ou={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(Wp);if(l){let c=r.indexOf(":",l[1].length);if(c!==-1&&!ru(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&&!ru(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 Bp=["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"],lu=new RegExp(`(?:^|[^\\w$.])(${Bp.join("|")})(?=[^\\w$]|$)`,"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 au={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;lu.lastIndex=0;while((l=lu.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(jp(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 cu=/^\s*(?:public|private|protected|static|readonly|abstract|override|async|get|set|\*|#|[a-zA-Z_$])/,uu={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(cu.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!=="}"&&cu.test(u)){if(l!==-1&&a===l+1)s.push("");if(!u.endsWith("{"))l=a}s.push(c)}return s.join(`
169
- `)}};var fu={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=Up(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="",R=(P)=>{if(P===" "||P==="\t")return;x=P};for(let P=0;P<a.length;P++){let C=a[P];if(p){p=!1;continue}if(C==="\\"){p=!0;continue}if(h){if(d){if(C==="]")d=!1;continue}if(C==="["){d=!0;continue}if(C==="/"){h=!1;while(P+1<a.length&&/[a-z]/i.test(a[P+1]))P++;x="/"}continue}if(!f&&!m&&C==="'"){u=!u,R(u?"'":"x");continue}if(!u&&!m&&C==='"'){f=!f,R(f?'"':"x");continue}if(!u&&!f&&C==="`"){m=!m,R(m?"`":"x");continue}if(u||f||m)continue;if(C==="/"&&mu(x,a,P)){h=!0;continue}if(!g){if(C==="f"&&a.slice(P,P+4).match(/^for\b/)){let O=a.slice(P+3).trimStart(),I=a.length-O.length;if(a[I]==="("){g=!0,y=1,P=I,x="(";continue}}}else if(C==="(")y++;else if(C===")"){if(y--,y<=0)g=!1}else if(C===";"){R(C);continue}if(C===";")c++;R(C)}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 Up(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==="/"&&mu(l,e,a)){i=!0;continue}if(c!==" "&&c!=="\t")l=c}return-1}function mu(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 hu(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 du={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(hu(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&&!hu(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 pu=new RegExp("\\bnew\\s+([A-Z][a-zA-Z0-9_$.]+)(?![a-zA-Z0-9_$])(?:\\s*<[^>]*>)?\\s*(?=[^(;\\n]|$)","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 gu={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;pu.lastIndex=0;while((l=pu.exec(r))!==null){if(zp(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 SI=new RegExp("\\breturn\\s+\\(([^()]*)\\)\\s*[;\\n]","g"),yu=/^[a-zA-Z_$][a-zA-Z0-9_$.[\]'"`]*$/;var bu={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(yu.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(yu.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 xu=/(\S)\s+(\.)[a-zA-Z_$]/g,wu=/(\S)\s+(\?\.)[a-zA-Z_$]/g;function zs(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:"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;xu.lastIndex=0;while((l=xu.exec(r))!==null){let a=l.index+l[0].indexOf(".");if(zs(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"})}wu.lastIndex=0;while((l=wu.exec(r))!==null){let a=l.index+l[0].indexOf("?.");if(zs(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(zs(r,f))return a;return c+u}),l=l.replace(/(\S)\s+(\.[a-zA-Z_$])/g,(a,c,u,f)=>{if(zs(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 Pt(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 ku=/&&/g,$u=/\|\|/g,Pu=/\?\?/g,vu=/(?<![&])&(?![&=])/g,Iu=/(?<![|])\|(?![|=])/g,Mu=/\^(?!=)/g;function qp(e){let n=[];ku.lastIndex=0;let t;while((t=ku.exec(e))!==null)if(!Pt(e,t.index))n.push({op:"&&",group:0,index:t.index});$u.lastIndex=0;while((t=$u.exec(e))!==null)if(!Pt(e,t.index))n.push({op:"||",group:1,index:t.index});Pu.lastIndex=0;while((t=Pu.exec(e))!==null)if(!Pt(e,t.index))n.push({op:"??",group:2,index:t.index});vu.lastIndex=0;while((t=vu.exec(e))!==null)if(!Pt(e,t.index))n.push({op:"&",group:3,index:t.index});Iu.lastIndex=0;while((t=Iu.exec(e))!==null)if(!Pt(e,t.index))n.push({op:"|",group:4,index:t.index});Mu.lastIndex=0;while((t=Mu.exec(e))!==null)if(!Pt(e,t.index))n.push({op:"^",group:5,index:t.index});return n.sort((s,i)=>s.index-i.index)}function Kp(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 Vp=[{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 ^"}],Cu={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=qp(r);if(l.length<2)continue;let a=new Set(l.map((c)=>c.group));for(let c of Vp)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(!Kp(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 Su=/(?<![0-9.])\.\d/g,Eu=/\d\.(?!\d|\.|\w)/g;function Lu(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:"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;Su.lastIndex=0;while((l=Su.exec(r))!==null){if(Lu(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"})}Eu.lastIndex=0;while((l=Eu.exec(r))!==null){if(Lu(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 Au={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 Ou={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 _u={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 Du={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 Fu={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 Nu(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:"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]==="{"&&!Nu(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]==="}"&&!Nu(r,l)){let a=l>0?r[l-1]:void 0;if(a==="{"||a===void 0||a===`
163
+ `),M=R.includes(",");if(x>=1&&/\S,\s*\S/.test(y)&&!k&&!M){let P=u.indexToLoc(s+1+g+1);t.push({filePath:n,line:P.line,column:P.column,ruleId:o,message:"Should not have line breaks between items",severity:"warning"});return}else if(x>=1&&/\S,\s*\S/.test(y)){let P=u.indexToLoc(s+1+y.search(/,\s*\S/));t.push({filePath:n,line:P.line,column:P.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 R=u.indexToLoc(y.start);t.push({filePath:n,line:R.line,column:R.column,ruleId:o,message:"Should have line breaks between items",severity:"warning"});break}}}var Zc={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;Ws(e,n.filePath,t,i,"{","}","style/consistent-list-newline")}else if(r==="[")Ws(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)Ws(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)Ws(e,n.filePath,t,o,"{","}","style/consistent-list-newline")}}return t}};function Fp(e){let n=e.trim();return n===""||n.startsWith("//")||n.startsWith("/*")}function ur(e,n){for(let t=n;t<e.length;t++)if(!Fp(e[t]))return t;return-1}function $t(e,n,t){if(e[n].slice(t).includes("{"))return!0;let i=ur(e,n+1);if(i>=0){if(e[i].trim().startsWith("{"))return!0}return!1}function Bs(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 Gc={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=$t(s,r,c),f=Bs(s,r,c),m=r,h=u,d=f;while(!0){let p=ur(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||$t(s,p,x),d=d||Bs(s,p,x),m=p;continue}else{let x=s[p].indexOf("else")+4;h=h||$t(s,p,x),d=d||Bs(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=ur(s,p+1);if(g<0)break;let y=s[g],x=y.trim();if(!x.startsWith("else"))break;let R=x.match(/^else\s+if\s*\(([^)]*)\)/);if(R){let k=y.indexOf(R[0])+R[0].length;if(!$t(s,g,k))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 k=y.indexOf("else")+4;if(!$t(s,g,k))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=$t(s,r,c),f=Bs(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=Np(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 Np(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,R=y!==x,k=!1;for(let M=i+1;M<s.length;M++){let P=s[M].trim();if(P===""||P==="}"||/^\/\//.test(P))continue;if(!/^else\b/.test(P))break;let C=s[M].indexOf("else")+4,O=P.match(/^else\s+if\s*\([^)]*\)/);if(O)C=s[M].indexOf(O[0])+O[0].length;let I=M,N=s[M].indexOf("{",C);if(N<0){let S=function(F){for(let L=F;L<s.length;L++)if(s[L].trim()!=="")return L;return-1}(M+1);if(S<0)break;if(N=s[S].indexOf("{"),N<0)continue;I=S}let T=0,_=-1;for(let S=I;S<s.length;S++){let A=s[S],F=S===I?Math.max(0,N):0;for(let L=F;L<A.length;L++){let w=A[L];if(w==="{")T++;else if(w==="}"){if(T--,T===0){_=S;break}}}if(_>=0)break}if(_>=0){let S=0;for(let A=I+1;A<_;A++){let F=s[A].trim();if(F===""||/^\/\//.test(F))continue;if(S++,S>1){k=!0;break}}}if(k)break}if(!k&&l==="if"){let M=function(C){for(let O=C;O<s.length;O++){let I=s[O].trim();if(I!==""&&I!=="}"&&!/^\/\//.test(I))return O}return-1}(m+1);if(M>=0&&/^else\b/.test(s[M].trim())){let P=s[M].indexOf("else")+4,C=s[M].trim().match(/^else\s+if\s*\([^)]*\)/);if(C)P=s[M].indexOf(C[0])+C[0].length;let O=M,I=s[M].indexOf("{",P);if(I<0){let N=function(_){for(let S=_;S<s.length;S++)if(s[S].trim()!=="")return S;return-1}(M+1);if(N>=0)I=s[N].indexOf("{"),O=I>=0?N:O}if(I>=0){let N=0,T=-1;for(let _=O;_<s.length;_++){let S=s[_],A=_===O?Math.max(0,I):0;for(let F=A;F<S.length;F++){let L=S[F];if(L==="{")N++;else if(L==="}"){if(N--,N===0){T=_;break}}}if(T>=0)break}if(T>=0){let _=0;for(let S=O+1;S<T;S++){let A=s[S].trim();if(A===""||/^\/\//.test(A))continue;if(++_>1){k=!0;break}}}}}}if(!p&&!g&&!R&&!k)t.push({line:c+1,column:Math.max(1,s[c].indexOf("{")+1),message:"Unnecessary curly braces around single statement"})}}return t}var Jc={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=Qe(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=Qe(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(`
164
+ `)}};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=["===","!==",">>>","==","!=",">=","<=","&&","||","??","**","<<",">>","+","-","*","/","%","|","&","^",">","<","instanceof","in"],$I=new RegExp(`^(${Xc.map((e)=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})\\s`),Wp=new Set(["in","instanceof"]),Bp=/^(?:instanceof|in)\s/;function js(e){if(Bp.test(e))return!0;for(let n of Xc){if(Wp.has(n))continue;if(e.startsWith(n)){let t=e[n.length];if(t===void 0||t===" "||t==="\t")return!0}}return!1}function fr(e){let n=e.match(/^(\s*)/);return n?n[1].length:0}var Qc={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(!js(o))continue;if(Yc(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(js(u)){l--;continue}break}if(l<0)continue;let a=fr(s[l])+2,c=fr(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(!js(o)||Yc(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(js(f))continue;l=u;break}if(l<0){s.push(r);continue}let a=fr(s[l])+2,c=" ".repeat(a)+o;s.push(c);continue}return s.join(`
165
+ `)}};var eu=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"]),Us=/([a-zA-Z_$][a-zA-Z0-9_$]*)\s+\(/g;function tu(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:"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;Us.lastIndex=0;while((l=Us.exec(r))!==null){let a=l[1],c=l.index;if(tu(r,c))continue;if(eu.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;Us.lastIndex=0;while((c=Us.exec(r))!==null){let u=c[1],f=c.index;if(tu(r,f))continue;if(eu.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(`
166
+ `)}};var su=/\bfunction\s*\*/g;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:"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;su.lastIndex=0;while((l=su.exec(r))!==null){let c=l.index;if(iu(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]!==`
167
+ `&&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(!iu(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 ou={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 jp=["$","unindent","unIndent"],lu={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(!jp.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 Up=/^(\s*)(["']?[a-zA-Z_$][a-zA-Z0-9_$]*["']?\s*(?:\?)?):(\S)/;function au(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 cu={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(Up);if(l){let c=r.indexOf(":",l[1].length);if(c!==-1&&!au(r,c)){let u=r[c+1];if(u&&u!==" "&&u!=="\t"&&u!==`
168
+ `)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&&!au(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(`
169
+ `)}};var zp=["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"],uu=new RegExp(`(?:^|[^\\w$.])(${zp.join("|")})(?=[^\\w$]|$)`,"g");function qp(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 fu={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;uu.lastIndex=0;while((l=uu.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(qp(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(`
170
+ `)}};var mu=/^\s*(?:public|private|protected|static|readonly|abstract|override|async|get|set|\*|#|[a-zA-Z_$])/,hu={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(mu.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!=="}"&&mu.test(u)){if(l!==-1&&a===l+1)s.push("");if(!u.endsWith("{"))l=a}s.push(c)}return s.join(`
171
+ `)}};var du={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=Kp(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="",R=(P)=>{if(P===" "||P==="\t")return;x=P};for(let P=0;P<a.length;P++){let C=a[P];if(p){p=!1;continue}if(C==="\\"){p=!0;continue}if(h){if(d){if(C==="]")d=!1;continue}if(C==="["){d=!0;continue}if(C==="/"){h=!1;while(P+1<a.length&&/[a-z]/i.test(a[P+1]))P++;x="/"}continue}if(!f&&!m&&C==="'"){u=!u,R(u?"'":"x");continue}if(!u&&!m&&C==='"'){f=!f,R(f?'"':"x");continue}if(!u&&!f&&C==="`"){m=!m,R(m?"`":"x");continue}if(u||f||m)continue;if(C==="/"&&pu(x,a,P)){h=!0;continue}if(!g){if(C==="f"&&a.slice(P,P+4).match(/^for\b/)){let O=a.slice(P+3).trimStart(),I=a.length-O.length;if(a[I]==="("){g=!0,y=1,P=I,x="(";continue}}}else if(C==="(")y++;else if(C===")"){if(y--,y<=0)g=!1}else if(C===";"){R(C);continue}if(C===";")c++;R(C)}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 Kp(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==="/"&&pu(l,e,a)){i=!0;continue}if(c!==" "&&c!=="\t")l=c}return-1}function pu(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 gu(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 yu={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(gu(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&&!gu(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 bu=new RegExp("\\bnew\\s+([A-Z][a-zA-Z0-9_$.]+)(?![a-zA-Z0-9_$])(?:\\s*<[^>]*>)?\\s*(?=[^(;\\n]|$)","g");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 xu={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;bu.lastIndex=0;while((l=bu.exec(r))!==null){if(Vp(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 _I=new RegExp("\\breturn\\s+\\(([^()]*)\\)\\s*[;\\n]","g"),wu=/^[a-zA-Z_$][a-zA-Z0-9_$.[\]'"`]*$/;var Ru={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(wu.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(wu.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(`
172
+ `)}};var ku=/(\S)\s+(\.)[a-zA-Z_$]/g,$u=/(\S)\s+(\?\.)[a-zA-Z_$]/g;function zs(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:"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;ku.lastIndex=0;while((l=ku.exec(r))!==null){let a=l.index+l[0].indexOf(".");if(zs(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"})}$u.lastIndex=0;while((l=$u.exec(r))!==null){let a=l.index+l[0].indexOf("?.");if(zs(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(zs(r,f))return a;return c+u}),l=l.replace(/(\S)\s+(\.[a-zA-Z_$])/g,(a,c,u,f)=>{if(zs(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(`
173
+ `)}};function Pt(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=/&&/g,Iu=/\|\|/g,Mu=/\?\?/g,Cu=/(?<![&])&(?![&=])/g,Su=/(?<![|])\|(?![|=])/g,Eu=/\^(?!=)/g;function Hp(e){let n=[];vu.lastIndex=0;let t;while((t=vu.exec(e))!==null)if(!Pt(e,t.index))n.push({op:"&&",group:0,index:t.index});Iu.lastIndex=0;while((t=Iu.exec(e))!==null)if(!Pt(e,t.index))n.push({op:"||",group:1,index:t.index});Mu.lastIndex=0;while((t=Mu.exec(e))!==null)if(!Pt(e,t.index))n.push({op:"??",group:2,index:t.index});Cu.lastIndex=0;while((t=Cu.exec(e))!==null)if(!Pt(e,t.index))n.push({op:"&",group:3,index:t.index});Su.lastIndex=0;while((t=Su.exec(e))!==null)if(!Pt(e,t.index))n.push({op:"|",group:4,index:t.index});Eu.lastIndex=0;while((t=Eu.exec(e))!==null)if(!Pt(e,t.index))n.push({op:"^",group:5,index:t.index});return n.sort((s,i)=>s.index-i.index)}function Zp(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 Gp=[{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 ^"}],Lu={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=Hp(r);if(l.length<2)continue;let a=new Set(l.map((c)=>c.group));for(let c of Gp)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(!Zp(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 Tu=/(?<![0-9.])\.\d/g,Au=/\d\.(?!\d|\.|\w)/g;function Ou(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 _u={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;Tu.lastIndex=0;while((l=Tu.exec(r))!==null){if(Ou(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"})}Au.lastIndex=0;while((l=Au.exec(r))!==null){if(Ou(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 Du={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 Fu={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 Nu={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 Wu={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 Bu={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 ju(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 Uu={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]==="{"&&!ju(r,l)){let a=r[l+1];if(a==="}"||a===void 0||a===`
174
+ `)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]==="}"&&!ju(r,l)){let a=l>0?r[l-1]:void 0;if(a==="{"||a===void 0||a===`
173
175
  `)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 Bu=/(\&\&|\|\||\?\?|\?|\+|(?<!=)-(?!=)|\*|\/|%|\*\*|\|(?!\|)|&(?!&)|\^|<<|>>>?)\s*$/;function ju(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 Uu={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(Bu);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(!ju(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(Bu);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(ju(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 zu={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 fr=/^(\s*)(["'])([a-zA-Z_$][a-zA-Z0-9_$]*)\2\s*:/;var qu={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(fr);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(fr);if(o&&!s.has(o[3]))r=i.replace(fr,"$1$3:");t.push(r)}return t.join(`
177
- `)}};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 Ku=/\.\.\.\s+([a-zA-Z_$])/g,Vu={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;Ku.lastIndex=0;while((l=Ku.exec(r))!==null){if(Hp(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 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 Hu={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(Zp(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]!==`
176
+ `)}};var zu=/(\&\&|\|\||\?\?|\?|\+|(?<!=)-(?!=)|\*|\/|%|\*\*|\|(?!\|)|&(?!&)|\^|<<|>>>?)\s*$/;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 Ku={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(zu);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(!qu(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(zu);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(qu(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(`
177
+ `)}};var Vu={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(`
178
+ `)}};var mr=/^(\s*)(["'])([a-zA-Z_$][a-zA-Z0-9_$]*)\2\s*:/;var Hu={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(mr);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(mr);if(o&&!s.has(o[3]))r=i.replace(mr,"$1$3:");t.push(r)}return t.join(`
179
+ `)}};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 Zu=/\.\.\.\s+([a-zA-Z_$])/g,Gu={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;Zu.lastIndex=0;while((l=Zu.exec(r))!==null){if(Jp(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 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 Ju={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(Yp(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
180
  `&&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 Zu=/(\S)\{/g;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 Gu={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;Zu.lastIndex=0;while((l=Zu.exec(r))!==null){let a=l.index,c=l[1];if(Gp(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 Ju=/\bfunction\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s+\(/g,Yu=/\bfunction\(/g;function Xu(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={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;Ju.lastIndex=0;while((l=Ju.exec(r))!==null){if(Xu(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"})}Yu.lastIndex=0;while((l=Yu.exec(r))!==null){if(Xu(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 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 tf={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]==="("&&!ef(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]===")"&&!ef(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 nf=["&&","||","??","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","|=","^=","??=","||=","&&="];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 sf={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 nf){let a=0,c;while((c=r.indexOf(l,a))!==-1){if(a=c+l.length,Jp(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=[...nf].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 rf=["typeof","void","delete","new","throw","yield","await"];function mr(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={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 rf){let f=new RegExp(`\\b${u}([^\\s;,)])`,"g"),m;while((m=f.exec(r))!==null){if(mr(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(mr(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(mr(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 rf)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 lf={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]!==`
181
+ `)}};var Yu=/(\S)\{/g;function Xp(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:"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;Yu.lastIndex=0;while((l=Yu.exec(r))!==null){let a=l.index,c=l[1];if(Xp(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(`
182
+ `)}};var Qu=/\bfunction\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s+\(/g,ef=/\bfunction\(/g;function tf(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:"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;Qu.lastIndex=0;while((l=Qu.exec(r))!==null){if(tf(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"})}ef.lastIndex=0;while((l=ef.exec(r))!==null){if(tf(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 sf(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:"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]==="("&&!sf(r,l)){let a=r[l+1];if(a===")"||a===void 0||a===`
183
+ `)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]===")"&&!sf(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(`
184
+ `)}};var of=["&&","||","??","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","|=","^=","??=","||=","&&="];function Qp(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={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 of){let a=0,c;while((c=r.indexOf(l,a))!==-1){if(a=c+l.length,Qp(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!==`
185
+ `&&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=[...of].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 af=["typeof","void","delete","new","throw","yield","await"];function hr(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={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 af){let f=new RegExp(`\\b${u}([^\\s;,)])`,"g"),m;while((m=f.exec(r))!==null){if(hr(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(hr(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(hr(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 af)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 uf={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
186
  `)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 af=/^\s*(case\b.+?|default)\s*:/,cf={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(af);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(af.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 uf="${",ff={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(uf,0);o!==-1;o=r.indexOf(uf,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 vt=/([a-zA-Z_$][a-zA-Z0-9_$]*)\s+`/g;function mf(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 hf=new Set(["return","case","typeof","void","delete","throw","new","in","of","await","yield","export","default","extends","else","instanceof"]),df={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;vt.lastIndex=0;for(l=vt.exec(r);l!==null;l=vt.exec(r)){let a=l[1],c=l.index;if(mf(r,c))continue;if(hf.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;vt.lastIndex=0;for(c=vt.exec(r);c!==null;c=vt.exec(r)){let u=c[1],f=c.index;if(mf(r,f))continue;if(hf.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 pf={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(`
187
+ `)}};var ff=/^\s*(case\b.+?|default)\s*:/,mf={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(ff);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]!==`
188
+ `)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(ff.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(`
189
+ `)}};var hf="${",df={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(hf,0);o!==-1;o=r.indexOf(hf,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 vt=/([a-zA-Z_$][a-zA-Z0-9_$]*)\s+`/g;function pf(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=new Set(["return","case","typeof","void","delete","throw","new","in","of","await","yield","export","default","extends","else","instanceof"]),yf={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;vt.lastIndex=0;for(l=vt.exec(r);l!==null;l=vt.exec(r)){let a=l[1],c=l.index;if(pf(r,c))continue;if(gf.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;vt.lastIndex=0;for(c=vt.exec(r);c!==null;c=vt.exec(r)){let u=c[1],f=c.index;if(pf(r,f))continue;if(gf.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(`
190
+ `)}};var bf={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
191
  `).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 gf=/\byield\s*\*/g;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 yf={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;gf.lastIndex=0;while((l=gf.exec(r))!==null){let a=l.index;if(Yp(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 bf={name:"style",rules:{"brace-style":b(Oc),curly:b(Vc),"max-statements-per-line":b(fu),"if-newline":b(su),"consistent-chaining":b(jc),"consistent-list-newline":b(Kc),"indent-unindent":b(iu),"no-multi-spaces":Ou,"no-multiple-empty-lines":_u,"no-trailing-spaces":Fu,"keyword-spacing":b(au),"arrow-spacing":b(Tc),"space-infix-ops":b(sf),"object-curly-spacing":b(Wu),"spaced-comment":b(lf),"block-spacing":b(Ac),"space-before-blocks":b(Gu),"comma-spacing":b(Nc),"semi-spacing":b(Hu),"rest-spread-spacing":b(Vu),"generator-star-spacing":b(nu),"yield-star-spacing":b(yf),"function-call-spacing":b(Qc),"template-tag-spacing":b(df),"no-whitespace-before-property":b(Ru),"key-spacing":b(ou),"computed-property-spacing":b(Bc),"array-bracket-spacing":b(Cc),"space-in-parens":b(tf),"template-curly-spacing":b(ff),"space-unary-ops":b(of),"switch-colon-spacing":b(cf),"comma-dangle":b(Fc),"arrow-parens":b(Ec),"space-before-function-paren":b(Qu),"quote-props":b(qu),"no-floating-decimal":b(Tu),"new-parens":b(gu),"no-extra-parens":b(bu),"wrap-iife":b(pf),"comma-style":b(Wc),"dot-location":b(Hc),"operator-linebreak":b(Uu),"multiline-ternary":b(du),"padded-blocks":b(zu),"lines-between-class-members":b(uu),"no-mixed-operators":b(Cu),"indent-binary-ops":b(Jc),"no-tabs":b(Du),"no-mixed-spaces-and-tabs":b(Au)}};var xf={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 wf={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 R=l.indexOf("any",Math.max(0,h-5));t.push({filePath:n.filePath,line:r+1,column:R>=0?R+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 Rf={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 R=g.slice(x).trim();if(/^\.(?:then|catch|finally)\s*\(/.test(R))continue;if(R===""||R.startsWith(";")){let k=l.indexOf(h[0]);t.push({filePath:n.filePath,line:r+1,column:k>=0?k+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 kf={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])),R=u.slice(u.indexOf("if (")+4);if(!/\bawait\s/.test(R)){let k=l.indexOf(y);t.push({filePath:n.filePath,line:r+1,column:k>=0?k+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),R=u.slice(g+y.length,Math.min(u.length,g+y.length+10));if(/(?:&&|\|\|)\s*$/.test(x)||/^\s*(?:&&|\|\|)/.test(R)){if(!/\bawait\s*$/.test(x)){let M=l.indexOf(y,Math.max(0,g-5));t.push({filePath:n.filePath,line:r+1,column:M>=0?M+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 k=u.slice(Math.max(0,g-20),g);if(/\?\s*$/.test(x)||/\?[^:]*$/.test(k)){if(!/\bawait\s*$/.test(x)){let M=l.indexOf(y,Math.max(0,g-5));t.push({filePath:n.filePath,line:r+1,column:M>=0?M+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 $f={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 Pf={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),R=d===0||/[^$\w]/.test(e[d-1]),k=/[^$\w]/.test(e[d+5]||" ");if(!x&&R&&k&&i===0)h(f);d+=4,f+=4;continue}}return t}};var vf={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 If={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],R=m.index,k=u.slice(R+m[0].length).trim(),M=u.slice(0,R).trim();if(/=\s*$/.test(M)&&!/==|===|!=|!==/.test(M)){let P=l.indexOf(m[0]);t.push({filePath:n.filePath,line:r+1,column:P>=0?P+1:R+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 R=new RegExp(`\\b${x.replace(".","\\.")}\\s*\\(`,"g");R.lastIndex=0;while((m=R.exec(u))!==null){let k=m.index,M=u.slice(0,k).trim(),P=M.match(/(?:const|let|var)\s+([\w$]+)\s*=\s*$/);if(P){let I=P[1];if(!new RegExp(`\\b${I}\\s*:\\s*\\w+`).test(u)){let T=l.indexOf(m[0]);t.push({filePath:n.filePath,line:r+1,column:T>=0?T+1:k+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 ${I} or use a type assertion with a specific type`})}}let C=M.match(/([\w$.]+)\s*=\s*$/),O=/(?:const|let|var)\s+/.test(M);if(C&&!P&&!O){let I=l.indexOf(m[0]);t.push({filePath:n.filePath,line:r+1,column:I>=0?I+1:k+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],R=l.indexOf(p[0]);t.push({filePath:n.filePath,line:r+1,column:R>=0?R+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 Mf={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 I=f[p];if(I===")")g++;else if(I==="("){if(g===0){p++;break}g--}else if(I==="}")y++;else if(I==="{"){if(y===0){p++;break}y--}else if(I==="]")x++;else if(I==="["){if(x===0){p++;break}x--}else if(g===0&&y===0&&x===0){if(new RegExp("[;,=:?]").test(I)){p++;break}if(I==="&"||I==="|"){p++;break}}p--}if(p<0)p=0;let R=f.slice(p,d).trim();if(/[<>!=]/.test(R))continue;if(/\b(?:true|false)\b/.test(R))continue;let k=d+2,M=k;g=0,y=0,x=0;while(M<f.length){let I=f[M];if(I==="(")g++;else if(I===")"){if(g===0)break;g--}else if(I==="{")y++;else if(I==="}"){if(y===0)break;y--}else if(I==="[")x++;else if(I==="]"){if(x===0)break;x--}else if(g===0&&y===0&&x===0){if(new RegExp("[;,?:]").test(I))break;if(I==="&"||I==="|"&&f[M+1]==="|")break}M++}let P=f.slice(k,M).trim(),C=/^["'`\d]/.test(P)||/^\{/.test(P)||/^[\w$]+\(/.test(P)||/^[\w$.[\]]+$/.test(P),O=/^[\w$]+$/.test(R)||/^[\w$.?[\]()]+$/.test(R);if(C&&O)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 Cf={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 R=l.indexOf(g);t.push({filePath:n.filePath,line:r+1,column:R>=0?R+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 Xp(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 Sf=/([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,Ef={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;Sf.lastIndex=0;while((l=Sf.exec(r))!==null){if(Xp(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 Lf(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 Tf=/([A-Za-z_$][A-Za-z0-9_$]*)\s*<(\s+)/g,Af=/(\s+)>(?!=)/g,Qp=/([A-Za-z_$][A-Za-z0-9_$]*)\s*<\s+/g,eg=/\s+>(?!=)/g,Of={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;Tf.lastIndex=0;let l;while((l=Tf.exec(r))!==null){let a=l.index+l[1].length,c=r.indexOf("<",a);if(c===-1)continue;if(Lf(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"})}Af.lastIndex=0;while((l=Af.exec(r))!==null){let a=l.index+l[1].length;if(Lf(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(Qp,(l,a)=>`${a}<`),/[A-Za-z_$][A-Za-z0-9_$]*\s*</.test(o))o=o.replace(eg,">");s.push(o)}return s.join(`
198
- `)}};function tg(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 _f=/([a-zA-Z_$][a-zA-Z0-9_$?]*):(\S)/g,Nf={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=Df(r);for(let a of l){_f.lastIndex=0;let c;while((c=_f.exec(a.text))!==null){let f=a.start+c.index+c[1].length;if(tg(r,f))continue;if(!Ff(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(!Ff(i)){s.push(i);continue}let o=i,l=Df(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 Df(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 Ff(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 Wf={name:"ts",rules:{"no-require-imports":b($f),"no-top-level-await":b(Pf),"no-ts-export-equal":b(vf),"no-explicit-any":b(wf),"prefer-nullish-coalescing":b(Mf),"prefer-optional-chain":b(Cf),"no-floating-promises":b(Rf),"no-misused-promises":b(kf),"no-unsafe-assignment":b(If),"member-delimiter-style":b(xf),"type-annotation-spacing":b(Ef),"type-generic-spacing":b(Of),"type-named-tuple-spacing":b(Nf)}};var Bf={name:"unused-imports",rules:{"no-unused-vars":b(Xe),"no-unused-imports":b(Xe)}};function hr(){return[Do,qo,Ga,Za,bf,Qa,Wf,la,vc,Ic,ua,sl,$a,Bf,fa]}var dr=null;function qf(){if(!dr)dr=new rt("pickier",{showTags:!1});return dr}function It(...e){if(_e.TRACE)qf().debug("[pickier:trace]",e)}async function Uf(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 qf().error(`[pickier:error] ${t} failed:`,r?.message||r),It("withTimeout error:",t,r),r}}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+=`
192
+ `,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 xf=/\byield\s*\*/g;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 wf={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;xf.lastIndex=0;while((l=xf.exec(r))!==null){let a=l.index;if(eg(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]!==`
193
+ `)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 Rf={name:"style",rules:{"brace-style":b(Fc),curly:b(Gc),"max-statements-per-line":b(du),"if-newline":b(ou),"consistent-chaining":b(qc),"consistent-list-newline":b(Zc),"indent-unindent":b(lu),"no-multi-spaces":Fu,"no-multiple-empty-lines":Nu,"no-trailing-spaces":Bu,"keyword-spacing":b(fu),"arrow-spacing":b(_c),"space-infix-ops":b(lf),"object-curly-spacing":b(Uu),"spaced-comment":b(uf),"block-spacing":b(Dc),"space-before-blocks":b(Xu),"comma-spacing":b(jc),"semi-spacing":b(Ju),"rest-spread-spacing":b(Gu),"generator-star-spacing":b(ru),"yield-star-spacing":b(wf),"function-call-spacing":b(nu),"template-tag-spacing":b(yf),"no-whitespace-before-property":b(Pu),"key-spacing":b(cu),"computed-property-spacing":b(zc),"array-bracket-spacing":b(Lc),"space-in-parens":b(rf),"template-curly-spacing":b(df),"space-unary-ops":b(cf),"switch-colon-spacing":b(mf),"comma-dangle":b(Bc),"arrow-parens":b(Ac),"space-before-function-paren":b(nf),"quote-props":b(Hu),"no-floating-decimal":b(_u),"new-parens":b(xu),"no-extra-parens":b(Ru),"wrap-iife":b(bf),"comma-style":b(Uc),"dot-location":b(Jc),"operator-linebreak":b(Ku),"multiline-ternary":b(yu),"padded-blocks":b(Vu),"lines-between-class-members":b(hu),"no-mixed-operators":b(Lu),"indent-binary-ops":b(Qc),"no-tabs":b(Wu),"no-mixed-spaces-and-tabs":b(Du)}};var kf={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(`
194
+ `)}};var $f={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 R=l.indexOf("any",Math.max(0,h-5));t.push({filePath:n.filePath,line:r+1,column:R>=0?R+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(`
195
+ `)}};var Pf={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 R=g.slice(x).trim();if(/^\.(?:then|catch|finally)\s*\(/.test(R))continue;if(R===""||R.startsWith(";")){let k=l.indexOf(h[0]);t.push({filePath:n.filePath,line:r+1,column:k>=0?k+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 vf={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])),R=u.slice(u.indexOf("if (")+4);if(!/\bawait\s/.test(R)){let k=l.indexOf(y);t.push({filePath:n.filePath,line:r+1,column:k>=0?k+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),R=u.slice(g+y.length,Math.min(u.length,g+y.length+10));if(/(?:&&|\|\|)\s*$/.test(x)||/^\s*(?:&&|\|\|)/.test(R)){if(!/\bawait\s*$/.test(x)){let M=l.indexOf(y,Math.max(0,g-5));t.push({filePath:n.filePath,line:r+1,column:M>=0?M+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 k=u.slice(Math.max(0,g-20),g);if(/\?\s*$/.test(x)||/\?[^:]*$/.test(k)){if(!/\bawait\s*$/.test(x)){let M=l.indexOf(y,Math.max(0,g-5));t.push({filePath:n.filePath,line:r+1,column:M>=0?M+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 If={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 Mf={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===`
196
+ `){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),R=d===0||/[^$\w]/.test(e[d-1]),k=/[^$\w]/.test(e[d+5]||" ");if(!x&&R&&k&&i===0)h(f);d+=4,f+=4;continue}}return t}};var Cf={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 Sf={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],R=m.index,k=u.slice(R+m[0].length).trim(),M=u.slice(0,R).trim();if(/=\s*$/.test(M)&&!/==|===|!=|!==/.test(M)){let P=l.indexOf(m[0]);t.push({filePath:n.filePath,line:r+1,column:P>=0?P+1:R+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 R=new RegExp(`\\b${x.replace(".","\\.")}\\s*\\(`,"g");R.lastIndex=0;while((m=R.exec(u))!==null){let k=m.index,M=u.slice(0,k).trim(),P=M.match(/(?:const|let|var)\s+([\w$]+)\s*=\s*$/);if(P){let I=P[1];if(!new RegExp(`\\b${I}\\s*:\\s*\\w+`).test(u)){let T=l.indexOf(m[0]);t.push({filePath:n.filePath,line:r+1,column:T>=0?T+1:k+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 ${I} or use a type assertion with a specific type`})}}let C=M.match(/([\w$.]+)\s*=\s*$/),O=/(?:const|let|var)\s+/.test(M);if(C&&!P&&!O){let I=l.indexOf(m[0]);t.push({filePath:n.filePath,line:r+1,column:I>=0?I+1:k+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],R=l.indexOf(p[0]);t.push({filePath:n.filePath,line:r+1,column:R>=0?R+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 Ef={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 I=f[p];if(I===")")g++;else if(I==="("){if(g===0){p++;break}g--}else if(I==="}")y++;else if(I==="{"){if(y===0){p++;break}y--}else if(I==="]")x++;else if(I==="["){if(x===0){p++;break}x--}else if(g===0&&y===0&&x===0){if(new RegExp("[;,=:?]").test(I)){p++;break}if(I==="&"||I==="|"){p++;break}}p--}if(p<0)p=0;let R=f.slice(p,d).trim();if(/[<>!=]/.test(R))continue;if(/\b(?:true|false)\b/.test(R))continue;let k=d+2,M=k;g=0,y=0,x=0;while(M<f.length){let I=f[M];if(I==="(")g++;else if(I===")"){if(g===0)break;g--}else if(I==="{")y++;else if(I==="}"){if(y===0)break;y--}else if(I==="[")x++;else if(I==="]"){if(x===0)break;x--}else if(g===0&&y===0&&x===0){if(new RegExp("[;,?:]").test(I))break;if(I==="&"||I==="|"&&f[M+1]==="|")break}M++}let P=f.slice(k,M).trim(),C=/^["'`\d]/.test(P)||/^\{/.test(P)||/^[\w$]+\(/.test(P)||/^[\w$.[\]]+$/.test(P),O=/^[\w$]+$/.test(R)||/^[\w$.?[\]()]+$/.test(R);if(C&&O)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(`
197
+ `)}};var Lf={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 R=l.indexOf(g);t.push({filePath:n.filePath,line:r+1,column:R>=0?R+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(`
198
+ `)}};function tg(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 Tf=/([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,Af={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;Tf.lastIndex=0;while((l=Tf.exec(r))!==null){if(tg(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(`
199
+ `)}};function Of(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 _f=/([A-Za-z_$][A-Za-z0-9_$]*)\s*<(\s+)/g,Df=/(\s+)>(?!=)/g,ng=/([A-Za-z_$][A-Za-z0-9_$]*)\s*<\s+/g,sg=/\s+>(?!=)/g,Ff={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;_f.lastIndex=0;let l;while((l=_f.exec(r))!==null){let a=l.index+l[1].length,c=r.indexOf("<",a);if(c===-1)continue;if(Of(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"})}Df.lastIndex=0;while((l=Df.exec(r))!==null){let a=l.index+l[1].length;if(Of(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(ng,(l,a)=>`${a}<`),/[A-Za-z_$][A-Za-z0-9_$]*\s*</.test(o))o=o.replace(sg,">");s.push(o)}return s.join(`
200
+ `)}};function ig(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=/([a-zA-Z_$][a-zA-Z0-9_$?]*):(\S)/g,jf={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=Wf(r);for(let a of l){Nf.lastIndex=0;let c;while((c=Nf.exec(a.text))!==null){let f=a.start+c.index+c[1].length;if(ig(r,f))continue;if(!Bf(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(!Bf(i)){s.push(i);continue}let o=i,l=Wf(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(`
201
+ `)}};function Wf(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 Bf(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 Uf={name:"ts",rules:{"no-require-imports":b(If),"no-top-level-await":b(Mf),"no-ts-export-equal":b(Cf),"no-explicit-any":b($f),"prefer-nullish-coalescing":b(Ef),"prefer-optional-chain":b(Lf),"no-floating-promises":b(Pf),"no-misused-promises":b(vf),"no-unsafe-assignment":b(Sf),"member-delimiter-style":b(kf),"type-annotation-spacing":b(Af),"type-generic-spacing":b(Ff),"type-named-tuple-spacing":b(jf)}};var zf={name:"unused-imports",rules:{"no-unused-vars":b(Xe),"no-unused-imports":b(Xe)}};function dr(){return[Fo,Ko,Xa,Ya,Rf,nc,Uf,aa,Cc,Sc,fa,il,Pa,zf,ma]}var pr=null;function Hf(){if(!pr)pr=new rt("pickier",{showTags:!1});return pr}function It(...e){if(_e.TRACE)Hf().debug("[pickier:trace]",e)}async function Kf(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 Hf().error(`[pickier:error] ${t} failed:`,r?.message||r),It("withTimeout error:",t,r),r}}function Zf(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
202
  ${se.bold(`\x1B[4m${s}\x1B[24m`)}
201
- `;let r;try{r=zf(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)}
203
+ `;let r;try{r=Vf(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
204
  `}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
205
  ${a} ${c}: ${l.message}
204
206
  `;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}]`)}
@@ -208,17 +210,17 @@ ${se.bold(`\x1B[4m${s}\x1B[24m`)}
208
210
  `;else t+=` ${se.gray(y)} ${se.gray("| ")}${x}
209
211
  `}if(t+=` ${se.gray(" `----")}
210
212
  `,l.help)t+=` ${se.blue("help")}: ${l.help}
211
- `}}return t}function Vf(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+=`
213
+ `}}return t}function Gf(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
214
  ${se.bold(`\x1B[4m${s}\x1B[24m`)}
213
215
  `;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 eS(e,n){It("runFormat:start",{globs:e,options:n});let t=await Ut(n.config),s=e.length?e:["."],i=zt(s);It("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=_e.TIMEOUT_MS,a=i.some((g)=>{let y=g.replace(/\/?\*\*(?:\/\*+)?$/,"");return!(sg(y)?y:ig(process.cwd(),y)).startsWith(process.cwd())})?nt(at):nt(t.ignores),c=qt(a),u=[];if(i.length===1&&/\*\*\/\*$/.test(i[0])){let g=i[0].replace(/\/?\*\*\/\*$/,"");try{let{readdirSync:y,statSync:x}=await import("fs"),{join:R}=await import("path"),k=[g];while(k.length){let M=k.pop(),P=y(M);for(let C of P){let O=R(M,C),I=x(O);if(c(O))continue;if(I.isDirectory())k.push(O);else u.push(O)}}}catch{u=await Uf(tt(i,{dot:!1,ignore:a,onlyFiles:!0,absolute:!0}),o,"glob")}}else u=await Uf(tt(i,{dot:!1,ignore:a,onlyFiles:!0,absolute:!0}),o,"glob");It("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)});It("filtered files",m.length);let h=0,d=[];for(let g of m){It("format start",jf(process.cwd(),g));let y=zf(g,"utf8"),x=qs(y,t,g),R=x!==y;if(n.write){if(R)ng(g,x,"utf8")}if(R)d.push(jf(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 gr=null;function ee(){if(!gr)gr=new rt("pickier:lint",{showTags:!1});return gr}function $e(...e){if(_e.TRACE)ee().error("[pickier:trace]",e)}async function uS(e,n,t="untitled",s){if(s?.aborted)throw Error("AbortError");let i=ct(e),r=ut(e),o=St(t,e,n,i,r);if(s?.aborted)throw Error("AbortError");try{let l=await Rr(t,e,n);for(let a of l){if(s?.aborted)throw Error("AbortError");if(Ae(a.ruleId,a.line,i))continue;if(r.has(a.line)&&Hs(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 fS(e,n,t){$e("runLintProgrammatic:start",{globs:e,options:n});let s=await Ut(n.config);if(t?.aborted)throw Error("AbortError");let i=e.length?e:["."],r=zt(i),o=n.ext||s.lint.extensions.join(","),l=new Set(o.split(",").map((T)=>{let _=T.trim();return _.startsWith(".")?_:`.${_}`})),a=_e.TIMEOUT_MS,u=r.some((T)=>{let _=T.replace(/\/?\*\*\/*\*\*$/,""),S=Mt(_)?_:Ct(process.cwd(),_),A=process.cwd();return S!==A&&!S.startsWith(A+sm)})?nt(at):nt(s.ignores),f=qt(u),m=[];if(r.length===1&&!/[*?[\]{}()!]/.test(r[0]))try{if(Vs(r[0]).isFile())m=[Mt(r[0])?r[0]:Ct(process.cwd(),r[0])]}catch{}let d=r.length===1&&/\*\*\/*\*$/.test(r[0]);if(!m.length&&d){let T=r[0].replace(/\/?\*\*\/*\*\*$/,""),_=Mt(T)?T:Ct(process.cwd(),T);try{let S=[_];while(S.length){if(t?.aborted)throw Error("AbortError");let A=S.pop(),F=em(A);for(let L of F){let w=nm(A,L),E=Vs(w);if(f(w))continue;if(E.isDirectory())S.push(w);else m.push(w)}}}catch{m=await Vt(tt(r,{dot:!1,ignore:u,onlyFiles:!0,absolute:!0}),a,"glob")}}else if(!m.length)m=await Vt(tt(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,R=0,k=[];for(let T of m){if(p++,T.replace(/\\/g,"/").includes("/node_modules/")){y++;continue}if(f(T)){x++;continue}if(!xr(T,l)){R++;continue}k.push(T),g++}$e("filter:programmatic",{total:p,included:g,node_modules:y,ignored:x,wrongExt:R});let M=_e.CONCURRENCY,O=(await rm(k,M,async(T)=>{if(t?.aborted)throw Error("AbortError");let _=tm(T,"utf8"),S=ct(_),A=ut(_),F=St(T,_,s,S,A);try{let L=await Rr(T,_,s);for(let w of L){if(t?.aborted)throw Error("AbortError");if(Ae(w.ruleId,w.line,S))continue;if(A.has(w.line)&&Hs(w.ruleId))continue;F.push({filePath:w.filePath,line:w.line,column:w.column,ruleId:w.ruleId,message:w.message,severity:w.severity,...w.help&&{help:w.help}})}}catch{}{let L=new Set;F=F.filter((w)=>{let E=`${w.line}:${w.column}:${w.ruleId}`;if(L.has(E))return!1;return L.add(E),!0})}if(n.fix){let L=lm(T,_,s,S,A);if(L=om(T,L,s),L!==_){let w=ct(L),E=ut(L);if(F=St(T,L,s,w,E),!n.dryRun)yr(T,L,"utf8")}}return F})).flat(),I=O.filter((T)=>T.severity==="error").length,N=O.filter((T)=>T.severity==="warning").length;return{errors:I,warnings:N,issues:O}}function rg(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function og(e){return e.replace(/-([a-z])/g,(n,t)=>t.toUpperCase())}function ct(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((R)=>R.trim()).filter(Boolean):["*"];if(x.length>0){let R=f+1,k=n.get(R)||new Set;for(let M of x)k.add(M);n.set(R,k)}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((k)=>k.trim()).filter(Boolean),R=s.get(f)||new Set;for(let k of x)R.add(k),o.add(k);s.set(f,R)}if(c===0)if(!y||y==="")t.add("*");else{let x=y.split(",").map((R)=>R.trim()).filter(Boolean);for(let R of x)t.add(R)}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((k)=>k.trim()).filter(Boolean),R=i.get(f)||new Set;for(let k of x)R.add(k),o.delete(k);i.set(f,R)}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((k)=>k.trim()).filter(Boolean),R=s.get(f)||new Set;for(let k of x)R.add(k),o.add(k);s.set(f,R)}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((k)=>k.trim()).filter(Boolean),R=i.get(f)||new Set;for(let k of x)R.add(k),o.delete(k);i.set(f,R)}}}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 Ae(e,n,t){if(t instanceof Map){let l=t.get(n);if(!l||l.size===0)return!1;return Kt(e,l)}if(t.fileLevel.size>0){if(Kt(e,t.fileLevel))return!0}let s=t.nextLine.get(n);if(s&&Kt(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(Kt(e,f))i=!0;r++;continue}let u=t.rangeEnable.get(a);if(u.has("*")||Kt(e,u))i=!1;o++}return i}function Kt(e,n){if(n.size===0)return!1;if(n.has("*"))return!0;if(n.has(e))return!0;let t=rg(e);if(n.has(t)||n.has(og(e)))return!0;for(let s of n)if(!s.includes("/")){if(e.endsWith(`/${s}`))return!0}return!1}function Hs(e){return e!=="spaced-comment"&&!e.endsWith("/spaced-comment")}function im(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 Vt(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),$e("withTimeout error:",t,r),r}}async function rm(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 Hf=new WeakMap;function lg(e){let n=hr();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 ag(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 Zs(e){let n=Hf.get(e);if(n)return n;let t=lg(e),s=ag(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=Qf(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 Hf.set(e,c),c}function cg(e,n){return/\.(?:sh|bash|zsh|ksh|dash)$/.test(e)||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(n)}function ug(e){return/(?:^|[/\\])(?:bun\.lock|bun\.lockb|package-lock\.json|pnpm-lock\.yaml|yarn\.lock|npm-shrinkwrap\.json)$/.test(e)}function wr(e,n,t){switch(e.pluginName){case"markdown":return n.endsWith(".md");case"shell":return cg(n,t);case"publint":return/(?:^|[/\\])package\.json$/.test(n);case"lockfile":return ug(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 Rr(e,n,t){let s=[],i=Zs(t),r={filePath:e,config:t};for(let o of i.checkRules){if(!wr(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{$e("rule:start",l);let u=_e.RULE_TIMEOUT_MS,f={...r,options:o.options},m=performance.now(),h=await Vt(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"});$e("rule:end",l,Array.isArray(h)?h.length:0);for(let p of h){let g=im(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 fg=/\.(?:[cm]?[jt]sx?|vue|svelte|stx)$/i;function mg(e,n,t){if(!fg.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=Qe(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 om(e,n,t){let s=Zs(t),i={filePath:e,config:t},r=n,o=!0,l=0;while(o&&l++<pr){o=!1;for(let a of s.fixRules){if(!wr(a,e,r))continue;let c={...i,options:a.options},u=a.rule.fix(r,c),f=a.rule.meta?.editsStringContent?u:mg(r,u,e);if(f!==r)r=f,o=!0}}return r}function lm(e,n,t,s,i){if(!st(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=kr(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)&&!Ae("no-debugger",p,s)){m=!0;continue}f.push(d)}return m?f.join(`
216
- `):n}function am(e,n,t){let s=st(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 hg(e,n,t,s){let i=n.format.indent,r=n.format.indentStyle,o=kr(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)||Ae("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(!br(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 kr(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==="/"&&$r(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 Zf(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 Gf(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 Jf(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($r(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 $r(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 Yf(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 ut(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===`
216
+ `}}return t}async function oS(e,n){It("runFormat:start",{globs:e,options:n});let t=await Ut(n.config),s=e.length?e:["."],i=zt(s);It("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=_e.TIMEOUT_MS,a=i.some((g)=>{let y=g.replace(/\/?\*\*(?:\/\*+)?$/,"");return!(og(y)?y:lg(process.cwd(),y)).startsWith(process.cwd())})?nt(at):nt(t.ignores),c=qt(a),u=[];if(i.length===1&&/\*\*\/\*$/.test(i[0])){let g=i[0].replace(/\/?\*\*\/\*$/,"");try{let{readdirSync:y,statSync:x}=await import("fs"),{join:R}=await import("path"),k=[g];while(k.length){let M=k.pop(),P=y(M);for(let C of P){let O=R(M,C),I=x(O);if(c(O))continue;if(I.isDirectory())k.push(O);else u.push(O)}}}catch{u=await Kf(tt(i,{dot:!1,ignore:a,onlyFiles:!0,absolute:!0}),o,"glob")}}else u=await Kf(tt(i,{dot:!1,ignore:a,onlyFiles:!0,absolute:!0}),o,"glob");It("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)});It("filtered files",m.length);let h=0,d=[];for(let g of m){It("format start",qf(process.cwd(),g));let y=Vf(g,"utf8"),x=qs(y,t,g),R=x!==y;if(n.write){if(R)rg(g,x,"utf8")}if(R)d.push(qf(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 yr=null;function ee(){if(!yr)yr=new rt("pickier:lint",{showTags:!1});return yr}function $e(...e){if(_e.TRACE)ee().error("[pickier:trace]",e)}async function gS(e,n,t="untitled",s){if(s?.aborted)throw Error("AbortError");let i=ct(e),r=ut(e),o=St(t,e,n,i,r);if(s?.aborted)throw Error("AbortError");try{let l=await kr(t,e,n);for(let a of l){if(s?.aborted)throw Error("AbortError");if(Ae(a.ruleId,a.line,i))continue;if(r.has(a.line)&&Hs(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 yS(e,n,t){$e("runLintProgrammatic:start",{globs:e,options:n});let s=await Ut(n.config);if(t?.aborted)throw Error("AbortError");let i=e.length?e:["."],r=zt(i),o=n.ext||s.lint.extensions.join(","),l=new Set(o.split(",").map((T)=>{let _=T.trim();return _.startsWith(".")?_:`.${_}`})),a=_e.TIMEOUT_MS,u=r.some((T)=>{let _=T.replace(/\/?\*\*\/*\*\*$/,""),S=Mt(_)?_:Ct(process.cwd(),_),A=process.cwd();return S!==A&&!S.startsWith(A+om)})?nt(at):nt(s.ignores),f=qt(u),m=[];if(r.length===1&&!/[*?[\]{}()!]/.test(r[0]))try{if(Vs(r[0]).isFile())m=[Mt(r[0])?r[0]:Ct(process.cwd(),r[0])]}catch{}let d=r.length===1&&/\*\*\/*\*$/.test(r[0]);if(!m.length&&d){let T=r[0].replace(/\/?\*\*\/*\*\*$/,""),_=Mt(T)?T:Ct(process.cwd(),T);try{let S=[_];while(S.length){if(t?.aborted)throw Error("AbortError");let A=S.pop(),F=sm(A);for(let L of F){let w=rm(A,L),E=Vs(w);if(f(w))continue;if(E.isDirectory())S.push(w);else m.push(w)}}}catch{m=await Vt(tt(r,{dot:!1,ignore:u,onlyFiles:!0,absolute:!0}),a,"glob")}}else if(!m.length)m=await Vt(tt(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,R=0,k=[];for(let T of m){if(p++,T.replace(/\\/g,"/").includes("/node_modules/")){y++;continue}if(f(T)){x++;continue}if(!wr(T,l)){R++;continue}k.push(T),g++}$e("filter:programmatic",{total:p,included:g,node_modules:y,ignored:x,wrongExt:R});let M=_e.CONCURRENCY,O=(await am(k,M,async(T)=>{if(t?.aborted)throw Error("AbortError");let _=im(T,"utf8"),S=ct(_),A=ut(_),F=St(T,_,s,S,A);try{let L=await kr(T,_,s);for(let w of L){if(t?.aborted)throw Error("AbortError");if(Ae(w.ruleId,w.line,S))continue;if(A.has(w.line)&&Hs(w.ruleId))continue;F.push({filePath:w.filePath,line:w.line,column:w.column,ruleId:w.ruleId,message:w.message,severity:w.severity,...w.help&&{help:w.help}})}}catch{}{let L=new Set;F=F.filter((w)=>{let E=`${w.line}:${w.column}:${w.ruleId}`;if(L.has(E))return!1;return L.add(E),!0})}if(n.fix){let L=um(T,_,s,S,A);if(L=cm(T,L,s),L!==_){let w=ct(L),E=ut(L);if(F=St(T,L,s,w,E),!n.dryRun)br(T,L,"utf8")}}return F})).flat(),I=O.filter((T)=>T.severity==="error").length,N=O.filter((T)=>T.severity==="warning").length;return{errors:I,warnings:N,issues:O}}function ag(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function cg(e){return e.replace(/-([a-z])/g,(n,t)=>t.toUpperCase())}function ct(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((R)=>R.trim()).filter(Boolean):["*"];if(x.length>0){let R=f+1,k=n.get(R)||new Set;for(let M of x)k.add(M);n.set(R,k)}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((k)=>k.trim()).filter(Boolean),R=s.get(f)||new Set;for(let k of x)R.add(k),o.add(k);s.set(f,R)}if(c===0)if(!y||y==="")t.add("*");else{let x=y.split(",").map((R)=>R.trim()).filter(Boolean);for(let R of x)t.add(R)}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((k)=>k.trim()).filter(Boolean),R=i.get(f)||new Set;for(let k of x)R.add(k),o.delete(k);i.set(f,R)}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((k)=>k.trim()).filter(Boolean),R=s.get(f)||new Set;for(let k of x)R.add(k),o.add(k);s.set(f,R)}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((k)=>k.trim()).filter(Boolean),R=i.get(f)||new Set;for(let k of x)R.add(k),o.delete(k);i.set(f,R)}}}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 Ae(e,n,t){if(t instanceof Map){let l=t.get(n);if(!l||l.size===0)return!1;return Kt(e,l)}if(t.fileLevel.size>0){if(Kt(e,t.fileLevel))return!0}let s=t.nextLine.get(n);if(s&&Kt(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(Kt(e,f))i=!0;r++;continue}let u=t.rangeEnable.get(a);if(u.has("*")||Kt(e,u))i=!1;o++}return i}function Kt(e,n){if(n.size===0)return!1;if(n.has("*"))return!0;if(n.has(e))return!0;let t=ag(e);if(n.has(t)||n.has(cg(e)))return!0;for(let s of n)if(!s.includes("/")){if(e.endsWith(`/${s}`))return!0}return!1}function Hs(e){return e!=="spaced-comment"&&!e.endsWith("/spaced-comment")}function lm(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 Vt(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),$e("withTimeout error:",t,r),r}}async function am(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 Jf=new WeakMap;function ug(e){let n=dr();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 fg(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 Zs(e){let n=Jf.get(e);if(n)return n;let t=ug(e),s=fg(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=nm(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 Jf.set(e,c),c}function mg(e,n){return/\.(?:sh|bash|zsh|ksh|dash)$/.test(e)||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(n)}function hg(e){return/(?:^|[/\\])(?:bun\.lock|bun\.lockb|package-lock\.json|pnpm-lock\.yaml|yarn\.lock|npm-shrinkwrap\.json)$/.test(e)}function Rr(e,n,t){switch(e.pluginName){case"markdown":return n.endsWith(".md");case"shell":return mg(n,t);case"publint":return/(?:^|[/\\])package\.json$/.test(n);case"lockfile":return hg(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 kr(e,n,t){let s=[],i=Zs(t),r={filePath:e,config:t};for(let o of i.checkRules){if(!Rr(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{$e("rule:start",l);let u=_e.RULE_TIMEOUT_MS,f={...r,options:o.options},m=performance.now(),h=await Vt(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"});$e("rule:end",l,Array.isArray(h)?h.length:0);for(let p of h){let g=lm(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 dg=/\.(?:[cm]?[jt]sx?|vue|svelte|stx)$/i;function pg(e,n,t){if(!dg.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=Qe(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(`
217
+ `):n}function cm(e,n,t){let s=Zs(t),i={filePath:e,config:t},r=n,o=!0,l=0;while(o&&l++<gr){o=!1;for(let a of s.fixRules){if(!Rr(a,e,r))continue;let c={...i,options:a.options},u=a.rule.fix(r,c),f=a.rule.meta?.editsStringContent?u:pg(r,u,e);if(f!==r)r=f,o=!0}}return r}function um(e,n,t,s,i){if(!st(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=$r(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)&&!Ae("no-debugger",p,s)){m=!0;continue}f.push(d)}return m?f.join(`
218
+ `):n}function fm(e,n,t){let s=st(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 gg(e,n,t,s){let i=n.format.indent,r=n.format.indentStyle,o=$r(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)||Ae("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(!xr(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(`
219
+ `):e}function $r(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===`
220
+ `){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==="/"&&Pr(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 Yf(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 Xf(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 Qf(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(Pr(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 Pr(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 em(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 ut(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
221
  `){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
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]===`
221
223
  `)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
224
  `)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 St(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=st(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=am(e,n,t),p=!1,g=st(t,"no-debugger",["noDebugger"]),y=st(t,"no-console",["noConsole"]),x=st(t,"no-template-curly-in-string",["noTemplateCurlyInString"]),R=st(t,"no-cond-assign",["noCondAssign"]),k=/\bconsole\.log\s*\(/,M=/^\s*debugger\b/,P=new Set;if(a==="md"){let O=!1;for(let I=0;I<o.length;I++){if(/^(?:`{3,}|~{3,})/.test(o[I].trim())){O=!O;continue}if(O)P.add(I+1)}}let C=kr(n);for(let O=0;O<o.length;O++){let I=o[O],N=O+1;if(i.has(N))continue;if(!m&&!C.has(N)){let S=Yf(Jf(I)),A=Xf(S,l);if(A.length>0&&!p){if(!Ae("quotes",N,s))r.push({filePath:e,line:N,column:(A[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<I.length&&(I.charCodeAt(T)===32||I.charCodeAt(T)===9))T++;let _=T>0?I.slice(0,T):"";if(d&&_.length>0&&!P.has(N)&&!C.has(N)&&br(_,t.format.indent,t.format.indentStyle,I)){if(!Ae("indent",N,s))r.push({filePath:e,line:N,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&&!C.has(N)&&M.test(I)){if(!Ae("no-debugger",N,s))r.push({filePath:e,line:N,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&&!C.has(N)&&k.test(I)){let S=I.indexOf("//"),A=I.indexOf("console.");if(S!==-1&&A>S);else{let F=null;for(let L=0;L<I.length;L++){let w=I[L];if(!F){if(w==='"')F="double";else if(w==="'")F="single";else if(w==="`")F="template";else if(I.slice(L).startsWith("console.")){let E=L+1;if(!Ae("no-console",N,s))r.push({filePath:e,line:N,column:E,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(F==="double"&&w==='"'||F==="single"&&w==="'"||F==="template"&&w==="`"){let E=0;for(let v=L-1;v>=0&&I[v]==="\\";v--)E++;if(E%2===0)F=null}}}}if(x&&!C.has(N)){let S=I,A=null,F=!1,L=!1,w="",E="";for(let v=0;v<S.length;v++){let D=S[v];if(F){if(E==="\\"){E=D;continue}if(L){if(D==="]")L=!1}else if(D==="[")L=!0;else if(D==="/"){F=!1;while(v+1<S.length&&/[a-z]/i.test(S[v+1]))v++;w="/"}E=D;continue}if(!A){if(D==='"'){A="double",E=D;continue}if(D==="'"){A="single",E=D;continue}if(D==="`"){A="template",E=D;continue}if(D==="/"&&S[v+1]!=="/"&&S[v+1]!=="*"&&$r(w,S,v)){F=!0,L=!1,E=D;continue}if(D!==" "&&D!=="\t")w=D}else if(A==="double"&&D==='"'||A==="single"&&D==="'"||A==="template"&&D==="`"){if(E!=="\\")A=null}else if(D==="$"&&S[v+1]==="{"&&E!=="\\"&&A!=="template"){if(!Ae("no-template-curly-in-string",N,s))r.push({filePath:e,line:N,column:v+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}E=D}}if(!h&&R&&!C.has(N)){let A=Yf(Jf(I)).replace(/'[^']*'|"[^"]*"/g,'""'),F=(v)=>/[^=!<>]=(?![=>])/.test(v),L=(v)=>{let D=I.match(v);if(D&&D.index!==void 0)return D.index+D[0].length;return Math.max(1,I.indexOf("(")+1)},w=Zf(A,/\b(?:if|while)\s*\(/);if(w){let v=Gf(w);if(F(v)){if(!Ae("no-cond-assign",N,s))r.push({filePath:e,line:N,column:L(/\b(?:if|while)\s*\(/),ruleId:"no-cond-assign",message:"Unexpected assignment within a conditional expression",severity:R,help:"Use === or == for comparison instead of = (assignment). Wrap intentional assignments in extra parentheses."})}}let E=Zf(A,/\bfor\s*\(/);if(E){let v=E.split(";");if(v.length>=2){let D=Gf(v[1]);if(F(D)){if(!Ae("no-cond-assign",N,s))r.push({filePath:e,line:N,column:L(/\bfor\s*\(/),ruleId:"no-cond-assign",message:"Unexpected assignment within a conditional expression",severity:R,help:"Use === or == for comparison instead of = (assignment). Wrap intentional assignments in extra parentheses."})}}}}}return r}function mS(e,n,t){let s=ct(n),i=ut(n),r=St(e,n,t,s,i);try{let o=Zs(t),l={filePath:e,config:t};for(let a of o.checkRules){if(!wr(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(Ae(u.ruleId,u.line,s))continue;if(i.has(u.line)&&Hs(u.ruleId))continue;let f=im(u,a.fullRuleId);r.push(a.severity?{...f,severity:a.severity}:f)}}}catch{}return r}async function hS(e,n){$e("runLint:start",{globs:e,options:n});let t=_e.DIAGNOSTICS;if(t)ee().info("[pickier:diagnostics] Starting lint process...");try{if(t)ee().info("[pickier:diagnostics] Loading config...");let s=await Ut(n.config);$e("config:loaded",{reporter:s.lint.reporter,ext:s.lint.extensions.join(",")});let i=e.length?e:["."],r=zt(i);if($e("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((w)=>{let E=w.trim();return E.startsWith(".")?E:`.${E}`}));if(t)ee().info(`[pickier:diagnostics] File extensions: ${Array.from(l).join(", ")}`);let a=_e.TIMEOUT_MS;if(t)ee().info(`[pickier:diagnostics] Glob timeout: ${a}ms`);let c=r.some((w)=>{let E=w.replace(/\/?\*\*\/*\*\*$/,""),v=Mt(E)?E:Ct(process.cwd(),E),D=process.cwd();return v!==D&&!v.startsWith(D+sm)}),u=c?nt(at):nt(s.ignores),f=qt(u);if(t){if(ee().info(`[pickier:diagnostics] Globbing outside project: ${c}, ignore patterns: ${u.length}`),c)ee().info(`[pickier:diagnostics] Using universal ignores: ${at.slice(0,5).join(", ")}... (${at.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(Vs(r[0]).isFile())m=[Mt(r[0])?r[0]:Ct(process.cwd(),r[0])]}catch{}let d=r.length===1&&/\*\*\/*\*$/.test(r[0]);if(!m.length&&d){let w=r[0].replace(/\/?\*\*\/*\*\*$/,"");if(t)ee().info(`[pickier:diagnostics] Using fast directory scan for: ${w}`);try{let v=[Mt(w)?w:Ct(process.cwd(),w)],D=0;while(v.length){let Y=v.pop();if(D++,t&&D%100===0)ee().info(`[pickier:diagnostics] Scanned ${D} directories, ${m.length} files found so far...`);let V=em(Y);for(let W of V){let B=nm(Y,W),J=Vs(B);if(f(B))continue;if(J.isDirectory())v.push(B);else m.push(B)}}if(t)ee().info(`[pickier:diagnostics] Fast scan complete: ${D} directories, ${m.length} total files`)}catch(E){if(t)ee().info(`[pickier:diagnostics] Fast scan failed: ${E?.message}, falling back to glob`);m=await Vt(tt(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 Vt(tt(r,{dot:!1,ignore:u,onlyFiles:!0,absolute:!0}),a,"glob"),t)ee().info(`[pickier:diagnostics] glob found ${m.length} files`)}if($e("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,R=0,k=[];for(let w of m){if(p++,t&&p%1000===0)ee().info(`[pickier:diagnostics] Filtering progress: ${p}/${m.length} files checked, ${g} included...`);if(w.replace(/\\/g,"/").includes("/node_modules/")){y++;continue}if(f(w)){x++;continue}if(!xr(w,l)){R++;continue}k.push(w),g++}if($e("filter:cli",{total:p,included:g,node_modules:y,ignored:x,wrongExt:R}),$e("filtered files",k.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): ${R}`);if(k.length>5000){if(ee().warn(`[pickier:warn] After filtering, ${k.length} files will be linted. This may take a while and use significant memory.`),k.length>50000)return ee().error(`[pickier:error] ${k.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 M=_e.CONCURRENCY;if(t)ee().info(`[pickier:diagnostics] Starting to process ${k.length} files with concurrency ${M}...`);let P=0,C=!!n._formatOnly,N=(await rm(k,M,async(w)=>{if(t){if(P++,P===1||P%10===0||P===k.length)ee().info(`[pickier:diagnostics] Processing file ${P}/${k.length}: ${Ks(process.cwd(),w)}`)}let E=tm(w,"utf8");if(C){let W=qs(E,s,w);if(W!==E)if(!n.dryRun)yr(w,W,"utf8");else return[{filePath:w,line:1,column:1,ruleId:"format",message:"File is not formatted",severity:"error",help:"Run pickier format with --write to apply formatting."}];return[]}let v=ct(E),Y=/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/.test(w)?ut(E):new Set,V=St(w,E,s,v,Y);try{let W=await Rr(w,E,s);for(let B of W){if(Ae(B.ruleId,B.line,v))continue;if(Y.has(B.line)&&Hs(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 W=new Set;V=V.filter((B)=>{let J=`${B.line}:${B.column}:${B.ruleId}`;if(W.has(J))return!1;return W.add(J),!0})}if(n.fix){let W=lm(w,E,s,v,Y);if(W=om(w,W,s),am(w,W,s))W=hg(W,s,ct(W),ut(W));if(W!==E){let B=ct(W),J=ut(W);if(V=St(w,W,s,B,J),!n.dryRun)yr(w,W,"utf8");if(n.dryRun&&(n.verbose!==void 0?n.verbose:s.verbose))ee().debug(se.gray(`dry-run: would apply fixes in ${Ks(process.cwd(),w)}`))}}return $e("scan done",Ks(process.cwd(),w),V.length),V})).flat();if(t)ee().info(`[pickier:diagnostics] Processing complete! Found ${N.length} issues total`);let T=N.filter((w)=>w.severity==="error").length,_=N.filter((w)=>w.severity==="warning").length;if($e("issues:summary",{errors:T,warnings:_}),t)ee().info(`[pickier:diagnostics] Errors: ${T}, Warnings: ${_}`);let S=n.reporter||s.lint.reporter,A=n.verbose!==void 0?n.verbose:s.verbose;if(S==="json")console.log(JSON.stringify({errors:T,warnings:_,issues:N},null,2));else if(S==="compact")for(let w of N)console.log(`${Ks(process.cwd(),w.filePath)}:${w.line}:${w.column} ${w.severity} ${w.ruleId} ${w.message}`);else if(N.length>0)console.log(A?Kf(N):Vf(N));if(N.length>0&&S!=="json"){let w=T+_,E=w===1?"problem":"problems",v=T===1?"error":"errors",D=_===1?"warning":"warnings",Y=Zs(s),V=0,W=0;for(let B of N){let J=B.ruleId;if(Y.fixableRuleIds.has(J)||Y.fixableBareRuleNames.has(J)){if(B.severity==="error")V++;else if(B.severity==="warning")W++}}if(console.log(),console.log(se.red(`\u2716 ${w} ${E} (${T} ${v}, ${_} ${D})`)),V>0||W>0){let B=V===1?"error":"errors",J=W===1?"warning":"warnings";console.log(se.gray(` ${V} ${B} and ${W} ${J} potentially fixable with the \`--fix\` option.`))}}if(A&&S!=="json")console.log(se.gray(`Scanned ${k.length} files, found ${T} errors and ${_} warnings.`));let F=n.maxWarnings??s.lint.maxWarnings,L=_e.FAIL_ON_WARNINGS;if(T>0)return $e("runLint:end",1),1;if(L&&_>0)return $e("runLint:end",1),1;if(F>=0&&_>F)return $e("runLint:end",1),1;return $e("runLint:end",0),0}catch(s){return ee().error("[pickier:error] runLint failed:",s?.message||s),$e("runLint:exception",s),1}}
224
- export{eS as a,uS as b,fS as c,Rr as d,St as e,mS as f,hS as g};
225
+ `)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 St(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=st(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=fm(e,n,t),p=!1,g=st(t,"no-debugger",["noDebugger"]),y=st(t,"no-console",["noConsole"]),x=st(t,"no-template-curly-in-string",["noTemplateCurlyInString"]),R=st(t,"no-cond-assign",["noCondAssign"]),k=/\bconsole\.log\s*\(/,M=/^\s*debugger\b/,P=new Set;if(a==="md"){let O=!1;for(let I=0;I<o.length;I++){if(/^(?:`{3,}|~{3,})/.test(o[I].trim())){O=!O;continue}if(O)P.add(I+1)}}let C=$r(n);for(let O=0;O<o.length;O++){let I=o[O],N=O+1;if(i.has(N))continue;if(!m&&!C.has(N)){let S=em(Qf(I)),A=tm(S,l);if(A.length>0&&!p){if(!Ae("quotes",N,s))r.push({filePath:e,line:N,column:(A[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<I.length&&(I.charCodeAt(T)===32||I.charCodeAt(T)===9))T++;let _=T>0?I.slice(0,T):"";if(d&&_.length>0&&!P.has(N)&&!C.has(N)&&xr(_,t.format.indent,t.format.indentStyle,I)){if(!Ae("indent",N,s))r.push({filePath:e,line:N,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&&!C.has(N)&&M.test(I)){if(!Ae("no-debugger",N,s))r.push({filePath:e,line:N,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&&!C.has(N)&&k.test(I)){let S=I.indexOf("//"),A=I.indexOf("console.");if(S!==-1&&A>S);else{let F=null;for(let L=0;L<I.length;L++){let w=I[L];if(!F){if(w==='"')F="double";else if(w==="'")F="single";else if(w==="`")F="template";else if(I.slice(L).startsWith("console.")){let E=L+1;if(!Ae("no-console",N,s))r.push({filePath:e,line:N,column:E,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(F==="double"&&w==='"'||F==="single"&&w==="'"||F==="template"&&w==="`"){let E=0;for(let v=L-1;v>=0&&I[v]==="\\";v--)E++;if(E%2===0)F=null}}}}if(x&&!C.has(N)){let S=I,A=null,F=!1,L=!1,w="",E="";for(let v=0;v<S.length;v++){let D=S[v];if(F){if(E==="\\"){E=D;continue}if(L){if(D==="]")L=!1}else if(D==="[")L=!0;else if(D==="/"){F=!1;while(v+1<S.length&&/[a-z]/i.test(S[v+1]))v++;w="/"}E=D;continue}if(!A){if(D==='"'){A="double",E=D;continue}if(D==="'"){A="single",E=D;continue}if(D==="`"){A="template",E=D;continue}if(D==="/"&&S[v+1]!=="/"&&S[v+1]!=="*"&&Pr(w,S,v)){F=!0,L=!1,E=D;continue}if(D!==" "&&D!=="\t")w=D}else if(A==="double"&&D==='"'||A==="single"&&D==="'"||A==="template"&&D==="`"){if(E!=="\\")A=null}else if(D==="$"&&S[v+1]==="{"&&E!=="\\"&&A!=="template"){if(!Ae("no-template-curly-in-string",N,s))r.push({filePath:e,line:N,column:v+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}E=D}}if(!h&&R&&!C.has(N)){let A=em(Qf(I)).replace(/'[^']*'|"[^"]*"/g,'""'),F=(v)=>/[^=!<>]=(?![=>])/.test(v),L=(v)=>{let D=I.match(v);if(D&&D.index!==void 0)return D.index+D[0].length;return Math.max(1,I.indexOf("(")+1)},w=Yf(A,/\b(?:if|while)\s*\(/);if(w){let v=Xf(w);if(F(v)){if(!Ae("no-cond-assign",N,s))r.push({filePath:e,line:N,column:L(/\b(?:if|while)\s*\(/),ruleId:"no-cond-assign",message:"Unexpected assignment within a conditional expression",severity:R,help:"Use === or == for comparison instead of = (assignment). Wrap intentional assignments in extra parentheses."})}}let E=Yf(A,/\bfor\s*\(/);if(E){let v=E.split(";");if(v.length>=2){let D=Xf(v[1]);if(F(D)){if(!Ae("no-cond-assign",N,s))r.push({filePath:e,line:N,column:L(/\bfor\s*\(/),ruleId:"no-cond-assign",message:"Unexpected assignment within a conditional expression",severity:R,help:"Use === or == for comparison instead of = (assignment). Wrap intentional assignments in extra parentheses."})}}}}}return r}function bS(e,n,t){let s=ct(n),i=ut(n),r=St(e,n,t,s,i);try{let o=Zs(t),l={filePath:e,config:t};for(let a of o.checkRules){if(!Rr(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(Ae(u.ruleId,u.line,s))continue;if(i.has(u.line)&&Hs(u.ruleId))continue;let f=lm(u,a.fullRuleId);r.push(a.severity?{...f,severity:a.severity}:f)}}}catch{}return r}async function xS(e,n){$e("runLint:start",{globs:e,options:n});let t=_e.DIAGNOSTICS;if(t)ee().info("[pickier:diagnostics] Starting lint process...");try{if(t)ee().info("[pickier:diagnostics] Loading config...");let s=await Ut(n.config);$e("config:loaded",{reporter:s.lint.reporter,ext:s.lint.extensions.join(",")});let i=e.length?e:["."],r=zt(i);if($e("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((w)=>{let E=w.trim();return E.startsWith(".")?E:`.${E}`}));if(t)ee().info(`[pickier:diagnostics] File extensions: ${Array.from(l).join(", ")}`);let a=_e.TIMEOUT_MS;if(t)ee().info(`[pickier:diagnostics] Glob timeout: ${a}ms`);let c=r.some((w)=>{let E=w.replace(/\/?\*\*\/*\*\*$/,""),v=Mt(E)?E:Ct(process.cwd(),E),D=process.cwd();return v!==D&&!v.startsWith(D+om)}),u=c?nt(at):nt(s.ignores),f=qt(u);if(t){if(ee().info(`[pickier:diagnostics] Globbing outside project: ${c}, ignore patterns: ${u.length}`),c)ee().info(`[pickier:diagnostics] Using universal ignores: ${at.slice(0,5).join(", ")}... (${at.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(Vs(r[0]).isFile())m=[Mt(r[0])?r[0]:Ct(process.cwd(),r[0])]}catch{}let d=r.length===1&&/\*\*\/*\*$/.test(r[0]);if(!m.length&&d){let w=r[0].replace(/\/?\*\*\/*\*\*$/,"");if(t)ee().info(`[pickier:diagnostics] Using fast directory scan for: ${w}`);try{let v=[Mt(w)?w:Ct(process.cwd(),w)],D=0;while(v.length){let Y=v.pop();if(D++,t&&D%100===0)ee().info(`[pickier:diagnostics] Scanned ${D} directories, ${m.length} files found so far...`);let V=sm(Y);for(let W of V){let B=rm(Y,W),J=Vs(B);if(f(B))continue;if(J.isDirectory())v.push(B);else m.push(B)}}if(t)ee().info(`[pickier:diagnostics] Fast scan complete: ${D} directories, ${m.length} total files`)}catch(E){if(t)ee().info(`[pickier:diagnostics] Fast scan failed: ${E?.message}, falling back to glob`);m=await Vt(tt(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 Vt(tt(r,{dot:!1,ignore:u,onlyFiles:!0,absolute:!0}),a,"glob"),t)ee().info(`[pickier:diagnostics] glob found ${m.length} files`)}if($e("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,R=0,k=[];for(let w of m){if(p++,t&&p%1000===0)ee().info(`[pickier:diagnostics] Filtering progress: ${p}/${m.length} files checked, ${g} included...`);if(w.replace(/\\/g,"/").includes("/node_modules/")){y++;continue}if(f(w)){x++;continue}if(!wr(w,l)){R++;continue}k.push(w),g++}if($e("filter:cli",{total:p,included:g,node_modules:y,ignored:x,wrongExt:R}),$e("filtered files",k.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): ${R}`);if(k.length>5000){if(ee().warn(`[pickier:warn] After filtering, ${k.length} files will be linted. This may take a while and use significant memory.`),k.length>50000)return ee().error(`[pickier:error] ${k.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 M=_e.CONCURRENCY;if(t)ee().info(`[pickier:diagnostics] Starting to process ${k.length} files with concurrency ${M}...`);let P=0,C=!!n._formatOnly,N=(await am(k,M,async(w)=>{if(t){if(P++,P===1||P%10===0||P===k.length)ee().info(`[pickier:diagnostics] Processing file ${P}/${k.length}: ${Ks(process.cwd(),w)}`)}let E=im(w,"utf8");if(C){let W=qs(E,s,w);if(W!==E)if(!n.dryRun)br(w,W,"utf8");else return[{filePath:w,line:1,column:1,ruleId:"format",message:"File is not formatted",severity:"error",help:"Run pickier format with --write to apply formatting."}];return[]}let v=ct(E),Y=/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/.test(w)?ut(E):new Set,V=St(w,E,s,v,Y);try{let W=await kr(w,E,s);for(let B of W){if(Ae(B.ruleId,B.line,v))continue;if(Y.has(B.line)&&Hs(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 W=new Set;V=V.filter((B)=>{let J=`${B.line}:${B.column}:${B.ruleId}`;if(W.has(J))return!1;return W.add(J),!0})}if(n.fix){let W=um(w,E,s,v,Y);if(W=cm(w,W,s),fm(w,W,s))W=gg(W,s,ct(W),ut(W));if(W!==E){let B=ct(W),J=ut(W);if(V=St(w,W,s,B,J),!n.dryRun)br(w,W,"utf8");if(n.dryRun&&(n.verbose!==void 0?n.verbose:s.verbose))ee().debug(se.gray(`dry-run: would apply fixes in ${Ks(process.cwd(),w)}`))}}return $e("scan done",Ks(process.cwd(),w),V.length),V})).flat();if(t)ee().info(`[pickier:diagnostics] Processing complete! Found ${N.length} issues total`);let T=N.filter((w)=>w.severity==="error").length,_=N.filter((w)=>w.severity==="warning").length;if($e("issues:summary",{errors:T,warnings:_}),t)ee().info(`[pickier:diagnostics] Errors: ${T}, Warnings: ${_}`);let S=n.reporter||s.lint.reporter,A=n.verbose!==void 0?n.verbose:s.verbose;if(S==="json")console.log(JSON.stringify({errors:T,warnings:_,issues:N},null,2));else if(S==="compact")for(let w of N)console.log(`${Ks(process.cwd(),w.filePath)}:${w.line}:${w.column} ${w.severity} ${w.ruleId} ${w.message}`);else if(N.length>0)console.log(A?Zf(N):Gf(N));if(N.length>0&&S!=="json"){let w=T+_,E=w===1?"problem":"problems",v=T===1?"error":"errors",D=_===1?"warning":"warnings",Y=Zs(s),V=0,W=0;for(let B of N){let J=B.ruleId;if(Y.fixableRuleIds.has(J)||Y.fixableBareRuleNames.has(J)){if(B.severity==="error")V++;else if(B.severity==="warning")W++}}if(console.log(),console.log(se.red(`\u2716 ${w} ${E} (${T} ${v}, ${_} ${D})`)),V>0||W>0){let B=V===1?"error":"errors",J=W===1?"warning":"warnings";console.log(se.gray(` ${V} ${B} and ${W} ${J} potentially fixable with the \`--fix\` option.`))}}if(A&&S!=="json")console.log(se.gray(`Scanned ${k.length} files, found ${T} errors and ${_} warnings.`));let F=n.maxWarnings??s.lint.maxWarnings,L=_e.FAIL_ON_WARNINGS;if(T>0)return $e("runLint:end",1),1;if(L&&_>0)return $e("runLint:end",1),1;if(F>=0&&_>F)return $e("runLint:end",1),1;return $e("runLint:end",0),0}catch(s){return ee().error("[pickier:error] runLint failed:",s?.message||s),$e("runLint:exception",s),1}}
226
+ export{oS as a,gS as b,yS as c,kr as d,St as e,bS as f,xS as g};