nemar-cli 0.10.18-dev.3417 → 0.10.18-dev.3427
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -99,7 +99,7 @@ ${t}`,eIe,tIe,rIe=(e,t,r)=>{let n=r===""?"":`with ${r.trim()}() `,i=Q6e.bind(nul
|
|
|
99
99
|
`)}var R2=!1;var{spawn:jJe}=globalThis.Bun;function Vl(e,t=[]){let r=e.replace(MJe,'("$1","<redacted>")');for(let n of t)if(n.length>=qJe)r=r.split(n).join("<redacted>");return r}function rw(e){let t=["AWS_SESSION_TOKEN","AWS_SECRET_ACCESS_KEY","AWS_ACCESS_KEY_ID"],r=new Set;for(let n of[process.env,e??{}])for(let i of t){let o=n[i];if(typeof o==="string"&&o.length>0)r.add(o)}return[...r]}async function Xte(e,t){let r=e.getReader(),n=new TextDecoder,i="";while(!0){let{done:o,value:s}=await r.read();if(o)break;if(s.byteLength===0)continue;t(),i+=n.decode(s,{stream:!0})}return i+n.decode()}async function k(e,t={}){let r={...process.env,GIT_TERMINAL_PROMPT:"0",...t.env};for(let b of t.unsetEnv??[])delete r[b];let n=jJe({cmd:e,cwd:t.cwd,...t.stdin===void 0?{}:{stdin:new TextEncoder().encode(t.stdin)},stdout:"pipe",stderr:"pipe",env:r}),i=!1,o,s,a=performance.now(),c=()=>{if(s!==void 0)clearTimeout(s),s=void 0},u=()=>{if(!t.onInactivityWarning)return;c(),s=setTimeout(()=>{s=void 0;try{t.onInactivityWarning?.(performance.now()-a)}catch{console.error("Could not display subprocess inactivity warning; the child result is unaffected.")}},t.inactivityWarningAfterMs??LJe)};if(u(),t.timeout)o=setTimeout(()=>{i=!0,c(),n.kill()},t.timeout);let d=tw()?[...rw(r),...t.redact??[]]:[];if(tw()){let b=t.cwd?` (cwd=${t.cwd})`:"";Ic(l.dim(Vl(`$ ${e.join(" ")}${b}`,d)))}let f=()=>{a=performance.now(),u()},m,p,g,h=n.exited.then((b)=>(c(),b));try{[m,p,g]=await Promise.all([Xte(n.stdout,f),Xte(n.stderr,f),h])}finally{if(c(),o)clearTimeout(o)}if(tw()){if(t.sensitiveOutput)Ic(l.dim("[sensitive subprocess output suppressed]"));else{if(m.trim())Ic(l.dim(Vl(m.trimEnd(),d)));if(p.trim())Ic(l.yellow(Vl(p.trimEnd(),d)))}Ic(l.dim(`(exit ${g})`))}if(i)return{stdout:m,stderr:p||`Command timed out after ${Math.round(t.timeout/1000)}s`,exitCode:g??1,timedOut:!0};return{stdout:m,stderr:p,exitCode:g,timedOut:!1}}var MJe,qJe=8,LJe=120000;var It=I(()=>{Ze();MJe=/\(\s*"((?:x-amz-)[^"]*|authorization|proxy-authorization)"\s*,\s*"[^"]*"\s*\)/gi});function UJe(){if(process.platform==="darwin")return"macos";if(process.platform==="win32")return"windows";return"linux"}function Qte(e,t=UJe()){return e.installInstructions[t]}function zJe(e){let t=e.match(/(\d+\.\d+(?:\.\d+)?)/);return t?t[1]:void 0}function HJe(){let e=Number(process.env.TEST_PROBE_TIMEOUT_MS);return Number.isFinite(e)&&e>0?e:VJe}async function ere(e){try{let{exitCode:t,stdout:r,timedOut:n}=await k(e.cmd,{timeout:HJe()});if(n)return{available:!1,timedOut:!0};if(t!==0)return{available:!1};return{available:!0,version:zJe(r)}}catch(t){let r=t instanceof Error?t.message:String(t);if(!r.includes("ENOENT")&&!r.includes("not found"))console.error(` Warning: ${e.name} check failed unexpectedly: ${r}`);return{available:!1}}}async function ph(){let e=Object.entries(Zte);return Promise.all(e.map(async([t,r])=>{let{available:n,version:i,timedOut:o}=await ere(r);return{key:t,name:r.name,purpose:r.purpose,required:r.required,available:n,version:i,timedOut:o,installInstruction:Qte(r)}}))}async function tre(){let t=(await ph()).filter((r)=>r.required&&!r.available);if(t.length===0)return[];console.warn(`
|
|
100
100
|
Heads up: some tools NEMAR needs for uploading/validating aren't installed yet:`);for(let r of t)console.warn(` - ${r.name} (${r.purpose})`),console.warn(` Install: ${r.installInstruction}`);return console.warn("Run `nemar doctor` anytime to re-check. You can finish signup without them.\n"),t}async function Hl(e){let r=BJe[e].map((s)=>Zte[s]).filter(Boolean),n=await Promise.all(r.map(async(s)=>{let a=await ere(s);return{check:s,available:a.available,timedOut:a.timedOut}}));for(let s of n)if(s.timedOut&&s.check.required)console.warn(`Warning: ${s.check.name} did not respond to a version check in time; continuing anyway.`);let i=n.filter((s)=>!s.available&&!s.timedOut&&s.check.required).map((s)=>({tool:s.check.name,installInstruction:Qte(s.check)}));if(i.length===0)return;let o=[`
|
|
101
101
|
Missing required tools:`];for(let s of i)o.push(` ${s.tool} not installed`),o.push(` Install: ${s.installInstruction}`);throw Error(o.join(`
|
|
102
|
-
`))}var Zte,BJe,VJe=4000;var mh=I(()=>{It();Zte={git:{name:"git",purpose:"version control for dataset metadata",cmd:["git","--version"],required:!0,installInstructions:{macos:"brew install git (or install Xcode Command Line Tools)",linux:"sudo apt-get install git OR sudo dnf install git",windows:"winget install Git.Git (or https://git-scm.com/download/win)"}},"git-annex":{name:"git-annex",purpose:"large-file data transfer (upload/download)",cmd:["git-annex","version"],required:!0,installInstructions:{macos:"brew install git-annex",linux:"sudo apt-get install git-annex OR sudo dnf install git-annex",windows:"Download the installer from https://git-annex.branchable.com/install/Windows/"}},gh:{name:"GitHub CLI (gh)",purpose:"GitHub authentication + repository operations",cmd:["gh","--version"],required:!0,installInstructions:{macos:"brew install gh",linux:"See https://cli.github.com/manual/installation",windows:"winget install GitHub.cli (or: scoop install gh)"}},aws:{name:"AWS CLI",purpose:"S3 data upload/download",cmd:["aws","--version"],required:!0,installInstructions:{macos:"brew install awscli",linux:"pip install awscli OR sudo snap install aws-cli --classic",windows:"winget install Amazon.AWSCLI (or the MSI from https://aws.amazon.com/cli/)"}},deno:{name:"Deno",purpose:"BIDS validation",cmd:["deno","--version"],required:!0,installInstructions:{macos:"brew install deno (or: curl -fsSL https://deno.land/install.sh | sh)",linux:"curl -fsSL https://deno.land/install.sh | sh",windows:"winget install DenoLand.Deno (or: irm https://deno.land/install.ps1 | iex)"}}},BJe={upload:["git-annex","gh","aws","deno"],download:["gh"],clone:["git","gh"],push:["git-annex","gh"],publish:["gh","aws"],update:["git","gh"],release:["git","gh"]}});var nre;var rre=I(()=>{nre={name:"nemar-cli",packageManager:"bun@1.4.3",version:"0.10.18-dev.
|
|
102
|
+
`))}var Zte,BJe,VJe=4000;var mh=I(()=>{It();Zte={git:{name:"git",purpose:"version control for dataset metadata",cmd:["git","--version"],required:!0,installInstructions:{macos:"brew install git (or install Xcode Command Line Tools)",linux:"sudo apt-get install git OR sudo dnf install git",windows:"winget install Git.Git (or https://git-scm.com/download/win)"}},"git-annex":{name:"git-annex",purpose:"large-file data transfer (upload/download)",cmd:["git-annex","version"],required:!0,installInstructions:{macos:"brew install git-annex",linux:"sudo apt-get install git-annex OR sudo dnf install git-annex",windows:"Download the installer from https://git-annex.branchable.com/install/Windows/"}},gh:{name:"GitHub CLI (gh)",purpose:"GitHub authentication + repository operations",cmd:["gh","--version"],required:!0,installInstructions:{macos:"brew install gh",linux:"See https://cli.github.com/manual/installation",windows:"winget install GitHub.cli (or: scoop install gh)"}},aws:{name:"AWS CLI",purpose:"S3 data upload/download",cmd:["aws","--version"],required:!0,installInstructions:{macos:"brew install awscli",linux:"pip install awscli OR sudo snap install aws-cli --classic",windows:"winget install Amazon.AWSCLI (or the MSI from https://aws.amazon.com/cli/)"}},deno:{name:"Deno",purpose:"BIDS validation",cmd:["deno","--version"],required:!0,installInstructions:{macos:"brew install deno (or: curl -fsSL https://deno.land/install.sh | sh)",linux:"curl -fsSL https://deno.land/install.sh | sh",windows:"winget install DenoLand.Deno (or: irm https://deno.land/install.ps1 | iex)"}}},BJe={upload:["git-annex","gh","aws","deno"],download:["gh"],clone:["git","gh"],push:["git-annex","gh"],publish:["gh","aws"],update:["git","gh"],release:["git","gh"]}});var nre;var rre=I(()=>{nre={name:"nemar-cli",packageManager:"bun@1.4.3",version:"0.10.18-dev.3427",description:"CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",type:"module",main:"dist/index.js",bin:{nemar:"dist/index.js"},scripts:{dev:"bun run src/index.ts",build:"bun build src/index.ts --outdir dist --target bun --minify && sed '1s|#!/usr/bin/env node|#!/usr/bin/env bun|' dist/index.js > dist/index.js.tmp && mv dist/index.js.tmp dist/index.js",test:"bun test",lint:"biome check src/","lint:scrub":"biome check scripts/scrub shared/identifier-scrub.ts test/scrub","test:scrub":"bun test --preload ./test/scrub/helpers/temp-dirs-preload.ts --path-ignore-patterns='__run_every_scrub_suite__' test/scrub test/identifier-scan.test.ts test/identifier-scrub.test.ts test/identifier-dates.test.ts test/identifier-fleet.test.ts","migrations:d1-check":"bun run scripts/d1-migration-check.ts","zarr:geometry-check":"bun run backend/scripts/zarr-geometry-conformance.ts","lint:fix":"biome check --fix src/",format:"biome format --write src/",typecheck:"tsc --noEmit && tsc --noEmit -p backend","generate-openapi":"bun run scripts/generate-openapi.ts",prepublishOnly:"bun run build",prepare:"husky",postinstall:"bun scripts/postinstall-check.mjs",deploy:"wrangler deploy",preview:"wrangler dev"},keywords:["nemar","bids","neuroimaging","eeg","emg","datalad","cli"],author:"NEMAR Team",license:"CC-BY-NC-ND-4.0",repository:{type:"git",url:"git+https://github.com/nemarOrg/nemar-cli.git"},bugs:{url:"https://github.com/nemarOrg/nemar-cli/issues"},homepage:"https://docs.nemar.org",engines:{bun:">=1.0.0"},files:["dist","scripts/postinstall-check.mjs","scripts/recover-datasets.json","scripts/withdrawn-datasets.json","README.md","LICENSE"],dependencies:{chalk:"^5.3.0",commander:"^12.1.0",conf:"^13.0.1",inquirer:"^9.2.15",ora:"^8.0.1",semver:"^7.8.5",zod:"^3.23.8"},"lint-staged":{"src/**/*.{ts,tsx}":["biome check --fix"],"backend/src/**/*.{ts,tsx}":["biome check --fix"]},devDependencies:{"@anthropic-ai/sdk":"^0.132.1","@asteasolutions/zod-to-openapi":"^7.3.4","@biomejs/biome":"1.9.4","@types/bun":"latest","@types/inquirer":"^9.0.7","@types/semver":"^7.8.0",ajv:"^8.20.0","ajv-formats":"^3.0.1",husky:"^9.1.7","lint-staged":"^16.3.2",typescript:"^5.5.4",wrangler:"^4.70.0",yaml:"^2.8.4"}}});var eo;var kf=I(()=>{rre();eo=nre.version});import{mkdirSync as WJe,readdirSync as KJe,unlinkSync as JJe,writeFileSync as YJe}from"fs";import{join as A2}from"path";function lre(){Cf=!0}function Gl(){return Cf}function ure(e,t=process.env){return e.includes("--debug")||t.NEMAR_DEBUG==="1"}function gh(e){cre=e,Zt(`Step: ${e}`)}function yh(){sre=!0}function dre(){return sre}function Qt(){are=!0}function fre(){return are}function Zt(e){if(Cf)process.stderr.write(`[debug] ${e}
|
|
103
103
|
`)}function eYe(e){let t={};for(let[r,n]of Object.entries(e))t[r]=QJe.has(r.toLowerCase())?"[REDACTED]":n;return t}function mre(e){let t=e.indexOf("@");if(t<=0)return"***";return`${e[0]}***${e.slice(t)}`}function O2(e,t,r=0){if(r>rYe)return"[REDACTED: depth]";if(Array.isArray(t))return t.map((n)=>O2(e,n,r+1));if(t&&typeof t==="object"){let n={};for(let[i,o]of Object.entries(t))n[i]=O2(i,o,r+1);return n}if(typeof t==="string"){if(tYe.test(e))return"[REDACTED]";return t.replace(pre,mre)}return t}function T2(e){return e.replace(nYe,"Bearer [REDACTED]").replace(iYe,"[REDACTED_AWS_KEY]").replace(oYe,"$1[REDACTED]").replace(sYe,"$1$2=[REDACTED]").replace(pre,mre)}function aYe(e){return T2(e)}function ire(e,t=ZJe){if(e===void 0)return;let r=e;try{let n=JSON.parse(e);r=JSON.stringify(O2("",n))}catch{}if(r=T2(r),Buffer.byteLength(r,"utf8")>t)r=`${Buffer.from(r,"utf8").subarray(0,t).toString("utf8")}... [truncated]`;return r}function ow(e){if(!Cf)return;let t=aYe(e.url);try{let r={...e,url:t,requestHeaders:e.requestHeaders?eYe(e.requestHeaders):void 0,requestBody:ire(e.requestBody),responseBody:ire(e.responseBody)};iw.push(r),Zt(`${e.method} ${t} -> ${e.status??"ERROR"} (${e.durationMs}ms)`)}catch(r){let n=q(r);iw.push({method:e.method,url:t,status:e.status,durationMs:e.durationMs,note:`redaction failed: ${n}`}),Zt(`redaction failed for ${e.method} ${t}: ${n}`)}}async function cYe(){let e=[];try{let t=process.versions.bun?`Bun ${process.versions.bun}`:`Node ${process.version}`;e.push(`CLI version: ${eo}`),e.push(`OS/Arch: ${process.platform}/${process.arch}`),e.push(`Runtime: ${t}`)}catch(t){e.push(`(could not read CLI/OS/runtime info: ${q(t)})`)}e.push(""),e.push("Active account:");try{let t=Ft();if(t.apiKey){if(t.username)e.push(` Username: ${t.username}`);if(e.push(` API URL: ${t.apiUrl}`),t.role)e.push(` Role: ${t.role}`);e.push(` Sandbox completed: ${!!t.sandboxCompleted}`)}else e.push(" (not authenticated)")}catch(t){e.push(` (could not read account config: ${q(t)})`)}e.push(""),e.push("External tools:");try{let t=await ph();for(let r of t){let n=r.available?r.version??"installed":r.timedOut?"(timed out)":"not installed";e.push(` ${r.name}: ${n}`)}}catch(t){e.push(` (could not probe external tools: ${q(t)})`)}return e}async function F2(){return(await cYe()).join(`
|
|
104
104
|
`)}async function hre(){if(!Cf||nw!==void 0)return;try{nw=await F2()}catch(e){let t=q(e);nw=`(could not build environment report: ${t})`,Zt(`environment snapshot failed: ${t}`)}}function gre(e){if(ore.has(e))return{flag:e};for(let t of ore){if(!e.startsWith(t)||e.length<=t.length)continue;if(t.length===2)return{flag:t,kind:"short-attached"};if(e[t.length]==="=")return{flag:t,kind:"long-eq"}}return null}function lYe(e){let t=[];for(let r=0;r<e.length;r++){let n=e[r],i=gre(n);if(!i){t.push(n);continue}if(i.kind==="long-eq")t.push(`${i.flag}=[REDACTED]`);else if(i.kind==="short-attached")t.push(`${i.flag}[REDACTED]`);else if(t.push(n),r+1<e.length)t.push("[REDACTED]"),r++}return t}function uYe(e){let t=[];for(let r=0;r<e.length;r++){let n=e[r],i=gre(n);if(!i){t.push(n);continue}if(!i.kind&&r+1<e.length)r++}return t}function dYe(e){let t=[];for(let n of uYe(e)){if(n.startsWith("-"))continue;if(t.push(n),t.length===2)break}return(t.length>0?t.join("-"):"nemar").replace(/[^a-zA-Z0-9_-]/g,"_")}function fYe(e,t){let r=[];if(r.push("NEMAR CLI Debug Log"),r.push(`Generated: ${new Date().toISOString()}`),r.push(`Command: nemar ${T2(lYe(e).join(" "))}`),r.push(""),r.push(nw??"(environment snapshot unavailable)"),r.push(""),r.push("HTTP requests:"),iw.length===0)r.push(" (none)");else iw.forEach((n,i)=>{if(r.push(` [${i+1}] ${n.method} ${n.url} -> ${n.status??"ERROR"} (${n.durationMs}ms)`),n.error)r.push(` Error: ${n.error}`);if(n.note)r.push(` Note: ${n.note}`);if(n.requestHeaders)r.push(` Request headers: ${JSON.stringify(n.requestHeaders)}`);if(n.requestBody)r.push(` Request body: ${n.requestBody}`);if(n.responseBody)r.push(` Response body: ${n.responseBody}`)});return r.push(""),r.push(`Failing step: ${cre??"(none recorded)"}`),r.push(`Exit code: ${t}`),`${r.join(`
|
|
105
105
|
`)}
|
|
@@ -135,7 +135,7 @@ Interrupted while ${t.length} annexed file(s) were marked assume-unchanged, and
|
|
|
135
135
|
`}function xC(e){let t=Buffer.from(e),r=Date.now()+sXe,n=0;while(n<t.length&&Date.now()<r)try{n+=KYe(2,t,n)}catch(i){if(i.code!=="EAGAIN")return;Iw(aXe)}}function lXe(e,t){let r=t.map((o)=>`${o.path}\x00`).join("");function n(){for(let o of Eh)process.removeListener(o,i)}function i(o){let s=Date.now()+nXe,a=Hie(e,r,Vie);if(a){bC();while(a&&Date.now()<s)Iw(iXe),a=Hie(e,r,Vie)}if(a)xC(cXe(e,t,a));n(),process.kill(process.pid,o)}for(let o of Eh)process.on(o,i);return n}function Gie(e,t){let r=[],n=[],i=[],o=[];for(let s of t){let a;try{a=WYe(JYe(e,s.path))}catch(c){let u=c.code;if(u==="ENOENT"||u==="ENOTDIR")i.push(s.path);else o.push(s.path);continue}if(a.size!==s.size||a.mtimeMs!==s.mtimeMs)n.push(s.path);else r.push(s)}return{unchanged:r,changed:n,vanished:i,unreadable:o}}function Wie(e,t){let r=Dw(e.slice(0,3)),n=e.length>3?` (and ${e.length-3} more)`:"";if(t==="during")return`${e.length} annexed file(s) changed, disappeared or became unreadable while the save was running, so the commit does not match the tree: ${r}${n}. Re-run the upload command to re-track them.`;return`${e.length} annexed file(s) changed since the upload plan recorded them, so the commit would not match the tree: ${r}${n}. Re-run the upload command to re-track them.`}function hC(e,t="save"){if(t==="upload"){if(e.stage==="clear")return`Could not clear ${e.found} assume-unchanged flag(s) on annexed files (${e.error}). git skips those files until they are cleared, so the upload stopped before tracking anything. Run the upload again.`;return`Could not check this repository for assume-unchanged flags (${e.error}). A flag left behind would make git skip a file, so the upload stopped before tracking anything. Run the upload again; if git keeps failing, the repository needs attention.`}if(e.stage==="clear")return`Found ${e.found} assume-unchanged flag(s) on annexed files but could not clear them (${e.error}). They would hide edits from this save, so nothing was saved. Run the save again: every save clears them first.`;return`Could not check this repository for assume-unchanged flags (${e.error}). A flag left behind would hide edits from this save, so nothing was saved. Run the save again; if git keeps failing, the repository needs attention.`}function uXe(e,t,r){return`${r?"The save was committed, but ":""}${e} assume-unchanged flag(s) it set could not be cleared (${t}). Until they are, git hides later edits to those files. Run \`nemar dataset commit\` in this directory, or the upload again: both clear stale flags before they save.`}async function gC(e){let t=(r,n,i=0)=>({cleared:0,found:i,error:n,stage:r});try{let r=await k(["git","ls-files","-v","-z"],{cwd:e});if(r.exitCode!==0)return t("list",r.stderr.trim()||"git ls-files failed");let n=r.stdout.split("\x00").filter((s)=>YYe.test(s)).map((s)=>s.slice(2));if(n.length===0)return{cleared:0,found:0};let i=[];for(let s of ln(n)){let a=await k(["git","--literal-pathspecs","ls-files","-s","-z","--",...s],{cwd:e});if(a.exitCode!==0)return t("classify",a.stderr.trim()||"git ls-files -s failed");let c=[];for(let d of a.stdout.split("\x00").filter(Boolean)){let f=d.match(/^(\d{6}) \S+ \d\t(.*)$/s);if(!f)continue;if(f[1]==="120000")i.push(f[2]);else c.push(f[2])}if(c.length===0)continue;let u=await k(["git","--literal-pathspecs","grep","--cached","-l","-z","-e","^/annex/objects/","--",...c],{cwd:e});if(u.exitCode>1)return t("classify",u.stderr.trim()||`git grep exited ${u.exitCode}`);i.push(...u.stdout.split("\x00").filter(Boolean))}if(i.length===0)return{cleared:0,found:0};let o=await Fw(e,i,!1);if(!o.success)return t("clear",o.error??"git update-index failed",i.length);return{cleared:i.length,found:i.length}}catch(r){return t("classify",r instanceof Error?r.message:String(r))}}async function Fw(e,t,r){try{let{stderr:n,exitCode:i}=await k(["git","update-index",r?"--assume-unchanged":"--no-assume-unchanged","-z","--stdin"],{cwd:e,stdin:t.map((o)=>`${o}\x00`).join("")});if(i!==0)return{success:!1,error:n.trim()||`git update-index exited ${i}`};return{success:!0}}catch(n){return{success:!1,error:n instanceof Error?n.message:String(n)}}}async function dXe(e,t,r,n={}){try{let i={};if(r)i.GIT_AUTHOR_NAME=r.name,i.GIT_AUTHOR_EMAIL=r.email,i.GIT_COMMITTER_NAME=r.name,i.GIT_COMMITTER_EMAIL=r.email;let{stderr:o,exitCode:s}=await k(["git","add","-A"],{cwd:e,...Object.keys(i).length>0?{env:i}:{},...n.onInactivityWarning?{onInactivityWarning:n.onInactivityWarning}:{},...n.inactivityWarningAfterMs===void 0?{}:{inactivityWarningAfterMs:n.inactivityWarningAfterMs}});if(s!==0)return{success:!1,error:o.trim()||"Failed to stage changes"};let{stdout:a,exitCode:c,stderr:u}=await k(["git","status","--porcelain"],{cwd:e});if(c!==0)return{success:!1,error:u.trim()||"Failed to check git status"};if(!a.trim())return{success:!0};let{stderr:d,exitCode:f}=await k(["git","commit","-m",t],{cwd:e,...Object.keys(i).length>0?{env:i}:{}});if(f!==0){if(d.includes("nothing to commit"))return{success:!0};return{success:!1,error:d.trim()||"Failed to commit changes"}}return{success:!0}}catch(i){return{success:!1,error:i.message}}}function Zie(e){return/\[rejected\]|fetch first|non-fast-forward|Updates were rejected/i.test(e)}async function Tw(e,t,r){if(t===r)return!0;let n=await k(["git","merge-base","--is-ancestor",t,r],{cwd:e});if(n.exitCode===0)return!0;if(n.exitCode===1)return!1;return}async function fXe(e,t,r){let n=`refs/remotes/${t}/git-annex`,i=async()=>{let d=await k(["git","rev-parse","--verify","--quiet",`${n}^{commit}`],{cwd:e});if(d.exitCode===0)return{success:!0,oid:d.stdout.trim()};if(d.exitCode===1)return{success:!0};return{success:!1}},o=(d)=>({success:!1,error:`${n} could not be updated after the checked annex push: ${d}`}),s=await i();if(!s.success)return o("its current value could not be read");let a=await Jie(e,r);if(!a.success)return o("the remote annex tip could not be refreshed");let c=await i();if(!c.success)return o("its current value could not be read");let u="the compare-and-swap failed without an error message";for(let d=0;d<3;d++){if(c.oid===a.oid)return{success:!0};if(c.oid!==s.oid){if(!c.oid)return o("it was removed during the refresh and was preserved");let b=await Tw(e,a.oid,c.oid);if(b===!0)return{success:!0};if(b===void 0)return o("its current value could not be compared with the refreshed remote tip");if(await Tw(e,c.oid,a.oid)!==!0)return o("it changed during the refresh and the divergent value was preserved")}let f=c.oid?`update ${n} ${a.oid} ${c.oid}
|
|
136
136
|
`:`create ${n} ${a.oid}
|
|
137
137
|
`,m=await k(["git","update-ref","--stdin"],{cwd:e,stdin:f});if(m.exitCode===0)return{success:!0};u=m.stderr.trim()||`compare-and-swap exited ${m.exitCode}`;let p=await i();if(!p.success)return o(u);if(p.oid===a.oid)return{success:!0};if(!p.oid){if(s.oid)return o("it was removed during the refresh and was preserved");c=p;continue}let g=await Tw(e,a.oid,p.oid);if(g===!0)return{success:!0};if(g===void 0)return o(`its value after the compare-and-swap could not be compared with the remote tip (${u})`);if(await Tw(e,p.oid,a.oid)!==!0)return o(`it changed during the compare-and-swap and the divergent value was preserved (${u})`);c=p}return o(`the update did not succeed after three compare-and-swap attempts (${u})`)}async function Qie(e,t,r){let n="",i,o=0,s=r;for(let c=0;c<=Pw;c++){if(c>0){let m=await yC(e,t);if(!m.success)return{success:!1,error:m.error,retryPreparationFailed:!0};s=m}let u=await k(["git","push",s.remoteUrl,`${s.localOid}:refs/heads/git-annex`],{cwd:e});if(u.exitCode===0){let m=await k(["git","rev-parse","refs/heads/git-annex^{commit}"],{cwd:e});if(m.exitCode!==0||m.stdout.trim()!==s.localOid)return{success:!1,error:"The checked git-annex history was pushed, but the local annex branch advanced during the push. Review and retry to publish the remaining changes.",localRefAdvanced:!0};let p=await fXe(e,t,s.remoteUrl);if(!p.success)return{success:!1,error:p.error,trackingRefUpdateFailed:!0};return{success:!0}}if(n=u.stderr,c===Pw||!Zie(u.stderr))break;let d=await k(["git","fetch",t,"git-annex"],{cwd:e});if(d.exitCode!==0){i=`fetch ${t} git-annex failed: ${d.stderr.trim()||`exit ${d.exitCode}`}`;break}let f=await k(["git","annex","merge"],{cwd:e});if(f.exitCode!==0){i=`git annex merge failed: ${f.stderr.trim()||`exit ${f.exitCode}`}`;break}o++}let a=o>0?` (still rejected after ${o} fetch+merge retry cycle(s))`:"";return{success:!1,error:i?`${i} (after push was rejected: ${n.trim()||"unknown rejection"})`:`${n.trim()||"Failed to push git-annex branch"}${a}`}}async function Sh(e,t="origin"){try{let r=await yC(e,t);if(!r.success)return{success:!1,error:r.error};return await Qie(e,t,r)}catch(r){return{success:!1,error:r.message}}}async function Dr(e,t="origin",r){try{let n=r;if(!n){let f=await ls(e);if(!f||f==="HEAD"){let{exitCode:m}=await k(["git","log","-1","--oneline"],{cwd:e});if(m!==0)return{success:!1,error:"No commits found. The repository may not have been initialized correctly, or no changes were saved before pushing."};if(f==="HEAD")n="HEAD:main";else return{success:!1,error:"Could not detect current branch"}}else if(f.startsWith("adjusted/")){let m=f.replace(/^adjusted\//,"").replace(/\(.*\)$/,"");n=`${f}:${m}`}else n=f}let i=n.includes(":")?n.slice(n.indexOf(":")+1):n,o=!n.startsWith("adjusted/")&&n!=="HEAD:main",s=await yC(e,t);if(!s.success)return{success:!1,error:`Push stopped before the main branch was updated because ${s.error}.`};let a="",c=!1,u=0;for(let f=0;f<=Pw;f++){let m=await k(["git","push","-u",t,n],{cwd:e});if(m.exitCode===0){c=!0;break}if(a=m.stderr,!o||f===Pw||!Zie(m.stderr))break;let p=await k(["git","fetch",t],{cwd:e});if(p.exitCode!==0)return{success:!1,error:`Push rejected (non-fast-forward) and the retry fetch of ${t} failed: ${p.stderr.trim()||`exit ${p.exitCode}`}. Cannot integrate remote commits.`};let g=await k(["git","rebase",`${t}/${i}`],{cwd:e});if(g.exitCode!==0)return await k(["git","rebase","--abort"],{cwd:e}),{success:!1,error:`Push rejected: ${t}/${i} has diverging commits and auto-rebase failed: ${g.stderr.trim()}`};u++}if(!c){let f=u>0?` (still rejected after ${u} fetch+rebase retry cycle(s))`:"";return{success:!1,error:`${a.trim()||"Failed to push to GitHub"}${f}`}}let d=await Qie(e,t,s);if(!d.success){if(d.retryPreparationFailed)return{success:!1,error:`Main branch pushed, but the git-annex branch was not pushed because ${d.error}.`};if(d.localRefAdvanced)return{success:!1,error:d.error};if(d.trackingRefUpdateFailed)return{success:!1,error:`Main and git-annex branches were pushed, but ${d.error}`};return{success:!0,warning:`Main branch pushed, but git-annex branch failed: ${d.error}. Clone operations may have issues.`}}return{success:!0}}catch(n){return{success:!1,error:n.message}}}async function un(e,t,r={}){try{let n=e,i;if(r.useGitHubToken){let d=process.env.GH_TOKEN?.trim()||null,f;if(!d){let p=await Kl();d=p.token,f=p.error}let m=Eie(e,d);if(n=m.url,i=m.credentialHelper,e.startsWith("git@github.com:")&&!i)return{success:!1,error:`No usable GitHub token for authenticated clone of ${e} (GH_TOKEN unset/malformed${f?`; gh CLI: ${f}`:""}). Set GH_TOKEN on this runner.`}}let o=i?{GIT_CONFIG_COUNT:"1",GIT_CONFIG_KEY_0:"credential.https://github.com.helper",GIT_CONFIG_VALUE_0:i}:void 0,{stderr:s,exitCode:a}=await k(["git","clone",n,t],o?{env:o}:{});if(a!==0)return{success:!1,error:s.trim()||"Failed to clone dataset"};if(i){let{exitCode:d,stderr:f}=await k(["git","config","credential.https://github.com.helper",i],{cwd:t,redact:[i]});if(d!==0)return{success:!1,error:`Cloned but failed to persist the credential helper (later pushes would fail to authenticate): ${f.trim()||"git config returned non-zero"}`}}if(r.identity)await k(["git","config","user.name",r.identity.name],{cwd:t}),await k(["git","config","user.email",r.identity.email],{cwd:t});let{stderr:c,exitCode:u}=await k(["git","annex","init",Aie],{cwd:t});if(u!==0){let{exitCode:d}=await k(["git","annex","info"],{cwd:t});if(d!==0)return{success:!1,error:`Cloned repository but git-annex initialization failed: ${c.trim()}`};console.warn("git annex init returned non-zero but annex is initialized")}return{success:!0}}catch(n){return{success:!1,error:n instanceof Error?n.message:String(n)}}}async function eoe(e,t,r){try{let{stderr:n,exitCode:i}=await k(["git","checkout","-b",r],{cwd:e});if(i!==0)return{success:!1,error:n.trim()||"Failed to create branch"};let o=t.startsWith("v")?t:`v${t}`,{stderr:s,exitCode:a}=await k(["git","checkout",o,"--","."],{cwd:e});if(a!==0)return{success:!1,error:s.trim()||"Failed to checkout files from target version"};return{success:!0}}catch(n){return{success:!1,error:n.message}}}async function toe(e,t,r){let n=r||`Revert to ${t}`;try{let{exitCode:i}=await k(["git","add","-A"],{cwd:e});if(i!==0)return{success:!1,error:"Failed to stage changes"};let{stdout:o}=await k(["git","status","--porcelain"],{cwd:e});if(!o.trim())return{success:!1,error:"No changes to revert (already at target version)"};let{stderr:s,exitCode:a}=await k(["git","commit","-m",n],{cwd:e});if(a!==0)return{success:!1,error:s.trim()||"Failed to commit"};return{success:!0}}catch(i){return{success:!1,error:i.message}}}async function $h(e,t,r="origin"){try{let{stderr:n,exitCode:i}=await k(["git","push","-u",r,t],{cwd:e});if(i!==0)return{success:!1,error:n.trim()||"Failed to push branch"};return{success:!0}}catch(n){return{success:!1,error:n.message}}}var YYe,ZYe,Eh,Vie=5000,nXe=2500,iXe=100,oXe=10,sXe=500,aXe=20,Pw=3;var Ri=I(()=>{jf();ss();cs();qf();It();YYe=/^[a-z] /;ZYe=/^[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}$/;Eh=["SIGINT","SIGTERM","SIGHUP"]});var Lf=y(function(K2t,roe){var pXe=Number.MAX_SAFE_INTEGER||9007199254740991,mXe=["major","premajor","minor","preminor","patch","prepatch","prerelease"];roe.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:pXe,RELEASE_TYPES:mXe,SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var kh=y(function(J2t,noe){var hXe=typeof process==="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};noe.exports=hXe});var Bf=y(function(us,ioe){var{MAX_SAFE_COMPONENT_LENGTH:wC,MAX_SAFE_BUILD_LENGTH:gXe,MAX_LENGTH:yXe}=Lf(),bXe=kh();us=ioe.exports={};var xXe=us.re=[],wXe=us.safeRe=[],me=us.src=[],vXe=us.safeSrc=[],he=us.t={},_Xe=0,vC="[a-zA-Z0-9-]",DXe=[["\\s",1],["\\d",yXe],[vC,gXe]],EXe=(e)=>{for(let[t,r]of DXe)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e},Le=(e,t,r)=>{let n=EXe(t),i=_Xe++;bXe(e,i,t),he[e]=i,me[i]=t,vXe[i]=n,xXe[i]=new RegExp(t,r?"g":void 0),wXe[i]=new RegExp(n,r?"g":void 0)};Le("NUMERICIDENTIFIER","0|[1-9]\\d*");Le("NUMERICIDENTIFIERLOOSE","\\d+");Le("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${vC}*`);Le("MAINVERSION",`(${me[he.NUMERICIDENTIFIER]})\\.(${me[he.NUMERICIDENTIFIER]})\\.(${me[he.NUMERICIDENTIFIER]})`);Le("MAINVERSIONLOOSE",`(${me[he.NUMERICIDENTIFIERLOOSE]})\\.(${me[he.NUMERICIDENTIFIERLOOSE]})\\.(${me[he.NUMERICIDENTIFIERLOOSE]})`);Le("PRERELEASEIDENTIFIER",`(?:${me[he.NONNUMERICIDENTIFIER]}|${me[he.NUMERICIDENTIFIER]})`);Le("PRERELEASEIDENTIFIERLOOSE",`(?:${me[he.NONNUMERICIDENTIFIER]}|${me[he.NUMERICIDENTIFIERLOOSE]})`);Le("PRERELEASE",`(?:-(${me[he.PRERELEASEIDENTIFIER]}(?:\\.${me[he.PRERELEASEIDENTIFIER]})*))`);Le("PRERELEASELOOSE",`(?:-?(${me[he.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${me[he.PRERELEASEIDENTIFIERLOOSE]})*))`);Le("BUILDIDENTIFIER",`${vC}+`);Le("BUILD",`(?:\\+(${me[he.BUILDIDENTIFIER]}(?:\\.${me[he.BUILDIDENTIFIER]})*))`);Le("FULLPLAIN",`v?${me[he.MAINVERSION]}${me[he.PRERELEASE]}?${me[he.BUILD]}?`);Le("FULL",`^${me[he.FULLPLAIN]}$`);Le("LOOSEPLAIN",`[v=\\s]*${me[he.MAINVERSIONLOOSE]}${me[he.PRERELEASELOOSE]}?${me[he.BUILD]}?`);Le("LOOSE",`^${me[he.LOOSEPLAIN]}$`);Le("GTLT","((?:<|>)?=?)");Le("XRANGEIDENTIFIERLOOSE",`${me[he.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);Le("XRANGEIDENTIFIER",`${me[he.NUMERICIDENTIFIER]}|x|X|\\*`);Le("XRANGEPLAIN",`[v=\\s]*(${me[he.XRANGEIDENTIFIER]})(?:\\.(${me[he.XRANGEIDENTIFIER]})(?:\\.(${me[he.XRANGEIDENTIFIER]})(?:${me[he.PRERELEASE]})?${me[he.BUILD]}?)?)?`);Le("XRANGEPLAINLOOSE",`[v=\\s]*(${me[he.XRANGEIDENTIFIERLOOSE]})(?:\\.(${me[he.XRANGEIDENTIFIERLOOSE]})(?:\\.(${me[he.XRANGEIDENTIFIERLOOSE]})(?:${me[he.PRERELEASELOOSE]})?${me[he.BUILD]}?)?)?`);Le("XRANGE",`^${me[he.GTLT]}\\s*${me[he.XRANGEPLAIN]}$`);Le("XRANGELOOSE",`^${me[he.GTLT]}\\s*${me[he.XRANGEPLAINLOOSE]}$`);Le("COERCEPLAIN",`(^|[^\\d])(\\d{1,${wC}})(?:\\.(\\d{1,${wC}}))?(?:\\.(\\d{1,${wC}}))?`);Le("COERCE",`${me[he.COERCEPLAIN]}(?:$|[^\\d])`);Le("COERCEFULL",me[he.COERCEPLAIN]+`(?:${me[he.PRERELEASE]})?(?:${me[he.BUILD]})?(?:$|[^\\d])`);Le("COERCERTL",me[he.COERCE],!0);Le("COERCERTLFULL",me[he.COERCEFULL],!0);Le("LONETILDE","(?:~>?)");Le("TILDETRIM",`(\\s*)${me[he.LONETILDE]}\\s+`,!0);us.tildeTrimReplace="$1~";Le("TILDE",`^${me[he.LONETILDE]}${me[he.XRANGEPLAIN]}$`);Le("TILDELOOSE",`^${me[he.LONETILDE]}${me[he.XRANGEPLAINLOOSE]}$`);Le("LONECARET","(?:\\^)");Le("CARETTRIM",`(\\s*)${me[he.LONECARET]}\\s+`,!0);us.caretTrimReplace="$1^";Le("CARET",`^${me[he.LONECARET]}${me[he.XRANGEPLAIN]}$`);Le("CARETLOOSE",`^${me[he.LONECARET]}${me[he.XRANGEPLAINLOOSE]}$`);Le("COMPARATORLOOSE",`^${me[he.GTLT]}\\s*(${me[he.LOOSEPLAIN]})$|^$`);Le("COMPARATOR",`^${me[he.GTLT]}\\s*(${me[he.FULLPLAIN]})$|^$`);Le("COMPARATORTRIM",`(\\s*)${me[he.GTLT]}\\s*(${me[he.LOOSEPLAIN]}|${me[he.XRANGEPLAIN]})`,!0);us.comparatorTrimReplace="$1$2$3";Le("HYPHENRANGE",`^\\s*(${me[he.XRANGEPLAIN]})\\s+-\\s+(${me[he.XRANGEPLAIN]})\\s*$`);Le("HYPHENRANGELOOSE",`^\\s*(${me[he.XRANGEPLAINLOOSE]})\\s+-\\s+(${me[he.XRANGEPLAINLOOSE]})\\s*$`);Le("STAR","(<|>)?=?\\s*\\*");Le("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");Le("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var Nw=y(function(Y2t,ooe){var SXe=Object.freeze({loose:!0}),$Xe=Object.freeze({}),kXe=(e)=>{if(!e)return $Xe;if(typeof e!=="object")return SXe;return e};ooe.exports=kXe});var _C=y(function(X2t,coe){var soe=/^[0-9]+$/,aoe=(e,t)=>{if(typeof e==="number"&&typeof t==="number")return e===t?0:e<t?-1:1;let r=soe.test(e),n=soe.test(t);if(r&&n)e=+e,t=+t;return e===t?0:r&&!n?-1:n&&!r?1:e<t?-1:1},CXe=(e,t)=>aoe(t,e);coe.exports={compareIdentifiers:aoe,rcompareIdentifiers:CXe}});var Jr=y(function(Z2t,uoe){var jw=kh(),{MAX_LENGTH:loe,MAX_SAFE_INTEGER:Mw}=Lf(),{safeRe:qw,t:Lw}=Bf(),RXe=Nw(),{compareIdentifiers:DC}=_C(),AXe=(e,t)=>{let r=t.split(".");if(r.length>e.length)return!1;for(let n=0;n<r.length;n++)if(DC(e[n],r[n])!==0)return!1;return!0};class no{constructor(e,t){if(t=RXe(t),e instanceof no)if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;else e=e.version;else if(typeof e!=="string")throw TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>loe)throw TypeError(`version is longer than ${loe} characters`);jw("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let r=e.trim().match(t.loose?qw[Lw.LOOSE]:qw[Lw.FULL]);if(!r)throw TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>Mw||this.major<0)throw TypeError("Invalid major version");if(this.minor>Mw||this.minor<0)throw TypeError("Invalid minor version");if(this.patch>Mw||this.patch<0)throw TypeError("Invalid patch version");if(!r[4])this.prerelease=[];else this.prerelease=r[4].split(".").map((n)=>{if(/^[0-9]+$/.test(n)){let i=+n;if(i>=0&&i<Mw)return i}return n});this.build=r[5]?r[5].split("."):[],this.format()}format(){if(this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length)this.version+=`-${this.prerelease.join(".")}`;return this.version}toString(){return this.version}compare(e){if(jw("SemVer.compare",this.version,this.options,e),!(e instanceof no)){if(typeof e==="string"&&e===this.version)return 0;e=new no(e,this.options)}if(e.version===this.version)return 0;return this.compareMain(e)||this.comparePre(e)}compareMain(e){if(!(e instanceof no))e=new no(e,this.options);if(this.major<e.major)return-1;if(this.major>e.major)return 1;if(this.minor<e.minor)return-1;if(this.minor>e.minor)return 1;if(this.patch<e.patch)return-1;if(this.patch>e.patch)return 1;return 0}comparePre(e){if(!(e instanceof no))e=new no(e,this.options);if(this.prerelease.length&&!e.prerelease.length)return-1;else if(!this.prerelease.length&&e.prerelease.length)return 1;else if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{let r=this.prerelease[t],n=e.prerelease[t];if(jw("prerelease compare",t,r,n),r===void 0&&n===void 0)return 0;else if(n===void 0)return 1;else if(r===void 0)return-1;else if(r===n)continue;else return DC(r,n)}while(++t)}compareBuild(e){if(!(e instanceof no))e=new no(e,this.options);let t=0;do{let r=this.build[t],n=e.build[t];if(jw("build compare",t,r,n),r===void 0&&n===void 0)return 0;else if(n===void 0)return 1;else if(r===void 0)return-1;else if(r===n)continue;else return DC(r,n)}while(++t)}inc(e,t,r){if(e.startsWith("pre")){if(!t&&r===!1)throw Error("invalid increment argument: identifier is empty");if(t){let n=`-${t}`.match(this.options.loose?qw[Lw.PRERELEASELOOSE]:qw[Lw.PRERELEASE]);if(!n||n[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,r),this.inc("pre",t,r);break;case"prerelease":if(this.prerelease.length===0)this.inc("patch",t,r);this.inc("pre",t,r);break;case"release":if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":if(this.minor!==0||this.patch!==0||this.prerelease.length===0)this.major++;this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":if(this.patch!==0||this.prerelease.length===0)this.minor++;this.patch=0,this.prerelease=[];break;case"patch":if(this.prerelease.length===0)this.patch++;this.prerelease=[];break;case"pre":{let n=Number(r)?1:0;if(this.prerelease.length===0)this.prerelease=[n];else{let i=this.prerelease.length;while(--i>=0)if(typeof this.prerelease[i]==="number")this.prerelease[i]++,i=-2;if(i===-1){if(t===this.prerelease.join(".")&&r===!1)throw Error("invalid increment argument: identifier already exists");this.prerelease.push(n)}}if(t){let i=[t,n];if(r===!1)i=[t];if(AXe(this.prerelease,t)){let o=this.prerelease[t.split(".").length];if(isNaN(o))this.prerelease=i}else this.prerelease=i}break}default:throw Error(`invalid increment argument: ${e}`)}if(this.raw=this.format(),this.build.length)this.raw+=`+${this.build.join(".")}`;return this}}uoe.exports=no});var zc=y(function(Q2t,foe){var doe=Jr(),OXe=(e,t,r=!1)=>{if(e instanceof doe)return e;try{return new doe(e,t)}catch(n){if(!r)return null;throw n}};foe.exports=OXe});var moe=y(function(eCt,poe){var TXe=zc(),FXe=(e,t)=>{let r=TXe(e,t);return r?r.version:null};poe.exports=FXe});var goe=y(function(tCt,hoe){var PXe=zc(),IXe=(e,t)=>{let r=PXe(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null};hoe.exports=IXe});var xoe=y(function(rCt,boe){var yoe=Jr(),NXe=(e,t,r,n,i)=>{if(typeof r==="string")i=n,n=r,r=void 0;try{return new yoe(e instanceof yoe?e.version:e,r).inc(t,n,i).version}catch(o){return null}};boe.exports=NXe});var _oe=y(function(nCt,voe){var woe=zc(),jXe=(e,t)=>{let r=woe(e,null,!0),n=woe(t,null,!0),i=r.compare(n);if(i===0)return null;let o=i>0,s=o?r:n,a=o?n:r,c=!!s.prerelease.length;if(!!a.prerelease.length&&!c){if(!a.patch&&!a.minor)return"major";if(a.compareMain(s)===0){if(a.minor&&!a.patch)return"minor";return"patch"}}let d=c?"pre":"";if(r.major!==n.major)return d+"major";if(r.minor!==n.minor)return d+"minor";if(r.patch!==n.patch)return d+"patch";return"prerelease"};voe.exports=jXe});var Eoe=y(function(iCt,Doe){var MXe=Jr(),qXe=(e,t)=>new MXe(e,t).major;Doe.exports=qXe});var $oe=y(function(oCt,Soe){var LXe=Jr(),BXe=(e,t)=>new LXe(e,t).minor;Soe.exports=BXe});var Coe=y(function(sCt,koe){var UXe=Jr(),zXe=(e,t)=>new UXe(e,t).patch;koe.exports=zXe});var Aoe=y(function(aCt,Roe){var VXe=zc(),HXe=(e,t)=>{let r=VXe(e,t);return r&&r.prerelease.length?r.prerelease:null};Roe.exports=HXe});var Ai=y(function(cCt,Toe){var Ooe=Jr(),GXe=(e,t,r)=>new Ooe(e,r).compare(new Ooe(t,r));Toe.exports=GXe});var Poe=y(function(lCt,Foe){var WXe=Ai(),KXe=(e,t,r)=>WXe(t,e,r);Foe.exports=KXe});var Noe=y(function(uCt,Ioe){var JXe=Ai(),YXe=(e,t)=>JXe(e,t,!0);Ioe.exports=YXe});var Bw=y(function(dCt,Moe){var joe=Jr(),XXe=(e,t,r)=>{let n=new joe(e,r),i=new joe(t,r);return n.compare(i)||n.compareBuild(i)};Moe.exports=XXe});var Loe=y(function(fCt,qoe){var ZXe=Bw(),QXe=(e,t)=>e.sort((r,n)=>ZXe(r,n,t));qoe.exports=QXe});var Uoe=y(function(pCt,Boe){var eZe=Bw(),tZe=(e,t)=>e.sort((r,n)=>eZe(n,r,t));Boe.exports=tZe});var Ch=y(function(mCt,zoe){var rZe=Ai(),nZe=(e,t,r)=>rZe(e,t,r)>0;zoe.exports=nZe});var Uw=y(function(hCt,Voe){var iZe=Ai(),oZe=(e,t,r)=>iZe(e,t,r)<0;Voe.exports=oZe});var EC=y(function(gCt,Hoe){var sZe=Ai(),aZe=(e,t,r)=>sZe(e,t,r)===0;Hoe.exports=aZe});var SC=y(function(yCt,Goe){var cZe=Ai(),lZe=(e,t,r)=>cZe(e,t,r)!==0;Goe.exports=lZe});var zw=y(function(bCt,Woe){var uZe=Ai(),dZe=(e,t,r)=>uZe(e,t,r)>=0;Woe.exports=dZe});var Vw=y(function(xCt,Koe){var fZe=Ai(),pZe=(e,t,r)=>fZe(e,t,r)<=0;Koe.exports=pZe});var $C=y(function(wCt,Joe){var mZe=EC(),hZe=SC(),gZe=Ch(),yZe=zw(),bZe=Uw(),xZe=Vw(),wZe=(e,t,r,n)=>{switch(t){case"===":if(typeof e==="object")e=e.version;if(typeof r==="object")r=r.version;return e===r;case"!==":if(typeof e==="object")e=e.version;if(typeof r==="object")r=r.version;return e!==r;case"":case"=":case"==":return mZe(e,r,n);case"!=":return hZe(e,r,n);case">":return gZe(e,r,n);case">=":return yZe(e,r,n);case"<":return bZe(e,r,n);case"<=":return xZe(e,r,n);default:throw TypeError(`Invalid operator: ${t}`)}};Joe.exports=wZe});var Xoe=y(function(vCt,Yoe){var vZe=Jr(),_Ze=zc(),{safeRe:Hw,t:Gw}=Bf(),DZe=(e,t)=>{if(e instanceof vZe)return e;if(typeof e==="number")e=String(e);if(typeof e!=="string")return null;t=t||{};let r=null;if(!t.rtl)r=e.match(t.includePrerelease?Hw[Gw.COERCEFULL]:Hw[Gw.COERCE]);else{let c=t.includePrerelease?Hw[Gw.COERCERTLFULL]:Hw[Gw.COERCERTL],u;while((u=c.exec(e))&&(!r||r.index+r[0].length!==e.length)){if(!r||u.index+u[0].length!==r.index+r[0].length)r=u;c.lastIndex=u.index+u[1].length+u[2].length}c.lastIndex=-1}if(r===null)return null;let n=r[2],i=r[3]||"0",o=r[4]||"0",s=t.includePrerelease&&r[5]?`-${r[5]}`:"",a=t.includePrerelease&&r[6]?`+${r[6]}`:"";return _Ze(`${n}.${i}.${o}${s}${a}`,t)};Yoe.exports=DZe});var ese=y(function(_Ct,Qoe){var EZe=zc(),Zoe=Lf(),SZe=Jr(),$Ze=(e,t,r)=>{if(!Zoe.RELEASE_TYPES.includes(t))return null;let n=kZe(e,r);return n&&CZe(n,t)},kZe=(e,t)=>{let r=e instanceof SZe?e.version:e;return EZe(r,t)},CZe=(e,t)=>{if(RZe(t))return e.version;switch(e.prerelease=[],t){case"major":e.minor=0,e.patch=0;break;case"minor":e.patch=0;break}return e.format()},RZe=(e)=>e.startsWith("pre");Qoe.exports=$Ze});var nse=y(function(DCt,rse){class tse{constructor(){this.max=1000,this.map=new Map}get(e){let t=this.map.get(e);if(t===void 0)return;else return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let n=this.map.keys().next().value;this.delete(n)}this.map.set(e,t)}return this}}rse.exports=tse});var Oi=y(function(ECt,ase){var AZe=/\s+/g;class Rh{constructor(e,t){if(t=TZe(t),e instanceof Rh)if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;else return new Rh(e.raw,t);if(e instanceof Ww)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().replace(AZe," "),this.set=this.raw.split("||").map((r)=>this.parseRange(r.trim())).filter((r)=>r.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let r=this.set[0];if(this.set=this.set.filter((n)=>!ose(n[0])),this.set.length===0)this.set=[r];else if(this.set.length>1){for(let n of this.set)if(n.length===1&&BZe(n[0])){this.set=[n];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let e=0;e<this.set.length;e++){if(e>0)this.formatted+="||";let t=this.set[e];for(let r=0;r<t.length;r++){if(r>0)this.formatted+=" ";this.formatted+=t[r].toString().trim()}}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){e=e.replace(LZe,"");let r=((this.options.includePrerelease&&MZe)|(this.options.loose&&qZe))+":"+e,n=ise.get(r);if(n)return n;let i=this.options.loose,o=i?vn[Yr.HYPHENRANGELOOSE]:vn[Yr.HYPHENRANGE];e=e.replace(o,ZZe(this.options.includePrerelease)),Lt("hyphen replace",e),e=e.replace(vn[Yr.COMPARATORTRIM],IZe),Lt("comparator trim",e),e=e.replace(vn[Yr.TILDETRIM],NZe),Lt("tilde trim",e),e=e.replace(vn[Yr.CARETTRIM],jZe),Lt("caret trim",e);let s=e.split(" ").map((d)=>UZe(d,this.options)).join(" ").split(/\s+/).map((d)=>XZe(d,this.options));if(i)s=s.filter((d)=>(Lt("loose invalid filter",d,this.options),!!d.match(vn[Yr.COMPARATORLOOSE])));Lt("range list",s);let a=new Map,c=s.map((d)=>new Ww(d,this.options));for(let d of c){if(ose(d))return[d];a.set(d.value,d)}if(a.size>1&&a.has(""))a.delete("");let u=[...a.values()];return ise.set(r,u),u}intersects(e,t){if(!(e instanceof Rh))throw TypeError("a Range is required");return this.set.some((r)=>sse(r,t)&&e.set.some((n)=>sse(n,t)&&r.every((i)=>n.every((o)=>i.intersects(o,t)))))}test(e){if(!e)return!1;if(typeof e==="string")try{e=new FZe(e,this.options)}catch(t){return!1}for(let t=0;t<this.set.length;t++)if(QZe(this.set[t],e,this.options))return!0;return!1}}ase.exports=Rh;var OZe=nse(),ise=new OZe,TZe=Nw(),Ww=Ah(),Lt=kh(),FZe=Jr(),{safeRe:vn,src:PZe,t:Yr,comparatorTrimReplace:IZe,tildeTrimReplace:NZe,caretTrimReplace:jZe}=Bf(),{FLAG_INCLUDE_PRERELEASE:MZe,FLAG_LOOSE:qZe}=Lf(),LZe=new RegExp(PZe[Yr.BUILD],"g"),ose=(e)=>e.value==="<0.0.0-0",BZe=(e)=>e.value==="",sse=(e,t)=>{let r=!0,n=e.slice(),i=n.pop();while(r&&n.length)r=n.every((o)=>i.intersects(o,t)),i=n.pop();return r},UZe=(e,t)=>(e=e.replace(vn[Yr.BUILD],""),Lt("comp",e,t),e=GZe(e,t),Lt("caret",e),e=VZe(e,t),Lt("tildes",e),e=KZe(e,t),Lt("xrange",e),e=YZe(e,t),Lt("stars",e),e),Cr=(e)=>!e||e.toLowerCase()==="x"||e==="*",zZe=(e,t,r)=>Cr(e)&&!Cr(t)||Cr(t)&&r&&!Cr(r),VZe=(e,t)=>e.trim().split(/\s+/).map((r)=>HZe(r,t)).join(" "),HZe=(e,t)=>{let r=t.loose?vn[Yr.TILDELOOSE]:vn[Yr.TILDE],n=t.includePrerelease?"-0":"";return e.replace(r,(i,o,s,a,c)=>{Lt("tilde",e,i,o,s,a,c);let u;if(Cr(o))u="";else if(Cr(s))u=`>=${o}.0.0${n} <${+o+1}.0.0-0`;else if(Cr(a))u=`>=${o}.${s}.0${n} <${o}.${+s+1}.0-0`;else if(c)Lt("replaceTilde pr",c),u=`>=${o}.${s}.${a}-${c} <${o}.${+s+1}.0-0`;else u=`>=${o}.${s}.${a} <${o}.${+s+1}.0-0`;return Lt("tilde return",u),u})},GZe=(e,t)=>e.trim().split(/\s+/).map((r)=>WZe(r,t)).join(" "),WZe=(e,t)=>{Lt("caret",e,t);let r=t.loose?vn[Yr.CARETLOOSE]:vn[Yr.CARET],n=t.includePrerelease?"-0":"";return e.replace(r,(i,o,s,a,c)=>{Lt("caret",e,i,o,s,a,c);let u;if(Cr(o))u="";else if(Cr(s))u=`>=${o}.0.0${n} <${+o+1}.0.0-0`;else if(Cr(a))if(o==="0")u=`>=${o}.${s}.0${n} <${o}.${+s+1}.0-0`;else u=`>=${o}.${s}.0${n} <${+o+1}.0.0-0`;else if(c)if(Lt("replaceCaret pr",c),o==="0")if(s==="0")u=`>=${o}.${s}.${a}-${c} <${o}.${s}.${+a+1}-0`;else u=`>=${o}.${s}.${a}-${c} <${o}.${+s+1}.0-0`;else u=`>=${o}.${s}.${a}-${c} <${+o+1}.0.0-0`;else if(Lt("no pr"),o==="0")if(s==="0")u=`>=${o}.${s}.${a} <${o}.${s}.${+a+1}-0`;else u=`>=${o}.${s}.${a} <${o}.${+s+1}.0-0`;else u=`>=${o}.${s}.${a} <${+o+1}.0.0-0`;return Lt("caret return",u),u})},KZe=(e,t)=>(Lt("replaceXRanges",e,t),e.split(/\s+/).map((r)=>JZe(r,t)).join(" ")),JZe=(e,t)=>{e=e.trim();let r=t.loose?vn[Yr.XRANGELOOSE]:vn[Yr.XRANGE];return e.replace(r,(n,i,o,s,a,c)=>{if(Lt("xRange",e,n,i,o,s,a,c),zZe(o,s,a))return e;let u=Cr(o),d=u||Cr(s),f=d||Cr(a),m=f;if(i==="="&&m)i="";if(c=t.includePrerelease?"-0":"",u)if(i===">"||i==="<")n="<0.0.0-0";else n="*";else if(i&&m){if(d)s=0;if(a=0,i===">")if(i=">=",d)o=+o+1,s=0,a=0;else s=+s+1,a=0;else if(i==="<=")if(i="<",d)o=+o+1;else s=+s+1;if(i==="<")c="-0";n=`${i+o}.${s}.${a}${c}`}else if(d)n=`>=${o}.0.0${c} <${+o+1}.0.0-0`;else if(f)n=`>=${o}.${s}.0${c} <${o}.${+s+1}.0-0`;return Lt("xRange return",n),n})},YZe=(e,t)=>(Lt("replaceStars",e,t),e.trim().replace(vn[Yr.STAR],"")),XZe=(e,t)=>(Lt("replaceGTE0",e,t),e.trim().replace(vn[t.includePrerelease?Yr.GTE0PRE:Yr.GTE0],"")),ZZe=(e)=>(t,r,n,i,o,s,a,c,u,d,f,m)=>{if(Cr(n))r="";else if(Cr(i))r=`>=${n}.0.0${e?"-0":""}`;else if(Cr(o))r=`>=${n}.${i}.0${e?"-0":""}`;else if(s)r=`>=${r}`;else r=`>=${r}${e?"-0":""}`;if(Cr(u))c="";else if(Cr(d))c=`<${+u+1}.0.0-0`;else if(Cr(f))c=`<${u}.${+d+1}.0-0`;else if(m)c=`<=${u}.${d}.${f}-${m}`;else if(e)c=`<${u}.${d}.${+f+1}-0`;else c=`<=${c}`;return`${r} ${c}`.trim()},QZe=(e,t,r)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let n=0;n<e.length;n++){if(Lt(e[n].semver),e[n].semver===Ww.ANY)continue;if(e[n].semver.prerelease.length>0){let i=e[n].semver;if(i.major===t.major&&i.minor===t.minor&&i.patch===t.patch)return!0}}return!1}return!0}});var Ah=y(function(SCt,pse){var Oh=Symbol("SemVer ANY");class Kw{static get ANY(){return Oh}constructor(e,t){if(t=cse(t),e instanceof Kw)if(e.loose===!!t.loose)return e;else e=e.value;if(e=e.trim().split(/\s+/).join(" "),CC("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===Oh)this.value="";else this.value=this.operator+this.semver.version;CC("comp",this)}parse(e){let t=this.options.loose?lse[use.COMPARATORLOOSE]:lse[use.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);if(this.operator=r[1]!==void 0?r[1]:"",this.operator==="=")this.operator="";if(!r[2])this.semver=Oh;else this.semver=new dse(r[2],this.options.loose)}toString(){return this.value}test(e){if(CC("Comparator.test",e,this.options.loose),this.semver===Oh||e===Oh)return!0;if(typeof e==="string")try{e=new dse(e,this.options)}catch(t){return!1}return kC(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof Kw))throw TypeError("a Comparator is required");if(this.operator===""){if(this.value==="")return!0;return new fse(e.value,t).test(this.value)}else if(e.operator===""){if(e.value==="")return!0;return new fse(this.value,t).test(e.semver)}if(t=cse(t),t.includePrerelease&&(this.value==="<0.0.0-0"||e.value==="<0.0.0-0"))return!1;if(!t.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0")))return!1;if(this.operator.startsWith(">")&&e.operator.startsWith(">"))return!0;if(this.operator.startsWith("<")&&e.operator.startsWith("<"))return!0;if(this.semver.version===e.semver.version&&this.operator.includes("=")&&e.operator.includes("="))return!0;if(kC(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))return!0;if(kC(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">"))return!0;return!1}}pse.exports=Kw;var cse=Nw(),{safeRe:lse,t:use}=Bf(),kC=$C(),CC=kh(),dse=Jr(),fse=Oi()});var Th=y(function($Ct,mse){var eQe=Oi(),tQe=(e,t,r)=>{try{t=new eQe(t,r)}catch(n){return!1}return t.test(e)};mse.exports=tQe});var gse=y(function(kCt,hse){var rQe=Oi(),nQe=(e,t)=>new rQe(e,t).set.map((r)=>r.map((n)=>n.value).join(" ").trim().split(" "));hse.exports=nQe});var bse=y(function(CCt,yse){var iQe=Jr(),oQe=Oi(),sQe=(e,t,r)=>{let n=null,i=null,o=null;try{o=new oQe(t,r)}catch(s){return null}return e.forEach((s)=>{if(o.test(s)){if(!n||i.compare(s)===-1)n=s,i=new iQe(n,r)}}),n};yse.exports=sQe});var wse=y(function(RCt,xse){var aQe=Jr(),cQe=Oi(),lQe=(e,t,r)=>{let n=null,i=null,o=null;try{o=new cQe(t,r)}catch(s){return null}return e.forEach((s)=>{if(o.test(s)){if(!n||i.compare(s)===1)n=s,i=new aQe(n,r)}}),n};xse.exports=lQe});var Dse=y(function(ACt,_se){var RC=Jr(),uQe=Oi(),vse=Ch(),dQe=(e,t)=>{e=new uQe(e,t);let r=new RC("0.0.0");if(e.test(r))return r;if(r=new RC("0.0.0-0"),e.test(r))return r;r=null;for(let n=0;n<e.set.length;++n){let i=e.set[n],o=null;if(i.forEach((s)=>{let a=new RC(s.semver.version);switch(s.operator){case">":if(a.prerelease.length===0)a.patch++;else a.prerelease.push(0);a.raw=a.format();case"":case">=":if(!o||vse(a,o))o=a;break;case"<":case"<=":break;default:throw Error(`Unexpected operation: ${s.operator}`)}}),o&&(!r||vse(r,o)))r=o}if(r&&e.test(r))return r;return null};_se.exports=dQe});var Sse=y(function(OCt,Ese){var fQe=Oi(),pQe=(e,t)=>{try{return new fQe(e,t).range||"*"}catch(r){return null}};Ese.exports=pQe});var Jw=y(function(TCt,Rse){var mQe=Jr(),Cse=Ah(),{ANY:hQe}=Cse,gQe=Oi(),yQe=Th(),$se=Ch(),kse=Uw(),bQe=Vw(),xQe=zw(),wQe=(e,t,r,n)=>{e=new mQe(e,n),t=new gQe(t,n);let i,o,s,a,c;switch(r){case">":i=$se,o=bQe,s=kse,a=">",c=">=";break;case"<":i=kse,o=xQe,s=$se,a="<",c="<=";break;default:throw TypeError('Must provide a hilo val of "<" or ">"')}if(yQe(e,t,n))return!1;for(let u=0;u<t.set.length;++u){let d=t.set[u],f=null,m=null;if(d.forEach((p)=>{if(p.semver===hQe)p=new Cse(">=0.0.0");if(f=f||p,m=m||p,i(p.semver,f.semver,n))f=p;else if(s(p.semver,m.semver,n))m=p}),f.operator===a||f.operator===c)return!1;if((!m.operator||m.operator===a)&&o(e,m.semver))return!1;else if(m.operator===c&&s(e,m.semver))return!1}return!0};Rse.exports=wQe});var Ose=y(function(FCt,Ase){var vQe=Jw(),_Qe=(e,t,r)=>vQe(e,t,">",r);Ase.exports=_Qe});var Fse=y(function(PCt,Tse){var DQe=Jw(),EQe=(e,t,r)=>DQe(e,t,"<",r);Tse.exports=EQe});var Nse=y(function(ICt,Ise){var Pse=Oi(),SQe=(e,t,r)=>(e=new Pse(e,r),t=new Pse(t,r),e.intersects(t,r));Ise.exports=SQe});var Mse=y(function(NCt,jse){var $Qe=Th(),kQe=Ai();jse.exports=(e,t,r)=>{let n=[],i=null,o=null,s=e.sort((d,f)=>kQe(d,f,r));for(let d of s)if($Qe(d,t,r)){if(o=d,!i)i=d}else{if(o)n.push([i,o]);o=null,i=null}if(i)n.push([i,null]);let a=[];for(let[d,f]of n)if(d===f)a.push(d);else if(!f&&d===s[0])a.push("*");else if(!f)a.push(`>=${d}`);else if(d===s[0])a.push(`<=${f}`);else a.push(`${d} - ${f}`);let c=a.join(" || "),u=typeof t.raw==="string"?t.raw:String(t);return c.length<u.length?c:t}});var Vse=y(function(jCt,zse){var qse=Oi(),TC=Ah(),{ANY:AC}=TC,OC=Th(),FC=Ai(),CQe=(e,t,r={})=>{if(e===t)return!0;e=new qse(e,r),t=new qse(t,r);let n=!1;e:for(let i of e.set){for(let o of t.set){let s=AQe(i,o,r);if(n=n||s!==null,s)continue e}if(n)return!1}return!0},RQe=[new TC(">=0.0.0-0")],Lse=[new TC(">=0.0.0")],AQe=(e,t,r)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===AC)if(t.length===1&&t[0].semver===AC)return!0;else if(r.includePrerelease)e=RQe;else e=Lse;if(t.length===1&&t[0].semver===AC)if(r.includePrerelease)return!0;else t=Lse;let n=new Set,i,o;for(let p of e)if(p.operator===">"||p.operator===">=")i=Bse(i,p,r);else if(p.operator==="<"||p.operator==="<=")o=Use(o,p,r);else n.add(p.semver);if(n.size>1)return null;let s;if(i&&o){if(s=FC(i.semver,o.semver,r),s>0)return null;else if(s===0&&(i.operator!==">="||o.operator!=="<="))return null}for(let p of n){if(i&&!OC(p,String(i),r))return null;if(o&&!OC(p,String(o),r))return null;for(let g of t)if(!OC(p,String(g),r))return!1;return!0}let a,c,u,d,f=o&&!r.includePrerelease&&o.semver.prerelease.length?o.semver:!1,m=i&&!r.includePrerelease&&i.semver.prerelease.length?i.semver:!1;if(f&&f.prerelease.length===1&&o.operator==="<"&&f.prerelease[0]===0)f=!1;for(let p of t){if(d=d||p.operator===">"||p.operator===">=",u=u||p.operator==="<"||p.operator==="<=",i){if(m){if(p.semver.prerelease&&p.semver.prerelease.length&&p.semver.major===m.major&&p.semver.minor===m.minor&&p.semver.patch===m.patch)m=!1}if(p.operator===">"||p.operator===">="){if(a=Bse(i,p,r),a===p&&a!==i)return!1}else if(i.operator===">="&&!p.test(i.semver))return!1}if(o){if(f){if(p.semver.prerelease&&p.semver.prerelease.length&&p.semver.major===f.major&&p.semver.minor===f.minor&&p.semver.patch===f.patch)f=!1}if(p.operator==="<"||p.operator==="<="){if(c=Use(o,p,r),c===p&&c!==o)return!1}else if(o.operator==="<="&&!p.test(o.semver))return!1}if(!p.operator&&(o||i)&&s!==0)return!1}if(i&&u&&!o&&s!==0)return!1;if(o&&d&&!i&&s!==0)return!1;if(m||f)return!1;return!0},Bse=(e,t,r)=>{if(!e)return t;let n=FC(e.semver,t.semver,r);return n>0?e:n<0?t:t.operator===">"&&e.operator===">="?t:e},Use=(e,t,r)=>{if(!e)return t;let n=FC(e.semver,t.semver,r);return n<0?e:n>0?t:t.operator==="<"&&e.operator==="<="?t:e};zse.exports=CQe});var Zw=y(function(MCt,Hse){var Uf=Bf(),Yw=Lf(),OQe=Jr(),Xw=_C(),TQe=zc(),FQe=moe(),PQe=goe(),IQe=xoe(),NQe=_oe(),jQe=Eoe(),MQe=$oe(),qQe=Coe(),LQe=Aoe(),BQe=Ai(),UQe=Poe(),zQe=Noe(),VQe=Bw(),HQe=Loe(),GQe=Uoe(),WQe=Ch(),KQe=Uw(),JQe=EC(),YQe=SC(),XQe=zw(),ZQe=Vw(),QQe=$C(),eet=Xoe(),tet=ese(),ret=Ah(),net=Oi(),iet=Th(),oet=gse(),set=bse(),aet=wse(),cet=Dse(),uet=Sse(),det=Jw(),fet=Ose(),pet=Fse(),met=Nse(),het=Mse(),get=Vse();Hse.exports={parse:TQe,valid:FQe,clean:PQe,inc:IQe,diff:NQe,major:jQe,minor:MQe,patch:qQe,prerelease:LQe,compare:BQe,rcompare:UQe,compareLoose:zQe,compareBuild:VQe,sort:HQe,rsort:GQe,gt:WQe,lt:KQe,eq:JQe,neq:YQe,gte:XQe,lte:ZQe,cmp:QQe,coerce:eet,truncate:tet,Comparator:ret,Range:net,satisfies:iet,toComparators:oet,maxSatisfying:set,minSatisfying:aet,minVersion:cet,validRange:uet,outside:det,gtr:fet,ltr:pet,intersects:met,simplifyRange:het,subset:get,SemVer:OQe,re:Uf.re,src:Uf.src,tokens:Uf.t,SEMVER_SPEC_VERSION:Yw.SEMVER_SPEC_VERSION,RELEASE_TYPES:Yw.RELEASE_TYPES,compareIdentifiers:Xw.compareIdentifiers,rcompareIdentifiers:Xw.rcompareIdentifiers}});function ds(e){let t="";for(let r of e)if(/\p{Lu}/u.test(r))t+="A";else if(/\p{L}/u.test(r))t+="a";else if(/\p{N}/u.test(r))t+="9";else if(/^[ -~]$/.test(r))t+=r;else t+="?";return t.replace(/(.)\1{2,}/g,"$1+")}function tv(e){return IC.has(e.toLowerCase())}function Yse(e){return tv(e)||_et.test(e)||/^\d+$/.test(e)}function Xse(e){let t=e.toLowerCase();return xet.has(t)||IC.has(t)}function $et(e,t){if(e===""||Yse(e))return!1;let r=t?(i)=>wet.has(i.toLowerCase())||vet.has(i.toLowerCase()):Xse;if(/^[\p{L}'._-]+$/u.test(e)){let i=e.split(/['._-]+/).filter((o)=>o!=="");return i.length>0&&!i.every(r)}return(e.match(/\p{L}+/gu)??[]).some((i)=>i.length>=4&&!r(i))}function zf(e,t=!1){if(e===""||Yse(e))return!1;return e.split(Eet).some((r)=>$et(r,t))}function Kse(e,t,r){for(let n=t;n<r;n++)if(e[n]>=128)return!0;return!1}function Zse(e,t,r){let n="";for(let i=t;i<r;i++){let o=e[i];n+=o===0?" ":String.fromCharCode(o)}return n}function Qs(e,t,r){return Zse(e,t,r).trim()}function nv(e){return{patient:Qs(e,8,88),recording:Qs(e,88,168),startdate:Qs(e,168,176)}}function Qse(e){return e.length>0&&e.every((t)=>t.day===1&&t.month===1)}function Ih(e){let t=[],r=(f,m)=>t.push({text:f[0],index:f.index??0,candidates:m}),n=/(?<![\p{L}\p{N}])(\d{1,2})[-./_ ]?([A-Za-z]{3,9})[-./_ ]?(\d{2,4})(?![\p{L}\p{N}])/gu;for(let f of e.matchAll(n)){let m=PC(f[2]),p=Number(f[1]);if(Yl(p,m))r(f,[{day:p,month:m,year:Number(f[3])}])}let i=/(?<![\p{L}\p{N}])(\d{1,2})[-./_ ]?([A-Za-z]{3,9})[-./_ ]?((?:19|20)\d{2})(?![\p{L}\p{N}])/gu;for(let f of e.matchAll(i)){let m=Number(f[1]);if(PC(f[2])===0&&m>=1&&m<=31)r(f,[{day:m,month:0,year:Number(f[3])}])}let o=/(?<![\p{N}])(\d{4})[-./_](\d{1,2})[-./_](\d{1,2})(?![\p{N}])/gu;for(let f of e.matchAll(o)){let[m,p,g]=[Number(f[1]),Number(f[2]),Number(f[3])];if(Yl(g,p))r(f,[{day:g,month:p,year:m}])}let s=[/(?<![\p{N}])(\d{1,2})[-./_](\d{1,2})[-./_](\d{2,4})(?![\p{N}])/gu,/(?<![\p{N}])(\d{1,2}) (\d{1,2}) (\d{4})(?![\p{N}])/gu];for(let f of s)for(let m of e.matchAll(f)){let[p,g,h]=[Number(m[1]),Number(m[2]),Number(m[3])],b=[];if(Yl(p,g))b.push({day:p,month:g,year:h});if(Yl(g,p))b.push({day:g,month:p,year:h});if(b.length>0)r(m,b)}let a=/(?<![\p{N}])(\d{8})(?![\p{N}])/gu;for(let f of e.matchAll(a)){let m=f[1],p=[],g={year:Number(m.slice(0,4)),month:Number(m.slice(4,6)),day:Number(m.slice(6))};if(g.year>=1900&&g.year<=2100&&Yl(g.day,g.month))p.push(g);let h={day:Number(m.slice(0,2)),month:Number(m.slice(2,4)),year:Number(m.slice(4))};if(h.year>=1900&&h.year<=2100&&Yl(h.day,h.month))p.push(h);if(p.length>0)r(f,p)}let c=/(?<![\p{L}\p{N}_])(\d{4})[-./_](\d{1,2})(?![\p{N}])/gu;for(let f of e.matchAll(c)){let m=Number(f[2]);if(m>=1&&m<=12)r(f,[{day:0,month:m,year:Number(f[1])}])}let u=/(?<![\p{L}\p{N}])(\d{1,2})[-./_](\d{4})(?![\p{N}])/gu;for(let f of e.matchAll(u)){let[m,p]=[Number(f[1]),Number(f[2])];if(m>=1&&m<=12&&p>=1900&&p<=2100)r(f,[{day:0,month:m,year:p}])}let d=/(?<![\p{L}\p{N}])([A-Za-z]{3,9})[-./_ ](\d{4})(?![\p{L}\p{N}])/gu;for(let f of e.matchAll(d)){let m=PC(f[1]);if(m>0)r(f,[{day:0,month:m,year:Number(f[2])}])}return t.filter((f)=>!t.some((m)=>m!==f&&m.text.length>f.text.length&&f.index>=m.index&&f.index+f.text.length<=m.index+m.text.length))}function Ph(e,t){let r=e;for(let n of t)r=r.replace(n.text," ");return r}function ket(e){let t=/^(\d{2})\.(\d{2})\.(\d{2})$/.exec(e);if(!t)return null;let[r,n]=[Number(t[1]),Number(t[2])];return Yl(r,n)?{day:r,month:n}:null}function eae(e){let t=ket(e);if(!t)return"unparsed";return t.day===1&&t.month===1?"year-only":"dated"}function tae(e){let t=e.split(/\s+/),r=t[0].toLowerCase()==="startdate",n=Ih(e),i=r?t[1]:void 0,o=i===void 0?void 0:{text:i,index:e.indexOf(i,t[0].length)},s=(d)=>o!==void 0&&d.index>=o.index&&d.index<o.index+o.text.length,a=/\b(?:dob|d\.o\.b)\b|birth|\bborn|\bgeb|nacid|nacimiento|(?:^|\s)\*(?=\d)/iu.test(e),c,u=[];for(let d of n){if(Qse(d.candidates))continue;if(r?s(d):!a)c??=d;else u.push(d)}return{parts:t,keyword:r,slot:o,dates:n,acquisition:c,birth:u}}function NC(e){if(!Vc(e))return null;let t=Zse(e,88,168),r=t.trim(),n=null;if(r!==""&&!tv(r)){let i=tae(r),o=i.acquisition;if(o){let s=88+(t.length-t.trimStart().length)+o.index;n={start:s,end:s+o.text.length,wholeSlot:i.slot!==void 0&&i.slot.text===o.text}}}return{startdate:eae(Qs(e,168,176))==="dated",recording:n}}function Vc(e){if(e.length<256)return null;if(e[0]===255&&Qs(e,1,8)==="BIOSEMI")return"bdf";if(Qs(e,0,8)==="0")return"edf";return null}function ea(e){if(!Vc(e))return[{kind:"edf-unreadable",severity:"review",field:"header",shape:ds("")}];let t=[],r=(w,D,C,E)=>t.push({kind:w,severity:D,field:C,shape:ds(E)}),n=Qs(e,8,88);if(Kse(e,8,88))r("edf-patient-nonascii","identifier","patient",n);let i=n===""?[]:n.split(/\s+/),o=Ih(n),s=new Set,a=(w,D)=>{if(s.has(w))return;s.add(w),r("edf-patient-birthdate","identifier",w,D)};for(let w of o)if(!Qse(w.candidates))a("patient.birthdate",w.text);let c=["m","f","x","male","female"],u=i.length>=4&&c.includes(i[1].toLowerCase()),d=(w)=>Ph(w,Ih(w)).trim();if(u){let[w,,D,C]=i;if(zf(d(w),!0))r("edf-patient-code","identifier","patient.code",w);if(zf(d(C),!0))r("edf-patient-name","identifier","patient.name",C);if(!(D==="X"||tv(D)||/^(19|20)\d{2}$/.test(D)||/^\d{1,3}y?$/i.test(D)||Ih(D).length>0))a("patient.birthdate",D);let A=i.slice(4).map(d);if(A.some((T)=>zf(T)))r("edf-patient-freetext","identifier","patient.additional",A.join(" "))}else if(Ph(n,o).split(/\s+/).filter((D)=>D!=="").some((D)=>zf(D)))r("edf-patient-freetext","identifier","patient",n);let f=Ph(n,o),p=(()=>{let w=(O,N)=>N>=90&&N<=130?O:void 0,D=u?i[2]:"",C=/^(\d{2,3})y?$/i.exec(D);if(C)return w(D,Number(C[1]));let E=[/\bage[=: _-]*(\d{2,3})\b/gi,/\b(\d{2,3})\s?(?:y|yr|yrs|yo|y\/o|years?)\b/gi,/\b(\d{2,3})[- ]?(?:year|yr)s?[- ]?old\b/gi,/\b(?:m|f|male|female)\s+(\d{2,3})\b(?!\s?(?:kg|cm|lbs?|bpm|mm|hz|ms|mv|uv|years?\b))/gi];for(let O of E)for(let N of f.matchAll(O)){let W=w(N[0],Number(N[1]));if(W)return W}let A=new Date().getFullYear()-90,T=/^(19|20)\d{2}$/.test(D)?Number(D):void 0,L=[...o.flatMap((O)=>O.candidates.map((N)=>N.year)),T];for(let O of L)if(O!==void 0&&O>=1900&&O<A)return String(O);return})();if(p)r("edf-patient-age","identifier","patient.age",p);let g=/\d{6,}|\b\d{3}-\d{2}-\d{4}\b/.exec(Ph(n,o));if(g)r("edf-patient-recordnumber","review","patient",g[0]);let h=Qs(e,88,168);if(Kse(e,88,168))r("edf-recording-nonascii","review","recording",h);if(h!==""&&!tv(h)){let{parts:w,keyword:D,dates:C,slot:E,acquisition:A,birth:T}=tae(h),L=E?.text,O=T[0];if(O)a("recording.birthdate",O.text);if(A)r("edf-recording-startdate","review","recording.startdate",A.text);if(D){if(L!==void 0&&L!=="X"&&Ih(L).length===0)r("edf-recording-freetext","review","recording.startdate",L);w.slice(2).forEach((N,W)=>{if(!zf(d(N)))return;let F=W===1;r(F?"edf-recording-technician":"edf-recording-freetext","review",F?"recording.technician":"recording",N)})}else if(Ph(h,C).split(/\s+/).filter((W)=>W!=="").some((W)=>zf(W)))r("edf-recording-freetext","identifier","recording",h)}let b=Qs(e,168,176),x=eae(b);if(x==="unparsed")r("edf-startdate-unparsed","review","startdate",b);else if(x==="dated")r("edf-startdate","review","startdate",b);return t}function rae(e){let t=[];for(let r of e.replace(/^\uFEFF/,"").split("\t")){let n=jC(r);if(n!==""&&Cet.has(n))t.push({kind:"participants-identifier-column",severity:"identifier",field:n,shape:ds(r.trim())})}return t}function nae(e){return/^\p{L}{4,}$/u.test(e)&&!Xse(e)}function iae(e){let t=[],r=e.replace(/^\uFEFF/,"").split(/\r?\n/).slice(1);for(let n of r){let i=(n.split("\t")[0]??"").trim().replace(/^sub-/i,"");if(nae(i))t.push({kind:"path-subject-label",severity:"review",field:"participant_id",shape:ds(i)})}return t}function MC(e){let t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e.trim());if(!t)return[];if(Number(t[3])===1&&Number(t[2])===1)return[];return[{kind:"acq-time-dated",severity:"review",field:"acq_time",shape:ds(e)}]}function qC(e){let t=[],r=e.startsWith("\uFEFF")?1:0,n=-1;for(let i=0;;i++){let o=e.indexOf(`
|
|
138
|
-
`,r),s=o<0?e.length:o,a=e.slice(r,s);if(i===0){if(n=a.replace(/\r$/,"").split("\t").indexOf("acq_time"),n<0)return t}else{let c=0,u=0;for(;u<n;u++){let d=a.indexOf("\t",c);if(d<0)break;c=d+1}if(u===n){let d=a.indexOf("\t",c);t.push({index:r+c,value:a.slice(c,d<0?a.length:d)})}}if(o<0)return t;r=o+1}}function iv(e){return qC(e).flatMap((t)=>MC(t.value))}function Nh(e){if(e===null||e===void 0)return!1;if(typeof e==="string")return e.trim()!=="";if(typeof e==="number"||typeof e==="boolean")return!0;if(Array.isArray(e))return e.some(Nh);if(typeof e==="object")return Object.values(e).some(Nh);return!1}function Xl(e){let t=[];if(Array.isArray(e)){for(let r of e)t.push(...Xl(r));return t}if(e===null||typeof e!=="object")return t;for(let[r,n]of Object.entries(e)){let i=jC(r),o=Ret.has(i)?"identifier":Aet.has(i)?"review":null;if(o&&Nh(n)){let s=Array.isArray(n)?"[]":typeof n==="object"?"{}":String(n);t.push({kind:"json-identifier-key",severity:o,field:i,shape:ds(s)});continue}if(n!==null&&typeof n==="object")t.push(...Xl(n))}return t}function ov(e){let t=[],r=new Set;for(let n of e){let i=n.slice(n.lastIndexOf("/")+1);if(Fet.test(n))t.push({kind:"tooling-debris",severity:"review",field:"path",shape:ds(i)});else if(Oet.test(i)&&!Tet.test(i))t.push({kind:"image-or-document-file",severity:"review",field:"path",shape:ds(i)});for(let o of n.matchAll(/(?:^|\/)sub-([\p{L}\p{N}]+)/gu)){let s=o[1];if(nae(s)&&!r.has(s))r.add(s),t.push({kind:"path-subject-label",severity:"review",field:"path",shape:ds(s)})}}return t}function oae(e){let t=Pet.exec(e);if(!t||Iet.has(t[1].toLowerCase()))return[];return[{kind:"local-user-path",severity:"review",field:"text",shape:ds(t[0])}]}function sae(e){let t={},r=new Set,n=0,i=(o)=>{t[o]=(t[o]??0)+1};for(let o of e){let s=o.toLowerCase();if(s.endsWith(".edf")||s.endsWith(".bdf")){n++;continue}let a=s.split("/"),c=a.findIndex((f,m)=>m<a.length-1&&rv.some((p)=>f.endsWith(p)));if(c>=0){let f=a.slice(0,c+1).join("/");if(!r.has(f)){r.add(f);let m=rv.find((p)=>a[c].endsWith(p));i(`${m}/`)}continue}let u=Net.exec(s);if(u){let f=u[2];if(f!=="json"&&f!=="tsv")i(`.${f}`);continue}let d=LC.filter((f)=>s.endsWith(f)).sort((f,m)=>m.length-f.length)[0];if(d){i(d);continue}if(s.startsWith("sourcedata/")){let f=a[a.length-1],m=f.lastIndexOf("."),p=m>0?f.slice(m+1):m===0?f.slice(1):"";if(!jet.has(p)&&!Met.test(f))i(p===""?"(no extension)":`.${p}`)}}return{screened:n,unscreened:t}}function aae(e){let t={};for(let r of e)t[r.kind]=(t[r.kind]??0)+1;return t}var Jse,Zl,wt=256,IC,xet,wet,vet,_et,Det,PC=(e)=>Det[e.toLowerCase()]??0,Eet,Yl=(e,t)=>t>=1&&t<=12&&e>=1&&e<=31,jC=(e)=>e.trim().toLowerCase().replace(/[\s_-]+/g,""),Cet,Ret,Aet,Oet,Tet,Fet,Pet,Iet,rv,Net,LC,jet,Met;var Ql=I(()=>{Jse=new Set(["edf-patient-name","edf-patient-code","edf-patient-freetext","edf-patient-birthdate","edf-patient-nonascii","edf-patient-age","edf-recording-freetext","json-identifier-key","participants-identifier-column"]),Zl=new Set(["edf-startdate","edf-recording-startdate","acq-time-dated"]),IC=new Set(["x","x_x","xx","unknown","anonymous","anon","n/a","na","none","null","default","noname","no_name","patient","subject","participant","-"]),xet=new Set(["m","f","male","female","sex","age","id","name","dob","mrn","ssn","hand","handed","handedness","right","left","ambidextrous","sub","subj","session","ses","run","task","rest","resting","test","pilot","phantom","study","control","healthy","recording","eeg","emg","meg","ieeg","birth","birthdate","date","startdate","weight","height","kg","cm","year","years","anonymized","anonymised","deidentified","de","identified","unnamed","nn","hc","pd","ad","mci","and","biosemi","neuracle","neuroscan","brainvision","brainproducts","actichamp","nihonkohden","natus","compumedics","eego","mitsar","emotiv","openbci","gtec","biopac","bitbrain","cognionics","state","eyes","closed","open","recorder","baseline","calibration","impedance","cap","amplifier","reference","ref","online","offline","software","system","device","lab","laboratory","clinic","hospital","unit","centre","center","department","dept","university","institute","experiment","trial","block","acquisition","protocol","montage","channel","channels","sampling","filter","raw","data","file","time","start","end","day","visit","pre","post","stim","stimulation","sham","active","of","the","at","in","by","with","for","to","a","an","on","or","from"]),wet=new Set([...IC,"unnamed","nn","hc","pd","mci","anonymized","anonymised","deidentified"]),vet=new Set(["control","healthy","test","pilot","phantom","study","group","cohort","patient","volunteer"]),_et=/^(sub|subj|subject|s|p|pt|participant)[-_ ]?\d+$/i,Det={jan:1,january:1,feb:2,february:2,mar:3,march:3,apr:4,april:4,may:5,jun:6,june:6,jul:7,july:7,aug:8,august:8,sep:9,sept:9,september:9,oct:10,october:10,nov:11,november:11,dec:12,december:12};Eet=/[^\p{L}\p{N}'._-]+/u;Cet=new Set(["name","firstname","lastname","fullname","givenname","familyname","surname","forename","participantname","subjectname","initials","dob","birthdate","dateofbirth","birthday","email","phone","telephone","address","street","zip","postcode","mrn","ssn","medicalrecord","medicalrecordnumber","medicalrecordno","medicalrecordid","recordnumber","patientid","patientname","patientcode","hospitalid","nationalid"]);Ret=new Set(["patientname","patientid","patientguid","patientcode","patientbirthdate","birthdate","dateofbirth","dob","examdoctor","diagnosisdoctor","requestdoctor","admissionid","bednumber","medicalrecord","medicalrecordnumber","medicalrecordno","medicalrecordid","mrn","ssn","nationalid"]),Aet=new Set(["address","contact","phone","telephone","email","national"]);Oet=/\.(jpe?g|png|gif|bmp|tiff?|webp|pdf|docx?|xlsx?|pptx?|rtf|odt)$/i,Tet=/_photo\.(jpe?g|png|tiff?)$/i,Fet=/(^|\/)(\.idea|\.vscode|__pycache__|\.ipynb_checkpoints|\.DS_Store|Thumbs\.db)(\/|$)|\.pyc$/;Pet=/(?:[A-Za-z]:\\{1,2}Users\\{1,2}|(?<![A-Za-z0-9._~:/-])\/(?:Users|home)\/)([A-Za-z0-9_.-]+)/,Iet=new Set(["user","username","name","you","me","yourname","your_name","runner","ubuntu","vagrant","node","foo","example","dev","docker","root","shared","public","default"]);rv=[".ds",".mff",".mefd",".zarr"],Net=/_(eeg|ieeg|meg|emg|nirs|physio|motion)\.([a-z0-9+]+(?:\.[a-z0-9]+)?)$/,LC=[".vhdr",".set",".fdt",".fif",".fif.gz",".cnt",".xdf",".nwb",".snirf",".gdf",".con",".sqd",".hdf5",".h5",".mat",".trc",".cdt",".nev",".edf.gz",".bdf.gz",".nii",".nii.gz",".ns1",".ns2",".ns3",".ns4",".ns5",".ns6",".lay",".rec",".smr",".dat",".npy",".parquet",".zip",".tar",".tar.gz",".tgz",".7z",".rar"],jet=new Set(["json","tsv","csv","txt","md","yml","yaml","xml","iml","py","pyc","m","r","rmd","ipynb","gitignore","jpg","jpeg","png","gif","pdf","svg","tex","bib","rst","cfg","ini","toml","docx","doc","xlsx","xls","pptx","ppt","odt","ods","rtf","html","htm","log","sh","bat","ps1","js","ts","css","lock","gitkeep","ds_store"]),Met=/^(readme|license|licence|changes|citation|authors|notice|thumbs\.db|\.ds_store|\.gitkeep)/});function kt(e){throw new av(e)}function qh(e,t,r){for(let n of Object.keys(e))if(!t.includes(n))kt(r)}function BC(e,t,r,n){if(!Vf(e)||Object.keys(e).length>r)kt(n);let i={};for(let[o,s]of Object.entries(e)){if(!t(o)||!Mh(s))kt(n);i[o]=s}return i}function zC(e){let t=e.indexOf("/");if(t<0)return!1;let r=e.slice(0,t),n=e.slice(t+1);return Wet.has(r)&&(Ket.has(n)||Jet.test(n))}function Xet(e){let t=Object.keys(e.findings_by_kind??{}),r=Object.values(e.unscreened_formats??{}).reduce((o,s)=>o+s,0),n=e.files;if(n){let o=n.header_read!==n.edf_bdf||e.incomplete_reasons.length>0;if(e.incomplete!==o)kt("scan-status")}if(e.status==="clean"||e.status==="dates-only"||e.status==="no-recordings"){if(!n||e.incomplete||r>0||(e.edf_bdf_files_flagged??0)>0)kt("scan-status");if(e.status==="no-recordings"){if(n.edf_bdf!==0)kt("scan-status")}else if(n.edf_bdf===0)kt("scan-status");if(e.status==="clean"&&t.length>0)kt("scan-status");if(e.status!=="clean"&&!t.every((o)=>Zl.has(o)))kt("scan-status")}if(e.status==="unchecked"&&!e.incomplete)kt("scan-status")}function Zet(e){if(typeof e.scanned_at!=="string"||!Yet.test(e.scanned_at))kt("scan-time");if(!VC.includes(e.status))kt("scan-status");if(typeof e.incomplete!=="boolean")kt("scan-incomplete");if(!Array.isArray(e.incomplete_reasons)||e.incomplete_reasons.length>40||!e.incomplete_reasons.every((r)=>typeof r==="string"&&Get.has(r)))kt("scan-reasons");let t={scanned_at:e.scanned_at,status:e.status,incomplete:e.incomplete,incomplete_reasons:e.incomplete_reasons};if(e.manifest_source!==void 0){if(typeof e.manifest_source!=="string"||!Uet.has(e.manifest_source))kt("scan-source");t.manifest_source=e.manifest_source}if(e.files!==void 0){let r=e.files;if(!Vf(r))kt("scan-files");let n=r;qh(n,["total","edf_bdf","header_read","header_read_failed"],"scan-files");for(let i of["total","edf_bdf","header_read","header_read_failed"])if(!Mh(n[i]))kt("scan-files");t.files=n}if(e.sampling!==void 0){let r=e.sampling;if(!Vf(r))kt("scan-sampling");let n=r,i=["edf_headers","scans_tables","json_files","text_files"];qh(n,i,"scan-sampling");for(let o of i){let s=n[o];if(!Vf(s))kt("scan-sampling");let a=s;qh(a,["candidates","oversize","selected","scanned"],"scan-sampling");for(let c of["candidates","oversize","selected","scanned"])if(!Mh(a[c]))kt("scan-sampling")}t.sampling=n}if(e.read_failures!==void 0)t.read_failures=BC(e.read_failures,zC,60,"scan-failures");for(let r of["edf_bdf_files_flagged","distinct_patient_field_values","distinct_subjects_with_edf_bdf","distinct_patient_code_subfield","distinct_patient_name_subfield","distinct_patient_birth_subfield","distinct_patient_field_values_in_flagged_files","side_reads_failed"])if(e[r]!==void 0){if(!Mh(e[r]))kt("scan-count");t[r]=e[r]}for(let r of["findings_by_kind","edf_bdf_files_by_kind"])if(e[r]!==void 0)t[r]=BC(e[r],(n)=>Bet.has(n),40,"scan-kinds");if(e.unscreened_formats!==void 0)t.unscreened_formats=BC(e.unscreened_formats,(r)=>Vet.test(r),60,"scan-formats");return t}function Hc(e){switch(e){case"clean":case"dates-only":case"no-recordings":return"clear";case"direct-identifiers":return"blocks";case"review":case"unchecked":case"not-screened":case"clean-edf-only-others-unscreened":return"acknowledge";case"pending":return"wait";default:return"rerun"}}function lae(e){return e==="pending"||e==="error"||e==="unreported"||VC.includes(e)}function ett(e){return Object.entries(e??{}).map(([t,r])=>`${t} x${r}`).join(", ")}function cv(e){let t=0;for(let[r,n]of Object.entries(e??{}))if(Zl.has(r)&&Mh(n))t+=n;return t}function ttt(e){let t=cv(e?.findings_by_kind),r="in recording headers or scans tables";if(t>0){let n=`${e?.incomplete===!0?"at least ":""}${t} ${t===1?"entry":"entries"}`;r=`${r} (${n})`}else if(e?.status!=="dates-only")return[];return[`${uae} ${r}.`,...dae]}function fae(e){return e.startsWith(uae)||dae.includes(e)}function pae(e){return`Acquisition dates in ${`${e} recording header${e===1?"":"s"}`} were set to 1 January of their year.`}function mae(e){return["Your request was received.","NEMAR is checking publication eligibility.","If every check passes, an administrator is notified to approve it.","You will be emailed if a check needs your attention, and when an administrator decides.",`Run 'nemar dataset publish status ${e}' to see where it stands.`]}function rtt(e){let t=[];if(e.files){let i=e.files.header_read_failed>0?` (${e.files.header_read_failed} unreadable)`:"";t.push(`Files: ${e.files.total}; EDF/BDF headers read: ${e.files.header_read} of ${e.files.edf_bdf}${i}.`)}let r=ett(e.findings_by_kind);if(r)t.push(`Findings by kind: ${r}.`);if(e.edf_bdf_files_flagged)t.push(`EDF/BDF files with an identifier finding: ${e.edf_bdf_files_flagged}.`);let n=Object.entries(e.unscreened_formats??{});if(n.length>0)t.push(`Not screened (format x files): ${n.map(([i,o])=>`${i} x${o}`).join(", ")}.`);if(e.incomplete_reasons.length>0)t.push(`Incomplete: ${e.incomplete_reasons.join(", ")}.`);return t}function gae(e){let t=e?.read_failures;if(typeof t!=="object"||t===null)return e;let r={},n=(o,s)=>{r[o]=(r[o]??0)+s};for(let[o,s]of Object.entries(t)){let a=o.toLowerCase();if(zC(a)){n(a,s);continue}let c=a.slice(0,Math.max(0,a.indexOf("/")));n(`${zC(`${c}/${jh}`)?c:jh}/${jh}`,s)}let i=Object.entries(r).sort(([,o],[,s])=>s-o);if(i.length>UC){let o=Object.fromEntries(i.slice(0,UC-1)),s=`${jh}/${jh}`;for(let[,a]of i.slice(UC-1))o[s]=(o[s]??0)+a;return{...e,read_failures:o}}return{...e,read_failures:r}}function bae(e){let t=e?.unscreened_formats;if(typeof t!=="object"||t===null)return e;let r={};for(let[n,i]of Object.entries(t)){let o=yae.has(n)?n:hae;r[o]=(r[o]??0)+i}return{...e,unscreened_formats:r}}function HC(e){if(!Vf(e))return kt("scan-shape");qh(e,cae,"scan-key");for(let r of cae)if(e[r]===void 0)kt("scan-missing");let t=Zet(e);for(let r of Object.keys(t.unscreened_formats))if(!yae.has(r))kt("scan-formats");return Xet(t),t}function xae(e){if(!Vf(e))return kt("preflight-shape");if(qh(e,["version","scanner","scan","acknowledged_via"],"preflight-key"),e.version!==sv)kt("preflight-version");if(typeof e.scanner!=="string"||!ntt.test(e.scanner))kt("preflight-scanner");let t=HC(e.scan),r=e.acknowledged_via;if(r!==null&&r!=="prompt"&&r!=="flag")kt("preflight-ack");if(Hc(t.status)==="acknowledge"!==(r!==null))kt("preflight-ack");return{version:sv,scanner:e.scanner,scan:t,acknowledged_via:r}}function GC(e,t){let r=Qet[e.status],n=rtt(e);if(n.push(...ttt(e)),t==="prompt")n.push("Acknowledged by the uploader at the prompt.");if(t==="flag")n.push("Acknowledged by the uploader with --acknowledge-identifier-preflight.");return{headline:`Identifier preflight: ${r.verdict}`,tone:r.tone,lines:n}}var qet,Let,Bet,VC,Uet,zet,VCt,av,Vf=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),Mh=(e)=>typeof e==="number"&&Number.isSafeInteger(e)&&e>=0,Vet,Het,Get,Wet,Ket,Jet,Yet,Qet,uae="Warning: acquisition dates finer than year and month were found",dae,hae=".other",jh="internal",UC=60,sv=1,yae,cae,lv,ntt;var Hf=I(()=>{Ql();qet={"edf-unreadable":!0,"edf-patient-nonascii":!0,"edf-recording-nonascii":!0,"path-subject-label":!0,"edf-patient-name":!0,"edf-patient-code":!0,"edf-patient-recordnumber":!0,"edf-patient-age":!0,"edf-patient-freetext":!0,"edf-patient-birthdate":!0,"edf-recording-startdate":!0,"edf-recording-freetext":!0,"edf-recording-technician":!0,"edf-startdate":!0,"edf-startdate-unparsed":!0,"participants-identifier-column":!0,"json-identifier-key":!0,"acq-time-dated":!0,"image-or-document-file":!0,"tooling-debris":!0,"local-user-path":!0},Let=Object.keys(qet),Bet=new Set(Let),VC=["direct-identifiers","dates-only","review","clean","clean-edf-only-others-unscreened","not-screened","no-recordings","unchecked"],Uet=new Set(["manifest.json","s3-version-manifest","git-tree","clone"]),zet=["dispatch-unconfigured","dispatch-failed","no-report-in-time","workflow-failed","clone-failed","credentials-missing","deadline"],VCt=new Set(zet);av=class av extends Error{constructor(e){super(e);this.name="ReportError"}};Vet=/^(\.[a-z0-9]{1,12}(\.[a-z0-9]{1,12})?\/?|\(no extension\))$/,Het=["edf-headers-oversize","edf-headers-sampled","edf-headers-unread","json-oversize","json-sampled","json-unread","text-oversize","text-sampled","text-unread","scans-unread","participants-unread","participants-truncated","history-unread","submodule-unread","no-latest-version","manifest-shape","tree-truncated","credentials-missing","deadline"],Get=new Set(Het),Wet=new Set(["edf","participants","scans","json","text","internal"]),Ket=new Set(["timeout","network","deadline","credentials-missing","header-truncated","json-parse","no-body","short-body","unreadable-entry","superseded-absent","blob-missing","blob-closed","internal","error-error","error-rangeerror","error-typeerror","error-syntaxerror","error-referenceerror","error-evalerror","error-urierror","error-aborterror","error-timeouterror"]),Jet=/^http-[1-5]\d\d$/;Yet=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?Z$/;Qet={pending:{verdict:"running",tone:"note"},clean:{verdict:"clean",tone:"ok"},"dates-only":{verdict:"clean (acquisition dates only)",tone:"ok"},"no-recordings":{verdict:"clean (no recordings)",tone:"ok"},review:{verdict:"needs review",tone:"warn"},"direct-identifiers":{verdict:"FOUND IDENTIFIERS",tone:"stop"},unchecked:{verdict:"INCOMPLETE",tone:"warn"},"not-screened":{verdict:"recordings NOT screened",tone:"warn"},"clean-edf-only-others-unscreened":{verdict:"EDF/BDF clean, other recordings NOT screened",tone:"warn"},error:{verdict:"DID NOT RUN",tone:"stop"},unreported:{verdict:"DID NOT REPORT",tone:"stop"}};dae=["NEMAR does not change them.","A date can help identify a participant when it is combined with other information.","Remove or coarsen any date that could identify someone before uploading or requesting publication.","Administrators are told of these findings when publication is requested."];yae=new Set([...LC,...rv.map((e)=>`${e}/`),".eeg",".vmrk",".mef",".kdf",".mrk",".elp",".hsp",".raw",".mhd",".tsv.gz","(no extension)",hae]);cae=["scanned_at","status","incomplete","incomplete_reasons","files","findings_by_kind","edf_bdf_files_flagged","unscreened_formats","read_failures"],lv=VC.filter((e)=>Hc(e)==="acknowledge"),ntt=/^nemar-cli@\d{1,4}\.\d{1,4}\.\d{1,6}(-[0-9a-z.]{1,24})?$/});var{spawn:ztt}=globalThis.Bun;async function tu(){try{return await ztt({cmd:["aws","--version"],stdout:"pipe",stderr:"pipe"}).exited===0}catch{return!1}}function uR(e){let t=e.split(`
|
|
138
|
+
`,r),s=o<0?e.length:o,a=e.slice(r,s);if(i===0){if(n=a.replace(/\r$/,"").split("\t").indexOf("acq_time"),n<0)return t}else{let c=0,u=0;for(;u<n;u++){let d=a.indexOf("\t",c);if(d<0)break;c=d+1}if(u===n){let d=a.indexOf("\t",c);t.push({index:r+c,value:a.slice(c,d<0?a.length:d)})}}if(o<0)return t;r=o+1}}function iv(e){return qC(e).flatMap((t)=>MC(t.value))}function Nh(e){if(e===null||e===void 0)return!1;if(typeof e==="string")return e.trim()!=="";if(typeof e==="number"||typeof e==="boolean")return!0;if(Array.isArray(e))return e.some(Nh);if(typeof e==="object")return Object.values(e).some(Nh);return!1}function Xl(e){let t=[];if(Array.isArray(e)){for(let r of e)t.push(...Xl(r));return t}if(e===null||typeof e!=="object")return t;for(let[r,n]of Object.entries(e)){let i=jC(r),o=Ret.has(i)?"identifier":Aet.has(i)?"review":null;if(o&&Nh(n)){let s=Array.isArray(n)?"[]":typeof n==="object"?"{}":String(n);t.push({kind:"json-identifier-key",severity:o,field:i,shape:ds(s)});continue}if(n!==null&&typeof n==="object")t.push(...Xl(n))}return t}function ov(e){let t=[],r=new Set;for(let n of e){let i=n.slice(n.lastIndexOf("/")+1);if(Fet.test(n))t.push({kind:"tooling-debris",severity:"review",field:"path",shape:ds(i)});else if(Oet.test(i)&&!Tet.test(i))t.push({kind:"image-or-document-file",severity:"review",field:"path",shape:ds(i)});for(let o of n.matchAll(/(?:^|\/)sub-([\p{L}\p{N}]+)/gu)){let s=o[1];if(nae(s)&&!r.has(s))r.add(s),t.push({kind:"path-subject-label",severity:"review",field:"path",shape:ds(s)})}}return t}function oae(e){for(let t of e.matchAll(new RegExp(Pet,"g"))){if(Iet.has(t[1].toLowerCase()))continue;return[{kind:"local-user-path",severity:"review",field:"text",shape:ds(t[0])}]}return[]}function sae(e){let t={},r=new Set,n=0,i=(o)=>{t[o]=(t[o]??0)+1};for(let o of e){let s=o.toLowerCase();if(s.endsWith(".edf")||s.endsWith(".bdf")){n++;continue}let a=s.split("/"),c=a.findIndex((f,m)=>m<a.length-1&&rv.some((p)=>f.endsWith(p)));if(c>=0){let f=a.slice(0,c+1).join("/");if(!r.has(f)){r.add(f);let m=rv.find((p)=>a[c].endsWith(p));i(`${m}/`)}continue}let u=Net.exec(s);if(u){let f=u[2];if(f!=="json"&&f!=="tsv")i(`.${f}`);continue}let d=LC.filter((f)=>s.endsWith(f)).sort((f,m)=>m.length-f.length)[0];if(d){i(d);continue}if(s.startsWith("sourcedata/")){let f=a[a.length-1],m=f.lastIndexOf("."),p=m>0?f.slice(m+1):m===0?f.slice(1):"";if(!jet.has(p)&&!Met.test(f))i(p===""?"(no extension)":`.${p}`)}}return{screened:n,unscreened:t}}function aae(e){let t={};for(let r of e)t[r.kind]=(t[r.kind]??0)+1;return t}var Jse,Zl,wt=256,IC,xet,wet,vet,_et,Det,PC=(e)=>Det[e.toLowerCase()]??0,Eet,Yl=(e,t)=>t>=1&&t<=12&&e>=1&&e<=31,jC=(e)=>e.trim().toLowerCase().replace(/[\s_-]+/g,""),Cet,Ret,Aet,Oet,Tet,Fet,Pet,Iet,rv,Net,LC,jet,Met;var Ql=I(()=>{Jse=new Set(["edf-patient-name","edf-patient-code","edf-patient-freetext","edf-patient-birthdate","edf-patient-nonascii","edf-patient-age","edf-recording-freetext","json-identifier-key","participants-identifier-column"]),Zl=new Set(["edf-startdate","edf-recording-startdate","acq-time-dated"]),IC=new Set(["x","x_x","xx","unknown","anonymous","anon","n/a","na","none","null","default","noname","no_name","patient","subject","participant","-"]),xet=new Set(["m","f","male","female","sex","age","id","name","dob","mrn","ssn","hand","handed","handedness","right","left","ambidextrous","sub","subj","session","ses","run","task","rest","resting","test","pilot","phantom","study","control","healthy","recording","eeg","emg","meg","ieeg","birth","birthdate","date","startdate","weight","height","kg","cm","year","years","anonymized","anonymised","deidentified","de","identified","unnamed","nn","hc","pd","ad","mci","and","biosemi","neuracle","neuroscan","brainvision","brainproducts","actichamp","nihonkohden","natus","compumedics","eego","mitsar","emotiv","openbci","gtec","biopac","bitbrain","cognionics","state","eyes","closed","open","recorder","baseline","calibration","impedance","cap","amplifier","reference","ref","online","offline","software","system","device","lab","laboratory","clinic","hospital","unit","centre","center","department","dept","university","institute","experiment","trial","block","acquisition","protocol","montage","channel","channels","sampling","filter","raw","data","file","time","start","end","day","visit","pre","post","stim","stimulation","sham","active","of","the","at","in","by","with","for","to","a","an","on","or","from"]),wet=new Set([...IC,"unnamed","nn","hc","pd","mci","anonymized","anonymised","deidentified"]),vet=new Set(["control","healthy","test","pilot","phantom","study","group","cohort","patient","volunteer"]),_et=/^(sub|subj|subject|s|p|pt|participant)[-_ ]?\d+$/i,Det={jan:1,january:1,feb:2,february:2,mar:3,march:3,apr:4,april:4,may:5,jun:6,june:6,jul:7,july:7,aug:8,august:8,sep:9,sept:9,september:9,oct:10,october:10,nov:11,november:11,dec:12,december:12};Eet=/[^\p{L}\p{N}'._-]+/u;Cet=new Set(["name","firstname","lastname","fullname","givenname","familyname","surname","forename","participantname","subjectname","initials","dob","birthdate","dateofbirth","birthday","email","phone","telephone","address","street","zip","postcode","mrn","ssn","medicalrecord","medicalrecordnumber","medicalrecordno","medicalrecordid","recordnumber","patientid","patientname","patientcode","hospitalid","nationalid"]);Ret=new Set(["patientname","patientid","patientguid","patientcode","patientbirthdate","birthdate","dateofbirth","dob","examdoctor","diagnosisdoctor","requestdoctor","admissionid","bednumber","medicalrecord","medicalrecordnumber","medicalrecordno","medicalrecordid","mrn","ssn","nationalid"]),Aet=new Set(["address","contact","phone","telephone","email","national"]);Oet=/\.(jpe?g|png|gif|bmp|tiff?|webp|pdf|docx?|xlsx?|pptx?|rtf|odt)$/i,Tet=/_photo\.(jpe?g|png|tiff?)$/i,Fet=/(^|\/)(\.idea|\.vscode|__pycache__|\.ipynb_checkpoints|\.DS_Store|Thumbs\.db)(\/|$)|\.pyc$/;Pet=/(?:[A-Za-z]:\\{1,2}Users\\{1,2}|(?<![A-Za-z0-9._~:/-])\/(?:Users|home)\/)([A-Za-z0-9_.-]+)/,Iet=new Set(["user","username","name","you","me","yourname","your_name","runner","ubuntu","vagrant","node","foo","example","dev","docker","root","shared","public","default"]);rv=[".ds",".mff",".mefd",".zarr"],Net=/_(eeg|ieeg|meg|emg|nirs|physio|motion)\.([a-z0-9+]+(?:\.[a-z0-9]+)?)$/,LC=[".vhdr",".set",".fdt",".fif",".fif.gz",".cnt",".xdf",".nwb",".snirf",".gdf",".con",".sqd",".hdf5",".h5",".mat",".trc",".cdt",".nev",".edf.gz",".bdf.gz",".nii",".nii.gz",".ns1",".ns2",".ns3",".ns4",".ns5",".ns6",".lay",".rec",".smr",".dat",".npy",".parquet",".zip",".tar",".tar.gz",".tgz",".7z",".rar"],jet=new Set(["json","tsv","csv","txt","md","yml","yaml","xml","iml","py","pyc","m","r","rmd","ipynb","gitignore","jpg","jpeg","png","gif","pdf","svg","tex","bib","rst","cfg","ini","toml","docx","doc","xlsx","xls","pptx","ppt","odt","ods","rtf","html","htm","log","sh","bat","ps1","js","ts","css","lock","gitkeep","ds_store"]),Met=/^(readme|license|licence|changes|citation|authors|notice|thumbs\.db|\.ds_store|\.gitkeep)/});function kt(e){throw new av(e)}function qh(e,t,r){for(let n of Object.keys(e))if(!t.includes(n))kt(r)}function BC(e,t,r,n){if(!Vf(e)||Object.keys(e).length>r)kt(n);let i={};for(let[o,s]of Object.entries(e)){if(!t(o)||!Mh(s))kt(n);i[o]=s}return i}function zC(e){let t=e.indexOf("/");if(t<0)return!1;let r=e.slice(0,t),n=e.slice(t+1);return Wet.has(r)&&(Ket.has(n)||Jet.test(n))}function Xet(e){let t=Object.keys(e.findings_by_kind??{}),r=Object.values(e.unscreened_formats??{}).reduce((o,s)=>o+s,0),n=e.files;if(n){let o=n.header_read!==n.edf_bdf||e.incomplete_reasons.length>0;if(e.incomplete!==o)kt("scan-status")}if(e.status==="clean"||e.status==="dates-only"||e.status==="no-recordings"){if(!n||e.incomplete||r>0||(e.edf_bdf_files_flagged??0)>0)kt("scan-status");if(e.status==="no-recordings"){if(n.edf_bdf!==0)kt("scan-status")}else if(n.edf_bdf===0)kt("scan-status");if(e.status==="clean"&&t.length>0)kt("scan-status");if(e.status!=="clean"&&!t.every((o)=>Zl.has(o)))kt("scan-status")}if(e.status==="unchecked"&&!e.incomplete)kt("scan-status")}function Zet(e){if(typeof e.scanned_at!=="string"||!Yet.test(e.scanned_at))kt("scan-time");if(!VC.includes(e.status))kt("scan-status");if(typeof e.incomplete!=="boolean")kt("scan-incomplete");if(!Array.isArray(e.incomplete_reasons)||e.incomplete_reasons.length>40||!e.incomplete_reasons.every((r)=>typeof r==="string"&&Get.has(r)))kt("scan-reasons");let t={scanned_at:e.scanned_at,status:e.status,incomplete:e.incomplete,incomplete_reasons:e.incomplete_reasons};if(e.manifest_source!==void 0){if(typeof e.manifest_source!=="string"||!Uet.has(e.manifest_source))kt("scan-source");t.manifest_source=e.manifest_source}if(e.files!==void 0){let r=e.files;if(!Vf(r))kt("scan-files");let n=r;qh(n,["total","edf_bdf","header_read","header_read_failed"],"scan-files");for(let i of["total","edf_bdf","header_read","header_read_failed"])if(!Mh(n[i]))kt("scan-files");t.files=n}if(e.sampling!==void 0){let r=e.sampling;if(!Vf(r))kt("scan-sampling");let n=r,i=["edf_headers","scans_tables","json_files","text_files"];qh(n,i,"scan-sampling");for(let o of i){let s=n[o];if(!Vf(s))kt("scan-sampling");let a=s;qh(a,["candidates","oversize","selected","scanned"],"scan-sampling");for(let c of["candidates","oversize","selected","scanned"])if(!Mh(a[c]))kt("scan-sampling")}t.sampling=n}if(e.read_failures!==void 0)t.read_failures=BC(e.read_failures,zC,60,"scan-failures");for(let r of["edf_bdf_files_flagged","distinct_patient_field_values","distinct_subjects_with_edf_bdf","distinct_patient_code_subfield","distinct_patient_name_subfield","distinct_patient_birth_subfield","distinct_patient_field_values_in_flagged_files","side_reads_failed"])if(e[r]!==void 0){if(!Mh(e[r]))kt("scan-count");t[r]=e[r]}for(let r of["findings_by_kind","edf_bdf_files_by_kind"])if(e[r]!==void 0)t[r]=BC(e[r],(n)=>Bet.has(n),40,"scan-kinds");if(e.unscreened_formats!==void 0)t.unscreened_formats=BC(e.unscreened_formats,(r)=>Vet.test(r),60,"scan-formats");return t}function Hc(e){switch(e){case"clean":case"dates-only":case"no-recordings":return"clear";case"direct-identifiers":return"blocks";case"review":case"unchecked":case"not-screened":case"clean-edf-only-others-unscreened":return"acknowledge";case"pending":return"wait";default:return"rerun"}}function lae(e){return e==="pending"||e==="error"||e==="unreported"||VC.includes(e)}function ett(e){return Object.entries(e??{}).map(([t,r])=>`${t} x${r}`).join(", ")}function cv(e){let t=0;for(let[r,n]of Object.entries(e??{}))if(Zl.has(r)&&Mh(n))t+=n;return t}function ttt(e){let t=cv(e?.findings_by_kind),r="in recording headers or scans tables";if(t>0){let n=`${e?.incomplete===!0?"at least ":""}${t} ${t===1?"entry":"entries"}`;r=`${r} (${n})`}else if(e?.status!=="dates-only")return[];return[`${uae} ${r}.`,...dae]}function fae(e){return e.startsWith(uae)||dae.includes(e)}function pae(e){return`Acquisition dates in ${`${e} recording header${e===1?"":"s"}`} were set to 1 January of their year.`}function mae(e){return["Your request was received.","NEMAR is checking publication eligibility.","If every check passes, an administrator is notified to approve it.","You will be emailed if a check needs your attention, and when an administrator decides.",`Run 'nemar dataset publish status ${e}' to see where it stands.`]}function rtt(e){let t=[];if(e.files){let i=e.files.header_read_failed>0?` (${e.files.header_read_failed} unreadable)`:"";t.push(`Files: ${e.files.total}; EDF/BDF headers read: ${e.files.header_read} of ${e.files.edf_bdf}${i}.`)}let r=ett(e.findings_by_kind);if(r)t.push(`Findings by kind: ${r}.`);if(e.edf_bdf_files_flagged)t.push(`EDF/BDF files with an identifier finding: ${e.edf_bdf_files_flagged}.`);let n=Object.entries(e.unscreened_formats??{});if(n.length>0)t.push(`Not screened (format x files): ${n.map(([i,o])=>`${i} x${o}`).join(", ")}.`);if(e.incomplete_reasons.length>0)t.push(`Incomplete: ${e.incomplete_reasons.join(", ")}.`);return t}function gae(e){let t=e?.read_failures;if(typeof t!=="object"||t===null)return e;let r={},n=(o,s)=>{r[o]=(r[o]??0)+s};for(let[o,s]of Object.entries(t)){let a=o.toLowerCase();if(zC(a)){n(a,s);continue}let c=a.slice(0,Math.max(0,a.indexOf("/")));n(`${zC(`${c}/${jh}`)?c:jh}/${jh}`,s)}let i=Object.entries(r).sort(([,o],[,s])=>s-o);if(i.length>UC){let o=Object.fromEntries(i.slice(0,UC-1)),s=`${jh}/${jh}`;for(let[,a]of i.slice(UC-1))o[s]=(o[s]??0)+a;return{...e,read_failures:o}}return{...e,read_failures:r}}function bae(e){let t=e?.unscreened_formats;if(typeof t!=="object"||t===null)return e;let r={};for(let[n,i]of Object.entries(t)){let o=yae.has(n)?n:hae;r[o]=(r[o]??0)+i}return{...e,unscreened_formats:r}}function HC(e){if(!Vf(e))return kt("scan-shape");qh(e,cae,"scan-key");for(let r of cae)if(e[r]===void 0)kt("scan-missing");let t=Zet(e);for(let r of Object.keys(t.unscreened_formats))if(!yae.has(r))kt("scan-formats");return Xet(t),t}function xae(e){if(!Vf(e))return kt("preflight-shape");if(qh(e,["version","scanner","scan","acknowledged_via"],"preflight-key"),e.version!==sv)kt("preflight-version");if(typeof e.scanner!=="string"||!ntt.test(e.scanner))kt("preflight-scanner");let t=HC(e.scan),r=e.acknowledged_via;if(r!==null&&r!=="prompt"&&r!=="flag")kt("preflight-ack");if(Hc(t.status)==="acknowledge"!==(r!==null))kt("preflight-ack");return{version:sv,scanner:e.scanner,scan:t,acknowledged_via:r}}function GC(e,t){let r=Qet[e.status],n=rtt(e);if(n.push(...ttt(e)),t==="prompt")n.push("Acknowledged by the uploader at the prompt.");if(t==="flag")n.push("Acknowledged by the uploader with --acknowledge-identifier-preflight.");return{headline:`Identifier preflight: ${r.verdict}`,tone:r.tone,lines:n}}var qet,Let,Bet,VC,Uet,zet,VCt,av,Vf=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),Mh=(e)=>typeof e==="number"&&Number.isSafeInteger(e)&&e>=0,Vet,Het,Get,Wet,Ket,Jet,Yet,Qet,uae="Warning: acquisition dates finer than year and month were found",dae,hae=".other",jh="internal",UC=60,sv=1,yae,cae,lv,ntt;var Hf=I(()=>{Ql();qet={"edf-unreadable":!0,"edf-patient-nonascii":!0,"edf-recording-nonascii":!0,"path-subject-label":!0,"edf-patient-name":!0,"edf-patient-code":!0,"edf-patient-recordnumber":!0,"edf-patient-age":!0,"edf-patient-freetext":!0,"edf-patient-birthdate":!0,"edf-recording-startdate":!0,"edf-recording-freetext":!0,"edf-recording-technician":!0,"edf-startdate":!0,"edf-startdate-unparsed":!0,"participants-identifier-column":!0,"json-identifier-key":!0,"acq-time-dated":!0,"image-or-document-file":!0,"tooling-debris":!0,"local-user-path":!0},Let=Object.keys(qet),Bet=new Set(Let),VC=["direct-identifiers","dates-only","review","clean","clean-edf-only-others-unscreened","not-screened","no-recordings","unchecked"],Uet=new Set(["manifest.json","s3-version-manifest","git-tree","clone"]),zet=["dispatch-unconfigured","dispatch-failed","no-report-in-time","workflow-failed","clone-failed","credentials-missing","deadline"],VCt=new Set(zet);av=class av extends Error{constructor(e){super(e);this.name="ReportError"}};Vet=/^(\.[a-z0-9]{1,12}(\.[a-z0-9]{1,12})?\/?|\(no extension\))$/,Het=["edf-headers-oversize","edf-headers-sampled","edf-headers-unread","json-oversize","json-sampled","json-unread","text-oversize","text-sampled","text-unread","scans-unread","participants-unread","participants-truncated","history-unread","submodule-unread","no-latest-version","manifest-shape","tree-truncated","credentials-missing","deadline"],Get=new Set(Het),Wet=new Set(["edf","participants","scans","json","text","internal"]),Ket=new Set(["timeout","network","deadline","credentials-missing","header-truncated","json-parse","no-body","short-body","unreadable-entry","superseded-absent","blob-missing","blob-closed","internal","error-error","error-rangeerror","error-typeerror","error-syntaxerror","error-referenceerror","error-evalerror","error-urierror","error-aborterror","error-timeouterror"]),Jet=/^http-[1-5]\d\d$/;Yet=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?Z$/;Qet={pending:{verdict:"running",tone:"note"},clean:{verdict:"clean",tone:"ok"},"dates-only":{verdict:"clean (acquisition dates only)",tone:"ok"},"no-recordings":{verdict:"clean (no recordings)",tone:"ok"},review:{verdict:"needs review",tone:"warn"},"direct-identifiers":{verdict:"FOUND IDENTIFIERS",tone:"stop"},unchecked:{verdict:"INCOMPLETE",tone:"warn"},"not-screened":{verdict:"recordings NOT screened",tone:"warn"},"clean-edf-only-others-unscreened":{verdict:"EDF/BDF clean, other recordings NOT screened",tone:"warn"},error:{verdict:"DID NOT RUN",tone:"stop"},unreported:{verdict:"DID NOT REPORT",tone:"stop"}};dae=["NEMAR does not change them.","A date can help identify a participant when it is combined with other information.","Remove or coarsen any date that could identify someone before uploading or requesting publication.","Administrators are told of these findings when publication is requested."];yae=new Set([...LC,...rv.map((e)=>`${e}/`),".eeg",".vmrk",".mef",".kdf",".mrk",".elp",".hsp",".raw",".mhd",".tsv.gz","(no extension)",hae]);cae=["scanned_at","status","incomplete","incomplete_reasons","files","findings_by_kind","edf_bdf_files_flagged","unscreened_formats","read_failures"],lv=VC.filter((e)=>Hc(e)==="acknowledge"),ntt=/^nemar-cli@\d{1,4}\.\d{1,4}\.\d{1,6}(-[0-9a-z.]{1,24})?$/});var{spawn:ztt}=globalThis.Bun;async function tu(){try{return await ztt({cmd:["aws","--version"],stdout:"pipe",stderr:"pipe"}).exited===0}catch{return!1}}function uR(e){let t=e.split(`
|
|
139
139
|
`).map((r)=>r.trim()).filter(Boolean);return t[t.length-1]??""}async function Dv(e){let{credentials:t,bucket:r,region:n,prefix:i}=e,o={bucket:r,prefix:i,object:null};if(!await tu())return{...o,outcome:"unavailable",detail:"the aws CLI is not on PATH"};let s={AWS_ACCESS_KEY_ID:t.access_key_id,AWS_SECRET_ACCESS_KEY:t.secret_access_key,AWS_SESSION_TOKEN:t.session_token,AWS_DEFAULT_REGION:n},a=["AWS_PROFILE","AWS_DEFAULT_PROFILE"],c;try{c=await k(["aws","s3api","list-objects-v2","--bucket",r,"--prefix",`${i.replace(/\/$/,"")}/`,"--max-keys","1","--query","Contents[0].Key","--output","text"],{env:s,unsetEnv:a,timeout:60000})}catch(f){return{...o,outcome:"inconclusive",detail:f instanceof Error?f.message:String(f)}}if(c.timedOut)return{...o,outcome:"inconclusive",detail:"the listing timed out"};if(c.exitCode!==0){let f=uR(c.stderr);return/AccessDenied|InvalidAccessKeyId|ExpiredToken|SignatureDoesNotMatch|NoSuchBucket|403|404|An error occurred/i.test(f)?{...o,outcome:"refused",detail:f}:{...o,outcome:"inconclusive",detail:f}}let u=c.stdout.trim();if(!u||u==="None")return{...o,outcome:"empty-prefix"};let d;try{d=await k(["aws","s3api","head-object","--bucket",r,"--key",u],{env:s,unsetEnv:a,timeout:60000})}catch(f){return{...o,object:u,outcome:"inconclusive",detail:f instanceof Error?f.message:String(f)}}if(d.timedOut)return{...o,object:u,outcome:"inconclusive",detail:"the read timed out"};if(d.exitCode!==0){let f=uR(d.stderr);return/AccessDenied|InvalidAccessKeyId|ExpiredToken|SignatureDoesNotMatch|403|404|An error occurred/i.test(f)?{...o,object:u,outcome:"refused",detail:f}:{...o,object:u,outcome:"inconclusive",detail:f}}return{...o,object:u,outcome:"reachable"}}async function nce(e){let{credentials:t,bucket:r,region:n,prefix:i,keys:o}=e;if(o.length===0)return[];if(!await tu())return o.map((m)=>({key:m,outcome:"unknown",detail:"the aws CLI is not on PATH"}));let s=t?{AWS_ACCESS_KEY_ID:t.access_key_id,AWS_SECRET_ACCESS_KEY:t.secret_access_key,AWS_SESSION_TOKEN:t.session_token,AWS_DEFAULT_REGION:n}:{AWS_DEFAULT_REGION:n},a=t?["AWS_PROFILE","AWS_DEFAULT_PROFILE"]:[],c=`${i.replace(/\/$/,"")}/`,u=Array(o.length),d=0;async function f(){while(!0){let m=d++;if(m>=o.length)return;let p=o[m],g;try{g=await k(["aws","s3api","head-object","--bucket",r,"--key",`${c}${p}`],{env:s,unsetEnv:a,timeout:60000})}catch(b){u[m]={key:p,outcome:"unknown",detail:b instanceof Error?b.message:String(b)};continue}if(g.exitCode===0){u[m]={key:p,outcome:"present"};continue}let h=uR(g.stderr);u[m]=/404|Not Found/i.test(h)?{key:p,outcome:"absent"}:{key:p,outcome:"unknown",detail:h}}}return await Promise.all(Array.from({length:Math.min(Vtt,o.length)},()=>f())),u}async function ice(e){let{credentials:t,bucket:r,region:n,prefix:i}=e;if(!await tu())throw Error("the aws CLI is not on PATH, so the bucket cannot be listed");let o=`${i.replace(/\/$/,"")}/`,{stdout:s,stderr:a,exitCode:c,timedOut:u}=await k(["aws","s3api","list-objects-v2","--bucket",r,"--prefix",o,"--query","Contents[].[Key,Size]","--output","text","--page-size","1000"],{env:{AWS_ACCESS_KEY_ID:t.access_key_id,AWS_SECRET_ACCESS_KEY:t.secret_access_key,AWS_SESSION_TOKEN:t.session_token,AWS_DEFAULT_REGION:n},unsetEnv:["AWS_PROFILE","AWS_DEFAULT_PROFILE","AWS_ENDPOINT_URL","AWS_ENDPOINT_URL_S3"],timeout:600000});if(c!==0||u)throw Error(`listing s3://${r}/${o} failed: ${u?"timed out":a.trim()||`exit ${c}`}`);return Htt(s,o)}function Htt(e,t){let r=t.endsWith("/")?t:`${t}/`,n=new Map;for(let i of e.split(`
|
|
140
140
|
`)){let o=i.trim();if(!o||o==="None")continue;let s=o.lastIndexOf("\t")>=0?o.lastIndexOf("\t"):o.lastIndexOf(" ");if(s<0)continue;let a=o.slice(0,s).trimEnd(),c=Number(o.slice(s+1).trim());if(!a.startsWith(r))continue;let u=a.slice(r.length);if(!Number.isFinite(c))continue;if(u&&!u.includes("/"))n.set(u,c)}return n}var Vtt=8;var Xf=I(()=>{It()});function Er(e){return{accessKeyId:e.access_key_id,secretAccessKey:e.secret_access_key,sessionToken:e.session_token}}function fR(e){let t=[/^\(merging .* into .*\.\.\.\)$/,/^\(recording state in git\.\.\.\)$/,/^\(scanning for /,/^\(checking /];return e.split(`
|
|
141
141
|
`).filter((r)=>{let n=r.trim();if(!n)return!1;if(n.includes("setting annex-ignore"))return!1;if(t.some((i)=>i.test(n)))return!1;return!0}).join(`
|
|
@@ -193,7 +193,7 @@ Privacy correction ${e}: ${n}. The checksums in the provenance file describe the
|
|
|
193
193
|
${m}`:", ";return`${e.slice(0,c)}${g}${p}${e.slice(c)}`}function sg(e){try{return ag(e).isFile()}catch{return!1}}async function Hit(e,t){for(let r of ln(t))if((await k(["git","-c","annex.largefiles=nothing","add","--",...r],{cwd:e})).exitCode!==0)throw Error(`git add failed for ${r.length} scrubbed file(s)`)}function Git(e){let t=Ii(e,ng);if(!_it(t))return!1;let r;try{r=Lle(t)}catch{return!0}let n=!1;for(let i of r){if(i.action==="history-rewritten")n=!1;if(i.action==="import-scrubbed"&&((i.counts.json_values_blanked??0)>0||(i.counts.git_held_recordings_scrubbed??0)>0))n=!0}return n}async function Wit(e){try{return await Kit(e)}catch(t){if(t instanceof Bt)throw t;throw new Bt("scrub-failed",cg(t))}}async function Kit(e){let{datasetPath:t}=e,r=Bit(),n=[...await iu(t)].sort(),i=await Ti(t),o=n.filter((B)=>gue.test(B));r.recordings=o.length;let s=!e.reimport,a=[],c=[],u=new Set,d=[];for(let B of o){let re=i.get(B);if(re===void 0){a.push(B);continue}if(e.skipData){r.headers_not_read_skip_data++;continue}if(ti(re)===0){r.headers_not_edf++,u.add(re);continue}let Z=e.keyUrlMap.get(re);if(Z===void 0){if(e.reimport)r.headers_not_read_nemar_held++;else r.headers_not_read_no_source++;continue}let J=Cv(Z),rt=J?{kind:"s3",ref:J}:/^https?:\/\//.test(Z)?{kind:"url",url:Z}:null;if(!rt){d.push("source-unsupported");continue}c.push({path:B,key:re,source:rt})}let f=[];for(let B of a){let re=XR(Ii(t,B));if(re===null){d.push("local-unreadable");continue}r.headers_read++;let Z=ZR(re,s);if(Z===null){r.headers_not_edf++;continue}if(Z.change.datesLeft)r.headers_dates_left++;if(Z.change.datesUnproven)r.headers_dates_unproven++;if(Z.change.scrub||Z.change.dates)f.push({path:B,change:Z.change})}let m=await Uit(c,e.concurrency??16,(B)=>e.reader.header(B.source)),p=[...d],g=[],h=[];if(m.forEach((B,re)=>{let Z=c[re];if(!B.ok){p.push(B.failure);return}let J=ti(Z.key);if(J!==null&&B.total===null){p.push("no-length");return}if(J!==null&&B.total!==J){g.push(Z.key);return}r.headers_read++,u.add(Z.key);let rt=ZR(B.bytes,s);if(rt===null){r.headers_not_edf++;return}if(rt.change.datesLeft)r.headers_dates_left++;if(rt.change.datesUnproven)r.headers_dates_unproven++;if(rt.change.scrub||rt.change.dates)h.push({...Z,size:J??0,change:rt.change})}),p.length>0){let B=p.every((re)=>re==="http-403"||re==="http-404");throw new Bt("header-unreadable",`${p.length} of ${o.length} recording header(s) could not be read: ${zit(p)}`,B)}if(g.length>0)throw new Bt("upstream-size-mismatch",`${g.length} upstream object(s) are not the size their annex key declares`);let b=h.filter((B)=>B.change.scrub),x=f.filter((B)=>B.change.scrub),w=b.length+x.length;if(e.reimport&&w>0)throw new Bt("already-imported-unscrubbed",`${w} recording(s) in the dataset's own tree need a scrub; correct it with ADR 0085's procedure, not by re-importing`);let D=(B)=>rl.test(B.key)&&B.size>0;if(b.some((B)=>!D(B))){let B=b.filter((re)=>!D(re)).length;throw new Bt("unsupported-key-backend",`${B} recording key(s) to replace are not SHA256E with a declared size`)}let C=e.maxBytes??LR,E=b.reduce((B,re)=>B+re.size,0),A=e.unannexedData.reduce((B,re)=>B+re.size,0);if(E+A>C)throw new Bt("bound-exceeded",`${b.length} recording(s) to scrub, ${(E/1073741824).toFixed(1)} GiB to download and ${(A/1073741824).toFixed(1)} GiB of git-held data to upload, over the ${(C/1073741824).toFixed(1)} GiB bound; run on a host that can move them with --normalize-max-gb`);let T=h.filter((B)=>!B.change.scrub),L=T.filter(D);r.headers_dates_left+=T.length-L.length;let O=L.reduce((B,re)=>B+re.size,0),N=E+A+O<=C;if(!N)r.headers_dates_over_bound=L.length,r.headers_dates_left+=L.length;let W=new Set(N?L:[]),F=h.filter((B)=>B.change.scrub||W.has(B)),H=[];for(let B of F){let re=Ii(t,B.path),Z=`${re}.nemar-scrub-download`,J=await e.reader.download(B.source,Z);if(!B.change.scrub){let si=rl.exec(B.key)?.[2],vs=J.ok&&J.bytes===B.size&&await fue(Z)===si;if(vs)try{YR(Z,s)}catch{vs=!1}if(!vs){nl(Z,{force:!0}),r.headers_dates_failed++,r.headers_dates_left++;continue}r.bytes_downloaded+=B.size,nl(re,{force:!0}),aue(Z,re),H.push(B);continue}if(!J.ok)throw new Bt("header-unreadable",`a recording to scrub could not be downloaded: ${J.failure}`,J.failure==="http-403"||J.failure==="http-404");let rt=rl.exec(B.key)?.[2];if(J.bytes!==B.size||await fue(Z)!==rt)throw nl(Z,{force:!0}),new Bt("content-mismatch","a downloaded recording does not hash to the key it was downloaded for");r.bytes_downloaded+=J.bytes,YR(Z,s),nl(re,{force:!0}),aue(Z,re),H.push(B)}for(let B of f)YR(Ii(t,B.path),s);r.headers_scrubbed=w,r.git_held_recordings_scrubbed=x.length;let te=f.filter((B)=>B.change.dates).length;r.headers_dates_normalized=H.filter((B)=>B.change.dates).length+te,r.git_held_recordings_dates_normalized=te;let P=[],M=new Set,ge=new Set,ce=[],br=f.map((B)=>B.path),Et=[...H.map((B)=>({path:B.path,size:B.size})),...e.skipData?[]:br.map((B)=>({path:B,size:ag(Ii(t,B)).size}))];if(e.skipData)ce.push(...br);if(Et.length>0){if(!e.upload)throw Error("scrubbed recordings need an upload strategy");let B;try{B=await BR({datasetPath:t,files:Et,remoteName:e.remoteName,bucket:e.bucket,nemarId:e.nemarId,maxBytes:C,upload:e.upload,backend:"SHA256E"})}catch(J){throw new Bt("upload-failed",`${Et.length} scrubbed recording(s) could not be annexed or uploaded: ${cg(J)}`)}P.push(...B.items);for(let J of br)ge.add(J);let re=new Map(B.files.map((J)=>[J.path,J.key])),Z={};for(let J of H){let rt=re.get(J.path);if(!rt||!rl.test(rt)||rt===J.key)throw new Bt("scrub-unverified","a scrubbed recording has no new key");Z[J.key]=rt,M.add(J.key)}if(r.upstream_keys_replaced=M.size,M.size>0){let J;try{J=await Kle({repo:t,keymap:Z,remoteUuids:[],execute:!0})}catch(si){throw new Bt("retire-failed",`the git-annex branch could not be updated: ${cg(si)}`)}let rt=new Set(Object.values(Z)).size;if(J.oldStillHeld!==0||J.oldDead!==J.oldKeys||J.deadRefused!==0||J.newPresent!==rt)throw new Bt("retire-failed",`${J.oldKeys-J.oldDead} of ${J.oldKeys} replaced key(s) not recorded dead, ${rt-J.newPresent} new key(s) not recorded at the remote`)}}for(let B of n){if(!Iit.test(B))continue;if(i.has(B)){r.json_files_annexed++;continue}let re=Ii(t,B);if(!sg(re)||ag(re).size>Fit){r.json_files_unread++;continue}let Z;try{Z=sue(Xv(re))}catch(J){if(J instanceof ig)throw new Bt("scrub-unverified","a blanked JSON file failed its proof");throw J}if(Z.status==="unreadable"){r.json_files_unread++;continue}if(r.json_files_read++,Z.status==="blanked"&&Z.bytes)og(re,Z.bytes),ce.push(B),r.json_files_blanked++,r.json_values_blanked+=Z.blanked}if(s)for(let B of n){if(!Nit.test(B))continue;if(i.has(B)){r.scans_tables_annexed++;continue}let re=Ii(t,B);if(!sg(re)||ag(re).size>Pit){r.scans_tables_unread++;continue}let Z;try{Z=oue(Xv(re))}catch{Z={status:"unreadable",values:0}}if(Z.status==="unreadable"){r.scans_tables_unread++;continue}if(r.scans_tables_read++,Z.status==="normalized"&&Z.bytes)og(re,Z.bytes),ce.push(B),r.scans_tables_normalized++,r.scans_values_normalized+=Z.values}r.images_or_documents_held=ov(n).filter((B)=>B.kind==="image-or-document-file").length;let gr=r.headers_scrubbed>0||r.headers_dates_normalized>0||r.json_values_blanked>0||r.scans_values_normalized>0,Zr=e.now??new Date,Rr=Zr.toISOString().slice(0,10),qr=r.headers_scrubbed>0?r.headers_dates_normalized>0?"scrubbed-and-dates-set":"scrubbed-in-place":r.headers_dates_normalized>0?"dates-set":null;if(qr!==null){let B=Ii(t,ip);if(n.includes(ip)&&sg(B)){let Z=Xv(B,"utf8"),J=Z.charCodeAt(0)===65279?String.fromCharCode(65279):"",rt=Vit(Z.slice(J.length),VR,Nle(Rr,qr));if(rt!==null)og(B,`${J}${rt}`),ce.push(ip),r.provenance_annotated=1;else r.provenance_not_annotated++}else if(n.includes(ip))r.provenance_not_annotated++;let re=Ii(t,rg);if(n.includes(rg)&&sg(re)){let Z=jle(Rr,qr),J=Xv(re,"utf8");if(!J.endsWith(Z))og(re,`${J}${J===""||J.endsWith(`
|
|
194
194
|
`)?"":`
|
|
195
195
|
`}${Z}`),ce.push(rg);r.provenance_readme_annotated=1}else if(n.includes(rg))r.provenance_not_annotated++}let Q=!1;if(gr){let B=process.env.GITHUB_ACTOR,re=e.actor??(B&&Tit.test(B)?B:Oit);qle(Ii(t,ng),{version:1,at:Zr.toISOString(),dataset:e.nemarId,action:"import-scrubbed",versions:[],counts:{...r},scanner:Ait,verification:"scanner-clean+payload-identical",actor:re}),ce.push(ng),await Hit(t,ce);let Z=[`Recording headers scrubbed: ${r.headers_scrubbed} (identification fields only; signal bytes unchanged).`,`Acquisition dates set to 1 January of their year: ${r.headers_dates_normalized} recording header(s), ${r.scans_values_normalized} scans table value(s) in ${r.scans_tables_normalized} file(s).`,`JSON values blanked: ${r.json_values_blanked} in ${r.json_files_blanked} file(s).`,`Images and documents left for review: ${r.images_or_documents_held}.`,`Recorded in ${ng}.`].join(`
|
|
196
|
-
`),J=[...new Set([...ce,...Et.map((vs)=>vs.path)])],rt=Dit(Ii($it(),"nemar-scrub-pathspec-")),si=Ii(rt,"paths");og(si,`${J.join("\x00")}\x00`,{mode:384});try{if((await k(["git","-c","annex.largefiles=nothing","commit","-m","Privacy correction on import (ADR 0089)","-m",Z,`--pathspec-from-file=${si}`,"--pathspec-file-nul"],{cwd:t})).exitCode!==0)throw Error("could not commit the import scrub")}finally{nl(rt,{recursive:!0,force:!0})}Q=!0}return{counts:r,items:P,replacedKeys:M,handledPaths:ge,historyHoldsOriginals:r.json_values_blanked>0||r.git_held_recordings_scrubbed>0||e.reimport&&Git(t),headerReadKeys:u,committed:Q}}async function Jit(e,t,r){try{return await Yit(e,t,r)}catch(n){if(n instanceof Bt)throw n;throw new Bt("scrub-failed",cg(n))}}async function Yit(e,t,r){let n=new Set((await Ti(e)).values()),i=[...r].filter((d)=>n.has(d)).length;if(i>0)throw new Bt("old-key-still-named",`${i} replaced key(s) are still named by the tree`);let o=new Map;for(let d of t)if(!o.has(d.key))o.set(d.key,d);let s=[...o.values()].filter((d)=>n.has(d.key)),a=o.size-s.length,c=await Gv(e,s.map((d)=>d.key)),u=s.filter((d,f)=>!Wv(c[f]??""));return{items:u,droppedNotInTree:a,droppedDead:s.length-u.length}}async function bue(e){let t=await Wit({datasetPath:e.datasetPath,nemarId:e.nemarId,keyUrlMap:e.keyUrlMap,unannexedData:e.unannexedData,reimport:e.reimport,skipData:e.skipData,maxBytes:e.maxBytes,reader:e.reader,upload:e.upload,remoteName:e.remoteName,bucket:e.bucket,now:e.now,actor:e.actor}),r=await Uv({datasetPath:e.datasetPath,nemarId:e.nemarId,bucket:e.bucket,remoteName:e.remoteName,unannexedData:e.unannexedData.filter((a)=>!t.handledPaths.has(a.path)),upstreamKeys:new Set(e.keyUrlMap.keys()),carryOverUnaccountedKeys:e.reimport&&!e.skipData,upload:e.upload,maxBytes:e.maxBytes}),n=e.skipData?{items:[],droppedNotInTree:0,droppedDead:0}:await Jit(e.datasetPath,[...e.upstreamItems,...t.items,...r.items],t.replacedKeys),i;try{i=await Ti(e.datasetPath)}catch(a){throw new Bt("scrub-failed",cg(a))}let o=new Set([...i].filter(([a])=>gue.test(a)).map(([,a])=>a)),s=n.items.filter((a)=>!ep(a)&&o.has(a.key)&&!t.headerReadKeys.has(a.key)).length;if(s>0)throw new Bt("header-unreadable",`${s} recording(s) in the copy manifest whose header this run did not read`);return{scrub:t,normalized:r,manifest:n,privacy:{version:1,historyHoldsOriginals:t.historyHoldsOriginals}}}var Bt,Cit,Rit,Ait,Oit="nemar-importer",Tit,Fit=1048576,Pit=8388608,gue,Iit,Nit,cue="nemar-cli-import-scrub",Mit;var xue=I(()=>{Vv();Jle();GR();Ql();JR();cs();It();ri();eg();io();tl();Bt=class Bt extends Error{code;constructor(e,t,r=!1){super(`${r?`${zv} `:""}${kle} refused: ${e} (${t}). Nothing was pushed, and the copy phase did not run.`);this.code=e;this.name="ImportScrubRefused"}};Cit=new Set(["GitScrubError","ContractError","LedgerRefused"]),Rit=/^[A-Z][A-Z0-9_]{1,20}$/;Ait=`identifier-scan@${"
|
|
196
|
+
`),J=[...new Set([...ce,...Et.map((vs)=>vs.path)])],rt=Dit(Ii($it(),"nemar-scrub-pathspec-")),si=Ii(rt,"paths");og(si,`${J.join("\x00")}\x00`,{mode:384});try{if((await k(["git","-c","annex.largefiles=nothing","commit","-m","Privacy correction on import (ADR 0089)","-m",Z,`--pathspec-from-file=${si}`,"--pathspec-file-nul"],{cwd:t})).exitCode!==0)throw Error("could not commit the import scrub")}finally{nl(rt,{recursive:!0,force:!0})}Q=!0}return{counts:r,items:P,replacedKeys:M,handledPaths:ge,historyHoldsOriginals:r.json_values_blanked>0||r.git_held_recordings_scrubbed>0||e.reimport&&Git(t),headerReadKeys:u,committed:Q}}async function Jit(e,t,r){try{return await Yit(e,t,r)}catch(n){if(n instanceof Bt)throw n;throw new Bt("scrub-failed",cg(n))}}async function Yit(e,t,r){let n=new Set((await Ti(e)).values()),i=[...r].filter((d)=>n.has(d)).length;if(i>0)throw new Bt("old-key-still-named",`${i} replaced key(s) are still named by the tree`);let o=new Map;for(let d of t)if(!o.has(d.key))o.set(d.key,d);let s=[...o.values()].filter((d)=>n.has(d.key)),a=o.size-s.length,c=await Gv(e,s.map((d)=>d.key)),u=s.filter((d,f)=>!Wv(c[f]??""));return{items:u,droppedNotInTree:a,droppedDead:s.length-u.length}}async function bue(e){let t=await Wit({datasetPath:e.datasetPath,nemarId:e.nemarId,keyUrlMap:e.keyUrlMap,unannexedData:e.unannexedData,reimport:e.reimport,skipData:e.skipData,maxBytes:e.maxBytes,reader:e.reader,upload:e.upload,remoteName:e.remoteName,bucket:e.bucket,now:e.now,actor:e.actor}),r=await Uv({datasetPath:e.datasetPath,nemarId:e.nemarId,bucket:e.bucket,remoteName:e.remoteName,unannexedData:e.unannexedData.filter((a)=>!t.handledPaths.has(a.path)),upstreamKeys:new Set(e.keyUrlMap.keys()),carryOverUnaccountedKeys:e.reimport&&!e.skipData,upload:e.upload,maxBytes:e.maxBytes}),n=e.skipData?{items:[],droppedNotInTree:0,droppedDead:0}:await Jit(e.datasetPath,[...e.upstreamItems,...t.items,...r.items],t.replacedKeys),i;try{i=await Ti(e.datasetPath)}catch(a){throw new Bt("scrub-failed",cg(a))}let o=new Set([...i].filter(([a])=>gue.test(a)).map(([,a])=>a)),s=n.items.filter((a)=>!ep(a)&&o.has(a.key)&&!t.headerReadKeys.has(a.key)).length;if(s>0)throw new Bt("header-unreadable",`${s} recording(s) in the copy manifest whose header this run did not read`);return{scrub:t,normalized:r,manifest:n,privacy:{version:1,historyHoldsOriginals:t.historyHoldsOriginals}}}var Bt,Cit,Rit,Ait,Oit="nemar-importer",Tit,Fit=1048576,Pit=8388608,gue,Iit,Nit,cue="nemar-cli-import-scrub",Mit;var xue=I(()=>{Vv();Jle();GR();Ql();JR();cs();It();ri();eg();io();tl();Bt=class Bt extends Error{code;constructor(e,t,r=!1){super(`${r?`${zv} `:""}${kle} refused: ${e} (${t}). Nothing was pushed, and the copy phase did not run.`);this.code=e;this.name="ImportScrubRefused"}};Cit=new Set(["GitScrubError","ContractError","LedgerRefused"]),Rit=/^[A-Z][A-Z0-9_]{1,20}$/;Ait=`identifier-scan@${"b25e171d43a990cf"}`,Tit=/^[a-z0-9][a-z0-9-]{0,38}$/i,gue=/\.(edf|bdf)$/i,Iit=/\.json$/i,Nit=/_scans\.tsv$/;Mit=new Set(["ENOSPC","EACCES","EPERM","EROFS","EIO","EMFILE","ENFILE"])});import{existsSync as vue,mkdirSync as Xit,mkdtempSync as _ue,readFileSync as Zit,readdirSync as lg,readlinkSync as Qit,renameSync as eot,rmSync as tot,statSync as rot,writeFileSync as QR}from"fs";import{tmpdir as Due}from"os";import{join as En}from"path";async function eA(e,t,r=120000,n=5000){let i=Date.now()+r,o,s=!1;while(Date.now()<i){try{let c=await pw(e);if(s=!0,c.bids_validation.present&&c.bids_validation.status!=="no_runs")return{kind:"found"}}catch(c){o=c}let a=Math.max(0,i-Date.now());t.text=`Waiting for BIDS validation run to register... (${Math.ceil(a/1000)}s left)`,await new Promise((c)=>setTimeout(c,Math.min(n,a)))}if(!s&&o!==void 0)return{kind:"error",lastError:o};return{kind:"timeout"}}function oot(e){if(!e.ciDeployed)return{skipCiCheck:!1,abortReason:"CI workflows did not deploy. Aborting before approval: --trust-upstream bypasses validation lookup, not workflow deployment. Re-run after fixing the deploy failure, or run `nemar admin ci add <id>` manually before approving."};let t=e.poll;if(t===null||t.kind==="found")return{skipCiCheck:!1};if(t.kind==="error")return{skipCiCheck:!1,abortReason:`Every BIDS validation poll attempt failed (last error: ${t.lastError instanceof Error?t.lastError.message:String(t.lastError)}). Refusing to bypass under --trust-upstream because validation state was never actually observed. Investigate API/auth health and re-run.`};if(e.trustUpstream)return{skipCiCheck:!0};return{skipCiCheck:!1,abortReason:"BIDS validation run did not register within the bounded poll window. Re-run with --trust-upstream to bypass (OpenNeuro datasets are pre-validated upstream), or investigate why the deployed CI did not trigger."}}function sot(e){return e.includes("already exists")||e.includes("409")}function aot(e){return e==="public"?"skip-already-published":"request"}function cot(e){return e.originMainSha!==null&&e.originMainSha!==""&&e.currentBranch==="main"}function tA(e){let t=e.match(/^ds(\d{6})$/);if(!t)throw Error(`Invalid OpenNeuro ID "${e}". Expected format: ds###### (e.g., ds007262)`);return`on${t[1]}`}async function Zv(e){let[t,r]=await Promise.all([iu(e),el(e)]),n=[];for(let i of t){if(r.has(i))continue;let o;try{o=rot(En(e,i)).size}catch(s){let a=s.code;if(a==="ENOENT"||a==="ENOTDIR")continue;throw Error(`Cannot stat tracked file ${i}: ${s instanceof Error?s.message:String(s)}`)}if(qc(i,o))n.push({path:i,size:o})}return n}function lot(e){let t;try{t=lg(e,{withFileTypes:!0})}catch(n){let i=n.code;if(i==="ENOENT"||i==="ENOTDIR")return[];throw Error(`Cannot scan ${e} for annexed metadata: ${n instanceof Error?n.message:String(n)}`)}let r=[];for(let n of t){if(!n.isSymbolicLink())continue;if(!kie(n.name))continue;try{if(Qit(En(e,n.name)).includes("annex/objects"))r.push(n.name)}catch{}}return r.sort()}function dot(e,t){let r=t.split("/").map(encodeURIComponent).join("/");return`https://s3.amazonaws.com/openneuro.org/${e}/${r}`}async function fot(e,t){let r=lot(e);if(r.length===0)return[];let n=[];for(let o of r){let s=dot(t,o),a;try{let u=await fetch(s);if(!u.ok){n.push(`${o} (HTTP ${u.status})`);continue}a=Buffer.from(await u.arrayBuffer())}catch(u){n.push(`${o} (fetch failed: ${u instanceof Error?u.message:String(u)})`);continue}if(a.length===0){n.push(`${o} (HTTP 200 but empty body)`);continue}let c=En(e,o);try{tot(c,{force:!0}),QR(c,a)}catch(u){throw Error(`Failed to write fetched metadata ${o} to ${c} (local error, not OpenNeuro): ${u instanceof Error?u.message:String(u)}`)}}if(n.length>0)throw Error(`${zv} cannot fetch metadata from OpenNeuro: ${n.join(", ")}. These objects are not anonymously readable and NEMAR has no signed OpenNeuro login. This is an OpenNeuro-side access problem, not a NEMAR import bug. (Any files that did fetch are left as regular files on disk, unstaged.)`);let i=await k(["git","-c","annex.largefiles=nothing","add",...r],{cwd:e});if(i.exitCode!==0)throw Error(`Failed to stage un-annexed metadata (${r.join(", ")}): ${i.stderr.trim()}. The files are already regular files on disk; recover with: git -C ${e} -c annex.largefiles=nothing add ${r.join(" ")}`);return r}function pot(e){let t=En(e,"dataset_description.json");if(!vue(t))throw Error(`dataset_description.json not found at ${t}`);try{return JSON.parse(Zit(t,"utf-8"))}catch(r){throw Error(`Failed to parse dataset_description.json at ${t}: ${r instanceof Error?r.message:String(r)}`)}}function Eue(){let e=process.env.AWS_ACCESS_KEY_ID,t=process.env.AWS_SECRET_ACCESS_KEY;if(!e||!t)throw Error("AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must be set in environment for S3 operations");return{accessKeyId:e,secretAccessKey:t,sessionToken:process.env.AWS_SESSION_TOKEN}}function mot(e){return typeof e.DatasetDOI==="string"?e.DatasetDOI.replace(/^doi:/,""):null}function hot(e){let t=new Set,r=[];try{r=lg(e,{withFileTypes:!0}).filter((n)=>n.isDirectory()&&n.name.startsWith("sub-")).map((n)=>n.name)}catch{return[]}for(let n of r){let i=En(e,n),o=[];try{o=lg(i,{withFileTypes:!0})}catch{continue}for(let s of o){if(!s.isDirectory())continue;if(s.name.startsWith("ses-")){let a=[];try{a=lg(En(i,s.name),{withFileTypes:!0})}catch{continue}for(let c of a)if(c.isDirectory()&&wue.includes(c.name))t.add(c.name)}else if(wue.includes(s.name))t.add(s.name)}}return[...t].sort()}function got(e){let t=e.Funding;if(!Array.isArray(t))return[];return t.filter((r)=>typeof r==="string"&&r.trim().length>0).map((r)=>({funder_name:r.trim()}))}function yot(e,t,r,n,i){let o=En(e,".nemar");if(!vue(o))Xit(o,{recursive:!0});let s=i?[{identifier:i,identifier_type:"DOI",relation_type:"IsIdenticalTo"}]:[],a=hot(e),c=got(n),u={version:"2.0",dataset_id:t,source:"openneuro",source_id:r,title:n.Name||t,authors:Array.isArray(n.Authors)?Object.fromEntries(n.Authors.map((d)=>[d,{}])):{},license:n.License||"CC0",dataset_type:n.DatasetType||"raw",related_identifiers:s,pipeline_stage:"seeded"};if(typeof n.BIDSVersion==="string")u.bids_version=n.BIDSVersion;if(a.length>0)u.recording_modality=a;if(a.length>0)u.datatypes=a;if(c.length>0)u.funding_references=c;if(typeof n.Acknowledgements==="string"&&n.Acknowledgements.trim().length>0)u.acknowledgements=n.Acknowledgements.trim();QR(En(o,"metadata.json"),`${JSON.stringify(u,null,2)}
|
|
197
197
|
`)}function xot(e,t,r){let i=lg(e,{withFileTypes:!0}).filter((f)=>f.isFile()&&bot.test(f.name)),o=i.find((f)=>f.name.includes("."));if(o)return{kind:"kept",path:o.name};let s=i.find((f)=>!f.name.includes("."));if(s)return eot(En(e,s.name),En(e,"README.md")),{kind:"renamed",from:"README",to:"README.md"};let a="<!-- nemar:provenance -->",c=`https://openneuro.org/datasets/${t}`,u=r?`
|
|
198
198
|
- DOI: [${r}](https://doi.org/${r})`:"",d=`${a}
|
|
199
199
|
## Provenance
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nemar-cli",
|
|
3
3
|
"packageManager": "bun@1.4.3",
|
|
4
|
-
"version": "0.10.18-dev.
|
|
4
|
+
"version": "0.10.18-dev.3427",
|
|
5
5
|
"description": "CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|