@cldmv/fix-headers 2.2.2 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,36 @@
1
1
  #!/usr/bin/env node
2
- var Yr=Object.defineProperty;var i=(e,t)=>Yr(e,"name",{value:t,configurable:!0});import{realpathSync as Pr}from"node:fs";import{fileURLToPath as Wo,pathToFileURL as Yo}from"node:url";import{readFile as Gr}from"node:fs/promises";import{createRequire as Vr}from"node:module";import{dirname as Jr,isAbsolute as qr,resolve as rt}from"node:path";var Kr=3e4,Xr=new Set(["localhost","127.0.0.1","[::1]"]);function se(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(se,"isPlainObject");function ce(e,t){let r={...e};for(let[n,o]of Object.entries(t))n!=="__proto__"&&(r[n]=se(r[n])&&se(o)?ce(r[n],o):o);return r}i(ce,"mergeConfig");function nt(e){return e.kind==="file"?e.path:e.href}i(nt,"describeSource");async function Zr(e){if(e.kind==="file")return{text:await Gr(e.path,"utf8"),source:e};let t;try{t=await fetch(e.href,{cache:"no-store",redirect:"follow",signal:AbortSignal.timeout(Kr)})}catch(r){let n=r.cause instanceof Error?r.cause.message:r.message;throw new Error(`Failed to fetch config ${e.href}: ${n}`,{cause:r})}if(!t.ok)throw new Error(`Failed to fetch config ${e.href}: HTTP ${t.status} ${t.statusText}`);return{text:await t.text(),source:{kind:"url",href:t.url}}}i(Zr,"readSource");function tt(e){if(e.protocol==="http:"&&!Xr.has(e.hostname))throw new Error(`Refusing to fetch config over plain http: ${e.href} (use https)`);return{kind:"url",href:e.href}}i(tt,"toUrlSource");function Qr(e,t){if(/^https?:\/\//i.test(e))return tt(new URL(e));if(/^[a-z][a-z\d+.-]+:\/\//i.test(e))throw new Error(`Unsupported extends URL "${e}" in ${nt(t)}; use https, a file path or a package path`);let r=/^\.{1,2}[\\/]/.test(e);if(t.kind==="url"){if(r||e.startsWith("/"))return tt(new URL(e,t.href));throw new Error(`Cannot extend package "${e}" from the remote config ${t.href}; use a URL or a relative path`)}if(r||qr(e))return{kind:"file",path:rt(Jr(t.path),e)};try{return{kind:"file",path:Vr(t.path).resolve(e)}}catch(n){throw new Error(`Cannot resolve extends "${e}" from ${t.path}: ${n.message}`,{cause:n})}}i(Qr,"resolveReference");function en(e,t){if(e===void 0)return[];let r=Array.isArray(e)?e:[e];if(!r.every(n=>typeof n=="string"&&n.trim().length>0))throw new Error(`Config "extends" must be a string or an array of strings: ${t}`);return r.map(n=>n.trim())}i(en,"readExtends");async function ot(e,t){let r=nt(e);if(t.includes(r))throw new Error(`Config extends cycle: ${[...t,r].join(" -> ")}`);let{text:n,source:o}=await Zr(e),a;try{a=JSON.parse(n)}catch(u){throw new Error(`Config ${r} is not valid JSON: ${u.message}`,{cause:u})}if(!se(a))throw new Error(`Config file must contain a JSON object: ${r}`);let{extends:s,...c}=a,l={};for(let u of en(s,r))l=ce(l,await ot(Qr(u,o),[...t,r]));return ce(l,c)}i(ot,"loadSource");function tn(e,t=process.cwd()){return ot({kind:"file",path:rt(t,e)},[])}i(tn,"loadConfigFile");async function q(e,t){let r=typeof e[t]=="string"?e[t].trim():"";if(r.length===0)return e;let n=typeof e.cwd=="string"&&e.cwd.length>0?e.cwd:process.cwd(),o={...await tn(r,n),...e};return delete o[t],o}i(q,"applyConfigOption");import{readFile as Mo,stat as Ro,writeFile as Po}from"node:fs/promises";import{relative as Pe,resolve as Lr}from"node:path";import{extname as le}from"node:path";import{extname as rn}from"node:path";var it=[".css"];function nn(e){let t=rn(e).toLowerCase();return it.includes(t)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}i(nn,"resolveCssCommentSyntax");var at={id:"css",extensions:it,enabledByDefault:!0,resolveCommentSyntax(e){return nn(e)}};import{extname as on}from"node:path";var st=[".go"];function an(e){let t=on(e).toLowerCase();return st.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(an,"resolveGoCommentSyntax");var ct={id:"go",extensions:st,enabledByDefault:!0,resolveCommentSyntax(e){return an(e)}};import{extname as sn}from"node:path";var lt=[".html",".htm"];function cn(e){let t=sn(e).toLowerCase();return lt.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}i(cn,"resolveHtmlCommentSyntax");var ut={id:"html",extensions:lt,enabledByDefault:!0,resolveCommentSyntax(e){return cn(e)}};import{extname as ln}from"node:path";var ft=[".jsonv",".jsonc",".json5"];function un(e){let t=ln(e).toLowerCase();return ft.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(un,"resolveJsonCommentSyntax");var dt={id:"json",extensions:ft,enabledByDefault:!0,resolveCommentSyntax(e){return un(e)}};import{extname as fn}from"node:path";var mt=[".md",".markdown"];function dn(e){let t=fn(e).toLowerCase();return mt.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}i(dn,"resolveMarkdownCommentSyntax");function mn(e,t){let r=t.match(/^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/);return r?r[0]:""}i(mn,"resolveMarkdownPreservedPrefix");var pt={id:"markdown",extensions:mt,enabledByDefault:!1,requiresForce:!0,resolvePreservedPrefix(e,t){return mn(e,t)},resolveCommentSyntax(e){return dn(e)}};import{extname as pn}from"node:path";var ht=[".js",".mjs",".cjs",".ts",".tsx",".jsx"];function hn(e){let t=pn(e).toLowerCase();return ht.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(hn,"resolveNodeCommentSyntax");function gn(e,t){let r=t.match(/^#!.*\b(node|bun|deno|tsx|ts-node)\b.*(?:\r?\n|$)/);return r?r[0]:""}i(gn,"resolveNodePreservedPrefix");var gt={id:"node",extensions:ht,enabledByDefault:!0,resolvePreservedPrefix(e,t){return gn(e,t)},resolveCommentSyntax(e){return hn(e)}};import{extname as yn}from"node:path";var yt=[".php"];function xn(e){let t=yn(e).toLowerCase();return yt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(xn,"resolvePhpCommentSyntax");var xt={id:"php",extensions:yt,enabledByDefault:!0,resolveCommentSyntax(e){return xn(e)}};import{extname as wn}from"node:path";var wt=[".py"];function bn(e,t){let r=t.match(/^#!.*\bpython(?:\d+(?:\.\d+)*)?\b.*(?:\r?\n|$)/);return r?r[0]:""}i(bn,"resolvePythonPreservedPrefix");var bt={id:"python",extensions:wt,enabledByDefault:!0,resolvePreservedPrefix(e,t){return bn(e,t)},resolveCommentSyntax(e){let t=wn(e).toLowerCase();return wt.includes(t)?{kind:"line",linePrefix:"#"}:null}};import{extname as kn}from"node:path";var kt=[".rs"];function En(e){let t=kn(e).toLowerCase();return kt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(En,"resolveRustCommentSyntax");var Et={id:"rust",extensions:kt,enabledByDefault:!0,resolveCommentSyntax(e){return En(e)}};import{extname as Sn}from"node:path";var St=[".yaml",".yml"];function $n(e){let t=Sn(e).toLowerCase();return St.includes(t)?{kind:"line",linePrefix:"#"}:null}i($n,"resolveYamlCommentSyntax");var $t={id:"yaml",extensions:St,enabledByDefault:!0,resolveCommentSyntax(e){return $n(e)}};var K=[at,ct,ut,dt,pt,gt,xt,bt,Et,$t],An=new Map(K.map(e=>[e.id,e]));function Dn(e,t){return!t||typeof t!="object"?e:e.kind==="line"?{...e,linePrefix:typeof t.linePrefix=="string"&&t.linePrefix.length>0?t.linePrefix:e.linePrefix,lineSeparator:typeof t.lineSeparator=="string"?t.lineSeparator:e.lineSeparator}:{...e,blockStart:typeof t.blockStart=="string"&&t.blockStart.length>0?t.blockStart:e.blockStart,blockLinePrefix:typeof t.blockLinePrefix=="string"&&t.blockLinePrefix.length>0?t.blockLinePrefix:e.blockLinePrefix,blockEnd:typeof t.blockEnd=="string"&&t.blockEnd.length>0?t.blockEnd:e.blockEnd}}i(Dn,"applySyntaxOverride");function At(e){if(e==null)return[];if(!Array.isArray(e)||e.some(r=>typeof r!="string"))throw new Error(`forcedDetectors must be an array of detector ids, got ${JSON.stringify(e)}`);let t=K.filter(r=>r.requiresForce===!0).map(r=>r.id);for(let r of e){if(!An.has(r))throw new Error(`forcedDetectors: unknown detector "${r}" (force-only detectors: ${t.join(", ")})`);if(!t.includes(r))throw new Error(`forcedDetectors: "${r}" does not need forcing (force-only detectors: ${t.join(", ")})`)}return Array.from(new Set(e))}i(At,"resolveForcedDetectors");function F(e={}){let t=new Set(Array.isArray(e.enabledDetectors)?e.enabledDetectors:[]),r=new Set(Array.isArray(e.disabledDetectors)?e.disabledDetectors:[]),n=new Set(Array.isArray(e.forcedDetectors)?e.forcedDetectors:[]);return K.filter(o=>o.requiresForce===!0?n.has(o.id)&&!r.has(o.id):t.size>0?t.has(o.id):r.has(o.id)?!1:o.enabledByDefault)}i(F,"getEnabledDetectors");function Dt(e={}){if(Array.isArray(e.includeExtensions)&&e.includeExtensions.length>0)return new Set(e.includeExtensions.map(r=>r.toLowerCase()));let t=F(e);return new Set(t.flatMap(r=>r.extensions))}i(Dt,"getAllowedExtensions");function vt(e,t={}){let r=le(e).toLowerCase();if(F(t).some(s=>s.extensions.includes(r)&&s.resolveCommentSyntax(e)!==null))return null;if(r.length===0)return"the file has no extension, so its comment syntax is unknown";let o=new Set(Array.isArray(t.forcedDetectors)?t.forcedDetectors:[]),a=K.find(s=>s.requiresForce===!0&&s.extensions.includes(r)&&!o.has(s.id));return a?`${r} files get a header only when forced (--force-detector ${a.id} / forcedDetectors: ["${a.id}"])`:`no enabled detector handles ${r} files`}i(vt,"getHeaderSkipReason");function Ct(e,t={}){let r=le(e).toLowerCase(),n=Array.isArray(t.detectors)?t.detectors:F(t);for(let o of n){if(!o.extensions.includes(r))continue;let a=o.resolveCommentSyntax(e);if(a){let s=t.detectorSyntaxOverrides&&typeof t.detectorSyntaxOverrides=="object"?t.detectorSyntaxOverrides:{};return Dn(a,s[o.id])}}return{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}}i(Ct,"getCommentSyntaxForFile");function Nt(e,t,r={}){let n=le(e).toLowerCase(),o=F(r);for(let a of o)if(a.extensions.includes(n))return typeof a.resolvePreservedPrefix=="function"?a.resolvePreservedPrefix(e,t):"";return""}i(Nt,"getPreservedPrefixForFile");var Ft=200,B=1,X=2;function j(e,t,r){if(e==null)return r;if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new Error(`${t} must be a whole number of 0 or more, got ${JSON.stringify(e)}`);return e}i(j,"resolveLayoutCount");import{existsSync as Tn}from"node:fs";import{join as ye,relative as Ut,resolve as xe,sep as he}from"node:path";import{realpath as Hn,stat as _n}from"node:fs/promises";import{access as vn,readdir as Cn,readFile as ra,stat as Nn}from"node:fs/promises";import{constants as Fn}from"node:fs";import{dirname as ia,join as jn,resolve as aa}from"node:path";async function ue(e){try{return await vn(e,Fn.F_OK),!0}catch{return!1}}i(ue,"pathExists");async function fe(e,t){let r=[],n=await Cn(e,{withFileTypes:!0});for(let o of n){let a=jn(e,o.name);if(o.isDirectory()&&t.recursive===!1||o.isDirectory()&&t.ignoreFolders.has(o.name)||o.isDirectory()&&await t.shouldSkipDirectory?.(a,o.name)===!0)continue;if(o.isDirectory()){let l=await fe(a,t);r.push(...l);continue}if(!o.isFile())continue;let s=o.name.lastIndexOf(".");if(s===-1)continue;let c=o.name.slice(s).toLowerCase();t.allowedExtensions.has(c)&&r.push(a)}return r}i(fe,"walkFiles");async function jt(e){let t=await Nn(e);return{createdAt:t.birthtimeMs>0&&t.birthtime<t.mtime?t.birthtime:t.mtime,updatedAt:t.mtime}}i(jt,"readFileDates");import{execFile as Ln}from"node:child_process";import{lstat as Mn,readFile as Rn}from"node:fs/promises";import{dirname as Lt,isAbsolute as Pn,join as Pt,relative as It,resolve as de,sep as Ot}from"node:path";import In from"ignore";function Mt(e,t){return new Promise(r=>{Ln("git",t,{cwd:e,encoding:"utf8",maxBuffer:Number.POSITIVE_INFINITY},(n,o)=>{if(!n){r({code:0,stdout:o});return}r({code:typeof n.code=="number"?n.code:-1,stdout:""})})})}i(Mt,"runGitCommand");function pe(e,t){return It(e,t).split(Ot).join("/")}i(pe,"toPosixRelative");async function Tt(e){try{return In().add(await Rn(e,"utf8"))}catch{return null}}i(Tt,"readIgnoreFile");async function On(e){return Mn(Pt(e,".git")).then(()=>!0,()=>!1)}i(On,"hasGitEntry");function Rt(e,t,r){for(let n=e.length-1;n>=0;n--){let{base:o,rules:a}=e[n],s=a.test(`${pe(o,t)}${r?"/":""}`);if(s.ignored||s.unignored)return s.ignored}return!1}i(Rt,"matchesRules");async function Ht(e,t){let r=await Tt(Pt(e,".gitignore"));return{kind:"rules",nested:!0,excluded:!1,matchers:r?[...t,{base:e,rules:r}]:t}}i(Ht,"buildRulesContext");async function me(e){let[t,r]=await Promise.all([Mt(e,["check-ignore","-q","."]),Mt(e,["ls-files","--cached","--others","--exclude-standard","-z"])]);if(t.code!==1||r.code!==0)return Ht(e,[]);let n=new Set,o=new Set;for(let a of r.stdout.split("\0")){let s=a.endsWith("/")?a.slice(0,-1):a;if(s.length!==0){n.add(s);for(let c=s.indexOf("/");c!==-1;c=s.indexOf("/",c+1))o.add(s.slice(0,c))}}return{kind:"git",root:e,entries:n,dirs:o}}i(me,"resolveScopeContext");function _t(e){let t=de(e.root),r=e.gitignore;if(r===!1)return{isIgnored:i(async()=>!1,"isIgnored")};let n=new Map,o=i(async()=>{if(typeof r!="string"&&!Array.isArray(r))return me(t);let c=typeof r=="string"?[r]:r.filter(u=>typeof u=="string"),l=[];for(let u of c){let f=await Tt(de(t,u));f&&l.push({base:t,rules:f})}return{kind:"rules",nested:!1,excluded:!1,matchers:l}},"buildRootContext"),a=i(c=>{let l=n.get(c);return l||(l=c===t?o():s(c),n.set(c,l)),l},"contextFor"),s=i(async c=>{let l=await a(Lt(c));return l.kind==="git"?l.entries.has(pe(l.root,c))?me(c):l:!l.nested||l.excluded?l:Rt(l.matchers,c,!0)?{...l,excluded:!0}:await On(c)?me(c):Ht(c,l.matchers)},"deriveContext");return{async isIgnored(c,l){let u=de(c),f=It(t,u);if(f.length===0||f===".."||f.startsWith(`..${Ot}`)||Pn(f))return!1;let m=await a(Lt(u));if(m.kind==="git"){let g=pe(m.root,u);return!(m.entries.has(g)||l&&m.dirs.has(g))}return m.excluded||Rt(m.matchers,u,l)}}}i(_t,"createIgnoreFilter");function Un(e){return Dt(e)}i(Un,"resolveExtensions");var zn=Object.freeze(["node_modules","bower_components","jspm_packages",".pnpm-store",".yarn"]),Wt=new Set([".git",...zn]),Bn=Object.freeze(["autoload.php","modules.txt"]);function zt(e,t){return Wt.has(t)?!0:t==="vendor"&&Bn.some(r=>Tn(ye(e,r)))}i(zt,"isNeverWalked");function ge(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}i(ge,"normalizeFolderPath");function Wn(e){return Array.isArray(e)?e.map(t=>{if(typeof t=="string")return{path:t,recursive:!0};if(t&&typeof t=="object"&&typeof t.path=="string")return{path:t.path,recursive:t.recursive!==!1};throw new TypeError(`Invalid includeFolders entry: ${JSON.stringify(t)} (expected a path string or { path, recursive? })`)}):[]}i(Wn,"resolveIncludeFolders");function Bt(e,t){let r=t instanceof Error?t.message:String(t);console.warn(`fix-headers: skipped include folder "${e}" (${r})`)}i(Bt,"reportSkippedIncludeFolder");function Yn(e,t){if(!Array.isArray(t)||t.length===0)return()=>!1;let r=xe(e),n=[],o=new Set;for(let a of t){if(typeof a!="string")continue;let s=ge(a);if(s.length!==0){if(s.includes("/")){n.push(xe(r,s));continue}o.add(s)}}return(a,s)=>{if(o.has(s))return!0;for(let l of n)if(a===l||a.startsWith(`${l}/`))return!0;let c=ge(Ut(r,a));return n.some(l=>{let u=ge(Ut(r,l));return c===u||c.startsWith(`${u}/`)})}}i(Yn,"buildExclusionMatcher");async function we(e){let t=Un(e),r=Wn(e.includeFolders),n=Array.isArray(e.excludeFolders)?e.excludeFolders:[],o=Yn(e.projectRoot,n),a=_t({root:e.projectRoot,gitignore:e.gitignore}),s=i(async(d,h)=>zt(d,h)||o(d,h)||await a.isIgnored(d,!0),"shouldSkipDirectory"),c=r.length>0?r.map(d=>({includeFolder:d.path,rootPath:ye(e.projectRoot,d.path),recursive:d.recursive})):[{includeFolder:".",rootPath:e.projectRoot,recursive:!0}],l=[];for(let d of c){let h=await _n(d.rootPath).catch($=>$);if(h instanceof Error){if(h.code==="ENOENT"){Bt(d.includeFolder,h);continue}throw h}if(!h.isDirectory()){Bt(d.includeFolder,`path is not a directory: ${d.rootPath}`);continue}let b=await Hn(d.rootPath).catch(()=>xe(d.rootPath));l.push({...d,realRoot:b})}let u=i((d,h)=>{if(d.realRoot===h.realRoot)return d.recursive||!h.recursive;let b=d.realRoot.endsWith(he)?d.realRoot:`${d.realRoot}${he}`;if(!d.recursive||!h.realRoot.startsWith(b))return!1;let $=d.rootPath;for(let v of h.realRoot.slice(b.length).split(he))if($=ye($,v),zt($,v)||o($,v))return!1;return!0},"covers"),f=[...l].sort((d,h)=>d.realRoot.length-h.realRoot.length||Number(h.recursive)-Number(d.recursive)),m=[];for(let d of f)m.some(h=>u(h,d))||m.push(d);let g=[];for(let d of l){if(!m.includes(d))continue;let h=await fe(d.rootPath,{allowedExtensions:t,ignoreFolders:Wt,shouldSkipDirectory:s,recursive:d.recursive});g.push(...h)}let x=[];for(let d of new Set(g))!o(d,d.split("/").at(-1)||"")&&!await a.isIgnored(d,!1)&&x.push(d);return x}i(we,"discoverFiles");import{basename as xo,dirname as wo,extname as bo,resolve as Ae}from"node:path";import{dirname as rr,isAbsolute as ro,join as nr,relative as no,resolve as or,sep as oo}from"node:path";import{readFile as Gn}from"node:fs/promises";import{join as Vn}from"node:path";async function Jn(e){try{return await Gn(e,"utf8")}catch{return null}}i(Jn,"readManifest");async function A(e,t){let r=[];for(let n of t){let o=await Jn(Vn(e,n));o!==null&&r.push({file:n,content:o})}return r.length>0?{dir:e,manifest:r[0].file,files:r}:null}i(A,"detectManifests");function L(e,t){return e.files.find(r=>r.file===t)?.content??null}i(L,"manifestContent");function w(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}i(w,"cleanName");function be(e){if(typeof e!="string")return;let t=e.search(/[<(]/);return w(t===-1?e:e.slice(0,t))}i(be,"personName");function Z(e){try{return JSON.parse(e)}catch{return}}i(Z,"parseJsonManifest");function*ke(e,t){let r="";for(let n of e.split(/\r?\n/)){let o=n.trim();if(o.startsWith("[")){let a=o.match(/^\[([^[\]]+)\]/);r=a?a[1].split(".").map(s=>s.trim()).join("."):"";continue}r===t&&(yield o)}}i(ke,"sectionLines");function W(e,t,r){let n=new RegExp(`^${r}\\s*=\\s*(?:"([^"\\\\]*)"|'([^']*)')`);for(let o of ke(e,t)){let a=o.match(n);if(a)return w(a[1]??a[2])}}i(W,"readTomlString");function Ee(e,t,r){let n=new RegExp(`^${r}\\s*[=:](.*)$`);for(let o of ke(e,t)){let a=o.match(n);if(a)return w(a[1])}}i(Ee,"readIniValue");function qn(e,t,r){let n=new RegExp(`^${r}\\s*=\\s*\\[`),o=null;for(let a of ke(e,t)){if(o!==null){o.push(a);continue}let s=a.match(n);s&&(o=[a.slice(s[0].length)])}return o===null?null:o.join(`
3
- `)}i(qn,"tomlArrayText");function Kn(e,t){let r=t;for(;r<e.length;)if(e[r]==="#"){let n=e.indexOf(`
4
- `,r);r=n===-1?e.length:n+1}else if(/\s/.test(e[r]))r+=1;else break;return r}i(Kn,"skipTomlSpace");function Y(e,t){let r=qn(e,t,"authors");if(r===null)return;let n=r.slice(Kn(r,0)),o=n.match(/^(?:"([^"\\\n]*)"|'([^'\n]*)')/);if(o)return be(o[1]??o[2]);let s=n.match(/^\{([^}\n]*)\}/)?.[1].match(/(?:^|,)\s*name\s*=\s*(?:"([^"\\\n]*)"|'([^'\n]*)')/);return s?w(s[1]??s[2]):void 0}i(Y,"readTomlAuthor");var Yt=["go.mod"];function Xn(e){let t=e.match(/^\s*module\s+(.+)$/m);if(t)return w(t[1].replace(/\/\/.*$/,"").trim().replace(/^["`](.*)["`]$/,"$1"))}i(Xn,"readModulePath");var Gt={id:"go",languages:["go"],manifests:Yt,detect(e){return A(e,Yt)},read(e){return{name:Xn(e.files[0].content)}}};var Vt=["package.json"];function Zn(e){let t=w(e?.name),r=w(e?.publisher),n=typeof e?.engines?.vscode=="string";return t&&r&&n?`${r}.${t}`:t}i(Zn,"readPublishedName");function Qn(e){if(e!==null&&typeof e=="object"){let t=e;return w(t.company)??w(t.name)}return be(e)}i(Qn,"readAuthorCompany");var Jt={id:"node",languages:["node"],manifests:Vt,detect(e){return A(e,Vt)},read(e){let t=Z(e.files[0].content);return{name:Zn(t),company:Qn(t?.author)}}};var qt=["composer.json"],Kt={id:"php",languages:["php"],manifests:qt,detect(e){return A(e,qt)},read(e){let t=Z(e.files[0].content),r=t?.authors;return{name:w(t?.name),company:Array.isArray(r)?w(r[0]?.name):void 0}}};var Xt=["pyproject.toml","setup.cfg","setup.py"];function Zt(e,t){let r=e.indexOf("setup(");if(r===-1)return;let n=e.slice(r).match(new RegExp(`\\b${t}\\s*=\\s*(["'])([^"'\\n]+)\\1`));return n&&n[2].trim()||void 0}i(Zt,"readSetupPyArgument");function eo(e){let t=L(e,"pyproject.toml"),r=L(e,"setup.cfg"),n=L(e,"setup.py");return(t===null?void 0:W(t,"project","name")??W(t,"tool.poetry","name"))??(r===null?void 0:Ee(r,"metadata","name"))??(n===null?void 0:Zt(n,"name"))}i(eo,"readPythonName");function to(e){let t=L(e,"pyproject.toml"),r=L(e,"setup.cfg"),n=L(e,"setup.py");return(t===null?void 0:Y(t,"project")??Y(t,"tool.poetry"))??(r===null?void 0:Ee(r,"metadata","author"))??(n===null?void 0:Zt(n,"author"))}i(to,"readPythonCompany");var Qt={id:"python",languages:["python"],manifests:Xt,detect(e){return A(e,Xt)},read(e){return{name:eo(e),company:to(e)}}};var er=["Cargo.toml"],tr={id:"rust",languages:["rust"],manifests:er,detect(e){return A(e,er)},read(e){let t=e.files[0].content;return{name:W(t,"package","name"),company:Y(t,"package")}}};var io=[Jt,Qt,Kt,tr,Gt],ir=["name","company"];async function Se(e,t,r){let o=(await Promise.all(t.map(async s=>({driver:s,detection:await s.detect(e)})))).filter(s=>s.detection!==null),a=o.filter(s=>typeof r=="string"&&s.driver.languages.includes(r));return[...a,...o.filter(s=>!a.includes(s))]}i(Se,"claimFolder");function ao(e,t){let r=no(t,e);return r!==""&&r!==".."&&!r.startsWith(`..${oo}`)&&!ro(r)}i(ao,"isStrictlyInside");async function ar(e,t={}){let r=Array.isArray(t.drivers)?t.drivers:io,n=typeof t.scanRoot=="string"?or(t.scanRoot):null,o=or(e),a=await Se(o,r,t.language);for(;a.length===0;){if(await ue(nr(o,".git")))return{root:o,marker:".git",drivers:[],fields:{},sources:{}};let f=rr(o);if(f===o)return null;o=f,a=await Se(o,r,t.language)}let s={},c={},l=o,u=a;for(;;){for(let{driver:m,detection:g}of u){let x=m.read(g);for(let d of ir)s[d]===void 0&&x[d]!==void 0&&(s[d]=x[d],c[d]={driver:m.id,manifest:g.manifest,dir:l})}if(ir.every(m=>s[m]!==void 0)||n===null||!ao(l,n)||await ue(nr(l,".git")))break;l=rr(l),u=await Se(l,r,t.language)}return{root:o,marker:a[0].detection.manifest,drivers:a.map(f=>f.driver.id),fields:s,sources:c}}i(ar,"resolveManifestProject");import{execFile as so}from"node:child_process";import{basename as co,dirname as lo}from"node:path";import{promisify as uo}from"node:util";var $e=uo(so);async function S(e,t){try{let{stdout:r}=await $e("git",t,{cwd:e}),n=r.trim();return n.length>0?n:null}catch{return null}}i(S,"runGit");function sr(e,t){let r=0;for(let n=t-1;n>=0&&e[n]==="\\";n--)r++;return r%2===1}i(sr,"isEscaped");function fo(e){let t=e.trim();if(!t.endsWith(")")||sr(t,t.length-1))return t;let r=0;for(let n=t.length-1;n>=0;n--){let o=t[n];if(!(o!=="("&&o!==")"||sr(t,n))&&(r+=o===")"?1:-1,r===0))return t.slice(0,n).trim()}return t}i(fo,"stripUidComment");function mo(e){let t=e.trim();if(t.length===0)return{authorName:null,authorEmail:null};let r=t.match(/<([^>\n]+)>\s*$/),n=r?.[1]?.trim()||null,o=(r?t.slice(0,r.index):t).trim();return{authorName:fo(o)||o||null,authorEmail:n}}i(mo,"parseSignerUid");async function po(e,t){try{let{stdout:r}=await $e(e,t),n=r.trim();return n.length>0?n:null}catch{return null}}i(po,"runProgram");function ho(e){return e.replace(/\\x([0-9a-fA-F]{2})/g,(t,r)=>String.fromCharCode(Number.parseInt(r,16)))}i(ho,"decodeColonField");async function go(e){let t=await S(e,["config","--get","gpg.format"]);if(t!==null&&t!=="openpgp")return null;let r=await S(e,["config","--get","user.signingkey"]);if(!r)return null;let n=await S(e,["config","--get","gpg.openpgp.program"])||await S(e,["config","--get","gpg.program"])||"gpg",o=await po(n,["--batch","--with-colons","--list-keys",r]);if(!o)return null;for(let a of o.split(`
5
- `)){let s=a.split(":");if(s[0]==="uid"&&s[1]!=="r"&&s[1]!=="e"&&s[9])return ho(s[9])}return null}i(go,"readSigningKeyUid");async function cr(e,t={}){let r=await S(e,["config","--get","user.name"]),n=await S(e,["config","--get","user.email"]);if(t.useGpgSignerAuthor===!0){let o=await go(e)||await S(e,["log","-1","--format=%GS"]),a=mo(o||"");r=a.authorName||r,n=n||a.authorEmail}if(!r||!n){let o=await S(e,["log","-1","--format=%an|%ae"]);if(o){let[a,s]=o.split("|");r=r||a||null,n=n||s||null}}return{authorName:r,authorEmail:n}}i(cr,"detectGitAuthor");function lr(e){return e.replace(/z$/i,"+00:00")}i(lr,"canonicalGitDate");async function ur(e,t){let r=await S(e,["log","--follow","--format=%aI|%at","--reverse","--",t]);if(!r)return null;let n=r.split(`
6
- `)[0],[o,a]=n.split("|");if(!o||!a)return null;let s=Number.parseInt(a,10);return Number.isNaN(s)?null:{date:lr(o),timestamp:s}}i(ur,"getGitCreationDate");async function fr(e,t){let r=await S(e,["log","-1","--format=%aI|%at","--",t]);if(!r)return null;let[n,o]=r.split("|");if(!n||!o)return null;let a=Number.parseInt(o,10);return Number.isNaN(a)?null:{date:lr(n),timestamp:a}}i(fr,"getGitLastModifiedDate");var yo=256*1024*1024;async function dr(e){let t=lo(e);if(await S(t,["rev-parse","--is-inside-work-tree"])!=="true")return{state:"no-git",content:null};try{let{stdout:r}=await $e("git",["show",`HEAD:./${co(e)}`],{cwd:t,encoding:"utf8",maxBuffer:yo});return{state:"tracked",content:r}}catch{return{state:"untracked",content:null}}}i(dr,"readGitHeadFile");function ko(e){return xo(e)||"project"}i(ko,"folderName");function Eo(e,t){if(typeof t!="string")return e;let r=t.trim();return r.length===0||/<[^>]+>/.test(e)?e:`${e} <${r}>`}i(Eo,"formatAuthorNameWithCompany");async function So(e,t={}){let r=Array.isArray(t.detectors)?t.detectors:F(t),n=typeof t.preferredExtension=="string"?t.preferredExtension.trim().toLowerCase():"",o=n.length>0?r.find(u=>u.extensions.includes(n)):void 0,a=await ar(e,{drivers:t.drivers,language:o?.id,scanRoot:t.scanRoot}),s=a?a.root:Ae(e),c=a?.sources.name,l=a?.sources.company;return{language:o?.id??a?.drivers[0]??"unknown",rootDir:s,marker:a?a.marker:null,projectName:a?.fields.name??ko(s),projectNameSource:c?{from:"manifest",...c}:{from:"folder",dir:s},companyName:a?.fields.company??null,companyNameSource:l?{from:"manifest",...l}:{from:"none"},drivers:a?a.drivers:[]}}i(So,"detectProjectFromMarkers");async function De(e={}){let t=e.targetFilePath||e.cwd||process.cwd(),r=Ae(t),n=F(e),o=e.targetFilePath?wo(r):r,a=e.targetFilePath?bo(r).toLowerCase():"",s=Ae(e.projectRoot||e.cwd||process.cwd()),c=await So(o,{detectors:n,preferredExtension:a,scanRoot:s}),l=await cr(c.rootDir,{useGpgSignerAuthor:e.useGpgSignerAuthor===!0}),u=e.authorName||l.authorName||"Unknown Author",f=typeof e.companyName=="string"?e.companyName.trim():"";return{projectName:e.projectName||c.projectName,projectNameSource:e.projectName?{from:"option"}:c.projectNameSource,language:e.language||c.language,projectRoot:e.projectRoot||c.rootDir,marker:e.marker===void 0?c.marker:e.marker,authorName:Eo(u,e.company),authorEmail:e.authorEmail||l.authorEmail||"unknown@example.com",companyName:f||c.companyName,companyNameSource:f?{from:"option"}:c.companyNameSource,copyrightStartYear:Number.isInteger(e.copyrightStartYear)?Number(e.copyrightStartYear):null}}i(De,"resolveProjectMetadata");function $o(e){return ve({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),offsetMinutes:-e.getTimezoneOffset()})}i($o,"formatDateWithTimezone");function ve(e){return`${gr(e," ")} ${yr(e.offsetMinutes)}`}i(ve,"formatSpaceDate");function pr(e){if(typeof e!="string")throw new Error(`timezone must be an IANA time zone name string, such as "America/Los_Angeles" or "UTC" (got ${typeof e})`);try{hr(e)}catch(t){throw new Error(`Unknown time zone "${e}": expected an IANA time zone name, such as "America/Los_Angeles" or "UTC"`,{cause:t})}return e}i(pr,"assertTimeZone");var mr=new Map;function hr(e){let t=mr.get(e);return t||(t=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),mr.set(e,t)),t}i(hr,"getZoneFormatter");function Ce(e,t){let r={};for(let o of hr(t).formatToParts(new Date(e*1e3)))r[o.type]=Number(o.value);let n=Date.UTC(r.year,r.month-1,r.day,r.hour,r.minute,r.second)/1e3;return{year:r.year,month:r.month,day:r.day,hour:r.hour,minute:r.minute,second:r.second,offsetMinutes:(n-e)/60}}i(Ce,"toZonedDateParts");function gr(e,t){let r=i(n=>String(n).padStart(2,"0"),"pad");return`${String(e.year).padStart(4,"0")}-${r(e.month)}-${r(e.day)}${t}${r(e.hour)}:${r(e.minute)}:${r(e.second)}`}i(gr,"formatWallClock");function yr(e){let t=i(n=>String(n).padStart(2,"0"),"pad"),r=Math.abs(e);return`${e>=0?"+":"-"}${t(Math.floor(r/60))}:${t(r%60)}`}i(yr,"formatOffset");function Q(e=new Date){return{date:$o(e),timestamp:Math.floor(e.getTime()/1e3)}}i(Q,"toDatePayload");var Ao=/^(\d{4})-(\d{2})-(\d{2})(?:T|\s+)(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?\s*(?:(Z)|([+-])(\d{2}):?(\d{2}))$/i;function M(e){let t=Ao.exec(e.trim());if(!t)return null;let[r,n,o,a,s,c]=t.slice(1,7).map(Number),l=t[7]?0:Number(t[9])*60+Number(t[10]),u=t[8]==="-"?-l:l,f=new Date(Date.UTC(r,n-1,o,a,s,c));return!(f.getUTCFullYear()===r&&f.getUTCMonth()===n-1&&f.getUTCDate()===o&&f.getUTCHours()===a&&f.getUTCMinutes()===s&&f.getUTCSeconds()===c)||Number(t[10]??0)>59?null:{year:r,month:n,day:o,hour:a,minute:s,second:c,offsetMinutes:u,timestamp:Math.floor(f.getTime()/1e3)-u*60}}i(M,"parseHeaderDate");function Ne(e){return`${gr(e,"T")}${yr(e.offsetMinutes)}`}i(Ne,"formatIsoDate");var Do={"git-created":"git first commit","filesystem-created":"filesystem creation time"};function xr(e,t){let r=e.match(new RegExp(`${t}:[^\\S\\n]*(.*)$`,"m"));return r?r[1].trim():null}i(xr,"readHeaderField");function Fe(e){let t=null;for(let{source:r,payload:n}of e)n&&(!t||n.timestamp<t.payload.timestamp)&&(t={source:r,payload:n});return t}i(Fe,"pickOldestDate");function br({existing:e,gitCreated:t,filesystemCreated:r,fixCreatedDate:n=!1}){let o=[{source:"git-created",payload:t},{source:"filesystem-created",payload:r}];if(!e)return Fe(o);if(!n)return{source:"existing-header",payload:e};let a=M(e.date)?e:null;return Fe([{source:"existing-header",payload:a},...o])}i(br,"resolveCreatedDate");function kr(e,t=null){if(t)return Ce(e.timestamp,t).year;let r=M(e.date);return r?r.year:new Date(e.timestamp*1e3).getFullYear()}i(kr,"dateYear");function wr(e,t,r,n){let o=e.match(/^(.+?)\s*\((\d+)\)$/),a=o?M(o[1]):null;if(!o||!a)return n.push({check:`${r}-format`,field:t,advisory:!1,value:e,message:`${t} value "${e}" is not a "<datetime> (<epoch>)" pair with a recognised datetime`}),null;let s=Number.parseInt(o[2],10);return s!==a.timestamp&&n.push({check:`${r}-epoch`,field:t,advisory:!1,value:e,expected:`${o[1]} (${a.timestamp})`,message:`${t} epoch ${s} does not match ${o[1]} (expected ${a.timestamp})`}),{text:o[1],timestamp:a.timestamp}}i(wr,"checkDateValue");function Er(e,t={},r={}){let n=[],o=xr(e,"@Date"),a=o===null?null:wr(o,"@Date","created",n),s=Fe([{source:"git-created",payload:t.gitCreated},{source:"filesystem-created",payload:t.filesystemCreated}]);if(a&&s&&a.timestamp>s.payload.timestamp){let f=Do[s.source];n.push({check:"created-newer-than-source",field:"@Date",advisory:r.strictCreatedDate!==!0,value:o,expected:`${s.payload.date} (${s.payload.timestamp})`,source:s.source,message:`@Date ${a.text} is later than the ${f} ${s.payload.date} (${s.payload.timestamp})`})}let c=xr(e,"@Last modified time"),l=c===null?null:wr(c,"@Last modified time","modified",n),u=t.gitLastModified;return l&&u&&l.timestamp!==u.timestamp&&n.push({check:"modified-git",field:"@Last modified time",advisory:!0,value:c,expected:`${u.date} (${u.timestamp})`,message:`@Last modified time ${l.text} does not match the git last commit ${u.date} (${u.timestamp})`}),n}i(Er,"checkHeaderDates");function je(e){if(!e)return null;let t=M(e.date);return t&&t.timestamp!==e.timestamp?{date:e.date,timestamp:t.timestamp}:e}i(je,"repairDateEpoch");function Sr(e){let t=M(e.date);return t?{date:Ne(t),timestamp:t.timestamp}:e}i(Sr,"normalizeDatePayload");function $r(e,t){let r=M(e.date);if(!r)return e;let n=Ce(r.timestamp,t);return n.offsetMinutes===r.offsetMinutes||!Number.isInteger(n.offsetMinutes)?e:{date:/^\d{4}-\d{2}-\d{2}T/i.test(e.date.trim())?Ne(n):ve(n),timestamp:r.timestamp}}i($r,"convertDatePayload");import{relative as Co}from"node:path";import{extname as vo}from"node:path";function G(e,t={}){let r=vo(e).toLowerCase(),n=j(t.spacing,"spacing",B);return r.length===0?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */",spacing:n}:{...Ct(e,t),spacing:n}}i(G,"getHeaderSyntaxForFile");function Ar(e,t){let r=e.spacing??B;if(e.kind==="line"){let c=e.linePrefix||"#",l=typeof e.lineSeparator=="string"?e.lineSeparator:" ",u=Array.from({length:r},()=>c);return[...u,...t.map(f=>`${c}${l}${f}`),...u].join(`
7
- `)}let n=e.blockStart||(e.kind==="html"?"<!--":"/**"),o=e.blockLinePrefix||(e.kind==="html"?" ":" * "),a=e.blockEnd||(e.kind==="html"?"-->":" */"),s=Array.from({length:r},()=>o.trimEnd());return[n,...s,...t.map(c=>`${o}${c}`),...s,a].join(`
8
- `)}i(Ar,"renderHeaderLines");function Dr(e){let t=`/${Co(e.projectRoot,e.absoluteFilePath).replace(/\\/g,"/")}`,r=G(e.absoluteFilePath,e.syntaxOptions||{language:e.language}),n=e.createdByName||e.authorName,o=e.createdByEmail||e.authorEmail,a=e.lastModifiedByName||e.authorName,s=e.lastModifiedByEmail||e.authorEmail,c=typeof e.companyName=="string"?e.companyName.trim():"",l=c.length>0?`${c} `:"",u=[`@Project: ${e.projectName}`,`@Filename: ${t}`,`@Date: ${e.createdAt.date} (${e.createdAt.timestamp})`,`@Author: ${n}`,`@Email: <${o}>`,"-----",`@Last modified by: ${a} (${s})`,`@Last modified time: ${e.lastModifiedAt.date} (${e.lastModifiedAt.timestamp})`,"-----",`@Copyright: Copyright (c) ${e.copyrightStartYear}-${e.currentYear} ${l}All rights reserved.`];return Ar(r,u)}i(Dr,"buildHeader");var No=Object.freeze(["projectName","filename","createdAt","authorName","authorEmail","lastModifiedByName","lastModifiedByEmail","lastModifiedAt","copyrightStartYear","copyrightEndYear","companyName"]);function C(e,t){let r=e.match(new RegExp(`@${t}:[ \\t]*(.*)$`,"m")),n=r?r[1].trim():"";return n.length>0?n:null}i(C,"readTag");function Fo(e){if(e===null)return{name:null,email:null};if(!e.endsWith(")"))return{name:e,email:null};let t=e.slice(0,-1),r=t.indexOf("(",t.lastIndexOf(")")+1);return r===-1?{name:e,email:null}:{name:t.slice(0,r).trimEnd()||null,email:t.slice(r+1)||null}}i(Fo,"splitLastModifiedBy");function jo(e){let t={startYear:null,endYear:null,companyName:null},r=e?.match(/^Copyright\s+\(c\)\s+(\d{4})/i);if(!r)return t;let n=e.slice(r[0].length),o=n.match(/^\s*-\s*(\d{4})/);o&&(n=n.slice(o[0].length));let a=n.toLowerCase(),s=a.endsWith("all rights reserved.")?20:a.endsWith("all rights reserved")?19:0;return s===0||!/^\s/.test(n)?t:{startYear:r[1],endYear:o?o[1]:null,companyName:n.slice(0,-s).trim()||null}}i(jo,"splitCopyright");function vr(e){let t=Fo(C(e,"Last modified by")),r=jo(C(e,"Copyright")),n=C(e,"Email");return{projectName:C(e,"Project"),filename:C(e,"Filename"),createdAt:C(e,"Date"),authorName:C(e,"Author"),authorEmail:n===null?null:n.replace(/^<(.*)>$/,"$1"),lastModifiedByName:t.name,lastModifiedByEmail:t.email,lastModifiedAt:C(e,"Last modified time"),copyrightStartYear:r.startYear,copyrightEndYear:r.endYear,companyName:r.companyName}}i(vr,"parseHeaderFields");function Cr(e,t){let r=vr(e??""),n=vr(t);return No.filter(o=>r[o]!==n[o]).map(o=>({field:o,previous:r[o],detected:n[o]}))}i(Cr,"compareHeaderFields");function ee(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}i(ee,"escapeRegex");function Le(e,t,r={}){let n=Nt(e,t,r);return n.length===0?{prefix:"",body:t}:{prefix:n,body:t.slice(n.length)}}i(Le,"splitPreservedPrefix");function Nr(e,t){if(t.kind==="html"){let n=ee(t.blockStart||"<!--"),o=ee(t.blockEnd||"-->");return e.match(new RegExp(`^${n}[\\s\\S]*?${o}\\n*`))}if(t.kind==="line"){let n=ee(t.linePrefix||"#");return e.match(new RegExp(`^(?:${n}.*\\n)+\\n*`))}let r=ee((t.blockEnd||" */").trim());return e.match(new RegExp(`^/\\*[\\s\\S]*?${r}\\n*`))}i(Nr,"matchHeaderSegment");function te(e,t="",r={}){let{prefix:n,body:o}=Le(t,e,r),a=o.split(`
9
- `).slice(0,Ft).join(`
10
- `),s=G(t,r);if(!Nr(a,s))return null;let l=0,u=0;for(;;){let f=a.slice(l),m=Nr(f,s);if(!m||!m[0].includes("@Project:"))break;l+=m[0].length,u=l}return u===0?null:{start:n.length,end:n.length+u}}i(te,"findProjectHeader");function Me(e,t,r="",n={}){let o=te(e,r,n),a=j(n.margin,"margin",X),s=G(r,n).kind==="line"?Math.max(1,a):a,c=`
11
- `.repeat(s+1),l=i(g=>g.trim()===""?`${t}
12
- `:`${t}${c}${g}`,"join");if(!o){let{prefix:g,body:x}=Le(r,e,n),d=`${g}${l(x.replace(/^\n+/,""))}`;return{nextContent:d,changed:d!==e}}let u=e.slice(0,o.start),f=e.slice(o.end).replace(/^\n+/,""),m=`${u}${l(f)}`;return{nextContent:m,changed:m!==e}}i(Me,"replaceOrInsertHeader");function Re(e,t="",r={}){let n=te(e,t,r),{prefix:o,body:a}=n?{prefix:e.slice(0,n.start),body:e.slice(n.end)}:Le(t,e,r),s=a.replace(/^\n+/,"");return`${o}${s.trim()===""?"":s}`}i(Re,"extractHeaderlessBody");function Lo(e,t){let r=e.length,n=t.length,o=Array.from({length:r+1},()=>new Array(n+1).fill(0));for(let l=r-1;l>=0;l-=1)for(let u=n-1;u>=0;u-=1)o[l][u]=e[l]===t[u]?o[l+1][u+1]+1:Math.max(o[l+1][u],o[l][u+1]);let a=[],s=0,c=0;for(;s<r&&c<n;)e[s]===t[c]?(a.push({type:" ",line:e[s]}),s+=1,c+=1):o[s+1][c]>=o[s][c+1]?(a.push({type:"-",line:e[s]}),s+=1):(a.push({type:"+",line:t[c]}),c+=1);for(;s<r;s+=1)a.push({type:"-",line:e[s]});for(;c<n;c+=1)a.push({type:"+",line:t[c]});return a}i(Lo,"diffLines");function Fr(e,t){return`${t===0?e:e+1},${t}`}i(Fr,"formatRange");function jr(e,t,r={}){let n=e===null?[]:e.split(`
2
+ var pr=Object.defineProperty;var s=(e,t)=>pr(e,"name",{value:t,configurable:!0});import{realpathSync as tr}from"node:fs";import{fileURLToPath as Ei,pathToFileURL as $i}from"node:url";import{readFile as hr}from"node:fs/promises";import{createRequire as gr}from"node:module";import{dirname as yr,isAbsolute as xr,resolve as ft}from"node:path";var wr=3e4,br=new Set(["localhost","127.0.0.1","[::1]"]);function we(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(we,"isPlainObject");function be(e,t){let n={...e};for(let[r,o]of Object.entries(t))r!=="__proto__"&&(n[r]=we(n[r])&&we(o)?be(n[r],o):o);return n}s(be,"mergeConfig");function mt(e){return e.kind==="file"?e.path:e.href}s(mt,"describeSource");async function kr(e){if(e.kind==="file")return{text:await hr(e.path,"utf8"),source:e};let t;try{t=await fetch(e.href,{cache:"no-store",redirect:"follow",signal:AbortSignal.timeout(wr)})}catch(n){let r=n.cause instanceof Error?n.cause.message:n.message;throw new Error(`Failed to fetch config ${e.href}: ${r}`,{cause:n})}if(!t.ok)throw new Error(`Failed to fetch config ${e.href}: HTTP ${t.status} ${t.statusText}`);return{text:await t.text(),source:{kind:"url",href:t.url}}}s(kr,"readSource");function dt(e){if(e.protocol==="http:"&&!br.has(e.hostname))throw new Error(`Refusing to fetch config over plain http: ${e.href} (use https)`);return{kind:"url",href:e.href}}s(dt,"toUrlSource");function Er(e,t){if(/^https?:\/\//i.test(e))return dt(new URL(e));if(/^[a-z][a-z\d+.-]+:\/\//i.test(e))throw new Error(`Unsupported extends URL "${e}" in ${mt(t)}; use https, a file path or a package path`);let n=/^\.{1,2}[\\/]/.test(e);if(t.kind==="url"){if(n||e.startsWith("/"))return dt(new URL(e,t.href));throw new Error(`Cannot extend package "${e}" from the remote config ${t.href}; use a URL or a relative path`)}if(n||xr(e))return{kind:"file",path:ft(yr(t.path),e)};try{return{kind:"file",path:gr(t.path).resolve(e)}}catch(r){throw new Error(`Cannot resolve extends "${e}" from ${t.path}: ${r.message}`,{cause:r})}}s(Er,"resolveReference");function $r(e,t){if(e===void 0)return[];let n=Array.isArray(e)?e:[e];if(!n.every(r=>typeof r=="string"&&r.trim().length>0))throw new Error(`Config "extends" must be a string or an array of strings: ${t}`);return n.map(r=>r.trim())}s($r,"readExtends");async function pt(e,t){let n=mt(e);if(t.includes(n))throw new Error(`Config extends cycle: ${[...t,n].join(" -> ")}`);let{text:r,source:o}=await kr(e),i;try{i=JSON.parse(r)}catch(d){throw new Error(`Config ${n} is not valid JSON: ${d.message}`,{cause:d})}if(!we(i))throw new Error(`Config file must contain a JSON object: ${n}`);let{extends:a,...c}=i,l={};for(let d of $r(a,n))l=be(l,await pt(Er(d,o),[...t,n]));return be(l,c)}s(pt,"loadSource");function Sr(e,t=process.cwd()){return pt({kind:"file",path:ft(t,e)},[])}s(Sr,"loadConfigFile");async function re(e,t){let n=typeof e[t]=="string"?e[t].trim():"";if(n.length===0)return e;let r=typeof e.cwd=="string"&&e.cwd.length>0?e.cwd:process.cwd(),o={...await Sr(n,r),...e};return delete o[t],o}s(re,"applyConfigOption");import{readFile as di,stat as fi,writeFile as mi}from"node:fs/promises";import{relative as Ve,resolve as Zn}from"node:path";import{extname as ke}from"node:path";import{extname as Ar}from"node:path";var ht=[".css"];function Dr(e){let t=Ar(e).toLowerCase();return ht.includes(t)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}s(Dr,"resolveCssCommentSyntax");var gt={id:"css",extensions:ht,enabledByDefault:!0,keepsAboveHeader:s((e,t)=>t===0&&/^@charset "[^"]*";/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return Dr(e)}};import{extname as Fr}from"node:path";var Cr=/^(?:#|\/\/|\/\*+|<!--)[ \t]+(vi|vim(?:[<=>]?\d+)?|Vim|ex):(.*)$/,vr=/^[a-z]+(?:[!&]|[+^-]?=(?:\\.|[^\s:\\])*)?$/,Nr=new Set(["et","expandtab","ai","autoindent","si","smartindent","ro","readonly","bin","binary","noet","noexpandtab","noai","noautoindent","nosi","nosmartindent","noro","noreadonly","nobin","nobinary","nowrap","nolist","nospell","nofen","nofoldenable","noeol","nofixeol","nofixendofline"]);function oe(e){let t=e.match(Cr);if(!t)return!1;let n=t[2].trim();if(n.endsWith("-->"))n=n.slice(0,-3).trimEnd();else if(n.endsWith("*/")){let i=n.length-2;for(;i>0&&n[i-1]==="*";)i-=1;n=n.slice(0,i).trimEnd()}let r=n.match(/^se(?:t)?[ \t]((?:\\.|[^:\\])*):/);if(!r&&t[1]==="Vim")return!1;let o=r?r[1].match(/(?:\\.|[^\s\\])+/g):n.match(/(?:\\.|[^\s:\\])+/g);return o!==null&&o.every(i=>vr.test(i))&&o.some(i=>i.includes("=")||Nr.has(i))}s(oe,"isModeline");function ie(e,t){return t===0&&e.startsWith("#!")}s(ie,"isShebang");function se(e,t,n=0){let r=0,o=n;for(;r<e.length;){let i=e.indexOf(`
3
+ `,r),a=i===-1?e.length:i+1;if(!t(e.slice(r,a).replace(/\r?\n$/,""),o))break;r=a,o+=1}return e.slice(0,r)}s(se,"takeTopLines");var xt=[".go"];function Lr(e){let t=Fr(e).toLowerCase();return xt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}s(Lr,"resolveGoCommentSyntax");var yt=/^\/\/(?:go:build|\s*\+build)\s/;function jr(e,t){let n=se(t,o=>yt.test(o)||oe(o));if(!n.split(/\r?\n/).some(o=>yt.test(o)))return"";let r=t.slice(n.length);return`${n}${r.slice(0,r.length-r.replace(/^(?:[ \t]*\r?\n)*/,"").length)}`}s(jr,"resolveGoPreservedPrefix");var wt={id:"go",extensions:xt,enabledByDefault:!0,resolvePreservedPrefix(e,t){return jr(e,t)},resolveCommentSyntax(e){return Lr(e)}};import{extname as Mr}from"node:path";var bt=[".html",".htm"];function Rr(e){let t=Mr(e).toLowerCase();return bt.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}s(Rr,"resolveHtmlCommentSyntax");var kt={id:"html",extensions:bt,enabledByDefault:!0,resolveCommentSyntax(e){return Rr(e)}};import{extname as Pr}from"node:path";var Et=[".jsonv",".jsonc",".json5"];function Ir(e){let t=Pr(e).toLowerCase();return Et.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}s(Ir,"resolveJsonCommentSyntax");var $t={id:"json",extensions:Et,enabledByDefault:!0,resolveCommentSyntax(e){return Ir(e)}};import{extname as Or}from"node:path";var St=[".md",".markdown"];function Tr(e){let t=Or(e).toLowerCase();return St.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}s(Tr,"resolveMarkdownCommentSyntax");function Hr(e,t){let n=t.match(/^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/);return n?n[0]:""}s(Hr,"resolveMarkdownPreservedPrefix");var At={id:"markdown",extensions:St,enabledByDefault:!1,requiresForce:!0,resolvePreservedPrefix(e,t){return Hr(e,t)},resolveCommentSyntax(e){return Tr(e)}};import{extname as _r}from"node:path";var Dt=[".js",".mjs",".cjs",".ts",".tsx",".jsx"];function Ur(e){let t=_r(e).toLowerCase();return Dt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}s(Ur,"resolveNodeCommentSyntax");var Ct={id:"node",extensions:Dt,enabledByDefault:!0,keepsAboveHeader:ie,resolveCommentSyntax(e){return Ur(e)}};import{extname as Br}from"node:path";var Nt=[".php"];function zr(e){let t=Br(e).toLowerCase();return Nt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}s(zr,"resolvePhpCommentSyntax");var vt=/^<\?php(?:\s|$)/i,Ft={id:"php",extensions:Nt,enabledByDefault:!0,keepsAboveHeader:s((e,t)=>t===0&&vt.test(e),"keepsAboveHeader"),resolveContentSkipReason(e){return vt.test(e.replace(/^\uFEFF/,""))?null:"the file does not start with <?php, so a comment at the top would be output as text"},resolveCommentSyntax(e){return zr(e)}};import{extname as Wr}from"node:path";var Lt=[".py"],Gr=/^#.*?(?<![A-Za-z])coding[:=]\s*[-\w.]+/;function Yr(e,t){return ie(e,t)||t<=1&&Gr.test(e)}s(Yr,"keepsAboveHeader");var jt={id:"python",extensions:Lt,enabledByDefault:!0,keepsAboveHeader:Yr,resolveCommentSyntax(e){let t=Wr(e).toLowerCase();return Lt.includes(t)?{kind:"line",linePrefix:"#"}:null}};import{extname as Vr}from"node:path";var Mt=[".rs"];function Jr(e){let t=Vr(e).toLowerCase();return Mt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}s(Jr,"resolveRustCommentSyntax");var Rt={id:"rust",extensions:Mt,enabledByDefault:!0,keepsAboveHeader:s((e,t)=>t===0&&e.startsWith("#!")&&!/^#!\s*\[/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return Jr(e)}};import{extname as qr}from"node:path";var Pt=[".yaml",".yml"];function Kr(e){let t=qr(e).toLowerCase();return Pt.includes(t)?{kind:"line",linePrefix:"#"}:null}s(Kr,"resolveYamlCommentSyntax");var It={id:"yaml",extensions:Pt,enabledByDefault:!0,keepsAboveHeader:s((e,t)=>t===0&&/^#cloud-config\s*$/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return Kr(e)}};var ae=[gt,wt,kt,$t,At,Ct,Ft,jt,Rt,It],Zr=new Map(ae.map(e=>[e.id,e]));function Xr(e,t){return!t||typeof t!="object"?e:e.kind==="line"?{...e,linePrefix:typeof t.linePrefix=="string"&&t.linePrefix.length>0?t.linePrefix:e.linePrefix,lineSeparator:typeof t.lineSeparator=="string"?t.lineSeparator:e.lineSeparator}:{...e,blockStart:typeof t.blockStart=="string"&&t.blockStart.length>0?t.blockStart:e.blockStart,blockLinePrefix:typeof t.blockLinePrefix=="string"&&t.blockLinePrefix.length>0?t.blockLinePrefix:e.blockLinePrefix,blockEnd:typeof t.blockEnd=="string"&&t.blockEnd.length>0?t.blockEnd:e.blockEnd}}s(Xr,"applySyntaxOverride");function Ot(e){if(e==null)return[];if(!Array.isArray(e)||e.some(n=>typeof n!="string"))throw new Error(`forcedDetectors must be an array of detector ids, got ${JSON.stringify(e)}`);let t=ae.filter(n=>n.requiresForce===!0).map(n=>n.id);for(let n of e){if(!Zr.has(n))throw new Error(`forcedDetectors: unknown detector "${n}" (force-only detectors: ${t.join(", ")})`);if(!t.includes(n))throw new Error(`forcedDetectors: "${n}" does not need forcing (force-only detectors: ${t.join(", ")})`)}return Array.from(new Set(e))}s(Ot,"resolveForcedDetectors");function O(e={}){let t=new Set(Array.isArray(e.enabledDetectors)?e.enabledDetectors:[]),n=new Set(Array.isArray(e.disabledDetectors)?e.disabledDetectors:[]),r=new Set(Array.isArray(e.forcedDetectors)?e.forcedDetectors:[]);return ae.filter(o=>o.requiresForce===!0?r.has(o.id)&&!n.has(o.id):t.size>0?t.has(o.id):n.has(o.id)?!1:o.enabledByDefault)}s(O,"getEnabledDetectors");function Tt(e={}){if(Array.isArray(e.includeExtensions)&&e.includeExtensions.length>0)return new Set(e.includeExtensions.map(n=>n.toLowerCase()));let t=O(e);return new Set(t.flatMap(n=>n.extensions))}s(Tt,"getAllowedExtensions");function Ht(e,t={}){let n=ke(e).toLowerCase();if(O(t).some(a=>a.extensions.includes(n)&&a.resolveCommentSyntax(e)!==null))return null;if(n.length===0)return"the file has no extension, so its comment syntax is unknown";let o=new Set(Array.isArray(t.forcedDetectors)?t.forcedDetectors:[]),i=ae.find(a=>a.requiresForce===!0&&a.extensions.includes(n)&&!o.has(a.id));return i?`${n} files get a header only when forced (--force-detector ${i.id} / forcedDetectors: ["${i.id}"])`:`no enabled detector handles ${n} files`}s(Ht,"getHeaderSkipReason");function _t(e,t={}){let n=ke(e).toLowerCase(),r=Array.isArray(t.detectors)?t.detectors:O(t);for(let o of r){if(!o.extensions.includes(n))continue;let i=o.resolveCommentSyntax(e);if(i){let a=t.detectorSyntaxOverrides&&typeof t.detectorSyntaxOverrides=="object"?t.detectorSyntaxOverrides:{};return Xr(i,a[o.id])}}return{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}}s(_t,"getCommentSyntaxForFile");function Ut(e,t){let n=ke(e).toLowerCase();return O(t).find(r=>r.extensions.includes(n))}s(Ut,"detectorForFile");function ce(e,t,n={}){let r=Ut(e,n);if(!r)return"";let o=typeof r.resolvePreservedPrefix=="function"?r.resolvePreservedPrefix(e,t):"",i=r.keepsAboveHeader,a=se(t.slice(o.length),(c,l)=>oe(c)||typeof i=="function"&&i(c,l),o.split(`
4
+ `).length-1);return`${o}${a}`}s(ce,"getPreservedPrefixForFile");function Bt(e,t,n={}){let r=Ut(e,n);return r&&typeof r.resolveContentSkipReason=="function"?r.resolveContentSkipReason(t):null}s(Bt,"getContentSkipReason");var zt=200,Z=1,le=2;function T(e,t,n){if(e==null)return n;if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new Error(`${t} must be a whole number of 0 or more, got ${JSON.stringify(e)}`);return e}s(T,"resolveLayoutCount");import{existsSync as uo}from"node:fs";import{join as Ne,relative as nn,resolve as Fe,sep as Ce}from"node:path";import{realpath as fo,stat as mo}from"node:fs/promises";import{access as Qr,readdir as eo,readFile as _s,stat as to}from"node:fs/promises";import{constants as no}from"node:fs";import{dirname as zs,join as ro,resolve as Ws}from"node:path";async function Ee(e){try{return await Qr(e,no.F_OK),!0}catch{return!1}}s(Ee,"pathExists");async function $e(e,t){let n=[],r=await eo(e,{withFileTypes:!0});for(let o of r){let i=ro(e,o.name);if(o.isDirectory()&&t.recursive===!1||o.isDirectory()&&t.ignoreFolders.has(o.name)||o.isDirectory()&&await t.shouldSkipDirectory?.(i,o.name)===!0)continue;if(o.isDirectory()){let l=await $e(i,t);n.push(...l);continue}if(!o.isFile())continue;let a=o.name.lastIndexOf(".");if(a===-1)continue;let c=o.name.slice(a).toLowerCase();t.allowedExtensions.has(c)&&n.push(i)}return n}s($e,"walkFiles");async function Wt(e){let t=await to(e);return{createdAt:t.birthtimeMs>0&&t.birthtime<t.mtime?t.birthtime:t.mtime,updatedAt:t.mtime}}s(Wt,"readFileDates");function Gt(e){let t=e.indexOf("<");for(;t!==-1;){let n=e.indexOf(">",t+1);if(n===-1)return!1;if(n>t+1)return!0;t=e.indexOf("<",n+1)}return!1}s(Gt,"hasAngleTag");function Yt(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}s(Yt,"trimTrailingSlashes");import{execFile as oo}from"node:child_process";import{lstat as io,readFile as so}from"node:fs/promises";import{dirname as Vt,isAbsolute as ao,join as Kt,relative as Zt,resolve as Se,sep as Xt}from"node:path";import co from"ignore";function Jt(e,t){return new Promise(n=>{oo("git",t,{cwd:e,encoding:"utf8",maxBuffer:Number.POSITIVE_INFINITY},(r,o)=>{if(!r){n({code:0,stdout:o});return}n({code:typeof r.code=="number"?r.code:-1,stdout:""})})})}s(Jt,"runGitCommand");function De(e,t){return Zt(e,t).split(Xt).join("/")}s(De,"toPosixRelative");async function Qt(e){try{return co().add(await so(e,"utf8"))}catch{return null}}s(Qt,"readIgnoreFile");async function lo(e){return io(Kt(e,".git")).then(()=>!0,()=>!1)}s(lo,"hasGitEntry");function qt(e,t,n){for(let r=e.length-1;r>=0;r--){let{base:o,rules:i}=e[r],a=i.test(`${De(o,t)}${n?"/":""}`);if(a.ignored||a.unignored)return a.ignored}return!1}s(qt,"matchesRules");async function en(e,t){let n=await Qt(Kt(e,".gitignore"));return{kind:"rules",nested:!0,excluded:!1,matchers:n?[...t,{base:e,rules:n}]:t}}s(en,"buildRulesContext");async function Ae(e){let[t,n]=await Promise.all([Jt(e,["check-ignore","-q","."]),Jt(e,["ls-files","--cached","--others","--exclude-standard","-z"])]);if(t.code!==1||n.code!==0)return en(e,[]);let r=new Set,o=new Set;for(let i of n.stdout.split("\0")){let a=i.endsWith("/")?i.slice(0,-1):i;if(a.length!==0){r.add(a);for(let c=a.indexOf("/");c!==-1;c=a.indexOf("/",c+1))o.add(a.slice(0,c))}}return{kind:"git",root:e,entries:r,dirs:o}}s(Ae,"resolveScopeContext");function tn(e){let t=Se(e.root),n=e.gitignore;if(n===!1)return{isIgnored:s(async()=>!1,"isIgnored")};let r=new Map,o=s(async()=>{if(typeof n!="string"&&!Array.isArray(n))return Ae(t);let c=typeof n=="string"?[n]:n.filter(d=>typeof d=="string"),l=[];for(let d of c){let u=await Qt(Se(t,d));u&&l.push({base:t,rules:u})}return{kind:"rules",nested:!1,excluded:!1,matchers:l}},"buildRootContext"),i=s(c=>{let l=r.get(c);return l||(l=c===t?o():a(c),r.set(c,l)),l},"contextFor"),a=s(async c=>{let l=await i(Vt(c));return l.kind==="git"?l.entries.has(De(l.root,c))?Ae(c):l:!l.nested||l.excluded?l:qt(l.matchers,c,!0)?{...l,excluded:!0}:await lo(c)?Ae(c):en(c,l.matchers)},"deriveContext");return{async isIgnored(c,l){let d=Se(c),u=Zt(t,d);if(u.length===0||u===".."||u.startsWith(`..${Xt}`)||ao(u))return!1;let m=await i(Vt(d));if(m.kind==="git"){let h=De(m.root,d);return!(m.entries.has(h)||l&&m.dirs.has(h))}return m.excluded||qt(m.matchers,d,l)}}}s(tn,"createIgnoreFilter");function po(e){return Tt(e)}s(po,"resolveExtensions");var ho=Object.freeze(["node_modules","bower_components","jspm_packages",".pnpm-store",".yarn"]),sn=new Set([".git",...ho]),go=Object.freeze(["autoload.php","modules.txt"]);function rn(e,t){return sn.has(t)?!0:t==="vendor"&&go.some(n=>uo(Ne(e,n)))}s(rn,"isNeverWalked");function ve(e){return Yt(e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,""))}s(ve,"normalizeFolderPath");function yo(e){return Array.isArray(e)?e.map(t=>{if(typeof t=="string")return{path:t,recursive:!0};if(t&&typeof t=="object"&&typeof t.path=="string")return{path:t.path,recursive:t.recursive!==!1};throw new TypeError(`Invalid includeFolders entry: ${JSON.stringify(t)} (expected a path string or { path, recursive? })`)}):[]}s(yo,"resolveIncludeFolders");function on(e,t){let n=t instanceof Error?t.message:String(t);console.warn(`fix-headers: skipped include folder "${e}" (${n})`)}s(on,"reportSkippedIncludeFolder");function xo(e,t){if(!Array.isArray(t)||t.length===0)return()=>!1;let n=Fe(e),r=[],o=new Set;for(let i of t){if(typeof i!="string")continue;let a=ve(i);if(a.length!==0){if(a.includes("/")){r.push(Fe(n,a));continue}o.add(a)}}return(i,a)=>{if(o.has(a))return!0;for(let l of r)if(i===l||i.startsWith(`${l}/`))return!0;let c=ve(nn(n,i));return r.some(l=>{let d=ve(nn(n,l));return c===d||c.startsWith(`${d}/`)})}}s(xo,"buildExclusionMatcher");async function Le(e){let t=po(e),n=yo(e.includeFolders),r=Array.isArray(e.excludeFolders)?e.excludeFolders:[],o=xo(e.projectRoot,r),i=tn({root:e.projectRoot,gitignore:e.gitignore}),a=s(async(f,p)=>rn(f,p)||o(f,p)||await i.isIgnored(f,!0),"shouldSkipDirectory"),c=n.length>0?n.map(f=>({includeFolder:f.path,rootPath:Ne(e.projectRoot,f.path),recursive:f.recursive})):[{includeFolder:".",rootPath:e.projectRoot,recursive:!0}],l=[];for(let f of c){let p=await mo(f.rootPath).catch(b=>b);if(p instanceof Error){if(p.code==="ENOENT"){on(f.includeFolder,p);continue}throw p}if(!p.isDirectory()){on(f.includeFolder,`path is not a directory: ${f.rootPath}`);continue}let w=await fo(f.rootPath).catch(()=>Fe(f.rootPath));l.push({...f,realRoot:w})}let d=s((f,p)=>{if(f.realRoot===p.realRoot)return f.recursive||!p.recursive;let w=f.realRoot.endsWith(Ce)?f.realRoot:`${f.realRoot}${Ce}`;if(!f.recursive||!p.realRoot.startsWith(w))return!1;let b=f.rootPath;for(let $ of p.realRoot.slice(w.length).split(Ce))if(b=Ne(b,$),rn(b,$)||o(b,$))return!1;return!0},"covers"),u=[...l].sort((f,p)=>f.realRoot.length-p.realRoot.length||Number(p.recursive)-Number(f.recursive)),m=[];for(let f of u)m.some(p=>d(p,f))||m.push(f);let h=[];for(let f of l){if(!m.includes(f))continue;let p=await $e(f.rootPath,{allowedExtensions:t,ignoreFolders:sn,shouldSkipDirectory:a,recursive:f.recursive});h.push(...p)}let y=[];for(let f of new Set(h))!o(f,f.split("/").at(-1)||"")&&!await i.isIgnored(f,!1)&&y.push(f);return y}s(Le,"discoverFiles");import{basename as Wo,dirname as Go,extname as Yo,resolve as Oe}from"node:path";import{dirname as xn,isAbsolute as No,join as wn,relative as Fo,resolve as bn,sep as Lo}from"node:path";import{readFile as wo}from"node:fs/promises";import{join as bo}from"node:path";async function ko(e){try{return await wo(e,"utf8")}catch{return null}}s(ko,"readManifest");async function j(e,t){let n=[];for(let r of t){let o=await ko(bo(e,r));o!==null&&n.push({file:r,content:o})}return n.length>0?{dir:e,manifest:n[0].file,files:n}:null}s(j,"detectManifests");function H(e,t){return e.files.find(n=>n.file===t)?.content??null}s(H,"manifestContent");function D(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}s(D,"cleanName");function je(e){if(typeof e!="string")return;let t=e.search(/[<(]/);return D(t===-1?e:e.slice(0,t))}s(je,"personName");function ue(e){try{return JSON.parse(e)}catch{return}}s(ue,"parseJsonManifest");function*Me(e,t){let n="";for(let r of e.split(/\r?\n/)){let o=r.trim();if(o.startsWith("[")){let i=o.match(/^\[([^[\]]+)\]/);n=i?i[1].split(".").map(a=>a.trim()).join("."):"";continue}n===t&&(yield o)}}s(Me,"sectionLines");function X(e,t,n){let r=new RegExp(`^${n}\\s*=\\s*(?:"([^"\\\\]*)"|'([^']*)')`);for(let o of Me(e,t)){let i=o.match(r);if(i)return D(i[1]??i[2])}}s(X,"readTomlString");function Re(e,t,n){let r=new RegExp(`^${n}\\s*[=:](.*)$`);for(let o of Me(e,t)){let i=o.match(r);if(i)return D(i[1])}}s(Re,"readIniValue");function Eo(e,t,n){let r=new RegExp(`^${n}\\s*=\\s*\\[`),o=null;for(let i of Me(e,t)){if(o!==null){o.push(i);continue}let a=i.match(r);a&&(o=[i.slice(a[0].length)])}return o===null?null:o.join(`
5
+ `)}s(Eo,"tomlArrayText");function $o(e,t){let n=t;for(;n<e.length;)if(e[n]==="#"){let r=e.indexOf(`
6
+ `,n);n=r===-1?e.length:r+1}else if(/\s/.test(e[n]))n+=1;else break;return n}s($o,"skipTomlSpace");function Q(e,t){let n=Eo(e,t,"authors");if(n===null)return;let r=n.slice($o(n,0)),o=r.match(/^(?:"([^"\\\n]*)"|'([^'\n]*)')/);if(o)return je(o[1]??o[2]);let a=r.match(/^\{([^}\n]*)\}/)?.[1].match(/(?:^|,)\s*name\s*=\s*(?:"([^"\\\n]*)"|'([^'\n]*)')/);return a?D(a[1]??a[2]):void 0}s(Q,"readTomlAuthor");var an=["go.mod"];function So(e){let t=e.match(/^\s*module\s+(.+)$/m);if(t)return D(t[1].replace(/\/\/.*$/,"").trim().replace(/^["`](.*)["`]$/,"$1"))}s(So,"readModulePath");var cn={id:"go",languages:["go"],manifests:an,detect(e){return j(e,an)},read(e){return{name:So(e.files[0].content)}}};var ln=["package.json"];function Ao(e){let t=D(e?.name),n=D(e?.publisher),r=typeof e?.engines?.vscode=="string";return t&&n&&r?`${n}.${t}`:t}s(Ao,"readPublishedName");function Do(e){if(e!==null&&typeof e=="object"){let t=e;return D(t.company)??D(t.name)}return je(e)}s(Do,"readAuthorCompany");var un={id:"node",languages:["node"],manifests:ln,detect(e){return j(e,ln)},read(e){let t=ue(e.files[0].content);return{name:Ao(t),company:Do(t?.author)}}};var dn=["composer.json"],fn={id:"php",languages:["php"],manifests:dn,detect(e){return j(e,dn)},read(e){let t=ue(e.files[0].content),n=t?.authors;return{name:D(t?.name),company:Array.isArray(n)?D(n[0]?.name):void 0}}};var mn=["pyproject.toml","setup.cfg","setup.py"];function pn(e,t){let n=e.indexOf("setup(");if(n===-1)return;let r=e.slice(n).match(new RegExp(`\\b${t}\\s*=\\s*(["'])([^"'\\n]+)\\1`));return r&&r[2].trim()||void 0}s(pn,"readSetupPyArgument");function Co(e){let t=H(e,"pyproject.toml"),n=H(e,"setup.cfg"),r=H(e,"setup.py");return(t===null?void 0:X(t,"project","name")??X(t,"tool.poetry","name"))??(n===null?void 0:Re(n,"metadata","name"))??(r===null?void 0:pn(r,"name"))}s(Co,"readPythonName");function vo(e){let t=H(e,"pyproject.toml"),n=H(e,"setup.cfg"),r=H(e,"setup.py");return(t===null?void 0:Q(t,"project")??Q(t,"tool.poetry"))??(n===null?void 0:Re(n,"metadata","author"))??(r===null?void 0:pn(r,"author"))}s(vo,"readPythonCompany");var hn={id:"python",languages:["python"],manifests:mn,detect(e){return j(e,mn)},read(e){return{name:Co(e),company:vo(e)}}};var gn=["Cargo.toml"],yn={id:"rust",languages:["rust"],manifests:gn,detect(e){return j(e,gn)},read(e){let t=e.files[0].content;return{name:X(t,"package","name"),company:Q(t,"package")}}};var jo=[un,hn,fn,yn,cn],kn=["name","company"];async function Pe(e,t,n){let o=(await Promise.all(t.map(async a=>({driver:a,detection:await a.detect(e)})))).filter(a=>a.detection!==null),i=o.filter(a=>typeof n=="string"&&a.driver.languages.includes(n));return[...i,...o.filter(a=>!i.includes(a))]}s(Pe,"claimFolder");function Mo(e,t){let n=Fo(t,e);return n!==""&&n!==".."&&!n.startsWith(`..${Lo}`)&&!No(n)}s(Mo,"isStrictlyInside");async function En(e,t={}){let n=Array.isArray(t.drivers)?t.drivers:jo,r=typeof t.scanRoot=="string"?bn(t.scanRoot):null,o=bn(e),i=await Pe(o,n,t.language);for(;i.length===0;){if(await Ee(wn(o,".git")))return{root:o,marker:".git",drivers:[],fields:{},sources:{}};let u=xn(o);if(u===o)return null;o=u,i=await Pe(o,n,t.language)}let a={},c={},l=o,d=i;for(;;){for(let{driver:m,detection:h}of d){let y=m.read(h);for(let f of kn)a[f]===void 0&&y[f]!==void 0&&(a[f]=y[f],c[f]={driver:m.id,manifest:h.manifest,dir:l})}if(kn.every(m=>a[m]!==void 0)||r===null||!Mo(l,r)||await Ee(wn(l,".git")))break;l=xn(l),d=await Pe(l,n,t.language)}return{root:o,marker:i[0].detection.manifest,drivers:i.map(u=>u.driver.id),fields:a,sources:c}}s(En,"resolveManifestProject");import{execFile as Ro}from"node:child_process";import{basename as Po,dirname as Io}from"node:path";import{promisify as Oo}from"node:util";var Ie=Oo(Ro);async function F(e,t){try{let{stdout:n}=await Ie("git",t,{cwd:e}),r=n.trim();return r.length>0?r:null}catch{return null}}s(F,"runGit");function $n(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r--)n++;return n%2===1}s($n,"isEscaped");function To(e){let t=e.trim();if(!t.endsWith(")")||$n(t,t.length-1))return t;let n=0;for(let r=t.length-1;r>=0;r--){let o=t[r];if(!(o!=="("&&o!==")"||$n(t,r))&&(n+=o===")"?1:-1,n===0))return t.slice(0,r).trim()}return t}s(To,"stripUidComment");function Ho(e){let t=e.trim();if(t.length===0)return{authorName:null,authorEmail:null};let n=t.match(/<([^>\n]+)>\s*$/),r=n?.[1]?.trim()||null,o=(n?t.slice(0,n.index):t).trim();return{authorName:To(o)||o||null,authorEmail:r}}s(Ho,"parseSignerUid");async function _o(e,t){try{let{stdout:n}=await Ie(e,t),r=n.trim();return r.length>0?r:null}catch{return null}}s(_o,"runProgram");function Uo(e){return e.replace(/\\x([0-9a-fA-F]{2})/g,(t,n)=>String.fromCharCode(Number.parseInt(n,16)))}s(Uo,"decodeColonField");async function Bo(e){let t=await F(e,["config","--get","gpg.format"]);if(t!==null&&t!=="openpgp")return null;let n=await F(e,["config","--get","user.signingkey"]);if(!n)return null;let r=await F(e,["config","--get","gpg.openpgp.program"])||await F(e,["config","--get","gpg.program"])||"gpg",o=await _o(r,["--batch","--with-colons","--list-keys",n]);if(!o)return null;for(let i of o.split(`
7
+ `)){let a=i.split(":");if(a[0]==="uid"&&a[1]!=="r"&&a[1]!=="e"&&a[9])return Uo(a[9])}return null}s(Bo,"readSigningKeyUid");async function Sn(e,t={}){let n=await F(e,["config","--get","user.name"]),r=await F(e,["config","--get","user.email"]);if(t.useGpgSignerAuthor===!0){let o=await Bo(e)||await F(e,["log","-1","--format=%GS"]),i=Ho(o||"");n=i.authorName||n,r=r||i.authorEmail}if(!n||!r){let o=await F(e,["log","-1","--format=%an|%ae"]);if(o){let[i,a]=o.split("|");n=n||i||null,r=r||a||null}}return{authorName:n,authorEmail:r}}s(Sn,"detectGitAuthor");function An(e){return e.replace(/z$/i,"+00:00")}s(An,"canonicalGitDate");async function Dn(e,t){let n=await F(e,["log","--follow","--format=%aI|%at","--reverse","--",t]);if(!n)return null;let r=n.split(`
8
+ `)[0],[o,i]=r.split("|");if(!o||!i)return null;let a=Number.parseInt(i,10);return Number.isNaN(a)?null:{date:An(o),timestamp:a}}s(Dn,"getGitCreationDate");async function Cn(e,t){let n=await F(e,["log","-1","--format=%aI|%at","--",t]);if(!n)return null;let[r,o]=n.split("|");if(!r||!o)return null;let i=Number.parseInt(o,10);return Number.isNaN(i)?null:{date:An(r),timestamp:i}}s(Cn,"getGitLastModifiedDate");var zo=256*1024*1024;async function vn(e){let t=Io(e);if(await F(t,["rev-parse","--is-inside-work-tree"])!=="true")return{state:"no-git",content:null};try{let{stdout:n}=await Ie("git",["show",`HEAD:./${Po(e)}`],{cwd:t,encoding:"utf8",maxBuffer:zo});return{state:"tracked",content:n}}catch{return{state:"untracked",content:null}}}s(vn,"readGitHeadFile");function Vo(e){return Wo(e)||"project"}s(Vo,"folderName");function Jo(e,t){if(typeof t!="string")return e;let n=t.trim();return n.length===0||Gt(e)?e:`${e} <${n}>`}s(Jo,"formatAuthorNameWithCompany");async function qo(e,t={}){let n=Array.isArray(t.detectors)?t.detectors:O(t),r=typeof t.preferredExtension=="string"?t.preferredExtension.trim().toLowerCase():"",o=r.length>0?n.find(d=>d.extensions.includes(r)):void 0,i=await En(e,{drivers:t.drivers,language:o?.id,scanRoot:t.scanRoot}),a=i?i.root:Oe(e),c=i?.sources.name,l=i?.sources.company;return{language:o?.id??i?.drivers[0]??"unknown",rootDir:a,marker:i?i.marker:null,projectName:i?.fields.name??Vo(a),projectNameSource:c?{from:"manifest",...c}:{from:"folder",dir:a},companyName:i?.fields.company??null,companyNameSource:l?{from:"manifest",...l}:{from:"none"},drivers:i?i.drivers:[]}}s(qo,"detectProjectFromMarkers");async function Te(e={}){let t=e.targetFilePath||e.cwd||process.cwd(),n=Oe(t),r=O(e),o=e.targetFilePath?Go(n):n,i=e.targetFilePath?Yo(n).toLowerCase():"",a=Oe(e.projectRoot||e.cwd||process.cwd()),c=await qo(o,{detectors:r,preferredExtension:i,scanRoot:a}),l=await Sn(c.rootDir,{useGpgSignerAuthor:e.useGpgSignerAuthor===!0}),d=e.authorName||l.authorName||"Unknown Author",u=typeof e.companyName=="string"?e.companyName.trim():"";return{projectName:e.projectName||c.projectName,projectNameSource:e.projectName?{from:"option"}:c.projectNameSource,language:e.language||c.language,projectRoot:e.projectRoot||c.rootDir,marker:e.marker===void 0?c.marker:e.marker,authorName:Jo(d,e.company),authorEmail:e.authorEmail||l.authorEmail||"unknown@example.com",companyName:u||c.companyName,companyNameSource:u?{from:"option"}:c.companyNameSource,copyrightStartYear:Number.isInteger(e.copyrightStartYear)?Number(e.copyrightStartYear):null}}s(Te,"resolveProjectMetadata");function Ko(e){return He({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),offsetMinutes:-e.getTimezoneOffset()})}s(Ko,"formatDateWithTimezone");function He(e){return`${jn(e," ")} ${Mn(e.offsetMinutes)}`}s(He,"formatSpaceDate");function Fn(e){if(typeof e!="string")throw new Error(`timezone must be an IANA time zone name string, such as "America/Los_Angeles" or "UTC" (got ${typeof e})`);try{Ln(e)}catch(t){throw new Error(`Unknown time zone "${e}": expected an IANA time zone name, such as "America/Los_Angeles" or "UTC"`,{cause:t})}return e}s(Fn,"assertTimeZone");var Nn=new Map;function Ln(e){let t=Nn.get(e);return t||(t=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),Nn.set(e,t)),t}s(Ln,"getZoneFormatter");function _e(e,t){let n={};for(let o of Ln(t).formatToParts(new Date(e*1e3)))n[o.type]=Number(o.value);let r=Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)/1e3;return{year:n.year,month:n.month,day:n.day,hour:n.hour,minute:n.minute,second:n.second,offsetMinutes:(r-e)/60}}s(_e,"toZonedDateParts");function jn(e,t){let n=s(r=>String(r).padStart(2,"0"),"pad");return`${String(e.year).padStart(4,"0")}-${n(e.month)}-${n(e.day)}${t}${n(e.hour)}:${n(e.minute)}:${n(e.second)}`}s(jn,"formatWallClock");function Mn(e){let t=s(r=>String(r).padStart(2,"0"),"pad"),n=Math.abs(e);return`${e>=0?"+":"-"}${t(Math.floor(n/60))}:${t(n%60)}`}s(Mn,"formatOffset");function de(e=new Date){return{date:Ko(e),timestamp:Math.floor(e.getTime()/1e3)}}s(de,"toDatePayload");var Zo=/^(\d{4})-(\d{2})-(\d{2})(?:T|\s+)(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?\s*(?:(Z)|([+-])(\d{2}):?(\d{2}))$/i;function _(e){let t=Zo.exec(e.trim());if(!t)return null;let[n,r,o,i,a,c]=t.slice(1,7).map(Number),l=t[7]?0:Number(t[9])*60+Number(t[10]),d=t[8]==="-"?-l:l,u=new Date(Date.UTC(n,r-1,o,i,a,c));return!(u.getUTCFullYear()===n&&u.getUTCMonth()===r-1&&u.getUTCDate()===o&&u.getUTCHours()===i&&u.getUTCMinutes()===a&&u.getUTCSeconds()===c)||Number(t[10]??0)>59?null:{year:n,month:r,day:o,hour:i,minute:a,second:c,offsetMinutes:d,timestamp:Math.floor(u.getTime()/1e3)-d*60}}s(_,"parseHeaderDate");function Ue(e){return`${jn(e,"T")}${Mn(e.offsetMinutes)}`}s(Ue,"formatIsoDate");var Xo={"git-created":"git first commit","filesystem-created":"filesystem creation time"};function Rn(e,t){let n=e.match(new RegExp(`${t}:[^\\S\\n]*(.*)$`,"m"));return n?n[1].trim():null}s(Rn,"readHeaderField");function Be(e){let t=null;for(let{source:n,payload:r}of e)r&&(!t||r.timestamp<t.payload.timestamp)&&(t={source:n,payload:r});return t}s(Be,"pickOldestDate");function In({existing:e,gitCreated:t,filesystemCreated:n,fixCreatedDate:r=!1}){let o=[{source:"git-created",payload:t},{source:"filesystem-created",payload:n}];if(!e)return Be(o);if(!r)return{source:"existing-header",payload:e};let i=_(e.date)?e:null;return Be([{source:"existing-header",payload:i},...o])}s(In,"resolveCreatedDate");function On(e,t=null){if(t)return _e(e.timestamp,t).year;let n=_(e.date);return n?n.year:new Date(e.timestamp*1e3).getFullYear()}s(On,"dateYear");function Pn(e,t,n,r){let o=e.match(/^(.+?)\s*\((\d+)\)$/),i=o?_(o[1]):null;if(!o||!i)return r.push({check:`${n}-format`,field:t,advisory:!1,value:e,message:`${t} value "${e}" is not a "<datetime> (<epoch>)" pair with a recognised datetime`}),null;let a=Number.parseInt(o[2],10);return a!==i.timestamp&&r.push({check:`${n}-epoch`,field:t,advisory:!1,value:e,expected:`${o[1]} (${i.timestamp})`,message:`${t} epoch ${a} does not match ${o[1]} (expected ${i.timestamp})`}),{text:o[1],timestamp:i.timestamp}}s(Pn,"checkDateValue");function Tn(e,t={},n={}){let r=[],o=Rn(e,"@Date"),i=o===null?null:Pn(o,"@Date","created",r),a=Be([{source:"git-created",payload:t.gitCreated},{source:"filesystem-created",payload:t.filesystemCreated}]);if(i&&a&&i.timestamp>a.payload.timestamp){let u=Xo[a.source];r.push({check:"created-newer-than-source",field:"@Date",advisory:n.strictCreatedDate!==!0,value:o,expected:`${a.payload.date} (${a.payload.timestamp})`,source:a.source,message:`@Date ${i.text} is later than the ${u} ${a.payload.date} (${a.payload.timestamp})`})}let c=Rn(e,"@Last modified time"),l=c===null?null:Pn(c,"@Last modified time","modified",r),d=t.gitLastModified;return l&&d&&l.timestamp!==d.timestamp&&r.push({check:"modified-git",field:"@Last modified time",advisory:!0,value:c,expected:`${d.date} (${d.timestamp})`,message:`@Last modified time ${l.text} does not match the git last commit ${d.date} (${d.timestamp})`}),r}s(Tn,"checkHeaderDates");function ze(e){if(!e)return null;let t=_(e.date);return t&&t.timestamp!==e.timestamp?{date:e.date,timestamp:t.timestamp}:e}s(ze,"repairDateEpoch");function Hn(e){let t=_(e.date);return t?{date:Ue(t),timestamp:t.timestamp}:e}s(Hn,"normalizeDatePayload");function _n(e,t){let n=_(e.date);if(!n)return e;let r=_e(n.timestamp,t);return r.offsetMinutes===n.offsetMinutes||!Number.isInteger(r.offsetMinutes)?e:{date:/^\d{4}-\d{2}-\d{2}T/i.test(e.date.trim())?Ue(r):He(r),timestamp:n.timestamp}}s(_n,"convertDatePayload");import{relative as ei}from"node:path";import{extname as Qo}from"node:path";function U(e,t={}){let n=Qo(e).toLowerCase(),r=T(t.spacing,"spacing",Z);return n.length===0?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */",spacing:r}:{..._t(e,t),spacing:r}}s(U,"getHeaderSyntaxForFile");function Un(e,t){let n=e.spacing??Z;if(e.kind==="line"){let c=e.linePrefix||"#",l=typeof e.lineSeparator=="string"?e.lineSeparator:" ",d=Array.from({length:n},()=>c);return[...d,...t.map(u=>`${c}${l}${u}`),...d].join(`
9
+ `)}let r=e.blockStart||(e.kind==="html"?"<!--":"/**"),o=e.blockLinePrefix||(e.kind==="html"?" ":" * "),i=e.blockEnd||(e.kind==="html"?"-->":" */"),a=Array.from({length:n},()=>o.trimEnd());return[r,...a,...t.map(c=>`${o}${c}`),...a,i].join(`
10
+ `)}s(Un,"renderHeaderLines");function Bn(e){let t=`/${ei(e.projectRoot,e.absoluteFilePath).replace(/\\/g,"/")}`,n=U(e.absoluteFilePath,e.syntaxOptions||{language:e.language}),r=e.createdByName||e.authorName,o=e.createdByEmail||e.authorEmail,i=e.lastModifiedByName||e.authorName,a=e.lastModifiedByEmail||e.authorEmail,c=typeof e.companyName=="string"?e.companyName.trim():"",l=c.length>0?`${c} `:"",d=[`@Project: ${e.projectName}`,`@Filename: ${t}`,`@Date: ${e.createdAt.date} (${e.createdAt.timestamp})`,`@Author: ${r}`,`@Email: <${o}>`,"-----",`@Last modified by: ${i} (${a})`,`@Last modified time: ${e.lastModifiedAt.date} (${e.lastModifiedAt.timestamp})`,"-----",`@Copyright: Copyright (c) ${e.copyrightStartYear}-${e.currentYear} ${l}All rights reserved.`];return Un(n,d)}s(Bn,"buildHeader");var ti=Object.freeze(["projectName","filename","createdAt","authorName","authorEmail","lastModifiedByName","lastModifiedByEmail","lastModifiedAt","copyrightStartYear","copyrightEndYear","companyName"]);function I(e,t){let n=e.match(new RegExp(`@${t}:[ \\t]*(.*)$`,"m")),r=n?n[1].trim():"";return r.length>0?r:null}s(I,"readTag");function ni(e){if(e===null)return{name:null,email:null};if(!e.endsWith(")"))return{name:e,email:null};let t=e.slice(0,-1),n=t.indexOf("(",t.lastIndexOf(")")+1);return n===-1?{name:e,email:null}:{name:t.slice(0,n).trimEnd()||null,email:t.slice(n+1)||null}}s(ni,"splitLastModifiedBy");function ri(e){let t={startYear:null,endYear:null,companyName:null},n=e?.match(/^Copyright\s+\(c\)\s+(\d{4})/i);if(!n)return t;let r=e.slice(n[0].length),o=r.match(/^\s*-\s*(\d{4})/);o&&(r=r.slice(o[0].length));let i=r.toLowerCase(),a=i.endsWith("all rights reserved.")?20:i.endsWith("all rights reserved")?19:0;return a===0||!/^\s/.test(r)?t:{startYear:n[1],endYear:o?o[1]:null,companyName:r.slice(0,-a).trim()||null}}s(ri,"splitCopyright");function zn(e){let t=ni(I(e,"Last modified by")),n=ri(I(e,"Copyright")),r=I(e,"Email");return{projectName:I(e,"Project"),filename:I(e,"Filename"),createdAt:I(e,"Date"),authorName:I(e,"Author"),authorEmail:r===null?null:r.replace(/^<(.*)>$/,"$1"),lastModifiedByName:t.name,lastModifiedByEmail:t.email,lastModifiedAt:I(e,"Last modified time"),copyrightStartYear:n.startYear,copyrightEndYear:n.endYear,companyName:n.companyName}}s(zn,"parseHeaderFields");function Wn(e,t){let n=zn(e??""),r=zn(t);return ti.filter(o=>n[o]!==r[o]).map(o=>({field:o,previous:n[o],detected:r[o]}))}s(Wn,"compareHeaderFields");function ee(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}s(ee,"escapeRegex");function We(e,t,n={}){let r=t.startsWith("\uFEFF")?"\uFEFF":"",o=t.slice(r.length),i=`${r}${ce(e,o,n)}`;return{prefix:i,body:t.slice(i.length)}}s(We,"splitPreservedPrefix");function fe(e){let t=e.indexOf(`
11
+ `);return t===-1?null:t>0&&e[t-1]==="\r"?`\r
12
+ `:`
13
+ `}s(fe,"lineEnding");function W(e,t){if(t.kind==="html"){let r=ee(t.blockStart||"<!--"),o=ee(t.blockEnd||"-->");return e.match(new RegExp(`^${r}[\\s\\S]*?${o}(?:\\r?\\n)*`))}if(t.kind==="line"){let r=ee(t.linePrefix||"#");return e.match(new RegExp(`^(?:${r}[^\\n]*\\n)+(?:\\r?\\n)*`))}let n=ee((t.blockEnd||" */").trim());return e.match(new RegExp(`^/\\*[\\s\\S]*?${n}(?:\\r?\\n)*`))}s(W,"matchHeaderSegment");var Vn=/^@(Project|Filename|Date|Author|Email|Last modified by|Last modified time|Copyright):/,oi="Moved out of the file header by fix-headers:";function Jn(e){return e.some(t=>/^@(?:Project|Filename):/.test(t.text))}s(Jn,"isFileHeader");function Ge(e,t){let n=e.replace(/(?:\r?\n)+$/,"");if(t.kind==="line"){let u=new RegExp(`^${ee(t.linePrefix||"#")}[ \\t]*`);return n.split(`
14
+ `).map(m=>{let h=m.replace(/\r$/,"");return{raw:h,text:h.replace(u,"").trim()}})}let r=t.kind==="html",o=r?n.replace(/^<!--/,"").replace(/--!?>\s*$/,""):n.replace(/^\/\*+/,"").replace(/\*+\/\s*$/,""),i=t.blockLinePrefix||(r?" ":" * "),a=r?/^\s*/:/^\s*\*?[ \t]*/,c=o.split(`
15
+ `).map((u,m)=>({raw:m===0&&u.trim()!==""?`${i}${u.trim()}`:u.trimEnd(),text:(m===0?u:u.replace(a,"")).trim()})),l=c[0].raw===""?1:0,d=c.length>l&&c[c.length-1].raw.trim()===""?c.length-1:c.length;return c.slice(l,d)}s(Ge,"segmentLines");function ii(e,t){let n=e.map(o=>{let i=o.text.match(Vn);return o.text===""?"blank":i&&i[1]==="Copyright"?t.copyright?"copyright":(t.copyright=!0,"field"):i?"field":/^-{3,}$/.test(o.text)?"dash":"text"}),r=s((o,i)=>{for(let a=o+i;a>=0&&a<n.length;a+=i)if(n[a]!=="blank"&&n[a]!=="dash")return n[a]==="copyright"?"field":n[a]},"neighbour");return n.map((o,i)=>o==="dash"?r(i,-1)==="field"||r(i,1)==="field"?"separator":"text":o)}s(ii,"classifyLines");function si(e,t="",n={}){let r=U(t,n),o=[],i=[],a={copyright:!1},c=e,l=W(c,r),d=!0;for(;l&&l[0].length>0;){let p=Ge(l[0],r),w=ii(p,a),b=p.findIndex($=>$.text!=="");!d&&b!==-1&&p[b].text===oi&&(w[b]="separator"),p.forEach(($,C)=>{w[C]==="copyright"&&i.push($.text.replace(Vn,"").trim()),o.push({raw:$.raw,kind:w[C]})}),c=c.slice(l[0].length),l=W(c,r),d=!1}let u=o.findIndex(p=>p.kind==="text");if(u===-1)return{foreign:[],copyrights:i};let m=o.map(p=>p.kind).lastIndexOf("text"),h=[],y=[],f=!1;for(let p of o.slice(u,m+1))p.kind==="text"?(h.push(...f?[]:y,p.raw),y=[],f=!1):p.kind==="blank"?y.push(p.raw):f=!0;return{foreign:h,copyrights:i}}s(si,"splitHeaderText");function ai(e,t,n){let r=t.kind==="html";return t.kind==="line"?e.join(n):[t.blockStart||(r?"<!--":"/**"),...e,t.blockEnd||(r?"-->":" */")].join(n)}s(ai,"renderForeignBlock");function ci(e,t,n){let r=e.split(`
16
+ `),o=n.kind==="html",i=n.kind==="line"?n.linePrefix||"#":(n.blockLinePrefix||(o?" ":" * ")).trimEnd(),a=Math.min(r.length-1,(n.spacing??1)+(n.kind==="line"?0:1)),c=r.length-a;return[...r.slice(0,c),i,...t,...r.slice(c)].join(`
17
+ `)}s(ci,"appendToHeader");function Gn(e){let t=e.trim(),n=t.match(/^copyright\b/i);t=n?t.slice(n[0].length).trimStart():t;for(let c=t.match(/^(?:\(c\)|©)/i);c;c=t.match(/^(?:\(c\)|©)/i))t=t.slice(c[0].length).trimStart();let r=t.match(/^\d{4}(?:\s*[-–,]\s*\d{4})*/);t=r?t.slice(r[0].length):t,t=t.trimEnd();let o=t.toLowerCase(),i=o.endsWith("all rights reserved.")?20:o.endsWith("all rights reserved")?19:0;t=t.slice(0,t.length-i);let a=t.length;for(;a>0&&`.,; \r
18
+ `.includes(t[a-1]);)a-=1;return t.slice(0,a).split(/\s+/).filter(Boolean).join(" ").toLowerCase()}s(Gn,"copyrightHolder");function li(e,t){let n=e.split(`
19
+ `),r=n.findIndex(c=>c.includes("@Copyright:")),o=n.map(c=>/@[A-Za-z][A-Za-z ]*:/.test(c)).lastIndexOf(!0),i=r!==-1?r:o;if(t.length===0||i===-1)return e;let a=n[i].slice(0,n[i].indexOf("@"));return[...n.slice(0,i+1),...t.map(c=>`${a}@Copyright: ${c}`),...n.slice(i+1)].join(`
20
+ `)}s(li,"insertCopyrights");function Yn(e,t){let n=0,r=W(e,t);for(;r&&r[0].length>0&&Jn(Ge(r[0],t));)n+=r[0].length,r=W(e.slice(n),t);return n}s(Yn,"leadingHeadersLength");function me(e,t="",n={}){let r=e.startsWith("\uFEFF")?"\uFEFF":"",o=e.slice(r.length),i=ce(t,o,n),a=U(t,n),c=i.length,l=Yn(o.slice(c),a);if(l===0)return e;let d=r===""&&c===0&&o.startsWith("\uFEFF",l);d&&(r="\uFEFF",o=`${o.slice(0,l)}${o.slice(l+1)}`,l+=Yn(o.slice(l),a));let u=o.slice(c,c+l),m=o.slice(c+l),h=ce(t,`${i}${m}`,n),y=h.length>i.length?h.slice(i.length):"";if(y===""&&!d)return e;let f=y===""||y.endsWith(`
21
+ `)?y:`${y}${fe(e)??`
22
+ `}`;return`${r}${i}${f}${u}${m.slice(y.length)}`}s(me,"restoreTopLines");function pe(e,t="",n={}){let{prefix:r,body:o}=We(t,e,n),i=o.split(`
23
+ `).slice(0,zt).join(`
24
+ `),a=U(t,n);if(!W(i,a))return null;let l=0,d=0;for(;;){let u=i.slice(l),m=W(u,a);if(!m||!Jn(Ge(m[0],a)))break;l+=m[0].length,d=l}return d===0?null:{start:r.length,end:r.length+d}}s(pe,"findProjectHeader");function he(e,t,n="",r={}){let o=me(e,n,r),i=pe(o,n,r),a=U(n,r),c=T(r.margin,"margin",le),l=a.kind==="line"?Math.max(1,c):c,d=s((E,S)=>S===`
25
+ `?E:E.replace(/\r?\n/g,S),"withEol");if(!i){let{prefix:E,body:S}=We(n,o,r),A=fe(o)??`
26
+ `,R=d(t,A),V=S.replace(/^(?:\r?\n)+/,""),g=E.replace(/^\uFEFF/,"")!==""&&!E.endsWith(`
27
+ `)?A:"",P=`${E}${g}${V.trim()===""?`${R}${A}`:`${R}${A.repeat(l+1)}${V}`}`;return{nextContent:P,changed:P!==e,header:R,written:R,extraCopyrights:[]}}let u=o.slice(i.start,i.end),{foreign:m,copyrights:h}=si(u,n,r),y=t.split(`
28
+ `).find(E=>E.includes("@Copyright:")),f=new Set(y===void 0?[]:[Gn(y.slice(y.indexOf("@Copyright:")+11))]),p=[];for(let E of h){let S=Gn(E);f.has(S)||(f.add(S),p.push(E))}let w=fe(o.slice(i.end))??fe(u)??`
29
+ `,b=w.repeat(l+1),$=r.strictHeaderBlock!==!1,C=li(t,p),M=d(m.length>0&&!$?ci(C,m,a):C,w),k=m.length>0&&$?ai(m,a,w):"",B=o.slice(i.end).replace(/^(?:\r?\n)+/,""),G=k===""?B:`${k}${B.trim()===""?w:`${b}${B}`}`,Y=`${o.slice(0,i.start)}${G.trim()===""?`${M}${w}`:`${M}${b}${G}`}`,x=`${M}${k===""?"":`${b}${k}`}`;return{nextContent:Y,changed:Y!==e,header:M,written:x,extraCopyrights:p}}s(he,"replaceOrInsertHeader");function Ye(e,t="",n={}){let r=me(e,t,n),o=pe(r,t,n);if(o){let l=r.slice(0,o.start),u=he(r,"",t,{...n,strictHeaderBlock:!0}).nextContent.slice(l.length).replace(/^(?:\r?\n)+/,"");return`${l}${u.trim()===""?"":u}`}let{prefix:i,body:a}=We(t,r,n),c=a.replace(/^(?:\r?\n)+/,"");return`${i}${c.trim()===""?"":c}`}s(Ye,"extractHeaderlessBody");function ui(e,t){let n=e.length,r=t.length,o=Array.from({length:n+1},()=>new Array(r+1).fill(0));for(let l=n-1;l>=0;l-=1)for(let d=r-1;d>=0;d-=1)o[l][d]=e[l]===t[d]?o[l+1][d+1]+1:Math.max(o[l+1][d],o[l][d+1]);let i=[],a=0,c=0;for(;a<n&&c<r;)e[a]===t[c]?(i.push({type:" ",line:e[a]}),a+=1,c+=1):o[a+1][c]>=o[a][c+1]?(i.push({type:"-",line:e[a]}),a+=1):(i.push({type:"+",line:t[c]}),c+=1);for(;a<n;a+=1)i.push({type:"-",line:e[a]});for(;c<r;c+=1)i.push({type:"+",line:t[c]});return i}s(ui,"diffLines");function qn(e,t){return`${t===0?e:e+1},${t}`}s(qn,"formatRange");function Kn(e,t,n={}){let r=e===null?[]:e.split(`
13
30
  `),o=t.split(`
14
- `),a=Lo(n,o),s=Math.max(0,r.context??3),c=r.lineOffset??0,l=[];if(a.forEach((g,x)=>{if(g.type===" ")return;let d=l[l.length-1];d&&x-d.last<=s*2+1?d.last=x:l.push({first:x,last:x})}),l.length===0)return"";let u=r.fromFile??"a",f=r.toFile??"b",m=[`--- ${e===null?"/dev/null":u}`,`+++ ${f}`];for(let g of l){let x=Math.max(0,g.first-s),d=Math.min(a.length,g.last+s+1),h=a.slice(0,x),b=a.slice(x,d),$=h.filter(k=>k.type!=="+").length+c,v=h.filter(k=>k.type!=="-").length+c,R=b.filter(k=>k.type!=="+").length,V=b.filter(k=>k.type!=="-").length;m.push(`@@ -${Fr($,R)} +${Fr(v,V)} @@`);for(let k of b)m.push(`${k.type}${k.line}`)}return m.join(`
15
- `)}i(jr,"createUnifiedDiff");function Io(e){return q(e,"configFile")}i(Io,"resolveRuntimeOptions");function Oo(e){if(e==null)return[];let t=Array.isArray(e)?e:[e];if(t.some(r=>typeof r!="string"))throw new Error(`input must be a path or an array of paths, got ${JSON.stringify(e)}`);return t.filter(r=>r.trim().length>0)}i(Oo,"resolveInputs");function To(e){let t=e.match(/@Author:\s*(.+)$/m),r=e.match(/@Email:\s*<([^>\n]+)>/m);return{authorName:t?.[1]?.trim(),authorEmail:r?.[1]?.trim()}}i(To,"extractHeaderAuthorIdentity");function Ho(e){let t=e.match(/@Last modified by:\s*(.+?)\s*\(([^)\n]+)\)\s*$/m);return{authorName:t?.[1]?.trim(),authorEmail:t?.[2]?.trim()}}i(Ho,"extractHeaderLastModifiedIdentity");function _o(e){let t=e.match(/@Date:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let r=Number.parseInt(t[2],10);return Number.isNaN(r)?null:{date:t[1].trim(),timestamp:r}}i(_o,"extractHeaderCreatedAt");function Uo(e){let t=e.match(/@Last modified time:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let r=Number.parseInt(t[2],10);return Number.isNaN(r)?null:{date:t[1].trim(),timestamp:r}}i(Uo,"extractHeaderLastModifiedAt");async function zo(e,t,r){let n=await dr(t);return n.state!=="tracked"?{edited:n.state==="untracked",state:n.state}:{edited:Re(n.content,t,r)!==Re(e,t,r),state:"tracked"}}i(zo,"detectContentEdit");async function Mr(e={}){let t=await Io(e),r=t.timezone===void 0||t.timezone===null?null:pr(t.timezone),n=t.convertTimezone===!0;if(n&&!r)throw new Error("convertTimezone requires timezone: set timezone (CLI --timezone <name>) to the IANA zone to convert header dates into");let o=At(t.forcedDetectors),a=Lr(t.projectRoot||t.cwd||process.cwd()),s=await De({...t,cwd:a});j(t.spacing,"spacing",B),j(t.margin,"margin",X);let c=t.check===!0,l=c||t.dryRun===!0,u=t.fixCreatedDate===!0,f=i(y=>y,"keepDate"),m=t.normalizeDateFormat===!0?Sr:f,g=r?y=>$r(y,r):f,x=n?g:f,d={language:s.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,includeFolders:t.includeFolders,excludeFolders:t.excludeFolders,includeExtensions:t.includeExtensions,gitignore:t.gitignore},h=Oo(t.input),b;if(h.length>0){let y=new Set;for(let P of h){let p=Lr(a,P),I=await Ro(p).catch(()=>null);if(!I)throw new Error(`Input path does not exist: ${P}`);if(I.isFile())y.add(p);else if(I.isDirectory())for(let N of await we({...d,projectRoot:p}))y.add(N);else throw new Error(`Input path must be a file or directory: ${P}`)}b=Array.from(y)}else b=await we({...d,projectRoot:a});let $=new Date().getFullYear(),v=[],R=[],V=new Set,k=0,Oe=0,Te=0;for(let y of b){let P=vt(y,{enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o});if(P!==null){R.push({file:Pe(a,y),reason:P});continue}let p=await De({...t,cwd:a,targetFilePath:y});V.add(`${p.language}:${p.projectRoot}`);let I=Pe(a,y),N=await Mo(y,"utf8"),T={language:p.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,detectorSyntaxOverrides:t.detectorSyntaxOverrides,spacing:t.spacing,margin:t.margin},re=te(N,y,T),E=re?N.slice(re.start,re.end):"",He=E.length>0?To(E):{},_e=E.length>0?Ho(E):{},Tr=E.length>0?_o(E):null,Hr=E.length>0?Uo(E):null,Ue=await jt(y),ze=Pe(p.projectRoot,y),Be=await ur(p.projectRoot,ze),H=await fr(p.projectRoot,ze),We=Q(Ue.createdAt),ne=br({existing:je(Tr),gitCreated:Be,filesystemCreated:We,fixCreatedDate:u}),_=je(Hr),Ye=ne.source,_r=_?"existing-header":H?"git-last-modified":"filesystem-updated",oe=m(Ye==="existing-header"?x(ne.payload):g(ne.payload)),Ur=p.copyrightStartYear===null?"created-date":"option",Ge=p.copyrightStartYear??kr(oe,r),Ve=m(_?x(_):g(H||Q(Ue.updatedAt))),Je=t.forceAuthorUpdate===!0,zr=t.forceLastModifiedAuthorUpdate===!0,qe=await zo(N,y,T),Ke=zr||qe.edited,Xe=i(D=>Dr({absoluteFilePath:y,language:p.language,syntaxOptions:T,projectRoot:p.projectRoot,projectName:p.projectName,createdByName:Je?p.authorName:He.authorName||p.authorName,createdByEmail:Je?p.authorEmail:He.authorEmail||p.authorEmail,lastModifiedByName:Ke?p.authorName:_e.authorName||p.authorName,lastModifiedByEmail:Ke?p.authorEmail:_e.authorEmail||p.authorEmail,authorName:p.authorName,authorEmail:p.authorEmail,createdAt:oe,lastModifiedAt:D,copyrightStartYear:Ge,companyName:p.companyName,currentYear:$}),"renderHeader"),Ze=Xe(Ve),Qe=Me(N,Ze,y,T),Br=qe.edited&&_!==null&&H!==null&&_.timestamp<H.timestamp,J=Qe.changed||Br,et=J?m(g(Q(new Date))):Ve,Wr=J?"current-time-on-change":_r,U=J?Xe(et):Ze,O=J?Me(N,U,y,T):Qe,ie={file:I,changed:O.changed};if(c){let D=Er(E,{gitCreated:Be,gitLastModified:H,filesystemCreated:We},{strictCreatedDate:t.strictCreatedDate===!0}),z=D.filter(ae=>ae.advisory).length;ie.dateIssues=D,Te+=z,Oe+=D.length>z?1:0}if(t.sampleOutput===!0&&O.changed){let D=E.length>0?E.trimEnd():null,z=I.replace(/\\/g,"/"),ae=O.nextContent.slice(0,O.nextContent.indexOf(U)).split(`
16
- `).length-1;ie.sample={previousValue:D,newValue:U,diff:jr(D,U,{fromFile:`a/${z}`,toFile:`b/${z}`,lineOffset:ae}),issues:Cr(D,U),detectedValues:{projectName:p.projectName,projectNameSource:p.projectNameSource,language:p.language,projectRoot:p.projectRoot,marker:p.marker,authorName:p.authorName,authorEmail:p.authorEmail,companyName:p.companyName,companyNameSource:p.companyNameSource,copyrightStartYear:Ge,copyrightStartYearSource:Ur,createdAtSource:Ye,lastModifiedAtSource:Wr,createdAt:oe,lastModifiedAt:et}}}v.push(ie),O.changed&&(k+=1,l||await Po(y,O.nextContent,"utf8"))}return{metadata:s,detectedProjects:Array.from(V),filesScanned:b.length-R.length,filesUpdated:k,filesSkipped:R.length,dryRun:l,check:c,...c?{filesWithDateDrift:Oe,dateAdvisories:Te}:{},changes:v,skipped:R}}i(Mr,"fixHeaders");function Bo(e){return Mr(e)}i(Bo,"fixHeaders");var Rr=Bo;var Go=`fix-headers CLI
31
+ `),i=ui(r,o),a=Math.max(0,n.context??3),c=n.lineOffset??0,l=[];if(i.forEach((h,y)=>{if(h.type===" ")return;let f=l[l.length-1];f&&y-f.last<=a*2+1?f.last=y:l.push({first:y,last:y})}),l.length===0)return"";let d=n.fromFile??"a",u=n.toFile??"b",m=[`--- ${e===null?"/dev/null":d}`,`+++ ${u}`];for(let h of l){let y=Math.max(0,h.first-a),f=Math.min(i.length,h.last+a+1),p=i.slice(0,y),w=i.slice(y,f),b=p.filter(k=>k.type!=="+").length+c,$=p.filter(k=>k.type!=="-").length+c,C=w.filter(k=>k.type!=="+").length,M=w.filter(k=>k.type!=="-").length;m.push(`@@ -${qn(b,C)} +${qn($,M)} @@`);for(let k of w)m.push(`${k.type}${k.line}`)}return m.join(`
32
+ `)}s(Kn,"createUnifiedDiff");function pi(e){return re(e,"configFile")}s(pi,"resolveRuntimeOptions");function hi(e){if(e==null)return[];let t=Array.isArray(e)?e:[e];if(t.some(n=>typeof n!="string"))throw new Error(`input must be a path or an array of paths, got ${JSON.stringify(e)}`);return t.filter(n=>n.trim().length>0)}s(hi,"resolveInputs");function gi(e){let t=e.match(/@Author:\s*(.+)$/m),n=e.match(/@Email:\s*<([^>\n]+)>/m);return{authorName:t?.[1]?.trim(),authorEmail:n?.[1]?.trim()}}s(gi,"extractHeaderAuthorIdentity");function yi(e){let t=e.match(/@Last modified by:\s*(.+?)\s*\(([^)\n]+)\)\s*$/m);return{authorName:t?.[1]?.trim(),authorEmail:t?.[2]?.trim()}}s(yi,"extractHeaderLastModifiedIdentity");function xi(e){let t=e.match(/@Date:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let n=Number.parseInt(t[2],10);return Number.isNaN(n)?null:{date:t[1].trim(),timestamp:n}}s(xi,"extractHeaderCreatedAt");function wi(e){let t=e.match(/@Last modified time:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let n=Number.parseInt(t[2],10);return Number.isNaN(n)?null:{date:t[1].trim(),timestamp:n}}s(wi,"extractHeaderLastModifiedAt");async function bi(e,t,n){let r=await vn(t);return r.state!=="tracked"?{edited:r.state==="untracked",state:r.state}:{edited:Ye(r.content,t,n)!==Ye(e,t,n),state:"tracked"}}s(bi,"detectContentEdit");async function Xn(e={}){let t=await pi(e),n=t.timezone===void 0||t.timezone===null?null:Fn(t.timezone),r=t.convertTimezone===!0;if(r&&!n)throw new Error("convertTimezone requires timezone: set timezone (CLI --timezone <name>) to the IANA zone to convert header dates into");let o=Ot(t.forcedDetectors),i=Zn(t.projectRoot||t.cwd||process.cwd()),a=await Te({...t,cwd:i});T(t.spacing,"spacing",Z),T(t.margin,"margin",le);let c=t.check===!0,l=c||t.dryRun===!0,d=t.fixCreatedDate===!0,u=s(x=>x,"keepDate"),m=t.normalizeDateFormat===!0?Hn:u,h=n?x=>_n(x,n):u,y=r?h:u,f={language:a.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,includeFolders:t.includeFolders,excludeFolders:t.excludeFolders,includeExtensions:t.includeExtensions,gitignore:t.gitignore},p=hi(t.input),w;if(p.length>0){let x=new Set;for(let E of p){let S=Zn(i,E),A=await fi(S).catch(()=>null);if(!A)throw new Error(`Input path does not exist: ${E}`);if(A.isFile())x.add(S);else if(A.isDirectory())for(let R of await Le({...f,projectRoot:S}))x.add(R);else throw new Error(`Input path must be a file or directory: ${E}`)}w=Array.from(x)}else w=await Le({...f,projectRoot:i});let b=new Date().getFullYear(),$=[],C=[],M=new Set,k=0,B=0,G=0,Y=[];for(let x of w){let E=Ht(x,{enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o});if(E!==null){C.push({file:Ve(i,x),reason:E});continue}let S=Ve(i,x),A=await di(x,"utf8"),R={enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,detectorSyntaxOverrides:t.detectorSyntaxOverrides},V=Bt(x,me(A,x,R),R);if(V!==null){C.push({file:S,reason:V});continue}let g=await Te({...t,cwd:i,targetFilePath:x});M.add(`${g.language}:${g.projectRoot}`);let P={language:g.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,detectorSyntaxOverrides:t.detectorSyntaxOverrides,spacing:t.spacing,margin:t.margin,strictHeaderBlock:t.strictHeaderBlock!==!1},ge=pe(A,x,P),v=ge?A.slice(ge.start,ge.end):"",qe=v.length>0?gi(v):{},Ke=v.length>0?yi(v):{},ir=v.length>0?xi(v):null,sr=v.length>0?wi(v):null,Ze=await Wt(x),Xe=Ve(g.projectRoot,x),Qe=await Dn(g.projectRoot,Xe),J=await Cn(g.projectRoot,Xe),et=de(Ze.createdAt),ye=In({existing:ze(ir),gitCreated:Qe,filesystemCreated:et,fixCreatedDate:d}),q=ze(sr),tt=ye.source,ar=q?"existing-header":J?"git-last-modified":"filesystem-updated",xe=m(tt==="existing-header"?y(ye.payload):h(ye.payload)),cr=g.copyrightStartYear===null?"created-date":"option",nt=g.copyrightStartYear??On(xe,n),rt=m(q?y(q):h(J||de(Ze.updatedAt))),ot=t.forceAuthorUpdate===!0,lr=t.forceLastModifiedAuthorUpdate===!0,it=await bi(A,x,P),st=lr||it.edited,at=s(N=>Bn({absoluteFilePath:x,language:g.language,syntaxOptions:P,projectRoot:g.projectRoot,projectName:g.projectName,createdByName:ot?g.authorName:qe.authorName||g.authorName,createdByEmail:ot?g.authorEmail:qe.authorEmail||g.authorEmail,lastModifiedByName:st?g.authorName:Ke.authorName||g.authorName,lastModifiedByEmail:st?g.authorEmail:Ke.authorEmail||g.authorEmail,authorName:g.authorName,authorEmail:g.authorEmail,createdAt:xe,lastModifiedAt:N,copyrightStartYear:nt,companyName:g.companyName,currentYear:b}),"renderHeader"),ct=at(rt),lt=he(A,ct,x,P),ur=it.edited&&q!==null&&J!==null&&q.timestamp<J.timestamp,te=lt.changed||ur,ut=te?m(h(de(new Date))):rt,dr=te?"current-time-on-change":ar,fr=te?at(ut):ct,L=te?he(A,fr,x,P):lt,ne={file:S,changed:L.changed};if(c){let N=Tn(v,{gitCreated:Qe,gitLastModified:J,filesystemCreated:et},{strictCreatedDate:t.strictCreatedDate===!0}),K=N.filter(z=>z.advisory).length;ne.dateIssues=N,G+=K,B+=N.length>K?1:0}if(t.sampleOutput===!0&&L.changed){let N=v.length>0?v.trimEnd():null,K=S.replace(/\\/g,"/"),z=L.written,mr=L.nextContent.slice(0,L.nextContent.indexOf(z)).split(`
33
+ `).length-1;ne.sample={previousValue:N,newValue:z,diff:Kn(N,z,{fromFile:`a/${K}`,toFile:`b/${K}`,lineOffset:mr}),issues:Wn(N,z),detectedValues:{projectName:g.projectName,projectNameSource:g.projectNameSource,language:g.language,projectRoot:g.projectRoot,marker:g.marker,authorName:g.authorName,authorEmail:g.authorEmail,companyName:g.companyName,companyNameSource:g.companyNameSource,copyrightStartYear:nt,copyrightStartYearSource:cr,createdAtSource:tt,lastModifiedAtSource:dr,createdAt:xe,lastModifiedAt:ut}}}if(L.extraCopyrights.length>0){ne.extraCopyrights=L.extraCopyrights;for(let N of L.extraCopyrights)Y.push({file:S,copyright:N})}$.push(ne),L.changed&&(k+=1,l||await mi(x,L.nextContent,"utf8"))}return{metadata:a,detectedProjects:Array.from(M),filesScanned:w.length-C.length,filesUpdated:k,filesSkipped:C.length,dryRun:l,check:c,...c?{filesWithDateDrift:B,dateAdvisories:G}:{},copyrightWarnings:Y,changes:$,skipped:C}}s(Xn,"fixHeaders");var Qn=typeof process>"u"?void 0:process.getBuiltinModule?.("node:module");if(Qn)try{Qn.createRequire(import.meta.url)("../devcheck.mjs")}catch(e){if(e?.code!=="MODULE_NOT_FOUND")throw e}function ki(e){return Xn(e)}s(ki,"fixHeaders");var er=ki;var Si=`fix-headers CLI
17
34
 
18
35
  Usage:
19
36
  fix-headers [options]
@@ -24,6 +41,8 @@ Options:
24
41
  --check Validate header dates without writing; exit 1 on date drift
25
42
  --fix-created-date Move an existing @Date back to the oldest of git first commit / file creation
26
43
  --strict-created-date With --check, fail when @Date is later than git first commit / file creation
44
+ --strict-header-block [true|false] Move non-field text found in a header to its own block below it (default: true)
45
+ --no-strict-header-block Keep non-field text found in a header inside it, after the fields
27
46
  --normalize-date-format Write every header date in the ISO 8601 T-form (git %aI)
28
47
  --timezone <name> Write new dates in an IANA time zone (e.g. America/Los_Angeles, UTC); the instant never changes
29
48
  --convert-timezone With --timezone, also rewrite existing @Date/@Last modified time values into that zone
@@ -62,5 +81,5 @@ Examples:
62
81
  fix-headers --check --verbose
63
82
  fix-headers --timezone America/Los_Angeles --convert-timezone
64
83
  fix-headers --project-name @scope/pkg --company-name "Catalyzed Motivation Inc."
65
- `;function Vo(e){return e.replace(/-([a-z])/g,(t,r)=>r.toUpperCase())}i(Vo,"toCamelCase");function Jo(e){let t={},r={help:!1,json:!1,diff:!1},n={"include-folder":"includeFolders","exclude-folder":"excludeFolders","include-extension":"includeExtensions","enable-detector":"enabledDetectors","disable-detector":"disabledDetectors","force-detector":"forcedDetectors",input:"input"},o={cwd:"cwd","project-name":"projectName",language:"language","project-root":"projectRoot",marker:"marker","author-name":"authorName","author-email":"authorEmail",company:"company","company-name":"companyName","copyright-start-year":"copyrightStartYear",spacing:"spacing",margin:"margin",timezone:"timezone",config:"config"};for(let a=0;a<e.length;a+=1){let s=e[a];if(s==="-h"||s==="--help"){r.help=!0;continue}if(s==="--json"){r.json=!0;continue}if(s==="--diff"){r.diff=!0;continue}if(s==="--verbose"){t.verbose=!0;continue}if(s==="--dry-run"){t.dryRun=!0;continue}if(s==="--check"){t.check=!0;continue}if(s==="--fix-created-date"){t.fixCreatedDate=!0;continue}if(s==="--strict-created-date"){t.strictCreatedDate=!0;continue}if(s==="--normalize-date-format"){t.normalizeDateFormat=!0;continue}if(s==="--convert-timezone"){t.convertTimezone=!0;continue}if(s==="--sample-output"){t.sampleOutput=!0;continue}if(s==="--force-author-update"){t.forceAuthorUpdate=!0;continue}if(s==="--force-last-modified-author-update"){t.forceLastModifiedAuthorUpdate=!0;continue}if(s==="--use-gpg-signer-author"){t.useGpgSignerAuthor=!0;continue}if(!s.startsWith("--"))throw new Error(`Unexpected argument: ${s}`);let c=s.slice(2);if(c==="include-folder-non-recursive"){let f=e[a+1];if(!f||f.startsWith("--"))throw new Error(`Missing value for --${c}`);a+=1;let m=Array.isArray(t.includeFolders)?t.includeFolders:[];t.includeFolders=[...m,{path:f,recursive:!1}];continue}if(n[c]){let f=e[a+1];if(!f||f.startsWith("--"))throw new Error(`Missing value for --${c}`);a+=1;let m=n[c],g=Array.isArray(t[m])?t[m]:[];t[m]=Array.from(new Set([...g,f]));continue}if(o[c]){let f=e[a+1];if(!f||f.startsWith("--"))throw new Error(`Missing value for --${c}`);a+=1;let m=o[c];if(m==="copyrightStartYear"||m==="spacing"||m==="margin"){if(t[m]=Number.parseInt(f,10),Number.isNaN(t[m]))throw new Error(`Invalid number for --${c}: ${f}`)}else m==="marker"&&f==="null"?t[m]=null:t[m]=f;continue}let l=Vo(c),u=e[a+1];if(!u||u.startsWith("--"))throw new Error(`Unknown or malformed flag: --${c}`);a+=1,t[l]=u}return{options:t,help:r.help,json:r.json,diff:r.diff}}i(Jo,"parseCliArgs");function qo(e){return q(e,"config")}i(qo,"applyConfigFile");function Ie(e){if(!e||typeof e!="object")return[];let t=e;return(Array.isArray(t.changes)?t.changes:[]).filter(n=>n&&n.changed===!0&&n.sample&&typeof n.sample.newValue=="string")}i(Ie,"getSampledChanges");function Ir(e){return typeof e=="string"?`"${e}"`:"(missing)"}i(Ir,"formatIssueValue");function Ko(e,t){for(let r of Ie(t)){let n=Array.isArray(r.sample.issues)?r.sample.issues:[];if(e(`issues: ${r.file||"<unknown-file>"}`),n.length===0){e(" (no field differences; header formatting only)");continue}for(let o of n)e(` ${o?.field||"<unknown-field>"}: found ${Ir(o?.previous)}, expected ${Ir(o?.detected)}`)}}i(Ko,"printIssues");function Xo(e,t){for(let r of Ie(t))typeof r.sample.diff=="string"&&r.sample.diff.length>0&&e(r.sample.diff)}i(Xo,"printDiffs");function Zo(e,t){for(let r of Ie(t))e(`sample: ${r.file||"<unknown-file>"}`),e("previous:"),e(r.sample.previousValue===null?"(none)":String(r.sample.previousValue)),e("new:"),e(r.sample.newValue),r.sample.detectedValues&&typeof r.sample.detectedValues=="object"&&(e("detected-values:"),e(JSON.stringify(r.sample.detectedValues,null,2)))}i(Zo,"printSampleOutput");function Qo(e,t){if(!t||typeof t!="object")return;let r=t,o=(Array.isArray(r.changes)?r.changes:[]).filter(a=>a&&a.changed===!0).map(a=>a.file||"<unknown-file>");for(let a of o)e(`updated: ${a}`)}i(Qo,"printChangedFiles");function ei(e,t){let r=Array.isArray(t.skipped)?t.skipped:[];for(let n of r)e(`skipped: ${n?.file||"<unknown-file>"} (${n?.reason||"no reason given"})`)}i(ei,"printSkipped");function Or(e,t,r,n){let o=r.sampleOutput===!0||n;r.verbose===!0&&(Qo(e,t),o&&Ko(e,t)),r.sampleOutput===!0&&Zo(e,t),n&&Xo(e,t)}i(Or,"printDetails");function ti(e,t,r){let n=Array.isArray(t.changes)?t.changes:[];for(let o of n){let a=Array.isArray(o?.dateIssues)?o.dateIssues:[];for(let s of a)s.advisory===!0&&!r||e(`${s.advisory===!0?"advisory":"drift"}: ${o.file||"<unknown-file>"}: ${s.message}`)}}i(ti,"printDateIssues");async function ri(e,t={}){let r=t.runner||Rr,n=t.stdout||console.log,o=t.stderr||console.error;try{let a=Jo(e);if(a.help)return n(Go),0;let s=await qo(a.options),c=await r(a.diff?{...s,sampleOutput:!0}:s),l=c&&typeof c=="object"&&c.check===!0?c:null,u=l&&Number(l.filesWithDateDrift)>0?1:0;if(a.json)return n(JSON.stringify(c,null,2)),u;if(l)return n(`fix-headers check: scanned=${l.filesScanned??0}, drift=${l.filesWithDateDrift??0}, advisories=${l.dateAdvisories??0}`),ti(n,l,s.verbose===!0),u;if(c&&typeof c=="object"){let f=c,m=Number(f.filesSkipped)>0?`, skipped=${f.filesSkipped}`:"";n(`fix-headers complete: scanned=${f.filesScanned??0}, updated=${f.filesUpdated??0}${m}, dryRun=${f.dryRun===!0}`),ei(n,f),Or(n,c,s,a.diff)}else Or(n,c,s,a.diff),n("fix-headers complete");return 0}catch(a){let s=a instanceof Error?a.message:String(a);return o(`fix-headers failed: ${s}`),1}}i(ri,"runCli");function ni(e=process.argv,t=import.meta.url,r=ri){let n=!1;if(e[1])try{let o=Pr(e[1]),a=Pr(Wo(t));n=o===a}catch{n=t===Yo(e[1]).href}return n?(r(e.slice(2)).then(o=>{process.exitCode=o}),!0):!1}i(ni,"runCliAsMain");ni();export{qo as applyConfigFile,Jo as parseCliArgs,ri as runCli,ni as runCliAsMain};
84
+ `;function Ai(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}s(Ai,"toCamelCase");function Di(e){let t={},n={help:!1,json:!1,diff:!1},r={"include-folder":"includeFolders","exclude-folder":"excludeFolders","include-extension":"includeExtensions","enable-detector":"enabledDetectors","disable-detector":"disabledDetectors","force-detector":"forcedDetectors",input:"input"},o={cwd:"cwd","project-name":"projectName",language:"language","project-root":"projectRoot",marker:"marker","author-name":"authorName","author-email":"authorEmail",company:"company","company-name":"companyName","copyright-start-year":"copyrightStartYear",spacing:"spacing",margin:"margin",timezone:"timezone",config:"config"};for(let i=0;i<e.length;i+=1){let a=e[i];if(a==="-h"||a==="--help"){n.help=!0;continue}if(a==="--json"){n.json=!0;continue}if(a==="--diff"){n.diff=!0;continue}if(a==="--verbose"){t.verbose=!0;continue}if(a==="--dry-run"){t.dryRun=!0;continue}if(a==="--check"){t.check=!0;continue}if(a==="--fix-created-date"){t.fixCreatedDate=!0;continue}if(a==="--strict-created-date"){t.strictCreatedDate=!0;continue}if(a==="--strict-header-block"){let u=e[i+1];(u==="true"||u==="false")&&(i+=1),t.strictHeaderBlock=u!=="false";continue}if(a==="--no-strict-header-block"){t.strictHeaderBlock=!1;continue}if(a==="--normalize-date-format"){t.normalizeDateFormat=!0;continue}if(a==="--convert-timezone"){t.convertTimezone=!0;continue}if(a==="--sample-output"){t.sampleOutput=!0;continue}if(a==="--force-author-update"){t.forceAuthorUpdate=!0;continue}if(a==="--force-last-modified-author-update"){t.forceLastModifiedAuthorUpdate=!0;continue}if(a==="--use-gpg-signer-author"){t.useGpgSignerAuthor=!0;continue}if(!a.startsWith("--"))throw new Error(`Unexpected argument: ${a}`);let c=a.slice(2);if(c==="include-folder-non-recursive"){let u=e[i+1];if(!u||u.startsWith("--"))throw new Error(`Missing value for --${c}`);i+=1;let m=Array.isArray(t.includeFolders)?t.includeFolders:[];t.includeFolders=[...m,{path:u,recursive:!1}];continue}if(r[c]){let u=e[i+1];if(!u||u.startsWith("--"))throw new Error(`Missing value for --${c}`);i+=1;let m=r[c],h=Array.isArray(t[m])?t[m]:[];t[m]=Array.from(new Set([...h,u]));continue}if(o[c]){let u=e[i+1];if(!u||u.startsWith("--"))throw new Error(`Missing value for --${c}`);i+=1;let m=o[c];if(m==="copyrightStartYear"||m==="spacing"||m==="margin"){if(t[m]=Number.parseInt(u,10),Number.isNaN(t[m]))throw new Error(`Invalid number for --${c}: ${u}`)}else m==="marker"&&u==="null"?t[m]=null:t[m]=u;continue}let l=Ai(c),d=e[i+1];if(!d||d.startsWith("--"))throw new Error(`Unknown or malformed flag: --${c}`);i+=1,t[l]=d}return{options:t,help:n.help,json:n.json,diff:n.diff}}s(Di,"parseCliArgs");function Ci(e){return re(e,"config")}s(Ci,"applyConfigFile");function Je(e){if(!e||typeof e!="object")return[];let t=e;return(Array.isArray(t.changes)?t.changes:[]).filter(r=>r&&r.changed===!0&&r.sample&&typeof r.sample.newValue=="string")}s(Je,"getSampledChanges");function nr(e){return typeof e=="string"?`"${e}"`:"(missing)"}s(nr,"formatIssueValue");function vi(e,t){for(let n of Je(t)){let r=Array.isArray(n.sample.issues)?n.sample.issues:[];if(e(`issues: ${n.file||"<unknown-file>"}`),r.length===0){e(" (no field differences; header formatting only)");continue}for(let o of r)e(` ${o?.field||"<unknown-field>"}: found ${nr(o?.previous)}, expected ${nr(o?.detected)}`)}}s(vi,"printIssues");function Ni(e,t){for(let n of Je(t))typeof n.sample.diff=="string"&&n.sample.diff.length>0&&e(n.sample.diff)}s(Ni,"printDiffs");function Fi(e,t){for(let n of Je(t))e(`sample: ${n.file||"<unknown-file>"}`),e("previous:"),e(n.sample.previousValue===null?"(none)":String(n.sample.previousValue)),e("new:"),e(n.sample.newValue),n.sample.detectedValues&&typeof n.sample.detectedValues=="object"&&(e("detected-values:"),e(JSON.stringify(n.sample.detectedValues,null,2)))}s(Fi,"printSampleOutput");function Li(e,t){if(!t||typeof t!="object")return;let n=t,o=(Array.isArray(n.changes)?n.changes:[]).filter(i=>i&&i.changed===!0).map(i=>i.file||"<unknown-file>");for(let i of o)e(`updated: ${i}`)}s(Li,"printChangedFiles");function rr(e,t){let n=Array.isArray(t.copyrightWarnings)?t.copyrightWarnings:[];for(let r of n)e(`warning: ${r?.file||"<unknown-file>"} keeps an additional @Copyright: ${r?.copyright??""}`)}s(rr,"printCopyrightWarnings");function ji(e,t){let n=Array.isArray(t.skipped)?t.skipped:[];for(let r of n)e(`skipped: ${r?.file||"<unknown-file>"} (${r?.reason||"no reason given"})`)}s(ji,"printSkipped");function or(e,t,n,r){let o=n.sampleOutput===!0||r;n.verbose===!0&&(Li(e,t),o&&vi(e,t)),n.sampleOutput===!0&&Fi(e,t),r&&Ni(e,t)}s(or,"printDetails");function Mi(e,t,n){let r=Array.isArray(t.changes)?t.changes:[];for(let o of r){let i=Array.isArray(o?.dateIssues)?o.dateIssues:[];for(let a of i)a.advisory===!0&&!n||e(`${a.advisory===!0?"advisory":"drift"}: ${o.file||"<unknown-file>"}: ${a.message}`)}}s(Mi,"printDateIssues");async function Ri(e,t={}){let n=t.runner||er,r=t.stdout||console.log,o=t.stderr||console.error;try{let i=Di(e);if(i.help)return r(Si),0;let a=await Ci(i.options),c=await n(i.diff?{...a,sampleOutput:!0}:a),l=c&&typeof c=="object"&&c.check===!0?c:null,d=l&&Number(l.filesWithDateDrift)>0?1:0;if(i.json)return r(JSON.stringify(c,null,2)),d;if(l)return r(`fix-headers check: scanned=${l.filesScanned??0}, drift=${l.filesWithDateDrift??0}, advisories=${l.dateAdvisories??0}`),Mi(r,l,a.verbose===!0),rr(r,c),d;if(c&&typeof c=="object"){let u=c,m=Number(u.filesSkipped)>0?`, skipped=${u.filesSkipped}`:"",h=Array.isArray(u.copyrightWarnings)&&u.copyrightWarnings.length>0?`, warnings=${u.copyrightWarnings.length}`:"";r(`fix-headers complete: scanned=${u.filesScanned??0}, updated=${u.filesUpdated??0}${m}${h}, dryRun=${u.dryRun===!0}`),ji(r,u),rr(r,u),or(r,c,a,i.diff)}else or(r,c,a,i.diff),r("fix-headers complete");return 0}catch(i){let a=i instanceof Error?i.message:String(i);return o(`fix-headers failed: ${a}`),1}}s(Ri,"runCli");function Pi(e=process.argv,t=import.meta.url,n=Ri){let r=!1;if(e[1])try{let o=tr(e[1]),i=tr(Ei(t));r=o===i}catch{r=t===$i(e[1]).href}return r?(n(e.slice(2)).then(o=>{process.exitCode=o}),!0):!1}s(Pi,"runCliAsMain");Pi();export{Ci as applyConfigFile,Di as parseCliArgs,Ri as runCli,Pi as runCliAsMain};
66
85
  //# sourceMappingURL=fix-headers.mjs.map
package/dist/index.cjs CHANGED
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  *
3
3
  * @Project: @cldmv/fix-headers
4
- * @Filename: /src/cjs/index.cjs
4
+ * @Filename: /src/index.cjs
5
5
  * @Date: 2026-09-28T06:56:09-07:00 (1790603769)
6
6
  * @Author: Nate Corcoran <CLDMV>
7
7
  * @Email: <Shinrai@users.noreply.github.com>
8
8
  * -----
9
9
  * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
- * @Last modified time: 2026-10-02T12:28:11-07:00 (1790969291)
10
+ * @Last modified time: 2026-10-31T14:46:53-07:00 (1793483213)
11
11
  * -----
12
12
  * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
13
  *
@@ -25,8 +25,10 @@
25
25
  * ERR_REQUIRE_ESM, so the check below fails early with a message that says what to do
26
26
  * instead.
27
27
  *
28
- * tsup copies this folder verbatim into dist/ (`publicDir` in tsup.config.mjs); it
29
- * never passes through esbuild, so it stays this small however much the library grows.
28
+ * It sits next to the ESM entry under the same name, so `require("./index.mjs")` resolves
29
+ * to src/index.mjs from source and to dist/index.mjs once built. tsup's `onSuccess` copies
30
+ * it verbatim into dist/ (tsup.config.mjs); it never passes through esbuild, so it stays
31
+ * this small however much the library grows.
30
32
  * @module fix-headers/cjs-entry
31
33
  */
32
34
  "use strict";