@sreetej510/pi-shipd-checks 0.2.0 → 0.2.3

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.
Files changed (3) hide show
  1. package/README.md +3 -3
  2. package/dist/index.js +13 -14
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -43,10 +43,10 @@ The two finder flags are additive/combinable; `--config` must be used alone.
43
43
 
44
44
  | Command | Effect |
45
45
  |---|---|
46
- | `/checks` | List available options (runs nothing) |
47
- | `/checks --gap-finder` | Find gaps sentence-by-sentence, then review them for fairness |
48
- | `/checks --solver-gap-finder` | Run several solver agents TDD-style against `agent_prompt.md` + `test.patch`, then compare their solutions to the real solution to find gaps |
46
+ | `/checks` | Open a menu with config, solver-gap-finder, and gap-finder options |
49
47
  | `/checks --config` | Configure behavioral and solver gap-finder models |
48
+ | `/checks --solver-gap-finder` | Run several solver agents TDD-style against `agent_prompt.md` + `test.patch`, then compare their solutions to the real solution to find gaps |
49
+ | `/checks --gap-finder` | Find gaps sentence-by-sentence, then review them for fairness |
50
50
  | `/analyze:on` | Enable the agent-callable Gap Finder tool for the current project |
51
51
  | `/analyze:off` | Disable the agent-callable Gap Finder tool for the current project |
52
52
 
package/dist/index.js CHANGED
@@ -1,17 +1,17 @@
1
- var th=Object.defineProperty;var Rt=(e,t)=>{for(var n in t)th(e,n,{get:t[n],enumerable:!0})};import{Container as rT,Key as aT,Spacer as oT,Text as vi}from"@earendil-works/pi-tui";import{randomUUID as Kf}from"node:crypto";import{copyFileSync as Wv,existsSync as zf,mkdirSync as Bf,rmSync as Hv,writeFileSync as Yv}from"node:fs";import{tmpdir as Vf}from"node:os";import{join as rt}from"node:path";import{getSettingsListTheme as Jv}from"@earendil-works/pi-coding-agent";import{Container as Xv,Key as zt,matchesKey as Bt,Spacer as Zv,Text as Wf}from"@earendil-works/pi-tui";import{createAgentSession as Oa,SessionManager as Pa}from"@earendil-works/pi-coding-agent";import{copyFileSync as ah,existsSync as no,lstatSync as oh,mkdirSync as ro,readFileSync as br,rmSync as Ni,symlinkSync as ih,unlinkSync as sh,writeFileSync as st}from"node:fs";import{join as he}from"node:path";import{createLocalBashOperations as mh}from"@earendil-works/pi-coding-agent";import{existsSync as Yt,mkdirSync as Ei,readFileSync as fr,writeFileSync as Si}from"node:fs";import{dirname as Ri,join as Oi}from"node:path";import{getAgentDir as Pi}from"@earendil-works/pi-coding-agent";var ft=Oi(Pi(),"checks-config.json"),dr=Oi(Pi(),"settings.json"),Ai=10,Ci=60,Ha=20,Ya=1,Mi=5,Ja=3,Xa=!0,Li=!1,nh=["off","minimal","low","medium","high","xhigh","max"];function qi(e){return e?.reasoning?nh.filter(t=>{let n=e.thinkingLevelMap?.[t];return n===null?!1:t==="xhigh"||t==="max"?n!==void 0:!0}):["off"]}function Te(){try{if(!Yt(ft))return null;let e=JSON.parse(fr(ft,"utf-8"));if(e.provider&&e.modelId&&e.thinkingLevel)return e}catch{}return null}function De(e){let t=Ri(ft);Yt(t)||Ei(t,{recursive:!0}),Si(ft,JSON.stringify(e,null,2),"utf-8")}function ji(){let e=Te()?.solverGap;return!e?.provider||!e.modelId||!e.thinkingLevel?null:{...e,timeoutMinutes:e.timeoutMinutes>0?e.timeoutMinutes:Ha,solverCount:e.solverCount>0?e.solverCount:Ja,saveArtifacts:typeof e.saveArtifacts=="boolean"?e.saveArtifacts:Xa}}function Za(){try{if(!Yt(ft))return{};let e=JSON.parse(fr(ft,"utf-8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Qa(){let e=Za().enabledProjects;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function hr(e){let t=Za();return Array.isArray(t.enabledProjects)?t.enabledProjects.some(n=>n===e):Te()?.enableAnalyzeTool??Li}function gr(e,t){let n=new Set(Qa());t?n.add(e):n.delete(e);let r=[...n],a=Te();if(a){De({...a,enabledProjects:r});return}let i=Ri(ft);Yt(i)||Ei(i,{recursive:!0}),Si(ft,JSON.stringify({...Za(),enabledProjects:r},null,2),"utf-8")}function yr(e){return e!==void 0?hr(e):Te()?.enableAnalyzeTool??Li}function Fi(){let e=Te()?.analyzeGap;return!e?.provider||!e.modelId||!e.thinkingLevel?null:{...e}}function Di(){try{return Yt(dr)?JSON.parse(fr(dr,"utf-8")).enabledModels??[]:[]}catch{return[]}}function Gi(e){let t=e.indexOf("/");return t<=0||t===e.length-1?null:{provider:e.slice(0,t),modelId:e.slice(t+1)}}function rh(){try{if(Yt(dr))return JSON.parse(fr(dr,"utf-8"))}catch{}return{}}function xr(){let e=rh().shellPath;return e||(process.platform==="win32"?"C:\\Program Files\\Git\\bin\\bash.exe":"bash")}function eo(e){return e.replace(/\\/g,"/")}function to(e){return`'${e.replace(/'/g,"'\\''")}'`}async function Ir(e,t,n,r){if(r?.aborted)return{status:"error",error:"cancelled"};if((await e.exec("git",["rev-parse","HEAD"],{cwd:t,timeout:15e3,signal:r})).code!==0)return{status:"error",error:"Not a git repository, or it has no commits yet."};let i=`git archive HEAD | tar -x -C ${to(eo(n))}`,m=await e.exec(xr(),["-c",i],{cwd:t,timeout:6e4,signal:r});return m.code!==0?{status:"error",error:m.stderr?.trim()||`git archive failed (exit ${m.code})`}:{status:"ok"}}var ao=3e4,_i=4e3,ph=".pi/shipd-checks",kn="solver_gap_solutions";function uh(e){let t=new Set,n=/^diff --git "?a\/(.+?)"? "?b\/(.+?)"?$/gm;for(let r of e.matchAll(n))r[1]&&t.add(r[1]),r[2]&&t.add(r[2]);return[...t]}function Ui(e,t){return e.length>t?e.slice(e.length-t):e}async function Ki(e){let{pi:t,repoDir:n,solverDir:r,testPatchPath:a,agentPromptPath:i,cancelSignal:m}=e;if(m?.aborted)return{status:"error",solverDir:r,error:"cancelled"};let u=await Ir(t,n,r,m);if(u.status==="error")return{status:"error",solverDir:r,error:u.error};let l={cwd:r,timeout:ao,signal:m},f=await t.exec("git",["init"],l);if(f.code!==0)return{status:"error",solverDir:r,error:f.stderr?.trim()||"git init failed"};await t.exec("git",["config","user.email","solvergap@shipd-checks.local"],l),await t.exec("git",["config","user.name","shipd-checks solver-gap-finder"],l);let h=await t.exec("git",["add","-A"],l);if(h.code!==0)return{status:"error",solverDir:r,error:h.stderr?.trim()||"git add (baseline) failed"};let v=await t.exec("git",["commit","-m","baseline","--allow-empty"],l);if(v.code!==0)return{status:"error",solverDir:r,error:v.stderr?.trim()||"git commit (baseline) failed"};let E=he(r,".gitignore"),A=no(E)?br(E,"utf-8"):"";if(!A.split(/\r?\n/).some(pe=>pe.trim()==="node_modules")){let pe=A.length>0&&!A.endsWith(`
1
+ var th=Object.defineProperty;var Rt=(e,t)=>{for(var n in t)th(e,n,{get:t[n],enumerable:!0})};import{Container as aT,Key as oT,Spacer as iT,Text as Ii}from"@earendil-works/pi-tui";import{randomUUID as Uf}from"node:crypto";import{copyFileSync as Wv,existsSync as Kf,mkdirSync as zf,rmSync as Hv,writeFileSync as Yv}from"node:fs";import{tmpdir as Bf}from"node:os";import{join as rt}from"node:path";import{getSettingsListTheme as Jv}from"@earendil-works/pi-coding-agent";import{Container as Xv,Key as zt,matchesKey as Bt,Spacer as Zv,Text as Vf}from"@earendil-works/pi-tui";import{createAgentSession as Oa,SessionManager as Pa}from"@earendil-works/pi-coding-agent";import{copyFileSync as ah,existsSync as no,lstatSync as oh,mkdirSync as ro,readFileSync as Ir,rmSync as Gi,symlinkSync as ih,unlinkSync as sh,writeFileSync as st}from"node:fs";import{join as he}from"node:path";import{createLocalBashOperations as mh}from"@earendil-works/pi-coding-agent";import{existsSync as Yt,mkdirSync as wi,readFileSync as fr,writeFileSync as Ei}from"node:fs";import{dirname as Si,join as Ri}from"node:path";import{getAgentDir as Oi}from"@earendil-works/pi-coding-agent";var ft=Ri(Oi(),"checks-config.json"),dr=Ri(Oi(),"settings.json"),Pi=10,Ai=60,Ha=20,Ya=1,Ci=5,Ja=3,Xa=!0,Mi=!1,nh=["off","minimal","low","medium","high","xhigh","max"];function qi(e){return e?.reasoning?nh.filter(t=>{let n=e.thinkingLevelMap?.[t];return n===null?!1:t==="xhigh"||t==="max"?n!==void 0:!0}):["off"]}function Te(){try{if(!Yt(ft))return null;let e=JSON.parse(fr(ft,"utf-8"));if(e.provider&&e.modelId&&e.thinkingLevel)return e}catch{}return null}function De(e){let t=Si(ft);Yt(t)||wi(t,{recursive:!0}),Ei(ft,JSON.stringify(e,null,2),"utf-8")}function Li(){let e=Te()?.solverGap;return!e?.provider||!e.modelId||!e.thinkingLevel?null:{...e,timeoutMinutes:e.timeoutMinutes>0?e.timeoutMinutes:Ha,solverCount:e.solverCount>0?e.solverCount:Ja,saveArtifacts:typeof e.saveArtifacts=="boolean"?e.saveArtifacts:Xa}}function Za(){try{if(!Yt(ft))return{};let e=JSON.parse(fr(ft,"utf-8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Qa(){let e=Za().enabledProjects;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function hr(e){let t=Za();return Array.isArray(t.enabledProjects)?t.enabledProjects.some(n=>n===e):Te()?.enableAnalyzeTool??Mi}function gr(e,t){let n=new Set(Qa());t?n.add(e):n.delete(e);let r=[...n],a=Te();if(a){De({...a,enabledProjects:r});return}let i=Si(ft);Yt(i)||wi(i,{recursive:!0}),Ei(ft,JSON.stringify({...Za(),enabledProjects:r},null,2),"utf-8")}function yr(e){return e!==void 0?hr(e):Te()?.enableAnalyzeTool??Mi}function ji(){let e=Te()?.analyzeGap;return!e?.provider||!e.modelId||!e.thinkingLevel?null:{...e}}function Fi(){try{return Yt(dr)?JSON.parse(fr(dr,"utf-8")).enabledModels??[]:[]}catch{return[]}}function Di(e){let t=e.indexOf("/");return t<=0||t===e.length-1?null:{provider:e.slice(0,t),modelId:e.slice(t+1)}}function rh(){try{if(Yt(dr))return JSON.parse(fr(dr,"utf-8"))}catch{}return{}}function xr(){let e=rh().shellPath;return e||(process.platform==="win32"?"C:\\Program Files\\Git\\bin\\bash.exe":"bash")}function eo(e){return e.replace(/\\/g,"/")}function to(e){return`'${e.replace(/'/g,"'\\''")}'`}async function br(e,t,n,r){if(r?.aborted)return{status:"error",error:"cancelled"};if((await e.exec("git",["rev-parse","HEAD"],{cwd:t,timeout:15e3,signal:r})).code!==0)return{status:"error",error:"Not a git repository, or it has no commits yet."};let i=`git archive HEAD | tar -x -C ${to(eo(n))}`,m=await e.exec(xr(),["-c",i],{cwd:t,timeout:6e4,signal:r});return m.code!==0?{status:"error",error:m.stderr?.trim()||`git archive failed (exit ${m.code})`}:{status:"ok"}}var ao=3e4,Ni=4e3,ph=".pi/shipd-checks",kn="solver_gap_solutions";function uh(e){let t=new Set,n=/^diff --git "?a\/(.+?)"? "?b\/(.+?)"?$/gm;for(let r of e.matchAll(n))r[1]&&t.add(r[1]),r[2]&&t.add(r[2]);return[...t]}function _i(e,t){return e.length>t?e.slice(e.length-t):e}async function Ui(e){let{pi:t,repoDir:n,solverDir:r,testPatchPath:a,agentPromptPath:i,cancelSignal:m}=e;if(m?.aborted)return{status:"error",solverDir:r,error:"cancelled"};let u=await br(t,n,r,m);if(u.status==="error")return{status:"error",solverDir:r,error:u.error};let l={cwd:r,timeout:ao,signal:m},f=await t.exec("git",["init"],l);if(f.code!==0)return{status:"error",solverDir:r,error:f.stderr?.trim()||"git init failed"};await t.exec("git",["config","user.email","solvergap@shipd-checks.local"],l),await t.exec("git",["config","user.name","shipd-checks solver-gap-finder"],l);let h=await t.exec("git",["add","-A"],l);if(h.code!==0)return{status:"error",solverDir:r,error:h.stderr?.trim()||"git add (baseline) failed"};let v=await t.exec("git",["commit","-m","baseline","--allow-empty"],l);if(v.code!==0)return{status:"error",solverDir:r,error:v.stderr?.trim()||"git commit (baseline) failed"};let E=he(r,".gitignore"),A=no(E)?Ir(E,"utf-8"):"";if(!A.split(/\r?\n/).some(pe=>pe.trim()==="node_modules")){let pe=A.length>0&&!A.endsWith(`
2
2
  `)?`
3
3
  `:"";st(E,`${A}${pe}node_modules
4
- `,"utf-8")}let F=he(n,"node_modules"),Y=he(r,"node_modules");if(no(F)&&!no(Y))try{ih(F,Y,process.platform==="win32"?"junction":"dir")}catch{}try{ah(i,he(r,"agent_prompt.md"))}catch{}let ae=br(a,"utf-8"),me=uh(ae),at=he(r,"test.patch");st(at,ae,"utf-8");let _=await t.exec("git",["apply","test.patch"],l);try{sh(at)}catch{}if(_.code!==0)return{status:"patchFailed",solverDir:r,error:_.stderr?.trim()||"git apply test.patch failed"};let ot=await t.exec("git",["add","-A"],l);if(ot.code!==0)return{status:"error",solverDir:r,error:ot.stderr?.trim()||"git add (tests applied) failed"};let it=await t.exec("git",["commit","-m","tests applied","--allow-empty"],l);if(it.code!==0)return{status:"error",solverDir:r,error:it.stderr?.trim()||"git commit (tests applied) failed"};let Ue=await t.exec("git",["rev-parse","HEAD"],l);return Ue.code!==0||!Ue.stdout.trim()?{status:"error",solverDir:r,error:"Could not resolve tests-applied commit hash."}:{status:"ok",solverDir:r,testsAppliedCommit:Ue.stdout.trim(),testPatchPaths:me}}function ch(e){try{let t=br(e,"utf-8").match(/<testsuites\b[^>]*>/i)?.[0];if(!t)return{totalTests:null,failedTests:null};let n=m=>Number.parseInt(t.match(new RegExp(`\\b${m}="(\\d+)"`,"i"))?.[1]??"",10),r=n("tests"),a=n("failures"),i=n("errors");return{totalTests:Number.isFinite(r)?r:null,failedTests:Number.isFinite(a)?a+(Number.isFinite(i)?i:0):null}}catch{return{totalTests:null,failedTests:null}}}async function zi(e){let{pi:t,index:n,workspace:r,status:a,durationMs:i,cancelSignal:m}=e,{solverDir:u,testsAppliedCommit:l,testPatchPaths:f}=r,h=he(u,"test_output.xml"),v=(pe="",Ke="cancelled")=>({index:n,status:"cancelled",passed:!1,diff:pe,testOutputTail:Ke,durationMs:i,totalTests:null,failedTests:null,testOutputXmlPath:h});if(m.aborted)return v();let E={cwd:u,timeout:ao,signal:m};if(await t.exec("git",["add","-A"],E),m.aborted)return v();let A=[...f,"agent_prompt.md"].map(pe=>`:(exclude)${pe}`),F=await t.exec("git",["diff","--cached",l,"--",".",...A],E),Y=F.code===0?F.stdout:"";if(m.aborted)return v(Y);let ae=`bash test.sh --output_path ${to(eo(h))} new`,me="",at=await mh({shellPath:xr()}).exec(ae,u,{signal:m,timeout:ao*10/1e3,onData:pe=>{me+=pe.toString()}});if(m.aborted)return v(Y,Ui(me.trim(),_i));let _=at.exitCode===0,ot=Ui(me.trim(),_i),{totalTests:it,failedTests:Ue}=ch(h);return{index:n,status:a,passed:_,diff:Y,testOutputTail:ot,durationMs:i,totalTests:it,failedTests:Ue,testOutputXmlPath:h}}function Bi(e){let{repoDir:t,runId:n,index:r,trajectory:a,solutionPatch:i,testOutputXmlPath:m,testOutputTail:u}=e,l=he(t,ph,n,`solver_${r}`);ro(l,{recursive:!0}),st(he(l,"trajectory.json"),JSON.stringify(a,null,2),"utf-8"),st(he(l,"solution.patch"),i,"utf-8");try{let f=br(m,"utf-8");st(he(l,"test_output.xml"),f,"utf-8")}catch{st(he(l,"test_output.txt"),u,"utf-8")}return l}function Vi(e,t){let n=he(e,kn);ro(n,{recursive:!0});let r=t.map(a=>{let i=he(n,`solver_${a.index}`);return ro(i,{recursive:!0}),st(he(i,"solution.diff"),a.diff,"utf-8"),st(he(i,"test_output.txt"),a.testOutputTail,"utf-8"),{index:a.index,status:a.status,passed:a.passed}});return st(he(n,"manifest.json"),JSON.stringify(r,null,2),"utf-8"),n}function Wi(e){let t=he(e,"node_modules");try{oh(t).isSymbolicLink()&&Ni(t,{force:!0})}catch{}try{Ni(e,{recursive:!0,force:!0})}catch{}}var p={};Rt(p,{Assign:()=>lh,Clone:()=>Rn,Create:()=>xg,Discard:()=>Ig,Metrics:()=>Ge,Update:()=>bg});var Ge={assign:0,create:0,clone:0,discard:0,update:0};function lh(e,t){return Ge.assign+=1,{...e,...t}}var s={};Rt(s,{Entries:()=>Mh,EntriesRegExp:()=>Ch,Every:()=>Oh,EveryAll:()=>Ph,GraphemeCount:()=>Eh,HasPropertyKey:()=>Ah,IsArray:()=>En,IsBigInt:()=>wn,IsBoolean:()=>ns,IsClassInstance:()=>kh,IsConstructor:()=>xh,IsDeepEqual:()=>mo,IsEqual:()=>M,IsFunction:()=>rs,IsGreaterEqualThan:()=>os,IsGreaterThan:()=>vh,IsInteger:()=>io,IsLessEqualThan:()=>as,IsLessThan:()=>Th,IsMaxLength:()=>Sh,IsMinLength:()=>Rh,IsMultipleOf:()=>$h,IsNull:()=>$r,IsNumber:()=>kr,IsObject:()=>Sn,IsObjectNotArray:()=>Ih,IsString:()=>wr,IsSymbol:()=>bh,IsUndefined:()=>so,IsUnsafePropertyKey:()=>is,IsValueLike:()=>wh,Keys:()=>Tr,ShiftLeft:()=>Er,Symbols:()=>Lh,Values:()=>qh});function Ot(e,t,n){return e>=t&&e<=n}function dh(e){return e===8205}function fh(e){return Ot(e,55296,56319)}function Hi(e){return Ot(e,127462,127487)}function Ji(e){return Ot(e,65024,65039)}function Xi(e){return Ot(e,768,879)||Ot(e,6832,6911)||Ot(e,7616,7679)||Ot(e,65056,65071)}function vr(e){return e>65535?2:1}function Yi(e,t){for(;t<e.length;){let n=e.codePointAt(t);if(Xi(n)||Ji(n))t+=vr(n);else break}return t}function oo(e,t){let n=e.codePointAt(t),r=t+vr(n);for(r=Yi(e,r);r<e.length-1&&e[r]==="\u200D";){let a=e.codePointAt(r+1);r+=1+vr(a),r=Yi(e,r)}return Hi(n)&&r<e.length&&Hi(e.codePointAt(r))&&(r+=vr(e.codePointAt(r))),r}function Zi(e){return fh(e)||Xi(e)||Ji(e)||dh(e)}function Qi(e){let t=0,n=0;for(;n<e.length;)n=oo(e,n),t++;return t}function hh(e,t){if(t===0)return!0;let n=0,r=0;for(;r<e.length;)if(r=oo(e,r),n++,n>=t)return!0;return!1}function gh(e,t){let n=0,r=0;for(;r<e.length;)if(r=oo(e,r),n++,n>t)return!1;return!0}function es(e,t){if(t===0)return!0;let n=0;for(;n<e.length;){if(Zi(e.charCodeAt(n)))return hh(e,t);if(n++,n>=t)return!0}return!1}function ts(e,t){let n=0;for(;n<e.length;){if(Zi(e.charCodeAt(n)))return gh(e,t);if(n++,n>t)return!1}return!0}function En(e){return Array.isArray(e)}function wn(e){return M(typeof e,"bigint")}function ns(e){return M(typeof e,"boolean")}function xh(e){if(so(e)||!rs(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function rs(e){return M(typeof e,"function")}function io(e){return Number.isInteger(e)}function $r(e){return M(e,null)}function kr(e){return Number.isFinite(e)}function Ih(e){return Sn(e)&&!En(e)}function Sn(e){return M(typeof e,"object")&&!$r(e)}function wr(e){return M(typeof e,"string")}function bh(e){return M(typeof e,"symbol")}function so(e){return M(e,void 0)}function M(e,t){return e===t}function vh(e,t){return e>t}function Th(e,t){return e<t}function as(e,t){return e<=t}function os(e,t){return e>=t}function $h(e,t){if(wn(e)||wn(t))return BigInt(e)%BigInt(t)===0n;let n=1e-10;if(!kr(e)||io(e)&&1/t%1===0)return!0;let r=e%t;return Math.min(Math.abs(r),Math.abs(r-t),Math.abs(r+t))<n}function kh(e){if(!Sn(e))return!1;let t=globalThis.Object.getPrototypeOf(e);return $r(t)?!1:M(typeof t.constructor,"function")&&!(M(t.constructor,globalThis.Object)||M(t.constructor.name,"Object"))}function wh(e){return wn(e)||ns(e)||$r(e)||kr(e)||wr(e)||so(e)}function Eh(e){return Qi(e)}function Sh(e,t){return ts(e,t)}function Rh(e,t){return es(e,t)}function Oh(e,t,n){for(let r=t;r<e.length;r++)if(!n(e[r],r))return!1;return!0}function Ph(e,t,n){let r=!0;for(let a=t;a<e.length;a++)n(e[a],a)||(r=!1);return r}function Er(e,t,n){return M(e.length,0)?n():t(e[0],e.slice(1))}function is(e){return M(e,"__proto__")||M(e,"constructor")||M(e,"prototype")}function Ah(e,t){return is(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function Ch(e){return Tr(e).map(t=>[new RegExp(`^${t}$`),e[t]])}function Mh(e){return Object.entries(e)}function Tr(e){return Object.getOwnPropertyNames(e)}function Lh(e){return Object.getOwnPropertySymbols(e)}function qh(e){return Object.values(e)}function jh(e,t){if(!Sn(t))return!1;let n=Tr(e);return M(n.length,Tr(t).length)&&n.every(r=>mo(e[r],t[r]))}function Fh(e,t){return En(t)&&M(e.length,t.length)&&e.every((n,r)=>mo(e[r],t[r]))}function mo(e,t){return En(e)?Fh(e,t):Sn(e)?jh(e,t):M(e,t)}var ht={};Rt(ht,{IsBigInt64Array:()=>Zh,IsBigUint64Array:()=>Qh,IsBoolean:()=>Gh,IsDate:()=>tg,IsFloat32Array:()=>Jh,IsFloat64Array:()=>Xh,IsInt16Array:()=>Vh,IsInt32Array:()=>Hh,IsInt8Array:()=>Kh,IsMap:()=>rg,IsNumber:()=>Nh,IsRegExp:()=>eg,IsSet:()=>ng,IsString:()=>_h,IsTypeArray:()=>Uh,IsUint16Array:()=>Wh,IsUint32Array:()=>Yh,IsUint8Array:()=>zh,IsUint8ClampedArray:()=>Bh});function Gh(e){return e instanceof Boolean}function Nh(e){return e instanceof Number}function _h(e){return e instanceof String}function Uh(e){return globalThis.ArrayBuffer.isView(e)}function Kh(e){return e instanceof globalThis.Int8Array}function zh(e){return e instanceof globalThis.Uint8Array}function Bh(e){return e instanceof globalThis.Uint8ClampedArray}function Vh(e){return e instanceof globalThis.Int16Array}function Wh(e){return e instanceof globalThis.Uint16Array}function Hh(e){return e instanceof globalThis.Int32Array}function Yh(e){return e instanceof globalThis.Uint32Array}function Jh(e){return e instanceof globalThis.Float32Array}function Xh(e){return e instanceof globalThis.Float64Array}function Zh(e){return e instanceof globalThis.BigInt64Array}function Qh(e){return e instanceof globalThis.BigUint64Array}function eg(e){return e instanceof globalThis.RegExp}function tg(e){return e instanceof globalThis.Date}function ng(e){return e instanceof globalThis.Set}function rg(e){return e instanceof globalThis.Map}function og(e){return s.HasPropertyKey(e,"~kind")||s.HasPropertyKey(e,"~unsafe")}function ig(e){let t={},n=Object.getOwnPropertyDescriptors(e);for(let r of Object.keys(n)){if(s.IsUnsafePropertyKey(r))continue;let a=n[r];s.HasPropertyKey(a,"value")&&Object.defineProperty(t,r,{...a,value:Pt(a.value)})}return t}function sg(e){let t={};for(let n of s.Keys(e))s.IsUnsafePropertyKey(n)||(t[n]=Pt(e[n]));for(let n of s.Symbols(e))t[n]=Pt(e[n]);return t}function mg(e){return s.IsClassInstance(e)?e:og(e)?ig(e):sg(e)}function pg(e){return e.map(t=>Pt(t))}function ug(e){return e.slice()}function cg(e){return new RegExp(e.source,e.flags)}function lg(e){return new Map(Pt([...e.entries()]))}function dg(e){return new Set(Pt([...e.values()]))}function Pt(e){return ht.IsTypeArray(e)?ug(e):ht.IsRegExp(e)?cg(e):ht.IsMap(e)?lg(e):ht.IsSet(e)?dg(e):s.IsArray(e)?pg(e):s.IsObject(e)?mg(e):e}function Rn(e){return Ge.clone+=1,Pt(e)}var At={};Rt(At,{Get:()=>gg,Reset:()=>fg,Set:()=>hg});var mt={immutableTypes:!1,maxErrors:8,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function fg(){mt.immutableTypes=!1,mt.maxErrors=8,mt.useAcceleration=!0,mt.exactOptionalPropertyTypes=!1,mt.enumerableKind=!1,mt.correctiveParse=!1,mt.unionPrioritySort=!0}function hg(e){for(let t of s.Keys(e)){let n=e[t];n!==void 0&&Object.defineProperty(mt,t,{value:n})}}function gg(){return mt}function yg(e,t){for(let n of Object.keys(t))Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:!1,value:t[n]});return e}function ss(e,t){return{...e,...t}}function xg(e,t,n={}){Ge.create+=1;let r=At.Get(),a=ss(t,n),i=r.enumerableKind?ss(a,e):yg(a,e);return r.immutableTypes?Object.freeze(i):i}function Ig(e,t){Ge.discard+=1;let n={},r=Object.getOwnPropertyDescriptors(Rn(e)),a=new Set(t);for(let i of Object.keys(r))a.has(i)||Object.defineProperty(n,i,r[i]);return n}function bg(e,t,n){Ge.update+=1;let r=At.Get(),a=Rn(e);for(let i of Object.keys(t))Object.defineProperty(a,i,{configurable:!0,writable:!0,enumerable:r.enumerableKind,value:t[i]});for(let i of Object.keys(n))Object.defineProperty(a,i,{configurable:!0,enumerable:!0,writable:!0,value:n[i]});return a}function y(e,t){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],t)}function ne(e){return s.IsObject(e)}function I(e,t,n){return p.Create({"~kind":"Deferred"},{type:"deferred",action:e,parameters:t,options:n},{})}function gt(e){return y(e,"Deferred")}function vg(e){return p.Update(e,{"~readonly":!0},{})}function On(e,t){return p.Update(vg(e),{},t)}function ms(e,t,n,r){let a=d(e,t,n);return On(a,r)}function Tg(e){return p.Update(e,{"~optional":!0},{})}function Pn(e,t){return p.Update(Tg(e),{},t)}function ps(e,t,n,r){let a=d(e,t,n);return Pn(a,r)}function Re(e,t){return p.Create({"~kind":"Array"},{type:"array",items:e},t)}function z(e){return y(e,"Array")}function Sr(e){return p.Discard(e,["~kind","type","items"])}function Be(e,t,n={}){return p.Create({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},n)}function oe(e){return y(e,"Constructor")}function us(e){return p.Discard(e,["~kind","type","parameters","instanceType"])}function Ve(e,t,n={}){return p.Create({"~kind":"Function"},{type:"function",parameters:e,returnType:t},n)}function ie(e){return y(e,"Function")}function cs(e){return p.Discard(e,["~kind","type","parameters","returnType"])}function pt(e,t){return p.Create({"~kind":"Ref"},{$ref:e},t)}function se(e){return y(e,"Ref")}function yt(e,t){return p.Create({"~kind":"Generic"},{type:"generic",parameters:e,expression:t})}function Jt(e){return y(e,"Generic")}function Xt(e){return p.Create({"~kind":"Any"},{},e)}function Z(e){return y(e,"Any")}var ls="(?!)";function D(e){return p.Create({"~kind":"Never"},{not:{}},e)}function xt(e){return y(e,"Never")}function We(e,t={}){return I("AddOptional",[e],t)}function Ct(e,t={}){return Pn(e,t)}function ds(e){return Ct(e)}function ge(e){return ne(e)&&s.HasPropertyKey(e,"~optional")}function fs(e){return s.Keys(e).filter(t=>!ge(e[t]))}function Rr(e){return s.Keys(e)}function Or(e){return s.Values(e)}function T(e,t={}){let n=fs(e),r=n.length>0?{required:n}:{};return p.Create({"~kind":"Object"},{type:"object",...r,properties:e},t)}function L(e){return y(e,"Object")}function hs(e){return p.Discard(e,["~kind","type","properties","required"])}function ue(e){return p.Create({"~kind":"Unknown"},{},e)}function re(e){return y(e,"Unknown")}function He(e,t,n){let r=s.Keys(e).reduce((a,i)=>({...a,[i]:p.Update(e[i],{},{$id:i})}),{});return p.Create({"~kind":"Cyclic"},{$defs:r,$ref:t},n)}function le(e){return y(e,"Cyclic")}function gs(e){return p.Update(e,{"~unsafe":null},{})}function Pr(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"~unsafe")&&s.IsNull(e["~unsafe"])}var Ye={};Rt(Ye,{Match:()=>$g});function $g(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}function An(...e){let[t,n]=Ye.Match(e,{2:(r,a)=>[r,a,a],1:r=>[r,ue(),ue()]});return p.Create({"~kind":"Infer"},{type:"infer",name:t,extends:n},{})}function J(e){return y(e,"Infer")}function Mt(e,t,n,r={}){return p.Create({"~kind":"Dependent"},{if:e,then:t,else:n},r)}function W(e){return y(e,"Dependent")}function ys(e){return p.Discard(e,["~kind","if","then","else"])}function xs(e){return s.IsObjectNotArray(e)}function Is(e){return s.Keys(e).filter(n=>isNaN(n)).reduce((n,r)=>[...n,e[r]],[])}function bs(e){return s.IsString(e)||s.IsNumber(e)}function vs(e,t){let n=xs(e)?Is(e):e;return p.Create({"~kind":"Enum"},{enum:n},t)}function xe(e){return y(e,"Enum")}function ye(e,t={}){return p.Create({"~kind":"Intersect"},{allOf:e},t)}function O(e){return y(e,"Intersect")}function Ts(e){return p.Discard(e,["~kind","allOf"])}function X(){throw new Error("Unreachable")}var $s;(function(e){e[e.Array=0]="Array",e[e.BigInt=1]="BigInt",e[e.Boolean=2]="Boolean",e[e.Date=3]="Date",e[e.Constructor=4]="Constructor",e[e.Function=5]="Function",e[e.Null=6]="Null",e[e.Number=7]="Number",e[e.Object=8]="Object",e[e.RegExp=9]="RegExp",e[e.String=10]="String",e[e.Symbol=11]="Symbol",e[e.TypeArray=12]="TypeArray",e[e.Undefined=13]="Undefined"})($s||($s={}));var wk=BigInt("14695981039346656037"),[Ek,Sk]=[BigInt("1099511628211"),BigInt("18446744073709551616")],Rk=Array.from({length:256}).map((e,t)=>BigInt(t)),ks=new Float64Array(1),Ok=new DataView(ks.buffer),Pk=new Uint8Array(ks.buffer);var Ak=new TextEncoder;var Cn=class{constructor(t,n){this.type=t,this.decode=n}Encode(t){let n=this.type,r=Ar(n)?m=>this.decode(n["~codec"].decode(m)):this.decode,a=Ar(n)?m=>n["~codec"].encode(t(m)):t,i={decode:r,encode:a};return p.Update(this.type,{"~codec":i},{})}},Mn=class{constructor(t){this.type=t}Decode(t){return new Cn(this.type,t)}};function Cr(e){return new Mn(e)}function Es(e,t){return Cr(e).Decode(t).Encode(()=>{throw Error("Encode not implemented")})}function Ss(e,t){return Cr(e).Decode(()=>{throw Error("Decode not implemented")}).Encode(t)}function Ar(e){return ne(e)&&s.HasPropertyKey(e,"~codec")&&s.IsObject(e["~codec"])&&s.HasPropertyKey(e["~codec"],"encode")&&s.HasPropertyKey(e["~codec"],"decode")}function Rs(e){return Zt(e)}function Lt(e){return ne(e)&&s.HasPropertyKey(e,"~immutable")}function Je(e,t={}){return I("AddReadonly",[e],t)}function qt(e,t={}){return On(e,t)}function Os(e){return qt(e)}function jt(e){return ne(e)&&s.HasPropertyKey(e,"~readonly")}function Sg(e,t){let n=po(e)?[...e["~refine"],t]:[t];return p.Update(e,{"~refine":n},{})}function Ps(...e){let[t,n,r]=Ye.Match(e,{3:(a,i,m)=>[a,i,m],2:(a,i)=>[a,i,()=>"Refine Error"]});return Sg(t,{check:n,error:r})}function Rg(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"check")&&s.HasPropertyKey(e,"error")&&s.IsFunction(e.check)&&s.IsFunction(e.error)}function po(e){return ne(e)&&s.HasPropertyKey(e,"~refine")&&s.IsArray(e["~refine"])&&s.Every(e["~refine"],0,t=>Rg(t))}var As="-?(?:0|[1-9][0-9]*)n";function Ln(e){return p.Create({"~kind":"BigInt"},{type:"bigint"},e)}function Xe(e){return y(e,"BigInt")}function Mr(e){return p.Create({"~kind":"Boolean"},{type:"boolean"},e)}function Ce(e){return y(e,"Boolean")}function qn(e){return p.Create({"~kind":"Identifier"},{name:e})}function Cs(e){return y(e,"Identifier")}var Lr="-?(?:0|[1-9][0-9]*)";function Ft(e){return p.Create({"~kind":"Integer"},{type:"integer"},e)}function Ie(e){return y(e,"Integer")}var uo=class extends Error{constructor(t){super("Invalid Literal value"),Object.defineProperty(this,"cause",{value:{value:t},writable:!1,configurable:!1,enumerable:!1})}};function Og(e){return s.IsBigInt(e)?"bigint":s.IsBoolean(e)?"boolean":s.IsNumber(e)?"number":s.IsString(e)?"string":(()=>{throw new uo(e)})()}function P(e,t){return p.Create({"~kind":"Literal"},{type:Og(e),const:e},t)}function qr(e){return s.IsBigInt(e)||s.IsBoolean(e)||s.IsNumber(e)||s.IsString(e)}function Ms(e){return q(e)&&s.IsNumber(e.const)}function Ls(e){return q(e)&&s.IsString(e.const)}function q(e){return y(e,"Literal")}function Qt(e){return p.Create({"~kind":"Null"},{type:"null"},e)}function en(e){return y(e,"Null")}var jr="-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";function we(e){return p.Create({"~kind":"Number"},{type:"number"},e)}function Q(e){return y(e,"Number")}function tn(e){return p.Create({"~kind":"Symbol"},{type:"symbol"},e)}function It(e){return y(e,"Symbol")}function Dt(...e){let[t,n,r]=Ye.Match(e,{3:(a,i,m)=>[a,i,m],2:(a,i)=>[a,i,i],1:a=>[a,ue(),ue()]});return p.Create({"~kind":"Parameter"},{name:t,extends:n,equals:r},{})}function qs(e){return y(e,"Parameter")}var Fr=".*";function Me(e){return p.Create({"~kind":"String"},{type:"string"},e)}function be(e){return y(e,"String")}function w(e,t={}){return p.Create({"~kind":"Union"},{anyOf:e},t)}function x(e){return y(e,"Union")}function js(e){return p.Discard(e,["~kind","anyOf"])}function jn(e){let t=Fs(e);return s.IsEqual(t.length,2)?t[0]:[]}function Pg(e){return!0}function Ds(e){return s.ShiftLeft(e,(t,n)=>Ag(t)?Ds(n):!1,()=>!0)}function Gs(e){return s.IsEqual(e.length,0)?!1:Ds(e)}function Ag(e){return x(e)?Gs(e.anyOf):q(e)?Pg(e.const):!1}function Dr(e){return Gs(e)}function Gr(e){return p.Create({"~kind":"TemplateLiteral"},{type:"string",pattern:e},{})}function Ns(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>Ns(a,t,[...n,`${r}${t}`]),()=>n)}function Cg(e,t){return s.IsEqual(e.length,0)?[`${t}`]:Ns(e,t)}function _s(e,t,n=[]){return s.ShiftLeft(t,(r,a)=>_s(e,a,[...n,...Us(e,r)]),()=>n)}function Us(e,t){return x(t)?_s(e,t.anyOf):q(t)?Cg(e,t.const):X()}function Ks(e,t){return s.ShiftLeft(t,(n,r)=>Ks(Us(e,n),r),()=>e)}function Mg(e){return e.map(t=>P(t))}function Lg(e){let t=Ks([],e),n=Mg(t);return w(n)}function qg(e){return s.IsEqual(e.length,0)?X():s.IsEqual(e.length,1)&&q(e[0])?e[0]:Lg(e)}function co(e){let t=jn(e);return s.IsEqual(t.length,0)?Me():Dr(t)?qg(t):Gr(e)}function zs(e){let t=co(e);return ee(t)?Me():t}function $e(e,t){let n="object",r={[e]:t};return p.Create({"~kind":"Record"},{type:n,patternProperties:r})}function Bs(e){return $e(Ne,e)}function Vs(e){return T({true:e,false:e})}function te(e,t={}){let[n,r,a]=[e,e.length,!1];return p.Create({"~kind":"Tuple"},{type:"array",additionalItems:a,items:n,minItems:r},t)}function N(e){return y(e,"Tuple")}function Ws(e){return p.Discard(e,["~kind","type","items","minItems","additionalItems"])}function jg(e){return p.Discard(e,["~readonly"])}function lo(e,t){return p.Update(jg(e),{},t)}function Hs(e,t,n,r){let a=d(e,t,n);return lo(a,r)}function Ys(e,t={}){return I("RemoveReadonly",[e],t)}function Js(e,t={}){return lo(e,t)}function Fg(e){return p.Discard(e,["~optional"])}function fo(e,t){return p.Update(Fg(e),{},t)}function Xs(e,t,n,r){let a=d(e,t,n);return fo(a,r)}function Zs(e,t={}){return I("RemoveOptional",[e],t)}function Nr(e,t={}){return fo(e,t)}function ho(e){return e.reduceRight((n,r,a)=>({[a]:r,...n}),{})}function Qs(e){let t=ho(e.items);return T(t)}function Dg(e,t){return jt(e)?!!jt(t):!1}function Gg(e,t){return ge(e)?!!ge(t):!1}function Ng(e,t){let n=Dg(e,t),r=Gg(e,t),a=B([e,t]),i=Js(Nr(a));return n&&r?qt(Ct(i)):n&&!r?qt(i):!n&&r?Ct(i):i}function _g(e,t,n){return n in e?n in t?Ng(e[n],t[n]):e[n]:n in t?t[n]:D()}function Ug(e,t){return[...new Set([...s.Keys(t),...s.Keys(e)])].reduce((r,a)=>({...r,[a]:_g(e,t,a)}),{})}function em(e){return L(e)?e.properties:N(e)?ho(e.items):X()}function tm(e,t){let n=em(e),r=em(t),a=Ug(n,r);return T(a)}function nm(e,t){let n=nn(e,t);return s.IsEqual(n,Dn)?e:s.IsEqual(n,Gn)||s.IsEqual(n,Fn)?t:D()}function rm(e){return L(e)||N(e)}function Kg(e,t){let n=x(e),r=x(t);return n||r}function zg(e,t){let n=Le(e),r=Le(t),a=Kg(n,r),i=rm(n),m=rm(r);return a?B([n,r]):i&&m?tm(n,r):i&&!m?n:!i&&m?r:nm(n,r)}function am(e,t,n=[]){return s.ShiftLeft(t,(r,a)=>am(e,a,[...n,zg(e,r)]),()=>s.IsEqual(n.length,0)?[e]:n)}function om(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>om(a,t,[...n,...Nn([r],t)]),()=>n)}function Nn(e,t=[]){return s.ShiftLeft(e,(n,r)=>x(n)?Nn(r,om(n.anyOf,t)):Nn(r,am(n,t)),()=>t)}function Bg(e,t){let n=de({},e,t);return b.IsExtendsTrueLike(n)?[]:[e]}function Vg(e,t){return e.reduce((n,r)=>[...n,...Bg(r,t)],[])}function _r(e,t){let n=Le(e),r=x(n)?n.anyOf:[n],a=Vg(r,t);return Ee(a)}function _e(e,t,n){let r=ye([e,t]),a=_r(n,e);return Ee([r,a])}function Oe(e){let t=e.map(n=>P(n));return Ee(t)}function B(e){let t=Nn(e),n=go(t);return ut(n)}function ke(e){let t=zs(e);return Le(t)}function Ee(e){let t=go(e);return ut(t)}function Le(e){return W(e)?_e(e.if,e.then,e.else):xe(e)?Oe(e.enum):O(e)?B(e.allOf):ee(e)?ke(e.pattern):x(e)?Ee(e.anyOf):e}function ut(e){return s.IsEqual(e.length,1)?e[0]:s.IsEqual(e.length,0)?D():w(e)}function im(e,t){let n=Oe(e);return bt(n,t)}function sm(e,t){return $e(vt,t)}function mm(e,t){let n=B(e);return bt(n,t)}function pm(e,t){return s.IsString(e)||s.IsNumber(e)?T({[e]:t}):s.IsEqual(e,!1)?T({false:t}):s.IsEqual(e,!0)?T({true:t}):T({})}function um(e,t){return $e(rn,t)}function cm(e,t){return s.HasPropertyKey(e,"pattern")&&(s.IsString(e.pattern)||e.pattern instanceof RegExp)?$e(e.pattern.toString(),t):$e(Ne,t)}function lm(e,t){let n=jn(e);return Dr(n)?bt(ke(e),t):$e(e,t)}function Wg(e){return x(e)?_n(e.anyOf):[e]}function _n(e){return e.reduce((t,n)=>[...t,...Wg(n)],[])}function Hg(e){return e.some(t=>be(t)||Q(t)||Ie(t))}function Yg(e,t){return s.IsEqual(Hg(e),!0)?$e(Ne,t):void 0}function Jg(e,t){return e.reduce((n,r)=>q(r)&&(s.IsString(r.const)||s.IsNumber(r.const))?{...n,[r.const]:t}:n,{})}function Xg(e,t){let n=Jg(e,t);return T(n)}function dm(e,t){let n=_n(e),r=Yg(n,t);return ne(r)?r:Xg(n,t)}function bt(e,t){return Z(e)?Bs(t):Ce(e)?Vs(t):xe(e)?im(e.enum,t):Ie(e)?sm(e,t):O(e)?mm(e.allOf,t):q(e)?pm(e.const,t):Q(e)?um(e,t):x(e)?dm(e.anyOf,t):be(e)?cm(e,t):ee(e)?lm(e.pattern,t):T({})}function yo(e,t,n){return k([e])?p.Update(bt(e,t),{},n):Ur(e,t,n)}function fm(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return yo(i,m,a)}var vt=`^${Lr}$`,rn=`^${jr}$`,Ne=`^${Fr}$`;function Ur(e,t,n={}){return I("Record",[e,t],n)}function Kr(e,t,n={}){return yo(e,t,n)}function hm(e,t){return $e(e,t)}function zr(e){return s.IsEqual(e,Ne)?Me():s.IsEqual(e,vt)?Ft():s.IsEqual(e,rn)?we():co(e)}function qe(e){return s.Keys(e.patternProperties)[0]}function an(e){let t=qe(e);return zr(t)}function ve(e){return e.patternProperties[qe(e)]}function fe(e){return y(e,"Record")}function Gt(e){return p.Create({"~kind":"Rest"},{type:"rest",items:e},{})}function Tt(e){return y(e,"Rest")}function Br(e){return p.Create({"~kind":"This"},{$ref:"#"},e)}function Vr(e){return y(e,"This")}function on(e){return p.Create({"~kind":"Undefined"},{type:"undefined"},e)}function sn(e){return y(e,"Undefined")}function Wr(e){return p.Create({"~kind":"Void"},{type:"void"},e)}function Ze(e){return y(e,"Void")}function Qg(e,t){return s.IsEqual(e,"Array")?Re(t[0]):s.IsEqual(e,"Capitalize")?Yr(t[0]):s.IsEqual(e,"ConstructorParameters")?ea(t[0]):s.IsEqual(e,"Evaluate")?yu(t[0]):s.IsEqual(e,"Exclude")?ta(t[0],t[1]):s.IsEqual(e,"Extract")?na(t[0],t[1]):s.IsEqual(e,"Index")?Bn(t[0],t[1]):s.IsEqual(e,"InstanceType")?ra(t[0]):s.IsEqual(e,"Lowercase")?Jr(t[0]):s.IsEqual(e,"NonNullable")?aa(t[0]):s.IsEqual(e,"Omit")?oa(t[0],t[1]):s.IsEqual(e,"Parameters")?ia(t[0]):s.IsEqual(e,"Partial")?sa(t[0]):s.IsEqual(e,"Pick")?ma(t[0],t[1]):s.IsEqual(e,"Readonly")?pa(t[0]):s.IsEqual(e,"KeyOf")?Vn(t[0]):s.IsEqual(e,"Record")?Ur(t[0],t[1]):s.IsEqual(e,"Required")?ua(t[0]):s.IsEqual(e,"ReturnType")?ca(t[0]):s.IsEqual(e,"Uncapitalize")?Xr(t[0]):s.IsEqual(e,"Uppercase")?Zr(t[0]):zn(pt(e),t)}function Nt(){throw Error("Unreachable")}var ey=(e,t=[])=>e.reduce((n,r)=>s.IsArray(r)&&s.IsEqual(r.length,2)?[...n,r[0]]:[...n,r],[]),ct=e=>{let[t,n]=e;return ey([...t,...n])};function bm(e){return Dt(e[0],e[2],e[4])}function vm(e){return Dt(e[0],e[2],e[2])}function Tm(e){return Dt(e[0],ue(),e[2])}function $m(e){return Dt(e,ue(),ue())}function km(e){return ct(e)}function wm(e){return e[1]}function Em(e){return ct(e)}function Sm(e){return e[1]}function Rm(e){return Qg(e[0],e[1])}function Om(e){return null}function Pm(e){return Me()}function Am(e){return we()}function Cm(e){return Mr()}function Mm(e){return on()}function Lm(e){return Qt()}function qm(e){return Ft()}function jm(e){return Ln()}function Fm(e){return ue()}function Dm(e){return Xt()}function Gm(e){return T({})}function Nm(e){return D()}function _m(e){return tn()}function Um(e){return Wr()}function Km(e){return Br()}function zm(e){return P(BigInt(e))}function Bm(e){return P(s.IsEqual(e,"true"))}function Vm(e){return P(parseFloat(e))}function Wm(e){return P(e)}function Hm(e){return e[1]}function Ym(e){return P(e)}function Jm(e){return s.IsEqual(e.length,3)?[e[0],e[1],...e[2]]:[e[0]]}function Xm(e){return e[1]}function Zm(e){return Hr(e)}function Qm(e){return s.IsEqual(e.length,6)?Mt(e[1],e[3],e[5]):Mt(e[1],e[3],ue())}function ep(e){return e.length>0}function tp(e){return e.reduce((t,n)=>s.IsEqual(n.length,3)?[...t,[n[1]]]:[...t,[]],[])}function np(e){return s.IsEqual(e.length,6)?[e[1],e[3],e[5]]:[]}function rp(e){return s.IsArray(e)&&s.IsEqual(e.length,3)?e[1]:e}function ap(e){return s.IsEqual(e.length,2)?e[1]:[]}function gm(e,t){return t.reduce((n,r)=>{let a=r;return s.IsEqual(a.length,1)?Bn(n,a[0]):s.IsEqual(a.length,0)?Re(n):Nt()},e)}function ym(e,t){return s.IsEqual(t.length,3)?Qr(e,t[0],t[1],t[2]):e}function ty(e,t){return s.IsArray(t)&&s.IsEqual(t.length,0)?e:la(e,t)}function op(e){let[t,n,r,a,i]=e;return ty(ym(t?Vn(gm(n,r)):gm(n,r),a),i)}function xo(e,t){return s.IsEqual(t.length,3)?(()=>{let[n,r,a]=t,i=xo(r,a);if(s.IsEqual(n,"&"))return O(i)?ye([e,...i.allOf]):ye([e,i]);if(s.IsEqual(n,"|"))return x(i)?w([e,...i.anyOf]):w([e,i]);Nt()})():e}function ip(e){let[t,n]=e;return xo(t,n)}function sp(e){let[t,n]=e;return xo(t,n)}function mp(e){return gu(e[1])}function pp(e){return e[1]}function up(e){return yt(e[0],e[2])}function cp(e){return s.IsEqual(e.length,4)?An(e[1],e[3]):s.IsEqual(e.length,2)?An(e[1],ue()):Nt()}function lp(e){return`${e}`}function dp(e){return Ie(e[3])?vt:Q(e[3])?rn:It(e[3])?Ne:be(e[3])?Ne:Nt()}function fp(e){return e.length>0}function hp(e){return e.length>0}function gp(e){let[t,n,r,a,i]=e;return{[n]:t&&r?Je(We(i)):t&&!r?Je(i):!t&&r?We(i):i}}function yp(e){return ct(e)}function xp(e){return e.reduce((t,n)=>s.HasPropertyKey(n,vt)||s.HasPropertyKey(n,rn)||s.HasPropertyKey(n,Ne)?[t[0],p.Assign(t[1],n)]:[p.Assign(t[0],n),t[1]],[{},{}])}function Ip(e){return xp(e[1])}function bp(e){let[t,n]=e,r=s.IsEqual(s.Keys(n).length,0)?{}:{patternProperties:n};return T(t,r)}function vp(e){return s.IsEqual(e.length,5)?Je(We(e[4])):s.IsEqual(e.length,3)?e[2]:s.IsEqual(e.length,4)?s.IsEqual(e[2],"readonly")?Je(e[3]):We(e[3]):Nt()}function Tp(e){return Je(We(e[1]))}function $p(e){return Je(e[1])}function kp(e){return We(e[0])}function wp(e){return s.IsEqual(e.length,2)?Gt(e[1]):s.IsEqual(e.length,1)?e[0]:Nt()}function Ep(e){return ct(e)}function Sp(e){return te(e[1])}function Rp(e){return Je(We(e[4]))}function Op(e){return Je(e[3])}function Pp(e){return We(e[3])}function Ap(e){return e[2]}function Cp(e){return s.IsEqual(e.length,2)?Gt(e[1]):s.IsEqual(e.length,1)?e[0]:Nt()}function Mp(e){return ct(e)}function Lp(e){return Ve(e[1],e[4])}function qp(e){return Be(e[2],e[5])}function xm(e,t){return s.IsEqual(e,"remove")?Ys(t):s.IsEqual(e,"add")?Je(t):t}function jp(e){return s.IsEqual(e.length,2)&&s.IsEqual(e[0],"-")?"remove":s.IsEqual(e.length,2)&&s.IsEqual(e[0],"+")||s.IsEqual(e.length,1)?"add":"none"}function Im(e,t){return s.IsEqual(e,"remove")?Zs(t):s.IsEqual(e,"add")?We(t):t}function Fp(e){return s.IsEqual(e.length,2)&&s.IsEqual(e[0],"-")?"remove":s.IsEqual(e.length,2)&&s.IsEqual(e[0],"+")||s.IsEqual(e.length,1)?"add":"none"}function Dp(e){return s.IsEqual(e.length,2)?[e[1]]:[]}function Gp(e){return s.IsArray(e[6])&&s.IsEqual(e[6].length,1)?Un(qn(e[3]),e[5],e[6][0],xm(e[1],Im(e[8],e[10]))):Un(qn(e[3]),e[5],pt(e[3]),xm(e[1],Im(e[8],e[10])))}function Np(e){return pt(e)}function _p(e){return BigInt(e)}function Up(e){return parseFloat(e)}function Kp(e){return s.IsEqual(e,"true")}function zp(e){return null}function Bp(e){return{[e[0]]:e[2]}}function Vp(e){return ct(e)}function ny(e){return e.reduce((t,n)=>p.Assign(t,n),{})}function Wp(e){return ny(e[1])}function Hp(e){return ct(e)}function Yp(e){return e[1]}function Jp(e){return Ln()}function Xp(e){return Me()}function Zp(e){return we()}function Qp(e){return Ft()}function eu(e){return D()}function tu(e){return P(e)}function nu(e){return w(e[1])}function ru(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function au(e){return[e[0],...e[1]]}function ou(e){return e[1]}function iu(e){return ct(e)}function su(e){return s.IsEqual(e.length,2)?e[1]:[]}function mu(e){let t=e[2],n=e[3],[r,a]=e[4],i=s.IsEqual(s.Keys(a).length,0)?{}:{patternProperties:a};return{[e[1]]:yt(t,Kn(n,r,i))}}function pu(e){let t=e[2],[n,r]=e[3],a=s.IsEqual(s.Keys(r).length,0)?{}:{patternProperties:r};return{[e[1]]:Kn(t,n,a)}}function uu(e){return{[e[1]]:yt(e[2],e[4])}}function cu(e){return{[e[1]]:e[3]}}function lu(e){return null}function du(e){return xp(ct(e))}function fu(e){return e[1]}function hu(e){let t=e[0],n=e[1];return xu(p.Assign(t,n[0]))}function Wn(e){return M(e.length,2)}function S(e,t,n){return Wn(e)?t(e[0],e[1]):n()}function oy(e,t){return M(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function V(e,t){for(let n=0;n<e.length;n++){let r=oy(e[n],t);if(Wn(r))return r}return[]}function Io(e,t){return Array.from({length:t-e+1},(n,r)=>String.fromCharCode(e+r))}var Iu=[...Io(97,122),...Io(65,90)],bo="0",vo=Io(49,57),mn=[bo,...vo],bu=" ",pn=`
5
- `;var $t="_",da=".",vu="$",fa="-";var Tu="//",$u="/*",sy="*/";function ku(e){let t=e.indexOf(sy);return M(t,-1)?"":e.slice(t+2)}function wu(e){let t=e.indexOf(pn);return M(t,-1)?"":e.slice(t)}function my(e){return e.replace(/^[ \t\r\f\v]+/,"")}function ha(e){let t=my(e);return t.startsWith($u)?ha(ku(t.slice(2))):t.startsWith(Tu)?ha(wu(t.slice(2))):t}function ce(e){let t=e.trimStart();return t.startsWith($u)?ce(ku(t.slice(2))):t.startsWith(Tu)?ce(wu(t.slice(2))):t}function ga(e,t){return S(V([e],t),(n,r)=>[n,r],()=>["",t])}function py(e,t){return e.includes(t)}function un(e,t,n,r=""){return S(V(e,n),(a,i)=>py(t,a)?un(e,t,i,r):un(e,t,i,`${r}${a}`),()=>[r,n])}function uy(e){return V(vo,e)}var cy=[...mn,$t];function ly(e){return un(cy,[$t],e)}function dy(e){return S(V([bo],e),(t,n)=>[t,n],()=>S(uy(e),(t,n)=>S(ly(n),(r,a)=>[`${t}${r}`,a],()=>[]),()=>[]))}function ya(e){return dy(ce(e))}function fy(e){return ga(fa,e)}function hy(e){return S(fy(e),(t,n)=>S(ya(n),(r,a)=>[`${t}${r}`,a],()=>[]),()=>[])}function Eu(e){return hy(ce(e))}function gy(e){return S(Eu(e),(t,n)=>S(V(["n"],n),(r,a)=>[`${t}`,a],()=>[]),()=>[])}function To(e){return gy(e)}function $o(e,t){return V([e],t)}function c(e,t){return M(e,"")?["",t]:e.startsWith(pn)?$o(e,ha(t)):e.startsWith(bu)?$o(e,t):$o(e,ce(t))}var Su=[...Iu,$t,vu];function yy(e){return V(Su,e)}var xy=[...Su,...mn];function Ru(e,t=""){return S(V(xy,e),(n,r)=>Ru(r,`${t}${n}`),()=>[t,e])}function Iy(e){return S(yy(e),(t,n)=>S(Ru(n),(r,a)=>[`${t}${r}`,a],()=>[]),()=>[])}function H(e){return Iy(ce(e))}var by=[...mn,$t];function vy(e){return Wn(V([da],e))}function Ou(e){return S(un(by,[$t],e),(t,n)=>M(t,"")?[]:[t,n],()=>[])}function Ty(e){return S(V([da],e),(t,n)=>S(Ou(n),(r,a)=>[`0${t}${r}`,a],()=>[]),()=>[])}function $y(e){return S(ya(e),(t,n)=>S(V([da],n),(r,a)=>S(Ou(a),(i,m)=>[`${t}${r}${i}`,m],()=>[`${t}`,a]),()=>[`${t}`,n]),()=>[])}function ky(e){return vy(e)?Ty(e):$y(e)}function Pu(e){return ky(ce(e))}function wy(e){return ga(fa,e)}function Ey(e){return S(wy(e),(t,n)=>S(Pu(n),(r,a)=>[`${t}${r}`,a],()=>[]),()=>[])}function xa(e){return Ey(ce(e))}function Sy(e){return M(e,"")?[]:[e.slice(0,1),e.slice(1)]}function Au(e,t){return Er(e,(n,r)=>t.startsWith(n)?!0:Au(r,t),()=>!1)}function kt(e,t,n=""){return S(Sy(t),(r,a)=>Au(e,t)?[n,t]:kt(e,a,`${n}${r}`),()=>[])}function Ry(e,t,n){return S(V([e],n),(r,a)=>S(kt([t],a),(i,m)=>S(V([t],m),(u,l)=>[`${i}`,l],()=>[]),()=>[]),()=>[])}function Oy(e,t,n){return S(V([e],n),(r,a)=>S(kt([pn,t],a),(i,m)=>S(V([t],m),(u,l)=>[`${i}`,l],()=>[]),()=>[]),()=>[])}function Cu(e,t,n,r){return n?Ry(e,t,ce(r)):Oy(e,t,ce(r))}function Py(e,t){return V(e,t)}function Ay(e,t){return Cu(e,e,!1,t)}function Cy(e,t){return S(Py(e,t),(n,r)=>Ay(n,`${n}${r}`),()=>[])}function Ia(e,t){return Cy(e,ce(t))}function Mu(e,t){return S(kt(e,t),(n,r)=>M(n,"")?[]:[n,r],()=>[])}var o=(e,t,n=()=>[])=>e.length===2?t(e):n(),Ly=e=>o(o(H(e),([t,n])=>o(c("extends",n),([r,a])=>o(R(a),([i,m])=>o(c("=",m),([u,l])=>o(R(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[bm(t),n]),qy=e=>o(o(H(e),([t,n])=>o(c("extends",n),([r,a])=>o(R(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[vm(t),n]),jy=e=>o(o(H(e),([t,n])=>o(c("=",n),([r,a])=>o(R(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Tm(t),n]),Fy=e=>o(H(e),([t,n])=>[$m(t),n]),ju=e=>o(o(Ly(e),([t,n])=>[t,n],()=>o(qy(e),([t,n])=>[t,n],()=>o(jy(e),([t,n])=>[t,n],()=>o(Fy(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),Fu=(e,t=[])=>o(o(ju(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>Fu(r,[...t,n]),()=>[t,e]),Dy=e=>o(o(Fu(e),([t,n])=>o(o(o(ju(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[km(t),n]),Eo=e=>o(o(c("<",e),([t,n])=>o(Dy(n),([r,a])=>o(c(">",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[wm(t),n]),Du=(e,t=[])=>o(o(R(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>Du(r,[...t,n]),()=>[t,e]),Gy=e=>o(o(Du(e),([t,n])=>o(o(o(R(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[Em(t),n]),Ny=e=>o(o(c("<",e),([t,n])=>o(Gy(n),([r,a])=>o(c(">",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Sm(t),n]),_y=e=>o(o(H(e),([t,n])=>o(Ny(n),([r,a])=>[[t,r],a])),([t,n])=>[Rm(t),n]),Gu=e=>o(o(o(c(";",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[Om(t),n]),Nu=e=>o(c("string",e),([t,n])=>[Pm(t),n]),_u=e=>o(c("number",e),([t,n])=>[Am(t),n]),Uy=e=>o(c("boolean",e),([t,n])=>[Cm(t),n]),Ky=e=>o(c("undefined",e),([t,n])=>[Mm(t),n]),zy=e=>o(c("null",e),([t,n])=>[Lm(t),n]),Uu=e=>o(c("integer",e),([t,n])=>[qm(t),n]),By=e=>o(c("bigint",e),([t,n])=>[jm(t),n]),Vy=e=>o(c("unknown",e),([t,n])=>[Fm(t),n]),Wy=e=>o(c("any",e),([t,n])=>[Dm(t),n]),Hy=e=>o(c("object",e),([t,n])=>[Gm(t),n]),Yy=e=>o(c("never",e),([t,n])=>[Nm(t),n]),Ku=e=>o(c("symbol",e),([t,n])=>[_m(t),n]),Jy=e=>o(c("void",e),([t,n])=>[Um(t),n]),Xy=e=>o(c("this",e),([t,n])=>[Km(t),n]),Zy=e=>o(o(c("${",e),([t,n])=>o(R(n),([r,a])=>o(c("}",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Hm(t),n]),ko=e=>o(kt(["${","`"],e),([t,n])=>[Ym(t),n]),zu=e=>o(o(o(ko(e),([t,n])=>o(Zy(n),([r,a])=>o(zu(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o(o(ko(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o(o(ko(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))),([t,n])=>[Jm(t),n]),So=e=>o(o(c("`",e),([t,n])=>o(zu(n),([r,a])=>o(c("`",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Xm(t),n]),Qy=e=>o(So(e),([t,n])=>[Zm(t),n]),ex=e=>o(o(o(c("if",e),([t,n])=>o(R(n),([r,a])=>o(c("then",a),([i,m])=>o(R(m),([u,l])=>o(c("else",l),([f,h])=>o(R(h),([v,E])=>[[t,r,i,u,f,v],E])))))),([t,n])=>[t,n],()=>o(o(c("if",e),([t,n])=>o(R(n),([r,a])=>o(c("then",a),([i,m])=>o(R(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[t,n],()=>[])),([t,n])=>[Qm(t),n]),tx=e=>o(To(e),([t,n])=>[zm(t),n]),nx=e=>o(o(c("true",e),([t,n])=>[t,n],()=>o(c("false",e),([t,n])=>[t,n],()=>[])),([t,n])=>[Bm(t),n]),rx=e=>o(xa(e),([t,n])=>[Vm(t),n]),ax=e=>o(Ia(["'",'"'],e),([t,n])=>[Wm(t),n]),ox=e=>o(o(o(c("keyof",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[ep(t),n]),Bu=(e,t=[])=>o(o(o(c("[",e),([n,r])=>o(R(r),([a,i])=>o(c("]",i),([m,u])=>[[n,a,m],u]))),([n,r])=>[n,r],()=>o(o(c("[",e),([n,r])=>o(c("]",r),([a,i])=>[[n,a],i])),([n,r])=>[n,r],()=>[])),([n,r])=>Bu(r,[...t,n]),()=>[t,e]),ix=e=>o(Bu(e),([t,n])=>[tp(t),n]),sx=e=>o(o(o(c("extends",e),([t,n])=>o(R(n),([r,a])=>o(c("?",a),([i,m])=>o(R(m),([u,l])=>o(c(":",l),([f,h])=>o(R(h),([v,E])=>[[t,r,i,u,f,v],E])))))),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[np(t),n]),mx=e=>o(o(o(c("(",e),([t,n])=>o(R(n),([r,a])=>o(c(")",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o(Nu(e),([t,n])=>[t,n],()=>o(_u(e),([t,n])=>[t,n],()=>o(Uy(e),([t,n])=>[t,n],()=>o(Ky(e),([t,n])=>[t,n],()=>o(zy(e),([t,n])=>[t,n],()=>o(Uu(e),([t,n])=>[t,n],()=>o(By(e),([t,n])=>[t,n],()=>o(Vy(e),([t,n])=>[t,n],()=>o(Wy(e),([t,n])=>[t,n],()=>o(Hy(e),([t,n])=>[t,n],()=>o(Yy(e),([t,n])=>[t,n],()=>o(Ku(e),([t,n])=>[t,n],()=>o(Jy(e),([t,n])=>[t,n],()=>o(Xy(e),([t,n])=>[t,n],()=>o(tx(e),([t,n])=>[t,n],()=>o(nx(e),([t,n])=>[t,n],()=>o(rx(e),([t,n])=>[t,n],()=>o(ax(e),([t,n])=>[t,n],()=>o(Qy(e),([t,n])=>[t,n],()=>o(ex(e),([t,n])=>[t,n],()=>o(vx(e),([t,n])=>[t,n],()=>o(Sx(e),([t,n])=>[t,n],()=>o(Mx(e),([t,n])=>[t,n],()=>o(Cx(e),([t,n])=>[t,n],()=>o(Fx(e),([t,n])=>[t,n],()=>o(_y(e),([t,n])=>[t,n],()=>o(Dx(e),([t,n])=>[t,n],()=>[])))))))))))))))))))))))))))),([t,n])=>[rp(t),n]),px=e=>o(o(o(c("with",e),([t,n])=>o(sc(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[ap(t),n]),Vu=e=>o(o(ox(e),([t,n])=>o(mx(n),([r,a])=>o(ix(a),([i,m])=>o(sx(m),([u,l])=>o(px(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[op(t),n]),Wu=e=>o(o(o(c("&",e),([t,n])=>o(Vu(n),([r,a])=>o(Wu(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[t,n]),Hu=e=>o(o(Vu(e),([t,n])=>o(Wu(n),([r,a])=>[[t,r],a])),([t,n])=>[ip(t),n]),Yu=e=>o(o(o(c("|",e),([t,n])=>o(Hu(n),([r,a])=>o(Yu(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[t,n]),ba=e=>o(o(Hu(e),([t,n])=>o(Yu(n),([r,a])=>[[t,r],a])),([t,n])=>[sp(t),n]),ux=e=>o(o(c("readonly",e),([t,n])=>o(ba(n),([r,a])=>[[t,r],a])),([t,n])=>[mp(t),n]),cx=e=>o(o(c("|",e),([t,n])=>o(ba(n),([r,a])=>[[t,r],a])),([t,n])=>[pp(t),n]),lx=e=>o(o(Eo(e),([t,n])=>o(c("=",n),([r,a])=>o(R(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[up(t),n]),dx=e=>o(o(o(c("infer",e),([t,n])=>o(H(n),([r,a])=>o(c("extends",a),([i,m])=>o(ba(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[t,n],()=>o(o(c("infer",e),([t,n])=>o(H(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>[])),([t,n])=>[cp(t),n]),R=e=>o(o(dx(e),([t,n])=>[t,n],()=>o(cx(e),([t,n])=>[t,n],()=>o(ux(e),([t,n])=>[t,n],()=>o(ba(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),fx=e=>o(xa(e),([t,n])=>[lp(t),n]),hx=e=>o(H(e),([t,n])=>[t,n]),gx=e=>o(Ia(["'",'"'],e),([t,n])=>[t,n]),yx=e=>o(o(c("[",e),([t,n])=>o(H(n),([r,a])=>o(c(":",a),([i,m])=>o(o(Uu(m),([u,l])=>[u,l],()=>o(_u(m),([u,l])=>[u,l],()=>o(Nu(m),([u,l])=>[u,l],()=>o(Ku(m),([u,l])=>[u,l],()=>[])))),([u,l])=>o(c("]",l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[dp(t),n]),Ju=e=>o(o(fx(e),([t,n])=>[t,n],()=>o(hx(e),([t,n])=>[t,n],()=>o(gx(e),([t,n])=>[t,n],()=>o(yx(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),xx=e=>o(o(o(c("readonly",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[fp(t),n]),Ix=e=>o(o(o(c("?",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[hp(t),n]),Xu=e=>o(o(xx(e),([t,n])=>o(Ju(n),([r,a])=>o(Ix(a),([i,m])=>o(c(":",m),([u,l])=>o(R(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[gp(t),n]),Zu=e=>o(o(o(c(",",e),([t,n])=>o(c(`
4
+ `,"utf-8")}let F=he(n,"node_modules"),Y=he(r,"node_modules");if(no(F)&&!no(Y))try{ih(F,Y,process.platform==="win32"?"junction":"dir")}catch{}try{ah(i,he(r,"agent_prompt.md"))}catch{}let ae=Ir(a,"utf-8"),me=uh(ae),at=he(r,"test.patch");st(at,ae,"utf-8");let _=await t.exec("git",["apply","test.patch"],l);try{sh(at)}catch{}if(_.code!==0)return{status:"patchFailed",solverDir:r,error:_.stderr?.trim()||"git apply test.patch failed"};let ot=await t.exec("git",["add","-A"],l);if(ot.code!==0)return{status:"error",solverDir:r,error:ot.stderr?.trim()||"git add (tests applied) failed"};let it=await t.exec("git",["commit","-m","tests applied","--allow-empty"],l);if(it.code!==0)return{status:"error",solverDir:r,error:it.stderr?.trim()||"git commit (tests applied) failed"};let Ue=await t.exec("git",["rev-parse","HEAD"],l);return Ue.code!==0||!Ue.stdout.trim()?{status:"error",solverDir:r,error:"Could not resolve tests-applied commit hash."}:{status:"ok",solverDir:r,testsAppliedCommit:Ue.stdout.trim(),testPatchPaths:me}}function ch(e){try{let t=Ir(e,"utf-8").match(/<testsuites\b[^>]*>/i)?.[0];if(!t)return{totalTests:null,failedTests:null};let n=m=>Number.parseInt(t.match(new RegExp(`\\b${m}="(\\d+)"`,"i"))?.[1]??"",10),r=n("tests"),a=n("failures"),i=n("errors");return{totalTests:Number.isFinite(r)?r:null,failedTests:Number.isFinite(a)?a+(Number.isFinite(i)?i:0):null}}catch{return{totalTests:null,failedTests:null}}}async function Ki(e){let{pi:t,index:n,workspace:r,status:a,durationMs:i,cancelSignal:m}=e,{solverDir:u,testsAppliedCommit:l,testPatchPaths:f}=r,h=he(u,"test_output.xml"),v=(pe="",Ke="cancelled")=>({index:n,status:"cancelled",passed:!1,diff:pe,testOutputTail:Ke,durationMs:i,totalTests:null,failedTests:null,testOutputXmlPath:h});if(m.aborted)return v();let E={cwd:u,timeout:ao,signal:m};if(await t.exec("git",["add","-A"],E),m.aborted)return v();let A=[...f,"agent_prompt.md"].map(pe=>`:(exclude)${pe}`),F=await t.exec("git",["diff","--cached",l,"--",".",...A],E),Y=F.code===0?F.stdout:"";if(m.aborted)return v(Y);let ae=`bash test.sh --output_path ${to(eo(h))} new`,me="",at=await mh({shellPath:xr()}).exec(ae,u,{signal:m,timeout:ao*10/1e3,onData:pe=>{me+=pe.toString()}});if(m.aborted)return v(Y,_i(me.trim(),Ni));let _=at.exitCode===0,ot=_i(me.trim(),Ni),{totalTests:it,failedTests:Ue}=ch(h);return{index:n,status:a,passed:_,diff:Y,testOutputTail:ot,durationMs:i,totalTests:it,failedTests:Ue,testOutputXmlPath:h}}function zi(e){let{repoDir:t,runId:n,index:r,trajectory:a,solutionPatch:i,testOutputXmlPath:m,testOutputTail:u}=e,l=he(t,ph,n,`solver_${r}`);ro(l,{recursive:!0}),st(he(l,"trajectory.json"),JSON.stringify(a,null,2),"utf-8"),st(he(l,"solution.patch"),i,"utf-8");try{let f=Ir(m,"utf-8");st(he(l,"test_output.xml"),f,"utf-8")}catch{st(he(l,"test_output.txt"),u,"utf-8")}return l}function Bi(e,t){let n=he(e,kn);ro(n,{recursive:!0});let r=t.map(a=>{let i=he(n,`solver_${a.index}`);return ro(i,{recursive:!0}),st(he(i,"solution.diff"),a.diff,"utf-8"),st(he(i,"test_output.txt"),a.testOutputTail,"utf-8"),{index:a.index,status:a.status,passed:a.passed}});return st(he(n,"manifest.json"),JSON.stringify(r,null,2),"utf-8"),n}function Vi(e){let t=he(e,"node_modules");try{oh(t).isSymbolicLink()&&Gi(t,{force:!0})}catch{}try{Gi(e,{recursive:!0,force:!0})}catch{}}var p={};Rt(p,{Assign:()=>lh,Clone:()=>Rn,Create:()=>xg,Discard:()=>bg,Metrics:()=>Ge,Update:()=>Ig});var Ge={assign:0,create:0,clone:0,discard:0,update:0};function lh(e,t){return Ge.assign+=1,{...e,...t}}var s={};Rt(s,{Entries:()=>Mh,EntriesRegExp:()=>Ch,Every:()=>Oh,EveryAll:()=>Ph,GraphemeCount:()=>Eh,HasPropertyKey:()=>Ah,IsArray:()=>En,IsBigInt:()=>wn,IsBoolean:()=>ts,IsClassInstance:()=>kh,IsConstructor:()=>xh,IsDeepEqual:()=>mo,IsEqual:()=>M,IsFunction:()=>ns,IsGreaterEqualThan:()=>as,IsGreaterThan:()=>vh,IsInteger:()=>io,IsLessEqualThan:()=>rs,IsLessThan:()=>Th,IsMaxLength:()=>Sh,IsMinLength:()=>Rh,IsMultipleOf:()=>$h,IsNull:()=>$r,IsNumber:()=>kr,IsObject:()=>Sn,IsObjectNotArray:()=>bh,IsString:()=>wr,IsSymbol:()=>Ih,IsUndefined:()=>so,IsUnsafePropertyKey:()=>os,IsValueLike:()=>wh,Keys:()=>Tr,ShiftLeft:()=>Er,Symbols:()=>qh,Values:()=>Lh});function Ot(e,t,n){return e>=t&&e<=n}function dh(e){return e===8205}function fh(e){return Ot(e,55296,56319)}function Wi(e){return Ot(e,127462,127487)}function Yi(e){return Ot(e,65024,65039)}function Ji(e){return Ot(e,768,879)||Ot(e,6832,6911)||Ot(e,7616,7679)||Ot(e,65056,65071)}function vr(e){return e>65535?2:1}function Hi(e,t){for(;t<e.length;){let n=e.codePointAt(t);if(Ji(n)||Yi(n))t+=vr(n);else break}return t}function oo(e,t){let n=e.codePointAt(t),r=t+vr(n);for(r=Hi(e,r);r<e.length-1&&e[r]==="\u200D";){let a=e.codePointAt(r+1);r+=1+vr(a),r=Hi(e,r)}return Wi(n)&&r<e.length&&Wi(e.codePointAt(r))&&(r+=vr(e.codePointAt(r))),r}function Xi(e){return fh(e)||Ji(e)||Yi(e)||dh(e)}function Zi(e){let t=0,n=0;for(;n<e.length;)n=oo(e,n),t++;return t}function hh(e,t){if(t===0)return!0;let n=0,r=0;for(;r<e.length;)if(r=oo(e,r),n++,n>=t)return!0;return!1}function gh(e,t){let n=0,r=0;for(;r<e.length;)if(r=oo(e,r),n++,n>t)return!1;return!0}function Qi(e,t){if(t===0)return!0;let n=0;for(;n<e.length;){if(Xi(e.charCodeAt(n)))return hh(e,t);if(n++,n>=t)return!0}return!1}function es(e,t){let n=0;for(;n<e.length;){if(Xi(e.charCodeAt(n)))return gh(e,t);if(n++,n>t)return!1}return!0}function En(e){return Array.isArray(e)}function wn(e){return M(typeof e,"bigint")}function ts(e){return M(typeof e,"boolean")}function xh(e){if(so(e)||!ns(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function ns(e){return M(typeof e,"function")}function io(e){return Number.isInteger(e)}function $r(e){return M(e,null)}function kr(e){return Number.isFinite(e)}function bh(e){return Sn(e)&&!En(e)}function Sn(e){return M(typeof e,"object")&&!$r(e)}function wr(e){return M(typeof e,"string")}function Ih(e){return M(typeof e,"symbol")}function so(e){return M(e,void 0)}function M(e,t){return e===t}function vh(e,t){return e>t}function Th(e,t){return e<t}function rs(e,t){return e<=t}function as(e,t){return e>=t}function $h(e,t){if(wn(e)||wn(t))return BigInt(e)%BigInt(t)===0n;let n=1e-10;if(!kr(e)||io(e)&&1/t%1===0)return!0;let r=e%t;return Math.min(Math.abs(r),Math.abs(r-t),Math.abs(r+t))<n}function kh(e){if(!Sn(e))return!1;let t=globalThis.Object.getPrototypeOf(e);return $r(t)?!1:M(typeof t.constructor,"function")&&!(M(t.constructor,globalThis.Object)||M(t.constructor.name,"Object"))}function wh(e){return wn(e)||ts(e)||$r(e)||kr(e)||wr(e)||so(e)}function Eh(e){return Zi(e)}function Sh(e,t){return es(e,t)}function Rh(e,t){return Qi(e,t)}function Oh(e,t,n){for(let r=t;r<e.length;r++)if(!n(e[r],r))return!1;return!0}function Ph(e,t,n){let r=!0;for(let a=t;a<e.length;a++)n(e[a],a)||(r=!1);return r}function Er(e,t,n){return M(e.length,0)?n():t(e[0],e.slice(1))}function os(e){return M(e,"__proto__")||M(e,"constructor")||M(e,"prototype")}function Ah(e,t){return os(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function Ch(e){return Tr(e).map(t=>[new RegExp(`^${t}$`),e[t]])}function Mh(e){return Object.entries(e)}function Tr(e){return Object.getOwnPropertyNames(e)}function qh(e){return Object.getOwnPropertySymbols(e)}function Lh(e){return Object.values(e)}function jh(e,t){if(!Sn(t))return!1;let n=Tr(e);return M(n.length,Tr(t).length)&&n.every(r=>mo(e[r],t[r]))}function Fh(e,t){return En(t)&&M(e.length,t.length)&&e.every((n,r)=>mo(e[r],t[r]))}function mo(e,t){return En(e)?Fh(e,t):Sn(e)?jh(e,t):M(e,t)}var ht={};Rt(ht,{IsBigInt64Array:()=>Zh,IsBigUint64Array:()=>Qh,IsBoolean:()=>Gh,IsDate:()=>tg,IsFloat32Array:()=>Jh,IsFloat64Array:()=>Xh,IsInt16Array:()=>Vh,IsInt32Array:()=>Hh,IsInt8Array:()=>Kh,IsMap:()=>rg,IsNumber:()=>Nh,IsRegExp:()=>eg,IsSet:()=>ng,IsString:()=>_h,IsTypeArray:()=>Uh,IsUint16Array:()=>Wh,IsUint32Array:()=>Yh,IsUint8Array:()=>zh,IsUint8ClampedArray:()=>Bh});function Gh(e){return e instanceof Boolean}function Nh(e){return e instanceof Number}function _h(e){return e instanceof String}function Uh(e){return globalThis.ArrayBuffer.isView(e)}function Kh(e){return e instanceof globalThis.Int8Array}function zh(e){return e instanceof globalThis.Uint8Array}function Bh(e){return e instanceof globalThis.Uint8ClampedArray}function Vh(e){return e instanceof globalThis.Int16Array}function Wh(e){return e instanceof globalThis.Uint16Array}function Hh(e){return e instanceof globalThis.Int32Array}function Yh(e){return e instanceof globalThis.Uint32Array}function Jh(e){return e instanceof globalThis.Float32Array}function Xh(e){return e instanceof globalThis.Float64Array}function Zh(e){return e instanceof globalThis.BigInt64Array}function Qh(e){return e instanceof globalThis.BigUint64Array}function eg(e){return e instanceof globalThis.RegExp}function tg(e){return e instanceof globalThis.Date}function ng(e){return e instanceof globalThis.Set}function rg(e){return e instanceof globalThis.Map}function og(e){return s.HasPropertyKey(e,"~kind")||s.HasPropertyKey(e,"~unsafe")}function ig(e){let t={},n=Object.getOwnPropertyDescriptors(e);for(let r of Object.keys(n)){if(s.IsUnsafePropertyKey(r))continue;let a=n[r];s.HasPropertyKey(a,"value")&&Object.defineProperty(t,r,{...a,value:Pt(a.value)})}return t}function sg(e){let t={};for(let n of s.Keys(e))s.IsUnsafePropertyKey(n)||(t[n]=Pt(e[n]));for(let n of s.Symbols(e))t[n]=Pt(e[n]);return t}function mg(e){return s.IsClassInstance(e)?e:og(e)?ig(e):sg(e)}function pg(e){return e.map(t=>Pt(t))}function ug(e){return e.slice()}function cg(e){return new RegExp(e.source,e.flags)}function lg(e){return new Map(Pt([...e.entries()]))}function dg(e){return new Set(Pt([...e.values()]))}function Pt(e){return ht.IsTypeArray(e)?ug(e):ht.IsRegExp(e)?cg(e):ht.IsMap(e)?lg(e):ht.IsSet(e)?dg(e):s.IsArray(e)?pg(e):s.IsObject(e)?mg(e):e}function Rn(e){return Ge.clone+=1,Pt(e)}var At={};Rt(At,{Get:()=>gg,Reset:()=>fg,Set:()=>hg});var mt={immutableTypes:!1,maxErrors:8,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function fg(){mt.immutableTypes=!1,mt.maxErrors=8,mt.useAcceleration=!0,mt.exactOptionalPropertyTypes=!1,mt.enumerableKind=!1,mt.correctiveParse=!1,mt.unionPrioritySort=!0}function hg(e){for(let t of s.Keys(e)){let n=e[t];n!==void 0&&Object.defineProperty(mt,t,{value:n})}}function gg(){return mt}function yg(e,t){for(let n of Object.keys(t))Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:!1,value:t[n]});return e}function is(e,t){return{...e,...t}}function xg(e,t,n={}){Ge.create+=1;let r=At.Get(),a=is(t,n),i=r.enumerableKind?is(a,e):yg(a,e);return r.immutableTypes?Object.freeze(i):i}function bg(e,t){Ge.discard+=1;let n={},r=Object.getOwnPropertyDescriptors(Rn(e)),a=new Set(t);for(let i of Object.keys(r))a.has(i)||Object.defineProperty(n,i,r[i]);return n}function Ig(e,t,n){Ge.update+=1;let r=At.Get(),a=Rn(e);for(let i of Object.keys(t))Object.defineProperty(a,i,{configurable:!0,writable:!0,enumerable:r.enumerableKind,value:t[i]});for(let i of Object.keys(n))Object.defineProperty(a,i,{configurable:!0,enumerable:!0,writable:!0,value:n[i]});return a}function y(e,t){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],t)}function ne(e){return s.IsObject(e)}function b(e,t,n){return p.Create({"~kind":"Deferred"},{type:"deferred",action:e,parameters:t,options:n},{})}function gt(e){return y(e,"Deferred")}function vg(e){return p.Update(e,{"~readonly":!0},{})}function On(e,t){return p.Update(vg(e),{},t)}function ss(e,t,n,r){let a=d(e,t,n);return On(a,r)}function Tg(e){return p.Update(e,{"~optional":!0},{})}function Pn(e,t){return p.Update(Tg(e),{},t)}function ms(e,t,n,r){let a=d(e,t,n);return Pn(a,r)}function Re(e,t){return p.Create({"~kind":"Array"},{type:"array",items:e},t)}function z(e){return y(e,"Array")}function Sr(e){return p.Discard(e,["~kind","type","items"])}function Be(e,t,n={}){return p.Create({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},n)}function oe(e){return y(e,"Constructor")}function ps(e){return p.Discard(e,["~kind","type","parameters","instanceType"])}function Ve(e,t,n={}){return p.Create({"~kind":"Function"},{type:"function",parameters:e,returnType:t},n)}function ie(e){return y(e,"Function")}function us(e){return p.Discard(e,["~kind","type","parameters","returnType"])}function pt(e,t){return p.Create({"~kind":"Ref"},{$ref:e},t)}function se(e){return y(e,"Ref")}function yt(e,t){return p.Create({"~kind":"Generic"},{type:"generic",parameters:e,expression:t})}function Jt(e){return y(e,"Generic")}function Xt(e){return p.Create({"~kind":"Any"},{},e)}function Z(e){return y(e,"Any")}var cs="(?!)";function D(e){return p.Create({"~kind":"Never"},{not:{}},e)}function xt(e){return y(e,"Never")}function We(e,t={}){return b("AddOptional",[e],t)}function Ct(e,t={}){return Pn(e,t)}function ls(e){return Ct(e)}function ge(e){return ne(e)&&s.HasPropertyKey(e,"~optional")}function ds(e){return s.Keys(e).filter(t=>!ge(e[t]))}function Rr(e){return s.Keys(e)}function Or(e){return s.Values(e)}function T(e,t={}){let n=ds(e),r=n.length>0?{required:n}:{};return p.Create({"~kind":"Object"},{type:"object",...r,properties:e},t)}function q(e){return y(e,"Object")}function fs(e){return p.Discard(e,["~kind","type","properties","required"])}function ue(e){return p.Create({"~kind":"Unknown"},{},e)}function re(e){return y(e,"Unknown")}function He(e,t,n){let r=s.Keys(e).reduce((a,i)=>({...a,[i]:p.Update(e[i],{},{$id:i})}),{});return p.Create({"~kind":"Cyclic"},{$defs:r,$ref:t},n)}function le(e){return y(e,"Cyclic")}function hs(e){return p.Update(e,{"~unsafe":null},{})}function Pr(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"~unsafe")&&s.IsNull(e["~unsafe"])}var Ye={};Rt(Ye,{Match:()=>$g});function $g(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}function An(...e){let[t,n]=Ye.Match(e,{2:(r,a)=>[r,a,a],1:r=>[r,ue(),ue()]});return p.Create({"~kind":"Infer"},{type:"infer",name:t,extends:n},{})}function J(e){return y(e,"Infer")}function Mt(e,t,n,r={}){return p.Create({"~kind":"Dependent"},{if:e,then:t,else:n},r)}function W(e){return y(e,"Dependent")}function gs(e){return p.Discard(e,["~kind","if","then","else"])}function ys(e){return s.IsObjectNotArray(e)}function xs(e){return s.Keys(e).filter(n=>isNaN(n)).reduce((n,r)=>[...n,e[r]],[])}function bs(e){return s.IsString(e)||s.IsNumber(e)}function Is(e,t){let n=ys(e)?xs(e):e;return p.Create({"~kind":"Enum"},{enum:n},t)}function xe(e){return y(e,"Enum")}function ye(e,t={}){return p.Create({"~kind":"Intersect"},{allOf:e},t)}function O(e){return y(e,"Intersect")}function vs(e){return p.Discard(e,["~kind","allOf"])}function X(){throw new Error("Unreachable")}var Ts;(function(e){e[e.Array=0]="Array",e[e.BigInt=1]="BigInt",e[e.Boolean=2]="Boolean",e[e.Date=3]="Date",e[e.Constructor=4]="Constructor",e[e.Function=5]="Function",e[e.Null=6]="Null",e[e.Number=7]="Number",e[e.Object=8]="Object",e[e.RegExp=9]="RegExp",e[e.String=10]="String",e[e.Symbol=11]="Symbol",e[e.TypeArray=12]="TypeArray",e[e.Undefined=13]="Undefined"})(Ts||(Ts={}));var Ek=BigInt("14695981039346656037"),[Sk,Rk]=[BigInt("1099511628211"),BigInt("18446744073709551616")],Ok=Array.from({length:256}).map((e,t)=>BigInt(t)),$s=new Float64Array(1),Pk=new DataView($s.buffer),Ak=new Uint8Array($s.buffer);var Ck=new TextEncoder;var Cn=class{constructor(t,n){this.type=t,this.decode=n}Encode(t){let n=this.type,r=Ar(n)?m=>this.decode(n["~codec"].decode(m)):this.decode,a=Ar(n)?m=>n["~codec"].encode(t(m)):t,i={decode:r,encode:a};return p.Update(this.type,{"~codec":i},{})}},Mn=class{constructor(t){this.type=t}Decode(t){return new Cn(this.type,t)}};function Cr(e){return new Mn(e)}function ws(e,t){return Cr(e).Decode(t).Encode(()=>{throw Error("Encode not implemented")})}function Es(e,t){return Cr(e).Decode(()=>{throw Error("Decode not implemented")}).Encode(t)}function Ar(e){return ne(e)&&s.HasPropertyKey(e,"~codec")&&s.IsObject(e["~codec"])&&s.HasPropertyKey(e["~codec"],"encode")&&s.HasPropertyKey(e["~codec"],"decode")}function Ss(e){return Zt(e)}function qt(e){return ne(e)&&s.HasPropertyKey(e,"~immutable")}function Je(e,t={}){return b("AddReadonly",[e],t)}function Lt(e,t={}){return On(e,t)}function Rs(e){return Lt(e)}function jt(e){return ne(e)&&s.HasPropertyKey(e,"~readonly")}function Sg(e,t){let n=po(e)?[...e["~refine"],t]:[t];return p.Update(e,{"~refine":n},{})}function Os(...e){let[t,n,r]=Ye.Match(e,{3:(a,i,m)=>[a,i,m],2:(a,i)=>[a,i,()=>"Refine Error"]});return Sg(t,{check:n,error:r})}function Rg(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"check")&&s.HasPropertyKey(e,"error")&&s.IsFunction(e.check)&&s.IsFunction(e.error)}function po(e){return ne(e)&&s.HasPropertyKey(e,"~refine")&&s.IsArray(e["~refine"])&&s.Every(e["~refine"],0,t=>Rg(t))}var Ps="-?(?:0|[1-9][0-9]*)n";function qn(e){return p.Create({"~kind":"BigInt"},{type:"bigint"},e)}function Xe(e){return y(e,"BigInt")}function Mr(e){return p.Create({"~kind":"Boolean"},{type:"boolean"},e)}function Ce(e){return y(e,"Boolean")}function Ln(e){return p.Create({"~kind":"Identifier"},{name:e})}function As(e){return y(e,"Identifier")}var qr="-?(?:0|[1-9][0-9]*)";function Ft(e){return p.Create({"~kind":"Integer"},{type:"integer"},e)}function be(e){return y(e,"Integer")}var uo=class extends Error{constructor(t){super("Invalid Literal value"),Object.defineProperty(this,"cause",{value:{value:t},writable:!1,configurable:!1,enumerable:!1})}};function Og(e){return s.IsBigInt(e)?"bigint":s.IsBoolean(e)?"boolean":s.IsNumber(e)?"number":s.IsString(e)?"string":(()=>{throw new uo(e)})()}function P(e,t){return p.Create({"~kind":"Literal"},{type:Og(e),const:e},t)}function Lr(e){return s.IsBigInt(e)||s.IsBoolean(e)||s.IsNumber(e)||s.IsString(e)}function Cs(e){return L(e)&&s.IsNumber(e.const)}function Ms(e){return L(e)&&s.IsString(e.const)}function L(e){return y(e,"Literal")}function Qt(e){return p.Create({"~kind":"Null"},{type:"null"},e)}function en(e){return y(e,"Null")}var jr="-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";function we(e){return p.Create({"~kind":"Number"},{type:"number"},e)}function Q(e){return y(e,"Number")}function tn(e){return p.Create({"~kind":"Symbol"},{type:"symbol"},e)}function bt(e){return y(e,"Symbol")}function Dt(...e){let[t,n,r]=Ye.Match(e,{3:(a,i,m)=>[a,i,m],2:(a,i)=>[a,i,i],1:a=>[a,ue(),ue()]});return p.Create({"~kind":"Parameter"},{name:t,extends:n,equals:r},{})}function qs(e){return y(e,"Parameter")}var Fr=".*";function Me(e){return p.Create({"~kind":"String"},{type:"string"},e)}function Ie(e){return y(e,"String")}function w(e,t={}){return p.Create({"~kind":"Union"},{anyOf:e},t)}function x(e){return y(e,"Union")}function Ls(e){return p.Discard(e,["~kind","anyOf"])}function jn(e){let t=js(e);return s.IsEqual(t.length,2)?t[0]:[]}function Pg(e){return!0}function Fs(e){return s.ShiftLeft(e,(t,n)=>Ag(t)?Fs(n):!1,()=>!0)}function Ds(e){return s.IsEqual(e.length,0)?!1:Fs(e)}function Ag(e){return x(e)?Ds(e.anyOf):L(e)?Pg(e.const):!1}function Dr(e){return Ds(e)}function Gr(e){return p.Create({"~kind":"TemplateLiteral"},{type:"string",pattern:e},{})}function Gs(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>Gs(a,t,[...n,`${r}${t}`]),()=>n)}function Cg(e,t){return s.IsEqual(e.length,0)?[`${t}`]:Gs(e,t)}function Ns(e,t,n=[]){return s.ShiftLeft(t,(r,a)=>Ns(e,a,[...n,..._s(e,r)]),()=>n)}function _s(e,t){return x(t)?Ns(e,t.anyOf):L(t)?Cg(e,t.const):X()}function Us(e,t){return s.ShiftLeft(t,(n,r)=>Us(_s(e,n),r),()=>e)}function Mg(e){return e.map(t=>P(t))}function qg(e){let t=Us([],e),n=Mg(t);return w(n)}function Lg(e){return s.IsEqual(e.length,0)?X():s.IsEqual(e.length,1)&&L(e[0])?e[0]:qg(e)}function co(e){let t=jn(e);return s.IsEqual(t.length,0)?Me():Dr(t)?Lg(t):Gr(e)}function Ks(e){let t=co(e);return ee(t)?Me():t}function $e(e,t){let n="object",r={[e]:t};return p.Create({"~kind":"Record"},{type:n,patternProperties:r})}function zs(e){return $e(Ne,e)}function Bs(e){return T({true:e,false:e})}function te(e,t={}){let[n,r,a]=[e,e.length,!1];return p.Create({"~kind":"Tuple"},{type:"array",additionalItems:a,items:n,minItems:r},t)}function N(e){return y(e,"Tuple")}function Vs(e){return p.Discard(e,["~kind","type","items","minItems","additionalItems"])}function jg(e){return p.Discard(e,["~readonly"])}function lo(e,t){return p.Update(jg(e),{},t)}function Ws(e,t,n,r){let a=d(e,t,n);return lo(a,r)}function Hs(e,t={}){return b("RemoveReadonly",[e],t)}function Ys(e,t={}){return lo(e,t)}function Fg(e){return p.Discard(e,["~optional"])}function fo(e,t){return p.Update(Fg(e),{},t)}function Js(e,t,n,r){let a=d(e,t,n);return fo(a,r)}function Xs(e,t={}){return b("RemoveOptional",[e],t)}function Nr(e,t={}){return fo(e,t)}function ho(e){return e.reduceRight((n,r,a)=>({[a]:r,...n}),{})}function Zs(e){let t=ho(e.items);return T(t)}function Dg(e,t){return jt(e)?!!jt(t):!1}function Gg(e,t){return ge(e)?!!ge(t):!1}function Ng(e,t){let n=Dg(e,t),r=Gg(e,t),a=B([e,t]),i=Ys(Nr(a));return n&&r?Lt(Ct(i)):n&&!r?Lt(i):!n&&r?Ct(i):i}function _g(e,t,n){return n in e?n in t?Ng(e[n],t[n]):e[n]:n in t?t[n]:D()}function Ug(e,t){return[...new Set([...s.Keys(t),...s.Keys(e)])].reduce((r,a)=>({...r,[a]:_g(e,t,a)}),{})}function Qs(e){return q(e)?e.properties:N(e)?ho(e.items):X()}function em(e,t){let n=Qs(e),r=Qs(t),a=Ug(n,r);return T(a)}function tm(e,t){let n=nn(e,t);return s.IsEqual(n,Dn)?e:s.IsEqual(n,Gn)||s.IsEqual(n,Fn)?t:D()}function nm(e){return q(e)||N(e)}function Kg(e,t){let n=x(e),r=x(t);return n||r}function zg(e,t){let n=qe(e),r=qe(t),a=Kg(n,r),i=nm(n),m=nm(r);return a?B([n,r]):i&&m?em(n,r):i&&!m?n:!i&&m?r:tm(n,r)}function rm(e,t,n=[]){return s.ShiftLeft(t,(r,a)=>rm(e,a,[...n,zg(e,r)]),()=>s.IsEqual(n.length,0)?[e]:n)}function am(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>am(a,t,[...n,...Nn([r],t)]),()=>n)}function Nn(e,t=[]){return s.ShiftLeft(e,(n,r)=>x(n)?Nn(r,am(n.anyOf,t)):Nn(r,rm(n,t)),()=>t)}function Bg(e,t){let n=de({},e,t);return I.IsExtendsTrueLike(n)?[]:[e]}function Vg(e,t){return e.reduce((n,r)=>[...n,...Bg(r,t)],[])}function _r(e,t){let n=qe(e),r=x(n)?n.anyOf:[n],a=Vg(r,t);return Ee(a)}function _e(e,t,n){let r=ye([e,t]),a=_r(n,e);return Ee([r,a])}function Oe(e){let t=e.map(n=>P(n));return Ee(t)}function B(e){let t=Nn(e),n=go(t);return ut(n)}function ke(e){let t=Ks(e);return qe(t)}function Ee(e){let t=go(e);return ut(t)}function qe(e){return W(e)?_e(e.if,e.then,e.else):xe(e)?Oe(e.enum):O(e)?B(e.allOf):ee(e)?ke(e.pattern):x(e)?Ee(e.anyOf):e}function ut(e){return s.IsEqual(e.length,1)?e[0]:s.IsEqual(e.length,0)?D():w(e)}function om(e,t){let n=Oe(e);return It(n,t)}function im(e,t){return $e(vt,t)}function sm(e,t){let n=B(e);return It(n,t)}function mm(e,t){return s.IsString(e)||s.IsNumber(e)?T({[e]:t}):s.IsEqual(e,!1)?T({false:t}):s.IsEqual(e,!0)?T({true:t}):T({})}function pm(e,t){return $e(rn,t)}function um(e,t){return s.HasPropertyKey(e,"pattern")&&(s.IsString(e.pattern)||e.pattern instanceof RegExp)?$e(e.pattern.toString(),t):$e(Ne,t)}function cm(e,t){let n=jn(e);return Dr(n)?It(ke(e),t):$e(e,t)}function Wg(e){return x(e)?_n(e.anyOf):[e]}function _n(e){return e.reduce((t,n)=>[...t,...Wg(n)],[])}function Hg(e){return e.some(t=>Ie(t)||Q(t)||be(t))}function Yg(e,t){return s.IsEqual(Hg(e),!0)?$e(Ne,t):void 0}function Jg(e,t){return e.reduce((n,r)=>L(r)&&(s.IsString(r.const)||s.IsNumber(r.const))?{...n,[r.const]:t}:n,{})}function Xg(e,t){let n=Jg(e,t);return T(n)}function lm(e,t){let n=_n(e),r=Yg(n,t);return ne(r)?r:Xg(n,t)}function It(e,t){return Z(e)?zs(t):Ce(e)?Bs(t):xe(e)?om(e.enum,t):be(e)?im(e,t):O(e)?sm(e.allOf,t):L(e)?mm(e.const,t):Q(e)?pm(e,t):x(e)?lm(e.anyOf,t):Ie(e)?um(e,t):ee(e)?cm(e.pattern,t):T({})}function yo(e,t,n){return k([e])?p.Update(It(e,t),{},n):Ur(e,t,n)}function dm(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return yo(i,m,a)}var vt=`^${qr}$`,rn=`^${jr}$`,Ne=`^${Fr}$`;function Ur(e,t,n={}){return b("Record",[e,t],n)}function Kr(e,t,n={}){return yo(e,t,n)}function fm(e,t){return $e(e,t)}function zr(e){return s.IsEqual(e,Ne)?Me():s.IsEqual(e,vt)?Ft():s.IsEqual(e,rn)?we():co(e)}function Le(e){return s.Keys(e.patternProperties)[0]}function an(e){let t=Le(e);return zr(t)}function ve(e){return e.patternProperties[Le(e)]}function fe(e){return y(e,"Record")}function Gt(e){return p.Create({"~kind":"Rest"},{type:"rest",items:e},{})}function Tt(e){return y(e,"Rest")}function Br(e){return p.Create({"~kind":"This"},{$ref:"#"},e)}function Vr(e){return y(e,"This")}function on(e){return p.Create({"~kind":"Undefined"},{type:"undefined"},e)}function sn(e){return y(e,"Undefined")}function Wr(e){return p.Create({"~kind":"Void"},{type:"void"},e)}function Ze(e){return y(e,"Void")}function Qg(e,t){return s.IsEqual(e,"Array")?Re(t[0]):s.IsEqual(e,"Capitalize")?Yr(t[0]):s.IsEqual(e,"ConstructorParameters")?ea(t[0]):s.IsEqual(e,"Evaluate")?gu(t[0]):s.IsEqual(e,"Exclude")?ta(t[0],t[1]):s.IsEqual(e,"Extract")?na(t[0],t[1]):s.IsEqual(e,"Index")?Bn(t[0],t[1]):s.IsEqual(e,"InstanceType")?ra(t[0]):s.IsEqual(e,"Lowercase")?Jr(t[0]):s.IsEqual(e,"NonNullable")?aa(t[0]):s.IsEqual(e,"Omit")?oa(t[0],t[1]):s.IsEqual(e,"Parameters")?ia(t[0]):s.IsEqual(e,"Partial")?sa(t[0]):s.IsEqual(e,"Pick")?ma(t[0],t[1]):s.IsEqual(e,"Readonly")?pa(t[0]):s.IsEqual(e,"KeyOf")?Vn(t[0]):s.IsEqual(e,"Record")?Ur(t[0],t[1]):s.IsEqual(e,"Required")?ua(t[0]):s.IsEqual(e,"ReturnType")?ca(t[0]):s.IsEqual(e,"Uncapitalize")?Xr(t[0]):s.IsEqual(e,"Uppercase")?Zr(t[0]):zn(pt(e),t)}function Nt(){throw Error("Unreachable")}var ey=(e,t=[])=>e.reduce((n,r)=>s.IsArray(r)&&s.IsEqual(r.length,2)?[...n,r[0]]:[...n,r],[]),ct=e=>{let[t,n]=e;return ey([...t,...n])};function bm(e){return Dt(e[0],e[2],e[4])}function Im(e){return Dt(e[0],e[2],e[2])}function vm(e){return Dt(e[0],ue(),e[2])}function Tm(e){return Dt(e,ue(),ue())}function $m(e){return ct(e)}function km(e){return e[1]}function wm(e){return ct(e)}function Em(e){return e[1]}function Sm(e){return Qg(e[0],e[1])}function Rm(e){return null}function Om(e){return Me()}function Pm(e){return we()}function Am(e){return Mr()}function Cm(e){return on()}function Mm(e){return Qt()}function qm(e){return Ft()}function Lm(e){return qn()}function jm(e){return ue()}function Fm(e){return Xt()}function Dm(e){return T({})}function Gm(e){return D()}function Nm(e){return tn()}function _m(e){return Wr()}function Um(e){return Br()}function Km(e){return P(BigInt(e))}function zm(e){return P(s.IsEqual(e,"true"))}function Bm(e){return P(parseFloat(e))}function Vm(e){return P(e)}function Wm(e){return e[1]}function Hm(e){return P(e)}function Ym(e){return s.IsEqual(e.length,3)?[e[0],e[1],...e[2]]:[e[0]]}function Jm(e){return e[1]}function Xm(e){return Hr(e)}function Zm(e){return s.IsEqual(e.length,6)?Mt(e[1],e[3],e[5]):Mt(e[1],e[3],ue())}function Qm(e){return e.length>0}function ep(e){return e.reduce((t,n)=>s.IsEqual(n.length,3)?[...t,[n[1]]]:[...t,[]],[])}function tp(e){return s.IsEqual(e.length,6)?[e[1],e[3],e[5]]:[]}function np(e){return s.IsArray(e)&&s.IsEqual(e.length,3)?e[1]:e}function rp(e){return s.IsEqual(e.length,2)?e[1]:[]}function hm(e,t){return t.reduce((n,r)=>{let a=r;return s.IsEqual(a.length,1)?Bn(n,a[0]):s.IsEqual(a.length,0)?Re(n):Nt()},e)}function gm(e,t){return s.IsEqual(t.length,3)?Qr(e,t[0],t[1],t[2]):e}function ty(e,t){return s.IsArray(t)&&s.IsEqual(t.length,0)?e:la(e,t)}function ap(e){let[t,n,r,a,i]=e;return ty(gm(t?Vn(hm(n,r)):hm(n,r),a),i)}function xo(e,t){return s.IsEqual(t.length,3)?(()=>{let[n,r,a]=t,i=xo(r,a);if(s.IsEqual(n,"&"))return O(i)?ye([e,...i.allOf]):ye([e,i]);if(s.IsEqual(n,"|"))return x(i)?w([e,...i.anyOf]):w([e,i]);Nt()})():e}function op(e){let[t,n]=e;return xo(t,n)}function ip(e){let[t,n]=e;return xo(t,n)}function sp(e){return hu(e[1])}function mp(e){return e[1]}function pp(e){return yt(e[0],e[2])}function up(e){return s.IsEqual(e.length,4)?An(e[1],e[3]):s.IsEqual(e.length,2)?An(e[1],ue()):Nt()}function cp(e){return`${e}`}function lp(e){return be(e[3])?vt:Q(e[3])?rn:bt(e[3])?Ne:Ie(e[3])?Ne:Nt()}function dp(e){return e.length>0}function fp(e){return e.length>0}function hp(e){let[t,n,r,a,i]=e;return{[n]:t&&r?Je(We(i)):t&&!r?Je(i):!t&&r?We(i):i}}function gp(e){return ct(e)}function yp(e){return e.reduce((t,n)=>s.HasPropertyKey(n,vt)||s.HasPropertyKey(n,rn)||s.HasPropertyKey(n,Ne)?[t[0],p.Assign(t[1],n)]:[p.Assign(t[0],n),t[1]],[{},{}])}function xp(e){return yp(e[1])}function bp(e){let[t,n]=e,r=s.IsEqual(s.Keys(n).length,0)?{}:{patternProperties:n};return T(t,r)}function Ip(e){return s.IsEqual(e.length,5)?Je(We(e[4])):s.IsEqual(e.length,3)?e[2]:s.IsEqual(e.length,4)?s.IsEqual(e[2],"readonly")?Je(e[3]):We(e[3]):Nt()}function vp(e){return Je(We(e[1]))}function Tp(e){return Je(e[1])}function $p(e){return We(e[0])}function kp(e){return s.IsEqual(e.length,2)?Gt(e[1]):s.IsEqual(e.length,1)?e[0]:Nt()}function wp(e){return ct(e)}function Ep(e){return te(e[1])}function Sp(e){return Je(We(e[4]))}function Rp(e){return Je(e[3])}function Op(e){return We(e[3])}function Pp(e){return e[2]}function Ap(e){return s.IsEqual(e.length,2)?Gt(e[1]):s.IsEqual(e.length,1)?e[0]:Nt()}function Cp(e){return ct(e)}function Mp(e){return Ve(e[1],e[4])}function qp(e){return Be(e[2],e[5])}function ym(e,t){return s.IsEqual(e,"remove")?Hs(t):s.IsEqual(e,"add")?Je(t):t}function Lp(e){return s.IsEqual(e.length,2)&&s.IsEqual(e[0],"-")?"remove":s.IsEqual(e.length,2)&&s.IsEqual(e[0],"+")||s.IsEqual(e.length,1)?"add":"none"}function xm(e,t){return s.IsEqual(e,"remove")?Xs(t):s.IsEqual(e,"add")?We(t):t}function jp(e){return s.IsEqual(e.length,2)&&s.IsEqual(e[0],"-")?"remove":s.IsEqual(e.length,2)&&s.IsEqual(e[0],"+")||s.IsEqual(e.length,1)?"add":"none"}function Fp(e){return s.IsEqual(e.length,2)?[e[1]]:[]}function Dp(e){return s.IsArray(e[6])&&s.IsEqual(e[6].length,1)?Un(Ln(e[3]),e[5],e[6][0],ym(e[1],xm(e[8],e[10]))):Un(Ln(e[3]),e[5],pt(e[3]),ym(e[1],xm(e[8],e[10])))}function Gp(e){return pt(e)}function Np(e){return BigInt(e)}function _p(e){return parseFloat(e)}function Up(e){return s.IsEqual(e,"true")}function Kp(e){return null}function zp(e){return{[e[0]]:e[2]}}function Bp(e){return ct(e)}function ny(e){return e.reduce((t,n)=>p.Assign(t,n),{})}function Vp(e){return ny(e[1])}function Wp(e){return ct(e)}function Hp(e){return e[1]}function Yp(e){return qn()}function Jp(e){return Me()}function Xp(e){return we()}function Zp(e){return Ft()}function Qp(e){return D()}function eu(e){return P(e)}function tu(e){return w(e[1])}function nu(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function ru(e){return[e[0],...e[1]]}function au(e){return e[1]}function ou(e){return ct(e)}function iu(e){return s.IsEqual(e.length,2)?e[1]:[]}function su(e){let t=e[2],n=e[3],[r,a]=e[4],i=s.IsEqual(s.Keys(a).length,0)?{}:{patternProperties:a};return{[e[1]]:yt(t,Kn(n,r,i))}}function mu(e){let t=e[2],[n,r]=e[3],a=s.IsEqual(s.Keys(r).length,0)?{}:{patternProperties:r};return{[e[1]]:Kn(t,n,a)}}function pu(e){return{[e[1]]:yt(e[2],e[4])}}function uu(e){return{[e[1]]:e[3]}}function cu(e){return null}function lu(e){return yp(ct(e))}function du(e){return e[1]}function fu(e){let t=e[0],n=e[1];return yu(p.Assign(t,n[0]))}function Wn(e){return M(e.length,2)}function S(e,t,n){return Wn(e)?t(e[0],e[1]):n()}function oy(e,t){return M(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function V(e,t){for(let n=0;n<e.length;n++){let r=oy(e[n],t);if(Wn(r))return r}return[]}function bo(e,t){return Array.from({length:t-e+1},(n,r)=>String.fromCharCode(e+r))}var xu=[...bo(97,122),...bo(65,90)],Io="0",vo=bo(49,57),mn=[Io,...vo],bu=" ",pn=`
5
+ `;var $t="_",da=".",Iu="$",fa="-";var vu="//",Tu="/*",sy="*/";function $u(e){let t=e.indexOf(sy);return M(t,-1)?"":e.slice(t+2)}function ku(e){let t=e.indexOf(pn);return M(t,-1)?"":e.slice(t)}function my(e){return e.replace(/^[ \t\r\f\v]+/,"")}function ha(e){let t=my(e);return t.startsWith(Tu)?ha($u(t.slice(2))):t.startsWith(vu)?ha(ku(t.slice(2))):t}function ce(e){let t=e.trimStart();return t.startsWith(Tu)?ce($u(t.slice(2))):t.startsWith(vu)?ce(ku(t.slice(2))):t}function ga(e,t){return S(V([e],t),(n,r)=>[n,r],()=>["",t])}function py(e,t){return e.includes(t)}function un(e,t,n,r=""){return S(V(e,n),(a,i)=>py(t,a)?un(e,t,i,r):un(e,t,i,`${r}${a}`),()=>[r,n])}function uy(e){return V(vo,e)}var cy=[...mn,$t];function ly(e){return un(cy,[$t],e)}function dy(e){return S(V([Io],e),(t,n)=>[t,n],()=>S(uy(e),(t,n)=>S(ly(n),(r,a)=>[`${t}${r}`,a],()=>[]),()=>[]))}function ya(e){return dy(ce(e))}function fy(e){return ga(fa,e)}function hy(e){return S(fy(e),(t,n)=>S(ya(n),(r,a)=>[`${t}${r}`,a],()=>[]),()=>[])}function wu(e){return hy(ce(e))}function gy(e){return S(wu(e),(t,n)=>S(V(["n"],n),(r,a)=>[`${t}`,a],()=>[]),()=>[])}function To(e){return gy(e)}function $o(e,t){return V([e],t)}function c(e,t){return M(e,"")?["",t]:e.startsWith(pn)?$o(e,ha(t)):e.startsWith(bu)?$o(e,t):$o(e,ce(t))}var Eu=[...xu,$t,Iu];function yy(e){return V(Eu,e)}var xy=[...Eu,...mn];function Su(e,t=""){return S(V(xy,e),(n,r)=>Su(r,`${t}${n}`),()=>[t,e])}function by(e){return S(yy(e),(t,n)=>S(Su(n),(r,a)=>[`${t}${r}`,a],()=>[]),()=>[])}function H(e){return by(ce(e))}var Iy=[...mn,$t];function vy(e){return Wn(V([da],e))}function Ru(e){return S(un(Iy,[$t],e),(t,n)=>M(t,"")?[]:[t,n],()=>[])}function Ty(e){return S(V([da],e),(t,n)=>S(Ru(n),(r,a)=>[`0${t}${r}`,a],()=>[]),()=>[])}function $y(e){return S(ya(e),(t,n)=>S(V([da],n),(r,a)=>S(Ru(a),(i,m)=>[`${t}${r}${i}`,m],()=>[`${t}`,a]),()=>[`${t}`,n]),()=>[])}function ky(e){return vy(e)?Ty(e):$y(e)}function Ou(e){return ky(ce(e))}function wy(e){return ga(fa,e)}function Ey(e){return S(wy(e),(t,n)=>S(Ou(n),(r,a)=>[`${t}${r}`,a],()=>[]),()=>[])}function xa(e){return Ey(ce(e))}function Sy(e){return M(e,"")?[]:[e.slice(0,1),e.slice(1)]}function Pu(e,t){return Er(e,(n,r)=>t.startsWith(n)?!0:Pu(r,t),()=>!1)}function kt(e,t,n=""){return S(Sy(t),(r,a)=>Pu(e,t)?[n,t]:kt(e,a,`${n}${r}`),()=>[])}function Ry(e,t,n){return S(V([e],n),(r,a)=>S(kt([t],a),(i,m)=>S(V([t],m),(u,l)=>[`${i}`,l],()=>[]),()=>[]),()=>[])}function Oy(e,t,n){return S(V([e],n),(r,a)=>S(kt([pn,t],a),(i,m)=>S(V([t],m),(u,l)=>[`${i}`,l],()=>[]),()=>[]),()=>[])}function Au(e,t,n,r){return n?Ry(e,t,ce(r)):Oy(e,t,ce(r))}function Py(e,t){return V(e,t)}function Ay(e,t){return Au(e,e,!1,t)}function Cy(e,t){return S(Py(e,t),(n,r)=>Ay(n,`${n}${r}`),()=>[])}function ba(e,t){return Cy(e,ce(t))}function Cu(e,t){return S(kt(e,t),(n,r)=>M(n,"")?[]:[n,r],()=>[])}var o=(e,t,n=()=>[])=>e.length===2?t(e):n(),qy=e=>o(o(H(e),([t,n])=>o(c("extends",n),([r,a])=>o(R(a),([i,m])=>o(c("=",m),([u,l])=>o(R(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[bm(t),n]),Ly=e=>o(o(H(e),([t,n])=>o(c("extends",n),([r,a])=>o(R(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Im(t),n]),jy=e=>o(o(H(e),([t,n])=>o(c("=",n),([r,a])=>o(R(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[vm(t),n]),Fy=e=>o(H(e),([t,n])=>[Tm(t),n]),Lu=e=>o(o(qy(e),([t,n])=>[t,n],()=>o(Ly(e),([t,n])=>[t,n],()=>o(jy(e),([t,n])=>[t,n],()=>o(Fy(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),ju=(e,t=[])=>o(o(Lu(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>ju(r,[...t,n]),()=>[t,e]),Dy=e=>o(o(ju(e),([t,n])=>o(o(o(Lu(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[$m(t),n]),Eo=e=>o(o(c("<",e),([t,n])=>o(Dy(n),([r,a])=>o(c(">",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[km(t),n]),Fu=(e,t=[])=>o(o(R(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>Fu(r,[...t,n]),()=>[t,e]),Gy=e=>o(o(Fu(e),([t,n])=>o(o(o(R(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[wm(t),n]),Ny=e=>o(o(c("<",e),([t,n])=>o(Gy(n),([r,a])=>o(c(">",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Em(t),n]),_y=e=>o(o(H(e),([t,n])=>o(Ny(n),([r,a])=>[[t,r],a])),([t,n])=>[Sm(t),n]),Du=e=>o(o(o(c(";",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[Rm(t),n]),Gu=e=>o(c("string",e),([t,n])=>[Om(t),n]),Nu=e=>o(c("number",e),([t,n])=>[Pm(t),n]),Uy=e=>o(c("boolean",e),([t,n])=>[Am(t),n]),Ky=e=>o(c("undefined",e),([t,n])=>[Cm(t),n]),zy=e=>o(c("null",e),([t,n])=>[Mm(t),n]),_u=e=>o(c("integer",e),([t,n])=>[qm(t),n]),By=e=>o(c("bigint",e),([t,n])=>[Lm(t),n]),Vy=e=>o(c("unknown",e),([t,n])=>[jm(t),n]),Wy=e=>o(c("any",e),([t,n])=>[Fm(t),n]),Hy=e=>o(c("object",e),([t,n])=>[Dm(t),n]),Yy=e=>o(c("never",e),([t,n])=>[Gm(t),n]),Uu=e=>o(c("symbol",e),([t,n])=>[Nm(t),n]),Jy=e=>o(c("void",e),([t,n])=>[_m(t),n]),Xy=e=>o(c("this",e),([t,n])=>[Um(t),n]),Zy=e=>o(o(c("${",e),([t,n])=>o(R(n),([r,a])=>o(c("}",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Wm(t),n]),ko=e=>o(kt(["${","`"],e),([t,n])=>[Hm(t),n]),Ku=e=>o(o(o(ko(e),([t,n])=>o(Zy(n),([r,a])=>o(Ku(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o(o(ko(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o(o(ko(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))),([t,n])=>[Ym(t),n]),So=e=>o(o(c("`",e),([t,n])=>o(Ku(n),([r,a])=>o(c("`",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Jm(t),n]),Qy=e=>o(So(e),([t,n])=>[Xm(t),n]),ex=e=>o(o(o(c("if",e),([t,n])=>o(R(n),([r,a])=>o(c("then",a),([i,m])=>o(R(m),([u,l])=>o(c("else",l),([f,h])=>o(R(h),([v,E])=>[[t,r,i,u,f,v],E])))))),([t,n])=>[t,n],()=>o(o(c("if",e),([t,n])=>o(R(n),([r,a])=>o(c("then",a),([i,m])=>o(R(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[t,n],()=>[])),([t,n])=>[Zm(t),n]),tx=e=>o(To(e),([t,n])=>[Km(t),n]),nx=e=>o(o(c("true",e),([t,n])=>[t,n],()=>o(c("false",e),([t,n])=>[t,n],()=>[])),([t,n])=>[zm(t),n]),rx=e=>o(xa(e),([t,n])=>[Bm(t),n]),ax=e=>o(ba(["'",'"'],e),([t,n])=>[Vm(t),n]),ox=e=>o(o(o(c("keyof",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[Qm(t),n]),zu=(e,t=[])=>o(o(o(c("[",e),([n,r])=>o(R(r),([a,i])=>o(c("]",i),([m,u])=>[[n,a,m],u]))),([n,r])=>[n,r],()=>o(o(c("[",e),([n,r])=>o(c("]",r),([a,i])=>[[n,a],i])),([n,r])=>[n,r],()=>[])),([n,r])=>zu(r,[...t,n]),()=>[t,e]),ix=e=>o(zu(e),([t,n])=>[ep(t),n]),sx=e=>o(o(o(c("extends",e),([t,n])=>o(R(n),([r,a])=>o(c("?",a),([i,m])=>o(R(m),([u,l])=>o(c(":",l),([f,h])=>o(R(h),([v,E])=>[[t,r,i,u,f,v],E])))))),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[tp(t),n]),mx=e=>o(o(o(c("(",e),([t,n])=>o(R(n),([r,a])=>o(c(")",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o(Gu(e),([t,n])=>[t,n],()=>o(Nu(e),([t,n])=>[t,n],()=>o(Uy(e),([t,n])=>[t,n],()=>o(Ky(e),([t,n])=>[t,n],()=>o(zy(e),([t,n])=>[t,n],()=>o(_u(e),([t,n])=>[t,n],()=>o(By(e),([t,n])=>[t,n],()=>o(Vy(e),([t,n])=>[t,n],()=>o(Wy(e),([t,n])=>[t,n],()=>o(Hy(e),([t,n])=>[t,n],()=>o(Yy(e),([t,n])=>[t,n],()=>o(Uu(e),([t,n])=>[t,n],()=>o(Jy(e),([t,n])=>[t,n],()=>o(Xy(e),([t,n])=>[t,n],()=>o(tx(e),([t,n])=>[t,n],()=>o(nx(e),([t,n])=>[t,n],()=>o(rx(e),([t,n])=>[t,n],()=>o(ax(e),([t,n])=>[t,n],()=>o(Qy(e),([t,n])=>[t,n],()=>o(ex(e),([t,n])=>[t,n],()=>o(vx(e),([t,n])=>[t,n],()=>o(Sx(e),([t,n])=>[t,n],()=>o(Mx(e),([t,n])=>[t,n],()=>o(Cx(e),([t,n])=>[t,n],()=>o(Fx(e),([t,n])=>[t,n],()=>o(_y(e),([t,n])=>[t,n],()=>o(Dx(e),([t,n])=>[t,n],()=>[])))))))))))))))))))))))))))),([t,n])=>[np(t),n]),px=e=>o(o(o(c("with",e),([t,n])=>o(ic(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[rp(t),n]),Bu=e=>o(o(ox(e),([t,n])=>o(mx(n),([r,a])=>o(ix(a),([i,m])=>o(sx(m),([u,l])=>o(px(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[ap(t),n]),Vu=e=>o(o(o(c("&",e),([t,n])=>o(Bu(n),([r,a])=>o(Vu(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[t,n]),Wu=e=>o(o(Bu(e),([t,n])=>o(Vu(n),([r,a])=>[[t,r],a])),([t,n])=>[op(t),n]),Hu=e=>o(o(o(c("|",e),([t,n])=>o(Wu(n),([r,a])=>o(Hu(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[t,n]),Ia=e=>o(o(Wu(e),([t,n])=>o(Hu(n),([r,a])=>[[t,r],a])),([t,n])=>[ip(t),n]),ux=e=>o(o(c("readonly",e),([t,n])=>o(Ia(n),([r,a])=>[[t,r],a])),([t,n])=>[sp(t),n]),cx=e=>o(o(c("|",e),([t,n])=>o(Ia(n),([r,a])=>[[t,r],a])),([t,n])=>[mp(t),n]),lx=e=>o(o(Eo(e),([t,n])=>o(c("=",n),([r,a])=>o(R(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[pp(t),n]),dx=e=>o(o(o(c("infer",e),([t,n])=>o(H(n),([r,a])=>o(c("extends",a),([i,m])=>o(Ia(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[t,n],()=>o(o(c("infer",e),([t,n])=>o(H(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>[])),([t,n])=>[up(t),n]),R=e=>o(o(dx(e),([t,n])=>[t,n],()=>o(cx(e),([t,n])=>[t,n],()=>o(ux(e),([t,n])=>[t,n],()=>o(Ia(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),fx=e=>o(xa(e),([t,n])=>[cp(t),n]),hx=e=>o(H(e),([t,n])=>[t,n]),gx=e=>o(ba(["'",'"'],e),([t,n])=>[t,n]),yx=e=>o(o(c("[",e),([t,n])=>o(H(n),([r,a])=>o(c(":",a),([i,m])=>o(o(_u(m),([u,l])=>[u,l],()=>o(Nu(m),([u,l])=>[u,l],()=>o(Gu(m),([u,l])=>[u,l],()=>o(Uu(m),([u,l])=>[u,l],()=>[])))),([u,l])=>o(c("]",l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[lp(t),n]),Yu=e=>o(o(fx(e),([t,n])=>[t,n],()=>o(hx(e),([t,n])=>[t,n],()=>o(gx(e),([t,n])=>[t,n],()=>o(yx(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),xx=e=>o(o(o(c("readonly",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[dp(t),n]),bx=e=>o(o(o(c("?",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[fp(t),n]),Ju=e=>o(o(xx(e),([t,n])=>o(Yu(n),([r,a])=>o(bx(a),([i,m])=>o(c(":",m),([u,l])=>o(R(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[hp(t),n]),Xu=e=>o(o(o(c(",",e),([t,n])=>o(c(`
6
6
  `,n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c(";",e),([t,n])=>o(c(`
7
7
  `,n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c(",",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o(o(c(";",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o(o(c(`
8
- `,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))))),([t,n])=>[t,n]),Qu=(e,t=[])=>o(o(Xu(e),([n,r])=>o(Zu(r),([a,i])=>[[n,a],i])),([n,r])=>Qu(r,[...t,n]),()=>[t,e]),bx=e=>o(o(Qu(e),([t,n])=>o(o(o(Xu(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[yp(t),n]),Ro=e=>o(o(c("{",e),([t,n])=>o(bx(n),([r,a])=>o(c("}",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Ip(t),n]),vx=e=>o(Ro(e),([t,n])=>[bp(t),n]),Tx=e=>o(o(o(H(e),([t,n])=>o(c("?",n),([r,a])=>o(c(":",a),([i,m])=>o(c("readonly",m),([u,l])=>o(R(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[t,n],()=>o(o(H(e),([t,n])=>o(c(":",n),([r,a])=>o(c("readonly",a),([i,m])=>o(R(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[t,n],()=>o(o(H(e),([t,n])=>o(c("?",n),([r,a])=>o(c(":",a),([i,m])=>o(R(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[t,n],()=>o(o(H(e),([t,n])=>o(c(":",n),([r,a])=>o(R(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>[])))),([t,n])=>[vp(t),n]),$x=e=>o(o(c("readonly",e),([t,n])=>o(R(n),([r,a])=>o(c("?",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Tp(t),n]),kx=e=>o(o(c("readonly",e),([t,n])=>o(R(n),([r,a])=>[[t,r],a])),([t,n])=>[$p(t),n]),wx=e=>o(o(R(e),([t,n])=>o(c("?",n),([r,a])=>[[t,r],a])),([t,n])=>[kp(t),n]),Lu=e=>o(o(Tx(e),([t,n])=>[t,n],()=>o($x(e),([t,n])=>[t,n],()=>o(kx(e),([t,n])=>[t,n],()=>o(wx(e),([t,n])=>[t,n],()=>o(R(e),([t,n])=>[t,n],()=>[]))))),([t,n])=>[t,n]),ec=e=>o(o(o(c("...",e),([t,n])=>o(Lu(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(Lu(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[])),([t,n])=>[wp(t),n]),tc=(e,t=[])=>o(o(ec(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>tc(r,[...t,n]),()=>[t,e]),Ex=e=>o(o(tc(e),([t,n])=>o(o(o(ec(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[Ep(t),n]),Sx=e=>o(o(c("[",e),([t,n])=>o(Ex(n),([r,a])=>o(c("]",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Sp(t),n]),Rx=e=>o(o(H(e),([t,n])=>o(c("?",n),([r,a])=>o(c(":",a),([i,m])=>o(c("readonly",m),([u,l])=>o(R(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[Rp(t),n]),Ox=e=>o(o(H(e),([t,n])=>o(c(":",n),([r,a])=>o(c("readonly",a),([i,m])=>o(R(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[Op(t),n]),Px=e=>o(o(H(e),([t,n])=>o(c("?",n),([r,a])=>o(c(":",a),([i,m])=>o(R(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[Pp(t),n]),Ax=e=>o(o(H(e),([t,n])=>o(c(":",n),([r,a])=>o(R(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Ap(t),n]),qu=e=>o(o(Rx(e),([t,n])=>[t,n],()=>o(Ox(e),([t,n])=>[t,n],()=>o(Px(e),([t,n])=>[t,n],()=>o(Ax(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),nc=e=>o(o(o(c("...",e),([t,n])=>o(qu(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(qu(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[])),([t,n])=>[Cp(t),n]),rc=(e,t=[])=>o(o(nc(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>rc(r,[...t,n]),()=>[t,e]),ac=e=>o(o(rc(e),([t,n])=>o(o(o(nc(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[Mp(t),n]),Cx=e=>o(o(c("(",e),([t,n])=>o(ac(n),([r,a])=>o(c(")",a),([i,m])=>o(c("=>",m),([u,l])=>o(R(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[Lp(t),n]),Mx=e=>o(o(c("new",e),([t,n])=>o(c("(",n),([r,a])=>o(ac(a),([i,m])=>o(c(")",m),([u,l])=>o(c("=>",l),([f,h])=>o(R(h),([v,E])=>[[t,r,i,u,f,v],E])))))),([t,n])=>[qp(t),n]),Lx=e=>o(o(o(c("+",e),([t,n])=>o(c("readonly",n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c("-",e),([t,n])=>o(c("readonly",n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c("readonly",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])))),([t,n])=>[jp(t),n]),qx=e=>o(o(o(c("+",e),([t,n])=>o(c("?",n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c("-",e),([t,n])=>o(c("?",n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c("?",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])))),([t,n])=>[Fp(t),n]),jx=e=>o(o(o(c("as",e),([t,n])=>o(R(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[Dp(t),n]),Fx=e=>o(o(c("{",e),([t,n])=>o(Lx(n),([r,a])=>o(c("[",a),([i,m])=>o(H(m),([u,l])=>o(c("in",l),([f,h])=>o(R(h),([v,E])=>o(jx(E),([A,F])=>o(c("]",F),([Y,ae])=>o(qx(ae),([me,at])=>o(c(":",at),([_,ot])=>o(R(ot),([it,Ue])=>o(Gu(Ue),([pe,Ke])=>o(c("}",Ke),([Vt,dt])=>[[t,r,i,u,f,v,A,Y,me,_,it,pe,Vt],dt]))))))))))))),([t,n])=>[Gp(t),n]),Dx=e=>o(H(e),([t,n])=>[Np(t),n]),Gx=e=>o(To(e),([t,n])=>[_p(t),n]),Nx=e=>o(xa(e),([t,n])=>[Up(t),n]),_x=e=>o(o(c("true",e),([t,n])=>[t,n],()=>o(c("false",e),([t,n])=>[t,n],()=>[])),([t,n])=>[Kp(t),n]),Ux=e=>o(Ia(['"',"'"],e),([t,n])=>[t,n]),Kx=e=>o(c("null",e),([t,n])=>[zp(t),n]),zx=e=>o(c("undefined",e),([t,n])=>[void 0,n]),oc=e=>o(o(Ju(e),([t,n])=>o(c(":",n),([r,a])=>o(Oo(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Bp(t),n]),ic=(e,t=[])=>o(o(oc(e),([n,r])=>o(Zu(r),([a,i])=>[[n,a],i])),([n,r])=>ic(r,[...t,n]),()=>[t,e]),Bx=e=>o(o(ic(e),([t,n])=>o(o(o(oc(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[Vp(t),n]),sc=e=>o(o(c("{",e),([t,n])=>o(Bx(n),([r,a])=>o(c("}",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Wp(t),n]),mc=(e,t=[])=>o(o(Oo(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>mc(r,[...t,n]),()=>[t,e]),Vx=e=>o(o(mc(e),([t,n])=>o(o(o(Oo(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[Hp(t),n]),Wx=e=>o(o(c("[",e),([t,n])=>o(Vx(n),([r,a])=>o(c("]",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Yp(t),n]),Oo=e=>o(o(Gx(e),([t,n])=>[t,n],()=>o(Nx(e),([t,n])=>[t,n],()=>o(_x(e),([t,n])=>[t,n],()=>o(Ux(e),([t,n])=>[t,n],()=>o(Kx(e),([t,n])=>[t,n],()=>o(zx(e),([t,n])=>[t,n],()=>o(sc(e),([t,n])=>[t,n],()=>o(Wx(e),([t,n])=>[t,n],()=>[])))))))),([t,n])=>[t,n]),Hx=e=>o(c("-?(?:0|[1-9][0-9]*)n",e),([t,n])=>[Jp(t),n]),Yx=e=>o(c(".*",e),([t,n])=>[Xp(t),n]),Jx=e=>o(c("-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?",e),([t,n])=>[Zp(t),n]),Xx=e=>o(c("-?(?:0|[1-9][0-9]*)",e),([t,n])=>[Qp(t),n]),Zx=e=>o(c("(?!)",e),([t,n])=>[eu(t),n]),Qx=e=>o(Mu(["-?(?:0|[1-9][0-9]*)n",".*","-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?","-?(?:0|[1-9][0-9]*)","(?!)","(",")","$","|"],e),([t,n])=>[tu(t),n]),eI=e=>o(o(Hx(e),([t,n])=>[t,n],()=>o(Yx(e),([t,n])=>[t,n],()=>o(Jx(e),([t,n])=>[t,n],()=>o(Xx(e),([t,n])=>[t,n],()=>o(Zx(e),([t,n])=>[t,n],()=>o(tI(e),([t,n])=>[t,n],()=>o(Qx(e),([t,n])=>[t,n],()=>[]))))))),([t,n])=>[t,n]),tI=e=>o(o(c("(",e),([t,n])=>o(Po(n),([r,a])=>o(c(")",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[nu(t),n]),pc=e=>o(o(o(wo(e),([t,n])=>o(c("|",n),([r,a])=>o(pc(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o(o(wo(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[]))),([t,n])=>[ru(t),n]),wo=e=>o(o(eI(e),([t,n])=>o(Po(n),([r,a])=>[[t,r],a])),([t,n])=>[au(t),n]),Po=e=>o(o(pc(e),([t,n])=>[t,n],()=>o(wo(e),([t,n])=>[t,n],()=>[])),([t,n])=>[t,n]),Fs=e=>o(o(c("^",e),([t,n])=>o(Po(n),([r,a])=>o(c("$",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[ou(t),n]),uc=(e,t=[])=>o(o(R(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>uc(r,[...t,n]),()=>[t,e]),nI=e=>o(o(uc(e),([t,n])=>o(o(o(R(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[iu(t),n]),cc=e=>o(o(o(c("extends",e),([t,n])=>o(nI(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[su(t),n]),rI=e=>o(o(c("interface",e),([t,n])=>o(H(n),([r,a])=>o(Eo(a),([i,m])=>o(cc(m),([u,l])=>o(Ro(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[mu(t),n]),aI=e=>o(o(c("interface",e),([t,n])=>o(H(n),([r,a])=>o(cc(a),([i,m])=>o(Ro(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[pu(t),n]),oI=e=>o(o(c("type",e),([t,n])=>o(H(n),([r,a])=>o(Eo(a),([i,m])=>o(c("=",m),([u,l])=>o(R(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[uu(t),n]),iI=e=>o(o(c("type",e),([t,n])=>o(H(n),([r,a])=>o(c("=",a),([i,m])=>o(R(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[cu(t),n]),sI=e=>o(o(o(c("export",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[lu(t),n]),mI=e=>o(o(o(c(";",e),([t,n])=>o(c(`
8
+ `,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))))),([t,n])=>[t,n]),Zu=(e,t=[])=>o(o(Ju(e),([n,r])=>o(Xu(r),([a,i])=>[[n,a],i])),([n,r])=>Zu(r,[...t,n]),()=>[t,e]),Ix=e=>o(o(Zu(e),([t,n])=>o(o(o(Ju(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[gp(t),n]),Ro=e=>o(o(c("{",e),([t,n])=>o(Ix(n),([r,a])=>o(c("}",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[xp(t),n]),vx=e=>o(Ro(e),([t,n])=>[bp(t),n]),Tx=e=>o(o(o(H(e),([t,n])=>o(c("?",n),([r,a])=>o(c(":",a),([i,m])=>o(c("readonly",m),([u,l])=>o(R(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[t,n],()=>o(o(H(e),([t,n])=>o(c(":",n),([r,a])=>o(c("readonly",a),([i,m])=>o(R(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[t,n],()=>o(o(H(e),([t,n])=>o(c("?",n),([r,a])=>o(c(":",a),([i,m])=>o(R(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[t,n],()=>o(o(H(e),([t,n])=>o(c(":",n),([r,a])=>o(R(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>[])))),([t,n])=>[Ip(t),n]),$x=e=>o(o(c("readonly",e),([t,n])=>o(R(n),([r,a])=>o(c("?",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[vp(t),n]),kx=e=>o(o(c("readonly",e),([t,n])=>o(R(n),([r,a])=>[[t,r],a])),([t,n])=>[Tp(t),n]),wx=e=>o(o(R(e),([t,n])=>o(c("?",n),([r,a])=>[[t,r],a])),([t,n])=>[$p(t),n]),Mu=e=>o(o(Tx(e),([t,n])=>[t,n],()=>o($x(e),([t,n])=>[t,n],()=>o(kx(e),([t,n])=>[t,n],()=>o(wx(e),([t,n])=>[t,n],()=>o(R(e),([t,n])=>[t,n],()=>[]))))),([t,n])=>[t,n]),Qu=e=>o(o(o(c("...",e),([t,n])=>o(Mu(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(Mu(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[])),([t,n])=>[kp(t),n]),ec=(e,t=[])=>o(o(Qu(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>ec(r,[...t,n]),()=>[t,e]),Ex=e=>o(o(ec(e),([t,n])=>o(o(o(Qu(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[wp(t),n]),Sx=e=>o(o(c("[",e),([t,n])=>o(Ex(n),([r,a])=>o(c("]",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Ep(t),n]),Rx=e=>o(o(H(e),([t,n])=>o(c("?",n),([r,a])=>o(c(":",a),([i,m])=>o(c("readonly",m),([u,l])=>o(R(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[Sp(t),n]),Ox=e=>o(o(H(e),([t,n])=>o(c(":",n),([r,a])=>o(c("readonly",a),([i,m])=>o(R(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[Rp(t),n]),Px=e=>o(o(H(e),([t,n])=>o(c("?",n),([r,a])=>o(c(":",a),([i,m])=>o(R(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[Op(t),n]),Ax=e=>o(o(H(e),([t,n])=>o(c(":",n),([r,a])=>o(R(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Pp(t),n]),qu=e=>o(o(Rx(e),([t,n])=>[t,n],()=>o(Ox(e),([t,n])=>[t,n],()=>o(Px(e),([t,n])=>[t,n],()=>o(Ax(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),tc=e=>o(o(o(c("...",e),([t,n])=>o(qu(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(qu(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[])),([t,n])=>[Ap(t),n]),nc=(e,t=[])=>o(o(tc(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>nc(r,[...t,n]),()=>[t,e]),rc=e=>o(o(nc(e),([t,n])=>o(o(o(tc(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[Cp(t),n]),Cx=e=>o(o(c("(",e),([t,n])=>o(rc(n),([r,a])=>o(c(")",a),([i,m])=>o(c("=>",m),([u,l])=>o(R(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[Mp(t),n]),Mx=e=>o(o(c("new",e),([t,n])=>o(c("(",n),([r,a])=>o(rc(a),([i,m])=>o(c(")",m),([u,l])=>o(c("=>",l),([f,h])=>o(R(h),([v,E])=>[[t,r,i,u,f,v],E])))))),([t,n])=>[qp(t),n]),qx=e=>o(o(o(c("+",e),([t,n])=>o(c("readonly",n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c("-",e),([t,n])=>o(c("readonly",n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c("readonly",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])))),([t,n])=>[Lp(t),n]),Lx=e=>o(o(o(c("+",e),([t,n])=>o(c("?",n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c("-",e),([t,n])=>o(c("?",n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c("?",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])))),([t,n])=>[jp(t),n]),jx=e=>o(o(o(c("as",e),([t,n])=>o(R(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[Fp(t),n]),Fx=e=>o(o(c("{",e),([t,n])=>o(qx(n),([r,a])=>o(c("[",a),([i,m])=>o(H(m),([u,l])=>o(c("in",l),([f,h])=>o(R(h),([v,E])=>o(jx(E),([A,F])=>o(c("]",F),([Y,ae])=>o(Lx(ae),([me,at])=>o(c(":",at),([_,ot])=>o(R(ot),([it,Ue])=>o(Du(Ue),([pe,Ke])=>o(c("}",Ke),([Vt,dt])=>[[t,r,i,u,f,v,A,Y,me,_,it,pe,Vt],dt]))))))))))))),([t,n])=>[Dp(t),n]),Dx=e=>o(H(e),([t,n])=>[Gp(t),n]),Gx=e=>o(To(e),([t,n])=>[Np(t),n]),Nx=e=>o(xa(e),([t,n])=>[_p(t),n]),_x=e=>o(o(c("true",e),([t,n])=>[t,n],()=>o(c("false",e),([t,n])=>[t,n],()=>[])),([t,n])=>[Up(t),n]),Ux=e=>o(ba(['"',"'"],e),([t,n])=>[t,n]),Kx=e=>o(c("null",e),([t,n])=>[Kp(t),n]),zx=e=>o(c("undefined",e),([t,n])=>[void 0,n]),ac=e=>o(o(Yu(e),([t,n])=>o(c(":",n),([r,a])=>o(Oo(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[zp(t),n]),oc=(e,t=[])=>o(o(ac(e),([n,r])=>o(Xu(r),([a,i])=>[[n,a],i])),([n,r])=>oc(r,[...t,n]),()=>[t,e]),Bx=e=>o(o(oc(e),([t,n])=>o(o(o(ac(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[Bp(t),n]),ic=e=>o(o(c("{",e),([t,n])=>o(Bx(n),([r,a])=>o(c("}",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Vp(t),n]),sc=(e,t=[])=>o(o(Oo(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>sc(r,[...t,n]),()=>[t,e]),Vx=e=>o(o(sc(e),([t,n])=>o(o(o(Oo(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[Wp(t),n]),Wx=e=>o(o(c("[",e),([t,n])=>o(Vx(n),([r,a])=>o(c("]",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Hp(t),n]),Oo=e=>o(o(Gx(e),([t,n])=>[t,n],()=>o(Nx(e),([t,n])=>[t,n],()=>o(_x(e),([t,n])=>[t,n],()=>o(Ux(e),([t,n])=>[t,n],()=>o(Kx(e),([t,n])=>[t,n],()=>o(zx(e),([t,n])=>[t,n],()=>o(ic(e),([t,n])=>[t,n],()=>o(Wx(e),([t,n])=>[t,n],()=>[])))))))),([t,n])=>[t,n]),Hx=e=>o(c("-?(?:0|[1-9][0-9]*)n",e),([t,n])=>[Yp(t),n]),Yx=e=>o(c(".*",e),([t,n])=>[Jp(t),n]),Jx=e=>o(c("-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?",e),([t,n])=>[Xp(t),n]),Xx=e=>o(c("-?(?:0|[1-9][0-9]*)",e),([t,n])=>[Zp(t),n]),Zx=e=>o(c("(?!)",e),([t,n])=>[Qp(t),n]),Qx=e=>o(Cu(["-?(?:0|[1-9][0-9]*)n",".*","-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?","-?(?:0|[1-9][0-9]*)","(?!)","(",")","$","|"],e),([t,n])=>[eu(t),n]),eb=e=>o(o(Hx(e),([t,n])=>[t,n],()=>o(Yx(e),([t,n])=>[t,n],()=>o(Jx(e),([t,n])=>[t,n],()=>o(Xx(e),([t,n])=>[t,n],()=>o(Zx(e),([t,n])=>[t,n],()=>o(tb(e),([t,n])=>[t,n],()=>o(Qx(e),([t,n])=>[t,n],()=>[]))))))),([t,n])=>[t,n]),tb=e=>o(o(c("(",e),([t,n])=>o(Po(n),([r,a])=>o(c(")",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[tu(t),n]),mc=e=>o(o(o(wo(e),([t,n])=>o(c("|",n),([r,a])=>o(mc(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o(o(wo(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[]))),([t,n])=>[nu(t),n]),wo=e=>o(o(eb(e),([t,n])=>o(Po(n),([r,a])=>[[t,r],a])),([t,n])=>[ru(t),n]),Po=e=>o(o(mc(e),([t,n])=>[t,n],()=>o(wo(e),([t,n])=>[t,n],()=>[])),([t,n])=>[t,n]),js=e=>o(o(c("^",e),([t,n])=>o(Po(n),([r,a])=>o(c("$",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[au(t),n]),pc=(e,t=[])=>o(o(R(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>pc(r,[...t,n]),()=>[t,e]),nb=e=>o(o(pc(e),([t,n])=>o(o(o(R(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[ou(t),n]),uc=e=>o(o(o(c("extends",e),([t,n])=>o(nb(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[iu(t),n]),rb=e=>o(o(c("interface",e),([t,n])=>o(H(n),([r,a])=>o(Eo(a),([i,m])=>o(uc(m),([u,l])=>o(Ro(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[su(t),n]),ab=e=>o(o(c("interface",e),([t,n])=>o(H(n),([r,a])=>o(uc(a),([i,m])=>o(Ro(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[mu(t),n]),ob=e=>o(o(c("type",e),([t,n])=>o(H(n),([r,a])=>o(Eo(a),([i,m])=>o(c("=",m),([u,l])=>o(R(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[pu(t),n]),ib=e=>o(o(c("type",e),([t,n])=>o(H(n),([r,a])=>o(c("=",a),([i,m])=>o(R(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[uu(t),n]),sb=e=>o(o(o(c("export",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[cu(t),n]),mb=e=>o(o(o(c(";",e),([t,n])=>o(c(`
9
9
  `,n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c(";",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o(o(c(`
10
- `,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))),([t,n])=>[t,n]),lc=(e,t=[])=>o(o(Ao(e),([n,r])=>o(mI(r),([a,i])=>[[n,a],i])),([n,r])=>lc(r,[...t,n]),()=>[t,e]),pI=e=>o(o(lc(e),([t,n])=>o(o(o(Ao(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[du(t),n]),Ao=e=>o(o(sI(e),([t,n])=>o(o(rI(n),([r,a])=>[r,a],()=>o(aI(n),([r,a])=>[r,a],()=>o(oI(n),([r,a])=>[r,a],()=>o(iI(n),([r,a])=>[r,a],()=>[])))),([r,a])=>o(Gu(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[fu(t),n]),uI=e=>o(o(Ao(e),([t,n])=>o(pI(n),([r,a])=>[[t,r],a])),([t,n])=>[hu(t),n]),dc=e=>o(o(uI(e),([t,n])=>[t,n],()=>o(lx(e),([t,n])=>[t,n],()=>o(R(e),([t,n])=>[t,n],()=>[]))),([t,n])=>[t,n]);function fc(e){let t=So(`\`${e}\``);return s.IsEqual(t.length,2)?t[0]:X()}function lI(e){return e.join("|")}function dI(e){return e.slice(1,e.length-1)}function fI(e,t,n){return wt(t,`${n}${e}`)}function hI(e,t){return wt(e,`${t}${As}`)}function gI(e,t){return wt(e,`${t}${Lr}`)}function yI(e,t){return wt(e,`${t}${jr}`)}function xI(e,t){return Hn(w([P("false"),P("true")]),e,t)}function II(e,t){return wt(e,`${t}${Fr}`)}function bI(e,t,n){return wt(t,`${n}${dI(e)}`)}function vI(e,t,n){let r=Yn(e,{});return Hn(r,t,n)}function TI(e,t,n){let r=Oe(e);return Hn(r,t,n)}function hc(e,t,n,r=[]){return s.ShiftLeft(e,(a,i)=>hc(i,t,n,[...r,Hn(a,[],"")]),()=>wt(t,`${n}(${lI(r)})`))}function Hn(e,t,n){return xe(e)?TI(e.enum,t,n):Ie(e)?gI(t,n):q(e)?fI(e.const,t,n):Xe(e)?hI(t,n):Ce(e)?xI(t,n):Q(e)?yI(t,n):be(e)?II(t,n):ee(e)?bI(e.pattern,t,n):yc(e)?vI(e.parameters[0],t,n):x(e)?hc(e.anyOf,t,n):ls}function wt(e,t){return s.ShiftLeft(e,(n,r)=>Hn(n,r,t),()=>t)}function $I(e){return`^${wt(e,"")}$`}function gc(e){let t=$I(e);return Gr(t)}function Yn(e,t){return k(e)?p.Update(gc(e),{},t):Hr(e,t)}function xc(e,t,n,r){let a=Pe(e,t,n);return Yn(a,r)}function Hr(e,t={}){return I("TemplateLiteral",[e],t)}function yc(e){return ne(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"TemplateLiteral")}function Ic(e){return Yn(e,{})}function kI(e){let t=fc(e);return Ic(t)}function bc(e,t={}){let n=s.IsString(e)?kI(e):Ic(e);return p.Update(n,{},t)}function ee(e){return y(e,"TemplateLiteral")}var b={};Rt(b,{ExtendsFalse:()=>$,ExtendsTrue:()=>g,ExtendsUnion:()=>Co,IsExtendsFalse:()=>wI,IsExtendsTrue:()=>Tc,IsExtendsTrueLike:()=>cn,IsExtendsUnion:()=>vc,Match:()=>K});function Co(e){return p.Create({"~kind":"ExtendsUnion"},{inferred:e})}function vc(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsUnion")&&s.IsObject(e.inferred)}function g(e){return p.Create({"~kind":"ExtendsTrue"},{inferred:e})}function Tc(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsTrue")&&s.IsObject(e.inferred)}function $(){return p.Create({"~kind":"ExtendsFalse"},{})}function wI(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],"ExtendsFalse")}function cn(e){return vc(e)||Tc(e)}function K(e,t,n){return cn(e)?t(e.inferred):n()}function EI(e,t,n,r){return K(C(e,n,r),a=>g(p.Assign(p.Assign(e,a),{[t]:n})),()=>$())}function SI(e,t){return g(e)}function RI(e,t,n,r,a){return K(C(e,t,n),i=>K(C(i,t,r),m=>g(m),()=>$()),()=>K(C(e,t,a),i=>g(i),()=>$()))}function OI(e,t,n){let r=Oe(n);return C(e,t,r)}function $c(e,t,n){return s.ShiftLeft(n,(r,a)=>K(C(e,t,r),i=>$c(i,t,a),()=>$()),()=>g(e))}function PI(e,t,n){let r=ke(n);return C(e,t,r)}function kc(e,t,n){return s.ShiftLeft(n,(r,a)=>K(C(e,t,r),i=>g(i),()=>kc(e,t,a)),()=>$())}function j(e,t,n){return Z(n)?SI(e,t):W(n)?RI(e,t,n.if,n.then,n.else):xe(n)?OI(e,t,n.enum):J(n)?EI(e,n.name,t,n.extends):O(n)?$c(e,t,n.allOf):ee(n)?PI(e,t,n.pattern):x(n)?kc(e,t,n.anyOf):re(n)?g(e):$()}function wc(e,t,n){return J(n)?j(e,t,n):Z(n)?g(e):re(n)?g(e):Co(e)}function AI(e,t){let n=Lt(e),r=Lt(t);return n&&r||!n&&r?!0:!(n&&!r)}function Ec(e,t,n,r){return z(r)?AI(t,r)?C(e,n,r.items):$():j(e,t,r)}function Sc(e,t,n){return Xe(n)?g(e):j(e,t,n)}function Rc(e,t,n){return Ce(n)?g(e):j(e,t,n)}function CI(e,t,n,r,a){let i=J(r)?t:r,m=J(r)?r:t,u=ge(t),l=ge(r);return!u&&l?$():K(C(e,i,m),f=>Jn(f,n,a),()=>$())}function MI(e,t,n,r){return s.ShiftLeft(r,(a,i)=>CI(e,t,n,a,i),()=>ge(t)?g(e):$())}function LI(e,t,n){return s.ShiftLeft(t,(r,a)=>MI(e,r,a,n),()=>g(e))}function Jn(e,t,n){return LI(e,t,n)}function va(e,t,n){return Ze(n)?g(e):C(e,t,n)}function Oc(e,t,n,r){return Z(r)?g(e):re(r)?g(e):oe(r)?K(Jn(e,t,r.parameters),a=>va(a,n,r.instanceType),()=>$()):$()}function Pc(e,t,n,r,a){return K(C(e,t,a),()=>C(e,n,a),()=>C(e,r,a))}function Ac(e,t,n){let r=Oe(t);return C(e,r,n)}function Cc(e,t,n,r){return Z(r)?g(e):re(r)?g(e):ie(r)?K(Jn(e,t,r.parameters),a=>va(a,n,r.returnType),()=>$()):$()}function Mc(e,t,n){return Ie(n)?g(e):Q(n)?g(e):j(e,t,n)}function Lc(e,t,n){let r=B(t);return C(e,r,n)}function Ta(e,t,n){return t===n?g(e):$()}function qI(e,t,n){return q(n)?Ta(e,t,n.const):Xe(n)?g(e):j(e,P(t),n)}function jI(e,t,n){return q(n)?Ta(e,t,n.const):Ce(n)?g(e):j(e,P(t),n)}function FI(e,t,n){return q(n)?Ta(e,t,n.const):Q(n)?g(e):j(e,P(t),n)}function DI(e,t,n){return q(n)?Ta(e,t,n.const):be(n)?g(e):j(e,P(t),n)}function qc(e,t,n){return s.IsBigInt(t.const)?qI(e,t.const,n):s.IsBoolean(t.const)?jI(e,t.const,n):s.IsNumber(t.const)?FI(e,t.const,n):s.IsString(t.const)?DI(e,t.const,n):X()}function jc(e,t,n){return J(n)?j(e,t,n):g(e)}function Fc(e,t,n){return en(n)?g(e):j(e,t,n)}function Dc(e,t,n){return Q(n)?g(e):j(e,t,n)}function GI(e,t,n){return ge(t)?ge(n)?g(e):$():g(e)}function NI(e,t,n){return J(n)&&xt(n.extends)?$():K(C(e,t,n),r=>GI(r,t,n),()=>$())}function _I(e,t){return e.reduce((n,r)=>r in t?cn(t[r])?{...n,...t[r].inferred}:X():X(),{})}function UI(e,t,n){let r={};for(let m of s.Keys(n))r[m]=m in t?NI({},t[m],n[m]):ge(n[m])?J(n[m])?g(p.Assign(e,{[n[m].name]:n[m].extends})):g(e):$();let a=s.Values(r).every(m=>cn(m)),i=a?_I(s.Keys(r),r):{};return a?g(i):$()}function KI(e,t,n){let r=UI(e,t,n);return cn(r)?g(p.Assign(e,r.inferred)):$()}function zI(e,t,n){return KI(e,t,n)}function BI(e,t){return s.Keys(t).reduce((n,r)=>({...n,[r]:s.HasPropertyKey(e,r)?x(n[r])?w([...n[r].anyOf,t[r]]):w([e[r],t[r]]):t[r]}),e)}function Gc(e,t,n,r){return s.ShiftLeft(t,(a,i)=>K(C({},e[a],n),m=>Gc(e,i,n,BI(r,m)),()=>$()),()=>g(r))}function VI(e,t,n,r){let a=s.Keys(t);return Gc(t,a,r,e)}function Nc(e,t,n){return fe(n)?VI(e,t,qe(n),ve(n)):L(n)?zI(e,t,n.properties):j(e,T(t),n)}function WI(e,t){return s.IsEqual(s.Keys(t).length,0)?g(e):$()}function HI(e,t,n,r,a){return C(e,n,a)}function _c(e,t,n,r){return fe(r)?HI(e,zr(t),n,zr(qe(r)),ve(r)):L(r)?WI(e,r.properties):Z(r)?g(e):re(r)?g(e):$()}function Uc(e,t,n){return be(n)?g(e):j(e,t,n)}function Kc(e,t,n){return It(n)?g(e):j(e,t,n)}function zc(e,t,n){let r=ke(t);return C(e,r,n)}function Mo(e,t){return p.Create({"~kind":"Inferrable"},{name:e,type:t},{})}function Xn(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"name")&&s.HasPropertyKey(e,"type")&&s.IsEqual(e["~kind"],"Inferrable")&&s.IsString(e.name)&&s.IsObject(e.type)}function Lo(e){return Tt(e)?J(e.items)?z(e.items.extends)?Mo(e.items.name,e.items.extends.items):re(e.items.extends)?Mo(e.items.name,e.items.extends):void 0:X():void 0}function $a(e){return J(e)?Mo(e.name,e.extends):void 0}function qo(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>K(C({},r,t),()=>qo(a,t,[...n,r]),()=>{}),()=>n)}function Bc(e,t,n,r){let a=qo(n,r);return s.IsArray(a)?g(p.Assign(e,{[t]:te(a)})):$()}function ka(e,t,n,r){let a=qo(n,r);return s.IsArray(a)?g(p.Assign(e,{[t]:w(a)})):$()}function YI(e){return[...e].reverse()}function jo(e,t){return t?YI(e):e}function JI(e){let t=e.length>0?e[0]:void 0,n=ne(t)?Lo(t):void 0;return ne(n)}function XI(e,t,n,r,a,i){return K(C(e,n,a),m=>Vc(m,t,r,i),()=>$())}function ZI(e,t,n,r,a){let i=Lo(r);return Xn(i)?Bc(e,i.name,jo(n,t),i.type):s.ShiftLeft(n,(m,u)=>XI(e,t,m,u,r,a),()=>$())}function QI(e,t,n,r){return s.ShiftLeft(r,(a,i)=>ZI(e,t,n,a,i),()=>s.IsEqual(n.length,0)?g(e):$())}function Vc(e,t,n,r){return QI(e,t,n,r)}function eb(e,t,n){let r=Et(e,U([],[]),n),a=JI(r);return Vc(e,a,jo(t,a),jo(r,a))}function Wc(e,t,n){let r=$a(n);return Xn(r)?ka(e,r.name,t,r.type):s.ShiftLeft(t,(a,i)=>K(C(e,a,n),m=>Wc(m,i,n),()=>$()),()=>g(e))}function Hc(e,t,n){let r=Et(e,U([],[]),t);return N(n)?eb(e,r,n.items):z(n)?Wc(e,r,n.items):j(e,te(r),n)}function Yc(e,t,n){return Ze(n)?g(e):sn(n)?g(e):j(e,t,n)}function Jc(e,t,n){return s.ShiftLeft(n,(r,a)=>K(C(e,t,r),i=>g(i),()=>Jc(e,t,a)),()=>$())}function Fo(e,t,n){return s.ShiftLeft(t,(r,a)=>K(Jc(e,r,n),i=>Fo(i,a,n),()=>$()),()=>g(e))}function Xc(e,t,n){let r=$a(n);return Xn(r)?ka(e,r.name,t,r.type):x(n)?Fo(e,t,n.anyOf):Fo(e,t,[n])}function Zc(e,t,n){return J(n)?j(e,t,n):Z(n)?g(e):re(n)?g(e):$()}function Qc(e,t,n){return Ze(n)?g(e):j(e,t,n)}function C(e,t,n){return Z(t)?wc(e,t,n):z(t)?Ec(e,t,t.items,n):Xe(t)?Sc(e,t,n):Ce(t)?Rc(e,t,n):oe(t)?Oc(e,t.parameters,t.instanceType,n):W(t)?Pc(e,t.if,t.then,t.else,n):xe(t)?Ac(e,t.enum,n):ie(t)?Cc(e,t.parameters,t.returnType,n):Ie(t)?Mc(e,t,n):O(t)?Lc(e,t.allOf,n):q(t)?qc(e,t,n):xt(t)?jc(e,t,n):en(t)?Fc(e,t,n):Q(t)?Dc(e,t,n):L(t)?Nc(e,t.properties,n):fe(t)?_c(e,qe(t),ve(t),n):be(t)?Uc(e,t,n):It(t)?Kc(e,t,n):ee(t)?zc(e,t.pattern,n):N(t)?Hc(e,t.items,n):sn(t)?Yc(e,t,n):x(t)?Xc(e,t.anyOf,n):re(t)?Zc(e,t,n):Ze(t)?Qc(e,t,n):$()}function tb(e,t){return B([...e,T(t)])}function Do(e,t,n){return k(e)?p.Update(tb(e,t),{},n):Kn(e,t,n)}function el(e,t,n,r,a){let i=Pe(e,t,n),m=Zn(e,t,r);return Do(i,m,a)}function Kn(e,t,n={}){return I("Interface",[e,t],n)}function ln(e){return ne(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"Interface")}function tl(e,t,n={}){return Do(e,t,n)}function nb(e,t,n){return e.includes(n)?!0:Qn([...e,n],t,t[n])}function nl(e,t,n){let r=Or(n);return _t(e,t,r)}function _t(e,t,n){return s.ShiftLeft(n,(r,a)=>Qn(e,t,r)?!0:_t(e,t,a),()=>!1)}function Qn(e,t,n){return se(n)?nb(e,t,n.$ref):z(n)?Qn(e,t,n.items):oe(n)?_t(e,t,[...n.parameters,n.instanceType]):ie(n)?_t(e,t,[...n.parameters,n.returnType]):ln(n)?nl(e,t,n.parameters[1]):O(n)?_t(e,t,n.allOf):L(n)?nl(e,t,n.properties):x(n)?_t(e,t,n.anyOf):N(n)?_t(e,t,n.items):fe(n)?Qn(e,t,ve(n)):!1}function rl(e,t,n){return Qn(e,t,n)}function rb(e,t){return t.reduce((n,r)=>rl([r],e,e[r])?[...n,r]:n,[])}function al(e){let t=Rr(e);return rb(e,t)}function ab(e,t,n){return n.includes(t)?n:t in e?er(e,e[t],[...n,t]):X()}function ol(e,t,n){let r=Or(t);return dn(e,r,n)}function dn(e,t,n){return t.reduce((r,a)=>er(e,a,r),n)}function er(e,t,n){return se(t)?ab(e,t.$ref,n):z(t)?er(e,t.items,n):oe(t)?dn(e,[...t.parameters,t.instanceType],n):ie(t)?dn(e,[...t.parameters,t.returnType],n):ln(t)?ol(e,t.parameters[1],n):O(t)?dn(e,t.allOf,n):L(t)?ol(e,t.properties,n):x(t)?dn(e,t.anyOf,n):N(t)?dn(e,t.items,n):fe(t)?er(e,ve(t),n):n}function il(e,t,n){return er(e,n,[t])}function ob(e){return Xt()}function ib(e){return s.Keys(e).reduce((t,n)=>({...t,[n]:Ut(e[n])}),{})}function tr(e){return e.reduce((t,n)=>[...t,Ut(n)],[])}function Ut(e){return se(e)?ob(e.$ref):z(e)?Re(Ut(e.items),Sr(e)):oe(e)?Be(tr(e.parameters),Ut(e.instanceType)):ie(e)?Ve(tr(e.parameters),Ut(e.returnType)):O(e)?ye(tr(e.allOf)):L(e)?T(ib(e.properties)):fe(e)?Kr(an(e),Ut(ve(e))):x(e)?w(tr(e.anyOf)):N(e)?te(tr(e.items)):e}function sb(e,t){return t in e?Ut(e[t]):ue()}function sl(e){return sb(e.$defs,e.$ref)}function mb(e,t,n){let r=Pe(e,U([],[]),t),a=Zn({},U([],[]),n);return B([...r,T(a)])}function pb(e,t){return s.Keys(e).filter(r=>t.includes(r)).reduce((r,a)=>{let i=e[a],m=ln(i)?mb(e,i.parameters[0],i.parameters[1]):i;return{...r,[a]:m}},{})}function ml(e,t,n){let r=il(e,t,n),a=pb(e,r);return He(a,t)}function pl(e,t){return t in e?se(e[t])?pl(e,e[t].$ref):e[t]:D()}function Qe(e,t){return pl(e,t)}function ul(e){return le(e)?sl(e):Pr(e)?ue():e}function de(e,t,n){let r=ul(t),a=ul(n);return C(e,r,a)}var Fn="equal",ub="disjoint",Dn="left-inside",Gn="right-inside";function nn(e,t){let n=[re(e)?b.ExtendsFalse():de({},e,t),re(e)?b.ExtendsTrue({}):de({},t,e)];return b.IsExtendsTrueLike(n[0])&&b.IsExtendsTrueLike(n[1])?Fn:b.IsExtendsTrueLike(n[0])&&b.IsExtendsFalse(n[1])?Dn:b.IsExtendsFalse(n[0])&&b.IsExtendsTrueLike(n[1])?Gn:ub}function cb(e,t){return t.filter(n=>nn(e,n)!==Gn)}function lb(e,t){let n=t.some(r=>{let a=nn(e,r);return s.IsEqual(a,Dn)||s.IsEqual(a,Fn)});return s.IsEqual(n,!1)}function db(e,t){let n=Le(e);return Z(n)?[n]:lb(n,t)?[...cb(n,t),n]:t}function fb(e){return e.reduce((t,n)=>L(n)?[...t,n]:xt(n)?t:db(n,t),[])}function go(e){let t=fb(e);return _n(t)}function Go(e,t){return p.Update(Le(e),{},t)}function cl(e,t,n,r){let a=d(e,t,n);return Go(a,r)}function nr(e,t=[]){return gt(e)&&s.IsEqual(e.action,"Conditional")?se(e.parameters[0])?nr(e.parameters[2],nr(e.parameters[3],[...t,e.parameters[0].$ref])):nr(e.parameters[2],nr(e.parameters[3],t)):gt(e)&&s.IsEqual(e.action,"Mapped")&&gt(e.parameters[1])&&s.IsEqual(e.parameters[1].action,"KeyOf")&&se(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t}function hb(e,t){return e.reduce((n,r)=>[...n,t.includes(r.name)],[])}function fl(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>s.ShiftLeft(t,(i,m)=>fl(a,m,[...n,[i,r]]),()=>n),()=>n)}function gb(e){return x(e)?[...e.anyOf]:[e]}function yb(e,t){return e.reduce((n,r)=>[...n,[...r,t]],[])}function ll(e,t){return t.reduce((n,r)=>[...n,...yb(e,r)],[])}function dl(e){return e.reduce((t,n)=>s.IsEqual(n[0],!0)?ll(t,gb(n[1])):ll(t,[n[1]]),[[]])}function hl(e,t,n){let r=nr(n),a=hb(e,r),i=fl(t,a);return gt(n)&&s.IsEqual(n.action,"Conditional")||gt(n)&&s.IsEqual(n.action,"Mapped")?dl(i):[t]}function xb(){return["(not-resolvable)",D()]}function Ib(){return["(not-generic)",D()]}function bb(e,t,n){return[e,yt(t,n)]}function vb(e,t,n){return t in e?gl(e,t,e[t],n):xb()}function gl(e,t,n,r){return Jt(n)?bb(t,n.parameters,n.expression):se(n)?vb(e,n.$ref,r):Ib()}function yl(e,t,n){return gl(e,"(anonymous)",t,n)}function Tb(e,t,n){if(J(t)||fn(t)||b.IsExtendsTrueLike(de({},t,n)))return;let r={parameter:e,expect:n,actual:t};throw new Error(`Argument for parameter ${e} does not satisfy constraint`,{cause:r})}function xl(e,t,n,r,a){let i=d(e,t,a);return Tb(n,i,r),p.Assign(e,{[n]:i})}function $b(e,t,n,r,a){let i=d(e,t,n.extends),m=d(e,t,n.equals);return s.ShiftLeft(a,(u,l)=>No(xl(e,t,n.name,i,u),t,r,l),()=>No(xl(e,t,n.name,i,m),t,r,[]))}function No(e,t,n,r){return s.ShiftLeft(n,(a,i)=>$b(e,t,a,i,r),()=>e)}function Il(e,t,n,r){return No(e,t,n,r)}function kb(e){return s.IsGreaterThan(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}function wb(e,t){return s.IsEqual(kb(e),t)}function Eb(e,t,n,r,a,i){let m=Il(e,t,r,i),u=d(m,U([...t.callstack,n.$ref],t.visited),a);return d(m,U([],[]),u)}function Sb(e,t,n,r,a,i){return i.reduce((m,u)=>[...m,Eb(e,t,n,r,a,u)],[])}function Rb(e,t,n,r,a,i){let m=hl(r,i,a),u=Sb(e,t,n,r,a,m);return s.IsEqual(u.length,1)?u[0]:Ee(u)}function wa(e,t,n,r){let a=Pe(e,t,r),i=yl(e,n,r),m=i[0],u=i[1];return Jt(u)?wb(t,m)?zn(pt(m),a):Rb(e,t,pt(m),u.parameters,u.expression,a):zn(n,a)}function zn(e,t){return p.Create({"~kind":"Call"},{type:"call",target:e,arguments:t},{})}function bl(e,t){return wa({},U([],[]),e,t)}function fn(e){return y(e,"Call")}function Ob(e){return p.Discard(e,["~immutable"])}function vl(e,t){return p.Update(Ob(e),{},t)}function Tl(e,t,n,r){let a=d(e,t,n);return vl(a,r)}function $l(e,t){return e(t)}function kl(e,t){return s.IsString(t)?P($l(e,t)):P(t)}function wl(e,t){let n=ke(t);return lt(e,n)}function El(e,t){let n=t.map(r=>lt(e,r));return w(n)}function lt(e,t){return q(t)?kl(e,t.const):ee(t)?wl(e,t.pattern):x(t)?El(e,t.anyOf):t}function Yr(e,t={}){return I("Capitalize",[e],t)}function Sl(e,t={}){return _o(e,t)}function Jr(e,t={}){return I("Lowercase",[e],t)}function Rl(e,t={}){return Uo(e,t)}function Xr(e,t={}){return I("Uncapitalize",[e],t)}function Ol(e,t={}){return Ko(e,t)}function Zr(e,t={}){return I("Uppercase",[e],t)}function Pl(e,t={}){return zo(e,t)}var Pb=e=>e[0].toUpperCase()+e.slice(1),Ab=e=>e.toLowerCase(),Cb=e=>e[0].toLowerCase()+e.slice(1),Mb=e=>e.toUpperCase();function _o(e,t){return k([e])?p.Update(lt(Pb,e),{},t):Yr(e,t)}function Uo(e,t){return k([e])?p.Update(lt(Ab,e),{},t):Jr(e,t)}function Ko(e,t){return k([e])?p.Update(lt(Cb,e),{},t):Xr(e,t)}function zo(e,t){return k([e])?p.Update(lt(Mb,e),{},t):Zr(e,t)}function Al(e,t,n,r){let a=d(e,t,n);return _o(a,r)}function Cl(e,t,n,r){let a=d(e,t,n);return Uo(a,r)}function Ml(e,t,n,r){let a=d(e,t,n);return Ko(a,r)}function Ll(e,t,n,r){let a=d(e,t,n);return zo(a,r)}function Qr(e,t,n,r,a={}){return I("Conditional",[e,t,n,r],a)}function ql(e,t,n,r,a={}){return Bo({},U([],[]),e,t,n,r,a)}function Lb(e,t,n,r,a,i){let m=de(e,n,r);return b.IsExtendsUnion(m)?w([d(m.inferred,t,a),d(e,t,i)]):b.IsExtendsTrue(m)?d(m.inferred,t,a):d(e,t,i)}function Bo(e,t,n,r,a,i,m){return k([n,r])?p.Update(Lb(e,t,n,r,a,i),{},m):Qr(n,r,a,i,m)}function jl(e,t,n,r,a,i,m){let u=d(e,t,n),l=d(e,t,r);return Bo(e,t,u,l,a,i,m)}function ea(e,t={}){return I("ConstructorParameters",[e],t)}function Fl(e,t={}){return Vo(e,t)}function qb(e){let t=oe(e)?e.parameters:[],n=Et({},U([],[]),t);return te(n)}function Vo(e,t){return k([e])?p.Update(qb(e),{},t):ea(e,t)}function Dl(e,t,n,r){let a=d(e,t,n);return Vo(a,r)}function ta(e,t,n={}){return I("Exclude",[e,t],n)}function Gl(e,t,n={}){return rr(e,t,n)}function rr(e,t,n){return k([e,t])?p.Update(_r(e,t),{},n):ta(e,t,n)}function Nl(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return rr(i,m,a)}function na(e,t,n={}){return I("Extract",[e,t],n)}function _l(e,t,n={}){return Wo(e,t,n)}function jb(e,t){let n=de({},e,t);return b.IsExtendsTrueLike(n)?[e]:[]}function Fb(e,t){return e.reduce((n,r)=>[...n,...jb(r,t)],[])}function Ul(e,t){let n=Le(e),r=x(n)?n.anyOf:[n],a=Fb(r,t);return Ee(a)}function Wo(e,t,n){return k([e,t])?p.Update(Ul(e,t),{},n):na(e,t,n)}function Kl(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return Wo(i,m,a)}function Db(e){return e.reduce((t,n)=>qr(n)?[...t,P(n)]:t,[])}function hn(e){let t=Db(e);return w(t)}function Bn(e,t,n={}){return I("Index",[e,t],n)}function zl(e,t,n={}){let r=s.IsArray(t)?hn(t):t;return Ho(e,r,n)}function Bl(e,t){let n=Qe(e,t);return Ae(n)}function Vl(e,t,n){let r=_e(e,t,n);return Ae(r)}function Gb(e,t){let n=s.Keys(e).filter(h=>!s.HasPropertyKey(t,h)),r=s.Keys(t).filter(h=>!s.HasPropertyKey(e,h)),a=s.Keys(e).filter(h=>s.HasPropertyKey(t,h)),i=n.reduce((h,v)=>({...h,[v]:e[v]}),{}),m=r.reduce((h,v)=>({...h,[v]:t[v]}),{}),u=a.reduce((h,v)=>({...h,[v]:B([e[v],t[v]])}),{}),l=p.Assign(i,m);return p.Assign(l,u)}function Wl(e){return e.reduce((t,n)=>Gb(t,Ae(n)),{})}function Hl(e){let t=Qs(te(e));return Ae(t)}function Nb(e,t){return s.Keys(e).filter(a=>a in t).reduce((a,i)=>({...a,[i]:Ee([e[i],t[i]])}),{})}function Yl(e,t){return s.ShiftLeft(e,(n,r)=>Yl(r,Nb(t,Ae(n))),()=>t)}function Jl(e){return s.ShiftLeft(e,(t,n)=>Yl(n,Ae(t)),()=>X())}function Ae(e){return le(e)?Bl(e.$defs,e.$ref):W(e)?Vl(e.if,e.then,e.else):O(e)?Wl(e.allOf):x(e)?Jl(e.anyOf):N(e)?Hl(e.items):L(e)?e.properties:{}}function gn(e){let t=Ae(e);return T(t)}var _b=new RegExp("^(?:0|[1-9][0-9]*)$");function yn(e){let t=`${e}`;return _b.test(t)?parseInt(t):e}function Ub(e){return P(yn(e))}function Xl(e){return e.map(t=>Zl(t))}function Zl(e){return O(e)?ye(Xl(e.allOf)):x(e)?w(Xl(e.anyOf)):q(e)?Ub(e.const):e}function Ql(e,t){let n=Zl(t),r=de({},n,we());return b.IsExtendsTrueLike(r)?e:q(t)&&s.IsEqual(t.const,"length")?we():D()}function ed(e,t){let n=Qe(e,t);return Se(n)}function td(e,t,n){let r=_e(e,t,n);return Se(r)}function nd(e){let t=Oe(e);return Se(t)}function rd(e){let t=B(e);return Se(t)}function ad(e){return[`${e}`]}function od(e){let t=ke(e);return Se(t)}function id(e){return e.reduce((t,n)=>[...t,...Se(n)],[])}function Se(e){return le(e)?ed(e.$defs,e.$ref):W(e)?td(e.if,e.then,e.else):xe(e)?nd(e.enum):O(e)?rd(e.allOf):q(e)?ad(e.const):ee(e)?od(e.pattern):x(e)?id(e.anyOf):[]}function xn(e){return Se(e)}function ar(e,t){return t.map(n=>or(e,n))}function or(e,t){return z(t)?Re(or(e,t.items)):oe(t)?Be(ar(e,t.parameters),or(e,t.instanceType)):ie(t)?Ve(ar(e,t.parameters),or(e,t.returnType)):N(t)?te(ar(e,t.items)):x(t)?w(ar(e,t.anyOf)):O(t)?ye(ar(e,t.allOf)):Vr(t)?T(e):t}function sd(e,t){return or(e,t)}function Kb(e,t){let n=t in e?e[t]:D();return sd(e,n)}function md(e,t){return t.reduce((n,r)=>[...n,Kb(e,r)],[])}function zb(e,t){let n=xn(t),r=md(e,n);return Ee(r)}var Bb=new RegExp(vt);function Vb(e){return e.filter(n=>Bb.test(n))}function Wb(e){let t=Rr(e),n=Vb(t),r=md(e,n);return Ee(r)}function pd(e,t){return Q(t)?Wb(e):zb(e,t)}function Hb(e){return P(yn(e))}function ud(e){return e.map(t=>Yo(t))}function Yo(e){return O(e)?ye(ud(e.allOf)):x(e)?w(ud(e.anyOf)):q(e)?Hb(e.const):e}function Yb(e,t){return e.reduceRight((n,r,a)=>{let i=de({},P(a),t);return b.IsExtendsTrueLike(i)?[r,...n]:n},[])}function Jb(e,t){let n=Yo(t),r=Yb(e,n);return ut(r)}function Xb(e){return ut(e)}function cd(e,t){return q(t)&&s.IsEqual(t.const,"length")?P(e.length):Q(t)||Ie(t)?Xb(e):Jb(e,t)}function ld(e,t){return z(e)?Ql(e.items,t):L(e)?pd(e.properties,t):N(e)?cd(e.items,t):D()}function Zb(e){return le(e)||W(e)||O(e)||x(e)?gn(e):e}function Ho(e,t,n){return k([e,t])?p.Update(ld(Zb(e),t),{},n):Bn(e,t,n)}function dd(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return Ho(i,m,a)}function ra(e,t={}){return I("InstanceType",[e],t)}function fd(e,t={}){return Jo(e,t)}function Qb(e){return oe(e)?e.instanceType:D()}function Jo(e,t){return k([e])?p.Update(Qb(e),{},t):ra(e,t)}function hd(e,t,n,r={}){let a=d(e,t,n);return Jo(a,r)}function Vn(e,t={}){return I("KeyOf",[e],t)}function gd(e,t={}){return Xo(e,t)}function yd(){return w([we(),Me(),tn()])}function xd(e){return we()}function ev(e){return e.reduce((n,r)=>qr(r)?[...n,P(yn(r))]:X(),[])}function Id(e){let t=s.Keys(e),n=ev(t);return ut(n)}function bd(e){return an(e)}function vd(e){let t=e.map((n,r)=>P(r));return ut(t)}function Td(e){return Z(e)?yd():z(e)?xd(e.items):L(e)?Id(e.properties):fe(e)?bd(e):N(e)?vd(e.items):D()}function tv(e){return le(e)||W(e)||O(e)||x(e)?gn(e):e}function Xo(e,t){return k([e])?p.Update(Td(tv(e)),{},t):Vn(e,t)}function $d(e,t,n,r){let a=d(e,t,n);return Xo(a,r)}function Un(e,t,n,r,a={}){return I("Mapped",[e,t,n,r],a)}function kd(e,t,n,r,a={}){return Zo({},U([],[]),e,t,n,r,a)}function nv(e){let t=ke(e);return Ea(t)}function rv(e){return e.reduce((t,n)=>[...t,...Ea(n)],[])}function av(e){let t=Oe(e);return Ea(t)}function ov(e){return s.IsNumber(e)?[P(`${e}`)]:[P(e)]}function Ea(e){return xe(e)?av(e.enum):q(e)?ov(e.const):ee(e)?nv(e.pattern):x(e)?rv(e.anyOf):[e]}function wd(e){return Ea(e)}function iv(e){return ee(e)?ke(e.pattern):e}function sv(e,t,n,r,a,i){let m=p.Assign(e,{[n.name]:r}),u=d(m,t,a),l=iv(u),f=d(m,t,i);return Ms(l)||Ls(l)?{[l.const]:f}:{}}function mv(e,t,n,r,a,i){return r.reduce((m,u)=>[...m,sv(e,t,n,u,a,i)],[])}function pv(e){return e.reduce((t,n)=>[...t,T(n)],[])}function Ed(e,t,n,r,a,i){let m=wd(r),u=mv(e,t,n,m,a,i),l=pv(u);return B(l)}function Zo(e,t,n,r,a,i,m){return k([r])?p.Update(Ed(e,t,n,r,a,i),{},m):Un(n,r,a,i,m)}function Sd(e,t,n,r,a,i,m){let u=d(e,t,r);return Zo(e,t,n,u,a,i,m)}function uv(e,t,n){let r=p.Assign(e,t);return s.Keys(t).filter(i=>n.includes(i)).reduce((i,m)=>({...i,[m]:ml(r,m,t[m])}),{})}function cv(e,t,n){let r=p.Assign(e,t);return s.Keys(t).filter(i=>!n.includes(i)).reduce((i,m)=>({...i,[m]:d(r,U([],[]),t[m])}),{})}function lv(e,t,n){let r=al(t),a=uv(e,t,r),i=cv(e,t,r),m={...a,...i};return p.Update(m,{},n)}function Sa(e,t,n,r){return lv(e,n,r)}function aa(e,t={}){return I("NonNullable",[e],t)}function Rd(e,t={}){return Qo(e,t)}function dv(e){let t=w([Qt(),on()]);return rr(e,t,{})}function Qo(e,t){return k([e])?p.Update(dv(e),{},t):aa(e,t)}function Od(e,t,n,r){let a=d(e,t,n);return Qo(a,r)}function oa(e,t,n={}){return I("Omit",[e,t],n)}function Pd(e,t,n={}){let r=s.IsArray(t)?hn(t):t;return ei(e,r,n)}function Ra(e){let t=gn(e);return L(t)?t.properties:X()}function fv(e,t){return s.Keys(e).reduce((r,a)=>t.includes(a)?r:{...r,[a]:e[a]},{})}function Ad(e,t){let n=Ra(e),r=xn(t),a=fv(n,r);return T(a)}function ei(e,t,n){return k([e,t])?p.Update(Ad(e,t),{},n):oa(e,t,n)}function Cd(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return ei(i,m,a)}function ia(e,t={}){return I("Parameters",[e],t)}function Md(e,t={}){return ti(e,t)}function hv(e){let t=ie(e)?e.parameters:[],n=Et({},U([],[]),t);return te(n)}function ti(e,t){return k([e])?p.Update(hv(e),{},t):ia(e,t)}function Ld(e,t,n,r){let a=d(e,t,n);return ti(a,r)}function sa(e,t={}){return I("Partial",[e],t)}function qd(e,t={}){return ni(e,t)}function jd(e,t){let n=Qe(e,t),r=et(n);return He(p.Assign(e,{[t]:r}),t)}function Fd(e,t,n){let r=_e(e,t,n);return et(r)}function Dd(e){let t=B(e);return et(t)}function Gd(e){let t=e.map(n=>et(n));return w(t)}function Nd(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:Ct(e[a])}),{});return T(t)}function et(e){return le(e)?jd(e.$defs,e.$ref):W(e)?Fd(e.if,e.then,e.else):O(e)?Dd(e.allOf):x(e)?Gd(e.anyOf):L(e)?Nd(e.properties):T({})}function ni(e,t){return k([e])?p.Update(et(e),{},t):sa(e,t)}function _d(e,t,n,r){let a=d(e,t,n);return ni(a,r)}function ma(e,t,n={}){return I("Pick",[e,t],n)}function Ud(e,t,n={}){let r=s.IsArray(t)?hn(t):t;return ri(e,r,n)}function gv(e,t){return s.Keys(e).reduce((r,a)=>t.includes(a)?p.Assign(r,{[a]:e[a]}):r,{})}function Kd(e,t){let n=Ra(e),r=xn(t),a=gv(n,r);return T(a)}function ri(e,t,n){return k([e,t])?p.Update(Kd(e,t),{},n):ma(e,t,n)}function zd(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return ri(i,m,a)}function pa(e,t={}){return I("ReadonlyObject",[e],t)}function ai(e,t={}){return oi(e,t)}var Bd=ai;function Vd(e){return Zt(Re(e))}function Wd(e,t){let n=Qe(e,t),r=tt(n);return He(p.Assign(e,{[t]:r}),t)}function Hd(e,t,n){let r=_e(e,t,n);return tt(r)}function Yd(e){let t=B(e);return tt(t)}function Jd(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:qt(e[a])}),{});return T(t)}function Xd(e){return Zt(te(e))}function Zd(e){let t=e.map(n=>tt(n));return w(t)}function tt(e){return z(e)?Vd(e.items):le(e)?Wd(e.$defs,e.$ref):W(e)?Hd(e.if,e.then,e.else):O(e)?Yd(e.allOf):L(e)?Jd(e.properties):N(e)?Xd(e.items):x(e)?Zd(e.anyOf):e}function oi(e,t){return k([e])?p.Update(tt(e),{},t):pa(e)}function Qd(e,t,n,r){let a=d(e,t,n);return oi(a,r)}function ef(e,t,n,r){return t.visited.includes(r)?n:r in e?d(e,U(t.callstack,[...t.visited,r]),e[r]):n}function tf(e,t){let n=Qe(e,t),r=nt(n);return He(p.Assign(e,{[t]:r}),t)}function nf(e,t,n){let r=_e(e,t,n);return nt(r)}function rf(e){let t=B(e);return nt(t)}function af(e){let t=e.map(n=>nt(n));return w(t)}function of(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:Nr(e[a])}),{});return T(t)}function nt(e){return le(e)?tf(e.$defs,e.$ref):W(e)?nf(e.if,e.then,e.else):O(e)?rf(e.allOf):x(e)?af(e.anyOf):L(e)?of(e.properties):T({})}function ua(e,t={}){return I("Required",[e],t)}function sf(e,t={}){return ii(e,t)}function ii(e,t){return k([e])?p.Update(nt(e),{},t):ua(e,t)}function mf(e,t,n,r){let a=d(e,t,n);return ii(a,r)}function ca(e,t={}){return I("ReturnType",[e],t)}function pf(e,t={}){return si(e,t)}function yv(e){return ie(e)?e.returnType:D()}function si(e,t){return k([e])?p.Update(yv(e),{},t):ca(e,t)}function uf(e,t,n,r={}){let a=d(e,t,n);return si(a,r)}function la(e,t){return I("With",[e,t],{})}function cf(e,t){return mi(e,t)}function mi(e,t){return k([e])?p.Update(e,{},t):la(e,t)}function lf(e,t,n,r){let a=d(e,t,n);return mi(a,r)}function xv(e){return Tt(e)?N(e.items)?pi(e.items.items):J(e.items)?[e]:se(e.items)?[e]:[D()]:[e]}function pi(e){return e.reduce((n,r)=>[...n,...xv(r)],[])}function U(e,t){return{callstack:e,visited:t}}function k(e){return s.ShiftLeft(e,(t,n)=>se(t)?!1:k(n),()=>!0)}function Zn(e,t,n){return s.Keys(n).reduce((r,a)=>({...r,[a]:d(e,t,n[a])}),{})}function Et(e,t,n){let r=Pe(e,t,n);return pi(r)}function Pe(e,t,n){return n.map(r=>d(e,t,r))}function Iv(e,t){let n=ge(e)?Pn(t,{}):t,r=jt(e)?On(n,{}):n;return Lt(e)?ir(r,{}):r}function bv(e,t,n,r,a){return s.IsEqual(n,"AddImmutable")?df(e,t,r[0],a):s.IsEqual(n,"RemoveImmutable")?Tl(e,t,r[0],a):s.IsEqual(n,"AddReadonly")?ms(e,t,r[0],a):s.IsEqual(n,"RemoveReadonly")?Hs(e,t,r[0],a):s.IsEqual(n,"AddOptional")?ps(e,t,r[0],a):s.IsEqual(n,"RemoveOptional")?Xs(e,t,r[0],a):s.IsEqual(n,"Capitalize")?Al(e,t,r[0],a):s.IsEqual(n,"Conditional")?jl(e,t,r[0],r[1],r[2],r[3],a):s.IsEqual(n,"ConstructorParameters")?Dl(e,t,r[0],a):s.IsEqual(n,"Evaluate")?cl(e,t,r[0],a):s.IsEqual(n,"Exclude")?Nl(e,t,r[0],r[1],a):s.IsEqual(n,"Extract")?Kl(e,t,r[0],r[1],a):s.IsEqual(n,"Index")?dd(e,t,r[0],r[1],a):s.IsEqual(n,"InstanceType")?hd(e,t,r[0],a):s.IsEqual(n,"Interface")?el(e,t,r[0],r[1],a):s.IsEqual(n,"KeyOf")?$d(e,t,r[0],a):s.IsEqual(n,"Lowercase")?Cl(e,t,r[0],a):s.IsEqual(n,"Mapped")?Sd(e,t,r[0],r[1],r[2],r[3],a):s.IsEqual(n,"Module")?Sa(e,t,r[0],a):s.IsEqual(n,"NonNullable")?Od(e,t,r[0],a):s.IsEqual(n,"Pick")?zd(e,t,r[0],r[1],a):s.IsEqual(n,"Parameters")?Ld(e,t,r[0],a):s.IsEqual(n,"Partial")?_d(e,t,r[0],a):s.IsEqual(n,"Omit")?Cd(e,t,r[0],r[1],a):s.IsEqual(n,"ReadonlyObject")?Qd(e,t,r[0],a):s.IsEqual(n,"Record")?fm(e,t,r[0],r[1],a):s.IsEqual(n,"Required")?mf(e,t,r[0],a):s.IsEqual(n,"ReturnType")?uf(e,t,r[0],a):s.IsEqual(n,"TemplateLiteral")?xc(e,t,r[0],a):s.IsEqual(n,"Uncapitalize")?Ml(e,t,r[0],a):s.IsEqual(n,"Uppercase")?Ll(e,t,r[0],a):s.IsEqual(n,"With")?lf(e,t,r[0],r[1]):I(n,r,a)}function vv(e,t,n){let r=se(n)?ef(e,t,n,n.$ref):z(n)?Re(d(e,t,n.items),Sr(n)):fn(n)?wa(e,t,n.target,n.arguments):oe(n)?Be(Pe(e,t,n.parameters),d(e,t,n.instanceType),us(n)):ie(n)?Ve(Pe(e,t,n.parameters),d(e,t,n.returnType),cs(n)):W(n)?Mt(d(e,t,n.if),d(e,t,n.then),d(e,t,n.else),ys(n)):O(n)?ye(Pe(e,t,n.allOf),Ts(n)):L(n)?T(Zn(e,t,n.properties),hs(n)):fe(n)?hm(qe(n),d(e,t,ve(n))):Tt(n)?Gt(d(e,t,n.items)):N(n)?te(Et(e,t,n.items),Ws(n)):x(n)?w(Pe(e,t,n.anyOf),js(n)):n;return Iv(n,r)}function d(e,t,n){return gt(n)?bv(e,t,n.action,n.parameters,n.options):vv(e,t,n)}function ui(e,t){return d(e,U([],[]),t)}function Tv(e){return p.Update(e,{"~immutable":!0},{})}function ir(e,t){return p.Update(Tv(e),{},t)}function df(e,t,n,r){let a=d(e,t,n);return ir(a,r)}function gu(e,t={}){return I("AddImmutable",[e],t)}function Zt(e,t={}){return ir(e,t)}function yu(e,t={}){return I("Evaluate",[e],t)}function ff(e,t={}){return Go(e,t)}function xu(e,t={}){return I("Module",[e],t)}function hf(e,t={}){return Sa({},U([],[]),e,t)}function gf(...e){let[t,n,r]=Ye.Match(e,{2:(m,u)=>s.IsString(m)?[{},m,u]:[m,u,{}],3:(m,u,l)=>[m,u,l],1:m=>[{},m,{}]}),a=dc(n),i=s.IsArray(a)&&s.IsEqual(a.length,2)?d(t,U([],[]),a[0]):D();return p.Update(i,{},r)}var G={};Rt(G,{Any:()=>Xt,Array:()=>Re,BigInt:()=>Ln,Boolean:()=>Mr,Call:()=>bl,Capitalize:()=>Sl,Codec:()=>Cr,Conditional:()=>ql,Constructor:()=>Be,ConstructorParameters:()=>Fl,Cyclic:()=>He,Decode:()=>Es,DecodeBuilder:()=>Mn,Dependent:()=>Mt,Encode:()=>Ss,EncodeBuilder:()=>Cn,Enum:()=>vs,Evaluate:()=>ff,Exclude:()=>Gl,Extends:()=>de,ExtendsResult:()=>b,Extract:()=>_l,Function:()=>Ve,Generic:()=>yt,Identifier:()=>qn,Immutable:()=>Rs,Index:()=>zl,Infer:()=>An,InstanceType:()=>fd,Instantiate:()=>ui,Integer:()=>Ft,Interface:()=>tl,Intersect:()=>ye,IsAny:()=>Z,IsArray:()=>z,IsBigInt:()=>Xe,IsBoolean:()=>Ce,IsCall:()=>fn,IsCodec:()=>Ar,IsConstructor:()=>oe,IsCyclic:()=>le,IsDependent:()=>W,IsEnum:()=>xe,IsEnumValue:()=>bs,IsFunction:()=>ie,IsGeneric:()=>Jt,IsIdentifier:()=>Cs,IsImmutable:()=>Lt,IsInfer:()=>J,IsInteger:()=>Ie,IsIntersect:()=>O,IsKind:()=>y,IsLiteral:()=>q,IsNever:()=>xt,IsNull:()=>en,IsNumber:()=>Q,IsObject:()=>L,IsOptional:()=>ge,IsParameter:()=>qs,IsReadonly:()=>jt,IsRecord:()=>fe,IsRef:()=>se,IsRefine:()=>po,IsRest:()=>Tt,IsSchema:()=>ne,IsString:()=>be,IsSymbol:()=>It,IsTemplateLiteral:()=>ee,IsThis:()=>Vr,IsTuple:()=>N,IsUndefined:()=>sn,IsUnion:()=>x,IsUnknown:()=>re,IsUnsafe:()=>Pr,IsVoid:()=>Ze,KeyOf:()=>gd,Literal:()=>P,Lowercase:()=>Rl,Mapped:()=>kd,Module:()=>hf,Never:()=>D,NonNullable:()=>Rd,Null:()=>Qt,Number:()=>we,Object:()=>T,Omit:()=>Pd,Optional:()=>ds,Parameter:()=>Dt,Parameters:()=>Md,Partial:()=>qd,Pick:()=>Ud,Readonly:()=>Os,ReadonlyObject:()=>ai,ReadonlyType:()=>Bd,Record:()=>Kr,RecordKey:()=>an,RecordPattern:()=>qe,RecordValue:()=>ve,Ref:()=>pt,Refine:()=>Ps,Required:()=>sf,Rest:()=>Gt,ReturnType:()=>pf,Script:()=>gf,String:()=>Me,Symbol:()=>tn,TemplateLiteral:()=>bc,This:()=>Br,Tuple:()=>te,Uncapitalize:()=>Ol,Undefined:()=>on,Union:()=>w,Unknown:()=>ue,Unsafe:()=>gs,Uppercase:()=>Pl,Void:()=>Wr,With:()=>cf});var sr="submit_test_gap_candidates",mr="submit_filtered_test_gaps",pr="submit_solver_gaps",m8=G.Object({verdict:G.Union([G.Literal("PASS"),G.Literal("FAIL")],{description:"FAIL only for a genuine blocking issue (clear rubric violation, agent-fault-worthy gap, unfair/undiscoverable test requirement, or a real determinism/regression risk). Optional, minor, or stylistic points are NOT grounds for FAIL \u2014 put those in `notes` instead and use PASS."}),summary:G.String({description:"One short sentence summarizing the verdict."}),reasons:G.Array(G.String(),{description:"Specific BLOCKING justifications only, citing rubric item IDs and concrete evidence from the files you read. Required (non-empty) when verdict is FAIL. Use an empty array when verdict is PASS."}),notes:G.Array(G.String(),{description:"Non-blocking, optional/minor observations or suggested improvements \u2014 the kind of feedback a real reviewer leaves as 'Minor/optional' without failing the task. Include these regardless of verdict; use an empty array if you truly have none."})});var $v=G.Object({statement:G.String({description:"One sentence from agent_prompt.md, copied verbatim."}),gaps:G.Array(G.Object({description:G.String({description:"A fair, publicly observable missing behavioral test."}),risk:G.String({description:"Why an incorrect implementation could pass the current tests despite this missing behavior."})}),{description:"All candidate positive and negative gaps for this sentence; there is no maximum or target count, so include every distinct evidence-backed gap and relevant edge case rather than stopping at 10; use an empty array only when exhaustive analysis finds none."})});function yf(e){return{name:sr,label:"Submit Candidate Test Gaps",description:"Submit one candidate-gap list for one prompt sentence. Call this after each sentence so the orchestrator can track the todo list; empty lists are required when that sentence has no gaps.",parameters:$v,async execute(t,n){let r=e.statements??[];return r.push({statement:n.statement,gaps:n.gaps??[]}),e.statements=r,{content:[{type:"text",text:`Recorded ${n.gaps?.length??0} candidate gap(s)`}],details:void 0}}}}var kv=G.Object({gaps:G.Array(G.Object({description:G.String({description:"The confirmed, real, fair test gap (may be reworded for clarity). Keep POSITIVE:/NEGATIVE: prefix when applicable."}),justification:G.String({description:"Why this is genuinely grounded in agent_prompt.md or the repo, fair to test per the fairness methodology, and a real (non-duplicate) coverage hole in test.patch \u2014 for negative gaps, cite the prompt's prohibition/constraint and why no existing test catches the forbidden outcome."})}),{description:"The filtered, final list of confirmed test gaps. Use an empty array if none of the candidates survive strict scrutiny."})});function xf(e){return{name:mr,label:"Submit Filtered Test Gaps",description:"Submit your final, strictly filtered list of confirmed test gaps. This is the ONLY way to report your result \u2014 call it exactly once, as your last action, after you have independently verified each candidate.",parameters:kv,async execute(t,n){let r=n.gaps??[];return e.gaps=r,{content:[{type:"text",text:`Confirmed ${r.length} gap(s) after filtering`}],details:void 0}}}}var wv=G.Object({gaps:G.Array(G.Object({description:G.String({description:"The specific behavioral gap: a way one or more solver's diff differs materially from what agent_prompt.md/solution.patch require, despite that solver passing `./test.sh new`."}),justification:G.String({description:"Why this is a genuine requirement from agent_prompt.md or solution.patch (cite the specific requirement/line) that the solver's diff misses, contradicts, or diverges from \u2014 and why the current tests fail to catch that divergence."}),evidence:G.String({description:"Which solver(s) (by index) exhibit this, and the specific part of their diff that grounds the gap."})}),{description:"Concrete, diff-grounded behavioral gaps \u2014 cases where a passing solver's materially different approach reveals that `test.sh new` under-specifies a real requirement. Use an empty array if the solvers converged on equivalent behavior; do not manufacture gaps just to report something."})});function If(e){return{name:pr,label:"Submit Solver Gaps",description:"Submit your final list of behavioral gaps found by comparing the solver diffs against the real solution.patch. This is the ONLY way to report your result \u2014 call it exactly once, as your last action, after you have finished comparing every solver.",parameters:wv,async execute(t,n){let r=n.gaps??[];return e.gaps=r,{content:[{type:"text",text:`Recorded ${r.length} solver gap(s)`}],details:void 0}}}}function Ev(e){return[e,"You are working inside the actual repository (this is your current directory) in read-only mode. You have access to read/grep/find/ls tools only \u2014 you cannot execute code or edit files.","Read `agent_prompt.md` for the task requirements and inspect the repository's existing source/code files with read/grep/find/ls. Base the analysis on the prompt and the observable behavior supported by those code files."]}var Sv=["Thoroughness \u2014 your job is high recall on genuine gaps only:","- There is no target count or cap: do not stop at 10 (or any other arbitrary number). For each prompt sentence, enumerate as many distinct uncovered required behaviors and edge cases as the files justify, then continue until an additional sweep finds no new genuine gap.","- Find every gap you can justify with concrete evidence. Do not stop after the first obvious ones \u2014 keep reading until you have systematically covered the prompt and relevant repository code.","- After your first pass, run at least one deliberate second sweep (re-read `agent_prompt.md` and grep/read the relevant code files) before submitting \u2014 but if that sweep still finds nothing, submit an empty list.","- Do not self-censor or merge distinct genuine gaps into one \u2014 the validator will prune. Never invent or pad the list to seem thorough; an empty array is correct when exhaustive analysis truly finds none.","- Hunt subtle gaps too: behaviors that may be missed under other valid inputs, repository conventions, interaction effects, ordering/timing, and branches in the relevant source code that need behavioral coverage.","- Include a candidate only when you can cite specific grounding and a concrete false-pass risk \u2014 not to meet a quota."],bf=["Fairness rules \u2014 apply these to every proposed gap and every proposed assertion:","- Ground every candidate in a specific sentence or requirement in `agent_prompt.md`, or in an existing public contract that is clear and directly relevant in the repository. Record the observable behavior and the plausible incorrect implementation that could pass without this check. Do not create requirements from intuition, taste, general best practice, or a desire for more coverage.","- Treat `agent_prompt.md` as the task contract. Existing source can clarify how an already-public API behaves and can make an established convention discoverable, but a neighboring helper, default, example, or implementation choice does not automatically become a requirement for a new behavior. If repository evidence is absent, mixed, or contradictory, leave the detail open rather than choosing one interpretation.","- A fair check must be expressible through a user-visible result, a caller-visible side effect, a named public API, or another documented/public contract. Do not require private state, private helpers, internal classes, file placement, module boundaries, call order, a particular algorithm, or a particular direct platform/API call when another repo-valid route produces the required outcome.","- A newly invented function, class, property, export, constructor, method name, argument shape, import path, or registry/config key is not a fair requirement merely because it would be a convenient way to test the feature. Require a new API only when `agent_prompt.md` names it, or when the API already exists publicly and the task explicitly relies on it.","- For UI behavior, assert the user-facing control, label, visible state, accessible action, or resulting effect when that is the contract. Do not require a particular DOM hierarchy, tag, CSS class, selector, test/data attribute, ARIA attribute, hidden-shim text, focus order, keyboard traversal, or control implementation unless the prompt or an established public UI contract explicitly requires it.","- Test semantics rather than source representation. Do not pin quote style, whitespace, line breaks, token adjacency, identifier spelling, generated-source wording, code length, AST node shape, type-text spelling, serialization style, or a particular equivalent syntax when the resulting behavior is the same. Normalize, parse, compile, or observe the result when that is necessary to compare equivalent forms.","- For structured results, assert the fields, values, relationships, ordering, and preservation that the contract actually requires. Allow additional valid fields and metadata unless the prompt explicitly forbids them. Do not compare a whole object, list, mapping, or serialized document to a minimal reference-shaped object when only a subset of its contents is contractual.","- Do not infer a concrete value from relational wording. Terms such as current, latest, selected, next, matching, appropriate, or stable require the stated relationship or effect, not an arbitrary numeric or serialized value. Pin a concrete value only when the prompt or a clear existing public contract determines it.","- Do not infer an exact ordering, grouping, cardinality, count, or error-counting model from incidental map order, loop order, a convenient fixture, or one implementation. Require ordering or counts only when the contract makes them observable; otherwise assert membership, relationships, preservation, and the required effect without choosing a granularity the prompt leaves open.","- Do not invent an input-domain policy for unspecified cases. Do not require acceptance or rejection of a particular malformed, nullish, Unicode, unusually large, boolean-like, platform-specific, symlink, missing-parent, or other boundary value unless the prompt or an established public contract settles that case. A sensible API policy is not automatically the specified policy.","- For failures, assert the failure or user-visible error behavior required by the contract. Do not require a specific exception class, message wording, punctuation, embedded input value, capitalization, basename, validation phase, or eager-versus-deferred timing unless it is explicitly promised or publicly established. If the contract only says an operation fails clearly, accept equivalent clear failures.","- Respect asynchronous and lazy contracts. If the prompt promises an eventual effect, do not require a callback to return a promise, immediate settlement, a particular debounce interval, construction-time validation, or one exact observation point. Trigger the public operation and observe or wait for the promised result at a fair boundary.","- Do not select an outcome for an underspecified mode boundary. Dry-run, preview, no-op, conflict, rollback, cache, preflight, and post-context-change behavior may have multiple valid outcomes unless the prompt chooses one. Test the guarantees that are stated, such as non-mutation or reporting, without adding a rejection, write, refresh, or validation policy that was not stated.","- Do not convert an incidental side effect into a requirement. For a no-op or reuse case, test the required content, state, preservation, or absence of duplicate effects; do not additionally require an empty file, directory, cache entry, history item, or other artifact to exist or not exist unless that artifact is part of the contract.","- For logs and status messages, check that the required operation or failure is reported when reporting is contractual. Do not demand arbitrary English words, formatting, punctuation, path spelling, message fragments, or exact output layout when the prompt only requires that the operation be communicated.","- A fair behavioral test must not depend on a hidden harness's mock shape, a source-level monkeypatch landing at one import binding, an incomplete module mock, reassigned exported state, a particular failure-injection primitive, or a synthetic fixture that violates real repository invariants. A reasonable implementation must be able to use the repository's valid public exports and state model without being rejected by the setup.","- Distinguish the semantic goal from the assertion form. If a candidate contains a fair behavioral core plus an unsupported value, representation, timing, API, or harness assumption, keep or rewrite the fair core and remove only the unsupported co-assertion. Do not discard a real gap merely because the first proposed assertion was too specific.","- Edge-case coverage is valuable only when the edge case is required or discoverable. Do not report 'more negative tests would be nice' or every conceivable malformed input. Keep a candidate only when it is distinct, publicly testable, concretely grounded, and could let a materially incorrect implementation pass.","- When uncertain, re-read the exact prompt sentence and the closest public source analogues. If two competent implementations can satisfy the contract while differing on the proposed assertion, the assertion is not fair; return the semantic relationship instead or drop the candidate. An empty result is correct when no candidate survives this standard."],vf=bf,Rv=bf;function Tf(e,t){let n=[...Ev("You are an exhaustive behavioral test-gap finder. Review the task prompt sentence by sentence, finding both missing required-behavior (positive) and missing forbidden/wrong-behavior (negative) tests."),"","First split `agent_prompt.md` into its meaningful sentences using periods (`.`) as the sentence boundary. Create an explicit TODO checklist of every resulting requirement sentence. Work through it one item at a time; do not finish until every item is checked off.","","Before analyzing each sentence, use read/grep/find/ls to inspect the relevant source files and their closest analogues. Use that code context to understand the public contracts, conventions, branches, guards, early returns, state transitions, side effects, boundary handling, and negative/prohibited outcomes required by the sentence. Report every distinct, prompt-required behavioral edge case or prohibition that a plausible implementation could miss. Include positive and negative gaps together for that sentence. There is no maximum number of gaps: keep enumerating distinct missing behaviors for this sentence, including boundary, empty, repeated, interacting, and other relevant edge cases; do not treat 10 as sufficient.","",...Sv,"",...vf,"","Test-coverage checklist for calibration:",e];return n.push("","Fairness: keep only behavior that a user, caller, or existing public contract can observe. Do not require private helpers, internal state, implementation structure, call order, selectors, or incidental strings unless the task explicitly makes them public requirements."),n.push("","For every candidate, state the missing fair behavioral test, the relevant source behavior or branch that led you to investigate it, and why a plausible incorrect implementation could evade that test. The prompt sentence is the required specification: do not report incidental implementation details it does not require. Do not propose the exact test implementation.",`After completing EACH TODO sentence, call \`${sr}\` with that exact sentence and its gap array (including an empty array when none exist). You may and must call the tool multiple times: once per sentence. Only finish after every TODO item has been submitted.`),n.join(`
11
- `)}function $f(e,t,n){let r=["You are a strict, skeptical fairness auditor for a coding-agent benchmark task.","You are working inside a throwaway, read-only copy of a git repository (this is your current directory). You have access to read/grep/find/ls tools only \u2014 you cannot execute code or edit files.","Two specialized research agents reviewed `agent_prompt.md` and the repository's source/code files sentence by sentence, proposing both positive (missing required-behavior) and negative (missing forbidden/wrong-behavior) gaps. It submitted the following per-sentence candidate report:","",JSON.stringify(e,null,2),"","Your job is to independently re-verify the files yourself and FILTER this list down to only candidates that are ALL of the following:","1. Genuinely grounded \u2014 actually required by a specific statement in `agent_prompt.md`, or unambiguous from clearly visible, existing repo behavior. Drop anything speculative, nice-to-have, or invented beyond what the prompt actually asks for.","2. Fair to test \u2014 verifying it would not require undiscoverable private internals, an invented/unnamed API, or exact incidental implementation structure. Judge this precisely against the fairness guidance below.","3. A real, distinct behavioral gap \u2014 drop near-duplicate candidates and keep only the clearest phrasing of each distinct gap. Retain a candidate only when the source code and prompt provide concrete grounding for a behavior that deserves an explicit public-outcome check.","4. Behaviorally testable through a public contract \u2014 drop candidates that would require an internal helper, private state, implementation structure, call order, DOM class/attribute/data hook, selector, or exact string literal. The sole exceptions are details explicitly named in `agent_prompt.md` or already established as a public contract in the existing repository.","","Be strict: when genuinely unsure whether a candidate holds up, drop it rather than keep it. It is fine \u2014 expected, even \u2014 to return an empty list if none of the candidates survive scrutiny.","","Checklist for the tests focus area, for calibration:",t];return r.push("","Fairness: keep only behavior that a user, caller, or existing public contract can observe. Do not require private helpers, internal state, implementation structure, call order, selectors, or incidental strings unless the task explicitly makes them public requirements.","",...Rv),r.push("","For every gap you keep, give a short justification citing where in `agent_prompt.md` or the repo it is grounded. Preserve POSITIVE:/NEGATIVE: prefix when applicable.",`When you are done, call the \`${mr}\` tool exactly once with your final filtered list (which may be empty). That tool call is your only way to report a result.`),r.join(`
12
- `)}function kf(){return["You are a adversarial tester. Your goal is to find the most minimal, shortcut implementation that makes all new tests pass \u2014 not a full, correct solution. This is intentional: we want to discover whether the test suite lets through an implementation that barely satisfies the assertions without properly implementing the prompt's required behavior.","`agent_prompt.md` in the repo root describes the intended task. Tests for it already exist and are currently failing.","","Goal: make ALL of the new tests pass with the least amount of real logic possible.","1. Run `bash test.sh new` to see the failures and what the tests expect. Read the failing tests carefully \u2014 they are the only spec you need to satisfy.","2. Understand exactly what each test assertion checks. Ask, 'what is the minimum thing I can do \u2014 a stub, a hardcoded return, a mockish pass-through, a trivial branch \u2014 to satisfy this test?', not 'what does agent_prompt.md intend?'. Skim `agent_prompt.md` only enough to understand what the test file names and assertions refer to, then rely on the test errors to drive what to implement.","3. Prefer the most minimal implementation possible:"," - Hardcode a return value if the test expects one."," - Add only the code paths a test actually exercises; leave anything untested unimplemented."," - Mock the minimum number of dependencies (or none) that the test error forces you to touch."," - Use the most direct, trivial, shortcut approach \u2014 do not build abstractions, do not handle unobserved edge cases, do not add defensive code.","4. Before declaring success, also run `bash test.sh base` to confirm your changes cause no regressions. The shortcut must not break existing tests \u2014 that would be a false positive from a different angle.","5. Re-run `bash test.sh new` and iterate until both the new tests and the base tests pass, or you're confident you cannot pass more without adding real logic.","","Rules:","- Do NOT modify the test files or `test.sh`. Only change application/library code.","- You have shell access \u2014 install any dependencies you need.","- The prompt is not your spec: the tests are. Implement exactly what the tests demand, nothing more. If you can satisfy a test with a hardcoded return, do it."].join(`
13
- `)}function Ov(e){let t=e.status==="ok"?e.passed?"PASSED all new tests":"did NOT pass all new tests":`did not complete normally (status: ${e.status})`;return`- Solver ${e.index} \u2014 ${t} \u2014 solution.diff / test_output.txt in \`${kn}/solver_${e.index}/\``}function wf(e,t,n){let r=["You are a strict, skeptical behavioral-gap auditor for a coding-agent benchmark task.","You are working inside a throwaway, read-only copy of a git repository (this is your current directory). You have access to read/grep/find/ls tools only \u2014 you cannot execute code, apply patches, or edit files.","The repo root contains `agent_prompt.md` (the real task description), `solution.patch` (a unified diff of the real golden/reference solution), and `test.patch` (a unified diff adding the hidden tests).","",`Separately, several coding agents ('solvers') were each given the same \`agent_prompt.md\` plus the failing tests from \`test.patch\` \u2014 but never \`solution.patch\` \u2014 and asked to implement the task TDD-style, iterating with real shell access until the tests passed or they gave up. Each solver's diff and full \`test.sh new\` output \u2014 captured and verified independently by the harness, not self-reported \u2014 is saved under \`${kn}/solver_<index>/\` (\`solution.diff\`, \`test_output.txt\`), with a \`${kn}/manifest.json\` summary. Use read/grep/find/ls to open exactly what you need. Status summary:`,"",...e.map(Ov),"","Your job: compare the reference `solution.patch` with each solver's `solution.diff` to find concrete BEHAVIORAL GAPS. Keep only a difference where: (a) `agent_prompt.md` explicitly requires the behavior, (b) the solver passed the relevant tests (even if it failed elsewhere), (c) the reference and solver produce observably different behavior for a real edge case or scenario, and (d) a fair public-facing test could distinguish them. The reference solution is evidence for scenarios to inspect, never a specification by itself.","","How to work:","1. Read `agent_prompt.md` sentence by sentence and note every distinct requirement, constraint, and prohibition.","2. Read `solution.patch` to see how the reference solution satisfies those requirements.","3. For each solver, read its `solution.diff` and compare it against the reference behavior. Look specifically for a solver shortcut, missed constraint, edge case, or side effect that the PROMPT requires, where the solver still passes because the tests do not observe the behavioral difference.","4. A solver that did not pass the full suite may still provide evidence for a completed, relevant part of its diff, but only when its test output shows the failure is unrelated to that behavior (or shows the relevant tests already passed). Do not treat its failing behavior as a gap, and do not infer gaps from a hypothetical wrong implementation.","5. Treat multiple solvers converging on the same divergent-but-passing shortcut as stronger evidence of a real gap, not proof it's acceptable \u2014 the tests are what's under scrutiny, not majority solver behavior.","",...vf,"- Every gap must be evidenced by an actual, cited solver diff and a contrasting reference behavior. For a solver that failed the full suite, also cite its test output showing that the relevant behavior already passed or is unrelated to the failure. Cite the prompt sentence that makes the behavioral difference required; do not report a gap that is purely theoretical or based only on the reference implementation.","- It is fine, and expected, to submit an empty list if the solvers that passed all converged on behavior equivalent to the reference solution with no material gaps.","- Do not self-censor for volume, but do not pad the list either \u2014 only include what you can concretely justify with cited evidence.","","For reference, here is the checklist for the tests focus area (use it to calibrate what good coverage looks like, not as a list of gaps to report verbatim):",t];return n&&r.push("","Fairness methodology (context on what a fair, in-scope requirement looks like):",n),r.push("",`When you are done, call the \`${pr}\` tool exactly once with your final list (which may be empty). That tool call is your only way to report a result.`),r.join(`
14
- `)}var Pv=900*1e3,ci=["read","grep","find","ls"];function Aa(e){return e==="off"?void 0:e}async function Ca(e,t,n=Pv){return t.aborted?"cancelled":new Promise((r,a)=>{let i=!1,m,u=()=>{m!==void 0&&clearTimeout(m),t.removeEventListener("abort",f)},l=h=>{i||(i=!0,u(),r(h))},f=()=>l("cancelled");m=setTimeout(()=>l("timedOut"),n),t.addEventListener("abort",f,{once:!0}),e().then(()=>l("done"),h=>{i||(i=!0,u(),a(h))})})}async function Ma(e){if(e){try{e.isIdle||await e.abort()}catch{}e.dispose()}}async function La(e){let t={},n=e.model,r;try{({session:r}=await Oa({cwd:e.tempDir,model:n,thinkingLevel:Aa(e.thinkingLevel),tools:[...ci,sr],customTools:[yf(t)],sessionManager:Pa.inMemory()}));let a=await Ca(async()=>{await r?.prompt(Tf(e.testRubric,e.fairnessRules))},e.cancelSignal);if(a!=="done")return await r.abort(),{status:a,gaps:[]}}catch{return{status:"error",gaps:[]}}finally{await Ma(r)}return t.statements?{status:"ok",gaps:t.statements}:{status:"noSubmission",gaps:[]}}var Av=["read","grep","find","ls","write","edit","bash"];async function Ef(e){let t=e.model,n=Pa.inMemory(),r;try{({session:r}=await Oa({cwd:e.solverDir,model:t,thinkingLevel:Aa(e.thinkingLevel),tools:[...Av],sessionManager:n}));let a=await Ca(async()=>{await r?.prompt(kf())},e.cancelSignal,e.timeoutMinutes*60*1e3);return a!=="done"&&await r.abort(),{outcome:a,trajectory:n.getEntries()}}catch{return{outcome:"error",trajectory:[]}}finally{await Ma(r)}}async function Sf(e){let t={},n=e.model,r;try{({session:r}=await Oa({cwd:e.tempDir,model:n,thinkingLevel:Aa(e.thinkingLevel),tools:[...ci,pr],customTools:[If(t)],sessionManager:Pa.inMemory()}));let a=await Ca(async()=>{await r?.prompt(wf(e.solverResults,e.testRubric,e.fairnessRules))},e.cancelSignal);if(a!=="done")return await r.abort(),{status:a,gaps:[]}}catch{return{status:"error",gaps:[]}}finally{await Ma(r)}return t.gaps?{status:"ok",gaps:t.gaps}:{status:"noSubmission",gaps:[]}}async function qa(e){let t={},n=e.model,r;try{({session:r}=await Oa({cwd:e.tempDir,model:n,thinkingLevel:Aa(e.thinkingLevel),tools:[...ci,mr],customTools:[xf(t)],sessionManager:Pa.inMemory()}));let a=await Ca(async()=>{await r?.prompt($f(e.statementReports,e.testRubric,e.fairnessRules))},e.cancelSignal);if(a!=="done")return await r.abort(),{status:a,gaps:[]}}catch{return{status:"error",gaps:[]}}finally{await Ma(r)}return t.gaps?{status:"ok",gaps:t.gaps}:{status:"noSubmission",gaps:[]}}var St="checks_progress";function ur(e,t,n,r){let a=n>0?Math.min(1,t/n):0,i=Math.round(24*a),m="\u2588".repeat(i)+"\u2591".repeat(Math.max(0,24-i)),u=r?` pass:${r.passed} fail:${r.failed}`:"";return[`checks: ${e} [${m}] ${t}/${n}${u}`]}import{existsSync as Cv,readFileSync as Mv}from"node:fs";var li=["agent_prompt.md","solution.patch","test.patch"];function di(e=new Date){let t=(i,m=2)=>String(i).padStart(m,"0"),n=-e.getTimezoneOffset(),r=n>=0?"+":"-",a=Math.abs(n);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}.${t(e.getMilliseconds(),3)}${r}${t(Math.floor(a/60))}:${t(a%60)}`}function Rf(e){try{if(!Cv(e))return{};let t=JSON.parse(Mv(e,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function Of(e){let t={...e.existingReport,timestamp:di(),model:`${e.config.provider}/${e.config.modelId}`,thinkingLevel:e.config.thinkingLevel};return delete t.overall,delete t.reports,e.runGapFinder&&(t.testGaps=e.testGaps,e.gapAnalysisIncomplete?t.testGapAnalysisNote=`Gap analysis did not fully complete (sentence finder: ${e.gapFinderStatus}, review: ${e.gapFilterStatus}); testGaps may be incomplete.`:delete t.testGapAnalysisNote),e.runSolverGapFinder&&(t.solverRunSummary=e.solverResults.map(n=>({index:n.index,status:n.status,passed:n.passed,durationMs:n.durationMs,totalTests:n.totalTests,failedTests:n.failedTests,artifactsDir:n.artifactsDir})),t.solverGaps=e.solverGaps,e.solverGapAnalysisIncomplete?t.solverGapAnalysisNote=`Solver-gap analysis did not fully complete (comparison reviewer: ${e.solverComparisonStatus}); solverGaps may be incomplete.`:delete t.solverGapAnalysisNote),t}function Pf(e){let t=Math.round(e/1e3);return t>=60?`${Math.floor(t/60)}m ${t%60}s`:`${t}s`}function Af(e){let t=Array.isArray(e.merged.testGaps)?e.merged.testGaps.length:0,n=e.runSolverGapFinder&&Array.isArray(e.merged.solverRunSummary)?e.merged.solverRunSummary.map(i=>({...i,durationMs:i.durationMs??0})):[],r=Array.isArray(e.merged.solverGaps)?e.merged.solverGaps.length:0,a=[];return e.runGapFinder&&a.push(t>0?`${t} test gap(s) found`:"no test gaps found"),e.runSolverGapFinder&&a.push(`${n.filter(i=>i.passed).length}/${n.length} solvers passed, ${r} gap(s) found`),{content:`Gap finders: ${a.join(" | ")}`,details:{gapsCount:t,showGaps:e.runGapFinder,showSolverGaps:e.runSolverGapFinder,solverDetails:n,solverGapsCount:r}}}var Cf=`## The problem description (aka the task)\r
10
+ `,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))),([t,n])=>[t,n]),cc=(e,t=[])=>o(o(Ao(e),([n,r])=>o(mb(r),([a,i])=>[[n,a],i])),([n,r])=>cc(r,[...t,n]),()=>[t,e]),pb=e=>o(o(cc(e),([t,n])=>o(o(o(Ao(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[lu(t),n]),Ao=e=>o(o(sb(e),([t,n])=>o(o(rb(n),([r,a])=>[r,a],()=>o(ab(n),([r,a])=>[r,a],()=>o(ob(n),([r,a])=>[r,a],()=>o(ib(n),([r,a])=>[r,a],()=>[])))),([r,a])=>o(Du(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[du(t),n]),ub=e=>o(o(Ao(e),([t,n])=>o(pb(n),([r,a])=>[[t,r],a])),([t,n])=>[fu(t),n]),lc=e=>o(o(ub(e),([t,n])=>[t,n],()=>o(lx(e),([t,n])=>[t,n],()=>o(R(e),([t,n])=>[t,n],()=>[]))),([t,n])=>[t,n]);function dc(e){let t=So(`\`${e}\``);return s.IsEqual(t.length,2)?t[0]:X()}function lb(e){return e.join("|")}function db(e){return e.slice(1,e.length-1)}function fb(e,t,n){return wt(t,`${n}${e}`)}function hb(e,t){return wt(e,`${t}${Ps}`)}function gb(e,t){return wt(e,`${t}${qr}`)}function yb(e,t){return wt(e,`${t}${jr}`)}function xb(e,t){return Hn(w([P("false"),P("true")]),e,t)}function bb(e,t){return wt(e,`${t}${Fr}`)}function Ib(e,t,n){return wt(t,`${n}${db(e)}`)}function vb(e,t,n){let r=Yn(e,{});return Hn(r,t,n)}function Tb(e,t,n){let r=Oe(e);return Hn(r,t,n)}function fc(e,t,n,r=[]){return s.ShiftLeft(e,(a,i)=>fc(i,t,n,[...r,Hn(a,[],"")]),()=>wt(t,`${n}(${lb(r)})`))}function Hn(e,t,n){return xe(e)?Tb(e.enum,t,n):be(e)?gb(t,n):L(e)?fb(e.const,t,n):Xe(e)?hb(t,n):Ce(e)?xb(t,n):Q(e)?yb(t,n):Ie(e)?bb(t,n):ee(e)?Ib(e.pattern,t,n):gc(e)?vb(e.parameters[0],t,n):x(e)?fc(e.anyOf,t,n):cs}function wt(e,t){return s.ShiftLeft(e,(n,r)=>Hn(n,r,t),()=>t)}function $b(e){return`^${wt(e,"")}$`}function hc(e){let t=$b(e);return Gr(t)}function Yn(e,t){return k(e)?p.Update(hc(e),{},t):Hr(e,t)}function yc(e,t,n,r){let a=Pe(e,t,n);return Yn(a,r)}function Hr(e,t={}){return b("TemplateLiteral",[e],t)}function gc(e){return ne(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"TemplateLiteral")}function xc(e){return Yn(e,{})}function kb(e){let t=dc(e);return xc(t)}function bc(e,t={}){let n=s.IsString(e)?kb(e):xc(e);return p.Update(n,{},t)}function ee(e){return y(e,"TemplateLiteral")}var I={};Rt(I,{ExtendsFalse:()=>$,ExtendsTrue:()=>g,ExtendsUnion:()=>Co,IsExtendsFalse:()=>wb,IsExtendsTrue:()=>vc,IsExtendsTrueLike:()=>cn,IsExtendsUnion:()=>Ic,Match:()=>K});function Co(e){return p.Create({"~kind":"ExtendsUnion"},{inferred:e})}function Ic(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsUnion")&&s.IsObject(e.inferred)}function g(e){return p.Create({"~kind":"ExtendsTrue"},{inferred:e})}function vc(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsTrue")&&s.IsObject(e.inferred)}function $(){return p.Create({"~kind":"ExtendsFalse"},{})}function wb(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],"ExtendsFalse")}function cn(e){return Ic(e)||vc(e)}function K(e,t,n){return cn(e)?t(e.inferred):n()}function Eb(e,t,n,r){return K(C(e,n,r),a=>g(p.Assign(p.Assign(e,a),{[t]:n})),()=>$())}function Sb(e,t){return g(e)}function Rb(e,t,n,r,a){return K(C(e,t,n),i=>K(C(i,t,r),m=>g(m),()=>$()),()=>K(C(e,t,a),i=>g(i),()=>$()))}function Ob(e,t,n){let r=Oe(n);return C(e,t,r)}function Tc(e,t,n){return s.ShiftLeft(n,(r,a)=>K(C(e,t,r),i=>Tc(i,t,a),()=>$()),()=>g(e))}function Pb(e,t,n){let r=ke(n);return C(e,t,r)}function $c(e,t,n){return s.ShiftLeft(n,(r,a)=>K(C(e,t,r),i=>g(i),()=>$c(e,t,a)),()=>$())}function j(e,t,n){return Z(n)?Sb(e,t):W(n)?Rb(e,t,n.if,n.then,n.else):xe(n)?Ob(e,t,n.enum):J(n)?Eb(e,n.name,t,n.extends):O(n)?Tc(e,t,n.allOf):ee(n)?Pb(e,t,n.pattern):x(n)?$c(e,t,n.anyOf):re(n)?g(e):$()}function kc(e,t,n){return J(n)?j(e,t,n):Z(n)?g(e):re(n)?g(e):Co(e)}function Ab(e,t){let n=qt(e),r=qt(t);return n&&r||!n&&r?!0:!(n&&!r)}function wc(e,t,n,r){return z(r)?Ab(t,r)?C(e,n,r.items):$():j(e,t,r)}function Ec(e,t,n){return Xe(n)?g(e):j(e,t,n)}function Sc(e,t,n){return Ce(n)?g(e):j(e,t,n)}function Cb(e,t,n,r,a){let i=J(r)?t:r,m=J(r)?r:t,u=ge(t),l=ge(r);return!u&&l?$():K(C(e,i,m),f=>Jn(f,n,a),()=>$())}function Mb(e,t,n,r){return s.ShiftLeft(r,(a,i)=>Cb(e,t,n,a,i),()=>ge(t)?g(e):$())}function qb(e,t,n){return s.ShiftLeft(t,(r,a)=>Mb(e,r,a,n),()=>g(e))}function Jn(e,t,n){return qb(e,t,n)}function va(e,t,n){return Ze(n)?g(e):C(e,t,n)}function Rc(e,t,n,r){return Z(r)?g(e):re(r)?g(e):oe(r)?K(Jn(e,t,r.parameters),a=>va(a,n,r.instanceType),()=>$()):$()}function Oc(e,t,n,r,a){return K(C(e,t,a),()=>C(e,n,a),()=>C(e,r,a))}function Pc(e,t,n){let r=Oe(t);return C(e,r,n)}function Ac(e,t,n,r){return Z(r)?g(e):re(r)?g(e):ie(r)?K(Jn(e,t,r.parameters),a=>va(a,n,r.returnType),()=>$()):$()}function Cc(e,t,n){return be(n)?g(e):Q(n)?g(e):j(e,t,n)}function Mc(e,t,n){let r=B(t);return C(e,r,n)}function Ta(e,t,n){return t===n?g(e):$()}function Lb(e,t,n){return L(n)?Ta(e,t,n.const):Xe(n)?g(e):j(e,P(t),n)}function jb(e,t,n){return L(n)?Ta(e,t,n.const):Ce(n)?g(e):j(e,P(t),n)}function Fb(e,t,n){return L(n)?Ta(e,t,n.const):Q(n)?g(e):j(e,P(t),n)}function Db(e,t,n){return L(n)?Ta(e,t,n.const):Ie(n)?g(e):j(e,P(t),n)}function qc(e,t,n){return s.IsBigInt(t.const)?Lb(e,t.const,n):s.IsBoolean(t.const)?jb(e,t.const,n):s.IsNumber(t.const)?Fb(e,t.const,n):s.IsString(t.const)?Db(e,t.const,n):X()}function Lc(e,t,n){return J(n)?j(e,t,n):g(e)}function jc(e,t,n){return en(n)?g(e):j(e,t,n)}function Fc(e,t,n){return Q(n)?g(e):j(e,t,n)}function Gb(e,t,n){return ge(t)?ge(n)?g(e):$():g(e)}function Nb(e,t,n){return J(n)&&xt(n.extends)?$():K(C(e,t,n),r=>Gb(r,t,n),()=>$())}function _b(e,t){return e.reduce((n,r)=>r in t?cn(t[r])?{...n,...t[r].inferred}:X():X(),{})}function Ub(e,t,n){let r={};for(let m of s.Keys(n))r[m]=m in t?Nb({},t[m],n[m]):ge(n[m])?J(n[m])?g(p.Assign(e,{[n[m].name]:n[m].extends})):g(e):$();let a=s.Values(r).every(m=>cn(m)),i=a?_b(s.Keys(r),r):{};return a?g(i):$()}function Kb(e,t,n){let r=Ub(e,t,n);return cn(r)?g(p.Assign(e,r.inferred)):$()}function zb(e,t,n){return Kb(e,t,n)}function Bb(e,t){return s.Keys(t).reduce((n,r)=>({...n,[r]:s.HasPropertyKey(e,r)?x(n[r])?w([...n[r].anyOf,t[r]]):w([e[r],t[r]]):t[r]}),e)}function Dc(e,t,n,r){return s.ShiftLeft(t,(a,i)=>K(C({},e[a],n),m=>Dc(e,i,n,Bb(r,m)),()=>$()),()=>g(r))}function Vb(e,t,n,r){let a=s.Keys(t);return Dc(t,a,r,e)}function Gc(e,t,n){return fe(n)?Vb(e,t,Le(n),ve(n)):q(n)?zb(e,t,n.properties):j(e,T(t),n)}function Wb(e,t){return s.IsEqual(s.Keys(t).length,0)?g(e):$()}function Hb(e,t,n,r,a){return C(e,n,a)}function Nc(e,t,n,r){return fe(r)?Hb(e,zr(t),n,zr(Le(r)),ve(r)):q(r)?Wb(e,r.properties):Z(r)?g(e):re(r)?g(e):$()}function _c(e,t,n){return Ie(n)?g(e):j(e,t,n)}function Uc(e,t,n){return bt(n)?g(e):j(e,t,n)}function Kc(e,t,n){let r=ke(t);return C(e,r,n)}function Mo(e,t){return p.Create({"~kind":"Inferrable"},{name:e,type:t},{})}function Xn(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"name")&&s.HasPropertyKey(e,"type")&&s.IsEqual(e["~kind"],"Inferrable")&&s.IsString(e.name)&&s.IsObject(e.type)}function qo(e){return Tt(e)?J(e.items)?z(e.items.extends)?Mo(e.items.name,e.items.extends.items):re(e.items.extends)?Mo(e.items.name,e.items.extends):void 0:X():void 0}function $a(e){return J(e)?Mo(e.name,e.extends):void 0}function Lo(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>K(C({},r,t),()=>Lo(a,t,[...n,r]),()=>{}),()=>n)}function zc(e,t,n,r){let a=Lo(n,r);return s.IsArray(a)?g(p.Assign(e,{[t]:te(a)})):$()}function ka(e,t,n,r){let a=Lo(n,r);return s.IsArray(a)?g(p.Assign(e,{[t]:w(a)})):$()}function Yb(e){return[...e].reverse()}function jo(e,t){return t?Yb(e):e}function Jb(e){let t=e.length>0?e[0]:void 0,n=ne(t)?qo(t):void 0;return ne(n)}function Xb(e,t,n,r,a,i){return K(C(e,n,a),m=>Bc(m,t,r,i),()=>$())}function Zb(e,t,n,r,a){let i=qo(r);return Xn(i)?zc(e,i.name,jo(n,t),i.type):s.ShiftLeft(n,(m,u)=>Xb(e,t,m,u,r,a),()=>$())}function Qb(e,t,n,r){return s.ShiftLeft(r,(a,i)=>Zb(e,t,n,a,i),()=>s.IsEqual(n.length,0)?g(e):$())}function Bc(e,t,n,r){return Qb(e,t,n,r)}function eI(e,t,n){let r=Et(e,U([],[]),n),a=Jb(r);return Bc(e,a,jo(t,a),jo(r,a))}function Vc(e,t,n){let r=$a(n);return Xn(r)?ka(e,r.name,t,r.type):s.ShiftLeft(t,(a,i)=>K(C(e,a,n),m=>Vc(m,i,n),()=>$()),()=>g(e))}function Wc(e,t,n){let r=Et(e,U([],[]),t);return N(n)?eI(e,r,n.items):z(n)?Vc(e,r,n.items):j(e,te(r),n)}function Hc(e,t,n){return Ze(n)?g(e):sn(n)?g(e):j(e,t,n)}function Yc(e,t,n){return s.ShiftLeft(n,(r,a)=>K(C(e,t,r),i=>g(i),()=>Yc(e,t,a)),()=>$())}function Fo(e,t,n){return s.ShiftLeft(t,(r,a)=>K(Yc(e,r,n),i=>Fo(i,a,n),()=>$()),()=>g(e))}function Jc(e,t,n){let r=$a(n);return Xn(r)?ka(e,r.name,t,r.type):x(n)?Fo(e,t,n.anyOf):Fo(e,t,[n])}function Xc(e,t,n){return J(n)?j(e,t,n):Z(n)?g(e):re(n)?g(e):$()}function Zc(e,t,n){return Ze(n)?g(e):j(e,t,n)}function C(e,t,n){return Z(t)?kc(e,t,n):z(t)?wc(e,t,t.items,n):Xe(t)?Ec(e,t,n):Ce(t)?Sc(e,t,n):oe(t)?Rc(e,t.parameters,t.instanceType,n):W(t)?Oc(e,t.if,t.then,t.else,n):xe(t)?Pc(e,t.enum,n):ie(t)?Ac(e,t.parameters,t.returnType,n):be(t)?Cc(e,t,n):O(t)?Mc(e,t.allOf,n):L(t)?qc(e,t,n):xt(t)?Lc(e,t,n):en(t)?jc(e,t,n):Q(t)?Fc(e,t,n):q(t)?Gc(e,t.properties,n):fe(t)?Nc(e,Le(t),ve(t),n):Ie(t)?_c(e,t,n):bt(t)?Uc(e,t,n):ee(t)?Kc(e,t.pattern,n):N(t)?Wc(e,t.items,n):sn(t)?Hc(e,t,n):x(t)?Jc(e,t.anyOf,n):re(t)?Xc(e,t,n):Ze(t)?Zc(e,t,n):$()}function tI(e,t){return B([...e,T(t)])}function Do(e,t,n){return k(e)?p.Update(tI(e,t),{},n):Kn(e,t,n)}function Qc(e,t,n,r,a){let i=Pe(e,t,n),m=Zn(e,t,r);return Do(i,m,a)}function Kn(e,t,n={}){return b("Interface",[e,t],n)}function ln(e){return ne(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"Interface")}function el(e,t,n={}){return Do(e,t,n)}function nI(e,t,n){return e.includes(n)?!0:Qn([...e,n],t,t[n])}function tl(e,t,n){let r=Or(n);return _t(e,t,r)}function _t(e,t,n){return s.ShiftLeft(n,(r,a)=>Qn(e,t,r)?!0:_t(e,t,a),()=>!1)}function Qn(e,t,n){return se(n)?nI(e,t,n.$ref):z(n)?Qn(e,t,n.items):oe(n)?_t(e,t,[...n.parameters,n.instanceType]):ie(n)?_t(e,t,[...n.parameters,n.returnType]):ln(n)?tl(e,t,n.parameters[1]):O(n)?_t(e,t,n.allOf):q(n)?tl(e,t,n.properties):x(n)?_t(e,t,n.anyOf):N(n)?_t(e,t,n.items):fe(n)?Qn(e,t,ve(n)):!1}function nl(e,t,n){return Qn(e,t,n)}function rI(e,t){return t.reduce((n,r)=>nl([r],e,e[r])?[...n,r]:n,[])}function rl(e){let t=Rr(e);return rI(e,t)}function aI(e,t,n){return n.includes(t)?n:t in e?er(e,e[t],[...n,t]):X()}function al(e,t,n){let r=Or(t);return dn(e,r,n)}function dn(e,t,n){return t.reduce((r,a)=>er(e,a,r),n)}function er(e,t,n){return se(t)?aI(e,t.$ref,n):z(t)?er(e,t.items,n):oe(t)?dn(e,[...t.parameters,t.instanceType],n):ie(t)?dn(e,[...t.parameters,t.returnType],n):ln(t)?al(e,t.parameters[1],n):O(t)?dn(e,t.allOf,n):q(t)?al(e,t.properties,n):x(t)?dn(e,t.anyOf,n):N(t)?dn(e,t.items,n):fe(t)?er(e,ve(t),n):n}function ol(e,t,n){return er(e,n,[t])}function oI(e){return Xt()}function iI(e){return s.Keys(e).reduce((t,n)=>({...t,[n]:Ut(e[n])}),{})}function tr(e){return e.reduce((t,n)=>[...t,Ut(n)],[])}function Ut(e){return se(e)?oI(e.$ref):z(e)?Re(Ut(e.items),Sr(e)):oe(e)?Be(tr(e.parameters),Ut(e.instanceType)):ie(e)?Ve(tr(e.parameters),Ut(e.returnType)):O(e)?ye(tr(e.allOf)):q(e)?T(iI(e.properties)):fe(e)?Kr(an(e),Ut(ve(e))):x(e)?w(tr(e.anyOf)):N(e)?te(tr(e.items)):e}function sI(e,t){return t in e?Ut(e[t]):ue()}function il(e){return sI(e.$defs,e.$ref)}function mI(e,t,n){let r=Pe(e,U([],[]),t),a=Zn({},U([],[]),n);return B([...r,T(a)])}function pI(e,t){return s.Keys(e).filter(r=>t.includes(r)).reduce((r,a)=>{let i=e[a],m=ln(i)?mI(e,i.parameters[0],i.parameters[1]):i;return{...r,[a]:m}},{})}function sl(e,t,n){let r=ol(e,t,n),a=pI(e,r);return He(a,t)}function ml(e,t){return t in e?se(e[t])?ml(e,e[t].$ref):e[t]:D()}function Qe(e,t){return ml(e,t)}function pl(e){return le(e)?il(e):Pr(e)?ue():e}function de(e,t,n){let r=pl(t),a=pl(n);return C(e,r,a)}var Fn="equal",uI="disjoint",Dn="left-inside",Gn="right-inside";function nn(e,t){let n=[re(e)?I.ExtendsFalse():de({},e,t),re(e)?I.ExtendsTrue({}):de({},t,e)];return I.IsExtendsTrueLike(n[0])&&I.IsExtendsTrueLike(n[1])?Fn:I.IsExtendsTrueLike(n[0])&&I.IsExtendsFalse(n[1])?Dn:I.IsExtendsFalse(n[0])&&I.IsExtendsTrueLike(n[1])?Gn:uI}function cI(e,t){return t.filter(n=>nn(e,n)!==Gn)}function lI(e,t){let n=t.some(r=>{let a=nn(e,r);return s.IsEqual(a,Dn)||s.IsEqual(a,Fn)});return s.IsEqual(n,!1)}function dI(e,t){let n=qe(e);return Z(n)?[n]:lI(n,t)?[...cI(n,t),n]:t}function fI(e){return e.reduce((t,n)=>q(n)?[...t,n]:xt(n)?t:dI(n,t),[])}function go(e){let t=fI(e);return _n(t)}function Go(e,t){return p.Update(qe(e),{},t)}function ul(e,t,n,r){let a=d(e,t,n);return Go(a,r)}function nr(e,t=[]){return gt(e)&&s.IsEqual(e.action,"Conditional")?se(e.parameters[0])?nr(e.parameters[2],nr(e.parameters[3],[...t,e.parameters[0].$ref])):nr(e.parameters[2],nr(e.parameters[3],t)):gt(e)&&s.IsEqual(e.action,"Mapped")&&gt(e.parameters[1])&&s.IsEqual(e.parameters[1].action,"KeyOf")&&se(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t}function hI(e,t){return e.reduce((n,r)=>[...n,t.includes(r.name)],[])}function dl(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>s.ShiftLeft(t,(i,m)=>dl(a,m,[...n,[i,r]]),()=>n),()=>n)}function gI(e){return x(e)?[...e.anyOf]:[e]}function yI(e,t){return e.reduce((n,r)=>[...n,[...r,t]],[])}function cl(e,t){return t.reduce((n,r)=>[...n,...yI(e,r)],[])}function ll(e){return e.reduce((t,n)=>s.IsEqual(n[0],!0)?cl(t,gI(n[1])):cl(t,[n[1]]),[[]])}function fl(e,t,n){let r=nr(n),a=hI(e,r),i=dl(t,a);return gt(n)&&s.IsEqual(n.action,"Conditional")||gt(n)&&s.IsEqual(n.action,"Mapped")?ll(i):[t]}function xI(){return["(not-resolvable)",D()]}function bI(){return["(not-generic)",D()]}function II(e,t,n){return[e,yt(t,n)]}function vI(e,t,n){return t in e?hl(e,t,e[t],n):xI()}function hl(e,t,n,r){return Jt(n)?II(t,n.parameters,n.expression):se(n)?vI(e,n.$ref,r):bI()}function gl(e,t,n){return hl(e,"(anonymous)",t,n)}function TI(e,t,n){if(J(t)||fn(t)||I.IsExtendsTrueLike(de({},t,n)))return;let r={parameter:e,expect:n,actual:t};throw new Error(`Argument for parameter ${e} does not satisfy constraint`,{cause:r})}function yl(e,t,n,r,a){let i=d(e,t,a);return TI(n,i,r),p.Assign(e,{[n]:i})}function $I(e,t,n,r,a){let i=d(e,t,n.extends),m=d(e,t,n.equals);return s.ShiftLeft(a,(u,l)=>No(yl(e,t,n.name,i,u),t,r,l),()=>No(yl(e,t,n.name,i,m),t,r,[]))}function No(e,t,n,r){return s.ShiftLeft(n,(a,i)=>$I(e,t,a,i,r),()=>e)}function xl(e,t,n,r){return No(e,t,n,r)}function kI(e){return s.IsGreaterThan(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}function wI(e,t){return s.IsEqual(kI(e),t)}function EI(e,t,n,r,a,i){let m=xl(e,t,r,i),u=d(m,U([...t.callstack,n.$ref],t.visited),a);return d(m,U([],[]),u)}function SI(e,t,n,r,a,i){return i.reduce((m,u)=>[...m,EI(e,t,n,r,a,u)],[])}function RI(e,t,n,r,a,i){let m=fl(r,i,a),u=SI(e,t,n,r,a,m);return s.IsEqual(u.length,1)?u[0]:Ee(u)}function wa(e,t,n,r){let a=Pe(e,t,r),i=gl(e,n,r),m=i[0],u=i[1];return Jt(u)?wI(t,m)?zn(pt(m),a):RI(e,t,pt(m),u.parameters,u.expression,a):zn(n,a)}function zn(e,t){return p.Create({"~kind":"Call"},{type:"call",target:e,arguments:t},{})}function bl(e,t){return wa({},U([],[]),e,t)}function fn(e){return y(e,"Call")}function OI(e){return p.Discard(e,["~immutable"])}function Il(e,t){return p.Update(OI(e),{},t)}function vl(e,t,n,r){let a=d(e,t,n);return Il(a,r)}function Tl(e,t){return e(t)}function $l(e,t){return s.IsString(t)?P(Tl(e,t)):P(t)}function kl(e,t){let n=ke(t);return lt(e,n)}function wl(e,t){let n=t.map(r=>lt(e,r));return w(n)}function lt(e,t){return L(t)?$l(e,t.const):ee(t)?kl(e,t.pattern):x(t)?wl(e,t.anyOf):t}function Yr(e,t={}){return b("Capitalize",[e],t)}function El(e,t={}){return _o(e,t)}function Jr(e,t={}){return b("Lowercase",[e],t)}function Sl(e,t={}){return Uo(e,t)}function Xr(e,t={}){return b("Uncapitalize",[e],t)}function Rl(e,t={}){return Ko(e,t)}function Zr(e,t={}){return b("Uppercase",[e],t)}function Ol(e,t={}){return zo(e,t)}var PI=e=>e[0].toUpperCase()+e.slice(1),AI=e=>e.toLowerCase(),CI=e=>e[0].toLowerCase()+e.slice(1),MI=e=>e.toUpperCase();function _o(e,t){return k([e])?p.Update(lt(PI,e),{},t):Yr(e,t)}function Uo(e,t){return k([e])?p.Update(lt(AI,e),{},t):Jr(e,t)}function Ko(e,t){return k([e])?p.Update(lt(CI,e),{},t):Xr(e,t)}function zo(e,t){return k([e])?p.Update(lt(MI,e),{},t):Zr(e,t)}function Pl(e,t,n,r){let a=d(e,t,n);return _o(a,r)}function Al(e,t,n,r){let a=d(e,t,n);return Uo(a,r)}function Cl(e,t,n,r){let a=d(e,t,n);return Ko(a,r)}function Ml(e,t,n,r){let a=d(e,t,n);return zo(a,r)}function Qr(e,t,n,r,a={}){return b("Conditional",[e,t,n,r],a)}function ql(e,t,n,r,a={}){return Bo({},U([],[]),e,t,n,r,a)}function qI(e,t,n,r,a,i){let m=de(e,n,r);return I.IsExtendsUnion(m)?w([d(m.inferred,t,a),d(e,t,i)]):I.IsExtendsTrue(m)?d(m.inferred,t,a):d(e,t,i)}function Bo(e,t,n,r,a,i,m){return k([n,r])?p.Update(qI(e,t,n,r,a,i),{},m):Qr(n,r,a,i,m)}function Ll(e,t,n,r,a,i,m){let u=d(e,t,n),l=d(e,t,r);return Bo(e,t,u,l,a,i,m)}function ea(e,t={}){return b("ConstructorParameters",[e],t)}function jl(e,t={}){return Vo(e,t)}function LI(e){let t=oe(e)?e.parameters:[],n=Et({},U([],[]),t);return te(n)}function Vo(e,t){return k([e])?p.Update(LI(e),{},t):ea(e,t)}function Fl(e,t,n,r){let a=d(e,t,n);return Vo(a,r)}function ta(e,t,n={}){return b("Exclude",[e,t],n)}function Dl(e,t,n={}){return rr(e,t,n)}function rr(e,t,n){return k([e,t])?p.Update(_r(e,t),{},n):ta(e,t,n)}function Gl(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return rr(i,m,a)}function na(e,t,n={}){return b("Extract",[e,t],n)}function Nl(e,t,n={}){return Wo(e,t,n)}function jI(e,t){let n=de({},e,t);return I.IsExtendsTrueLike(n)?[e]:[]}function FI(e,t){return e.reduce((n,r)=>[...n,...jI(r,t)],[])}function _l(e,t){let n=qe(e),r=x(n)?n.anyOf:[n],a=FI(r,t);return Ee(a)}function Wo(e,t,n){return k([e,t])?p.Update(_l(e,t),{},n):na(e,t,n)}function Ul(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return Wo(i,m,a)}function DI(e){return e.reduce((t,n)=>Lr(n)?[...t,P(n)]:t,[])}function hn(e){let t=DI(e);return w(t)}function Bn(e,t,n={}){return b("Index",[e,t],n)}function Kl(e,t,n={}){let r=s.IsArray(t)?hn(t):t;return Ho(e,r,n)}function zl(e,t){let n=Qe(e,t);return Ae(n)}function Bl(e,t,n){let r=_e(e,t,n);return Ae(r)}function GI(e,t){let n=s.Keys(e).filter(h=>!s.HasPropertyKey(t,h)),r=s.Keys(t).filter(h=>!s.HasPropertyKey(e,h)),a=s.Keys(e).filter(h=>s.HasPropertyKey(t,h)),i=n.reduce((h,v)=>({...h,[v]:e[v]}),{}),m=r.reduce((h,v)=>({...h,[v]:t[v]}),{}),u=a.reduce((h,v)=>({...h,[v]:B([e[v],t[v]])}),{}),l=p.Assign(i,m);return p.Assign(l,u)}function Vl(e){return e.reduce((t,n)=>GI(t,Ae(n)),{})}function Wl(e){let t=Zs(te(e));return Ae(t)}function NI(e,t){return s.Keys(e).filter(a=>a in t).reduce((a,i)=>({...a,[i]:Ee([e[i],t[i]])}),{})}function Hl(e,t){return s.ShiftLeft(e,(n,r)=>Hl(r,NI(t,Ae(n))),()=>t)}function Yl(e){return s.ShiftLeft(e,(t,n)=>Hl(n,Ae(t)),()=>X())}function Ae(e){return le(e)?zl(e.$defs,e.$ref):W(e)?Bl(e.if,e.then,e.else):O(e)?Vl(e.allOf):x(e)?Yl(e.anyOf):N(e)?Wl(e.items):q(e)?e.properties:{}}function gn(e){let t=Ae(e);return T(t)}var _I=new RegExp("^(?:0|[1-9][0-9]*)$");function yn(e){let t=`${e}`;return _I.test(t)?parseInt(t):e}function UI(e){return P(yn(e))}function Jl(e){return e.map(t=>Xl(t))}function Xl(e){return O(e)?ye(Jl(e.allOf)):x(e)?w(Jl(e.anyOf)):L(e)?UI(e.const):e}function Zl(e,t){let n=Xl(t),r=de({},n,we());return I.IsExtendsTrueLike(r)?e:L(t)&&s.IsEqual(t.const,"length")?we():D()}function Ql(e,t){let n=Qe(e,t);return Se(n)}function ed(e,t,n){let r=_e(e,t,n);return Se(r)}function td(e){let t=Oe(e);return Se(t)}function nd(e){let t=B(e);return Se(t)}function rd(e){return[`${e}`]}function ad(e){let t=ke(e);return Se(t)}function od(e){return e.reduce((t,n)=>[...t,...Se(n)],[])}function Se(e){return le(e)?Ql(e.$defs,e.$ref):W(e)?ed(e.if,e.then,e.else):xe(e)?td(e.enum):O(e)?nd(e.allOf):L(e)?rd(e.const):ee(e)?ad(e.pattern):x(e)?od(e.anyOf):[]}function xn(e){return Se(e)}function ar(e,t){return t.map(n=>or(e,n))}function or(e,t){return z(t)?Re(or(e,t.items)):oe(t)?Be(ar(e,t.parameters),or(e,t.instanceType)):ie(t)?Ve(ar(e,t.parameters),or(e,t.returnType)):N(t)?te(ar(e,t.items)):x(t)?w(ar(e,t.anyOf)):O(t)?ye(ar(e,t.allOf)):Vr(t)?T(e):t}function id(e,t){return or(e,t)}function KI(e,t){let n=t in e?e[t]:D();return id(e,n)}function sd(e,t){return t.reduce((n,r)=>[...n,KI(e,r)],[])}function zI(e,t){let n=xn(t),r=sd(e,n);return Ee(r)}var BI=new RegExp(vt);function VI(e){return e.filter(n=>BI.test(n))}function WI(e){let t=Rr(e),n=VI(t),r=sd(e,n);return Ee(r)}function md(e,t){return Q(t)?WI(e):zI(e,t)}function HI(e){return P(yn(e))}function pd(e){return e.map(t=>Yo(t))}function Yo(e){return O(e)?ye(pd(e.allOf)):x(e)?w(pd(e.anyOf)):L(e)?HI(e.const):e}function YI(e,t){return e.reduceRight((n,r,a)=>{let i=de({},P(a),t);return I.IsExtendsTrueLike(i)?[r,...n]:n},[])}function JI(e,t){let n=Yo(t),r=YI(e,n);return ut(r)}function XI(e){return ut(e)}function ud(e,t){return L(t)&&s.IsEqual(t.const,"length")?P(e.length):Q(t)||be(t)?XI(e):JI(e,t)}function cd(e,t){return z(e)?Zl(e.items,t):q(e)?md(e.properties,t):N(e)?ud(e.items,t):D()}function ZI(e){return le(e)||W(e)||O(e)||x(e)?gn(e):e}function Ho(e,t,n){return k([e,t])?p.Update(cd(ZI(e),t),{},n):Bn(e,t,n)}function ld(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return Ho(i,m,a)}function ra(e,t={}){return b("InstanceType",[e],t)}function dd(e,t={}){return Jo(e,t)}function QI(e){return oe(e)?e.instanceType:D()}function Jo(e,t){return k([e])?p.Update(QI(e),{},t):ra(e,t)}function fd(e,t,n,r={}){let a=d(e,t,n);return Jo(a,r)}function Vn(e,t={}){return b("KeyOf",[e],t)}function hd(e,t={}){return Xo(e,t)}function gd(){return w([we(),Me(),tn()])}function yd(e){return we()}function ev(e){return e.reduce((n,r)=>Lr(r)?[...n,P(yn(r))]:X(),[])}function xd(e){let t=s.Keys(e),n=ev(t);return ut(n)}function bd(e){return an(e)}function Id(e){let t=e.map((n,r)=>P(r));return ut(t)}function vd(e){return Z(e)?gd():z(e)?yd(e.items):q(e)?xd(e.properties):fe(e)?bd(e):N(e)?Id(e.items):D()}function tv(e){return le(e)||W(e)||O(e)||x(e)?gn(e):e}function Xo(e,t){return k([e])?p.Update(vd(tv(e)),{},t):Vn(e,t)}function Td(e,t,n,r){let a=d(e,t,n);return Xo(a,r)}function Un(e,t,n,r,a={}){return b("Mapped",[e,t,n,r],a)}function $d(e,t,n,r,a={}){return Zo({},U([],[]),e,t,n,r,a)}function nv(e){let t=ke(e);return Ea(t)}function rv(e){return e.reduce((t,n)=>[...t,...Ea(n)],[])}function av(e){let t=Oe(e);return Ea(t)}function ov(e){return s.IsNumber(e)?[P(`${e}`)]:[P(e)]}function Ea(e){return xe(e)?av(e.enum):L(e)?ov(e.const):ee(e)?nv(e.pattern):x(e)?rv(e.anyOf):[e]}function kd(e){return Ea(e)}function iv(e){return ee(e)?ke(e.pattern):e}function sv(e,t,n,r,a,i){let m=p.Assign(e,{[n.name]:r}),u=d(m,t,a),l=iv(u),f=d(m,t,i);return Cs(l)||Ms(l)?{[l.const]:f}:{}}function mv(e,t,n,r,a,i){return r.reduce((m,u)=>[...m,sv(e,t,n,u,a,i)],[])}function pv(e){return e.reduce((t,n)=>[...t,T(n)],[])}function wd(e,t,n,r,a,i){let m=kd(r),u=mv(e,t,n,m,a,i),l=pv(u);return B(l)}function Zo(e,t,n,r,a,i,m){return k([r])?p.Update(wd(e,t,n,r,a,i),{},m):Un(n,r,a,i,m)}function Ed(e,t,n,r,a,i,m){let u=d(e,t,r);return Zo(e,t,n,u,a,i,m)}function uv(e,t,n){let r=p.Assign(e,t);return s.Keys(t).filter(i=>n.includes(i)).reduce((i,m)=>({...i,[m]:sl(r,m,t[m])}),{})}function cv(e,t,n){let r=p.Assign(e,t);return s.Keys(t).filter(i=>!n.includes(i)).reduce((i,m)=>({...i,[m]:d(r,U([],[]),t[m])}),{})}function lv(e,t,n){let r=rl(t),a=uv(e,t,r),i=cv(e,t,r),m={...a,...i};return p.Update(m,{},n)}function Sa(e,t,n,r){return lv(e,n,r)}function aa(e,t={}){return b("NonNullable",[e],t)}function Sd(e,t={}){return Qo(e,t)}function dv(e){let t=w([Qt(),on()]);return rr(e,t,{})}function Qo(e,t){return k([e])?p.Update(dv(e),{},t):aa(e,t)}function Rd(e,t,n,r){let a=d(e,t,n);return Qo(a,r)}function oa(e,t,n={}){return b("Omit",[e,t],n)}function Od(e,t,n={}){let r=s.IsArray(t)?hn(t):t;return ei(e,r,n)}function Ra(e){let t=gn(e);return q(t)?t.properties:X()}function fv(e,t){return s.Keys(e).reduce((r,a)=>t.includes(a)?r:{...r,[a]:e[a]},{})}function Pd(e,t){let n=Ra(e),r=xn(t),a=fv(n,r);return T(a)}function ei(e,t,n){return k([e,t])?p.Update(Pd(e,t),{},n):oa(e,t,n)}function Ad(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return ei(i,m,a)}function ia(e,t={}){return b("Parameters",[e],t)}function Cd(e,t={}){return ti(e,t)}function hv(e){let t=ie(e)?e.parameters:[],n=Et({},U([],[]),t);return te(n)}function ti(e,t){return k([e])?p.Update(hv(e),{},t):ia(e,t)}function Md(e,t,n,r){let a=d(e,t,n);return ti(a,r)}function sa(e,t={}){return b("Partial",[e],t)}function qd(e,t={}){return ni(e,t)}function Ld(e,t){let n=Qe(e,t),r=et(n);return He(p.Assign(e,{[t]:r}),t)}function jd(e,t,n){let r=_e(e,t,n);return et(r)}function Fd(e){let t=B(e);return et(t)}function Dd(e){let t=e.map(n=>et(n));return w(t)}function Gd(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:Ct(e[a])}),{});return T(t)}function et(e){return le(e)?Ld(e.$defs,e.$ref):W(e)?jd(e.if,e.then,e.else):O(e)?Fd(e.allOf):x(e)?Dd(e.anyOf):q(e)?Gd(e.properties):T({})}function ni(e,t){return k([e])?p.Update(et(e),{},t):sa(e,t)}function Nd(e,t,n,r){let a=d(e,t,n);return ni(a,r)}function ma(e,t,n={}){return b("Pick",[e,t],n)}function _d(e,t,n={}){let r=s.IsArray(t)?hn(t):t;return ri(e,r,n)}function gv(e,t){return s.Keys(e).reduce((r,a)=>t.includes(a)?p.Assign(r,{[a]:e[a]}):r,{})}function Ud(e,t){let n=Ra(e),r=xn(t),a=gv(n,r);return T(a)}function ri(e,t,n){return k([e,t])?p.Update(Ud(e,t),{},n):ma(e,t,n)}function Kd(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return ri(i,m,a)}function pa(e,t={}){return b("ReadonlyObject",[e],t)}function ai(e,t={}){return oi(e,t)}var zd=ai;function Bd(e){return Zt(Re(e))}function Vd(e,t){let n=Qe(e,t),r=tt(n);return He(p.Assign(e,{[t]:r}),t)}function Wd(e,t,n){let r=_e(e,t,n);return tt(r)}function Hd(e){let t=B(e);return tt(t)}function Yd(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:Lt(e[a])}),{});return T(t)}function Jd(e){return Zt(te(e))}function Xd(e){let t=e.map(n=>tt(n));return w(t)}function tt(e){return z(e)?Bd(e.items):le(e)?Vd(e.$defs,e.$ref):W(e)?Wd(e.if,e.then,e.else):O(e)?Hd(e.allOf):q(e)?Yd(e.properties):N(e)?Jd(e.items):x(e)?Xd(e.anyOf):e}function oi(e,t){return k([e])?p.Update(tt(e),{},t):pa(e)}function Zd(e,t,n,r){let a=d(e,t,n);return oi(a,r)}function Qd(e,t,n,r){return t.visited.includes(r)?n:r in e?d(e,U(t.callstack,[...t.visited,r]),e[r]):n}function ef(e,t){let n=Qe(e,t),r=nt(n);return He(p.Assign(e,{[t]:r}),t)}function tf(e,t,n){let r=_e(e,t,n);return nt(r)}function nf(e){let t=B(e);return nt(t)}function rf(e){let t=e.map(n=>nt(n));return w(t)}function af(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:Nr(e[a])}),{});return T(t)}function nt(e){return le(e)?ef(e.$defs,e.$ref):W(e)?tf(e.if,e.then,e.else):O(e)?nf(e.allOf):x(e)?rf(e.anyOf):q(e)?af(e.properties):T({})}function ua(e,t={}){return b("Required",[e],t)}function of(e,t={}){return ii(e,t)}function ii(e,t){return k([e])?p.Update(nt(e),{},t):ua(e,t)}function sf(e,t,n,r){let a=d(e,t,n);return ii(a,r)}function ca(e,t={}){return b("ReturnType",[e],t)}function mf(e,t={}){return si(e,t)}function yv(e){return ie(e)?e.returnType:D()}function si(e,t){return k([e])?p.Update(yv(e),{},t):ca(e,t)}function pf(e,t,n,r={}){let a=d(e,t,n);return si(a,r)}function la(e,t){return b("With",[e,t],{})}function uf(e,t){return mi(e,t)}function mi(e,t){return k([e])?p.Update(e,{},t):la(e,t)}function cf(e,t,n,r){let a=d(e,t,n);return mi(a,r)}function xv(e){return Tt(e)?N(e.items)?pi(e.items.items):J(e.items)?[e]:se(e.items)?[e]:[D()]:[e]}function pi(e){return e.reduce((n,r)=>[...n,...xv(r)],[])}function U(e,t){return{callstack:e,visited:t}}function k(e){return s.ShiftLeft(e,(t,n)=>se(t)?!1:k(n),()=>!0)}function Zn(e,t,n){return s.Keys(n).reduce((r,a)=>({...r,[a]:d(e,t,n[a])}),{})}function Et(e,t,n){let r=Pe(e,t,n);return pi(r)}function Pe(e,t,n){return n.map(r=>d(e,t,r))}function bv(e,t){let n=ge(e)?Pn(t,{}):t,r=jt(e)?On(n,{}):n;return qt(e)?ir(r,{}):r}function Iv(e,t,n,r,a){return s.IsEqual(n,"AddImmutable")?lf(e,t,r[0],a):s.IsEqual(n,"RemoveImmutable")?vl(e,t,r[0],a):s.IsEqual(n,"AddReadonly")?ss(e,t,r[0],a):s.IsEqual(n,"RemoveReadonly")?Ws(e,t,r[0],a):s.IsEqual(n,"AddOptional")?ms(e,t,r[0],a):s.IsEqual(n,"RemoveOptional")?Js(e,t,r[0],a):s.IsEqual(n,"Capitalize")?Pl(e,t,r[0],a):s.IsEqual(n,"Conditional")?Ll(e,t,r[0],r[1],r[2],r[3],a):s.IsEqual(n,"ConstructorParameters")?Fl(e,t,r[0],a):s.IsEqual(n,"Evaluate")?ul(e,t,r[0],a):s.IsEqual(n,"Exclude")?Gl(e,t,r[0],r[1],a):s.IsEqual(n,"Extract")?Ul(e,t,r[0],r[1],a):s.IsEqual(n,"Index")?ld(e,t,r[0],r[1],a):s.IsEqual(n,"InstanceType")?fd(e,t,r[0],a):s.IsEqual(n,"Interface")?Qc(e,t,r[0],r[1],a):s.IsEqual(n,"KeyOf")?Td(e,t,r[0],a):s.IsEqual(n,"Lowercase")?Al(e,t,r[0],a):s.IsEqual(n,"Mapped")?Ed(e,t,r[0],r[1],r[2],r[3],a):s.IsEqual(n,"Module")?Sa(e,t,r[0],a):s.IsEqual(n,"NonNullable")?Rd(e,t,r[0],a):s.IsEqual(n,"Pick")?Kd(e,t,r[0],r[1],a):s.IsEqual(n,"Parameters")?Md(e,t,r[0],a):s.IsEqual(n,"Partial")?Nd(e,t,r[0],a):s.IsEqual(n,"Omit")?Ad(e,t,r[0],r[1],a):s.IsEqual(n,"ReadonlyObject")?Zd(e,t,r[0],a):s.IsEqual(n,"Record")?dm(e,t,r[0],r[1],a):s.IsEqual(n,"Required")?sf(e,t,r[0],a):s.IsEqual(n,"ReturnType")?pf(e,t,r[0],a):s.IsEqual(n,"TemplateLiteral")?yc(e,t,r[0],a):s.IsEqual(n,"Uncapitalize")?Cl(e,t,r[0],a):s.IsEqual(n,"Uppercase")?Ml(e,t,r[0],a):s.IsEqual(n,"With")?cf(e,t,r[0],r[1]):b(n,r,a)}function vv(e,t,n){let r=se(n)?Qd(e,t,n,n.$ref):z(n)?Re(d(e,t,n.items),Sr(n)):fn(n)?wa(e,t,n.target,n.arguments):oe(n)?Be(Pe(e,t,n.parameters),d(e,t,n.instanceType),ps(n)):ie(n)?Ve(Pe(e,t,n.parameters),d(e,t,n.returnType),us(n)):W(n)?Mt(d(e,t,n.if),d(e,t,n.then),d(e,t,n.else),gs(n)):O(n)?ye(Pe(e,t,n.allOf),vs(n)):q(n)?T(Zn(e,t,n.properties),fs(n)):fe(n)?fm(Le(n),d(e,t,ve(n))):Tt(n)?Gt(d(e,t,n.items)):N(n)?te(Et(e,t,n.items),Vs(n)):x(n)?w(Pe(e,t,n.anyOf),Ls(n)):n;return bv(n,r)}function d(e,t,n){return gt(n)?Iv(e,t,n.action,n.parameters,n.options):vv(e,t,n)}function ui(e,t){return d(e,U([],[]),t)}function Tv(e){return p.Update(e,{"~immutable":!0},{})}function ir(e,t){return p.Update(Tv(e),{},t)}function lf(e,t,n,r){let a=d(e,t,n);return ir(a,r)}function hu(e,t={}){return b("AddImmutable",[e],t)}function Zt(e,t={}){return ir(e,t)}function gu(e,t={}){return b("Evaluate",[e],t)}function df(e,t={}){return Go(e,t)}function yu(e,t={}){return b("Module",[e],t)}function ff(e,t={}){return Sa({},U([],[]),e,t)}function hf(...e){let[t,n,r]=Ye.Match(e,{2:(m,u)=>s.IsString(m)?[{},m,u]:[m,u,{}],3:(m,u,l)=>[m,u,l],1:m=>[{},m,{}]}),a=lc(n),i=s.IsArray(a)&&s.IsEqual(a.length,2)?d(t,U([],[]),a[0]):D();return p.Update(i,{},r)}var G={};Rt(G,{Any:()=>Xt,Array:()=>Re,BigInt:()=>qn,Boolean:()=>Mr,Call:()=>bl,Capitalize:()=>El,Codec:()=>Cr,Conditional:()=>ql,Constructor:()=>Be,ConstructorParameters:()=>jl,Cyclic:()=>He,Decode:()=>ws,DecodeBuilder:()=>Mn,Dependent:()=>Mt,Encode:()=>Es,EncodeBuilder:()=>Cn,Enum:()=>Is,Evaluate:()=>df,Exclude:()=>Dl,Extends:()=>de,ExtendsResult:()=>I,Extract:()=>Nl,Function:()=>Ve,Generic:()=>yt,Identifier:()=>Ln,Immutable:()=>Ss,Index:()=>Kl,Infer:()=>An,InstanceType:()=>dd,Instantiate:()=>ui,Integer:()=>Ft,Interface:()=>el,Intersect:()=>ye,IsAny:()=>Z,IsArray:()=>z,IsBigInt:()=>Xe,IsBoolean:()=>Ce,IsCall:()=>fn,IsCodec:()=>Ar,IsConstructor:()=>oe,IsCyclic:()=>le,IsDependent:()=>W,IsEnum:()=>xe,IsEnumValue:()=>bs,IsFunction:()=>ie,IsGeneric:()=>Jt,IsIdentifier:()=>As,IsImmutable:()=>qt,IsInfer:()=>J,IsInteger:()=>be,IsIntersect:()=>O,IsKind:()=>y,IsLiteral:()=>L,IsNever:()=>xt,IsNull:()=>en,IsNumber:()=>Q,IsObject:()=>q,IsOptional:()=>ge,IsParameter:()=>qs,IsReadonly:()=>jt,IsRecord:()=>fe,IsRef:()=>se,IsRefine:()=>po,IsRest:()=>Tt,IsSchema:()=>ne,IsString:()=>Ie,IsSymbol:()=>bt,IsTemplateLiteral:()=>ee,IsThis:()=>Vr,IsTuple:()=>N,IsUndefined:()=>sn,IsUnion:()=>x,IsUnknown:()=>re,IsUnsafe:()=>Pr,IsVoid:()=>Ze,KeyOf:()=>hd,Literal:()=>P,Lowercase:()=>Sl,Mapped:()=>$d,Module:()=>ff,Never:()=>D,NonNullable:()=>Sd,Null:()=>Qt,Number:()=>we,Object:()=>T,Omit:()=>Od,Optional:()=>ls,Parameter:()=>Dt,Parameters:()=>Cd,Partial:()=>qd,Pick:()=>_d,Readonly:()=>Rs,ReadonlyObject:()=>ai,ReadonlyType:()=>zd,Record:()=>Kr,RecordKey:()=>an,RecordPattern:()=>Le,RecordValue:()=>ve,Ref:()=>pt,Refine:()=>Os,Required:()=>of,Rest:()=>Gt,ReturnType:()=>mf,Script:()=>hf,String:()=>Me,Symbol:()=>tn,TemplateLiteral:()=>bc,This:()=>Br,Tuple:()=>te,Uncapitalize:()=>Rl,Undefined:()=>on,Union:()=>w,Unknown:()=>ue,Unsafe:()=>hs,Uppercase:()=>Ol,Void:()=>Wr,With:()=>uf});var sr="submit_test_gap_candidates",mr="submit_filtered_test_gaps",pr="submit_solver_gaps",p8=G.Object({verdict:G.Union([G.Literal("PASS"),G.Literal("FAIL")],{description:"FAIL only for a genuine blocking issue (clear rubric violation, agent-fault-worthy gap, unfair/undiscoverable test requirement, or a real determinism/regression risk). Optional, minor, or stylistic points are NOT grounds for FAIL \u2014 put those in `notes` instead and use PASS."}),summary:G.String({description:"One short sentence summarizing the verdict."}),reasons:G.Array(G.String(),{description:"Specific BLOCKING justifications only, citing rubric item IDs and concrete evidence from the files you read. Required (non-empty) when verdict is FAIL. Use an empty array when verdict is PASS."}),notes:G.Array(G.String(),{description:"Non-blocking, optional/minor observations or suggested improvements \u2014 the kind of feedback a real reviewer leaves as 'Minor/optional' without failing the task. Include these regardless of verdict; use an empty array if you truly have none."})});var $v=G.Object({statement:G.String({description:"One sentence from agent_prompt.md, copied verbatim."}),gaps:G.Array(G.Object({description:G.String({description:"A fair, publicly observable missing behavioral test."}),risk:G.String({description:"Why an incorrect implementation could pass the current tests despite this missing behavior."})}),{description:"All candidate positive and negative gaps for this sentence; there is no maximum or target count, so include every distinct evidence-backed gap and relevant edge case rather than stopping at 10; use an empty array only when exhaustive analysis finds none."})});function gf(e){return{name:sr,label:"Submit Candidate Test Gaps",description:"Submit one candidate-gap list for one prompt sentence. Call this after each sentence so the orchestrator can track the todo list; empty lists are required when that sentence has no gaps.",parameters:$v,async execute(t,n){let r=e.statements??[];return r.push({statement:n.statement,gaps:n.gaps??[]}),e.statements=r,{content:[{type:"text",text:`Recorded ${n.gaps?.length??0} candidate gap(s)`}],details:void 0}}}}var kv=G.Object({gaps:G.Array(G.Object({description:G.String({description:"The confirmed, real, fair test gap (may be reworded for clarity). Keep POSITIVE:/NEGATIVE: prefix when applicable."}),justification:G.String({description:"Why this is genuinely grounded in agent_prompt.md or the repo, fair to test per the fairness methodology, and a real (non-duplicate) coverage hole in test.patch \u2014 for negative gaps, cite the prompt's prohibition/constraint and why no existing test catches the forbidden outcome."})}),{description:"The filtered, final list of confirmed test gaps. Use an empty array if none of the candidates survive strict scrutiny."})});function yf(e){return{name:mr,label:"Submit Filtered Test Gaps",description:"Submit your final, strictly filtered list of confirmed test gaps. This is the ONLY way to report your result \u2014 call it exactly once, as your last action, after you have independently verified each candidate.",parameters:kv,async execute(t,n){let r=n.gaps??[];return e.gaps=r,{content:[{type:"text",text:`Confirmed ${r.length} gap(s) after filtering`}],details:void 0}}}}var wv=G.Object({gaps:G.Array(G.Object({description:G.String({description:"The specific behavioral gap: a way one or more solver's diff differs materially from what agent_prompt.md/solution.patch require, despite that solver passing `./test.sh new`."}),justification:G.String({description:"Why this is a genuine requirement from agent_prompt.md or solution.patch (cite the specific requirement/line) that the solver's diff misses, contradicts, or diverges from \u2014 and why the current tests fail to catch that divergence."}),evidence:G.String({description:"Which solver(s) (by index) exhibit this, and the specific part of their diff that grounds the gap."})}),{description:"Concrete, diff-grounded behavioral gaps \u2014 cases where a passing solver's materially different approach reveals that `test.sh new` under-specifies a real requirement. Use an empty array if the solvers converged on equivalent behavior; do not manufacture gaps just to report something."})});function xf(e){return{name:pr,label:"Submit Solver Gaps",description:"Submit your final list of behavioral gaps found by comparing the solver diffs against the real solution.patch. This is the ONLY way to report your result \u2014 call it exactly once, as your last action, after you have finished comparing every solver.",parameters:wv,async execute(t,n){let r=n.gaps??[];return e.gaps=r,{content:[{type:"text",text:`Recorded ${r.length} solver gap(s)`}],details:void 0}}}}function Ev(e){return[e,"You are working inside the actual repository (this is your current directory) in read-only mode. You have access to read/grep/find/ls tools only \u2014 you cannot execute code or edit files.","Read `agent_prompt.md` for the task requirements and inspect the repository's existing source/code files with read/grep/find/ls. Base the analysis on the prompt and the observable behavior supported by those code files."]}var Sv=["Thoroughness \u2014 your job is high recall on genuine gaps only:","- There is no target count or cap: do not stop at 10 (or any other arbitrary number). For each prompt sentence, enumerate as many distinct uncovered required behaviors and edge cases as the files justify, then continue until an additional sweep finds no new genuine gap.","- Find every gap you can justify with concrete evidence. Do not stop after the first obvious ones \u2014 keep reading until you have systematically covered the prompt and relevant repository code.","- After your first pass, run at least one deliberate second sweep (re-read `agent_prompt.md` and grep/read the relevant code files) before submitting \u2014 but if that sweep still finds nothing, submit an empty list.","- Do not self-censor or merge distinct genuine gaps into one \u2014 the validator will prune. Never invent or pad the list to seem thorough; an empty array is correct when exhaustive analysis truly finds none.","- Hunt subtle gaps too: behaviors that may be missed under other valid inputs, repository conventions, interaction effects, ordering/timing, and branches in the relevant source code that need behavioral coverage.","- Include a candidate only when you can cite specific grounding and a concrete false-pass risk \u2014 not to meet a quota."],bf=["Fairness rules \u2014 apply these to every proposed gap and every proposed assertion:","- Ground every candidate in a specific sentence or requirement in `agent_prompt.md`, or in an existing public contract that is clear and directly relevant in the repository. Record the observable behavior and the plausible incorrect implementation that could pass without this check. Do not create requirements from intuition, taste, general best practice, or a desire for more coverage.","- Treat `agent_prompt.md` as the task contract. Existing source can clarify how an already-public API behaves and can make an established convention discoverable, but a neighboring helper, default, example, or implementation choice does not automatically become a requirement for a new behavior. If repository evidence is absent, mixed, or contradictory, leave the detail open rather than choosing one interpretation.","- A fair check must be expressible through a user-visible result, a caller-visible side effect, a named public API, or another documented/public contract. Do not require private state, private helpers, internal classes, file placement, module boundaries, call order, a particular algorithm, or a particular direct platform/API call when another repo-valid route produces the required outcome.","- A newly invented function, class, property, export, constructor, method name, argument shape, import path, or registry/config key is not a fair requirement merely because it would be a convenient way to test the feature. Require a new API only when `agent_prompt.md` names it, or when the API already exists publicly and the task explicitly relies on it.","- For UI behavior, assert the user-facing control, label, visible state, accessible action, or resulting effect when that is the contract. Do not require a particular DOM hierarchy, tag, CSS class, selector, test/data attribute, ARIA attribute, hidden-shim text, focus order, keyboard traversal, or control implementation unless the prompt or an established public UI contract explicitly requires it.","- Test semantics rather than source representation. Do not pin quote style, whitespace, line breaks, token adjacency, identifier spelling, generated-source wording, code length, AST node shape, type-text spelling, serialization style, or a particular equivalent syntax when the resulting behavior is the same. Normalize, parse, compile, or observe the result when that is necessary to compare equivalent forms.","- For structured results, assert the fields, values, relationships, ordering, and preservation that the contract actually requires. Allow additional valid fields and metadata unless the prompt explicitly forbids them. Do not compare a whole object, list, mapping, or serialized document to a minimal reference-shaped object when only a subset of its contents is contractual. For unspecified unknown fields, do not assume either permissive or strict validation: acceptance is fair only when extras are expressly allowed or established, and rejection is fair only when unknown fields are expressly forbidden or established at that schema level.","- Treat configuration schemas as contracts, not guesses. Field type, collection shape, omitted-field defaults, unknown-key policy, extension-based dispatch, coercion, and cross-field constraints are independently specified decisions. Do not require a string-only name, a particular list shape, a filename-driven parser, a boolean-only flag, a valid range relationship, or rejection of an extra key unless the prompt or a public schema settles it.","- Make aggregation semantics explicit before requiring exact counts. A count may be per input, field, item, target, rule, match, category, finding, log record, or operation; multiple units may overlap or be mutually exclusive. For repair or mutation output, also distinguish findings measured before the change from findings remaining after the change. If the contract does not choose the unit, test presence, effect, or a stated relationship rather than an exact number.","- Do not resolve interactions between separately described rules by intuition. Optional-path handling versus target-level checks, validation versus evaluation, duplicate detection across collections, cache reuse versus a new input, and consensus among agreeing versus dissenting values each need an explicit precedence or scope. A test must not silently choose skip-all versus continue, majority versus unanimity, per-collection versus global deduplication, or disjoint versus overlapping diagnostic categories.","- Do not infer a concrete value from relational wording. Terms such as current, latest, selected, next, matching, appropriate, or stable require the stated relationship or effect, not an arbitrary numeric or serialized value. Pin a concrete value only when the prompt or a clear existing public contract determines it.","- Do not infer an exact ordering, grouping, cardinality, count, or error-counting model from incidental map order, loop order, a convenient fixture, or one implementation. Require ordering or counts only when the contract makes them observable; otherwise assert membership, relationships, preservation, and the required effect without choosing a granularity the prompt leaves open. This includes order of newly added versus loaded values and the number or placement of repeated diagnostic terms.","- Preserve scope qualifiers. A requirement for aware values, naive values, all-day values, one mode, one target state, or one lifecycle phase does not automatically apply to every representation or phase. Do not transfer a rule from one subtype to another, or require a changed wall time, timezone, normalization, or side effect outside the scope in which the prompt states it.","- Do not invent an input-domain policy for unspecified cases. Do not require acceptance or rejection of a particular malformed, nullish, Unicode, unusually large, boolean-like, platform-specific, symlink, missing-parent, or other boundary value unless the prompt or an established public contract settles that case. A sensible API policy is not automatically the specified policy.","- For failures, assert the failure or user-visible error behavior required by the contract. Do not require a specific exception class, message wording, punctuation, embedded input value, capitalization, basename, validation phase, or eager-versus-deferred timing unless it is explicitly promised or publicly established. If the contract only says an operation fails clearly, accept equivalent clear failures. When the prompt expressly permits more than one failure phase or handling path\u2014such as load-time rejection or evaluation-time violation\u2014accept every permitted path; do not force one merely because it is easier to assert.","- Do not assume an expression or embedded language has unlisted builtins, operators, container types, mutability, mapping shapes, or context bindings. Test only the language surface and binding representation that the prompt or an existing public evaluator contract names. A useful operation such as length, indexing, mutation, or a helper call is not implicitly available in a restricted environment.","- Respect asynchronous and lazy contracts. If the prompt promises an eventual effect, do not require a callback to return a promise, immediate settlement, a particular debounce interval, construction-time validation, or one exact observation point. Trigger the public operation and observe or wait for the promised result at a fair boundary.","- Do not select an outcome for an underspecified mode boundary. Dry-run, preview, no-op, conflict, rollback, cache, preflight, and post-context-change behavior may have multiple valid outcomes unless the prompt chooses one. Test the guarantees that are stated, such as non-mutation or reporting, without adding a rejection, write, refresh, or validation policy that was not stated.","- Do not convert an incidental side effect into a requirement. For a no-op or reuse case, test the required content, state, preservation, or absence of duplicate effects; do not additionally require an empty file, directory, cache entry, history item, or other artifact to exist or not exist unless that artifact is part of the contract.","- For logs and status messages, check that the required operation or failure is reported when reporting is contractual. Do not demand arbitrary English words, formatting, punctuation, path spelling, message fragments, or exact output layout when the prompt only requires that the operation be communicated.","- A fair behavioral test must not depend on a hidden harness's mock shape, a source-level monkeypatch landing at one import binding, an incomplete module mock, reassigned exported state, a particular failure-injection primitive, or a synthetic fixture that violates real repository invariants. Patch or fake a dependency at a public lookup boundary that supports the repository's valid import styles, rather than assuming whether code imports a module or a symbol. A reasonable implementation must be able to use the repository's valid public exports and state model without being rejected by the setup.","- Test doubles must preserve the public interface and lifecycle needed to reach the assertion. A double for a collaborator must implement existing extension points, return valid shapes, and provide newly required public capabilities or isolate them through an explicit seam. Do not make a detached constructor, unmounted widget, partial collection, missing pane service, or fake cache stand in for an active production flow unless that detached behavior is itself contractual.","- Separate fairness from test strength. A test can be fairly scoped yet too weak if it observes a color anywhere instead of on the required target, checks a generic message without associating it with the operation, or verifies a destination representation without preserving the required identity/instant/relationship. Do not call such a test unfair for being permissive; treat it as insufficient coverage and require a precise public observation.","- Distinguish the semantic goal from the assertion form. If a candidate contains a fair behavioral core plus an unsupported value, representation, timing, API, or harness assumption, keep or rewrite the fair core and remove only the unsupported co-assertion. Do not discard a real gap merely because the first proposed assertion was too specific.","- Do not turn a harness safety limit into a product requirement. A test-level subprocess timeout, signal alarm, poll interval, viewport size, or platform-specific signal is only fair when the task or public performance contract specifies it. Use a separate generous anti-hang guard for malformed or pathological evaluation, and assert the required bounded/failure outcome without choosing an arbitrary wall-clock budget.","- A failed setup and a failed behavioral assertion are different evidence. If a shared fixture crashes before the feature is observed, or an observer renders the wrong viewport/widget after locating a valid result, the test is broken rather than proof of an implementation gap. If the fixture reaches the public behavior but rejects a valid alternative representation or integration path, it is a contract/test mismatch. Do not treat either as a fair behavioral requirement.","- Edge-case coverage is valuable only when the edge case is required or discoverable. Do not report 'more negative tests would be nice' or every conceivable malformed input. Keep a candidate only when it is distinct, publicly testable, concretely grounded, and could let a materially incorrect implementation pass.","- When uncertain, re-read the exact prompt sentence and the closest public source analogues. If two competent implementations can satisfy the contract while differing on the proposed assertion, the assertion is not fair; return the semantic relationship instead or drop the candidate. An empty result is correct when no candidate survives this standard."],If=bf,Rv=bf;function vf(e,t){let n=[...Ev("You are an exhaustive behavioral test-gap finder. Review the task prompt sentence by sentence, finding both missing required-behavior (positive) and missing forbidden/wrong-behavior (negative) tests."),"","First split `agent_prompt.md` into its meaningful sentences using periods (`.`) as the sentence boundary. Create an explicit TODO checklist of every resulting requirement sentence. Work through it one item at a time; do not finish until every item is checked off.","","Before analyzing each sentence, use read/grep/find/ls to inspect the relevant source files and their closest analogues. Use that code context to understand the public contracts, conventions, branches, guards, early returns, state transitions, side effects, boundary handling, and negative/prohibited outcomes required by the sentence. Report every distinct, prompt-required behavioral edge case or prohibition that a plausible implementation could miss. Include positive and negative gaps together for that sentence. There is no maximum number of gaps: keep enumerating distinct missing behaviors for this sentence, including boundary, empty, repeated, interacting, and other relevant edge cases; do not treat 10 as sufficient.","",...Sv,"",...If,"","Test-coverage checklist for calibration:",e];return n.push("","Fairness: keep only behavior that a user, caller, or existing public contract can observe. Do not require private helpers, internal state, implementation structure, call order, selectors, or incidental strings unless the task explicitly makes them public requirements."),n.push("","For every candidate, state the missing fair behavioral test, the relevant source behavior or branch that led you to investigate it, and why a plausible incorrect implementation could evade that test. The prompt sentence is the required specification: do not report incidental implementation details it does not require. Do not propose the exact test implementation.",`After completing EACH TODO sentence, call \`${sr}\` with that exact sentence and its gap array (including an empty array when none exist). You may and must call the tool multiple times: once per sentence. Only finish after every TODO item has been submitted.`),n.join(`
11
+ `)}function Tf(e,t,n){let r=["You are a strict, skeptical fairness auditor for a coding-agent benchmark task.","You are working inside a throwaway, read-only copy of a git repository (this is your current directory). You have access to read/grep/find/ls tools only \u2014 you cannot execute code or edit files.","Two specialized research agents reviewed `agent_prompt.md` and the repository's source/code files sentence by sentence, proposing both positive (missing required-behavior) and negative (missing forbidden/wrong-behavior) gaps. It submitted the following per-sentence candidate report:","",JSON.stringify(e,null,2),"","Your job is to independently re-verify the files yourself and FILTER this list down to only candidates that are ALL of the following:","1. Genuinely grounded \u2014 actually required by a specific statement in `agent_prompt.md`, or unambiguous from clearly visible, existing repo behavior. Drop anything speculative, nice-to-have, or invented beyond what the prompt actually asks for.","2. Fair to test \u2014 verifying it would not require undiscoverable private internals, an invented/unnamed API, or exact incidental implementation structure. Judge this precisely against the fairness guidance below.","3. A real, distinct behavioral gap \u2014 drop near-duplicate candidates and keep only the clearest phrasing of each distinct gap. Retain a candidate only when the source code and prompt provide concrete grounding for a behavior that deserves an explicit public-outcome check.","4. Behaviorally testable through a public contract \u2014 drop candidates that would require an internal helper, private state, implementation structure, call order, DOM class/attribute/data hook, selector, or exact string literal. The sole exceptions are details explicitly named in `agent_prompt.md` or already established as a public contract in the existing repository.","","Be strict: when genuinely unsure whether a candidate holds up, drop it rather than keep it. It is fine \u2014 expected, even \u2014 to return an empty list if none of the candidates survive scrutiny.","","Checklist for the tests focus area, for calibration:",t];return r.push("","Fairness: keep only behavior that a user, caller, or existing public contract can observe. Do not require private helpers, internal state, implementation structure, call order, selectors, or incidental strings unless the task explicitly makes them public requirements.","",...Rv),r.push("","For every gap you keep, give a short justification citing where in `agent_prompt.md` or the repo it is grounded. Preserve POSITIVE:/NEGATIVE: prefix when applicable.",`When you are done, call the \`${mr}\` tool exactly once with your final filtered list (which may be empty). That tool call is your only way to report a result.`),r.join(`
12
+ `)}function $f(){return["You are a adversarial tester. Your goal is to find the most minimal, shortcut implementation that makes all new tests pass \u2014 not a full, correct solution. This is intentional: we want to discover whether the test suite lets through an implementation that barely satisfies the assertions without properly implementing the prompt's required behavior.","`agent_prompt.md` in the repo root describes the intended task. Tests for it already exist and are currently failing.","","Goal: make ALL of the new tests pass with the least amount of real logic possible.","1. Run `bash test.sh new` to see the failures and what the tests expect. Read the failing tests carefully \u2014 they are the only spec you need to satisfy.","2. Understand exactly what each test assertion checks. Ask, 'what is the minimum thing I can do \u2014 a stub, a hardcoded return, a mockish pass-through, a trivial branch \u2014 to satisfy this test?', not 'what does agent_prompt.md intend?'. Skim `agent_prompt.md` only enough to understand what the test file names and assertions refer to, then rely on the test errors to drive what to implement.","3. Prefer the most minimal implementation possible:"," - Hardcode a return value if the test expects one."," - Add only the code paths a test actually exercises; leave anything untested unimplemented."," - Mock the minimum number of dependencies (or none) that the test error forces you to touch."," - Use the most direct, trivial, shortcut approach \u2014 do not build abstractions, do not handle unobserved edge cases, do not add defensive code.","4. Before declaring success, also run `bash test.sh base` to confirm your changes cause no regressions. The shortcut must not break existing tests \u2014 that would be a false positive from a different angle.","5. Re-run `bash test.sh new` and iterate until both the new tests and the base tests pass, or you're confident you cannot pass more without adding real logic.","","Rules:","- Do NOT modify the test files or `test.sh`. Only change application/library code.","- You have shell access \u2014 install any dependencies you need.","- The prompt is not your spec: the tests are. Implement exactly what the tests demand, nothing more. If you can satisfy a test with a hardcoded return, do it."].join(`
13
+ `)}function Ov(e){let t=e.status==="ok"?e.passed?"PASSED all new tests":"did NOT pass all new tests":`did not complete normally (status: ${e.status})`;return`- Solver ${e.index} \u2014 ${t} \u2014 solution.diff / test_output.txt in \`${kn}/solver_${e.index}/\``}function kf(e,t,n){let r=["You are a strict, skeptical behavioral-gap auditor for a coding-agent benchmark task.","You are working inside a throwaway, read-only copy of a git repository (this is your current directory). You have access to read/grep/find/ls tools only \u2014 you cannot execute code, apply patches, or edit files.","The repo root contains `agent_prompt.md` (the real task description), `solution.patch` (a unified diff of the real golden/reference solution), and `test.patch` (a unified diff adding the hidden tests).","",`Separately, several coding agents ('solvers') were each given the same \`agent_prompt.md\` plus the failing tests from \`test.patch\` \u2014 but never \`solution.patch\` \u2014 and asked to implement the task TDD-style, iterating with real shell access until the tests passed or they gave up. Each solver's diff and full \`test.sh new\` output \u2014 captured and verified independently by the harness, not self-reported \u2014 is saved under \`${kn}/solver_<index>/\` (\`solution.diff\`, \`test_output.txt\`), with a \`${kn}/manifest.json\` summary. Use read/grep/find/ls to open exactly what you need. Status summary:`,"",...e.map(Ov),"","Your job: compare the reference `solution.patch` with each solver's `solution.diff` to find concrete BEHAVIORAL GAPS. Keep only a difference where: (a) `agent_prompt.md` explicitly requires the behavior, (b) the solver passed the relevant tests (even if it failed elsewhere), (c) the reference and solver produce observably different behavior for a real edge case or scenario, and (d) a fair public-facing test could distinguish them. The reference solution is evidence for scenarios to inspect, never a specification by itself.","","How to work:","1. Read `agent_prompt.md` sentence by sentence and note every distinct requirement, constraint, and prohibition.","2. Read `solution.patch` to see how the reference solution satisfies those requirements.","3. For each solver, read its `solution.diff` and compare it against the reference behavior. Look specifically for a solver shortcut, missed constraint, edge case, or side effect that the PROMPT requires, where the solver still passes because the tests do not observe the behavioral difference.","4. A solver that did not pass the full suite may still provide evidence for a completed, relevant part of its diff, but only when its test output shows the failure is unrelated to that behavior (or shows the relevant tests already passed). Do not treat its failing behavior as a gap, and do not infer gaps from a hypothetical wrong implementation.","5. Treat multiple solvers converging on the same divergent-but-passing shortcut as stronger evidence of a real gap, not proof it's acceptable \u2014 the tests are what's under scrutiny, not majority solver behavior.","",...If,"- Every gap must be evidenced by an actual, cited solver diff and a contrasting reference behavior. For a solver that failed the full suite, also cite its test output showing that the relevant behavior already passed or is unrelated to the failure. Cite the prompt sentence that makes the behavioral difference required; do not report a gap that is purely theoretical or based only on the reference implementation.","- It is fine, and expected, to submit an empty list if the solvers that passed all converged on behavior equivalent to the reference solution with no material gaps.","- Do not self-censor for volume, but do not pad the list either \u2014 only include what you can concretely justify with cited evidence.","","For reference, here is the checklist for the tests focus area (use it to calibrate what good coverage looks like, not as a list of gaps to report verbatim):",t];return n&&r.push("","Fairness methodology (context on what a fair, in-scope requirement looks like):",n),r.push("",`When you are done, call the \`${pr}\` tool exactly once with your final list (which may be empty). That tool call is your only way to report a result.`),r.join(`
14
+ `)}var Pv=900*1e3,ci=["read","grep","find","ls"];function Aa(e){return e==="off"?void 0:e}async function Ca(e,t,n=Pv){return t.aborted?"cancelled":new Promise((r,a)=>{let i=!1,m,u=()=>{m!==void 0&&clearTimeout(m),t.removeEventListener("abort",f)},l=h=>{i||(i=!0,u(),r(h))},f=()=>l("cancelled");m=setTimeout(()=>l("timedOut"),n),t.addEventListener("abort",f,{once:!0}),e().then(()=>l("done"),h=>{i||(i=!0,u(),a(h))})})}async function Ma(e){if(e){try{e.isIdle||await e.abort()}catch{}e.dispose()}}async function qa(e){let t={},n=e.model,r;try{({session:r}=await Oa({cwd:e.tempDir,model:n,thinkingLevel:Aa(e.thinkingLevel),tools:[...ci,sr],customTools:[gf(t)],sessionManager:Pa.inMemory()}));let a=await Ca(async()=>{await r?.prompt(vf(e.testRubric,e.fairnessRules))},e.cancelSignal);if(a!=="done")return await r.abort(),{status:a,gaps:[]}}catch{return{status:"error",gaps:[]}}finally{await Ma(r)}return t.statements?{status:"ok",gaps:t.statements}:{status:"noSubmission",gaps:[]}}var Av=["read","grep","find","ls","write","edit","bash"];async function wf(e){let t=e.model,n=Pa.inMemory(),r;try{({session:r}=await Oa({cwd:e.solverDir,model:t,thinkingLevel:Aa(e.thinkingLevel),tools:[...Av],sessionManager:n}));let a=await Ca(async()=>{await r?.prompt($f())},e.cancelSignal,e.timeoutMinutes*60*1e3);return a!=="done"&&await r.abort(),{outcome:a,trajectory:n.getEntries()}}catch{return{outcome:"error",trajectory:[]}}finally{await Ma(r)}}async function Ef(e){let t={},n=e.model,r;try{({session:r}=await Oa({cwd:e.tempDir,model:n,thinkingLevel:Aa(e.thinkingLevel),tools:[...ci,pr],customTools:[xf(t)],sessionManager:Pa.inMemory()}));let a=await Ca(async()=>{await r?.prompt(kf(e.solverResults,e.testRubric,e.fairnessRules))},e.cancelSignal);if(a!=="done")return await r.abort(),{status:a,gaps:[]}}catch{return{status:"error",gaps:[]}}finally{await Ma(r)}return t.gaps?{status:"ok",gaps:t.gaps}:{status:"noSubmission",gaps:[]}}async function La(e){let t={},n=e.model,r;try{({session:r}=await Oa({cwd:e.tempDir,model:n,thinkingLevel:Aa(e.thinkingLevel),tools:[...ci,mr],customTools:[yf(t)],sessionManager:Pa.inMemory()}));let a=await Ca(async()=>{await r?.prompt(Tf(e.statementReports,e.testRubric,e.fairnessRules))},e.cancelSignal);if(a!=="done")return await r.abort(),{status:a,gaps:[]}}catch{return{status:"error",gaps:[]}}finally{await Ma(r)}return t.gaps?{status:"ok",gaps:t.gaps}:{status:"noSubmission",gaps:[]}}var St="checks_progress";function ur(e,t,n,r){let a=n>0?Math.min(1,t/n):0,i=Math.round(24*a),m="\u2588".repeat(i)+"\u2591".repeat(Math.max(0,24-i)),u=r?` pass:${r.passed} fail:${r.failed}`:"";return[`checks: ${e} [${m}] ${t}/${n}${u}`]}import{existsSync as Cv,readFileSync as Mv}from"node:fs";var li=["agent_prompt.md","solution.patch","test.patch"];function di(e=new Date){let t=(i,m=2)=>String(i).padStart(m,"0"),n=-e.getTimezoneOffset(),r=n>=0?"+":"-",a=Math.abs(n);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}.${t(e.getMilliseconds(),3)}${r}${t(Math.floor(a/60))}:${t(a%60)}`}function Sf(e){try{if(!Cv(e))return{};let t=JSON.parse(Mv(e,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function Rf(e){let t={...e.existingReport,timestamp:di(),model:`${e.config.provider}/${e.config.modelId}`,thinkingLevel:e.config.thinkingLevel};return delete t.overall,delete t.reports,e.runGapFinder&&(t.testGaps=e.testGaps,e.gapAnalysisIncomplete?t.testGapAnalysisNote=`Gap analysis did not fully complete (sentence finder: ${e.gapFinderStatus}, review: ${e.gapFilterStatus}); testGaps may be incomplete.`:delete t.testGapAnalysisNote),e.runSolverGapFinder&&(t.solverRunSummary=e.solverResults.map(n=>({index:n.index,status:n.status,passed:n.passed,durationMs:n.durationMs,totalTests:n.totalTests,failedTests:n.failedTests,artifactsDir:n.artifactsDir})),t.solverGaps=e.solverGaps,e.solverGapAnalysisIncomplete?t.solverGapAnalysisNote=`Solver-gap analysis did not fully complete (comparison reviewer: ${e.solverComparisonStatus}); solverGaps may be incomplete.`:delete t.solverGapAnalysisNote),t}function Of(e){let t=Math.round(e/1e3);return t>=60?`${Math.floor(t/60)}m ${t%60}s`:`${t}s`}function Pf(e){let t=Array.isArray(e.merged.testGaps)?e.merged.testGaps.length:0,n=e.runSolverGapFinder&&Array.isArray(e.merged.solverRunSummary)?e.merged.solverRunSummary.map(i=>({...i,durationMs:i.durationMs??0})):[],r=Array.isArray(e.merged.solverGaps)?e.merged.solverGaps.length:0,a=[];return e.runGapFinder&&a.push(t>0?`${t} test gap(s) found`:"no test gaps found"),e.runSolverGapFinder&&a.push(`${n.filter(i=>i.passed).length}/${n.length} solvers passed, ${r} gap(s) found`),{content:`Gap finders: ${a.join(" | ")}`,details:{gapsCount:t,showGaps:e.runGapFinder,showSolverGaps:e.runSolverGapFinder,solverDetails:n,solverGapsCount:r}}}var Af=`## The problem description (aka the task)\r
15
15
  P1: Aligns with the repo's philosophy\r
16
16
  P2: Self-contained \u2014 solvable from the repo and description alone\r
17
17
  P3: Clear, concise, and unambiguous \u2014 describes what to build or fix and don't leave points for guessing\r
@@ -38,7 +38,7 @@ That's the golden solution \u2014 the proof that your task is solvable and that
38
38
  S1: The solution should meet all the requirements. (If it's missing a requirement and it manages to pass your tests, you're in a bad position \u{1F620}.)\r
39
39
  S2: No regressions and follow existing code patterns. Don't break existing working code by mistake (we'll still run the repo's existing tests).\r
40
40
  S3: No irrelevant changes to the code \u2014 if something is unrelated to your task, keep it as it is.\r
41
- S4: No AI slop (weird comments, unexplained defensive code, new coding patterns, etc).`,Lv=`# Agent Evaluation Guidelines\r
41
+ S4: No AI slop (weird comments, unexplained defensive code, new coding patterns, etc).`,qv=`# Agent Evaluation Guidelines\r
42
42
  \r
43
43
  This file describes how to align a task prompt, reference solution, and tests for fair coding-agent evaluation. It is generic and can be reused across repositories and tasks.\r
44
44
  \r
@@ -323,9 +323,8 @@ Keep changes separated when possible:\r
323
323
  - Avoid unrelated dependency or lockfile changes.\r
324
324
  - Regenerate patches after every prompt/test/solution change.\r
325
325
  \r
326
- ---`;function ja(){return(Cf.split(/\r?\n(?=## )/g).find(t=>/^## The tests/i.test(t.trim()))??Cf).trim()}function Fa(){return Lv.trim()}var Da=!1,In;function Ga(){return Da}function Mf(){return Da=!0,In=new AbortController,In}function Lf(){Da=!1,In=void 0}function qf(){return!Da||!In||In.signal.aborted?!1:(In.abort(),!0)}import{existsSync as qv}from"node:fs";import{join as jv}from"node:path";import{keyHint as Fv}from"@earendil-works/pi-coding-agent";import{Text as Dv,wrapTextWithAnsi as Gv}from"@earendil-works/pi-tui";var cr="analyze_test_gaps",jf=6;function Ff(e){e.registerTool({name:cr,label:"Gap Finder",description:"Only call this when the user explicitly asks for gap analysis or asks you to run Gap Finder. Run a sequential, sentence-by-sentence behavioral test-gap analysis on the current task and its repository source files: a read-only finder agent iterates through every sentence in agent_prompt.md and proposes missing positive/negative behavioral tests per sentence, then a read-only fairness reviewer filters out unfair or internally-observable candidates (skipped when the finder found nothing). Returns the confirmed gaps as the tool result (details.testGaps). Never writes or modifies files. For an explicitly requested iterative workflow, the caller should apply the returned gaps as tests and invoke this tool again sequentially.",promptSnippet:"When asked, analyze the task's hidden tests for behavioral coverage gaps",promptGuidelines:["Call analyze_test_gaps only when the user explicitly asks you to find/analyze test gaps or run Gap Finder; do not call it proactively or for unrelated work.","Run one analysis at a time and wait for it to finish; never issue multiple analyze_test_gaps calls in parallel.","If the user asks for repeated or iterative gap finding, after each result apply the confirmed gaps as tests, then run analyze_test_gaps again sequentially; repeat until a pass finds no new fair gaps, or the gaps are non-trivial or the user says to stop. The tool is read-only, so the caller performs the test changes."],parameters:G.Object({}),renderCall(t,n,r){let a=r.state;r.executionStarted&&a.startedAt===void 0&&(a.startedAt=Date.now(),a.endedAt=void 0);let i=r.lastComponent??new Dv("",0,0);return i.setText(""),i},renderResult(t,n,r,a){let i=a.state;i.startedAt!==void 0&&n.isPartial&&!i.interval&&(i.interval=setInterval(()=>a.invalidate(),1e3)),(!n.isPartial||a.isError)&&(i.endedAt??=Date.now(),i.interval&&(clearInterval(i.interval),i.interval=void 0));let m=n.isPartial?"Elapsed":"Took",u=i.endedAt??Date.now(),l=i.startedAt!==void 0?Uv(u-i.startedAt):"\u2014",f=t.details,h=Array.isArray(f?.testGaps)?f.testGaps.length:void 0,v=[`${m} ${l}`];h!==void 0&&v.push(`${h} gap${h===1?"":"s"}`);let E=r.fg("toolTitle",r.bold("Gap Finder"))+r.fg("muted",` ${v.join(" \xB7 ")}`),F=(t.content??[]).map(me=>me.type==="text"?me.text:"").join(`
326
+ ---`;function ja(){return(Af.split(/\r?\n(?=## )/g).find(t=>/^## The tests/i.test(t.trim()))??Af).trim()}function Fa(){return qv.trim()}var Da=!1,bn;function Ga(){return Da}function Cf(){return Da=!0,bn=new AbortController,bn}function Mf(){Da=!1,bn=void 0}function qf(){return!Da||!bn||bn.signal.aborted?!1:(bn.abort(),!0)}import{existsSync as Lv}from"node:fs";import{join as jv}from"node:path";import{keyHint as Fv}from"@earendil-works/pi-coding-agent";import{Text as Dv,wrapTextWithAnsi as Gv}from"@earendil-works/pi-tui";var cr="analyze_test_gaps",Lf=6;function jf(e){e.registerTool({name:cr,label:"Gap Finder",description:"Only call this when the user explicitly asks for gap analysis or asks you to run Gap Finder. Run a sequential, sentence-by-sentence behavioral test-gap analysis on the current task and its repository source files: a read-only finder agent iterates through every sentence in agent_prompt.md and proposes missing positive/negative behavioral tests per sentence, then a read-only fairness reviewer filters out unfair or internally-observable candidates (skipped when the finder found nothing). Returns the confirmed gaps as the tool result (details.testGaps). Never writes or modifies files. For an explicitly requested iterative workflow, the caller should apply the returned gaps as tests and invoke this tool again sequentially.",promptSnippet:"When asked, analyze the task's hidden tests for behavioral coverage gaps",promptGuidelines:["Call analyze_test_gaps only when the user explicitly asks you to find/analyze test gaps or run Gap Finder; do not call it proactively or for unrelated work.","Run one analysis at a time and wait for it to finish; never issue multiple analyze_test_gaps calls in parallel.","If the user asks for repeated or iterative gap finding, after each result apply the confirmed gaps as tests, then run analyze_test_gaps again sequentially; repeat until a pass finds no new fair gaps, or the gaps are non-trivial or the user says to stop. The tool is read-only, so the caller performs the test changes."],parameters:G.Object({}),renderCall(t,n,r){let a=r.state;r.executionStarted&&a.startedAt===void 0&&(a.startedAt=Date.now(),a.endedAt=void 0);let i=r.lastComponent??new Dv("",0,0);return i.setText(""),i},renderResult(t,n,r,a){let i=a.state;i.startedAt!==void 0&&n.isPartial&&!i.interval&&(i.interval=setInterval(()=>a.invalidate(),1e3)),(!n.isPartial||a.isError)&&(i.endedAt??=Date.now(),i.interval&&(clearInterval(i.interval),i.interval=void 0));let m=n.isPartial?"Elapsed":"Took",u=i.endedAt??Date.now(),l=i.startedAt!==void 0?Uv(u-i.startedAt):"\u2014",f=t.details,h=Array.isArray(f?.testGaps)?f.testGaps.length:void 0,v=[`${m} ${l}`];h!==void 0&&v.push(`${h} gap${h===1?"":"s"}`);let E=r.fg("toolTitle",r.bold("Gap Finder"))+r.fg("muted",` ${v.join(" \xB7 ")}`),F=(t.content??[]).map(me=>me.type==="text"?me.text:"").join(`
327
327
  `).trim(),Y=F?Nv(F.split(`
328
- `)):["(no output)"];if(!n.expanded){let me=Math.max(0,Y.length-jf);Y=Y.slice(0,jf),me>0&&Y.push(`... (${me} more lines, ${Fv("app.tools.expand","to expand")})`)}let ae=a.lastComponent instanceof Na?a.lastComponent:new Na;return ae.setContent(E,Y,r),ae},async execute(t,n,r,a,i){if(!yr(i.cwd))throw new Error("analyze_test_gaps is disabled for this project. Enable it with /analyze:on.");let m=jv(i.cwd,"agent_prompt.md");if(!qv(m))throw new Error("Missing required file in project root: agent_prompt.md");let u=Fi()??Te(),l=u,f=l?i.modelRegistry.find(l.provider,l.modelId):i.model;if(!f||l&&!i.modelRegistry.hasConfiguredAuth(f))throw new Error("No model configured/authenticated for analyze_test_gaps. Set one via /checks --config (Analyze Tool section).");let h=u?.thinkingLevel??"off",v=new AbortController;r&&(r.aborted?v.abort():r.addEventListener("abort",()=>v.abort(),{once:!0}));let E={tempDir:i.cwd,model:f,thinkingLevel:h,testRubric:ja(),fairnessRules:Fa(),cancelSignal:v.signal};a?.({content:[{type:"text",text:"Finding behavioral test gaps sentence by sentence..."}],details:{}});let A=await La(E);if(v.signal.aborted)throw new Error("Cancelled by user.");if(A.status!=="ok")throw new Error(`Gap finder did not complete (status: ${A.status}).`);let F=A.gaps.reduce((ae,me)=>ae+me.gaps.length,0),Y=[];if(F>0){a?.({content:[{type:"text",text:`Validating ${F} candidate gap(s)...`}],details:{}});let ae=await qa({...E,statementReports:A.gaps});if(v.signal.aborted)throw new Error("Cancelled by user.");if(ae.status!=="ok")throw new Error(`Gap review did not complete (status: ${ae.status}).`);Y=ae.gaps}return{content:[{type:"text",text:Kv(Y)}],details:{testGaps:Y}}}})}function Nv(e){let t=[],n=!1;for(let r of e)/^\s*\d+\.\s+/.test(r)?(n=!1,t.push(r)):/^\s*Justification:/i.test(r)?n=!0:n||t.push(r);return t}var Na=class{header="";styledLines=[];theme;cachedWidth=-1;cachedLines=[];setContent(t,n,r){this.header=t,this.styledLines=n.map(a=>_v(a,r)),this.theme=r,this.cachedWidth=-1}invalidate(){this.cachedWidth=-1}render(t){if(this.cachedWidth!==t){let n=this.theme,r=[];this.header&&r.push(this.header,"");for(let a of this.styledLines)n?r.push(...Gv(a,t)):r.push(a);this.cachedLines=r,this.cachedWidth=t}return this.cachedLines}};function _v(e,t){let n=e.match(/^(\d+)\.\s+(.*)$/);return n?`${t.fg("accent",`${n[1]}.`)} ${t.fg("muted",n[2]??"")}`:t.fg("toolOutput",e)}function Uv(e){return`${Math.floor(e/1e3)}s`}function Kv(e){return e.length===0?"Gap analysis complete: no confirmed behavioral test gaps were found.":["Below are the gaps found by another agent. If they are fair under our prompt, we need to add tests to fix the gap. If not fair, do not mind those \u2014 only add tests for gaps that are absolutely fair.","",...e.map((n,r)=>`${r+1}. ${n.description}
328
+ `)):["(no output)"];if(!n.expanded){let me=Math.max(0,Y.length-Lf);Y=Y.slice(0,Lf),me>0&&Y.push(`... (${me} more lines, ${Fv("app.tools.expand","to expand")})`)}let ae=a.lastComponent instanceof Na?a.lastComponent:new Na;return ae.setContent(E,Y,r),ae},async execute(t,n,r,a,i){if(!yr(i.cwd))throw new Error("analyze_test_gaps is disabled for this project. Enable it with /analyze:on.");let m=jv(i.cwd,"agent_prompt.md");if(!Lv(m))throw new Error("Missing required file in project root: agent_prompt.md");let u=ji()??Te(),l=u,f=l?i.modelRegistry.find(l.provider,l.modelId):i.model;if(!f||l&&!i.modelRegistry.hasConfiguredAuth(f))throw new Error("No model configured/authenticated for analyze_test_gaps. Set one via /checks --config (Analyze Tool section).");let h=u?.thinkingLevel??"off",v=new AbortController;r&&(r.aborted?v.abort():r.addEventListener("abort",()=>v.abort(),{once:!0}));let E={tempDir:i.cwd,model:f,thinkingLevel:h,testRubric:ja(),fairnessRules:Fa(),cancelSignal:v.signal};a?.({content:[{type:"text",text:"Finding behavioral test gaps sentence by sentence..."}],details:{}});let A=await qa(E);if(v.signal.aborted)throw new Error("Cancelled by user.");if(A.status!=="ok")throw new Error(`Gap finder did not complete (status: ${A.status}).`);let F=A.gaps.reduce((ae,me)=>ae+me.gaps.length,0),Y=[];if(F>0){a?.({content:[{type:"text",text:`Validating ${F} candidate gap(s)...`}],details:{}});let ae=await La({...E,statementReports:A.gaps});if(v.signal.aborted)throw new Error("Cancelled by user.");if(ae.status!=="ok")throw new Error(`Gap review did not complete (status: ${ae.status}).`);Y=ae.gaps}return{content:[{type:"text",text:Kv(Y)}],details:{testGaps:Y}}}})}function Nv(e){let t=[],n=!1;for(let r of e)/^\s*\d+\.\s+/.test(r)?(n=!1,t.push(r)):/^\s*Justification:/i.test(r)?n=!0:n||t.push(r);return t}var Na=class{header="";styledLines=[];theme;cachedWidth=-1;cachedLines=[];setContent(t,n,r){this.header=t,this.styledLines=n.map(a=>_v(a,r)),this.theme=r,this.cachedWidth=-1}invalidate(){this.cachedWidth=-1}render(t){if(this.cachedWidth!==t){let n=this.theme,r=[];this.header&&r.push(this.header,"");for(let a of this.styledLines)n?r.push(...Gv(a,t)):r.push(a);this.cachedLines=r,this.cachedWidth=t}return this.cachedLines}};function _v(e,t){let n=e.match(/^(\d+)\.\s+(.*)$/);return n?`${t.fg("accent",`${n[1]}.`)} ${t.fg("muted",n[2]??"")}`:t.fg("toolOutput",e)}function Uv(e){return`${Math.floor(e/1e3)}s`}function Kv(e){return e.length===0?"Gap analysis complete: no confirmed behavioral test gaps were found.":["Below are the gaps found by another agent. If they are fair under our prompt, we need to add tests to fix the gap. If not fair, do not mind those \u2014 only add tests for gaps that are absolutely fair.","",...e.map((n,r)=>`${r+1}. ${n.description}
329
329
  Justification: ${n.justification}`)].join(`
330
- `)}var _a=!1,Df=!1,Kt=!1;function fi(e){return e.getActiveTools().map(n=>typeof n=="string"?n:n.name)}function hi(){return _a}function zv(e){return fi(e).includes(cr)}function Ua(e){return hi()!==zv(e)}function Bv(e){Df||(Ff(e),Df=!0)}function Vv(e,t){let n=fi(e);if(t){if(n.length===0){Kt=!0;return}let r=new Set(n);r.add(cr),r.size!==n.length&&e.setActiveTools([...r])}else{let r=n.filter(a=>a!==cr);r.length!==n.length&&e.setActiveTools(r)}Kt=Ua(e)}function bn(e){let t=hi();t&&Bv(e),Vv(e,t)}function gi(e,t){_a=hr(t),Kt=!0,Gf(e)}function Gf(e,t=0){let n=hi(),r=fi(e);if(n&&r.length===0&&t<8){queueMicrotask(()=>Gf(e,t+1));return}bn(e)}function Nf(e){for(let t of[0,50,150,400])setTimeout(()=>{(Kt||Ua(e))&&bn(e)},t)}function _f(){return Kt}function yi(e,t,n){_a=n,gr(t,n),Kt=!0,bn(e)}function Uf(e,t){_a=hr(t),Kt=!0,bn(e)}var Qv="Ctrl+Shift+X";function eT(e,t){return{index:e,status:"cancelled",passed:!1,diff:"",testOutputTail:"cancelled",durationMs:t,totalTests:null,failedTests:null}}var Ii=[{value:"--gap-finder",label:"--gap-finder",description:"Find and validate behavioral test-coverage gaps"},{value:"--solver-gap-finder",label:"--solver-gap-finder",description:"Use TDD solver attempts to find behavioral gaps"},{value:"--config",label:"--config",description:"Configure gap-finder models"}];function tT(e){let t=e.trimStart(),n=/\s$/.test(t),r=t.trimEnd().split(/\s+/).filter(Boolean),a=n?"":r.at(-1)??"",i=new Set(n?r:r.slice(0,-1)),m=n?t:t.slice(0,t.length-a.length),u=i.has("--config"),l=[...i].some(h=>h!=="--config"),f=Ii.filter(h=>!i.has(h.value)&&!u&&!(l&&h.value==="--config")&&h.value.startsWith(a));return f.length?f.map(h=>({...h,value:`${m}${h.value}`})):null}async function xi(e,t,n){let r=Di();if(r.length===0)return e.ui.notify("No enabledModels configured in settings.json.","error"),null;let a=e.modelRegistry.getAll(),i=r.map(f=>{let h=Gi(f);if(!h)return null;let v=a.find(F=>F.provider===h.provider&&F.id===h.modelId),E=t?.provider===h.provider&&t?.modelId===h.modelId,A=v?`${v.name} (${f})`:f;return{ref:f,parsed:h,display:E?`${A} [current]`:A,isCurrent:E}}).filter(f=>f!==null);if(i.length===0)return e.ui.notify("Could not resolve any enabledModels entries.","error"),null;let m=[...i].sort((f,h)=>f.isCurrent===h.isCurrent?0:f.isCurrent?-1:1),u=await e.ui.select(n,m.map(f=>f.display));if(!u)return null;let l=i.find(f=>f.display===u);return l?{provider:l.parsed.provider,modelId:l.parsed.modelId}:null}function vn(e,t,n){let r=e.modelRegistry.getAll().find(a=>a.provider===t&&a.id===n);return qi(r)}var Ka={provider:"",modelId:"",thinkingLevel:"off",timeoutMinutes:Ha,solverCount:Ja,saveArtifacts:Xa},za={provider:"",modelId:"",thinkingLevel:"off"};function Hf(e,t,n,r){let a=t?vn(e,t.provider,t.modelId):["off"],i=n.provider?vn(e,n.provider,n.modelId):["off"],m=r.provider?vn(e,r.provider,r.modelId):["off"];return[{id:"reviewer-model",section:"Reviewer",label:"Model",value:t?`${t.provider}/${t.modelId}`:"not set",kind:"model"},{id:"reviewer-thinking",section:"Reviewer",label:"Thinking level",value:t?.thinkingLevel??"off",kind:"cycle",values:a},{id:"solvergap-model",section:"Solver",label:"Model",value:n.provider?`${n.provider}/${n.modelId}`:"not set",kind:"model"},{id:"solvergap-thinking",section:"Solver",label:"Thinking level",value:n.thinkingLevel,kind:"cycle",values:i},{id:"solvergap-timeout",section:"Solver",label:"Timeout",value:`${n.timeoutMinutes} min`,kind:"cycle",values:[10,20,30,40,50,Ci].filter((u,l,f)=>u>=Ai&&f.indexOf(u)===l).map(u=>`${u} min`)},{id:"solvergap-solver-count",section:"Solver",label:"Parallel agents",value:String(n.solverCount),kind:"cycle",values:Array.from({length:Mi-Ya+1},(u,l)=>`${Ya+l}`)},{id:"solvergap-save-artifacts",section:"Solver",label:"Save artifacts",value:n.saveArtifacts?"on":"off",kind:"cycle",values:["on","off"]},{id:"analyze-enabled",section:"Analyze Tool",label:"Enabled here",value:yr(e.cwd)?"on":"off",kind:"cycle",values:["on","off"]},{id:"analyze-model",section:"Analyze Tool",label:"Model",value:r.provider?`${r.provider}/${r.modelId}`:"not set",kind:"model"},{id:"analyze-thinking",section:"Analyze Tool",label:"Thinking level",value:r.thinkingLevel,kind:"cycle",values:m}]}var bi=class{constructor(t,n,r,a,i,m){this.ctx=t;this.settingsListTheme=n;this.theme=r;this.onCycleSaved=a;this.onActivateModel=i;this.onExit=m;this.rows=Hf(t,Te(),Te()?.solverGap??Ka,Te()?.analyzeGap??za)}selectedIndex=0;rows;refresh(){let t=Te();this.rows=Hf(this.ctx,t,t?.solverGap??Ka,t?.analyzeGap??za),this.selectedIndex=Math.min(this.selectedIndex,this.rows.length-1)}invalidate(){}render(t){let n=[],r=Math.min(30,Math.max(...this.rows.map(i=>i.label.length))),a;for(let i=0;i<this.rows.length;i++){let m=this.rows[i];if(!m)continue;m.section!==a&&(a!==void 0&&n.push(""),n.push(this.theme.bold(this.theme.fg("accent",m.section))),a=m.section);let u=i===this.selectedIndex,l=u?this.settingsListTheme.cursor:" ",f=m.label+" ".repeat(Math.max(0,r-m.label.length)),h=this.settingsListTheme.label(f,u),v=this.settingsListTheme.value(m.value,u);n.push(`${l}${h} ${v}`)}return n}handleInput(t){if(Bt(t,zt.ctrl("s"))||Bt(t,zt.escape)||Bt(t,zt.ctrl("c"))){this.onExit();return}if(Bt(t,zt.up)){this.selectedIndex=this.selectedIndex===0?this.rows.length-1:this.selectedIndex-1;return}if(Bt(t,zt.down)){this.selectedIndex=this.selectedIndex===this.rows.length-1?0:this.selectedIndex+1;return}if(Bt(t,zt.enter)||Bt(t,zt.return)||t===" "){let n=this.rows[this.selectedIndex];if(!n)return;if(n.kind==="model"){this.onActivateModel(n.id);return}if(!n.values||n.values.length===0)return;let r=Te();if(!r){this.ctx.ui.notify("Set the reviewer model first \u2014 it's required before solver-gap-finder settings.","warning");return}let a=r.solverGap??Ka,i=r.analyzeGap??za,m=n.values.indexOf(n.value),u=n.values[(m+1)%n.values.length];if(u===void 0)return;n.id==="reviewer-thinking"?De({...r,thinkingLevel:u,solverGap:a,analyzeGap:i}):n.id==="solvergap-thinking"?De({...r,solverGap:{...a,thinkingLevel:u}}):n.id==="solvergap-timeout"?De({...r,solverGap:{...a,timeoutMinutes:Number.parseInt(u,10)}}):n.id==="solvergap-solver-count"?De({...r,solverGap:{...a,solverCount:Number.parseInt(u,10)}}):n.id==="solvergap-save-artifacts"?De({...r,solverGap:{...a,saveArtifacts:u==="on"}}):n.id==="analyze-enabled"?gr(this.ctx.cwd,u==="on"):n.id==="analyze-thinking"&&De({...r,analyzeGap:{...i,thinkingLevel:u}}),this.refresh(),this.onCycleSaved()}}};async function nT(e,t){if(t.mode!=="tui"){t.ui.notify("/checks --config requires interactive mode","error");return}let n=0;for(;;){let r=await t.ui.custom((u,l,f,h)=>{let v=new bi(t,Jv(),l,()=>{Uf(e,t.cwd),u.requestRender()},A=>h(A),()=>h(void 0));v.selectedIndex=n;let E=new Xv;return E.addChild(new Wf(l.bold(l.fg("accent","Checks settings")))),E.addChild({render:A=>v.render(A),invalidate:()=>v.invalidate()}),E.addChild(new Zv(1)),E.addChild(new Wf(l.fg("dim","\u2191\u2193 navigate enter select ctrl+s save & exit esc cancel"))),{render(A){return E.render(A)},invalidate(){E.invalidate()},handleInput(A){v.handleInput(A),n=v.selectedIndex,u.requestRender()}}});if(!r)return;let a=Te(),i=a?.solverGap??Ka,m=a?.analyzeGap??za;if(r==="reviewer-model"){let u=await xi(t,a,"Select reviewer model");if(!u)continue;let l=vn(t,u.provider,u.modelId),f=l.includes(a?.thinkingLevel??"off")?a?.thinkingLevel??"off":l[0]??"off";De({...u,thinkingLevel:f,solverGap:i,analyzeGap:m,enabledProjects:a?.enabledProjects??Qa(),enableAnalyzeTool:a?.enableAnalyzeTool}),t.ui.notify(`Reviewer model saved: ${u.provider}/${u.modelId}`,"info");continue}if(r==="solvergap-model"){if(!a){t.ui.notify("Set the reviewer model first \u2014 it's required before solver-gap-finder settings.","warning");continue}let u=await xi(t,i.provider?i:null,"Select solver model");if(!u)continue;let l=vn(t,u.provider,u.modelId),f=l.includes(i.thinkingLevel)?i.thinkingLevel:l[0]??"off";De({...a,solverGap:{...i,...u,thinkingLevel:f}}),t.ui.notify(`Solver model saved: ${u.provider}/${u.modelId}`,"info");continue}if(r==="analyze-model"){if(!a){t.ui.notify("Set the reviewer model first \u2014 it's required before analyze-tool settings.","warning");continue}let u=await xi(t,m.provider?m:null,"Select analyze tool model");if(!u)continue;let l=vn(t,u.provider,u.modelId),f=l.includes(m.thinkingLevel)?m.thinkingLevel:l[0]??"off";De({...a,analyzeGap:{...m,...u,thinkingLevel:f}}),t.ui.notify(`Analyze tool model saved: ${u.provider}/${u.modelId}`,"info")}}}function Yf(e){e.registerCommand("checks",{description:"Find behavioral gaps in test coverage. Requires an option \u2014 see /checks.",getArgumentCompletions:tT,handler:async(t,n)=>{let r=t.trim();if(!r){n.ui.notify(Ii.map(_=>`${_.value} \u2014 ${_.description}`).join(`
331
- `),"info");return}let a=[...new Set(r.split(/\s+/).filter(Boolean))],i=new Set(Ii.map(_=>_.value)),m=a.filter(_=>!i.has(_));if(m.length){n.ui.notify(`Unknown option(s): ${m.join(", ")}. Run /checks with no arguments to see options.`,"warning");return}if(a.includes("--config")){a.length>1?n.ui.notify("--config cannot be combined with other options.","warning"):await nT(e,n);return}let u=a.includes("--gap-finder"),l=a.includes("--solver-gap-finder");if(!u&&!l)return;if(Ga()){n.ui.notify("A checks run is already in progress.","warning");return}let f=Te();if(!f){n.ui.notify("No gap-finder model configured. Run /checks --config first.","error");return}let h=n.modelRegistry.find(f.provider,f.modelId);if(!h||!n.modelRegistry.hasConfiguredAuth(h)){n.ui.notify("Configured behavioral gap-finder model is unavailable or unauthenticated. Run /checks --config.","error");return}let v=li.filter(_=>!zf(rt(n.cwd,_)));if(v.length){n.ui.notify(`Missing required file(s): ${v.join(", ")}`,"error");return}let E=null,A;if(l){if(E=ji(),!E||!zf(rt(n.cwd,"test.sh"))){n.ui.notify("Configure solver gap finder and provide test.sh before running it.","error");return}if(A=n.modelRegistry.find(E.provider,E.modelId),!A||!n.modelRegistry.hasConfiguredAuth(A)){n.ui.notify("Configured solver gap-finder model is unavailable or unauthenticated.","error");return}}let F=Mf(),Y=E?.solverCount??0,ae=(u?2:0)+(l?Y+1:0);n.ui.setWidget(St,ur("preparing clean snapshot",0,ae)),n.ui.notify(`gap finders (${a.join(" ")}) started. Press ${Qv} to cancel.`,"info");let me,at=[];try{let _=rt(Vf(),`checks-${Kf()}`);Bf(_,{recursive:!0}),me=_;let ot=await Ir(e,n.cwd,_,F.signal);if(ot.status==="error"){n.ui.notify(`checks: ${ot.error}`,"error");return}if(F.signal.aborted)return;for(let je of li)Wv(rt(n.cwd,je),rt(_,je));let it=ja(),Ue=Fa(),pe=0,Ke={status:"ok",gaps:[]},Vt={status:"ok",gaps:[]};if(u){let je={tempDir:_,model:h,thinkingLevel:f.thinkingLevel,testRubric:it,fairnessRules:Ue,cancelSignal:F.signal};if(n.ui.setWidget(St,ur("finding sentence-by-sentence test gaps",pe,ae)),Ke=await La(je),pe+=1,n.ui.setWidget(St,ur("reviewing test gaps",pe,ae)),Ke.gaps.reduce((Ba,Va)=>Ba+Va.gaps.length,0)>0&&(Vt=await qa({...je,statementReports:Ke.gaps})),pe+=1,F.signal.aborted){n.ui.notify("checks: cancelled.","warning");return}}let dt=[],lr={status:"ok",gaps:[]};if(l&&E){if(F.signal.aborted){n.ui.notify("checks: cancelled.","warning");return}let je=[],Tn=ze=>{je.push(ze),pe+=1,n.ui.setWidget(St,ur("solver gap finder: solving",pe,ae,{passed:je.filter(Fe=>Fe.passed).length,failed:je.filter(Fe=>!Fe.passed).length}))},Ba=await Promise.all(Array.from({length:Y},async(ze,Fe)=>{let Wt=rt(Vf(),`checks-solvergap-${Kf()}`);return Bf(Wt,{recursive:!0}),at.push(Wt),{index:Fe+1,setup:await Ki({pi:e,repoDir:n.cwd,solverDir:Wt,testPatchPath:rt(n.cwd,"test.patch"),agentPromptPath:rt(n.cwd,"agent_prompt.md"),cancelSignal:F.signal})}})),Va=di().replace(/[:.]/g,"-");if(dt=await Promise.all(Ba.map(async({index:ze,setup:Fe})=>{if(Fe.status!=="ok"){let $n={index:ze,status:Fe.status,passed:!1,diff:"",testOutputTail:Fe.error,durationMs:0,totalTests:null,failedTests:null};return Tn($n),$n}let Wt=Date.now(),{outcome:Wa,trajectory:Zf}=await Ef({pi:e,solverDir:Fe.solverDir,model:A,thinkingLevel:E.thinkingLevel,timeoutMinutes:E.timeoutMinutes,cancelSignal:F.signal});if(F.signal.aborted||Wa==="cancelled"){let $n=eT(ze,Date.now()-Wt);return Tn($n),$n}let{testOutputXmlPath:Qf,...Ht}=await zi({pi:e,index:ze,workspace:Fe,status:Wa==="done"?"ok":Wa,durationMs:Date.now()-Wt,cancelSignal:F.signal});if(F.signal.aborted||Ht.status==="cancelled")return Tn(Ht),Ht;let eh=E.saveArtifacts?Bi({repoDir:n.cwd,runId:Va,index:ze,trajectory:Zf,solutionPatch:Ht.diff,testOutputXmlPath:Qf,testOutputTail:Ht.testOutputTail}):void 0,wi={...Ht,artifactsDir:eh};return Tn(wi),wi})),F.signal.aborted){n.ui.notify("checks: cancelled.","warning");return}if(dt.some(ze=>ze.status!=="patchFailed"&&ze.status!=="error")&&(Vi(_,dt),lr=await Sf({tempDir:_,model:h,thinkingLevel:f.thinkingLevel,solverResults:dt,testRubric:it,fairnessRules:Ue,cancelSignal:F.signal})),pe+=1,F.signal.aborted){n.ui.notify("checks: cancelled.","warning");return}}let Xf=u&&(Ke.status!=="ok"||Ke.gaps.length>0&&Vt.status!=="ok"),Ti=Of({existingReport:Rf(rt(n.cwd,"shipd_report.json")),config:f,runGapFinder:u,testGaps:Vt.gaps,gapAnalysisIncomplete:Xf,gapFinderStatus:Ke.status,gapFilterStatus:Vt.status,runSolverGapFinder:l,solverResults:dt,solverGaps:lr.gaps,solverGapAnalysisIncomplete:l&&(dt.some(je=>je.status==="error")||lr.status!=="ok"),solverComparisonStatus:lr.status}),$i=Af({merged:Ti,runGapFinder:u,runSolverGapFinder:l});e.sendMessage({customType:"shipd_checks_report",content:$i.content,display:!0,details:$i.details});let ki=rt(n.cwd,"shipd_report.json");Yv(ki,JSON.stringify(Ti,null,2),"utf-8"),n.ui.notify(`checks: wrote details to ${ki}`,"info")}catch(_){n.ui.notify(`checks failed: ${_ instanceof Error?_.message:String(_)}`,"error")}finally{n.ui.setWidget(St,void 0),me&&Hv(me,{recursive:!0,force:!0});for(let _ of at)Wi(_);Lf()}}})}var Jf=aT.ctrlShift("x");function iT(e){e.registerCommand("analyze:on",{description:"Enable the Gap Finder tool for this project folder",handler:async(t,n)=>{yi(e,n.cwd,!0),n.ui.notify("Gap Finder tool ON in this project","info")}}),e.registerCommand("analyze:off",{description:"Disable the Gap Finder tool for this project folder",handler:async(t,n)=>{yi(e,n.cwd,!1),n.ui.notify("Gap Finder tool OFF in this project","info")}}),e.registerMessageRenderer("shipd_checks_report",(t,n,r)=>{let a=t.details??{},i=new rT;i.addChild(new vi(r.bold(r.fg("accent","Checks")),0,0));let m=!1,u=l=>{i.addChild(new vi(l,0,0)),m=!0};if(a.showGaps){let l=a.gapsCount??0;u(l>0?r.fg("warning",` \u26A0 ${l} test gap(s) found`):r.fg("success"," \u2713 no test gaps found"))}if(a.showSolverGaps){let l=a.solverDetails??[],f=l.filter(A=>A.passed).length,h=a.solverGapsCount??0;i.addChild(new oT(1)),u(r.bold(r.fg("accent","Solver gap finder")));for(let A of l){let F=A.passed?r.fg("success","\u2713"):r.fg("error","\u2717"),Y=A.passed?"passed":A.status==="ok"?"failed tests":A.status;u(` ${F} Solver ${A.index}: ${Y} (${Pf(A.durationMs)})`)}let v=f===l.length&&l.length>0?r.fg("success",`${f}/${l.length} solvers passed`):r.fg("warning",`${f}/${l.length} solvers passed`),E=h>0?r.fg("warning",`${h} behavioral gap(s) found`):r.fg("success","no behavioral gaps found");u(` ${v}, ${E}`)}return m||i.addChild(new vi(r.fg("dim"," nothing to report"),0,0)),i}),e.registerShortcut(Jf,{description:"Cancel an in-progress /checks run",handler:t=>{Ga()&&qf()&&(t.ui.setWidget(St,[`checks: cancelling (${Jf})...`]),t.ui.notify("checks: cancelling...","warning"))}}),sT(e),Yf(e)}function sT(e){e.on("session_start",(t,n)=>{gi(e,n.cwd),(t.reason==="resume"||t.reason==="reload"||t.reason==="startup")&&Nf(e)}),e.on("session_tree",async(t,n)=>{gi(e,n.cwd)}),e.on("before_agent_start",()=>{!_f()&&!Ua(e)||bn(e)})}export{iT as default};
330
+ `)}var _a=!1,Ff=!1,Kt=!1;function fi(e){return e.getActiveTools().map(n=>typeof n=="string"?n:n.name)}function hi(){return _a}function zv(e){return fi(e).includes(cr)}function Ua(e){return hi()!==zv(e)}function Bv(e){Ff||(jf(e),Ff=!0)}function Vv(e,t){let n=fi(e);if(t){if(n.length===0){Kt=!0;return}let r=new Set(n);r.add(cr),r.size!==n.length&&e.setActiveTools([...r])}else{let r=n.filter(a=>a!==cr);r.length!==n.length&&e.setActiveTools(r)}Kt=Ua(e)}function In(e){let t=hi();t&&Bv(e),Vv(e,t)}function gi(e,t){_a=hr(t),Kt=!0,Df(e)}function Df(e,t=0){let n=hi(),r=fi(e);if(n&&r.length===0&&t<8){queueMicrotask(()=>Df(e,t+1));return}In(e)}function Gf(e){for(let t of[0,50,150,400])setTimeout(()=>{(Kt||Ua(e))&&In(e)},t)}function Nf(){return Kt}function yi(e,t,n){_a=n,gr(t,n),Kt=!0,In(e)}function _f(e,t){_a=hr(t),Kt=!0,In(e)}var Qv="Ctrl+Shift+X";function eT(e,t){return{index:e,status:"cancelled",passed:!1,diff:"",testOutputTail:"cancelled",durationMs:t,totalTests:null,failedTests:null}}var Hf=[{value:"--config",label:"--config",description:"Configure gap-finder models"},{value:"--solver-gap-finder",label:"--solver-gap-finder",description:"Use TDD solver attempts to find behavioral gaps"},{value:"--gap-finder",label:"--gap-finder",description:"Find and validate behavioral test-coverage gaps"}],tT=["config","solver-gap-finder","gap-finder"];function nT(e){let t=e.trimStart(),n=/\s$/.test(t),r=t.trimEnd().split(/\s+/).filter(Boolean),a=n?"":r.at(-1)??"",i=new Set(n?r:r.slice(0,-1)),m=n?t:t.slice(0,t.length-a.length),u=i.has("--config"),l=[...i].some(h=>h!=="--config"),f=Hf.filter(h=>!i.has(h.value)&&!u&&!(l&&h.value==="--config")&&h.value.startsWith(a));return f.length?f.map(h=>({...h,value:`${m}${h.value}`})):null}async function xi(e,t,n){let r=Fi();if(r.length===0)return e.ui.notify("No enabledModels configured in settings.json.","error"),null;let a=e.modelRegistry.getAll(),i=r.map(f=>{let h=Di(f);if(!h)return null;let v=a.find(F=>F.provider===h.provider&&F.id===h.modelId),E=t?.provider===h.provider&&t?.modelId===h.modelId,A=v?`${v.name} (${f})`:f;return{ref:f,parsed:h,display:E?`${A} [current]`:A,isCurrent:E}}).filter(f=>f!==null);if(i.length===0)return e.ui.notify("Could not resolve any enabledModels entries.","error"),null;let m=[...i].sort((f,h)=>f.isCurrent===h.isCurrent?0:f.isCurrent?-1:1),u=await e.ui.select(n,m.map(f=>f.display));if(!u)return null;let l=i.find(f=>f.display===u);return l?{provider:l.parsed.provider,modelId:l.parsed.modelId}:null}function vn(e,t,n){let r=e.modelRegistry.getAll().find(a=>a.provider===t&&a.id===n);return qi(r)}var Ka={provider:"",modelId:"",thinkingLevel:"off",timeoutMinutes:Ha,solverCount:Ja,saveArtifacts:Xa},za={provider:"",modelId:"",thinkingLevel:"off"};function Wf(e,t,n,r){let a=t?vn(e,t.provider,t.modelId):["off"],i=n.provider?vn(e,n.provider,n.modelId):["off"],m=r.provider?vn(e,r.provider,r.modelId):["off"];return[{id:"reviewer-model",section:"Reviewer",label:"Model",value:t?`${t.provider}/${t.modelId}`:"not set",kind:"model"},{id:"reviewer-thinking",section:"Reviewer",label:"Thinking level",value:t?.thinkingLevel??"off",kind:"cycle",values:a},{id:"solvergap-model",section:"Solver",label:"Model",value:n.provider?`${n.provider}/${n.modelId}`:"not set",kind:"model"},{id:"solvergap-thinking",section:"Solver",label:"Thinking level",value:n.thinkingLevel,kind:"cycle",values:i},{id:"solvergap-timeout",section:"Solver",label:"Timeout",value:`${n.timeoutMinutes} min`,kind:"cycle",values:[10,20,30,40,50,Ai].filter((u,l,f)=>u>=Pi&&f.indexOf(u)===l).map(u=>`${u} min`)},{id:"solvergap-solver-count",section:"Solver",label:"Parallel agents",value:String(n.solverCount),kind:"cycle",values:Array.from({length:Ci-Ya+1},(u,l)=>`${Ya+l}`)},{id:"solvergap-save-artifacts",section:"Solver",label:"Save artifacts",value:n.saveArtifacts?"on":"off",kind:"cycle",values:["on","off"]},{id:"analyze-enabled",section:"Analyze Tool",label:"Enabled here",value:yr(e.cwd)?"on":"off",kind:"cycle",values:["on","off"]},{id:"analyze-model",section:"Analyze Tool",label:"Model",value:r.provider?`${r.provider}/${r.modelId}`:"not set",kind:"model"},{id:"analyze-thinking",section:"Analyze Tool",label:"Thinking level",value:r.thinkingLevel,kind:"cycle",values:m}]}var bi=class{constructor(t,n,r,a,i,m){this.ctx=t;this.settingsListTheme=n;this.theme=r;this.onCycleSaved=a;this.onActivateModel=i;this.onExit=m;this.rows=Wf(t,Te(),Te()?.solverGap??Ka,Te()?.analyzeGap??za)}selectedIndex=0;rows;refresh(){let t=Te();this.rows=Wf(this.ctx,t,t?.solverGap??Ka,t?.analyzeGap??za),this.selectedIndex=Math.min(this.selectedIndex,this.rows.length-1)}invalidate(){}render(t){let n=[],r=Math.min(30,Math.max(...this.rows.map(i=>i.label.length))),a;for(let i=0;i<this.rows.length;i++){let m=this.rows[i];if(!m)continue;m.section!==a&&(a!==void 0&&n.push(""),n.push(this.theme.bold(this.theme.fg("accent",m.section))),a=m.section);let u=i===this.selectedIndex,l=u?this.settingsListTheme.cursor:" ",f=m.label+" ".repeat(Math.max(0,r-m.label.length)),h=this.settingsListTheme.label(f,u),v=this.settingsListTheme.value(m.value,u);n.push(`${l}${h} ${v}`)}return n}handleInput(t){if(Bt(t,zt.ctrl("s"))||Bt(t,zt.escape)||Bt(t,zt.ctrl("c"))){this.onExit();return}if(Bt(t,zt.up)){this.selectedIndex=this.selectedIndex===0?this.rows.length-1:this.selectedIndex-1;return}if(Bt(t,zt.down)){this.selectedIndex=this.selectedIndex===this.rows.length-1?0:this.selectedIndex+1;return}if(Bt(t,zt.enter)||Bt(t,zt.return)||t===" "){let n=this.rows[this.selectedIndex];if(!n)return;if(n.kind==="model"){this.onActivateModel(n.id);return}if(!n.values||n.values.length===0)return;let r=Te();if(!r){this.ctx.ui.notify("Set the reviewer model first \u2014 it's required before solver-gap-finder settings.","warning");return}let a=r.solverGap??Ka,i=r.analyzeGap??za,m=n.values.indexOf(n.value),u=n.values[(m+1)%n.values.length];if(u===void 0)return;n.id==="reviewer-thinking"?De({...r,thinkingLevel:u,solverGap:a,analyzeGap:i}):n.id==="solvergap-thinking"?De({...r,solverGap:{...a,thinkingLevel:u}}):n.id==="solvergap-timeout"?De({...r,solverGap:{...a,timeoutMinutes:Number.parseInt(u,10)}}):n.id==="solvergap-solver-count"?De({...r,solverGap:{...a,solverCount:Number.parseInt(u,10)}}):n.id==="solvergap-save-artifacts"?De({...r,solverGap:{...a,saveArtifacts:u==="on"}}):n.id==="analyze-enabled"?gr(this.ctx.cwd,u==="on"):n.id==="analyze-thinking"&&De({...r,analyzeGap:{...i,thinkingLevel:u}}),this.refresh(),this.onCycleSaved()}}};async function rT(e,t){if(t.mode!=="tui"){t.ui.notify("/checks --config requires interactive mode","error");return}let n=0;for(;;){let r=await t.ui.custom((u,l,f,h)=>{let v=new bi(t,Jv(),l,()=>{_f(e,t.cwd),u.requestRender()},A=>h(A),()=>h(void 0));v.selectedIndex=n;let E=new Xv;return E.addChild(new Vf(l.bold(l.fg("accent","Checks settings")))),E.addChild({render:A=>v.render(A),invalidate:()=>v.invalidate()}),E.addChild(new Zv(1)),E.addChild(new Vf(l.fg("dim","\u2191\u2193 navigate enter select ctrl+s save & exit esc cancel"))),{render(A){return E.render(A)},invalidate(){E.invalidate()},handleInput(A){v.handleInput(A),n=v.selectedIndex,u.requestRender()}}});if(!r)return;let a=Te(),i=a?.solverGap??Ka,m=a?.analyzeGap??za;if(r==="reviewer-model"){let u=await xi(t,a,"Select reviewer model");if(!u)continue;let l=vn(t,u.provider,u.modelId),f=l.includes(a?.thinkingLevel??"off")?a?.thinkingLevel??"off":l[0]??"off";De({...u,thinkingLevel:f,solverGap:i,analyzeGap:m,enabledProjects:a?.enabledProjects??Qa(),enableAnalyzeTool:a?.enableAnalyzeTool}),t.ui.notify(`Reviewer model saved: ${u.provider}/${u.modelId}`,"info");continue}if(r==="solvergap-model"){if(!a){t.ui.notify("Set the reviewer model first \u2014 it's required before solver-gap-finder settings.","warning");continue}let u=await xi(t,i.provider?i:null,"Select solver model");if(!u)continue;let l=vn(t,u.provider,u.modelId),f=l.includes(i.thinkingLevel)?i.thinkingLevel:l[0]??"off";De({...a,solverGap:{...i,...u,thinkingLevel:f}}),t.ui.notify(`Solver model saved: ${u.provider}/${u.modelId}`,"info");continue}if(r==="analyze-model"){if(!a){t.ui.notify("Set the reviewer model first \u2014 it's required before analyze-tool settings.","warning");continue}let u=await xi(t,m.provider?m:null,"Select analyze tool model");if(!u)continue;let l=vn(t,u.provider,u.modelId),f=l.includes(m.thinkingLevel)?m.thinkingLevel:l[0]??"off";De({...a,analyzeGap:{...m,...u,thinkingLevel:f}}),t.ui.notify(`Analyze tool model saved: ${u.provider}/${u.modelId}`,"info")}}}function Yf(e){e.registerCommand("checks",{description:"Find behavioral gaps in test coverage. Choose an option from the menu.",getArgumentCompletions:nT,handler:async(t,n)=>{let r=t.trim();if(!r){let _=await n.ui.select("Choose a checks action",[...tT]);if(!_)return;r=`--${_}`}let a=[...new Set(r.split(/\s+/).filter(Boolean))],i=new Set(Hf.map(_=>_.value)),m=a.filter(_=>!i.has(_));if(m.length){n.ui.notify(`Unknown option(s): ${m.join(", ")}. Run /checks with no arguments to see options.`,"warning");return}if(a.includes("--config")){a.length>1?n.ui.notify("--config cannot be combined with other options.","warning"):await rT(e,n);return}let u=a.includes("--gap-finder"),l=a.includes("--solver-gap-finder");if(!u&&!l)return;if(Ga()){n.ui.notify("A checks run is already in progress.","warning");return}let f=Te();if(!f){n.ui.notify("No gap-finder model configured. Run /checks --config first.","error");return}let h=n.modelRegistry.find(f.provider,f.modelId);if(!h||!n.modelRegistry.hasConfiguredAuth(h)){n.ui.notify("Configured behavioral gap-finder model is unavailable or unauthenticated. Run /checks --config.","error");return}let v=li.filter(_=>!Kf(rt(n.cwd,_)));if(v.length){n.ui.notify(`Missing required file(s): ${v.join(", ")}`,"error");return}let E=null,A;if(l){if(E=Li(),!E||!Kf(rt(n.cwd,"test.sh"))){n.ui.notify("Configure solver gap finder and provide test.sh before running it.","error");return}if(A=n.modelRegistry.find(E.provider,E.modelId),!A||!n.modelRegistry.hasConfiguredAuth(A)){n.ui.notify("Configured solver gap-finder model is unavailable or unauthenticated.","error");return}}let F=Cf(),Y=E?.solverCount??0,ae=(u?2:0)+(l?Y+1:0);n.ui.setWidget(St,ur("preparing clean snapshot",0,ae)),n.ui.notify(`gap finders (${a.join(" ")}) started. Press ${Qv} to cancel.`,"info");let me,at=[];try{let _=rt(Bf(),`checks-${Uf()}`);zf(_,{recursive:!0}),me=_;let ot=await br(e,n.cwd,_,F.signal);if(ot.status==="error"){n.ui.notify(`checks: ${ot.error}`,"error");return}if(F.signal.aborted)return;for(let je of li)Wv(rt(n.cwd,je),rt(_,je));let it=ja(),Ue=Fa(),pe=0,Ke={status:"ok",gaps:[]},Vt={status:"ok",gaps:[]};if(u){let je={tempDir:_,model:h,thinkingLevel:f.thinkingLevel,testRubric:it,fairnessRules:Ue,cancelSignal:F.signal};if(n.ui.setWidget(St,ur("finding sentence-by-sentence test gaps",pe,ae)),Ke=await qa(je),pe+=1,n.ui.setWidget(St,ur("reviewing test gaps",pe,ae)),Ke.gaps.reduce((Ba,Va)=>Ba+Va.gaps.length,0)>0&&(Vt=await La({...je,statementReports:Ke.gaps})),pe+=1,F.signal.aborted){n.ui.notify("checks: cancelled.","warning");return}}let dt=[],lr={status:"ok",gaps:[]};if(l&&E){if(F.signal.aborted){n.ui.notify("checks: cancelled.","warning");return}let je=[],Tn=ze=>{je.push(ze),pe+=1,n.ui.setWidget(St,ur("solver gap finder: solving",pe,ae,{passed:je.filter(Fe=>Fe.passed).length,failed:je.filter(Fe=>!Fe.passed).length}))},Ba=await Promise.all(Array.from({length:Y},async(ze,Fe)=>{let Wt=rt(Bf(),`checks-solvergap-${Uf()}`);return zf(Wt,{recursive:!0}),at.push(Wt),{index:Fe+1,setup:await Ui({pi:e,repoDir:n.cwd,solverDir:Wt,testPatchPath:rt(n.cwd,"test.patch"),agentPromptPath:rt(n.cwd,"agent_prompt.md"),cancelSignal:F.signal})}})),Va=di().replace(/[:.]/g,"-");if(dt=await Promise.all(Ba.map(async({index:ze,setup:Fe})=>{if(Fe.status!=="ok"){let $n={index:ze,status:Fe.status,passed:!1,diff:"",testOutputTail:Fe.error,durationMs:0,totalTests:null,failedTests:null};return Tn($n),$n}let Wt=Date.now(),{outcome:Wa,trajectory:Zf}=await wf({pi:e,solverDir:Fe.solverDir,model:A,thinkingLevel:E.thinkingLevel,timeoutMinutes:E.timeoutMinutes,cancelSignal:F.signal});if(F.signal.aborted||Wa==="cancelled"){let $n=eT(ze,Date.now()-Wt);return Tn($n),$n}let{testOutputXmlPath:Qf,...Ht}=await Ki({pi:e,index:ze,workspace:Fe,status:Wa==="done"?"ok":Wa,durationMs:Date.now()-Wt,cancelSignal:F.signal});if(F.signal.aborted||Ht.status==="cancelled")return Tn(Ht),Ht;let eh=E.saveArtifacts?zi({repoDir:n.cwd,runId:Va,index:ze,trajectory:Zf,solutionPatch:Ht.diff,testOutputXmlPath:Qf,testOutputTail:Ht.testOutputTail}):void 0,ki={...Ht,artifactsDir:eh};return Tn(ki),ki})),F.signal.aborted){n.ui.notify("checks: cancelled.","warning");return}if(dt.some(ze=>ze.status!=="patchFailed"&&ze.status!=="error")&&(Bi(_,dt),lr=await Ef({tempDir:_,model:h,thinkingLevel:f.thinkingLevel,solverResults:dt,testRubric:it,fairnessRules:Ue,cancelSignal:F.signal})),pe+=1,F.signal.aborted){n.ui.notify("checks: cancelled.","warning");return}}let Xf=u&&(Ke.status!=="ok"||Ke.gaps.length>0&&Vt.status!=="ok"),vi=Rf({existingReport:Sf(rt(n.cwd,"shipd_report.json")),config:f,runGapFinder:u,testGaps:Vt.gaps,gapAnalysisIncomplete:Xf,gapFinderStatus:Ke.status,gapFilterStatus:Vt.status,runSolverGapFinder:l,solverResults:dt,solverGaps:lr.gaps,solverGapAnalysisIncomplete:l&&(dt.some(je=>je.status==="error")||lr.status!=="ok"),solverComparisonStatus:lr.status}),Ti=Pf({merged:vi,runGapFinder:u,runSolverGapFinder:l});e.sendMessage({customType:"shipd_checks_report",content:Ti.content,display:!0,details:Ti.details});let $i=rt(n.cwd,"shipd_report.json");Yv($i,JSON.stringify(vi,null,2),"utf-8"),n.ui.notify(`checks: wrote details to ${$i}`,"info")}catch(_){n.ui.notify(`checks failed: ${_ instanceof Error?_.message:String(_)}`,"error")}finally{n.ui.setWidget(St,void 0),me&&Hv(me,{recursive:!0,force:!0});for(let _ of at)Vi(_);Mf()}}})}var Jf=oT.ctrlShift("x");function sT(e){e.registerCommand("analyze:on",{description:"Enable the Gap Finder tool for this project folder",handler:async(t,n)=>{yi(e,n.cwd,!0),n.ui.notify("Gap Finder tool ON in this project","info")}}),e.registerCommand("analyze:off",{description:"Disable the Gap Finder tool for this project folder",handler:async(t,n)=>{yi(e,n.cwd,!1),n.ui.notify("Gap Finder tool OFF in this project","info")}}),e.registerMessageRenderer("shipd_checks_report",(t,n,r)=>{let a=t.details??{},i=new aT;i.addChild(new Ii(r.bold(r.fg("accent","Checks")),0,0));let m=!1,u=l=>{i.addChild(new Ii(l,0,0)),m=!0};if(a.showGaps){let l=a.gapsCount??0;u(l>0?r.fg("warning",` \u26A0 ${l} test gap(s) found`):r.fg("success"," \u2713 no test gaps found"))}if(a.showSolverGaps){let l=a.solverDetails??[],f=l.filter(A=>A.passed).length,h=a.solverGapsCount??0;i.addChild(new iT(1)),u(r.bold(r.fg("accent","Solver gap finder")));for(let A of l){let F=A.passed?r.fg("success","\u2713"):r.fg("error","\u2717"),Y=A.passed?"passed":A.status==="ok"?"failed tests":A.status;u(` ${F} Solver ${A.index}: ${Y} (${Of(A.durationMs)})`)}let v=f===l.length&&l.length>0?r.fg("success",`${f}/${l.length} solvers passed`):r.fg("warning",`${f}/${l.length} solvers passed`),E=h>0?r.fg("warning",`${h} behavioral gap(s) found`):r.fg("success","no behavioral gaps found");u(` ${v}, ${E}`)}return m||i.addChild(new Ii(r.fg("dim"," nothing to report"),0,0)),i}),e.registerShortcut(Jf,{description:"Cancel an in-progress /checks run",handler:t=>{Ga()&&qf()&&(t.ui.setWidget(St,[`checks: cancelling (${Jf})...`]),t.ui.notify("checks: cancelling...","warning"))}}),mT(e),Yf(e)}function mT(e){e.on("session_start",(t,n)=>{gi(e,n.cwd),(t.reason==="resume"||t.reason==="reload"||t.reason==="startup")&&Gf(e)}),e.on("session_tree",async(t,n)=>{gi(e,n.cwd)}),e.on("before_agent_start",()=>{!Nf()&&!Ua(e)||In(e)})}export{sT as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sreetej510/pi-shipd-checks",
3
- "version": "0.2.0",
3
+ "version": "0.2.3",
4
4
  "description": "Pi extension that runs a strict, multi-agent fairness review of a benchmark task's agent_prompt.md, test.patch, and solution.patch, plus behavioral test-gap analysis, via /checks.",
5
5
  "type": "module",
6
6
  "license": "MIT",