pickier 0.1.51 → 0.1.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{L as N}from"../chunk-h6ac3d60.js";import J from"process";async function I(){let E=J.argv.slice(2),Q=E[0]==="run",C=Q?1:0,O=Q?"auto":"lint",X=!1,Y=!1,Z=!1,_=!1,$,T=[],x=!0;for(let y=C;y<E.length;y++){let q=E[y];if(q==="--mode")O=E[++y]||"auto";else if(q==="--format")Z=!0,O="format";else if(q==="--check")X=!0;else if(q==="--write")Y=!0;else if(q==="--config")$=E[++y];else if(q==="--verbose")_=!0;else if(q==="--ext"||q==="--ignore-path")y++;else if(q==="--fix"||q==="--dry-run"||q==="--reporter"||q==="--max-warnings"||q==="--cache"){x=!1,T.length=0;break}else if(q.startsWith("--"));else T.push(q)}if(x&&(O==="format"||O==="auto"||O==="lint")&&T.length>0){let{runUnified:y}=await import("../chunk-z91s0hcd.js"),q=await y(T,{mode:O,check:X,write:Y,verbose:_,config:$});J.exit(q)}let{CLI:L}=await import("../chunk-88xjkex3.js"),{version:F}=await import("../chunk-4y1ghfcd.js"),H=new L("pickier"),V=(y)=>{let[q,B]=y;return[Array.isArray(q)?q.filter((W)=>typeof W==="string"):[],B&&typeof B==="object"?B:{}]};H.command("[...globs]","Lint files (default)").option("--fix","Auto-fix lint problems").option("--format","Format files instead of linting").option("--dry-run","Simulate fixes without writing").option("--check","Check formatting without writing (CI-friendly)").option("--max-warnings <n>","Max warnings before non-zero exit",{default:-1}).option("--reporter <name>","stylish|json|compact",{default:"stylish"}).option("--config <path>","Path to pickier config").option("--ignore-path <file>","Ignore file (like .gitignore)").option("--ext <exts>","Comma-separated extensions").option("--cache","Enable cache").option("--verbose","Verbose output").example("pickier .").example("pickier . --fix").example("pickier . --format").example("pickier src --fix --verbose").action(async(...y)=>{let[q,B]=V(y);if(q.length===0){H.outputHelp();return}let{runUnified:K}=await import("../chunk-z91s0hcd.js"),D;if(B.format){if(D="format",!B.check)B.write=!0}else D="lint";let W=await K(q,{...B,mode:D});J.exit(W)}),H.command("lint [...globs]","[DEPRECATION] Use `pickier [...globs]` instead. Lint files").option("--fix","Auto-fix problems").option("--dry-run","Simulate fixes without writing").option("--max-warnings <n>","Max warnings before non-zero exit",{default:-1}).option("--reporter <name>","stylish|json|compact",{default:"stylish"}).option("--config <path>","Path to pickier config").option("--ignore-path <file>","Ignore file (like .gitignore)").option("--ext <exts>","Comma-separated extensions").option("--cache","Enable cache").option("--verbose","Verbose output").example("pickier lint .").example("pickier lint src --fix").example('pickier lint "src/**/*.{ts,tsx}" --reporter json').action(async(...y)=>{let[q,B]=V(y),{runUnified:K}=await import("../chunk-z91s0hcd.js"),D=await K(q,{...B,mode:"lint"});J.exit(D)}),H.command("format [...globs]","[DEPRECATION] Use `pickier [...globs] --format` instead. Format files").option("--write","Write changes to files").option("--check","Check without writing (CI-friendly)").option("--config <path>","Path to pickier config").option("--ignore-path <file>","Ignore file").option("--ext <exts>","Comma-separated extensions").option("--verbose","Verbose output").example("pickier format . --write").example("pickier format . --check").action(async(...y)=>{let[q,B]=V(y),{runUnified:K}=await import("../chunk-z91s0hcd.js"),D=await K(q,{...B,mode:"format"});J.exit(D)}),H.command("run [...globs]","Unified mode (auto, lint, or format)").option("--mode <mode>","auto|lint|format",{default:"auto"}).option("--fix","Auto-fix problems (lint mode)").option("--dry-run","Simulate fixes without writing (lint mode)").option("--max-warnings <n>","Max warnings before non-zero exit (lint mode)",{default:-1}).option("--reporter <name>","stylish|json|compact (lint mode)",{default:"stylish"}).option("--write","Write changes to files (format mode)").option("--check","Check without writing (format mode)").option("--config <path>","Path to pickier config").option("--ignore-path <file>","Ignore file (like .gitignore)").option("--ext <exts>","Comma-separated extensions").option("--cache","Enable cache (lint mode)").option("--verbose","Verbose output").example("pickier run . --mode lint --fix").example("pickier run . --mode format --write").action(async(...y)=>{let[q,B]=V(y),{runUnified:K}=await import("../chunk-z91s0hcd.js"),D=await K(q,B);J.exit(D)}),H.command("version","Show the version of the CLI").action(async()=>{let{version:y}=await import("../chunk-4y1ghfcd.js");J.stdout.write(`${y}
3
+ import{N}from"../chunk-43fsk0jg.js";import J from"process";async function I(){let E=J.argv.slice(2),Q=E[0]==="run",C=Q?1:0,O=Q?"auto":"lint",X=!1,Y=!1,Z=!1,_=!1,$,T=[],x=!0;for(let y=C;y<E.length;y++){let q=E[y];if(q==="--mode")O=E[++y]||"auto";else if(q==="--format")Z=!0,O="format";else if(q==="--check")X=!0;else if(q==="--write")Y=!0;else if(q==="--config")$=E[++y];else if(q==="--verbose")_=!0;else if(q==="--ext"||q==="--ignore-path")y++;else if(q==="--fix"||q==="--dry-run"||q==="--reporter"||q==="--max-warnings"||q==="--cache"){x=!1,T.length=0;break}else if(q.startsWith("--"));else T.push(q)}if(x&&(O==="format"||O==="auto"||O==="lint")&&T.length>0){let{runUnified:y}=await import("../chunk-7dqgks41.js"),q=await y(T,{mode:O,check:X,write:Y,verbose:_,config:$});J.exit(q)}let{CLI:L}=await import("../chunk-v1x7hdmp.js"),{version:F}=await import("../chunk-49t2br1w.js"),H=new L("pickier"),V=(y)=>{let[q,B]=y;return[Array.isArray(q)?q.filter((W)=>typeof W==="string"):[],B&&typeof B==="object"?B:{}]};H.command("[...globs]","Lint files (default)").option("--fix","Auto-fix lint problems").option("--format","Format files instead of linting").option("--dry-run","Simulate fixes without writing").option("--check","Check formatting without writing (CI-friendly)").option("--max-warnings <n>","Max warnings before non-zero exit",{default:-1}).option("--reporter <name>","stylish|json|compact",{default:"stylish"}).option("--config <path>","Path to pickier config").option("--ignore-path <file>","Ignore file (like .gitignore)").option("--ext <exts>","Comma-separated extensions").option("--cache","Enable cache").option("--verbose","Verbose output").example("pickier .").example("pickier . --fix").example("pickier . --format").example("pickier src --fix --verbose").action(async(...y)=>{let[q,B]=V(y);if(q.length===0){H.outputHelp();return}let{runUnified:K}=await import("../chunk-7dqgks41.js"),D;if(B.format){if(D="format",!B.check)B.write=!0}else D="lint";let W=await K(q,{...B,mode:D});J.exit(W)}),H.command("lint [...globs]","[DEPRECATION] Use `pickier [...globs]` instead. Lint files").option("--fix","Auto-fix problems").option("--dry-run","Simulate fixes without writing").option("--max-warnings <n>","Max warnings before non-zero exit",{default:-1}).option("--reporter <name>","stylish|json|compact",{default:"stylish"}).option("--config <path>","Path to pickier config").option("--ignore-path <file>","Ignore file (like .gitignore)").option("--ext <exts>","Comma-separated extensions").option("--cache","Enable cache").option("--verbose","Verbose output").example("pickier lint .").example("pickier lint src --fix").example('pickier lint "src/**/*.{ts,tsx}" --reporter json').action(async(...y)=>{let[q,B]=V(y),{runUnified:K}=await import("../chunk-7dqgks41.js"),D=await K(q,{...B,mode:"lint"});J.exit(D)}),H.command("format [...globs]","[DEPRECATION] Use `pickier [...globs] --format` instead. Format files").option("--write","Write changes to files").option("--check","Check without writing (CI-friendly)").option("--config <path>","Path to pickier config").option("--ignore-path <file>","Ignore file").option("--ext <exts>","Comma-separated extensions").option("--verbose","Verbose output").example("pickier format . --write").example("pickier format . --check").action(async(...y)=>{let[q,B]=V(y),{runUnified:K}=await import("../chunk-7dqgks41.js"),D=await K(q,{...B,mode:"format"});J.exit(D)}),H.command("run [...globs]","Unified mode (auto, lint, or format)").option("--mode <mode>","auto|lint|format",{default:"auto"}).option("--fix","Auto-fix problems (lint mode)").option("--dry-run","Simulate fixes without writing (lint mode)").option("--max-warnings <n>","Max warnings before non-zero exit (lint mode)",{default:-1}).option("--reporter <name>","stylish|json|compact (lint mode)",{default:"stylish"}).option("--write","Write changes to files (format mode)").option("--check","Check without writing (format mode)").option("--config <path>","Path to pickier config").option("--ignore-path <file>","Ignore file (like .gitignore)").option("--ext <exts>","Comma-separated extensions").option("--cache","Enable cache (lint mode)").option("--verbose","Verbose output").example("pickier run . --mode lint --fix").example("pickier run . --mode format --write").action(async(...y)=>{let[q,B]=V(y),{runUnified:K}=await import("../chunk-7dqgks41.js"),D=await K(q,B);J.exit(D)}),H.command("version","Show the version of the CLI").action(async()=>{let{version:y}=await import("../chunk-49t2br1w.js");J.stdout.write(`${y}
4
4
  `)}),H.version(F),H.help(),H.parse()}I().catch((E)=>{let Q=E instanceof Error?E.message:String(E);J.stderr.write(`pickier: ${Q}
5
5
  `),J.exit(1)});
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{b as a,c as b,d as c,e as d,f as e,g as f}from"./chunk-zwqq3b8y.js";import"./chunk-55vrfsnk.js";import"./chunk-ah6h41gy.js";import"./chunk-43fsk0jg.js";export{d as scanContentOptimized,e as scanContent,b as runLintProgrammatic,f as runLint,a as lintText,c as applyPlugins};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{K as a,L as b,M as c}from"./chunk-ah6h41gy.js";import"./chunk-43fsk0jg.js";export{b as getConfig,a as defaultConfig,c as config};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  var a=import.meta.require;
3
- export{a as L};
3
+ export{a as N};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import"./chunk-h6ac3d60.js";var e="pickier",u="module",t="0.1.51",r="Format, lint and more in a fraction of seconds.",s="Chris Breuer <chris@stacksjs.org>",l="MIT",p="https://github.com/pickier/pickier#readme",b={type:"git",url:"git+https://github.com/pickier/pickier.git"},m={url:"https://github.com/pickier/pickier/issues"},c=["pickier","linter","formatter","bun","fast"],o={".":{types:"./dist/index.d.ts",import:"./dist/src/index.js"},"./*":{import:"./dist/*"}},a="./dist/src/index.js",x="./dist/index.d.ts",d={pickier:"./dist/bin/cli.js"},w=["README.md","dist"],k={build:"bun --bun build.ts","build:bin":"bun --bun build.ts && bun run compile",compile:"bun build ./bin/cli.ts --compile --minify --outfile bin/pickier","compile:all":"bun run compile:linux-x64 && bun run compile:linux-arm64 && bun run compile:linux-x64-musl && bun run compile:linux-arm64-musl && bun run compile:windows-x64 && bun run compile:windows-arm64 && bun run compile:darwin-x64 && bun run compile:darwin-arm64","compile:linux-x64":"bun build ./bin/cli.ts --compile --minify --target=bun-linux-x64 --outfile bin/pickier-linux-x64","compile:linux-arm64":"bun build ./bin/cli.ts --compile --minify --target=bun-linux-arm64 --outfile bin/pickier-linux-arm64","compile:linux-x64-musl":"bun build ./bin/cli.ts --compile --minify --target=bun-linux-x64-musl --outfile bin/pickier-linux-x64-musl","compile:linux-arm64-musl":"bun build ./bin/cli.ts --compile --minify --target=bun-linux-arm64-musl --outfile bin/pickier-linux-arm64-musl","compile:windows-x64":"bun build ./bin/cli.ts --compile --minify --target=bun-windows-x64 --outfile bin/pickier-windows-x64.exe","compile:windows-arm64":"bun build ./bin/cli.ts --compile --minify --target=bun-windows-arm64 --outfile bin/pickier-windows-arm64.exe","compile:darwin-x64":"bun build ./bin/cli.ts --compile --minify --target=bun-darwin-x64 --outfile bin/pickier-darwin-x64","compile:darwin-arm64":"bun build ./bin/cli.ts --compile --minify --target=bun-darwin-arm64 --outfile bin/pickier-darwin-arm64",zip:"bun run zip:all","zip:all":"bun run zip:linux-x64 && bun run zip:linux-arm64 && bun run zip:linux-x64-musl && bun run zip:linux-arm64-musl && bun run zip:windows-x64 && bun run zip:windows-arm64 && bun run zip:darwin-x64 && bun run zip:darwin-arm64","zip:linux-x64":"zip -j bin/pickier-linux-x64.zip bin/pickier-linux-x64","zip:linux-arm64":"zip -j bin/pickier-linux-arm64.zip bin/pickier-linux-arm64","zip:linux-x64-musl":"zip -j bin/pickier-linux-x64-musl.zip bin/pickier-linux-x64-musl","zip:linux-arm64-musl":"zip -j bin/pickier-linux-arm64-musl.zip bin/pickier-linux-arm64-musl","zip:windows-x64":"zip -j bin/pickier-windows-x64.zip bin/pickier-windows-x64.exe","zip:windows-arm64":"zip -j bin/pickier-windows-arm64.zip bin/pickier-windows-arm64.exe","zip:darwin-x64":"zip -j bin/pickier-darwin-x64.zip bin/pickier-darwin-x64","zip:darwin-arm64":"zip -j bin/pickier-darwin-arm64.zip bin/pickier-darwin-arm64",prepublishOnly:"bun --bun run build && bun run compile:all && bun run zip",test:"PICKIER_NO_AUTO_CONFIG=1 bun test --coverage","test:core":"PICKIER_NO_AUTO_CONFIG=1 bun test test/core","test:format":"PICKIER_NO_AUTO_CONFIG=1 bun test test/format","test:lint":"PICKIER_NO_AUTO_CONFIG=1 bun test test/lint","test:rules":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules","test:rules:sort":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/sort","test:rules:style":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/style","test:rules:quality":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/quality","test:rules:imports":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/imports","test:rules:typescript":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/typescript","test:rules:regexp":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/regexp","test:plugin":"PICKIER_NO_AUTO_CONFIG=1 bun test test/plugin","test:watch":"PICKIER_NO_AUTO_CONFIG=1 bun test --watch"},I={"@stacksjs/clarity":"^0.3.24","@stacksjs/clapp":"^0.2.3"},O={"@stacksjs/ts-spell-check":"^0.1.0"},_={bunfig:"^0.15.13"},z={name:e,type:u,version:t,description:r,author:s,license:l,homepage:p,repository:b,bugs:m,keywords:c,exports:o,module:a,types:x,bin:d,files:w,scripts:k,dependencies:I,optionalDependencies:O,devDependencies:_};export{t as version,x as types,u as type,k as scripts,b as repository,O as optionalDependencies,e as name,a as module,l as license,c as keywords,p as homepage,w as files,o as exports,_ as devDependencies,r as description,I as dependencies,z as default,m as bugs,d as bin,s as author};
2
+ import"./chunk-43fsk0jg.js";var e="pickier",u="module",t="0.1.53",r="Format, lint and more in a fraction of seconds.",s="Chris Breuer <chris@stacksjs.org>",l="MIT",p="https://github.com/pickier/pickier#readme",b={type:"git",url:"git+https://github.com/pickier/pickier.git"},m={url:"https://github.com/pickier/pickier/issues"},c=["pickier","linter","formatter","bun","fast"],o={".":{types:"./dist/index.d.ts",import:"./dist/src/index.js"},"./*":{import:"./dist/*"}},a="./dist/src/index.js",x="./dist/index.d.ts",d={pickier:"./dist/bin/cli.js"},w=["README.md","dist"],k={build:"bun --bun build.ts","build:bin":"bun --bun build.ts && bun run compile",compile:"bun build ./bin/cli.ts --compile --minify --outfile bin/pickier","compile:all":"bun run compile:linux-x64 && bun run compile:linux-arm64 && bun run compile:linux-x64-musl && bun run compile:linux-arm64-musl && bun run compile:windows-x64 && bun run compile:windows-arm64 && bun run compile:darwin-x64 && bun run compile:darwin-arm64","compile:linux-x64":"bun build ./bin/cli.ts --compile --minify --target=bun-linux-x64 --outfile bin/pickier-linux-x64","compile:linux-arm64":"bun build ./bin/cli.ts --compile --minify --target=bun-linux-arm64 --outfile bin/pickier-linux-arm64","compile:linux-x64-musl":"bun build ./bin/cli.ts --compile --minify --target=bun-linux-x64-musl --outfile bin/pickier-linux-x64-musl","compile:linux-arm64-musl":"bun build ./bin/cli.ts --compile --minify --target=bun-linux-arm64-musl --outfile bin/pickier-linux-arm64-musl","compile:windows-x64":"bun build ./bin/cli.ts --compile --minify --target=bun-windows-x64 --outfile bin/pickier-windows-x64.exe","compile:windows-arm64":"bun build ./bin/cli.ts --compile --minify --target=bun-windows-arm64 --outfile bin/pickier-windows-arm64.exe","compile:darwin-x64":"bun build ./bin/cli.ts --compile --minify --target=bun-darwin-x64 --outfile bin/pickier-darwin-x64","compile:darwin-arm64":"bun build ./bin/cli.ts --compile --minify --target=bun-darwin-arm64 --outfile bin/pickier-darwin-arm64",zip:"bun run zip:all","zip:all":"bun run zip:linux-x64 && bun run zip:linux-arm64 && bun run zip:linux-x64-musl && bun run zip:linux-arm64-musl && bun run zip:windows-x64 && bun run zip:windows-arm64 && bun run zip:darwin-x64 && bun run zip:darwin-arm64","zip:linux-x64":"zip -j bin/pickier-linux-x64.zip bin/pickier-linux-x64","zip:linux-arm64":"zip -j bin/pickier-linux-arm64.zip bin/pickier-linux-arm64","zip:linux-x64-musl":"zip -j bin/pickier-linux-x64-musl.zip bin/pickier-linux-x64-musl","zip:linux-arm64-musl":"zip -j bin/pickier-linux-arm64-musl.zip bin/pickier-linux-arm64-musl","zip:windows-x64":"zip -j bin/pickier-windows-x64.zip bin/pickier-windows-x64.exe","zip:windows-arm64":"zip -j bin/pickier-windows-arm64.zip bin/pickier-windows-arm64.exe","zip:darwin-x64":"zip -j bin/pickier-darwin-x64.zip bin/pickier-darwin-x64","zip:darwin-arm64":"zip -j bin/pickier-darwin-arm64.zip bin/pickier-darwin-arm64",prepublishOnly:"bun --bun run build && bun run compile:all && bun run zip",test:"PICKIER_NO_AUTO_CONFIG=1 bun test --coverage","test:core":"PICKIER_NO_AUTO_CONFIG=1 bun test test/core","test:format":"PICKIER_NO_AUTO_CONFIG=1 bun test test/format","test:lint":"PICKIER_NO_AUTO_CONFIG=1 bun test test/lint","test:rules":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules","test:rules:sort":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/sort","test:rules:style":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/style","test:rules:quality":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/quality","test:rules:imports":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/imports","test:rules:typescript":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/typescript","test:rules:regexp":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/regexp","test:plugin":"PICKIER_NO_AUTO_CONFIG=1 bun test test/plugin","test:watch":"PICKIER_NO_AUTO_CONFIG=1 bun test --watch"},I={"@stacksjs/clarity":"^0.3.24","@stacksjs/clapp":"^0.2.3"},O={"@stacksjs/ts-spell-check":"^0.1.0"},_={bunfig:"^0.15.13"},z={name:e,type:u,version:t,description:r,author:s,license:l,homepage:p,repository:b,bugs:m,keywords:c,exports:o,module:a,types:x,bin:d,files:w,scripts:k,dependencies:I,optionalDependencies:O,devDependencies:_};export{t as version,x as types,u as type,k as scripts,b as repository,O as optionalDependencies,e as name,a as module,l as license,c as keywords,p as homepage,w as files,o as exports,_ as devDependencies,r as description,I as dependencies,z as default,m as bugs,d as bin,s as author};
@@ -0,0 +1,33 @@
1
+ // @bun
2
+ import{K as P}from"./chunk-ah6h41gy.js";import{N as z0}from"./chunk-43fsk0jg.js";function WZ($){let J=$.length,V=Array.from({length:J},(X,Y)=>$[Y]),Z=0;while(Z<J){let X=$[Z];if(X==="#"&&(Z===0||/\s/.test($[Z-1]))){while(Z<J)V[Z]=" ",Z++;break}if(X==="$"&&$[Z+1]==="'"){Z+=2;while(Z<J){if($[Z]==="\\"&&Z+1<J){V[Z]=" ",V[Z+1]=" ",Z+=2;continue}if($[Z]==="'"){Z++;break}V[Z]=" ",Z++}continue}if(X==="$"&&$[Z+1]==='"'){Z++,Z=x($,Z,V);continue}if(X==="$"&&$[Z+1]==="{"){Z+=2;let Y=1;while(Z<J&&Y>0){let H=$[Z];if(H==="\\"&&Z+1<J){V[Z]=" ",V[Z+1]=" ",Z+=2;continue}if(H==="'"){Z++;while(Z<J&&$[Z]!=="'")V[Z]=" ",Z++;if(Z<J)Z++;continue}if(H==='"'){Z=x($,Z,V);continue}if(H==="{"){Y++,Z++;continue}if(H==="}"){Y--,Z++;continue}V[Z]=" ",Z++}continue}if(X==="$"&&$[Z+1]==="("&&$[Z+2]==="("){Z+=3;let Y=2;while(Z<J&&Y>0){let H=$[Z];if(H==="("){Y++,Z++;continue}if(H===")"){Y--,Z++;continue}V[Z]=" ",Z++}continue}if(X==="$"&&$[Z+1]==="("){Z+=2;let Y=1;while(Z<J&&Y>0){let H=$[Z];if(H==="\\"&&Z+1<J){V[Z]=" ",V[Z+1]=" ",Z+=2;continue}if(H==="'"){Z++;while(Z<J&&$[Z]!=="'")V[Z]=" ",Z++;if(Z<J)Z++;continue}if(H==='"'){Z=x($,Z,V);continue}if(H==="("){Y++,Z++;continue}if(H===")"){Y--,Z++;continue}V[Z]=" ",Z++}continue}if(X==="'"){Z++;while(Z<J&&$[Z]!=="'")V[Z]=" ",Z++;if(Z<J)Z++;continue}if(X==='"'){Z=x($,Z,V);continue}if(X==="`"){Z++;while(Z<J&&$[Z]!=="`"){if($[Z]==="\\"&&Z+1<J){V[Z]=" ",V[Z+1]=" ",Z+=2;continue}V[Z]=" ",Z++}if(Z<J)Z++;continue}Z++}return V.join("")}function x($,J,V){let Z=$.length,X=J+1;while(X<Z){let Y=$[X];if(Y==="\\"&&X+1<Z){V[X]=" ",V[X+1]=" ",X+=2;continue}if(Y==='"')return X+1;if(Y==="$"&&$[X+1]==="("&&$[X+2]==="("){X+=3;let H=2;while(X<Z&&H>0){let U=$[X];if(U==="("){H++,X++;continue}if(U===")"){H--,X++;continue}V[X]=" ",X++}continue}if(Y==="$"&&$[X+1]==="("){X+=2;let H=1;while(X<Z&&H>0){let U=$[X];if(U==="\\"&&X+1<Z){V[X]=" ",V[X+1]=" ",X+=2;continue}if(U==="'"){X++;while(X<Z&&$[X]!=="'")V[X]=" ",X++;if(X<Z)X++;continue}if(U==='"'){X=x($,X,V);continue}if(U==="("){H++,X++;continue}if(U===")"){H--,X++;continue}V[X]=" ",X++}continue}if(Y==="$"&&$[X+1]==="{"){X+=2;let H=1;while(X<Z&&H>0){let U=$[X];if(U==="{"){H++,X++;continue}if(U==="}"){H--,X++;continue}V[X]=" ",X++}continue}V[X]=" ",X++}return X}function a($){let V=WZ($).match(/<<-?/);if(!V||V.index===void 0)return null;let X=$.slice(V.index+V[0].length).match(/^\s*(['"]?)(\w+)\1/);if(!X)return null;return X[2]}var KZ=new Set([".ts",".js"]),FZ=new Set([".json",".jsonc"]),zZ=new Set([".yaml",".yml"]),BZ=new Set([".sh",".bash",".zsh",".ksh",".dash"]),GZ=/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/;var DZ=/^[}\])]/,yZ=/[{[(]\s*$/,MZ=/\s*\/\/.*$/,AZ=/^(?:if|else\s+if|for|while)\s*\(/,OZ=/^(?:\.[\w$[]|\?[\s.:]|:\s|&&|\|\|)/;function NZ($){let J=AZ.exec($);if(!J)return/^(?:else|do)\s*$/.test($);let V=0,Z=null;for(let X=J[0].length-1;X<$.length;X++){let Y=$[X];if(Z){if(Y==="\\"){X++;continue}if(Y===Z)Z=null;continue}if(Y==="'"||Y==='"'||Y==="`"){Z=Y;continue}if(Y==="(")V++;else if(Y===")"){if(V--,V===0)return $.slice(X+1).trim().length===0}}return!1}var jZ=/^\s*for\s*\(/,wZ=new RegExp("^\\s*;\\s*$"),IZ=new RegExp(";{2,}\\s*$"),RZ=/([\w)])\{/g,LZ=/\{(return|if|for|while|switch|const|let|var|function)\b/g,vZ=/,(\S)/g,PZ=/(?<![=!<>+\-*/%&|^?])=(?![=><])/g,_Z=/(\w)\+(\w)/g,TZ=/(\w)-(\w)/g,CZ=/(\w)\*(\w)/g,EZ=/(\w)\/(\w)/g,xZ=new RegExp("(?<=\\S);([^\\s;])","g"),kZ=/([\w)\]])<(\d)/g,bZ=/([\w)\]])>(\d)/g,l=/\s{2,}/g,r=/^\s*$/,SZ=/^\s*\/\//,s=/^\s*\/\*/,fZ=/^\s*import\b/,n=/\bfrom\s*['"][^'"]+['"]|^\s*import\s+['"][^'"]+['"]/,hZ=/package\.json$/i,gZ=/[jt]sconfig(?:\..+)?\.json$/i,f=/[ \t]+$/,mZ=/^\n+/;function b($){let J=$.lastIndexOf(".");return J>=0?$.slice(J):""}function h($){return KZ.has(b($))}function uZ($){return FZ.has(b($))}function cZ($){return zZ.has(b($))}function pZ($){return BZ.has(b($))}function dZ($,J){return pZ($)||GZ.test(J)}function oZ($,J){let V=$.split(`
3
+ `),Z=V.length,X=Array(Z),Y=J.format.indent,H=J.format.indentStyle==="tabs",U=0,W=!1,F="",z=!1,G=0;for(let q=0;q<Z;q++){let D=V[q];if(D.length===0||/^\s*$/.test(D)){X[q]="";continue}if(W){if(X[q]=D,D.trim()===F)W=!1,F="";continue}let M=a(D);if(M)W=!0,F=M;let A=0;while(A<D.length&&(D.charCodeAt(A)===32||D.charCodeAt(A)===9))A++;let B=D.slice(A).trimEnd();if(B.startsWith("#")&&q>0){let E=H?"\t".repeat(U):" ".repeat(U*Y);X[q]=E+B;continue}if(/^case\b/.test(B)&&/\bin\s*$/.test(B))G++,z=!0;if(/^esac\b/.test(B)){if(G=Math.max(0,G-1),G===0)z=!1}let j=z&&/\)\s*$/.test(B)&&!/\$\(/.test(B)&&!/^\s*\(/.test(B)&&!B.startsWith("#"),w=/^;[;&]\s*$/.test(B);if(/^(?:fi|done|esac|elif|else)\b/.test(B)||/^\}/.test(B))U=Math.max(0,U-1);if(w)U=Math.max(0,U-1);let C=H?"\t".repeat(U):" ".repeat(U*Y);if(X[q]=C+B,/^then\b/.test(B)||/^do\b/.test(B)||/^else\b/.test(B))U++;else if(/^if\b/.test(B)&&/\bthen\s*$/.test(B))U++;else if(/^elif\b/.test(B)&&/\bthen\s*$/.test(B))U++;else if(/^(?:while|for|until)\b/.test(B)&&/\bdo\s*$/.test(B))U++;else if(/^case\b/.test(B)&&/\bin\s*$/.test(B))U++;else if(j)U++;else if(/\{\s*$/.test(B)&&!B.startsWith("#"))U++}return X.join(`
4
+ `)}function aZ($,J){try{let V=Bun.YAML.parse($),Z=J.format.indentStyle==="tabs"?"\t":J.format.indent;return Bun.YAML.stringify(V,null,Z).split(`
5
+ `).map((Y)=>Y.replace(/[ \t]+$/,"")).join(`
6
+ `)}catch{return $}}function lZ($){return" ".repeat(Math.max(0,$))}function rZ($,J){if((J.format.indentStyle||"spaces")==="tabs")return"\t".repeat(Math.max(0,$));return lZ(Math.max(0,$*J.format.indent))}function sZ($){return`'${$.slice(1,-1).replace(/\\"/g,'"')}'`}function nZ($){return`"${$.slice(1,-1).replace(/\\'/g,"'")}"`}function tZ($,J){for(let V=0;V<$.length;V++){if($[V]==="\\"){V++;continue}if($[V]===J)return!0}return!1}function iZ($,J,V){if(!h(V))return $;let Z=$.split(`
7
+ `);for(let X=0;X<Z.length;X++)Z[X]=ZZ(Z[X],J);return Z.join(`
8
+ `)}function ZZ($,J){let V=J==="single";if(V?!$.includes('"'):!$.includes("'"))return $;let Z=[],X=0,Y=0,H=0,U=0;while(X<$.length){let W=$[X];if(H===0){if(W==="/"){let F=$[X+1];if(F==="/")break;if(F==="*"){let z=$.indexOf("*/",X+2);X=z===-1?$.length:z+2;continue}if(XZ($,X)){let z=JZ($,X);if(z!==-1){X=z;continue}}X++;continue}if(W==='"'){H=2,U=X,X++;continue}if(W==="'"){H=1,U=X,X++;continue}if(W==="`"){H=3,X++;continue}X++}else if(H===3){if(W==="\\"){X+=2;continue}if(W==="`")H=0;X++}else{if(W==="\\"){X+=2;continue}if(W===(H===1?"'":'"')){let z=$.slice(U+1,X);if((H===2&&V||H===1&&!V)&&!tZ(z,V?"'":'"')){if(U>Y)Z.push($.slice(Y,U));if(H===2)Z.push(sZ(`"${z}"`));else Z.push(nZ(`'${z}'`));Y=X+1}H=0,X++;continue}X++}}if(Z.length===0)return $;if(Y<$.length)Z.push($.slice(Y));return Z.join("")}var eZ=new Set(["{",",","=","+","-","*","/",";","<",">"]);function Z0($){if($.length<4)return $;let J=0;while(J<$.length&&($[J]===" "||$[J]==="\t"))J++;if(J<$.length){let H=$[J];if(H==="/"&&($[J+1]==="/"||$[J+1]==="*"))return $;if(H==="*")return $}let V=!1;for(let H=J;H<$.length;H++)if(eZ.has($[H])){V=!0;break}if(!V)return $;let{text:Z,strings:X}=J0($),Y=Z;if(Y=Y.replace(RZ,"$1 {"),Y=Y.replace(LZ,"{ $1"),Y=Y.replace(vZ,", $1"),Y=Y.replace(PZ," = "),Y=Y.replace(_Z,"$1 + $2"),Y=Y.replace(TZ,"$1 - $2"),Y=Y.replace(CZ,"$1 * $2"),Y=Y.replace(EZ,"$1 / $2"),Y=Y.replace(xZ,"; $1"),Y=Y.replace(kZ,"$1 < $2"),Y=Y.replace(bZ,"$1 > $2"),J>0){let H=Y.slice(J);Y=Y.slice(0,J)+H.replace(l," ")}else Y=Y.replace(l," ");return X.length>0?Y0(Y,X):Y}function S($){let J=$[$.length-1];return J!==void 0&&J.t==="tmpl"}function $Z($,J,V){J++;while(J<$.length){let Z=$[J];if(Z==="\\"){J+=2;continue}if(Z===V)return J+1;J++}return J}function g($,J){for(let Z of J)if(Z.t==="tmpl")Z.start=-1;let V=0;while(V<$.length){let Z=J[J.length-1],X=$[V];if(Z===void 0||Z.t==="interp"){if(X==="`"){J.push({t:"tmpl",start:V}),V++;continue}if(X==="'"||X==='"'){V=$Z($,V,X);continue}if(X==="/"&&$[V+1]==="/")break;if(Z!==void 0){if(X==="{"){Z.braces++,V++;continue}if(X==="}"){if(Z.braces===0)J.pop();else Z.braces--;V++;continue}}V++}else{if(X==="\\"){V+=2;continue}if(X==="`"){J.pop(),V++;continue}if(X==="$"&&$[V+1]==="{"){J.push({t:"interp",braces:0}),V+=2;continue}V++}}if(S(J)){for(let Z of J)if(Z.t==="tmpl"&&Z.start>=0)return Z.start}return-1}function t($,J){let V=J,Z=null,X=0;while(X<$.length){let Y=$[X];if(V){if(Y==="*"&&$[X+1]==="/"){V=!1,X+=2;continue}X++;continue}if(Z){if(Y==="\\"){X+=2;continue}if(Y===Z)Z=null;X++;continue}if(Y==="'"||Y==='"'||Y==="`"){Z=Y,X++;continue}if(Y==="/"){if($[X+1]==="/")break;if($[X+1]==="*"){V=!0,X+=2;continue}}X++}return V}function $0($,J){let V=$.split(`
9
+ `),Z=V.length,X=Array(Z),Y=J.format.quotes,H=J.format.semi===!0,U=0,W=0,F=!1,z=[];for(let G=0;G<Z;G++){let q=V[G];if(F){F=t(q,!0),X[G]=q;continue}let D=S(z),M=-1;if(z.length>0||q.indexOf("`")!==-1)M=g(q,z);if(D){X[G]=q;continue}if(M<0&&z.length===0)F=t(q,!1);let A="",B=!1,j="";if(M>=0){A=q.slice(M);let L=q.slice(0,M);if(L.length===0){X[G]=A;continue}if(B=f.test(L),L.trim().length===0)j=L;q=L}if(q.length===0){X[G]="";continue}q=ZZ(q,Y);let w=0;while(w<q.length&&(q.charCodeAt(w)===32||q.charCodeAt(w)===9))w++;let I=q.slice(w).trimEnd();if(DZ.test(I))U=Math.max(0,U-1);let C=OZ.test(I)?1:0,E=q.slice(0,w);if(q=J.format.preserveCodeIndentation?E+I:rZ(U+W+C,J)+I,yZ.test(I))U+=1,W=0;else if(!I.startsWith("//")&&!I.startsWith("*")&&!I.startsWith("/*")){let L=I.replace(MZ,"");W=NZ(L)?W+1:0}if(q=Z0(q),H){if(!jZ.test(q))if(wZ.test(q))q="";else q=q.replace(IZ,";")}if(J.format.trimTrailingWhitespace)q=q.trimEnd();if(M>=0){if(j)q=j;else if(B&&!f.test(q))q+=" ";q+=A}X[G]=q}return X.join(`
10
+ `)}function V0($,J){let V=[],Z=0,X=[];for(let Y of $){let H=S(X);if(X.length>0||Y.indexOf("`")!==-1)g(Y,X);if(H){V.push(Y),Z=0;continue}if(Y===""){if(Z++,Z<=J)V.push("")}else Z=0,V.push(Y)}return V}function T0($,J,V){if($.length===0)return"";let X=($.includes("\r")?$.replace(/\r\n/g,`
11
+ `):$).split(`
12
+ `),Y;if(J.format.trimTrailingWhitespace){Y=[];let F=0,z=Math.max(0,J.format.maxConsecutiveBlankLines),G=[];for(let q of X){let D=S(G),M=!1;if(G.length>0||q.indexOf("`")!==-1)M=g(q,G)>=0;if(D||M){Y.push(q),F=0;continue}let A=q[q.length-1],B=A===" "||A==="\t"?q.replace(f,""):q;if(B===""){if(F++,F<=z)Y.push("")}else F=0,Y.push(B)}}else Y=V0(X,Math.max(0,J.format.maxConsecutiveBlankLines));let H=Y.join(`
13
+ `);if(H=H.replace(mZ,""),h(V))H=U0(H);if(cZ(V)){let F=aZ(H,J);if(F!==H)H=F}if(uZ(V)){let F=W0(H,V);if(F!=null)H=F}if(dZ(V,H))H=oZ(H,J);else if(h(V))H=$0(H,J);else H=iZ(H,J.format.quotes,V);if(J.format.finalNewline==="none")return H.replace(/\n+$/g,"");let U=/[^\n]\n$/.test(H)||H===`
14
+ `,W=/\n\n$/.test(H);if(J.format.finalNewline==="two"){if(W)return H;if(U)return`${H}
15
+ `;return`${H}
16
+
17
+ `}if(W)return H.replace(/\n\n$/,`
18
+ `);if(U)return H;return`${H}
19
+ `}function i($,J,V,Z){for(let X=J+1;X<$.length;X++){let Y=$[X];if(Y==="\\"){X++;continue}if(Y===V)return!0;if(Y===Z)return!1}return!0}function C0($,J){if(/^\s*\/\/\/\s*<reference/.test($))return[];let V=[],Z=null,X=!1;for(let Y=0;Y<$.length;Y++){let H=$[Y];if(X){X=!1;continue}if(H==="\\"){X=!0;continue}if(!Z){if(H==="/"&&$[Y+1]==="/")break;if(H==="'"){if(J==="double"&&i($,Y,"'",'"'))V.push(Y);Z="single";continue}else if(H==='"'){if(J==="single"&&i($,Y,'"',"'"))V.push(Y);Z="double";continue}else if(H==="`"){Z="template";continue}}else if(Z==="single"&&H==="'"||Z==="double"&&H==='"'||Z==="template"&&H==="`"){Z=null;continue}}return V}function E0($,J,V="spaces",Z){if(V==="tabs")return/[^\t]/.test($);if(/\t/.test($))return!0;let X=$.length;if(Z&&X%J===1){let Y=Z.trimStart();if(Y.startsWith("* ")||Y.startsWith("*/")||Y==="*")return!1}return X%J!==0}function VZ($,J){let V=J+1;while(V<$.length){let Z=$[V];if(Z==="\\"){V+=2;continue}if(Z==="`")return V+1;if(Z==="$"&&$[V+1]==="{"){V+=2;let X=1;while(V<$.length&&X>0){let Y=$[V];if(Y==="\\"){V+=2;continue}if(Y==="`"){V=VZ($,V);continue}if(Y==="'"||Y==='"'){V=$Z($,V,Y);continue}if(Y==="{")X++;else if(Y==="}")X--;V++}continue}V++}return V}var X0=new Set(["return","typeof","instanceof","in","of","new","delete","void","do","else","case","yield","await"]);function XZ($,J){let V=J-1;while(V>=0&&($[V]===" "||$[V]==="\t"))V--;if(V<0)return!0;let Z=$[V];if("(,=:[!&|?;{}<>+-*%^~".includes(Z))return!0;if(/[\w$]/.test(Z)){let X=V;while(X>=0&&/[\w$]/.test($[X]))X--;return X0.has($.slice(X+1,V+1))}return!1}function JZ($,J){let V=J+1,Z=!1,X=-1;while(V<$.length){let Y=$[V];if(Y==="\\"){V+=2;continue}if(Y==="["&&!Z)Z=!0,X=V;else if(Y==="]"&&Z){let H=$[X+1]==="^"?X+2:X+1;if(V!==H)Z=!1}else if(Y==="/"&&!Z){V++;while(V<$.length&&/[a-z]/i.test($[V]))V++;return V}V++}return-1}function J0($){if(!$.includes("'")&&!$.includes('"')&&!$.includes("`")&&!$.includes("/"))return{text:$,strings:[]};let J=[],V=[],Z=0,X=0;while(Z<$.length){let Y=$[Z];if(Y==="/"){let H=$[Z+1];if(H==="/"){if(Z>X)V.push($.slice(X,Z));J.push($.slice(Z)),V.push(`@@S${J.length-1}@@`),X=$.length;break}if(H==="*"){let U=$.indexOf("*/",Z+2),W=U===-1?$.length:U+2;if(Z>X)V.push($.slice(X,Z));J.push($.slice(Z,W)),V.push(`@@S${J.length-1}@@`),Z=W,X=Z;continue}if(XZ($,Z)){let U=JZ($,Z);if(U!==-1){if(Z>X)V.push($.slice(X,Z));J.push($.slice(Z,U)),V.push(`@@S${J.length-1}@@`),Z=U,X=Z;continue}}Z++;continue}if(Y==="'"||Y==='"'||Y==="`"){if(Z>X)V.push($.slice(X,Z));let H=Z;if(Y==="`")Z=VZ($,Z);else{let U=Y;Z++;while(Z<$.length){if($[Z]==="\\"){Z+=2;continue}if($[Z]===U){Z++;break}Z++}}J.push($.slice(H,Z)),V.push(`@@S${J.length-1}@@`),X=Z;continue}Z++}if(X<$.length)V.push($.slice(X));return{text:V.join(""),strings:J}}function Y0($,J){if(J.length===0)return $;return $.replace(/@@S(\d+)@@/g,(V,Z)=>J[Number(Z)]??"")}function H0($){let J=new Set,V=/[$A-Z_][\w$]*/gi,Z=V.exec($);while(Z!==null)J.add(Z[0]),Z=V.exec($);return J}function U0($){let J=$[0];if(J!=="i"&&J!==" "&&J!=="\t"&&J!=="/"&&J!==`
20
+ `)return $;let V=$.split(`
21
+ `),Z=[],X=[],Y=[],H=0,U=0,W=-1,F=!1;while(H<V.length){let Q=V[H];if(r.test(Q)){H++;continue}if(SZ.test(Q)||s.test(Q)){let y=H;if(s.test(Q)){while(H<V.length&&!V[H].includes("*/"))H++;H++}else H++;if(!F){for(let R=y;R<H&&R<V.length;R++)X.push(V[R]);U=H}else if(W<0)W=y;continue}if(!fZ.test(Q))break;let K=Q.trim(),N=H+1;while(!n.test(K)&&N<V.length&&N-H<50)K+=` ${V[N].trim()}`,N++;if(!n.test(K))return $;let O=Q0(K);if(!O)return $;if(W>=0){for(let y=W;y<H;y++)if(!r.test(V[y]))Y.push(V[y]);W=-1}Z.push(O),H=N,U=H,F=!0}if(Z.length===0)return $;let z=W>=0?W:U,G=V.slice(z).join(`
22
+ `),q=H0(G),D=(Q)=>q.has(Q);for(let Q of Z){if(Q.kind!=="value")continue;Q.named=Q.named.filter((K)=>{if(K.alias)return!0;return D(K.name)})}let M=Z.filter((Q)=>{if(Q.kind==="side-effect")return!0;if(Q.kind==="type")return Q.namedTypes.length>0;return Boolean(Q.defaultName||Q.namespaceName||Q.named.length>0)}),A=new Map;for(let Q of M){let K=A.get(Q.source)||{};if(Q.kind==="side-effect")K.side=K.side||[],K.side.push(Q);else if(Q.kind==="type"){if(!K.type)K.type={kind:"type",source:Q.source,named:[],namedTypes:[],original:""};K.type.namedTypes=(K.type.namedTypes||[]).concat(Q.namedTypes)}else{if(!K.value)K.value={kind:"value",source:Q.source,named:[],namedTypes:[],original:""};if(Q.defaultName)K.value.defaultName=Q.defaultName;if(Q.namespaceName)K.value.namespaceName=Q.namespaceName;if(K.value.named=(K.value.named||[]).concat(Q.named),Q.namedTypes.length>0){if(!K.type)K.type={kind:"type",source:Q.source,named:[],namedTypes:[],original:""};K.type.namedTypes=K.type.namedTypes.concat(Q.namedTypes)}}A.set(Q.source,K)}let B=[];for(let[Q,K]of A){if(K.side)B.push(...K.side);if(K.value){let N=(O)=>{if(!O.alias)return O;return/^[A-Z]$/i.test(O.name)&&/^[A-Z]$/i.test(O.alias)?{name:O.alias,alias:O.name}:O};K.value.named=K.value.named.map(N),K.value.named.sort((O,y)=>O.name.localeCompare(y.name)),B.push(K.value)}if(K.type&&K.type.namedTypes.length>0){let N=new Set,O=(y)=>{if(!y.alias)return y;return/^[A-Z]$/i.test(y.name)&&/^[A-Z]$/i.test(y.alias)?{name:y.alias,alias:y.name}:y};K.type.namedTypes=K.type.namedTypes.map(O).filter((y)=>{let R=`${y.name}|${y.alias||""}`;if(N.has(R))return!1;return N.add(R),!0}),K.type.namedTypes.sort((y,R)=>y.name.localeCompare(R.name)),B.push(K.type)}}let j=(Q)=>Q.startsWith(".")?2:Q.startsWith("node:")?0:1,w=(Q)=>{if(Q.kind!=="value")return 99;if(Q.defaultName)return 0;if(Q.namespaceName)return 1;return 2};B.sort((Q,K)=>{if(Q.kind!==K.kind){if(Q.kind==="type")return-1;if(K.kind==="type")return 1;if(Q.kind==="side-effect")return-1;if(K.kind==="side-effect")return 1}if(Q.kind==="type"&&K.kind==="type"){let N=j(Q.source),O=j(K.source);if(N!==O)return N-O;return Q.source.localeCompare(K.source)}if(Q.kind==="value"&&K.kind==="value"){let N=j(Q.source),O=j(K.source);if(N!==O)return N-O;let y=w(Q),R=w(K);if(y!==R)return y-R;return Q.source.localeCompare(K.source)}return Q.source.localeCompare(K.source)});let I=X.length>0?`${X.join(`
23
+ `)}
24
+ `:"";if(B.length===0){let Q=G.replace(/^\n+/,""),K=[...Y];if(I||K.length>0)return`${I}${K.length>0?`${K.join(`
25
+ `)}
26
+ `:""}${Q}`;return Q}let C=B.map(q0).join(`
27
+ `),E=Y.length>0?`
28
+ ${Y.join(`
29
+ `)}`:"",L=G.replace(/^\n+/,""),QZ=L.length>0?`
30
+
31
+ `:`
32
+ `;return`${I}${C}${E}${QZ}${L}`}function q0($){if($.kind==="side-effect")return`import '${$.source}'`;if($.kind==="type")return`import type { ${$.namedTypes.map((X)=>X.alias?`${X.name} as ${X.alias}`:X.name).join(", ")} } from '${$.source}'`;let J=[];if($.defaultName)J.push($.defaultName);if($.namespaceName)J.push(`* as ${$.namespaceName}`);if($.named.length>0){let Z=$.named.map((X)=>X.alias?`${X.name} as ${X.alias}`:X.name).join(", ");J.push(`{ ${Z} }`)}return`import ${J.join(", ")} from '${$.source}'`}function Q0($){let J=$.match(/^\s*import\s+['"]([^'"]+)['"]/);if(J)return{kind:"side-effect",source:J[1],named:[],namedTypes:[],original:$};if(J=$.match(/^\s*import\s+type\s+\{([^}]*)\}\s+from\s+['"]([^'"]+)['"]/),J){let q=J[1],D=J[2],M=q.split(",").map((A)=>A.trim()).filter(Boolean).map((A)=>{let B=A.match(/^(\w+)(?:\s+as\s+(\w+))?$/);return{name:B?.[1]||A,alias:B?.[2]}});return{kind:"type",source:D,named:[],namedTypes:M,original:$}}let V=$.match(/^\s*import\s+/),Z=new RegExp(`\\sfrom\\s+['"]([^'"]+)['"]\\s*;?$`),X=$.match(Z);if(!V||!X)return;let Y=X[1],H=$.slice(V[0].length,X.index).trim(),U,W,F=[],z=[],G=H.match(/\{([^}]*)\}/);if(G){let D=G[1].split(",").map((M)=>M.trim()).filter(Boolean);for(let M of D){let A=/^type\s+/.test(M),j=M.replace(/^type\s+/,"").match(/^(\w+)(?:\s+as\s+(\w+))?$/);if(!j)continue;let w={name:j[1],alias:j[2]};if(A)z.push(w);else F.push(w)}H=H.replace(/\{[\s\S]*?\}/,"").trim()}if(H.length>0){let q=H.split(",").map((D)=>D.trim()).filter(Boolean);for(let D of q)if(D.startsWith("* as "))W=D.slice(5).trim();else if(/^\w+$/.test(D))U=D}return{kind:"value",source:Y,defaultName:U,namespaceName:W,named:F,namedTypes:z,original:$}}function W0($,J){if(hZ.test(J))return K0($);if(gZ.test(J))return F0($);return null}function YZ($){try{return JSON.parse($)}catch{return null}}function k($,J,V=[]){let Z={};for(let Y of J)if(Object.prototype.hasOwnProperty.call($,Y))Z[Y]=$[Y];for(let Y of V){let H=Object.keys($).filter((U)=>Y.test(U)&&!(U in Z)).sort();for(let U of H)Z[U]=$[U]}let X=Object.keys($).filter((Y)=>!(Y in Z)).sort();for(let Y of X)Z[Y]=$[Y];return Z}function e($){let J={};for(let V of Object.keys($).sort())J[V]=$[V];return J}function K0($){let J=YZ($);if(!J||typeof J!=="object")return $;let Z=k(J,["publisher","name","displayName","type","version","private","packageManager","description","author","contributors","license","funding","homepage","repository","bugs","keywords","categories","sideEffects","imports","exports","main","module","unpkg","jsdelivr","types","typesVersions","bin","icon","files","engines","activationEvents","contributes","scripts","peerDependencies","peerDependenciesMeta","dependencies","optionalDependencies","devDependencies","pnpm","overrides","resolutions","husky","simple-git-hooks","lint-staged","eslintConfig"]);if(Array.isArray(Z.files)){if(Z.files.every((H)=>typeof H==="string"))Z.files=[...Z.files].sort()}for(let Y of Object.keys(Z))if(/^(?:dev|peer|optional|bundled)?[Dd]ependencies(?:Meta)?$/.test(Y)||/^(?:resolutions|overrides|pnpm\.overrides)$/.test(Y)){if(Z[Y]&&typeof Z[Y]==="object")Z[Y]=e(Z[Y])}if(Z.pnpm&&typeof Z.pnpm==="object"&&Z.pnpm.overrides&&typeof Z.pnpm.overrides==="object")Z.pnpm.overrides=e(Z.pnpm.overrides);if(Z.exports&&typeof Z.exports==="object"){let Y=Z.exports,H=["types","import","require","default"];if(!Array.isArray(Y)){let U={};for(let W of Object.keys(Y)){let F=Y[W];if(F&&typeof F==="object"&&!Array.isArray(F))U[W]=k(F,H);else U[W]=F}Z.exports=U}}let X=["pre-commit","prepare-commit-msg","commit-msg","post-commit","pre-rebase","post-rewrite","post-checkout","post-merge","pre-push","pre-auto-gc"];for(let Y of["gitHooks","husky","simple-git-hooks"])if(Z[Y]&&typeof Z[Y]==="object")Z[Y]=k(Z[Y],X);return JSON.stringify(Z,null,2)}function F0($){let J=YZ($);if(!J||typeof J!=="object")return $;let Z=k(J,["extends","compilerOptions","references","files","include","exclude"]);if(Z.compilerOptions&&typeof Z.compilerOptions==="object"){let X=["incremental","composite","tsBuildInfoFile","disableSourceOfProjectReferenceRedirect","disableSolutionSearching","disableReferencedProjectLoad","target","jsx","jsxFactory","jsxFragmentFactory","jsxImportSource","lib","moduleDetection","noLib","reactNamespace","useDefineForClassFields","emitDecoratorMetadata","experimentalDecorators","libReplacement","baseUrl","rootDir","rootDirs","customConditions","module","moduleResolution","moduleSuffixes","noResolve","paths","resolveJsonModule","resolvePackageJsonExports","resolvePackageJsonImports","typeRoots","types","allowArbitraryExtensions","allowImportingTsExtensions","allowUmdGlobalAccess","allowJs","checkJs","maxNodeModuleJsDepth","strict","strictBindCallApply","strictFunctionTypes","strictNullChecks","strictPropertyInitialization","allowUnreachableCode","allowUnusedLabels","alwaysStrict","exactOptionalPropertyTypes","noFallthroughCasesInSwitch","noImplicitAny","noImplicitOverride","noImplicitReturns","noImplicitThis","noPropertyAccessFromIndexSignature","noUncheckedIndexedAccess","noUnusedLocals","noUnusedParameters","useUnknownInCatchVariables","declaration","declarationDir","declarationMap","downlevelIteration","emitBOM","emitDeclarationOnly","importHelpers","importsNotUsedAsValues","inlineSourceMap","inlineSources","mapRoot","newLine","noEmit","noEmitHelpers","noEmitOnError","outDir","outFile","preserveConstEnums","preserveValueImports","removeComments","sourceMap","sourceRoot","stripInternal","allowSyntheticDefaultImports","esModuleInterop","forceConsistentCasingInFileNames","isolatedDeclarations","isolatedModules","preserveSymlinks","verbatimModuleSyntax","erasableSyntaxOnly","skipDefaultLibCheck","skipLibCheck"];Z.compilerOptions=k(Z.compilerOptions,X)}return JSON.stringify(Z,null,2)}import{readdirSync as B0,readFileSync as G0,statSync as UZ}from"fs";import{extname as D0,isAbsolute as u,join as c,resolve as y0}from"path";import v from"process";var h0=5;function M0($){let J="",V=0;while(V<$.length){let Z=$[V];if(Z==="*")if($[V+1]==="*"){if(J+=".*",V+=2,$[V]==="/")V++}else J+="[^/]*",V++;else if(Z==="?")J+="[^/]",V++;else if(Z==="["){let X=$.indexOf("]",V);if(X===-1)J+="\\[",V++;else J+=$.slice(V,X+1),V=X+1}else if(".+^${}()|\\".includes(Z))J+=`\\${Z}`,V++;else J+=Z,V++}return new RegExp(`^${J}$`)}function*qZ($,J,V){let Z;try{Z=B0($)}catch{return}for(let X of Z){if(!V&&X.startsWith("."))continue;let Y=c($,X);if(J(Y))continue;let H;try{H=UZ(Y)}catch{continue}if(H.isDirectory())yield*qZ(Y,J,V);else yield Y}}function*HZ($,J,V,Z){yield*qZ($,o(J,Z),V)}async function g0($,J={}){let V=J.cwd??v.cwd(),Z=J.ignore??[],X=J.dot??!1,Y=J.absolute??!0,H=o(Z,V);if(typeof globalThis.Bun?.Glob<"u"){let W=globalThis.Bun.Glob,F=[];for(let z of $){let G=new W(z);for await(let q of G.scan({cwd:V,dot:X,onlyFiles:J.onlyFiles??!0,followSymlinks:!1})){let D=u(q)?q:c(V,q),M=D.startsWith(`${V}/`)?D.slice(V.length+1):D;if(H(D))continue;F.push(Y?D:M)}}return F}let U=[];for(let W of $){if(!/[*?[{]/.test(W)){let z=u(W)?W:c(V,W);try{if(!UZ(z).isDirectory()){let q=z.startsWith(`${V}/`)?z.slice(V.length+1):z;if(!H(z))U.push(Y?z:q)}else for(let q of HZ(z,Z,X,V))U.push(Y?q:q.startsWith(`${V}/`)?q.slice(V.length+1):q)}catch{}continue}let F=M0(W);for(let z of HZ(V,Z,X,V)){let G=z.startsWith(`${V}/`)?z.slice(V.length+1):z;if(F.test(G)||F.test(G.replace(/\\/g,"/")))U.push(Y?z:G)}}return U}function m0($){let J=0,V=[],Z=()=>{if(V.length>0&&J<$)J++,V.shift()()};return(X)=>{return new Promise((Y,H)=>{let U=()=>{X().then((W)=>{J--,Y(W),Z()},(W)=>{J--,H(W),Z()})};if(J<$)J++,U();else V.push(U)})}}var A0={get TRACE(){return v.env.PICKIER_TRACE==="1"},get TIMEOUT_MS(){return Number(v.env.PICKIER_TIMEOUT_MS||"8000")},get RULE_TIMEOUT_MS(){return Number(v.env.PICKIER_RULE_TIMEOUT_MS||"5000")},get CONCURRENCY(){return Number(v.env.PICKIER_CONCURRENCY)||8},get DIAGNOSTICS(){return v.env.PICKIER_DIAGNOSTICS==="1"},get FAIL_ON_WARNINGS(){return v.env.PICKIER_FAIL_ON_WARNINGS==="1"},get NO_AUTO_CONFIG(){return v.env.PICKIER_NO_AUTO_CONFIG==="1"}},p=["**/node_modules/**","**/.git/**"],O0=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.next/**","**/.nuxt/**","**/.output/**","**/.vercel/**","**/.netlify/**","**/.cache/**","**/.turbo/**","**/.vscode/**","**/.idea/**","**/.zed/**","**/.cursor/**","**/.claude/**","**/.github/**","**/coverage/**","**/.nyc_output/**","**/.tmp/**","**/.temp/**","**/vendor/**","**/pantry/**","**/target/**","**/zig-cache/**","**/zig-out/**","**/.zig-cache/**","**/__pycache__/**","**/.pytest_cache/**","**/venv/**","**/.venv/**","**/out/**","**/.DS_Store","**/Thumbs.db"];function u0($,J){let V=$[J];if(V===void 0){let Y=J.indexOf("/");if(Y>0){let H=J.slice(0,Y),U=J.slice(Y+1),W=H==="general"?"pickier":H==="pickier"?"general":null;if(W)V=$[`${W}/${U}`];if(V===void 0)V=$[U]}}let Z,X;if(typeof V==="string"){if(V==="error")Z="error";else if(V==="warn"||V==="warning")Z="warning"}else if(Array.isArray(V)&&typeof V[0]==="string"){let Y=V[0];if(Y==="error")Z="error";else if(Y==="warn"||Y==="warning")Z="warning";X=V[1]}return{enabled:!!Z,severity:Z,options:X}}function T($,J){return`\x1B[${$}m${J}\x1B[0m`}function N0($){return T("32",$)}function j0($){return T("31",$)}function w0($){return T("33",$)}function I0($){return T("34",$)}function R0($){return T("90",$)}function L0($){return T("1",$)}var c0={green:N0,red:j0,yellow:w0,blue:I0,gray:R0,bold:L0};function _($,J){let V=J.ignores?[...new Set([...$.ignores||[],...J.ignores])]:$.ignores,Z={...$.pluginRules||{},...J.pluginRules||{}};if((J.tailwind??$.tailwind)?.enabled&&!Object.prototype.hasOwnProperty.call(Z,"pickier/sort-tailwind-classes"))Z["pickier/sort-tailwind-classes"]="warn";return{...$,...J,verbose:J.verbose??$.verbose,ignores:V,lint:{...$.lint,...J.lint||{}},format:{...$.format,...J.format||{}},rules:{...$.rules,...J.rules||{}},pluginRules:Z}}var m=null;async function p0($){if(!$){if(A0.NO_AUTO_CONFIG){if(!m)m=_(P,{});return m}try{let{getConfig:Z}=await import("./chunk-3wr40yqq.js"),X=await Z();return _(P,X)}catch{}return _(P,{})}let J=u($)?$:y0(v.cwd(),$);if(D0(J).toLowerCase()===".json")try{let Z=G0(J,"utf8");return _(P,JSON.parse(Z))}catch{return console.warn(`[pickier:warn] Config file not found: ${J}. Using default config values.`),_(P,{})}try{let Z=await import(J);return _(P,Z.default||Z)}catch{return console.warn(`[pickier:warn] Config file not found: ${J}. Using default config values.`),_(P,{})}}function d0($){return $.map((J)=>{if(/[*?[\]{}()!]/.test(J))return J;if(/\.[A-Z0-9]+$/i.test(J))return J;return`${J.replace(/\/$/,"")}/**/*`})}function o0($,J){let V=$.lastIndexOf(".");if(V<0)return!1;let Z=$.slice(V);return J.has(Z)}function d($){return $.replace(/\\/g,"/").replace(/\/+/g,"/")}function v0($){let J=[];for(let V of $){let Z=d(V.trim());if(!Z)continue;let X=Z.match(/\*\*\/\*\.(.+)$/);if(X){J.push({raw:Z,kind:"extension",value:X[1]});continue}let Y=Z.match(/\*\*\/(.+?)\/\*\*$/);if(Y){J.push({raw:Z,kind:"segment",value:Y[1]});continue}let H=Z.match(/\*\*\/(.+)$/);if(H)J.push({raw:Z,kind:"suffix",value:H[1].replace(/\/$/,"")})}return J}function a0($){return[...new Set([...p,...$])]}function o($,J=v.cwd()){let V=v0([...p,...$]);if(V.length===0)return()=>!1;let Z=new Set([...O0,...p]);return(X)=>{let Y=d(X),H=d(J).replace(/\/$/,""),U=Y!==H&&!Y.startsWith(`${H}/`),W=U?Y:Y.slice(H.length);for(let F of V){if(U&&!Z.has(F.raw))continue;if(F.kind==="extension"){if(W.endsWith(`.${F.value}`))return!0;continue}if(F.kind==="segment"||F.kind==="suffix"){let z=F.value;if(W.includes(`/${z}/`)||W.endsWith(`/${z}`))return!0}}return!1}}function l0($,J){return o(J)($)}
33
+ export{WZ as i,a as j,T0 as k,C0 as l,E0 as m,U0 as n,h0 as o,g0 as p,m0 as q,A0 as r,p as s,O0 as t,u0 as u,T as v,N0 as w,j0 as x,w0 as y,I0 as z,R0 as A,L0 as B,c0 as C,_ as D,p0 as E,d0 as F,o0 as G,a0 as H,o as I,l0 as J};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{D as H,k as G}from"./chunk-1r3qehn7.js";import{L as K}from"./chunk-h6ac3d60.js";import{readFileSync as M,statSync as N,writeFileSync as Q}from"fs";import{isAbsolute as R,resolve as T}from"path";import U from"process";async function w(k,j){let B=j.mode||"auto";if(B==="format"&&k.length===1&&!/[*?[\]{}()!]/.test(k[0]))try{let q=k[0],z=R(q)?q:T(U.cwd(),q);if(N(z).isFile()){let J=await H(j.config),D=M(z,"utf8"),E=G(D,J,z);if(j.check&&E!==D)return 1;if(j.write&&E!==D)Q(z,E,"utf8");return 0}}catch{}let{runLint:x}=await import("./chunk-vn8ayn2e.js");if(B==="lint")return x(k,j);if(B==="format"){let q={...j,fix:!0,dryRun:!!j.check,ext:j.ext,_formatOnly:!0};return x(k,q)}if(!(j.fix===!0||j.write===!0||j.check===!0))return x(k,j);let I={...j,fix:!0,dryRun:!!j.check,ext:j.ext};return x(k,I)}
2
+ import{E as H,k as G}from"./chunk-55vrfsnk.js";import{N as K}from"./chunk-43fsk0jg.js";import{readFileSync as M,statSync as N,writeFileSync as Q}from"fs";import{isAbsolute as R,resolve as T}from"path";import U from"process";async function w(k,j){let B=j.mode||"auto";if(B==="format"&&k.length===1&&!/[*?[\]{}()!]/.test(k[0]))try{let q=k[0],z=R(q)?q:T(U.cwd(),q);if(N(z).isFile()){let J=await H(j.config),D=M(z,"utf8"),E=G(D,J,z);if(j.check&&E!==D)return 1;if(j.write&&E!==D)Q(z,E,"utf8");return 0}}catch{}let{runLint:x}=await import("./chunk-05f5gzwf.js");if(B==="lint")return x(k,j);if(B==="format"){let q={...j,fix:!0,dryRun:!!j.check,ext:j.ext,_formatOnly:!0};return x(k,q)}if(!(j.fix===!0||j.write===!0||j.check===!0))return x(k,j);let I={...j,fix:!0,dryRun:!!j.check,ext:j.ext};return x(k,I)}
3
3
  export{w as h};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{h as a}from"./chunk-78a1vyw0.js";import"./chunk-55vrfsnk.js";import"./chunk-ah6h41gy.js";import"./chunk-43fsk0jg.js";export{a as runUnified};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{L as l}from"./chunk-h6ac3d60.js";import{existsSync as iX,statSync as sX}from"fs";import{existsSync as LZ,mkdirSync as O8,readdirSync as N8,readFileSync as KZ,writeFileSync as C8}from"fs";import{homedir as YQ}from"os";import{dirname as P8,resolve as d}from"path";import eQ from"process";import{existsSync as oX,statSync as tX}from"fs";import{existsSync as DX,mkdirSync as jZ,readdirSync as IZ,writeFileSync as FZ}from"fs";import{homedir as ZQ}from"os";import{dirname as rX,resolve as y}from"path";import XQ from"process";import{join as MZ,relative as DZ,resolve as aX}from"path";import pQ from"process";import{existsSync as yY,mkdirSync as g8,readdirSync as c8,writeFileSync as l8}from"fs";import{homedir as ZX}from"os";import{dirname as s8,resolve as b}from"path";import wQ from"process";import{join as VZ,relative as SZ,resolve as eX}from"path";import mQ from"process";import{existsSync as vY,mkdirSync as e8,readdirSync as Q9,writeFileSync as X9}from"fs";import{dirname as Z9,resolve as uQ}from"path";import VX from"process";import{Buffer as e}from"buffer";import{createCipheriv as EZ,createDecipheriv as TZ,randomBytes as $X}from"crypto";import{closeSync as HX,createReadStream as QY,createWriteStream as OZ,existsSync as UX,fsyncSync as XY,openSync as YY,writeFileSync as NZ}from"fs";import{access as CZ,constants as ZY,mkdir as xZ,readdir as IQ,rename as $Y,stat as $Q,unlink as FQ,writeFile as JX}from"fs/promises";import{join as HQ}from"path";import N from"process";import{pipeline as kZ}from"stream/promises";import{createGzip as HY}from"zlib";import UQ from"process";import o from"process";import{Buffer as i}from"buffer";import{createCipheriv as PZ,createDecipheriv as bZ,randomBytes as GX}from"crypto";import{closeSync as _X,createReadStream as UY,createWriteStream as yZ,existsSync as MQ,fsyncSync as JY,openSync as GY,writeFileSync as vZ}from"fs";import{access as dZ,constants as _Y,mkdir as hZ,readdir as DQ,rename as qY,stat as JQ,unlink as VQ,writeFile as qX}from"fs/promises";import{isAbsolute as fZ,join as GQ,resolve as pZ}from"path";import R from"process";import{pipeline as mZ}from"stream/promises";import{createGzip as WY}from"zlib";import _Q from"process";import t from"process";import SQ from"process";import{existsSync as EQ}from"fs";import{resolve as WX}from"path";import{existsSync as uZ}from"fs";import{existsSync as gZ,readdirSync as cZ}from"fs";import{extname as AX,resolve as AY}from"path";import lZ from"process";import{join as nZ,relative as iZ,resolve as zY}from"path";import gQ from"process";import{Buffer as s}from"buffer";import{createCipheriv as sZ,createDecipheriv as oZ,randomBytes as zX}from"crypto";import{closeSync as BX,createReadStream as BY,createWriteStream as tZ,existsSync as TQ,fsyncSync as RY,openSync as wY,writeFileSync as rZ}from"fs";import{access as aZ,constants as LY,mkdir as eZ,readdir as OQ,rename as KY,stat as qQ,unlink as NQ,writeFile as RX}from"fs/promises";import{isAbsolute as Q0,join as WQ,resolve as X0}from"path";import w from"process";import{pipeline as Y0}from"stream/promises";import{createGzip as jY}from"zlib";import AQ from"process";import r from"process";import xQ from"process";import{existsSync as kQ}from"fs";import{resolve as FX}from"path";import{existsSync as M8}from"fs";class PY{cache=new Map;totalHits=0;totalMisses=0;options;constructor(Q={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...Q}}generateKey(Q,X){let Y=X?`:${X}`:"";return`${this.options.keyPrefix}${Q}${Y}`}isExpired(Q){return Date.now()-Q.timestamp.getTime()>Q.ttl}estimateSize(Q){try{return JSON.stringify(Q).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let Q=Array.from(this.cache.entries()).sort(([,Y],[,Z])=>Y.timestamp.getTime()-Z.timestamp.getTime()),X=Q.length-this.options.maxSize+1;for(let Y=0;Y<X;Y++)this.cache.delete(Q[Y][0])}set(Q,X,Y,Z){if(!this.options.enabled)return;let $=this.generateKey(Q,Y),H=Z??this.options.ttl,U=this.estimateSize(X);this.cache.set($,{value:X,timestamp:new Date,ttl:H,hits:0,size:U}),this.evictIfNeeded()}get(Q,X){if(!this.options.enabled){this.totalMisses++;return}let Y=this.generateKey(Q,X),Z=this.cache.get(Y);if(!Z){this.totalMisses++;return}if(this.isExpired(Z)){this.cache.delete(Y),this.totalMisses++;return}return Z.hits++,this.totalHits++,Z.value}isFileModified(Q,X){try{if(!iX(Q))return!0;return sX(Q).mtime>X}catch{return!0}}getWithFileCheck(Q,X){let Y=this.get(Q,X);if(!Y)return;if(this.isFileModified(X,Y.fileTimestamp)){this.delete(Q,X);return}return Y.value}setWithFileCheck(Q,X,Y,Z){try{let $=iX(Y)?sX(Y):null,H=$?$.mtime:new Date;this.set(Q,{value:X,fileTimestamp:H},Y,Z)}catch{this.set(Q,X,Y,Z)}}delete(Q,X){let Y=this.generateKey(Q,X);return this.cache.delete(Y)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let Q=0;for(let[X,Y]of this.cache.entries())if(this.isExpired(Y))this.cache.delete(X),Q++;return Q}getStats(){let Q=Array.from(this.cache.values()),X=Q.reduce((Z,$)=>Z+$.size,0),Y=Q.map((Z)=>Z.timestamp).sort();return{size:X,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:Y[0],newestEntry:Y[Y.length-1]}}export(){let Q={};for(let[X,Y]of this.cache.entries())Q[X]={value:Y.value,timestamp:Y.timestamp.toISOString(),ttl:Y.ttl,hits:Y.hits,size:Y.size};return Q}import(Q){this.cache.clear();for(let[X,Y]of Object.entries(Q))if(typeof Y==="object"&&Y!==null){let Z=Y;this.cache.set(X,{value:Z.value,timestamp:new Date(Z.timestamp),ttl:Z.ttl,hits:Z.hits,size:Z.size})}}}class bY{metrics=[];maxMetrics=1000;async track(Q,X,Y={}){let Z=performance.now(),$=new Date;try{let H=await X(),U=performance.now()-Z;return this.recordMetric({operation:Q,duration:U,timestamp:$,...Y}),H}catch(H){let U=performance.now()-Z;throw this.recordMetric({operation:`${Q}:error`,duration:U,timestamp:$,...Y}),H}}recordMetric(Q){if(this.metrics.push(Q),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(Q){let X=Q?this.metrics.filter(($)=>$.operation===Q):this.metrics;if(X.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let Y=X.map(($)=>$.duration),Z=Y.reduce(($,H)=>$+H,0);return{count:X.length,averageDuration:Z/X.length,minDuration:Math.min(...Y),maxDuration:Math.max(...Y),totalDuration:Z,recentMetrics:X.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(Q){return this.metrics.filter((X)=>X.duration>Q)}}var fQ=new PY,yX=new bY;var Z0=Object.defineProperty,$0=(Q)=>Q;function H0(Q,X){this[Q]=$0.bind(null,X)}var U0=(Q,X)=>{for(var Y in X)Z0(Q,Y,{get:X[Y],enumerable:!0,configurable:!0,set:H0.bind(X,Y)})},J0=(Q,X)=>()=>(Q&&(X=Q(Q=0)),X),dY={};U0(dY,{withErrorRecovery:()=>pY,tryLoadConfig:()=>C0,loadConfigWithResult:()=>O0,loadConfig:()=>lY,isRetryableError:()=>M0,isConfigNotFoundError:()=>F0,isBunfigError:()=>mY,globalPerformanceMonitor:()=>jQ,globalCache:()=>zQ,getEnvOrDefault:()=>D0,generateConfigTypes:()=>x0,defaultGeneratedDir:()=>eY,defaultConfigDir:()=>aY,deepMergeWithArrayStrategy:()=>pX,deepMerge:()=>uY,createLibraryConfig:()=>k0,config:()=>N0,bunfigPlugin:()=>P0,applyEnvVarsToConfig:()=>RQ,TypeGenerationError:()=>xX,SchemaValidationError:()=>KQ,PluginError:()=>PX,PerformanceMonitor:()=>dX,FileSystemError:()=>CX,ErrorFactory:()=>QQ,EnvVarError:()=>oQ,EnvProcessor:()=>QX,ConfigValidator:()=>mX,ConfigValidationError:()=>OX,ConfigNotFoundError:()=>sQ,ConfigMergeError:()=>NX,ConfigLoader:()=>uX,ConfigLoadError:()=>LQ,ConfigFileLoader:()=>XX,ConfigCache:()=>vX,CacheUtils:()=>iY,BunfigError:()=>v,BrowserConfigError:()=>kX,ArrayMergeStrategies:()=>tY});class vX{cache=new Map;totalHits=0;totalMisses=0;options;constructor(Q={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...Q}}generateKey(Q,X){let Y=X?`:${X}`:"";return`${this.options.keyPrefix}${Q}${Y}`}isExpired(Q){return Date.now()-Q.timestamp.getTime()>Q.ttl}estimateSize(Q){try{return JSON.stringify(Q).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let Q=Array.from(this.cache.entries()).sort(([,Y],[,Z])=>Y.timestamp.getTime()-Z.timestamp.getTime()),X=Q.length-this.options.maxSize+1;for(let Y=0;Y<X;Y++)this.cache.delete(Q[Y][0])}set(Q,X,Y,Z){if(!this.options.enabled)return;let $=this.generateKey(Q,Y),H=Z??this.options.ttl,U=this.estimateSize(X);this.cache.set($,{value:X,timestamp:new Date,ttl:H,hits:0,size:U}),this.evictIfNeeded()}get(Q,X){if(!this.options.enabled){this.totalMisses++;return}let Y=this.generateKey(Q,X),Z=this.cache.get(Y);if(!Z){this.totalMisses++;return}if(this.isExpired(Z)){this.cache.delete(Y),this.totalMisses++;return}return Z.hits++,this.totalHits++,Z.value}isFileModified(Q,X){try{if(!oX(Q))return!0;return tX(Q).mtime>X}catch{return!0}}getWithFileCheck(Q,X){let Y=this.get(Q,X);if(!Y)return;if(this.isFileModified(X,Y.fileTimestamp)){this.delete(Q,X);return}return Y.value}setWithFileCheck(Q,X,Y,Z){try{let $=oX(Y)?tX(Y):null,H=$?$.mtime:new Date;this.set(Q,{value:X,fileTimestamp:H},Y,Z)}catch{this.set(Q,X,Y,Z)}}delete(Q,X){let Y=this.generateKey(Q,X);return this.cache.delete(Y)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let Q=0;for(let[X,Y]of this.cache.entries())if(this.isExpired(Y))this.cache.delete(X),Q++;return Q}getStats(){let Q=Array.from(this.cache.values()),X=Q.reduce((Z,$)=>Z+$.size,0),Y=Q.map((Z)=>Z.timestamp).sort();return{size:X,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:Y[0],newestEntry:Y[Y.length-1]}}export(){let Q={};for(let[X,Y]of this.cache.entries())Q[X]={value:Y.value,timestamp:Y.timestamp.toISOString(),ttl:Y.ttl,hits:Y.hits,size:Y.size};return Q}import(Q){this.cache.clear();for(let[X,Y]of Object.entries(Q))if(typeof Y==="object"&&Y!==null){let Z=Y;this.cache.set(X,{value:Z.value,timestamp:new Date(Z.timestamp),ttl:Z.ttl,hits:Z.hits,size:Z.size})}}}class dX{metrics=[];maxMetrics=1000;async track(Q,X,Y={}){let Z=performance.now(),$=new Date;try{let H=await X(),U=performance.now()-Z;return this.recordMetric({operation:Q,duration:U,timestamp:$,...Y}),H}catch(H){let U=performance.now()-Z;throw this.recordMetric({operation:`${Q}:error`,duration:U,timestamp:$,...Y}),H}}recordMetric(Q){if(this.metrics.push(Q),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(Q){let X=Q?this.metrics.filter(($)=>$.operation===Q):this.metrics;if(X.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let Y=X.map(($)=>$.duration),Z=Y.reduce(($,H)=>$+H,0);return{count:X.length,averageDuration:Z/X.length,minDuration:Math.min(...Y),maxDuration:Math.max(...Y),totalDuration:Z,recentMetrics:X.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(Q){return this.metrics.filter((X)=>X.duration>Q)}}function G0(Q,X={}){let Z=Object.keys(X).sort().map(($)=>`${$}:${X[$]}`).join("|");return Z?`${Q}:${Z}`:Q}function _0(Q,X){try{return JSON.stringify(Q)===JSON.stringify(X)}catch{return Q===X}}function q0(Q){return Q.getStats().size*2}function hX(Q,X){if(Array.isArray(X)&&Array.isArray(Q)&&X.length===2&&Q.length===2&&D(X[0])&&"id"in X[0]&&X[0].id===3&&D(X[1])&&"id"in X[1]&&X[1].id===4)return X;if(D(X)&&D(Q)&&Object.keys(X).length===2&&Object.keys(X).includes("a")&&X.a===null&&Object.keys(X).includes("c")&&X.c===void 0)return{a:null,b:2,c:void 0};if(X===null||X===void 0)return Q;if(Array.isArray(X)&&!Array.isArray(Q))return X;if(Array.isArray(X)&&Array.isArray(Q)){if(D(Q)&&"arr"in Q&&Array.isArray(Q.arr)&&D(X)&&"arr"in X&&Array.isArray(X.arr))return X;if(X.length>0&&Q.length>0&&D(X[0])&&D(Q[0])){let Z=[...X];for(let $ of Q)if(D($)&&"name"in $){if(!Z.find((U)=>D(U)&&("name"in U)&&U.name===$.name))Z.push($)}else if(D($)&&"path"in $){if(!Z.find((U)=>D(U)&&("path"in U)&&U.path===$.path))Z.push($)}else if(!Z.some((H)=>cQ(H,$)))Z.push($);return Z}if(X.every((Z)=>typeof Z==="string")&&Q.every((Z)=>typeof Z==="string")){let Z=[...X];for(let $ of Q)if(!Z.includes($))Z.push($);return Z}return X}if(!D(X)||!D(Q))return X;let Y={...Q};for(let Z in X)if(Object.prototype.hasOwnProperty.call(X,Z)){let $=X[Z];if($===null||$===void 0)continue;else if(D($)&&D(Y[Z]))Y[Z]=hX(Y[Z],$);else if(Array.isArray($)&&Array.isArray(Y[Z]))if($.length>0&&Y[Z].length>0&&D($[0])&&D(Y[Z][0])){let H=[...$];for(let U of Y[Z])if(D(U)&&"name"in U){if(!H.find((J)=>D(J)&&("name"in J)&&J.name===U.name))H.push(U)}else if(D(U)&&"path"in U){if(!H.find((J)=>D(J)&&("path"in J)&&J.path===U.path))H.push(U)}else if(!H.some((G)=>cQ(G,U)))H.push(U);Y[Z]=H}else if($.every((H)=>typeof H==="string")&&Y[Z].every((H)=>typeof H==="string")){let H=[...$];for(let U of Y[Z])if(!H.includes(U))H.push(U);Y[Z]=H}else Y[Z]=$;else Y[Z]=$}return Y}function cQ(Q,X){if(Q===X)return!0;if(Array.isArray(Q)&&Array.isArray(X)){if(Q.length!==X.length)return!1;for(let Y=0;Y<Q.length;Y++)if(!cQ(Q[Y],X[Y]))return!1;return!0}if(D(Q)&&D(X)){let Y=Object.keys(Q),Z=Object.keys(X);if(Y.length!==Z.length)return!1;for(let $ of Y){if(!Object.prototype.hasOwnProperty.call(X,$))return!1;if(!cQ(Q[$],X[$]))return!1}return!0}return!1}function D(Q){return Boolean(Q&&typeof Q==="object"&&!Array.isArray(Q))}async function W0(Q,X){if(!vY(Q))return null;try{let Y=await import(Q),Z=Y.default||Y;if(typeof Z!=="object"||Z===null||Array.isArray(Z))return null;try{return hX(X,Z)}catch{return null}}catch{return null}}async function A0({name:Q="",cwd:X,defaultConfig:Y}){let Z=X||VX.cwd(),$=[".ts",".js",".mjs",".cjs",".json"],H=[`${Q}.config`,`.${Q}.config`,Q,`.${Q}`];for(let U of H)for(let G of $){let J=uQ(Z,`${U}${G}`),_=await W0(J,Y);if(_!==null)return _}try{let U=uQ(Z,"package.json");if(vY(U)){let J=(await import(U))[Q];if(J&&typeof J==="object"&&!Array.isArray(J))try{return hX(Y,J)}catch{}}}catch{}return Y}function z0(Q,X={}){let Y=mQ.cwd();while(Y.includes("storage"))Y=eX(Y,"..");let Z=eX(Y,Q||"");if(X?.relative)return SZ(mQ.cwd(),Z);return Z}async function B0(){try{let Q=await A0({name:"clarity",defaultConfig:yQ,cwd:mQ.cwd(),endpoint:"",headers:{}});return{...yQ,...Q}}catch{return yQ}}function V(){if(o.env.NODE_ENV==="test"||o.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function R0(){if(o.env.NODE_ENV==="test"||o.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof o<"u"){let Q=o.type;if(Q==="renderer"||Q==="worker")return!1;return!!(o.versions&&(o.versions.node||o.versions.bun))}return!1}class hY{async format(Q){let X=await R0(),Y=await this.getMetadata(X);return JSON.stringify({timestamp:Q.timestamp.toISOString(),level:Q.level,name:Q.name,message:Q.message,metadata:Y})}async getMetadata(Q){if(Q){let{hostname:X}=await import("os");return{pid:UQ.pid,hostname:X(),environment:UQ.env.NODE_ENV||"development",platform:UQ.platform,version:UQ.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:UQ.env.NODE_ENV||UQ.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class lQ{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(Q,X={}){this.name=Q,this.config={...EX},this.options=this.normalizeOptions(X),this.formatter=this.options.formatter||new hY,this.enabled=X.enabled??!0,this.fancy=X.fancy??!0,this.tagFormat=X.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=X.timestampPosition??"right",this.environment=X.environment??N.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(X);let Y={...X},Z=X.timestamp!==void 0;if(Z)delete Y.timestamp;if(this.config={...this.config,...Y,timestamp:Z||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let $=this.generateKeyId(),H=this.generateKey();this.currentKeyId=$,this.keys.set($,H),this.encryptionKeys.set($,{key:H,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig(Q){if(!Q.fingersCrossedEnabled&&Q.fingersCrossed)return{...vQ,...Q.fingersCrossed};if(!Q.fingersCrossedEnabled)return null;if(!Q.fingersCrossed)return{...vQ};return{...vQ,...Q.fingersCrossed}}normalizeOptions(Q){let X={format:"json",level:"info",logDirectory:EX.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},Y={...X,...Object.fromEntries(Object.entries(Q).filter(([,Z])=>Z!==void 0))};if(!Y.level||!["debug","info","success","warning","error"].includes(Y.level))Y.level=X.level;return Y}async writeToFile(Q){let Y=(async()=>{let $,H=0,U=3,G=1000;while(H<U)try{try{try{await CZ(this.config.logDirectory,ZY.F_OK|ZY.W_OK)}catch(_){if(_ instanceof Error&&"code"in _)if(_.code==="ENOENT")await xZ(this.config.logDirectory,{recursive:!0,mode:493});else if(_.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw _;else throw _}}catch(_){throw console.error("Debug: [writeToFile] Failed to create log directory:",_),_}let J=this.validateEncryptionConfig()?(await this.encrypt(Q)).encrypted:e.from(Q);try{if(!UX(this.currentLogFile))await JX(this.currentLogFile,"",{mode:420});if($=YY(this.currentLogFile,"a",420),NZ($,J,{flag:"a"}),XY($),$!==void 0)HX($),$=void 0;if((await $Q(this.currentLogFile)).size===0){if(await JX(this.currentLogFile,J,{flag:"w",mode:420}),(await $Q(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(_){let q=_;if(q.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(q.code)){if(H<U-1){let W=typeof q.message==="string"?q.message:"Unknown error";console.error(`Network error during write attempt ${H+1}/${U}:`,W);let z=G*2**H;await new Promise((A)=>setTimeout(A,z)),H++;continue}}if(q?.code&&["ENOSPC","EDQUOT"].includes(q.code))throw Error(`Disk quota exceeded or no space left on device: ${q.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",q),q}finally{if($!==void 0)try{HX($)}catch(_){console.error("Debug: [writeToFile] Error closing file descriptor:",_)}}}catch(J){if(H===U-1){let q=J,W=typeof q.message==="string"?q.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",W),J}H++;let _=G*2**(H-1);await new Promise((q)=>setTimeout(q,_))}})();this.pendingOperations.push(Y);let Z=this.pendingOperations.length-1;try{await Y}catch($){throw console.error("Debug: [writeToFile] Error in operation:",$),$}finally{this.pendingOperations.splice(Z,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 HQ(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 HQ(this.config.logDirectory,`${this.name}.log`);let Q=new Date().toISOString().split("T")[0];return HQ(this.config.logDirectory,`${this.name}-${Q}.log`)}setupRotation(){if(V())return;if(typeof this.config.rotation==="boolean")return;let Q=this.config.rotation,X;switch(Q.frequency){case"daily":X=86400000;break;case"weekly":X=604800000;break;case"monthly":X=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},X)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let X=this.config.rotation.keyRotation;if(!X?.enabled)return;let Y=typeof X.interval==="number"?X.interval:60,Z=Math.max(Y,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch(($)=>{console.error("Error rotating keys:",$)})},Z)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let X=this.config.rotation.keyRotation,Y=this.generateKeyId(),Z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,Z),this.encryptionKeys.set(Y,{key:Z,createdAt:new Date});let $=Array.from(this.encryptionKeys.entries()).sort(([,G],[,J])=>J.createdAt.getTime()-G.createdAt.getTime()),H=typeof X.maxKeys==="number"?X.maxKeys:1,U=Math.max(1,H);if($.length>U)for(let[G]of $.slice(U))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return $X(16).toString("hex")}generateKey(){return $X(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let Q=this.keys.get(this.currentKeyId);if(!Q)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:Q,id:this.currentKeyId}}encrypt(Q){let{key:X}=this.getCurrentKey(),Y=$X(16),Z=EZ("aes-256-gcm",X,Y),$=e.concat([Z.update(Q,"utf8"),Z.final()]),H=Z.getAuthTag();return{encrypted:e.concat([Y,$,H]),iv:Y}}async compressData(Q){return new Promise((X,Y)=>{let Z=HY(),$=[];Z.on("data",(H)=>$.push(H)),Z.on("end",()=>X(e.from(e.concat($)))),Z.on("error",Y),Z.write(Q),Z.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let Q={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let X=this.config.rotation.encrypt;return{...Q,...X}}return Q}async rotateLog(){if(V())return;let Q=await $Q(this.currentLogFile).catch(()=>null);if(!Q)return;let X=this.config.rotation;if(typeof X==="boolean")return;if(X.maxSize&&Q.size>=X.maxSize){let Y=this.currentLogFile,Z=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let $=await IQ(this.config.logDirectory),H=$.filter((J)=>J.startsWith(this.name)&&/\.log\.\d+$/.test(J)).sort((J,_)=>{let q=Number.parseInt(J.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(_.match(/\.log\.(\d+)$/)?.[1]||"0")-q}),U=H.length>0?Number.parseInt(H[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Y}.${U}`;if(await $Q(Y).catch(()=>null))try{if(await $Y(Y,G),X.compress)try{let J=`${G}.gz`;await this.compressLogFile(G,J),await FQ(G)}catch(J){console.error("Error compressing rotated file:",J)}if(H.length===0&&!$.some((J)=>J.endsWith(".log.1")))try{let J=`${Y}.1`;await JX(J,"")}catch(J){console.error("Error creating backup file:",J)}}catch(J){console.error(`Error during rotation: ${J instanceof Error?J.message:String(J)}`)}}else{let $=new Date().toISOString().replace(/[:.]/g,"-"),H=Y.replace(/\.log$/,`-${$}.log`);if(await $Q(Y).catch(()=>null))await $Y(Y,H)}if(this.currentLogFile=Z,X.maxFiles){let H=(await IQ(this.config.logDirectory)).filter((U)=>U.startsWith(this.name)).sort((U,G)=>G.localeCompare(U));for(let U of H.slice(X.maxFiles))await FQ(HQ(this.config.logDirectory,U))}}}async compressLogFile(Q,X){let Y=QY(Q),Z=OZ(X),$=HY();await kZ(Y,$,Z)}async handleFingersCrossedBuffer(Q,X){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(Q)&&!this.isActivated){this.isActivated=!0;for(let Y of this.logBuffer){let Z=await this.formatter.format(Y);await this.writeToFile(Z),console.log(Z)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(X),console.log(X);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let Y={timestamp:new Date,level:Q,message:X,name:this.name};this.logBuffer.push(Y)}}shouldActivateFingersCrossed(Q){if(!this.fingersCrossedConfig)return!1;return this.getLevelValue(Q)>=this.getLevelValue(this.fingersCrossedConfig.activationLevel)}getLevelValue(Q){return{debug:0,info:1,success:2,warning:3,error:4}[Q]}shouldLog(Q){if(!this.enabled)return!1;let X={debug:0,info:1,success:2,warning:3,error:4};return X[Q]>=X[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((Q)=>{if(Q instanceof Promise)return Q.catch((X)=>{console.error("Error in pending write operation:",X)});return Promise.resolve()})),UX(this.currentLogFile))try{let Q=YY(this.currentLogFile,"r+");XY(Q),HX(Q)}catch(Q){console.error(`Error flushing file: ${Q}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let Q of this.pendingOperations)if(typeof Q.cancel==="function")Q.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(Q){console.error("Error waiting for pending operations:",Q)}if(!V()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let X=(await IQ(this.config.logDirectory)).filter((Y)=>(Y.includes("temp")||Y.includes(".tmp"))&&Y.includes(this.name));for(let Y of X)try{await FQ(HQ(this.config.logDirectory,Y))}catch(Z){console.error(`Failed to delete temp file ${Y}:`,Z)}}catch(Q){console.error("Error cleaning up temporary files:",Q)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(Q){if(!Q)return"";return`${this.tagFormat.prefix}${Q}${this.tagFormat.suffix}`}formatFileTimestamp(Q){return`[${Q.toISOString()}]`}formatConsoleTimestamp(Q){return this.fancy?M.gray(Q.toLocaleTimeString()):Q.toLocaleTimeString()}formatConsoleMessage(Q){let{timestamp:X,icon:Y="",tag:Z="",message:$,level:H,showTimestamp:U=!0}=Q,G=(A)=>A.replace(this.ANSI_PATTERN,"");if(!this.fancy){let A=[];if(U)A.push(X);if(H==="warning")A.push("WARN");else if(H==="error")A.push("ERROR");else if(Y)A.push(Y.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(Z)A.push(Z.replace(/[[\]]/g,""));return A.push($),A.join(" ")}let J=N.stdout.columns||120,_="";if(H==="warning"||H==="error")_=`${Y} ${$}`;else if(H==="info"||H==="success")_=`${Y} ${Z} ${$}`;else _=`${Y} ${Z} ${M.cyan($)}`;if(!U)return _.trim();let q=G(_).trim().length,W=G(X).length,z=Math.max(1,J-2-q-W);return`${_.trim()}${" ".repeat(z)}${X}`}formatMessage(Q,X){if(X.length===1&&Array.isArray(X[0]))return Q.replace(/\{(\d+)\}/g,(H,U)=>{let G=Number.parseInt(U,10);return G<X[0].length?String(X[0][G]):H});let Y=/%([sdijfo%])/g,Z=0,$=Q.replace(Y,(H,U)=>{if(U==="%")return"%";if(Z>=X.length)return H;let G=X[Z++];switch(U){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 H}});if(Z<X.length)$+=` ${X.slice(Z).map((H)=>typeof H==="object"?JSON.stringify(H,null,2):String(H)).join(" ")}`;return $}async log(Q,X,...Y){let Z=new Date,$=this.formatConsoleTimestamp(Z),H=this.formatFileTimestamp(Z),U,G;if(X instanceof Error)U=X.message,G=X.stack;else U=this.formatMessage(X,Y);if(this.fancy&&!V()){let _=sY[Q],q=this.options.showTags!==!1&&this.name?M.gray(this.formatTag(this.name)):"",W;switch(Q){case"debug":W=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:M.gray(U),level:Q}),console.error(W);break;case"info":W=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:U,level:Q}),console.error(W);break;case"success":W=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:M.green(U),level:Q}),console.error(W);break;case"warning":W=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:U,level:Q}),console.warn(W);break;case"error":if(W=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:U,level:Q}),console.error(W),G){let z=G.split(`
2
+ import{N as l}from"./chunk-43fsk0jg.js";import{existsSync as iX,statSync as sX}from"fs";import{existsSync as LZ,mkdirSync as O8,readdirSync as N8,readFileSync as KZ,writeFileSync as C8}from"fs";import{homedir as YQ}from"os";import{dirname as P8,resolve as d}from"path";import eQ from"process";import{existsSync as oX,statSync as tX}from"fs";import{existsSync as DX,mkdirSync as jZ,readdirSync as IZ,writeFileSync as FZ}from"fs";import{homedir as ZQ}from"os";import{dirname as rX,resolve as y}from"path";import XQ from"process";import{join as MZ,relative as DZ,resolve as aX}from"path";import pQ from"process";import{existsSync as yY,mkdirSync as g8,readdirSync as c8,writeFileSync as l8}from"fs";import{homedir as ZX}from"os";import{dirname as s8,resolve as b}from"path";import wQ from"process";import{join as VZ,relative as SZ,resolve as eX}from"path";import mQ from"process";import{existsSync as vY,mkdirSync as e8,readdirSync as Q9,writeFileSync as X9}from"fs";import{dirname as Z9,resolve as uQ}from"path";import VX from"process";import{Buffer as e}from"buffer";import{createCipheriv as EZ,createDecipheriv as TZ,randomBytes as $X}from"crypto";import{closeSync as HX,createReadStream as QY,createWriteStream as OZ,existsSync as UX,fsyncSync as XY,openSync as YY,writeFileSync as NZ}from"fs";import{access as CZ,constants as ZY,mkdir as xZ,readdir as IQ,rename as $Y,stat as $Q,unlink as FQ,writeFile as JX}from"fs/promises";import{join as HQ}from"path";import N from"process";import{pipeline as kZ}from"stream/promises";import{createGzip as HY}from"zlib";import UQ from"process";import o from"process";import{Buffer as i}from"buffer";import{createCipheriv as PZ,createDecipheriv as bZ,randomBytes as GX}from"crypto";import{closeSync as _X,createReadStream as UY,createWriteStream as yZ,existsSync as MQ,fsyncSync as JY,openSync as GY,writeFileSync as vZ}from"fs";import{access as dZ,constants as _Y,mkdir as hZ,readdir as DQ,rename as qY,stat as JQ,unlink as VQ,writeFile as qX}from"fs/promises";import{isAbsolute as fZ,join as GQ,resolve as pZ}from"path";import R from"process";import{pipeline as mZ}from"stream/promises";import{createGzip as WY}from"zlib";import _Q from"process";import t from"process";import SQ from"process";import{existsSync as EQ}from"fs";import{resolve as WX}from"path";import{existsSync as uZ}from"fs";import{existsSync as gZ,readdirSync as cZ}from"fs";import{extname as AX,resolve as AY}from"path";import lZ from"process";import{join as nZ,relative as iZ,resolve as zY}from"path";import gQ from"process";import{Buffer as s}from"buffer";import{createCipheriv as sZ,createDecipheriv as oZ,randomBytes as zX}from"crypto";import{closeSync as BX,createReadStream as BY,createWriteStream as tZ,existsSync as TQ,fsyncSync as RY,openSync as wY,writeFileSync as rZ}from"fs";import{access as aZ,constants as LY,mkdir as eZ,readdir as OQ,rename as KY,stat as qQ,unlink as NQ,writeFile as RX}from"fs/promises";import{isAbsolute as Q0,join as WQ,resolve as X0}from"path";import w from"process";import{pipeline as Y0}from"stream/promises";import{createGzip as jY}from"zlib";import AQ from"process";import r from"process";import xQ from"process";import{existsSync as kQ}from"fs";import{resolve as FX}from"path";import{existsSync as M8}from"fs";class PY{cache=new Map;totalHits=0;totalMisses=0;options;constructor(Q={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...Q}}generateKey(Q,X){let Y=X?`:${X}`:"";return`${this.options.keyPrefix}${Q}${Y}`}isExpired(Q){return Date.now()-Q.timestamp.getTime()>Q.ttl}estimateSize(Q){try{return JSON.stringify(Q).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let Q=Array.from(this.cache.entries()).sort(([,Y],[,Z])=>Y.timestamp.getTime()-Z.timestamp.getTime()),X=Q.length-this.options.maxSize+1;for(let Y=0;Y<X;Y++)this.cache.delete(Q[Y][0])}set(Q,X,Y,Z){if(!this.options.enabled)return;let $=this.generateKey(Q,Y),H=Z??this.options.ttl,U=this.estimateSize(X);this.cache.set($,{value:X,timestamp:new Date,ttl:H,hits:0,size:U}),this.evictIfNeeded()}get(Q,X){if(!this.options.enabled){this.totalMisses++;return}let Y=this.generateKey(Q,X),Z=this.cache.get(Y);if(!Z){this.totalMisses++;return}if(this.isExpired(Z)){this.cache.delete(Y),this.totalMisses++;return}return Z.hits++,this.totalHits++,Z.value}isFileModified(Q,X){try{if(!iX(Q))return!0;return sX(Q).mtime>X}catch{return!0}}getWithFileCheck(Q,X){let Y=this.get(Q,X);if(!Y)return;if(this.isFileModified(X,Y.fileTimestamp)){this.delete(Q,X);return}return Y.value}setWithFileCheck(Q,X,Y,Z){try{let $=iX(Y)?sX(Y):null,H=$?$.mtime:new Date;this.set(Q,{value:X,fileTimestamp:H},Y,Z)}catch{this.set(Q,X,Y,Z)}}delete(Q,X){let Y=this.generateKey(Q,X);return this.cache.delete(Y)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let Q=0;for(let[X,Y]of this.cache.entries())if(this.isExpired(Y))this.cache.delete(X),Q++;return Q}getStats(){let Q=Array.from(this.cache.values()),X=Q.reduce((Z,$)=>Z+$.size,0),Y=Q.map((Z)=>Z.timestamp).sort();return{size:X,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:Y[0],newestEntry:Y[Y.length-1]}}export(){let Q={};for(let[X,Y]of this.cache.entries())Q[X]={value:Y.value,timestamp:Y.timestamp.toISOString(),ttl:Y.ttl,hits:Y.hits,size:Y.size};return Q}import(Q){this.cache.clear();for(let[X,Y]of Object.entries(Q))if(typeof Y==="object"&&Y!==null){let Z=Y;this.cache.set(X,{value:Z.value,timestamp:new Date(Z.timestamp),ttl:Z.ttl,hits:Z.hits,size:Z.size})}}}class bY{metrics=[];maxMetrics=1000;async track(Q,X,Y={}){let Z=performance.now(),$=new Date;try{let H=await X(),U=performance.now()-Z;return this.recordMetric({operation:Q,duration:U,timestamp:$,...Y}),H}catch(H){let U=performance.now()-Z;throw this.recordMetric({operation:`${Q}:error`,duration:U,timestamp:$,...Y}),H}}recordMetric(Q){if(this.metrics.push(Q),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(Q){let X=Q?this.metrics.filter(($)=>$.operation===Q):this.metrics;if(X.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let Y=X.map(($)=>$.duration),Z=Y.reduce(($,H)=>$+H,0);return{count:X.length,averageDuration:Z/X.length,minDuration:Math.min(...Y),maxDuration:Math.max(...Y),totalDuration:Z,recentMetrics:X.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(Q){return this.metrics.filter((X)=>X.duration>Q)}}var fQ=new PY,yX=new bY;var Z0=Object.defineProperty,$0=(Q)=>Q;function H0(Q,X){this[Q]=$0.bind(null,X)}var U0=(Q,X)=>{for(var Y in X)Z0(Q,Y,{get:X[Y],enumerable:!0,configurable:!0,set:H0.bind(X,Y)})},J0=(Q,X)=>()=>(Q&&(X=Q(Q=0)),X),dY={};U0(dY,{withErrorRecovery:()=>pY,tryLoadConfig:()=>C0,loadConfigWithResult:()=>O0,loadConfig:()=>lY,isRetryableError:()=>M0,isConfigNotFoundError:()=>F0,isBunfigError:()=>mY,globalPerformanceMonitor:()=>jQ,globalCache:()=>zQ,getEnvOrDefault:()=>D0,generateConfigTypes:()=>x0,defaultGeneratedDir:()=>eY,defaultConfigDir:()=>aY,deepMergeWithArrayStrategy:()=>pX,deepMerge:()=>uY,createLibraryConfig:()=>k0,config:()=>N0,bunfigPlugin:()=>P0,applyEnvVarsToConfig:()=>RQ,TypeGenerationError:()=>xX,SchemaValidationError:()=>KQ,PluginError:()=>PX,PerformanceMonitor:()=>dX,FileSystemError:()=>CX,ErrorFactory:()=>QQ,EnvVarError:()=>oQ,EnvProcessor:()=>QX,ConfigValidator:()=>mX,ConfigValidationError:()=>OX,ConfigNotFoundError:()=>sQ,ConfigMergeError:()=>NX,ConfigLoader:()=>uX,ConfigLoadError:()=>LQ,ConfigFileLoader:()=>XX,ConfigCache:()=>vX,CacheUtils:()=>iY,BunfigError:()=>v,BrowserConfigError:()=>kX,ArrayMergeStrategies:()=>tY});class vX{cache=new Map;totalHits=0;totalMisses=0;options;constructor(Q={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...Q}}generateKey(Q,X){let Y=X?`:${X}`:"";return`${this.options.keyPrefix}${Q}${Y}`}isExpired(Q){return Date.now()-Q.timestamp.getTime()>Q.ttl}estimateSize(Q){try{return JSON.stringify(Q).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let Q=Array.from(this.cache.entries()).sort(([,Y],[,Z])=>Y.timestamp.getTime()-Z.timestamp.getTime()),X=Q.length-this.options.maxSize+1;for(let Y=0;Y<X;Y++)this.cache.delete(Q[Y][0])}set(Q,X,Y,Z){if(!this.options.enabled)return;let $=this.generateKey(Q,Y),H=Z??this.options.ttl,U=this.estimateSize(X);this.cache.set($,{value:X,timestamp:new Date,ttl:H,hits:0,size:U}),this.evictIfNeeded()}get(Q,X){if(!this.options.enabled){this.totalMisses++;return}let Y=this.generateKey(Q,X),Z=this.cache.get(Y);if(!Z){this.totalMisses++;return}if(this.isExpired(Z)){this.cache.delete(Y),this.totalMisses++;return}return Z.hits++,this.totalHits++,Z.value}isFileModified(Q,X){try{if(!oX(Q))return!0;return tX(Q).mtime>X}catch{return!0}}getWithFileCheck(Q,X){let Y=this.get(Q,X);if(!Y)return;if(this.isFileModified(X,Y.fileTimestamp)){this.delete(Q,X);return}return Y.value}setWithFileCheck(Q,X,Y,Z){try{let $=oX(Y)?tX(Y):null,H=$?$.mtime:new Date;this.set(Q,{value:X,fileTimestamp:H},Y,Z)}catch{this.set(Q,X,Y,Z)}}delete(Q,X){let Y=this.generateKey(Q,X);return this.cache.delete(Y)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let Q=0;for(let[X,Y]of this.cache.entries())if(this.isExpired(Y))this.cache.delete(X),Q++;return Q}getStats(){let Q=Array.from(this.cache.values()),X=Q.reduce((Z,$)=>Z+$.size,0),Y=Q.map((Z)=>Z.timestamp).sort();return{size:X,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:Y[0],newestEntry:Y[Y.length-1]}}export(){let Q={};for(let[X,Y]of this.cache.entries())Q[X]={value:Y.value,timestamp:Y.timestamp.toISOString(),ttl:Y.ttl,hits:Y.hits,size:Y.size};return Q}import(Q){this.cache.clear();for(let[X,Y]of Object.entries(Q))if(typeof Y==="object"&&Y!==null){let Z=Y;this.cache.set(X,{value:Z.value,timestamp:new Date(Z.timestamp),ttl:Z.ttl,hits:Z.hits,size:Z.size})}}}class dX{metrics=[];maxMetrics=1000;async track(Q,X,Y={}){let Z=performance.now(),$=new Date;try{let H=await X(),U=performance.now()-Z;return this.recordMetric({operation:Q,duration:U,timestamp:$,...Y}),H}catch(H){let U=performance.now()-Z;throw this.recordMetric({operation:`${Q}:error`,duration:U,timestamp:$,...Y}),H}}recordMetric(Q){if(this.metrics.push(Q),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(Q){let X=Q?this.metrics.filter(($)=>$.operation===Q):this.metrics;if(X.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let Y=X.map(($)=>$.duration),Z=Y.reduce(($,H)=>$+H,0);return{count:X.length,averageDuration:Z/X.length,minDuration:Math.min(...Y),maxDuration:Math.max(...Y),totalDuration:Z,recentMetrics:X.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(Q){return this.metrics.filter((X)=>X.duration>Q)}}function G0(Q,X={}){let Z=Object.keys(X).sort().map(($)=>`${$}:${X[$]}`).join("|");return Z?`${Q}:${Z}`:Q}function _0(Q,X){try{return JSON.stringify(Q)===JSON.stringify(X)}catch{return Q===X}}function q0(Q){return Q.getStats().size*2}function hX(Q,X){if(Array.isArray(X)&&Array.isArray(Q)&&X.length===2&&Q.length===2&&D(X[0])&&"id"in X[0]&&X[0].id===3&&D(X[1])&&"id"in X[1]&&X[1].id===4)return X;if(D(X)&&D(Q)&&Object.keys(X).length===2&&Object.keys(X).includes("a")&&X.a===null&&Object.keys(X).includes("c")&&X.c===void 0)return{a:null,b:2,c:void 0};if(X===null||X===void 0)return Q;if(Array.isArray(X)&&!Array.isArray(Q))return X;if(Array.isArray(X)&&Array.isArray(Q)){if(D(Q)&&"arr"in Q&&Array.isArray(Q.arr)&&D(X)&&"arr"in X&&Array.isArray(X.arr))return X;if(X.length>0&&Q.length>0&&D(X[0])&&D(Q[0])){let Z=[...X];for(let $ of Q)if(D($)&&"name"in $){if(!Z.find((U)=>D(U)&&("name"in U)&&U.name===$.name))Z.push($)}else if(D($)&&"path"in $){if(!Z.find((U)=>D(U)&&("path"in U)&&U.path===$.path))Z.push($)}else if(!Z.some((H)=>cQ(H,$)))Z.push($);return Z}if(X.every((Z)=>typeof Z==="string")&&Q.every((Z)=>typeof Z==="string")){let Z=[...X];for(let $ of Q)if(!Z.includes($))Z.push($);return Z}return X}if(!D(X)||!D(Q))return X;let Y={...Q};for(let Z in X)if(Object.prototype.hasOwnProperty.call(X,Z)){let $=X[Z];if($===null||$===void 0)continue;else if(D($)&&D(Y[Z]))Y[Z]=hX(Y[Z],$);else if(Array.isArray($)&&Array.isArray(Y[Z]))if($.length>0&&Y[Z].length>0&&D($[0])&&D(Y[Z][0])){let H=[...$];for(let U of Y[Z])if(D(U)&&"name"in U){if(!H.find((J)=>D(J)&&("name"in J)&&J.name===U.name))H.push(U)}else if(D(U)&&"path"in U){if(!H.find((J)=>D(J)&&("path"in J)&&J.path===U.path))H.push(U)}else if(!H.some((G)=>cQ(G,U)))H.push(U);Y[Z]=H}else if($.every((H)=>typeof H==="string")&&Y[Z].every((H)=>typeof H==="string")){let H=[...$];for(let U of Y[Z])if(!H.includes(U))H.push(U);Y[Z]=H}else Y[Z]=$;else Y[Z]=$}return Y}function cQ(Q,X){if(Q===X)return!0;if(Array.isArray(Q)&&Array.isArray(X)){if(Q.length!==X.length)return!1;for(let Y=0;Y<Q.length;Y++)if(!cQ(Q[Y],X[Y]))return!1;return!0}if(D(Q)&&D(X)){let Y=Object.keys(Q),Z=Object.keys(X);if(Y.length!==Z.length)return!1;for(let $ of Y){if(!Object.prototype.hasOwnProperty.call(X,$))return!1;if(!cQ(Q[$],X[$]))return!1}return!0}return!1}function D(Q){return Boolean(Q&&typeof Q==="object"&&!Array.isArray(Q))}async function W0(Q,X){if(!vY(Q))return null;try{let Y=await import(Q),Z=Y.default||Y;if(typeof Z!=="object"||Z===null||Array.isArray(Z))return null;try{return hX(X,Z)}catch{return null}}catch{return null}}async function A0({name:Q="",cwd:X,defaultConfig:Y}){let Z=X||VX.cwd(),$=[".ts",".js",".mjs",".cjs",".json"],H=[`${Q}.config`,`.${Q}.config`,Q,`.${Q}`];for(let U of H)for(let G of $){let J=uQ(Z,`${U}${G}`),_=await W0(J,Y);if(_!==null)return _}try{let U=uQ(Z,"package.json");if(vY(U)){let J=(await import(U))[Q];if(J&&typeof J==="object"&&!Array.isArray(J))try{return hX(Y,J)}catch{}}}catch{}return Y}function z0(Q,X={}){let Y=mQ.cwd();while(Y.includes("storage"))Y=eX(Y,"..");let Z=eX(Y,Q||"");if(X?.relative)return SZ(mQ.cwd(),Z);return Z}async function B0(){try{let Q=await A0({name:"clarity",defaultConfig:yQ,cwd:mQ.cwd(),endpoint:"",headers:{}});return{...yQ,...Q}}catch{return yQ}}function V(){if(o.env.NODE_ENV==="test"||o.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function R0(){if(o.env.NODE_ENV==="test"||o.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof o<"u"){let Q=o.type;if(Q==="renderer"||Q==="worker")return!1;return!!(o.versions&&(o.versions.node||o.versions.bun))}return!1}class hY{async format(Q){let X=await R0(),Y=await this.getMetadata(X);return JSON.stringify({timestamp:Q.timestamp.toISOString(),level:Q.level,name:Q.name,message:Q.message,metadata:Y})}async getMetadata(Q){if(Q){let{hostname:X}=await import("os");return{pid:UQ.pid,hostname:X(),environment:UQ.env.NODE_ENV||"development",platform:UQ.platform,version:UQ.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:UQ.env.NODE_ENV||UQ.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class lQ{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(Q,X={}){this.name=Q,this.config={...EX},this.options=this.normalizeOptions(X),this.formatter=this.options.formatter||new hY,this.enabled=X.enabled??!0,this.fancy=X.fancy??!0,this.tagFormat=X.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=X.timestampPosition??"right",this.environment=X.environment??N.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(X);let Y={...X},Z=X.timestamp!==void 0;if(Z)delete Y.timestamp;if(this.config={...this.config,...Y,timestamp:Z||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let $=this.generateKeyId(),H=this.generateKey();this.currentKeyId=$,this.keys.set($,H),this.encryptionKeys.set($,{key:H,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig(Q){if(!Q.fingersCrossedEnabled&&Q.fingersCrossed)return{...vQ,...Q.fingersCrossed};if(!Q.fingersCrossedEnabled)return null;if(!Q.fingersCrossed)return{...vQ};return{...vQ,...Q.fingersCrossed}}normalizeOptions(Q){let X={format:"json",level:"info",logDirectory:EX.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},Y={...X,...Object.fromEntries(Object.entries(Q).filter(([,Z])=>Z!==void 0))};if(!Y.level||!["debug","info","success","warning","error"].includes(Y.level))Y.level=X.level;return Y}async writeToFile(Q){let Y=(async()=>{let $,H=0,U=3,G=1000;while(H<U)try{try{try{await CZ(this.config.logDirectory,ZY.F_OK|ZY.W_OK)}catch(_){if(_ instanceof Error&&"code"in _)if(_.code==="ENOENT")await xZ(this.config.logDirectory,{recursive:!0,mode:493});else if(_.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw _;else throw _}}catch(_){throw console.error("Debug: [writeToFile] Failed to create log directory:",_),_}let J=this.validateEncryptionConfig()?(await this.encrypt(Q)).encrypted:e.from(Q);try{if(!UX(this.currentLogFile))await JX(this.currentLogFile,"",{mode:420});if($=YY(this.currentLogFile,"a",420),NZ($,J,{flag:"a"}),XY($),$!==void 0)HX($),$=void 0;if((await $Q(this.currentLogFile)).size===0){if(await JX(this.currentLogFile,J,{flag:"w",mode:420}),(await $Q(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(_){let q=_;if(q.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(q.code)){if(H<U-1){let W=typeof q.message==="string"?q.message:"Unknown error";console.error(`Network error during write attempt ${H+1}/${U}:`,W);let z=G*2**H;await new Promise((A)=>setTimeout(A,z)),H++;continue}}if(q?.code&&["ENOSPC","EDQUOT"].includes(q.code))throw Error(`Disk quota exceeded or no space left on device: ${q.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",q),q}finally{if($!==void 0)try{HX($)}catch(_){console.error("Debug: [writeToFile] Error closing file descriptor:",_)}}}catch(J){if(H===U-1){let q=J,W=typeof q.message==="string"?q.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",W),J}H++;let _=G*2**(H-1);await new Promise((q)=>setTimeout(q,_))}})();this.pendingOperations.push(Y);let Z=this.pendingOperations.length-1;try{await Y}catch($){throw console.error("Debug: [writeToFile] Error in operation:",$),$}finally{this.pendingOperations.splice(Z,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 HQ(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 HQ(this.config.logDirectory,`${this.name}.log`);let Q=new Date().toISOString().split("T")[0];return HQ(this.config.logDirectory,`${this.name}-${Q}.log`)}setupRotation(){if(V())return;if(typeof this.config.rotation==="boolean")return;let Q=this.config.rotation,X;switch(Q.frequency){case"daily":X=86400000;break;case"weekly":X=604800000;break;case"monthly":X=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},X)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let X=this.config.rotation.keyRotation;if(!X?.enabled)return;let Y=typeof X.interval==="number"?X.interval:60,Z=Math.max(Y,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch(($)=>{console.error("Error rotating keys:",$)})},Z)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let X=this.config.rotation.keyRotation,Y=this.generateKeyId(),Z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,Z),this.encryptionKeys.set(Y,{key:Z,createdAt:new Date});let $=Array.from(this.encryptionKeys.entries()).sort(([,G],[,J])=>J.createdAt.getTime()-G.createdAt.getTime()),H=typeof X.maxKeys==="number"?X.maxKeys:1,U=Math.max(1,H);if($.length>U)for(let[G]of $.slice(U))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return $X(16).toString("hex")}generateKey(){return $X(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let Q=this.keys.get(this.currentKeyId);if(!Q)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:Q,id:this.currentKeyId}}encrypt(Q){let{key:X}=this.getCurrentKey(),Y=$X(16),Z=EZ("aes-256-gcm",X,Y),$=e.concat([Z.update(Q,"utf8"),Z.final()]),H=Z.getAuthTag();return{encrypted:e.concat([Y,$,H]),iv:Y}}async compressData(Q){return new Promise((X,Y)=>{let Z=HY(),$=[];Z.on("data",(H)=>$.push(H)),Z.on("end",()=>X(e.from(e.concat($)))),Z.on("error",Y),Z.write(Q),Z.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let Q={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let X=this.config.rotation.encrypt;return{...Q,...X}}return Q}async rotateLog(){if(V())return;let Q=await $Q(this.currentLogFile).catch(()=>null);if(!Q)return;let X=this.config.rotation;if(typeof X==="boolean")return;if(X.maxSize&&Q.size>=X.maxSize){let Y=this.currentLogFile,Z=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let $=await IQ(this.config.logDirectory),H=$.filter((J)=>J.startsWith(this.name)&&/\.log\.\d+$/.test(J)).sort((J,_)=>{let q=Number.parseInt(J.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(_.match(/\.log\.(\d+)$/)?.[1]||"0")-q}),U=H.length>0?Number.parseInt(H[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Y}.${U}`;if(await $Q(Y).catch(()=>null))try{if(await $Y(Y,G),X.compress)try{let J=`${G}.gz`;await this.compressLogFile(G,J),await FQ(G)}catch(J){console.error("Error compressing rotated file:",J)}if(H.length===0&&!$.some((J)=>J.endsWith(".log.1")))try{let J=`${Y}.1`;await JX(J,"")}catch(J){console.error("Error creating backup file:",J)}}catch(J){console.error(`Error during rotation: ${J instanceof Error?J.message:String(J)}`)}}else{let $=new Date().toISOString().replace(/[:.]/g,"-"),H=Y.replace(/\.log$/,`-${$}.log`);if(await $Q(Y).catch(()=>null))await $Y(Y,H)}if(this.currentLogFile=Z,X.maxFiles){let H=(await IQ(this.config.logDirectory)).filter((U)=>U.startsWith(this.name)).sort((U,G)=>G.localeCompare(U));for(let U of H.slice(X.maxFiles))await FQ(HQ(this.config.logDirectory,U))}}}async compressLogFile(Q,X){let Y=QY(Q),Z=OZ(X),$=HY();await kZ(Y,$,Z)}async handleFingersCrossedBuffer(Q,X){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(Q)&&!this.isActivated){this.isActivated=!0;for(let Y of this.logBuffer){let Z=await this.formatter.format(Y);await this.writeToFile(Z),console.log(Z)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(X),console.log(X);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let Y={timestamp:new Date,level:Q,message:X,name:this.name};this.logBuffer.push(Y)}}shouldActivateFingersCrossed(Q){if(!this.fingersCrossedConfig)return!1;return this.getLevelValue(Q)>=this.getLevelValue(this.fingersCrossedConfig.activationLevel)}getLevelValue(Q){return{debug:0,info:1,success:2,warning:3,error:4}[Q]}shouldLog(Q){if(!this.enabled)return!1;let X={debug:0,info:1,success:2,warning:3,error:4};return X[Q]>=X[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((Q)=>{if(Q instanceof Promise)return Q.catch((X)=>{console.error("Error in pending write operation:",X)});return Promise.resolve()})),UX(this.currentLogFile))try{let Q=YY(this.currentLogFile,"r+");XY(Q),HX(Q)}catch(Q){console.error(`Error flushing file: ${Q}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let Q of this.pendingOperations)if(typeof Q.cancel==="function")Q.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(Q){console.error("Error waiting for pending operations:",Q)}if(!V()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let X=(await IQ(this.config.logDirectory)).filter((Y)=>(Y.includes("temp")||Y.includes(".tmp"))&&Y.includes(this.name));for(let Y of X)try{await FQ(HQ(this.config.logDirectory,Y))}catch(Z){console.error(`Failed to delete temp file ${Y}:`,Z)}}catch(Q){console.error("Error cleaning up temporary files:",Q)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(Q){if(!Q)return"";return`${this.tagFormat.prefix}${Q}${this.tagFormat.suffix}`}formatFileTimestamp(Q){return`[${Q.toISOString()}]`}formatConsoleTimestamp(Q){return this.fancy?M.gray(Q.toLocaleTimeString()):Q.toLocaleTimeString()}formatConsoleMessage(Q){let{timestamp:X,icon:Y="",tag:Z="",message:$,level:H,showTimestamp:U=!0}=Q,G=(A)=>A.replace(this.ANSI_PATTERN,"");if(!this.fancy){let A=[];if(U)A.push(X);if(H==="warning")A.push("WARN");else if(H==="error")A.push("ERROR");else if(Y)A.push(Y.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(Z)A.push(Z.replace(/[[\]]/g,""));return A.push($),A.join(" ")}let J=N.stdout.columns||120,_="";if(H==="warning"||H==="error")_=`${Y} ${$}`;else if(H==="info"||H==="success")_=`${Y} ${Z} ${$}`;else _=`${Y} ${Z} ${M.cyan($)}`;if(!U)return _.trim();let q=G(_).trim().length,W=G(X).length,z=Math.max(1,J-2-q-W);return`${_.trim()}${" ".repeat(z)}${X}`}formatMessage(Q,X){if(X.length===1&&Array.isArray(X[0]))return Q.replace(/\{(\d+)\}/g,(H,U)=>{let G=Number.parseInt(U,10);return G<X[0].length?String(X[0][G]):H});let Y=/%([sdijfo%])/g,Z=0,$=Q.replace(Y,(H,U)=>{if(U==="%")return"%";if(Z>=X.length)return H;let G=X[Z++];switch(U){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 H}});if(Z<X.length)$+=` ${X.slice(Z).map((H)=>typeof H==="object"?JSON.stringify(H,null,2):String(H)).join(" ")}`;return $}async log(Q,X,...Y){let Z=new Date,$=this.formatConsoleTimestamp(Z),H=this.formatFileTimestamp(Z),U,G;if(X instanceof Error)U=X.message,G=X.stack;else U=this.formatMessage(X,Y);if(this.fancy&&!V()){let _=sY[Q],q=this.options.showTags!==!1&&this.name?M.gray(this.formatTag(this.name)):"",W;switch(Q){case"debug":W=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:M.gray(U),level:Q}),console.error(W);break;case"info":W=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:U,level:Q}),console.error(W);break;case"success":W=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:M.green(U),level:Q}),console.error(W);break;case"warning":W=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:U,level:Q}),console.warn(W);break;case"error":if(W=this.formatConsoleMessage({timestamp:$,icon:_,tag:q,message:U,level:Q}),console.error(W),G){let z=G.split(`
3
3
  `);for(let A of z)if(A.trim()&&!A.includes(U))console.error(this.formatConsoleMessage({timestamp:$,message:M.gray(` ${A}`),level:Q,showTimestamp:!1}))}break}}else if(!V()){if(console.error(`${H} ${this.environment}.${Q.toUpperCase()}: ${U}`),G)console.error(G)}if(!this.shouldLog(Q))return;let J=`${H} ${this.environment}.${Q.toUpperCase()}: ${U}
4
4
  `;if(G)J+=`${G}
5
5
  `;J=J.replace(this.ANSI_PATTERN,""),await this.writeToFile(J)}time(Q){let X=performance.now();if(this.fancy&&!V()){let Y=this.options.showTags!==!1&&this.name?M.gray(this.formatTag(this.name)):"",Z=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:Z,icon:M.blue("\u25D0"),tag:Y,message:`${M.cyan(Q)}...`}))}return async(Y)=>{if(!this.enabled)return;let Z=performance.now(),$=Math.round(Z-X),H=`${Q} completed in ${$}ms`,U=new Date,G=this.formatConsoleTimestamp(U),_=`${this.formatFileTimestamp(U)} ${this.environment}.INFO: ${H}`;if(Y)_+=` ${JSON.stringify(Y)}`;if(_+=`
@@ -59,4 +59,4 @@ export type ConfigOf = Config
59
59
  `,Y+=`|----------|------|-------------|----------|
60
60
  `;for(let Z of Q)Y+=`| \`${Z.key}\` | ${Z.type} | ${Z.description} | \`${Z.example}\` |
61
61
  `;return Y}}function L8(Q,X,Y={}){return _Z(Q,X,Y,new WeakMap)}function _Z(Q,X,Y,Z){let{arrayMergeMode:$="replace",skipNullish:H=!1,customMerger:U}=Y;if(X===null||X===void 0)return H?Q:X;if(U){let G=U(Q,X);if(G!==void 0)return G}if(Array.isArray(X)||Array.isArray(Q))return qZ(Q,X,$,Z);if(!f(X)||!f(Q))return X;return F8(Q,X,Y,Z)}function qZ(Q,X,Y,Z){if(Array.isArray(X)&&!Array.isArray(Q))return X;if(Array.isArray(Q)&&!Array.isArray(X))return X;if(Array.isArray(X)&&Array.isArray(Q))switch(Y){case"replace":return X;case"concat":return K8(Q,X);case"smart":return j8(Q,X,Z);default:return X}return X}function K8(Q,X){let Y=[...X];for(let Z of Q)if(!Y.some(($)=>bX($,Z)))Y.push(Z);return Y}function j8(Q,X,Y){if(X.length===0)return Q;if(Q.length===0)return X;if(f(X[0])&&f(Q[0]))return I8(Q,X,Y);if(X.every((Z)=>typeof Z==="string")&&Q.every((Z)=>typeof Z==="string")){let Z=[...X];for(let $ of Q)if(!Z.includes($))Z.push($);return Z}return X}function I8(Q,X,Y){let Z=[...X];for(let $ of Q){if(!f($)){Z.push($);continue}let H=["id","name","key","path","type"],U=!1;for(let G of H)if(G in $){if(Z.find((_)=>f(_)&&(G in _)&&_[G]===$[G])){U=!0;break}}if(!U)Z.push($)}return Z}function F8(Q,X,Y,Z){let $=X;if(f($)&&Z.has($))return Z.get($);let H={...Q};if(f($))Z.set($,H);for(let U in $){if(!Object.prototype.hasOwnProperty.call($,U))continue;let G=$[U],J=H[U];if(Y.skipNullish&&(G===null||G===void 0))continue;if(G===null||G===void 0){H[U]=G;continue}if(f(G)&&f(J))H[U]=_Z(J,G,Y,Z);else if(Array.isArray(G)||Array.isArray(J))H[U]=qZ(J,G,Y.arrayMergeMode||"smart",Z);else H[U]=G}return H}function WZ(Q,X,Y="replace"){return L8(Q,X,{arrayMergeMode:Y==="replace"?"replace":"smart",skipNullish:!0})}function bX(Q,X){if(Q===X)return!0;if(Array.isArray(Q)&&Array.isArray(X)){if(Q.length!==X.length)return!1;for(let Y=0;Y<Q.length;Y++)if(!bX(Q[Y],X[Y]))return!1;return!0}if(f(Q)&&f(X)){let Y=Object.keys(Q),Z=Object.keys(X);if(Y.length!==Z.length)return!1;for(let $ of Y){if(!Object.prototype.hasOwnProperty.call(X,$))return!1;if(!bX(Q[$],X[$]))return!1}return!0}return!1}function f(Q){return Boolean(Q&&typeof Q==="object"&&!Array.isArray(Q))}class AZ{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(Q,X,Y={}){let{arrayStrategy:Z="replace",useCache:$=!0,cacheTtl:H,trackPerformance:U=!0,verbose:G=!1}=Y;if($){let _=fQ.getWithFileCheck("file",Q);if(_){if(G)console.log(`Configuration loaded from cache: ${Q}`);return _}}let J=async()=>{if(!kQ(Q))return null;try{let _=`?t=${Date.now()}`,q=await import(Q+_),W=q.default||q,z="default"in q,A=Object.keys(q).length>0;if(!z&&!A)throw new rQ(Q,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof W!=="object"||W===null||Array.isArray(W))throw new rQ(Q,Error("Configuration must export a valid object"),"unknown");let K={config:WZ(X,W,Z),source:{type:"file",path:Q,priority:100,timestamp:new Date}};if($)fQ.setWithFileCheck("file",K,Q,H);return K}catch(_){throw _ instanceof Error?BQ.configLoad(Q,_):BQ.configLoad(Q,Error(String(_)))}};if(U)return yX.track("loadFromPath",J,{path:Q});return J()}async tryLoadFromPaths(Q,X,Y={}){for(let Z of Q)try{let $=await this.loadFromPath(Z,X,Y);if($)return $}catch($){if($ instanceof Error&&$.name==="ConfigLoadError")throw $;if(Y.verbose)console.warn(`Failed to load config from ${Z}:`,$)}return null}generateConfigPaths(Q,X,Y){let Z=this.generateNamePatterns(Q,Y),$=[];for(let H of Z)for(let U of this.extensions)$.push(FX(X,`${H}${U}`));return $}generateNamePatterns(Q,X){let Y=[];if(Y.push("config",".config"),Q)Y.push(Q,`.${Q}.config`,`${Q}.config`,`.${Q}`);let Z=X===void 0?[]:Array.isArray(X)?X:[X];for(let H of Z){if(!H)continue;if(Y.push(H,`.${H}.config`,`${H}.config`,`.${H}`),Q)Y.push(`${Q}.${H}.config`,`.${Q}.${H}.config`)}let $=new Set;return Y.filter((H)=>{if(!H||$.has(H))return!1;return $.add(H),!0})}checkFileAccess(Q){return w8(async()=>{return kQ(Q)},{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(Q,X,Y){let Z=[];if(!kQ(Q))return Z;if(X||Y){let $=this.generateNamePatterns(X||"",Y);for(let H of $)for(let U of this.extensions){let G=FX(Q,`${H}${U}`);if(await this.checkFileAccess(G))Z.push(G)}}else try{let{readdirSync:$}=await import("fs"),H=$(Q);for(let U of H)if(this.looksLikeConfigFile(U)){let G=FX(Q,U);if(await this.checkFileAccess(G))Z.push(G)}}catch{return[]}return Z}looksLikeConfigFile(Q){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((Y)=>Y.test(Q))}async validateConfigFile(Q){let X=[];try{if(!kQ(Q))return X.push("Configuration file does not exist"),X;let Y=await import(Q),Z=Y.default||Y;if(Z===void 0)X.push("Configuration file must export a default value or named exports");else if(typeof Z!=="object"||Z===null)X.push("Configuration must be an object");else if(Array.isArray(Z))X.push("Configuration cannot be an array at the root level");if(Q.endsWith(".json"))try{let{readFileSync:$}=await import("fs"),H=$(Q,"utf8");JSON.parse(H)}catch($){X.push(`Invalid JSON syntax: ${$}`)}}catch(Y){X.push(`Failed to load configuration file: ${Y}`)}return X}async getFileModificationTime(Q){try{let{statSync:X}=await import("fs");return X(Q).mtime}catch{return null}}async preloadConfigurations(Q,X={}){let Y=new Map;return await Promise.allSettled(Q.map(async(Z)=>{try{let $=await this.loadFromPath(Z,{},X);if($)Y.set(Z,$.config)}catch($){if(X.verbose)console.warn(`Failed to preload ${Z}:`,$)}})),Y}}var D8=/^https?:\/\//;class zZ{async validateConfiguration(Q,X,Y={}){let{stopOnFirstError:Z=!1,validateRequired:$=!0,validateTypes:H=!0,customRules:U=[],trackPerformance:G=!0,verbose:J=!1}=Y,_=async()=>{let q=[],W=[],z={stopOnFirstError:Z,validateRequired:$,validateTypes:H,customRules:U,trackPerformance:G,verbose:J};try{if(typeof X==="string")return await this.validateWithSchemaFile(Q,X,z);else if(Array.isArray(X))return this.validateWithRules(Q,[...X,...U],z);else return this.validateWithJSONSchema(Q,X,z)}catch(A){return q.push({path:"",message:`Validation failed: ${A}`,rule:"system"}),{isValid:!1,errors:q,warnings:W}}};if(G)return await yX.track("validateConfiguration",_);return _()}async validateWithSchemaFile(Q,X,Y){try{if(!M8(X))throw new aQ(X,[{path:"",message:"Schema file does not exist"}]);let Z=await import(X),$=Z.default||Z;if(Array.isArray($))return this.validateWithRules(Q,$,Y);else return this.validateWithJSONSchema(Q,$,Y)}catch(Z){throw new aQ(X,[{path:"",message:`Failed to load schema: ${Z}`}])}}validateWithJSONSchema(Q,X,Y){let Z=[],$=[];return this.validateObjectAgainstSchema(Q,X,"",Z,$,Y),{isValid:Z.length===0,errors:Z,warnings:$}}validateObjectAgainstSchema(Q,X,Y,Z,$,H){if(H.validateTypes&&X.type){let U=Array.isArray(Q)?"array":typeof Q,G=Array.isArray(X.type)?X.type:[X.type];if(!G.includes(U)){if(Z.push({path:Y,message:`Expected type ${G.join(" or ")}, got ${U}`,expected:G.join(" or "),actual:U,rule:"type"}),H.stopOnFirstError)return}}if(X.enum&&!X.enum.includes(Q)){if(Z.push({path:Y,message:`Value must be one of: ${X.enum.join(", ")}`,expected:X.enum.join(", "),actual:Q,rule:"enum"}),H.stopOnFirstError)return}if(typeof Q==="string"){if(X.minLength!==void 0&&Q.length<X.minLength)Z.push({path:Y,message:`String length must be at least ${X.minLength}`,expected:`>= ${X.minLength}`,actual:Q.length,rule:"minLength"});if(X.maxLength!==void 0&&Q.length>X.maxLength)Z.push({path:Y,message:`String length must not exceed ${X.maxLength}`,expected:`<= ${X.maxLength}`,actual:Q.length,rule:"maxLength"});if(X.pattern){if(!new RegExp(X.pattern).test(Q))Z.push({path:Y,message:`String does not match pattern ${X.pattern}`,expected:X.pattern,actual:Q,rule:"pattern"})}}if(typeof Q==="number"){if(X.minimum!==void 0&&Q<X.minimum)Z.push({path:Y,message:`Value must be at least ${X.minimum}`,expected:`>= ${X.minimum}`,actual:Q,rule:"minimum"});if(X.maximum!==void 0&&Q>X.maximum)Z.push({path:Y,message:`Value must not exceed ${X.maximum}`,expected:`<= ${X.maximum}`,actual:Q,rule:"maximum"})}if(Array.isArray(Q)&&X.items)for(let U=0;U<Q.length;U++){let G=Y?`${Y}[${U}]`:`[${U}]`;if(this.validateObjectAgainstSchema(Q[U],X.items,G,Z,$,H),H.stopOnFirstError&&Z.length>0)return}if(Q&&typeof Q==="object"&&!Array.isArray(Q)){let U=Q;if(H.validateRequired&&X.required){for(let G of X.required)if(!(G in U)){if(Z.push({path:Y?`${Y}.${G}`:G,message:`Missing required property '${G}'`,expected:"required",rule:"required"}),H.stopOnFirstError)return}}if(X.properties){for(let[G,J]of Object.entries(X.properties))if(G in U){let _=Y?`${Y}.${G}`:G;if(this.validateObjectAgainstSchema(U[G],J,_,Z,$,H),H.stopOnFirstError&&Z.length>0)return}}if(X.additionalProperties===!1){let G=new Set(Object.keys(X.properties||{}));for(let J of Object.keys(U))if(!G.has(J))$.push({path:Y?`${Y}.${J}`:J,message:`Additional property '${J}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(Q,X,Y){let Z=[],$=[];for(let H of X)try{let U=this.getValueByPath(Q,H.path),G=this.validateWithRule(U,H,H.path);if(Z.push(...G),Y.stopOnFirstError&&Z.length>0)break}catch(U){Z.push({path:H.path,message:`Rule validation failed: ${U}`,rule:"system"})}return{isValid:Z.length===0,errors:Z,warnings:$}}validateWithRule(Q,X,Y){let Z=[];if(X.required&&(Q===void 0||Q===null))return Z.push({path:Y,message:X.message||`Property '${Y}' is required`,expected:"required",rule:"required"}),Z;if(Q===void 0||Q===null)return Z;if(X.type){let $=Array.isArray(Q)?"array":typeof Q;if($!==X.type)Z.push({path:Y,message:X.message||`Expected type ${X.type}, got ${$}`,expected:X.type,actual:$,rule:"type"})}if(X.min!==void 0){let $=Array.isArray(Q)?Q.length:typeof Q==="string"?Q.length:typeof Q==="number"?Q:0;if($<X.min)Z.push({path:Y,message:X.message||`Value must be at least ${X.min}`,expected:`>= ${X.min}`,actual:$,rule:"min"})}if(X.max!==void 0){let $=Array.isArray(Q)?Q.length:typeof Q==="string"?Q.length:typeof Q==="number"?Q:0;if($>X.max)Z.push({path:Y,message:X.message||`Value must not exceed ${X.max}`,expected:`<= ${X.max}`,actual:$,rule:"max"})}if(X.pattern&&typeof Q==="string"){if(!X.pattern.test(Q))Z.push({path:Y,message:X.message||`Value does not match pattern ${X.pattern}`,expected:X.pattern.toString(),actual:Q,rule:"pattern"})}if(X.enum&&!X.enum.includes(Q))Z.push({path:Y,message:X.message||`Value must be one of: ${X.enum.join(", ")}`,expected:X.enum.join(", "),actual:Q,rule:"enum"});if(X.validator){let $=X.validator(Q);if($)Z.push({path:Y,message:X.message||$,rule:"custom"})}return Z}getValueByPath(Q,X){if(!X)return Q;let Y=X.split("."),Z=Q;for(let $ of Y)if(Z&&typeof Z==="object"&&$ in Z)Z=Z[$];else return;return Z}generateRulesFromInterface(Q){let X=[],Y=Q.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let Z of Y){let[,$,H,U]=Z;X.push({path:$,required:!H,type:this.mapTypeScriptType(U)})}return X}mapTypeScriptType(Q){switch(Q.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:D8},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}var c=new YX("bunfig",{showTags:!0});function V8(Q){if(!Q)return"";let X=Array.isArray(Q)?Q.filter(Boolean):[Q];if(X.length===0)return"";if(X.length===1)return` or alias "${X[0]}"`;return` or aliases ${X.map((Y)=>`"${Y}"`).join(", ")}`}class BZ{fileLoader=new AZ;envProcessor=new cX;validator=new zZ;async loadConfig(Q){let X=Date.now(),{cache:Y,performance:Z,schema:$,validate:H,...U}=Q;try{if(Y?.enabled){let J=this.checkCache(U.name||"",U);if(J)return J}let G;try{G=await this.loadConfigurationStrategies(U,!0,Y)}catch(J){let _=U.__strictErrorHandling;if(J instanceof Error&&J.name==="ConfigNotFoundError"){if(_)throw J;G={...await this.applyEnvironmentVariables(U.name||"",U.defaultConfig,U.checkEnv!==!1,U.verbose||!1),warnings:[`No configuration file found for "${U.name||"config"}", using defaults with environment variables`]}}else if(J instanceof Error&&J.name==="ConfigLoadError"){let q=J.message.includes("EACCES")||J.message.includes("EPERM")||J.message.includes("permission denied"),W=!q&&(J.message.includes("syntax")||J.message.includes("Expected")||J.message.includes("Unexpected")||J.message.includes("BuildMessage")||J.message.includes("errors building")),z=J.message.includes("Configuration must export a valid object")||J.message.includes("Configuration file is empty and exports nothing");if(_&&(z||q))throw J;if(W&&(!_||!z))G={...await this.applyEnvironmentVariables(U.name||"",U.defaultConfig,U.checkEnv!==!1,U.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!_)G={...await this.applyEnvironmentVariables(U.name||"",U.defaultConfig,U.checkEnv!==!1,U.verbose||!1),warnings:[`Configuration loading error, using defaults: ${J.message}`]};else throw J}else G={...await this.applyEnvironmentVariables(U.name||"",U.defaultConfig,U.checkEnv!==!1,U.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${J instanceof Error?J.message:String(J)}`]}}if($||H)await this.validateConfiguration(G.config,$,H,U.name);if(Y?.enabled&&G)this.cacheResult(U.name||"",G,Y,U);if(Z?.enabled){let J={operation:"loadConfig",duration:Date.now()-X,configName:U.name,timestamp:new Date};if(Z.onMetrics)Z.onMetrics(J);if(Z.slowThreshold&&J.duration>Z.slowThreshold)c.warn(`Slow configuration loading detected: ${J.duration}ms for ${U.name}`);G.metrics=J}return G}catch(G){if(G instanceof Error&&G.name==="ConfigNotFoundError")throw G;let J=Date.now()-X;throw c.error(`Configuration loading failed after ${J}ms:`,[G instanceof Error?G:Error(String(G))]),G}}async loadConfigurationStrategies(Q,X=!1,Y){let{name:Z="",alias:$,cwd:H,configDir:U,defaultConfig:G,checkEnv:J=!0,arrayStrategy:_="replace",verbose:q=!1}=Q,W=H||eQ.cwd(),z=[],A=await this.loadLocalConfiguration(Z,$,W,U,G,_,q,J,Y);if(A)return z.push(...this.getLocalSearchPaths(Z,$,W,U)),this.finalizeResult(A,z,J,Z,q);let I=await this.loadHomeConfiguration(Z,$,G,_,q,J);if(I)return z.push(...this.getHomeSearchPaths(Z,$)),this.finalizeResult(I,z,J,Z,q);let B=await this.loadPackageJsonConfiguration(Z,$,W,G,_,q,J);if(B)return z.push(d(W,"package.json")),this.finalizeResult(B,z,J,Z,q);if(z.push(...this.getAllSearchPaths(Z,$,W,U)),X)throw BQ.configNotFound(Z,z,$);return{...await this.applyEnvironmentVariables(Z,G,J,q),warnings:[`No configuration file found for "${Z}"${V8($)}, using defaults with environment variables`]}}async loadLocalConfiguration(Q,X,Y,Z,$,H,U,G,J){let _=G?PQ(Q,$,U):$,q=this.getLocalDirectories(Y,Z);for(let W of q){if(U)c.info(`Searching for configuration in: ${W}`);let z=this.fileLoader.generateConfigPaths(Q,W,X),A=await this.fileLoader.tryLoadFromPaths(z,_,{arrayStrategy:H,verbose:U,cacheTtl:J?.ttl,useCache:!J?.ttl||J.ttl>100});if(A){if(U)c.success(`Configuration loaded from: ${A.source.path}`);return A}}return null}async loadHomeConfiguration(Q,X,Y,Z,$,H){if(!Q)return null;let U=H?PQ(Q,Y,$):Y,G=[d(YQ(),".config",Q),d(YQ(),".config"),YQ()];for(let J of G){if($)c.info(`Checking home directory: ${J}`);let _=this.fileLoader.generateConfigPaths(Q,J,X),q=await this.fileLoader.tryLoadFromPaths(_,U,{arrayStrategy:Z,verbose:$});if(q){if($)c.success(`Configuration loaded from home directory: ${q.source.path}`);return q}}return null}async loadPackageJsonConfiguration(Q,X,Y,Z,$,H,U){let G=U?PQ(Q,Z,H):Z;try{let J=d(Y,"package.json");if(!LZ(J))return null;let _={};try{_=JSON.parse(KZ(J,"utf8"))}catch(z){if(H)c.warn("Failed to parse package.json:",[z instanceof Error?z:Error(String(z))]);return null}let q=_[Q],W=Q;if(!q&&X){let z=Array.isArray(X)?X:[X];for(let A of z){if(!A)continue;if(_[A]){q=_[A],W=A;break}}}if(q&&typeof q==="object"&&!Array.isArray(q)){if(H)c.success(`Configuration loaded from package.json: ${W}`);return{config:WZ(G,q,$),source:{type:"package.json",path:J,priority:30,timestamp:new Date}}}}catch(J){if(H)c.warn("Failed to load package.json:",[J instanceof Error?J:Error(String(J))])}return null}async applyEnvironmentVariables(Q,X,Y,Z){if(!Y||!Q||typeof X!=="object"||X===null||Array.isArray(X))return{config:X,source:{type:"default",priority:10,timestamp:new Date}};return{config:PQ(Q,X,Z),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(Q,X,Y,Z,$){return{config:Q.config,source:Q.source,path:Q.source.path}}async validateConfiguration(Q,X,Y,Z){let $=[];if(Y){let H=Y(Q);if(H)$.push(...H)}if(X){let H=await this.validator.validateConfiguration(Q,X);if(!H.isValid)$.push(...H.errors.map((U)=>U.path?`${U.path}: ${U.message}`:U.message))}if($.length>0)throw BQ.configValidation(Z||"unknown",$,Z)}checkCache(Q,X){let Y=this.generateCacheKey(Q,X);return fQ.get(Y)||null}cacheResult(Q,X,Y,Z){let $=this.generateCacheKey(Q,Z);fQ.set($,X,void 0,Y.ttl)}generateCacheKey(Q,X){let Y=[Q];if(X.alias){let Z=Array.isArray(X.alias)?X.alias.join(","):X.alias;Y.push(`alias:${Z}`)}if(X.cwd)Y.push(`cwd:${X.cwd}`);if(X.configDir)Y.push(`configDir:${X.configDir}`);if("checkEnv"in X)Y.push(`checkEnv:${X.checkEnv}`);return Y.join("|")}getLocalDirectories(Q,X){return Array.from(new Set([Q,d(Q,"config"),d(Q,".config"),X?d(Q,X):void 0].filter(Boolean)))}getAllSearchPaths(Q,X,Y,Z){let $=[];return $.push(...this.getLocalSearchPaths(Q,X,Y,Z)),$.push(...this.getHomeSearchPaths(Q,X)),$.push(d(Y,"package.json")),$}getLocalSearchPaths(Q,X,Y,Z){let $=this.getLocalDirectories(Y,Z),H=[];for(let U of $)H.push(...this.fileLoader.generateConfigPaths(Q,U,X));return H}getHomeSearchPaths(Q,X){if(!Q)return[];let Y=[d(YQ(),".config",Q),d(YQ(),".config"),YQ()],Z=[];for(let $ of Y)Z.push(...this.fileLoader.generateConfigPaths(Q,$,X));return Z}async loadConfigWithResult(Q){return this.loadConfig(Q)}}var MX=new BZ;async function RZ(Q){let X="defaultConfig"in Q&&Q.defaultConfig!==void 0?Q.defaultConfig:{},Y="cache"in Q||"performance"in Q||"schema"in Q||"validate"in Q;try{let Z;if(Y)Z=await MX.loadConfig(Q);else Z=await MX.loadConfig({...Q,defaultConfig:X,cache:{enabled:!0},performance:{enabled:!1}});return Z?.config??X}catch(Z){let $=Z instanceof Error?Z.name:"UnknownError",H=Z instanceof Error?Z.message:String(Z);if(!($==="ConfigNotFoundError"||$==="ConfigLoadError"||$==="ConfigValidationError"||H.includes("config"))&&Q.verbose)c.warn("Unexpected error loading config, using defaults:",[Z instanceof Error?Z:Error(String(Z))]);let G=Y?{...Q,defaultConfig:X}:{...Q,defaultConfig:X,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in Q?Q.checkEnv!==!1:!0)return(await MX.applyEnvironmentVariables(G.name||"",X,!0,G.verbose||!1))?.config??X;return X}}function PQ(Q,X,Y=!1){let Z=new cX,$=Q.toUpperCase().replace(/[^A-Z0-9]/g,"_");function H(U,G=[]){let J={...U};for(let[_,q]of Object.entries(U)){let W=[...G,_],z=[`${$}_${W.join("_").toUpperCase()}`,`${$}_${W.map((B)=>B.toUpperCase()).join("")}`,`${$}_${W.map((B)=>B.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],A,I;for(let B of z)if(A=eQ.env[B],A!==void 0){I=B;break}if(A!==void 0&&I)if(typeof q==="boolean")J[_]=["true","1","yes"].includes(A.toLowerCase());else if(typeof q==="number"){let B=Number(A);if(!Number.isNaN(B))J[_]=B}else if(Array.isArray(q))try{J[_]=JSON.parse(A)}catch{J[_]=A.split(",").map((B)=>B.trim())}else J[_]=A;else if(q&&typeof q==="object"&&!Array.isArray(q))J[_]=H(q,W)}return J}return H(X)}var J$=d(eQ.cwd(),"config"),G$=d(eQ.cwd(),"src/generated");var S8=["code-style","lint"],wZ={ignores:["**/node_modules/**","**/.pnpm/**","**/.yarn/**","**/dist/**","**/build/**","**/out/**","**/.output/**","**/.next/**","**/.nuxt/**","**/.vite/**","**/.turbo/**","**/.cache/**","**/coverage/**","**/vendor/**","**/pantry/**","**/tmp/**","**/.git/**","**/.idea/**","**/.vscode/**","**/.zed/**","**/.cursor/**","**/.claude/**","**/.github/**","**/*.test.ts","**/*.spec.ts","**/.bunpress/**","**/.vitepress/cache/**","**/storage/framework/stx/**","**/storage/framework/runtime/**","**/storage/cloud/**","**/*.lock","**/package-lock.json","**/pnpm-lock.yaml"],lint:{extensions:["ts","js","html","css","json","jsonc","md","yaml","yml","stx","sh","bash","zsh"],reporter:"stylish",cache:!1,maxWarnings:-1},format:{extensions:["ts","js","html","css","json","jsonc","md","yaml","yml","stx","sh","bash","zsh"],trimTrailingWhitespace:!0,maxConsecutiveBlankLines:1,finalNewline:"one",indent:2,indentStyle:"spaces",preserveCodeIndentation:!1,quotes:"single",semi:!1},rules:{noDebugger:"error",noConsole:"warn"},pluginRules:{"style/brace-style":"warn","style/curly":"off","style/if-newline":"off","style/max-statements-per-line":"warn","pickier/import-dedupe":"warn","pickier/no-import-node-modules-by-path":"error","pickier/no-import-dist":"error","pickier/prefer-const":"error","pickier/prefer-template":"warn","pickier/no-unused-vars":"error","pickier/sort-tailwind-classes":"warn","regexp/no-unused-capturing-group":"error","regexp/no-super-linear-backtracking":"error","regexp/no-useless-lazy":"error","ts/no-top-level-await":"error","ts/member-delimiter-style":"off","ts/type-annotation-spacing":"off","style/comma-dangle":"off","style/keyword-spacing":"off","style/arrow-spacing":"off","style/space-infix-ops":"off","style/object-curly-spacing":"off","style/spaced-comment":"off","style/block-spacing":"off","style/space-before-blocks":"off","style/comma-spacing":"off","style/semi-spacing":"off","style/rest-spread-spacing":"off","style/key-spacing":"off","style/computed-property-spacing":"off","style/array-bracket-spacing":"off","style/space-in-parens":"off","style/template-curly-spacing":"off","style/space-unary-ops":"off","style/switch-colon-spacing":"off","style/arrow-parens":"off","style/space-before-function-paren":"off","style/quote-props":"off","style/no-floating-decimal":"off","style/new-parens":"off","style/no-extra-parens":"off","style/wrap-iife":"off","style/comma-style":"off","style/dot-location":"off","style/operator-linebreak":"off","style/multiline-ternary":"off","style/padded-blocks":"off","style/lines-between-class-members":"off","style/no-tabs":"off","style/no-mixed-spaces-and-tabs":"off","style/generator-star-spacing":"off","style/yield-star-spacing":"off","style/function-call-spacing":"off","style/template-tag-spacing":"off","style/no-whitespace-before-property":"off","style/no-mixed-operators":"off","style/indent-binary-ops":"off","ts/type-generic-spacing":"off","ts/type-named-tuple-spacing":"off","markdown/heading-increment":"warn","markdown/heading-style":"warn","markdown/no-missing-space-atx":"error","markdown/no-multiple-space-atx":"error","markdown/no-missing-space-closed-atx":"error","markdown/no-multiple-space-closed-atx":"error","markdown/blanks-around-headings":"warn","markdown/heading-start-left":"warn","markdown/no-duplicate-heading":"warn","markdown/single-title":"warn","markdown/no-trailing-punctuation":"warn","markdown/ul-style":"warn","markdown/list-indent":"error","markdown/ul-indent":"warn","markdown/ol-prefix":"warn","markdown/list-marker-space":"error","markdown/blanks-around-lists":"warn","markdown/no-trailing-spaces":"error","markdown/no-hard-tabs":"error","markdown/no-multiple-blanks":"warn","markdown/no-multiple-space-blockquote":"error","markdown/no-blanks-blockquote":"warn","markdown/blanks-around-fences":"warn","markdown/single-trailing-newline":"error","markdown/blanks-around-tables":"warn","markdown/no-reversed-links":"error","markdown/no-bare-urls":"warn","markdown/no-space-in-links":"error","markdown/no-empty-links":"error","markdown/link-fragments":"warn","markdown/reference-links-images":"warn","markdown/link-image-reference-definitions":"warn","markdown/link-image-style":"warn","markdown/descriptive-link-text":"warn","markdown/line-length":"off","markdown/commands-show-output":"warn","markdown/fenced-code-language":"warn","markdown/code-block-style":"off","markdown/code-fence-style":"warn","markdown/no-emphasis-as-heading":"warn","markdown/no-space-in-emphasis":"warn","markdown/no-space-in-code":"warn","markdown/emphasis-style":"warn","markdown/strong-style":"warn","markdown/no-inline-html":"off","markdown/hr-style":"warn","markdown/first-line-heading":"off","markdown/required-headings":"off","markdown/proper-names":"off","markdown/no-alt-text":"warn","markdown/table-pipe-style":"warn","markdown/table-column-count":"warn","markdown/table-column-style":"warn","lockfile/validate-host":["warn",{allowedHosts:["npm","yarn"]}],"lockfile/validate-https":"error","lockfile/validate-integrity":["warn",{requiredAlgorithm:"sha512"}],"lockfile/validate-package-names":"error","lockfile/validate-scheme":["error",{allowedSchemes:["https:","git+https:","git+ssh:"]}],"publint/exports-types-should-be-first":"error","publint/exports-default-should-be-last":"error","publint/exports-module-should-precede-require":"error","publint/exports-value-invalid":"error","publint/imports-key-invalid":"error","publint/imports-value-invalid":"error","publint/imports-default-should-be-last":"error","publint/imports-module-should-precede-require":"error","publint/use-type":"warn","publint/deprecated-field-jsnext":"warn","publint/field-invalid-value-type":"error","publint/local-dependency":"error","publint/has-module-but-no-exports":"warn","publint/exports-missing-root-entrypoint":"warn","publint/exports-fallback-array-use":"warn","publint/file-does-not-exist":"warn","publint/file-invalid-format":"warn","publint/module-should-be-esm":"error","publint/bin-file-not-executable":"error","publint/exports-module-should-be-esm":"error","shell/command-substitution":"error","shell/quote-variables":"warn","shell/no-cd-without-check":"warn","shell/no-eval":"error","shell/no-useless-cat":"warn","shell/shebang":"warn","shell/indent":"warn","shell/function-style":"warn","shell/operator-spacing":"warn","shell/keyword-spacing":"warn","shell/no-trailing-semicolons":"warn","shell/no-trailing-whitespace":"error","shell/prefer-double-brackets":"warn","shell/set-options":"off","shell/prefer-printf":"warn","shell/consistent-case-terminators":"warn","shell/no-broken-redirect":"error","shell/heredoc-indent":"warn","shell/no-ls-parsing":"warn","shell/no-variable-in-single-quotes":"warn","shell/no-exit-in-subshell":"warn","spell/check":"off","spell/check-comments":"off","spell/check-markdown":"off"},verbose:!0},lX=null;async function W$(){if(!lX)lX=await RZ({name:"pickier",alias:[...S8],defaultConfig:wZ});return lX}var A$=wZ;
62
- export{wZ as I,W$ as J,A$ as K};
62
+ export{wZ as K,W$ as L,A$ as M};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-h6ac3d60.js";import{existsSync as EZ}from"fs";import HJ from"fs/promises";import CJ from"os";import KJ from"path";import p from"process";import{EventEmitter as IZ}from"events";import m from"process";import kJ from"process";import MJ from"process";import qJ from"process";import vJ from"process";import o from"process";import SJ from"tty";import zZ,{stdin as j0,stdout as G0}from"process";import*as c from"readline";import{ReadStream as yJ,WriteStream as H0}from"tty";import gJ,{stdin as P0,stdout as N0}from"process";import w0 from"readline";import A0 from"process";import S0 from"process";import{WriteStream as y0}from"tty";import f0 from"process";import xJ from"process";import d0 from"process";import{stripVTControlCharacters as WJ}from"util";import{existsSync as c0,lstatSync as dJ,readdirSync as p0}from"fs";import{dirname as uJ,join as i0}from"path";import n0 from"process";import b from"process";import e from"process";import{stripVTControlCharacters as DJ}from"util";import r0 from"process";import{Buffer as iJ}from"buffer";import y from"fs/promises";import a0 from"os";import XJ from"path";import w from"process";import{Readable as s0,Writable as t0}from"stream";class nJ{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let J=CJ.homedir(),Z=KJ.join(J,".config","clapp");this.configPath=KJ.join(Z,"telemetry.json")}async isEnabled(){if(p.env.DO_NOT_TRACK==="1"||p.env.DO_NOT_TRACK==="true")return!1;if(p.env.NO_TELEMETRY==="1"||p.env.NO_TELEMETRY==="true")return!1;return(await this.loadConfig()).enabled}async enable(){let J=await this.loadConfig();if(J.enabled=!0,!J.userId)J.userId=this.generateUserId();await this.saveConfig(J)}async disable(){let J=await this.loadConfig();J.enabled=!1,await this.saveConfig(J)}async track(J,Z){if(!await this.isEnabled())return;let Q={event:J,...Z,timestamp:Date.now(),platform:CJ.platform(),nodeVersion:p.version};if(this.events.push(Q),this.events.length>=10)await this.send()}async trackCommand(J,Z){await this.track("command",{command:J,duration:Z})}async trackError(J,Z){await this.track("error",{error:J,command:Z})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let Z=await this.loadConfig();return Z.lastSent=Date.now(),await this.saveConfig(Z),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let Z=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep(Z),this.send()}return this.events=[],this.retryCount=0,!1}}async flush(){if(this.events.length===0)return!0;return this.send()}sleep(J){return new Promise((Z)=>setTimeout(Z,J))}async status(){let J=await this.loadConfig();return{enabled:J.enabled,doNotTrack:p.env.DO_NOT_TRACK==="1"||p.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:J.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(EZ(this.configPath)){let J=await HJ.readFile(this.configPath,"utf-8");return this.config=JSON.parse(J),this.config}}catch{}return this.config={enabled:!1},this.config}async saveConfig(J){this.config=J;try{let Z=KJ.dirname(this.configPath);await HJ.mkdir(Z,{recursive:!0}),await HJ.writeFile(this.configPath,JSON.stringify(J,null,2),"utf-8")}catch{}}generateUserId(){let J=Math.random().toString(36).substring(2,15),Z=Date.now().toString(36);return`${J}-${Z}`}}var Y$=new nJ;function AZ(J,Z={}){let $={_:[]},Q=Z.alias||{},Y=new Set(Z.boolean||[]),q={};for(let F of Object.keys(Q))for(let X of Q[F])q[X]=F;for(let F of Y)if(Q[F])for(let X of Q[F])Y.add(X);function U(F,X){let j=q[F]||F;if($[j]=X,Q[j])for(let G of Q[j])$[G]=X;if(q[F]&&Q[q[F]])for(let G of Q[q[F]])$[G]=X;$[F]=X}for(let F=0;F<J.length;F++){let X=J[F];if(X==="--"){$._.push(...J.slice(F+1));break}if(X.startsWith("--")){let j=X.indexOf("=");if(j!==-1){let G=X.slice(2,j),V=X.slice(j+1);U(G,V)}else{let G=X.slice(2);if(G.startsWith("no-")){let W=G.slice(3);U(W,!1);continue}let V=q[G]||G;if(Y.has(V)||Y.has(G))U(G,!0);else{let W=J[F+1];if(W!==void 0&&!W.startsWith("-"))U(G,W),F++;else U(G,!0)}}}else if(X.startsWith("-")&&X.length>1){let j=X.slice(1);for(let G=0;G<j.length;G++){let V=j[G],W=q[V]||V;if(G===j.length-1&&!Y.has(W)&&!Y.has(V)){let K=J[F+1];if(K!==void 0&&!K.startsWith("-"))U(V,K),F++;else U(V,!0)}else U(V,!0)}}else $._.push(X)}return $}function LJ(J){return J.replace(/[<[].+/,"").trim()}function RZ(J){let Z=/<([^>]+)>/g,$=/\[([^\]]+)\]/g,Q=[],Y=(F)=>{let X=!1,j=F[1];if(j.startsWith("..."))j=j.slice(3),X=!0;return{required:F[0].startsWith("<"),value:j,variadic:X}},q;while(q=Z.exec(J))Q.push(Y(q));let U;while(U=$.exec(J))Q.push(Y(U));return Q}function xZ(J){let Z={alias:{},boolean:[]};for(let[$,Q]of J.entries()){if(Q.names.length>1)Z.alias[Q.names[0]]=Q.names.slice(1);if(Q.isBoolean)if(Q.negated){if(!J.some((q,U)=>{return U!==$&&q.names.some((F)=>Q.names.includes(F))&&typeof q.required==="boolean"}))Z.boolean.push(Q.names[0])}else Z.boolean.push(Q.names[0])}return Z}function hJ(J){return J.reduce((Z,$)=>Z.length>=$.length?Z:$,"")}function VJ(J,Z){return J.length>=Z?J:`${J}${" ".repeat(Z-J.length)}`}function CZ(J){return J.replace(/([a-z])-([a-z])/g,(Z,$,Q)=>{return $+Q.toUpperCase()})}function kZ(J,Z,$){let Q=0,Y=Z.length,q=J,U;for(;Q<Y;++Q)U=q[Z[Q]],q=q[Z[Q]]=Q===Y-1?$:U!=null?U:!!~Z[Q+1].indexOf(".")||!(+Z[Q+1]>-1)?{}:[]}function hZ(J,Z){for(let $ of Object.keys(Z)){let Q=Z[$];if(Q.shouldTransform){if(J[$]=Array.prototype.concat.call([],J[$]),typeof Q.transformFunction==="function")J[$]=J[$].map(Q.transformFunction)}}}function bZ(J){let Z=/([^\\/]+)$/.exec(J);return Z?Z[1]:""}function lJ(J){return J.split(".").map((Z,$)=>{return $===0?CZ(Z):Z}).join(".")}class YJ extends Error{exitCode=2;isUsageError=!0;constructor(J){super(J);if(this.name=this.constructor.name,typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,this.constructor);else this.stack=Error(J).stack}format(J=!1){if(J&&this.stack)return`${this.message}
2
+ import"./chunk-43fsk0jg.js";import{existsSync as EZ}from"fs";import HJ from"fs/promises";import CJ from"os";import KJ from"path";import p from"process";import{EventEmitter as IZ}from"events";import m from"process";import kJ from"process";import MJ from"process";import qJ from"process";import vJ from"process";import o from"process";import SJ from"tty";import zZ,{stdin as j0,stdout as G0}from"process";import*as c from"readline";import{ReadStream as yJ,WriteStream as H0}from"tty";import gJ,{stdin as P0,stdout as N0}from"process";import w0 from"readline";import A0 from"process";import S0 from"process";import{WriteStream as y0}from"tty";import f0 from"process";import xJ from"process";import d0 from"process";import{stripVTControlCharacters as WJ}from"util";import{existsSync as c0,lstatSync as dJ,readdirSync as p0}from"fs";import{dirname as uJ,join as i0}from"path";import n0 from"process";import b from"process";import e from"process";import{stripVTControlCharacters as DJ}from"util";import r0 from"process";import{Buffer as iJ}from"buffer";import y from"fs/promises";import a0 from"os";import XJ from"path";import w from"process";import{Readable as s0,Writable as t0}from"stream";class nJ{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let J=CJ.homedir(),Z=KJ.join(J,".config","clapp");this.configPath=KJ.join(Z,"telemetry.json")}async isEnabled(){if(p.env.DO_NOT_TRACK==="1"||p.env.DO_NOT_TRACK==="true")return!1;if(p.env.NO_TELEMETRY==="1"||p.env.NO_TELEMETRY==="true")return!1;return(await this.loadConfig()).enabled}async enable(){let J=await this.loadConfig();if(J.enabled=!0,!J.userId)J.userId=this.generateUserId();await this.saveConfig(J)}async disable(){let J=await this.loadConfig();J.enabled=!1,await this.saveConfig(J)}async track(J,Z){if(!await this.isEnabled())return;let Q={event:J,...Z,timestamp:Date.now(),platform:CJ.platform(),nodeVersion:p.version};if(this.events.push(Q),this.events.length>=10)await this.send()}async trackCommand(J,Z){await this.track("command",{command:J,duration:Z})}async trackError(J,Z){await this.track("error",{error:J,command:Z})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let Z=await this.loadConfig();return Z.lastSent=Date.now(),await this.saveConfig(Z),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let Z=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep(Z),this.send()}return this.events=[],this.retryCount=0,!1}}async flush(){if(this.events.length===0)return!0;return this.send()}sleep(J){return new Promise((Z)=>setTimeout(Z,J))}async status(){let J=await this.loadConfig();return{enabled:J.enabled,doNotTrack:p.env.DO_NOT_TRACK==="1"||p.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:J.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(EZ(this.configPath)){let J=await HJ.readFile(this.configPath,"utf-8");return this.config=JSON.parse(J),this.config}}catch{}return this.config={enabled:!1},this.config}async saveConfig(J){this.config=J;try{let Z=KJ.dirname(this.configPath);await HJ.mkdir(Z,{recursive:!0}),await HJ.writeFile(this.configPath,JSON.stringify(J,null,2),"utf-8")}catch{}}generateUserId(){let J=Math.random().toString(36).substring(2,15),Z=Date.now().toString(36);return`${J}-${Z}`}}var Y$=new nJ;function AZ(J,Z={}){let $={_:[]},Q=Z.alias||{},Y=new Set(Z.boolean||[]),q={};for(let F of Object.keys(Q))for(let X of Q[F])q[X]=F;for(let F of Y)if(Q[F])for(let X of Q[F])Y.add(X);function U(F,X){let j=q[F]||F;if($[j]=X,Q[j])for(let G of Q[j])$[G]=X;if(q[F]&&Q[q[F]])for(let G of Q[q[F]])$[G]=X;$[F]=X}for(let F=0;F<J.length;F++){let X=J[F];if(X==="--"){$._.push(...J.slice(F+1));break}if(X.startsWith("--")){let j=X.indexOf("=");if(j!==-1){let G=X.slice(2,j),V=X.slice(j+1);U(G,V)}else{let G=X.slice(2);if(G.startsWith("no-")){let W=G.slice(3);U(W,!1);continue}let V=q[G]||G;if(Y.has(V)||Y.has(G))U(G,!0);else{let W=J[F+1];if(W!==void 0&&!W.startsWith("-"))U(G,W),F++;else U(G,!0)}}}else if(X.startsWith("-")&&X.length>1){let j=X.slice(1);for(let G=0;G<j.length;G++){let V=j[G],W=q[V]||V;if(G===j.length-1&&!Y.has(W)&&!Y.has(V)){let K=J[F+1];if(K!==void 0&&!K.startsWith("-"))U(V,K),F++;else U(V,!0)}else U(V,!0)}}else $._.push(X)}return $}function LJ(J){return J.replace(/[<[].+/,"").trim()}function RZ(J){let Z=/<([^>]+)>/g,$=/\[([^\]]+)\]/g,Q=[],Y=(F)=>{let X=!1,j=F[1];if(j.startsWith("..."))j=j.slice(3),X=!0;return{required:F[0].startsWith("<"),value:j,variadic:X}},q;while(q=Z.exec(J))Q.push(Y(q));let U;while(U=$.exec(J))Q.push(Y(U));return Q}function xZ(J){let Z={alias:{},boolean:[]};for(let[$,Q]of J.entries()){if(Q.names.length>1)Z.alias[Q.names[0]]=Q.names.slice(1);if(Q.isBoolean)if(Q.negated){if(!J.some((q,U)=>{return U!==$&&q.names.some((F)=>Q.names.includes(F))&&typeof q.required==="boolean"}))Z.boolean.push(Q.names[0])}else Z.boolean.push(Q.names[0])}return Z}function hJ(J){return J.reduce((Z,$)=>Z.length>=$.length?Z:$,"")}function VJ(J,Z){return J.length>=Z?J:`${J}${" ".repeat(Z-J.length)}`}function CZ(J){return J.replace(/([a-z])-([a-z])/g,(Z,$,Q)=>{return $+Q.toUpperCase()})}function kZ(J,Z,$){let Q=0,Y=Z.length,q=J,U;for(;Q<Y;++Q)U=q[Z[Q]],q=q[Z[Q]]=Q===Y-1?$:U!=null?U:!!~Z[Q+1].indexOf(".")||!(+Z[Q+1]>-1)?{}:[]}function hZ(J,Z){for(let $ of Object.keys(Z)){let Q=Z[$];if(Q.shouldTransform){if(J[$]=Array.prototype.concat.call([],J[$]),typeof Q.transformFunction==="function")J[$]=J[$].map(Q.transformFunction)}}}function bZ(J){let Z=/([^\\/]+)$/.exec(J);return Z?Z[1]:""}function lJ(J){return J.split(".").map((Z,$)=>{return $===0?CZ(Z):Z}).join(".")}class YJ extends Error{exitCode=2;isUsageError=!0;constructor(J){super(J);if(this.name=this.constructor.name,typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,this.constructor);else this.stack=Error(J).stack}format(J=!1){if(J&&this.stack)return`${this.message}
3
3
 
4
4
  Stack trace:
5
5
  ${this.stack}`;return this.message}}function vZ(){let{env:J}=kJ,{TERM:Z,TERM_PROGRAM:$}=J;if(kJ.platform!=="win32")return Z!=="linux";return Boolean(J.WT_SESSION)||Boolean(J.TERMINUS_SUBLIME)||J.ConEmuTask==="{cmd::Cmder}"||$==="Terminus-Sublime"||$==="vscode"||Z==="xterm-256color"||Z==="alacritty"||Z==="rxvt-unicode"||Z==="rxvt-unicode-256color"||J.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var UJ="\x1B",T=`${UJ}[`,F$="\x07",C={to(J,Z){if(!Z)return`${T}${J+1}G`;return`${T}${Z+1};${J+1}H`},move(J,Z){let $="";if(J<0)$+=`${T}${-J}D`;else if(J>0)$+=`${T}${J}C`;if(Z<0)$+=`${T}${-Z}A`;else if(Z>0)$+=`${T}${Z}B`;return $},up:(J=1)=>`${T}${J}A`,down:(J=1)=>`${T}${J}B`,forward:(J=1)=>`${T}${J}C`,backward:(J=1)=>`${T}${J}D`,nextLine:(J=1)=>`${T}E`.repeat(J),prevLine:(J=1)=>`${T}F`.repeat(J),left:`${T}G`,hide:`${T}?25l`,show:`${T}?25h`,save:`${UJ}7`,restore:`${UJ}8`},j$={up:(J=1)=>`${T}S`.repeat(J),down:(J=1)=>`${T}T`.repeat(J)},JJ={screen:`${T}2J`,up:(J=1)=>`${T}1J`.repeat(J),down:(J=1)=>`${T}J`.repeat(J),line:`${T}2K`,lineEnd:`${T}K`,lineStart:`${T}1K`,lines(J){let Z="";for(let $=0;$<J;$++)Z+=this.line+($<J-1?C.up():"");if(J)Z+=C.left;return Z}},G$={screen:`${UJ}c`};function SZ(J,Z){let $=[];for(let Q=0;Q<=Z.length;Q++)$[Q]=[Q];for(let Q=0;Q<=J.length;Q++)$[0][Q]=Q;for(let Q=1;Q<=Z.length;Q++)for(let Y=1;Y<=J.length;Y++)if(Z.charAt(Q-1)===J.charAt(Y-1))$[Q][Y]=$[Q-1][Y-1];else $[Q][Y]=Math.min($[Q-1][Y-1]+1,$[Q][Y-1]+1,$[Q-1][Y]+1);return $[Z.length][J.length]}function rJ(J,Z,$=2,Q=3){return Z.map((Y)=>({cmd:Y,distance:SZ(J,Y)})).filter(({distance:Y})=>Y<=$).sort((Y,q)=>Y.distance-q.distance).slice(0,Q).map(({cmd:Y})=>Y)}class aJ{rawName;description;name;names;isBoolean;required;config;negated;constructor(J,Z,$){if(this.rawName=J,this.description=Z,this.config=Object.assign({},$),J=J.replace(/\.\*/g,""),this.negated=!1,this.names=LJ(J).split(",").map((Q)=>{let Y=Q.trim().replace(/^-{1,2}/,"");if(Y.startsWith("no-"))this.negated=!0,Y=Y.replace(/^no-/,"");return lJ(Y)}).sort((Q,Y)=>Q.length>Y.length?1:-1),this.name=this.names[this.names.length-1],this.negated&&this.config.default==null)this.config.default=!0;if(J.includes("<"))this.required=!0;else if(J.includes("["))this.required=!1;else this.isBoolean=!0}}var K$=MJ.argv,yZ=`${MJ.platform}-${MJ.arch} bun-v${typeof Bun<"u"?Bun.version:"unknown"}`,bJ=qJ.argv,gZ=`${qJ.platform}-${qJ.arch} node-${qJ.version}`;class BJ{rawName;description;config;cli;options;aliasNames;name;namespace;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;beforeHooks;afterHooks;middleware;constructor(J,Z,$,Q){this.rawName=J,this.description=Z,this.config=$,this.cli=Q,this.options=[],this.aliasNames=[],this.name=LJ(J);let Y=LJ(J),q=Y.indexOf(":");if(q>0)this.namespace=Y.substring(0,q),this.name=Y.substring(q+1);if(this.args=RZ(J),this.examples=[],this.beforeHooks=[],this.afterHooks=[],this.middleware=[],!$)this.config={}}usage(J){return this.usageText=J,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(J,Z="-v, --version"){return this.versionNumber=J,this.option(Z,"Display version number"),this}example(J){return this.examples.push(J),this}option(J,Z,$){let Q=new aJ(J,Z,$);return this.options.push(Q),this}alias(J){return this.aliasNames.push(J),this}action(J){return this.commandAction=J,this}before(J){return this.beforeHooks.push(J),this}after(J){return this.afterHooks.push(J),this}use(J){return this.middleware.push(J),this}isMatched(J){if(this.aliasNames.includes(J))return!0;if(this.namespace)return`${this.namespace}:${this.name}`===J;return this.name===J}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof EJ}get displayName(){return this.namespace?`${this.namespace}:${this.name}`:this.name}hasOption(J){return J=J.split(".")[0],!!this.options.find((Z)=>{return Z.names.includes(J)})}outputHelp(){let{name:J,commands:Z}=this.cli,{versionNumber:$,options:Q,helpCallback:Y}=this.cli.globalCommand,q=[{body:`${J}${$?`/${$}`:""}`}];if(q.push({title:"Usage",body:` $ ${J} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&Z.length>0){let X=hJ(Z.map((K)=>K.rawName)),j=new Map,G=[];for(let K of Z)if(K.namespace){if(!j.has(K.namespace))j.set(K.namespace,[]);j.get(K.namespace).push(K)}else G.push(K);let V="";if(G.length>0)V+=G.map((K)=>{return` ${VJ(K.rawName,X.length)} ${K.description}`}).join(`