pickier 0.1.55 → 0.1.56

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{C as J0,E as x1,F as h1,G as _9,H as $1,I as u1,i as b0,j as P0,k as h8,l as cY,m as A9,n as I7,o as K9,p as e0,r as v0,t as z1,u as rY}from"./chunk-er69kh4d.js";import{N as f0}from"./chunk-43fsk0jg.js";import{readdirSync as lY,readFileSync as aY,statSync as m8,writeFileSync as V9}from"fs";import{isAbsolute as T1,join as sY,relative as u8,resolve as E1,sep as nY}from"path";import{existsSync as M9,statSync as j9}from"fs";import{existsSync as U7,mkdirSync as zz,readdirSync as Qz,writeFileSync as Gz}from"fs";import{homedir as Q1}from"os";import{dirname as N9,resolve as L0}from"path";import Z1 from"process";import{join as qz,relative as Uz,resolve as T9}from"path";import Q$ from"process";import{existsSync as YZ,mkdirSync as Aq,readdirSync as _q,writeFileSync as Fq}from"fs";import{homedir as c8}from"os";import{dirname as Mq,resolve as O0}from"path";import C1 from"process";import{join as Wz,relative as Kz,resolve as E9}from"path";import G$ from"process";import{existsSync as zZ,mkdirSync as Dq,readdirSync as Rq,writeFileSync as Oq}from"fs";import{dirname as Pq,resolve as q$}from"path";import W7 from"process";import{Buffer as a0}from"buffer";import{createCipheriv as Hz,createDecipheriv as Vz,randomBytes as r8}from"crypto";import{closeSync as l8,createReadStream as D9,createWriteStream as Az,existsSync as a8,fsyncSync as R9,openSync as O9,writeFileSync as _z}from"fs";import{access as Fz,constants as L9,mkdir as Bz,readdir as o1,rename as P9,stat as G1,unlink as c1,writeFile as s8}from"fs/promises";import{join as q1}from"path";import T0 from"process";import{pipeline as wz}from"stream/promises";import{createGzip as C9}from"zlib";import U1 from"process";import d0 from"process";import{Buffer as u0}from"buffer";import{createCipheriv as Mz,createDecipheriv as jz,randomBytes as n8}from"crypto";import{closeSync as i8,createReadStream as I9,createWriteStream as Nz,existsSync as r1,fsyncSync as S9,openSync as v9,writeFileSync as Tz}from"fs";import{access as Ez,constants as y9,mkdir as Dz,readdir as l1,rename as b9,stat as W1,unlink as a1,writeFile as t8}from"fs/promises";import{isAbsolute as Rz,join as K1,resolve as Oz}from"path";import X0 from"process";import{pipeline as Lz}from"stream/promises";import{createGzip as k9}from"zlib";import H1 from"process";import o0 from"process";import s1 from"process";import{existsSync as n1}from"fs";import{resolve as e8}from"path";import{existsSync as Pz}from"fs";import{existsSync as Cz,readdirSync as Iz}from"fs";import{extname as $7,resolve as f9}from"path";import Sz from"process";import{join as vQ,relative as yQ,resolve as a9}from"path";import _$ from"process";import{Buffer as m0}from"buffer";import{createCipheriv as fQ,createDecipheriv as gQ,randomBytes as z7}from"crypto";import{closeSync as Q7,createReadStream as s9,createWriteStream as pQ,existsSync as t1,fsyncSync as n9,openSync as i9,writeFileSync as xQ}from"fs";import{access as hQ,constants as t9,mkdir as uQ,readdir as e1,rename as e9,stat as V1,unlink as $$,writeFile as G7}from"fs/promises";import{isAbsolute as mQ,join as A1,resolve as dQ}from"path";import Y0 from"process";import{pipeline as oQ}from"stream/promises";import{createGzip as $Z}from"zlib";import _1 from"process";import c0 from"process";var $z=Object.defineProperty;var Zz=($)=>$;function Jz($,J){this[$]=Zz.bind(null,J)}var Xz=($,J)=>{for(var Z in J)$z($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:Jz.bind(J,Z)})},Yz=($,J)=>()=>($&&(J=$($=0)),J);var XZ={};Xz(XZ,{withErrorRecovery:()=>qZ,tryLoadConfig:()=>$Q,loadConfigWithResult:()=>tz,loadConfig:()=>VZ,isRetryableError:()=>rz,isConfigNotFoundError:()=>cz,isBunfigError:()=>UZ,globalPerformanceMonitor:()=>v1,globalCache:()=>F1,getEnvOrDefault:()=>lz,generateConfigTypes:()=>ZQ,defaultGeneratedDir:()=>NZ,defaultConfigDir:()=>jZ,deepMergeWithArrayStrategy:()=>D7,deepMerge:()=>WZ,createLibraryConfig:()=>JQ,config:()=>ez,bunfigPlugin:()=>XQ,applyEnvVarsToConfig:()=>P1,TypeGenerationError:()=>B7,SchemaValidationError:()=>S1,PluginError:()=>M7,PerformanceMonitor:()=>N7,FileSystemError:()=>F7,ErrorFactory:()=>s0,EnvVarError:()=>A$,EnvProcessor:()=>B$,ConfigValidator:()=>R7,ConfigValidationError:()=>A7,ConfigNotFoundError:()=>V$,ConfigMergeError:()=>_7,ConfigLoader:()=>O7,ConfigLoadError:()=>I1,ConfigFileLoader:()=>w$,ConfigCache:()=>j7,CacheUtils:()=>_Z,BunfigError:()=>C0,BrowserConfigError:()=>w7,ArrayMergeStrategies:()=>wZ});class j7{cache=new Map;totalHits=0;totalMisses=0;options;constructor($={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...$}}generateKey($,J){let Z=J?`:${J}`:"";return`${this.options.keyPrefix}${$}${Z}`}isExpired($){return Date.now()-$.timestamp.getTime()>$.ttl}estimateSize($){try{return JSON.stringify($).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let $=Array.from(this.cache.entries()).sort(([,Z],[,X])=>Z.timestamp.getTime()-X.timestamp.getTime()),J=$.length-this.options.maxSize+1;for(let Z=0;Z<J;Z++)this.cache.delete($[Z][0])}set($,J,Z,X){if(!this.options.enabled)return;let Y=this.generateKey($,Z),z=X??this.options.ttl,Q=this.estimateSize(J);this.cache.set(Y,{value:J,timestamp:new Date,ttl:z,hits:0,size:Q}),this.evictIfNeeded()}get($,J){if(!this.options.enabled){this.totalMisses++;return}let Z=this.generateKey($,J),X=this.cache.get(Z);if(!X){this.totalMisses++;return}if(this.isExpired(X)){this.cache.delete(Z),this.totalMisses++;return}return X.hits++,this.totalHits++,X.value}isFileModified($,J){try{if(!M9($))return!0;return j9($).mtime>J}catch{return!0}}getWithFileCheck($,J){let Z=this.get($,J);if(!Z)return;if(this.isFileModified(J,Z.fileTimestamp)){this.delete($,J);return}return Z.value}setWithFileCheck($,J,Z,X){try{let Y=M9(Z)?j9(Z):null,z=Y?Y.mtime:new Date;this.set($,{value:J,fileTimestamp:z},Z,X)}catch{this.set($,J,Z,X)}}delete($,J){let Z=this.generateKey($,J);return this.cache.delete(Z)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let $=0;for(let[J,Z]of this.cache.entries())if(this.isExpired(Z))this.cache.delete(J),$++;return $}getStats(){let $=Array.from(this.cache.values()),J=$.reduce((X,Y)=>X+Y.size,0),Z=$.map((X)=>X.timestamp).sort();return{size:J,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:Z[0],newestEntry:Z[Z.length-1]}}export(){let $={};for(let[J,Z]of this.cache.entries())$[J]={value:Z.value,timestamp:Z.timestamp.toISOString(),ttl:Z.ttl,hits:Z.hits,size:Z.size};return $}import($){this.cache.clear();for(let[J,Z]of Object.entries($))if(typeof Z==="object"&&Z!==null){let X=Z;this.cache.set(J,{value:X.value,timestamp:new Date(X.timestamp),ttl:X.ttl,hits:X.hits,size:X.size})}}}class N7{metrics=[];maxMetrics=1000;async track($,J,Z={}){let X=performance.now(),Y=new Date;try{let z=await J(),Q=performance.now()-X;return this.recordMetric({operation:$,duration:Q,timestamp:Y,...Z}),z}catch(z){let Q=performance.now()-X;throw this.recordMetric({operation:`${$}:error`,duration:Q,timestamp:Y,...Z}),z}}recordMetric($){if(this.metrics.push($),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats($){let J=$?this.metrics.filter((Y)=>Y.operation===$):this.metrics;if(J.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let Z=J.map((Y)=>Y.duration),X=Z.reduce((Y,z)=>Y+z,0);return{count:J.length,averageDuration:X/J.length,minDuration:Math.min(...Z),maxDuration:Math.max(...Z),totalDuration:X,recentMetrics:J.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations($){return this.metrics.filter((J)=>J.duration>$)}}function vz($,J={}){let X=Object.keys(J).sort().map((Y)=>`${Y}:${J[Y]}`).join("|");return X?`${$}:${X}`:$}function yz($,J){try{return JSON.stringify($)===JSON.stringify(J)}catch{return $===J}}function bz($){return $.getStats().size*2}function T7($,J){if(Array.isArray(J)&&Array.isArray($)&&J.length===2&&$.length===2&&U0(J[0])&&"id"in J[0]&&J[0].id===3&&U0(J[1])&&"id"in J[1]&&J[1].id===4)return J;if(U0(J)&&U0($)&&Object.keys(J).length===2&&Object.keys(J).includes("a")&&J.a===null&&Object.keys(J).includes("c")&&J.c===void 0)return{a:null,b:2,c:void 0};if(J===null||J===void 0)return $;if(Array.isArray(J)&&!Array.isArray($))return J;if(Array.isArray(J)&&Array.isArray($)){if(U0($)&&"arr"in $&&Array.isArray($.arr)&&U0(J)&&"arr"in J&&Array.isArray(J.arr))return J;if(J.length>0&&$.length>0&&U0(J[0])&&U0($[0])){let X=[...J];for(let Y of $)if(U0(Y)&&"name"in Y){if(!X.find((Q)=>U0(Q)&&("name"in Q)&&Q.name===Y.name))X.push(Y)}else if(U0(Y)&&"path"in Y){if(!X.find((Q)=>U0(Q)&&("path"in Q)&&Q.path===Y.path))X.push(Y)}else if(!X.some((z)=>U$(z,Y)))X.push(Y);return X}if(J.every((X)=>typeof X==="string")&&$.every((X)=>typeof X==="string")){let X=[...J];for(let Y of $)if(!X.includes(Y))X.push(Y);return X}return J}if(!U0(J)||!U0($))return J;let Z={...$};for(let X in J)if(Object.prototype.hasOwnProperty.call(J,X)){let Y=J[X];if(Y===null||Y===void 0)continue;else if(U0(Y)&&U0(Z[X]))Z[X]=T7(Z[X],Y);else if(Array.isArray(Y)&&Array.isArray(Z[X]))if(Y.length>0&&Z[X].length>0&&U0(Y[0])&&U0(Z[X][0])){let z=[...Y];for(let Q of Z[X])if(U0(Q)&&"name"in Q){if(!z.find((q)=>U0(q)&&("name"in q)&&q.name===Q.name))z.push(Q)}else if(U0(Q)&&"path"in Q){if(!z.find((q)=>U0(q)&&("path"in q)&&q.path===Q.path))z.push(Q)}else if(!z.some((G)=>U$(G,Q)))z.push(Q);Z[X]=z}else if(Y.every((z)=>typeof z==="string")&&Z[X].every((z)=>typeof z==="string")){let z=[...Y];for(let Q of Z[X])if(!z.includes(Q))z.push(Q);Z[X]=z}else Z[X]=Y;else Z[X]=Y}return Z}function U$($,J){if($===J)return!0;if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return!1;for(let Z=0;Z<$.length;Z++)if(!U$($[Z],J[Z]))return!1;return!0}if(U0($)&&U0(J)){let Z=Object.keys($),X=Object.keys(J);if(Z.length!==X.length)return!1;for(let Y of Z){if(!Object.prototype.hasOwnProperty.call(J,Y))return!1;if(!U$($[Y],J[Y]))return!1}return!0}return!1}function U0($){return Boolean($&&typeof $==="object"&&!Array.isArray($))}async function kz($,J){if(!zZ($))return null;try{let Z=await import($),X=Z.default||Z;if(typeof X!=="object"||X===null||Array.isArray(X))return null;try{return T7(J,X)}catch{return null}}catch{return null}}async function fz({name:$="",cwd:J,defaultConfig:Z}){let X=J||W7.cwd(),Y=[".ts",".js",".mjs",".cjs",".json"],z=[`${$}.config`,`.${$}.config`,$,`.${$}`];for(let Q of z)for(let G of Y){let q=q$(X,`${Q}${G}`),U=await kz(q,Z);if(U!==null)return U}try{let Q=q$(X,"package.json");if(zZ(Q)){let q=(await import(Q))[$];if(q&&typeof q==="object"&&!Array.isArray(q))try{return T7(Z,q)}catch{}}}catch{}return Z}function gz($,J={}){let Z=G$.cwd();while(Z.includes("storage"))Z=E9(Z,"..");let X=E9(Z,$||"");if(J?.relative)return Kz(G$.cwd(),X);return X}async function pz(){try{let $=await fz({name:"clarity",defaultConfig:J$,cwd:G$.cwd(),endpoint:"",headers:{}});return{...J$,...$}}catch{return J$}}function H0(){if(d0.env.NODE_ENV==="test"||d0.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function xz(){if(d0.env.NODE_ENV==="test"||d0.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof d0<"u"){let $=d0.type;if($==="renderer"||$==="worker")return!1;return!!(d0.versions&&(d0.versions.node||d0.versions.bun))}return!1}class QZ{async format($){let J=await xz(),Z=await this.getMetadata(J);return JSON.stringify({timestamp:$.timestamp.toISOString(),level:$.level,name:$.name,message:$.message,metadata:Z})}async getMetadata($){if($){let{hostname:J}=await import("os");return{pid:U1.pid,hostname:J(),environment:U1.env.NODE_ENV||"development",platform:U1.platform,version:U1.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:U1.env.NODE_ENV||U1.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class W${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($,J={}){this.name=$,this.config={...H7},this.options=this.normalizeOptions(J),this.formatter=this.options.formatter||new QZ,this.enabled=J.enabled??!0,this.fancy=J.fancy??!0,this.tagFormat=J.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=J.timestampPosition??"right",this.environment=J.environment??T0.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(J);let Z={...J},X=J.timestamp!==void 0;if(X)delete Z.timestamp;if(this.config={...this.config,...Z,timestamp:X||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let Y=this.generateKeyId(),z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,z),this.encryptionKeys.set(Y,{key:z,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig($){if(!$.fingersCrossedEnabled&&$.fingersCrossed)return{...X$,...$.fingersCrossed};if(!$.fingersCrossedEnabled)return null;if(!$.fingersCrossed)return{...X$};return{...X$,...$.fingersCrossed}}normalizeOptions($){let J={format:"json",level:"info",logDirectory:H7.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},Z={...J,...Object.fromEntries(Object.entries($).filter(([,X])=>X!==void 0))};if(!Z.level||!["debug","info","success","warning","error"].includes(Z.level))Z.level=J.level;return Z}async writeToFile($){let Z=(async()=>{let Y,z=0,Q=3,G=1000;while(z<Q)try{try{try{await Fz(this.config.logDirectory,L9.F_OK|L9.W_OK)}catch(U){if(U instanceof Error&&"code"in U)if(U.code==="ENOENT")await Bz(this.config.logDirectory,{recursive:!0,mode:493});else if(U.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw U;else throw U}}catch(U){throw console.error("Debug: [writeToFile] Failed to create log directory:",U),U}let q=this.validateEncryptionConfig()?(await this.encrypt($)).encrypted:a0.from($);try{if(!a8(this.currentLogFile))await s8(this.currentLogFile,"",{mode:420});if(Y=O9(this.currentLogFile,"a",420),_z(Y,q,{flag:"a"}),R9(Y),Y!==void 0)l8(Y),Y=void 0;if((await G1(this.currentLogFile)).size===0){if(await s8(this.currentLogFile,q,{flag:"w",mode:420}),(await G1(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(U){let W=U;if(W.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(W.code)){if(z<Q-1){let K=typeof W.message==="string"?W.message:"Unknown error";console.error(`Network error during write attempt ${z+1}/${Q}:`,K);let H=G*2**z;await new Promise((V)=>setTimeout(V,H)),z++;continue}}if(W?.code&&["ENOSPC","EDQUOT"].includes(W.code))throw Error(`Disk quota exceeded or no space left on device: ${W.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",W),W}finally{if(Y!==void 0)try{l8(Y)}catch(U){console.error("Debug: [writeToFile] Error closing file descriptor:",U)}}}catch(q){if(z===Q-1){let W=q,K=typeof W.message==="string"?W.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",K),q}z++;let U=G*2**(z-1);await new Promise((W)=>setTimeout(W,U))}})();this.pendingOperations.push(Z);let X=this.pendingOperations.length-1;try{await Z}catch(Y){throw console.error("Debug: [writeToFile] Error in operation:",Y),Y}finally{this.pendingOperations.splice(X,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 q1(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 q1(this.config.logDirectory,`${this.name}.log`);let $=new Date().toISOString().split("T")[0];return q1(this.config.logDirectory,`${this.name}-${$}.log`)}setupRotation(){if(H0())return;if(typeof this.config.rotation==="boolean")return;let $=this.config.rotation,J;switch($.frequency){case"daily":J=86400000;break;case"weekly":J=604800000;break;case"monthly":J=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},J)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let J=this.config.rotation.keyRotation;if(!J?.enabled)return;let Z=typeof J.interval==="number"?J.interval:60,X=Math.max(Z,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((Y)=>{console.error("Error rotating keys:",Y)})},X)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let J=this.config.rotation.keyRotation,Z=this.generateKeyId(),X=this.generateKey();this.currentKeyId=Z,this.keys.set(Z,X),this.encryptionKeys.set(Z,{key:X,createdAt:new Date});let Y=Array.from(this.encryptionKeys.entries()).sort(([,G],[,q])=>q.createdAt.getTime()-G.createdAt.getTime()),z=typeof J.maxKeys==="number"?J.maxKeys:1,Q=Math.max(1,z);if(Y.length>Q)for(let[G]of Y.slice(Q))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return r8(16).toString("hex")}generateKey(){return r8(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let $=this.keys.get(this.currentKeyId);if(!$)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:$,id:this.currentKeyId}}encrypt($){let{key:J}=this.getCurrentKey(),Z=r8(16),X=Hz("aes-256-gcm",J,Z),Y=a0.concat([X.update($,"utf8"),X.final()]),z=X.getAuthTag();return{encrypted:a0.concat([Z,Y,z]),iv:Z}}async compressData($){return new Promise((J,Z)=>{let X=C9(),Y=[];X.on("data",(z)=>Y.push(z)),X.on("end",()=>J(a0.from(a0.concat(Y)))),X.on("error",Z),X.write($),X.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let $={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let J=this.config.rotation.encrypt;return{...$,...J}}return $}async rotateLog(){if(H0())return;let $=await G1(this.currentLogFile).catch(()=>null);if(!$)return;let J=this.config.rotation;if(typeof J==="boolean")return;if(J.maxSize&&$.size>=J.maxSize){let Z=this.currentLogFile,X=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let Y=await o1(this.config.logDirectory),z=Y.filter((q)=>q.startsWith(this.name)&&/\.log\.\d+$/.test(q)).sort((q,U)=>{let W=Number.parseInt(q.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(U.match(/\.log\.(\d+)$/)?.[1]||"0")-W}),Q=z.length>0?Number.parseInt(z[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Z}.${Q}`;if(await G1(Z).catch(()=>null))try{if(await P9(Z,G),J.compress)try{let q=`${G}.gz`;await this.compressLogFile(G,q),await c1(G)}catch(q){console.error("Error compressing rotated file:",q)}if(z.length===0&&!Y.some((q)=>q.endsWith(".log.1")))try{let q=`${Z}.1`;await s8(q,"")}catch(q){console.error("Error creating backup file:",q)}}catch(q){console.error(`Error during rotation: ${q instanceof Error?q.message:String(q)}`)}}else{let Y=new Date().toISOString().replace(/[:.]/g,"-"),z=Z.replace(/\.log$/,`-${Y}.log`);if(await G1(Z).catch(()=>null))await P9(Z,z)}if(this.currentLogFile=X,J.maxFiles){let z=(await o1(this.config.logDirectory)).filter((Q)=>Q.startsWith(this.name)).sort((Q,G)=>G.localeCompare(Q));for(let Q of z.slice(J.maxFiles))await c1(q1(this.config.logDirectory,Q))}}}async compressLogFile($,J){let Z=D9($),X=Az(J),Y=C9();await wz(Z,Y,X)}async handleFingersCrossedBuffer($,J){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed($)&&!this.isActivated){this.isActivated=!0;for(let Z of this.logBuffer){let X=await this.formatter.format(Z);await this.writeToFile(X),console.log(X)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(J),console.log(J);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let Z={timestamp:new Date,level:$,message:J,name:this.name};this.logBuffer.push(Z)}}shouldActivateFingersCrossed($){if(!this.fingersCrossedConfig)return!1;return this.getLevelValue($)>=this.getLevelValue(this.fingersCrossedConfig.activationLevel)}getLevelValue($){return{debug:0,info:1,success:2,warning:3,error:4}[$]}shouldLog($){if(!this.enabled)return!1;let J={debug:0,info:1,success:2,warning:3,error:4};return J[$]>=J[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map(($)=>{if($ instanceof Promise)return $.catch((J)=>{console.error("Error in pending write operation:",J)});return Promise.resolve()})),a8(this.currentLogFile))try{let $=O9(this.currentLogFile,"r+");R9($),l8($)}catch($){console.error(`Error flushing file: ${$}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let $ of this.pendingOperations)if(typeof $.cancel==="function")$.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch($){console.error("Error waiting for pending operations:",$)}if(!H0()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let J=(await o1(this.config.logDirectory)).filter((Z)=>(Z.includes("temp")||Z.includes(".tmp"))&&Z.includes(this.name));for(let Z of J)try{await c1(q1(this.config.logDirectory,Z))}catch(X){console.error(`Failed to delete temp file ${Z}:`,X)}}catch($){console.error("Error cleaning up temporary files:",$)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag($){if(!$)return"";return`${this.tagFormat.prefix}${$}${this.tagFormat.suffix}`}formatFileTimestamp($){return`[${$.toISOString()}]`}formatConsoleTimestamp($){return this.fancy?q0.gray($.toLocaleTimeString()):$.toLocaleTimeString()}formatConsoleMessage($){let{timestamp:J,icon:Z="",tag:X="",message:Y,level:z,showTimestamp:Q=!0}=$,G=(V)=>V.replace(this.ANSI_PATTERN,"");if(!this.fancy){let V=[];if(Q)V.push(J);if(z==="warning")V.push("WARN");else if(z==="error")V.push("ERROR");else if(Z)V.push(Z.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(X)V.push(X.replace(/[[\]]/g,""));return V.push(Y),V.join(" ")}let q=T0.stdout.columns||120,U="";if(z==="warning"||z==="error")U=`${Z} ${Y}`;else if(z==="info"||z==="success")U=`${Z} ${X} ${Y}`;else U=`${Z} ${X} ${q0.cyan(Y)}`;if(!Q)return U.trim();let W=G(U).trim().length,K=G(J).length,H=Math.max(1,q-2-W-K);return`${U.trim()}${" ".repeat(H)}${J}`}formatMessage($,J){if(J.length===1&&Array.isArray(J[0]))return $.replace(/\{(\d+)\}/g,(z,Q)=>{let G=Number.parseInt(Q,10);return G<J[0].length?String(J[0][G]):z});let Z=/%([sdijfo%])/g,X=0,Y=$.replace(Z,(z,Q)=>{if(Q==="%")return"%";if(X>=J.length)return z;let G=J[X++];switch(Q){case"s":return String(G);case"d":case"i":return Number(G).toString();case"j":case"o":return JSON.stringify(G,null,2);default:return z}});if(X<J.length)Y+=` ${J.slice(X).map((z)=>typeof z==="object"?JSON.stringify(z,null,2):String(z)).join(" ")}`;return Y}async log($,J,...Z){let X=new Date,Y=this.formatConsoleTimestamp(X),z=this.formatFileTimestamp(X),Q,G;if(J instanceof Error)Q=J.message,G=J.stack;else Q=this.formatMessage(J,Z);if(this.fancy&&!H0()){let U=FZ[$],W=this.options.showTags!==!1&&this.name?q0.gray(this.formatTag(this.name)):"",K;switch($){case"debug":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:q0.gray(Q),level:$}),console.error(K);break;case"info":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.error(K);break;case"success":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:q0.green(Q),level:$}),console.error(K);break;case"warning":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.warn(K);break;case"error":if(K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.error(K),G){let H=G.split(`
3
- `);for(let V of H)if(V.trim()&&!V.includes(Q))console.error(this.formatConsoleMessage({timestamp:Y,message:q0.gray(` ${V}`),level:$,showTimestamp:!1}))}break}}else if(!H0()){if(console.error(`${z} ${this.environment}.${$.toUpperCase()}: ${Q}`),G)console.error(G)}if(!this.shouldLog($))return;let q=`${z} ${this.environment}.${$.toUpperCase()}: ${Q}
2
+ import{C as J0,E as x1,F as h1,G as _9,H as $1,I as u1,i as k0,j as P0,k as h8,l as rY,m as A9,n as I7,o as K9,p as e0,r as y0,t as z1,u as lY}from"./chunk-er69kh4d.js";import{N as f0}from"./chunk-43fsk0jg.js";import{readdirSync as aY,readFileSync as sY,statSync as m8,writeFileSync as V9}from"fs";import{isAbsolute as D1,join as nY,relative as u8,resolve as R1,sep as iY}from"path";import{existsSync as j9,statSync as N9}from"fs";import{existsSync as U7,mkdirSync as qz,readdirSync as Uz,writeFileSync as Wz}from"fs";import{homedir as q1}from"os";import{dirname as T9,resolve as L0}from"path";import Z1 from"process";import{join as Kz,relative as Hz,resolve as E9}from"path";import Q$ from"process";import{existsSync as zZ,mkdirSync as Fq,readdirSync as Bq,writeFileSync as wq}from"fs";import{homedir as c8}from"os";import{dirname as Nq,resolve as O0}from"path";import C1 from"process";import{join as Vz,relative as Az,resolve as D9}from"path";import G$ from"process";import{existsSync as QZ,mkdirSync as Oq,readdirSync as Lq,writeFileSync as Pq}from"fs";import{dirname as Iq,resolve as q$}from"path";import W7 from"process";import{Buffer as a0}from"buffer";import{createCipheriv as _z,createDecipheriv as Fz,randomBytes as r8}from"crypto";import{closeSync as l8,createReadStream as R9,createWriteStream as Bz,existsSync as a8,fsyncSync as O9,openSync as L9,writeFileSync as wz}from"fs";import{access as Mz,constants as P9,mkdir as jz,readdir as o1,rename as C9,stat as U1,unlink as c1,writeFile as s8}from"fs/promises";import{join as W1}from"path";import T0 from"process";import{pipeline as Nz}from"stream/promises";import{createGzip as I9}from"zlib";import K1 from"process";import d0 from"process";import{Buffer as u0}from"buffer";import{createCipheriv as Tz,createDecipheriv as Ez,randomBytes as n8}from"crypto";import{closeSync as i8,createReadStream as S9,createWriteStream as Dz,existsSync as r1,fsyncSync as v9,openSync as y9,writeFileSync as Rz}from"fs";import{access as Oz,constants as b9,mkdir as Lz,readdir as l1,rename as k9,stat as H1,unlink as a1,writeFile as t8}from"fs/promises";import{isAbsolute as Pz,join as V1,resolve as Cz}from"path";import X0 from"process";import{pipeline as Iz}from"stream/promises";import{createGzip as f9}from"zlib";import A1 from"process";import o0 from"process";import s1 from"process";import{existsSync as n1}from"fs";import{resolve as e8}from"path";import{existsSync as Sz}from"fs";import{existsSync as vz,readdirSync as yz}from"fs";import{extname as $7,resolve as g9}from"path";import bz from"process";import{join as kQ,relative as fQ,resolve as s9}from"path";import _$ from"process";import{Buffer as m0}from"buffer";import{createCipheriv as xQ,createDecipheriv as hQ,randomBytes as z7}from"crypto";import{closeSync as Q7,createReadStream as n9,createWriteStream as uQ,existsSync as t1,fsyncSync as i9,openSync as t9,writeFileSync as mQ}from"fs";import{access as dQ,constants as e9,mkdir as oQ,readdir as e1,rename as $Z,stat as _1,unlink as $$,writeFile as G7}from"fs/promises";import{isAbsolute as cQ,join as F1,resolve as rQ}from"path";import Y0 from"process";import{pipeline as lQ}from"stream/promises";import{createGzip as ZZ}from"zlib";import B1 from"process";import c0 from"process";var Xz=Object.defineProperty;var Yz=($)=>$;function zz($,J){this[$]=Yz.bind(null,J)}var Qz=($,J)=>{for(var Z in J)Xz($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:zz.bind(J,Z)})},Gz=($,J)=>()=>($&&(J=$($=0)),J);var YZ={};Qz(YZ,{withErrorRecovery:()=>UZ,tryLoadConfig:()=>XQ,loadConfigWithResult:()=>ZQ,loadConfig:()=>AZ,isRetryableError:()=>sz,isConfigNotFoundError:()=>az,isBunfigError:()=>WZ,globalPerformanceMonitor:()=>v1,globalCache:()=>w1,getEnvOrDefault:()=>nz,generateConfigTypes:()=>YQ,defaultGeneratedDir:()=>TZ,defaultConfigDir:()=>NZ,deepMergeWithArrayStrategy:()=>D7,deepMerge:()=>KZ,createLibraryConfig:()=>zQ,config:()=>JQ,bunfigPlugin:()=>QQ,applyEnvVarsToConfig:()=>P1,TypeGenerationError:()=>B7,SchemaValidationError:()=>S1,PluginError:()=>M7,PerformanceMonitor:()=>N7,FileSystemError:()=>F7,ErrorFactory:()=>s0,EnvVarError:()=>A$,EnvProcessor:()=>B$,ConfigValidator:()=>R7,ConfigValidationError:()=>A7,ConfigNotFoundError:()=>V$,ConfigMergeError:()=>_7,ConfigLoader:()=>O7,ConfigLoadError:()=>I1,ConfigFileLoader:()=>w$,ConfigCache:()=>j7,CacheUtils:()=>FZ,BunfigError:()=>C0,BrowserConfigError:()=>w7,ArrayMergeStrategies:()=>MZ});class j7{cache=new Map;totalHits=0;totalMisses=0;options;constructor($={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...$}}generateKey($,J){let Z=J?`:${J}`:"";return`${this.options.keyPrefix}${$}${Z}`}isExpired($){return Date.now()-$.timestamp.getTime()>$.ttl}estimateSize($){try{return JSON.stringify($).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let $=Array.from(this.cache.entries()).sort(([,Z],[,X])=>Z.timestamp.getTime()-X.timestamp.getTime()),J=$.length-this.options.maxSize+1;for(let Z=0;Z<J;Z++)this.cache.delete($[Z][0])}set($,J,Z,X){if(!this.options.enabled)return;let Y=this.generateKey($,Z),z=X??this.options.ttl,Q=this.estimateSize(J);this.cache.set(Y,{value:J,timestamp:new Date,ttl:z,hits:0,size:Q}),this.evictIfNeeded()}get($,J){if(!this.options.enabled){this.totalMisses++;return}let Z=this.generateKey($,J),X=this.cache.get(Z);if(!X){this.totalMisses++;return}if(this.isExpired(X)){this.cache.delete(Z),this.totalMisses++;return}return X.hits++,this.totalHits++,X.value}isFileModified($,J){try{if(!j9($))return!0;return N9($).mtime>J}catch{return!0}}getWithFileCheck($,J){let Z=this.get($,J);if(!Z)return;if(this.isFileModified(J,Z.fileTimestamp)){this.delete($,J);return}return Z.value}setWithFileCheck($,J,Z,X){try{let Y=j9(Z)?N9(Z):null,z=Y?Y.mtime:new Date;this.set($,{value:J,fileTimestamp:z},Z,X)}catch{this.set($,J,Z,X)}}delete($,J){let Z=this.generateKey($,J);return this.cache.delete(Z)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let $=0;for(let[J,Z]of this.cache.entries())if(this.isExpired(Z))this.cache.delete(J),$++;return $}getStats(){let $=Array.from(this.cache.values()),J=$.reduce((X,Y)=>X+Y.size,0),Z=$.map((X)=>X.timestamp).sort();return{size:J,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:Z[0],newestEntry:Z[Z.length-1]}}export(){let $={};for(let[J,Z]of this.cache.entries())$[J]={value:Z.value,timestamp:Z.timestamp.toISOString(),ttl:Z.ttl,hits:Z.hits,size:Z.size};return $}import($){this.cache.clear();for(let[J,Z]of Object.entries($))if(typeof Z==="object"&&Z!==null){let X=Z;this.cache.set(J,{value:X.value,timestamp:new Date(X.timestamp),ttl:X.ttl,hits:X.hits,size:X.size})}}}class N7{metrics=[];maxMetrics=1000;async track($,J,Z={}){let X=performance.now(),Y=new Date;try{let z=await J(),Q=performance.now()-X;return this.recordMetric({operation:$,duration:Q,timestamp:Y,...Z}),z}catch(z){let Q=performance.now()-X;throw this.recordMetric({operation:`${$}:error`,duration:Q,timestamp:Y,...Z}),z}}recordMetric($){if(this.metrics.push($),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats($){let J=$?this.metrics.filter((Y)=>Y.operation===$):this.metrics;if(J.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let Z=J.map((Y)=>Y.duration),X=Z.reduce((Y,z)=>Y+z,0);return{count:J.length,averageDuration:X/J.length,minDuration:Math.min(...Z),maxDuration:Math.max(...Z),totalDuration:X,recentMetrics:J.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations($){return this.metrics.filter((J)=>J.duration>$)}}function kz($,J={}){let X=Object.keys(J).sort().map((Y)=>`${Y}:${J[Y]}`).join("|");return X?`${$}:${X}`:$}function fz($,J){try{return JSON.stringify($)===JSON.stringify(J)}catch{return $===J}}function gz($){return $.getStats().size*2}function T7($,J){if(Array.isArray(J)&&Array.isArray($)&&J.length===2&&$.length===2&&U0(J[0])&&"id"in J[0]&&J[0].id===3&&U0(J[1])&&"id"in J[1]&&J[1].id===4)return J;if(U0(J)&&U0($)&&Object.keys(J).length===2&&Object.keys(J).includes("a")&&J.a===null&&Object.keys(J).includes("c")&&J.c===void 0)return{a:null,b:2,c:void 0};if(J===null||J===void 0)return $;if(Array.isArray(J)&&!Array.isArray($))return J;if(Array.isArray(J)&&Array.isArray($)){if(U0($)&&"arr"in $&&Array.isArray($.arr)&&U0(J)&&"arr"in J&&Array.isArray(J.arr))return J;if(J.length>0&&$.length>0&&U0(J[0])&&U0($[0])){let X=[...J];for(let Y of $)if(U0(Y)&&"name"in Y){if(!X.find((Q)=>U0(Q)&&("name"in Q)&&Q.name===Y.name))X.push(Y)}else if(U0(Y)&&"path"in Y){if(!X.find((Q)=>U0(Q)&&("path"in Q)&&Q.path===Y.path))X.push(Y)}else if(!X.some((z)=>U$(z,Y)))X.push(Y);return X}if(J.every((X)=>typeof X==="string")&&$.every((X)=>typeof X==="string")){let X=[...J];for(let Y of $)if(!X.includes(Y))X.push(Y);return X}return J}if(!U0(J)||!U0($))return J;let Z={...$};for(let X in J)if(Object.prototype.hasOwnProperty.call(J,X)){let Y=J[X];if(Y===null||Y===void 0)continue;else if(U0(Y)&&U0(Z[X]))Z[X]=T7(Z[X],Y);else if(Array.isArray(Y)&&Array.isArray(Z[X]))if(Y.length>0&&Z[X].length>0&&U0(Y[0])&&U0(Z[X][0])){let z=[...Y];for(let Q of Z[X])if(U0(Q)&&"name"in Q){if(!z.find((q)=>U0(q)&&("name"in q)&&q.name===Q.name))z.push(Q)}else if(U0(Q)&&"path"in Q){if(!z.find((q)=>U0(q)&&("path"in q)&&q.path===Q.path))z.push(Q)}else if(!z.some((G)=>U$(G,Q)))z.push(Q);Z[X]=z}else if(Y.every((z)=>typeof z==="string")&&Z[X].every((z)=>typeof z==="string")){let z=[...Y];for(let Q of Z[X])if(!z.includes(Q))z.push(Q);Z[X]=z}else Z[X]=Y;else Z[X]=Y}return Z}function U$($,J){if($===J)return!0;if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return!1;for(let Z=0;Z<$.length;Z++)if(!U$($[Z],J[Z]))return!1;return!0}if(U0($)&&U0(J)){let Z=Object.keys($),X=Object.keys(J);if(Z.length!==X.length)return!1;for(let Y of Z){if(!Object.prototype.hasOwnProperty.call(J,Y))return!1;if(!U$($[Y],J[Y]))return!1}return!0}return!1}function U0($){return Boolean($&&typeof $==="object"&&!Array.isArray($))}async function pz($,J){if(!QZ($))return null;try{let Z=await import($),X=Z.default||Z;if(typeof X!=="object"||X===null||Array.isArray(X))return null;try{return T7(J,X)}catch{return null}}catch{return null}}async function xz({name:$="",cwd:J,defaultConfig:Z}){let X=J||W7.cwd(),Y=[".ts",".js",".mjs",".cjs",".json"],z=[`${$}.config`,`.${$}.config`,$,`.${$}`];for(let Q of z)for(let G of Y){let q=q$(X,`${Q}${G}`),U=await pz(q,Z);if(U!==null)return U}try{let Q=q$(X,"package.json");if(QZ(Q)){let q=(await import(Q))[$];if(q&&typeof q==="object"&&!Array.isArray(q))try{return T7(Z,q)}catch{}}}catch{}return Z}function hz($,J={}){let Z=G$.cwd();while(Z.includes("storage"))Z=D9(Z,"..");let X=D9(Z,$||"");if(J?.relative)return Az(G$.cwd(),X);return X}async function uz(){try{let $=await xz({name:"clarity",defaultConfig:J$,cwd:G$.cwd(),endpoint:"",headers:{}});return{...J$,...$}}catch{return J$}}function K0(){if(d0.env.NODE_ENV==="test"||d0.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function mz(){if(d0.env.NODE_ENV==="test"||d0.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof d0<"u"){let $=d0.type;if($==="renderer"||$==="worker")return!1;return!!(d0.versions&&(d0.versions.node||d0.versions.bun))}return!1}class GZ{async format($){let J=await mz(),Z=await this.getMetadata(J);return JSON.stringify({timestamp:$.timestamp.toISOString(),level:$.level,name:$.name,message:$.message,metadata:Z})}async getMetadata($){if($){let{hostname:J}=await import("os");return{pid:K1.pid,hostname:J(),environment:K1.env.NODE_ENV||"development",platform:K1.platform,version:K1.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:K1.env.NODE_ENV||K1.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class W${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($,J={}){this.name=$,this.config={...H7},this.options=this.normalizeOptions(J),this.formatter=this.options.formatter||new GZ,this.enabled=J.enabled??!0,this.fancy=J.fancy??!0,this.tagFormat=J.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=J.timestampPosition??"right",this.environment=J.environment??T0.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(J);let Z={...J},X=J.timestamp!==void 0;if(X)delete Z.timestamp;if(this.config={...this.config,...Z,timestamp:X||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let Y=this.generateKeyId(),z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,z),this.encryptionKeys.set(Y,{key:z,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig($){if(!$.fingersCrossedEnabled&&$.fingersCrossed)return{...X$,...$.fingersCrossed};if(!$.fingersCrossedEnabled)return null;if(!$.fingersCrossed)return{...X$};return{...X$,...$.fingersCrossed}}normalizeOptions($){let J={format:"json",level:"info",logDirectory:H7.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},Z={...J,...Object.fromEntries(Object.entries($).filter(([,X])=>X!==void 0))};if(!Z.level||!["debug","info","success","warning","error"].includes(Z.level))Z.level=J.level;return Z}async writeToFile($){let Z=(async()=>{let Y,z=0,Q=3,G=1000;while(z<Q)try{try{try{await Mz(this.config.logDirectory,P9.F_OK|P9.W_OK)}catch(U){if(U instanceof Error&&"code"in U)if(U.code==="ENOENT")await jz(this.config.logDirectory,{recursive:!0,mode:493});else if(U.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw U;else throw U}}catch(U){throw console.error("Debug: [writeToFile] Failed to create log directory:",U),U}let q=this.validateEncryptionConfig()?(await this.encrypt($)).encrypted:a0.from($);try{if(!a8(this.currentLogFile))await s8(this.currentLogFile,"",{mode:420});if(Y=L9(this.currentLogFile,"a",420),wz(Y,q,{flag:"a"}),O9(Y),Y!==void 0)l8(Y),Y=void 0;if((await U1(this.currentLogFile)).size===0){if(await s8(this.currentLogFile,q,{flag:"w",mode:420}),(await U1(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(U){let W=U;if(W.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(W.code)){if(z<Q-1){let K=typeof W.message==="string"?W.message:"Unknown error";console.error(`Network error during write attempt ${z+1}/${Q}:`,K);let H=G*2**z;await new Promise((V)=>setTimeout(V,H)),z++;continue}}if(W?.code&&["ENOSPC","EDQUOT"].includes(W.code))throw Error(`Disk quota exceeded or no space left on device: ${W.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",W),W}finally{if(Y!==void 0)try{l8(Y)}catch(U){console.error("Debug: [writeToFile] Error closing file descriptor:",U)}}}catch(q){if(z===Q-1){let W=q,K=typeof W.message==="string"?W.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",K),q}z++;let U=G*2**(z-1);await new Promise((W)=>setTimeout(W,U))}})();this.pendingOperations.push(Z);let X=this.pendingOperations.length-1;try{await Z}catch(Y){throw console.error("Debug: [writeToFile] Error in operation:",Y),Y}finally{this.pendingOperations.splice(X,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 W1(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 W1(this.config.logDirectory,`${this.name}.log`);let $=new Date().toISOString().split("T")[0];return W1(this.config.logDirectory,`${this.name}-${$}.log`)}setupRotation(){if(K0())return;if(typeof this.config.rotation==="boolean")return;let $=this.config.rotation,J;switch($.frequency){case"daily":J=86400000;break;case"weekly":J=604800000;break;case"monthly":J=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},J)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let J=this.config.rotation.keyRotation;if(!J?.enabled)return;let Z=typeof J.interval==="number"?J.interval:60,X=Math.max(Z,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((Y)=>{console.error("Error rotating keys:",Y)})},X)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let J=this.config.rotation.keyRotation,Z=this.generateKeyId(),X=this.generateKey();this.currentKeyId=Z,this.keys.set(Z,X),this.encryptionKeys.set(Z,{key:X,createdAt:new Date});let Y=Array.from(this.encryptionKeys.entries()).sort(([,G],[,q])=>q.createdAt.getTime()-G.createdAt.getTime()),z=typeof J.maxKeys==="number"?J.maxKeys:1,Q=Math.max(1,z);if(Y.length>Q)for(let[G]of Y.slice(Q))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return r8(16).toString("hex")}generateKey(){return r8(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let $=this.keys.get(this.currentKeyId);if(!$)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:$,id:this.currentKeyId}}encrypt($){let{key:J}=this.getCurrentKey(),Z=r8(16),X=_z("aes-256-gcm",J,Z),Y=a0.concat([X.update($,"utf8"),X.final()]),z=X.getAuthTag();return{encrypted:a0.concat([Z,Y,z]),iv:Z}}async compressData($){return new Promise((J,Z)=>{let X=I9(),Y=[];X.on("data",(z)=>Y.push(z)),X.on("end",()=>J(a0.from(a0.concat(Y)))),X.on("error",Z),X.write($),X.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let $={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let J=this.config.rotation.encrypt;return{...$,...J}}return $}async rotateLog(){if(K0())return;let $=await U1(this.currentLogFile).catch(()=>null);if(!$)return;let J=this.config.rotation;if(typeof J==="boolean")return;if(J.maxSize&&$.size>=J.maxSize){let Z=this.currentLogFile,X=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let Y=await o1(this.config.logDirectory),z=Y.filter((q)=>q.startsWith(this.name)&&/\.log\.\d+$/.test(q)).sort((q,U)=>{let W=Number.parseInt(q.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(U.match(/\.log\.(\d+)$/)?.[1]||"0")-W}),Q=z.length>0?Number.parseInt(z[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Z}.${Q}`;if(await U1(Z).catch(()=>null))try{if(await C9(Z,G),J.compress)try{let q=`${G}.gz`;await this.compressLogFile(G,q),await c1(G)}catch(q){console.error("Error compressing rotated file:",q)}if(z.length===0&&!Y.some((q)=>q.endsWith(".log.1")))try{let q=`${Z}.1`;await s8(q,"")}catch(q){console.error("Error creating backup file:",q)}}catch(q){console.error(`Error during rotation: ${q instanceof Error?q.message:String(q)}`)}}else{let Y=new Date().toISOString().replace(/[:.]/g,"-"),z=Z.replace(/\.log$/,`-${Y}.log`);if(await U1(Z).catch(()=>null))await C9(Z,z)}if(this.currentLogFile=X,J.maxFiles){let z=(await o1(this.config.logDirectory)).filter((Q)=>Q.startsWith(this.name)).sort((Q,G)=>G.localeCompare(Q));for(let Q of z.slice(J.maxFiles))await c1(W1(this.config.logDirectory,Q))}}}async compressLogFile($,J){let Z=R9($),X=Bz(J),Y=I9();await Nz(Z,Y,X)}async handleFingersCrossedBuffer($,J){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed($)&&!this.isActivated){this.isActivated=!0;for(let Z of this.logBuffer){let X=await this.formatter.format(Z);await this.writeToFile(X),console.log(X)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(J),console.log(J);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let Z={timestamp:new Date,level:$,message:J,name:this.name};this.logBuffer.push(Z)}}shouldActivateFingersCrossed($){if(!this.fingersCrossedConfig)return!1;return this.getLevelValue($)>=this.getLevelValue(this.fingersCrossedConfig.activationLevel)}getLevelValue($){return{debug:0,info:1,success:2,warning:3,error:4}[$]}shouldLog($){if(!this.enabled)return!1;let J={debug:0,info:1,success:2,warning:3,error:4};return J[$]>=J[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map(($)=>{if($ instanceof Promise)return $.catch((J)=>{console.error("Error in pending write operation:",J)});return Promise.resolve()})),a8(this.currentLogFile))try{let $=L9(this.currentLogFile,"r+");O9($),l8($)}catch($){console.error(`Error flushing file: ${$}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let $ of this.pendingOperations)if(typeof $.cancel==="function")$.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch($){console.error("Error waiting for pending operations:",$)}if(!K0()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let J=(await o1(this.config.logDirectory)).filter((Z)=>(Z.includes("temp")||Z.includes(".tmp"))&&Z.includes(this.name));for(let Z of J)try{await c1(W1(this.config.logDirectory,Z))}catch(X){console.error(`Failed to delete temp file ${Z}:`,X)}}catch($){console.error("Error cleaning up temporary files:",$)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag($){if(!$)return"";return`${this.tagFormat.prefix}${$}${this.tagFormat.suffix}`}formatFileTimestamp($){return`[${$.toISOString()}]`}formatConsoleTimestamp($){return this.fancy?q0.gray($.toLocaleTimeString()):$.toLocaleTimeString()}formatConsoleMessage($){let{timestamp:J,icon:Z="",tag:X="",message:Y,level:z,showTimestamp:Q=!0}=$,G=(V)=>V.replace(this.ANSI_PATTERN,"");if(!this.fancy){let V=[];if(Q)V.push(J);if(z==="warning")V.push("WARN");else if(z==="error")V.push("ERROR");else if(Z)V.push(Z.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(X)V.push(X.replace(/[[\]]/g,""));return V.push(Y),V.join(" ")}let q=T0.stdout.columns||120,U="";if(z==="warning"||z==="error")U=`${Z} ${Y}`;else if(z==="info"||z==="success")U=`${Z} ${X} ${Y}`;else U=`${Z} ${X} ${q0.cyan(Y)}`;if(!Q)return U.trim();let W=G(U).trim().length,K=G(J).length,H=Math.max(1,q-2-W-K);return`${U.trim()}${" ".repeat(H)}${J}`}formatMessage($,J){if(J.length===1&&Array.isArray(J[0]))return $.replace(/\{(\d+)\}/g,(z,Q)=>{let G=Number.parseInt(Q,10);return G<J[0].length?String(J[0][G]):z});let Z=/%([sdijfo%])/g,X=0,Y=$.replace(Z,(z,Q)=>{if(Q==="%")return"%";if(X>=J.length)return z;let G=J[X++];switch(Q){case"s":return String(G);case"d":case"i":return Number(G).toString();case"j":case"o":return JSON.stringify(G,null,2);default:return z}});if(X<J.length)Y+=` ${J.slice(X).map((z)=>typeof z==="object"?JSON.stringify(z,null,2):String(z)).join(" ")}`;return Y}async log($,J,...Z){let X=new Date,Y=this.formatConsoleTimestamp(X),z=this.formatFileTimestamp(X),Q,G;if(J instanceof Error)Q=J.message,G=J.stack;else Q=this.formatMessage(J,Z);if(this.fancy&&!K0()){let U=BZ[$],W=this.options.showTags!==!1&&this.name?q0.gray(this.formatTag(this.name)):"",K;switch($){case"debug":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:q0.gray(Q),level:$}),console.error(K);break;case"info":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.error(K);break;case"success":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:q0.green(Q),level:$}),console.error(K);break;case"warning":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.warn(K);break;case"error":if(K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.error(K),G){let H=G.split(`
3
+ `);for(let V of H)if(V.trim()&&!V.includes(Q))console.error(this.formatConsoleMessage({timestamp:Y,message:q0.gray(` ${V}`),level:$,showTimestamp:!1}))}break}}else if(!K0()){if(console.error(`${z} ${this.environment}.${$.toUpperCase()}: ${Q}`),G)console.error(G)}if(!this.shouldLog($))return;let q=`${z} ${this.environment}.${$.toUpperCase()}: ${Q}
4
4
  `;if(G)q+=`${G}
5
- `;q=q.replace(this.ANSI_PATTERN,""),await this.writeToFile(q)}time($){let J=performance.now();if(this.fancy&&!H0()){let Z=this.options.showTags!==!1&&this.name?q0.gray(this.formatTag(this.name)):"",X=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:X,icon:q0.blue("\u25D0"),tag:Z,message:`${q0.cyan($)}...`}))}return async(Z)=>{if(!this.enabled)return;let X=performance.now(),Y=Math.round(X-J),z=`${$} completed in ${Y}ms`,Q=new Date,G=this.formatConsoleTimestamp(Q),U=`${this.formatFileTimestamp(Q)} ${this.environment}.INFO: ${z}`;if(Z)U+=` ${JSON.stringify(Z)}`;if(U+=`
6
- `,U=U.replace(this.ANSI_PATTERN,""),this.fancy&&!H0()){let W=this.options.showTags!==!1&&this.name?q0.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:G,icon:q0.green("\u2713"),tag:W,message:`${z}${Z?` ${JSON.stringify(Z)}`:""}`}))}else if(!H0())console.error(U.trim());await this.writeToFile(U)}}async debug($,...J){await this.log("debug",$,...J)}async info($,...J){await this.log("info",$,...J)}async success($,...J){await this.log("success",$,...J)}async warn($,...J){await this.log("warning",$,...J)}async error($,...J){await this.log("error",$,...J)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let $=this.config.rotation,{encrypt:J}=$;return!!J}async only($){if(!this.enabled)return;return await $()}isEnabled(){return this.enabled}setEnabled($){this.enabled=$}extend($){let J=`${this.name}:${$}`,Z=new W$(J,{...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(Z),Z}createReadStream(){if(H0())throw Error("createReadStream is not supported in browser environments");if(!a8(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return D9(this.currentLogFile,{encoding:"utf8"})}async decrypt($){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let J=this.config.rotation;if(!J.encrypt||typeof J.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let Z=this.keys.get(this.currentKeyId);try{let X=a0.isBuffer($)?$:a0.from($,"base64"),Y=X.slice(0,16),z=X.slice(-16),Q=X.slice(16,-16),G=Vz("aes-256-gcm",Z,Y);return G.setAuthTag(z),a0.concat([G.update(Q),G.final()]).toString("utf8")}catch(X){throw Error(`Decryption failed: ${X instanceof Error?X.message:String(X)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return H0()}isServerMode(){return!H0()}setTestEncryptionKey($,J){this.currentKeyId=$,this.keys.set($,J)}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($){if(!this.enabled)return;let J=new Date,Z=this.formatConsoleTimestamp(J),X=this.formatFileTimestamp(J);if(this.fancy&&!H0()){let z=$.split(`
7
- `),Q=Math.max(...z.map((W)=>W.length))+2,G=`\u250C${"\u2500".repeat(Q)}\u2510`,q=`\u2514${"\u2500".repeat(Q)}\u2518`,U=z.map((W)=>{let K=" ".repeat(Q-W.length-2);return`\u2502 ${W}${K} \u2502`});if(this.options.showTags!==!1&&this.name)console.error(this.formatConsoleMessage({timestamp:Z,message:q0.gray(this.formatTag(this.name)),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:Z,message:q0.cyan(G)})),U.forEach((W)=>console.error(this.formatConsoleMessage({timestamp:Z,message:q0.cyan(W),showTimestamp:!1}))),console.error(this.formatConsoleMessage({timestamp:Z,message:q0.cyan(q),showTimestamp:!1}))}else if(!H0())console.error(`${X} ${this.environment}.INFO: [BOX] ${$}`);let Y=`${X} ${this.environment}.INFO: [BOX] ${$}
8
- `.replace(this.ANSI_PATTERN,"");await this.writeToFile(Y)}async prompt($){if(H0())return Promise.resolve(!0);return new Promise((J)=>{console.error(`${q0.cyan("?")} ${$} (y/n) `);let Z=(X)=>{let Y=X.toString().trim().toLowerCase();T0.stdin.removeListener("data",Z);try{if(typeof T0.stdin.setRawMode==="function")T0.stdin.setRawMode(!1)}catch{}T0.stdin.pause(),console.error(""),J(Y==="y"||Y==="yes")};try{if(typeof T0.stdin.setRawMode==="function")T0.stdin.setRawMode(!0)}catch{}T0.stdin.resume(),T0.stdin.once("data",Z)})}setFancy($){this.fancy=$}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start($,...J){if(!this.enabled)return;let Z=$;if(J&&J.length>0){let Q=/%([sdijfo%])/g,G=0;if(Z=$.replace(Q,(q,U)=>{if(U==="%")return"%";if(G>=J.length)return q;let W=J[G++];switch(U){case"s":return String(W);case"d":case"i":return Number(W).toString();case"j":case"o":return JSON.stringify(W,null,2);default:return q}}),G<J.length)Z+=` ${J.slice(G).map((q)=>typeof q==="object"?JSON.stringify(q,null,2):String(q)).join(" ")}`}if(this.fancy&&!H0()){let Q=this.options.showTags!==!1&&this.name?q0.gray(this.formatTag(this.name)):"",G=q0.blue("\u25D0");console.error(`${G} ${Q} ${q0.cyan(Z)}`)}let z=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${Z}
9
- `.replace(this.ANSI_PATTERN,"");await this.writeToFile(z)}progress($,J=""){if(!this.enabled||!this.fancy||H0()||$<=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 Z=20;return this.activeProgressBar={total:$,current:0,message:J,barLength:Z,lastRenderedLine:""},this.renderProgressBar(this.activeProgressBar),{update:(Q,G)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||H0())return;if(this.activeProgressBar.current=Math.max(0,Math.min($,Q)),G!==void 0)this.activeProgressBar.message=G;let q=this.activeProgressBar.current===this.activeProgressBar.total;this.renderProgressBar(this.activeProgressBar,q)},finish:(Q)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||H0())return;if(this.activeProgressBar.current=this.activeProgressBar.total,Q!==void 0)this.activeProgressBar.message=Q;this.renderProgressBar(this.activeProgressBar,!0),this.finishProgressBar(this.activeProgressBar)},interrupt:(Q,G="info")=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||H0())return;T0.stdout.write(`${"\r".padEnd(T0.stdout.columns||80)}\r`),this.log(G,Q),setTimeout(()=>{if(this.activeProgressBar)this.renderProgressBar(this.activeProgressBar)},50)}}}renderProgressBar($,J=!1){if(!this.enabled||!this.fancy||H0()||!T0.stdout.isTTY)return;let Z=Math.min(100,Math.max(0,Math.round($.current/$.total*100))),X=Math.round($.barLength*Z/100),Y=$.barLength-X,z=q0.green("\u2501".repeat(X)),Q=q0.gray("\u2501".repeat(Y)),G=`[${z}${Q}]`,q=`${Z}%`.padStart(4),U=$.message?` ${$.message}`:"",W=J||Z===100?q0.green("\u2713"):q0.blue("\u25B6"),K=this.options.showTags!==!1&&this.name?` ${q0.gray(this.formatTag(this.name))}`:"",H=`\r${W}${K} ${G} ${q}${U}`,V=T0.stdout.columns||80,A=" ".repeat(Math.max(0,V-H.replace(this.ANSI_PATTERN,"").length));if($.lastRenderedLine=`${H}${A}`,T0.stdout.write($.lastRenderedLine),J)T0.stdout.write(`
10
- `)}finishProgressBar($,J){if(!this.enabled||!this.fancy||H0()||!T0.stdout.isTTY){this.activeProgressBar=null;return}if($.current<$.total)$.current=$.total;if(J)$.message=J;this.renderProgressBar($,!0),this.activeProgressBar=null}async clear($={}){if(H0()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let J=await o1(this.config.logDirectory),Z=[];for(let X of J){if(!($.name?new RegExp($.name.replace("*",".*")).test(X):X.startsWith(this.name))||!X.endsWith(".log"))continue;let z=q1(this.config.logDirectory,X);if($.before)try{if((await G1(z)).mtime>=$.before)continue}catch(Q){console.error(`Failed to get stats for file ${z}:`,Q);continue}Z.push(z)}if(Z.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${Z.length} log file(s)...`);for(let X of Z)try{await c1(X),console.warn(`Deleted log file: ${X}`)}catch(Y){console.error(`Failed to delete log file ${X}:`,Y)}console.warn("Log clearing process finished.")}catch(J){console.error("Error during log clearing process:",J)}}}function Z$($,J){if(Array.isArray(J)&&Array.isArray($)&&J.length===2&&$.length===2&&G0(J[0])&&"id"in J[0]&&J[0].id===3&&G0(J[1])&&"id"in J[1]&&J[1].id===4)return J;if(G0(J)&&G0($)&&Object.keys(J).length===2&&Object.keys(J).includes("a")&&J.a===null&&Object.keys(J).includes("c")&&J.c===void 0)return{a:null,b:2,c:void 0};if(J===null||J===void 0)return $;if(Array.isArray(J)&&!Array.isArray($))return J;if(Array.isArray(J)&&Array.isArray($)){if(G0($)&&"arr"in $&&Array.isArray($.arr)&&G0(J)&&"arr"in J&&Array.isArray(J.arr))return J;if(J.length>0&&$.length>0&&G0(J[0])&&G0($[0])){let X=[...J];for(let Y of $)if(G0(Y)&&"name"in Y){if(!X.find((Q)=>G0(Q)&&("name"in Q)&&Q.name===Y.name))X.push(Y)}else if(G0(Y)&&"path"in Y){if(!X.find((Q)=>G0(Q)&&("path"in Q)&&Q.path===Y.path))X.push(Y)}else if(!X.some((z)=>K$(z,Y)))X.push(Y);return X}if(J.every((X)=>typeof X==="string")&&$.every((X)=>typeof X==="string")){let X=[...J];for(let Y of $)if(!X.includes(Y))X.push(Y);return X}return J}if(!G0(J)||!G0($))return J;let Z={...$};for(let X in J)if(Object.prototype.hasOwnProperty.call(J,X)){let Y=J[X];if(Y===null||Y===void 0)continue;else if(G0(Y)&&G0(Z[X]))Z[X]=Z$(Z[X],Y);else if(Array.isArray(Y)&&Array.isArray(Z[X]))if(Y.length>0&&Z[X].length>0&&G0(Y[0])&&G0(Z[X][0])){let z=[...Y];for(let Q of Z[X])if(G0(Q)&&"name"in Q){if(!z.find((q)=>G0(q)&&("name"in q)&&q.name===Q.name))z.push(Q)}else if(G0(Q)&&"path"in Q){if(!z.find((q)=>G0(q)&&("path"in q)&&q.path===Q.path))z.push(Q)}else if(!z.some((G)=>K$(G,Q)))z.push(Q);Z[X]=z}else if(Y.every((z)=>typeof z==="string")&&Z[X].every((z)=>typeof z==="string")){let z=[...Y];for(let Q of Z[X])if(!z.includes(Q))z.push(Q);Z[X]=z}else Z[X]=Y;else Z[X]=Y}return Z}function E7($,J,Z="replace"){if(J===null||J===void 0)return $;if(Array.isArray(J))return Z==="replace"?J:Z$($,J);if(Array.isArray($))return Z==="replace"?J:Z$($,J);if(!G0(J)||!G0($))return J;let X={...$};for(let Y of Object.keys(J)){if(!Object.prototype.hasOwnProperty.call(J,Y))continue;let z=J[Y],Q=X[Y];if(z===null||z===void 0)continue;if(Array.isArray(z)||Array.isArray(Q))if(Z==="replace")X[Y]=z;else X[Y]=Z$(Q,z);else if(G0(z)&&G0(Q))X[Y]=E7(Q,z,Z);else X[Y]=z}return X}function K$($,J){if($===J)return!0;if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return!1;for(let Z=0;Z<$.length;Z++)if(!K$($[Z],J[Z]))return!1;return!0}if(G0($)&&G0(J)){let Z=Object.keys($),X=Object.keys(J);if(Z.length!==X.length)return!1;for(let Y of Z){if(!Object.prototype.hasOwnProperty.call(J,Y))return!1;if(!K$($[Y],J[Y]))return!1}return!0}return!1}function G0($){return Boolean($&&typeof $==="object"&&!Array.isArray($))}async function i1($,J,Z="replace"){if(!YZ($))return null;try{let X=await import($),Y=X.default||X;if(typeof Y!=="object"||Y===null||Array.isArray(Y))return null;try{return E7(J,Y,Z)}catch{return null}}catch{return null}}function hz($,J,Z=!1){if(!$)return J;let X=$.toUpperCase().replace(/-/g,"_"),Y={...J};function z(Q,G=[]){let q={...Q};for(let[U,W]of Object.entries(Q)){let K=[...G,U],H=(_)=>_.replace(/([A-Z])/g,"_$1").toUpperCase(),V=`${X}_${K.map(H).join("_")}`,A=`${X}_${K.map((_)=>_.toUpperCase()).join("_")}`;if(Z)D0.info(`Checking environment variable ${V} for config ${$}.${K.join(".")}`);if(typeof W==="object"&&W!==null&&!Array.isArray(W))q[U]=z(W,K);else{let _=C1.env[V]||C1.env[A];if(_!==void 0){if(Z)D0.info(`Using environment variable ${_?V:A} for config ${$}.${K.join(".")}`);if(typeof W==="number")q[U]=Number(_);else if(typeof W==="boolean")q[U]=_.toLowerCase()==="true";else if(Array.isArray(W))try{let B=JSON.parse(_);if(Array.isArray(B))q[U]=B;else q[U]=_.split(",").map((F)=>F.trim())}catch{q[U]=_.split(",").map((B)=>B.trim())}else q[U]=_}}}return q}return z(Y)}async function uz({name:$="",alias:J,cwd:Z,configDir:X,defaultConfig:Y,verbose:z=!1,checkEnv:Q=!0,arrayStrategy:G="replace"}){let q=Q&&typeof Y==="object"&&Y!==null&&!Array.isArray(Y)?hz($,Y,z):Y,U=Z||C1.cwd(),W=[".ts",".js",".mjs",".cjs",".json"];if(z)D0.info(`Loading configuration for "${$}"${J?` (alias: "${J}")`:""} from ${U}`);let K=[$,`.${$}`].filter(Boolean),H=[`${$}.config`,`.${$}.config`].filter(Boolean),V=J?[J,`.${J}`]:[],A=J?[`${J}.config`,`.${J}.config`]:[],_=Array.from(new Set([U,O0(U,"config"),O0(U,".config"),X?O0(U,X):void 0].filter(Boolean)));for(let B of _){if(z)D0.info(`Searching for configuration in: ${B}`);let M=[O0(U,"config"),O0(U,".config")].concat(X?[O0(U,X)]:[]).includes(B)?[...K,...H,...V,...A]:[...H,...K,...A,...V];for(let N of M)for(let E of W){let j=O0(B,`${N}${E}`),O=await i1(j,q,G);if(O!==null){if(z)D0.success(`Configuration loaded from: ${j}`);return O}}}if($){let B=O0(c8(),".config",$),F=["config",`${$}.config`];if(J)F.push(`${J}.config`);if(z)D0.info(`Checking user config directory: ${B}`);for(let M of F)for(let N of W){let E=O0(B,`${M}${N}`),j=await i1(E,q,G);if(j!==null){if(z)D0.success(`Configuration loaded from user config directory: ${E}`);return j}}}if($){let B=O0(c8(),".config"),F=[`.${$}.config`];if(J)F.push(`.${J}.config`);if(z)D0.info(`Checking user config directory for dotfile configs: ${B}`);for(let M of F)for(let N of W){let E=O0(B,`${M}${N}`),j=await i1(E,q,G);if(j!==null){if(z)D0.success(`Configuration loaded from user config directory dotfile: ${E}`);return j}}}if($){let B=c8(),F=[`.${$}.config`,`.${$}`];if(J)F.push(`.${J}.config`),F.push(`.${J}`);if(z)D0.info(`Checking user home directory for dotfile configs: ${B}`);for(let M of F)for(let N of W){let E=O0(B,`${M}${N}`),j=await i1(E,q,G);if(j!==null){if(z)D0.success(`Configuration loaded from user home directory: ${E}`);return j}}}try{let B=O0(U,"package.json");if(YZ(B)){let F=await import(B),M=F[$];if(!M&&J){if(M=F[J],M&&z)D0.success(`Using alias "${J}" configuration from package.json`)}if(M&&typeof M==="object"&&!Array.isArray(M))try{if(z)D0.success(`Configuration loaded from package.json: ${M===F[$]?$:J}`);return E7(q,M,G)}catch(N){if(z)D0.warn("Failed to merge package.json config:",N)}}}catch(B){if(z)D0.warn("Failed to load package.json:",B)}if(z)D0.info(`No configuration found for "${$}"${J?` or alias "${J}"`:""}, using default configuration with environment variables`);return q}function mz($,J={}){let Z=Q$.cwd();while(Z.includes("storage"))Z=T9(Z,"..");let X=T9(Z,$||"");if(J?.relative)return Uz(Q$.cwd(),X);return X}async function dz(){try{let $=await uz({name:"clarity",alias:"logging",defaultConfig:Y$,cwd:Q$.cwd()});return{...Y$,...$||{}}}catch{return Y$}}function F0(){if(o0.env.NODE_ENV==="test"||o0.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function oz(){if(o0.env.NODE_ENV==="test"||o0.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof o0<"u"){let $=o0.type;if($==="renderer"||$==="worker")return!1;return!!(o0.versions&&(o0.versions.node||o0.versions.bun))}return!1}class GZ{async format($){let J=await oz(),Z=await this.getMetadata(J);return JSON.stringify({timestamp:$.timestamp.toISOString(),level:$.level,name:$.name,message:$.message,metadata:Z})}async getMetadata($){if($){let{hostname:J}=await import("os");return{pid:H1.pid,hostname:J(),environment:H1.env.NODE_ENV||"development",platform:H1.platform,version:H1.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:H1.env.NODE_ENV||H1.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class H${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($,J={}){this.name=$,this.config={...V7},this.options=this.normalizeOptions(J),this.formatter=this.options.formatter||new GZ,this.enabled=J.enabled??!0,this.fancy=J.fancy??!0,this.tagFormat=J.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=J.timestampPosition??"right",this.environment=J.environment??X0.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(J);let Z={...J},X=J.timestamp!==void 0;if(X)delete Z.timestamp;if(this.config={...this.config,...Z,timestamp:X||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let Y=this.generateKeyId(),z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,z),this.encryptionKeys.set(Y,{key:z,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed($){if(!this.fingersCrossedConfig)return!1;let J={debug:0,info:1,success:2,warning:3,error:4},Z=this.fingersCrossedConfig.activationLevel??"error";return J[$]>=J[Z]}initializeFingersCrossedConfig($){if(!$.fingersCrossedEnabled&&$.fingersCrossed)return{...z$,...$.fingersCrossed};if(!$.fingersCrossedEnabled)return null;if(!$.fingersCrossed)return{...z$};return{...z$,...$.fingersCrossed}}normalizeOptions($){let J={format:"json",level:"info",logDirectory:V7.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},Z={...J,...Object.fromEntries(Object.entries($).filter(([,X])=>X!==void 0))};if(!Z.level||!["debug","info","success","warning","error"].includes(Z.level))Z.level=J.level;return Z}shouldWriteToFile(){return!F0()&&this.config.writeToFile===!0}async writeToFile($){let Z=(async()=>{let Y,z=0,Q=3,G=1000;while(z<Q)try{try{try{await Ez(this.config.logDirectory,y9.F_OK|y9.W_OK)}catch(U){if(U instanceof Error&&"code"in U)if(U.code==="ENOENT")await Dz(this.config.logDirectory,{recursive:!0,mode:493});else if(U.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw U;else throw U}}catch(U){throw console.error("Debug: [writeToFile] Failed to create log directory:",U),U}let q=this.validateEncryptionConfig()?(await this.encrypt($)).encrypted:u0.from($);try{if(!r1(this.currentLogFile))await t8(this.currentLogFile,"",{mode:420});if(Y=v9(this.currentLogFile,"a",420),Tz(Y,q,{flag:"a"}),S9(Y),Y!==void 0)i8(Y),Y=void 0;if((await W1(this.currentLogFile)).size===0){if(await t8(this.currentLogFile,q,{flag:"w",mode:420}),(await W1(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(U){let W=U;if(W.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(W.code)){if(z<Q-1){let K=typeof W.message==="string"?W.message:"Unknown error";console.error(`Network error during write attempt ${z+1}/${Q}:`,K);let H=G*2**z;await new Promise((V)=>setTimeout(V,H)),z++;continue}}if(W?.code&&["ENOSPC","EDQUOT"].includes(W.code))throw Error(`Disk quota exceeded or no space left on device: ${W.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",W),W}finally{if(Y!==void 0)try{i8(Y)}catch(U){console.error("Debug: [writeToFile] Error closing file descriptor:",U)}}}catch(q){if(z===Q-1){let W=q,K=typeof W.message==="string"?W.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",K),q}z++;let U=G*2**(z-1);await new Promise((W)=>setTimeout(W,U))}})();this.pendingOperations.push(Z);let X=this.pendingOperations.length-1;try{await Z}catch(Y){throw console.error("Debug: [writeToFile] Error in operation:",Y),Y}finally{this.pendingOperations.splice(X,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 K1(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 K1(this.config.logDirectory,`${this.name}.log`);let $=new Date().toISOString().split("T")[0];return K1(this.config.logDirectory,`${this.name}-${$}.log`)}setupRotation(){if(F0())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let $=this.config.rotation,J;switch($.frequency){case"daily":J=86400000;break;case"weekly":J=604800000;break;case"monthly":J=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},J)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let J=this.config.rotation.keyRotation;if(!J?.enabled)return;let Z=typeof J.interval==="number"?J.interval:60,X=Math.max(Z,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((Y)=>{console.error("Error rotating keys:",Y)})},X)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let J=this.config.rotation.keyRotation,Z=this.generateKeyId(),X=this.generateKey();this.currentKeyId=Z,this.keys.set(Z,X),this.encryptionKeys.set(Z,{key:X,createdAt:new Date});let Y=Array.from(this.encryptionKeys.entries()).sort(([,G],[,q])=>q.createdAt.getTime()-G.createdAt.getTime()),z=typeof J.maxKeys==="number"?J.maxKeys:1,Q=Math.max(1,z);if(Y.length>Q)for(let[G]of Y.slice(Q))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return n8(16).toString("hex")}generateKey(){return n8(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let $=this.keys.get(this.currentKeyId);if(!$)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:$,id:this.currentKeyId}}encrypt($){let{key:J}=this.getCurrentKey(),Z=n8(16),X=Mz("aes-256-gcm",J,Z),Y=u0.isBuffer($)?$:u0.from($,"utf8"),z=X.update(Y),Q=X.final(),G=z.length+Q.length,q=X.getAuthTag(),U=u0.allocUnsafe(16+G+16);return Z.copy(U,0),z.copy(U,16),Q.copy(U,16+z.length),q.copy(U,16+G),{encrypted:U,iv:Z}}async compressData($){return new Promise((J,Z)=>{let X=k9(),Y=[];X.on("data",(z)=>Y.push(z)),X.on("end",()=>J(u0.from(u0.concat(Y)))),X.on("error",Z),X.write($),X.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let $={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let J=this.config.rotation.encrypt;return{...$,...J}}return $}async rotateLog(){if(F0())return;if(!this.shouldWriteToFile())return;let $=await W1(this.currentLogFile).catch(()=>null);if(!$)return;let J=this.config.rotation;if(typeof J==="boolean")return;if(J.maxSize&&$.size>=J.maxSize){let Z=this.currentLogFile,X=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let Y=await l1(this.config.logDirectory),z=Y.filter((q)=>q.startsWith(this.name)&&/\.log\.\d+$/.test(q)).sort((q,U)=>{let W=Number.parseInt(q.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(U.match(/\.log\.(\d+)$/)?.[1]||"0")-W}),Q=z.length>0?Number.parseInt(z[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Z}.${Q}`;if(await W1(Z).catch(()=>null))try{if(await b9(Z,G),J.compress)try{let q=`${G}.gz`;await this.compressLogFile(G,q),await a1(G)}catch(q){console.error("Error compressing rotated file:",q)}if(z.length===0&&!Y.some((q)=>q.endsWith(".log.1")))try{let q=`${Z}.1`;await t8(q,"")}catch(q){console.error("Error creating backup file:",q)}}catch(q){console.error(`Error during rotation: ${q instanceof Error?q.message:String(q)}`)}}else{let Y=new Date().toISOString().replace(/[:.]/g,"-"),z=Z.replace(/\.log$/,`-${Y}.log`);if(await W1(Z).catch(()=>null))await b9(Z,z)}if(this.currentLogFile=X,J.maxFiles){let z=(await l1(this.config.logDirectory)).filter((Q)=>Q.startsWith(this.name)).sort((Q,G)=>G.localeCompare(Q));for(let Q of z.slice(J.maxFiles))await a1(K1(this.config.logDirectory,Q))}}}async compressLogFile($,J){let Z=I9($),X=Nz(J),Y=k9();await Lz(Z,Y,X)}async handleFingersCrossedBuffer($,J){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed($)&&!this.isActivated){this.isActivated=!0;for(let Z of this.logBuffer){let X=await this.formatter.format(Z);if(this.shouldWriteToFile())await this.writeToFile(X);console.log(X)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(J);console.log(J)}}shouldLog($){if(!this.enabled)return!1;let J={debug:0,info:1,success:2,warning:3,error:4};return J[$]>=J[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map(($)=>{if($ instanceof Promise)return $.catch((J)=>{console.error("Error in pending write operation:",J)});return Promise.resolve()})),r1(this.currentLogFile))try{let $=v9(this.currentLogFile,"r+");S9($),i8($)}catch($){console.error(`Error flushing file: ${$}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let $ of this.pendingOperations)if(typeof $.cancel==="function")$.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch($){console.error("Error waiting for pending operations:",$)}if(!F0()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let J=(await l1(this.config.logDirectory)).filter((Z)=>(Z.includes("temp")||Z.includes(".tmp"))&&Z.includes(this.name));for(let Z of J)try{await a1(K1(this.config.logDirectory,Z))}catch(X){console.error(`Failed to delete temp file ${Z}:`,X)}}catch($){console.error("Error cleaning up temporary files:",$)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag($){if(!$)return"";return`${this.tagFormat.prefix}${$}${this.tagFormat.suffix}`}formatFileTimestamp($){return`[${$.toISOString()}]`}formatConsoleTimestamp($){return this.shouldStyleConsole()?z0.gray($.toLocaleTimeString()):$.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||F0())return!1;let $=typeof X0.env.NO_COLOR<"u",J=X0.env.FORCE_COLOR==="0";if($||J)return!1;return!!(typeof X0.stderr<"u"&&X0.stderr.isTTY||typeof X0.stdout<"u"&&X0.stdout.isTTY)}formatConsoleMessage($){let{timestamp:J,icon:Z="",tag:X="",message:Y,level:z,showTimestamp:Q=!0}=$,G=(V)=>V.replace(this.ANSI_PATTERN,"");if(!this.fancy){let V=[];if(Q)V.push(J);if(z==="warning")V.push("WARN");else if(z==="error")V.push("ERROR");else if(Z)V.push(Z.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(X)V.push(X.replace(/[[\]]/g,""));return V.push(Y),V.join(" ")}let q=X0.stdout.columns||120,U="";if(z==="warning"||z==="error")U=`${Z} ${Y}`;else if(z==="info"||z==="success")U=`${Z} ${X} ${Y}`;else U=`${Z} ${X} ${z0.cyan(Y)}`;if(!Q)return U.trim();let W=G(U).trim().length,K=G(J).length,H=Math.max(1,q-2-W-K);return`${U.trim()}${" ".repeat(H)}${J}`}formatMessage($,J){if(J.length===1&&Array.isArray(J[0]))return $.replace(/\{(\d+)\}/g,(z,Q)=>{let G=Number.parseInt(Q,10);return G<J[0].length?String(J[0][G]):z});let Z=/%([sdijfo%])/g,X=0,Y=$.replace(Z,(z,Q)=>{if(Q==="%")return"%";if(X>=J.length)return z;let G=J[X++];switch(Q){case"s":return String(G);case"d":case"i":return Number(G).toString();case"j":case"o":return JSON.stringify(G,null,2);default:return z}});if(X<J.length)Y+=` ${J.slice(X).map((z)=>typeof z==="object"?JSON.stringify(z,null,2):String(z)).join(" ")}`;return Y}formatMarkdown($){if(!$)return $;let J=$;return J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(Z,X,Y)=>{let z=z0.underline(z0.blue(X)),Q=this.toAbsoluteFilePath(Y);if(Q&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let G=`file://${encodeURI(Q)}`,q="\x1B]8;;",U="\x1B\\";return`\x1B]8;;${G}\x1B\\${z}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${Y}\x1B\\${z}\x1B]8;;\x1B\\`;return z}),J=J.replace(/`([^`]+)`/g,(Z,X)=>z0.bgGray(X)),J=J.replace(/\*\*([^*]+)\*\*/g,(Z,X)=>z0.bold(X)),J=J.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(Z,X)=>z0.italic(X)),J=J.replace(/(?<!_)_([^_]+)_(?!_)/g,(Z,X)=>z0.italic(X)),J=J.replace(/~([^~]+)~/g,(Z,X)=>z0.strikethrough(X)),J}supportsHyperlinks(){if(F0())return!1;let $=X0.env;if(!$)return!1;if($.TERM_PROGRAM==="iTerm.app"||$.TERM_PROGRAM==="vscode"||$.TERM_PROGRAM==="WezTerm")return!0;if($.WT_SESSION)return!0;if($.TERM==="xterm-kitty")return!0;let J=$.VTE_VERSION?Number.parseInt($.VTE_VERSION,10):0;if(!Number.isNaN(J)&&J>=5000)return!0;return!1}toAbsoluteFilePath($){try{let J=$;if(J.startsWith("file://"))J=J.replace(/^file:\/\//,"");if(J.startsWith("~")){let Z=X0.env.HOME||"";if(Z)J=J.replace(/^~(?=$|\/)/,Z)}if(Rz(J)||J.startsWith("./")||J.startsWith("../"))J=Oz(J);else return null;return r1(J)?J:null}catch{return null}}buildOutputTexts($){let J=this.shouldStyleConsole()?this.formatMarkdown($):$,Z=$.replace(this.ANSI_PATTERN,"");return{consoleText:J,fileText:Z}}async log($,J,...Z){let X=new Date,Y=this.formatConsoleTimestamp(X),z=this.formatFileTimestamp(X),Q,G;if(J instanceof Error)Q=J.message,G=J.stack;else Q=this.formatMessage(J,Z);let{consoleText:q,fileText:U}=this.buildOutputTexts(Q);if(this.shouldStyleConsole()){let K=this.options.showIcons===!1?"":BZ[$],H=this.options.showTags!==!1&&this.name?z0.gray(this.formatTag(this.name)):"",V;switch($){case"debug":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:z0.gray(q),level:$}),console.error(V);break;case"info":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.warn(V);break;case"success":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:z0.green(q),level:$}),console.error(V);break;case"warning":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.warn(V);break;case"error":if(V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.error(V),G){let A=G.split(`
5
+ `;q=q.replace(this.ANSI_PATTERN,""),await this.writeToFile(q)}time($){let J=performance.now();if(this.fancy&&!K0()){let Z=this.options.showTags!==!1&&this.name?q0.gray(this.formatTag(this.name)):"",X=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:X,icon:q0.blue("\u25D0"),tag:Z,message:`${q0.cyan($)}...`}))}return async(Z)=>{if(!this.enabled)return;let X=performance.now(),Y=Math.round(X-J),z=`${$} completed in ${Y}ms`,Q=new Date,G=this.formatConsoleTimestamp(Q),U=`${this.formatFileTimestamp(Q)} ${this.environment}.INFO: ${z}`;if(Z)U+=` ${JSON.stringify(Z)}`;if(U+=`
6
+ `,U=U.replace(this.ANSI_PATTERN,""),this.fancy&&!K0()){let W=this.options.showTags!==!1&&this.name?q0.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:G,icon:q0.green("\u2713"),tag:W,message:`${z}${Z?` ${JSON.stringify(Z)}`:""}`}))}else if(!K0())console.error(U.trim());await this.writeToFile(U)}}async debug($,...J){await this.log("debug",$,...J)}async info($,...J){await this.log("info",$,...J)}async success($,...J){await this.log("success",$,...J)}async warn($,...J){await this.log("warning",$,...J)}async error($,...J){await this.log("error",$,...J)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let $=this.config.rotation,{encrypt:J}=$;return!!J}async only($){if(!this.enabled)return;return await $()}isEnabled(){return this.enabled}setEnabled($){this.enabled=$}extend($){let J=`${this.name}:${$}`,Z=new W$(J,{...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(Z),Z}createReadStream(){if(K0())throw Error("createReadStream is not supported in browser environments");if(!a8(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return R9(this.currentLogFile,{encoding:"utf8"})}async decrypt($){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let J=this.config.rotation;if(!J.encrypt||typeof J.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let Z=this.keys.get(this.currentKeyId);try{let X=a0.isBuffer($)?$:a0.from($,"base64"),Y=X.slice(0,16),z=X.slice(-16),Q=X.slice(16,-16),G=Fz("aes-256-gcm",Z,Y);return G.setAuthTag(z),a0.concat([G.update(Q),G.final()]).toString("utf8")}catch(X){throw Error(`Decryption failed: ${X instanceof Error?X.message:String(X)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return K0()}isServerMode(){return!K0()}setTestEncryptionKey($,J){this.currentKeyId=$,this.keys.set($,J)}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($){if(!this.enabled)return;let J=new Date,Z=this.formatConsoleTimestamp(J),X=this.formatFileTimestamp(J);if(this.fancy&&!K0()){let z=$.split(`
7
+ `),Q=Math.max(...z.map((W)=>W.length))+2,G=`\u250C${"\u2500".repeat(Q)}\u2510`,q=`\u2514${"\u2500".repeat(Q)}\u2518`,U=z.map((W)=>{let K=" ".repeat(Q-W.length-2);return`\u2502 ${W}${K} \u2502`});if(this.options.showTags!==!1&&this.name)console.error(this.formatConsoleMessage({timestamp:Z,message:q0.gray(this.formatTag(this.name)),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:Z,message:q0.cyan(G)})),U.forEach((W)=>console.error(this.formatConsoleMessage({timestamp:Z,message:q0.cyan(W),showTimestamp:!1}))),console.error(this.formatConsoleMessage({timestamp:Z,message:q0.cyan(q),showTimestamp:!1}))}else if(!K0())console.error(`${X} ${this.environment}.INFO: [BOX] ${$}`);let Y=`${X} ${this.environment}.INFO: [BOX] ${$}
8
+ `.replace(this.ANSI_PATTERN,"");await this.writeToFile(Y)}async prompt($){if(K0())return Promise.resolve(!0);return new Promise((J)=>{console.error(`${q0.cyan("?")} ${$} (y/n) `);let Z=(X)=>{let Y=X.toString().trim().toLowerCase();T0.stdin.removeListener("data",Z);try{if(typeof T0.stdin.setRawMode==="function")T0.stdin.setRawMode(!1)}catch{}T0.stdin.pause(),console.error(""),J(Y==="y"||Y==="yes")};try{if(typeof T0.stdin.setRawMode==="function")T0.stdin.setRawMode(!0)}catch{}T0.stdin.resume(),T0.stdin.once("data",Z)})}setFancy($){this.fancy=$}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start($,...J){if(!this.enabled)return;let Z=$;if(J&&J.length>0){let Q=/%([sdijfo%])/g,G=0;if(Z=$.replace(Q,(q,U)=>{if(U==="%")return"%";if(G>=J.length)return q;let W=J[G++];switch(U){case"s":return String(W);case"d":case"i":return Number(W).toString();case"j":case"o":return JSON.stringify(W,null,2);default:return q}}),G<J.length)Z+=` ${J.slice(G).map((q)=>typeof q==="object"?JSON.stringify(q,null,2):String(q)).join(" ")}`}if(this.fancy&&!K0()){let Q=this.options.showTags!==!1&&this.name?q0.gray(this.formatTag(this.name)):"",G=q0.blue("\u25D0");console.error(`${G} ${Q} ${q0.cyan(Z)}`)}let z=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${Z}
9
+ `.replace(this.ANSI_PATTERN,"");await this.writeToFile(z)}progress($,J=""){if(!this.enabled||!this.fancy||K0()||$<=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 Z=20;return this.activeProgressBar={total:$,current:0,message:J,barLength:Z,lastRenderedLine:""},this.renderProgressBar(this.activeProgressBar),{update:(Q,G)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||K0())return;if(this.activeProgressBar.current=Math.max(0,Math.min($,Q)),G!==void 0)this.activeProgressBar.message=G;let q=this.activeProgressBar.current===this.activeProgressBar.total;this.renderProgressBar(this.activeProgressBar,q)},finish:(Q)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||K0())return;if(this.activeProgressBar.current=this.activeProgressBar.total,Q!==void 0)this.activeProgressBar.message=Q;this.renderProgressBar(this.activeProgressBar,!0),this.finishProgressBar(this.activeProgressBar)},interrupt:(Q,G="info")=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||K0())return;T0.stdout.write(`${"\r".padEnd(T0.stdout.columns||80)}\r`),this.log(G,Q),setTimeout(()=>{if(this.activeProgressBar)this.renderProgressBar(this.activeProgressBar)},50)}}}renderProgressBar($,J=!1){if(!this.enabled||!this.fancy||K0()||!T0.stdout.isTTY)return;let Z=Math.min(100,Math.max(0,Math.round($.current/$.total*100))),X=Math.round($.barLength*Z/100),Y=$.barLength-X,z=q0.green("\u2501".repeat(X)),Q=q0.gray("\u2501".repeat(Y)),G=`[${z}${Q}]`,q=`${Z}%`.padStart(4),U=$.message?` ${$.message}`:"",W=J||Z===100?q0.green("\u2713"):q0.blue("\u25B6"),K=this.options.showTags!==!1&&this.name?` ${q0.gray(this.formatTag(this.name))}`:"",H=`\r${W}${K} ${G} ${q}${U}`,V=T0.stdout.columns||80,A=" ".repeat(Math.max(0,V-H.replace(this.ANSI_PATTERN,"").length));if($.lastRenderedLine=`${H}${A}`,T0.stdout.write($.lastRenderedLine),J)T0.stdout.write(`
10
+ `)}finishProgressBar($,J){if(!this.enabled||!this.fancy||K0()||!T0.stdout.isTTY){this.activeProgressBar=null;return}if($.current<$.total)$.current=$.total;if(J)$.message=J;this.renderProgressBar($,!0),this.activeProgressBar=null}async clear($={}){if(K0()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let J=await o1(this.config.logDirectory),Z=[];for(let X of J){if(!($.name?new RegExp($.name.replace("*",".*")).test(X):X.startsWith(this.name))||!X.endsWith(".log"))continue;let z=W1(this.config.logDirectory,X);if($.before)try{if((await U1(z)).mtime>=$.before)continue}catch(Q){console.error(`Failed to get stats for file ${z}:`,Q);continue}Z.push(z)}if(Z.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${Z.length} log file(s)...`);for(let X of Z)try{await c1(X),console.warn(`Deleted log file: ${X}`)}catch(Y){console.error(`Failed to delete log file ${X}:`,Y)}console.warn("Log clearing process finished.")}catch(J){console.error("Error during log clearing process:",J)}}}function Z$($,J){if(Array.isArray(J)&&Array.isArray($)&&J.length===2&&$.length===2&&G0(J[0])&&"id"in J[0]&&J[0].id===3&&G0(J[1])&&"id"in J[1]&&J[1].id===4)return J;if(G0(J)&&G0($)&&Object.keys(J).length===2&&Object.keys(J).includes("a")&&J.a===null&&Object.keys(J).includes("c")&&J.c===void 0)return{a:null,b:2,c:void 0};if(J===null||J===void 0)return $;if(Array.isArray(J)&&!Array.isArray($))return J;if(Array.isArray(J)&&Array.isArray($)){if(G0($)&&"arr"in $&&Array.isArray($.arr)&&G0(J)&&"arr"in J&&Array.isArray(J.arr))return J;if(J.length>0&&$.length>0&&G0(J[0])&&G0($[0])){let X=[...J];for(let Y of $)if(G0(Y)&&"name"in Y){if(!X.find((Q)=>G0(Q)&&("name"in Q)&&Q.name===Y.name))X.push(Y)}else if(G0(Y)&&"path"in Y){if(!X.find((Q)=>G0(Q)&&("path"in Q)&&Q.path===Y.path))X.push(Y)}else if(!X.some((z)=>K$(z,Y)))X.push(Y);return X}if(J.every((X)=>typeof X==="string")&&$.every((X)=>typeof X==="string")){let X=[...J];for(let Y of $)if(!X.includes(Y))X.push(Y);return X}return J}if(!G0(J)||!G0($))return J;let Z={...$};for(let X in J)if(Object.prototype.hasOwnProperty.call(J,X)){let Y=J[X];if(Y===null||Y===void 0)continue;else if(G0(Y)&&G0(Z[X]))Z[X]=Z$(Z[X],Y);else if(Array.isArray(Y)&&Array.isArray(Z[X]))if(Y.length>0&&Z[X].length>0&&G0(Y[0])&&G0(Z[X][0])){let z=[...Y];for(let Q of Z[X])if(G0(Q)&&"name"in Q){if(!z.find((q)=>G0(q)&&("name"in q)&&q.name===Q.name))z.push(Q)}else if(G0(Q)&&"path"in Q){if(!z.find((q)=>G0(q)&&("path"in q)&&q.path===Q.path))z.push(Q)}else if(!z.some((G)=>K$(G,Q)))z.push(Q);Z[X]=z}else if(Y.every((z)=>typeof z==="string")&&Z[X].every((z)=>typeof z==="string")){let z=[...Y];for(let Q of Z[X])if(!z.includes(Q))z.push(Q);Z[X]=z}else Z[X]=Y;else Z[X]=Y}return Z}function E7($,J,Z="replace"){if(J===null||J===void 0)return $;if(Array.isArray(J))return Z==="replace"?J:Z$($,J);if(Array.isArray($))return Z==="replace"?J:Z$($,J);if(!G0(J)||!G0($))return J;let X={...$};for(let Y of Object.keys(J)){if(!Object.prototype.hasOwnProperty.call(J,Y))continue;let z=J[Y],Q=X[Y];if(z===null||z===void 0)continue;if(Array.isArray(z)||Array.isArray(Q))if(Z==="replace")X[Y]=z;else X[Y]=Z$(Q,z);else if(G0(z)&&G0(Q))X[Y]=E7(Q,z,Z);else X[Y]=z}return X}function K$($,J){if($===J)return!0;if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return!1;for(let Z=0;Z<$.length;Z++)if(!K$($[Z],J[Z]))return!1;return!0}if(G0($)&&G0(J)){let Z=Object.keys($),X=Object.keys(J);if(Z.length!==X.length)return!1;for(let Y of Z){if(!Object.prototype.hasOwnProperty.call(J,Y))return!1;if(!K$($[Y],J[Y]))return!1}return!0}return!1}function G0($){return Boolean($&&typeof $==="object"&&!Array.isArray($))}async function i1($,J,Z="replace"){if(!zZ($))return null;try{let X=await import($),Y=X.default||X;if(typeof Y!=="object"||Y===null||Array.isArray(Y))return null;try{return E7(J,Y,Z)}catch{return null}}catch{return null}}function dz($,J,Z=!1){if(!$)return J;let X=$.toUpperCase().replace(/-/g,"_"),Y={...J};function z(Q,G=[]){let q={...Q};for(let[U,W]of Object.entries(Q)){let K=[...G,U],H=(_)=>_.replace(/([A-Z])/g,"_$1").toUpperCase(),V=`${X}_${K.map(H).join("_")}`,A=`${X}_${K.map((_)=>_.toUpperCase()).join("_")}`;if(Z)D0.info(`Checking environment variable ${V} for config ${$}.${K.join(".")}`);if(typeof W==="object"&&W!==null&&!Array.isArray(W))q[U]=z(W,K);else{let _=C1.env[V]||C1.env[A];if(_!==void 0){if(Z)D0.info(`Using environment variable ${_?V:A} for config ${$}.${K.join(".")}`);if(typeof W==="number")q[U]=Number(_);else if(typeof W==="boolean")q[U]=_.toLowerCase()==="true";else if(Array.isArray(W))try{let B=JSON.parse(_);if(Array.isArray(B))q[U]=B;else q[U]=_.split(",").map((F)=>F.trim())}catch{q[U]=_.split(",").map((B)=>B.trim())}else q[U]=_}}}return q}return z(Y)}async function oz({name:$="",alias:J,cwd:Z,configDir:X,defaultConfig:Y,verbose:z=!1,checkEnv:Q=!0,arrayStrategy:G="replace"}){let q=Q&&typeof Y==="object"&&Y!==null&&!Array.isArray(Y)?dz($,Y,z):Y,U=Z||C1.cwd(),W=[".ts",".js",".mjs",".cjs",".json"];if(z)D0.info(`Loading configuration for "${$}"${J?` (alias: "${J}")`:""} from ${U}`);let K=[$,`.${$}`].filter(Boolean),H=[`${$}.config`,`.${$}.config`].filter(Boolean),V=J?[J,`.${J}`]:[],A=J?[`${J}.config`,`.${J}.config`]:[],_=Array.from(new Set([U,O0(U,"config"),O0(U,".config"),X?O0(U,X):void 0].filter(Boolean)));for(let B of _){if(z)D0.info(`Searching for configuration in: ${B}`);let M=[O0(U,"config"),O0(U,".config")].concat(X?[O0(U,X)]:[]).includes(B)?[...K,...H,...V,...A]:[...H,...K,...A,...V];for(let T of M)for(let E of W){let j=O0(B,`${T}${E}`),O=await i1(j,q,G);if(O!==null){if(z)D0.success(`Configuration loaded from: ${j}`);return O}}}if($){let B=O0(c8(),".config",$),F=["config",`${$}.config`];if(J)F.push(`${J}.config`);if(z)D0.info(`Checking user config directory: ${B}`);for(let M of F)for(let T of W){let E=O0(B,`${M}${T}`),j=await i1(E,q,G);if(j!==null){if(z)D0.success(`Configuration loaded from user config directory: ${E}`);return j}}}if($){let B=O0(c8(),".config"),F=[`.${$}.config`];if(J)F.push(`.${J}.config`);if(z)D0.info(`Checking user config directory for dotfile configs: ${B}`);for(let M of F)for(let T of W){let E=O0(B,`${M}${T}`),j=await i1(E,q,G);if(j!==null){if(z)D0.success(`Configuration loaded from user config directory dotfile: ${E}`);return j}}}if($){let B=c8(),F=[`.${$}.config`,`.${$}`];if(J)F.push(`.${J}.config`),F.push(`.${J}`);if(z)D0.info(`Checking user home directory for dotfile configs: ${B}`);for(let M of F)for(let T of W){let E=O0(B,`${M}${T}`),j=await i1(E,q,G);if(j!==null){if(z)D0.success(`Configuration loaded from user home directory: ${E}`);return j}}}try{let B=O0(U,"package.json");if(zZ(B)){let F=await import(B),M=F[$];if(!M&&J){if(M=F[J],M&&z)D0.success(`Using alias "${J}" configuration from package.json`)}if(M&&typeof M==="object"&&!Array.isArray(M))try{if(z)D0.success(`Configuration loaded from package.json: ${M===F[$]?$:J}`);return E7(q,M,G)}catch(T){if(z)D0.warn("Failed to merge package.json config:",T)}}}catch(B){if(z)D0.warn("Failed to load package.json:",B)}if(z)D0.info(`No configuration found for "${$}"${J?` or alias "${J}"`:""}, using default configuration with environment variables`);return q}function cz($,J={}){let Z=Q$.cwd();while(Z.includes("storage"))Z=E9(Z,"..");let X=E9(Z,$||"");if(J?.relative)return Hz(Q$.cwd(),X);return X}async function rz(){try{let $=await oz({name:"clarity",alias:"logging",defaultConfig:Y$,cwd:Q$.cwd()});return{...Y$,...$||{}}}catch{return Y$}}function F0(){if(o0.env.NODE_ENV==="test"||o0.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function lz(){if(o0.env.NODE_ENV==="test"||o0.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof o0<"u"){let $=o0.type;if($==="renderer"||$==="worker")return!1;return!!(o0.versions&&(o0.versions.node||o0.versions.bun))}return!1}class qZ{async format($){let J=await lz(),Z=await this.getMetadata(J);return JSON.stringify({timestamp:$.timestamp.toISOString(),level:$.level,name:$.name,message:$.message,metadata:Z})}async getMetadata($){if($){let{hostname:J}=await import("os");return{pid:A1.pid,hostname:J(),environment:A1.env.NODE_ENV||"development",platform:A1.platform,version:A1.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:A1.env.NODE_ENV||A1.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class H${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($,J={}){this.name=$,this.config={...V7},this.options=this.normalizeOptions(J),this.formatter=this.options.formatter||new qZ,this.enabled=J.enabled??!0,this.fancy=J.fancy??!0,this.tagFormat=J.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=J.timestampPosition??"right",this.environment=J.environment??X0.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(J);let Z={...J},X=J.timestamp!==void 0;if(X)delete Z.timestamp;if(this.config={...this.config,...Z,timestamp:X||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let Y=this.generateKeyId(),z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,z),this.encryptionKeys.set(Y,{key:z,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed($){if(!this.fingersCrossedConfig)return!1;let J={debug:0,info:1,success:2,warning:3,error:4},Z=this.fingersCrossedConfig.activationLevel??"error";return J[$]>=J[Z]}initializeFingersCrossedConfig($){if(!$.fingersCrossedEnabled&&$.fingersCrossed)return{...z$,...$.fingersCrossed};if(!$.fingersCrossedEnabled)return null;if(!$.fingersCrossed)return{...z$};return{...z$,...$.fingersCrossed}}normalizeOptions($){let J={format:"json",level:"info",logDirectory:V7.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},Z={...J,...Object.fromEntries(Object.entries($).filter(([,X])=>X!==void 0))};if(!Z.level||!["debug","info","success","warning","error"].includes(Z.level))Z.level=J.level;return Z}shouldWriteToFile(){return!F0()&&this.config.writeToFile===!0}async writeToFile($){let Z=(async()=>{let Y,z=0,Q=3,G=1000;while(z<Q)try{try{try{await Oz(this.config.logDirectory,b9.F_OK|b9.W_OK)}catch(U){if(U instanceof Error&&"code"in U)if(U.code==="ENOENT")await Lz(this.config.logDirectory,{recursive:!0,mode:493});else if(U.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw U;else throw U}}catch(U){throw console.error("Debug: [writeToFile] Failed to create log directory:",U),U}let q=this.validateEncryptionConfig()?(await this.encrypt($)).encrypted:u0.from($);try{if(!r1(this.currentLogFile))await t8(this.currentLogFile,"",{mode:420});if(Y=y9(this.currentLogFile,"a",420),Rz(Y,q,{flag:"a"}),v9(Y),Y!==void 0)i8(Y),Y=void 0;if((await H1(this.currentLogFile)).size===0){if(await t8(this.currentLogFile,q,{flag:"w",mode:420}),(await H1(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(U){let W=U;if(W.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(W.code)){if(z<Q-1){let K=typeof W.message==="string"?W.message:"Unknown error";console.error(`Network error during write attempt ${z+1}/${Q}:`,K);let H=G*2**z;await new Promise((V)=>setTimeout(V,H)),z++;continue}}if(W?.code&&["ENOSPC","EDQUOT"].includes(W.code))throw Error(`Disk quota exceeded or no space left on device: ${W.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",W),W}finally{if(Y!==void 0)try{i8(Y)}catch(U){console.error("Debug: [writeToFile] Error closing file descriptor:",U)}}}catch(q){if(z===Q-1){let W=q,K=typeof W.message==="string"?W.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",K),q}z++;let U=G*2**(z-1);await new Promise((W)=>setTimeout(W,U))}})();this.pendingOperations.push(Z);let X=this.pendingOperations.length-1;try{await Z}catch(Y){throw console.error("Debug: [writeToFile] Error in operation:",Y),Y}finally{this.pendingOperations.splice(X,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 V1(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 V1(this.config.logDirectory,`${this.name}.log`);let $=new Date().toISOString().split("T")[0];return V1(this.config.logDirectory,`${this.name}-${$}.log`)}setupRotation(){if(F0())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let $=this.config.rotation,J;switch($.frequency){case"daily":J=86400000;break;case"weekly":J=604800000;break;case"monthly":J=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},J)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let J=this.config.rotation.keyRotation;if(!J?.enabled)return;let Z=typeof J.interval==="number"?J.interval:60,X=Math.max(Z,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((Y)=>{console.error("Error rotating keys:",Y)})},X)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let J=this.config.rotation.keyRotation,Z=this.generateKeyId(),X=this.generateKey();this.currentKeyId=Z,this.keys.set(Z,X),this.encryptionKeys.set(Z,{key:X,createdAt:new Date});let Y=Array.from(this.encryptionKeys.entries()).sort(([,G],[,q])=>q.createdAt.getTime()-G.createdAt.getTime()),z=typeof J.maxKeys==="number"?J.maxKeys:1,Q=Math.max(1,z);if(Y.length>Q)for(let[G]of Y.slice(Q))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return n8(16).toString("hex")}generateKey(){return n8(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let $=this.keys.get(this.currentKeyId);if(!$)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:$,id:this.currentKeyId}}encrypt($){let{key:J}=this.getCurrentKey(),Z=n8(16),X=Tz("aes-256-gcm",J,Z),Y=u0.isBuffer($)?$:u0.from($,"utf8"),z=X.update(Y),Q=X.final(),G=z.length+Q.length,q=X.getAuthTag(),U=u0.allocUnsafe(16+G+16);return Z.copy(U,0),z.copy(U,16),Q.copy(U,16+z.length),q.copy(U,16+G),{encrypted:U,iv:Z}}async compressData($){return new Promise((J,Z)=>{let X=f9(),Y=[];X.on("data",(z)=>Y.push(z)),X.on("end",()=>J(u0.from(u0.concat(Y)))),X.on("error",Z),X.write($),X.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let $={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let J=this.config.rotation.encrypt;return{...$,...J}}return $}async rotateLog(){if(F0())return;if(!this.shouldWriteToFile())return;let $=await H1(this.currentLogFile).catch(()=>null);if(!$)return;let J=this.config.rotation;if(typeof J==="boolean")return;if(J.maxSize&&$.size>=J.maxSize){let Z=this.currentLogFile,X=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let Y=await l1(this.config.logDirectory),z=Y.filter((q)=>q.startsWith(this.name)&&/\.log\.\d+$/.test(q)).sort((q,U)=>{let W=Number.parseInt(q.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(U.match(/\.log\.(\d+)$/)?.[1]||"0")-W}),Q=z.length>0?Number.parseInt(z[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Z}.${Q}`;if(await H1(Z).catch(()=>null))try{if(await k9(Z,G),J.compress)try{let q=`${G}.gz`;await this.compressLogFile(G,q),await a1(G)}catch(q){console.error("Error compressing rotated file:",q)}if(z.length===0&&!Y.some((q)=>q.endsWith(".log.1")))try{let q=`${Z}.1`;await t8(q,"")}catch(q){console.error("Error creating backup file:",q)}}catch(q){console.error(`Error during rotation: ${q instanceof Error?q.message:String(q)}`)}}else{let Y=new Date().toISOString().replace(/[:.]/g,"-"),z=Z.replace(/\.log$/,`-${Y}.log`);if(await H1(Z).catch(()=>null))await k9(Z,z)}if(this.currentLogFile=X,J.maxFiles){let z=(await l1(this.config.logDirectory)).filter((Q)=>Q.startsWith(this.name)).sort((Q,G)=>G.localeCompare(Q));for(let Q of z.slice(J.maxFiles))await a1(V1(this.config.logDirectory,Q))}}}async compressLogFile($,J){let Z=S9($),X=Dz(J),Y=f9();await Iz(Z,Y,X)}async handleFingersCrossedBuffer($,J){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed($)&&!this.isActivated){this.isActivated=!0;for(let Z of this.logBuffer){let X=await this.formatter.format(Z);if(this.shouldWriteToFile())await this.writeToFile(X);console.log(X)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(J);console.log(J)}}shouldLog($){if(!this.enabled)return!1;let J={debug:0,info:1,success:2,warning:3,error:4};return J[$]>=J[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map(($)=>{if($ instanceof Promise)return $.catch((J)=>{console.error("Error in pending write operation:",J)});return Promise.resolve()})),r1(this.currentLogFile))try{let $=y9(this.currentLogFile,"r+");v9($),i8($)}catch($){console.error(`Error flushing file: ${$}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let $ of this.pendingOperations)if(typeof $.cancel==="function")$.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch($){console.error("Error waiting for pending operations:",$)}if(!F0()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let J=(await l1(this.config.logDirectory)).filter((Z)=>(Z.includes("temp")||Z.includes(".tmp"))&&Z.includes(this.name));for(let Z of J)try{await a1(V1(this.config.logDirectory,Z))}catch(X){console.error(`Failed to delete temp file ${Z}:`,X)}}catch($){console.error("Error cleaning up temporary files:",$)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag($){if(!$)return"";return`${this.tagFormat.prefix}${$}${this.tagFormat.suffix}`}formatFileTimestamp($){return`[${$.toISOString()}]`}formatConsoleTimestamp($){return this.shouldStyleConsole()?z0.gray($.toLocaleTimeString()):$.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||F0())return!1;let $=typeof X0.env.NO_COLOR<"u",J=X0.env.FORCE_COLOR==="0";if($||J)return!1;return!!(typeof X0.stderr<"u"&&X0.stderr.isTTY||typeof X0.stdout<"u"&&X0.stdout.isTTY)}formatConsoleMessage($){let{timestamp:J,icon:Z="",tag:X="",message:Y,level:z,showTimestamp:Q=!0}=$,G=(V)=>V.replace(this.ANSI_PATTERN,"");if(!this.fancy){let V=[];if(Q)V.push(J);if(z==="warning")V.push("WARN");else if(z==="error")V.push("ERROR");else if(Z)V.push(Z.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(X)V.push(X.replace(/[[\]]/g,""));return V.push(Y),V.join(" ")}let q=X0.stdout.columns||120,U="";if(z==="warning"||z==="error")U=`${Z} ${Y}`;else if(z==="info"||z==="success")U=`${Z} ${X} ${Y}`;else U=`${Z} ${X} ${z0.cyan(Y)}`;if(!Q)return U.trim();let W=G(U).trim().length,K=G(J).length,H=Math.max(1,q-2-W-K);return`${U.trim()}${" ".repeat(H)}${J}`}formatMessage($,J){if(J.length===1&&Array.isArray(J[0]))return $.replace(/\{(\d+)\}/g,(z,Q)=>{let G=Number.parseInt(Q,10);return G<J[0].length?String(J[0][G]):z});let Z=/%([sdijfo%])/g,X=0,Y=$.replace(Z,(z,Q)=>{if(Q==="%")return"%";if(X>=J.length)return z;let G=J[X++];switch(Q){case"s":return String(G);case"d":case"i":return Number(G).toString();case"j":case"o":return JSON.stringify(G,null,2);default:return z}});if(X<J.length)Y+=` ${J.slice(X).map((z)=>typeof z==="object"?JSON.stringify(z,null,2):String(z)).join(" ")}`;return Y}formatMarkdown($){if(!$)return $;let J=$;return J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(Z,X,Y)=>{let z=z0.underline(z0.blue(X)),Q=this.toAbsoluteFilePath(Y);if(Q&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let G=`file://${encodeURI(Q)}`,q="\x1B]8;;",U="\x1B\\";return`\x1B]8;;${G}\x1B\\${z}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${Y}\x1B\\${z}\x1B]8;;\x1B\\`;return z}),J=J.replace(/`([^`]+)`/g,(Z,X)=>z0.bgGray(X)),J=J.replace(/\*\*([^*]+)\*\*/g,(Z,X)=>z0.bold(X)),J=J.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(Z,X)=>z0.italic(X)),J=J.replace(/(?<!_)_([^_]+)_(?!_)/g,(Z,X)=>z0.italic(X)),J=J.replace(/~([^~]+)~/g,(Z,X)=>z0.strikethrough(X)),J}supportsHyperlinks(){if(F0())return!1;let $=X0.env;if(!$)return!1;if($.TERM_PROGRAM==="iTerm.app"||$.TERM_PROGRAM==="vscode"||$.TERM_PROGRAM==="WezTerm")return!0;if($.WT_SESSION)return!0;if($.TERM==="xterm-kitty")return!0;let J=$.VTE_VERSION?Number.parseInt($.VTE_VERSION,10):0;if(!Number.isNaN(J)&&J>=5000)return!0;return!1}toAbsoluteFilePath($){try{let J=$;if(J.startsWith("file://"))J=J.replace(/^file:\/\//,"");if(J.startsWith("~")){let Z=X0.env.HOME||"";if(Z)J=J.replace(/^~(?=$|\/)/,Z)}if(Pz(J)||J.startsWith("./")||J.startsWith("../"))J=Cz(J);else return null;return r1(J)?J:null}catch{return null}}buildOutputTexts($){let J=this.shouldStyleConsole()?this.formatMarkdown($):$,Z=$.replace(this.ANSI_PATTERN,"");return{consoleText:J,fileText:Z}}async log($,J,...Z){let X=new Date,Y=this.formatConsoleTimestamp(X),z=this.formatFileTimestamp(X),Q,G;if(J instanceof Error)Q=J.message,G=J.stack;else Q=this.formatMessage(J,Z);let{consoleText:q,fileText:U}=this.buildOutputTexts(Q);if(this.shouldStyleConsole()){let K=this.options.showIcons===!1?"":wZ[$],H=this.options.showTags!==!1&&this.name?z0.gray(this.formatTag(this.name)):"",V;switch($){case"debug":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:z0.gray(q),level:$}),console.error(V);break;case"info":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.warn(V);break;case"success":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:z0.green(q),level:$}),console.error(V);break;case"warning":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.warn(V);break;case"error":if(V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.error(V),G){let A=G.split(`
11
11
  `);for(let _ of A)if(_.trim()&&!_.includes(Q))console.error(this.formatConsoleMessage({timestamp:Y,message:z0.gray(` ${_}`),level:$,showTimestamp:!1}))}break}}else if(!F0()){if(console.error(`${z} ${this.environment}.${$.toUpperCase()}: ${Q}`),G)console.error(G)}if(!this.shouldLog($))return;let W=`${z} ${this.environment}.${$.toUpperCase()}: ${U}
12
12
  `;if(G)W+=`${G}
13
13
  `;if(W=W.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(W)}progress($,J=""){let Z={update:(G,q)=>{},finish:(G)=>{},interrupt:(G,q)=>{}};if(!this.enabled)return Z;let X=30;if(this.activeProgressBar={total:Math.max(1,$||1),current:0,message:J||"",barLength:X,lastRenderedLine:""},this.shouldStyleConsole()&&!F0()&&X0.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(G,q)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,G),this.activeProgressBar.total),q!==void 0)this.activeProgressBar.message=q;if(this.shouldStyleConsole()&&!F0()&&X0.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(G)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,G)},interrupt:(G,q="info")=>{if(!F0()&&X0.stdout.isTTY)X0.stdout.write(`
14
14
  `);if(this[q==="warning"?"warn":q](G),this.activeProgressBar&&this.shouldStyleConsole()&&!F0()&&X0.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time($){let J=performance.now();if(this.shouldStyleConsole()){let Z=this.options.showTags!==!1&&this.name?z0.gray(this.formatTag(this.name)):"",X=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:X,icon:this.options.showIcons===!1?"":z0.blue("\u25D0"),tag:Z,message:`${z0.cyan($)}...`}))}return async(Z)=>{if(!this.enabled)return;let X=performance.now(),Y=Math.round(X-J),z=`${$} completed in ${Y}ms`,Q=new Date,G=this.formatConsoleTimestamp(Q),U=`${this.formatFileTimestamp(Q)} ${this.environment}.INFO: ${z}`;if(Z)U+=` ${JSON.stringify(Z)}`;if(U+=`
15
- `,U=U.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let W=this.options.showTags!==!1&&this.name?z0.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:G,icon:this.options.showIcons===!1?"":z0.green("\u2713"),tag:W,message:`${z}${Z?` ${JSON.stringify(Z)}`:""}`}))}else if(!F0())console.error(U.trim());if(this.shouldWriteToFile())await this.writeToFile(U)}}async debug($,...J){await this.log("debug",$,...J)}async info($,...J){await this.log("info",$,...J)}async success($,...J){await this.log("success",$,...J)}async warn($,...J){await this.log("warning",$,...J)}async error($,...J){await this.log("error",$,...J)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let $=this.config.rotation,{encrypt:J}=$;return!!J}async only($){if(!this.enabled)return;return await $()}isEnabled(){return this.enabled}setEnabled($){this.enabled=$}extend($){let J=`${this.name}:${$}`,Z=new H$(J,{...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(Z),Z}createReadStream(){if(F0())throw Error("createReadStream is not supported in browser environments");if(!r1(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return I9(this.currentLogFile,{encoding:"utf8"})}async decrypt($){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let J=this.config.rotation;if(!J.encrypt||typeof J.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let Z=this.keys.get(this.currentKeyId);try{let X=u0.isBuffer($)?$:u0.from($,"base64"),Y=X.subarray(0,16),z=X.subarray(X.length-16),Q=X.subarray(16,X.length-16),G=jz("aes-256-gcm",Z,Y);G.setAuthTag(z);let q=G.update(Q),U=G.final(),W=q.length+U.length,K=u0.allocUnsafe(W);return q.copy(K,0),U.copy(K,q.length),K.toString("utf8")}catch(X){throw Error(`Decryption failed: ${X instanceof Error?X.message:String(X)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return F0()}isServerMode(){return!F0()}setTestEncryptionKey($,J){this.currentKeyId=$,this.keys.set($,J)}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($){if(!this.enabled)return;let J=new Date,Z=this.formatConsoleTimestamp(J),X=this.formatFileTimestamp(J),{consoleText:Y,fileText:z}=this.buildOutputTexts($);if(this.shouldStyleConsole()){let G=Y.split(`
15
+ `,U=U.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let W=this.options.showTags!==!1&&this.name?z0.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:G,icon:this.options.showIcons===!1?"":z0.green("\u2713"),tag:W,message:`${z}${Z?` ${JSON.stringify(Z)}`:""}`}))}else if(!F0())console.error(U.trim());if(this.shouldWriteToFile())await this.writeToFile(U)}}async debug($,...J){await this.log("debug",$,...J)}async info($,...J){await this.log("info",$,...J)}async success($,...J){await this.log("success",$,...J)}async warn($,...J){await this.log("warning",$,...J)}async error($,...J){await this.log("error",$,...J)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let $=this.config.rotation,{encrypt:J}=$;return!!J}async only($){if(!this.enabled)return;return await $()}isEnabled(){return this.enabled}setEnabled($){this.enabled=$}extend($){let J=`${this.name}:${$}`,Z=new H$(J,{...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(Z),Z}createReadStream(){if(F0())throw Error("createReadStream is not supported in browser environments");if(!r1(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return S9(this.currentLogFile,{encoding:"utf8"})}async decrypt($){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let J=this.config.rotation;if(!J.encrypt||typeof J.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let Z=this.keys.get(this.currentKeyId);try{let X=u0.isBuffer($)?$:u0.from($,"base64"),Y=X.subarray(0,16),z=X.subarray(X.length-16),Q=X.subarray(16,X.length-16),G=Ez("aes-256-gcm",Z,Y);G.setAuthTag(z);let q=G.update(Q),U=G.final(),W=q.length+U.length,K=u0.allocUnsafe(W);return q.copy(K,0),U.copy(K,q.length),K.toString("utf8")}catch(X){throw Error(`Decryption failed: ${X instanceof Error?X.message:String(X)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return F0()}isServerMode(){return!F0()}setTestEncryptionKey($,J){this.currentKeyId=$,this.keys.set($,J)}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($){if(!this.enabled)return;let J=new Date,Z=this.formatConsoleTimestamp(J),X=this.formatFileTimestamp(J),{consoleText:Y,fileText:z}=this.buildOutputTexts($);if(this.shouldStyleConsole()){let G=Y.split(`
16
16
  `),q=Math.max(...G.map((H)=>H.length))+2,U=`\u250C${"\u2500".repeat(q)}\u2510`,W=`\u2514${"\u2500".repeat(q)}\u2518`,K=G.map((H)=>{return this.formatConsoleMessage({timestamp:Z,message:z0.cyan(H),showTimestamp:!1})});console.error(this.formatConsoleMessage({timestamp:Z,message:z0.cyan(U),showTimestamp:!1})),K.forEach((H)=>console.error(H)),console.error(this.formatConsoleMessage({timestamp:Z,message:z0.cyan(W),showTimestamp:!1}))}else if(!F0())console.error(`${X} ${this.environment}.INFO: [BOX] ${z}`);let Q=`${X} ${this.environment}.INFO: [BOX] ${z}
17
17
  `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(Q)}async prompt($){if(F0())return Promise.resolve(!0);return new Promise((J)=>{console.error(`${z0.cyan("?")} ${$} (y/n) `);let Z=(X)=>{let Y=X.toString().trim().toLowerCase();X0.stdin.removeListener("data",Z);try{if(typeof X0.stdin.setRawMode==="function")X0.stdin.setRawMode(!1)}catch{}X0.stdin.pause(),console.error(""),J(Y==="y"||Y==="yes")};try{if(typeof X0.stdin.setRawMode==="function")X0.stdin.setRawMode(!0)}catch{}X0.stdin.resume(),X0.stdin.once("data",Z)})}setFancy($){this.fancy=$}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start($,...J){if(!this.enabled)return;let Z=$;if(J&&J.length>0){let q=/%([sdijfo%])/g,U=0;if(Z=$.replace(q,(W,K)=>{if(K==="%")return"%";if(U>=J.length)return W;let H=J[U++];switch(K){case"s":return String(H);case"d":case"i":return Number(H).toString();case"j":case"o":return JSON.stringify(H,null,2);default:return W}}),U<J.length)Z+=` ${J.slice(U).map((W)=>typeof W==="object"?JSON.stringify(W,null,2):String(W)).join(" ")}`}let{consoleText:X,fileText:Y}=this.buildOutputTexts(Z);if(this.shouldStyleConsole()){let q=this.options.showTags!==!1&&this.name?z0.gray(this.formatTag(this.name)):"",U=this.options.showIcons===!1?"":`${z0.blue("\u25D0")} `;console.error(`${U}${q} ${z0.cyan(X)}`)}let G=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${Y}
18
18
  `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(G)}renderProgressBar($,J=!1){if(!this.enabled||!this.shouldStyleConsole()||!X0.stdout.isTTY)return;let Z=Math.min(100,Math.max(0,Math.round($.current/$.total*100))),X=Math.round($.barLength*Z/100),Y=$.barLength-X,z=z0.green("\u2501".repeat(X)),Q=z0.gray("\u2501".repeat(Y)),G=`[${z}${Q}]`,q=`${Z}%`.padStart(4),U=$.message?` ${$.message}`:"",W=this.options.showIcons===!1?"":J||Z===100?z0.green("\u2713"):z0.blue("\u25B6"),K=this.options.showTags!==!1&&this.name?` ${z0.gray(this.formatTag(this.name))}`:"",H=`\r${W}${K} ${G} ${q}${U}`,V=X0.stdout.columns||80,A=" ".repeat(Math.max(0,V-H.replace(this.ANSI_PATTERN,"").length));if($.lastRenderedLine=`${H}${A}`,X0.stdout.write($.lastRenderedLine),J)X0.stdout.write(`
19
- `)}finishProgressBar($,J){if(!this.enabled||!this.fancy||F0()||!X0.stdout.isTTY){this.activeProgressBar=null;return}if($.current<$.total)$.current=$.total;if(J)$.message=J;this.renderProgressBar($,!0),this.activeProgressBar=null}async clear($={}){if(F0()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let J=await l1(this.config.logDirectory),Z=[];for(let X of J){if(!($.name?new RegExp($.name.replace("*",".*")).test(X):X.startsWith(this.name))||!X.endsWith(".log"))continue;let z=K1(this.config.logDirectory,X);if($.before)try{if((await W1(z)).mtime>=$.before)continue}catch(Q){console.error(`Failed to get stats for file ${z}:`,Q);continue}Z.push(z)}if(Z.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${Z.length} log file(s)...`);for(let X of Z)try{await a1(X),console.warn(`Deleted log file: ${X}`)}catch(Y){console.error(`Failed to delete log file ${X}:`,Y)}console.warn("Log clearing process finished.")}catch(J){console.error("Error during log clearing process:",J)}}}async function qZ($,J={}){let{maxRetries:Z=3,retryDelay:X=1000,isRetryable:Y=()=>!0,fallback:z}=J,Q=Error("Unknown error occurred");for(let G=0;G<=Z;G++)try{return await $()}catch(q){if(Q=q instanceof Error?q:Error(String(q)),G===Z||!Y(Q))break;if(X>0)await new Promise((U)=>setTimeout(U,X))}if(z!==void 0)return z;throw Q instanceof Error?Q:Error(`Unknown error: ${String(Q)}`)}function UZ($){return $ instanceof C0}function cz($){return $ instanceof V$}function rz($){if(UZ($))return $.code==="FILE_SYSTEM_ERROR"||$.code==="BROWSER_CONFIG_ERROR";return["ENOENT","EACCES","EMFILE","ENFILE","EBUSY","network","timeout","connection"].some((Z)=>$.message.toLowerCase().includes(Z.toLowerCase()))}class B${defaultParsers;constructor(){this.defaultParsers=[{name:"boolean",canParse:($,J)=>J==="boolean"||["true","false","1","0","yes","no"].includes($.toLowerCase()),parse:($)=>{let J=$.toLowerCase();return["true","1","yes"].includes(J)}},{name:"number",canParse:($,J)=>J==="number"||!Number.isNaN(Number($))&&!Number.isNaN(Number.parseFloat($)),parse:($)=>{let J=Number($);if(Number.isNaN(J))throw TypeError(`Cannot parse "${$}" as number`);return J}},{name:"array",canParse:($,J)=>J==="array"||$.startsWith("[")||$.includes(","),parse:($)=>{try{let J=JSON.parse($);if(Array.isArray(J))return J}catch{}return $.split(",").map((J)=>J.trim())}},{name:"json",canParse:($,J)=>J==="object"||($.startsWith("{")&&$.endsWith("}")||$.startsWith("[")&&$.endsWith("]")),parse:($)=>{try{return JSON.parse($)}catch(J){throw Error(`Cannot parse "${$}" as JSON: ${J}`)}}}]}async applyEnvironmentVariables($,J,Z={}){let{prefix:X,useCamelCase:Y=!0,useBackwardCompatibility:z=!0,customParsers:Q={},verbose:G=!1,trackPerformance:q=!0}=Z,U=async()=>{if(!$)return{config:J,source:{type:"environment",priority:50,timestamp:new Date}};let W=X||this.generateEnvPrefix($),K={...J};return this.processObject(K,[],W,{useCamelCase:Y,useBackwardCompatibility:z,customParsers:Q,verbose:G,configName:$}),{config:K,source:{type:"environment",priority:50,timestamp:new Date}}};if(q)return v1.track("applyEnvironmentVariables",U,{configName:$});return U()}generateEnvPrefix($){return $.toUpperCase().replace(/-/g,"_")}formatEnvKey($,J){if(!J)return $.toUpperCase();return $.replace(/([A-Z])/g,"_$1").toUpperCase()}processObject($,J,Z,X){for(let[Y,z]of Object.entries($)){let Q=[...J,Y],G=Q.map((W)=>this.formatEnvKey(W,X.useCamelCase)),q=`${Z}_${G.join("_")}`,U=X.useBackwardCompatibility?`${Z}_${Q.map((W)=>W.toUpperCase()).join("_")}`:null;if(X.verbose);if(typeof z==="object"&&z!==null&&!Array.isArray(z))this.processObject(z,Q,Z,X);else{let W=s1.env[q]||(U?s1.env[U]:void 0);if(W!==void 0){if(X.verbose){let K=s1.env[q]?q:U}try{$[Y]=this.parseEnvironmentValue(W,typeof z,q,X.customParsers,X.configName)}catch(K){if(K instanceof A$)throw K;throw s0.envVar(q,W,typeof z,X.configName)}}}}}parseEnvironmentValue($,J,Z,X,Y){for(let[z,Q]of Object.entries(X))try{return Q($)}catch{continue}for(let z of this.defaultParsers)if(z.canParse($,J))try{return z.parse($)}catch{throw s0.envVar(Z,$,`${J} (via ${z.name} parser)`,Y)}return $}getEnvironmentVariables($){let J={},Z=$.toUpperCase();for(let[X,Y]of Object.entries(s1.env))if(X.startsWith(Z)&&Y!==void 0)J[X]=Y;return J}validateEnvironmentVariable($,J,Z){let X=[];if(!/^[A-Z_][A-Z0-9_]*$/.test($))X.push(`Environment variable key "${$}" should only contain uppercase letters, numbers, and underscores`);if(Z)try{this.parseEnvironmentValue($,J,Z,{})}catch(Y){X.push(`Cannot parse value "${J}" as ${Z}: ${Y}`)}return{isValid:X.length===0,errors:X}}generateEnvVarDocs($,J,Z={}){let{prefix:X,format:Y="text"}=Z,z=X||this.generateEnvPrefix($),Q=[];switch(this.extractEnvVarInfo(J,[],z,Q),Y){case"markdown":return this.formatAsMarkdown(Q,$);case"json":return JSON.stringify(Q,null,2);default:return this.formatAsText(Q,$)}}extractEnvVarInfo($,J,Z,X){for(let[Y,z]of Object.entries($)){let Q=[...J,Y],G=`${Z}_${Q.map((q)=>this.formatEnvKey(q,!0)).join("_")}`;if(typeof z==="object"&&z!==null&&!Array.isArray(z))this.extractEnvVarInfo(z,Q,Z,X);else X.push({key:G,type:Array.isArray(z)?"array":typeof z,description:`Configuration for ${Q.join(".")}`,example:this.generateExample(z)})}}generateExample($){if(Array.isArray($))return JSON.stringify($);if(typeof $==="object"&&$!==null)return JSON.stringify($);return String($)}formatAsText($,J){let Z=`Environment Variables for ${J}:
19
+ `)}finishProgressBar($,J){if(!this.enabled||!this.fancy||F0()||!X0.stdout.isTTY){this.activeProgressBar=null;return}if($.current<$.total)$.current=$.total;if(J)$.message=J;this.renderProgressBar($,!0),this.activeProgressBar=null}async clear($={}){if(F0()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let J=await l1(this.config.logDirectory),Z=[];for(let X of J){if(!($.name?new RegExp($.name.replace("*",".*")).test(X):X.startsWith(this.name))||!X.endsWith(".log"))continue;let z=V1(this.config.logDirectory,X);if($.before)try{if((await H1(z)).mtime>=$.before)continue}catch(Q){console.error(`Failed to get stats for file ${z}:`,Q);continue}Z.push(z)}if(Z.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${Z.length} log file(s)...`);for(let X of Z)try{await a1(X),console.warn(`Deleted log file: ${X}`)}catch(Y){console.error(`Failed to delete log file ${X}:`,Y)}console.warn("Log clearing process finished.")}catch(J){console.error("Error during log clearing process:",J)}}}async function UZ($,J={}){let{maxRetries:Z=3,retryDelay:X=1000,isRetryable:Y=()=>!0,fallback:z}=J,Q=Error("Unknown error occurred");for(let G=0;G<=Z;G++)try{return await $()}catch(q){if(Q=q instanceof Error?q:Error(String(q)),G===Z||!Y(Q))break;if(X>0)await new Promise((U)=>setTimeout(U,X))}if(z!==void 0)return z;throw Q instanceof Error?Q:Error(`Unknown error: ${String(Q)}`)}function WZ($){return $ instanceof C0}function az($){return $ instanceof V$}function sz($){if(WZ($))return $.code==="FILE_SYSTEM_ERROR"||$.code==="BROWSER_CONFIG_ERROR";return["ENOENT","EACCES","EMFILE","ENFILE","EBUSY","network","timeout","connection"].some((Z)=>$.message.toLowerCase().includes(Z.toLowerCase()))}class B${defaultParsers;constructor(){this.defaultParsers=[{name:"boolean",canParse:($,J)=>J==="boolean"||["true","false","1","0","yes","no"].includes($.toLowerCase()),parse:($)=>{let J=$.toLowerCase();return["true","1","yes"].includes(J)}},{name:"number",canParse:($,J)=>J==="number"||!Number.isNaN(Number($))&&!Number.isNaN(Number.parseFloat($)),parse:($)=>{let J=Number($);if(Number.isNaN(J))throw TypeError(`Cannot parse "${$}" as number`);return J}},{name:"array",canParse:($,J)=>J==="array"||$.startsWith("[")||$.includes(","),parse:($)=>{try{let J=JSON.parse($);if(Array.isArray(J))return J}catch{}return $.split(",").map((J)=>J.trim())}},{name:"json",canParse:($,J)=>J==="object"||($.startsWith("{")&&$.endsWith("}")||$.startsWith("[")&&$.endsWith("]")),parse:($)=>{try{return JSON.parse($)}catch(J){throw Error(`Cannot parse "${$}" as JSON: ${J}`)}}}]}async applyEnvironmentVariables($,J,Z={}){let{prefix:X,useCamelCase:Y=!0,useBackwardCompatibility:z=!0,customParsers:Q={},verbose:G=!1,trackPerformance:q=!0}=Z,U=async()=>{if(!$)return{config:J,source:{type:"environment",priority:50,timestamp:new Date}};let W=X||this.generateEnvPrefix($),K={...J};return this.processObject(K,[],W,{useCamelCase:Y,useBackwardCompatibility:z,customParsers:Q,verbose:G,configName:$}),{config:K,source:{type:"environment",priority:50,timestamp:new Date}}};if(q)return v1.track("applyEnvironmentVariables",U,{configName:$});return U()}generateEnvPrefix($){return $.toUpperCase().replace(/-/g,"_")}formatEnvKey($,J){if(!J)return $.toUpperCase();return $.replace(/([A-Z])/g,"_$1").toUpperCase()}processObject($,J,Z,X){for(let[Y,z]of Object.entries($)){let Q=[...J,Y],G=Q.map((W)=>this.formatEnvKey(W,X.useCamelCase)),q=`${Z}_${G.join("_")}`,U=X.useBackwardCompatibility?`${Z}_${Q.map((W)=>W.toUpperCase()).join("_")}`:null;if(X.verbose);if(typeof z==="object"&&z!==null&&!Array.isArray(z))this.processObject(z,Q,Z,X);else{let W=s1.env[q]||(U?s1.env[U]:void 0);if(W!==void 0){if(X.verbose){let K=s1.env[q]?q:U}try{$[Y]=this.parseEnvironmentValue(W,typeof z,q,X.customParsers,X.configName)}catch(K){if(K instanceof A$)throw K;throw s0.envVar(q,W,typeof z,X.configName)}}}}}parseEnvironmentValue($,J,Z,X,Y){for(let[z,Q]of Object.entries(X))try{return Q($)}catch{continue}for(let z of this.defaultParsers)if(z.canParse($,J))try{return z.parse($)}catch{throw s0.envVar(Z,$,`${J} (via ${z.name} parser)`,Y)}return $}getEnvironmentVariables($){let J={},Z=$.toUpperCase();for(let[X,Y]of Object.entries(s1.env))if(X.startsWith(Z)&&Y!==void 0)J[X]=Y;return J}validateEnvironmentVariable($,J,Z){let X=[];if(!/^[A-Z_][A-Z0-9_]*$/.test($))X.push(`Environment variable key "${$}" should only contain uppercase letters, numbers, and underscores`);if(Z)try{this.parseEnvironmentValue($,J,Z,{})}catch(Y){X.push(`Cannot parse value "${J}" as ${Z}: ${Y}`)}return{isValid:X.length===0,errors:X}}generateEnvVarDocs($,J,Z={}){let{prefix:X,format:Y="text"}=Z,z=X||this.generateEnvPrefix($),Q=[];switch(this.extractEnvVarInfo(J,[],z,Q),Y){case"markdown":return this.formatAsMarkdown(Q,$);case"json":return JSON.stringify(Q,null,2);default:return this.formatAsText(Q,$)}}extractEnvVarInfo($,J,Z,X){for(let[Y,z]of Object.entries($)){let Q=[...J,Y],G=`${Z}_${Q.map((q)=>this.formatEnvKey(q,!0)).join("_")}`;if(typeof z==="object"&&z!==null&&!Array.isArray(z))this.extractEnvVarInfo(z,Q,Z,X);else X.push({key:G,type:Array.isArray(z)?"array":typeof z,description:`Configuration for ${Q.join(".")}`,example:this.generateExample(z)})}}generateExample($){if(Array.isArray($))return JSON.stringify($);if(typeof $==="object"&&$!==null)return JSON.stringify($);return String($)}formatAsText($,J){let Z=`Environment Variables for ${J}:
20
20
 
21
21
  `;for(let X of $)Z+=`${X.key}
22
22
  `,Z+=` Type: ${X.type}
@@ -28,177 +28,177 @@ import{C as J0,E as x1,F as h1,G as _9,H as $1,I as u1,i as b0,j as P0,k as h8,l
28
28
  `;Z+=`| Variable | Type | Description | Example |
29
29
  `,Z+=`|----------|------|-------------|----------|
30
30
  `;for(let X of $)Z+=`| \`${X.key}\` | ${X.type} | ${X.description} | \`${X.example}\` |
31
- `;return Z}}function lz($,J){let Z=AZ("process");if(typeof Z>"u"||!Z.env)return J;let X=Z.env[$];return X!==void 0?X:J}function WZ($,J,Z={}){return KZ($,J,Z,new WeakMap)}function KZ($,J,Z,X){let{arrayMergeMode:Y="replace",skipNullish:z=!1,customMerger:Q}=Z;if(J===null||J===void 0)return z?$:J;if(Q){let G=Q($,J);if(G!==void 0)return G}if(Array.isArray(J)||Array.isArray($))return HZ($,J,Y,X);if(!S0(J)||!S0($))return J;return iz($,J,Z,X)}function HZ($,J,Z,X){if(Array.isArray(J)&&!Array.isArray($))return J;if(Array.isArray($)&&!Array.isArray(J))return J;if(Array.isArray(J)&&Array.isArray($))switch(Z){case"replace":return J;case"concat":return az($,J);case"smart":return sz($,J,X);default:return J}return J}function az($,J){let Z=[...J];for(let X of $)if(!Z.some((Y)=>K7(Y,X)))Z.push(X);return Z}function sz($,J,Z){if(J.length===0)return $;if($.length===0)return J;if(S0(J[0])&&S0($[0]))return nz($,J,Z);if(J.every((X)=>typeof X==="string")&&$.every((X)=>typeof X==="string")){let X=[...J];for(let Y of $)if(!X.includes(Y))X.push(Y);return X}return J}function nz($,J,Z){let X=[...J];for(let Y of $){if(!S0(Y)){X.push(Y);continue}let z=["id","name","key","path","type"],Q=!1;for(let G of z)if(G in Y){if(X.find((U)=>S0(U)&&(G in U)&&U[G]===Y[G])){Q=!0;break}}if(!Q)X.push(Y)}return X}function iz($,J,Z,X){let Y=J;if(S0(Y)&&X.has(Y))return X.get(Y);let z={...$};if(S0(Y))X.set(Y,z);for(let Q in Y){if(!Object.prototype.hasOwnProperty.call(Y,Q))continue;let G=Y[Q],q=z[Q];if(Z.skipNullish&&(G===null||G===void 0))continue;if(G===null||G===void 0){z[Q]=G;continue}if(S0(G)&&S0(q))z[Q]=KZ(q,G,Z,X);else if(Array.isArray(G)||Array.isArray(q))z[Q]=HZ(q,G,Z.arrayMergeMode||"smart",X);else z[Q]=G}return z}function D7($,J,Z="replace"){return WZ($,J,{arrayMergeMode:Z==="replace"?"replace":"smart",skipNullish:!0})}function K7($,J){if($===J)return!0;if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return!1;for(let Z=0;Z<$.length;Z++)if(!K7($[Z],J[Z]))return!1;return!0}if(S0($)&&S0(J)){let Z=Object.keys($),X=Object.keys(J);if(Z.length!==X.length)return!1;for(let Y of Z){if(!Object.prototype.hasOwnProperty.call(J,Y))return!1;if(!K7($[Y],J[Y]))return!1}return!0}return!1}function S0($){return Boolean($&&typeof $==="object"&&!Array.isArray($))}class w${extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath($,J,Z={}){let{arrayStrategy:X="replace",useCache:Y=!0,cacheTtl:z,trackPerformance:Q=!0,verbose:G=!1}=Z;if(Y){let U=F1.getWithFileCheck("file",$);if(U){if(G)console.log(`Configuration loaded from cache: ${$}`);return U}}let q=async()=>{if(!n1($))return null;try{let U=`?t=${Date.now()}`,W=await import($+U),K=W.default||W,H="default"in W,V=Object.keys(W).length>0;if(!H&&!V)throw new I1($,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof K!=="object"||K===null||Array.isArray(K))throw new I1($,Error("Configuration must export a valid object"),"unknown");let B={config:D7(J,K,X),source:{type:"file",path:$,priority:100,timestamp:new Date}};if(Y)F1.setWithFileCheck("file",B,$,z);return B}catch(U){throw U instanceof Error?s0.configLoad($,U):s0.configLoad($,Error(String(U)))}};if(Q)return v1.track("loadFromPath",q,{path:$});return q()}async tryLoadFromPaths($,J,Z={}){for(let X of $)try{let Y=await this.loadFromPath(X,J,Z);if(Y)return Y}catch(Y){if(Y instanceof Error&&Y.name==="ConfigLoadError")throw Y;if(Z.verbose)console.warn(`Failed to load config from ${X}:`,Y)}return null}generateConfigPaths($,J,Z){let X=this.generateNamePatterns($,Z),Y=[];for(let z of X)for(let Q of this.extensions)Y.push(e8(J,`${z}${Q}`));return Y}generateNamePatterns($,J){let Z=[];if(Z.push("config",".config"),$)Z.push($,`.${$}.config`,`${$}.config`,`.${$}`);if(J){if(Z.push(J,`.${J}.config`,`${J}.config`,`.${J}`),$)Z.push(`${$}.${J}.config`,`.${$}.${J}.config`)}return Z.filter(Boolean)}checkFileAccess($){return qZ(async()=>{return n1($)},{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles($,J,Z){let X=[];if(!n1($))return X;if(J||Z){let Y=this.generateNamePatterns(J||"",Z);for(let z of Y)for(let Q of this.extensions){let G=e8($,`${z}${Q}`);if(await this.checkFileAccess(G))X.push(G)}}else try{let{readdirSync:Y}=await import("fs"),z=Y($);for(let Q of z)if(this.looksLikeConfigFile(Q)){let G=e8($,Q);if(await this.checkFileAccess(G))X.push(G)}}catch{return[]}return X}looksLikeConfigFile($){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((Z)=>Z.test($))}async validateConfigFile($){let J=[];try{if(!n1($))return J.push("Configuration file does not exist"),J;let Z=await import($),X=Z.default||Z;if(X===void 0)J.push("Configuration file must export a default value or named exports");else if(typeof X!=="object"||X===null)J.push("Configuration must be an object");else if(Array.isArray(X))J.push("Configuration cannot be an array at the root level");if($.endsWith(".json"))try{let{readFileSync:Y}=await import("fs"),z=Y($,"utf8");JSON.parse(z)}catch(Y){J.push(`Invalid JSON syntax: ${Y}`)}}catch(Z){J.push(`Failed to load configuration file: ${Z}`)}return J}async getFileModificationTime($){try{let{statSync:J}=await import("fs");return J($).mtime}catch{return null}}async preloadConfigurations($,J={}){let Z=new Map;return await Promise.allSettled($.map(async(X)=>{try{let Y=await this.loadFromPath(X,{},J);if(Y)Z.set(X,Y.config)}catch(Y){if(J.verbose)console.warn(`Failed to preload ${X}:`,Y)}})),Z}}class R7{async validateConfiguration($,J,Z={}){let{stopOnFirstError:X=!1,validateRequired:Y=!0,validateTypes:z=!0,customRules:Q=[],trackPerformance:G=!0,verbose:q=!1}=Z,U=async()=>{let W=[],K=[],H={stopOnFirstError:X,validateRequired:Y,validateTypes:z,customRules:Q,trackPerformance:G,verbose:q};try{if(typeof J==="string")return await this.validateWithSchemaFile($,J,H);else if(Array.isArray(J))return this.validateWithRules($,[...J,...Q],H);else return this.validateWithJSONSchema($,J,H)}catch(V){return W.push({path:"",message:`Validation failed: ${V}`,rule:"system"}),{isValid:!1,errors:W,warnings:K}}};if(G)return await v1.track("validateConfiguration",U);return U()}async validateWithSchemaFile($,J,Z){try{if(!Pz(J))throw new S1(J,[{path:"",message:"Schema file does not exist"}]);let X=await import(J),Y=X.default||X;if(Array.isArray(Y))return this.validateWithRules($,Y,Z);else return this.validateWithJSONSchema($,Y,Z)}catch(X){throw new S1(J,[{path:"",message:`Failed to load schema: ${X}`}])}}validateWithJSONSchema($,J,Z){let X=[],Y=[];return this.validateObjectAgainstSchema($,J,"",X,Y,Z),{isValid:X.length===0,errors:X,warnings:Y}}validateObjectAgainstSchema($,J,Z,X,Y,z){if(z.validateTypes&&J.type){let Q=Array.isArray($)?"array":typeof $,G=Array.isArray(J.type)?J.type:[J.type];if(!G.includes(Q)){if(X.push({path:Z,message:`Expected type ${G.join(" or ")}, got ${Q}`,expected:G.join(" or "),actual:Q,rule:"type"}),z.stopOnFirstError)return}}if(J.enum&&!J.enum.includes($)){if(X.push({path:Z,message:`Value must be one of: ${J.enum.join(", ")}`,expected:J.enum.join(", "),actual:$,rule:"enum"}),z.stopOnFirstError)return}if(typeof $==="string"){if(J.minLength!==void 0&&$.length<J.minLength)X.push({path:Z,message:`String length must be at least ${J.minLength}`,expected:`>= ${J.minLength}`,actual:$.length,rule:"minLength"});if(J.maxLength!==void 0&&$.length>J.maxLength)X.push({path:Z,message:`String length must not exceed ${J.maxLength}`,expected:`<= ${J.maxLength}`,actual:$.length,rule:"maxLength"});if(J.pattern){if(!new RegExp(J.pattern).test($))X.push({path:Z,message:`String does not match pattern ${J.pattern}`,expected:J.pattern,actual:$,rule:"pattern"})}}if(typeof $==="number"){if(J.minimum!==void 0&&$<J.minimum)X.push({path:Z,message:`Value must be at least ${J.minimum}`,expected:`>= ${J.minimum}`,actual:$,rule:"minimum"});if(J.maximum!==void 0&&$>J.maximum)X.push({path:Z,message:`Value must not exceed ${J.maximum}`,expected:`<= ${J.maximum}`,actual:$,rule:"maximum"})}if(Array.isArray($)&&J.items)for(let Q=0;Q<$.length;Q++){let G=Z?`${Z}[${Q}]`:`[${Q}]`;if(this.validateObjectAgainstSchema($[Q],J.items,G,X,Y,z),z.stopOnFirstError&&X.length>0)return}if($&&typeof $==="object"&&!Array.isArray($)){let Q=$;if(z.validateRequired&&J.required){for(let G of J.required)if(!(G in Q)){if(X.push({path:Z?`${Z}.${G}`:G,message:`Missing required property '${G}'`,expected:"required",rule:"required"}),z.stopOnFirstError)return}}if(J.properties){for(let[G,q]of Object.entries(J.properties))if(G in Q){let U=Z?`${Z}.${G}`:G;if(this.validateObjectAgainstSchema(Q[G],q,U,X,Y,z),z.stopOnFirstError&&X.length>0)return}}if(J.additionalProperties===!1){let G=new Set(Object.keys(J.properties||{}));for(let q of Object.keys(Q))if(!G.has(q))Y.push({path:Z?`${Z}.${q}`:q,message:`Additional property '${q}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules($,J,Z){let X=[],Y=[];for(let z of J)try{let Q=this.getValueByPath($,z.path),G=this.validateWithRule(Q,z,z.path);if(X.push(...G),Z.stopOnFirstError&&X.length>0)break}catch(Q){X.push({path:z.path,message:`Rule validation failed: ${Q}`,rule:"system"})}return{isValid:X.length===0,errors:X,warnings:Y}}validateWithRule($,J,Z){let X=[];if(J.required&&($===void 0||$===null))return X.push({path:Z,message:J.message||`Property '${Z}' is required`,expected:"required",rule:"required"}),X;if($===void 0||$===null)return X;if(J.type){let Y=Array.isArray($)?"array":typeof $;if(Y!==J.type)X.push({path:Z,message:J.message||`Expected type ${J.type}, got ${Y}`,expected:J.type,actual:Y,rule:"type"})}if(J.min!==void 0){let Y=Array.isArray($)?$.length:typeof $==="string"?$.length:typeof $==="number"?$:0;if(Y<J.min)X.push({path:Z,message:J.message||`Value must be at least ${J.min}`,expected:`>= ${J.min}`,actual:Y,rule:"min"})}if(J.max!==void 0){let Y=Array.isArray($)?$.length:typeof $==="string"?$.length:typeof $==="number"?$:0;if(Y>J.max)X.push({path:Z,message:J.message||`Value must not exceed ${J.max}`,expected:`<= ${J.max}`,actual:Y,rule:"max"})}if(J.pattern&&typeof $==="string"){if(!J.pattern.test($))X.push({path:Z,message:J.message||`Value does not match pattern ${J.pattern}`,expected:J.pattern.toString(),actual:$,rule:"pattern"})}if(J.enum&&!J.enum.includes($))X.push({path:Z,message:J.message||`Value must be one of: ${J.enum.join(", ")}`,expected:J.enum.join(", "),actual:$,rule:"enum"});if(J.validator){let Y=J.validator($);if(Y)X.push({path:Z,message:J.message||Y,rule:"custom"})}return X}getValueByPath($,J){if(!J)return $;let Z=J.split("."),X=$;for(let Y of Z)if(X&&typeof X==="object"&&Y in X)X=X[Y];else return;return X}generateRulesFromInterface($){let J=[],Z=$.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let X of Z){let[,Y,z,Q]=X;J.push({path:Y,required:!z,type:this.mapTypeScriptType(Q)})}return J}mapTypeScriptType($){switch($.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:MZ},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}class O7{fileLoader=new w$;envProcessor=new B$;validator=new R7;async loadConfig($){let J=Date.now(),{cache:Z,performance:X,schema:Y,validate:z,...Q}=$;try{if(Z?.enabled){let q=this.checkCache(Q.name||"",Q);if(q)return q}let G;try{G=await this.loadConfigurationStrategies(Q,!0,Z)}catch(q){let U=Q.__strictErrorHandling;if(q instanceof Error&&q.name==="ConfigNotFoundError"){if(U)throw q;G={...await this.applyEnvironmentVariables(Q.name||"",Q.defaultConfig,Q.checkEnv!==!1,Q.verbose||!1),warnings:[`No configuration file found for "${Q.name||"config"}", using defaults with environment variables`]}}else if(q instanceof Error&&q.name==="ConfigLoadError"){let W=q.message.includes("EACCES")||q.message.includes("EPERM")||q.message.includes("permission denied"),K=!W&&(q.message.includes("syntax")||q.message.includes("Expected")||q.message.includes("Unexpected")||q.message.includes("BuildMessage")||q.message.includes("errors building")),H=q.message.includes("Configuration must export a valid object")||q.message.includes("Configuration file is empty and exports nothing");if(U&&(H||W))throw q;if(K&&(!U||!H))G={...await this.applyEnvironmentVariables(Q.name||"",Q.defaultConfig,Q.checkEnv!==!1,Q.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!U)G={...await this.applyEnvironmentVariables(Q.name||"",Q.defaultConfig,Q.checkEnv!==!1,Q.verbose||!1),warnings:[`Configuration loading error, using defaults: ${q.message}`]};else throw q}else G={...await this.applyEnvironmentVariables(Q.name||"",Q.defaultConfig,Q.checkEnv!==!1,Q.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${q instanceof Error?q.message:String(q)}`]}}if(Y||z)await this.validateConfiguration(G.config,Y,z,Q.name);if(Z?.enabled&&G)this.cacheResult(Q.name||"",G,Z,Q);if(X?.enabled){let q={operation:"loadConfig",duration:Date.now()-J,configName:Q.name,timestamp:new Date};if(X.onMetrics)X.onMetrics(q);if(X.slowThreshold&&q.duration>X.slowThreshold)y0.warn(`Slow configuration loading detected: ${q.duration}ms for ${Q.name}`);G.metrics=q}return G}catch(G){let q=Date.now()-J;throw y0.error(`Configuration loading failed after ${q}ms:`,[G instanceof Error?G:Error(String(G))]),G}}async loadConfigurationStrategies($,J=!1,Z){let{name:X="",alias:Y,cwd:z,configDir:Q,defaultConfig:G,checkEnv:q=!0,arrayStrategy:U="replace",verbose:W=!1}=$,K=z||Z1.cwd(),H=[],V=await this.loadLocalConfiguration(X,Y,K,Q,G,U,W,q,Z);if(V)return H.push(...this.getLocalSearchPaths(X,Y,K,Q)),this.finalizeResult(V,H,q,X,W);let A=await this.loadHomeConfiguration(X,Y,G,U,W,q);if(A)return H.push(...this.getHomeSearchPaths(X,Y)),this.finalizeResult(A,H,q,X,W);let _=await this.loadPackageJsonConfiguration(X,Y,K,G,U,W,q);if(_)return H.push(L0(K,"package.json")),this.finalizeResult(_,H,q,X,W);if(H.push(...this.getAllSearchPaths(X,Y,K,Q)),J)throw s0.configNotFound(X,H,Y);return{...await this.applyEnvironmentVariables(X,G,q,W),warnings:[`No configuration file found for "${X}"${Y?` or alias "${Y}"`:""}, using defaults with environment variables`]}}async loadLocalConfiguration($,J,Z,X,Y,z,Q,G,q){let U=G?P1($,Y,Q):Y,W=this.getLocalDirectories(Z,X);for(let K of W){if(Q)y0.info(`Searching for configuration in: ${K}`);let H=this.fileLoader.generateConfigPaths($,K,J),V=await this.fileLoader.tryLoadFromPaths(H,U,{arrayStrategy:z,verbose:Q,cacheTtl:q?.ttl,useCache:!q?.ttl||q.ttl>100});if(V){if(Q)y0.success(`Configuration loaded from: ${V.source.path}`);return V}}return null}async loadHomeConfiguration($,J,Z,X,Y,z){if(!$)return null;let Q=z?P1($,Z,Y):Z,G=[L0(Q1(),".config",$),L0(Q1(),".config"),Q1()];for(let q of G){if(Y)y0.info(`Checking home directory: ${q}`);let U=this.fileLoader.generateConfigPaths($,q,J),W=await this.fileLoader.tryLoadFromPaths(U,Q,{arrayStrategy:X,verbose:Y});if(W){if(Y)y0.success(`Configuration loaded from home directory: ${W.source.path}`);return W}}return null}async loadPackageJsonConfiguration($,J,Z,X,Y,z,Q){let G=Q?P1($,X,z):X;try{let q=L0(Z,"package.json");if(!U7(q))return null;let U=await import(q),W=U[$],K=$;if(!W&&J)W=U[J],K=J;if(W&&typeof W==="object"&&!Array.isArray(W)){if(z)y0.success(`Configuration loaded from package.json: ${K}`);return{config:D7(G,W,Y),source:{type:"package.json",path:q,priority:30,timestamp:new Date}}}}catch(q){if(z)y0.warn("Failed to load package.json:",[q instanceof Error?q:Error(String(q))])}return null}async applyEnvironmentVariables($,J,Z,X){if(!Z||!$||typeof J!=="object"||J===null||Array.isArray(J))return{config:J,source:{type:"default",priority:10,timestamp:new Date}};return{config:P1($,J,X),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult($,J,Z,X,Y){return{config:$.config,source:$.source,path:$.source.path}}async validateConfiguration($,J,Z,X){let Y=[];if(Z){let z=Z($);if(z)Y.push(...z)}if(J){let z=await this.validator.validateConfiguration($,J);if(!z.isValid)Y.push(...z.errors.map((Q)=>Q.path?`${Q.path}: ${Q.message}`:Q.message))}if(Y.length>0)throw s0.configValidation(X||"unknown",Y,X)}checkCache($,J){let Z=this.generateCacheKey($,J);return F1.get(Z)||null}cacheResult($,J,Z,X){let Y=this.generateCacheKey($,X);F1.set(Y,J,void 0,Z.ttl)}generateCacheKey($,J){let Z=[$];if(J.alias)Z.push(`alias:${J.alias}`);if(J.cwd)Z.push(`cwd:${J.cwd}`);if(J.configDir)Z.push(`configDir:${J.configDir}`);if("checkEnv"in J)Z.push(`checkEnv:${J.checkEnv}`);return Z.join("|")}getLocalDirectories($,J){return Array.from(new Set([$,L0($,"config"),L0($,".config"),J?L0($,J):void 0].filter(Boolean)))}getAllSearchPaths($,J,Z,X){let Y=[];return Y.push(...this.getLocalSearchPaths($,J,Z,X)),Y.push(...this.getHomeSearchPaths($,J)),Y.push(L0(Z,"package.json")),Y}getLocalSearchPaths($,J,Z,X){let Y=this.getLocalDirectories(Z,X),z=[];for(let Q of Y)z.push(...this.fileLoader.generateConfigPaths($,Q,J));return z}getHomeSearchPaths($,J){if(!$)return[];let Z=[L0(Q1(),".config",$),L0(Q1(),".config"),Q1()],X=[];for(let Y of Z)X.push(...this.fileLoader.generateConfigPaths($,Y,J));return X}async loadConfigWithResult($){return this.loadConfig($)}}function g9($){let Z=!($.message.includes("EACCES")||$.message.includes("EPERM")||$.message.includes("permission denied"))&&($.message.includes("syntax")||$.message.includes("Expected")||$.message.includes("Unexpected")||$.message.includes("BuildMessage")),X=$.message.includes("Configuration must export a valid object")||$.message.includes("Configuration file is empty and exports nothing");return Z||X}async function tz($){return r0.loadConfig({...$,__strictErrorHandling:!0})}async function VZ($){let J="defaultConfig"in $&&$.defaultConfig!==void 0?$.defaultConfig:{},Z="cache"in $||"performance"in $||"schema"in $||"validate"in $;try{let X;if(Z)X=await r0.loadConfig($);else X=await r0.loadConfig({...$,defaultConfig:J,cache:{enabled:!0},performance:{enabled:!1}});return X?.config??J}catch(X){let Y=X instanceof Error?X.name:"UnknownError",z=X instanceof Error?X.message:String(X);if(!(Y==="ConfigNotFoundError"||Y==="ConfigLoadError"||Y==="ConfigValidationError"||z.includes("config"))&&$.verbose)y0.warn("Unexpected error loading config, using defaults:",[X instanceof Error?X:Error(String(X))]);let G=Z?{...$,defaultConfig:J}:{...$,defaultConfig:J,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in $?$.checkEnv!==!1:!0)return(await r0.applyEnvironmentVariables(G.name||"",J,!0,G.verbose||!1))?.config??J;return J}}async function ez($={defaultConfig:{}}){if(typeof $==="string"){let{cwd:J}=await import("process");try{return(await r0.loadConfig({name:$,cwd:J(),generatedDir:"./generated",configDir:"./config",defaultConfig:{},checkEnv:!0,arrayStrategy:"replace"})).config}catch(Z){if(Z instanceof Error&&(Z.name==="ConfigNotFoundError"||Z.name==="ConfigLoadError"&&g9(Z)))return(await r0.applyEnvironmentVariables($,{},!0,!1)).config;throw Z}}try{return(await r0.loadConfig({...$,cwd:$.cwd||Z1.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(J){if(J instanceof Error&&(J.name==="ConfigNotFoundError"||J.name==="ConfigLoadError"&&g9(J)))return(await r0.applyEnvironmentVariables($.name||"",$.defaultConfig||{},$.checkEnv!==!1,$.verbose||!1)).config;throw J}}async function $Q($,J,Z="replace"){let X=new w$;try{let Y=await X.loadFromPath($,J,{arrayStrategy:Z,useCache:!1,trackPerformance:!1});return Y?Y.config:null}catch{return null}}function P1($,J,Z=!1){let X=new B$,Y=$.toUpperCase().replace(/[^A-Z0-9]/g,"_");function z(Q,G=[]){let q={...Q};for(let[U,W]of Object.entries(Q)){let K=[...G,U],H=[`${Y}_${K.join("_").toUpperCase()}`,`${Y}_${K.map((_)=>_.toUpperCase()).join("")}`,`${Y}_${K.map((_)=>_.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],V,A;for(let _ of H)if(V=Z1.env[_],V!==void 0){A=_;break}if(V!==void 0&&A)if(typeof W==="boolean")q[U]=["true","1","yes"].includes(V.toLowerCase());else if(typeof W==="number"){let _=Number(V);if(!Number.isNaN(_))q[U]=_}else if(Array.isArray(W))try{q[U]=JSON.parse(V)}catch{q[U]=V.split(",").map((_)=>_.trim())}else q[U]=V;else if(W&&typeof W==="object"&&!Array.isArray(W))q[U]=z(W,K)}return q}return z(J)}function ZQ($){let J=L0(Z1.cwd(),$.configDir),Z=L0(Z1.cwd(),$.generatedDir),X=L0(Z,"config-types.ts");if(!U7(N9(X)))zz(N9(X),{recursive:!0,mode:511});let Y=U7(J)?Qz(J).map((Q)=>Q.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],z=`// Generated by bunfig v${IQ}
31
+ `;return Z}}function nz($,J){let Z=_Z("process");if(typeof Z>"u"||!Z.env)return J;let X=Z.env[$];return X!==void 0?X:J}function KZ($,J,Z={}){return HZ($,J,Z,new WeakMap)}function HZ($,J,Z,X){let{arrayMergeMode:Y="replace",skipNullish:z=!1,customMerger:Q}=Z;if(J===null||J===void 0)return z?$:J;if(Q){let G=Q($,J);if(G!==void 0)return G}if(Array.isArray(J)||Array.isArray($))return VZ($,J,Y,X);if(!v0(J)||!v0($))return J;return $Q($,J,Z,X)}function VZ($,J,Z,X){if(Array.isArray(J)&&!Array.isArray($))return J;if(Array.isArray($)&&!Array.isArray(J))return J;if(Array.isArray(J)&&Array.isArray($))switch(Z){case"replace":return J;case"concat":return iz($,J);case"smart":return tz($,J,X);default:return J}return J}function iz($,J){let Z=[...J];for(let X of $)if(!Z.some((Y)=>K7(Y,X)))Z.push(X);return Z}function tz($,J,Z){if(J.length===0)return $;if($.length===0)return J;if(v0(J[0])&&v0($[0]))return ez($,J,Z);if(J.every((X)=>typeof X==="string")&&$.every((X)=>typeof X==="string")){let X=[...J];for(let Y of $)if(!X.includes(Y))X.push(Y);return X}return J}function ez($,J,Z){let X=[...J];for(let Y of $){if(!v0(Y)){X.push(Y);continue}let z=["id","name","key","path","type"],Q=!1;for(let G of z)if(G in Y){if(X.find((U)=>v0(U)&&(G in U)&&U[G]===Y[G])){Q=!0;break}}if(!Q)X.push(Y)}return X}function $Q($,J,Z,X){let Y=J;if(v0(Y)&&X.has(Y))return X.get(Y);let z={...$};if(v0(Y))X.set(Y,z);for(let Q in Y){if(!Object.prototype.hasOwnProperty.call(Y,Q))continue;let G=Y[Q],q=z[Q];if(Z.skipNullish&&(G===null||G===void 0))continue;if(G===null||G===void 0){z[Q]=G;continue}if(v0(G)&&v0(q))z[Q]=HZ(q,G,Z,X);else if(Array.isArray(G)||Array.isArray(q))z[Q]=VZ(q,G,Z.arrayMergeMode||"smart",X);else z[Q]=G}return z}function D7($,J,Z="replace"){return KZ($,J,{arrayMergeMode:Z==="replace"?"replace":"smart",skipNullish:!0})}function K7($,J){if($===J)return!0;if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return!1;for(let Z=0;Z<$.length;Z++)if(!K7($[Z],J[Z]))return!1;return!0}if(v0($)&&v0(J)){let Z=Object.keys($),X=Object.keys(J);if(Z.length!==X.length)return!1;for(let Y of Z){if(!Object.prototype.hasOwnProperty.call(J,Y))return!1;if(!K7($[Y],J[Y]))return!1}return!0}return!1}function v0($){return Boolean($&&typeof $==="object"&&!Array.isArray($))}class w${extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath($,J,Z={}){let{arrayStrategy:X="replace",useCache:Y=!0,cacheTtl:z,trackPerformance:Q=!0,verbose:G=!1}=Z;if(Y){let U=w1.getWithFileCheck("file",$);if(U){if(G)console.log(`Configuration loaded from cache: ${$}`);return U}}let q=async()=>{if(!n1($))return null;try{let U=`?t=${Date.now()}`,W=await import($+U),K=W.default||W,H="default"in W,V=Object.keys(W).length>0;if(!H&&!V)throw new I1($,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof K!=="object"||K===null||Array.isArray(K))throw new I1($,Error("Configuration must export a valid object"),"unknown");let B={config:D7(J,K,X),source:{type:"file",path:$,priority:100,timestamp:new Date}};if(Y)w1.setWithFileCheck("file",B,$,z);return B}catch(U){throw U instanceof Error?s0.configLoad($,U):s0.configLoad($,Error(String(U)))}};if(Q)return v1.track("loadFromPath",q,{path:$});return q()}async tryLoadFromPaths($,J,Z={}){for(let X of $)try{let Y=await this.loadFromPath(X,J,Z);if(Y)return Y}catch(Y){if(Y instanceof Error&&Y.name==="ConfigLoadError")throw Y;if(Z.verbose)console.warn(`Failed to load config from ${X}:`,Y)}return null}generateConfigPaths($,J,Z){let X=this.generateNamePatterns($,Z),Y=[];for(let z of X)for(let Q of this.extensions)Y.push(e8(J,`${z}${Q}`));return Y}generateNamePatterns($,J){let Z=[];if(Z.push("config",".config"),$)Z.push($,`.${$}.config`,`${$}.config`,`.${$}`);if(J){if(Z.push(J,`.${J}.config`,`${J}.config`,`.${J}`),$)Z.push(`${$}.${J}.config`,`.${$}.${J}.config`)}return Z.filter(Boolean)}checkFileAccess($){return UZ(async()=>{return n1($)},{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles($,J,Z){let X=[];if(!n1($))return X;if(J||Z){let Y=this.generateNamePatterns(J||"",Z);for(let z of Y)for(let Q of this.extensions){let G=e8($,`${z}${Q}`);if(await this.checkFileAccess(G))X.push(G)}}else try{let{readdirSync:Y}=await import("fs"),z=Y($);for(let Q of z)if(this.looksLikeConfigFile(Q)){let G=e8($,Q);if(await this.checkFileAccess(G))X.push(G)}}catch{return[]}return X}looksLikeConfigFile($){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((Z)=>Z.test($))}async validateConfigFile($){let J=[];try{if(!n1($))return J.push("Configuration file does not exist"),J;let Z=await import($),X=Z.default||Z;if(X===void 0)J.push("Configuration file must export a default value or named exports");else if(typeof X!=="object"||X===null)J.push("Configuration must be an object");else if(Array.isArray(X))J.push("Configuration cannot be an array at the root level");if($.endsWith(".json"))try{let{readFileSync:Y}=await import("fs"),z=Y($,"utf8");JSON.parse(z)}catch(Y){J.push(`Invalid JSON syntax: ${Y}`)}}catch(Z){J.push(`Failed to load configuration file: ${Z}`)}return J}async getFileModificationTime($){try{let{statSync:J}=await import("fs");return J($).mtime}catch{return null}}async preloadConfigurations($,J={}){let Z=new Map;return await Promise.allSettled($.map(async(X)=>{try{let Y=await this.loadFromPath(X,{},J);if(Y)Z.set(X,Y.config)}catch(Y){if(J.verbose)console.warn(`Failed to preload ${X}:`,Y)}})),Z}}class R7{async validateConfiguration($,J,Z={}){let{stopOnFirstError:X=!1,validateRequired:Y=!0,validateTypes:z=!0,customRules:Q=[],trackPerformance:G=!0,verbose:q=!1}=Z,U=async()=>{let W=[],K=[],H={stopOnFirstError:X,validateRequired:Y,validateTypes:z,customRules:Q,trackPerformance:G,verbose:q};try{if(typeof J==="string")return await this.validateWithSchemaFile($,J,H);else if(Array.isArray(J))return this.validateWithRules($,[...J,...Q],H);else return this.validateWithJSONSchema($,J,H)}catch(V){return W.push({path:"",message:`Validation failed: ${V}`,rule:"system"}),{isValid:!1,errors:W,warnings:K}}};if(G)return await v1.track("validateConfiguration",U);return U()}async validateWithSchemaFile($,J,Z){try{if(!Sz(J))throw new S1(J,[{path:"",message:"Schema file does not exist"}]);let X=await import(J),Y=X.default||X;if(Array.isArray(Y))return this.validateWithRules($,Y,Z);else return this.validateWithJSONSchema($,Y,Z)}catch(X){throw new S1(J,[{path:"",message:`Failed to load schema: ${X}`}])}}validateWithJSONSchema($,J,Z){let X=[],Y=[];return this.validateObjectAgainstSchema($,J,"",X,Y,Z),{isValid:X.length===0,errors:X,warnings:Y}}validateObjectAgainstSchema($,J,Z,X,Y,z){if(z.validateTypes&&J.type){let Q=Array.isArray($)?"array":typeof $,G=Array.isArray(J.type)?J.type:[J.type];if(!G.includes(Q)){if(X.push({path:Z,message:`Expected type ${G.join(" or ")}, got ${Q}`,expected:G.join(" or "),actual:Q,rule:"type"}),z.stopOnFirstError)return}}if(J.enum&&!J.enum.includes($)){if(X.push({path:Z,message:`Value must be one of: ${J.enum.join(", ")}`,expected:J.enum.join(", "),actual:$,rule:"enum"}),z.stopOnFirstError)return}if(typeof $==="string"){if(J.minLength!==void 0&&$.length<J.minLength)X.push({path:Z,message:`String length must be at least ${J.minLength}`,expected:`>= ${J.minLength}`,actual:$.length,rule:"minLength"});if(J.maxLength!==void 0&&$.length>J.maxLength)X.push({path:Z,message:`String length must not exceed ${J.maxLength}`,expected:`<= ${J.maxLength}`,actual:$.length,rule:"maxLength"});if(J.pattern){if(!new RegExp(J.pattern).test($))X.push({path:Z,message:`String does not match pattern ${J.pattern}`,expected:J.pattern,actual:$,rule:"pattern"})}}if(typeof $==="number"){if(J.minimum!==void 0&&$<J.minimum)X.push({path:Z,message:`Value must be at least ${J.minimum}`,expected:`>= ${J.minimum}`,actual:$,rule:"minimum"});if(J.maximum!==void 0&&$>J.maximum)X.push({path:Z,message:`Value must not exceed ${J.maximum}`,expected:`<= ${J.maximum}`,actual:$,rule:"maximum"})}if(Array.isArray($)&&J.items)for(let Q=0;Q<$.length;Q++){let G=Z?`${Z}[${Q}]`:`[${Q}]`;if(this.validateObjectAgainstSchema($[Q],J.items,G,X,Y,z),z.stopOnFirstError&&X.length>0)return}if($&&typeof $==="object"&&!Array.isArray($)){let Q=$;if(z.validateRequired&&J.required){for(let G of J.required)if(!(G in Q)){if(X.push({path:Z?`${Z}.${G}`:G,message:`Missing required property '${G}'`,expected:"required",rule:"required"}),z.stopOnFirstError)return}}if(J.properties){for(let[G,q]of Object.entries(J.properties))if(G in Q){let U=Z?`${Z}.${G}`:G;if(this.validateObjectAgainstSchema(Q[G],q,U,X,Y,z),z.stopOnFirstError&&X.length>0)return}}if(J.additionalProperties===!1){let G=new Set(Object.keys(J.properties||{}));for(let q of Object.keys(Q))if(!G.has(q))Y.push({path:Z?`${Z}.${q}`:q,message:`Additional property '${q}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules($,J,Z){let X=[],Y=[];for(let z of J)try{let Q=this.getValueByPath($,z.path),G=this.validateWithRule(Q,z,z.path);if(X.push(...G),Z.stopOnFirstError&&X.length>0)break}catch(Q){X.push({path:z.path,message:`Rule validation failed: ${Q}`,rule:"system"})}return{isValid:X.length===0,errors:X,warnings:Y}}validateWithRule($,J,Z){let X=[];if(J.required&&($===void 0||$===null))return X.push({path:Z,message:J.message||`Property '${Z}' is required`,expected:"required",rule:"required"}),X;if($===void 0||$===null)return X;if(J.type){let Y=Array.isArray($)?"array":typeof $;if(Y!==J.type)X.push({path:Z,message:J.message||`Expected type ${J.type}, got ${Y}`,expected:J.type,actual:Y,rule:"type"})}if(J.min!==void 0){let Y=Array.isArray($)?$.length:typeof $==="string"?$.length:typeof $==="number"?$:0;if(Y<J.min)X.push({path:Z,message:J.message||`Value must be at least ${J.min}`,expected:`>= ${J.min}`,actual:Y,rule:"min"})}if(J.max!==void 0){let Y=Array.isArray($)?$.length:typeof $==="string"?$.length:typeof $==="number"?$:0;if(Y>J.max)X.push({path:Z,message:J.message||`Value must not exceed ${J.max}`,expected:`<= ${J.max}`,actual:Y,rule:"max"})}if(J.pattern&&typeof $==="string"){if(!J.pattern.test($))X.push({path:Z,message:J.message||`Value does not match pattern ${J.pattern}`,expected:J.pattern.toString(),actual:$,rule:"pattern"})}if(J.enum&&!J.enum.includes($))X.push({path:Z,message:J.message||`Value must be one of: ${J.enum.join(", ")}`,expected:J.enum.join(", "),actual:$,rule:"enum"});if(J.validator){let Y=J.validator($);if(Y)X.push({path:Z,message:J.message||Y,rule:"custom"})}return X}getValueByPath($,J){if(!J)return $;let Z=J.split("."),X=$;for(let Y of Z)if(X&&typeof X==="object"&&Y in X)X=X[Y];else return;return X}generateRulesFromInterface($){let J=[],Z=$.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let X of Z){let[,Y,z,Q]=X;J.push({path:Y,required:!z,type:this.mapTypeScriptType(Q)})}return J}mapTypeScriptType($){switch($.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:jZ},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}class O7{fileLoader=new w$;envProcessor=new B$;validator=new R7;async loadConfig($){let J=Date.now(),{cache:Z,performance:X,schema:Y,validate:z,...Q}=$;try{if(Z?.enabled){let q=this.checkCache(Q.name||"",Q);if(q)return q}let G;try{G=await this.loadConfigurationStrategies(Q,!0,Z)}catch(q){let U=Q.__strictErrorHandling;if(q instanceof Error&&q.name==="ConfigNotFoundError"){if(U)throw q;G={...await this.applyEnvironmentVariables(Q.name||"",Q.defaultConfig,Q.checkEnv!==!1,Q.verbose||!1),warnings:[`No configuration file found for "${Q.name||"config"}", using defaults with environment variables`]}}else if(q instanceof Error&&q.name==="ConfigLoadError"){let W=q.message.includes("EACCES")||q.message.includes("EPERM")||q.message.includes("permission denied"),K=!W&&(q.message.includes("syntax")||q.message.includes("Expected")||q.message.includes("Unexpected")||q.message.includes("BuildMessage")||q.message.includes("errors building")),H=q.message.includes("Configuration must export a valid object")||q.message.includes("Configuration file is empty and exports nothing");if(U&&(H||W))throw q;if(K&&(!U||!H))G={...await this.applyEnvironmentVariables(Q.name||"",Q.defaultConfig,Q.checkEnv!==!1,Q.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!U)G={...await this.applyEnvironmentVariables(Q.name||"",Q.defaultConfig,Q.checkEnv!==!1,Q.verbose||!1),warnings:[`Configuration loading error, using defaults: ${q.message}`]};else throw q}else G={...await this.applyEnvironmentVariables(Q.name||"",Q.defaultConfig,Q.checkEnv!==!1,Q.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${q instanceof Error?q.message:String(q)}`]}}if(Y||z)await this.validateConfiguration(G.config,Y,z,Q.name);if(Z?.enabled&&G)this.cacheResult(Q.name||"",G,Z,Q);if(X?.enabled){let q={operation:"loadConfig",duration:Date.now()-J,configName:Q.name,timestamp:new Date};if(X.onMetrics)X.onMetrics(q);if(X.slowThreshold&&q.duration>X.slowThreshold)b0.warn(`Slow configuration loading detected: ${q.duration}ms for ${Q.name}`);G.metrics=q}return G}catch(G){let q=Date.now()-J;throw b0.error(`Configuration loading failed after ${q}ms:`,[G instanceof Error?G:Error(String(G))]),G}}async loadConfigurationStrategies($,J=!1,Z){let{name:X="",alias:Y,cwd:z,configDir:Q,defaultConfig:G,checkEnv:q=!0,arrayStrategy:U="replace",verbose:W=!1}=$,K=z||Z1.cwd(),H=[],V=await this.loadLocalConfiguration(X,Y,K,Q,G,U,W,q,Z);if(V)return H.push(...this.getLocalSearchPaths(X,Y,K,Q)),this.finalizeResult(V,H,q,X,W);let A=await this.loadHomeConfiguration(X,Y,G,U,W,q);if(A)return H.push(...this.getHomeSearchPaths(X,Y)),this.finalizeResult(A,H,q,X,W);let _=await this.loadPackageJsonConfiguration(X,Y,K,G,U,W,q);if(_)return H.push(L0(K,"package.json")),this.finalizeResult(_,H,q,X,W);if(H.push(...this.getAllSearchPaths(X,Y,K,Q)),J)throw s0.configNotFound(X,H,Y);return{...await this.applyEnvironmentVariables(X,G,q,W),warnings:[`No configuration file found for "${X}"${Y?` or alias "${Y}"`:""}, using defaults with environment variables`]}}async loadLocalConfiguration($,J,Z,X,Y,z,Q,G,q){let U=G?P1($,Y,Q):Y,W=this.getLocalDirectories(Z,X);for(let K of W){if(Q)b0.info(`Searching for configuration in: ${K}`);let H=this.fileLoader.generateConfigPaths($,K,J),V=await this.fileLoader.tryLoadFromPaths(H,U,{arrayStrategy:z,verbose:Q,cacheTtl:q?.ttl,useCache:!q?.ttl||q.ttl>100});if(V){if(Q)b0.success(`Configuration loaded from: ${V.source.path}`);return V}}return null}async loadHomeConfiguration($,J,Z,X,Y,z){if(!$)return null;let Q=z?P1($,Z,Y):Z,G=[L0(q1(),".config",$),L0(q1(),".config"),q1()];for(let q of G){if(Y)b0.info(`Checking home directory: ${q}`);let U=this.fileLoader.generateConfigPaths($,q,J),W=await this.fileLoader.tryLoadFromPaths(U,Q,{arrayStrategy:X,verbose:Y});if(W){if(Y)b0.success(`Configuration loaded from home directory: ${W.source.path}`);return W}}return null}async loadPackageJsonConfiguration($,J,Z,X,Y,z,Q){let G=Q?P1($,X,z):X;try{let q=L0(Z,"package.json");if(!U7(q))return null;let U=await import(q),W=U[$],K=$;if(!W&&J)W=U[J],K=J;if(W&&typeof W==="object"&&!Array.isArray(W)){if(z)b0.success(`Configuration loaded from package.json: ${K}`);return{config:D7(G,W,Y),source:{type:"package.json",path:q,priority:30,timestamp:new Date}}}}catch(q){if(z)b0.warn("Failed to load package.json:",[q instanceof Error?q:Error(String(q))])}return null}async applyEnvironmentVariables($,J,Z,X){if(!Z||!$||typeof J!=="object"||J===null||Array.isArray(J))return{config:J,source:{type:"default",priority:10,timestamp:new Date}};return{config:P1($,J,X),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult($,J,Z,X,Y){return{config:$.config,source:$.source,path:$.source.path}}async validateConfiguration($,J,Z,X){let Y=[];if(Z){let z=Z($);if(z)Y.push(...z)}if(J){let z=await this.validator.validateConfiguration($,J);if(!z.isValid)Y.push(...z.errors.map((Q)=>Q.path?`${Q.path}: ${Q.message}`:Q.message))}if(Y.length>0)throw s0.configValidation(X||"unknown",Y,X)}checkCache($,J){let Z=this.generateCacheKey($,J);return w1.get(Z)||null}cacheResult($,J,Z,X){let Y=this.generateCacheKey($,X);w1.set(Y,J,void 0,Z.ttl)}generateCacheKey($,J){let Z=[$];if(J.alias)Z.push(`alias:${J.alias}`);if(J.cwd)Z.push(`cwd:${J.cwd}`);if(J.configDir)Z.push(`configDir:${J.configDir}`);if("checkEnv"in J)Z.push(`checkEnv:${J.checkEnv}`);return Z.join("|")}getLocalDirectories($,J){return Array.from(new Set([$,L0($,"config"),L0($,".config"),J?L0($,J):void 0].filter(Boolean)))}getAllSearchPaths($,J,Z,X){let Y=[];return Y.push(...this.getLocalSearchPaths($,J,Z,X)),Y.push(...this.getHomeSearchPaths($,J)),Y.push(L0(Z,"package.json")),Y}getLocalSearchPaths($,J,Z,X){let Y=this.getLocalDirectories(Z,X),z=[];for(let Q of Y)z.push(...this.fileLoader.generateConfigPaths($,Q,J));return z}getHomeSearchPaths($,J){if(!$)return[];let Z=[L0(q1(),".config",$),L0(q1(),".config"),q1()],X=[];for(let Y of Z)X.push(...this.fileLoader.generateConfigPaths($,Y,J));return X}async loadConfigWithResult($){return this.loadConfig($)}}function p9($){let Z=!($.message.includes("EACCES")||$.message.includes("EPERM")||$.message.includes("permission denied"))&&($.message.includes("syntax")||$.message.includes("Expected")||$.message.includes("Unexpected")||$.message.includes("BuildMessage")),X=$.message.includes("Configuration must export a valid object")||$.message.includes("Configuration file is empty and exports nothing");return Z||X}async function ZQ($){return r0.loadConfig({...$,__strictErrorHandling:!0})}async function AZ($){let J="defaultConfig"in $&&$.defaultConfig!==void 0?$.defaultConfig:{},Z="cache"in $||"performance"in $||"schema"in $||"validate"in $;try{let X;if(Z)X=await r0.loadConfig($);else X=await r0.loadConfig({...$,defaultConfig:J,cache:{enabled:!0},performance:{enabled:!1}});return X?.config??J}catch(X){let Y=X instanceof Error?X.name:"UnknownError",z=X instanceof Error?X.message:String(X);if(!(Y==="ConfigNotFoundError"||Y==="ConfigLoadError"||Y==="ConfigValidationError"||z.includes("config"))&&$.verbose)b0.warn("Unexpected error loading config, using defaults:",[X instanceof Error?X:Error(String(X))]);let G=Z?{...$,defaultConfig:J}:{...$,defaultConfig:J,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in $?$.checkEnv!==!1:!0)return(await r0.applyEnvironmentVariables(G.name||"",J,!0,G.verbose||!1))?.config??J;return J}}async function JQ($={defaultConfig:{}}){if(typeof $==="string"){let{cwd:J}=await import("process");try{return(await r0.loadConfig({name:$,cwd:J(),generatedDir:"./generated",configDir:"./config",defaultConfig:{},checkEnv:!0,arrayStrategy:"replace"})).config}catch(Z){if(Z instanceof Error&&(Z.name==="ConfigNotFoundError"||Z.name==="ConfigLoadError"&&p9(Z)))return(await r0.applyEnvironmentVariables($,{},!0,!1)).config;throw Z}}try{return(await r0.loadConfig({...$,cwd:$.cwd||Z1.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(J){if(J instanceof Error&&(J.name==="ConfigNotFoundError"||J.name==="ConfigLoadError"&&p9(J)))return(await r0.applyEnvironmentVariables($.name||"",$.defaultConfig||{},$.checkEnv!==!1,$.verbose||!1)).config;throw J}}async function XQ($,J,Z="replace"){let X=new w$;try{let Y=await X.loadFromPath($,J,{arrayStrategy:Z,useCache:!1,trackPerformance:!1});return Y?Y.config:null}catch{return null}}function P1($,J,Z=!1){let X=new B$,Y=$.toUpperCase().replace(/[^A-Z0-9]/g,"_");function z(Q,G=[]){let q={...Q};for(let[U,W]of Object.entries(Q)){let K=[...G,U],H=[`${Y}_${K.join("_").toUpperCase()}`,`${Y}_${K.map((_)=>_.toUpperCase()).join("")}`,`${Y}_${K.map((_)=>_.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],V,A;for(let _ of H)if(V=Z1.env[_],V!==void 0){A=_;break}if(V!==void 0&&A)if(typeof W==="boolean")q[U]=["true","1","yes"].includes(V.toLowerCase());else if(typeof W==="number"){let _=Number(V);if(!Number.isNaN(_))q[U]=_}else if(Array.isArray(W))try{q[U]=JSON.parse(V)}catch{q[U]=V.split(",").map((_)=>_.trim())}else q[U]=V;else if(W&&typeof W==="object"&&!Array.isArray(W))q[U]=z(W,K)}return q}return z(J)}function YQ($){let J=L0(Z1.cwd(),$.configDir),Z=L0(Z1.cwd(),$.generatedDir),X=L0(Z,"config-types.ts");if(!U7(T9(X)))qz(T9(X),{recursive:!0,mode:511});let Y=U7(J)?Uz(J).map((Q)=>Q.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],z=`// Generated by bunfig v${yQ}
32
32
  export type ConfigNames = ${Y.length?`'${Y.join("' | '")}'`:"string"}
33
- `;Gz(X,z,{mode:438})}function JQ($){let J=null,Z=null,X=()=>{if(!Z)Z=VZ($).then((z)=>{return J=z,z},(z)=>{let Q="defaultConfig"in $?$.defaultConfig:{};if(J=Q,"verbose"in $&&$.verbose)y0.warn("Config loading failed, using defaults:",[z instanceof Error?z:Error(String(z))]);return Q});return Z},Y="defaultConfig"in $?$.defaultConfig:{};return J=Y,X(),new Proxy({},{get(z,Q){if(J)return J[Q];let G=Y[Q];return X(),G},has(z,Q){return Q in(J||Y)},ownKeys(){return Object.keys(J||Y)},getOwnPropertyDescriptor(z,Q){return Object.getOwnPropertyDescriptor(J||Y,Q)},set(z,Q,G){if(!J)J={...Y};return J[Q]=G,!0}})}function XQ($){let J=f9(Sz.cwd(),$?.configDir||"./config");function Z(){if(!Cz(J))return[];let Y=new Set([".ts",".js",".mjs",".cjs",".mts",".cts",".json"]),z=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"],Q=Iz(J).filter((q)=>Y.has($7(q))).map((q)=>({base:q.replace(/\.(?:ts|js|mjs|cjs|mts|cts|json)$/i,""),file:q})),G=new Map;for(let{base:q,file:U}of Q){let W=$7(U).toLowerCase(),K=G.get(q);if(!K){G.set(q,U);continue}let H=$7(K).toLowerCase();if(z.indexOf(W)<z.indexOf(H))G.set(q,U)}return Array.from(G.entries()).map(([q,U])=>({base:q,file:U})).sort((q,U)=>q.base.localeCompare(U.base))}function X(){let Y=Z(),z=Y.map((U)=>U.base),Q=z.length?z.map((U)=>`'${U}'`).join(" | "):"string",G=Y.length?`{
34
- ${Y.map((U)=>{let W=f9(J,U.file).replace(/\\/g,"/");return` '${U.base}': typeof import('${W}').default`}).join(`,
33
+ `;Wz(X,z,{mode:438})}function zQ($){let J=null,Z=null,X=()=>{if(!Z)Z=AZ($).then((z)=>{return J=z,z},(z)=>{let Q="defaultConfig"in $?$.defaultConfig:{};if(J=Q,"verbose"in $&&$.verbose)b0.warn("Config loading failed, using defaults:",[z instanceof Error?z:Error(String(z))]);return Q});return Z},Y="defaultConfig"in $?$.defaultConfig:{};return J=Y,X(),new Proxy({},{get(z,Q){if(J)return J[Q];let G=Y[Q];return X(),G},has(z,Q){return Q in(J||Y)},ownKeys(){return Object.keys(J||Y)},getOwnPropertyDescriptor(z,Q){return Object.getOwnPropertyDescriptor(J||Y,Q)},set(z,Q,G){if(!J)J={...Y};return J[Q]=G,!0}})}function QQ($){let J=g9(bz.cwd(),$?.configDir||"./config");function Z(){if(!vz(J))return[];let Y=new Set([".ts",".js",".mjs",".cjs",".mts",".cts",".json"]),z=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"],Q=yz(J).filter((q)=>Y.has($7(q))).map((q)=>({base:q.replace(/\.(?:ts|js|mjs|cjs|mts|cts|json)$/i,""),file:q})),G=new Map;for(let{base:q,file:U}of Q){let W=$7(U).toLowerCase(),K=G.get(q);if(!K){G.set(q,U);continue}let H=$7(K).toLowerCase();if(z.indexOf(W)<z.indexOf(H))G.set(q,U)}return Array.from(G.entries()).map(([q,U])=>({base:q,file:U})).sort((q,U)=>q.base.localeCompare(U.base))}function X(){let Y=Z(),z=Y.map((U)=>U.base),Q=z.length?z.map((U)=>`'${U}'`).join(" | "):"string",G=Y.length?`{
34
+ ${Y.map((U)=>{let W=g9(J,U.file).replace(/\\/g,"/");return` '${U.base}': typeof import('${W}').default`}).join(`,
35
35
  `)}
36
36
  }`:"Record<string, any>";return`export type ConfigNames = ${Q}
37
37
  export type ConfigByName = ${G}
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(Y){Y.onResolve({filter:/^virtual:bunfig-types$/},(z)=>{return{path:z.path,namespace:"bunfig-virtual"}}),Y.onLoad({filter:/^virtual:bunfig-types$/,namespace:"bunfig-virtual"},()=>{return{contents:X(),loader:"ts"}})}}}var AZ,F1,v1,_Z,YQ,zQ,p9,J$,H7,E0,q0,QQ,x9,GQ,h9,qQ,UQ,Z7,WQ,u9,m9,J7,KQ,HQ,VQ,AQ,X$,FZ,_Q,D0,FQ,BQ,d9,Y$,V7,B0,z0,wQ,o9,MQ,c9,jQ,NQ,X7,TQ,r9,l9,EQ,Y7,DQ,RQ,OQ,LQ,PQ,z$,BZ,CQ,IQ="0.15.6",C0,V$,I1,A7,_7,A$,F7,B7,S1,w7,M7,s0,wZ,MZ,y0,r0,jZ,NZ,SQ=Yz(async()=>{AZ=import.meta.require,F1=new j7,v1=new N7,_Z={createKey:vz,isEquivalent:yz,estimateMemoryUsage:bz},YQ=q$(W7.cwd(),"config"),zQ=q$(W7.cwd(),"src/generated"),p9=G$.env.CLARITY_LOG_DIR||Wz(gz(),"logs"),J$={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:p9,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1},H7=await pz(),E0={red:($)=>`\x1B[31m${$}\x1B[0m`,green:($)=>`\x1B[32m${$}\x1B[0m`,yellow:($)=>`\x1B[33m${$}\x1B[0m`,blue:($)=>`\x1B[34m${$}\x1B[0m`,magenta:($)=>`\x1B[35m${$}\x1B[0m`,cyan:($)=>`\x1B[36m${$}\x1B[0m`,white:($)=>`\x1B[37m${$}\x1B[0m`,gray:($)=>`\x1B[90m${$}\x1B[0m`,bgRed:($)=>`\x1B[41m${$}\x1B[0m`,bgYellow:($)=>`\x1B[43m${$}\x1B[0m`,bold:($)=>`\x1B[1m${$}\x1B[0m`,dim:($)=>`\x1B[2m${$}\x1B[0m`,italic:($)=>`\x1B[3m${$}\x1B[0m`,underline:($)=>`\x1B[4m${$}\x1B[0m`,reset:"\x1B[0m"},q0=E0,QQ=E0.red,x9=E0.green,GQ=E0.yellow,h9=E0.blue,qQ=E0.magenta,UQ=E0.cyan,Z7=E0.white,WQ=E0.gray,u9=E0.bgRed,m9=E0.bgYellow,J7=E0.bold,KQ=E0.dim,HQ=E0.italic,VQ=E0.underline,AQ=E0.reset,X$={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},FZ={debug:"\uD83D\uDD0D",info:h9("\u2139"),success:x9("\u2713"),warning:m9(Z7(J7(" WARN "))),error:u9(Z7(J7(" ERROR ")))},_Q=new W$("stacks"),D0=new W$("bunfig",{showTags:!0}),FQ=O0(C1.cwd(),"config"),BQ=O0(C1.cwd(),"src/generated"),d9=Q$.env.CLARITY_LOG_DIR||qz(mz(),"logs"),Y$={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:d9,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},V7=await dz(),B0={red:($)=>`\x1B[31m${$}\x1B[0m`,green:($)=>`\x1B[32m${$}\x1B[0m`,yellow:($)=>`\x1B[33m${$}\x1B[0m`,blue:($)=>`\x1B[34m${$}\x1B[0m`,magenta:($)=>`\x1B[35m${$}\x1B[0m`,cyan:($)=>`\x1B[36m${$}\x1B[0m`,white:($)=>`\x1B[37m${$}\x1B[0m`,gray:($)=>`\x1B[90m${$}\x1B[0m`,bgRed:($)=>`\x1B[41m${$}\x1B[0m`,bgYellow:($)=>`\x1B[43m${$}\x1B[0m`,bgGray:($)=>`\x1B[100m${$}\x1B[0m`,bold:($)=>`\x1B[1m${$}\x1B[0m`,dim:($)=>`\x1B[2m${$}\x1B[0m`,italic:($)=>`\x1B[3m${$}\x1B[0m`,underline:($)=>`\x1B[4m${$}\x1B[0m`,strikethrough:($)=>`\x1B[9m${$}\x1B[0m`,reset:"\x1B[0m"},z0=B0,wQ=B0.red,o9=B0.green,MQ=B0.yellow,c9=B0.blue,jQ=B0.magenta,NQ=B0.cyan,X7=B0.white,TQ=B0.gray,r9=B0.bgRed,l9=B0.bgYellow,EQ=B0.bgGray,Y7=B0.bold,DQ=B0.dim,RQ=B0.italic,OQ=B0.underline,LQ=B0.strikethrough,PQ=B0.reset,z$={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},BZ={debug:"\uD83D\uDD0D",info:c9("\u2139"),success:o9("\u2713"),warning:l9(X7(Y7(" WARN "))),error:r9(X7(Y7(" ERROR ")))},CQ=new H$("stacks"),C0=class extends Error{timestamp;context;constructor(J,Z={}){super(J);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=Z,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 J=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([Z,X])=>`${Z}: ${X}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${J}`}},V$=class extends C0{code="CONFIG_NOT_FOUND";constructor(J,Z,X){let Y=X?` or alias "${X}"`:"";super(`Configuration "${J}"${Y} not found`,{configName:J,alias:X,searchPaths:Z,searchPathCount:Z.length})}},I1=class extends C0{code="CONFIG_LOAD_ERROR";constructor(J,Z,X){super(`Failed to load configuration from "${J}": ${Z.message}`,{configPath:J,configName:X,originalError:Z.name,originalMessage:Z.message});this.cause=Z}},A7=class extends C0{code="CONFIG_VALIDATION_ERROR";constructor(J,Z,X){super(`Configuration validation failed for "${J}"`,{configPath:J,configName:X,validationErrors:Z,errorCount:Z.length})}},_7=class extends C0{code="CONFIG_MERGE_ERROR";constructor(J,Z,X,Y){super(`Failed to merge configuration from "${J}" with "${Z}": ${X.message}`,{sourcePath:J,targetPath:Z,configName:Y,originalError:X.name,originalMessage:X.message});this.cause=X}},A$=class extends C0{code="ENV_VAR_ERROR";constructor(J,Z,X,Y){super(`Failed to parse environment variable "${J}" with value "${Z}" as ${X}`,{envKey:J,envValue:Z,expectedType:X,configName:Y})}},F7=class extends C0{code="FILE_SYSTEM_ERROR";constructor(J,Z,X){super(`File system ${J} failed for "${Z}": ${X.message}`,{operation:J,path:Z,originalError:X.name,originalMessage:X.message});this.cause=X}},B7=class extends C0{code="TYPE_GENERATION_ERROR";constructor(J,Z,X){super(`Failed to generate types from "${J}" to "${Z}": ${X.message}`,{configDir:J,outputPath:Z,originalError:X.name,originalMessage:X.message});this.cause=X}},S1=class extends C0{code="SCHEMA_VALIDATION_ERROR";constructor(J,Z,X){super(`Schema validation failed${X?` for config "${X}"`:""}`,{schemaPath:J,configName:X,validationErrors:Z,errorCount:Z.length})}},w7=class extends C0{code="BROWSER_CONFIG_ERROR";constructor(J,Z,X,Y){super(`Failed to fetch configuration from "${J}": ${Z} ${X}`,{endpoint:J,status:Z,statusText:X,configName:Y})}},M7=class extends C0{code="PLUGIN_ERROR";constructor(J,Z,X){super(`Plugin "${J}" failed during ${Z}: ${X.message}`,{pluginName:J,operation:Z,originalError:X.name,originalMessage:X.message});this.cause=X}},s0={configNotFound($,J,Z){return new V$($,J,Z)},configLoad($,J,Z){return new I1($,J,Z)},configValidation($,J,Z){return new A7($,J,Z)},configMerge($,J,Z,X){return new _7($,J,Z,X)},envVar($,J,Z,X){return new A$($,J,Z,X)},fileSystem($,J,Z){return new F7($,J,Z)},typeGeneration($,J,Z){return new B7($,J,Z)},schemaValidation($,J,Z){return new S1($,J,Z)},browserConfig($,J,Z,X){return new w7($,J,Z,X)},plugin($,J,Z){return new M7($,J,Z)}},wZ={replace:"replace",concat:"concat",smart:"smart"},MZ=/^https?:\/\//,y0=new H$("bunfig",{showTags:!0}),r0=new O7,jZ=L0(Z1.cwd(),"config"),NZ=L0(Z1.cwd(),"src/generated")});function bQ($,J={}){let Z=_$.cwd();while(Z.includes("storage"))Z=a9(Z,"..");let X=a9(Z,$||"");if(J?.relative)return yQ(_$.cwd(),X);return X}var kQ=_$.env.CLARITY_LOG_DIR||vQ(bQ(),"logs"),TZ={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:kQ,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},F$={...TZ},zU=(async()=>{try{let{loadConfig:$}=await SQ().then(()=>XZ),J=await $({name:"clarity",alias:"logging",defaultConfig:TZ,cwd:_$.cwd()});if(J)Object.assign(F$,J)}catch{}return F$})();function w0(){if(c0.env.NODE_ENV==="test"||c0.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function cQ(){if(c0.env.NODE_ENV==="test"||c0.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof c0<"u"){let $=c0.type;if($==="renderer"||$==="worker")return!1;return!!(c0.versions&&(c0.versions.node||c0.versions.bun))}return!1}class EZ{async format($){let J=await cQ(),Z=await this.getMetadata(J);return JSON.stringify({timestamp:$.timestamp.toISOString(),level:$.level,name:$.name,message:$.message,metadata:Z})}async getMetadata($){if($){let{hostname:J}=await import("os");return{pid:_1.pid,hostname:J(),environment:_1.env.NODE_ENV||"development",platform:_1.platform,version:_1.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:_1.env.NODE_ENV||_1.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}var j0={red:($)=>`\x1B[31m${$}\x1B[0m`,green:($)=>`\x1B[32m${$}\x1B[0m`,yellow:($)=>`\x1B[33m${$}\x1B[0m`,blue:($)=>`\x1B[34m${$}\x1B[0m`,magenta:($)=>`\x1B[35m${$}\x1B[0m`,cyan:($)=>`\x1B[36m${$}\x1B[0m`,white:($)=>`\x1B[37m${$}\x1B[0m`,gray:($)=>`\x1B[90m${$}\x1B[0m`,bgRed:($)=>`\x1B[41m${$}\x1B[0m`,bgYellow:($)=>`\x1B[43m${$}\x1B[0m`,bgGray:($)=>`\x1B[100m${$}\x1B[0m`,bold:($)=>`\x1B[1m${$}\x1B[0m`,dim:($)=>`\x1B[2m${$}\x1B[0m`,italic:($)=>`\x1B[3m${$}\x1B[0m`,underline:($)=>`\x1B[4m${$}\x1B[0m`,strikethrough:($)=>`\x1B[9m${$}\x1B[0m`,reset:"\x1B[0m"},Q0=j0,FU=j0.red,rQ=j0.green,BU=j0.yellow,lQ=j0.blue,wU=j0.magenta,MU=j0.cyan,ZZ=j0.white,jU=j0.gray,aQ=j0.bgRed,sQ=j0.bgYellow,NU=j0.bgGray,JZ=j0.bold,TU=j0.dim,EU=j0.italic,DU=j0.underline,RU=j0.strikethrough,OU=j0.reset,q7={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},nQ={debug:"\uD83D\uDD0D",info:lQ("\u2139"),success:rQ("\u2713"),warning:sQ(ZZ(JZ(" WARN "))),error:aQ(ZZ(JZ(" ERROR ")))};class J1{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($,J={}){this.name=$,this.config={...F$},this.options=this.normalizeOptions(J),this.formatter=this.options.formatter||new EZ,this.enabled=J.enabled??!0,this.fancy=J.fancy??!0,this.tagFormat=J.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=J.timestampPosition??"right",this.environment=J.environment??Y0.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(J);let Z={...J},X=J.timestamp!==void 0;if(X)delete Z.timestamp;if(this.config={...this.config,...Z,timestamp:X||this.config.timestamp,level:this.options.level??"info"},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let Y=this.generateKeyId(),z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,z),this.encryptionKeys.set(Y,{key:z,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed($){if(!this.fingersCrossedConfig)return!1;let J={debug:0,info:1,success:2,warning:3,error:4},Z=this.fingersCrossedConfig.activationLevel??"error";return J[$]>=J[Z]}initializeFingersCrossedConfig($){if(!$.fingersCrossedEnabled&&$.fingersCrossed)return{...q7,...$.fingersCrossed};if(!$.fingersCrossedEnabled)return null;if(!$.fingersCrossed)return{...q7};return{...q7,...$.fingersCrossed}}normalizeOptions($){let J={format:"json",level:"info",logDirectory:F$.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},Z={...J,...Object.fromEntries(Object.entries($).filter(([,X])=>X!==void 0))};if(!Z.level||!["debug","info","success","warning","error"].includes(Z.level))Z.level=J.level;return Z}shouldWriteToFile(){return!w0()&&this.config.writeToFile===!0}async writeToFile($){let Z=(async()=>{let Y,z=0,Q=3,G=1000;while(z<Q)try{try{try{await hQ(this.config.logDirectory,t9.F_OK|t9.W_OK)}catch(U){if(U instanceof Error&&"code"in U)if(U.code==="ENOENT")await uQ(this.config.logDirectory,{recursive:!0,mode:493});else if(U.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw U;else throw U}}catch(U){throw console.error("Debug: [writeToFile] Failed to create log directory:",U),U}let q=this.validateEncryptionConfig()?(await this.encrypt($)).encrypted:m0.from($);try{if(!t1(this.currentLogFile))await G7(this.currentLogFile,"",{mode:420});if(Y=i9(this.currentLogFile,"a",420),xQ(Y,q,{flag:"a"}),n9(Y),Y!==void 0)Q7(Y),Y=void 0;if((await V1(this.currentLogFile)).size===0){if(await G7(this.currentLogFile,q,{flag:"w",mode:420}),(await V1(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(U){let W=U;if(W.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(W.code)){if(z<Q-1){let K=typeof W.message==="string"?W.message:"Unknown error";console.error(`Network error during write attempt ${z+1}/${Q}:`,K);let H=G*2**z;await new Promise((V)=>setTimeout(V,H)),z++;continue}}if(W?.code&&["ENOSPC","EDQUOT"].includes(W.code))throw Error(`Disk quota exceeded or no space left on device: ${W.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",W),W}finally{if(Y!==void 0)try{Q7(Y)}catch(U){console.error("Debug: [writeToFile] Error closing file descriptor:",U)}}}catch(q){if(z===Q-1){let W=q,K=typeof W.message==="string"?W.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",K),q}z++;let U=G*2**(z-1);await new Promise((W)=>setTimeout(W,U))}})();this.pendingOperations.push(Z);let X=this.pendingOperations.length-1;try{await Z}catch(Y){throw console.error("Debug: [writeToFile] Error in operation:",Y),Y}finally{this.pendingOperations.splice(X,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 A1(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 A1(this.config.logDirectory,`${this.name}.log`);let $=new Date().toISOString().split("T")[0];return A1(this.config.logDirectory,`${this.name}-${$}.log`)}setupRotation(){if(w0())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let $=this.config.rotation,J;switch($.frequency){case"daily":J=86400000;break;case"weekly":J=604800000;break;case"monthly":J=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},J)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let J=this.config.rotation.keyRotation;if(!J?.enabled)return;let Z=typeof J.interval==="number"?J.interval:60,X=Math.max(Z,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((Y)=>{console.error("Error rotating keys:",Y)})},X)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let J=this.config.rotation.keyRotation,Z=this.generateKeyId(),X=this.generateKey();this.currentKeyId=Z,this.keys.set(Z,X),this.encryptionKeys.set(Z,{key:X,createdAt:new Date});let Y=Array.from(this.encryptionKeys.entries()).sort(([,G],[,q])=>q.createdAt.getTime()-G.createdAt.getTime()),z=typeof J.maxKeys==="number"?J.maxKeys:1,Q=Math.max(1,z);if(Y.length>Q)for(let[G]of Y.slice(Q))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return z7(16).toString("hex")}generateKey(){return z7(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let $=this.keys.get(this.currentKeyId);if(!$)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:$,id:this.currentKeyId}}encrypt($){let{key:J}=this.getCurrentKey(),Z=z7(16),X=fQ("aes-256-gcm",J,Z),Y=m0.isBuffer($)?$:m0.from($,"utf8"),z=X.update(Y),Q=X.final(),G=z.length+Q.length,q=X.getAuthTag(),U=m0.allocUnsafe(16+G+16);return Z.copy(U,0),z.copy(U,16),Q.copy(U,16+z.length),q.copy(U,16+G),{encrypted:U,iv:Z}}async compressData($){return new Promise((J,Z)=>{let X=$Z(),Y=[];X.on("data",(z)=>Y.push(z)),X.on("end",()=>J(m0.from(m0.concat(Y)))),X.on("error",Z),X.write($),X.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let $={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let J=this.config.rotation.encrypt;return{...$,...J}}return $}async rotateLog(){if(w0())return;if(!this.shouldWriteToFile())return;let $=await V1(this.currentLogFile).catch(()=>null);if(!$)return;let J=this.config.rotation;if(typeof J==="boolean")return;if(J.maxSize&&$.size>=J.maxSize){let Z=this.currentLogFile,X=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let Y=await e1(this.config.logDirectory),z=Y.filter((q)=>q.startsWith(this.name)&&/\.log\.\d+$/.test(q)).sort((q,U)=>{let W=Number.parseInt(q.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(U.match(/\.log\.(\d+)$/)?.[1]||"0")-W}),Q=z.length>0?Number.parseInt(z[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Z}.${Q}`;if(await V1(Z).catch(()=>null))try{if(await e9(Z,G),J.compress)try{let q=`${G}.gz`;await this.compressLogFile(G,q),await $$(G)}catch(q){console.error("Error compressing rotated file:",q)}if(z.length===0&&!Y.some((q)=>q.endsWith(".log.1")))try{let q=`${Z}.1`;await G7(q,"")}catch(q){console.error("Error creating backup file:",q)}}catch(q){console.error(`Error during rotation: ${q instanceof Error?q.message:String(q)}`)}}else{let Y=new Date().toISOString().replace(/[:.]/g,"-"),z=Z.replace(/\.log$/,`-${Y}.log`);if(await V1(Z).catch(()=>null))await e9(Z,z)}if(this.currentLogFile=X,J.maxFiles){let z=(await e1(this.config.logDirectory)).filter((Q)=>Q.startsWith(this.name)).sort((Q,G)=>G.localeCompare(Q));for(let Q of z.slice(J.maxFiles))await $$(A1(this.config.logDirectory,Q))}}}async compressLogFile($,J){let Z=s9($),X=pQ(J),Y=$Z();await oQ(Z,Y,X)}async handleFingersCrossedBuffer($,J){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed($)&&!this.isActivated){this.isActivated=!0;for(let Z of this.logBuffer){let X=await this.formatter.format(Z);if(this.shouldWriteToFile())await this.writeToFile(X);console.log(X)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(J);console.log(J)}}shouldLog($){if(!this.enabled)return!1;let J={debug:0,info:1,success:2,warning:3,error:4};return J[$]>=J[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map(($)=>{if($ instanceof Promise)return $.catch((J)=>{console.error("Error in pending write operation:",J)});return Promise.resolve()})),t1(this.currentLogFile))try{let $=i9(this.currentLogFile,"r+");n9($),Q7($)}catch($){console.error(`Error flushing file: ${$}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let $ of this.pendingOperations)if(typeof $.cancel==="function")$.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch($){console.error("Error waiting for pending operations:",$)}if(!w0()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let J=(await e1(this.config.logDirectory)).filter((Z)=>(Z.includes("temp")||Z.includes(".tmp"))&&Z.includes(this.name));for(let Z of J)try{await $$(A1(this.config.logDirectory,Z))}catch(X){console.error(`Failed to delete temp file ${Z}:`,X)}}catch($){console.error("Error cleaning up temporary files:",$)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag($){if(!$)return"";return`${this.tagFormat.prefix}${$}${this.tagFormat.suffix}`}formatFileTimestamp($){return`[${$.toISOString()}]`}formatConsoleTimestamp($){return this.shouldStyleConsole()?Q0.gray($.toLocaleTimeString()):$.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||w0())return!1;let $=typeof Y0.env.NO_COLOR<"u",J=Y0.env.FORCE_COLOR==="0";if($||J)return!1;return!!(typeof Y0.stderr<"u"&&Y0.stderr.isTTY||typeof Y0.stdout<"u"&&Y0.stdout.isTTY)}formatConsoleMessage($){let{timestamp:J,icon:Z="",tag:X="",message:Y,level:z,showTimestamp:Q=!0}=$,G=(V)=>V.replace(this.ANSI_PATTERN,"");if(!this.fancy){let V=[];if(Q)V.push(J);if(z==="warning")V.push("WARN");else if(z==="error")V.push("ERROR");else if(Z)V.push(Z.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(X)V.push(X.replace(/[[\]]/g,""));return V.push(Y),V.join(" ")}let q=Y0.stdout.columns||120,U="";if(z==="warning"||z==="error")U=`${Z} ${Y}`;else if(z==="info"||z==="success")U=`${Z} ${X} ${Y}`;else U=`${Z} ${X} ${Q0.cyan(Y)}`;if(!Q)return U.trim();let W=G(U).trim().length,K=G(J).length,H=Math.max(1,q-2-W-K);return`${U.trim()}${" ".repeat(H)}${J}`}formatMessage($,J){if(J.length===1&&Array.isArray(J[0]))return $.replace(/\{(\d+)\}/g,(z,Q)=>{let G=Number.parseInt(Q,10);return G<J[0].length?String(J[0][G]):z});let Z=/%([sdijfo%])/g,X=0,Y=$.replace(Z,(z,Q)=>{if(Q==="%")return"%";if(X>=J.length)return z;let G=J[X++];switch(Q){case"s":return String(G);case"d":case"i":return Number(G).toString();case"j":case"o":return JSON.stringify(G,null,2);default:return z}});if(X<J.length)Y+=` ${J.slice(X).map((z)=>typeof z==="object"?JSON.stringify(z,null,2):String(z)).join(" ")}`;return Y}formatMarkdown($){if(!$)return $;let J=$;return J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(Z,X,Y)=>{let z=Q0.underline(Q0.blue(X)),Q=this.toAbsoluteFilePath(Y);if(Q&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let G=`file://${encodeURI(Q)}`,q="\x1B]8;;",U="\x1B\\";return`\x1B]8;;${G}\x1B\\${z}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${Y}\x1B\\${z}\x1B]8;;\x1B\\`;return z}),J=J.replace(/`([^`]+)`/g,(Z,X)=>Q0.bgGray(X)),J=J.replace(/\*\*([^*]+)\*\*/g,(Z,X)=>Q0.bold(X)),J=J.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(Z,X)=>Q0.italic(X)),J=J.replace(/(?<!_)_([^_]+)_(?!_)/g,(Z,X)=>Q0.italic(X)),J=J.replace(/~([^~]+)~/g,(Z,X)=>Q0.strikethrough(X)),J}supportsHyperlinks(){if(w0())return!1;let $=Y0.env;if(!$)return!1;if($.TERM_PROGRAM==="iTerm.app"||$.TERM_PROGRAM==="vscode"||$.TERM_PROGRAM==="WezTerm")return!0;if($.WT_SESSION)return!0;if($.TERM==="xterm-kitty")return!0;let J=$.VTE_VERSION?Number.parseInt($.VTE_VERSION,10):0;if(!Number.isNaN(J)&&J>=5000)return!0;return!1}toAbsoluteFilePath($){try{let J=$;if(J.startsWith("file://"))J=J.replace(/^file:\/\//,"");if(J.startsWith("~")){let Z=Y0.env.HOME||"";if(Z)J=J.replace(/^~(?=$|\/)/,Z)}if(mQ(J)||J.startsWith("./")||J.startsWith("../"))J=dQ(J);else return null;return t1(J)?J:null}catch{return null}}buildOutputTexts($){let J=this.shouldStyleConsole()?this.formatMarkdown($):$,Z=$.replace(this.ANSI_PATTERN,"");return{consoleText:J,fileText:Z}}async log($,J,...Z){if(!this.shouldLog($))return;let X=new Date,Y=this.formatConsoleTimestamp(X),z=this.formatFileTimestamp(X),Q,G;if(J instanceof Error)Q=J.message,G=J.stack;else Q=this.formatMessage(J,Z);let{consoleText:q,fileText:U}=this.buildOutputTexts(Q);if(this.shouldStyleConsole()){let K=this.options.showIcons===!1?"":nQ[$],H=this.options.showTags!==!1&&this.name?Q0.gray(this.formatTag(this.name)):"",V;switch($){case"debug":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:Q0.gray(q),level:$}),console.error(V);break;case"info":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.warn(V);break;case"success":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:Q0.green(q),level:$}),console.error(V);break;case"warning":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.warn(V);break;case"error":if(V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.error(V),G){let A=G.split(`
40
+ `}return{name:"bunfig-plugin",setup(Y){Y.onResolve({filter:/^virtual:bunfig-types$/},(z)=>{return{path:z.path,namespace:"bunfig-virtual"}}),Y.onLoad({filter:/^virtual:bunfig-types$/,namespace:"bunfig-virtual"},()=>{return{contents:X(),loader:"ts"}})}}}var _Z,w1,v1,FZ,GQ,qQ,x9,J$,H7,E0,q0,UQ,h9,WQ,u9,KQ,HQ,Z7,VQ,m9,d9,J7,AQ,_Q,FQ,BQ,X$,BZ,wQ,D0,MQ,jQ,o9,Y$,V7,B0,z0,NQ,c9,TQ,r9,EQ,DQ,X7,RQ,l9,a9,OQ,Y7,LQ,PQ,CQ,IQ,SQ,z$,wZ,vQ,yQ="0.15.6",C0,V$,I1,A7,_7,A$,F7,B7,S1,w7,M7,s0,MZ,jZ,b0,r0,NZ,TZ,bQ=Gz(async()=>{_Z=import.meta.require,w1=new j7,v1=new N7,FZ={createKey:kz,isEquivalent:fz,estimateMemoryUsage:gz},GQ=q$(W7.cwd(),"config"),qQ=q$(W7.cwd(),"src/generated"),x9=G$.env.CLARITY_LOG_DIR||Vz(hz(),"logs"),J$={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:x9,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1},H7=await uz(),E0={red:($)=>`\x1B[31m${$}\x1B[0m`,green:($)=>`\x1B[32m${$}\x1B[0m`,yellow:($)=>`\x1B[33m${$}\x1B[0m`,blue:($)=>`\x1B[34m${$}\x1B[0m`,magenta:($)=>`\x1B[35m${$}\x1B[0m`,cyan:($)=>`\x1B[36m${$}\x1B[0m`,white:($)=>`\x1B[37m${$}\x1B[0m`,gray:($)=>`\x1B[90m${$}\x1B[0m`,bgRed:($)=>`\x1B[41m${$}\x1B[0m`,bgYellow:($)=>`\x1B[43m${$}\x1B[0m`,bold:($)=>`\x1B[1m${$}\x1B[0m`,dim:($)=>`\x1B[2m${$}\x1B[0m`,italic:($)=>`\x1B[3m${$}\x1B[0m`,underline:($)=>`\x1B[4m${$}\x1B[0m`,reset:"\x1B[0m"},q0=E0,UQ=E0.red,h9=E0.green,WQ=E0.yellow,u9=E0.blue,KQ=E0.magenta,HQ=E0.cyan,Z7=E0.white,VQ=E0.gray,m9=E0.bgRed,d9=E0.bgYellow,J7=E0.bold,AQ=E0.dim,_Q=E0.italic,FQ=E0.underline,BQ=E0.reset,X$={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},BZ={debug:"\uD83D\uDD0D",info:u9("\u2139"),success:h9("\u2713"),warning:d9(Z7(J7(" WARN "))),error:m9(Z7(J7(" ERROR ")))},wQ=new W$("stacks"),D0=new W$("bunfig",{showTags:!0}),MQ=O0(C1.cwd(),"config"),jQ=O0(C1.cwd(),"src/generated"),o9=Q$.env.CLARITY_LOG_DIR||Kz(cz(),"logs"),Y$={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:o9,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},V7=await rz(),B0={red:($)=>`\x1B[31m${$}\x1B[0m`,green:($)=>`\x1B[32m${$}\x1B[0m`,yellow:($)=>`\x1B[33m${$}\x1B[0m`,blue:($)=>`\x1B[34m${$}\x1B[0m`,magenta:($)=>`\x1B[35m${$}\x1B[0m`,cyan:($)=>`\x1B[36m${$}\x1B[0m`,white:($)=>`\x1B[37m${$}\x1B[0m`,gray:($)=>`\x1B[90m${$}\x1B[0m`,bgRed:($)=>`\x1B[41m${$}\x1B[0m`,bgYellow:($)=>`\x1B[43m${$}\x1B[0m`,bgGray:($)=>`\x1B[100m${$}\x1B[0m`,bold:($)=>`\x1B[1m${$}\x1B[0m`,dim:($)=>`\x1B[2m${$}\x1B[0m`,italic:($)=>`\x1B[3m${$}\x1B[0m`,underline:($)=>`\x1B[4m${$}\x1B[0m`,strikethrough:($)=>`\x1B[9m${$}\x1B[0m`,reset:"\x1B[0m"},z0=B0,NQ=B0.red,c9=B0.green,TQ=B0.yellow,r9=B0.blue,EQ=B0.magenta,DQ=B0.cyan,X7=B0.white,RQ=B0.gray,l9=B0.bgRed,a9=B0.bgYellow,OQ=B0.bgGray,Y7=B0.bold,LQ=B0.dim,PQ=B0.italic,CQ=B0.underline,IQ=B0.strikethrough,SQ=B0.reset,z$={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},wZ={debug:"\uD83D\uDD0D",info:r9("\u2139"),success:c9("\u2713"),warning:a9(X7(Y7(" WARN "))),error:l9(X7(Y7(" ERROR ")))},vQ=new H$("stacks"),C0=class extends Error{timestamp;context;constructor(J,Z={}){super(J);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=Z,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 J=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([Z,X])=>`${Z}: ${X}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${J}`}},V$=class extends C0{code="CONFIG_NOT_FOUND";constructor(J,Z,X){let Y=X?` or alias "${X}"`:"";super(`Configuration "${J}"${Y} not found`,{configName:J,alias:X,searchPaths:Z,searchPathCount:Z.length})}},I1=class extends C0{code="CONFIG_LOAD_ERROR";constructor(J,Z,X){super(`Failed to load configuration from "${J}": ${Z.message}`,{configPath:J,configName:X,originalError:Z.name,originalMessage:Z.message});this.cause=Z}},A7=class extends C0{code="CONFIG_VALIDATION_ERROR";constructor(J,Z,X){super(`Configuration validation failed for "${J}"`,{configPath:J,configName:X,validationErrors:Z,errorCount:Z.length})}},_7=class extends C0{code="CONFIG_MERGE_ERROR";constructor(J,Z,X,Y){super(`Failed to merge configuration from "${J}" with "${Z}": ${X.message}`,{sourcePath:J,targetPath:Z,configName:Y,originalError:X.name,originalMessage:X.message});this.cause=X}},A$=class extends C0{code="ENV_VAR_ERROR";constructor(J,Z,X,Y){super(`Failed to parse environment variable "${J}" with value "${Z}" as ${X}`,{envKey:J,envValue:Z,expectedType:X,configName:Y})}},F7=class extends C0{code="FILE_SYSTEM_ERROR";constructor(J,Z,X){super(`File system ${J} failed for "${Z}": ${X.message}`,{operation:J,path:Z,originalError:X.name,originalMessage:X.message});this.cause=X}},B7=class extends C0{code="TYPE_GENERATION_ERROR";constructor(J,Z,X){super(`Failed to generate types from "${J}" to "${Z}": ${X.message}`,{configDir:J,outputPath:Z,originalError:X.name,originalMessage:X.message});this.cause=X}},S1=class extends C0{code="SCHEMA_VALIDATION_ERROR";constructor(J,Z,X){super(`Schema validation failed${X?` for config "${X}"`:""}`,{schemaPath:J,configName:X,validationErrors:Z,errorCount:Z.length})}},w7=class extends C0{code="BROWSER_CONFIG_ERROR";constructor(J,Z,X,Y){super(`Failed to fetch configuration from "${J}": ${Z} ${X}`,{endpoint:J,status:Z,statusText:X,configName:Y})}},M7=class extends C0{code="PLUGIN_ERROR";constructor(J,Z,X){super(`Plugin "${J}" failed during ${Z}: ${X.message}`,{pluginName:J,operation:Z,originalError:X.name,originalMessage:X.message});this.cause=X}},s0={configNotFound($,J,Z){return new V$($,J,Z)},configLoad($,J,Z){return new I1($,J,Z)},configValidation($,J,Z){return new A7($,J,Z)},configMerge($,J,Z,X){return new _7($,J,Z,X)},envVar($,J,Z,X){return new A$($,J,Z,X)},fileSystem($,J,Z){return new F7($,J,Z)},typeGeneration($,J,Z){return new B7($,J,Z)},schemaValidation($,J,Z){return new S1($,J,Z)},browserConfig($,J,Z,X){return new w7($,J,Z,X)},plugin($,J,Z){return new M7($,J,Z)}},MZ={replace:"replace",concat:"concat",smart:"smart"},jZ=/^https?:\/\//,b0=new H$("bunfig",{showTags:!0}),r0=new O7,NZ=L0(Z1.cwd(),"config"),TZ=L0(Z1.cwd(),"src/generated")});function gQ($,J={}){let Z=_$.cwd();while(Z.includes("storage"))Z=s9(Z,"..");let X=s9(Z,$||"");if(J?.relative)return fQ(_$.cwd(),X);return X}var pQ=_$.env.CLARITY_LOG_DIR||kQ(gQ(),"logs"),EZ={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:pQ,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},F$={...EZ},GU=(async()=>{try{let{loadConfig:$}=await bQ().then(()=>YZ),J=await $({name:"clarity",alias:"logging",defaultConfig:EZ,cwd:_$.cwd()});if(J)Object.assign(F$,J)}catch{}return F$})();function w0(){if(c0.env.NODE_ENV==="test"||c0.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function aQ(){if(c0.env.NODE_ENV==="test"||c0.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof c0<"u"){let $=c0.type;if($==="renderer"||$==="worker")return!1;return!!(c0.versions&&(c0.versions.node||c0.versions.bun))}return!1}class DZ{async format($){let J=await aQ(),Z=await this.getMetadata(J);return JSON.stringify({timestamp:$.timestamp.toISOString(),level:$.level,name:$.name,message:$.message,metadata:Z})}async getMetadata($){if($){let{hostname:J}=await import("os");return{pid:B1.pid,hostname:J(),environment:B1.env.NODE_ENV||"development",platform:B1.platform,version:B1.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:B1.env.NODE_ENV||B1.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}var j0={red:($)=>`\x1B[31m${$}\x1B[0m`,green:($)=>`\x1B[32m${$}\x1B[0m`,yellow:($)=>`\x1B[33m${$}\x1B[0m`,blue:($)=>`\x1B[34m${$}\x1B[0m`,magenta:($)=>`\x1B[35m${$}\x1B[0m`,cyan:($)=>`\x1B[36m${$}\x1B[0m`,white:($)=>`\x1B[37m${$}\x1B[0m`,gray:($)=>`\x1B[90m${$}\x1B[0m`,bgRed:($)=>`\x1B[41m${$}\x1B[0m`,bgYellow:($)=>`\x1B[43m${$}\x1B[0m`,bgGray:($)=>`\x1B[100m${$}\x1B[0m`,bold:($)=>`\x1B[1m${$}\x1B[0m`,dim:($)=>`\x1B[2m${$}\x1B[0m`,italic:($)=>`\x1B[3m${$}\x1B[0m`,underline:($)=>`\x1B[4m${$}\x1B[0m`,strikethrough:($)=>`\x1B[9m${$}\x1B[0m`,reset:"\x1B[0m"},Q0=j0,wU=j0.red,sQ=j0.green,MU=j0.yellow,nQ=j0.blue,jU=j0.magenta,NU=j0.cyan,JZ=j0.white,TU=j0.gray,iQ=j0.bgRed,tQ=j0.bgYellow,EU=j0.bgGray,XZ=j0.bold,DU=j0.dim,RU=j0.italic,OU=j0.underline,LU=j0.strikethrough,PU=j0.reset,q7={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},eQ={debug:"\uD83D\uDD0D",info:nQ("\u2139"),success:sQ("\u2713"),warning:tQ(JZ(XZ(" WARN "))),error:iQ(JZ(XZ(" ERROR ")))};class J1{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($,J={}){this.name=$,this.config={...F$},this.options=this.normalizeOptions(J),this.formatter=this.options.formatter||new DZ,this.enabled=J.enabled??!0,this.fancy=J.fancy??!0,this.tagFormat=J.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=J.timestampPosition??"right",this.environment=J.environment??Y0.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(J);let Z={...J},X=J.timestamp!==void 0;if(X)delete Z.timestamp;if(this.config={...this.config,...Z,timestamp:X||this.config.timestamp,level:this.options.level??"info"},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let Y=this.generateKeyId(),z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,z),this.encryptionKeys.set(Y,{key:z,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed($){if(!this.fingersCrossedConfig)return!1;let J={debug:0,info:1,success:2,warning:3,error:4},Z=this.fingersCrossedConfig.activationLevel??"error";return J[$]>=J[Z]}initializeFingersCrossedConfig($){if(!$.fingersCrossedEnabled&&$.fingersCrossed)return{...q7,...$.fingersCrossed};if(!$.fingersCrossedEnabled)return null;if(!$.fingersCrossed)return{...q7};return{...q7,...$.fingersCrossed}}normalizeOptions($){let J={format:"json",level:"info",logDirectory:F$.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},Z={...J,...Object.fromEntries(Object.entries($).filter(([,X])=>X!==void 0))};if(!Z.level||!["debug","info","success","warning","error"].includes(Z.level))Z.level=J.level;return Z}shouldWriteToFile(){return!w0()&&this.config.writeToFile===!0}async writeToFile($){let Z=(async()=>{let Y,z=0,Q=3,G=1000;while(z<Q)try{try{try{await dQ(this.config.logDirectory,e9.F_OK|e9.W_OK)}catch(U){if(U instanceof Error&&"code"in U)if(U.code==="ENOENT")await oQ(this.config.logDirectory,{recursive:!0,mode:493});else if(U.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw U;else throw U}}catch(U){throw console.error("Debug: [writeToFile] Failed to create log directory:",U),U}let q=this.validateEncryptionConfig()?(await this.encrypt($)).encrypted:m0.from($);try{if(!t1(this.currentLogFile))await G7(this.currentLogFile,"",{mode:420});if(Y=t9(this.currentLogFile,"a",420),mQ(Y,q,{flag:"a"}),i9(Y),Y!==void 0)Q7(Y),Y=void 0;if((await _1(this.currentLogFile)).size===0){if(await G7(this.currentLogFile,q,{flag:"w",mode:420}),(await _1(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(U){let W=U;if(W.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(W.code)){if(z<Q-1){let K=typeof W.message==="string"?W.message:"Unknown error";console.error(`Network error during write attempt ${z+1}/${Q}:`,K);let H=G*2**z;await new Promise((V)=>setTimeout(V,H)),z++;continue}}if(W?.code&&["ENOSPC","EDQUOT"].includes(W.code))throw Error(`Disk quota exceeded or no space left on device: ${W.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",W),W}finally{if(Y!==void 0)try{Q7(Y)}catch(U){console.error("Debug: [writeToFile] Error closing file descriptor:",U)}}}catch(q){if(z===Q-1){let W=q,K=typeof W.message==="string"?W.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",K),q}z++;let U=G*2**(z-1);await new Promise((W)=>setTimeout(W,U))}})();this.pendingOperations.push(Z);let X=this.pendingOperations.length-1;try{await Z}catch(Y){throw console.error("Debug: [writeToFile] Error in operation:",Y),Y}finally{this.pendingOperations.splice(X,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 F1(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 F1(this.config.logDirectory,`${this.name}.log`);let $=new Date().toISOString().split("T")[0];return F1(this.config.logDirectory,`${this.name}-${$}.log`)}setupRotation(){if(w0())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let $=this.config.rotation,J;switch($.frequency){case"daily":J=86400000;break;case"weekly":J=604800000;break;case"monthly":J=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},J)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let J=this.config.rotation.keyRotation;if(!J?.enabled)return;let Z=typeof J.interval==="number"?J.interval:60,X=Math.max(Z,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((Y)=>{console.error("Error rotating keys:",Y)})},X)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let J=this.config.rotation.keyRotation,Z=this.generateKeyId(),X=this.generateKey();this.currentKeyId=Z,this.keys.set(Z,X),this.encryptionKeys.set(Z,{key:X,createdAt:new Date});let Y=Array.from(this.encryptionKeys.entries()).sort(([,G],[,q])=>q.createdAt.getTime()-G.createdAt.getTime()),z=typeof J.maxKeys==="number"?J.maxKeys:1,Q=Math.max(1,z);if(Y.length>Q)for(let[G]of Y.slice(Q))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return z7(16).toString("hex")}generateKey(){return z7(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let $=this.keys.get(this.currentKeyId);if(!$)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:$,id:this.currentKeyId}}encrypt($){let{key:J}=this.getCurrentKey(),Z=z7(16),X=xQ("aes-256-gcm",J,Z),Y=m0.isBuffer($)?$:m0.from($,"utf8"),z=X.update(Y),Q=X.final(),G=z.length+Q.length,q=X.getAuthTag(),U=m0.allocUnsafe(16+G+16);return Z.copy(U,0),z.copy(U,16),Q.copy(U,16+z.length),q.copy(U,16+G),{encrypted:U,iv:Z}}async compressData($){return new Promise((J,Z)=>{let X=ZZ(),Y=[];X.on("data",(z)=>Y.push(z)),X.on("end",()=>J(m0.from(m0.concat(Y)))),X.on("error",Z),X.write($),X.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let $={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let J=this.config.rotation.encrypt;return{...$,...J}}return $}async rotateLog(){if(w0())return;if(!this.shouldWriteToFile())return;let $=await _1(this.currentLogFile).catch(()=>null);if(!$)return;let J=this.config.rotation;if(typeof J==="boolean")return;if(J.maxSize&&$.size>=J.maxSize){let Z=this.currentLogFile,X=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let Y=await e1(this.config.logDirectory),z=Y.filter((q)=>q.startsWith(this.name)&&/\.log\.\d+$/.test(q)).sort((q,U)=>{let W=Number.parseInt(q.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(U.match(/\.log\.(\d+)$/)?.[1]||"0")-W}),Q=z.length>0?Number.parseInt(z[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Z}.${Q}`;if(await _1(Z).catch(()=>null))try{if(await $Z(Z,G),J.compress)try{let q=`${G}.gz`;await this.compressLogFile(G,q),await $$(G)}catch(q){console.error("Error compressing rotated file:",q)}if(z.length===0&&!Y.some((q)=>q.endsWith(".log.1")))try{let q=`${Z}.1`;await G7(q,"")}catch(q){console.error("Error creating backup file:",q)}}catch(q){console.error(`Error during rotation: ${q instanceof Error?q.message:String(q)}`)}}else{let Y=new Date().toISOString().replace(/[:.]/g,"-"),z=Z.replace(/\.log$/,`-${Y}.log`);if(await _1(Z).catch(()=>null))await $Z(Z,z)}if(this.currentLogFile=X,J.maxFiles){let z=(await e1(this.config.logDirectory)).filter((Q)=>Q.startsWith(this.name)).sort((Q,G)=>G.localeCompare(Q));for(let Q of z.slice(J.maxFiles))await $$(F1(this.config.logDirectory,Q))}}}async compressLogFile($,J){let Z=n9($),X=uQ(J),Y=ZZ();await lQ(Z,Y,X)}async handleFingersCrossedBuffer($,J){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed($)&&!this.isActivated){this.isActivated=!0;for(let Z of this.logBuffer){let X=await this.formatter.format(Z);if(this.shouldWriteToFile())await this.writeToFile(X);console.log(X)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(J);console.log(J)}}shouldLog($){if(!this.enabled)return!1;let J={debug:0,info:1,success:2,warning:3,error:4};return J[$]>=J[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map(($)=>{if($ instanceof Promise)return $.catch((J)=>{console.error("Error in pending write operation:",J)});return Promise.resolve()})),t1(this.currentLogFile))try{let $=t9(this.currentLogFile,"r+");i9($),Q7($)}catch($){console.error(`Error flushing file: ${$}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let $ of this.pendingOperations)if(typeof $.cancel==="function")$.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch($){console.error("Error waiting for pending operations:",$)}if(!w0()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let J=(await e1(this.config.logDirectory)).filter((Z)=>(Z.includes("temp")||Z.includes(".tmp"))&&Z.includes(this.name));for(let Z of J)try{await $$(F1(this.config.logDirectory,Z))}catch(X){console.error(`Failed to delete temp file ${Z}:`,X)}}catch($){console.error("Error cleaning up temporary files:",$)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag($){if(!$)return"";return`${this.tagFormat.prefix}${$}${this.tagFormat.suffix}`}formatFileTimestamp($){return`[${$.toISOString()}]`}formatConsoleTimestamp($){return this.shouldStyleConsole()?Q0.gray($.toLocaleTimeString()):$.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||w0())return!1;let $=typeof Y0.env.NO_COLOR<"u",J=Y0.env.FORCE_COLOR==="0";if($||J)return!1;return!!(typeof Y0.stderr<"u"&&Y0.stderr.isTTY||typeof Y0.stdout<"u"&&Y0.stdout.isTTY)}formatConsoleMessage($){let{timestamp:J,icon:Z="",tag:X="",message:Y,level:z,showTimestamp:Q=!0}=$,G=(V)=>V.replace(this.ANSI_PATTERN,"");if(!this.fancy){let V=[];if(Q)V.push(J);if(z==="warning")V.push("WARN");else if(z==="error")V.push("ERROR");else if(Z)V.push(Z.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(X)V.push(X.replace(/[[\]]/g,""));return V.push(Y),V.join(" ")}let q=Y0.stdout.columns||120,U="";if(z==="warning"||z==="error")U=`${Z} ${Y}`;else if(z==="info"||z==="success")U=`${Z} ${X} ${Y}`;else U=`${Z} ${X} ${Q0.cyan(Y)}`;if(!Q)return U.trim();let W=G(U).trim().length,K=G(J).length,H=Math.max(1,q-2-W-K);return`${U.trim()}${" ".repeat(H)}${J}`}formatMessage($,J){if(J.length===1&&Array.isArray(J[0]))return $.replace(/\{(\d+)\}/g,(z,Q)=>{let G=Number.parseInt(Q,10);return G<J[0].length?String(J[0][G]):z});let Z=/%([sdijfo%])/g,X=0,Y=$.replace(Z,(z,Q)=>{if(Q==="%")return"%";if(X>=J.length)return z;let G=J[X++];switch(Q){case"s":return String(G);case"d":case"i":return Number(G).toString();case"j":case"o":return JSON.stringify(G,null,2);default:return z}});if(X<J.length)Y+=` ${J.slice(X).map((z)=>typeof z==="object"?JSON.stringify(z,null,2):String(z)).join(" ")}`;return Y}formatMarkdown($){if(!$)return $;let J=$;return J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(Z,X,Y)=>{let z=Q0.underline(Q0.blue(X)),Q=this.toAbsoluteFilePath(Y);if(Q&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let G=`file://${encodeURI(Q)}`,q="\x1B]8;;",U="\x1B\\";return`\x1B]8;;${G}\x1B\\${z}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${Y}\x1B\\${z}\x1B]8;;\x1B\\`;return z}),J=J.replace(/`([^`]+)`/g,(Z,X)=>Q0.bgGray(X)),J=J.replace(/\*\*([^*]+)\*\*/g,(Z,X)=>Q0.bold(X)),J=J.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(Z,X)=>Q0.italic(X)),J=J.replace(/(?<!_)_([^_]+)_(?!_)/g,(Z,X)=>Q0.italic(X)),J=J.replace(/~([^~]+)~/g,(Z,X)=>Q0.strikethrough(X)),J}supportsHyperlinks(){if(w0())return!1;let $=Y0.env;if(!$)return!1;if($.TERM_PROGRAM==="iTerm.app"||$.TERM_PROGRAM==="vscode"||$.TERM_PROGRAM==="WezTerm")return!0;if($.WT_SESSION)return!0;if($.TERM==="xterm-kitty")return!0;let J=$.VTE_VERSION?Number.parseInt($.VTE_VERSION,10):0;if(!Number.isNaN(J)&&J>=5000)return!0;return!1}toAbsoluteFilePath($){try{let J=$;if(J.startsWith("file://"))J=J.replace(/^file:\/\//,"");if(J.startsWith("~")){let Z=Y0.env.HOME||"";if(Z)J=J.replace(/^~(?=$|\/)/,Z)}if(cQ(J)||J.startsWith("./")||J.startsWith("../"))J=rQ(J);else return null;return t1(J)?J:null}catch{return null}}buildOutputTexts($){let J=this.shouldStyleConsole()?this.formatMarkdown($):$,Z=$.replace(this.ANSI_PATTERN,"");return{consoleText:J,fileText:Z}}async log($,J,...Z){if(!this.shouldLog($))return;let X=new Date,Y=this.formatConsoleTimestamp(X),z=this.formatFileTimestamp(X),Q,G;if(J instanceof Error)Q=J.message,G=J.stack;else Q=this.formatMessage(J,Z);let{consoleText:q,fileText:U}=this.buildOutputTexts(Q);if(this.shouldStyleConsole()){let K=this.options.showIcons===!1?"":eQ[$],H=this.options.showTags!==!1&&this.name?Q0.gray(this.formatTag(this.name)):"",V;switch($){case"debug":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:Q0.gray(q),level:$}),console.error(V);break;case"info":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.warn(V);break;case"success":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:Q0.green(q),level:$}),console.error(V);break;case"warning":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.warn(V);break;case"error":if(V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.error(V),G){let A=G.split(`
41
41
  `);for(let _ of A)if(_.trim()&&!_.includes(Q))console.error(this.formatConsoleMessage({timestamp:Y,message:Q0.gray(` ${_}`),level:$,showTimestamp:!1}))}break}}else if(!w0()){if(console.error(`${z} ${this.environment}.${$.toUpperCase()}: ${Q}`),G)console.error(G)}let W=`${z} ${this.environment}.${$.toUpperCase()}: ${U}
42
42
  `;if(G)W+=`${G}
43
43
  `;if(W=W.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(W)}progress($,J=""){let Z={update:(G,q)=>{},finish:(G)=>{},interrupt:(G,q)=>{}};if(!this.enabled)return Z;let X=30;if(this.activeProgressBar={total:Math.max(1,$||1),current:0,message:J||"",barLength:X,lastRenderedLine:""},this.shouldStyleConsole()&&!w0()&&Y0.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(G,q)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,G),this.activeProgressBar.total),q!==void 0)this.activeProgressBar.message=q;if(this.shouldStyleConsole()&&!w0()&&Y0.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(G)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,G)},interrupt:(G,q="info")=>{if(!w0()&&Y0.stdout.isTTY)Y0.stdout.write(`
44
44
  `);if(this[q==="warning"?"warn":q](G),this.activeProgressBar&&this.shouldStyleConsole()&&!w0()&&Y0.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time($){let J=performance.now();if(this.shouldStyleConsole()){let Z=this.options.showTags!==!1&&this.name?Q0.gray(this.formatTag(this.name)):"",X=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:X,icon:this.options.showIcons===!1?"":Q0.blue("\u25D0"),tag:Z,message:`${Q0.cyan($)}...`}))}return async(Z)=>{if(!this.enabled)return;let X=performance.now(),Y=Math.round(X-J),z=`${$} completed in ${Y}ms`,Q=new Date,G=this.formatConsoleTimestamp(Q),U=`${this.formatFileTimestamp(Q)} ${this.environment}.INFO: ${z}`;if(Z)U+=` ${JSON.stringify(Z)}`;if(U+=`
45
- `,U=U.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let W=this.options.showTags!==!1&&this.name?Q0.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:G,icon:this.options.showIcons===!1?"":Q0.green("\u2713"),tag:W,message:`${z}${Z?` ${JSON.stringify(Z)}`:""}`}))}else if(!w0())console.error(U.trim());if(this.shouldWriteToFile())await this.writeToFile(U)}}async debug($,...J){await this.log("debug",$,...J)}async info($,...J){await this.log("info",$,...J)}async success($,...J){await this.log("success",$,...J)}async warn($,...J){await this.log("warning",$,...J)}async error($,...J){await this.log("error",$,...J)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let $=this.config.rotation,{encrypt:J}=$;return!!J}async only($){if(!this.enabled)return;return await $()}isEnabled(){return this.enabled}setEnabled($){this.enabled=$}extend($){let J=`${this.name}:${$}`,Z=new J1(J,{...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(Z),Z}createReadStream(){if(w0())throw Error("createReadStream is not supported in browser environments");if(!t1(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return s9(this.currentLogFile,{encoding:"utf8"})}async decrypt($){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let J=this.config.rotation;if(!J.encrypt||typeof J.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let Z=this.keys.get(this.currentKeyId);try{let X=m0.isBuffer($)?$:m0.from($,"base64"),Y=X.subarray(0,16),z=X.subarray(X.length-16),Q=X.subarray(16,X.length-16),G=gQ("aes-256-gcm",Z,Y);G.setAuthTag(z);let q=G.update(Q),U=G.final(),W=q.length+U.length,K=m0.allocUnsafe(W);return q.copy(K,0),U.copy(K,q.length),K.toString("utf8")}catch(X){throw Error(`Decryption failed: ${X instanceof Error?X.message:String(X)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return w0()}isServerMode(){return!w0()}setTestEncryptionKey($,J){this.currentKeyId=$,this.keys.set($,J)}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($){if(!this.enabled)return;let J=new Date,Z=this.formatConsoleTimestamp(J),X=this.formatFileTimestamp(J),{consoleText:Y,fileText:z}=this.buildOutputTexts($);if(this.shouldStyleConsole()){let G=Y.split(`
45
+ `,U=U.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let W=this.options.showTags!==!1&&this.name?Q0.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:G,icon:this.options.showIcons===!1?"":Q0.green("\u2713"),tag:W,message:`${z}${Z?` ${JSON.stringify(Z)}`:""}`}))}else if(!w0())console.error(U.trim());if(this.shouldWriteToFile())await this.writeToFile(U)}}async debug($,...J){await this.log("debug",$,...J)}async info($,...J){await this.log("info",$,...J)}async success($,...J){await this.log("success",$,...J)}async warn($,...J){await this.log("warning",$,...J)}async error($,...J){await this.log("error",$,...J)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let $=this.config.rotation,{encrypt:J}=$;return!!J}async only($){if(!this.enabled)return;return await $()}isEnabled(){return this.enabled}setEnabled($){this.enabled=$}extend($){let J=`${this.name}:${$}`,Z=new J1(J,{...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(Z),Z}createReadStream(){if(w0())throw Error("createReadStream is not supported in browser environments");if(!t1(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return n9(this.currentLogFile,{encoding:"utf8"})}async decrypt($){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let J=this.config.rotation;if(!J.encrypt||typeof J.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let Z=this.keys.get(this.currentKeyId);try{let X=m0.isBuffer($)?$:m0.from($,"base64"),Y=X.subarray(0,16),z=X.subarray(X.length-16),Q=X.subarray(16,X.length-16),G=hQ("aes-256-gcm",Z,Y);G.setAuthTag(z);let q=G.update(Q),U=G.final(),W=q.length+U.length,K=m0.allocUnsafe(W);return q.copy(K,0),U.copy(K,q.length),K.toString("utf8")}catch(X){throw Error(`Decryption failed: ${X instanceof Error?X.message:String(X)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return w0()}isServerMode(){return!w0()}setTestEncryptionKey($,J){this.currentKeyId=$,this.keys.set($,J)}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($){if(!this.enabled)return;let J=new Date,Z=this.formatConsoleTimestamp(J),X=this.formatFileTimestamp(J),{consoleText:Y,fileText:z}=this.buildOutputTexts($);if(this.shouldStyleConsole()){let G=Y.split(`
46
46
  `),q=Math.max(...G.map((H)=>H.length))+2,U=`\u250C${"\u2500".repeat(q)}\u2510`,W=`\u2514${"\u2500".repeat(q)}\u2518`,K=G.map((H)=>{return this.formatConsoleMessage({timestamp:Z,message:Q0.cyan(H),showTimestamp:!1})});console.error(this.formatConsoleMessage({timestamp:Z,message:Q0.cyan(U),showTimestamp:!1})),K.forEach((H)=>console.error(H)),console.error(this.formatConsoleMessage({timestamp:Z,message:Q0.cyan(W),showTimestamp:!1}))}else if(!w0())console.error(`${X} ${this.environment}.INFO: [BOX] ${z}`);let Q=`${X} ${this.environment}.INFO: [BOX] ${z}
47
47
  `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(Q)}async prompt($){if(w0())return Promise.resolve(!0);return new Promise((J)=>{console.error(`${Q0.cyan("?")} ${$} (y/n) `);let Z=(X)=>{let Y=X.toString().trim().toLowerCase();Y0.stdin.removeListener("data",Z);try{if(typeof Y0.stdin.setRawMode==="function")Y0.stdin.setRawMode(!1)}catch{}Y0.stdin.pause(),console.error(""),J(Y==="y"||Y==="yes")};try{if(typeof Y0.stdin.setRawMode==="function")Y0.stdin.setRawMode(!0)}catch{}Y0.stdin.resume(),Y0.stdin.once("data",Z)})}setFancy($){this.fancy=$}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start($,...J){if(!this.enabled)return;let Z=$;if(J&&J.length>0){let q=/%([sdijfo%])/g,U=0;if(Z=$.replace(q,(W,K)=>{if(K==="%")return"%";if(U>=J.length)return W;let H=J[U++];switch(K){case"s":return String(H);case"d":case"i":return Number(H).toString();case"j":case"o":return JSON.stringify(H,null,2);default:return W}}),U<J.length)Z+=` ${J.slice(U).map((W)=>typeof W==="object"?JSON.stringify(W,null,2):String(W)).join(" ")}`}let{consoleText:X,fileText:Y}=this.buildOutputTexts(Z);if(this.shouldStyleConsole()){let q=this.options.showTags!==!1&&this.name?Q0.gray(this.formatTag(this.name)):"",U=this.options.showIcons===!1?"":`${Q0.blue("\u25D0")} `;console.error(`${U}${q} ${Q0.cyan(X)}`)}let G=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${Y}
48
48
  `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(G)}renderProgressBar($,J=!1){if(!this.enabled||!this.shouldStyleConsole()||!Y0.stdout.isTTY)return;let Z=Math.min(100,Math.max(0,Math.round($.current/$.total*100))),X=Math.round($.barLength*Z/100),Y=$.barLength-X,z=Q0.green("\u2501".repeat(X)),Q=Q0.gray("\u2501".repeat(Y)),G=`[${z}${Q}]`,q=`${Z}%`.padStart(4),U=$.message?` ${$.message}`:"",W=this.options.showIcons===!1?"":J||Z===100?Q0.green("\u2713"):Q0.blue("\u25B6"),K=this.options.showTags!==!1&&this.name?` ${Q0.gray(this.formatTag(this.name))}`:"",H=`\r${W}${K} ${G} ${q}${U}`,V=Y0.stdout.columns||80,A=" ".repeat(Math.max(0,V-H.replace(this.ANSI_PATTERN,"").length));if($.lastRenderedLine=`${H}${A}`,Y0.stdout.write($.lastRenderedLine),J)Y0.stdout.write(`
49
- `)}finishProgressBar($,J){if(!this.enabled||!this.fancy||w0()||!Y0.stdout.isTTY){this.activeProgressBar=null;return}if($.current<$.total)$.current=$.total;if(J)$.message=J;this.renderProgressBar($,!0),this.activeProgressBar=null}async clear($={}){if(w0()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let J=await e1(this.config.logDirectory),Z=[];for(let X of J){if(!($.name?new RegExp($.name.replace("*",".*")).test(X):X.startsWith(this.name))||!X.endsWith(".log"))continue;let z=A1(this.config.logDirectory,X);if($.before)try{if((await V1(z)).mtime>=$.before)continue}catch(Q){console.error(`Failed to get stats for file ${z}:`,Q);continue}Z.push(z)}if(Z.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${Z.length} log file(s)...`);for(let X of Z)try{await $$(X),console.warn(`Deleted log file: ${X}`)}catch(Y){console.error(`Failed to delete log file ${X}:`,Y)}console.warn("Log clearing process finished.")}catch(J){console.error("Error during log clearing process:",J)}}}var LU=new J1("stacks");import{readFileSync as fY,writeFileSync as lG}from"fs";import{isAbsolute as aG,relative as bY,resolve as sG}from"path";var M$={meta:{docs:"Enforce return statements in callbacks of array methods",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=new RegExp(`\\.(${["map","filter","find","findIndex","findLast","findLastIndex","every","some","reduce","reduceRight","sort","flatMap"].join("|")})\\s*\\(`,"g");for(let Q=0;Q<X.length;Q++){let G=X[Q],q;for(q=z.exec(G);q!==null;q=z.exec(G)){let U=q[1],W=q.index+q[0].length,K=G.slice(W),H=K.match(/^\s*(?:\(([^)]*)\)|([a-z_$][\w$]*))\s*=>/i),V=K.match(/^\s*function\s*(?:[a-zA-Z_$][\w$]*\s*)?\(/);if(H){let A=K.slice(H[0].length).trim();if(A.startsWith("{")){let _=!1,B=0,F=A,M=Q;while(M<X.length){let N=M===Q?F:X[M];for(let E=0;E<N.length;E++){let j=N[E];if(j==="{")B++;if(j==="}"){if(B--,B===0){if(!_)Z.push({filePath:J.filePath,line:Q+1,column:q.index+1,ruleId:"eslint/array-callback-return",message:`Array method '${U}' callback should return a value`,severity:"error"});break}}}if(N.match(new RegExp("\\breturn\\s+[^;]")))_=!0;if(B===0)break;M++,F=X[M]||""}}}else if(V){let A=!1,_=0,B=Q,F=!1;while(B<X.length){let M=X[B];for(let N=0;N<M.length;N++){let E=M[N];if(E==="{")_++,F=!0;else if(E==="}"){if(_--,_===0&&F){if(!A)Z.push({filePath:J.filePath,line:Q+1,column:q.index+1,ruleId:"eslint/array-callback-return",message:`Array method '${U}' callback should return a value`,severity:"error"});break}}}if(F&&M.match(new RegExp("\\breturn\\s+[^;]")))A=!0;if(_===0&&F)break;B++}}}}return Z}};var j$={meta:{docs:"Require super() calls in constructors of derived classes",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1,Q=0,G=0,q=!1;for(let U=0;U<X.length;U++){let W=X[U];if(W.match(/\bclass\s+\w+\s+extends\s+\w+/))Y=!0;if(Y&&W.match(/\bconstructor\s*\(/))z=!0,Q=U+1,G=0,q=!1;if(z){for(let K of W){if(K==="{")G++;if(K==="}")G--}if(W.match(/\bsuper\s*\(/))q=!0;if(G===0&&W.includes("}")){if(!q)Z.push({filePath:J.filePath,line:Q,column:1,ruleId:"eslint/constructor-super",message:"Constructors of derived classes must call super()",severity:"error"});z=!1,Y=!1}}}return Z}};var N$={meta:{docs:'Enforce "for" loop update clause moving counter in the right direction',recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=new RegExp("\\bfor\\s*\\(\\s*(?:(?:let|var|const)\\s*)?(\\w+)\\s*=[^;]+;\\s*(\\w+)\\s*([<>]=?)[^;]+;\\s*(\\w+)(\\+\\+|--|[\\s+-]=)"),G=z.match(Q);if(G){let q=G[1],U=G[2],W=G[3],K=G[4],H=G[5];if(q===U&&U===K){let V=H.includes("+"),A=W.includes("<");if(A&&!V||!A&&V)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"eslint/for-direction",message:"The update clause in this loop moves the variable in the wrong direction",severity:"error"})}}}return Z}};var T$={meta:{docs:"Enforce return statements in getters",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let Q=X[Y].match(/\bget\s+(\w+)\s*\(/);if(Q){let G=Q[1],q=!1,U=0,W=Y;while(W<X.length){let K=X[W];for(let V of K){if(V==="{")U++;if(V==="}"){if(U--,U===0){if(!q)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"eslint/getter-return",message:`Getter '${G}' must return a value`,severity:"error"});break}}}let H=new RegExp("\\breturn\\s+[^;]");if(K.match(H))q=!0;if(U===0)break;W++}}}return Z}};var E$={meta:{docs:"Disallow async functions as Promise executor",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/new\s+Promise\s*\(\s*async\s*(?:\(|function)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"eslint/no-async-promise-executor",message:"Promise executor functions should not be async",severity:"error"})}return Z}};var D$={meta:{docs:"Disallow comparing against -0",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/([!=]==?)\s*-0\b|\b-0\s*([!=]==?)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"eslint/no-compare-neg-zero",message:"Do not use the '-0' literal in comparisons",severity:"error"})}return Z}};var R$={meta:{docs:"Disallow assignment operators in conditional expressions",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b(if|while)\s*\([^)]*\b(\w+)\s*=\s*(?!=)[^)]*\)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[0];if(/===|==/.test(q))continue;if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-cond-assign",message:"Expected a conditional expression and instead saw an assignment",severity:"error"})}}return Z}};var O$={meta:{docs:"Disallow reassigning const variables",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map;for(let z=0;z<X.length;z++){let Q=X[z],G=Q.match(/\bconst\s+(\w+)/);if(G)Y.set(G[1],z);let q=/\b(\w+)\s*=(?!=)/g,U;for(U=q.exec(Q);U!==null;U=q.exec(Q)){let W=U[1],K=Q.substring(0,U.index);if(!/\b(?:const|let|var)\s*$/.test(K)&&Y.has(W))Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,U.index+1),ruleId:"eslint/no-const-assign",message:`'${W}' is constant`,severity:"error"})}}return Z}};var L$={meta:{docs:"Disallow constant expressions in conditions",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[{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:G,type:q}of Q){let U;while((U=G.exec(z))!==null){let W=U[1];if(z.substring(0,U.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,U.index+W.length+2),ruleId:"eslint/no-constant-condition",message:"Unexpected constant condition",severity:"error"})}}}return Z}};var P$={meta:{docs:"Disallow duplicate class members",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=new Set,Q=0;for(let G=0;G<X.length;G++){let q=X[G];if(q.match(/\bclass\s+\w+/))Y=!0,z=new Set,Q=0;if(Y){for(let W of q){if(W==="{")Q++;if(W==="}"){if(Q--,Q===0)Y=!1}}let U=[...q.matchAll(/^\s*(?:(?:public|private|protected|static|readonly|async)\s*)?(?:get|set)?\s*(\w+)\s*\(/g),...q.matchAll(/^\s*(?:(?:public|private|protected|static|readonly)\s*)?(\w+)\s*[:=]/g)];for(let W of U){let K=W[1];if(z.has(K))Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"eslint/no-dupe-class-members",message:`Duplicate class member '${K}'`,severity:"error"});else z.add(K)}}}return Z}};var y1={meta:{docs:"Disallow duplicate keys in object literals",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=/\{\s*$/,z=/^\s*(?:(['"`])(.+?)\1|(\w+))\s*:/;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(!Y.test(G)&&!G.includes("{"))continue;let q=new Map,U=(G.match(/\{/g)||[]).length-(G.match(/\}/g)||[]).length,W=Q;for(let K=Q+1;K<X.length&&U>0;K++){let H=X[K];U+=(H.match(/\{/g)||[]).length,U-=(H.match(/\}/g)||[]).length;let V=H.match(z);if(V){let A=V[2]||V[3];if(A)if(q.get(A)!==void 0)Z.push({filePath:J.filePath,line:K+1,column:Math.max(1,H.search(/\S/)+1),ruleId:"eslint/no-dupe-keys",message:`Duplicate key '${A}'`,severity:"error"});else q.set(A,K)}if(U===0)break}}return Z},fix:($,J)=>{let Z=y1.check($,J);if(Z.length===0)return $;let X=$.split(/\r?\n/),Y=new Set(Z.map((Q)=>Q.line-1));return X.filter((Q,G)=>!Y.has(G)).join(`
49
+ `)}finishProgressBar($,J){if(!this.enabled||!this.fancy||w0()||!Y0.stdout.isTTY){this.activeProgressBar=null;return}if($.current<$.total)$.current=$.total;if(J)$.message=J;this.renderProgressBar($,!0),this.activeProgressBar=null}async clear($={}){if(w0()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let J=await e1(this.config.logDirectory),Z=[];for(let X of J){if(!($.name?new RegExp($.name.replace("*",".*")).test(X):X.startsWith(this.name))||!X.endsWith(".log"))continue;let z=F1(this.config.logDirectory,X);if($.before)try{if((await _1(z)).mtime>=$.before)continue}catch(Q){console.error(`Failed to get stats for file ${z}:`,Q);continue}Z.push(z)}if(Z.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${Z.length} log file(s)...`);for(let X of Z)try{await $$(X),console.warn(`Deleted log file: ${X}`)}catch(Y){console.error(`Failed to delete log file ${X}:`,Y)}console.warn("Log clearing process finished.")}catch(J){console.error("Error during log clearing process:",J)}}}var CU=new J1("stacks");import{readFileSync as gY,writeFileSync as nG}from"fs";import{isAbsolute as iG,relative as kY,resolve as tG}from"path";var M$={meta:{docs:"Enforce return statements in callbacks of array methods",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=new RegExp(`\\.(${["map","filter","find","findIndex","findLast","findLastIndex","every","some","reduce","reduceRight","sort","flatMap"].join("|")})\\s*\\(`,"g");for(let Q=0;Q<X.length;Q++){let G=X[Q],q;for(q=z.exec(G);q!==null;q=z.exec(G)){let U=q[1],W=q.index+q[0].length,K=G.slice(W),H=K.match(/^\s*(?:\(([^)]*)\)|([a-z_$][\w$]*))\s*=>/i),V=K.match(/^\s*function\s*(?:[a-zA-Z_$][\w$]*\s*)?\(/);if(H){let A=K.slice(H[0].length).trim();if(A.startsWith("{")){let _=!1,B=0,F=A,M=Q;while(M<X.length){let T=M===Q?F:X[M];for(let E=0;E<T.length;E++){let j=T[E];if(j==="{")B++;if(j==="}"){if(B--,B===0){if(!_)Z.push({filePath:J.filePath,line:Q+1,column:q.index+1,ruleId:"eslint/array-callback-return",message:`Array method '${U}' callback should return a value`,severity:"error"});break}}}if(T.match(new RegExp("\\breturn\\s+[^;]")))_=!0;if(B===0)break;M++,F=X[M]||""}}}else if(V){let A=!1,_=0,B=Q,F=!1;while(B<X.length){let M=X[B];for(let T=0;T<M.length;T++){let E=M[T];if(E==="{")_++,F=!0;else if(E==="}"){if(_--,_===0&&F){if(!A)Z.push({filePath:J.filePath,line:Q+1,column:q.index+1,ruleId:"eslint/array-callback-return",message:`Array method '${U}' callback should return a value`,severity:"error"});break}}}if(F&&M.match(new RegExp("\\breturn\\s+[^;]")))A=!0;if(_===0&&F)break;B++}}}}return Z}};var j$={meta:{docs:"Require super() calls in constructors of derived classes",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1,Q=0,G=0,q=!1;for(let U=0;U<X.length;U++){let W=X[U];if(W.match(/\bclass\s+\w+\s+extends\s+\w+/))Y=!0;if(Y&&W.match(/\bconstructor\s*\(/))z=!0,Q=U+1,G=0,q=!1;if(z){for(let K of W){if(K==="{")G++;if(K==="}")G--}if(W.match(/\bsuper\s*\(/))q=!0;if(G===0&&W.includes("}")){if(!q)Z.push({filePath:J.filePath,line:Q,column:1,ruleId:"eslint/constructor-super",message:"Constructors of derived classes must call super()",severity:"error"});z=!1,Y=!1}}}return Z}};var N$={meta:{docs:'Enforce "for" loop update clause moving counter in the right direction',recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=new RegExp("\\bfor\\s*\\(\\s*(?:(?:let|var|const)\\s*)?(\\w+)\\s*=[^;]+;\\s*(\\w+)\\s*([<>]=?)[^;]+;\\s*(\\w+)(\\+\\+|--|[\\s+-]=)"),G=z.match(Q);if(G){let q=G[1],U=G[2],W=G[3],K=G[4],H=G[5];if(q===U&&U===K){let V=H.includes("+"),A=W.includes("<");if(A&&!V||!A&&V)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"eslint/for-direction",message:"The update clause in this loop moves the variable in the wrong direction",severity:"error"})}}}return Z}};var T$={meta:{docs:"Enforce return statements in getters",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let Q=X[Y].match(/\bget\s+(\w+)\s*\(/);if(Q){let G=Q[1],q=!1,U=0,W=Y;while(W<X.length){let K=X[W];for(let V of K){if(V==="{")U++;if(V==="}"){if(U--,U===0){if(!q)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"eslint/getter-return",message:`Getter '${G}' must return a value`,severity:"error"});break}}}let H=new RegExp("\\breturn\\s+[^;]");if(K.match(H))q=!0;if(U===0)break;W++}}}return Z}};var E$={meta:{docs:"Disallow async functions as Promise executor",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/new\s+Promise\s*\(\s*async\s*(?:\(|function)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"eslint/no-async-promise-executor",message:"Promise executor functions should not be async",severity:"error"})}return Z}};var D$={meta:{docs:"Disallow comparing against -0",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/([!=]==?)\s*-0\b|\b-0\s*([!=]==?)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"eslint/no-compare-neg-zero",message:"Do not use the '-0' literal in comparisons",severity:"error"})}return Z}};var R$={meta:{docs:"Disallow assignment operators in conditional expressions",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b(if|while)\s*\([^)]*\b(\w+)\s*=\s*(?!=)[^)]*\)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[0];if(/===|==/.test(q))continue;if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-cond-assign",message:"Expected a conditional expression and instead saw an assignment",severity:"error"})}}return Z}};var O$={meta:{docs:"Disallow reassigning const variables",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map;for(let z=0;z<X.length;z++){let Q=X[z],G=Q.match(/\bconst\s+(\w+)/);if(G)Y.set(G[1],z);let q=/\b(\w+)\s*=(?!=)/g,U;for(U=q.exec(Q);U!==null;U=q.exec(Q)){let W=U[1],K=Q.substring(0,U.index);if(!/\b(?:const|let|var)\s*$/.test(K)&&Y.has(W))Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,U.index+1),ruleId:"eslint/no-const-assign",message:`'${W}' is constant`,severity:"error"})}}return Z}};var L$={meta:{docs:"Disallow constant expressions in conditions",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[{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:G,type:q}of Q){let U;while((U=G.exec(z))!==null){let W=U[1];if(z.substring(0,U.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,U.index+W.length+2),ruleId:"eslint/no-constant-condition",message:"Unexpected constant condition",severity:"error"})}}}return Z}};var P$={meta:{docs:"Disallow duplicate class members",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=new Set,Q=0;for(let G=0;G<X.length;G++){let q=X[G];if(q.match(/\bclass\s+\w+/))Y=!0,z=new Set,Q=0;if(Y){for(let W of q){if(W==="{")Q++;if(W==="}"){if(Q--,Q===0)Y=!1}}let U=[...q.matchAll(/^\s*(?:(?:public|private|protected|static|readonly|async)\s*)?(?:get|set)?\s*(\w+)\s*\(/g),...q.matchAll(/^\s*(?:(?:public|private|protected|static|readonly)\s*)?(\w+)\s*[:=]/g)];for(let W of U){let K=W[1];if(z.has(K))Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"eslint/no-dupe-class-members",message:`Duplicate class member '${K}'`,severity:"error"});else z.add(K)}}}return Z}};var y1={meta:{docs:"Disallow duplicate keys in object literals",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=/\{\s*$/,z=/^\s*(?:(['"`])(.+?)\1|(\w+))\s*:/;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(!Y.test(G)&&!G.includes("{"))continue;let q=new Map,U=(G.match(/\{/g)||[]).length-(G.match(/\}/g)||[]).length,W=Q;for(let K=Q+1;K<X.length&&U>0;K++){let H=X[K];U+=(H.match(/\{/g)||[]).length,U-=(H.match(/\}/g)||[]).length;let V=H.match(z);if(V){let A=V[2]||V[3];if(A)if(q.get(A)!==void 0)Z.push({filePath:J.filePath,line:K+1,column:Math.max(1,H.search(/\S/)+1),ruleId:"eslint/no-dupe-keys",message:`Duplicate key '${A}'`,severity:"error"});else q.set(A,K)}if(U===0)break}}return Z},fix:($,J)=>{let Z=y1.check($,J);if(Z.length===0)return $;let X=$.split(/\r?\n/),Y=new Set(Z.map((Q)=>Q.line-1));return X.filter((Q,G)=>!Y.has(G)).join(`
50
50
  `)}};var C$={meta:{docs:"Disallow duplicate case labels in switch statements",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=new Set,Q=-1;for(let G=0;G<X.length;G++){let q=X[G],U=q.trim();if(/\bswitch\s*\(/.test(U)){Y=!0,z=new Set,Q=G;continue}if(Y&&U==="}"&&G>Q){let W=X[Q].match(/^\s*/)?.[0].length||0;if((q.match(/^\s*/)?.[0].length||0)<=W+2)Y=!1,z=new Set}if(Y){let W=U.match(/^case\s+(.+?)\s*:/);if(W){let K=W[1].trim();if(z.has(K))Z.push({filePath:J.filePath,line:G+1,column:Math.max(1,q.indexOf("case")+1),ruleId:"eslint/no-duplicate-case",message:`Duplicate case label '${K}'`,severity:"error"});else z.add(K)}}}return Z}};var I$={meta:{docs:"Disallow empty destructuring patterns",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\{\s*\}\s*=/g,G=/\[\s*\]\s*=/g,q;for(q=Q.exec(z);q!==null;q=Q.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-empty-pattern",message:"Unexpected empty object pattern",severity:"error"})}for(q=G.exec(z);q!==null;q=G.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-empty-pattern",message:"Unexpected empty array pattern",severity:"error"})}}return Z}};var S$={meta:{docs:"Disallow fallthrough of case statements",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=-1,Q=!1;for(let G=0;G<X.length;G++){let U=X[G].trim();if(/\bswitch\s*\(/.test(U)){Y=!0;continue}if(Y){if(/^case\s+/.test(U)||/^default\s*:/.test(U)){if(z>=0&&Q){if(!(/\/\/.*falls?\s*through|\/\*.*falls?\s*through/i.test(X[z])||G>0&&/\/\/.*falls?\s*through|\/\*.*falls?\s*through/i.test(X[G-1])))Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,X[z].indexOf("case")+1),ruleId:"eslint/no-fallthrough",message:"Expected a 'break' statement before 'case'",severity:"error"})}z=G,Q=!0}if(/\b(?:break|return|throw|continue)\b/.test(U))Q=!1;if(U==="}")Y=!1,z=-1,Q=!1}}return Z}};var v$={meta:{docs:"Disallow number literals that lose precision",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b(\d{17,}(?:\.\d+)?|\d+\.\d{17,})\b/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[1];if(Number(q).toString()!==q)Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"eslint/no-loss-of-precision",message:"This number literal will lose precision at runtime",severity:"error"})}}return Z}};var y$={meta:{docs:"Disallow returning values from Promise executor functions",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++)if(X[Y].match(/new\s+Promise\s*\(/)){let G=0,q=!1,U=Y;while(U<X.length){let W=X[U];for(let H of W){if(H==="{")G++,q=!0;if(H==="}"){if(G--,G===0&&q)break}}let K=new RegExp("\\breturn\\s+[^;]");if(q&&W.match(K))Z.push({filePath:J.filePath,line:U+1,column:1,ruleId:"eslint/no-promise-executor-return",message:"Return values from promise executor functions cannot be read",severity:"error"});if(G===0&&q)break;U++}}return Z}};var b$={meta:{docs:"Disallow variable redeclaration",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map;for(let z=0;z<X.length;z++){let Q=X[z],G=/\b(var|let|const)\s+(\w+)/g,q;for(q=G.exec(Q);q!==null;q=G.exec(Q)){let W=q[2];if(Y.get(W)!==void 0)Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-redeclare",message:`'${W}' is already defined`,severity:"error"});else Y.set(W,z)}let U=/\bfunction\s+(\w+)/g;for(q=U.exec(Q);q!==null;q=U.exec(Q)){let W=q[1];if(Y.get(W)!==void 0)Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-redeclare",message:`'${W}' is already defined`,severity:"error"});else Y.set(W,z)}}return Z}};var b1={meta:{docs:"Disallow assignments where both sides are identical",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=new RegExp("\\b(\\w+)\\s*=\\s*(\\w+)\\s*(?:;\\s*)?(?:\\/\\/.*)?$"),G=z.match(Q);if(G&&G[1]===G[2]){Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf(G[1])+1),ruleId:"eslint/no-self-assign",message:`'${G[1]}' is assigned to itself`,severity:"error"});continue}let q=z.match(/([\w.]+)\s*=\s*([\w.]+)/);if(q&&q[1]===q[2]){Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf(q[1])+1),ruleId:"eslint/no-self-assign",message:`'${q[1]}' is assigned to itself`,severity:"error"});continue}let U=z.match(/(\w+\[[^\]]+\])\s*=\s*(\w+\[[^\]]+\])/);if(U){let W=U[1].replace(/\s/g,""),K=U[2].replace(/\s/g,"");if(W===K)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf(U[1])+1),ruleId:"eslint/no-self-assign",message:`'${U[1]}' is assigned to itself`,severity:"error"})}}return Z},fix:($,J)=>{let Z=b1.check($,J);if(Z.length===0)return $;let X=$.split(/\r?\n/),Y=new Set(Z.map((Q)=>Q.line-1));return X.map((Q,G)=>{if(Y.has(G)){let q=Q.trim();if(new RegExp("^\\w+(?:\\.\\w+|\\[[^\\]]+\\])?\\s*=\\s*\\w+(?:\\.\\w+|\\[[^\\]]+\\])?;?\\s*$").test(q))return""}return Q}).filter((Q,G,q)=>{if(Q===""&&Y.has(G)){let U=G>0&&q[G-1].trim()!=="",W=G<q.length-1&&q[G+1]&&q[G+1].trim()!=="";if(!U||!W)return!1}return!0}).join(`
51
51
  `)}};var k$={meta:{docs:"Disallow comparisons where both sides are identical",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/([\w.\[\]]+)\s*(===|!==|==|!=|<|>|<=|>=)\s*([\w.\[\]]+)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[1].replace(/\s/g,""),U=G[2],W=G[3].replace(/\s/g,"");if(q===W)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-self-compare",message:`Comparing '${G[1]}' to itself is potentially pointless`,severity:"error"})}}return Z}};var f$={meta:{docs:"Disallow sparse arrays (arrays with empty slots)",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\[([^\]]*)\]/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[1];if(/,\s*,/.test(q))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-sparse-arrays",message:"Unexpected sparse array",severity:"error"})}}return Z},fix:($,J)=>{let Z=$.split(/\r?\n/),X=!1,Y=Z.map((z)=>{let Q=z;return Q=Q.replace(/\[([^\]]*)\]/g,(G,q)=>{if(/,\s*,/.test(q))return X=!0,`[${q.replace(/,(\s*),/g,", undefined,")}]`;return G}),Q});return X?Y.join(`
52
52
  `):$}};var g$={meta:{docs:"Disallow undeclared variables",recommended:!0,wip:!0},check:($,J)=>{return[]}};var p$={meta:{docs:"Disallow unreachable code after return, throw, continue, or break",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(/^\s*(?:return|throw|break|continue)\b/.test(z))for(let G=Y+1;G<X.length;G++){let q=X[G],U=q.trim();if(U===""||U.startsWith("//")||U.startsWith("/*"))continue;if(U==="}"||U.startsWith("}"))break;if(/^(?:case\b|default\s*:)/.test(U))break;Z.push({filePath:J.filePath,line:G+1,column:Math.max(1,q.search(/\S/)+1),ruleId:"eslint/no-unreachable",message:"Unreachable code",severity:"error"});break}}return Z}};var x$={meta:{docs:"Disallow negation of the left operand of relational operators",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/!\s*\w+\s+in\s+/g,G=/!\s*\w+\s+instanceof\s+/g,q;for(q=Q.exec(z);q!==null;q=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:q.index+1,ruleId:"eslint/no-unsafe-negation",message:"Unexpected negation of 'in' operand",severity:"error"});for(q=G.exec(z);q!==null;q=G.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:q.index+1,ruleId:"eslint/no-unsafe-negation",message:"Unexpected negation of 'instanceof' operand",severity:"error"})}return Z},fix:($)=>{let J=$;return J=J.replace(/!\s*(\w+)\s+in\s+/g,"!($1 in "),J=J.replace(/!\s*(\w+)\s+instanceof\s+/g,"!($1 instanceof "),J}};var h$={meta:{docs:"Disallow unnecessary catch clauses",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.match(/catch\s*\(\s*(\w+)\s*\)/);if(!Q)continue;let G=Q[1];for(let q=Y+1;q<Math.min(Y+5,X.length);q++){let U=X[q].trim();if(U===`throw ${G}`||U===`throw ${G};`){let W=!1;for(let K=Y+1;K<q;K++){let H=X[K].trim();if(H!==""&&H!=="{"&&!H.startsWith("//")){W=!0;break}}if(!W)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf("catch")+1),ruleId:"eslint/no-useless-catch",message:"Unnecessary catch clause",severity:"error"});break}if(U==="}")break}}return Z}};var u$={meta:{docs:"Require isNaN() when checking for NaN",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b([\w.\[\]]+)\s*(===|!==|==|!=)\s*NaN\b|\bNaN\s*(===|!==|==|!=)\s*([\w.\[\]]+)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[1]||G[4];Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/use-isnan",message:"Use isNaN() to compare with NaN",severity:"error"})}}return Z},fix:($,J)=>{let Z=$.split(/\r?\n/),X=!1,Y=Z.map((z)=>{let Q=z;return Q=Q.replace(/\b([\w.\[\]]+)\s*===\s*NaN\b/g,(G,q)=>{return X=!0,`isNaN(${q})`}),Q=Q.replace(/\bNaN\s*===\s*([\w.\[\]]+)\b/g,(G,q)=>{return X=!0,`isNaN(${q})`}),Q=Q.replace(/\b([\w.\[\]]+)\s*!==\s*NaN\b/g,(G,q)=>{return X=!0,`!isNaN(${q})`}),Q=Q.replace(/\bNaN\s*!==\s*([\w.\[\]]+)\b/g,(G,q)=>{return X=!0,`!isNaN(${q})`}),Q=Q.replace(/\b([\w.\[\]]+)\s*==\s*NaN\b/g,(G,q)=>{return X=!0,`isNaN(${q})`}),Q=Q.replace(/\bNaN\s*==\s*([\w.\[\]]+)\b/g,(G,q)=>{return X=!0,`isNaN(${q})`}),Q=Q.replace(/\b([\w.\[\]]+)\s*!=\s*NaN\b/g,(G,q)=>{return X=!0,`!isNaN(${q})`}),Q=Q.replace(/\bNaN\s*!=\s*([\w.\[\]]+)\b/g,(G,q)=>{return X=!0,`!isNaN(${q})`}),Q});return X?Y.join(`
53
- `):$}};var DZ=["undefined","object","boolean","number","string","function","symbol","bigint"],m$={meta:{docs:"Enforce comparing typeof expressions against valid strings",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/typeof\s+\w+\s*(?:===|!==|==|!=)\s*(['"`])(\w+)\1/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let U=G[2];if(!DZ.includes(U))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/valid-typeof",message:`Invalid typeof comparison value '${U}'`,severity:"error"})}let q=/(['"`])(\w+)\1\s*(?:===|!==|==|!=)\s*typeof\s+\w+/g;for(G=q.exec(z);G!==null;G=q.exec(z)){let U=G[2];if(!DZ.includes(U))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/valid-typeof",message:`Invalid typeof comparison value '${U}'`,severity:"error"})}}return Z}};var d$={meta:{docs:"Enforce a maximum cyclomatic complexity allowed in a program",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=10,z=!1,Q=0,G="",q=0,U=0;for(let W=0;W<X.length;W++){let K=X[W],H=K.match(/\bfunction\s+(\w+)\s*\(|(\w+)\s*=\s*(?:\([^)]*\)|(\w+))\s*=>/);if(H)z=!0,Q=W+1,G=H[1]||H[2]||H[3]||"anonymous",q=1,U=0;if(z){for(let A of K){if(A==="{")U++;if(A==="}"){if(U--,U===0){if(q>10)Z.push({filePath:J.filePath,line:Q,column:1,ruleId:"eslint/complexity",message:`Function '${G}' has complexity ${q}, exceeds maximum of 10`,severity:"error"});z=!1}}}let V=[/\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 A of V){let _=K.match(new RegExp(A,"g"));if(_)q+=_.length}}}return Z}};var o$={meta:{docs:"Require default case in switch statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=0,Q=!1,G=0;for(let q=0;q<X.length;q++){let U=X[q];if(U.match(/\bswitch\s*\(/))Y=!0,z=q+1,Q=!1,G=0;if(Y){for(let W of U){if(W==="{")G++;if(W==="}"){if(G--,G===0){if(!Q)Z.push({filePath:J.filePath,line:z,column:1,ruleId:"eslint/default-case",message:"Expected a default case",severity:"error"});Y=!1}}}if(U.match(/\bdefault\s*:/))Q=!0}}return Z}};var c$={meta:{docs:"Require === and !== instead of == and !=",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/([^=!])(\s*)(==)(\s*)([^=])/g,G=/([^!])(\s*)(!=)(\s*)([^=])/g,q;for(q=Q.exec(z);q!==null;q=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+2),ruleId:"eslint/eqeqeq",message:"Expected '===' and instead saw '=='",severity:"error"});for(q=G.exec(z);q!==null;q=G.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+2),ruleId:"eslint/eqeqeq",message:"Expected '!==' and instead saw '!='",severity:"error"})}return Z},fix:($)=>{let J=$;return J=J.replace(/([^!])(\s*)(!=)(\s*)([^=])/g,"$1$2!==$4$5"),J=J.replace(/([^=!])(\s*)(==)(\s*)([^=])/g,"$1$2===$4$5"),J}};var r$={meta:{docs:"Enforce a maximum depth that blocks can be nested",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=4,z=0,Q=0,G=0;for(let q=0;q<X.length;q++){let U=X[q];if(U.match(/\b(if|for|while|switch|try|catch|else)\b.*\{/)){if(z++,z>Q)Q=z,G=q+1}else if(U.match(/\{/)&&!U.match(/^.*\}/)){if(X[q-1]?.match(/\b(if|for|while|switch|try|catch|else)\b/)){if(z++,z>Q)Q=z,G=q+1}}if(U.match(/^\s*\}/))z--;if(z>4)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"eslint/max-depth",message:`Blocks are nested too deeply (${z}), maximum allowed is 4`,severity:"error"})}return Z}};var l$={meta:{docs:"Enforce a maximum number of lines of code in a function",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=50,z=!1,Q=0,G="",q=0;for(let U=0;U<X.length;U++){let W=X[U],K=W.match(/\bfunction\s+(\w+)\s*\(|(\w+)\s*=\s*(?:\([^)]*\)|(\w+))\s*=>/);if(K)z=!0,Q=U+1,G=K[1]||K[2]||K[3]||"anonymous",q=0;if(z)for(let H of W){if(H==="{")q++;if(H==="}"){if(q--,q===0){let V=U+1-Q+1;if(V>50)Z.push({filePath:J.filePath,line:Q,column:1,ruleId:"eslint/max-lines-per-function",message:`Function '${G}' has ${V} lines, exceeds maximum of 50`,severity:"error"});z=!1}}}}return Z}};var a$={meta:{docs:"Disallow alert, confirm, and prompt",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b(alert|confirm|prompt)\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-alert",message:`Unexpected ${G[1]}`,severity:"warning"})}}return Z}};var s$={meta:{docs:"Disallow await inside of loops",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=0,Q=0;for(let G=0;G<X.length;G++){let q=X[G];if(q.match(/\b(for|while|do)\s*\(/))Y=!0,z=0,Q=G;if(Y){for(let U of q){if(U==="{")z++;if(U==="}"){if(z--,z===0)Y=!1}}if(q.match(/\bawait\s+/))Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"eslint/no-await-in-loop",message:"Unexpected await inside a loop. Consider using Promise.all() instead",severity:"error"})}}return Z}};var n$={meta:{docs:"Disallow use of arguments.caller or arguments.callee",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\barguments\s*\.\s*(caller|callee)\b/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"eslint/no-caller",message:`Avoid arguments.${G[1]}`,severity:"error"})}return Z}};var i$={meta:{docs:"Disallow lexical declarations in case clauses",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(G.match(/\bcase\s+(?:\S.*)?:|default\s*:/))Y=!0,z=!0;else z=!1;if(Y&&!z&&(G.match(/\bbreak\b/)||G.match(/\bcase\s+(?:\S.*)?:/)))Y=!1;if(Y&&!z){if(G.match(/\b(let|const|function|class)\s+/))Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"eslint/no-case-declarations",message:"Unexpected lexical declaration in case block",severity:"error"})}}return Z}};var t$={meta:{docs:"Disallow else blocks after return statements in if statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(!/^\s*else\b/.test(z))continue;let Q=!1;for(let G=Y-1;G>=0&&G>=Y-10;G--){let q=X[G].trim();if(q.startsWith("return"))Q=!0;if(q==="}"&&Q)break;if(q.includes("{"))break}if(Q)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf("else")+1),ruleId:"eslint/no-else-return",message:"Unnecessary else after return",severity:"warning"})}return Z}};var e$={meta:{docs:"Disallow empty block statements",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\{\s*\}/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=z.substring(0,G.index).trim(),U=/(?:if|else|for|while|do|try|catch|finally|function|\})\s*$/.test(q),W=/[=:]$/.test(q)||/return\s*$/.test(q);if(U&&!W)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-empty",message:"Empty block statement",severity:"error"})}}for(let Y=0;Y<X.length-1;Y++){let z=X[Y],Q=X[Y+1];if(/\{\s*$/.test(z.trim()))for(let G=Y+1;G<X.length;G++){let q=X[G].trim();if(q==="")continue;if(q==="}"||q.startsWith("}")){let U=z.substring(0,z.lastIndexOf("{")).trim(),W=/(?:if|else|for|while|do|try|catch|finally|function|\})\s*$/.test(U),K=/[=:]$/.test(U)||/return\s*$/.test(U);if(W&&!K)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.lastIndexOf("{")+1),ruleId:"eslint/no-empty",message:"Empty block statement",severity:"error"})}break}}return Z}};var $8={meta:{docs:"Disallow empty functions",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[/function\s+\w+\s*\([^)]*\)\s*\{\s*\}/g,/function\s*\([^)]*\)\s*\{\s*\}/g,/\([^)]*\)\s*=>\s*\{\s*\}/g,/\w+\s*\([^)]*\)\s*\{\s*\}/g];for(let G of Q){let q;for(q=G.exec(z);q!==null;q=G.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-empty-function",message:"Unexpected empty function",severity:"warning"})}}}return Z}};var Z8={meta:{docs:"Disallow use of eval()",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\beval\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-eval",message:"eval can be harmful",severity:"error"})}}return Z}};var iQ=["Object","Array","String","Number","Boolean","Date","RegExp","Function","Math","JSON","Promise","Map","Set","WeakMap","WeakSet","Symbol","Proxy","Reflect","Error","TypeError","RangeError"],J8={meta:{docs:"Disallow extending native types",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];for(let Q of iQ){let G=new RegExp(`\\b${Q}\\.prototype\\.\\w+\\s*=`,"g"),q;for(q=G.exec(z);q!==null;q=G.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-extend-native",message:`${Q} prototype is read only, properties should not be added`,severity:"error"})}}}return Z}};var X8={meta:{docs:"Disallow unnecessary boolean casts",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[/\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 G of Q){let q;for(q=G.exec(z);q!==null;q=G.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-extra-boolean-cast",message:"Redundant Boolean call or double negation",severity:"error"})}}}return Z},fix:($)=>{let J=$;return J=J.replace(/\b(if|while)\s*\(\s*Boolean\s*\(([^)]+)\)\s*\)/g,"$1 ($2)"),J=J.replace(/!\s*Boolean\s*\(([^)]+)\)/g,"!$1"),J=J.replace(/!!\s*(\w+)/g,"$1"),J}};var tQ=["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"],Y8={meta:{docs:"Disallow assignment to native objects or read-only global variables",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];for(let Q of tQ){let G=new RegExp(`\\b${Q}\\s*=\\s*[^=]`,"g"),q;for(q=G.exec(z);q!==null;q=G.exec(z))if(!z.slice(q.index).match(new RegExp(`^${Q}\\s*===?`)))Z.push({filePath:J.filePath,line:Y+1,column:q.index+1,ruleId:"eslint/no-global-assign",message:`Read-only global '${Q}' should not be modified`,severity:"error"})}}return Z}};var z8={meta:{docs:"Disallow implied eval() via setTimeout/setInterval with strings",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b(setTimeout|setInterval)\s*\(\s*(['"`])/g,G;while((G=Q.exec(z))!==null){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-implied-eval",message:"Implied eval. Consider passing a function instead of a string",severity:"error"})}}return Z}};var Q8={meta:{docs:"Disallow the use of the __iterator__ property",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/__iterator__/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-iterator",message:"Reserved name '__iterator__'",severity:"error"})}}return Z}};var k1={meta:{docs:"Disallow if statements as the only statement in else blocks",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(/^\s*else\s*(?:\{\s*)?$/.test(z)){let G=Y,q=z.includes("{");if(!q){if(Y+1<X.length&&X[Y+1].trim()==="{")G=Y+1,q=!0}if(q)for(let U=G+1;U<X.length;U++){let W=X[U].trim();if(W===""||W.startsWith("//")||W.startsWith("/*"))continue;if(W==="}")break;if(W.startsWith("if ")||W.startsWith("if(")){let K=!0,H=0,V=!1;for(let A=U;A<X.length;A++){let _=X[A];if(H+=(_.match(/\{/g)||[]).length,H-=(_.match(/\}/g)||[]).length,A===U){V=!0;continue}if(H===0){for(let B=A+1;B<X.length;B++){let F=X[B].trim();if(F===""||F.startsWith("//"))continue;if(F==="}"||F.startsWith("}"))break;else K=!1;break}break}}if(V&&K)Z.push({filePath:J.filePath,line:U+1,column:Math.max(1,X[U].indexOf("if")+1),ruleId:"eslint/no-lonely-if",message:"Unexpected if as the only statement in an else block",severity:"warning"})}break}}}return Z},fix:($,J)=>{if(k1.check($,J).length===0)return $;return $}};var G8={meta:{docs:"Disallow new operators outside of assignments or comparisons",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/^\s*new\s+\w+\s*\(/.test(z)){if(!/[=:]/.test(z.substring(0,z.indexOf("new"))))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf("new")+1),ruleId:"eslint/no-new",message:"Do not use 'new' for side effects",severity:"warning"})}}return Z}};var q8={meta:{docs:"Disallow new Function() declarations",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\bnew\s+Function\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-new-func",message:"The Function constructor is eval",severity:"error"})}}return Z}};var U8={meta:{docs:"Disallow new operators with String, Number, and Boolean",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\bnew\s+(String|Number|Boolean)\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-new-wrappers",message:`Do not use ${G[1]} as a constructor`,severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=!1,X=J.map((Y)=>{if(Y.trim().startsWith("//")||Y.trim().startsWith("/*"))return Y;return Y.replace(/\bnew\s+(String|Number|Boolean)\s*\(/g,(Q,G)=>{return Z=!0,`${G}(`})});return Z?X.join(`
53
+ `):$}};var RZ=["undefined","object","boolean","number","string","function","symbol","bigint"],m$={meta:{docs:"Enforce comparing typeof expressions against valid strings",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/typeof\s+\w+\s*(?:===|!==|==|!=)\s*(['"`])(\w+)\1/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let U=G[2];if(!RZ.includes(U))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/valid-typeof",message:`Invalid typeof comparison value '${U}'`,severity:"error"})}let q=/(['"`])(\w+)\1\s*(?:===|!==|==|!=)\s*typeof\s+\w+/g;for(G=q.exec(z);G!==null;G=q.exec(z)){let U=G[2];if(!RZ.includes(U))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/valid-typeof",message:`Invalid typeof comparison value '${U}'`,severity:"error"})}}return Z}};var d$={meta:{docs:"Enforce a maximum cyclomatic complexity allowed in a program",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=10,z=!1,Q=0,G="",q=0,U=0;for(let W=0;W<X.length;W++){let K=X[W],H=K.match(/\bfunction\s+(\w+)\s*\(|(\w+)\s*=\s*(?:\([^)]*\)|(\w+))\s*=>/);if(H)z=!0,Q=W+1,G=H[1]||H[2]||H[3]||"anonymous",q=1,U=0;if(z){for(let A of K){if(A==="{")U++;if(A==="}"){if(U--,U===0){if(q>10)Z.push({filePath:J.filePath,line:Q,column:1,ruleId:"eslint/complexity",message:`Function '${G}' has complexity ${q}, exceeds maximum of 10`,severity:"error"});z=!1}}}let V=[/\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 A of V){let _=K.match(new RegExp(A,"g"));if(_)q+=_.length}}}return Z}};var o$={meta:{docs:"Require default case in switch statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=0,Q=!1,G=0;for(let q=0;q<X.length;q++){let U=X[q];if(U.match(/\bswitch\s*\(/))Y=!0,z=q+1,Q=!1,G=0;if(Y){for(let W of U){if(W==="{")G++;if(W==="}"){if(G--,G===0){if(!Q)Z.push({filePath:J.filePath,line:z,column:1,ruleId:"eslint/default-case",message:"Expected a default case",severity:"error"});Y=!1}}}if(U.match(/\bdefault\s*:/))Q=!0}}return Z}};var c$={meta:{docs:"Require === and !== instead of == and !=",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/([^=!])(\s*)(==)(\s*)([^=])/g,G=/([^!])(\s*)(!=)(\s*)([^=])/g,q;for(q=Q.exec(z);q!==null;q=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+2),ruleId:"eslint/eqeqeq",message:"Expected '===' and instead saw '=='",severity:"error"});for(q=G.exec(z);q!==null;q=G.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+2),ruleId:"eslint/eqeqeq",message:"Expected '!==' and instead saw '!='",severity:"error"})}return Z},fix:($)=>{let J=$;return J=J.replace(/([^!])(\s*)(!=)(\s*)([^=])/g,"$1$2!==$4$5"),J=J.replace(/([^=!])(\s*)(==)(\s*)([^=])/g,"$1$2===$4$5"),J}};var r$={meta:{docs:"Enforce a maximum depth that blocks can be nested",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=4,z=0,Q=0,G=0;for(let q=0;q<X.length;q++){let U=X[q];if(U.match(/\b(if|for|while|switch|try|catch|else)\b.*\{/)){if(z++,z>Q)Q=z,G=q+1}else if(U.match(/\{/)&&!U.match(/^.*\}/)){if(X[q-1]?.match(/\b(if|for|while|switch|try|catch|else)\b/)){if(z++,z>Q)Q=z,G=q+1}}if(U.match(/^\s*\}/))z--;if(z>4)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"eslint/max-depth",message:`Blocks are nested too deeply (${z}), maximum allowed is 4`,severity:"error"})}return Z}};var l$={meta:{docs:"Enforce a maximum number of lines of code in a function",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=50,z=!1,Q=0,G="",q=0;for(let U=0;U<X.length;U++){let W=X[U],K=W.match(/\bfunction\s+(\w+)\s*\(|(\w+)\s*=\s*(?:\([^)]*\)|(\w+))\s*=>/);if(K)z=!0,Q=U+1,G=K[1]||K[2]||K[3]||"anonymous",q=0;if(z)for(let H of W){if(H==="{")q++;if(H==="}"){if(q--,q===0){let V=U+1-Q+1;if(V>50)Z.push({filePath:J.filePath,line:Q,column:1,ruleId:"eslint/max-lines-per-function",message:`Function '${G}' has ${V} lines, exceeds maximum of 50`,severity:"error"});z=!1}}}}return Z}};var a$={meta:{docs:"Disallow alert, confirm, and prompt",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b(alert|confirm|prompt)\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-alert",message:`Unexpected ${G[1]}`,severity:"warning"})}}return Z}};var s$={meta:{docs:"Disallow await inside of loops",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=0,Q=0;for(let G=0;G<X.length;G++){let q=X[G];if(q.match(/\b(for|while|do)\s*\(/))Y=!0,z=0,Q=G;if(Y){for(let U of q){if(U==="{")z++;if(U==="}"){if(z--,z===0)Y=!1}}if(q.match(/\bawait\s+/))Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"eslint/no-await-in-loop",message:"Unexpected await inside a loop. Consider using Promise.all() instead",severity:"error"})}}return Z}};var n$={meta:{docs:"Disallow use of arguments.caller or arguments.callee",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\barguments\s*\.\s*(caller|callee)\b/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"eslint/no-caller",message:`Avoid arguments.${G[1]}`,severity:"error"})}return Z}};var i$={meta:{docs:"Disallow lexical declarations in case clauses",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(G.match(/\bcase\s+(?:\S.*)?:|default\s*:/))Y=!0,z=!0;else z=!1;if(Y&&!z&&(G.match(/\bbreak\b/)||G.match(/\bcase\s+(?:\S.*)?:/)))Y=!1;if(Y&&!z){if(G.match(/\b(let|const|function|class)\s+/))Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"eslint/no-case-declarations",message:"Unexpected lexical declaration in case block",severity:"error"})}}return Z}};var t$={meta:{docs:"Disallow else blocks after return statements in if statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(!/^\s*else\b/.test(z))continue;let Q=!1;for(let G=Y-1;G>=0&&G>=Y-10;G--){let q=X[G].trim();if(q.startsWith("return"))Q=!0;if(q==="}"&&Q)break;if(q.includes("{"))break}if(Q)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf("else")+1),ruleId:"eslint/no-else-return",message:"Unnecessary else after return",severity:"warning"})}return Z}};var e$={meta:{docs:"Disallow empty block statements",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\{\s*\}/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=z.substring(0,G.index).trim(),U=/(?:if|else|for|while|do|try|catch|finally|function|\})\s*$/.test(q),W=/[=:]$/.test(q)||/return\s*$/.test(q);if(U&&!W)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-empty",message:"Empty block statement",severity:"error"})}}for(let Y=0;Y<X.length-1;Y++){let z=X[Y],Q=X[Y+1];if(/\{\s*$/.test(z.trim()))for(let G=Y+1;G<X.length;G++){let q=X[G].trim();if(q==="")continue;if(q==="}"||q.startsWith("}")){let U=z.substring(0,z.lastIndexOf("{")).trim(),W=/(?:if|else|for|while|do|try|catch|finally|function|\})\s*$/.test(U),K=/[=:]$/.test(U)||/return\s*$/.test(U);if(W&&!K)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.lastIndexOf("{")+1),ruleId:"eslint/no-empty",message:"Empty block statement",severity:"error"})}break}}return Z}};var $8={meta:{docs:"Disallow empty functions",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[/function\s+\w+\s*\([^)]*\)\s*\{\s*\}/g,/function\s*\([^)]*\)\s*\{\s*\}/g,/\([^)]*\)\s*=>\s*\{\s*\}/g,/\w+\s*\([^)]*\)\s*\{\s*\}/g];for(let G of Q){let q;for(q=G.exec(z);q!==null;q=G.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-empty-function",message:"Unexpected empty function",severity:"warning"})}}}return Z}};var Z8={meta:{docs:"Disallow use of eval()",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\beval\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-eval",message:"eval can be harmful",severity:"error"})}}return Z}};var $2=["Object","Array","String","Number","Boolean","Date","RegExp","Function","Math","JSON","Promise","Map","Set","WeakMap","WeakSet","Symbol","Proxy","Reflect","Error","TypeError","RangeError"],J8={meta:{docs:"Disallow extending native types",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];for(let Q of $2){let G=new RegExp(`\\b${Q}\\.prototype\\.\\w+\\s*=`,"g"),q;for(q=G.exec(z);q!==null;q=G.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-extend-native",message:`${Q} prototype is read only, properties should not be added`,severity:"error"})}}}return Z}};var X8={meta:{docs:"Disallow unnecessary boolean casts",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[/\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 G of Q){let q;for(q=G.exec(z);q!==null;q=G.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-extra-boolean-cast",message:"Redundant Boolean call or double negation",severity:"error"})}}}return Z},fix:($)=>{let J=$;return J=J.replace(/\b(if|while)\s*\(\s*Boolean\s*\(([^)]+)\)\s*\)/g,"$1 ($2)"),J=J.replace(/!\s*Boolean\s*\(([^)]+)\)/g,"!$1"),J=J.replace(/!!\s*(\w+)/g,"$1"),J}};var Z2=["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"],Y8={meta:{docs:"Disallow assignment to native objects or read-only global variables",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];for(let Q of Z2){let G=new RegExp(`\\b${Q}\\s*=\\s*[^=]`,"g"),q;for(q=G.exec(z);q!==null;q=G.exec(z))if(!z.slice(q.index).match(new RegExp(`^${Q}\\s*===?`)))Z.push({filePath:J.filePath,line:Y+1,column:q.index+1,ruleId:"eslint/no-global-assign",message:`Read-only global '${Q}' should not be modified`,severity:"error"})}}return Z}};var z8={meta:{docs:"Disallow implied eval() via setTimeout/setInterval with strings",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b(setTimeout|setInterval)\s*\(\s*(['"`])/g,G;while((G=Q.exec(z))!==null){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-implied-eval",message:"Implied eval. Consider passing a function instead of a string",severity:"error"})}}return Z}};var Q8={meta:{docs:"Disallow the use of the __iterator__ property",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/__iterator__/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-iterator",message:"Reserved name '__iterator__'",severity:"error"})}}return Z}};var k1={meta:{docs:"Disallow if statements as the only statement in else blocks",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(/^\s*else\s*(?:\{\s*)?$/.test(z)){let G=Y,q=z.includes("{");if(!q){if(Y+1<X.length&&X[Y+1].trim()==="{")G=Y+1,q=!0}if(q)for(let U=G+1;U<X.length;U++){let W=X[U].trim();if(W===""||W.startsWith("//")||W.startsWith("/*"))continue;if(W==="}")break;if(W.startsWith("if ")||W.startsWith("if(")){let K=!0,H=0,V=!1;for(let A=U;A<X.length;A++){let _=X[A];if(H+=(_.match(/\{/g)||[]).length,H-=(_.match(/\}/g)||[]).length,A===U){V=!0;continue}if(H===0){for(let B=A+1;B<X.length;B++){let F=X[B].trim();if(F===""||F.startsWith("//"))continue;if(F==="}"||F.startsWith("}"))break;else K=!1;break}break}}if(V&&K)Z.push({filePath:J.filePath,line:U+1,column:Math.max(1,X[U].indexOf("if")+1),ruleId:"eslint/no-lonely-if",message:"Unexpected if as the only statement in an else block",severity:"warning"})}break}}}return Z},fix:($,J)=>{if(k1.check($,J).length===0)return $;return $}};var G8={meta:{docs:"Disallow new operators outside of assignments or comparisons",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/^\s*new\s+\w+\s*\(/.test(z)){if(!/[=:]/.test(z.substring(0,z.indexOf("new"))))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf("new")+1),ruleId:"eslint/no-new",message:"Do not use 'new' for side effects",severity:"warning"})}}return Z}};var q8={meta:{docs:"Disallow new Function() declarations",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\bnew\s+Function\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-new-func",message:"The Function constructor is eval",severity:"error"})}}return Z}};var U8={meta:{docs:"Disallow new operators with String, Number, and Boolean",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\bnew\s+(String|Number|Boolean)\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-new-wrappers",message:`Do not use ${G[1]} as a constructor`,severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=!1,X=J.map((Y)=>{if(Y.trim().startsWith("//")||Y.trim().startsWith("/*"))return Y;return Y.replace(/\bnew\s+(String|Number|Boolean)\s*\(/g,(Q,G)=>{return Z=!0,`${G}(`})});return Z?X.join(`
54
54
  `):$}};var W8={meta:{docs:"Disallow octal literals",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b0[0-7]+\b/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"eslint/no-octal",message:"Octal literals should not be used",severity:"error"})}return Z}};var K8={meta:{docs:"Disallow reassignment of function parameters",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map;for(let z=0;z<X.length;z++){let Q=X[z],G=[...Q.matchAll(/function\s+(?:(\w+)\s*)?\(([^)]*)\)/g),...Q.matchAll(/(?:const|let|var)?\s*(\w+)\s*=\s*\(([^)]*)\)\s*=>/g),...Q.matchAll(/(?:const|let|var)?\s*(\w+)\s*=\s*(\w+)\s*=>/g)];for(let q of G){let U=q[2]?q[2].split(",").map((K)=>K.trim().split(/[=:]/)[0].trim()):[],W=`line-${z}`;if(U.length>0)Y.set(W,new Set(U.filter((K)=>K&&/^\w+$/.test(K))))}for(let[q,U]of Y.entries())for(let W of U){let K=new RegExp(`\\b${W}\\s*=\\s*[^=]`,"g"),H;for(H=K.exec(Q);H!==null;H=K.exec(Q))if(!Q.slice(H.index).match(/^\w+\s*===?/))Z.push({filePath:J.filePath,line:z+1,column:H.index+1,ruleId:"eslint/no-param-reassign",message:`Assignment to function parameter '${W}'`,severity:"error"})}}return Z}};var H8={meta:{docs:"Disallow use of __proto__",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/__proto__/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-proto",message:"The '__proto__' property is deprecated",severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=!1,X=J.map((Y)=>{if(Y.trim().startsWith("//")||Y.trim().startsWith("/*"))return Y;return Y.replace(/(\w+)\.__proto__/g,(Q,G)=>{return Z=!0,`Object.getPrototypeOf(${G})`})});return Z?X.join(`
55
- `):$}};var V8={meta:{docs:"Disallow assignment operators in return statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\breturn\s[^;]*\b\w+\s*=\s*(?!=)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[0];if(/===|==/.test(q))continue;if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-return-assign",message:"Return statement should not contain assignment",severity:"error"})}}return Z}};var A8={meta:{docs:"Disallow comma operators",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\)\s*,\s*\w+\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+G[0].indexOf(",")+1),ruleId:"eslint/no-sequences",message:"Unexpected use of comma operator",severity:"warning"})}}return Z}};var _8={meta:{docs:"Disallow variable declarations from shadowing variables declared in the outer scope",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=[new Set];for(let Q=0;Q<X.length;Q++){let G=X[Q];if(G.match(/\bfunction\s+\w+\s*\(|=>\s*\{|\{\s*$/))z.push(new Set);let q=[...G.matchAll(/\b(const|let|var)\s+(\w+)/g),...G.matchAll(/function\s+(\w+)\s*\(/g)];for(let U of q){let W=U[2]||U[1];for(let K=0;K<z.length-1;K++)if(z[K].has(W)){Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"eslint/no-shadow",message:`'${W}' is already declared in the upper scope`,severity:"error"});break}z[z.length-1].add(W)}if(G.match(/^\s*\}\s*$/)){if(z.length>1)z.pop()}}return Z}};var F8={meta:{docs:"Disallow throwing literals as exceptions",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[{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:G,type:q}of Q){let U;while((U=G.exec(z))!==null){if(z.substring(0,U.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,U.index+1),ruleId:"eslint/no-throw-literal",message:`Expected an error object to be thrown, got ${q} literal`,severity:"error"})}}}return Z}};var B8={meta:{docs:"Disallow the use of variables before they are defined",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map;for(let z=0;z<X.length;z++){let Q=X[z],G=[...Q.matchAll(/\b(const|let|var)\s+(\w+)/g),...Q.matchAll(/\bfunction\s+(\w+)\s*\(/g),...Q.matchAll(/\bclass\s+(\w+)/g)];for(let q of G){let U=q[2]||q[1];if(!Y.has(U))Y.set(U,z+1)}}for(let z=0;z<X.length;z++){let Q=X[z];if(Q.match(/\b(const|let|var|function|class)\s+\w+/))continue;let G=Q.matchAll(/\b(\w+)\b/g);for(let q of G){let U=q[1],W=Y.get(U);if(W&&W>z+1)Z.push({filePath:J.filePath,line:z+1,column:q.index+1,ruleId:"eslint/no-use-before-define",message:`'${U}' was used before it was defined`,severity:"error"})}}return Z}};var w8={meta:{docs:"Disallow unnecessary .call() and .apply()",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\.\s*call\s*\(\s*(undefined|null)\s*,/g,G=/\.\s*apply\s*\(\s*(undefined|null)\s*,/g,q;for(q=Q.exec(z);q!==null;q=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:q.index+1,ruleId:"eslint/no-useless-call",message:"Unnecessary '.call()'",severity:"error"});for(q=G.exec(z);q!==null;q=G.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:q.index+1,ruleId:"eslint/no-useless-call",message:"Unnecessary '.apply()'",severity:"error"})}return Z}};var M8={meta:{docs:"Disallow unnecessary concatenation of literals or template literals",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[/(['"`])([^'"`]*)\1\s*\+\s*\1([^'"`]*)\1/g];for(let G of Q){let q;while((q=G.exec(z))!==null){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-useless-concat",message:"Unexpected string concatenation of literals",severity:"warning"})}}}return Z},fix:($)=>{let J=$;return J=J.replace(/(['"`])([^'"`]*)\1\s*\+\s*\1([^'"`]*)\1/g,"$1$2$3$1"),J}};var RZ=["/","(",")","[","]","{","}","<",">",":","@","#","$","%","&","=","+","-","*","?","!",";",",","|","~","`","^"],j8={meta:{docs:"Disallow unnecessary escape characters",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];for(let Q of RZ){let G=`\\${Q}`,q=new RegExp(`(['"\`])[^'"\`]*${G.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}`,"g"),U;while((U=q.exec(z))!==null){let W=U.index,K=z.indexOf(G,W);if(K>W)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,K+1),ruleId:"eslint/no-useless-escape",message:`Unnecessary escape character: \\${Q}`,severity:"warning"})}}}return Z},fix:($)=>{let J=$;for(let Z of RZ){let X=`\\${Z}`;J=J.replace(new RegExp(X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),Z)}return J}};var N8={meta:{docs:"Disallow renaming import, export, and destructured assignments to the same name",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/import\s*\{[^}]*\b(\w+)\s+as\s+\1\b[^}]*\}/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming import '${G[1]}' to '${G[1]}' is redundant`,severity:"error"});let q=/export\s*\{[^}]*\b(\w+)\s+as\s+\1\b[^}]*\}/g;for(G=q.exec(z);G!==null;G=q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming export '${G[1]}' to '${G[1]}' is redundant`,severity:"error"});let U=/\{[^}]*\b(\w+)\s*:\s*\1\b[^}]*\}\s*=/g;for(G=U.exec(z);G!==null;G=U.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming destructured property '${G[1]}' to '${G[1]}' is redundant`,severity:"error"})}return Z},fix:($)=>{let J=$;return J=J.replace(/\b(\w+)\s+as\s+\1\b/g,"$1"),J=J.replace(/\{([^}]*)\b(\w+)\s*:\s*\2\b([^}]*)\}/g,"{$1$2$3}"),J}};var f1={meta:{docs:"Disallow redundant return statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(Q==="return"||Q==="return;"){let G=!1;for(let q=Y+1;q<X.length;q++){let U=X[q].trim();if(U===""||U.startsWith("//")||U.startsWith("/*"))continue;if(U==="}"||U.startsWith("}"))G=!0;break}if(G)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf("return")+1),ruleId:"eslint/no-useless-return",message:"Unnecessary return statement",severity:"warning"})}}return Z},fix:($,J)=>{let Z=f1.check($,J);if(Z.length===0)return $;let X=$.split(/\r?\n/),Y=new Set(Z.map((Q)=>Q.line-1));return X.filter((Q,G)=>!Y.has(G)).join(`
55
+ `):$}};var V8={meta:{docs:"Disallow assignment operators in return statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\breturn\s[^;]*\b\w+\s*=\s*(?!=)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[0];if(/===|==/.test(q))continue;if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-return-assign",message:"Return statement should not contain assignment",severity:"error"})}}return Z}};var A8={meta:{docs:"Disallow comma operators",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\)\s*,\s*\w+\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+G[0].indexOf(",")+1),ruleId:"eslint/no-sequences",message:"Unexpected use of comma operator",severity:"warning"})}}return Z}};var _8={meta:{docs:"Disallow variable declarations from shadowing variables declared in the outer scope",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=[new Set];for(let Q=0;Q<X.length;Q++){let G=X[Q];if(G.match(/\bfunction\s+\w+\s*\(|=>\s*\{|\{\s*$/))z.push(new Set);let q=[...G.matchAll(/\b(const|let|var)\s+(\w+)/g),...G.matchAll(/function\s+(\w+)\s*\(/g)];for(let U of q){let W=U[2]||U[1];for(let K=0;K<z.length-1;K++)if(z[K].has(W)){Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"eslint/no-shadow",message:`'${W}' is already declared in the upper scope`,severity:"error"});break}z[z.length-1].add(W)}if(G.match(/^\s*\}\s*$/)){if(z.length>1)z.pop()}}return Z}};var F8={meta:{docs:"Disallow throwing literals as exceptions",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[{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:G,type:q}of Q){let U;while((U=G.exec(z))!==null){if(z.substring(0,U.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,U.index+1),ruleId:"eslint/no-throw-literal",message:`Expected an error object to be thrown, got ${q} literal`,severity:"error"})}}}return Z}};var B8={meta:{docs:"Disallow the use of variables before they are defined",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map;for(let z=0;z<X.length;z++){let Q=X[z],G=[...Q.matchAll(/\b(const|let|var)\s+(\w+)/g),...Q.matchAll(/\bfunction\s+(\w+)\s*\(/g),...Q.matchAll(/\bclass\s+(\w+)/g)];for(let q of G){let U=q[2]||q[1];if(!Y.has(U))Y.set(U,z+1)}}for(let z=0;z<X.length;z++){let Q=X[z];if(Q.match(/\b(const|let|var|function|class)\s+\w+/))continue;let G=Q.matchAll(/\b(\w+)\b/g);for(let q of G){let U=q[1],W=Y.get(U);if(W&&W>z+1)Z.push({filePath:J.filePath,line:z+1,column:q.index+1,ruleId:"eslint/no-use-before-define",message:`'${U}' was used before it was defined`,severity:"error"})}}return Z}};var w8={meta:{docs:"Disallow unnecessary .call() and .apply()",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\.\s*call\s*\(\s*(undefined|null)\s*,/g,G=/\.\s*apply\s*\(\s*(undefined|null)\s*,/g,q;for(q=Q.exec(z);q!==null;q=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:q.index+1,ruleId:"eslint/no-useless-call",message:"Unnecessary '.call()'",severity:"error"});for(q=G.exec(z);q!==null;q=G.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:q.index+1,ruleId:"eslint/no-useless-call",message:"Unnecessary '.apply()'",severity:"error"})}return Z}};var M8={meta:{docs:"Disallow unnecessary concatenation of literals or template literals",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[/(['"`])([^'"`]*)\1\s*\+\s*\1([^'"`]*)\1/g];for(let G of Q){let q;while((q=G.exec(z))!==null){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-useless-concat",message:"Unexpected string concatenation of literals",severity:"warning"})}}}return Z},fix:($)=>{let J=$;return J=J.replace(/(['"`])([^'"`]*)\1\s*\+\s*\1([^'"`]*)\1/g,"$1$2$3$1"),J}};var OZ=["/","(",")","[","]","{","}","<",">",":","@","#","$","%","&","=","+","-","*","?","!",";",",","|","~","`","^"],j8={meta:{docs:"Disallow unnecessary escape characters",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];for(let Q of OZ){let G=`\\${Q}`,q=new RegExp(`(['"\`])[^'"\`]*${G.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}`,"g"),U;while((U=q.exec(z))!==null){let W=U.index,K=z.indexOf(G,W);if(K>W)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,K+1),ruleId:"eslint/no-useless-escape",message:`Unnecessary escape character: \\${Q}`,severity:"warning"})}}}return Z},fix:($)=>{let J=$;for(let Z of OZ){let X=`\\${Z}`;J=J.replace(new RegExp(X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),Z)}return J}};var N8={meta:{docs:"Disallow renaming import, export, and destructured assignments to the same name",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/import\s*\{[^}]*\b(\w+)\s+as\s+\1\b[^}]*\}/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming import '${G[1]}' to '${G[1]}' is redundant`,severity:"error"});let q=/export\s*\{[^}]*\b(\w+)\s+as\s+\1\b[^}]*\}/g;for(G=q.exec(z);G!==null;G=q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming export '${G[1]}' to '${G[1]}' is redundant`,severity:"error"});let U=/\{[^}]*\b(\w+)\s*:\s*\1\b[^}]*\}\s*=/g;for(G=U.exec(z);G!==null;G=U.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming destructured property '${G[1]}' to '${G[1]}' is redundant`,severity:"error"})}return Z},fix:($)=>{let J=$;return J=J.replace(/\b(\w+)\s+as\s+\1\b/g,"$1"),J=J.replace(/\{([^}]*)\b(\w+)\s*:\s*\2\b([^}]*)\}/g,"{$1$2$3}"),J}};var f1={meta:{docs:"Disallow redundant return statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(Q==="return"||Q==="return;"){let G=!1;for(let q=Y+1;q<X.length;q++){let U=X[q].trim();if(U===""||U.startsWith("//")||U.startsWith("/*"))continue;if(U==="}"||U.startsWith("}"))G=!0;break}if(G)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf("return")+1),ruleId:"eslint/no-useless-return",message:"Unnecessary return statement",severity:"warning"})}}return Z},fix:($,J)=>{let Z=f1.check($,J);if(Z.length===0)return $;let X=$.split(/\r?\n/),Y=new Set(Z.map((Q)=>Q.line-1));return X.filter((Q,G)=>!Y.has(G)).join(`
56
56
  `)}};var T8={meta:{docs:"Require let or const instead of var",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\bvar\s+/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-var",message:"Unexpected var, use let or const instead",severity:"error"})}}return Z},fix:($,J)=>{return $.split(/\r?\n/).map((Y)=>{if(Y.trim().startsWith("//")||Y.trim().startsWith("/*"))return Y;return Y.replace(/\bvar\s+/g,"let ")}).join(`
57
- `)}};var E8={meta:{docs:"Disallow with statements",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\bwith\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-with",message:"Unexpected use of 'with' statement",severity:"error"})}}return Z}};var D8={meta:{docs:"Require using arrow functions for callbacks",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\.(map|filter|reduce|forEach|some|every|find|findIndex)\s*\(\s*function\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/prefer-arrow-callback",message:"Unexpected function expression, use arrow function instead",severity:"warning"})}}return Z}};var R8={meta:{docs:"Disallow async functions which have no await expression",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++)if(X[Y].match(/\basync\s+(?:function\s+\w+|(?:\(|\w+)\s*(?:\(|=>))/)){let G=!1,q=0,U=!1,W=Y;while(W<X.length){let K=X[W];for(let H of K){if(H==="{")q++,U=!0;if(H==="}"){if(q--,q===0&&U)break}}if(K.match(/\bawait\s+/))G=!0;if(q===0&&U){if(!G)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"eslint/require-await",message:"Async function has no await expression",severity:"error"});break}W++}}return Z}};var OZ=/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/;function w($){return{meta:$.meta,check:(J,Z)=>{if(!OZ.test(Z.filePath))return[];return $.check(J,Z)},fix:$.fix?(J,Z)=>{if(!OZ.test(Z.filePath))return J;return $.fix(J,Z)}:void 0}}var LZ=/\.(?:sh|bash|zsh|ksh|dash)$/,PZ=/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/;function V0($){return{meta:$.meta,check:(J,Z)=>{if(!LZ.test(Z.filePath)&&!PZ.test(J))return[];return $.check(J,Z)},fix:$.fix?(J,Z)=>{if(!LZ.test(Z.filePath)&&!PZ.test(J))return J;return $.fix(J,Z)}:void 0}}var CZ=/(?:^|[/\\])package\.json$/;function A0($){return{meta:$.meta,check:(J,Z)=>{if(!CZ.test(Z.filePath))return[];return $.check(J,Z)},fix:$.fix?(J,Z)=>{if(!CZ.test(Z.filePath))return J;return $.fix(J,Z)}:void 0}}var IZ={name:"eslint",rules:{"array-callback-return":w(M$),"constructor-super":w(j$),"for-direction":w(N$),"getter-return":w(T$),"no-async-promise-executor":w(E$),"no-compare-neg-zero":w(D$),"no-cond-assign":w(R$),"no-constant-condition":w(L$),"no-const-assign":w(O$),"no-dupe-class-members":w(P$),"no-dupe-keys":w(y1),"no-duplicate-case":w(C$),"no-empty-pattern":w(I$),"no-fallthrough":w(S$),"no-loss-of-precision":w(v$),"no-promise-executor-return":w(y$),"no-redeclare":w(b$),"no-self-assign":w(b1),"no-self-compare":w(k$),"no-sparse-arrays":w(f$),"no-undef":w(g$),"no-unsafe-negation":w(x$),"no-unreachable":w(p$),"no-useless-catch":w(h$),"use-isnan":w(u$),"valid-typeof":w(m$),"default-case":w(o$),eqeqeq:w(c$),"no-alert":w(a$),"no-await-in-loop":w(s$),"no-caller":w(n$),"no-case-declarations":w(i$),"no-else-return":w(t$),"no-empty":w(e$),"no-empty-function":w($8),"no-eval":w(Z8),"no-extend-native":w(J8),"no-global-assign":w(Y8),"no-implied-eval":w(z8),"no-iterator":w(Q8),"no-new":w(G8),"no-new-func":w(q8),"no-new-wrappers":w(U8),"no-octal":w(W8),"no-param-reassign":w(K8),"no-proto":w(H8),"no-return-assign":w(V8),"no-shadow":w(_8),"no-throw-literal":w(F8),"no-use-before-define":w(B8),"no-useless-call":w(w8),"no-with":w(E8),"require-await":w(R8),complexity:w(d$),"max-depth":w(r$),"max-lines-per-function":w(l$),"no-extra-boolean-cast":w(X8),"no-lonely-if":w(k1),"no-sequences":w(A8),"no-useless-concat":w(M8),"no-useless-escape":w(j8),"no-useless-rename":w(N8),"no-useless-return":w(f1),"no-var":w(T8),"prefer-arrow-callback":w(D8)}};var SZ={meta:{docs:"Disallow return statements in constructors - constructors automatically return the instance"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.indexOf("//");if(!(Q>=0?z.slice(0,Q):z).match(/\bconstructor\s*\(/))continue;let U=0,W=!1,K=-1;for(let H=Y;H<X.length;H++){let V=X[H],A=null,_=!1;for(let B=0;B<V.length;B++){let F=V[B];if(_){_=!1;continue}if(F==="\\"&&A){_=!0;continue}if(!A){if(F==="'")A="single";else if(F==='"')A="double";else if(F==="`")A="template";else if(F==="{")U++,W=!0;else if(F==="}"){if(U--,W&&U===0){K=H;break}}}else if(A==="single"&&F==="'"||A==="double"&&F==='"'||A==="template"&&F==="`")A=null}if(K!==-1)break}if(K===-1)continue;for(let H=Y;H<=K;H++){let V=X[H];if(H===Y)continue;if(/^\s*\/\//.test(V))continue;let A=V.indexOf("//"),_=A>=0?V.slice(0,A):V;if(_=_.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),_.match(/\breturn\b/)){let F=_.indexOf("return"),M=F>0?_[F-1]:" ",N=F+6<_.length?_[F+6]:" ";if(/\w/.test(M)||/\w/.test(N))continue;let E=_.slice(F+6).trim();if(E.startsWith("this;")||E==="this")continue;if(E===";"||E==="")continue;let j=V.indexOf("return");Z.push({filePath:J.filePath,line:H+1,column:j+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 Z}};var vZ={meta:{docs:"Disallow irregular whitespace characters that may cause issues in code"},check:($,J)=>{let Z=[],X=/[\u00A0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/g,Y=$.split(/\r?\n/);for(let z=0;z<Y.length;z++){let Q=Y[z],G;X.lastIndex=0;while((G=X.exec(Q))!==null){let U=G[0].charCodeAt(0),W="irregular whitespace",K={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(K[U])W=K[U];Z.push({filePath:J.filePath,line:z+1,column:G.index+1,ruleId:"no-irregular-whitespace",message:`Irregular whitespace detected: ${W} (U+${U.toString(16).toUpperCase().padStart(4,"0")})`,severity:"error",help:"Replace irregular whitespace with regular spaces or tabs"})}}return Z},fix:($)=>{return $.replace(/[\u00A0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/g," ")}};var yZ={meta:{docs:"Disallow new operators outside of assignments or comparisons",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(Q.startsWith("//")||Q.startsWith("/*")||Q.startsWith("*"))continue;if(/^\s*new\s+\w+/.test(z)){let q=/^\s*(?:const|let|var|this\.\w+)\s*=\s*new\s+/,U=/^\s*return\s+new\s+/,W=new RegExp("^\\s*new\\s+\\w[^;]*,"),K=/[=:,(]\s*new\s+/;if(!q.test(z)&&!U.test(z)&&!W.test(z)&&!K.test(Q)){let H=z.search(/new\s+/)+1;Z.push({filePath:J.filePath,line:Y+1,column:H,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 Z}};var bZ={meta:{docs:"Disallow multiple spaces in regular expressions",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/^\s*\/\//.test(z))continue;let Q=/\/(?![*/])((?:\\.|[^/\\])+)\/[gimsuvy]*/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let U=G[1];if(/ {2,}/.test(U)){let W=G.index+1;Z.push({filePath:J.filePath,line:Y+1,column:W,ruleId:"no-regex-spaces",message:"Multiple spaces in regular expression",severity:"error",help:"Use quantifiers like {2} instead of multiple spaces for clarity."})}}let q=/new\s+RegExp\s*\(\s*['"`]([^'"`]+)['"`]/g;for(G=q.exec(z);G!==null;G=q.exec(z)){let U=G[1];if(/ {2,}/.test(U)){let W=G.index+1;Z.push({filePath:J.filePath,line:Y+1,column:W,ruleId:"no-regex-spaces",message:"Multiple spaces in regular expression",severity:"error",help:"Use quantifiers like {2} instead of multiple spaces for clarity."})}}}return Z}};var kZ=new Set(["|","&",":",",","<"]),eQ=new Set(["(",",","=",":","[","!","&","|","?","{","}",";","+","-","*","%","<",">","~","^"]),$2=["return","typeof","instanceof","in","of","new","delete","void","case","do","else","yield","await"];function Z2($,J){let Z=J-1;while(Z>=0&&/\s/.test($[Z]))Z-=1;if(Z<0)return!0;let X=$[Z];if(eQ.has(X))return!0;if(/[\w$)\]]/.test(X)){if(/[\w$]/.test(X)){let Y=Z;while(Y>=0&&/[\w$]/.test($[Y]))Y-=1;let z=$.slice(Y+1,Z+1);return $2.includes(z)}return!1}return!0}function O8($,J){if($[J+1]==="/"||$[J+1]==="*")return!1;let Z=$.slice(0,J).trimEnd();return!Z||/[=([{,:;!&|?]$/.test(Z)||Z.endsWith("=>")||Z.endsWith("return")}function J2($){let J=$.split(""),Z=0,X=null,Y=!1,z=(Q,G)=>{for(let q=Q;q<G&&q<J.length;q+=1)if(J[q]!==`
57
+ `)}};var E8={meta:{docs:"Disallow with statements",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\bwith\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-with",message:"Unexpected use of 'with' statement",severity:"error"})}}return Z}};var D8={meta:{docs:"Require using arrow functions for callbacks",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\.(map|filter|reduce|forEach|some|every|find|findIndex)\s*\(\s*function\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/prefer-arrow-callback",message:"Unexpected function expression, use arrow function instead",severity:"warning"})}}return Z}};var R8={meta:{docs:"Disallow async functions which have no await expression",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++)if(X[Y].match(/\basync\s+(?:function\s+\w+|(?:\(|\w+)\s*(?:\(|=>))/)){let G=!1,q=0,U=!1,W=Y;while(W<X.length){let K=X[W];for(let H of K){if(H==="{")q++,U=!0;if(H==="}"){if(q--,q===0&&U)break}}if(K.match(/\bawait\s+/))G=!0;if(q===0&&U){if(!G)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"eslint/require-await",message:"Async function has no await expression",severity:"error"});break}W++}}return Z}};var LZ=/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/;function w($){return{meta:$.meta,check:(J,Z)=>{if(!LZ.test(Z.filePath))return[];return $.check(J,Z)},fix:$.fix?(J,Z)=>{if(!LZ.test(Z.filePath))return J;return $.fix(J,Z)}:void 0}}var PZ=/\.(?:sh|bash|zsh|ksh|dash)$/,CZ=/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/;function H0($){return{meta:$.meta,check:(J,Z)=>{if(!PZ.test(Z.filePath)&&!CZ.test(J))return[];return $.check(J,Z)},fix:$.fix?(J,Z)=>{if(!PZ.test(Z.filePath)&&!CZ.test(J))return J;return $.fix(J,Z)}:void 0}}var IZ=/(?:^|[/\\])package\.json$/;function A0($){return{meta:$.meta,check:(J,Z)=>{if(!IZ.test(Z.filePath))return[];return $.check(J,Z)},fix:$.fix?(J,Z)=>{if(!IZ.test(Z.filePath))return J;return $.fix(J,Z)}:void 0}}var SZ={name:"eslint",rules:{"array-callback-return":w(M$),"constructor-super":w(j$),"for-direction":w(N$),"getter-return":w(T$),"no-async-promise-executor":w(E$),"no-compare-neg-zero":w(D$),"no-cond-assign":w(R$),"no-constant-condition":w(L$),"no-const-assign":w(O$),"no-dupe-class-members":w(P$),"no-dupe-keys":w(y1),"no-duplicate-case":w(C$),"no-empty-pattern":w(I$),"no-fallthrough":w(S$),"no-loss-of-precision":w(v$),"no-promise-executor-return":w(y$),"no-redeclare":w(b$),"no-self-assign":w(b1),"no-self-compare":w(k$),"no-sparse-arrays":w(f$),"no-undef":w(g$),"no-unsafe-negation":w(x$),"no-unreachable":w(p$),"no-useless-catch":w(h$),"use-isnan":w(u$),"valid-typeof":w(m$),"default-case":w(o$),eqeqeq:w(c$),"no-alert":w(a$),"no-await-in-loop":w(s$),"no-caller":w(n$),"no-case-declarations":w(i$),"no-else-return":w(t$),"no-empty":w(e$),"no-empty-function":w($8),"no-eval":w(Z8),"no-extend-native":w(J8),"no-global-assign":w(Y8),"no-implied-eval":w(z8),"no-iterator":w(Q8),"no-new":w(G8),"no-new-func":w(q8),"no-new-wrappers":w(U8),"no-octal":w(W8),"no-param-reassign":w(K8),"no-proto":w(H8),"no-return-assign":w(V8),"no-shadow":w(_8),"no-throw-literal":w(F8),"no-use-before-define":w(B8),"no-useless-call":w(w8),"no-with":w(E8),"require-await":w(R8),complexity:w(d$),"max-depth":w(r$),"max-lines-per-function":w(l$),"no-extra-boolean-cast":w(X8),"no-lonely-if":w(k1),"no-sequences":w(A8),"no-useless-concat":w(M8),"no-useless-escape":w(j8),"no-useless-rename":w(N8),"no-useless-return":w(f1),"no-var":w(T8),"prefer-arrow-callback":w(D8)}};var vZ={meta:{docs:"Disallow return statements in constructors - constructors automatically return the instance"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.indexOf("//");if(!(Q>=0?z.slice(0,Q):z).match(/\bconstructor\s*\(/))continue;let U=0,W=!1,K=-1;for(let H=Y;H<X.length;H++){let V=X[H],A=null,_=!1;for(let B=0;B<V.length;B++){let F=V[B];if(_){_=!1;continue}if(F==="\\"&&A){_=!0;continue}if(!A){if(F==="'")A="single";else if(F==='"')A="double";else if(F==="`")A="template";else if(F==="{")U++,W=!0;else if(F==="}"){if(U--,W&&U===0){K=H;break}}}else if(A==="single"&&F==="'"||A==="double"&&F==='"'||A==="template"&&F==="`")A=null}if(K!==-1)break}if(K===-1)continue;for(let H=Y;H<=K;H++){let V=X[H];if(H===Y)continue;if(/^\s*\/\//.test(V))continue;let A=V.indexOf("//"),_=A>=0?V.slice(0,A):V;if(_=_.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),_.match(/\breturn\b/)){let F=_.indexOf("return"),M=F>0?_[F-1]:" ",T=F+6<_.length?_[F+6]:" ";if(/\w/.test(M)||/\w/.test(T))continue;let E=_.slice(F+6).trim();if(E.startsWith("this;")||E==="this")continue;if(E===";"||E==="")continue;let j=V.indexOf("return");Z.push({filePath:J.filePath,line:H+1,column:j+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 Z}};var yZ={meta:{docs:"Disallow irregular whitespace characters that may cause issues in code"},check:($,J)=>{let Z=[],X=/[\u00A0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/g,Y=$.split(/\r?\n/);for(let z=0;z<Y.length;z++){let Q=Y[z],G;X.lastIndex=0;while((G=X.exec(Q))!==null){let U=G[0].charCodeAt(0),W="irregular whitespace",K={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(K[U])W=K[U];Z.push({filePath:J.filePath,line:z+1,column:G.index+1,ruleId:"no-irregular-whitespace",message:`Irregular whitespace detected: ${W} (U+${U.toString(16).toUpperCase().padStart(4,"0")})`,severity:"error",help:"Replace irregular whitespace with regular spaces or tabs"})}}return Z},fix:($)=>{return $.replace(/[\u00A0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/g," ")}};var bZ={meta:{docs:"Disallow new operators outside of assignments or comparisons",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(Q.startsWith("//")||Q.startsWith("/*")||Q.startsWith("*"))continue;if(/^\s*new\s+\w+/.test(z)){let q=/^\s*(?:const|let|var|this\.\w+)\s*=\s*new\s+/,U=/^\s*return\s+new\s+/,W=new RegExp("^\\s*new\\s+\\w[^;]*,"),K=/[=:,(]\s*new\s+/;if(!q.test(z)&&!U.test(z)&&!W.test(z)&&!K.test(Q)){let H=z.search(/new\s+/)+1;Z.push({filePath:J.filePath,line:Y+1,column:H,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 Z}};var kZ={meta:{docs:"Disallow multiple spaces in regular expressions",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/^\s*\/\//.test(z))continue;let Q=/\/(?![*/])((?:\\.|[^/\\])+)\/[gimsuvy]*/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let U=G[1];if(/ {2,}/.test(U)){let W=G.index+1;Z.push({filePath:J.filePath,line:Y+1,column:W,ruleId:"no-regex-spaces",message:"Multiple spaces in regular expression",severity:"error",help:"Use quantifiers like {2} instead of multiple spaces for clarity."})}}let q=/new\s+RegExp\s*\(\s*['"`]([^'"`]+)['"`]/g;for(G=q.exec(z);G!==null;G=q.exec(z)){let U=G[1];if(/ {2,}/.test(U)){let W=G.index+1;Z.push({filePath:J.filePath,line:Y+1,column:W,ruleId:"no-regex-spaces",message:"Multiple spaces in regular expression",severity:"error",help:"Use quantifiers like {2} instead of multiple spaces for clarity."})}}}return Z}};var fZ=new Set(["|","&",":",",","<"]),J2=new Set(["(",",","=",":","[","!","&","|","?","{","}",";","+","-","*","%","<",">","~","^"]),X2=["return","typeof","instanceof","in","of","new","delete","void","case","do","else","yield","await"];function Y2($,J){let Z=J-1;while(Z>=0&&/\s/.test($[Z]))Z-=1;if(Z<0)return!0;let X=$[Z];if(J2.has(X))return!0;if(/[\w$)\]]/.test(X)){if(/[\w$]/.test(X)){let Y=Z;while(Y>=0&&/[\w$]/.test($[Y]))Y-=1;let z=$.slice(Y+1,Z+1);return X2.includes(z)}return!1}return!0}function O8($,J){if($[J+1]==="/"||$[J+1]==="*")return!1;let Z=$.slice(0,J).trimEnd();return!Z||/[=([{,:;!&|?]$/.test(Z)||Z.endsWith("=>")||Z.endsWith("return")}function z2($){let J=$.split(""),Z=0,X=null,Y=!1,z=(Q,G)=>{for(let q=Q;q<G&&q<J.length;q+=1)if(J[q]!==`
58
58
  `&&J[q]!=="\r")J[q]=" "};while(Z<$.length){let Q=$[Z];if(X){if(Y)Y=!1;else if(Q==="\\")Y=!0;else if(Q===X)X=null;else if(Q===`
59
- `&&X!=="`")X=null;Z+=1;continue}if(Q==="'"||Q==='"'||Q==="`"){X=Q,Z+=1;continue}if(Q==="/"&&$[Z+1]!=="/"&&$[Z+1]!=="*"&&Z2($,Z)){let G=Z+1,q=!1,U=!1;while(G<$.length){let W=$[G];if(U)U=!1;else if(W==="\\")U=!0;else if(W==="[")q=!0;else if(W==="]")q=!1;else if(W===`
59
+ `&&X!=="`")X=null;Z+=1;continue}if(Q==="'"||Q==='"'||Q==="`"){X=Q,Z+=1;continue}if(Q==="/"&&$[Z+1]!=="/"&&$[Z+1]!=="*"&&Y2($,Z)){let G=Z+1,q=!1,U=!1;while(G<$.length){let W=$[G];if(U)U=!1;else if(W==="\\")U=!0;else if(W==="[")q=!0;else if(W==="]")q=!1;else if(W===`
60
60
  `)break;else if(W==="/"&&!q){G+=1;break}G+=1}Z=G;continue}if(Q==="/"&&$[Z+1]==="/"){let G=$.indexOf(`
61
- `,Z);z(Z+2,G<0?$.length:G),Z=G<0?$.length:G;continue}if(Q==="/"&&$[Z+1]==="*"){let G=$.indexOf("*/",Z+2);z(Z+2,G<0?$.length:G),Z=G<0?$.length:G+2;continue}Z+=1}return J.join("")}var n0={meta:{docs:"Report variables and parameters that are declared/assigned but never used"},check:($,J)=>{if(J.filePath.endsWith("/no-unused-vars.ts"))return[];if(J.filePath.endsWith(".d.ts"))return[];let Z=[],X=J.options||{},Y=typeof X.varsIgnorePattern==="string"?X.varsIgnorePattern:"^_",z=typeof X.argsIgnorePattern==="string"?X.argsIgnorePattern:"^_",Q=new RegExp(Y,"u"),G=new RegExp(z,"u"),q=J2($),U=q.split(/\r?\n/),W=q,K=Array(U.length).fill(!1);(()=>{let j=[],O=!1,y=!1,k=!1,L=!1,x=!1,b="",P=()=>{if(b==="")return!0;if("=([{,;!&|?:+-*/%^~<>".includes(b))return!0;return!1};for(let I=0;I<U.length;I++){K[I]=j.length>0&&j[j.length-1]===-1;let S=U[I];for(let C=0;C<S.length;C++){let T=S[C];if(L){if(T==="*"&&C+1<S.length&&S[C+1]==="/")L=!1,C++;continue}if(x){x=!1;continue}let R=j.length>0&&j[j.length-1]===-1,D=j.length>0&&j[j.length-1]>=0;if(T==="\\"&&(O||y||k||R)){x=!0;continue}if(O){if(T==="'")O=!1;continue}if(y){if(T==='"')y=!1;continue}if(k){if(T==="["){let f=1,h=C+1;while(h<S.length){let o=S[h];if(o==="\\"){h+=2;continue}if(o==="]"){if(f--,f===0)break}h++}C=h;continue}if(T==="/"){k=!1;while(C+1<S.length&&/[gimsuvy]/.test(S[C+1]))C++}continue}if(R){if(T==="`")j.pop();else if(T==="$"&&C+1<S.length&&S[C+1]==="{")j.push(0),C++;continue}if(T==="/"&&C+1<S.length&&S[C+1]==="/")break;if(T==="/"&&C+1<S.length&&S[C+1]==="*"){L=!0,C++;continue}if(D){if(T==="`")j.push(-1),b="";else if(T==="'")O=!0,b="'";else if(T==='"')y=!0,b='"';else if(T==="{")j[j.length-1]++,b="{";else if(T==="}"){let f=j[j.length-1];if(f>0)j[j.length-1]=f-1;else j.pop();b="}"}else if(T==="/"&&P())k=!0;else if(!/\s/.test(T))b=T;continue}if(T==="`")j.push(-1),b="";else if(T==="'")O=!0,b="'";else if(T==='"')y=!0,b='"';else if(T==="/"&&P())k=!0;else if(!/\s/.test(T))b=T}}})();let V=new RegExp("^\\s*(?:const|let|var)\\s+(.+?);?\\s*$");for(let j=0;j<U.length;j++){if(K[j])continue;let O=U[j],y=O.match(V);if(!y)continue;let k=y[1],L=[],x="",b=0,P=0,I=null,S=!1;for(let C=0;C<k.length;C++){let T=k[C];if(S){S=!1,x+=T;continue}if(T==="\\"&&I){S=!0,x+=T;continue}if(!I){if(T==="/"&&k[C+1]==="/")break;if(T==="/"&&k[C+1]==="*"){C+=2;while(C<k.length&&!(k[C]==="*"&&k[C+1]==="/"))C++;C++;continue}if(T==="'")I="single";else if(T==='"')I="double";else if(T==="`")I="template";else if(T==="<")P++;else if(T===">")P--;else if(T==="("||T==="["||T==="{")b++;else if(T===")"||T==="]"||T==="}")b--;else if(T===","&&b===0&&P===0){L.push(x),x="";continue}}else if(I==="single"&&T==="'"||I==="double"&&T==='"'||I==="template"&&T==="`")I=null;x+=T}if(x)L.push(x);for(let C of L){let T=C.trim();if(!T)continue;let R=T.match(/^([$A-Z_][\w$]*)/i),D=[];if(R)D.push(R[1]);else if(T.startsWith("{")||T.startsWith("[")){let f=T[0],h=f==="{"?"}":"]",o=0,u=-1,p=null,v=!1;for(let g=0;g<T.length;g++){let d=T[g];if(v){v=!1;continue}if(d==="\\"&&p){v=!0;continue}if(!p){if(d==="'"||d==='"'||d==="`")p=d==="'"?"single":d==='"'?"double":"template";else if(d===f)o++;else if(d===h){if(o--,o===0){u=g;break}}}else if(p==="single"&&d==="'"||p==="double"&&d==='"'||p==="template"&&d==="`")p=null}if(u>0){let g=T.slice(1,u),d=[],$0="",K0=0,c=null,s=!1;for(let a=0;a<g.length;a++){let r=g[a];if(s){s=!1,$0+=r;continue}if(r==="\\"&&c){s=!0,$0+=r;continue}if(!c){if(r==="'"||r==='"'||r==="`"){c=r==="'"?"single":r==='"'?"double":"template",$0+=r;continue}if(r==="("||r==="{"||r==="[")K0++;if(r===")"||r==="}"||r==="]")K0--;if(r===","&&K0===0){d.push($0.trim()),$0="";continue}}else if(c==="single"&&r==="'"||c==="double"&&r==='"'||c==="template"&&r==="`")c=null;$0+=r}if($0.trim())d.push($0.trim());for(let a of d){if(a.startsWith("...")){let M0=a.slice(3).match(/^([$A-Z_][\w$]*)/i);if(M0)D.push(M0[1]);continue}let r=a.indexOf(":");if(r!==-1){let M0=a.slice(r+1).trim(),_0=0;for(let h0=0;h0<M0.length;h0++){let R0=M0[h0];if(R0==="("||R0==="{"||R0==="[")_0++;else if(R0===")"||R0==="}"||R0==="]")_0--;else if(R0==="="&&_0===0){M0=M0.slice(0,h0).trim();break}}let L1=M0.match(/^([$A-Z_][\w$]*)/i);if(L1)D.push(L1[1])}else{let M0=a,_0=0;for(let h0=0;h0<M0.length;h0++){let R0=M0[h0];if(R0==="("||R0==="{"||R0==="[")_0++;else if(R0===")"||R0==="}"||R0==="]")_0--;else if(R0==="="&&_0===0){M0=M0.slice(0,h0).trim();break}}let L1=M0.match(/^([$A-Z_][\w$]*)/i);if(L1)D.push(L1[1])}}}}for(let f of D){if(Q.test(f))continue;let h=`${U.slice(0,j).join(`
61
+ `,Z);z(Z+2,G<0?$.length:G),Z=G<0?$.length:G;continue}if(Q==="/"&&$[Z+1]==="*"){let G=$.indexOf("*/",Z+2);z(Z+2,G<0?$.length:G),Z=G<0?$.length:G+2;continue}Z+=1}return J.join("")}var n0={meta:{docs:"Report variables and parameters that are declared/assigned but never used"},check:($,J)=>{if(J.filePath.endsWith("/no-unused-vars.ts"))return[];if(J.filePath.endsWith(".d.ts"))return[];let Z=[],X=J.options||{},Y=typeof X.varsIgnorePattern==="string"?X.varsIgnorePattern:"^_",z=typeof X.argsIgnorePattern==="string"?X.argsIgnorePattern:"^_",Q=new RegExp(Y,"u"),G=new RegExp(z,"u"),q=z2($),U=q.split(/\r?\n/),W=q,K=Array(U.length).fill(!1);(()=>{let j=[],O=!1,v=!1,y=!1,C=!1,k=!1,P="",L=()=>{if(P==="")return!0;if("=([{,;!&|?:+-*/%^~<>".includes(P))return!0;return!1};for(let I=0;I<U.length;I++){K[I]=j.length>0&&j[j.length-1]===-1;let f=U[I];for(let S=0;S<f.length;S++){let N=f[S];if(C){if(N==="*"&&S+1<f.length&&f[S+1]==="/")C=!1,S++;continue}if(k){k=!1;continue}let R=j.length>0&&j[j.length-1]===-1,D=j.length>0&&j[j.length-1]>=0;if(N==="\\"&&(O||v||y||R)){k=!0;continue}if(O){if(N==="'")O=!1;continue}if(v){if(N==='"')v=!1;continue}if(y){if(N==="["){let g=1,x=S+1;while(x<f.length){let p=f[x];if(p==="\\"){x+=2;continue}if(p==="]"){if(g--,g===0)break}x++}S=x;continue}if(N==="/"){y=!1;while(S+1<f.length&&/[gimsuvy]/.test(f[S+1]))S++}continue}if(R){if(N==="`")j.pop();else if(N==="$"&&S+1<f.length&&f[S+1]==="{")j.push(0),S++;continue}if(N==="/"&&S+1<f.length&&f[S+1]==="/")break;if(N==="/"&&S+1<f.length&&f[S+1]==="*"){C=!0,S++;continue}if(D){if(N==="`")j.push(-1),P="";else if(N==="'")O=!0,P="'";else if(N==='"')v=!0,P='"';else if(N==="{")j[j.length-1]++,P="{";else if(N==="}"){let g=j[j.length-1];if(g>0)j[j.length-1]=g-1;else j.pop();P="}"}else if(N==="/"&&L())y=!0;else if(!/\s/.test(N))P=N;continue}if(N==="`")j.push(-1),P="";else if(N==="'")O=!0,P="'";else if(N==='"')v=!0,P='"';else if(N==="/"&&L())y=!0;else if(!/\s/.test(N))P=N}}})();let V=new RegExp("^\\s*(?:const|let|var)\\s+(.+?);?\\s*$");for(let j=0;j<U.length;j++){if(K[j])continue;let O=U[j],v=O.match(V);if(!v)continue;let y=v[1],C=[],k="",P=0,L=0,I=null,f=!1;for(let S=0;S<y.length;S++){let N=y[S];if(f){f=!1,k+=N;continue}if(N==="\\"&&I){f=!0,k+=N;continue}if(!I){if(N==="/"&&y[S+1]==="/")break;if(N==="/"&&y[S+1]==="*"){S+=2;while(S<y.length&&!(y[S]==="*"&&y[S+1]==="/"))S++;S++;continue}if(N==="'")I="single";else if(N==='"')I="double";else if(N==="`")I="template";else if(N==="<")L++;else if(N===">")L--;else if(N==="("||N==="["||N==="{")P++;else if(N===")"||N==="]"||N==="}")P--;else if(N===","&&P===0&&L===0){C.push(k),k="";continue}}else if(I==="single"&&N==="'"||I==="double"&&N==='"'||I==="template"&&N==="`")I=null;k+=N}if(k)C.push(k);for(let S of C){let N=S.trim();if(!N)continue;let R=N.match(/^([$A-Z_][\w$]*)/i),D=[];if(R)D.push(R[1]);else if(N.startsWith("{")||N.startsWith("[")){let g=N[0],x=g==="{"?"}":"]",p=0,b=-1,m=null,u=!1;for(let n=0;n<N.length;n++){let c=N[n];if(u){u=!1;continue}if(c==="\\"&&m){u=!0;continue}if(!m){if(c==="'"||c==='"'||c==="`")m=c==="'"?"single":c==='"'?"double":"template";else if(c===g)p++;else if(c===x){if(p--,p===0){b=n;break}}}else if(m==="single"&&c==="'"||m==="double"&&c==='"'||m==="template"&&c==="`")m=null}if(b>0){let n=N.slice(1,b),c=[],$0="",V0=0,d=null,a=!1;for(let l=0;l<n.length;l++){let o=n[l];if(a){a=!1,$0+=o;continue}if(o==="\\"&&d){a=!0,$0+=o;continue}if(!d){if(o==="'"||o==='"'||o==="`"){d=o==="'"?"single":o==='"'?"double":"template",$0+=o;continue}if(o==="("||o==="{"||o==="[")V0++;if(o===")"||o==="}"||o==="]")V0--;if(o===","&&V0===0){c.push($0.trim()),$0="";continue}}else if(d==="single"&&o==="'"||d==="double"&&o==='"'||d==="template"&&o==="`")d=null;$0+=o}if($0.trim())c.push($0.trim());for(let l of c){if(l.startsWith("...")){let M0=l.slice(3).match(/^([$A-Z_][\w$]*)/i);if(M0)D.push(M0[1]);continue}let o=l.indexOf(":");if(o!==-1){let M0=l.slice(o+1).trim(),_0=0;for(let h0=0;h0<M0.length;h0++){let R0=M0[h0];if(R0==="("||R0==="{"||R0==="[")_0++;else if(R0===")"||R0==="}"||R0==="]")_0--;else if(R0==="="&&_0===0){M0=M0.slice(0,h0).trim();break}}let L1=M0.match(/^([$A-Z_][\w$]*)/i);if(L1)D.push(L1[1])}else{let M0=l,_0=0;for(let h0=0;h0<M0.length;h0++){let R0=M0[h0];if(R0==="("||R0==="{"||R0==="[")_0++;else if(R0===")"||R0==="}"||R0==="]")_0--;else if(R0==="="&&_0===0){M0=M0.slice(0,h0).trim();break}}let L1=M0.match(/^([$A-Z_][\w$]*)/i);if(L1)D.push(L1[1])}}}}for(let g of D){if(Q.test(g))continue;let x=`${U.slice(0,j).join(`
62
62
  `)}
63
63
  ${U.slice(j+1).join(`
64
- `)}`;if(!new RegExp(`\\b${f}\\b`,"g").test(h))Z.push({filePath:J.filePath,line:j+1,column:Math.max(1,O.indexOf(f)+1),ruleId:"pickier/no-unused-vars",message:`'${f}' is assigned a value but never used. Allowed unused vars must match pattern: ${Y}`,severity:"error",help:`Either use this variable in your code, remove it, or prefix it with an underscore (_${f}) to mark it as intentionally unused`})}}}let A=(j)=>{let y=((x)=>{let b="",P=null,I=!1,S=0;for(let C=0;C<x.length;C++){let T=x[C];if(I){I=!1;continue}if(T==="\\"&&P){I=!0;continue}if(!P){if(T==="'")P="single";else if(T==='"')P="double";else if(T==="`")P="template";else if(T==="("||T==="{"||T==="[")S++;else if(T===")"||T==="}"||T==="]")S--;else if(T==="="&&S===0)return b}else if(P==="single"&&T==="'"||P==="double"&&T==='"'||P==="template"&&T==="`")P=null;b+=T}return b})(j);return((x)=>{let b="",P=0;while(P<x.length){let I=x[P];if(I===":"){P++;while(P<x.length&&/\s/.test(x[P]))P++;let S=0,C=0,T=null,R=!1;while(P<x.length){let D=x[P];if(R){R=!1,P++;continue}if(D==="\\"&&T){R=!0,P++;continue}if(!T){if(D==="'")T="single";else if(D==='"')T="double";else if(D==="`")T="template";else if(D==="<")C++;else if(D===">")C--;else if(D==="("||D==="{"||D==="[")S++;else if(D===")"||D==="}"||D==="]")if(S>0)S--;else break;else if(D===","&&S===0&&C===0)break}else if(T==="single"&&D==="'"||T==="double"&&D==='"'||T==="template"&&D==="`")T=null;P++}continue}b+=I,P++}return b})(y).split(/[^$\w]+/).filter((x)=>x&&x!=="undefined")},_=(j,O)=>{let y=!1,k=0,L=0,x=!1,b=0,P=null,I=!1,S=!0,C="",T=!1,R=!1,D=[],f=!1;for(let h=j;h<U.length;h++){let o=U[h],u=o,p=D.length>0&&D[D.length-1]===-1,v=-1,g=null,d=!1;if(!p)for(let c=0;c<o.length-1;c++){let s=o[c],a=o[c+1];if(d){d=!1;continue}if(s==="\\"&&g){d=!0;continue}if(!g){if(s==="'")g="single";else if(s==='"')g="double";else if(s==="`")g="template";else if(s==="/"&&a==="/"){v=c;break}}else if(g==="single"&&s==="'"||g==="double"&&s==='"'||g==="template"&&s==="`")g=null}if(v>=0)u=o.slice(0,v);let $0=(c)=>{let s="",a=0,r=null,M0=!1;while(a<c.length){let _0=c[a];if(M0){M0=!1,s+=_0,a++;continue}if(_0==="\\"&&r){M0=!0,s+=_0,a++;continue}if(!r){if(_0==="'")r="single";else if(_0==='"')r="double";else if(_0==="`")r="template";else if(_0==="/"){if(O8(c,a)){a++;while(a<c.length){if(c[a]==="\\"){a+=2;continue}if(c[a]==="/"){a++;while(a<c.length&&/[gimsuvy]/.test(c[a]))a++;break}a++}continue}}}else if(r==="single"&&_0==="'"||r==="double"&&_0==='"'||r==="template"&&_0==="`")r=null;s+=_0,a++}return s};if(!p)u=$0(u);let K0=0;if(!y){let c=-1,s=S?typeof O==="number"?O:0:0;if(S=!1,s>=u.length){let a=u.indexOf("=>");s=a>=0?a+2:0}for(let a=s;a<u.length;a++){let r=u[a];if(I){I=!1;continue}if(r==="\\"&&P){I=!0;continue}if(!P){if(r!==" "&&r!=="\t"&&r!==`
65
- `&&r!=="\r"&&r!=="{"&&r!=="}"&&L===0)C=r;if(r==="'")P="single";else if(r==='"')P="double";else if(r==="`")P="template";else if(r==="<")b++;else if(r===">")b=Math.max(0,b-1);else if(r==="{"){if(L===0){if(x&&b===0&&!kZ.has(C)){c=a;break}}L++}else if(r==="}"){if(L>0){if(L--,L===0)x=!0,C="}"}}}else if(P==="single"&&r==="'"||P==="double"&&r==='"'||P==="template"&&r==="`")P=null}if(c===-1){if(L>0&&kZ.has(C))continue;for(let a=s;a<u.length;a++)if(u[a]==="{"&&!P){c=a;break}}if(c===-1)continue;y=!0,k=1,K0=c+1,j=h}for(let c=K0;c<u.length;c++){let s=u[c];if(f){f=!1;continue}let a=D.length>0&&D[D.length-1]===-1,r=D.length>0&&D[D.length-1]>=0;if(s==="\\"&&(T||R||a)){f=!0;continue}if(T){if(s==="'")T=!1;continue}if(R){if(s==='"')R=!1;continue}if(a){if(s==="`")D.pop();else if(s==="$"&&c+1<u.length&&u[c+1]==="{")D[D.length-1]=0,c++;continue}if(r){if(s==="/"){if(O8(u,c)){c++;while(c<u.length){if(u[c]==="\\"){c+=2;continue}if(u[c]==="/"){while(c+1<u.length&&/[gimsuvy]/.test(u[c+1]))c++;break}c++}continue}}if(s==="`"){D.push(-1);continue}if(s==="'"){T=!0;continue}if(s==='"'){R=!0;continue}if(s==="{"){D[D.length-1]++;continue}if(s==="}")if(D[D.length-1]>0)D[D.length-1]--;else D[D.length-1]=-1;continue}if(s==="'")T=!0;else if(s==='"')R=!0;else if(s==="`")D.push(-1);else if(s==="{")k++;else if(s==="}"){if(k--,k===0)return{from:j,to:h}}}}return null},B=(j,O)=>{let y={parenDepth:0,braceDepth:0,bracketDepth:0,inTemplate:!1},k=(S)=>{for(let C=0;C<S.length;C++){let T=S[C];if(T==="`")y.inTemplate=!y.inTemplate;else if(T==="(")y.parenDepth++;else if(T===")")y.parenDepth--;else if(T==="{")y.braceDepth++;else if(T==="}")y.braceDepth--;else if(T==="[")y.bracketDepth++;else if(T==="]")y.bracketDepth--}},L=()=>y.parenDepth>0||y.braceDepth>0||y.bracketDepth>0||y.inTemplate,x=(S)=>/(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)$/.test(S.trimEnd()),b=(S)=>/^(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)/.test(S.trimStart()),P=U[j].slice(O+2);k(P);let I=j+1;while(I<U.length){let S=I===j+1?P:U[I-1];if(!(!P.trim()||L()||x(S)||b(U[I])))break;P+=`
66
- ${U[I]}`,k(U[I]),I++}return P},F=[],M=!1,N=!1,E=!1;for(let j=0;j<U.length;j++){let O=U[j];if(/^\s*\/\//.test(O))continue;if(K[j])continue;let y=O,k=null,L=!1,x=!1;for(let T=0;T<O.length-1;T++){let R=O[T],D=O[T+1];if(x){x=!1;continue}if(R==="\\"&&(k||L)){x=!0;continue}if(!k&&!L){if(R==="'")k="single";else if(R==='"')k="double";else if(R==="`")k="template";else if(R==="/"){if(O8(O,T))L=!0;else if(D==="/"){y=O.slice(0,T);break}}}else if(k){if(k==="single"&&R==="'"||k==="double"&&R==='"'||k==="template"&&R==="`")k=null}else if(L&&R==="/")L=!1}let I=((T)=>{let R="",D=0;while(D<T.length){if(T[D]==="/"){if(O8(T,D)){D++;while(D<T.length){if(T[D]==="\\"){D+=2;continue}if(T[D]==="/"){D++;while(D<T.length&&/[gimsuvy]/.test(T[D]))D++;break}D++}continue}}R+=T[D],D++}return R})(y).replace(/'(?:[^'\\]|\\.)*'/g,"''").replace(/"(?:[^"\\]|\\.)*"/g,'""');{let T="";for(let R=0;R<I.length;R++){let D=I[R];if(E){E=!1;let o=F.length>0&&F[F.length-1]===-1;T+=o?" ":D;continue}let f=F.length>0&&F[F.length-1]===-1,h=F.length>0&&F[F.length-1]>=0;if(D==="\\"&&(M||N||f)){E=!0,T+=f?" ":D;continue}if(M){if(D==="'")M=!1;T+=D;continue}if(N){if(D==='"')N=!1;T+=D;continue}if(f){if(D==="`")F.pop();else if(D==="$"&&R+1<I.length&&I[R+1]==="{")F[F.length-1]=0,T+=" ",R++;else T+=" ";continue}if(h){if(D==="`")F.push(-1),T+=" ";else if(D==="'")M=!0,T+=D;else if(D==='"')N=!0,T+=D;else if(D==="{")F[F.length-1]++,T+=D;else if(D==="}")if(F[F.length-1]>0)F[F.length-1]--,T+=D;else F[F.length-1]=-1,T+=" ";else T+=D;continue}if(D==="`")F.push(-1),T+=" ";else if(D==="'")M=!0,T+=D;else if(D==='"')N=!0,T+=D;else T+=D}I=T}let S=I.match(/\bfunction\b/);if(S){if(O.includes("function scanContent")||O.includes("function findMatching"))continue;if(I.slice(S.index+8).trimStart().startsWith(":"))continue;let R=I.slice(0,S.index).trimEnd();if(R.endsWith(".")||R.endsWith("?."))continue;let D=S.index,f=O.indexOf("(",D);if(f===-1)continue;let h=0,o=-1,u=j,p="";for(let $0=j;$0<U.length;$0++){let K0=$0===j?U[$0]:U[$0],c=$0===j?f:0;for(let s=c;s<K0.length;s++)if(K0[s]==="(")h++;else if(K0[s]===")"){if(h--,h===0){if(o=s,u=$0,j===$0)p=O.slice(f+1,o);else{p=O.slice(f+1);for(let a=j+1;a<$0;a++)p+=` ${U[a]}`;p+=` ${K0.slice(0,o)}`}break}}if(o!==-1)break}if(o===-1)continue;let v=A(p),g=_(u,o),d="";if(g)if(g.from===u){let $0=U[g.from],K0=$0.lastIndexOf("{"),c=K0>=0?$0.slice(K0+1):"";if(g.to>g.from)d=`${c}
67
- ${U.slice(g.from+1,g.to+1).join(`
68
- `)}`;else d=c}else d=U.slice(g.from,g.to+1).join(`
69
- `);for(let $0 of v){if(!$0||G.test($0)||$0==="undefined")continue;if(!new RegExp(`\\b${$0}\\b`,"g").test(d))Z.push({filePath:J.filePath,line:j+1,column:Math.max(1,O.indexOf($0)+1),ruleId:"pickier/no-unused-vars",message:`'${$0}' is defined but never used (function parameter). Allowed unused args must match pattern: ${z}`,severity:"error"})}continue}let C=O.indexOf("=>");if(C!==-1&&I.includes("=>")){let T=-1;for(let R=C-1;R>=0;R--){let D=O[R];if(D===")"){T=R;break}if(D!==" "&&D!=="\t"&&D!==`
70
- `&&D!==":"&&D!==">"&&!/\w/.test(D))break}if(T!==-1){let R=-1,D=1;for(let f=T-1;f>=0;f--){let h=O[f];if(h===")")D++;else if(h==="("){if(D--,D===0){R=f;break}}}if(R!==-1){let f=!1,h=0,o=0;for(let p=R-1;p>=0;p--){let v=O[p];if(v===">"){h++;continue}if(v==="<"){if(h>0){h--;continue}if(o===0){f=!0;break}continue}if(v===":"&&h===0&&o===0){f=!0;break}if(h>0)continue;if(v===",")continue;if(v===")"){o++;continue}if(v==="("){o--;continue}if(v==="|"||v==="&"){f=!0;break}if(v==="="||v==="{"||v==="["){if(o>=0)break;continue}if(v!==" "&&v!=="\t"&&!/[\w.]/.test(v)){if(o>=0)break}}if(!f){let p=O.slice(0,R);if(/^\s*(?:export\s+)?(?:declare\s+)?type\s+\w[\w$]*\s*(?:<[^>]*>)?\s*=\s*$/.test(p))f=!0;else if(/\bas\s+$/.test(p))f=!0}if(f)continue;let u=O.slice(R+1,T);if(!(u.trim()===""&&O.slice(Math.max(0,R-10),R).includes("async"))){let p=A(u);if(p.length>0){let v="";if(O.slice(C+2).trimStart().startsWith("{")){let d=_(j,C);if(d)if(d.from===j){let $0=U[d.from],K0=$0.indexOf("{",C),c=K0>=0?$0.slice(K0+1):"";if(d.to>d.from)v=`${c}
71
- ${U.slice(d.from+1,d.to+1).join(`
72
- `)}`;else v=c}else v=U.slice(d.from,d.to+1).join(`
73
- `)}else v=B(j,C);for(let d of p){if(!d||G.test(d)||d==="undefined")continue;if(!new RegExp(`\\b${d}\\b`,"g").test(v))Z.push({filePath:J.filePath,line:j+1,column:Math.max(1,O.indexOf(d)+1),ruleId:"pickier/no-unused-vars",message:`'${d}' is defined but never used (function parameter). Allowed unused args must match pattern: ${z}`,severity:"error"})}continue}}}}}{let T=/(?:^|[=,:({\s])\s*([$A-Z_][\w$]*)\s*=>/gi,R;while((R=T.exec(I))!==null){let D=R[1];if(!D||G.test(D)||D==="undefined")continue;let f=I.slice(0,R.index+R[0].indexOf(D)).trimEnd();if(/\)\s*:$/.test(f)||/\)\s*:\s*$/.test(f))continue;if(/\)\s*:\s*[$A-Z_][\w$]*\s+is$/i.test(f))continue;if(/^(?:string|number|boolean|void|never|any|unknown|object|bigint|symbol|undefined|null)$/.test(D))continue;let h=new RegExp(`\\b${D}\\s*=>`),o=O.match(h);if(!o)continue;let u=O.indexOf(o[0])+o[0].lastIndexOf("=>"),p="";if(O.slice(u+2).trimStart().startsWith("{")){let d=_(j,u);if(d)if(d.from===j){let $0=U[d.from],K0=$0.indexOf("{",u),c=K0>=0?$0.slice(K0+1):"";if(d.to>d.from)p=`${c}
74
- ${U.slice(d.from+1,d.to+1).join(`
75
- `)}`;else p=c}else p=U.slice(d.from,d.to+1).join(`
76
- `)}else p=B(j,u);if(!new RegExp(`\\b${D}\\b`,"g").test(p))Z.push({filePath:J.filePath,line:j+1,column:Math.max(1,O.indexOf(D)+1),ruleId:"pickier/no-unused-vars",message:`'${D}' is defined but never used (function parameter). Allowed unused args must match pattern: ${z}`,severity:"error"})}}}return Z},fix:($,J)=>{let Z=n0.check($,J);if(Z.length===0)return $;let X=Z.filter((K)=>K.message.includes("(function parameter)"));if(X.length===0)return $;let Y=$.split(/\r?\n/),z=new Set,Q=/(?:eslint|pickier)-disable-next-line\b([^*\n]*)/;for(let K=0;K<Y.length;K++){let H=Y[K].match(Q);if(!H)continue;let V=H[1].trim();if(V===""||/\bno-unused-vars\b/.test(V)||/\bpickier\/no-unused-vars\b/.test(V))z.add(K+2)}let G=new Map;for(let K of X){if(z.has(K.line))continue;let H=K.message.match(/^'([^']+)'/);if(!H)continue;let V=H[1];if(V.startsWith("_"))continue;let A=G.get(K.line);if(!A)A=new Set,G.set(K.line,A);A.add(V)}if(G.size===0)return $;let q=$.split(/\r?\n/);function U(K){let H=[],V=!1,A=!1,_=!1,B=-1;for(let F=0;F<K.length;F++){let M=K[F];if(_){_=!1;continue}if(M==="\\"&&(V||A||B>=0)){_=!0;continue}if(B>=0){if(M==="`")H.push([B,F]),B=-1;continue}if(V){if(M==="'")V=!1;continue}if(A){if(M==='"')A=!1;continue}if(M==="`")B=F;else if(M==="'")V=!0;else if(M==='"')A=!0}if(B>=0)H.push([B,K.length]);return H}let W=!1;for(let[K,H]of G){let V=K-1,A=q[V];if(A===void 0)continue;let _=U(A),B=(N)=>_.some(([E,j])=>N>E&&N<j),F=[];for(let N of H){let E=N.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),j=new RegExp(`(?<=[(,]\\s*)\\b${E}\\b(?=\\s*[,):=])`,"g"),O;while((O=j.exec(A))!==null){if(B(O.index))continue;F.push({start:O.index,end:O.index+N.length,name:N})}}if(F.length===0)continue;F.sort((N,E)=>E.start-N.start);let M=A;for(let N of F)M=`${M.slice(0,N.start)}_${N.name}${M.slice(N.end)}`;if(M!==A)q[V]=M,W=!0}return W?q.join(`
77
- `):$}};function i0($){let J=$.split(/\r?\n/),Z=Array(J.length).fill(!1),X=[],Y=!1,z=!1,Q=!1,G=!1,q=!1,U="",W=()=>{if(U==="")return!0;return"=([{,;!&|?:+-*/%^~<>".includes(U)};for(let K=0;K<J.length;K++){Z[K]=X.length>0&&X[X.length-1]===-1;let H=J[K];for(let V=0;V<H.length;V++){let A=H[V];if(G){if(A==="*"&&V+1<H.length&&H[V+1]==="/")G=!1,V++;continue}if(q){q=!1;continue}let _=X.length>0&&X[X.length-1]===-1,B=X.length>0&&X[X.length-1]>=0;if(A==="\\"&&(Y||z||Q||_)){q=!0;continue}if(Y){if(A==="'")Y=!1;continue}if(z){if(A==='"')z=!1;continue}if(Q){if(A==="["){let F=1,M=V+1;while(M<H.length){let N=H[M];if(N==="\\"){M+=2;continue}if(N==="]"){if(F--,F===0)break}M++}V=M;continue}if(A==="/"){Q=!1;while(V+1<H.length&&/[gimsuvy]/.test(H[V+1]))V++}continue}if(_){if(A==="`")X.pop();else if(A==="$"&&V+1<H.length&&H[V+1]==="{")X.push(0),V++;continue}if(A==="/"&&V+1<H.length&&H[V+1]==="/")break;if(A==="/"&&V+1<H.length&&H[V+1]==="*"){G=!0,V++;continue}if(B){if(A==="`")X.push(-1),U="";else if(A==="'")Y=!0,U="'";else if(A==='"')z=!0,U='"';else if(A==="{")X[X.length-1]++,U="{";else if(A==="}"){let F=X[X.length-1];if(F>0)X[X.length-1]=F-1;else X.pop();U="}"}else if(A==="/"&&W())Q=!0;else if(!/\s/.test(A))U=A;continue}if(A==="`")X.push(-1),U="";else if(A==="'")Y=!0,U="'";else if(A==='"')z=!0,U='"';else if(A==="/"&&W())Q=!0;else if(!/\s/.test(A))U=A}}return Z}function X2($,J){let Z=[],X=0,Y=0,z=null,Q=!1;for(let G=0;G<$.length;G++){let q=$[G];if(Q){Q=!1;continue}if(q==="\\"&&z){Q=!0;continue}if(!z){if(q==="'")z="single";else if(q==='"')z="double";else if(q==="`")z="template";else if(q==="("||q==="{"||q==="[")X++;else if(q===")"||q==="}"||q==="]")X--;else if(q===J&&X===0)Z.push($.slice(Y,G)),Y=G+1}else if(z==="single"&&q==="'"||z==="double"&&q==='"'||z==="template"&&q==="`")z=null}return Z.push($.slice(Y)),Z}function Y2($){let J=0;for(let Z=0;Z<$.length;Z++){let X=$[Z];if(X==="{"||X==="("||X==="["||X==="<")J++;else if(X==="}"||X===")"||X==="]"||X===">")J--;else if(X==="="&&J===0&&$[Z+1]!=="="&&$[Z-1]!=="!"&&$[Z-1]!=="<"&&$[Z-1]!==">")return Z}return-1}function z2($,J){let Z=new RegExp(`\\b${J}\\b`),X=0,Y=null,z=!1;while(X<$.length){let Q=$[X];if(z){z=!1,X++;continue}if(Q==="\\"&&Y){z=!0,X++;continue}if(Y){if(Y==="single"&&Q==="'"||Y==="double"&&Q==='"'||Y==="template"&&Q==="`")Y=null;X++;continue}if(Q==="'"){Y="single",X++;continue}if(Q==='"'){Y="double",X++;continue}if(Q==="`"){Y="template",X++;continue}if(Q==="["||Q==="{"){let G=Q,q=Q==="["?"]":"}",U=1,W=X+1;while(W<$.length&&U>0){let K=$[W];if(K==="\\"){W+=2;continue}if(K===G)U++;else if(K===q)U--;if(U===0)break;W++}if(U===0&&W<$.length){let K=W+1;while(K<$.length&&($[K]===" "||$[K]==="\t"||$[K]==="\r"||$[K]===`
78
- `))K++;if($[K]==="="&&$[K+1]!=="="&&$[K+1]!==">"){let H=$.slice(X+1,W);if(Z.test(H)){let V=new RegExp(`\\b${J}\\b\\s*:`),A=new RegExp(`:\\s*\\b${J}\\b`);if(G==="{"){if(!(V.test(H)&&!A.test(H)&&!new RegExp(`(?:^|[\\s,{])\\s*${J}\\s*(?:,|\\s*=|\\s*})`).test(H)))return!0}else return!0}}}X=W+1;continue}X++}return!1}function fZ($,J){let Z=new RegExp("^\\s*(?:let|var)\\s+(.+?);?\\s*$"),X=$.match(Z);if(!X)return null;let Y=X[1],z=Y2(Y);if(z>=0){let q=Y.indexOf(":");if(q>=0&&q<z)Y=Y.slice(0,q)+Y.slice(z)}let Q=X2(Y,","),G=[];for(let q of Q){let U=q.trim();if(!U)continue;if(U.match(/^[{[]/))return null;let K=U.match(/^([$A-Z_][\w$]*)/i);if(!K)return null;let H=K[1];if(!/=/.test(U))return null;let A=J.indexOf($),_=J.slice(A+$.length),F=`\\b${H}\\s*(?:${["=","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","^=","|="].map((k)=>k.replace(/[|\\^$*+?.(){}[\]]/g,(L)=>`\\${L}`)).join("|")})`,M=new RegExp(F).test(_),N=new RegExp(`(?:^|[^$w])(?:\\+\\+|--)\\s*${H}\\b|\\b${H}\\s*(?:\\+\\+|--)`).test(_),E=z2(_,H),j=U.indexOf("="),O=j>=0?U.slice(j+1):"",y=new RegExp(F).test(O);G.push({name:H,fixable:!M&&!N&&!E&&!y})}return G}var L8={meta:{docs:"Suggest 'const' for variables that are never reassigned (heuristic)"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=i0($);for(let z=0;z<X.length;z++){if(Y[z])continue;let Q=X[z],G=fZ(Q,$);if(!G)continue;for(let{name:q,fixable:U}of G){if(!U)continue;let W=Q.search(new RegExp(`\\b${q.replace(/\$/g,"\\$")}\\b`)),K=W!==-1?W:Q.indexOf(q);Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,K+1),ruleId:"prefer-const",message:`'${q}' is never reassigned. Use 'const' instead`,severity:"error",help:`Change 'let ${q}' to 'const ${q}' since the variable is never reassigned. This makes your code more predictable and prevents accidental mutations`})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=i0($),X=new Set,Y=/(?:eslint|pickier)-disable-next-line\b([^*\n]*)/;for(let Q=0;Q<J.length;Q++){let G=J[Q].match(Y);if(!G)continue;let q=G[1].trim();if(q===""||/\bprefer-const\b/.test(q))X.add(Q+2)}let z=!1;for(let Q=0;Q<J.length;Q++){if(X.has(Q+1))continue;if(Z[Q])continue;let G=J[Q];if(!/^\s*let\b/.test(G))continue;let q=fZ(G,$);if(!q||q.length===0)continue;if(!q.every((W)=>W.fixable))continue;let U=G.replace(/^(\s*)let(\s+)/,"$1const$2");if(U!==G)J[Q]=U,z=!0}return z?J.join(`
79
- `):$}};var gZ={meta:{docs:"Prefer object spread ({...obj}) over Object.assign() for object composition"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/^\s*\/\//.test(z))continue;let Q=z.indexOf("//"),G=Q>=0?z.slice(0,Q):z,q=G.matchAll(/\bObject\.assign\s*\(/g);for(let U of q){let W=U.index,K=G.slice(0,W),H=(K.match(/'/g)||[]).length,V=(K.match(/"/g)||[]).length,A=(K.match(/`/g)||[]).length;if(H%2!==0||V%2!==0||A%2!==0)continue;let _=W+13,B=G.slice(_),F=-1,M=1,N=0,E=0,j=null,O=!1;for(let k=1;k<B.length;k++){let L=B[k];if(O){O=!1;continue}if(L==="\\"&&j){O=!0;continue}if(!j){if(L==="'")j="single";else if(L==='"')j="double";else if(L==="`")j="template";else if(L==="(")M++;else if(L===")"){if(M--,M===0)break}else if(L==="{")N++;else if(L==="}")N--;else if(L==="[")E++;else if(L==="]")E--;else if(L===","&&M===1&&N===0&&E===0){F=k;break}}else if(j==="single"&&L==="'"||j==="double"&&L==='"'||j==="template"&&L==="`")j=null}if(F===-1)continue;let y=B.slice(1,F).trim();if(y==="{}")Z.push({filePath:J.filePath,line:Y+1,column:W+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(y==="{}"||/^\{.*\}$/.test(y))Z.push({filePath:J.filePath,line:Y+1,column:W+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 Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[];for(let X=0;X<J.length;X++){let Y=J[X];Y=Y.replace(/\bObject\.assign\s*\(\s*\{\}\s*,\s*([^)]+)\)/g,(z,Q)=>{return`{${Q.split(",").map((q)=>q.trim()).map((q)=>`...${q}`).join(", ")}}`}),Z.push(Y)}return Z.join(`
80
- `)}};function Q2($,J){let Z=!1,X=!1,Y=!1;for(let z=0;z<J;z++){let Q=$[z];if(Q==="\\"){z++;continue}if(Q==="'"&&!X&&!Y)Z=!Z;else if(Q==='"'&&!Z&&!Y)X=!X;else if(Q==="`"&&!Z&&!X)Y=!Y}return Z||X||Y}var P8={meta:{docs:"Prefer template literals over string concatenation",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(Q.startsWith("//")||Q.startsWith("/*")||Q.startsWith("*")||Q.startsWith("import"))continue;let G=/(['"`][^'"`]*['"`])\s*\+\s*([a-z_$][\w$]*)/i,q=/([a-z_$][\w$]*)\s*\+\s*(['"`][^'"`]*['"`])/i,U=Q.match(G)||Q.match(q);if(U){let W=z.indexOf("//"),K=z.indexOf(U[0]);if(W>=0&&K>W)continue;if(Q2(z,K))continue;let H=!!Q.match(q),V=!!Q.match(G);if(H&&!V){if(Q.slice(Q.indexOf(U[0])+U[0].length).startsWith("."))continue}Z.push({filePath:J.filePath,line:Y+1,column:K+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 Z}};var pZ={name:"general",rules:{"array-callback-return":w(M$),"constructor-super":w(j$),"for-direction":w(N$),"getter-return":w(T$),"no-async-promise-executor":w(E$),"no-compare-neg-zero":w(D$),"no-cond-assign":w(R$),"no-const-assign":w(O$),"no-constant-condition":w(L$),"no-constructor-return":w(SZ),"no-dupe-class-members":w(P$),"no-dupe-keys":w(y1),"no-duplicate-case":w(C$),"no-empty-pattern":w(I$),"no-fallthrough":w(S$),"no-irregular-whitespace":w(vZ),"no-loss-of-precision":w(v$),"no-new":w(yZ),"no-regex-spaces":w(bZ),"no-promise-executor-return":w(y$),"no-redeclare":w(b$),"no-self-assign":w(b1),"no-self-compare":w(k$),"no-sparse-arrays":w(f$),"no-undef":w(g$),"no-unsafe-negation":w(x$),"no-unreachable":w(p$),"no-unused-vars":w(n0),"no-useless-catch":w(h$),"prefer-const":w(L8),"prefer-object-spread":w(gZ),"prefer-template":w(P8),"use-isnan":w(u$),"valid-typeof":w(m$)}};var g1={npm:"registry.npmjs.org",yarn:"registry.yarnpkg.com",verdaccio:"registry.verdaccio.org"};function xZ($){let J=$.split("/").pop()||"";if(J==="package-lock.json")return"npm";if(J==="yarn.lock")return"yarn";if(J==="bun.lockb"||J==="bun.lock")return"bun";return null}function g0($,J){let Z=xZ(J);if(!Z)return!1;if(Z==="npm")try{let X=JSON.parse($);return"lockfileVersion"in X||"dependencies"in X||"packages"in X}catch{return!1}if(Z==="yarn")return $.startsWith("#")||$.includes("__metadata:")||$.includes('resolved "');if(Z==="bun")try{let X=JSON.parse($);return"lockfileVersion"in X||"packages"in X}catch{return!1}return!1}function G2($){let J=new Map,Z=JSON.parse($);if((Z.lockfileVersion||1)>=2&&Z.packages)for(let[Y,z]of Object.entries(Z.packages)){if(!Y||Y==="")continue;let Q=Y.replace(/^node_modules\//,"").replace(/\/node_modules\//g,"/"),G=Q.split("/node_modules/").pop()||Q;J.set(Y,{name:G,version:z.version||"",resolved:z.resolved,integrity:z.integrity})}else if(Z.dependencies)hZ(Z.dependencies,J,"");return{type:"npm",packages:J}}function hZ($,J,Z){for(let[X,Y]of Object.entries($)){let z=Z?`${Z}/${X}`:X;if(J.set(z,{name:X,version:Y.version||"",resolved:Y.resolved,integrity:Y.integrity}),Y.dependencies)hZ(Y.dependencies,J,z)}}function q2($){let J=new Map,Z=$.includes("__metadata:"),X=Z?"yarn-berry":"yarn",Y=$.split(`
81
- `),z="",Q={};for(let G of Y){if(G.startsWith("#")||G.trim()==="")continue;if(!G.startsWith(" ")&&G.includes("@")&&G.endsWith(":")){if(z&&(Q.resolved||Q.integrity))J.set(z,Q);if(z=G.slice(0,-1).trim(),z.startsWith('"')&&z.endsWith('"'))z=z.slice(1,-1);let q=z.match(/^(@?[^@]+)@/);Q={name:q?q[1]:z.split("@")[0],version:""}}else if(G.startsWith(" ")||G.startsWith("\t")){let q=G.trim();if(q.startsWith("version")){let U=q.match(/version[:\s]+"?([^"]+)"?/);if(U)Q.version=U[1]}else if(q.startsWith("resolved")){let U=q.match(/resolved[:\s]+"?([^"]+)"?/);if(U)Q.resolved=U[1]}else if(q.startsWith("resolution:")&&Z){let U=q.match(/resolution[:\s]+"?([^"]+)"?/);if(U)Q.resolved=U[1]}else if(q.startsWith("integrity")||q.startsWith("checksum")){let U=q.match(/(integrity|checksum)[:\s]+"?([^"]+)"?/);if(U)Q.integrity=U[2]}}}if(z&&(Q.resolved||Q.integrity))J.set(z,Q);return{type:X,packages:J}}function U2($){let J=new Map,Z=JSON.parse($);if(Z.packages)for(let[X,Y]of Object.entries(Z.packages)){if(!X||X==="")continue;if(Array.isArray(Y)){let[z,Q,G,q]=Y,U=X,W="";if(typeof z==="string"&&z.includes("@")){let K=z.lastIndexOf("@");if(K>0)U=z.substring(0,K),W=z.substring(K+1)}J.set(X,{name:U,version:W,resolved:Q||void 0,integrity:q||void 0})}else if(typeof Y==="object")J.set(X,{name:Y.name||X.split("@")[0],version:Y.version||"",resolved:Y.resolved,integrity:Y.integrity||Y.hash})}return{type:"bun",packages:J}}function p0($,J){let Z=xZ(J);if(!Z)return null;try{switch(Z){case"npm":return G2($);case"yarn":return q2($);case"bun":return U2($);default:return null}}catch{return null}}function uZ($){try{return new URL($).hostname}catch{return null}}function C8($){try{return new URL($).protocol}catch{return null}}function mZ($){try{let Z=new URL($).pathname,X=Z.indexOf("/-/");if(X===-1)return null;let Y=Z.substring(1,X);if(Y.startsWith("@"))return Y;return Y}catch{return null}}function dZ($){if(!$)return null;let J=$.match(/^(sha\d+)-/);return J?J[1]:null}function oZ($){return $.map((J)=>{let Z=J.toLowerCase();return g1[Z]||J})}var rZ={meta:{docs:"Ensure all packages are from allowed registry hosts",recommended:!0},check($,J){let Z=[];if(!g0($,J.filePath))return Z;let X=p0($,J.filePath);if(!X)return Z;let Y=J.options||{},z=Y.allowedHosts||["npm","yarn"],Q=Y.emptyHostname!==!1,G=oZ(z),q=$.split(`
82
- `);for(let[U,W]of X.packages){if(!W.resolved){if(!Q){let H=cZ(q,U);Z.push({filePath:J.filePath,line:H,column:1,ruleId:"lockfile/validate-host",message:`Package "${W.name}" has no resolved URL`,severity:"error",help:"All packages should have a resolved URL from an allowed registry."})}continue}let K=uZ(W.resolved);if(!K)continue;if(!G.includes(K)){let H=cZ(q,U),V=z.map((A)=>g1[A.toLowerCase()]||A).join(", ");Z.push({filePath:J.filePath,line:H,column:1,ruleId:"lockfile/validate-host",message:`Invalid host for package "${W.name}": expected one of [${V}], got "${K}"`,severity:"error",help:`Package is resolving from an unauthorized registry. This could indicate a supply chain attack. Allowed hosts: ${V}`})}}return Z}};function cZ($,J){for(let Z=0;Z<$.length;Z++)if($[Z].includes(J)||$[Z].includes(`"${J}"`))return Z+1;return 1}var lZ={meta:{docs:"Ensure all packages use HTTPS protocol",recommended:!0},check($,J){let Z=[];if(!g0($,J.filePath))return Z;let X=p0($,J.filePath);if(!X)return Z;let Y=$.split(`
83
- `);for(let[z,Q]of X.packages){if(!Q.resolved)continue;let G=C8(Q.resolved);if(!G)continue;if(G!=="https:"){let q=W2(Y,z);Z.push({filePath:J.filePath,line:q,column:1,ruleId:"lockfile/validate-https",message:`Package "${Q.name}" uses insecure protocol: "${G}" instead of "https:"`,severity:"error",help:"All packages should be downloaded over HTTPS to prevent man-in-the-middle attacks."})}}return Z}};function W2($,J){for(let Z=0;Z<$.length;Z++)if($[Z].includes(J)||$[Z].includes(`"${J}"`))return Z+1;return 1}var aZ={meta:{docs:"Ensure all packages use strong integrity hashes (SHA512)",recommended:!0},check($,J){let Z=[];if(!g0($,J.filePath))return Z;let X=p0($,J.filePath);if(!X)return Z;let Y=J.options||{},z=Y.requiredAlgorithm||"sha512",Q=new Set(Y.exclude||[]),G={sha1:1,sha256:2,sha384:3,sha512:4},q=G[z]||4,U=$.split(`
84
- `);for(let[W,K]of X.packages){if(Q.has(K.name))continue;if(!K.integrity)continue;let H=dZ(K.integrity);if(!H)continue;if((G[H.toLowerCase()]||0)<q){let A=K2(U,W);Z.push({filePath:J.filePath,line:A,column:1,ruleId:"lockfile/validate-integrity",message:`Package "${K.name}" uses weak hash algorithm: "${H}" (required: ${z})`,severity:"error",help:`Weak hash algorithms are susceptible to collision attacks. Upgrade to ${z} by regenerating your lockfile with a recent package manager.`})}}return Z}};function K2($,J){for(let Z=0;Z<$.length;Z++)if($[Z].includes(J)||$[Z].includes(`"${J}"`))return Z+1;return 1}var sZ={meta:{docs:"Ensure package names match their resolved URLs",recommended:!0},check($,J){let Z=[];if(!g0($,J.filePath))return Z;let X=p0($,J.filePath);if(!X)return Z;let z=(J.options||{}).aliases||{},Q=Object.values(g1),G=$.split(`
85
- `);for(let[q,U]of X.packages){if(!U.resolved)continue;let W=!1;try{let A=new URL(U.resolved);W=Q.includes(A.hostname)}catch{continue}if(!W)continue;let K=mZ(U.resolved);if(!K)continue;let H=U.name,V=z[H]||H;if(K!==V){let A=H2(G,q);Z.push({filePath:J.filePath,line:A,column:1,ruleId:"lockfile/validate-package-names",message:`Package name mismatch: "${H}" resolves to "${K}"`,severity:"error",help:`This could indicate a package substitution attack. The lockfile entry is for "${H}" but the resolved URL points to "${K}".`})}}return Z}};function H2($,J){for(let Z=0;Z<$.length;Z++)if($[Z].includes(J)||$[Z].includes(`"${J}"`))return Z+1;return 1}var nZ={meta:{docs:"Ensure all packages use allowed URL schemes",recommended:!0},check($,J){let Z=[];if(!g0($,J.filePath))return Z;let X=p0($,J.filePath);if(!X)return Z;let Q=((J.options||{}).allowedSchemes||["https:","git+https:","git+ssh:"]).map((q)=>q.endsWith(":")?q:`${q}:`),G=$.split(`
86
- `);for(let[q,U]of X.packages){if(!U.resolved)continue;let W=C8(U.resolved);if(!W)continue;if(!Q.includes(W)){let K=V2(G,q);Z.push({filePath:J.filePath,line:K,column:1,ruleId:"lockfile/validate-scheme",message:`Package "${U.name}" uses disallowed URL scheme: "${W}"`,severity:"error",help:`Only the following URL schemes are allowed: ${Q.join(", ")}. Using "${W}" could be a security risk.`})}}return Z}};function V2($,J){for(let Z=0;Z<$.length;Z++)if($[Z].includes(J)||$[Z].includes(`"${J}"`))return Z+1;return 1}var iZ={name:"lockfile",rules:{"validate-host":rZ,"validate-https":lZ,"validate-integrity":aZ,"validate-package-names":sZ,"validate-scheme":nZ}};var tZ={meta:{docs:"Fenced code blocks should be surrounded by blank lines"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z];if(/^(?:`{3,}|~{3,})/.test(Q.trim()))if(!Y){let q=z>0?X[z-1]:"";if(z>0&&q.trim().length>0){if(!/^:::/.test(q.trim()))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-fences",message:"Fenced code blocks should be surrounded by blank lines",severity:"error"})}Y=!0}else{let q=z+1<X.length?X[z+1]:"";if(z+1<X.length&&q.trim().length>0){if(!/^:::/.test(q.trim()))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-fences",message:"Fenced code blocks should be surrounded by blank lines",severity:"error"})}Y=!1}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[],X=!1;for(let Y=0;Y<J.length;Y++){let z=J[Y],Q=Y>0?J[Y-1]:"",G=/^(?:`{3,}|~{3,})/.test(z.trim());if(G)if(!X){if(Y>0&&Q.trim().length>0&&!/^:::/.test(Q.trim())&&Z.length>0)Z.push("");X=!0}else X=!1;if(Z.push(z),G&&!X&&Y+1<J.length){let q=J[Y+1];if(q.trim().length>0&&!/^:::/.test(q.trim()))Z.push("")}}return Z.join(`
87
- `)}};var eZ={meta:{docs:"Headings should be surrounded by blank lines"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z],G=z>0?X[z-1]:"",q=z+1<X.length?X[z+1]:"";if(/^(?:`{3,}|~{3,})/.test(Q.trim())){Y=!Y;continue}if(Y)continue;let U=/^#{1,6}\s/.test(Q),W=z+1<X.length&&/^(?:=+|-+)\s*$/.test(q)&&Q.trim().length>0;if(U){if(z>0&&G.trim().length>0)Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"});if(z+1<X.length&&q.trim().length>0&&!/^#{1,6}\s/.test(q))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"})}if(W){if(z>0&&G.trim().length>0)Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"});let K=z+2<X.length?X[z+2]:"";if(z+2<X.length&&K.trim().length>0)Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[],X=!1;for(let Y=0;Y<J.length;Y++){let z=J[Y],Q=Y>0?J[Y-1]:"",G=Y+1<J.length?J[Y+1]:"";if(/^(?:`{3,}|~{3,})/.test(z.trim())){X=!X,Z.push(z);continue}if(X){Z.push(z);continue}let q=/^#{1,6}\s/.test(z),U=Y+1<J.length&&/^(?:=+|-+)\s*$/.test(G)&&z.trim().length>0;if(q||U){if(Y>0&&Q.trim().length>0&&Z.length>0)Z.push("")}if(Z.push(z),q){if(Y+1<J.length&&G.trim().length>0&&!/^#{1,6}\s/.test(G))Z.push("")}if(Y>0&&/^(?:=+|-+)\s*$/.test(z)&&J[Y-1].trim().length>0){if((Y+1<J.length?J[Y+1]:"").trim().length>0)Z.push("")}}return Z.join(`
88
- `)}};var $J={meta:{docs:"Lists should be surrounded by blank lines"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q],q=Q>0?X[Q-1]:"";if(/^(?:`{3,}|~{3,})/.test(G.trim())){if(z=!z,Y)Y=!1;continue}if(z)continue;let U=/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(G),W=Y&&!U&&G.trim().length>0&&/^\s+/.test(G);if(U&&!Y){if(Y=!0,Q>0&&q.trim().length>0)Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"markdown/blanks-around-lists",message:"Lists should be surrounded by blank lines",severity:"error"})}else if(!U&&!W&&Y&&G.trim().length>0){if(Y=!1,/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(q))Z.push({filePath:J.filePath,line:Q,column:1,ruleId:"markdown/blanks-around-lists",message:"Lists should be surrounded by blank lines",severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[],X=!1,Y=!1,z=(Q)=>/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(Q);for(let Q=0;Q<J.length;Q++){let G=J[Q],q=Q>0?J[Q-1]:"";if(/^(?:`{3,}|~{3,})/.test(G.trim())){Y=!Y,X=!1,Z.push(G);continue}if(Y){Z.push(G);continue}let U=z(G),W=G.trim().length===0,K=X&&!U&&!W&&/^\s/.test(G);if(U&&!X){if(Q>0&&q.trim().length>0&&Z.length>0)Z.push("");X=!0}else if(!U&&!K&&!W&&X){if(X=!1,Z.length>0)Z.push("")}else if(W){let H=Q+1<J.length?J[Q+1]:"",V=z(H),A=/^\s+\S/.test(H);if(!V&&!A&&X)X=!1}Z.push(G)}return Z.join(`
89
- `)}};function m($){let J=new Set,Z=null,X=0,Y=!1,z=!1;for(let Q=0;Q<$.length;Q++){let G=$[Q],q=G.trim();if(Z===null){let H=q.match(/^(`{3,}|~{3,})(.*)$/);if(H){let V=H[1],A=H[2],_=V[0];if(_==="`"&&A.includes("`"));else{Z=_,X=V.length,J.add(Q),Y=!1,z=!1;continue}}}else{J.add(Q);let H=q.match(/^(`{3,}|~{3,})\s*$/);if(H&&H[1][0]===Z&&H[1].length>=X)Z=null,X=0;continue}let U=G.length-G.trimStart().length,W=/^\t/.test(G);if((U>=4||W)&&q.length>0){if(z||Y||Q===0)J.add(Q),z=!0;Y=z;continue}if(q.length===0){if(z)J.add(Q),Y=!0;else Y=!0;continue}z=!1,Y=!1}return J}function ZJ($,J,Z){let X=0,Y=0;while(X<$.length){if($[X]!=="`"){X++;continue}let z=0;while($[X+z]==="`")z++;let Q=X+z,G=-1;while(Q<$.length)if($[Q]==="`"){let q=0;while($[Q+q]==="`")q++;if(q===z){G=Q;break}Q+=q}else Q++;if(G===-1){X+=z;continue}if(Y<X)J($.slice(Y,X));Z($.slice(X,G+z)),X=G+z,Y=X}if(Y<$.length)J($.slice(Y))}function B1($,J){let Z="";return ZJ($,(X)=>{Z+=J(X)},(X)=>{Z+=X}),Z}function t0($){let J="";return ZJ($,(Z)=>{J+=Z},(Z)=>{J+=" ".repeat(Z.length)}),J}function JJ($){let J=m($),Z=[],X=0;for(let Y=0;Y<$.length;Y++){let z=$[Y];if(J.has(Y)||z.trim()===""){X=0,Z.push(z);continue}if(X===0){let q=t0(z),U=A2(q);if(!U){Z.push(q);continue}X=U.length,Z.push(q.slice(0,U.index)+" ".repeat(q.length-U.index));continue}let Q=new RegExp(`(?<!\`)\`{${X}}(?!\`)`).exec(z);if(!Q){Z.push(" ".repeat(z.length));continue}let G=Q.index+Q[0].length;X=0,Z.push(" ".repeat(G)+t0(z.slice(G)))}return Z}function A2($){let J=/(?<!`)(`+)(?!`)(?=[^`]*$)/.exec($);return J?{index:J.index,length:J[1].length}:null}function X1($){let J=new Set,Z=m($);for(let X=0;X<$.length;X++){if(Z.has(X))continue;let Y=$[X];if(!_2(Y))continue;if(X>0&&!Z.has(X-1)&&/\|/.test($[X-1])&&$[X-1].trim().length>0)J.add(X-1);J.add(X);for(let z=X+1;z<$.length;z++){if(Z.has(z))break;let Q=$[z];if(Q.trim().length===0||!/\|/.test(Q))break;J.add(z)}}return J}function _2($){let J=$.trim();if(!J.includes("|"))return!1;if(!/^[|\s:-]+$/.test(J))return!1;if(!/-{3,}/.test(J))return!1;return!0}var XJ={meta:{docs:"Tables should be surrounded by blank lines"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1,Q=X1(X);for(let G=0;G<X.length;G++){let q=X[G],U=G>0?X[G-1]:"";if(/^(?:`{3,}|~{3,})/.test(q.trim())){if(z=!z,Y)Y=!1;continue}if(z)continue;let W=Q.has(G)&&/\|/.test(q)&&q.trim().length>0;if(W&&!Y){if(Y=!0,G>0&&U.trim().length>0)Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"markdown/blanks-around-tables",message:"Tables should be surrounded by blank lines",severity:"error"})}else if(!W&&Y){if(Y=!1,q.trim().length>0)Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"markdown/blanks-around-tables",message:"Tables should be surrounded by blank lines",severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=m(J),X=X1(J),Y=[],z=!1;for(let G=0;G<J.length;G++){let q=J[G];if(Z.has(G)){Y.push(q);continue}let U=X.has(G)&&/\|/.test(q)&&q.trim().length>0;if(U&&!z){let W=Y.length-1;if(W>=0&&Y[W].trim().length>0)Y.push("");z=!0,Y.push(q);continue}if(!U&&z){if(z=!1,q.trim().length>0)Y.push("")}Y.push(q)}let Q=Y.join(`
90
- `);return Q!==$?Q:$}};var YJ={meta:{docs:"Code block style should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).style||"consistent",Q=null,G=!1;for(let q=0;q<X.length;q++){let U=X[q];if(/^(?:`{3,}|~{3,})/.test(U)){if(G=!G,z==="indented")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-block-style",message:"Expected indented code block style",severity:"error"});else if(z==="consistent"){if(Q===null)Q="fenced";else if(Q==="indented")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-block-style",message:"Code block style should be consistent throughout document",severity:"error"})}continue}if(G)continue;if(/^(?: {4}|\t)/.test(U)&&U.trim().length>0){let V=(q>0?X[q-1]:"").trim().length===0||q===0;if(V&&z==="fenced")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-block-style",message:"Expected fenced code block style",severity:"error"});else if(V&&z==="consistent"){if(Q===null)Q="indented";else if(Q==="fenced")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-block-style",message:"Code block style should be consistent throughout document",severity:"error"})}}}return Z}};function zJ($){let J=new Set,Z=null,X=0;for(let Y=0;Y<$.length;Y++){let z=$[Y].trim();if(Z===null){let Q=z.match(/^(`{3,}|~{3,})(.*)$/);if(Q){let G=Q[1][0];if(G==="`"&&Q[2].includes("`"))continue;Z=G,X=Q[1].length,J.add(Y)}}else{let Q=z.match(/^(`{3,}|~{3,})\s*$/);if(Q&&Q[1][0]===Z&&Q[1].length>=X)J.add(Y),Z=null,X=0}}return J}var QJ={meta:{docs:"Code fence style should be consistent (backtick or tilde)"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=zJ(X),Q=(J.options||{}).style||"consistent",G=null;for(let q of Y){let U=X[q],K=/^`{3,}/.test(U.trim())?"backtick":"tilde";if(Q==="backtick"||Q==="tilde"){if(K!==Q)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-fence-style",message:Q==="tilde"?"Expected tilde (~~~) code fence":"Expected backtick (```) code fence",severity:"error"})}else if(Q==="consistent"){if(G===null)G=K;else if(G!==K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-fence-style",message:"Code fence style should be consistent throughout document",severity:"error"})}}return Z},fix:($,J)=>{let X=(J.options||{}).style||"consistent",Y=$.split(/\r?\n/),z=zJ(Y),Q="backtick";if(X==="backtick"||X==="tilde")Q=X;else for(let W of z){Q=/^`{3,}/.test(Y[W].trim())?"backtick":"tilde";break}let G=Q==="backtick"?"`":"~",q=Q==="backtick"?/^(\s*)(~{3,})(.*)$/:/^(\s*)(`{3,})(.*)$/;return Y.map((W,K)=>{if(!z.has(K))return W;return W.replace(q,(H,V,A,_)=>`${V}${G.repeat(A.length)}${_}`)}).join(`
91
- `)}};var GJ={meta:{docs:"Commands in code blocks should not be prefixed with $ unless showing output"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=-1;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(/^(?:`{3,}|~{3,})/.test(G)){if(!Y)Y=!0,z=Q;else Y=!1;continue}if(Y&&/^\$\s+/.test(G.trim())){let q=!0,U=!1;for(let W=z+1;W<Q;W++){let K=X[W].trim();if(K.length>0){if(U=!0,!K.startsWith("$")){q=!1;break}}}if(q&&U)Z.push({filePath:J.filePath,line:Q+1,column:G.indexOf("$")+1,ruleId:"markdown/commands-show-output",message:"Dollar signs used before commands without showing output",severity:"warning"})}}return Z}};var qJ={meta:{docs:"Link text should be meaningful and descriptive"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=["click here","here","link","read more","more","this"],z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(/^(?:`{3,}|~{3,})/.test(G.trim())){z=!z;continue}if(z)continue;let U=G.replace(/``[^`]+``/g,(W)=>" ".repeat(W.length)).replace(/`[^`]+`/g,(W)=>" ".repeat(W.length)).matchAll(/\[([^\]]+)\]\([^)]+\)/g);for(let W of U){let K=W[1].toLowerCase().trim();if(Y.includes(K)){let H=W.index+1;Z.push({filePath:J.filePath,line:Q+1,column:H,ruleId:"markdown/descriptive-link-text",message:`Link text '${W[1]}' is not descriptive`,severity:"warning"})}}}return Z}};var L7="(?<!\\*)\\*(?!\\*)(?!\\s)([^*]*[^*\\s])\\*(?!\\*)",F2=new RegExp(L7),P7="(?<![A-Za-z0-9_])_(?!_)([^_]+)_(?![A-Za-z0-9_])",B2=new RegExp(P7),UJ={meta:{docs:"Emphasis style should be consistent (asterisk or underscore)"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).style||"consistent",Q=null,G=m(X),q=JJ(X);for(let U=0;U<X.length;U++){let W=X[U];if(G.has(U))continue;let K=q[U]??t0(W),H=K.matchAll(new RegExp(L7,"g"));for(let A of H)if(z==="underscore")Z.push({filePath:J.filePath,line:U+1,column:A.index+1,ruleId:"markdown/emphasis-style",message:"Expected underscore (_) for emphasis",severity:"error"});else if(z==="consistent"){if(Q===null)Q="asterisk";else if(Q==="underscore")Z.push({filePath:J.filePath,line:U+1,column:A.index+1,ruleId:"markdown/emphasis-style",message:"Emphasis style should be consistent throughout document",severity:"error"})}let V=K.matchAll(new RegExp(P7,"g"));for(let A of V)if(z==="asterisk")Z.push({filePath:J.filePath,line:U+1,column:A.index+1,ruleId:"markdown/emphasis-style",message:"Expected asterisk (*) for emphasis",severity:"error"});else if(z==="consistent"){if(Q===null)Q="underscore";else if(Q==="asterisk")Z.push({filePath:J.filePath,line:U+1,column:A.index+1,ruleId:"markdown/emphasis-style",message:"Emphasis style should be consistent throughout document",severity:"error"})}}return Z},fix:($,J)=>{let X=(J.options||{}).style||"consistent",Y=$.split(/\r?\n/),z=m(Y),Q="asterisk";if(X==="asterisk")Q="asterisk";else if(X==="underscore")Q="underscore";else if(X==="consistent"){let q=null,U=null;for(let K=0;K<Y.length;K++){if(z.has(K))continue;let H=t0(Y[K]);if(q===null){let V=H.match(F2);if(V)q={line:K,col:V.index}}if(U===null){let V=H.match(B2);if(V)U={line:K,col:V.index}}if(q&&U)break}if(q&&(!U||((K,H)=>K.line!==H.line?K.line-H.line:K.col-H.col)(q,U)<0))Q="asterisk";else if(U)Q="underscore"}let G=!1;for(let q=0;q<Y.length;q++){if(z.has(q))continue;let U=B1(Y[q],(W)=>Q==="asterisk"?W.replace(new RegExp(P7,"g"),"*$1*"):W.replace(new RegExp(L7,"g"),"_$1_"));if(U!==Y[q])Y[q]=U,G=!0}return G?Y.join(`
92
- `):$}};var WJ={meta:{docs:"Fenced code blocks should have a language specified"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++)if(X[Y].match(/^(?:`{3,}|~{3,})\s*$/)){let G=!0;for(let q=Y-1;q>=0;q--)if(/^(?:`{3,}|~{3,})/.test(X[q])){G=!1;break}if(G)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"markdown/fenced-code-language",message:"Fenced code blocks should have a language specified",severity:"error"})}return Z}};var KJ={meta:{docs:"First line in a file should be a top-level heading"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=-1;for(let q=0;q<X.length;q++)if(X[q].trim().length>0){Y=q;break}if(Y===-1)return Z;let z=X[Y],Q=/^#\s/.test(z),G=Y+1<X.length&&/^=+\s*$/.test(X[Y+1]);if(!Q&&!G)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"markdown/first-line-heading",message:"First line in a file should be a top-level heading",severity:"warning"});return Z}};var HJ={meta:{docs:"Heading levels should only increment by one level at a time"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X),z=0;for(let Q=0;Q<X.length;Q++){if(Y.has(Q))continue;let q=X[Q].match(/^(#{1,6})\s/);if(q){let U=q[1].length;if(z>0&&U>z+1)Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"markdown/heading-increment",message:`Heading level should not skip from h${z} to h${U}`,severity:"error"});z=U}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=m(J),X=0,Y=!1;for(let z=0;z<J.length;z++){if(Z.has(z))continue;let G=J[z].match(/^(#{1,6})(\s.*)$/);if(!G)continue;let q=G[1].length,U=X===0?q:Math.min(q,X+1);if(U!==q)J[z]="#".repeat(U)+G[2],Y=!0;X=U}return Y?J.join(`
93
- `):$}};var VJ={meta:{docs:"Headings must start at the beginning of the line"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z];if(/^(?:`{3,}|~{3,})/.test(Q.trim())){Y=!Y;continue}if(Y)continue;if(Q.match(/^(\s+)(#{1,6}\s)/))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/heading-start-left",message:"Headings must start at the beginning of the line",severity:"error"})}return Z},fix:($)=>{return $.split(/\r?\n/).map((X)=>{return X.replace(/^(\s+)(#{1,6}\s)/,"$2")}).join(`
94
- `)}};var AJ={meta:{docs:"Heading style should be consistent (atx, setext, or consistent)"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).style||"consistent",Q=null,G=m(X);for(let q=0;q<X.length;q++){if(G.has(q))continue;let U=X[q],W=q+1<X.length?X[q+1]:"",K=U.match(/^#{1,6}\s/),H=W.match(/^(?:=+|-+)\s*$/)&&U.trim().length>0&&!G.has(q+1);if(K){if(z==="setext")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/heading-style",message:"Expected setext style heading",severity:"error"});else if(z==="consistent"){if(Q===null)Q="atx";else if(Q==="setext")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/heading-style",message:"Heading style should be consistent throughout document",severity:"error"})}}else if(H){if(z==="atx")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/heading-style",message:"Expected atx style heading",severity:"error"});else if(z==="consistent"){if(Q===null)Q="setext";else if(Q==="atx")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/heading-style",message:"Heading style should be consistent throughout document",severity:"error"})}}}return Z},fix:($,J)=>{let X=(J.options||{}).style||"consistent",Y=$.split(/\r?\n/),z=m(Y),Q=X==="consistent"?null:X;if(Q===null)for(let U=0;U<Y.length;U++){if(z.has(U))continue;let W=Y[U],K=U+1<Y.length?Y[U+1]:"";if(/^#{1,6}\s/.test(W)){Q="atx";break}if(/^(?:=+|-+)\s*$/.test(K)&&W.trim().length>0&&!z.has(U+1)){Q="setext";break}}if(Q===null)return $;let G=[],q=!1;for(let U=0;U<Y.length;U++){let W=Y[U];if(z.has(U)){G.push(W);continue}let K=U+1<Y.length?Y[U+1]:"";if(Q==="atx"){let H=/^=+\s*$/.test(K),V=/^-+\s*$/.test(K),A=z.has(U+1);if((H||V)&&!A&&W.trim().length>0&&!/^#{1,6}\s/.test(W)){let _=H?"#":"##";G.push(`${_} ${W.trim()}`),U++,q=!0;continue}}if(Q==="setext"){let H=W.match(/^(#{1,2})\s+(.+?)\s*#*\s*$/);if(H){let V=H[1].length,A=H[2],_=(V===1?"=":"-").repeat(Math.max(3,A.length));G.push(A),G.push(_),q=!0;continue}}G.push(W)}return q?G.join(`
95
- `):$}};var _J={meta:{docs:"Horizontal rule style should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).style||"consistent",Q=null;for(let G=0;G<X.length;G++){let q=X[G].trim();if(q.match(/^([-*_])\1{2,}$/)){let W=q;if(z!=="consistent"&&q!==z)Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"markdown/hr-style",message:`Expected horizontal rule style '${z}'`,severity:"error"});else if(z==="consistent"){if(Q===null)Q=W;else if(Q!==W)Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"markdown/hr-style",message:"Horizontal rule style should be consistent throughout document",severity:"error"})}}}return Z}};var FJ={meta:{docs:"Lines should not exceed a specified length"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=J.options||{},z=Y.line_length||80,Q=Y.code_blocks!==!1,G=Y.tables!==!1,q=Y.headings!==!1,U=!1;for(let W=0;W<X.length;W++){let K=X[W];if(/^(?:`{3,}|~{3,})/.test(K)){U=!U;continue}if(U&&!Q)continue;if(!G&&/\|/.test(K))continue;if(!q&&/^#{1,6}\s/.test(K))continue;if(K.length>z)Z.push({filePath:J.filePath,line:W+1,column:z+1,ruleId:"markdown/line-length",message:`Line length exceeds ${z} characters (${K.length} characters)`,severity:"warning"})}return Z}};function w2($){return $.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s/g,"-")}var BJ={meta:{docs:"Link fragments should reference valid headings"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X),z=new Set;for(let Q=0;Q<X.length;Q++){if(Y.has(Q))continue;let q=X[Q].match(/^#{1,6}\s+(.+?)(?:\s*#+\s*)?$/);if(q){let U=q[1].trim();z.add(w2(U))}}for(let Q=0;Q<X.length;Q++){if(Y.has(Q))continue;let q=X[Q].matchAll(/\[[^\]]+\]\(#([^)]+)\)/g);for(let U of q){let W=U[1];if(!z.has(W)){let K=U.index+1;Z.push({filePath:J.filePath,line:Q+1,column:K,ruleId:"markdown/link-fragments",message:`Link fragment '#${W}' does not match any heading`,severity:"error"})}}}return Z}};var wJ={meta:{docs:"Link and image reference definitions should be used"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X),z=new Map;for(let G=0;G<X.length;G++){if(Y.has(G))continue;let U=X[G].match(/^\[([^\]]+)\]:\s*\S+/);if(U)z.set(U[1].toLowerCase(),G+1)}let Q=new Set;for(let G=0;G<X.length;G++){if(Y.has(G))continue;let q=X[G];if(q.match(/^\[(?:[^\]]+)\]:\s*\S+/))continue;let U=q.matchAll(/\[([^\]]+)\](?:\[([^\]]+)\])?(?!\()/g);for(let W of U){let K=(W[2]||W[1]).toLowerCase();Q.add(K)}}for(let[G,q]of z)if(!Q.has(G))Z.push({filePath:J.filePath,line:q,column:1,ruleId:"markdown/link-image-reference-definitions",message:`Unused reference definition '[${G}]'`,severity:"warning"});return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=m(J),X=new Map;for(let Q=0;Q<J.length;Q++){if(Z.has(Q))continue;let G=J[Q].match(/^\s*\[([^\]]+)\]:\s*\S+/);if(G)X.set(Q,G[1].toLowerCase())}if(X.size===0)return $;let Y=new Set;for(let Q=0;Q<J.length;Q++){if(Z.has(Q))continue;if(X.has(Q))continue;let q=J[Q].matchAll(/\[([^\]]+)\](?:\[([^\]]*)\])?(?!\()/g);for(let U of q){let W=(U[2]&&U[2].length>0?U[2]:U[1]).toLowerCase();Y.add(W)}}let z=new Set;for(let[Q,G]of X)if(!Y.has(G))z.add(Q);if(z.size===0)return $;return J.filter((Q,G)=>!z.has(G)).join(`
96
- `)}};var MJ={meta:{docs:"Link and image style should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X),Q=(J.options||{}).style||"consistent",G=Q==="consistent"?null:Q;if(G===null){let U=0,W=0,K=!1;for(let H=0;H<X.length;H++){if(Y.has(H))continue;let V=X[H];if(V.includes("<!--"))K=!0;if(V.includes("-->")){K=!1;continue}if(K)continue;if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(V))continue;let A=C7(V);U+=(A.match(/\[[^\]]+\]\([^)]+\)/g)||[]).length,W+=(A.match(/\[[^\]]+\]\[(?:[^\]]*)\]/g)||[]).length}G=W>U?"reference":"inline"}let q=!1;for(let U=0;U<X.length;U++){if(Y.has(U))continue;let W=X[U];if(W.includes("<!--"))q=!0;if(W.includes("-->")){q=!1;continue}if(q)continue;if(W.match(/^\[(?:[^\]]+)\]:\s*\S+/))continue;let K=C7(W),H=K.matchAll(/\[[^\]]+\]\([^)]+\)/g);for(let A of H)if(G==="reference")Z.push({filePath:J.filePath,line:U+1,column:A.index+1,ruleId:"markdown/link-image-style",message:Q==="consistent"?"Link style should be consistent throughout document":"Expected reference style link",severity:Q==="consistent"?"warning":"error"});let V=K.matchAll(/\[[^\]]+\]\[(?:[^\]]+)\]/g);for(let A of V)if(G==="inline")Z.push({filePath:J.filePath,line:U+1,column:A.index+1,ruleId:"markdown/link-image-style",message:Q==="consistent"?"Link style should be consistent throughout document":"Expected inline style link",severity:Q==="consistent"?"warning":"error"})}return Z},fix:($,J)=>{let X=(J.options||{}).style||"consistent",Y=$.split(/\r?\n/),z=m(Y),Q=new Map;for(let U=0;U<Y.length;U++){if(z.has(U))continue;let W=Y[U].match(/^\s*\[([^\]]+)\]:\s*(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?\s*$/);if(W){let K=W[1].toLowerCase(),H=W[2],V=W[3]??W[4]??W[5];if(!Q.has(K))Q.set(K,{url:H,title:V})}}if(Q.size===0)return $;let G=X==="reference"?"reference":"inline";if(X==="consistent"){let U=0,W=0;for(let K=0;K<Y.length;K++){if(z.has(K))continue;let H=Y[K];if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(H))continue;let V=C7(H);U+=(V.match(/\[[^\]]+\]\([^)]+\)/g)||[]).length,W+=(V.match(/\[[^\]]+\]\[(?:[^\]]*)\]/g)||[]).length}G=W>U?"reference":"inline"}if(G!=="inline")return $;let q=!1;for(let U=0;U<Y.length;U++){if(z.has(U))continue;let W=Y[U];if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(W))continue;let K=W;for(let H=0;H<8;H++){let V=K.replace(/(!?)\[((?:[^[\]]|\[[^\]]*\]\([^)]*\))+)\]\[([^\]]*)\]/g,(A,_,B,F)=>{let M=(F.trim()===""?B:F).toLowerCase(),N=Q.get(M);if(!N)return A;let E=N.title?` "${N.title}"`:"";return`${_}[${B}](${N.url}${E})`});if(V===K)break;K=V}if(K!==W)Y[U]=K,q=!0}return q?Y.join(`
97
- `):$}};function C7($){return $.replace(/(`+)([^`]+?)\1/g,(J)=>" ".repeat(J.length))}var jJ={meta:{docs:"List items at the same level should have consistent indentation"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map,z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q],q=G.match(/^(\s*)(?:[*\-+]|\d+\.)\s+/);if(q){z=!0;let U=q[1].length,W=Math.floor(U/2);if(Y.has(W)){let K=Y.get(W);if(U!==K)Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"markdown/list-indent",message:`Inconsistent indentation for list items at the same level. Expected ${K} spaces, found ${U}`,severity:"error"})}else Y.set(W,U)}else if(G.trim().length===0){if(z){let U=X.slice(Q+1).find((W)=>W.trim().length>0);if(U&&!/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(U))z=!1,Y.clear()}}}return Z}};var NJ={meta:{docs:"Spaces after list markers should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=J.options||{},z=Y.ul_single||1,Q=Y.ol_single||1;for(let G=0;G<X.length;G++){let q=X[G],U=q.match(/^(\s*)([*\-+])(\s+)/);if(U){let K=U[3].length;if(K!==z)Z.push({filePath:J.filePath,line:G+1,column:U[1].length+2,ruleId:"markdown/list-marker-space",message:`Expected ${z} space${z!==1?"s":""} after list marker, found ${K}`,severity:"error"})}let W=q.match(/^(\s*)(\d+\.)(\s+)/);if(W){let K=W[3].length;if(K!==Q)Z.push({filePath:J.filePath,line:G+1,column:W[1].length+W[2].length+1,ruleId:"markdown/list-marker-space",message:`Expected ${Q} space${Q!==1?"s":""} after list marker, found ${K}`,severity:"error"})}}return Z},fix:($,J)=>{let Z=J.options||{},X=Z.ul_single||1,Y=Z.ol_single||1;return $.split(/\r?\n/).map((G)=>{return G=G.replace(/^(\s*)([*\-+])\s+/,(q,U,W)=>{return`${U}${W}${" ".repeat(X)}`}),G=G.replace(/^(\s*)(\d+\.)\s+/,(q,U,W)=>{return`${U}${W}${" ".repeat(Y)}`}),G}).join(`
98
- `)}};var TJ={meta:{docs:"Images should have alternate text"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z];if(/^(?:`{3,}|~{3,})/.test(Q.trim())){Y=!Y;continue}if(Y)continue;let q=Q.replace(/``[^`]+``/g,(U)=>" ".repeat(U.length)).replace(/`[^`]+`/g,(U)=>" ".repeat(U.length)).matchAll(/!\[\s*\]\([^)]+\)/g);for(let U of q){let W=U.index+1;Z.push({filePath:J.filePath,line:z+1,column:W,ruleId:"markdown/no-alt-text",message:"Images should have alternate text (alt text)",severity:"error"})}}return Z}};var EJ={meta:{docs:"Bare URLs should be wrapped in angle brackets"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X),z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y.has(Q))continue;if(G.includes("<!--"))z=!0;if(G.includes("-->")){z=!1;continue}if(z)continue;if(/^\[(?:[^\]]+)\]:\s*\S+/.test(G))continue;let q=G.replace(/`[^`]+`/g,(K)=>" ".repeat(K.length)),U=/(?<![<(="'])https?:\/\/[^\s<>`)\]"']+(?![>\])"'])/g,W=q.matchAll(U);for(let K of W)Z.push({filePath:J.filePath,line:Q+1,column:K.index+1,ruleId:"markdown/no-bare-urls",message:"Bare URL used. Wrap in angle brackets: <url>",severity:"error"})}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=m(J),X=!1;return J.map((z,Q)=>{if(Z.has(Q))return z;if(z.includes("<!--"))X=!0;if(z.includes("-->"))return X=!1,z;if(X)return z;if(/^\[(?:[^\]]+)\]:\s*\S+/.test(z))return z;return z.replace(/(?<![<(="'])https?:\/\/[^\s<>`)\]"']+(?![>\])"'])/g,"<$&>")}).join(`
99
- `)}};var DJ={meta:{docs:"Blank lines inside blockquotes should use the blockquote symbol"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q],q=Q+1<X.length?X[Q+1]:"";if(/^(?:`{3,}|~{3,})/.test(G.trim())){z=!z,Y=!1;continue}if(z)continue;let U=/^\s*>/.test(G),W=G.trim().length===0,K=/^\s*>/.test(q);if(U)Y=!0;else if(W&&Y&&K)Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"markdown/no-blanks-blockquote",message:"Blank line inside blockquote should use blockquote symbol (>)",severity:"error"});else if(!U&&!W)Y=!1}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=!1,X=!1,Y=!1;for(let z=0;z<J.length;z++){let Q=J[z],G=z+1<J.length?J[z+1]:"";if(/^(?:`{3,}|~{3,})/.test(Q.trim())){X=!X,Z=!1;continue}if(X)continue;let q=/^\s*>/.test(Q),U=Q.trim().length===0,W=/^\s*>/.test(G);if(q)Z=!0;else if(U&&Z&&W){let K=G.match(/^(\s*)>/),H=K?`${K[1]}>`:">";J[z]=H,Y=!0}else if(!q&&!U)Z=!1}return Y?J.join(`
100
- `):$}};var RJ={meta:{docs:"Multiple headings should not have the same content"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=Array.from({length:7},()=>new Map);for(let Q=0;Q<X.length;Q++){let G=X[Q];if(/^(?:`{3,}|~{3,})/.test(G.trim())){Y=!Y;continue}if(Y)continue;if(/^\s*\[Compare changes\]\(/.test(G)){for(let H=3;H<=6;H++)z[H].clear();continue}let q=null,U=0,W=G.match(/^(#{1,6})\s+(.+?)(?:\s*#+\s*)?$/);if(W)U=W[1].length,q=W[2].trim();if(!q){let H=Q+1<X.length?X[Q+1]:"";if(/^(?:=+)\s*$/.test(H)&&G.trim().length>0)U=1,q=G.trim();else if(/^(?:-+)\s*$/.test(H)&&G.trim().length>0)U=2,q=G.trim()}if(!q||U===0)continue;for(let H=U+1;H<=6;H++)z[H].clear();let K=z[U];if(K.has(q))Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"markdown/no-duplicate-heading",message:`Duplicate heading "${q}" (first occurrence on line ${K.get(q)})`,severity:"error"});else K.set(q,Q+1)}return Z}};var M2=/[.!?:;,]\s*$/;function OJ($,J,Z){let X=$.match(/^\*\*([^*]+)\*\*\s*$/)||$.match(/^__([^_]+)__\s*$/),Y=$.match(/^\*([^*]+)\*\s*$/)||$.match(/^_([^_]+)_\s*$/),z=X||Y;if(!z)return null;if(J.trim().length!==0||Z.trim().length!==0)return null;let Q=z[1];if(M2.test(Q))return null;if(Q.trim().split(/\s+/).length>=7)return null;return Q}var LJ={meta:{docs:"Emphasis should not be used for headings"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X);for(let z=0;z<X.length;z++){if(Y.has(z))continue;let Q=X[z],G=z>0?X[z-1]:"",q=z+1<X.length?X[z+1]:"";if(OJ(Q,G,q)===null)continue;Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/no-emphasis-as-heading",message:"Emphasis used instead of a heading",severity:"warning"})}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=m(J),X=2,Y=!1;for(let z=0;z<J.length;z++){if(Z.has(z))continue;let Q=J[z],G=Q.match(/^(#{1,6})\s/);if(G){X=G[1].length;continue}let q=z>0?J[z-1]:"",U=z+1<J.length?J[z+1]:"",W=OJ(Q,q,U);if(W===null)continue;let K=Math.min(6,Math.max(2,X+1));J[z]=`${"#".repeat(K)} ${W.trim()}`,Y=!0}return Y?J.join(`
101
- `):$}};var PJ={meta:{docs:"Links should not be empty"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z];if(/^(?:`{3,}|~{3,})/.test(Q.trim())){Y=!Y;continue}if(Y)continue;let G=Q.replace(/`[^`]+`/g,(W)=>"x".repeat(W.length)),q=G.matchAll(/\[[^\]]+\]\(\s*\)/g);for(let W of q){let K=W.index+1;Z.push({filePath:J.filePath,line:z+1,column:K,ruleId:"markdown/no-empty-links",message:"Empty link URL",severity:"error"})}let U=G.matchAll(/\[\s*\]\([^)]+\)/g);for(let W of U){let K=W.index+1;Z.push({filePath:J.filePath,line:z+1,column:K,ruleId:"markdown/no-empty-links",message:"Empty link text",severity:"error"})}}return Z}};var CJ={meta:{docs:"Spaces should be used instead of hard tabs"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z];if(/^(?:`{3,}|~{3,})/.test(Q.trim())){Y=!Y;continue}if(Y)continue;let G=Q.indexOf("\t");if(G!==-1)Z.push({filePath:J.filePath,line:z+1,column:G+1,ruleId:"markdown/no-hard-tabs",message:"Hard tabs should not be used",severity:"error"})}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=!1;return J.map((Y)=>{if(/^(?:`{3,}|~{3,})/.test(Y.trim()))return Z=!Z,Y;if(Z)return Y;return Y.replace(/\t/g," ")}).join(`
102
- `)}};var IJ={meta:{docs:"Inline HTML should not be used"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).allowed_elements||[],Q=!1;for(let G=0;G<X.length;G++){let q=X[G];if(/^(?:`{3,}|~{3,})/.test(q.trim())){Q=!Q;continue}if(Q)continue;let U=q;U=U.replace(/``[^`]+``/g,(K)=>" ".repeat(K.length)),U=U.replace(/`[^`]+`/g,(K)=>" ".repeat(K.length));let W=U.matchAll(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi);for(let K of W){let H=K[1].toLowerCase(),V=U.slice(K.index+1+H.length);if(V.startsWith("://")||H==="mailto"&&V.startsWith(":"))continue;if(!z.includes(H)){let A=K.index+1;Z.push({filePath:J.filePath,line:G+1,column:A,ruleId:"markdown/no-inline-html",message:`Inline HTML element '<${H}>' should not be used`,severity:"warning"})}}}return Z}};var SJ={meta:{docs:"ATX style headings must have a space after the hash"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X);for(let z=0;z<X.length;z++){if(Y.has(z))continue;let G=X[z].match(/^(#{1,6})([^\s#])/);if(G)Z.push({filePath:J.filePath,line:z+1,column:G[1].length+1,ruleId:"markdown/no-missing-space-atx",message:"No space after hash on atx style heading",severity:"error"})}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=m(J);return J.map((Y,z)=>{if(Z.has(z))return Y;return Y.replace(/^(#{1,6})([^\s#])/,"$1 $2")}).join(`
103
- `)}};var vJ={meta:{docs:"Closed ATX style headings must have spaces inside the hashes"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X);for(let z=0;z<X.length;z++){if(Y.has(z))continue;let Q=X[z],G=Q.match(/^(#{1,6})\s+(.+?)(#{1,6})\s*$/);if(G){let U=G[1],W=G[2],K=G[3];if(!W.endsWith(" ")){let H=U.length+1+W.length;Z.push({filePath:J.filePath,line:z+1,column:H,ruleId:"markdown/no-missing-space-closed-atx",message:"No space inside hashes on closed atx style heading",severity:"error"})}}let q=Q.match(/^(#{1,6})(\S.+?#{1,6})\s*$/);if(q)Z.push({filePath:J.filePath,line:z+1,column:q[1].length+1,ruleId:"markdown/no-missing-space-closed-atx",message:"No space inside hashes on closed atx style heading",severity:"error"})}return Z}};var yJ={meta:{docs:"Multiple consecutive blank lines should not be used"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=J.options||{},z=Y.maximum!==void 0?Y.maximum:1,Q=0;for(let G=0;G<X.length;G++)if(X[G].trim().length===0){if(Q++,Q>z)Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"markdown/no-multiple-blanks",message:`Multiple consecutive blank lines (max ${z})`,severity:"error"})}else Q=0;return Z},fix:($,J)=>{let Z=J.options||{},X=Z.maximum!==void 0?Z.maximum:1,Y=$.split(/\r?\n/),z=[],Q=0;for(let G of Y)if(G.trim().length===0){if(Q++,Q<=X)z.push(G)}else Q=0,z.push(G);return z.join(`
104
- `)}};var bJ={meta:{docs:"ATX style headings should have only one space after the hash"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X);for(let z=0;z<X.length;z++){if(Y.has(z))continue;let G=X[z].match(/^(#{1,6})\s{2,}/);if(G)Z.push({filePath:J.filePath,line:z+1,column:G[1].length+1,ruleId:"markdown/no-multiple-space-atx",message:"Multiple spaces after hash on atx style heading",severity:"error"})}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=m(J);return J.map((Y,z)=>{if(Z.has(z))return Y;return Y.replace(/^(#{1,6})\s{2,}/,"$1 ")}).join(`
105
- `)}};var kJ={meta:{docs:"Blockquote symbols should be followed by a single space"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X);for(let z=0;z<X.length;z++){if(Y.has(z))continue;let G=X[z].match(/^(\s*)(>+)\s{2,}/);if(G){let q=G[1].length+G[2].length+1;Z.push({filePath:J.filePath,line:z+1,column:q,ruleId:"markdown/no-multiple-space-blockquote",message:"Multiple spaces after blockquote symbol",severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=m(J);return J.map((Y,z)=>{if(Z.has(z))return Y;return Y.replace(/^(\s*>+)\s{2,}/,"$1 ")}).join(`
106
- `)}};var fJ={meta:{docs:"Closed ATX style headings should have only one space inside the hashes"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X);for(let z=0;z<X.length;z++){if(Y.has(z))continue;let Q=X[z],G=Q.match(/^(#{1,6})\s{2,}(?:\S.*?|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])#{1,6}\s*$/);if(G)Z.push({filePath:J.filePath,line:z+1,column:G[1].length+1,ruleId:"markdown/no-multiple-space-closed-atx",message:"Multiple spaces inside hashes on closed atx style heading",severity:"error"});let q=Q.match(/^#{1,6}\s+(?:\S.*?|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\s{2,}(#{1,6})\s*$/);if(q){let U=Q.lastIndexOf(q[1])-1;Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,U),ruleId:"markdown/no-multiple-space-closed-atx",message:"Multiple spaces inside hashes on closed atx style heading",severity:"error"})}}return Z}};var gJ={meta:{docs:"Link syntax should not be reversed"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X);for(let z=0;z<X.length;z++){if(Y.has(z))continue;let G=X[z].matchAll(/\(([^)]+)\)\[(?:[^\]]+)\]/g);for(let q of G){let U=q.index+1;Z.push({filePath:J.filePath,line:z+1,column:U,ruleId:"markdown/no-reversed-links",message:"Reversed link syntax: should be [text](url) not (text)[url]",severity:"error"})}}return Z}};var pJ={meta:{docs:"Code span elements should not have spaces inside the backticks"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X);for(let z=0;z<X.length;z++){let Q=X[z];if(Y.has(z))continue;let G=/(`+)([\s\S]*?)\1/g;for(let q of Q.matchAll(G)){let U=q[2];if(U.startsWith(" ")&&U.endsWith(" ")&&U.trim().length>0)Z.push({filePath:J.filePath,line:z+1,column:q.index+1,ruleId:"markdown/no-space-in-code",message:"Spaces inside code span elements",severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=m(J),X=[];for(let Y=0;Y<J.length;Y++){let z=J[Y];if(Z.has(Y)){X.push(z);continue}X.push(z.replace(/(`+)([\s\S]*?)\1/g,(Q,G,q)=>{if(q.startsWith(" ")&&q.endsWith(" ")&&q.trim().length>0)return`${G}${q.trim()}${G}`;return Q}))}return X.join(`
107
- `)}};var j2=[/(?<![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],xJ={meta:{docs:"Emphasis markers should not have spaces inside them"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X);for(let z=0;z<X.length;z++){let Q=X[z];if(Y.has(z))continue;let G=Q.replace(/`[^`]+`/g,(q)=>"\x01".repeat(q.length));for(let q of j2)for(let U of G.matchAll(q))Z.push({filePath:J.filePath,line:z+1,column:U.index+1,ruleId:"markdown/no-space-in-emphasis",message:"Spaces inside emphasis markers",severity:"error"})}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=m(J),X=[];for(let Y=0;Y<J.length;Y++){let z=J[Y];if(Z.has(Y)){X.push(z);continue}let Q=B1(z,(G)=>{let q=G;return q=q.replace(/(?<![A-Za-z0-9])(\*\*)\s+([^*]+?)\*\*(?![A-Za-z0-9])/g,"$1$2**"),q=q.replace(/(?<![A-Za-z0-9])(\*\*)([^*]+?)\s+\*\*(?![A-Za-z0-9])/g,"$1$2**"),q=q.replace(/(?<![A-Za-z0-9])(__)\s+([^_]+?)__(?![A-Za-z0-9])/g,"$1$2__"),q=q.replace(/(?<![A-Za-z0-9])(__)([^_]+?)\s+__(?![A-Za-z0-9])/g,"$1$2__"),q});X.push(Q)}return X.join(`
108
- `)}};var hJ={meta:{docs:"Link text should not have leading or trailing spaces"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X);for(let z=0;z<X.length;z++){if(Y.has(z))continue;let G=X[z].matchAll(/\[([^\][]*)\]\([^)]*\)/g);for(let q of G){let U=q[1];if(/^\s/.test(U)||/\s$/.test(U)){let W=q.index+1;Z.push({filePath:J.filePath,line:z+1,column:W,ruleId:"markdown/no-space-in-links",message:"Spaces inside link text",severity:"error"})}}}return Z}};var uJ={meta:{docs:"Headings should not end with punctuation"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).punctuation||".,;:!?",Q=!1;for(let G=0;G<X.length;G++){let q=X[G];if(/^(?:`{3,}|~{3,})/.test(q.trim())){Q=!Q;continue}if(Q)continue;let U=q.match(/^#{1,6}\s+(.+?)(?:\s*#+\s*)?$/);if(U){let K=U[1].trim(),H=K[K.length-1];if(H&&z.includes(H))Z.push({filePath:J.filePath,line:G+1,column:q.indexOf(K)+K.length,ruleId:"markdown/no-trailing-punctuation",message:`Trailing punctuation in heading: '${H}'`,severity:"error"})}let W=G+1<X.length?X[G+1]:"";if(/^(?:=+|-+)\s*$/.test(W)&&q.trim().length>0){let K=q.trim(),H=K[K.length-1];if(H&&z.includes(H))Z.push({filePath:J.filePath,line:G+1,column:q.indexOf(K)+K.length,ruleId:"markdown/no-trailing-punctuation",message:`Trailing punctuation in heading: '${H}'`,severity:"error"})}}return Z},fix:($,J)=>{let X=(J.options||{}).punctuation||".,;:!?",Y=new RegExp(`[${X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}]+$`),z=$.split(/\r?\n/),Q=!1;return z.map((q,U)=>{if(/^(?:`{3,}|~{3,})/.test(q.trim()))return Q=!Q,q;if(Q)return q;let W=q.match(/^(#{1,6}\s+)(.+?)(\s*#+\s*)?$/);if(W){let H=W[1],V=W[2],A=W[3]||"",_=V.replace(Y,"");return`${H}${_}${A}`}let K=U+1<z.length?z[U+1]:"";if(/^(?:=+|-+)\s*$/.test(K)&&q.trim().length>0)return q.replace(Y,"");return q}).join(`
109
- `)}};var mJ={meta:{docs:"Lines should not end with trailing spaces"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.match(/\s+$/);if(Q){let G=J.options||{},q=G.br_spaces!==void 0?G.br_spaces:2;if(q===0||Q[0].length!==q)Z.push({filePath:J.filePath,line:Y+1,column:z.length-Q[0].length+1,ruleId:"markdown/no-trailing-spaces",message:`Trailing spaces found (${Q[0].length} space${Q[0].length!==1?"s":""})`,severity:"error"})}}return Z},fix:($,J)=>{let Z=$.split(/\r?\n/),X=J.options||{},Y=X.br_spaces!==void 0?X.br_spaces:2;return Z.map((Q)=>{let G=Q.match(/\s+$/);if(G){if(Y>0&&G[0].length===Y)return Q;return Q.replace(/\s+$/,"")}return Q}).join(`
110
- `)}};var dJ={meta:{docs:"Ordered list item prefix should follow specified style"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).style||"one_or_ordered",Q=1;for(let G=0;G<X.length;G++){let q=X[G],U=q.match(/^(\s*)(\d+)\.\s+/);if(U){let W=Number.parseInt(U[2],10);if(z==="one"&&W!==1)Z.push({filePath:J.filePath,line:G+1,column:U[1].length+1,ruleId:"markdown/ol-prefix",message:`Ordered list item prefix should be '1.', found '${W}.'`,severity:"error"});else if(z==="ordered"&&W!==Q)Z.push({filePath:J.filePath,line:G+1,column:U[1].length+1,ruleId:"markdown/ol-prefix",message:`Ordered list item prefix should be '${Q}.', found '${W}.'`,severity:"error"});Q++}else if(q.trim().length===0)Q=1}return Z},fix:($,J)=>{let X=(J.options||{}).style||"one_or_ordered",Y=$.split(/\r?\n/),z=[],Q=1;for(let G of Y){let q=G.match(/^(\s*)(\d+)(\.\s+)/);if(q){let U=q[1],W=q[3];if(X==="one")z.push(G.replace(/^(\s*)\d+(\.\s+)/,`${U}1${W}`));else if(X==="ordered")z.push(G.replace(/^(\s*)\d+(\.\s+)/,`${U}${Q}${W}`)),Q++;else z.push(G),Q++}else if(z.push(G),G.trim().length===0)Q=1}return z.join(`
111
- `)}};var oJ={meta:{docs:"Proper names should have correct capitalization"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=J.options||{},z=Y.names||[],Q=Y.code_blocks!==!1;if(z.length===0)return Z;let G=m(X);for(let q=0;q<X.length;q++){if(G.has(q)&&!Q)continue;let U=X[q];for(let W of z){let K=new RegExp(`\\b${W}\\b`,"gi"),H=U.matchAll(K);for(let V of H)if(V[0]!==W){let A=V.index+1;Z.push({filePath:J.filePath,line:q+1,column:A,ruleId:"markdown/proper-names",message:`Incorrect capitalization of '${V[0]}', should be '${W}'`,severity:"error"})}}}return Z}};var cJ={meta:{docs:"Reference links and images should use defined labels"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Set;for(let G of X){let q=G.match(/^\s*\[([^\]]+)\]:\s*\S+/);if(q)Y.add(q[1].toLowerCase())}let z=!1,Q=!1;for(let G=0;G<X.length;G++){let q=X[G];if(/^(?:`{3,}|~{3,})/.test(q.trim())){z=!z;continue}if(z)continue;if(q.includes("<!--"))Q=!0;if(q.includes("-->")){Q=!1;continue}if(Q)continue;if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(q))continue;let U=q.replace(/`[^`]+`/g,(K)=>" ".repeat(K.length));U=U.replace(/!?\[[^\]]*\]\([^)]*\)/g,(K)=>" ".repeat(K.length));let W=U.matchAll(/!?\[([^\]]+)\]\[([^\]]*)\]/g);for(let K of W){let H=(K[2].trim()||K[1]).toLowerCase();if(!Y.has(H))Z.push({filePath:J.filePath,line:G+1,column:K.index+1,ruleId:"markdown/reference-links-images",message:`Reference link '[${H}]' is not defined`,severity:"error"})}}return Z}};var rJ={meta:{docs:"Document should have required heading structure"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).headings||[];if(z.length===0)return Z;let Q=[];for(let q of X){let U=q.match(/^#{1,6}\s+(.+?)(?:\s*#+\s*)?$/);if(U)Q.push(U[1].trim())}let G=0;for(let q=0;q<Q.length&&G<z.length;q++)if(Q[q]===z[G])G++;if(G<z.length)Z.push({filePath:J.filePath,line:1,column:1,ruleId:"markdown/required-headings",message:`Missing required heading: '${z[G]}'`,severity:"error"});return Z}};var lJ={meta:{docs:"Document should have only one top-level heading (h1)"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X),z=-1;for(let Q=0;Q<X.length;Q++){if(Y.has(Q))continue;let G=X[Q],q=Q+1<X.length?X[Q+1]:"",U=!1;if(/^#\s/.test(G))U=!0;if(/^=+\s*$/.test(q)&&G.trim().length>0&&!Y.has(Q+1))U=!0;if(U)if(z===-1)z=Q+1;else Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"markdown/single-title",message:`Multiple top-level headings in the same document (first h1 on line ${z})`,severity:"error"})}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=m(J),X=[],Y=!1,z=!1;for(let Q=0;Q<J.length;Q++){if(Z.has(Q)){X.push(J[Q]);continue}let G=J[Q],q=Q+1<J.length?J[Q+1]:"",U=/^#\s/.test(G),W=/^=+\s*$/.test(q)&&G.trim().length>0&&!Z.has(Q+1);if(U){if(!Y)Y=!0,X.push(G);else X.push(`#${G}`),z=!0;continue}if(W){if(!Y){Y=!0,X.push(G);continue}X.push(`## ${G.trim()}`),Q++,z=!0;continue}X.push(G)}return z?X.join(`
112
- `):$}};var aJ={meta:{docs:"Files should end with a single newline character"},check:($,J)=>{let Z=[];if(!$.endsWith(`
64
+ `)}`;if(!new RegExp(`\\b${g}\\b`,"g").test(x))Z.push({filePath:J.filePath,line:j+1,column:Math.max(1,O.indexOf(g)+1),ruleId:"pickier/no-unused-vars",message:`'${g}' is assigned a value but never used. Allowed unused vars must match pattern: ${Y}`,severity:"error",help:`Either use this variable in your code, remove it, or prefix it with an underscore (_${g}) to mark it as intentionally unused`})}}}let A=(j)=>{let v=((k)=>{let P="",L=null,I=!1,f=0;for(let S=0;S<k.length;S++){let N=k[S];if(I){I=!1;continue}if(N==="\\"&&L){I=!0;continue}if(!L){if(N==="'")L="single";else if(N==='"')L="double";else if(N==="`")L="template";else if(N==="("||N==="{"||N==="[")f++;else if(N===")"||N==="}"||N==="]")f--;else if(N==="="&&f===0)return P}else if(L==="single"&&N==="'"||L==="double"&&N==='"'||L==="template"&&N==="`")L=null;P+=N}return P})(j);return((k)=>{let P="",L=0;while(L<k.length){let I=k[L];if(I===":"){L++;while(L<k.length&&/\s/.test(k[L]))L++;let f=0,S=0,N=null,R=!1;while(L<k.length){let D=k[L];if(R){R=!1,L++;continue}if(D==="\\"&&N){R=!0,L++;continue}if(!N){if(D==="'")N="single";else if(D==='"')N="double";else if(D==="`")N="template";else if(D==="<")S++;else if(D===">")S--;else if(D==="("||D==="{"||D==="[")f++;else if(D===")"||D==="}"||D==="]")if(f>0)f--;else break;else if(D===","&&f===0&&S===0)break}else if(N==="single"&&D==="'"||N==="double"&&D==='"'||N==="template"&&D==="`")N=null;L++}continue}P+=I,L++}return P})(v).split(/[^$\w]+/).filter((k)=>k&&k!=="undefined")},_=(j,O)=>{let v=!1,y=0,C=0,k=!1,P=0,L=null,I=!1,f=!0,S="",N=!1,R=!1,D=[],g=!1;for(let x=j;x<U.length;x++){let p=U[x],b=p,m=D.length>0&&D[D.length-1]===-1,u=-1,n=null,c=!1;if(!m)for(let d=0;d<p.length-1;d++){let a=p[d],l=p[d+1];if(c){c=!1;continue}if(a==="\\"&&n){c=!0;continue}if(!n){if(a==="'")n="single";else if(a==='"')n="double";else if(a==="`")n="template";else if(a==="/"&&l==="/"){u=d;break}}else if(n==="single"&&a==="'"||n==="double"&&a==='"'||n==="template"&&a==="`")n=null}if(u>=0)b=p.slice(0,u);let $0=(d)=>{let a="",l=0,o=null,M0=!1;while(l<d.length){let _0=d[l];if(M0){M0=!1,a+=_0,l++;continue}if(_0==="\\"&&o){M0=!0,a+=_0,l++;continue}if(!o){if(_0==="'")o="single";else if(_0==='"')o="double";else if(_0==="`")o="template";else if(_0==="/"){if(O8(d,l)){l++;while(l<d.length){if(d[l]==="\\"){l+=2;continue}if(d[l]==="/"){l++;while(l<d.length&&/[gimsuvy]/.test(d[l]))l++;break}l++}continue}}}else if(o==="single"&&_0==="'"||o==="double"&&_0==='"'||o==="template"&&_0==="`")o=null;a+=_0,l++}return a};if(!m)b=$0(b);let V0=0;if(!v){let d=-1,a=f?typeof O==="number"?O:0:0;if(f=!1,a>=b.length){let l=b.indexOf("=>");a=l>=0?l+2:0}for(let l=a;l<b.length;l++){let o=b[l];if(I){I=!1;continue}if(o==="\\"&&L){I=!0;continue}if(!L){if(o!==" "&&o!=="\t"&&o!==`
65
+ `&&o!=="\r"&&o!=="{"&&o!=="}"&&C===0)S=o;if(o==="'")L="single";else if(o==='"')L="double";else if(o==="`")L="template";else if(o==="<")P++;else if(o===">")P=Math.max(0,P-1);else if(o==="{"){if(C===0){if(k&&P===0&&!fZ.has(S)){d=l;break}}C++}else if(o==="}"){if(C>0){if(C--,C===0)k=!0,S="}"}}}else if(L==="single"&&o==="'"||L==="double"&&o==='"'||L==="template"&&o==="`")L=null}if(d===-1){if(C>0&&fZ.has(S))continue;for(let l=a;l<b.length;l++)if(b[l]==="{"&&!L){d=l;break}}if(d===-1)continue;v=!0,y=1,V0=d+1,j=x}for(let d=V0;d<b.length;d++){let a=b[d];if(g){g=!1;continue}let l=D.length>0&&D[D.length-1]===-1,o=D.length>0&&D[D.length-1]>=0;if(a==="\\"&&(N||R||l)){g=!0;continue}if(N){if(a==="'")N=!1;continue}if(R){if(a==='"')R=!1;continue}if(l){if(a==="`")D.pop();else if(a==="$"&&d+1<b.length&&b[d+1]==="{")D[D.length-1]=0,d++;continue}if(o){if(a==="/"){if(O8(b,d)){d++;while(d<b.length){if(b[d]==="\\"){d+=2;continue}if(b[d]==="/"){while(d+1<b.length&&/[gimsuvy]/.test(b[d+1]))d++;break}d++}continue}}if(a==="`"){D.push(-1);continue}if(a==="'"){N=!0;continue}if(a==='"'){R=!0;continue}if(a==="{"){D[D.length-1]++;continue}if(a==="}")if(D[D.length-1]>0)D[D.length-1]--;else D[D.length-1]=-1;continue}if(a==="'")N=!0;else if(a==='"')R=!0;else if(a==="`")D.push(-1);else if(a==="{")y++;else if(a==="}"){if(y--,y===0)return{from:j,to:x}}}}return null},B=(j,O)=>{let v={parenDepth:0,braceDepth:0,bracketDepth:0,inTemplate:!1},y=(f)=>{for(let S=0;S<f.length;S++){let N=f[S];if(N==="`")v.inTemplate=!v.inTemplate;else if(N==="(")v.parenDepth++;else if(N===")")v.parenDepth--;else if(N==="{")v.braceDepth++;else if(N==="}")v.braceDepth--;else if(N==="[")v.bracketDepth++;else if(N==="]")v.bracketDepth--}},C=()=>v.parenDepth>0||v.braceDepth>0||v.bracketDepth>0||v.inTemplate,k=(f)=>/(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)$/.test(f.trimEnd()),P=(f)=>/^(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)/.test(f.trimStart()),L=U[j].slice(O+2);y(L);let I=j+1;while(I<U.length){let f=I===j+1?L:U[I-1];if(!(!L.trim()||C()||k(f)||P(U[I])))break;L+=`
66
+ ${U[I]}`,y(U[I]),I++}return L},F=[],M=!1,T=!1,E=!1;for(let j=0;j<U.length;j++){let O=U[j];if(/^\s*\/\//.test(O))continue;if(K[j])continue;let v=O,y=null,C=!1,k=!1;for(let N=0;N<O.length-1;N++){let R=O[N],D=O[N+1];if(k){k=!1;continue}if(R==="\\"&&(y||C)){k=!0;continue}if(!y&&!C){if(R==="'")y="single";else if(R==='"')y="double";else if(R==="`")y="template";else if(R==="/"){if(O8(O,N))C=!0;else if(D==="/"){v=O.slice(0,N);break}}}else if(y){if(y==="single"&&R==="'"||y==="double"&&R==='"'||y==="template"&&R==="`")y=null}else if(C&&R==="/")C=!1}let I=((N)=>{let R="",D=0;while(D<N.length){if(N[D]==="/"){if(O8(N,D)){D++;while(D<N.length){if(N[D]==="\\"){D+=2;continue}if(N[D]==="/"){D++;while(D<N.length&&/[gimsuvy]/.test(N[D]))D++;break}D++}continue}}R+=N[D],D++}return R})(v).replace(/'(?:[^'\\]|\\.)*'/g,"''").replace(/"(?:[^"\\]|\\.)*"/g,'""');{let N="";for(let R=0;R<I.length;R++){let D=I[R];if(E){E=!1;let p=F.length>0&&F[F.length-1]===-1;N+=p?" ":D;continue}let g=F.length>0&&F[F.length-1]===-1,x=F.length>0&&F[F.length-1]>=0;if(D==="\\"&&(M||T||g)){E=!0,N+=g?" ":D;continue}if(M){if(D==="'")M=!1;N+=D;continue}if(T){if(D==='"')T=!1;N+=D;continue}if(g){if(D==="`")F.pop();else if(D==="$"&&R+1<I.length&&I[R+1]==="{")F[F.length-1]=0,N+=" ",R++;else N+=" ";continue}if(x){if(D==="`")F.push(-1),N+=" ";else if(D==="'")M=!0,N+=D;else if(D==='"')T=!0,N+=D;else if(D==="{")F[F.length-1]++,N+=D;else if(D==="}")if(F[F.length-1]>0)F[F.length-1]--,N+=D;else F[F.length-1]=-1,N+=" ";else N+=D;continue}if(D==="`")F.push(-1),N+=" ";else if(D==="'")M=!0,N+=D;else if(D==='"')T=!0,N+=D;else N+=D}I=N}let f=I.match(/\bfunction\b/);if(f){if(O.includes("function scanContent")||O.includes("function findMatching"))continue;if(I.slice(f.index+8).trimStart().startsWith(":"))continue;let R=I.slice(0,f.index).trimEnd();if(R.endsWith(".")||R.endsWith("?."))continue;let D=f.index,g=O.indexOf("(",D);if(g===-1)continue;let x=0,p=-1,b=j,m="";for(let $0=j;$0<U.length;$0++){let V0=$0===j?U[$0]:U[$0],d=$0===j?g:0;for(let a=d;a<V0.length;a++)if(V0[a]==="(")x++;else if(V0[a]===")"){if(x--,x===0){if(p=a,b=$0,j===$0)m=O.slice(g+1,p);else{m=O.slice(g+1);for(let l=j+1;l<$0;l++)m+=` ${U[l]}`;m+=` ${V0.slice(0,p)}`}break}}if(p!==-1)break}if(p===-1)continue;let u=A(m),n=_(b,p),c="";if(n)if(n.from===b){let $0=U[n.from],V0=$0.lastIndexOf("{"),d=V0>=0?$0.slice(V0+1):"";if(n.to>n.from)c=`${d}
67
+ ${U.slice(n.from+1,n.to+1).join(`
68
+ `)}`;else c=d}else c=U.slice(n.from,n.to+1).join(`
69
+ `);for(let $0 of u){if(!$0||G.test($0)||$0==="undefined")continue;if(!new RegExp(`\\b${$0}\\b`,"g").test(c))Z.push({filePath:J.filePath,line:j+1,column:Math.max(1,O.indexOf($0)+1),ruleId:"pickier/no-unused-vars",message:`'${$0}' is defined but never used (function parameter). Allowed unused args must match pattern: ${z}`,severity:"error"})}continue}let S=O.indexOf("=>");if(S!==-1&&I.includes("=>")){let N=-1;for(let R=S-1;R>=0;R--){let D=O[R];if(D===")"){N=R;break}if(D!==" "&&D!=="\t"&&D!==`
70
+ `&&D!==":"&&D!==">"&&!/\w/.test(D))break}if(N!==-1){let R=-1,D=1;for(let g=N-1;g>=0;g--){let x=O[g];if(x===")")D++;else if(x==="("){if(D--,D===0){R=g;break}}}if(R!==-1){let g=!1,x=0,p=0;for(let m=R-1;m>=0;m--){let u=O[m];if(u===">"){x++;continue}if(u==="<"){if(x>0){x--;continue}if(p===0){g=!0;break}continue}if(u===":"&&x===0&&p===0){g=!0;break}if(x>0)continue;if(u===",")continue;if(u===")"){p++;continue}if(u==="("){p--;continue}if(u==="|"||u==="&"){g=!0;break}if(u==="="||u==="{"||u==="["){if(p>=0)break;continue}if(u!==" "&&u!=="\t"&&!/[\w.]/.test(u)){if(p>=0)break}}if(!g){let m=O.slice(0,R);if(/^\s*(?:export\s+)?(?:declare\s+)?type\s+\w[\w$]*\s*(?:<[^>]*>)?\s*=\s*$/.test(m))g=!0;else if(/\bas\s+$/.test(m))g=!0}if(g)continue;let b=O.slice(R+1,N);if(!(b.trim()===""&&O.slice(Math.max(0,R-10),R).includes("async"))){let m=A(b);if(m.length>0){let u="";if(O.slice(S+2).trimStart().startsWith("{")){let c=_(j,S);if(c)if(c.from===j){let $0=U[c.from],V0=$0.indexOf("{",S),d=V0>=0?$0.slice(V0+1):"";if(c.to>c.from)u=`${d}
71
+ ${U.slice(c.from+1,c.to+1).join(`
72
+ `)}`;else u=d}else u=U.slice(c.from,c.to+1).join(`
73
+ `)}else u=B(j,S);for(let c of m){if(!c||G.test(c)||c==="undefined")continue;if(!new RegExp(`\\b${c}\\b`,"g").test(u))Z.push({filePath:J.filePath,line:j+1,column:Math.max(1,O.indexOf(c)+1),ruleId:"pickier/no-unused-vars",message:`'${c}' is defined but never used (function parameter). Allowed unused args must match pattern: ${z}`,severity:"error"})}continue}}}}}{let N=/(?:^|[=,:({\s])\s*([$A-Z_][\w$]*)\s*=>/gi,R;while((R=N.exec(I))!==null){let D=R[1];if(!D||G.test(D)||D==="undefined")continue;let g=I.slice(0,R.index+R[0].indexOf(D)).trimEnd();if(/\)\s*:$/.test(g)||/\)\s*:\s*$/.test(g))continue;if(/\)\s*:\s*[$A-Z_][\w$]*\s+is$/i.test(g))continue;if(/^(?:string|number|boolean|void|never|any|unknown|object|bigint|symbol|undefined|null)$/.test(D))continue;let x=new RegExp(`\\b${D}\\s*=>`),p=O.match(x);if(!p)continue;let b=O.indexOf(p[0])+p[0].lastIndexOf("=>"),m="";if(O.slice(b+2).trimStart().startsWith("{")){let c=_(j,b);if(c)if(c.from===j){let $0=U[c.from],V0=$0.indexOf("{",b),d=V0>=0?$0.slice(V0+1):"";if(c.to>c.from)m=`${d}
74
+ ${U.slice(c.from+1,c.to+1).join(`
75
+ `)}`;else m=d}else m=U.slice(c.from,c.to+1).join(`
76
+ `)}else m=B(j,b);if(!new RegExp(`\\b${D}\\b`,"g").test(m))Z.push({filePath:J.filePath,line:j+1,column:Math.max(1,O.indexOf(D)+1),ruleId:"pickier/no-unused-vars",message:`'${D}' is defined but never used (function parameter). Allowed unused args must match pattern: ${z}`,severity:"error"})}}}return Z},fix:($,J)=>{let Z=n0.check($,J);if(Z.length===0)return $;let X=Z.filter((K)=>K.message.includes("(function parameter)"));if(X.length===0)return $;let Y=$.split(/\r?\n/),z=new Set,Q=/(?:eslint|pickier)-disable-next-line\b([^*\n]*)/;for(let K=0;K<Y.length;K++){let H=Y[K].match(Q);if(!H)continue;let V=H[1].trim();if(V===""||/\bno-unused-vars\b/.test(V)||/\bpickier\/no-unused-vars\b/.test(V))z.add(K+2)}let G=new Map;for(let K of X){if(z.has(K.line))continue;let H=K.message.match(/^'([^']+)'/);if(!H)continue;let V=H[1];if(V.startsWith("_"))continue;let A=G.get(K.line);if(!A)A=new Set,G.set(K.line,A);A.add(V)}if(G.size===0)return $;let q=$.split(/\r?\n/);function U(K){let H=[],V=!1,A=!1,_=!1,B=-1;for(let F=0;F<K.length;F++){let M=K[F];if(_){_=!1;continue}if(M==="\\"&&(V||A||B>=0)){_=!0;continue}if(B>=0){if(M==="`")H.push([B,F]),B=-1;continue}if(V){if(M==="'")V=!1;continue}if(A){if(M==='"')A=!1;continue}if(M==="`")B=F;else if(M==="'")V=!0;else if(M==='"')A=!0}if(B>=0)H.push([B,K.length]);return H}let W=!1;for(let[K,H]of G){let V=K-1,A=q[V];if(A===void 0)continue;let _=U(A),B=(T)=>_.some(([E,j])=>T>E&&T<j),F=[];for(let T of H){let E=T.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),j=new RegExp(`(?<=[(,]\\s*)\\b${E}\\b(?=\\s*[,):=])`,"g"),O;while((O=j.exec(A))!==null){if(B(O.index))continue;F.push({start:O.index,end:O.index+T.length,name:T})}}if(F.length===0)continue;F.sort((T,E)=>E.start-T.start);let M=A;for(let T of F)M=`${M.slice(0,T.start)}_${T.name}${M.slice(T.end)}`;if(M!==A)q[V]=M,W=!0}return W?q.join(`
77
+ `):$}};function i0($){let J=$.split(/\r?\n/),Z=Array(J.length).fill(!1),X=[],Y=!1,z=!1,Q=!1,G=!1,q=!1,U="",W=()=>{if(U==="")return!0;return"=([{,;!&|?:+-*/%^~<>".includes(U)};for(let K=0;K<J.length;K++){Z[K]=X.length>0&&X[X.length-1]===-1;let H=J[K];for(let V=0;V<H.length;V++){let A=H[V];if(G){if(A==="*"&&V+1<H.length&&H[V+1]==="/")G=!1,V++;continue}if(q){q=!1;continue}let _=X.length>0&&X[X.length-1]===-1,B=X.length>0&&X[X.length-1]>=0;if(A==="\\"&&(Y||z||Q||_)){q=!0;continue}if(Y){if(A==="'")Y=!1;continue}if(z){if(A==='"')z=!1;continue}if(Q){if(A==="["){let F=1,M=V+1;while(M<H.length){let T=H[M];if(T==="\\"){M+=2;continue}if(T==="]"){if(F--,F===0)break}M++}V=M;continue}if(A==="/"){Q=!1;while(V+1<H.length&&/[gimsuvy]/.test(H[V+1]))V++}continue}if(_){if(A==="`")X.pop();else if(A==="$"&&V+1<H.length&&H[V+1]==="{")X.push(0),V++;continue}if(A==="/"&&V+1<H.length&&H[V+1]==="/")break;if(A==="/"&&V+1<H.length&&H[V+1]==="*"){G=!0,V++;continue}if(B){if(A==="`")X.push(-1),U="";else if(A==="'")Y=!0,U="'";else if(A==='"')z=!0,U='"';else if(A==="{")X[X.length-1]++,U="{";else if(A==="}"){let F=X[X.length-1];if(F>0)X[X.length-1]=F-1;else X.pop();U="}"}else if(A==="/"&&W())Q=!0;else if(!/\s/.test(A))U=A;continue}if(A==="`")X.push(-1),U="";else if(A==="'")Y=!0,U="'";else if(A==='"')z=!0,U='"';else if(A==="/"&&W())Q=!0;else if(!/\s/.test(A))U=A}}return Z}function Q2($,J){let Z=[],X=0,Y=0,z=null,Q=!1;for(let G=0;G<$.length;G++){let q=$[G];if(Q){Q=!1;continue}if(q==="\\"&&z){Q=!0;continue}if(!z){if(q==="'")z="single";else if(q==='"')z="double";else if(q==="`")z="template";else if(q==="("||q==="{"||q==="[")X++;else if(q===")"||q==="}"||q==="]")X--;else if(q===J&&X===0)Z.push($.slice(Y,G)),Y=G+1}else if(z==="single"&&q==="'"||z==="double"&&q==='"'||z==="template"&&q==="`")z=null}return Z.push($.slice(Y)),Z}function G2($){let J=0;for(let Z=0;Z<$.length;Z++){let X=$[Z];if(X==="{"||X==="("||X==="["||X==="<")J++;else if(X==="}"||X===")"||X==="]"||X===">")J--;else if(X==="="&&J===0&&$[Z+1]!=="="&&$[Z-1]!=="!"&&$[Z-1]!=="<"&&$[Z-1]!==">")return Z}return-1}function q2($,J){let Z=new RegExp(`\\b${J}\\b`),X=0,Y=null,z=!1;while(X<$.length){let Q=$[X];if(z){z=!1,X++;continue}if(Q==="\\"&&Y){z=!0,X++;continue}if(Y){if(Y==="single"&&Q==="'"||Y==="double"&&Q==='"'||Y==="template"&&Q==="`")Y=null;X++;continue}if(Q==="'"){Y="single",X++;continue}if(Q==='"'){Y="double",X++;continue}if(Q==="`"){Y="template",X++;continue}if(Q==="["||Q==="{"){let G=Q,q=Q==="["?"]":"}",U=1,W=X+1;while(W<$.length&&U>0){let K=$[W];if(K==="\\"){W+=2;continue}if(K===G)U++;else if(K===q)U--;if(U===0)break;W++}if(U===0&&W<$.length){let K=W+1;while(K<$.length&&($[K]===" "||$[K]==="\t"||$[K]==="\r"||$[K]===`
78
+ `))K++;if($[K]==="="&&$[K+1]!=="="&&$[K+1]!==">"){let H=$.slice(X+1,W);if(Z.test(H)){let V=new RegExp(`\\b${J}\\b\\s*:`),A=new RegExp(`:\\s*\\b${J}\\b`);if(G==="{"){if(!(V.test(H)&&!A.test(H)&&!new RegExp(`(?:^|[\\s,{])\\s*${J}\\s*(?:,|\\s*=|\\s*})`).test(H)))return!0}else return!0}}}X=W+1;continue}X++}return!1}function gZ($,J){let Z=new RegExp("^\\s*(?:let|var)\\s+(.+?);?\\s*$"),X=$.match(Z);if(!X)return null;let Y=X[1],z=G2(Y);if(z>=0){let q=Y.indexOf(":");if(q>=0&&q<z)Y=Y.slice(0,q)+Y.slice(z)}let Q=Q2(Y,","),G=[];for(let q of Q){let U=q.trim();if(!U)continue;if(U.match(/^[{[]/))return null;let K=U.match(/^([$A-Z_][\w$]*)/i);if(!K)return null;let H=K[1];if(!/=/.test(U))return null;let A=J.indexOf($),_=J.slice(A+$.length),F=`\\b${H}\\s*(?:${["=","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","^=","|="].map((y)=>y.replace(/[|\\^$*+?.(){}[\]]/g,(C)=>`\\${C}`)).join("|")})`,M=new RegExp(F).test(_),T=new RegExp(`(?:^|[^$w])(?:\\+\\+|--)\\s*${H}\\b|\\b${H}\\s*(?:\\+\\+|--)`).test(_),E=q2(_,H),j=U.indexOf("="),O=j>=0?U.slice(j+1):"",v=new RegExp(F).test(O);G.push({name:H,fixable:!M&&!T&&!E&&!v})}return G}var L8={meta:{docs:"Suggest 'const' for variables that are never reassigned (heuristic)"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=i0($);for(let z=0;z<X.length;z++){if(Y[z])continue;let Q=X[z],G=gZ(Q,$);if(!G)continue;for(let{name:q,fixable:U}of G){if(!U)continue;let W=Q.search(new RegExp(`\\b${q.replace(/\$/g,"\\$")}\\b`)),K=W!==-1?W:Q.indexOf(q);Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,K+1),ruleId:"prefer-const",message:`'${q}' is never reassigned. Use 'const' instead`,severity:"error",help:`Change 'let ${q}' to 'const ${q}' since the variable is never reassigned. This makes your code more predictable and prevents accidental mutations`})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=i0($),X=new Set,Y=/(?:eslint|pickier)-disable-next-line\b([^*\n]*)/;for(let Q=0;Q<J.length;Q++){let G=J[Q].match(Y);if(!G)continue;let q=G[1].trim();if(q===""||/\bprefer-const\b/.test(q))X.add(Q+2)}let z=!1;for(let Q=0;Q<J.length;Q++){if(X.has(Q+1))continue;if(Z[Q])continue;let G=J[Q];if(!/^\s*let\b/.test(G))continue;let q=gZ(G,$);if(!q||q.length===0)continue;if(!q.every((W)=>W.fixable))continue;let U=G.replace(/^(\s*)let(\s+)/,"$1const$2");if(U!==G)J[Q]=U,z=!0}return z?J.join(`
79
+ `):$}};var pZ={meta:{docs:"Prefer object spread ({...obj}) over Object.assign() for object composition"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/^\s*\/\//.test(z))continue;let Q=z.indexOf("//"),G=Q>=0?z.slice(0,Q):z,q=G.matchAll(/\bObject\.assign\s*\(/g);for(let U of q){let W=U.index,K=G.slice(0,W),H=(K.match(/'/g)||[]).length,V=(K.match(/"/g)||[]).length,A=(K.match(/`/g)||[]).length;if(H%2!==0||V%2!==0||A%2!==0)continue;let _=W+13,B=G.slice(_),F=-1,M=1,T=0,E=0,j=null,O=!1;for(let y=1;y<B.length;y++){let C=B[y];if(O){O=!1;continue}if(C==="\\"&&j){O=!0;continue}if(!j){if(C==="'")j="single";else if(C==='"')j="double";else if(C==="`")j="template";else if(C==="(")M++;else if(C===")"){if(M--,M===0)break}else if(C==="{")T++;else if(C==="}")T--;else if(C==="[")E++;else if(C==="]")E--;else if(C===","&&M===1&&T===0&&E===0){F=y;break}}else if(j==="single"&&C==="'"||j==="double"&&C==='"'||j==="template"&&C==="`")j=null}if(F===-1)continue;let v=B.slice(1,F).trim();if(v==="{}")Z.push({filePath:J.filePath,line:Y+1,column:W+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(v==="{}"||/^\{.*\}$/.test(v))Z.push({filePath:J.filePath,line:Y+1,column:W+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 Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[];for(let X=0;X<J.length;X++){let Y=J[X];Y=Y.replace(/\bObject\.assign\s*\(\s*\{\}\s*,\s*([^)]+)\)/g,(z,Q)=>{return`{${Q.split(",").map((q)=>q.trim()).map((q)=>`...${q}`).join(", ")}}`}),Z.push(Y)}return Z.join(`
80
+ `)}};function U2($,J){let Z=!1,X=!1,Y=!1;for(let z=0;z<J;z++){let Q=$[z];if(Q==="\\"){z++;continue}if(Q==="'"&&!X&&!Y)Z=!Z;else if(Q==='"'&&!Z&&!Y)X=!X;else if(Q==="`"&&!Z&&!X)Y=!Y}return Z||X||Y}var P8={meta:{docs:"Prefer template literals over string concatenation",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(Q.startsWith("//")||Q.startsWith("/*")||Q.startsWith("*")||Q.startsWith("import"))continue;let G=/(['"`][^'"`]*['"`])\s*\+\s*([a-z_$][\w$]*)/i,q=/([a-z_$][\w$]*)\s*\+\s*(['"`][^'"`]*['"`])/i,U=Q.match(G)||Q.match(q);if(U){let W=z.indexOf("//"),K=z.indexOf(U[0]);if(W>=0&&K>W)continue;if(U2(z,K))continue;let H=!!Q.match(q),V=!!Q.match(G);if(H&&!V){if(Q.slice(Q.indexOf(U[0])+U[0].length).startsWith("."))continue}Z.push({filePath:J.filePath,line:Y+1,column:K+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 Z}};var xZ={name:"general",rules:{"array-callback-return":w(M$),"constructor-super":w(j$),"for-direction":w(N$),"getter-return":w(T$),"no-async-promise-executor":w(E$),"no-compare-neg-zero":w(D$),"no-cond-assign":w(R$),"no-const-assign":w(O$),"no-constant-condition":w(L$),"no-constructor-return":w(vZ),"no-dupe-class-members":w(P$),"no-dupe-keys":w(y1),"no-duplicate-case":w(C$),"no-empty-pattern":w(I$),"no-fallthrough":w(S$),"no-irregular-whitespace":w(yZ),"no-loss-of-precision":w(v$),"no-new":w(bZ),"no-regex-spaces":w(kZ),"no-promise-executor-return":w(y$),"no-redeclare":w(b$),"no-self-assign":w(b1),"no-self-compare":w(k$),"no-sparse-arrays":w(f$),"no-undef":w(g$),"no-unsafe-negation":w(x$),"no-unreachable":w(p$),"no-unused-vars":w(n0),"no-useless-catch":w(h$),"prefer-const":w(L8),"prefer-object-spread":w(pZ),"prefer-template":w(P8),"use-isnan":w(u$),"valid-typeof":w(m$)}};var g1={npm:"registry.npmjs.org",yarn:"registry.yarnpkg.com",verdaccio:"registry.verdaccio.org"};function hZ($){let J=$.split("/").pop()||"";if(J==="package-lock.json")return"npm";if(J==="yarn.lock")return"yarn";if(J==="bun.lockb"||J==="bun.lock")return"bun";return null}function g0($,J){let Z=hZ(J);if(!Z)return!1;if(Z==="npm")try{let X=JSON.parse($);return"lockfileVersion"in X||"dependencies"in X||"packages"in X}catch{return!1}if(Z==="yarn")return $.startsWith("#")||$.includes("__metadata:")||$.includes('resolved "');if(Z==="bun")try{let X=JSON.parse($);return"lockfileVersion"in X||"packages"in X}catch{return!1}return!1}function W2($){let J=new Map,Z=JSON.parse($);if((Z.lockfileVersion||1)>=2&&Z.packages)for(let[Y,z]of Object.entries(Z.packages)){if(!Y||Y==="")continue;let Q=Y.replace(/^node_modules\//,"").replace(/\/node_modules\//g,"/"),G=Q.split("/node_modules/").pop()||Q;J.set(Y,{name:G,version:z.version||"",resolved:z.resolved,integrity:z.integrity})}else if(Z.dependencies)uZ(Z.dependencies,J,"");return{type:"npm",packages:J}}function uZ($,J,Z){for(let[X,Y]of Object.entries($)){let z=Z?`${Z}/${X}`:X;if(J.set(z,{name:X,version:Y.version||"",resolved:Y.resolved,integrity:Y.integrity}),Y.dependencies)uZ(Y.dependencies,J,z)}}function K2($){let J=new Map,Z=$.includes("__metadata:"),X=Z?"yarn-berry":"yarn",Y=$.split(`
81
+ `),z="",Q={};for(let G of Y){if(G.startsWith("#")||G.trim()==="")continue;if(!G.startsWith(" ")&&G.includes("@")&&G.endsWith(":")){if(z&&(Q.resolved||Q.integrity))J.set(z,Q);if(z=G.slice(0,-1).trim(),z.startsWith('"')&&z.endsWith('"'))z=z.slice(1,-1);let q=z.match(/^(@?[^@]+)@/);Q={name:q?q[1]:z.split("@")[0],version:""}}else if(G.startsWith(" ")||G.startsWith("\t")){let q=G.trim();if(q.startsWith("version")){let U=q.match(/version[:\s]+"?([^"]+)"?/);if(U)Q.version=U[1]}else if(q.startsWith("resolved")){let U=q.match(/resolved[:\s]+"?([^"]+)"?/);if(U)Q.resolved=U[1]}else if(q.startsWith("resolution:")&&Z){let U=q.match(/resolution[:\s]+"?([^"]+)"?/);if(U)Q.resolved=U[1]}else if(q.startsWith("integrity")||q.startsWith("checksum")){let U=q.match(/(integrity|checksum)[:\s]+"?([^"]+)"?/);if(U)Q.integrity=U[2]}}}if(z&&(Q.resolved||Q.integrity))J.set(z,Q);return{type:X,packages:J}}function H2($){let J=new Map,Z=JSON.parse($);if(Z.packages)for(let[X,Y]of Object.entries(Z.packages)){if(!X||X==="")continue;if(Array.isArray(Y)){let[z,Q,G,q]=Y,U=X,W="";if(typeof z==="string"&&z.includes("@")){let K=z.lastIndexOf("@");if(K>0)U=z.substring(0,K),W=z.substring(K+1)}J.set(X,{name:U,version:W,resolved:Q||void 0,integrity:q||void 0})}else if(typeof Y==="object")J.set(X,{name:Y.name||X.split("@")[0],version:Y.version||"",resolved:Y.resolved,integrity:Y.integrity||Y.hash})}return{type:"bun",packages:J}}function p0($,J){let Z=hZ(J);if(!Z)return null;try{switch(Z){case"npm":return W2($);case"yarn":return K2($);case"bun":return H2($);default:return null}}catch{return null}}function mZ($){try{return new URL($).hostname}catch{return null}}function C8($){try{return new URL($).protocol}catch{return null}}function dZ($){try{let Z=new URL($).pathname,X=Z.indexOf("/-/");if(X===-1)return null;let Y=Z.substring(1,X);if(Y.startsWith("@"))return Y;return Y}catch{return null}}function oZ($){if(!$)return null;let J=$.match(/^(sha\d+)-/);return J?J[1]:null}function cZ($){return $.map((J)=>{let Z=J.toLowerCase();return g1[Z]||J})}var lZ={meta:{docs:"Ensure all packages are from allowed registry hosts",recommended:!0},check($,J){let Z=[];if(!g0($,J.filePath))return Z;let X=p0($,J.filePath);if(!X)return Z;let Y=J.options||{},z=Y.allowedHosts||["npm","yarn"],Q=Y.emptyHostname!==!1,G=cZ(z),q=$.split(`
82
+ `);for(let[U,W]of X.packages){if(!W.resolved){if(!Q){let H=rZ(q,U);Z.push({filePath:J.filePath,line:H,column:1,ruleId:"lockfile/validate-host",message:`Package "${W.name}" has no resolved URL`,severity:"error",help:"All packages should have a resolved URL from an allowed registry."})}continue}let K=mZ(W.resolved);if(!K)continue;if(!G.includes(K)){let H=rZ(q,U),V=z.map((A)=>g1[A.toLowerCase()]||A).join(", ");Z.push({filePath:J.filePath,line:H,column:1,ruleId:"lockfile/validate-host",message:`Invalid host for package "${W.name}": expected one of [${V}], got "${K}"`,severity:"error",help:`Package is resolving from an unauthorized registry. This could indicate a supply chain attack. Allowed hosts: ${V}`})}}return Z}};function rZ($,J){for(let Z=0;Z<$.length;Z++)if($[Z].includes(J)||$[Z].includes(`"${J}"`))return Z+1;return 1}var aZ={meta:{docs:"Ensure all packages use HTTPS protocol",recommended:!0},check($,J){let Z=[];if(!g0($,J.filePath))return Z;let X=p0($,J.filePath);if(!X)return Z;let Y=$.split(`
83
+ `);for(let[z,Q]of X.packages){if(!Q.resolved)continue;let G=C8(Q.resolved);if(!G)continue;if(G!=="https:"){let q=V2(Y,z);Z.push({filePath:J.filePath,line:q,column:1,ruleId:"lockfile/validate-https",message:`Package "${Q.name}" uses insecure protocol: "${G}" instead of "https:"`,severity:"error",help:"All packages should be downloaded over HTTPS to prevent man-in-the-middle attacks."})}}return Z}};function V2($,J){for(let Z=0;Z<$.length;Z++)if($[Z].includes(J)||$[Z].includes(`"${J}"`))return Z+1;return 1}var sZ={meta:{docs:"Ensure all packages use strong integrity hashes (SHA512)",recommended:!0},check($,J){let Z=[];if(!g0($,J.filePath))return Z;let X=p0($,J.filePath);if(!X)return Z;let Y=J.options||{},z=Y.requiredAlgorithm||"sha512",Q=new Set(Y.exclude||[]),G={sha1:1,sha256:2,sha384:3,sha512:4},q=G[z]||4,U=$.split(`
84
+ `);for(let[W,K]of X.packages){if(Q.has(K.name))continue;if(!K.integrity)continue;let H=oZ(K.integrity);if(!H)continue;if((G[H.toLowerCase()]||0)<q){let A=A2(U,W);Z.push({filePath:J.filePath,line:A,column:1,ruleId:"lockfile/validate-integrity",message:`Package "${K.name}" uses weak hash algorithm: "${H}" (required: ${z})`,severity:"error",help:`Weak hash algorithms are susceptible to collision attacks. Upgrade to ${z} by regenerating your lockfile with a recent package manager.`})}}return Z}};function A2($,J){for(let Z=0;Z<$.length;Z++)if($[Z].includes(J)||$[Z].includes(`"${J}"`))return Z+1;return 1}var nZ={meta:{docs:"Ensure package names match their resolved URLs",recommended:!0},check($,J){let Z=[];if(!g0($,J.filePath))return Z;let X=p0($,J.filePath);if(!X)return Z;let z=(J.options||{}).aliases||{},Q=Object.values(g1),G=$.split(`
85
+ `);for(let[q,U]of X.packages){if(!U.resolved)continue;let W=!1;try{let A=new URL(U.resolved);W=Q.includes(A.hostname)}catch{continue}if(!W)continue;let K=dZ(U.resolved);if(!K)continue;let H=U.name,V=z[H]||H;if(K!==V){let A=_2(G,q);Z.push({filePath:J.filePath,line:A,column:1,ruleId:"lockfile/validate-package-names",message:`Package name mismatch: "${H}" resolves to "${K}"`,severity:"error",help:`This could indicate a package substitution attack. The lockfile entry is for "${H}" but the resolved URL points to "${K}".`})}}return Z}};function _2($,J){for(let Z=0;Z<$.length;Z++)if($[Z].includes(J)||$[Z].includes(`"${J}"`))return Z+1;return 1}var iZ={meta:{docs:"Ensure all packages use allowed URL schemes",recommended:!0},check($,J){let Z=[];if(!g0($,J.filePath))return Z;let X=p0($,J.filePath);if(!X)return Z;let Q=((J.options||{}).allowedSchemes||["https:","git+https:","git+ssh:"]).map((q)=>q.endsWith(":")?q:`${q}:`),G=$.split(`
86
+ `);for(let[q,U]of X.packages){if(!U.resolved)continue;let W=C8(U.resolved);if(!W)continue;if(!Q.includes(W)){let K=F2(G,q);Z.push({filePath:J.filePath,line:K,column:1,ruleId:"lockfile/validate-scheme",message:`Package "${U.name}" uses disallowed URL scheme: "${W}"`,severity:"error",help:`Only the following URL schemes are allowed: ${Q.join(", ")}. Using "${W}" could be a security risk.`})}}return Z}};function F2($,J){for(let Z=0;Z<$.length;Z++)if($[Z].includes(J)||$[Z].includes(`"${J}"`))return Z+1;return 1}var tZ={name:"lockfile",rules:{"validate-host":lZ,"validate-https":aZ,"validate-integrity":sZ,"validate-package-names":nZ,"validate-scheme":iZ}};var eZ={meta:{docs:"Fenced code blocks should be surrounded by blank lines"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z];if(/^(?:`{3,}|~{3,})/.test(Q.trim()))if(!Y){let q=z>0?X[z-1]:"";if(z>0&&q.trim().length>0){if(!/^:::/.test(q.trim()))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-fences",message:"Fenced code blocks should be surrounded by blank lines",severity:"error"})}Y=!0}else{let q=z+1<X.length?X[z+1]:"";if(z+1<X.length&&q.trim().length>0){if(!/^:::/.test(q.trim()))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-fences",message:"Fenced code blocks should be surrounded by blank lines",severity:"error"})}Y=!1}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[],X=!1;for(let Y=0;Y<J.length;Y++){let z=J[Y],Q=Y>0?J[Y-1]:"",G=/^(?:`{3,}|~{3,})/.test(z.trim());if(G)if(!X){if(Y>0&&Q.trim().length>0&&!/^:::/.test(Q.trim())&&Z.length>0)Z.push("");X=!0}else X=!1;if(Z.push(z),G&&!X&&Y+1<J.length){let q=J[Y+1];if(q.trim().length>0&&!/^:::/.test(q.trim()))Z.push("")}}return Z.join(`
87
+ `)}};var $J={meta:{docs:"Headings should be surrounded by blank lines"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z],G=z>0?X[z-1]:"",q=z+1<X.length?X[z+1]:"";if(/^(?:`{3,}|~{3,})/.test(Q.trim())){Y=!Y;continue}if(Y)continue;let U=/^#{1,6}\s/.test(Q),W=z+1<X.length&&/^(?:=+|-+)\s*$/.test(q)&&Q.trim().length>0;if(U){if(z>0&&G.trim().length>0)Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"});if(z+1<X.length&&q.trim().length>0&&!/^#{1,6}\s/.test(q))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"})}if(W){if(z>0&&G.trim().length>0)Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"});let K=z+2<X.length?X[z+2]:"";if(z+2<X.length&&K.trim().length>0)Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[],X=!1;for(let Y=0;Y<J.length;Y++){let z=J[Y],Q=Y>0?J[Y-1]:"",G=Y+1<J.length?J[Y+1]:"";if(/^(?:`{3,}|~{3,})/.test(z.trim())){X=!X,Z.push(z);continue}if(X){Z.push(z);continue}let q=/^#{1,6}\s/.test(z),U=Y+1<J.length&&/^(?:=+|-+)\s*$/.test(G)&&z.trim().length>0;if(q||U){if(Y>0&&Q.trim().length>0&&Z.length>0)Z.push("")}if(Z.push(z),q){if(Y+1<J.length&&G.trim().length>0&&!/^#{1,6}\s/.test(G))Z.push("")}if(Y>0&&/^(?:=+|-+)\s*$/.test(z)&&J[Y-1].trim().length>0){if((Y+1<J.length?J[Y+1]:"").trim().length>0)Z.push("")}}return Z.join(`
88
+ `)}};var ZJ={meta:{docs:"Lists should be surrounded by blank lines"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q],q=Q>0?X[Q-1]:"";if(/^(?:`{3,}|~{3,})/.test(G.trim())){if(z=!z,Y)Y=!1;continue}if(z)continue;let U=/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(G),W=Y&&!U&&G.trim().length>0&&/^\s+/.test(G);if(U&&!Y){if(Y=!0,Q>0&&q.trim().length>0)Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"markdown/blanks-around-lists",message:"Lists should be surrounded by blank lines",severity:"error"})}else if(!U&&!W&&Y&&G.trim().length>0){if(Y=!1,/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(q))Z.push({filePath:J.filePath,line:Q,column:1,ruleId:"markdown/blanks-around-lists",message:"Lists should be surrounded by blank lines",severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[],X=!1,Y=!1,z=(Q)=>/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(Q);for(let Q=0;Q<J.length;Q++){let G=J[Q],q=Q>0?J[Q-1]:"";if(/^(?:`{3,}|~{3,})/.test(G.trim())){Y=!Y,X=!1,Z.push(G);continue}if(Y){Z.push(G);continue}let U=z(G),W=G.trim().length===0,K=X&&!U&&!W&&/^\s/.test(G);if(U&&!X){if(Q>0&&q.trim().length>0&&Z.length>0)Z.push("");X=!0}else if(!U&&!K&&!W&&X){if(X=!1,Z.length>0)Z.push("")}else if(W){let H=Q+1<J.length?J[Q+1]:"",V=z(H),A=/^\s+\S/.test(H);if(!V&&!A&&X)X=!1}Z.push(G)}return Z.join(`
89
+ `)}};function h($){let J=new Set,Z=null,X=0,Y=!1,z=!1;for(let Q=0;Q<$.length;Q++){let G=$[Q],q=G.trim();if(Z===null){let H=q.match(/^(`{3,}|~{3,})(.*)$/);if(H){let V=H[1],A=H[2],_=V[0];if(_==="`"&&A.includes("`"));else{Z=_,X=V.length,J.add(Q),Y=!1,z=!1;continue}}}else{J.add(Q);let H=q.match(/^(`{3,}|~{3,})\s*$/);if(H&&H[1][0]===Z&&H[1].length>=X)Z=null,X=0;continue}let U=G.length-G.trimStart().length,W=/^\t/.test(G);if((U>=4||W)&&q.length>0){if(z||Y||Q===0)J.add(Q),z=!0;Y=z;continue}if(q.length===0){if(z)J.add(Q),Y=!0;else Y=!0;continue}z=!1,Y=!1}return J}function JJ($,J,Z){let X=0,Y=0;while(X<$.length){if($[X]!=="`"){X++;continue}let z=0;while($[X+z]==="`")z++;let Q=X+z,G=-1;while(Q<$.length)if($[Q]==="`"){let q=0;while($[Q+q]==="`")q++;if(q===z){G=Q;break}Q+=q}else Q++;if(G===-1){X+=z;continue}if(Y<X)J($.slice(Y,X));Z($.slice(X,G+z)),X=G+z,Y=X}if(Y<$.length)J($.slice(Y))}function M1($,J){let Z="";return JJ($,(X)=>{Z+=J(X)},(X)=>{Z+=X}),Z}function t0($){let J="";return JJ($,(Z)=>{J+=Z},(Z)=>{J+=" ".repeat(Z.length)}),J}function XJ($){let J=h($),Z=[],X=0;for(let Y=0;Y<$.length;Y++){let z=$[Y];if(J.has(Y)||z.trim()===""){X=0,Z.push(z);continue}if(X===0){let q=t0(z),U=B2(q);if(!U){Z.push(q);continue}X=U.length,Z.push(q.slice(0,U.index)+" ".repeat(q.length-U.index));continue}let Q=new RegExp(`(?<!\`)\`{${X}}(?!\`)`).exec(z);if(!Q){Z.push(" ".repeat(z.length));continue}let G=Q.index+Q[0].length;X=0,Z.push(" ".repeat(G)+t0(z.slice(G)))}return Z}function B2($){let J=/(?<!`)(`+)(?!`)(?=[^`]*$)/.exec($);return J?{index:J.index,length:J[1].length}:null}function X1($){let J=new Set,Z=h($);for(let X=0;X<$.length;X++){if(Z.has(X))continue;let Y=$[X];if(!w2(Y))continue;if(X>0&&!Z.has(X-1)&&/\|/.test($[X-1])&&$[X-1].trim().length>0)J.add(X-1);J.add(X);for(let z=X+1;z<$.length;z++){if(Z.has(z))break;let Q=$[z];if(Q.trim().length===0||!/\|/.test(Q))break;J.add(z)}}return J}function w2($){let J=$.trim();if(!J.includes("|"))return!1;if(!/^[|\s:-]+$/.test(J))return!1;if(!/-{3,}/.test(J))return!1;return!0}var YJ={meta:{docs:"Tables should be surrounded by blank lines"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1,Q=X1(X);for(let G=0;G<X.length;G++){let q=X[G],U=G>0?X[G-1]:"";if(/^(?:`{3,}|~{3,})/.test(q.trim())){if(z=!z,Y)Y=!1;continue}if(z)continue;let W=Q.has(G)&&/\|/.test(q)&&q.trim().length>0;if(W&&!Y){if(Y=!0,G>0&&U.trim().length>0)Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"markdown/blanks-around-tables",message:"Tables should be surrounded by blank lines",severity:"error"})}else if(!W&&Y){if(Y=!1,q.trim().length>0)Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"markdown/blanks-around-tables",message:"Tables should be surrounded by blank lines",severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=h(J),X=X1(J),Y=[],z=!1;for(let G=0;G<J.length;G++){let q=J[G];if(Z.has(G)){Y.push(q);continue}let U=X.has(G)&&/\|/.test(q)&&q.trim().length>0;if(U&&!z){let W=Y.length-1;if(W>=0&&Y[W].trim().length>0)Y.push("");z=!0,Y.push(q);continue}if(!U&&z){if(z=!1,q.trim().length>0)Y.push("")}Y.push(q)}let Q=Y.join(`
90
+ `);return Q!==$?Q:$}};var zJ={meta:{docs:"Code block style should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).style||"consistent",Q=null,G=!1;for(let q=0;q<X.length;q++){let U=X[q];if(/^(?:`{3,}|~{3,})/.test(U)){if(G=!G,z==="indented")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-block-style",message:"Expected indented code block style",severity:"error"});else if(z==="consistent"){if(Q===null)Q="fenced";else if(Q==="indented")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-block-style",message:"Code block style should be consistent throughout document",severity:"error"})}continue}if(G)continue;if(/^(?: {4}|\t)/.test(U)&&U.trim().length>0){let V=(q>0?X[q-1]:"").trim().length===0||q===0;if(V&&z==="fenced")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-block-style",message:"Expected fenced code block style",severity:"error"});else if(V&&z==="consistent"){if(Q===null)Q="indented";else if(Q==="fenced")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-block-style",message:"Code block style should be consistent throughout document",severity:"error"})}}}return Z}};function QJ($){let J=new Set,Z=null,X=0;for(let Y=0;Y<$.length;Y++){let z=$[Y].trim();if(Z===null){let Q=z.match(/^(`{3,}|~{3,})(.*)$/);if(Q){let G=Q[1][0];if(G==="`"&&Q[2].includes("`"))continue;Z=G,X=Q[1].length,J.add(Y)}}else{let Q=z.match(/^(`{3,}|~{3,})\s*$/);if(Q&&Q[1][0]===Z&&Q[1].length>=X)J.add(Y),Z=null,X=0}}return J}var GJ={meta:{docs:"Code fence style should be consistent (backtick or tilde)"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=QJ(X),Q=(J.options||{}).style||"consistent",G=null;for(let q of Y){let U=X[q],K=/^`{3,}/.test(U.trim())?"backtick":"tilde";if(Q==="backtick"||Q==="tilde"){if(K!==Q)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-fence-style",message:Q==="tilde"?"Expected tilde (~~~) code fence":"Expected backtick (```) code fence",severity:"error"})}else if(Q==="consistent"){if(G===null)G=K;else if(G!==K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-fence-style",message:"Code fence style should be consistent throughout document",severity:"error"})}}return Z},fix:($,J)=>{let X=(J.options||{}).style||"consistent",Y=$.split(/\r?\n/),z=QJ(Y),Q="backtick";if(X==="backtick"||X==="tilde")Q=X;else for(let W of z){Q=/^`{3,}/.test(Y[W].trim())?"backtick":"tilde";break}let G=Q==="backtick"?"`":"~",q=Q==="backtick"?/^(\s*)(~{3,})(.*)$/:/^(\s*)(`{3,})(.*)$/;return Y.map((W,K)=>{if(!z.has(K))return W;return W.replace(q,(H,V,A,_)=>`${V}${G.repeat(A.length)}${_}`)}).join(`
91
+ `)}};var qJ={meta:{docs:"Commands in code blocks should not be prefixed with $ unless showing output"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=-1;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(/^(?:`{3,}|~{3,})/.test(G)){if(!Y)Y=!0,z=Q;else Y=!1;continue}if(Y&&/^\$\s+/.test(G.trim())){let q=!0,U=!1;for(let W=z+1;W<Q;W++){let K=X[W].trim();if(K.length>0){if(U=!0,!K.startsWith("$")){q=!1;break}}}if(q&&U)Z.push({filePath:J.filePath,line:Q+1,column:G.indexOf("$")+1,ruleId:"markdown/commands-show-output",message:"Dollar signs used before commands without showing output",severity:"warning"})}}return Z}};var UJ={meta:{docs:"Link text should be meaningful and descriptive"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=["click here","here","link","read more","more","this"],z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(/^(?:`{3,}|~{3,})/.test(G.trim())){z=!z;continue}if(z)continue;let U=G.replace(/``[^`]+``/g,(W)=>" ".repeat(W.length)).replace(/`[^`]+`/g,(W)=>" ".repeat(W.length)).matchAll(/\[([^\]]+)\]\([^)]+\)/g);for(let W of U){let K=W[1].toLowerCase().trim();if(Y.includes(K)){let H=W.index+1;Z.push({filePath:J.filePath,line:Q+1,column:H,ruleId:"markdown/descriptive-link-text",message:`Link text '${W[1]}' is not descriptive`,severity:"warning"})}}}return Z}};var L7="(?<!\\*)\\*(?!\\*)(?!\\s)([^*]*[^*\\s])\\*(?!\\*)",M2=new RegExp(L7),P7="(?<![A-Za-z0-9_])_(?!_)([^_]+)_(?![A-Za-z0-9_])",j2=new RegExp(P7),WJ={meta:{docs:"Emphasis style should be consistent (asterisk or underscore)"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).style||"consistent",Q=null,G=h(X),q=XJ(X);for(let U=0;U<X.length;U++){let W=X[U];if(G.has(U))continue;let K=q[U]??t0(W),H=K.matchAll(new RegExp(L7,"g"));for(let A of H)if(z==="underscore")Z.push({filePath:J.filePath,line:U+1,column:A.index+1,ruleId:"markdown/emphasis-style",message:"Expected underscore (_) for emphasis",severity:"error"});else if(z==="consistent"){if(Q===null)Q="asterisk";else if(Q==="underscore")Z.push({filePath:J.filePath,line:U+1,column:A.index+1,ruleId:"markdown/emphasis-style",message:"Emphasis style should be consistent throughout document",severity:"error"})}let V=K.matchAll(new RegExp(P7,"g"));for(let A of V)if(z==="asterisk")Z.push({filePath:J.filePath,line:U+1,column:A.index+1,ruleId:"markdown/emphasis-style",message:"Expected asterisk (*) for emphasis",severity:"error"});else if(z==="consistent"){if(Q===null)Q="underscore";else if(Q==="asterisk")Z.push({filePath:J.filePath,line:U+1,column:A.index+1,ruleId:"markdown/emphasis-style",message:"Emphasis style should be consistent throughout document",severity:"error"})}}return Z},fix:($,J)=>{let X=(J.options||{}).style||"consistent",Y=$.split(/\r?\n/),z=h(Y),Q="asterisk";if(X==="asterisk")Q="asterisk";else if(X==="underscore")Q="underscore";else if(X==="consistent"){let q=null,U=null;for(let K=0;K<Y.length;K++){if(z.has(K))continue;let H=t0(Y[K]);if(q===null){let V=H.match(M2);if(V)q={line:K,col:V.index}}if(U===null){let V=H.match(j2);if(V)U={line:K,col:V.index}}if(q&&U)break}if(q&&(!U||((K,H)=>K.line!==H.line?K.line-H.line:K.col-H.col)(q,U)<0))Q="asterisk";else if(U)Q="underscore"}let G=!1;for(let q=0;q<Y.length;q++){if(z.has(q))continue;let U=M1(Y[q],(W)=>Q==="asterisk"?W.replace(new RegExp(P7,"g"),"*$1*"):W.replace(new RegExp(L7,"g"),"_$1_"));if(U!==Y[q])Y[q]=U,G=!0}return G?Y.join(`
92
+ `):$}};var KJ={meta:{docs:"Fenced code blocks should have a language specified"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++)if(X[Y].match(/^(?:`{3,}|~{3,})\s*$/)){let G=!0;for(let q=Y-1;q>=0;q--)if(/^(?:`{3,}|~{3,})/.test(X[q])){G=!1;break}if(G)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"markdown/fenced-code-language",message:"Fenced code blocks should have a language specified",severity:"error"})}return Z}};var HJ={meta:{docs:"First line in a file should be a top-level heading"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=-1;for(let q=0;q<X.length;q++)if(X[q].trim().length>0){Y=q;break}if(Y===-1)return Z;let z=X[Y],Q=/^#\s/.test(z),G=Y+1<X.length&&/^=+\s*$/.test(X[Y+1]);if(!Q&&!G)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"markdown/first-line-heading",message:"First line in a file should be a top-level heading",severity:"warning"});return Z}};var VJ={meta:{docs:"Heading levels should only increment by one level at a time"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X),z=0;for(let Q=0;Q<X.length;Q++){if(Y.has(Q))continue;let q=X[Q].match(/^(#{1,6})\s/);if(q){let U=q[1].length;if(z>0&&U>z+1)Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"markdown/heading-increment",message:`Heading level should not skip from h${z} to h${U}`,severity:"error"});z=U}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=h(J),X=0,Y=!1;for(let z=0;z<J.length;z++){if(Z.has(z))continue;let G=J[z].match(/^(#{1,6})(\s.*)$/);if(!G)continue;let q=G[1].length,U=X===0?q:Math.min(q,X+1);if(U!==q)J[z]="#".repeat(U)+G[2],Y=!0;X=U}return Y?J.join(`
93
+ `):$}};var AJ={meta:{docs:"Headings must start at the beginning of the line"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z];if(/^(?:`{3,}|~{3,})/.test(Q.trim())){Y=!Y;continue}if(Y)continue;if(Q.match(/^(\s+)(#{1,6}\s)/))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/heading-start-left",message:"Headings must start at the beginning of the line",severity:"error"})}return Z},fix:($)=>{return $.split(/\r?\n/).map((X)=>{return X.replace(/^(\s+)(#{1,6}\s)/,"$2")}).join(`
94
+ `)}};var _J={meta:{docs:"Heading style should be consistent (atx, setext, or consistent)"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).style||"consistent",Q=null,G=h(X);for(let q=0;q<X.length;q++){if(G.has(q))continue;let U=X[q],W=q+1<X.length?X[q+1]:"",K=U.match(/^#{1,6}\s/),H=W.match(/^(?:=+|-+)\s*$/)&&U.trim().length>0&&!G.has(q+1);if(K){if(z==="setext")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/heading-style",message:"Expected setext style heading",severity:"error"});else if(z==="consistent"){if(Q===null)Q="atx";else if(Q==="setext")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/heading-style",message:"Heading style should be consistent throughout document",severity:"error"})}}else if(H){if(z==="atx")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/heading-style",message:"Expected atx style heading",severity:"error"});else if(z==="consistent"){if(Q===null)Q="setext";else if(Q==="atx")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/heading-style",message:"Heading style should be consistent throughout document",severity:"error"})}}}return Z},fix:($,J)=>{let X=(J.options||{}).style||"consistent",Y=$.split(/\r?\n/),z=h(Y),Q=X==="consistent"?null:X;if(Q===null)for(let U=0;U<Y.length;U++){if(z.has(U))continue;let W=Y[U],K=U+1<Y.length?Y[U+1]:"";if(/^#{1,6}\s/.test(W)){Q="atx";break}if(/^(?:=+|-+)\s*$/.test(K)&&W.trim().length>0&&!z.has(U+1)){Q="setext";break}}if(Q===null)return $;let G=[],q=!1;for(let U=0;U<Y.length;U++){let W=Y[U];if(z.has(U)){G.push(W);continue}let K=U+1<Y.length?Y[U+1]:"";if(Q==="atx"){let H=/^=+\s*$/.test(K),V=/^-+\s*$/.test(K),A=z.has(U+1);if((H||V)&&!A&&W.trim().length>0&&!/^#{1,6}\s/.test(W)){let _=H?"#":"##";G.push(`${_} ${W.trim()}`),U++,q=!0;continue}}if(Q==="setext"){let H=W.match(/^(#{1,2})\s+(.+?)\s*#*\s*$/);if(H){let V=H[1].length,A=H[2],_=(V===1?"=":"-").repeat(Math.max(3,A.length));G.push(A),G.push(_),q=!0;continue}}G.push(W)}return q?G.join(`
95
+ `):$}};var FJ={meta:{docs:"Horizontal rule style should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).style||"consistent",Q=null;for(let G=0;G<X.length;G++){let q=X[G].trim();if(q.match(/^([-*_])\1{2,}$/)){let W=q;if(z!=="consistent"&&q!==z)Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"markdown/hr-style",message:`Expected horizontal rule style '${z}'`,severity:"error"});else if(z==="consistent"){if(Q===null)Q=W;else if(Q!==W)Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"markdown/hr-style",message:"Horizontal rule style should be consistent throughout document",severity:"error"})}}}return Z}};var BJ={meta:{docs:"Lines should not exceed a specified length"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=J.options||{},z=Y.line_length||80,Q=Y.code_blocks!==!1,G=Y.tables!==!1,q=Y.headings!==!1,U=!1;for(let W=0;W<X.length;W++){let K=X[W];if(/^(?:`{3,}|~{3,})/.test(K)){U=!U;continue}if(U&&!Q)continue;if(!G&&/\|/.test(K))continue;if(!q&&/^#{1,6}\s/.test(K))continue;if(K.length>z)Z.push({filePath:J.filePath,line:W+1,column:z+1,ruleId:"markdown/line-length",message:`Line length exceeds ${z} characters (${K.length} characters)`,severity:"warning"})}return Z}};function N2($){return $.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s/g,"-")}var wJ={meta:{docs:"Link fragments should reference valid headings"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X),z=new Set;for(let Q=0;Q<X.length;Q++){if(Y.has(Q))continue;let q=X[Q].match(/^#{1,6}\s+(.+?)(?:\s*#+\s*)?$/);if(q){let U=q[1].trim();z.add(N2(U))}}for(let Q=0;Q<X.length;Q++){if(Y.has(Q))continue;let q=X[Q].matchAll(/\[[^\]]+\]\(#([^)]+)\)/g);for(let U of q){let W=U[1];if(!z.has(W)){let K=U.index+1;Z.push({filePath:J.filePath,line:Q+1,column:K,ruleId:"markdown/link-fragments",message:`Link fragment '#${W}' does not match any heading`,severity:"error"})}}}return Z}};var MJ={meta:{docs:"Link and image reference definitions should be used"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X),z=new Map;for(let G=0;G<X.length;G++){if(Y.has(G))continue;let U=X[G].match(/^\[([^\]]+)\]:\s*\S+/);if(U)z.set(U[1].toLowerCase(),G+1)}let Q=new Set;for(let G=0;G<X.length;G++){if(Y.has(G))continue;let q=X[G];if(q.match(/^\[(?:[^\]]+)\]:\s*\S+/))continue;let U=q.matchAll(/\[([^\]]+)\](?:\[([^\]]+)\])?(?!\()/g);for(let W of U){let K=(W[2]||W[1]).toLowerCase();Q.add(K)}}for(let[G,q]of z)if(!Q.has(G))Z.push({filePath:J.filePath,line:q,column:1,ruleId:"markdown/link-image-reference-definitions",message:`Unused reference definition '[${G}]'`,severity:"warning"});return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=h(J),X=new Map;for(let Q=0;Q<J.length;Q++){if(Z.has(Q))continue;let G=J[Q].match(/^\s*\[([^\]]+)\]:\s*\S+/);if(G)X.set(Q,G[1].toLowerCase())}if(X.size===0)return $;let Y=new Set;for(let Q=0;Q<J.length;Q++){if(Z.has(Q))continue;if(X.has(Q))continue;let q=J[Q].matchAll(/\[([^\]]+)\](?:\[([^\]]*)\])?(?!\()/g);for(let U of q){let W=(U[2]&&U[2].length>0?U[2]:U[1]).toLowerCase();Y.add(W)}}let z=new Set;for(let[Q,G]of X)if(!Y.has(G))z.add(Q);if(z.size===0)return $;return J.filter((Q,G)=>!z.has(G)).join(`
96
+ `)}};var jJ={meta:{docs:"Link and image style should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X),Q=(J.options||{}).style||"consistent",G=Q==="consistent"?null:Q;if(G===null){let U=0,W=0,K=!1;for(let H=0;H<X.length;H++){if(Y.has(H))continue;let V=X[H];if(V.includes("<!--"))K=!0;if(V.includes("-->")){K=!1;continue}if(K)continue;if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(V))continue;let A=C7(V);U+=(A.match(/\[[^\]]+\]\([^)]+\)/g)||[]).length,W+=(A.match(/\[[^\]]+\]\[(?:[^\]]*)\]/g)||[]).length}G=W>U?"reference":"inline"}let q=!1;for(let U=0;U<X.length;U++){if(Y.has(U))continue;let W=X[U];if(W.includes("<!--"))q=!0;if(W.includes("-->")){q=!1;continue}if(q)continue;if(W.match(/^\[(?:[^\]]+)\]:\s*\S+/))continue;let K=C7(W),H=K.matchAll(/\[[^\]]+\]\([^)]+\)/g);for(let A of H)if(G==="reference")Z.push({filePath:J.filePath,line:U+1,column:A.index+1,ruleId:"markdown/link-image-style",message:Q==="consistent"?"Link style should be consistent throughout document":"Expected reference style link",severity:Q==="consistent"?"warning":"error"});let V=K.matchAll(/\[[^\]]+\]\[(?:[^\]]+)\]/g);for(let A of V)if(G==="inline")Z.push({filePath:J.filePath,line:U+1,column:A.index+1,ruleId:"markdown/link-image-style",message:Q==="consistent"?"Link style should be consistent throughout document":"Expected inline style link",severity:Q==="consistent"?"warning":"error"})}return Z},fix:($,J)=>{let X=(J.options||{}).style||"consistent",Y=$.split(/\r?\n/),z=h(Y),Q=new Map;for(let U=0;U<Y.length;U++){if(z.has(U))continue;let W=Y[U].match(/^\s*\[([^\]]+)\]:\s*(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?\s*$/);if(W){let K=W[1].toLowerCase(),H=W[2],V=W[3]??W[4]??W[5];if(!Q.has(K))Q.set(K,{url:H,title:V})}}if(Q.size===0)return $;let G=X==="reference"?"reference":"inline";if(X==="consistent"){let U=0,W=0;for(let K=0;K<Y.length;K++){if(z.has(K))continue;let H=Y[K];if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(H))continue;let V=C7(H);U+=(V.match(/\[[^\]]+\]\([^)]+\)/g)||[]).length,W+=(V.match(/\[[^\]]+\]\[(?:[^\]]*)\]/g)||[]).length}G=W>U?"reference":"inline"}if(G!=="inline")return $;let q=!1;for(let U=0;U<Y.length;U++){if(z.has(U))continue;let W=Y[U];if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(W))continue;let K=W;for(let H=0;H<8;H++){let V=K.replace(/(!?)\[((?:[^[\]]|\[[^\]]*\]\([^)]*\))+)\]\[([^\]]*)\]/g,(A,_,B,F)=>{let M=(F.trim()===""?B:F).toLowerCase(),T=Q.get(M);if(!T)return A;let E=T.title?` "${T.title}"`:"";return`${_}[${B}](${T.url}${E})`});if(V===K)break;K=V}if(K!==W)Y[U]=K,q=!0}return q?Y.join(`
97
+ `):$}};function C7($){return $.replace(/(`+)([^`]+?)\1/g,(J)=>" ".repeat(J.length))}var NJ={meta:{docs:"List items at the same level should have consistent indentation"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map,z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q],q=G.match(/^(\s*)(?:[*\-+]|\d+\.)\s+/);if(q){z=!0;let U=q[1].length,W=Math.floor(U/2);if(Y.has(W)){let K=Y.get(W);if(U!==K)Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"markdown/list-indent",message:`Inconsistent indentation for list items at the same level. Expected ${K} spaces, found ${U}`,severity:"error"})}else Y.set(W,U)}else if(G.trim().length===0){if(z){let U=X.slice(Q+1).find((W)=>W.trim().length>0);if(U&&!/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(U))z=!1,Y.clear()}}}return Z}};var TJ={meta:{docs:"Spaces after list markers should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=J.options||{},z=Y.ul_single||1,Q=Y.ol_single||1;for(let G=0;G<X.length;G++){let q=X[G],U=q.match(/^(\s*)([*\-+])(\s+)/);if(U){let K=U[3].length;if(K!==z)Z.push({filePath:J.filePath,line:G+1,column:U[1].length+2,ruleId:"markdown/list-marker-space",message:`Expected ${z} space${z!==1?"s":""} after list marker, found ${K}`,severity:"error"})}let W=q.match(/^(\s*)(\d+\.)(\s+)/);if(W){let K=W[3].length;if(K!==Q)Z.push({filePath:J.filePath,line:G+1,column:W[1].length+W[2].length+1,ruleId:"markdown/list-marker-space",message:`Expected ${Q} space${Q!==1?"s":""} after list marker, found ${K}`,severity:"error"})}}return Z},fix:($,J)=>{let Z=J.options||{},X=Z.ul_single||1,Y=Z.ol_single||1;return $.split(/\r?\n/).map((G)=>{return G=G.replace(/^(\s*)([*\-+])\s+/,(q,U,W)=>{return`${U}${W}${" ".repeat(X)}`}),G=G.replace(/^(\s*)(\d+\.)\s+/,(q,U,W)=>{return`${U}${W}${" ".repeat(Y)}`}),G}).join(`
98
+ `)}};var EJ={meta:{docs:"Images should have alternate text"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z];if(/^(?:`{3,}|~{3,})/.test(Q.trim())){Y=!Y;continue}if(Y)continue;let q=Q.replace(/``[^`]+``/g,(U)=>" ".repeat(U.length)).replace(/`[^`]+`/g,(U)=>" ".repeat(U.length)).matchAll(/!\[\s*\]\([^)]+\)/g);for(let U of q){let W=U.index+1;Z.push({filePath:J.filePath,line:z+1,column:W,ruleId:"markdown/no-alt-text",message:"Images should have alternate text (alt text)",severity:"error"})}}return Z}};var DJ={meta:{docs:"Bare URLs should be wrapped in angle brackets"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X),z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y.has(Q))continue;if(G.includes("<!--"))z=!0;if(G.includes("-->")){z=!1;continue}if(z)continue;if(/^\[(?:[^\]]+)\]:\s*\S+/.test(G))continue;let q=G.replace(/`[^`]+`/g,(K)=>" ".repeat(K.length)),U=/(?<![<(="'])https?:\/\/[^\s<>`)\]"']+(?![>\])"'])/g,W=q.matchAll(U);for(let K of W)Z.push({filePath:J.filePath,line:Q+1,column:K.index+1,ruleId:"markdown/no-bare-urls",message:"Bare URL used. Wrap in angle brackets: <url>",severity:"error"})}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=h(J),X=!1;return J.map((z,Q)=>{if(Z.has(Q))return z;if(z.includes("<!--"))X=!0;if(z.includes("-->"))return X=!1,z;if(X)return z;if(/^\[(?:[^\]]+)\]:\s*\S+/.test(z))return z;return z.replace(/(?<![<(="'])https?:\/\/[^\s<>`)\]"']+(?![>\])"'])/g,"<$&>")}).join(`
99
+ `)}};var RJ={meta:{docs:"Blank lines inside blockquotes should use the blockquote symbol"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q],q=Q+1<X.length?X[Q+1]:"";if(/^(?:`{3,}|~{3,})/.test(G.trim())){z=!z,Y=!1;continue}if(z)continue;let U=/^\s*>/.test(G),W=G.trim().length===0,K=/^\s*>/.test(q);if(U)Y=!0;else if(W&&Y&&K)Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"markdown/no-blanks-blockquote",message:"Blank line inside blockquote should use blockquote symbol (>)",severity:"error"});else if(!U&&!W)Y=!1}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=!1,X=!1,Y=!1;for(let z=0;z<J.length;z++){let Q=J[z],G=z+1<J.length?J[z+1]:"";if(/^(?:`{3,}|~{3,})/.test(Q.trim())){X=!X,Z=!1;continue}if(X)continue;let q=/^\s*>/.test(Q),U=Q.trim().length===0,W=/^\s*>/.test(G);if(q)Z=!0;else if(U&&Z&&W){let K=G.match(/^(\s*)>/),H=K?`${K[1]}>`:">";J[z]=H,Y=!0}else if(!q&&!U)Z=!1}return Y?J.join(`
100
+ `):$}};var OJ={meta:{docs:"Multiple headings should not have the same content"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=Array.from({length:7},()=>new Map);for(let Q=0;Q<X.length;Q++){let G=X[Q];if(/^(?:`{3,}|~{3,})/.test(G.trim())){Y=!Y;continue}if(Y)continue;if(/^\s*\[Compare changes\]\(/.test(G)){for(let H=3;H<=6;H++)z[H].clear();continue}let q=null,U=0,W=G.match(/^(#{1,6})\s+(.+?)(?:\s*#+\s*)?$/);if(W)U=W[1].length,q=W[2].trim();if(!q){let H=Q+1<X.length?X[Q+1]:"";if(/^(?:=+)\s*$/.test(H)&&G.trim().length>0)U=1,q=G.trim();else if(/^(?:-+)\s*$/.test(H)&&G.trim().length>0)U=2,q=G.trim()}if(!q||U===0)continue;for(let H=U+1;H<=6;H++)z[H].clear();let K=z[U];if(K.has(q))Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"markdown/no-duplicate-heading",message:`Duplicate heading "${q}" (first occurrence on line ${K.get(q)})`,severity:"error"});else K.set(q,Q+1)}return Z}};var T2=/[.!?:;,]\s*$/;function LJ($,J,Z){let X=$.match(/^\*\*([^*]+)\*\*\s*$/)||$.match(/^__([^_]+)__\s*$/),Y=$.match(/^\*([^*]+)\*\s*$/)||$.match(/^_([^_]+)_\s*$/),z=X||Y;if(!z)return null;if(J.trim().length!==0||Z.trim().length!==0)return null;let Q=z[1];if(T2.test(Q))return null;if(Q.trim().split(/\s+/).length>=7)return null;return Q}var PJ={meta:{docs:"Emphasis should not be used for headings"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X);for(let z=0;z<X.length;z++){if(Y.has(z))continue;let Q=X[z],G=z>0?X[z-1]:"",q=z+1<X.length?X[z+1]:"";if(LJ(Q,G,q)===null)continue;Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/no-emphasis-as-heading",message:"Emphasis used instead of a heading",severity:"warning"})}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=h(J),X=2,Y=!1;for(let z=0;z<J.length;z++){if(Z.has(z))continue;let Q=J[z],G=Q.match(/^(#{1,6})\s/);if(G){X=G[1].length;continue}let q=z>0?J[z-1]:"",U=z+1<J.length?J[z+1]:"",W=LJ(Q,q,U);if(W===null)continue;let K=Math.min(6,Math.max(2,X+1));J[z]=`${"#".repeat(K)} ${W.trim()}`,Y=!0}return Y?J.join(`
101
+ `):$}};var CJ={meta:{docs:"Links should not be empty"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z];if(/^(?:`{3,}|~{3,})/.test(Q.trim())){Y=!Y;continue}if(Y)continue;let G=Q.replace(/`[^`]+`/g,(W)=>"x".repeat(W.length)),q=G.matchAll(/\[[^\]]+\]\(\s*\)/g);for(let W of q){let K=W.index+1;Z.push({filePath:J.filePath,line:z+1,column:K,ruleId:"markdown/no-empty-links",message:"Empty link URL",severity:"error"})}let U=G.matchAll(/\[\s*\]\([^)]+\)/g);for(let W of U){let K=W.index+1;Z.push({filePath:J.filePath,line:z+1,column:K,ruleId:"markdown/no-empty-links",message:"Empty link text",severity:"error"})}}return Z}};var IJ={meta:{docs:"Spaces should be used instead of hard tabs"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z];if(/^(?:`{3,}|~{3,})/.test(Q.trim())){Y=!Y;continue}if(Y)continue;let G=Q.indexOf("\t");if(G!==-1)Z.push({filePath:J.filePath,line:z+1,column:G+1,ruleId:"markdown/no-hard-tabs",message:"Hard tabs should not be used",severity:"error"})}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=!1;return J.map((Y)=>{if(/^(?:`{3,}|~{3,})/.test(Y.trim()))return Z=!Z,Y;if(Z)return Y;return Y.replace(/\t/g," ")}).join(`
102
+ `)}};var SJ={meta:{docs:"Inline HTML should not be used"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).allowed_elements||[],Q=!1;for(let G=0;G<X.length;G++){let q=X[G];if(/^(?:`{3,}|~{3,})/.test(q.trim())){Q=!Q;continue}if(Q)continue;let U=q;U=U.replace(/``[^`]+``/g,(K)=>" ".repeat(K.length)),U=U.replace(/`[^`]+`/g,(K)=>" ".repeat(K.length));let W=U.matchAll(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi);for(let K of W){let H=K[1].toLowerCase(),V=U.slice(K.index+1+H.length);if(V.startsWith("://")||H==="mailto"&&V.startsWith(":"))continue;if(!z.includes(H)){let A=K.index+1;Z.push({filePath:J.filePath,line:G+1,column:A,ruleId:"markdown/no-inline-html",message:`Inline HTML element '<${H}>' should not be used`,severity:"warning"})}}}return Z}};var vJ={meta:{docs:"ATX style headings must have a space after the hash"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X);for(let z=0;z<X.length;z++){if(Y.has(z))continue;let G=X[z].match(/^(#{1,6})([^\s#])/);if(G)Z.push({filePath:J.filePath,line:z+1,column:G[1].length+1,ruleId:"markdown/no-missing-space-atx",message:"No space after hash on atx style heading",severity:"error"})}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=h(J);return J.map((Y,z)=>{if(Z.has(z))return Y;return Y.replace(/^(#{1,6})([^\s#])/,"$1 $2")}).join(`
103
+ `)}};var yJ={meta:{docs:"Closed ATX style headings must have spaces inside the hashes"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X);for(let z=0;z<X.length;z++){if(Y.has(z))continue;let Q=X[z],G=Q.match(/^(#{1,6})\s+(.+?)(#{1,6})\s*$/);if(G){let U=G[1],W=G[2],K=G[3];if(!W.endsWith(" ")){let H=U.length+1+W.length;Z.push({filePath:J.filePath,line:z+1,column:H,ruleId:"markdown/no-missing-space-closed-atx",message:"No space inside hashes on closed atx style heading",severity:"error"})}}let q=Q.match(/^(#{1,6})(\S.+?#{1,6})\s*$/);if(q)Z.push({filePath:J.filePath,line:z+1,column:q[1].length+1,ruleId:"markdown/no-missing-space-closed-atx",message:"No space inside hashes on closed atx style heading",severity:"error"})}return Z}};var bJ={meta:{docs:"Multiple consecutive blank lines should not be used"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=J.options||{},z=Y.maximum!==void 0?Y.maximum:1,Q=0;for(let G=0;G<X.length;G++)if(X[G].trim().length===0){if(Q++,Q>z)Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"markdown/no-multiple-blanks",message:`Multiple consecutive blank lines (max ${z})`,severity:"error"})}else Q=0;return Z},fix:($,J)=>{let Z=J.options||{},X=Z.maximum!==void 0?Z.maximum:1,Y=$.split(/\r?\n/),z=[],Q=0;for(let G of Y)if(G.trim().length===0){if(Q++,Q<=X)z.push(G)}else Q=0,z.push(G);return z.join(`
104
+ `)}};var kJ={meta:{docs:"ATX style headings should have only one space after the hash"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X);for(let z=0;z<X.length;z++){if(Y.has(z))continue;let G=X[z].match(/^(#{1,6})\s{2,}/);if(G)Z.push({filePath:J.filePath,line:z+1,column:G[1].length+1,ruleId:"markdown/no-multiple-space-atx",message:"Multiple spaces after hash on atx style heading",severity:"error"})}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=h(J);return J.map((Y,z)=>{if(Z.has(z))return Y;return Y.replace(/^(#{1,6})\s{2,}/,"$1 ")}).join(`
105
+ `)}};var fJ={meta:{docs:"Blockquote symbols should be followed by a single space"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X);for(let z=0;z<X.length;z++){if(Y.has(z))continue;let G=X[z].match(/^(\s*)(>+)\s{2,}/);if(G){let q=G[1].length+G[2].length+1;Z.push({filePath:J.filePath,line:z+1,column:q,ruleId:"markdown/no-multiple-space-blockquote",message:"Multiple spaces after blockquote symbol",severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=h(J);return J.map((Y,z)=>{if(Z.has(z))return Y;return Y.replace(/^(\s*>+)\s{2,}/,"$1 ")}).join(`
106
+ `)}};var gJ={meta:{docs:"Closed ATX style headings should have only one space inside the hashes"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X);for(let z=0;z<X.length;z++){if(Y.has(z))continue;let Q=X[z],G=Q.match(/^(#{1,6})\s{2,}(?:\S.*?|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])#{1,6}\s*$/);if(G)Z.push({filePath:J.filePath,line:z+1,column:G[1].length+1,ruleId:"markdown/no-multiple-space-closed-atx",message:"Multiple spaces inside hashes on closed atx style heading",severity:"error"});let q=Q.match(/^#{1,6}\s+(?:\S.*?|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\s{2,}(#{1,6})\s*$/);if(q){let U=Q.lastIndexOf(q[1])-1;Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,U),ruleId:"markdown/no-multiple-space-closed-atx",message:"Multiple spaces inside hashes on closed atx style heading",severity:"error"})}}return Z}};var pJ={meta:{docs:"Link syntax should not be reversed"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X);for(let z=0;z<X.length;z++){if(Y.has(z))continue;let G=X[z].matchAll(/\(([^)]+)\)\[(?:[^\]]+)\]/g);for(let q of G){let U=q.index+1;Z.push({filePath:J.filePath,line:z+1,column:U,ruleId:"markdown/no-reversed-links",message:"Reversed link syntax: should be [text](url) not (text)[url]",severity:"error"})}}return Z}};var xJ={meta:{docs:"Code span elements should not have spaces inside the backticks"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X);for(let z=0;z<X.length;z++){let Q=X[z];if(Y.has(z))continue;let G=/(`+)([\s\S]*?)\1/g;for(let q of Q.matchAll(G)){let U=q[2];if(U.startsWith(" ")&&U.endsWith(" ")&&U.trim().length>0)Z.push({filePath:J.filePath,line:z+1,column:q.index+1,ruleId:"markdown/no-space-in-code",message:"Spaces inside code span elements",severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=h(J),X=[];for(let Y=0;Y<J.length;Y++){let z=J[Y];if(Z.has(Y)){X.push(z);continue}X.push(z.replace(/(`+)([\s\S]*?)\1/g,(Q,G,q)=>{if(q.startsWith(" ")&&q.endsWith(" ")&&q.trim().length>0)return`${G}${q.trim()}${G}`;return Q}))}return X.join(`
107
+ `)}};var E2=[/(?<![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],hJ={meta:{docs:"Emphasis markers should not have spaces inside them"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X);for(let z=0;z<X.length;z++){let Q=X[z];if(Y.has(z))continue;let G=Q.replace(/`[^`]+`/g,(q)=>"\x01".repeat(q.length));for(let q of E2)for(let U of G.matchAll(q))Z.push({filePath:J.filePath,line:z+1,column:U.index+1,ruleId:"markdown/no-space-in-emphasis",message:"Spaces inside emphasis markers",severity:"error"})}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=h(J),X=[];for(let Y=0;Y<J.length;Y++){let z=J[Y];if(Z.has(Y)){X.push(z);continue}let Q=M1(z,(G)=>{let q=G;return q=q.replace(/(?<![A-Za-z0-9])(\*\*)\s+([^*]+?)\*\*(?![A-Za-z0-9])/g,"$1$2**"),q=q.replace(/(?<![A-Za-z0-9])(\*\*)([^*]+?)\s+\*\*(?![A-Za-z0-9])/g,"$1$2**"),q=q.replace(/(?<![A-Za-z0-9])(__)\s+([^_]+?)__(?![A-Za-z0-9])/g,"$1$2__"),q=q.replace(/(?<![A-Za-z0-9])(__)([^_]+?)\s+__(?![A-Za-z0-9])/g,"$1$2__"),q});X.push(Q)}return X.join(`
108
+ `)}};var uJ={meta:{docs:"Link text should not have leading or trailing spaces"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X);for(let z=0;z<X.length;z++){if(Y.has(z))continue;let G=X[z].matchAll(/\[([^\][]*)\]\([^)]*\)/g);for(let q of G){let U=q[1];if(/^\s/.test(U)||/\s$/.test(U)){let W=q.index+1;Z.push({filePath:J.filePath,line:z+1,column:W,ruleId:"markdown/no-space-in-links",message:"Spaces inside link text",severity:"error"})}}}return Z}};var mJ={meta:{docs:"Headings should not end with punctuation"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).punctuation||".,;:!?",Q=!1;for(let G=0;G<X.length;G++){let q=X[G];if(/^(?:`{3,}|~{3,})/.test(q.trim())){Q=!Q;continue}if(Q)continue;let U=q.match(/^#{1,6}\s+(.+?)(?:\s*#+\s*)?$/);if(U){let K=U[1].trim(),H=K[K.length-1];if(H&&z.includes(H))Z.push({filePath:J.filePath,line:G+1,column:q.indexOf(K)+K.length,ruleId:"markdown/no-trailing-punctuation",message:`Trailing punctuation in heading: '${H}'`,severity:"error"})}let W=G+1<X.length?X[G+1]:"";if(/^(?:=+|-+)\s*$/.test(W)&&q.trim().length>0){let K=q.trim(),H=K[K.length-1];if(H&&z.includes(H))Z.push({filePath:J.filePath,line:G+1,column:q.indexOf(K)+K.length,ruleId:"markdown/no-trailing-punctuation",message:`Trailing punctuation in heading: '${H}'`,severity:"error"})}}return Z},fix:($,J)=>{let X=(J.options||{}).punctuation||".,;:!?",Y=new RegExp(`[${X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}]+$`),z=$.split(/\r?\n/),Q=!1;return z.map((q,U)=>{if(/^(?:`{3,}|~{3,})/.test(q.trim()))return Q=!Q,q;if(Q)return q;let W=q.match(/^(#{1,6}\s+)(.+?)(\s*#+\s*)?$/);if(W){let H=W[1],V=W[2],A=W[3]||"",_=V.replace(Y,"");return`${H}${_}${A}`}let K=U+1<z.length?z[U+1]:"";if(/^(?:=+|-+)\s*$/.test(K)&&q.trim().length>0)return q.replace(Y,"");return q}).join(`
109
+ `)}};var dJ={meta:{docs:"Lines should not end with trailing spaces"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.match(/\s+$/);if(Q){let G=J.options||{},q=G.br_spaces!==void 0?G.br_spaces:2;if(q===0||Q[0].length!==q)Z.push({filePath:J.filePath,line:Y+1,column:z.length-Q[0].length+1,ruleId:"markdown/no-trailing-spaces",message:`Trailing spaces found (${Q[0].length} space${Q[0].length!==1?"s":""})`,severity:"error"})}}return Z},fix:($,J)=>{let Z=$.split(/\r?\n/),X=J.options||{},Y=X.br_spaces!==void 0?X.br_spaces:2;return Z.map((Q)=>{let G=Q.match(/\s+$/);if(G){if(Y>0&&G[0].length===Y)return Q;return Q.replace(/\s+$/,"")}return Q}).join(`
110
+ `)}};var oJ={meta:{docs:"Ordered list item prefix should follow specified style"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).style||"one_or_ordered",Q=1;for(let G=0;G<X.length;G++){let q=X[G],U=q.match(/^(\s*)(\d+)\.\s+/);if(U){let W=Number.parseInt(U[2],10);if(z==="one"&&W!==1)Z.push({filePath:J.filePath,line:G+1,column:U[1].length+1,ruleId:"markdown/ol-prefix",message:`Ordered list item prefix should be '1.', found '${W}.'`,severity:"error"});else if(z==="ordered"&&W!==Q)Z.push({filePath:J.filePath,line:G+1,column:U[1].length+1,ruleId:"markdown/ol-prefix",message:`Ordered list item prefix should be '${Q}.', found '${W}.'`,severity:"error"});Q++}else if(q.trim().length===0)Q=1}return Z},fix:($,J)=>{let X=(J.options||{}).style||"one_or_ordered",Y=$.split(/\r?\n/),z=[],Q=1;for(let G of Y){let q=G.match(/^(\s*)(\d+)(\.\s+)/);if(q){let U=q[1],W=q[3];if(X==="one")z.push(G.replace(/^(\s*)\d+(\.\s+)/,`${U}1${W}`));else if(X==="ordered")z.push(G.replace(/^(\s*)\d+(\.\s+)/,`${U}${Q}${W}`)),Q++;else z.push(G),Q++}else if(z.push(G),G.trim().length===0)Q=1}return z.join(`
111
+ `)}};var cJ={meta:{docs:"Proper names should have correct capitalization"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=J.options||{},z=Y.names||[],Q=Y.code_blocks!==!1;if(z.length===0)return Z;let G=h(X);for(let q=0;q<X.length;q++){if(G.has(q)&&!Q)continue;let U=X[q];for(let W of z){let K=new RegExp(`\\b${W}\\b`,"gi"),H=U.matchAll(K);for(let V of H)if(V[0]!==W){let A=V.index+1;Z.push({filePath:J.filePath,line:q+1,column:A,ruleId:"markdown/proper-names",message:`Incorrect capitalization of '${V[0]}', should be '${W}'`,severity:"error"})}}}return Z}};var rJ={meta:{docs:"Reference links and images should use defined labels"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Set;for(let G of X){let q=G.match(/^\s*\[([^\]]+)\]:\s*\S+/);if(q)Y.add(q[1].toLowerCase())}let z=!1,Q=!1;for(let G=0;G<X.length;G++){let q=X[G];if(/^(?:`{3,}|~{3,})/.test(q.trim())){z=!z;continue}if(z)continue;if(q.includes("<!--"))Q=!0;if(q.includes("-->")){Q=!1;continue}if(Q)continue;if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(q))continue;let U=q.replace(/`[^`]+`/g,(K)=>" ".repeat(K.length));U=U.replace(/!?\[[^\]]*\]\([^)]*\)/g,(K)=>" ".repeat(K.length));let W=U.matchAll(/!?\[([^\]]+)\]\[([^\]]*)\]/g);for(let K of W){let H=(K[2].trim()||K[1]).toLowerCase();if(!Y.has(H))Z.push({filePath:J.filePath,line:G+1,column:K.index+1,ruleId:"markdown/reference-links-images",message:`Reference link '[${H}]' is not defined`,severity:"error"})}}return Z}};var lJ={meta:{docs:"Document should have required heading structure"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).headings||[];if(z.length===0)return Z;let Q=[];for(let q of X){let U=q.match(/^#{1,6}\s+(.+?)(?:\s*#+\s*)?$/);if(U)Q.push(U[1].trim())}let G=0;for(let q=0;q<Q.length&&G<z.length;q++)if(Q[q]===z[G])G++;if(G<z.length)Z.push({filePath:J.filePath,line:1,column:1,ruleId:"markdown/required-headings",message:`Missing required heading: '${z[G]}'`,severity:"error"});return Z}};var aJ={meta:{docs:"Document should have only one top-level heading (h1)"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X),z=-1;for(let Q=0;Q<X.length;Q++){if(Y.has(Q))continue;let G=X[Q],q=Q+1<X.length?X[Q+1]:"",U=!1;if(/^#\s/.test(G))U=!0;if(/^=+\s*$/.test(q)&&G.trim().length>0&&!Y.has(Q+1))U=!0;if(U)if(z===-1)z=Q+1;else Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"markdown/single-title",message:`Multiple top-level headings in the same document (first h1 on line ${z})`,severity:"error"})}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=h(J),X=[],Y=!1,z=!1;for(let Q=0;Q<J.length;Q++){if(Z.has(Q)){X.push(J[Q]);continue}let G=J[Q],q=Q+1<J.length?J[Q+1]:"",U=/^#\s/.test(G),W=/^=+\s*$/.test(q)&&G.trim().length>0&&!Z.has(Q+1);if(U){if(!Y)Y=!0,X.push(G);else X.push(`#${G}`),z=!0;continue}if(W){if(!Y){Y=!0,X.push(G);continue}X.push(`## ${G.trim()}`),Q++,z=!0;continue}X.push(G)}return z?X.join(`
112
+ `):$}};var sJ={meta:{docs:"Files should end with a single newline character"},check:($,J)=>{let Z=[];if(!$.endsWith(`
113
113
  `)&&!$.endsWith(`\r
114
114
  `)){let X=$.split(/\r?\n/);Z.push({filePath:J.filePath,line:X.length,column:X[X.length-1].length+1,ruleId:"markdown/single-trailing-newline",message:"File should end with a single newline character",severity:"error"})}if($.endsWith(`
115
115
 
116
116
  `)||$.endsWith(`\r
117
117
  \r
118
118
  `)){let X=$.split(/\r?\n/);Z.push({filePath:J.filePath,line:X.length,column:1,ruleId:"markdown/single-trailing-newline",message:"File should end with a single newline character (not multiple)",severity:"error"})}return Z},fix:($)=>{return`${$.replace(/[\r\n]+$/,"")}
119
- `}};var sJ={meta:{docs:"Strong style should be consistent (asterisk or underscore)"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X),Q=(J.options||{}).style||"consistent",G=null;for(let q=0;q<X.length;q++){if(Y.has(q))continue;let U=t0(X[q]),W=U.matchAll(/\*\*([^*]+)\*\*/g);for(let H of W)if(Q==="underscore")Z.push({filePath:J.filePath,line:q+1,column:H.index+1,ruleId:"markdown/strong-style",message:"Expected underscore (__) for strong",severity:"error"});else if(Q==="consistent"){if(G===null)G="asterisk";else if(G==="underscore")Z.push({filePath:J.filePath,line:q+1,column:H.index+1,ruleId:"markdown/strong-style",message:"Strong style should be consistent throughout document",severity:"error"})}let K=U.matchAll(/__([^_]+)__/g);for(let H of K)if(Q==="asterisk")Z.push({filePath:J.filePath,line:q+1,column:H.index+1,ruleId:"markdown/strong-style",message:"Expected asterisk (**) for strong",severity:"error"});else if(Q==="consistent"){if(G===null)G="underscore";else if(G==="asterisk")Z.push({filePath:J.filePath,line:q+1,column:H.index+1,ruleId:"markdown/strong-style",message:"Strong style should be consistent throughout document",severity:"error"})}}return Z},fix:($,J)=>{let X=(J.options||{}).style||"consistent",Y=$.split(/\r?\n/),z=m(Y),Q="asterisk";if(X==="asterisk")Q="asterisk";else if(X==="underscore")Q="underscore";else if(X==="consistent"){let q=null,U=null;for(let K=0;K<Y.length;K++){if(z.has(K))continue;let H=t0(Y[K]);if(q===null){let V=H.match(/\*\*([^*]+)\*\*/);if(V)q={line:K,col:V.index}}if(U===null){let V=H.match(/__([^_]+)__/);if(V)U={line:K,col:V.index}}if(q&&U)break}if(q&&(!U||((K,H)=>K.line!==H.line?K.line-H.line:K.col-H.col)(q,U)<0))Q="asterisk";else if(U)Q="underscore"}let G=!1;for(let q=0;q<Y.length;q++){if(z.has(q))continue;let U=Y[q],W=B1(U,(K)=>Q==="asterisk"?K.replace(/__([^_]+)__/g,"**$1**"):K.replace(/\*\*([^*]+)\*\*/g,"__$1__"));if(W!==U)Y[q]=W,G=!0}return G?Y.join(`
120
- `):$}};var nJ={meta:{docs:"Table rows should have consistent column counts"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=-1,Q=!1,G=X1(X);for(let q=0;q<X.length;q++){let U=X[q];if(/^(?:`{3,}|~{3,})/.test(U.trim())){if(Q=!Q,Y)Y=!1,z=-1;continue}if(Q)continue;let W=G.has(q)&&/\|/.test(U)&&U.trim().length>0;if(W){let K=N2(U);if(!Y)Y=!0,z=K;else if(K!==z)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-column-count",message:`Table row has ${K} column(s), expected ${z}`,severity:"error"})}else if(U.trim().length===0||!W){if(Y)Y=!1,z=-1}}return Z}};function N2($){let J=$.trim();if(J.startsWith("|"))J=J.slice(1);if(J.endsWith("|")&&!J.endsWith("\\|"))J=J.slice(0,-1);if(J==="")return 0;let Z=1,X=!1,Y=0,z=0;while(z<J.length){let Q=J[z];if(Q==="\\"&&J[z+1]==="|"){z+=2;continue}if(Q==="`"){let G=0;while(J[z+G]==="`")G++;if(!X)X=!0,Y=G;else if(G===Y)X=!1,Y=0;z+=G;continue}if(!X&&Q==="|")Z++;z++}return Z}var iJ={meta:{docs:"Table columns should have consistent alignment"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/[-:]/.test(z)&&/\|/.test(z)){if(z.match(/^[|\s:.-]+$/)){let G=z.split("|").filter((q)=>q.trim().length>0);for(let q of G){let U=q.trim();if(!/^:?-+:?$/.test(U))Z.push({filePath:J.filePath,line:Y+1,column:z.indexOf(q)+1,ruleId:"markdown/table-column-style",message:"Invalid table column separator",severity:"error"})}}}}return Z}};var tJ={meta:{docs:"Table pipe style should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).style||"leading_and_trailing",Q=!1,G=X1(X);for(let q=0;q<X.length;q++){let U=X[q];if(/^(?:`{3,}|~{3,})/.test(U.trim())){Q=!Q;continue}if(Q)continue;if(G.has(q)&&/\|/.test(U)&&U.trim().length>0){let W=U.trim().startsWith("|"),K=U.trim().endsWith("|");if(z==="leading_and_trailing"){if(!W||!K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have leading and trailing pipes",severity:"error"})}else if(z==="leading_only"){if(!W||K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have leading pipe only",severity:"error"})}else if(z==="trailing_only"){if(W||!K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have trailing pipe only",severity:"error"})}else if(z==="no_leading_or_trailing"){if(W||K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should not have leading or trailing pipes",severity:"error"})}}}return Z}};var eJ={meta:{docs:"Unordered list indentation should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).indent||2,Q=!1,G=[];for(let q=0;q<X.length;q++){let U=X[q];if(/^(?:`{3,}|~{3,})/.test(U.trim())){Q=!Q;continue}if(Q)continue;if(U.trim()==="")continue;let W=U.match(/^(\s*)([*\-+])(\s+)/),K=U.match(/^(\s*)(\d+[.)])(\s+)/);if(!W&&!K){let M=U.match(/^(\s*)/)?.[1].length||0;while(G.length>0&&G[G.length-1].contentCol>M)G.pop();continue}let H=W||K,V=H[1].length,A=H[2],_=H[3],B=V+A.length+_.length,F=W?"ul":"ol";while(G.length>0&&V<G[G.length-1].contentCol)G.pop();if(F==="ul"){let M=G.length>0?G[G.length-1]:null;if(!M){if(V!==0&&V%z!==0)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/ul-indent",message:`Unordered list indentation should be ${z} spaces per level. Found ${V} spaces`,severity:"error"})}else if(M.type==="ul"){let N=M.contentCol,E=M.indent+z;if(V!==N&&V!==E)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/ul-indent",message:`Unordered list indentation should be ${z} spaces per level. Found ${V} spaces`,severity:"error"})}}G.push({indent:V,contentCol:B,type:F})}return Z}};var $X={meta:{docs:"Unordered list style should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X),Q=(J.options||{}).style||"consistent",G=null;for(let q=0;q<X.length;q++){let U=X[q];if(Y.has(q))continue;let W=U.match(/^(\s*)([*\-+])\s+/);if(W){let K=W[2];if(Q==="asterisk"&&K!=="*")Z.push({filePath:J.filePath,line:q+1,column:W[1].length+1,ruleId:"markdown/ul-style",message:`Expected asterisk (*) for unordered list, found '${K}'`,severity:"error"});else if(Q==="dash"&&K!=="-")Z.push({filePath:J.filePath,line:q+1,column:W[1].length+1,ruleId:"markdown/ul-style",message:`Expected dash (-) for unordered list, found '${K}'`,severity:"error"});else if(Q==="plus"&&K!=="+")Z.push({filePath:J.filePath,line:q+1,column:W[1].length+1,ruleId:"markdown/ul-style",message:`Expected plus (+) for unordered list, found '${K}'`,severity:"error"});else if(Q==="consistent"){if(G===null)G=K;else if(G!==K)Z.push({filePath:J.filePath,line:q+1,column:W[1].length+1,ruleId:"markdown/ul-style",message:`Unordered list style should be consistent throughout document. Expected '${G}', found '${K}'`,severity:"error"})}}}return Z},fix:($,J)=>{let X=(J.options||{}).style||"consistent",Y=$.split(/\r?\n/),z=m(Y),Q="*";if(X==="asterisk")Q="*";else if(X==="dash")Q="-";else if(X==="plus")Q="+";else if(X==="consistent")for(let q=0;q<Y.length;q++){if(z.has(q))continue;let U=Y[q].match(/^(\s*)([*\-+])\s+/);if(U){Q=U[2];break}}return Y.map((q,U)=>{if(z.has(U))return q;return q.replace(/^(\s*)([*\-+])(\s+)/,`$1${Q}$3`)}).join(`
121
- `)}};function T2($){let J=$.split(/\r?\n/);if(J[0]?.trim()!=="---")return{text:$,frontmatter:null,frontmatterEndLine:0};for(let Z=1;Z<J.length;Z++)if(J[Z].trim()==="---"){let X=J.slice(0,Z+1);return{text:[...X.map(()=>""),...J.slice(Z+1)].join(`
122
- `),frontmatter:X,frontmatterEndLine:Z+1}}return{text:$,frontmatter:null,frontmatterEndLine:0}}function E2($){let J=$.split(/\r?\n/);if(J[0]?.trim()!=="---")return{header:null,body:$};for(let Z=1;Z<J.length;Z++)if(J[Z].trim()==="---")return{header:J.slice(0,Z+1).join(`
119
+ `}};var nJ={meta:{docs:"Strong style should be consistent (asterisk or underscore)"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X),Q=(J.options||{}).style||"consistent",G=null;for(let q=0;q<X.length;q++){if(Y.has(q))continue;let U=t0(X[q]),W=U.matchAll(/\*\*([^*]+)\*\*/g);for(let H of W)if(Q==="underscore")Z.push({filePath:J.filePath,line:q+1,column:H.index+1,ruleId:"markdown/strong-style",message:"Expected underscore (__) for strong",severity:"error"});else if(Q==="consistent"){if(G===null)G="asterisk";else if(G==="underscore")Z.push({filePath:J.filePath,line:q+1,column:H.index+1,ruleId:"markdown/strong-style",message:"Strong style should be consistent throughout document",severity:"error"})}let K=U.matchAll(/__([^_]+)__/g);for(let H of K)if(Q==="asterisk")Z.push({filePath:J.filePath,line:q+1,column:H.index+1,ruleId:"markdown/strong-style",message:"Expected asterisk (**) for strong",severity:"error"});else if(Q==="consistent"){if(G===null)G="underscore";else if(G==="asterisk")Z.push({filePath:J.filePath,line:q+1,column:H.index+1,ruleId:"markdown/strong-style",message:"Strong style should be consistent throughout document",severity:"error"})}}return Z},fix:($,J)=>{let X=(J.options||{}).style||"consistent",Y=$.split(/\r?\n/),z=h(Y),Q="asterisk";if(X==="asterisk")Q="asterisk";else if(X==="underscore")Q="underscore";else if(X==="consistent"){let q=null,U=null;for(let K=0;K<Y.length;K++){if(z.has(K))continue;let H=t0(Y[K]);if(q===null){let V=H.match(/\*\*([^*]+)\*\*/);if(V)q={line:K,col:V.index}}if(U===null){let V=H.match(/__([^_]+)__/);if(V)U={line:K,col:V.index}}if(q&&U)break}if(q&&(!U||((K,H)=>K.line!==H.line?K.line-H.line:K.col-H.col)(q,U)<0))Q="asterisk";else if(U)Q="underscore"}let G=!1;for(let q=0;q<Y.length;q++){if(z.has(q))continue;let U=Y[q],W=M1(U,(K)=>Q==="asterisk"?K.replace(/__([^_]+)__/g,"**$1**"):K.replace(/\*\*([^*]+)\*\*/g,"__$1__"));if(W!==U)Y[q]=W,G=!0}return G?Y.join(`
120
+ `):$}};var iJ={meta:{docs:"Table rows should have consistent column counts"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=-1,Q=!1,G=X1(X);for(let q=0;q<X.length;q++){let U=X[q];if(/^(?:`{3,}|~{3,})/.test(U.trim())){if(Q=!Q,Y)Y=!1,z=-1;continue}if(Q)continue;let W=G.has(q)&&/\|/.test(U)&&U.trim().length>0;if(W){let K=D2(U);if(!Y)Y=!0,z=K;else if(K!==z)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-column-count",message:`Table row has ${K} column(s), expected ${z}`,severity:"error"})}else if(U.trim().length===0||!W){if(Y)Y=!1,z=-1}}return Z}};function D2($){let J=$.trim();if(J.startsWith("|"))J=J.slice(1);if(J.endsWith("|")&&!J.endsWith("\\|"))J=J.slice(0,-1);if(J==="")return 0;let Z=1,X=!1,Y=0,z=0;while(z<J.length){let Q=J[z];if(Q==="\\"&&J[z+1]==="|"){z+=2;continue}if(Q==="`"){let G=0;while(J[z+G]==="`")G++;if(!X)X=!0,Y=G;else if(G===Y)X=!1,Y=0;z+=G;continue}if(!X&&Q==="|")Z++;z++}return Z}var tJ={meta:{docs:"Table columns should have consistent alignment"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/[-:]/.test(z)&&/\|/.test(z)){if(z.match(/^[|\s:.-]+$/)){let G=z.split("|").filter((q)=>q.trim().length>0);for(let q of G){let U=q.trim();if(!/^:?-+:?$/.test(U))Z.push({filePath:J.filePath,line:Y+1,column:z.indexOf(q)+1,ruleId:"markdown/table-column-style",message:"Invalid table column separator",severity:"error"})}}}}return Z}};var eJ={meta:{docs:"Table pipe style should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).style||"leading_and_trailing",Q=!1,G=X1(X);for(let q=0;q<X.length;q++){let U=X[q];if(/^(?:`{3,}|~{3,})/.test(U.trim())){Q=!Q;continue}if(Q)continue;if(G.has(q)&&/\|/.test(U)&&U.trim().length>0){let W=U.trim().startsWith("|"),K=U.trim().endsWith("|");if(z==="leading_and_trailing"){if(!W||!K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have leading and trailing pipes",severity:"error"})}else if(z==="leading_only"){if(!W||K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have leading pipe only",severity:"error"})}else if(z==="trailing_only"){if(W||!K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have trailing pipe only",severity:"error"})}else if(z==="no_leading_or_trailing"){if(W||K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should not have leading or trailing pipes",severity:"error"})}}}return Z}};var $X={meta:{docs:"Unordered list indentation should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).indent||2,Q=!1,G=[];for(let q=0;q<X.length;q++){let U=X[q];if(/^(?:`{3,}|~{3,})/.test(U.trim())){Q=!Q;continue}if(Q)continue;if(U.trim()==="")continue;let W=U.match(/^(\s*)([*\-+])(\s+)/),K=U.match(/^(\s*)(\d+[.)])(\s+)/);if(!W&&!K){let M=U.match(/^(\s*)/)?.[1].length||0;while(G.length>0&&G[G.length-1].contentCol>M)G.pop();continue}let H=W||K,V=H[1].length,A=H[2],_=H[3],B=V+A.length+_.length,F=W?"ul":"ol";while(G.length>0&&V<G[G.length-1].contentCol)G.pop();if(F==="ul"){let M=G.length>0?G[G.length-1]:null;if(!M){if(V!==0&&V%z!==0)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/ul-indent",message:`Unordered list indentation should be ${z} spaces per level. Found ${V} spaces`,severity:"error"})}else if(M.type==="ul"){let T=M.contentCol,E=M.indent+z;if(V!==T&&V!==E)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/ul-indent",message:`Unordered list indentation should be ${z} spaces per level. Found ${V} spaces`,severity:"error"})}}G.push({indent:V,contentCol:B,type:F})}return Z}};var ZX={meta:{docs:"Unordered list style should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=h(X),Q=(J.options||{}).style||"consistent",G=null;for(let q=0;q<X.length;q++){let U=X[q];if(Y.has(q))continue;let W=U.match(/^(\s*)([*\-+])\s+/);if(W){let K=W[2];if(Q==="asterisk"&&K!=="*")Z.push({filePath:J.filePath,line:q+1,column:W[1].length+1,ruleId:"markdown/ul-style",message:`Expected asterisk (*) for unordered list, found '${K}'`,severity:"error"});else if(Q==="dash"&&K!=="-")Z.push({filePath:J.filePath,line:q+1,column:W[1].length+1,ruleId:"markdown/ul-style",message:`Expected dash (-) for unordered list, found '${K}'`,severity:"error"});else if(Q==="plus"&&K!=="+")Z.push({filePath:J.filePath,line:q+1,column:W[1].length+1,ruleId:"markdown/ul-style",message:`Expected plus (+) for unordered list, found '${K}'`,severity:"error"});else if(Q==="consistent"){if(G===null)G=K;else if(G!==K)Z.push({filePath:J.filePath,line:q+1,column:W[1].length+1,ruleId:"markdown/ul-style",message:`Unordered list style should be consistent throughout document. Expected '${G}', found '${K}'`,severity:"error"})}}}return Z},fix:($,J)=>{let X=(J.options||{}).style||"consistent",Y=$.split(/\r?\n/),z=h(Y),Q="*";if(X==="asterisk")Q="*";else if(X==="dash")Q="-";else if(X==="plus")Q="+";else if(X==="consistent")for(let q=0;q<Y.length;q++){if(z.has(q))continue;let U=Y[q].match(/^(\s*)([*\-+])\s+/);if(U){Q=U[2];break}}return Y.map((q,U)=>{if(z.has(U))return q;return q.replace(/^(\s*)([*\-+])(\s+)/,`$1${Q}$3`)}).join(`
121
+ `)}};function R2($){let J=$.split(/\r?\n/);if(J[0]?.trim()!=="---")return{text:$,frontmatter:null,frontmatterEndLine:0};for(let Z=1;Z<J.length;Z++)if(J[Z].trim()==="---"){let X=J.slice(0,Z+1);return{text:[...X.map(()=>""),...J.slice(Z+1)].join(`
122
+ `),frontmatter:X,frontmatterEndLine:Z+1}}return{text:$,frontmatter:null,frontmatterEndLine:0}}function O2($){let J=$.split(/\r?\n/);if(J[0]?.trim()!=="---")return{header:null,body:$};for(let Z=1;Z<J.length;Z++)if(J[Z].trim()==="---")return{header:J.slice(0,Z+1).join(`
123
123
  `),body:J.slice(Z+1).join(`
124
- `)};return{header:null,body:$}}function D2($){return{meta:$.meta,check:(J,Z)=>Z.filePath.endsWith(".md")?$.check(J,Z):[],fix:$.fix?(J,Z)=>Z.filePath.endsWith(".md")?$.fix(J,Z):J:void 0}}function l($){return{meta:$.meta,check:(J,Z)=>{if(!Z.filePath.endsWith(".md"))return[];let{text:X,frontmatterEndLine:Y}=T2(J),z=$.check(X,Z);if(Y>0)return z.filter((Q)=>Q.line>Y+1);return z},fix:$.fix?(J,Z)=>{if(!Z.filePath.endsWith(".md"))return J;let{header:X,body:Y}=E2(J);if(X===null)return $.fix(J,Z);let z=$.fix(Y,Z);if(z===Y)return J;return`${X}
125
- ${z}`}:void 0}}var ZX={name:"markdown",rules:{"heading-increment":l(HJ),"heading-style":l(AJ),"no-missing-space-atx":l(SJ),"no-multiple-space-atx":l(bJ),"no-missing-space-closed-atx":l(vJ),"no-multiple-space-closed-atx":l(fJ),"blanks-around-headings":l(eZ),"heading-start-left":l(VJ),"no-duplicate-heading":l(RJ),"single-title":l(lJ),"no-trailing-punctuation":l(uJ),"ul-style":l($X),"list-indent":l(jJ),"ul-indent":l(eJ),"ol-prefix":l(dJ),"list-marker-space":l(NJ),"blanks-around-lists":l($J),"no-trailing-spaces":l(mJ),"no-hard-tabs":l(CJ),"no-multiple-blanks":l(yJ),"no-multiple-space-blockquote":l(kJ),"no-blanks-blockquote":l(DJ),"blanks-around-fences":l(tZ),"single-trailing-newline":D2(aJ),"blanks-around-tables":l(XJ),"no-reversed-links":l(gJ),"no-bare-urls":l(EJ),"no-space-in-links":l(hJ),"no-empty-links":l(PJ),"link-fragments":l(BJ),"reference-links-images":l(cJ),"link-image-reference-definitions":l(wJ),"link-image-style":l(MJ),"descriptive-link-text":l(qJ),"line-length":l(FJ),"commands-show-output":l(GJ),"fenced-code-language":l(WJ),"code-block-style":l(YJ),"code-fence-style":l(QJ),"no-emphasis-as-heading":l(LJ),"no-space-in-emphasis":l(xJ),"no-space-in-code":l(pJ),"emphasis-style":l(UJ),"strong-style":l(sJ),"no-inline-html":l(IJ),"hr-style":l(_J),"first-line-heading":l(KJ),"required-headings":l(rJ),"proper-names":l(oJ),"no-alt-text":l(TJ),"table-pipe-style":l(tJ),"table-column-count":l(nJ),"table-column-style":l(iJ)}};var JX={meta:{docs:"Prefer using global Buffer instead of requiring it",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=/(?:import\b[^;\n]*\bfrom\s*|require\s*\(\s*)['"](?:node:)?buffer['"]/;for(let z=0;z<X.length;z++){let Q=X[z],G=Q.trim();if(G.startsWith("//")||G.startsWith("/*")||G.startsWith("*"))continue;let q=Q.match(Y);if(!q||q.index===void 0)continue;if(!/\bBuffer\b/.test(Q))continue;Z.push({filePath:J.filePath,line:z+1,column:q.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 Z}};var XX={meta:{docs:"Prefer using global process instead of requiring it",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=/(?:import\b[^;\n]*\bfrom\s*|require\s*\(\s*)['"](?:node:)?process['"]/;for(let z=0;z<X.length;z++){let Q=X[z],G=Q.trim();if(G.startsWith("//")||G.startsWith("/*")||G.startsWith("*"))continue;let q=Q.match(Y);if(!q||q.index===void 0)continue;Z.push({filePath:J.filePath,line:z+1,column:q.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 Z}};var YX={name:"node",rules:{"prefer-global/buffer":w(JX),"prefer-global/process":w(XX)}};var I8={meta:{docs:"Enforce sorted imports (delegates to formatter check only)"},check:($,J)=>{let Z=$.split(/\r?\n/),X=0;while(X<Z.length&&(/^\s*$/.test(Z[X])||/^\s*\/.\/.*/.test(Z[X])||/^\s*\/.\*/.test(Z[X])))X++;let Y=X,z=[];while(X<Z.length&&/^\s*import\b/.test(Z[X]))z.push(Z[X].trim()),X++;if(z.length===0)return[];let Q=z.join(`
124
+ `)};return{header:null,body:$}}function L2($){return{meta:$.meta,check:(J,Z)=>Z.filePath.endsWith(".md")?$.check(J,Z):[],fix:$.fix?(J,Z)=>Z.filePath.endsWith(".md")?$.fix(J,Z):J:void 0}}function r($){return{meta:$.meta,check:(J,Z)=>{if(!Z.filePath.endsWith(".md"))return[];let{text:X,frontmatterEndLine:Y}=R2(J),z=$.check(X,Z);if(Y>0)return z.filter((Q)=>Q.line>Y+1);return z},fix:$.fix?(J,Z)=>{if(!Z.filePath.endsWith(".md"))return J;let{header:X,body:Y}=O2(J);if(X===null)return $.fix(J,Z);let z=$.fix(Y,Z);if(z===Y)return J;return`${X}
125
+ ${z}`}:void 0}}var JX={name:"markdown",rules:{"heading-increment":r(VJ),"heading-style":r(_J),"no-missing-space-atx":r(vJ),"no-multiple-space-atx":r(kJ),"no-missing-space-closed-atx":r(yJ),"no-multiple-space-closed-atx":r(gJ),"blanks-around-headings":r($J),"heading-start-left":r(AJ),"no-duplicate-heading":r(OJ),"single-title":r(aJ),"no-trailing-punctuation":r(mJ),"ul-style":r(ZX),"list-indent":r(NJ),"ul-indent":r($X),"ol-prefix":r(oJ),"list-marker-space":r(TJ),"blanks-around-lists":r(ZJ),"no-trailing-spaces":r(dJ),"no-hard-tabs":r(IJ),"no-multiple-blanks":r(bJ),"no-multiple-space-blockquote":r(fJ),"no-blanks-blockquote":r(RJ),"blanks-around-fences":r(eZ),"single-trailing-newline":L2(sJ),"blanks-around-tables":r(YJ),"no-reversed-links":r(pJ),"no-bare-urls":r(DJ),"no-space-in-links":r(uJ),"no-empty-links":r(CJ),"link-fragments":r(wJ),"reference-links-images":r(rJ),"link-image-reference-definitions":r(MJ),"link-image-style":r(jJ),"descriptive-link-text":r(UJ),"line-length":r(BJ),"commands-show-output":r(qJ),"fenced-code-language":r(KJ),"code-block-style":r(zJ),"code-fence-style":r(GJ),"no-emphasis-as-heading":r(PJ),"no-space-in-emphasis":r(hJ),"no-space-in-code":r(xJ),"emphasis-style":r(WJ),"strong-style":r(nJ),"no-inline-html":r(SJ),"hr-style":r(FJ),"first-line-heading":r(HJ),"required-headings":r(lJ),"proper-names":r(cJ),"no-alt-text":r(EJ),"table-pipe-style":r(eJ),"table-column-count":r(iJ),"table-column-style":r(tJ)}};var XX={meta:{docs:"Prefer using global Buffer instead of requiring it",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=/(?:import\b[^;\n]*\bfrom\s*|require\s*\(\s*)['"](?:node:)?buffer['"]/;for(let z=0;z<X.length;z++){let Q=X[z],G=Q.trim();if(G.startsWith("//")||G.startsWith("/*")||G.startsWith("*"))continue;let q=Q.match(Y);if(!q||q.index===void 0)continue;if(!/\bBuffer\b/.test(Q))continue;Z.push({filePath:J.filePath,line:z+1,column:q.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 Z}};var YX={meta:{docs:"Prefer using global process instead of requiring it",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=/(?:import\b[^;\n]*\bfrom\s*|require\s*\(\s*)['"](?:node:)?process['"]/;for(let z=0;z<X.length;z++){let Q=X[z],G=Q.trim();if(G.startsWith("//")||G.startsWith("/*")||G.startsWith("*"))continue;let q=Q.match(Y);if(!q||q.index===void 0)continue;Z.push({filePath:J.filePath,line:z+1,column:q.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 Z}};var zX={name:"node",rules:{"prefer-global/buffer":w(XX),"prefer-global/process":w(YX)}};var I8={meta:{docs:"Enforce sorted imports (delegates to formatter check only)"},check:($,J)=>{let Z=$.split(/\r?\n/),X=0;while(X<Z.length&&(/^\s*$/.test(Z[X])||/^\s*\/.\/.*/.test(Z[X])||/^\s*\/.\*/.test(Z[X])))X++;let Y=X,z=[];while(X<Z.length&&/^\s*import\b/.test(Z[X]))z.push(Z[X].trim()),X++;if(z.length===0)return[];let Q=z.join(`
126
126
  `),G=Z.slice(X).join(`
127
127
  `),q=`${Q}
128
- ${G}`;if(I7(q)!==q)return[{filePath:J.filePath,line:Y+1,column:1,ruleId:"sort-imports",message:"Imports are not sorted/grouped consistently",severity:"warning"}];return[]},fix:($)=>I7($)};var zX={name:"perfectionist",rules:{"sort-imports":w(I8)}};import{dirname as R2,resolve as O2}from"path";function t($){try{let J=JSON.parse($);if(typeof J!=="object"||J===null||Array.isArray(J))return null;return J}catch{return null}}function L2($,J){let Z=$.split(`
129
- `),X=1,Y=0;for(let z of J){let Q=new RegExp(`"${S2(z)}"\\s*:`);for(let G=Y;G<Z.length;G++)if(Q.test(Z[G])){X=G+1,Y=G+1;break}}return X}function x0($){return R2($)}function I0($,J){return O2($,J)}function Z0($){let J="pkg";for(let Z of $)if(/^\d+$/.test(Z))J+=`[${Z}]`;else if(!/^[a-z_$][a-z0-9_$]*$/i.test(Z))J+=`["${Z}"]`;else J+=`.${Z}`;return J}function i($,J){if($.publishConfig?.[J]!==void 0)return[$.publishConfig[J],["publishConfig",J]];return[$[J],[J]]}var P2=new RegExp(`(?:[\\s;]|^)(?:import[\\w,{}\\s*]*from|import\\s*['"*{]|export\\b\\s*(?:[*{]|default|type|function|const|var|let|async function)|import\\.meta\\b)`,"m"),C2=new RegExp("(?:[\\s;]|^)(?:module.exports\\b|exports\\.\\w|require\\s*\\(|global\\.\\w|Object\\.(?:defineProperty|defineProperties|assign)\\s*\\(\\s*exports\\b)","m");function Y1($){let J=I2($),Z=P2.test(J),X=C2.test(J);if(Z&&X)return"mixed";if(Z)return"ESM";if(X)return"CJS";return"unknown"}function QX($,J){if($.endsWith(".mjs"))return"ESM";if($.endsWith(".cjs"))return"CJS";return J==="module"?"ESM":"CJS"}function GX($){if($==="ESM")return".mjs";if($==="CJS")return".cjs";return".js"}function qX($){return $===".mjs"||$===".cjs"}function l0($){return $.endsWith(".js")||$.endsWith(".mjs")||$.endsWith(".cjs")}function UX($){return/^#!\s*\//.test($)}function I2($){return $.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*/g,"")}function W0($,J,Z,X){S7($,J,Z,X)}function S7($,J,Z,X){if(typeof $==="string"){X($,{path:J,isImports:Z});return}if(Array.isArray($)){X($,{path:J,isImports:Z});for(let Y=0;Y<$.length;Y++)S7($[Y],J.concat(String(Y)),Z,X);return}if($!==null&&typeof $==="object"){let Y=Object.keys($);X($,{path:J,isImports:Z},Y);for(let z of Y)S7($[z],J.concat(z),Z,X)}}function n($,J,Z,X,Y,z,Q){return{filePath:$,line:L2(J,Z),column:1,ruleId:X,message:Y,severity:z,...Q&&{help:Q}}}function S2($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var v7={meta:{docs:"Disallow deprecated jsnext:main and jsnext fields",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[];if(Z["jsnext:main"]!=null)X.push(n(J.filePath,$,["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(Z.jsnext!=null)X.push(n(J.filePath,$,["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 X}};var y7={meta:{docs:'Ensure "default" condition is last in exports objects',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return W0(Y,z,!1,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("default"in Q))return;if(q[q.length-1]!=="default")X.push(n(J.filePath,$,G.path.concat("default"),"publint/exports-default-should-be-last",`${Z0(G.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.'))}),X}};var b7={meta:{docs:"Warn against using fallback arrays in exports",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return W0(Y,z,!1,(Q,G)=>{if(!Array.isArray(Q))return;X.push(n(J.filePath,$,G.path,"publint/exports-fallback-array-use",`${Z0(G.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."))}),X}};var k7={meta:{docs:"Ensure exports has a root entrypoint when main/module exist",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let[X]=i(Z,"main"),[Y]=i(Z,"module"),[z,Q]=i(Z,"exports");if(X==null&&Y==null||z==null)return[];if(typeof z!=="object"||Array.isArray(z))return[];let G=Object.keys(z);if(G.length===0)return[];if(!G[0]?.startsWith("."))return[];if(G.includes("."))return[];let U=[];if(X)U.push("main");if(Y)U.push("module");return[n(J.filePath,$,Q,"publint/exports-missing-root-entrypoint",`${Z0(Q)} is missing the root entrypoint export, which is defined in pkg.${U[0]}. Environments that support "exports" will ignore pkg.${U[0]} as "exports" takes the highest priority.`,"warning",`Add ${Z0(Q.concat("."))} to ensure the root entrypoint is accessible.`)]}};var f7={meta:{docs:'Ensure "module" condition precedes "require" in exports',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return W0(Y,z,!1,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("module"in Q)||!("require"in Q))return;if(q.indexOf("module")>q.indexOf("require"))X.push(n(J.filePath,$,G.path.concat("module"),"publint/exports-module-should-precede-require",`${Z0(G.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.'))}),X}};var g7={meta:{docs:'Ensure "types" condition is first in exports objects',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return W0(Y,z,!1,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("types"in Q))return;let U=q.indexOf("types");if(U===0)return;if(q.slice(0,U).filter((K)=>{if(K.startsWith("types"))return!1;if(typeof Q[K]==="object"&&Q[K]!==null&&WX(Q[K],"types"))return!1;return!0}).length>0)X.push(n(J.filePath,$,G.path.concat("types"),"publint/exports-types-should-be-first",`${Z0(G.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.'))}),X}};function WX($,J){for(let Z in $){if(Z===J)return!0;if(typeof $[Z]==="object"&&$[Z]!==null&&WX($[Z],J))return!0}return!1}var p7={meta:{docs:'Ensure exports values start with "./"',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return W0(Y,z,!1,(Q,G)=>{if(typeof Q!=="string")return;if(Q.startsWith("./"))return;let q=`./${Q.replace(/^[/]+/,"")}`;X.push(n(J.filePath,$,G.path,"publint/exports-value-invalid",`${Z0(G.path)} is "${Q}" which is invalid as it does not start with "./". Use "${q}" instead.`,"error",'All exports values must be relative paths starting with "./".'))}),X}};var v2=[{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"]}],x7={meta:{docs:"Ensure package.json fields have correct value types",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[];for(let{field:Y,expectTypes:z}of v2){let[Q,G]=i(Z,Y);if(Q==null)continue;let q=typeof Q;if(!z.includes(q)){let U=z.length===1?z[0]:`${z.slice(0,-1).join(", ")} or ${z[z.length-1]}`;X.push(n(J.filePath,$,G,"publint/field-invalid-value-type",`${Z0(G)} has an invalid ${q} type. Expected a ${U} type instead.`,"error",`The "${Y}" field must be of type ${U}.`))}}return X}};var h7={meta:{docs:"Suggest adding exports when module field is present",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let[X,Y]=i(Z,"module"),[z]=i(Z,"exports");if(X!=null&&z==null)return[n(J.filePath,$,Y,"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 u7={meta:{docs:'Ensure "default" condition is last in imports objects',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"imports");if(Y==null||typeof Y!=="object")return[];return W0(Y,z,!0,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("default"in Q))return;if(q[q.length-1]!=="default")X.push(n(J.filePath,$,G.path.concat("default"),"publint/imports-default-should-be-last",`${Z0(G.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.'))}),X}};var m7={meta:{docs:'Ensure imports keys start with "#"',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"imports");if(Y==null||typeof Y!=="object"||Array.isArray(Y))return[];for(let Q of Object.keys(Y))if(!Q.startsWith("#")){let G=`#${Q.replace(/^[/]+/,"")}`,q=z.concat(Q);X.push(n(J.filePath,$,q,"publint/imports-key-invalid",`${Z0(q)} is invalid as the imports key does not start with "#". Use "${G}" instead.`,"error",'All imports keys must start with "#" to distinguish them from package specifiers.'))}return X}};var d7={meta:{docs:'Ensure "module" condition precedes "require" in imports',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"imports");if(Y==null||typeof Y!=="object")return[];return W0(Y,z,!0,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("module"in Q)||!("require"in Q))return;if(q.indexOf("module")>q.indexOf("require"))X.push(n(J.filePath,$,G.path.concat("module"),"publint/imports-module-should-precede-require",`${Z0(G.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.'))}),X}};var o7={meta:{docs:'Ensure imports values start with "./"',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"imports");if(Y==null||typeof Y!=="object")return[];return W0(Y,z,!0,(Q,G)=>{if(typeof Q!=="string")return;if(!Q.startsWith("."))return;if(Q.startsWith("./"))return;let q=`./${Q.replace(/^[/]+/,"")}`;X.push(n(J.filePath,$,G.path,"publint/imports-value-invalid",`${Z0(G.path)} is "${Q}" which is invalid as it does not start with "./". Use "${q}" instead.`,"error",'Relative imports values must start with "./".'))}),X}};var c7={meta:{docs:"Disallow local file references in dependencies",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=["dependencies","optionalDependencies","peerDependencies"];for(let z of Y){let Q=Z[z];if(!Q||typeof Q!=="object")continue;for(let G of Object.keys(Q)){let q=Q[G];if(typeof q==="string"&&(q.startsWith("file:")||q.startsWith("link:")))X.push(n(J.filePath,$,[z,G],"publint/local-dependency",`The "${G}" dependency references "${q}" 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 X}};var r7={meta:{docs:'Suggest specifying the "type" field in package.json',recommended:!0},check($,J){let Z=t($);if(!Z)return[];if(Z.type==null)return[n(J.filePath,$,["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 y2,readFileSync as b2}from"fs";var l7={meta:{docs:"Ensure bin files have a shebang for executability",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=x0(J.filePath),[z,Q]=i(Z,"bin");if(z==null)return[];if(typeof z==="string")KX(z,Q,Y,X,J.filePath,$);else if(typeof z==="object"){for(let G of Object.keys(z))if(typeof z[G]==="string")KX(z[G],Q.concat(G),Y,X,J.filePath,$)}return X}};function KX($,J,Z,X,Y,z){let Q=I0(Z,$);if(!y2(Q))return;if(!l0($))return;let G;try{G=b2(Q,"utf8")}catch{return}if(!UX(G))X.push(n(Y,z,J,"publint/bin-file-not-executable",`${Z0(J)} is "${$}" 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 HX,readFileSync as VX}from"fs";var a7={meta:{docs:'Ensure files under "module" condition in exports are ESM',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=x0(J.filePath),[z,Q]=i(Z,"exports");if(z==null)return[];W0(z,Q,!1,(U,W)=>{if(typeof U!=="string")return;if(!W.path.includes("module"))return;if(!U.startsWith("./")&&!U.startsWith("../"))return;if(U.includes("*"))return;let K=I0(Y,U);if(!HX(K))return;if(!l0(U))return;let H;try{H=VX(K,"utf8")}catch{return}if(Y1(H)==="CJS")X.push(n(J.filePath,$,W.path,"publint/exports-module-should-be-esm",`${Z0(W.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[G,q]=i(Z,"imports");if(G!=null&&typeof G==="object")W0(G,q,!0,(U,W)=>{if(typeof U!=="string")return;if(!W.path.includes("module"))return;if(!U.startsWith("./"))return;if(U.includes("*"))return;let K=I0(Y,U);if(!HX(K))return;if(!l0(U))return;let H;try{H=VX(K,"utf8")}catch{return}if(Y1(H)==="CJS")X.push(n(J.filePath,$,W.path,"publint/exports-module-should-be-esm",`${Z0(W.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 X}};import{existsSync as p1}from"fs";import{dirname as k2,isAbsolute as f2,resolve as g2}from"path";function s7($,J){let Z=J;while(Z.startsWith("./"))Z=Z.slice(2);let X=Z.split("/")[0];if(!X||X===".."||X.startsWith("."))return!1;let Y=f2(J)?k2(J).split("/")[0]||"/":g2($,X);return!p1(Y)}var n7={meta:{docs:"Ensure files referenced in package.json exist",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=x0(J.filePath),z=["main","module","types","typings","unpkg","jsdelivr"];for(let W of z){let[K,H]=i(Z,W);if(K==null||typeof K!=="string")continue;if(s7(Y,K))continue;let V=I0(Y,K);if(!_X(V))X.push(n(J.filePath,$,H,"publint/file-does-not-exist",`${Z0(H)} is "${K}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))}let[Q,G]=i(Z,"bin");if(Q!=null){if(typeof Q==="string")AX(Q,G,X,J.filePath,$,Y);else if(typeof Q==="object"){for(let W of Object.keys(Q))if(typeof Q[W]==="string")AX(Q[W],G.concat(W),X,J.filePath,$,Y)}}let[q,U]=i(Z,"exports");if(q!=null)W0(q,U,!1,(W,K)=>{if(typeof W!=="string")return;if(!W.startsWith("./")&&!W.startsWith("../"))return;if(W.includes("*"))return;if(s7(Y,W))return;let H=I0(Y,W);if(!p1(H))X.push(n(J.filePath,$,K.path,"publint/file-does-not-exist",`${Z0(K.path)} is "${W}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))});return X}};function AX($,J,Z,X,Y,z){if(s7(z,$))return;let Q=I0(z,$);if(!_X(Q))Z.push(n(X,Y,J,"publint/file-does-not-exist",`${Z0(J)} is "${$}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))}function _X($){if(p1($))return!0;if(p1(`${$}.js`))return!0;if(p1(`${$}/index.js`))return!0;return!1}import{existsSync as p2,readFileSync as x2}from"fs";import{extname as h2}from"path";var i7={meta:{docs:"Ensure file code format matches its extension and package type",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=x0(J.filePath),z=Z.type,[Q,G]=i(Z,"main");if(Q!=null&&typeof Q==="string")FX(Q,G,Y,z,X,J.filePath,$);let[q,U]=i(Z,"exports");if(q!=null)W0(q,U,!1,(W,K)=>{if(typeof W!=="string")return;if(!W.startsWith("./")&&!W.startsWith("../"))return;if(W.includes("*"))return;if(K.path.includes("browser"))return;FX(W,K.path,Y,z,X,J.filePath,$)});return X}};function FX($,J,Z,X,Y,z,Q){let G=I0(Z,$);if(!p2(G))return;if(!l0($))return;let q;try{q=x2(G,"utf8")}catch{return}let U=Y1(q);if(U==="unknown"||U==="mixed")return;let W=QX(G,X);if(U===W)return;let K=h2(G),H=GX(U),A=(qX(K)?"FILE_INVALID_EXPLICIT_FORMAT":"FILE_INVALID_FORMAT")==="FILE_INVALID_EXPLICIT_FORMAT"?`${Z0(J)} is "${$}" and ends with the ${K} extension, but the code is written in ${U}. Consider using the ${H} extension.`:`${Z0(J)} is "${$}" and is written in ${U}, but is interpreted as ${W}. Consider using the ${H} extension.`;Y.push(n(z,Q,J,"publint/file-invalid-format",A,"warning",`The file's code format (${U}) doesn't match the expected format (${W}) based on its extension and package type.`))}import{existsSync as u2,readFileSync as m2}from"fs";var t7={meta:{docs:'Ensure the "module" field points to an ESM file',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let[X,Y]=i(Z,"module");if(X==null||typeof X!=="string")return[];let z=x0(J.filePath),Q=I0(z,X);if(!u2(Q))return[];if(!l0(X))return[];let G;try{G=m2(Q,"utf8")}catch{return[]}if(Y1(G)==="CJS")return[n(J.filePath,$,Y,"publint/module-should-be-esm",`${Z0(Y)} 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 BX={name:"publint",rules:{"use-type":A0(r7),"local-dependency":A0(c7),"deprecated-field-jsnext":A0(v7),"has-module-but-no-exports":A0(h7),"field-invalid-value-type":A0(x7),"exports-types-should-be-first":A0(g7),"exports-default-should-be-last":A0(y7),"exports-module-should-precede-require":A0(f7),"exports-value-invalid":A0(p7),"exports-missing-root-entrypoint":A0(k7),"exports-fallback-array-use":A0(b7),"imports-key-invalid":A0(m7),"imports-value-invalid":A0(o7),"imports-default-should-be-last":A0(u7),"imports-module-should-precede-require":A0(d7),"file-does-not-exist":A0(n7),"file-invalid-format":A0(i7),"module-should-be-esm":A0(t7),"bin-file-not-executable":A0(l7),"exports-module-should-be-esm":A0(a7)}};var wX={meta:{docs:"Ensure all imports appear before other statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=0;for(let Q=0;Q<X.length;Q++){let G=X[Q].trim();if(!G||G.startsWith("//")||G.startsWith("/*")||G.startsWith("*"))continue;let q=G.match(/^\s*import\s+/);if(!q&&G.length>0){if(Y=!0,z===0)z=Q+1}if(Y&&q)Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"import/first",message:"Import statement must appear before other statements",severity:"error"})}return Z}};var MX={meta:{docs:"Disallow duplicate specifier names in a single import declaration"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.match(/^\s*import\s*\{([^}]*)\}\s*from\s*['"][^'"]+['"]/);if(!Q)continue;let q=Q[1].split(",").map((W)=>W.trim()).filter(Boolean).map((W)=>W.split(/\s+as\s+/i)[0].trim()),U=new Set;for(let W of q){if(U.has(W)){Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf(W)+1),ruleId:"pickier/import-dedupe",message:"Expect no duplication in imports",severity:"warning"});break}U.add(W)}}return Z}};import{existsSync as d2,readFileSync as o2}from"fs";import{dirname as c2,resolve as r2}from"path";var jX={meta:{docs:"Ensure named imports correspond to a named export in the remote file",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=c2(J.filePath);for(let z=0;z<X.length;z++){let G=X[z].match(/\bimport\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/);if(G){let q=G[1].split(",").map((H)=>H.trim().split(/\s+as\s+/)[0].trim()),U=G[2];if(!U.startsWith(".")&&!U.startsWith("/"))continue;let W=[".ts",".tsx",".js",".jsx",""],K="";for(let H of W){let V=r2(Y,U+H);if(d2(V)){K=o2(V,"utf8");break}}if(K)for(let H of q){let V=new RegExp(`\\bexport\\s+(?:const|let|var|function|class)\\s+${H}\\b`),A=new RegExp(`\\bexport\\s+\\{[^}]*\\b${H}\\b[^}]*\\}`);if(![V,A].some((F)=>F.test(K)))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"import/named",message:`'${H}' not found in '${U}'`,severity:"error"})}}}return Z}};import{existsSync as NX,readFileSync as l2}from"fs";import{dirname as TX,resolve as EX}from"path";var DX={meta:{docs:"Ensure imports don't create circular dependencies",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=J.filePath,z=new Set,Q=new Set;function G(U,W){if(Q.has(U))return!0;if(z.has(U))return!1;z.add(U),Q.add(U);try{let K=l2(U,"utf8"),H=q(K,TX(U));for(let V of H)if(G(V,[...W,V]))return!0}catch{}return Q.delete(U),!1}function q(U,W){let K=[],H=/\bimport(?:\s{2,}|\s+\S.*?(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))from\s+['"]([^'"]+)['"]/g,V;for(V=H.exec(U);V!==null;V=H.exec(U)){let A=V[1];if(A.startsWith(".")||A.startsWith("/")){let _=[".ts",".tsx",".js",".jsx",""];for(let B of _){let F=EX(W,A+B);if(NX(F)){K.push(F);break}}}}return K}for(let U=0;U<X.length;U++){let K=X[U].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(K){let H=K[1];if(H.startsWith(".")||H.startsWith("/")){let V=[".ts",".tsx",".js",".jsx",""],A="";for(let _ of V){let B=EX(TX(Y),H+_);if(NX(B)){A=B;break}}if(A){if(z.clear(),Q.clear(),Q.add(Y),G(A,[Y,A]))Z.push({filePath:J.filePath,line:U+1,column:1,ruleId:"import/no-cycle",message:"Dependency cycle detected",severity:"error"})}}}}return Z}};var RX={meta:{docs:"Disallow duplicate module imports - all imports from the same module should be combined"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map,z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(z){let V=G.indexOf("*/");if(V>=0)G=G.slice(V+2),z=!1;else continue}let q=G.indexOf("/*"),U=G.indexOf("//");if(q>=0&&(U===-1||q<U)){let V=G.indexOf("*/",q+2);if(V>=0)G=G.slice(0,q)+G.slice(V+2);else z=!0,G=G.slice(0,q)}if(U>=0)G=G.slice(0,U);let W=G.trim();if(!W)continue;let K=W.match(/^import\s+(?:type\s+)?(?:\{[^}]*\}|[\w$]+(?:\s*,\s*\{[^}]*\})?|\*\s+as\s+[\w$]+)\s+from\s+(['"`])(.+?)\1/);if(K){let V=K[2];if(Y.has(V)){let A=Y.get(V);Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"no-duplicate-imports",message:`'${V}' imported multiple times (also imported on line${A.length>1?"s":""} ${A.join(", ")})`,severity:"error",help:`Combine all imports from '${V}' into a single import statement`}),A.push(Q+1)}else Y.set(V,[Q+1])}let H=W.match(/^export\s+(?:type\s+)?(?:\{[^}]*\}|\*(?:\s+as\s+[\w$]+)?)\s+from\s+(['"`])(.+?)\1/);if(H){let V=H[2],A=`export:${V}`;if(Y.has(A)){let _=Y.get(A);Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"no-duplicate-imports",message:`'${V}' re-exported multiple times (also exported on line${_.length>1?"s":""} ${_.join(", ")})`,severity:"error",help:`Combine all re-exports from '${V}' into a single export statement`}),_.push(Q+1)}else Y.set(A,[Q+1])}}return Z}};var OX={meta:{docs:"Disallow importing from dist directories"},check:($,J)=>{let Z=[],X=new RegExp(`^\\s*import\\s[^;]*?from\\s*['"]([^'"]+)['"]`,"m"),Y=$.split(/\r?\n/);for(let z=0;z<Y.length;z++){let Q=Y[z],G=Q.match(X);if(!G)continue;let q=G[1];if(q==="dist"||(q.startsWith(".")||q.startsWith("/"))&&/(?:^|\/)dist(?:\/.|$)/.test(q))Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,Q.indexOf(q)+1),ruleId:"pickier/no-import-dist",message:`Do not import modules in \`dist\` folder, got ${q}`,severity:"error"})}return Z}};var LX={meta:{docs:"Disallow importing from node_modules by explicit path"},check:($,J)=>{let Z=[],X=new RegExp(`^\\s*import\\s[^;]*?from\\s*['"]([^'"]+)['"]`,"m"),Y=/require\(\s*['"]([^'"]+)['"]\s*\)/,z=$.split(/\r?\n/);for(let Q=0;Q<z.length;Q++){let G=z[Q],q=G.match(X),U=G.match(Y),W=q?.[1]||U?.[1];if(!W)continue;if(W.includes("/node_modules/")){let K=Math.max(1,G.indexOf(W)+1);Z.push({filePath:J.filePath,line:Q+1,column:K,ruleId:"pickier/no-import-node-modules-by-path",message:"Do not import modules in `node_modules` folder by path",severity:"error"})}}return Z}};import{existsSync as a2}from"fs";import{dirname as s2,join as n2,resolve as i2}from"path";var PX={meta:{docs:"Ensure imports point to a file/module that can be resolved",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=s2(J.filePath);for(let z=0;z<X.length;z++){let Q=X[z],G=[...Q.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),...Q.matchAll(/\bimport\s*\(\s*['"]([^'"]+)['"]\s*\)/g),...Q.matchAll(/\brequire\s*\(\s*['"]([^'"]+)['"]\s*\)/g)];for(let q of G){let U=q[1];if(!U.startsWith(".")&&!U.startsWith("/"))continue;let W=[],K=[".ts",".tsx",".js",".jsx",".mjs",".cjs",""];for(let V of K){let A=i2(Y,U+V);W.push(A),W.push(n2(A,`index${V}`))}if(!W.some((V)=>a2(V)))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"import/no-unresolved",message:`Unable to resolve path to module '${U}'`,severity:"error"})}}return Z}};function CX($,J,Z){let X=Z.order==="desc"?-1:1,Y=Z.type||"alphabetical",z=Z.ignoreCase?$.toLowerCase():$,Q=Z.ignoreCase?J.toLowerCase():J;if(Y==="line-length")return(z.length-Q.length)*X;if(Y==="natural")return z.localeCompare(Q,void 0,{numeric:!0,sensitivity:"base"})*X;if(Y==="unsorted")return 0;return z.localeCompare(Q)*X}var t2=new RegExp(`^export\\s+\\{[^}]*\\}\\s+from\\s+['"][^'"]+['"];?\\s*$`);function S8($){return t2.test($)}var IX={meta:{docs:"Ensure contiguous export statements are sorted consistently."},check:($,J)=>{let Z=[],X=J.config.pluginRules?.["pickier/sort-exports"]?.[1]||{},Y=$.split(/\r?\n/),z=0;while(z<Y.length){while(z<Y.length&&!S8(Y[z]))z++;if(z>=Y.length)break;let Q=[],G=z;while(G<Y.length){let q=Y[G];if(S8(q)){Q.push({idx:G,line:q}),G++;continue}if(X.partitionByNewLine&&q.trim()==="")break;else break}if(Q.length>1){let q=Q.map((K)=>K.line),U=[...q].sort((K,H)=>CX(K,H,X));if(!q.every((K,H)=>K===U[H])){let K=q.findIndex((V,A)=>V!==U[A]),H=Q[K]?.idx??Q[0].idx;Z.push({filePath:J.filePath,line:H+1,column:1,ruleId:"pickier/sort-exports",message:"Export statements are not sorted.",severity:"warning"})}}z=G+1}return Z},fix:($,J)=>{let Z=J.config.pluginRules?.["pickier/sort-exports"]?.[1]||{},Y=[...$.split(/\r?\n/)],z=0;while(z<Y.length){while(z<Y.length&&!S8(Y[z]))z++;if(z>=Y.length)break;let Q=[],G=z;while(G<Y.length){let q=Y[G];if(S8(q)){Q.push(G),G++;continue}if(Z.partitionByNewLine&&q.trim()==="")break;else break}if(Q.length>1){let q=Q.map((K)=>Y[K]),U=[...q].sort((K,H)=>CX(K,H,Z));if(!q.every((K,H)=>K===U[H]))Q.forEach((K,H)=>{Y[K]=U[H]})}z=G+1}return Y.join(`
130
- `)}};var SX={meta:{docs:"Enforce sorted TypeScript heritage clauses (extends/implements lists)"},check:($,J)=>{let Z=J.options||{},X=Z.type||"alphabetical",Y=Z.order||"asc",z=Z.ignoreCase!==!1,Q=Array.isArray(Z.groups)?Z.groups:[],G=Z.customGroups||{},q=$.split(/\r?\n/),U=[],W=(E)=>Y==="asc"?E:-E,K=(E,j)=>(z?E.toLowerCase():E).localeCompare(z?j.toLowerCase():j),H=(E,j)=>(z?E.toLowerCase():E).localeCompare(z?j.toLowerCase():j,void 0,{numeric:!0}),V=(E,j)=>{if(X==="line-length")return W(E.length-j.length);if(X==="natural")return W(H(E,j));if(X==="unsorted")return 0;return W(K(E,j))},A=Object.fromEntries(Object.entries(G).map(([E,j])=>{let y=(Array.isArray(j)?j:[j]).map((k)=>new RegExp(k));return[E,y]})),_=[];for(let E of Q)if(Array.isArray(E))_.push(...E);else _.push(E);if(!_.includes("unknown"))_.push("unknown");let B=(E)=>{for(let[j,O]of Object.entries(A))if(O.some((y)=>y.test(E)))return j;return"unknown"},F=(E)=>{let j=[],O=0,y="";for(let k=0;k<E.length;k++){let L=E[k];if(L==="<")O++;else if(L===">")O=Math.max(0,O-1);if(L===","&&O===0){j.push(y.trim()),y="";continue}y+=L}if(y.trim())j.push(y.trim());return j},M=(E)=>{let j=E.trim(),O=j.match(/^([A-Z_$][\w$.]*)/i);return O?O[1]:j},N=(E,j)=>{let O=F(j);if(O.length<=1)return;let y=O.map(M),k=y.map(B),L=y.map((b,P)=>({n:b,g:k[P],i:P})).sort((b,P)=>{let I=_.indexOf(b.g),S=_.indexOf(P.g);if(I!==S)return I-S;return V(b.n,P.n)}).map((b)=>b.n);if(!y.every((b,P)=>b===L[P]))U.push({filePath:J.filePath,line:E,column:1,ruleId:"sort-heritage-clauses",message:"Heritage clauses are not sorted",severity:"warning"})};for(let E=0;E<q.length;E++){let j=q[E],O=j.match(/^\s*interface\s+[A-Za-z_$][^{]*\bextends\s+(.+?)\s*\{/);if(O)N(E+1,O[1]);let y=j.match(/^\s*class\s+[A-Za-z_$][^{]*\bimplements\s+(.+?)\s*\{/);if(y)N(E+1,y[1])}return U}};var vX={meta:{docs:"Require object keys to be sorted (ESLint-compatible core rule subset)"},check:()=>{return[]}};var yX={meta:{docs:"Enforce sorted named imports within each import statement"},check:($,J)=>{let Z=J.options||{},X=Z.type||"alphabetical",Y=Z.order||"asc",z=Z.ignoreCase!==!1,Q=Boolean(Z.ignoreAlias),G=$.split(/\r?\n/),q=[],U=(W,K)=>{let H=0;if(X==="line-length")H=W.length-K.length;else{let V=z?W.toLowerCase():W,A=z?K.toLowerCase():K;H=V.localeCompare(A)}return Y==="asc"?H:-H};for(let W=0;W<G.length;W++){let H=G[W].match(/^\s*import\s+\{([^}]*)\}\s+from\s+['"][^'"]+['"]/);if(!H)continue;let A=H[1].split(",").map((M)=>M.trim()).filter(Boolean);if(A.length<=1)continue;let _=A.map((M)=>{let N=M.replace(/^type\s+/,""),E=N.match(/^([\w$]+)\s+as\s+([\w$]+)$/);if(E)return Q?E[2]:E[1];let j=N.match(/^([\w$]+)$/);return j?j[1]:N}),B=[..._].sort(U);if(!_.every((M,N)=>M===B[N]))q.push({filePath:J.filePath,line:W+1,column:1,ruleId:"sort-named-imports",message:"Named imports are not sorted",severity:"warning"})}return q}};var bX={meta:{docs:"Enforce sorted object keys"},check:($,J)=>{let Z=J.options||{},X=Z.type||"alphabetical",Y=Z.order||"asc",z=Z.ignoreCase!==!1,Q=Boolean(Z.partitionByNewLine),G=$.split(/\r?\n/),q=[],U=(K,H)=>{let V=0;if(X==="line-length")V=K.length-H.length;else{let A=z?K.toLowerCase():K,_=z?H.toLowerCase():H;V=A.localeCompare(_)}return Y==="asc"?V:-V},W=0;while(W<G.length){let K=G[W],H=K.indexOf("{");if(H!==-1){let V=K.slice(0,H);if(/=\s*$|\(\s*$|\breturn\s*$/.test(V)){let A=0,_=W,B=W;for(;B<G.length;B++){for(let F of G[B])if(F==="{")A++;else if(F==="}")A--;if(A===0)break}if(B>_){let F=G.slice(_+1,B),M=[],N={startLine:_+2,props:[]},E=()=>{if(N.props.length)M.push(N);N={startLine:0,props:[]}};for(let j=0;j<F.length;j++){let O=F[j];if(Q&&/^\s*$/.test(O)){E();continue}if(/^\s*\.\.\./.test(O))continue;if(/\{|\}/.test(O))continue;let y=O.match(/^\s*['"]?([\w$-]+)['"]?\s*:/);if(y){if(N.startLine===0)N.startLine=_+2+j;N.props.push({key:y[1],line:_+2+j})}}E();for(let j of M){let O=j.props.map((L)=>L.key),y=[...O].sort(U);if(!(O.length<=1||O.every((L,x)=>L===y[x]))&&j.props.length>0){let L=j.props[0];q.push({filePath:J.filePath,line:L.line,column:1,ruleId:"sort-objects",message:"Object keys are not sorted",severity:"warning"})}}W=B+1;continue}}}W++}return q}};var kX={meta:{docs:"Enforce top-level functions to use function declarations"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/^\s+/.test(z))continue;if(/^\s*(?:\/\/|\/\*)/.test(z))continue;let Q=z.match(/^const\s+([A-Za-z_$][\w$]*)\s*=(.*)$/);if(!Q)continue;let G=Q[2].trim();if(/^\(?[A-Z_$,]*(?:\)\s*)?=>/i.test(G)||/^function\b/.test(G)){let q=z.indexOf("const")+1;Z.push({filePath:J.filePath,line:Y+1,column:q,ruleId:"pickier/top-level-function",message:"Top-level functions should be declared with function keyword",severity:"warning"});continue}if(G.trim().length===0||/[,({]$/.test(G.trim())){let q=X[Y+1]||"";if(/^\s*(?:\(?[A-Za-z_$,]*(?:\)\s*)?=>|function\b)/.test(q)){let U=z.indexOf("const")+1;Z.push({filePath:J.filePath,line:Y+1,column:U,ruleId:"pickier/top-level-function",message:"Top-level functions should be declared with function keyword",severity:"warning"})}}}return Z}};var e2=[[/^(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]],$G=/^([a-z0-9][-a-z0-9]{0,50}:)+(?!\[)/;function ZG($){let J=0;while(J<$.length){if($[J]==="[")break;let Z=$.indexOf(":",J);if(Z===-1)break;if($[Z+1]==="[")break;J=Z+1}return $.slice(J)}function JG($){let J=ZG($);if(J.startsWith("!"))J=J.slice(1);for(let[Z,X]of e2)if(Z.test(J))return X;return 99}function XG($){let J=$.match($G);if(!J)return 0;let Z=J[0].slice(0,-1).split(":"),X={sm:1,md:2,lg:3,xl:4,"2xl":5},Y=10;for(let z of Z)if(X[z]!==void 0)Y+=X[z];else Y+=20;return Y}var fX=new Map;function gX($){let J=fX.get($);if(J)return J;let Z={group:JG($),variant:XG($)};return fX.set($,Z),Z}function e7($){return[...$].sort((J,Z)=>{let X=gX(J),Y=gX(Z),z=X.group,Q=Y.group;if(z!==Q)return z-Q;let G=X.variant,q=Y.variant;if(G!==q)return G-q;return J.localeCompare(Z)})}var YG=/\b(?:class|className|:class)\s*=\s*(?:"([^"]*?)"|'([^']*?)')/g,zG=/\b(?:class|className|:class)\s*=\s*\{`([^`]*?)`\}/g,QG=/\b(?:clsx|cn|tw|cva|tv)\s*\(\s*(?:"([^"]*?)"|'([^']*?)')/g;function GG($){let J=$.replace(/\[[^\]]*\]/g,"");if(/['"`]/.test(J))return!0;if(/[{}()=]/.test(J))return!0;if(/ \? | && | \|\| /.test(J))return!0;if(/\b(?:true|false|null|undefined|function|return|typeof|instanceof)\b/.test(J))return!0;return!1}function pX($){let J=[];if(!$.includes("class")&&!$.includes("clsx")&&!$.includes("cn(")&&!$.includes("tw(")&&!$.includes("cva(")&&!$.includes("tv("))return J;for(let Z of[YG,zG,QG]){Z.lastIndex=0;let X;while((X=Z.exec($))!==null){let Y=X[1]??X[2]??"";if(!Y.trim())continue;if(GG(Y))continue;let z=$.indexOf(Y,X.index);if(z===-1)continue;J.push({value:Y,start:z,end:z+Y.length})}}return J.sort((Z,X)=>Z.start-X.start),J}function xX($){let J=[],Z="",X=0;for(let Y of $)if(Y==="[")X++,Z+=Y;else if(Y==="]")X=Math.max(0,X-1),Z+=Y;else if(/\s/.test(Y)&&X===0){if(Z)J.push(Z),Z=""}else Z+=Y;if(Z)J.push(Z);return J}function hX($){let J=e7($);return $.every((Z,X)=>Z===J[X])}var uX={meta:{docs:"Enforce consistent Tailwind CSS class ordering (layout \u2192 spacing \u2192 typography \u2192 etc.).",recommended:!0,editsStringContent:!0},check:($,J)=>{let Z=[],X=pX($);for(let{value:Y,start:z}of X){let Q=xX(Y);if(Q.length<2)continue;if(!hX(Q)){let G=$.slice(0,z),q=(G.match(/\n/g)??[]).length+1,U=G.lastIndexOf(`
131
- `),W=U===-1?z+1:z-U;Z.push({filePath:J.filePath,line:q,column:W,ruleId:"pickier/sort-tailwind-classes",message:`Tailwind classes are not in the recommended order. Expected: "${e7(Q).join(" ")}"`,severity:"warning",help:"Run with --fix to automatically sort Tailwind classes, or reorder them manually."})}}return Z},fix:($)=>{let J=pX($);if(J.length===0)return $;let Z=[...J].reverse(),X=$;for(let{value:Y,start:z,end:Q}of Z){let G=xX(Y);if(G.length<2||hX(G))continue;let q=e7(G).join(" ");X=X.slice(0,z)+q+X.slice(Q)}return X}};var mX={name:"pickier",rules:{"sort-exports":w(IX),"sort-objects":w(bX),"sort-imports":w(I8),"sort-named-imports":w(yX),"sort-heritage-clauses":w(SX),"sort-keys":w(vX),"import-dedupe":w(MX),"import-first":w(wX),"import-named":w(jX),"import-no-cycle":w(DX),"import-no-unresolved":w(PX),"no-import-dist":w(OX),"no-import-node-modules-by-path":w(LX),"no-duplicate-imports":w(RX),"top-level-function":w(kX),"sort-tailwind-classes":uX,"prefer-const":w(L8),"prefer-template":w(P8),"no-unused-vars":w(n0)}};var dX={name:"quality",rules:{"default-case":w(o$),eqeqeq:w(c$),"no-alert":w(a$),"no-await-in-loop":w(s$),"no-caller":w(n$),"no-case-declarations":w(i$),"no-else-return":w(t$),"no-empty":w(e$),"no-empty-function":w($8),"no-eval":w(Z8),"no-extend-native":w(J8),"no-global-assign":w(Y8),"no-implied-eval":w(z8),"no-iterator":w(Q8),"no-new":w(G8),"no-new-func":w(q8),"no-new-wrappers":w(U8),"no-octal":w(W8),"no-param-reassign":w(K8),"no-proto":w(H8),"no-return-assign":w(V8),"no-shadow":w(_8),"no-throw-literal":w(F8),"no-use-before-define":w(B8),"no-useless-call":w(w8),"no-with":w(E8),"require-await":w(R8),complexity:w(d$),"max-depth":w(r$),"max-lines-per-function":w(l$),"no-extra-boolean-cast":w(X8),"no-lonely-if":w(k1),"no-sequences":w(A8),"no-useless-concat":w(M8),"no-useless-escape":w(j8),"no-useless-rename":w(N8),"no-useless-return":w(f1),"no-var":w(T8),"prefer-arrow-callback":w(D8)}};var oX={meta:{docs:"Detects potentially super-linear backtracking patterns in regex literals (heuristic)"},check:($,J)=>{let Z=[],X=/\/[^/\\\n]*(?:\\.[^/\\\n]*)*\//g,Y=(K,H,V)=>{let A=$.slice(0,K),_=(A.match(/\n/g)||[]).length+1,B=K-A.lastIndexOf(`
132
- `);Z.push({filePath:J.filePath,line:_,column:B,ruleId:"no-super-linear-backtracking",message:V,severity:"error"})},z=[],Q=/\/\*[\s\S]*?\*\//g,G;while(G=Q.exec($))z.push({start:G.index,end:G.index+G[0].length});let q=/\/\/[^\n]*/g,U;while(U=q.exec($))z.push({start:U.index,end:U.index+U[0].length});let W;while(W=X.exec($)){let K=W[0],H=W.index;if(z.some((F)=>H>=F.start&&H<F.end))continue;if(H>0){let F=$[H-1];if(F===")"||F==="]"||F==="."||/[\w$]/.test(F))continue;let M=K.slice(1,K.lastIndexOf("/"));if(/^\s+\w/.test(M)&&/\w\s*\)/.test(M))continue}let A=K.slice(1,K.lastIndexOf("/")).replace(/\[.*?\]/g,"");if(A.includes(".+?\\s*")||A.includes("\\s*.+?")||A.includes(".*\\s*")||A.includes("\\s*.*")){Y(H,K.length,"The combination of ' .*' or ' .+?' with '\\s*' can cause super-linear backtracking due to exchangeable characters");continue}let B=A.replace(/\s+/g,"");if(/(?:\.\*\??){2,}/.test(B)||/(?:\.\+\??){2,}/.test(B)||/\.\*\??\.\+\?|\.\+\??\.\*\?/.test(B)){Y(H,K.length,"Multiple adjacent unlimited wildcard quantifiers can cause super-linear backtracking");continue}if(/\((?:\?:)?[^)]*?[+*][^)]*\)\s*[+*]/.test(A.replace(/\\[()]/g,"_"))){Y(H,K.length,"Nested unlimited quantifiers detected (e.g., (.+)+) which can cause catastrophic backtracking");continue}}return Z}};function qG($,J){let Z=J-1;while(Z>=0&&($[Z]===" "||$[Z]==="\t"))Z--;let X=Z>=0?$[Z]:"",Y="=(<>!&|?:;,{[+(~^%*/";if(!(Z<0||Y.includes(X)||/\b(?:return|typeof|void|delete|throw|new|in|of|case)\s*$/.test($.slice(Math.max(0,Z-5),Z+1))))return null;let Q=J+1,G=!1,q=!1,U=-1;while(Q<$.length){let _=$[Q];if(q)q=!1;else if(_==="\\")q=!0;else if(_==="["){if(!G)G=!0}else if(_==="]"){if(G)G=!1}else if(_==="/"&&!G){U=Q;break}else if(_===`
133
- `)break;Q++}if(U<=J)return null;let W=$.slice(J+1,U),K=U+1;while(K<$.length&&/[gimsuvy]/.test($[K]))K++;if(/\\[1-9]/.test(W))return null;let H=0,V=-1,A=!1;for(let _=0;_<W.length;_++){if(W[_]==="\\"){_++;continue}if(W[_]==="["&&!A){A=!0;continue}if(W[_]==="]"&&A){A=!1;continue}if(A)continue;if(W[_]==="("&&W.slice(_+1,_+3)!=="?:"&&W.slice(_+1,_+3)!=="?="&&W.slice(_+1,_+3)!=="?!"&&W.slice(_+1,_+4)!=="?<="&&W.slice(_+1,_+4)!=="?<!"){if(V<0)V=_;H++}}if(H===0)return null;return{patternStart:J,patternEnd:K,pattern:W,capCount:H,firstCapOffset:V}}function UG($,J,Z){let X=Z;while(X<$.length&&($[X]===" "||$[X]==="\t"))X++;if($[X]==="."){let q=$.slice(X+1,X+20);if(/^test\s*\(/.test(q))return!1;if(/^exec\s*\(/.test(q))return!0}let Y=J-1;while(Y>=0&&($[Y]===" "||$[Y]==="\t"))Y--;if($[Y]==="("){let U=Y-1;while(U>=0&&($[U]===" "||$[U]==="\t"))U--;let W=$.slice(Math.max(0,U-20),U+1);if(/\.match\s*$/.test(W))return!0;if(/\.matchAll\s*$/.test(W))return!0;if(/\.exec\s*$/.test(W))return!0;if(/\.replace\s*$/.test(W))return!0;if(/\.replaceAll\s*$/.test(W))return!0;if(/\.split\s*$/.test(W))return!0;if(/\.search\s*$/.test(W))return!1;if(/\.test\s*$/.test(W))return!1}let z=$.lastIndexOf(`
134
- `,J)+1,G=$.slice(z,J).trim().match(/(?:const|let|var)\s+(\w+)\s*=\s*$/);if(G){let q=G[1],U=$.slice(Z),W=new RegExp(`\\b${q}\\.exec\\s*\\(`),K=new RegExp(`\\b${q}\\.test\\s*\\(`),H=new RegExp(`\\.match(?:All)?\\s*\\(\\s*${q}\\s*\\)`),V=new RegExp(`\\.replace(?:All)?\\s*\\(\\s*${q}`),A=W.test(U),_=H.test(U),B=V.test(U),F=K.test(U);if(A||_||B)return!0;if(F)return!1;return!0}return!0}function WG($,J){let Z=J-1;while(Z>=0&&($[Z]===" "||$[Z]==="\t"))Z--;let X=Z>=0?$[Z]:"",Y="=(<>!&|?:;,{[+(~^%*/";if(!(Z<0||Y.includes(X)||/\b(?:return|typeof|void|delete|throw|new|in|of|case)\s*$/.test($.slice(Math.max(0,Z-5),Z+1))))return J+1;let Q=J+1,G=!1,q=!1;while(Q<$.length){let U=$[Q];if(q)q=!1;else if(U==="\\")q=!0;else if(U==="["){if(!G)G=!0}else if(U==="]"){if(G)G=!1}else if(U==="/"&&!G){Q++;while(Q<$.length&&/[gimsuvy]/.test($[Q]))Q++;return Q}else if(U===`
135
- `)break;Q++}return J+1}function KG($,J){let Z=[],X=J.filePath,Y=0;while(Y<$.length){let z=$[Y];if(z==="/"&&$[Y+1]==="/"){while(Y<$.length&&$[Y]!==`
136
- `)Y++;continue}if(z==="/"&&$[Y+1]==="*"){Y+=2;while(Y<$.length-1&&!($[Y]==="*"&&$[Y+1]==="/"))Y++;Y+=2;continue}if(z==="'"||z==='"'||z==="`"){let Q=z;Y++;while(Y<$.length){if($[Y]==="\\"){Y+=2;continue}if($[Y]===Q){Y++;break}Y++}continue}if(z==="/"){let Q=qG($,Y);if(!Q){let G=WG($,Y);if(G>Y+1)Y=G;else Y++;continue}if(!UG($,Q.patternStart,Q.patternEnd)){let G=Q.patternStart+1+(Q.firstCapOffset>=0?Q.firstCapOffset:0),q=$.slice(0,G),U=(q.match(/\r?\n/g)||[]).length+1,W=G-(q.lastIndexOf(`
137
- `)+1)+1;Z.push({filePath:X,line:U,column:W,ruleId:"regexp/no-unused-capturing-group",message:"Unused capturing group in regular expression; use non-capturing group (?:...) instead",severity:"error"})}Y=Q.patternEnd;continue}Y++}return Z}var cX={meta:{docs:"Flags regex literals with unused capturing groups (context-aware)",recommended:!1},check($,J){return KG($,J)}};var rX={meta:{docs:"Disallow lazy quantifiers that don't affect the matching behavior",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(z.trim().startsWith("//")||z.trim().startsWith("/*")||z.trim().startsWith("*"))continue;let Q=/\/(?![/*])([^/\n\r\\]|\\.)+\/[gimsuvy]*/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[0],U=q.slice(1,q.lastIndexOf("/"));if(/[+*?]\?\$$/.test(U))Z.push({filePath:J.filePath,line:Y+1,column:G.index+U.search(/[+*?]\?\$$/)+2,ruleId:"regexp/no-useless-lazy",message:"Lazy quantifier is useless before end-of-string anchor",severity:"error"});if(/[+*?]\?$/.test(U))Z.push({filePath:J.filePath,line:Y+1,column:G.index+U.length-1,ruleId:"regexp/no-useless-lazy",message:"Lazy quantifier is useless at the end of the pattern",severity:"error"})}}return Z}};var lX={name:"regexp",rules:{"no-super-linear-backtracking":w(oX),"no-unused-capturing-group":w(cX),"no-useless-lazy":w(rX)}};var aX={meta:{docs:"Use $() instead of backticks for command substitution",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="",Q=!1;for(let G=0;G<X.length;G++){let q=X[G];if(Y){if(q.trim()===z)Y=!1;continue}let U=q.match(/<<-?\s*['"]?(\w+)['"]?/);if(U)Y=!0,z=U[1];if(q.replace(/^\s+/,"").startsWith("#"))continue;Q=!1;for(let K=0;K<q.length;K++){let H=q[K];if(H==="#"&&!Q)break;if(H==="\\"){K++;continue}if(H==="'"){Q=!Q;continue}if(Q)continue;if(H==="`"){Z.push({filePath:J.filePath,line:G+1,column:K+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(K++;K<q.length&&q[K]!=="`";K++)if(q[K]==="\\")K++}}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[],Y=!1,z="";for(let Q of Z){if(Y){if(X.push(Q),Q.trim()===z)Y=!1;continue}let G=Q.match(/<<-?\s*['"]?(\w+)['"]?/);if(G)Y=!0,z=G[1];let q="",U=!1,W=0;while(W<Q.length){let K=Q[W];if(K==="#"&&!U){q+=Q.slice(W);break}if(K==="\\"){q+=Q.slice(W,W+2),W+=2;continue}if(K==="'"){U=!U,q+=K,W++;continue}if(U){q+=K,W++;continue}if(K==="`"){let H="";W++;while(W<Q.length&&Q[W]!=="`")if(Q[W]==="\\")H+=Q[W+1]||"",W+=2;else H+=Q[W],W++;W++,q+=`$(${H})`}else q+=K,W++}X.push(q)}return X.join(`
138
- `)}};var sX={meta:{docs:"Require error handling after cd commands",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=G.match(/<<-?\s*['"]?(\w+)['"]?/);if(q)Y=!0,z=q[1];let U=G.replace(/^\s+/,"");if(U.startsWith("#"))continue;let W=U.match(/^cd\s+/);if(!W)continue;let K=/\|\||&&/.test(G),H=/^\s*(?:if|elif|while|until)\s/.test(U)||/\bif\s+cd\b/.test(G),V=/\(.*\bcd\b.*\)/.test(G);if(!K&&!H&&!V)Z.push({filePath:J.filePath,line:Q+1,column:W.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 Z}};var nX={meta:{docs:"Disallow use of eval in shell scripts",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=G.match(/<<-?\s*['"]?(\w+)['"]?/);if(q)Y=!0,z=q[1];if(G.replace(/^\s+/,"").startsWith("#"))continue;if(G.match(/(?:^|[;&|]\s*|^\s+)eval\s/)){let K=G.indexOf("eval");Z.push({filePath:J.filePath,line:Q+1,column:K+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 Z}};var iX={meta:{docs:"Flag exit inside subshells where it only exits the subshell",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="",Q=0;for(let G=0;G<X.length;G++){let q=X[G];if(Y){if(q.trim()===z)Y=!1;continue}let U=q.match(/<<-?\s*['"]?(\w+)['"]?/);if(U)Y=!0,z=U[1];if(q.replace(/^\s+/,"").startsWith("#"))continue;let K=!1,H=!1;for(let V=0;V<q.length;V++){let A=q[V];if(A==="#"&&!K&&!H)break;if(A==="\\"&&!K){V++;continue}if(A==="'"&&!H){K=!K;continue}if(A==='"'&&!K){H=!H;continue}if(!K&&!H){if(A==="("&&V>0&&q[V-1]!=="$"&&q[V+1]!=="(")Q++;else if(A==="("&&V===0&&q[V+1]!=="(")Q++;else if(A===")"&&Q>0&&(V+1>=q.length||q[V+1]!==")"))Q--}}if(Q>0){let V=q.match(/\bexit\b/);if(V)Z.push({filePath:J.filePath,line:G+1,column:V.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(Q===0){let V=q.match(/(?<!\$)\((?!\()([^)]*\bexit\b[^)]*)\)(?!\))/);if(V){let A=q.indexOf("exit",V.index);Z.push({filePath:J.filePath,line:G+1,column:A+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 Z}};var tX={meta:{docs:"Disallow parsing ls output \u2014 use globs or find instead",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=G.match(/<<-?\s*['"]?(\w+)['"]?/);if(q)Y=!0,z=q[1];if(G.replace(/^\s+/,"").startsWith("#"))continue;if(G.match(/\bls\b[^|]*\|/)){let V=G.indexOf("ls");Z.push({filePath:J.filePath,line:Q+1,column:V+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 K=G.match(/\$\(\s*ls\b/);if(K){let V=K.index+1;Z.push({filePath:J.filePath,line:Q+1,column:V,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 H=G.match(/`\s*ls\b/);if(H){let V=H.index+1;Z.push({filePath:J.filePath,line:Q+1,column:V,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 Z}};var eX={meta:{docs:"Detect useless use of cat (UUOC)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=G.match(/<<-?\s*['"]?(\w+)['"]?/);if(q)Y=!0,z=q[1];if(G.replace(/^\s+/,"").startsWith("#"))continue;let W=G.match(/\bcat\s+(["']?[\w.\/~${}*?-]+["']?)\s*\|/);if(W){let K=G.indexOf("cat");Z.push({filePath:J.filePath,line:Q+1,column:K+1,ruleId:"shell/no-useless-cat",message:`Useless use of cat \u2014 pipe the file directly instead of \`cat ${W[1]} | ...\``,severity:"warning",help:`Use \`cmd < ${W[1]}\` or pass the file as an argument to the command`})}}return Z}};var $5={meta:{docs:"Flag variables inside single quotes where they won't expand",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=G.match(/<<-?\s*['"]?(\w+)['"]?/);if(q)Y=!0,z=q[1];if(G.replace(/^\s+/,"").startsWith("#"))continue;let W=!1,K=!1,H=-1;for(let V=0;V<G.length;V++){let A=G[V];if(A==="#"&&!W&&!K)break;if(A==="\\"&&!W){V++;continue}if(A==='"'&&!W){K=!K;continue}if(A==="'"&&!K)if(!W)W=!0,H=V;else{let B=G.slice(H+1,V).match(/\$(?:[A-Za-z_]\w*|\{[^}]+\}|\([^)]*\))/);if(B)Z.push({filePath:J.filePath,line:Q+1,column:H+1+B.index+1,ruleId:"shell/no-variable-in-single-quotes",message:`Variable ${B[0]} is inside single quotes and won't be expanded`,severity:"warning",help:`Use double quotes if you want variable expansion: "..." instead of '...'`});W=!1}}}return Z}};var HG=[/^\s*(?:local|export|declare|typeset|readonly)\s+/,/\[\[.*\]\]/,/\(\(.*\)\)/],$9=/^\$(?:\{[A-Za-z_]\w*(?:[:#%\/][^}]*)?\}|[A-Za-z_]\w*)/,Z5={meta:{docs:"Quote variable expansions to prevent word splitting and globbing",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=P0(G);if(q){if(Y=!0,z=q,new RegExp(`<<-?\\s*['"]${q}['"]`).test(G))continue}if(G.replace(/^\s+/,"").startsWith("#"))continue;if(HG.some((H)=>H.test(G)))continue;let W=[],K=0;while(K<G.length){let H=W[W.length-1];if(H==="squote"){if(G[K]==="'")W.pop();K++;continue}if(G[K]==="\\"&&K+1<G.length){K+=2;continue}if(H==="dquote"){let A=G[K];if(A==='"'){W.pop(),K++;continue}if(A==="$"&&G[K+1]==="("&&G[K+2]==="("){W.push("arith"),K+=3;continue}if(A==="$"&&G[K+1]==="("){W.push("subshell"),K+=2;continue}if(A==="$"){let _=G.slice(K).match($9);if(_){K+=_[0].length;continue}}K++;continue}if(H==="arith"){let A=G[K];if(A===")"&&G[K+1]===")"){W.pop(),K+=2;continue}if(A==="$"){let _=G.slice(K).match($9);if(_){K+=_[0].length;continue}}K++;continue}let V=G[K];if(V==="#"&&(K===0||/\s/.test(G[K-1])))break;if(V==="'"){W.push("squote"),K++;continue}if(V==='"'){W.push("dquote"),K++;continue}if(V==="$"&&G[K+1]==="("&&G[K+2]==="("){W.push("arith"),K+=3;continue}if(V==="$"&&G[K+1]==="("){W.push("subshell"),K+=2;continue}if(V===")"&&H==="subshell"){W.pop(),K++;continue}if(V==="$"){let A=G.slice(K).match($9);if(A){let _=A[0];if(!/^\$[?!#@*0-9-]/.test(_))Z.push({filePath:J.filePath,line:Q+1,column:K+1,ruleId:"shell/quote-variables",message:`Unquoted variable ${_} \u2014 use "${_}" to prevent word splitting`,severity:"warning",help:`Wrap in double quotes: "${_}"`});K+=_.length;continue}}K++}}return Z}};var J5={meta:{docs:"Enforce consistent function declaration style",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=G.match(/<<-?\s*['"]?(\w+)['"]?/);if(q)Y=!0,z=q[1];let U=G.replace(/^\s+/,"");if(U.startsWith("#"))continue;let W=U.match(/^function\s+(\w+)\s*(?:\(\s*\))?\s*\{?\s*$/);if(W){let K=W[1],H=G.indexOf("function");Z.push({filePath:J.filePath,line:Q+1,column:H+1,ruleId:"shell/function-style",message:`Use \`${K}() {\` instead of \`function ${K}\` \u2014 POSIX-compatible style`,severity:"warning",help:`Replace with: ${K}() {`})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X.match(/^(\s*)function\s+(\w+)\s*(?:\(\s*\))?\s*(\{?\s*)$/);if(Y){let[,z,Q,G]=Y;Z.push(`${z}${Q}() ${G||"{"}`)}else Z.push(X)}return Z.join(`
139
- `)}};function X5($,J){if(/^then\b/.test($)||/^do\b/.test($)||/^else\b/.test($))return!0;if(/^if\b/.test($)&&/\bthen\s*$/.test($))return!0;if(/^elif\b/.test($)&&/\bthen\s*$/.test($))return!0;if(/^(?:while|for|until)\b/.test($)&&/\bdo\s*$/.test($))return!0;if(/^case\b/.test($)&&/\bin\s*$/.test($))return!0;if(J&&/\)\s*$/.test($)&&!/\$\(/.test($)&&!/^\s*\(/.test($)&&!$.startsWith("#"))return!0;if(/\{\s*$/.test($)&&!$.startsWith("#"))return!0;return!1}function Y5($){return/^(?:fi|done|esac|elif|else)\b/.test($)||/^\}/.test($)||/^;[;&]\s*$/.test($)}var z5={meta:{docs:"Enforce consistent indentation in shell scripts",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=J.config.format.indent||2,z=0,Q=!1,G="",q=!1,U=0;for(let W=0;W<X.length;W++){let K=X[W];if(/^\s*$/.test(K))continue;if(Q){if(K.trim()===G)Q=!1;continue}let H=K.match(/<<-?\s*['"]?(\w+)['"]?/);if(H)Q=!0,G=H[1];let V=K.replace(/^\s+/,"");if(W===0&&V.startsWith("#!"))continue;if(/^case\b/.test(V)&&/\bin\s*$/.test(V))U++,q=!0;if(/^esac\b/.test(V)){if(U=Math.max(0,U-1),U===0)q=!1}if(Y5(V))z=Math.max(0,z-1);let A=0;for(let B=0;B<K.length;B++)if(K[B]===" ")A++;else if(K[B]==="\t")A+=Y;else break;let _=z*Y;if(A!==_&&!V.startsWith("#"))Z.push({filePath:J.filePath,line:W+1,column:1,ruleId:"shell/indent",message:`Expected ${_} spaces of indentation, found ${A}`,severity:"warning"});if(X5(V,q))z++}return Z},fix($,J){let Z=$.split(/\r?\n/),X=J.config.format.indent||2,Y=J.config.format.indentStyle==="tabs",z=[],Q=0,G=!1,q="",U=!1,W=0;for(let K=0;K<Z.length;K++){let H=Z[K];if(/^\s*$/.test(H)){z.push("");continue}if(G){if(z.push(H),H.trim()===q)G=!1;continue}let V=H.match(/<<-?\s*['"]?(\w+)['"]?/);if(V)G=!0,q=V[1];let A=H.replace(/^\s+/,"").trimEnd();if(K===0&&A.startsWith("#!")){z.push(A);continue}if(/^case\b/.test(A)&&/\bin\s*$/.test(A))W++,U=!0;if(/^esac\b/.test(A)){if(W=Math.max(0,W-1),W===0)U=!1}if(Y5(A))Q=Math.max(0,Q-1);let _=Y?"\t".repeat(Q):" ".repeat(Q*X);if(z.push(_+A),X5(A,U))Q++}return z.join(`
140
- `)}};var Q5={meta:{docs:"Enforce spacing around shell keywords (if, then, do, else, fi, etc.)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=P0(G);if(q)Y=!0,z=q;if(G.replace(/^\s+/,"").startsWith("#"))continue;let W=b0(G),K=W.match(/;(?![;\s$])\S/);if(K)Z.push({filePath:J.filePath,line:Q+1,column:(K.index||0)+1,ruleId:"shell/keyword-spacing",message:"Missing space after semicolon",severity:"warning"});let H=W.match(/\w(then|do|else|elif|fi|done|esac)\b/);if(H&&!/[a-z]/.test(W[H.index])){let V=H[1],A=W[H.index];if(A!==" "&&A!=="\t"&&A!==";")Z.push({filePath:J.filePath,line:Q+1,column:(H.index||0)+2,ruleId:"shell/keyword-spacing",message:`Missing space before keyword '${V}'`,severity:"warning"})}}return Z}};var G5={meta:{docs:"Disallow unnecessary trailing semicolons",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=G.match(/<<-?\s*['"]?(\w+)['"]?/);if(q)Y=!0,z=q[1];let U=G.replace(/^\s+/,"").trimEnd();if(U.startsWith("#"))continue;if(/;;\s*$/.test(U))continue;if(/\bfor\b/.test(U)||/\bwhile\b/.test(U)||/\buntil\b/.test(U))continue;if(/;\s*(?:then|do|else|elif|fi|done|esac)\s*$/.test(U))continue;if(/;\s*$/.test(U)){let W=G.lastIndexOf(";");Z.push({filePath:J.filePath,line:Q+1,column:W+1,ruleId:"shell/no-trailing-semicolons",message:"Unnecessary trailing semicolon",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[],X=!1,Y="";for(let z of J){if(X){if(Z.push(z),z.trim()===Y)X=!1;continue}let Q=z.match(/<<-?\s*['"]?(\w+)['"]?/);if(Q)X=!0,Y=Q[1];let G=z.replace(/^\s+/,"").trimEnd();if(G.startsWith("#")||/;;\s*$/.test(G)||/\bfor\b/.test(G)||/\bwhile\b/.test(G)||/\buntil\b/.test(G)||/;\s*(?:then|do|else|elif|fi|done|esac)\s*$/.test(G)){Z.push(z);continue}Z.push(z.replace(/;\s*$/,""))}return Z.join(`
141
- `)}};var q5={meta:{docs:"Disallow trailing whitespace",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=P0(G);if(q)Y=!0,z=q;if(/[ \t]+$/.test(G)){let U=G.match(/[ \t]+$/);Z.push({filePath:J.filePath,line:Q+1,column:U.index+1,ruleId:"shell/no-trailing-whitespace",message:"Trailing whitespace",severity:"error"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=!1,X="";return J.map((z)=>{if(Z){if(z.trim()===X)Z=!1;return z}let Q=P0(z);if(Q)Z=!0,X=Q;return z.replace(/[ \t]+$/,"")}).join(`
142
- `)}};var U5={meta:{docs:"Enforce spaces inside [ ] and [[ ]] test expressions",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=P0(G);if(q)Y=!0,z=q;if(G.replace(/^\s+/,"").startsWith("#"))continue;let W=b0(G);for(let K of VG(W,Q+1,J.filePath))Z.push(K)}return Z},fix($){let J=$.split(/\r?\n/),Z=[],X=!1,Y="";for(let z of J){if(X){if(z.trim()===Y)X=!1;Z.push(z);continue}let Q=P0(z);if(Q){X=!0,Y=Q,Z.push(z);continue}if(z.replace(/^\s+/,"").startsWith("#")){Z.push(z);continue}Z.push(AG(z))}return Z.join(`
143
- `)}};function VG($,J,Z){let X=[],Y=/\[\[(?!\s|\]|$)/g;for(let Q of $.matchAll(Y))X.push({filePath:Z,line:J,column:(Q.index??0)+1,ruleId:"shell/operator-spacing",message:"Missing space after [[",severity:"warning"});let z=/(?<!\s|\[)\]\]/g;for(let Q of $.matchAll(z))X.push({filePath:Z,line:J,column:(Q.index??0)+1,ruleId:"shell/operator-spacing",message:"Missing space before ]]",severity:"warning"});for(let Q=0;Q<$.length;Q++){if($[Q]!=="[")continue;if($[Q+1]==="[")continue;if(Q>0&&$[Q-1]==="[")continue;if(!W5($,Q))continue;let G=$[Q+1];if(G!==void 0&&G!==" "&&G!=="\t")X.push({filePath:Z,line:J,column:Q+1,ruleId:"shell/operator-spacing",message:"Missing space after [",severity:"warning"})}for(let Q=0;Q<$.length;Q++){if($[Q]!=="]")continue;if($[Q+1]==="]")continue;if(Q>0&&$[Q-1]==="]")continue;if(!K5($,Q))continue;let G=$[Q-1];if(G!==void 0&&G!==" "&&G!=="\t")X.push({filePath:Z,line:J,column:Q+1,ruleId:"shell/operator-spacing",message:"Missing space before ]",severity:"warning"})}return X}function AG($){let J=b0($),Z=[];for(let Y of J.matchAll(/\[\[(?!\s|\]|$)/g)){let z=(Y.index??0)+2;Z.push({pos:z,text:" "})}for(let Y of J.matchAll(/(?<!\s|\[)\]\]/g)){let z=Y.index??0;Z.push({pos:z,text:" "})}for(let Y=0;Y<J.length;Y++){if(J[Y]!=="[")continue;if(J[Y+1]==="[")continue;if(Y>0&&J[Y-1]==="[")continue;if(!W5(J,Y))continue;let z=J[Y+1];if(z!==void 0&&z!==" "&&z!=="\t")Z.push({pos:Y+1,text:" "})}for(let Y=0;Y<J.length;Y++){if(J[Y]!=="]")continue;if(J[Y+1]==="]")continue;if(Y>0&&J[Y-1]==="]")continue;if(!K5(J,Y))continue;let z=J[Y-1];if(z!==void 0&&z!==" "&&z!=="\t")Z.push({pos:Y,text:" "})}if(Z.length===0)return $;Z.sort((Y,z)=>z.pos-Y.pos);let X=$;for(let{pos:Y,text:z}of Z)X=`${X.slice(0,Y)}${z}${X.slice(Y)}`;return X}function W5($,J){let Z=J-1;while(Z>=0&&($[Z]===" "||$[Z]==="\t"))Z--;if(Z<0)return!0;let X=$[Z];if(X===";"||X==="|"||X==="&"||X==="!"||X==="(")return!0;let Y=$.slice(0,Z+1);if(/(?:^|\s)(?:if|while|until|elif|then|else|do)\s*$/.test(Y))return!0;return!1}function K5($,J){let Z=$[J+1];if(Z===void 0)return!0;return Z===" "||Z==="\t"||Z===";"||Z==="|"||Z==="&"||Z===")"}var _G=/^#!\s*(?:\/usr\/bin\/env\s+(?:ba|z|k|da)?sh|\/bin\/(?:ba|z|k|da)?sh|\/usr\/bin\/(?:ba|z|k|da)?sh)\b/,H5={meta:{docs:"Ensure shell scripts have a proper shebang line",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);if(X.length===0)return Z;let Y=X[0];if(X.every((z)=>z.trim()===""))return Z;if(!Y.startsWith("#!"))return Z.push({filePath:J.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"}),Z;if(!_G.test(Y))Z.push({filePath:J.filePath,line:1,column:1,ruleId:"shell/shebang",message:`Invalid shebang: ${Y} \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 Z}};var V5={meta:{docs:"Enforce consistent case statement terminator placement",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="",Q=[];for(let G of X){if(Y){if(G.trim()===z)Y=!1;Q.push("");continue}let q=P0(G);if(q)Y=!0,z=q;if(G.replace(/^\s+/,"").startsWith("#")){Q.push("");continue}Q.push(b0(G))}for(let G=0;G<Q.length;G++){if(!/\bcase\b[\s\S]*\bin\s*$/.test(Q[G].trimEnd()))continue;let q=1,U=-1;for(let V=G+1;V<Q.length;V++){let A=Q[V].trimEnd();if(/^\s*esac\b/.test(A)){if(q--,q===0){U=V;break}continue}if(/\bcase\b[\s\S]*\bin\s*$/.test(A))q++}if(U===-1)continue;let W=0,K=!1,H=!1;for(let V=G+1;V<U;V++){let A=Q[V],_=A.trim();if(_==="")continue;if(W===0){let B=FG(A);if(B!==-1){if(K&&H)Z.push({filePath:J.filePath,line:V+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"});K=!0,H=!0;let F=A.slice(B+1).trimEnd();if(/;;\s*$/.test(F))K=!1;continue}}if(W+=BG(A),W<0)W=0;if(K&&W===0&&/;;\s*$/.test(_))K=!1}}return Z}};function FG($){let J=$.replace(/^\s+/,"");if(J==="")return-1;if(/^(?:for|while|until|if|case|do|then|else|elif|fi|done|esac)\b/.test(J))return-1;let Z=$.length-J.length,X=0;if(J[X]==="(")X++;let Y=0;while(X<J.length){let z=J[X];if(z==="(")Y++;else if(z===")"){if(Y===0)return Z+X;Y--}else if(z===";"||z==="&"||z==="<"||z===">"||z==="=")return-1;X++}return-1}function BG($){let J=$.trim();if(J==="")return 0;let Z=J.split(/[\s;]+/),X=0;for(let Y of Z)if(Y==="if"||Y==="for"||Y==="while"||Y==="until")X++;else if(Y==="fi"||Y==="done")X--;return X}var A5={meta:{docs:"Recommend <<- for heredocs inside indented blocks"},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(z.replace(/^\s+/,"").startsWith("#"))continue;if(!z.match(/^\s+/))continue;let U=b0(z).match(/(?<!<)<<(?![<-])/);if(!U||U.index===void 0)continue;let K=z.slice(U.index+2).match(/^\s*(['"]?)(\w+)\1\s*$/);if(K){let H=K[2];Z.push({filePath:J.filePath,line:Y+1,column:U.index+1,ruleId:"shell/heredoc-indent",message:`Use <<- instead of << for indented heredoc (delimiter '${H}' must be at column 0 otherwise)`,severity:"warning",help:"Use <<- to strip leading tabs from heredoc content, allowing proper indentation"})}}return Z}};var _5={meta:{docs:"Detect incorrect redirect ordering (2>&1 before > file)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=P0(G);if(q)Y=!0,z=q;if(G.replace(/^\s+/,"").startsWith("#"))continue;let W=b0(G);if(W.match(/2>&1\s+>(?!&)\s*\S/)){let H=W.indexOf("2>&1");Z.push({filePath:J.filePath,line:Q+1,column:H+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 Z}};var F5={meta:{docs:"Prefer [[ ]] over [ ] for test expressions in bash/zsh",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/)[0]||"",Y=/bash|zsh/.test(X);if(/^#!.*\bsh\b/.test(X)&&!Y||!Y)return Z;let Q=$.split(/\r?\n/),G=!1,q="";for(let U=0;U<Q.length;U++){let W=Q[U];if(G){if(W.trim()===q)G=!1;continue}let K=W.match(/<<-?\s*['"]?(\w+)['"]?/);if(K)G=!0,q=K[1];if(W.replace(/^\s+/,"").startsWith("#"))continue;if(W.match(/(?:^|\s|;)\[\s(?!\[)/)){if(/(?<!\])\](?!\])/.test(W)){let A=W.indexOf("[");Z.push({filePath:J.filePath,line:U+1,column:A+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 Z},fix($){let J=$.split(/\r?\n/)[0]||"";if(!/bash|zsh/.test(J))return $;let X=$.split(/\r?\n/),Y=[];for(let z of X){let Q=z;Q=Q.replace(/(?:^|(?<=\s|;))\[(\s(?!\[).*?(?<!\]))\](?!\])/g,"[[$1]]"),Y.push(Q)}return Y.join(`
144
- `)}};var B5={meta:{docs:"Prefer printf over echo -e and echo -n",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=G.match(/<<-?\s*['"]?(\w+)['"]?/);if(q)Y=!0,z=q[1];if(G.replace(/^\s+/,"").startsWith("#"))continue;let W=G.match(/\becho\s+-[en]+\b/);if(W){let K=G.indexOf("echo"),H=W[0].replace("echo ","");Z.push({filePath:J.filePath,line:Q+1,column:K+1,ruleId:"shell/prefer-printf",message:`Use printf instead of echo ${H} \u2014 echo behavior varies across platforms`,severity:"warning",help:'printf is portable: printf "format\\n" args... (use \\n for newline)'})}}return Z}};var w5={meta:{docs:"Recommend set -euo pipefail for safer script execution"},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1,Q=!1,G=-1,q=!1;for(let W=0;W<X.length;W++){let K=X[W].replace(/^\s+/,"");if(W===0&&K.startsWith("#!")){G=W;continue}if(K.startsWith("#"))continue;if(K==="")continue;if(q=!0,/\bset\s+-\w*e/.test(K))Y=!0;if(/\bset\s+-\w*u/.test(K))z=!0;if(/\bset\s+.*-o\s+pipefail/.test(K))Q=!0;if(/\bset\s+-euo\s+pipefail/.test(K))Y=!0,z=!0,Q=!0}if(!q)return Z;let U=[];if(!Y)U.push("-e");if(!z)U.push("-u");if(!Q)U.push("-o pipefail");if(U.length>0)Z.push({filePath:J.filePath,line:G>=0?G+2:1,column:1,ruleId:"shell/set-options",message:`Missing shell safety options: set ${U.join(" ")}`,severity:"warning",help:"Add `set -euo pipefail` near the top of the script for safer execution"});return Z}};var M5={name:"shell",rules:{"command-substitution":V0(aX),"quote-variables":V0(Z5),"no-cd-without-check":V0(sX),"no-eval":V0(nX),"no-useless-cat":V0(eX),"no-ls-parsing":V0(tX),"no-variable-in-single-quotes":V0($5),"no-exit-in-subshell":V0(iX),shebang:V0(H5),indent:V0(z5),"function-style":V0(J5),"operator-spacing":V0(U5),"keyword-spacing":V0(Q5),"no-trailing-semicolons":V0(G5),"no-trailing-whitespace":V0(q5),"prefer-double-brackets":V0(F5),"set-options":V0(w5),"prefer-printf":V0(B5),"consistent-case-terminators":V0(V5),"no-broken-redirect":V0(_5),"heredoc-indent":V0(A5)}};var y8=null,v8=null,Z9=!1,J9=!0;function wG(){if(Z9)return J9;try{return y8=(()=>{throw new Error("Cannot require module "+"@stacksjs/ts-spell-check");})(),y8.SpellChecker.create({minWordLength:3,maxSuggestions:3}).then(($)=>{v8=$}).catch(()=>{J9=!1}),Z9=!0,!0}catch{return Z9=!0,J9=!1,!1}}function X9($,J){return{meta:{docs:$==="spell/check"?"Check spelling in text content":$==="spell/check-comments"?"Check spelling in code comments only":"Check spelling in markdown files"},check(Z,X){if(!wG()||!y8)return[];let{extractWords:Y,parseDirectives:z,isSuppressed:Q,getProgrammingWords:G}=y8,q=X.options,U=new Set((q?.words||[]).map((_)=>_.toLowerCase())),W=q?.minWordLength||3,K=G(),H=z(Z);for(let _ of H)if(_.type==="word")_.words.forEach((B)=>U.add(B.toLowerCase()));let V=Z.split(/\r?\n/),A=[];for(let _=0;_<V.length;_++){let B=V[_],F=_+1;if(J&&!J(B))continue;let M=Y(B);for(let{word:N,offset:E}of M){if(N.length<W)continue;if(N===N.toUpperCase()&&N.length<=5)continue;if(U.has(N.toLowerCase()))continue;if(K.has(N.toLowerCase()))continue;if(Q(N,F,H,U))continue;if(v8){if(v8.isCorrect(N))continue;let j=v8.suggest(N);A.push({filePath:X.filePath,line:F,column:E+1,ruleId:$,message:`Unknown word: "${N}"`,severity:"warning",help:j.length?`Did you mean: ${j.slice(0,3).join(", ")}? Or add to config words.`:`Add "${N}" to your config words array, or use: // spell-check:ignore ${N}`})}}}return A}}}function MG($){let J=$.trimStart();return J.startsWith("//")||J.startsWith("/*")||J.startsWith("*")||J.startsWith("#")}var j5={name:"spell",rules:{check:X9("spell/check"),"check-comments":X9("spell/check-comments",MG),"check-markdown":{meta:{docs:"Check spelling in markdown files"},check($,J){if(!J.filePath.endsWith(".md"))return[];return X9("spell/check-markdown").check($,J)}}}};function N5($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var T5={meta:{docs:"Disallow spaces inside array brackets",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G=0;G<z.length;G++){if(z[G]==="["&&!N5(z,G)){let q=z[G+1];if(q==="]"||q===void 0||q===`
145
- `)continue;if(q===" "||q==="\t"){if(z.indexOf("]",G+1)!==-1)Z.push({filePath:J.filePath,line:Y+1,column:G+2,ruleId:"style/array-bracket-spacing",message:"Unexpected space after '['",severity:"warning"})}}if(z[G]==="]"&&!N5(z,G)){let q=G>0?z[G-1]:void 0;if(q==="["||q===void 0)continue;if(q===" "||q==="\t"){if(z.lastIndexOf("[",G-1)!==-1)Z.push({filePath:J.filePath,line:Y+1,column:G,ruleId:"style/array-bracket-spacing",message:"Unexpected space before ']'",severity:"warning"})}}}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.replace(/\[\s+(\S)/g,(z,Q)=>{if(Q==="]")return z;return`[${Q}`}),Y=Y.replace(/(\S)\s+\]/g,"$1]"),Z.push(Y)}return Z.join(`
146
- `)}};var E5=/(?<![(\[{,=:?&|+\-*/])\b([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=>/g;function jG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var D5={meta:{docs:"Require parentheses around arrow function parameters",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;E5.lastIndex=0;while((G=E5.exec(z))!==null){let q=G.index;if(jG(z,q))continue;let U=G[1];if(z.slice(0,q).trimEnd().endsWith("("))continue;if(U==="async")continue;Z.push({filePath:J.filePath,line:Y+1,column:q+1,ruleId:"style/arrow-parens",message:`Arrow function parameter '${U}' should be wrapped in parentheses`,severity:"warning"})}}return Z},fix($){return $.replace(/(?<![(\[{,=:?&|+\-*/])\b([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=>/g,(J,Z)=>{if(Z==="async")return J;return J.replace(Z,`(${Z})`)})}};var b8=/=>/g;function R5($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var O5={meta:{docs:"Require space before and after => in arrow functions",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;b8.lastIndex=0;while((G=b8.exec(z))!==null){let q=G.index;if(R5(z,q))continue;if(q>0&&z[q-1]!==" "&&z[q-1]!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:q+1,ruleId:"style/arrow-spacing",message:"Missing space before =>",severity:"warning"});let U=q+2;if(U<z.length&&z[U]!==" "&&z[U]!=="\t"&&z[U]!==`
128
+ ${G}`;if(I7(q)!==q)return[{filePath:J.filePath,line:Y+1,column:1,ruleId:"sort-imports",message:"Imports are not sorted/grouped consistently",severity:"warning"}];return[]},fix:($)=>I7($)};var QX={name:"perfectionist",rules:{"sort-imports":w(I8)}};import{dirname as P2,resolve as C2}from"path";function t($){try{let J=JSON.parse($);if(typeof J!=="object"||J===null||Array.isArray(J))return null;return J}catch{return null}}function I2($,J){let Z=$.split(`
129
+ `),X=1,Y=0;for(let z of J){let Q=new RegExp(`"${b2(z)}"\\s*:`);for(let G=Y;G<Z.length;G++)if(Q.test(Z[G])){X=G+1,Y=G+1;break}}return X}function x0($){return P2($)}function I0($,J){return C2($,J)}function Z0($){let J="pkg";for(let Z of $)if(/^\d+$/.test(Z))J+=`[${Z}]`;else if(!/^[a-z_$][a-z0-9_$]*$/i.test(Z))J+=`["${Z}"]`;else J+=`.${Z}`;return J}function i($,J){if($.publishConfig?.[J]!==void 0)return[$.publishConfig[J],["publishConfig",J]];return[$[J],[J]]}var S2=new RegExp(`(?:[\\s;]|^)(?:import[\\w,{}\\s*]*from|import\\s*['"*{]|export\\b\\s*(?:[*{]|default|type|function|const|var|let|async function)|import\\.meta\\b)`,"m"),v2=new RegExp("(?:[\\s;]|^)(?:module.exports\\b|exports\\.\\w|require\\s*\\(|global\\.\\w|Object\\.(?:defineProperty|defineProperties|assign)\\s*\\(\\s*exports\\b)","m");function Y1($){let J=y2($),Z=S2.test(J),X=v2.test(J);if(Z&&X)return"mixed";if(Z)return"ESM";if(X)return"CJS";return"unknown"}function GX($,J){if($.endsWith(".mjs"))return"ESM";if($.endsWith(".cjs"))return"CJS";return J==="module"?"ESM":"CJS"}function qX($){if($==="ESM")return".mjs";if($==="CJS")return".cjs";return".js"}function UX($){return $===".mjs"||$===".cjs"}function l0($){return $.endsWith(".js")||$.endsWith(".mjs")||$.endsWith(".cjs")}function WX($){return/^#!\s*\//.test($)}function y2($){return $.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*/g,"")}function W0($,J,Z,X){S7($,J,Z,X)}function S7($,J,Z,X){if(typeof $==="string"){X($,{path:J,isImports:Z});return}if(Array.isArray($)){X($,{path:J,isImports:Z});for(let Y=0;Y<$.length;Y++)S7($[Y],J.concat(String(Y)),Z,X);return}if($!==null&&typeof $==="object"){let Y=Object.keys($);X($,{path:J,isImports:Z},Y);for(let z of Y)S7($[z],J.concat(z),Z,X)}}function s($,J,Z,X,Y,z,Q){return{filePath:$,line:I2(J,Z),column:1,ruleId:X,message:Y,severity:z,...Q&&{help:Q}}}function b2($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var v7={meta:{docs:"Disallow deprecated jsnext:main and jsnext fields",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[];if(Z["jsnext:main"]!=null)X.push(s(J.filePath,$,["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(Z.jsnext!=null)X.push(s(J.filePath,$,["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 X}};var y7={meta:{docs:'Ensure "default" condition is last in exports objects',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return W0(Y,z,!1,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("default"in Q))return;if(q[q.length-1]!=="default")X.push(s(J.filePath,$,G.path.concat("default"),"publint/exports-default-should-be-last",`${Z0(G.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.'))}),X}};var b7={meta:{docs:"Warn against using fallback arrays in exports",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return W0(Y,z,!1,(Q,G)=>{if(!Array.isArray(Q))return;X.push(s(J.filePath,$,G.path,"publint/exports-fallback-array-use",`${Z0(G.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."))}),X}};var k7={meta:{docs:"Ensure exports has a root entrypoint when main/module exist",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let[X]=i(Z,"main"),[Y]=i(Z,"module"),[z,Q]=i(Z,"exports");if(X==null&&Y==null||z==null)return[];if(typeof z!=="object"||Array.isArray(z))return[];let G=Object.keys(z);if(G.length===0)return[];if(!G[0]?.startsWith("."))return[];if(G.includes("."))return[];let U=[];if(X)U.push("main");if(Y)U.push("module");return[s(J.filePath,$,Q,"publint/exports-missing-root-entrypoint",`${Z0(Q)} is missing the root entrypoint export, which is defined in pkg.${U[0]}. Environments that support "exports" will ignore pkg.${U[0]} as "exports" takes the highest priority.`,"warning",`Add ${Z0(Q.concat("."))} to ensure the root entrypoint is accessible.`)]}};var f7={meta:{docs:'Ensure "module" condition precedes "require" in exports',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return W0(Y,z,!1,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("module"in Q)||!("require"in Q))return;if(q.indexOf("module")>q.indexOf("require"))X.push(s(J.filePath,$,G.path.concat("module"),"publint/exports-module-should-precede-require",`${Z0(G.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.'))}),X}};var g7={meta:{docs:'Ensure "types" condition is first in exports objects',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return W0(Y,z,!1,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("types"in Q))return;let U=q.indexOf("types");if(U===0)return;if(q.slice(0,U).filter((K)=>{if(K.startsWith("types"))return!1;if(typeof Q[K]==="object"&&Q[K]!==null&&KX(Q[K],"types"))return!1;return!0}).length>0)X.push(s(J.filePath,$,G.path.concat("types"),"publint/exports-types-should-be-first",`${Z0(G.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.'))}),X}};function KX($,J){for(let Z in $){if(Z===J)return!0;if(typeof $[Z]==="object"&&$[Z]!==null&&KX($[Z],J))return!0}return!1}var p7={meta:{docs:'Ensure exports values start with "./"',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return W0(Y,z,!1,(Q,G)=>{if(typeof Q!=="string")return;if(Q.startsWith("./"))return;let q=`./${Q.replace(/^[/]+/,"")}`;X.push(s(J.filePath,$,G.path,"publint/exports-value-invalid",`${Z0(G.path)} is "${Q}" which is invalid as it does not start with "./". Use "${q}" instead.`,"error",'All exports values must be relative paths starting with "./".'))}),X}};var k2=[{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"]}],x7={meta:{docs:"Ensure package.json fields have correct value types",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[];for(let{field:Y,expectTypes:z}of k2){let[Q,G]=i(Z,Y);if(Q==null)continue;let q=typeof Q;if(!z.includes(q)){let U=z.length===1?z[0]:`${z.slice(0,-1).join(", ")} or ${z[z.length-1]}`;X.push(s(J.filePath,$,G,"publint/field-invalid-value-type",`${Z0(G)} has an invalid ${q} type. Expected a ${U} type instead.`,"error",`The "${Y}" field must be of type ${U}.`))}}return X}};var h7={meta:{docs:"Suggest adding exports when module field is present",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let[X,Y]=i(Z,"module"),[z]=i(Z,"exports");if(X!=null&&z==null)return[s(J.filePath,$,Y,"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 u7={meta:{docs:'Ensure "default" condition is last in imports objects',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"imports");if(Y==null||typeof Y!=="object")return[];return W0(Y,z,!0,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("default"in Q))return;if(q[q.length-1]!=="default")X.push(s(J.filePath,$,G.path.concat("default"),"publint/imports-default-should-be-last",`${Z0(G.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.'))}),X}};var m7={meta:{docs:'Ensure imports keys start with "#"',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"imports");if(Y==null||typeof Y!=="object"||Array.isArray(Y))return[];for(let Q of Object.keys(Y))if(!Q.startsWith("#")){let G=`#${Q.replace(/^[/]+/,"")}`,q=z.concat(Q);X.push(s(J.filePath,$,q,"publint/imports-key-invalid",`${Z0(q)} is invalid as the imports key does not start with "#". Use "${G}" instead.`,"error",'All imports keys must start with "#" to distinguish them from package specifiers.'))}return X}};var d7={meta:{docs:'Ensure "module" condition precedes "require" in imports',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"imports");if(Y==null||typeof Y!=="object")return[];return W0(Y,z,!0,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("module"in Q)||!("require"in Q))return;if(q.indexOf("module")>q.indexOf("require"))X.push(s(J.filePath,$,G.path.concat("module"),"publint/imports-module-should-precede-require",`${Z0(G.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.'))}),X}};var o7={meta:{docs:'Ensure imports values start with "./"',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"imports");if(Y==null||typeof Y!=="object")return[];return W0(Y,z,!0,(Q,G)=>{if(typeof Q!=="string")return;if(!Q.startsWith("."))return;if(Q.startsWith("./"))return;let q=`./${Q.replace(/^[/]+/,"")}`;X.push(s(J.filePath,$,G.path,"publint/imports-value-invalid",`${Z0(G.path)} is "${Q}" which is invalid as it does not start with "./". Use "${q}" instead.`,"error",'Relative imports values must start with "./".'))}),X}};var c7={meta:{docs:"Disallow local file references in dependencies",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=["dependencies","optionalDependencies","peerDependencies"];for(let z of Y){let Q=Z[z];if(!Q||typeof Q!=="object")continue;for(let G of Object.keys(Q)){let q=Q[G];if(typeof q==="string"&&(q.startsWith("file:")||q.startsWith("link:")))X.push(s(J.filePath,$,[z,G],"publint/local-dependency",`The "${G}" dependency references "${q}" 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 X}};var r7={meta:{docs:'Suggest specifying the "type" field in package.json',recommended:!0},check($,J){let Z=t($);if(!Z)return[];if(Z.type==null)return[s(J.filePath,$,["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 f2,readFileSync as g2}from"fs";var l7={meta:{docs:"Ensure bin files have a shebang for executability",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=x0(J.filePath),[z,Q]=i(Z,"bin");if(z==null)return[];if(typeof z==="string")HX(z,Q,Y,X,J.filePath,$);else if(typeof z==="object"){for(let G of Object.keys(z))if(typeof z[G]==="string")HX(z[G],Q.concat(G),Y,X,J.filePath,$)}return X}};function HX($,J,Z,X,Y,z){let Q=I0(Z,$);if(!f2(Q))return;if(!l0($))return;let G;try{G=g2(Q,"utf8")}catch{return}if(!WX(G))X.push(s(Y,z,J,"publint/bin-file-not-executable",`${Z0(J)} is "${$}" 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 VX,readFileSync as AX}from"fs";var a7={meta:{docs:'Ensure files under "module" condition in exports are ESM',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=x0(J.filePath),[z,Q]=i(Z,"exports");if(z==null)return[];W0(z,Q,!1,(U,W)=>{if(typeof U!=="string")return;if(!W.path.includes("module"))return;if(!U.startsWith("./")&&!U.startsWith("../"))return;if(U.includes("*"))return;let K=I0(Y,U);if(!VX(K))return;if(!l0(U))return;let H;try{H=AX(K,"utf8")}catch{return}if(Y1(H)==="CJS")X.push(s(J.filePath,$,W.path,"publint/exports-module-should-be-esm",`${Z0(W.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[G,q]=i(Z,"imports");if(G!=null&&typeof G==="object")W0(G,q,!0,(U,W)=>{if(typeof U!=="string")return;if(!W.path.includes("module"))return;if(!U.startsWith("./"))return;if(U.includes("*"))return;let K=I0(Y,U);if(!VX(K))return;if(!l0(U))return;let H;try{H=AX(K,"utf8")}catch{return}if(Y1(H)==="CJS")X.push(s(J.filePath,$,W.path,"publint/exports-module-should-be-esm",`${Z0(W.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 X}};import{existsSync as p1}from"fs";import{dirname as p2,isAbsolute as x2,resolve as h2}from"path";function s7($,J){let Z=J;while(Z.startsWith("./"))Z=Z.slice(2);let X=Z.split("/")[0];if(!X||X===".."||X.startsWith("."))return!1;let Y=x2(J)?p2(J).split("/")[0]||"/":h2($,X);return!p1(Y)}var n7={meta:{docs:"Ensure files referenced in package.json exist",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=x0(J.filePath),z=["main","module","types","typings","unpkg","jsdelivr"];for(let W of z){let[K,H]=i(Z,W);if(K==null||typeof K!=="string")continue;if(s7(Y,K))continue;let V=I0(Y,K);if(!FX(V))X.push(s(J.filePath,$,H,"publint/file-does-not-exist",`${Z0(H)} is "${K}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))}let[Q,G]=i(Z,"bin");if(Q!=null){if(typeof Q==="string")_X(Q,G,X,J.filePath,$,Y);else if(typeof Q==="object"){for(let W of Object.keys(Q))if(typeof Q[W]==="string")_X(Q[W],G.concat(W),X,J.filePath,$,Y)}}let[q,U]=i(Z,"exports");if(q!=null)W0(q,U,!1,(W,K)=>{if(typeof W!=="string")return;if(!W.startsWith("./")&&!W.startsWith("../"))return;if(W.includes("*"))return;if(s7(Y,W))return;let H=I0(Y,W);if(!p1(H))X.push(s(J.filePath,$,K.path,"publint/file-does-not-exist",`${Z0(K.path)} is "${W}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))});return X}};function _X($,J,Z,X,Y,z){if(s7(z,$))return;let Q=I0(z,$);if(!FX(Q))Z.push(s(X,Y,J,"publint/file-does-not-exist",`${Z0(J)} is "${$}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))}function FX($){if(p1($))return!0;if(p1(`${$}.js`))return!0;if(p1(`${$}/index.js`))return!0;return!1}import{existsSync as u2,readFileSync as m2}from"fs";import{extname as d2}from"path";var i7={meta:{docs:"Ensure file code format matches its extension and package type",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=x0(J.filePath),z=Z.type,[Q,G]=i(Z,"main");if(Q!=null&&typeof Q==="string")BX(Q,G,Y,z,X,J.filePath,$);let[q,U]=i(Z,"exports");if(q!=null)W0(q,U,!1,(W,K)=>{if(typeof W!=="string")return;if(!W.startsWith("./")&&!W.startsWith("../"))return;if(W.includes("*"))return;if(K.path.includes("browser"))return;BX(W,K.path,Y,z,X,J.filePath,$)});return X}};function BX($,J,Z,X,Y,z,Q){let G=I0(Z,$);if(!u2(G))return;if(!l0($))return;let q;try{q=m2(G,"utf8")}catch{return}let U=Y1(q);if(U==="unknown"||U==="mixed")return;let W=GX(G,X);if(U===W)return;let K=d2(G),H=qX(U),A=(UX(K)?"FILE_INVALID_EXPLICIT_FORMAT":"FILE_INVALID_FORMAT")==="FILE_INVALID_EXPLICIT_FORMAT"?`${Z0(J)} is "${$}" and ends with the ${K} extension, but the code is written in ${U}. Consider using the ${H} extension.`:`${Z0(J)} is "${$}" and is written in ${U}, but is interpreted as ${W}. Consider using the ${H} extension.`;Y.push(s(z,Q,J,"publint/file-invalid-format",A,"warning",`The file's code format (${U}) doesn't match the expected format (${W}) based on its extension and package type.`))}import{existsSync as o2,readFileSync as c2}from"fs";var t7={meta:{docs:'Ensure the "module" field points to an ESM file',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let[X,Y]=i(Z,"module");if(X==null||typeof X!=="string")return[];let z=x0(J.filePath),Q=I0(z,X);if(!o2(Q))return[];if(!l0(X))return[];let G;try{G=c2(Q,"utf8")}catch{return[]}if(Y1(G)==="CJS")return[s(J.filePath,$,Y,"publint/module-should-be-esm",`${Z0(Y)} 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 wX={name:"publint",rules:{"use-type":A0(r7),"local-dependency":A0(c7),"deprecated-field-jsnext":A0(v7),"has-module-but-no-exports":A0(h7),"field-invalid-value-type":A0(x7),"exports-types-should-be-first":A0(g7),"exports-default-should-be-last":A0(y7),"exports-module-should-precede-require":A0(f7),"exports-value-invalid":A0(p7),"exports-missing-root-entrypoint":A0(k7),"exports-fallback-array-use":A0(b7),"imports-key-invalid":A0(m7),"imports-value-invalid":A0(o7),"imports-default-should-be-last":A0(u7),"imports-module-should-precede-require":A0(d7),"file-does-not-exist":A0(n7),"file-invalid-format":A0(i7),"module-should-be-esm":A0(t7),"bin-file-not-executable":A0(l7),"exports-module-should-be-esm":A0(a7)}};var MX={meta:{docs:"Ensure all imports appear before other statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=0;for(let Q=0;Q<X.length;Q++){let G=X[Q].trim();if(!G||G.startsWith("//")||G.startsWith("/*")||G.startsWith("*"))continue;let q=G.match(/^\s*import\s+/);if(!q&&G.length>0){if(Y=!0,z===0)z=Q+1}if(Y&&q)Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"import/first",message:"Import statement must appear before other statements",severity:"error"})}return Z}};var jX={meta:{docs:"Disallow duplicate specifier names in a single import declaration"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.match(/^\s*import\s*\{([^}]*)\}\s*from\s*['"][^'"]+['"]/);if(!Q)continue;let q=Q[1].split(",").map((W)=>W.trim()).filter(Boolean).map((W)=>W.split(/\s+as\s+/i)[0].trim()),U=new Set;for(let W of q){if(U.has(W)){Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf(W)+1),ruleId:"pickier/import-dedupe",message:"Expect no duplication in imports",severity:"warning"});break}U.add(W)}}return Z}};import{existsSync as r2,readFileSync as l2}from"fs";import{dirname as a2,resolve as s2}from"path";var NX={meta:{docs:"Ensure named imports correspond to a named export in the remote file",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=a2(J.filePath);for(let z=0;z<X.length;z++){let G=X[z].match(/\bimport\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/);if(G){let q=G[1].split(",").map((H)=>H.trim().split(/\s+as\s+/)[0].trim()),U=G[2];if(!U.startsWith(".")&&!U.startsWith("/"))continue;let W=[".ts",".tsx",".js",".jsx",""],K="";for(let H of W){let V=s2(Y,U+H);if(r2(V)){K=l2(V,"utf8");break}}if(K)for(let H of q){let V=new RegExp(`\\bexport\\s+(?:const|let|var|function|class)\\s+${H}\\b`),A=new RegExp(`\\bexport\\s+\\{[^}]*\\b${H}\\b[^}]*\\}`);if(![V,A].some((F)=>F.test(K)))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"import/named",message:`'${H}' not found in '${U}'`,severity:"error"})}}}return Z}};import{existsSync as TX,readFileSync as n2}from"fs";import{dirname as EX,resolve as DX}from"path";var RX={meta:{docs:"Ensure imports don't create circular dependencies",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=J.filePath,z=new Set,Q=new Set;function G(U,W){if(Q.has(U))return!0;if(z.has(U))return!1;z.add(U),Q.add(U);try{let K=n2(U,"utf8"),H=q(K,EX(U));for(let V of H)if(G(V,[...W,V]))return!0}catch{}return Q.delete(U),!1}function q(U,W){let K=[],H=/\bimport(?:\s{2,}|\s+\S.*?(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))from\s+['"]([^'"]+)['"]/g,V;for(V=H.exec(U);V!==null;V=H.exec(U)){let A=V[1];if(A.startsWith(".")||A.startsWith("/")){let _=[".ts",".tsx",".js",".jsx",""];for(let B of _){let F=DX(W,A+B);if(TX(F)){K.push(F);break}}}}return K}for(let U=0;U<X.length;U++){let K=X[U].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(K){let H=K[1];if(H.startsWith(".")||H.startsWith("/")){let V=[".ts",".tsx",".js",".jsx",""],A="";for(let _ of V){let B=DX(EX(Y),H+_);if(TX(B)){A=B;break}}if(A){if(z.clear(),Q.clear(),Q.add(Y),G(A,[Y,A]))Z.push({filePath:J.filePath,line:U+1,column:1,ruleId:"import/no-cycle",message:"Dependency cycle detected",severity:"error"})}}}}return Z}};var OX={meta:{docs:"Disallow duplicate module imports - all imports from the same module should be combined"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map,z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(z){let V=G.indexOf("*/");if(V>=0)G=G.slice(V+2),z=!1;else continue}let q=G.indexOf("/*"),U=G.indexOf("//");if(q>=0&&(U===-1||q<U)){let V=G.indexOf("*/",q+2);if(V>=0)G=G.slice(0,q)+G.slice(V+2);else z=!0,G=G.slice(0,q)}if(U>=0)G=G.slice(0,U);let W=G.trim();if(!W)continue;let K=W.match(/^import\s+(?:type\s+)?(?:\{[^}]*\}|[\w$]+(?:\s*,\s*\{[^}]*\})?|\*\s+as\s+[\w$]+)\s+from\s+(['"`])(.+?)\1/);if(K){let V=K[2];if(Y.has(V)){let A=Y.get(V);Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"no-duplicate-imports",message:`'${V}' imported multiple times (also imported on line${A.length>1?"s":""} ${A.join(", ")})`,severity:"error",help:`Combine all imports from '${V}' into a single import statement`}),A.push(Q+1)}else Y.set(V,[Q+1])}let H=W.match(/^export\s+(?:type\s+)?(?:\{[^}]*\}|\*(?:\s+as\s+[\w$]+)?)\s+from\s+(['"`])(.+?)\1/);if(H){let V=H[2],A=`export:${V}`;if(Y.has(A)){let _=Y.get(A);Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"no-duplicate-imports",message:`'${V}' re-exported multiple times (also exported on line${_.length>1?"s":""} ${_.join(", ")})`,severity:"error",help:`Combine all re-exports from '${V}' into a single export statement`}),_.push(Q+1)}else Y.set(A,[Q+1])}}return Z}};var LX={meta:{docs:"Disallow importing from dist directories"},check:($,J)=>{let Z=[],X=new RegExp(`^\\s*import\\s[^;]*?from\\s*['"]([^'"]+)['"]`,"m"),Y=$.split(/\r?\n/);for(let z=0;z<Y.length;z++){let Q=Y[z],G=Q.match(X);if(!G)continue;let q=G[1];if(q==="dist"||(q.startsWith(".")||q.startsWith("/"))&&/(?:^|\/)dist(?:\/.|$)/.test(q))Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,Q.indexOf(q)+1),ruleId:"pickier/no-import-dist",message:`Do not import modules in \`dist\` folder, got ${q}`,severity:"error"})}return Z}};var PX={meta:{docs:"Disallow importing from node_modules by explicit path"},check:($,J)=>{let Z=[],X=new RegExp(`^\\s*import\\s[^;]*?from\\s*['"]([^'"]+)['"]`,"m"),Y=/require\(\s*['"]([^'"]+)['"]\s*\)/,z=$.split(/\r?\n/);for(let Q=0;Q<z.length;Q++){let G=z[Q],q=G.match(X),U=G.match(Y),W=q?.[1]||U?.[1];if(!W)continue;if(W.includes("/node_modules/")){let K=Math.max(1,G.indexOf(W)+1);Z.push({filePath:J.filePath,line:Q+1,column:K,ruleId:"pickier/no-import-node-modules-by-path",message:"Do not import modules in `node_modules` folder by path",severity:"error"})}}return Z}};import{existsSync as i2}from"fs";import{dirname as t2,join as e2,resolve as $G}from"path";var CX={meta:{docs:"Ensure imports point to a file/module that can be resolved",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=t2(J.filePath);for(let z=0;z<X.length;z++){let Q=X[z],G=[...Q.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),...Q.matchAll(/\bimport\s*\(\s*['"]([^'"]+)['"]\s*\)/g),...Q.matchAll(/\brequire\s*\(\s*['"]([^'"]+)['"]\s*\)/g)];for(let q of G){let U=q[1];if(!U.startsWith(".")&&!U.startsWith("/"))continue;let W=[],K=[".ts",".tsx",".js",".jsx",".mjs",".cjs",""];for(let V of K){let A=$G(Y,U+V);W.push(A),W.push(e2(A,`index${V}`))}if(!W.some((V)=>i2(V)))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"import/no-unresolved",message:`Unable to resolve path to module '${U}'`,severity:"error"})}}return Z}};function IX($,J,Z){let X=Z.order==="desc"?-1:1,Y=Z.type||"alphabetical",z=Z.ignoreCase?$.toLowerCase():$,Q=Z.ignoreCase?J.toLowerCase():J;if(Y==="line-length")return(z.length-Q.length)*X;if(Y==="natural")return z.localeCompare(Q,void 0,{numeric:!0,sensitivity:"base"})*X;if(Y==="unsorted")return 0;return z.localeCompare(Q)*X}var ZG=new RegExp(`^export\\s+\\{[^}]*\\}\\s+from\\s+['"][^'"]+['"];?\\s*$`);function S8($){return ZG.test($)}var SX={meta:{docs:"Ensure contiguous export statements are sorted consistently."},check:($,J)=>{let Z=[],X=J.config.pluginRules?.["pickier/sort-exports"]?.[1]||{},Y=$.split(/\r?\n/),z=0;while(z<Y.length){while(z<Y.length&&!S8(Y[z]))z++;if(z>=Y.length)break;let Q=[],G=z;while(G<Y.length){let q=Y[G];if(S8(q)){Q.push({idx:G,line:q}),G++;continue}if(X.partitionByNewLine&&q.trim()==="")break;else break}if(Q.length>1){let q=Q.map((K)=>K.line),U=[...q].sort((K,H)=>IX(K,H,X));if(!q.every((K,H)=>K===U[H])){let K=q.findIndex((V,A)=>V!==U[A]),H=Q[K]?.idx??Q[0].idx;Z.push({filePath:J.filePath,line:H+1,column:1,ruleId:"pickier/sort-exports",message:"Export statements are not sorted.",severity:"warning"})}}z=G+1}return Z},fix:($,J)=>{let Z=J.config.pluginRules?.["pickier/sort-exports"]?.[1]||{},Y=[...$.split(/\r?\n/)],z=0;while(z<Y.length){while(z<Y.length&&!S8(Y[z]))z++;if(z>=Y.length)break;let Q=[],G=z;while(G<Y.length){let q=Y[G];if(S8(q)){Q.push(G),G++;continue}if(Z.partitionByNewLine&&q.trim()==="")break;else break}if(Q.length>1){let q=Q.map((K)=>Y[K]),U=[...q].sort((K,H)=>IX(K,H,Z));if(!q.every((K,H)=>K===U[H]))Q.forEach((K,H)=>{Y[K]=U[H]})}z=G+1}return Y.join(`
130
+ `)}};var vX={meta:{docs:"Enforce sorted TypeScript heritage clauses (extends/implements lists)"},check:($,J)=>{let Z=J.options||{},X=Z.type||"alphabetical",Y=Z.order||"asc",z=Z.ignoreCase!==!1,Q=Array.isArray(Z.groups)?Z.groups:[],G=Z.customGroups||{},q=$.split(/\r?\n/),U=[],W=(E)=>Y==="asc"?E:-E,K=(E,j)=>(z?E.toLowerCase():E).localeCompare(z?j.toLowerCase():j),H=(E,j)=>(z?E.toLowerCase():E).localeCompare(z?j.toLowerCase():j,void 0,{numeric:!0}),V=(E,j)=>{if(X==="line-length")return W(E.length-j.length);if(X==="natural")return W(H(E,j));if(X==="unsorted")return 0;return W(K(E,j))},A=Object.fromEntries(Object.entries(G).map(([E,j])=>{let v=(Array.isArray(j)?j:[j]).map((y)=>new RegExp(y));return[E,v]})),_=[];for(let E of Q)if(Array.isArray(E))_.push(...E);else _.push(E);if(!_.includes("unknown"))_.push("unknown");let B=(E)=>{for(let[j,O]of Object.entries(A))if(O.some((v)=>v.test(E)))return j;return"unknown"},F=(E)=>{let j=[],O=0,v="";for(let y=0;y<E.length;y++){let C=E[y];if(C==="<")O++;else if(C===">")O=Math.max(0,O-1);if(C===","&&O===0){j.push(v.trim()),v="";continue}v+=C}if(v.trim())j.push(v.trim());return j},M=(E)=>{let j=E.trim(),O=j.match(/^([A-Z_$][\w$.]*)/i);return O?O[1]:j},T=(E,j)=>{let O=F(j);if(O.length<=1)return;let v=O.map(M),y=v.map(B),C=v.map((P,L)=>({n:P,g:y[L],i:L})).sort((P,L)=>{let I=_.indexOf(P.g),f=_.indexOf(L.g);if(I!==f)return I-f;return V(P.n,L.n)}).map((P)=>P.n);if(!v.every((P,L)=>P===C[L]))U.push({filePath:J.filePath,line:E,column:1,ruleId:"sort-heritage-clauses",message:"Heritage clauses are not sorted",severity:"warning"})};for(let E=0;E<q.length;E++){let j=q[E],O=j.match(/^\s*interface\s+[A-Za-z_$][^{]*\bextends\s+(.+?)\s*\{/);if(O)T(E+1,O[1]);let v=j.match(/^\s*class\s+[A-Za-z_$][^{]*\bimplements\s+(.+?)\s*\{/);if(v)T(E+1,v[1])}return U}};var yX={meta:{docs:"Require object keys to be sorted (ESLint-compatible core rule subset)"},check:()=>{return[]}};var bX={meta:{docs:"Enforce sorted named imports within each import statement"},check:($,J)=>{let Z=J.options||{},X=Z.type||"alphabetical",Y=Z.order||"asc",z=Z.ignoreCase!==!1,Q=Boolean(Z.ignoreAlias),G=$.split(/\r?\n/),q=[],U=(W,K)=>{let H=0;if(X==="line-length")H=W.length-K.length;else{let V=z?W.toLowerCase():W,A=z?K.toLowerCase():K;H=V.localeCompare(A)}return Y==="asc"?H:-H};for(let W=0;W<G.length;W++){let H=G[W].match(/^\s*import\s+\{([^}]*)\}\s+from\s+['"][^'"]+['"]/);if(!H)continue;let A=H[1].split(",").map((M)=>M.trim()).filter(Boolean);if(A.length<=1)continue;let _=A.map((M)=>{let T=M.replace(/^type\s+/,""),E=T.match(/^([\w$]+)\s+as\s+([\w$]+)$/);if(E)return Q?E[2]:E[1];let j=T.match(/^([\w$]+)$/);return j?j[1]:T}),B=[..._].sort(U);if(!_.every((M,T)=>M===B[T]))q.push({filePath:J.filePath,line:W+1,column:1,ruleId:"sort-named-imports",message:"Named imports are not sorted",severity:"warning"})}return q}};var kX={meta:{docs:"Enforce sorted object keys"},check:($,J)=>{let Z=J.options||{},X=Z.type||"alphabetical",Y=Z.order||"asc",z=Z.ignoreCase!==!1,Q=Boolean(Z.partitionByNewLine),G=$.split(/\r?\n/),q=[],U=(K,H)=>{let V=0;if(X==="line-length")V=K.length-H.length;else{let A=z?K.toLowerCase():K,_=z?H.toLowerCase():H;V=A.localeCompare(_)}return Y==="asc"?V:-V},W=0;while(W<G.length){let K=G[W],H=K.indexOf("{");if(H!==-1){let V=K.slice(0,H);if(/=\s*$|\(\s*$|\breturn\s*$/.test(V)){let A=0,_=W,B=W;for(;B<G.length;B++){for(let F of G[B])if(F==="{")A++;else if(F==="}")A--;if(A===0)break}if(B>_){let F=G.slice(_+1,B),M=[],T={startLine:_+2,props:[]},E=()=>{if(T.props.length)M.push(T);T={startLine:0,props:[]}};for(let j=0;j<F.length;j++){let O=F[j];if(Q&&/^\s*$/.test(O)){E();continue}if(/^\s*\.\.\./.test(O))continue;if(/\{|\}/.test(O))continue;let v=O.match(/^\s*['"]?([\w$-]+)['"]?\s*:/);if(v){if(T.startLine===0)T.startLine=_+2+j;T.props.push({key:v[1],line:_+2+j})}}E();for(let j of M){let O=j.props.map((C)=>C.key),v=[...O].sort(U);if(!(O.length<=1||O.every((C,k)=>C===v[k]))&&j.props.length>0){let C=j.props[0];q.push({filePath:J.filePath,line:C.line,column:1,ruleId:"sort-objects",message:"Object keys are not sorted",severity:"warning"})}}W=B+1;continue}}}W++}return q}};var fX={meta:{docs:"Enforce top-level functions to use function declarations"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/^\s+/.test(z))continue;if(/^\s*(?:\/\/|\/\*)/.test(z))continue;let Q=z.match(/^const\s+([A-Za-z_$][\w$]*)\s*=(.*)$/);if(!Q)continue;let G=Q[2].trim();if(/^\(?[A-Z_$,]*(?:\)\s*)?=>/i.test(G)||/^function\b/.test(G)){let q=z.indexOf("const")+1;Z.push({filePath:J.filePath,line:Y+1,column:q,ruleId:"pickier/top-level-function",message:"Top-level functions should be declared with function keyword",severity:"warning"});continue}if(G.trim().length===0||/[,({]$/.test(G.trim())){let q=X[Y+1]||"";if(/^\s*(?:\(?[A-Za-z_$,]*(?:\)\s*)?=>|function\b)/.test(q)){let U=z.indexOf("const")+1;Z.push({filePath:J.filePath,line:Y+1,column:U,ruleId:"pickier/top-level-function",message:"Top-level functions should be declared with function keyword",severity:"warning"})}}}return Z}};var JG=[[/^(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]],XG=/^([a-z0-9][-a-z0-9]{0,50}:)+(?!\[)/;function YG($){let J=0;while(J<$.length){if($[J]==="[")break;let Z=$.indexOf(":",J);if(Z===-1)break;if($[Z+1]==="[")break;J=Z+1}return $.slice(J)}function zG($){let J=YG($);if(J.startsWith("!"))J=J.slice(1);for(let[Z,X]of JG)if(Z.test(J))return X;return 99}function QG($){let J=$.match(XG);if(!J)return 0;let Z=J[0].slice(0,-1).split(":"),X={sm:1,md:2,lg:3,xl:4,"2xl":5},Y=10;for(let z of Z)if(X[z]!==void 0)Y+=X[z];else Y+=20;return Y}var gX=new Map;function pX($){let J=gX.get($);if(J)return J;let Z={group:zG($),variant:QG($)};return gX.set($,Z),Z}function e7($){return[...$].sort((J,Z)=>{let X=pX(J),Y=pX(Z),z=X.group,Q=Y.group;if(z!==Q)return z-Q;let G=X.variant,q=Y.variant;if(G!==q)return G-q;return J.localeCompare(Z)})}var GG=/\b(?:class|className|:class)\s*=\s*(?:"([^"]*?)"|'([^']*?)')/g,qG=/\b(?:class|className|:class)\s*=\s*\{`([^`]*?)`\}/g,UG=/\b(?:clsx|cn|tw|cva|tv)\s*\(\s*(?:"([^"]*?)"|'([^']*?)')/g;function WG($){let J=$.replace(/\[[^\]]*\]/g,"");if(/['"`]/.test(J))return!0;if(/[{}()=]/.test(J))return!0;if(/ \? | && | \|\| /.test(J))return!0;if(/\b(?:true|false|null|undefined|function|return|typeof|instanceof)\b/.test(J))return!0;return!1}function xX($){let J=[];if(!$.includes("class")&&!$.includes("clsx")&&!$.includes("cn(")&&!$.includes("tw(")&&!$.includes("cva(")&&!$.includes("tv("))return J;for(let Z of[GG,qG,UG]){Z.lastIndex=0;let X;while((X=Z.exec($))!==null){let Y=X[1]??X[2]??"";if(!Y.trim())continue;if(WG(Y))continue;let z=$.indexOf(Y,X.index);if(z===-1)continue;J.push({value:Y,start:z,end:z+Y.length})}}return J.sort((Z,X)=>Z.start-X.start),J}function hX($){let J=[],Z="",X=0;for(let Y of $)if(Y==="[")X++,Z+=Y;else if(Y==="]")X=Math.max(0,X-1),Z+=Y;else if(/\s/.test(Y)&&X===0){if(Z)J.push(Z),Z=""}else Z+=Y;if(Z)J.push(Z);return J}function uX($){let J=e7($);return $.every((Z,X)=>Z===J[X])}var mX={meta:{docs:"Enforce consistent Tailwind CSS class ordering (layout \u2192 spacing \u2192 typography \u2192 etc.).",recommended:!0,editsStringContent:!0},check:($,J)=>{let Z=[],X=xX($);for(let{value:Y,start:z}of X){let Q=hX(Y);if(Q.length<2)continue;if(!uX(Q)){let G=$.slice(0,z),q=(G.match(/\n/g)??[]).length+1,U=G.lastIndexOf(`
131
+ `),W=U===-1?z+1:z-U;Z.push({filePath:J.filePath,line:q,column:W,ruleId:"pickier/sort-tailwind-classes",message:`Tailwind classes are not in the recommended order. Expected: "${e7(Q).join(" ")}"`,severity:"warning",help:"Run with --fix to automatically sort Tailwind classes, or reorder them manually."})}}return Z},fix:($)=>{let J=xX($);if(J.length===0)return $;let Z=[...J].reverse(),X=$;for(let{value:Y,start:z,end:Q}of Z){let G=hX(Y);if(G.length<2||uX(G))continue;let q=e7(G).join(" ");X=X.slice(0,z)+q+X.slice(Q)}return X}};var dX={name:"pickier",rules:{"sort-exports":w(SX),"sort-objects":w(kX),"sort-imports":w(I8),"sort-named-imports":w(bX),"sort-heritage-clauses":w(vX),"sort-keys":w(yX),"import-dedupe":w(jX),"import-first":w(MX),"import-named":w(NX),"import-no-cycle":w(RX),"import-no-unresolved":w(CX),"no-import-dist":w(LX),"no-import-node-modules-by-path":w(PX),"no-duplicate-imports":w(OX),"top-level-function":w(fX),"sort-tailwind-classes":mX,"prefer-const":w(L8),"prefer-template":w(P8),"no-unused-vars":w(n0)}};var oX={name:"quality",rules:{"default-case":w(o$),eqeqeq:w(c$),"no-alert":w(a$),"no-await-in-loop":w(s$),"no-caller":w(n$),"no-case-declarations":w(i$),"no-else-return":w(t$),"no-empty":w(e$),"no-empty-function":w($8),"no-eval":w(Z8),"no-extend-native":w(J8),"no-global-assign":w(Y8),"no-implied-eval":w(z8),"no-iterator":w(Q8),"no-new":w(G8),"no-new-func":w(q8),"no-new-wrappers":w(U8),"no-octal":w(W8),"no-param-reassign":w(K8),"no-proto":w(H8),"no-return-assign":w(V8),"no-shadow":w(_8),"no-throw-literal":w(F8),"no-use-before-define":w(B8),"no-useless-call":w(w8),"no-with":w(E8),"require-await":w(R8),complexity:w(d$),"max-depth":w(r$),"max-lines-per-function":w(l$),"no-extra-boolean-cast":w(X8),"no-lonely-if":w(k1),"no-sequences":w(A8),"no-useless-concat":w(M8),"no-useless-escape":w(j8),"no-useless-rename":w(N8),"no-useless-return":w(f1),"no-var":w(T8),"prefer-arrow-callback":w(D8)}};var cX={meta:{docs:"Detects potentially super-linear backtracking patterns in regex literals (heuristic)"},check:($,J)=>{let Z=[],X=/\/[^/\\\n]*(?:\\.[^/\\\n]*)*\//g,Y=(K,H,V)=>{let A=$.slice(0,K),_=(A.match(/\n/g)||[]).length+1,B=K-A.lastIndexOf(`
132
+ `);Z.push({filePath:J.filePath,line:_,column:B,ruleId:"no-super-linear-backtracking",message:V,severity:"error"})},z=[],Q=/\/\*[\s\S]*?\*\//g,G;while(G=Q.exec($))z.push({start:G.index,end:G.index+G[0].length});let q=/\/\/[^\n]*/g,U;while(U=q.exec($))z.push({start:U.index,end:U.index+U[0].length});let W;while(W=X.exec($)){let K=W[0],H=W.index;if(z.some((F)=>H>=F.start&&H<F.end))continue;if(H>0){let F=$[H-1];if(F===")"||F==="]"||F==="."||/[\w$]/.test(F))continue;let M=K.slice(1,K.lastIndexOf("/"));if(/^\s+\w/.test(M)&&/\w\s*\)/.test(M))continue}let A=K.slice(1,K.lastIndexOf("/")).replace(/\[.*?\]/g,"");if(A.includes(".+?\\s*")||A.includes("\\s*.+?")||A.includes(".*\\s*")||A.includes("\\s*.*")){Y(H,K.length,"The combination of ' .*' or ' .+?' with '\\s*' can cause super-linear backtracking due to exchangeable characters");continue}let B=A.replace(/\s+/g,"");if(/(?:\.\*\??){2,}/.test(B)||/(?:\.\+\??){2,}/.test(B)||/\.\*\??\.\+\?|\.\+\??\.\*\?/.test(B)){Y(H,K.length,"Multiple adjacent unlimited wildcard quantifiers can cause super-linear backtracking");continue}if(/\((?:\?:)?[^)]*?[+*][^)]*\)\s*[+*]/.test(A.replace(/\\[()]/g,"_"))){Y(H,K.length,"Nested unlimited quantifiers detected (e.g., (.+)+) which can cause catastrophic backtracking");continue}}return Z}};function KG($,J){let Z=J-1;while(Z>=0&&($[Z]===" "||$[Z]==="\t"))Z--;let X=Z>=0?$[Z]:"",Y="=(<>!&|?:;,{[+(~^%*/";if(!(Z<0||Y.includes(X)||/\b(?:return|typeof|void|delete|throw|new|in|of|case)\s*$/.test($.slice(Math.max(0,Z-5),Z+1))))return null;let Q=J+1,G=!1,q=!1,U=-1;while(Q<$.length){let _=$[Q];if(q)q=!1;else if(_==="\\")q=!0;else if(_==="["){if(!G)G=!0}else if(_==="]"){if(G)G=!1}else if(_==="/"&&!G){U=Q;break}else if(_===`
133
+ `)break;Q++}if(U<=J)return null;let W=$.slice(J+1,U),K=U+1;while(K<$.length&&/[gimsuvy]/.test($[K]))K++;if(/\\[1-9]/.test(W))return null;let H=0,V=-1,A=!1;for(let _=0;_<W.length;_++){if(W[_]==="\\"){_++;continue}if(W[_]==="["&&!A){A=!0;continue}if(W[_]==="]"&&A){A=!1;continue}if(A)continue;if(W[_]==="("&&W.slice(_+1,_+3)!=="?:"&&W.slice(_+1,_+3)!=="?="&&W.slice(_+1,_+3)!=="?!"&&W.slice(_+1,_+4)!=="?<="&&W.slice(_+1,_+4)!=="?<!"){if(V<0)V=_;H++}}if(H===0)return null;return{patternStart:J,patternEnd:K,pattern:W,capCount:H,firstCapOffset:V}}function HG($,J,Z){let X=Z;while(X<$.length&&($[X]===" "||$[X]==="\t"))X++;if($[X]==="."){let q=$.slice(X+1,X+20);if(/^test\s*\(/.test(q))return!1;if(/^exec\s*\(/.test(q))return!0}let Y=J-1;while(Y>=0&&($[Y]===" "||$[Y]==="\t"))Y--;if($[Y]==="("){let U=Y-1;while(U>=0&&($[U]===" "||$[U]==="\t"))U--;let W=$.slice(Math.max(0,U-20),U+1);if(/\.match\s*$/.test(W))return!0;if(/\.matchAll\s*$/.test(W))return!0;if(/\.exec\s*$/.test(W))return!0;if(/\.replace\s*$/.test(W))return!0;if(/\.replaceAll\s*$/.test(W))return!0;if(/\.split\s*$/.test(W))return!0;if(/\.search\s*$/.test(W))return!1;if(/\.test\s*$/.test(W))return!1}let z=$.lastIndexOf(`
134
+ `,J)+1,G=$.slice(z,J).trim().match(/(?:const|let|var)\s+(\w+)\s*=\s*$/);if(G){let q=G[1],U=$.slice(Z),W=new RegExp(`\\b${q}\\.exec\\s*\\(`),K=new RegExp(`\\b${q}\\.test\\s*\\(`),H=new RegExp(`\\.match(?:All)?\\s*\\(\\s*${q}\\s*\\)`),V=new RegExp(`\\.replace(?:All)?\\s*\\(\\s*${q}`),A=W.test(U),_=H.test(U),B=V.test(U),F=K.test(U);if(A||_||B)return!0;if(F)return!1;return!0}return!0}function VG($,J){let Z=J-1;while(Z>=0&&($[Z]===" "||$[Z]==="\t"))Z--;let X=Z>=0?$[Z]:"",Y="=(<>!&|?:;,{[+(~^%*/";if(!(Z<0||Y.includes(X)||/\b(?:return|typeof|void|delete|throw|new|in|of|case)\s*$/.test($.slice(Math.max(0,Z-5),Z+1))))return J+1;let Q=J+1,G=!1,q=!1;while(Q<$.length){let U=$[Q];if(q)q=!1;else if(U==="\\")q=!0;else if(U==="["){if(!G)G=!0}else if(U==="]"){if(G)G=!1}else if(U==="/"&&!G){Q++;while(Q<$.length&&/[gimsuvy]/.test($[Q]))Q++;return Q}else if(U===`
135
+ `)break;Q++}return J+1}function AG($,J){let Z=[],X=J.filePath,Y=0;while(Y<$.length){let z=$[Y];if(z==="/"&&$[Y+1]==="/"){while(Y<$.length&&$[Y]!==`
136
+ `)Y++;continue}if(z==="/"&&$[Y+1]==="*"){Y+=2;while(Y<$.length-1&&!($[Y]==="*"&&$[Y+1]==="/"))Y++;Y+=2;continue}if(z==="'"||z==='"'||z==="`"){let Q=z;Y++;while(Y<$.length){if($[Y]==="\\"){Y+=2;continue}if($[Y]===Q){Y++;break}Y++}continue}if(z==="/"){let Q=KG($,Y);if(!Q){let G=VG($,Y);if(G>Y+1)Y=G;else Y++;continue}if(!HG($,Q.patternStart,Q.patternEnd)){let G=Q.patternStart+1+(Q.firstCapOffset>=0?Q.firstCapOffset:0),q=$.slice(0,G),U=(q.match(/\r?\n/g)||[]).length+1,W=G-(q.lastIndexOf(`
137
+ `)+1)+1;Z.push({filePath:X,line:U,column:W,ruleId:"regexp/no-unused-capturing-group",message:"Unused capturing group in regular expression; use non-capturing group (?:...) instead",severity:"error"})}Y=Q.patternEnd;continue}Y++}return Z}var rX={meta:{docs:"Flags regex literals with unused capturing groups (context-aware)",recommended:!1},check($,J){return AG($,J)}};var lX={meta:{docs:"Disallow lazy quantifiers that don't affect the matching behavior",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(z.trim().startsWith("//")||z.trim().startsWith("/*")||z.trim().startsWith("*"))continue;let Q=/\/(?![/*])([^/\n\r\\]|\\.)+\/[gimsuvy]*/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[0],U=q.slice(1,q.lastIndexOf("/"));if(/[+*?]\?\$$/.test(U))Z.push({filePath:J.filePath,line:Y+1,column:G.index+U.search(/[+*?]\?\$$/)+2,ruleId:"regexp/no-useless-lazy",message:"Lazy quantifier is useless before end-of-string anchor",severity:"error"});if(/[+*?]\?$/.test(U))Z.push({filePath:J.filePath,line:Y+1,column:G.index+U.length-1,ruleId:"regexp/no-useless-lazy",message:"Lazy quantifier is useless at the end of the pattern",severity:"error"})}}return Z}};var aX={name:"regexp",rules:{"no-super-linear-backtracking":w(cX),"no-unused-capturing-group":w(rX),"no-useless-lazy":w(lX)}};var sX={meta:{docs:"Use $() instead of backticks for command substitution",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="",Q=!1;for(let G=0;G<X.length;G++){let q=X[G];if(Y){if(q.trim()===z)Y=!1;continue}let U=q.match(/<<-?\s*['"]?(\w+)['"]?/);if(U)Y=!0,z=U[1];if(q.replace(/^\s+/,"").startsWith("#"))continue;Q=!1;for(let K=0;K<q.length;K++){let H=q[K];if(H==="#"&&!Q)break;if(H==="\\"){K++;continue}if(H==="'"){Q=!Q;continue}if(Q)continue;if(H==="`"){Z.push({filePath:J.filePath,line:G+1,column:K+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(K++;K<q.length&&q[K]!=="`";K++)if(q[K]==="\\")K++}}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[],Y=!1,z="";for(let Q of Z){if(Y){if(X.push(Q),Q.trim()===z)Y=!1;continue}let G=Q.match(/<<-?\s*['"]?(\w+)['"]?/);if(G)Y=!0,z=G[1];let q="",U=!1,W=0;while(W<Q.length){let K=Q[W];if(K==="#"&&!U){q+=Q.slice(W);break}if(K==="\\"){q+=Q.slice(W,W+2),W+=2;continue}if(K==="'"){U=!U,q+=K,W++;continue}if(U){q+=K,W++;continue}if(K==="`"){let H="";W++;while(W<Q.length&&Q[W]!=="`")if(Q[W]==="\\")H+=Q[W+1]||"",W+=2;else H+=Q[W],W++;W++,q+=`$(${H})`}else q+=K,W++}X.push(q)}return X.join(`
138
+ `)}};var nX={meta:{docs:"Require error handling after cd commands",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=G.match(/<<-?\s*['"]?(\w+)['"]?/);if(q)Y=!0,z=q[1];let U=G.replace(/^\s+/,"");if(U.startsWith("#"))continue;let W=U.match(/^cd\s+/);if(!W)continue;let K=/\|\||&&/.test(G),H=/^\s*(?:if|elif|while|until)\s/.test(U)||/\bif\s+cd\b/.test(G),V=/\(.*\bcd\b.*\)/.test(G);if(!K&&!H&&!V)Z.push({filePath:J.filePath,line:Q+1,column:W.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 Z}};var iX={meta:{docs:"Disallow use of eval in shell scripts",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=G.match(/<<-?\s*['"]?(\w+)['"]?/);if(q)Y=!0,z=q[1];if(G.replace(/^\s+/,"").startsWith("#"))continue;if(G.match(/(?:^|[;&|]\s*|^\s+)eval\s/)){let K=G.indexOf("eval");Z.push({filePath:J.filePath,line:Q+1,column:K+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 Z}};var tX={meta:{docs:"Flag exit inside subshells where it only exits the subshell",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="",Q=0;for(let G=0;G<X.length;G++){let q=X[G];if(Y){if(q.trim()===z)Y=!1;continue}let U=q.match(/<<-?\s*['"]?(\w+)['"]?/);if(U)Y=!0,z=U[1];if(q.replace(/^\s+/,"").startsWith("#"))continue;let K=!1,H=!1;for(let V=0;V<q.length;V++){let A=q[V];if(A==="#"&&!K&&!H)break;if(A==="\\"&&!K){V++;continue}if(A==="'"&&!H){K=!K;continue}if(A==='"'&&!K){H=!H;continue}if(!K&&!H){if(A==="("&&V>0&&q[V-1]!=="$"&&q[V+1]!=="(")Q++;else if(A==="("&&V===0&&q[V+1]!=="(")Q++;else if(A===")"&&Q>0&&(V+1>=q.length||q[V+1]!==")"))Q--}}if(Q>0){let V=q.match(/\bexit\b/);if(V)Z.push({filePath:J.filePath,line:G+1,column:V.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(Q===0){let V=q.match(/(?<!\$)\((?!\()([^)]*\bexit\b[^)]*)\)(?!\))/);if(V){let A=q.indexOf("exit",V.index);Z.push({filePath:J.filePath,line:G+1,column:A+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 Z}};var eX={meta:{docs:"Disallow parsing ls output \u2014 use globs or find instead",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=G.match(/<<-?\s*['"]?(\w+)['"]?/);if(q)Y=!0,z=q[1];if(G.replace(/^\s+/,"").startsWith("#"))continue;if(G.match(/\bls\b[^|]*\|/)){let V=G.indexOf("ls");Z.push({filePath:J.filePath,line:Q+1,column:V+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 K=G.match(/\$\(\s*ls\b/);if(K){let V=K.index+1;Z.push({filePath:J.filePath,line:Q+1,column:V,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 H=G.match(/`\s*ls\b/);if(H){let V=H.index+1;Z.push({filePath:J.filePath,line:Q+1,column:V,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 Z}};var $5={meta:{docs:"Detect useless use of cat (UUOC)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=G.match(/<<-?\s*['"]?(\w+)['"]?/);if(q)Y=!0,z=q[1];if(G.replace(/^\s+/,"").startsWith("#"))continue;let W=G.match(/\bcat\s+(["']?[\w.\/~${}*?-]+["']?)\s*\|/);if(W){let K=G.indexOf("cat");Z.push({filePath:J.filePath,line:Q+1,column:K+1,ruleId:"shell/no-useless-cat",message:`Useless use of cat \u2014 pipe the file directly instead of \`cat ${W[1]} | ...\``,severity:"warning",help:`Use \`cmd < ${W[1]}\` or pass the file as an argument to the command`})}}return Z}};var Z5={meta:{docs:"Flag variables inside single quotes where they won't expand",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=G.match(/<<-?\s*['"]?(\w+)['"]?/);if(q)Y=!0,z=q[1];if(G.replace(/^\s+/,"").startsWith("#"))continue;let W=!1,K=!1,H=-1;for(let V=0;V<G.length;V++){let A=G[V];if(A==="#"&&!W&&!K)break;if(A==="\\"&&!W){V++;continue}if(A==='"'&&!W){K=!K;continue}if(A==="'"&&!K)if(!W)W=!0,H=V;else{let B=G.slice(H+1,V).match(/\$(?:[A-Za-z_]\w*|\{[^}]+\}|\([^)]*\))/);if(B)Z.push({filePath:J.filePath,line:Q+1,column:H+1+B.index+1,ruleId:"shell/no-variable-in-single-quotes",message:`Variable ${B[0]} is inside single quotes and won't be expanded`,severity:"warning",help:`Use double quotes if you want variable expansion: "..." instead of '...'`});W=!1}}}return Z}};var _G=[/^\s*(?:local|export|declare|typeset|readonly)\s+/,/\[\[.*\]\]/,/\(\(.*\)\)/],$9=/^\$(?:\{[A-Za-z_]\w*(?:[:#%\/][^}]*)?\}|[A-Za-z_]\w*)/,J5={meta:{docs:"Quote variable expansions to prevent word splitting and globbing",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=P0(G);if(q){if(Y=!0,z=q,new RegExp(`<<-?\\s*['"]${q}['"]`).test(G))continue}if(G.replace(/^\s+/,"").startsWith("#"))continue;if(_G.some((H)=>H.test(G)))continue;let W=[],K=0;while(K<G.length){let H=W[W.length-1];if(H==="squote"){if(G[K]==="'")W.pop();K++;continue}if(G[K]==="\\"&&K+1<G.length){K+=2;continue}if(H==="dquote"){let A=G[K];if(A==='"'){W.pop(),K++;continue}if(A==="$"&&G[K+1]==="("&&G[K+2]==="("){W.push("arith"),K+=3;continue}if(A==="$"&&G[K+1]==="("){W.push("subshell"),K+=2;continue}if(A==="$"){let _=G.slice(K).match($9);if(_){K+=_[0].length;continue}}K++;continue}if(H==="arith"){let A=G[K];if(A===")"&&G[K+1]===")"){W.pop(),K+=2;continue}if(A==="$"){let _=G.slice(K).match($9);if(_){K+=_[0].length;continue}}K++;continue}let V=G[K];if(V==="#"&&(K===0||/\s/.test(G[K-1])))break;if(V==="'"){W.push("squote"),K++;continue}if(V==='"'){W.push("dquote"),K++;continue}if(V==="$"&&G[K+1]==="("&&G[K+2]==="("){W.push("arith"),K+=3;continue}if(V==="$"&&G[K+1]==="("){W.push("subshell"),K+=2;continue}if(V===")"&&H==="subshell"){W.pop(),K++;continue}if(V==="$"){let A=G.slice(K).match($9);if(A){let _=A[0];if(!/^\$[?!#@*0-9-]/.test(_))Z.push({filePath:J.filePath,line:Q+1,column:K+1,ruleId:"shell/quote-variables",message:`Unquoted variable ${_} \u2014 use "${_}" to prevent word splitting`,severity:"warning",help:`Wrap in double quotes: "${_}"`});K+=_.length;continue}}K++}}return Z}};var X5={meta:{docs:"Enforce consistent function declaration style",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=G.match(/<<-?\s*['"]?(\w+)['"]?/);if(q)Y=!0,z=q[1];let U=G.replace(/^\s+/,"");if(U.startsWith("#"))continue;let W=U.match(/^function\s+(\w+)\s*(?:\(\s*\))?\s*\{?\s*$/);if(W){let K=W[1],H=G.indexOf("function");Z.push({filePath:J.filePath,line:Q+1,column:H+1,ruleId:"shell/function-style",message:`Use \`${K}() {\` instead of \`function ${K}\` \u2014 POSIX-compatible style`,severity:"warning",help:`Replace with: ${K}() {`})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X.match(/^(\s*)function\s+(\w+)\s*(?:\(\s*\))?\s*(\{?\s*)$/);if(Y){let[,z,Q,G]=Y;Z.push(`${z}${Q}() ${G||"{"}`)}else Z.push(X)}return Z.join(`
139
+ `)}};function Y5($,J){if(/^then\b/.test($)||/^do\b/.test($)||/^else\b/.test($))return!0;if(/^if\b/.test($)&&/\bthen\s*$/.test($))return!0;if(/^elif\b/.test($)&&/\bthen\s*$/.test($))return!0;if(/^(?:while|for|until)\b/.test($)&&/\bdo\s*$/.test($))return!0;if(/^case\b/.test($)&&/\bin\s*$/.test($))return!0;if(J&&/\)\s*$/.test($)&&!/\$\(/.test($)&&!/^\s*\(/.test($)&&!$.startsWith("#"))return!0;if(/\{\s*$/.test($)&&!$.startsWith("#"))return!0;return!1}function z5($){return/^(?:fi|done|esac|elif|else)\b/.test($)||/^\}/.test($)||/^;[;&]\s*$/.test($)}var Q5={meta:{docs:"Enforce consistent indentation in shell scripts",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=J.config.format.indent||2,z=0,Q=!1,G="",q=!1,U=0;for(let W=0;W<X.length;W++){let K=X[W];if(/^\s*$/.test(K))continue;if(Q){if(K.trim()===G)Q=!1;continue}let H=K.match(/<<-?\s*['"]?(\w+)['"]?/);if(H)Q=!0,G=H[1];let V=K.replace(/^\s+/,"");if(W===0&&V.startsWith("#!"))continue;if(/^case\b/.test(V)&&/\bin\s*$/.test(V))U++,q=!0;if(/^esac\b/.test(V)){if(U=Math.max(0,U-1),U===0)q=!1}if(z5(V))z=Math.max(0,z-1);let A=0;for(let B=0;B<K.length;B++)if(K[B]===" ")A++;else if(K[B]==="\t")A+=Y;else break;let _=z*Y;if(A!==_&&!V.startsWith("#"))Z.push({filePath:J.filePath,line:W+1,column:1,ruleId:"shell/indent",message:`Expected ${_} spaces of indentation, found ${A}`,severity:"warning"});if(Y5(V,q))z++}return Z},fix($,J){let Z=$.split(/\r?\n/),X=J.config.format.indent||2,Y=J.config.format.indentStyle==="tabs",z=[],Q=0,G=!1,q="",U=!1,W=0;for(let K=0;K<Z.length;K++){let H=Z[K];if(/^\s*$/.test(H)){z.push("");continue}if(G){if(z.push(H),H.trim()===q)G=!1;continue}let V=H.match(/<<-?\s*['"]?(\w+)['"]?/);if(V)G=!0,q=V[1];let A=H.replace(/^\s+/,"").trimEnd();if(K===0&&A.startsWith("#!")){z.push(A);continue}if(/^case\b/.test(A)&&/\bin\s*$/.test(A))W++,U=!0;if(/^esac\b/.test(A)){if(W=Math.max(0,W-1),W===0)U=!1}if(z5(A))Q=Math.max(0,Q-1);let _=Y?"\t".repeat(Q):" ".repeat(Q*X);if(z.push(_+A),Y5(A,U))Q++}return z.join(`
140
+ `)}};var G5={meta:{docs:"Enforce spacing around shell keywords (if, then, do, else, fi, etc.)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=P0(G);if(q)Y=!0,z=q;if(G.replace(/^\s+/,"").startsWith("#"))continue;let W=k0(G),K=W.match(/;(?![;\s$])\S/);if(K)Z.push({filePath:J.filePath,line:Q+1,column:(K.index||0)+1,ruleId:"shell/keyword-spacing",message:"Missing space after semicolon",severity:"warning"});let H=W.match(/\w(then|do|else|elif|fi|done|esac)\b/);if(H&&!/[a-z]/.test(W[H.index])){let V=H[1],A=W[H.index];if(A!==" "&&A!=="\t"&&A!==";")Z.push({filePath:J.filePath,line:Q+1,column:(H.index||0)+2,ruleId:"shell/keyword-spacing",message:`Missing space before keyword '${V}'`,severity:"warning"})}}return Z}};var q5={meta:{docs:"Disallow unnecessary trailing semicolons",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=G.match(/<<-?\s*['"]?(\w+)['"]?/);if(q)Y=!0,z=q[1];let U=G.replace(/^\s+/,"").trimEnd();if(U.startsWith("#"))continue;if(/;;\s*$/.test(U))continue;if(/\bfor\b/.test(U)||/\bwhile\b/.test(U)||/\buntil\b/.test(U))continue;if(/;\s*(?:then|do|else|elif|fi|done|esac)\s*$/.test(U))continue;if(/;\s*$/.test(U)){let W=G.lastIndexOf(";");Z.push({filePath:J.filePath,line:Q+1,column:W+1,ruleId:"shell/no-trailing-semicolons",message:"Unnecessary trailing semicolon",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[],X=!1,Y="";for(let z of J){if(X){if(Z.push(z),z.trim()===Y)X=!1;continue}let Q=z.match(/<<-?\s*['"]?(\w+)['"]?/);if(Q)X=!0,Y=Q[1];let G=z.replace(/^\s+/,"").trimEnd();if(G.startsWith("#")||/;;\s*$/.test(G)||/\bfor\b/.test(G)||/\bwhile\b/.test(G)||/\buntil\b/.test(G)||/;\s*(?:then|do|else|elif|fi|done|esac)\s*$/.test(G)){Z.push(z);continue}Z.push(z.replace(/;\s*$/,""))}return Z.join(`
141
+ `)}};var U5={meta:{docs:"Disallow trailing whitespace",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=P0(G);if(q)Y=!0,z=q;if(/[ \t]+$/.test(G)){let U=G.match(/[ \t]+$/);Z.push({filePath:J.filePath,line:Q+1,column:U.index+1,ruleId:"shell/no-trailing-whitespace",message:"Trailing whitespace",severity:"error"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=!1,X="";return J.map((z)=>{if(Z){if(z.trim()===X)Z=!1;return z}let Q=P0(z);if(Q)Z=!0,X=Q;return z.replace(/[ \t]+$/,"")}).join(`
142
+ `)}};var W5={meta:{docs:"Enforce spaces inside [ ] and [[ ]] test expressions",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=P0(G);if(q)Y=!0,z=q;if(G.replace(/^\s+/,"").startsWith("#"))continue;let W=k0(G);for(let K of FG(W,Q+1,J.filePath))Z.push(K)}return Z},fix($){let J=$.split(/\r?\n/),Z=[],X=!1,Y="";for(let z of J){if(X){if(z.trim()===Y)X=!1;Z.push(z);continue}let Q=P0(z);if(Q){X=!0,Y=Q,Z.push(z);continue}if(z.replace(/^\s+/,"").startsWith("#")){Z.push(z);continue}Z.push(BG(z))}return Z.join(`
143
+ `)}};function FG($,J,Z){let X=[],Y=/\[\[(?!\s|\]|$)/g;for(let Q of $.matchAll(Y))X.push({filePath:Z,line:J,column:(Q.index??0)+1,ruleId:"shell/operator-spacing",message:"Missing space after [[",severity:"warning"});let z=/(?<!\s|\[)\]\]/g;for(let Q of $.matchAll(z))X.push({filePath:Z,line:J,column:(Q.index??0)+1,ruleId:"shell/operator-spacing",message:"Missing space before ]]",severity:"warning"});for(let Q=0;Q<$.length;Q++){if($[Q]!=="[")continue;if($[Q+1]==="[")continue;if(Q>0&&$[Q-1]==="[")continue;if(!K5($,Q))continue;let G=$[Q+1];if(G!==void 0&&G!==" "&&G!=="\t")X.push({filePath:Z,line:J,column:Q+1,ruleId:"shell/operator-spacing",message:"Missing space after [",severity:"warning"})}for(let Q=0;Q<$.length;Q++){if($[Q]!=="]")continue;if($[Q+1]==="]")continue;if(Q>0&&$[Q-1]==="]")continue;if(!H5($,Q))continue;let G=$[Q-1];if(G!==void 0&&G!==" "&&G!=="\t")X.push({filePath:Z,line:J,column:Q+1,ruleId:"shell/operator-spacing",message:"Missing space before ]",severity:"warning"})}return X}function BG($){let J=k0($),Z=[];for(let Y of J.matchAll(/\[\[(?!\s|\]|$)/g)){let z=(Y.index??0)+2;Z.push({pos:z,text:" "})}for(let Y of J.matchAll(/(?<!\s|\[)\]\]/g)){let z=Y.index??0;Z.push({pos:z,text:" "})}for(let Y=0;Y<J.length;Y++){if(J[Y]!=="[")continue;if(J[Y+1]==="[")continue;if(Y>0&&J[Y-1]==="[")continue;if(!K5(J,Y))continue;let z=J[Y+1];if(z!==void 0&&z!==" "&&z!=="\t")Z.push({pos:Y+1,text:" "})}for(let Y=0;Y<J.length;Y++){if(J[Y]!=="]")continue;if(J[Y+1]==="]")continue;if(Y>0&&J[Y-1]==="]")continue;if(!H5(J,Y))continue;let z=J[Y-1];if(z!==void 0&&z!==" "&&z!=="\t")Z.push({pos:Y,text:" "})}if(Z.length===0)return $;Z.sort((Y,z)=>z.pos-Y.pos);let X=$;for(let{pos:Y,text:z}of Z)X=`${X.slice(0,Y)}${z}${X.slice(Y)}`;return X}function K5($,J){let Z=J-1;while(Z>=0&&($[Z]===" "||$[Z]==="\t"))Z--;if(Z<0)return!0;let X=$[Z];if(X===";"||X==="|"||X==="&"||X==="!"||X==="(")return!0;let Y=$.slice(0,Z+1);if(/(?:^|\s)(?:if|while|until|elif|then|else|do)\s*$/.test(Y))return!0;return!1}function H5($,J){let Z=$[J+1];if(Z===void 0)return!0;return Z===" "||Z==="\t"||Z===";"||Z==="|"||Z==="&"||Z===")"}var wG=/^#!\s*(?:\/usr\/bin\/env\s+(?:ba|z|k|da)?sh|\/bin\/(?:ba|z|k|da)?sh|\/usr\/bin\/(?:ba|z|k|da)?sh)\b/,V5={meta:{docs:"Ensure shell scripts have a proper shebang line",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);if(X.length===0)return Z;let Y=X[0];if(X.every((z)=>z.trim()===""))return Z;if(!Y.startsWith("#!"))return Z.push({filePath:J.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"}),Z;if(!wG.test(Y))Z.push({filePath:J.filePath,line:1,column:1,ruleId:"shell/shebang",message:`Invalid shebang: ${Y} \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 Z}};var A5={meta:{docs:"Enforce consistent case statement terminator placement",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="",Q=[];for(let G of X){if(Y){if(G.trim()===z)Y=!1;Q.push("");continue}let q=P0(G);if(q)Y=!0,z=q;if(G.replace(/^\s+/,"").startsWith("#")){Q.push("");continue}Q.push(k0(G))}for(let G=0;G<Q.length;G++){if(!/\bcase\b[\s\S]*\bin\s*$/.test(Q[G].trimEnd()))continue;let q=1,U=-1;for(let V=G+1;V<Q.length;V++){let A=Q[V].trimEnd();if(/^\s*esac\b/.test(A)){if(q--,q===0){U=V;break}continue}if(/\bcase\b[\s\S]*\bin\s*$/.test(A))q++}if(U===-1)continue;let W=0,K=!1,H=!1;for(let V=G+1;V<U;V++){let A=Q[V],_=A.trim();if(_==="")continue;if(W===0){let B=MG(A);if(B!==-1){if(K&&H)Z.push({filePath:J.filePath,line:V+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"});K=!0,H=!0;let F=A.slice(B+1).trimEnd();if(/;;\s*$/.test(F))K=!1;continue}}if(W+=jG(A),W<0)W=0;if(K&&W===0&&/;;\s*$/.test(_))K=!1}}return Z}};function MG($){let J=$.replace(/^\s+/,"");if(J==="")return-1;if(/^(?:for|while|until|if|case|do|then|else|elif|fi|done|esac)\b/.test(J))return-1;let Z=$.length-J.length,X=0;if(J[X]==="(")X++;let Y=0;while(X<J.length){let z=J[X];if(z==="(")Y++;else if(z===")"){if(Y===0)return Z+X;Y--}else if(z===";"||z==="&"||z==="<"||z===">"||z==="=")return-1;X++}return-1}function jG($){let J=$.trim();if(J==="")return 0;let Z=J.split(/[\s;]+/),X=0;for(let Y of Z)if(Y==="if"||Y==="for"||Y==="while"||Y==="until")X++;else if(Y==="fi"||Y==="done")X--;return X}var _5={meta:{docs:"Recommend <<- for heredocs inside indented blocks"},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(z.replace(/^\s+/,"").startsWith("#"))continue;if(!z.match(/^\s+/))continue;let U=k0(z).match(/(?<!<)<<(?![<-])/);if(!U||U.index===void 0)continue;let K=z.slice(U.index+2).match(/^\s*(['"]?)(\w+)\1\s*$/);if(K){let H=K[2];Z.push({filePath:J.filePath,line:Y+1,column:U.index+1,ruleId:"shell/heredoc-indent",message:`Use <<- instead of << for indented heredoc (delimiter '${H}' must be at column 0 otherwise)`,severity:"warning",help:"Use <<- to strip leading tabs from heredoc content, allowing proper indentation"})}}return Z}};var F5={meta:{docs:"Detect incorrect redirect ordering (2>&1 before > file)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=P0(G);if(q)Y=!0,z=q;if(G.replace(/^\s+/,"").startsWith("#"))continue;let W=k0(G);if(W.match(/2>&1\s+>(?!&)\s*\S/)){let H=W.indexOf("2>&1");Z.push({filePath:J.filePath,line:Q+1,column:H+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 Z}};var B5={meta:{docs:"Prefer [[ ]] over [ ] for test expressions in bash/zsh",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/)[0]||"",Y=/bash|zsh/.test(X);if(/^#!.*\bsh\b/.test(X)&&!Y||!Y)return Z;let Q=$.split(/\r?\n/),G=!1,q="";for(let U=0;U<Q.length;U++){let W=Q[U];if(G){if(W.trim()===q)G=!1;continue}let K=W.match(/<<-?\s*['"]?(\w+)['"]?/);if(K)G=!0,q=K[1];if(W.replace(/^\s+/,"").startsWith("#"))continue;if(W.match(/(?:^|\s|;)\[\s(?!\[)/)){if(/(?<!\])\](?!\])/.test(W)){let A=W.indexOf("[");Z.push({filePath:J.filePath,line:U+1,column:A+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 Z},fix($){let J=$.split(/\r?\n/)[0]||"";if(!/bash|zsh/.test(J))return $;let X=$.split(/\r?\n/),Y=[];for(let z of X){let Q=z;Q=Q.replace(/(?:^|(?<=\s|;))\[(\s(?!\[).*?(?<!\]))\](?!\])/g,"[[$1]]"),Y.push(Q)}return Y.join(`
144
+ `)}};var w5={meta:{docs:"Prefer printf over echo -e and echo -n",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z="";for(let Q=0;Q<X.length;Q++){let G=X[Q];if(Y){if(G.trim()===z)Y=!1;continue}let q=G.match(/<<-?\s*['"]?(\w+)['"]?/);if(q)Y=!0,z=q[1];if(G.replace(/^\s+/,"").startsWith("#"))continue;let W=G.match(/\becho\s+-[en]+\b/);if(W){let K=G.indexOf("echo"),H=W[0].replace("echo ","");Z.push({filePath:J.filePath,line:Q+1,column:K+1,ruleId:"shell/prefer-printf",message:`Use printf instead of echo ${H} \u2014 echo behavior varies across platforms`,severity:"warning",help:'printf is portable: printf "format\\n" args... (use \\n for newline)'})}}return Z}};var M5={meta:{docs:"Recommend set -euo pipefail for safer script execution"},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1,Q=!1,G=-1,q=!1;for(let W=0;W<X.length;W++){let K=X[W].replace(/^\s+/,"");if(W===0&&K.startsWith("#!")){G=W;continue}if(K.startsWith("#"))continue;if(K==="")continue;if(q=!0,/\bset\s+-\w*e/.test(K))Y=!0;if(/\bset\s+-\w*u/.test(K))z=!0;if(/\bset\s+.*-o\s+pipefail/.test(K))Q=!0;if(/\bset\s+-euo\s+pipefail/.test(K))Y=!0,z=!0,Q=!0}if(!q)return Z;let U=[];if(!Y)U.push("-e");if(!z)U.push("-u");if(!Q)U.push("-o pipefail");if(U.length>0)Z.push({filePath:J.filePath,line:G>=0?G+2:1,column:1,ruleId:"shell/set-options",message:`Missing shell safety options: set ${U.join(" ")}`,severity:"warning",help:"Add `set -euo pipefail` near the top of the script for safer execution"});return Z}};var j5={name:"shell",rules:{"command-substitution":H0(sX),"quote-variables":H0(J5),"no-cd-without-check":H0(nX),"no-eval":H0(iX),"no-useless-cat":H0($5),"no-ls-parsing":H0(eX),"no-variable-in-single-quotes":H0(Z5),"no-exit-in-subshell":H0(tX),shebang:H0(V5),indent:H0(Q5),"function-style":H0(X5),"operator-spacing":H0(W5),"keyword-spacing":H0(G5),"no-trailing-semicolons":H0(q5),"no-trailing-whitespace":H0(U5),"prefer-double-brackets":H0(B5),"set-options":H0(M5),"prefer-printf":H0(w5),"consistent-case-terminators":H0(A5),"no-broken-redirect":H0(F5),"heredoc-indent":H0(_5)}};var y8=null,v8=null,Z9=!1,J9=!0;function NG(){if(Z9)return J9;try{return y8=(()=>{throw new Error("Cannot require module "+"@stacksjs/ts-spell-check");})(),y8.SpellChecker.create({minWordLength:3,maxSuggestions:3}).then(($)=>{v8=$}).catch(()=>{J9=!1}),Z9=!0,!0}catch{return Z9=!0,J9=!1,!1}}function X9($,J){return{meta:{docs:$==="spell/check"?"Check spelling in text content":$==="spell/check-comments"?"Check spelling in code comments only":"Check spelling in markdown files"},check(Z,X){if(!NG()||!y8)return[];let{extractWords:Y,parseDirectives:z,isSuppressed:Q,getProgrammingWords:G}=y8,q=X.options,U=new Set((q?.words||[]).map((_)=>_.toLowerCase())),W=q?.minWordLength||3,K=G(),H=z(Z);for(let _ of H)if(_.type==="word")_.words.forEach((B)=>U.add(B.toLowerCase()));let V=Z.split(/\r?\n/),A=[];for(let _=0;_<V.length;_++){let B=V[_],F=_+1;if(J&&!J(B))continue;let M=Y(B);for(let{word:T,offset:E}of M){if(T.length<W)continue;if(T===T.toUpperCase()&&T.length<=5)continue;if(U.has(T.toLowerCase()))continue;if(K.has(T.toLowerCase()))continue;if(Q(T,F,H,U))continue;if(v8){if(v8.isCorrect(T))continue;let j=v8.suggest(T);A.push({filePath:X.filePath,line:F,column:E+1,ruleId:$,message:`Unknown word: "${T}"`,severity:"warning",help:j.length?`Did you mean: ${j.slice(0,3).join(", ")}? Or add to config words.`:`Add "${T}" to your config words array, or use: // spell-check:ignore ${T}`})}}}return A}}}function TG($){let J=$.trimStart();return J.startsWith("//")||J.startsWith("/*")||J.startsWith("*")||J.startsWith("#")}var N5={name:"spell",rules:{check:X9("spell/check"),"check-comments":X9("spell/check-comments",TG),"check-markdown":{meta:{docs:"Check spelling in markdown files"},check($,J){if(!J.filePath.endsWith(".md"))return[];return X9("spell/check-markdown").check($,J)}}}};function T5($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var E5={meta:{docs:"Disallow spaces inside array brackets",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G=0;G<z.length;G++){if(z[G]==="["&&!T5(z,G)){let q=z[G+1];if(q==="]"||q===void 0||q===`
145
+ `)continue;if(q===" "||q==="\t"){if(z.indexOf("]",G+1)!==-1)Z.push({filePath:J.filePath,line:Y+1,column:G+2,ruleId:"style/array-bracket-spacing",message:"Unexpected space after '['",severity:"warning"})}}if(z[G]==="]"&&!T5(z,G)){let q=G>0?z[G-1]:void 0;if(q==="["||q===void 0)continue;if(q===" "||q==="\t"){if(z.lastIndexOf("[",G-1)!==-1)Z.push({filePath:J.filePath,line:Y+1,column:G,ruleId:"style/array-bracket-spacing",message:"Unexpected space before ']'",severity:"warning"})}}}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.replace(/\[\s+(\S)/g,(z,Q)=>{if(Q==="]")return z;return`[${Q}`}),Y=Y.replace(/(\S)\s+\]/g,"$1]"),Z.push(Y)}return Z.join(`
146
+ `)}};var D5=/(?<![(\[{,=:?&|+\-*/])\b([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=>/g;function EG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var R5={meta:{docs:"Require parentheses around arrow function parameters",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;D5.lastIndex=0;while((G=D5.exec(z))!==null){let q=G.index;if(EG(z,q))continue;let U=G[1];if(z.slice(0,q).trimEnd().endsWith("("))continue;if(U==="async")continue;Z.push({filePath:J.filePath,line:Y+1,column:q+1,ruleId:"style/arrow-parens",message:`Arrow function parameter '${U}' should be wrapped in parentheses`,severity:"warning"})}}return Z},fix($){return $.replace(/(?<![(\[{,=:?&|+\-*/])\b([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=>/g,(J,Z)=>{if(Z==="async")return J;return J.replace(Z,`(${Z})`)})}};var b8=/=>/g;function O5($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var L5={meta:{docs:"Require space before and after => in arrow functions",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;b8.lastIndex=0;while((G=b8.exec(z))!==null){let q=G.index;if(O5(z,q))continue;if(q>0&&z[q-1]!==" "&&z[q-1]!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:q+1,ruleId:"style/arrow-spacing",message:"Missing space before =>",severity:"warning"});let U=q+2;if(U<z.length&&z[U]!==" "&&z[U]!=="\t"&&z[U]!==`
147
147
  `)Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/arrow-spacing",message:"Missing space after =>",severity:"warning"})}}return Z},fix($){let J=$.split(`
148
- `);for(let Z=0;Z<J.length;Z++){let X=J[Z],Y=X.trim();if(!Y||Y.startsWith("//")||Y.startsWith("*")||Y.startsWith("/*"))continue;let z="",Q=0;b8.lastIndex=0;let G;while((G=b8.exec(X))!==null){let q=G.index;if(R5(X,q))continue;let U=X[q-1],W=X[q+2],K=q>0&&U!==" "&&U!=="\t",H=W!==void 0&&W!==" "&&W!=="\t";if(!K&&!H)continue;z+=X.slice(Q,q),z+=`${K?" ":""}=>${H?" ":""}`,Q=q+2}if(Q>0)J[Z]=z+X.slice(Q)}return J.join(`
149
- `)}};function Y9($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var L5={meta:{docs:"Require spaces inside single-line blocks",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G=0;G<z.length;G++){if(z[G]!=="{")continue;if(Y9(z,G))continue;if(G>0&&z[G-1]==="$")continue;let q=1,U=-1;for(let K=G+1;K<z.length;K++){if(z[K]==="{"&&!Y9(z,K))q++;if(z[K]==="}"&&!Y9(z,K)){if(q--,q===0){U=K;break}}}if(U===-1)continue;let W=z.slice(G+1,U);if(!W.trim())continue;if(W[0]!==" "&&W[0]!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:G+2,ruleId:"style/block-spacing",message:"Missing space after '{'",severity:"warning"});if(W[W.length-1]!==" "&&W[W.length-1]!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/block-spacing",message:"Missing space before '}'",severity:"warning"});break}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X.replace(/(?<!\$)\{(\S)([^}]*?)(\S)\}/g,(z,Q,G,q)=>{return`{ ${Q}${G}${q} }`});Y=Y.replace(/(?<!\$)\{(\S)([^}]*?)\s\}/g,(z,Q,G)=>{return`{ ${Q}${G} }`}),Y=Y.replace(/(?<!\$)\{\s([^}]*?)(\S)\}/g,(z,Q,G)=>{return`{ ${Q}${G} }`}),Z.push(Y)}return Z.join(`
150
- `)}};var P5={meta:{docs:"Enforce consistent brace style for blocks",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let Q=X[Y].trim();if(Q.startsWith("//")||Q.startsWith("/*"))continue;if(/\}\s+(?:else|catch|finally)\b/.test(Q))Z.push({filePath:J.filePath,line:Y+1,column:Q.indexOf("}")+1,ruleId:"style/brace-style",message:"Closing curly brace appears on the same line as the subsequent block",severity:"error"});if(Q==="{"&&Y>0){let q=X[Y-1].trim();if(!q||q.startsWith("//")||q.startsWith("/*")||q.endsWith("*/"))continue;if(q&&!q.endsWith("{")&&!q.endsWith(",")&&!q.endsWith("(")){if(!q.match(/[=:]\s*$/)&&!q.endsWith("["))Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"style/brace-style",message:"Opening curly brace should be on the same line",severity:"error"})}}}return Z}};var C5=/,\s*$/,I5=new RegExp("^\\s*[}\\])](?:\\s*;?\\s*)?$"),S5={meta:{docs:"Require trailing commas in multiline constructs",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=1;Y<X.length;Y++){let Q=X[Y].trim();if(!I5.test(Q))continue;let G=X[Y-1],q=G.trim();if(!q||q==="{"||q==="["||q==="(")continue;if(q.startsWith("//")||q.startsWith("*")||q.startsWith("/*"))continue;if(C5.test(q))continue;if(q.endsWith("{")||q.endsWith("[")||q.endsWith("("))continue;if(q.endsWith("=>"))continue;Z.push({filePath:J.filePath,line:Y,column:G.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 Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X=0;X<J.length;X++){let Y=J[X];if(X+1<J.length){let z=J[X+1].trim(),Q=Y.trim();if(I5.test(z)&&Q&&Q!=="{"&&Q!=="["&&Q!=="("&&!Q.startsWith("//")&&!Q.startsWith("*")&&!Q.startsWith("/*")&&!C5.test(Q)&&!Q.endsWith("{")&&!Q.endsWith("[")&&!Q.endsWith("(")&&!Q.endsWith("=>")){Z.push(Y.replace(/(\s*)$/,",$1"));continue}}Z.push(Y)}return Z.join(`
151
- `)}};function NG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var v5={meta:{docs:"Require space after commas, disallow space before commas",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G=0;G<z.length;G++){if(z[G]!==",")continue;if(NG(z,G))continue;if(G>0&&z[G-1]===" "){if(z.slice(0,G).trim().length>0)Z.push({filePath:J.filePath,line:Y+1,column:G+1,ruleId:"style/comma-spacing",message:"Unexpected space before comma",severity:"warning"})}if(G+1<z.length&&z[G+1]!==" "&&z[G+1]!=="\t"&&z[G+1]!==`
148
+ `);for(let Z=0;Z<J.length;Z++){let X=J[Z],Y=X.trim();if(!Y||Y.startsWith("//")||Y.startsWith("*")||Y.startsWith("/*"))continue;let z="",Q=0;b8.lastIndex=0;let G;while((G=b8.exec(X))!==null){let q=G.index;if(O5(X,q))continue;let U=X[q-1],W=X[q+2],K=q>0&&U!==" "&&U!=="\t",H=W!==void 0&&W!==" "&&W!=="\t";if(!K&&!H)continue;z+=X.slice(Q,q),z+=`${K?" ":""}=>${H?" ":""}`,Q=q+2}if(Q>0)J[Z]=z+X.slice(Q)}return J.join(`
149
+ `)}};function Y9($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var P5={meta:{docs:"Require spaces inside single-line blocks",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G=0;G<z.length;G++){if(z[G]!=="{")continue;if(Y9(z,G))continue;if(G>0&&z[G-1]==="$")continue;let q=1,U=-1;for(let K=G+1;K<z.length;K++){if(z[K]==="{"&&!Y9(z,K))q++;if(z[K]==="}"&&!Y9(z,K)){if(q--,q===0){U=K;break}}}if(U===-1)continue;let W=z.slice(G+1,U);if(!W.trim())continue;if(W[0]!==" "&&W[0]!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:G+2,ruleId:"style/block-spacing",message:"Missing space after '{'",severity:"warning"});if(W[W.length-1]!==" "&&W[W.length-1]!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/block-spacing",message:"Missing space before '}'",severity:"warning"});break}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X.replace(/(?<!\$)\{(\S)([^}]*?)(\S)\}/g,(z,Q,G,q)=>{return`{ ${Q}${G}${q} }`});Y=Y.replace(/(?<!\$)\{(\S)([^}]*?)\s\}/g,(z,Q,G)=>{return`{ ${Q}${G} }`}),Y=Y.replace(/(?<!\$)\{\s([^}]*?)(\S)\}/g,(z,Q,G)=>{return`{ ${Q}${G} }`}),Z.push(Y)}return Z.join(`
150
+ `)}};var C5={meta:{docs:"Enforce consistent brace style for blocks",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let Q=X[Y].trim();if(Q.startsWith("//")||Q.startsWith("/*"))continue;if(/\}\s+(?:else|catch|finally)\b/.test(Q))Z.push({filePath:J.filePath,line:Y+1,column:Q.indexOf("}")+1,ruleId:"style/brace-style",message:"Closing curly brace appears on the same line as the subsequent block",severity:"error"});if(Q==="{"&&Y>0){let q=X[Y-1].trim();if(!q||q.startsWith("//")||q.startsWith("/*")||q.endsWith("*/"))continue;if(q&&!q.endsWith("{")&&!q.endsWith(",")&&!q.endsWith("(")){if(!q.match(/[=:]\s*$/)&&!q.endsWith("["))Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"style/brace-style",message:"Opening curly brace should be on the same line",severity:"error"})}}}return Z}};var I5=/,\s*$/,S5=new RegExp("^\\s*[}\\])](?:\\s*;?\\s*)?$"),v5={meta:{docs:"Require trailing commas in multiline constructs",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=1;Y<X.length;Y++){let Q=X[Y].trim();if(!S5.test(Q))continue;let G=X[Y-1],q=G.trim();if(!q||q==="{"||q==="["||q==="(")continue;if(q.startsWith("//")||q.startsWith("*")||q.startsWith("/*"))continue;if(I5.test(q))continue;if(q.endsWith("{")||q.endsWith("[")||q.endsWith("("))continue;if(q.endsWith("=>"))continue;Z.push({filePath:J.filePath,line:Y,column:G.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 Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X=0;X<J.length;X++){let Y=J[X];if(X+1<J.length){let z=J[X+1].trim(),Q=Y.trim();if(S5.test(z)&&Q&&Q!=="{"&&Q!=="["&&Q!=="("&&!Q.startsWith("//")&&!Q.startsWith("*")&&!Q.startsWith("/*")&&!I5.test(Q)&&!Q.endsWith("{")&&!Q.endsWith("[")&&!Q.endsWith("(")&&!Q.endsWith("=>")){Z.push(Y.replace(/(\s*)$/,",$1"));continue}}Z.push(Y)}return Z.join(`
151
+ `)}};function DG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var y5={meta:{docs:"Require space after commas, disallow space before commas",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G=0;G<z.length;G++){if(z[G]!==",")continue;if(DG(z,G))continue;if(G>0&&z[G-1]===" "){if(z.slice(0,G).trim().length>0)Z.push({filePath:J.filePath,line:Y+1,column:G+1,ruleId:"style/comma-spacing",message:"Unexpected space before comma",severity:"warning"})}if(G+1<z.length&&z[G+1]!==" "&&z[G+1]!=="\t"&&z[G+1]!==`
152
152
  `&&z[G+1]!=="\r")Z.push({filePath:J.filePath,line:Y+1,column:G+2,ruleId:"style/comma-spacing",message:"Missing space after comma",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.replace(/ ,/g,","),Y=Y.replace(/,(\S)/g,", $1"),Z.push(Y)}return Z.join(`
153
- `)}};var y5={meta:{docs:"Enforce comma-last style (commas at the end of lines, not the beginning)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;if(Q.startsWith(","))Z.push({filePath:J.filePath,line:Y+1,column:z.indexOf(",")+1,ruleId:"style/comma-style",message:"Comma should be placed at the end of the previous line",severity:"warning"})}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X=0;X<J.length;X++){let Y=J[X],z=Y.trim();if(z.startsWith(",")&&Z.length>0){let Q=Z.length-1;Z[Q]=Z[Q].replace(/\s*$/,",");let G=Y.match(/^(\s*)/)?.[1]||"";Z.push(G+z.slice(1).trim())}else Z.push(Y)}return Z.join(`
154
- `)}};function TG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var b5={meta:{docs:"Disallow spaces inside computed property brackets [expr]",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G=0;G<z.length;G++){if(z[G]!=="[")continue;if(TG(z,G))continue;if(G===0)continue;let q=z[G-1];if(!/[a-zA-Z0-9_$)\]]/.test(q))continue;if(G+1<z.length&&(z[G+1]===" "||z[G+1]==="\t"))Z.push({filePath:J.filePath,line:Y+1,column:G+2,ruleId:"style/computed-property-spacing",message:"Unexpected space after '['",severity:"warning"});let U=1,W=G+1;while(W<z.length&&U>0){if(z[W]==="[")U++;if(z[W]==="]")U--;if(U>0)W++}if(U===0&&W>0){if(z[W-1]===" "||z[W-1]==="\t")Z.push({filePath:J.filePath,line:Y+1,column:W,ruleId:"style/computed-property-spacing",message:"Unexpected space before ']'",severity:"warning"})}}}return Z},fix($){return $.replace(/([a-zA-Z0-9_$)\]])\[\s+([\s\S]*?)\s+\]/g,"$1[$2]")}};function EG($){let J=[],Z=$.split(/\r?\n/),X=0;for(let Y=0;Y<Z.length;Y++){let z=Z[Y],Q=/\b[\w$)\]]+\s*\./.test(z),G=Y+1<Z.length&&/^\s*\./.test(Z[Y+1]);if(Q||G){let q=Y,U=Y;while(q+1<Z.length&&/^\s*\./.test(Z[q+1]))q++,U=q;if(U>Y){let W=X,K=X+Z[Y].length+1+Z.slice(Y+1,U+1).join(`
155
- `).length;J.push({start:W,end:K}),Y=U}}X+=z.length+1}return J}var k5={meta:{docs:"Enforce consistent line breaks in member-access/call chains"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=EG($);for(let{start:z,end:Q}of Y){let q=$.slice(z,Q).split(/\r?\n/),U=[];for(let V=0;V<q.length;V++){let A=q[V],_=[...A.matchAll(/\./g)].map((B)=>B.index||0);for(let B of _){if(B>0&&A[B-1]==="?")continue;if(/^\s*\./.test(A)&&B===A.indexOf(".")&&A.slice(0,B).trim()==="")U.push("newline");else U.push("inline")}}if(U.length<=1)continue;let W=U[0];if(U.every((V)=>V===W))continue;let K=U.findIndex((V)=>V!==W),H=0;for(let V=0;V<q.length;V++){let A=q[V],_=[...A.matchAll(/\./g)].map((B)=>B.index||0);for(let B of _){if(B>0&&A[B-1]==="?")continue;if(H===K){let M=$.slice(0,z).split(/\r?\n/),N=M.length,E=(M[M.length-1]||"").length;Z.push({filePath:J.filePath,line:N+V,column:(V===0?E:0)+B+1,ruleId:"style/consistent-chaining",message:`Inconsistent chaining style: mix of ${W} and ${W==="inline"?"newline":"inline"}.`,severity:"warning"}),V=q.length;break}H++}}}return Z}};function f5($){let J=[0];for(let X=0;X<$.length;X++)if($[X]===`
156
- `)J.push(X+1);function Z(X){let Y=0,z=J.length-1;while(Y<=z){let G=Y+z>>1,q=J[G],U=G+1<J.length?J[G+1]:1/0;if(X<q)z=G-1;else if(X>=U)Y=G+1;else return{line:G+1,column:X-q+1}}let Q=J[J.length-1];return{line:J.length,column:Math.max(1,X-Q+1)}}return{lineStarts:J,indexToLoc:Z}}function g5($){let J=[],Z=(z,Q,G)=>J.push({type:z,value:$.slice(Q,G),start:Q,end:G}),X=0,Y=$.length;while(X<Y){let z=$[X];if(z<=" "){X++;continue}if(z==="/"&&$[X+1]==="/"){let q=X;X+=2;while(X<Y&&$[X]!==`
153
+ `)}};var b5={meta:{docs:"Enforce comma-last style (commas at the end of lines, not the beginning)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;if(Q.startsWith(","))Z.push({filePath:J.filePath,line:Y+1,column:z.indexOf(",")+1,ruleId:"style/comma-style",message:"Comma should be placed at the end of the previous line",severity:"warning"})}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X=0;X<J.length;X++){let Y=J[X],z=Y.trim();if(z.startsWith(",")&&Z.length>0){let Q=Z.length-1;Z[Q]=Z[Q].replace(/\s*$/,",");let G=Y.match(/^(\s*)/)?.[1]||"";Z.push(G+z.slice(1).trim())}else Z.push(Y)}return Z.join(`
154
+ `)}};function RG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var k5={meta:{docs:"Disallow spaces inside computed property brackets [expr]",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G=0;G<z.length;G++){if(z[G]!=="[")continue;if(RG(z,G))continue;if(G===0)continue;let q=z[G-1];if(!/[a-zA-Z0-9_$)\]]/.test(q))continue;if(G+1<z.length&&(z[G+1]===" "||z[G+1]==="\t"))Z.push({filePath:J.filePath,line:Y+1,column:G+2,ruleId:"style/computed-property-spacing",message:"Unexpected space after '['",severity:"warning"});let U=1,W=G+1;while(W<z.length&&U>0){if(z[W]==="[")U++;if(z[W]==="]")U--;if(U>0)W++}if(U===0&&W>0){if(z[W-1]===" "||z[W-1]==="\t")Z.push({filePath:J.filePath,line:Y+1,column:W,ruleId:"style/computed-property-spacing",message:"Unexpected space before ']'",severity:"warning"})}}}return Z},fix($){return $.replace(/([a-zA-Z0-9_$)\]])\[\s+([\s\S]*?)\s+\]/g,"$1[$2]")}};function OG($){let J=[],Z=$.split(/\r?\n/),X=0;for(let Y=0;Y<Z.length;Y++){let z=Z[Y],Q=/\b[\w$)\]]+\s*\./.test(z),G=Y+1<Z.length&&/^\s*\./.test(Z[Y+1]);if(Q||G){let q=Y,U=Y;while(q+1<Z.length&&/^\s*\./.test(Z[q+1]))q++,U=q;if(U>Y){let W=X,K=X+Z[Y].length+1+Z.slice(Y+1,U+1).join(`
155
+ `).length;J.push({start:W,end:K}),Y=U}}X+=z.length+1}return J}var f5={meta:{docs:"Enforce consistent line breaks in member-access/call chains"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=OG($);for(let{start:z,end:Q}of Y){let q=$.slice(z,Q).split(/\r?\n/),U=[];for(let V=0;V<q.length;V++){let A=q[V],_=[...A.matchAll(/\./g)].map((B)=>B.index||0);for(let B of _){if(B>0&&A[B-1]==="?")continue;if(/^\s*\./.test(A)&&B===A.indexOf(".")&&A.slice(0,B).trim()==="")U.push("newline");else U.push("inline")}}if(U.length<=1)continue;let W=U[0];if(U.every((V)=>V===W))continue;let K=U.findIndex((V)=>V!==W),H=0;for(let V=0;V<q.length;V++){let A=q[V],_=[...A.matchAll(/\./g)].map((B)=>B.index||0);for(let B of _){if(B>0&&A[B-1]==="?")continue;if(H===K){let M=$.slice(0,z).split(/\r?\n/),T=M.length,E=(M[M.length-1]||"").length;Z.push({filePath:J.filePath,line:T+V,column:(V===0?E:0)+B+1,ruleId:"style/consistent-chaining",message:`Inconsistent chaining style: mix of ${W} and ${W==="inline"?"newline":"inline"}.`,severity:"warning"}),V=q.length;break}H++}}}return Z}};function g5($){let J=[0];for(let X=0;X<$.length;X++)if($[X]===`
156
+ `)J.push(X+1);function Z(X){let Y=0,z=J.length-1;while(Y<=z){let G=Y+z>>1,q=J[G],U=G+1<J.length?J[G+1]:1/0;if(X<q)z=G-1;else if(X>=U)Y=G+1;else return{line:G+1,column:X-q+1}}let Q=J[J.length-1];return{line:J.length,column:Math.max(1,X-Q+1)}}return{lineStarts:J,indexToLoc:Z}}function p5($){let J=[],Z=(z,Q,G)=>J.push({type:z,value:$.slice(Q,G),start:Q,end:G}),X=0,Y=$.length;while(X<Y){let z=$[X];if(z<=" "){X++;continue}if(z==="/"&&$[X+1]==="/"){let q=X;X+=2;while(X<Y&&$[X]!==`
157
157
  `)X++;Z("LineComment",q,X);continue}if(z==="/"&&$[X+1]==="*"){let q=X;X+=2;while(X<Y&&!($[X]==="*"&&$[X+1]==="/"))X++;X=Math.min(Y,X+2),Z("BlockComment",q,X);continue}if(z==='"'||z==="'"){let q=z,U=X;X++;while(X<Y){let W=$[X];if(W==="\\"){X+=2;continue}if(W===q){X++;break}X++}Z("String",U,X);continue}if(z==="`"){let q=X;X++;let U=0;while(X<Y){let W=$[X];if(W==="\\"){X+=2;continue}if(W==="`"&&U===0){X++;break}if(W==="$"&&$[X+1]==="{"){U++,X+=2;continue}if(W==="}"&&U>0){U--,X++;continue}X++}Z("Template",q,X);continue}if(z==="/"){if($[X+1]==="/"){let q=X;X+=2;while(X<Y&&$[X]!==`
158
- `)X++;Z("LineComment",q,X);continue}if($[X+1]==="*"){let q=X;X+=2;while(X<Y&&!($[X]==="*"&&$[X+1]==="/"))X++;X=Math.min(Y,X+2),Z("BlockComment",q,X);continue}if(DG(J)){let q=X;X++;while(X<Y){let U=$[X];if(U==="\\"){X+=2;continue}if(U==="/"){X++;break}X++}while(X<Y&&/[a-z]/i.test($[X]))X++;Z("Regex",q,X);continue}Z("Punct",X,X+1),X++;continue}if("(){}[];:,.<>+-*%&|^!?=~".includes(z)){Z("Punct",X,X+1),X++;continue}let Q=X,G=new RegExp("[^\\s(){}[\\];:,.<>+\\-*%&|^!?=~'\"`/]");while(X<Y&&G.test($[X]))X++;if(X>Q)Z("Word",Q,X);else Z("Word",X,X+1),X++}return J}function DG($){if($.length===0)return!0;let J=$[$.length-1],Z=new RegExp("[(!,{;:?=]");return J.type==="Punct"&&Z.test(J.value)||J.type==="Word"&&/^(?:return|throw|case|of|in|instanceof|typeof|void|new)$/.test(J.value)}function p5($,J,Z,X){let Y=0,z=(K)=>K<=" ",Q=(K)=>{while(K<$.length&&$[K]!==`
159
- `)K++;return K},G=(K)=>{K+=2;while(K<$.length&&!($[K]==="*"&&$[K+1]==="/"))K++;return Math.min($.length,K+2)},q=(K,H)=>{let V=$.length;if(H==="`"){K++;let A=0;while(K<V){let _=$[K];if(_==="\\"){K+=2;continue}if(_==="`"&&A===0){K++;break}if(_==="$"&&$[K+1]==="{"){A++,K+=2;continue}if(_==="}"&&A>0){A--,K++;continue}if(_==='"'||_==="'"){K=q(K,_);continue}if(_==="/"&&$[K+1]==="/"){K=Q(K+2);continue}if(_==="/"&&$[K+1]==="*"){K=G(K);continue}K++}return K}K++;while(K<V){let A=$[K];if(A==="\\"){K+=2;continue}if(A===H){K++;break}K++}return K},U=(K)=>{let H=K-1;while(H>=0&&z($[H]))H--;let V=H>=0?$[H]:"";if(new RegExp("[(:[{;?,=!&|^~+\\-*%<>]").test(V))return!0;if(V==="")return!0;return!1},W=(K)=>{K++;let H=$.length;while(K<H){let V=$[K];if(V==="\\"){K+=2;continue}if(V==="/"){K++;break}K++}while(K<H&&/[a-z]/i.test($[K]))K++;return K};for(let K=J;K<$.length;K++){let H=$[K];if(H===Z){Y++;continue}if(H===X){if(Y--,Y===0)return K;continue}if(H==='"'||H==="'"||H==="`"){K=q(K,H)-1;continue}if(H==="/"&&$[K+1]==="/"){K=Q(K+2)-1;continue}if(H==="/"&&$[K+1]==="*"){K=G(K)-1;continue}if(H==="/"&&U(K)){K=W(K)-1;continue}}return-1}function k8($,J,Z,X,Y,z,Q){let G=p5($,X,Y,z);if(G<=X)return;let q=$.slice(X+1,G),U=/\r?\n/.test(q),W=f5($),K=[],H=0,V=X+1,A=g5($.slice(X+1,G)),_=0;for(let F of A){let M=X+1+F.start,N=X+1+F.end;if(_=N,F.type==="Punct"){if(F.value===Y)H++;else if(F.value===z&&H>0)H--;else if(F.value===","&&H===0)K.push({start:V,end:M}),V=N}}if(K.push({start:V,end:G}),!U){for(let F of K){let M=$.slice(F.start,F.end);if(/\r?\n/.test(M)){let N=W.indexToLoc(F.start);Z.push({filePath:J,line:N.line,column:N.column,ruleId:Q,message:"Should not have line breaks between items",severity:"warning"});break}}return}let B=q.indexOf(`
160
- `);if(B>0){let F=q.slice(0,B),M=(F.match(/,/g)||[]).length,N=q.slice(B+1),E=N.includes(`
161
- `),j=N.includes(",");if(M>=1&&/\S,\s*\S/.test(F)&&!E&&!j){let O=W.indexToLoc(X+1+B+1);Z.push({filePath:J,line:O.line,column:O.column,ruleId:Q,message:"Should not have line breaks between items",severity:"warning"});return}else if(M>=1&&/\S,\s*\S/.test(F)){let O=W.indexToLoc(X+1+F.search(/,\s*\S/));Z.push({filePath:J,line:O.line,column:O.column,ruleId:Q,message:"Should have line breaks between items",severity:"warning"});return}}for(let F of K){let M=$.slice(X+1,F.start);if(!/\n[ \t]*$/.test(M)&&M.trim()!==""){let N=W.indexToLoc(F.start);Z.push({filePath:J,line:N.line,column:N.column,ruleId:Q,message:"Should have line breaks between items",severity:"warning"});break}}}var x5={meta:{docs:"Enforce consistent newlines for list-like constructs (objects, arrays, named imports/exports)"},check:($,J)=>{let Z=[],X="style/consistent-list-newline";for(let Y=0;Y<$.length;Y++){let z=$[Y];if(z==="{"){let Q=Y-1;while(Q>=0&&/[ \t]/.test($[Q]))Q--;if(Q>=0&&$[Q]===")")continue;let G=$.slice(Math.max(0,Y-60),Y);if(/\b(?:function|class|interface|type|enum|try|catch|finally|if|else|for|while|switch)\b[\s\S]*$/.test(G))continue;k8($,J.filePath,Z,Y,"{","}","style/consistent-list-newline")}else if(z==="[")k8($,J.filePath,Z,Y,"[","]","style/consistent-list-newline");else if(z==="i"&&$.startsWith("import",Y)){let Q=$.indexOf("{",Y);if(Q>-1)k8($,J.filePath,Z,Q,"{","}","style/consistent-list-newline")}else if(z==="e"&&$.startsWith("export",Y)){let Q=$.indexOf("{",Y);if(Q>-1)k8($,J.filePath,Z,Q,"{","}","style/consistent-list-newline")}}return Z}};function RG($){let J=$.trim();return J===""||J.startsWith("//")||J.startsWith("/*")}function z9($,J){for(let Z=J;Z<$.length;Z++)if(!RG($[Z]))return Z;return-1}function w1($,J,Z){if($[J].slice(Z).includes("{"))return!0;let Y=z9($,J+1);if(Y>=0){if($[Y].trim().startsWith("{"))return!0}return!1}function f8($,J,Z){let X=$[J].slice(Z);if(/\bif\b|\bfor\b|\bwhile\b|\bdo\b/.test(X))return!0;return!1}var h5={meta:{docs:"Enforce curly brackets similar to src-2: require braces when any branch/body requires them"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let z=0;z<X.length;z++){let Q=X[z],G=Q.match(/^(\s*)if\s*\(([^)]*)\)/);if(G){let U=G[0].length,W=w1(X,z,U),K=f8(X,z,U),H=z,V=W,A=K;while(!0){let _=z9(X,H+1);if(_<0)break;let B=X[_].trim();if(!B.startsWith("else"))break;let F=B.match(/^else\s+if\s*\(([^)]*)\)/);if(F){let M=X[_].indexOf(F[0])+F[0].length;V=V||w1(X,_,M),A=A||f8(X,_,M),H=_;continue}else{let M=X[_].indexOf("else")+4;V=V||w1(X,_,M),A=A||f8(X,_,M),H=_;break}}if(V||A){if(!W)Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,Q.indexOf("if")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});let _=z;while(!0){let B=z9(X,_+1);if(B<0)break;let F=X[B],M=F.trim();if(!M.startsWith("else"))break;let N=M.match(/^else\s+if\s*\(([^)]*)\)/);if(N){let E=F.indexOf(N[0])+N[0].length;if(!w1(X,B,E))Z.push({filePath:J.filePath,line:B+1,column:Math.max(1,F.indexOf("else")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});_=B;continue}else{let E=F.indexOf("else")+4;if(!w1(X,B,E))Z.push({filePath:J.filePath,line:B+1,column:Math.max(1,F.indexOf("else")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});break}}}}let q=Q.match(/^(\s*)(while|do|for|for\s+await)\b/);if(q){let U=q[0].length,W=w1(X,z,U),K=f8(X,z,U);if((W||K)&&!W)Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,Q.indexOf(q[2])+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"})}}let Y=OG($,J.filePath);for(let z of Y)Z.push({filePath:J.filePath,line:z.line,column:z.column,ruleId:"style/curly",message:z.message,severity:"warning"});return Z}};function OG($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim(),G=/^if\s*\(/.test(Q)?"if":/^else\s+if\s*\(/.test(Q)?"else-if":/^else\b/.test(Q)?"else":null;if(!G)continue;let q=0;if(G==="if"){let A=z.match(/if\s*\([^)]*\)/);q=A?z.indexOf(A[0])+A[0].length:z.indexOf("if")+2}else if(G==="else-if"){let A=z.match(/else\s+if\s*\([^)]*\)/);q=A?z.indexOf(A[0])+A[0].length:z.indexOf("else")+4}else q=z.indexOf("else")+4;let U=Y,W=z.indexOf("{",q);if(W<0){let A=function(B){for(let F=B;F<X.length;F++)if(X[F].trim()!=="")return F;return-1}(Y+1);if(A<0)continue;if(W=X[A].indexOf("{"),W<0)continue;U=A}let K=0,H=-1;for(let A=U;A<X.length;A++){let _=X[A],B=A===U?Math.max(0,W):0;for(let F=B;F<_.length;F++){let M=_[F];if(M==="{")K++;else if(M==="}"){if(K--,K===0){H=A;break}}}if(H>=0)break}if(H<0)continue;let V=[];for(let A=U+1;A<H;A++){let _=X[A].trim();if(_===""||/^\/\//.test(_))continue;if(V.push(_),V.length>1)break}if(V.length===1&&H===U+2){let A=V[0],_=/^(?:if|for|while|do|switch|try|catch|else)\b/.test(A),B=/[{}]/.test(A),F=(A.match(/\(/g)||[]).length,M=(A.match(/\)/g)||[]).length,N=F!==M,E=!1;for(let j=Y+1;j<X.length;j++){let O=X[j].trim();if(O===""||O==="}"||/^\/\//.test(O))continue;if(!/^else\b/.test(O))break;let y=X[j].indexOf("else")+4,k=O.match(/^else\s+if\s*\([^)]*\)/);if(k)y=X[j].indexOf(k[0])+k[0].length;let L=j,x=X[j].indexOf("{",y);if(x<0){let I=function(C){for(let T=C;T<X.length;T++)if(X[T].trim()!=="")return T;return-1}(j+1);if(I<0)break;if(x=X[I].indexOf("{"),x<0)continue;L=I}let b=0,P=-1;for(let I=L;I<X.length;I++){let S=X[I],C=I===L?Math.max(0,x):0;for(let T=C;T<S.length;T++){let R=S[T];if(R==="{")b++;else if(R==="}"){if(b--,b===0){P=I;break}}}if(P>=0)break}if(P>=0){let I=0;for(let S=L+1;S<P;S++){let C=X[S].trim();if(C===""||/^\/\//.test(C))continue;if(I++,I>1){E=!0;break}}}if(E)break}if(!E&&G==="if"){let j=function(y){for(let k=y;k<X.length;k++){let L=X[k].trim();if(L!==""&&L!=="}"&&!/^\/\//.test(L))return k}return-1}(H+1);if(j>=0&&/^else\b/.test(X[j].trim())){let O=X[j].indexOf("else")+4,y=X[j].trim().match(/^else\s+if\s*\([^)]*\)/);if(y)O=X[j].indexOf(y[0])+y[0].length;let k=j,L=X[j].indexOf("{",O);if(L<0){let x=function(P){for(let I=P;I<X.length;I++)if(X[I].trim()!=="")return I;return-1}(j+1);if(x>=0)L=X[x].indexOf("{"),k=L>=0?x:k}if(L>=0){let x=0,b=-1;for(let P=k;P<X.length;P++){let I=X[P],S=P===k?Math.max(0,L):0;for(let C=S;C<I.length;C++){let T=I[C];if(T==="{")x++;else if(T==="}"){if(x--,x===0){b=P;break}}}if(b>=0)break}if(b>=0){let P=0;for(let I=k+1;I<b;I++){let S=X[I].trim();if(S===""||/^\/\//.test(S))continue;if(++P>1){E=!0;break}}}}}}if(!_&&!B&&!N&&!E)Z.push({line:U+1,column:Math.max(1,X[U].indexOf("{")+1),message:"Unnecessary curly braces around single statement"})}}return Z}var u5={meta:{docs:"Enforce dot on the property line in chained method calls",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=i0($);for(let z=0;z<X.length;z++){let Q=X[z],G=Q.trim();if(!G||G.startsWith("//")||G.startsWith("*")||G.startsWith("/*"))continue;if(Y[z+1])continue;if(G.endsWith(".")&&z+1<X.length){let q=X[z+1].trim();if(q&&/^[a-zA-Z_$]/.test(q))Z.push({filePath:J.filePath,line:z+1,column:Q.length,ruleId:"style/dot-location",message:"Dot should be on the same line as the property",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[],X=i0($);for(let Y=0;Y<J.length;Y++){let z=J[Y];if(z.trim().endsWith(".")&&!X[Y+1]&&Y+1<J.length){let G=J[Y+1],q=G.trim();if(q&&/^[a-zA-Z_$]/.test(q)){Z.push(z.replace(/\.\s*$/,""));let U=G.match(/^(\s*)/)?.[1]||"";J[Y+1]=`${U}.${q}`;continue}}Z.push(z)}return Z.join(`
162
- `)}};function m5($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var d5=["===","!==",">>>","==","!=",">=","<=","&&","||","??","**","<<",">>","+","-","*","/","%","|","&","^",">","<","instanceof","in"],Uw=new RegExp(`^(${d5.map(($)=>$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})\\s`),LG=new Set(["in","instanceof"]),PG=/^(?:instanceof|in)\s/;function g8($){if(PG.test($))return!0;for(let J of d5){if(LG.has(J))continue;if($.startsWith(J)){let Z=$[J.length];if(Z===void 0||Z===" "||Z==="\t")return!0}}return!1}function Q9($){let J=$.match(/^(\s*)/);return J?J[1].length:0}var o5={meta:{docs:"Enforce consistent indentation of continuation lines in multiline binary expressions",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;if(!g8(Q))continue;if(m5(z,0))continue;let G=Y-1;while(G>=0){let W=X[G].trim();if(!W||W.startsWith("//")||W.startsWith("*")||W.startsWith("/*")){G--;continue}if(g8(W)){G--;continue}break}if(G<0)continue;let q=Q9(X[G])+2,U=Q9(z);if(U!==q)Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/indent-binary-ops",message:`Expected indentation of ${q} spaces for binary operator continuation, but found ${U}`,severity:"warning"})}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y=0;Y<Z.length;Y++){let z=Z[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*")){X.push(z);continue}if(!g8(Q)||m5(z,0)){X.push(z);continue}let G=-1;for(let W=X.length-1;W>=0;W--){let K=X[W].trim();if(!K||K.startsWith("//")||K.startsWith("*")||K.startsWith("/*"))continue;if(g8(K))continue;G=W;break}if(G<0){X.push(z);continue}let q=Q9(X[G])+2,U=" ".repeat(q)+Q;X.push(U);continue}return X.join(`
163
- `)}};var c5=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"]),p8=/([a-zA-Z_$][a-zA-Z0-9_$]*)\s+\(/g;function r5($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var l5={meta:{docs:"Disallow spaces between function name and opening parenthesis in calls",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;p8.lastIndex=0;while((G=p8.exec(z))!==null){let q=G[1],U=G.index;if(r5(z,U))continue;if(c5.has(q))continue;let W=z.slice(0,U).trimEnd();if(W.endsWith("function")||W.endsWith("function*"))continue;if(/\b(?:get|set)\s*$/.test(W))continue;let K=U+q.length;Z.push({filePath:J.filePath,line:Y+1,column:K+1,ruleId:"style/function-call-spacing",message:"Unexpected space between function name and parenthesis",severity:"warning"})}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y=0;Y<Z.length;Y++){let z=Z[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*")){X.push(z);continue}let G=z,q=[],U;p8.lastIndex=0;while((U=p8.exec(z))!==null){let W=U[1],K=U.index;if(r5(z,K))continue;if(c5.has(W))continue;let H=z.slice(0,K).trimEnd();if(H.endsWith("function")||H.endsWith("function*"))continue;if(/\b(?:get|set)\s*$/.test(H))continue;q.push({index:K,fullMatch:U[0],identifier:W})}for(let W=q.length-1;W>=0;W--){let K=q[W],H=K.index,V=H+K.fullMatch.length;G=`${G.slice(0,H)}${K.identifier}(${G.slice(V)}`}X.push(G)}return X.join(`
164
- `)}};var a5=/\bfunction\s*\*/g;function s5($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var n5={meta:{docs:"Enforce spacing around * in generator functions (space after, no space before)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;a5.lastIndex=0;while((G=a5.exec(z))!==null){let U=G.index;if(s5(z,U))continue;let W=G[0],K=U+W.indexOf("*"),H=K+1;if(W!=="function*")Z.push({filePath:J.filePath,line:Y+1,column:K+1,ruleId:"style/generator-star-spacing",message:"Unexpected space before * in generator function",severity:"warning"});if(H<z.length&&z[H]!==" "&&z[H]!=="\t"&&z[H]!==`
165
- `&&z[H]!=="(")Z.push({filePath:J.filePath,line:Y+1,column:H+1,ruleId:"style/generator-star-spacing",message:"Missing space after * in generator function",severity:"warning"})}if(Q.match(/^(?:async\s+)?\*\s*([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/)){let U=z.indexOf("*",z.indexOf(Q.charAt(0)));if(!s5(z,U)){let W=U+1;if(W<z.length&&z[W]!==" "&&z[W]!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"style/generator-star-spacing",message:"Missing space after * in generator method",severity:"warning"})}}}return Z},fix($,J){let Z=$;return Z=Z.replace(/\bfunction\s+\*/g,"function*"),Z=Z.replace(/\bfunction\*([a-zA-Z_$])/g,"function* $1"),Z=Z.replace(/(^\s*(?:async\s+)?)\*([a-zA-Z_$])/gm,"$1* $2"),Z}};var i5={meta:{docs:"Enforce newline after if when without braces"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(!z.match(/^\s*if\s*\([^)]*\)\s*([^\s{/].*)$/))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf("if")+1),ruleId:"style/if-newline",message:"Expect newline after if",severity:"warning"})}return Z}};var CG=["$","unindent","unIndent"],t5={meta:{docs:"Enforce consistent indentation inside unindent-style tagged templates"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.match(/^\s*/)?.[0]??"",G=/([$A-Z_][\w$]*)\s*`/gi,q;while(q=G.exec(z)){let U=q[1];if(!CG.includes(U))continue;if(z.slice(q.index+q[0].length).includes("`"))continue;let K=-1;for(let V=Y+1;V<X.length;V++)if(X[V].includes("`")){K=V;break}if(K<0)continue;let H=`${Q} `;for(let V=Y+1;V<K;V++){let A=X[V];if(A.trim()==="")continue;let _=A.match(/^\s*/)?.[0]??"";if(!_.startsWith(H)){Z.push({filePath:J.filePath,line:V+1,column:(_.length||0)+1,ruleId:"style/indent-unindent",message:"Consistent indentation in unindent tag",severity:"warning"});break}}}}return Z}};var IG=/^(\s*)(["']?[a-zA-Z_$][a-zA-Z0-9_$]*["']?\s*(?:\?)?):(\S)/;function e5($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var $6={meta:{docs:"Require space after colon in object properties",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=z.match(IG);if(G){let U=z.indexOf(":",G[1].length);if(U!==-1&&!e5(z,U)){let W=z[U+1];if(W&&W!==" "&&W!=="\t"&&W!==`
166
- `)Z.push({filePath:J.filePath,line:Y+1,column:U+2,ruleId:"style/key-spacing",message:"Missing space after colon in property",severity:"warning"})}}let q=Q.match(/^(["']?[a-zA-Z_$][a-zA-Z0-9_$]*["']?)\s+:/);if(q&&!Q.match(/^\s*(case|default)\b/)){let U=z.indexOf(":",z.indexOf(q[1])+q[1].length);if(U!==-1&&!e5(z,U))Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/key-spacing",message:"Unexpected space before colon in property",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.replace(/^(\s*)(["']?[a-zA-Z_$][a-zA-Z0-9_$]*["']?\s*(?:\?)?):(\S)/,"$1$2: $3"),Z.push(Y)}return Z.join(`
167
- `)}};var SG=["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"],Z6=new RegExp(`(?:^|[^\\w$.])(${SG.join("|")})(?=[^\\w$]|$)`,"g");function vG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var J6={meta:{docs:"Require space before and after keywords",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;Z6.lastIndex=0;while((G=Z6.exec(z))!==null){let q=G[0].charAt(0)===G[1].charAt(0)?"":G[0].charAt(0),U=G.index+q.length,W=U+G[1].length;if(vG(z,U))continue;if(U>0){let K=z[U-1];if(K===")"||K==="}")Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/keyword-spacing",message:`Missing space before keyword '${G[1]}'`,severity:"warning"})}if(W<z.length){let K=z[W];if(K!==" "&&K!=="\t"&&K!==";"&&K!==","&&K!==":"&&K!=="."){if(K==="("&&(G[1]==="if"||G[1]==="for"||G[1]==="while"||G[1]==="switch"||G[1]==="catch"))Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"style/keyword-spacing",message:`Missing space after keyword '${G[1]}'`,severity:"warning"})}}}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;for(let z of["if","for","while","switch","catch"]){let Q=new RegExp(`(\\b${z})\\(`,"g");Y=Y.replace(Q,"$1 (")}for(let z of["else","catch","finally"])Y=Y.replace(new RegExp(`\\)${z}\\b`,"g"),`) ${z}`),Y=Y.replace(new RegExp(`\\}${z}\\b`,"g"),`} ${z}`);Z.push(Y)}return Z.join(`
168
- `)}};var X6=/^\s*(?:public|private|protected|static|readonly|abstract|override|async|get|set|\*|#|[a-zA-Z_$])/,Y6={meta:{docs:"Require blank line between class members",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z=0,Q=0,G=-1;for(let q=0;q<X.length;q++){let W=X[q].trim();if(W.match(/\bclass\b/)&&(W.includes("{")||q+1<X.length&&X[q+1].trim()==="{"))Y=!0,Q=z+1;let K=z;for(let H of W){if(H==="{")z++;if(H==="}")z--}if(Y&&z<Q){Y=!1,G=-1;continue}if(!Y)continue;if(K>Q&&z===Q&&W.endsWith("}")){G=q;continue}if(K===Q){if(!W||W.startsWith("//")||W.startsWith("*")||W.startsWith("/*")||W==="}")continue;if(X6.test(W)){if(G!==-1&&q===G+1)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"style/lines-between-class-members",message:"Missing blank line between class members",severity:"warning"});if(!W.endsWith("{"))G=q}}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[],Y=!1,z=0,Q=0,G=-1;for(let q=0;q<Z.length;q++){let U=Z[q],W=U.trim();if(W.match(/\bclass\b/)&&(W.includes("{")||q+1<Z.length&&Z[q+1].trim()==="{"))Y=!0,Q=z+1;let K=z;for(let H of W){if(H==="{")z++;if(H==="}")z--}if(Y&&z<Q){Y=!1,G=-1,X.push(U);continue}if(Y&&K>Q&&z===Q&&W.endsWith("}")){G=q,X.push(U);continue}if(Y&&K===Q&&W&&!W.startsWith("//")&&!W.startsWith("*")&&!W.startsWith("/*")&&W!=="}"&&X6.test(W)){if(G!==-1&&q===G+1)X.push("");if(!W.endsWith("{"))G=q}X.push(U)}return X.join(`
169
- `)}};var z6={meta:{docs:"Limit the number of statements allowed on a single line"},check:($,J)=>{let Z=J.options&&typeof J.options.max==="number"?J.options.max:1,X=[],Y=$.split(/\r?\n/),z=(Q)=>{let G=yG(Q),q=G>=0?Q.slice(0,G):Q,U=0,W=!1,K=!1,H=!1,V=!1,A=!1,_=!1,B=!1,F=0,M="",N=(O)=>{if(O===" "||O==="\t")return;M=O};for(let O=0;O<q.length;O++){let y=q[O];if(_){_=!1;continue}if(y==="\\"){_=!0;continue}if(V){if(A){if(y==="]")A=!1;continue}if(y==="["){A=!0;continue}if(y==="/"){V=!1;while(O+1<q.length&&/[a-z]/i.test(q[O+1]))O++;M="/"}continue}if(!K&&!H&&y==="'"){W=!W,N(W?"'":"x");continue}if(!W&&!H&&y==='"'){K=!K,N(K?'"':"x");continue}if(!W&&!K&&y==="`"){H=!H,N(H?"`":"x");continue}if(W||K||H)continue;if(y==="/"&&Q6(M,q,O)){V=!0;continue}if(!B){if(y==="f"&&q.slice(O,O+4).match(/^for\b/)){let k=q.slice(O+3).trimStart(),L=q.length-k.length;if(q[L]==="("){B=!0,F=1,O=L,M="(";continue}}}else if(y==="(")F++;else if(y===")"){if(F--,F<=0)B=!1}else if(y===";"){N(y);continue}if(y===";")U++;N(y)}if(U===0)return 1;return q.trimEnd().endsWith(";")?U:U+1};for(let Q=0;Q<Y.length;Q++){let G=Y[Q];if(/^\s*$/.test(G))continue;let q=z(G);if(q>Z)X.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"max-statements-per-line",message:`This line has ${q} statements. Maximum allowed is ${Z}`,severity:"warning"})}return X}};function yG($){let J=!1,Z=!1,X=!1,Y=!1,z=!1,Q=!1,G="";for(let q=0;q<$.length;q++){let U=$[q];if(Q){Q=!1;continue}if(U==="\\"){Q=!0;continue}if(Y){if(z){if(U==="]")z=!1;continue}if(U==="["){z=!0;continue}if(U==="/"){Y=!1;while(q+1<$.length&&/[a-z]/i.test($[q+1]))q++;G="/"}continue}if(!Z&&!X&&U==="'"){J=!J,G=U;continue}if(!J&&!X&&U==='"'){Z=!Z,G=U;continue}if(!J&&!Z&&U==="`"){X=!X,G=U;continue}if(J||Z||X)continue;if(U==="/"&&$[q+1]==="/")return q;if(U==="/"&&Q6(G,$,q)){Y=!0;continue}if(U!==" "&&U!=="\t")G=U}return-1}function Q6($,J,Z){if($==="")return!0;if("([{,:;!?&|=<>~^+*%-".includes($))return!0;if(/[A-Za-z_$]/.test($)){if(J.slice(0,Z).trimEnd().match(/(?:^|[^A-Za-z0-9_$])(return|typeof|instanceof|new|delete|void|in|of|yield|await|throw|case)$/))return!0}return!1}function G6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var q6={meta:{docs:"Enforce consistent multiline ternary expressions",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=z.indexOf("?");if(G===-1)continue;if(z[G+1]==="."||z[G+1]==="?")continue;if(G6(z,G))continue;if(z.indexOf(":",G+1)!==-1)continue;for(let U=Y+1;U<Math.min(Y+10,X.length);U++){let W=X[U].trim();if(W.startsWith(":"))break;let K=W.indexOf(":");if(K>0&&!G6(X[U],K)){if(W.match(/^\w+\s*:/)||W.match(/^case\b/))continue;Z.push({filePath:J.filePath,line:U+1,column:X[U].indexOf(":")+1,ruleId:"style/multiline-ternary",message:"In multiline ternary, ':' should be at the start of the line",severity:"warning"});break}}}return Z}};var U6=new RegExp("\\bnew\\s+([A-Z][a-zA-Z0-9_$.]+)(?![a-zA-Z0-9_$])(?:\\s*<[^>]*>)?\\s*(?=[^(;\\n]|$)","g");function bG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var W6={meta:{docs:"Require parentheses when invoking a constructor with no arguments",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;U6.lastIndex=0;while((G=U6.exec(z))!==null){if(bG(z,G.index))continue;if(z.slice(G.index+G[0].length).startsWith("("))continue;if(G[0].includes("new."))continue;Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"style/new-parens",message:`Missing parentheses invoking constructor '${G[1]}'`,severity:"warning",help:"Add () after the constructor name."})}}return Z},fix($){return $.replace(/\bnew\s+([A-Z][a-zA-Z0-9_$.]+)(?![a-zA-Z0-9_$])(\s*<[^>]*>)?\s*(?=[^(]|$)/g,(J,Z,X)=>{if(J.slice(J.indexOf(Z)+Z.length+(X?.length||0)).trim().startsWith("("))return J;return`new ${Z}${X||""}()`})}};var Nw=new RegExp("\\breturn\\s+\\(([^()]*)\\)\\s*[;\\n]","g"),K6=/^[a-zA-Z_$][a-zA-Z0-9_$.[\]'"`]*$/;var H6={meta:{docs:"Remove redundant parentheses in return statements",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=new RegExp("^return\\s+\\(([^()]*)\\)\\s*;?\\s*$"),q=Q.match(G);if(q){let U=q[1].trim();if(K6.test(U)||/^['"`]/.test(U)||/^\d/.test(U)||U==="true"||U==="false"||U==="null"||U==="undefined")Z.push({filePath:J.filePath,line:Y+1,column:z.indexOf("(")+1,ruleId:"style/no-extra-parens",message:"Unnecessary parentheses around return value",severity:"warning",help:"Remove the outer parentheses."})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X.trim(),z=new RegExp("^return\\s+\\(([^()]*)\\)\\s*(;?)\\s*$"),Q=Y.match(z);if(Q){let G=Q[1].trim(),q=Q[2];if(K6.test(G)||/^['"`]/.test(G)||/^\d/.test(G)||G==="true"||G==="false"||G==="null"||G==="undefined"){let U=X.match(/^(\s*)/)?.[1]||"";Z.push(`${U}return ${G}${q}`);continue}}Z.push(X)}return Z.join(`
170
- `)}};var V6=/(\S)\s+(\.)[a-zA-Z_$]/g,A6=/(\S)\s+(\?\.)[a-zA-Z_$]/g;function x8($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var _6={meta:{docs:"Disallow whitespace before . or ?. in property access",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;V6.lastIndex=0;while((G=V6.exec(z))!==null){let q=G.index+G[0].indexOf(".");if(x8(z,G.index))continue;if(q+1<z.length&&z[q+1]===".")continue;if(q>0&&z[q-1]===".")continue;Z.push({filePath:J.filePath,line:Y+1,column:q+1,ruleId:"style/no-whitespace-before-property",message:"Unexpected whitespace before property access dot",severity:"warning"})}A6.lastIndex=0;while((G=A6.exec(z))!==null){let q=G.index+G[0].indexOf("?.");if(x8(z,G.index))continue;Z.push({filePath:J.filePath,line:Y+1,column:q+1,ruleId:"style/no-whitespace-before-property",message:"Unexpected whitespace before optional chaining operator",severity:"warning"})}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y=0;Y<Z.length;Y++){let z=Z[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*")){X.push(z);continue}let G=z;G=G.replace(/(\S)\s+(\?\.[a-zA-Z_$])/g,(q,U,W,K)=>{if(x8(z,K))return q;return U+W}),G=G.replace(/(\S)\s+(\.[a-zA-Z_$])/g,(q,U,W,K)=>{if(x8(z,K))return q;let H=K+q.indexOf(".");if(H+1<G.length&&G[H+1]===".")return q;return U+W}),X.push(G)}return X.join(`
171
- `)}};function M1($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var F6=/&&/g,B6=/\|\|/g,w6=/\?\?/g,M6=/(?<![&])&(?![&=])/g,j6=/(?<![|])\|(?![|=])/g,N6=/\^(?!=)/g;function kG($){let J=[];F6.lastIndex=0;let Z;while((Z=F6.exec($))!==null)if(!M1($,Z.index))J.push({op:"&&",group:0,index:Z.index});B6.lastIndex=0;while((Z=B6.exec($))!==null)if(!M1($,Z.index))J.push({op:"||",group:1,index:Z.index});w6.lastIndex=0;while((Z=w6.exec($))!==null)if(!M1($,Z.index))J.push({op:"??",group:2,index:Z.index});M6.lastIndex=0;while((Z=M6.exec($))!==null)if(!M1($,Z.index))J.push({op:"&",group:3,index:Z.index});j6.lastIndex=0;while((Z=j6.exec($))!==null)if(!M1($,Z.index))J.push({op:"|",group:4,index:Z.index});N6.lastIndex=0;while((Z=N6.exec($))!==null)if(!M1($,Z.index))J.push({op:"^",group:5,index:Z.index});return J.sort((X,Y)=>X.index-Y.index)}function fG($,J){if(J.length<2)return!0;let Z=[];for(let z of J){let Q=0;for(let G=0;G<z.index;G++)if($[G]==="(")Q++;else if($[G]===")")Q--;Z.push(Q)}let X=new Map;for(let z=0;z<J.length;z++){let Q=J[z].group;if(!X.has(Q))X.set(Q,[]);X.get(Q).push(Z[z])}let Y=[...X.entries()];if(Y.length===2){let[,z]=Y[0],[,Q]=Y[1],G=Math.min(...z),q=Math.max(...z),U=Math.min(...Q),W=Math.max(...Q);if(G>W||U>q)return!0}return!1}var gG=[{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 ^"}],T6={meta:{docs:"Disallow mixed logical/bitwise operators without parentheses",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=kG(z);if(G.length<2)continue;let q=new Set(G.map((U)=>U.group));for(let U of gG)if(q.has(U.groups[0])&&q.has(U.groups[1])){let W=G.filter((K)=>K.group===U.groups[0]||K.group===U.groups[1]);if(!fG(z,W)){let K=W.find((H)=>H.group===U.groups[1]);if(K)Z.push({filePath:J.filePath,line:Y+1,column:K.index+1,ruleId:"style/no-mixed-operators",message:`Unexpected mix of ${U.label} without parentheses`,severity:"warning"})}}}return Z}};var E6=/(?<![0-9.])\.\d/g,D6=/\d\.(?!\d|\.|\w)/g;function R6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var O6={meta:{docs:"Disallow floating decimals like .5 or 2.",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;E6.lastIndex=0;while((G=E6.exec(z))!==null){if(R6(z,G.index))continue;if(G.index>0){let q=z[G.index-1];if(/[a-zA-Z_$)\]]/.test(q))continue}Z.push({filePath:J.filePath,line:Y+1,column:G.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"})}D6.lastIndex=0;while((G=D6.exec(z))!==null){if(R6(z,G.index))continue;Z.push({filePath:J.filePath,line:Y+1,column:G.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 Z},fix($){let J=$;return J=J.replace(/(?<![a-zA-Z_$0-9.)\]])\.\d/g,(Z)=>`0${Z}`),J=J.replace(/(\d)\.(?!\d|\.|\w)/g,(Z,X)=>`${X}.0`),J}};var L6={meta:{docs:"Disallow mixed spaces and tabs for indentation",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let Q=X[Y].match(/^(\s*)/)?.[1]||"";if(!Q)continue;let G=Q.includes("\t"),q=Q.includes(" ");if(G&&q)Z.push({filePath:J.filePath,line:Y+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 Z}};var P6={meta:{docs:"Disallow multiple consecutive spaces",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(!z.trim())continue;let Q=z.match(/^(\s*)/)?.[1]||"",G=z.slice(Q.length),q=/ {2,}/g,U;for(U=q.exec(G);U!==null;U=q.exec(G)){let W=Q.length+U.index+1,K=G.slice(0,U.index),H=(K.match(/'/g)||[]).length,V=(K.match(/"/g)||[]).length,A=(K.match(/`/g)||[]).length;if(H%2===1||V%2===1||A%2===1)continue;if(K.includes("//"))continue;if(z.trim().startsWith("*")||z.trim().startsWith("/*"))continue;Z.push({filePath:J.filePath,line:Y+1,column:W,ruleId:"style/no-multi-spaces",message:"Multiple spaces found",severity:"warning",help:"Remove extra spaces. Use single spaces between tokens."})}}return Z}};var C6={meta:{docs:"Disallow multiple consecutive blank lines",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=0,z=-1;for(let Q=0;Q<X.length;Q++)if(X[Q].trim()===""){if(Y++,z===-1)z=Q;if(Y>1&&Q===z+Y-1)Z.push({filePath:J.filePath,line:Q+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 Y=0,z=-1;return Z}};var I6={meta:{docs:"Disallow tab characters (when using spaces for indentation)",recommended:!1},check($,J){let Z=[];if(J.config.format?.indentStyle==="tabs")return Z;let X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let Q=X[Y].indexOf("\t");if(Q!==-1)Z.push({filePath:J.filePath,line:Y+1,column:Q+1,ruleId:"style/no-tabs",message:"Unexpected tab character",severity:"warning",help:"Use spaces for indentation instead of tabs."})}return Z},fix($,J){let Z=J.config.format?.indent??2;return $.replace(/\t/g," ".repeat(Z))}};var S6={meta:{docs:"Disallow trailing whitespace at the end of lines",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.match(/(\s+)$/);if(Q){let G=z.length-Q[1].length+1;Z.push({filePath:J.filePath,line:Y+1,column:G,ruleId:"style/no-trailing-spaces",message:"Trailing spaces not allowed",severity:"error",help:"Remove trailing whitespace from the end of this line."})}}return Z}};function v6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var y6={meta:{docs:"Require spaces inside curly braces in objects and destructuring",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G=0;G<z.length;G++){if(z[G]==="{"&&!v6(z,G)){let q=z[G+1];if(q==="}"||q===void 0||q===`
172
- `)continue;if(G>0&&z[G-1]==="$")continue;if(q!==" "&&q!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:G+2,ruleId:"style/object-curly-spacing",message:"Missing space after '{'",severity:"warning"})}if(z[G]==="}"&&!v6(z,G)){let q=G>0?z[G-1]:void 0;if(q==="{"||q===void 0||q===`
158
+ `)X++;Z("LineComment",q,X);continue}if($[X+1]==="*"){let q=X;X+=2;while(X<Y&&!($[X]==="*"&&$[X+1]==="/"))X++;X=Math.min(Y,X+2),Z("BlockComment",q,X);continue}if(LG(J)){let q=X;X++;while(X<Y){let U=$[X];if(U==="\\"){X+=2;continue}if(U==="/"){X++;break}X++}while(X<Y&&/[a-z]/i.test($[X]))X++;Z("Regex",q,X);continue}Z("Punct",X,X+1),X++;continue}if("(){}[];:,.<>+-*%&|^!?=~".includes(z)){Z("Punct",X,X+1),X++;continue}let Q=X,G=new RegExp("[^\\s(){}[\\];:,.<>+\\-*%&|^!?=~'\"`/]");while(X<Y&&G.test($[X]))X++;if(X>Q)Z("Word",Q,X);else Z("Word",X,X+1),X++}return J}function LG($){if($.length===0)return!0;let J=$[$.length-1],Z=new RegExp("[(!,{;:?=]");return J.type==="Punct"&&Z.test(J.value)||J.type==="Word"&&/^(?:return|throw|case|of|in|instanceof|typeof|void|new)$/.test(J.value)}function x5($,J,Z,X){let Y=0,z=(K)=>K<=" ",Q=(K)=>{while(K<$.length&&$[K]!==`
159
+ `)K++;return K},G=(K)=>{K+=2;while(K<$.length&&!($[K]==="*"&&$[K+1]==="/"))K++;return Math.min($.length,K+2)},q=(K,H)=>{let V=$.length;if(H==="`"){K++;let A=0;while(K<V){let _=$[K];if(_==="\\"){K+=2;continue}if(_==="`"&&A===0){K++;break}if(_==="$"&&$[K+1]==="{"){A++,K+=2;continue}if(_==="}"&&A>0){A--,K++;continue}if(_==='"'||_==="'"){K=q(K,_);continue}if(_==="/"&&$[K+1]==="/"){K=Q(K+2);continue}if(_==="/"&&$[K+1]==="*"){K=G(K);continue}K++}return K}K++;while(K<V){let A=$[K];if(A==="\\"){K+=2;continue}if(A===H){K++;break}K++}return K},U=(K)=>{let H=K-1;while(H>=0&&z($[H]))H--;let V=H>=0?$[H]:"";if(new RegExp("[(:[{;?,=!&|^~+\\-*%<>]").test(V))return!0;if(V==="")return!0;return!1},W=(K)=>{K++;let H=$.length;while(K<H){let V=$[K];if(V==="\\"){K+=2;continue}if(V==="/"){K++;break}K++}while(K<H&&/[a-z]/i.test($[K]))K++;return K};for(let K=J;K<$.length;K++){let H=$[K];if(H===Z){Y++;continue}if(H===X){if(Y--,Y===0)return K;continue}if(H==='"'||H==="'"||H==="`"){K=q(K,H)-1;continue}if(H==="/"&&$[K+1]==="/"){K=Q(K+2)-1;continue}if(H==="/"&&$[K+1]==="*"){K=G(K)-1;continue}if(H==="/"&&U(K)){K=W(K)-1;continue}}return-1}function k8($,J,Z,X,Y,z,Q){let G=x5($,X,Y,z);if(G<=X)return;let q=$.slice(X+1,G),U=/\r?\n/.test(q),W=g5($),K=[],H=0,V=X+1,A=p5($.slice(X+1,G)),_=0;for(let F of A){let M=X+1+F.start,T=X+1+F.end;if(_=T,F.type==="Punct"){if(F.value===Y)H++;else if(F.value===z&&H>0)H--;else if(F.value===","&&H===0)K.push({start:V,end:M}),V=T}}if(K.push({start:V,end:G}),!U){for(let F of K){let M=$.slice(F.start,F.end);if(/\r?\n/.test(M)){let T=W.indexToLoc(F.start);Z.push({filePath:J,line:T.line,column:T.column,ruleId:Q,message:"Should not have line breaks between items",severity:"warning"});break}}return}let B=q.indexOf(`
160
+ `);if(B>0){let F=q.slice(0,B),M=(F.match(/,/g)||[]).length,T=q.slice(B+1),E=T.includes(`
161
+ `),j=T.includes(",");if(M>=1&&/\S,\s*\S/.test(F)&&!E&&!j){let O=W.indexToLoc(X+1+B+1);Z.push({filePath:J,line:O.line,column:O.column,ruleId:Q,message:"Should not have line breaks between items",severity:"warning"});return}else if(M>=1&&/\S,\s*\S/.test(F)){let O=W.indexToLoc(X+1+F.search(/,\s*\S/));Z.push({filePath:J,line:O.line,column:O.column,ruleId:Q,message:"Should have line breaks between items",severity:"warning"});return}}for(let F of K){let M=$.slice(X+1,F.start);if(!/\n[ \t]*$/.test(M)&&M.trim()!==""){let T=W.indexToLoc(F.start);Z.push({filePath:J,line:T.line,column:T.column,ruleId:Q,message:"Should have line breaks between items",severity:"warning"});break}}}var h5={meta:{docs:"Enforce consistent newlines for list-like constructs (objects, arrays, named imports/exports)"},check:($,J)=>{let Z=[],X="style/consistent-list-newline";for(let Y=0;Y<$.length;Y++){let z=$[Y];if(z==="{"){let Q=Y-1;while(Q>=0&&/[ \t]/.test($[Q]))Q--;if(Q>=0&&$[Q]===")")continue;let G=$.slice(Math.max(0,Y-60),Y);if(/\b(?:function|class|interface|type|enum|try|catch|finally|if|else|for|while|switch)\b[\s\S]*$/.test(G))continue;k8($,J.filePath,Z,Y,"{","}","style/consistent-list-newline")}else if(z==="[")k8($,J.filePath,Z,Y,"[","]","style/consistent-list-newline");else if(z==="i"&&$.startsWith("import",Y)){let Q=$.indexOf("{",Y);if(Q>-1)k8($,J.filePath,Z,Q,"{","}","style/consistent-list-newline")}else if(z==="e"&&$.startsWith("export",Y)){let Q=$.indexOf("{",Y);if(Q>-1)k8($,J.filePath,Z,Q,"{","}","style/consistent-list-newline")}}return Z}};function PG($){let J=$.trim();return J===""||J.startsWith("//")||J.startsWith("/*")}function z9($,J){for(let Z=J;Z<$.length;Z++)if(!PG($[Z]))return Z;return-1}function j1($,J,Z){if($[J].slice(Z).includes("{"))return!0;let Y=z9($,J+1);if(Y>=0){if($[Y].trim().startsWith("{"))return!0}return!1}function f8($,J,Z){let X=$[J].slice(Z);if(/\bif\b|\bfor\b|\bwhile\b|\bdo\b/.test(X))return!0;return!1}var u5={meta:{docs:"Enforce curly brackets similar to src-2: require braces when any branch/body requires them"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let z=0;z<X.length;z++){let Q=X[z],G=Q.match(/^(\s*)if\s*\(([^)]*)\)/);if(G){let U=G[0].length,W=j1(X,z,U),K=f8(X,z,U),H=z,V=W,A=K;while(!0){let _=z9(X,H+1);if(_<0)break;let B=X[_].trim();if(!B.startsWith("else"))break;let F=B.match(/^else\s+if\s*\(([^)]*)\)/);if(F){let M=X[_].indexOf(F[0])+F[0].length;V=V||j1(X,_,M),A=A||f8(X,_,M),H=_;continue}else{let M=X[_].indexOf("else")+4;V=V||j1(X,_,M),A=A||f8(X,_,M),H=_;break}}if(V||A){if(!W)Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,Q.indexOf("if")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});let _=z;while(!0){let B=z9(X,_+1);if(B<0)break;let F=X[B],M=F.trim();if(!M.startsWith("else"))break;let T=M.match(/^else\s+if\s*\(([^)]*)\)/);if(T){let E=F.indexOf(T[0])+T[0].length;if(!j1(X,B,E))Z.push({filePath:J.filePath,line:B+1,column:Math.max(1,F.indexOf("else")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});_=B;continue}else{let E=F.indexOf("else")+4;if(!j1(X,B,E))Z.push({filePath:J.filePath,line:B+1,column:Math.max(1,F.indexOf("else")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});break}}}}let q=Q.match(/^(\s*)(while|do|for|for\s+await)\b/);if(q){let U=q[0].length,W=j1(X,z,U),K=f8(X,z,U);if((W||K)&&!W)Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,Q.indexOf(q[2])+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"})}}let Y=CG($,J.filePath);for(let z of Y)Z.push({filePath:J.filePath,line:z.line,column:z.column,ruleId:"style/curly",message:z.message,severity:"warning"});return Z}};function CG($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim(),G=/^if\s*\(/.test(Q)?"if":/^else\s+if\s*\(/.test(Q)?"else-if":/^else\b/.test(Q)?"else":null;if(!G)continue;let q=0;if(G==="if"){let A=z.match(/if\s*\([^)]*\)/);q=A?z.indexOf(A[0])+A[0].length:z.indexOf("if")+2}else if(G==="else-if"){let A=z.match(/else\s+if\s*\([^)]*\)/);q=A?z.indexOf(A[0])+A[0].length:z.indexOf("else")+4}else q=z.indexOf("else")+4;let U=Y,W=z.indexOf("{",q);if(W<0){let A=function(B){for(let F=B;F<X.length;F++)if(X[F].trim()!=="")return F;return-1}(Y+1);if(A<0)continue;if(W=X[A].indexOf("{"),W<0)continue;U=A}let K=0,H=-1;for(let A=U;A<X.length;A++){let _=X[A],B=A===U?Math.max(0,W):0;for(let F=B;F<_.length;F++){let M=_[F];if(M==="{")K++;else if(M==="}"){if(K--,K===0){H=A;break}}}if(H>=0)break}if(H<0)continue;let V=[];for(let A=U+1;A<H;A++){let _=X[A].trim();if(_===""||/^\/\//.test(_))continue;if(V.push(_),V.length>1)break}if(V.length===1&&H===U+2){let A=V[0],_=/^(?:if|for|while|do|switch|try|catch|else)\b/.test(A),B=/[{}]/.test(A),F=(A.match(/\(/g)||[]).length,M=(A.match(/\)/g)||[]).length,T=F!==M,E=!1;for(let j=Y+1;j<X.length;j++){let O=X[j].trim();if(O===""||O==="}"||/^\/\//.test(O))continue;if(!/^else\b/.test(O))break;let v=X[j].indexOf("else")+4,y=O.match(/^else\s+if\s*\([^)]*\)/);if(y)v=X[j].indexOf(y[0])+y[0].length;let C=j,k=X[j].indexOf("{",v);if(k<0){let I=function(S){for(let N=S;N<X.length;N++)if(X[N].trim()!=="")return N;return-1}(j+1);if(I<0)break;if(k=X[I].indexOf("{"),k<0)continue;C=I}let P=0,L=-1;for(let I=C;I<X.length;I++){let f=X[I],S=I===C?Math.max(0,k):0;for(let N=S;N<f.length;N++){let R=f[N];if(R==="{")P++;else if(R==="}"){if(P--,P===0){L=I;break}}}if(L>=0)break}if(L>=0){let I=0;for(let f=C+1;f<L;f++){let S=X[f].trim();if(S===""||/^\/\//.test(S))continue;if(I++,I>1){E=!0;break}}}if(E)break}if(!E&&G==="if"){let j=function(v){for(let y=v;y<X.length;y++){let C=X[y].trim();if(C!==""&&C!=="}"&&!/^\/\//.test(C))return y}return-1}(H+1);if(j>=0&&/^else\b/.test(X[j].trim())){let O=X[j].indexOf("else")+4,v=X[j].trim().match(/^else\s+if\s*\([^)]*\)/);if(v)O=X[j].indexOf(v[0])+v[0].length;let y=j,C=X[j].indexOf("{",O);if(C<0){let k=function(L){for(let I=L;I<X.length;I++)if(X[I].trim()!=="")return I;return-1}(j+1);if(k>=0)C=X[k].indexOf("{"),y=C>=0?k:y}if(C>=0){let k=0,P=-1;for(let L=y;L<X.length;L++){let I=X[L],f=L===y?Math.max(0,C):0;for(let S=f;S<I.length;S++){let N=I[S];if(N==="{")k++;else if(N==="}"){if(k--,k===0){P=L;break}}}if(P>=0)break}if(P>=0){let L=0;for(let I=y+1;I<P;I++){let f=X[I].trim();if(f===""||/^\/\//.test(f))continue;if(++L>1){E=!0;break}}}}}}if(!_&&!B&&!T&&!E)Z.push({line:U+1,column:Math.max(1,X[U].indexOf("{")+1),message:"Unnecessary curly braces around single statement"})}}return Z}var m5={meta:{docs:"Enforce dot on the property line in chained method calls",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=i0($);for(let z=0;z<X.length;z++){let Q=X[z],G=Q.trim();if(!G||G.startsWith("//")||G.startsWith("*")||G.startsWith("/*"))continue;if(Y[z+1])continue;if(G.endsWith(".")&&z+1<X.length){let q=X[z+1].trim();if(q&&/^[a-zA-Z_$]/.test(q))Z.push({filePath:J.filePath,line:z+1,column:Q.length,ruleId:"style/dot-location",message:"Dot should be on the same line as the property",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[],X=i0($);for(let Y=0;Y<J.length;Y++){let z=J[Y];if(z.trim().endsWith(".")&&!X[Y+1]&&Y+1<J.length){let G=J[Y+1],q=G.trim();if(q&&/^[a-zA-Z_$]/.test(q)){Z.push(z.replace(/\.\s*$/,""));let U=G.match(/^(\s*)/)?.[1]||"";J[Y+1]=`${U}.${q}`;continue}}Z.push(z)}return Z.join(`
162
+ `)}};function d5($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var o5=["===","!==",">>>","==","!=",">=","<=","&&","||","??","**","<<",">>","+","-","*","/","%","|","&","^",">","<","instanceof","in"],Kw=new RegExp(`^(${o5.map(($)=>$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})\\s`),IG=new Set(["in","instanceof"]),SG=/^(?:instanceof|in)\s/;function g8($){if(SG.test($))return!0;for(let J of o5){if(IG.has(J))continue;if($.startsWith(J)){let Z=$[J.length];if(Z===void 0||Z===" "||Z==="\t")return!0}}return!1}function Q9($){let J=$.match(/^(\s*)/);return J?J[1].length:0}var c5={meta:{docs:"Enforce consistent indentation of continuation lines in multiline binary expressions",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;if(!g8(Q))continue;if(d5(z,0))continue;let G=Y-1;while(G>=0){let W=X[G].trim();if(!W||W.startsWith("//")||W.startsWith("*")||W.startsWith("/*")){G--;continue}if(g8(W)){G--;continue}break}if(G<0)continue;let q=Q9(X[G])+2,U=Q9(z);if(U!==q)Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/indent-binary-ops",message:`Expected indentation of ${q} spaces for binary operator continuation, but found ${U}`,severity:"warning"})}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y=0;Y<Z.length;Y++){let z=Z[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*")){X.push(z);continue}if(!g8(Q)||d5(z,0)){X.push(z);continue}let G=-1;for(let W=X.length-1;W>=0;W--){let K=X[W].trim();if(!K||K.startsWith("//")||K.startsWith("*")||K.startsWith("/*"))continue;if(g8(K))continue;G=W;break}if(G<0){X.push(z);continue}let q=Q9(X[G])+2,U=" ".repeat(q)+Q;X.push(U);continue}return X.join(`
163
+ `)}};var r5=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"]),p8=/([a-zA-Z_$][a-zA-Z0-9_$]*)\s+\(/g;function l5($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var a5={meta:{docs:"Disallow spaces between function name and opening parenthesis in calls",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;p8.lastIndex=0;while((G=p8.exec(z))!==null){let q=G[1],U=G.index;if(l5(z,U))continue;if(r5.has(q))continue;let W=z.slice(0,U).trimEnd();if(W.endsWith("function")||W.endsWith("function*"))continue;if(/\b(?:get|set)\s*$/.test(W))continue;let K=U+q.length;Z.push({filePath:J.filePath,line:Y+1,column:K+1,ruleId:"style/function-call-spacing",message:"Unexpected space between function name and parenthesis",severity:"warning"})}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y=0;Y<Z.length;Y++){let z=Z[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*")){X.push(z);continue}let G=z,q=[],U;p8.lastIndex=0;while((U=p8.exec(z))!==null){let W=U[1],K=U.index;if(l5(z,K))continue;if(r5.has(W))continue;let H=z.slice(0,K).trimEnd();if(H.endsWith("function")||H.endsWith("function*"))continue;if(/\b(?:get|set)\s*$/.test(H))continue;q.push({index:K,fullMatch:U[0],identifier:W})}for(let W=q.length-1;W>=0;W--){let K=q[W],H=K.index,V=H+K.fullMatch.length;G=`${G.slice(0,H)}${K.identifier}(${G.slice(V)}`}X.push(G)}return X.join(`
164
+ `)}};var s5=/\bfunction\s*\*/g;function n5($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var i5={meta:{docs:"Enforce spacing around * in generator functions (space after, no space before)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;s5.lastIndex=0;while((G=s5.exec(z))!==null){let U=G.index;if(n5(z,U))continue;let W=G[0],K=U+W.indexOf("*"),H=K+1;if(W!=="function*")Z.push({filePath:J.filePath,line:Y+1,column:K+1,ruleId:"style/generator-star-spacing",message:"Unexpected space before * in generator function",severity:"warning"});if(H<z.length&&z[H]!==" "&&z[H]!=="\t"&&z[H]!==`
165
+ `&&z[H]!=="(")Z.push({filePath:J.filePath,line:Y+1,column:H+1,ruleId:"style/generator-star-spacing",message:"Missing space after * in generator function",severity:"warning"})}if(Q.match(/^(?:async\s+)?\*\s*([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/)){let U=z.indexOf("*",z.indexOf(Q.charAt(0)));if(!n5(z,U)){let W=U+1;if(W<z.length&&z[W]!==" "&&z[W]!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"style/generator-star-spacing",message:"Missing space after * in generator method",severity:"warning"})}}}return Z},fix($,J){let Z=$;return Z=Z.replace(/\bfunction\s+\*/g,"function*"),Z=Z.replace(/\bfunction\*([a-zA-Z_$])/g,"function* $1"),Z=Z.replace(/(^\s*(?:async\s+)?)\*([a-zA-Z_$])/gm,"$1* $2"),Z}};var t5={meta:{docs:"Enforce newline after if when without braces"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(!z.match(/^\s*if\s*\([^)]*\)\s*([^\s{/].*)$/))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf("if")+1),ruleId:"style/if-newline",message:"Expect newline after if",severity:"warning"})}return Z}};var vG=["$","unindent","unIndent"],e5={meta:{docs:"Enforce consistent indentation inside unindent-style tagged templates"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.match(/^\s*/)?.[0]??"",G=/([$A-Z_][\w$]*)\s*`/gi,q;while(q=G.exec(z)){let U=q[1];if(!vG.includes(U))continue;if(z.slice(q.index+q[0].length).includes("`"))continue;let K=-1;for(let V=Y+1;V<X.length;V++)if(X[V].includes("`")){K=V;break}if(K<0)continue;let H=`${Q} `;for(let V=Y+1;V<K;V++){let A=X[V];if(A.trim()==="")continue;let _=A.match(/^\s*/)?.[0]??"";if(!_.startsWith(H)){Z.push({filePath:J.filePath,line:V+1,column:(_.length||0)+1,ruleId:"style/indent-unindent",message:"Consistent indentation in unindent tag",severity:"warning"});break}}}}return Z}};var yG=/^(\s*)(["']?[a-zA-Z_$][a-zA-Z0-9_$]*["']?\s*(?:\?)?):(\S)/;function $6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var Z6={meta:{docs:"Require space after colon in object properties",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=z.match(yG);if(G){let U=z.indexOf(":",G[1].length);if(U!==-1&&!$6(z,U)){let W=z[U+1];if(W&&W!==" "&&W!=="\t"&&W!==`
166
+ `)Z.push({filePath:J.filePath,line:Y+1,column:U+2,ruleId:"style/key-spacing",message:"Missing space after colon in property",severity:"warning"})}}let q=Q.match(/^(["']?[a-zA-Z_$][a-zA-Z0-9_$]*["']?)\s+:/);if(q&&!Q.match(/^\s*(case|default)\b/)){let U=z.indexOf(":",z.indexOf(q[1])+q[1].length);if(U!==-1&&!$6(z,U))Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/key-spacing",message:"Unexpected space before colon in property",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.replace(/^(\s*)(["']?[a-zA-Z_$][a-zA-Z0-9_$]*["']?\s*(?:\?)?):(\S)/,"$1$2: $3"),Z.push(Y)}return Z.join(`
167
+ `)}};var bG=["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"],J6=new RegExp(`(?:^|[^\\w$.])(${bG.join("|")})(?=[^\\w$]|$)`,"g");function kG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var X6={meta:{docs:"Require space before and after keywords",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;J6.lastIndex=0;while((G=J6.exec(z))!==null){let q=G[0].charAt(0)===G[1].charAt(0)?"":G[0].charAt(0),U=G.index+q.length,W=U+G[1].length;if(kG(z,U))continue;if(U>0){let K=z[U-1];if(K===")"||K==="}")Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/keyword-spacing",message:`Missing space before keyword '${G[1]}'`,severity:"warning"})}if(W<z.length){let K=z[W];if(K!==" "&&K!=="\t"&&K!==";"&&K!==","&&K!==":"&&K!=="."){if(K==="("&&(G[1]==="if"||G[1]==="for"||G[1]==="while"||G[1]==="switch"||G[1]==="catch"))Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"style/keyword-spacing",message:`Missing space after keyword '${G[1]}'`,severity:"warning"})}}}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;for(let z of["if","for","while","switch","catch"]){let Q=new RegExp(`(\\b${z})\\(`,"g");Y=Y.replace(Q,"$1 (")}for(let z of["else","catch","finally"])Y=Y.replace(new RegExp(`\\)${z}\\b`,"g"),`) ${z}`),Y=Y.replace(new RegExp(`\\}${z}\\b`,"g"),`} ${z}`);Z.push(Y)}return Z.join(`
168
+ `)}};var Y6=/^\s*(?:public|private|protected|static|readonly|abstract|override|async|get|set|\*|#|[a-zA-Z_$])/,z6={meta:{docs:"Require blank line between class members",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z=0,Q=0,G=-1;for(let q=0;q<X.length;q++){let W=X[q].trim();if(W.match(/\bclass\b/)&&(W.includes("{")||q+1<X.length&&X[q+1].trim()==="{"))Y=!0,Q=z+1;let K=z;for(let H of W){if(H==="{")z++;if(H==="}")z--}if(Y&&z<Q){Y=!1,G=-1;continue}if(!Y)continue;if(K>Q&&z===Q&&W.endsWith("}")){G=q;continue}if(K===Q){if(!W||W.startsWith("//")||W.startsWith("*")||W.startsWith("/*")||W==="}")continue;if(Y6.test(W)){if(G!==-1&&q===G+1)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"style/lines-between-class-members",message:"Missing blank line between class members",severity:"warning"});if(!W.endsWith("{"))G=q}}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[],Y=!1,z=0,Q=0,G=-1;for(let q=0;q<Z.length;q++){let U=Z[q],W=U.trim();if(W.match(/\bclass\b/)&&(W.includes("{")||q+1<Z.length&&Z[q+1].trim()==="{"))Y=!0,Q=z+1;let K=z;for(let H of W){if(H==="{")z++;if(H==="}")z--}if(Y&&z<Q){Y=!1,G=-1,X.push(U);continue}if(Y&&K>Q&&z===Q&&W.endsWith("}")){G=q,X.push(U);continue}if(Y&&K===Q&&W&&!W.startsWith("//")&&!W.startsWith("*")&&!W.startsWith("/*")&&W!=="}"&&Y6.test(W)){if(G!==-1&&q===G+1)X.push("");if(!W.endsWith("{"))G=q}X.push(U)}return X.join(`
169
+ `)}};var Q6={meta:{docs:"Limit the number of statements allowed on a single line"},check:($,J)=>{let Z=J.options&&typeof J.options.max==="number"?J.options.max:1,X=[],Y=$.split(/\r?\n/),z=(Q)=>{let G=fG(Q),q=G>=0?Q.slice(0,G):Q,U=0,W=!1,K=!1,H=!1,V=!1,A=!1,_=!1,B=!1,F=0,M="",T=(O)=>{if(O===" "||O==="\t")return;M=O};for(let O=0;O<q.length;O++){let v=q[O];if(_){_=!1;continue}if(v==="\\"){_=!0;continue}if(V){if(A){if(v==="]")A=!1;continue}if(v==="["){A=!0;continue}if(v==="/"){V=!1;while(O+1<q.length&&/[a-z]/i.test(q[O+1]))O++;M="/"}continue}if(!K&&!H&&v==="'"){W=!W,T(W?"'":"x");continue}if(!W&&!H&&v==='"'){K=!K,T(K?'"':"x");continue}if(!W&&!K&&v==="`"){H=!H,T(H?"`":"x");continue}if(W||K||H)continue;if(v==="/"&&G6(M,q,O)){V=!0;continue}if(!B){if(v==="f"&&q.slice(O,O+4).match(/^for\b/)){let y=q.slice(O+3).trimStart(),C=q.length-y.length;if(q[C]==="("){B=!0,F=1,O=C,M="(";continue}}}else if(v==="(")F++;else if(v===")"){if(F--,F<=0)B=!1}else if(v===";"){T(v);continue}if(v===";")U++;T(v)}if(U===0)return 1;return q.trimEnd().endsWith(";")?U:U+1};for(let Q=0;Q<Y.length;Q++){let G=Y[Q];if(/^\s*$/.test(G))continue;let q=z(G);if(q>Z)X.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"max-statements-per-line",message:`This line has ${q} statements. Maximum allowed is ${Z}`,severity:"warning"})}return X}};function fG($){let J=!1,Z=!1,X=!1,Y=!1,z=!1,Q=!1,G="";for(let q=0;q<$.length;q++){let U=$[q];if(Q){Q=!1;continue}if(U==="\\"){Q=!0;continue}if(Y){if(z){if(U==="]")z=!1;continue}if(U==="["){z=!0;continue}if(U==="/"){Y=!1;while(q+1<$.length&&/[a-z]/i.test($[q+1]))q++;G="/"}continue}if(!Z&&!X&&U==="'"){J=!J,G=U;continue}if(!J&&!X&&U==='"'){Z=!Z,G=U;continue}if(!J&&!Z&&U==="`"){X=!X,G=U;continue}if(J||Z||X)continue;if(U==="/"&&$[q+1]==="/")return q;if(U==="/"&&G6(G,$,q)){Y=!0;continue}if(U!==" "&&U!=="\t")G=U}return-1}function G6($,J,Z){if($==="")return!0;if("([{,:;!?&|=<>~^+*%-".includes($))return!0;if(/[A-Za-z_$]/.test($)){if(J.slice(0,Z).trimEnd().match(/(?:^|[^A-Za-z0-9_$])(return|typeof|instanceof|new|delete|void|in|of|yield|await|throw|case)$/))return!0}return!1}function q6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var U6={meta:{docs:"Enforce consistent multiline ternary expressions",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=z.indexOf("?");if(G===-1)continue;if(z[G+1]==="."||z[G+1]==="?")continue;if(q6(z,G))continue;if(z.indexOf(":",G+1)!==-1)continue;for(let U=Y+1;U<Math.min(Y+10,X.length);U++){let W=X[U].trim();if(W.startsWith(":"))break;let K=W.indexOf(":");if(K>0&&!q6(X[U],K)){if(W.match(/^\w+\s*:/)||W.match(/^case\b/))continue;Z.push({filePath:J.filePath,line:U+1,column:X[U].indexOf(":")+1,ruleId:"style/multiline-ternary",message:"In multiline ternary, ':' should be at the start of the line",severity:"warning"});break}}}return Z}};var W6=new RegExp("\\bnew\\s+([A-Z][a-zA-Z0-9_$.]+)(?![a-zA-Z0-9_$])(?:\\s*<[^>]*>)?\\s*(?=[^(;\\n]|$)","g");function gG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var K6={meta:{docs:"Require parentheses when invoking a constructor with no arguments",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;W6.lastIndex=0;while((G=W6.exec(z))!==null){if(gG(z,G.index))continue;if(z.slice(G.index+G[0].length).startsWith("("))continue;if(G[0].includes("new."))continue;Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"style/new-parens",message:`Missing parentheses invoking constructor '${G[1]}'`,severity:"warning",help:"Add () after the constructor name."})}}return Z},fix($){return $.replace(/\bnew\s+([A-Z][a-zA-Z0-9_$.]+)(?![a-zA-Z0-9_$])(\s*<[^>]*>)?\s*(?=[^(]|$)/g,(J,Z,X)=>{if(J.slice(J.indexOf(Z)+Z.length+(X?.length||0)).trim().startsWith("("))return J;return`new ${Z}${X||""}()`})}};var Ew=new RegExp("\\breturn\\s+\\(([^()]*)\\)\\s*[;\\n]","g"),H6=/^[a-zA-Z_$][a-zA-Z0-9_$.[\]'"`]*$/;var V6={meta:{docs:"Remove redundant parentheses in return statements",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=new RegExp("^return\\s+\\(([^()]*)\\)\\s*;?\\s*$"),q=Q.match(G);if(q){let U=q[1].trim();if(H6.test(U)||/^['"`]/.test(U)||/^\d/.test(U)||U==="true"||U==="false"||U==="null"||U==="undefined")Z.push({filePath:J.filePath,line:Y+1,column:z.indexOf("(")+1,ruleId:"style/no-extra-parens",message:"Unnecessary parentheses around return value",severity:"warning",help:"Remove the outer parentheses."})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X.trim(),z=new RegExp("^return\\s+\\(([^()]*)\\)\\s*(;?)\\s*$"),Q=Y.match(z);if(Q){let G=Q[1].trim(),q=Q[2];if(H6.test(G)||/^['"`]/.test(G)||/^\d/.test(G)||G==="true"||G==="false"||G==="null"||G==="undefined"){let U=X.match(/^(\s*)/)?.[1]||"";Z.push(`${U}return ${G}${q}`);continue}}Z.push(X)}return Z.join(`
170
+ `)}};var A6=/(\S)\s+(\.)[a-zA-Z_$]/g,_6=/(\S)\s+(\?\.)[a-zA-Z_$]/g;function x8($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var F6={meta:{docs:"Disallow whitespace before . or ?. in property access",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;A6.lastIndex=0;while((G=A6.exec(z))!==null){let q=G.index+G[0].indexOf(".");if(x8(z,G.index))continue;if(q+1<z.length&&z[q+1]===".")continue;if(q>0&&z[q-1]===".")continue;Z.push({filePath:J.filePath,line:Y+1,column:q+1,ruleId:"style/no-whitespace-before-property",message:"Unexpected whitespace before property access dot",severity:"warning"})}_6.lastIndex=0;while((G=_6.exec(z))!==null){let q=G.index+G[0].indexOf("?.");if(x8(z,G.index))continue;Z.push({filePath:J.filePath,line:Y+1,column:q+1,ruleId:"style/no-whitespace-before-property",message:"Unexpected whitespace before optional chaining operator",severity:"warning"})}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y=0;Y<Z.length;Y++){let z=Z[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*")){X.push(z);continue}let G=z;G=G.replace(/(\S)\s+(\?\.[a-zA-Z_$])/g,(q,U,W,K)=>{if(x8(z,K))return q;return U+W}),G=G.replace(/(\S)\s+(\.[a-zA-Z_$])/g,(q,U,W,K)=>{if(x8(z,K))return q;let H=K+q.indexOf(".");if(H+1<G.length&&G[H+1]===".")return q;return U+W}),X.push(G)}return X.join(`
171
+ `)}};function N1($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var B6=/&&/g,w6=/\|\|/g,M6=/\?\?/g,j6=/(?<![&])&(?![&=])/g,N6=/(?<![|])\|(?![|=])/g,T6=/\^(?!=)/g;function pG($){let J=[];B6.lastIndex=0;let Z;while((Z=B6.exec($))!==null)if(!N1($,Z.index))J.push({op:"&&",group:0,index:Z.index});w6.lastIndex=0;while((Z=w6.exec($))!==null)if(!N1($,Z.index))J.push({op:"||",group:1,index:Z.index});M6.lastIndex=0;while((Z=M6.exec($))!==null)if(!N1($,Z.index))J.push({op:"??",group:2,index:Z.index});j6.lastIndex=0;while((Z=j6.exec($))!==null)if(!N1($,Z.index))J.push({op:"&",group:3,index:Z.index});N6.lastIndex=0;while((Z=N6.exec($))!==null)if(!N1($,Z.index))J.push({op:"|",group:4,index:Z.index});T6.lastIndex=0;while((Z=T6.exec($))!==null)if(!N1($,Z.index))J.push({op:"^",group:5,index:Z.index});return J.sort((X,Y)=>X.index-Y.index)}function xG($,J){if(J.length<2)return!0;let Z=[];for(let z of J){let Q=0;for(let G=0;G<z.index;G++)if($[G]==="(")Q++;else if($[G]===")")Q--;Z.push(Q)}let X=new Map;for(let z=0;z<J.length;z++){let Q=J[z].group;if(!X.has(Q))X.set(Q,[]);X.get(Q).push(Z[z])}let Y=[...X.entries()];if(Y.length===2){let[,z]=Y[0],[,Q]=Y[1],G=Math.min(...z),q=Math.max(...z),U=Math.min(...Q),W=Math.max(...Q);if(G>W||U>q)return!0}return!1}var hG=[{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 ^"}],E6={meta:{docs:"Disallow mixed logical/bitwise operators without parentheses",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=pG(z);if(G.length<2)continue;let q=new Set(G.map((U)=>U.group));for(let U of hG)if(q.has(U.groups[0])&&q.has(U.groups[1])){let W=G.filter((K)=>K.group===U.groups[0]||K.group===U.groups[1]);if(!xG(z,W)){let K=W.find((H)=>H.group===U.groups[1]);if(K)Z.push({filePath:J.filePath,line:Y+1,column:K.index+1,ruleId:"style/no-mixed-operators",message:`Unexpected mix of ${U.label} without parentheses`,severity:"warning"})}}}return Z}};var D6=/(?<![0-9.])\.\d/g,R6=/\d\.(?!\d|\.|\w)/g;function O6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var L6={meta:{docs:"Disallow floating decimals like .5 or 2.",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;D6.lastIndex=0;while((G=D6.exec(z))!==null){if(O6(z,G.index))continue;if(G.index>0){let q=z[G.index-1];if(/[a-zA-Z_$)\]]/.test(q))continue}Z.push({filePath:J.filePath,line:Y+1,column:G.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"})}R6.lastIndex=0;while((G=R6.exec(z))!==null){if(O6(z,G.index))continue;Z.push({filePath:J.filePath,line:Y+1,column:G.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 Z},fix($){let J=$;return J=J.replace(/(?<![a-zA-Z_$0-9.)\]])\.\d/g,(Z)=>`0${Z}`),J=J.replace(/(\d)\.(?!\d|\.|\w)/g,(Z,X)=>`${X}.0`),J}};var P6={meta:{docs:"Disallow mixed spaces and tabs for indentation",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let Q=X[Y].match(/^(\s*)/)?.[1]||"";if(!Q)continue;let G=Q.includes("\t"),q=Q.includes(" ");if(G&&q)Z.push({filePath:J.filePath,line:Y+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 Z}};var C6={meta:{docs:"Disallow multiple consecutive spaces",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(!z.trim())continue;let Q=z.match(/^(\s*)/)?.[1]||"",G=z.slice(Q.length),q=/ {2,}/g,U;for(U=q.exec(G);U!==null;U=q.exec(G)){let W=Q.length+U.index+1,K=G.slice(0,U.index),H=(K.match(/'/g)||[]).length,V=(K.match(/"/g)||[]).length,A=(K.match(/`/g)||[]).length;if(H%2===1||V%2===1||A%2===1)continue;if(K.includes("//"))continue;if(z.trim().startsWith("*")||z.trim().startsWith("/*"))continue;Z.push({filePath:J.filePath,line:Y+1,column:W,ruleId:"style/no-multi-spaces",message:"Multiple spaces found",severity:"warning",help:"Remove extra spaces. Use single spaces between tokens."})}}return Z}};var I6={meta:{docs:"Disallow multiple consecutive blank lines",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=0,z=-1;for(let Q=0;Q<X.length;Q++)if(X[Q].trim()===""){if(Y++,z===-1)z=Q;if(Y>1&&Q===z+Y-1)Z.push({filePath:J.filePath,line:Q+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 Y=0,z=-1;return Z}};var S6={meta:{docs:"Disallow tab characters (when using spaces for indentation)",recommended:!1},check($,J){let Z=[];if(J.config.format?.indentStyle==="tabs")return Z;let X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let Q=X[Y].indexOf("\t");if(Q!==-1)Z.push({filePath:J.filePath,line:Y+1,column:Q+1,ruleId:"style/no-tabs",message:"Unexpected tab character",severity:"warning",help:"Use spaces for indentation instead of tabs."})}return Z},fix($,J){let Z=J.config.format?.indent??2;return $.replace(/\t/g," ".repeat(Z))}};var v6={meta:{docs:"Disallow trailing whitespace at the end of lines",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.match(/(\s+)$/);if(Q){let G=z.length-Q[1].length+1;Z.push({filePath:J.filePath,line:Y+1,column:G,ruleId:"style/no-trailing-spaces",message:"Trailing spaces not allowed",severity:"error",help:"Remove trailing whitespace from the end of this line."})}}return Z}};function y6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var b6={meta:{docs:"Require spaces inside curly braces in objects and destructuring",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G=0;G<z.length;G++){if(z[G]==="{"&&!y6(z,G)){let q=z[G+1];if(q==="}"||q===void 0||q===`
172
+ `)continue;if(G>0&&z[G-1]==="$")continue;if(q!==" "&&q!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:G+2,ruleId:"style/object-curly-spacing",message:"Missing space after '{'",severity:"warning"})}if(z[G]==="}"&&!y6(z,G)){let q=G>0?z[G-1]:void 0;if(q==="{"||q===void 0||q===`
173
173
  `)continue;if(G+1<z.length&&z.slice(G+1).match(/^[^}]*\$\{/))continue;if(q!==" "&&q!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:G+1,ruleId:"style/object-curly-spacing",message:"Missing space before '}'",severity:"warning"})}}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.replace(/(?<!\$)\{(\S)/g,(z,Q)=>{if(Q==="}")return z;return`{ ${Q}`}),Y=Y.replace(/(\S)\}/g,(z,Q)=>{if(Q==="{"||Q==="$")return z;return`${Q} }`}),Z.push(Y)}return Z.join(`
174
- `)}};var b6=/(\&\&|\|\||\?\?|\?|\+|(?<!=)-(?!=)|\*|\/|%|\*\*|\|(?!\|)|&(?!&)|\^|<<|>>>?)\s*$/;function k6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var f6={meta:{docs:"Enforce operators at the beginning of continued lines",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=Q.match(b6);if(G&&Y+1<X.length){let q=X[Y+1].trim();if(q&&!q.startsWith("//")&&!q.startsWith("*")){let U=z.lastIndexOf(G[1]);if(!k6(z,U)){if(G[1]==="?"||G[1]===":")continue;Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/operator-linebreak",message:`Operator '${G[1]}' should be at the beginning of the next line`,severity:"warning"})}}}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X=0;X<J.length;X++){let Y=J[X],z=Y.trim();if(!z||z.startsWith("//")||z.startsWith("*")||z.startsWith("/*")||z.endsWith("*/")){Z.push(Y);continue}let Q=z.match(b6);if(Q&&X+1<J.length&&Q[1]!=="?"&&Q[1]!==":"){let G=J[X+1],q=G.trim();if(q&&!q.startsWith("//")&&!q.startsWith("*")){let U=Q[1],W=Y.lastIndexOf(Q[1]);if(k6(Y,W)){Z.push(Y);continue}Z.push(Y.replace(new RegExp(`\\s*${U.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*$`),""));let K=G.match(/^(\s*)/)?.[1]||"";J[X+1]=`${K}${U} ${q}`;continue}}Z.push(Y)}return Z.join(`
175
- `)}};var g6={meta:{docs:"Disallow empty lines at the beginning and end of blocks",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let Q=X[Y].trim();if(Q.endsWith("{")&&Y+1<X.length){if(X[Y+1].trim()==="")Z.push({filePath:J.filePath,line:Y+2,column:1,ruleId:"style/padded-blocks",message:"Unexpected empty line after opening brace",severity:"warning"})}if(Q==="}"&&Y>0){if(X[Y-1].trim()==="")Z.push({filePath:J.filePath,line:Y,column:1,ruleId:"style/padded-blocks",message:"Unexpected empty line before closing brace",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=new Set;for(let X=0;X<J.length;X++){let Y=J[X].trim();if(Y.endsWith("{")&&X+1<J.length&&J[X+1].trim()==="")Z.add(X+1);if(Y==="}"&&X>0&&J[X-1].trim()==="")Z.add(X-1)}return J.filter((X,Y)=>!Z.has(Y)).join(`
176
- `)}};var G9=/^(\s*)(["'])([a-zA-Z_$][a-zA-Z0-9_$]*)\2\s*:/;var p6={meta:{docs:"Remove unnecessary quotes from object property keys",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=z.match(G9);if(G){let q=G[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(q))continue;Z.push({filePath:J.filePath,line:Y+1,column:z.indexOf(G[2])+1,ruleId:"style/quote-props",message:`Unnecessarily quoted property '${q}'`,severity:"warning",help:"Remove quotes from this property key."})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[],X=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 Y of J){let z=Y,Q=Y.match(G9);if(Q&&!X.has(Q[3]))z=Y.replace(G9,"$1$3:");Z.push(z)}return Z.join(`
177
- `)}};function pG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var x6=/\.\.\.\s+([a-zA-Z_$])/g,h6={meta:{docs:"Disallow space after spread/rest operator (...)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;x6.lastIndex=0;while((G=x6.exec(z))!==null){if(pG(z,G.index))continue;Z.push({filePath:J.filePath,line:Y+1,column:G.index+4,ruleId:"style/rest-spread-spacing",message:"Unexpected space after spread operator",severity:"warning"})}}return Z},fix($){return $.replace(/\.\.\.\s+([a-zA-Z_$\[{])/g,"...$1")}};function xG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var u6={meta:{docs:"Disallow space before semicolons, require space after",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G=0;G<z.length;G++){if(z[G]!==";")continue;if(xG(z,G))continue;if(G>0&&z[G-1]===" "){if(z.slice(0,G).trim().length>0)Z.push({filePath:J.filePath,line:Y+1,column:G+1,ruleId:"style/semi-spacing",message:"Unexpected space before semicolon",severity:"warning"})}if(G+1<z.length&&z[G+1]!==" "&&z[G+1]!=="\t"&&z[G+1]!==`
174
+ `)}};var k6=/(\&\&|\|\||\?\?|\?|\+|(?<!=)-(?!=)|\*|\/|%|\*\*|\|(?!\|)|&(?!&)|\^|<<|>>>?)\s*$/;function f6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var g6={meta:{docs:"Enforce operators at the beginning of continued lines",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=Q.match(k6);if(G&&Y+1<X.length){let q=X[Y+1].trim();if(q&&!q.startsWith("//")&&!q.startsWith("*")){let U=z.lastIndexOf(G[1]);if(!f6(z,U)){if(G[1]==="?"||G[1]===":")continue;Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/operator-linebreak",message:`Operator '${G[1]}' should be at the beginning of the next line`,severity:"warning"})}}}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X=0;X<J.length;X++){let Y=J[X],z=Y.trim();if(!z||z.startsWith("//")||z.startsWith("*")||z.startsWith("/*")||z.endsWith("*/")){Z.push(Y);continue}let Q=z.match(k6);if(Q&&X+1<J.length&&Q[1]!=="?"&&Q[1]!==":"){let G=J[X+1],q=G.trim();if(q&&!q.startsWith("//")&&!q.startsWith("*")){let U=Q[1],W=Y.lastIndexOf(Q[1]);if(f6(Y,W)){Z.push(Y);continue}Z.push(Y.replace(new RegExp(`\\s*${U.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*$`),""));let K=G.match(/^(\s*)/)?.[1]||"";J[X+1]=`${K}${U} ${q}`;continue}}Z.push(Y)}return Z.join(`
175
+ `)}};var p6={meta:{docs:"Disallow empty lines at the beginning and end of blocks",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let Q=X[Y].trim();if(Q.endsWith("{")&&Y+1<X.length){if(X[Y+1].trim()==="")Z.push({filePath:J.filePath,line:Y+2,column:1,ruleId:"style/padded-blocks",message:"Unexpected empty line after opening brace",severity:"warning"})}if(Q==="}"&&Y>0){if(X[Y-1].trim()==="")Z.push({filePath:J.filePath,line:Y,column:1,ruleId:"style/padded-blocks",message:"Unexpected empty line before closing brace",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=new Set;for(let X=0;X<J.length;X++){let Y=J[X].trim();if(Y.endsWith("{")&&X+1<J.length&&J[X+1].trim()==="")Z.add(X+1);if(Y==="}"&&X>0&&J[X-1].trim()==="")Z.add(X-1)}return J.filter((X,Y)=>!Z.has(Y)).join(`
176
+ `)}};var G9=/^(\s*)(["'])([a-zA-Z_$][a-zA-Z0-9_$]*)\2\s*:/;var x6={meta:{docs:"Remove unnecessary quotes from object property keys",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=z.match(G9);if(G){let q=G[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(q))continue;Z.push({filePath:J.filePath,line:Y+1,column:z.indexOf(G[2])+1,ruleId:"style/quote-props",message:`Unnecessarily quoted property '${q}'`,severity:"warning",help:"Remove quotes from this property key."})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[],X=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 Y of J){let z=Y,Q=Y.match(G9);if(Q&&!X.has(Q[3]))z=Y.replace(G9,"$1$3:");Z.push(z)}return Z.join(`
177
+ `)}};function uG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var h6=/\.\.\.\s+([a-zA-Z_$])/g,u6={meta:{docs:"Disallow space after spread/rest operator (...)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;h6.lastIndex=0;while((G=h6.exec(z))!==null){if(uG(z,G.index))continue;Z.push({filePath:J.filePath,line:Y+1,column:G.index+4,ruleId:"style/rest-spread-spacing",message:"Unexpected space after spread operator",severity:"warning"})}}return Z},fix($){return $.replace(/\.\.\.\s+([a-zA-Z_$\[{])/g,"...$1")}};function mG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var m6={meta:{docs:"Disallow space before semicolons, require space after",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G=0;G<z.length;G++){if(z[G]!==";")continue;if(mG(z,G))continue;if(G>0&&z[G-1]===" "){if(z.slice(0,G).trim().length>0)Z.push({filePath:J.filePath,line:Y+1,column:G+1,ruleId:"style/semi-spacing",message:"Unexpected space before semicolon",severity:"warning"})}if(G+1<z.length&&z[G+1]!==" "&&z[G+1]!=="\t"&&z[G+1]!==`
178
178
  `&&z[G+1]!=="\r"&&z[G+1]!==")"){let q=z.slice(G+1);if(z.slice(0,G).includes(";")||q.includes(";"))Z.push({filePath:J.filePath,line:Y+1,column:G+2,ruleId:"style/semi-spacing",message:"Missing space after semicolon",severity:"warning"})}}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X,z=new RegExp(" ;","g");Y=Y.replace(z,String.fromCharCode(59));let Q=new RegExp(";(\\S)","g");Y=Y.replace(Q,(G,q)=>{if(q===";"||q===")")return G;return`; ${q}`}),Z.push(Y)}return Z.join(`
179
- `)}};var m6=/(\S)\{/g;function hG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var d6={meta:{docs:"Require space before opening brace of blocks",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;m6.lastIndex=0;while((G=m6.exec(z))!==null){let q=G.index,U=G[1];if(hG(z,q))continue;if(U==="$")continue;if(U==="="||U===":"||U==="("||U===","||U==="[")continue;if(U==="{")continue;if(U===")"||/[a-zA-Z0-9_]/.test(U))Z.push({filePath:J.filePath,line:Y+1,column:G.index+2,ruleId:"style/space-before-blocks",message:"Missing space before '{'",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X.replace(/([)a-zA-Z0-9_])\{/g,"$1 {");Z.push(Y)}return Z.join(`
180
- `)}};var o6=/\bfunction\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s+\(/g,c6=/\bfunction\(/g;function r6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var l6={meta:{docs:"Control spacing before ( in function declarations",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;o6.lastIndex=0;while((G=o6.exec(z))!==null){if(r6(z,G.index))continue;Z.push({filePath:J.filePath,line:Y+1,column:G.index+G[0].length,ruleId:"style/space-before-function-paren",message:"Unexpected space before function parentheses",severity:"warning"})}c6.lastIndex=0;while((G=c6.exec(z))!==null){if(r6(z,G.index))continue;if(z.slice(0,G.index+8).match(/function\s+[a-zA-Z_$]/))continue;Z.push({filePath:J.filePath,line:Y+1,column:G.index+9,ruleId:"style/space-before-function-paren",message:"Missing space before function parentheses",severity:"warning"})}}return Z},fix($){let J=$;return J=J.replace(/\bfunction\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s+\(/g,"function $1("),J=J.replace(/\bfunction\(/g,"function ("),J}};function a6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var s6={meta:{docs:"Disallow spaces inside parentheses",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G=0;G<z.length;G++){if(z[G]==="("&&!a6(z,G)){let q=z[G+1];if(q===")"||q===void 0||q===`
181
- `)continue;if(q===" ")Z.push({filePath:J.filePath,line:Y+1,column:G+2,ruleId:"style/space-in-parens",message:"Unexpected space after '('",severity:"warning"})}if(z[G]===")"&&!a6(z,G)){if(G===0)continue;let q=z[G-1];if(q==="(")continue;if(q===" "){if(z.slice(0,G).includes("("))Z.push({filePath:J.filePath,line:Y+1,column:G,ruleId:"style/space-in-parens",message:"Unexpected space before ')'",severity:"warning"})}}}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.replace(/\(\s+(\S)/g,"($1"),Y=Y.replace(/(\S)\s+\)/g,"$1)"),Z.push(Y)}return Z.join(`
182
- `)}};var n6=["&&","||","??","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","|=","^=","??=","||=","&&="];function uG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var i6={meta:{docs:"Require spacing around infix operators (&&, ||, ??, assignment operators)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G of n6){let q=0,U;while((U=z.indexOf(G,q))!==-1){if(q=U+G.length,uG(z,U))continue;if(G==="&&"&&z[U+2]==="=")continue;if(G==="||"&&z[U+2]==="=")continue;if(G==="??"&&z[U+2]==="=")continue;let W=U>0?z[U-1]:" ",K=U+G.length<z.length?z[U+G.length]:" ";if(W!==" "&&W!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/space-infix-ops",message:`Missing space before '${G}'`,severity:"warning"});if(K!==" "&&K!=="\t"&&K!==`
183
- `&&K!=="\r")Z.push({filePath:J.filePath,line:Y+1,column:U+G.length+1,ruleId:"style/space-infix-ops",message:`Missing space after '${G}'`,severity:"warning"})}}}return Z},fix($){let J=$,Z=[...n6].sort((X,Y)=>Y.length-X.length);for(let X of Z){let Y=X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");J=J.replace(new RegExp(`(\\S)${Y}`,"g"),`$1 ${X}`),J=J.replace(new RegExp(`${Y}(\\S)`,"g"),`${X} $1`)}return J}};var t6=["typeof","void","delete","new","throw","yield","await"];function q9($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var e6={meta:{docs:"Require space after word unary operators, disallow space after symbol unary operators",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let W of t6){let K=new RegExp(`\\b${W}([^\\s;,)])`,"g"),H;while((H=K.exec(z))!==null){if(q9(z,H.index))continue;Z.push({filePath:J.filePath,line:Y+1,column:H.index+W.length+1,ruleId:"style/space-unary-ops",message:`Missing space after '${W}'`,severity:"warning"})}}let G=/!\s+([a-zA-Z_$({[])/g,q;while((q=G.exec(z))!==null){if(q9(z,q.index))continue;let W=z.slice(0,q.index),K=W.trimEnd().slice(-1),H=new RegExp("[=(<[{,;|&?:+\\-*/!~^%]");if(!K||H.test(K)||W.trimEnd().endsWith("return")||W.trimEnd().endsWith("case"))Z.push({filePath:J.filePath,line:Y+1,column:q.index+2,ruleId:"style/space-unary-ops",message:"Unexpected space after '!'",severity:"warning"})}let U=/~\s+([a-zA-Z_$({[])/g;while((q=U.exec(z))!==null){if(q9(z,q.index))continue;Z.push({filePath:J.filePath,line:Y+1,column:q.index+2,ruleId:"style/space-unary-ops",message:"Unexpected space after '~'",severity:"warning"})}}return Z},fix($){let J=$;for(let Z of t6)J=J.replace(new RegExp(`\\b${Z}([^\\s;,)])`,"g"),`${Z} $1`);return J=J.replace(/!\s+([a-zA-Z_$({[])/g,"!$1"),J=J.replace(/~\s+([a-zA-Z_$({[])/g,"~$1"),J}};var $Y={meta:{docs:"Require space after // and /* in comments",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim(),G=z.indexOf("//");if(G!==-1){let U=z.slice(0,G),W=(U.match(/'/g)||[]).length,K=(U.match(/"/g)||[]).length,H=(U.match(/`/g)||[]).length;if(W%2===0&&K%2===0&&H%2===0){if(!U.match(/https?:$/)){let V=z.slice(G+2);if(V.length>0&&V[0]!==" "&&V[0]!=="\t"&&V[0]!=="/"&&V[0]!=="!")Z.push({filePath:J.filePath,line:Y+1,column:G+3,ruleId:"style/spaced-comment",message:"Missing space after '//'",severity:"warning",help:"Add a space after // in comments."})}}}let q=z.indexOf("/*");if(q!==-1&&z[q+2]!=="*"&&z[q+2]!=="!"){let U=z.slice(0,q),W=(U.match(/'/g)||[]).length,K=(U.match(/"/g)||[]).length,H=(U.match(/`/g)||[]).length;if(W%2===0&&K%2===0&&H%2===0){let V=z.slice(q+2);if(V.length>0&&V[0]!==" "&&V[0]!=="\t"&&V[0]!==`
179
+ `)}};var d6=/(\S)\{/g;function dG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var o6={meta:{docs:"Require space before opening brace of blocks",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;d6.lastIndex=0;while((G=d6.exec(z))!==null){let q=G.index,U=G[1];if(dG(z,q))continue;if(U==="$")continue;if(U==="="||U===":"||U==="("||U===","||U==="[")continue;if(U==="{")continue;if(U===")"||/[a-zA-Z0-9_]/.test(U))Z.push({filePath:J.filePath,line:Y+1,column:G.index+2,ruleId:"style/space-before-blocks",message:"Missing space before '{'",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X.replace(/([)a-zA-Z0-9_])\{/g,"$1 {");Z.push(Y)}return Z.join(`
180
+ `)}};var c6=/\bfunction\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s+\(/g,r6=/\bfunction\(/g;function l6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var a6={meta:{docs:"Control spacing before ( in function declarations",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;c6.lastIndex=0;while((G=c6.exec(z))!==null){if(l6(z,G.index))continue;Z.push({filePath:J.filePath,line:Y+1,column:G.index+G[0].length,ruleId:"style/space-before-function-paren",message:"Unexpected space before function parentheses",severity:"warning"})}r6.lastIndex=0;while((G=r6.exec(z))!==null){if(l6(z,G.index))continue;if(z.slice(0,G.index+8).match(/function\s+[a-zA-Z_$]/))continue;Z.push({filePath:J.filePath,line:Y+1,column:G.index+9,ruleId:"style/space-before-function-paren",message:"Missing space before function parentheses",severity:"warning"})}}return Z},fix($){let J=$;return J=J.replace(/\bfunction\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s+\(/g,"function $1("),J=J.replace(/\bfunction\(/g,"function ("),J}};function s6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var n6={meta:{docs:"Disallow spaces inside parentheses",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G=0;G<z.length;G++){if(z[G]==="("&&!s6(z,G)){let q=z[G+1];if(q===")"||q===void 0||q===`
181
+ `)continue;if(q===" ")Z.push({filePath:J.filePath,line:Y+1,column:G+2,ruleId:"style/space-in-parens",message:"Unexpected space after '('",severity:"warning"})}if(z[G]===")"&&!s6(z,G)){if(G===0)continue;let q=z[G-1];if(q==="(")continue;if(q===" "){if(z.slice(0,G).includes("("))Z.push({filePath:J.filePath,line:Y+1,column:G,ruleId:"style/space-in-parens",message:"Unexpected space before ')'",severity:"warning"})}}}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.replace(/\(\s+(\S)/g,"($1"),Y=Y.replace(/(\S)\s+\)/g,"$1)"),Z.push(Y)}return Z.join(`
182
+ `)}};var i6=["&&","||","??","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","|=","^=","??=","||=","&&="];function oG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var t6={meta:{docs:"Require spacing around infix operators (&&, ||, ??, assignment operators)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G of i6){let q=0,U;while((U=z.indexOf(G,q))!==-1){if(q=U+G.length,oG(z,U))continue;if(G==="&&"&&z[U+2]==="=")continue;if(G==="||"&&z[U+2]==="=")continue;if(G==="??"&&z[U+2]==="=")continue;let W=U>0?z[U-1]:" ",K=U+G.length<z.length?z[U+G.length]:" ";if(W!==" "&&W!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/space-infix-ops",message:`Missing space before '${G}'`,severity:"warning"});if(K!==" "&&K!=="\t"&&K!==`
183
+ `&&K!=="\r")Z.push({filePath:J.filePath,line:Y+1,column:U+G.length+1,ruleId:"style/space-infix-ops",message:`Missing space after '${G}'`,severity:"warning"})}}}return Z},fix($){let J=$,Z=[...i6].sort((X,Y)=>Y.length-X.length);for(let X of Z){let Y=X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");J=J.replace(new RegExp(`(\\S)${Y}`,"g"),`$1 ${X}`),J=J.replace(new RegExp(`${Y}(\\S)`,"g"),`${X} $1`)}return J}};var e6=["typeof","void","delete","new","throw","yield","await"];function q9($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var $Y={meta:{docs:"Require space after word unary operators, disallow space after symbol unary operators",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let W of e6){let K=new RegExp(`\\b${W}([^\\s;,)])`,"g"),H;while((H=K.exec(z))!==null){if(q9(z,H.index))continue;Z.push({filePath:J.filePath,line:Y+1,column:H.index+W.length+1,ruleId:"style/space-unary-ops",message:`Missing space after '${W}'`,severity:"warning"})}}let G=/!\s+([a-zA-Z_$({[])/g,q;while((q=G.exec(z))!==null){if(q9(z,q.index))continue;let W=z.slice(0,q.index),K=W.trimEnd().slice(-1),H=new RegExp("[=(<[{,;|&?:+\\-*/!~^%]");if(!K||H.test(K)||W.trimEnd().endsWith("return")||W.trimEnd().endsWith("case"))Z.push({filePath:J.filePath,line:Y+1,column:q.index+2,ruleId:"style/space-unary-ops",message:"Unexpected space after '!'",severity:"warning"})}let U=/~\s+([a-zA-Z_$({[])/g;while((q=U.exec(z))!==null){if(q9(z,q.index))continue;Z.push({filePath:J.filePath,line:Y+1,column:q.index+2,ruleId:"style/space-unary-ops",message:"Unexpected space after '~'",severity:"warning"})}}return Z},fix($){let J=$;for(let Z of e6)J=J.replace(new RegExp(`\\b${Z}([^\\s;,)])`,"g"),`${Z} $1`);return J=J.replace(/!\s+([a-zA-Z_$({[])/g,"!$1"),J=J.replace(/~\s+([a-zA-Z_$({[])/g,"~$1"),J}};var ZY={meta:{docs:"Require space after // and /* in comments",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim(),G=z.indexOf("//");if(G!==-1){let U=z.slice(0,G),W=(U.match(/'/g)||[]).length,K=(U.match(/"/g)||[]).length,H=(U.match(/`/g)||[]).length;if(W%2===0&&K%2===0&&H%2===0){if(!U.match(/https?:$/)){let V=z.slice(G+2);if(V.length>0&&V[0]!==" "&&V[0]!=="\t"&&V[0]!=="/"&&V[0]!=="!")Z.push({filePath:J.filePath,line:Y+1,column:G+3,ruleId:"style/spaced-comment",message:"Missing space after '//'",severity:"warning",help:"Add a space after // in comments."})}}}let q=z.indexOf("/*");if(q!==-1&&z[q+2]!=="*"&&z[q+2]!=="!"){let U=z.slice(0,q),W=(U.match(/'/g)||[]).length,K=(U.match(/"/g)||[]).length,H=(U.match(/`/g)||[]).length;if(W%2===0&&K%2===0&&H%2===0){let V=z.slice(q+2);if(V.length>0&&V[0]!==" "&&V[0]!=="\t"&&V[0]!==`
184
184
  `)Z.push({filePath:J.filePath,line:Y+1,column:q+3,ruleId:"style/spaced-comment",message:"Missing space after '/*'",severity:"warning",help:"Add a space after /* in comments."})}}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.replace(/(\/\/)([^\s/!])/,"$1 $2"),Y=Y.replace(/(\/\*)([^\s*!])/,"$1 $2"),Z.push(Y)}return Z.join(`
185
- `)}};var ZY=/^\s*(case\b.+?|default)\s*:/,JY={meta:{docs:"Enforce spacing around colon in switch case/default clauses",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q)continue;let G=Q.match(ZY);if(!G)continue;let q=G[1],U=z.indexOf(":",z.indexOf(q)+q.length);if(U===-1)continue;if(U>0&&z[U-1]===" ")Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/switch-colon-spacing",message:"Unexpected space before colon in switch case",severity:"warning"});if(U+1<z.length&&z[U+1]!==" "&&z[U+1]!=="\t"&&z[U+1]!==`
186
- `)Z.push({filePath:J.filePath,line:Y+1,column:U+2,ruleId:"style/switch-colon-spacing",message:"Missing space after colon in switch case",severity:"warning"})}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X,z=X.trim();if(ZY.test(z))Y=Y.replace(/(case\b.+?|default)\s+:/,"$1:"),Y=Y.replace(/(case\b.+?:|default:)(\S)/,"$1 $2");Z.push(Y)}return Z.join(`
187
- `)}};var XY="${",YY={meta:{docs:"Disallow spaces inside template literal interpolation curly braces",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];for(let Q=z.indexOf(XY,0);Q!==-1;Q=z.indexOf(XY,Q)){let G=Q+2;if(G<z.length&&(z[G]===" "||z[G]==="\t")){if((z.slice(0,Q).match(/`/g)||[]).length%2===1)Z.push({filePath:J.filePath,line:Y+1,column:G+1,ruleId:"style/template-curly-spacing",message:"Unexpected space after '${'",severity:"warning"})}let q=1,U=G;while(U<z.length&&q>0){if(z[U]==="{")q++;if(z[U]==="}")q--;if(q>0)U++}if(q===0&&U>0){let W=z[U-1];if(W===" "||W==="\t"){if((z.slice(0,Q).match(/`/g)||[]).length%2===1)Z.push({filePath:J.filePath,line:Y+1,column:U,ruleId:"style/template-curly-spacing",message:"Unexpected space before '}'",severity:"warning"})}}Q=G}}return Z},fix($){return $.replace(/\$\{\s+([^}]*?)\s+\}/g,"${$1}")}};var j1=/([a-zA-Z_$][a-zA-Z0-9_$]*)\s+`/g;function zY($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var QY=new Set(["return","case","typeof","void","delete","throw","new","in","of","await","yield","export","default","extends","else","instanceof"]),GY={meta:{docs:"Disallow space between tag function and template literal",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;j1.lastIndex=0;for(G=j1.exec(z);G!==null;G=j1.exec(z)){let q=G[1],U=G.index;if(zY(z,U))continue;if(QY.has(q))continue;let W=U+q.length;Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"style/template-tag-spacing",message:"Unexpected space between tag function and template literal",severity:"warning"})}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y=0;Y<Z.length;Y++){let z=Z[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*")){X.push(z);continue}let G=z,q=[],U;j1.lastIndex=0;for(U=j1.exec(z);U!==null;U=j1.exec(z)){let W=U[1],K=U.index;if(zY(z,K))continue;if(QY.has(W))continue;q.push({index:K,fullMatch:U[0],identifier:W})}for(let W=q.length-1;W>=0;W--){let K=q[W],H=K.index,V=H+K.fullMatch.length;G=G.slice(0,H)+K.identifier+"`"+G.slice(V)}X.push(G)}return X.join(`
188
- `)}};var qY={meta:{docs:"Require parentheses around immediately invoked function expressions (IIFEs)",recommended:!0},check($,J){let Z=[],X=/[^a-zA-Z_$](function\s*\([^)]*\)\s*\{[^}]*\})\s*\(/g,Y;for(Y=X.exec($);Y!==null;Y=X.exec($)){if(Y.index>0&&$[Y.index]==="(")continue;let z=$.slice(0,Y.index).split(`
185
+ `)}};var JY=/^\s*(case\b.+?|default)\s*:/,XY={meta:{docs:"Enforce spacing around colon in switch case/default clauses",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q)continue;let G=Q.match(JY);if(!G)continue;let q=G[1],U=z.indexOf(":",z.indexOf(q)+q.length);if(U===-1)continue;if(U>0&&z[U-1]===" ")Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/switch-colon-spacing",message:"Unexpected space before colon in switch case",severity:"warning"});if(U+1<z.length&&z[U+1]!==" "&&z[U+1]!=="\t"&&z[U+1]!==`
186
+ `)Z.push({filePath:J.filePath,line:Y+1,column:U+2,ruleId:"style/switch-colon-spacing",message:"Missing space after colon in switch case",severity:"warning"})}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X,z=X.trim();if(JY.test(z))Y=Y.replace(/(case\b.+?|default)\s+:/,"$1:"),Y=Y.replace(/(case\b.+?:|default:)(\S)/,"$1 $2");Z.push(Y)}return Z.join(`
187
+ `)}};var YY="${",zY={meta:{docs:"Disallow spaces inside template literal interpolation curly braces",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];for(let Q=z.indexOf(YY,0);Q!==-1;Q=z.indexOf(YY,Q)){let G=Q+2;if(G<z.length&&(z[G]===" "||z[G]==="\t")){if((z.slice(0,Q).match(/`/g)||[]).length%2===1)Z.push({filePath:J.filePath,line:Y+1,column:G+1,ruleId:"style/template-curly-spacing",message:"Unexpected space after '${'",severity:"warning"})}let q=1,U=G;while(U<z.length&&q>0){if(z[U]==="{")q++;if(z[U]==="}")q--;if(q>0)U++}if(q===0&&U>0){let W=z[U-1];if(W===" "||W==="\t"){if((z.slice(0,Q).match(/`/g)||[]).length%2===1)Z.push({filePath:J.filePath,line:Y+1,column:U,ruleId:"style/template-curly-spacing",message:"Unexpected space before '}'",severity:"warning"})}}Q=G}}return Z},fix($){return $.replace(/\$\{\s+([^}]*?)\s+\}/g,"${$1}")}};var T1=/([a-zA-Z_$][a-zA-Z0-9_$]*)\s+`/g;function QY($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var GY=new Set(["return","case","typeof","void","delete","throw","new","in","of","await","yield","export","default","extends","else","instanceof"]),qY={meta:{docs:"Disallow space between tag function and template literal",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;T1.lastIndex=0;for(G=T1.exec(z);G!==null;G=T1.exec(z)){let q=G[1],U=G.index;if(QY(z,U))continue;if(GY.has(q))continue;let W=U+q.length;Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"style/template-tag-spacing",message:"Unexpected space between tag function and template literal",severity:"warning"})}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y=0;Y<Z.length;Y++){let z=Z[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*")){X.push(z);continue}let G=z,q=[],U;T1.lastIndex=0;for(U=T1.exec(z);U!==null;U=T1.exec(z)){let W=U[1],K=U.index;if(QY(z,K))continue;if(GY.has(W))continue;q.push({index:K,fullMatch:U[0],identifier:W})}for(let W=q.length-1;W>=0;W--){let K=q[W],H=K.index,V=H+K.fullMatch.length;G=G.slice(0,H)+K.identifier+"`"+G.slice(V)}X.push(G)}return X.join(`
188
+ `)}};var UY={meta:{docs:"Require parentheses around immediately invoked function expressions (IIFEs)",recommended:!0},check($,J){let Z=[],X=/[^a-zA-Z_$](function\s*\([^)]*\)\s*\{[^}]*\})\s*\(/g,Y;for(Y=X.exec($);Y!==null;Y=X.exec($)){if(Y.index>0&&$[Y.index]==="(")continue;let z=$.slice(0,Y.index).split(`
189
189
  `).length,Q=$.lastIndexOf(`
190
- `,Y.index),G=Y.index-Q;Z.push({filePath:J.filePath,line:z,column:G,ruleId:"style/wrap-iife",message:"Wrap immediately invoked function expressions in parentheses",severity:"warning"})}return Z},fix($){return $.replace(/([^a-zA-Z_$(\n])(function\s*\([^)]*\)\s*\{[^}]*\})\s*\(/g,"$1($2)(")}};var UY=/\byield\s*\*/g;function mG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var WY={meta:{docs:"Enforce spacing around * in yield* expressions (no space before *, space after)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;UY.lastIndex=0;while((G=UY.exec(z))!==null){let q=G.index;if(mG(z,q))continue;let U=G[0],W=q+U.length-1,K=W+1;if(U!=="yield*")Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"style/yield-star-spacing",message:"Unexpected space before * in yield expression",severity:"warning"});if(K<z.length&&z[K]!==" "&&z[K]!=="\t"&&z[K]!==`
191
- `)Z.push({filePath:J.filePath,line:Y+1,column:K+1,ruleId:"style/yield-star-spacing",message:"Missing space after * in yield expression",severity:"warning"})}}return Z},fix($,J){let Z=$;return Z=Z.replace(/\byield\s+\*/g,"yield*"),Z=Z.replace(/\byield\*(\S)/g,"yield* $1"),Z}};var KY={name:"style",rules:{"brace-style":w(P5),curly:w(h5),"max-statements-per-line":w(z6),"if-newline":w(i5),"consistent-chaining":w(k5),"consistent-list-newline":w(x5),"indent-unindent":w(t5),"no-multi-spaces":P6,"no-multiple-empty-lines":C6,"no-trailing-spaces":S6,"keyword-spacing":w(J6),"arrow-spacing":w(O5),"space-infix-ops":w(i6),"object-curly-spacing":w(y6),"spaced-comment":w($Y),"block-spacing":w(L5),"space-before-blocks":w(d6),"comma-spacing":w(v5),"semi-spacing":w(u6),"rest-spread-spacing":w(h6),"generator-star-spacing":w(n5),"yield-star-spacing":w(WY),"function-call-spacing":w(l5),"template-tag-spacing":w(GY),"no-whitespace-before-property":w(_6),"key-spacing":w($6),"computed-property-spacing":w(b5),"array-bracket-spacing":w(T5),"space-in-parens":w(s6),"template-curly-spacing":w(YY),"space-unary-ops":w(e6),"switch-colon-spacing":w(JY),"comma-dangle":w(S5),"arrow-parens":w(D5),"space-before-function-paren":w(l6),"quote-props":w(p6),"no-floating-decimal":w(O6),"new-parens":w(W6),"no-extra-parens":w(H6),"wrap-iife":w(qY),"comma-style":w(y5),"dot-location":w(u5),"operator-linebreak":w(f6),"multiline-ternary":w(q6),"padded-blocks":w(g6),"lines-between-class-members":w(Y6),"no-mixed-operators":w(T6),"indent-binary-ops":w(o5),"no-tabs":w(I6),"no-mixed-spaces-and-tabs":w(L6)}};var HY={meta:{docs:"Enforce consistent member delimiter style in interfaces and type literals",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z=0,Q=0;for(let G=0;G<X.length;G++){let q=X[G],U=q.trim();if(!U||U.startsWith("//")||U.startsWith("*")||U.startsWith("/*"))continue;if(U.match(/\b(interface|type)\b.*\{/))Y=!0,Q=z+1;for(let W of U){if(W==="{")z++;if(W==="}")z--}if(Y&&z<Q){Y=!1;continue}if(!Y||z!==Q)continue;if(U==="}"||U==="};"||U==="},")continue;if(U.endsWith(",")){if(U.startsWith("|")||U.startsWith("&"))continue;Z.push({filePath:J.filePath,line:G+1,column:q.length,ruleId:"ts/member-delimiter-style",message:"Expected semicolon delimiter in interface, found comma",severity:"warning"})}if(!U.endsWith(";")&&!U.endsWith(",")&&!U.endsWith("{")&&!U.endsWith("(")){if(U.match(/^\w+[\s?]*:/)||U.match(/^\[/)||U.match(/^readonly\b/))Z.push({filePath:J.filePath,line:G+1,column:q.length+1,ruleId:"ts/member-delimiter-style",message:"Missing semicolon delimiter in interface member",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[],X=!1,Y=0,z=0;for(let Q=0;Q<J.length;Q++){let G=J[Q],q=G.trim();if(q.match(/\b(interface|type)\b.*\{/))X=!0,z=Y+1;let U=Y;for(let W of q){if(W==="{")Y++;if(W==="}")Y--}if(X&&Y<z){X=!1,Z.push(G);continue}if(X&&U===z&&q!=="}"&&q!=="};"&&q!=="},"){let W=G;if(q.endsWith(","))W=G.replace(/,\s*$/,";");Z.push(W);continue}Z.push(G)}return Z.join(`
192
- `)}};var VY={meta:{docs:"Disallow the use of the `any` type - it defeats the purpose of TypeScript type safety"},check:($,J)=>{let Z=[];if(!/\.tsx?$/.test(J.filePath))return Z;let X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z],G=Q;if(Y){let V=Q.indexOf("*/");if(V>=0)Q=Q.slice(V+2),Y=!1;else continue}let q=Q.indexOf("/*"),U=Q.indexOf("//");if(q>=0&&(U===-1||q<U)){let V=Q.indexOf("*/",q+2);if(V>=0)Q=Q.slice(0,q)+Q.slice(V+2);else Y=!0,Q=Q.slice(0,q)}if(U>=0)Q=Q.slice(0,U);let W=Q.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),K=/\b(any)\b/g,H;while((H=K.exec(W))!==null){let V=H.index,A=W[V-1]||" ",_=W[V+3]||" ",B=W.slice(Math.max(0,V-10),V),F=W.slice(V+3,Math.min(W.length,V+10));if(/\w/.test(A)||/\w/.test(_))continue;if(/:/.test(B)||/</.test(B)||/\bas\s*$/.test(B)||/,/.test(B)||/\|/.test(B)||/&/.test(B)||/\[/.test(F)||/>/.test(F)||/,/.test(F)||/\|/.test(F)||/extends\s+$/.test(B)||/=\s*$/.test(B)){let N=G.indexOf("any",Math.max(0,V-5));Z.push({filePath:J.filePath,line:z+1,column:N>=0?N+1:V+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 Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.replace(/:\s*any\b(?!\s*\))/g,(z)=>{return z.replace("any","unknown")}),Z.push(Y)}return Z.join(`
193
- `)}};var AY={meta:{docs:"Require promises to be handled - must be awaited, returned, or have .catch() called"},check:($,J)=>{let Z=[];if(!/\.tsx?$/.test(J.filePath))return Z;let X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z],G=Q;if(Y){let H=Q.indexOf("*/");if(H>=0)Q=Q.slice(H+2),Y=!1;else continue}let q=Q.indexOf("/*"),U=Q.indexOf("//");if(q>=0&&(U===-1||q<U)){let H=Q.indexOf("*/",q+2);if(H>=0)Q=Q.slice(0,q)+Q.slice(H+2);else Y=!0,Q=Q.slice(0,q)}if(U>=0)Q=Q.slice(0,U);let W=Q.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""');if(/\b(?:await|return|void)\s/.test(W))continue;if(/\.(?:then|catch|finally)\s*\(/.test(W))continue;let K=[/\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 H of K){let V=W.match(H);if(!V)continue;let A=W.indexOf(V[0]),_=W.slice(0,A).trim();if(/\b(?:const|let|var)\s+[\w$]+\s*=\s*$/.test(_))continue;if(/[\w$]+\s*=\s*$/.test(_))continue;if(/\breturn\s+$/.test(_))continue;if(/\(\s*$/.test(_)||/,\s*$/.test(_))continue;let B=W.slice(A+V[0].length),F=1,M=V[0].length;while(M<B.length&&F>0){if(B[M]==="(")F++;else if(B[M]===")")F--;M++}let N=B.slice(M).trim();if(/^\.(?:then|catch|finally)\s*\(/.test(N))continue;if(N===""||N.startsWith(";")){let E=G.indexOf(V[0]);Z.push({filePath:J.filePath,line:z+1,column:E>=0?E+1:A+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 Z}};var _Y={meta:{docs:"Disallow promises in places not designed to handle them (conditionals, logical expressions)"},check:($,J)=>{let Z=[];if(!/\.tsx?$/.test(J.filePath))return Z;let X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z],G=Q;if(Y){let B=Q.indexOf("*/");if(B>=0)Q=Q.slice(B+2),Y=!1;else continue}let q=Q.indexOf("/*"),U=Q.indexOf("//");if(q>=0&&(U===-1||q<U)){let B=Q.indexOf("*/",q+2);if(B>=0)Q=Q.slice(0,q)+Q.slice(B+2);else Y=!0,Q=Q.slice(0,q)}if(U>=0)Q=Q.slice(0,U);let W=Q.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),K=W.match(/\bif\s*\(\s*(!?)\s*([\w$]+\s*\([^)]*\))/);if(K){let B=K[1],F=K[2];if(/async|Async|fetch|Fetch|load|Load|get|Get|save|Save/.test(F)){let M=W.slice(0,W.indexOf(K[0])),N=W.slice(W.indexOf("if (")+4);if(!/\bawait\s/.test(N)){let E=G.indexOf(F);Z.push({filePath:J.filePath,line:z+1,column:E>=0?E+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 H=/(?:async|Async|fetch|Fetch|load|Load|get|Get|save|Save|Promise\.)[\w$]*\s*\([^)]*\)/g,V;while((V=H.exec(W))!==null){let B=V.index,F=V[0],M=W.slice(Math.max(0,B-10),B),N=W.slice(B+F.length,Math.min(W.length,B+F.length+10));if(/(?:&&|\|\|)\s*$/.test(M)||/^\s*(?:&&|\|\|)/.test(N)){if(!/\bawait\s*$/.test(M)){let j=G.indexOf(F,Math.max(0,B-5));Z.push({filePath:J.filePath,line:z+1,column:j>=0?j+1:B+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 E=W.slice(Math.max(0,B-20),B);if(/\?\s*$/.test(M)||/\?[^:]*$/.test(E)){if(!/\bawait\s*$/.test(M)){let j=G.indexOf(F,Math.max(0,B-5));Z.push({filePath:J.filePath,line:z+1,column:j>=0?j+1:B+1,ruleId:"ts/no-misused-promises",message:"Promise used in ternary expression without await.",severity:"error",help:"Add await before the async call"})}}}let A=W.match(/\b(?:while|for)\s*\([^)]*(?:async|Async|fetch|Fetch|load|Load|get|Get)[\w$]*\s*\([^)]*\)/);if(A){if(!/\bawait\s/.test(A[0])){let B=G.indexOf(A[0]);Z.push({filePath:J.filePath,line:z+1,column:B>=0?B+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 _=W.match(/\.(forEach|map|filter|reduce|every|some|find|findIndex)\s*\(\s*async\s*(?:\(|[\w$]+\s*=>)/);if(_){if(_[1]==="forEach"){let F=G.indexOf(_[0]);Z.push({filePath:J.filePath,line:z+1,column:F>=0?F+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 Z}};var FY={meta:{docs:"Disallow require() in TypeScript files; prefer ESM imports"},check:($,J)=>{let Z=[];if(!/\.ts$/.test(J.filePath))return Z;let X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z],G=Q;if(Y){let H=G.indexOf("*/");if(H>=0)G=G.slice(H+2),Y=!1;else continue}let q=G.indexOf("/*"),U=G.indexOf("//");if(q>=0&&(U===-1||q<U)){let H=G.indexOf("*/",q+2);if(H>=0)G=G.slice(0,q)+G.slice(H+2);else Y=!0,G=G.slice(0,q)}if(U>=0)G=G.slice(0,U);let W=G.trim();if(!W)continue;if(/\bimport\s*\(/.test(W))continue;let K=W.indexOf("require(");if(K>=0){Z.push({filePath:J.filePath,line:z+1,column:Q.indexOf("require(")+1||K+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(W)){let H=Q.indexOf("require(");Z.push({filePath:J.filePath,line:z+1,column:H>-1?H+1:1,ruleId:"ts/no-require-imports",message:"Do not use require() in TypeScript files. Use ESM import syntax instead.",severity:"error"})}}return Z}};var BY={meta:{docs:"Disallow top-level await in TypeScript/JavaScript files"},check:($,J)=>{let Z=[],X=J.filePath.split(".").pop()||"";if(!["ts","tsx","mts","cts","js","mjs","cjs"].includes(X))return Z;let Y=0,z=!1,Q=!1,G=!1,q=!1,U=!1,W=!1,K=0,H=1,V=(A)=>{Z.push({filePath:J.filePath,line:H,column:A,ruleId:"ts/no-top-level-await",message:"Do not use top-level await",severity:"error"})};for(let A=0;A<$.length;A++){let _=$[A];K++;let B=$[A+1];if(_===`
194
- `){Q=!1,H++,K=0;continue}if(Q)continue;if(z){if(_==="*"&&B==="/")z=!1,A++,K++;continue}if(G){if(!W&&_==="\\"){W=!0;continue}if(!W&&_==="'")G=!1;W=!1;continue}if(q){if(!W&&_==="\\"){W=!0;continue}if(!W&&_==='"')q=!1;W=!1;continue}if(U){if(!W&&_==="\\"){W=!0;continue}if(!W&&_==="`")U=!1;W=!1;continue}if(_==="/"&&B==="*"){z=!0,A++,K++;continue}if(_==="/"&&B==="/"){Q=!0,A++,K++;continue}if(_==="'"){G=!0;continue}if(_==='"'){q=!0;continue}if(_==="`"){U=!0;continue}if(_==="{"){Y++;continue}if(_==="}"){if(Y>0)Y--;continue}if(_==="a"&&$.slice(A,A+5)==="await"){let F=$.slice(Math.max(0,A-6),A),M=/for\s+$/.test(F),N=A===0||/[^$\w]/.test($[A-1]),E=/[^$\w]/.test($[A+5]||" ");if(!M&&N&&E&&Y===0)V(K);A+=4,K+=4;continue}}return Z}};var wY={meta:{docs:"Disallow `exports =` in TypeScript; prefer ESM export default"},check:($,J)=>{let Z=[],X=J.filePath.split(".").pop()||"";if(!["ts","tsx","mts","cts","d.ts"].includes(X))return Z;let Y=$.split(/\r?\n/);for(let z=0;z<Y.length;z++){let q=Y[z].replace(/\/\*.*?\*\//g,"").replace(/\/\/.*$/,"").match(/\bexports\s*=\s*/);if(q)Z.push({filePath:J.filePath,line:z+1,column:(q.index||0)+1,ruleId:"ts/no-ts-export-equal",message:"Use ESM `export default` instead of `exports =`",severity:"error"})}return Z}};var MY={meta:{docs:"Disallow assignment of `any` typed values to variables - unsafe assignments bypass type checking"},check:($,J)=>{let Z=[];if(!/\.tsx?$/.test(J.filePath))return Z;let X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z],G=Q;if(Y){let M=Q.indexOf("*/");if(M>=0)Q=Q.slice(M+2),Y=!1;else continue}let q=Q.indexOf("/*"),U=Q.indexOf("//");if(q>=0&&(U===-1||q<U)){let M=Q.indexOf("*/",q+2);if(M>=0)Q=Q.slice(0,q)+Q.slice(M+2);else Y=!0,Q=Q.slice(0,q)}if(U>=0)Q=Q.slice(0,U);let W=Q.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),K=/(\w+)\s+as\s+any/g,H;while((H=K.exec(W))!==null){let M=H[1],N=H.index,E=W.slice(N+H[0].length).trim(),j=W.slice(0,N).trim();if(/=\s*$/.test(j)&&!/==|===|!=|!==/.test(j)){let O=G.indexOf(H[0]);Z.push({filePath:J.filePath,line:z+1,column:O>=0?O+1:N+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 V=["JSON.parse","eval","Function","require"];for(let M of V){let N=new RegExp(`\\b${M.replace(".","\\.")}\\s*\\(`,"g");N.lastIndex=0;while((H=N.exec(W))!==null){let E=H.index,j=W.slice(0,E).trim(),O=j.match(/(?:const|let|var)\s+([\w$]+)\s*=\s*$/);if(O){let L=O[1];if(!new RegExp(`\\b${L}\\s*:\\s*\\w+`).test(W)){let b=G.indexOf(H[0]);Z.push({filePath:J.filePath,line:z+1,column:b>=0?b+1:E+1,ruleId:"ts/no-unsafe-assignment",message:`Unsafe assignment from ${M}() without type annotation. This function returns 'any'.`,severity:"error",help:`Add a type annotation to ${L} or use a type assertion with a specific type`})}}let y=j.match(/([\w$.]+)\s*=\s*$/),k=/(?:const|let|var)\s+/.test(j);if(y&&!O&&!k){let L=G.indexOf(H[0]);Z.push({filePath:J.filePath,line:z+1,column:L>=0?L+1:E+1,ruleId:"ts/no-unsafe-assignment",message:`Unsafe assignment from ${M}() which returns 'any'.`,severity:"error",help:"Consider adding a type assertion with a specific type"})}}}let A=/(?:const|let|var)\s+([\w$]+)\s*:\s*any\s*=/,_=W.match(A);if(_){let M=_[1],N=G.indexOf(_[0]);Z.push({filePath:J.filePath,line:z+1,column:N>=0?N+1:1,ruleId:"ts/no-unsafe-assignment",message:`Variable '${M}' 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 B=/(?:const|let|var)\s+(?:\{[^}]+\}|\[[^\]]+\])\s*=\s*([\w$]+)/,F=W.match(B);if(F){let M=F[1];if(/^(?:params|query|body|req|res|response|data|result)$/.test(M));}}return Z}};var jY={meta:{docs:"Prefer nullish coalescing operator (??) over logical OR (||) when checking for null/undefined"},check:($,J)=>{let Z=[];if(!/\.tsx?$/.test(J.filePath))return Z;let X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z],G=Q.split(""),q=G.length,U=0;if(Y){let A=Q.indexOf("*/");if(A<0)continue;for(let _=0;_<=A+1;_++)G[_]=" ";Y=!1,U=A+2}let W=null;for(;U<q;U++){let A=G[U];if(W){if(A==="\\"){if(G[U]=" ",U+1<q)G[U+1]=" ",U++;continue}if(A===W){W=null;continue}G[U]=" ";continue}if(A==="/"&&G[U+1]==="/"){for(let _=U;_<q;_++)G[_]=" ";break}if(A==="/"&&G[U+1]==="*"){let _=Q.indexOf("*/",U+2);if(_<0){for(let B=U;B<q;B++)G[B]=" ";Y=!0;break}for(let B=U;B<=_+1;B++)G[B]=" ";U=_+1;continue}if(A==='"'||A==="'"||A==="`")W=A}let K=G.join(""),H=/\|\|/g,V;while((V=H.exec(K))!==null){let A=V.index,_=A-1,B=0,F=0,M=0;while(_>=0){let L=K[_];if(L===")")B++;else if(L==="("){if(B===0){_++;break}B--}else if(L==="}")F++;else if(L==="{"){if(F===0){_++;break}F--}else if(L==="]")M++;else if(L==="["){if(M===0){_++;break}M--}else if(B===0&&F===0&&M===0){if(new RegExp("[;,=:?]").test(L)){_++;break}if(L==="&"||L==="|"){_++;break}}_--}if(_<0)_=0;let N=K.slice(_,A).trim();if(/[<>!=]/.test(N))continue;if(/\b(?:true|false)\b/.test(N))continue;let E=A+2,j=E;B=0,F=0,M=0;while(j<K.length){let L=K[j];if(L==="(")B++;else if(L===")"){if(B===0)break;B--}else if(L==="{")F++;else if(L==="}"){if(F===0)break;F--}else if(L==="[")M++;else if(L==="]"){if(M===0)break;M--}else if(B===0&&F===0&&M===0){if(new RegExp("[;,?:]").test(L))break;if(L==="&"||L==="|"&&K[j+1]==="|")break}j++}let O=K.slice(E,j).trim(),y=/^["'`\d]/.test(O)||/^\{/.test(O)||/^[\w$]+\(/.test(O)||/^[\w$.[\]]+$/.test(O),k=/^[\w$]+$/.test(N)||/^[\w$.?[\]()]+$/.test(N);if(y&&k)Z.push({filePath:J.filePath,line:z+1,column:A+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 Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X,z=new RegExp("(\\b[\\w$.]+)\\s*\\|\\|\\s*([^|&]+?)(?=\\s*[;,)\\]}]|$)","g");Y=Y.replace(z,(Q,G,q)=>{if(/\b(?:true|false)\b/.test(q.trim()))return Q;return`${G} ?? ${q}`}),Z.push(Y)}return Z.join(`
195
- `)}};var NY={meta:{docs:"Prefer optional chaining (?.) over chained logical AND (&&) for property access"},check:($,J)=>{let Z=[];if(!/\.tsx?$/.test(J.filePath))return Z;let X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z],G=Q;if(Y){let _=Q.indexOf("*/");if(_>=0)Q=Q.slice(_+2),Y=!1;else continue}let q=Q.indexOf("/*"),U=Q.indexOf("//");if(q>=0&&(U===-1||q<U)){let _=Q.indexOf("*/",q+2);if(_>=0)Q=Q.slice(0,q)+Q.slice(_+2);else Y=!0,Q=Q.slice(0,q)}if(U>=0)Q=Q.slice(0,U);let W=Q.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),K=/(\b[\w$]+)\s*&&\s*\1\.([\w$]+)/g,H;while((H=K.exec(W))!==null){let _=H[1],B=H[2],F=H.index,M=G.indexOf(H[0],Math.max(0,F-5));Z.push({filePath:J.filePath,line:z+1,column:M>=0?M+1:F+1,ruleId:"ts/prefer-optional-chain",message:`Prefer optional chaining over && for property access: ${_}?.${B}`,severity:"error",help:`Use \`${_}?.${B}\` instead of \`${_} && ${_}.${B}\``})}let V=/([\w$]+\.[\w$.]+)\s*&&\s*\1\.([\w$]+)/g;V.lastIndex=0;while((H=V.exec(W))!==null){let _=H[1],B=H[2],F=H.index,M=G.indexOf(H[0],Math.max(0,F-5));Z.push({filePath:J.filePath,line:z+1,column:M>=0?M+1:F+1,ruleId:"ts/prefer-optional-chain",message:`Prefer optional chaining over && for nested property access: ${_}?.${B}`,severity:"error",help:`Use \`${_}?.${B}\` instead of \`${_} && ${_}.${B}\``})}let A=W.split(/\s*&&\s*/);if(A.length>=3)for(let _=0;_<A.length-2;_++){let B=A[_].trim(),F=A[_+1].trim(),M=A[_+2].trim();if(F.startsWith(`${B}.`)&&M.startsWith(`${F}.`)){let N=G.indexOf(B);Z.push({filePath:J.filePath,line:z+1,column:N>=0?N+1:1,ruleId:"ts/prefer-optional-chain",message:"Prefer optional chaining over multiple && checks for nested properties",severity:"error",help:`Use optional chaining like \`${B}?.${F.slice(B.length+1)}?.${M.slice(F.length+1)}\``});break}}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.replace(/(\b[\w$]+)\s*&&\s*\1\.([\w$]+)/g,"$1?.$2"),Y=Y.replace(/([\w$]+\.[\w$.]+)\s*&&\s*\1\.([\w$]+)/g,"$1?.$2"),Z.push(Y)}return Z.join(`
196
- `)}};function dG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var TY=/([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,EY={meta:{docs:"Require consistent spacing around type annotation colons",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;TY.lastIndex=0;while((G=TY.exec(z))!==null){if(dG(z,G.index))continue;let q=G[0],U=q.indexOf(":"),W=G.index+U;if(U>0&&q[U-1]===" "&&!q.startsWith("?")){if(!G[1].endsWith("?")||q[U-1]===" "){if(z[W-1]===" "&&!/\?\s*$/.test(G[1]))Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"ts/type-annotation-spacing",message:"Unexpected space before colon in type annotation",severity:"warning"})}}if(W+1<z.length&&z[W+1]!==" "&&z[W+1]!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:W+2,ruleId:"ts/type-annotation-spacing",message:"Missing space after colon in type annotation",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.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"),Z.push(Y)}return Z.join(`
197
- `)}};function DY($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var RY=/([A-Za-z_$][A-Za-z0-9_$]*)\s*<(\s+)/g,OY=/(\s+)>(?!=)/g,oG=/([A-Za-z_$][A-Za-z0-9_$]*)\s*<\s+/g,cG=/\s+>(?!=)/g,LY={meta:{docs:"Disallow spaces inside TypeScript generic angle brackets",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;RY.lastIndex=0;let G;while((G=RY.exec(z))!==null){let q=G.index+G[1].length,U=z.indexOf("<",q);if(U===-1)continue;if(DY(z,U))continue;Z.push({filePath:J.filePath,line:Y+1,column:U+2,ruleId:"ts/type-generic-spacing",message:"Unexpected space after '<' in generic type",severity:"warning"})}OY.lastIndex=0;while((G=OY.exec(z))!==null){let q=G.index+G[1].length;if(DY(z,q))continue;let U=z.slice(0,q);if(!/[A-Za-z_$][A-Za-z0-9_$]*\s*</.test(U))continue;Z.push({filePath:J.filePath,line:Y+1,column:q+1,ruleId:"ts/type-generic-spacing",message:"Unexpected space before '>' in generic type",severity:"warning"})}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y of Z){let z=Y.trim();if(!z||z.startsWith("//")||z.startsWith("*")||z.startsWith("/*")){X.push(Y);continue}let Q=Y;if(Q=Q.replace(oG,(G,q)=>{return`${q}<`}),/[A-Za-z_$][A-Za-z0-9_$]*\s*</.test(Q))Q=Q.replace(cG,">");X.push(Q)}return X.join(`
198
- `)}};function rG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var PY=/([a-zA-Z_$][a-zA-Z0-9_$?]*):(\S)/g,SY={meta:{docs:"Require space after colon in named tuple members",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=CY(z);for(let q of G){PY.lastIndex=0;let U;while((U=PY.exec(q.text))!==null){let K=q.start+U.index+U[1].length;if(rG(z,K))continue;if(!IY(z))continue;Z.push({filePath:J.filePath,line:Y+1,column:K+2,ruleId:"ts/type-named-tuple-spacing",message:"Missing space after colon in named tuple member",severity:"warning"})}}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y of Z){let z=Y.trim();if(!z||z.startsWith("//")||z.startsWith("*")||z.startsWith("/*")){X.push(Y);continue}if(!IY(Y)){X.push(Y);continue}let Q=Y,G=CY(Y);for(let q=G.length-1;q>=0;q--){let U=G[q],W=U.text.replace(/([a-zA-Z_$][a-zA-Z0-9_$?]*):(\S)/g,"$1: $2");if(W!==U.text)Q=Q.slice(0,U.start)+W+Q.slice(U.start+U.text.length)}X.push(Q)}return X.join(`
199
- `)}};function CY($){let J=[],Z=0,X=-1;for(let Y=0;Y<$.length;Y++)if($[Y]==="["){if(Z===0)X=Y;Z++}else if($[Y]==="]"){if(Z--,Z===0&&X>=0)J.push({start:X,text:$.slice(X,Y+1)}),X=-1}return J}function IY($){let J=$.trim();return/\btype\s/.test(J)||/:\s*\[/.test(J)||/=\s*\[/.test(J)||/\bas\s/.test(J)||/<[^>]*\[/.test(J)||/\bextends\s/.test(J)||/\bimplements\s/.test(J)}var vY={name:"ts",rules:{"no-require-imports":w(FY),"no-top-level-await":w(BY),"no-ts-export-equal":w(wY),"no-explicit-any":w(VY),"prefer-nullish-coalescing":w(jY),"prefer-optional-chain":w(NY),"no-floating-promises":w(AY),"no-misused-promises":w(_Y),"no-unsafe-assignment":w(MY),"member-delimiter-style":w(HY),"type-annotation-spacing":w(EY),"type-generic-spacing":w(LY),"type-named-tuple-spacing":w(SY)}};var yY={name:"unused-imports",rules:{"no-unused-vars":w(n0),"no-unused-imports":w(n0)}};function U9(){return[IZ,pZ,dX,mX,KY,lX,vY,ZX,M5,j5,YX,iZ,BX,yY,zX]}var W9=null;function gY(){if(!W9)W9=new J1("pickier",{showTags:!1});return W9}function N1(...$){if(v0.TRACE)gY().debug("[pickier:trace]",$)}async function kY($,J,Z){let X,Y=new Promise((z,Q)=>{X=setTimeout(()=>Q(Error(`Timeout after ${J}ms at ${Z}`)),J)});try{let z=await Promise.race([$,Y]);return clearTimeout(X),z}catch(z){throw gY().error(`[pickier:error] ${Z} failed:`,z?.message||z),N1("withTimeout error:",Z,z),z}}function pY($){if($.length===0)return"";let J=new Map;for(let X of $){let Y=J.get(X.filePath)||[];Y.push(X),J.set(X.filePath,Y)}let Z="";for(let[X,Y]of J){Z+=`
190
+ `,Y.index),G=Y.index-Q;Z.push({filePath:J.filePath,line:z,column:G,ruleId:"style/wrap-iife",message:"Wrap immediately invoked function expressions in parentheses",severity:"warning"})}return Z},fix($){return $.replace(/([^a-zA-Z_$(\n])(function\s*\([^)]*\)\s*\{[^}]*\})\s*\(/g,"$1($2)(")}};var WY=/\byield\s*\*/g;function cG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var KY={meta:{docs:"Enforce spacing around * in yield* expressions (no space before *, space after)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;WY.lastIndex=0;while((G=WY.exec(z))!==null){let q=G.index;if(cG(z,q))continue;let U=G[0],W=q+U.length-1,K=W+1;if(U!=="yield*")Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"style/yield-star-spacing",message:"Unexpected space before * in yield expression",severity:"warning"});if(K<z.length&&z[K]!==" "&&z[K]!=="\t"&&z[K]!==`
191
+ `)Z.push({filePath:J.filePath,line:Y+1,column:K+1,ruleId:"style/yield-star-spacing",message:"Missing space after * in yield expression",severity:"warning"})}}return Z},fix($,J){let Z=$;return Z=Z.replace(/\byield\s+\*/g,"yield*"),Z=Z.replace(/\byield\*(\S)/g,"yield* $1"),Z}};var HY={name:"style",rules:{"brace-style":w(C5),curly:w(u5),"max-statements-per-line":w(Q6),"if-newline":w(t5),"consistent-chaining":w(f5),"consistent-list-newline":w(h5),"indent-unindent":w(e5),"no-multi-spaces":C6,"no-multiple-empty-lines":I6,"no-trailing-spaces":v6,"keyword-spacing":w(X6),"arrow-spacing":w(L5),"space-infix-ops":w(t6),"object-curly-spacing":w(b6),"spaced-comment":w(ZY),"block-spacing":w(P5),"space-before-blocks":w(o6),"comma-spacing":w(y5),"semi-spacing":w(m6),"rest-spread-spacing":w(u6),"generator-star-spacing":w(i5),"yield-star-spacing":w(KY),"function-call-spacing":w(a5),"template-tag-spacing":w(qY),"no-whitespace-before-property":w(F6),"key-spacing":w(Z6),"computed-property-spacing":w(k5),"array-bracket-spacing":w(E5),"space-in-parens":w(n6),"template-curly-spacing":w(zY),"space-unary-ops":w($Y),"switch-colon-spacing":w(XY),"comma-dangle":w(v5),"arrow-parens":w(R5),"space-before-function-paren":w(a6),"quote-props":w(x6),"no-floating-decimal":w(L6),"new-parens":w(K6),"no-extra-parens":w(V6),"wrap-iife":w(UY),"comma-style":w(b5),"dot-location":w(m5),"operator-linebreak":w(g6),"multiline-ternary":w(U6),"padded-blocks":w(p6),"lines-between-class-members":w(z6),"no-mixed-operators":w(E6),"indent-binary-ops":w(c5),"no-tabs":w(S6),"no-mixed-spaces-and-tabs":w(P6)}};var VY={meta:{docs:"Enforce consistent member delimiter style in interfaces and type literals",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z=0,Q=0;for(let G=0;G<X.length;G++){let q=X[G],U=q.trim();if(!U||U.startsWith("//")||U.startsWith("*")||U.startsWith("/*"))continue;if(U.match(/\b(interface|type)\b.*\{/))Y=!0,Q=z+1;for(let W of U){if(W==="{")z++;if(W==="}")z--}if(Y&&z<Q){Y=!1;continue}if(!Y||z!==Q)continue;if(U==="}"||U==="};"||U==="},")continue;if(U.endsWith(",")){if(U.startsWith("|")||U.startsWith("&"))continue;Z.push({filePath:J.filePath,line:G+1,column:q.length,ruleId:"ts/member-delimiter-style",message:"Expected semicolon delimiter in interface, found comma",severity:"warning"})}if(!U.endsWith(";")&&!U.endsWith(",")&&!U.endsWith("{")&&!U.endsWith("(")){if(U.match(/^\w+[\s?]*:/)||U.match(/^\[/)||U.match(/^readonly\b/))Z.push({filePath:J.filePath,line:G+1,column:q.length+1,ruleId:"ts/member-delimiter-style",message:"Missing semicolon delimiter in interface member",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[],X=!1,Y=0,z=0;for(let Q=0;Q<J.length;Q++){let G=J[Q],q=G.trim();if(q.match(/\b(interface|type)\b.*\{/))X=!0,z=Y+1;let U=Y;for(let W of q){if(W==="{")Y++;if(W==="}")Y--}if(X&&Y<z){X=!1,Z.push(G);continue}if(X&&U===z&&q!=="}"&&q!=="};"&&q!=="},"){let W=G;if(q.endsWith(","))W=G.replace(/,\s*$/,";");Z.push(W);continue}Z.push(G)}return Z.join(`
192
+ `)}};var AY={meta:{docs:"Disallow the use of the `any` type - it defeats the purpose of TypeScript type safety"},check:($,J)=>{let Z=[];if(!/\.tsx?$/.test(J.filePath))return Z;let X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z],G=Q;if(Y){let V=Q.indexOf("*/");if(V>=0)Q=Q.slice(V+2),Y=!1;else continue}let q=Q.indexOf("/*"),U=Q.indexOf("//");if(q>=0&&(U===-1||q<U)){let V=Q.indexOf("*/",q+2);if(V>=0)Q=Q.slice(0,q)+Q.slice(V+2);else Y=!0,Q=Q.slice(0,q)}if(U>=0)Q=Q.slice(0,U);let W=Q.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),K=/\b(any)\b/g,H;while((H=K.exec(W))!==null){let V=H.index,A=W[V-1]||" ",_=W[V+3]||" ",B=W.slice(Math.max(0,V-10),V),F=W.slice(V+3,Math.min(W.length,V+10));if(/\w/.test(A)||/\w/.test(_))continue;if(/:/.test(B)||/</.test(B)||/\bas\s*$/.test(B)||/,/.test(B)||/\|/.test(B)||/&/.test(B)||/\[/.test(F)||/>/.test(F)||/,/.test(F)||/\|/.test(F)||/extends\s+$/.test(B)||/=\s*$/.test(B)){let T=G.indexOf("any",Math.max(0,V-5));Z.push({filePath:J.filePath,line:z+1,column:T>=0?T+1:V+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 Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.replace(/:\s*any\b(?!\s*\))/g,(z)=>{return z.replace("any","unknown")}),Z.push(Y)}return Z.join(`
193
+ `)}};var _Y={meta:{docs:"Require promises to be handled - must be awaited, returned, or have .catch() called"},check:($,J)=>{let Z=[];if(!/\.tsx?$/.test(J.filePath))return Z;let X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z],G=Q;if(Y){let H=Q.indexOf("*/");if(H>=0)Q=Q.slice(H+2),Y=!1;else continue}let q=Q.indexOf("/*"),U=Q.indexOf("//");if(q>=0&&(U===-1||q<U)){let H=Q.indexOf("*/",q+2);if(H>=0)Q=Q.slice(0,q)+Q.slice(H+2);else Y=!0,Q=Q.slice(0,q)}if(U>=0)Q=Q.slice(0,U);let W=Q.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""');if(/\b(?:await|return|void)\s/.test(W))continue;if(/\.(?:then|catch|finally)\s*\(/.test(W))continue;let K=[/\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 H of K){let V=W.match(H);if(!V)continue;let A=W.indexOf(V[0]),_=W.slice(0,A).trim();if(/\b(?:const|let|var)\s+[\w$]+\s*=\s*$/.test(_))continue;if(/[\w$]+\s*=\s*$/.test(_))continue;if(/\breturn\s+$/.test(_))continue;if(/\(\s*$/.test(_)||/,\s*$/.test(_))continue;let B=W.slice(A+V[0].length),F=1,M=V[0].length;while(M<B.length&&F>0){if(B[M]==="(")F++;else if(B[M]===")")F--;M++}let T=B.slice(M).trim();if(/^\.(?:then|catch|finally)\s*\(/.test(T))continue;if(T===""||T.startsWith(";")){let E=G.indexOf(V[0]);Z.push({filePath:J.filePath,line:z+1,column:E>=0?E+1:A+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 Z}};var FY={meta:{docs:"Disallow promises in places not designed to handle them (conditionals, logical expressions)"},check:($,J)=>{let Z=[];if(!/\.tsx?$/.test(J.filePath))return Z;let X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z],G=Q;if(Y){let B=Q.indexOf("*/");if(B>=0)Q=Q.slice(B+2),Y=!1;else continue}let q=Q.indexOf("/*"),U=Q.indexOf("//");if(q>=0&&(U===-1||q<U)){let B=Q.indexOf("*/",q+2);if(B>=0)Q=Q.slice(0,q)+Q.slice(B+2);else Y=!0,Q=Q.slice(0,q)}if(U>=0)Q=Q.slice(0,U);let W=Q.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),K=W.match(/\bif\s*\(\s*(!?)\s*([\w$]+\s*\([^)]*\))/);if(K){let B=K[1],F=K[2];if(/async|Async|fetch|Fetch|load|Load|get|Get|save|Save/.test(F)){let M=W.slice(0,W.indexOf(K[0])),T=W.slice(W.indexOf("if (")+4);if(!/\bawait\s/.test(T)){let E=G.indexOf(F);Z.push({filePath:J.filePath,line:z+1,column:E>=0?E+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 H=/(?:async|Async|fetch|Fetch|load|Load|get|Get|save|Save|Promise\.)[\w$]*\s*\([^)]*\)/g,V;while((V=H.exec(W))!==null){let B=V.index,F=V[0],M=W.slice(Math.max(0,B-10),B),T=W.slice(B+F.length,Math.min(W.length,B+F.length+10));if(/(?:&&|\|\|)\s*$/.test(M)||/^\s*(?:&&|\|\|)/.test(T)){if(!/\bawait\s*$/.test(M)){let j=G.indexOf(F,Math.max(0,B-5));Z.push({filePath:J.filePath,line:z+1,column:j>=0?j+1:B+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 E=W.slice(Math.max(0,B-20),B);if(/\?\s*$/.test(M)||/\?[^:]*$/.test(E)){if(!/\bawait\s*$/.test(M)){let j=G.indexOf(F,Math.max(0,B-5));Z.push({filePath:J.filePath,line:z+1,column:j>=0?j+1:B+1,ruleId:"ts/no-misused-promises",message:"Promise used in ternary expression without await.",severity:"error",help:"Add await before the async call"})}}}let A=W.match(/\b(?:while|for)\s*\([^)]*(?:async|Async|fetch|Fetch|load|Load|get|Get)[\w$]*\s*\([^)]*\)/);if(A){if(!/\bawait\s/.test(A[0])){let B=G.indexOf(A[0]);Z.push({filePath:J.filePath,line:z+1,column:B>=0?B+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 _=W.match(/\.(forEach|map|filter|reduce|every|some|find|findIndex)\s*\(\s*async\s*(?:\(|[\w$]+\s*=>)/);if(_){if(_[1]==="forEach"){let F=G.indexOf(_[0]);Z.push({filePath:J.filePath,line:z+1,column:F>=0?F+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 Z}};var BY={meta:{docs:"Disallow require() in TypeScript files; prefer ESM imports"},check:($,J)=>{let Z=[];if(!/\.ts$/.test(J.filePath))return Z;let X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z],G=Q;if(Y){let H=G.indexOf("*/");if(H>=0)G=G.slice(H+2),Y=!1;else continue}let q=G.indexOf("/*"),U=G.indexOf("//");if(q>=0&&(U===-1||q<U)){let H=G.indexOf("*/",q+2);if(H>=0)G=G.slice(0,q)+G.slice(H+2);else Y=!0,G=G.slice(0,q)}if(U>=0)G=G.slice(0,U);let W=G.trim();if(!W)continue;if(/\bimport\s*\(/.test(W))continue;let K=W.indexOf("require(");if(K>=0){Z.push({filePath:J.filePath,line:z+1,column:Q.indexOf("require(")+1||K+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(W)){let H=Q.indexOf("require(");Z.push({filePath:J.filePath,line:z+1,column:H>-1?H+1:1,ruleId:"ts/no-require-imports",message:"Do not use require() in TypeScript files. Use ESM import syntax instead.",severity:"error"})}}return Z}};var wY={meta:{docs:"Disallow top-level await in TypeScript/JavaScript files"},check:($,J)=>{let Z=[],X=J.filePath.split(".").pop()||"";if(!["ts","tsx","mts","cts","js","mjs","cjs"].includes(X))return Z;let Y=0,z=!1,Q=!1,G=!1,q=!1,U=!1,W=!1,K=0,H=1,V=(A)=>{Z.push({filePath:J.filePath,line:H,column:A,ruleId:"ts/no-top-level-await",message:"Do not use top-level await",severity:"error"})};for(let A=0;A<$.length;A++){let _=$[A];K++;let B=$[A+1];if(_===`
194
+ `){Q=!1,H++,K=0;continue}if(Q)continue;if(z){if(_==="*"&&B==="/")z=!1,A++,K++;continue}if(G){if(!W&&_==="\\"){W=!0;continue}if(!W&&_==="'")G=!1;W=!1;continue}if(q){if(!W&&_==="\\"){W=!0;continue}if(!W&&_==='"')q=!1;W=!1;continue}if(U){if(!W&&_==="\\"){W=!0;continue}if(!W&&_==="`")U=!1;W=!1;continue}if(_==="/"&&B==="*"){z=!0,A++,K++;continue}if(_==="/"&&B==="/"){Q=!0,A++,K++;continue}if(_==="'"){G=!0;continue}if(_==='"'){q=!0;continue}if(_==="`"){U=!0;continue}if(_==="{"){Y++;continue}if(_==="}"){if(Y>0)Y--;continue}if(_==="a"&&$.slice(A,A+5)==="await"){let F=$.slice(Math.max(0,A-6),A),M=/for\s+$/.test(F),T=A===0||/[^$\w]/.test($[A-1]),E=/[^$\w]/.test($[A+5]||" ");if(!M&&T&&E&&Y===0)V(K);A+=4,K+=4;continue}}return Z}};var MY={meta:{docs:"Disallow `exports =` in TypeScript; prefer ESM export default"},check:($,J)=>{let Z=[],X=J.filePath.split(".").pop()||"";if(!["ts","tsx","mts","cts","d.ts"].includes(X))return Z;let Y=$.split(/\r?\n/);for(let z=0;z<Y.length;z++){let q=Y[z].replace(/\/\*.*?\*\//g,"").replace(/\/\/.*$/,"").match(/\bexports\s*=\s*/);if(q)Z.push({filePath:J.filePath,line:z+1,column:(q.index||0)+1,ruleId:"ts/no-ts-export-equal",message:"Use ESM `export default` instead of `exports =`",severity:"error"})}return Z}};var jY={meta:{docs:"Disallow assignment of `any` typed values to variables - unsafe assignments bypass type checking"},check:($,J)=>{let Z=[];if(!/\.tsx?$/.test(J.filePath))return Z;let X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z],G=Q;if(Y){let M=Q.indexOf("*/");if(M>=0)Q=Q.slice(M+2),Y=!1;else continue}let q=Q.indexOf("/*"),U=Q.indexOf("//");if(q>=0&&(U===-1||q<U)){let M=Q.indexOf("*/",q+2);if(M>=0)Q=Q.slice(0,q)+Q.slice(M+2);else Y=!0,Q=Q.slice(0,q)}if(U>=0)Q=Q.slice(0,U);let W=Q.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),K=/(\w+)\s+as\s+any/g,H;while((H=K.exec(W))!==null){let M=H[1],T=H.index,E=W.slice(T+H[0].length).trim(),j=W.slice(0,T).trim();if(/=\s*$/.test(j)&&!/==|===|!=|!==/.test(j)){let O=G.indexOf(H[0]);Z.push({filePath:J.filePath,line:z+1,column:O>=0?O+1:T+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 V=["JSON.parse","eval","Function","require"];for(let M of V){let T=new RegExp(`\\b${M.replace(".","\\.")}\\s*\\(`,"g");T.lastIndex=0;while((H=T.exec(W))!==null){let E=H.index,j=W.slice(0,E).trim(),O=j.match(/(?:const|let|var)\s+([\w$]+)\s*=\s*$/);if(O){let C=O[1];if(!new RegExp(`\\b${C}\\s*:\\s*\\w+`).test(W)){let P=G.indexOf(H[0]);Z.push({filePath:J.filePath,line:z+1,column:P>=0?P+1:E+1,ruleId:"ts/no-unsafe-assignment",message:`Unsafe assignment from ${M}() without type annotation. This function returns 'any'.`,severity:"error",help:`Add a type annotation to ${C} or use a type assertion with a specific type`})}}let v=j.match(/([\w$.]+)\s*=\s*$/),y=/(?:const|let|var)\s+/.test(j);if(v&&!O&&!y){let C=G.indexOf(H[0]);Z.push({filePath:J.filePath,line:z+1,column:C>=0?C+1:E+1,ruleId:"ts/no-unsafe-assignment",message:`Unsafe assignment from ${M}() which returns 'any'.`,severity:"error",help:"Consider adding a type assertion with a specific type"})}}}let A=/(?:const|let|var)\s+([\w$]+)\s*:\s*any\s*=/,_=W.match(A);if(_){let M=_[1],T=G.indexOf(_[0]);Z.push({filePath:J.filePath,line:z+1,column:T>=0?T+1:1,ruleId:"ts/no-unsafe-assignment",message:`Variable '${M}' 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 B=/(?:const|let|var)\s+(?:\{[^}]+\}|\[[^\]]+\])\s*=\s*([\w$]+)/,F=W.match(B);if(F){let M=F[1];if(/^(?:params|query|body|req|res|response|data|result)$/.test(M));}}return Z}};var NY={meta:{docs:"Prefer nullish coalescing operator (??) over logical OR (||) when checking for null/undefined"},check:($,J)=>{let Z=[];if(!/\.tsx?$/.test(J.filePath))return Z;let X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z],G=Q.split(""),q=G.length,U=0;if(Y){let A=Q.indexOf("*/");if(A<0)continue;for(let _=0;_<=A+1;_++)G[_]=" ";Y=!1,U=A+2}let W=null;for(;U<q;U++){let A=G[U];if(W){if(A==="\\"){if(G[U]=" ",U+1<q)G[U+1]=" ",U++;continue}if(A===W){W=null;continue}G[U]=" ";continue}if(A==="/"&&G[U+1]==="/"){for(let _=U;_<q;_++)G[_]=" ";break}if(A==="/"&&G[U+1]==="*"){let _=Q.indexOf("*/",U+2);if(_<0){for(let B=U;B<q;B++)G[B]=" ";Y=!0;break}for(let B=U;B<=_+1;B++)G[B]=" ";U=_+1;continue}if(A==='"'||A==="'"||A==="`")W=A}let K=G.join(""),H=/\|\|/g,V;while((V=H.exec(K))!==null){let A=V.index,_=A-1,B=0,F=0,M=0;while(_>=0){let C=K[_];if(C===")")B++;else if(C==="("){if(B===0){_++;break}B--}else if(C==="}")F++;else if(C==="{"){if(F===0){_++;break}F--}else if(C==="]")M++;else if(C==="["){if(M===0){_++;break}M--}else if(B===0&&F===0&&M===0){if(new RegExp("[;,=:?]").test(C)){_++;break}if(C==="&"||C==="|"){_++;break}}_--}if(_<0)_=0;let T=K.slice(_,A).trim();if(/[<>!=]/.test(T))continue;if(/\b(?:true|false)\b/.test(T))continue;let E=A+2,j=E;B=0,F=0,M=0;while(j<K.length){let C=K[j];if(C==="(")B++;else if(C===")"){if(B===0)break;B--}else if(C==="{")F++;else if(C==="}"){if(F===0)break;F--}else if(C==="[")M++;else if(C==="]"){if(M===0)break;M--}else if(B===0&&F===0&&M===0){if(new RegExp("[;,?:]").test(C))break;if(C==="&"||C==="|"&&K[j+1]==="|")break}j++}let O=K.slice(E,j).trim(),v=/^["'`\d]/.test(O)||/^\{/.test(O)||/^[\w$]+\(/.test(O)||/^[\w$.[\]]+$/.test(O),y=/^[\w$]+$/.test(T)||/^[\w$.?[\]()]+$/.test(T);if(v&&y)Z.push({filePath:J.filePath,line:z+1,column:A+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 Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X,z=new RegExp("(\\b[\\w$.]+)\\s*\\|\\|\\s*([^|&]+?)(?=\\s*[;,)\\]}]|$)","g");Y=Y.replace(z,(Q,G,q)=>{if(/\b(?:true|false)\b/.test(q.trim()))return Q;return`${G} ?? ${q}`}),Z.push(Y)}return Z.join(`
195
+ `)}};var TY={meta:{docs:"Prefer optional chaining (?.) over chained logical AND (&&) for property access"},check:($,J)=>{let Z=[];if(!/\.tsx?$/.test(J.filePath))return Z;let X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z],G=Q;if(Y){let _=Q.indexOf("*/");if(_>=0)Q=Q.slice(_+2),Y=!1;else continue}let q=Q.indexOf("/*"),U=Q.indexOf("//");if(q>=0&&(U===-1||q<U)){let _=Q.indexOf("*/",q+2);if(_>=0)Q=Q.slice(0,q)+Q.slice(_+2);else Y=!0,Q=Q.slice(0,q)}if(U>=0)Q=Q.slice(0,U);let W=Q.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),K=/(\b[\w$]+)\s*&&\s*\1\.([\w$]+)/g,H;while((H=K.exec(W))!==null){let _=H[1],B=H[2],F=H.index,M=G.indexOf(H[0],Math.max(0,F-5));Z.push({filePath:J.filePath,line:z+1,column:M>=0?M+1:F+1,ruleId:"ts/prefer-optional-chain",message:`Prefer optional chaining over && for property access: ${_}?.${B}`,severity:"error",help:`Use \`${_}?.${B}\` instead of \`${_} && ${_}.${B}\``})}let V=/([\w$]+\.[\w$.]+)\s*&&\s*\1\.([\w$]+)/g;V.lastIndex=0;while((H=V.exec(W))!==null){let _=H[1],B=H[2],F=H.index,M=G.indexOf(H[0],Math.max(0,F-5));Z.push({filePath:J.filePath,line:z+1,column:M>=0?M+1:F+1,ruleId:"ts/prefer-optional-chain",message:`Prefer optional chaining over && for nested property access: ${_}?.${B}`,severity:"error",help:`Use \`${_}?.${B}\` instead of \`${_} && ${_}.${B}\``})}let A=W.split(/\s*&&\s*/);if(A.length>=3)for(let _=0;_<A.length-2;_++){let B=A[_].trim(),F=A[_+1].trim(),M=A[_+2].trim();if(F.startsWith(`${B}.`)&&M.startsWith(`${F}.`)){let T=G.indexOf(B);Z.push({filePath:J.filePath,line:z+1,column:T>=0?T+1:1,ruleId:"ts/prefer-optional-chain",message:"Prefer optional chaining over multiple && checks for nested properties",severity:"error",help:`Use optional chaining like \`${B}?.${F.slice(B.length+1)}?.${M.slice(F.length+1)}\``});break}}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.replace(/(\b[\w$]+)\s*&&\s*\1\.([\w$]+)/g,"$1?.$2"),Y=Y.replace(/([\w$]+\.[\w$.]+)\s*&&\s*\1\.([\w$]+)/g,"$1?.$2"),Z.push(Y)}return Z.join(`
196
+ `)}};function rG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var EY=/([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,DY={meta:{docs:"Require consistent spacing around type annotation colons",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;EY.lastIndex=0;while((G=EY.exec(z))!==null){if(rG(z,G.index))continue;let q=G[0],U=q.indexOf(":"),W=G.index+U;if(U>0&&q[U-1]===" "&&!q.startsWith("?")){if(!G[1].endsWith("?")||q[U-1]===" "){if(z[W-1]===" "&&!/\?\s*$/.test(G[1]))Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"ts/type-annotation-spacing",message:"Unexpected space before colon in type annotation",severity:"warning"})}}if(W+1<z.length&&z[W+1]!==" "&&z[W+1]!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:W+2,ruleId:"ts/type-annotation-spacing",message:"Missing space after colon in type annotation",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.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"),Z.push(Y)}return Z.join(`
197
+ `)}};function RY($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var OY=/([A-Za-z_$][A-Za-z0-9_$]*)\s*<(\s+)/g,LY=/(\s+)>(?!=)/g,lG=/([A-Za-z_$][A-Za-z0-9_$]*)\s*<\s+/g,aG=/\s+>(?!=)/g,PY={meta:{docs:"Disallow spaces inside TypeScript generic angle brackets",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;OY.lastIndex=0;let G;while((G=OY.exec(z))!==null){let q=G.index+G[1].length,U=z.indexOf("<",q);if(U===-1)continue;if(RY(z,U))continue;Z.push({filePath:J.filePath,line:Y+1,column:U+2,ruleId:"ts/type-generic-spacing",message:"Unexpected space after '<' in generic type",severity:"warning"})}LY.lastIndex=0;while((G=LY.exec(z))!==null){let q=G.index+G[1].length;if(RY(z,q))continue;let U=z.slice(0,q);if(!/[A-Za-z_$][A-Za-z0-9_$]*\s*</.test(U))continue;Z.push({filePath:J.filePath,line:Y+1,column:q+1,ruleId:"ts/type-generic-spacing",message:"Unexpected space before '>' in generic type",severity:"warning"})}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y of Z){let z=Y.trim();if(!z||z.startsWith("//")||z.startsWith("*")||z.startsWith("/*")){X.push(Y);continue}let Q=Y;if(Q=Q.replace(lG,(G,q)=>{return`${q}<`}),/[A-Za-z_$][A-Za-z0-9_$]*\s*</.test(Q))Q=Q.replace(aG,">");X.push(Q)}return X.join(`
198
+ `)}};function sG($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var CY=/([a-zA-Z_$][a-zA-Z0-9_$?]*):(\S)/g,vY={meta:{docs:"Require space after colon in named tuple members",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=IY(z);for(let q of G){CY.lastIndex=0;let U;while((U=CY.exec(q.text))!==null){let K=q.start+U.index+U[1].length;if(sG(z,K))continue;if(!SY(z))continue;Z.push({filePath:J.filePath,line:Y+1,column:K+2,ruleId:"ts/type-named-tuple-spacing",message:"Missing space after colon in named tuple member",severity:"warning"})}}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y of Z){let z=Y.trim();if(!z||z.startsWith("//")||z.startsWith("*")||z.startsWith("/*")){X.push(Y);continue}if(!SY(Y)){X.push(Y);continue}let Q=Y,G=IY(Y);for(let q=G.length-1;q>=0;q--){let U=G[q],W=U.text.replace(/([a-zA-Z_$][a-zA-Z0-9_$?]*):(\S)/g,"$1: $2");if(W!==U.text)Q=Q.slice(0,U.start)+W+Q.slice(U.start+U.text.length)}X.push(Q)}return X.join(`
199
+ `)}};function IY($){let J=[],Z=0,X=-1;for(let Y=0;Y<$.length;Y++)if($[Y]==="["){if(Z===0)X=Y;Z++}else if($[Y]==="]"){if(Z--,Z===0&&X>=0)J.push({start:X,text:$.slice(X,Y+1)}),X=-1}return J}function SY($){let J=$.trim();return/\btype\s/.test(J)||/:\s*\[/.test(J)||/=\s*\[/.test(J)||/\bas\s/.test(J)||/<[^>]*\[/.test(J)||/\bextends\s/.test(J)||/\bimplements\s/.test(J)}var yY={name:"ts",rules:{"no-require-imports":w(BY),"no-top-level-await":w(wY),"no-ts-export-equal":w(MY),"no-explicit-any":w(AY),"prefer-nullish-coalescing":w(NY),"prefer-optional-chain":w(TY),"no-floating-promises":w(_Y),"no-misused-promises":w(FY),"no-unsafe-assignment":w(jY),"member-delimiter-style":w(VY),"type-annotation-spacing":w(DY),"type-generic-spacing":w(PY),"type-named-tuple-spacing":w(vY)}};var bY={name:"unused-imports",rules:{"no-unused-vars":w(n0),"no-unused-imports":w(n0)}};function U9(){return[SZ,xZ,oX,dX,HY,aX,yY,JX,j5,N5,zX,tZ,wX,bY,QX]}var W9=null;function pY(){if(!W9)W9=new J1("pickier",{showTags:!1});return W9}function E1(...$){if(y0.TRACE)pY().debug("[pickier:trace]",$)}async function fY($,J,Z){let X,Y=new Promise((z,Q)=>{X=setTimeout(()=>Q(Error(`Timeout after ${J}ms at ${Z}`)),J)});try{let z=await Promise.race([$,Y]);return clearTimeout(X),z}catch(z){throw pY().error(`[pickier:error] ${Z} failed:`,z?.message||z),E1("withTimeout error:",Z,z),z}}function xY($){if($.length===0)return"";let J=new Map;for(let X of $){let Y=J.get(X.filePath)||[];Y.push(X),J.set(X.filePath,Y)}let Z="";for(let[X,Y]of J){Z+=`
200
200
  ${J0.bold(`\x1B[4m${X}\x1B[24m`)}
201
- `;let z;try{z=fY(X,"utf8")}catch{for(let G of Y){let q=G.severity==="error"?J0.red("error"):J0.yellow("warn ");Z+=` ${G.line}:${G.column} ${q} ${G.message} ${J0.blue(G.ruleId)}
201
+ `;let z;try{z=gY(X,"utf8")}catch{for(let G of Y){let q=G.severity==="error"?J0.red("error"):J0.yellow("warn ");Z+=` ${G.line}:${G.column} ${q} ${G.message} ${J0.blue(G.ruleId)}
202
202
  `}continue}let Q=z.split(/\r?\n/);for(let G of Y){let q=G.severity==="error"?J0.red("!"):J0.yellow("!"),U=J0.blue(G.ruleId);Z+=`
203
203
  ${q} ${U}: ${G.message}
204
204
  `;let W=2,K=2,H=Math.max(1,G.line-W),V=Math.min(Q.length,G.line+K),_=String(V).length;Z+=` ${J0.gray(" ,-")}${J0.gray(`[:${G.line}:${G.column}]`)}
@@ -208,18 +208,17 @@ ${J0.bold(`\x1B[4m${X}\x1B[24m`)}
208
208
  `;else Z+=` ${J0.gray(F)} ${J0.gray("| ")}${M}
209
209
  `}if(Z+=` ${J0.gray(" `----")}
210
210
  `,G.help)Z+=` ${J0.blue("help")}: ${G.help}
211
- `}}return Z}function xY($){if($.length===0)return"";let J=new Map;for(let X of $){let Y=J.get(X.filePath)||[];Y.push(X),J.set(X.filePath,Y)}let Z="";for(let[X,Y]of J){Z+=`
211
+ `}}return Z}function hY($){if($.length===0)return"";let J=new Map;for(let X of $){let Y=J.get(X.filePath)||[];Y.push(X),J.set(X.filePath,Y)}let Z="";for(let[X,Y]of J){Z+=`
212
212
  ${J0.bold(`\x1B[4m${X}\x1B[24m`)}
213
213
  `;for(let z of Y){let Q=z.severity==="error"?J0.red("error"):J0.yellow("warn "),q=`${z.line}:${z.column}`.padStart(6),U=60,W=z.message.padEnd(60);Z+=`${q} ${Q} ${W} ${J0.blue(z.ruleId)}
214
- `}}return Z}async function cj($,J){N1("runFormat:start",{globs:$,options:J});let Z=await x1(J.config),X=$.length?$:["."],Y=h1(X);N1("patterns",Y);let z=new Set((J.ext||Z.format.extensions.join(",")).split(",").map((B)=>{let F=B.trim();return F.startsWith(".")?F:`.${F}`})),Q=v0.TIMEOUT_MS,q=Y.some((B)=>{let F=B.replace(/\/?\*\*(?:\/\*+)?$/,"");return!(aG(F)?F:sG(process.cwd(),F)).startsWith(process.cwd())})?$1(z1):$1(Z.ignores),U=u1(q),W=[];if(Y.length===1&&/\*\*\/\*$/.test(Y[0])){let B=Y[0].replace(/\/?\*\*\/\*$/,"");try{let{readdirSync:F,statSync:M}=await import("fs"),{join:N}=await import("path"),E=[B];while(E.length){let j=E.pop(),O=F(j);for(let y of O){let k=N(j,y),L=M(k);if(U(k))continue;if(L.isDirectory())E.push(k);else W.push(k)}}}catch{W=await kY(e0(Y,{dot:!1,ignore:q,onlyFiles:!0,absolute:!0}),Q,"glob")}}else W=await kY(e0(Y,{dot:!1,ignore:q,onlyFiles:!0,absolute:!0}),Q,"glob");N1("globbed entries",W.length);let H=W.filter((B)=>{if(U(B))return!1;let F=B.lastIndexOf(".");if(F<0)return!0;let M=B.slice(F);return z.has(M)});N1("filtered files",H.length);let V=0,A=[];for(let B of H){N1("format start",bY(process.cwd(),B));let F=fY(B,"utf8"),M=h8(F,Z,B),N=M!==F;if(J.write){if(N)lG(B,M,"utf8")}if(N)A.push(bY(process.cwd(),B));V++}let _=A.length;if(_>0){for(let B of A)console.log(J0.gray(` ${B}`));console.log(J.write?J0.gray(`Formatted ${_} of ${V} file(s).`):J0.yellow(`${_} of ${V} file(s) need formatting. Run with --write to fix.`))}else if(J.verbose!==void 0?J.verbose:Z.verbose)console.log(J0.gray(`Checked ${V} files, all formatted.`));return J.check&&_>0?1:0}var H9=null;function e(){if(!H9)H9=new J1("pickier:lint",{showTags:!1});return H9}function N0(...$){if(v0.TRACE)e().error("[pickier:trace]",$)}async function ZN($,J,Z="untitled",X){if(X?.aborted)throw Error("AbortError");let Y=D1($),z=R1($),Q=O1(Z,$,J,Y,z);if(X?.aborted)throw Error("AbortError");try{let G=await B9(Z,$,J);for(let q of G){if(X?.aborted)throw Error("AbortError");if(k0(q.ruleId,q.line,Y))continue;if(z.has(q.line)&&d8(q.ruleId))continue;Q.push({filePath:q.filePath,line:q.line,column:q.column,ruleId:q.ruleId,message:q.message,severity:q.severity,...q.help&&{help:q.help}})}}catch{}return Q}async function JN($,J,Z){N0("runLintProgrammatic:start",{globs:$,options:J});let X=await x1(J.config);if(Z?.aborted)throw Error("AbortError");let Y=$.length?$:["."],z=h1(Y),Q=J.ext||X.lint.extensions.join(","),G=new Set(Q.split(",").map((b)=>{let P=b.trim();return P.startsWith(".")?P:`.${P}`})),q=v0.TIMEOUT_MS,W=z.some((b)=>{let P=b.replace(/\/?\*\*\/*\*\*$/,""),I=T1(P)?P:E1(process.cwd(),P),S=process.cwd();return I!==S&&!I.startsWith(S+nY)})?$1(z1):$1(X.ignores),K=u1(W),H=[];if(z.length===1&&!/[*?[\]{}()!]/.test(z[0]))try{if(m8(z[0]).isFile())H=[T1(z[0])?z[0]:E1(process.cwd(),z[0])]}catch{}let A=z.length===1&&/\*\*\/*\*$/.test(z[0]);if(!H.length&&A){let b=z[0].replace(/\/?\*\*\/*\*\*$/,""),P=T1(b)?b:E1(process.cwd(),b);try{let I=[P];while(I.length){if(Z?.aborted)throw Error("AbortError");let S=I.pop(),C=lY(S);for(let T of C){let R=sY(S,T),D=m8(R);if(K(R))continue;if(D.isDirectory())I.push(R);else H.push(R)}}}catch{H=await d1(e0(z,{dot:!1,ignore:W,onlyFiles:!0,absolute:!0}),q,"glob")}}else if(!H.length)H=await d1(e0(z,{dot:!1,ignore:W,onlyFiles:!0,absolute:!0}),q,"glob");if(Z?.aborted)throw Error("AbortError");let _=0,B=0,F=0,M=0,N=0,E=[];for(let b of H){if(_++,b.replace(/\\/g,"/").includes("/node_modules/")){F++;continue}if(K(b)){M++;continue}if(!_9(b,G)){N++;continue}E.push(b),B++}N0("filter:programmatic",{total:_,included:B,node_modules:F,ignored:M,wrongExt:N});let j=v0.CONCURRENCY,k=(await tY(E,j,async(b)=>{if(Z?.aborted)throw Error("AbortError");let P=aY(b,"utf8"),I=D1(P),S=R1(P),C=O1(b,P,X,I,S);try{let T=await B9(b,P,X);for(let R of T){if(Z?.aborted)throw Error("AbortError");if(k0(R.ruleId,R.line,I))continue;if(S.has(R.line)&&d8(R.ruleId))continue;C.push({filePath:R.filePath,line:R.line,column:R.column,ruleId:R.ruleId,message:R.message,severity:R.severity,...R.help&&{help:R.help}})}}catch{}{let T=new Set;C=C.filter((R)=>{let D=`${R.line}:${R.column}:${R.ruleId}`;if(T.has(D))return!1;return T.add(D),!0})}if(J.fix){let T=/^\s*debugger\b/,R=P;if(X.rules.noDebugger==="error"||X.rules.noDebugger==="warn"){let f=R.split(/\r?\n/),h=[];for(let o of f){if(T.test(o))continue;h.push(o)}R=h.join(`
215
- `)}if(R=eY(b,R,X),R!==P){let f=D1(R),h=R1(R);if(C=O1(b,R,X,f,h),!J.dryRun)V9(b,R,"utf8")}}return C})).flat(),L=k.filter((b)=>b.severity==="error").length,x=k.filter((b)=>b.severity==="warning").length;return{errors:L,warnings:x,issues:k}}function nG($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function iG($){return $.replace(/-([a-z])/g,(J,Z)=>Z.toUpperCase())}function D1($){let J=new Map,Z=new Set,X=new Map,Y=new Map,z=$.split(/\r?\n/),Q=new Set;for(let U=0;U<z.length;U++){let W=z[U].trim(),K=U+1,H=W.match(/^\/\/\s*(?:eslint|pickier)-disable-next-line(?:\s+(\S.*))?$/);if(H){let F=H[1]?.replace(/\s+--\s.*$/,""),M=F?F.split(",").map((N)=>N.trim()).filter(Boolean):["*"];if(M.length>0){let N=K+1,E=J.get(N)||new Set;for(let j of M)E.add(j);J.set(N,E)}continue}let V=W.match(/^\/\*\s*(?:eslint|pickier)-disable(?:\s+([^*]+))?\s*\*\//);if(V){let F=V[1]?.trim().replace(/\s+--\s.*$/,"");if(!F||F==="")X.set(K,new Set(["*"])),Q.add("*");else{let M=F.split(",").map((E)=>E.trim()).filter(Boolean),N=X.get(K)||new Set;for(let E of M)N.add(E),Q.add(E);X.set(K,N)}if(U===0)if(!F||F==="")Z.add("*");else{let M=F.split(",").map((N)=>N.trim()).filter(Boolean);for(let N of M)Z.add(N)}continue}let A=W.match(/^\/\*\s*(?:eslint|pickier)-enable(?:\s+([^*]+))?\s*\*\//);if(A){let F=A[1]?.trim();if(!F||F==="")Y.set(K,new Set(["*"])),Q.clear();else{let M=F.split(",").map((E)=>E.trim()).filter(Boolean),N=Y.get(K)||new Set;for(let E of M)N.add(E),Q.delete(E);Y.set(K,N)}continue}let _=W.match(/^\/\/\s*(?:eslint|pickier)-disable(?:\s+(\S.*))?$/);if(_){let F=_[1]?.trim().replace(/\s+--\s.*$/,"");if(!F||F==="")X.set(K,new Set(["*"])),Q.add("*");else{let M=F.split(",").map((E)=>E.trim()).filter(Boolean),N=X.get(K)||new Set;for(let E of M)N.add(E),Q.add(E);X.set(K,N)}continue}let B=W.match(/^\/\/\s*(?:eslint|pickier)-enable(?:\s+(\S.*))?$/);if(B){let F=B[1]?.trim();if(!F||F==="")Y.set(K,new Set(["*"])),Q.clear();else{let M=F.split(",").map((E)=>E.trim()).filter(Boolean),N=Y.get(K)||new Set;for(let E of M)N.add(E),Q.delete(E);Y.set(K,N)}}}let G=Array.from(X.keys()).sort((U,W)=>U-W),q=Array.from(Y.keys()).sort((U,W)=>U-W);return{nextLine:J,fileLevel:Z,rangeDisable:X,rangeEnable:Y,sortedDisableLines:G,sortedEnableLines:q}}function k0($,J,Z){if(Z instanceof Map){let G=Z.get(J);if(!G||G.size===0)return!1;return m1($,G)}if(Z.fileLevel.size>0){if(m1($,Z.fileLevel))return!0}let X=Z.nextLine.get(J);if(X&&m1($,X))return!0;let Y=!1,z=0,Q=0;while(!0){let G=z<Z.sortedDisableLines.length?Z.sortedDisableLines[z]:Number.POSITIVE_INFINITY,q=Q<Z.sortedEnableLines.length?Z.sortedEnableLines[Q]:Number.POSITIVE_INFINITY,U=Math.min(G,q);if(U>=J)break;if(G===U){let K=Z.rangeDisable.get(G);if(m1($,K))Y=!0;z++;continue}let W=Z.rangeEnable.get(q);if(W.has("*")||m1($,W))Y=!1;Q++}return Y}function m1($,J){if(J.size===0)return!1;if(J.has("*"))return!0;if(J.has($))return!0;let Z=nG($);if(J.has(Z)||J.has(iG($)))return!0;for(let X of J)if(!X.includes("/")){if($.endsWith(`/${X}`))return!0}return!1}function d8($){return $!=="spaced-comment"&&!$.endsWith("/spaced-comment")}function iY($,J){if($.help)return $;let Z=J.includes("/")?J.split("/")[1]:J,X;if(Z.startsWith("no-"))X=`Remove or refactor this ${Z.replace("no-","").replace(/-/g," ")}. Check the rule documentation for more details or disable with: // eslint-disable-next-line ${J}`;else if(Z.startsWith("prefer-"))X=`Consider using ${Z.replace("prefer-","").replace(/-/g," ")} instead. This is a best practice recommendation. Disable with: // eslint-disable-next-line ${J} if needed`;else if(Z.includes("sort")||Z.includes("order"))X=`Reorder these items according to the rule requirements, or use --fix to auto-sort. Disable with: // eslint-disable-next-line ${J}`;else if(Z.includes("indent")||Z.includes("spacing")||Z.includes("newline"))X=`Fix the formatting issue. Run with --fix to automatically format. Disable with: // eslint-disable-next-line ${J}`;else X=`Fix this issue or disable the rule with: // eslint-disable-next-line ${J}. Check the rule documentation for more details`;return{...$,help:X}}async function d1($,J,Z){let X,Y=new Promise((z,Q)=>{X=setTimeout(()=>Q(Error(`Timeout after ${J}ms at ${Z}`)),J)});try{let z=await Promise.race([$,Y]);return clearTimeout(X),z}catch(z){throw e().error(`[pickier:error] ${Z} failed:`,z?.message||z),N0("withTimeout error:",Z,z),z}}async function tY($,J,Z){let X=Array($.length);if($.length===0)return X;let Y=0,z=Math.max(1,Math.min(Math.max(1,J),$.length));async function Q(){while(Y<$.length){let G=Y++;X[G]=await Z($[G],G)}}return await Promise.all(Array.from({length:z},Q)),X}var hY=new WeakMap;function tG($){let J=U9();if($.plugins&&$.plugins.length>0){let Z=new Set(["pickier","style","regexp","ts"]),X=$.plugins.filter((z)=>typeof z!=="string");J=X.some((z)=>Z.has(z.name))?J:[];for(let z of X)J.push(z)}return J}function eG($,J){let Z={...$.pluginRules||{}};if($.rules?.noUnusedCapturingGroup)Z["regexp/no-unused-capturing-group"]=$.rules.noUnusedCapturingGroup;let X={"antfu/curly":"style/curly","antfu/if-newline":"style/if-newline","antfu/no-top-level-await":"ts/no-top-level-await"};for(let[Y,z]of Object.entries(X))if(Z[Y])Z[z]=Z[Y];for(let Y of Object.keys($.pluginRules||{}))if(!Y.includes("/")){for(let z of J)if(z.rules&&Object.prototype.hasOwnProperty.call(z.rules,Y))Z[`${z.name}/${Y}`]=$.pluginRules[Y]}return Z}function o8($){let J=hY.get($);if(J)return J;let Z=tG($),X=eG($,Z),Y=[],z=[],Q=new Set(["no-debugger"]),G=new Set(["no-debugger"]),q=new Set;for(let W of Z)for(let K in W.rules){let H=`${W.name}/${K}`,V=rY(X,H);if(!V.enabled)continue;if(q.has(K))continue;q.add(K);let A=W.rules[K],_={pluginName:W.name,ruleName:K,fullRuleId:H,rule:A,severity:V.severity,options:V.options};if(typeof A?.check==="function")Y.push(_);else if(V.severity==="error")Y.push(_);if(typeof A?.fix==="function")z.push(_),Q.add(H),G.add(K)}let U={checkRules:Y,fixRules:z,fixableRuleIds:Q,fixableBareRuleNames:G};return hY.set($,U),U}function $q($,J){return/\.(?:sh|bash|zsh|ksh|dash)$/.test($)||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(J)}function Zq($){return/(?:^|[/\\])(?:bun\.lock|bun\.lockb|package-lock\.json|pnpm-lock\.yaml|yarn\.lock|npm-shrinkwrap\.json)$/.test($)}function F9($,J,Z){switch($.pluginName){case"markdown":return J.endsWith(".md");case"shell":return $q(J,Z);case"publint":return/(?:^|[/\\])package\.json$/.test(J);case"lockfile":return Zq(J);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(J);default:return!0}}async function B9($,J,Z){let X=[],Y=o8(Z),z={filePath:$,config:Z};for(let Q of Y.checkRules){if(!F9(Q,$,J))continue;let{fullRuleId:G,rule:q,severity:U}=Q;if(!q||typeof q.check!=="function"){if(U==="error")X.push({filePath:$,line:1,column:1,ruleId:`${G}-internal`,message:"Rule missing implementation (check function is undefined)",severity:"error"});continue}try{N0("rule:start",G);let W=v0.RULE_TIMEOUT_MS,K={...z,options:Q.options},H=performance.now(),V=await d1(Promise.resolve().then(()=>q.check(J,K)),W,`rule:${G}`),A=performance.now()-H;if(A>W)X.push({filePath:$,line:1,column:1,ruleId:`${G}-internal`,message:`Rule exceeded timeout budget: ${Math.round(A)}ms > ${W}ms`,severity:"error"});N0("rule:end",G,Array.isArray(V)?V.length:0);for(let _ of V){let B=iY(_,G);if(U)X.push({...B,severity:U});else X.push(B)}}catch(W){X.push({filePath:$,line:1,column:1,ruleId:`${G}-internal`,message:`Rule threw: ${W?.message||W}`,severity:"error"})}}return X}var Jq=/\.(?:[cm]?[jt]sx?|vue|svelte|stx)$/i;function Xq($,J,Z){if(!Jq.test(Z)||!$.includes("`"))return J;let X=$.split(/\r?\n/),Y=J.split(/\r?\n/);if(X.length!==Y.length)return J;let z=i0($),Q=0;for(let G=0;G<Y.length;G++)if(z[G]&&Y[G]!==X[G])Y[G]=X[G],Q++;return Q>0?Y.join(`
216
- `):J}function eY($,J,Z){let X=o8(Z),Y={filePath:$,config:Z},z=J,Q=!0,G=0;while(Q&&G++<K9){Q=!1;for(let q of X.fixRules){if(!F9(q,$,z))continue;let U={...Y,options:q.options},W=q.rule.fix(z,U),K=q.rule.meta?.editsStringContent?W:Xq(z,W,$);if(K!==z)z=K,Q=!0}}return z}function Yq($,J){let Z=J.format.indent,X=J.format.indentStyle,Y=$.split(/\r?\n/),z=!1;for(let Q=0;Q<Y.length;Q++){let G=Y[Q],q=0;while(q<G.length&&(G.charCodeAt(q)===32||G.charCodeAt(q)===9))q++;if(q===0)continue;let U=G.slice(0,q);if(!A9(U,Z,X,G))continue;let W;if(X==="tabs"){let K=0,H=0;for(let A=0;A<U.length;A++)if(U.charCodeAt(A)===9)H++;else K++;let V=Math.floor(K/Z);W="\t".repeat(H+V)}else{let K=0;for(let V=0;V<U.length;V++)if(U.charCodeAt(V)===9)K+=Z;else K++;let H=Math.floor(K/Z)*Z;W=" ".repeat(H)}if(W!==U)Y[Q]=W+G.slice(q),z=!0}return z?Y.join(`
217
- `):$}function zq($){let J=new Set;if(!$.includes("`"))return J;let Z=[],X="code",Y=1,z="",Q=0,G=()=>Z[Z.length-1]==="template";for(let q=0;q<$.length;q++){let U=$[q],W=$[q+1];if(U===`
218
- `){if(X==="line-comment")X="code";Y++,Q=q+1,z="";continue}if(G()&&X==="code")J.add(Y);switch(X){case"single":case"double":if(U==="\\")q++;else if(X==="single"&&U==="'"||X==="double"&&U==='"')X="code";continue;case"line-comment":continue;case"block-comment":if(U==="*"&&W==="/")q++,X="code";continue;case"regex":if(U==="\\")q++;else if(U==="[")X="regex-class";else if(U==="/")X="code";continue;case"regex-class":if(U==="\\")q++;else if(U==="]")X="regex";continue}if(G()){if(U==="\\"){q++;continue}if(U==="`"){Z.pop();continue}if(U==="$"&&W==="{"){Z.push("interpolation"),q++;continue}continue}if(U==="`"){Z.push("template"),J.add(Y);continue}if(U==="'"){X="single";continue}if(U==='"'){X="double";continue}if(U==="/"&&W==="/"){X="line-comment",q++;continue}if(U==="/"&&W==="*"){X="block-comment",q++;continue}if(U==="/"&&w9(z,$.slice(Q,q+1),q-Q)){X="regex";continue}if(U==="}"&&Z[Z.length-1]==="interpolation"){Z.pop();continue}if(!/\s/.test(U))z=U}return J}function uY($,J){let Z=$.match(J);if(!Z||Z.index===void 0)return null;let X=Z.index+Z[0].length-1,Y=0;for(let z=X;z<$.length;z++)if($[z]==="(")Y++;else if($[z]===")"){if(Y--,Y===0)return $.slice(X+1,z)}return null}function mY($){let J="",Z=0;for(let X of $){if(X==="("){Z++;continue}if(X===")"){Z=Math.max(0,Z-1);continue}if(Z===0)J+=X}return J}function dY($){let J="",Z=0;while(Z<$.length){if($[Z]==="/"){if($[Z+1]==="/"||$[Z+1]==="*")return J+$.slice(Z);let X=$.slice(0,Z).trimEnd();if(w9(X[X.length-1]??"",$,Z)){Z++;let Y=!1;while(Z<$.length){if($[Z]==="\\"){Z+=2;continue}if($[Z]==="[")Y=!0;else if($[Z]==="]")Y=!1;else if($[Z]==="/"&&!Y){Z++;while(Z<$.length&&/[gimsuvy]/.test($[Z]))Z++;break}Z++}continue}}J+=$[Z],Z++}return J}function w9($,J,Z){if($==="")return!0;if("([{,:;!?&|=<>~^+*%-".includes($))return!0;if(/[A-Za-z_$]/.test($)){let Y=J.slice(0,Z).trimEnd();if(/(?:^|[^A-Za-z0-9_$])(?:return|typeof|instanceof|new|delete|void|in|of|yield|await|throw|case)$/.test(Y))return!0}return!1}function oY($){let J="",Z=0,X=null,Y=!1;while(Z<$.length){let z=$[Z],Q=$[Z+1];if(Y){J+=z,Y=!1,Z++;continue}if(z==="\\"&&X){Y=!0,J+=z,Z++;continue}if(!X){if(z==='"'){X="double",J+=z,Z++;continue}if(z==="'"){X="single",J+=z,Z++;continue}if(z==="`"){X="template",J+=z,Z++;continue}if(z==="/"&&Q==="/")break;if(z==="/"&&Q==="*"){Z+=2;while(Z<$.length){if($[Z]==="*"&&$[Z+1]==="/"){Z+=2;break}Z++}J+=" ";continue}J+=z,Z++}else{if(X==="double"&&z==='"'||X==="single"&&z==="'"||X==="template"&&z==="`")X=null;J+=z,Z++}}return J}function R1($){let J=new Set,Z="code",X=1,Y=!1,z=!1,Q=!1,G=[];for(let q=0;q<$.length;q++){let U=$[q],W=$[q+1],K=q>0?$[q-1]:"";if(U===`
214
+ `}}return Z}async function lj($,J){E1("runFormat:start",{globs:$,options:J});let Z=await x1(J.config),X=$.length?$:["."],Y=h1(X);E1("patterns",Y);let z=new Set((J.ext||Z.format.extensions.join(",")).split(",").map((B)=>{let F=B.trim();return F.startsWith(".")?F:`.${F}`})),Q=y0.TIMEOUT_MS,q=Y.some((B)=>{let F=B.replace(/\/?\*\*(?:\/\*+)?$/,"");return!(iG(F)?F:tG(process.cwd(),F)).startsWith(process.cwd())})?$1(z1):$1(Z.ignores),U=u1(q),W=[];if(Y.length===1&&/\*\*\/\*$/.test(Y[0])){let B=Y[0].replace(/\/?\*\*\/\*$/,"");try{let{readdirSync:F,statSync:M}=await import("fs"),{join:T}=await import("path"),E=[B];while(E.length){let j=E.pop(),O=F(j);for(let v of O){let y=T(j,v),C=M(y);if(U(y))continue;if(C.isDirectory())E.push(y);else W.push(y)}}}catch{W=await fY(e0(Y,{dot:!1,ignore:q,onlyFiles:!0,absolute:!0}),Q,"glob")}}else W=await fY(e0(Y,{dot:!1,ignore:q,onlyFiles:!0,absolute:!0}),Q,"glob");E1("globbed entries",W.length);let H=W.filter((B)=>{if(U(B))return!1;let F=B.lastIndexOf(".");if(F<0)return!0;let M=B.slice(F);return z.has(M)});E1("filtered files",H.length);let V=0,A=[];for(let B of H){E1("format start",kY(process.cwd(),B));let F=gY(B,"utf8"),M=h8(F,Z,B),T=M!==F;if(J.write){if(T)nG(B,M,"utf8")}if(T)A.push(kY(process.cwd(),B));V++}let _=A.length;if(_>0){for(let B of A)console.log(J0.gray(` ${B}`));console.log(J.write?J0.gray(`Formatted ${_} of ${V} file(s).`):J0.yellow(`${_} of ${V} file(s) need formatting. Run with --write to fix.`))}else if(J.verbose!==void 0?J.verbose:Z.verbose)console.log(J0.gray(`Checked ${V} files, all formatted.`));return J.check&&_>0?1:0}var H9=null;function e(){if(!H9)H9=new J1("pickier:lint",{showTags:!1});return H9}function N0(...$){if(y0.TRACE)e().error("[pickier:trace]",$)}async function XN($,J,Z="untitled",X){if(X?.aborted)throw Error("AbortError");let Y=Q1($),z=G1($),Q=O1(Z,$,J,Y,z);if(X?.aborted)throw Error("AbortError");try{let G=await B9(Z,$,J);for(let q of G){if(X?.aborted)throw Error("AbortError");if(S0(q.ruleId,q.line,Y))continue;if(z.has(q.line)&&d8(q.ruleId))continue;Q.push({filePath:q.filePath,line:q.line,column:q.column,ruleId:q.ruleId,message:q.message,severity:q.severity,...q.help&&{help:q.help}})}}catch{}return Q}async function YN($,J,Z){N0("runLintProgrammatic:start",{globs:$,options:J});let X=await x1(J.config);if(Z?.aborted)throw Error("AbortError");let Y=$.length?$:["."],z=h1(Y),Q=J.ext||X.lint.extensions.join(","),G=new Set(Q.split(",").map((P)=>{let L=P.trim();return L.startsWith(".")?L:`.${L}`})),q=y0.TIMEOUT_MS,W=z.some((P)=>{let L=P.replace(/\/?\*\*\/*\*\*$/,""),I=D1(L)?L:R1(process.cwd(),L),f=process.cwd();return I!==f&&!I.startsWith(f+iY)})?$1(z1):$1(X.ignores),K=u1(W),H=[];if(z.length===1&&!/[*?[\]{}()!]/.test(z[0]))try{if(m8(z[0]).isFile())H=[D1(z[0])?z[0]:R1(process.cwd(),z[0])]}catch{}let A=z.length===1&&/\*\*\/*\*$/.test(z[0]);if(!H.length&&A){let P=z[0].replace(/\/?\*\*\/*\*\*$/,""),L=D1(P)?P:R1(process.cwd(),P);try{let I=[L];while(I.length){if(Z?.aborted)throw Error("AbortError");let f=I.pop(),S=aY(f);for(let N of S){let R=nY(f,N),D=m8(R);if(K(R))continue;if(D.isDirectory())I.push(R);else H.push(R)}}}catch{H=await d1(e0(z,{dot:!1,ignore:W,onlyFiles:!0,absolute:!0}),q,"glob")}}else if(!H.length)H=await d1(e0(z,{dot:!1,ignore:W,onlyFiles:!0,absolute:!0}),q,"glob");if(Z?.aborted)throw Error("AbortError");let _=0,B=0,F=0,M=0,T=0,E=[];for(let P of H){if(_++,P.replace(/\\/g,"/").includes("/node_modules/")){F++;continue}if(K(P)){M++;continue}if(!_9(P,G)){T++;continue}E.push(P),B++}N0("filter:programmatic",{total:_,included:B,node_modules:F,ignored:M,wrongExt:T});let j=y0.CONCURRENCY,y=(await eY(E,j,async(P)=>{if(Z?.aborted)throw Error("AbortError");let L=sY(P,"utf8"),I=Q1(L),f=G1(L),S=O1(P,L,X,I,f);try{let N=await B9(P,L,X);for(let R of N){if(Z?.aborted)throw Error("AbortError");if(S0(R.ruleId,R.line,I))continue;if(f.has(R.line)&&d8(R.ruleId))continue;S.push({filePath:R.filePath,line:R.line,column:R.column,ruleId:R.ruleId,message:R.message,severity:R.severity,...R.help&&{help:R.help}})}}catch{}{let N=new Set;S=S.filter((R)=>{let D=`${R.line}:${R.column}:${R.ruleId}`;if(N.has(D))return!1;return N.add(D),!0})}if(J.fix){let N=Zz(P,L,X,I,f);if(N=$z(P,N,X),N!==L){let R=Q1(N),D=G1(N);if(S=O1(P,N,X,R,D),!J.dryRun)V9(P,N,"utf8")}}return S})).flat(),C=y.filter((P)=>P.severity==="error").length,k=y.filter((P)=>P.severity==="warning").length;return{errors:C,warnings:k,issues:y}}function eG($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function $q($){return $.replace(/-([a-z])/g,(J,Z)=>Z.toUpperCase())}function Q1($){let J=new Map,Z=new Set,X=new Map,Y=new Map,z=$.split(/\r?\n/),Q=new Set;for(let U=0;U<z.length;U++){let W=z[U].trim(),K=U+1,H=W.match(/^\/\/\s*(?:eslint|pickier)-disable-next-line(?:\s+(\S.*))?$/);if(H){let F=H[1]?.replace(/\s+--\s.*$/,""),M=F?F.split(",").map((T)=>T.trim()).filter(Boolean):["*"];if(M.length>0){let T=K+1,E=J.get(T)||new Set;for(let j of M)E.add(j);J.set(T,E)}continue}let V=W.match(/^\/\*\s*(?:eslint|pickier)-disable(?:\s+([^*]+))?\s*\*\//);if(V){let F=V[1]?.trim().replace(/\s+--\s.*$/,"");if(!F||F==="")X.set(K,new Set(["*"])),Q.add("*");else{let M=F.split(",").map((E)=>E.trim()).filter(Boolean),T=X.get(K)||new Set;for(let E of M)T.add(E),Q.add(E);X.set(K,T)}if(U===0)if(!F||F==="")Z.add("*");else{let M=F.split(",").map((T)=>T.trim()).filter(Boolean);for(let T of M)Z.add(T)}continue}let A=W.match(/^\/\*\s*(?:eslint|pickier)-enable(?:\s+([^*]+))?\s*\*\//);if(A){let F=A[1]?.trim();if(!F||F==="")Y.set(K,new Set(["*"])),Q.clear();else{let M=F.split(",").map((E)=>E.trim()).filter(Boolean),T=Y.get(K)||new Set;for(let E of M)T.add(E),Q.delete(E);Y.set(K,T)}continue}let _=W.match(/^\/\/\s*(?:eslint|pickier)-disable(?:\s+(\S.*))?$/);if(_){let F=_[1]?.trim().replace(/\s+--\s.*$/,"");if(!F||F==="")X.set(K,new Set(["*"])),Q.add("*");else{let M=F.split(",").map((E)=>E.trim()).filter(Boolean),T=X.get(K)||new Set;for(let E of M)T.add(E),Q.add(E);X.set(K,T)}continue}let B=W.match(/^\/\/\s*(?:eslint|pickier)-enable(?:\s+(\S.*))?$/);if(B){let F=B[1]?.trim();if(!F||F==="")Y.set(K,new Set(["*"])),Q.clear();else{let M=F.split(",").map((E)=>E.trim()).filter(Boolean),T=Y.get(K)||new Set;for(let E of M)T.add(E),Q.delete(E);Y.set(K,T)}}}let G=Array.from(X.keys()).sort((U,W)=>U-W),q=Array.from(Y.keys()).sort((U,W)=>U-W);return{nextLine:J,fileLevel:Z,rangeDisable:X,rangeEnable:Y,sortedDisableLines:G,sortedEnableLines:q}}function S0($,J,Z){if(Z instanceof Map){let G=Z.get(J);if(!G||G.size===0)return!1;return m1($,G)}if(Z.fileLevel.size>0){if(m1($,Z.fileLevel))return!0}let X=Z.nextLine.get(J);if(X&&m1($,X))return!0;let Y=!1,z=0,Q=0;while(!0){let G=z<Z.sortedDisableLines.length?Z.sortedDisableLines[z]:Number.POSITIVE_INFINITY,q=Q<Z.sortedEnableLines.length?Z.sortedEnableLines[Q]:Number.POSITIVE_INFINITY,U=Math.min(G,q);if(U>=J)break;if(G===U){let K=Z.rangeDisable.get(G);if(m1($,K))Y=!0;z++;continue}let W=Z.rangeEnable.get(q);if(W.has("*")||m1($,W))Y=!1;Q++}return Y}function m1($,J){if(J.size===0)return!1;if(J.has("*"))return!0;if(J.has($))return!0;let Z=eG($);if(J.has(Z)||J.has($q($)))return!0;for(let X of J)if(!X.includes("/")){if($.endsWith(`/${X}`))return!0}return!1}function d8($){return $!=="spaced-comment"&&!$.endsWith("/spaced-comment")}function tY($,J){if($.help)return $;let Z=J.includes("/")?J.split("/")[1]:J,X;if(Z.startsWith("no-"))X=`Remove or refactor this ${Z.replace("no-","").replace(/-/g," ")}. Check the rule documentation for more details or disable with: // eslint-disable-next-line ${J}`;else if(Z.startsWith("prefer-"))X=`Consider using ${Z.replace("prefer-","").replace(/-/g," ")} instead. This is a best practice recommendation. Disable with: // eslint-disable-next-line ${J} if needed`;else if(Z.includes("sort")||Z.includes("order"))X=`Reorder these items according to the rule requirements, or use --fix to auto-sort. Disable with: // eslint-disable-next-line ${J}`;else if(Z.includes("indent")||Z.includes("spacing")||Z.includes("newline"))X=`Fix the formatting issue. Run with --fix to automatically format. Disable with: // eslint-disable-next-line ${J}`;else X=`Fix this issue or disable the rule with: // eslint-disable-next-line ${J}. Check the rule documentation for more details`;return{...$,help:X}}async function d1($,J,Z){let X,Y=new Promise((z,Q)=>{X=setTimeout(()=>Q(Error(`Timeout after ${J}ms at ${Z}`)),J)});try{let z=await Promise.race([$,Y]);return clearTimeout(X),z}catch(z){throw e().error(`[pickier:error] ${Z} failed:`,z?.message||z),N0("withTimeout error:",Z,z),z}}async function eY($,J,Z){let X=Array($.length);if($.length===0)return X;let Y=0,z=Math.max(1,Math.min(Math.max(1,J),$.length));async function Q(){while(Y<$.length){let G=Y++;X[G]=await Z($[G],G)}}return await Promise.all(Array.from({length:z},Q)),X}var uY=new WeakMap;function Zq($){let J=U9();if($.plugins&&$.plugins.length>0){let Z=new Set(["pickier","style","regexp","ts"]),X=$.plugins.filter((z)=>typeof z!=="string");J=X.some((z)=>Z.has(z.name))?J:[];for(let z of X)J.push(z)}return J}function Jq($,J){let Z={...$.pluginRules||{}};if($.rules?.noUnusedCapturingGroup)Z["regexp/no-unused-capturing-group"]=$.rules.noUnusedCapturingGroup;let X={"antfu/curly":"style/curly","antfu/if-newline":"style/if-newline","antfu/no-top-level-await":"ts/no-top-level-await"};for(let[Y,z]of Object.entries(X))if(Z[Y])Z[z]=Z[Y];for(let Y of Object.keys($.pluginRules||{}))if(!Y.includes("/")){for(let z of J)if(z.rules&&Object.prototype.hasOwnProperty.call(z.rules,Y))Z[`${z.name}/${Y}`]=$.pluginRules[Y]}return Z}function o8($){let J=uY.get($);if(J)return J;let Z=Zq($),X=Jq($,Z),Y=[],z=[],Q=new Set(["no-debugger"]),G=new Set(["no-debugger"]),q=new Set;for(let W of Z)for(let K in W.rules){let H=`${W.name}/${K}`,V=lY(X,H);if(!V.enabled)continue;if(q.has(K))continue;q.add(K);let A=W.rules[K],_={pluginName:W.name,ruleName:K,fullRuleId:H,rule:A,severity:V.severity,options:V.options};if(typeof A?.check==="function")Y.push(_);else if(V.severity==="error")Y.push(_);if(typeof A?.fix==="function")z.push(_),Q.add(H),G.add(K)}let U={checkRules:Y,fixRules:z,fixableRuleIds:Q,fixableBareRuleNames:G};return uY.set($,U),U}function Xq($,J){return/\.(?:sh|bash|zsh|ksh|dash)$/.test($)||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(J)}function Yq($){return/(?:^|[/\\])(?:bun\.lock|bun\.lockb|package-lock\.json|pnpm-lock\.yaml|yarn\.lock|npm-shrinkwrap\.json)$/.test($)}function F9($,J,Z){switch($.pluginName){case"markdown":return J.endsWith(".md");case"shell":return Xq(J,Z);case"publint":return/(?:^|[/\\])package\.json$/.test(J);case"lockfile":return Yq(J);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(J);default:return!0}}async function B9($,J,Z){let X=[],Y=o8(Z),z={filePath:$,config:Z};for(let Q of Y.checkRules){if(!F9(Q,$,J))continue;let{fullRuleId:G,rule:q,severity:U}=Q;if(!q||typeof q.check!=="function"){if(U==="error")X.push({filePath:$,line:1,column:1,ruleId:`${G}-internal`,message:"Rule missing implementation (check function is undefined)",severity:"error"});continue}try{N0("rule:start",G);let W=y0.RULE_TIMEOUT_MS,K={...z,options:Q.options},H=performance.now(),V=await d1(Promise.resolve().then(()=>q.check(J,K)),W,`rule:${G}`),A=performance.now()-H;if(A>W)X.push({filePath:$,line:1,column:1,ruleId:`${G}-internal`,message:`Rule exceeded timeout budget: ${Math.round(A)}ms > ${W}ms`,severity:"error"});N0("rule:end",G,Array.isArray(V)?V.length:0);for(let _ of V){let B=tY(_,G);if(U)X.push({...B,severity:U});else X.push(B)}}catch(W){X.push({filePath:$,line:1,column:1,ruleId:`${G}-internal`,message:`Rule threw: ${W?.message||W}`,severity:"error"})}}return X}var zq=/\.(?:[cm]?[jt]sx?|vue|svelte|stx)$/i;function Qq($,J,Z){if(!zq.test(Z)||!$.includes("`"))return J;let X=$.split(/\r?\n/),Y=J.split(/\r?\n/);if(X.length!==Y.length)return J;let z=i0($),Q=0;for(let G=0;G<Y.length;G++)if(z[G]&&Y[G]!==X[G])Y[G]=X[G],Q++;return Q>0?Y.join(`
215
+ `):J}function $z($,J,Z){let X=o8(Z),Y={filePath:$,config:Z},z=J,Q=!0,G=0;while(Q&&G++<K9){Q=!1;for(let q of X.fixRules){if(!F9(q,$,z))continue;let U={...Y,options:q.options},W=q.rule.fix(z,U),K=q.rule.meta?.editsStringContent?W:Qq(z,W,$);if(K!==z)z=K,Q=!0}}return z}function Zz($,J,Z,X,Y){if(!(Z.rules.noDebugger==="error"||Z.rules.noDebugger==="warn")||!J.includes("debugger"))return J;let Q=$.split(".").pop()?.toLowerCase()??"",G=Q==="sh"||Q==="bash"||Q==="zsh"||Q==="ksh"||Q==="dash"||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(J);if(Q==="md"||Q==="yaml"||Q==="yml"||Q==="json"||Q==="jsonc"||G)return J;let q=/^\s*debugger\b/,U=w9(J),W=J.split(/\r?\n/),K=[],H=!1;for(let V=0;V<W.length;V++){let A=W[V],_=V+1;if(q.test(A)&&!Y.has(_)&&!U.has(_)&&!S0("no-debugger",_,X)){H=!0;continue}K.push(A)}return H?K.join(`
216
+ `):J}function Jz($,J,Z){if((Z.rules?.indent??Z.pluginRules?.indent??Z.pluginRules?.["style/indent"])==="off")return!1;let Y=$.split(".").pop()?.toLowerCase()??"";if(Y==="md")return!1;if(Y==="stx"||Y==="html"||Y==="htm"||Y==="vue")return!1;if(Y==="yaml"||Y==="yml")return!1;if(Y==="sh"||Y==="bash"||Y==="zsh"||Y==="ksh"||Y==="dash"||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(J))return!1;return!0}function Gq($,J,Z,X){let Y=J.format.indent,z=J.format.indentStyle,Q=w9($),G=$.split(/\r?\n/),q=!1;for(let U=0;U<G.length;U++){let W=G[U],K=U+1;if(X.has(K)||Q.has(K)||S0("indent",K,Z))continue;let H=0;while(H<W.length&&(W.charCodeAt(H)===32||W.charCodeAt(H)===9))H++;if(H===0)continue;let V=W.slice(0,H);if(!A9(V,Y,z,W))continue;let A;if(z==="tabs"){let _=0,B=0;for(let M=0;M<V.length;M++)if(V.charCodeAt(M)===9)B++;else _++;let F=Math.floor(_/Y);A="\t".repeat(B+F)}else{let _=0;for(let F=0;F<V.length;F++)if(V.charCodeAt(F)===9)_+=Y;else _++;let B=Math.floor(_/Y)*Y;A=" ".repeat(B)}if(A!==V)G[U]=A+W.slice(H),q=!0}return q?G.join(`
217
+ `):$}function w9($){let J=new Set;if(!$.includes("`"))return J;let Z=[],X="code",Y=1,z="",Q=0,G=()=>Z[Z.length-1]==="template";for(let q=0;q<$.length;q++){let U=$[q],W=$[q+1];if(U===`
218
+ `){if(X==="line-comment")X="code";Y++,Q=q+1,z="";continue}if(G()&&X==="code")J.add(Y);switch(X){case"single":case"double":if(U==="\\")q++;else if(X==="single"&&U==="'"||X==="double"&&U==='"')X="code";continue;case"line-comment":continue;case"block-comment":if(U==="*"&&W==="/")q++,X="code";continue;case"regex":if(U==="\\")q++;else if(U==="[")X="regex-class";else if(U==="/")X="code";continue;case"regex-class":if(U==="\\")q++;else if(U==="]")X="regex";continue}if(G()){if(U==="\\"){q++;continue}if(U==="`"){Z.pop();continue}if(U==="$"&&W==="{"){Z.push("interpolation"),q++;continue}continue}if(U==="`"){Z.push("template"),J.add(Y);continue}if(U==="'"){X="single";continue}if(U==='"'){X="double";continue}if(U==="/"&&W==="/"){X="line-comment",q++;continue}if(U==="/"&&W==="*"){X="block-comment",q++;continue}if(U==="/"&&M9(z,$.slice(Q,q+1),q-Q)){X="regex";continue}if(U==="}"&&Z[Z.length-1]==="interpolation"){Z.pop();continue}if(!/\s/.test(U))z=U}return J}function mY($,J){let Z=$.match(J);if(!Z||Z.index===void 0)return null;let X=Z.index+Z[0].length-1,Y=0;for(let z=X;z<$.length;z++)if($[z]==="(")Y++;else if($[z]===")"){if(Y--,Y===0)return $.slice(X+1,z)}return null}function dY($){let J="",Z=0;for(let X of $){if(X==="("){Z++;continue}if(X===")"){Z=Math.max(0,Z-1);continue}if(Z===0)J+=X}return J}function oY($){let J="",Z=0;while(Z<$.length){if($[Z]==="/"){if($[Z+1]==="/"||$[Z+1]==="*")return J+$.slice(Z);let X=$.slice(0,Z).trimEnd();if(M9(X[X.length-1]??"",$,Z)){Z++;let Y=!1;while(Z<$.length){if($[Z]==="\\"){Z+=2;continue}if($[Z]==="[")Y=!0;else if($[Z]==="]")Y=!1;else if($[Z]==="/"&&!Y){Z++;while(Z<$.length&&/[gimsuvy]/.test($[Z]))Z++;break}Z++}continue}}J+=$[Z],Z++}return J}function M9($,J,Z){if($==="")return!0;if("([{,:;!?&|=<>~^+*%-".includes($))return!0;if(/[A-Za-z_$]/.test($)){let Y=J.slice(0,Z).trimEnd();if(/(?:^|[^A-Za-z0-9_$])(?:return|typeof|instanceof|new|delete|void|in|of|yield|await|throw|case)$/.test(Y))return!0}return!1}function cY($){let J="",Z=0,X=null,Y=!1;while(Z<$.length){let z=$[Z],Q=$[Z+1];if(Y){J+=z,Y=!1,Z++;continue}if(z==="\\"&&X){Y=!0,J+=z,Z++;continue}if(!X){if(z==='"'){X="double",J+=z,Z++;continue}if(z==="'"){X="single",J+=z,Z++;continue}if(z==="`"){X="template",J+=z,Z++;continue}if(z==="/"&&Q==="/")break;if(z==="/"&&Q==="*"){Z+=2;while(Z<$.length){if($[Z]==="*"&&$[Z+1]==="/"){Z+=2;break}Z++}J+=" ";continue}J+=z,Z++}else{if(X==="double"&&z==='"'||X==="single"&&z==="'"||X==="template"&&z==="`")X=null;J+=z,Z++}}return J}function G1($){let J=new Set,Z="code",X=1,Y=!1,z=!1,Q=!1,G=[];for(let q=0;q<$.length;q++){let U=$[q],W=$[q+1],K=q>0?$[q-1]:"";if(U===`
219
219
  `){if(Q&&Z==="block-comment")J.add(X);else if(!Y&&z&&Z!=="block-comment")J.add(X);else if(!Y&&Z==="block-comment")J.add(X);if(X++,Y=!1,z=!1,Q=Z==="block-comment",Z==="line-comment")Z="code";continue}switch(Z){case"code":if(U==="/"&&W==="/")Z="line-comment",z=!0,q++;else if(U==="/"&&W==="*"){let H=!1;if(q>0){let V=q-1;while(V>0&&($[V]===" "||$[V]==="\t"))V--;let A=$[V];if("=([{,;!&|?:~^%+-".includes(A)&&A!==`
220
220
  `)H=!0;else if(/[a-z]/.test(A)){let _=$.slice(Math.max(0,V-6),V+1);if(/\b(?:return|case|typeof|void|in|of|new|throw|delete)$/.test(_))H=!0}}if(H){Y=!0,q++;while(q<$.length){if($[q]==="\\"){q+=2;continue}if($[q]==="/"){q++;break}if($[q]===`
221
221
  `)break;q++}while(q<$.length&&/[gimsuy]/.test($[q]))q++;q--}else z=!0,Z="block-comment",q++}else if(U==="/"&&W!==void 0){let H=!1;if(q>0){let V=q-1;while(V>0&&($[V]===" "||$[V]==="\t"))V--;let A=$[V];if("=([{,;!&|?:~^%+-".includes(A)||A===`
222
222
  `)H=!0;else if(/[a-z]/.test(A)){let _=$.slice(Math.max(0,V-6),V+1);if(/\b(?:return|case|typeof|void|in|of|new|throw|delete)$/.test(_))H=!0}}if(H){Y=!0,q++;while(q<$.length){if($[q]==="\\"){q+=2;continue}if($[q]==="/"){q++;break}if($[q]===`
223
- `)break;q++}while(q<$.length&&/[gimsuy]/.test($[q]))q++;q--}else Y=!0}else if(U==="'")Z="string-single",Y=!0;else if(U==='"')Z="string-double",Y=!0;else if(U==="`")Z="string-template",Y=!0;else if(U==="{"){if(G.length)G[G.length-1]++;Y=!0}else if(U==="}"){if(G.length)if(G[G.length-1]===0)G.pop(),Z="string-template";else G[G.length-1]--;Y=!0}else if(!/\s/.test(U))Y=!0;break;case"string-single":if(U==="\\"){q++;break}if(U==="'")Z="code";break;case"string-double":if(U==="\\"){q++;break}if(U==='"')Z="code";break;case"string-template":if(U==="\\"){q++;break}if(U==="$"&&W==="{"){G.push(0),Z="code",q++;break}if(U==="`")Z="code";break;case"line-comment":break;case"block-comment":if(U==="*"&&W==="/")Z="code",q++;break}}if(Q&&Z==="block-comment")J.add(X);else if(!Y&&z&&Z!=="block-comment")J.add(X);else if(!Y&&Z==="block-comment")J.add(X);return J}function O1($,J,Z,X,Y){let z=[],Q=J.split(/\r?\n/),G=Z.format.quotes,q=$.split(".").pop()?.toLowerCase()??"",U=q==="md",W=q==="sh"||q==="bash"||q==="zsh"||q==="ksh"||q==="dash"||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(J),V=(Z.rules?.quotes??Z.pluginRules?.quotes??Z.pluginRules?.["style/quotes"])==="off"||q==="json"||q==="jsonc"||q==="lock"||U||q==="yaml"||q==="yml"||q==="stx"||q==="html"||q==="htm"||q==="vue"||W||$.endsWith("bun.lock"),A=U||q==="yaml"||q==="yml"||q==="json"||q==="jsonc"||W,M=(Z.rules?.indent??Z.pluginRules?.indent??Z.pluginRules?.["style/indent"])!=="off"&&!U&&!(q==="stx"||q==="html"||q==="htm"||q==="vue"),N=!1,E=(I)=>I==="warn"?"warning":I==="error"?"error":void 0,j=E(Z.rules.noDebugger),O=E(Z.rules.noConsole),y=E(Z.rules.noTemplateCurlyInString),k=E(Z.rules.noCondAssign),L=/\bconsole\.log\s*\(/,x=/^\s*debugger\b/,b=new Set;if(q==="md"){let I=!1;for(let S=0;S<Q.length;S++){if(/^(?:`{3,}|~{3,})/.test(Q[S].trim())){I=!I;continue}if(I)b.add(S+1)}}let P=zq(J);for(let I=0;I<Q.length;I++){let S=Q[I],C=I+1;if(Y.has(C))continue;if(!V&&!P.has(C)){let D=oY(dY(S)),f=cY(D,G);if(f.length>0&&!N){if(!k0("quotes",C,X))z.push({filePath:$,line:C,column:(f[0]||0)+1,ruleId:"quotes",message:"Inconsistent quote style",severity:"warning",help:`Use ${G} quotes consistently throughout your code. You can change the preferred quote style in your config with format.quotes: '${G==="single"?"double":"single"}'`});N=!0}}let T=0;while(T<S.length&&(S.charCodeAt(T)===32||S.charCodeAt(T)===9))T++;let R=T>0?S.slice(0,T):"";if(M&&R.length>0&&!b.has(C)&&A9(R,Z.format.indent,Z.format.indentStyle,S)){if(!k0("indent",C,X))z.push({filePath:$,line:C,column:1,ruleId:"indent",message:"Incorrect indentation detected",severity:"warning",help:`Use ${Z.format.indentStyle==="spaces"?`${Z.format.indent} spaces`:"tabs"} for indentation. Configure with format.indent and format.indentStyle in your config`})}if(!A&&j&&x.test(S)){if(!k0("no-debugger",C,X))z.push({filePath:$,line:C,column:1,ruleId:"no-debugger",message:"Unexpected debugger statement",severity:j,help:"Remove debugger statements before committing code. Use breakpoints in your IDE instead, or run with --fix to auto-remove"})}if(!A&&O&&!P.has(C)&&L.test(S)){let D=S.indexOf("//"),f=S.indexOf("console.");if(D!==-1&&f>D);else{let h=null;for(let o=0;o<S.length;o++){let u=S[o];if(!h){if(u==='"')h="double";else if(u==="'")h="single";else if(u==="`")h="template";else if(S.slice(o).startsWith("console.")){let p=o+1;if(!k0("no-console",C,X))z.push({filePath:$,line:C,column:p,ruleId:"no-console",message:"Unexpected console call",severity:O,help:"Remove console statements before committing. Use a proper logging library or disable this rule if console output is intentional"});break}}else if(h==="double"&&u==='"'||h==="single"&&u==="'"||h==="template"&&u==="`"){let p=0;for(let v=o-1;v>=0&&S[v]==="\\";v--)p++;if(p%2===0)h=null}}}}if(y&&!P.has(C)){let D=S,f=null,h=!1,o=!1,u="",p="";for(let v=0;v<D.length;v++){let g=D[v];if(h){if(p==="\\"){p=g;continue}if(o){if(g==="]")o=!1}else if(g==="[")o=!0;else if(g==="/"){h=!1;while(v+1<D.length&&/[a-z]/i.test(D[v+1]))v++;u="/"}p=g;continue}if(!f){if(g==='"'){f="double",p=g;continue}if(g==="'"){f="single",p=g;continue}if(g==="`"){f="template",p=g;continue}if(g==="/"&&D[v+1]!=="/"&&D[v+1]!=="*"&&w9(u,D,v)){h=!0,o=!1,p=g;continue}if(g!==" "&&g!=="\t")u=g}else if(f==="double"&&g==='"'||f==="single"&&g==="'"||f==="template"&&g==="`"){if(p!=="\\")f=null}else if(g==="$"&&D[v+1]==="{"&&p!=="\\"&&f!=="template"){if(!k0("no-template-curly-in-string",C,X))z.push({filePath:$,line:C,column:v+1,ruleId:"no-template-curly-in-string",message:"Unexpected template string expression in normal string",severity:y,help:"Change the string quotes from ' or \" to backticks (`) to use template literal interpolation, or escape the $ if you meant to use it literally"});break}p=g}}if(!A&&k&&!P.has(C)){let f=oY(dY(S)).replace(/'[^']*'|"[^"]*"/g,'""'),h=(v)=>/[^=!<>]=(?![=>])/.test(v),o=(v)=>{let g=S.match(v);if(g&&g.index!==void 0)return g.index+g[0].length;return Math.max(1,S.indexOf("(")+1)},u=uY(f,/\b(?:if|while)\s*\(/);if(u){let v=mY(u);if(h(v)){if(!k0("no-cond-assign",C,X))z.push({filePath:$,line:C,column:o(/\b(?:if|while)\s*\(/),ruleId:"no-cond-assign",message:"Unexpected assignment within a conditional expression",severity:k,help:"Use === or == for comparison instead of = (assignment). Wrap intentional assignments in extra parentheses."})}}let p=uY(f,/\bfor\s*\(/);if(p){let v=p.split(";");if(v.length>=2){let g=mY(v[1]);if(h(g)){if(!k0("no-cond-assign",C,X))z.push({filePath:$,line:C,column:o(/\bfor\s*\(/),ruleId:"no-cond-assign",message:"Unexpected assignment within a conditional expression",severity:k,help:"Use === or == for comparison instead of = (assignment). Wrap intentional assignments in extra parentheses."})}}}}}return z}function XN($,J,Z){let X=D1(J),Y=R1(J),z=O1($,J,Z,X,Y);try{let Q=o8(Z),G={filePath:$,config:Z};for(let q of Q.checkRules){if(!F9(q,$,J))continue;if(!q.rule||typeof q.rule.check!=="function")continue;let U=q.rule.check(J,{...G,options:q.options});for(let W of U){if(k0(W.ruleId,W.line,X))continue;if(Y.has(W.line)&&d8(W.ruleId))continue;let K=iY(W,q.fullRuleId);z.push(q.severity?{...K,severity:q.severity}:K)}}}catch{}return z}async function YN($,J){N0("runLint:start",{globs:$,options:J});let Z=v0.DIAGNOSTICS;if(Z)e().info("[pickier:diagnostics] Starting lint process...");try{if(Z)e().info("[pickier:diagnostics] Loading config...");let X=await x1(J.config);N0("config:loaded",{reporter:X.lint.reporter,ext:X.lint.extensions.join(",")});let Y=$.length?$:["."],z=h1(Y);if(N0("patterns",z),Z)e().info(`[pickier:diagnostics] Patterns to search: ${z.join(", ")}`);let Q=J.ext||X.lint.extensions.join(","),G=new Set(Q.split(",").map((R)=>{let D=R.trim();return D.startsWith(".")?D:`.${D}`}));if(Z)e().info(`[pickier:diagnostics] File extensions: ${Array.from(G).join(", ")}`);let q=v0.TIMEOUT_MS;if(Z)e().info(`[pickier:diagnostics] Glob timeout: ${q}ms`);let U=z.some((R)=>{let D=R.replace(/\/?\*\*\/*\*\*$/,""),f=T1(D)?D:E1(process.cwd(),D),h=process.cwd();return f!==h&&!f.startsWith(h+nY)}),W=U?$1(z1):$1(X.ignores),K=u1(W);if(Z){if(e().info(`[pickier:diagnostics] Globbing outside project: ${U}, ignore patterns: ${W.length}`),U)e().info(`[pickier:diagnostics] Using universal ignores: ${z1.slice(0,5).join(", ")}... (${z1.length} total)`)}let H=[],V=z.length===1&&!/[*?[\]{}()!]/.test(z[0]);if(Z)e().info(`[pickier:diagnostics] Starting file discovery... (nonGlobSingle: ${V})`);if(V)try{if(m8(z[0]).isFile())H=[T1(z[0])?z[0]:E1(process.cwd(),z[0])]}catch{}let A=z.length===1&&/\*\*\/*\*$/.test(z[0]);if(!H.length&&A){let R=z[0].replace(/\/?\*\*\/*\*\*$/,"");if(Z)e().info(`[pickier:diagnostics] Using fast directory scan for: ${R}`);try{let f=[T1(R)?R:E1(process.cwd(),R)],h=0;while(f.length){let o=f.pop();if(h++,Z&&h%100===0)e().info(`[pickier:diagnostics] Scanned ${h} directories, ${H.length} files found so far...`);let u=lY(o);for(let p of u){let v=sY(o,p),g=m8(v);if(K(v))continue;if(g.isDirectory())f.push(v);else H.push(v)}}if(Z)e().info(`[pickier:diagnostics] Fast scan complete: ${h} directories, ${H.length} total files`)}catch(D){if(Z)e().info(`[pickier:diagnostics] Fast scan failed: ${D?.message}, falling back to glob`);H=await d1(e0(z,{dot:!1,ignore:W,onlyFiles:!0,absolute:!0}),q,"glob")}}else if(!H.length){if(Z)e().info(`[pickier:diagnostics] Using glob with timeout ${q}ms...`);if(H=await d1(e0(z,{dot:!1,ignore:W,onlyFiles:!0,absolute:!0}),q,"glob"),Z)e().info(`[pickier:diagnostics] glob found ${H.length} files`)}if(N0("globbed entries",H.length),Z)e().info(`[pickier:diagnostics] File discovery complete: ${H.length} files found`);if(H.length>1e4){if(e().warn(`[pickier:warn] Found ${H.length} files. This seems unusually high and may cause memory issues.`),e().warn("[pickier:warn] Consider checking your ignore patterns or being more specific with your glob pattern."),e().warn("[pickier:warn] Common culprits: node_modules, build directories, cache folders, or vendor dependencies."),H.length>1e5)return e().error(`[pickier:error] File count exceeds 100,000 (${H.length}). This will likely cause out-of-memory errors.`),e().error("[pickier:error] Aborting to prevent crash. Please refine your glob pattern or ignore patterns."),1}if(Z)e().info(`[pickier:diagnostics] Filtering ${H.length} files by extension and ignore patterns...`);let _=0,B=0,F=0,M=0,N=0,E=[];for(let R of H){if(_++,Z&&_%1000===0)e().info(`[pickier:diagnostics] Filtering progress: ${_}/${H.length} files checked, ${B} included...`);if(R.replace(/\\/g,"/").includes("/node_modules/")){F++;continue}if(K(R)){M++;continue}if(!_9(R,G)){N++;continue}E.push(R),B++}if(N0("filter:cli",{total:_,included:B,node_modules:F,ignored:M,wrongExt:N}),N0("filtered files",E.length),Z)e().info("[pickier:diagnostics] Filtering complete:"),e().info(`[pickier:diagnostics] Total files found: ${_}`),e().info(`[pickier:diagnostics] Files to lint: ${B}`),e().info(`[pickier:diagnostics] Excluded (node_modules): ${F}`),e().info(`[pickier:diagnostics] Excluded (ignored): ${M}`),e().info(`[pickier:diagnostics] Excluded (wrong extension): ${N}`);if(E.length>5000){if(e().warn(`[pickier:warn] After filtering, ${E.length} files will be linted. This may take a while and use significant memory.`),E.length>50000)return e().error(`[pickier:error] ${E.length} files to lint exceeds safe limit (50,000). This will likely cause out-of-memory errors.`),e().error("[pickier:error] Aborting to prevent crash. Please be more specific with your glob pattern."),e().error("[pickier:error] Example: Instead of '../stx', try '../stx/src' or '../stx/packages/core'"),1}let j=v0.CONCURRENCY;if(Z)e().info(`[pickier:diagnostics] Starting to process ${E.length} files with concurrency ${j}...`);let O=0,y=!!J._formatOnly,x=(await tY(E,j,async(R)=>{if(Z){if(O++,O===1||O%10===0||O===E.length)e().info(`[pickier:diagnostics] Processing file ${O}/${E.length}: ${u8(process.cwd(),R)}`)}let D=aY(R,"utf8");if(y){let p=h8(D,X,R);if(p!==D)if(!J.dryRun)V9(R,p,"utf8");else return[{filePath:R,line:1,column:1,ruleId:"format",message:"File is not formatted",severity:"error",help:"Run pickier format with --write to apply formatting."}];return[]}let f=D1(D),o=/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/.test(R)?R1(D):new Set,u=O1(R,D,X,f,o);try{let p=await B9(R,D,X);for(let v of p){if(k0(v.ruleId,v.line,f))continue;if(o.has(v.line)&&d8(v.ruleId))continue;u.push({filePath:v.filePath,line:v.line,column:v.column,ruleId:v.ruleId,message:v.message,severity:v.severity,...v.help&&{help:v.help}})}}catch{}{let p=new Set;u=u.filter((v)=>{let g=`${v.line}:${v.column}:${v.ruleId}`;if(p.has(g))return!1;return p.add(g),!0})}if(J.fix){let p=/^\s*debugger\b/,v=D;if(X.rules.noDebugger==="error"||X.rules.noDebugger==="warn"){let c=v.split(/\r?\n/),s=[];for(let a of c){if(p.test(a))continue;s.push(a)}v=s.join(`
224
- `)}v=eY(R,v,X);let d=R.split(".").pop()?.toLowerCase()??"";if(d!=="md"&&!(d==="sh"||d==="bash"||d==="zsh"||d==="ksh"||d==="dash")&&d!=="yaml"&&d!=="yml")v=Yq(v,X);if(v!==D){let c=D1(v),s=R1(v);if(u=O1(R,v,X,c,s),!J.dryRun)V9(R,v,"utf8");if(J.dryRun&&(J.verbose!==void 0?J.verbose:X.verbose))e().debug(J0.gray(`dry-run: would apply fixes in ${u8(process.cwd(),R)}`))}}return N0("scan done",u8(process.cwd(),R),u.length),u})).flat();if(Z)e().info(`[pickier:diagnostics] Processing complete! Found ${x.length} issues total`);let b=x.filter((R)=>R.severity==="error").length,P=x.filter((R)=>R.severity==="warning").length;if(N0("issues:summary",{errors:b,warnings:P}),Z)e().info(`[pickier:diagnostics] Errors: ${b}, Warnings: ${P}`);let I=J.reporter||X.lint.reporter,S=J.verbose!==void 0?J.verbose:X.verbose;if(I==="json")console.log(JSON.stringify({errors:b,warnings:P,issues:x},null,2));else if(I==="compact")for(let R of x)console.log(`${u8(process.cwd(),R.filePath)}:${R.line}:${R.column} ${R.severity} ${R.ruleId} ${R.message}`);else if(x.length>0)console.log(S?pY(x):xY(x));if(x.length>0&&I!=="json"){let R=b+P,D=R===1?"problem":"problems",f=b===1?"error":"errors",h=P===1?"warning":"warnings",o=o8(X),u=0,p=0;for(let v of x){let g=v.ruleId;if(o.fixableRuleIds.has(g)||o.fixableBareRuleNames.has(g)){if(v.severity==="error")u++;else if(v.severity==="warning")p++}}if(console.log(),console.log(J0.red(`\u2716 ${R} ${D} (${b} ${f}, ${P} ${h})`)),u>0||p>0){let v=u===1?"error":"errors",g=p===1?"warning":"warnings";console.log(J0.gray(` ${u} ${v} and ${p} ${g} potentially fixable with the \`--fix\` option.`))}}if(S&&I!=="json")console.log(J0.gray(`Scanned ${E.length} files, found ${b} errors and ${P} warnings.`));let C=J.maxWarnings??X.lint.maxWarnings,T=v0.FAIL_ON_WARNINGS;if(b>0)return N0("runLint:end",1),1;if(T&&P>0)return N0("runLint:end",1),1;if(C>=0&&P>C)return N0("runLint:end",1),1;return N0("runLint:end",0),0}catch(X){return e().error("[pickier:error] runLint failed:",X?.message||X),N0("runLint:exception",X),1}}
225
- export{cj as a,ZN as b,JN as c,B9 as d,O1 as e,XN as f,YN as g};
223
+ `)break;q++}while(q<$.length&&/[gimsuy]/.test($[q]))q++;q--}else Y=!0}else if(U==="'")Z="string-single",Y=!0;else if(U==='"')Z="string-double",Y=!0;else if(U==="`")Z="string-template",Y=!0;else if(U==="{"){if(G.length)G[G.length-1]++;Y=!0}else if(U==="}"){if(G.length)if(G[G.length-1]===0)G.pop(),Z="string-template";else G[G.length-1]--;Y=!0}else if(!/\s/.test(U))Y=!0;break;case"string-single":if(U==="\\"){q++;break}if(U==="'")Z="code";break;case"string-double":if(U==="\\"){q++;break}if(U==='"')Z="code";break;case"string-template":if(U==="\\"){q++;break}if(U==="$"&&W==="{"){G.push(0),Z="code",q++;break}if(U==="`")Z="code";break;case"line-comment":break;case"block-comment":if(U==="*"&&W==="/")Z="code",q++;break}}if(Q&&Z==="block-comment")J.add(X);else if(!Y&&z&&Z!=="block-comment")J.add(X);else if(!Y&&Z==="block-comment")J.add(X);return J}function O1($,J,Z,X,Y){let z=[],Q=J.split(/\r?\n/),G=Z.format.quotes,q=$.split(".").pop()?.toLowerCase()??"",U=q==="md",W=q==="sh"||q==="bash"||q==="zsh"||q==="ksh"||q==="dash"||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(J),V=(Z.rules?.quotes??Z.pluginRules?.quotes??Z.pluginRules?.["style/quotes"])==="off"||q==="json"||q==="jsonc"||q==="lock"||U||q==="yaml"||q==="yml"||q==="stx"||q==="html"||q==="htm"||q==="vue"||W||$.endsWith("bun.lock"),A=U||q==="yaml"||q==="yml"||q==="json"||q==="jsonc"||W,_=Jz($,J,Z),B=!1,F=(k)=>k==="warn"?"warning":k==="error"?"error":void 0,M=F(Z.rules.noDebugger),T=F(Z.rules.noConsole),E=F(Z.rules.noTemplateCurlyInString),j=F(Z.rules.noCondAssign),O=/\bconsole\.log\s*\(/,v=/^\s*debugger\b/,y=new Set;if(q==="md"){let k=!1;for(let P=0;P<Q.length;P++){if(/^(?:`{3,}|~{3,})/.test(Q[P].trim())){k=!k;continue}if(k)y.add(P+1)}}let C=w9(J);for(let k=0;k<Q.length;k++){let P=Q[k],L=k+1;if(Y.has(L))continue;if(!V&&!C.has(L)){let S=cY(oY(P)),N=rY(S,G);if(N.length>0&&!B){if(!S0("quotes",L,X))z.push({filePath:$,line:L,column:(N[0]||0)+1,ruleId:"quotes",message:"Inconsistent quote style",severity:"warning",help:`Use ${G} quotes consistently throughout your code. You can change the preferred quote style in your config with format.quotes: '${G==="single"?"double":"single"}'`});B=!0}}let I=0;while(I<P.length&&(P.charCodeAt(I)===32||P.charCodeAt(I)===9))I++;let f=I>0?P.slice(0,I):"";if(_&&f.length>0&&!y.has(L)&&!C.has(L)&&A9(f,Z.format.indent,Z.format.indentStyle,P)){if(!S0("indent",L,X))z.push({filePath:$,line:L,column:1,ruleId:"indent",message:"Incorrect indentation detected",severity:"warning",help:`Use ${Z.format.indentStyle==="spaces"?`${Z.format.indent} spaces`:"tabs"} for indentation. Configure with format.indent and format.indentStyle in your config`})}if(!A&&M&&!C.has(L)&&v.test(P)){if(!S0("no-debugger",L,X))z.push({filePath:$,line:L,column:1,ruleId:"no-debugger",message:"Unexpected debugger statement",severity:M,help:"Remove debugger statements before committing code. Use breakpoints in your IDE instead, or run with --fix to auto-remove"})}if(!A&&T&&!C.has(L)&&O.test(P)){let S=P.indexOf("//"),N=P.indexOf("console.");if(S!==-1&&N>S);else{let R=null;for(let D=0;D<P.length;D++){let g=P[D];if(!R){if(g==='"')R="double";else if(g==="'")R="single";else if(g==="`")R="template";else if(P.slice(D).startsWith("console.")){let x=D+1;if(!S0("no-console",L,X))z.push({filePath:$,line:L,column:x,ruleId:"no-console",message:"Unexpected console call",severity:T,help:"Remove console statements before committing. Use a proper logging library or disable this rule if console output is intentional"});break}}else if(R==="double"&&g==='"'||R==="single"&&g==="'"||R==="template"&&g==="`"){let x=0;for(let p=D-1;p>=0&&P[p]==="\\";p--)x++;if(x%2===0)R=null}}}}if(E&&!C.has(L)){let S=P,N=null,R=!1,D=!1,g="",x="";for(let p=0;p<S.length;p++){let b=S[p];if(R){if(x==="\\"){x=b;continue}if(D){if(b==="]")D=!1}else if(b==="[")D=!0;else if(b==="/"){R=!1;while(p+1<S.length&&/[a-z]/i.test(S[p+1]))p++;g="/"}x=b;continue}if(!N){if(b==='"'){N="double",x=b;continue}if(b==="'"){N="single",x=b;continue}if(b==="`"){N="template",x=b;continue}if(b==="/"&&S[p+1]!=="/"&&S[p+1]!=="*"&&M9(g,S,p)){R=!0,D=!1,x=b;continue}if(b!==" "&&b!=="\t")g=b}else if(N==="double"&&b==='"'||N==="single"&&b==="'"||N==="template"&&b==="`"){if(x!=="\\")N=null}else if(b==="$"&&S[p+1]==="{"&&x!=="\\"&&N!=="template"){if(!S0("no-template-curly-in-string",L,X))z.push({filePath:$,line:L,column:p+1,ruleId:"no-template-curly-in-string",message:"Unexpected template string expression in normal string",severity:E,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}x=b}}if(!A&&j&&!C.has(L)){let N=cY(oY(P)).replace(/'[^']*'|"[^"]*"/g,'""'),R=(p)=>/[^=!<>]=(?![=>])/.test(p),D=(p)=>{let b=P.match(p);if(b&&b.index!==void 0)return b.index+b[0].length;return Math.max(1,P.indexOf("(")+1)},g=mY(N,/\b(?:if|while)\s*\(/);if(g){let p=dY(g);if(R(p)){if(!S0("no-cond-assign",L,X))z.push({filePath:$,line:L,column:D(/\b(?:if|while)\s*\(/),ruleId:"no-cond-assign",message:"Unexpected assignment within a conditional expression",severity:j,help:"Use === or == for comparison instead of = (assignment). Wrap intentional assignments in extra parentheses."})}}let x=mY(N,/\bfor\s*\(/);if(x){let p=x.split(";");if(p.length>=2){let b=dY(p[1]);if(R(b)){if(!S0("no-cond-assign",L,X))z.push({filePath:$,line:L,column:D(/\bfor\s*\(/),ruleId:"no-cond-assign",message:"Unexpected assignment within a conditional expression",severity:j,help:"Use === or == for comparison instead of = (assignment). Wrap intentional assignments in extra parentheses."})}}}}}return z}function zN($,J,Z){let X=Q1(J),Y=G1(J),z=O1($,J,Z,X,Y);try{let Q=o8(Z),G={filePath:$,config:Z};for(let q of Q.checkRules){if(!F9(q,$,J))continue;if(!q.rule||typeof q.rule.check!=="function")continue;let U=q.rule.check(J,{...G,options:q.options});for(let W of U){if(S0(W.ruleId,W.line,X))continue;if(Y.has(W.line)&&d8(W.ruleId))continue;let K=tY(W,q.fullRuleId);z.push(q.severity?{...K,severity:q.severity}:K)}}}catch{}return z}async function QN($,J){N0("runLint:start",{globs:$,options:J});let Z=y0.DIAGNOSTICS;if(Z)e().info("[pickier:diagnostics] Starting lint process...");try{if(Z)e().info("[pickier:diagnostics] Loading config...");let X=await x1(J.config);N0("config:loaded",{reporter:X.lint.reporter,ext:X.lint.extensions.join(",")});let Y=$.length?$:["."],z=h1(Y);if(N0("patterns",z),Z)e().info(`[pickier:diagnostics] Patterns to search: ${z.join(", ")}`);let Q=J.ext||X.lint.extensions.join(","),G=new Set(Q.split(",").map((R)=>{let D=R.trim();return D.startsWith(".")?D:`.${D}`}));if(Z)e().info(`[pickier:diagnostics] File extensions: ${Array.from(G).join(", ")}`);let q=y0.TIMEOUT_MS;if(Z)e().info(`[pickier:diagnostics] Glob timeout: ${q}ms`);let U=z.some((R)=>{let D=R.replace(/\/?\*\*\/*\*\*$/,""),g=D1(D)?D:R1(process.cwd(),D),x=process.cwd();return g!==x&&!g.startsWith(x+iY)}),W=U?$1(z1):$1(X.ignores),K=u1(W);if(Z){if(e().info(`[pickier:diagnostics] Globbing outside project: ${U}, ignore patterns: ${W.length}`),U)e().info(`[pickier:diagnostics] Using universal ignores: ${z1.slice(0,5).join(", ")}... (${z1.length} total)`)}let H=[],V=z.length===1&&!/[*?[\]{}()!]/.test(z[0]);if(Z)e().info(`[pickier:diagnostics] Starting file discovery... (nonGlobSingle: ${V})`);if(V)try{if(m8(z[0]).isFile())H=[D1(z[0])?z[0]:R1(process.cwd(),z[0])]}catch{}let A=z.length===1&&/\*\*\/*\*$/.test(z[0]);if(!H.length&&A){let R=z[0].replace(/\/?\*\*\/*\*\*$/,"");if(Z)e().info(`[pickier:diagnostics] Using fast directory scan for: ${R}`);try{let g=[D1(R)?R:R1(process.cwd(),R)],x=0;while(g.length){let p=g.pop();if(x++,Z&&x%100===0)e().info(`[pickier:diagnostics] Scanned ${x} directories, ${H.length} files found so far...`);let b=aY(p);for(let m of b){let u=nY(p,m),n=m8(u);if(K(u))continue;if(n.isDirectory())g.push(u);else H.push(u)}}if(Z)e().info(`[pickier:diagnostics] Fast scan complete: ${x} directories, ${H.length} total files`)}catch(D){if(Z)e().info(`[pickier:diagnostics] Fast scan failed: ${D?.message}, falling back to glob`);H=await d1(e0(z,{dot:!1,ignore:W,onlyFiles:!0,absolute:!0}),q,"glob")}}else if(!H.length){if(Z)e().info(`[pickier:diagnostics] Using glob with timeout ${q}ms...`);if(H=await d1(e0(z,{dot:!1,ignore:W,onlyFiles:!0,absolute:!0}),q,"glob"),Z)e().info(`[pickier:diagnostics] glob found ${H.length} files`)}if(N0("globbed entries",H.length),Z)e().info(`[pickier:diagnostics] File discovery complete: ${H.length} files found`);if(H.length>1e4){if(e().warn(`[pickier:warn] Found ${H.length} files. This seems unusually high and may cause memory issues.`),e().warn("[pickier:warn] Consider checking your ignore patterns or being more specific with your glob pattern."),e().warn("[pickier:warn] Common culprits: node_modules, build directories, cache folders, or vendor dependencies."),H.length>1e5)return e().error(`[pickier:error] File count exceeds 100,000 (${H.length}). This will likely cause out-of-memory errors.`),e().error("[pickier:error] Aborting to prevent crash. Please refine your glob pattern or ignore patterns."),1}if(Z)e().info(`[pickier:diagnostics] Filtering ${H.length} files by extension and ignore patterns...`);let _=0,B=0,F=0,M=0,T=0,E=[];for(let R of H){if(_++,Z&&_%1000===0)e().info(`[pickier:diagnostics] Filtering progress: ${_}/${H.length} files checked, ${B} included...`);if(R.replace(/\\/g,"/").includes("/node_modules/")){F++;continue}if(K(R)){M++;continue}if(!_9(R,G)){T++;continue}E.push(R),B++}if(N0("filter:cli",{total:_,included:B,node_modules:F,ignored:M,wrongExt:T}),N0("filtered files",E.length),Z)e().info("[pickier:diagnostics] Filtering complete:"),e().info(`[pickier:diagnostics] Total files found: ${_}`),e().info(`[pickier:diagnostics] Files to lint: ${B}`),e().info(`[pickier:diagnostics] Excluded (node_modules): ${F}`),e().info(`[pickier:diagnostics] Excluded (ignored): ${M}`),e().info(`[pickier:diagnostics] Excluded (wrong extension): ${T}`);if(E.length>5000){if(e().warn(`[pickier:warn] After filtering, ${E.length} files will be linted. This may take a while and use significant memory.`),E.length>50000)return e().error(`[pickier:error] ${E.length} files to lint exceeds safe limit (50,000). This will likely cause out-of-memory errors.`),e().error("[pickier:error] Aborting to prevent crash. Please be more specific with your glob pattern."),e().error("[pickier:error] Example: Instead of '../stx', try '../stx/src' or '../stx/packages/core'"),1}let j=y0.CONCURRENCY;if(Z)e().info(`[pickier:diagnostics] Starting to process ${E.length} files with concurrency ${j}...`);let O=0,v=!!J._formatOnly,k=(await eY(E,j,async(R)=>{if(Z){if(O++,O===1||O%10===0||O===E.length)e().info(`[pickier:diagnostics] Processing file ${O}/${E.length}: ${u8(process.cwd(),R)}`)}let D=sY(R,"utf8");if(v){let m=h8(D,X,R);if(m!==D)if(!J.dryRun)V9(R,m,"utf8");else return[{filePath:R,line:1,column:1,ruleId:"format",message:"File is not formatted",severity:"error",help:"Run pickier format with --write to apply formatting."}];return[]}let g=Q1(D),p=/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/.test(R)?G1(D):new Set,b=O1(R,D,X,g,p);try{let m=await B9(R,D,X);for(let u of m){if(S0(u.ruleId,u.line,g))continue;if(p.has(u.line)&&d8(u.ruleId))continue;b.push({filePath:u.filePath,line:u.line,column:u.column,ruleId:u.ruleId,message:u.message,severity:u.severity,...u.help&&{help:u.help}})}}catch{}{let m=new Set;b=b.filter((u)=>{let n=`${u.line}:${u.column}:${u.ruleId}`;if(m.has(n))return!1;return m.add(n),!0})}if(J.fix){let m=Zz(R,D,X,g,p);if(m=$z(R,m,X),Jz(R,m,X))m=Gq(m,X,Q1(m),G1(m));if(m!==D){let u=Q1(m),n=G1(m);if(b=O1(R,m,X,u,n),!J.dryRun)V9(R,m,"utf8");if(J.dryRun&&(J.verbose!==void 0?J.verbose:X.verbose))e().debug(J0.gray(`dry-run: would apply fixes in ${u8(process.cwd(),R)}`))}}return N0("scan done",u8(process.cwd(),R),b.length),b})).flat();if(Z)e().info(`[pickier:diagnostics] Processing complete! Found ${k.length} issues total`);let P=k.filter((R)=>R.severity==="error").length,L=k.filter((R)=>R.severity==="warning").length;if(N0("issues:summary",{errors:P,warnings:L}),Z)e().info(`[pickier:diagnostics] Errors: ${P}, Warnings: ${L}`);let I=J.reporter||X.lint.reporter,f=J.verbose!==void 0?J.verbose:X.verbose;if(I==="json")console.log(JSON.stringify({errors:P,warnings:L,issues:k},null,2));else if(I==="compact")for(let R of k)console.log(`${u8(process.cwd(),R.filePath)}:${R.line}:${R.column} ${R.severity} ${R.ruleId} ${R.message}`);else if(k.length>0)console.log(f?xY(k):hY(k));if(k.length>0&&I!=="json"){let R=P+L,D=R===1?"problem":"problems",g=P===1?"error":"errors",x=L===1?"warning":"warnings",p=o8(X),b=0,m=0;for(let u of k){let n=u.ruleId;if(p.fixableRuleIds.has(n)||p.fixableBareRuleNames.has(n)){if(u.severity==="error")b++;else if(u.severity==="warning")m++}}if(console.log(),console.log(J0.red(`\u2716 ${R} ${D} (${P} ${g}, ${L} ${x})`)),b>0||m>0){let u=b===1?"error":"errors",n=m===1?"warning":"warnings";console.log(J0.gray(` ${b} ${u} and ${m} ${n} potentially fixable with the \`--fix\` option.`))}}if(f&&I!=="json")console.log(J0.gray(`Scanned ${E.length} files, found ${P} errors and ${L} warnings.`));let S=J.maxWarnings??X.lint.maxWarnings,N=y0.FAIL_ON_WARNINGS;if(P>0)return N0("runLint:end",1),1;if(N&&L>0)return N0("runLint:end",1),1;if(S>=0&&L>S)return N0("runLint:end",1),1;return N0("runLint:end",0),0}catch(X){return e().error("[pickier:error] runLint failed:",X?.message||X),N0("runLint:exception",X),1}}
224
+ export{lj as a,XN as b,YN as c,B9 as d,O1 as e,zN as f,QN as g};