@sreetej510/pi-shipd-checks 0.1.27 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +16 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Xf=Object.defineProperty;var St=(e,t)=>{for(var n in t)Xf(e,n,{get:t[n],enumerable:!0})};import{Container as e$,Key as t$,Spacer as n$,Text as xi}from"@earendil-works/pi-tui";import{randomUUID as Nf}from"node:crypto";import{copyFileSync as Bv,existsSync as _f,mkdirSync as Uf,rmSync as Vv,writeFileSync as Wv}from"node:fs";import{tmpdir as Kf}from"node:os";import{join as et}from"node:path";import{getSettingsListTheme as Hv}from"@earendil-works/pi-coding-agent";import{Container as Yv,Key as zt,matchesKey as Bt,Spacer as Jv,Text as zf}from"@earendil-works/pi-tui";import{createAgentSession as Sa,SessionManager as Oa}from"@earendil-works/pi-coding-agent";import{copyFileSync as th,existsSync as Qa,lstatSync as nh,mkdirSync as eo,readFileSync as Ir,rmSync as Gi,symlinkSync as rh,unlinkSync as ah,writeFileSync as ot}from"node:fs";import{join as fe}from"node:path";import{existsSync as Wt,mkdirSync as wi,readFileSync as cr,writeFileSync as Ei}from"node:fs";import{dirname as Ri,join as Si}from"node:path";import{getAgentDir as Oi}from"@earendil-works/pi-coding-agent";var ft=Si(Oi(),"checks-config.json"),ur=Si(Oi(),"settings.json"),Pi=10,Ai=60,Wa=20,Ha=1,Ci=5,Ya=3,Ja=!0,Mi=!1,Qf=["off","minimal","low","medium","high","xhigh","max"];function Li(e){return e?.reasoning?Qf.filter(t=>{let n=e.thinkingLevelMap?.[t];return n===null?!1:t==="xhigh"||t==="max"?n!==void 0:!0}):["off"]}function ve(){try{if(!Wt(ft))return null;let e=JSON.parse(cr(ft,"utf-8"));if(e.provider&&e.modelId&&e.thinkingLevel)return e}catch{}return null}function Fe(e){let t=Ri(ft);Wt(t)||wi(t,{recursive:!0}),Ei(ft,JSON.stringify(e,null,2),"utf-8")}function qi(){let e=ve()?.solverGap;return!e?.provider||!e.modelId||!e.thinkingLevel?null:{...e,timeoutMinutes:e.timeoutMinutes>0?e.timeoutMinutes:Wa,solverCount:e.solverCount>0?e.solverCount:Ya,saveArtifacts:typeof e.saveArtifacts=="boolean"?e.saveArtifacts:Ja}}function Za(){try{if(!Wt(ft))return{};let e=JSON.parse(cr(ft,"utf-8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Xa(){let e=Za().enabledProjects;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function lr(e){let t=Za();return Array.isArray(t.enabledProjects)?t.enabledProjects.some(n=>n===e):ve()?.enableAnalyzeTool??Mi}function dr(e,t){let n=new Set(Xa());t?n.add(e):n.delete(e);let r=[...n],a=ve();if(a){Fe({...a,enabledProjects:r});return}let i=Ri(ft);Wt(i)||wi(i,{recursive:!0}),Ei(ft,JSON.stringify({...Za(),enabledProjects:r},null,2),"utf-8")}function fr(e){return e!==void 0?lr(e):ve()?.enableAnalyzeTool??Mi}function ji(){let e=ve()?.analyzeGap;return!e?.provider||!e.modelId||!e.thinkingLevel?null:{...e}}function Fi(){try{return Wt(ur)?JSON.parse(cr(ur,"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 eh(){try{if(Wt(ur))return JSON.parse(cr(ur,"utf-8"))}catch{}return{}}function hr(){let e=eh().shellPath;return e||(process.platform==="win32"?"C:\\Program Files\\Git\\bin\\bash.exe":"bash")}function gr(e){return e.replace(/\\/g,"/")}function yr(e){return`'${e.replace(/'/g,"'\\''")}'`}async function xr(e,t,n){if((await e.exec("git",["rev-parse","HEAD"],{cwd:t,timeout:15e3})).code!==0)return{status:"error",error:"Not a git repository, or it has no commits yet."};let a=`git archive HEAD | tar -x -C ${yr(gr(n))}`,i=await e.exec(hr(),["-c",a],{cwd:t,timeout:6e4});return i.code!==0?{status:"error",error:i.stderr?.trim()||`git archive failed (exit ${i.code})`}:{status:"ok"}}var to=3e4,oh=4e3,ih=".pi/shipd-checks",vn="solver_gap_solutions";function sh(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 mh(e,t){return e.length>t?e.slice(e.length-t):e}async function Ni(e){let{pi:t,repoDir:n,solverDir:r,testPatchPath:a,agentPromptPath:i}=e,m=await xr(t,n,r);if(m.status==="error")return{status:"error",solverDir:r,error:m.error};let u={cwd:r,timeout:to},l=await t.exec("git",["init"],u);if(l.code!==0)return{status:"error",solverDir:r,error:l.stderr?.trim()||"git init failed"};await t.exec("git",["config","user.email","solvergap@shipd-checks.local"],u),await t.exec("git",["config","user.name","shipd-checks solver-gap-finder"],u);let f=await t.exec("git",["add","-A"],u);if(f.code!==0)return{status:"error",solverDir:r,error:f.stderr?.trim()||"git add (baseline) failed"};let h=await t.exec("git",["commit","-m","baseline","--allow-empty"],u);if(h.code!==0)return{status:"error",solverDir:r,error:h.stderr?.trim()||"git commit (baseline) failed"};let $=fe(r,".gitignore"),E=Qa($)?Ir($,"utf-8"):"";if(!E.split(/\r?\n/).some(ct=>ct.trim()==="node_modules")){let ct=E.length>0&&!E.endsWith(`
|
|
2
2
|
`)?`
|
|
3
3
|
`:"";ot($,`${E}${ct}node_modules
|
|
4
|
-
`,"utf-8")}let A=fe(n,"node_modules"),H=fe(r,"node_modules");if(Qa(A)&&!Qa(H))try{
|
|
5
|
-
${ne.stderr}`.trim(),ah),{totalTests:N,failedTests:nt}=mh(A);return{index:n,status:a,passed:ue,diff:E,testOutputTail:tt,durationMs:i,totalTests:N,failedTests:nt,testOutputXmlPath:A}}function Ui(e){let{repoDir:t,runId:n,index:r,trajectory:a,solutionPatch:i,testOutputXmlPath:m,testOutputTail:u}=e,l=fe(t,oh,n,`solver_${r}`);eo(l,{recursive:!0}),ot(fe(l,"trajectory.json"),JSON.stringify(a,null,2),"utf-8"),ot(fe(l,"solution.patch"),i,"utf-8");try{let f=Ir(m,"utf-8");ot(fe(l,"test_output.xml"),f,"utf-8")}catch{ot(fe(l,"test_output.txt"),u,"utf-8")}return l}function Ki(e,t){let n=fe(e,vn);eo(n,{recursive:!0});let r=t.map(a=>{let i=fe(n,`solver_${a.index}`);return eo(i,{recursive:!0}),ot(fe(i,"solution.diff"),a.diff,"utf-8"),ot(fe(i,"test_output.txt"),a.testOutputTail,"utf-8"),{index:a.index,status:a.status,passed:a.passed}});return ot(fe(n,"manifest.json"),JSON.stringify(r,null,2),"utf-8"),n}function zi(e){let t=fe(e,"node_modules");try{th(t).isSymbolicLink()&&Gi(t,{force:!0})}catch{}try{Gi(e,{recursive:!0,force:!0})}catch{}}var p={};St(p,{Assign:()=>ph,Clone:()=>wn,Create:()=>hg,Discard:()=>gg,Metrics:()=>De,Update:()=>yg});var De={assign:0,create:0,clone:0,discard:0,update:0};function ph(e,t){return De.assign+=1,{...e,...t}}var s={};St(s,{Entries:()=>Ph,EntriesRegExp:()=>Oh,Every:()=>Eh,EveryAll:()=>Rh,GraphemeCount:()=>Th,HasPropertyKey:()=>Sh,IsArray:()=>Tn,IsBigInt:()=>$n,IsBoolean:()=>Qi,IsClassInstance:()=>vh,IsConstructor:()=>hh,IsDeepEqual:()=>oo,IsEqual:()=>M,IsFunction:()=>es,IsGreaterEqualThan:()=>ns,IsGreaterThan:()=>xh,IsInteger:()=>ro,IsLessEqualThan:()=>ts,IsLessThan:()=>Ih,IsMaxLength:()=>kh,IsMinLength:()=>wh,IsMultipleOf:()=>bh,IsNull:()=>$r,IsNumber:()=>Tr,IsObject:()=>kn,IsObjectNotArray:()=>gh,IsString:()=>kr,IsSymbol:()=>yh,IsUndefined:()=>ao,IsUnsafePropertyKey:()=>rs,IsValueLike:()=>$h,Keys:()=>vr,ShiftLeft:()=>wr,Symbols:()=>Ah,Values:()=>Ch});function Ot(e,t,n){return e>=t&&e<=n}function uh(e){return e===8205}function ch(e){return Ot(e,55296,56319)}function Bi(e){return Ot(e,127462,127487)}function Wi(e){return Ot(e,65024,65039)}function Hi(e){return Ot(e,768,879)||Ot(e,6832,6911)||Ot(e,7616,7679)||Ot(e,65056,65071)}function br(e){return e>65535?2:1}function Vi(e,t){for(;t<e.length;){let n=e.codePointAt(t);if(Hi(n)||Wi(n))t+=br(n);else break}return t}function no(e,t){let n=e.codePointAt(t),r=t+br(n);for(r=Vi(e,r);r<e.length-1&&e[r]==="\u200D";){let a=e.codePointAt(r+1);r+=1+br(a),r=Vi(e,r)}return Bi(n)&&r<e.length&&Bi(e.codePointAt(r))&&(r+=br(e.codePointAt(r))),r}function Yi(e){return ch(e)||Hi(e)||Wi(e)||uh(e)}function Ji(e){let t=0,n=0;for(;n<e.length;)n=no(e,n),t++;return t}function lh(e,t){if(t===0)return!0;let n=0,r=0;for(;r<e.length;)if(r=no(e,r),n++,n>=t)return!0;return!1}function dh(e,t){let n=0,r=0;for(;r<e.length;)if(r=no(e,r),n++,n>t)return!1;return!0}function Zi(e,t){if(t===0)return!0;let n=0;for(;n<e.length;){if(Yi(e.charCodeAt(n)))return lh(e,t);if(n++,n>=t)return!0}return!1}function Xi(e,t){let n=0;for(;n<e.length;){if(Yi(e.charCodeAt(n)))return dh(e,t);if(n++,n>t)return!1}return!0}function Tn(e){return Array.isArray(e)}function $n(e){return M(typeof e,"bigint")}function Qi(e){return M(typeof e,"boolean")}function hh(e){if(ao(e)||!es(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function es(e){return M(typeof e,"function")}function ro(e){return Number.isInteger(e)}function $r(e){return M(e,null)}function Tr(e){return Number.isFinite(e)}function gh(e){return kn(e)&&!Tn(e)}function kn(e){return M(typeof e,"object")&&!$r(e)}function kr(e){return M(typeof e,"string")}function yh(e){return M(typeof e,"symbol")}function ao(e){return M(e,void 0)}function M(e,t){return e===t}function xh(e,t){return e>t}function Ih(e,t){return e<t}function ts(e,t){return e<=t}function ns(e,t){return e>=t}function bh(e,t){if($n(e)||$n(t))return BigInt(e)%BigInt(t)===0n;let n=1e-10;if(!Tr(e)||ro(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 vh(e){if(!kn(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 $h(e){return $n(e)||Qi(e)||$r(e)||Tr(e)||kr(e)||ao(e)}function Th(e){return Ji(e)}function kh(e,t){return Xi(e,t)}function wh(e,t){return Zi(e,t)}function Eh(e,t,n){for(let r=t;r<e.length;r++)if(!n(e[r],r))return!1;return!0}function Rh(e,t,n){let r=!0;for(let a=t;a<e.length;a++)n(e[a],a)||(r=!1);return r}function wr(e,t,n){return M(e.length,0)?n():t(e[0],e.slice(1))}function rs(e){return M(e,"__proto__")||M(e,"constructor")||M(e,"prototype")}function Sh(e,t){return rs(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function Oh(e){return vr(e).map(t=>[new RegExp(`^${t}$`),e[t]])}function Ph(e){return Object.entries(e)}function vr(e){return Object.getOwnPropertyNames(e)}function Ah(e){return Object.getOwnPropertySymbols(e)}function Ch(e){return Object.values(e)}function Mh(e,t){if(!kn(t))return!1;let n=vr(e);return M(n.length,vr(t).length)&&n.every(r=>oo(e[r],t[r]))}function Lh(e,t){return Tn(t)&&M(e.length,t.length)&&e.every((n,r)=>oo(e[r],t[r]))}function oo(e,t){return Tn(e)?Lh(e,t):kn(e)?Mh(e,t):M(e,t)}var ht={};St(ht,{IsBigInt64Array:()=>Yh,IsBigUint64Array:()=>Jh,IsBoolean:()=>jh,IsDate:()=>Xh,IsFloat32Array:()=>Wh,IsFloat64Array:()=>Hh,IsInt16Array:()=>Kh,IsInt32Array:()=>Bh,IsInt8Array:()=>Nh,IsMap:()=>eg,IsNumber:()=>Fh,IsRegExp:()=>Zh,IsSet:()=>Qh,IsString:()=>Dh,IsTypeArray:()=>Gh,IsUint16Array:()=>zh,IsUint32Array:()=>Vh,IsUint8Array:()=>_h,IsUint8ClampedArray:()=>Uh});function jh(e){return e instanceof Boolean}function Fh(e){return e instanceof Number}function Dh(e){return e instanceof String}function Gh(e){return globalThis.ArrayBuffer.isView(e)}function Nh(e){return e instanceof globalThis.Int8Array}function _h(e){return e instanceof globalThis.Uint8Array}function Uh(e){return e instanceof globalThis.Uint8ClampedArray}function Kh(e){return e instanceof globalThis.Int16Array}function zh(e){return e instanceof globalThis.Uint16Array}function Bh(e){return e instanceof globalThis.Int32Array}function Vh(e){return e instanceof globalThis.Uint32Array}function Wh(e){return e instanceof globalThis.Float32Array}function Hh(e){return e instanceof globalThis.Float64Array}function Yh(e){return e instanceof globalThis.BigInt64Array}function Jh(e){return e instanceof globalThis.BigUint64Array}function Zh(e){return e instanceof globalThis.RegExp}function Xh(e){return e instanceof globalThis.Date}function Qh(e){return e instanceof globalThis.Set}function eg(e){return e instanceof globalThis.Map}function ng(e){return s.HasPropertyKey(e,"~kind")||s.HasPropertyKey(e,"~unsafe")}function rg(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 ag(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 og(e){return s.IsClassInstance(e)?e:ng(e)?rg(e):ag(e)}function ig(e){return e.map(t=>Pt(t))}function sg(e){return e.slice()}function mg(e){return new RegExp(e.source,e.flags)}function pg(e){return new Map(Pt([...e.entries()]))}function ug(e){return new Set(Pt([...e.values()]))}function Pt(e){return ht.IsTypeArray(e)?sg(e):ht.IsRegExp(e)?mg(e):ht.IsMap(e)?pg(e):ht.IsSet(e)?ug(e):s.IsArray(e)?ig(e):s.IsObject(e)?og(e):e}function wn(e){return De.clone+=1,Pt(e)}var At={};St(At,{Get:()=>dg,Reset:()=>cg,Set:()=>lg});var it={immutableTypes:!1,maxErrors:8,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function cg(){it.immutableTypes=!1,it.maxErrors=8,it.useAcceleration=!0,it.exactOptionalPropertyTypes=!1,it.enumerableKind=!1,it.correctiveParse=!1,it.unionPrioritySort=!0}function lg(e){for(let t of s.Keys(e)){let n=e[t];n!==void 0&&Object.defineProperty(it,t,{value:n})}}function dg(){return it}function fg(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 as(e,t){return{...e,...t}}function hg(e,t,n={}){De.create+=1;let r=At.Get(),a=as(t,n),i=r.enumerableKind?as(a,e):fg(a,e);return r.immutableTypes?Object.freeze(i):i}function gg(e,t){De.discard+=1;let n={},r=Object.getOwnPropertyDescriptors(wn(e)),a=new Set(t);for(let i of Object.keys(r))a.has(i)||Object.defineProperty(n,i,r[i]);return n}function yg(e,t,n){De.update+=1;let r=At.Get(),a=wn(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 re(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 xg(e){return p.Update(e,{"~readonly":!0},{})}function En(e,t){return p.Update(xg(e),{},t)}function os(e,t,n,r){let a=d(e,t,n);return En(a,r)}function Ig(e){return p.Update(e,{"~optional":!0},{})}function Rn(e,t){return p.Update(Ig(e),{},t)}function is(e,t,n,r){let a=d(e,t,n);return Rn(a,r)}function Re(e,t){return p.Create({"~kind":"Array"},{type:"array",items:e},t)}function K(e){return y(e,"Array")}function Er(e){return p.Discard(e,["~kind","type","items"])}function Ue(e,t,n={}){return p.Create({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},n)}function oe(e){return y(e,"Constructor")}function ss(e){return p.Discard(e,["~kind","type","parameters","instanceType"])}function Ke(e,t,n={}){return p.Create({"~kind":"Function"},{type:"function",parameters:e,returnType:t},n)}function ie(e){return y(e,"Function")}function ms(e){return p.Discard(e,["~kind","type","parameters","returnType"])}function st(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 Ht(e){return y(e,"Generic")}function Yt(e){return p.Create({"~kind":"Any"},{},e)}function Z(e){return y(e,"Any")}var ps="(?!)";function F(e){return p.Create({"~kind":"Never"},{not:{}},e)}function xt(e){return y(e,"Never")}function ze(e,t={}){return I("AddOptional",[e],t)}function Ct(e,t={}){return Rn(e,t)}function us(e){return Ct(e)}function he(e){return re(e)&&s.HasPropertyKey(e,"~optional")}function cs(e){return s.Keys(e).filter(t=>!he(e[t]))}function Rr(e){return s.Keys(e)}function Sr(e){return s.Values(e)}function v(e,t={}){let n=cs(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 ls(e){return p.Discard(e,["~kind","type","properties","required"])}function me(e){return p.Create({"~kind":"Unknown"},{},e)}function ae(e){return y(e,"Unknown")}function Be(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 ce(e){return y(e,"Cyclic")}function ds(e){return p.Update(e,{"~unsafe":null},{})}function Or(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"~unsafe")&&s.IsNull(e["~unsafe"])}var Ve={};St(Ve,{Match:()=>bg});function bg(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}function Sn(...e){let[t,n]=Ve.Match(e,{2:(r,a)=>[r,a,a],1:r=>[r,me(),me()]});return p.Create({"~kind":"Infer"},{type:"infer",name:t,extends:n},{})}function Y(e){return y(e,"Infer")}function Mt(e,t,n,r={}){return p.Create({"~kind":"Dependent"},{if:e,then:t,else:n},r)}function V(e){return y(e,"Dependent")}function fs(e){return p.Discard(e,["~kind","if","then","else"])}function hs(e){return s.IsObjectNotArray(e)}function gs(e){return s.Keys(e).filter(n=>isNaN(n)).reduce((n,r)=>[...n,e[r]],[])}function ys(e){return s.IsString(e)||s.IsNumber(e)}function xs(e,t){let n=hs(e)?gs(e):e;return p.Create({"~kind":"Enum"},{enum:n},t)}function ye(e){return y(e,"Enum")}function ge(e,t={}){return p.Create({"~kind":"Intersect"},{allOf:e},t)}function O(e){return y(e,"Intersect")}function Is(e){return p.Discard(e,["~kind","allOf"])}function J(){throw new Error("Unreachable")}var bs;(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"})(bs||(bs={}));var bk=BigInt("14695981039346656037"),[vk,$k]=[BigInt("1099511628211"),BigInt("18446744073709551616")],Tk=Array.from({length:256}).map((e,t)=>BigInt(t)),vs=new Float64Array(1),kk=new DataView(vs.buffer),wk=new Uint8Array(vs.buffer);var Ek=new TextEncoder;var On=class{constructor(t,n){this.type=t,this.decode=n}Encode(t){let n=this.type,r=Pr(n)?m=>this.decode(n["~codec"].decode(m)):this.decode,a=Pr(n)?m=>n["~codec"].encode(t(m)):t,i={decode:r,encode:a};return p.Update(this.type,{"~codec":i},{})}},Pn=class{constructor(t){this.type=t}Decode(t){return new On(this.type,t)}};function Ar(e){return new Pn(e)}function Ts(e,t){return Ar(e).Decode(t).Encode(()=>{throw Error("Encode not implemented")})}function ks(e,t){return Ar(e).Decode(()=>{throw Error("Decode not implemented")}).Encode(t)}function Pr(e){return re(e)&&s.HasPropertyKey(e,"~codec")&&s.IsObject(e["~codec"])&&s.HasPropertyKey(e["~codec"],"encode")&&s.HasPropertyKey(e["~codec"],"decode")}function ws(e){return Jt(e)}function Lt(e){return re(e)&&s.HasPropertyKey(e,"~immutable")}function We(e,t={}){return I("AddReadonly",[e],t)}function qt(e,t={}){return En(e,t)}function Es(e){return qt(e)}function jt(e){return re(e)&&s.HasPropertyKey(e,"~readonly")}function kg(e,t){let n=io(e)?[...e["~refine"],t]:[t];return p.Update(e,{"~refine":n},{})}function Rs(...e){let[t,n,r]=Ve.Match(e,{3:(a,i,m)=>[a,i,m],2:(a,i)=>[a,i,()=>"Refine Error"]});return kg(t,{check:n,error:r})}function wg(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"check")&&s.HasPropertyKey(e,"error")&&s.IsFunction(e.check)&&s.IsFunction(e.error)}function io(e){return re(e)&&s.HasPropertyKey(e,"~refine")&&s.IsArray(e["~refine"])&&s.Every(e["~refine"],0,t=>wg(t))}var Ss="-?(?:0|[1-9][0-9]*)n";function An(e){return p.Create({"~kind":"BigInt"},{type:"bigint"},e)}function He(e){return y(e,"BigInt")}function Cr(e){return p.Create({"~kind":"Boolean"},{type:"boolean"},e)}function Ae(e){return y(e,"Boolean")}function Cn(e){return p.Create({"~kind":"Identifier"},{name:e})}function Os(e){return y(e,"Identifier")}var Mr="-?(?:0|[1-9][0-9]*)";function Ft(e){return p.Create({"~kind":"Integer"},{type:"integer"},e)}function xe(e){return y(e,"Integer")}var so=class extends Error{constructor(t){super("Invalid Literal value"),Object.defineProperty(this,"cause",{value:{value:t},writable:!1,configurable:!1,enumerable:!1})}};function Eg(e){return s.IsBigInt(e)?"bigint":s.IsBoolean(e)?"boolean":s.IsNumber(e)?"number":s.IsString(e)?"string":(()=>{throw new so(e)})()}function P(e,t){return p.Create({"~kind":"Literal"},{type:Eg(e),const:e},t)}function Lr(e){return s.IsBigInt(e)||s.IsBoolean(e)||s.IsNumber(e)||s.IsString(e)}function Ps(e){return q(e)&&s.IsNumber(e.const)}function As(e){return q(e)&&s.IsString(e.const)}function q(e){return y(e,"Literal")}function Zt(e){return p.Create({"~kind":"Null"},{type:"null"},e)}function Xt(e){return y(e,"Null")}var qr="-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";function ke(e){return p.Create({"~kind":"Number"},{type:"number"},e)}function X(e){return y(e,"Number")}function Qt(e){return p.Create({"~kind":"Symbol"},{type:"symbol"},e)}function It(e){return y(e,"Symbol")}function Dt(...e){let[t,n,r]=Ve.Match(e,{3:(a,i,m)=>[a,i,m],2:(a,i)=>[a,i,i],1:a=>[a,me(),me()]});return p.Create({"~kind":"Parameter"},{name:t,extends:n,equals:r},{})}function Cs(e){return y(e,"Parameter")}var jr=".*";function Ce(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 Ms(e){return p.Discard(e,["~kind","anyOf"])}function Mn(e){let t=Ls(e);return s.IsEqual(t.length,2)?t[0]:[]}function Rg(e){return!0}function qs(e){return s.ShiftLeft(e,(t,n)=>Sg(t)?qs(n):!1,()=>!0)}function js(e){return s.IsEqual(e.length,0)?!1:qs(e)}function Sg(e){return x(e)?js(e.anyOf):q(e)?Rg(e.const):!1}function Fr(e){return js(e)}function Dr(e){return p.Create({"~kind":"TemplateLiteral"},{type:"string",pattern:e},{})}function Fs(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>Fs(a,t,[...n,`${r}${t}`]),()=>n)}function Og(e,t){return s.IsEqual(e.length,0)?[`${t}`]:Fs(e,t)}function Ds(e,t,n=[]){return s.ShiftLeft(t,(r,a)=>Ds(e,a,[...n,...Gs(e,r)]),()=>n)}function Gs(e,t){return x(t)?Ds(e,t.anyOf):q(t)?Og(e,t.const):J()}function Ns(e,t){return s.ShiftLeft(t,(n,r)=>Ns(Gs(e,n),r),()=>e)}function Pg(e){return e.map(t=>P(t))}function Ag(e){let t=Ns([],e),n=Pg(t);return w(n)}function Cg(e){return s.IsEqual(e.length,0)?J():s.IsEqual(e.length,1)&&q(e[0])?e[0]:Ag(e)}function mo(e){let t=Mn(e);return s.IsEqual(t.length,0)?Ce():Fr(t)?Cg(t):Dr(e)}function _s(e){let t=mo(e);return Q(t)?Ce():t}function $e(e,t){let n="object",r={[e]:t};return p.Create({"~kind":"Record"},{type:n,patternProperties:r})}function Us(e){return $e(Ge,e)}function Ks(e){return v({true:e,false:e})}function ee(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 G(e){return y(e,"Tuple")}function zs(e){return p.Discard(e,["~kind","type","items","minItems","additionalItems"])}function Mg(e){return p.Discard(e,["~readonly"])}function po(e,t){return p.Update(Mg(e),{},t)}function Bs(e,t,n,r){let a=d(e,t,n);return po(a,r)}function Vs(e,t={}){return I("RemoveReadonly",[e],t)}function Ws(e,t={}){return po(e,t)}function Lg(e){return p.Discard(e,["~optional"])}function uo(e,t){return p.Update(Lg(e),{},t)}function Hs(e,t,n,r){let a=d(e,t,n);return uo(a,r)}function Ys(e,t={}){return I("RemoveOptional",[e],t)}function Gr(e,t={}){return uo(e,t)}function co(e){return e.reduceRight((n,r,a)=>({[a]:r,...n}),{})}function Js(e){let t=co(e.items);return v(t)}function qg(e,t){return jt(e)?!!jt(t):!1}function jg(e,t){return he(e)?!!he(t):!1}function Fg(e,t){let n=qg(e,t),r=jg(e,t),a=z([e,t]),i=Ws(Gr(a));return n&&r?qt(Ct(i)):n&&!r?qt(i):!n&&r?Ct(i):i}function Dg(e,t,n){return n in e?n in t?Fg(e[n],t[n]):e[n]:n in t?t[n]:F()}function Gg(e,t){return[...new Set([...s.Keys(t),...s.Keys(e)])].reduce((r,a)=>({...r,[a]:Dg(e,t,a)}),{})}function Zs(e){return L(e)?e.properties:G(e)?co(e.items):J()}function Xs(e,t){let n=Zs(e),r=Zs(t),a=Gg(n,r);return v(a)}function Qs(e,t){let n=en(e,t);return s.IsEqual(n,qn)?e:s.IsEqual(n,jn)||s.IsEqual(n,Ln)?t:F()}function em(e){return L(e)||G(e)}function Ng(e,t){let n=x(e),r=x(t);return n||r}function _g(e,t){let n=Me(e),r=Me(t),a=Ng(n,r),i=em(n),m=em(r);return a?z([n,r]):i&&m?Xs(n,r):i&&!m?n:!i&&m?r:Qs(n,r)}function tm(e,t,n=[]){return s.ShiftLeft(t,(r,a)=>tm(e,a,[...n,_g(e,r)]),()=>s.IsEqual(n.length,0)?[e]:n)}function nm(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>nm(a,t,[...n,...Fn([r],t)]),()=>n)}function Fn(e,t=[]){return s.ShiftLeft(e,(n,r)=>x(n)?Fn(r,nm(n.anyOf,t)):Fn(r,tm(n,t)),()=>t)}function Ug(e,t){let n=le({},e,t);return b.IsExtendsTrueLike(n)?[]:[e]}function Kg(e,t){return e.reduce((n,r)=>[...n,...Ug(r,t)],[])}function Nr(e,t){let n=Me(e),r=x(n)?n.anyOf:[n],a=Kg(r,t);return we(a)}function Ne(e,t,n){let r=ge([e,t]),a=Nr(n,e);return we([r,a])}function Se(e){let t=e.map(n=>P(n));return we(t)}function z(e){let t=Fn(e),n=lo(t);return mt(n)}function Te(e){let t=_s(e);return Me(t)}function we(e){let t=lo(e);return mt(t)}function Me(e){return V(e)?Ne(e.if,e.then,e.else):ye(e)?Se(e.enum):O(e)?z(e.allOf):Q(e)?Te(e.pattern):x(e)?we(e.anyOf):e}function mt(e){return s.IsEqual(e.length,1)?e[0]:s.IsEqual(e.length,0)?F():w(e)}function rm(e,t){let n=Se(e);return bt(n,t)}function am(e,t){return $e(vt,t)}function om(e,t){let n=z(e);return bt(n,t)}function im(e,t){return s.IsString(e)||s.IsNumber(e)?v({[e]:t}):s.IsEqual(e,!1)?v({false:t}):s.IsEqual(e,!0)?v({true:t}):v({})}function sm(e,t){return $e(tn,t)}function mm(e,t){return s.HasPropertyKey(e,"pattern")&&(s.IsString(e.pattern)||e.pattern instanceof RegExp)?$e(e.pattern.toString(),t):$e(Ge,t)}function pm(e,t){let n=Mn(e);return Fr(n)?bt(Te(e),t):$e(e,t)}function zg(e){return x(e)?Dn(e.anyOf):[e]}function Dn(e){return e.reduce((t,n)=>[...t,...zg(n)],[])}function Bg(e){return e.some(t=>Ie(t)||X(t)||xe(t))}function Vg(e,t){return s.IsEqual(Bg(e),!0)?$e(Ge,t):void 0}function Wg(e,t){return e.reduce((n,r)=>q(r)&&(s.IsString(r.const)||s.IsNumber(r.const))?{...n,[r.const]:t}:n,{})}function Hg(e,t){let n=Wg(e,t);return v(n)}function um(e,t){let n=Dn(e),r=Vg(n,t);return re(r)?r:Hg(n,t)}function bt(e,t){return Z(e)?Us(t):Ae(e)?Ks(t):ye(e)?rm(e.enum,t):xe(e)?am(e,t):O(e)?om(e.allOf,t):q(e)?im(e.const,t):X(e)?sm(e,t):x(e)?um(e.anyOf,t):Ie(e)?mm(e,t):Q(e)?pm(e.pattern,t):v({})}function fo(e,t,n){return k([e])?p.Update(bt(e,t),{},n):_r(e,t,n)}function cm(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return fo(i,m,a)}var vt=`^${Mr}$`,tn=`^${qr}$`,Ge=`^${jr}$`;function _r(e,t,n={}){return I("Record",[e,t],n)}function Ur(e,t,n={}){return fo(e,t,n)}function lm(e,t){return $e(e,t)}function Kr(e){return s.IsEqual(e,Ge)?Ce():s.IsEqual(e,vt)?Ft():s.IsEqual(e,tn)?ke():mo(e)}function Le(e){return s.Keys(e.patternProperties)[0]}function nn(e){let t=Le(e);return Kr(t)}function be(e){return e.patternProperties[Le(e)]}function de(e){return y(e,"Record")}function Gt(e){return p.Create({"~kind":"Rest"},{type:"rest",items:e},{})}function $t(e){return y(e,"Rest")}function zr(e){return p.Create({"~kind":"This"},{$ref:"#"},e)}function Br(e){return y(e,"This")}function rn(e){return p.Create({"~kind":"Undefined"},{type:"undefined"},e)}function an(e){return y(e,"Undefined")}function Vr(e){return p.Create({"~kind":"Void"},{type:"void"},e)}function Ye(e){return y(e,"Void")}function Jg(e,t){return s.IsEqual(e,"Array")?Re(t[0]):s.IsEqual(e,"Capitalize")?Hr(t[0]):s.IsEqual(e,"ConstructorParameters")?Qr(t[0]):s.IsEqual(e,"Evaluate")?fu(t[0]):s.IsEqual(e,"Exclude")?ea(t[0],t[1]):s.IsEqual(e,"Extract")?ta(t[0],t[1]):s.IsEqual(e,"Index")?Un(t[0],t[1]):s.IsEqual(e,"InstanceType")?na(t[0]):s.IsEqual(e,"Lowercase")?Yr(t[0]):s.IsEqual(e,"NonNullable")?ra(t[0]):s.IsEqual(e,"Omit")?aa(t[0],t[1]):s.IsEqual(e,"Parameters")?oa(t[0]):s.IsEqual(e,"Partial")?ia(t[0]):s.IsEqual(e,"Pick")?sa(t[0],t[1]):s.IsEqual(e,"Readonly")?ma(t[0]):s.IsEqual(e,"KeyOf")?Kn(t[0]):s.IsEqual(e,"Record")?_r(t[0],t[1]):s.IsEqual(e,"Required")?pa(t[0]):s.IsEqual(e,"ReturnType")?ua(t[0]):s.IsEqual(e,"Uncapitalize")?Jr(t[0]):s.IsEqual(e,"Uppercase")?Zr(t[0]):_n(st(e),t)}function Nt(){throw Error("Unreachable")}var Zg=(e,t=[])=>e.reduce((n,r)=>s.IsArray(r)&&s.IsEqual(r.length,2)?[...n,r[0]]:[...n,r],[]),pt=e=>{let[t,n]=e;return Zg([...t,...n])};function ym(e){return Dt(e[0],e[2],e[4])}function xm(e){return Dt(e[0],e[2],e[2])}function Im(e){return Dt(e[0],me(),e[2])}function bm(e){return Dt(e,me(),me())}function vm(e){return pt(e)}function $m(e){return e[1]}function Tm(e){return pt(e)}function km(e){return e[1]}function wm(e){return Jg(e[0],e[1])}function Em(e){return null}function Rm(e){return Ce()}function Sm(e){return ke()}function Om(e){return Cr()}function Pm(e){return rn()}function Am(e){return Zt()}function Cm(e){return Ft()}function Mm(e){return An()}function Lm(e){return me()}function qm(e){return Yt()}function jm(e){return v({})}function Fm(e){return F()}function Dm(e){return Qt()}function Gm(e){return Vr()}function Nm(e){return zr()}function _m(e){return P(BigInt(e))}function Um(e){return P(s.IsEqual(e,"true"))}function Km(e){return P(parseFloat(e))}function zm(e){return P(e)}function Bm(e){return e[1]}function Vm(e){return P(e)}function Wm(e){return s.IsEqual(e.length,3)?[e[0],e[1],...e[2]]:[e[0]]}function Hm(e){return e[1]}function Ym(e){return Wr(e)}function Jm(e){return s.IsEqual(e.length,6)?Mt(e[1],e[3],e[5]):Mt(e[1],e[3],me())}function Zm(e){return e.length>0}function Xm(e){return e.reduce((t,n)=>s.IsEqual(n.length,3)?[...t,[n[1]]]:[...t,[]],[])}function Qm(e){return s.IsEqual(e.length,6)?[e[1],e[3],e[5]]:[]}function ep(e){return s.IsArray(e)&&s.IsEqual(e.length,3)?e[1]:e}function tp(e){return s.IsEqual(e.length,2)?e[1]:[]}function dm(e,t){return t.reduce((n,r)=>{let a=r;return s.IsEqual(a.length,1)?Un(n,a[0]):s.IsEqual(a.length,0)?Re(n):Nt()},e)}function fm(e,t){return s.IsEqual(t.length,3)?Xr(e,t[0],t[1],t[2]):e}function Xg(e,t){return s.IsArray(t)&&s.IsEqual(t.length,0)?e:ca(e,t)}function np(e){let[t,n,r,a,i]=e;return Xg(fm(t?Kn(dm(n,r)):dm(n,r),a),i)}function ho(e,t){return s.IsEqual(t.length,3)?(()=>{let[n,r,a]=t,i=ho(r,a);if(s.IsEqual(n,"&"))return O(i)?ge([e,...i.allOf]):ge([e,i]);if(s.IsEqual(n,"|"))return x(i)?w([e,...i.anyOf]):w([e,i]);Nt()})():e}function rp(e){let[t,n]=e;return ho(t,n)}function ap(e){let[t,n]=e;return ho(t,n)}function op(e){return du(e[1])}function ip(e){return e[1]}function sp(e){return yt(e[0],e[2])}function mp(e){return s.IsEqual(e.length,4)?Sn(e[1],e[3]):s.IsEqual(e.length,2)?Sn(e[1],me()):Nt()}function pp(e){return`${e}`}function up(e){return xe(e[3])?vt:X(e[3])?tn:It(e[3])?Ge:Ie(e[3])?Ge:Nt()}function cp(e){return e.length>0}function lp(e){return e.length>0}function dp(e){let[t,n,r,a,i]=e;return{[n]:t&&r?We(ze(i)):t&&!r?We(i):!t&&r?ze(i):i}}function fp(e){return pt(e)}function hp(e){return e.reduce((t,n)=>s.HasPropertyKey(n,vt)||s.HasPropertyKey(n,tn)||s.HasPropertyKey(n,Ge)?[t[0],p.Assign(t[1],n)]:[p.Assign(t[0],n),t[1]],[{},{}])}function gp(e){return hp(e[1])}function yp(e){let[t,n]=e,r=s.IsEqual(s.Keys(n).length,0)?{}:{patternProperties:n};return v(t,r)}function xp(e){return s.IsEqual(e.length,5)?We(ze(e[4])):s.IsEqual(e.length,3)?e[2]:s.IsEqual(e.length,4)?s.IsEqual(e[2],"readonly")?We(e[3]):ze(e[3]):Nt()}function Ip(e){return We(ze(e[1]))}function bp(e){return We(e[1])}function vp(e){return ze(e[0])}function $p(e){return s.IsEqual(e.length,2)?Gt(e[1]):s.IsEqual(e.length,1)?e[0]:Nt()}function Tp(e){return pt(e)}function kp(e){return ee(e[1])}function wp(e){return We(ze(e[4]))}function Ep(e){return We(e[3])}function Rp(e){return ze(e[3])}function Sp(e){return e[2]}function Op(e){return s.IsEqual(e.length,2)?Gt(e[1]):s.IsEqual(e.length,1)?e[0]:Nt()}function Pp(e){return pt(e)}function Ap(e){return Ke(e[1],e[4])}function Cp(e){return Ue(e[2],e[5])}function hm(e,t){return s.IsEqual(e,"remove")?Vs(t):s.IsEqual(e,"add")?We(t):t}function Mp(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 gm(e,t){return s.IsEqual(e,"remove")?Ys(t):s.IsEqual(e,"add")?ze(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 qp(e){return s.IsEqual(e.length,2)?[e[1]]:[]}function jp(e){return s.IsArray(e[6])&&s.IsEqual(e[6].length,1)?Gn(Cn(e[3]),e[5],e[6][0],hm(e[1],gm(e[8],e[10]))):Gn(Cn(e[3]),e[5],st(e[3]),hm(e[1],gm(e[8],e[10])))}function Fp(e){return st(e)}function Dp(e){return BigInt(e)}function Gp(e){return parseFloat(e)}function Np(e){return s.IsEqual(e,"true")}function _p(e){return null}function Up(e){return{[e[0]]:e[2]}}function Kp(e){return pt(e)}function Qg(e){return e.reduce((t,n)=>p.Assign(t,n),{})}function zp(e){return Qg(e[1])}function Bp(e){return pt(e)}function Vp(e){return e[1]}function Wp(e){return An()}function Hp(e){return Ce()}function Yp(e){return ke()}function Jp(e){return Ft()}function Zp(e){return F()}function Xp(e){return P(e)}function Qp(e){return w(e[1])}function eu(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function tu(e){return[e[0],...e[1]]}function nu(e){return e[1]}function ru(e){return pt(e)}function au(e){return s.IsEqual(e.length,2)?e[1]:[]}function ou(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,Nn(n,r,i))}}function iu(e){let t=e[2],[n,r]=e[3],a=s.IsEqual(s.Keys(r).length,0)?{}:{patternProperties:r};return{[e[1]]:Nn(t,n,a)}}function su(e){return{[e[1]]:yt(e[2],e[4])}}function mu(e){return{[e[1]]:e[3]}}function pu(e){return null}function uu(e){return hp(pt(e))}function cu(e){return e[1]}function lu(e){let t=e[0],n=e[1];return hu(p.Assign(t,n[0]))}function zn(e){return M(e.length,2)}function R(e,t,n){return zn(e)?t(e[0],e[1]):n()}function ny(e,t){return M(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function B(e,t){for(let n=0;n<e.length;n++){let r=ny(e[n],t);if(zn(r))return r}return[]}function go(e,t){return Array.from({length:t-e+1},(n,r)=>String.fromCharCode(e+r))}var gu=[...go(97,122),...go(65,90)],yo="0",xo=go(49,57),on=[yo,...xo],yu=" ",sn=`
|
|
6
|
-
`;var Tt="_",la=".",xu="$",da="-";var Iu="//",bu="/*",
|
|
4
|
+
`,"utf-8")}let A=fe(n,"node_modules"),H=fe(r,"node_modules");if(Qa(A)&&!Qa(H))try{rh(A,H,process.platform==="win32"?"junction":"dir")}catch{}try{th(i,fe(r,"agent_prompt.md"))}catch{}let te=Ir(a,"utf-8"),ne=sh(te),ue=fe(r,"test.patch");ot(ue,te,"utf-8");let tt=await t.exec("git",["apply","test.patch"],u);try{ah(ue)}catch{}if(tt.code!==0)return{status:"patchFailed",solverDir:r,error:tt.stderr?.trim()||"git apply test.patch failed"};let N=await t.exec("git",["add","-A"],u);if(N.code!==0)return{status:"error",solverDir:r,error:N.stderr?.trim()||"git add (tests applied) failed"};let nt=await t.exec("git",["commit","-m","tests applied","--allow-empty"],u);if(nt.code!==0)return{status:"error",solverDir:r,error:nt.stderr?.trim()||"git commit (tests applied) failed"};let _e=await t.exec("git",["rev-parse","HEAD"],u);return _e.code!==0||!_e.stdout.trim()?{status:"error",solverDir:r,error:"Could not resolve tests-applied commit hash."}:{status:"ok",solverDir:r,testsAppliedCommit:_e.stdout.trim(),testPatchPaths:ne}}function ph(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 _i(e){let{pi:t,index:n,workspace:r,status:a,durationMs:i}=e,{solverDir:m,testsAppliedCommit:u,testPatchPaths:l}=r,f={cwd:m,timeout:to};await t.exec("git",["add","-A"],f);let h=[...l,"agent_prompt.md"].map(_e=>`:(exclude)${_e}`),$=await t.exec("git",["diff","--cached",u,"--",".",...h],f),E=$.code===0?$.stdout:"",A=fe(m,"test_output.xml"),H=`bash test.sh --output_path ${yr(gr(A))} new`,te=hr(),ne=await t.exec(te,["-c",`cd ${yr(gr(m))} && ${H}`],{timeout:to*10}),ue=ne.code===0,tt=mh(`${ne.stdout}
|
|
5
|
+
${ne.stderr}`.trim(),oh),{totalTests:N,failedTests:nt}=ph(A);return{index:n,status:a,passed:ue,diff:E,testOutputTail:tt,durationMs:i,totalTests:N,failedTests:nt,testOutputXmlPath:A}}function Ui(e){let{repoDir:t,runId:n,index:r,trajectory:a,solutionPatch:i,testOutputXmlPath:m,testOutputTail:u}=e,l=fe(t,ih,n,`solver_${r}`);eo(l,{recursive:!0}),ot(fe(l,"trajectory.json"),JSON.stringify(a,null,2),"utf-8"),ot(fe(l,"solution.patch"),i,"utf-8");try{let f=Ir(m,"utf-8");ot(fe(l,"test_output.xml"),f,"utf-8")}catch{ot(fe(l,"test_output.txt"),u,"utf-8")}return l}function Ki(e,t){let n=fe(e,vn);eo(n,{recursive:!0});let r=t.map(a=>{let i=fe(n,`solver_${a.index}`);return eo(i,{recursive:!0}),ot(fe(i,"solution.diff"),a.diff,"utf-8"),ot(fe(i,"test_output.txt"),a.testOutputTail,"utf-8"),{index:a.index,status:a.status,passed:a.passed}});return ot(fe(n,"manifest.json"),JSON.stringify(r,null,2),"utf-8"),n}function zi(e){let t=fe(e,"node_modules");try{nh(t).isSymbolicLink()&&Gi(t,{force:!0})}catch{}try{Gi(e,{recursive:!0,force:!0})}catch{}}var p={};St(p,{Assign:()=>uh,Clone:()=>wn,Create:()=>gg,Discard:()=>yg,Metrics:()=>De,Update:()=>xg});var De={assign:0,create:0,clone:0,discard:0,update:0};function uh(e,t){return De.assign+=1,{...e,...t}}var s={};St(s,{Entries:()=>Ah,EntriesRegExp:()=>Ph,Every:()=>Rh,EveryAll:()=>Sh,GraphemeCount:()=>kh,HasPropertyKey:()=>Oh,IsArray:()=>Tn,IsBigInt:()=>$n,IsBoolean:()=>Qi,IsClassInstance:()=>$h,IsConstructor:()=>gh,IsDeepEqual:()=>oo,IsEqual:()=>M,IsFunction:()=>es,IsGreaterEqualThan:()=>ns,IsGreaterThan:()=>Ih,IsInteger:()=>ro,IsLessEqualThan:()=>ts,IsLessThan:()=>bh,IsMaxLength:()=>wh,IsMinLength:()=>Eh,IsMultipleOf:()=>vh,IsNull:()=>$r,IsNumber:()=>Tr,IsObject:()=>kn,IsObjectNotArray:()=>yh,IsString:()=>kr,IsSymbol:()=>xh,IsUndefined:()=>ao,IsUnsafePropertyKey:()=>rs,IsValueLike:()=>Th,Keys:()=>vr,ShiftLeft:()=>wr,Symbols:()=>Ch,Values:()=>Mh});function Ot(e,t,n){return e>=t&&e<=n}function ch(e){return e===8205}function lh(e){return Ot(e,55296,56319)}function Bi(e){return Ot(e,127462,127487)}function Wi(e){return Ot(e,65024,65039)}function Hi(e){return Ot(e,768,879)||Ot(e,6832,6911)||Ot(e,7616,7679)||Ot(e,65056,65071)}function br(e){return e>65535?2:1}function Vi(e,t){for(;t<e.length;){let n=e.codePointAt(t);if(Hi(n)||Wi(n))t+=br(n);else break}return t}function no(e,t){let n=e.codePointAt(t),r=t+br(n);for(r=Vi(e,r);r<e.length-1&&e[r]==="\u200D";){let a=e.codePointAt(r+1);r+=1+br(a),r=Vi(e,r)}return Bi(n)&&r<e.length&&Bi(e.codePointAt(r))&&(r+=br(e.codePointAt(r))),r}function Yi(e){return lh(e)||Hi(e)||Wi(e)||ch(e)}function Ji(e){let t=0,n=0;for(;n<e.length;)n=no(e,n),t++;return t}function dh(e,t){if(t===0)return!0;let n=0,r=0;for(;r<e.length;)if(r=no(e,r),n++,n>=t)return!0;return!1}function fh(e,t){let n=0,r=0;for(;r<e.length;)if(r=no(e,r),n++,n>t)return!1;return!0}function Zi(e,t){if(t===0)return!0;let n=0;for(;n<e.length;){if(Yi(e.charCodeAt(n)))return dh(e,t);if(n++,n>=t)return!0}return!1}function Xi(e,t){let n=0;for(;n<e.length;){if(Yi(e.charCodeAt(n)))return fh(e,t);if(n++,n>t)return!1}return!0}function Tn(e){return Array.isArray(e)}function $n(e){return M(typeof e,"bigint")}function Qi(e){return M(typeof e,"boolean")}function gh(e){if(ao(e)||!es(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function es(e){return M(typeof e,"function")}function ro(e){return Number.isInteger(e)}function $r(e){return M(e,null)}function Tr(e){return Number.isFinite(e)}function yh(e){return kn(e)&&!Tn(e)}function kn(e){return M(typeof e,"object")&&!$r(e)}function kr(e){return M(typeof e,"string")}function xh(e){return M(typeof e,"symbol")}function ao(e){return M(e,void 0)}function M(e,t){return e===t}function Ih(e,t){return e>t}function bh(e,t){return e<t}function ts(e,t){return e<=t}function ns(e,t){return e>=t}function vh(e,t){if($n(e)||$n(t))return BigInt(e)%BigInt(t)===0n;let n=1e-10;if(!Tr(e)||ro(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 $h(e){if(!kn(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 Th(e){return $n(e)||Qi(e)||$r(e)||Tr(e)||kr(e)||ao(e)}function kh(e){return Ji(e)}function wh(e,t){return Xi(e,t)}function Eh(e,t){return Zi(e,t)}function Rh(e,t,n){for(let r=t;r<e.length;r++)if(!n(e[r],r))return!1;return!0}function Sh(e,t,n){let r=!0;for(let a=t;a<e.length;a++)n(e[a],a)||(r=!1);return r}function wr(e,t,n){return M(e.length,0)?n():t(e[0],e.slice(1))}function rs(e){return M(e,"__proto__")||M(e,"constructor")||M(e,"prototype")}function Oh(e,t){return rs(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function Ph(e){return vr(e).map(t=>[new RegExp(`^${t}$`),e[t]])}function Ah(e){return Object.entries(e)}function vr(e){return Object.getOwnPropertyNames(e)}function Ch(e){return Object.getOwnPropertySymbols(e)}function Mh(e){return Object.values(e)}function Lh(e,t){if(!kn(t))return!1;let n=vr(e);return M(n.length,vr(t).length)&&n.every(r=>oo(e[r],t[r]))}function qh(e,t){return Tn(t)&&M(e.length,t.length)&&e.every((n,r)=>oo(e[r],t[r]))}function oo(e,t){return Tn(e)?qh(e,t):kn(e)?Lh(e,t):M(e,t)}var ht={};St(ht,{IsBigInt64Array:()=>Jh,IsBigUint64Array:()=>Zh,IsBoolean:()=>Fh,IsDate:()=>Qh,IsFloat32Array:()=>Hh,IsFloat64Array:()=>Yh,IsInt16Array:()=>zh,IsInt32Array:()=>Vh,IsInt8Array:()=>_h,IsMap:()=>tg,IsNumber:()=>Dh,IsRegExp:()=>Xh,IsSet:()=>eg,IsString:()=>Gh,IsTypeArray:()=>Nh,IsUint16Array:()=>Bh,IsUint32Array:()=>Wh,IsUint8Array:()=>Uh,IsUint8ClampedArray:()=>Kh});function Fh(e){return e instanceof Boolean}function Dh(e){return e instanceof Number}function Gh(e){return e instanceof String}function Nh(e){return globalThis.ArrayBuffer.isView(e)}function _h(e){return e instanceof globalThis.Int8Array}function Uh(e){return e instanceof globalThis.Uint8Array}function Kh(e){return e instanceof globalThis.Uint8ClampedArray}function zh(e){return e instanceof globalThis.Int16Array}function Bh(e){return e instanceof globalThis.Uint16Array}function Vh(e){return e instanceof globalThis.Int32Array}function Wh(e){return e instanceof globalThis.Uint32Array}function Hh(e){return e instanceof globalThis.Float32Array}function Yh(e){return e instanceof globalThis.Float64Array}function Jh(e){return e instanceof globalThis.BigInt64Array}function Zh(e){return e instanceof globalThis.BigUint64Array}function Xh(e){return e instanceof globalThis.RegExp}function Qh(e){return e instanceof globalThis.Date}function eg(e){return e instanceof globalThis.Set}function tg(e){return e instanceof globalThis.Map}function rg(e){return s.HasPropertyKey(e,"~kind")||s.HasPropertyKey(e,"~unsafe")}function ag(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 og(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 ig(e){return s.IsClassInstance(e)?e:rg(e)?ag(e):og(e)}function sg(e){return e.map(t=>Pt(t))}function mg(e){return e.slice()}function pg(e){return new RegExp(e.source,e.flags)}function ug(e){return new Map(Pt([...e.entries()]))}function cg(e){return new Set(Pt([...e.values()]))}function Pt(e){return ht.IsTypeArray(e)?mg(e):ht.IsRegExp(e)?pg(e):ht.IsMap(e)?ug(e):ht.IsSet(e)?cg(e):s.IsArray(e)?sg(e):s.IsObject(e)?ig(e):e}function wn(e){return De.clone+=1,Pt(e)}var At={};St(At,{Get:()=>fg,Reset:()=>lg,Set:()=>dg});var it={immutableTypes:!1,maxErrors:8,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function lg(){it.immutableTypes=!1,it.maxErrors=8,it.useAcceleration=!0,it.exactOptionalPropertyTypes=!1,it.enumerableKind=!1,it.correctiveParse=!1,it.unionPrioritySort=!0}function dg(e){for(let t of s.Keys(e)){let n=e[t];n!==void 0&&Object.defineProperty(it,t,{value:n})}}function fg(){return it}function hg(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 as(e,t){return{...e,...t}}function gg(e,t,n={}){De.create+=1;let r=At.Get(),a=as(t,n),i=r.enumerableKind?as(a,e):hg(a,e);return r.immutableTypes?Object.freeze(i):i}function yg(e,t){De.discard+=1;let n={},r=Object.getOwnPropertyDescriptors(wn(e)),a=new Set(t);for(let i of Object.keys(r))a.has(i)||Object.defineProperty(n,i,r[i]);return n}function xg(e,t,n){De.update+=1;let r=At.Get(),a=wn(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 re(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 Ig(e){return p.Update(e,{"~readonly":!0},{})}function En(e,t){return p.Update(Ig(e),{},t)}function os(e,t,n,r){let a=d(e,t,n);return En(a,r)}function bg(e){return p.Update(e,{"~optional":!0},{})}function Rn(e,t){return p.Update(bg(e),{},t)}function is(e,t,n,r){let a=d(e,t,n);return Rn(a,r)}function Re(e,t){return p.Create({"~kind":"Array"},{type:"array",items:e},t)}function K(e){return y(e,"Array")}function Er(e){return p.Discard(e,["~kind","type","items"])}function Ue(e,t,n={}){return p.Create({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},n)}function oe(e){return y(e,"Constructor")}function ss(e){return p.Discard(e,["~kind","type","parameters","instanceType"])}function Ke(e,t,n={}){return p.Create({"~kind":"Function"},{type:"function",parameters:e,returnType:t},n)}function ie(e){return y(e,"Function")}function ms(e){return p.Discard(e,["~kind","type","parameters","returnType"])}function st(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 Ht(e){return y(e,"Generic")}function Yt(e){return p.Create({"~kind":"Any"},{},e)}function Z(e){return y(e,"Any")}var ps="(?!)";function F(e){return p.Create({"~kind":"Never"},{not:{}},e)}function xt(e){return y(e,"Never")}function ze(e,t={}){return I("AddOptional",[e],t)}function Ct(e,t={}){return Rn(e,t)}function us(e){return Ct(e)}function he(e){return re(e)&&s.HasPropertyKey(e,"~optional")}function cs(e){return s.Keys(e).filter(t=>!he(e[t]))}function Rr(e){return s.Keys(e)}function Sr(e){return s.Values(e)}function v(e,t={}){let n=cs(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 ls(e){return p.Discard(e,["~kind","type","properties","required"])}function me(e){return p.Create({"~kind":"Unknown"},{},e)}function ae(e){return y(e,"Unknown")}function Be(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 ce(e){return y(e,"Cyclic")}function ds(e){return p.Update(e,{"~unsafe":null},{})}function Or(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"~unsafe")&&s.IsNull(e["~unsafe"])}var Ve={};St(Ve,{Match:()=>vg});function vg(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}function Sn(...e){let[t,n]=Ve.Match(e,{2:(r,a)=>[r,a,a],1:r=>[r,me(),me()]});return p.Create({"~kind":"Infer"},{type:"infer",name:t,extends:n},{})}function Y(e){return y(e,"Infer")}function Mt(e,t,n,r={}){return p.Create({"~kind":"Dependent"},{if:e,then:t,else:n},r)}function V(e){return y(e,"Dependent")}function fs(e){return p.Discard(e,["~kind","if","then","else"])}function hs(e){return s.IsObjectNotArray(e)}function gs(e){return s.Keys(e).filter(n=>isNaN(n)).reduce((n,r)=>[...n,e[r]],[])}function ys(e){return s.IsString(e)||s.IsNumber(e)}function xs(e,t){let n=hs(e)?gs(e):e;return p.Create({"~kind":"Enum"},{enum:n},t)}function ye(e){return y(e,"Enum")}function ge(e,t={}){return p.Create({"~kind":"Intersect"},{allOf:e},t)}function O(e){return y(e,"Intersect")}function Is(e){return p.Discard(e,["~kind","allOf"])}function J(){throw new Error("Unreachable")}var bs;(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"})(bs||(bs={}));var vk=BigInt("14695981039346656037"),[$k,Tk]=[BigInt("1099511628211"),BigInt("18446744073709551616")],kk=Array.from({length:256}).map((e,t)=>BigInt(t)),vs=new Float64Array(1),wk=new DataView(vs.buffer),Ek=new Uint8Array(vs.buffer);var Rk=new TextEncoder;var On=class{constructor(t,n){this.type=t,this.decode=n}Encode(t){let n=this.type,r=Pr(n)?m=>this.decode(n["~codec"].decode(m)):this.decode,a=Pr(n)?m=>n["~codec"].encode(t(m)):t,i={decode:r,encode:a};return p.Update(this.type,{"~codec":i},{})}},Pn=class{constructor(t){this.type=t}Decode(t){return new On(this.type,t)}};function Ar(e){return new Pn(e)}function Ts(e,t){return Ar(e).Decode(t).Encode(()=>{throw Error("Encode not implemented")})}function ks(e,t){return Ar(e).Decode(()=>{throw Error("Decode not implemented")}).Encode(t)}function Pr(e){return re(e)&&s.HasPropertyKey(e,"~codec")&&s.IsObject(e["~codec"])&&s.HasPropertyKey(e["~codec"],"encode")&&s.HasPropertyKey(e["~codec"],"decode")}function ws(e){return Jt(e)}function Lt(e){return re(e)&&s.HasPropertyKey(e,"~immutable")}function We(e,t={}){return I("AddReadonly",[e],t)}function qt(e,t={}){return En(e,t)}function Es(e){return qt(e)}function jt(e){return re(e)&&s.HasPropertyKey(e,"~readonly")}function wg(e,t){let n=io(e)?[...e["~refine"],t]:[t];return p.Update(e,{"~refine":n},{})}function Rs(...e){let[t,n,r]=Ve.Match(e,{3:(a,i,m)=>[a,i,m],2:(a,i)=>[a,i,()=>"Refine Error"]});return wg(t,{check:n,error:r})}function Eg(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"check")&&s.HasPropertyKey(e,"error")&&s.IsFunction(e.check)&&s.IsFunction(e.error)}function io(e){return re(e)&&s.HasPropertyKey(e,"~refine")&&s.IsArray(e["~refine"])&&s.Every(e["~refine"],0,t=>Eg(t))}var Ss="-?(?:0|[1-9][0-9]*)n";function An(e){return p.Create({"~kind":"BigInt"},{type:"bigint"},e)}function He(e){return y(e,"BigInt")}function Cr(e){return p.Create({"~kind":"Boolean"},{type:"boolean"},e)}function Ae(e){return y(e,"Boolean")}function Cn(e){return p.Create({"~kind":"Identifier"},{name:e})}function Os(e){return y(e,"Identifier")}var Mr="-?(?:0|[1-9][0-9]*)";function Ft(e){return p.Create({"~kind":"Integer"},{type:"integer"},e)}function xe(e){return y(e,"Integer")}var so=class extends Error{constructor(t){super("Invalid Literal value"),Object.defineProperty(this,"cause",{value:{value:t},writable:!1,configurable:!1,enumerable:!1})}};function Rg(e){return s.IsBigInt(e)?"bigint":s.IsBoolean(e)?"boolean":s.IsNumber(e)?"number":s.IsString(e)?"string":(()=>{throw new so(e)})()}function P(e,t){return p.Create({"~kind":"Literal"},{type:Rg(e),const:e},t)}function Lr(e){return s.IsBigInt(e)||s.IsBoolean(e)||s.IsNumber(e)||s.IsString(e)}function Ps(e){return q(e)&&s.IsNumber(e.const)}function As(e){return q(e)&&s.IsString(e.const)}function q(e){return y(e,"Literal")}function Zt(e){return p.Create({"~kind":"Null"},{type:"null"},e)}function Xt(e){return y(e,"Null")}var qr="-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";function ke(e){return p.Create({"~kind":"Number"},{type:"number"},e)}function X(e){return y(e,"Number")}function Qt(e){return p.Create({"~kind":"Symbol"},{type:"symbol"},e)}function It(e){return y(e,"Symbol")}function Dt(...e){let[t,n,r]=Ve.Match(e,{3:(a,i,m)=>[a,i,m],2:(a,i)=>[a,i,i],1:a=>[a,me(),me()]});return p.Create({"~kind":"Parameter"},{name:t,extends:n,equals:r},{})}function Cs(e){return y(e,"Parameter")}var jr=".*";function Ce(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 Ms(e){return p.Discard(e,["~kind","anyOf"])}function Mn(e){let t=Ls(e);return s.IsEqual(t.length,2)?t[0]:[]}function Sg(e){return!0}function qs(e){return s.ShiftLeft(e,(t,n)=>Og(t)?qs(n):!1,()=>!0)}function js(e){return s.IsEqual(e.length,0)?!1:qs(e)}function Og(e){return x(e)?js(e.anyOf):q(e)?Sg(e.const):!1}function Fr(e){return js(e)}function Dr(e){return p.Create({"~kind":"TemplateLiteral"},{type:"string",pattern:e},{})}function Fs(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>Fs(a,t,[...n,`${r}${t}`]),()=>n)}function Pg(e,t){return s.IsEqual(e.length,0)?[`${t}`]:Fs(e,t)}function Ds(e,t,n=[]){return s.ShiftLeft(t,(r,a)=>Ds(e,a,[...n,...Gs(e,r)]),()=>n)}function Gs(e,t){return x(t)?Ds(e,t.anyOf):q(t)?Pg(e,t.const):J()}function Ns(e,t){return s.ShiftLeft(t,(n,r)=>Ns(Gs(e,n),r),()=>e)}function Ag(e){return e.map(t=>P(t))}function Cg(e){let t=Ns([],e),n=Ag(t);return w(n)}function Mg(e){return s.IsEqual(e.length,0)?J():s.IsEqual(e.length,1)&&q(e[0])?e[0]:Cg(e)}function mo(e){let t=Mn(e);return s.IsEqual(t.length,0)?Ce():Fr(t)?Mg(t):Dr(e)}function _s(e){let t=mo(e);return Q(t)?Ce():t}function $e(e,t){let n="object",r={[e]:t};return p.Create({"~kind":"Record"},{type:n,patternProperties:r})}function Us(e){return $e(Ge,e)}function Ks(e){return v({true:e,false:e})}function ee(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 G(e){return y(e,"Tuple")}function zs(e){return p.Discard(e,["~kind","type","items","minItems","additionalItems"])}function Lg(e){return p.Discard(e,["~readonly"])}function po(e,t){return p.Update(Lg(e),{},t)}function Bs(e,t,n,r){let a=d(e,t,n);return po(a,r)}function Vs(e,t={}){return I("RemoveReadonly",[e],t)}function Ws(e,t={}){return po(e,t)}function qg(e){return p.Discard(e,["~optional"])}function uo(e,t){return p.Update(qg(e),{},t)}function Hs(e,t,n,r){let a=d(e,t,n);return uo(a,r)}function Ys(e,t={}){return I("RemoveOptional",[e],t)}function Gr(e,t={}){return uo(e,t)}function co(e){return e.reduceRight((n,r,a)=>({[a]:r,...n}),{})}function Js(e){let t=co(e.items);return v(t)}function jg(e,t){return jt(e)?!!jt(t):!1}function Fg(e,t){return he(e)?!!he(t):!1}function Dg(e,t){let n=jg(e,t),r=Fg(e,t),a=z([e,t]),i=Ws(Gr(a));return n&&r?qt(Ct(i)):n&&!r?qt(i):!n&&r?Ct(i):i}function Gg(e,t,n){return n in e?n in t?Dg(e[n],t[n]):e[n]:n in t?t[n]:F()}function Ng(e,t){return[...new Set([...s.Keys(t),...s.Keys(e)])].reduce((r,a)=>({...r,[a]:Gg(e,t,a)}),{})}function Zs(e){return L(e)?e.properties:G(e)?co(e.items):J()}function Xs(e,t){let n=Zs(e),r=Zs(t),a=Ng(n,r);return v(a)}function Qs(e,t){let n=en(e,t);return s.IsEqual(n,qn)?e:s.IsEqual(n,jn)||s.IsEqual(n,Ln)?t:F()}function em(e){return L(e)||G(e)}function _g(e,t){let n=x(e),r=x(t);return n||r}function Ug(e,t){let n=Me(e),r=Me(t),a=_g(n,r),i=em(n),m=em(r);return a?z([n,r]):i&&m?Xs(n,r):i&&!m?n:!i&&m?r:Qs(n,r)}function tm(e,t,n=[]){return s.ShiftLeft(t,(r,a)=>tm(e,a,[...n,Ug(e,r)]),()=>s.IsEqual(n.length,0)?[e]:n)}function nm(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>nm(a,t,[...n,...Fn([r],t)]),()=>n)}function Fn(e,t=[]){return s.ShiftLeft(e,(n,r)=>x(n)?Fn(r,nm(n.anyOf,t)):Fn(r,tm(n,t)),()=>t)}function Kg(e,t){let n=le({},e,t);return b.IsExtendsTrueLike(n)?[]:[e]}function zg(e,t){return e.reduce((n,r)=>[...n,...Kg(r,t)],[])}function Nr(e,t){let n=Me(e),r=x(n)?n.anyOf:[n],a=zg(r,t);return we(a)}function Ne(e,t,n){let r=ge([e,t]),a=Nr(n,e);return we([r,a])}function Se(e){let t=e.map(n=>P(n));return we(t)}function z(e){let t=Fn(e),n=lo(t);return mt(n)}function Te(e){let t=_s(e);return Me(t)}function we(e){let t=lo(e);return mt(t)}function Me(e){return V(e)?Ne(e.if,e.then,e.else):ye(e)?Se(e.enum):O(e)?z(e.allOf):Q(e)?Te(e.pattern):x(e)?we(e.anyOf):e}function mt(e){return s.IsEqual(e.length,1)?e[0]:s.IsEqual(e.length,0)?F():w(e)}function rm(e,t){let n=Se(e);return bt(n,t)}function am(e,t){return $e(vt,t)}function om(e,t){let n=z(e);return bt(n,t)}function im(e,t){return s.IsString(e)||s.IsNumber(e)?v({[e]:t}):s.IsEqual(e,!1)?v({false:t}):s.IsEqual(e,!0)?v({true:t}):v({})}function sm(e,t){return $e(tn,t)}function mm(e,t){return s.HasPropertyKey(e,"pattern")&&(s.IsString(e.pattern)||e.pattern instanceof RegExp)?$e(e.pattern.toString(),t):$e(Ge,t)}function pm(e,t){let n=Mn(e);return Fr(n)?bt(Te(e),t):$e(e,t)}function Bg(e){return x(e)?Dn(e.anyOf):[e]}function Dn(e){return e.reduce((t,n)=>[...t,...Bg(n)],[])}function Vg(e){return e.some(t=>Ie(t)||X(t)||xe(t))}function Wg(e,t){return s.IsEqual(Vg(e),!0)?$e(Ge,t):void 0}function Hg(e,t){return e.reduce((n,r)=>q(r)&&(s.IsString(r.const)||s.IsNumber(r.const))?{...n,[r.const]:t}:n,{})}function Yg(e,t){let n=Hg(e,t);return v(n)}function um(e,t){let n=Dn(e),r=Wg(n,t);return re(r)?r:Yg(n,t)}function bt(e,t){return Z(e)?Us(t):Ae(e)?Ks(t):ye(e)?rm(e.enum,t):xe(e)?am(e,t):O(e)?om(e.allOf,t):q(e)?im(e.const,t):X(e)?sm(e,t):x(e)?um(e.anyOf,t):Ie(e)?mm(e,t):Q(e)?pm(e.pattern,t):v({})}function fo(e,t,n){return k([e])?p.Update(bt(e,t),{},n):_r(e,t,n)}function cm(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return fo(i,m,a)}var vt=`^${Mr}$`,tn=`^${qr}$`,Ge=`^${jr}$`;function _r(e,t,n={}){return I("Record",[e,t],n)}function Ur(e,t,n={}){return fo(e,t,n)}function lm(e,t){return $e(e,t)}function Kr(e){return s.IsEqual(e,Ge)?Ce():s.IsEqual(e,vt)?Ft():s.IsEqual(e,tn)?ke():mo(e)}function Le(e){return s.Keys(e.patternProperties)[0]}function nn(e){let t=Le(e);return Kr(t)}function be(e){return e.patternProperties[Le(e)]}function de(e){return y(e,"Record")}function Gt(e){return p.Create({"~kind":"Rest"},{type:"rest",items:e},{})}function $t(e){return y(e,"Rest")}function zr(e){return p.Create({"~kind":"This"},{$ref:"#"},e)}function Br(e){return y(e,"This")}function rn(e){return p.Create({"~kind":"Undefined"},{type:"undefined"},e)}function an(e){return y(e,"Undefined")}function Vr(e){return p.Create({"~kind":"Void"},{type:"void"},e)}function Ye(e){return y(e,"Void")}function Zg(e,t){return s.IsEqual(e,"Array")?Re(t[0]):s.IsEqual(e,"Capitalize")?Hr(t[0]):s.IsEqual(e,"ConstructorParameters")?Qr(t[0]):s.IsEqual(e,"Evaluate")?fu(t[0]):s.IsEqual(e,"Exclude")?ea(t[0],t[1]):s.IsEqual(e,"Extract")?ta(t[0],t[1]):s.IsEqual(e,"Index")?Un(t[0],t[1]):s.IsEqual(e,"InstanceType")?na(t[0]):s.IsEqual(e,"Lowercase")?Yr(t[0]):s.IsEqual(e,"NonNullable")?ra(t[0]):s.IsEqual(e,"Omit")?aa(t[0],t[1]):s.IsEqual(e,"Parameters")?oa(t[0]):s.IsEqual(e,"Partial")?ia(t[0]):s.IsEqual(e,"Pick")?sa(t[0],t[1]):s.IsEqual(e,"Readonly")?ma(t[0]):s.IsEqual(e,"KeyOf")?Kn(t[0]):s.IsEqual(e,"Record")?_r(t[0],t[1]):s.IsEqual(e,"Required")?pa(t[0]):s.IsEqual(e,"ReturnType")?ua(t[0]):s.IsEqual(e,"Uncapitalize")?Jr(t[0]):s.IsEqual(e,"Uppercase")?Zr(t[0]):_n(st(e),t)}function Nt(){throw Error("Unreachable")}var Xg=(e,t=[])=>e.reduce((n,r)=>s.IsArray(r)&&s.IsEqual(r.length,2)?[...n,r[0]]:[...n,r],[]),pt=e=>{let[t,n]=e;return Xg([...t,...n])};function ym(e){return Dt(e[0],e[2],e[4])}function xm(e){return Dt(e[0],e[2],e[2])}function Im(e){return Dt(e[0],me(),e[2])}function bm(e){return Dt(e,me(),me())}function vm(e){return pt(e)}function $m(e){return e[1]}function Tm(e){return pt(e)}function km(e){return e[1]}function wm(e){return Zg(e[0],e[1])}function Em(e){return null}function Rm(e){return Ce()}function Sm(e){return ke()}function Om(e){return Cr()}function Pm(e){return rn()}function Am(e){return Zt()}function Cm(e){return Ft()}function Mm(e){return An()}function Lm(e){return me()}function qm(e){return Yt()}function jm(e){return v({})}function Fm(e){return F()}function Dm(e){return Qt()}function Gm(e){return Vr()}function Nm(e){return zr()}function _m(e){return P(BigInt(e))}function Um(e){return P(s.IsEqual(e,"true"))}function Km(e){return P(parseFloat(e))}function zm(e){return P(e)}function Bm(e){return e[1]}function Vm(e){return P(e)}function Wm(e){return s.IsEqual(e.length,3)?[e[0],e[1],...e[2]]:[e[0]]}function Hm(e){return e[1]}function Ym(e){return Wr(e)}function Jm(e){return s.IsEqual(e.length,6)?Mt(e[1],e[3],e[5]):Mt(e[1],e[3],me())}function Zm(e){return e.length>0}function Xm(e){return e.reduce((t,n)=>s.IsEqual(n.length,3)?[...t,[n[1]]]:[...t,[]],[])}function Qm(e){return s.IsEqual(e.length,6)?[e[1],e[3],e[5]]:[]}function ep(e){return s.IsArray(e)&&s.IsEqual(e.length,3)?e[1]:e}function tp(e){return s.IsEqual(e.length,2)?e[1]:[]}function dm(e,t){return t.reduce((n,r)=>{let a=r;return s.IsEqual(a.length,1)?Un(n,a[0]):s.IsEqual(a.length,0)?Re(n):Nt()},e)}function fm(e,t){return s.IsEqual(t.length,3)?Xr(e,t[0],t[1],t[2]):e}function Qg(e,t){return s.IsArray(t)&&s.IsEqual(t.length,0)?e:ca(e,t)}function np(e){let[t,n,r,a,i]=e;return Qg(fm(t?Kn(dm(n,r)):dm(n,r),a),i)}function ho(e,t){return s.IsEqual(t.length,3)?(()=>{let[n,r,a]=t,i=ho(r,a);if(s.IsEqual(n,"&"))return O(i)?ge([e,...i.allOf]):ge([e,i]);if(s.IsEqual(n,"|"))return x(i)?w([e,...i.anyOf]):w([e,i]);Nt()})():e}function rp(e){let[t,n]=e;return ho(t,n)}function ap(e){let[t,n]=e;return ho(t,n)}function op(e){return du(e[1])}function ip(e){return e[1]}function sp(e){return yt(e[0],e[2])}function mp(e){return s.IsEqual(e.length,4)?Sn(e[1],e[3]):s.IsEqual(e.length,2)?Sn(e[1],me()):Nt()}function pp(e){return`${e}`}function up(e){return xe(e[3])?vt:X(e[3])?tn:It(e[3])?Ge:Ie(e[3])?Ge:Nt()}function cp(e){return e.length>0}function lp(e){return e.length>0}function dp(e){let[t,n,r,a,i]=e;return{[n]:t&&r?We(ze(i)):t&&!r?We(i):!t&&r?ze(i):i}}function fp(e){return pt(e)}function hp(e){return e.reduce((t,n)=>s.HasPropertyKey(n,vt)||s.HasPropertyKey(n,tn)||s.HasPropertyKey(n,Ge)?[t[0],p.Assign(t[1],n)]:[p.Assign(t[0],n),t[1]],[{},{}])}function gp(e){return hp(e[1])}function yp(e){let[t,n]=e,r=s.IsEqual(s.Keys(n).length,0)?{}:{patternProperties:n};return v(t,r)}function xp(e){return s.IsEqual(e.length,5)?We(ze(e[4])):s.IsEqual(e.length,3)?e[2]:s.IsEqual(e.length,4)?s.IsEqual(e[2],"readonly")?We(e[3]):ze(e[3]):Nt()}function Ip(e){return We(ze(e[1]))}function bp(e){return We(e[1])}function vp(e){return ze(e[0])}function $p(e){return s.IsEqual(e.length,2)?Gt(e[1]):s.IsEqual(e.length,1)?e[0]:Nt()}function Tp(e){return pt(e)}function kp(e){return ee(e[1])}function wp(e){return We(ze(e[4]))}function Ep(e){return We(e[3])}function Rp(e){return ze(e[3])}function Sp(e){return e[2]}function Op(e){return s.IsEqual(e.length,2)?Gt(e[1]):s.IsEqual(e.length,1)?e[0]:Nt()}function Pp(e){return pt(e)}function Ap(e){return Ke(e[1],e[4])}function Cp(e){return Ue(e[2],e[5])}function hm(e,t){return s.IsEqual(e,"remove")?Vs(t):s.IsEqual(e,"add")?We(t):t}function Mp(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 gm(e,t){return s.IsEqual(e,"remove")?Ys(t):s.IsEqual(e,"add")?ze(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 qp(e){return s.IsEqual(e.length,2)?[e[1]]:[]}function jp(e){return s.IsArray(e[6])&&s.IsEqual(e[6].length,1)?Gn(Cn(e[3]),e[5],e[6][0],hm(e[1],gm(e[8],e[10]))):Gn(Cn(e[3]),e[5],st(e[3]),hm(e[1],gm(e[8],e[10])))}function Fp(e){return st(e)}function Dp(e){return BigInt(e)}function Gp(e){return parseFloat(e)}function Np(e){return s.IsEqual(e,"true")}function _p(e){return null}function Up(e){return{[e[0]]:e[2]}}function Kp(e){return pt(e)}function ey(e){return e.reduce((t,n)=>p.Assign(t,n),{})}function zp(e){return ey(e[1])}function Bp(e){return pt(e)}function Vp(e){return e[1]}function Wp(e){return An()}function Hp(e){return Ce()}function Yp(e){return ke()}function Jp(e){return Ft()}function Zp(e){return F()}function Xp(e){return P(e)}function Qp(e){return w(e[1])}function eu(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function tu(e){return[e[0],...e[1]]}function nu(e){return e[1]}function ru(e){return pt(e)}function au(e){return s.IsEqual(e.length,2)?e[1]:[]}function ou(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,Nn(n,r,i))}}function iu(e){let t=e[2],[n,r]=e[3],a=s.IsEqual(s.Keys(r).length,0)?{}:{patternProperties:r};return{[e[1]]:Nn(t,n,a)}}function su(e){return{[e[1]]:yt(e[2],e[4])}}function mu(e){return{[e[1]]:e[3]}}function pu(e){return null}function uu(e){return hp(pt(e))}function cu(e){return e[1]}function lu(e){let t=e[0],n=e[1];return hu(p.Assign(t,n[0]))}function zn(e){return M(e.length,2)}function R(e,t,n){return zn(e)?t(e[0],e[1]):n()}function ry(e,t){return M(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function B(e,t){for(let n=0;n<e.length;n++){let r=ry(e[n],t);if(zn(r))return r}return[]}function go(e,t){return Array.from({length:t-e+1},(n,r)=>String.fromCharCode(e+r))}var gu=[...go(97,122),...go(65,90)],yo="0",xo=go(49,57),on=[yo,...xo],yu=" ",sn=`
|
|
6
|
+
`;var Tt="_",la=".",xu="$",da="-";var Iu="//",bu="/*",oy="*/";function vu(e){let t=e.indexOf(oy);return M(t,-1)?"":e.slice(t+2)}function $u(e){let t=e.indexOf(sn);return M(t,-1)?"":e.slice(t)}function iy(e){return e.replace(/^[ \t\r\f\v]+/,"")}function fa(e){let t=iy(e);return t.startsWith(bu)?fa(vu(t.slice(2))):t.startsWith(Iu)?fa($u(t.slice(2))):t}function pe(e){let t=e.trimStart();return t.startsWith(bu)?pe(vu(t.slice(2))):t.startsWith(Iu)?pe($u(t.slice(2))):t}function ha(e,t){return R(B([e],t),(n,r)=>[n,r],()=>["",t])}function sy(e,t){return e.includes(t)}function mn(e,t,n,r=""){return R(B(e,n),(a,i)=>sy(t,a)?mn(e,t,i,r):mn(e,t,i,`${r}${a}`),()=>[r,n])}function my(e){return B(xo,e)}var py=[...on,Tt];function uy(e){return mn(py,[Tt],e)}function cy(e){return R(B([yo],e),(t,n)=>[t,n],()=>R(my(e),(t,n)=>R(uy(n),(r,a)=>[`${t}${r}`,a],()=>[]),()=>[]))}function ga(e){return cy(pe(e))}function ly(e){return ha(da,e)}function dy(e){return R(ly(e),(t,n)=>R(ga(n),(r,a)=>[`${t}${r}`,a],()=>[]),()=>[])}function Tu(e){return dy(pe(e))}function fy(e){return R(Tu(e),(t,n)=>R(B(["n"],n),(r,a)=>[`${t}`,a],()=>[]),()=>[])}function Io(e){return fy(e)}function bo(e,t){return B([e],t)}function c(e,t){return M(e,"")?["",t]:e.startsWith(sn)?bo(e,fa(t)):e.startsWith(yu)?bo(e,t):bo(e,pe(t))}var ku=[...gu,Tt,xu];function hy(e){return B(ku,e)}var gy=[...ku,...on];function wu(e,t=""){return R(B(gy,e),(n,r)=>wu(r,`${t}${n}`),()=>[t,e])}function yy(e){return R(hy(e),(t,n)=>R(wu(n),(r,a)=>[`${t}${r}`,a],()=>[]),()=>[])}function W(e){return yy(pe(e))}var xy=[...on,Tt];function Iy(e){return zn(B([la],e))}function Eu(e){return R(mn(xy,[Tt],e),(t,n)=>M(t,"")?[]:[t,n],()=>[])}function by(e){return R(B([la],e),(t,n)=>R(Eu(n),(r,a)=>[`0${t}${r}`,a],()=>[]),()=>[])}function vy(e){return R(ga(e),(t,n)=>R(B([la],n),(r,a)=>R(Eu(a),(i,m)=>[`${t}${r}${i}`,m],()=>[`${t}`,a]),()=>[`${t}`,n]),()=>[])}function $y(e){return Iy(e)?by(e):vy(e)}function Ru(e){return $y(pe(e))}function Ty(e){return ha(da,e)}function ky(e){return R(Ty(e),(t,n)=>R(Ru(n),(r,a)=>[`${t}${r}`,a],()=>[]),()=>[])}function ya(e){return ky(pe(e))}function wy(e){return M(e,"")?[]:[e.slice(0,1),e.slice(1)]}function Su(e,t){return wr(e,(n,r)=>t.startsWith(n)?!0:Su(r,t),()=>!1)}function kt(e,t,n=""){return R(wy(t),(r,a)=>Su(e,t)?[n,t]:kt(e,a,`${n}${r}`),()=>[])}function Ey(e,t,n){return R(B([e],n),(r,a)=>R(kt([t],a),(i,m)=>R(B([t],m),(u,l)=>[`${i}`,l],()=>[]),()=>[]),()=>[])}function Ry(e,t,n){return R(B([e],n),(r,a)=>R(kt([sn,t],a),(i,m)=>R(B([t],m),(u,l)=>[`${i}`,l],()=>[]),()=>[]),()=>[])}function Ou(e,t,n,r){return n?Ey(e,t,pe(r)):Ry(e,t,pe(r))}function Sy(e,t){return B(e,t)}function Oy(e,t){return Ou(e,e,!1,t)}function Py(e,t){return R(Sy(e,t),(n,r)=>Oy(n,`${n}${r}`),()=>[])}function xa(e,t){return Py(e,pe(t))}function Pu(e,t){return R(kt(e,t),(n,r)=>M(n,"")?[]:[n,r],()=>[])}var o=(e,t,n=()=>[])=>e.length===2?t(e):n(),Cy=e=>o(o(W(e),([t,n])=>o(c("extends",n),([r,a])=>o(S(a),([i,m])=>o(c("=",m),([u,l])=>o(S(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[ym(t),n]),My=e=>o(o(W(e),([t,n])=>o(c("extends",n),([r,a])=>o(S(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[xm(t),n]),Ly=e=>o(o(W(e),([t,n])=>o(c("=",n),([r,a])=>o(S(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Im(t),n]),qy=e=>o(W(e),([t,n])=>[bm(t),n]),Mu=e=>o(o(Cy(e),([t,n])=>[t,n],()=>o(My(e),([t,n])=>[t,n],()=>o(Ly(e),([t,n])=>[t,n],()=>o(qy(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),Lu=(e,t=[])=>o(o(Mu(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>Lu(r,[...t,n]),()=>[t,e]),jy=e=>o(o(Lu(e),([t,n])=>o(o(o(Mu(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[vm(t),n]),To=e=>o(o(c("<",e),([t,n])=>o(jy(n),([r,a])=>o(c(">",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[$m(t),n]),qu=(e,t=[])=>o(o(S(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>qu(r,[...t,n]),()=>[t,e]),Fy=e=>o(o(qu(e),([t,n])=>o(o(o(S(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[Tm(t),n]),Dy=e=>o(o(c("<",e),([t,n])=>o(Fy(n),([r,a])=>o(c(">",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[km(t),n]),Gy=e=>o(o(W(e),([t,n])=>o(Dy(n),([r,a])=>[[t,r],a])),([t,n])=>[wm(t),n]),ju=e=>o(o(o(c(";",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[Em(t),n]),Fu=e=>o(c("string",e),([t,n])=>[Rm(t),n]),Du=e=>o(c("number",e),([t,n])=>[Sm(t),n]),Ny=e=>o(c("boolean",e),([t,n])=>[Om(t),n]),_y=e=>o(c("undefined",e),([t,n])=>[Pm(t),n]),Uy=e=>o(c("null",e),([t,n])=>[Am(t),n]),Gu=e=>o(c("integer",e),([t,n])=>[Cm(t),n]),Ky=e=>o(c("bigint",e),([t,n])=>[Mm(t),n]),zy=e=>o(c("unknown",e),([t,n])=>[Lm(t),n]),By=e=>o(c("any",e),([t,n])=>[qm(t),n]),Vy=e=>o(c("object",e),([t,n])=>[jm(t),n]),Wy=e=>o(c("never",e),([t,n])=>[Fm(t),n]),Nu=e=>o(c("symbol",e),([t,n])=>[Dm(t),n]),Hy=e=>o(c("void",e),([t,n])=>[Gm(t),n]),Yy=e=>o(c("this",e),([t,n])=>[Nm(t),n]),Jy=e=>o(o(c("${",e),([t,n])=>o(S(n),([r,a])=>o(c("}",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Bm(t),n]),vo=e=>o(kt(["${","`"],e),([t,n])=>[Vm(t),n]),_u=e=>o(o(o(vo(e),([t,n])=>o(Jy(n),([r,a])=>o(_u(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o(o(vo(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o(o(vo(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))),([t,n])=>[Wm(t),n]),ko=e=>o(o(c("`",e),([t,n])=>o(_u(n),([r,a])=>o(c("`",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Hm(t),n]),Zy=e=>o(ko(e),([t,n])=>[Ym(t),n]),Xy=e=>o(o(o(c("if",e),([t,n])=>o(S(n),([r,a])=>o(c("then",a),([i,m])=>o(S(m),([u,l])=>o(c("else",l),([f,h])=>o(S(h),([$,E])=>[[t,r,i,u,f,$],E])))))),([t,n])=>[t,n],()=>o(o(c("if",e),([t,n])=>o(S(n),([r,a])=>o(c("then",a),([i,m])=>o(S(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[t,n],()=>[])),([t,n])=>[Jm(t),n]),Qy=e=>o(Io(e),([t,n])=>[_m(t),n]),ex=e=>o(o(c("true",e),([t,n])=>[t,n],()=>o(c("false",e),([t,n])=>[t,n],()=>[])),([t,n])=>[Um(t),n]),tx=e=>o(ya(e),([t,n])=>[Km(t),n]),nx=e=>o(xa(["'",'"'],e),([t,n])=>[zm(t),n]),rx=e=>o(o(o(c("keyof",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[Zm(t),n]),Uu=(e,t=[])=>o(o(o(c("[",e),([n,r])=>o(S(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])=>Uu(r,[...t,n]),()=>[t,e]),ax=e=>o(Uu(e),([t,n])=>[Xm(t),n]),ox=e=>o(o(o(c("extends",e),([t,n])=>o(S(n),([r,a])=>o(c("?",a),([i,m])=>o(S(m),([u,l])=>o(c(":",l),([f,h])=>o(S(h),([$,E])=>[[t,r,i,u,f,$],E])))))),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[Qm(t),n]),ix=e=>o(o(o(c("(",e),([t,n])=>o(S(n),([r,a])=>o(c(")",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o(Fu(e),([t,n])=>[t,n],()=>o(Du(e),([t,n])=>[t,n],()=>o(Ny(e),([t,n])=>[t,n],()=>o(_y(e),([t,n])=>[t,n],()=>o(Uy(e),([t,n])=>[t,n],()=>o(Gu(e),([t,n])=>[t,n],()=>o(Ky(e),([t,n])=>[t,n],()=>o(zy(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(Nu(e),([t,n])=>[t,n],()=>o(Hy(e),([t,n])=>[t,n],()=>o(Yy(e),([t,n])=>[t,n],()=>o(Qy(e),([t,n])=>[t,n],()=>o(ex(e),([t,n])=>[t,n],()=>o(tx(e),([t,n])=>[t,n],()=>o(nx(e),([t,n])=>[t,n],()=>o(Zy(e),([t,n])=>[t,n],()=>o(Xy(e),([t,n])=>[t,n],()=>o(Ix(e),([t,n])=>[t,n],()=>o(wx(e),([t,n])=>[t,n],()=>o(Ax(e),([t,n])=>[t,n],()=>o(Px(e),([t,n])=>[t,n],()=>o(qx(e),([t,n])=>[t,n],()=>o(Gy(e),([t,n])=>[t,n],()=>o(jx(e),([t,n])=>[t,n],()=>[])))))))))))))))))))))))))))),([t,n])=>[ep(t),n]),sx=e=>o(o(o(c("with",e),([t,n])=>o(ac(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[tp(t),n]),Ku=e=>o(o(rx(e),([t,n])=>o(ix(n),([r,a])=>o(ax(a),([i,m])=>o(ox(m),([u,l])=>o(sx(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[np(t),n]),zu=e=>o(o(o(c("&",e),([t,n])=>o(Ku(n),([r,a])=>o(zu(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[t,n]),Bu=e=>o(o(Ku(e),([t,n])=>o(zu(n),([r,a])=>[[t,r],a])),([t,n])=>[rp(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]),Ia=e=>o(o(Bu(e),([t,n])=>o(Vu(n),([r,a])=>[[t,r],a])),([t,n])=>[ap(t),n]),mx=e=>o(o(c("readonly",e),([t,n])=>o(Ia(n),([r,a])=>[[t,r],a])),([t,n])=>[op(t),n]),px=e=>o(o(c("|",e),([t,n])=>o(Ia(n),([r,a])=>[[t,r],a])),([t,n])=>[ip(t),n]),ux=e=>o(o(To(e),([t,n])=>o(c("=",n),([r,a])=>o(S(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[sp(t),n]),cx=e=>o(o(o(c("infer",e),([t,n])=>o(W(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(W(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>[])),([t,n])=>[mp(t),n]),S=e=>o(o(cx(e),([t,n])=>[t,n],()=>o(px(e),([t,n])=>[t,n],()=>o(mx(e),([t,n])=>[t,n],()=>o(Ia(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),lx=e=>o(ya(e),([t,n])=>[pp(t),n]),dx=e=>o(W(e),([t,n])=>[t,n]),fx=e=>o(xa(["'",'"'],e),([t,n])=>[t,n]),hx=e=>o(o(c("[",e),([t,n])=>o(W(n),([r,a])=>o(c(":",a),([i,m])=>o(o(Gu(m),([u,l])=>[u,l],()=>o(Du(m),([u,l])=>[u,l],()=>o(Fu(m),([u,l])=>[u,l],()=>o(Nu(m),([u,l])=>[u,l],()=>[])))),([u,l])=>o(c("]",l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[up(t),n]),Wu=e=>o(o(lx(e),([t,n])=>[t,n],()=>o(dx(e),([t,n])=>[t,n],()=>o(fx(e),([t,n])=>[t,n],()=>o(hx(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),gx=e=>o(o(o(c("readonly",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[cp(t),n]),yx=e=>o(o(o(c("?",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[lp(t),n]),Hu=e=>o(o(gx(e),([t,n])=>o(Wu(n),([r,a])=>o(yx(a),([i,m])=>o(c(":",m),([u,l])=>o(S(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[dp(t),n]),Yu=e=>o(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])=>o(c(`
|
|
8
8
|
`,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(`
|
|
9
|
-
`,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))))),([t,n])=>[t,n]),Ju=(e,t=[])=>o(o(Hu(e),([n,r])=>o(Yu(r),([a,i])=>[[n,a],i])),([n,r])=>Ju(r,[...t,n]),()=>[t,e]),
|
|
9
|
+
`,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))))),([t,n])=>[t,n]),Ju=(e,t=[])=>o(o(Hu(e),([n,r])=>o(Yu(r),([a,i])=>[[n,a],i])),([n,r])=>Ju(r,[...t,n]),()=>[t,e]),xx=e=>o(o(Ju(e),([t,n])=>o(o(o(Hu(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[fp(t),n]),wo=e=>o(o(c("{",e),([t,n])=>o(xx(n),([r,a])=>o(c("}",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[gp(t),n]),Ix=e=>o(wo(e),([t,n])=>[yp(t),n]),bx=e=>o(o(o(W(e),([t,n])=>o(c("?",n),([r,a])=>o(c(":",a),([i,m])=>o(c("readonly",m),([u,l])=>o(S(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[t,n],()=>o(o(W(e),([t,n])=>o(c(":",n),([r,a])=>o(c("readonly",a),([i,m])=>o(S(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[t,n],()=>o(o(W(e),([t,n])=>o(c("?",n),([r,a])=>o(c(":",a),([i,m])=>o(S(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[t,n],()=>o(o(W(e),([t,n])=>o(c(":",n),([r,a])=>o(S(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>[])))),([t,n])=>[xp(t),n]),vx=e=>o(o(c("readonly",e),([t,n])=>o(S(n),([r,a])=>o(c("?",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Ip(t),n]),$x=e=>o(o(c("readonly",e),([t,n])=>o(S(n),([r,a])=>[[t,r],a])),([t,n])=>[bp(t),n]),Tx=e=>o(o(S(e),([t,n])=>o(c("?",n),([r,a])=>[[t,r],a])),([t,n])=>[vp(t),n]),Au=e=>o(o(bx(e),([t,n])=>[t,n],()=>o(vx(e),([t,n])=>[t,n],()=>o($x(e),([t,n])=>[t,n],()=>o(Tx(e),([t,n])=>[t,n],()=>o(S(e),([t,n])=>[t,n],()=>[]))))),([t,n])=>[t,n]),Zu=e=>o(o(o(c("...",e),([t,n])=>o(Au(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(Au(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[])),([t,n])=>[$p(t),n]),Xu=(e,t=[])=>o(o(Zu(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>Xu(r,[...t,n]),()=>[t,e]),kx=e=>o(o(Xu(e),([t,n])=>o(o(o(Zu(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[Tp(t),n]),wx=e=>o(o(c("[",e),([t,n])=>o(kx(n),([r,a])=>o(c("]",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[kp(t),n]),Ex=e=>o(o(W(e),([t,n])=>o(c("?",n),([r,a])=>o(c(":",a),([i,m])=>o(c("readonly",m),([u,l])=>o(S(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[wp(t),n]),Rx=e=>o(o(W(e),([t,n])=>o(c(":",n),([r,a])=>o(c("readonly",a),([i,m])=>o(S(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[Ep(t),n]),Sx=e=>o(o(W(e),([t,n])=>o(c("?",n),([r,a])=>o(c(":",a),([i,m])=>o(S(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[Rp(t),n]),Ox=e=>o(o(W(e),([t,n])=>o(c(":",n),([r,a])=>o(S(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Sp(t),n]),Cu=e=>o(o(Ex(e),([t,n])=>[t,n],()=>o(Rx(e),([t,n])=>[t,n],()=>o(Sx(e),([t,n])=>[t,n],()=>o(Ox(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),Qu=e=>o(o(o(c("...",e),([t,n])=>o(Cu(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(Cu(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[])),([t,n])=>[Op(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]),tc=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])=>[Pp(t),n]),Px=e=>o(o(c("(",e),([t,n])=>o(tc(n),([r,a])=>o(c(")",a),([i,m])=>o(c("=>",m),([u,l])=>o(S(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[Ap(t),n]),Ax=e=>o(o(c("new",e),([t,n])=>o(c("(",n),([r,a])=>o(tc(a),([i,m])=>o(c(")",m),([u,l])=>o(c("=>",l),([f,h])=>o(S(h),([$,E])=>[[t,r,i,u,f,$],E])))))),([t,n])=>[Cp(t),n]),Cx=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])=>[Mp(t),n]),Mx=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])=>[Lp(t),n]),Lx=e=>o(o(o(c("as",e),([t,n])=>o(S(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[qp(t),n]),qx=e=>o(o(c("{",e),([t,n])=>o(Cx(n),([r,a])=>o(c("[",a),([i,m])=>o(W(m),([u,l])=>o(c("in",l),([f,h])=>o(S(h),([$,E])=>o(Lx(E),([A,H])=>o(c("]",H),([te,ne])=>o(Mx(ne),([ue,tt])=>o(c(":",tt),([N,nt])=>o(S(nt),([_e,ct])=>o(ju(ct),([rt,lt])=>o(c("}",lt),([Vt,dt])=>[[t,r,i,u,f,$,A,te,ue,N,_e,rt,Vt],dt]))))))))))))),([t,n])=>[jp(t),n]),jx=e=>o(W(e),([t,n])=>[Fp(t),n]),Fx=e=>o(Io(e),([t,n])=>[Dp(t),n]),Dx=e=>o(ya(e),([t,n])=>[Gp(t),n]),Gx=e=>o(o(c("true",e),([t,n])=>[t,n],()=>o(c("false",e),([t,n])=>[t,n],()=>[])),([t,n])=>[Np(t),n]),Nx=e=>o(xa(['"',"'"],e),([t,n])=>[t,n]),_x=e=>o(c("null",e),([t,n])=>[_p(t),n]),Ux=e=>o(c("undefined",e),([t,n])=>[void 0,n]),nc=e=>o(o(Wu(e),([t,n])=>o(c(":",n),([r,a])=>o(Eo(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Up(t),n]),rc=(e,t=[])=>o(o(nc(e),([n,r])=>o(Yu(r),([a,i])=>[[n,a],i])),([n,r])=>rc(r,[...t,n]),()=>[t,e]),Kx=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])=>[Kp(t),n]),ac=e=>o(o(c("{",e),([t,n])=>o(Kx(n),([r,a])=>o(c("}",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[zp(t),n]),oc=(e,t=[])=>o(o(Eo(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>oc(r,[...t,n]),()=>[t,e]),zx=e=>o(o(oc(e),([t,n])=>o(o(o(Eo(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]),Bx=e=>o(o(c("[",e),([t,n])=>o(zx(n),([r,a])=>o(c("]",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Vp(t),n]),Eo=e=>o(o(Fx(e),([t,n])=>[t,n],()=>o(Dx(e),([t,n])=>[t,n],()=>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(ac(e),([t,n])=>[t,n],()=>o(Bx(e),([t,n])=>[t,n],()=>[])))))))),([t,n])=>[t,n]),Vx=e=>o(c("-?(?:0|[1-9][0-9]*)n",e),([t,n])=>[Wp(t),n]),Wx=e=>o(c(".*",e),([t,n])=>[Hp(t),n]),Hx=e=>o(c("-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?",e),([t,n])=>[Yp(t),n]),Yx=e=>o(c("-?(?:0|[1-9][0-9]*)",e),([t,n])=>[Jp(t),n]),Jx=e=>o(c("(?!)",e),([t,n])=>[Zp(t),n]),Zx=e=>o(Pu(["-?(?:0|[1-9][0-9]*)n",".*","-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?","-?(?:0|[1-9][0-9]*)","(?!)","(",")","$","|"],e),([t,n])=>[Xp(t),n]),Xx=e=>o(o(Vx(e),([t,n])=>[t,n],()=>o(Wx(e),([t,n])=>[t,n],()=>o(Hx(e),([t,n])=>[t,n],()=>o(Yx(e),([t,n])=>[t,n],()=>o(Jx(e),([t,n])=>[t,n],()=>o(Qx(e),([t,n])=>[t,n],()=>o(Zx(e),([t,n])=>[t,n],()=>[]))))))),([t,n])=>[t,n]),Qx=e=>o(o(c("(",e),([t,n])=>o(Ro(n),([r,a])=>o(c(")",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Qp(t),n]),ic=e=>o(o(o($o(e),([t,n])=>o(c("|",n),([r,a])=>o(ic(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o(o($o(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[]))),([t,n])=>[eu(t),n]),$o=e=>o(o(Xx(e),([t,n])=>o(Ro(n),([r,a])=>[[t,r],a])),([t,n])=>[tu(t),n]),Ro=e=>o(o(ic(e),([t,n])=>[t,n],()=>o($o(e),([t,n])=>[t,n],()=>[])),([t,n])=>[t,n]),Ls=e=>o(o(c("^",e),([t,n])=>o(Ro(n),([r,a])=>o(c("$",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[nu(t),n]),sc=(e,t=[])=>o(o(S(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>sc(r,[...t,n]),()=>[t,e]),eI=e=>o(o(sc(e),([t,n])=>o(o(o(S(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[ru(t),n]),mc=e=>o(o(o(c("extends",e),([t,n])=>o(eI(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[au(t),n]),tI=e=>o(o(c("interface",e),([t,n])=>o(W(n),([r,a])=>o(To(a),([i,m])=>o(mc(m),([u,l])=>o(wo(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[ou(t),n]),nI=e=>o(o(c("interface",e),([t,n])=>o(W(n),([r,a])=>o(mc(a),([i,m])=>o(wo(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[iu(t),n]),rI=e=>o(o(c("type",e),([t,n])=>o(W(n),([r,a])=>o(To(a),([i,m])=>o(c("=",m),([u,l])=>o(S(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[su(t),n]),aI=e=>o(o(c("type",e),([t,n])=>o(W(n),([r,a])=>o(c("=",a),([i,m])=>o(S(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[mu(t),n]),oI=e=>o(o(o(c("export",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[pu(t),n]),iI=e=>o(o(o(c(";",e),([t,n])=>o(c(`
|
|
10
10
|
`,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(`
|
|
11
|
-
`,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))),([t,n])=>[t,n]),pc=(e,t=[])=>o(o(So(e),([n,r])=>o(oI(r),([a,i])=>[[n,a],i])),([n,r])=>pc(r,[...t,n]),()=>[t,e]),iI=e=>o(o(pc(e),([t,n])=>o(o(o(So(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[uu(t),n]),So=e=>o(o(aI(e),([t,n])=>o(o(eI(n),([r,a])=>[r,a],()=>o(tI(n),([r,a])=>[r,a],()=>o(nI(n),([r,a])=>[r,a],()=>o(rI(n),([r,a])=>[r,a],()=>[])))),([r,a])=>o(ju(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[cu(t),n]),sI=e=>o(o(So(e),([t,n])=>o(iI(n),([r,a])=>[[t,r],a])),([t,n])=>[lu(t),n]),uc=e=>o(o(sI(e),([t,n])=>[t,n],()=>o(px(e),([t,n])=>[t,n],()=>o(S(e),([t,n])=>[t,n],()=>[]))),([t,n])=>[t,n]);function cc(e){let t=ko(`\`${e}\``);return s.IsEqual(t.length,2)?t[0]:J()}function pI(e){return e.join("|")}function uI(e){return e.slice(1,e.length-1)}function cI(e,t,n){return wt(t,`${n}${e}`)}function lI(e,t){return wt(e,`${t}${Ss}`)}function dI(e,t){return wt(e,`${t}${Mr}`)}function fI(e,t){return wt(e,`${t}${qr}`)}function hI(e,t){return Bn(w([P("false"),P("true")]),e,t)}function gI(e,t){return wt(e,`${t}${jr}`)}function yI(e,t,n){return wt(t,`${n}${uI(e)}`)}function xI(e,t,n){let r=Vn(e,{});return Bn(r,t,n)}function II(e,t,n){let r=Se(e);return Bn(r,t,n)}function lc(e,t,n,r=[]){return s.ShiftLeft(e,(a,i)=>lc(i,t,n,[...r,Bn(a,[],"")]),()=>wt(t,`${n}(${pI(r)})`))}function Bn(e,t,n){return ye(e)?II(e.enum,t,n):xe(e)?dI(t,n):q(e)?cI(e.const,t,n):He(e)?lI(t,n):Ae(e)?hI(t,n):X(e)?fI(t,n):Ie(e)?gI(t,n):Q(e)?yI(e.pattern,t,n):fc(e)?xI(e.parameters[0],t,n):x(e)?lc(e.anyOf,t,n):ps}function wt(e,t){return s.ShiftLeft(e,(n,r)=>Bn(n,r,t),()=>t)}function bI(e){return`^${wt(e,"")}$`}function dc(e){let t=bI(e);return Dr(t)}function Vn(e,t){return k(e)?p.Update(dc(e),{},t):Wr(e,t)}function hc(e,t,n,r){let a=Oe(e,t,n);return Vn(a,r)}function Wr(e,t={}){return I("TemplateLiteral",[e],t)}function fc(e){return re(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"TemplateLiteral")}function gc(e){return Vn(e,{})}function vI(e){let t=cc(e);return gc(t)}function yc(e,t={}){let n=s.IsString(e)?vI(e):gc(e);return p.Update(n,{},t)}function Q(e){return y(e,"TemplateLiteral")}var b={};St(b,{ExtendsFalse:()=>T,ExtendsTrue:()=>g,ExtendsUnion:()=>Oo,IsExtendsFalse:()=>$I,IsExtendsTrue:()=>Ic,IsExtendsTrueLike:()=>pn,IsExtendsUnion:()=>xc,Match:()=>U});function Oo(e){return p.Create({"~kind":"ExtendsUnion"},{inferred:e})}function xc(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 Ic(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsTrue")&&s.IsObject(e.inferred)}function T(){return p.Create({"~kind":"ExtendsFalse"},{})}function $I(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],"ExtendsFalse")}function pn(e){return xc(e)||Ic(e)}function U(e,t,n){return pn(e)?t(e.inferred):n()}function TI(e,t,n,r){return U(C(e,n,r),a=>g(p.Assign(p.Assign(e,a),{[t]:n})),()=>T())}function kI(e,t){return g(e)}function wI(e,t,n,r,a){return U(C(e,t,n),i=>U(C(i,t,r),m=>g(m),()=>T()),()=>U(C(e,t,a),i=>g(i),()=>T()))}function EI(e,t,n){let r=Se(n);return C(e,t,r)}function bc(e,t,n){return s.ShiftLeft(n,(r,a)=>U(C(e,t,r),i=>bc(i,t,a),()=>T()),()=>g(e))}function RI(e,t,n){let r=Te(n);return C(e,t,r)}function vc(e,t,n){return s.ShiftLeft(n,(r,a)=>U(C(e,t,r),i=>g(i),()=>vc(e,t,a)),()=>T())}function j(e,t,n){return Z(n)?kI(e,t):V(n)?wI(e,t,n.if,n.then,n.else):ye(n)?EI(e,t,n.enum):Y(n)?TI(e,n.name,t,n.extends):O(n)?bc(e,t,n.allOf):Q(n)?RI(e,t,n.pattern):x(n)?vc(e,t,n.anyOf):ae(n)?g(e):T()}function $c(e,t,n){return Y(n)?j(e,t,n):Z(n)?g(e):ae(n)?g(e):Oo(e)}function SI(e,t){let n=Lt(e),r=Lt(t);return n&&r||!n&&r?!0:!(n&&!r)}function Tc(e,t,n,r){return K(r)?SI(t,r)?C(e,n,r.items):T():j(e,t,r)}function kc(e,t,n){return He(n)?g(e):j(e,t,n)}function wc(e,t,n){return Ae(n)?g(e):j(e,t,n)}function OI(e,t,n,r,a){let i=Y(r)?t:r,m=Y(r)?r:t,u=he(t),l=he(r);return!u&&l?T():U(C(e,i,m),f=>Wn(f,n,a),()=>T())}function PI(e,t,n,r){return s.ShiftLeft(r,(a,i)=>OI(e,t,n,a,i),()=>he(t)?g(e):T())}function AI(e,t,n){return s.ShiftLeft(t,(r,a)=>PI(e,r,a,n),()=>g(e))}function Wn(e,t,n){return AI(e,t,n)}function ba(e,t,n){return Ye(n)?g(e):C(e,t,n)}function Ec(e,t,n,r){return Z(r)?g(e):ae(r)?g(e):oe(r)?U(Wn(e,t,r.parameters),a=>ba(a,n,r.instanceType),()=>T()):T()}function Rc(e,t,n,r,a){return U(C(e,t,a),()=>C(e,n,a),()=>C(e,r,a))}function Sc(e,t,n){let r=Se(t);return C(e,r,n)}function Oc(e,t,n,r){return Z(r)?g(e):ae(r)?g(e):ie(r)?U(Wn(e,t,r.parameters),a=>ba(a,n,r.returnType),()=>T()):T()}function Pc(e,t,n){return xe(n)?g(e):X(n)?g(e):j(e,t,n)}function Ac(e,t,n){let r=z(t);return C(e,r,n)}function va(e,t,n){return t===n?g(e):T()}function CI(e,t,n){return q(n)?va(e,t,n.const):He(n)?g(e):j(e,P(t),n)}function MI(e,t,n){return q(n)?va(e,t,n.const):Ae(n)?g(e):j(e,P(t),n)}function LI(e,t,n){return q(n)?va(e,t,n.const):X(n)?g(e):j(e,P(t),n)}function qI(e,t,n){return q(n)?va(e,t,n.const):Ie(n)?g(e):j(e,P(t),n)}function Cc(e,t,n){return s.IsBigInt(t.const)?CI(e,t.const,n):s.IsBoolean(t.const)?MI(e,t.const,n):s.IsNumber(t.const)?LI(e,t.const,n):s.IsString(t.const)?qI(e,t.const,n):J()}function Mc(e,t,n){return Y(n)?j(e,t,n):g(e)}function Lc(e,t,n){return Xt(n)?g(e):j(e,t,n)}function qc(e,t,n){return X(n)?g(e):j(e,t,n)}function jI(e,t,n){return he(t)?he(n)?g(e):T():g(e)}function FI(e,t,n){return Y(n)&&xt(n.extends)?T():U(C(e,t,n),r=>jI(r,t,n),()=>T())}function DI(e,t){return e.reduce((n,r)=>r in t?pn(t[r])?{...n,...t[r].inferred}:J():J(),{})}function GI(e,t,n){let r={};for(let m of s.Keys(n))r[m]=m in t?FI({},t[m],n[m]):he(n[m])?Y(n[m])?g(p.Assign(e,{[n[m].name]:n[m].extends})):g(e):T();let a=s.Values(r).every(m=>pn(m)),i=a?DI(s.Keys(r),r):{};return a?g(i):T()}function NI(e,t,n){let r=GI(e,t,n);return pn(r)?g(p.Assign(e,r.inferred)):T()}function _I(e,t,n){return NI(e,t,n)}function UI(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 jc(e,t,n,r){return s.ShiftLeft(t,(a,i)=>U(C({},e[a],n),m=>jc(e,i,n,UI(r,m)),()=>T()),()=>g(r))}function KI(e,t,n,r){let a=s.Keys(t);return jc(t,a,r,e)}function Fc(e,t,n){return de(n)?KI(e,t,Le(n),be(n)):L(n)?_I(e,t,n.properties):j(e,v(t),n)}function zI(e,t){return s.IsEqual(s.Keys(t).length,0)?g(e):T()}function BI(e,t,n,r,a){return C(e,n,a)}function Dc(e,t,n,r){return de(r)?BI(e,Kr(t),n,Kr(Le(r)),be(r)):L(r)?zI(e,r.properties):Z(r)?g(e):ae(r)?g(e):T()}function Gc(e,t,n){return Ie(n)?g(e):j(e,t,n)}function Nc(e,t,n){return It(n)?g(e):j(e,t,n)}function _c(e,t,n){let r=Te(t);return C(e,r,n)}function Po(e,t){return p.Create({"~kind":"Inferrable"},{name:e,type:t},{})}function Hn(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 Ao(e){return $t(e)?Y(e.items)?K(e.items.extends)?Po(e.items.name,e.items.extends.items):ae(e.items.extends)?Po(e.items.name,e.items.extends):void 0:J():void 0}function $a(e){return Y(e)?Po(e.name,e.extends):void 0}function Co(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>U(C({},r,t),()=>Co(a,t,[...n,r]),()=>{}),()=>n)}function Uc(e,t,n,r){let a=Co(n,r);return s.IsArray(a)?g(p.Assign(e,{[t]:ee(a)})):T()}function Ta(e,t,n,r){let a=Co(n,r);return s.IsArray(a)?g(p.Assign(e,{[t]:w(a)})):T()}function VI(e){return[...e].reverse()}function Mo(e,t){return t?VI(e):e}function WI(e){let t=e.length>0?e[0]:void 0,n=re(t)?Ao(t):void 0;return re(n)}function HI(e,t,n,r,a,i){return U(C(e,n,a),m=>Kc(m,t,r,i),()=>T())}function YI(e,t,n,r,a){let i=Ao(r);return Hn(i)?Uc(e,i.name,Mo(n,t),i.type):s.ShiftLeft(n,(m,u)=>HI(e,t,m,u,r,a),()=>T())}function JI(e,t,n,r){return s.ShiftLeft(r,(a,i)=>YI(e,t,n,a,i),()=>s.IsEqual(n.length,0)?g(e):T())}function Kc(e,t,n,r){return JI(e,t,n,r)}function ZI(e,t,n){let r=Et(e,_([],[]),n),a=WI(r);return Kc(e,a,Mo(t,a),Mo(r,a))}function zc(e,t,n){let r=$a(n);return Hn(r)?Ta(e,r.name,t,r.type):s.ShiftLeft(t,(a,i)=>U(C(e,a,n),m=>zc(m,i,n),()=>T()),()=>g(e))}function Bc(e,t,n){let r=Et(e,_([],[]),t);return G(n)?ZI(e,r,n.items):K(n)?zc(e,r,n.items):j(e,ee(r),n)}function Vc(e,t,n){return Ye(n)?g(e):an(n)?g(e):j(e,t,n)}function Wc(e,t,n){return s.ShiftLeft(n,(r,a)=>U(C(e,t,r),i=>g(i),()=>Wc(e,t,a)),()=>T())}function Lo(e,t,n){return s.ShiftLeft(t,(r,a)=>U(Wc(e,r,n),i=>Lo(i,a,n),()=>T()),()=>g(e))}function Hc(e,t,n){let r=$a(n);return Hn(r)?Ta(e,r.name,t,r.type):x(n)?Lo(e,t,n.anyOf):Lo(e,t,[n])}function Yc(e,t,n){return Y(n)?j(e,t,n):Z(n)?g(e):ae(n)?g(e):T()}function Jc(e,t,n){return Ye(n)?g(e):j(e,t,n)}function C(e,t,n){return Z(t)?$c(e,t,n):K(t)?Tc(e,t,t.items,n):He(t)?kc(e,t,n):Ae(t)?wc(e,t,n):oe(t)?Ec(e,t.parameters,t.instanceType,n):V(t)?Rc(e,t.if,t.then,t.else,n):ye(t)?Sc(e,t.enum,n):ie(t)?Oc(e,t.parameters,t.returnType,n):xe(t)?Pc(e,t,n):O(t)?Ac(e,t.allOf,n):q(t)?Cc(e,t,n):xt(t)?Mc(e,t,n):Xt(t)?Lc(e,t,n):X(t)?qc(e,t,n):L(t)?Fc(e,t.properties,n):de(t)?Dc(e,Le(t),be(t),n):Ie(t)?Gc(e,t,n):It(t)?Nc(e,t,n):Q(t)?_c(e,t.pattern,n):G(t)?Bc(e,t.items,n):an(t)?Vc(e,t,n):x(t)?Hc(e,t.anyOf,n):ae(t)?Yc(e,t,n):Ye(t)?Jc(e,t,n):T()}function XI(e,t){return z([...e,v(t)])}function qo(e,t,n){return k(e)?p.Update(XI(e,t),{},n):Nn(e,t,n)}function Zc(e,t,n,r,a){let i=Oe(e,t,n),m=Yn(e,t,r);return qo(i,m,a)}function Nn(e,t,n={}){return I("Interface",[e,t],n)}function un(e){return re(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"Interface")}function Xc(e,t,n={}){return qo(e,t,n)}function QI(e,t,n){return e.includes(n)?!0:Jn([...e,n],t,t[n])}function Qc(e,t,n){let r=Sr(n);return _t(e,t,r)}function _t(e,t,n){return s.ShiftLeft(n,(r,a)=>Jn(e,t,r)?!0:_t(e,t,a),()=>!1)}function Jn(e,t,n){return se(n)?QI(e,t,n.$ref):K(n)?Jn(e,t,n.items):oe(n)?_t(e,t,[...n.parameters,n.instanceType]):ie(n)?_t(e,t,[...n.parameters,n.returnType]):un(n)?Qc(e,t,n.parameters[1]):O(n)?_t(e,t,n.allOf):L(n)?Qc(e,t,n.properties):x(n)?_t(e,t,n.anyOf):G(n)?_t(e,t,n.items):de(n)?Jn(e,t,be(n)):!1}function el(e,t,n){return Jn(e,t,n)}function eb(e,t){return t.reduce((n,r)=>el([r],e,e[r])?[...n,r]:n,[])}function tl(e){let t=Rr(e);return eb(e,t)}function tb(e,t,n){return n.includes(t)?n:t in e?Zn(e,e[t],[...n,t]):J()}function nl(e,t,n){let r=Sr(t);return cn(e,r,n)}function cn(e,t,n){return t.reduce((r,a)=>Zn(e,a,r),n)}function Zn(e,t,n){return se(t)?tb(e,t.$ref,n):K(t)?Zn(e,t.items,n):oe(t)?cn(e,[...t.parameters,t.instanceType],n):ie(t)?cn(e,[...t.parameters,t.returnType],n):un(t)?nl(e,t.parameters[1],n):O(t)?cn(e,t.allOf,n):L(t)?nl(e,t.properties,n):x(t)?cn(e,t.anyOf,n):G(t)?cn(e,t.items,n):de(t)?Zn(e,be(t),n):n}function rl(e,t,n){return Zn(e,n,[t])}function nb(e){return Yt()}function rb(e){return s.Keys(e).reduce((t,n)=>({...t,[n]:Ut(e[n])}),{})}function Xn(e){return e.reduce((t,n)=>[...t,Ut(n)],[])}function Ut(e){return se(e)?nb(e.$ref):K(e)?Re(Ut(e.items),Er(e)):oe(e)?Ue(Xn(e.parameters),Ut(e.instanceType)):ie(e)?Ke(Xn(e.parameters),Ut(e.returnType)):O(e)?ge(Xn(e.allOf)):L(e)?v(rb(e.properties)):de(e)?Ur(nn(e),Ut(be(e))):x(e)?w(Xn(e.anyOf)):G(e)?ee(Xn(e.items)):e}function ab(e,t){return t in e?Ut(e[t]):me()}function al(e){return ab(e.$defs,e.$ref)}function ob(e,t,n){let r=Oe(e,_([],[]),t),a=Yn({},_([],[]),n);return z([...r,v(a)])}function ib(e,t){return s.Keys(e).filter(r=>t.includes(r)).reduce((r,a)=>{let i=e[a],m=un(i)?ob(e,i.parameters[0],i.parameters[1]):i;return{...r,[a]:m}},{})}function ol(e,t,n){let r=rl(e,t,n),a=ib(e,r);return Be(a,t)}function il(e,t){return t in e?se(e[t])?il(e,e[t].$ref):e[t]:F()}function Je(e,t){return il(e,t)}function sl(e){return ce(e)?al(e):Or(e)?me():e}function le(e,t,n){let r=sl(t),a=sl(n);return C(e,r,a)}var Ln="equal",sb="disjoint",qn="left-inside",jn="right-inside";function en(e,t){let n=[ae(e)?b.ExtendsFalse():le({},e,t),ae(e)?b.ExtendsTrue({}):le({},t,e)];return b.IsExtendsTrueLike(n[0])&&b.IsExtendsTrueLike(n[1])?Ln:b.IsExtendsTrueLike(n[0])&&b.IsExtendsFalse(n[1])?qn:b.IsExtendsFalse(n[0])&&b.IsExtendsTrueLike(n[1])?jn:sb}function mb(e,t){return t.filter(n=>en(e,n)!==jn)}function pb(e,t){let n=t.some(r=>{let a=en(e,r);return s.IsEqual(a,qn)||s.IsEqual(a,Ln)});return s.IsEqual(n,!1)}function ub(e,t){let n=Me(e);return Z(n)?[n]:pb(n,t)?[...mb(n,t),n]:t}function cb(e){return e.reduce((t,n)=>L(n)?[...t,n]:xt(n)?t:ub(n,t),[])}function lo(e){let t=cb(e);return Dn(t)}function jo(e,t){return p.Update(Me(e),{},t)}function ml(e,t,n,r){let a=d(e,t,n);return jo(a,r)}function Qn(e,t=[]){return gt(e)&&s.IsEqual(e.action,"Conditional")?se(e.parameters[0])?Qn(e.parameters[2],Qn(e.parameters[3],[...t,e.parameters[0].$ref])):Qn(e.parameters[2],Qn(e.parameters[3],t)):gt(e)&&s.IsEqual(e.action,"Mapped")&>(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 lb(e,t){return e.reduce((n,r)=>[...n,t.includes(r.name)],[])}function cl(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>s.ShiftLeft(t,(i,m)=>cl(a,m,[...n,[i,r]]),()=>n),()=>n)}function db(e){return x(e)?[...e.anyOf]:[e]}function fb(e,t){return e.reduce((n,r)=>[...n,[...r,t]],[])}function pl(e,t){return t.reduce((n,r)=>[...n,...fb(e,r)],[])}function ul(e){return e.reduce((t,n)=>s.IsEqual(n[0],!0)?pl(t,db(n[1])):pl(t,[n[1]]),[[]])}function ll(e,t,n){let r=Qn(n),a=lb(e,r),i=cl(t,a);return gt(n)&&s.IsEqual(n.action,"Conditional")||gt(n)&&s.IsEqual(n.action,"Mapped")?ul(i):[t]}function hb(){return["(not-resolvable)",F()]}function gb(){return["(not-generic)",F()]}function yb(e,t,n){return[e,yt(t,n)]}function xb(e,t,n){return t in e?dl(e,t,e[t],n):hb()}function dl(e,t,n,r){return Ht(n)?yb(t,n.parameters,n.expression):se(n)?xb(e,n.$ref,r):gb()}function fl(e,t,n){return dl(e,"(anonymous)",t,n)}function Ib(e,t,n){if(Y(t)||ln(t)||b.IsExtendsTrueLike(le({},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 hl(e,t,n,r,a){let i=d(e,t,a);return Ib(n,i,r),p.Assign(e,{[n]:i})}function bb(e,t,n,r,a){let i=d(e,t,n.extends),m=d(e,t,n.equals);return s.ShiftLeft(a,(u,l)=>Fo(hl(e,t,n.name,i,u),t,r,l),()=>Fo(hl(e,t,n.name,i,m),t,r,[]))}function Fo(e,t,n,r){return s.ShiftLeft(n,(a,i)=>bb(e,t,a,i,r),()=>e)}function gl(e,t,n,r){return Fo(e,t,n,r)}function vb(e){return s.IsGreaterThan(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}function $b(e,t){return s.IsEqual(vb(e),t)}function Tb(e,t,n,r,a,i){let m=gl(e,t,r,i),u=d(m,_([...t.callstack,n.$ref],t.visited),a);return d(m,_([],[]),u)}function kb(e,t,n,r,a,i){return i.reduce((m,u)=>[...m,Tb(e,t,n,r,a,u)],[])}function wb(e,t,n,r,a,i){let m=ll(r,i,a),u=kb(e,t,n,r,a,m);return s.IsEqual(u.length,1)?u[0]:we(u)}function ka(e,t,n,r){let a=Oe(e,t,r),i=fl(e,n,r),m=i[0],u=i[1];return Ht(u)?$b(t,m)?_n(st(m),a):wb(e,t,st(m),u.parameters,u.expression,a):_n(n,a)}function _n(e,t){return p.Create({"~kind":"Call"},{type:"call",target:e,arguments:t},{})}function yl(e,t){return ka({},_([],[]),e,t)}function ln(e){return y(e,"Call")}function Eb(e){return p.Discard(e,["~immutable"])}function xl(e,t){return p.Update(Eb(e),{},t)}function Il(e,t,n,r){let a=d(e,t,n);return xl(a,r)}function bl(e,t){return e(t)}function vl(e,t){return s.IsString(t)?P(bl(e,t)):P(t)}function $l(e,t){let n=Te(t);return ut(e,n)}function Tl(e,t){let n=t.map(r=>ut(e,r));return w(n)}function ut(e,t){return q(t)?vl(e,t.const):Q(t)?$l(e,t.pattern):x(t)?Tl(e,t.anyOf):t}function Hr(e,t={}){return I("Capitalize",[e],t)}function kl(e,t={}){return Do(e,t)}function Yr(e,t={}){return I("Lowercase",[e],t)}function wl(e,t={}){return Go(e,t)}function Jr(e,t={}){return I("Uncapitalize",[e],t)}function El(e,t={}){return No(e,t)}function Zr(e,t={}){return I("Uppercase",[e],t)}function Rl(e,t={}){return _o(e,t)}var Rb=e=>e[0].toUpperCase()+e.slice(1),Sb=e=>e.toLowerCase(),Ob=e=>e[0].toLowerCase()+e.slice(1),Pb=e=>e.toUpperCase();function Do(e,t){return k([e])?p.Update(ut(Rb,e),{},t):Hr(e,t)}function Go(e,t){return k([e])?p.Update(ut(Sb,e),{},t):Yr(e,t)}function No(e,t){return k([e])?p.Update(ut(Ob,e),{},t):Jr(e,t)}function _o(e,t){return k([e])?p.Update(ut(Pb,e),{},t):Zr(e,t)}function Sl(e,t,n,r){let a=d(e,t,n);return Do(a,r)}function Ol(e,t,n,r){let a=d(e,t,n);return Go(a,r)}function Pl(e,t,n,r){let a=d(e,t,n);return No(a,r)}function Al(e,t,n,r){let a=d(e,t,n);return _o(a,r)}function Xr(e,t,n,r,a={}){return I("Conditional",[e,t,n,r],a)}function Cl(e,t,n,r,a={}){return Uo({},_([],[]),e,t,n,r,a)}function Ab(e,t,n,r,a,i){let m=le(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 Uo(e,t,n,r,a,i,m){return k([n,r])?p.Update(Ab(e,t,n,r,a,i),{},m):Xr(n,r,a,i,m)}function Ml(e,t,n,r,a,i,m){let u=d(e,t,n),l=d(e,t,r);return Uo(e,t,u,l,a,i,m)}function Qr(e,t={}){return I("ConstructorParameters",[e],t)}function Ll(e,t={}){return Ko(e,t)}function Cb(e){let t=oe(e)?e.parameters:[],n=Et({},_([],[]),t);return ee(n)}function Ko(e,t){return k([e])?p.Update(Cb(e),{},t):Qr(e,t)}function ql(e,t,n,r){let a=d(e,t,n);return Ko(a,r)}function ea(e,t,n={}){return I("Exclude",[e,t],n)}function jl(e,t,n={}){return er(e,t,n)}function er(e,t,n){return k([e,t])?p.Update(Nr(e,t),{},n):ea(e,t,n)}function Fl(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return er(i,m,a)}function ta(e,t,n={}){return I("Extract",[e,t],n)}function Dl(e,t,n={}){return zo(e,t,n)}function Mb(e,t){let n=le({},e,t);return b.IsExtendsTrueLike(n)?[e]:[]}function Lb(e,t){return e.reduce((n,r)=>[...n,...Mb(r,t)],[])}function Gl(e,t){let n=Me(e),r=x(n)?n.anyOf:[n],a=Lb(r,t);return we(a)}function zo(e,t,n){return k([e,t])?p.Update(Gl(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 zo(i,m,a)}function qb(e){return e.reduce((t,n)=>Lr(n)?[...t,P(n)]:t,[])}function dn(e){let t=qb(e);return w(t)}function Un(e,t,n={}){return I("Index",[e,t],n)}function _l(e,t,n={}){let r=s.IsArray(t)?dn(t):t;return Bo(e,r,n)}function Ul(e,t){let n=Je(e,t);return Pe(n)}function Kl(e,t,n){let r=Ne(e,t,n);return Pe(r)}function jb(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,$)=>({...h,[$]:e[$]}),{}),m=r.reduce((h,$)=>({...h,[$]:t[$]}),{}),u=a.reduce((h,$)=>({...h,[$]:z([e[$],t[$]])}),{}),l=p.Assign(i,m);return p.Assign(l,u)}function zl(e){return e.reduce((t,n)=>jb(t,Pe(n)),{})}function Bl(e){let t=Js(ee(e));return Pe(t)}function Fb(e,t){return s.Keys(e).filter(a=>a in t).reduce((a,i)=>({...a,[i]:we([e[i],t[i]])}),{})}function Vl(e,t){return s.ShiftLeft(e,(n,r)=>Vl(r,Fb(t,Pe(n))),()=>t)}function Wl(e){return s.ShiftLeft(e,(t,n)=>Vl(n,Pe(t)),()=>J())}function Pe(e){return ce(e)?Ul(e.$defs,e.$ref):V(e)?Kl(e.if,e.then,e.else):O(e)?zl(e.allOf):x(e)?Wl(e.anyOf):G(e)?Bl(e.items):L(e)?e.properties:{}}function fn(e){let t=Pe(e);return v(t)}var Db=new RegExp("^(?:0|[1-9][0-9]*)$");function hn(e){let t=`${e}`;return Db.test(t)?parseInt(t):e}function Gb(e){return P(hn(e))}function Hl(e){return e.map(t=>Yl(t))}function Yl(e){return O(e)?ge(Hl(e.allOf)):x(e)?w(Hl(e.anyOf)):q(e)?Gb(e.const):e}function Jl(e,t){let n=Yl(t),r=le({},n,ke());return b.IsExtendsTrueLike(r)?e:q(t)&&s.IsEqual(t.const,"length")?ke():F()}function Zl(e,t){let n=Je(e,t);return Ee(n)}function Xl(e,t,n){let r=Ne(e,t,n);return Ee(r)}function Ql(e){let t=Se(e);return Ee(t)}function ed(e){let t=z(e);return Ee(t)}function td(e){return[`${e}`]}function nd(e){let t=Te(e);return Ee(t)}function rd(e){return e.reduce((t,n)=>[...t,...Ee(n)],[])}function Ee(e){return ce(e)?Zl(e.$defs,e.$ref):V(e)?Xl(e.if,e.then,e.else):ye(e)?Ql(e.enum):O(e)?ed(e.allOf):q(e)?td(e.const):Q(e)?nd(e.pattern):x(e)?rd(e.anyOf):[]}function gn(e){return Ee(e)}function tr(e,t){return t.map(n=>nr(e,n))}function nr(e,t){return K(t)?Re(nr(e,t.items)):oe(t)?Ue(tr(e,t.parameters),nr(e,t.instanceType)):ie(t)?Ke(tr(e,t.parameters),nr(e,t.returnType)):G(t)?ee(tr(e,t.items)):x(t)?w(tr(e,t.anyOf)):O(t)?ge(tr(e,t.allOf)):Br(t)?v(e):t}function ad(e,t){return nr(e,t)}function Nb(e,t){let n=t in e?e[t]:F();return ad(e,n)}function od(e,t){return t.reduce((n,r)=>[...n,Nb(e,r)],[])}function _b(e,t){let n=gn(t),r=od(e,n);return we(r)}var Ub=new RegExp(vt);function Kb(e){return e.filter(n=>Ub.test(n))}function zb(e){let t=Rr(e),n=Kb(t),r=od(e,n);return we(r)}function id(e,t){return X(t)?zb(e):_b(e,t)}function Bb(e){return P(hn(e))}function sd(e){return e.map(t=>Vo(t))}function Vo(e){return O(e)?ge(sd(e.allOf)):x(e)?w(sd(e.anyOf)):q(e)?Bb(e.const):e}function Vb(e,t){return e.reduceRight((n,r,a)=>{let i=le({},P(a),t);return b.IsExtendsTrueLike(i)?[r,...n]:n},[])}function Wb(e,t){let n=Vo(t),r=Vb(e,n);return mt(r)}function Hb(e){return mt(e)}function md(e,t){return q(t)&&s.IsEqual(t.const,"length")?P(e.length):X(t)||xe(t)?Hb(e):Wb(e,t)}function pd(e,t){return K(e)?Jl(e.items,t):L(e)?id(e.properties,t):G(e)?md(e.items,t):F()}function Yb(e){return ce(e)||V(e)||O(e)||x(e)?fn(e):e}function Bo(e,t,n){return k([e,t])?p.Update(pd(Yb(e),t),{},n):Un(e,t,n)}function ud(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return Bo(i,m,a)}function na(e,t={}){return I("InstanceType",[e],t)}function cd(e,t={}){return Wo(e,t)}function Jb(e){return oe(e)?e.instanceType:F()}function Wo(e,t){return k([e])?p.Update(Jb(e),{},t):na(e,t)}function ld(e,t,n,r={}){let a=d(e,t,n);return Wo(a,r)}function Kn(e,t={}){return I("KeyOf",[e],t)}function dd(e,t={}){return Ho(e,t)}function fd(){return w([ke(),Ce(),Qt()])}function hd(e){return ke()}function Zb(e){return e.reduce((n,r)=>Lr(r)?[...n,P(hn(r))]:J(),[])}function gd(e){let t=s.Keys(e),n=Zb(t);return mt(n)}function yd(e){return nn(e)}function xd(e){let t=e.map((n,r)=>P(r));return mt(t)}function Id(e){return Z(e)?fd():K(e)?hd(e.items):L(e)?gd(e.properties):de(e)?yd(e):G(e)?xd(e.items):F()}function Xb(e){return ce(e)||V(e)||O(e)||x(e)?fn(e):e}function Ho(e,t){return k([e])?p.Update(Id(Xb(e)),{},t):Kn(e,t)}function bd(e,t,n,r){let a=d(e,t,n);return Ho(a,r)}function Gn(e,t,n,r,a={}){return I("Mapped",[e,t,n,r],a)}function vd(e,t,n,r,a={}){return Yo({},_([],[]),e,t,n,r,a)}function Qb(e){let t=Te(e);return wa(t)}function ev(e){return e.reduce((t,n)=>[...t,...wa(n)],[])}function tv(e){let t=Se(e);return wa(t)}function nv(e){return s.IsNumber(e)?[P(`${e}`)]:[P(e)]}function wa(e){return ye(e)?tv(e.enum):q(e)?nv(e.const):Q(e)?Qb(e.pattern):x(e)?ev(e.anyOf):[e]}function $d(e){return wa(e)}function rv(e){return Q(e)?Te(e.pattern):e}function av(e,t,n,r,a,i){let m=p.Assign(e,{[n.name]:r}),u=d(m,t,a),l=rv(u),f=d(m,t,i);return Ps(l)||As(l)?{[l.const]:f}:{}}function ov(e,t,n,r,a,i){return r.reduce((m,u)=>[...m,av(e,t,n,u,a,i)],[])}function iv(e){return e.reduce((t,n)=>[...t,v(n)],[])}function Td(e,t,n,r,a,i){let m=$d(r),u=ov(e,t,n,m,a,i),l=iv(u);return z(l)}function Yo(e,t,n,r,a,i,m){return k([r])?p.Update(Td(e,t,n,r,a,i),{},m):Gn(n,r,a,i,m)}function kd(e,t,n,r,a,i,m){let u=d(e,t,r);return Yo(e,t,n,u,a,i,m)}function sv(e,t,n){let r=p.Assign(e,t);return s.Keys(t).filter(i=>n.includes(i)).reduce((i,m)=>({...i,[m]:ol(r,m,t[m])}),{})}function mv(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,_([],[]),t[m])}),{})}function pv(e,t,n){let r=tl(t),a=sv(e,t,r),i=mv(e,t,r),m={...a,...i};return p.Update(m,{},n)}function Ea(e,t,n,r){return pv(e,n,r)}function ra(e,t={}){return I("NonNullable",[e],t)}function wd(e,t={}){return Jo(e,t)}function uv(e){let t=w([Zt(),rn()]);return er(e,t,{})}function Jo(e,t){return k([e])?p.Update(uv(e),{},t):ra(e,t)}function Ed(e,t,n,r){let a=d(e,t,n);return Jo(a,r)}function aa(e,t,n={}){return I("Omit",[e,t],n)}function Rd(e,t,n={}){let r=s.IsArray(t)?dn(t):t;return Zo(e,r,n)}function Ra(e){let t=fn(e);return L(t)?t.properties:J()}function cv(e,t){return s.Keys(e).reduce((r,a)=>t.includes(a)?r:{...r,[a]:e[a]},{})}function Sd(e,t){let n=Ra(e),r=gn(t),a=cv(n,r);return v(a)}function Zo(e,t,n){return k([e,t])?p.Update(Sd(e,t),{},n):aa(e,t,n)}function Od(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return Zo(i,m,a)}function oa(e,t={}){return I("Parameters",[e],t)}function Pd(e,t={}){return Xo(e,t)}function lv(e){let t=ie(e)?e.parameters:[],n=Et({},_([],[]),t);return ee(n)}function Xo(e,t){return k([e])?p.Update(lv(e),{},t):oa(e,t)}function Ad(e,t,n,r){let a=d(e,t,n);return Xo(a,r)}function ia(e,t={}){return I("Partial",[e],t)}function Cd(e,t={}){return Qo(e,t)}function Md(e,t){let n=Je(e,t),r=Ze(n);return Be(p.Assign(e,{[t]:r}),t)}function Ld(e,t,n){let r=Ne(e,t,n);return Ze(r)}function qd(e){let t=z(e);return Ze(t)}function jd(e){let t=e.map(n=>Ze(n));return w(t)}function Fd(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:Ct(e[a])}),{});return v(t)}function Ze(e){return ce(e)?Md(e.$defs,e.$ref):V(e)?Ld(e.if,e.then,e.else):O(e)?qd(e.allOf):x(e)?jd(e.anyOf):L(e)?Fd(e.properties):v({})}function Qo(e,t){return k([e])?p.Update(Ze(e),{},t):ia(e,t)}function Dd(e,t,n,r){let a=d(e,t,n);return Qo(a,r)}function sa(e,t,n={}){return I("Pick",[e,t],n)}function Gd(e,t,n={}){let r=s.IsArray(t)?dn(t):t;return ei(e,r,n)}function dv(e,t){return s.Keys(e).reduce((r,a)=>t.includes(a)?p.Assign(r,{[a]:e[a]}):r,{})}function Nd(e,t){let n=Ra(e),r=gn(t),a=dv(n,r);return v(a)}function ei(e,t,n){return k([e,t])?p.Update(Nd(e,t),{},n):sa(e,t,n)}function _d(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return ei(i,m,a)}function ma(e,t={}){return I("ReadonlyObject",[e],t)}function ti(e,t={}){return ni(e,t)}var Ud=ti;function Kd(e){return Jt(Re(e))}function zd(e,t){let n=Je(e,t),r=Xe(n);return Be(p.Assign(e,{[t]:r}),t)}function Bd(e,t,n){let r=Ne(e,t,n);return Xe(r)}function Vd(e){let t=z(e);return Xe(t)}function Wd(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:qt(e[a])}),{});return v(t)}function Hd(e){return Jt(ee(e))}function Yd(e){let t=e.map(n=>Xe(n));return w(t)}function Xe(e){return K(e)?Kd(e.items):ce(e)?zd(e.$defs,e.$ref):V(e)?Bd(e.if,e.then,e.else):O(e)?Vd(e.allOf):L(e)?Wd(e.properties):G(e)?Hd(e.items):x(e)?Yd(e.anyOf):e}function ni(e,t){return k([e])?p.Update(Xe(e),{},t):ma(e)}function Jd(e,t,n,r){let a=d(e,t,n);return ni(a,r)}function Zd(e,t,n,r){return t.visited.includes(r)?n:r in e?d(e,_(t.callstack,[...t.visited,r]),e[r]):n}function Xd(e,t){let n=Je(e,t),r=Qe(n);return Be(p.Assign(e,{[t]:r}),t)}function Qd(e,t,n){let r=Ne(e,t,n);return Qe(r)}function ef(e){let t=z(e);return Qe(t)}function tf(e){let t=e.map(n=>Qe(n));return w(t)}function nf(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:Gr(e[a])}),{});return v(t)}function Qe(e){return ce(e)?Xd(e.$defs,e.$ref):V(e)?Qd(e.if,e.then,e.else):O(e)?ef(e.allOf):x(e)?tf(e.anyOf):L(e)?nf(e.properties):v({})}function pa(e,t={}){return I("Required",[e],t)}function rf(e,t={}){return ri(e,t)}function ri(e,t){return k([e])?p.Update(Qe(e),{},t):pa(e,t)}function af(e,t,n,r){let a=d(e,t,n);return ri(a,r)}function ua(e,t={}){return I("ReturnType",[e],t)}function of(e,t={}){return ai(e,t)}function fv(e){return ie(e)?e.returnType:F()}function ai(e,t){return k([e])?p.Update(fv(e),{},t):ua(e,t)}function sf(e,t,n,r={}){let a=d(e,t,n);return ai(a,r)}function ca(e,t){return I("With",[e,t],{})}function mf(e,t){return oi(e,t)}function oi(e,t){return k([e])?p.Update(e,{},t):ca(e,t)}function pf(e,t,n,r){let a=d(e,t,n);return oi(a,r)}function hv(e){return $t(e)?G(e.items)?ii(e.items.items):Y(e.items)?[e]:se(e.items)?[e]:[F()]:[e]}function ii(e){return e.reduce((n,r)=>[...n,...hv(r)],[])}function _(e,t){return{callstack:e,visited:t}}function k(e){return s.ShiftLeft(e,(t,n)=>se(t)?!1:k(n),()=>!0)}function Yn(e,t,n){return s.Keys(n).reduce((r,a)=>({...r,[a]:d(e,t,n[a])}),{})}function Et(e,t,n){let r=Oe(e,t,n);return ii(r)}function Oe(e,t,n){return n.map(r=>d(e,t,r))}function gv(e,t){let n=he(e)?Rn(t,{}):t,r=jt(e)?En(n,{}):n;return Lt(e)?rr(r,{}):r}function yv(e,t,n,r,a){return s.IsEqual(n,"AddImmutable")?uf(e,t,r[0],a):s.IsEqual(n,"RemoveImmutable")?Il(e,t,r[0],a):s.IsEqual(n,"AddReadonly")?os(e,t,r[0],a):s.IsEqual(n,"RemoveReadonly")?Bs(e,t,r[0],a):s.IsEqual(n,"AddOptional")?is(e,t,r[0],a):s.IsEqual(n,"RemoveOptional")?Hs(e,t,r[0],a):s.IsEqual(n,"Capitalize")?Sl(e,t,r[0],a):s.IsEqual(n,"Conditional")?Ml(e,t,r[0],r[1],r[2],r[3],a):s.IsEqual(n,"ConstructorParameters")?ql(e,t,r[0],a):s.IsEqual(n,"Evaluate")?ml(e,t,r[0],a):s.IsEqual(n,"Exclude")?Fl(e,t,r[0],r[1],a):s.IsEqual(n,"Extract")?Nl(e,t,r[0],r[1],a):s.IsEqual(n,"Index")?ud(e,t,r[0],r[1],a):s.IsEqual(n,"InstanceType")?ld(e,t,r[0],a):s.IsEqual(n,"Interface")?Zc(e,t,r[0],r[1],a):s.IsEqual(n,"KeyOf")?bd(e,t,r[0],a):s.IsEqual(n,"Lowercase")?Ol(e,t,r[0],a):s.IsEqual(n,"Mapped")?kd(e,t,r[0],r[1],r[2],r[3],a):s.IsEqual(n,"Module")?Ea(e,t,r[0],a):s.IsEqual(n,"NonNullable")?Ed(e,t,r[0],a):s.IsEqual(n,"Pick")?_d(e,t,r[0],r[1],a):s.IsEqual(n,"Parameters")?Ad(e,t,r[0],a):s.IsEqual(n,"Partial")?Dd(e,t,r[0],a):s.IsEqual(n,"Omit")?Od(e,t,r[0],r[1],a):s.IsEqual(n,"ReadonlyObject")?Jd(e,t,r[0],a):s.IsEqual(n,"Record")?cm(e,t,r[0],r[1],a):s.IsEqual(n,"Required")?af(e,t,r[0],a):s.IsEqual(n,"ReturnType")?sf(e,t,r[0],a):s.IsEqual(n,"TemplateLiteral")?hc(e,t,r[0],a):s.IsEqual(n,"Uncapitalize")?Pl(e,t,r[0],a):s.IsEqual(n,"Uppercase")?Al(e,t,r[0],a):s.IsEqual(n,"With")?pf(e,t,r[0],r[1]):I(n,r,a)}function xv(e,t,n){let r=se(n)?Zd(e,t,n,n.$ref):K(n)?Re(d(e,t,n.items),Er(n)):ln(n)?ka(e,t,n.target,n.arguments):oe(n)?Ue(Oe(e,t,n.parameters),d(e,t,n.instanceType),ss(n)):ie(n)?Ke(Oe(e,t,n.parameters),d(e,t,n.returnType),ms(n)):V(n)?Mt(d(e,t,n.if),d(e,t,n.then),d(e,t,n.else),fs(n)):O(n)?ge(Oe(e,t,n.allOf),Is(n)):L(n)?v(Yn(e,t,n.properties),ls(n)):de(n)?lm(Le(n),d(e,t,be(n))):$t(n)?Gt(d(e,t,n.items)):G(n)?ee(Et(e,t,n.items),zs(n)):x(n)?w(Oe(e,t,n.anyOf),Ms(n)):n;return gv(n,r)}function d(e,t,n){return gt(n)?yv(e,t,n.action,n.parameters,n.options):xv(e,t,n)}function si(e,t){return d(e,_([],[]),t)}function Iv(e){return p.Update(e,{"~immutable":!0},{})}function rr(e,t){return p.Update(Iv(e),{},t)}function uf(e,t,n,r){let a=d(e,t,n);return rr(a,r)}function du(e,t={}){return I("AddImmutable",[e],t)}function Jt(e,t={}){return rr(e,t)}function fu(e,t={}){return I("Evaluate",[e],t)}function cf(e,t={}){return jo(e,t)}function hu(e,t={}){return I("Module",[e],t)}function lf(e,t={}){return Ea({},_([],[]),e,t)}function df(...e){let[t,n,r]=Ve.Match(e,{2:(m,u)=>s.IsString(m)?[{},m,u]:[m,u,{}],3:(m,u,l)=>[m,u,l],1:m=>[{},m,{}]}),a=uc(n),i=s.IsArray(a)&&s.IsEqual(a.length,2)?d(t,_([],[]),a[0]):F();return p.Update(i,{},r)}var D={};St(D,{Any:()=>Yt,Array:()=>Re,BigInt:()=>An,Boolean:()=>Cr,Call:()=>yl,Capitalize:()=>kl,Codec:()=>Ar,Conditional:()=>Cl,Constructor:()=>Ue,ConstructorParameters:()=>Ll,Cyclic:()=>Be,Decode:()=>Ts,DecodeBuilder:()=>Pn,Dependent:()=>Mt,Encode:()=>ks,EncodeBuilder:()=>On,Enum:()=>xs,Evaluate:()=>cf,Exclude:()=>jl,Extends:()=>le,ExtendsResult:()=>b,Extract:()=>Dl,Function:()=>Ke,Generic:()=>yt,Identifier:()=>Cn,Immutable:()=>ws,Index:()=>_l,Infer:()=>Sn,InstanceType:()=>cd,Instantiate:()=>si,Integer:()=>Ft,Interface:()=>Xc,Intersect:()=>ge,IsAny:()=>Z,IsArray:()=>K,IsBigInt:()=>He,IsBoolean:()=>Ae,IsCall:()=>ln,IsCodec:()=>Pr,IsConstructor:()=>oe,IsCyclic:()=>ce,IsDependent:()=>V,IsEnum:()=>ye,IsEnumValue:()=>ys,IsFunction:()=>ie,IsGeneric:()=>Ht,IsIdentifier:()=>Os,IsImmutable:()=>Lt,IsInfer:()=>Y,IsInteger:()=>xe,IsIntersect:()=>O,IsKind:()=>y,IsLiteral:()=>q,IsNever:()=>xt,IsNull:()=>Xt,IsNumber:()=>X,IsObject:()=>L,IsOptional:()=>he,IsParameter:()=>Cs,IsReadonly:()=>jt,IsRecord:()=>de,IsRef:()=>se,IsRefine:()=>io,IsRest:()=>$t,IsSchema:()=>re,IsString:()=>Ie,IsSymbol:()=>It,IsTemplateLiteral:()=>Q,IsThis:()=>Br,IsTuple:()=>G,IsUndefined:()=>an,IsUnion:()=>x,IsUnknown:()=>ae,IsUnsafe:()=>Or,IsVoid:()=>Ye,KeyOf:()=>dd,Literal:()=>P,Lowercase:()=>wl,Mapped:()=>vd,Module:()=>lf,Never:()=>F,NonNullable:()=>wd,Null:()=>Zt,Number:()=>ke,Object:()=>v,Omit:()=>Rd,Optional:()=>us,Parameter:()=>Dt,Parameters:()=>Pd,Partial:()=>Cd,Pick:()=>Gd,Readonly:()=>Es,ReadonlyObject:()=>ti,ReadonlyType:()=>Ud,Record:()=>Ur,RecordKey:()=>nn,RecordPattern:()=>Le,RecordValue:()=>be,Ref:()=>st,Refine:()=>Rs,Required:()=>rf,Rest:()=>Gt,ReturnType:()=>of,Script:()=>df,String:()=>Ce,Symbol:()=>Qt,TemplateLiteral:()=>yc,This:()=>zr,Tuple:()=>ee,Uncapitalize:()=>El,Undefined:()=>rn,Union:()=>w,Unknown:()=>me,Unsafe:()=>ds,Uppercase:()=>Rl,Void:()=>Vr,With:()=>mf});var ar="submit_test_gap_candidates",or="submit_filtered_test_gaps",ir="submit_solver_gaps",r8=D.Object({verdict:D.Union([D.Literal("PASS"),D.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:D.String({description:"One short sentence summarizing the verdict."}),reasons:D.Array(D.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:D.Array(D.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 bv=D.Object({statement:D.String({description:"One sentence from agent_prompt.md, copied verbatim."}),gaps:D.Array(D.Object({description:D.String({description:"A fair, publicly observable missing behavioral test."}),risk:D.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 ff(e){return{name:ar,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:bv,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 vv=D.Object({gaps:D.Array(D.Object({description:D.String({description:"The confirmed, real, fair test gap (may be reworded for clarity). Keep POSITIVE:/NEGATIVE: prefix when applicable."}),justification:D.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 hf(e){return{name:or,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:vv,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 $v=D.Object({gaps:D.Array(D.Object({description:D.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:D.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:D.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 gf(e){return{name:ir,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:$v,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 Tv(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 kv=["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."],yf=["Ground rules \u2014 do not overreach:","- Every gap must trace back to a specific requirement or sentence in `agent_prompt.md`, or to behavior that is unambiguous from the existing, visible repo. Do not invent requirements the prompt doesn't support.","- Do not propose gaps for things `agent_prompt.md` leaves intentionally open, or for implementation details/style the prompt doesn't mandate.","- Read the relevant source files carefully and distinguish genuinely required behavior from speculation; focus on public outcomes and edge cases that deserve behavioral coverage.","- Keep findings strictly behavioral and publicly observable: a user, caller, or documented public contract must be able to observe the required outcome. Do not report internal helper calls, private state, implementation structure, call order, file placement, or other incidental mechanics.","- Do not require DOM classes, DOM/data/test attributes, selectors, or exact string literals unless the prompt explicitly names them or they are an established, already-present public contract in the repository. Prefer a visible outcome or public API behavior that accepts equivalent implementations."],wv=["General calibration for validation:","- Check the required semantic properties and observable outcomes, while allowing valid additional data or equivalent implementations that do not weaken the contract.","- Assert relationships and effects required by the prompt rather than selecting an arbitrary concrete value when the prompt or an established public contract does not determine one.","- Compare behavior semantically. Do not reject equivalent representations merely because their syntax, formatting, ordering, or serialization differs unless that representation is part of the stated contract.","- Require exact wording, formatting, timing, or reporting details only when the prompt or an established public contract makes them observable requirements; otherwise validate the underlying operation or result.","- Do not invent behavior for cases the prompt leaves open. Treat examples, defaults, neighboring implementation choices, and reference-solution conventions as context, not as additional requirements."];function xf(e,t){let n=[...Tv("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.","",...kv,"",...yf,"","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 \`${ar}\` 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(`
|
|
12
|
-
`)}function
|
|
13
|
-
`)}function
|
|
14
|
-
`)}function
|
|
15
|
-
`)}var
|
|
11
|
+
`,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))),([t,n])=>[t,n]),pc=(e,t=[])=>o(o(So(e),([n,r])=>o(iI(r),([a,i])=>[[n,a],i])),([n,r])=>pc(r,[...t,n]),()=>[t,e]),sI=e=>o(o(pc(e),([t,n])=>o(o(o(So(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[uu(t),n]),So=e=>o(o(oI(e),([t,n])=>o(o(tI(n),([r,a])=>[r,a],()=>o(nI(n),([r,a])=>[r,a],()=>o(rI(n),([r,a])=>[r,a],()=>o(aI(n),([r,a])=>[r,a],()=>[])))),([r,a])=>o(ju(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[cu(t),n]),mI=e=>o(o(So(e),([t,n])=>o(sI(n),([r,a])=>[[t,r],a])),([t,n])=>[lu(t),n]),uc=e=>o(o(mI(e),([t,n])=>[t,n],()=>o(ux(e),([t,n])=>[t,n],()=>o(S(e),([t,n])=>[t,n],()=>[]))),([t,n])=>[t,n]);function cc(e){let t=ko(`\`${e}\``);return s.IsEqual(t.length,2)?t[0]:J()}function uI(e){return e.join("|")}function cI(e){return e.slice(1,e.length-1)}function lI(e,t,n){return wt(t,`${n}${e}`)}function dI(e,t){return wt(e,`${t}${Ss}`)}function fI(e,t){return wt(e,`${t}${Mr}`)}function hI(e,t){return wt(e,`${t}${qr}`)}function gI(e,t){return Bn(w([P("false"),P("true")]),e,t)}function yI(e,t){return wt(e,`${t}${jr}`)}function xI(e,t,n){return wt(t,`${n}${cI(e)}`)}function II(e,t,n){let r=Vn(e,{});return Bn(r,t,n)}function bI(e,t,n){let r=Se(e);return Bn(r,t,n)}function lc(e,t,n,r=[]){return s.ShiftLeft(e,(a,i)=>lc(i,t,n,[...r,Bn(a,[],"")]),()=>wt(t,`${n}(${uI(r)})`))}function Bn(e,t,n){return ye(e)?bI(e.enum,t,n):xe(e)?fI(t,n):q(e)?lI(e.const,t,n):He(e)?dI(t,n):Ae(e)?gI(t,n):X(e)?hI(t,n):Ie(e)?yI(t,n):Q(e)?xI(e.pattern,t,n):fc(e)?II(e.parameters[0],t,n):x(e)?lc(e.anyOf,t,n):ps}function wt(e,t){return s.ShiftLeft(e,(n,r)=>Bn(n,r,t),()=>t)}function vI(e){return`^${wt(e,"")}$`}function dc(e){let t=vI(e);return Dr(t)}function Vn(e,t){return k(e)?p.Update(dc(e),{},t):Wr(e,t)}function hc(e,t,n,r){let a=Oe(e,t,n);return Vn(a,r)}function Wr(e,t={}){return I("TemplateLiteral",[e],t)}function fc(e){return re(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"TemplateLiteral")}function gc(e){return Vn(e,{})}function $I(e){let t=cc(e);return gc(t)}function yc(e,t={}){let n=s.IsString(e)?$I(e):gc(e);return p.Update(n,{},t)}function Q(e){return y(e,"TemplateLiteral")}var b={};St(b,{ExtendsFalse:()=>T,ExtendsTrue:()=>g,ExtendsUnion:()=>Oo,IsExtendsFalse:()=>TI,IsExtendsTrue:()=>Ic,IsExtendsTrueLike:()=>pn,IsExtendsUnion:()=>xc,Match:()=>U});function Oo(e){return p.Create({"~kind":"ExtendsUnion"},{inferred:e})}function xc(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 Ic(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsTrue")&&s.IsObject(e.inferred)}function T(){return p.Create({"~kind":"ExtendsFalse"},{})}function TI(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],"ExtendsFalse")}function pn(e){return xc(e)||Ic(e)}function U(e,t,n){return pn(e)?t(e.inferred):n()}function kI(e,t,n,r){return U(C(e,n,r),a=>g(p.Assign(p.Assign(e,a),{[t]:n})),()=>T())}function wI(e,t){return g(e)}function EI(e,t,n,r,a){return U(C(e,t,n),i=>U(C(i,t,r),m=>g(m),()=>T()),()=>U(C(e,t,a),i=>g(i),()=>T()))}function RI(e,t,n){let r=Se(n);return C(e,t,r)}function bc(e,t,n){return s.ShiftLeft(n,(r,a)=>U(C(e,t,r),i=>bc(i,t,a),()=>T()),()=>g(e))}function SI(e,t,n){let r=Te(n);return C(e,t,r)}function vc(e,t,n){return s.ShiftLeft(n,(r,a)=>U(C(e,t,r),i=>g(i),()=>vc(e,t,a)),()=>T())}function j(e,t,n){return Z(n)?wI(e,t):V(n)?EI(e,t,n.if,n.then,n.else):ye(n)?RI(e,t,n.enum):Y(n)?kI(e,n.name,t,n.extends):O(n)?bc(e,t,n.allOf):Q(n)?SI(e,t,n.pattern):x(n)?vc(e,t,n.anyOf):ae(n)?g(e):T()}function $c(e,t,n){return Y(n)?j(e,t,n):Z(n)?g(e):ae(n)?g(e):Oo(e)}function OI(e,t){let n=Lt(e),r=Lt(t);return n&&r||!n&&r?!0:!(n&&!r)}function Tc(e,t,n,r){return K(r)?OI(t,r)?C(e,n,r.items):T():j(e,t,r)}function kc(e,t,n){return He(n)?g(e):j(e,t,n)}function wc(e,t,n){return Ae(n)?g(e):j(e,t,n)}function PI(e,t,n,r,a){let i=Y(r)?t:r,m=Y(r)?r:t,u=he(t),l=he(r);return!u&&l?T():U(C(e,i,m),f=>Wn(f,n,a),()=>T())}function AI(e,t,n,r){return s.ShiftLeft(r,(a,i)=>PI(e,t,n,a,i),()=>he(t)?g(e):T())}function CI(e,t,n){return s.ShiftLeft(t,(r,a)=>AI(e,r,a,n),()=>g(e))}function Wn(e,t,n){return CI(e,t,n)}function ba(e,t,n){return Ye(n)?g(e):C(e,t,n)}function Ec(e,t,n,r){return Z(r)?g(e):ae(r)?g(e):oe(r)?U(Wn(e,t,r.parameters),a=>ba(a,n,r.instanceType),()=>T()):T()}function Rc(e,t,n,r,a){return U(C(e,t,a),()=>C(e,n,a),()=>C(e,r,a))}function Sc(e,t,n){let r=Se(t);return C(e,r,n)}function Oc(e,t,n,r){return Z(r)?g(e):ae(r)?g(e):ie(r)?U(Wn(e,t,r.parameters),a=>ba(a,n,r.returnType),()=>T()):T()}function Pc(e,t,n){return xe(n)?g(e):X(n)?g(e):j(e,t,n)}function Ac(e,t,n){let r=z(t);return C(e,r,n)}function va(e,t,n){return t===n?g(e):T()}function MI(e,t,n){return q(n)?va(e,t,n.const):He(n)?g(e):j(e,P(t),n)}function LI(e,t,n){return q(n)?va(e,t,n.const):Ae(n)?g(e):j(e,P(t),n)}function qI(e,t,n){return q(n)?va(e,t,n.const):X(n)?g(e):j(e,P(t),n)}function jI(e,t,n){return q(n)?va(e,t,n.const):Ie(n)?g(e):j(e,P(t),n)}function Cc(e,t,n){return s.IsBigInt(t.const)?MI(e,t.const,n):s.IsBoolean(t.const)?LI(e,t.const,n):s.IsNumber(t.const)?qI(e,t.const,n):s.IsString(t.const)?jI(e,t.const,n):J()}function Mc(e,t,n){return Y(n)?j(e,t,n):g(e)}function Lc(e,t,n){return Xt(n)?g(e):j(e,t,n)}function qc(e,t,n){return X(n)?g(e):j(e,t,n)}function FI(e,t,n){return he(t)?he(n)?g(e):T():g(e)}function DI(e,t,n){return Y(n)&&xt(n.extends)?T():U(C(e,t,n),r=>FI(r,t,n),()=>T())}function GI(e,t){return e.reduce((n,r)=>r in t?pn(t[r])?{...n,...t[r].inferred}:J():J(),{})}function NI(e,t,n){let r={};for(let m of s.Keys(n))r[m]=m in t?DI({},t[m],n[m]):he(n[m])?Y(n[m])?g(p.Assign(e,{[n[m].name]:n[m].extends})):g(e):T();let a=s.Values(r).every(m=>pn(m)),i=a?GI(s.Keys(r),r):{};return a?g(i):T()}function _I(e,t,n){let r=NI(e,t,n);return pn(r)?g(p.Assign(e,r.inferred)):T()}function UI(e,t,n){return _I(e,t,n)}function KI(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 jc(e,t,n,r){return s.ShiftLeft(t,(a,i)=>U(C({},e[a],n),m=>jc(e,i,n,KI(r,m)),()=>T()),()=>g(r))}function zI(e,t,n,r){let a=s.Keys(t);return jc(t,a,r,e)}function Fc(e,t,n){return de(n)?zI(e,t,Le(n),be(n)):L(n)?UI(e,t,n.properties):j(e,v(t),n)}function BI(e,t){return s.IsEqual(s.Keys(t).length,0)?g(e):T()}function VI(e,t,n,r,a){return C(e,n,a)}function Dc(e,t,n,r){return de(r)?VI(e,Kr(t),n,Kr(Le(r)),be(r)):L(r)?BI(e,r.properties):Z(r)?g(e):ae(r)?g(e):T()}function Gc(e,t,n){return Ie(n)?g(e):j(e,t,n)}function Nc(e,t,n){return It(n)?g(e):j(e,t,n)}function _c(e,t,n){let r=Te(t);return C(e,r,n)}function Po(e,t){return p.Create({"~kind":"Inferrable"},{name:e,type:t},{})}function Hn(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 Ao(e){return $t(e)?Y(e.items)?K(e.items.extends)?Po(e.items.name,e.items.extends.items):ae(e.items.extends)?Po(e.items.name,e.items.extends):void 0:J():void 0}function $a(e){return Y(e)?Po(e.name,e.extends):void 0}function Co(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>U(C({},r,t),()=>Co(a,t,[...n,r]),()=>{}),()=>n)}function Uc(e,t,n,r){let a=Co(n,r);return s.IsArray(a)?g(p.Assign(e,{[t]:ee(a)})):T()}function Ta(e,t,n,r){let a=Co(n,r);return s.IsArray(a)?g(p.Assign(e,{[t]:w(a)})):T()}function WI(e){return[...e].reverse()}function Mo(e,t){return t?WI(e):e}function HI(e){let t=e.length>0?e[0]:void 0,n=re(t)?Ao(t):void 0;return re(n)}function YI(e,t,n,r,a,i){return U(C(e,n,a),m=>Kc(m,t,r,i),()=>T())}function JI(e,t,n,r,a){let i=Ao(r);return Hn(i)?Uc(e,i.name,Mo(n,t),i.type):s.ShiftLeft(n,(m,u)=>YI(e,t,m,u,r,a),()=>T())}function ZI(e,t,n,r){return s.ShiftLeft(r,(a,i)=>JI(e,t,n,a,i),()=>s.IsEqual(n.length,0)?g(e):T())}function Kc(e,t,n,r){return ZI(e,t,n,r)}function XI(e,t,n){let r=Et(e,_([],[]),n),a=HI(r);return Kc(e,a,Mo(t,a),Mo(r,a))}function zc(e,t,n){let r=$a(n);return Hn(r)?Ta(e,r.name,t,r.type):s.ShiftLeft(t,(a,i)=>U(C(e,a,n),m=>zc(m,i,n),()=>T()),()=>g(e))}function Bc(e,t,n){let r=Et(e,_([],[]),t);return G(n)?XI(e,r,n.items):K(n)?zc(e,r,n.items):j(e,ee(r),n)}function Vc(e,t,n){return Ye(n)?g(e):an(n)?g(e):j(e,t,n)}function Wc(e,t,n){return s.ShiftLeft(n,(r,a)=>U(C(e,t,r),i=>g(i),()=>Wc(e,t,a)),()=>T())}function Lo(e,t,n){return s.ShiftLeft(t,(r,a)=>U(Wc(e,r,n),i=>Lo(i,a,n),()=>T()),()=>g(e))}function Hc(e,t,n){let r=$a(n);return Hn(r)?Ta(e,r.name,t,r.type):x(n)?Lo(e,t,n.anyOf):Lo(e,t,[n])}function Yc(e,t,n){return Y(n)?j(e,t,n):Z(n)?g(e):ae(n)?g(e):T()}function Jc(e,t,n){return Ye(n)?g(e):j(e,t,n)}function C(e,t,n){return Z(t)?$c(e,t,n):K(t)?Tc(e,t,t.items,n):He(t)?kc(e,t,n):Ae(t)?wc(e,t,n):oe(t)?Ec(e,t.parameters,t.instanceType,n):V(t)?Rc(e,t.if,t.then,t.else,n):ye(t)?Sc(e,t.enum,n):ie(t)?Oc(e,t.parameters,t.returnType,n):xe(t)?Pc(e,t,n):O(t)?Ac(e,t.allOf,n):q(t)?Cc(e,t,n):xt(t)?Mc(e,t,n):Xt(t)?Lc(e,t,n):X(t)?qc(e,t,n):L(t)?Fc(e,t.properties,n):de(t)?Dc(e,Le(t),be(t),n):Ie(t)?Gc(e,t,n):It(t)?Nc(e,t,n):Q(t)?_c(e,t.pattern,n):G(t)?Bc(e,t.items,n):an(t)?Vc(e,t,n):x(t)?Hc(e,t.anyOf,n):ae(t)?Yc(e,t,n):Ye(t)?Jc(e,t,n):T()}function QI(e,t){return z([...e,v(t)])}function qo(e,t,n){return k(e)?p.Update(QI(e,t),{},n):Nn(e,t,n)}function Zc(e,t,n,r,a){let i=Oe(e,t,n),m=Yn(e,t,r);return qo(i,m,a)}function Nn(e,t,n={}){return I("Interface",[e,t],n)}function un(e){return re(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"Interface")}function Xc(e,t,n={}){return qo(e,t,n)}function eb(e,t,n){return e.includes(n)?!0:Jn([...e,n],t,t[n])}function Qc(e,t,n){let r=Sr(n);return _t(e,t,r)}function _t(e,t,n){return s.ShiftLeft(n,(r,a)=>Jn(e,t,r)?!0:_t(e,t,a),()=>!1)}function Jn(e,t,n){return se(n)?eb(e,t,n.$ref):K(n)?Jn(e,t,n.items):oe(n)?_t(e,t,[...n.parameters,n.instanceType]):ie(n)?_t(e,t,[...n.parameters,n.returnType]):un(n)?Qc(e,t,n.parameters[1]):O(n)?_t(e,t,n.allOf):L(n)?Qc(e,t,n.properties):x(n)?_t(e,t,n.anyOf):G(n)?_t(e,t,n.items):de(n)?Jn(e,t,be(n)):!1}function el(e,t,n){return Jn(e,t,n)}function tb(e,t){return t.reduce((n,r)=>el([r],e,e[r])?[...n,r]:n,[])}function tl(e){let t=Rr(e);return tb(e,t)}function nb(e,t,n){return n.includes(t)?n:t in e?Zn(e,e[t],[...n,t]):J()}function nl(e,t,n){let r=Sr(t);return cn(e,r,n)}function cn(e,t,n){return t.reduce((r,a)=>Zn(e,a,r),n)}function Zn(e,t,n){return se(t)?nb(e,t.$ref,n):K(t)?Zn(e,t.items,n):oe(t)?cn(e,[...t.parameters,t.instanceType],n):ie(t)?cn(e,[...t.parameters,t.returnType],n):un(t)?nl(e,t.parameters[1],n):O(t)?cn(e,t.allOf,n):L(t)?nl(e,t.properties,n):x(t)?cn(e,t.anyOf,n):G(t)?cn(e,t.items,n):de(t)?Zn(e,be(t),n):n}function rl(e,t,n){return Zn(e,n,[t])}function rb(e){return Yt()}function ab(e){return s.Keys(e).reduce((t,n)=>({...t,[n]:Ut(e[n])}),{})}function Xn(e){return e.reduce((t,n)=>[...t,Ut(n)],[])}function Ut(e){return se(e)?rb(e.$ref):K(e)?Re(Ut(e.items),Er(e)):oe(e)?Ue(Xn(e.parameters),Ut(e.instanceType)):ie(e)?Ke(Xn(e.parameters),Ut(e.returnType)):O(e)?ge(Xn(e.allOf)):L(e)?v(ab(e.properties)):de(e)?Ur(nn(e),Ut(be(e))):x(e)?w(Xn(e.anyOf)):G(e)?ee(Xn(e.items)):e}function ob(e,t){return t in e?Ut(e[t]):me()}function al(e){return ob(e.$defs,e.$ref)}function ib(e,t,n){let r=Oe(e,_([],[]),t),a=Yn({},_([],[]),n);return z([...r,v(a)])}function sb(e,t){return s.Keys(e).filter(r=>t.includes(r)).reduce((r,a)=>{let i=e[a],m=un(i)?ib(e,i.parameters[0],i.parameters[1]):i;return{...r,[a]:m}},{})}function ol(e,t,n){let r=rl(e,t,n),a=sb(e,r);return Be(a,t)}function il(e,t){return t in e?se(e[t])?il(e,e[t].$ref):e[t]:F()}function Je(e,t){return il(e,t)}function sl(e){return ce(e)?al(e):Or(e)?me():e}function le(e,t,n){let r=sl(t),a=sl(n);return C(e,r,a)}var Ln="equal",mb="disjoint",qn="left-inside",jn="right-inside";function en(e,t){let n=[ae(e)?b.ExtendsFalse():le({},e,t),ae(e)?b.ExtendsTrue({}):le({},t,e)];return b.IsExtendsTrueLike(n[0])&&b.IsExtendsTrueLike(n[1])?Ln:b.IsExtendsTrueLike(n[0])&&b.IsExtendsFalse(n[1])?qn:b.IsExtendsFalse(n[0])&&b.IsExtendsTrueLike(n[1])?jn:mb}function pb(e,t){return t.filter(n=>en(e,n)!==jn)}function ub(e,t){let n=t.some(r=>{let a=en(e,r);return s.IsEqual(a,qn)||s.IsEqual(a,Ln)});return s.IsEqual(n,!1)}function cb(e,t){let n=Me(e);return Z(n)?[n]:ub(n,t)?[...pb(n,t),n]:t}function lb(e){return e.reduce((t,n)=>L(n)?[...t,n]:xt(n)?t:cb(n,t),[])}function lo(e){let t=lb(e);return Dn(t)}function jo(e,t){return p.Update(Me(e),{},t)}function ml(e,t,n,r){let a=d(e,t,n);return jo(a,r)}function Qn(e,t=[]){return gt(e)&&s.IsEqual(e.action,"Conditional")?se(e.parameters[0])?Qn(e.parameters[2],Qn(e.parameters[3],[...t,e.parameters[0].$ref])):Qn(e.parameters[2],Qn(e.parameters[3],t)):gt(e)&&s.IsEqual(e.action,"Mapped")&>(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 db(e,t){return e.reduce((n,r)=>[...n,t.includes(r.name)],[])}function cl(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>s.ShiftLeft(t,(i,m)=>cl(a,m,[...n,[i,r]]),()=>n),()=>n)}function fb(e){return x(e)?[...e.anyOf]:[e]}function hb(e,t){return e.reduce((n,r)=>[...n,[...r,t]],[])}function pl(e,t){return t.reduce((n,r)=>[...n,...hb(e,r)],[])}function ul(e){return e.reduce((t,n)=>s.IsEqual(n[0],!0)?pl(t,fb(n[1])):pl(t,[n[1]]),[[]])}function ll(e,t,n){let r=Qn(n),a=db(e,r),i=cl(t,a);return gt(n)&&s.IsEqual(n.action,"Conditional")||gt(n)&&s.IsEqual(n.action,"Mapped")?ul(i):[t]}function gb(){return["(not-resolvable)",F()]}function yb(){return["(not-generic)",F()]}function xb(e,t,n){return[e,yt(t,n)]}function Ib(e,t,n){return t in e?dl(e,t,e[t],n):gb()}function dl(e,t,n,r){return Ht(n)?xb(t,n.parameters,n.expression):se(n)?Ib(e,n.$ref,r):yb()}function fl(e,t,n){return dl(e,"(anonymous)",t,n)}function bb(e,t,n){if(Y(t)||ln(t)||b.IsExtendsTrueLike(le({},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 hl(e,t,n,r,a){let i=d(e,t,a);return bb(n,i,r),p.Assign(e,{[n]:i})}function vb(e,t,n,r,a){let i=d(e,t,n.extends),m=d(e,t,n.equals);return s.ShiftLeft(a,(u,l)=>Fo(hl(e,t,n.name,i,u),t,r,l),()=>Fo(hl(e,t,n.name,i,m),t,r,[]))}function Fo(e,t,n,r){return s.ShiftLeft(n,(a,i)=>vb(e,t,a,i,r),()=>e)}function gl(e,t,n,r){return Fo(e,t,n,r)}function $b(e){return s.IsGreaterThan(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}function Tb(e,t){return s.IsEqual($b(e),t)}function kb(e,t,n,r,a,i){let m=gl(e,t,r,i),u=d(m,_([...t.callstack,n.$ref],t.visited),a);return d(m,_([],[]),u)}function wb(e,t,n,r,a,i){return i.reduce((m,u)=>[...m,kb(e,t,n,r,a,u)],[])}function Eb(e,t,n,r,a,i){let m=ll(r,i,a),u=wb(e,t,n,r,a,m);return s.IsEqual(u.length,1)?u[0]:we(u)}function ka(e,t,n,r){let a=Oe(e,t,r),i=fl(e,n,r),m=i[0],u=i[1];return Ht(u)?Tb(t,m)?_n(st(m),a):Eb(e,t,st(m),u.parameters,u.expression,a):_n(n,a)}function _n(e,t){return p.Create({"~kind":"Call"},{type:"call",target:e,arguments:t},{})}function yl(e,t){return ka({},_([],[]),e,t)}function ln(e){return y(e,"Call")}function Rb(e){return p.Discard(e,["~immutable"])}function xl(e,t){return p.Update(Rb(e),{},t)}function Il(e,t,n,r){let a=d(e,t,n);return xl(a,r)}function bl(e,t){return e(t)}function vl(e,t){return s.IsString(t)?P(bl(e,t)):P(t)}function $l(e,t){let n=Te(t);return ut(e,n)}function Tl(e,t){let n=t.map(r=>ut(e,r));return w(n)}function ut(e,t){return q(t)?vl(e,t.const):Q(t)?$l(e,t.pattern):x(t)?Tl(e,t.anyOf):t}function Hr(e,t={}){return I("Capitalize",[e],t)}function kl(e,t={}){return Do(e,t)}function Yr(e,t={}){return I("Lowercase",[e],t)}function wl(e,t={}){return Go(e,t)}function Jr(e,t={}){return I("Uncapitalize",[e],t)}function El(e,t={}){return No(e,t)}function Zr(e,t={}){return I("Uppercase",[e],t)}function Rl(e,t={}){return _o(e,t)}var Sb=e=>e[0].toUpperCase()+e.slice(1),Ob=e=>e.toLowerCase(),Pb=e=>e[0].toLowerCase()+e.slice(1),Ab=e=>e.toUpperCase();function Do(e,t){return k([e])?p.Update(ut(Sb,e),{},t):Hr(e,t)}function Go(e,t){return k([e])?p.Update(ut(Ob,e),{},t):Yr(e,t)}function No(e,t){return k([e])?p.Update(ut(Pb,e),{},t):Jr(e,t)}function _o(e,t){return k([e])?p.Update(ut(Ab,e),{},t):Zr(e,t)}function Sl(e,t,n,r){let a=d(e,t,n);return Do(a,r)}function Ol(e,t,n,r){let a=d(e,t,n);return Go(a,r)}function Pl(e,t,n,r){let a=d(e,t,n);return No(a,r)}function Al(e,t,n,r){let a=d(e,t,n);return _o(a,r)}function Xr(e,t,n,r,a={}){return I("Conditional",[e,t,n,r],a)}function Cl(e,t,n,r,a={}){return Uo({},_([],[]),e,t,n,r,a)}function Cb(e,t,n,r,a,i){let m=le(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 Uo(e,t,n,r,a,i,m){return k([n,r])?p.Update(Cb(e,t,n,r,a,i),{},m):Xr(n,r,a,i,m)}function Ml(e,t,n,r,a,i,m){let u=d(e,t,n),l=d(e,t,r);return Uo(e,t,u,l,a,i,m)}function Qr(e,t={}){return I("ConstructorParameters",[e],t)}function Ll(e,t={}){return Ko(e,t)}function Mb(e){let t=oe(e)?e.parameters:[],n=Et({},_([],[]),t);return ee(n)}function Ko(e,t){return k([e])?p.Update(Mb(e),{},t):Qr(e,t)}function ql(e,t,n,r){let a=d(e,t,n);return Ko(a,r)}function ea(e,t,n={}){return I("Exclude",[e,t],n)}function jl(e,t,n={}){return er(e,t,n)}function er(e,t,n){return k([e,t])?p.Update(Nr(e,t),{},n):ea(e,t,n)}function Fl(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return er(i,m,a)}function ta(e,t,n={}){return I("Extract",[e,t],n)}function Dl(e,t,n={}){return zo(e,t,n)}function Lb(e,t){let n=le({},e,t);return b.IsExtendsTrueLike(n)?[e]:[]}function qb(e,t){return e.reduce((n,r)=>[...n,...Lb(r,t)],[])}function Gl(e,t){let n=Me(e),r=x(n)?n.anyOf:[n],a=qb(r,t);return we(a)}function zo(e,t,n){return k([e,t])?p.Update(Gl(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 zo(i,m,a)}function jb(e){return e.reduce((t,n)=>Lr(n)?[...t,P(n)]:t,[])}function dn(e){let t=jb(e);return w(t)}function Un(e,t,n={}){return I("Index",[e,t],n)}function _l(e,t,n={}){let r=s.IsArray(t)?dn(t):t;return Bo(e,r,n)}function Ul(e,t){let n=Je(e,t);return Pe(n)}function Kl(e,t,n){let r=Ne(e,t,n);return Pe(r)}function Fb(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,$)=>({...h,[$]:e[$]}),{}),m=r.reduce((h,$)=>({...h,[$]:t[$]}),{}),u=a.reduce((h,$)=>({...h,[$]:z([e[$],t[$]])}),{}),l=p.Assign(i,m);return p.Assign(l,u)}function zl(e){return e.reduce((t,n)=>Fb(t,Pe(n)),{})}function Bl(e){let t=Js(ee(e));return Pe(t)}function Db(e,t){return s.Keys(e).filter(a=>a in t).reduce((a,i)=>({...a,[i]:we([e[i],t[i]])}),{})}function Vl(e,t){return s.ShiftLeft(e,(n,r)=>Vl(r,Db(t,Pe(n))),()=>t)}function Wl(e){return s.ShiftLeft(e,(t,n)=>Vl(n,Pe(t)),()=>J())}function Pe(e){return ce(e)?Ul(e.$defs,e.$ref):V(e)?Kl(e.if,e.then,e.else):O(e)?zl(e.allOf):x(e)?Wl(e.anyOf):G(e)?Bl(e.items):L(e)?e.properties:{}}function fn(e){let t=Pe(e);return v(t)}var Gb=new RegExp("^(?:0|[1-9][0-9]*)$");function hn(e){let t=`${e}`;return Gb.test(t)?parseInt(t):e}function Nb(e){return P(hn(e))}function Hl(e){return e.map(t=>Yl(t))}function Yl(e){return O(e)?ge(Hl(e.allOf)):x(e)?w(Hl(e.anyOf)):q(e)?Nb(e.const):e}function Jl(e,t){let n=Yl(t),r=le({},n,ke());return b.IsExtendsTrueLike(r)?e:q(t)&&s.IsEqual(t.const,"length")?ke():F()}function Zl(e,t){let n=Je(e,t);return Ee(n)}function Xl(e,t,n){let r=Ne(e,t,n);return Ee(r)}function Ql(e){let t=Se(e);return Ee(t)}function ed(e){let t=z(e);return Ee(t)}function td(e){return[`${e}`]}function nd(e){let t=Te(e);return Ee(t)}function rd(e){return e.reduce((t,n)=>[...t,...Ee(n)],[])}function Ee(e){return ce(e)?Zl(e.$defs,e.$ref):V(e)?Xl(e.if,e.then,e.else):ye(e)?Ql(e.enum):O(e)?ed(e.allOf):q(e)?td(e.const):Q(e)?nd(e.pattern):x(e)?rd(e.anyOf):[]}function gn(e){return Ee(e)}function tr(e,t){return t.map(n=>nr(e,n))}function nr(e,t){return K(t)?Re(nr(e,t.items)):oe(t)?Ue(tr(e,t.parameters),nr(e,t.instanceType)):ie(t)?Ke(tr(e,t.parameters),nr(e,t.returnType)):G(t)?ee(tr(e,t.items)):x(t)?w(tr(e,t.anyOf)):O(t)?ge(tr(e,t.allOf)):Br(t)?v(e):t}function ad(e,t){return nr(e,t)}function _b(e,t){let n=t in e?e[t]:F();return ad(e,n)}function od(e,t){return t.reduce((n,r)=>[...n,_b(e,r)],[])}function Ub(e,t){let n=gn(t),r=od(e,n);return we(r)}var Kb=new RegExp(vt);function zb(e){return e.filter(n=>Kb.test(n))}function Bb(e){let t=Rr(e),n=zb(t),r=od(e,n);return we(r)}function id(e,t){return X(t)?Bb(e):Ub(e,t)}function Vb(e){return P(hn(e))}function sd(e){return e.map(t=>Vo(t))}function Vo(e){return O(e)?ge(sd(e.allOf)):x(e)?w(sd(e.anyOf)):q(e)?Vb(e.const):e}function Wb(e,t){return e.reduceRight((n,r,a)=>{let i=le({},P(a),t);return b.IsExtendsTrueLike(i)?[r,...n]:n},[])}function Hb(e,t){let n=Vo(t),r=Wb(e,n);return mt(r)}function Yb(e){return mt(e)}function md(e,t){return q(t)&&s.IsEqual(t.const,"length")?P(e.length):X(t)||xe(t)?Yb(e):Hb(e,t)}function pd(e,t){return K(e)?Jl(e.items,t):L(e)?id(e.properties,t):G(e)?md(e.items,t):F()}function Jb(e){return ce(e)||V(e)||O(e)||x(e)?fn(e):e}function Bo(e,t,n){return k([e,t])?p.Update(pd(Jb(e),t),{},n):Un(e,t,n)}function ud(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return Bo(i,m,a)}function na(e,t={}){return I("InstanceType",[e],t)}function cd(e,t={}){return Wo(e,t)}function Zb(e){return oe(e)?e.instanceType:F()}function Wo(e,t){return k([e])?p.Update(Zb(e),{},t):na(e,t)}function ld(e,t,n,r={}){let a=d(e,t,n);return Wo(a,r)}function Kn(e,t={}){return I("KeyOf",[e],t)}function dd(e,t={}){return Ho(e,t)}function fd(){return w([ke(),Ce(),Qt()])}function hd(e){return ke()}function Xb(e){return e.reduce((n,r)=>Lr(r)?[...n,P(hn(r))]:J(),[])}function gd(e){let t=s.Keys(e),n=Xb(t);return mt(n)}function yd(e){return nn(e)}function xd(e){let t=e.map((n,r)=>P(r));return mt(t)}function Id(e){return Z(e)?fd():K(e)?hd(e.items):L(e)?gd(e.properties):de(e)?yd(e):G(e)?xd(e.items):F()}function Qb(e){return ce(e)||V(e)||O(e)||x(e)?fn(e):e}function Ho(e,t){return k([e])?p.Update(Id(Qb(e)),{},t):Kn(e,t)}function bd(e,t,n,r){let a=d(e,t,n);return Ho(a,r)}function Gn(e,t,n,r,a={}){return I("Mapped",[e,t,n,r],a)}function vd(e,t,n,r,a={}){return Yo({},_([],[]),e,t,n,r,a)}function ev(e){let t=Te(e);return wa(t)}function tv(e){return e.reduce((t,n)=>[...t,...wa(n)],[])}function nv(e){let t=Se(e);return wa(t)}function rv(e){return s.IsNumber(e)?[P(`${e}`)]:[P(e)]}function wa(e){return ye(e)?nv(e.enum):q(e)?rv(e.const):Q(e)?ev(e.pattern):x(e)?tv(e.anyOf):[e]}function $d(e){return wa(e)}function av(e){return Q(e)?Te(e.pattern):e}function ov(e,t,n,r,a,i){let m=p.Assign(e,{[n.name]:r}),u=d(m,t,a),l=av(u),f=d(m,t,i);return Ps(l)||As(l)?{[l.const]:f}:{}}function iv(e,t,n,r,a,i){return r.reduce((m,u)=>[...m,ov(e,t,n,u,a,i)],[])}function sv(e){return e.reduce((t,n)=>[...t,v(n)],[])}function Td(e,t,n,r,a,i){let m=$d(r),u=iv(e,t,n,m,a,i),l=sv(u);return z(l)}function Yo(e,t,n,r,a,i,m){return k([r])?p.Update(Td(e,t,n,r,a,i),{},m):Gn(n,r,a,i,m)}function kd(e,t,n,r,a,i,m){let u=d(e,t,r);return Yo(e,t,n,u,a,i,m)}function mv(e,t,n){let r=p.Assign(e,t);return s.Keys(t).filter(i=>n.includes(i)).reduce((i,m)=>({...i,[m]:ol(r,m,t[m])}),{})}function pv(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,_([],[]),t[m])}),{})}function uv(e,t,n){let r=tl(t),a=mv(e,t,r),i=pv(e,t,r),m={...a,...i};return p.Update(m,{},n)}function Ea(e,t,n,r){return uv(e,n,r)}function ra(e,t={}){return I("NonNullable",[e],t)}function wd(e,t={}){return Jo(e,t)}function cv(e){let t=w([Zt(),rn()]);return er(e,t,{})}function Jo(e,t){return k([e])?p.Update(cv(e),{},t):ra(e,t)}function Ed(e,t,n,r){let a=d(e,t,n);return Jo(a,r)}function aa(e,t,n={}){return I("Omit",[e,t],n)}function Rd(e,t,n={}){let r=s.IsArray(t)?dn(t):t;return Zo(e,r,n)}function Ra(e){let t=fn(e);return L(t)?t.properties:J()}function lv(e,t){return s.Keys(e).reduce((r,a)=>t.includes(a)?r:{...r,[a]:e[a]},{})}function Sd(e,t){let n=Ra(e),r=gn(t),a=lv(n,r);return v(a)}function Zo(e,t,n){return k([e,t])?p.Update(Sd(e,t),{},n):aa(e,t,n)}function Od(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return Zo(i,m,a)}function oa(e,t={}){return I("Parameters",[e],t)}function Pd(e,t={}){return Xo(e,t)}function dv(e){let t=ie(e)?e.parameters:[],n=Et({},_([],[]),t);return ee(n)}function Xo(e,t){return k([e])?p.Update(dv(e),{},t):oa(e,t)}function Ad(e,t,n,r){let a=d(e,t,n);return Xo(a,r)}function ia(e,t={}){return I("Partial",[e],t)}function Cd(e,t={}){return Qo(e,t)}function Md(e,t){let n=Je(e,t),r=Ze(n);return Be(p.Assign(e,{[t]:r}),t)}function Ld(e,t,n){let r=Ne(e,t,n);return Ze(r)}function qd(e){let t=z(e);return Ze(t)}function jd(e){let t=e.map(n=>Ze(n));return w(t)}function Fd(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:Ct(e[a])}),{});return v(t)}function Ze(e){return ce(e)?Md(e.$defs,e.$ref):V(e)?Ld(e.if,e.then,e.else):O(e)?qd(e.allOf):x(e)?jd(e.anyOf):L(e)?Fd(e.properties):v({})}function Qo(e,t){return k([e])?p.Update(Ze(e),{},t):ia(e,t)}function Dd(e,t,n,r){let a=d(e,t,n);return Qo(a,r)}function sa(e,t,n={}){return I("Pick",[e,t],n)}function Gd(e,t,n={}){let r=s.IsArray(t)?dn(t):t;return ei(e,r,n)}function fv(e,t){return s.Keys(e).reduce((r,a)=>t.includes(a)?p.Assign(r,{[a]:e[a]}):r,{})}function Nd(e,t){let n=Ra(e),r=gn(t),a=fv(n,r);return v(a)}function ei(e,t,n){return k([e,t])?p.Update(Nd(e,t),{},n):sa(e,t,n)}function _d(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return ei(i,m,a)}function ma(e,t={}){return I("ReadonlyObject",[e],t)}function ti(e,t={}){return ni(e,t)}var Ud=ti;function Kd(e){return Jt(Re(e))}function zd(e,t){let n=Je(e,t),r=Xe(n);return Be(p.Assign(e,{[t]:r}),t)}function Bd(e,t,n){let r=Ne(e,t,n);return Xe(r)}function Vd(e){let t=z(e);return Xe(t)}function Wd(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:qt(e[a])}),{});return v(t)}function Hd(e){return Jt(ee(e))}function Yd(e){let t=e.map(n=>Xe(n));return w(t)}function Xe(e){return K(e)?Kd(e.items):ce(e)?zd(e.$defs,e.$ref):V(e)?Bd(e.if,e.then,e.else):O(e)?Vd(e.allOf):L(e)?Wd(e.properties):G(e)?Hd(e.items):x(e)?Yd(e.anyOf):e}function ni(e,t){return k([e])?p.Update(Xe(e),{},t):ma(e)}function Jd(e,t,n,r){let a=d(e,t,n);return ni(a,r)}function Zd(e,t,n,r){return t.visited.includes(r)?n:r in e?d(e,_(t.callstack,[...t.visited,r]),e[r]):n}function Xd(e,t){let n=Je(e,t),r=Qe(n);return Be(p.Assign(e,{[t]:r}),t)}function Qd(e,t,n){let r=Ne(e,t,n);return Qe(r)}function ef(e){let t=z(e);return Qe(t)}function tf(e){let t=e.map(n=>Qe(n));return w(t)}function nf(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:Gr(e[a])}),{});return v(t)}function Qe(e){return ce(e)?Xd(e.$defs,e.$ref):V(e)?Qd(e.if,e.then,e.else):O(e)?ef(e.allOf):x(e)?tf(e.anyOf):L(e)?nf(e.properties):v({})}function pa(e,t={}){return I("Required",[e],t)}function rf(e,t={}){return ri(e,t)}function ri(e,t){return k([e])?p.Update(Qe(e),{},t):pa(e,t)}function af(e,t,n,r){let a=d(e,t,n);return ri(a,r)}function ua(e,t={}){return I("ReturnType",[e],t)}function of(e,t={}){return ai(e,t)}function hv(e){return ie(e)?e.returnType:F()}function ai(e,t){return k([e])?p.Update(hv(e),{},t):ua(e,t)}function sf(e,t,n,r={}){let a=d(e,t,n);return ai(a,r)}function ca(e,t){return I("With",[e,t],{})}function mf(e,t){return oi(e,t)}function oi(e,t){return k([e])?p.Update(e,{},t):ca(e,t)}function pf(e,t,n,r){let a=d(e,t,n);return oi(a,r)}function gv(e){return $t(e)?G(e.items)?ii(e.items.items):Y(e.items)?[e]:se(e.items)?[e]:[F()]:[e]}function ii(e){return e.reduce((n,r)=>[...n,...gv(r)],[])}function _(e,t){return{callstack:e,visited:t}}function k(e){return s.ShiftLeft(e,(t,n)=>se(t)?!1:k(n),()=>!0)}function Yn(e,t,n){return s.Keys(n).reduce((r,a)=>({...r,[a]:d(e,t,n[a])}),{})}function Et(e,t,n){let r=Oe(e,t,n);return ii(r)}function Oe(e,t,n){return n.map(r=>d(e,t,r))}function yv(e,t){let n=he(e)?Rn(t,{}):t,r=jt(e)?En(n,{}):n;return Lt(e)?rr(r,{}):r}function xv(e,t,n,r,a){return s.IsEqual(n,"AddImmutable")?uf(e,t,r[0],a):s.IsEqual(n,"RemoveImmutable")?Il(e,t,r[0],a):s.IsEqual(n,"AddReadonly")?os(e,t,r[0],a):s.IsEqual(n,"RemoveReadonly")?Bs(e,t,r[0],a):s.IsEqual(n,"AddOptional")?is(e,t,r[0],a):s.IsEqual(n,"RemoveOptional")?Hs(e,t,r[0],a):s.IsEqual(n,"Capitalize")?Sl(e,t,r[0],a):s.IsEqual(n,"Conditional")?Ml(e,t,r[0],r[1],r[2],r[3],a):s.IsEqual(n,"ConstructorParameters")?ql(e,t,r[0],a):s.IsEqual(n,"Evaluate")?ml(e,t,r[0],a):s.IsEqual(n,"Exclude")?Fl(e,t,r[0],r[1],a):s.IsEqual(n,"Extract")?Nl(e,t,r[0],r[1],a):s.IsEqual(n,"Index")?ud(e,t,r[0],r[1],a):s.IsEqual(n,"InstanceType")?ld(e,t,r[0],a):s.IsEqual(n,"Interface")?Zc(e,t,r[0],r[1],a):s.IsEqual(n,"KeyOf")?bd(e,t,r[0],a):s.IsEqual(n,"Lowercase")?Ol(e,t,r[0],a):s.IsEqual(n,"Mapped")?kd(e,t,r[0],r[1],r[2],r[3],a):s.IsEqual(n,"Module")?Ea(e,t,r[0],a):s.IsEqual(n,"NonNullable")?Ed(e,t,r[0],a):s.IsEqual(n,"Pick")?_d(e,t,r[0],r[1],a):s.IsEqual(n,"Parameters")?Ad(e,t,r[0],a):s.IsEqual(n,"Partial")?Dd(e,t,r[0],a):s.IsEqual(n,"Omit")?Od(e,t,r[0],r[1],a):s.IsEqual(n,"ReadonlyObject")?Jd(e,t,r[0],a):s.IsEqual(n,"Record")?cm(e,t,r[0],r[1],a):s.IsEqual(n,"Required")?af(e,t,r[0],a):s.IsEqual(n,"ReturnType")?sf(e,t,r[0],a):s.IsEqual(n,"TemplateLiteral")?hc(e,t,r[0],a):s.IsEqual(n,"Uncapitalize")?Pl(e,t,r[0],a):s.IsEqual(n,"Uppercase")?Al(e,t,r[0],a):s.IsEqual(n,"With")?pf(e,t,r[0],r[1]):I(n,r,a)}function Iv(e,t,n){let r=se(n)?Zd(e,t,n,n.$ref):K(n)?Re(d(e,t,n.items),Er(n)):ln(n)?ka(e,t,n.target,n.arguments):oe(n)?Ue(Oe(e,t,n.parameters),d(e,t,n.instanceType),ss(n)):ie(n)?Ke(Oe(e,t,n.parameters),d(e,t,n.returnType),ms(n)):V(n)?Mt(d(e,t,n.if),d(e,t,n.then),d(e,t,n.else),fs(n)):O(n)?ge(Oe(e,t,n.allOf),Is(n)):L(n)?v(Yn(e,t,n.properties),ls(n)):de(n)?lm(Le(n),d(e,t,be(n))):$t(n)?Gt(d(e,t,n.items)):G(n)?ee(Et(e,t,n.items),zs(n)):x(n)?w(Oe(e,t,n.anyOf),Ms(n)):n;return yv(n,r)}function d(e,t,n){return gt(n)?xv(e,t,n.action,n.parameters,n.options):Iv(e,t,n)}function si(e,t){return d(e,_([],[]),t)}function bv(e){return p.Update(e,{"~immutable":!0},{})}function rr(e,t){return p.Update(bv(e),{},t)}function uf(e,t,n,r){let a=d(e,t,n);return rr(a,r)}function du(e,t={}){return I("AddImmutable",[e],t)}function Jt(e,t={}){return rr(e,t)}function fu(e,t={}){return I("Evaluate",[e],t)}function cf(e,t={}){return jo(e,t)}function hu(e,t={}){return I("Module",[e],t)}function lf(e,t={}){return Ea({},_([],[]),e,t)}function df(...e){let[t,n,r]=Ve.Match(e,{2:(m,u)=>s.IsString(m)?[{},m,u]:[m,u,{}],3:(m,u,l)=>[m,u,l],1:m=>[{},m,{}]}),a=uc(n),i=s.IsArray(a)&&s.IsEqual(a.length,2)?d(t,_([],[]),a[0]):F();return p.Update(i,{},r)}var D={};St(D,{Any:()=>Yt,Array:()=>Re,BigInt:()=>An,Boolean:()=>Cr,Call:()=>yl,Capitalize:()=>kl,Codec:()=>Ar,Conditional:()=>Cl,Constructor:()=>Ue,ConstructorParameters:()=>Ll,Cyclic:()=>Be,Decode:()=>Ts,DecodeBuilder:()=>Pn,Dependent:()=>Mt,Encode:()=>ks,EncodeBuilder:()=>On,Enum:()=>xs,Evaluate:()=>cf,Exclude:()=>jl,Extends:()=>le,ExtendsResult:()=>b,Extract:()=>Dl,Function:()=>Ke,Generic:()=>yt,Identifier:()=>Cn,Immutable:()=>ws,Index:()=>_l,Infer:()=>Sn,InstanceType:()=>cd,Instantiate:()=>si,Integer:()=>Ft,Interface:()=>Xc,Intersect:()=>ge,IsAny:()=>Z,IsArray:()=>K,IsBigInt:()=>He,IsBoolean:()=>Ae,IsCall:()=>ln,IsCodec:()=>Pr,IsConstructor:()=>oe,IsCyclic:()=>ce,IsDependent:()=>V,IsEnum:()=>ye,IsEnumValue:()=>ys,IsFunction:()=>ie,IsGeneric:()=>Ht,IsIdentifier:()=>Os,IsImmutable:()=>Lt,IsInfer:()=>Y,IsInteger:()=>xe,IsIntersect:()=>O,IsKind:()=>y,IsLiteral:()=>q,IsNever:()=>xt,IsNull:()=>Xt,IsNumber:()=>X,IsObject:()=>L,IsOptional:()=>he,IsParameter:()=>Cs,IsReadonly:()=>jt,IsRecord:()=>de,IsRef:()=>se,IsRefine:()=>io,IsRest:()=>$t,IsSchema:()=>re,IsString:()=>Ie,IsSymbol:()=>It,IsTemplateLiteral:()=>Q,IsThis:()=>Br,IsTuple:()=>G,IsUndefined:()=>an,IsUnion:()=>x,IsUnknown:()=>ae,IsUnsafe:()=>Or,IsVoid:()=>Ye,KeyOf:()=>dd,Literal:()=>P,Lowercase:()=>wl,Mapped:()=>vd,Module:()=>lf,Never:()=>F,NonNullable:()=>wd,Null:()=>Zt,Number:()=>ke,Object:()=>v,Omit:()=>Rd,Optional:()=>us,Parameter:()=>Dt,Parameters:()=>Pd,Partial:()=>Cd,Pick:()=>Gd,Readonly:()=>Es,ReadonlyObject:()=>ti,ReadonlyType:()=>Ud,Record:()=>Ur,RecordKey:()=>nn,RecordPattern:()=>Le,RecordValue:()=>be,Ref:()=>st,Refine:()=>Rs,Required:()=>rf,Rest:()=>Gt,ReturnType:()=>of,Script:()=>df,String:()=>Ce,Symbol:()=>Qt,TemplateLiteral:()=>yc,This:()=>zr,Tuple:()=>ee,Uncapitalize:()=>El,Undefined:()=>rn,Union:()=>w,Unknown:()=>me,Unsafe:()=>ds,Uppercase:()=>Rl,Void:()=>Vr,With:()=>mf});var ar="submit_test_gap_candidates",or="submit_filtered_test_gaps",ir="submit_solver_gaps",a8=D.Object({verdict:D.Union([D.Literal("PASS"),D.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:D.String({description:"One short sentence summarizing the verdict."}),reasons:D.Array(D.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:D.Array(D.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 vv=D.Object({statement:D.String({description:"One sentence from agent_prompt.md, copied verbatim."}),gaps:D.Array(D.Object({description:D.String({description:"A fair, publicly observable missing behavioral test."}),risk:D.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 ff(e){return{name:ar,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:vv,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 $v=D.Object({gaps:D.Array(D.Object({description:D.String({description:"The confirmed, real, fair test gap (may be reworded for clarity). Keep POSITIVE:/NEGATIVE: prefix when applicable."}),justification:D.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 hf(e){return{name:or,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:$v,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 Tv=D.Object({gaps:D.Array(D.Object({description:D.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:D.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:D.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 gf(e){return{name:ir,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:Tv,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 kv(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 wv=["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."],yf=["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."],xf=yf,Ev=yf;function If(e,t){let n=[...kv("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.","",...wv,"",...xf,"","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 \`${ar}\` 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(`
|
|
12
|
+
`)}function bf(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.","",...Ev),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 \`${or}\` 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(`
|
|
13
|
+
`)}function vf(){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(`
|
|
14
|
+
`)}function Rv(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 \`${vn}/solver_${e.index}/\``}function $f(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 \`${vn}/solver_<index>/\` (\`solution.diff\`, \`test_output.txt\`), with a \`${vn}/manifest.json\` summary. Use read/grep/find/ls to open exactly what you need. Status summary:`,"",...e.map(Rv),"","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.","",...xf,"- 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 \`${ir}\` tool exactly once with your final list (which may be empty). That tool call is your only way to report a result.`),r.join(`
|
|
15
|
+
`)}var Sv=900*1e3,mi=["read","grep","find","ls"];function Pa(e){return e==="off"?void 0:e}async function Aa(e,t,n=Sv){let r=t.aborted?"cancelled":"done";return await Promise.race([e().then(()=>{t.aborted||(r="done")}),new Promise(a=>{setTimeout(()=>{r="timedOut",a()},n)}),new Promise(a=>{if(t.aborted)return a();t.addEventListener("abort",()=>{r="cancelled",a()},{once:!0})})]),r}async function Ca(e){let t={},n=e.model,{session:r}=await Sa({cwd:e.tempDir,model:n,thinkingLevel:Pa(e.thinkingLevel),tools:[...mi,ar],customTools:[ff(t)],sessionManager:Oa.inMemory()});try{let a=await Aa(async()=>{await r.prompt(If(e.testRubric,e.fairnessRules))},e.cancelSignal);if(a!=="done")return await r.abort(),{status:a,gaps:[]}}catch{return{status:"error",gaps:[]}}return t.statements?{status:"ok",gaps:t.statements}:{status:"noSubmission",gaps:[]}}var Ov=["read","grep","find","ls","write","edit","bash"];async function Tf(e){let t=e.model;try{let n=Oa.inMemory(),{session:r}=await Sa({cwd:e.solverDir,model:t,thinkingLevel:Pa(e.thinkingLevel),tools:[...Ov],sessionManager:n}),a=await Aa(async()=>{await r.prompt(vf())},e.cancelSignal,e.timeoutMinutes*60*1e3);return a!=="done"&&await r.abort(),{outcome:a,trajectory:n.getEntries()}}catch{return{outcome:"error",trajectory:[]}}}async function kf(e){let t={},n=e.model,{session:r}=await Sa({cwd:e.tempDir,model:n,thinkingLevel:Pa(e.thinkingLevel),tools:[...mi,ir],customTools:[gf(t)],sessionManager:Oa.inMemory()});try{let a=await Aa(async()=>{await r.prompt($f(e.solverResults,e.testRubric,e.fairnessRules))},e.cancelSignal);if(a!=="done")return await r.abort(),{status:a,gaps:[]}}catch{return{status:"error",gaps:[]}}return t.gaps?{status:"ok",gaps:t.gaps}:{status:"noSubmission",gaps:[]}}async function Ma(e){let t={},n=e.model,{session:r}=await Sa({cwd:e.tempDir,model:n,thinkingLevel:Pa(e.thinkingLevel),tools:[...mi,or],customTools:[hf(t)],sessionManager:Oa.inMemory()});try{let a=await Aa(async()=>{await r.prompt(bf(e.statementReports,e.testRubric,e.fairnessRules))},e.cancelSignal);if(a!=="done")return await r.abort(),{status:a,gaps:[]}}catch{return{status:"error",gaps:[]}}return t.gaps?{status:"ok",gaps:t.gaps}:{status:"noSubmission",gaps:[]}}var Rt="checks_progress";function sr(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 Pv,readFileSync as Av}from"node:fs";var pi=["agent_prompt.md","solution.patch","test.patch"];function ui(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 wf(e){try{if(!Pv(e))return{};let t=JSON.parse(Av(e,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function Ef(e){let t={...e.existingReport,timestamp:ui(),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 Rf(e){let t=Math.round(e/1e3);return t>=60?`${Math.floor(t/60)}m ${t%60}s`:`${t}s`}function Sf(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 Of=`## The problem description (aka the task)\r
|
|
16
16
|
P1: Aligns with the repo's philosophy\r
|
|
17
17
|
P2: Self-contained \u2014 solvable from the repo and description alone\r
|
|
18
18
|
P3: Clear, concise, and unambiguous \u2014 describes what to build or fix and don't leave points for guessing\r
|
|
@@ -39,7 +39,7 @@ That's the golden solution \u2014 the proof that your task is solvable and that
|
|
|
39
39
|
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
|
|
40
40
|
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
|
|
41
41
|
S3: No irrelevant changes to the code \u2014 if something is unrelated to your task, keep it as it is.\r
|
|
42
|
-
S4: No AI slop (weird comments, unexplained defensive code, new coding patterns, etc).`,
|
|
42
|
+
S4: No AI slop (weird comments, unexplained defensive code, new coding patterns, etc).`,Cv=`# Agent Evaluation Guidelines\r
|
|
43
43
|
\r
|
|
44
44
|
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
|
|
45
45
|
\r
|
|
@@ -324,9 +324,9 @@ Keep changes separated when possible:\r
|
|
|
324
324
|
- Avoid unrelated dependency or lockfile changes.\r
|
|
325
325
|
- Regenerate patches after every prompt/test/solution change.\r
|
|
326
326
|
\r
|
|
327
|
-
---`;function La(){return(
|
|
328
|
-
`).trim(),te=H?
|
|
329
|
-
`)):["(no output)"];if(!n.expanded){let ue=Math.max(0,te.length-
|
|
327
|
+
---`;function La(){return(Of.split(/\r?\n(?=## )/g).find(t=>/^## The tests/i.test(t.trim()))??Of).trim()}function qa(){return Cv.trim()}var ja=!1,yn;function Fa(){return ja}function Pf(){return ja=!0,yn=new AbortController,yn}function Af(){ja=!1,yn=void 0}function Cf(){return!ja||!yn||yn.signal.aborted?!1:(yn.abort(),!0)}import{existsSync as Mv}from"node:fs";import{join as Lv}from"node:path";import{keyHint as qv}from"@earendil-works/pi-coding-agent";import{Text as jv,wrapTextWithAnsi as Fv}from"@earendil-works/pi-tui";var mr="analyze_test_gaps",Mf=6;function Lf(e){e.registerTool({name:mr,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:D.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 jv("",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?Nv(u-i.startedAt):"\u2014",f=t.details,h=Array.isArray(f?.testGaps)?f.testGaps.length:void 0,$=[`${m} ${l}`];h!==void 0&&$.push(`${h} gap${h===1?"":"s"}`);let E=r.fg("toolTitle",r.bold("Gap Finder"))+r.fg("muted",` ${$.join(" \xB7 ")}`),H=(t.content??[]).map(ue=>ue.type==="text"?ue.text:"").join(`
|
|
328
|
+
`).trim(),te=H?Dv(H.split(`
|
|
329
|
+
`)):["(no output)"];if(!n.expanded){let ue=Math.max(0,te.length-Mf);te=te.slice(0,Mf),ue>0&&te.push(`... (${ue} more lines, ${qv("app.tools.expand","to expand")})`)}let ne=a.lastComponent instanceof Da?a.lastComponent:new Da;return ne.setContent(E,te,r),ne},async execute(t,n,r,a,i){if(!fr(i.cwd))throw new Error("analyze_test_gaps is disabled for this project. Enable it with /analyze:on.");let m=Lv(i.cwd,"agent_prompt.md");if(!Mv(m))throw new Error("Missing required file in project root: agent_prompt.md");let u=ji()??ve(),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",$=new AbortController;r&&(r.aborted?$.abort():r.addEventListener("abort",()=>$.abort(),{once:!0}));let E={tempDir:i.cwd,model:f,thinkingLevel:h,testRubric:La(),fairnessRules:qa(),cancelSignal:$.signal};a?.({content:[{type:"text",text:"Finding behavioral test gaps sentence by sentence..."}],details:{}});let A=await Ca(E);if($.signal.aborted)throw new Error("Cancelled by user.");if(A.status!=="ok")throw new Error(`Gap finder did not complete (status: ${A.status}).`);let H=A.gaps.reduce((ne,ue)=>ne+ue.gaps.length,0),te=[];if(H>0){a?.({content:[{type:"text",text:`Validating ${H} candidate gap(s)...`}],details:{}});let ne=await Ma({...E,statementReports:A.gaps});if($.signal.aborted)throw new Error("Cancelled by user.");if(ne.status!=="ok")throw new Error(`Gap review did not complete (status: ${ne.status}).`);te=ne.gaps}return{content:[{type:"text",text:_v(te)}],details:{testGaps:te}}}})}function Dv(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 Da=class{header="";styledLines=[];theme;cachedWidth=-1;cachedLines=[];setContent(t,n,r){this.header=t,this.styledLines=n.map(a=>Gv(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(...Fv(a,t)):r.push(a);this.cachedLines=r,this.cachedWidth=t}return this.cachedLines}};function Gv(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 Nv(e){return`${Math.floor(e/1e3)}s`}function _v(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}
|
|
330
330
|
Justification: ${n.justification}`)].join(`
|
|
331
|
-
`)}var Ga=!1,
|
|
332
|
-
`),"info");return}let a=[...new Set(r.split(/\s+/).filter(Boolean))],i=new Set(gi.map(N=>N.value)),m=a.filter(N=>!i.has(N));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
|
|
331
|
+
`)}var Ga=!1,qf=!1,Kt=!1;function ci(e){return e.getActiveTools().map(n=>typeof n=="string"?n:n.name)}function li(){return Ga}function Uv(e){return ci(e).includes(mr)}function Na(e){return li()!==Uv(e)}function Kv(e){qf||(Lf(e),qf=!0)}function zv(e,t){let n=ci(e);if(t){if(n.length===0){Kt=!0;return}let r=new Set(n);r.add(mr),r.size!==n.length&&e.setActiveTools([...r])}else{let r=n.filter(a=>a!==mr);r.length!==n.length&&e.setActiveTools(r)}Kt=Na(e)}function xn(e){let t=li();t&&Kv(e),zv(e,t)}function di(e,t){Ga=lr(t),Kt=!0,jf(e)}function jf(e,t=0){let n=li(),r=ci(e);if(n&&r.length===0&&t<8){queueMicrotask(()=>jf(e,t+1));return}xn(e)}function Ff(e){for(let t of[0,50,150,400])setTimeout(()=>{(Kt||Na(e))&&xn(e)},t)}function Df(){return Kt}function fi(e,t,n){Ga=n,dr(t,n),Kt=!0,xn(e)}function Gf(e,t){Ga=lr(t),Kt=!0,xn(e)}var Zv="Ctrl+Shift+X",gi=[{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 Xv(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=gi.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 hi(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 $=a.find(H=>H.provider===h.provider&&H.id===h.modelId),E=t?.provider===h.provider&&t?.modelId===h.modelId,A=$?`${$.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 In(e,t,n){let r=e.modelRegistry.getAll().find(a=>a.provider===t&&a.id===n);return Li(r)}var _a={provider:"",modelId:"",thinkingLevel:"off",timeoutMinutes:Wa,solverCount:Ya,saveArtifacts:Ja},Ua={provider:"",modelId:"",thinkingLevel:"off"};function Bf(e,t,n,r){let a=t?In(e,t.provider,t.modelId):["off"],i=n.provider?In(e,n.provider,n.modelId):["off"],m=r.provider?In(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-Ha+1},(u,l)=>`${Ha+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:fr(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 yi=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=Bf(t,ve(),ve()?.solverGap??_a,ve()?.analyzeGap??Ua)}selectedIndex=0;rows;refresh(){let t=ve();this.rows=Bf(this.ctx,t,t?.solverGap??_a,t?.analyzeGap??Ua),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),$=this.settingsListTheme.value(m.value,u);n.push(`${l}${h} ${$}`)}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=ve();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??_a,i=r.analyzeGap??Ua,m=n.values.indexOf(n.value),u=n.values[(m+1)%n.values.length];if(u===void 0)return;n.id==="reviewer-thinking"?Fe({...r,thinkingLevel:u,solverGap:a,analyzeGap:i}):n.id==="solvergap-thinking"?Fe({...r,solverGap:{...a,thinkingLevel:u}}):n.id==="solvergap-timeout"?Fe({...r,solverGap:{...a,timeoutMinutes:Number.parseInt(u,10)}}):n.id==="solvergap-solver-count"?Fe({...r,solverGap:{...a,solverCount:Number.parseInt(u,10)}}):n.id==="solvergap-save-artifacts"?Fe({...r,solverGap:{...a,saveArtifacts:u==="on"}}):n.id==="analyze-enabled"?dr(this.ctx.cwd,u==="on"):n.id==="analyze-thinking"&&Fe({...r,analyzeGap:{...i,thinkingLevel:u}}),this.refresh(),this.onCycleSaved()}}};async function Qv(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 $=new yi(t,Hv(),l,()=>{Gf(e,t.cwd),u.requestRender()},A=>h(A),()=>h(void 0));$.selectedIndex=n;let E=new Yv;return E.addChild(new zf(l.bold(l.fg("accent","Checks settings")))),E.addChild({render:A=>$.render(A),invalidate:()=>$.invalidate()}),E.addChild(new Jv(1)),E.addChild(new zf(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){$.handleInput(A),n=$.selectedIndex,u.requestRender()}}});if(!r)return;let a=ve(),i=a?.solverGap??_a,m=a?.analyzeGap??Ua;if(r==="reviewer-model"){let u=await hi(t,a,"Select reviewer model");if(!u)continue;let l=In(t,u.provider,u.modelId),f=l.includes(a?.thinkingLevel??"off")?a?.thinkingLevel??"off":l[0]??"off";Fe({...u,thinkingLevel:f,solverGap:i,analyzeGap:m,enabledProjects:a?.enabledProjects??Xa(),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 hi(t,i.provider?i:null,"Select solver model");if(!u)continue;let l=In(t,u.provider,u.modelId),f=l.includes(i.thinkingLevel)?i.thinkingLevel:l[0]??"off";Fe({...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 hi(t,m.provider?m:null,"Select analyze tool model");if(!u)continue;let l=In(t,u.provider,u.modelId),f=l.includes(m.thinkingLevel)?m.thinkingLevel:l[0]??"off";Fe({...a,analyzeGap:{...m,...u,thinkingLevel:f}}),t.ui.notify(`Analyze tool model saved: ${u.provider}/${u.modelId}`,"info")}}}function Vf(e){e.registerCommand("checks",{description:"Find behavioral gaps in test coverage. Requires an option \u2014 see /checks.",getArgumentCompletions:Xv,handler:async(t,n)=>{let r=t.trim();if(!r){n.ui.notify(gi.map(N=>`${N.value} \u2014 ${N.description}`).join(`
|
|
332
|
+
`),"info");return}let a=[...new Set(r.split(/\s+/).filter(Boolean))],i=new Set(gi.map(N=>N.value)),m=a.filter(N=>!i.has(N));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 Qv(e,n);return}let u=a.includes("--gap-finder"),l=a.includes("--solver-gap-finder");if(!u&&!l)return;if(Fa()){n.ui.notify("A checks run is already in progress.","warning");return}let f=ve();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 $=pi.filter(N=>!_f(et(n.cwd,N)));if($.length){n.ui.notify(`Missing required file(s): ${$.join(", ")}`,"error");return}let E=null,A;if(l){if(E=qi(),!E||!_f(et(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 H=Pf(),te=E?.solverCount??0,ne=(u?2:0)+(l?te+1:0);n.ui.setWidget(Rt,sr("preparing clean snapshot",0,ne)),n.ui.notify(`gap finders (${a.join(" ")}) started. Press ${Zv} to cancel.`,"info");let ue,tt=[];try{let N=et(Kf(),`checks-${Nf()}`);Uf(N,{recursive:!0}),ue=N;let nt=await xr(e,n.cwd,N);if(nt.status==="error"){n.ui.notify(`checks: ${nt.error}`,"error");return}for(let qe of pi)Bv(et(n.cwd,qe),et(N,qe));let _e=La(),ct=qa(),rt=0,lt={status:"ok",gaps:[]},Vt={status:"ok",gaps:[]};if(u){let qe={tempDir:N,model:h,thinkingLevel:f.thinkingLevel,testRubric:_e,fairnessRules:ct,cancelSignal:H.signal};if(n.ui.setWidget(Rt,sr("finding sentence-by-sentence test gaps",rt,ne)),lt=await Ca(qe),rt+=1,n.ui.setWidget(Rt,sr("reviewing test gaps",rt,ne)),lt.gaps.reduce((za,Ba)=>za+Ba.gaps.length,0)>0&&(Vt=await Ma({...qe,statementReports:lt.gaps})),rt+=1,H.signal.aborted){n.ui.notify("checks: cancelled.","warning");return}}let dt=[],pr={status:"ok",gaps:[]};if(l&&E){let qe=[],Ka=at=>{qe.push(at),rt+=1,n.ui.setWidget(Rt,sr("solver gap finder: solving",rt,ne,{passed:qe.filter(je=>je.passed).length,failed:qe.filter(je=>!je.passed).length}))},za=await Promise.all(Array.from({length:te},async(at,je)=>{let bn=et(Kf(),`checks-solvergap-${Nf()}`);return Uf(bn,{recursive:!0}),tt.push(bn),{index:je+1,setup:await Ni({pi:e,repoDir:n.cwd,solverDir:bn,testPatchPath:et(n.cwd,"test.patch"),agentPromptPath:et(n.cwd,"agent_prompt.md")})}})),Ba=ui().replace(/[:.]/g,"-");if(dt=await Promise.all(za.map(async({index:at,setup:je})=>{if(je.status!=="ok"){let ki={index:at,status:je.status,passed:!1,diff:"",testOutputTail:je.error,durationMs:0,totalTests:null,failedTests:null};return Ka(ki),ki}let bn=Date.now(),{outcome:$i,trajectory:Yf}=await Tf({pi:e,solverDir:je.solverDir,model:A,thinkingLevel:E.thinkingLevel,timeoutMinutes:E.timeoutMinutes,cancelSignal:H.signal}),{testOutputXmlPath:Jf,...Va}=await _i({pi:e,index:at,workspace:je,status:$i==="done"?"ok":$i,durationMs:Date.now()-bn}),Zf=E.saveArtifacts?Ui({repoDir:n.cwd,runId:Ba,index:at,trajectory:Yf,solutionPatch:Va.diff,testOutputXmlPath:Jf,testOutputTail:Va.testOutputTail}):void 0,Ti={...Va,artifactsDir:Zf};return Ka(Ti),Ti})),dt.some(at=>at.status!=="patchFailed"&&at.status!=="error")&&(Ki(N,dt),pr=await kf({tempDir:N,model:h,thinkingLevel:f.thinkingLevel,solverResults:dt,testRubric:_e,fairnessRules:ct,cancelSignal:H.signal})),rt+=1,H.signal.aborted){n.ui.notify("checks: cancelled.","warning");return}}let Hf=u&&(lt.status!=="ok"||lt.gaps.length>0&&Vt.status!=="ok"),Ii=Ef({existingReport:wf(et(n.cwd,"shipd_report.json")),config:f,runGapFinder:u,testGaps:Vt.gaps,gapAnalysisIncomplete:Hf,gapFinderStatus:lt.status,gapFilterStatus:Vt.status,runSolverGapFinder:l,solverResults:dt,solverGaps:pr.gaps,solverGapAnalysisIncomplete:l&&(dt.some(qe=>qe.status==="error")||pr.status!=="ok"),solverComparisonStatus:pr.status}),bi=Sf({merged:Ii,runGapFinder:u,runSolverGapFinder:l});e.sendMessage({customType:"shipd_checks_report",content:bi.content,display:!0,details:bi.details});let vi=et(n.cwd,"shipd_report.json");Wv(vi,JSON.stringify(Ii,null,2),"utf-8"),n.ui.notify(`checks: wrote details to ${vi}`,"info")}catch(N){n.ui.notify(`checks failed: ${N instanceof Error?N.message:String(N)}`,"error")}finally{n.ui.setWidget(Rt,void 0),ue&&Vv(ue,{recursive:!0,force:!0});for(let N of tt)zi(N);Af()}}})}var Wf=t$.ctrlShift("x");function r$(e){e.registerCommand("analyze:on",{description:"Enable the Gap Finder tool for this project folder",handler:async(t,n)=>{fi(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)=>{fi(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 e$;i.addChild(new xi(r.bold(r.fg("accent","Checks")),0,0));let m=!1,u=l=>{i.addChild(new xi(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 n$(1)),u(r.bold(r.fg("accent","Solver gap finder")));for(let A of l){let H=A.passed?r.fg("success","\u2713"):r.fg("error","\u2717"),te=A.passed?"passed":A.status==="ok"?"failed tests":A.status;u(` ${H} Solver ${A.index}: ${te} (${Rf(A.durationMs)})`)}let $=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(` ${$}, ${E}`)}return m||i.addChild(new xi(r.fg("dim"," nothing to report"),0,0)),i}),e.registerShortcut(Wf,{description:"Cancel an in-progress /checks run",handler:t=>{Fa()&&Cf()&&(t.ui.setWidget(Rt,[`checks: cancelling (${Wf})...`]),t.ui.notify("checks: cancelling...","warning"))}}),a$(e),Vf(e)}function a$(e){e.on("session_start",(t,n)=>{di(e,n.cwd),(t.reason==="resume"||t.reason==="reload"||t.reason==="startup")&&Ff(e)}),e.on("session_tree",async(t,n)=>{di(e,n.cwd)}),e.on("before_agent_start",()=>{!Df()&&!Na(e)||xn(e)})}export{r$ as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sreetej510/pi-shipd-checks",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28",
|
|
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",
|